@crewx/sdk 0.8.0-rc.80 → 0.8.0-rc.83
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 -0
- package/dist/esm/hooks/index.js +7 -0
- package/dist/esm/index.js +79 -0
- package/dist/esm/plugins/index.js +52 -0
- package/dist/esm/testing/index.js +1 -0
- package/dist/esm/tools/node/index.js +36 -0
- 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/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/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/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
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCopilotEvent = parseCopilotEvent;
|
|
4
|
-
const agent_call_util_1 = require("./agent-call.util");
|
|
5
|
-
/**
|
|
6
|
-
* Parse Copilot json events into TaskLogEntry[].
|
|
7
|
-
*
|
|
8
|
-
* Copilot events:
|
|
9
|
-
* - { type: "tool.execution_start", data: { toolName, arguments } }
|
|
10
|
-
* - { type: "tool.execution_complete", data: { result?: { content }, error?: { message } } }
|
|
11
|
-
* - { type: "assistant.message", data: { content } }
|
|
12
|
-
*/
|
|
13
|
-
function parseCopilotEvent(timestamp, parsed) {
|
|
14
|
-
const type = parsed.type;
|
|
15
|
-
const data = parsed.data;
|
|
16
|
-
if (!data)
|
|
17
|
-
return [];
|
|
18
|
-
const toolCallId = data.toolCallId;
|
|
19
|
-
if (type === 'tool.execution_start') {
|
|
20
|
-
const toolName = String(data.toolName || '');
|
|
21
|
-
const args = data.arguments;
|
|
22
|
-
const inputStr = args?.command
|
|
23
|
-
? String(args.command)
|
|
24
|
-
: JSON.stringify(args || {});
|
|
25
|
-
if ((toolName === 'bash' || toolName === 'Bash') &&
|
|
26
|
-
(0, agent_call_util_1.isAgentCallCommand)(inputStr)) {
|
|
27
|
-
return [(0, agent_call_util_1.parseAgentCall)(timestamp, inputStr)];
|
|
28
|
-
}
|
|
29
|
-
return [{
|
|
30
|
-
timestamp,
|
|
31
|
-
type: 'tool_use',
|
|
32
|
-
toolName,
|
|
33
|
-
toolInput: inputStr,
|
|
34
|
-
...(toolCallId && { toolUseId: toolCallId }),
|
|
35
|
-
}];
|
|
36
|
-
}
|
|
37
|
-
if (type === 'tool.execution_complete') {
|
|
38
|
-
const error = data.error;
|
|
39
|
-
if (error) {
|
|
40
|
-
return [{
|
|
41
|
-
timestamp,
|
|
42
|
-
type: 'tool_result',
|
|
43
|
-
isError: true,
|
|
44
|
-
resultPreview: String(error.message || ''),
|
|
45
|
-
...(toolCallId && { toolUseId: toolCallId }),
|
|
46
|
-
}];
|
|
47
|
-
}
|
|
48
|
-
const result = data.result;
|
|
49
|
-
const content = String(result?.content || '');
|
|
50
|
-
return [{
|
|
51
|
-
timestamp,
|
|
52
|
-
type: 'tool_result',
|
|
53
|
-
resultPreview: content,
|
|
54
|
-
isError: false,
|
|
55
|
-
...(toolCallId && { toolUseId: toolCallId }),
|
|
56
|
-
}];
|
|
57
|
-
}
|
|
58
|
-
if (type === 'assistant.message') {
|
|
59
|
-
const content = String(data.content || '');
|
|
60
|
-
if (!content)
|
|
61
|
-
return [];
|
|
62
|
-
return [{ timestamp, type: 'text', content }];
|
|
63
|
-
}
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=copilot.parser.js.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseGeminiEvent = parseGeminiEvent;
|
|
4
|
-
const agent_call_util_1 = require("./agent-call.util");
|
|
5
|
-
/**
|
|
6
|
-
* Parse Gemini stream-json events into TaskLogEntry[].
|
|
7
|
-
*
|
|
8
|
-
* Gemini events:
|
|
9
|
-
* - { type: "message", role: "assistant", delta: true, content: "..." }
|
|
10
|
-
* - { type: "init", ... } (ignored)
|
|
11
|
-
* - { type: "tool_use", tool_name, tool_id, parameters }
|
|
12
|
-
* - { type: "tool_result", tool_id, status, output }
|
|
13
|
-
*/
|
|
14
|
-
function parseGeminiEvent(timestamp, parsed) {
|
|
15
|
-
const type = parsed.type;
|
|
16
|
-
if (type === 'message') {
|
|
17
|
-
const role = parsed.role;
|
|
18
|
-
if (role !== 'assistant')
|
|
19
|
-
return [];
|
|
20
|
-
const content = parsed.content;
|
|
21
|
-
if (!content)
|
|
22
|
-
return [];
|
|
23
|
-
return [{ timestamp, type: 'text', content }];
|
|
24
|
-
}
|
|
25
|
-
if (type === 'tool_use') {
|
|
26
|
-
const toolName = String(parsed.tool_name || '');
|
|
27
|
-
const toolUseId = parsed.tool_id;
|
|
28
|
-
const parameters = parsed.parameters;
|
|
29
|
-
const inputStr = parameters?.command
|
|
30
|
-
? String(parameters.command)
|
|
31
|
-
: JSON.stringify(parameters || {});
|
|
32
|
-
if (/^bash$/i.test(toolName) && (0, agent_call_util_1.isAgentCallCommand)(inputStr)) {
|
|
33
|
-
return [(0, agent_call_util_1.parseAgentCall)(timestamp, inputStr)];
|
|
34
|
-
}
|
|
35
|
-
return [{ timestamp, type: 'tool_use', toolName, toolUseId, toolInput: inputStr }];
|
|
36
|
-
}
|
|
37
|
-
if (type === 'tool_result') {
|
|
38
|
-
const toolUseId = parsed.tool_id;
|
|
39
|
-
const output = String(parsed.output || '');
|
|
40
|
-
const isError = parsed.status !== 'success';
|
|
41
|
-
return [{ timestamp, type: 'tool_result', toolUseId, resultPreview: output, isError }];
|
|
42
|
-
}
|
|
43
|
-
// init and other events: skip
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=gemini.parser.js.map
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseOpencodeEvent = parseOpencodeEvent;
|
|
4
|
-
/**
|
|
5
|
-
* Parse OpenCode stream-json events (--format json) into TaskLogEntry[].
|
|
6
|
-
*
|
|
7
|
-
* OpenCode events:
|
|
8
|
-
* - { type: "step_start", sessionID: "ses_...", part: { type: "step-start" } }
|
|
9
|
-
* - { type: "text", part: { type: "text", text: "..." } }
|
|
10
|
-
* - { type: "step_finish", part: { reason: "stop", tokens: { total, input, output, reasoning, cache: { write, read } }, cost: 0 } }
|
|
11
|
-
* - { type: "tool_use", part: { type: "tool", tool: "bash"|"write"|..., callID: "...", state: { status, input, output } } }
|
|
12
|
-
*/
|
|
13
|
-
function parseOpencodeEvent(timestamp, parsed) {
|
|
14
|
-
const type = parsed.type;
|
|
15
|
-
if (type === 'text') {
|
|
16
|
-
const part = parsed.part;
|
|
17
|
-
const text = part?.text;
|
|
18
|
-
if (!text)
|
|
19
|
-
return [];
|
|
20
|
-
return [{ timestamp, type: 'text', content: text }];
|
|
21
|
-
}
|
|
22
|
-
if (type === 'tool_use') {
|
|
23
|
-
const part = parsed.part;
|
|
24
|
-
if (!part)
|
|
25
|
-
return [];
|
|
26
|
-
const tool = String(part.tool || '');
|
|
27
|
-
const toolUseId = String(part.callID || '');
|
|
28
|
-
const state = part.state;
|
|
29
|
-
const status = String(state?.status || '');
|
|
30
|
-
const input = state?.input;
|
|
31
|
-
const inputStr = extractToolInput(input);
|
|
32
|
-
const entries = [
|
|
33
|
-
{ timestamp, type: 'tool_use', toolName: tool, toolUseId, toolInput: inputStr },
|
|
34
|
-
];
|
|
35
|
-
if (status === 'completed' && state?.output !== undefined) {
|
|
36
|
-
const output = state.output;
|
|
37
|
-
const outputStr = typeof output === 'string' ? output : JSON.stringify(output);
|
|
38
|
-
entries.push({ timestamp, type: 'tool_result', toolUseId, resultPreview: outputStr, isError: false });
|
|
39
|
-
}
|
|
40
|
-
else if (status === 'error') {
|
|
41
|
-
entries.push({
|
|
42
|
-
timestamp,
|
|
43
|
-
type: 'tool_result',
|
|
44
|
-
toolUseId,
|
|
45
|
-
resultPreview: String(state?.error || 'tool error'),
|
|
46
|
-
isError: true,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return entries;
|
|
50
|
-
}
|
|
51
|
-
// step_start, step_finish: skip (usage is extracted by parse-usage.ts)
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Extract a human-friendly string from OpenCode tool input.
|
|
56
|
-
*
|
|
57
|
-
* Matches Claude/Gemini parser behaviour:
|
|
58
|
-
* - bash-like → input.command ("mkdir -p /tmp/foo")
|
|
59
|
-
* - file tools → input.filePath ("/tmp/foo/bar.ts")
|
|
60
|
-
* - otherwise → JSON.stringify fallback
|
|
61
|
-
*/
|
|
62
|
-
function extractToolInput(input) {
|
|
63
|
-
if (typeof input === 'string')
|
|
64
|
-
return input;
|
|
65
|
-
if (!input || typeof input !== 'object')
|
|
66
|
-
return JSON.stringify(input ?? {});
|
|
67
|
-
const obj = input;
|
|
68
|
-
if (obj.command)
|
|
69
|
-
return String(obj.command);
|
|
70
|
-
if (obj.filePath)
|
|
71
|
-
return String(obj.filePath);
|
|
72
|
-
if (obj.pattern)
|
|
73
|
-
return String(obj.pattern);
|
|
74
|
-
return JSON.stringify(obj);
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=opencode.parser.js.map
|
package/dist/parsers/router.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* parseStdoutEvent — routes a single stdout JSONL event to the appropriate provider parser.
|
|
4
|
-
* Returns TaskLogEntry[] (may be empty if event is not recognized or irrelevant).
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.parseStdoutEvent = parseStdoutEvent;
|
|
8
|
-
const claude_parser_1 = require("./claude.parser");
|
|
9
|
-
const copilot_parser_1 = require("./copilot.parser");
|
|
10
|
-
const codex_parser_1 = require("./codex.parser");
|
|
11
|
-
const gemini_parser_1 = require("./gemini.parser");
|
|
12
|
-
const opencode_parser_1 = require("./opencode.parser");
|
|
13
|
-
function parseStdoutEvent(timestamp, message) {
|
|
14
|
-
let parsed;
|
|
15
|
-
try {
|
|
16
|
-
parsed = JSON.parse(message);
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
const type = parsed.type;
|
|
22
|
-
if (!type)
|
|
23
|
-
return [];
|
|
24
|
-
// Claude stream-json (system event excluded — meta event)
|
|
25
|
-
if (type === 'assistant' || type === 'user') {
|
|
26
|
-
return (0, claude_parser_1.parseClaudeEvent)(timestamp, parsed);
|
|
27
|
-
}
|
|
28
|
-
// Copilot json — assistant.* check must precede Gemini "message" check
|
|
29
|
-
if (type.startsWith('tool.execution') || type.startsWith('assistant.') || type === 'user.message') {
|
|
30
|
-
return (0, copilot_parser_1.parseCopilotEvent)(timestamp, parsed);
|
|
31
|
-
}
|
|
32
|
-
// Codex experimental-json
|
|
33
|
-
if (type.startsWith('item.') || type.startsWith('turn.') || type.startsWith('thread.')) {
|
|
34
|
-
return (0, codex_parser_1.parseCodexEvent)(timestamp, parsed);
|
|
35
|
-
}
|
|
36
|
-
// Gemini stream-json — tool_use/tool_result routed by structure below
|
|
37
|
-
if (type === 'message' || type === 'init') {
|
|
38
|
-
return (0, gemini_parser_1.parseGeminiEvent)(timestamp, parsed);
|
|
39
|
-
}
|
|
40
|
-
// tool_use / tool_result: disambiguate by schema structure.
|
|
41
|
-
// OpenCode has a `part` object; Gemini is flat (tool_name, parameters).
|
|
42
|
-
if (type === 'tool_use' || type === 'tool_result') {
|
|
43
|
-
if (parsed.part && typeof parsed.part === 'object') {
|
|
44
|
-
return (0, opencode_parser_1.parseOpencodeEvent)(timestamp, parsed);
|
|
45
|
-
}
|
|
46
|
-
return (0, gemini_parser_1.parseGeminiEvent)(timestamp, parsed);
|
|
47
|
-
}
|
|
48
|
-
// OpenCode stream-json (--format json)
|
|
49
|
-
// Note: 'text' is a generic name but not used by any other provider currently.
|
|
50
|
-
// 'step_start' and 'step_finish' are OpenCode-specific.
|
|
51
|
-
if (type === 'text' || type === 'step_start' || type === 'step_finish') {
|
|
52
|
-
return (0, opencode_parser_1.parseOpencodeEvent)(timestamp, parsed);
|
|
53
|
-
}
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=router.js.map
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* BrowserFsAdapter — IFsAdapter implementation for browser environments.
|
|
4
|
-
*
|
|
5
|
-
* Uses localStorage as the backing store with a key-prefix namespace.
|
|
6
|
-
* Paths are normalized to forward-slash POSIX style.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* const fs = new BrowserFsAdapter();
|
|
10
|
-
* // Pre-load content before using with DocumentLoader:
|
|
11
|
-
* fs.setItem('/docs/guide.md', '# Guide\n...');
|
|
12
|
-
*/
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.BrowserFsAdapter = void 0;
|
|
15
|
-
const DEFAULT_PREFIX = 'crewx:fs:';
|
|
16
|
-
class BrowserFsAdapter {
|
|
17
|
-
prefix;
|
|
18
|
-
store;
|
|
19
|
-
/**
|
|
20
|
-
* @param options.prefix - localStorage key prefix (default: 'crewx:fs:')
|
|
21
|
-
* @param options.storage - optional external storage map (defaults to an in-memory Map;
|
|
22
|
-
* pass a localStorage-backed wrapper for persistence)
|
|
23
|
-
*/
|
|
24
|
-
constructor(options) {
|
|
25
|
-
this.prefix = options?.prefix ?? DEFAULT_PREFIX;
|
|
26
|
-
this.store = options?.storage ?? new Map();
|
|
27
|
-
}
|
|
28
|
-
async readFile(path) {
|
|
29
|
-
const key = this.toKey(path);
|
|
30
|
-
const content = this.store.get(key);
|
|
31
|
-
if (content === undefined) {
|
|
32
|
-
throw new Error(`BrowserFsAdapter: file not found: ${path}`);
|
|
33
|
-
}
|
|
34
|
-
return content;
|
|
35
|
-
}
|
|
36
|
-
async exists(path) {
|
|
37
|
-
return this.store.has(this.toKey(path));
|
|
38
|
-
}
|
|
39
|
-
resolvePath(...segments) {
|
|
40
|
-
// Simple POSIX-style path joining (no true "resolve" since there's no cwd)
|
|
41
|
-
const joined = segments
|
|
42
|
-
.map(s => s.replace(/\\/g, '/'))
|
|
43
|
-
.join('/')
|
|
44
|
-
.replace(/\/+/g, '/');
|
|
45
|
-
// Normalize . and .. segments
|
|
46
|
-
const parts = joined.split('/');
|
|
47
|
-
const resolved = [];
|
|
48
|
-
for (const part of parts) {
|
|
49
|
-
if (part === '.' || part === '')
|
|
50
|
-
continue;
|
|
51
|
-
if (part === '..') {
|
|
52
|
-
resolved.pop();
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
resolved.push(part);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const result = resolved.join('/');
|
|
59
|
-
return joined.startsWith('/') ? `/${result}` : result;
|
|
60
|
-
}
|
|
61
|
-
isAbsolute(path) {
|
|
62
|
-
return path.startsWith('/');
|
|
63
|
-
}
|
|
64
|
-
// ── Browser-specific helpers ───────────────────────────────────────────────
|
|
65
|
-
/** Store a virtual file for later reading. */
|
|
66
|
-
setItem(path, content) {
|
|
67
|
-
this.store.set(this.toKey(path), content);
|
|
68
|
-
}
|
|
69
|
-
/** Remove a virtual file. */
|
|
70
|
-
removeItem(path) {
|
|
71
|
-
this.store.delete(this.toKey(path));
|
|
72
|
-
}
|
|
73
|
-
/** List all stored virtual file paths. */
|
|
74
|
-
keys() {
|
|
75
|
-
return Array.from(this.store.keys())
|
|
76
|
-
.filter(k => k.startsWith(this.prefix))
|
|
77
|
-
.map(k => k.slice(this.prefix.length));
|
|
78
|
-
}
|
|
79
|
-
toKey(path) {
|
|
80
|
-
return `${this.prefix}${path.replace(/\\/g, '/')}`;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
exports.BrowserFsAdapter = BrowserFsAdapter;
|
|
84
|
-
//# sourceMappingURL=BrowserFsAdapter.js.map
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* NodeFsAdapter — default IFsAdapter implementation using Node.js fs/path.
|
|
4
|
-
*
|
|
5
|
-
* This is the concrete adapter used in CLI and server contexts.
|
|
6
|
-
* Full platform abstraction (WEB, browser) is deferred to a future round.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.defaultFsAdapter = exports.NodeFsAdapter = void 0;
|
|
10
|
-
const promises_1 = require("fs/promises");
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
class NodeFsAdapter {
|
|
13
|
-
async readFile(path) {
|
|
14
|
-
return (0, promises_1.readFile)(path, 'utf-8');
|
|
15
|
-
}
|
|
16
|
-
async exists(path) {
|
|
17
|
-
try {
|
|
18
|
-
await (0, promises_1.access)(path);
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
resolvePath(...segments) {
|
|
26
|
-
if (segments.length === 1) {
|
|
27
|
-
return (0, path_1.resolve)(segments[0]);
|
|
28
|
-
}
|
|
29
|
-
return (0, path_1.resolve)((0, path_1.join)(...segments));
|
|
30
|
-
}
|
|
31
|
-
isAbsolute(path) {
|
|
32
|
-
return (0, path_1.isAbsolute)(path);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.NodeFsAdapter = NodeFsAdapter;
|
|
36
|
-
/** Singleton default adapter for convenience in CLI usage. */
|
|
37
|
-
exports.defaultFsAdapter = new NodeFsAdapter();
|
|
38
|
-
//# sourceMappingURL=NodeFsAdapter.js.map
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Plugin Provider Runtime
|
|
4
|
-
*
|
|
5
|
-
* Implements ProviderRuntime for `type: plugin` providers in crewx.yaml.
|
|
6
|
-
* Wraps an arbitrary CLI tool as a CrewX agent via child_process.spawn (shell: false).
|
|
7
|
-
*
|
|
8
|
-
* Symmetric to remote/remote-provider.ts — registered as the `plugin` namespace factory.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.PluginProviderRuntime = void 0;
|
|
12
|
-
exports.createPluginProviderFactory = createPluginProviderFactory;
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const bridge_js_1 = require("../provider/bridge.js");
|
|
15
|
-
/**
|
|
16
|
-
* ProviderRuntime implementation for plugin (CLI-wrapped) providers.
|
|
17
|
-
*
|
|
18
|
-
* Created by the `plugin` namespace factory when `createProvider('plugin/mock')` is called.
|
|
19
|
-
* Spawns the configured CLI with args derived from query_args/execute_args,
|
|
20
|
-
* applies `{model}` substitution, and routes the prompt via args or stdin.
|
|
21
|
-
*/
|
|
22
|
-
class PluginProviderRuntime {
|
|
23
|
-
config;
|
|
24
|
-
providerStr;
|
|
25
|
-
constructor(id, config) {
|
|
26
|
-
this.config = config;
|
|
27
|
-
this.providerStr = `plugin/${id}`;
|
|
28
|
-
// Validate at construction time (fail early, not at call time)
|
|
29
|
-
validateCliCommand(config.cli_command);
|
|
30
|
-
validateCliArgs(config.query_args);
|
|
31
|
-
validateCliArgs(config.execute_args);
|
|
32
|
-
if (config.error_patterns)
|
|
33
|
-
validateErrorPatterns(config.error_patterns);
|
|
34
|
-
if (config.env)
|
|
35
|
-
validateEnv(config.env);
|
|
36
|
-
}
|
|
37
|
-
async query(message, options) {
|
|
38
|
-
const model = options?.model ?? this.config.default_model ?? 'default';
|
|
39
|
-
const args = resolveArgs(this.config.query_args, model, message, this.config.prompt_in_args);
|
|
40
|
-
const stdinMessage = this.config.prompt_in_args ? undefined : message;
|
|
41
|
-
options?.onCommand?.(`${this.config.cli_command} ${args.join(' ')}`);
|
|
42
|
-
const timeoutMs = this.config.timeout?.query ?? 600000;
|
|
43
|
-
return this.runProcess(args, options, stdinMessage, timeoutMs);
|
|
44
|
-
}
|
|
45
|
-
async execute(message, options) {
|
|
46
|
-
const model = options?.model ?? this.config.default_model ?? 'default';
|
|
47
|
-
const args = resolveArgs(this.config.execute_args, model, message, this.config.prompt_in_args);
|
|
48
|
-
const stdinMessage = this.config.prompt_in_args ? undefined : message;
|
|
49
|
-
options?.onCommand?.(`${this.config.cli_command} ${args.join(' ')}`);
|
|
50
|
-
const timeoutMs = this.config.timeout?.execute ?? 600000;
|
|
51
|
-
return this.runProcess(args, options, stdinMessage, timeoutMs);
|
|
52
|
-
}
|
|
53
|
-
runProcess(args, options, stdinMessage, timeoutMs) {
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
// Merge env: process.env is the base; config.env values are added on top.
|
|
56
|
-
// Never replaces process.env — only extends it.
|
|
57
|
-
const mergedEnv = {
|
|
58
|
-
...process.env,
|
|
59
|
-
...(this.config.env ?? {}),
|
|
60
|
-
};
|
|
61
|
-
const proc = (0, child_process_1.spawn)(this.config.cli_command, args, {
|
|
62
|
-
env: mergedEnv,
|
|
63
|
-
shell: process.platform === 'win32', // Windows: .cmd/.bat requires shell
|
|
64
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
65
|
-
});
|
|
66
|
-
// Write prompt to stdin when prompt_in_args is false
|
|
67
|
-
if (stdinMessage !== undefined) {
|
|
68
|
-
proc.stdin.write(stdinMessage);
|
|
69
|
-
proc.stdin.end();
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
proc.stdin.end();
|
|
73
|
-
}
|
|
74
|
-
if (proc.pid !== undefined) {
|
|
75
|
-
options?.onPid?.(proc.pid);
|
|
76
|
-
}
|
|
77
|
-
let stdout = '';
|
|
78
|
-
let stderr = '';
|
|
79
|
-
let stdoutBuf = '';
|
|
80
|
-
let stderrBuf = '';
|
|
81
|
-
proc.stdout.on('data', (chunk) => {
|
|
82
|
-
const str = chunk.toString();
|
|
83
|
-
stdout += str;
|
|
84
|
-
stdoutBuf += str;
|
|
85
|
-
const lines = stdoutBuf.split('\n');
|
|
86
|
-
stdoutBuf = lines.pop() ?? '';
|
|
87
|
-
for (const line of lines) {
|
|
88
|
-
if (line.trim())
|
|
89
|
-
options?.onOutput?.(line, 'stdout');
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
proc.stderr.on('data', (chunk) => {
|
|
93
|
-
const str = chunk.toString();
|
|
94
|
-
stderr += str;
|
|
95
|
-
stderrBuf += str;
|
|
96
|
-
const lines = stderrBuf.split('\n');
|
|
97
|
-
stderrBuf = lines.pop() ?? '';
|
|
98
|
-
for (const line of lines) {
|
|
99
|
-
if (line.trim())
|
|
100
|
-
options?.onOutput?.(line, 'stderr');
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
// Hard timeout — terminate and reject if exceeded
|
|
104
|
-
const timeoutHandle = setTimeout(() => {
|
|
105
|
-
proc.kill('SIGTERM');
|
|
106
|
-
reject(new bridge_js_1.ProviderError(`Plugin provider "${this.providerStr}" timed out after ${timeoutMs}ms`, this.providerStr));
|
|
107
|
-
}, timeoutMs);
|
|
108
|
-
proc.on('error', (err) => {
|
|
109
|
-
clearTimeout(timeoutHandle);
|
|
110
|
-
if (err.code === 'ENOENT') {
|
|
111
|
-
const hint = this.config.not_installed_message
|
|
112
|
-
?? `CLI command "${this.config.cli_command}" not found. Is ${this.config.id} installed?`;
|
|
113
|
-
reject(new bridge_js_1.ProviderError(hint, this.providerStr));
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
reject(new bridge_js_1.ProviderError(`Spawn error: ${err.message}`, this.providerStr));
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
proc.on('close', (code) => {
|
|
120
|
-
clearTimeout(timeoutHandle);
|
|
121
|
-
// Flush residual buffered content (no trailing newline)
|
|
122
|
-
if (stdoutBuf.trim())
|
|
123
|
-
options?.onOutput?.(stdoutBuf, 'stdout');
|
|
124
|
-
if (stderrBuf.trim())
|
|
125
|
-
options?.onOutput?.(stderrBuf, 'stderr');
|
|
126
|
-
const exitCode = code ?? 0;
|
|
127
|
-
options?.onExitCode?.(exitCode);
|
|
128
|
-
// Check configured error patterns before exit code
|
|
129
|
-
if (this.config.error_patterns) {
|
|
130
|
-
const combined = stderr || stdout;
|
|
131
|
-
for (const ep of this.config.error_patterns) {
|
|
132
|
-
if (combined.includes(ep.pattern)) {
|
|
133
|
-
reject(new bridge_js_1.ProviderError(ep.message, this.providerStr));
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (code !== 0) {
|
|
139
|
-
reject(new bridge_js_1.ProviderError(`Process exited with code ${code}: ${stderr.slice(0, 500)}`, this.providerStr));
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
resolve(stdout.trim());
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
exports.PluginProviderRuntime = PluginProviderRuntime;
|
|
148
|
-
// ── Factory ─────────────────────────────────────────────────────────────────
|
|
149
|
-
/**
|
|
150
|
-
* Create a provider factory function for the `plugin` namespace.
|
|
151
|
-
*
|
|
152
|
-
* @param pluginConfigs - Map of plugin provider ID → config (from crewx.yaml `providers:` section)
|
|
153
|
-
* @returns ProviderFactory to register via registerProviderFactory('plugin', factory)
|
|
154
|
-
*/
|
|
155
|
-
function createPluginProviderFactory(pluginConfigs) {
|
|
156
|
-
return (id, _providerStr) => {
|
|
157
|
-
const config = pluginConfigs.get(id);
|
|
158
|
-
if (!config) {
|
|
159
|
-
throw new bridge_js_1.ProviderError(`Plugin provider "${id}" not found. Available: ${Array.from(pluginConfigs.keys()).join(', ') || '(none)'}`, `plugin/${id}`);
|
|
160
|
-
}
|
|
161
|
-
return new PluginProviderRuntime(id, config);
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
165
|
-
/**
|
|
166
|
-
* Build the final args array for a CLI invocation:
|
|
167
|
-
* 1. Replace `{model}` placeholders in each arg.
|
|
168
|
-
* 2. If promptInArgs is true, append the prompt as a positional argument.
|
|
169
|
-
*/
|
|
170
|
-
function resolveArgs(templateArgs, model, prompt, promptInArgs) {
|
|
171
|
-
const args = templateArgs.map(arg => arg.replace(/\{model\}/g, model));
|
|
172
|
-
if (promptInArgs) {
|
|
173
|
-
args.push(prompt);
|
|
174
|
-
}
|
|
175
|
-
return args;
|
|
176
|
-
}
|
|
177
|
-
// ── Validation ───────────────────────────────────────────────────────────────
|
|
178
|
-
function validateCliCommand(cliCommand) {
|
|
179
|
-
if (!cliCommand || typeof cliCommand !== 'string') {
|
|
180
|
-
throw new Error('Plugin provider requires a cli_command');
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function validateCliArgs(args) {
|
|
184
|
-
if (!Array.isArray(args)) {
|
|
185
|
-
throw new Error('CLI arguments must be an array');
|
|
186
|
-
}
|
|
187
|
-
for (const arg of args) {
|
|
188
|
-
if (typeof arg !== 'string') {
|
|
189
|
-
throw new Error('Each CLI argument must be a string');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function validateErrorPatterns(patterns) {
|
|
194
|
-
for (const { pattern } of patterns) {
|
|
195
|
-
if (typeof pattern !== 'string') {
|
|
196
|
-
throw new Error('Error pattern must be a string');
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function validateEnv(env) {
|
|
201
|
-
for (const [key, value] of Object.entries(env)) {
|
|
202
|
-
if (typeof key !== 'string' || typeof value !== 'string') {
|
|
203
|
-
throw new Error('env entries must be string key/value pairs');
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
//# sourceMappingURL=plugin-provider.js.map
|
package/dist/plugin/types.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Plugin Provider Types
|
|
4
|
-
*
|
|
5
|
-
* Configuration for `type: plugin` providers in crewx.yaml.
|
|
6
|
-
* Plugin providers wrap arbitrary CLI tools as CrewX agents.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
//# sourceMappingURL=types.js.map
|
package/dist/plugin.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* CrewxPlugin — base class for SDK plugins.
|
|
4
|
-
*
|
|
5
|
-
* Plugins subscribe to Crewx events in attach() and clean up in detach().
|
|
6
|
-
* Register via Crewx.use(plugin).
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* class MyPlugin extends CrewxPlugin {
|
|
10
|
-
* readonly name = 'my-plugin';
|
|
11
|
-
* attach(crewx: Crewx) {
|
|
12
|
-
* crewx.on('task:start', (e) => console.log(e.traceId));
|
|
13
|
-
* }
|
|
14
|
-
* }
|
|
15
|
-
* await crewx.use(new MyPlugin());
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.CrewxPlugin = void 0;
|
|
19
|
-
class CrewxPlugin {
|
|
20
|
-
/**
|
|
21
|
-
* Called on Crewx.close() in LIFO order.
|
|
22
|
-
* Remove event listeners and release resources here.
|
|
23
|
-
* Default: no-op.
|
|
24
|
-
*/
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
-
detach(_crewx) { }
|
|
27
|
-
}
|
|
28
|
-
exports.CrewxPlugin = CrewxPlugin;
|
|
29
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConversationPlugin = void 0;
|
|
4
|
-
const plugin_1 = require("../plugin");
|
|
5
|
-
const sqlite_provider_1 = require("../conversation/sqlite-provider");
|
|
6
|
-
class ConversationPlugin extends plugin_1.CrewxPlugin {
|
|
7
|
-
name = 'conversation';
|
|
8
|
-
_provider;
|
|
9
|
-
unsubStart = null;
|
|
10
|
-
unsubEnd = null;
|
|
11
|
-
constructor(opts) {
|
|
12
|
-
super();
|
|
13
|
-
this._provider = new sqlite_provider_1.SqliteConversationProvider(opts?.dbPath);
|
|
14
|
-
}
|
|
15
|
-
/** Expose provider for SDK history auto-fetch (WI-CONV-002). */
|
|
16
|
-
get conversationProvider() {
|
|
17
|
-
return this._provider;
|
|
18
|
-
}
|
|
19
|
-
attach(crewx) {
|
|
20
|
-
// task:start — save user message + ensure thread
|
|
21
|
-
this.unsubStart = crewx.on('task:start', async (event) => {
|
|
22
|
-
if (!event.threadId)
|
|
23
|
-
return;
|
|
24
|
-
const platform = (event.platform ?? 'cli');
|
|
25
|
-
try {
|
|
26
|
-
await this._provider.ensureThread(event.threadId, platform, event.workspaceId);
|
|
27
|
-
await this._provider.saveUserMessage(event.threadId, event.message ?? '');
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
// Non-fatal: conversation persistence must never crash the main process
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
// task:end — save assistant response (WI-CONV-002)
|
|
34
|
-
this.unsubEnd = crewx.on('task:end', async (event) => {
|
|
35
|
-
if (!event.result)
|
|
36
|
-
return;
|
|
37
|
-
// Resolve threadId from metadata propagated in task:start
|
|
38
|
-
const threadId = event.metadata?.threadId;
|
|
39
|
-
if (!threadId)
|
|
40
|
-
return;
|
|
41
|
-
const agentId = event.agentRef?.replace(/^@/, '') ?? '';
|
|
42
|
-
try {
|
|
43
|
-
await this._provider.saveAssistantMessage(threadId, event.result, agentId);
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
// Non-fatal: conversation persistence must never crash the main process
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
detach(_crewx) {
|
|
51
|
-
this.unsubStart?.();
|
|
52
|
-
this.unsubStart = null;
|
|
53
|
-
this.unsubEnd?.();
|
|
54
|
-
this.unsubEnd = null;
|
|
55
|
-
this._provider.close?.();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.ConversationPlugin = ConversationPlugin;
|
|
59
|
-
//# sourceMappingURL=conversation.js.map
|