replicas-cli 0.3.259 → 0.3.262

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 +59 -12
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -20465,6 +20465,34 @@ There is no settings page: people change how you behave by telling you, and you
20465
20465
  }
20466
20466
  });
20467
20467
 
20468
+ // ../shared/src/message-origin.ts
20469
+ function parseMessageOrigin(raw) {
20470
+ const workspace = raw.match(WORKSPACE_SENDER);
20471
+ if (workspace) {
20472
+ let name;
20473
+ try {
20474
+ name = JSON.parse(workspace[1]);
20475
+ } catch {
20476
+ return null;
20477
+ }
20478
+ if (typeof name === "string") return { kind: "workspace", id: workspace[2], name, body: stripReplicasInstructionBlock(raw.slice(workspace[0].length)) };
20479
+ }
20480
+ const automation2 = raw.match(SCHEDULED_FOLLOW_UP);
20481
+ return automation2 ? { kind: "automation", id: automation2[2], name: automation2[1].trim(), body: stripReplicasInstructionBlock(raw.slice(automation2[0].length)) } : null;
20482
+ }
20483
+ var UUID, WORKSPACE_SENDER, SCHEDULED_NOTE, SCHEDULED_FOLLOW_UP;
20484
+ var init_message_origin = __esm({
20485
+ "../shared/src/message-origin.ts"() {
20486
+ "use strict";
20487
+ init_prompts();
20488
+ init_uuid();
20489
+ UUID = UUID_RE.source.slice(1, -1);
20490
+ WORKSPACE_SENDER = new RegExp(String.raw`^\s*<${REPLICAS_INSTRUCTIONS_TAG}>\nFrom the workspace ("(?:[^"\\\n]|\\.)*") \((${UUID})\)\.\n</${REPLICAS_INSTRUCTIONS_TAG}>`);
20491
+ SCHEDULED_NOTE = "This is a message you or a teammate scheduled earlier, delivered into this workspace.";
20492
+ SCHEDULED_FOLLOW_UP = new RegExp(String.raw`^\s*\*\*Scheduled follow-up: ([^\n]+)\*\*\n\nThe automation "[^\n]*" \((${UUID})\) fired at \S+\. ${SCHEDULED_NOTE.replace(/\./g, "\\.")}`);
20493
+ }
20494
+ });
20495
+
20468
20496
  // ../shared/src/mothership-events.ts
20469
20497
  function extractMothershipEvents(text3) {
20470
20498
  return [...text3.matchAll(BLOCK)].flatMap((match) => {
@@ -20497,6 +20525,7 @@ var init_mothership_events = __esm({
20497
20525
  init_zod();
20498
20526
  init_v1();
20499
20527
  init_prompts();
20528
+ init_message_origin();
20500
20529
  init_urls();
20501
20530
  MOTHERSHIP_EVENT_KINDS = ["finished", "ready", "needs_attention", "merged", "closed", "archived"];
20502
20531
  MOTHERSHIP_EVENT_TYPE = "multitask-event";
@@ -20986,13 +21015,20 @@ function applyToolInputEvent(event, messages, provider2, state, questionFilter)
20986
21015
  if (event.type === "replicas-tool-input-request" && typeof event.payload.toolUseId === "string" && typeof event.payload.requestId === "string" && (Array.isArray(event.payload.options) || Array.isArray(event.payload.questions))) {
20987
21016
  const previous = state.resolutions.get(event.payload.toolUseId);
20988
21017
  const resolved = previous && (!previous.requestId || previous.requestId === event.payload.requestId) ? previous : void 0;
21018
+ const earlier = state.requests.get(event.payload.toolUseId);
21019
+ const same = earlier?.requestId === event.payload.requestId;
21020
+ if (!same) state.requestedAt.set(event.payload.toolUseId, event.timestamp);
21021
+ const requestedAt = state.requestedAt.get(event.payload.toolUseId) ?? event.timestamp;
21022
+ const answeredNow = resolved && (!same || earlier?.status === "pending");
20989
21023
  const inputRequest = {
20990
21024
  requestId: event.payload.requestId,
20991
21025
  status: resolved?.selectionId === "aborted" || resolved?.selectionId === "declined" ? "aborted" : resolved ? "resolved" : "pending",
20992
21026
  ...Array.isArray(event.payload.options) ? { options: event.payload.options } : {},
20993
21027
  ...Array.isArray(event.payload.questions) ? { questions: questionFilter ? event.payload.questions.filter(questionFilter) : event.payload.questions } : {},
20994
21028
  ...resolved ? { selectionId: resolved.selectionId } : {},
20995
- ...resolved?.selectionSummary ? { selectionSummary: resolved.selectionSummary } : {}
21029
+ ...resolved?.selectionSummary ? { selectionSummary: resolved.selectionSummary } : {},
21030
+ ...resolved ? { resolvedAt: resolved.resolvedAt } : {},
21031
+ waitedMs: (earlier?.waitedMs ?? 0) + (answeredNow ? Math.max(0, parseTimestampMs(resolved.resolvedAt) - parseTimestampMs(requestedAt)) : 0)
20996
21032
  };
20997
21033
  state.requests.set(event.payload.toolUseId, inputRequest);
20998
21034
  const message2 = messages.find((candidate) => candidate.type === "tool_call" && candidate.id === `${provider2}-tool-${event.payload.toolUseId}`);
@@ -21003,7 +21039,8 @@ function applyToolInputEvent(event, messages, provider2, state, questionFilter)
21003
21039
  const resolved = {
21004
21040
  ...typeof event.payload.requestId === "string" ? { requestId: event.payload.requestId } : {},
21005
21041
  selectionId: event.payload.selectionId,
21006
- ...typeof event.payload.selectionSummary === "string" ? { selectionSummary: event.payload.selectionSummary } : {}
21042
+ ...typeof event.payload.selectionSummary === "string" ? { selectionSummary: event.payload.selectionSummary } : {},
21043
+ resolvedAt: event.timestamp
21007
21044
  };
21008
21045
  state.resolutions.set(event.payload.toolUseId, resolved);
21009
21046
  const inputRequest = state.requests.get(event.payload.toolUseId);
@@ -21011,6 +21048,9 @@ function applyToolInputEvent(event, messages, provider2, state, questionFilter)
21011
21048
  inputRequest.status = resolved.selectionId === "aborted" || resolved.selectionId === "declined" ? "aborted" : "resolved";
21012
21049
  inputRequest.selectionId = resolved.selectionId;
21013
21050
  if (resolved.selectionSummary) inputRequest.selectionSummary = resolved.selectionSummary;
21051
+ inputRequest.resolvedAt = resolved.resolvedAt;
21052
+ const requestedAt = state.requestedAt.get(event.payload.toolUseId);
21053
+ if (requestedAt) inputRequest.waitedMs = (inputRequest.waitedMs ?? 0) + Math.max(0, parseTimestampMs(resolved.resolvedAt) - parseTimestampMs(requestedAt));
21014
21054
  }
21015
21055
  return true;
21016
21056
  }
@@ -29759,7 +29799,7 @@ var init_opencode_parser = __esm({
29759
29799
  function parseMuseEvents(events) {
29760
29800
  const messages = [];
29761
29801
  const deltas = /* @__PURE__ */ new Map();
29762
- const inputState = { requests: /* @__PURE__ */ new Map(), resolutions: /* @__PURE__ */ new Map() };
29802
+ const inputState = { requests: /* @__PURE__ */ new Map(), resolutions: /* @__PURE__ */ new Map(), requestedAt: /* @__PURE__ */ new Map() };
29763
29803
  for (const event of events) {
29764
29804
  const userContent = getUserMessage(event);
29765
29805
  if (userContent !== null) {
@@ -30659,7 +30699,8 @@ function parseClaudeEvents(events, parentToolUseId) {
30659
30699
  ...message2.inputRequest,
30660
30700
  status: payload.selectionId === "aborted" ? "aborted" : "resolved",
30661
30701
  selectionId: payload.selectionId,
30662
- selectionSummary: payload.selectionSummary
30702
+ selectionSummary: payload.selectionSummary,
30703
+ resolvedAt: event.timestamp
30663
30704
  };
30664
30705
  }
30665
30706
  });
@@ -30907,10 +30948,12 @@ function filterDisplayMessages(messages, provider2) {
30907
30948
  }
30908
30949
  const cleaned = (msg.images?.length || files.length) && ATTACHMENT_PLACEHOLDER_REGEX.test(content) ? "" : content;
30909
30950
  if (cleaned.length === 0 && !msg.images?.length && files.length === 0 && walkthroughs.length === 0 && appshots.length === 0 && annotations.length === 0) return [];
30910
- if (cleaned === msg.content && files.length === 0 && walkthroughs.length === 0 && appshots.length === 0 && annotations.length === 0) return [msg];
30951
+ const origin = parseMessageOrigin(msg.content);
30952
+ if (cleaned === msg.content && !origin && files.length === 0 && walkthroughs.length === 0 && appshots.length === 0 && annotations.length === 0) return [msg];
30911
30953
  return [{
30912
30954
  ...msg,
30913
30955
  content: cleaned,
30956
+ ...origin ? { origin } : {},
30914
30957
  ...files.length > 0 ? { files } : {},
30915
30958
  ...walkthroughs.length > 0 ? { walkthroughs } : {},
30916
30959
  ...annotations.length > 0 ? { annotations } : {},
@@ -30926,6 +30969,7 @@ var init_parsers = __esm({
30926
30969
  init_event();
30927
30970
  init_mothership_events();
30928
30971
  init_prompts();
30972
+ init_message_origin();
30929
30973
  init_user_message_attachments();
30930
30974
  init_agent_event_utils();
30931
30975
  init_constants();
@@ -31111,6 +31155,7 @@ var init_metadata_pills = __esm({
31111
31155
  "use strict";
31112
31156
  init_agent();
31113
31157
  init_mothership_events();
31158
+ init_message_origin();
31114
31159
  init_prompts();
31115
31160
  init_user_message_attachments();
31116
31161
  init_parsers2();
@@ -31149,6 +31194,7 @@ var W, NOT_BEFORE, NOT_AFTER, URL_RE, PR_URL_RE, PR_NUM_RE, ERR_RE, BENIGN_RE, O
31149
31194
  var init_transcript_condense = __esm({
31150
31195
  "../shared/src/transcript-condense.ts"() {
31151
31196
  "use strict";
31197
+ init_message_origin();
31152
31198
  init_user_message_parser();
31153
31199
  W = "[\\p{L}\\p{N}_]";
31154
31200
  NOT_BEFORE = `(?<!${W})`;
@@ -31548,7 +31594,7 @@ var CLI_VERSION;
31548
31594
  var init_cli_version = __esm({
31549
31595
  "../shared/src/cli-version.ts"() {
31550
31596
  "use strict";
31551
- CLI_VERSION = "0.3.259";
31597
+ CLI_VERSION = "0.3.262";
31552
31598
  }
31553
31599
  });
31554
31600
 
@@ -42216,6 +42262,7 @@ var init_src = __esm({
42216
42262
  init_slash_commands();
42217
42263
  init_prompts();
42218
42264
  init_mothership_events();
42265
+ init_message_origin();
42219
42266
  init_user_message_attachments();
42220
42267
  init_image_attachments();
42221
42268
  init_scout();
@@ -42524,15 +42571,15 @@ async function ask(question) {
42524
42571
  if (!isInteractive()) {
42525
42572
  throw new Error(`Missing input (${String(question.message).trim()}) and no interactive terminal to ask for it. Pass it as an option; see --help.`);
42526
42573
  }
42527
- return (0, import_prompts6.default)(question);
42574
+ return (0, import_prompts7.default)(question);
42528
42575
  }
42529
- var import_chalk, import_prompts6, jsonMode, isJsonMode, isInteractive, outputSuccess;
42576
+ var import_chalk, import_prompts7, jsonMode, isJsonMode, isInteractive, outputSuccess;
42530
42577
  var init_output = __esm({
42531
42578
  "src/lib/output.ts"() {
42532
42579
  "use strict";
42533
42580
  import_chalk = __toESM(require("chalk"));
42534
42581
  init_src();
42535
- import_prompts6 = __toESM(require("prompts"));
42582
+ import_prompts7 = __toESM(require("prompts"));
42536
42583
  jsonMode = false;
42537
42584
  isJsonMode = () => jsonMode;
42538
42585
  isInteractive = () => !jsonMode && !!process.stdin.isTTY;
@@ -43329,16 +43376,16 @@ function parseKeyValuePairs(pairs) {
43329
43376
  }
43330
43377
  async function confirmAction(message2) {
43331
43378
  if (!isInteractive()) throw new Error(`${message2} Pass -f to confirm without a terminal.`);
43332
- const { confirm } = await (0, import_prompts7.default)({ type: "confirm", name: "confirm", message: message2, initial: false });
43379
+ const { confirm } = await (0, import_prompts8.default)({ type: "confirm", name: "confirm", message: message2, initial: false });
43333
43380
  if (!confirm) console.log(import_chalk7.default.yellow("\nCancelled."));
43334
43381
  return Boolean(confirm);
43335
43382
  }
43336
- var import_chalk7, import_prompts7;
43383
+ var import_chalk7, import_prompts8;
43337
43384
  var init_command_utils = __esm({
43338
43385
  "src/lib/command-utils.ts"() {
43339
43386
  "use strict";
43340
43387
  import_chalk7 = __toESM(require("chalk"));
43341
- import_prompts7 = __toESM(require("prompts"));
43388
+ import_prompts8 = __toESM(require("prompts"));
43342
43389
  init_config();
43343
43390
  init_output();
43344
43391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.259",
3
+ "version": "0.3.262",
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": {