replicas-cli 0.2.323 → 0.2.324

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.mjs +55 -12
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -9536,7 +9536,7 @@ var HOOK_EXEC_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
9536
9536
  var REPLICAS_CONFIG_FILENAMES = ["replicas.json", "replicas.yaml", "replicas.yml"];
9537
9537
 
9538
9538
  // ../shared/src/cli-version.ts
9539
- var CLI_VERSION = "0.2.323";
9539
+ var CLI_VERSION = "0.2.324";
9540
9540
 
9541
9541
  // ../shared/src/engine/environment.ts
9542
9542
  var DESKTOP_NOVNC_PORT = 6080;
@@ -10486,6 +10486,11 @@ function parseClaudeEvents(events, parentToolUseId) {
10486
10486
  const toolCallMap = /* @__PURE__ */ new Map();
10487
10487
  const taskMessageMap = /* @__PURE__ */ new Map();
10488
10488
  const partialIndexes = /* @__PURE__ */ new Map();
10489
+ const completedStreamIds = /* @__PURE__ */ new Set();
10490
+ const supersededStreamIds = /* @__PURE__ */ new Set();
10491
+ let liveStreamId = null;
10492
+ const assistantThinking = /* @__PURE__ */ new Map();
10493
+ const assistantTextCounts = /* @__PURE__ */ new Map();
10489
10494
  const taskAccumulator = new TaskAccumulator();
10490
10495
  const taskSnapshot = () => taskAccumulator.getTasks().map((task) => ({
10491
10496
  text: task.subject,
@@ -10496,6 +10501,10 @@ function parseClaudeEvents(events, parentToolUseId) {
10496
10501
  if (event.type === CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE) {
10497
10502
  const payload = coerceClaudePartialMessagePayload(event.payload);
10498
10503
  if (!payload) return;
10504
+ if (liveStreamId !== null && liveStreamId !== payload.streamId) {
10505
+ supersededStreamIds.add(liveStreamId);
10506
+ }
10507
+ liveStreamId = payload.streamId;
10499
10508
  const existing = partialIndexes.get(payload.streamId) ?? {};
10500
10509
  if (payload.thinking) {
10501
10510
  const reasoningMessage = {
@@ -10558,24 +10567,51 @@ function parseClaudeEvents(events, parentToolUseId) {
10558
10567
  if (event.type === "claude-assistant") {
10559
10568
  const messageId = event.payload.message?.id;
10560
10569
  const contentBlocks = normalizeContentBlocks(event.payload.message?.content);
10561
- const thinkingText = contentBlocks.filter((block) => block.type === "thinking" && block.thinking).map((block) => block.thinking).join("\n\n");
10562
- if (thinkingText) {
10563
- upsertDisplayMessage(messages, {
10564
- id: `reasoning-${messageId || event.timestamp}-thinking`,
10570
+ const messageKey = messageId || event.timestamp;
10571
+ const streamRefs = messageId ? partialIndexes.get(messageId) : void 0;
10572
+ if (messageId) {
10573
+ completedStreamIds.add(messageId);
10574
+ if (liveStreamId !== null && liveStreamId !== messageId) {
10575
+ supersededStreamIds.add(liveStreamId);
10576
+ }
10577
+ liveStreamId = null;
10578
+ }
10579
+ const thinkingBlocks = contentBlocks.flatMap(
10580
+ (block) => block.type === "thinking" && typeof block.thinking === "string" ? [block.thinking] : []
10581
+ );
10582
+ if (thinkingBlocks.length > 0) {
10583
+ const allThinking = [...assistantThinking.get(messageKey) ?? [], ...thinkingBlocks];
10584
+ assistantThinking.set(messageKey, allThinking);
10585
+ const reasoningMessage = {
10586
+ id: `reasoning-${messageKey}-thinking`,
10565
10587
  type: "reasoning",
10566
- content: thinkingText,
10588
+ content: allThinking.join("\n\n"),
10567
10589
  status: "completed",
10568
10590
  timestamp: event.timestamp
10569
- });
10591
+ };
10592
+ if (streamRefs?.reasoning !== void 0) {
10593
+ messages[streamRefs.reasoning] = reasoningMessage;
10594
+ streamRefs.reasoning = void 0;
10595
+ } else {
10596
+ upsertDisplayMessage(messages, reasoningMessage);
10597
+ }
10570
10598
  }
10571
- contentBlocks.forEach((block, blockIndex) => {
10599
+ contentBlocks.forEach((block) => {
10572
10600
  if (block.type === "text" && block.text) {
10573
- upsertDisplayMessage(messages, {
10574
- id: `agent-${messageId || event.timestamp}-${blockIndex}`,
10601
+ const textIndex = assistantTextCounts.get(messageKey) ?? 0;
10602
+ assistantTextCounts.set(messageKey, textIndex + 1);
10603
+ const agentMessage = {
10604
+ id: `agent-${messageKey}-${textIndex}`,
10575
10605
  type: "agent",
10576
10606
  content: block.text,
10577
10607
  timestamp: event.timestamp
10578
- });
10608
+ };
10609
+ if (streamRefs?.agent !== void 0) {
10610
+ messages[streamRefs.agent] = agentMessage;
10611
+ streamRefs.agent = void 0;
10612
+ } else {
10613
+ upsertDisplayMessage(messages, agentMessage);
10614
+ }
10579
10615
  }
10580
10616
  if (block.type === "tool_use" && block.id) {
10581
10617
  const toolName = block.name || "unknown";
@@ -10847,7 +10883,14 @@ function parseClaudeEvents(events, parentToolUseId) {
10847
10883
  }
10848
10884
  }
10849
10885
  });
10850
- return messages;
10886
+ const staleIndexes = /* @__PURE__ */ new Set();
10887
+ for (const streamId of [...completedStreamIds, ...supersededStreamIds]) {
10888
+ const refs = partialIndexes.get(streamId);
10889
+ if (refs?.reasoning !== void 0) staleIndexes.add(refs.reasoning);
10890
+ if (refs?.agent !== void 0) staleIndexes.add(refs.agent);
10891
+ }
10892
+ if (staleIndexes.size === 0) return messages;
10893
+ return messages.filter((_, index) => !staleIndexes.has(index));
10851
10894
  }
10852
10895
 
10853
10896
  // ../shared/src/agent-event-utils.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.2.323",
3
+ "version": "0.2.324",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.mjs",
6
6
  "bin": {