@botbotgo/kit 1.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/config/build/build.sh +182 -0
- package/config/build/tsconfig.dts.json +34 -0
- package/config/build/tsup.config.ts +19 -0
- package/config/build/vitest.config.ts +29 -0
- package/config/tool.yaml +11 -0
- package/dist/agent-context.d.ts +3 -0
- package/dist/agent-context.d.ts.map +1 -0
- package/dist/api/adapters/LangChainToolsHub.d.ts +35 -0
- package/dist/api/adapters/LangChainToolsHub.d.ts.map +1 -0
- package/dist/api/createAgentTools.d.ts +52 -0
- package/dist/api/createAgentTools.d.ts.map +1 -0
- package/dist/api/expose/extension-init/index.d.ts +3 -0
- package/dist/api/expose/extension-init/index.d.ts.map +1 -0
- package/dist/api/expose/extension-init/initExtension.d.ts +21 -0
- package/dist/api/expose/extension-init/initExtension.d.ts.map +1 -0
- package/dist/api/expose/index.d.ts +16 -0
- package/dist/api/expose/index.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/build.d.ts +21 -0
- package/dist/api/expose/mcp-build/build.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/generator.d.ts +15 -0
- package/dist/api/expose/mcp-build/generator.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/index.d.ts +8 -0
- package/dist/api/expose/mcp-build/index.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/init.d.ts +17 -0
- package/dist/api/expose/mcp-build/init.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/run.d.ts +17 -0
- package/dist/api/expose/mcp-build/run.d.ts.map +1 -0
- package/dist/api/expose/mcp-build/types.d.ts +25 -0
- package/dist/api/expose/mcp-build/types.d.ts.map +1 -0
- package/dist/api/expose/mcpServer.d.ts +74 -0
- package/dist/api/expose/mcpServer.d.ts.map +1 -0
- package/dist/api/expose/openapi.d.ts +23 -0
- package/dist/api/expose/openapi.d.ts.map +1 -0
- package/dist/api/expose/openapiHttp.d.ts +51 -0
- package/dist/api/expose/openapiHttp.d.ts.map +1 -0
- package/dist/api/extension/contextRunner.d.ts +10 -0
- package/dist/api/extension/contextRunner.d.ts.map +1 -0
- package/dist/api/extension/createExtension.d.ts +38 -0
- package/dist/api/extension/createExtension.d.ts.map +1 -0
- package/dist/api/extension/dynamicImportAdapter.d.ts +25 -0
- package/dist/api/extension/dynamicImportAdapter.d.ts.map +1 -0
- package/dist/api/extension/generateExtensionManifest.d.ts +29 -0
- package/dist/api/extension/generateExtensionManifest.d.ts.map +1 -0
- package/dist/api/extension/index.d.ts +23 -0
- package/dist/api/extension/index.d.ts.map +1 -0
- package/dist/api/extension/loadToolYaml.d.ts +7 -0
- package/dist/api/extension/loadToolYaml.d.ts.map +1 -0
- package/dist/api/extension/overrideWithConfig.d.ts +2 -0
- package/dist/api/extension/overrideWithConfig.d.ts.map +1 -0
- package/dist/api/extension/registerExtension.d.ts +32 -0
- package/dist/api/extension/registerExtension.d.ts.map +1 -0
- package/dist/api/extension/registerFromManifest.d.ts +43 -0
- package/dist/api/extension/registerFromManifest.d.ts.map +1 -0
- package/dist/api/extension/resolvePackageRoot.d.ts +2 -0
- package/dist/api/extension/resolvePackageRoot.d.ts.map +1 -0
- package/dist/api/extension/support/groupPrefix.d.ts +21 -0
- package/dist/api/extension/support/groupPrefix.d.ts.map +1 -0
- package/dist/api/extension/support/types.d.ts +15 -0
- package/dist/api/extension/support/types.d.ts.map +1 -0
- package/dist/api/register-tools.d.ts +17 -0
- package/dist/api/register-tools.d.ts.map +1 -0
- package/dist/api/resolveAgentSkillRoots.d.ts +7 -0
- package/dist/api/resolveAgentSkillRoots.d.ts.map +1 -0
- package/dist/api/runtimeFromConfig.d.ts +20 -0
- package/dist/api/runtimeFromConfig.d.ts.map +1 -0
- package/dist/api/runtimeFromConfig.helpers.d.ts +12 -0
- package/dist/api/runtimeFromConfig.helpers.d.ts.map +1 -0
- package/dist/api/runtimeFromConfig.types.d.ts +37 -0
- package/dist/api/runtimeFromConfig.types.d.ts.map +1 -0
- package/dist/build.cjs +30 -0
- package/dist/build.cjs.map +1 -0
- package/dist/build.d.ts +13 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +5 -0
- package/dist/build.js.map +1 -0
- package/dist/canonicalCoreSchemas-PHGTNPN5.js +3 -0
- package/dist/canonicalCoreSchemas-PHGTNPN5.js.map +1 -0
- package/dist/canonicalCoreSchemas-TY7NCWCC.cjs +16 -0
- package/dist/canonicalCoreSchemas-TY7NCWCC.cjs.map +1 -0
- package/dist/chunk-4OOTCNR7.js +324 -0
- package/dist/chunk-4OOTCNR7.js.map +1 -0
- package/dist/chunk-AGLGFQUW.cjs +259 -0
- package/dist/chunk-AGLGFQUW.cjs.map +1 -0
- package/dist/chunk-AZUXVVGV.cjs +1073 -0
- package/dist/chunk-AZUXVVGV.cjs.map +1 -0
- package/dist/chunk-BDUSB6GT.js +520 -0
- package/dist/chunk-BDUSB6GT.js.map +1 -0
- package/dist/chunk-BNIE2IKZ.cjs +100 -0
- package/dist/chunk-BNIE2IKZ.cjs.map +1 -0
- package/dist/chunk-BTHDNP3C.cjs +350 -0
- package/dist/chunk-BTHDNP3C.cjs.map +1 -0
- package/dist/chunk-GGFAGLDC.js +1049 -0
- package/dist/chunk-GGFAGLDC.js.map +1 -0
- package/dist/chunk-ITX6A2BT.js +92 -0
- package/dist/chunk-ITX6A2BT.js.map +1 -0
- package/dist/chunk-IVL4TBFB.js +248 -0
- package/dist/chunk-IVL4TBFB.js.map +1 -0
- package/dist/chunk-JW4EMVTE.cjs +553 -0
- package/dist/chunk-JW4EMVTE.cjs.map +1 -0
- package/dist/chunk-LNVK4GO7.cjs +3043 -0
- package/dist/chunk-LNVK4GO7.cjs.map +1 -0
- package/dist/chunk-NTWOVFEY.js +16 -0
- package/dist/chunk-NTWOVFEY.js.map +1 -0
- package/dist/chunk-P5XFA3MW.js +3013 -0
- package/dist/chunk-P5XFA3MW.js.map +1 -0
- package/dist/chunk-UUNG3GL3.cjs +19 -0
- package/dist/chunk-UUNG3GL3.cjs.map +1 -0
- package/dist/core/registry/ToolRegistry.d.ts +68 -0
- package/dist/core/registry/ToolRegistry.d.ts.map +1 -0
- package/dist/core/runtime/Budget.d.ts +63 -0
- package/dist/core/runtime/Budget.d.ts.map +1 -0
- package/dist/core/runtime/Evidence.d.ts +19 -0
- package/dist/core/runtime/Evidence.d.ts.map +1 -0
- package/dist/core/runtime/PTCRuntime.d.ts +124 -0
- package/dist/core/runtime/PTCRuntime.d.ts.map +1 -0
- package/dist/core/runtime/PTCRuntimeObservability.d.ts +26 -0
- package/dist/core/runtime/PTCRuntimeObservability.d.ts.map +1 -0
- package/dist/core/runtime/PTCRuntimePipeline.d.ts +69 -0
- package/dist/core/runtime/PTCRuntimePipeline.d.ts.map +1 -0
- package/dist/core/runtime/PolicyEngine.d.ts +67 -0
- package/dist/core/runtime/PolicyEngine.d.ts.map +1 -0
- package/dist/core/runtime/Retry.d.ts +33 -0
- package/dist/core/runtime/Retry.d.ts.map +1 -0
- package/dist/core/runtime/SchemaValidator.d.ts +42 -0
- package/dist/core/runtime/SchemaValidator.d.ts.map +1 -0
- package/dist/core/runtime/toolObservation.d.ts +7 -0
- package/dist/core/runtime/toolObservation.d.ts.map +1 -0
- package/dist/core/types/Events.d.ts +99 -0
- package/dist/core/types/Events.d.ts.map +1 -0
- package/dist/core/types/ToolIntent.d.ts +40 -0
- package/dist/core/types/ToolIntent.d.ts.map +1 -0
- package/dist/core/types/ToolResult.d.ts +44 -0
- package/dist/core/types/ToolResult.d.ts.map +1 -0
- package/dist/core/types/ToolSpec.d.ts +116 -0
- package/dist/core/types/ToolSpec.d.ts.map +1 -0
- package/dist/core/types/ToolTypeHandler.d.ts +88 -0
- package/dist/core/types/ToolTypeHandler.d.ts.map +1 -0
- package/dist/core/types/index.d.ts +7 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/index.cjs +399 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +394 -0
- package/dist/index.js.map +1 -0
- package/dist/observability/EventLog.d.ts +60 -0
- package/dist/observability/EventLog.d.ts.map +1 -0
- package/dist/observability/Logger.d.ts +33 -0
- package/dist/observability/Logger.d.ts.map +1 -0
- package/dist/observability/Metrics.d.ts +70 -0
- package/dist/observability/Metrics.d.ts.map +1 -0
- package/dist/observability/Tracing.d.ts +69 -0
- package/dist/observability/Tracing.d.ts.map +1 -0
- package/dist/sdk.cjs +493 -0
- package/dist/sdk.cjs.map +1 -0
- package/dist/sdk.d.ts +17 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +443 -0
- package/dist/sdk.js.map +1 -0
- package/dist/security/sandbox.d.ts +10 -0
- package/dist/security/sandbox.d.ts.map +1 -0
- package/dist/security/ssrf.d.ts +24 -0
- package/dist/security/ssrf.d.ts.map +1 -0
- package/dist/templates/mcp-server.js +48 -0
- package/dist/templates/n8n-invoker.js +11 -0
- package/dist/templates/skill-invoker.js +11 -0
- package/dist/templates/tool-index.js +9 -0
- package/dist/tools/discoveryFactory.d.ts +117 -0
- package/dist/tools/discoveryFactory.d.ts.map +1 -0
- package/dist/tools/function/index.d.ts +10 -0
- package/dist/tools/function/index.d.ts.map +1 -0
- package/dist/tools/function/scanner.d.ts +29 -0
- package/dist/tools/function/scanner.d.ts.map +1 -0
- package/dist/tools/function/schemaFromTs.d.ts +16 -0
- package/dist/tools/function/schemaFromTs.d.ts.map +1 -0
- package/dist/tools/function/types.d.ts +20 -0
- package/dist/tools/function/types.d.ts.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/langchain/LangChainLoader.d.ts +7 -0
- package/dist/tools/langchain/LangChainLoader.d.ts.map +1 -0
- package/dist/tools/langchain/directoryApply.d.ts +5 -0
- package/dist/tools/langchain/directoryApply.d.ts.map +1 -0
- package/dist/tools/langchain/directoryLoad.d.ts +13 -0
- package/dist/tools/langchain/directoryLoad.d.ts.map +1 -0
- package/dist/tools/langchain/index.d.ts +3 -0
- package/dist/tools/langchain/index.d.ts.map +1 -0
- package/dist/tools/langchain/scanner.d.ts +8 -0
- package/dist/tools/langchain/scanner.d.ts.map +1 -0
- package/dist/tools/langchain/types.d.ts +5 -0
- package/dist/tools/langchain/types.d.ts.map +1 -0
- package/dist/tools/mcp/MCPClientAdapter.d.ts +34 -0
- package/dist/tools/mcp/MCPClientAdapter.d.ts.map +1 -0
- package/dist/tools/mcp/MCPLoader.d.ts +8 -0
- package/dist/tools/mcp/MCPLoader.d.ts.map +1 -0
- package/dist/tools/mcp/MCPProcessManager.d.ts +29 -0
- package/dist/tools/mcp/MCPProcessManager.d.ts.map +1 -0
- package/dist/tools/mcp/connectMCP.d.ts +47 -0
- package/dist/tools/mcp/connectMCP.d.ts.map +1 -0
- package/dist/tools/mcp/directoryApply.d.ts +10 -0
- package/dist/tools/mcp/directoryApply.d.ts.map +1 -0
- package/dist/tools/mcp/index.d.ts +16 -0
- package/dist/tools/mcp/index.d.ts.map +1 -0
- package/dist/tools/mcp/mcpSpecToToolSpec.d.ts +8 -0
- package/dist/tools/mcp/mcpSpecToToolSpec.d.ts.map +1 -0
- package/dist/tools/mcp/registerMCPTools.d.ts +24 -0
- package/dist/tools/mcp/registerMCPTools.d.ts.map +1 -0
- package/dist/tools/mcp/scanner.d.ts +8 -0
- package/dist/tools/mcp/scanner.d.ts.map +1 -0
- package/dist/tools/mcp/support/types.d.ts +3 -0
- package/dist/tools/mcp/support/types.d.ts.map +1 -0
- package/dist/tools/n8n/N8nLoader.d.ts +25 -0
- package/dist/tools/n8n/N8nLoader.d.ts.map +1 -0
- package/dist/tools/n8n/directoryApply.d.ts +10 -0
- package/dist/tools/n8n/directoryApply.d.ts.map +1 -0
- package/dist/tools/n8n/index.d.ts +6 -0
- package/dist/tools/n8n/index.d.ts.map +1 -0
- package/dist/tools/n8n/scanN8n.d.ts +20 -0
- package/dist/tools/n8n/scanN8n.d.ts.map +1 -0
- package/dist/tools/n8n/types.d.ts +18 -0
- package/dist/tools/n8n/types.d.ts.map +1 -0
- package/dist/tools/scanPackage.d.ts +42 -0
- package/dist/tools/scanPackage.d.ts.map +1 -0
- package/dist/tools/skill/SkillLoader.d.ts +20 -0
- package/dist/tools/skill/SkillLoader.d.ts.map +1 -0
- package/dist/tools/skill/SkillManifest.d.ts +79 -0
- package/dist/tools/skill/SkillManifest.d.ts.map +1 -0
- package/dist/tools/skill/SkillMdParser.d.ts +31 -0
- package/dist/tools/skill/SkillMdParser.d.ts.map +1 -0
- package/dist/tools/skill/directoryApply.d.ts +10 -0
- package/dist/tools/skill/directoryApply.d.ts.map +1 -0
- package/dist/tools/skill/index.d.ts +8 -0
- package/dist/tools/skill/index.d.ts.map +1 -0
- package/dist/tools/skill/scanSkill.d.ts +20 -0
- package/dist/tools/skill/scanSkill.d.ts.map +1 -0
- package/dist/tools/skill/types.d.ts +19 -0
- package/dist/tools/skill/types.d.ts.map +1 -0
- package/dist/tools/util/canonicalCoreSchemas.d.ts +15 -0
- package/dist/tools/util/canonicalCoreSchemas.d.ts.map +1 -0
- package/dist/tools/util/index.d.ts +13 -0
- package/dist/tools/util/index.d.ts.map +1 -0
- package/dist/tools/util/resolveEntry.d.ts +6 -0
- package/dist/tools/util/resolveEntry.d.ts.map +1 -0
- package/dist/tools/util/scanUtil.d.ts +9 -0
- package/dist/tools/util/scanUtil.d.ts.map +1 -0
- package/dist/tools/util/toolConfig.d.ts +38 -0
- package/dist/tools/util/toolConfig.d.ts.map +1 -0
- package/dist/tools/util/toolDescriptor.d.ts +117 -0
- package/dist/tools/util/toolDescriptor.d.ts.map +1 -0
- package/dist/utils/cli/help.d.ts +2 -0
- package/dist/utils/cli/help.d.ts.map +1 -0
- package/dist/utils/cli/index.cjs +700 -0
- package/dist/utils/cli/index.cjs.map +1 -0
- package/dist/utils/cli/index.d.ts +9 -0
- package/dist/utils/cli/index.d.ts.map +1 -0
- package/dist/utils/cli/index.js +677 -0
- package/dist/utils/cli/index.js.map +1 -0
- package/dist/utils/cli/toolRuntime.d.ts +19 -0
- package/dist/utils/cli/toolRuntime.d.ts.map +1 -0
- package/dist/utils/log.d.ts +2 -0
- package/dist/utils/log.d.ts.map +1 -0
- package/dist/utils/npmCache.d.ts +11 -0
- package/dist/utils/npmCache.d.ts.map +1 -0
- package/dist/utils/npmVersion.d.ts +10 -0
- package/dist/utils/npmVersion.d.ts.map +1 -0
- package/dist/utils/overrideWithConfig.d.ts +2 -0
- package/dist/utils/overrideWithConfig.d.ts.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/registry/ToolRegistry.ts","../src/core/runtime/Retry.ts","../src/security/sandbox.ts"],"names":[],"mappings":";;;;;;AAqBO,IAAM,eAAN,MAAmB;AAAA,EACP,KAAA,uBAAY,GAAA,EAAsB;AAAA,EAClC,QAAA,uBAAe,GAAA,EAAyB;AAAA;AAAA,EACxC,SAAA,uBAAgB,GAAA,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM5D,SAAS,IAAA,EAAsB;AAC7B,IAAA,IAAA,CAAK,aAAa,IAAI,CAAA;AACtB,IAAA,MAAM,IAAA,GAAO,iBAAA,CAAkB,IAAA,CAAK,IAAI,CAAA;AACxC,IAAA,MAAM,UAAA,GAAa,EAAE,GAAG,IAAA,EAAM,IAAA,EAAK;AACnC,IAAA,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,IAAA,EAAM,UAAU,CAAA;AAC/B,IAAA,IAAA,CAAK,UAAU,UAAU,CAAA;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,KAAA,EAAyB;AACpC,IAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,MAAA,IAAA,CAAK,SAAS,IAAI,CAAA;AAAA,IACpB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW,IAAA,EAAuB;AAChC,IAAA,MAAM,GAAA,GAAM,kBA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,IAAA,EAAuB;AACzD,EAAA,MAAM,cAAA,GAAiB,UAAU,IAAI,CAAA;AACrC,EAAA,MAAM,cAAA,GAAiB,UAAU,IAAI,CAAA;AACrC,EAAA,OAAO,cAAA,KAAmB,cAAA,IAAkB,cAAA,CAAe,UAAA,CAAW,iBAAiB,GAAG,CAAA;AAC5F","file":"chunk-IVL4TBFB.js","sourcesContent":["import type { Capability, ToolKind, ToolSpec } from \"../types/ToolSpec.js\";\nimport { normalizeToolName } from \"../types/ToolSpec.js\";\n\n/**\n * Search query for tools.\n */\nexport interface ToolSearchQuery {\n /** Text search in name/description/tags */\n text?: string;\n /** Filter by tool kind */\n kind?: ToolKind;\n /** Filter by required capabilities */\n capabilities?: Capability[];\n /** Filter by tags */\n tags?: string[];\n}\n\n/**\n * Tool Registry: manages tool registration, lookup, and search.\n * Supports both static registration and dynamic discovery via adapters.\n */\nexport class ToolRegistry {\n private readonly tools = new Map<string, ToolSpec>();\n private readonly tagIndex = new Map<string, Set<string>>(); // tag → tool names\n private readonly kindIndex = new Map<ToolKind, Set<string>>(); // kind → tool names\n\n /**\n * Register a single tool spec.\n * Overwrites if same name already exists.\n */\n register(spec: ToolSpec): void {\n this.validateSpec(spec);\n const name = normalizeToolName(spec.name);\n const normalized = { ...spec, name };\n this.tools.set(name, normalized);\n this.indexTool(normalized);\n }\n\n /**\n * Register multiple tool specs at once.\n */\n bulkRegister(specs: ToolSpec[]): void {\n for (const spec of specs) {\n this.register(spec);\n }\n }\n\n /**\n * Unregister a tool by name.\n */\n unregister(name: string): boolean {\n const key = normalizeToolName(name);\n const spec = this.tools.get(key);\n if (!spec) return false;\n this.tools.delete(key);\n this.deindexTool(spec);\n return true;\n }\n\n /**\n * Get a tool spec by name (name is normalized before lookup).\n */\n get(name: string): ToolSpec | undefined {\n return this.tools.get(normalizeToolName(name));\n }\n\n /**\n * Check if a tool exists (name is normalized before lookup).\n */\n has(name: string): boolean {\n return this.tools.has(normalizeToolName(name));\n }\n\n /**\n * Search tools by query.\n */\n search(query: ToolSearchQuery): ToolSpec[] {\n let candidates: ToolSpec[];\n\n // Start with kind filter if specified (uses index)\n if (query.kind) {\n const names = this.kindIndex.get(query.kind);\n if (!names || names.size === 0) return [];\n candidates = [...names]\n .map((n) => this.tools.get(n))\n .filter((s): s is ToolSpec => s !== undefined);\n } else {\n candidates = [...this.tools.values()];\n }\n\n // Filter by tags (uses index for initial candidates if no kind filter)\n if (query.tags && query.tags.length > 0) {\n candidates = candidates.filter((spec) =>\n query.tags!.some((tag) => spec.tags?.includes(tag)),\n );\n }\n\n // Filter by capabilities\n if (query.capabilities && query.capabilities.length > 0) {\n candidates = candidates.filter((spec) =>\n query.capabilities!.every((cap) => spec.capabilities.includes(cap)),\n );\n }\n\n // Filter by text (name, description, tags)\n if (query.text) {\n const lower = query.text.toLowerCase();\n candidates = candidates.filter(\n (spec) =>\n spec.name.toLowerCase().includes(lower) ||\n spec.description?.toLowerCase().includes(lower) ||\n spec.tags?.some((t) => t.toLowerCase().includes(lower)),\n );\n }\n\n return candidates;\n }\n\n /**\n * List all registered tool names.\n */\n list(): string[] {\n return [...this.tools.keys()];\n }\n\n /**\n * Get count of registered tools.\n */\n get size(): number {\n return this.tools.size;\n }\n\n /**\n * Export a snapshot of all registered tools (for debugging/routing).\n */\n snapshot(): ToolSpec[] {\n return [...this.tools.values()];\n }\n\n /**\n * Clear all registered tools.\n */\n clear(): void {\n this.tools.clear();\n this.tagIndex.clear();\n this.kindIndex.clear();\n }\n\n private validateSpec(spec: ToolSpec): void {\n if (!spec.name) throw new Error(\"ToolSpec.name is required\");\n if (!spec.version) throw new Error(\"ToolSpec.version is required\");\n if (!spec.kind) throw new Error(\"ToolSpec.kind is required\");\n if (!spec.inputSchema) throw new Error(\"ToolSpec.inputSchema is required\");\n if (!spec.outputSchema) throw new Error(\"ToolSpec.outputSchema is required\");\n if (!spec.capabilities) throw new Error(\"ToolSpec.capabilities is required\");\n }\n\n private indexTool(spec: ToolSpec): void {\n // Kind index\n let kindSet = this.kindIndex.get(spec.kind);\n if (!kindSet) {\n kindSet = new Set();\n this.kindIndex.set(spec.kind, kindSet);\n }\n kindSet.add(spec.name);\n\n // Tag index\n if (spec.tags) {\n for (const tag of spec.tags) {\n let tagSet = this.tagIndex.get(tag);\n if (!tagSet) {\n tagSet = new Set();\n this.tagIndex.set(tag, tagSet);\n }\n tagSet.add(spec.name);\n }\n }\n }\n\n private deindexTool(spec: ToolSpec): void {\n this.kindIndex.get(spec.kind)?.delete(spec.name);\n if (spec.tags) {\n for (const tag of spec.tags) {\n this.tagIndex.get(tag)?.delete(spec.name);\n }\n }\n }\n}\n","import pRetry, { type Options as PRetryOptions } from \"p-retry\";\n\n/**\n * Retry configuration.\n */\nexport interface RetryOptions {\n /** Maximum number of retries (default: 2) */\n maxRetries?: number;\n /** Base delay in ms for exponential backoff (default: 1000) */\n baseDelayMs?: number;\n /** Maximum delay in ms (default: 10000) */\n maxDelayMs?: number;\n /** Jitter factor 0-1 (default: 0.1) */\n jitter?: number;\n /** Error filter: return true to retry, false to abort */\n shouldRetry?: (error: Error) => boolean;\n /** Callback on each retry attempt */\n onRetry?: (error: Error, attempt: number) => void;\n}\n\n/**\n * Default errors that should NOT be retried (deterministic failures).\n */\nconst NON_RETRYABLE_ERRORS = new Set([\n \"TOOL_NOT_FOUND\",\n \"INPUT_SCHEMA_INVALID\",\n \"POLICY_DENIED\",\n \"HITL_DENIED\",\n \"OUTPUT_SCHEMA_INVALID\",\n \"PATH_OUTSIDE_SANDBOX\",\n \"FILE_TOO_LARGE\",\n \"HTTP_DISALLOWED_HOST\",\n \"HTTP_TOO_LARGE\",\n \"EXEC_INVALID\",\n \"EXEC_SPAWN_ERROR\",\n \"DUCKDUCKGO_INVALID\",\n]);\n\n/**\n * Determine if an error is retryable.\n */\nexport function isRetryable(error: unknown): boolean {\n if (error instanceof Error) {\n const kind = (error as Error & { kind?: string }).kind;\n if (kind && NON_RETRYABLE_ERRORS.has(kind)) return false;\n }\n return true;\n}\n\n/**\n * Execute a function with retry logic using exponential backoff.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n options: RetryOptions = {},\n): Promise<T> {\n const {\n maxRetries = 2,\n baseDelayMs = 1000,\n maxDelayMs = 10_000,\n jitter = 0.1,\n shouldRetry,\n onRetry,\n } = options;\n\n if (maxRetries <= 0) {\n return fn();\n }\n\n const pRetryOptions: PRetryOptions = {\n retries: maxRetries,\n minTimeout: baseDelayMs,\n maxTimeout: maxDelayMs,\n randomize: true,\n factor: 2,\n onFailedAttempt: (error) => {\n // Apply jitter\n if (jitter > 0 && error.retriesLeft > 0) {\n // jitterMs calculated but p-retry handles backoff internally\n void (Math.random() * jitter * baseDelayMs);\n }\n\n // Check if should retry\n if (shouldRetry && !shouldRetry(error)) {\n throw error; // Abort retry\n }\n\n if (!isRetryable(error)) {\n throw error; // Non-retryable error kind\n }\n\n onRetry?.(error, maxRetries - error.retriesLeft);\n },\n };\n\n return pRetry(fn, pRetryOptions);\n}\n\n/**\n * Create a tagged error with a kind field for retry classification.\n */\nexport function createTaggedError(\n kind: string,\n message: string,\n details?: unknown,\n): Error & { kind: string; details?: unknown } {\n const error = new Error(message) as Error & {\n kind: string;\n details?: unknown;\n };\n error.kind = kind;\n error.details = details;\n return error;\n}\n","import { resolve, normalize, dirname, basename } from \"node:path\";\nimport { realpath, access } from \"node:fs/promises\";\nimport { createTaggedError } from \"../core/runtime/Retry.js\";\n\nlet sandboxValidationEnabled = false;\n\nexport function setSandboxValidationEnabled(enabled: boolean): void {\n sandboxValidationEnabled = enabled;\n}\n\n/**\n * Resolve an input path to an absolute path within the sandbox.\n * Throws PATH_OUTSIDE_SANDBOX if the resolved path escapes the sandbox root.\n *\n * For existing files: uses realpath to resolve symlinks.\n * For non-existing files (write targets): resolves the parent directory.\n */\nexport async function resolveSandboxedPath(\n inputPath: string,\n sandboxRoot: string,\n): Promise<string> {\n // Resolve the sandbox root itself with realpath to handle platform symlinks\n // (e.g. macOS /var -> /private/var)\n let normalizedRoot: string;\n try {\n normalizedRoot = await realpath(resolve(sandboxRoot));\n } catch {\n normalizedRoot = normalize(resolve(sandboxRoot));\n }\n\n // Resolve against sandbox root\n const resolved = resolve(normalizedRoot, inputPath);\n\n let real: string;\n try {\n // Try to resolve symlinks for existing paths\n await access(resolved);\n real = await realpath(resolved);\n } catch {\n // Path does not exist — resolve parent to check containment\n const parentDir = dirname(resolved);\n let realParent: string;\n try {\n await access(parentDir);\n realParent = await realpath(parentDir);\n } catch {\n // Parent also doesn't exist — use normalized resolved path\n // (will fail at actual FS operation if truly invalid)\n realParent = normalize(parentDir);\n }\n real = resolve(realParent, basename(resolved));\n }\n\n if (sandboxValidationEnabled && !isWithinRoot(real, normalizedRoot)) {\n throw createTaggedError(\n \"PATH_OUTSIDE_SANDBOX\",\n `Path \"${inputPath}\" resolves to \"${real}\" which is outside sandbox \"${normalizedRoot}\"`,\n { inputPath, resolvedPath: real, sandboxRoot: normalizedRoot },\n );\n }\n\n return real;\n}\n\nfunction isWithinRoot(path: string, root: string): boolean {\n const normalizedPath = normalize(path);\n const normalizedRoot = normalize(root);\n return normalizedPath === normalizedRoot || normalizedPath.startsWith(normalizedRoot + \"/\");\n}\n"]}
|
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var ts2 = require('typescript');
|
|
6
|
+
var promises = require('fs/promises');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
27
|
+
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
28
|
+
var ts2__namespace = /*#__PURE__*/_interopNamespace(ts2);
|
|
29
|
+
|
|
30
|
+
// src/tools/function/scanner.ts
|
|
31
|
+
async function findDirsContainingFile(rootPath, fileName) {
|
|
32
|
+
const found = [];
|
|
33
|
+
await collectDirsWithFile(rootPath, fileName, found);
|
|
34
|
+
return found;
|
|
35
|
+
}
|
|
36
|
+
async function collectDirsWithFile(dir, fileName, acc) {
|
|
37
|
+
let entries;
|
|
38
|
+
try {
|
|
39
|
+
const e = await promises.readdir(dir, { withFileTypes: true });
|
|
40
|
+
entries = e.map((x) => ({
|
|
41
|
+
name: x.name,
|
|
42
|
+
isDirectory: x.isDirectory(),
|
|
43
|
+
isFile: x.isFile()
|
|
44
|
+
}));
|
|
45
|
+
} catch {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (entries.some((x) => x.isFile && x.name === fileName)) acc.push(dir);
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
if (!entry.isDirectory || entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
51
|
+
await collectDirsWithFile(path.join(dir, entry.name), fileName, acc);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function pathToToolName(sourcePath, programName) {
|
|
55
|
+
const normalized = sourcePath.replace(/\\/g, "/").replace(/\.(ts|tsx|js|mjs|json)$/i, "");
|
|
56
|
+
const segments = normalized.split("/").filter(Boolean);
|
|
57
|
+
return segments.length === 0 ? programName : `${segments.join(".")}.${programName}`;
|
|
58
|
+
}
|
|
59
|
+
function buildOutputSchemaFromReturnType(node, typeChecker, onWarn) {
|
|
60
|
+
const sig = typeChecker.getSignatureFromDeclaration(node);
|
|
61
|
+
if (!sig) {
|
|
62
|
+
onWarn?.("Could not get signature for return type, using object");
|
|
63
|
+
return { type: "object", additionalProperties: true };
|
|
64
|
+
}
|
|
65
|
+
let returnType = typeChecker.getReturnTypeOfSignature(sig);
|
|
66
|
+
if (returnType.getSymbol?.()?.getName() === "Promise") {
|
|
67
|
+
const typeArgs = returnType.typeArguments;
|
|
68
|
+
if (typeArgs?.[0]) returnType = typeArgs[0];
|
|
69
|
+
}
|
|
70
|
+
const schema = typeToJsonSchema(returnType, typeChecker, onWarn);
|
|
71
|
+
const hasProps = typeof schema === "object" && schema.type === "object" && Object.keys(schema.properties ?? {}).length > 0;
|
|
72
|
+
return hasProps ? schema : { type: "object", additionalProperties: true };
|
|
73
|
+
}
|
|
74
|
+
function buildInputSchemaFromParams(node, typeChecker, onWarn) {
|
|
75
|
+
const properties = {};
|
|
76
|
+
const required = [];
|
|
77
|
+
if (!node.parameters.length) {
|
|
78
|
+
return { schema: { type: "object", properties: {} }, required: [] };
|
|
79
|
+
}
|
|
80
|
+
for (const param of node.parameters) {
|
|
81
|
+
const name = param.name.getText();
|
|
82
|
+
if (name.startsWith("_") && name.length <= 2) continue;
|
|
83
|
+
const sym = param.symbol;
|
|
84
|
+
const paramType = sym ? typeChecker.getTypeOfSymbolAtLocation(sym, param) : typeChecker.getTypeAtLocation(param);
|
|
85
|
+
const isOptional = !!param.questionToken || param.initializer !== void 0;
|
|
86
|
+
const propSchema = typeToJsonSchema(paramType, typeChecker, onWarn);
|
|
87
|
+
properties[name] = propSchema;
|
|
88
|
+
if (!isOptional) required.push(name);
|
|
89
|
+
}
|
|
90
|
+
const paramNames = Object.keys(properties);
|
|
91
|
+
if (paramNames.length === 1) {
|
|
92
|
+
const soleName = paramNames[0];
|
|
93
|
+
const inner = properties[soleName];
|
|
94
|
+
if (inner && typeof inner === "object" && inner.type === "object" && inner.properties && typeof inner.properties === "object") {
|
|
95
|
+
return {
|
|
96
|
+
schema: {
|
|
97
|
+
type: "object",
|
|
98
|
+
properties: inner.properties,
|
|
99
|
+
...Array.isArray(inner.required) && inner.required.length > 0 ? { required: inner.required } : {},
|
|
100
|
+
...inner.additionalProperties !== void 0 ? { additionalProperties: inner.additionalProperties } : {}
|
|
101
|
+
},
|
|
102
|
+
required: inner.required ?? []
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
schema: {
|
|
108
|
+
type: "object",
|
|
109
|
+
properties,
|
|
110
|
+
...required.length > 0 ? { required } : {}
|
|
111
|
+
},
|
|
112
|
+
required
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function typeToJsonSchema(type, typeChecker, onWarn) {
|
|
116
|
+
const flags = type.flags;
|
|
117
|
+
if (flags & ts2__namespace.TypeFlags.String) return { type: "string" };
|
|
118
|
+
if (flags & ts2__namespace.TypeFlags.Number) return { type: "number" };
|
|
119
|
+
if (flags & ts2__namespace.TypeFlags.Boolean) return { type: "boolean" };
|
|
120
|
+
if (flags & ts2__namespace.TypeFlags.BooleanLiteral) return { type: "boolean" };
|
|
121
|
+
if (flags & ts2__namespace.TypeFlags.Null) return { type: "null" };
|
|
122
|
+
if (flags & ts2__namespace.TypeFlags.Undefined || flags & ts2__namespace.TypeFlags.Void) return {};
|
|
123
|
+
if (flags & ts2__namespace.TypeFlags.Any || flags & ts2__namespace.TypeFlags.Unknown) {
|
|
124
|
+
onWarn?.(`Unsupported type: any/unknown, using empty schema`);
|
|
125
|
+
return {};
|
|
126
|
+
}
|
|
127
|
+
if (type.isUnion?.()) {
|
|
128
|
+
const union = type;
|
|
129
|
+
const types = union.types;
|
|
130
|
+
const withoutUndef = types.filter(
|
|
131
|
+
(t) => !(t.flags & ts2__namespace.TypeFlags.Undefined) && !(t.flags & ts2__namespace.TypeFlags.Void)
|
|
132
|
+
);
|
|
133
|
+
if (withoutUndef.length === 1) return typeToJsonSchema(withoutUndef[0], typeChecker, onWarn);
|
|
134
|
+
if (withoutUndef.length === 0) return {};
|
|
135
|
+
const stringEnumValues = [];
|
|
136
|
+
let allStringLiterals = true;
|
|
137
|
+
for (const t of withoutUndef) {
|
|
138
|
+
if (t.flags & ts2__namespace.TypeFlags.StringLiteral) {
|
|
139
|
+
const lit = t;
|
|
140
|
+
if (typeof lit.value === "string") stringEnumValues.push(lit.value);
|
|
141
|
+
} else {
|
|
142
|
+
allStringLiterals = false;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (allStringLiterals && stringEnumValues.length > 0) {
|
|
147
|
+
return { type: "string", enum: [...new Set(stringEnumValues)] };
|
|
148
|
+
}
|
|
149
|
+
let allBooleanLiterals = true;
|
|
150
|
+
for (const t of withoutUndef) {
|
|
151
|
+
if (!(t.flags & ts2__namespace.TypeFlags.BooleanLiteral)) {
|
|
152
|
+
allBooleanLiterals = false;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (allBooleanLiterals) return { type: "boolean" };
|
|
157
|
+
}
|
|
158
|
+
if (flags & ts2__namespace.TypeFlags.StringLiteral) {
|
|
159
|
+
const lit = type;
|
|
160
|
+
if (typeof lit.value === "string") {
|
|
161
|
+
return { type: "string", enum: [lit.value] };
|
|
162
|
+
}
|
|
163
|
+
return { type: "string" };
|
|
164
|
+
}
|
|
165
|
+
if (typeChecker.isArrayType(type)) {
|
|
166
|
+
const typeRef = type;
|
|
167
|
+
const typeArgs = typeRef.typeArguments;
|
|
168
|
+
const itemType = typeArgs?.[0];
|
|
169
|
+
const items = itemType ? typeToJsonSchema(itemType, typeChecker, onWarn) : {};
|
|
170
|
+
return { type: "array", items: Object.keys(items).length ? items : {} };
|
|
171
|
+
}
|
|
172
|
+
const str = typeChecker.typeToString(type);
|
|
173
|
+
if (str === "string") return { type: "string" };
|
|
174
|
+
if (str === "number") return { type: "number" };
|
|
175
|
+
if (str === "boolean") return { type: "boolean" };
|
|
176
|
+
if (str.endsWith("[]")) {
|
|
177
|
+
const inner = str.slice(0, -2).trim();
|
|
178
|
+
const itemType = inner === "string" ? { type: "string" } : inner === "number" ? { type: "number" } : {};
|
|
179
|
+
return { type: "array", items: itemType };
|
|
180
|
+
}
|
|
181
|
+
if (type.getProperties && type.getProperties().length >= 0) {
|
|
182
|
+
const props = type.getProperties();
|
|
183
|
+
const properties = {};
|
|
184
|
+
const required = [];
|
|
185
|
+
for (const p of props) {
|
|
186
|
+
const decl = p.valueDeclaration;
|
|
187
|
+
const propType = decl ? typeChecker.getTypeAtLocation(decl) : typeChecker.getTypeOfSymbolAtLocation(p, p.valueDeclaration);
|
|
188
|
+
const optional = decl && ts2__namespace.isPropertySignature(decl) ? !!decl.questionToken : false;
|
|
189
|
+
properties[p.name] = typeToJsonSchema(propType, typeChecker, onWarn);
|
|
190
|
+
if (!optional) required.push(p.name);
|
|
191
|
+
}
|
|
192
|
+
return { type: "object", properties, ...required.length ? { required } : {} };
|
|
193
|
+
}
|
|
194
|
+
onWarn?.(`Unsupported type: ${str}, using object`);
|
|
195
|
+
return { type: "object" };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/tools/function/types.ts
|
|
199
|
+
var FUNCTION_KIND = "function";
|
|
200
|
+
|
|
201
|
+
// src/core/types/ToolSpec.ts
|
|
202
|
+
function normalizeToolName(name) {
|
|
203
|
+
if (typeof name !== "string" || !name) return name;
|
|
204
|
+
return name.replace(/[^a-zA-Z0-9]/g, ".").replace(/\.+/g, ".");
|
|
205
|
+
}
|
|
206
|
+
var DEFAULT_INPUT_SCHEMA = {
|
|
207
|
+
type: "object",
|
|
208
|
+
additionalProperties: true
|
|
209
|
+
};
|
|
210
|
+
var DEFAULT_OUTPUT_SCHEMA = {
|
|
211
|
+
type: "object",
|
|
212
|
+
additionalProperties: true
|
|
213
|
+
};
|
|
214
|
+
function createToolSpec(opts) {
|
|
215
|
+
const sideEffect = opts.sideEffect ?? "none";
|
|
216
|
+
const name = normalizeToolName(opts.name);
|
|
217
|
+
return {
|
|
218
|
+
name,
|
|
219
|
+
version: opts.version ?? "1.0.0",
|
|
220
|
+
kind: opts.kind,
|
|
221
|
+
description: opts.description,
|
|
222
|
+
tags: opts.tags,
|
|
223
|
+
inputSchema: opts.inputSchema ?? DEFAULT_INPUT_SCHEMA,
|
|
224
|
+
outputSchema: opts.outputSchema ?? DEFAULT_OUTPUT_SCHEMA,
|
|
225
|
+
capabilities: opts.capabilities,
|
|
226
|
+
costHints: opts.costHints,
|
|
227
|
+
_meta: { hitl: { sideEffect } }
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// src/tools/skill/types.ts
|
|
232
|
+
var SKILL_KIND = "skill";
|
|
233
|
+
var SKILL_DIR_NAME = "skill";
|
|
234
|
+
|
|
235
|
+
// src/tools/n8n/types.ts
|
|
236
|
+
var N8N_KIND = "n8n";
|
|
237
|
+
|
|
238
|
+
// src/tools/mcp/mcpSpecToToolSpec.ts
|
|
239
|
+
var DEFAULT_OUTPUT = { type: "object", additionalProperties: true };
|
|
240
|
+
function mcpSpecToToolSpec(spec, projectPath) {
|
|
241
|
+
const base = {
|
|
242
|
+
name: spec.name,
|
|
243
|
+
version: "1.0.0",
|
|
244
|
+
kind: spec.kind,
|
|
245
|
+
description: spec.description,
|
|
246
|
+
inputSchema: spec.inputSchema ?? DEFAULT_OUTPUT,
|
|
247
|
+
outputSchema: "outputSchema" in spec && spec.outputSchema ? spec.outputSchema : DEFAULT_OUTPUT_SCHEMA,
|
|
248
|
+
capabilities: [],
|
|
249
|
+
_meta: spec._meta,
|
|
250
|
+
...spec.kind === N8N_KIND && "webhookUrl" in spec && spec.webhookUrl ? { endpoint: spec.webhookUrl } : {}
|
|
251
|
+
};
|
|
252
|
+
if (spec.kind === FUNCTION_KIND && "sourcePath" in spec && "exportName" in spec) {
|
|
253
|
+
base._meta = {
|
|
254
|
+
...base._meta,
|
|
255
|
+
sourcePath: spec.sourcePath,
|
|
256
|
+
exportName: spec.exportName,
|
|
257
|
+
...projectPath && { projectPath }
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
if (spec.kind === SKILL_KIND && "sourcePath" in spec && projectPath) {
|
|
261
|
+
base._meta = { ...base._meta, sourcePath: spec.sourcePath, projectPath };
|
|
262
|
+
}
|
|
263
|
+
if (spec.kind === N8N_KIND && "sourcePath" in spec && projectPath) {
|
|
264
|
+
base._meta = { ...base._meta, sourcePath: spec.sourcePath, projectPath };
|
|
265
|
+
}
|
|
266
|
+
return base;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/tools/function/scanner.ts
|
|
270
|
+
var TOOL_TAG = "@tool";
|
|
271
|
+
var EFFECT_VALUES = ["none", "local_write", "external_write", "destructive"];
|
|
272
|
+
function scanForTools(options) {
|
|
273
|
+
const projectPath = path__namespace.resolve(options.projectPath);
|
|
274
|
+
const tsconfigPath = options.tsconfigPath ?? path__namespace.join(projectPath, "tsconfig.json");
|
|
275
|
+
const include = options.include ?? ["**/*.ts"];
|
|
276
|
+
const errors = [];
|
|
277
|
+
const warnings = [];
|
|
278
|
+
const config = loadParsedCommandLine({
|
|
279
|
+
projectPath,
|
|
280
|
+
tsconfigPath,
|
|
281
|
+
include,
|
|
282
|
+
errors});
|
|
283
|
+
if (!config) return { specs: [], errors, warnings };
|
|
284
|
+
const program = ts2__namespace.createProgram(config.fileNames, config.options);
|
|
285
|
+
const typeChecker = program.getTypeChecker();
|
|
286
|
+
const specs = [];
|
|
287
|
+
const configFileSet = new Set(config.fileNames.map((f) => path__namespace.resolve(f)));
|
|
288
|
+
collectToolSpecsFromProgram({
|
|
289
|
+
program,
|
|
290
|
+
typeChecker,
|
|
291
|
+
projectPath,
|
|
292
|
+
warnings,
|
|
293
|
+
configFileSet,
|
|
294
|
+
specs
|
|
295
|
+
});
|
|
296
|
+
return { specs, errors, warnings };
|
|
297
|
+
}
|
|
298
|
+
function loadParsedCommandLine(input) {
|
|
299
|
+
let configPathResolved = path__namespace.resolve(input.projectPath, input.tsconfigPath);
|
|
300
|
+
if (!fs__namespace.existsSync(configPathResolved)) {
|
|
301
|
+
configPathResolved = path__namespace.join(input.projectPath, "tsconfig.json");
|
|
302
|
+
}
|
|
303
|
+
if (!fs__namespace.existsSync(configPathResolved)) {
|
|
304
|
+
return {
|
|
305
|
+
options: {
|
|
306
|
+
target: ts2__namespace.ScriptTarget.ES2022,
|
|
307
|
+
module: ts2__namespace.ModuleKind.ESNext,
|
|
308
|
+
moduleResolution: ts2__namespace.ModuleResolutionKind.NodeNext,
|
|
309
|
+
strict: true,
|
|
310
|
+
skipLibCheck: true,
|
|
311
|
+
noEmit: true
|
|
312
|
+
},
|
|
313
|
+
fileNames: resolveGlob(input.projectPath, input.include),
|
|
314
|
+
errors: []
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const configFile = ts2__namespace.readConfigFile(configPathResolved, ts2__namespace.sys.readFile);
|
|
318
|
+
if (configFile.error) {
|
|
319
|
+
input.errors.push({ file: configPathResolved, message: String(configFile.error.messageText) });
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
const parsed = ts2__namespace.parseJsonConfigFileContent(
|
|
323
|
+
configFile.config,
|
|
324
|
+
ts2__namespace.sys,
|
|
325
|
+
path__namespace.dirname(configPathResolved)
|
|
326
|
+
);
|
|
327
|
+
if (parsed.errors.length === 0) return parsed;
|
|
328
|
+
for (const e of parsed.errors) {
|
|
329
|
+
input.errors.push({ file: e.file?.fileName ?? "tsconfig", message: String(e.messageText) });
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
function collectToolSpecsFromProgram(input) {
|
|
334
|
+
for (const sourceFile of input.program.getSourceFiles()) {
|
|
335
|
+
const fileName = sourceFile.fileName;
|
|
336
|
+
if (fileName.includes("node_modules") || fileName.endsWith(".d.ts")) continue;
|
|
337
|
+
if (!input.configFileSet.has(path__namespace.resolve(fileName))) continue;
|
|
338
|
+
ts2__namespace.forEachChild(sourceFile, (node) => {
|
|
339
|
+
const spec = toFunctionToolSpec({
|
|
340
|
+
node,
|
|
341
|
+
fileName,
|
|
342
|
+
projectPath: input.projectPath,
|
|
343
|
+
typeChecker: input.typeChecker,
|
|
344
|
+
warnings: input.warnings
|
|
345
|
+
});
|
|
346
|
+
if (spec) input.specs.push(spec);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function toFunctionToolSpec(input) {
|
|
351
|
+
const decl = getExportedFunctionDeclaration(input.node);
|
|
352
|
+
if (!decl || !decl.name) return null;
|
|
353
|
+
const host = getJSDocHost(decl.func);
|
|
354
|
+
if (!hasToolTag(host)) return null;
|
|
355
|
+
const jsDoc = getJSDocComments(host);
|
|
356
|
+
const description = getDescription(jsDoc);
|
|
357
|
+
if (!description) {
|
|
358
|
+
input.warnings.push({
|
|
359
|
+
file: input.fileName,
|
|
360
|
+
message: `Tool ${decl.name}: missing description, using humanized name`
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
const sideEffect = getEffect(host);
|
|
364
|
+
const onWarn = (msg) => input.warnings.push({ file: input.fileName, message: `${decl.name}: ${msg}` });
|
|
365
|
+
const { schema } = buildInputSchemaFromParams(decl.func, input.typeChecker, onWarn);
|
|
366
|
+
const outputSchema = buildOutputSchemaFromReturnType(decl.func, input.typeChecker, onWarn);
|
|
367
|
+
const sourcePath = path__namespace.relative(input.projectPath, input.fileName) || path__namespace.basename(input.fileName);
|
|
368
|
+
const toolName = pathToToolName(sourcePath, decl.name);
|
|
369
|
+
return {
|
|
370
|
+
kind: FUNCTION_KIND,
|
|
371
|
+
name: toolName,
|
|
372
|
+
description: description || humanize(decl.name),
|
|
373
|
+
inputSchema: normalizeInputSchema(schema),
|
|
374
|
+
outputSchema,
|
|
375
|
+
_meta: { hitl: { sideEffect } },
|
|
376
|
+
sourcePath,
|
|
377
|
+
exportName: decl.name
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function normalizeInputSchema(schema) {
|
|
381
|
+
return Object.keys(schema.properties ?? {}).length > 0 ? schema : { type: "object", properties: {} };
|
|
382
|
+
}
|
|
383
|
+
function resolveGlob(projectPath, patterns) {
|
|
384
|
+
const result = [];
|
|
385
|
+
const seen = /* @__PURE__ */ new Set();
|
|
386
|
+
const add = (f) => {
|
|
387
|
+
const abs = path__namespace.resolve(f);
|
|
388
|
+
if (f.endsWith(".ts") && !f.endsWith(".d.ts") && !seen.has(abs)) {
|
|
389
|
+
seen.add(abs);
|
|
390
|
+
result.push(abs);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
for (const p of patterns) {
|
|
394
|
+
const full = path__namespace.join(projectPath, p);
|
|
395
|
+
if (full.includes("*")) {
|
|
396
|
+
const baseDir = full.replace(/\*\*\/.*$/, "").replace(/\*.*$/, "").replace(/\/?$/, "") || ".";
|
|
397
|
+
const dir = path__namespace.resolve(projectPath, baseDir);
|
|
398
|
+
if (fs__namespace.existsSync(dir)) walk(dir, add);
|
|
399
|
+
} else {
|
|
400
|
+
const resolved = path__namespace.resolve(projectPath, full);
|
|
401
|
+
if (fs__namespace.existsSync(resolved)) {
|
|
402
|
+
if (fs__namespace.statSync(resolved).isFile()) add(resolved);
|
|
403
|
+
else walk(resolved, add);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (result.length > 0) return result;
|
|
408
|
+
const srcDir = path__namespace.join(projectPath, "src");
|
|
409
|
+
if (fs__namespace.existsSync(srcDir)) return walkCollect(srcDir);
|
|
410
|
+
return [];
|
|
411
|
+
}
|
|
412
|
+
function walkCollect(dir) {
|
|
413
|
+
const out = [];
|
|
414
|
+
walk(dir, (fullPath) => {
|
|
415
|
+
if (fullPath.endsWith(".ts") && !fullPath.endsWith(".d.ts")) out.push(path__namespace.resolve(fullPath));
|
|
416
|
+
});
|
|
417
|
+
return out;
|
|
418
|
+
}
|
|
419
|
+
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "generated", "dist"]);
|
|
420
|
+
function walk(dir, visit) {
|
|
421
|
+
try {
|
|
422
|
+
const entries = fs__namespace.readdirSync(dir, { withFileTypes: true });
|
|
423
|
+
for (const e of entries) {
|
|
424
|
+
const full = path__namespace.join(dir, e.name);
|
|
425
|
+
if (e.isDirectory() && !SKIP_DIRS.has(e.name)) walk(full, visit);
|
|
426
|
+
else if (e.isFile()) visit(full);
|
|
427
|
+
}
|
|
428
|
+
} catch {
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function getExportedFunctionDeclaration(node, _sourceFile) {
|
|
432
|
+
if (ts2__namespace.isFunctionDeclaration(node) && node.name) {
|
|
433
|
+
const exported = (ts2__namespace.getModifiers(node) ?? []).some((m) => m.kind === ts2__namespace.SyntaxKind.ExportKeyword);
|
|
434
|
+
if (exported) return { func: node, name: node.name.getText() };
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
if (ts2__namespace.isVariableStatement(node)) {
|
|
438
|
+
const exported = (ts2__namespace.getModifiers(node) ?? []).some((m) => m.kind === ts2__namespace.SyntaxKind.ExportKeyword);
|
|
439
|
+
if (!exported) return null;
|
|
440
|
+
for (const decl of node.declarationList.declarations) {
|
|
441
|
+
let init = decl.initializer;
|
|
442
|
+
while (init && (ts2__namespace.isParenthesizedExpression(init) || ts2__namespace.isAsExpression(init)))
|
|
443
|
+
init = init.expression;
|
|
444
|
+
if (init && ts2__namespace.isArrowFunction(init)) {
|
|
445
|
+
const name = decl.name.getText();
|
|
446
|
+
return { func: init, name };
|
|
447
|
+
}
|
|
448
|
+
if (init && ts2__namespace.isFunctionExpression(init)) {
|
|
449
|
+
const name = decl.name.getText();
|
|
450
|
+
return { func: init, name };
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
function getJSDocHost(node) {
|
|
457
|
+
const parent = node.parent;
|
|
458
|
+
if (ts2__namespace.isVariableDeclaration(parent)) {
|
|
459
|
+
const gp = parent.parent;
|
|
460
|
+
if (ts2__namespace.isVariableDeclarationList(gp) && gp.parent && ts2__namespace.isVariableStatement(gp.parent)) return gp.parent;
|
|
461
|
+
}
|
|
462
|
+
return node;
|
|
463
|
+
}
|
|
464
|
+
function getJSDocComments(host) {
|
|
465
|
+
const all = ts2__namespace.getJSDocCommentsAndTags(host);
|
|
466
|
+
return all.filter((t) => ts2__namespace.isJSDoc(t));
|
|
467
|
+
}
|
|
468
|
+
function hasToolTag(host) {
|
|
469
|
+
const tags = ts2__namespace.getJSDocTags(host);
|
|
470
|
+
for (const tag of tags) {
|
|
471
|
+
const name = tag.tagName?.getText() ?? "";
|
|
472
|
+
if (name === "tool") return true;
|
|
473
|
+
}
|
|
474
|
+
const all = ts2__namespace.getJSDocCommentsAndTags(host);
|
|
475
|
+
for (const t of all) {
|
|
476
|
+
if (ts2__namespace.isJSDoc(t)) {
|
|
477
|
+
const full = t.getFullText();
|
|
478
|
+
if (full.includes(TOOL_TAG)) return true;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
function getDescription(jsDocs) {
|
|
484
|
+
for (const doc of jsDocs) {
|
|
485
|
+
const comment = doc.comment;
|
|
486
|
+
if (typeof comment === "string") {
|
|
487
|
+
const first = comment.split(/\n/)[0]?.trim() ?? "";
|
|
488
|
+
if (first && !first.startsWith("@")) return first;
|
|
489
|
+
}
|
|
490
|
+
if (Array.isArray(comment)) {
|
|
491
|
+
const first = comment[0];
|
|
492
|
+
if (first && typeof first === "object" && "text" in first) {
|
|
493
|
+
const t = first.text.trim();
|
|
494
|
+
if (t && !t.startsWith("@")) return t;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
const full = doc.getFullText();
|
|
498
|
+
const match = full.match(/\*\s*@tool\s+(.+?)(?=\n|$|\*\/)/s);
|
|
499
|
+
if (match?.[1]) return match[1].trim();
|
|
500
|
+
}
|
|
501
|
+
return "";
|
|
502
|
+
}
|
|
503
|
+
function getEffect(host) {
|
|
504
|
+
const tags = ts2__namespace.getJSDocTags(host);
|
|
505
|
+
for (const tag of tags) {
|
|
506
|
+
const name = tag.tagName?.getText() ?? "";
|
|
507
|
+
if (name === "effect") {
|
|
508
|
+
const comment = tag.comment;
|
|
509
|
+
const v = (typeof comment === "string" ? comment : "").trim().toLowerCase();
|
|
510
|
+
if (EFFECT_VALUES.includes(v)) return v;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
const all = ts2__namespace.getJSDocCommentsAndTags(host);
|
|
514
|
+
for (const t of all) {
|
|
515
|
+
if (ts2__namespace.isJSDoc(t)) {
|
|
516
|
+
const full = t.getFullText();
|
|
517
|
+
const match = full.match(/\*\s*@effect\s+(\w+)/);
|
|
518
|
+
if (match && EFFECT_VALUES.includes(match[1])) return match[1];
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return "none";
|
|
522
|
+
}
|
|
523
|
+
function humanize(name) {
|
|
524
|
+
return name.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
|
|
525
|
+
}
|
|
526
|
+
function scan(projectPath, options = {}) {
|
|
527
|
+
const root = path__namespace.resolve(projectPath);
|
|
528
|
+
const result = scanForTools({
|
|
529
|
+
projectPath: root,
|
|
530
|
+
include: options.include ?? ["**/*.ts"],
|
|
531
|
+
tsconfigPath: options.tsconfigPath
|
|
532
|
+
});
|
|
533
|
+
const specs = result.specs.map((s) => mcpSpecToToolSpec(s, root));
|
|
534
|
+
return Promise.resolve({
|
|
535
|
+
specs,
|
|
536
|
+
errors: result.errors,
|
|
537
|
+
warnings: result.warnings
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
exports.FUNCTION_KIND = FUNCTION_KIND;
|
|
542
|
+
exports.N8N_KIND = N8N_KIND;
|
|
543
|
+
exports.SKILL_DIR_NAME = SKILL_DIR_NAME;
|
|
544
|
+
exports.SKILL_KIND = SKILL_KIND;
|
|
545
|
+
exports.createToolSpec = createToolSpec;
|
|
546
|
+
exports.findDirsContainingFile = findDirsContainingFile;
|
|
547
|
+
exports.mcpSpecToToolSpec = mcpSpecToToolSpec;
|
|
548
|
+
exports.normalizeToolName = normalizeToolName;
|
|
549
|
+
exports.pathToToolName = pathToToolName;
|
|
550
|
+
exports.scan = scan;
|
|
551
|
+
exports.scanForTools = scanForTools;
|
|
552
|
+
//# sourceMappingURL=chunk-JW4EMVTE.cjs.map
|
|
553
|
+
//# sourceMappingURL=chunk-JW4EMVTE.cjs.map
|