replicas-engine 0.1.1698 → 0.1.1701

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.
@@ -8,13 +8,13 @@ import {
8
8
  listCodexModelsForDetails,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-UEWBZU47.js";
12
- import "./chunk-EEVIXUGW.js";
13
- import "./chunk-MKTLGQZ4.js";
14
- import "./chunk-5ZX72IOC.js";
15
- import "./chunk-TMH7DTFL.js";
11
+ } from "./chunk-OCDTIHNH.js";
12
+ import "./chunk-J4L2AHBJ.js";
13
+ import "./chunk-GYYGQTWQ.js";
14
+ import "./chunk-2IMTX5NL.js";
15
+ import "./chunk-YCVC3SGY.js";
16
16
  import "./chunk-UZSNFLDQ.js";
17
- import "./chunk-6KRCEGA6.js";
17
+ import "./chunk-6QWSUURS.js";
18
18
  import "./chunk-VEQXQN22.js";
19
19
  export {
20
20
  CODEX_ULTRAFAST_SERVICE_TIER,
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  execFileAsync
6
- } from "./chunk-TMH7DTFL.js";
6
+ } from "./chunk-YCVC3SGY.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-6KRCEGA6.js";
9
+ } from "./chunk-6QWSUURS.js";
10
10
 
11
11
  // src/utils/codex-agent-env.ts
12
12
  function buildCodexAgentEnv(source = process.env) {
@@ -244,7 +244,7 @@ function getCodexModelProvider(method) {
244
244
  if (method === "foundry") return "azure";
245
245
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
246
246
  }
247
- var ENGINE_PACKAGE_VERSION = "0.1.1698";
247
+ var ENGINE_PACKAGE_VERSION = "0.1.1701";
248
248
  var INITIALIZE_METHOD = "initialize";
249
249
  var INITIALIZED_NOTIFICATION = "initialized";
250
250
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -12556,9 +12556,16 @@ function getChatThreadSources(chats, chat) {
12556
12556
 
12557
12557
  // ../shared/src/credential-refresh.ts
12558
12558
  import { z as z20 } from "zod";
12559
+ var restingCredentialsSchema = z20.object({
12560
+ count: z20.number(),
12561
+ /** Set when every one of them is in this scope. */
12562
+ scope: z20.enum(CREDENTIAL_SCOPE).optional(),
12563
+ resetsAt: z20.string()
12564
+ });
12559
12565
  var engineCredentialRefreshFailureSchema = z20.object({
12560
12566
  code: z20.string(),
12561
- credential: workspaceCredentialSelectionSchema.optional()
12567
+ credential: workspaceCredentialSelectionSchema.optional(),
12568
+ resting: restingCredentialsSchema.optional()
12562
12569
  });
12563
12570
 
12564
12571
  // ../shared/src/credential-pool.ts
@@ -16436,29 +16443,6 @@ function stripAgentInstructionBlocks(text4) {
16436
16443
  else spans(prose, text4.length);
16437
16444
  return stripInstructionBlocksOutside(text4, quoted);
16438
16445
  }
16439
- var managerEventChatNote = (then) => `If a message the user typed in this turn is still unanswered, your final reply answers it and they see it. Otherwise they don't see text you write in this turn: if it brings something they asked for, or a blocker that needs them, send it with ${REPLICAS_MCP_TOOLS.sendToChat}; then ${then}end with a one-line note.`;
16440
- var MANAGER_EVENT_CHAT_NOTE = managerEventChatNote("update the board if its order, notes or overview changed, and ");
16441
- var BOARD_ANSWER_NOTE = "The user answered on the board.";
16442
- var MANAGER_ISSUE_EVENT_CHAT_NOTE = managerEventChatNote("");
16443
- var MERGE_RULE = `- When a pull request should merge once it's approved and CI passes, call \`${REPLICAS_MCP_TOOLS.mergeWhenReady}\`: Replicas merges it and sends \`merged\`, or \`needs_attention\` saying why it can't. Never watch CI or pull requests with \`gh\`, sleep loops or wait scripts, and merge one yourself only when the user wants it merged right away.`;
16444
- var chatRule = (view, news) => `- The chat is like texting an assistant. In a turn the user typed, they see the text you write between tool calls as it streams, your final reply, what you send with \`${REPLICAS_MCP_TOOLS.sendToChat}\`, and your \`${REPLICAS_MCP_TOOLS.setStatus}\` line, never your tool calls. Unless you can answer right away, open with one line on what you'll do first and roughly how long it takes. Then call \`${REPLICAS_MCP_TOOLS.setStatus}\` with a few words on your current step, such as "Reading the billing webhook", and again each time you move to a new step. Before your final reply, write only what they'd want to know now: ${news}. Never narrate tool calls or say you're still working. When they message you mid-turn, reply in one line before anything else, then fold it into your work. Write in a line or two with links and any media inline, and never restate ${view} in chat.`;
16445
- var BOARD_RULES = `- The board in the Ships pane beside this chat is the user's one view of the work: one ticket per task they ask for, holding only that task's pull requests. Replicas fills in each ticket's title, summaries, section and pull requests from the task, the ship's reports and its pull requests, so never restate what a ticket shows, and correct one with \`${REPLICAS_MCP_TOOLS.updateBoard}\` only when it's wrong.
16446
- - Keep the board organized with \`${REPLICAS_MCP_TOOLS.updateBoard}\`: tickets in order, most important first; one short note per ticket only when it adds something, such as "Merge after #12"; and one overview line on where the work as a whole stands. Archive tickets the user no longer needs.
16447
- - Ask the user only for decisions you truly can't make. Make routine calls yourself, such as retries, small scope choices or test cleanup. For a question of your own, create a ticket with it; the user's answer comes to you here, marked "${BOARD_ANSWER_NOTE}". Answers to a ship's questions go straight to that ship.
16448
- - A ship with open pull requests is not done when it sends \`finished\`: Replicas fixes their CI failures and review comments automatically, then sends \`ready\` or \`needs_attention\`. On \`needs_attention\`, direct the ship, or ask the user only if you can't decide.
16449
- ${MERGE_RULE}
16450
- - On every ship event and board answer, act with tools on whatever it unblocks, such as starting the next task once a pull request merges, and update the board if it changed. The user sees nothing you write in these turns unless a message they typed is still unanswered; otherwise reach them only with \`${REPLICAS_MCP_TOOLS.sendToChat}\`, and only for what they'd want right now: a deliverable they asked for, with its media, links or answer; a blocker that needs them, also on the board; or a request of theirs being done. Never for status, such as "PR #12 merged" or "I asked the ship to\u2026". End the turn with a one-line note of what you did.
16451
- ${chatRule("the board", "a finding that changes the answer, a ship you started, or a decision you need")}
16452
- `;
16453
- var ISSUE_RULES = `- Your work lives in issues in your slice of the organization's Issues, which the Issues tab beside this chat shows the user. Before delegating, turn a request into issues with \`replicas issue create\`: one per independent task, so five small bugs are five issues, and a parent with sub-issues for a big project. Reuse an issue the request is about; find it with \`replicas issue list\`. A title says what the task is about, never a ship, branch or pull request name.
16454
- - Spawn ships with \`issue\`, and pass \`issue\` to \`${REPLICAS_MCP_TOOLS.messageSubagent}\` to point a ship at another one: it is assigned, subscribed and told. Several ships can share an issue. Replicas moves an issue to In progress when a ship starts it. Ships link their pull requests with \`replicas issue link-pr\`, move the issue to Review themselves, and comment their progress, so never restate what an issue shows. Linked pull requests then move the status: Replicas moves an issue to Approved when every linked pull request is approved, and to Done when every one is merged, and each move reaches you as an \`<issue_event>\`. Nothing links on its own, so when a ship is asleep, link its pull request yourself if it isn't linked, and move the issue back when a move isn't really true. Give a ship one issue per pull request where you can. Statuses mean exactly this: In progress, work underway (a failing check, conflicts, review comments to answer, missing work, or waiting on another pull request); Review, waiting only on a person, with a linked pull request open, no conflicts and nothing failing (CI rerunning after a push is fine), and the person who must review or approve it assigned (move it back to In progress only for a conflict, a failing check or missing work, never just because something was pushed, so issues don't bounce); Approved, every linked pull request approved but not yet merged or live; Done, every linked pull request it needs merged (and deployed when that matters) and nothing left; Canceled, dropped, with a comment saying why. Keep every property true at all times: status, assignee, linked pull requests (link only the pull requests that do this issue's work; unlink wrong ones with \`replicas issue unlink-pr\` or the app), and the description, when the plan changes. Before ending a turn, check that your issues' statuses match reality, including those of ships that are asleep. Order, reprioritize or cancel issues with \`replicas issue update\`.
16455
- - You are subscribed to every issue in your slice: comments and changes by ships and people arrive as \`<issue_event>\` blocks. Act on them like ship events. Ships assigned to an issue get its comments too, so never relay a comment to them; pass it only to a ship that isn't on the issue.
16456
- - Ask the user only for decisions you truly can't make. Make routine calls yourself, such as retries, small scope choices or test cleanup. For a decision or merge only they can give, assign them to the issue with \`replicas issue assign\` and comment the question with \`replicas issue comment\`; their reply comes back as an \`<issue_event>\`. Once they answer a question you asked, unassign them with \`replicas issue unassign\` so the issue leaves their "Assigned to you"; they stay subscribed. Ships ask and unassign for their own questions, so leave those to them.
16457
- - A ship with open pull requests is not done when it sends \`finished\`: Replicas fixes their CI failures and review comments automatically, then sends \`ready\` or \`needs_attention\`. On \`needs_attention\`, direct the ship, or assign the user only if you can't decide. On \`ready\` for a pull request that needs a person's review, assign the user with a one-line comment.
16458
- ${MERGE_RULE}
16459
- - On every ship and issue event, act with tools on whatever it unblocks, such as starting the next task once a pull request merges. The user sees nothing you write in these turns unless a message they typed is still unanswered; otherwise reach them only with \`${REPLICAS_MCP_TOOLS.sendToChat}\`, and only for what they'd want right now: a deliverable they asked for, with its media, links or answer; a blocker that needs them, also assigned to them on its issue; or a request of theirs being done. Never for status, such as "PR #12 merged" or "I asked the ship to\u2026". End the turn with a one-line note of what you did, or only \`No action needed.\` when an issue event needs nothing from you.
16460
- ${chatRule("the Issues tab", "the issues you created, a ship you started, a finding that changes the answer, or a decision you need")}
16461
- `;
16462
16446
  function splitTaggedBlock(text4, tag) {
16463
16447
  const match = text4?.match(new RegExp(`\\s*<${tag}>\\n([\\s\\S]*?)\\n</${tag}>`));
16464
16448
  return { rest: match ? text4?.replace(match[0], "").trim() || void 0 : text4, block: match?.[1] };
@@ -16471,8 +16455,6 @@ function splitTurnInstructions(customInstructions) {
16471
16455
  const { rest, block } = splitTaggedBlock(customInstructions, TURN_INSTRUCTIONS_TAG);
16472
16456
  return { customInstructions: rest, turnInstructions: block };
16473
16457
  }
16474
- var MANAGER_TICKET_MESSAGE_NOTE = `The user sent this from your ticket on the Manager's board and reads your answer there, not in this chat. Answer them with \`${REPLICAS_MCP_TOOLS.replyOnTicket}\`: briefly, with a link or screenshot if it helps, and a follow-up question only if you need one. Keep longer work and detail in this chat.`;
16475
- var MANAGER_TICKET_REPLY_NUDGE = `The user is still waiting for your answer on your ticket, and they only read the ticket. Answer them now with \`${REPLICAS_MCP_TOOLS.replyOnTicket}\`, briefly.`;
16476
16458
  var T = REPLICAS_MCP_TOOLS;
16477
16459
  var SCOUT_LINEAR_RULES = `Linear issue triage: team instructions define what is actionable. Use \`replicas.linear.graphql\` from \`@replicas/sdk\` for every Linear read and mutation, never a Replicas CLI command. Choose exactly one:
16478
16460
  1. **Ignore** issues the team instructions leave to humans or that should not start work: do nothing and write nothing to Linear. If \`agent_session_id\` is set because you asked a question earlier, create a \`response\` Agent Activity on it with one short closing response.
@@ -16484,6 +16466,25 @@ var SCOUT_PRIOR_UNTAGGED_RULES = `\`prior_untagged_ignored=<ts>\`: the untagged
16484
16466
  var SCOUT_JOINED_RULES = `\`event=joined\`: you were just added to this channel; reply in this envelope's thread. If the channel's name or purpose points to a clear role (#triage, #bugs, #incidents, #support, #customer-*, a customer's shared channel), follow **Channel instructions** in the \`${SCOUT_SETTINGS_SKILL_NAME}\` skill to offer one concrete behavior. Otherwise do nothing at all.`;
16485
16467
  var SCOUT_REACTION_RULES = `\`event=reaction:\u2026\`: someone reacted to a message you posted. A thumbs-down or similar on a reply you posted unasked is frustration: follow **Frustration** in the \`${SCOUT_SETTINGS_SKILL_NAME}\` skill. On a reply someone asked for, it is about the answer: leave it. Otherwise do nothing.`;
16486
16468
 
16469
+ // ../shared/src/manager-prompts-common.ts
16470
+ var managerEventChatNote = (then) => `If a message the user typed in this turn is still unanswered, your final reply answers it and they see it. Otherwise they don't see text you write in this turn: if it brings something they asked for, or a blocker that needs them, send it with ${REPLICAS_MCP_TOOLS.sendToChat}; then ${then}end with a one-line note.`;
16471
+ var managerChatRule = (view, news) => `- The chat is like texting an assistant. In a turn the user typed, they see the text you write between tool calls as it streams, your final reply, what you send with \`${REPLICAS_MCP_TOOLS.sendToChat}\`, and your \`${REPLICAS_MCP_TOOLS.setStatus}\` line, never your tool calls. Unless you can answer right away, open with one line on what you'll do first and roughly how long it takes. Then call \`${REPLICAS_MCP_TOOLS.setStatus}\` with a few words on your current step, such as "Reading the billing webhook", and again each time you move to a new step. Before your final reply, write only what they'd want to know now: ${news}. Never narrate tool calls or say you're still working. When they message you mid-turn, reply in one line before anything else, then fold it into your work. Write in a line or two with links and any media inline, and never restate ${view} in chat.`;
16472
+
16473
+ // ../shared/src/manager-prompts-legacy.ts
16474
+ var MANAGER_EVENT_CHAT_NOTE = managerEventChatNote("update the board if its order, notes or overview changed, and ");
16475
+ var BOARD_ANSWER_NOTE = "The user answered on the board.";
16476
+ var MERGE_RULE = `- When a pull request should merge once it's approved and CI passes, call \`${REPLICAS_MCP_TOOLS.mergeWhenReady}\`: Replicas merges it and sends \`merged\`, or \`needs_attention\` saying why it can't. Never watch CI or pull requests with \`gh\`, sleep loops or wait scripts, and merge one yourself only when the user wants it merged right away.`;
16477
+ var BOARD_RULES = `- The board in the Ships pane beside this chat is the user's one view of the work: one ticket per task they ask for, holding only that task's pull requests. Replicas fills in each ticket's title, summaries, section and pull requests from the task, the ship's reports and its pull requests, so never restate what a ticket shows, and correct one with \`${REPLICAS_MCP_TOOLS.updateBoard}\` only when it's wrong.
16478
+ - Keep the board organized with \`${REPLICAS_MCP_TOOLS.updateBoard}\`: tickets in order, most important first; one short note per ticket only when it adds something, such as "Merge after #12"; and one overview line on where the work as a whole stands. Archive tickets the user no longer needs.
16479
+ - Ask the user only for decisions you truly can't make. Make routine calls yourself, such as retries, small scope choices or test cleanup. For a question of your own, create a ticket with it; the user's answer comes to you here, marked "${BOARD_ANSWER_NOTE}". Answers to a ship's questions go straight to that ship.
16480
+ - A ship with open pull requests is not done when it sends \`finished\`: Replicas fixes their CI failures and review comments automatically, then sends \`ready\` or \`needs_attention\`. On \`needs_attention\`, direct the ship, or ask the user only if you can't decide.
16481
+ ${MERGE_RULE}
16482
+ - On every ship event and board answer, act with tools on whatever it unblocks, such as starting the next task once a pull request merges, and update the board if it changed. The user sees nothing you write in these turns unless a message they typed is still unanswered; otherwise reach them only with \`${REPLICAS_MCP_TOOLS.sendToChat}\`, and only for what they'd want right now: a deliverable they asked for, with its media, links or answer; a blocker that needs them, also on the board; or a request of theirs being done. Never for status, such as "PR #12 merged" or "I asked the ship to\u2026". End the turn with a one-line note of what you did.
16483
+ ${managerChatRule("the board", "a finding that changes the answer, a ship you started, or a decision you need")}
16484
+ `;
16485
+ var MANAGER_TICKET_MESSAGE_NOTE = `The user sent this from your ticket on the Manager's board and reads your answer there, not in this chat. Answer them with \`${REPLICAS_MCP_TOOLS.replyOnTicket}\`: briefly, with a link or screenshot if it helps, and a follow-up question only if you need one. Keep longer work and detail in this chat.`;
16486
+ var MANAGER_TICKET_REPLY_NUDGE = `The user is still waiting for your answer on your ticket, and they only read the ticket. Answer them now with \`${REPLICAS_MCP_TOOLS.replyOnTicket}\`, briefly.`;
16487
+
16487
16488
  // ../shared/src/message-origin.ts
16488
16489
  var UUID = UUID_RE.source.slice(1, -1);
16489
16490
  var WORKSPACE_SENDER = new RegExp(String.raw`^\s*<${REPLICAS_INSTRUCTIONS_TAG}>\nFrom the workspace ("(?:[^"\\\n]|\\.)*") \((${UUID})\)\.\n</${REPLICAS_INSTRUCTIONS_TAG}>`);
@@ -20800,15 +20801,22 @@ function applyInterruptions(messages, events) {
20800
20801
  }
20801
20802
  function applyEngineNotices(messages, events) {
20802
20803
  const notices = [];
20803
- events.forEach((event, index) => {
20804
+ const sameTime = /* @__PURE__ */ new Map();
20805
+ const noticeId = (kind, timestamp2) => {
20806
+ const id = `${kind}-${timestamp2}`;
20807
+ const ordinal2 = sameTime.get(id) ?? 0;
20808
+ sameTime.set(id, ordinal2 + 1);
20809
+ return `${id}-${ordinal2}`;
20810
+ };
20811
+ events.forEach((event) => {
20804
20812
  if (event.type === MANAGER_EVENT_TYPE) {
20805
20813
  const parsed = typeof event.payload.text === "string" ? parseManagerEvents(event.payload.text) : null;
20806
- if (parsed) notices.push({ id: `multitask-event-${event.timestamp}-${index}`, type: "multitask_event", events: parsed, timestamp: event.timestamp });
20814
+ if (parsed) notices.push({ id: noticeId("multitask-event", event.timestamp), type: "multitask_event", events: parsed, timestamp: event.timestamp });
20807
20815
  return;
20808
20816
  }
20809
20817
  if (event.type === CHAT_MESSAGE_REJECTED_EVENT_TYPE) {
20810
20818
  notices.push({
20811
- id: `message-rejected-${event.timestamp}-${index}`,
20819
+ id: noticeId("message-rejected", event.timestamp),
20812
20820
  type: "error",
20813
20821
  message: typeof event.payload.message === "string" ? event.payload.message : "Message was rejected",
20814
20822
  rejectedMessageId: typeof event.payload[REJECTED_MESSAGE_ID_PAYLOAD_KEY] === "string" ? event.payload[REJECTED_MESSAGE_ID_PAYLOAD_KEY] : void 0,
@@ -20819,7 +20827,7 @@ function applyEngineNotices(messages, events) {
20819
20827
  }
20820
20828
  if (event.type === CHAT_TURN_LOST_EVENT_TYPE) {
20821
20829
  notices.push({
20822
- id: `turn-lost-${event.timestamp}-${index}`,
20830
+ id: noticeId("turn-lost", event.timestamp),
20823
20831
  type: "error",
20824
20832
  message: CHAT_TURN_LOST_MESSAGE,
20825
20833
  timestamp: event.timestamp
@@ -20831,7 +20839,7 @@ function applyEngineNotices(messages, events) {
20831
20839
  if (!payload) return;
20832
20840
  notices.push({
20833
20841
  ...payload,
20834
- id: `auth-fallback-${event.timestamp}-${index}`,
20842
+ id: noticeId("auth-fallback", event.timestamp),
20835
20843
  type: "auth_fallback",
20836
20844
  timestamp: event.timestamp
20837
20845
  });
@@ -21655,7 +21663,7 @@ async function withRetry(label, fn, options) {
21655
21663
  }
21656
21664
 
21657
21665
  // ../shared/src/tensorlake.ts
21658
- var TENSORLAKE_IMAGE_NAME = "replicas-sandbox-2026-11-20-v55";
21666
+ var TENSORLAKE_IMAGE_NAME = "replicas-sandbox-2026-11-20-v59";
21659
21667
  var TENSORLAKE_DISK_MB = 100 * 1024;
21660
21668
 
21661
21669
  // ../shared/src/egress.ts
@@ -22024,6 +22032,9 @@ var MAC_KEY_LABELS = {
22024
22032
  };
22025
22033
  var OTHER_KEY_LABELS = { ...MAC_KEY_LABELS, Enter: "Enter", Tab: "Tab", Backspace: "Backspace", Shift: "Shift", Alt: "Alt", Mod: "Ctrl" };
22026
22034
 
22035
+ // ../shared/src/manager-prompts-issues.ts
22036
+ var ISSUES_MANAGER_EVENT_CHAT_NOTE = managerEventChatNote("");
22037
+
22027
22038
  // ../shared/src/image-attachments.ts
22028
22039
  var MAX_LONG_EDGE = 2576;
22029
22040
  var MAX_PIXELS = 375e4;
@@ -5,7 +5,7 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  runGitCommand
8
- } from "./chunk-MKTLGQZ4.js";
8
+ } from "./chunk-GYYGQTWQ.js";
9
9
  import {
10
10
  COMMAND_PROTECTION_MAX_MESSAGE_FILE_BYTES,
11
11
  COMMAND_PROTECTION_REPO_GIT_ARGS,
@@ -18,7 +18,7 @@ import {
18
18
  parseCommandProtectionRequest,
19
19
  toCommandProtectionRepoState,
20
20
  withRetry
21
- } from "./chunk-6KRCEGA6.js";
21
+ } from "./chunk-6QWSUURS.js";
22
22
 
23
23
  // src/services/command-protection-service.ts
24
24
  import { readFile, stat } from "fs/promises";
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-TMH7DTFL.js";
7
+ } from "./chunk-YCVC3SGY.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
@@ -21,7 +21,7 @@ import {
21
21
  provisionedDeviceSchema,
22
22
  readReplicasRuntimeEnv,
23
23
  serializePosixEnvFile
24
- } from "./chunk-6KRCEGA6.js";
24
+ } from "./chunk-6QWSUURS.js";
25
25
 
26
26
  // src/runtime-env-loader.ts
27
27
  import { readFileSync } from "fs";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-7ZDAVYTV.js";
7
7
  import {
8
8
  engineScriptProcess
9
- } from "./chunk-EEVIXUGW.js";
9
+ } from "./chunk-J4L2AHBJ.js";
10
10
  import {
11
11
  isRecord
12
12
  } from "./chunk-UZSNFLDQ.js";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-6KRCEGA6.js";
8
+ } from "./chunk-6QWSUURS.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBAGENT_MCP_TOOL_NAMES
6
- } from "./chunk-6KRCEGA6.js";
6
+ } from "./chunk-6QWSUURS.js";
7
7
 
8
8
  // src/managers/subagent-mcp-config.ts
9
9
  import { existsSync } from "fs";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  subagentCodexMcpConfig
6
- } from "./chunk-EEVIXUGW.js";
6
+ } from "./chunk-J4L2AHBJ.js";
7
7
  import {
8
8
  ENGINE_ENV,
9
9
  UNQUOTED_PATHS_CONFIG,
@@ -15,15 +15,15 @@ import {
15
15
  resolveDiffBase,
16
16
  runGitCommand,
17
17
  setAgentCredentialSnapshot
18
- } from "./chunk-MKTLGQZ4.js";
18
+ } from "./chunk-GYYGQTWQ.js";
19
19
  import {
20
20
  AppServerProcess,
21
21
  buildCodexAgentEnv
22
- } from "./chunk-5ZX72IOC.js";
22
+ } from "./chunk-2IMTX5NL.js";
23
23
  import {
24
24
  SUBPROCESS_MAX_BUFFER,
25
25
  execFileAsync
26
- } from "./chunk-TMH7DTFL.js";
26
+ } from "./chunk-YCVC3SGY.js";
27
27
  import {
28
28
  isRecord
29
29
  } from "./chunk-UZSNFLDQ.js";
@@ -63,7 +63,7 @@ import {
63
63
  shrunkImageSize,
64
64
  splitManagerInstructions,
65
65
  withTimeout
66
- } from "./chunk-6KRCEGA6.js";
66
+ } from "./chunk-6QWSUURS.js";
67
67
 
68
68
  // src/managers/codex-token-manager.ts
69
69
  import { promises as fs } from "fs";
@@ -463,7 +463,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
463
463
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
464
464
  await this.applyCredentialsResponse(data);
465
465
  setAgentCredentialSnapshot("codex", data);
466
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-V3JO6HIP.js");
466
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-KKLTHCWI.js");
467
467
  await restartCodexAspHostIfRunning2();
468
468
  });
469
469
  await this.start(true);
@@ -485,7 +485,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
485
485
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
486
486
  await this.applyCredentialsResponse(data);
487
487
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
488
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-V3JO6HIP.js");
488
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-KKLTHCWI.js");
489
489
  await restartCodexAspHostIfRunning2();
490
490
  }
491
491
  setAgentCredentialSnapshot("codex", data);
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-7ZDAVYTV.js";
7
7
  import {
8
8
  AspClient
9
- } from "./chunk-5ZX72IOC.js";
9
+ } from "./chunk-2IMTX5NL.js";
10
10
  import {
11
11
  ASTER_BASE_URL,
12
12
  ASTER_PROVIDER,
@@ -18,7 +18,7 @@ import {
18
18
  isRecord,
19
19
  readOllamaAuthEnv,
20
20
  readOpenAICompatibleAuthEnv
21
- } from "./chunk-6KRCEGA6.js";
21
+ } from "./chunk-6QWSUURS.js";
22
22
 
23
23
  // src/managers/codex-asp/notification-dispatch.ts
24
24
  var TURN_STARTED_METHOD = "turn/started";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-6KRCEGA6.js";
6
+ } from "./chunk-6QWSUURS.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -4,15 +4,15 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  getManagedPiMcpServers,
6
6
  managedMcpServerProcess
7
- } from "./chunk-HWV2RFS4.js";
7
+ } from "./chunk-H6VDYEWY.js";
8
8
  import "./chunk-7ZDAVYTV.js";
9
- import "./chunk-EEVIXUGW.js";
9
+ import "./chunk-J4L2AHBJ.js";
10
10
  import {
11
11
  isRecord
12
12
  } from "./chunk-UZSNFLDQ.js";
13
13
  import {
14
14
  rankToolsByQuery
15
- } from "./chunk-6KRCEGA6.js";
15
+ } from "./chunk-6QWSUURS.js";
16
16
  import "./chunk-VEQXQN22.js";
17
17
 
18
18
  // src/codemode-mcp.ts
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-5MGSYR6V.js";
7
- import "./chunk-MKTLGQZ4.js";
8
- import "./chunk-TMH7DTFL.js";
6
+ } from "./chunk-CA5TVIS7.js";
7
+ import "./chunk-GYYGQTWQ.js";
8
+ import "./chunk-YCVC3SGY.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-6KRCEGA6.js";
12
+ import "./chunk-6QWSUURS.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -14,13 +14,13 @@ import {
14
14
  recoverCompletedTurn,
15
15
  spawnMuseMsp,
16
16
  startMuseSession
17
- } from "./chunk-7HIVUTJ5.js";
17
+ } from "./chunk-TKG7H4KQ.js";
18
18
  import "./chunk-7ZDAVYTV.js";
19
19
  import {
20
20
  AppServerProcess,
21
21
  buildCodexAgentEnv
22
- } from "./chunk-5ZX72IOC.js";
23
- import "./chunk-TMH7DTFL.js";
22
+ } from "./chunk-2IMTX5NL.js";
23
+ import "./chunk-YCVC3SGY.js";
24
24
  import {
25
25
  AGENT,
26
26
  OPENCODE_GO_PROVIDER,
@@ -30,7 +30,7 @@ import {
30
30
  headlessAgentUsagePath,
31
31
  isRecord,
32
32
  withTimeout
33
- } from "./chunk-6KRCEGA6.js";
33
+ } from "./chunk-6QWSUURS.js";
34
34
  import "./chunk-VEQXQN22.js";
35
35
 
36
36
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -90,12 +90,12 @@ import {
90
90
  import {
91
91
  getManagedPiMcpServers,
92
92
  managedMcpServerProcess
93
- } from "./chunk-HWV2RFS4.js";
93
+ } from "./chunk-H6VDYEWY.js";
94
94
  import {
95
95
  evaluateCommandProtection,
96
96
  extractToolCommand,
97
97
  reportCommandProtectionBlock
98
- } from "./chunk-5MGSYR6V.js";
98
+ } from "./chunk-CA5TVIS7.js";
99
99
  import {
100
100
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
101
101
  AGENT_MESSAGE_DELTA_METHOD,
@@ -129,7 +129,7 @@ import {
129
129
  spawnMuseMsp,
130
130
  startMuseSession,
131
131
  uuidV7
132
- } from "./chunk-7HIVUTJ5.js";
132
+ } from "./chunk-TKG7H4KQ.js";
133
133
  import {
134
134
  MUSE_AUTH_PATH,
135
135
  OPENCODE_AUTH_PATH,
@@ -137,7 +137,7 @@ import {
137
137
  } from "./chunk-7ZDAVYTV.js";
138
138
  import {
139
139
  publishedPullRequestUrls
140
- } from "./chunk-5LSRRDBB.js";
140
+ } from "./chunk-IWBMAFEM.js";
141
141
  import {
142
142
  ACCOUNT_RATE_LIMITS_READ_METHOD,
143
143
  AsyncLock,
@@ -215,12 +215,12 @@ import {
215
215
  transcriptSecrets,
216
216
  upsertCredentialFileLines,
217
217
  writeSecureCredentialFile
218
- } from "./chunk-UEWBZU47.js";
218
+ } from "./chunk-OCDTIHNH.js";
219
219
  import {
220
220
  SUBAGENT_MCP_TOOL_TIMEOUT_MS,
221
221
  engineScriptProcess,
222
222
  subagentMcpProcessConfig
223
- } from "./chunk-EEVIXUGW.js";
223
+ } from "./chunk-J4L2AHBJ.js";
224
224
  import {
225
225
  ENGINE_ENV,
226
226
  UNQUOTED_PATHS_CONFIG,
@@ -231,18 +231,18 @@ import {
231
231
  resolveDiffBase,
232
232
  setAgentCredentialSnapshot,
233
233
  setLinearSessionId
234
- } from "./chunk-MKTLGQZ4.js";
234
+ } from "./chunk-GYYGQTWQ.js";
235
235
  import {
236
236
  AspRequestTimeoutError,
237
237
  AspResponseError,
238
238
  buildCodexAgentEnv,
239
239
  getCodexModelProvider
240
- } from "./chunk-5ZX72IOC.js";
240
+ } from "./chunk-2IMTX5NL.js";
241
241
  import {
242
242
  SUBPROCESS_MAX_BUFFER,
243
243
  execAsync,
244
244
  execFileAsync
245
- } from "./chunk-TMH7DTFL.js";
245
+ } from "./chunk-YCVC3SGY.js";
246
246
  import {
247
247
  isRecord
248
248
  } from "./chunk-UZSNFLDQ.js";
@@ -543,7 +543,7 @@ import {
543
543
  workspaceTokenRequestSchema,
544
544
  workspaceTokenResponseSchema,
545
545
  wrapInTag
546
- } from "./chunk-6KRCEGA6.js";
546
+ } from "./chunk-6QWSUURS.js";
547
547
  import {
548
548
  __commonJS,
549
549
  __export,
@@ -11366,6 +11366,9 @@ function canSteerMessage(provider, request) {
11366
11366
  import { existsSync as existsSync5 } from "fs";
11367
11367
  import { join as join9 } from "path";
11368
11368
 
11369
+ // ../shared/src/routes/subscription-usage.ts
11370
+ var formatUsageTime = (iso3, options) => new Date(iso3).toLocaleString(void 0, { hour: "numeric", minute: "2-digit", ...options });
11371
+
11369
11372
  // src/managers/muse-token-manager.ts
11370
11373
  var MuseTokenManager = class extends BaseRefreshManager {
11371
11374
  constructor() {
@@ -11462,6 +11465,12 @@ function describeQuotaExhaustion(provider, reason, credential, fallback) {
11462
11465
  const agent = getProviderDisplayName(provider);
11463
11466
  const account = credential ? describeCredential(provider, credential) : "the credential this workspace is using";
11464
11467
  const limit = reason === "credits_required" ? `The selected model needs usage credits on ${account}.` : reason === "out_of_credits" ? `${agent} ran out of credits on ${account}.` : `${agent} hit the usage limit on ${account}.`;
11468
+ const resting = fallback.outcome === "not_configured" && reason === "rate_limit" ? fallback.resting : void 0;
11469
+ if (resting && resting.count > 1) {
11470
+ const owner = resting.scope === CREDENTIAL_SCOPE.ORG ? "the organization's" : resting.scope === CREDENTIAL_SCOPE.USER ? "the personal" : "the";
11471
+ const retryAt = formatUsageTime(resting.resetsAt, { month: "short", day: "numeric", timeZone: "UTC", timeZoneName: "short" });
11472
+ return `${limit} All ${resting.count} of ${owner} ${agent} credentials in the fallback chain are at their usage limit, and Replicas can use the first of them again ${retryAt}. Add a credential or harness in Settings \u2192 Fallbacks, or try again then.`;
11473
+ }
11465
11474
  const next = fallback.outcome === "fork" ? `Continuing in ${getProviderDisplayName(fallback.target.provider, "long")}.` : reason === "credits_required" ? "Pick a different model, or turn on usage credits for this account." : QUOTA_STOP_NEXT_STEP[fallback.outcome];
11466
11475
  return `${limit} ${next}`;
11467
11476
  }
@@ -11522,6 +11531,7 @@ var AuthFallbackCoordinator = class {
11522
11531
  }
11523
11532
  const steps = plan.ok ? plan.data.steps : tokenManager && exhausted ? [{ kind: "credentials", methods: [] }] : [];
11524
11533
  let failed = false;
11534
+ let resting;
11525
11535
  for (const step of steps) {
11526
11536
  if (step.kind === "harness") {
11527
11537
  if (!forkable || !isAgentAvailable(step.provider)) continue;
@@ -11543,6 +11553,14 @@ var AuthFallbackCoordinator = class {
11543
11553
  );
11544
11554
  if (!swap.ok) {
11545
11555
  failed ||= swap.error.code !== "no_credentials";
11556
+ const skipped = engineCredentialRefreshFailureSchema.safeParse(extractJsonObject(swap.error.message)).data?.resting;
11557
+ if (skipped) {
11558
+ resting = resting ? {
11559
+ count: resting.count + skipped.count,
11560
+ ...resting.scope === skipped.scope ? { scope: skipped.scope } : {},
11561
+ resetsAt: resting.resetsAt < skipped.resetsAt ? resting.resetsAt : skipped.resetsAt
11562
+ } : skipped;
11563
+ }
11546
11564
  continue;
11547
11565
  }
11548
11566
  const applied = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS[this.provider] ?? exhausted;
@@ -11553,7 +11571,7 @@ var AuthFallbackCoordinator = class {
11553
11571
  return this.switched(reason, exhausted, applied, step, detail);
11554
11572
  }
11555
11573
  if (!tokenManager || !exhausted) return { outcome: "unavailable" };
11556
- if (!failed) return { outcome: "not_configured" };
11574
+ if (!failed) return { outcome: "not_configured", ...resting ? { resting } : {} };
11557
11575
  this.recordNotice(reason, exhausted, exhausted, "failed", "Replicas could not load an alternate credential.");
11558
11576
  return { outcome: "failed" };
11559
11577
  }
@@ -11793,6 +11811,9 @@ var MessageQueueService = class {
11793
11811
  isStopped(signal) {
11794
11812
  return this.stoppedTurns.has(signal);
11795
11813
  }
11814
+ isRequeued(signal) {
11815
+ return this.activeTurn?.controller.signal === signal && this.activeTurn.requeueAfter !== void 0;
11816
+ }
11796
11817
  markDelivered() {
11797
11818
  if (this.activeTurn) this.activeTurn.delivered = true;
11798
11819
  }
@@ -11906,6 +11927,8 @@ var CodingAgentManager = class _CodingAgentManager {
11906
11927
  steerSettlements = /* @__PURE__ */ new Set();
11907
11928
  earlySteers = [];
11908
11929
  withdrawnSteers = /* @__PURE__ */ new WeakSet();
11930
+ // The agent can still read a steer while a Stop that took it waits on the agent.
11931
+ steersBeingStopped = /* @__PURE__ */ new Map();
11909
11932
  earlySteerDelivery = new AsyncLock();
11910
11933
  turnOpen = false;
11911
11934
  // The chat places a message and times its turn by the harness's record of it, which is written only once the agent has the message, so that record keeps this time.
@@ -12016,7 +12039,7 @@ var CodingAgentManager = class _CodingAgentManager {
12016
12039
  const { request: delivered, senderKey } = this.withSenderLine(request);
12017
12040
  const stopped = signal.aborted;
12018
12041
  if (!stopped) this.harnessTurns.add(signal);
12019
- if (stopped && (request.engineTurn || this.isStopped(signal) || !await this.keepStoppedRequest(delivered, signal))) return;
12042
+ if (stopped && (request.engineTurn || this.isStopped(signal) || this.isRequeued(signal) || !await this.keepStoppedRequest(delivered, signal))) return;
12020
12043
  await this.saveLastSenderKey(senderKey);
12021
12044
  if (stopped) return;
12022
12045
  const takesNotes = takesTurnNotes(request);
@@ -12075,6 +12098,10 @@ var CodingAgentManager = class _CodingAgentManager {
12075
12098
  return { sent: Promise.resolve([]), putBack: () => {
12076
12099
  } };
12077
12100
  }
12101
+ /** Whether this message's turn takes along a message the agent was not given. When it cannot, that message runs again after it. */
12102
+ carriesKeptRequests(_request) {
12103
+ return false;
12104
+ }
12078
12105
  oweNotes(message) {
12079
12106
  const notes = this.turnNotes.get(message);
12080
12107
  if (!notes) return;
@@ -12085,6 +12112,10 @@ var CodingAgentManager = class _CodingAgentManager {
12085
12112
  isStopped(signal) {
12086
12113
  return !!signal && this.messageQueue.isStopped(signal);
12087
12114
  }
12115
+ /** Its message runs again after the one that cut it, so nothing of this turn is kept or written to the chat. */
12116
+ isRequeued(signal) {
12117
+ return !!signal && this.messageQueue.isRequeued(signal);
12118
+ }
12088
12119
  // A harness calls this with nothing awaited before it hands the message over, or a Stop in between would still send a withdrawn message.
12089
12120
  deliver(signal) {
12090
12121
  if (signal.aborted) return false;
@@ -12139,8 +12170,8 @@ ${request.message}` }, senderKey };
12139
12170
  const requested = requestedStoppedAt ? Date.parse(requestedStoppedAt) : NaN;
12140
12171
  const stoppedAt = new Date(requested <= now && requested > now - MAX_REQUESTED_STOP_AGE_MS ? requested : now).toISOString();
12141
12172
  const queuedMessages = this.messageQueue.drainQueue();
12142
- const unreadSteers = [...this.unreadSteers.values()];
12143
- const steersInFlight = [...this.steersInFlight.values()].filter(({ read }) => !read);
12173
+ let unreadSteers = [...this.unreadSteers.values()];
12174
+ let steersInFlight = [...this.steersInFlight.values()].filter(({ read }) => !read);
12144
12175
  for (const { message } of steersInFlight) this.steersInFlight.delete(message.id);
12145
12176
  const earlySteers = this.earlySteers.splice(0);
12146
12177
  for (const steer of [...earlySteers, ...steersInFlight.map(({ delivered }) => delivered)]) this.withdrawnSteers.add(steer);
@@ -12150,6 +12181,7 @@ ${request.message}` }, senderKey };
12150
12181
  const turn = this.messageQueue.cancelActiveTurn(true);
12151
12182
  const kept = this.takeKeptRequests();
12152
12183
  const isProcessing = this.isProcessing() || (this.hasActiveBackgroundTasks?.() ?? false);
12184
+ for (const { message, delivered } of [...unreadSteers, ...steersInFlight]) this.steersBeingStopped.set(message.id, delivered);
12153
12185
  let failure = null;
12154
12186
  if (isProcessing) {
12155
12187
  try {
@@ -12158,8 +12190,15 @@ ${request.message}` }, senderKey };
12158
12190
  failure = { error };
12159
12191
  }
12160
12192
  }
12161
- const keptRequests = await kept.sent;
12162
- const withdrawn = turn && !turn.message.engineTurn && !turn.delivered && !await this.readStoppedMessage(turn.controller.signal) ? [turn.message] : [];
12193
+ let keptRequests;
12194
+ let withdrawn;
12195
+ try {
12196
+ keptRequests = await kept.sent;
12197
+ withdrawn = turn && !turn.message.engineTurn && !turn.delivered && !await this.readStoppedMessage(turn.controller.signal) ? [turn.message] : [];
12198
+ } finally {
12199
+ unreadSteers = unreadSteers.filter(({ message }) => this.steersBeingStopped.delete(message.id));
12200
+ steersInFlight = steersInFlight.filter(({ message }) => this.steersBeingStopped.delete(message.id));
12201
+ }
12163
12202
  if (failure && withdrawn.length === 0) {
12164
12203
  kept.putBack();
12165
12204
  for (const steer of unreadSteers) this.unreadSteers.set(steer.message.id, steer);
@@ -12330,7 +12369,7 @@ ${request.message}` }, senderKey };
12330
12369
  if (!taken) return { success: true, queue: this.getQueue() };
12331
12370
  this.messageQueue.restoreToQueue(taken.message, 0);
12332
12371
  if (this.messageQueue.isProcessing() && !this.messageQueue.stoppedTurn()) {
12333
- const requeued = this.keepStoppedRequest === _CodingAgentManager.prototype.keepStoppedRequest ? this.messageQueue.requeueActiveTurnAfter(messageId) : null;
12372
+ const requeued = this.carriesKeptRequests(taken.message) ? null : this.messageQueue.requeueActiveTurnAfter(messageId);
12334
12373
  if (requeued) {
12335
12374
  this.oweNotes(requeued.message);
12336
12375
  this.onMessageRequeued(requeued.message, requeued.afterId);
@@ -12371,7 +12410,9 @@ ${request.message}` }, senderKey };
12371
12410
  inFlight.read = true;
12372
12411
  this.onQueueChanged();
12373
12412
  }
12374
- return steer?.delivered ?? inFlight?.delivered ?? this.messageQueue.takeFromQueue(messageId)?.message;
12413
+ const beingStopped = this.steersBeingStopped.get(messageId);
12414
+ this.steersBeingStopped.delete(messageId);
12415
+ return steer?.delivered ?? inFlight?.delivered ?? beingStopped ?? this.messageQueue.takeFromQueue(messageId)?.message;
12375
12416
  }
12376
12417
  settlePromptStart() {
12377
12418
  this.promptStart?.resolve();
@@ -13679,6 +13720,10 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13679
13720
  async dropRecordedUnreadPrompt() {
13680
13721
  if (this.unreadPrompt && await this.promptRecorded(this.unreadPrompt.uuid)) this.unreadPrompt = null;
13681
13722
  }
13723
+ // Claude Code makes everything sent with a slash command part of that command's own entry, which the model does not answer.
13724
+ carriesKeptRequests(request) {
13725
+ return takesTurnNotes(request);
13726
+ }
13682
13727
  async readStoppedMessage(signal) {
13683
13728
  return this.sentPrompt?.signal === signal && this.promptRecorded(this.sentPrompt.uuid);
13684
13729
  }
@@ -14358,7 +14403,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14358
14403
  }
14359
14404
  await this.dropRecordedUnreadPrompt();
14360
14405
  const prompt = goalCommand ? [{ type: "text", text: `/goal ${goalObjective ?? "clear"}` }] : userMessage.message.content;
14361
- const notedCutOffs = [...this.cutOffTools.keys()];
14406
+ const takesUnread = this.carriesKeptRequests(request);
14407
+ const notedCutOffs = takesUnread ? [...this.cutOffTools.keys()] : [];
14362
14408
  const cutOffNote = notedCutOffs.length > 0 ? [{
14363
14409
  type: "text",
14364
14410
  text: wrapInTag(`The user pressed Stop while these tool calls were running: ${[...new Set(this.cutOffTools.values())].map((name) => `\`${name}\``).join(", ")}. Claude Code reports a call cut off this way as "The user doesn't want to proceed with this tool use. The tool use was rejected", but nobody rejected or declined them: they were stopped mid-run. Describe them as stopped or interrupted, never as rejected. They may or may not have taken effect, so check before relying on or repeating them.`, REPLICAS_INSTRUCTIONS_TAG)
@@ -14366,12 +14412,13 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14366
14412
  const dropNotedCutOffs = () => {
14367
14413
  for (const id of notedCutOffs) this.cutOffTools.delete(id);
14368
14414
  };
14369
- const content = appendUserContent(appendUserContent(cutOffNote, this.unreadPrompt?.content ?? []), prompt);
14415
+ const unsent = appendUserContent(appendUserContent(cutOffNote, this.unreadPrompt?.content ?? []), prompt);
14416
+ const content = takesUnread ? unsent : prompt;
14370
14417
  if (this.pendingInterrupt || options.signal?.aborted) {
14371
14418
  this.pendingInterrupt = false;
14372
- if (!options.engineTurn && !this.isStopped(options.signal)) {
14419
+ if (!options.engineTurn && !this.isStopped(options.signal) && !this.isRequeued(options.signal)) {
14373
14420
  await recordPrompt?.();
14374
- this.keepUnreadPrompt(userMessage.uuid, content);
14421
+ this.keepUnreadPrompt(userMessage.uuid, unsent);
14375
14422
  dropNotedCutOffs();
14376
14423
  }
14377
14424
  return;
@@ -14395,13 +14442,14 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14395
14442
  void this.deliverEarlySteers();
14396
14443
  });
14397
14444
  } finally {
14398
- const carried = options.signal?.aborted && !options.engineTurn && !this.isStopped(options.signal);
14445
+ const requeued = this.isRequeued(options.signal);
14446
+ const carried = options.signal?.aborted && !options.engineTurn && !requeued && !this.isStopped(options.signal);
14399
14447
  if (this.turnPromptRecorded || carried) dropNotedCutOffs();
14400
- if (this.turnPromptRecorded) this.unreadPrompt = null;
14401
- else if (carried) this.keepUnreadPrompt(userMessage.uuid, content);
14402
- else if (this.unreadPrompt && options.signal?.aborted) this.unreadPrompt = { ...this.unreadPrompt, uuid: userMessage.uuid };
14448
+ if (!this.turnPromptRecorded && carried) this.keepUnreadPrompt(userMessage.uuid, unsent);
14449
+ else if (takesUnread && this.turnPromptRecorded) this.unreadPrompt = null;
14450
+ else if (takesUnread && this.unreadPrompt && options.signal?.aborted) this.unreadPrompt = { ...this.unreadPrompt, uuid: userMessage.uuid };
14403
14451
  if (this.sentPrompt?.record) {
14404
- if (!this.isStopped(options.signal) || await this.promptRecorded(userMessage.uuid)) await this.recordSentPrompt();
14452
+ if (!requeued && (!this.isStopped(options.signal) || await this.promptRecorded(userMessage.uuid))) await this.recordSentPrompt();
14405
14453
  else this.sentPrompt.record = void 0;
14406
14454
  }
14407
14455
  }
@@ -14707,7 +14755,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14707
14755
  if (isRecord2(lifecycle2) && lifecycle2.type === "command_lifecycle" && lifecycle2.state === "started" && typeof lifecycle2.command_uuid === "string") {
14708
14756
  if (this.pendingTurn?.userMessageUuids.has(lifecycle2.command_uuid)) {
14709
14757
  this.turnPromptRecorded = true;
14710
- if (lifecycle2.command_uuid === this.sentPrompt?.uuid) {
14758
+ if (lifecycle2.command_uuid === this.sentPrompt?.uuid && !this.isRequeued(this.sentPrompt.signal)) {
14711
14759
  this.messageQueue.markDelivered();
14712
14760
  await this.recordSentPrompt();
14713
14761
  }
@@ -15475,9 +15523,13 @@ var CodexAspManager = class extends CodingAgentManager {
15475
15523
  `, sent: this.turnRequest });
15476
15524
  return true;
15477
15525
  }
15526
+ // `/compact` and a goal's clear or pause send Codex no input; a goal being set or resumed does.
15527
+ carriesKeptRequests(request) {
15528
+ const command = getGoalCommand(request.message, request.goalMode)?.type;
15529
+ return !isCompactCommand(request.message) && command !== "clear" && command !== "pause";
15530
+ }
15478
15531
  takeKeptRequests() {
15479
- const command = this.turnRequest && getGoalCommand(this.turnRequest.message, this.turnRequest.goalMode)?.type;
15480
- if (this.turnRequest && (isCompactCommand(this.turnRequest.message) || command && command !== "set")) return { sent: Promise.resolve([]), putBack: () => {
15532
+ if (this.turnRequest && !this.carriesKeptRequests(this.turnRequest)) return { sent: Promise.resolve([]), putBack: () => {
15481
15533
  } };
15482
15534
  const unread = this.unreadRequests;
15483
15535
  this.unreadRequests = [];
@@ -15888,7 +15940,7 @@ var CodexAspManager = class extends CodingAgentManager {
15888
15940
  const threadId = await this.ensureThread(host, request, developerInstructions);
15889
15941
  await this.lateStartStopped(signal);
15890
15942
  const delivered = this.deliver(signal);
15891
- if (delivered || !this.isStopped(signal)) recordUserMessage({ command: "goal" });
15943
+ if (delivered || !(this.isStopped(signal) || this.isRequeued(signal))) recordUserMessage({ command: "goal" });
15892
15944
  return delivered ? { host, threadId } : null;
15893
15945
  }
15894
15946
  // The app-server takes a start written behind one still in flight into that one's turn, so the next one waits until that one is stopped, undelivered: a Stop meanwhile still withdraws it.
@@ -15922,7 +15974,7 @@ var CodexAspManager = class extends CodingAgentManager {
15922
15974
  await this.lateStartStopped(signal);
15923
15975
  if (!this.deliver(signal)) {
15924
15976
  await removeTempImageFiles(tempImagePaths);
15925
- if (this.isStopped(signal)) return;
15977
+ if (this.isStopped(signal) || this.isRequeued(signal)) return;
15926
15978
  recordUserMessage(options.userMessagePayload);
15927
15979
  if (!options.runTurn && !options.continuation) await this.keepStoppedRequest(request);
15928
15980
  return;
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-5LSRRDBB.js";
6
+ } from "./chunk-IWBMAFEM.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-6KRCEGA6.js";
12
+ } from "./chunk-6QWSUURS.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -11,7 +11,7 @@ import {
11
11
  spawnSubagentRequestSchema,
12
12
  subagentResponseSchema,
13
13
  waitSubagentRequestSchema
14
- } from "./chunk-6KRCEGA6.js";
14
+ } from "./chunk-6QWSUURS.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1698",
3
+ "version": "0.1.1701",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",