replicas-cli 0.3.172 → 0.3.174

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.cjs +54 -3
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -23022,6 +23022,7 @@ var CODEX_ASP_ITEM_ID_PAYLOAD_KEY = "codexAspItemId";
23022
23022
  var CODEX_ITEM_EVENT_TYPE = "codex-item";
23023
23023
  var CODEX_ITEM_PARTIAL_EVENT_TYPE = "codex-item-partial";
23024
23024
  var CODEX_TURN_EVENT_TYPE = "codex-turn";
23025
+ var CODEX_TURN_RETRY_EVENT_TYPE = "codex-turn-retry";
23025
23026
  var CODEX_QUOTA_STATUS_EVENT_TYPE = "codex-quota-status";
23026
23027
  var CHAT_INTERRUPTED_EVENT_TYPE = "replicas-interrupted";
23027
23028
  var CHAT_MESSAGE_REJECTED_EVENT_TYPE = "replicas-message-rejected";
@@ -23047,6 +23048,10 @@ function coerceAuthFallbackPayload(payload) {
23047
23048
  ...typeof detail === "string" && detail ? { detail } : {}
23048
23049
  };
23049
23050
  }
23051
+ function parseCodexTurnRetryPayload(payload) {
23052
+ const { attempt, maxAttempts, [CODEX_ASP_ITEM_ID_PAYLOAD_KEY]: turnId } = payload;
23053
+ return typeof attempt === "number" && typeof maxAttempts === "number" && typeof turnId === "string" ? { attempt, maxAttempts, [CODEX_ASP_ITEM_ID_PAYLOAD_KEY]: turnId } : void 0;
23054
+ }
23050
23055
 
23051
23056
  // ../shared/src/engine/v1.ts
23052
23057
  var MERGED_MESSAGE_SEPARATOR = "\n\n<!-- replicas:merged -->\n\n";
@@ -27188,13 +27193,42 @@ function parseCodexEvents(events) {
27188
27193
  const pendingCommands = /* @__PURE__ */ new Map();
27189
27194
  const pendingToolCalls = /* @__PURE__ */ new Map();
27190
27195
  const pendingPatches = /* @__PURE__ */ new Map();
27196
+ const retriedTurnIds = /* @__PURE__ */ new Set();
27197
+ let pendingRetry = null;
27191
27198
  events.forEach((event, eventIndex) => {
27192
27199
  const turnId = codexItemFromEvent(event)?.turnId ?? codexTurnFromEvent(event)?.turnId;
27193
27200
  if (turnId !== void 0) {
27194
27201
  if (!turnInsertions.has(turnId)) turnInsertions.set(turnId, messages.length);
27202
+ if (pendingRetry && !retriedTurnIds.has(turnId)) {
27203
+ pendingRetry.status = "completed";
27204
+ pendingRetry = null;
27205
+ }
27206
+ return;
27207
+ }
27208
+ if (event.type === CHAT_INTERRUPTED_EVENT_TYPE) {
27209
+ pendingRetry = null;
27210
+ return;
27211
+ }
27212
+ if (event.type === CODEX_TURN_RETRY_EVENT_TYPE) {
27213
+ const retry = parseCodexTurnRetryPayload(event.payload);
27214
+ if (!retry) return;
27215
+ retriedTurnIds.add(retry[CODEX_ASP_ITEM_ID_PAYLOAD_KEY]);
27216
+ pendingRetry = {
27217
+ id: displayId(event, eventIndex, "capacity-retry"),
27218
+ type: "capacity_retry",
27219
+ attempt: retry.attempt,
27220
+ maxAttempts: retry.maxAttempts,
27221
+ status: "in_progress",
27222
+ timestamp: event.timestamp
27223
+ };
27224
+ messages.push(pendingRetry);
27195
27225
  return;
27196
27226
  }
27197
27227
  if (event.type === "codex-asp-error") {
27228
+ if (pendingRetry) {
27229
+ pendingRetry.status = "completed";
27230
+ pendingRetry = null;
27231
+ }
27198
27232
  const failedTurnId = getPayloadString(event, CODEX_ASP_ITEM_ID_PAYLOAD_KEY);
27199
27233
  if (!(failedTurnId && turns.has(failedTurnId))) {
27200
27234
  messages.push({
@@ -27376,6 +27410,13 @@ function parseCodexEvents(events) {
27376
27410
  if (!turn) continue;
27377
27411
  const kept = [];
27378
27412
  for (const message2 of messagesForCodexTurn(turn)) {
27413
+ if (retriedTurnIds.has(turnId)) {
27414
+ if (message2.type === "error") continue;
27415
+ if (message2.type === "reasoning" && message2.status === "in_progress") {
27416
+ kept.push({ ...message2, status: "failed" });
27417
+ continue;
27418
+ }
27419
+ }
27379
27420
  if (message2.type !== "user") {
27380
27421
  kept.push(message2);
27381
27422
  continue;
@@ -29094,7 +29135,7 @@ var headlessAgentRequestSchema = external_exports.object({
29094
29135
  });
29095
29136
 
29096
29137
  // ../shared/src/cli-version.ts
29097
- var CLI_VERSION = "0.3.172";
29138
+ var CLI_VERSION = "0.3.173";
29098
29139
 
29099
29140
  // ../shared/src/version.ts
29100
29141
  function compareVersions(v1, v2) {
@@ -30777,6 +30818,10 @@ var import_prompts7 = __toESM(require("prompts"));
30777
30818
  function formatDate(dateString) {
30778
30819
  return new Date(dateString).toLocaleString();
30779
30820
  }
30821
+ function printReplicaActivity(activity) {
30822
+ console.log(import_chalk7.default.gray(` Agent: ${activity.state.replaceAll("_", " ")}${activity.current_step ? ` \xB7 ${activity.current_step}` : ""}`));
30823
+ if (activity.last_agent_message) console.log(import_chalk7.default.gray(` Last message: ${activity.last_agent_message}`));
30824
+ }
30780
30825
  function ensureOrgApiAuthenticated() {
30781
30826
  if (!canCallOrgApi()) {
30782
30827
  throw new Error('Not logged in. Run "replicas login" or "replicas login --api-key".');
@@ -32757,6 +32802,7 @@ Replica: ${replica.name}
32757
32802
  if (replica.coding_agent) {
32758
32803
  console.log(import_chalk21.default.gray(` Coding Agent: ${replica.coding_agent}`));
32759
32804
  }
32805
+ if (replica.activity) printReplicaActivity(replica.activity);
32760
32806
  if (replica.repository_statuses && replica.repository_statuses.length > 0) {
32761
32807
  console.log(import_chalk21.default.gray(" Repository Statuses:"));
32762
32808
  for (const repositoryStatus of replica.repository_statuses) {
@@ -33002,9 +33048,14 @@ async function workspaceWaitCommand(id, options) {
33002
33048
  do {
33003
33049
  const query = new URLSearchParams({ timeout_seconds: String(Math.max(1, Math.min(50, Math.ceil((deadline - Date.now()) / 1e3)))) });
33004
33050
  if (options.chat) query.set("chat_id", options.chat);
33051
+ const step = result?.activity.current_step;
33005
33052
  result = await orgAuthenticatedFetch(`/v1/replica/${id}/wait?${query}`);
33006
- } while (!result.done && Date.now() < deadline);
33007
- output(result, ({ done, status }) => console.log(done ? `Done (status: ${status})` : `Still working after timeout (status: ${status})`));
33053
+ if (!result.done && result.activity.current_step && result.activity.current_step !== step) console.error(import_chalk22.default.gray(`\u2026 ${result.activity.current_step}`));
33054
+ } while (!result.done && result.activity.state !== "waiting_for_input" && Date.now() < deadline);
33055
+ output(result, ({ done, status, deleted, activity }) => {
33056
+ console.log(done ? `Done (status: ${deleted ? "deleted" : status})` : activity.state === "waiting_for_input" ? "The agent is waiting for input" : `Still working after timeout (status: ${status})`);
33057
+ printReplicaActivity(activity);
33058
+ });
33008
33059
  if (!result.done) process.exitCode = 1;
33009
33060
  }
33010
33061
  async function workspaceStatusCommand(id) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.172",
3
+ "version": "0.3.174",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {