@crewx/sdk 0.8.0-rc.79 → 0.8.0-rc.82
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/dist/__tests__/adapter/context-builder.test.d.ts +1 -0
- package/dist/__tests__/adapter/plugin-helper.test.d.ts +1 -0
- package/dist/__tests__/adapter/registration-integration.test.d.ts +1 -0
- package/dist/__tests__/adapter/scoped-store.test.d.ts +1 -0
- package/dist/__tests__/plugins/conversation.test.d.ts +1 -0
- package/dist/__tests__/testing/createMockContext.test.d.ts +1 -0
- package/dist/adapter/context-builder.d.ts +0 -9
- package/dist/adapter/index.d.ts +0 -1
- package/dist/adapter/plugin-helper.d.ts +0 -7
- package/dist/adapter/scoped-store.d.ts +0 -10
- package/dist/adapter/types.d.ts +0 -7
- package/dist/agent/resolver.d.ts +0 -13
- package/dist/boxing/box-storage.interface.d.ts +0 -4
- package/dist/boxing/box.service.d.ts +0 -4
- package/dist/boxing/box.types.d.ts +0 -4
- package/dist/boxing/context-builder.d.ts +0 -4
- package/dist/client/CrewxClient.d.ts +0 -32
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +1 -6
- package/dist/config/loader.browser.d.ts +0 -8
- package/dist/config/loader.d.ts +0 -12
- package/dist/conversation/__tests__/sqlite-provider.test.d.ts +1 -0
- package/dist/conversation/__tests__/to-task-reader.test.d.ts +1 -0
- package/dist/conversation/index.d.ts +0 -1
- package/dist/conversation/sqlite-provider.d.ts +0 -9
- package/dist/conversation/to-task-reader.d.ts +0 -11
- package/dist/conversation/to-template-messages.d.ts +0 -13
- package/dist/conversation/types.d.ts +0 -58
- package/dist/esm/client/index.js +1 -2
- package/dist/esm/hooks/index.js +7 -6
- package/dist/esm/index.js +79 -60
- package/dist/esm/plugins/index.js +52 -0
- package/dist/esm/testing/index.js +1 -0
- package/dist/esm/tools/node/index.js +36 -54
- package/dist/events/TypedEventEmitter.d.ts +0 -24
- package/dist/events/types.d.ts +0 -43
- package/dist/facade/Crewx.browser.d.ts +0 -40
- package/dist/facade/Crewx.d.ts +0 -163
- package/dist/hooks/define.d.ts +0 -1
- package/dist/hooks/dispatch.d.ts +0 -12
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +7 -24
- package/dist/hooks/observer.d.ts +0 -1
- package/dist/hooks/plugin.d.ts +0 -1
- package/dist/hooks/tool-normalize.d.ts +0 -26
- package/dist/hooks/types.d.ts +0 -1
- package/dist/hooks/yaml-plugin.d.ts +0 -1
- package/dist/index.browser.d.ts +0 -7
- package/dist/index.browser.js +2 -25
- package/dist/index.d.ts +0 -4
- package/dist/index.js +79 -151
- package/dist/layout/loader.d.ts +0 -20
- package/dist/layout/props-validator.d.ts +0 -6
- package/dist/layout/renderer.d.ts +0 -24
- package/dist/layout/types.d.ts +0 -42
- package/dist/parallel/agent-runtime.d.ts +0 -11
- package/dist/parallel/helpers.d.ts +0 -1
- package/dist/parallel/index.d.ts +0 -1
- package/dist/parallel/parallel-runner.d.ts +0 -8
- package/dist/parallel/types.d.ts +0 -24
- package/dist/parsers/agent-call.util.d.ts +0 -3
- package/dist/parsers/claude.parser.d.ts +0 -8
- package/dist/parsers/codex.parser.d.ts +0 -8
- package/dist/parsers/copilot.parser.d.ts +0 -9
- package/dist/parsers/gemini.parser.d.ts +0 -10
- package/dist/parsers/opencode.parser.d.ts +0 -10
- package/dist/parsers/router.d.ts +0 -5
- package/dist/paths.d.ts +1 -0
- package/dist/platform/BrowserFsAdapter.d.ts +0 -20
- package/dist/platform/IFsAdapter.d.ts +0 -23
- package/dist/platform/NodeFsAdapter.d.ts +0 -8
- package/dist/plugin/plugin-provider.d.ts +0 -22
- package/dist/plugin/types.d.ts +0 -31
- package/dist/plugin.d.ts +0 -27
- package/dist/plugins/conversation.d.ts +0 -2
- package/dist/plugins/file-logger.d.ts +0 -13
- package/dist/plugins/index.d.ts +0 -10
- package/dist/plugins/index.js +52 -19
- package/dist/plugins/sqlite-tracing.d.ts +0 -13
- package/dist/plugins/sqlite-tracing.spec.d.ts +1 -0
- package/dist/provider/bridge.browser.d.ts +0 -20
- package/dist/provider/bridge.d.ts +0 -47
- package/dist/provider/parse-usage.d.ts +0 -14
- package/dist/provider/register-api.d.ts +0 -7
- package/dist/provider/vercel-runtime.d.ts +0 -29
- package/dist/remote/index.d.ts +0 -6
- package/dist/remote/remote-agent-manager.d.ts +0 -31
- package/dist/remote/remote-provider.d.ts +0 -15
- package/dist/remote/remote-transport.d.ts +0 -17
- package/dist/remote/types.d.ts +0 -59
- package/dist/server/auth.d.ts +0 -16
- package/dist/server/handler.d.ts +0 -17
- package/dist/server/index.d.ts +0 -4
- package/dist/server/tool-adapter.d.ts +0 -16
- package/dist/template/engine.d.ts +0 -19
- package/dist/template/helpers/exec.browser.d.ts +0 -7
- package/dist/template/helpers/exec.d.ts +0 -45
- package/dist/template/helpers/fenced_code.d.ts +0 -16
- package/dist/template/helpers/format-conversation.d.ts +0 -22
- package/dist/template/helpers/include.d.ts +0 -15
- package/dist/template/helpers/p1p2.d.ts +0 -32
- package/dist/template/loader/DocumentLoader.d.ts +0 -30
- package/dist/template/types.d.ts +0 -30
- package/dist/testing/index.d.ts +0 -1
- package/dist/testing/index.js +1 -16
- package/dist/testing/mock-audit.d.ts +0 -1
- package/dist/testing/mock-context.d.ts +0 -1
- package/dist/testing/mock-logger.d.ts +0 -1
- package/dist/testing/mock-router.d.ts +0 -1
- package/dist/testing/mock-storage.d.ts +0 -1
- package/dist/testing/mock-store.d.ts +0 -1
- package/dist/tools/delegate.d.ts +0 -7
- package/dist/tools/index.d.ts +0 -4
- package/dist/tools/node/builtin.d.ts +0 -16
- package/dist/tools/node/index.d.ts +0 -20
- package/dist/tools/node/index.js +36 -59
- package/dist/types/index.d.ts +0 -20
- package/dist/types/task-log.types.d.ts +0 -4
- package/dist/utils/env-defaults.d.ts +0 -16
- package/dist/utils/glob-match.d.ts +0 -16
- package/dist/utils/id.d.ts +0 -15
- package/dist/utils/timestamp.d.ts +0 -1
- package/dist/utils/workspace.d.ts +0 -4
- package/package.json +24 -25
- package/dist/adapter/context-builder.js +0 -87
- package/dist/adapter/index.js +0 -21
- package/dist/adapter/plugin-helper.js +0 -45
- package/dist/adapter/scoped-store.js +0 -43
- package/dist/adapter/types.js +0 -23
- package/dist/agent/resolver.js +0 -46
- package/dist/boxing/box-storage.interface.js +0 -6
- package/dist/boxing/box.service.js +0 -73
- package/dist/boxing/box.types.js +0 -6
- package/dist/boxing/context-builder.js +0 -79
- package/dist/client/CrewxClient.js +0 -86
- package/dist/config/loader.browser.js +0 -59
- package/dist/config/loader.js +0 -95
- package/dist/conversation/index.js +0 -25
- package/dist/conversation/sqlite-provider.js +0 -178
- package/dist/conversation/to-task-reader.js +0 -28
- package/dist/conversation/to-template-messages.js +0 -34
- package/dist/conversation/types.js +0 -10
- package/dist/esm/agent/resolver.js +0 -41
- package/dist/esm/boxing/box-storage.interface.js +0 -5
- package/dist/esm/boxing/box.service.js +0 -69
- package/dist/esm/boxing/box.types.js +0 -5
- package/dist/esm/boxing/context-builder.js +0 -76
- package/dist/esm/client/CrewxClient.js +0 -82
- package/dist/esm/config/loader.browser.js +0 -54
- package/dist/esm/config/loader.js +0 -77
- package/dist/esm/events/TypedEventEmitter.js +0 -61
- package/dist/esm/events/types.js +0 -8
- package/dist/esm/facade/Crewx.browser.js +0 -310
- package/dist/esm/facade/Crewx.js +0 -941
- package/dist/esm/hooks/define.js +0 -10
- package/dist/esm/hooks/dispatch.js +0 -76
- package/dist/esm/hooks/observer.js +0 -56
- package/dist/esm/hooks/plugin.js +0 -12
- package/dist/esm/hooks/types.js +0 -9
- package/dist/esm/index.browser.js +0 -15
- package/dist/esm/layout/loader.js +0 -268
- package/dist/esm/layout/props-validator.js +0 -297
- package/dist/esm/layout/renderer.js +0 -180
- package/dist/esm/layout/types.js +0 -31
- package/dist/esm/parallel/agent-runtime.js +0 -21
- package/dist/esm/parallel/helpers.js +0 -214
- package/dist/esm/parallel/index.js +0 -5
- package/dist/esm/parallel/parallel-runner.js +0 -221
- package/dist/esm/parallel/types.js +0 -5
- package/dist/esm/parsers/agent-call.util.js +0 -15
- package/dist/esm/parsers/claude.parser.js +0 -64
- package/dist/esm/parsers/codex.parser.js +0 -97
- package/dist/esm/parsers/copilot.parser.js +0 -63
- package/dist/esm/parsers/gemini.parser.js +0 -43
- package/dist/esm/parsers/opencode.parser.js +0 -73
- package/dist/esm/parsers/router.js +0 -53
- package/dist/esm/platform/BrowserFsAdapter.js +0 -80
- package/dist/esm/platform/IFsAdapter.js +0 -2
- package/dist/esm/platform/NodeFsAdapter.js +0 -34
- package/dist/esm/plugin/plugin-provider.js +0 -202
- package/dist/esm/plugin/types.js +0 -8
- package/dist/esm/plugin.js +0 -25
- package/dist/esm/provider/bridge.browser.js +0 -43
- package/dist/esm/provider/bridge.js +0 -373
- package/dist/esm/provider/parse-usage.js +0 -80
- package/dist/esm/provider/register-api.js +0 -21
- package/dist/esm/provider/vercel-runtime.js +0 -310
- package/dist/esm/remote/index.js +0 -10
- package/dist/esm/remote/remote-agent-manager.js +0 -194
- package/dist/esm/remote/remote-provider.js +0 -98
- package/dist/esm/remote/remote-transport.js +0 -79
- package/dist/esm/remote/types.js +0 -8
- package/dist/esm/server/auth.js +0 -31
- package/dist/esm/server/handler.js +0 -72
- package/dist/esm/server/index.js +0 -5
- package/dist/esm/server/tool-adapter.js +0 -92
- package/dist/esm/template/engine.js +0 -100
- package/dist/esm/template/helpers/exec.browser.js +0 -31
- package/dist/esm/template/helpers/exec.js +0 -220
- package/dist/esm/template/helpers/fenced_code.js +0 -17
- package/dist/esm/template/helpers/include.js +0 -20
- package/dist/esm/template/helpers/p1p2.js +0 -83
- package/dist/esm/template/loader/DocumentLoader.js +0 -124
- package/dist/esm/template/types.js +0 -5
- package/dist/esm/tools/delegate.js +0 -57
- package/dist/esm/tools/index.js +0 -5
- package/dist/esm/tools/node/builtin.js +0 -541
- package/dist/esm/types/index.js +0 -27
- package/dist/esm/types/task-log.types.js +0 -5
- package/dist/esm/utils/env-defaults.js +0 -23
- package/dist/esm/utils/glob-match.js +0 -38
- package/dist/esm/utils/id.js +0 -46
- package/dist/esm/utils/workspace.js +0 -21
- package/dist/events/TypedEventEmitter.js +0 -65
- package/dist/events/types.js +0 -9
- package/dist/facade/Crewx.browser.js +0 -314
- package/dist/facade/Crewx.js +0 -1299
- package/dist/hooks/define.js +0 -13
- package/dist/hooks/dispatch.js +0 -147
- package/dist/hooks/observer.js +0 -60
- package/dist/hooks/plugin.js +0 -17
- package/dist/hooks/tool-normalize.js +0 -110
- package/dist/hooks/types.js +0 -12
- package/dist/hooks/yaml-plugin.js +0 -356
- package/dist/layout/loader.js +0 -305
- package/dist/layout/props-validator.js +0 -301
- package/dist/layout/renderer.js +0 -193
- package/dist/layout/types.js +0 -36
- package/dist/parallel/agent-runtime.js +0 -25
- package/dist/parallel/helpers.js +0 -219
- package/dist/parallel/index.js +0 -13
- package/dist/parallel/parallel-runner.js +0 -226
- package/dist/parallel/types.js +0 -6
- package/dist/parsers/agent-call.util.js +0 -19
- package/dist/parsers/api.parser.d.ts +0 -10
- package/dist/parsers/api.parser.js +0 -26
- package/dist/parsers/claude.parser.js +0 -67
- package/dist/parsers/codex.parser.js +0 -100
- package/dist/parsers/copilot.parser.js +0 -66
- package/dist/parsers/gemini.parser.js +0 -46
- package/dist/parsers/opencode.parser.js +0 -76
- package/dist/parsers/router.js +0 -56
- package/dist/platform/BrowserFsAdapter.js +0 -84
- package/dist/platform/IFsAdapter.js +0 -3
- package/dist/platform/NodeFsAdapter.js +0 -38
- package/dist/plugin/plugin-provider.js +0 -207
- package/dist/plugin/types.js +0 -9
- package/dist/plugin.js +0 -29
- package/dist/plugins/conversation.js +0 -59
- package/dist/plugins/file-logger.js +0 -87
- package/dist/plugins/sqlite-tracing.js +0 -112
- package/dist/provider/bridge.browser.js +0 -49
- package/dist/provider/bridge.js +0 -381
- package/dist/provider/mastra-runtime.d.ts +0 -45
- package/dist/provider/mastra-runtime.js +0 -208
- package/dist/provider/parse-usage.js +0 -83
- package/dist/provider/register-api.js +0 -24
- package/dist/provider/vercel-runtime.js +0 -347
- package/dist/remote/index.js +0 -32
- package/dist/remote/remote-agent-manager.js +0 -198
- package/dist/remote/remote-provider.js +0 -141
- package/dist/remote/remote-transport.js +0 -83
- package/dist/remote/types.js +0 -9
- package/dist/server/auth.js +0 -35
- package/dist/server/handler.js +0 -75
- package/dist/server/index.js +0 -9
- package/dist/server/tool-adapter.js +0 -95
- package/dist/template/engine.js +0 -137
- package/dist/template/helpers/exec.browser.js +0 -41
- package/dist/template/helpers/exec.js +0 -230
- package/dist/template/helpers/fenced_code.js +0 -20
- package/dist/template/helpers/format-conversation.js +0 -53
- package/dist/template/helpers/include.js +0 -23
- package/dist/template/helpers/p1p2.js +0 -90
- package/dist/template/loader/DocumentLoader.js +0 -128
- package/dist/template/types.js +0 -6
- package/dist/testing/mock-audit.js +0 -13
- package/dist/testing/mock-context.js +0 -68
- package/dist/testing/mock-logger.js +0 -27
- package/dist/testing/mock-router.js +0 -67
- package/dist/testing/mock-storage.js +0 -21
- package/dist/testing/mock-store.js +0 -8
- package/dist/tools/delegate.js +0 -60
- package/dist/tools/index.js +0 -9
- package/dist/tools/node/builtin.js +0 -547
- package/dist/types/index.js +0 -32
- package/dist/types/task-log.types.js +0 -6
- package/dist/utils/env-defaults.js +0 -27
- package/dist/utils/glob-match.js +0 -42
- package/dist/utils/id.js +0 -50
- package/dist/utils/timestamp.js +0 -13
- package/dist/utils/workspace.js +0 -58
package/dist/hooks/define.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
package/dist/hooks/dispatch.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
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
|
package/dist/hooks/observer.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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
|
package/dist/hooks/plugin.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1,110 +0,0 @@
|
|
|
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
|
package/dist/hooks/types.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
|