@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,214 @@
|
|
|
1
|
+
import { ParallelRunner } from './parallel-runner';
|
|
2
|
+
import { AgentRuntime } from './agent-runtime';
|
|
3
|
+
const DEFAULT_CONCURRENCY = 3;
|
|
4
|
+
const DEFAULT_TIMEOUT_MS = 30_000;
|
|
5
|
+
const DEFAULT_RETRY_DELAY_MS = 500;
|
|
6
|
+
const normalizeConcurrency = (value) => {
|
|
7
|
+
if (typeof value !== 'number' || Number.isNaN(value) || !Number.isFinite(value)) {
|
|
8
|
+
return DEFAULT_CONCURRENCY;
|
|
9
|
+
}
|
|
10
|
+
const normalized = Math.floor(value);
|
|
11
|
+
return normalized > 0 ? normalized : DEFAULT_CONCURRENCY;
|
|
12
|
+
};
|
|
13
|
+
const normalizeTimeout = (value) => {
|
|
14
|
+
if (value === undefined)
|
|
15
|
+
return DEFAULT_TIMEOUT_MS;
|
|
16
|
+
if (typeof value !== 'number' || Number.isNaN(value) || value <= 0)
|
|
17
|
+
return DEFAULT_TIMEOUT_MS;
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
const normalizeRetryPolicy = (policy) => {
|
|
21
|
+
if (!policy)
|
|
22
|
+
return { maxRetries: 0, retryDelay: DEFAULT_RETRY_DELAY_MS };
|
|
23
|
+
const maxRetries = Number.isInteger(policy.maxRetries) && policy.maxRetries >= 0
|
|
24
|
+
? policy.maxRetries
|
|
25
|
+
: 0;
|
|
26
|
+
const retryDelay = typeof policy.retryDelay === 'number' && policy.retryDelay >= 0
|
|
27
|
+
? policy.retryDelay
|
|
28
|
+
: DEFAULT_RETRY_DELAY_MS;
|
|
29
|
+
return { maxRetries, retryDelay };
|
|
30
|
+
};
|
|
31
|
+
const createAbortError = (signal) => {
|
|
32
|
+
const reason = signal.reason;
|
|
33
|
+
if (reason instanceof Error)
|
|
34
|
+
return reason;
|
|
35
|
+
if (typeof reason === 'string')
|
|
36
|
+
return new Error(reason);
|
|
37
|
+
return new Error('Parallel operation aborted');
|
|
38
|
+
};
|
|
39
|
+
const waitForDelay = (delayMs, signal) => {
|
|
40
|
+
if (delayMs <= 0)
|
|
41
|
+
return Promise.resolve();
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const timer = setTimeout(() => {
|
|
44
|
+
signal.removeEventListener('abort', onAbort);
|
|
45
|
+
resolve();
|
|
46
|
+
}, delayMs);
|
|
47
|
+
const onAbort = () => {
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
reject(createAbortError(signal));
|
|
50
|
+
};
|
|
51
|
+
if (signal.aborted) {
|
|
52
|
+
onAbort();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
const executeWithRetry = async (execute, retryPolicy, signal) => {
|
|
59
|
+
let lastFailureResult;
|
|
60
|
+
let lastError;
|
|
61
|
+
for (let attempt = 0; attempt <= retryPolicy.maxRetries; attempt++) {
|
|
62
|
+
if (signal.aborted)
|
|
63
|
+
throw createAbortError(signal);
|
|
64
|
+
try {
|
|
65
|
+
const result = await execute();
|
|
66
|
+
lastFailureResult = result;
|
|
67
|
+
if (result.success || attempt === retryPolicy.maxRetries)
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
lastError = error;
|
|
72
|
+
if (signal.aborted)
|
|
73
|
+
throw createAbortError(signal);
|
|
74
|
+
if (attempt === retryPolicy.maxRetries) {
|
|
75
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (attempt < retryPolicy.maxRetries) {
|
|
79
|
+
await waitForDelay(retryPolicy.retryDelay, signal);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (lastFailureResult)
|
|
83
|
+
return lastFailureResult;
|
|
84
|
+
if (lastError)
|
|
85
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
86
|
+
throw new Error('Parallel helper encountered an unexpected state');
|
|
87
|
+
};
|
|
88
|
+
const recordProgress = (config, state, wasSuccessful) => {
|
|
89
|
+
state.completed += 1;
|
|
90
|
+
if (wasSuccessful)
|
|
91
|
+
state.success += 1;
|
|
92
|
+
else
|
|
93
|
+
state.failure += 1;
|
|
94
|
+
try {
|
|
95
|
+
config.onProgress?.(state.completed, state.total);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (process.env['NODE_ENV'] !== 'production') {
|
|
99
|
+
console.warn('Parallel helper onProgress callback threw an error:', error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const buildAgentResults = (taskResults) => {
|
|
104
|
+
const decorated = taskResults.map((taskResult) => ({
|
|
105
|
+
metadata: taskResult.metadata,
|
|
106
|
+
taskResult,
|
|
107
|
+
}));
|
|
108
|
+
return decorated
|
|
109
|
+
.slice()
|
|
110
|
+
.sort((a, b) => a.metadata.index - b.metadata.index)
|
|
111
|
+
.map(({ metadata, taskResult }) => {
|
|
112
|
+
if (taskResult.value) {
|
|
113
|
+
const base = taskResult.value;
|
|
114
|
+
return {
|
|
115
|
+
...base,
|
|
116
|
+
agentId: base.agentId ?? metadata.request.agentId,
|
|
117
|
+
metadata: {
|
|
118
|
+
...base.metadata,
|
|
119
|
+
requestIndex: metadata.index,
|
|
120
|
+
mode: metadata.mode,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const error = taskResult.error ?? new Error('Unknown error');
|
|
125
|
+
return {
|
|
126
|
+
agentId: metadata.request.agentId,
|
|
127
|
+
content: error.message,
|
|
128
|
+
success: false,
|
|
129
|
+
metadata: {
|
|
130
|
+
error: error.message,
|
|
131
|
+
aborted: taskResult.aborted ?? false,
|
|
132
|
+
requestIndex: metadata.index,
|
|
133
|
+
mode: metadata.mode,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
const collectErrors = (taskResults) => {
|
|
139
|
+
return taskResults
|
|
140
|
+
.filter((r) => !r.success)
|
|
141
|
+
.map((taskResult) => {
|
|
142
|
+
const meta = taskResult.metadata;
|
|
143
|
+
if (taskResult.error instanceof Error) {
|
|
144
|
+
return { index: meta.index, error: taskResult.error };
|
|
145
|
+
}
|
|
146
|
+
if (taskResult.value && !taskResult.value.success) {
|
|
147
|
+
const msg = String(taskResult.value.metadata?.['error'] ?? taskResult.value.content ?? 'Agent returned unsuccessful result');
|
|
148
|
+
return { index: meta.index, error: new Error(msg) };
|
|
149
|
+
}
|
|
150
|
+
return { index: meta.index, error: new Error('Unknown failure') };
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
const createCallbacks = (progressState, config) => ({
|
|
154
|
+
onTaskComplete: async (result) => {
|
|
155
|
+
recordProgress(config, progressState, result.success);
|
|
156
|
+
},
|
|
157
|
+
onError: async () => {
|
|
158
|
+
recordProgress(config, progressState, false);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
const runAgentOperations = async (requests, mode, config = {}) => {
|
|
162
|
+
if (!Array.isArray(requests)) {
|
|
163
|
+
throw new TypeError('Parallel helpers expect an array of requests');
|
|
164
|
+
}
|
|
165
|
+
if (requests.length === 0) {
|
|
166
|
+
const emptyMetrics = {
|
|
167
|
+
totalTasks: 0, startedTasks: 0, completedTasks: 0,
|
|
168
|
+
successCount: 0, failureCount: 0, totalDurationMs: 0,
|
|
169
|
+
averageDurationMs: 0, throughput: 0,
|
|
170
|
+
};
|
|
171
|
+
const summary = {
|
|
172
|
+
total: 0, completed: 0, successCount: 0, failureCount: 0,
|
|
173
|
+
results: [], errors: [], metrics: emptyMetrics,
|
|
174
|
+
};
|
|
175
|
+
config.onComplete?.(summary);
|
|
176
|
+
return [];
|
|
177
|
+
}
|
|
178
|
+
const concurrency = normalizeConcurrency(config.concurrency);
|
|
179
|
+
const timeout = normalizeTimeout(config.timeout);
|
|
180
|
+
const retryPolicy = normalizeRetryPolicy(config.retryPolicy);
|
|
181
|
+
const runner = new ParallelRunner();
|
|
182
|
+
const runtime = new AgentRuntime();
|
|
183
|
+
const tasks = requests.map((request, index) => ({
|
|
184
|
+
id: `${mode}:${request.agentId ?? 'anonymous'}:${index}`,
|
|
185
|
+
metadata: { index, mode, request },
|
|
186
|
+
run: (context) => executeWithRetry(() => mode === 'query'
|
|
187
|
+
? runtime.query(request)
|
|
188
|
+
: runtime.execute(request), retryPolicy, context.signal),
|
|
189
|
+
}));
|
|
190
|
+
const progressState = { completed: 0, success: 0, failure: 0, total: requests.length };
|
|
191
|
+
const taskResults = await runner.run(tasks, {
|
|
192
|
+
maxConcurrency: concurrency,
|
|
193
|
+
timeoutMs: timeout,
|
|
194
|
+
evaluateTaskSuccess: (value) => value.success,
|
|
195
|
+
callbacks: createCallbacks(progressState, config),
|
|
196
|
+
});
|
|
197
|
+
const agentResults = buildAgentResults(taskResults);
|
|
198
|
+
const errors = collectErrors(taskResults);
|
|
199
|
+
const metrics = runner.getMetrics();
|
|
200
|
+
const summary = {
|
|
201
|
+
total: requests.length,
|
|
202
|
+
completed: requests.length,
|
|
203
|
+
successCount: agentResults.filter((r) => r.success).length,
|
|
204
|
+
failureCount: agentResults.filter((r) => !r.success).length,
|
|
205
|
+
results: agentResults,
|
|
206
|
+
errors,
|
|
207
|
+
metrics,
|
|
208
|
+
};
|
|
209
|
+
config.onComplete?.(summary);
|
|
210
|
+
return agentResults;
|
|
211
|
+
};
|
|
212
|
+
export const runQueriesParallel = (queries, config) => runAgentOperations(queries, 'query', config);
|
|
213
|
+
export const runExecutesParallel = (requests, config) => runAgentOperations(requests, 'execute', config);
|
|
214
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ParallelRunner } from './parallel-runner';
|
|
2
|
+
export { ParallelRunnerTimeoutError } from './parallel-runner';
|
|
3
|
+
export { runQueriesParallel, runExecutesParallel } from './helpers';
|
|
4
|
+
export { AgentRuntime } from './agent-runtime';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { performance } from 'node:perf_hooks';
|
|
2
|
+
/**
|
|
3
|
+
* Error raised when a task exceeds the configured per-task timeout.
|
|
4
|
+
*/
|
|
5
|
+
export class ParallelRunnerTimeoutError extends Error {
|
|
6
|
+
taskId;
|
|
7
|
+
timeoutMs;
|
|
8
|
+
constructor(taskId, timeoutMs) {
|
|
9
|
+
super(`Task ${taskId} timed out after ${timeoutMs}ms`);
|
|
10
|
+
this.taskId = taskId;
|
|
11
|
+
this.timeoutMs = timeoutMs;
|
|
12
|
+
this.name = 'ParallelRunnerTimeoutError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Executes tasks with bounded concurrency and cooperative cancellation support.
|
|
17
|
+
* Framework-agnostic — usable from CLI, SDK, or any consumer.
|
|
18
|
+
*/
|
|
19
|
+
export class ParallelRunner {
|
|
20
|
+
defaults;
|
|
21
|
+
metrics = {
|
|
22
|
+
totalTasks: 0,
|
|
23
|
+
startedTasks: 0,
|
|
24
|
+
completedTasks: 0,
|
|
25
|
+
successCount: 0,
|
|
26
|
+
failureCount: 0,
|
|
27
|
+
totalDurationMs: 0,
|
|
28
|
+
averageDurationMs: 0,
|
|
29
|
+
throughput: 0,
|
|
30
|
+
};
|
|
31
|
+
constructor(defaults = {}) {
|
|
32
|
+
this.defaults = defaults;
|
|
33
|
+
}
|
|
34
|
+
async run(tasks, options = {}) {
|
|
35
|
+
if (!Array.isArray(tasks)) {
|
|
36
|
+
throw new TypeError('ParallelRunner.run expects an array of tasks');
|
|
37
|
+
}
|
|
38
|
+
if (tasks.length === 0) {
|
|
39
|
+
this.metrics = {
|
|
40
|
+
totalTasks: 0,
|
|
41
|
+
startedTasks: 0,
|
|
42
|
+
completedTasks: 0,
|
|
43
|
+
successCount: 0,
|
|
44
|
+
failureCount: 0,
|
|
45
|
+
totalDurationMs: 0,
|
|
46
|
+
averageDurationMs: 0,
|
|
47
|
+
throughput: 0,
|
|
48
|
+
};
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const merged = this.mergeOptions(options);
|
|
52
|
+
const maxConcurrency = Math.max(1, merged.maxConcurrency ?? 5);
|
|
53
|
+
const timeoutMs = merged.timeoutMs;
|
|
54
|
+
const failFast = merged.failFast ?? false;
|
|
55
|
+
const callbacks = merged.callbacks;
|
|
56
|
+
const evaluateTaskSuccess = merged.evaluateTaskSuccess ?? (() => true);
|
|
57
|
+
const results = [];
|
|
58
|
+
let successCount = 0;
|
|
59
|
+
let failureCount = 0;
|
|
60
|
+
let startedTasks = 0;
|
|
61
|
+
let aborted = false;
|
|
62
|
+
let cursor = 0;
|
|
63
|
+
const startedAt = performance.now();
|
|
64
|
+
const executeTask = async (task) => {
|
|
65
|
+
if (callbacks?.onTaskStart) {
|
|
66
|
+
await callbacks.onTaskStart(task);
|
|
67
|
+
}
|
|
68
|
+
startedTasks += 1;
|
|
69
|
+
const controller = new AbortController();
|
|
70
|
+
const context = { signal: controller.signal };
|
|
71
|
+
let timeoutId;
|
|
72
|
+
let timeoutPromise;
|
|
73
|
+
if (typeof timeoutMs === 'number' && Number.isFinite(timeoutMs) && timeoutMs > 0) {
|
|
74
|
+
timeoutPromise = new Promise((_, reject) => {
|
|
75
|
+
timeoutId = setTimeout(() => {
|
|
76
|
+
const err = new ParallelRunnerTimeoutError(task.id, timeoutMs);
|
|
77
|
+
controller.abort(err);
|
|
78
|
+
reject(err);
|
|
79
|
+
}, timeoutMs);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const taskStartedAt = performance.now();
|
|
83
|
+
const runPromise = task.run(context);
|
|
84
|
+
const combinedPromise = timeoutPromise
|
|
85
|
+
? Promise.race([runPromise, timeoutPromise])
|
|
86
|
+
: runPromise;
|
|
87
|
+
try {
|
|
88
|
+
const value = await combinedPromise;
|
|
89
|
+
const taskFinishedAt = performance.now();
|
|
90
|
+
const durationMs = taskFinishedAt - taskStartedAt;
|
|
91
|
+
const success = evaluateTaskSuccess(value, task);
|
|
92
|
+
const result = {
|
|
93
|
+
taskId: task.id,
|
|
94
|
+
success,
|
|
95
|
+
value,
|
|
96
|
+
durationMs,
|
|
97
|
+
startedAt: taskStartedAt,
|
|
98
|
+
finishedAt: taskFinishedAt,
|
|
99
|
+
metadata: task.metadata,
|
|
100
|
+
aborted: false,
|
|
101
|
+
};
|
|
102
|
+
results.push(result);
|
|
103
|
+
success ? (successCount += 1) : (failureCount += 1);
|
|
104
|
+
if (callbacks?.onTaskComplete) {
|
|
105
|
+
await callbacks.onTaskComplete(result);
|
|
106
|
+
}
|
|
107
|
+
if (failFast && !success) {
|
|
108
|
+
aborted = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (rawError) {
|
|
112
|
+
const taskFinishedAt = performance.now();
|
|
113
|
+
const durationMs = taskFinishedAt - taskStartedAt;
|
|
114
|
+
const error = rawError instanceof Error ? rawError : new Error(String(rawError));
|
|
115
|
+
const result = {
|
|
116
|
+
taskId: task.id,
|
|
117
|
+
success: false,
|
|
118
|
+
error,
|
|
119
|
+
durationMs,
|
|
120
|
+
startedAt: taskStartedAt,
|
|
121
|
+
finishedAt: taskFinishedAt,
|
|
122
|
+
metadata: task.metadata,
|
|
123
|
+
aborted: controller.signal.aborted,
|
|
124
|
+
};
|
|
125
|
+
results.push(result);
|
|
126
|
+
failureCount += 1;
|
|
127
|
+
if (callbacks?.onError) {
|
|
128
|
+
await callbacks.onError(task, error, durationMs);
|
|
129
|
+
}
|
|
130
|
+
if (failFast) {
|
|
131
|
+
aborted = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
if (timeoutId)
|
|
136
|
+
clearTimeout(timeoutId);
|
|
137
|
+
// Prevent unhandled rejections if timeout fired before task finished
|
|
138
|
+
if (timeoutPromise)
|
|
139
|
+
runPromise.catch(() => undefined);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const worker = async () => {
|
|
143
|
+
while (true) {
|
|
144
|
+
if (aborted)
|
|
145
|
+
break;
|
|
146
|
+
const index = cursor;
|
|
147
|
+
if (index >= tasks.length)
|
|
148
|
+
break;
|
|
149
|
+
cursor += 1;
|
|
150
|
+
const task = tasks[index];
|
|
151
|
+
if (!task)
|
|
152
|
+
break;
|
|
153
|
+
await executeTask(task);
|
|
154
|
+
if (aborted)
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const workerCount = Math.min(maxConcurrency, tasks.length);
|
|
159
|
+
const workers = [];
|
|
160
|
+
for (let i = 0; i < workerCount; i++) {
|
|
161
|
+
workers.push(worker());
|
|
162
|
+
}
|
|
163
|
+
await Promise.all(workers);
|
|
164
|
+
const finishedAt = performance.now();
|
|
165
|
+
const totalDurationMs = finishedAt - startedAt;
|
|
166
|
+
const averageDurationMs = results.length
|
|
167
|
+
? results.reduce((sum, r) => sum + r.durationMs, 0) / results.length
|
|
168
|
+
: 0;
|
|
169
|
+
const throughput = totalDurationMs > 0
|
|
170
|
+
? results.length / (totalDurationMs / 1000)
|
|
171
|
+
: results.length;
|
|
172
|
+
this.metrics = {
|
|
173
|
+
totalTasks: tasks.length,
|
|
174
|
+
startedTasks,
|
|
175
|
+
completedTasks: results.length,
|
|
176
|
+
successCount,
|
|
177
|
+
failureCount,
|
|
178
|
+
totalDurationMs,
|
|
179
|
+
averageDurationMs,
|
|
180
|
+
throughput,
|
|
181
|
+
};
|
|
182
|
+
return results;
|
|
183
|
+
}
|
|
184
|
+
getMetrics() {
|
|
185
|
+
return this.metrics;
|
|
186
|
+
}
|
|
187
|
+
mergeOptions(options) {
|
|
188
|
+
return {
|
|
189
|
+
maxConcurrency: options.maxConcurrency ?? this.defaults.maxConcurrency,
|
|
190
|
+
timeoutMs: options.timeoutMs ?? this.defaults.timeoutMs,
|
|
191
|
+
failFast: options.failFast ?? this.defaults.failFast,
|
|
192
|
+
evaluateTaskSuccess: options.evaluateTaskSuccess ?? this.defaults.evaluateTaskSuccess,
|
|
193
|
+
callbacks: this.mergeCallbacks(this.defaults.callbacks, options.callbacks),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
mergeCallbacks(base, override) {
|
|
197
|
+
if (!base && !override)
|
|
198
|
+
return undefined;
|
|
199
|
+
return {
|
|
200
|
+
onTaskStart: async (task) => {
|
|
201
|
+
if (base?.onTaskStart)
|
|
202
|
+
await base.onTaskStart(task);
|
|
203
|
+
if (override?.onTaskStart)
|
|
204
|
+
await override.onTaskStart(task);
|
|
205
|
+
},
|
|
206
|
+
onTaskComplete: async (result) => {
|
|
207
|
+
if (base?.onTaskComplete)
|
|
208
|
+
await base.onTaskComplete(result);
|
|
209
|
+
if (override?.onTaskComplete)
|
|
210
|
+
await override.onTaskComplete(result);
|
|
211
|
+
},
|
|
212
|
+
onError: async (task, error, durationMs) => {
|
|
213
|
+
if (base?.onError)
|
|
214
|
+
await base.onError(task, error, durationMs);
|
|
215
|
+
if (override?.onError)
|
|
216
|
+
await override.onError(task, error, durationMs);
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=parallel-runner.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Detect crewx execute/x command pattern */
|
|
2
|
+
export function isAgentCallCommand(command) {
|
|
3
|
+
return /crewx\s+(x|execute)\s/.test(command);
|
|
4
|
+
}
|
|
5
|
+
/** Extract agent_call entry from crewx x "@agent ..." command */
|
|
6
|
+
export function parseAgentCall(timestamp, command) {
|
|
7
|
+
const agentMatch = command.match(/@(\S+)/);
|
|
8
|
+
return {
|
|
9
|
+
timestamp,
|
|
10
|
+
type: 'agent_call',
|
|
11
|
+
targetAgent: agentMatch?.[1]?.replace(/["']/g, ''),
|
|
12
|
+
toolInput: command,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=agent-call.util.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isAgentCallCommand, parseAgentCall } from './agent-call.util';
|
|
2
|
+
/**
|
|
3
|
+
* Parse Claude stream-json events into TaskLogEntry[].
|
|
4
|
+
*
|
|
5
|
+
* Claude events:
|
|
6
|
+
* - { type: "assistant", message: { content: [{ type: "text"|"tool_use", ... }] } }
|
|
7
|
+
* - { type: "user", message: { content: [{ type: "tool_result", ... }] } }
|
|
8
|
+
*/
|
|
9
|
+
export function parseClaudeEvent(timestamp, parsed) {
|
|
10
|
+
const msg = parsed.message;
|
|
11
|
+
const content = msg?.content;
|
|
12
|
+
if (!Array.isArray(content))
|
|
13
|
+
return [];
|
|
14
|
+
const entries = [];
|
|
15
|
+
for (const block of content) {
|
|
16
|
+
const entry = parseClaudeBlock(timestamp, block);
|
|
17
|
+
if (entry)
|
|
18
|
+
entries.push(entry);
|
|
19
|
+
}
|
|
20
|
+
return entries;
|
|
21
|
+
}
|
|
22
|
+
function parseClaudeBlock(timestamp, block) {
|
|
23
|
+
const blockType = block.type;
|
|
24
|
+
if (blockType === 'text') {
|
|
25
|
+
const text = String(block.text || '');
|
|
26
|
+
if (!text)
|
|
27
|
+
return null;
|
|
28
|
+
return { timestamp, type: 'text', content: text };
|
|
29
|
+
}
|
|
30
|
+
if (blockType === 'tool_use') {
|
|
31
|
+
const toolName = String(block.name || '');
|
|
32
|
+
const toolUseId = block.id;
|
|
33
|
+
const input = block.input;
|
|
34
|
+
const inputStr = input?.command
|
|
35
|
+
? String(input.command)
|
|
36
|
+
: JSON.stringify(input || {});
|
|
37
|
+
if (toolName === 'Bash' && isAgentCallCommand(inputStr)) {
|
|
38
|
+
return parseAgentCall(timestamp, inputStr);
|
|
39
|
+
}
|
|
40
|
+
return { timestamp, type: 'tool_use', toolUseId, toolName, toolInput: inputStr };
|
|
41
|
+
}
|
|
42
|
+
if (blockType === 'tool_result') {
|
|
43
|
+
const isError = Boolean(block.is_error);
|
|
44
|
+
const toolUseId = block.tool_use_id;
|
|
45
|
+
const raw = block.output ?? block.content ?? '';
|
|
46
|
+
let output;
|
|
47
|
+
if (typeof raw === 'string') {
|
|
48
|
+
output = raw;
|
|
49
|
+
}
|
|
50
|
+
else if (Array.isArray(raw)) {
|
|
51
|
+
// Claude tool_result content can be [{ type: "text", text: "..." }, ...]
|
|
52
|
+
output = raw
|
|
53
|
+
.filter(c => c.type === 'text' && typeof c.text === 'string')
|
|
54
|
+
.map(c => c.text)
|
|
55
|
+
.join('\n');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
output = JSON.stringify(raw);
|
|
59
|
+
}
|
|
60
|
+
return { timestamp, type: 'tool_result', toolUseId, resultPreview: output, isError };
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=claude.parser.js.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { isAgentCallCommand, parseAgentCall } from './agent-call.util';
|
|
2
|
+
/**
|
|
3
|
+
* Parse Codex experimental-json events into TaskLogEntry[].
|
|
4
|
+
*
|
|
5
|
+
* Codex events:
|
|
6
|
+
* - { type: "item.started", item: { type: "command_execution", command } }
|
|
7
|
+
* - { type: "item.completed", item: { type: "command_execution"|"message"|"text"|"reasoning"|"tool_use"|"tool_result", ... } }
|
|
8
|
+
*/
|
|
9
|
+
export function parseCodexEvent(timestamp, parsed) {
|
|
10
|
+
const type = parsed.type;
|
|
11
|
+
const item = parsed.item;
|
|
12
|
+
if (!item)
|
|
13
|
+
return [];
|
|
14
|
+
if (type === 'item.started') {
|
|
15
|
+
return parseItemStarted(timestamp, item);
|
|
16
|
+
}
|
|
17
|
+
if (type === 'item.completed') {
|
|
18
|
+
const entry = parseItemCompleted(timestamp, item);
|
|
19
|
+
return entry ? [entry] : [];
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
function parseItemStarted(timestamp, item) {
|
|
24
|
+
const itemType = item.type;
|
|
25
|
+
if (itemType === 'command_execution') {
|
|
26
|
+
const command = String(item.command || '');
|
|
27
|
+
if (isAgentCallCommand(command)) {
|
|
28
|
+
return [parseAgentCall(timestamp, command)];
|
|
29
|
+
}
|
|
30
|
+
return [{ timestamp, type: 'tool_use', toolName: 'Bash', toolInput: command }];
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
function parseItemCompleted(timestamp, item) {
|
|
35
|
+
const itemType = item.type;
|
|
36
|
+
// assistant_message / message / text
|
|
37
|
+
if (itemType === 'message' || itemType === 'text') {
|
|
38
|
+
const content = item.content;
|
|
39
|
+
if (Array.isArray(content)) {
|
|
40
|
+
for (const block of content) {
|
|
41
|
+
const entry = parseCodexBlock(timestamp, block);
|
|
42
|
+
if (entry)
|
|
43
|
+
return entry;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (typeof item.text === 'string') {
|
|
47
|
+
return { timestamp, type: 'text', content: item.text };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (itemType === 'reasoning') {
|
|
51
|
+
return { timestamp, type: 'text', content: String(item.text || '') };
|
|
52
|
+
}
|
|
53
|
+
// command_execution completed → tool_result (with error support)
|
|
54
|
+
if (itemType === 'command_execution') {
|
|
55
|
+
const output = String(item.aggregated_output || item.output || '');
|
|
56
|
+
const isError = Boolean(item.is_error);
|
|
57
|
+
return { timestamp, type: 'tool_result', resultPreview: output, isError };
|
|
58
|
+
}
|
|
59
|
+
// tool_use from Codex item.completed
|
|
60
|
+
if (itemType === 'tool_use') {
|
|
61
|
+
const toolName = String(item.name || item.tool_name || '');
|
|
62
|
+
const input = item.input;
|
|
63
|
+
const inputStr = input?.command
|
|
64
|
+
? String(input.command)
|
|
65
|
+
: JSON.stringify(input || {});
|
|
66
|
+
if (toolName === 'Bash' && isAgentCallCommand(inputStr)) {
|
|
67
|
+
return parseAgentCall(timestamp, inputStr);
|
|
68
|
+
}
|
|
69
|
+
return { timestamp, type: 'tool_use', toolName, toolInput: inputStr };
|
|
70
|
+
}
|
|
71
|
+
// tool_result from Codex item.completed
|
|
72
|
+
if (itemType === 'tool_result') {
|
|
73
|
+
const isError = Boolean(item.is_error);
|
|
74
|
+
const output = String(item.output || item.content || '');
|
|
75
|
+
return { timestamp, type: 'tool_result', resultPreview: output, isError };
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
function parseCodexBlock(timestamp, block) {
|
|
80
|
+
const blockType = block.type;
|
|
81
|
+
if (blockType === 'text') {
|
|
82
|
+
return { timestamp, type: 'text', content: String(block.text || '') };
|
|
83
|
+
}
|
|
84
|
+
if (blockType === 'tool_use') {
|
|
85
|
+
const toolName = String(block.name || '');
|
|
86
|
+
const input = block.input;
|
|
87
|
+
const inputStr = input?.command
|
|
88
|
+
? String(input.command)
|
|
89
|
+
: JSON.stringify(input || {});
|
|
90
|
+
if (toolName === 'Bash' && isAgentCallCommand(inputStr)) {
|
|
91
|
+
return parseAgentCall(timestamp, inputStr);
|
|
92
|
+
}
|
|
93
|
+
return { timestamp, type: 'tool_use', toolName, toolInput: inputStr };
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=codex.parser.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { isAgentCallCommand, parseAgentCall } from './agent-call.util';
|
|
2
|
+
/**
|
|
3
|
+
* Parse Copilot json events into TaskLogEntry[].
|
|
4
|
+
*
|
|
5
|
+
* Copilot events:
|
|
6
|
+
* - { type: "tool.execution_start", data: { toolName, arguments } }
|
|
7
|
+
* - { type: "tool.execution_complete", data: { result?: { content }, error?: { message } } }
|
|
8
|
+
* - { type: "assistant.message", data: { content } }
|
|
9
|
+
*/
|
|
10
|
+
export function parseCopilotEvent(timestamp, parsed) {
|
|
11
|
+
const type = parsed.type;
|
|
12
|
+
const data = parsed.data;
|
|
13
|
+
if (!data)
|
|
14
|
+
return [];
|
|
15
|
+
const toolCallId = data.toolCallId;
|
|
16
|
+
if (type === 'tool.execution_start') {
|
|
17
|
+
const toolName = String(data.toolName || '');
|
|
18
|
+
const args = data.arguments;
|
|
19
|
+
const inputStr = args?.command
|
|
20
|
+
? String(args.command)
|
|
21
|
+
: JSON.stringify(args || {});
|
|
22
|
+
if ((toolName === 'bash' || toolName === 'Bash') &&
|
|
23
|
+
isAgentCallCommand(inputStr)) {
|
|
24
|
+
return [parseAgentCall(timestamp, inputStr)];
|
|
25
|
+
}
|
|
26
|
+
return [{
|
|
27
|
+
timestamp,
|
|
28
|
+
type: 'tool_use',
|
|
29
|
+
toolName,
|
|
30
|
+
toolInput: inputStr,
|
|
31
|
+
...(toolCallId && { toolUseId: toolCallId }),
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
if (type === 'tool.execution_complete') {
|
|
35
|
+
const error = data.error;
|
|
36
|
+
if (error) {
|
|
37
|
+
return [{
|
|
38
|
+
timestamp,
|
|
39
|
+
type: 'tool_result',
|
|
40
|
+
isError: true,
|
|
41
|
+
resultPreview: String(error.message || ''),
|
|
42
|
+
...(toolCallId && { toolUseId: toolCallId }),
|
|
43
|
+
}];
|
|
44
|
+
}
|
|
45
|
+
const result = data.result;
|
|
46
|
+
const content = String(result?.content || '');
|
|
47
|
+
return [{
|
|
48
|
+
timestamp,
|
|
49
|
+
type: 'tool_result',
|
|
50
|
+
resultPreview: content,
|
|
51
|
+
isError: false,
|
|
52
|
+
...(toolCallId && { toolUseId: toolCallId }),
|
|
53
|
+
}];
|
|
54
|
+
}
|
|
55
|
+
if (type === 'assistant.message') {
|
|
56
|
+
const content = String(data.content || '');
|
|
57
|
+
if (!content)
|
|
58
|
+
return [];
|
|
59
|
+
return [{ timestamp, type: 'text', content }];
|
|
60
|
+
}
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=copilot.parser.js.map
|