replicas-engine 0.1.897 → 0.1.898

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-BB62GNVH.js";
9
- import "./chunk-P34LDLQX.js";
10
- import "./chunk-IVBKWUL3.js";
8
+ } from "./chunk-DFMMOCJL.js";
9
+ import "./chunk-FJATNWKV.js";
10
+ import "./chunk-SDKQ6OMN.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-LNW62HPO.js";
12
+ import "./chunk-TXJVZXLN.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -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-P34LDLQX.js";
6
+ } from "./chunk-FJATNWKV.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-LNW62HPO.js";
11
+ } from "./chunk-TXJVZXLN.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-P34LDLQX.js";
8
+ } from "./chunk-FJATNWKV.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-IVBKWUL3.js";
14
+ } from "./chunk-SDKQ6OMN.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-LNW62HPO.js";
28
+ } from "./chunk-TXJVZXLN.js";
29
29
 
30
30
  // src/managers/codex-token-manager.ts
31
31
  import { promises as fs } from "fs";
@@ -255,7 +255,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
255
255
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
256
256
  await this.applyCredentialsResponse(data);
257
257
  if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
258
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ZTKJ55VS.js");
258
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-6PC24I7Z.js");
259
259
  await restartCodexAspHostIfRunning2();
260
260
  });
261
261
  await this.start(true);
@@ -275,7 +275,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
275
275
  await this.applyCredentialUpdate(generation, async () => {
276
276
  await this.applyCredentialsResponse(data);
277
277
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
278
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-ZTKJ55VS.js");
278
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-6PC24I7Z.js");
279
279
  await restartCodexAspHostIfRunning2();
280
280
  }
281
281
  if (data.scope) {
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-LNW62HPO.js";
18
+ } from "./chunk-TXJVZXLN.js";
19
19
 
20
20
  // src/engine-env.ts
21
21
  import { readFileSync as readFileSync2 } from "fs";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-LNW62HPO.js";
8
+ } from "./chunk-TXJVZXLN.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -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-LNW62HPO.js";
7
+ } from "./chunk-TXJVZXLN.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.897";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.898";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -1150,6 +1150,7 @@ var createChatRequestSchema = z3.object({
1150
1150
  relayBaseProvider: z3.enum(VALID_CODING_AGENT_PROVIDERS).optional(),
1151
1151
  title: z3.string().min(1).optional(),
1152
1152
  parentChatId: z3.string().uuid().optional(),
1153
+ forkSourceChatId: z3.string().uuid().optional(),
1153
1154
  clientRequestId: z3.string().min(1).max(128).optional()
1154
1155
  }).refine((request) => request.provider === "relay" || request.relayBaseProvider === void 0, {
1155
1156
  message: "relayBaseProvider is only valid for Relay chats"
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-AAGTCVUR.js";
6
+ } from "./chunk-HROMYATU.js";
7
7
  import {
8
8
  shouldRefreshPullRequests
9
- } from "./chunk-LNW62HPO.js";
9
+ } from "./chunk-TXJVZXLN.js";
10
10
 
11
11
  // src/services/post-tool-pr-notifier.ts
12
12
  async function notifyPostToolUse(toolName, toolInput, result) {
@@ -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-2OAEXQII.js";
7
- import "./chunk-P34LDLQX.js";
6
+ } from "./chunk-6NEE6737.js";
7
+ import "./chunk-FJATNWKV.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-LNW62HPO.js";
11
+ import "./chunk-TXJVZXLN.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/command-protection-hook.ts
@@ -3,14 +3,14 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-2OAEXQII.js";
6
+ } from "./chunk-6NEE6737.js";
7
7
  import {
8
8
  notifyPostToolUse
9
- } from "./chunk-O7VJSBSX.js";
10
- import "./chunk-AAGTCVUR.js";
11
- import "./chunk-P34LDLQX.js";
9
+ } from "./chunk-USA3ABPA.js";
10
+ import "./chunk-HROMYATU.js";
11
+ import "./chunk-FJATNWKV.js";
12
12
  import "./chunk-UZSNFLDQ.js";
13
- import "./chunk-LNW62HPO.js";
13
+ import "./chunk-TXJVZXLN.js";
14
14
  import "./chunk-VEQXQN22.js";
15
15
 
16
16
  // src/deepseek-command-protection-plugin.ts
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  AppServerProcess,
10
10
  buildCodexAgentEnv
11
- } from "./chunk-IVBKWUL3.js";
11
+ } from "./chunk-SDKQ6OMN.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-LNW62HPO.js";
16
+ } from "./chunk-TXJVZXLN.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
 
19
19
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -91,7 +91,7 @@ import {
91
91
  evaluateCommandProtection,
92
92
  extractToolCommand,
93
93
  reportCommandProtectionBlock
94
- } from "./chunk-2OAEXQII.js";
94
+ } from "./chunk-6NEE6737.js";
95
95
  import {
96
96
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
97
97
  AGENT_MESSAGE_DELTA_METHOD,
@@ -116,7 +116,7 @@ import {
116
116
  } from "./chunk-FLDA7BX3.js";
117
117
  import {
118
118
  publishedPullRequestUrls
119
- } from "./chunk-AAGTCVUR.js";
119
+ } from "./chunk-HROMYATU.js";
120
120
  import {
121
121
  RELAY_MCP_TOOLS,
122
122
  RELAY_MCP_TOOL_NAMES,
@@ -137,21 +137,21 @@ import {
137
137
  refreshDelayMs,
138
138
  restartCodexAspHost,
139
139
  routineRefreshExclusions
140
- } from "./chunk-BB62GNVH.js";
140
+ } from "./chunk-DFMMOCJL.js";
141
141
  import {
142
142
  ENGINE_ENV,
143
143
  IS_WARMING_MODE,
144
144
  monolithRequest,
145
145
  monolithService,
146
146
  setAgentCredentialSnapshot
147
- } from "./chunk-P34LDLQX.js";
147
+ } from "./chunk-FJATNWKV.js";
148
148
  import {
149
149
  AspClient,
150
150
  SUBPROCESS_MAX_BUFFER,
151
151
  execAsync,
152
152
  execFileAsync,
153
153
  getCodexModelProvider
154
- } from "./chunk-IVBKWUL3.js";
154
+ } from "./chunk-SDKQ6OMN.js";
155
155
  import {
156
156
  isRecord as isRecord2
157
157
  } from "./chunk-UZSNFLDQ.js";
@@ -378,7 +378,7 @@ import {
378
378
  workspaceCredentialProviderSchema,
379
379
  workspaceTokenRequestSchema,
380
380
  workspaceTokenResponseSchema
381
- } from "./chunk-LNW62HPO.js";
381
+ } from "./chunk-TXJVZXLN.js";
382
382
  import {
383
383
  __commonJS,
384
384
  __export,
@@ -10144,6 +10144,7 @@ var EnvironmentDetailsService = class {
10144
10144
  details.supportsQueuedMessageEditing = true;
10145
10145
  details.supportsChatForking = true;
10146
10146
  details.supportsChatForkMessage = true;
10147
+ details.supportsDeferredChatForking = true;
10147
10148
  details.supportsCredentialSwitching = true;
10148
10149
  details.agentCredentials = { ...ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS };
10149
10150
  details.claudeAuthMethod = detectAgentAuthMethod(AGENT.CLAUDE);
@@ -61508,6 +61509,15 @@ async function resolveRelayBaseProvider(provider, requested) {
61508
61509
  if (provider !== "relay") return null;
61509
61510
  return requested ?? (await monolithService.getRelayConfig())?.baseProvider ?? (!ENGINE_ENV.REPLICAS_WORKSPACE_ID ? DEFAULT_RELAY_BASE_PROVIDER : null);
61510
61511
  }
61512
+ function createForkInfo(source, trigger, startedAt, reason) {
61513
+ return {
61514
+ source: { chatId: source.id, provider: source.provider, title: source.title },
61515
+ trigger,
61516
+ ...reason ? { reason } : {},
61517
+ state: "preparing",
61518
+ startedAt
61519
+ };
61520
+ }
61511
61521
  function isForkPreparing(chat) {
61512
61522
  return chat.persisted.fork?.state === "preparing";
61513
61523
  }
@@ -61540,6 +61550,7 @@ function normalizePersistedChat(chat) {
61540
61550
  lastMessageText: chat.lastMessageText ?? null,
61541
61551
  deletedAt: chat.deletedAt ?? null,
61542
61552
  fork: coerceChatForkInfo(chat.fork),
61553
+ pendingForkHandoff: chat.pendingForkHandoff === true,
61543
61554
  removedMessageIds: Array.isArray(chat.removedMessageIds) ? chat.removedMessageIds.filter((id) => typeof id === "string").slice(-MAX_REMOVED_MESSAGE_IDS) : [],
61544
61555
  acceptedSendResponses: isRecord2(chat.acceptedSendResponses) ? Object.fromEntries(Object.entries(chat.acceptedSendResponses).filter((entry) => {
61545
61556
  const response = entry[1];
@@ -61642,6 +61653,7 @@ var ChatService = class {
61642
61653
  if (request.id) {
61643
61654
  const existing = this.chats.get(request.id);
61644
61655
  if (existing && !existing.persisted.deletedAt) {
61656
+ if (request.forkSourceChatId && existing.persisted.fork) return this.toSummary(existing);
61645
61657
  if (existing.persisted.provider !== request.provider || request.provider === "relay" && getChatExecutionProvider(existing.persisted) !== relayBaseProvider) {
61646
61658
  throw new Error(`Chat ${request.id} already exists with a different provider`);
61647
61659
  }
@@ -61662,6 +61674,7 @@ var ChatService = class {
61662
61674
  if (parentChatId && !this.chats.has(parentChatId)) {
61663
61675
  throw new ChatNotFoundError(parentChatId);
61664
61676
  }
61677
+ const source = request.forkSourceChatId ? this.requireChat(request.forkSourceChatId) : void 0;
61665
61678
  const persisted = {
61666
61679
  id: request.id ?? randomUUID13(),
61667
61680
  provider: request.provider,
@@ -61671,7 +61684,13 @@ var ChatService = class {
61671
61684
  updatedAt: now,
61672
61685
  providerSessionId: null,
61673
61686
  parentChatId,
61674
- fork: request.fork ?? null
61687
+ fork: request.fork ?? null,
61688
+ ...source ? {
61689
+ displayName: request.title?.trim() || void 0,
61690
+ model: getChatExecutionProvider(source.persisted) === (relayBaseProvider ?? request.provider) ? source.persisted.model : void 0,
61691
+ pendingForkHandoff: true,
61692
+ fork: createForkInfo(source.persisted, "manual", now)
61693
+ } : {}
61675
61694
  };
61676
61695
  const runtime = this.createRuntimeChat(persisted);
61677
61696
  this.chats.set(persisted.id, runtime);
@@ -61793,6 +61812,16 @@ var ChatService = class {
61793
61812
  try {
61794
61813
  await previousAcceptance?.catch(() => {
61795
61814
  });
61815
+ if (chat.persisted.pendingForkHandoff && chat.persisted.fork) {
61816
+ request = {
61817
+ ...request,
61818
+ message: await this.createForkHandoffMessage(chatId, {
61819
+ source: chat.persisted.fork.source,
61820
+ trigger: chat.persisted.fork.trigger,
61821
+ message: request.message
61822
+ })
61823
+ };
61824
+ }
61796
61825
  const savedModel = chat.persisted.model ?? (!request.model ? extractLatestContextUsage((await chat.provider.getHistory()).events, getChatExecutionProvider(chat.persisted))?.model : void 0);
61797
61826
  request = { ...request, model: request.model ?? savedModel ?? void 0 };
61798
61827
  return await chat.provider.enqueueMessage(
@@ -61839,6 +61868,8 @@ var ChatService = class {
61839
61868
  const previousLastMessageText = chat.persisted.lastMessageText;
61840
61869
  const previousModel = chat.persisted.model;
61841
61870
  const previousUpdatedAt = chat.persisted.updatedAt;
61871
+ const previousFork = chat.persisted.fork;
61872
+ const previousPendingForkHandoff = chat.persisted.pendingForkHandoff;
61842
61873
  const idempotencyKey = request.idempotencyKey ?? request.messageId;
61843
61874
  if (idempotencyKey) {
61844
61875
  chat.acceptedSendResponses.set(idempotencyKey, result);
@@ -61857,6 +61888,10 @@ var ChatService = class {
61857
61888
  chat.persisted.lastMessageText = request.message.trim().slice(0, LAST_MESSAGE_PREVIEW_MAX) || null;
61858
61889
  chat.persisted.model = acceptedMessage.model ?? previousModel;
61859
61890
  chat.persisted.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
61891
+ if (chat.persisted.pendingForkHandoff && chat.persisted.fork) {
61892
+ chat.persisted.pendingForkHandoff = false;
61893
+ chat.persisted.fork = { ...chat.persisted.fork, state: "ready", completedAt: chat.persisted.updatedAt };
61894
+ }
61860
61895
  try {
61861
61896
  await this.persistAllChats();
61862
61897
  } catch (error) {
@@ -61871,6 +61906,8 @@ var ChatService = class {
61871
61906
  chat.persisted.lastMessageText = previousLastMessageText;
61872
61907
  chat.persisted.model = previousModel;
61873
61908
  chat.persisted.updatedAt = previousUpdatedAt;
61909
+ chat.persisted.fork = previousFork;
61910
+ chat.persisted.pendingForkHandoff = previousPendingForkHandoff;
61874
61911
  throw new ChatMessagePersistenceError(error);
61875
61912
  }
61876
61913
  chat.lastSendRequest = request;
@@ -61902,7 +61939,7 @@ var ChatService = class {
61902
61939
  }).catch((error) => {
61903
61940
  console.error("[ChatService] Failed to publish accepted turn:", { chatId, messageId: result.messageId, error });
61904
61941
  });
61905
- if (chat.persisted.model !== previousModel) {
61942
+ if (chat.persisted.model !== previousModel || previousPendingForkHandoff) {
61906
61943
  await this.publish({ type: "chat.updated", payload: { chat: this.toSummary(chat) } }).catch((error) => {
61907
61944
  console.error("[ChatService] Failed to publish accepted chat update:", { chatId, error });
61908
61945
  });
@@ -62207,20 +62244,13 @@ var ChatService = class {
62207
62244
  if (trigger === "manual" && (!executionProvider || !isAgentAvailable(executionProvider))) {
62208
62245
  throw new ChatProviderUnavailableError(request.provider);
62209
62246
  }
62210
- const fork = {
62211
- source: { chatId: source.persisted.id, provider: source.persisted.provider, title: source.persisted.title },
62212
- trigger,
62213
- ...reason ? { reason } : {},
62214
- state: "preparing",
62215
- startedAt: (/* @__PURE__ */ new Date()).toISOString()
62216
- };
62217
62247
  return this.createChat({
62218
62248
  id: request.id,
62219
62249
  provider: request.provider,
62220
62250
  ...relayBaseProvider ? { relayBaseProvider } : {},
62221
62251
  title: request.title?.trim() || defaultForkChatTitle(source.persisted, request.provider),
62222
62252
  clientRequestId: request.clientRequestId,
62223
- fork
62253
+ fork: createForkInfo(source.persisted, trigger, (/* @__PURE__ */ new Date()).toISOString(), reason)
62224
62254
  });
62225
62255
  }
62226
62256
  async createForkHandoffMessage(targetChatId, options) {
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  notifyPostToolUse
6
- } from "./chunk-O7VJSBSX.js";
7
- import "./chunk-AAGTCVUR.js";
6
+ } from "./chunk-USA3ABPA.js";
7
+ import "./chunk-HROMYATU.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-LNW62HPO.js";
11
+ import "./chunk-TXJVZXLN.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/post-tool-pr-hook.ts
@@ -11,7 +11,7 @@ import {
11
11
  relaySubagentResponseSchema,
12
12
  spawnRelaySubagentRequestSchema,
13
13
  waitRelaySubagentRequestSchema
14
- } from "./chunk-LNW62HPO.js";
14
+ } from "./chunk-TXJVZXLN.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.897",
3
+ "version": "0.1.898",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",