replicas-cli 0.2.700 → 0.2.701
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.cjs +275 -303
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22917,6 +22917,9 @@ var QUEUED_MESSAGE_REMOVED_EVENT_TYPE = "replicas-queued-message-removed";
|
|
|
22917
22917
|
var REMOVED_MESSAGE_IDS_PAYLOAD_KEY = "removedMessageIds";
|
|
22918
22918
|
var USER_MESSAGE_ID_PAYLOAD_KEY = "replicasMessageId";
|
|
22919
22919
|
var CODEX_ASP_ITEM_ID_PAYLOAD_KEY = "codexAspItemId";
|
|
22920
|
+
var CODEX_ITEM_EVENT_TYPE = "codex-item";
|
|
22921
|
+
var CODEX_ITEM_PARTIAL_EVENT_TYPE = "codex-item-partial";
|
|
22922
|
+
var CODEX_TURN_EVENT_TYPE = "codex-turn";
|
|
22920
22923
|
var CODEX_QUOTA_STATUS_EVENT_TYPE = "codex-quota-status";
|
|
22921
22924
|
var CHAT_INTERRUPTED_EVENT_TYPE = "replicas-interrupted";
|
|
22922
22925
|
var AUTH_FALLBACK_EVENT_TYPE = "auth-fallback";
|
|
@@ -23030,6 +23033,38 @@ function getCodexAspTurnResponse(turn) {
|
|
|
23030
23033
|
if (normalizeCodexAspTranscriptStatus(turn.status) === "in_progress") return null;
|
|
23031
23034
|
return turn.items.findLast((item) => item.type === "agentMessage") ?? null;
|
|
23032
23035
|
}
|
|
23036
|
+
function isTranscriptItemStatus(value) {
|
|
23037
|
+
return value === "in_progress" || value === "completed" || value === "failed";
|
|
23038
|
+
}
|
|
23039
|
+
var CODEX_ITEM_FIELD_CHECKS = {
|
|
23040
|
+
userMessage: (item) => typeof item.content === "string",
|
|
23041
|
+
agentMessage: (item) => typeof item.text === "string",
|
|
23042
|
+
reasoning: (item) => typeof item.text === "string" && isTranscriptItemStatus(item.status),
|
|
23043
|
+
commandExecution: (item) => typeof item.command === "string" && isTranscriptItemStatus(item.status),
|
|
23044
|
+
fileChange: (item) => Array.isArray(item.operations) && isTranscriptItemStatus(item.status),
|
|
23045
|
+
toolCall: (item) => typeof item.server === "string" && typeof item.tool === "string" && isTranscriptItemStatus(item.status),
|
|
23046
|
+
subagent: (item) => typeof item.description === "string" && typeof item.prompt === "string" && typeof item.subagentType === "string" && isTranscriptItemStatus(item.status),
|
|
23047
|
+
webSearch: (item) => typeof item.query === "string" && isTranscriptItemStatus(item.status),
|
|
23048
|
+
plan: (item) => typeof item.text === "string" && isTranscriptItemStatus(item.status),
|
|
23049
|
+
contextCompaction: (item) => isTranscriptItemStatus(item.status),
|
|
23050
|
+
error: (item) => typeof item.message === "string"
|
|
23051
|
+
};
|
|
23052
|
+
function isCodexAspTranscriptItem(value) {
|
|
23053
|
+
if (!isRecord(value) || typeof value.id !== "string" || typeof value.timestamp !== "string") return false;
|
|
23054
|
+
if (value.sequence !== void 0 && typeof value.sequence !== "number") return false;
|
|
23055
|
+
if (typeof value.type !== "string" || !Object.hasOwn(CODEX_ITEM_FIELD_CHECKS, value.type)) return false;
|
|
23056
|
+
return CODEX_ITEM_FIELD_CHECKS[value.type](value);
|
|
23057
|
+
}
|
|
23058
|
+
function codexItemFromEvent(event) {
|
|
23059
|
+
if (event.type !== CODEX_ITEM_EVENT_TYPE && event.type !== CODEX_ITEM_PARTIAL_EVENT_TYPE) return null;
|
|
23060
|
+
const { turnId, item } = event.payload;
|
|
23061
|
+
return typeof turnId === "string" && isCodexAspTranscriptItem(item) ? { turnId, item } : null;
|
|
23062
|
+
}
|
|
23063
|
+
function codexTurnFromEvent(event) {
|
|
23064
|
+
if (event.type !== CODEX_TURN_EVENT_TYPE) return null;
|
|
23065
|
+
const { turnId, status, error: error51 } = event.payload;
|
|
23066
|
+
return typeof turnId === "string" && typeof status === "string" ? { turnId, status, ...typeof error51 === "string" ? { error: error51 } : {} } : null;
|
|
23067
|
+
}
|
|
23033
23068
|
|
|
23034
23069
|
// ../shared/src/display-message/types.ts
|
|
23035
23070
|
var BACKGROUND_TASK_SUBTYPES = /* @__PURE__ */ new Set([
|
|
@@ -25008,6 +25043,201 @@ function removeReplicasInstructions(text) {
|
|
|
25008
25043
|
return removeTag(text, REPLICAS_INSTRUCTIONS_TAG);
|
|
25009
25044
|
}
|
|
25010
25045
|
|
|
25046
|
+
// ../shared/src/display-message/parsers/codex-asp-parser.ts
|
|
25047
|
+
function collectCodexTurns(events) {
|
|
25048
|
+
const turns = /* @__PURE__ */ new Map();
|
|
25049
|
+
const turnFor = (id) => {
|
|
25050
|
+
const existing = turns.get(id);
|
|
25051
|
+
if (existing) return existing;
|
|
25052
|
+
const turn = { id, status: "inProgress", items: [] };
|
|
25053
|
+
turns.set(id, turn);
|
|
25054
|
+
return turn;
|
|
25055
|
+
};
|
|
25056
|
+
for (const event of events) {
|
|
25057
|
+
const item = codexItemFromEvent(event);
|
|
25058
|
+
if (item) {
|
|
25059
|
+
const turn = turnFor(item.turnId);
|
|
25060
|
+
const index = turn.items.findIndex((candidate) => candidate.id === item.item.id);
|
|
25061
|
+
if (index === -1) turn.items.push(item.item);
|
|
25062
|
+
else turn.items[index] = item.item;
|
|
25063
|
+
continue;
|
|
25064
|
+
}
|
|
25065
|
+
const turnEvent = codexTurnFromEvent(event);
|
|
25066
|
+
if (turnEvent) {
|
|
25067
|
+
const turn = turnFor(turnEvent.turnId);
|
|
25068
|
+
turn.status = turnEvent.status;
|
|
25069
|
+
turn.completedAt = event.timestamp;
|
|
25070
|
+
turn.error = turnEvent.error;
|
|
25071
|
+
}
|
|
25072
|
+
}
|
|
25073
|
+
return turns;
|
|
25074
|
+
}
|
|
25075
|
+
function messagesForCodexTurn(turn) {
|
|
25076
|
+
const items = turn.items.map((item, index) => ({ item, index })).sort((a, b) => parseTimestampMs(a.item.timestamp) - parseTimestampMs(b.item.timestamp) || a.index - b.index).map(({ item }) => item);
|
|
25077
|
+
const reasoning = items.filter(
|
|
25078
|
+
(item) => item.type === "reasoning" && item.text.trim().length > 0
|
|
25079
|
+
);
|
|
25080
|
+
const firstReasoningIndex = items.findIndex((item) => item.type === "reasoning");
|
|
25081
|
+
const coalesced = items.flatMap((item, index) => {
|
|
25082
|
+
if (item.type !== "reasoning") return [item];
|
|
25083
|
+
if (index !== firstReasoningIndex || reasoning.length === 0) return [];
|
|
25084
|
+
return [{
|
|
25085
|
+
type: "reasoning",
|
|
25086
|
+
id: turn.id,
|
|
25087
|
+
text: reasoning.map(({ text }) => text.trim()).join("\n\n"),
|
|
25088
|
+
timestamp: reasoning[0].timestamp,
|
|
25089
|
+
status: reasoning.at(-1)?.status ?? "completed"
|
|
25090
|
+
}];
|
|
25091
|
+
});
|
|
25092
|
+
const response = getCodexAspTurnResponse({ status: turn.status, items: coalesced });
|
|
25093
|
+
const reasoningIndex = coalesced.findIndex((item) => item.type === "reasoning");
|
|
25094
|
+
const responseIndex = response ? coalesced.indexOf(response) : -1;
|
|
25095
|
+
if (responseIndex !== -1 && reasoningIndex > responseIndex) {
|
|
25096
|
+
coalesced.splice(responseIndex, 0, ...coalesced.splice(reasoningIndex, 1));
|
|
25097
|
+
}
|
|
25098
|
+
const messages = coalesced.flatMap((item) => {
|
|
25099
|
+
const message = messageForItem(item);
|
|
25100
|
+
return [...message ? [message] : [], ...skillMessagesForItem(item)];
|
|
25101
|
+
});
|
|
25102
|
+
if (turn.error) {
|
|
25103
|
+
messages.push({
|
|
25104
|
+
id: `error-${turn.id}`,
|
|
25105
|
+
type: "error",
|
|
25106
|
+
message: turn.error,
|
|
25107
|
+
timestamp: turn.completedAt ?? items.at(-1)?.timestamp ?? (/* @__PURE__ */ new Date(0)).toISOString()
|
|
25108
|
+
});
|
|
25109
|
+
}
|
|
25110
|
+
return messages;
|
|
25111
|
+
}
|
|
25112
|
+
function inputForDisplay(input) {
|
|
25113
|
+
if (input === void 0 || input === null) return void 0;
|
|
25114
|
+
if (typeof input === "string") return input;
|
|
25115
|
+
if (isRecord(input)) return input;
|
|
25116
|
+
return String(input);
|
|
25117
|
+
}
|
|
25118
|
+
function isInternalUserMessage(content) {
|
|
25119
|
+
const trimmed = content.trim();
|
|
25120
|
+
return trimmed.startsWith("<environment_context>") || trimmed.startsWith("<goal_context>");
|
|
25121
|
+
}
|
|
25122
|
+
function messageForItem(item) {
|
|
25123
|
+
if (item.type === "userMessage") {
|
|
25124
|
+
if (isInternalUserMessage(item.content)) return null;
|
|
25125
|
+
return {
|
|
25126
|
+
id: `user-${item.id}`,
|
|
25127
|
+
type: "user",
|
|
25128
|
+
content: item.content,
|
|
25129
|
+
images: item.images,
|
|
25130
|
+
timestamp: item.timestamp
|
|
25131
|
+
};
|
|
25132
|
+
}
|
|
25133
|
+
if (item.type === "agentMessage" || item.type === "plan") {
|
|
25134
|
+
if (!item.text) return null;
|
|
25135
|
+
return {
|
|
25136
|
+
id: `agent-${item.id}`,
|
|
25137
|
+
type: "agent",
|
|
25138
|
+
content: item.text,
|
|
25139
|
+
timestamp: item.timestamp,
|
|
25140
|
+
...item.type === "plan" ? { isPlan: true } : {}
|
|
25141
|
+
};
|
|
25142
|
+
}
|
|
25143
|
+
if (item.type === "reasoning") {
|
|
25144
|
+
if (!item.text) return null;
|
|
25145
|
+
return {
|
|
25146
|
+
id: `reasoning-${item.id}`,
|
|
25147
|
+
type: "reasoning",
|
|
25148
|
+
content: item.text,
|
|
25149
|
+
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
25150
|
+
timestamp: item.timestamp,
|
|
25151
|
+
...item.sourceTimestamp ? { sourceTimestamp: item.sourceTimestamp } : {}
|
|
25152
|
+
};
|
|
25153
|
+
}
|
|
25154
|
+
if (item.type === "commandExecution") {
|
|
25155
|
+
const skillNames = skillNamesFromCommand(item.command);
|
|
25156
|
+
return {
|
|
25157
|
+
id: `command-${item.id}`,
|
|
25158
|
+
type: "command",
|
|
25159
|
+
command: item.command,
|
|
25160
|
+
...skillNames.length > 0 ? { skillNames } : {},
|
|
25161
|
+
output: item.output,
|
|
25162
|
+
exitCode: item.exitCode ?? void 0,
|
|
25163
|
+
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
25164
|
+
timestamp: item.timestamp
|
|
25165
|
+
};
|
|
25166
|
+
}
|
|
25167
|
+
if (item.type === "fileChange") {
|
|
25168
|
+
return {
|
|
25169
|
+
id: `patch-${item.id}`,
|
|
25170
|
+
type: "patch",
|
|
25171
|
+
operations: item.operations,
|
|
25172
|
+
output: item.output,
|
|
25173
|
+
exitCode: item.exitCode ?? void 0,
|
|
25174
|
+
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
25175
|
+
timestamp: item.timestamp
|
|
25176
|
+
};
|
|
25177
|
+
}
|
|
25178
|
+
if (item.type === "toolCall") {
|
|
25179
|
+
return createCallDisplayMessage({
|
|
25180
|
+
id: `toolcall-${item.id}`,
|
|
25181
|
+
server: item.server,
|
|
25182
|
+
tool: item.tool,
|
|
25183
|
+
input: inputForDisplay(item.input),
|
|
25184
|
+
output: item.output,
|
|
25185
|
+
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
25186
|
+
timestamp: item.timestamp
|
|
25187
|
+
});
|
|
25188
|
+
}
|
|
25189
|
+
if (item.type === "subagent") {
|
|
25190
|
+
return {
|
|
25191
|
+
id: `subagent-${item.id}`,
|
|
25192
|
+
type: "subagent",
|
|
25193
|
+
toolUseId: item.id,
|
|
25194
|
+
description: item.description,
|
|
25195
|
+
prompt: item.prompt,
|
|
25196
|
+
subagentType: item.subagentType,
|
|
25197
|
+
...item.receiverThreadIds ? { receiverThreadIds: item.receiverThreadIds } : {},
|
|
25198
|
+
...item.model ? { model: item.model } : {},
|
|
25199
|
+
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
25200
|
+
...item.output ? { output: item.output } : {},
|
|
25201
|
+
nestedEvents: [],
|
|
25202
|
+
timestamp: item.timestamp
|
|
25203
|
+
};
|
|
25204
|
+
}
|
|
25205
|
+
if (item.type === "webSearch") {
|
|
25206
|
+
return {
|
|
25207
|
+
id: `web-search-${item.id}`,
|
|
25208
|
+
type: "web_search",
|
|
25209
|
+
query: item.query,
|
|
25210
|
+
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
25211
|
+
timestamp: item.timestamp
|
|
25212
|
+
};
|
|
25213
|
+
}
|
|
25214
|
+
if (item.type === "contextCompaction") {
|
|
25215
|
+
return {
|
|
25216
|
+
id: `reasoning-${item.id}`,
|
|
25217
|
+
type: "reasoning",
|
|
25218
|
+
content: "Context compacted",
|
|
25219
|
+
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
25220
|
+
timestamp: item.timestamp
|
|
25221
|
+
};
|
|
25222
|
+
}
|
|
25223
|
+
return {
|
|
25224
|
+
id: `error-${item.id}`,
|
|
25225
|
+
type: "error",
|
|
25226
|
+
message: item.message,
|
|
25227
|
+
timestamp: item.timestamp
|
|
25228
|
+
};
|
|
25229
|
+
}
|
|
25230
|
+
function skillMessagesForItem(item) {
|
|
25231
|
+
if (item.type !== "userMessage" || !item.skillNames) return [];
|
|
25232
|
+
return item.skillNames.filter((skillName) => skillName.trim().length > 0).map((skillName, index) => ({
|
|
25233
|
+
id: `skill-${item.id}-${index}`,
|
|
25234
|
+
type: "skill",
|
|
25235
|
+
skillName,
|
|
25236
|
+
status: "completed",
|
|
25237
|
+
timestamp: item.timestamp
|
|
25238
|
+
}));
|
|
25239
|
+
}
|
|
25240
|
+
|
|
25011
25241
|
// ../shared/src/display-message/parsers/codex-parser.ts
|
|
25012
25242
|
function getStatusFromExitCode(exitCode) {
|
|
25013
25243
|
return exitCode === 0 ? "completed" : "failed";
|
|
@@ -25082,17 +25312,29 @@ function parsePatch(input) {
|
|
|
25082
25312
|
}
|
|
25083
25313
|
function parseCodexEvents(events) {
|
|
25084
25314
|
const messages = [];
|
|
25315
|
+
const turns = collectCodexTurns(events);
|
|
25316
|
+
const turnInsertions = [];
|
|
25085
25317
|
const pendingCommands = /* @__PURE__ */ new Map();
|
|
25086
25318
|
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
25087
25319
|
const pendingPatches = /* @__PURE__ */ new Map();
|
|
25088
25320
|
events.forEach((event, eventIndex) => {
|
|
25321
|
+
const turnId = codexItemFromEvent(event)?.turnId ?? codexTurnFromEvent(event)?.turnId;
|
|
25322
|
+
if (turnId !== void 0) {
|
|
25323
|
+
if (!turnInsertions.some((insertion) => insertion.turnId === turnId)) {
|
|
25324
|
+
turnInsertions.push({ index: messages.length, turnId });
|
|
25325
|
+
}
|
|
25326
|
+
return;
|
|
25327
|
+
}
|
|
25089
25328
|
if (event.type === "codex-asp-error") {
|
|
25090
|
-
|
|
25091
|
-
|
|
25092
|
-
|
|
25093
|
-
|
|
25094
|
-
|
|
25095
|
-
|
|
25329
|
+
const failedTurnId = getPayloadString(event, CODEX_ASP_ITEM_ID_PAYLOAD_KEY);
|
|
25330
|
+
if (!(failedTurnId && turns.has(failedTurnId))) {
|
|
25331
|
+
messages.push({
|
|
25332
|
+
id: displayId(event, eventIndex, "error"),
|
|
25333
|
+
type: "error",
|
|
25334
|
+
message: getPayloadString(event, "message") ?? "Codex run failed",
|
|
25335
|
+
timestamp: event.timestamp
|
|
25336
|
+
});
|
|
25337
|
+
}
|
|
25096
25338
|
return;
|
|
25097
25339
|
}
|
|
25098
25340
|
if (event.type === CODEX_QUOTA_STATUS_EVENT_TYPE) {
|
|
@@ -25251,6 +25493,25 @@ function parseCodexEvents(events) {
|
|
|
25251
25493
|
}
|
|
25252
25494
|
}
|
|
25253
25495
|
});
|
|
25496
|
+
const claimedPrompts = /* @__PURE__ */ new Set();
|
|
25497
|
+
for (const { index, turnId } of turnInsertions.reverse()) {
|
|
25498
|
+
const turn = turns.get(turnId);
|
|
25499
|
+
if (!turn) continue;
|
|
25500
|
+
const kept = [];
|
|
25501
|
+
for (const message of messagesForCodexTurn(turn)) {
|
|
25502
|
+
const recordedIndex = message.type === "user" ? messages.findLastIndex((candidate, candidateIndex) => candidateIndex < index && candidate.type === "user" && candidate.content === message.content && !claimedPrompts.has(candidateIndex)) : -1;
|
|
25503
|
+
if (recordedIndex === -1) {
|
|
25504
|
+
kept.push(message);
|
|
25505
|
+
continue;
|
|
25506
|
+
}
|
|
25507
|
+
claimedPrompts.add(recordedIndex);
|
|
25508
|
+
const recorded = messages[recordedIndex];
|
|
25509
|
+
if (recorded.type === "user" && message.type === "user" && !recorded.images && message.images) {
|
|
25510
|
+
messages[recordedIndex] = { ...recorded, images: message.images };
|
|
25511
|
+
}
|
|
25512
|
+
}
|
|
25513
|
+
messages.splice(index, 0, ...kept);
|
|
25514
|
+
}
|
|
25254
25515
|
return messages;
|
|
25255
25516
|
}
|
|
25256
25517
|
|
|
@@ -26794,292 +27055,6 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
26794
27055
|
return messages.filter((_2, index) => !staleIndexes.has(index));
|
|
26795
27056
|
}
|
|
26796
27057
|
|
|
26797
|
-
// ../shared/src/display-message/parsers/codex-asp-parser.ts
|
|
26798
|
-
var DUPLICATE_WINDOW_MS = 5 * 60 * 1e3;
|
|
26799
|
-
function nearTimestamp(a, b) {
|
|
26800
|
-
return Math.abs(parseTimestampMs(a) - parseTimestampMs(b)) <= DUPLICATE_WINDOW_MS;
|
|
26801
|
-
}
|
|
26802
|
-
function inputForDisplay(input) {
|
|
26803
|
-
if (input === void 0 || input === null) return void 0;
|
|
26804
|
-
if (typeof input === "string") return input;
|
|
26805
|
-
if (isRecord(input)) return input;
|
|
26806
|
-
return String(input);
|
|
26807
|
-
}
|
|
26808
|
-
function isInternalUserMessage(content) {
|
|
26809
|
-
const trimmed = content.trim();
|
|
26810
|
-
return trimmed.startsWith("<environment_context>") || trimmed.startsWith("<goal_context>");
|
|
26811
|
-
}
|
|
26812
|
-
function messageForItem(item) {
|
|
26813
|
-
if (item.type === "userMessage") {
|
|
26814
|
-
if (isInternalUserMessage(item.content)) return null;
|
|
26815
|
-
return {
|
|
26816
|
-
id: `user-${item.id}`,
|
|
26817
|
-
type: "user",
|
|
26818
|
-
content: item.content,
|
|
26819
|
-
images: item.images,
|
|
26820
|
-
timestamp: item.timestamp
|
|
26821
|
-
};
|
|
26822
|
-
}
|
|
26823
|
-
if (item.type === "agentMessage" || item.type === "plan") {
|
|
26824
|
-
if (!item.text) return null;
|
|
26825
|
-
return {
|
|
26826
|
-
id: `agent-${item.id}`,
|
|
26827
|
-
type: "agent",
|
|
26828
|
-
content: item.text,
|
|
26829
|
-
timestamp: item.timestamp,
|
|
26830
|
-
...item.type === "plan" ? { isPlan: true } : {}
|
|
26831
|
-
};
|
|
26832
|
-
}
|
|
26833
|
-
if (item.type === "reasoning") {
|
|
26834
|
-
if (!item.text) return null;
|
|
26835
|
-
return {
|
|
26836
|
-
id: `reasoning-${item.id}`,
|
|
26837
|
-
type: "reasoning",
|
|
26838
|
-
content: item.text,
|
|
26839
|
-
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
26840
|
-
timestamp: item.timestamp,
|
|
26841
|
-
...item.sourceTimestamp ? { sourceTimestamp: item.sourceTimestamp } : {}
|
|
26842
|
-
};
|
|
26843
|
-
}
|
|
26844
|
-
if (item.type === "commandExecution") {
|
|
26845
|
-
const skillNames = skillNamesFromCommand(item.command);
|
|
26846
|
-
return {
|
|
26847
|
-
id: `command-${item.id}`,
|
|
26848
|
-
type: "command",
|
|
26849
|
-
command: item.command,
|
|
26850
|
-
...skillNames.length > 0 ? { skillNames } : {},
|
|
26851
|
-
output: item.output,
|
|
26852
|
-
exitCode: item.exitCode ?? void 0,
|
|
26853
|
-
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
26854
|
-
timestamp: item.timestamp
|
|
26855
|
-
};
|
|
26856
|
-
}
|
|
26857
|
-
if (item.type === "fileChange") {
|
|
26858
|
-
return {
|
|
26859
|
-
id: `patch-${item.id}`,
|
|
26860
|
-
type: "patch",
|
|
26861
|
-
operations: item.operations,
|
|
26862
|
-
output: item.output,
|
|
26863
|
-
exitCode: item.exitCode ?? void 0,
|
|
26864
|
-
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
26865
|
-
timestamp: item.timestamp
|
|
26866
|
-
};
|
|
26867
|
-
}
|
|
26868
|
-
if (item.type === "toolCall") {
|
|
26869
|
-
return createCallDisplayMessage({
|
|
26870
|
-
id: `toolcall-${item.id}`,
|
|
26871
|
-
server: item.server,
|
|
26872
|
-
tool: item.tool,
|
|
26873
|
-
input: inputForDisplay(item.input),
|
|
26874
|
-
output: item.output,
|
|
26875
|
-
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
26876
|
-
timestamp: item.timestamp
|
|
26877
|
-
});
|
|
26878
|
-
}
|
|
26879
|
-
if (item.type === "subagent") {
|
|
26880
|
-
return {
|
|
26881
|
-
id: `subagent-${item.id}`,
|
|
26882
|
-
type: "subagent",
|
|
26883
|
-
toolUseId: item.id,
|
|
26884
|
-
description: item.description,
|
|
26885
|
-
prompt: item.prompt,
|
|
26886
|
-
subagentType: item.subagentType,
|
|
26887
|
-
...item.receiverThreadIds ? { receiverThreadIds: item.receiverThreadIds } : {},
|
|
26888
|
-
...item.model ? { model: item.model } : {},
|
|
26889
|
-
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
26890
|
-
...item.output ? { output: item.output } : {},
|
|
26891
|
-
nestedEvents: [],
|
|
26892
|
-
timestamp: item.timestamp
|
|
26893
|
-
};
|
|
26894
|
-
}
|
|
26895
|
-
if (item.type === "webSearch") {
|
|
26896
|
-
return {
|
|
26897
|
-
id: `web-search-${item.id}`,
|
|
26898
|
-
type: "web_search",
|
|
26899
|
-
query: item.query,
|
|
26900
|
-
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
26901
|
-
timestamp: item.timestamp
|
|
26902
|
-
};
|
|
26903
|
-
}
|
|
26904
|
-
if (item.type === "contextCompaction") {
|
|
26905
|
-
return {
|
|
26906
|
-
id: `reasoning-${item.id}`,
|
|
26907
|
-
type: "reasoning",
|
|
26908
|
-
content: "Context compacted",
|
|
26909
|
-
status: normalizeCodexAspTranscriptStatus(item.status),
|
|
26910
|
-
timestamp: item.timestamp
|
|
26911
|
-
};
|
|
26912
|
-
}
|
|
26913
|
-
return {
|
|
26914
|
-
id: `error-${item.id}`,
|
|
26915
|
-
type: "error",
|
|
26916
|
-
message: item.message,
|
|
26917
|
-
timestamp: item.timestamp
|
|
26918
|
-
};
|
|
26919
|
-
}
|
|
26920
|
-
function skillMessagesForItem(item) {
|
|
26921
|
-
if (item.type !== "userMessage" || !item.skillNames) return [];
|
|
26922
|
-
return item.skillNames.filter((skillName) => skillName.trim().length > 0).map((skillName, index) => ({
|
|
26923
|
-
id: `skill-${item.id}-${index}`,
|
|
26924
|
-
type: "skill",
|
|
26925
|
-
skillName,
|
|
26926
|
-
status: "completed",
|
|
26927
|
-
timestamp: item.timestamp
|
|
26928
|
-
}));
|
|
26929
|
-
}
|
|
26930
|
-
function stableString(value) {
|
|
26931
|
-
if (value === void 0) return "";
|
|
26932
|
-
if (typeof value !== "object" || value === null) return String(value);
|
|
26933
|
-
try {
|
|
26934
|
-
return JSON.stringify(value, Object.keys(value).sort());
|
|
26935
|
-
} catch {
|
|
26936
|
-
return String(value);
|
|
26937
|
-
}
|
|
26938
|
-
}
|
|
26939
|
-
function duplicateKey(message) {
|
|
26940
|
-
if (message.type === "user" || message.type === "agent" || message.type === "reasoning") {
|
|
26941
|
-
return JSON.stringify([message.type, message.content]);
|
|
26942
|
-
}
|
|
26943
|
-
if (message.type === "command") return JSON.stringify([message.type, message.command]);
|
|
26944
|
-
if (message.type === "web_search") return JSON.stringify([message.type, message.query]);
|
|
26945
|
-
if (message.type === "subagent") {
|
|
26946
|
-
return JSON.stringify([
|
|
26947
|
-
message.type,
|
|
26948
|
-
message.description,
|
|
26949
|
-
message.prompt,
|
|
26950
|
-
message.subagentType,
|
|
26951
|
-
message.model
|
|
26952
|
-
]);
|
|
26953
|
-
}
|
|
26954
|
-
if (message.type === "todo_list") {
|
|
26955
|
-
return JSON.stringify([message.type, stableString(message.items)]);
|
|
26956
|
-
}
|
|
26957
|
-
if (message.type === "patch") {
|
|
26958
|
-
return JSON.stringify([message.type, stableString(message.operations)]);
|
|
26959
|
-
}
|
|
26960
|
-
if (message.type === "tool_call") {
|
|
26961
|
-
return JSON.stringify([
|
|
26962
|
-
message.type,
|
|
26963
|
-
message.server,
|
|
26964
|
-
message.tool,
|
|
26965
|
-
stableString(message.input)
|
|
26966
|
-
]);
|
|
26967
|
-
}
|
|
26968
|
-
return null;
|
|
26969
|
-
}
|
|
26970
|
-
function duplicateBucketKey(message, bucketOffset = 0) {
|
|
26971
|
-
const key = duplicateKey(message);
|
|
26972
|
-
if (key === null) return null;
|
|
26973
|
-
const bucket = Math.floor(parseTimestampMs(message.timestamp) / DUPLICATE_WINDOW_MS) + bucketOffset;
|
|
26974
|
-
return JSON.stringify([bucket, key]);
|
|
26975
|
-
}
|
|
26976
|
-
function mergeCodexAspDisplayMessages(primary, supplemental) {
|
|
26977
|
-
const merged = [...primary];
|
|
26978
|
-
const primaryCount = primary.length;
|
|
26979
|
-
const firstIndexById = /* @__PURE__ */ new Map();
|
|
26980
|
-
const indexesByDuplicateBucket = /* @__PURE__ */ new Map();
|
|
26981
|
-
const indexMessage = (message, index) => {
|
|
26982
|
-
if (!firstIndexById.has(message.id)) firstIndexById.set(message.id, index);
|
|
26983
|
-
const key = duplicateBucketKey(message);
|
|
26984
|
-
if (key === null) return;
|
|
26985
|
-
const indexes = indexesByDuplicateBucket.get(key) ?? /* @__PURE__ */ new Set();
|
|
26986
|
-
indexes.add(index);
|
|
26987
|
-
indexesByDuplicateBucket.set(key, indexes);
|
|
26988
|
-
};
|
|
26989
|
-
const unindexMessage = (message, index) => {
|
|
26990
|
-
const key = duplicateBucketKey(message);
|
|
26991
|
-
if (key === null) return;
|
|
26992
|
-
const indexes = indexesByDuplicateBucket.get(key);
|
|
26993
|
-
indexes?.delete(index);
|
|
26994
|
-
if (indexes?.size === 0) indexesByDuplicateBucket.delete(key);
|
|
26995
|
-
};
|
|
26996
|
-
merged.forEach(indexMessage);
|
|
26997
|
-
for (const message of supplemental) {
|
|
26998
|
-
let duplicateIndex = firstIndexById.get(message.id);
|
|
26999
|
-
if (duplicateIndex === void 0) {
|
|
27000
|
-
for (let bucketOffset = -1; bucketOffset <= 1; bucketOffset += 1) {
|
|
27001
|
-
const key = duplicateBucketKey(message, bucketOffset);
|
|
27002
|
-
for (const index of (key === null ? void 0 : indexesByDuplicateBucket.get(key)) ?? []) {
|
|
27003
|
-
if (nearTimestamp(merged[index].timestamp, message.timestamp) && (duplicateIndex === void 0 || index < duplicateIndex)) {
|
|
27004
|
-
duplicateIndex = index;
|
|
27005
|
-
}
|
|
27006
|
-
}
|
|
27007
|
-
}
|
|
27008
|
-
}
|
|
27009
|
-
if (duplicateIndex === void 0) {
|
|
27010
|
-
indexMessage(message, merged.push(message) - 1);
|
|
27011
|
-
} else if (message.type === "user") {
|
|
27012
|
-
unindexMessage(merged[duplicateIndex], duplicateIndex);
|
|
27013
|
-
merged[duplicateIndex] = {
|
|
27014
|
-
...merged[duplicateIndex],
|
|
27015
|
-
id: message.id
|
|
27016
|
-
};
|
|
27017
|
-
firstIndexById.set(message.id, duplicateIndex);
|
|
27018
|
-
indexMessage(merged[duplicateIndex], duplicateIndex);
|
|
27019
|
-
}
|
|
27020
|
-
}
|
|
27021
|
-
const ordered = merged.slice(0, primaryCount);
|
|
27022
|
-
const supplementalOnly = merged.slice(primaryCount).map((message, index) => ({ message, index })).sort((a, b) => parseTimestampMs(a.message.timestamp) - parseTimestampMs(b.message.timestamp) || a.index - b.index);
|
|
27023
|
-
for (const { message } of supplementalOnly) {
|
|
27024
|
-
insertDisplayMessageByTimestamp(ordered, message);
|
|
27025
|
-
}
|
|
27026
|
-
return ordered;
|
|
27027
|
-
}
|
|
27028
|
-
function parseCodexAspTranscript(transcript) {
|
|
27029
|
-
const messages = [];
|
|
27030
|
-
const orderedItems = transcript.turns.map((turn, turnIndex) => ({ turn, turnIndex })).flatMap(({ turn, turnIndex }) => turn.items.map((item, itemIndex) => ({ item, turn, turnIndex, itemIndex }))).sort((a, b) => {
|
|
27031
|
-
const aSequence = a.item.sequence ?? Number.MAX_SAFE_INTEGER;
|
|
27032
|
-
const bSequence = b.item.sequence ?? Number.MAX_SAFE_INTEGER;
|
|
27033
|
-
return aSequence - bSequence || parseTimestampMs(a.item.timestamp) - parseTimestampMs(b.item.timestamp) || a.turnIndex - b.turnIndex || a.itemIndex - b.itemIndex;
|
|
27034
|
-
});
|
|
27035
|
-
const reasoningByTurnId = /* @__PURE__ */ new Map();
|
|
27036
|
-
for (const { item, turn } of orderedItems) {
|
|
27037
|
-
if (item.type !== "reasoning" || !item.text.trim()) continue;
|
|
27038
|
-
const reasoning = reasoningByTurnId.get(turn.id) ?? [];
|
|
27039
|
-
reasoning.push(item);
|
|
27040
|
-
reasoningByTurnId.set(turn.id, reasoning);
|
|
27041
|
-
}
|
|
27042
|
-
const emittedReasoningTurnIds = /* @__PURE__ */ new Set();
|
|
27043
|
-
const coalescedItems = orderedItems.flatMap((entry) => {
|
|
27044
|
-
if (entry.item.type !== "reasoning") return [entry];
|
|
27045
|
-
const reasoning = reasoningByTurnId.get(entry.turn.id);
|
|
27046
|
-
if (!reasoning || emittedReasoningTurnIds.has(entry.turn.id)) return [];
|
|
27047
|
-
emittedReasoningTurnIds.add(entry.turn.id);
|
|
27048
|
-
return [{
|
|
27049
|
-
...entry,
|
|
27050
|
-
item: {
|
|
27051
|
-
type: "reasoning",
|
|
27052
|
-
id: entry.turn.id,
|
|
27053
|
-
text: reasoning.map(({ text }) => text.trim()).join("\n\n"),
|
|
27054
|
-
timestamp: entry.turn.startedAt,
|
|
27055
|
-
...reasoning[0] ? { sourceTimestamp: reasoning[0].timestamp } : {},
|
|
27056
|
-
status: reasoning.at(-1)?.status ?? "completed",
|
|
27057
|
-
sequence: entry.item.sequence
|
|
27058
|
-
}
|
|
27059
|
-
}];
|
|
27060
|
-
});
|
|
27061
|
-
for (const turn of transcript.turns) {
|
|
27062
|
-
const reasoningIndex = coalescedItems.findIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "reasoning");
|
|
27063
|
-
if (reasoningIndex === -1) continue;
|
|
27064
|
-
const responseItem = getCodexAspTurnResponse({
|
|
27065
|
-
status: turn.status,
|
|
27066
|
-
items: coalescedItems.filter(({ turn: itemTurn }) => itemTurn.id === turn.id).map(({ item }) => item)
|
|
27067
|
-
});
|
|
27068
|
-
const finalAnswerIndex = responseItem ? coalescedItems.findIndex(({ item }) => item === responseItem) : -1;
|
|
27069
|
-
if (finalAnswerIndex === -1 || reasoningIndex < finalAnswerIndex) continue;
|
|
27070
|
-
const [reasoning] = coalescedItems.splice(reasoningIndex, 1);
|
|
27071
|
-
coalescedItems.splice(finalAnswerIndex, 0, reasoning);
|
|
27072
|
-
}
|
|
27073
|
-
for (const { item } of coalescedItems) {
|
|
27074
|
-
const message = messageForItem(item);
|
|
27075
|
-
if (message) {
|
|
27076
|
-
messages.push(message);
|
|
27077
|
-
}
|
|
27078
|
-
messages.push(...skillMessagesForItem(item));
|
|
27079
|
-
}
|
|
27080
|
-
return messages;
|
|
27081
|
-
}
|
|
27082
|
-
|
|
27083
27058
|
// ../shared/src/display-message/parsers/index.ts
|
|
27084
27059
|
var INTERRUPTION_DEDUP_WINDOW_MS = 15e3;
|
|
27085
27060
|
function parseAgentEvents(events, agentType) {
|
|
@@ -27113,22 +27088,19 @@ function parseAgentEvents(events, agentType) {
|
|
|
27113
27088
|
}
|
|
27114
27089
|
return parseClaudeEvents(events);
|
|
27115
27090
|
}
|
|
27116
|
-
function parseDisplayMessages(events, agentType,
|
|
27091
|
+
function parseDisplayMessages(events, agentType, options = {}) {
|
|
27117
27092
|
events = excludeQueuedAcceptedEvents(events, []);
|
|
27118
|
-
const shouldFilter = options.filter ?? true;
|
|
27119
27093
|
const parsedEvents = agentType === "claude" || agentType === "relay" ? parseClaudeEvents(events, options.parentToolUseId) : parseAgentEvents(events, agentType);
|
|
27120
27094
|
const reconciledEvents = [];
|
|
27121
27095
|
for (const message of parsedEvents) {
|
|
27122
27096
|
if (message.type === "user") upsertDisplayMessage(reconciledEvents, message);
|
|
27123
27097
|
else reconciledEvents.push(message);
|
|
27124
27098
|
}
|
|
27125
|
-
|
|
27126
|
-
|
|
27127
|
-
|
|
27128
|
-
|
|
27129
|
-
|
|
27130
|
-
const nativeCodexMessages = shouldFilter ? filterDisplayMessages(parseCodexAspTranscript(codexAspTranscript), agentType) : parseCodexAspTranscript(codexAspTranscript);
|
|
27131
|
-
return applySyntheticNotices(mergeCodexAspDisplayMessages(nativeCodexMessages, legacyMessages));
|
|
27099
|
+
if (options.filter === false) return reconciledEvents;
|
|
27100
|
+
return applyAuthFallbackNotices(
|
|
27101
|
+
applyInterruptions(filterDisplayMessages(reconciledEvents, agentType), events),
|
|
27102
|
+
events
|
|
27103
|
+
);
|
|
27132
27104
|
}
|
|
27133
27105
|
function applyInterruptions(messages, events) {
|
|
27134
27106
|
const result = [...messages];
|
|
@@ -27378,7 +27350,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
|
|
|
27378
27350
|
});
|
|
27379
27351
|
|
|
27380
27352
|
// ../shared/src/cli-version.ts
|
|
27381
|
-
var CLI_VERSION = "0.2.
|
|
27353
|
+
var CLI_VERSION = "0.2.701";
|
|
27382
27354
|
|
|
27383
27355
|
// ../shared/src/version.ts
|
|
27384
27356
|
function compareVersions(v1, v2) {
|
|
@@ -30102,7 +30074,7 @@ Conversation History
|
|
|
30102
30074
|
}
|
|
30103
30075
|
console.log(import_chalk15.default.gray("-".repeat(60)));
|
|
30104
30076
|
const agentType = response.coding_agent || "claude";
|
|
30105
|
-
const displayMessages = parseDisplayMessages(response.events, agentType
|
|
30077
|
+
const displayMessages = parseDisplayMessages(response.events, agentType);
|
|
30106
30078
|
for (const message of displayMessages) {
|
|
30107
30079
|
formatDisplayMessage(message);
|
|
30108
30080
|
}
|