@respan/cli 0.6.0 → 0.6.1
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/hooks/claude-code.cjs +2 -2
- package/dist/hooks/claude-code.js +2 -2
- package/dist/hooks/codex-cli.cjs +16 -5
- package/dist/hooks/codex-cli.js +17 -5
- package/dist/hooks/gemini-cli.cjs +8 -7
- package/dist/hooks/gemini-cli.js +9 -7
- package/oclif.manifest.json +483 -483
- package/package.json +1 -1
|
@@ -607,7 +607,7 @@ function createSpans(sessionId, turnNum, userMsg, assistantMsgs, toolResults, co
|
|
|
607
607
|
provider_id: "",
|
|
608
608
|
span_path: "",
|
|
609
609
|
input: promptMessages.length ? JSON.stringify(promptMessages) : "",
|
|
610
|
-
output:
|
|
610
|
+
output: finalOutput,
|
|
611
611
|
timestamp: timestampStr,
|
|
612
612
|
start_time: startTimeStr,
|
|
613
613
|
metadata,
|
|
@@ -627,7 +627,7 @@ function createSpans(sessionId, turnNum, userMsg, assistantMsgs, toolResults, co
|
|
|
627
627
|
provider_id: "anthropic",
|
|
628
628
|
metadata: {},
|
|
629
629
|
input: promptMessages.length ? JSON.stringify(promptMessages) : "",
|
|
630
|
-
output:
|
|
630
|
+
output: finalOutput,
|
|
631
631
|
prompt_messages: promptMessages,
|
|
632
632
|
completion_message: completionMessage,
|
|
633
633
|
timestamp: genEnd,
|
|
@@ -256,7 +256,7 @@ function createSpans(sessionId, turnNum, userMsg, assistantMsgs, toolResults, co
|
|
|
256
256
|
provider_id: '',
|
|
257
257
|
span_path: '',
|
|
258
258
|
input: promptMessages.length ? JSON.stringify(promptMessages) : '',
|
|
259
|
-
output:
|
|
259
|
+
output: finalOutput,
|
|
260
260
|
timestamp: timestampStr,
|
|
261
261
|
start_time: startTimeStr,
|
|
262
262
|
metadata,
|
|
@@ -277,7 +277,7 @@ function createSpans(sessionId, turnNum, userMsg, assistantMsgs, toolResults, co
|
|
|
277
277
|
provider_id: 'anthropic',
|
|
278
278
|
metadata: {},
|
|
279
279
|
input: promptMessages.length ? JSON.stringify(promptMessages) : '',
|
|
280
|
-
output:
|
|
280
|
+
output: finalOutput,
|
|
281
281
|
prompt_messages: promptMessages,
|
|
282
282
|
completion_message: completionMessage,
|
|
283
283
|
timestamp: genEnd,
|
package/dist/hooks/codex-cli.cjs
CHANGED
|
@@ -475,6 +475,7 @@ function extractTurns(events) {
|
|
|
475
475
|
tool_calls: [],
|
|
476
476
|
tool_outputs: [],
|
|
477
477
|
reasoning: false,
|
|
478
|
+
reasoning_text: "",
|
|
478
479
|
token_usage: {}
|
|
479
480
|
};
|
|
480
481
|
} else if (msgType === "task_complete" && current) {
|
|
@@ -512,13 +513,23 @@ function extractTurns(events) {
|
|
|
512
513
|
timestamp
|
|
513
514
|
});
|
|
514
515
|
} else if (itemType === "reasoning") {
|
|
515
|
-
if (current)
|
|
516
|
+
if (current) {
|
|
517
|
+
current.reasoning = true;
|
|
518
|
+
const summary = String(payload.summary ?? payload.text ?? "");
|
|
519
|
+
if (summary) current.reasoning_text += (current.reasoning_text ? "\n" : "") + summary;
|
|
520
|
+
}
|
|
516
521
|
} else if (itemType === "web_search_call") {
|
|
517
522
|
const action = payload.action ?? {};
|
|
523
|
+
const syntheticId = `web_search_${timestamp}`;
|
|
518
524
|
current.tool_calls.push({
|
|
519
525
|
name: "web_search",
|
|
520
526
|
arguments: JSON.stringify({ query: action.query ?? "" }),
|
|
521
|
-
call_id:
|
|
527
|
+
call_id: syntheticId,
|
|
528
|
+
timestamp
|
|
529
|
+
});
|
|
530
|
+
current.tool_outputs.push({
|
|
531
|
+
call_id: syntheticId,
|
|
532
|
+
output: `Search: ${action.query ?? ""}`,
|
|
522
533
|
timestamp
|
|
523
534
|
});
|
|
524
535
|
}
|
|
@@ -570,7 +581,7 @@ function createSpans(sessionId, turnNum, turn, config) {
|
|
|
570
581
|
provider_id: "",
|
|
571
582
|
span_path: "",
|
|
572
583
|
input: promptMessages.length ? JSON.stringify(promptMessages) : "",
|
|
573
|
-
output:
|
|
584
|
+
output: turn.assistant_message,
|
|
574
585
|
timestamp: endTimeStr,
|
|
575
586
|
start_time: startTimeStr,
|
|
576
587
|
metadata,
|
|
@@ -587,7 +598,7 @@ function createSpans(sessionId, turnNum, turn, config) {
|
|
|
587
598
|
provider_id: "openai",
|
|
588
599
|
metadata: {},
|
|
589
600
|
input: promptMessages.length ? JSON.stringify(promptMessages) : "",
|
|
590
|
-
output:
|
|
601
|
+
output: turn.assistant_message,
|
|
591
602
|
prompt_messages: promptMessages,
|
|
592
603
|
completion_message: completionMessage,
|
|
593
604
|
timestamp: endTimeStr,
|
|
@@ -607,7 +618,7 @@ function createSpans(sessionId, turnNum, turn, config) {
|
|
|
607
618
|
provider_id: "",
|
|
608
619
|
metadata: reasoningTokens > 0 ? { reasoning_tokens: reasoningTokens } : {},
|
|
609
620
|
input: "",
|
|
610
|
-
output: reasoningTokens > 0 ? `[Reasoning: ${reasoningTokens} tokens]` : "[Reasoning]",
|
|
621
|
+
output: turn.reasoning_text || (reasoningTokens > 0 ? `[Reasoning: ${reasoningTokens} tokens]` : "[Reasoning]"),
|
|
611
622
|
timestamp: endTimeStr,
|
|
612
623
|
start_time: startTimeStr
|
|
613
624
|
});
|
package/dist/hooks/codex-cli.js
CHANGED
|
@@ -99,6 +99,7 @@ function extractTurns(events) {
|
|
|
99
99
|
tool_calls: [],
|
|
100
100
|
tool_outputs: [],
|
|
101
101
|
reasoning: false,
|
|
102
|
+
reasoning_text: '',
|
|
102
103
|
token_usage: {},
|
|
103
104
|
};
|
|
104
105
|
}
|
|
@@ -147,15 +148,26 @@ function extractTurns(events) {
|
|
|
147
148
|
});
|
|
148
149
|
}
|
|
149
150
|
else if (itemType === 'reasoning') {
|
|
150
|
-
if (current)
|
|
151
|
+
if (current) {
|
|
151
152
|
current.reasoning = true;
|
|
153
|
+
const summary = String(payload.summary ?? payload.text ?? '');
|
|
154
|
+
if (summary)
|
|
155
|
+
current.reasoning_text += (current.reasoning_text ? '\n' : '') + summary;
|
|
156
|
+
}
|
|
152
157
|
}
|
|
153
158
|
else if (itemType === 'web_search_call') {
|
|
154
159
|
const action = (payload.action ?? {});
|
|
160
|
+
const syntheticId = `web_search_${timestamp}`;
|
|
155
161
|
current.tool_calls.push({
|
|
156
162
|
name: 'web_search',
|
|
157
163
|
arguments: JSON.stringify({ query: action.query ?? '' }),
|
|
158
|
-
call_id:
|
|
164
|
+
call_id: syntheticId,
|
|
165
|
+
timestamp,
|
|
166
|
+
});
|
|
167
|
+
// Web search has no separate output event; record query as output
|
|
168
|
+
current.tool_outputs.push({
|
|
169
|
+
call_id: syntheticId,
|
|
170
|
+
output: `Search: ${action.query ?? ''}`,
|
|
159
171
|
timestamp,
|
|
160
172
|
});
|
|
161
173
|
}
|
|
@@ -218,7 +230,7 @@ function createSpans(sessionId, turnNum, turn, config) {
|
|
|
218
230
|
provider_id: '',
|
|
219
231
|
span_path: '',
|
|
220
232
|
input: promptMessages.length ? JSON.stringify(promptMessages) : '',
|
|
221
|
-
output:
|
|
233
|
+
output: turn.assistant_message,
|
|
222
234
|
timestamp: endTimeStr,
|
|
223
235
|
start_time: startTimeStr,
|
|
224
236
|
metadata,
|
|
@@ -236,7 +248,7 @@ function createSpans(sessionId, turnNum, turn, config) {
|
|
|
236
248
|
provider_id: 'openai',
|
|
237
249
|
metadata: {},
|
|
238
250
|
input: promptMessages.length ? JSON.stringify(promptMessages) : '',
|
|
239
|
-
output:
|
|
251
|
+
output: turn.assistant_message,
|
|
240
252
|
prompt_messages: promptMessages,
|
|
241
253
|
completion_message: completionMessage,
|
|
242
254
|
timestamp: endTimeStr,
|
|
@@ -257,7 +269,7 @@ function createSpans(sessionId, turnNum, turn, config) {
|
|
|
257
269
|
provider_id: '',
|
|
258
270
|
metadata: reasoningTokens > 0 ? { reasoning_tokens: reasoningTokens } : {},
|
|
259
271
|
input: '',
|
|
260
|
-
output: reasoningTokens > 0 ? `[Reasoning: ${reasoningTokens} tokens]` : '[Reasoning]',
|
|
272
|
+
output: turn.reasoning_text || (reasoningTokens > 0 ? `[Reasoning: ${reasoningTokens} tokens]` : '[Reasoning]'),
|
|
261
273
|
timestamp: endTimeStr,
|
|
262
274
|
start_time: startTimeStr,
|
|
263
275
|
});
|
|
@@ -443,8 +443,9 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
443
443
|
spanName: "gemini-cli"
|
|
444
444
|
});
|
|
445
445
|
const safeId = sessionId.replace(/[/\\]/g, "_").slice(0, 50);
|
|
446
|
-
const
|
|
447
|
-
const
|
|
446
|
+
const turnTs = beginTime.replace(/[^0-9]/g, "").slice(0, 14);
|
|
447
|
+
const traceUniqueId = `gcli_${safeId}_${turnTs}`;
|
|
448
|
+
const rootSpanId = `gcli_${safeId}_${turnTs}_root`;
|
|
448
449
|
const threadId = `gcli_${sessionId}`;
|
|
449
450
|
const llmReq = hookData.llm_request ?? {};
|
|
450
451
|
const reqConfig = llmReq.config ?? {};
|
|
@@ -463,7 +464,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
463
464
|
provider_id: "",
|
|
464
465
|
span_path: "",
|
|
465
466
|
input: promptMessages.length ? JSON.stringify(promptMessages) : "",
|
|
466
|
-
output:
|
|
467
|
+
output: truncate(outputText, MAX_CHARS),
|
|
467
468
|
timestamp: endTime,
|
|
468
469
|
start_time: beginTime,
|
|
469
470
|
metadata,
|
|
@@ -471,7 +472,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
471
472
|
});
|
|
472
473
|
const genSpan = {
|
|
473
474
|
trace_unique_id: traceUniqueId,
|
|
474
|
-
span_unique_id: `gcli_${safeId}_gen`,
|
|
475
|
+
span_unique_id: `gcli_${safeId}_${turnTs}_gen`,
|
|
475
476
|
span_parent_id: rootSpanId,
|
|
476
477
|
span_name: "gemini.chat",
|
|
477
478
|
span_workflow_name: workflowName,
|
|
@@ -480,7 +481,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
480
481
|
provider_id: "google",
|
|
481
482
|
metadata: {},
|
|
482
483
|
input: promptMessages.length ? JSON.stringify(promptMessages) : "",
|
|
483
|
-
output:
|
|
484
|
+
output: truncate(outputText, MAX_CHARS),
|
|
484
485
|
timestamp: endTime,
|
|
485
486
|
start_time: beginTime,
|
|
486
487
|
prompt_tokens: tokens.prompt_tokens,
|
|
@@ -494,7 +495,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
494
495
|
if (thoughtsTokens > 0) {
|
|
495
496
|
spans.push({
|
|
496
497
|
trace_unique_id: traceUniqueId,
|
|
497
|
-
span_unique_id: `gcli_${safeId}_reasoning`,
|
|
498
|
+
span_unique_id: `gcli_${safeId}_${turnTs}_reasoning`,
|
|
498
499
|
span_parent_id: rootSpanId,
|
|
499
500
|
span_name: "Reasoning",
|
|
500
501
|
span_workflow_name: workflowName,
|
|
@@ -522,7 +523,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
522
523
|
const toolLat = latencySeconds(toolStart, toolEnd);
|
|
523
524
|
spans.push({
|
|
524
525
|
trace_unique_id: traceUniqueId,
|
|
525
|
-
span_unique_id: `gcli_${safeId}_tool_${i + 1}`,
|
|
526
|
+
span_unique_id: `gcli_${safeId}_${turnTs}_tool_${i + 1}`,
|
|
526
527
|
span_parent_id: rootSpanId,
|
|
527
528
|
span_name: `Tool: ${displayName}`,
|
|
528
529
|
span_workflow_name: workflowName,
|
package/dist/hooks/gemini-cli.js
CHANGED
|
@@ -146,8 +146,10 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
146
146
|
spanName: 'gemini-cli',
|
|
147
147
|
});
|
|
148
148
|
const safeId = sessionId.replace(/[/\\]/g, '_').slice(0, 50);
|
|
149
|
-
|
|
150
|
-
const
|
|
149
|
+
// Use first chunk timestamp to differentiate turns within the same session
|
|
150
|
+
const turnTs = beginTime.replace(/[^0-9]/g, '').slice(0, 14);
|
|
151
|
+
const traceUniqueId = `gcli_${safeId}_${turnTs}`;
|
|
152
|
+
const rootSpanId = `gcli_${safeId}_${turnTs}_root`;
|
|
151
153
|
const threadId = `gcli_${sessionId}`;
|
|
152
154
|
// LLM config
|
|
153
155
|
const llmReq = (hookData.llm_request ?? {});
|
|
@@ -171,7 +173,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
171
173
|
provider_id: '',
|
|
172
174
|
span_path: '',
|
|
173
175
|
input: promptMessages.length ? JSON.stringify(promptMessages) : '',
|
|
174
|
-
output:
|
|
176
|
+
output: truncate(outputText, MAX_CHARS),
|
|
175
177
|
timestamp: endTime,
|
|
176
178
|
start_time: beginTime,
|
|
177
179
|
metadata,
|
|
@@ -180,7 +182,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
180
182
|
// Generation child span
|
|
181
183
|
const genSpan = {
|
|
182
184
|
trace_unique_id: traceUniqueId,
|
|
183
|
-
span_unique_id: `gcli_${safeId}_gen`,
|
|
185
|
+
span_unique_id: `gcli_${safeId}_${turnTs}_gen`,
|
|
184
186
|
span_parent_id: rootSpanId,
|
|
185
187
|
span_name: 'gemini.chat',
|
|
186
188
|
span_workflow_name: workflowName,
|
|
@@ -189,7 +191,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
189
191
|
provider_id: 'google',
|
|
190
192
|
metadata: {},
|
|
191
193
|
input: promptMessages.length ? JSON.stringify(promptMessages) : '',
|
|
192
|
-
output:
|
|
194
|
+
output: truncate(outputText, MAX_CHARS),
|
|
193
195
|
timestamp: endTime,
|
|
194
196
|
start_time: beginTime,
|
|
195
197
|
prompt_tokens: tokens.prompt_tokens,
|
|
@@ -206,7 +208,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
206
208
|
if (thoughtsTokens > 0) {
|
|
207
209
|
spans.push({
|
|
208
210
|
trace_unique_id: traceUniqueId,
|
|
209
|
-
span_unique_id: `gcli_${safeId}_reasoning`,
|
|
211
|
+
span_unique_id: `gcli_${safeId}_${turnTs}_reasoning`,
|
|
210
212
|
span_parent_id: rootSpanId,
|
|
211
213
|
span_name: 'Reasoning',
|
|
212
214
|
span_workflow_name: workflowName,
|
|
@@ -237,7 +239,7 @@ function buildSpans(hookData, outputText, tokens, config, startTimeIso, toolTurn
|
|
|
237
239
|
const toolLat = latencySeconds(toolStart, toolEnd);
|
|
238
240
|
spans.push({
|
|
239
241
|
trace_unique_id: traceUniqueId,
|
|
240
|
-
span_unique_id: `gcli_${safeId}_tool_${i + 1}`,
|
|
242
|
+
span_unique_id: `gcli_${safeId}_${turnTs}_tool_${i + 1}`,
|
|
241
243
|
span_parent_id: rootSpanId,
|
|
242
244
|
span_name: `Tool: ${displayName}`,
|
|
243
245
|
span_workflow_name: workflowName,
|