replicas-mcp 0.2.5 → 0.2.8

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.
@@ -4,7 +4,7 @@ import {
4
4
  fromUtf8,
5
5
  toHex,
6
6
  toUtf8
7
- } from "./chunk-C6IOMGXW.js";
7
+ } from "./chunk-B7L4ZPGB.js";
8
8
  import "./chunk-Q6JESX2O.js";
9
9
 
10
10
  // ../node_modules/.bun/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
@@ -496,7 +496,7 @@ var a_lookUpTable = [
496
496
  ];
497
497
  var lookupTable = uint32ArrayFrom(a_lookUpTable);
498
498
 
499
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/Int64.js
499
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/Int64.js
500
500
  var Int64 = class _Int64 {
501
501
  bytes;
502
502
  constructor(bytes) {
@@ -541,7 +541,7 @@ function negate(bytes) {
541
541
  }
542
542
  }
543
543
 
544
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js
544
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/HeaderMarshaller.js
545
545
  var HeaderMarshaller = class {
546
546
  toUtf8;
547
547
  fromUtf8;
@@ -725,7 +725,7 @@ var TIMESTAMP_TAG = "timestamp";
725
725
  var UUID_TAG = "uuid";
726
726
  var UUID_PATTERN = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
727
727
 
728
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js
728
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/splitMessage.js
729
729
  var PRELUDE_MEMBER_LENGTH = 4;
730
730
  var PRELUDE_LENGTH = PRELUDE_MEMBER_LENGTH * 2;
731
731
  var CHECKSUM_LENGTH = 4;
@@ -756,7 +756,7 @@ function splitMessage({ byteLength, byteOffset, buffer }) {
756
756
  };
757
757
  }
758
758
 
759
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js
759
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/EventStreamCodec.js
760
760
  var EventStreamCodec = class {
761
761
  headerMarshaller;
762
762
  messageBuffer;
@@ -820,7 +820,7 @@ var EventStreamCodec = class {
820
820
  }
821
821
  };
822
822
 
823
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageDecoderStream.js
823
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageDecoderStream.js
824
824
  var MessageDecoderStream = class {
825
825
  options;
826
826
  constructor(options) {
@@ -837,7 +837,7 @@ var MessageDecoderStream = class {
837
837
  }
838
838
  };
839
839
 
840
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageEncoderStream.js
840
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/MessageEncoderStream.js
841
841
  var MessageEncoderStream = class {
842
842
  options;
843
843
  constructor(options) {
@@ -857,7 +857,7 @@ var MessageEncoderStream = class {
857
857
  }
858
858
  };
859
859
 
860
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js
860
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageDecoderStream.js
861
861
  var SmithyMessageDecoderStream = class {
862
862
  options;
863
863
  constructor(options) {
@@ -876,7 +876,7 @@ var SmithyMessageDecoderStream = class {
876
876
  }
877
877
  };
878
878
 
879
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageEncoderStream.js
879
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-codec/SmithyMessageEncoderStream.js
880
880
  var SmithyMessageEncoderStream = class {
881
881
  options;
882
882
  constructor(options) {
@@ -893,10 +893,10 @@ var SmithyMessageEncoderStream = class {
893
893
  }
894
894
  };
895
895
 
896
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
896
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
897
897
  import { Readable } from "stream";
898
898
 
899
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getChunkedStream.js
899
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getChunkedStream.js
900
900
  function getChunkedStream(source) {
901
901
  let currentMessageTotalLength = 0;
902
902
  let currentMessagePendingLength = 0;
@@ -962,7 +962,7 @@ function getChunkedStream(source) {
962
962
  };
963
963
  }
964
964
 
965
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js
965
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/getUnmarshalledStream.js
966
966
  function getUnmarshalledStream(source, options) {
967
967
  const messageUnmarshaller = getMessageUnmarshaller(options.deserializer, options.toUtf8);
968
968
  return {
@@ -1008,7 +1008,7 @@ function getMessageUnmarshaller(deserializer, toUtf82) {
1008
1008
  };
1009
1009
  }
1010
1010
 
1011
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/EventStreamMarshaller.js
1011
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-universal/EventStreamMarshaller.js
1012
1012
  var EventStreamMarshaller = class {
1013
1013
  eventStreamCodec;
1014
1014
  utfEncoder;
@@ -1033,7 +1033,7 @@ var EventStreamMarshaller = class {
1033
1033
  };
1034
1034
  var eventStreamSerdeProvider = (options) => new EventStreamMarshaller(options);
1035
1035
 
1036
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
1036
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/EventStreamMarshaller.js
1037
1037
  var EventStreamMarshaller2 = class {
1038
1038
  universalMarshaller;
1039
1039
  constructor({ utf8Encoder, utf8Decoder }) {
@@ -1078,7 +1078,7 @@ async function* readableToIterable(readStream) {
1078
1078
  }
1079
1079
  }
1080
1080
 
1081
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/utils.js
1081
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde/utils.js
1082
1082
  var readableStreamToIterable = (readableStream) => ({
1083
1083
  [Symbol.asyncIterator]: async function* () {
1084
1084
  const reader = readableStream.getReader();
@@ -1107,12 +1107,12 @@ var iterableToReadableStream = (asyncIterable) => {
1107
1107
  });
1108
1108
  };
1109
1109
 
1110
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-config-resolver/EventStreamSerdeConfig.js
1110
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/eventstream-serde-config-resolver/EventStreamSerdeConfig.js
1111
1111
  var resolveEventStreamSerdeConfig = (input) => Object.assign(input, {
1112
1112
  eventStreamMarshaller: input.eventStreamSerdeProvider(input)
1113
1113
  });
1114
1114
 
1115
- // ../node_modules/.bun/@smithy+core@3.24.6/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
1115
+ // ../node_modules/.bun/@smithy+core@3.25.1/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js
1116
1116
  var EventStreamSerde = class {
1117
1117
  marshaller;
1118
1118
  serializer;
package/dist/index.js CHANGED
@@ -7342,6 +7342,32 @@ function isRecord(value) {
7342
7342
  return typeof value === "object" && value !== null && !Array.isArray(value);
7343
7343
  }
7344
7344
 
7345
+ // ../shared/src/agent.ts
7346
+ var VALID_AGENT_PROVIDERS = ["claude", "codex", "cursor", "opencode", "relay"];
7347
+ var VALID_CODING_AGENT_PROVIDERS = VALID_AGENT_PROVIDERS.filter(
7348
+ (provider) => provider !== "relay"
7349
+ );
7350
+ function isValidCodingAgentProvider(value) {
7351
+ return VALID_CODING_AGENT_PROVIDERS.some((provider) => provider === value);
7352
+ }
7353
+ function getProviderDisplayName(provider, variant = "short") {
7354
+ switch (provider) {
7355
+ case "codex":
7356
+ return "Codex";
7357
+ case "cursor":
7358
+ return "Cursor";
7359
+ case "opencode":
7360
+ return "Opencode";
7361
+ case "relay":
7362
+ return "Relay";
7363
+ case "claude":
7364
+ return variant === "long" ? "Claude Code" : "Claude";
7365
+ }
7366
+ }
7367
+ function getCodingAgentDisplayNames() {
7368
+ return VALID_CODING_AGENT_PROVIDERS.map((provider) => getProviderDisplayName(provider)).join(", ");
7369
+ }
7370
+
7345
7371
  // ../shared/src/event.ts
7346
7372
  var CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE = "claude-partial-message";
7347
7373
  function coerceClaudePartialMessagePayload(payload) {
@@ -7364,6 +7390,10 @@ var CODEX_ASP_ITEM_ID_PAYLOAD_KEY = "codexAspItemId";
7364
7390
  var CODEX_QUOTA_STATUS_EVENT_TYPE = "codex-quota-status";
7365
7391
 
7366
7392
  // ../shared/src/pricing.ts
7393
+ var INTEGRATION_SOURCES = ["slack", "linear", "github", "gitlab"];
7394
+ var SYSTEMIC_SOURCES = ["api", "automation"];
7395
+ var INTEGRATION_SOURCES_SQL = INTEGRATION_SOURCES.map((s) => `'${s}'`).join(", ");
7396
+ var SYSTEMIC_SOURCES_SQL = SYSTEMIC_SOURCES.map((s) => `'${s}'`).join(", ");
7367
7397
  var PLANS = {
7368
7398
  hobby: {
7369
7399
  id: "hobby",
@@ -7489,16 +7519,13 @@ scrot /tmp/state.png
7489
7519
  replicas computer info
7490
7520
 
7491
7521
  # 2) Launch a browser on the workspace display.
7492
- replicas computer launch chrome
7522
+ replicas computer launch chrome https://news.ycombinator.com
7493
7523
 
7494
7524
  # 3) Take a screenshot so you can see what's there.
7495
7525
  replicas computer screenshot /tmp/state.png
7496
7526
  # (Read the PNG yourself before deciding where to click.)
7497
7527
 
7498
7528
  # 4) Drive the UI.
7499
- replicas computer key ctrl+l # focus address bar
7500
- replicas computer type "https://news.ycombinator.com"
7501
- replicas computer key Return
7502
7529
  replicas computer click 521 700 # click coordinates from the screenshot
7503
7530
  replicas computer scroll down --amount 5
7504
7531
 
@@ -7551,6 +7578,7 @@ Spawns an app on the workspace display. Built-in aliases:
7551
7578
  - \`notepad\` / \`editor\` - mousepad (lightweight GTK text editor)
7552
7579
  - \`files\` / \`filemanager\` - thunar (file manager)
7553
7580
  Anything else gets \`exec\`'d verbatim, so \`replicas computer launch xeyes\` works if xeyes is installed.
7581
+ When opening a known page, prefer passing the URL directly: \`replicas computer launch chrome http://localhost:3000/\`.
7554
7582
 
7555
7583
  ### \`replicas computer record start <path> [--fps N]\`
7556
7584
  Starts an ffmpeg screen recorder. Output is a fragmented MP4 (still playable if the workspace dies mid-record). Default 60fps; drop to 30 if the workspace is CPU-constrained.
@@ -7576,6 +7604,8 @@ replicas computer screenshot /tmp/after-click.png
7576
7604
 
7577
7605
  ### Typing into an address bar
7578
7606
  \`\`\`bash
7607
+ replicas computer launch chrome
7608
+ sleep 2
7579
7609
  replicas computer key ctrl+l # focus address bar
7580
7610
  replicas computer type "https://example.com"
7581
7611
  replicas computer key Return
@@ -8957,6 +8987,8 @@ var HOOK_EXEC_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
8957
8987
  var CLAUDE_OPUS_1M_MODEL = "opus[1m]";
8958
8988
  var LEGACY_CLAUDE_OPUS_1M_MODEL = "opus-1m";
8959
8989
  var DEFAULT_CODEX_MODEL = "gpt-5.5";
8990
+ var DEFAULT_CURSOR_MODEL = "composer-2";
8991
+ var DEFAULT_OPENCODE_MODEL = "z-ai/glm-5.2";
8960
8992
  var MODEL_LABELS = {
8961
8993
  sonnet: "Sonnet 4.5",
8962
8994
  opus: "Opus 4.8",
@@ -8964,6 +8996,12 @@ var MODEL_LABELS = {
8964
8996
  [LEGACY_CLAUDE_OPUS_1M_MODEL]: "Opus 4.8 (1M)",
8965
8997
  haiku: "Haiku 4.5",
8966
8998
  [DEFAULT_CODEX_MODEL]: "GPT-5.5",
8999
+ [DEFAULT_CURSOR_MODEL]: "Composer 2",
9000
+ [DEFAULT_OPENCODE_MODEL]: "GLM 5.2 via OpenRouter",
9001
+ "composer-2.5": "Composer 2.5",
9002
+ "minimax/minimax-m3": "MiniMax M3 via OpenRouter",
9003
+ "xiaomi/mimo-v2.5-pro": "MiMo V2.5 Pro via OpenRouter",
9004
+ "moonshotai/kimi-k2.6:free": "Kimi K2.6 via OpenRouter",
8967
9005
  "gpt-5.4": "GPT-5.4",
8968
9006
  "gpt-5.4-mini": "GPT-5.4 Mini",
8969
9007
  "gpt-5.3-codex": "GPT-5.3 Codex",
@@ -9309,6 +9347,330 @@ function parseCodexEvents(events) {
9309
9347
  return messages;
9310
9348
  }
9311
9349
 
9350
+ // ../shared/src/display-message/parsers/utils.ts
9351
+ function stringifyDisplayValue(value) {
9352
+ if (value === void 0 || value === null) return void 0;
9353
+ if (typeof value === "string") return value;
9354
+ try {
9355
+ return JSON.stringify(value, null, 2);
9356
+ } catch {
9357
+ return String(value);
9358
+ }
9359
+ }
9360
+
9361
+ // ../shared/src/display-message/parsers/cursor-parser.ts
9362
+ function getTextContent(value) {
9363
+ if (!Array.isArray(value)) return "";
9364
+ return value.map((block) => isRecord(block) && block.type === "text" && typeof block.text === "string" ? block.text : "").join("");
9365
+ }
9366
+ function cursorStatusToDisplayStatus(status) {
9367
+ return status === "completed" || status === "FINISHED" ? "completed" : status === "error" || status === "ERROR" || status === "CANCELLED" || status === "EXPIRED" ? "failed" : "in_progress";
9368
+ }
9369
+ function cursorRunId(event) {
9370
+ const runId = event.payload.run_id;
9371
+ return typeof runId === "string" ? runId : "unknown-run";
9372
+ }
9373
+ function getCursorAssistantText(event) {
9374
+ const message = isRecord(event.payload.message) ? event.payload.message : null;
9375
+ return getTextContent(message?.content);
9376
+ }
9377
+ function getCursorThinkingText(event) {
9378
+ const text = event.payload.text;
9379
+ if (typeof text === "string") return text;
9380
+ const message = isRecord(event.payload.message) ? event.payload.message : null;
9381
+ return typeof message?.text === "string" ? message.text : "";
9382
+ }
9383
+ function isTerminalStatus(status) {
9384
+ return status === "FINISHED" || status === "ERROR" || status === "CANCELLED" || status === "EXPIRED";
9385
+ }
9386
+ function finalizeOpenTools(messages, toolIndexes, status) {
9387
+ for (const index of toolIndexes.values()) {
9388
+ const message = messages[index];
9389
+ if (message?.type === "tool_call" && message.status === "in_progress") {
9390
+ messages[index] = {
9391
+ ...message,
9392
+ status
9393
+ };
9394
+ }
9395
+ }
9396
+ }
9397
+ function parseCursorEvents(events) {
9398
+ const messages = [];
9399
+ const toolIndexes = /* @__PURE__ */ new Map();
9400
+ const runAssistantSegments = /* @__PURE__ */ new Map();
9401
+ const runThinkingSegments = /* @__PURE__ */ new Map();
9402
+ let activeAssistant = null;
9403
+ let activeThinking = null;
9404
+ const finalizeActiveThinking = (status) => {
9405
+ if (!activeThinking) return;
9406
+ const message = messages[activeThinking.index];
9407
+ if (message?.type === "reasoning") {
9408
+ messages[activeThinking.index] = {
9409
+ ...message,
9410
+ status
9411
+ };
9412
+ }
9413
+ };
9414
+ for (const event of events) {
9415
+ if (event.type === "event_msg" && event.payload.type === "user_message") {
9416
+ activeAssistant = null;
9417
+ activeThinking = null;
9418
+ const message = event.payload.message;
9419
+ if (typeof message === "string" && message.trim()) {
9420
+ messages.push({
9421
+ id: `cursor-user-${event.timestamp}-${messages.length}`,
9422
+ type: "user",
9423
+ content: message,
9424
+ timestamp: event.timestamp
9425
+ });
9426
+ }
9427
+ continue;
9428
+ }
9429
+ if (event.type === "cursor-assistant") {
9430
+ const text = getCursorAssistantText(event);
9431
+ if (text) {
9432
+ const runId = cursorRunId(event);
9433
+ if (!activeAssistant || activeAssistant.runId !== runId) {
9434
+ const segment = runAssistantSegments.get(runId) ?? 0;
9435
+ runAssistantSegments.set(runId, segment + 1);
9436
+ activeAssistant = {
9437
+ runId,
9438
+ index: messages.push({
9439
+ id: `cursor-agent-${runId}-${segment}`,
9440
+ type: "agent",
9441
+ content: "",
9442
+ timestamp: event.timestamp
9443
+ }) - 1
9444
+ };
9445
+ }
9446
+ const message = messages[activeAssistant.index];
9447
+ if (message?.type === "agent") {
9448
+ messages[activeAssistant.index] = {
9449
+ ...message,
9450
+ content: `${message.content}${text}`
9451
+ };
9452
+ }
9453
+ }
9454
+ continue;
9455
+ }
9456
+ if (event.type === "cursor-thinking") {
9457
+ const text = getCursorThinkingText(event);
9458
+ if (text.trim()) {
9459
+ const runId = cursorRunId(event);
9460
+ if (!activeThinking || activeThinking.runId !== runId) {
9461
+ const segment = runThinkingSegments.get(runId) ?? 0;
9462
+ runThinkingSegments.set(runId, segment + 1);
9463
+ activeThinking = {
9464
+ runId,
9465
+ index: messages.push({
9466
+ id: `cursor-reasoning-${runId}-${segment}`,
9467
+ type: "reasoning",
9468
+ content: "",
9469
+ status: "in_progress",
9470
+ timestamp: event.timestamp
9471
+ }) - 1
9472
+ };
9473
+ }
9474
+ const message = messages[activeThinking.index];
9475
+ if (message?.type === "reasoning") {
9476
+ messages[activeThinking.index] = {
9477
+ ...message,
9478
+ content: `${message.content}${text}`,
9479
+ status: "in_progress"
9480
+ };
9481
+ }
9482
+ }
9483
+ continue;
9484
+ }
9485
+ if (event.type === "cursor-tool_call") {
9486
+ activeAssistant = null;
9487
+ const callId = typeof event.payload.call_id === "string" ? event.payload.call_id : `cursor-tool-${event.timestamp}-${messages.length}`;
9488
+ const tool = typeof event.payload.name === "string" ? event.payload.name : "tool";
9489
+ const status = cursorStatusToDisplayStatus(event.payload.status);
9490
+ const input = isRecord(event.payload.args) ? event.payload.args : typeof event.payload.args === "string" ? event.payload.args : void 0;
9491
+ const existing = toolIndexes.get(callId);
9492
+ const next = {
9493
+ id: callId,
9494
+ type: "tool_call",
9495
+ server: "cursor",
9496
+ tool,
9497
+ ...input !== void 0 ? { input } : {},
9498
+ output: stringifyDisplayValue(event.payload.result),
9499
+ status,
9500
+ timestamp: event.timestamp
9501
+ };
9502
+ if (existing === void 0) {
9503
+ toolIndexes.set(callId, messages.push(next) - 1);
9504
+ } else {
9505
+ messages[existing] = { ...messages[existing], ...next };
9506
+ }
9507
+ continue;
9508
+ }
9509
+ if (event.type === "cursor-task") {
9510
+ activeAssistant = null;
9511
+ const text = event.payload.text;
9512
+ if (typeof text === "string" && text.trim()) {
9513
+ messages.push({
9514
+ id: `cursor-task-${event.timestamp}-${messages.length}`,
9515
+ type: "agent",
9516
+ content: text,
9517
+ timestamp: event.timestamp
9518
+ });
9519
+ }
9520
+ continue;
9521
+ }
9522
+ if (event.type === "cursor-status") {
9523
+ const status = event.payload.status;
9524
+ if (isTerminalStatus(status)) {
9525
+ const displayStatus = cursorStatusToDisplayStatus(status);
9526
+ finalizeActiveThinking(displayStatus);
9527
+ finalizeOpenTools(messages, toolIndexes, displayStatus);
9528
+ activeThinking = null;
9529
+ activeAssistant = null;
9530
+ }
9531
+ continue;
9532
+ }
9533
+ if (event.type === "cursor-error") {
9534
+ finalizeActiveThinking("failed");
9535
+ finalizeOpenTools(messages, toolIndexes, "failed");
9536
+ activeAssistant = null;
9537
+ activeThinking = null;
9538
+ const message = typeof event.payload.message === "string" ? event.payload.message : "Cursor run failed";
9539
+ messages.push({
9540
+ id: `cursor-error-${event.timestamp}-${messages.length}`,
9541
+ type: "error",
9542
+ message,
9543
+ timestamp: event.timestamp
9544
+ });
9545
+ }
9546
+ }
9547
+ return messages;
9548
+ }
9549
+
9550
+ // ../shared/src/display-message/parsers/opencode-parser.ts
9551
+ function timestampFromMs(value, fallback) {
9552
+ return typeof value === "number" && Number.isFinite(value) ? new Date(value).toISOString() : fallback;
9553
+ }
9554
+ function partFromEvent(event) {
9555
+ return isRecord(event.payload.part) ? event.payload.part : null;
9556
+ }
9557
+ function toolStatus(status) {
9558
+ return status === "completed" ? "completed" : status === "error" ? "failed" : "in_progress";
9559
+ }
9560
+ function setById(messages, id, next) {
9561
+ const index = messages.findIndex((message) => message.id === id);
9562
+ if (index === -1) {
9563
+ messages.push(next);
9564
+ } else {
9565
+ messages[index] = next;
9566
+ }
9567
+ }
9568
+ function assistantError(info) {
9569
+ if (!isRecord(info) || !isRecord(info.error)) return null;
9570
+ const data = isRecord(info.error.data) ? info.error.data : null;
9571
+ if (typeof data?.message === "string") return data.message;
9572
+ if (typeof info.error.message === "string") return info.error.message;
9573
+ return stringifyDisplayValue(info.error) ?? "Opencode run failed";
9574
+ }
9575
+ function parseOpencodeEvents(events) {
9576
+ const messages = [];
9577
+ for (const event of events) {
9578
+ if (event.type === "event_msg" && event.payload.type === "user_message") {
9579
+ const message = event.payload.message;
9580
+ if (typeof message === "string" && message.trim()) {
9581
+ messages.push({
9582
+ id: `opencode-user-${event.timestamp}-${messages.length}`,
9583
+ type: "user",
9584
+ content: message,
9585
+ timestamp: event.timestamp
9586
+ });
9587
+ }
9588
+ continue;
9589
+ }
9590
+ if (event.type === "opencode-message.updated") {
9591
+ const error = assistantError(event.payload.info);
9592
+ if (error) {
9593
+ messages.push({
9594
+ id: `opencode-error-${event.timestamp}-${messages.length}`,
9595
+ type: "error",
9596
+ message: error,
9597
+ timestamp: event.timestamp
9598
+ });
9599
+ }
9600
+ continue;
9601
+ }
9602
+ if (event.type === "opencode-error") {
9603
+ const message = typeof event.payload.message === "string" ? event.payload.message : "Opencode run failed";
9604
+ messages.push({
9605
+ id: `opencode-error-${event.timestamp}-${messages.length}`,
9606
+ type: "error",
9607
+ message,
9608
+ timestamp: event.timestamp
9609
+ });
9610
+ continue;
9611
+ }
9612
+ const part = partFromEvent(event);
9613
+ if (!part) continue;
9614
+ const id = typeof part.id === "string" ? `opencode-${part.id}` : `opencode-${event.timestamp}-${messages.length}`;
9615
+ const time = isRecord(part.time) ? part.time : null;
9616
+ const timestamp = timestampFromMs(time?.start, event.timestamp);
9617
+ if (part.type === "text") {
9618
+ const text = typeof part.text === "string" ? part.text : "";
9619
+ if (text.trim()) {
9620
+ setById(messages, id, {
9621
+ id,
9622
+ type: "agent",
9623
+ content: text,
9624
+ timestamp
9625
+ });
9626
+ }
9627
+ continue;
9628
+ }
9629
+ if (part.type === "reasoning") {
9630
+ const text = typeof part.text === "string" ? part.text : "";
9631
+ if (text.trim()) {
9632
+ setById(messages, id, {
9633
+ id,
9634
+ type: "reasoning",
9635
+ content: text,
9636
+ status: time?.end ? "completed" : "in_progress",
9637
+ timestamp
9638
+ });
9639
+ }
9640
+ continue;
9641
+ }
9642
+ if (part.type === "tool" && isRecord(part.state)) {
9643
+ const state = part.state;
9644
+ const status = toolStatus(state.status);
9645
+ const output = state.status === "completed" ? stringifyDisplayValue(state.output) : state.status === "error" ? stringifyDisplayValue(state.error) : void 0;
9646
+ setById(messages, id, {
9647
+ id,
9648
+ type: "tool_call",
9649
+ server: "opencode",
9650
+ tool: typeof part.tool === "string" ? part.tool : "tool",
9651
+ input: isRecord(state.input) ? state.input : stringifyDisplayValue(state.input),
9652
+ output,
9653
+ status,
9654
+ timestamp
9655
+ });
9656
+ continue;
9657
+ }
9658
+ if (part.type === "patch") {
9659
+ const files = Array.isArray(part.files) ? part.files.filter((file) => typeof file === "string") : [];
9660
+ if (files.length > 0) {
9661
+ setById(messages, id, {
9662
+ id,
9663
+ type: "file_change",
9664
+ changes: files.map((path) => ({ path, kind: "update" })),
9665
+ status: "completed",
9666
+ timestamp
9667
+ });
9668
+ }
9669
+ }
9670
+ }
9671
+ return messages;
9672
+ }
9673
+
9312
9674
  // ../shared/src/display-message/task-accumulator.ts
9313
9675
  function mapTaskStatus(status) {
9314
9676
  if (status === "in_progress" || status === "completed") return status;
@@ -9840,6 +10202,12 @@ function parseAgentEvents(events, agentType) {
9840
10202
  if (agentType === "codex") {
9841
10203
  return parseCodexEvents(events);
9842
10204
  }
10205
+ if (agentType === "cursor") {
10206
+ return parseCursorEvents(events);
10207
+ }
10208
+ if (agentType === "opencode") {
10209
+ return parseOpencodeEvents(events);
10210
+ }
9843
10211
  return parseClaudeEvents(events);
9844
10212
  }
9845
10213
 
@@ -9884,9 +10252,12 @@ function result(data, isError = false) {
9884
10252
  }
9885
10253
  var server = new McpServer({
9886
10254
  name: "replicas-mcp",
9887
- version: "0.2.5"
10255
+ version: "0.2.8"
9888
10256
  });
9889
10257
  var registerTool = server.registerTool.bind(server);
10258
+ var codingAgentSchema = z.string().refine(isValidCodingAgentProvider, {
10259
+ message: `Coding agent must be ${getCodingAgentDisplayNames()}`
10260
+ });
9890
10261
  registerTool(
9891
10262
  "create_replica",
9892
10263
  {
@@ -9896,7 +10267,7 @@ registerTool(
9896
10267
  message: z.string(),
9897
10268
  repository_ids: z.array(z.string()).min(1).optional().describe("Repository IDs to include. Mutually exclusive with repository_set_id."),
9898
10269
  repository_set_id: z.string().optional().describe("Repository set ID to use. Mutually exclusive with repository_ids."),
9899
- coding_agent: z.enum(["claude", "codex"]).optional().describe("Coding agent to use (default: claude)"),
10270
+ coding_agent: codingAgentSchema.optional().describe("Coding agent to use (default: claude)"),
9900
10271
  model: z.string().optional().describe("Model to use for the coding agent"),
9901
10272
  lifecycle_policy: z.enum(["default", "delete_when_done", "delete_after_inactivity"]).optional().describe("Lifecycle policy for the workspace")
9902
10273
  }
@@ -9972,7 +10343,7 @@ registerTool(
9972
10343
  inputSchema: {
9973
10344
  id: z.string(),
9974
10345
  message: z.string(),
9975
- coding_agent: z.enum(["claude", "codex"]).optional().describe("Coding agent to use"),
10346
+ coding_agent: codingAgentSchema.optional().describe("Coding agent to use"),
9976
10347
  chat_id: z.string().optional().describe("Chat ID to send the message to (uses default chat if omitted)"),
9977
10348
  model: z.string().optional().describe("Model to use"),
9978
10349
  plan_mode: z.boolean().optional().describe("Whether to use plan mode")
@@ -10055,7 +10426,7 @@ registerTool(
10055
10426
  description: "Create a new chat in a replica workspace",
10056
10427
  inputSchema: {
10057
10428
  id: z.string().describe("Replica ID"),
10058
- provider: z.enum(["claude", "codex"]).describe("Coding agent provider for the chat"),
10429
+ provider: codingAgentSchema.describe("Coding agent provider for the chat"),
10059
10430
  title: z.string().optional().describe("Optional title for the chat")
10060
10431
  }
10061
10432
  },