@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
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Browser-safe Crewx facade.
|
|
4
|
+
*
|
|
5
|
+
* Stripped of all Node.js dependencies (path, fs, child_process, crypto, events).
|
|
6
|
+
* Supports: fromConfig(), query(), execute(), registerTool(), agents, tools.
|
|
7
|
+
*
|
|
8
|
+
* Built-in providers (e.g. api/webllm) are auto-initialised when detected
|
|
9
|
+
* in the agents list — no manual registerProviderFactory required.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Crewx = void 0;
|
|
13
|
+
const resolver_js_1 = require("../agent/resolver.js");
|
|
14
|
+
const bridge_browser_js_1 = require("../provider/bridge.browser.js");
|
|
15
|
+
/** Dynamic import that bypasses TypeScript module resolution for CDN URLs. */
|
|
16
|
+
const _cdnImport = new Function('u', 'return import(u)');
|
|
17
|
+
class Crewx {
|
|
18
|
+
_agents;
|
|
19
|
+
_config;
|
|
20
|
+
_tools = new Map();
|
|
21
|
+
_apiProviders = new Map();
|
|
22
|
+
constructor(agents, config) {
|
|
23
|
+
this._agents = new Map(agents.map(a => [a.id, a]));
|
|
24
|
+
this._config = config;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a Crewx instance from an already-parsed config object.
|
|
28
|
+
*
|
|
29
|
+
* Built-in browser providers (api/webllm, api/openrouter) are auto-initialised
|
|
30
|
+
* when detected in the agents list — no manual registerProviderFactory required.
|
|
31
|
+
*/
|
|
32
|
+
static async fromConfig(config, options) {
|
|
33
|
+
const instance = new Crewx(config.agents ?? [], config);
|
|
34
|
+
const agents = config.agents ?? [];
|
|
35
|
+
const providerOf = (a) => Array.isArray(a.provider) ? a.provider[0] : a.provider;
|
|
36
|
+
const webllmAgents = agents.filter(a => providerOf(a) === 'api/webllm');
|
|
37
|
+
const openrouterAgents = agents.filter(a => providerOf(a) === 'api/openrouter');
|
|
38
|
+
if (webllmAgents.length > 0) {
|
|
39
|
+
await instance._initWebLLM(webllmAgents, options?.onProgress);
|
|
40
|
+
}
|
|
41
|
+
if (openrouterAgents.length > 0) {
|
|
42
|
+
if (!options?.openrouterApiKey) {
|
|
43
|
+
throw new Error('openrouterApiKey is required when using api/openrouter provider');
|
|
44
|
+
}
|
|
45
|
+
instance._initOpenRouter(openrouterAgents, options.openrouterApiKey);
|
|
46
|
+
}
|
|
47
|
+
// Register unified api factory dispatching to initialised sub-providers
|
|
48
|
+
if (instance._apiProviders.size > 0) {
|
|
49
|
+
(0, bridge_browser_js_1.registerProviderFactory)('api', (id, providerStr) => {
|
|
50
|
+
const provider = instance._apiProviders.get(id);
|
|
51
|
+
if (!provider) {
|
|
52
|
+
throw new bridge_browser_js_1.ProviderError(`Unknown api provider: ${id}`, providerStr);
|
|
53
|
+
}
|
|
54
|
+
return provider;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return instance;
|
|
58
|
+
}
|
|
59
|
+
// ── web-llm auto-init ──────────────────────────────────────────────────────
|
|
60
|
+
/**
|
|
61
|
+
* Load web-llm from CDN, create the inference engine, and store
|
|
62
|
+
* the provider runtime. Called automatically by fromConfig().
|
|
63
|
+
*/
|
|
64
|
+
async _initWebLLM(agents, onProgress) {
|
|
65
|
+
if (typeof navigator === 'undefined' || !navigator.gpu) {
|
|
66
|
+
throw new Error('WebGPU is not available. Chrome 113+ or Edge 113+ required.');
|
|
67
|
+
}
|
|
68
|
+
const webllm = await _cdnImport('https://esm.run/@mlc-ai/web-llm');
|
|
69
|
+
const modelId = agents[0]?.inline?.model ?? 'gemma-2-2b-it-q4f16_1-MLC';
|
|
70
|
+
const engine = await webllm.CreateMLCEngine(modelId, {
|
|
71
|
+
initProgressCallback: onProgress
|
|
72
|
+
? (report) => onProgress(report)
|
|
73
|
+
: undefined,
|
|
74
|
+
});
|
|
75
|
+
const history = [];
|
|
76
|
+
this._apiProviders.set('webllm', {
|
|
77
|
+
async query(message, options) {
|
|
78
|
+
const messages = [];
|
|
79
|
+
if (options?.systemPrompt) {
|
|
80
|
+
messages.push({ role: 'system', content: options.systemPrompt });
|
|
81
|
+
}
|
|
82
|
+
messages.push(...history);
|
|
83
|
+
messages.push({ role: 'user', content: message });
|
|
84
|
+
let fullReply = '';
|
|
85
|
+
const stream = await engine.chat.completions.create({
|
|
86
|
+
messages,
|
|
87
|
+
stream: true,
|
|
88
|
+
temperature: 0.7,
|
|
89
|
+
max_tokens: 4096,
|
|
90
|
+
});
|
|
91
|
+
for await (const chunk of stream) {
|
|
92
|
+
const delta = chunk.choices?.[0]?.delta?.content ?? '';
|
|
93
|
+
fullReply += delta;
|
|
94
|
+
if (options?.onOutput) {
|
|
95
|
+
options.onOutput(fullReply, 'stdout');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
history.push({ role: 'user', content: message });
|
|
99
|
+
history.push({ role: 'assistant', content: fullReply });
|
|
100
|
+
return fullReply;
|
|
101
|
+
},
|
|
102
|
+
async execute(message, options) {
|
|
103
|
+
return this.query(message, options);
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Initialise the OpenRouter API provider.
|
|
109
|
+
* Uses fetch + SSE streaming against the OpenAI-compatible endpoint.
|
|
110
|
+
*/
|
|
111
|
+
_initOpenRouter(agents, apiKey) {
|
|
112
|
+
const defaultModel = agents[0]?.inline?.model ?? 'google/gemma-2-2b-it';
|
|
113
|
+
const history = [];
|
|
114
|
+
this._apiProviders.set('openrouter', {
|
|
115
|
+
async query(message, options) {
|
|
116
|
+
const messages = [];
|
|
117
|
+
if (options?.systemPrompt) {
|
|
118
|
+
messages.push({ role: 'system', content: options.systemPrompt });
|
|
119
|
+
}
|
|
120
|
+
messages.push(...history);
|
|
121
|
+
messages.push({ role: 'user', content: message });
|
|
122
|
+
const response = await fetch('https://openrouter.ai/api/v1/chat/completions', {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
headers: {
|
|
125
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
126
|
+
'Content-Type': 'application/json',
|
|
127
|
+
},
|
|
128
|
+
body: JSON.stringify({
|
|
129
|
+
model: options?.model || defaultModel,
|
|
130
|
+
messages,
|
|
131
|
+
stream: true,
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
if (!response.ok) {
|
|
135
|
+
const errorBody = await response.text();
|
|
136
|
+
throw new Error(`OpenRouter API error (${response.status}): ${errorBody}`);
|
|
137
|
+
}
|
|
138
|
+
const reader = response.body.getReader();
|
|
139
|
+
const decoder = new TextDecoder();
|
|
140
|
+
let fullReply = '';
|
|
141
|
+
let buffer = '';
|
|
142
|
+
while (true) {
|
|
143
|
+
const { done, value } = await reader.read();
|
|
144
|
+
if (done)
|
|
145
|
+
break;
|
|
146
|
+
buffer += decoder.decode(value, { stream: true });
|
|
147
|
+
const lines = buffer.split('\n');
|
|
148
|
+
buffer = lines.pop();
|
|
149
|
+
for (const line of lines) {
|
|
150
|
+
const trimmed = line.trim();
|
|
151
|
+
if (!trimmed || !trimmed.startsWith('data: '))
|
|
152
|
+
continue;
|
|
153
|
+
const data = trimmed.slice(6);
|
|
154
|
+
if (data === '[DONE]')
|
|
155
|
+
continue;
|
|
156
|
+
try {
|
|
157
|
+
const parsed = JSON.parse(data);
|
|
158
|
+
const delta = parsed.choices?.[0]?.delta?.content ?? '';
|
|
159
|
+
fullReply += delta;
|
|
160
|
+
if (delta && options?.onOutput) {
|
|
161
|
+
options.onOutput(fullReply, 'stdout');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// skip malformed SSE chunks
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
history.push({ role: 'user', content: message });
|
|
170
|
+
history.push({ role: 'assistant', content: fullReply });
|
|
171
|
+
return fullReply;
|
|
172
|
+
},
|
|
173
|
+
async execute(message, options) {
|
|
174
|
+
return this.query(message, options);
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
get agents() {
|
|
179
|
+
return this._agents;
|
|
180
|
+
}
|
|
181
|
+
get config() {
|
|
182
|
+
return this._config;
|
|
183
|
+
}
|
|
184
|
+
get tools() {
|
|
185
|
+
return this._tools;
|
|
186
|
+
}
|
|
187
|
+
registerTool(name, definition) {
|
|
188
|
+
this._tools.set(name, { name, ...definition });
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Query an agent with a message.
|
|
192
|
+
* Browser version — delegates directly to the registered provider factory.
|
|
193
|
+
* Passes onOutput through for streaming support.
|
|
194
|
+
*/
|
|
195
|
+
async query(agentRef, message, options) {
|
|
196
|
+
const startMs = Date.now();
|
|
197
|
+
let agent;
|
|
198
|
+
try {
|
|
199
|
+
agent = (0, resolver_js_1.resolveAgent)(agentRef, Array.from(this._agents.values()));
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
if (err instanceof resolver_js_1.AgentNotFoundError) {
|
|
203
|
+
return {
|
|
204
|
+
ok: false,
|
|
205
|
+
data: '',
|
|
206
|
+
error: { code: 'AGENT_NOT_FOUND', message: err.message },
|
|
207
|
+
meta: { agentId: agentRef.replace(/^@/, ''), provider: '', durationMs: Date.now() - startMs },
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
throw err;
|
|
211
|
+
}
|
|
212
|
+
const providerStr = Array.isArray(agent.provider)
|
|
213
|
+
? agent.provider[0] ?? 'api/default'
|
|
214
|
+
: agent.provider;
|
|
215
|
+
const effectiveProviderStr = options?.provider ?? providerStr;
|
|
216
|
+
const effectiveModel = options?.model ?? agent.inline?.model;
|
|
217
|
+
let provider;
|
|
218
|
+
try {
|
|
219
|
+
provider = (0, bridge_browser_js_1.createProvider)(effectiveProviderStr);
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
return {
|
|
223
|
+
ok: false,
|
|
224
|
+
data: '',
|
|
225
|
+
error: { code: 'PROVIDER_ERROR', message: err.message },
|
|
226
|
+
meta: { agentId: agent.id, provider: effectiveProviderStr, model: effectiveModel, durationMs: Date.now() - startMs },
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
try {
|
|
230
|
+
const response = await provider.query(message, {
|
|
231
|
+
model: effectiveModel,
|
|
232
|
+
context: options?.context,
|
|
233
|
+
systemPrompt: agent.inline?.system_prompt ?? agent.inline?.prompt,
|
|
234
|
+
onOutput: options?.onOutput
|
|
235
|
+
? (line) => options.onOutput(line)
|
|
236
|
+
: undefined,
|
|
237
|
+
});
|
|
238
|
+
return {
|
|
239
|
+
ok: true,
|
|
240
|
+
data: response,
|
|
241
|
+
meta: { agentId: agent.id, provider: effectiveProviderStr, model: effectiveModel, durationMs: Date.now() - startMs },
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
catch (err) {
|
|
245
|
+
return {
|
|
246
|
+
ok: false,
|
|
247
|
+
data: '',
|
|
248
|
+
error: { code: 'QUERY_FAILED', message: err.message },
|
|
249
|
+
meta: { agentId: agent.id, provider: effectiveProviderStr, model: effectiveModel, durationMs: Date.now() - startMs },
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Execute a task with an agent.
|
|
255
|
+
* Browser version — same delegation pattern as query().
|
|
256
|
+
*/
|
|
257
|
+
async execute(agentRef, message, options) {
|
|
258
|
+
const startMs = Date.now();
|
|
259
|
+
let agent;
|
|
260
|
+
try {
|
|
261
|
+
agent = (0, resolver_js_1.resolveAgent)(agentRef, Array.from(this._agents.values()));
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
if (err instanceof resolver_js_1.AgentNotFoundError) {
|
|
265
|
+
return {
|
|
266
|
+
ok: false,
|
|
267
|
+
data: '',
|
|
268
|
+
error: { code: 'AGENT_NOT_FOUND', message: err.message },
|
|
269
|
+
meta: { agentId: agentRef.replace(/^@/, ''), provider: '', durationMs: Date.now() - startMs },
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
throw err;
|
|
273
|
+
}
|
|
274
|
+
const providerStr = Array.isArray(agent.provider)
|
|
275
|
+
? agent.provider[0] ?? 'api/default'
|
|
276
|
+
: agent.provider;
|
|
277
|
+
const effectiveProviderStr = options?.provider ?? providerStr;
|
|
278
|
+
const effectiveModel = options?.model ?? agent.inline?.model;
|
|
279
|
+
let provider;
|
|
280
|
+
try {
|
|
281
|
+
provider = (0, bridge_browser_js_1.createProvider)(effectiveProviderStr);
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
return {
|
|
285
|
+
ok: false,
|
|
286
|
+
data: '',
|
|
287
|
+
error: { code: 'PROVIDER_ERROR', message: err.message },
|
|
288
|
+
meta: { agentId: agent.id, provider: effectiveProviderStr, model: effectiveModel, durationMs: Date.now() - startMs },
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
const response = await provider.execute(message, {
|
|
293
|
+
model: effectiveModel,
|
|
294
|
+
context: options?.context,
|
|
295
|
+
systemPrompt: agent.inline?.system_prompt ?? agent.inline?.prompt,
|
|
296
|
+
});
|
|
297
|
+
return {
|
|
298
|
+
ok: true,
|
|
299
|
+
data: response,
|
|
300
|
+
meta: { agentId: agent.id, provider: effectiveProviderStr, model: effectiveModel, durationMs: Date.now() - startMs },
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
catch (err) {
|
|
304
|
+
return {
|
|
305
|
+
ok: false,
|
|
306
|
+
data: '',
|
|
307
|
+
error: { code: 'EXECUTE_FAILED', message: err.message },
|
|
308
|
+
meta: { agentId: agent.id, provider: effectiveProviderStr, model: effectiveModel, durationMs: Date.now() - startMs },
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
exports.Crewx = Crewx;
|
|
314
|
+
//# sourceMappingURL=Crewx.browser.js.map
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crewx facade — main entry point for the CrewX SDK.
|
|
3
|
+
* Provides loadYaml(), fromConfig(), query(), execute(), renderAgentPromptFull(),
|
|
4
|
+
* and registerLayout() methods.
|
|
5
|
+
*/
|
|
6
|
+
import { TypedEventEmitter } from '../events/TypedEventEmitter';
|
|
7
|
+
import type { CrewxPlugin } from '../plugin';
|
|
8
|
+
import type { IFsAdapter } from '../platform/IFsAdapter';
|
|
9
|
+
import type { ChannelAdapterRegistration } from '../adapter/types';
|
|
10
|
+
import type { CrewxProjectConfig, AgentConfig, CrewxOptions, QueryOptions, QueryResult, ExecuteOptions, ExecuteResult } from '../types';
|
|
11
|
+
import type { TemplateContext } from '../template/types';
|
|
12
|
+
import type { CustomLayoutDefinition } from '../layout/types';
|
|
13
|
+
import type { TemplateMessage } from '../conversation/types';
|
|
14
|
+
import type { HandlerOptions, CrewxHandler } from '../server/handler';
|
|
15
|
+
import type { RemoteProviderConfig } from '../remote/types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Definition for a custom tool that can be registered via crewx.registerTool().
|
|
18
|
+
* Tools are made available in the agent prompt context for browser/API environments.
|
|
19
|
+
*/
|
|
20
|
+
export interface ToolDefinition {
|
|
21
|
+
/** Tool name (unique identifier). */
|
|
22
|
+
name: string;
|
|
23
|
+
/** Human-readable description of what the tool does. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** JSON Schema for tool parameters (optional). */
|
|
26
|
+
parameters?: Record<string, unknown>;
|
|
27
|
+
/** Tool execution function. Omit for client-side tools (Vercel AI SDK client tools). */
|
|
28
|
+
execute?: (args: Record<string, unknown>) => Promise<unknown>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Layout specification for renderAgentPromptFull options.
|
|
32
|
+
* Matches the crewx.yaml inline.layout schema.
|
|
33
|
+
*/
|
|
34
|
+
export type LayoutSpec = string | {
|
|
35
|
+
id: string;
|
|
36
|
+
props?: Record<string, any>;
|
|
37
|
+
} | {
|
|
38
|
+
template: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Skill entry for available_skills rendering in agent prompts.
|
|
42
|
+
*/
|
|
43
|
+
export interface SkillEntry {
|
|
44
|
+
metadata: {
|
|
45
|
+
name: string;
|
|
46
|
+
version: string;
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
filePath: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Options for renderAgentPromptFull().
|
|
53
|
+
*/
|
|
54
|
+
export interface RenderAgentPromptOptions {
|
|
55
|
+
/** Override layout resolution. Priority: options.layout > agent.inline.layout > project default > SDK default. */
|
|
56
|
+
layout?: LayoutSpec;
|
|
57
|
+
/** Override session info (default: { mode: 'query', platform: 'cli' }). */
|
|
58
|
+
session?: {
|
|
59
|
+
mode?: string;
|
|
60
|
+
platform?: string;
|
|
61
|
+
options?: string[];
|
|
62
|
+
};
|
|
63
|
+
/** Override env (default: process.env). */
|
|
64
|
+
env?: Record<string, string>;
|
|
65
|
+
/** Override vars (e.g. security_key). Default: auto-generated. */
|
|
66
|
+
vars?: Record<string, unknown>;
|
|
67
|
+
/** Skills to inject as available_skills context. Default: []. */
|
|
68
|
+
skills?: SkillEntry[];
|
|
69
|
+
/** Conversation history messages for layout rendering (WI-CONV-002). Caller-provided takes priority over auto-fetch. */
|
|
70
|
+
messages?: TemplateMessage[];
|
|
71
|
+
}
|
|
72
|
+
export declare class Crewx extends TypedEventEmitter {
|
|
73
|
+
private readonly _agents;
|
|
74
|
+
private readonly _templateEngine;
|
|
75
|
+
private readonly _documentLoader;
|
|
76
|
+
private readonly _layoutLoader;
|
|
77
|
+
private readonly _layoutRenderer;
|
|
78
|
+
private readonly _config?;
|
|
79
|
+
private readonly _projectRoot;
|
|
80
|
+
private readonly _workspaceId;
|
|
81
|
+
private readonly _workspaceName;
|
|
82
|
+
private readonly _plugins;
|
|
83
|
+
private readonly _tools;
|
|
84
|
+
private readonly _activeAdapters;
|
|
85
|
+
private readonly _pendingThreads;
|
|
86
|
+
/**
|
|
87
|
+
* Bootstrap factory for target Crewx instances when delegating file:// remote agents.
|
|
88
|
+
* Consumers (CLI / server / Slack) provide their own bootstrap wrapper so that the
|
|
89
|
+
* target inherits the same plugin/environment setup as the caller.
|
|
90
|
+
*/
|
|
91
|
+
private readonly _remoteFactory?;
|
|
92
|
+
/** Lazily-created target Crewx instances, keyed by absolute configPath. */
|
|
93
|
+
private readonly _remoteTargets;
|
|
94
|
+
private constructor();
|
|
95
|
+
/**
|
|
96
|
+
* If `agentRef` resolves to a `remote/*` provider backed by `file://`, return
|
|
97
|
+
* the target Crewx (lazily bootstrapped) together with the agent ref to use
|
|
98
|
+
* inside the target. Returns null for local agents or non-file remotes.
|
|
99
|
+
*
|
|
100
|
+
* The caller's Crewx.query/execute delegates entirely to the returned target
|
|
101
|
+
* (including task:start/end emit, renderContext, plugins) so execution
|
|
102
|
+
* semantics exactly match running `crewx q` inside the target workspace.
|
|
103
|
+
*/
|
|
104
|
+
private resolveFileRemoteTarget;
|
|
105
|
+
/**
|
|
106
|
+
* Load crewx.yaml from the given file path and create a Crewx instance.
|
|
107
|
+
*/
|
|
108
|
+
static loadYaml(path: string, options?: CrewxOptions, fsAdapter?: IFsAdapter): Promise<Crewx>;
|
|
109
|
+
/**
|
|
110
|
+
* Create a Crewx instance from an already-parsed config object.
|
|
111
|
+
*/
|
|
112
|
+
static fromConfig(config: CrewxProjectConfig, options?: CrewxOptions, projectRoot?: string, fsAdapter?: IFsAdapter): Promise<Crewx>;
|
|
113
|
+
/** All loaded agents, keyed by agent id. */
|
|
114
|
+
get agents(): ReadonlyMap<string, AgentConfig>;
|
|
115
|
+
/** The raw project config (includes providers, settings, etc.). */
|
|
116
|
+
get config(): CrewxProjectConfig | undefined;
|
|
117
|
+
/** All registered plugins. */
|
|
118
|
+
get plugins(): readonly CrewxPlugin[];
|
|
119
|
+
/** All registered custom tools. */
|
|
120
|
+
get tools(): ReadonlyMap<string, ToolDefinition>;
|
|
121
|
+
/** Workspace ID (SHA-256 hash). Single source of truth for all plugins. */
|
|
122
|
+
get workspaceId(): string;
|
|
123
|
+
/** Human-readable workspace name (basename of cwd). */
|
|
124
|
+
get workspaceName(): string;
|
|
125
|
+
/**
|
|
126
|
+
* Return an agent config by ref (with or without leading '@').
|
|
127
|
+
* Returns undefined if the agent is not found.
|
|
128
|
+
*/
|
|
129
|
+
getAgent(agentRef: string): AgentConfig | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Return a remote provider config by provider ID from the crewx.yaml `providers:` section.
|
|
132
|
+
* Returns undefined if not found or if config has no providers.
|
|
133
|
+
*/
|
|
134
|
+
getRemoteProviderConfig(providerId: string): RemoteProviderConfig | undefined;
|
|
135
|
+
private computeTaskLogPath;
|
|
136
|
+
/**
|
|
137
|
+
* Register a custom tool for use in agent prompts.
|
|
138
|
+
*
|
|
139
|
+
* Registered tools are included in the `tools` context of renderAgentPromptFull(),
|
|
140
|
+
* and can be invoked programmatically (e.g. in browser environments with API providers).
|
|
141
|
+
*
|
|
142
|
+
* @param name - Unique tool name (overwrites if already registered)
|
|
143
|
+
* @param definition - Tool definition with description, parameters, and execute function
|
|
144
|
+
*/
|
|
145
|
+
registerTool(name: string, definition: Omit<ToolDefinition, 'name'>): void;
|
|
146
|
+
/**
|
|
147
|
+
* Register a plugin and immediately call attach().
|
|
148
|
+
* Same instance registered twice is silently ignored (by reference).
|
|
149
|
+
*/
|
|
150
|
+
use(plugin: CrewxPlugin): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Create a Web Standard MCP HTTP handler for exposing agents over the network.
|
|
153
|
+
*
|
|
154
|
+
* @param options - Handler config. `agents` list is required for security.
|
|
155
|
+
* @returns `(req: Request) => Promise<Response>` handler
|
|
156
|
+
*/
|
|
157
|
+
handler(options: HandlerOptions): CrewxHandler;
|
|
158
|
+
/**
|
|
159
|
+
* Register a channel adapter and start it.
|
|
160
|
+
*/
|
|
161
|
+
registerChannelAdapter<TConfig = unknown>(reg: ChannelAdapterRegistration<TConfig>): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Unregister and stop a channel adapter by instanceId.
|
|
164
|
+
*/
|
|
165
|
+
unregisterChannelAdapter(instanceId: string): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Stop all registered adapters with a timeout.
|
|
168
|
+
*/
|
|
169
|
+
stopAllAdapters(opts?: {
|
|
170
|
+
timeoutMs?: number;
|
|
171
|
+
}): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Detach all plugins in LIFO order and release resources.
|
|
174
|
+
* Call before process exit for clean shutdown.
|
|
175
|
+
*/
|
|
176
|
+
close(): Promise<void>;
|
|
177
|
+
/**
|
|
178
|
+
* Filter agents by role, team, and/or provider.
|
|
179
|
+
*/
|
|
180
|
+
filterAgents(filters: {
|
|
181
|
+
role?: string;
|
|
182
|
+
team?: string;
|
|
183
|
+
provider?: string;
|
|
184
|
+
}): AgentConfig[];
|
|
185
|
+
/**
|
|
186
|
+
* Return the raw system prompt for the given agent (no template expansion, no layout).
|
|
187
|
+
* @throws AgentNotFoundError if agentId is not found
|
|
188
|
+
*/
|
|
189
|
+
renderAgentPrompt(agentId: string): string;
|
|
190
|
+
/**
|
|
191
|
+
* Render a Handlebars template string with the given context.
|
|
192
|
+
* Documents from crewx.yaml are automatically merged into context.documents.
|
|
193
|
+
*/
|
|
194
|
+
renderPrompt(template: string, context?: TemplateContext): Promise<string>;
|
|
195
|
+
/**
|
|
196
|
+
* Register a custom layout template at runtime.
|
|
197
|
+
*
|
|
198
|
+
* @param name - Layout identifier (used as-is, no forced namespace)
|
|
199
|
+
* @param template - Handlebars template string or CustomLayoutDefinition
|
|
200
|
+
*/
|
|
201
|
+
registerLayout(name: string, template: string | CustomLayoutDefinition): void;
|
|
202
|
+
/**
|
|
203
|
+
* Render the full agent prompt using the layout system.
|
|
204
|
+
*
|
|
205
|
+
* Resolution priority (first match wins):
|
|
206
|
+
* 1. options.layout (call-site override)
|
|
207
|
+
* 2. agent.inline.layout (agent YAML definition)
|
|
208
|
+
* 3. config.layouts.default (project-level default)
|
|
209
|
+
* 4. SDK built-in default (crewx/default)
|
|
210
|
+
*
|
|
211
|
+
* @param agentId - Agent ID (with or without leading '@')
|
|
212
|
+
* @param options - Optional layout/session/env/vars overrides
|
|
213
|
+
* @throws AgentNotFoundError if agentId is not found
|
|
214
|
+
*/
|
|
215
|
+
renderAgentPromptFull(agentId: string, options?: RenderAgentPromptOptions): Promise<string>;
|
|
216
|
+
/**
|
|
217
|
+
* Filter tools by allowed names from agent options (query/execute mode).
|
|
218
|
+
* If allowedNames is undefined, return all registered tools.
|
|
219
|
+
*/
|
|
220
|
+
private _filterToolsByMode;
|
|
221
|
+
/**
|
|
222
|
+
* Resolve layout spec following the priority order.
|
|
223
|
+
*/
|
|
224
|
+
private _resolveLayoutSpec;
|
|
225
|
+
/** Extract the layout ID string from a LayoutSpec. */
|
|
226
|
+
private _extractLayoutId;
|
|
227
|
+
/** Extract layout props overrides from agent inline.layout and call-site options. */
|
|
228
|
+
private _extractLayoutProps;
|
|
229
|
+
/**
|
|
230
|
+
* Get the ConversationPlugin's provider for history auto-fetch (WI-CONV-002).
|
|
231
|
+
* Returns undefined if no ConversationPlugin is registered.
|
|
232
|
+
*/
|
|
233
|
+
private _getConversationProvider;
|
|
234
|
+
/**
|
|
235
|
+
* Auto-fetch conversation history and convert to TemplateMessage[] (WI-CONV-002).
|
|
236
|
+
* Returns undefined if no threadId, no provider, or fetch fails.
|
|
237
|
+
*/
|
|
238
|
+
private _fetchHistoryMessages;
|
|
239
|
+
private emitToolEvents;
|
|
240
|
+
private tryParseJson;
|
|
241
|
+
/**
|
|
242
|
+
* Query an agent with a message.
|
|
243
|
+
*
|
|
244
|
+
* Emits task:start (with child pid when available) then task:output per
|
|
245
|
+
* stdout/stderr line, then task:end on completion or error.
|
|
246
|
+
*/
|
|
247
|
+
query(agentRef: string, message: string, options?: QueryOptions): Promise<QueryResult>;
|
|
248
|
+
/**
|
|
249
|
+
* Continue a conversation after providing client-side tool results.
|
|
250
|
+
*
|
|
251
|
+
* Called when a previous query() returned status: 'requires_action'.
|
|
252
|
+
* Feeds the tool result back to the agent and resumes generation.
|
|
253
|
+
* May return 'requires_action' again if the agent calls another client tool.
|
|
254
|
+
*/
|
|
255
|
+
continueQuery(threadId: string, toolResults: Array<{
|
|
256
|
+
toolCallId: string;
|
|
257
|
+
result: unknown;
|
|
258
|
+
}>): Promise<QueryResult>;
|
|
259
|
+
/**
|
|
260
|
+
* Execute a task with an agent.
|
|
261
|
+
*
|
|
262
|
+
* Emits task:start (with child pid when available) then task:output per
|
|
263
|
+
* stdout/stderr line, then task:end on completion or error.
|
|
264
|
+
*/
|
|
265
|
+
execute(agentRef: string, message: string, options?: ExecuteOptions): Promise<ExecuteResult>;
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=Crewx.d.ts.map
|