replicas-engine 0.1.925 → 0.1.926

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-ARAD76EY.js";
9
- import "./chunk-Y3ZAG37O.js";
10
- import "./chunk-JLRNRGG3.js";
8
+ } from "./chunk-2TUMNESB.js";
9
+ import "./chunk-IJXBOFTY.js";
10
+ import "./chunk-QQ2ENBZT.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-RLBC7EZ4.js";
12
+ import "./chunk-O7V7LVOY.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-Y3ZAG37O.js";
8
+ } from "./chunk-IJXBOFTY.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-JLRNRGG3.js";
14
+ } from "./chunk-QQ2ENBZT.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-RLBC7EZ4.js";
28
+ } from "./chunk-O7V7LVOY.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-7Q4EG2HV.js");
261
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-DQEMHOBE.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-7Q4EG2HV.js");
281
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-DQEMHOBE.js");
282
282
  await restartCodexAspHostIfRunning2();
283
283
  }
284
284
  setAgentCredentialSnapshot("codex", data);
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-RLBC7EZ4.js";
8
+ } from "./chunk-O7V7LVOY.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-RLBC7EZ4.js";
18
+ } from "./chunk-O7V7LVOY.js";
19
19
 
20
20
  // src/runtime-env-loader.ts
21
21
  import { readFileSync } from "fs";
@@ -1914,7 +1914,11 @@ var fallbackHarnessStepSchema = z7.object({
1914
1914
  thinkingLevel: z7.enum(VALID_THINKING_LEVELS).optional()
1915
1915
  });
1916
1916
  var fallbackPlanStepSchema = z7.discriminatedUnion("kind", [
1917
- z7.object({ kind: z7.literal("credentials"), methods: z7.array(z7.custom(isAuthMethod)).min(1) }),
1917
+ z7.object({
1918
+ kind: z7.literal("credentials"),
1919
+ methods: z7.array(z7.custom(isAuthMethod)).min(1),
1920
+ models: z7.record(z7.string(), z7.string().min(1)).optional()
1921
+ }),
1918
1922
  fallbackHarnessStepSchema
1919
1923
  ]);
1920
1924
  var fallbackPlanResponseSchema = z7.object({ steps: z7.array(fallbackPlanStepSchema) });
@@ -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-RLBC7EZ4.js";
7
+ } from "./chunk-O7V7LVOY.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.925";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.926";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -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-Y3ZAG37O.js";
6
+ } from "./chunk-IJXBOFTY.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-RLBC7EZ4.js";
11
+ } from "./chunk-O7V7LVOY.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-P56H3PGY.js";
7
- import "./chunk-Y3ZAG37O.js";
6
+ } from "./chunk-YVIDUOHO.js";
7
+ import "./chunk-IJXBOFTY.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-RLBC7EZ4.js";
11
+ import "./chunk-O7V7LVOY.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-JLRNRGG3.js";
11
+ } from "./chunk-QQ2ENBZT.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-RLBC7EZ4.js";
16
+ } from "./chunk-O7V7LVOY.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-P56H3PGY.js";
30
+ } from "./chunk-YVIDUOHO.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-4Q7E2QOZ.js";
55
+ } from "./chunk-HT56CL2D.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-ARAD76EY.js";
77
+ } from "./chunk-2TUMNESB.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-Y3ZAG37O.js";
85
+ } from "./chunk-IJXBOFTY.js";
86
86
  import {
87
87
  AspClient,
88
88
  SUBPROCESS_MAX_BUFFER,
89
89
  execAsync,
90
90
  execFileAsync,
91
91
  getCodexModelProvider
92
- } from "./chunk-JLRNRGG3.js";
92
+ } from "./chunk-QQ2ENBZT.js";
93
93
  import {
94
94
  isRecord as isRecord2
95
95
  } from "./chunk-UZSNFLDQ.js";
@@ -316,7 +316,7 @@ import {
316
316
  workspaceCredentialProviderSchema,
317
317
  workspaceTokenRequestSchema,
318
318
  workspaceTokenResponseSchema
319
- } from "./chunk-RLBC7EZ4.js";
319
+ } from "./chunk-O7V7LVOY.js";
320
320
  import {
321
321
  cloneMcpConfig,
322
322
  ensureCompatibilityImports,
@@ -11745,7 +11745,8 @@ var AuthFallbackCoordinator = class {
11745
11745
  continue;
11746
11746
  }
11747
11747
  this.recordNotice(reason, exhausted, applied, "switched", detail, !chatCredentials);
11748
- return { outcome: "switched" };
11748
+ const model = step.models?.[applied.method];
11749
+ return { outcome: "switched", ...model ? { model } : {} };
11749
11750
  }
11750
11751
  if (!tokenManager || !exhausted) return { outcome: "unavailable" };
11751
11752
  if (!failed) return { outcome: "not_configured" };
@@ -11999,6 +12000,7 @@ var CodingAgentManager = class {
11999
12000
  hostOnTurnComplete;
12000
12001
  onProcessingChanged;
12001
12002
  onMessageStarted;
12003
+ onModelSwitched;
12002
12004
  authFallback;
12003
12005
  additionalInstructions;
12004
12006
  compacting = false;
@@ -12018,6 +12020,8 @@ var CodingAgentManager = class {
12018
12020
  });
12019
12021
  this.onMessageStarted = options.onMessageStarted ?? (async () => {
12020
12022
  });
12023
+ this.onModelSwitched = options.onModelSwitched ?? (async () => {
12024
+ });
12021
12025
  this.authFallback = options.provider ? new AuthFallbackCoordinator(options.provider, (event) => {
12022
12026
  this.onEvent(event);
12023
12027
  this.getHistorySink()?.append(event);
@@ -12025,7 +12029,9 @@ var CodingAgentManager = class {
12025
12029
  }
12026
12030
  async fallBackCredential(reason, detail, chatCredentials) {
12027
12031
  if (!this.authFallback) return { outcome: "unavailable" };
12028
- return this.authFallback.fallBack(reason, detail, chatCredentials);
12032
+ const result = await this.authFallback.fallBack(reason, detail, chatCredentials);
12033
+ if (result.outcome === "switched" && result.model) await this.onModelSwitched(result.model);
12034
+ return result;
12029
12035
  }
12030
12036
  onTurnComplete = async () => {
12031
12037
  if (this.compacting) {
@@ -13649,6 +13655,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13649
13655
  const detail = error instanceof ClaudeQuotaError ? error.message : extractErrorText(error);
13650
13656
  const fallback = quotaFallbacks < MAX_QUOTA_FALLBACKS ? await this.fallBackCredential(quotaKind, detail, this.turnCredentials ?? void 0) : { outcome: "unavailable" };
13651
13657
  if (fallback.outcome === "switched") {
13658
+ if (fallback.model) currentRequest = { ...currentRequest, model: fallback.model };
13652
13659
  quotaFallbacks++;
13653
13660
  await this.tearDownSession();
13654
13661
  attempt++;
@@ -15552,6 +15559,7 @@ var CodexAspManager = class extends CodingAgentManager {
15552
15559
  terminalError.message
15553
15560
  );
15554
15561
  if (fallback.outcome === "switched") {
15562
+ if (fallback.model) request = { ...request, model: fallback.model };
15555
15563
  attemptedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex;
15556
15564
  const retryFailure = await this.restartAndRetry(dispatch);
15557
15565
  if (!retryFailure) return;
@@ -61490,6 +61498,15 @@ var ChatService = class {
61490
61498
  forkable: (chat?.persisted ?? persisted).parentChatId === null
61491
61499
  };
61492
61500
  };
61501
+ const onModelSwitched = async (model) => {
61502
+ const chat = this.chats.get(persisted.id);
61503
+ if (!chat || chat.persisted.model === model) return;
61504
+ chat.persisted.model = model;
61505
+ await this.persistAllChats();
61506
+ await this.publish({ type: "chat.updated", payload: { chat: this.toSummary(chat) } }).catch((error) => {
61507
+ console.error("[ChatService] Failed to publish switched chat model:", { chatId: persisted.id, error });
61508
+ });
61509
+ };
61493
61510
  if (persisted.parentChatId === void 0) {
61494
61511
  persisted.parentChatId = null;
61495
61512
  }
@@ -61509,6 +61526,7 @@ var ChatService = class {
61509
61526
  onUsageUpdate: onProviderUsage,
61510
61527
  fallbackContext,
61511
61528
  chatId: persisted.id,
61529
+ onModelSwitched,
61512
61530
  additionalInstructions,
61513
61531
  linearSessionId: persisted.parentChatId === null ? ENGINE_ENV.REPLICAS_LINEAR_SESSION_ID : void 0,
61514
61532
  ...persisted.provider === "relay" ? { relayParentChatId: persisted.id } : {}
@@ -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-4Q7E2QOZ.js";
6
+ } from "./chunk-HT56CL2D.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-RLBC7EZ4.js";
12
+ } from "./chunk-O7V7LVOY.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-RLBC7EZ4.js";
14
+ } from "./chunk-O7V7LVOY.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.925",
3
+ "version": "0.1.926",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",