replicas-engine 0.1.1316 → 0.1.1318

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,12 +8,12 @@ import {
8
8
  listRunningCodexModels,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-O4UY6MG5.js";
12
- import "./chunk-WWLQEDZK.js";
13
- import "./chunk-X57JBOEJ.js";
14
- import "./chunk-4U6EPPZF.js";
11
+ } from "./chunk-ORM5QECI.js";
12
+ import "./chunk-56WDCAN2.js";
13
+ import "./chunk-QLDS5LTC.js";
14
+ import "./chunk-2MCGQBB5.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
- import "./chunk-2E6IP4OG.js";
16
+ import "./chunk-LLSE2EKJ.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
  export {
19
19
  CODEX_ULTRAFAST_SERVICE_TIER,
@@ -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-2E6IP4OG.js";
6
+ } from "./chunk-LLSE2EKJ.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-4U6EPPZF.js";
7
+ } from "./chunk-2MCGQBB5.js";
8
8
  import {
9
9
  isRecord as isRecord2
10
10
  } from "./chunk-UZSNFLDQ.js";
@@ -21,7 +21,7 @@ import {
21
21
  provisionedDeviceSchema,
22
22
  readReplicasRuntimeEnv,
23
23
  serializePosixEnvFile
24
- } from "./chunk-2E6IP4OG.js";
24
+ } from "./chunk-LLSE2EKJ.js";
25
25
 
26
26
  // src/runtime-env-loader.ts
27
27
  import { readFileSync } 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
  AspClient
6
- } from "./chunk-X57JBOEJ.js";
6
+ } from "./chunk-QLDS5LTC.js";
7
7
  import {
8
8
  ASTER_BASE_URL,
9
9
  ASTER_PROVIDER,
@@ -15,7 +15,7 @@ import {
15
15
  isRecord,
16
16
  readOllamaAuthEnv,
17
17
  readOpenAICompatibleAuthEnv
18
- } from "./chunk-2E6IP4OG.js";
18
+ } from "./chunk-LLSE2EKJ.js";
19
19
 
20
20
  // src/managers/codex-asp/notification-dispatch.ts
21
21
  var TURN_STARTED_METHOD = "turn/started";
@@ -1643,7 +1643,8 @@ var sendChatMessageRequestSchema = z4.object({
1643
1643
  senderAvatarUrl: z4.string().optional(),
1644
1644
  errorNotificationTarget: integrationErrorNotificationTargetSchema.optional(),
1645
1645
  errorNotificationTargets: z4.array(integrationErrorNotificationTargetSchema).optional(),
1646
- replacesMessageId: z4.string().min(1).max(256).optional()
1646
+ replacesMessageId: z4.string().min(1).max(256).optional(),
1647
+ steer: z4.union([z4.boolean(), z4.literal("alone")]).optional()
1647
1648
  }).passthrough();
1648
1649
  function isChatMessageSender(value) {
1649
1650
  return isRecord(value) && (value.messageId === void 0 || typeof value.messageId === "string") && typeof value.senderUserId === "string" && typeof value.senderEmail === "string" && typeof value.recordedAt === "string";
@@ -1826,11 +1827,20 @@ function applyCodexAspTranscriptDelta(current, delta) {
1826
1827
  turns
1827
1828
  };
1828
1829
  }
1830
+ async function steerQueuedInOrder(queue, messageId, steer) {
1831
+ const ids = queue.slice(0, queue.findIndex(({ id }) => id === messageId) + 1).filter(({ steeredAt }) => !steeredAt).map(({ id }) => id);
1832
+ if (ids.at(-1) !== messageId) return false;
1833
+ for (const id of ids) {
1834
+ if (!await steer(id)) return false;
1835
+ }
1836
+ return true;
1837
+ }
1829
1838
  var sendChatMessageResponseSchema = z4.object({
1830
1839
  messageId: z4.string(),
1831
1840
  queued: z4.boolean(),
1832
1841
  position: z4.number(),
1833
- chatId: z4.string().optional()
1842
+ chatId: z4.string().optional(),
1843
+ steered: z4.boolean().optional()
1834
1844
  });
1835
1845
  function isLatestChatHistoryPage(params) {
1836
1846
  return params.beforeCursor === void 0 && params.beforeEvent === void 0 && params.beforeTurn === void 0;
@@ -5936,25 +5946,18 @@ function fileContentDiff(path, content, action) {
5936
5946
  ].join("\n");
5937
5947
  }
5938
5948
  var SEARCH_COMMANDS = /* @__PURE__ */ new Set(["grep", "rg"]);
5939
- var OPTION_VALUE_FLAGS = /* @__PURE__ */ new Set([
5940
- "-A",
5941
- "-B",
5942
- "-C",
5943
- "-e",
5944
- "-f",
5945
- "-m",
5946
- "--after-context",
5947
- "--before-context",
5948
- "--context",
5949
- "--glob",
5950
- "--max-count",
5951
- "--regexp"
5952
- ]);
5953
- var LINE_COUNT_VALUE_FLAGS = /* @__PURE__ */ new Set([
5954
- "-c",
5955
- "-n",
5956
- "--lines"
5957
- ]);
5949
+ var LINE_COUNT_VALUE_FLAGS = /* @__PURE__ */ new Set(["-c", "-n", "--bytes", "--lines"]);
5950
+ var SEARCH_VALUE_FLAGS = ["-A", "-B", "-C", "-d", "-e", "-f", "-m", "--after-context", "--before-context", "--context", "--file", "--max-count", "--regexp"];
5951
+ var VALUE_FLAGS = {
5952
+ grep: /* @__PURE__ */ new Set([...SEARCH_VALUE_FLAGS, "-D", "--devices", "--directories", "--exclude", "--exclude-dir", "--include"]),
5953
+ rg: /* @__PURE__ */ new Set([...SEARCH_VALUE_FLAGS, "-E", "-M", "-T", "-g", "-j", "-t", "--encoding", "--glob", "--iglob", "--max-columns", "--max-depth", "--sort", "--sortr", "--threads", "--type", "--type-add", "--type-not"]),
5954
+ head: LINE_COUNT_VALUE_FLAGS,
5955
+ tail: LINE_COUNT_VALUE_FLAGS,
5956
+ ls: /* @__PURE__ */ new Set(["-I", "-T", "-w", "--hide", "--ignore", "--tabsize", "--width"]),
5957
+ nl: /* @__PURE__ */ new Set(["-b", "-d", "-f", "-h", "-i", "-l", "-n", "-s", "-v", "-w"]),
5958
+ tree: /* @__PURE__ */ new Set(["-I", "-L", "-P", "--filelimit"])
5959
+ };
5960
+ var PATTERN_FLAGS = /* @__PURE__ */ new Set(["-e", "-f", "--file", "--regexp"]);
5958
5961
  var SCRIPT_ROOT = "/";
5959
5962
  var commandName = (argv) => argv[0].split("/").pop() ?? argv[0];
5960
5963
  var fileWrites = ({ writes }) => writes.filter(({ path }) => path !== "/dev/null");
@@ -5976,15 +5979,15 @@ function skillNamesFromCommand(command) {
5976
5979
  });
5977
5980
  })));
5978
5981
  }
5979
- function pathArgs(words, extraValueFlags) {
5982
+ function pathArgs(command, words) {
5980
5983
  const paths = [];
5981
5984
  for (let i = 0; i < words.length; i++) {
5982
5985
  const word = words[i];
5983
- if (OPTION_VALUE_FLAGS.has(word) || extraValueFlags?.has(word)) {
5986
+ const valueAt = /^-[A-Za-z]{2,}$/.test(word) ? [...word.slice(1)].findIndex((letter) => VALUE_FLAGS[command]?.has(`-${letter}`)) : -1;
5987
+ if (VALUE_FLAGS[command]?.has(word) || valueAt >= 0 && valueAt === word.length - 2) {
5984
5988
  i++;
5985
5989
  continue;
5986
5990
  }
5987
- if (word.startsWith("--glob=") || word.startsWith("--regexp=")) continue;
5988
5991
  if (word.startsWith("-")) continue;
5989
5992
  paths.push(word);
5990
5993
  }
@@ -5992,8 +5995,13 @@ function pathArgs(words, extraValueFlags) {
5992
5995
  }
5993
5996
  function readCommandPaths(command, words) {
5994
5997
  if (SEARCH_COMMANDS.has(command)) {
5995
- const args = pathArgs(words.slice(1));
5996
- return args.slice(1);
5998
+ const args = pathArgs(command, words.slice(1));
5999
+ return words.some((word) => PATTERN_FLAGS.has(word) || /^-[A-Za-z]+[ef]$/.test(word) || /^--(file|regexp)=/.test(word)) ? args : args.slice(1);
6000
+ }
6001
+ if (command === "find") {
6002
+ const paths = words.slice(1).filter((word) => !/^(-[HLP]|-O\d|--)$/.test(word));
6003
+ const expression = paths.findIndex((word) => word.startsWith("-") || word === "(" || word === "!");
6004
+ return expression === -1 ? paths : paths.slice(0, expression);
5997
6005
  }
5998
6006
  if (command === "sed") {
5999
6007
  const paths = [];
@@ -6019,7 +6027,7 @@ function readCommandPaths(command, words) {
6019
6027
  }
6020
6028
  return Array.from(new Set(paths));
6021
6029
  }
6022
- return pathArgs(words.slice(1), command === "head" || command === "tail" ? LINE_COUNT_VALUE_FLAGS : void 0);
6030
+ return pathArgs(command, words.slice(1));
6023
6031
  }
6024
6032
  function writesFiles(name, argv) {
6025
6033
  if (name === "sed") return argv.some((word) => /^(-[a-zA-Z]*i|--in-place)/.test(word));
@@ -9175,6 +9183,9 @@ function parseGoalCommand(message2) {
9175
9183
  if (!value) return null;
9176
9184
  return classifyGoalValue(value);
9177
9185
  }
9186
+ function isCompactCommand(message2) {
9187
+ return /^\/compact$/i.test(message2.trim());
9188
+ }
9178
9189
  function getGoalCommand(message2, goalMode) {
9179
9190
  if (!goalMode) return parseGoalCommand(message2);
9180
9191
  const value = message2.trim();
@@ -10838,6 +10849,7 @@ export {
10838
10849
  codexItemFromEvent,
10839
10850
  codexTurnFromEvent,
10840
10851
  codexTranscriptToEvents,
10852
+ steerQueuedInOrder,
10841
10853
  isLatestChatHistoryPage,
10842
10854
  getChatHistoryPageSenders,
10843
10855
  parseChatHistoryCursor,
@@ -10939,6 +10951,7 @@ export {
10939
10951
  mergeSlashCommands,
10940
10952
  getSlashCommandsForProvider,
10941
10953
  MAX_CODEX_GOAL_OBJECTIVE_CHARS,
10954
+ isCompactCommand,
10942
10955
  getGoalCommand,
10943
10956
  getGoalCommandObjectiveValidationError,
10944
10957
  DEFAULT_START_HOOK_TIMEOUT_MS,
@@ -10,15 +10,15 @@ import {
10
10
  resolveDiffBase,
11
11
  runGitCommand,
12
12
  setAgentCredentialSnapshot
13
- } from "./chunk-WWLQEDZK.js";
13
+ } from "./chunk-56WDCAN2.js";
14
14
  import {
15
15
  AppServerProcess,
16
16
  buildCodexAgentEnv
17
- } from "./chunk-X57JBOEJ.js";
17
+ } from "./chunk-QLDS5LTC.js";
18
18
  import {
19
19
  SUBPROCESS_MAX_BUFFER,
20
20
  execFileAsync
21
- } from "./chunk-4U6EPPZF.js";
21
+ } from "./chunk-2MCGQBB5.js";
22
22
  import {
23
23
  isRecord
24
24
  } from "./chunk-UZSNFLDQ.js";
@@ -56,7 +56,7 @@ import {
56
56
  resolveOpenAICompatibleModelsUrl,
57
57
  splitMothershipInstructions,
58
58
  withTimeout
59
- } from "./chunk-2E6IP4OG.js";
59
+ } from "./chunk-LLSE2EKJ.js";
60
60
 
61
61
  // src/managers/codex-token-manager.ts
62
62
  import { promises as fs } from "fs";
@@ -306,7 +306,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
306
306
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
307
307
  await this.applyCredentialsResponse(data);
308
308
  setAgentCredentialSnapshot("codex", data);
309
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ODE5XLJ7.js");
309
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ANSPVIFL.js");
310
310
  await restartCodexAspHostIfRunning2();
311
311
  });
312
312
  await this.start(true);
@@ -328,7 +328,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
328
328
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
329
329
  await this.applyCredentialsResponse(data);
330
330
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
331
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ODE5XLJ7.js");
331
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ANSPVIFL.js");
332
332
  await restartCodexAspHostIfRunning2();
333
333
  }
334
334
  setAgentCredentialSnapshot("codex", data);
@@ -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-4U6EPPZF.js";
6
+ } from "./chunk-2MCGQBB5.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-2E6IP4OG.js";
9
+ } from "./chunk-LLSE2EKJ.js";
10
10
 
11
11
  // src/utils/codex-agent-env.ts
12
12
  function buildCodexAgentEnv(source = process.env) {
@@ -240,7 +240,7 @@ function getCodexModelProvider(method) {
240
240
  if (method === "foundry") return "azure";
241
241
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
242
242
  }
243
- var ENGINE_PACKAGE_VERSION = "0.1.1316";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1318";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-2E6IP4OG.js";
8
+ } from "./chunk-LLSE2EKJ.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -6,7 +6,7 @@ import {
6
6
  getOriginDefaultBranch,
7
7
  monolithRequest,
8
8
  runGitCommand
9
- } from "./chunk-WWLQEDZK.js";
9
+ } from "./chunk-56WDCAN2.js";
10
10
  import {
11
11
  extractCommandProtectionCommandText,
12
12
  findCommandProtectionGitLookups,
@@ -14,7 +14,7 @@ import {
14
14
  findPrMergeSignals,
15
15
  findScoutRepoWriteSignals,
16
16
  parseCommandProtectionRequest
17
- } from "./chunk-2E6IP4OG.js";
17
+ } from "./chunk-LLSE2EKJ.js";
18
18
 
19
19
  // src/services/command-protection-service.ts
20
20
  import { readFile, stat } from "fs/promises";
@@ -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-4G3GJD4G.js";
7
- import "./chunk-WWLQEDZK.js";
8
- import "./chunk-4U6EPPZF.js";
6
+ } from "./chunk-VY3L43BO.js";
7
+ import "./chunk-56WDCAN2.js";
8
+ import "./chunk-2MCGQBB5.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-2E6IP4OG.js";
12
+ import "./chunk-LLSE2EKJ.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -14,12 +14,12 @@ import {
14
14
  recoverCompletedTurn,
15
15
  spawnMuseMsp,
16
16
  startMuseSession
17
- } from "./chunk-7OUVPGTE.js";
17
+ } from "./chunk-I2O6UQT6.js";
18
18
  import {
19
19
  AppServerProcess,
20
20
  buildCodexAgentEnv
21
- } from "./chunk-X57JBOEJ.js";
22
- import "./chunk-4U6EPPZF.js";
21
+ } from "./chunk-QLDS5LTC.js";
22
+ import "./chunk-2MCGQBB5.js";
23
23
  import {
24
24
  AGENT,
25
25
  OPENCODE_GO_PROVIDER,
@@ -29,7 +29,7 @@ import {
29
29
  headlessAgentUsagePath,
30
30
  isRecord,
31
31
  withTimeout
32
- } from "./chunk-2E6IP4OG.js";
32
+ } from "./chunk-LLSE2EKJ.js";
33
33
  import "./chunk-VEQXQN22.js";
34
34
 
35
35
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  evaluateCommandProtection,
28
28
  extractToolCommand,
29
29
  reportCommandProtectionBlock
30
- } from "./chunk-4G3GJD4G.js";
30
+ } from "./chunk-VY3L43BO.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -65,10 +65,10 @@ import {
65
65
  spawnMuseMsp,
66
66
  startMuseSession,
67
67
  uuidV7
68
- } from "./chunk-7OUVPGTE.js";
68
+ } from "./chunk-I2O6UQT6.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
- } from "./chunk-QNFQZSM4.js";
71
+ } from "./chunk-RG6ZUUTP.js";
72
72
  import {
73
73
  ACCOUNT_RATE_LIMITS_READ_METHOD,
74
74
  AsyncLock,
@@ -143,7 +143,7 @@ import {
143
143
  timestampFromSeconds,
144
144
  upsertCredentialFileLines,
145
145
  writeSecureCredentialFile
146
- } from "./chunk-O4UY6MG5.js";
146
+ } from "./chunk-ORM5QECI.js";
147
147
  import {
148
148
  ENGINE_ENV,
149
149
  monolithRequest,
@@ -153,15 +153,15 @@ import {
153
153
  resolveDiffBase,
154
154
  setAgentCredentialSnapshot,
155
155
  setLinearSessionId
156
- } from "./chunk-WWLQEDZK.js";
156
+ } from "./chunk-56WDCAN2.js";
157
157
  import {
158
158
  getCodexModelProvider
159
- } from "./chunk-X57JBOEJ.js";
159
+ } from "./chunk-QLDS5LTC.js";
160
160
  import {
161
161
  SUBPROCESS_MAX_BUFFER,
162
162
  execAsync,
163
163
  execFileAsync
164
- } from "./chunk-4U6EPPZF.js";
164
+ } from "./chunk-2MCGQBB5.js";
165
165
  import {
166
166
  isRecord as isRecord2
167
167
  } from "./chunk-UZSNFLDQ.js";
@@ -343,6 +343,7 @@ import {
343
343
  isClaudeResultError,
344
344
  isClientMessageSource,
345
345
  isCodexAuthError,
346
+ isCompactCommand,
346
347
  isDefaultChat,
347
348
  isExcludedRepoFilePath,
348
349
  isLatestChatHistoryPage,
@@ -403,6 +404,7 @@ import {
403
404
  skillNamesFromCommand,
404
405
  spawnSubagentRequestSchema,
405
406
  splitMothershipInstructions,
407
+ steerQueuedInOrder,
406
408
  stripAgentDiagnosticErrors,
407
409
  threadHandoffText,
408
410
  toClaudeCodeModel,
@@ -415,7 +417,7 @@ import {
415
417
  workspaceTokenRequestSchema,
416
418
  workspaceTokenResponseSchema,
417
419
  wrapInTag
418
- } from "./chunk-2E6IP4OG.js";
420
+ } from "./chunk-LLSE2EKJ.js";
419
421
  import {
420
422
  cloneMcpConfig,
421
423
  ensureCompatibilityImports,
@@ -10812,6 +10814,11 @@ function insertChronologically(existing, additions) {
10812
10814
  result.push(...sorted.slice(next));
10813
10815
  return result;
10814
10816
  }
10817
+ function canSteerMessage(provider, request) {
10818
+ if (provider === "cursor") return !request.images?.length;
10819
+ if (provider !== "claude" && provider !== "codex") return false;
10820
+ return !getGoalCommand(request.message, request.goalMode) && !(provider === "codex" && isCompactCommand(request.message));
10821
+ }
10815
10822
 
10816
10823
  // src/managers/claude-manager.ts
10817
10824
  import {
@@ -14670,9 +14677,6 @@ function skillsListToSlashCommands(response) {
14670
14677
  }))
14671
14678
  );
14672
14679
  }
14673
- function isCompactCommand(message) {
14674
- return /^\/compact$/i.test(message.trim());
14675
- }
14676
14680
  var CodexAspManager = class extends CodingAgentManager {
14677
14681
  currentThreadId = null;
14678
14682
  pendingFork = null;
@@ -14749,7 +14753,7 @@ var CodexAspManager = class extends CodingAgentManager {
14749
14753
  return super.interrupt(persistRemoval);
14750
14754
  }
14751
14755
  async keepStoppedRequest(request) {
14752
- if (isCompactCommand(request.message) || getGoalCommand(request.message, request.goalMode)) return false;
14756
+ if (!canSteerMessage("codex", request)) return false;
14753
14757
  this.unreadRequests.push({ ...request, message: `${request.message}
14754
14758
 
14755
14759
  ` });
@@ -14815,7 +14819,7 @@ var CodexAspManager = class extends CodingAgentManager {
14815
14819
  const expectedTurnId = this.activeTurnId;
14816
14820
  if (!threadId || !expectedTurnId || !this.messageQueue.isProcessing()) return false;
14817
14821
  if (this.compacting) return false;
14818
- if (getGoalCommand(request.message, request.goalMode) || isCompactCommand(request.message)) return false;
14822
+ if (!canSteerMessage("codex", request)) return false;
14819
14823
  const { input, tempImagePaths } = await buildTurnInput(request);
14820
14824
  const result = await this.requestActiveTurnWithReconciliation(
14821
14825
  "steer",
@@ -60551,12 +60555,12 @@ var ChatService = class {
60551
60555
  const typedMessage = request.message;
60552
60556
  const idempotencyKey = request.idempotencyKey ?? request.messageId;
60553
60557
  if (idempotencyKey) {
60558
+ const accepting2 = chat.acceptingSendResponses.get(idempotencyKey);
60559
+ if (accepting2) return accepting2;
60554
60560
  const accepted = chat.acceptedSendResponses.get(idempotencyKey);
60555
60561
  if (accepted) {
60556
60562
  return accepted;
60557
60563
  }
60558
- const accepting2 = chat.acceptingSendResponses.get(idempotencyKey);
60559
- if (accepting2) return accepting2;
60560
60564
  }
60561
60565
  if (chat.switching) await chat.switching.catch(() => {
60562
60566
  });
@@ -60602,17 +60606,29 @@ ${decisions}` };
60602
60606
  model: request.model ?? savedModel ?? void 0,
60603
60607
  thinkingLevel: request.thinkingLevel ?? (request.inheritThinkingLevel ? chat.persisted.thinkingLevel : void 0)
60604
60608
  };
60605
- return await chat.provider.enqueueMessage(
60606
- request,
60607
- (result, acceptedMessage) => this.withUnpublishedHistory(chat, () => this.handleMessageAccepted(
60608
- chatId,
60609
- chat,
60610
- request,
60611
- acceptedMessage,
60612
- result,
60613
- typedMessage
60614
- ))
60615
- );
60609
+ const { steer, ...queued } = request;
60610
+ const enqueued = steer ? { ...queued, messageId: queued.messageId ?? `msg_${randomUUID10()}` } : queued;
60611
+ if (enqueued.messageId && steer && chat.provider.isProcessing() && (steer === "alone" || chat.provider.getQueue().every(({ steeredAt }) => steeredAt)) && canSteerMessage(chat.persisted.provider, enqueued)) {
60612
+ chat.steeringOnArrival.add(enqueued.messageId);
60613
+ }
60614
+ try {
60615
+ const response = await chat.provider.enqueueMessage(
60616
+ enqueued,
60617
+ (result, acceptedMessage) => this.withUnpublishedHistory(chat, () => this.handleMessageAccepted(
60618
+ chatId,
60619
+ chat,
60620
+ request,
60621
+ acceptedMessage,
60622
+ result,
60623
+ typedMessage
60624
+ ))
60625
+ );
60626
+ if (!steer || !response.queued) return response;
60627
+ const steered = await steerQueuedInOrder(steer === "alone" ? [{ id: response.messageId }] : chat.provider.getQueue(), response.messageId, async (id) => (await this.steerFromQueue(chatId, id)).success);
60628
+ return { ...response, steered };
60629
+ } finally {
60630
+ if (enqueued.messageId && chat.steeringOnArrival.delete(enqueued.messageId)) this.publishQueueIfChanged(chatId);
60631
+ }
60616
60632
  } catch (error) {
60617
60633
  if (seenBeforeSend) this.forkSourceSeenBlocks.set(chatId, seenBeforeSend);
60618
60634
  else this.forkSourceSeenBlocks.delete(chatId);
@@ -60833,7 +60849,7 @@ ${decisions}` };
60833
60849
  return {
60834
60850
  chatId,
60835
60851
  processing: hasActiveChatTurn(chat),
60836
- queue: chat.provider.getQueue()
60852
+ queue: chat.provider.getQueue().map((message) => chat.steeringOnArrival.has(message.id) && !message.steeredAt ? { ...message, steeredAt: message.queuedAt } : message)
60837
60853
  };
60838
60854
  }
60839
60855
  async withUnpublishedHistory(chat, run) {
@@ -61563,6 +61579,7 @@ ${note}`;
61563
61579
  historyVersion: randomUUID10(),
61564
61580
  provider,
61565
61581
  pendingMessageIds: [],
61582
+ steeringOnArrival: /* @__PURE__ */ new Set(),
61566
61583
  acceptedUserEvents: /* @__PURE__ */ new Map(),
61567
61584
  acceptedSendResponses: new Map(Object.entries(persisted.acceptedSendResponses ?? {})),
61568
61585
  acceptingSendResponses: /* @__PURE__ */ new Map(),
@@ -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-QNFQZSM4.js";
6
+ } from "./chunk-RG6ZUUTP.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-2E6IP4OG.js";
12
+ } from "./chunk-LLSE2EKJ.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-2E6IP4OG.js";
14
+ } from "./chunk-LLSE2EKJ.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.1316",
3
+ "version": "0.1.1318",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",