@tryarcanist/cli 0.1.58 → 0.1.60

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 (2) hide show
  1. package/dist/index.js +96 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -586,6 +586,7 @@ function getRawSessionEventKind(event) {
586
586
  if (!isCanonicalRawSessionEvent(event)) return event.type;
587
587
  const payload = compatPayload(event);
588
588
  const bridgeEventType = compatBridgeEventType(event);
589
+ if (bridgeEventType === "prompt_activity") return "prompt_activity";
589
590
  switch (event.phase) {
590
591
  case "text.delta":
591
592
  return payload.channel === "reasoning" ? "reasoning" : "text";
@@ -814,6 +815,7 @@ function createFlattenState() {
814
815
  merged: [],
815
816
  streams: createStreamCoalescerState(),
816
817
  toolCallIndexById: /* @__PURE__ */ new Map(),
818
+ promptActivityIndexByKey: /* @__PURE__ */ new Map(),
817
819
  questionIndexById: /* @__PURE__ */ new Map()
818
820
  };
819
821
  }
@@ -893,6 +895,28 @@ function projectAgentTimeline(data, index) {
893
895
  ...resolvePromptId(data) ? { promptId: resolvePromptId(data) } : {}
894
896
  };
895
897
  }
898
+ function projectPromptActivity(data, index) {
899
+ const promptId = resolvePromptId(data);
900
+ return {
901
+ type: "prompt_activity",
902
+ id: resolveEventId(data, "pa", index),
903
+ phase: typeof data?.phase === "string" ? data.phase : "unknown",
904
+ ...typeof data?.detail === "string" ? { detail: data.detail } : {},
905
+ ...promptId ? { promptId } : {}
906
+ };
907
+ }
908
+ function projectPromptActivityEvent(data, state) {
909
+ const event = projectPromptActivity(data, state.merged.length);
910
+ const key = `${event.promptId ?? ""}\0${event.phase}\0${event.detail ?? ""}`;
911
+ const existingIdx = state.promptActivityIndexByKey.get(key);
912
+ if (existingIdx !== void 0) {
913
+ const existing = state.merged[existingIdx];
914
+ state.merged[existingIdx] = existing.type === "prompt_activity" ? { ...event, id: existing.id } : event;
915
+ return;
916
+ }
917
+ state.promptActivityIndexByKey.set(key, state.merged.length);
918
+ state.merged.push(event);
919
+ }
896
920
  function projectSessionError(data, index) {
897
921
  return {
898
922
  type: "session_error",
@@ -1060,6 +1084,9 @@ function flattenSessionEvents(raw) {
1060
1084
  case "agent_timeline":
1061
1085
  pushEvent(state, projectAgentTimeline(data, state.merged.length));
1062
1086
  break;
1087
+ case "prompt_activity":
1088
+ projectPromptActivityEvent(data, state);
1089
+ break;
1063
1090
  case "session_error":
1064
1091
  pushEvent(state, projectSessionError(data, state.merged.length));
1065
1092
  break;
@@ -1126,8 +1153,52 @@ function getEmbeddedTerminalHistory(raw) {
1126
1153
  }
1127
1154
  return null;
1128
1155
  }
1129
- function resolveAuthoritativePromptEvents(raw) {
1130
- return getEmbeddedTerminalHistory(raw) ?? raw;
1156
+ function promptActivityKey(event) {
1157
+ const data = getRawSessionEventData(event);
1158
+ return [
1159
+ getRawSessionEventPromptId(event) ?? "",
1160
+ typeof data?.phase === "string" ? data.phase : "",
1161
+ typeof data?.detail === "string" ? data.detail : ""
1162
+ ].join("\0");
1163
+ }
1164
+ function resolveAuthoritativePromptEventsWithDiagnostics(raw) {
1165
+ const embeddedHistory = getEmbeddedTerminalHistory(raw);
1166
+ const durablePromptActivity = raw.filter((event) => getRawSessionEventKind(event) === "prompt_activity");
1167
+ if (!embeddedHistory) {
1168
+ return {
1169
+ events: raw,
1170
+ diagnostics: {
1171
+ embeddedHistoryPresent: false,
1172
+ durablePromptActivityCount: durablePromptActivity.length,
1173
+ embeddedPromptActivityCount: 0,
1174
+ mergedDurablePromptActivityCount: 0,
1175
+ duplicateDurablePromptActivityCount: 0
1176
+ }
1177
+ };
1178
+ }
1179
+ const embeddedPromptActivity = embeddedHistory.filter((event) => getRawSessionEventKind(event) === "prompt_activity");
1180
+ const embeddedPromptActivityKeys = new Set(embeddedPromptActivity.map(promptActivityKey));
1181
+ const embeddedPromptActivityCount = embeddedPromptActivity.length;
1182
+ let duplicateDurablePromptActivityCount = 0;
1183
+ const missingDurablePromptActivity = durablePromptActivity.filter((event) => {
1184
+ const key = promptActivityKey(event);
1185
+ if (embeddedPromptActivityKeys.has(key)) {
1186
+ duplicateDurablePromptActivityCount += 1;
1187
+ return false;
1188
+ }
1189
+ embeddedPromptActivityKeys.add(key);
1190
+ return true;
1191
+ });
1192
+ return {
1193
+ events: missingDurablePromptActivity.length > 0 ? [...missingDurablePromptActivity, ...embeddedHistory] : embeddedHistory,
1194
+ diagnostics: {
1195
+ embeddedHistoryPresent: true,
1196
+ durablePromptActivityCount: durablePromptActivity.length,
1197
+ embeddedPromptActivityCount,
1198
+ mergedDurablePromptActivityCount: missingDurablePromptActivity.length,
1199
+ duplicateDurablePromptActivityCount
1200
+ }
1201
+ };
1131
1202
  }
1132
1203
 
1133
1204
  // ../../shared/types/error-codes.ts
@@ -1141,7 +1212,6 @@ var ERROR_CODES = [
1141
1212
  "api_error",
1142
1213
  "config_error",
1143
1214
  "doom_loop",
1144
- "tool_limit",
1145
1215
  "failed_edits",
1146
1216
  "empty_completion",
1147
1217
  "followup_not_started",
@@ -1175,7 +1245,6 @@ var ERROR_CODE_LABELS = {
1175
1245
  api_error: "Provider API error",
1176
1246
  config_error: "Configuration error",
1177
1247
  doom_loop: "Repeated failure loop",
1178
- tool_limit: "Tool limit reached",
1179
1248
  failed_edits: "Edit failure",
1180
1249
  empty_completion: "Empty completion",
1181
1250
  followup_not_started: "Follow-up did not start",
@@ -1273,6 +1342,9 @@ ${event.answer ? `**Answer:** ${event.answer}
1273
1342
  `;
1274
1343
  case "customer_activity":
1275
1344
  return `**${event.title}:** ${event.summary}
1345
+ `;
1346
+ case "prompt_activity":
1347
+ return `*[${event.detail ?? event.phase}]*
1276
1348
  `;
1277
1349
  case "raw_codex":
1278
1350
  return "";
@@ -1300,8 +1372,27 @@ function renderSessionTranscript(exportData) {
1300
1372
  for (let i = 0; i < exportData.prompts.length; i++) {
1301
1373
  const prompt = exportData.prompts[i];
1302
1374
  const rawEvents = eventBuckets.get(prompt.id) ?? [];
1303
- const authoritativeEvents = resolveAuthoritativePromptEvents(rawEvents);
1375
+ const { events: authoritativeEvents, diagnostics } = resolveAuthoritativePromptEventsWithDiagnostics(rawEvents);
1376
+ if (diagnostics.mergedDurablePromptActivityCount > 0) {
1377
+ console.error("[transcript] merged durable prompt_activity events missing from embedded terminal history", {
1378
+ sessionId: exportData.session.id,
1379
+ promptId: prompt.id,
1380
+ mergedDurablePromptActivityCount: diagnostics.mergedDurablePromptActivityCount,
1381
+ durablePromptActivityCount: diagnostics.durablePromptActivityCount,
1382
+ embeddedPromptActivityCount: diagnostics.embeddedPromptActivityCount,
1383
+ duplicateDurablePromptActivityCount: diagnostics.duplicateDurablePromptActivityCount
1384
+ });
1385
+ }
1304
1386
  const events = flattenSessionEvents(authoritativeEvents);
1387
+ const renderedPromptActivityCount = events.filter((event) => event.type === "prompt_activity").length;
1388
+ if (diagnostics.durablePromptActivityCount > 0 && renderedPromptActivityCount === 0) {
1389
+ console.error("[transcript] durable prompt_activity events did not render", {
1390
+ sessionId: exportData.session.id,
1391
+ promptId: prompt.id,
1392
+ durablePromptActivityCount: diagnostics.durablePromptActivityCount,
1393
+ authoritativeEventCount: authoritativeEvents.length
1394
+ });
1395
+ }
1305
1396
  lines.push("---\n");
1306
1397
  lines.push(`## Turn ${i + 1}
1307
1398
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.58",
3
+ "version": "0.1.60",
4
4
  "description": "CLI for Arcanist — create and manage coding agent sessions",
5
5
  "type": "module",
6
6
  "bin": {