@meistrari/tela-cli 0.7.42 → 0.7.44
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/index.js +285 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3446,6 +3446,7 @@ var require_run = __commonJS({
|
|
|
3446
3446
|
exports2.addLocalAgentRunInputs = addLocalAgentRunInputs;
|
|
3447
3447
|
exports2.removeLocalAgentRunInput = removeLocalAgentRunInput;
|
|
3448
3448
|
exports2.createInitialRunSnapshot = createInitialRunSnapshot;
|
|
3449
|
+
exports2.getDefaultAgentRunsRoot = getDefaultAgentRunsRoot;
|
|
3449
3450
|
exports2.runLocalAgentCommand = runLocalAgentCommand;
|
|
3450
3451
|
exports2.renderRunExecutionRecap = renderRunExecutionRecap;
|
|
3451
3452
|
exports2.renderRunArtifactCard = renderRunArtifactCard;
|
|
@@ -3473,6 +3474,7 @@ var require_run = __commonJS({
|
|
|
3473
3474
|
];
|
|
3474
3475
|
var TOOL_PROGRESS_MILESTONES = [0, 5, 15, 30];
|
|
3475
3476
|
var RUN_ARCHIVE_SCHEMA_VERSION = 1;
|
|
3477
|
+
var LIVE_DEBUG_SNAPSHOT_INTERVAL_MS = 1e3;
|
|
3476
3478
|
function writeLine2(writer, line) {
|
|
3477
3479
|
const message = `${line}
|
|
3478
3480
|
`;
|
|
@@ -3626,7 +3628,7 @@ var require_run = __commonJS({
|
|
|
3626
3628
|
const detail = summarizeToolInput(name, input);
|
|
3627
3629
|
return detail ? { summary: truncate(`${name} ${detail}`), detail: `${name}: ${detail}` } : { summary: name };
|
|
3628
3630
|
}
|
|
3629
|
-
function
|
|
3631
|
+
function extractMessageUsage(message) {
|
|
3630
3632
|
if (!message || typeof message !== "object")
|
|
3631
3633
|
return void 0;
|
|
3632
3634
|
const usage = message.usage;
|
|
@@ -3635,6 +3637,21 @@ var require_run = __commonJS({
|
|
|
3635
3637
|
const usageRecord = usage;
|
|
3636
3638
|
const input = safeNumber(usageRecord.input_tokens) ?? 0;
|
|
3637
3639
|
const output = safeNumber(usageRecord.output_tokens) ?? 0;
|
|
3640
|
+
const cached = safeNumber(usageRecord.cache_read_input_tokens) ?? safeNumber(usageRecord.cache_read_tokens) ?? 0;
|
|
3641
|
+
if (input <= 0 && output <= 0 && cached <= 0)
|
|
3642
|
+
return void 0;
|
|
3643
|
+
return {
|
|
3644
|
+
inputTokens: input,
|
|
3645
|
+
outputTokens: output,
|
|
3646
|
+
cachedTokens: cached
|
|
3647
|
+
};
|
|
3648
|
+
}
|
|
3649
|
+
function extractMessageTokens(message) {
|
|
3650
|
+
const usage = extractMessageUsage(message);
|
|
3651
|
+
if (!usage)
|
|
3652
|
+
return void 0;
|
|
3653
|
+
const input = usage.inputTokens;
|
|
3654
|
+
const output = usage.outputTokens;
|
|
3638
3655
|
const total = input + output;
|
|
3639
3656
|
return total > 0 ? total : void 0;
|
|
3640
3657
|
}
|
|
@@ -3763,6 +3780,7 @@ var require_run = __commonJS({
|
|
|
3763
3780
|
summary: "Claude session started.",
|
|
3764
3781
|
detail: safeString(event.cwd),
|
|
3765
3782
|
model: safeString(event.model),
|
|
3783
|
+
claudeSessionId: safeString(event.session_id),
|
|
3766
3784
|
recordStep: true
|
|
3767
3785
|
}];
|
|
3768
3786
|
case "status": {
|
|
@@ -3845,6 +3863,7 @@ var require_run = __commonJS({
|
|
|
3845
3863
|
const normalized = [];
|
|
3846
3864
|
const parentToolUseId = safeString(event.parent_tool_use_id);
|
|
3847
3865
|
const tokens = extractMessageTokens(event.message);
|
|
3866
|
+
const usage = extractMessageUsage(event.message);
|
|
3848
3867
|
const text = extractAssistantText(event.message);
|
|
3849
3868
|
if (text.trim()) {
|
|
3850
3869
|
const summary = summarizeLines(text);
|
|
@@ -3855,7 +3874,9 @@ var require_run = __commonJS({
|
|
|
3855
3874
|
detail: summary.detail,
|
|
3856
3875
|
recordStep: true,
|
|
3857
3876
|
parentToolUseId,
|
|
3858
|
-
tokens
|
|
3877
|
+
tokens,
|
|
3878
|
+
usage,
|
|
3879
|
+
startsTurn: !parentToolUseId
|
|
3859
3880
|
});
|
|
3860
3881
|
}
|
|
3861
3882
|
const toolUses = extractAssistantToolUses(event.message);
|
|
@@ -3863,8 +3884,11 @@ var require_run = __commonJS({
|
|
|
3863
3884
|
const batch = buildToolBatchEvent(buildDerivedToolSummary(toolUses), toolUses);
|
|
3864
3885
|
if (batch.kind === "tool_batch") {
|
|
3865
3886
|
batch.parentToolUseId = parentToolUseId;
|
|
3887
|
+
batch.startsTurn = !parentToolUseId && normalized.length === 0;
|
|
3866
3888
|
if (tokens != null && normalized.length === 0)
|
|
3867
3889
|
batch.tokens = tokens;
|
|
3890
|
+
if (usage && normalized.length === 0)
|
|
3891
|
+
batch.usage = usage;
|
|
3868
3892
|
}
|
|
3869
3893
|
normalized.push(batch);
|
|
3870
3894
|
}
|
|
@@ -3920,7 +3944,8 @@ var require_run = __commonJS({
|
|
|
3920
3944
|
text,
|
|
3921
3945
|
summary: summary.summary,
|
|
3922
3946
|
detail: summary.detail,
|
|
3923
|
-
recordStep: true
|
|
3947
|
+
recordStep: true,
|
|
3948
|
+
startsTurn: true
|
|
3924
3949
|
}];
|
|
3925
3950
|
}
|
|
3926
3951
|
case "tool_use_summary": {
|
|
@@ -3983,6 +4008,38 @@ var require_run = __commonJS({
|
|
|
3983
4008
|
const elapsed = timeElapsed != null && Number.isFinite(timeElapsed) ? ` timeElapsed="${String(timeElapsed).replace(/"/g, """)}"` : "";
|
|
3984
4009
|
return `<step${elapsed}>${escapeReasoningStepContent(content)}</step>`;
|
|
3985
4010
|
}
|
|
4011
|
+
function mapRunStatusToDebugTimelineStatus(status) {
|
|
4012
|
+
switch (status) {
|
|
4013
|
+
case "success":
|
|
4014
|
+
return "completed";
|
|
4015
|
+
case "failed":
|
|
4016
|
+
return "failed";
|
|
4017
|
+
case "cancelled":
|
|
4018
|
+
return "cancelled";
|
|
4019
|
+
case "running":
|
|
4020
|
+
return "running";
|
|
4021
|
+
case "starting":
|
|
4022
|
+
default:
|
|
4023
|
+
return "pending";
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
function getTimelineToolCategory(toolName) {
|
|
4027
|
+
const normalized = toolName?.toLowerCase() ?? "";
|
|
4028
|
+
if (includesAny(normalized, ["bash", "shell", "exec", "command", "terminal"]))
|
|
4029
|
+
return "shell";
|
|
4030
|
+
if (includesAny(normalized, ["grep", "glob", "search", "find", "lsp"]))
|
|
4031
|
+
return "search";
|
|
4032
|
+
if (includesAny(normalized, ["read", "fetch", "get", "open", "view"]))
|
|
4033
|
+
return "file";
|
|
4034
|
+
if (includesAny(normalized, ["write", "edit", "patch", "replace", "update", "insert", "delete", "move", "apply"]))
|
|
4035
|
+
return "edit";
|
|
4036
|
+
if (includesAny(normalized, ["web", "url", "browser"]))
|
|
4037
|
+
return "web";
|
|
4038
|
+
return "other";
|
|
4039
|
+
}
|
|
4040
|
+
function includesAny(value, needles) {
|
|
4041
|
+
return needles.some((needle) => value.includes(needle));
|
|
4042
|
+
}
|
|
3986
4043
|
function normalizeToolInput(input) {
|
|
3987
4044
|
if (isRecord2(input)) {
|
|
3988
4045
|
return input;
|
|
@@ -4000,11 +4057,19 @@ var require_run = __commonJS({
|
|
|
4000
4057
|
reasoningSteps = [];
|
|
4001
4058
|
activeTools = /* @__PURE__ */ new Map();
|
|
4002
4059
|
subagentBuckets = /* @__PURE__ */ new Map();
|
|
4060
|
+
timelineEvents = [];
|
|
4061
|
+
timelineToolEventIndexes = /* @__PURE__ */ new Map();
|
|
4062
|
+
runTurns = [];
|
|
4063
|
+
debugSessionId = (0, node_crypto_1.randomUUID)();
|
|
4003
4064
|
execution;
|
|
4004
4065
|
stepIndex = 0;
|
|
4066
|
+
sequenceIndex = 0;
|
|
4067
|
+
runTurnIndex = 0;
|
|
4005
4068
|
status = "starting";
|
|
4006
4069
|
currentActivity = "Preparing Claude run\u2026";
|
|
4007
4070
|
model;
|
|
4071
|
+
claudeSessionId = null;
|
|
4072
|
+
currentRunTurnId = null;
|
|
4008
4073
|
constructor(prepared, mode, startedAtMs = Date.now()) {
|
|
4009
4074
|
this.prepared = prepared;
|
|
4010
4075
|
this.mode = mode;
|
|
@@ -4027,6 +4092,163 @@ var require_run = __commonJS({
|
|
|
4027
4092
|
notable
|
|
4028
4093
|
});
|
|
4029
4094
|
}
|
|
4095
|
+
elapsedMs() {
|
|
4096
|
+
return Math.max(0, Date.now() - this.startedAtMs);
|
|
4097
|
+
}
|
|
4098
|
+
eventClock() {
|
|
4099
|
+
const relativeTimeMs = this.elapsedMs();
|
|
4100
|
+
return {
|
|
4101
|
+
relativeTimeMs,
|
|
4102
|
+
timestamp: this.startedAtMs + relativeTimeMs
|
|
4103
|
+
};
|
|
4104
|
+
}
|
|
4105
|
+
startRunTurn(startMs = this.elapsedMs()) {
|
|
4106
|
+
const lastTurn = this.runTurns.at(-1);
|
|
4107
|
+
if (lastTurn && lastTurn.endMs == null) {
|
|
4108
|
+
lastTurn.endMs = Math.max(lastTurn.startMs, startMs);
|
|
4109
|
+
}
|
|
4110
|
+
const id = `run-turn-${++this.runTurnIndex}`;
|
|
4111
|
+
this.runTurns.push({
|
|
4112
|
+
id,
|
|
4113
|
+
startMs
|
|
4114
|
+
});
|
|
4115
|
+
this.currentRunTurnId = id;
|
|
4116
|
+
return id;
|
|
4117
|
+
}
|
|
4118
|
+
ensureRunTurn() {
|
|
4119
|
+
return this.currentRunTurnId ?? this.startRunTurn();
|
|
4120
|
+
}
|
|
4121
|
+
finishRunTurn(endMs = this.elapsedMs()) {
|
|
4122
|
+
const turn = this.currentRunTurnId ? this.runTurns.find((candidate) => candidate.id === this.currentRunTurnId) : this.runTurns.at(-1);
|
|
4123
|
+
if (turn) {
|
|
4124
|
+
turn.endMs = Math.max(turn.startMs, endMs);
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
addTimelineTextEvent(event) {
|
|
4128
|
+
if (event.startsTurn) {
|
|
4129
|
+
this.startRunTurn();
|
|
4130
|
+
}
|
|
4131
|
+
const { relativeTimeMs, timestamp } = this.eventClock();
|
|
4132
|
+
this.timelineEvents.push({
|
|
4133
|
+
type: "text",
|
|
4134
|
+
relativeTimeMs,
|
|
4135
|
+
timestamp,
|
|
4136
|
+
sequenceIndex: ++this.sequenceIndex,
|
|
4137
|
+
runTurnId: this.ensureRunTurn(),
|
|
4138
|
+
tokensIn: event.usage?.inputTokens,
|
|
4139
|
+
tokensOut: event.usage?.outputTokens,
|
|
4140
|
+
cachedTokens: event.usage?.cachedTokens,
|
|
4141
|
+
text: event.text,
|
|
4142
|
+
displaySummary: event.summary
|
|
4143
|
+
});
|
|
4144
|
+
}
|
|
4145
|
+
addTimelineToolEvents(event) {
|
|
4146
|
+
if (event.startsTurn) {
|
|
4147
|
+
this.startRunTurn();
|
|
4148
|
+
}
|
|
4149
|
+
for (let index = 0; index < event.tools.length; index += 1) {
|
|
4150
|
+
const tool = event.tools[index];
|
|
4151
|
+
const includeUsage = index === 0;
|
|
4152
|
+
const { relativeTimeMs, timestamp } = this.eventClock();
|
|
4153
|
+
const timelineEvent = {
|
|
4154
|
+
type: "tool_call",
|
|
4155
|
+
relativeTimeMs,
|
|
4156
|
+
timestamp,
|
|
4157
|
+
sequenceIndex: ++this.sequenceIndex,
|
|
4158
|
+
runTurnId: this.ensureRunTurn(),
|
|
4159
|
+
...includeUsage && event.usage ? {
|
|
4160
|
+
tokensIn: event.usage.inputTokens,
|
|
4161
|
+
tokensOut: event.usage.outputTokens,
|
|
4162
|
+
cachedTokens: event.usage.cachedTokens
|
|
4163
|
+
} : {},
|
|
4164
|
+
toolName: tool.name,
|
|
4165
|
+
callId: tool.id,
|
|
4166
|
+
arguments: normalizeToolInput(tool.input),
|
|
4167
|
+
displaySummary: tool.detail ?? tool.summary,
|
|
4168
|
+
category: getTimelineToolCategory(tool.name)
|
|
4169
|
+
};
|
|
4170
|
+
this.timelineToolEventIndexes.set(tool.id, this.timelineEvents.length);
|
|
4171
|
+
this.timelineEvents.push(timelineEvent);
|
|
4172
|
+
}
|
|
4173
|
+
}
|
|
4174
|
+
completeTimelineToolEvent(event) {
|
|
4175
|
+
const index = this.timelineToolEventIndexes.get(event.toolUseId);
|
|
4176
|
+
if (index == null)
|
|
4177
|
+
return;
|
|
4178
|
+
const existing = this.timelineEvents[index];
|
|
4179
|
+
if (!existing || existing.type !== "tool_call")
|
|
4180
|
+
return;
|
|
4181
|
+
const endMs = this.elapsedMs();
|
|
4182
|
+
existing.status = event.isError ? "failed" : "success";
|
|
4183
|
+
existing.result = {
|
|
4184
|
+
output: event.output,
|
|
4185
|
+
isError: event.isError,
|
|
4186
|
+
durationMs: Math.max(0, endMs - existing.relativeTimeMs)
|
|
4187
|
+
};
|
|
4188
|
+
}
|
|
4189
|
+
buildDebugTimeline() {
|
|
4190
|
+
const events = this.timelineEvents.map((event) => ({
|
|
4191
|
+
...event,
|
|
4192
|
+
result: event.result ? { ...event.result } : void 0,
|
|
4193
|
+
arguments: event.arguments ? { ...event.arguments } : void 0
|
|
4194
|
+
}));
|
|
4195
|
+
const fallbackEndMs = this.execution.durationMs ?? this.elapsedMs();
|
|
4196
|
+
const turns = this.runTurns.length > 0 ? this.runTurns : [{ id: "run-turn-1", startMs: 0, endMs: fallbackEndMs }];
|
|
4197
|
+
const timelineStatus = mapRunStatusToDebugTimelineStatus(this.status);
|
|
4198
|
+
const spans = turns.map((turn) => {
|
|
4199
|
+
const turnEvents = events.filter((event) => event.runTurnId === turn.id);
|
|
4200
|
+
const isOpenTurn = turn.endMs == null && (timelineStatus === "running" || timelineStatus === "pending");
|
|
4201
|
+
const endCandidates = [
|
|
4202
|
+
turn.endMs,
|
|
4203
|
+
isOpenTurn ? fallbackEndMs : void 0,
|
|
4204
|
+
...turnEvents.map((event) => {
|
|
4205
|
+
const duration = event.type === "tool_call" ? event.result?.durationMs ?? 0 : 0;
|
|
4206
|
+
return event.relativeTimeMs + duration;
|
|
4207
|
+
})
|
|
4208
|
+
].filter((value) => typeof value === "number" && Number.isFinite(value));
|
|
4209
|
+
const endMs = Math.max(turn.startMs, endCandidates.length > 0 ? Math.max(...endCandidates) : fallbackEndMs);
|
|
4210
|
+
return {
|
|
4211
|
+
id: turn.id,
|
|
4212
|
+
type: "run_turn",
|
|
4213
|
+
parentId: null,
|
|
4214
|
+
startMs: turn.startMs,
|
|
4215
|
+
endMs,
|
|
4216
|
+
metrics: {
|
|
4217
|
+
tokensIn: turnEvents.reduce((sum, event) => sum + (event.tokensIn ?? 0), 0),
|
|
4218
|
+
tokensOut: turnEvents.reduce((sum, event) => sum + (event.tokensOut ?? 0), 0),
|
|
4219
|
+
cachedTokens: turnEvents.reduce((sum, event) => sum + (event.cachedTokens ?? 0), 0),
|
|
4220
|
+
costUsd: turnEvents.reduce((sum, event) => sum + (event.costUsd ?? 0), 0),
|
|
4221
|
+
toolCallCount: turnEvents.filter((event) => event.type === "tool_call").length,
|
|
4222
|
+
apiCallCount: 1
|
|
4223
|
+
}
|
|
4224
|
+
};
|
|
4225
|
+
});
|
|
4226
|
+
const tokensIn = events.reduce((sum, event) => sum + (event.tokensIn ?? 0), 0);
|
|
4227
|
+
const tokensOut = events.reduce((sum, event) => sum + (event.tokensOut ?? 0), 0);
|
|
4228
|
+
const cachedTokens = events.reduce((sum, event) => sum + (event.cachedTokens ?? 0), 0);
|
|
4229
|
+
return {
|
|
4230
|
+
sessionId: this.debugSessionId,
|
|
4231
|
+
status: timelineStatus,
|
|
4232
|
+
metrics: {
|
|
4233
|
+
durationMs: fallbackEndMs,
|
|
4234
|
+
toolCalls: events.filter((event) => event.type === "tool_call").length,
|
|
4235
|
+
apiCalls: this.execution.numTurns ?? spans.length,
|
|
4236
|
+
tokensIn,
|
|
4237
|
+
tokensOut,
|
|
4238
|
+
cachedTokens,
|
|
4239
|
+
totalCostUsd: this.execution.totalCostUsd ?? events.reduce((sum, event) => sum + (event.costUsd ?? 0), 0),
|
|
4240
|
+
cacheSavingsUsd: 0
|
|
4241
|
+
},
|
|
4242
|
+
prompt: {
|
|
4243
|
+
model: this.model ?? null,
|
|
4244
|
+
claudeSessionId: this.claudeSessionId,
|
|
4245
|
+
timestamp: this.startedAtMs,
|
|
4246
|
+
text: INITIAL_PROMPT
|
|
4247
|
+
},
|
|
4248
|
+
events,
|
|
4249
|
+
spans
|
|
4250
|
+
};
|
|
4251
|
+
}
|
|
4030
4252
|
pushReasoningStep(parentToolUseId, step) {
|
|
4031
4253
|
if (parentToolUseId && this.subagentBuckets.has(parentToolUseId)) {
|
|
4032
4254
|
this.subagentBuckets.get(parentToolUseId).reasoningSteps.push(step);
|
|
@@ -4118,6 +4340,7 @@ var require_run = __commonJS({
|
|
|
4118
4340
|
this.execution.status = "running";
|
|
4119
4341
|
this.currentActivity = event.summary;
|
|
4120
4342
|
this.model = event.model ?? this.model;
|
|
4343
|
+
this.claudeSessionId = event.claudeSessionId ?? this.claudeSessionId;
|
|
4121
4344
|
if (event.recordStep) {
|
|
4122
4345
|
this.addStep("status", event.summary, event.detail);
|
|
4123
4346
|
this.addReasoningText(event.detail ? `${event.summary}
|
|
@@ -4134,6 +4357,9 @@ ${event.detail}` : event.summary);
|
|
|
4134
4357
|
this.execution.status = "running";
|
|
4135
4358
|
this.currentActivity = event.summary;
|
|
4136
4359
|
this.addReasoningText(event.text, event.parentToolUseId);
|
|
4360
|
+
if (!event.parentToolUseId) {
|
|
4361
|
+
this.addTimelineTextEvent(event);
|
|
4362
|
+
}
|
|
4137
4363
|
if (isSubagent && event.tokens != null) {
|
|
4138
4364
|
this.subagentBuckets.get(event.parentToolUseId).totalTokens += event.tokens;
|
|
4139
4365
|
}
|
|
@@ -4161,6 +4387,9 @@ ${event.detail}` : event.summary);
|
|
|
4161
4387
|
this.subagentBuckets.get(event.parentToolUseId).totalToolUseCount += 1;
|
|
4162
4388
|
}
|
|
4163
4389
|
}
|
|
4390
|
+
if (!event.parentToolUseId) {
|
|
4391
|
+
this.addTimelineToolEvents(event);
|
|
4392
|
+
}
|
|
4164
4393
|
if (isSubagent && event.tokens != null) {
|
|
4165
4394
|
this.subagentBuckets.get(event.parentToolUseId).totalTokens += event.tokens;
|
|
4166
4395
|
}
|
|
@@ -4182,6 +4411,9 @@ ${event.detail}` : event.summary);
|
|
|
4182
4411
|
}
|
|
4183
4412
|
case "tool_result":
|
|
4184
4413
|
this.addReasoningToolResult(event.toolUseId, event.output, event.isError, event.parentToolUseId);
|
|
4414
|
+
if (!event.parentToolUseId) {
|
|
4415
|
+
this.completeTimelineToolEvent(event);
|
|
4416
|
+
}
|
|
4185
4417
|
break;
|
|
4186
4418
|
case "status_notice":
|
|
4187
4419
|
this.status = "running";
|
|
@@ -4258,6 +4490,7 @@ ${event.detail}` : event.summary);
|
|
|
4258
4490
|
this.addStep("result", event.summary, event.detail, event.execution.status !== "success");
|
|
4259
4491
|
this.addReasoningText(event.detail ? `${event.summary}
|
|
4260
4492
|
${event.detail}` : event.summary);
|
|
4493
|
+
this.finishRunTurn();
|
|
4261
4494
|
break;
|
|
4262
4495
|
}
|
|
4263
4496
|
return this.snapshot();
|
|
@@ -4282,7 +4515,8 @@ ${event.detail}` : event.summary);
|
|
|
4282
4515
|
this.addReasoningText(detail?.errors?.length ? `${summary}
|
|
4283
4516
|
${detail.errors.join("\n")}` : summary);
|
|
4284
4517
|
}
|
|
4285
|
-
|
|
4518
|
+
this.finishRunTurn();
|
|
4519
|
+
return this.snapshot(true);
|
|
4286
4520
|
}
|
|
4287
4521
|
buildSubagentReasoningById() {
|
|
4288
4522
|
if (this.subagentBuckets.size === 0)
|
|
@@ -4293,19 +4527,23 @@ ${detail.errors.join("\n")}` : summary);
|
|
|
4293
4527
|
}
|
|
4294
4528
|
return result;
|
|
4295
4529
|
}
|
|
4296
|
-
snapshot() {
|
|
4530
|
+
snapshot(includeDebugTimeline = false) {
|
|
4297
4531
|
return {
|
|
4298
4532
|
repoRoot: this.prepared.repoRoot,
|
|
4299
4533
|
mode: this.mode,
|
|
4300
4534
|
model: this.model,
|
|
4301
4535
|
artifactPath: this.prepared.resultPath,
|
|
4302
4536
|
sourceResultPath: this.prepared.resultPath,
|
|
4537
|
+
runDirectory: this.prepared.repoRoot,
|
|
4538
|
+
inputDirectory: (0, node_path_1.join)(this.prepared.repoRoot, "input"),
|
|
4539
|
+
outputDirectory: (0, node_path_1.join)(this.prepared.repoRoot, "output"),
|
|
4303
4540
|
startedAtMs: this.startedAtMs,
|
|
4304
4541
|
status: this.status,
|
|
4305
4542
|
currentActivity: this.currentActivity,
|
|
4306
4543
|
steps: this.steps.map((step) => ({ ...step })),
|
|
4307
4544
|
reasoningMarkup: this.reasoningSteps.join(""),
|
|
4308
4545
|
subagentReasoningById: this.buildSubagentReasoningById(),
|
|
4546
|
+
debugTimeline: includeDebugTimeline ? this.buildDebugTimeline() : void 0,
|
|
4309
4547
|
outputSchema: this.prepared.outputSchema,
|
|
4310
4548
|
activeTools: Array.from(this.activeTools.values()).map((tool) => ({ ...tool })),
|
|
4311
4549
|
execution: {
|
|
@@ -4950,17 +5188,40 @@ Input folder: ${comparableInputRoot}`,
|
|
|
4950
5188
|
return { stagedPath };
|
|
4951
5189
|
}
|
|
4952
5190
|
function createInitialRunSnapshot(prepared, mode = prepared.config.isMultiturn ? "chat" : "one-shot") {
|
|
5191
|
+
const startedAtMs = Date.now();
|
|
4953
5192
|
return {
|
|
4954
5193
|
repoRoot: prepared.repoRoot,
|
|
4955
5194
|
mode,
|
|
4956
5195
|
model: prepared.config.model,
|
|
4957
5196
|
artifactPath: prepared.resultPath,
|
|
4958
5197
|
sourceResultPath: prepared.resultPath,
|
|
4959
|
-
startedAtMs
|
|
5198
|
+
startedAtMs,
|
|
4960
5199
|
status: "starting",
|
|
4961
5200
|
currentActivity: mode === "chat" ? "Preparing Claude chat handoff\u2026" : "Validating repository contract\u2026",
|
|
4962
5201
|
steps: [],
|
|
4963
5202
|
reasoningMarkup: "",
|
|
5203
|
+
debugTimeline: {
|
|
5204
|
+
sessionId: (0, node_crypto_1.randomUUID)(),
|
|
5205
|
+
status: "pending",
|
|
5206
|
+
metrics: {
|
|
5207
|
+
durationMs: 0,
|
|
5208
|
+
toolCalls: 0,
|
|
5209
|
+
apiCalls: 0,
|
|
5210
|
+
tokensIn: 0,
|
|
5211
|
+
tokensOut: 0,
|
|
5212
|
+
cachedTokens: 0,
|
|
5213
|
+
totalCostUsd: 0,
|
|
5214
|
+
cacheSavingsUsd: 0
|
|
5215
|
+
},
|
|
5216
|
+
prompt: {
|
|
5217
|
+
model: prepared.config.model ?? null,
|
|
5218
|
+
claudeSessionId: null,
|
|
5219
|
+
timestamp: startedAtMs,
|
|
5220
|
+
text: INITIAL_PROMPT
|
|
5221
|
+
},
|
|
5222
|
+
events: [],
|
|
5223
|
+
spans: []
|
|
5224
|
+
},
|
|
4964
5225
|
outputSchema: prepared.outputSchema,
|
|
4965
5226
|
activeTools: [],
|
|
4966
5227
|
execution: {
|
|
@@ -5125,6 +5386,8 @@ Input folder: ${comparableInputRoot}`,
|
|
|
5125
5386
|
execution: input.execution,
|
|
5126
5387
|
steps: input.snapshot.steps,
|
|
5127
5388
|
reasoningMarkup: input.snapshot.reasoningMarkup,
|
|
5389
|
+
subagentReasoningById: input.snapshot.subagentReasoningById,
|
|
5390
|
+
debugTimeline: input.snapshot.debugTimeline,
|
|
5128
5391
|
inputs: input.inputs
|
|
5129
5392
|
}), "utf-8");
|
|
5130
5393
|
} catch (error) {
|
|
@@ -5281,6 +5544,7 @@ Input folder: ${comparableInputRoot}`,
|
|
|
5281
5544
|
steps: snapshot.steps,
|
|
5282
5545
|
reasoningMarkup: snapshot.reasoningMarkup,
|
|
5283
5546
|
subagentReasoningById: snapshot.subagentReasoningById,
|
|
5547
|
+
debugTimeline: snapshot.debugTimeline,
|
|
5284
5548
|
outputSchema: prepared.outputSchema,
|
|
5285
5549
|
artifact: {
|
|
5286
5550
|
path: archived.resultPath,
|
|
@@ -5344,7 +5608,7 @@ Input folder: ${comparableInputRoot}`,
|
|
|
5344
5608
|
const notifySnapshot = (snapshot2) => {
|
|
5345
5609
|
options.onSnapshot?.(snapshot2);
|
|
5346
5610
|
};
|
|
5347
|
-
notifySnapshot(tracker.snapshot());
|
|
5611
|
+
notifySnapshot(tracker.snapshot(true));
|
|
5348
5612
|
if (options.surface === "plain") {
|
|
5349
5613
|
writeLine2(options.writeStdout, "Streaming Claude execution in one-shot mode.");
|
|
5350
5614
|
}
|
|
@@ -5387,6 +5651,12 @@ Input folder: ${comparableInputRoot}`,
|
|
|
5387
5651
|
}
|
|
5388
5652
|
}
|
|
5389
5653
|
});
|
|
5654
|
+
const liveDebugSnapshotTimer = setInterval(() => {
|
|
5655
|
+
const snapshot2 = tracker.snapshot(true);
|
|
5656
|
+
if (snapshot2.status === "running" || snapshot2.status === "starting") {
|
|
5657
|
+
notifySnapshot(snapshot2);
|
|
5658
|
+
}
|
|
5659
|
+
}, LIVE_DEBUG_SNAPSHOT_INTERVAL_MS);
|
|
5390
5660
|
options.onControl?.({
|
|
5391
5661
|
interrupt() {
|
|
5392
5662
|
cancelled = true;
|
|
@@ -5397,8 +5667,13 @@ Input folder: ${comparableInputRoot}`,
|
|
|
5397
5667
|
handle.kill();
|
|
5398
5668
|
}
|
|
5399
5669
|
});
|
|
5400
|
-
|
|
5401
|
-
|
|
5670
|
+
let result;
|
|
5671
|
+
try {
|
|
5672
|
+
result = await handle.result;
|
|
5673
|
+
} finally {
|
|
5674
|
+
clearInterval(liveDebugSnapshotTimer);
|
|
5675
|
+
}
|
|
5676
|
+
let snapshot = tracker.snapshot(true);
|
|
5402
5677
|
if (result.exitCode !== 0) {
|
|
5403
5678
|
if (cancelled) {
|
|
5404
5679
|
snapshot = tracker.finalize("cancelled", {
|
|
@@ -5467,7 +5742,7 @@ Input folder: ${comparableInputRoot}`,
|
|
|
5467
5742
|
snapshot = await runOneShotAgent(prepared, effectiveOptions, tracker, claudeLaunch);
|
|
5468
5743
|
}
|
|
5469
5744
|
} catch (error) {
|
|
5470
|
-
let terminalSnapshot = tracker.snapshot();
|
|
5745
|
+
let terminalSnapshot = tracker.snapshot(true);
|
|
5471
5746
|
let archiveFailureWarning;
|
|
5472
5747
|
if (error instanceof process_1.CommandError && terminalSnapshot.execution.status !== "failed" && terminalSnapshot.execution.status !== "cancelled") {
|
|
5473
5748
|
terminalSnapshot = tracker.finalize("failed", {
|