replicas-cli 0.2.704 → 0.2.705

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 +45 -17
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -25068,6 +25068,15 @@ function removeReplicasInstructions(text) {
25068
25068
  return removeTag(text, REPLICAS_INSTRUCTIONS_TAG);
25069
25069
  }
25070
25070
 
25071
+ // ../shared/src/user-message-matching.ts
25072
+ function parseTimestampMs(timestamp) {
25073
+ const value = typeof timestamp === "number" ? timestamp : Date.parse(timestamp);
25074
+ return Number.isFinite(value) ? value : 0;
25075
+ }
25076
+ function areUserMessagesWithinMatchWindow(a, b) {
25077
+ return a.content === b.content && Math.abs(parseTimestampMs(a.timestamp) - parseTimestampMs(b.timestamp)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
25078
+ }
25079
+
25071
25080
  // ../shared/src/display-message/parsers/codex-asp-parser.ts
25072
25081
  function collectCodexTurns(events) {
25073
25082
  const turns = /* @__PURE__ */ new Map();
@@ -25335,6 +25344,25 @@ function parsePatch(input) {
25335
25344
  }
25336
25345
  return operations;
25337
25346
  }
25347
+ function takeRecordedPrompt(prompts7, echo, turnIndex) {
25348
+ const timestampMs = parseTimestampMs(echo.timestamp);
25349
+ let closestIndex = -1;
25350
+ let closestDistance = Infinity;
25351
+ for (let i = prompts7.length - 1; i >= 0; i--) {
25352
+ const candidate = prompts7[i];
25353
+ const distance = Math.abs(candidate.timestampMs - timestampMs);
25354
+ if (distance > closestDistance) continue;
25355
+ if (candidate.index >= turnIndex && !areUserMessagesWithinMatchWindow(
25356
+ { content: candidate.message.content, timestamp: candidate.timestampMs },
25357
+ { content: echo.content, timestamp: timestampMs }
25358
+ )) continue;
25359
+ const images = candidate.message.images;
25360
+ if (images && echo.images && (images.length !== echo.images.length || images.some((image, index) => image.mediaType !== echo.images?.[index].mediaType || image.data !== echo.images?.[index].data))) continue;
25361
+ closestIndex = i;
25362
+ closestDistance = distance;
25363
+ }
25364
+ return closestIndex === -1 ? void 0 : prompts7.splice(closestIndex, 1)[0].message;
25365
+ }
25338
25366
  function parseCodexEvents(events) {
25339
25367
  const messages = [];
25340
25368
  const turns = collectCodexTurns(events);
@@ -25518,26 +25546,35 @@ function parseCodexEvents(events) {
25518
25546
  }
25519
25547
  }
25520
25548
  });
25549
+ const recordedPrompts = /* @__PURE__ */ new Map();
25550
+ messages.forEach((message, index) => {
25551
+ if (message.type !== "user") return;
25552
+ const prompts7 = recordedPrompts.get(message.content) ?? [];
25553
+ prompts7.push({ message, index, timestampMs: parseTimestampMs(message.timestamp) });
25554
+ recordedPrompts.set(message.content, prompts7);
25555
+ });
25521
25556
  const claimedPrompts = /* @__PURE__ */ new Set();
25522
25557
  for (const { index, turnId } of turnInsertions.reverse()) {
25523
25558
  const turn = turns.get(turnId);
25524
25559
  if (!turn) continue;
25525
25560
  const kept = [];
25526
25561
  for (const message of messagesForCodexTurn(turn)) {
25527
- const recordedIndex = message.type === "user" ? messages.findLastIndex((candidate, candidateIndex) => candidateIndex < index && candidate.type === "user" && candidate.content === message.content && !claimedPrompts.has(candidateIndex)) : -1;
25528
- if (recordedIndex === -1) {
25562
+ if (message.type !== "user") {
25529
25563
  kept.push(message);
25530
25564
  continue;
25531
25565
  }
25532
- claimedPrompts.add(recordedIndex);
25533
- const recorded = messages[recordedIndex];
25534
- if (recorded.type === "user" && message.type === "user" && !recorded.images && message.images) {
25535
- messages[recordedIndex] = { ...recorded, images: message.images };
25566
+ const prompts7 = recordedPrompts.get(message.content);
25567
+ const recorded = prompts7 && takeRecordedPrompt(prompts7, message, index);
25568
+ if (!recorded) {
25569
+ kept.push(message);
25570
+ continue;
25536
25571
  }
25572
+ claimedPrompts.add(recorded);
25573
+ kept.push({ ...recorded, images: recorded.images ?? message.images });
25537
25574
  }
25538
25575
  messages.splice(index, 0, ...kept);
25539
25576
  }
25540
- return messages;
25577
+ return messages.filter((message) => !claimedPrompts.has(message));
25541
25578
  }
25542
25579
 
25543
25580
  // ../shared/src/display-message/parsers/cursor-parser.ts
@@ -26525,15 +26562,6 @@ function parseMcpToolName(name) {
26525
26562
  return { server, tool };
26526
26563
  }
26527
26564
 
26528
- // ../shared/src/user-message-matching.ts
26529
- function parseTimestampMs(timestamp) {
26530
- const value = Date.parse(timestamp);
26531
- return Number.isFinite(value) ? value : 0;
26532
- }
26533
- function areUserMessagesWithinMatchWindow(a, b) {
26534
- return a.content === b.content && Math.abs(parseTimestampMs(a.timestamp) - parseTimestampMs(b.timestamp)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
26535
- }
26536
-
26537
26565
  // ../shared/src/display-message/parsers/claude-parser.ts
26538
26566
  var ABORTED_TERMINAL_REASONS = /* @__PURE__ */ new Set(["aborted_streaming", "aborted_tools"]);
26539
26567
  function createSubagentMessage(messageIndex, timestamp, fields) {
@@ -27375,7 +27403,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
27375
27403
  });
27376
27404
 
27377
27405
  // ../shared/src/cli-version.ts
27378
- var CLI_VERSION = "0.2.704";
27406
+ var CLI_VERSION = "0.2.705";
27379
27407
 
27380
27408
  // ../shared/src/version.ts
27381
27409
  function compareVersions(v1, v2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.2.704",
3
+ "version": "0.2.705",
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": {