@tryarcanist/cli 0.1.53 → 0.1.54
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 +3 -85
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -523,7 +523,6 @@ function isRecord(value) {
|
|
|
523
523
|
|
|
524
524
|
// ../../shared/transcript/projector.ts
|
|
525
525
|
var DUPLICATE_TEXT_DELTA_MIN_CHARS = 24;
|
|
526
|
-
var SUBAGENT_EVENT_TYPES = /* @__PURE__ */ new Set(["subagent_start", "subagent_complete", "subagent_tool_call", "subagent_text"]);
|
|
527
526
|
var RAW_CODEX_NOISE = /* @__PURE__ */ new Set([
|
|
528
527
|
"session.updated",
|
|
529
528
|
"session.diff",
|
|
@@ -1129,66 +1128,6 @@ function getEmbeddedTerminalHistory(raw) {
|
|
|
1129
1128
|
function resolveAuthoritativePromptEvents(raw) {
|
|
1130
1129
|
return getEmbeddedTerminalHistory(raw) ?? raw;
|
|
1131
1130
|
}
|
|
1132
|
-
function extractSubagentInfo(raw) {
|
|
1133
|
-
const empty = {
|
|
1134
|
-
names: /* @__PURE__ */ new Map(),
|
|
1135
|
-
activity: /* @__PURE__ */ new Map(),
|
|
1136
|
-
toolToChildSessions: /* @__PURE__ */ new Map(),
|
|
1137
|
-
subagentUsage: /* @__PURE__ */ new Map()
|
|
1138
|
-
};
|
|
1139
|
-
if (!raw.some((event) => SUBAGENT_EVENT_TYPES.has(getRawSessionEventKind(event)))) return empty;
|
|
1140
|
-
const { names, activity, toolToChildSessions, subagentUsage } = empty;
|
|
1141
|
-
for (const event of raw) {
|
|
1142
|
-
const type = getRawSessionEventKind(event);
|
|
1143
|
-
const data = getRawSessionEventData(event);
|
|
1144
|
-
if (!data) continue;
|
|
1145
|
-
const childSessionId = typeof data.childSessionId === "string" ? data.childSessionId : void 0;
|
|
1146
|
-
const parentToolId = typeof data.parentToolId === "string" ? data.parentToolId : void 0;
|
|
1147
|
-
const key = childSessionId || parentToolId;
|
|
1148
|
-
if (!key) continue;
|
|
1149
|
-
if (type === "subagent_start" || type === "subagent_complete") {
|
|
1150
|
-
const name = typeof data.name === "string" ? data.name : "";
|
|
1151
|
-
if (name) names.set(key, name);
|
|
1152
|
-
if (parentToolId && childSessionId) {
|
|
1153
|
-
const existing = toolToChildSessions.get(parentToolId) ?? [];
|
|
1154
|
-
if (!existing.includes(childSessionId)) existing.push(childSessionId);
|
|
1155
|
-
toolToChildSessions.set(parentToolId, existing);
|
|
1156
|
-
}
|
|
1157
|
-
if (type === "subagent_complete" && isRecord(data.tokenUsage)) {
|
|
1158
|
-
subagentUsage.set(key, {
|
|
1159
|
-
input: Number(data.tokenUsage.input ?? 0),
|
|
1160
|
-
output: Number(data.tokenUsage.output ?? 0),
|
|
1161
|
-
cacheRead: Number(data.tokenUsage.cacheRead ?? 0),
|
|
1162
|
-
cacheWrite: Number(data.tokenUsage.cacheWrite ?? 0)
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
continue;
|
|
1166
|
-
}
|
|
1167
|
-
if (type === "subagent_tool_call") {
|
|
1168
|
-
const items = activity.get(key) ?? [];
|
|
1169
|
-
items.push({
|
|
1170
|
-
type: "tool",
|
|
1171
|
-
tool: typeof data.tool === "string" ? data.tool : "unknown",
|
|
1172
|
-
summary: typeof data.summary === "string" ? data.summary : ""
|
|
1173
|
-
});
|
|
1174
|
-
activity.set(key, items);
|
|
1175
|
-
continue;
|
|
1176
|
-
}
|
|
1177
|
-
if (type === "subagent_text") {
|
|
1178
|
-
const delta = typeof data.delta === "string" ? data.delta : typeof data.text === "string" ? data.text : "";
|
|
1179
|
-
if (!delta) continue;
|
|
1180
|
-
const items = activity.get(key) ?? [];
|
|
1181
|
-
const last = items[items.length - 1];
|
|
1182
|
-
if (last?.type === "text") {
|
|
1183
|
-
items[items.length - 1] = { ...last, text: last.text + delta };
|
|
1184
|
-
} else {
|
|
1185
|
-
items.push({ type: "text", text: delta });
|
|
1186
|
-
}
|
|
1187
|
-
activity.set(key, items);
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
return { names, activity, toolToChildSessions, subagentUsage };
|
|
1191
|
-
}
|
|
1192
1131
|
|
|
1193
1132
|
// ../../shared/types/error-codes.ts
|
|
1194
1133
|
var ERROR_CODES = [
|
|
@@ -1276,33 +1215,13 @@ function formatDate(value) {
|
|
|
1276
1215
|
if (Number.isNaN(date.getTime())) return value;
|
|
1277
1216
|
return date.toISOString().replace("T", " ").replace(/\.\d+Z$/, " UTC");
|
|
1278
1217
|
}
|
|
1279
|
-
function
|
|
1280
|
-
if (item.type === "text") return ` - ${item.text}
|
|
1281
|
-
`;
|
|
1282
|
-
return ` - **Tool:** ${item.tool}${item.summary ? ` - ${item.summary}` : ""}
|
|
1283
|
-
`;
|
|
1284
|
-
}
|
|
1285
|
-
function renderSubagentActivityForTool(toolId, subagents) {
|
|
1286
|
-
const childSessionIds = subagents.toolToChildSessions.get(toolId) ?? [];
|
|
1287
|
-
if (childSessionIds.length === 0) return "";
|
|
1288
|
-
const lines = [];
|
|
1289
|
-
for (const childSessionId of childSessionIds) {
|
|
1290
|
-
const name = subagents.names.get(childSessionId);
|
|
1291
|
-
lines.push(` - **Subagent:** ${name ?? childSessionId}`);
|
|
1292
|
-
for (const item of subagents.activity.get(childSessionId) ?? []) {
|
|
1293
|
-
lines.push(renderSubagentActivityItem(item).trimEnd());
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
return `${lines.join("\n")}
|
|
1297
|
-
`;
|
|
1298
|
-
}
|
|
1299
|
-
function renderTranscriptEvent(event, subagents) {
|
|
1218
|
+
function renderTranscriptEvent(event) {
|
|
1300
1219
|
switch (event.type) {
|
|
1301
1220
|
case "text":
|
|
1302
1221
|
return event.text;
|
|
1303
1222
|
case "tool_call":
|
|
1304
1223
|
return `**Tool call:** ${event.tool}${event.summary ? ` - ${event.summary}` : ""}${event.toolStatus ? ` (${event.toolStatus})` : ""}
|
|
1305
|
-
|
|
1224
|
+
`;
|
|
1306
1225
|
case "reasoning":
|
|
1307
1226
|
return `<details><summary>Reasoning</summary>
|
|
1308
1227
|
|
|
@@ -1378,7 +1297,6 @@ function renderSessionTranscript(exportData) {
|
|
|
1378
1297
|
const rawEvents = eventBuckets.get(prompt.id) ?? [];
|
|
1379
1298
|
const authoritativeEvents = resolveAuthoritativePromptEvents(rawEvents);
|
|
1380
1299
|
const events = flattenSessionEvents(authoritativeEvents);
|
|
1381
|
-
const subagents = extractSubagentInfo(authoritativeEvents);
|
|
1382
1300
|
lines.push("---\n");
|
|
1383
1301
|
lines.push(`## Turn ${i + 1}
|
|
1384
1302
|
`);
|
|
@@ -1392,7 +1310,7 @@ function renderSessionTranscript(exportData) {
|
|
|
1392
1310
|
lines.push("**Assistant:**\n");
|
|
1393
1311
|
let pendingText = "";
|
|
1394
1312
|
for (const event of events) {
|
|
1395
|
-
const rendered = renderTranscriptEvent(event
|
|
1313
|
+
const rendered = renderTranscriptEvent(event);
|
|
1396
1314
|
if (!rendered) continue;
|
|
1397
1315
|
if (event.type === "text") {
|
|
1398
1316
|
pendingText += rendered;
|