replicas-cli 0.2.189 → 0.2.190
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.mjs +35 -10
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8001,6 +8001,8 @@ function getProviderDisplayName(provider) {
|
|
|
8001
8001
|
}
|
|
8002
8002
|
|
|
8003
8003
|
// ../shared/src/event.ts
|
|
8004
|
+
var USER_MESSAGE_ID_PAYLOAD_KEY = "replicasMessageId";
|
|
8005
|
+
var CODEX_ASP_ITEM_ID_PAYLOAD_KEY = "codexAspItemId";
|
|
8004
8006
|
var CODEX_QUOTA_STATUS_EVENT_TYPE = "codex-quota-status";
|
|
8005
8007
|
|
|
8006
8008
|
// ../shared/src/pricing.ts
|
|
@@ -9603,6 +9605,14 @@ function safeJsonParse(str, fallback) {
|
|
|
9603
9605
|
function getStatusFromExitCode(exitCode) {
|
|
9604
9606
|
return exitCode === 0 ? "completed" : "failed";
|
|
9605
9607
|
}
|
|
9608
|
+
function getPayloadString(event, key) {
|
|
9609
|
+
const value = event.payload?.[key];
|
|
9610
|
+
return typeof value === "string" ? value : null;
|
|
9611
|
+
}
|
|
9612
|
+
function displayId(event, eventIndex, prefix) {
|
|
9613
|
+
const stableId = getPayloadString(event, USER_MESSAGE_ID_PAYLOAD_KEY) ?? getPayloadString(event, CODEX_ASP_ITEM_ID_PAYLOAD_KEY);
|
|
9614
|
+
return stableId ? `${prefix}-${stableId}` : `${prefix}-${event.timestamp}-${eventIndex}`;
|
|
9615
|
+
}
|
|
9606
9616
|
function parseShellOutput(raw) {
|
|
9607
9617
|
const exitCodeMatch = raw.match(/^Exit code: (\d+)/m) || raw.match(/Process exited with code (\d+)/);
|
|
9608
9618
|
const exitCode = exitCodeMatch ? parseInt(exitCodeMatch[1], 10) : 0;
|
|
@@ -9666,6 +9676,7 @@ function parsePatch(input) {
|
|
|
9666
9676
|
function parseCodexEvents(events) {
|
|
9667
9677
|
const messages = [];
|
|
9668
9678
|
const pendingCommands = /* @__PURE__ */ new Map();
|
|
9679
|
+
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
9669
9680
|
const pendingPatches = /* @__PURE__ */ new Map();
|
|
9670
9681
|
events.forEach((event, eventIndex) => {
|
|
9671
9682
|
if (event.type === CODEX_QUOTA_STATUS_EVENT_TYPE) {
|
|
@@ -9686,7 +9697,7 @@ function parseCodexEvents(events) {
|
|
|
9686
9697
|
}
|
|
9687
9698
|
if (event.type === "event_msg" && event.payload?.type === "user_message") {
|
|
9688
9699
|
messages.push({
|
|
9689
|
-
id:
|
|
9700
|
+
id: displayId(event, eventIndex, "user"),
|
|
9690
9701
|
type: "user",
|
|
9691
9702
|
content: event.payload.message || "",
|
|
9692
9703
|
timestamp: event.timestamp
|
|
@@ -9694,7 +9705,7 @@ function parseCodexEvents(events) {
|
|
|
9694
9705
|
}
|
|
9695
9706
|
if (event.type === "event_msg" && event.payload?.type === "agent_reasoning") {
|
|
9696
9707
|
messages.push({
|
|
9697
|
-
id:
|
|
9708
|
+
id: displayId(event, eventIndex, "reasoning"),
|
|
9698
9709
|
type: "reasoning",
|
|
9699
9710
|
content: event.payload.text || "",
|
|
9700
9711
|
status: "completed",
|
|
@@ -9708,7 +9719,7 @@ function parseCodexEvents(events) {
|
|
|
9708
9719
|
const textContent = content.filter((c) => c.type === "output_text").map((c) => c.text || "").join("\n");
|
|
9709
9720
|
if (textContent) {
|
|
9710
9721
|
messages.push({
|
|
9711
|
-
id:
|
|
9722
|
+
id: displayId(event, eventIndex, "agent"),
|
|
9712
9723
|
type: "agent",
|
|
9713
9724
|
content: textContent,
|
|
9714
9725
|
timestamp: event.timestamp
|
|
@@ -9748,19 +9759,25 @@ function parseCodexEvents(events) {
|
|
|
9748
9759
|
const callId = event.payload.call_id;
|
|
9749
9760
|
const name = event.payload.name;
|
|
9750
9761
|
const input = event.payload.input || "";
|
|
9762
|
+
const server = typeof event.payload.server === "string" ? event.payload.server : "custom";
|
|
9751
9763
|
const status = event.payload.status || "in_progress";
|
|
9752
9764
|
if (name === "apply_patch") {
|
|
9753
9765
|
const operations = parsePatch(input);
|
|
9754
9766
|
pendingPatches.set(callId, { input, status, timestamp: event.timestamp, operations });
|
|
9755
9767
|
} else {
|
|
9756
|
-
|
|
9757
|
-
id: `toolcall-${event.timestamp}-${eventIndex}`,
|
|
9768
|
+
const msg = {
|
|
9769
|
+
id: `toolcall-${callId || getPayloadString(event, CODEX_ASP_ITEM_ID_PAYLOAD_KEY) || `${event.timestamp}-${eventIndex}`}`,
|
|
9758
9770
|
type: "tool_call",
|
|
9759
|
-
server
|
|
9771
|
+
server,
|
|
9760
9772
|
tool: name,
|
|
9773
|
+
input,
|
|
9761
9774
|
status,
|
|
9762
9775
|
timestamp: event.timestamp
|
|
9763
|
-
}
|
|
9776
|
+
};
|
|
9777
|
+
messages.push(msg);
|
|
9778
|
+
if (callId) {
|
|
9779
|
+
pendingToolCalls.set(callId, msg);
|
|
9780
|
+
}
|
|
9764
9781
|
}
|
|
9765
9782
|
}
|
|
9766
9783
|
if (payloadType === "custom_tool_call_output") {
|
|
@@ -9782,9 +9799,14 @@ function parseCodexEvents(events) {
|
|
|
9782
9799
|
});
|
|
9783
9800
|
pendingPatches.delete(callId);
|
|
9784
9801
|
} else {
|
|
9785
|
-
const
|
|
9802
|
+
const fallbackToolCallMsg = messages.findLast((m) => m.type === "tool_call");
|
|
9803
|
+
const toolCallMsg = pendingToolCalls.get(callId) ?? fallbackToolCallMsg;
|
|
9786
9804
|
if (toolCallMsg) {
|
|
9787
9805
|
toolCallMsg.status = getStatusFromExitCode(output.metadata?.exit_code);
|
|
9806
|
+
toolCallMsg.output = output.output ?? (typeof event.payload.output === "string" ? event.payload.output : "");
|
|
9807
|
+
if (callId) {
|
|
9808
|
+
pendingToolCalls.delete(callId);
|
|
9809
|
+
}
|
|
9788
9810
|
}
|
|
9789
9811
|
}
|
|
9790
9812
|
}
|
|
@@ -10135,6 +10157,9 @@ function parseAgentEvents(events, agentType) {
|
|
|
10135
10157
|
}
|
|
10136
10158
|
return parseClaudeEvents(events);
|
|
10137
10159
|
}
|
|
10160
|
+
function isCodexInitializationPrompt(message) {
|
|
10161
|
+
return message.type === "user" && removeReplicasInstructions(message.content).trim() === "Hello";
|
|
10162
|
+
}
|
|
10138
10163
|
function createUserMessage(content) {
|
|
10139
10164
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
10140
10165
|
return {
|
|
@@ -10156,7 +10181,7 @@ function filterDisplayMessages(messages, provider) {
|
|
|
10156
10181
|
let result = messages;
|
|
10157
10182
|
if (provider === "codex") {
|
|
10158
10183
|
const userMessages = result.map((msg, index) => ({ msg, index })).filter(({ msg }) => msg.type === "user");
|
|
10159
|
-
if (userMessages.length >= 2) {
|
|
10184
|
+
if (userMessages.length >= 2 && isCodexInitializationPrompt(userMessages[0].msg)) {
|
|
10160
10185
|
result = result.slice(userMessages[1].index);
|
|
10161
10186
|
}
|
|
10162
10187
|
}
|
|
@@ -16577,7 +16602,7 @@ Deleted file ${pathOrId}.
|
|
|
16577
16602
|
}
|
|
16578
16603
|
|
|
16579
16604
|
// src/index.ts
|
|
16580
|
-
var CLI_VERSION = "0.2.
|
|
16605
|
+
var CLI_VERSION = "0.2.190";
|
|
16581
16606
|
function parseBooleanOption(value) {
|
|
16582
16607
|
if (value === "true") return true;
|
|
16583
16608
|
if (value === "false") return false;
|