@crewx/sdk 0.8.0-rc.79 → 0.8.0-rc.80

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