@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,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in tool definitions for api/* provider agents.
|
|
3
|
+
*
|
|
4
|
+
* Adapted from packages/sdk-bak/src/tools/.
|
|
5
|
+
* Uses only Node.js built-ins — no external dependencies.
|
|
6
|
+
*
|
|
7
|
+
* Each entry in BUILTIN_TOOL_REGISTRY matches Omit<ToolDefinition, 'name'>.
|
|
8
|
+
* Register via crewx.registerTool(name, BUILTIN_TOOL_REGISTRY[name]).
|
|
9
|
+
*/
|
|
10
|
+
type BuiltinTool = {
|
|
11
|
+
description: string;
|
|
12
|
+
parameters?: Record<string, unknown>;
|
|
13
|
+
execute: (args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* All available built-in tools, keyed by tool name.
|
|
17
|
+
*
|
|
18
|
+
* Listed tools are registered via crewx.registerTool() when their name appears
|
|
19
|
+
* in crewx.yaml `tools.builtin` for an agent using an api/* provider.
|
|
20
|
+
*/
|
|
21
|
+
export declare const BUILTIN_TOOL_REGISTRY: Record<string, BuiltinTool>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=builtin.d.ts.map
|
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in tool definitions for api/* provider agents.
|
|
4
|
+
*
|
|
5
|
+
* Adapted from packages/sdk-bak/src/tools/.
|
|
6
|
+
* Uses only Node.js built-ins — no external dependencies.
|
|
7
|
+
*
|
|
8
|
+
* Each entry in BUILTIN_TOOL_REGISTRY matches Omit<ToolDefinition, 'name'>.
|
|
9
|
+
* Register via crewx.registerTool(name, BUILTIN_TOOL_REGISTRY[name]).
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BUILTIN_TOOL_REGISTRY = void 0;
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
18
|
+
const node_child_process_1 = require("node:child_process");
|
|
19
|
+
const node_util_1 = require("node:util");
|
|
20
|
+
const execAsync = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
22
|
+
// Shared helpers
|
|
23
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
24
|
+
const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'build', '.next']);
|
|
25
|
+
async function listRecursive(dirPath, basePath, maxDepth = 5, depth = 0) {
|
|
26
|
+
if (depth >= maxDepth) {
|
|
27
|
+
return [`${node_path_1.default.relative(basePath, dirPath)}/ (max depth reached)`];
|
|
28
|
+
}
|
|
29
|
+
const results = [];
|
|
30
|
+
let entries;
|
|
31
|
+
try {
|
|
32
|
+
entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return [`${node_path_1.default.relative(basePath, dirPath)}/ (permission denied)`];
|
|
36
|
+
}
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const fullPath = node_path_1.default.join(dirPath, entry.name);
|
|
39
|
+
const rel = node_path_1.default.relative(basePath, fullPath);
|
|
40
|
+
if (entry.isDirectory()) {
|
|
41
|
+
results.push(`${rel}/`);
|
|
42
|
+
const sub = await listRecursive(fullPath, basePath, maxDepth, depth + 1);
|
|
43
|
+
results.push(...sub);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const s = await promises_1.default.stat(fullPath);
|
|
47
|
+
results.push(`${rel} (${s.size} bytes)`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return results;
|
|
51
|
+
}
|
|
52
|
+
async function buildTreeLines(dirPath, opts) {
|
|
53
|
+
const { currentDepth, maxDepth } = opts;
|
|
54
|
+
const indent = ' '.repeat(currentDepth);
|
|
55
|
+
let entries;
|
|
56
|
+
try {
|
|
57
|
+
entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
const code = err.code ?? 'unknown';
|
|
61
|
+
return [`${indent}(error: ${code})`];
|
|
62
|
+
}
|
|
63
|
+
entries.sort((a, b) => {
|
|
64
|
+
if (a.isDirectory() && !b.isDirectory())
|
|
65
|
+
return -1;
|
|
66
|
+
if (!a.isDirectory() && b.isDirectory())
|
|
67
|
+
return 1;
|
|
68
|
+
return a.name.localeCompare(b.name);
|
|
69
|
+
});
|
|
70
|
+
const lines = [];
|
|
71
|
+
for (const entry of entries) {
|
|
72
|
+
const fullPath = node_path_1.default.join(dirPath, entry.name);
|
|
73
|
+
if (entry.isDirectory()) {
|
|
74
|
+
lines.push(`${indent}[DIR] ${entry.name}/`);
|
|
75
|
+
if (currentDepth < maxDepth) {
|
|
76
|
+
const child = await buildTreeLines(fullPath, {
|
|
77
|
+
currentDepth: currentDepth + 1,
|
|
78
|
+
maxDepth,
|
|
79
|
+
});
|
|
80
|
+
lines.push(...child);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
lines.push(`${' '.repeat(currentDepth + 1)}(max depth reached)`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
try {
|
|
88
|
+
const s = await promises_1.default.stat(fullPath);
|
|
89
|
+
lines.push(`${indent}[FILE] ${entry.name} (${s.size} bytes)`);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
lines.push(`${indent}[FILE] ${entry.name} (stat error)`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return lines;
|
|
97
|
+
}
|
|
98
|
+
async function searchFile(filePath, pattern, basePath) {
|
|
99
|
+
try {
|
|
100
|
+
const content = await promises_1.default.readFile(filePath, 'utf-8');
|
|
101
|
+
const lines = content.split('\n');
|
|
102
|
+
const rel = node_path_1.default.relative(basePath, filePath);
|
|
103
|
+
return lines.flatMap((line, i) => pattern.test(line) ? [`${rel}:${i + 1}: ${line}`] : []);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function searchRecursive(dirPath, pattern, basePath, maxDepth = 10, depth = 0) {
|
|
110
|
+
if (depth >= maxDepth)
|
|
111
|
+
return [];
|
|
112
|
+
const results = [];
|
|
113
|
+
let entries;
|
|
114
|
+
try {
|
|
115
|
+
entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
for (const entry of entries) {
|
|
121
|
+
const fullPath = node_path_1.default.join(dirPath, entry.name);
|
|
122
|
+
if (entry.isDirectory()) {
|
|
123
|
+
if (!SKIP_DIRS.has(entry.name)) {
|
|
124
|
+
const sub = await searchRecursive(fullPath, pattern, basePath, maxDepth, depth + 1);
|
|
125
|
+
results.push(...sub);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const m = await searchFile(fullPath, pattern, basePath);
|
|
130
|
+
results.push(...m);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return results;
|
|
134
|
+
}
|
|
135
|
+
function matchWildcard(name, pattern, caseSensitive) {
|
|
136
|
+
const n = caseSensitive ? name : name.toLowerCase();
|
|
137
|
+
const p = caseSensitive ? pattern : pattern.toLowerCase();
|
|
138
|
+
const regexStr = p
|
|
139
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
140
|
+
.replace(/\*/g, '.*')
|
|
141
|
+
.replace(/\?/g, '.');
|
|
142
|
+
return new RegExp(`^${regexStr}$`).test(n);
|
|
143
|
+
}
|
|
144
|
+
async function findFiles(dirPath, pattern, caseSensitive, results, maxResults, depth = 0) {
|
|
145
|
+
if (results.length >= maxResults || depth > 10)
|
|
146
|
+
return;
|
|
147
|
+
let entries;
|
|
148
|
+
try {
|
|
149
|
+
entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
for (const entry of entries) {
|
|
155
|
+
if (results.length >= maxResults)
|
|
156
|
+
break;
|
|
157
|
+
const fullPath = node_path_1.default.join(dirPath, entry.name);
|
|
158
|
+
if (entry.isDirectory()) {
|
|
159
|
+
if (!SKIP_DIRS.has(entry.name)) {
|
|
160
|
+
await findFiles(fullPath, pattern, caseSensitive, results, maxResults, depth + 1);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (matchWildcard(entry.name, pattern, caseSensitive)) {
|
|
164
|
+
results.push(fullPath);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function matchGlob(relPath, pattern) {
|
|
169
|
+
const rel = relPath.replace(/\\/g, '/');
|
|
170
|
+
const pat = pattern.replace(/\\/g, '/');
|
|
171
|
+
const regexStr = pat
|
|
172
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
173
|
+
.replace(/\*\*\//g, '§§§')
|
|
174
|
+
.replace(/\*\*/g, '§§§')
|
|
175
|
+
.replace(/\*/g, '[^/]*')
|
|
176
|
+
.replace(/\?/g, '[^/]')
|
|
177
|
+
.replace(/§§§/g, '.*');
|
|
178
|
+
return new RegExp(`^${regexStr}$`).test(rel);
|
|
179
|
+
}
|
|
180
|
+
async function globSearch(dirPath, pattern, basePath, results, maxResults, depth = 0) {
|
|
181
|
+
if (results.length >= maxResults || depth > 15)
|
|
182
|
+
return;
|
|
183
|
+
let entries;
|
|
184
|
+
try {
|
|
185
|
+
entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
for (const entry of entries) {
|
|
191
|
+
if (results.length >= maxResults)
|
|
192
|
+
break;
|
|
193
|
+
const fullPath = node_path_1.default.join(dirPath, entry.name);
|
|
194
|
+
if (entry.isDirectory()) {
|
|
195
|
+
if (!SKIP_DIRS.has(entry.name)) {
|
|
196
|
+
await globSearch(fullPath, pattern, basePath, results, maxResults, depth + 1);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const rel = node_path_1.default.relative(basePath, fullPath).replace(/\\/g, '/');
|
|
201
|
+
if (matchGlob(rel, pattern))
|
|
202
|
+
results.push(fullPath);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
207
|
+
// Tool definitions
|
|
208
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
209
|
+
const readFileTool = {
|
|
210
|
+
description: 'Reads and returns the content of a specified file. Use offset/limit to paginate large text files.',
|
|
211
|
+
parameters: {
|
|
212
|
+
type: 'object',
|
|
213
|
+
properties: {
|
|
214
|
+
file_path: { type: 'string', description: 'Path to the file to read.' },
|
|
215
|
+
offset: { type: 'integer', description: 'Optional 0-based line number to start reading from.' },
|
|
216
|
+
limit: { type: 'integer', description: 'Optional maximum number of lines to read.' },
|
|
217
|
+
},
|
|
218
|
+
required: ['file_path'],
|
|
219
|
+
},
|
|
220
|
+
execute: async (args) => {
|
|
221
|
+
const filePath = args['file_path'];
|
|
222
|
+
const offset = args['offset'];
|
|
223
|
+
const limit = args['limit'];
|
|
224
|
+
if (!filePath.trim())
|
|
225
|
+
throw new Error("The 'file_path' parameter must be non-empty.");
|
|
226
|
+
const resolvedPath = node_path_1.default.resolve(filePath);
|
|
227
|
+
const content = await promises_1.default.readFile(resolvedPath, 'utf-8');
|
|
228
|
+
if (offset !== undefined || limit !== undefined) {
|
|
229
|
+
const lines = content.split('\n');
|
|
230
|
+
const start = offset ?? 0;
|
|
231
|
+
const end = limit !== undefined ? start + limit : lines.length;
|
|
232
|
+
const slice = lines.slice(start, end);
|
|
233
|
+
const truncated = end < lines.length;
|
|
234
|
+
const text = slice.join('\n');
|
|
235
|
+
if (truncated) {
|
|
236
|
+
return `IMPORTANT: Content truncated. Showing lines ${start}-${end - 1} of ${lines.length}.\n\n${text}`;
|
|
237
|
+
}
|
|
238
|
+
return text;
|
|
239
|
+
}
|
|
240
|
+
return content;
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
const writeFileTool = {
|
|
244
|
+
description: 'Creates a new file or overwrites an existing file with the provided content.',
|
|
245
|
+
parameters: {
|
|
246
|
+
type: 'object',
|
|
247
|
+
properties: {
|
|
248
|
+
file_path: { type: 'string', description: 'Path to the file to create or overwrite.' },
|
|
249
|
+
content: { type: 'string', description: 'The content to write to the file.' },
|
|
250
|
+
},
|
|
251
|
+
required: ['file_path', 'content'],
|
|
252
|
+
},
|
|
253
|
+
execute: async (args) => {
|
|
254
|
+
const filePath = args['file_path'];
|
|
255
|
+
const content = args['content'];
|
|
256
|
+
if (!filePath.trim())
|
|
257
|
+
throw new Error("The 'file_path' parameter must be non-empty.");
|
|
258
|
+
const resolvedPath = node_path_1.default.resolve(filePath);
|
|
259
|
+
await promises_1.default.mkdir(node_path_1.default.dirname(resolvedPath), { recursive: true });
|
|
260
|
+
let fileExists = false;
|
|
261
|
+
try {
|
|
262
|
+
await promises_1.default.access(resolvedPath);
|
|
263
|
+
fileExists = true;
|
|
264
|
+
}
|
|
265
|
+
catch { /* file does not exist */ }
|
|
266
|
+
await promises_1.default.writeFile(resolvedPath, content, 'utf-8');
|
|
267
|
+
const size = Buffer.byteLength(content, 'utf-8');
|
|
268
|
+
return `${fileExists ? 'Updated' : 'Created'} file: ${filePath} (${size} bytes)`;
|
|
269
|
+
},
|
|
270
|
+
};
|
|
271
|
+
const replaceTool = {
|
|
272
|
+
description: 'Replaces a range of lines in a file with new text. Line numbers are 1-based.',
|
|
273
|
+
parameters: {
|
|
274
|
+
type: 'object',
|
|
275
|
+
properties: {
|
|
276
|
+
file_path: { type: 'string', description: 'Path to the file to modify.' },
|
|
277
|
+
start_line: { type: 'integer', description: 'Starting line number (1-based, inclusive).' },
|
|
278
|
+
end_line: { type: 'integer', description: 'Ending line number (1-based, inclusive).' },
|
|
279
|
+
new_text: { type: 'string', description: 'New text to insert in place of the specified lines.' },
|
|
280
|
+
},
|
|
281
|
+
required: ['file_path', 'start_line', 'end_line', 'new_text'],
|
|
282
|
+
},
|
|
283
|
+
execute: async (args) => {
|
|
284
|
+
const filePath = args['file_path'];
|
|
285
|
+
const startLine = args['start_line'];
|
|
286
|
+
const endLine = args['end_line'];
|
|
287
|
+
const newText = args['new_text'];
|
|
288
|
+
if (!filePath.trim())
|
|
289
|
+
throw new Error("The 'file_path' parameter must be non-empty.");
|
|
290
|
+
if (startLine > endLine) {
|
|
291
|
+
throw new Error(`start_line (${startLine}) must be <= end_line (${endLine}).`);
|
|
292
|
+
}
|
|
293
|
+
const resolvedPath = node_path_1.default.resolve(filePath);
|
|
294
|
+
const content = await promises_1.default.readFile(resolvedPath, 'utf-8');
|
|
295
|
+
const lines = content.split('\n');
|
|
296
|
+
if (startLine < 1 || startLine > lines.length) {
|
|
297
|
+
throw new Error(`start_line (${startLine}) out of range. File has ${lines.length} lines.`);
|
|
298
|
+
}
|
|
299
|
+
if (endLine > lines.length) {
|
|
300
|
+
throw new Error(`end_line (${endLine}) out of range. File has ${lines.length} lines.`);
|
|
301
|
+
}
|
|
302
|
+
const newLines = newText.split('\n');
|
|
303
|
+
lines.splice(startLine - 1, endLine - startLine + 1, ...newLines);
|
|
304
|
+
await promises_1.default.writeFile(resolvedPath, lines.join('\n'), 'utf-8');
|
|
305
|
+
return `Successfully replaced lines ${startLine}-${endLine} in ${filePath}`;
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
const lsTool = {
|
|
309
|
+
description: "Lists contents of a directory. Shows file sizes and marks directories with trailing slashes.",
|
|
310
|
+
parameters: {
|
|
311
|
+
type: 'object',
|
|
312
|
+
properties: {
|
|
313
|
+
path: { type: 'string', description: 'Directory path to list (default: current directory).' },
|
|
314
|
+
recursive: { type: 'boolean', description: 'List contents recursively (default: false).' },
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
execute: async (args) => {
|
|
318
|
+
const dirPath = args['path'] ?? '.';
|
|
319
|
+
const recursive = args['recursive'] ?? false;
|
|
320
|
+
const resolvedPath = node_path_1.default.resolve(dirPath);
|
|
321
|
+
const stats = await promises_1.default.stat(resolvedPath);
|
|
322
|
+
if (!stats.isDirectory())
|
|
323
|
+
throw new Error(`Path is not a directory: ${dirPath}`);
|
|
324
|
+
let output = `Directory listing: ${dirPath}\n\n`;
|
|
325
|
+
if (recursive) {
|
|
326
|
+
const entries = await listRecursive(resolvedPath, resolvedPath);
|
|
327
|
+
output += entries.join('\n');
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
const entries = await promises_1.default.readdir(resolvedPath, { withFileTypes: true });
|
|
331
|
+
const lines = [];
|
|
332
|
+
for (const entry of entries) {
|
|
333
|
+
if (entry.isDirectory()) {
|
|
334
|
+
lines.push(`${entry.name}/`);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
const s = await promises_1.default.stat(node_path_1.default.join(resolvedPath, entry.name));
|
|
338
|
+
lines.push(`${entry.name} (${s.size} bytes)`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
output += lines.join('\n');
|
|
342
|
+
}
|
|
343
|
+
return output || 'Directory is empty';
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
const treeTool = {
|
|
347
|
+
description: "Displays a directory tree with [DIR]/[FILE] labels up to max_depth levels.",
|
|
348
|
+
parameters: {
|
|
349
|
+
type: 'object',
|
|
350
|
+
properties: {
|
|
351
|
+
path: { type: 'string', description: 'Directory to inspect (default: current directory).' },
|
|
352
|
+
max_depth: { type: 'integer', description: 'Maximum depth to traverse (default: 3).' },
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
execute: async (args) => {
|
|
356
|
+
const targetPath = args['path'] ?? '.';
|
|
357
|
+
const maxDepth = args['max_depth'] ?? 3;
|
|
358
|
+
const resolvedPath = node_path_1.default.resolve(targetPath);
|
|
359
|
+
const stats = await promises_1.default.stat(resolvedPath);
|
|
360
|
+
if (!stats.isDirectory())
|
|
361
|
+
throw new Error(`Path is not a directory: ${targetPath}`);
|
|
362
|
+
const relRoot = node_path_1.default.relative(process.cwd(), resolvedPath);
|
|
363
|
+
const rootLabel = relRoot === '' ? '.' : relRoot;
|
|
364
|
+
const lines = [
|
|
365
|
+
`Tree for ${rootLabel} (max depth: ${maxDepth})`,
|
|
366
|
+
`[DIR] ${rootLabel}/`,
|
|
367
|
+
];
|
|
368
|
+
const treeLines = await buildTreeLines(resolvedPath, { currentDepth: 1, maxDepth });
|
|
369
|
+
lines.push(...treeLines);
|
|
370
|
+
return lines.join('\n');
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
const grepTool = {
|
|
374
|
+
description: 'Searches for a regex pattern in files. Returns matching lines with file paths and line numbers.',
|
|
375
|
+
parameters: {
|
|
376
|
+
type: 'object',
|
|
377
|
+
properties: {
|
|
378
|
+
pattern: { type: 'string', description: 'Regular expression pattern to search for.' },
|
|
379
|
+
path: { type: 'string', description: 'File or directory path to search in (default: current directory).' },
|
|
380
|
+
recursive: { type: 'boolean', description: 'Search recursively through subdirectories (default: true).' },
|
|
381
|
+
},
|
|
382
|
+
required: ['pattern'],
|
|
383
|
+
},
|
|
384
|
+
execute: async (args) => {
|
|
385
|
+
const pattern = args['pattern'];
|
|
386
|
+
const searchPath = args['path'] ?? '.';
|
|
387
|
+
const recursive = args['recursive'] ?? true;
|
|
388
|
+
if (!pattern.trim())
|
|
389
|
+
throw new Error("The 'pattern' parameter must be non-empty.");
|
|
390
|
+
let regex;
|
|
391
|
+
try {
|
|
392
|
+
regex = new RegExp(pattern);
|
|
393
|
+
}
|
|
394
|
+
catch (err) {
|
|
395
|
+
throw new Error(`Invalid regular expression: ${err.message}`);
|
|
396
|
+
}
|
|
397
|
+
const resolvedPath = node_path_1.default.resolve(searchPath);
|
|
398
|
+
const stats = await promises_1.default.stat(resolvedPath);
|
|
399
|
+
const basePath = stats.isDirectory() ? resolvedPath : node_path_1.default.dirname(resolvedPath);
|
|
400
|
+
let matches = [];
|
|
401
|
+
if (stats.isDirectory()) {
|
|
402
|
+
if (recursive) {
|
|
403
|
+
matches = await searchRecursive(resolvedPath, regex, basePath);
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
const entries = await promises_1.default.readdir(resolvedPath, { withFileTypes: true });
|
|
407
|
+
for (const entry of entries) {
|
|
408
|
+
if (!entry.isDirectory()) {
|
|
409
|
+
const m = await searchFile(node_path_1.default.join(resolvedPath, entry.name), regex, basePath);
|
|
410
|
+
matches.push(...m);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
matches = await searchFile(resolvedPath, regex, basePath);
|
|
417
|
+
}
|
|
418
|
+
if (matches.length === 0)
|
|
419
|
+
return `No matches found for pattern: ${pattern}`;
|
|
420
|
+
const maxResults = 100;
|
|
421
|
+
const limited = matches.slice(0, maxResults);
|
|
422
|
+
let output = `Found ${matches.length} match(es) for pattern: ${pattern}\n\n${limited.join('\n')}`;
|
|
423
|
+
if (matches.length > maxResults) {
|
|
424
|
+
output += `\n\n... and ${matches.length - maxResults} more (output truncated)`;
|
|
425
|
+
}
|
|
426
|
+
return output;
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
const findTool = {
|
|
430
|
+
description: 'Searches for files by filename pattern. Supports * and ? wildcards.',
|
|
431
|
+
parameters: {
|
|
432
|
+
type: 'object',
|
|
433
|
+
properties: {
|
|
434
|
+
pattern: { type: 'string', description: 'Filename pattern. Supports * and ? wildcards.' },
|
|
435
|
+
dir_path: { type: 'string', description: 'Directory to search in (default: current directory).' },
|
|
436
|
+
case_sensitive: { type: 'boolean', description: 'Case-sensitive matching (default: false).' },
|
|
437
|
+
max_results: { type: 'integer', description: 'Maximum results to return (default: 50).' },
|
|
438
|
+
},
|
|
439
|
+
required: ['pattern'],
|
|
440
|
+
},
|
|
441
|
+
execute: async (args) => {
|
|
442
|
+
const pattern = args['pattern'];
|
|
443
|
+
const dirPath = args['dir_path'] ?? '.';
|
|
444
|
+
const caseSensitive = args['case_sensitive'] ?? false;
|
|
445
|
+
const maxResults = args['max_results'] ?? 50;
|
|
446
|
+
const searchDir = node_path_1.default.resolve(dirPath);
|
|
447
|
+
const matches = [];
|
|
448
|
+
await findFiles(searchDir, pattern, caseSensitive, matches, maxResults);
|
|
449
|
+
if (matches.length === 0) {
|
|
450
|
+
return `No files found matching pattern: ${pattern}\nSearched in: ${searchDir}`;
|
|
451
|
+
}
|
|
452
|
+
const lines = matches.map((p, i) => ` ${i + 1}. ${node_path_1.default.relative(process.cwd(), p)}`);
|
|
453
|
+
const footer = matches.length >= maxResults ? `\n(Limited to ${maxResults} results)` : '';
|
|
454
|
+
return `Found ${matches.length} file(s) matching "${pattern}":\n${lines.join('\n')}${footer}`;
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
const globTool = {
|
|
458
|
+
description: 'Finds files matching glob patterns (e.g., "**/*.ts", "src/**/*.yaml"). Returns file paths.',
|
|
459
|
+
parameters: {
|
|
460
|
+
type: 'object',
|
|
461
|
+
properties: {
|
|
462
|
+
pattern: { type: 'string', description: 'Glob pattern to match files against.' },
|
|
463
|
+
dir_path: { type: 'string', description: 'Directory to search in (default: current directory).' },
|
|
464
|
+
max_results: { type: 'integer', description: 'Maximum results to return (default: 100).' },
|
|
465
|
+
},
|
|
466
|
+
required: ['pattern'],
|
|
467
|
+
},
|
|
468
|
+
execute: async (args) => {
|
|
469
|
+
const pattern = args['pattern'];
|
|
470
|
+
const dirPath = args['dir_path'] ?? '.';
|
|
471
|
+
const maxResults = args['max_results'] ?? 100;
|
|
472
|
+
const searchDir = node_path_1.default.resolve(dirPath);
|
|
473
|
+
const matches = [];
|
|
474
|
+
await globSearch(searchDir, pattern, searchDir, matches, maxResults);
|
|
475
|
+
if (matches.length === 0) {
|
|
476
|
+
return `No files found matching pattern: ${pattern}\nSearched in: ${searchDir}`;
|
|
477
|
+
}
|
|
478
|
+
const lines = matches.map((p, i) => ` ${i + 1}. ${node_path_1.default.relative(process.cwd(), p)}`);
|
|
479
|
+
const footer = matches.length >= maxResults ? `\n(Limited to ${maxResults} results)` : '';
|
|
480
|
+
return `Found ${matches.length} file(s) matching "${pattern}":\n${lines.join('\n')}${footer}`;
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
const runShellCommandTool = {
|
|
484
|
+
description: 'Executes a shell command and returns its output (stdout and stderr). Use with caution.',
|
|
485
|
+
parameters: {
|
|
486
|
+
type: 'object',
|
|
487
|
+
properties: {
|
|
488
|
+
command: { type: 'string', description: 'The shell command to execute.' },
|
|
489
|
+
timeout_seconds: { type: 'integer', description: 'Maximum execution time in seconds (default: 30).' },
|
|
490
|
+
},
|
|
491
|
+
required: ['command'],
|
|
492
|
+
},
|
|
493
|
+
execute: async (args) => {
|
|
494
|
+
const command = args['command'];
|
|
495
|
+
const timeoutSeconds = args['timeout_seconds'] ?? 30;
|
|
496
|
+
if (!command.trim())
|
|
497
|
+
throw new Error("The 'command' parameter must be non-empty.");
|
|
498
|
+
try {
|
|
499
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
500
|
+
timeout: timeoutSeconds * 1000,
|
|
501
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
502
|
+
cwd: process.cwd(),
|
|
503
|
+
});
|
|
504
|
+
let output = '';
|
|
505
|
+
if (stdout)
|
|
506
|
+
output += `STDOUT:\n${stdout}`;
|
|
507
|
+
if (stderr)
|
|
508
|
+
output += (stdout ? '\n\n' : '') + `STDERR:\n${stderr}`;
|
|
509
|
+
return output || 'Command executed successfully (no output)';
|
|
510
|
+
}
|
|
511
|
+
catch (err) {
|
|
512
|
+
const error = err;
|
|
513
|
+
if (error.killed && error.signal === 'SIGTERM') {
|
|
514
|
+
throw new Error(`Command timed out after ${timeoutSeconds} seconds`);
|
|
515
|
+
}
|
|
516
|
+
let msg = `Command failed: ${command}`;
|
|
517
|
+
if (error.stdout)
|
|
518
|
+
msg += `\nSTDOUT:\n${error.stdout}`;
|
|
519
|
+
if (error.stderr)
|
|
520
|
+
msg += `\nSTDERR:\n${error.stderr}`;
|
|
521
|
+
if (error.code !== undefined)
|
|
522
|
+
msg += `\nExit code: ${error.code}`;
|
|
523
|
+
throw new Error(msg);
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
};
|
|
527
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
528
|
+
// Registry
|
|
529
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
530
|
+
/**
|
|
531
|
+
* All available built-in tools, keyed by tool name.
|
|
532
|
+
*
|
|
533
|
+
* Listed tools are registered via crewx.registerTool() when their name appears
|
|
534
|
+
* in crewx.yaml `tools.builtin` for an agent using an api/* provider.
|
|
535
|
+
*/
|
|
536
|
+
exports.BUILTIN_TOOL_REGISTRY = {
|
|
537
|
+
read_file: readFileTool,
|
|
538
|
+
write_file: writeFileTool,
|
|
539
|
+
replace: replaceTool,
|
|
540
|
+
ls: lsTool,
|
|
541
|
+
tree: treeTool,
|
|
542
|
+
grep: grepTool,
|
|
543
|
+
find: findTool,
|
|
544
|
+
glob: globTool,
|
|
545
|
+
run_shell_command: runShellCommandTool,
|
|
546
|
+
};
|
|
547
|
+
//# sourceMappingURL=builtin.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @crewx/sdk/tools/node — Node.js built-in tools.
|
|
3
|
+
*
|
|
4
|
+
* Provides file system, shell, and search tools for api/* providers.
|
|
5
|
+
* Import this only in Node.js environments (CLI, Express server).
|
|
6
|
+
* Do NOT import in browser builds.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* import { registerBuiltinTools } from '@crewx/sdk/tools/node';
|
|
10
|
+
* const crewx = await Crewx.loadYaml('./crewx.yaml');
|
|
11
|
+
* registerBuiltinTools(crewx);
|
|
12
|
+
*/
|
|
13
|
+
import type { Crewx } from '../../facade/Crewx';
|
|
14
|
+
/**
|
|
15
|
+
* Register built-in Node.js tools based on agent configs in crewx.yaml.
|
|
16
|
+
*
|
|
17
|
+
* Scans all agents using api/* providers, collects tool names from
|
|
18
|
+
* options.query.tools and options.execute.tools, then registers
|
|
19
|
+
* only the matching built-in tools via crewx.registerTool().
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerBuiltinTools(crewx: Crewx): void;
|
|
22
|
+
export { BUILTIN_TOOL_REGISTRY } from './builtin';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @crewx/sdk/tools/node — Node.js built-in tools.
|
|
4
|
+
*
|
|
5
|
+
* Provides file system, shell, and search tools for api/* providers.
|
|
6
|
+
* Import this only in Node.js environments (CLI, Express server).
|
|
7
|
+
* Do NOT import in browser builds.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* import { registerBuiltinTools } from '@crewx/sdk/tools/node';
|
|
11
|
+
* const crewx = await Crewx.loadYaml('./crewx.yaml');
|
|
12
|
+
* registerBuiltinTools(crewx);
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BUILTIN_TOOL_REGISTRY = void 0;
|
|
16
|
+
exports.registerBuiltinTools = registerBuiltinTools;
|
|
17
|
+
const builtin_1 = require("./builtin");
|
|
18
|
+
/**
|
|
19
|
+
* Register built-in Node.js tools based on agent configs in crewx.yaml.
|
|
20
|
+
*
|
|
21
|
+
* Scans all agents using api/* providers, collects tool names from
|
|
22
|
+
* options.query.tools and options.execute.tools, then registers
|
|
23
|
+
* only the matching built-in tools via crewx.registerTool().
|
|
24
|
+
*/
|
|
25
|
+
function registerBuiltinTools(crewx) {
|
|
26
|
+
const config = crewx.config;
|
|
27
|
+
if (!config)
|
|
28
|
+
return;
|
|
29
|
+
const agents = config.agents ?? [];
|
|
30
|
+
// Collect all tool names referenced by api/* agents
|
|
31
|
+
const neededTools = new Set();
|
|
32
|
+
for (const agent of agents) {
|
|
33
|
+
const providers = Array.isArray(agent.provider)
|
|
34
|
+
? agent.provider
|
|
35
|
+
: [agent.provider];
|
|
36
|
+
const isApiProvider = providers.some((p) => typeof p === 'string' && p.startsWith('api/'));
|
|
37
|
+
if (!isApiProvider)
|
|
38
|
+
continue;
|
|
39
|
+
const opts = agent.options;
|
|
40
|
+
if (Array.isArray(opts?.query?.tools)) {
|
|
41
|
+
for (const name of opts.query.tools)
|
|
42
|
+
neededTools.add(name);
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(opts?.execute?.tools)) {
|
|
45
|
+
for (const name of opts.execute.tools)
|
|
46
|
+
neededTools.add(name);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Register only the needed built-in tools
|
|
50
|
+
for (const name of neededTools) {
|
|
51
|
+
const toolDef = builtin_1.BUILTIN_TOOL_REGISTRY[name];
|
|
52
|
+
if (toolDef) {
|
|
53
|
+
crewx.registerTool(name, toolDef);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
var builtin_2 = require("./builtin");
|
|
58
|
+
Object.defineProperty(exports, "BUILTIN_TOOL_REGISTRY", { enumerable: true, get: function () { return builtin_2.BUILTIN_TOOL_REGISTRY; } });
|
|
59
|
+
//# sourceMappingURL=index.js.map
|