Fix finam-trade plugin compliance with teleton-agent plugin loader#169
Fix finam-trade plugin compliance with teleton-agent plugin loader#169xlabtg merged 3 commits intoxlabtg:mainfrom
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: xlabtg#168
- manifest export: name changed from "Finam Trade Pro" to "finam-trade" to pass Zod /^[a-z0-9][a-z0-9-]*$/ validation in plugin-validator.ts - manifest export: author changed from object to string as required by ManifestSchema (z.string().max(128)) - manifest export: stripped fields not in ManifestSchema (id, license, entry, teleton, permissions, tags, tools, repository, funding) to keep the inline manifest minimal and schema-compliant - start(): use activeRuntime directly instead of getRuntime(ctx?.sdk), since the PluginContext passed by the agent has no sdk field; also use ctx.log (the prefixed logger provided by the loader) for log calls - getRuntime(): guard against null activeRuntime before identity check to prevent a TypeError when sdk is undefined - grpc.js: replace eager top-level import of @grpc/grpc-js and @grpc/proto-loader with lazy createRequire() calls via property getters, so the module loads without the optional gRPC packages installed and only resolves them when the renewal stream is actually started All 16 plugin tests pass; validate-plugins reports 27 tools, 0 errors.
Solution summaryAll done. Here's a summary of what was found and fixed: Root causes identified and fixedBy reading the teleton-agent source directly (
All 16 plugin tests pass, This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $2.876294📊 Context and tokens usage:Claude Sonnet 4.6:
Total: (93.5K + 6.9M cached) input tokens, 22.9K output tokens, $2.777573 cost Claude Haiku 4.5:
Total: (46.8K + 261.4K cached) input tokens, 2.8K output tokens, $0.098721 cost 🤖 Models used:
📎 Log file uploaded as Gist (2847KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit 51dc1cf.
Fixes #168.
Root Cause Analysis
After reviewing the teleton-agent source (
src/agent/tools/plugin-validator.ts,src/agent/tools/plugin-loader.ts,src/webui/services/marketplace.ts), the following issues were found that prevented the plugin from installing or working correctly:Issues Fixed
1. Manifest
namefailed Zod validationThe inline
manifestexport inindex.jshadname: "Finam Trade Pro". The agent'sManifestSchemavalidates name against/^[a-z0-9][a-z0-9-]*$/— spaces and uppercase letters fail. Result: the manifest was silently discarded, the plugin loaded with fallback metadata, and the Zod validation warning was logged.Fix: Changed
nameto"finam-trade"(the plugin folder ID).2. Manifest
authorfailed Zod validationauthor: { name: "Teleton Community", url: "..." }is an object; the schema requiresz.string().max(128). Same silent discard.Fix: Changed to
author: "Teleton Community".3. Manifest contained non-schema fields
id,license,entry,teleton,permissions,tags,tools,repository,fundingare not part ofManifestSchema. They're stripped by Zod's default behavior but bloated the inline manifest unnecessarily.Fix: Removed all fields not in
ManifestSchemafrom the inline export. Themanifest.jsonfile retains full metadata for the registry/marketplace.4.
start()crashed with TypeError when called by the agentThe agent's
adaptPluginwrapsstart(ctx)and passes anEnhancedPluginContextthat has{ bridge, db, config, pluginConfig, log }— nosdkfield. The plugin calledgetRuntime(ctx?.sdk)→getRuntime(undefined). IngetRuntime,null?.sdk === undefinedwastrue(wrong guard), returningnull, thennull.configthrew a TypeError. This was caught by the loader wrapper and logged as an error, but thestartfunction never completed.Fix:
activeRuntime ?? getRuntime(ctx?.sdk)— reuse the runtime already built bytools(sdk), which is called beforestart.ctx?.log(the prefixed logger from the loader) for log calls.getRuntimewithactiveRuntime &&instead ofactiveRuntime?.to prevent false equality on null.5. gRPC packages loaded eagerly at module import time
grpc.jsimported@grpc/grpc-jsand@grpc/proto-loaderas top-level static imports. If the plugin'snode_moduleswere not present (e.g. during local validation without runningnpm cifirst), the entire module failed to import. Since gRPC is only needed whenenable_grpc_jwt_renewal: true(off by default), the packages should be resolved lazily.Fix: Replaced static imports with lazy
createRequire()calls inside property getters onFinamGrpcJwtRenewal. The packages are only loaded when the gRPC stream is actually started.Verification