replicas-cli 0.2.188 → 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 +37 -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
|
|
@@ -8099,6 +8101,8 @@ function getSandboxPaths(providerId) {
|
|
|
8099
8101
|
return E2B_PATHS;
|
|
8100
8102
|
}
|
|
8101
8103
|
}
|
|
8104
|
+
var WORKSPACE_SIZES = ["small", "large"];
|
|
8105
|
+
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
8102
8106
|
|
|
8103
8107
|
// ../shared/src/urls.ts
|
|
8104
8108
|
function getWorkspaceDashboardUrl(workspaceId, options = {}) {
|
|
@@ -9601,6 +9605,14 @@ function safeJsonParse(str, fallback) {
|
|
|
9601
9605
|
function getStatusFromExitCode(exitCode) {
|
|
9602
9606
|
return exitCode === 0 ? "completed" : "failed";
|
|
9603
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
|
+
}
|
|
9604
9616
|
function parseShellOutput(raw) {
|
|
9605
9617
|
const exitCodeMatch = raw.match(/^Exit code: (\d+)/m) || raw.match(/Process exited with code (\d+)/);
|
|
9606
9618
|
const exitCode = exitCodeMatch ? parseInt(exitCodeMatch[1], 10) : 0;
|
|
@@ -9664,6 +9676,7 @@ function parsePatch(input) {
|
|
|
9664
9676
|
function parseCodexEvents(events) {
|
|
9665
9677
|
const messages = [];
|
|
9666
9678
|
const pendingCommands = /* @__PURE__ */ new Map();
|
|
9679
|
+
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
9667
9680
|
const pendingPatches = /* @__PURE__ */ new Map();
|
|
9668
9681
|
events.forEach((event, eventIndex) => {
|
|
9669
9682
|
if (event.type === CODEX_QUOTA_STATUS_EVENT_TYPE) {
|
|
@@ -9684,7 +9697,7 @@ function parseCodexEvents(events) {
|
|
|
9684
9697
|
}
|
|
9685
9698
|
if (event.type === "event_msg" && event.payload?.type === "user_message") {
|
|
9686
9699
|
messages.push({
|
|
9687
|
-
id:
|
|
9700
|
+
id: displayId(event, eventIndex, "user"),
|
|
9688
9701
|
type: "user",
|
|
9689
9702
|
content: event.payload.message || "",
|
|
9690
9703
|
timestamp: event.timestamp
|
|
@@ -9692,7 +9705,7 @@ function parseCodexEvents(events) {
|
|
|
9692
9705
|
}
|
|
9693
9706
|
if (event.type === "event_msg" && event.payload?.type === "agent_reasoning") {
|
|
9694
9707
|
messages.push({
|
|
9695
|
-
id:
|
|
9708
|
+
id: displayId(event, eventIndex, "reasoning"),
|
|
9696
9709
|
type: "reasoning",
|
|
9697
9710
|
content: event.payload.text || "",
|
|
9698
9711
|
status: "completed",
|
|
@@ -9706,7 +9719,7 @@ function parseCodexEvents(events) {
|
|
|
9706
9719
|
const textContent = content.filter((c) => c.type === "output_text").map((c) => c.text || "").join("\n");
|
|
9707
9720
|
if (textContent) {
|
|
9708
9721
|
messages.push({
|
|
9709
|
-
id:
|
|
9722
|
+
id: displayId(event, eventIndex, "agent"),
|
|
9710
9723
|
type: "agent",
|
|
9711
9724
|
content: textContent,
|
|
9712
9725
|
timestamp: event.timestamp
|
|
@@ -9746,19 +9759,25 @@ function parseCodexEvents(events) {
|
|
|
9746
9759
|
const callId = event.payload.call_id;
|
|
9747
9760
|
const name = event.payload.name;
|
|
9748
9761
|
const input = event.payload.input || "";
|
|
9762
|
+
const server = typeof event.payload.server === "string" ? event.payload.server : "custom";
|
|
9749
9763
|
const status = event.payload.status || "in_progress";
|
|
9750
9764
|
if (name === "apply_patch") {
|
|
9751
9765
|
const operations = parsePatch(input);
|
|
9752
9766
|
pendingPatches.set(callId, { input, status, timestamp: event.timestamp, operations });
|
|
9753
9767
|
} else {
|
|
9754
|
-
|
|
9755
|
-
id: `toolcall-${event.timestamp}-${eventIndex}`,
|
|
9768
|
+
const msg = {
|
|
9769
|
+
id: `toolcall-${callId || getPayloadString(event, CODEX_ASP_ITEM_ID_PAYLOAD_KEY) || `${event.timestamp}-${eventIndex}`}`,
|
|
9756
9770
|
type: "tool_call",
|
|
9757
|
-
server
|
|
9771
|
+
server,
|
|
9758
9772
|
tool: name,
|
|
9773
|
+
input,
|
|
9759
9774
|
status,
|
|
9760
9775
|
timestamp: event.timestamp
|
|
9761
|
-
}
|
|
9776
|
+
};
|
|
9777
|
+
messages.push(msg);
|
|
9778
|
+
if (callId) {
|
|
9779
|
+
pendingToolCalls.set(callId, msg);
|
|
9780
|
+
}
|
|
9762
9781
|
}
|
|
9763
9782
|
}
|
|
9764
9783
|
if (payloadType === "custom_tool_call_output") {
|
|
@@ -9780,9 +9799,14 @@ function parseCodexEvents(events) {
|
|
|
9780
9799
|
});
|
|
9781
9800
|
pendingPatches.delete(callId);
|
|
9782
9801
|
} else {
|
|
9783
|
-
const
|
|
9802
|
+
const fallbackToolCallMsg = messages.findLast((m) => m.type === "tool_call");
|
|
9803
|
+
const toolCallMsg = pendingToolCalls.get(callId) ?? fallbackToolCallMsg;
|
|
9784
9804
|
if (toolCallMsg) {
|
|
9785
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
|
+
}
|
|
9786
9810
|
}
|
|
9787
9811
|
}
|
|
9788
9812
|
}
|
|
@@ -10133,6 +10157,9 @@ function parseAgentEvents(events, agentType) {
|
|
|
10133
10157
|
}
|
|
10134
10158
|
return parseClaudeEvents(events);
|
|
10135
10159
|
}
|
|
10160
|
+
function isCodexInitializationPrompt(message) {
|
|
10161
|
+
return message.type === "user" && removeReplicasInstructions(message.content).trim() === "Hello";
|
|
10162
|
+
}
|
|
10136
10163
|
function createUserMessage(content) {
|
|
10137
10164
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
10138
10165
|
return {
|
|
@@ -10154,7 +10181,7 @@ function filterDisplayMessages(messages, provider) {
|
|
|
10154
10181
|
let result = messages;
|
|
10155
10182
|
if (provider === "codex") {
|
|
10156
10183
|
const userMessages = result.map((msg, index) => ({ msg, index })).filter(({ msg }) => msg.type === "user");
|
|
10157
|
-
if (userMessages.length >= 2) {
|
|
10184
|
+
if (userMessages.length >= 2 && isCodexInitializationPrompt(userMessages[0].msg)) {
|
|
10158
10185
|
result = result.slice(userMessages[1].index);
|
|
10159
10186
|
}
|
|
10160
10187
|
}
|
|
@@ -16575,7 +16602,7 @@ Deleted file ${pathOrId}.
|
|
|
16575
16602
|
}
|
|
16576
16603
|
|
|
16577
16604
|
// src/index.ts
|
|
16578
|
-
var CLI_VERSION = "0.2.
|
|
16605
|
+
var CLI_VERSION = "0.2.190";
|
|
16579
16606
|
function parseBooleanOption(value) {
|
|
16580
16607
|
if (value === "true") return true;
|
|
16581
16608
|
if (value === "false") return false;
|