@tryarcanist/cli 0.1.60 → 0.1.62
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 +57 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -587,6 +587,7 @@ function getRawSessionEventKind(event) {
|
|
|
587
587
|
const payload = compatPayload(event);
|
|
588
588
|
const bridgeEventType = compatBridgeEventType(event);
|
|
589
589
|
if (bridgeEventType === "prompt_activity") return "prompt_activity";
|
|
590
|
+
if (bridgeEventType === "agent_progress") return "agent_progress";
|
|
590
591
|
switch (event.phase) {
|
|
591
592
|
case "text.delta":
|
|
592
593
|
return payload.channel === "reasoning" ? "reasoning" : "text";
|
|
@@ -815,7 +816,7 @@ function createFlattenState() {
|
|
|
815
816
|
merged: [],
|
|
816
817
|
streams: createStreamCoalescerState(),
|
|
817
818
|
toolCallIndexById: /* @__PURE__ */ new Map(),
|
|
818
|
-
|
|
819
|
+
agentProgressIndexByKey: /* @__PURE__ */ new Map(),
|
|
819
820
|
questionIndexById: /* @__PURE__ */ new Map()
|
|
820
821
|
};
|
|
821
822
|
}
|
|
@@ -895,26 +896,27 @@ function projectAgentTimeline(data, index) {
|
|
|
895
896
|
...resolvePromptId(data) ? { promptId: resolvePromptId(data) } : {}
|
|
896
897
|
};
|
|
897
898
|
}
|
|
898
|
-
function
|
|
899
|
+
function projectAgentProgress(data, index) {
|
|
899
900
|
const promptId = resolvePromptId(data);
|
|
900
901
|
return {
|
|
901
|
-
type: "
|
|
902
|
-
id: resolveEventId(data, "
|
|
903
|
-
|
|
904
|
-
|
|
902
|
+
type: "agent_progress",
|
|
903
|
+
id: resolveEventId(data, "ap", index),
|
|
904
|
+
step: typeof data?.step === "string" ? data.step : "unknown",
|
|
905
|
+
label: typeof data?.label === "string" ? data.label : "Working",
|
|
906
|
+
terminal: data?.terminal === true,
|
|
905
907
|
...promptId ? { promptId } : {}
|
|
906
908
|
};
|
|
907
909
|
}
|
|
908
|
-
function
|
|
909
|
-
const event =
|
|
910
|
-
const key = `${event.promptId ?? ""}\0${event.
|
|
911
|
-
const existingIdx = state.
|
|
910
|
+
function projectAgentProgressEvent(data, state) {
|
|
911
|
+
const event = projectAgentProgress(data, state.merged.length);
|
|
912
|
+
const key = `${event.promptId ?? ""}\0${event.step}`;
|
|
913
|
+
const existingIdx = state.agentProgressIndexByKey.get(key);
|
|
912
914
|
if (existingIdx !== void 0) {
|
|
913
915
|
const existing = state.merged[existingIdx];
|
|
914
|
-
state.merged[existingIdx] = existing.type === "
|
|
916
|
+
state.merged[existingIdx] = existing.type === "agent_progress" ? { ...event, id: existing.id } : event;
|
|
915
917
|
return;
|
|
916
918
|
}
|
|
917
|
-
state.
|
|
919
|
+
state.agentProgressIndexByKey.set(key, state.merged.length);
|
|
918
920
|
state.merged.push(event);
|
|
919
921
|
}
|
|
920
922
|
function projectSessionError(data, index) {
|
|
@@ -1085,7 +1087,9 @@ function flattenSessionEvents(raw) {
|
|
|
1085
1087
|
pushEvent(state, projectAgentTimeline(data, state.merged.length));
|
|
1086
1088
|
break;
|
|
1087
1089
|
case "prompt_activity":
|
|
1088
|
-
|
|
1090
|
+
break;
|
|
1091
|
+
case "agent_progress":
|
|
1092
|
+
projectAgentProgressEvent(data, state);
|
|
1089
1093
|
break;
|
|
1090
1094
|
case "session_error":
|
|
1091
1095
|
pushEvent(state, projectSessionError(data, state.merged.length));
|
|
@@ -1161,9 +1165,14 @@ function promptActivityKey(event) {
|
|
|
1161
1165
|
typeof data?.detail === "string" ? data.detail : ""
|
|
1162
1166
|
].join("\0");
|
|
1163
1167
|
}
|
|
1168
|
+
function agentProgressKey(event) {
|
|
1169
|
+
const data = getRawSessionEventData(event);
|
|
1170
|
+
return [getRawSessionEventPromptId(event) ?? "", typeof data?.step === "string" ? data.step : ""].join("\0");
|
|
1171
|
+
}
|
|
1164
1172
|
function resolveAuthoritativePromptEventsWithDiagnostics(raw) {
|
|
1165
1173
|
const embeddedHistory = getEmbeddedTerminalHistory(raw);
|
|
1166
1174
|
const durablePromptActivity = raw.filter((event) => getRawSessionEventKind(event) === "prompt_activity");
|
|
1175
|
+
const durableAgentProgress = raw.filter((event) => getRawSessionEventKind(event) === "agent_progress");
|
|
1167
1176
|
if (!embeddedHistory) {
|
|
1168
1177
|
return {
|
|
1169
1178
|
events: raw,
|
|
@@ -1172,14 +1181,22 @@ function resolveAuthoritativePromptEventsWithDiagnostics(raw) {
|
|
|
1172
1181
|
durablePromptActivityCount: durablePromptActivity.length,
|
|
1173
1182
|
embeddedPromptActivityCount: 0,
|
|
1174
1183
|
mergedDurablePromptActivityCount: 0,
|
|
1175
|
-
duplicateDurablePromptActivityCount: 0
|
|
1184
|
+
duplicateDurablePromptActivityCount: 0,
|
|
1185
|
+
durableAgentProgressCount: durableAgentProgress.length,
|
|
1186
|
+
embeddedAgentProgressCount: 0,
|
|
1187
|
+
mergedDurableAgentProgressCount: 0,
|
|
1188
|
+
duplicateDurableAgentProgressCount: 0
|
|
1176
1189
|
}
|
|
1177
1190
|
};
|
|
1178
1191
|
}
|
|
1179
1192
|
const embeddedPromptActivity = embeddedHistory.filter((event) => getRawSessionEventKind(event) === "prompt_activity");
|
|
1193
|
+
const embeddedAgentProgress = embeddedHistory.filter((event) => getRawSessionEventKind(event) === "agent_progress");
|
|
1180
1194
|
const embeddedPromptActivityKeys = new Set(embeddedPromptActivity.map(promptActivityKey));
|
|
1195
|
+
const embeddedAgentProgressKeys = new Set(embeddedAgentProgress.map(agentProgressKey));
|
|
1181
1196
|
const embeddedPromptActivityCount = embeddedPromptActivity.length;
|
|
1197
|
+
const embeddedAgentProgressCount = embeddedAgentProgress.length;
|
|
1182
1198
|
let duplicateDurablePromptActivityCount = 0;
|
|
1199
|
+
let duplicateDurableAgentProgressCount = 0;
|
|
1183
1200
|
const missingDurablePromptActivity = durablePromptActivity.filter((event) => {
|
|
1184
1201
|
const key = promptActivityKey(event);
|
|
1185
1202
|
if (embeddedPromptActivityKeys.has(key)) {
|
|
@@ -1189,14 +1206,28 @@ function resolveAuthoritativePromptEventsWithDiagnostics(raw) {
|
|
|
1189
1206
|
embeddedPromptActivityKeys.add(key);
|
|
1190
1207
|
return true;
|
|
1191
1208
|
});
|
|
1209
|
+
const missingDurableAgentProgress = durableAgentProgress.filter((event) => {
|
|
1210
|
+
const key = agentProgressKey(event);
|
|
1211
|
+
if (embeddedAgentProgressKeys.has(key)) {
|
|
1212
|
+
duplicateDurableAgentProgressCount += 1;
|
|
1213
|
+
return false;
|
|
1214
|
+
}
|
|
1215
|
+
embeddedAgentProgressKeys.add(key);
|
|
1216
|
+
return true;
|
|
1217
|
+
});
|
|
1218
|
+
const missingDurableSideChannelEvents = [...missingDurablePromptActivity, ...missingDurableAgentProgress];
|
|
1192
1219
|
return {
|
|
1193
|
-
events:
|
|
1220
|
+
events: missingDurableSideChannelEvents.length > 0 ? [...missingDurableSideChannelEvents, ...embeddedHistory] : embeddedHistory,
|
|
1194
1221
|
diagnostics: {
|
|
1195
1222
|
embeddedHistoryPresent: true,
|
|
1196
1223
|
durablePromptActivityCount: durablePromptActivity.length,
|
|
1197
1224
|
embeddedPromptActivityCount,
|
|
1198
1225
|
mergedDurablePromptActivityCount: missingDurablePromptActivity.length,
|
|
1199
|
-
duplicateDurablePromptActivityCount
|
|
1226
|
+
duplicateDurablePromptActivityCount,
|
|
1227
|
+
durableAgentProgressCount: durableAgentProgress.length,
|
|
1228
|
+
embeddedAgentProgressCount,
|
|
1229
|
+
mergedDurableAgentProgressCount: missingDurableAgentProgress.length,
|
|
1230
|
+
duplicateDurableAgentProgressCount
|
|
1200
1231
|
}
|
|
1201
1232
|
};
|
|
1202
1233
|
}
|
|
@@ -1344,7 +1375,9 @@ ${event.answer ? `**Answer:** ${event.answer}
|
|
|
1344
1375
|
return `**${event.title}:** ${event.summary}
|
|
1345
1376
|
`;
|
|
1346
1377
|
case "prompt_activity":
|
|
1347
|
-
return
|
|
1378
|
+
return "";
|
|
1379
|
+
case "agent_progress":
|
|
1380
|
+
return `*[${event.label}]*
|
|
1348
1381
|
`;
|
|
1349
1382
|
case "raw_codex":
|
|
1350
1383
|
return "";
|
|
@@ -1383,16 +1416,17 @@ function renderSessionTranscript(exportData) {
|
|
|
1383
1416
|
duplicateDurablePromptActivityCount: diagnostics.duplicateDurablePromptActivityCount
|
|
1384
1417
|
});
|
|
1385
1418
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
if (diagnostics.durablePromptActivityCount > 0 && renderedPromptActivityCount === 0) {
|
|
1389
|
-
console.error("[transcript] durable prompt_activity events did not render", {
|
|
1419
|
+
if (diagnostics.mergedDurableAgentProgressCount > 0) {
|
|
1420
|
+
console.error("[transcript] merged durable agent_progress events missing from embedded terminal history", {
|
|
1390
1421
|
sessionId: exportData.session.id,
|
|
1391
1422
|
promptId: prompt.id,
|
|
1392
|
-
|
|
1393
|
-
|
|
1423
|
+
mergedDurableAgentProgressCount: diagnostics.mergedDurableAgentProgressCount,
|
|
1424
|
+
durableAgentProgressCount: diagnostics.durableAgentProgressCount,
|
|
1425
|
+
embeddedAgentProgressCount: diagnostics.embeddedAgentProgressCount,
|
|
1426
|
+
duplicateDurableAgentProgressCount: diagnostics.duplicateDurableAgentProgressCount
|
|
1394
1427
|
});
|
|
1395
1428
|
}
|
|
1429
|
+
const events = flattenSessionEvents(authoritativeEvents);
|
|
1396
1430
|
lines.push("---\n");
|
|
1397
1431
|
lines.push(`## Turn ${i + 1}
|
|
1398
1432
|
`);
|