@tryarcanist/cli 0.1.59 → 0.1.61
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 +114 -17
- 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));
|
|
@@ -1153,8 +1157,79 @@ function getEmbeddedTerminalHistory(raw) {
|
|
|
1153
1157
|
}
|
|
1154
1158
|
return null;
|
|
1155
1159
|
}
|
|
1156
|
-
function
|
|
1157
|
-
|
|
1160
|
+
function promptActivityKey(event) {
|
|
1161
|
+
const data = getRawSessionEventData(event);
|
|
1162
|
+
return [
|
|
1163
|
+
getRawSessionEventPromptId(event) ?? "",
|
|
1164
|
+
typeof data?.phase === "string" ? data.phase : "",
|
|
1165
|
+
typeof data?.detail === "string" ? data.detail : ""
|
|
1166
|
+
].join("\0");
|
|
1167
|
+
}
|
|
1168
|
+
function agentProgressKey(event) {
|
|
1169
|
+
const data = getRawSessionEventData(event);
|
|
1170
|
+
return [getRawSessionEventPromptId(event) ?? "", typeof data?.step === "string" ? data.step : ""].join("\0");
|
|
1171
|
+
}
|
|
1172
|
+
function resolveAuthoritativePromptEventsWithDiagnostics(raw) {
|
|
1173
|
+
const embeddedHistory = getEmbeddedTerminalHistory(raw);
|
|
1174
|
+
const durablePromptActivity = raw.filter((event) => getRawSessionEventKind(event) === "prompt_activity");
|
|
1175
|
+
const durableAgentProgress = raw.filter((event) => getRawSessionEventKind(event) === "agent_progress");
|
|
1176
|
+
if (!embeddedHistory) {
|
|
1177
|
+
return {
|
|
1178
|
+
events: raw,
|
|
1179
|
+
diagnostics: {
|
|
1180
|
+
embeddedHistoryPresent: false,
|
|
1181
|
+
durablePromptActivityCount: durablePromptActivity.length,
|
|
1182
|
+
embeddedPromptActivityCount: 0,
|
|
1183
|
+
mergedDurablePromptActivityCount: 0,
|
|
1184
|
+
duplicateDurablePromptActivityCount: 0,
|
|
1185
|
+
durableAgentProgressCount: durableAgentProgress.length,
|
|
1186
|
+
embeddedAgentProgressCount: 0,
|
|
1187
|
+
mergedDurableAgentProgressCount: 0,
|
|
1188
|
+
duplicateDurableAgentProgressCount: 0
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
const embeddedPromptActivity = embeddedHistory.filter((event) => getRawSessionEventKind(event) === "prompt_activity");
|
|
1193
|
+
const embeddedAgentProgress = embeddedHistory.filter((event) => getRawSessionEventKind(event) === "agent_progress");
|
|
1194
|
+
const embeddedPromptActivityKeys = new Set(embeddedPromptActivity.map(promptActivityKey));
|
|
1195
|
+
const embeddedAgentProgressKeys = new Set(embeddedAgentProgress.map(agentProgressKey));
|
|
1196
|
+
const embeddedPromptActivityCount = embeddedPromptActivity.length;
|
|
1197
|
+
const embeddedAgentProgressCount = embeddedAgentProgress.length;
|
|
1198
|
+
let duplicateDurablePromptActivityCount = 0;
|
|
1199
|
+
let duplicateDurableAgentProgressCount = 0;
|
|
1200
|
+
const missingDurablePromptActivity = durablePromptActivity.filter((event) => {
|
|
1201
|
+
const key = promptActivityKey(event);
|
|
1202
|
+
if (embeddedPromptActivityKeys.has(key)) {
|
|
1203
|
+
duplicateDurablePromptActivityCount += 1;
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
embeddedPromptActivityKeys.add(key);
|
|
1207
|
+
return true;
|
|
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];
|
|
1219
|
+
return {
|
|
1220
|
+
events: missingDurableSideChannelEvents.length > 0 ? [...missingDurableSideChannelEvents, ...embeddedHistory] : embeddedHistory,
|
|
1221
|
+
diagnostics: {
|
|
1222
|
+
embeddedHistoryPresent: true,
|
|
1223
|
+
durablePromptActivityCount: durablePromptActivity.length,
|
|
1224
|
+
embeddedPromptActivityCount,
|
|
1225
|
+
mergedDurablePromptActivityCount: missingDurablePromptActivity.length,
|
|
1226
|
+
duplicateDurablePromptActivityCount,
|
|
1227
|
+
durableAgentProgressCount: durableAgentProgress.length,
|
|
1228
|
+
embeddedAgentProgressCount,
|
|
1229
|
+
mergedDurableAgentProgressCount: missingDurableAgentProgress.length,
|
|
1230
|
+
duplicateDurableAgentProgressCount
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1158
1233
|
}
|
|
1159
1234
|
|
|
1160
1235
|
// ../../shared/types/error-codes.ts
|
|
@@ -1300,7 +1375,9 @@ ${event.answer ? `**Answer:** ${event.answer}
|
|
|
1300
1375
|
return `**${event.title}:** ${event.summary}
|
|
1301
1376
|
`;
|
|
1302
1377
|
case "prompt_activity":
|
|
1303
|
-
return
|
|
1378
|
+
return "";
|
|
1379
|
+
case "agent_progress":
|
|
1380
|
+
return `*[${event.label}]*
|
|
1304
1381
|
`;
|
|
1305
1382
|
case "raw_codex":
|
|
1306
1383
|
return "";
|
|
@@ -1328,7 +1405,27 @@ function renderSessionTranscript(exportData) {
|
|
|
1328
1405
|
for (let i = 0; i < exportData.prompts.length; i++) {
|
|
1329
1406
|
const prompt = exportData.prompts[i];
|
|
1330
1407
|
const rawEvents = eventBuckets.get(prompt.id) ?? [];
|
|
1331
|
-
const authoritativeEvents =
|
|
1408
|
+
const { events: authoritativeEvents, diagnostics } = resolveAuthoritativePromptEventsWithDiagnostics(rawEvents);
|
|
1409
|
+
if (diagnostics.mergedDurablePromptActivityCount > 0) {
|
|
1410
|
+
console.error("[transcript] merged durable prompt_activity events missing from embedded terminal history", {
|
|
1411
|
+
sessionId: exportData.session.id,
|
|
1412
|
+
promptId: prompt.id,
|
|
1413
|
+
mergedDurablePromptActivityCount: diagnostics.mergedDurablePromptActivityCount,
|
|
1414
|
+
durablePromptActivityCount: diagnostics.durablePromptActivityCount,
|
|
1415
|
+
embeddedPromptActivityCount: diagnostics.embeddedPromptActivityCount,
|
|
1416
|
+
duplicateDurablePromptActivityCount: diagnostics.duplicateDurablePromptActivityCount
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
if (diagnostics.mergedDurableAgentProgressCount > 0) {
|
|
1420
|
+
console.error("[transcript] merged durable agent_progress events missing from embedded terminal history", {
|
|
1421
|
+
sessionId: exportData.session.id,
|
|
1422
|
+
promptId: prompt.id,
|
|
1423
|
+
mergedDurableAgentProgressCount: diagnostics.mergedDurableAgentProgressCount,
|
|
1424
|
+
durableAgentProgressCount: diagnostics.durableAgentProgressCount,
|
|
1425
|
+
embeddedAgentProgressCount: diagnostics.embeddedAgentProgressCount,
|
|
1426
|
+
duplicateDurableAgentProgressCount: diagnostics.duplicateDurableAgentProgressCount
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1332
1429
|
const events = flattenSessionEvents(authoritativeEvents);
|
|
1333
1430
|
lines.push("---\n");
|
|
1334
1431
|
lines.push(`## Turn ${i + 1}
|