@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,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LayoutRenderer — Handlebars-based layout rendering.
|
|
4
|
+
* Ported from packages/sdk-bak/src/services/layout-renderer.service.ts.
|
|
5
|
+
* Excluded: registerTemplateHelpers (exec/shell-quote).
|
|
6
|
+
* Exec is handled separately by TemplateEngine in the facade layer.
|
|
7
|
+
* WI-CONV-002: formatConversation helper restored.
|
|
8
|
+
*/
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.LayoutRenderer = exports.PropsValidationError = void 0;
|
|
14
|
+
const handlebars_1 = __importDefault(require("handlebars"));
|
|
15
|
+
const format_conversation_1 = require("../template/helpers/format-conversation");
|
|
16
|
+
const props_validator_1 = require("./props-validator");
|
|
17
|
+
const types_1 = require("./types");
|
|
18
|
+
var types_2 = require("./types");
|
|
19
|
+
Object.defineProperty(exports, "PropsValidationError", { enumerable: true, get: function () { return types_2.PropsValidationError; } });
|
|
20
|
+
/**
|
|
21
|
+
* LayoutRenderer — renders layout templates with Handlebars.
|
|
22
|
+
*/
|
|
23
|
+
class LayoutRenderer {
|
|
24
|
+
handlebars;
|
|
25
|
+
propsValidator;
|
|
26
|
+
constructor(propsValidator) {
|
|
27
|
+
this.handlebars = handlebars_1.default.create();
|
|
28
|
+
this.propsValidator = propsValidator ?? new props_validator_1.PropsValidator();
|
|
29
|
+
this.registerHelpers();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Render a layout template with the given context.
|
|
33
|
+
*/
|
|
34
|
+
render(layout, context, options = {}) {
|
|
35
|
+
try {
|
|
36
|
+
const preparedContext = this.prepareRenderContext(layout, context, options);
|
|
37
|
+
const template = this.handlebars.compile(layout.template, { noEscape: true });
|
|
38
|
+
return template(preparedContext);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof Error) {
|
|
42
|
+
throw new Error(`Template rendering failed for layout '${layout.id}': ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Unknown error rendering layout '${layout.id}'`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Validate props against schema.
|
|
49
|
+
*/
|
|
50
|
+
validate(props, propsSchema, mode = 'lenient') {
|
|
51
|
+
return this.executeValidation(props, propsSchema, mode);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Merge default props and runtime props, then validate.
|
|
55
|
+
*/
|
|
56
|
+
resolveProps(layout, props, mode = 'lenient') {
|
|
57
|
+
const mergedProps = this.mergeProps(layout.defaultProps, props);
|
|
58
|
+
if (!layout.propsSchema || Object.keys(layout.propsSchema).length === 0) {
|
|
59
|
+
return { valid: true, props: mergedProps, errors: [] };
|
|
60
|
+
}
|
|
61
|
+
return this.executeValidation(mergedProps, layout.propsSchema, mode);
|
|
62
|
+
}
|
|
63
|
+
prepareRenderContext(layout, context, options) {
|
|
64
|
+
const { validationMode = 'lenient', skipValidation = false } = options;
|
|
65
|
+
const resolvedProps = skipValidation
|
|
66
|
+
? this.mergeProps(layout.defaultProps, context.props)
|
|
67
|
+
: this.resolveProps(layout, context.props, validationMode).props;
|
|
68
|
+
return {
|
|
69
|
+
...context,
|
|
70
|
+
vars: this.sanitizeVars(context.vars),
|
|
71
|
+
props: resolvedProps,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Register built-in Handlebars helpers (no exec).
|
|
76
|
+
* WI-CONV-002: formatConversation block helper registered for conversation history.
|
|
77
|
+
*/
|
|
78
|
+
registerHelpers() {
|
|
79
|
+
// Conversation history block helper (WI-CONV-002)
|
|
80
|
+
this.handlebars.registerHelper('formatConversation', format_conversation_1.formatConversationHelper);
|
|
81
|
+
// Built-in block helpers
|
|
82
|
+
if (handlebars_1.default.helpers.each) {
|
|
83
|
+
this.handlebars.registerHelper('each', handlebars_1.default.helpers.each);
|
|
84
|
+
}
|
|
85
|
+
if (handlebars_1.default.helpers.if) {
|
|
86
|
+
this.handlebars.registerHelper('if', handlebars_1.default.helpers.if);
|
|
87
|
+
}
|
|
88
|
+
if (handlebars_1.default.helpers.unless) {
|
|
89
|
+
this.handlebars.registerHelper('unless', handlebars_1.default.helpers.unless);
|
|
90
|
+
}
|
|
91
|
+
if (handlebars_1.default.helpers.with) {
|
|
92
|
+
this.handlebars.registerHelper('with', handlebars_1.default.helpers.with);
|
|
93
|
+
}
|
|
94
|
+
this.handlebars.registerHelper('eq', function (a, b) {
|
|
95
|
+
return a === b;
|
|
96
|
+
});
|
|
97
|
+
this.handlebars.registerHelper('ne', function (a, b) {
|
|
98
|
+
return a !== b;
|
|
99
|
+
});
|
|
100
|
+
this.handlebars.registerHelper('gt', function (a, b) {
|
|
101
|
+
return a > b;
|
|
102
|
+
});
|
|
103
|
+
this.handlebars.registerHelper('lt', function (a, b) {
|
|
104
|
+
return a < b;
|
|
105
|
+
});
|
|
106
|
+
this.handlebars.registerHelper('json', function (obj) {
|
|
107
|
+
return new handlebars_1.default.SafeString(JSON.stringify(obj));
|
|
108
|
+
});
|
|
109
|
+
this.handlebars.registerHelper('raw', function (options) {
|
|
110
|
+
return typeof options?.fn === 'function' ? options.fn(this) : '';
|
|
111
|
+
});
|
|
112
|
+
this.handlebars.registerHelper('escapeHandlebars', function (text) {
|
|
113
|
+
if (typeof text !== 'string')
|
|
114
|
+
return '';
|
|
115
|
+
return text.replace(/\{\{/g, '{{').replace(/\}\}/g, '}}');
|
|
116
|
+
});
|
|
117
|
+
this.handlebars.registerHelper('formatFileSize', function (bytes) {
|
|
118
|
+
if (bytes === 0)
|
|
119
|
+
return '0 B';
|
|
120
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
121
|
+
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
122
|
+
return Math.round((bytes / Math.pow(1024, i)) * 100) / 100 + ' ' + sizes[i];
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
executeValidation(props, propsSchema, mode) {
|
|
126
|
+
try {
|
|
127
|
+
return this.propsValidator.validate(props, propsSchema, mode);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
if (error instanceof types_1.PropsValidationError && error.errors && error.errors.length > 0) {
|
|
131
|
+
const firstError = error.errors[0];
|
|
132
|
+
if (firstError) {
|
|
133
|
+
throw new types_1.PropsValidationError(firstError.message, error.errors);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
mergeProps(defaultProps, overrides) {
|
|
140
|
+
const base = this.cloneDeep(defaultProps ?? {});
|
|
141
|
+
if (!overrides)
|
|
142
|
+
return base;
|
|
143
|
+
return this.deepMerge(base, overrides);
|
|
144
|
+
}
|
|
145
|
+
deepMerge(target, source) {
|
|
146
|
+
for (const [key, value] of Object.entries(source)) {
|
|
147
|
+
if (this.isPlainObject(value)) {
|
|
148
|
+
const existing = target[key];
|
|
149
|
+
target[key] = this.deepMerge(this.isPlainObject(existing) ? existing : {}, value);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (Array.isArray(value)) {
|
|
153
|
+
target[key] = this.cloneDeep(value);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
target[key] = value;
|
|
157
|
+
}
|
|
158
|
+
return target;
|
|
159
|
+
}
|
|
160
|
+
cloneDeep(value) {
|
|
161
|
+
if (Array.isArray(value)) {
|
|
162
|
+
return value.map(item => this.cloneDeep(item));
|
|
163
|
+
}
|
|
164
|
+
if (this.isPlainObject(value)) {
|
|
165
|
+
const cloned = {};
|
|
166
|
+
for (const [key, nested] of Object.entries(value)) {
|
|
167
|
+
cloned[key] = this.cloneDeep(nested);
|
|
168
|
+
}
|
|
169
|
+
return cloned;
|
|
170
|
+
}
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
isPlainObject(value) {
|
|
174
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
175
|
+
}
|
|
176
|
+
sanitizeVars(vars) {
|
|
177
|
+
if (!vars)
|
|
178
|
+
return {};
|
|
179
|
+
const sanitizedVars = { ...vars };
|
|
180
|
+
if (typeof vars.user_input === 'string') {
|
|
181
|
+
sanitizedVars.user_input_raw = vars.user_input;
|
|
182
|
+
const escapedHandlebars = vars.user_input
|
|
183
|
+
.replace(/\{\{\{/g, '{{{')
|
|
184
|
+
.replace(/\}\}\}/g, '}}}')
|
|
185
|
+
.replace(/\{\{/g, '{{')
|
|
186
|
+
.replace(/\}\}/g, '}}');
|
|
187
|
+
sanitizedVars.user_input = this.handlebars.escapeExpression(escapedHandlebars);
|
|
188
|
+
}
|
|
189
|
+
return sanitizedVars;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.LayoutRenderer = LayoutRenderer;
|
|
193
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Layout system type definitions for CrewX SDK.
|
|
3
|
+
* Ported from packages/sdk-bak/src/types/layout.types.ts (1:1, import path only changed).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Template variables for layout rendering (security_key, custom extensions).
|
|
7
|
+
*/
|
|
8
|
+
export interface TemplateVars {
|
|
9
|
+
/** Authentication token used to validate prompt containers */
|
|
10
|
+
security_key?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Prop schema definition (React PropTypes style).
|
|
15
|
+
*/
|
|
2
16
|
export interface PropSchema {
|
|
3
17
|
type: 'string' | 'number' | 'bool' | 'array' | 'arrayOf' | 'object' | 'shape' | 'oneOfType' | 'func' | 'node';
|
|
4
18
|
isRequired?: boolean;
|
|
@@ -15,6 +29,9 @@ export interface PropSchema {
|
|
|
15
29
|
pattern?: string;
|
|
16
30
|
description?: string;
|
|
17
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Layout definition loaded from YAML.
|
|
34
|
+
*/
|
|
18
35
|
export interface LayoutDefinition {
|
|
19
36
|
id: string;
|
|
20
37
|
version: string;
|
|
@@ -23,6 +40,9 @@ export interface LayoutDefinition {
|
|
|
23
40
|
propsSchema: Record<string, PropSchema>;
|
|
24
41
|
defaultProps: Record<string, any>;
|
|
25
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Custom layout configuration for runtime registration.
|
|
45
|
+
*/
|
|
26
46
|
export interface CustomLayoutDefinition {
|
|
27
47
|
template: string;
|
|
28
48
|
description?: string;
|
|
@@ -30,25 +50,40 @@ export interface CustomLayoutDefinition {
|
|
|
30
50
|
propsSchema?: Record<string, any>;
|
|
31
51
|
defaultProps?: Record<string, any>;
|
|
32
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Inline layout specification from agent config.
|
|
55
|
+
*/
|
|
33
56
|
export type InlineLayoutSpec = string | {
|
|
34
57
|
id: string;
|
|
35
58
|
props?: Record<string, any>;
|
|
36
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Validation result from PropsValidator.
|
|
62
|
+
*/
|
|
37
63
|
export interface ValidationResult {
|
|
38
64
|
valid: boolean;
|
|
39
65
|
props: Record<string, any>;
|
|
40
66
|
errors: ValidationError[];
|
|
41
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Validation error details.
|
|
70
|
+
*/
|
|
42
71
|
export interface ValidationError {
|
|
43
72
|
path: string;
|
|
44
73
|
message: string;
|
|
45
74
|
value?: any;
|
|
46
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Layout loader options.
|
|
78
|
+
*/
|
|
47
79
|
export interface LoaderOptions {
|
|
48
80
|
templatesPath: string;
|
|
49
81
|
validationMode?: 'strict' | 'lenient';
|
|
50
82
|
fallbackLayoutId?: string;
|
|
51
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Render context for layout-specific template rendering.
|
|
86
|
+
*/
|
|
52
87
|
export interface RenderContext {
|
|
53
88
|
user_input?: string;
|
|
54
89
|
messages?: Array<{
|
|
@@ -94,7 +129,11 @@ export interface RenderContext {
|
|
|
94
129
|
[key: string]: any;
|
|
95
130
|
};
|
|
96
131
|
context?: Record<string, any>;
|
|
132
|
+
[key: string]: unknown;
|
|
97
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Raw layout YAML structure.
|
|
136
|
+
*/
|
|
98
137
|
export interface RawLayoutYaml {
|
|
99
138
|
id?: string;
|
|
100
139
|
version?: string;
|
|
@@ -103,13 +142,20 @@ export interface RawLayoutYaml {
|
|
|
103
142
|
template?: string;
|
|
104
143
|
layouts?: Record<string, string>;
|
|
105
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Error thrown when layout loading fails.
|
|
147
|
+
*/
|
|
106
148
|
export declare class LayoutLoadError extends Error {
|
|
107
149
|
readonly layoutId?: string | undefined;
|
|
108
150
|
readonly cause?: Error | undefined;
|
|
109
151
|
constructor(message: string, layoutId?: string | undefined, cause?: Error | undefined);
|
|
110
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Error thrown when props validation fails (strict mode).
|
|
155
|
+
*/
|
|
111
156
|
export declare class PropsValidationError extends Error {
|
|
112
157
|
readonly errors: ValidationError[];
|
|
113
158
|
readonly cause?: Error | undefined;
|
|
114
159
|
constructor(message: string, errors?: ValidationError[], cause?: Error | undefined);
|
|
115
160
|
}
|
|
161
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Layout system type definitions for CrewX SDK.
|
|
4
|
+
* Ported from packages/sdk-bak/src/types/layout.types.ts (1:1, import path only changed).
|
|
5
|
+
*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.PropsValidationError = exports.LayoutLoadError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Error thrown when layout loading fails.
|
|
10
|
+
*/
|
|
4
11
|
class LayoutLoadError extends Error {
|
|
12
|
+
layoutId;
|
|
13
|
+
cause;
|
|
5
14
|
constructor(message, layoutId, cause) {
|
|
6
15
|
super(message);
|
|
7
16
|
this.layoutId = layoutId;
|
|
@@ -10,7 +19,12 @@ class LayoutLoadError extends Error {
|
|
|
10
19
|
}
|
|
11
20
|
}
|
|
12
21
|
exports.LayoutLoadError = LayoutLoadError;
|
|
22
|
+
/**
|
|
23
|
+
* Error thrown when props validation fails (strict mode).
|
|
24
|
+
*/
|
|
13
25
|
class PropsValidationError extends Error {
|
|
26
|
+
errors;
|
|
27
|
+
cause;
|
|
14
28
|
constructor(message, errors = [], cause) {
|
|
15
29
|
super(message);
|
|
16
30
|
this.errors = errors;
|
|
@@ -19,4 +33,4 @@ class PropsValidationError extends Error {
|
|
|
19
33
|
}
|
|
20
34
|
}
|
|
21
35
|
exports.PropsValidationError = PropsValidationError;
|
|
22
|
-
//# sourceMappingURL=
|
|
36
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal AgentRuntime for the parallel execution module.
|
|
3
|
+
* Provides query/execute methods to run agent operations.
|
|
4
|
+
* Tests use vi.spyOn(AgentRuntime.prototype, 'query') to mock these methods.
|
|
5
|
+
*/
|
|
6
|
+
export interface AgentQueryRequest {
|
|
7
|
+
agentId?: string;
|
|
8
|
+
prompt: string;
|
|
9
|
+
context?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentExecuteRequest {
|
|
12
|
+
agentId?: string;
|
|
13
|
+
prompt: string;
|
|
14
|
+
context?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AgentResult {
|
|
17
|
+
content: string;
|
|
18
|
+
success: boolean;
|
|
19
|
+
agentId?: string;
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Runtime that executes agent query/execute operations.
|
|
24
|
+
* Default implementation throws — callers must inject a working provider
|
|
25
|
+
* or mock the prototype methods in tests.
|
|
26
|
+
*/
|
|
27
|
+
export declare class AgentRuntime {
|
|
28
|
+
query(_request: AgentQueryRequest): Promise<AgentResult>;
|
|
29
|
+
execute(_request: AgentExecuteRequest): Promise<AgentResult>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=agent-runtime.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal AgentRuntime for the parallel execution module.
|
|
4
|
+
* Provides query/execute methods to run agent operations.
|
|
5
|
+
* Tests use vi.spyOn(AgentRuntime.prototype, 'query') to mock these methods.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.AgentRuntime = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Runtime that executes agent query/execute operations.
|
|
11
|
+
* Default implementation throws — callers must inject a working provider
|
|
12
|
+
* or mock the prototype methods in tests.
|
|
13
|
+
*/
|
|
14
|
+
class AgentRuntime {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
+
async query(_request) {
|
|
17
|
+
throw new Error('AgentRuntime.query is not implemented. Provide a subclass or mock AgentRuntime.prototype.query.');
|
|
18
|
+
}
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
async execute(_request) {
|
|
21
|
+
throw new Error('AgentRuntime.execute is not implemented. Provide a subclass or mock AgentRuntime.prototype.execute.');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AgentRuntime = AgentRuntime;
|
|
25
|
+
//# sourceMappingURL=agent-runtime.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ParallelRunnerMetrics } from './types';
|
|
2
|
-
import {
|
|
2
|
+
import type { AgentQueryRequest, AgentExecuteRequest, AgentResult } from './agent-runtime';
|
|
3
3
|
export interface RetryPolicy {
|
|
4
4
|
maxRetries: number;
|
|
5
5
|
retryDelay: number;
|
|
@@ -25,3 +25,4 @@ export interface HelperResult<T = AgentResult> {
|
|
|
25
25
|
}
|
|
26
26
|
export declare const runQueriesParallel: (queries: AgentQueryRequest[], config?: ParallelConfig) => Promise<AgentResult[]>;
|
|
27
27
|
export declare const runExecutesParallel: (requests: AgentExecuteRequest[], config?: ParallelConfig) => Promise<AgentResult[]>;
|
|
28
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runExecutesParallel = exports.runQueriesParallel = void 0;
|
|
4
4
|
const parallel_runner_1 = require("./parallel-runner");
|
|
5
|
-
const
|
|
5
|
+
const agent_runtime_1 = require("./agent-runtime");
|
|
6
6
|
const DEFAULT_CONCURRENCY = 3;
|
|
7
|
-
const DEFAULT_TIMEOUT_MS =
|
|
7
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
8
8
|
const DEFAULT_RETRY_DELAY_MS = 500;
|
|
9
9
|
const normalizeConcurrency = (value) => {
|
|
10
10
|
if (typeof value !== 'number' || Number.isNaN(value) || !Number.isFinite(value)) {
|
|
@@ -14,18 +14,15 @@ const normalizeConcurrency = (value) => {
|
|
|
14
14
|
return normalized > 0 ? normalized : DEFAULT_CONCURRENCY;
|
|
15
15
|
};
|
|
16
16
|
const normalizeTimeout = (value) => {
|
|
17
|
-
if (value === undefined)
|
|
17
|
+
if (value === undefined)
|
|
18
18
|
return DEFAULT_TIMEOUT_MS;
|
|
19
|
-
|
|
20
|
-
if (typeof value !== 'number' || Number.isNaN(value) || value <= 0) {
|
|
19
|
+
if (typeof value !== 'number' || Number.isNaN(value) || value <= 0)
|
|
21
20
|
return DEFAULT_TIMEOUT_MS;
|
|
22
|
-
}
|
|
23
21
|
return value;
|
|
24
22
|
};
|
|
25
23
|
const normalizeRetryPolicy = (policy) => {
|
|
26
|
-
if (!policy)
|
|
24
|
+
if (!policy)
|
|
27
25
|
return { maxRetries: 0, retryDelay: DEFAULT_RETRY_DELAY_MS };
|
|
28
|
-
}
|
|
29
26
|
const maxRetries = Number.isInteger(policy.maxRetries) && policy.maxRetries >= 0
|
|
30
27
|
? policy.maxRetries
|
|
31
28
|
: 0;
|
|
@@ -36,18 +33,15 @@ const normalizeRetryPolicy = (policy) => {
|
|
|
36
33
|
};
|
|
37
34
|
const createAbortError = (signal) => {
|
|
38
35
|
const reason = signal.reason;
|
|
39
|
-
if (reason instanceof Error)
|
|
36
|
+
if (reason instanceof Error)
|
|
40
37
|
return reason;
|
|
41
|
-
|
|
42
|
-
if (typeof reason === 'string') {
|
|
38
|
+
if (typeof reason === 'string')
|
|
43
39
|
return new Error(reason);
|
|
44
|
-
}
|
|
45
40
|
return new Error('Parallel operation aborted');
|
|
46
41
|
};
|
|
47
42
|
const waitForDelay = (delayMs, signal) => {
|
|
48
|
-
if (delayMs <= 0)
|
|
43
|
+
if (delayMs <= 0)
|
|
49
44
|
return Promise.resolve();
|
|
50
|
-
}
|
|
51
45
|
return new Promise((resolve, reject) => {
|
|
52
46
|
const timer = setTimeout(() => {
|
|
53
47
|
signal.removeEventListener('abort', onAbort);
|
|
@@ -67,72 +61,64 @@ const waitForDelay = (delayMs, signal) => {
|
|
|
67
61
|
const executeWithRetry = async (execute, retryPolicy, signal) => {
|
|
68
62
|
let lastFailureResult;
|
|
69
63
|
let lastError;
|
|
70
|
-
for (let attempt = 0; attempt <= retryPolicy.maxRetries; attempt
|
|
71
|
-
if (signal.aborted)
|
|
64
|
+
for (let attempt = 0; attempt <= retryPolicy.maxRetries; attempt++) {
|
|
65
|
+
if (signal.aborted)
|
|
72
66
|
throw createAbortError(signal);
|
|
73
|
-
}
|
|
74
67
|
try {
|
|
75
68
|
const result = await execute();
|
|
76
69
|
lastFailureResult = result;
|
|
77
|
-
if (result.success || attempt === retryPolicy.maxRetries)
|
|
70
|
+
if (result.success || attempt === retryPolicy.maxRetries)
|
|
78
71
|
return result;
|
|
79
|
-
}
|
|
80
72
|
}
|
|
81
73
|
catch (error) {
|
|
82
74
|
lastError = error;
|
|
83
|
-
if (signal.aborted)
|
|
75
|
+
if (signal.aborted)
|
|
84
76
|
throw createAbortError(signal);
|
|
85
|
-
}
|
|
86
77
|
if (attempt === retryPolicy.maxRetries) {
|
|
87
|
-
|
|
88
|
-
throw normalizedError;
|
|
78
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
89
79
|
}
|
|
90
80
|
}
|
|
91
81
|
if (attempt < retryPolicy.maxRetries) {
|
|
92
82
|
await waitForDelay(retryPolicy.retryDelay, signal);
|
|
93
83
|
}
|
|
94
84
|
}
|
|
95
|
-
if (lastFailureResult)
|
|
85
|
+
if (lastFailureResult)
|
|
96
86
|
return lastFailureResult;
|
|
97
|
-
|
|
98
|
-
if (lastError) {
|
|
87
|
+
if (lastError)
|
|
99
88
|
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
100
|
-
}
|
|
101
89
|
throw new Error('Parallel helper encountered an unexpected state');
|
|
102
90
|
};
|
|
103
|
-
const recordProgress = (
|
|
91
|
+
const recordProgress = (config, state, wasSuccessful) => {
|
|
104
92
|
state.completed += 1;
|
|
105
|
-
if (wasSuccessful)
|
|
93
|
+
if (wasSuccessful)
|
|
106
94
|
state.success += 1;
|
|
107
|
-
|
|
108
|
-
else {
|
|
95
|
+
else
|
|
109
96
|
state.failure += 1;
|
|
110
|
-
}
|
|
111
97
|
try {
|
|
112
|
-
|
|
98
|
+
config.onProgress?.(state.completed, state.total);
|
|
113
99
|
}
|
|
114
100
|
catch (error) {
|
|
115
|
-
if (process.env
|
|
101
|
+
if (process.env['NODE_ENV'] !== 'production') {
|
|
116
102
|
console.warn('Parallel helper onProgress callback threw an error:', error);
|
|
117
103
|
}
|
|
118
104
|
}
|
|
119
105
|
};
|
|
120
|
-
const
|
|
121
|
-
|
|
106
|
+
const buildAgentResults = (taskResults) => {
|
|
107
|
+
const decorated = taskResults.map((taskResult) => ({
|
|
122
108
|
metadata: taskResult.metadata,
|
|
123
109
|
taskResult,
|
|
124
110
|
}));
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
111
|
+
return decorated
|
|
112
|
+
.slice()
|
|
113
|
+
.sort((a, b) => a.metadata.index - b.metadata.index)
|
|
114
|
+
.map(({ metadata, taskResult }) => {
|
|
129
115
|
if (taskResult.value) {
|
|
130
|
-
const
|
|
116
|
+
const base = taskResult.value;
|
|
131
117
|
return {
|
|
132
|
-
...
|
|
133
|
-
agentId:
|
|
118
|
+
...base,
|
|
119
|
+
agentId: base.agentId ?? metadata.request.agentId,
|
|
134
120
|
metadata: {
|
|
135
|
-
...
|
|
121
|
+
...base.metadata,
|
|
136
122
|
requestIndex: metadata.index,
|
|
137
123
|
mode: metadata.mode,
|
|
138
124
|
},
|
|
@@ -152,20 +138,19 @@ const buildAgentResults = (decoratedResults) => {
|
|
|
152
138
|
};
|
|
153
139
|
});
|
|
154
140
|
};
|
|
155
|
-
const collectErrors = (
|
|
156
|
-
return
|
|
157
|
-
.filter((
|
|
158
|
-
.map((
|
|
141
|
+
const collectErrors = (taskResults) => {
|
|
142
|
+
return taskResults
|
|
143
|
+
.filter((r) => !r.success)
|
|
144
|
+
.map((taskResult) => {
|
|
145
|
+
const meta = taskResult.metadata;
|
|
159
146
|
if (taskResult.error instanceof Error) {
|
|
160
|
-
return { index:
|
|
147
|
+
return { index: meta.index, error: taskResult.error };
|
|
161
148
|
}
|
|
162
149
|
if (taskResult.value && !taskResult.value.success) {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
?? 'Agent returned unsuccessful result';
|
|
166
|
-
return { index: metadata.index, error: new Error(errorMessage) };
|
|
150
|
+
const msg = String(taskResult.value.metadata?.['error'] ?? taskResult.value.content ?? 'Agent returned unsuccessful result');
|
|
151
|
+
return { index: meta.index, error: new Error(msg) };
|
|
167
152
|
}
|
|
168
|
-
return { index:
|
|
153
|
+
return { index: meta.index, error: new Error('Unknown failure') };
|
|
169
154
|
});
|
|
170
155
|
};
|
|
171
156
|
const createCallbacks = (progressState, config) => ({
|
|
@@ -182,23 +167,13 @@ const runAgentOperations = async (requests, mode, config = {}) => {
|
|
|
182
167
|
}
|
|
183
168
|
if (requests.length === 0) {
|
|
184
169
|
const emptyMetrics = {
|
|
185
|
-
totalTasks: 0,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
successCount: 0,
|
|
189
|
-
failureCount: 0,
|
|
190
|
-
totalDurationMs: 0,
|
|
191
|
-
averageDurationMs: 0,
|
|
192
|
-
throughput: 0,
|
|
170
|
+
totalTasks: 0, startedTasks: 0, completedTasks: 0,
|
|
171
|
+
successCount: 0, failureCount: 0, totalDurationMs: 0,
|
|
172
|
+
averageDurationMs: 0, throughput: 0,
|
|
193
173
|
};
|
|
194
174
|
const summary = {
|
|
195
|
-
total: 0,
|
|
196
|
-
|
|
197
|
-
successCount: 0,
|
|
198
|
-
failureCount: 0,
|
|
199
|
-
results: [],
|
|
200
|
-
errors: [],
|
|
201
|
-
metrics: emptyMetrics,
|
|
175
|
+
total: 0, completed: 0, successCount: 0, failureCount: 0,
|
|
176
|
+
results: [], errors: [], metrics: emptyMetrics,
|
|
202
177
|
};
|
|
203
178
|
config.onComplete?.(summary);
|
|
204
179
|
return [];
|
|
@@ -207,37 +182,29 @@ const runAgentOperations = async (requests, mode, config = {}) => {
|
|
|
207
182
|
const timeout = normalizeTimeout(config.timeout);
|
|
208
183
|
const retryPolicy = normalizeRetryPolicy(config.retryPolicy);
|
|
209
184
|
const runner = new parallel_runner_1.ParallelRunner();
|
|
210
|
-
const runtime = new
|
|
211
|
-
const runSingleOperation = (request) => (mode === 'query'
|
|
212
|
-
? runtime.query(request)
|
|
213
|
-
: runtime.execute(request));
|
|
185
|
+
const runtime = new agent_runtime_1.AgentRuntime();
|
|
214
186
|
const tasks = requests.map((request, index) => ({
|
|
215
187
|
id: `${mode}:${request.agentId ?? 'anonymous'}:${index}`,
|
|
216
188
|
metadata: { index, mode, request },
|
|
217
|
-
run: (context) => executeWithRetry(() =>
|
|
189
|
+
run: (context) => executeWithRetry(() => mode === 'query'
|
|
190
|
+
? runtime.query(request)
|
|
191
|
+
: runtime.execute(request), retryPolicy, context.signal),
|
|
218
192
|
}));
|
|
219
|
-
const progressState = {
|
|
220
|
-
|
|
221
|
-
success: 0,
|
|
222
|
-
failure: 0,
|
|
223
|
-
total: requests.length,
|
|
224
|
-
};
|
|
225
|
-
const runnerOptions = {
|
|
193
|
+
const progressState = { completed: 0, success: 0, failure: 0, total: requests.length };
|
|
194
|
+
const taskResults = await runner.run(tasks, {
|
|
226
195
|
maxConcurrency: concurrency,
|
|
227
196
|
timeoutMs: timeout,
|
|
228
197
|
evaluateTaskSuccess: (value) => value.success,
|
|
229
198
|
callbacks: createCallbacks(progressState, config),
|
|
230
|
-
};
|
|
231
|
-
const
|
|
232
|
-
const
|
|
233
|
-
const agentResults = buildAgentResults(decoratedResults);
|
|
234
|
-
const errors = collectErrors(decoratedResults);
|
|
199
|
+
});
|
|
200
|
+
const agentResults = buildAgentResults(taskResults);
|
|
201
|
+
const errors = collectErrors(taskResults);
|
|
235
202
|
const metrics = runner.getMetrics();
|
|
236
203
|
const summary = {
|
|
237
204
|
total: requests.length,
|
|
238
205
|
completed: requests.length,
|
|
239
|
-
successCount: agentResults.filter((
|
|
240
|
-
failureCount: agentResults.filter((
|
|
206
|
+
successCount: agentResults.filter((r) => r.success).length,
|
|
207
|
+
failureCount: agentResults.filter((r) => !r.success).length,
|
|
241
208
|
results: agentResults,
|
|
242
209
|
errors,
|
|
243
210
|
metrics,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ParallelRunner } from './parallel-runner';
|
|
2
|
+
export { ParallelRunnerTimeoutError } from './parallel-runner';
|
|
3
|
+
export type { Task, TaskResult, TaskExecutionContext, TaskCallbacks, ParallelRunnerOptions, ParallelRunnerMetrics, } from './types';
|
|
4
|
+
export { runQueriesParallel, runExecutesParallel } from './helpers';
|
|
5
|
+
export type { ParallelConfig, HelperResult, RetryPolicy } from './helpers';
|
|
6
|
+
export { AgentRuntime } from './agent-runtime';
|
|
7
|
+
export type { AgentResult, AgentQueryRequest, AgentExecuteRequest } from './agent-runtime';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|