@crewx/sdk 0.8.0-rc.73 → 0.8.0-rc.75
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 +68 -103
- 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,10 @@
|
|
|
1
|
+
import { ToolObserverPlugin, type ObserverSubscription } from './observer';
|
|
2
|
+
import type { ObserverContext, ObserverResult } from './types';
|
|
3
|
+
export interface PluginDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
on: ObserverSubscription;
|
|
7
|
+
run(ctx: ObserverContext): Promise<ObserverResult>;
|
|
8
|
+
}
|
|
9
|
+
export declare function definePlugin(def: PluginDefinition): ToolObserverPlugin;
|
|
10
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.definePlugin = definePlugin;
|
|
4
|
+
const observer_1 = require("./observer");
|
|
5
|
+
function definePlugin(def) {
|
|
6
|
+
return new (class extends observer_1.ToolObserverPlugin {
|
|
7
|
+
name = def.name;
|
|
8
|
+
version = def.version;
|
|
9
|
+
on = def.on;
|
|
10
|
+
run = def.run;
|
|
11
|
+
})();
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=define.js.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security notes:
|
|
3
|
+
*
|
|
4
|
+
* (M1) Codex `systemMessage` is merged into the agent's system prompt directly.
|
|
5
|
+
* Guide messages MUST NOT contain dynamic external input (tool_input,
|
|
6
|
+
* external API results, etc.) to prevent prompt injection via hook inject.
|
|
7
|
+
*
|
|
8
|
+
* Provider matching: When `provider` is not specified in a hook definition,
|
|
9
|
+
* it applies to ALL providers (§4.1.1 2-Layer Selector design).
|
|
10
|
+
* This is intentional — allows catch-all safety rules.
|
|
11
|
+
*/
|
|
12
|
+
import type { HookContext } from '../hooks/types';
|
|
13
|
+
import type { HookPlugin } from '../hooks/plugin';
|
|
14
|
+
export interface ClaudeHookInput {
|
|
15
|
+
session_id: string;
|
|
16
|
+
transcript_path: string;
|
|
17
|
+
cwd: string;
|
|
18
|
+
hook_event_name: string;
|
|
19
|
+
tool_name: string;
|
|
20
|
+
tool_input: Record<string, unknown>;
|
|
21
|
+
tool_use_id: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ClaudeHookOutput {
|
|
24
|
+
hookSpecificOutput: {
|
|
25
|
+
hookEventName: string;
|
|
26
|
+
permissionDecision: 'allow' | 'deny' | 'ask';
|
|
27
|
+
permissionDecisionReason?: string;
|
|
28
|
+
additionalContext?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export interface CodexHookOutput {
|
|
32
|
+
hookSpecificOutput: {
|
|
33
|
+
hookEventName: string;
|
|
34
|
+
permissionDecision: 'allow' | 'deny' | 'ask';
|
|
35
|
+
permissionDecisionReason?: string;
|
|
36
|
+
systemMessage?: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface ProviderHookOutput {
|
|
40
|
+
hookSpecificOutput: {
|
|
41
|
+
hookEventName: string;
|
|
42
|
+
permissionDecision: 'allow' | 'deny' | 'ask';
|
|
43
|
+
permissionDecisionReason?: string;
|
|
44
|
+
additionalContext?: string;
|
|
45
|
+
systemMessage?: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export type Provider = 'claude' | 'codex';
|
|
49
|
+
export interface HookDispatchResult {
|
|
50
|
+
exitCode: number;
|
|
51
|
+
stdout: ProviderHookOutput;
|
|
52
|
+
injected: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare function sanitizeDenyReason(reason: string): string;
|
|
55
|
+
export declare function sanitizeInjectMessage(message: string): string;
|
|
56
|
+
export declare function isPathSafe(pluginPath: string, projectRoot: string): boolean;
|
|
57
|
+
export declare function formatInjectOutput(provider: Provider, hookEventName: string, message: string): ProviderHookOutput;
|
|
58
|
+
export declare function formatDenyOutput(_provider: Provider, hookEventName: string, reason: string): ProviderHookOutput;
|
|
59
|
+
export declare function buildHookContext(input: ClaudeHookInput, cwd: string, provider?: string): HookContext;
|
|
60
|
+
export declare function evaluateHook(plugin: HookPlugin, input: ClaudeHookInput, cwd: string, provider?: string): Promise<HookDispatchResult>;
|
|
61
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Security notes:
|
|
4
|
+
*
|
|
5
|
+
* (M1) Codex `systemMessage` is merged into the agent's system prompt directly.
|
|
6
|
+
* Guide messages MUST NOT contain dynamic external input (tool_input,
|
|
7
|
+
* external API results, etc.) to prevent prompt injection via hook inject.
|
|
8
|
+
*
|
|
9
|
+
* Provider matching: When `provider` is not specified in a hook definition,
|
|
10
|
+
* it applies to ALL providers (§4.1.1 2-Layer Selector design).
|
|
11
|
+
* This is intentional — allows catch-all safety rules.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.sanitizeDenyReason = sanitizeDenyReason;
|
|
15
|
+
exports.sanitizeInjectMessage = sanitizeInjectMessage;
|
|
16
|
+
exports.isPathSafe = isPathSafe;
|
|
17
|
+
exports.formatInjectOutput = formatInjectOutput;
|
|
18
|
+
exports.formatDenyOutput = formatDenyOutput;
|
|
19
|
+
exports.buildHookContext = buildHookContext;
|
|
20
|
+
exports.evaluateHook = evaluateHook;
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
const tool_normalize_1 = require("./tool-normalize");
|
|
23
|
+
const MAX_REASON_LENGTH = 200;
|
|
24
|
+
const MAX_INJECT_LENGTH = 2000;
|
|
25
|
+
function sanitizeDenyReason(reason) {
|
|
26
|
+
const cleaned = reason.replace(/[\x00-\x1f\x7f\u2028\u2029]/g, '');
|
|
27
|
+
if (cleaned.length <= MAX_REASON_LENGTH) {
|
|
28
|
+
return cleaned;
|
|
29
|
+
}
|
|
30
|
+
return cleaned.slice(0, MAX_REASON_LENGTH - 11) + ' [redacted]';
|
|
31
|
+
}
|
|
32
|
+
function sanitizeInjectMessage(message) {
|
|
33
|
+
const cleaned = message.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\u2028\u2029]/g, '');
|
|
34
|
+
if (cleaned.length <= MAX_INJECT_LENGTH) {
|
|
35
|
+
return cleaned;
|
|
36
|
+
}
|
|
37
|
+
return cleaned.slice(0, MAX_INJECT_LENGTH - 11) + ' [redacted]';
|
|
38
|
+
}
|
|
39
|
+
function isPathSafe(pluginPath, projectRoot) {
|
|
40
|
+
const resolved = (0, path_1.resolve)(pluginPath);
|
|
41
|
+
const root = (0, path_1.resolve)(projectRoot);
|
|
42
|
+
const rel = (0, path_1.relative)(root, resolved);
|
|
43
|
+
if (rel.startsWith('..') || (0, path_1.resolve)(resolved).startsWith('/etc/') || (0, path_1.resolve)(resolved).startsWith('/usr/')) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (resolved.includes('node_modules')) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
function toProvider(provider) {
|
|
52
|
+
if (provider === 'codex')
|
|
53
|
+
return 'codex';
|
|
54
|
+
return 'claude';
|
|
55
|
+
}
|
|
56
|
+
function formatInjectOutput(provider, hookEventName, message) {
|
|
57
|
+
switch (provider) {
|
|
58
|
+
case 'codex':
|
|
59
|
+
return {
|
|
60
|
+
hookSpecificOutput: {
|
|
61
|
+
hookEventName,
|
|
62
|
+
permissionDecision: 'allow',
|
|
63
|
+
systemMessage: message,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
default:
|
|
67
|
+
return {
|
|
68
|
+
hookSpecificOutput: {
|
|
69
|
+
hookEventName,
|
|
70
|
+
permissionDecision: 'allow',
|
|
71
|
+
additionalContext: message,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function formatDenyOutput(_provider, hookEventName, reason) {
|
|
77
|
+
return {
|
|
78
|
+
hookSpecificOutput: {
|
|
79
|
+
hookEventName,
|
|
80
|
+
permissionDecision: 'deny',
|
|
81
|
+
permissionDecisionReason: reason,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function buildHookContext(input, cwd, provider = 'cli/claude') {
|
|
86
|
+
const resolvedProvider = provider || process.env.CREWX_PROVIDER || 'cli/claude';
|
|
87
|
+
return {
|
|
88
|
+
event: 'beforeTool',
|
|
89
|
+
traceId: input.tool_use_id || '',
|
|
90
|
+
agent: {
|
|
91
|
+
id: process.env.CREWX_AGENT_ID || '',
|
|
92
|
+
role: process.env.CREWX_AGENT_ROLE || '',
|
|
93
|
+
team: process.env.CREWX_AGENT_TEAM || '',
|
|
94
|
+
},
|
|
95
|
+
provider: resolvedProvider,
|
|
96
|
+
thread: { id: process.env.CREWX_THREAD_ID || '' },
|
|
97
|
+
tool: {
|
|
98
|
+
name: (0, tool_normalize_1.normalizeToolName)(input.tool_name, resolvedProvider),
|
|
99
|
+
rawName: input.tool_name,
|
|
100
|
+
input: input.tool_input,
|
|
101
|
+
},
|
|
102
|
+
cwd: cwd || input.cwd,
|
|
103
|
+
sessionId: input.session_id || process.env.CREWX_SESSION_ID || '',
|
|
104
|
+
pass: () => ({ type: 'pass' }),
|
|
105
|
+
deny: (r) => ({ type: 'deny', reason: r }),
|
|
106
|
+
inject: (m) => ({ type: 'inject', message: m }),
|
|
107
|
+
modify: (p) => ({ type: 'modify', patch: p }),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
async function evaluateHook(plugin, input, cwd, provider = 'cli/claude') {
|
|
111
|
+
const ctx = buildHookContext(input, cwd, provider);
|
|
112
|
+
const result = await plugin.run(ctx);
|
|
113
|
+
const simpleProvider = toProvider(provider);
|
|
114
|
+
const baseOutput = {
|
|
115
|
+
hookSpecificOutput: {
|
|
116
|
+
hookEventName: input.hook_event_name,
|
|
117
|
+
permissionDecision: 'allow',
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
switch (result.type) {
|
|
121
|
+
case 'pass':
|
|
122
|
+
return { exitCode: 0, stdout: baseOutput, injected: false };
|
|
123
|
+
case 'deny': {
|
|
124
|
+
const sanitizedReason = sanitizeDenyReason(result.reason);
|
|
125
|
+
return {
|
|
126
|
+
exitCode: 2,
|
|
127
|
+
stdout: formatDenyOutput(simpleProvider, input.hook_event_name, sanitizedReason),
|
|
128
|
+
injected: false,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
case 'inject': {
|
|
132
|
+
const sanitizedMessage = sanitizeInjectMessage(result.message);
|
|
133
|
+
return {
|
|
134
|
+
exitCode: 0,
|
|
135
|
+
stdout: formatInjectOutput(simpleProvider, input.hook_event_name, sanitizedMessage),
|
|
136
|
+
injected: true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
case 'modify':
|
|
140
|
+
console.error(`[crewx] Hook result type '${result.type}' is not supported in Phase 0. ` +
|
|
141
|
+
`Plugin: ${plugin.name}. Treating as pass.`);
|
|
142
|
+
return { exitCode: 0, stdout: baseOutput, injected: false };
|
|
143
|
+
default:
|
|
144
|
+
return { exitCode: 0, stdout: baseOutput, injected: false };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { ToolObserverPlugin } from './observer';
|
|
2
|
+
export type { ObserverSubscription } from './observer';
|
|
3
|
+
export { HookPlugin, defineHookPlugin } from './plugin';
|
|
4
|
+
export type { HookPluginDefinition } from './plugin';
|
|
5
|
+
export { definePlugin } from './define';
|
|
6
|
+
export type { PluginDefinition } from './define';
|
|
7
|
+
export { YamlHookPlugin, validateHooksSchema } from './yaml-plugin';
|
|
8
|
+
export type { YamlHookConfig } from './yaml-plugin';
|
|
9
|
+
export { Tools } from './types';
|
|
10
|
+
export type { ObserverContext, ObserverResult, ObserverEvent, HookContext, HookResult, HookEvent, ToolName, ToolInputPatch, Capability, } from './types';
|
|
11
|
+
export { evaluateHook, sanitizeDenyReason, sanitizeInjectMessage, isPathSafe, buildHookContext, formatInjectOutput, formatDenyOutput, } from './dispatch';
|
|
12
|
+
export type { ClaudeHookInput, ClaudeHookOutput, CodexHookOutput, ProviderHookOutput, Provider, HookDispatchResult, } from './dispatch';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatDenyOutput = exports.formatInjectOutput = exports.buildHookContext = exports.isPathSafe = exports.sanitizeInjectMessage = exports.sanitizeDenyReason = exports.evaluateHook = exports.Tools = exports.validateHooksSchema = exports.YamlHookPlugin = exports.definePlugin = exports.defineHookPlugin = exports.HookPlugin = exports.ToolObserverPlugin = void 0;
|
|
4
|
+
var observer_1 = require("./observer");
|
|
5
|
+
Object.defineProperty(exports, "ToolObserverPlugin", { enumerable: true, get: function () { return observer_1.ToolObserverPlugin; } });
|
|
6
|
+
var plugin_1 = require("./plugin");
|
|
7
|
+
Object.defineProperty(exports, "HookPlugin", { enumerable: true, get: function () { return plugin_1.HookPlugin; } });
|
|
8
|
+
Object.defineProperty(exports, "defineHookPlugin", { enumerable: true, get: function () { return plugin_1.defineHookPlugin; } });
|
|
9
|
+
var define_1 = require("./define");
|
|
10
|
+
Object.defineProperty(exports, "definePlugin", { enumerable: true, get: function () { return define_1.definePlugin; } });
|
|
11
|
+
var yaml_plugin_1 = require("./yaml-plugin");
|
|
12
|
+
Object.defineProperty(exports, "YamlHookPlugin", { enumerable: true, get: function () { return yaml_plugin_1.YamlHookPlugin; } });
|
|
13
|
+
Object.defineProperty(exports, "validateHooksSchema", { enumerable: true, get: function () { return yaml_plugin_1.validateHooksSchema; } });
|
|
14
|
+
var types_1 = require("./types");
|
|
15
|
+
Object.defineProperty(exports, "Tools", { enumerable: true, get: function () { return types_1.Tools; } });
|
|
16
|
+
var dispatch_1 = require("./dispatch");
|
|
17
|
+
Object.defineProperty(exports, "evaluateHook", { enumerable: true, get: function () { return dispatch_1.evaluateHook; } });
|
|
18
|
+
Object.defineProperty(exports, "sanitizeDenyReason", { enumerable: true, get: function () { return dispatch_1.sanitizeDenyReason; } });
|
|
19
|
+
Object.defineProperty(exports, "sanitizeInjectMessage", { enumerable: true, get: function () { return dispatch_1.sanitizeInjectMessage; } });
|
|
20
|
+
Object.defineProperty(exports, "isPathSafe", { enumerable: true, get: function () { return dispatch_1.isPathSafe; } });
|
|
21
|
+
Object.defineProperty(exports, "buildHookContext", { enumerable: true, get: function () { return dispatch_1.buildHookContext; } });
|
|
22
|
+
Object.defineProperty(exports, "formatInjectOutput", { enumerable: true, get: function () { return dispatch_1.formatInjectOutput; } });
|
|
23
|
+
Object.defineProperty(exports, "formatDenyOutput", { enumerable: true, get: function () { return dispatch_1.formatDenyOutput; } });
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CrewxPlugin } from '../plugin';
|
|
2
|
+
import type { Crewx } from '../facade/Crewx';
|
|
3
|
+
import type { ObserverContext, ObserverResult, ToolName } from './types';
|
|
4
|
+
export interface ObserverSubscription {
|
|
5
|
+
beforeTool?: ToolName[] | true;
|
|
6
|
+
afterTool?: ToolName[] | true;
|
|
7
|
+
beforePrompt?: true;
|
|
8
|
+
sessionStart?: true;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class ToolObserverPlugin extends CrewxPlugin {
|
|
11
|
+
abstract readonly version: string;
|
|
12
|
+
abstract readonly on: ObserverSubscription;
|
|
13
|
+
private unsubs;
|
|
14
|
+
abstract run(ctx: ObserverContext): Promise<ObserverResult>;
|
|
15
|
+
attach(crewx: Crewx): void;
|
|
16
|
+
detach(_crewx: Crewx): Promise<void>;
|
|
17
|
+
private matchesTool;
|
|
18
|
+
private buildContext;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=observer.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolObserverPlugin = void 0;
|
|
4
|
+
const plugin_1 = require("../plugin");
|
|
5
|
+
class ToolObserverPlugin extends plugin_1.CrewxPlugin {
|
|
6
|
+
unsubs = [];
|
|
7
|
+
attach(crewx) {
|
|
8
|
+
if (this.on.beforeTool) {
|
|
9
|
+
const unsub = crewx.on('tool:observed:before', async (e) => {
|
|
10
|
+
if (!this.matchesTool(this.on.beforeTool, e.tool.name))
|
|
11
|
+
return;
|
|
12
|
+
const ctx = this.buildContext('beforeTool', e);
|
|
13
|
+
await this.run(ctx);
|
|
14
|
+
});
|
|
15
|
+
this.unsubs.push(unsub);
|
|
16
|
+
}
|
|
17
|
+
if (this.on.afterTool) {
|
|
18
|
+
const unsub = crewx.on('tool:observed:after', async (e) => {
|
|
19
|
+
if (!this.matchesTool(this.on.afterTool, e.tool.name))
|
|
20
|
+
return;
|
|
21
|
+
const ctx = this.buildContext('afterTool', e);
|
|
22
|
+
await this.run(ctx);
|
|
23
|
+
});
|
|
24
|
+
this.unsubs.push(unsub);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async detach(_crewx) {
|
|
28
|
+
for (const unsub of this.unsubs)
|
|
29
|
+
unsub();
|
|
30
|
+
this.unsubs = [];
|
|
31
|
+
}
|
|
32
|
+
matchesTool(filter, toolName) {
|
|
33
|
+
if (filter === true)
|
|
34
|
+
return true;
|
|
35
|
+
return filter.includes(toolName);
|
|
36
|
+
}
|
|
37
|
+
buildContext(event, e) {
|
|
38
|
+
return {
|
|
39
|
+
event,
|
|
40
|
+
traceId: e.traceId,
|
|
41
|
+
agent: {
|
|
42
|
+
id: e.agentId || e.agentRef,
|
|
43
|
+
role: '',
|
|
44
|
+
team: '',
|
|
45
|
+
},
|
|
46
|
+
provider: e.provider,
|
|
47
|
+
thread: { id: e.threadId || '' },
|
|
48
|
+
tool: {
|
|
49
|
+
name: e.tool.name,
|
|
50
|
+
rawName: e.tool.rawName,
|
|
51
|
+
input: 'input' in e.tool ? e.tool.input : undefined,
|
|
52
|
+
},
|
|
53
|
+
cwd: process.cwd(),
|
|
54
|
+
sessionId: e.sessionId || '',
|
|
55
|
+
pass: () => ({ type: 'pass' }),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.ToolObserverPlugin = ToolObserverPlugin;
|
|
60
|
+
//# sourceMappingURL=observer.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HookContext, HookResult, Capability } from './types';
|
|
2
|
+
export declare abstract class HookPlugin {
|
|
3
|
+
abstract readonly name: string;
|
|
4
|
+
abstract readonly version: string;
|
|
5
|
+
abstract run(ctx: HookContext): Promise<HookResult>;
|
|
6
|
+
readonly capabilities: {
|
|
7
|
+
required: readonly Capability[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface HookPluginDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
capabilities?: {
|
|
14
|
+
required: Capability[];
|
|
15
|
+
};
|
|
16
|
+
run(ctx: HookContext): Promise<HookResult>;
|
|
17
|
+
}
|
|
18
|
+
export declare function defineHookPlugin(def: HookPluginDefinition): HookPlugin;
|
|
19
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HookPlugin = void 0;
|
|
4
|
+
exports.defineHookPlugin = defineHookPlugin;
|
|
5
|
+
class HookPlugin {
|
|
6
|
+
capabilities = { required: [] };
|
|
7
|
+
}
|
|
8
|
+
exports.HookPlugin = HookPlugin;
|
|
9
|
+
function defineHookPlugin(def) {
|
|
10
|
+
return new (class extends HookPlugin {
|
|
11
|
+
name = def.name;
|
|
12
|
+
version = def.version;
|
|
13
|
+
capabilities = def.capabilities ?? { required: [] };
|
|
14
|
+
run = def.run;
|
|
15
|
+
})();
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool name normalization — 5-provider raw tool names → Tools.* enum.
|
|
3
|
+
*
|
|
4
|
+
* Design: docs/hook-설계서.md §8.1 Tools.* 정규화 enum.
|
|
5
|
+
*
|
|
6
|
+
* Raw tool names come from each provider's PreToolUse stdin payload:
|
|
7
|
+
* - Claude: "Read" / "Write" / "Edit" / "Bash" / "Grep" / "Glob" / ...
|
|
8
|
+
* - Codex: everything routed through "Bash" (shell command) — parsing optional
|
|
9
|
+
* - Gemini: "read_file" / "write_file" / "replace" / "run_shell_command" / ...
|
|
10
|
+
* - Copilot: "read" / "write" / "shell" / ...
|
|
11
|
+
* - OpenCode: "file.read" / "file.write" / "file.edit" / "bash" / ...
|
|
12
|
+
*
|
|
13
|
+
* Unknown tools fall through to Tools.Other (still usable via `rawName` in rules).
|
|
14
|
+
*/
|
|
15
|
+
import { type ToolName } from './types';
|
|
16
|
+
export type ProviderKey = 'claude' | 'codex' | 'gemini' | 'copilot' | 'opencode';
|
|
17
|
+
/**
|
|
18
|
+
* Normalize a provider's raw tool name to the Tools.* enum.
|
|
19
|
+
*
|
|
20
|
+
* Matching priority:
|
|
21
|
+
* 1. Exact key lookup in the provider's table.
|
|
22
|
+
* 2. Fallback: if rawName already looks like a Tools.* value (contains a dot), accept it.
|
|
23
|
+
* 3. Otherwise → Tools.Other.
|
|
24
|
+
*
|
|
25
|
+
* @param rawName provider-specific tool name (e.g. "Read", "read_file")
|
|
26
|
+
* @param provider provider key; accepts 'cli/claude' style prefix too.
|
|
27
|
+
*/
|
|
28
|
+
export declare function normalizeToolName(rawName: string, provider: string): ToolName;
|
|
29
|
+
//# sourceMappingURL=tool-normalize.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool name normalization — 5-provider raw tool names → Tools.* enum.
|
|
4
|
+
*
|
|
5
|
+
* Design: docs/hook-설계서.md §8.1 Tools.* 정규화 enum.
|
|
6
|
+
*
|
|
7
|
+
* Raw tool names come from each provider's PreToolUse stdin payload:
|
|
8
|
+
* - Claude: "Read" / "Write" / "Edit" / "Bash" / "Grep" / "Glob" / ...
|
|
9
|
+
* - Codex: everything routed through "Bash" (shell command) — parsing optional
|
|
10
|
+
* - Gemini: "read_file" / "write_file" / "replace" / "run_shell_command" / ...
|
|
11
|
+
* - Copilot: "read" / "write" / "shell" / ...
|
|
12
|
+
* - OpenCode: "file.read" / "file.write" / "file.edit" / "bash" / ...
|
|
13
|
+
*
|
|
14
|
+
* Unknown tools fall through to Tools.Other (still usable via `rawName` in rules).
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.normalizeToolName = normalizeToolName;
|
|
18
|
+
const types_1 = require("./types");
|
|
19
|
+
const CLAUDE = {
|
|
20
|
+
Read: types_1.Tools.FileRead,
|
|
21
|
+
Write: types_1.Tools.FileWrite,
|
|
22
|
+
Edit: types_1.Tools.FileEdit,
|
|
23
|
+
MultiEdit: types_1.Tools.FileEdit,
|
|
24
|
+
NotebookEdit: types_1.Tools.FileEdit,
|
|
25
|
+
Bash: types_1.Tools.Shell,
|
|
26
|
+
Grep: types_1.Tools.Search,
|
|
27
|
+
Glob: types_1.Tools.Search,
|
|
28
|
+
};
|
|
29
|
+
const GEMINI = {
|
|
30
|
+
read_file: types_1.Tools.FileRead,
|
|
31
|
+
write_file: types_1.Tools.FileWrite,
|
|
32
|
+
replace: types_1.Tools.FileEdit,
|
|
33
|
+
edit: types_1.Tools.FileEdit,
|
|
34
|
+
run_shell_command: types_1.Tools.Shell,
|
|
35
|
+
search_file_content: types_1.Tools.Search,
|
|
36
|
+
glob: types_1.Tools.Search,
|
|
37
|
+
};
|
|
38
|
+
const COPILOT = {
|
|
39
|
+
read: types_1.Tools.FileRead,
|
|
40
|
+
write: types_1.Tools.FileWrite,
|
|
41
|
+
edit: types_1.Tools.FileEdit,
|
|
42
|
+
shell: types_1.Tools.Shell,
|
|
43
|
+
bash: types_1.Tools.Shell,
|
|
44
|
+
search: types_1.Tools.Search,
|
|
45
|
+
grep: types_1.Tools.Search,
|
|
46
|
+
};
|
|
47
|
+
const OPENCODE = {
|
|
48
|
+
'file.read': types_1.Tools.FileRead,
|
|
49
|
+
'file.write': types_1.Tools.FileWrite,
|
|
50
|
+
'file.edit': types_1.Tools.FileEdit,
|
|
51
|
+
read: types_1.Tools.FileRead,
|
|
52
|
+
write: types_1.Tools.FileWrite,
|
|
53
|
+
edit: types_1.Tools.FileEdit,
|
|
54
|
+
bash: types_1.Tools.Shell,
|
|
55
|
+
shell: types_1.Tools.Shell,
|
|
56
|
+
grep: types_1.Tools.Search,
|
|
57
|
+
glob: types_1.Tools.Search,
|
|
58
|
+
};
|
|
59
|
+
// Codex routes file ops through Bash — no direct file tools to map.
|
|
60
|
+
// Users can still match on Tools.Shell or use `pattern`/`regex` against ctx.tool.input.command.
|
|
61
|
+
const CODEX = {
|
|
62
|
+
Bash: types_1.Tools.Shell,
|
|
63
|
+
bash: types_1.Tools.Shell,
|
|
64
|
+
};
|
|
65
|
+
const TABLES = {
|
|
66
|
+
claude: CLAUDE,
|
|
67
|
+
codex: CODEX,
|
|
68
|
+
gemini: GEMINI,
|
|
69
|
+
copilot: COPILOT,
|
|
70
|
+
opencode: OPENCODE,
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Normalize a provider's raw tool name to the Tools.* enum.
|
|
74
|
+
*
|
|
75
|
+
* Matching priority:
|
|
76
|
+
* 1. Exact key lookup in the provider's table.
|
|
77
|
+
* 2. Fallback: if rawName already looks like a Tools.* value (contains a dot), accept it.
|
|
78
|
+
* 3. Otherwise → Tools.Other.
|
|
79
|
+
*
|
|
80
|
+
* @param rawName provider-specific tool name (e.g. "Read", "read_file")
|
|
81
|
+
* @param provider provider key; accepts 'cli/claude' style prefix too.
|
|
82
|
+
*/
|
|
83
|
+
function normalizeToolName(rawName, provider) {
|
|
84
|
+
const key = resolveProviderKey(provider);
|
|
85
|
+
if (key) {
|
|
86
|
+
const mapped = TABLES[key][rawName];
|
|
87
|
+
if (mapped)
|
|
88
|
+
return mapped;
|
|
89
|
+
}
|
|
90
|
+
// Already-normalized form passes through (e.g. OpenCode "file.read").
|
|
91
|
+
if (Object.values(types_1.Tools).includes(rawName)) {
|
|
92
|
+
return rawName;
|
|
93
|
+
}
|
|
94
|
+
return types_1.Tools.Other;
|
|
95
|
+
}
|
|
96
|
+
function resolveProviderKey(provider) {
|
|
97
|
+
const lower = provider.toLowerCase();
|
|
98
|
+
if (lower.includes('claude'))
|
|
99
|
+
return 'claude';
|
|
100
|
+
if (lower.includes('codex'))
|
|
101
|
+
return 'codex';
|
|
102
|
+
if (lower.includes('gemini'))
|
|
103
|
+
return 'gemini';
|
|
104
|
+
if (lower.includes('copilot'))
|
|
105
|
+
return 'copilot';
|
|
106
|
+
if (lower.includes('opencode'))
|
|
107
|
+
return 'opencode';
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=tool-normalize.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare const Tools: {
|
|
2
|
+
readonly FileRead: "file.read";
|
|
3
|
+
readonly FileWrite: "file.write";
|
|
4
|
+
readonly FileEdit: "file.edit";
|
|
5
|
+
readonly Shell: "shell";
|
|
6
|
+
readonly Search: "search";
|
|
7
|
+
readonly Other: "other";
|
|
8
|
+
};
|
|
9
|
+
export type ToolName = typeof Tools[keyof typeof Tools];
|
|
10
|
+
export type ObserverEvent = 'beforeTool' | 'afterTool' | 'beforePrompt' | 'sessionStart';
|
|
11
|
+
export interface ObserverContext {
|
|
12
|
+
event: ObserverEvent;
|
|
13
|
+
traceId: string;
|
|
14
|
+
agent: {
|
|
15
|
+
id: string;
|
|
16
|
+
role: string;
|
|
17
|
+
team: string;
|
|
18
|
+
};
|
|
19
|
+
provider: string;
|
|
20
|
+
thread: {
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
tool: {
|
|
24
|
+
name: ToolName | string;
|
|
25
|
+
rawName: string;
|
|
26
|
+
input: unknown;
|
|
27
|
+
};
|
|
28
|
+
cwd: string;
|
|
29
|
+
sessionId: string;
|
|
30
|
+
config?: Record<string, unknown>;
|
|
31
|
+
pass(): ObserverResult;
|
|
32
|
+
}
|
|
33
|
+
export type ObserverResult = {
|
|
34
|
+
type: 'pass';
|
|
35
|
+
};
|
|
36
|
+
export type HookEvent = 'beforeTool' | 'afterTool' | 'beforePrompt' | 'sessionStart';
|
|
37
|
+
export interface HookContext {
|
|
38
|
+
event: HookEvent;
|
|
39
|
+
traceId: string;
|
|
40
|
+
agent: {
|
|
41
|
+
id: string;
|
|
42
|
+
role: string;
|
|
43
|
+
team: string;
|
|
44
|
+
};
|
|
45
|
+
provider: string;
|
|
46
|
+
thread: {
|
|
47
|
+
id: string;
|
|
48
|
+
};
|
|
49
|
+
tool: {
|
|
50
|
+
name: ToolName | string;
|
|
51
|
+
rawName: string;
|
|
52
|
+
input: unknown;
|
|
53
|
+
};
|
|
54
|
+
cwd: string;
|
|
55
|
+
sessionId: string;
|
|
56
|
+
config?: Record<string, unknown>;
|
|
57
|
+
pass(): HookResult;
|
|
58
|
+
deny(reason: string): HookResult;
|
|
59
|
+
inject(message: string): HookResult;
|
|
60
|
+
modify(patch: ToolInputPatch): HookResult;
|
|
61
|
+
}
|
|
62
|
+
export type HookResult = {
|
|
63
|
+
type: 'pass';
|
|
64
|
+
} | {
|
|
65
|
+
type: 'deny';
|
|
66
|
+
reason: string;
|
|
67
|
+
} | {
|
|
68
|
+
type: 'inject';
|
|
69
|
+
message: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: 'modify';
|
|
72
|
+
patch: ToolInputPatch;
|
|
73
|
+
};
|
|
74
|
+
export interface ToolInputPatch {
|
|
75
|
+
input?: Record<string, unknown>;
|
|
76
|
+
systemPromptPrepend?: string;
|
|
77
|
+
}
|
|
78
|
+
export type Capability = 'inject' | 'deny' | 'modify' | 'ask';
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tools = void 0;
|
|
4
|
+
exports.Tools = {
|
|
5
|
+
FileRead: 'file.read',
|
|
6
|
+
FileWrite: 'file.write',
|
|
7
|
+
FileEdit: 'file.edit',
|
|
8
|
+
Shell: 'shell',
|
|
9
|
+
Search: 'search',
|
|
10
|
+
Other: 'other',
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HookPlugin } from './plugin';
|
|
2
|
+
import type { HookContext, HookResult } from './types';
|
|
3
|
+
import type { YamlHookEntry, AgentConfig } from '../types';
|
|
4
|
+
export interface YamlHookConfig {
|
|
5
|
+
hooks: YamlHookEntry[];
|
|
6
|
+
agents?: AgentConfig[];
|
|
7
|
+
}
|
|
8
|
+
export declare function validateHooksSchema(hooks: unknown[]): {
|
|
9
|
+
valid: YamlHookEntry[];
|
|
10
|
+
warnings: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare class YamlHookPlugin extends HookPlugin {
|
|
13
|
+
readonly name = "@crewx/yaml-hook-plugin";
|
|
14
|
+
readonly version = "0.1.0";
|
|
15
|
+
readonly capabilities: {
|
|
16
|
+
required: readonly ["inject"];
|
|
17
|
+
};
|
|
18
|
+
private readonly hooks;
|
|
19
|
+
private readonly agentMap;
|
|
20
|
+
constructor(config: YamlHookConfig);
|
|
21
|
+
run(ctx: HookContext): Promise<HookResult>;
|
|
22
|
+
private appendHookLog;
|
|
23
|
+
private matchEntryLevel;
|
|
24
|
+
private matchRuleLevel;
|
|
25
|
+
private hasFired;
|
|
26
|
+
private markFired;
|
|
27
|
+
firedFilePath(sessionId: string): string;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=yaml-plugin.d.ts.map
|