replicas-engine 0.1.1601 → 0.1.1604

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.
@@ -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-O76HWQZW.js";
7
- import "./chunk-LAVIBP35.js";
8
- import "./chunk-6DGCGNRD.js";
6
+ } from "./chunk-GUT6QWKE.js";
7
+ import "./chunk-YMTLOKKY.js";
8
+ import "./chunk-6D5SMRMT.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-Z744SRUU.js";
12
+ import "./chunk-ZKSPRQIP.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-PUN65MPP.js";
17
+ } from "./chunk-G4JGVKBD.js";
18
18
  import {
19
19
  AppServerProcess,
20
20
  buildCodexAgentEnv
21
- } from "./chunk-E5U45B5E.js";
22
- import "./chunk-6DGCGNRD.js";
21
+ } from "./chunk-CLNFEQTV.js";
22
+ import "./chunk-6D5SMRMT.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-Z744SRUU.js";
32
+ } from "./chunk-ZKSPRQIP.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-O76HWQZW.js";
30
+ } from "./chunk-GUT6QWKE.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-PUN65MPP.js";
68
+ } from "./chunk-G4JGVKBD.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
- } from "./chunk-4XXV6XF7.js";
71
+ } from "./chunk-L4G45OOU.js";
72
72
  import {
73
73
  ACCOUNT_RATE_LIMITS_READ_METHOD,
74
74
  AsyncLock,
@@ -147,7 +147,7 @@ import {
147
147
  transcriptSecrets,
148
148
  upsertCredentialFileLines,
149
149
  writeSecureCredentialFile
150
- } from "./chunk-LM3GPSH5.js";
150
+ } from "./chunk-YSWTDVQS.js";
151
151
  import {
152
152
  ENGINE_ENV,
153
153
  UNQUOTED_PATHS_CONFIG,
@@ -158,16 +158,16 @@ import {
158
158
  resolveDiffBase,
159
159
  setAgentCredentialSnapshot,
160
160
  setLinearSessionId
161
- } from "./chunk-LAVIBP35.js";
161
+ } from "./chunk-YMTLOKKY.js";
162
162
  import {
163
163
  buildCodexAgentEnv,
164
164
  getCodexModelProvider
165
- } from "./chunk-E5U45B5E.js";
165
+ } from "./chunk-CLNFEQTV.js";
166
166
  import {
167
167
  SUBPROCESS_MAX_BUFFER,
168
168
  execAsync,
169
169
  execFileAsync
170
- } from "./chunk-6DGCGNRD.js";
170
+ } from "./chunk-6D5SMRMT.js";
171
171
  import {
172
172
  isRecord as isRecord2
173
173
  } from "./chunk-UZSNFLDQ.js";
@@ -463,7 +463,7 @@ import {
463
463
  workspaceTokenRequestSchema,
464
464
  workspaceTokenResponseSchema,
465
465
  wrapInTag
466
- } from "./chunk-Z744SRUU.js";
466
+ } from "./chunk-ZKSPRQIP.js";
467
467
  import {
468
468
  cloneMcpConfig,
469
469
  ensureCompatibilityImports,
@@ -10318,7 +10318,7 @@ These hooks are currently executing in the background. You can:
10318
10318
  - View hook commands in each repository's replicas.json (under the "startHook" field)
10319
10319
 
10320
10320
  The start hooks may install dependencies, build projects, or perform other setup tasks.
10321
- If your task depends on setup being complete, check the log file before proceeding.`;
10321
+ Don't run those steps yourself while the hooks are running: a second install or build alongside theirs can break both. Before anything that needs the setup, wait until the log shows "=== All start hooks completed".`;
10322
10322
  async function readReplicasConfigFromDir(dirPath) {
10323
10323
  for (const filename of REPLICAS_CONFIG_FILENAMES) {
10324
10324
  const configPath = join5(dirPath, filename);
@@ -10357,6 +10357,7 @@ var ReplicasConfigService = class {
10357
10357
  }
10358
10358
  };
10359
10359
  this.hooksRunning = true;
10360
+ if (this.getStartHookConfig()) await writeFile3(START_HOOKS_LOG, "Start hooks are waiting to run.\n", "utf-8").catch((error) => console.error("Failed to reset start hooks log:", error));
10360
10361
  void beforeHooks.then(() => this.executeStartHooks({ onStart: () => void report({ status: "running" }) })).then(async (result) => report({
10361
10362
  status: result.exitCode === 0 && !result.timedOut ? "succeeded" : "failed",
10362
10363
  exitCode: result.exitCode,
@@ -10684,7 +10685,6 @@ ${startHookConfig.commands.join("\n")}`;
10684
10685
  }
10685
10686
  this.hooksCompleted = true;
10686
10687
  this.hooksFailed = overallExitCode !== 0;
10687
- await this.logToFile(`=== All start hooks completed at ${(/* @__PURE__ */ new Date()).toISOString()} ===`);
10688
10688
  const result = {
10689
10689
  exitCode: overallExitCode,
10690
10690
  output: outputBlocks.join("\n\n"),
@@ -10700,6 +10700,7 @@ ${startHookConfig.commands.join("\n")}`;
10700
10700
  await this.logToFile(`[SYSTEM] [ERROR] Start hooks execution failed: ${errorMessage}`);
10701
10701
  throw error;
10702
10702
  } finally {
10703
+ await this.logToFile(`=== All start hooks completed at ${(/* @__PURE__ */ new Date()).toISOString()} ===`);
10703
10704
  this.hooksRunning = false;
10704
10705
  }
10705
10706
  }
@@ -11160,7 +11161,7 @@ import { z as z4 } from "zod";
11160
11161
 
11161
11162
  // ../shared/src/persisted-query-hashes.ts
11162
11163
  var PERSISTED_QUERY_HASHES = {
11163
- workspaceChats: "79951346"
11164
+ workspaceChats: "e406bd60"
11164
11165
  };
11165
11166
 
11166
11167
  // ../shared/src/workspace-chat.ts
@@ -11853,6 +11854,7 @@ Native subagent tools are disabled in this workspace. To delegate work to a suba
11853
11854
  var MAX_INTERRUPT_QUEUE_ITEMS = 1e3;
11854
11855
  var MAX_INTERRUPT_QUEUE_CHARS = 2e5;
11855
11856
  var MAX_REQUESTED_STOP_AGE_MS = 1e4;
11857
+ var PROMPT_START_WAIT_MS = 1e4;
11856
11858
  function toQueuedMessageInfo(message) {
11857
11859
  return {
11858
11860
  id: message.id,
@@ -11899,6 +11901,9 @@ var CodingAgentManager = class _CodingAgentManager {
11899
11901
  withdrawnSteers = /* @__PURE__ */ new WeakSet();
11900
11902
  earlySteerDelivery = new AsyncLock();
11901
11903
  turnOpen = false;
11904
+ reportsPromptStart = false;
11905
+ // A Send now waits for the turn's prompt to start, as an earlier cut cuts nothing; a command's turn has none, so it is never cut as it begins.
11906
+ promptStart = null;
11902
11907
  lastSenderKey;
11903
11908
  // Unset until this process sends a turn, so a restart can't mistake the first one for a change.
11904
11909
  sentTurn = false;
@@ -11988,7 +11993,7 @@ var CodingAgentManager = class _CodingAgentManager {
11988
11993
  initializeManager(processMessage) {
11989
11994
  this.messageQueue = new MessageQueueService(
11990
11995
  async (request, signal) => {
11991
- this.turnOpen = true;
11996
+ this.openTurn(request);
11992
11997
  try {
11993
11998
  await Promise.all([this.refreshSubagentMcp(), this.refreshAutoCompactTokens()]);
11994
11999
  const { request: delivered, senderKey } = this.withSenderLine(request);
@@ -12014,7 +12019,7 @@ var CodingAgentManager = class _CodingAgentManager {
12014
12019
  this.onProcessingChanged,
12015
12020
  // Opened before the turn-start event persists, since a follow-up can arrive while it does.
12016
12021
  async (message) => {
12017
- this.turnOpen = true;
12022
+ this.openTurn(message);
12018
12023
  try {
12019
12024
  await this.onMessageStarted(message);
12020
12025
  } catch (error) {
@@ -12234,6 +12239,8 @@ ${note}` };
12234
12239
  const queued = this.messageQueue.getQueue().some(({ id }) => id === messageId);
12235
12240
  if (!queued && !this.unreadSteers.has(messageId)) return { success: false, queue: this.getQueue() };
12236
12241
  if (this.messageQueue.isProcessing() && (!queued || (await this.steerFromQueue(messageId)).success)) {
12242
+ const start = this.unreadSteers.has(messageId) && !this.canDeliverSteersNow() ? this.promptStart : null;
12243
+ if (start && await raceWithTimeout(start.promise, PROMPT_START_WAIT_MS) === TIMEOUT) return { success: false, queue: this.getQueue() };
12237
12244
  const delivered = !this.unreadSteers.has(messageId) || !this.canDeliverSteersNow() || await this.deliverSteersNow();
12238
12245
  return { success: delivered, queue: this.getQueue() };
12239
12246
  }
@@ -12248,8 +12255,13 @@ ${note}` };
12248
12255
  }
12249
12256
  return { success: true, queue: this.getQueue() };
12250
12257
  }
12258
+ openTurn(message) {
12259
+ this.turnOpen = true;
12260
+ if (this.reportsPromptStart && takesTurnNotes(message)) this.promptStart ??= Promise.withResolvers();
12261
+ }
12251
12262
  closeTurn() {
12252
12263
  this.turnOpen = false;
12264
+ this.settlePromptStart();
12253
12265
  if (this.earlySteers.length > 0) this.requeueUnreadSteers();
12254
12266
  }
12255
12267
  requeueUnreadSteers() {
@@ -12274,6 +12286,10 @@ ${note}` };
12274
12286
  }
12275
12287
  return steer?.delivered ?? inFlight?.delivered ?? this.messageQueue.takeFromQueue(messageId)?.message;
12276
12288
  }
12289
+ settlePromptStart() {
12290
+ this.promptStart?.resolve();
12291
+ this.promptStart = null;
12292
+ }
12277
12293
  canDeliverSteersNow() {
12278
12294
  return false;
12279
12295
  }
@@ -13532,6 +13548,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13532
13548
  stopping = null;
13533
13549
  // Claude Code emits a stopped turn's partial reply only after acknowledging the interrupt, so teardown waits for the turn to end.
13534
13550
  stoppedTurnEnded = null;
13551
+ reportsPromptStart = true;
13535
13552
  // Claude Code writes a started prompt to the session transcript even when the turn then fails, so a retry must not resend it.
13536
13553
  turnPromptRecorded = false;
13537
13554
  endedReplies = /* @__PURE__ */ new Set();
@@ -14594,8 +14611,10 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14594
14611
  this.setAuthRetrying(false);
14595
14612
  const lifecycle2 = msg;
14596
14613
  if (isRecord(lifecycle2) && lifecycle2.type === "command_lifecycle" && lifecycle2.state === "started" && typeof lifecycle2.command_uuid === "string") {
14597
- if (this.pendingTurn?.userMessageUuids.has(lifecycle2.command_uuid)) this.turnPromptRecorded = true;
14598
- else if (!this.activePromptStream?.sentUuids.has(lifecycle2.command_uuid)) await this.recordPeerMessage(lifecycle2.command_uuid, response);
14614
+ if (this.pendingTurn?.userMessageUuids.has(lifecycle2.command_uuid)) {
14615
+ this.turnPromptRecorded = true;
14616
+ this.settlePromptStart();
14617
+ } else if (!this.activePromptStream?.sentUuids.has(lifecycle2.command_uuid)) await this.recordPeerMessage(lifecycle2.command_uuid, response);
14599
14618
  if (this.activeQuery !== response) break;
14600
14619
  await this.recordSteerRead(lifecycle2.command_uuid);
14601
14620
  }
@@ -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-4XXV6XF7.js";
6
+ } from "./chunk-L4G45OOU.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-Z744SRUU.js";
12
+ } from "./chunk-ZKSPRQIP.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-Z744SRUU.js";
14
+ } from "./chunk-ZKSPRQIP.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.1601",
3
+ "version": "0.1.1604",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",