replicas-engine 0.1.931 → 0.1.933

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.
@@ -5,11 +5,11 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-OBW7XFNZ.js";
9
- import "./chunk-KTWH5E6W.js";
10
- import "./chunk-ASZVT3MJ.js";
8
+ } from "./chunk-5PTJWSW3.js";
9
+ import "./chunk-3GJEQKPY.js";
10
+ import "./chunk-BXHF65NV.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-QZYXFGI7.js";
12
+ import "./chunk-RVSMHQVH.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-QZYXFGI7.js";
18
+ } from "./chunk-RVSMHQVH.js";
19
19
 
20
20
  // src/runtime-env-loader.ts
21
21
  import { readFileSync } from "fs";
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-KTWH5E6W.js";
8
+ } from "./chunk-3GJEQKPY.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-ASZVT3MJ.js";
14
+ } from "./chunk-BXHF65NV.js";
15
15
  import {
16
16
  isRecord
17
17
  } from "./chunk-UZSNFLDQ.js";
@@ -25,7 +25,7 @@ import {
25
25
  listOpenAICompatibleModels,
26
26
  readOllamaAuthEnv,
27
27
  resolveOpenAICompatibleModelsUrl
28
- } from "./chunk-QZYXFGI7.js";
28
+ } from "./chunk-RVSMHQVH.js";
29
29
 
30
30
  // src/managers/codex-token-manager.ts
31
31
  import { promises as fs } from "fs";
@@ -258,7 +258,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
258
258
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
259
259
  await this.applyCredentialsResponse(data);
260
260
  setAgentCredentialSnapshot("codex", data);
261
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-26FIANOX.js");
261
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-V5JMSPLS.js");
262
262
  await restartCodexAspHostIfRunning2();
263
263
  });
264
264
  await this.start(true);
@@ -278,7 +278,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
278
278
  await this.applyCredentialUpdate(generation, async () => {
279
279
  await this.applyCredentialsResponse(data);
280
280
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
281
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-26FIANOX.js");
281
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-V5JMSPLS.js");
282
282
  await restartCodexAspHostIfRunning2();
283
283
  }
284
284
  setAgentCredentialSnapshot("codex", data);
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES,
6
6
  isVersionBelow
7
- } from "./chunk-QZYXFGI7.js";
7
+ } from "./chunk-RVSMHQVH.js";
8
8
 
9
9
  // src/utils/codex-agent-env.ts
10
10
  function buildCodexAgentEnv(source = process.env) {
@@ -245,7 +245,7 @@ function getCodexModelProvider(method) {
245
245
  if (method === "foundry") return "azure";
246
246
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
247
247
  }
248
- var ENGINE_PACKAGE_VERSION = "0.1.931";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.933";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  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-QZYXFGI7.js";
8
+ } from "./chunk-RVSMHQVH.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -1109,9 +1109,12 @@ var createChatRequestSchema = z3.object({
1109
1109
  title: z3.string().min(1).optional(),
1110
1110
  parentChatId: z3.string().uuid().optional(),
1111
1111
  forkSourceChatId: z3.string().uuid().optional(),
1112
+ sideChat: z3.boolean().optional(),
1112
1113
  clientRequestId: z3.string().min(1).max(128).optional()
1113
1114
  }).refine((request) => request.provider === "relay" || request.relayBaseProvider === void 0, {
1114
1115
  message: "relayBaseProvider is only valid for Relay chats"
1116
+ }).refine((request) => !request.sideChat || request.forkSourceChatId !== void 0 && request.parentChatId === request.forkSourceChatId, {
1117
+ message: "A side chat must fork its parent chat"
1115
1118
  });
1116
1119
  var spawnRelaySubagentRequestSchema = z3.object({
1117
1120
  provider: z3.enum(VALID_AGENT_PROVIDERS),
@@ -1931,7 +1934,7 @@ var chatForkInfoSchema = z8.object({
1931
1934
  provider: z8.enum(VALID_AGENT_PROVIDERS),
1932
1935
  title: z8.string()
1933
1936
  }),
1934
- trigger: z8.enum(["manual", "auto"]),
1937
+ trigger: z8.enum(["manual", "auto", "side"]),
1935
1938
  reason: quotaLimitKindSchema.optional(),
1936
1939
  state: z8.enum(["preparing", "ready", "failed"]),
1937
1940
  error: z8.string().optional(),
@@ -6638,6 +6641,7 @@ function createProviderSlashCommand(provider, name, description, argumentHint) {
6638
6641
  providers: [provider]
6639
6642
  };
6640
6643
  }
6644
+ var SIDE_CHAT_COMMANDS = ["/btw", "/side"];
6641
6645
  var SLASH_COMMANDS = [
6642
6646
  {
6643
6647
  command: "/plan",
@@ -6666,7 +6670,13 @@ var SLASH_COMMANDS = [
6666
6670
  command: "/compact",
6667
6671
  description: "Compact the conversation context.",
6668
6672
  providers: ["codex", "muse"]
6669
- }
6673
+ },
6674
+ ...SIDE_CHAT_COMMANDS.map((command) => ({
6675
+ command,
6676
+ description: "Open a side chat about this chat without interrupting it.",
6677
+ argumentHint: "[question]",
6678
+ providers: [...VALID_AGENT_PROVIDERS]
6679
+ }))
6670
6680
  ];
6671
6681
  function mergeSlashCommands(...commandGroups) {
6672
6682
  const seen = /* @__PURE__ */ new Set();
@@ -7634,14 +7644,15 @@ function formatChatForkHandoffMessage(handoff) {
7634
7644
  const sourceName = getProviderDisplayName(handoff.source.provider, "long");
7635
7645
  const reason = describeChatForkReason(handoff.reason, handoff.source.provider);
7636
7646
  const why = handoff.trigger === "auto" ? `until ${reason ?? "it stopped"}, so Replicas moved the conversation to you automatically` : "until the user forked it to you";
7647
+ const side = handoff.trigger === "side";
7637
7648
  const body = [
7638
- handoff.subagent ? "# Delegated task context" : `# Continuing a ${sourceName} chat`,
7649
+ side ? "# Side chat" : handoff.subagent ? "# Delegated task context" : `# Continuing a ${sourceName} chat`,
7639
7650
  "",
7640
- handoff.subagent ? `You are a subagent of the chat "${handoff.source.title}" in this same workspace. The inherited transcript is background for your assigned task below. Follow that task and report your result to the parent; do not take over the parent's entire request. Workspace files and git state are shared and authoritative.` : `You are picking up the chat "${handoff.source.title}" in this same workspace. It was running on ${sourceName} ${why}. Everything the previous agent changed is already on disk: the workspace files and git state are authoritative.`,
7651
+ side ? `You are a side chat the user opened next to the main chat "${handoff.source.title}" (${sourceName}) in this same workspace, to talk about it without interrupting it. The main chat may still be working, and nothing you say reaches it or its agent. Answer from its transcript and the workspace. The recent turns below are a snapshot from when you were opened and the main chat has likely moved on, so re-read the transcript file before answering anything about what it is doing or has done. Its agent works in the same files, so don't edit files, change git state, or start or stop processes unless the user explicitly asks you to.` : handoff.subagent ? `You are a subagent of the chat "${handoff.source.title}" in this same workspace. The inherited transcript is background for your assigned task below. Follow that task and report your result to the parent; do not take over the parent's entire request. Workspace files and git state are shared and authoritative.` : `You are picking up the chat "${handoff.source.title}" in this same workspace. It was running on ${sourceName} ${why}. Everything the previous agent changed is already on disk: the workspace files and git state are authoritative.`,
7641
7652
  "",
7642
7653
  "## Transcript",
7643
7654
  "",
7644
- `- Sanitized transcript: \`${handoff.transcriptPath}\` (read or grep it for anything not in the excerpt below)`,
7655
+ side ? `- Main chat transcript: \`${handoff.transcriptPath}\` (Replicas refreshes it with the main chat's latest turns before each of your turns; re-read it whenever you need the main chat's current state)` : `- Sanitized transcript: \`${handoff.transcriptPath}\` (read or grep it for anything not in the excerpt below)`,
7645
7656
  ...handoff.rawHistoryPath ? [`- Raw event log: \`${handoff.rawHistoryPath}\``] : [],
7646
7657
  ...handoff.sourceTruncated ? [`- The chat was too large to sanitize in full; the sanitized file holds only its most recent part.${handoff.rawHistoryPath ? " Grep the raw event log for anything older." : ""}`] : [],
7647
7658
  "",
@@ -7650,7 +7661,7 @@ function formatChatForkHandoffMessage(handoff) {
7650
7661
  ...handoff.excerptTruncated ? [CHAT_FORK_EXCERPT_OMITTED_NOTICE, ""] : [],
7651
7662
  handoff.excerpt.trim() || "_The source chat had no messages yet._"
7652
7663
  ].join("\n");
7653
- const instruction = handoff.message?.trim() || (handoff.resumeRequest ? `The previous agent was interrupted before it finished this request from the user. Continue it now:
7664
+ const instruction = handoff.message?.trim() || (side ? "Say in one sentence that you are ready for questions about the main chat." : handoff.resumeRequest ? `The previous agent was interrupted before it finished this request from the user. Continue it now:
7654
7665
 
7655
7666
  ${handoff.resumeRequest.trim().replace(/^/gm, "> ")}` : "Review the recent turns and the current workspace state, then continue where the previous agent left off. If nothing is pending, confirm in a sentence or two what you know and wait for the next request.");
7656
7667
  return `${OPEN_MARKER}${JSON.stringify(meta)}${OPEN_MARKER_END}
@@ -7659,6 +7670,18 @@ ${CLOSE_MARKER}
7659
7670
 
7660
7671
  ${instruction}`;
7661
7672
  }
7673
+ function formatSideChatUpdateMessage(source, turns, message) {
7674
+ const meta = { sourceProvider: source.provider, sourceTitle: source.title, trigger: "side" };
7675
+ return `${OPEN_MARKER}${JSON.stringify(meta)}${OPEN_MARKER_END}
7676
+ # Main chat update
7677
+
7678
+ The main chat "${source.title}" has new turns since your last reply:
7679
+
7680
+ ${turns}
7681
+ ${CLOSE_MARKER}
7682
+
7683
+ ${message}`;
7684
+ }
7662
7685
 
7663
7686
  // ../shared/src/onboarding-emails.ts
7664
7687
  var EMAIL_KEYS = [
@@ -8281,7 +8304,9 @@ export {
8281
8304
  MAX_REPO_FILE_CONTENT_BYTES,
8282
8305
  searchRepoFileIndex,
8283
8306
  isExcludedRepoFilePath,
8307
+ CHAT_FORK_EXCERPT_OMITTED_NOTICE,
8284
8308
  formatChatForkHandoffMessage,
8309
+ formatSideChatUpdateMessage,
8285
8310
  readJsonlPage,
8286
8311
  parseChatTranscriptArtifact,
8287
8312
  readSseStream,
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  monolithRequest
6
- } from "./chunk-KTWH5E6W.js";
6
+ } from "./chunk-3GJEQKPY.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-QZYXFGI7.js";
11
+ } from "./chunk-RVSMHQVH.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-HSG6K3WN.js";
7
- import "./chunk-KTWH5E6W.js";
6
+ } from "./chunk-SY46VC2H.js";
7
+ import "./chunk-3GJEQKPY.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-QZYXFGI7.js";
11
+ import "./chunk-RVSMHQVH.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/command-protection-hook.ts
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  AppServerProcess,
10
10
  buildCodexAgentEnv
11
- } from "./chunk-ASZVT3MJ.js";
11
+ } from "./chunk-BXHF65NV.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-QZYXFGI7.js";
16
+ } from "./chunk-RVSMHQVH.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
 
19
19
  // 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-HSG6K3WN.js";
30
+ } from "./chunk-SY46VC2H.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -52,7 +52,7 @@ import {
52
52
  } from "./chunk-FLDA7BX3.js";
53
53
  import {
54
54
  publishedPullRequestUrls
55
- } from "./chunk-LPVZD5CN.js";
55
+ } from "./chunk-RAZD4N5G.js";
56
56
  import {
57
57
  RELAY_MCP_TOOLS,
58
58
  RELAY_MCP_TOOL_NAMES,
@@ -74,7 +74,7 @@ import {
74
74
  refreshDelayMs,
75
75
  restartCodexAspHost,
76
76
  routineRefreshExclusions
77
- } from "./chunk-OBW7XFNZ.js";
77
+ } from "./chunk-5PTJWSW3.js";
78
78
  import {
79
79
  ENGINE_ENV,
80
80
  monolithRequest,
@@ -82,14 +82,14 @@ import {
82
82
  readRuntimeEnvFile,
83
83
  reloadEngineEnv,
84
84
  setAgentCredentialSnapshot
85
- } from "./chunk-KTWH5E6W.js";
85
+ } from "./chunk-3GJEQKPY.js";
86
86
  import {
87
87
  AspClient,
88
88
  SUBPROCESS_MAX_BUFFER,
89
89
  execAsync,
90
90
  execFileAsync,
91
91
  getCodexModelProvider
92
- } from "./chunk-ASZVT3MJ.js";
92
+ } from "./chunk-BXHF65NV.js";
93
93
  import {
94
94
  isRecord as isRecord2
95
95
  } from "./chunk-UZSNFLDQ.js";
@@ -105,6 +105,7 @@ import {
105
105
  ASTER_PROVIDER,
106
106
  AUTH_FALLBACK_EVENT_TYPE,
107
107
  AUTH_RETRY_STATUS_EVENT_TYPE,
108
+ CHAT_FORK_EXCERPT_OMITTED_NOTICE,
108
109
  CHAT_GOAL_EVENT_TYPE,
109
110
  CHAT_INTERRUPTED_EVENT_TYPE,
110
111
  CLAUDE_AUTH_ENV_KEYS,
@@ -230,6 +231,7 @@ import {
230
231
  fetchOpenCodeGoCatalog,
231
232
  forkChatRequestSchema,
232
233
  formatChatForkHandoffMessage,
234
+ formatSideChatUpdateMessage,
233
235
  getChatExecutionProvider,
234
236
  getChatHistoryPageSenders,
235
237
  getClaudeModelContextWindow,
@@ -317,7 +319,7 @@ import {
317
319
  workspaceCredentialProviderSchema,
318
320
  workspaceTokenRequestSchema,
319
321
  workspaceTokenResponseSchema
320
- } from "./chunk-QZYXFGI7.js";
322
+ } from "./chunk-RVSMHQVH.js";
321
323
  import {
322
324
  cloneMcpConfig,
323
325
  ensureCompatibilityImports,
@@ -10194,6 +10196,7 @@ var EnvironmentDetailsService = class {
10194
10196
  details.supportsChatForking = true;
10195
10197
  details.supportsChatForkMessage = true;
10196
10198
  details.supportsDeferredChatForking = true;
10199
+ details.supportsSideChats = true;
10197
10200
  details.supportsCredentialSwitching = true;
10198
10201
  details.supportsChatCredentials = true;
10199
10202
  details.agentCredentials = { ...ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS };
@@ -10990,7 +10993,7 @@ import { join as join35 } from "path";
10990
10993
  import { randomUUID as randomUUID11 } from "crypto";
10991
10994
 
10992
10995
  // ../shared/src/workspace-chat.ts
10993
- var WORKSPACE_CHATS_QUERY_SCHEMA_VERSION = 7;
10996
+ var WORKSPACE_CHATS_QUERY_SCHEMA_VERSION = 8;
10994
10997
  var WORKSPACE_CHATS_QUERY_ROOT = `workspace-chats:v${WORKSPACE_CHATS_QUERY_SCHEMA_VERSION}`;
10995
10998
  function isAcceptedUserMessage(event) {
10996
10999
  return getUserMessage(event) !== null && event.payload.source === ACCEPTED_USER_MESSAGE_SOURCE;
@@ -60414,6 +60417,7 @@ async function uploadEngineLog(input, timeoutMs) {
60414
60417
  }
60415
60418
 
60416
60419
  // src/services/chat/fork-handoff.ts
60420
+ import { createHash as createHash8 } from "crypto";
60417
60421
  import { mkdir as mkdir19, open as open3, writeFile as writeFile10 } from "fs/promises";
60418
60422
  import { join as join34 } from "path";
60419
60423
  var EXCERPT_MAX_CHARS = 24e3;
@@ -60449,6 +60453,19 @@ function tailBlocks(blocks, maxChars) {
60449
60453
  const excerpt = start < blocks.length ? blocks.slice(start).join("\n\n") : `\u2026${blocks.at(-1)?.slice(-maxChars) ?? ""}`;
60450
60454
  return { excerpt, truncated: start > 0 };
60451
60455
  }
60456
+ function hashTranscriptBlocks(blocks) {
60457
+ return blocks.map((block) => createHash8("sha1").update(block).digest("base64"));
60458
+ }
60459
+ function unseenTurnsExcerpt(seenHashes, blocks) {
60460
+ const hashes = hashTranscriptBlocks(blocks);
60461
+ let common = 0;
60462
+ while (common < seenHashes.length && common < blocks.length && seenHashes[common] === hashes[common]) common++;
60463
+ if (common === blocks.length) return null;
60464
+ const { excerpt, truncated } = tailBlocks(blocks.slice(common), EXCERPT_MAX_CHARS);
60465
+ return truncated ? `${CHAT_FORK_EXCERPT_OMITTED_NOTICE}
60466
+
60467
+ ${excerpt}` : excerpt;
60468
+ }
60452
60469
  async function buildForkHandoff(input) {
60453
60470
  const rawHistoryPath = join34(HISTORY_DIR_BY_PROVIDER[input.sourceProvider], `${input.sourceChatId}.jsonl`);
60454
60471
  const { content, truncated: sourceTruncated } = await readHistoryTail(rawHistoryPath, MAX_SANITIZED_SOURCE_BYTES);
@@ -60471,6 +60488,7 @@ async function buildForkHandoff(input) {
60471
60488
  excerpt,
60472
60489
  excerptTruncated: truncated,
60473
60490
  sourceTruncated,
60491
+ blocks,
60474
60492
  resumeRequest: unansweredRequest(blocks),
60475
60493
  transcriptPath,
60476
60494
  rawHistoryPath: input.turnLimit === void 0 ? rawHistoryPath : void 0
@@ -60610,6 +60628,7 @@ var ChatService = class {
60610
60628
  agentChatActivityTrackerService;
60611
60629
  agentTokenUsageTracker;
60612
60630
  chats = /* @__PURE__ */ new Map();
60631
+ sideChatSeenBlocks = /* @__PURE__ */ new Map();
60613
60632
  persistPromise = null;
60614
60633
  persistQueued = false;
60615
60634
  async initialize() {
@@ -60704,6 +60723,13 @@ var ChatService = class {
60704
60723
  throw new ChatNotFoundError(parentChatId);
60705
60724
  }
60706
60725
  const source = request.forkSourceChatId ? this.requireChat(request.forkSourceChatId) : void 0;
60726
+ if (request.sideChat) {
60727
+ for (const previous of this.chats.values()) {
60728
+ if (previous.persisted.parentChatId === parentChatId && previous.persisted.fork?.trigger === "side" && !previous.persisted.deletedAt) {
60729
+ await this.deleteChat(previous.persisted.id);
60730
+ }
60731
+ }
60732
+ }
60707
60733
  const persisted = {
60708
60734
  id: request.id ?? randomUUID11(),
60709
60735
  provider: request.provider,
@@ -60718,7 +60744,7 @@ var ChatService = class {
60718
60744
  displayName: request.title?.trim() || void 0,
60719
60745
  model: getChatExecutionProvider(source.persisted) === (relayBaseProvider ?? request.provider) ? source.persisted.model : void 0,
60720
60746
  pendingForkHandoff: true,
60721
- fork: createForkInfo(source.persisted, "manual", now)
60747
+ fork: createForkInfo(source.persisted, request.sideChat ? "side" : "manual", now)
60722
60748
  } : {}
60723
60749
  };
60724
60750
  const runtime = this.createRuntimeChat(persisted);
@@ -60838,10 +60864,12 @@ var ChatService = class {
60838
60864
  const previousAcceptance = chat.lastSendAcceptance;
60839
60865
  const accepting = (async () => {
60840
60866
  chat.acceptingMessages += 1;
60867
+ let seenBeforeSend;
60841
60868
  try {
60842
60869
  await previousAcceptance?.catch(() => {
60843
60870
  });
60844
- if (chat.persisted.pendingForkHandoff && chat.persisted.fork) {
60871
+ seenBeforeSend = this.sideChatSeenBlocks.get(chatId);
60872
+ if (chat.persisted.fork && (chat.persisted.pendingForkHandoff || chat.persisted.fork.trigger === "side")) {
60845
60873
  request = {
60846
60874
  ...request,
60847
60875
  message: await this.createForkHandoffMessage(chatId, {
@@ -60863,6 +60891,10 @@ var ChatService = class {
60863
60891
  result
60864
60892
  )
60865
60893
  );
60894
+ } catch (error) {
60895
+ if (seenBeforeSend) this.sideChatSeenBlocks.set(chatId, seenBeforeSend);
60896
+ else this.sideChatSeenBlocks.delete(chatId);
60897
+ throw error;
60866
60898
  } finally {
60867
60899
  chat.acceptingMessages -= 1;
60868
60900
  }
@@ -61273,7 +61305,12 @@ var ChatService = class {
61273
61305
  senders: await this.readSenders(options.source.chatId),
61274
61306
  turnLimit: options.turnLimit
61275
61307
  });
61276
- return formatChatForkHandoffMessage({ ...handoff, ...options });
61308
+ if (options.trigger !== "side") return formatChatForkHandoffMessage({ ...handoff, ...options });
61309
+ const seen = this.sideChatSeenBlocks.get(targetChatId);
61310
+ this.sideChatSeenBlocks.set(targetChatId, hashTranscriptBlocks(handoff.blocks));
61311
+ if (!seen) return formatChatForkHandoffMessage({ ...handoff, ...options });
61312
+ const unseen = unseenTurnsExcerpt(seen, handoff.blocks);
61313
+ return unseen ? formatSideChatUpdateMessage(options.source, unseen, options.message ?? "") : options.message ?? "";
61277
61314
  }
61278
61315
  async runFork(targetId, request, errorNotificationTargets) {
61279
61316
  const target = this.chats.get(targetId);
@@ -61333,7 +61370,7 @@ var ChatService = class {
61333
61370
  }
61334
61371
  async autoForkAfterQuota(chat, exhaustion) {
61335
61372
  const target = exhaustion.forkTo;
61336
- if (!target || chat.persisted.deletedAt) return false;
61373
+ if (!target || chat.persisted.deletedAt || chat.persisted.fork?.trigger === "side") return false;
61337
61374
  const alreadyForked = [...this.chats.values()].some((other) => other.persisted.fork?.trigger === "auto" && other.persisted.fork.source.chatId === chat.persisted.id && !other.persisted.deletedAt);
61338
61375
  if (alreadyForked) return false;
61339
61376
  const last = chat.lastSendRequest;
@@ -61790,7 +61827,7 @@ var ChatService = class {
61790
61827
  }
61791
61828
  const stillProcessing = processing || forked;
61792
61829
  this.publishTurnCompleted(chat, completedAt, stillProcessing);
61793
- await this.publishAgentTurnCompleteWebhook(chat, completedAt, stillProcessing);
61830
+ await this.publishAgentTurnCompleteWebhook(chat, completedAt, stillProcessing, forked ? null : exhaustion);
61794
61831
  this.notifyWorkspaceAgentIdle();
61795
61832
  }
61796
61833
  publishTurnCompleted(chat, completedAt, processing) {
@@ -61903,7 +61940,7 @@ var ChatService = class {
61903
61940
  } catch {
61904
61941
  }
61905
61942
  }
61906
- async publishAgentTurnCompleteWebhook(chat, completedAt, processing = false) {
61943
+ async publishAgentTurnCompleteWebhook(chat, completedAt, processing = false, quotaExhaustion = null) {
61907
61944
  const linearSessionId = ENGINE_ENV.REPLICAS_LINEAR_SESSION_ID;
61908
61945
  const errors = chat.persisted.parentChatId === null ? chat.lastTurnErrors : null;
61909
61946
  chat.lastTurnErrors = null;
@@ -61918,7 +61955,8 @@ var ChatService = class {
61918
61955
  processing,
61919
61956
  repoStatuses,
61920
61957
  ...errors?.length ? { errors } : {},
61921
- ...errors?.length && errorNotificationTargets.length > 0 ? { errorNotificationTargets } : {}
61958
+ ...(errors?.length || quotaExhaustion) && errorNotificationTargets.length > 0 ? { errorNotificationTargets } : {},
61959
+ ...quotaExhaustion ? { quotaExhaustion } : {}
61922
61960
  };
61923
61961
  await monolithService.sendEvent({ type: "agent_turn_complete", payload });
61924
61962
  } catch (error) {
@@ -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-LPVZD5CN.js";
6
+ } from "./chunk-RAZD4N5G.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-QZYXFGI7.js";
12
+ } from "./chunk-RVSMHQVH.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
  relaySubagentResponseSchema,
12
12
  spawnRelaySubagentRequestSchema,
13
13
  waitRelaySubagentRequestSchema
14
- } from "./chunk-QZYXFGI7.js";
14
+ } from "./chunk-RVSMHQVH.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/relay-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.931",
3
+ "version": "0.1.933",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",