@crewx/sdk 0.8.0-rc.72 → 0.8.0-rc.74
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 +380 -818
- package/dist/adapter/context-builder.d.ts +35 -0
- package/dist/adapter/context-builder.js +87 -0
- package/dist/adapter/index.d.ts +5 -0
- package/dist/{core/remote → adapter}/index.js +3 -2
- package/dist/adapter/plugin-helper.d.ts +19 -0
- package/dist/adapter/plugin-helper.js +45 -0
- package/dist/adapter/scoped-store.d.ts +12 -0
- package/dist/adapter/scoped-store.js +43 -0
- package/dist/adapter/types.d.ts +264 -0
- package/dist/adapter/types.js +23 -0
- package/dist/agent/resolver.d.ts +18 -0
- package/dist/agent/resolver.js +46 -0
- package/dist/boxing/box-storage.interface.d.ts +12 -0
- package/dist/boxing/box-storage.interface.js +3 -0
- package/dist/boxing/box.service.d.ts +4 -0
- package/dist/boxing/box.service.js +5 -1
- package/dist/boxing/box.types.d.ts +4 -0
- package/dist/boxing/box.types.js +3 -0
- package/dist/boxing/context-builder.d.ts +6 -7
- package/dist/boxing/context-builder.js +3 -0
- package/dist/client/CrewxClient.d.ts +65 -0
- package/dist/client/CrewxClient.js +86 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +6 -0
- package/dist/config/loader.browser.d.ts +14 -0
- package/dist/config/loader.browser.js +59 -0
- package/dist/config/loader.d.ts +19 -0
- package/dist/config/loader.js +95 -0
- package/dist/conversation/index.d.ts +5 -3
- package/dist/conversation/index.js +8 -3
- package/dist/conversation/sqlite-provider.d.ts +21 -0
- package/dist/conversation/sqlite-provider.js +178 -0
- package/dist/conversation/to-task-reader.d.ts +14 -0
- package/dist/conversation/to-task-reader.js +28 -0
- package/dist/conversation/to-template-messages.d.ts +15 -0
- package/dist/conversation/to-template-messages.js +34 -0
- package/dist/conversation/types.d.ts +101 -0
- package/dist/conversation/types.js +10 -0
- package/dist/esm/agent/resolver.js +41 -0
- package/dist/esm/boxing/box-storage.interface.js +5 -0
- package/dist/esm/boxing/box.service.js +69 -0
- package/dist/esm/boxing/box.types.js +5 -0
- package/dist/esm/boxing/context-builder.js +76 -0
- package/dist/esm/client/CrewxClient.js +82 -0
- package/dist/esm/client/index.js +2 -0
- package/dist/esm/config/loader.browser.js +54 -0
- package/dist/esm/config/loader.js +77 -0
- package/dist/esm/events/TypedEventEmitter.js +61 -0
- package/dist/esm/events/types.js +8 -0
- package/dist/esm/facade/Crewx.browser.js +310 -0
- package/dist/esm/facade/Crewx.js +941 -0
- package/dist/esm/hooks/define.js +10 -0
- package/dist/esm/hooks/dispatch.js +76 -0
- package/dist/esm/hooks/index.js +6 -0
- package/dist/esm/hooks/observer.js +56 -0
- package/dist/esm/hooks/plugin.js +12 -0
- package/dist/esm/hooks/types.js +9 -0
- package/dist/esm/index.browser.js +15 -0
- package/dist/esm/index.js +60 -0
- package/dist/esm/layout/loader.js +268 -0
- package/dist/esm/layout/props-validator.js +297 -0
- package/dist/esm/layout/renderer.js +180 -0
- package/dist/esm/layout/types.js +31 -0
- package/dist/esm/parallel/agent-runtime.js +21 -0
- package/dist/esm/parallel/helpers.js +214 -0
- package/dist/esm/parallel/index.js +5 -0
- package/dist/esm/parallel/parallel-runner.js +221 -0
- package/dist/esm/parallel/types.js +5 -0
- package/dist/esm/parsers/agent-call.util.js +15 -0
- package/dist/esm/parsers/claude.parser.js +64 -0
- package/dist/esm/parsers/codex.parser.js +97 -0
- package/dist/esm/parsers/copilot.parser.js +63 -0
- package/dist/esm/parsers/gemini.parser.js +43 -0
- package/dist/esm/parsers/opencode.parser.js +73 -0
- package/dist/esm/parsers/router.js +53 -0
- package/dist/esm/platform/BrowserFsAdapter.js +80 -0
- package/dist/esm/platform/IFsAdapter.js +2 -0
- package/dist/esm/platform/NodeFsAdapter.js +34 -0
- package/dist/esm/plugin/plugin-provider.js +202 -0
- package/dist/esm/plugin/types.js +8 -0
- package/dist/esm/plugin.js +25 -0
- package/dist/esm/provider/bridge.browser.js +43 -0
- package/dist/esm/provider/bridge.js +373 -0
- package/dist/esm/provider/parse-usage.js +80 -0
- package/dist/esm/provider/register-api.js +21 -0
- package/dist/esm/provider/vercel-runtime.js +310 -0
- package/dist/esm/remote/index.js +10 -0
- package/dist/esm/remote/remote-agent-manager.js +194 -0
- package/dist/esm/remote/remote-provider.js +98 -0
- package/dist/esm/remote/remote-transport.js +79 -0
- package/dist/esm/remote/types.js +8 -0
- package/dist/esm/server/auth.js +31 -0
- package/dist/esm/server/handler.js +72 -0
- package/dist/esm/server/index.js +5 -0
- package/dist/esm/server/tool-adapter.js +92 -0
- package/dist/esm/template/engine.js +100 -0
- package/dist/esm/template/helpers/exec.browser.js +31 -0
- package/dist/esm/template/helpers/exec.js +220 -0
- package/dist/esm/template/helpers/fenced_code.js +17 -0
- package/dist/esm/template/helpers/include.js +20 -0
- package/dist/esm/template/helpers/p1p2.js +83 -0
- package/dist/esm/template/loader/DocumentLoader.js +124 -0
- package/dist/esm/template/types.js +5 -0
- package/dist/esm/tools/delegate.js +57 -0
- package/dist/esm/tools/index.js +5 -0
- package/dist/esm/tools/node/builtin.js +541 -0
- package/dist/esm/tools/node/index.js +54 -0
- package/dist/esm/types/index.js +27 -0
- package/dist/esm/types/task-log.types.js +5 -0
- package/dist/esm/utils/env-defaults.js +23 -0
- package/dist/esm/utils/glob-match.js +38 -0
- package/dist/esm/utils/id.js +46 -0
- package/dist/esm/utils/workspace.js +21 -0
- package/dist/events/TypedEventEmitter.d.ts +31 -0
- package/dist/events/TypedEventEmitter.js +65 -0
- package/dist/events/types.d.ts +139 -0
- package/dist/events/types.js +9 -0
- package/dist/facade/Crewx.browser.d.ts +73 -0
- package/dist/facade/Crewx.browser.js +314 -0
- package/dist/facade/Crewx.d.ts +267 -0
- package/dist/facade/Crewx.js +1299 -0
- package/dist/hooks/define.d.ts +10 -0
- package/dist/hooks/define.js +13 -0
- package/dist/hooks/dispatch.d.ts +61 -0
- package/dist/hooks/dispatch.js +147 -0
- package/dist/hooks/index.d.ts +13 -0
- package/dist/hooks/index.js +24 -0
- package/dist/hooks/observer.d.ts +20 -0
- package/dist/hooks/observer.js +60 -0
- package/dist/hooks/plugin.d.ts +19 -0
- package/dist/hooks/plugin.js +17 -0
- package/dist/hooks/tool-normalize.d.ts +29 -0
- package/dist/hooks/tool-normalize.js +110 -0
- package/dist/hooks/types.d.ts +79 -0
- package/dist/hooks/types.js +12 -0
- package/dist/hooks/yaml-plugin.d.ts +29 -0
- package/dist/hooks/yaml-plugin.js +356 -0
- package/dist/index.browser.d.ts +15 -0
- package/dist/index.browser.js +25 -0
- package/dist/index.d.ts +70 -58
- package/dist/index.js +144 -133
- package/dist/{services/layout-loader.service.d.ts → layout/loader.d.ts} +24 -4
- package/dist/{services/layout-loader.service.js → layout/loader.js} +103 -73
- package/dist/{services/props-validator.service.d.ts → layout/props-validator.d.ts} +7 -1
- package/dist/{services/props-validator.service.js → layout/props-validator.js} +28 -59
- package/dist/{services/layout-renderer.service.d.ts → layout/renderer.d.ts} +28 -14
- package/dist/layout/renderer.js +193 -0
- package/dist/{types/layout.types.d.ts → layout/types.d.ts} +47 -1
- package/dist/{types/layout.types.js → layout/types.js} +15 -1
- package/dist/parallel/agent-runtime.d.ts +31 -0
- package/dist/parallel/agent-runtime.js +25 -0
- package/dist/{core/parallel → parallel}/helpers.d.ts +2 -1
- package/dist/{core/parallel → parallel}/helpers.js +55 -88
- package/dist/parallel/index.d.ts +8 -0
- package/dist/{core/parallel → parallel}/index.js +5 -3
- package/dist/{core/parallel → parallel}/parallel-runner.d.ts +8 -1
- package/dist/{core/parallel → parallel}/parallel-runner.js +53 -57
- package/dist/parallel/types.d.ts +65 -0
- package/dist/parallel/types.js +6 -0
- package/dist/parsers/agent-call.util.d.ts +3 -0
- package/dist/parsers/agent-call.util.js +2 -0
- package/dist/parsers/api.parser.d.ts +10 -0
- package/dist/parsers/api.parser.js +26 -0
- package/dist/parsers/claude.parser.d.ts +8 -0
- package/dist/parsers/claude.parser.js +22 -1
- package/dist/parsers/codex.parser.d.ts +8 -0
- package/dist/parsers/codex.parser.js +11 -0
- package/dist/parsers/copilot.parser.d.ts +9 -0
- package/dist/parsers/copilot.parser.js +8 -0
- package/dist/parsers/gemini.parser.d.ts +10 -0
- package/dist/parsers/gemini.parser.js +10 -0
- package/dist/parsers/opencode.parser.d.ts +12 -0
- package/dist/parsers/opencode.parser.js +76 -0
- package/dist/parsers/router.d.ts +7 -0
- package/dist/parsers/router.js +56 -0
- package/dist/platform/BrowserFsAdapter.d.ts +37 -0
- package/dist/platform/BrowserFsAdapter.js +84 -0
- package/dist/platform/IFsAdapter.d.ts +29 -0
- package/dist/{core/remote/types.js → platform/IFsAdapter.js} +1 -1
- package/dist/platform/NodeFsAdapter.d.ts +16 -0
- package/dist/platform/NodeFsAdapter.js +38 -0
- package/dist/plugin/plugin-provider.d.ts +33 -0
- package/dist/plugin/plugin-provider.js +207 -0
- package/dist/plugin/types.d.ts +53 -0
- package/dist/plugin/types.js +9 -0
- package/dist/plugin.d.ts +33 -0
- package/dist/plugin.js +29 -0
- package/dist/plugins/conversation.d.ts +18 -0
- package/dist/plugins/conversation.js +59 -0
- package/dist/plugins/file-logger.d.ts +29 -0
- package/dist/plugins/file-logger.js +87 -0
- package/dist/plugins/index.d.ts +16 -0
- package/dist/plugins/index.js +19 -0
- package/dist/plugins/sqlite-tracing.d.ts +29 -0
- package/dist/plugins/sqlite-tracing.js +112 -0
- package/dist/provider/bridge.browser.d.ts +49 -0
- package/dist/provider/bridge.browser.js +49 -0
- package/dist/provider/bridge.d.ts +106 -0
- package/dist/provider/bridge.js +380 -0
- package/dist/provider/mastra-runtime.d.ts +45 -0
- package/dist/provider/mastra-runtime.js +208 -0
- package/dist/provider/parse-usage.d.ts +20 -0
- package/dist/provider/parse-usage.js +83 -0
- package/dist/provider/register-api.d.ts +14 -0
- package/dist/provider/register-api.js +24 -0
- package/dist/provider/vercel-runtime.d.ts +54 -0
- package/dist/provider/vercel-runtime.js +347 -0
- package/dist/remote/index.d.ts +13 -0
- package/dist/remote/index.js +32 -0
- package/dist/remote/remote-agent-manager.d.ts +54 -0
- package/dist/{core/remote → remote}/remote-agent-manager.js +100 -97
- package/dist/remote/remote-provider.d.ts +47 -0
- package/dist/remote/remote-provider.js +141 -0
- package/dist/remote/remote-transport.d.ts +32 -0
- package/dist/remote/remote-transport.js +83 -0
- package/dist/remote/types.d.ts +147 -0
- package/dist/remote/types.js +9 -0
- package/dist/server/auth.d.ts +21 -0
- package/dist/server/auth.js +35 -0
- package/dist/server/handler.d.ts +24 -0
- package/dist/server/handler.js +75 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.js +9 -0
- package/dist/server/tool-adapter.d.ts +19 -0
- package/dist/server/tool-adapter.js +95 -0
- package/dist/template/engine.d.ts +28 -0
- package/dist/template/engine.js +137 -0
- package/dist/template/helpers/exec.browser.d.ts +22 -0
- package/dist/template/helpers/exec.browser.js +41 -0
- package/dist/template/helpers/exec.d.ts +60 -0
- package/dist/template/helpers/exec.js +230 -0
- package/dist/template/helpers/fenced_code.d.ts +22 -0
- package/dist/template/helpers/fenced_code.js +20 -0
- package/dist/template/helpers/format-conversation.d.ts +30 -0
- package/dist/template/helpers/format-conversation.js +53 -0
- package/dist/template/helpers/include.d.ts +16 -0
- package/dist/template/helpers/include.js +23 -0
- package/dist/template/helpers/p1p2.d.ts +37 -0
- package/dist/template/helpers/p1p2.js +90 -0
- package/dist/template/loader/DocumentLoader.d.ts +48 -0
- package/dist/template/loader/DocumentLoader.js +128 -0
- package/dist/template/types.d.ts +51 -0
- package/dist/template/types.js +6 -0
- package/dist/testing/index.d.ts +12 -0
- package/dist/testing/index.js +16 -0
- package/dist/testing/mock-audit.d.ts +10 -0
- package/dist/testing/mock-audit.js +13 -0
- package/dist/testing/mock-context.d.ts +27 -0
- package/dist/testing/mock-context.js +68 -0
- package/dist/testing/mock-logger.d.ts +15 -0
- package/dist/testing/mock-logger.js +27 -0
- package/dist/testing/mock-router.d.ts +16 -0
- package/dist/testing/mock-router.js +67 -0
- package/dist/testing/mock-storage.d.ts +9 -0
- package/dist/testing/mock-storage.js +21 -0
- package/dist/testing/mock-store.d.ts +3 -0
- package/dist/testing/mock-store.js +8 -0
- package/dist/tools/delegate.d.ts +10 -0
- package/dist/tools/delegate.js +60 -0
- package/dist/tools/index.d.ts +5 -12
- package/dist/tools/index.js +6 -37
- package/dist/tools/node/builtin.d.ts +23 -0
- package/dist/tools/node/builtin.js +547 -0
- package/dist/tools/node/index.d.ts +23 -0
- package/dist/tools/node/index.js +59 -0
- package/dist/types/index.d.ts +804 -6
- package/dist/types/index.js +29 -20
- package/dist/types/task-log.types.d.ts +4 -0
- package/dist/types/task-log.types.js +3 -0
- package/dist/utils/env-defaults.d.ts +18 -0
- package/dist/utils/env-defaults.js +27 -0
- package/dist/utils/glob-match.d.ts +18 -0
- package/dist/utils/glob-match.js +42 -0
- package/dist/{core → utils}/id.d.ts +15 -0
- package/dist/utils/id.js +50 -0
- package/dist/utils/timestamp.d.ts +2 -0
- package/dist/utils/timestamp.js +13 -0
- package/dist/{core → utils}/workspace.d.ts +4 -0
- package/dist/{core → utils}/workspace.js +3 -0
- package/package.json +67 -102
- package/src/schemas/hooks.schema.json +59 -0
- package/templates/agents/default.yaml +490 -0
- package/templates/agents/minimal.yaml +16 -0
- package/LICENSE +0 -201
- package/dist/adapters/MastraToolAdapter.d.ts +0 -9
- package/dist/adapters/MastraToolAdapter.js +0 -66
- package/dist/adapters/MastraToolAdapter.js.map +0 -1
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.js +0 -8
- package/dist/api/index.js.map +0 -1
- package/dist/boxing/box-storage.interface.js.map +0 -1
- package/dist/boxing/box.service.js.map +0 -1
- package/dist/boxing/box.types.js.map +0 -1
- package/dist/boxing/context-builder.js.map +0 -1
- package/dist/boxing/index.d.ts +0 -6
- package/dist/boxing/index.js +0 -11
- package/dist/boxing/index.js.map +0 -1
- package/dist/boxing/tokenizer.d.ts +0 -3
- package/dist/boxing/tokenizer.js +0 -11
- package/dist/boxing/tokenizer.js.map +0 -1
- package/dist/config/api-provider-parser.d.ts +0 -58
- package/dist/config/api-provider-parser.js +0 -212
- package/dist/config/api-provider-parser.js.map +0 -1
- package/dist/config/index.d.ts +0 -3
- package/dist/config/index.js +0 -20
- package/dist/config/index.js.map +0 -1
- package/dist/config/log.config.d.ts +0 -7
- package/dist/config/log.config.js +0 -20
- package/dist/config/log.config.js.map +0 -1
- package/dist/config/pricing.d.ts +0 -11
- package/dist/config/pricing.js +0 -53
- package/dist/config/pricing.js.map +0 -1
- package/dist/config/timeout.config.d.ts +0 -14
- package/dist/config/timeout.config.js +0 -34
- package/dist/config/timeout.config.js.map +0 -1
- package/dist/config/yaml-loader.d.ts +0 -8
- package/dist/config/yaml-loader.js +0 -155
- package/dist/config/yaml-loader.js.map +0 -1
- package/dist/constants/index.d.ts +0 -4
- package/dist/constants/index.js +0 -8
- package/dist/constants/index.js.map +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -18
- package/dist/constants.js.map +0 -1
- package/dist/conversation/conversation-config.d.ts +0 -9
- package/dist/conversation/conversation-config.js +0 -22
- package/dist/conversation/conversation-config.js.map +0 -1
- package/dist/conversation/conversation-history.interface.d.ts +0 -36
- package/dist/conversation/conversation-history.interface.js +0 -3
- package/dist/conversation/conversation-history.interface.js.map +0 -1
- package/dist/conversation/conversation-storage.service.d.ts +0 -16
- package/dist/conversation/conversation-storage.service.js +0 -213
- package/dist/conversation/conversation-storage.service.js.map +0 -1
- package/dist/conversation/index.js.map +0 -1
- package/dist/core/__tests__/id.test.d.ts +0 -1
- package/dist/core/__tests__/id.test.js +0 -115
- package/dist/core/__tests__/id.test.js.map +0 -1
- package/dist/core/agent/agent-factory.d.ts +0 -37
- package/dist/core/agent/agent-factory.js +0 -68
- package/dist/core/agent/agent-factory.js.map +0 -1
- package/dist/core/agent/agent-runtime.d.ts +0 -52
- package/dist/core/agent/agent-runtime.js +0 -206
- package/dist/core/agent/agent-runtime.js.map +0 -1
- package/dist/core/agent/event-bus.d.ts +0 -44
- package/dist/core/agent/event-bus.js +0 -43
- package/dist/core/agent/event-bus.js.map +0 -1
- package/dist/core/agent/index.d.ts +0 -3
- package/dist/core/agent/index.js +0 -13
- package/dist/core/agent/index.js.map +0 -1
- package/dist/core/env-defaults.d.ts +0 -1
- package/dist/core/env-defaults.js +0 -7
- package/dist/core/env-defaults.js.map +0 -1
- package/dist/core/id.js +0 -27
- package/dist/core/id.js.map +0 -1
- package/dist/core/parallel/helpers.js.map +0 -1
- package/dist/core/parallel/index.d.ts +0 -4
- package/dist/core/parallel/index.js.map +0 -1
- package/dist/core/parallel/parallel-runner.js.map +0 -1
- package/dist/core/parallel/types.d.ts +0 -41
- package/dist/core/parallel/types.js +0 -3
- package/dist/core/parallel/types.js.map +0 -1
- package/dist/core/providers/MastraAPIProvider.d.ts +0 -31
- package/dist/core/providers/MastraAPIProvider.js +0 -365
- package/dist/core/providers/MastraAPIProvider.js.map +0 -1
- package/dist/core/providers/ai-provider.interface.d.ts +0 -79
- package/dist/core/providers/ai-provider.interface.js +0 -23
- package/dist/core/providers/ai-provider.interface.js.map +0 -1
- package/dist/core/providers/base-ai.provider.d.ts +0 -84
- package/dist/core/providers/base-ai.provider.js +0 -1237
- package/dist/core/providers/base-ai.provider.js.map +0 -1
- package/dist/core/providers/base-ai.types.d.ts +0 -26
- package/dist/core/providers/base-ai.types.js +0 -3
- package/dist/core/providers/base-ai.types.js.map +0 -1
- package/dist/core/providers/claude.provider.d.ts +0 -19
- package/dist/core/providers/claude.provider.js +0 -170
- package/dist/core/providers/claude.provider.js.map +0 -1
- package/dist/core/providers/codex.provider.d.ts +0 -21
- package/dist/core/providers/codex.provider.js +0 -134
- package/dist/core/providers/codex.provider.js.map +0 -1
- package/dist/core/providers/copilot.provider.d.ts +0 -25
- package/dist/core/providers/copilot.provider.js +0 -146
- package/dist/core/providers/copilot.provider.js.map +0 -1
- package/dist/core/providers/dynamic-provider.factory.d.ts +0 -74
- package/dist/core/providers/dynamic-provider.factory.js +0 -645
- package/dist/core/providers/dynamic-provider.factory.js.map +0 -1
- package/dist/core/providers/gemini.provider.d.ts +0 -16
- package/dist/core/providers/gemini.provider.js +0 -101
- package/dist/core/providers/gemini.provider.js.map +0 -1
- package/dist/core/providers/index.d.ts +0 -8
- package/dist/core/providers/index.js +0 -20
- package/dist/core/providers/index.js.map +0 -1
- package/dist/core/providers/mock.provider.d.ts +0 -13
- package/dist/core/providers/mock.provider.js +0 -55
- package/dist/core/providers/mock.provider.js.map +0 -1
- package/dist/core/providers/provider-factory.d.ts +0 -3
- package/dist/core/providers/provider-factory.js +0 -65
- package/dist/core/providers/provider-factory.js.map +0 -1
- package/dist/core/providers/tool-call.types.d.ts +0 -39
- package/dist/core/providers/tool-call.types.js +0 -3
- package/dist/core/providers/tool-call.types.js.map +0 -1
- package/dist/core/remote/index.d.ts +0 -3
- package/dist/core/remote/index.js.map +0 -1
- package/dist/core/remote/remote-agent-manager.d.ts +0 -24
- package/dist/core/remote/remote-agent-manager.js.map +0 -1
- package/dist/core/remote/remote-transport.d.ts +0 -15
- package/dist/core/remote/remote-transport.js +0 -70
- package/dist/core/remote/remote-transport.js.map +0 -1
- package/dist/core/remote/types.d.ts +0 -79
- package/dist/core/remote/types.js.map +0 -1
- package/dist/core/workspace.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/index.d.ts +0 -1
- package/dist/internal/index.js +0 -6
- package/dist/internal/index.js.map +0 -1
- package/dist/knowledge/DocumentManager.d.ts +0 -4
- package/dist/knowledge/DocumentManager.js +0 -119
- package/dist/knowledge/DocumentManager.js.map +0 -1
- package/dist/knowledge/index.d.ts +0 -1
- package/dist/knowledge/index.js +0 -18
- package/dist/knowledge/index.js.map +0 -1
- package/dist/parsers/agent-call.util.js.map +0 -1
- package/dist/parsers/claude.parser.js.map +0 -1
- package/dist/parsers/codex.parser.js.map +0 -1
- package/dist/parsers/copilot.parser.js.map +0 -1
- package/dist/parsers/gemini.parser.js.map +0 -1
- package/dist/parsers/index.d.ts +0 -7
- package/dist/parsers/index.js +0 -45
- package/dist/parsers/index.js.map +0 -1
- package/dist/schema/skills-parser.d.ts +0 -8
- package/dist/schema/skills-parser.js +0 -438
- package/dist/schema/skills-parser.js.map +0 -1
- package/dist/schema/skills.types.d.ts +0 -158
- package/dist/schema/skills.types.js +0 -41
- package/dist/schema/skills.types.js.map +0 -1
- package/dist/schemas/api-provider.schema.d.ts +0 -432
- package/dist/schemas/api-provider.schema.js +0 -50
- package/dist/schemas/api-provider.schema.js.map +0 -1
- package/dist/services/index.d.ts +0 -2
- package/dist/services/index.js +0 -19
- package/dist/services/index.js.map +0 -1
- package/dist/services/layout-loader.service.js.map +0 -1
- package/dist/services/layout-renderer.service.js +0 -325
- package/dist/services/layout-renderer.service.js.map +0 -1
- package/dist/services/props-validator.service.js.map +0 -1
- package/dist/skills/adapter/claude-skill-adapter.d.ts +0 -11
- package/dist/skills/adapter/claude-skill-adapter.js +0 -222
- package/dist/skills/adapter/claude-skill-adapter.js.map +0 -1
- package/dist/skills/index.d.ts +0 -6
- package/dist/skills/index.js +0 -31
- package/dist/skills/index.js.map +0 -1
- package/dist/skills/runtime/progressive-loader.d.ts +0 -27
- package/dist/skills/runtime/progressive-loader.js +0 -186
- package/dist/skills/runtime/progressive-loader.js.map +0 -1
- package/dist/skills/runtime/runtime-requirements-validator.d.ts +0 -23
- package/dist/skills/runtime/runtime-requirements-validator.js +0 -248
- package/dist/skills/runtime/runtime-requirements-validator.js.map +0 -1
- package/dist/skills/runtime/skill-runtime.service.d.ts +0 -42
- package/dist/skills/runtime/skill-runtime.service.js +0 -434
- package/dist/skills/runtime/skill-runtime.service.js.map +0 -1
- package/dist/tools/file-system.service.d.ts +0 -10
- package/dist/tools/file-system.service.js +0 -33
- package/dist/tools/file-system.service.js.map +0 -1
- package/dist/tools/find.tool.d.ts +0 -21
- package/dist/tools/find.tool.js +0 -139
- package/dist/tools/find.tool.js.map +0 -1
- package/dist/tools/glob.tool.d.ts +0 -24
- package/dist/tools/glob.tool.js +0 -153
- package/dist/tools/glob.tool.js.map +0 -1
- package/dist/tools/grep.tool.d.ts +0 -1
- package/dist/tools/grep.tool.js +0 -137
- package/dist/tools/grep.tool.js.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/ls.tool.d.ts +0 -1
- package/dist/tools/ls.tool.js +0 -94
- package/dist/tools/ls.tool.js.map +0 -1
- package/dist/tools/read-file.tool.d.ts +0 -1
- package/dist/tools/read-file.tool.js +0 -69
- package/dist/tools/read-file.tool.js.map +0 -1
- package/dist/tools/replace.tool.d.ts +0 -1
- package/dist/tools/replace.tool.js +0 -68
- package/dist/tools/replace.tool.js.map +0 -1
- package/dist/tools/run-shell-command.tool.d.ts +0 -1
- package/dist/tools/run-shell-command.tool.js +0 -64
- package/dist/tools/run-shell-command.tool.js.map +0 -1
- package/dist/tools/tree.tool.d.ts +0 -1
- package/dist/tools/tree.tool.js +0 -109
- package/dist/tools/tree.tool.js.map +0 -1
- package/dist/tools/types.d.ts +0 -42
- package/dist/tools/types.js +0 -13
- package/dist/tools/types.js.map +0 -1
- package/dist/tools/utils/file-utils.d.ts +0 -5
- package/dist/tools/utils/file-utils.js +0 -221
- package/dist/tools/utils/file-utils.js.map +0 -1
- package/dist/tools/write-file.tool.d.ts +0 -1
- package/dist/tools/write-file.tool.js +0 -55
- package/dist/tools/write-file.tool.js.map +0 -1
- package/dist/types/agent.types.d.ts +0 -134
- package/dist/types/agent.types.js +0 -16
- package/dist/types/agent.types.js.map +0 -1
- package/dist/types/api-provider.types.d.ts +0 -85
- package/dist/types/api-provider.types.js +0 -65
- package/dist/types/api-provider.types.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/layout.types.js.map +0 -1
- package/dist/types/provider.types.d.ts +0 -12
- package/dist/types/provider.types.js +0 -3
- package/dist/types/provider.types.js.map +0 -1
- package/dist/types/skill-runtime.types.d.ts +0 -244
- package/dist/types/skill-runtime.types.js +0 -44
- package/dist/types/skill-runtime.types.js.map +0 -1
- package/dist/types/structured-payload.types.d.ts +0 -46
- package/dist/types/structured-payload.types.js +0 -65
- package/dist/types/structured-payload.types.js.map +0 -1
- package/dist/types/task-log.types.js.map +0 -1
- package/dist/types/template.types.d.ts +0 -38
- package/dist/types/template.types.js +0 -3
- package/dist/types/template.types.js.map +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -18
- package/dist/types.js.map +0 -1
- package/dist/utils/api-provider-normalizer.d.ts +0 -16
- package/dist/utils/api-provider-normalizer.js +0 -135
- package/dist/utils/api-provider-normalizer.js.map +0 -1
- package/dist/utils/base-message-formatter.d.ts +0 -32
- package/dist/utils/base-message-formatter.js +0 -170
- package/dist/utils/base-message-formatter.js.map +0 -1
- package/dist/utils/error-utils.d.ts +0 -3
- package/dist/utils/error-utils.js +0 -27
- package/dist/utils/error-utils.js.map +0 -1
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.js +0 -21
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/math-utils.d.ts +0 -3
- package/dist/utils/math-utils.js +0 -10
- package/dist/utils/math-utils.js.map +0 -1
- package/dist/utils/mention-parser.d.ts +0 -18
- package/dist/utils/mention-parser.js +0 -136
- package/dist/utils/mention-parser.js.map +0 -1
- package/dist/utils/string-utils.d.ts +0 -1
- package/dist/utils/string-utils.js +0 -10
- package/dist/utils/string-utils.js.map +0 -1
- package/dist/utils.d.ts +0 -3
- package/dist/utils.js +0 -20
- package/dist/utils.js.map +0 -1
- package/schema/api-provider-config.json +0 -138
- package/schema/crewx-config.json +0 -224
- package/schema/skills-config.json +0 -306
|
@@ -1,100 +1,148 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Remote Agent Manager
|
|
4
|
+
*
|
|
5
|
+
* Manages communication with remote MCP agents.
|
|
6
|
+
* Migrated from sdk-bak/src/core/remote/remote-agent-manager.ts
|
|
7
|
+
* and adapted to use the new RemoteTransport interface.
|
|
8
|
+
*/
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.RemoteAgentManager = void 0;
|
|
4
|
-
const
|
|
11
|
+
const remote_transport_js_1 = require("./remote-transport.js");
|
|
12
|
+
/**
|
|
13
|
+
* Remote Agent Manager
|
|
14
|
+
*
|
|
15
|
+
* Manages communication with remote MCP agents.
|
|
16
|
+
* Each loaded agent config creates its own transport instance.
|
|
17
|
+
*/
|
|
5
18
|
class RemoteAgentManager {
|
|
19
|
+
logger;
|
|
20
|
+
configs = new Map();
|
|
21
|
+
transports = new Map();
|
|
6
22
|
constructor(options = {}) {
|
|
7
|
-
this.
|
|
8
|
-
this.transport = options.transport || new remote_transport_1.FetchRemoteTransport();
|
|
9
|
-
this.logger = options.logger || (() => { });
|
|
23
|
+
this.logger = options.logger ?? (() => { });
|
|
10
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Load configuration for a remote agent.
|
|
27
|
+
* Creates a transport instance for the agent.
|
|
28
|
+
*/
|
|
11
29
|
loadConfig(agentId, config) {
|
|
12
30
|
this.validateConfig(config);
|
|
13
31
|
this.configs.set(agentId, config);
|
|
32
|
+
this.transports.set(agentId, new remote_transport_js_1.McpHttpTransport({
|
|
33
|
+
url: config.url,
|
|
34
|
+
apiKey: config.apiKey,
|
|
35
|
+
headers: config.headers,
|
|
36
|
+
timeoutMs: config.timeoutMs,
|
|
37
|
+
}));
|
|
14
38
|
this.logger(`Loaded remote agent config for: ${agentId}`, 'debug');
|
|
15
39
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Load configuration with a custom transport (e.g. for testing).
|
|
42
|
+
*/
|
|
43
|
+
loadConfigWithTransport(agentId, config, transport) {
|
|
44
|
+
this.validateConfig(config);
|
|
45
|
+
this.configs.set(agentId, config);
|
|
46
|
+
this.transports.set(agentId, transport);
|
|
47
|
+
this.logger(`Loaded remote agent config for: ${agentId} (custom transport)`, 'debug');
|
|
21
48
|
}
|
|
49
|
+
/** Get configuration for a remote agent. */
|
|
22
50
|
getConfig(agentId) {
|
|
23
51
|
return this.configs.get(agentId);
|
|
24
52
|
}
|
|
53
|
+
/** Check if an agent is configured as remote. */
|
|
25
54
|
isRemoteAgent(agentId) {
|
|
26
55
|
return this.configs.has(agentId);
|
|
27
56
|
}
|
|
57
|
+
/** Get all configured remote agent IDs. */
|
|
28
58
|
getRemoteAgentIds() {
|
|
29
59
|
return Array.from(this.configs.keys());
|
|
30
60
|
}
|
|
61
|
+
/** Query a remote agent. */
|
|
31
62
|
async query(agentId, request) {
|
|
32
|
-
const config = this.
|
|
33
|
-
if (!config) {
|
|
34
|
-
throw new Error(`Agent ${agentId} is not configured as a remote agent`);
|
|
35
|
-
}
|
|
63
|
+
const config = this.requireConfig(agentId);
|
|
36
64
|
const toolName = config.tools?.query ?? 'crewx_queryAgent';
|
|
37
65
|
const remoteAgentId = config.agentId ?? agentId;
|
|
38
66
|
const payload = {
|
|
39
67
|
agentId: remoteAgentId,
|
|
40
68
|
query: request.query,
|
|
41
69
|
};
|
|
42
|
-
if (request.context)
|
|
70
|
+
if (request.context)
|
|
43
71
|
payload.context = request.context;
|
|
44
|
-
|
|
45
|
-
if (request.model) {
|
|
72
|
+
if (request.model)
|
|
46
73
|
payload.model = request.model;
|
|
47
|
-
|
|
48
|
-
if (request.platform) {
|
|
74
|
+
if (request.platform)
|
|
49
75
|
payload.platform = request.platform;
|
|
50
|
-
|
|
51
|
-
if (request.messages && request.messages.length > 0) {
|
|
76
|
+
if (request.messages?.length)
|
|
52
77
|
payload.messages = request.messages;
|
|
53
|
-
}
|
|
54
78
|
try {
|
|
55
|
-
const result = await this.callRemoteTool(
|
|
79
|
+
const result = await this.callRemoteTool(agentId, toolName, payload);
|
|
56
80
|
return this.normalizeResponse(result);
|
|
57
81
|
}
|
|
58
82
|
catch (error) {
|
|
59
|
-
|
|
83
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
84
|
+
this.logger(`Remote query failed for agent ${agentId}: ${msg}`, 'error');
|
|
60
85
|
throw error;
|
|
61
86
|
}
|
|
62
87
|
}
|
|
88
|
+
/** Execute a task on a remote agent. */
|
|
63
89
|
async execute(agentId, request) {
|
|
64
|
-
const config = this.
|
|
65
|
-
if (!config) {
|
|
66
|
-
throw new Error(`Agent ${agentId} is not configured as a remote agent`);
|
|
67
|
-
}
|
|
90
|
+
const config = this.requireConfig(agentId);
|
|
68
91
|
const toolName = config.tools?.execute ?? 'crewx_executeAgent';
|
|
69
92
|
const remoteAgentId = config.agentId ?? agentId;
|
|
70
93
|
const payload = {
|
|
71
94
|
agentId: remoteAgentId,
|
|
72
95
|
task: request.task,
|
|
73
96
|
};
|
|
74
|
-
if (request.context)
|
|
97
|
+
if (request.context)
|
|
75
98
|
payload.context = request.context;
|
|
76
|
-
|
|
77
|
-
if (request.model) {
|
|
99
|
+
if (request.model)
|
|
78
100
|
payload.model = request.model;
|
|
79
|
-
|
|
80
|
-
if (request.platform) {
|
|
101
|
+
if (request.platform)
|
|
81
102
|
payload.platform = request.platform;
|
|
82
|
-
|
|
83
|
-
if (request.messages && request.messages.length > 0) {
|
|
103
|
+
if (request.messages?.length)
|
|
84
104
|
payload.messages = request.messages;
|
|
85
|
-
}
|
|
86
105
|
try {
|
|
87
|
-
const result = await this.callRemoteTool(
|
|
106
|
+
const result = await this.callRemoteTool(agentId, toolName, payload);
|
|
88
107
|
return this.normalizeResponse(result);
|
|
89
108
|
}
|
|
90
109
|
catch (error) {
|
|
91
|
-
|
|
110
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
111
|
+
this.logger(`Remote execute failed for agent ${agentId}: ${msg}`, 'error');
|
|
92
112
|
throw error;
|
|
93
113
|
}
|
|
94
114
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
115
|
+
/** Map tool names for a remote agent. */
|
|
116
|
+
mapToolNames(agentId, mapping) {
|
|
117
|
+
const config = this.requireConfig(agentId);
|
|
118
|
+
config.tools = {
|
|
119
|
+
query: mapping.query ?? config.tools?.query ?? 'crewx_queryAgent',
|
|
120
|
+
execute: mapping.execute ?? config.tools?.execute ?? 'crewx_executeAgent',
|
|
121
|
+
};
|
|
122
|
+
this.logger(`Updated tool name mapping for agent ${agentId}`, 'debug');
|
|
123
|
+
}
|
|
124
|
+
/** Clear all configurations and close transports. */
|
|
125
|
+
async clearConfigs() {
|
|
126
|
+
for (const transport of this.transports.values()) {
|
|
127
|
+
await transport.close();
|
|
128
|
+
}
|
|
129
|
+
this.configs.clear();
|
|
130
|
+
this.transports.clear();
|
|
131
|
+
this.logger('Cleared all remote agent configurations', 'debug');
|
|
132
|
+
}
|
|
133
|
+
// ── Private ───────────────────────────────────────────────────────────────
|
|
134
|
+
requireConfig(agentId) {
|
|
135
|
+
const config = this.configs.get(agentId);
|
|
136
|
+
if (!config) {
|
|
137
|
+
throw new Error(`Agent ${agentId} is not configured as a remote agent`);
|
|
138
|
+
}
|
|
139
|
+
return config;
|
|
140
|
+
}
|
|
141
|
+
async callRemoteTool(agentId, toolName, args) {
|
|
142
|
+
const transport = this.transports.get(agentId);
|
|
143
|
+
if (!transport) {
|
|
144
|
+
throw new Error(`No transport available for agent ${agentId}`);
|
|
145
|
+
}
|
|
98
146
|
const request = {
|
|
99
147
|
jsonrpc: '2.0',
|
|
100
148
|
id: `${toolName}-${Date.now()}`,
|
|
@@ -104,76 +152,35 @@ class RemoteAgentManager {
|
|
|
104
152
|
arguments: args,
|
|
105
153
|
},
|
|
106
154
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
};
|
|
110
|
-
if (config.apiKey) {
|
|
111
|
-
headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
112
|
-
}
|
|
113
|
-
this.logger(`Calling remote MCP tool ${toolName} on ${baseUrl}`, 'debug');
|
|
114
|
-
const response = await this.transport.request(url, {
|
|
115
|
-
method: 'POST',
|
|
116
|
-
headers,
|
|
117
|
-
body: request,
|
|
118
|
-
timeoutMs: config.timeoutMs,
|
|
119
|
-
});
|
|
155
|
+
this.logger(`Calling remote MCP tool ${toolName} for agent ${agentId}`, 'debug');
|
|
156
|
+
const response = await transport.send(request);
|
|
120
157
|
if (response.error) {
|
|
121
158
|
throw new Error(response.error.message || 'MCP server returned an error');
|
|
122
159
|
}
|
|
123
160
|
return response.result;
|
|
124
161
|
}
|
|
162
|
+
/** Normalize remote agent response to consistent format. */
|
|
125
163
|
normalizeResponse(result) {
|
|
126
164
|
if (!result) {
|
|
127
165
|
return {
|
|
128
166
|
success: false,
|
|
129
|
-
content: [
|
|
130
|
-
{
|
|
131
|
-
type: 'text',
|
|
132
|
-
text: 'Remote agent returned no response.',
|
|
133
|
-
},
|
|
134
|
-
],
|
|
167
|
+
content: [{ type: 'text', text: 'Remote agent returned no response.' }],
|
|
135
168
|
};
|
|
136
169
|
}
|
|
137
|
-
|
|
138
|
-
|
|
170
|
+
const obj = result;
|
|
171
|
+
// Already has content array — return as-is
|
|
172
|
+
if (Array.isArray(obj.content) && obj.content.length > 0) {
|
|
173
|
+
return obj;
|
|
139
174
|
}
|
|
140
|
-
|
|
175
|
+
// Extract content from various possible fields
|
|
176
|
+
const fallbackContent = obj.response ?? obj.implementation ?? obj.message ?? obj.output;
|
|
141
177
|
const text = typeof fallbackContent === 'string'
|
|
142
178
|
? fallbackContent
|
|
143
179
|
: JSON.stringify(fallbackContent ?? result, null, 2);
|
|
144
180
|
return {
|
|
145
|
-
...
|
|
146
|
-
content: [
|
|
147
|
-
{
|
|
148
|
-
type: 'text',
|
|
149
|
-
text,
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
normalizeUrl(url) {
|
|
155
|
-
if (!url) {
|
|
156
|
-
return url;
|
|
157
|
-
}
|
|
158
|
-
const trimmed = url.trim();
|
|
159
|
-
if (!trimmed) {
|
|
160
|
-
return trimmed;
|
|
161
|
-
}
|
|
162
|
-
const withoutTrailingSlash = trimmed.replace(/\/+$/, '');
|
|
163
|
-
return withoutTrailingSlash.toLowerCase().endsWith('/mcp')
|
|
164
|
-
? withoutTrailingSlash.slice(0, -4)
|
|
165
|
-
: withoutTrailingSlash;
|
|
166
|
-
}
|
|
167
|
-
mapToolNames(agentId, mapping) {
|
|
168
|
-
const config = this.getConfig(agentId);
|
|
169
|
-
if (!config) {
|
|
170
|
-
throw new Error(`Agent ${agentId} is not configured as a remote agent`);
|
|
171
|
-
}
|
|
172
|
-
config.tools = {
|
|
173
|
-
query: mapping.query ?? config.tools?.query ?? 'crewx_queryAgent',
|
|
174
|
-
execute: mapping.execute ?? config.tools?.execute ?? 'crewx_executeAgent',
|
|
181
|
+
...obj,
|
|
182
|
+
content: [{ type: 'text', text }],
|
|
175
183
|
};
|
|
176
|
-
this.logger(`Updated tool name mapping for agent ${agentId}`, 'debug');
|
|
177
184
|
}
|
|
178
185
|
validateConfig(config) {
|
|
179
186
|
if (!config.url) {
|
|
@@ -186,10 +193,6 @@ class RemoteAgentManager {
|
|
|
186
193
|
throw new Error(`Unsupported remote agent type: ${config.type}`);
|
|
187
194
|
}
|
|
188
195
|
}
|
|
189
|
-
clearConfigs() {
|
|
190
|
-
this.configs.clear();
|
|
191
|
-
this.logger('Cleared all remote agent configurations', 'debug');
|
|
192
|
-
}
|
|
193
196
|
}
|
|
194
197
|
exports.RemoteAgentManager = RemoteAgentManager;
|
|
195
198
|
//# sourceMappingURL=remote-agent-manager.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Provider Runtime
|
|
3
|
+
*
|
|
4
|
+
* Implements ProviderRuntime for remote agents via MCP-HTTP transport.
|
|
5
|
+
*
|
|
6
|
+
* Resolution path:
|
|
7
|
+
* - http(s):// → MCP-HTTP transport via RemoteAgentManager
|
|
8
|
+
*
|
|
9
|
+
* Note: file:// remote agents are handled at the CLI level by swapping the
|
|
10
|
+
* Crewx instance to the target crewx.yaml before calling query/execute.
|
|
11
|
+
* See packages/cli/src/commands/execute.ts and query.ts for details.
|
|
12
|
+
*/
|
|
13
|
+
import type { ProviderRuntime, ProviderQueryOptions } from '../provider/bridge.js';
|
|
14
|
+
import type { RemoteProviderConfig } from './types.js';
|
|
15
|
+
import type { AgentConfig } from '../types/index.js';
|
|
16
|
+
export type ProviderFactoryFn = (providerStr: string) => ProviderRuntime;
|
|
17
|
+
export interface FileRemoteResolution {
|
|
18
|
+
agent: AgentConfig;
|
|
19
|
+
provider: string;
|
|
20
|
+
}
|
|
21
|
+
/** Raw agent shape extracted from a remote crewx.yaml — minimal, lenient. */
|
|
22
|
+
interface RawAgent {
|
|
23
|
+
id: string;
|
|
24
|
+
provider?: string | string[];
|
|
25
|
+
/** Newer crewx.yaml format: provider may live inside inline. */
|
|
26
|
+
inline?: {
|
|
27
|
+
provider?: string | string[];
|
|
28
|
+
};
|
|
29
|
+
working_directory?: string;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
export declare function resolveFileRemoteAgent(config: RemoteProviderConfig, yamlLoader?: (path: string) => {
|
|
33
|
+
agents?: RawAgent[];
|
|
34
|
+
}, existsFn?: (path: string) => boolean): FileRemoteResolution;
|
|
35
|
+
export interface FileRemoteResolver {
|
|
36
|
+
(config: RemoteProviderConfig): FileRemoteResolution;
|
|
37
|
+
}
|
|
38
|
+
export declare class RemoteProviderRuntime implements ProviderRuntime {
|
|
39
|
+
private readonly manager;
|
|
40
|
+
private readonly agentId;
|
|
41
|
+
constructor(remoteId: string, providerConfig: RemoteProviderConfig, _providerFactory?: ProviderFactoryFn);
|
|
42
|
+
query(message: string, options?: ProviderQueryOptions): Promise<string>;
|
|
43
|
+
execute(message: string, options?: ProviderQueryOptions): Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
export declare function createRemoteProviderFactory(remoteConfigs: Map<string, RemoteProviderConfig>, providerFactory?: ProviderFactoryFn): (id: string, providerStr: string) => ProviderRuntime;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=remote-provider.d.ts.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Remote Provider Runtime
|
|
4
|
+
*
|
|
5
|
+
* Implements ProviderRuntime for remote agents via MCP-HTTP transport.
|
|
6
|
+
*
|
|
7
|
+
* Resolution path:
|
|
8
|
+
* - http(s):// → MCP-HTTP transport via RemoteAgentManager
|
|
9
|
+
*
|
|
10
|
+
* Note: file:// remote agents are handled at the CLI level by swapping the
|
|
11
|
+
* Crewx instance to the target crewx.yaml before calling query/execute.
|
|
12
|
+
* See packages/cli/src/commands/execute.ts and query.ts for details.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RemoteProviderRuntime = void 0;
|
|
16
|
+
exports.resolveFileRemoteAgent = resolveFileRemoteAgent;
|
|
17
|
+
exports.createRemoteProviderFactory = createRemoteProviderFactory;
|
|
18
|
+
const fs_1 = require("fs");
|
|
19
|
+
const path_1 = require("path");
|
|
20
|
+
const js_yaml_1 = require("js-yaml");
|
|
21
|
+
const bridge_js_1 = require("../provider/bridge.js");
|
|
22
|
+
const remote_agent_manager_js_1 = require("./remote-agent-manager.js");
|
|
23
|
+
/**
|
|
24
|
+
* Load a remote crewx.yaml without strict schema validation.
|
|
25
|
+
*
|
|
26
|
+
* Unlike loadYamlFile(), this does not run Zod validation so it tolerates
|
|
27
|
+
* schema variations in remote workspaces (e.g. provider nested in inline).
|
|
28
|
+
*/
|
|
29
|
+
function loadYamlFileLenient(filePath) {
|
|
30
|
+
const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
|
|
31
|
+
const raw = (0, js_yaml_1.load)(content);
|
|
32
|
+
const agents = Array.isArray(raw?.agents) ? raw.agents : undefined;
|
|
33
|
+
return { agents };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Extract provider string from an agent, handling both formats:
|
|
37
|
+
* - top-level: agent.provider = "cli/claude"
|
|
38
|
+
* - inline: agent.inline.provider = "cli/claude"
|
|
39
|
+
*/
|
|
40
|
+
function extractAgentProvider(agent) {
|
|
41
|
+
const direct = Array.isArray(agent.provider) ? agent.provider[0] : agent.provider;
|
|
42
|
+
if (direct)
|
|
43
|
+
return direct;
|
|
44
|
+
const fromInline = Array.isArray(agent.inline?.provider)
|
|
45
|
+
? agent.inline.provider[0]
|
|
46
|
+
: agent.inline?.provider;
|
|
47
|
+
return fromInline;
|
|
48
|
+
}
|
|
49
|
+
function resolveFileRemoteAgent(config, yamlLoader = loadYamlFileLenient, existsFn = fs_1.existsSync) {
|
|
50
|
+
const configPath = config.location.replace('file://', '');
|
|
51
|
+
if (!existsFn(configPath)) {
|
|
52
|
+
throw new Error(`Remote config file not found: ${configPath}`);
|
|
53
|
+
}
|
|
54
|
+
if (!config.external_agent_id) {
|
|
55
|
+
throw new Error(`external_agent_id is required for file:// remote provider "${config.id}"`);
|
|
56
|
+
}
|
|
57
|
+
const targetConfig = yamlLoader(configPath);
|
|
58
|
+
const targetAgent = targetConfig.agents?.find((a) => a.id === config.external_agent_id);
|
|
59
|
+
if (!targetAgent) {
|
|
60
|
+
throw new Error(`Agent "${config.external_agent_id}" not found in ${configPath}`);
|
|
61
|
+
}
|
|
62
|
+
const targetProvider = extractAgentProvider(targetAgent);
|
|
63
|
+
if (!targetProvider) {
|
|
64
|
+
throw new Error(`Agent "${config.external_agent_id}" in ${configPath} has no provider configured`);
|
|
65
|
+
}
|
|
66
|
+
if (targetProvider.startsWith('remote/')) {
|
|
67
|
+
throw new Error(`Chained remotes not allowed: ${config.id} → ${targetProvider}`);
|
|
68
|
+
}
|
|
69
|
+
// Resolve working_directory relative to target config file's directory.
|
|
70
|
+
// path.resolve handles absolute paths transparently (absolute overrides base).
|
|
71
|
+
const resolvedDir = (0, path_1.resolve)((0, path_1.dirname)(configPath), targetAgent.working_directory ?? '.');
|
|
72
|
+
return {
|
|
73
|
+
agent: { ...targetAgent, working_directory: resolvedDir },
|
|
74
|
+
provider: targetProvider,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
class RemoteProviderRuntime {
|
|
78
|
+
manager;
|
|
79
|
+
agentId;
|
|
80
|
+
constructor(remoteId, providerConfig, _providerFactory = bridge_js_1.createProvider) {
|
|
81
|
+
this.agentId = providerConfig.external_agent_id ?? remoteId;
|
|
82
|
+
this.manager = new remote_agent_manager_js_1.RemoteAgentManager();
|
|
83
|
+
const mcpConfig = toRemoteAgentConfig(remoteId, providerConfig);
|
|
84
|
+
this.manager.loadConfig(this.agentId, mcpConfig);
|
|
85
|
+
}
|
|
86
|
+
async query(message, options) {
|
|
87
|
+
const response = await this.manager.query(this.agentId, {
|
|
88
|
+
agentId: this.agentId,
|
|
89
|
+
query: message,
|
|
90
|
+
model: options?.model,
|
|
91
|
+
context: options?.context ?? options?.systemPrompt,
|
|
92
|
+
});
|
|
93
|
+
return response.content.map((c) => c.text).join('\n');
|
|
94
|
+
}
|
|
95
|
+
async execute(message, options) {
|
|
96
|
+
const response = await this.manager.execute(this.agentId, {
|
|
97
|
+
agentId: this.agentId,
|
|
98
|
+
task: message,
|
|
99
|
+
model: options?.model,
|
|
100
|
+
context: options?.context ?? options?.systemPrompt,
|
|
101
|
+
});
|
|
102
|
+
return response.content.map((c) => c.text).join('\n');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.RemoteProviderRuntime = RemoteProviderRuntime;
|
|
106
|
+
// ── Factory ─────────────────────────────────────────────────────────────────
|
|
107
|
+
function createRemoteProviderFactory(remoteConfigs, providerFactory = bridge_js_1.createProvider) {
|
|
108
|
+
return (id, _providerStr) => {
|
|
109
|
+
const config = remoteConfigs.get(id);
|
|
110
|
+
if (!config) {
|
|
111
|
+
throw new Error(`Remote provider "${id}" not found. Available: ${Array.from(remoteConfigs.keys()).join(', ') || '(none)'}`);
|
|
112
|
+
}
|
|
113
|
+
// file:// locations are handled at the CLI level (Crewx instance swap).
|
|
114
|
+
// RemoteProviderRuntime only supports http(s):// (MCP-HTTP).
|
|
115
|
+
if (config.location.startsWith('file://')) {
|
|
116
|
+
throw new Error(`Remote provider "${id}" uses file:// location which is not supported at the SDK level. ` +
|
|
117
|
+
'Use the CLI commands (crewx query / crewx execute) which handle file:// remotes automatically.');
|
|
118
|
+
}
|
|
119
|
+
return new RemoteProviderRuntime(id, config, providerFactory);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
123
|
+
function toRemoteAgentConfig(remoteId, config) {
|
|
124
|
+
const location = config.location;
|
|
125
|
+
if (!location) {
|
|
126
|
+
throw new Error('Remote provider config requires a location');
|
|
127
|
+
}
|
|
128
|
+
if (!location.startsWith('http://') &&
|
|
129
|
+
!location.startsWith('https://')) {
|
|
130
|
+
throw new Error(`Unsupported remote location protocol for MCP-HTTP: ${location}`);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
type: 'mcp-http',
|
|
134
|
+
url: location,
|
|
135
|
+
apiKey: config.apiKey,
|
|
136
|
+
headers: config.headers,
|
|
137
|
+
timeoutMs: config.timeout?.query ?? 30000,
|
|
138
|
+
agentId: config.external_agent_id ?? remoteId,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=remote-provider.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Transport Implementations
|
|
3
|
+
*
|
|
4
|
+
* MCP-HTTP JSON-RPC 2.0 transport for communicating with remote MCP servers.
|
|
5
|
+
* Migrated from sdk-bak and adapted to the new RemoteTransport interface.
|
|
6
|
+
*/
|
|
7
|
+
import type { RemoteTransport, McpJsonRpcRequest, McpJsonRpcResponse } from './types.js';
|
|
8
|
+
/** Options for creating an McpHttpTransport. */
|
|
9
|
+
export interface McpHttpTransportOptions {
|
|
10
|
+
/** Base URL of the MCP server (e.g. "http://localhost:3030"). */
|
|
11
|
+
url: string;
|
|
12
|
+
/** Optional API key for Bearer authentication. */
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
/** Optional custom headers. */
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
/** Request timeout in milliseconds (default: 30000). */
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* MCP-HTTP transport — sends JSON-RPC 2.0 requests over HTTP POST.
|
|
21
|
+
*
|
|
22
|
+
* Endpoint: `${baseUrl}/mcp`
|
|
23
|
+
*/
|
|
24
|
+
export declare class McpHttpTransport implements RemoteTransport {
|
|
25
|
+
private readonly endpoint;
|
|
26
|
+
private readonly headers;
|
|
27
|
+
private readonly timeoutMs;
|
|
28
|
+
constructor(options: McpHttpTransportOptions);
|
|
29
|
+
send(request: McpJsonRpcRequest): Promise<McpJsonRpcResponse>;
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=remote-transport.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Remote Transport Implementations
|
|
4
|
+
*
|
|
5
|
+
* MCP-HTTP JSON-RPC 2.0 transport for communicating with remote MCP servers.
|
|
6
|
+
* Migrated from sdk-bak and adapted to the new RemoteTransport interface.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.McpHttpTransport = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* MCP-HTTP transport — sends JSON-RPC 2.0 requests over HTTP POST.
|
|
12
|
+
*
|
|
13
|
+
* Endpoint: `${baseUrl}/mcp`
|
|
14
|
+
*/
|
|
15
|
+
class McpHttpTransport {
|
|
16
|
+
endpoint;
|
|
17
|
+
headers;
|
|
18
|
+
timeoutMs;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
const baseUrl = normalizeUrl(options.url);
|
|
21
|
+
this.endpoint = `${baseUrl}/mcp`;
|
|
22
|
+
this.headers = {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
...(options.headers ?? {}),
|
|
25
|
+
};
|
|
26
|
+
if (options.apiKey) {
|
|
27
|
+
this.headers['Authorization'] = `Bearer ${options.apiKey}`;
|
|
28
|
+
}
|
|
29
|
+
this.timeoutMs = options.timeoutMs ?? 30000;
|
|
30
|
+
}
|
|
31
|
+
async send(request) {
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(this.endpoint, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: this.headers,
|
|
38
|
+
body: JSON.stringify(request),
|
|
39
|
+
signal: controller.signal,
|
|
40
|
+
});
|
|
41
|
+
clearTimeout(timeout);
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const text = await response.text();
|
|
44
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}${text ? ` - ${text}` : ''}`);
|
|
45
|
+
}
|
|
46
|
+
const contentType = response.headers.get('content-type');
|
|
47
|
+
if (contentType?.includes('application/json')) {
|
|
48
|
+
return (await response.json());
|
|
49
|
+
}
|
|
50
|
+
// Non-JSON response — wrap as error
|
|
51
|
+
const body = await response.text();
|
|
52
|
+
return {
|
|
53
|
+
jsonrpc: '2.0',
|
|
54
|
+
id: request.id,
|
|
55
|
+
error: { code: -32600, message: `Unexpected response content-type: ${contentType}`, data: body },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
clearTimeout(timeout);
|
|
60
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
61
|
+
throw new Error(`MCP-HTTP request timeout after ${this.timeoutMs}ms to ${this.endpoint}`);
|
|
62
|
+
}
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async close() {
|
|
67
|
+
// No persistent connection to close for HTTP transport.
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.McpHttpTransport = McpHttpTransport;
|
|
71
|
+
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
72
|
+
/**
|
|
73
|
+
* Normalize a URL: remove trailing slashes and redundant /mcp suffix.
|
|
74
|
+
*/
|
|
75
|
+
function normalizeUrl(url) {
|
|
76
|
+
if (!url)
|
|
77
|
+
return url;
|
|
78
|
+
const trimmed = url.trim().replace(/\/+$/, '');
|
|
79
|
+
return trimmed.toLowerCase().endsWith('/mcp')
|
|
80
|
+
? trimmed.slice(0, -4)
|
|
81
|
+
: trimmed;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=remote-transport.js.map
|