replicas-engine 0.1.1577 → 0.1.1579

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
  listCodexModelsForDetails,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-KVU36YTE.js";
12
- import "./chunk-MIMEP2M4.js";
13
- import "./chunk-M5VTBOCO.js";
14
- import "./chunk-VUQFJXAV.js";
11
+ } from "./chunk-5VCKFH2P.js";
12
+ import "./chunk-UPPPY2ZE.js";
13
+ import "./chunk-N2L2AOYB.js";
14
+ import "./chunk-WJG3HGWB.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
- import "./chunk-66OYINQO.js";
16
+ import "./chunk-7NLNGNK3.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
  export {
19
19
  CODEX_ULTRAFAST_SERVICE_TIER,
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-66OYINQO.js";
8
+ } from "./chunk-7NLNGNK3.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -12,15 +12,15 @@ import {
12
12
  resolveDiffBase,
13
13
  runGitCommand,
14
14
  setAgentCredentialSnapshot
15
- } from "./chunk-MIMEP2M4.js";
15
+ } from "./chunk-UPPPY2ZE.js";
16
16
  import {
17
17
  AppServerProcess,
18
18
  buildCodexAgentEnv
19
- } from "./chunk-M5VTBOCO.js";
19
+ } from "./chunk-N2L2AOYB.js";
20
20
  import {
21
21
  SUBPROCESS_MAX_BUFFER,
22
22
  execFileAsync
23
- } from "./chunk-VUQFJXAV.js";
23
+ } from "./chunk-WJG3HGWB.js";
24
24
  import {
25
25
  isRecord
26
26
  } from "./chunk-UZSNFLDQ.js";
@@ -61,7 +61,7 @@ import {
61
61
  shrunkImageSize,
62
62
  splitMothershipInstructions,
63
63
  withTimeout
64
- } from "./chunk-66OYINQO.js";
64
+ } from "./chunk-7NLNGNK3.js";
65
65
 
66
66
  // src/managers/codex-token-manager.ts
67
67
  import { promises as fs } from "fs";
@@ -123,9 +123,13 @@ function routineRefreshRequest(provider) {
123
123
  ...live ? { currentCredential: live } : {}
124
124
  };
125
125
  }
126
+ var exhaustedKey = (credential) => `${credential.method}|${credential.scope}|${credential.credentialId ?? ""}`;
127
+ function forgetExhaustedCredentials(provider, credentials) {
128
+ for (const credential of credentials) exhaustedByAgent.get(provider)?.delete(exhaustedKey(credential));
129
+ }
126
130
  function recordExhaustedCredential(provider, credential, resetsAt) {
127
131
  const spent = exhaustedByAgent.get(provider) ?? /* @__PURE__ */ new Map();
128
- spent.set(`${credential.method}|${credential.scope}|${credential.credentialId ?? ""}`, {
132
+ spent.set(exhaustedKey(credential), {
129
133
  credential,
130
134
  until: exhaustedUntil(resetsAt).getTime()
131
135
  });
@@ -457,7 +461,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
457
461
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
458
462
  await this.applyCredentialsResponse(data);
459
463
  setAgentCredentialSnapshot("codex", data);
460
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-3UP6FBHK.js");
464
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-VM2QTYX2.js");
461
465
  await restartCodexAspHostIfRunning2();
462
466
  });
463
467
  await this.start(true);
@@ -479,7 +483,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
479
483
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
480
484
  await this.applyCredentialsResponse(data);
481
485
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
482
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-3UP6FBHK.js");
486
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-VM2QTYX2.js");
483
487
  await restartCodexAspHostIfRunning2();
484
488
  }
485
489
  setAgentCredentialSnapshot("codex", data);
@@ -2278,6 +2282,7 @@ export {
2278
2282
  recordCredentialFallback,
2279
2283
  listCredentialFallbacks,
2280
2284
  routineRefreshRequest,
2285
+ forgetExhaustedCredentials,
2281
2286
  recordExhaustedCredential,
2282
2287
  refreshDelayMs,
2283
2288
  BaseRefreshManager,
@@ -9535,6 +9535,7 @@ var linearIssueFiltersSchema = z3.object({
9535
9535
  var LINEAR_STATE_TYPES = LINEAR_WORKFLOW_STATE_TYPES.filter((type) => type !== "duplicate");
9536
9536
 
9537
9537
  // ../shared/src/routes/mothership.ts
9538
+ var setUpMothershipTextingRequestSchema = z4.object({ line: z4.string().optional() });
9538
9539
  var linearRuleFields = linearIssueFiltersSchema.extend({ team_id: z4.string().min(1) }).strict();
9539
9540
  var withLabelIds = (value) => {
9540
9541
  if (!isRecord(value) || typeof value.label_id !== "string") return value;
@@ -9839,16 +9840,6 @@ var CLAUDE_SONNET_5_5_MODEL = "claude-sonnet-5-5";
9839
9840
  var CLAUDE_SONNET_5_MODEL = "claude-sonnet-5";
9840
9841
  var CLAUDE_HAIKU_5_5_MODEL = "claude-haiku-5-5";
9841
9842
  var CLAUDE_HAIKU_4_5_MODEL = "claude-haiku-4-5";
9842
- var CLAUDE_FABLE_5_2_BEDROCK_MODEL = "anthropic.claude-fable-5-2";
9843
- var CLAUDE_FABLE_5_1_BEDROCK_MODEL = "anthropic.claude-fable-5-1";
9844
- var CLAUDE_FABLE_5_BEDROCK_MODEL = "anthropic.claude-fable-5";
9845
- var CLAUDE_OPUS_5_5_BEDROCK_MODEL = "anthropic.claude-opus-5-5";
9846
- var CLAUDE_OPUS_5_BEDROCK_MODEL = "anthropic.claude-opus-5";
9847
- var CLAUDE_OPUS_4_8_BEDROCK_MODEL = "us.anthropic.claude-opus-4-8";
9848
- var CLAUDE_SONNET_5_5_BEDROCK_MODEL = "anthropic.claude-sonnet-5-5";
9849
- var CLAUDE_SONNET_5_BEDROCK_MODEL = "anthropic.claude-sonnet-5";
9850
- var CLAUDE_HAIKU_5_5_BEDROCK_MODEL = "anthropic.claude-haiku-5-5";
9851
- var CLAUDE_HAIKU_4_5_BEDROCK_MODEL = "us.anthropic.claude-haiku-4-5-20251001-v1:0";
9852
9843
  var DEFAULT_CLAUDE_MODEL = CLAUDE_OPUS_5_5_MODEL;
9853
9844
  var GPT_6_ASTRA_MODEL = "gpt-6-astra";
9854
9845
  var GPT_6_1_SOL_MODEL = "gpt-6.1-sol";
@@ -9911,35 +9902,6 @@ function normalizeClaudeModel(model2) {
9911
9902
  }
9912
9903
  return model2;
9913
9904
  }
9914
- function toClaudeCodeModel(model2, bedrock) {
9915
- if (!bedrock) {
9916
- return model2;
9917
- }
9918
- switch (normalizeClaudeModel(model2)) {
9919
- case CLAUDE_FABLE_5_2_MODEL:
9920
- return CLAUDE_FABLE_5_2_BEDROCK_MODEL;
9921
- case CLAUDE_FABLE_5_1_MODEL:
9922
- return CLAUDE_FABLE_5_1_BEDROCK_MODEL;
9923
- case CLAUDE_FABLE_5_MODEL:
9924
- return CLAUDE_FABLE_5_BEDROCK_MODEL;
9925
- case CLAUDE_OPUS_5_5_MODEL:
9926
- return CLAUDE_OPUS_5_5_BEDROCK_MODEL;
9927
- case CLAUDE_OPUS_5_MODEL:
9928
- return CLAUDE_OPUS_5_BEDROCK_MODEL;
9929
- case CLAUDE_OPUS_4_8_MODEL:
9930
- return "opus";
9931
- case CLAUDE_SONNET_5_5_MODEL:
9932
- return CLAUDE_SONNET_5_5_BEDROCK_MODEL;
9933
- case CLAUDE_SONNET_5_MODEL:
9934
- return "sonnet";
9935
- case CLAUDE_HAIKU_5_5_MODEL:
9936
- return CLAUDE_HAIKU_5_5_BEDROCK_MODEL;
9937
- case CLAUDE_HAIKU_4_5_MODEL:
9938
- return "haiku";
9939
- default:
9940
- return model2;
9941
- }
9942
- }
9943
9905
  var CLAUDE_MODEL_CONTEXT_WINDOWS = {
9944
9906
  [CLAUDE_FABLE_5_2_MODEL]: 1e6,
9945
9907
  [CLAUDE_FABLE_5_1_MODEL]: 1e6,
@@ -9951,26 +9913,14 @@ var CLAUDE_MODEL_CONTEXT_WINDOWS = {
9951
9913
  [CLAUDE_SONNET_5_MODEL]: 1e6,
9952
9914
  [CLAUDE_HAIKU_5_5_MODEL]: 1e6,
9953
9915
  [CLAUDE_HAIKU_4_5_MODEL]: 2e5,
9954
- [CLAUDE_FABLE_5_2_BEDROCK_MODEL]: 1e6,
9955
- [CLAUDE_FABLE_5_1_BEDROCK_MODEL]: 1e6,
9956
- [CLAUDE_FABLE_5_BEDROCK_MODEL]: 1e6,
9957
- [CLAUDE_OPUS_5_5_BEDROCK_MODEL]: 1e6,
9958
- [CLAUDE_OPUS_5_BEDROCK_MODEL]: 1e6,
9959
- [CLAUDE_OPUS_4_8_BEDROCK_MODEL]: 1e6,
9960
- [CLAUDE_SONNET_5_5_BEDROCK_MODEL]: 1e6,
9961
- [CLAUDE_SONNET_5_BEDROCK_MODEL]: 1e6,
9962
- [CLAUDE_HAIKU_5_5_BEDROCK_MODEL]: 1e6,
9963
- [CLAUDE_HAIKU_4_5_BEDROCK_MODEL]: 2e5,
9964
- "anthropic.claude-opus-4-8": 1e6,
9965
- "us.anthropic.claude-sonnet-5": 1e6,
9966
- "anthropic.claude-haiku-4-5": 2e5,
9967
9916
  "claude-haiku-4-5-20251001": 2e5,
9968
9917
  "claude-haiku-4-5@20251001": 2e5
9969
9918
  };
9970
9919
  function getClaudeModelContextWindow(model2) {
9971
9920
  if (!model2) return null;
9972
- const normalized = normalizeClaudeModel(model2) ?? model2;
9973
- return CLAUDE_MODEL_CONTEXT_WINDOWS[normalized] ?? CLAUDE_MODEL_CONTEXT_WINDOWS[model2] ?? null;
9921
+ const firstParty = model2.replace(/^(?:[a-z-]+\.)?anthropic\./, "").replace(/-v\d+(?::\d+)?$/, "");
9922
+ const normalized = normalizeClaudeModel(firstParty) ?? firstParty;
9923
+ return CLAUDE_MODEL_CONTEXT_WINDOWS[normalized] ?? CLAUDE_MODEL_CONTEXT_WINDOWS[firstParty] ?? null;
9974
9924
  }
9975
9925
  function canUseClaudeFastMode(model2) {
9976
9926
  const normalized = normalizeClaudeModel(model2);
@@ -10084,7 +10034,7 @@ function getAgentModelOptions(provider2, overrides) {
10084
10034
  if (provider2 === "cursor") return DEFAULT_CURSOR_MODELS;
10085
10035
  return AGENT_MODELS[provider2] ?? [];
10086
10036
  }
10087
- var SANDBOX_IMAGE_MODEL_FALLBACKS = {
10037
+ var MODEL_PREDECESSORS = {
10088
10038
  [CLAUDE_FABLE_5_2_MODEL]: CLAUDE_FABLE_5_1_MODEL,
10089
10039
  [CLAUDE_OPUS_5_5_MODEL]: CLAUDE_OPUS_5_MODEL,
10090
10040
  [CLAUDE_SONNET_5_5_MODEL]: CLAUDE_SONNET_5_MODEL,
@@ -10894,7 +10844,7 @@ var AUTH_RETRY_STATUS_EVENT_TYPE = "auth-retry-status";
10894
10844
  var CURSOR_CONNECTION_STATUS_EVENT_TYPE = "cursor-connection-status";
10895
10845
  var AUTH_FALLBACK_EVENT_TYPE = "auth-fallback";
10896
10846
  function coerceAuthFallbackPayload(payload) {
10897
- const { provider: provider2, reason, exhaustedMethod, exhaustedScope, candidateMethod, candidateScope, status, detail } = payload;
10847
+ const { provider: provider2, reason, exhaustedMethod, exhaustedScope, candidateMethod, candidateScope, status, detail, fromModel, toModel } = payload;
10898
10848
  const exhaustedAccount = credentialAccountSchema.safeParse(payload.exhaustedAccount).data;
10899
10849
  const candidateAccount = credentialAccountSchema.safeParse(payload.candidateAccount).data;
10900
10850
  if (typeof provider2 !== "string" || !isValidAgentProvider(provider2) || !isAgentFallbackReason(reason) || !isAuthMethod(exhaustedMethod) || !isAuthMethod(candidateMethod) || !isCredentialScope(candidateScope) || status !== "switched" && status !== "failed") {
@@ -10910,7 +10860,8 @@ function coerceAuthFallbackPayload(payload) {
10910
10860
  candidateScope,
10911
10861
  ...candidateAccount ? { candidateAccount } : {},
10912
10862
  status,
10913
- ...typeof detail === "string" && detail ? { detail } : {}
10863
+ ...typeof detail === "string" && detail ? { detail } : {},
10864
+ ...typeof fromModel === "string" && typeof toModel === "string" ? { fromModel, toModel } : {}
10914
10865
  };
10915
10866
  }
10916
10867
  var CHAT_GOAL_STATUSES = [
@@ -11848,6 +11799,12 @@ function describeAuthFallback(payload) {
11848
11799
  account: payload.exhaustedAccount
11849
11800
  });
11850
11801
  const switched = payload.status === "switched";
11802
+ if (payload.fromModel && payload.toModel) {
11803
+ return {
11804
+ headline: `${MODEL_LABELS[payload.fromModel] ?? payload.fromModel} isn't available on ${exhausted}`,
11805
+ outcomeClause: `switched to ${MODEL_LABELS[payload.toModel] ?? payload.toModel}`
11806
+ };
11807
+ }
11851
11808
  return {
11852
11809
  headline: payload.reason === "out_of_credits" ? `${agent} is out of credits on ${exhausted}` : payload.reason === "auth_failed" ? `${agent} could not authenticate with ${exhausted}` : payload.reason === "credits_required" ? `The selected model needs usage credits on ${exhausted}` : payload.reason === "model_unavailable" ? `The selected model is not available on ${exhausted}` : `${agent} hit its usage limit on ${exhausted}`,
11853
11810
  outcomeClause: switched ? `switched to ${describeCredential(payload.provider, {
@@ -16055,7 +16012,7 @@ ${operation.diff}` : ""}`).join("\n\n");
16055
16012
  }
16056
16013
  if (message2.type === "auth_fallback") {
16057
16014
  const { headline, outcomeClause } = describeAuthFallback(message2);
16058
- return { kind: "error", title: "Credential fallback", summary: headline, content: [`The workspace ${outcomeClause}.`, message2.detail].filter(Boolean).join("\n\n") };
16015
+ return { kind: "error", title: message2.toModel ? "Model fallback" : "Credential fallback", summary: headline, content: [`The workspace ${outcomeClause}.`, message2.detail].filter(Boolean).join("\n\n") };
16059
16016
  }
16060
16017
  if (message2.type === "harness_switch") return { kind: "error", title: describeHarnessSwitch(message2), summary: "", content: "" };
16061
16018
  if (message2.type === "interruption") return { kind: "error", title: "Agent stopped", summary: "", content: "" };
@@ -20187,7 +20144,7 @@ var VOICE_WAVEFORM = {
20187
20144
  };
20188
20145
 
20189
20146
  // ../shared/src/e2b.ts
20190
- var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-11-15-v3";
20147
+ var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-11-15-v4";
20191
20148
 
20192
20149
  // ../shared/src/e2b-retry.ts
20193
20150
  var DEFAULT_BACKOFFS_MS = [2e3, 5e3];
@@ -22535,8 +22492,6 @@ export {
22535
22492
  TERMINAL_RTC_ICE_SERVER,
22536
22493
  exhaustedUntil,
22537
22494
  detectAgentQuotaLimit,
22538
- describeCredential,
22539
- fallbackPlanResponseSchema,
22540
22495
  ASTER_PROVIDER,
22541
22496
  ASTER_BASE_URL,
22542
22497
  ASTER_MODELS,
@@ -22553,9 +22508,6 @@ export {
22553
22508
  isDefaultChat,
22554
22509
  hasGeneratedChatTitle,
22555
22510
  isPullRequestFeedbackChat,
22556
- CLAUDE_OPUS_4_8_BEDROCK_MODEL,
22557
- CLAUDE_SONNET_5_BEDROCK_MODEL,
22558
- CLAUDE_HAIKU_4_5_BEDROCK_MODEL,
22559
22511
  DEFAULT_CLAUDE_MODEL,
22560
22512
  DEFAULT_CODEX_MODEL,
22561
22513
  DEFAULT_CURSOR_MODEL,
@@ -22564,10 +22516,11 @@ export {
22564
22516
  DEFAULT_PI_MODEL,
22565
22517
  getDefaultAgentModel,
22566
22518
  normalizeClaudeModel,
22567
- toClaudeCodeModel,
22568
22519
  getClaudeModelContextWindow,
22569
22520
  canUseClaudeFastMode,
22570
22521
  AGENT_MODELS,
22522
+ MODEL_PREDECESSORS,
22523
+ MODEL_LABELS,
22571
22524
  IMAGE_MEDIA_TYPES,
22572
22525
  MAX_PENDING_RESOURCE_MINUTES,
22573
22526
  MAX_CANVAS_FILE_BYTES,
@@ -22578,6 +22531,9 @@ export {
22578
22531
  classifyCanvasFilename,
22579
22532
  isValidEngineLogSessionId,
22580
22533
  paginateEngineLogContent,
22534
+ describeCredential,
22535
+ describeAuthFallback,
22536
+ fallbackPlanResponseSchema,
22581
22537
  coerceChatForkInfo,
22582
22538
  forkChatRequestSchema,
22583
22539
  describeQuotaLimit,
@@ -22611,6 +22567,7 @@ export {
22611
22567
  AUTH_RETRY_STATUS_EVENT_TYPE,
22612
22568
  CURSOR_CONNECTION_STATUS_EVENT_TYPE,
22613
22569
  AUTH_FALLBACK_EVENT_TYPE,
22570
+ coerceAuthFallbackPayload,
22614
22571
  coerceChatGoalPayload,
22615
22572
  CONTEXT_USAGE_EVENT_TYPE,
22616
22573
  MERGED_MESSAGE_SEPARATOR,
@@ -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-M5VTBOCO.js";
6
+ } from "./chunk-N2L2AOYB.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-66OYINQO.js";
18
+ } from "./chunk-7NLNGNK3.js";
19
19
 
20
20
  // src/managers/codex-asp/notification-dispatch.ts
21
21
  var TURN_STARTED_METHOD = "turn/started";
@@ -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-VUQFJXAV.js";
6
+ } from "./chunk-WJG3HGWB.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-66OYINQO.js";
9
+ } from "./chunk-7NLNGNK3.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.1577";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1578";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -6,7 +6,7 @@ import {
6
6
  getOriginDefaultBranch,
7
7
  monolithRequest,
8
8
  runGitCommand
9
- } from "./chunk-MIMEP2M4.js";
9
+ } from "./chunk-UPPPY2ZE.js";
10
10
  import {
11
11
  extractCommandProtectionCommandText,
12
12
  findCommandProtectionGitLookups,
@@ -15,7 +15,7 @@ import {
15
15
  findScoutRepoWriteSignals,
16
16
  parseCommandProtectionRequest,
17
17
  withE2BRetry
18
- } from "./chunk-66OYINQO.js";
18
+ } from "./chunk-7NLNGNK3.js";
19
19
 
20
20
  // src/services/command-protection-service.ts
21
21
  import { readFile, stat } from "fs/promises";
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-VUQFJXAV.js";
7
+ } from "./chunk-WJG3HGWB.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-66OYINQO.js";
24
+ } from "./chunk-7NLNGNK3.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
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-66OYINQO.js";
6
+ } from "./chunk-7NLNGNK3.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -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-U3EN4QCR.js";
7
- import "./chunk-MIMEP2M4.js";
8
- import "./chunk-VUQFJXAV.js";
6
+ } from "./chunk-ONIBN4G7.js";
7
+ import "./chunk-UPPPY2ZE.js";
8
+ import "./chunk-WJG3HGWB.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-66OYINQO.js";
12
+ import "./chunk-7NLNGNK3.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-DIECEGIA.js";
17
+ } from "./chunk-JUV3457M.js";
18
18
  import {
19
19
  AppServerProcess,
20
20
  buildCodexAgentEnv
21
- } from "./chunk-M5VTBOCO.js";
22
- import "./chunk-VUQFJXAV.js";
21
+ } from "./chunk-N2L2AOYB.js";
22
+ import "./chunk-WJG3HGWB.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-66OYINQO.js";
32
+ } from "./chunk-7NLNGNK3.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-U3EN4QCR.js";
30
+ } from "./chunk-ONIBN4G7.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-DIECEGIA.js";
68
+ } from "./chunk-JUV3457M.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
- } from "./chunk-MOE3YPCA.js";
71
+ } from "./chunk-2NPZJAON.js";
72
72
  import {
73
73
  ACCOUNT_RATE_LIMITS_READ_METHOD,
74
74
  AsyncLock,
@@ -114,6 +114,7 @@ import {
114
114
  codexTokenManager,
115
115
  configureManagedGitCredentialHelper,
116
116
  extractRateLimitsSnapshot,
117
+ forgetExhaustedCredentials,
117
118
  formatTurnFailure,
118
119
  getAgentAdditionalDirectories,
119
120
  getCodexAspHost,
@@ -146,7 +147,7 @@ import {
146
147
  transcriptSecrets,
147
148
  upsertCredentialFileLines,
148
149
  writeSecureCredentialFile
149
- } from "./chunk-KVU36YTE.js";
150
+ } from "./chunk-5VCKFH2P.js";
150
151
  import {
151
152
  ENGINE_ENV,
152
153
  UNQUOTED_PATHS_CONFIG,
@@ -157,15 +158,15 @@ import {
157
158
  resolveDiffBase,
158
159
  setAgentCredentialSnapshot,
159
160
  setLinearSessionId
160
- } from "./chunk-MIMEP2M4.js";
161
+ } from "./chunk-UPPPY2ZE.js";
161
162
  import {
162
163
  getCodexModelProvider
163
- } from "./chunk-M5VTBOCO.js";
164
+ } from "./chunk-N2L2AOYB.js";
164
165
  import {
165
166
  SUBPROCESS_MAX_BUFFER,
166
167
  execAsync,
167
168
  execFileAsync
168
- } from "./chunk-VUQFJXAV.js";
169
+ } from "./chunk-WJG3HGWB.js";
169
170
  import {
170
171
  isRecord as isRecord2
171
172
  } from "./chunk-UZSNFLDQ.js";
@@ -190,11 +191,8 @@ import {
190
191
  CHAT_TURN_LOST_MESSAGE,
191
192
  CLAUDE_AUTH_ENV_KEYS,
192
193
  CLAUDE_AUTH_ENV_KEYS_BY_METHOD,
193
- CLAUDE_HAIKU_4_5_BEDROCK_MODEL,
194
- CLAUDE_OPUS_4_8_BEDROCK_MODEL,
195
194
  CLAUDE_PARTIAL_MESSAGE_EVENT_TYPE,
196
195
  CLAUDE_PEER_MESSAGE_EVENT_TYPE,
197
- CLAUDE_SONNET_5_BEDROCK_MODEL,
198
196
  CLAUDE_STOPPED_TOOL_RESULT,
199
197
  CODEX_ASP_ITEM_ID_PAYLOAD_KEY,
200
198
  CODEX_HISTORY_FORMAT_EVENT_TYPE,
@@ -248,6 +246,8 @@ import {
248
246
  MAX_PENDING_RESOURCE_MINUTES,
249
247
  MAX_REPO_FILE_CONTENT_BYTES,
250
248
  MERGED_MESSAGE_SEPARATOR,
249
+ MODEL_LABELS,
250
+ MODEL_PREDECESSORS,
251
251
  MOTHERSHIP_EVENT_MESSAGE_TYPE,
252
252
  MOTHERSHIP_INSTRUCTIONS_TAG,
253
253
  MOTHERSHIP_TURN_ERROR_SUMMARY,
@@ -297,6 +297,7 @@ import {
297
297
  codexTranscriptToEvents,
298
298
  codexTurnEvent,
299
299
  codexTurnFromEvent,
300
+ coerceAuthFallbackPayload,
300
301
  coerceBackgroundTaskPayload,
301
302
  coerceChatForkInfo,
302
303
  coerceChatGoalPayload,
@@ -311,6 +312,7 @@ import {
311
312
  createUuidFromHex,
312
313
  currentStepLabel,
313
314
  defaultForkChatTitle,
315
+ describeAuthFallback,
314
316
  describeCredential,
315
317
  describeQuotaLimit,
316
318
  detectAgentQuotaLimit,
@@ -437,7 +439,6 @@ import {
437
439
  steerQueuedInOrder,
438
440
  stripAgentDiagnosticErrors,
439
441
  threadHandoffText,
440
- toClaudeCodeModel,
441
442
  toolInputAnswer,
442
443
  truncateMothershipEventResponse,
443
444
  updateChatDisplayNameRequestSchema,
@@ -448,7 +449,7 @@ import {
448
449
  workspaceTokenRequestSchema,
449
450
  workspaceTokenResponseSchema,
450
451
  wrapInTag
451
- } from "./chunk-66OYINQO.js";
452
+ } from "./chunk-7NLNGNK3.js";
452
453
  import {
453
454
  cloneMcpConfig,
454
455
  ensureCompatibilityImports,
@@ -11486,6 +11487,11 @@ function describeLoginFailure(provider, login, configuredMethod, revoked) {
11486
11487
  const reconnect = orgLogin ? `An organization admin can reconnect it in ${agentsPage}` : `Reconnect it in ${agentsPage}`;
11487
11488
  return `${agent} could not sign in with ${name}. ${why} ${reconnect}`;
11488
11489
  }
11490
+ function describeModelUnavailable(provider, models, credential) {
11491
+ const bedrock = credential?.method === "bedrock";
11492
+ const where = credential ? describeCredential(provider, credential) : `the ${getProviderDisplayName(provider)} credential this workspace uses`;
11493
+ return `${models.map((model) => MODEL_LABELS[model] ?? model).join(" and ")} ${models.length > 1 ? "are" : "is"} not available on ${where}${bedrock && ENGINE_ENV.AWS_REGION ? ` in ${ENGINE_ENV.AWS_REGION}` : ""}.` + (bedrock ? " Turn on access for that region in the Amazon Bedrock console (Model access)," : "") + " pick a different model in the chat's model picker, or add a credential that serves it in Settings \u2192 Fallbacks.";
11494
+ }
11489
11495
  var fallbackLocks = /* @__PURE__ */ new Map();
11490
11496
  var AuthFallbackCoordinator = class {
11491
11497
  constructor(provider, record3, context) {
@@ -12789,11 +12795,8 @@ function buildClaudeAgentEnv(overrides) {
12789
12795
  if (method === "ollama" || method === "anthropic-compatible") env.ANTHROPIC_API_KEY = "";
12790
12796
  if (isBedrock) {
12791
12797
  env.CLAUDE_CODE_USE_BEDROCK = "1";
12792
- env.CLAUDE_CODE_USE_MANTLE = "1";
12793
- env.ANTHROPIC_DEFAULT_OPUS_MODEL = CLAUDE_OPUS_4_8_BEDROCK_MODEL;
12794
- env.ANTHROPIC_DEFAULT_SONNET_MODEL = CLAUDE_SONNET_5_BEDROCK_MODEL;
12795
- env.ANTHROPIC_DEFAULT_HAIKU_MODEL = CLAUDE_HAIKU_4_5_BEDROCK_MODEL;
12796
12798
  }
12799
+ if (method === "bedrock" || env.REPLICAS_CLAUDE_AUTH_METHOD === "bedrock") env.AWS_BEARER_TOKEN_BEDROCK = void 0;
12797
12800
  env.GH_TOKEN = void 0;
12798
12801
  env.GITHUB_TOKEN = void 0;
12799
12802
  env.GH_CONFIG_DIR = void 0;
@@ -13939,6 +13942,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13939
13942
  let loginRevoked = false;
13940
13943
  let namedLogin;
13941
13944
  let failedCredentials = [];
13945
+ let modelRejected = [];
13942
13946
  let walkLimit;
13943
13947
  let attempt = 0;
13944
13948
  let authRetries = 0;
@@ -14018,6 +14022,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14018
14022
  const detail = error instanceof ClaudeQuotaError || error instanceof ClaudeModelUnavailableError ? error.message : extractErrorText(error);
14019
14023
  const repeated = !!attemptedCredential && failedCredentials.some((failed) => isSameCredential(failed, attemptedCredential));
14020
14024
  if (attemptedCredential) failedCredentials.push(attemptedCredential);
14025
+ if (attemptedCredential && modelUnavailable) modelRejected.push(attemptedCredential);
14021
14026
  const limit = quotaKind ? { kind: quotaKind, credential: attemptedCredential } : walkLimit;
14022
14027
  const fallback = repeated ? { outcome: "unavailable" } : await this.fallBackCredential(reason, detail, attemptedCredential, error instanceof ClaudeQuotaError ? error.resetsAt : void 0, !!walkLimit);
14023
14028
  if (fallback.outcome === "switched") {
@@ -14041,7 +14046,38 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14041
14046
  return;
14042
14047
  }
14043
14048
  if (modelUnavailable) {
14044
- await this.emitTerminalErrorResult(detail, [`${detail} No other credential in the fallback chain could serve it. Pick a different model, or check Settings \u2192 Fallbacks.`]);
14049
+ const model = normalizeClaudeModel(currentRequest.model) ?? DEFAULT_CLAUDE_MODEL;
14050
+ const predecessor = MODEL_PREDECESSORS[model];
14051
+ if (predecessor) {
14052
+ currentRequest = { ...currentRequest, model: predecessor };
14053
+ if (attemptedCredential) {
14054
+ const { method, scope, account } = attemptedCredential;
14055
+ this.record({
14056
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
14057
+ type: AUTH_FALLBACK_EVENT_TYPE,
14058
+ payload: {
14059
+ provider: "claude",
14060
+ reason: "model_unavailable",
14061
+ status: "switched",
14062
+ detail,
14063
+ exhaustedMethod: method,
14064
+ exhaustedScope: scope,
14065
+ candidateMethod: method,
14066
+ candidateScope: scope,
14067
+ ...account ? { exhaustedAccount: account, candidateAccount: account } : {},
14068
+ fromModel: model,
14069
+ toModel: predecessor
14070
+ }
14071
+ });
14072
+ }
14073
+ forgetExhaustedCredentials("claude", modelRejected);
14074
+ failedCredentials = [];
14075
+ modelRejected = [];
14076
+ attempt++;
14077
+ continue;
14078
+ }
14079
+ const requested = normalizeClaudeModel(request.model) ?? DEFAULT_CLAUDE_MODEL;
14080
+ await this.emitTerminalErrorResult(detail, [describeModelUnavailable("claude", [.../* @__PURE__ */ new Set([requested, model])], attemptedCredential)]);
14045
14081
  return;
14046
14082
  }
14047
14083
  failedLogin = { credential: attemptedCredential ?? namedLogin, revoked: loginRevoked };
@@ -14184,10 +14220,6 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14184
14220
  const authMethod = resolveClaudeAuthMethodForMessage();
14185
14221
  const isClaudeModel = !!requestedModel && /^claude-/i.test(requestedModel);
14186
14222
  const resolvedModel = authMethod === "ollama" ? getFallbackModel("claude") ?? (requestedModel && !isClaudeModel ? requestedModel : DEFAULT_OLLAMA_MODEL) : (authMethod === "oauth" || authMethod === "api_key") && requestedModel && !isClaudeModel ? DEFAULT_CLAUDE_MODEL : requestedModel || DEFAULT_CLAUDE_MODEL;
14187
- const claudeCodeModel = toClaudeCodeModel(
14188
- resolvedModel,
14189
- ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD === "bedrock" || ENGINE_ENV.CLAUDE_CODE_USE_BEDROCK === "1"
14190
- );
14191
14223
  const resolvedPermissionMode = planMode ? "plan" : "bypassPermissions";
14192
14224
  const resolvedFastMode = Boolean(fastMode && canUseClaudeFastMode(resolvedModel));
14193
14225
  this.onChatCredential("workspace");
@@ -14205,7 +14237,6 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14205
14237
  signature,
14206
14238
  combinedInstructions,
14207
14239
  resolvedModel,
14208
- claudeCodeModel,
14209
14240
  resolvedPermissionMode,
14210
14241
  enableInteractiveTools: signature.enableInteractiveTools,
14211
14242
  thinkingLevel
@@ -14294,16 +14325,15 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14294
14325
  signature,
14295
14326
  combinedInstructions,
14296
14327
  resolvedModel,
14297
- claudeCodeModel,
14298
14328
  resolvedPermissionMode,
14299
14329
  enableInteractiveTools,
14300
14330
  thinkingLevel
14301
14331
  } = args;
14302
14332
  if (this.activeQuery && this.activeSessionSignature && (this.sessionSignaturesMatch(this.activeSessionSignature, signature) || this.backgroundTasks.active.size > 0 && this.activeSessionSignature.credential === signature.credential)) {
14303
- if (this.activeSessionModel !== claudeCodeModel) {
14333
+ if (this.activeSessionModel !== resolvedModel) {
14304
14334
  try {
14305
- await this.activeQuery.setModel(claudeCodeModel);
14306
- this.activeSessionModel = claudeCodeModel;
14335
+ await this.activeQuery.setModel(resolvedModel);
14336
+ this.activeSessionModel = resolvedModel;
14307
14337
  } catch (err) {
14308
14338
  console.warn("[ClaudeManager] setModel failed; recreating session:", err);
14309
14339
  await this.tearDownSession();
@@ -14316,7 +14346,6 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14316
14346
  await this.startSession({
14317
14347
  combinedInstructions,
14318
14348
  resolvedModel,
14319
- claudeCodeModel,
14320
14349
  resolvedPermissionMode,
14321
14350
  enableInteractiveTools,
14322
14351
  thinkingLevel,
@@ -14350,7 +14379,6 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14350
14379
  const {
14351
14380
  combinedInstructions,
14352
14381
  resolvedModel,
14353
- claudeCodeModel,
14354
14382
  resolvedPermissionMode,
14355
14383
  enableInteractiveTools,
14356
14384
  thinkingLevel,
@@ -14404,7 +14432,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14404
14432
  ANTHROPIC_DEFAULT_HAIKU_MODEL: resolvedModel
14405
14433
  } : {}
14406
14434
  },
14407
- model: claudeCodeModel,
14435
+ model: resolvedModel,
14408
14436
  ...this.chatTitle ? { title: this.chatTitle() } : {},
14409
14437
  settings: {
14410
14438
  fastMode: signature.fastMode,
@@ -14459,7 +14487,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14459
14487
  this.activeQuery = response;
14460
14488
  this.activePromptStream = promptStream;
14461
14489
  this.activeSessionSignature = signature;
14462
- this.activeSessionModel = claudeCodeModel;
14490
+ this.activeSessionModel = resolvedModel;
14463
14491
  this.sessionLinearForwarder = new LinearEventForwarder(() => this.linearSessionId);
14464
14492
  this.sessionLoop = this.runSessionLoop(response).catch((err) => {
14465
14493
  console.error("[ClaudeManager] Session loop crashed:", err);
@@ -63048,6 +63076,7 @@ ${note}`;
63048
63076
  hasActiveTurn: false,
63049
63077
  observedBranchesByRepo: /* @__PURE__ */ new Map(),
63050
63078
  lastTurnErrors: null,
63079
+ turnNotices: [],
63051
63080
  turnRequest: null,
63052
63081
  turnAnswer: null,
63053
63082
  turnCompletion: null,
@@ -63230,6 +63259,11 @@ ${note}`;
63230
63259
  if (terminalErrors !== void 0) {
63231
63260
  chat.lastTurnErrors = terminalErrors;
63232
63261
  }
63262
+ const fallback = event.type === AUTH_FALLBACK_EVENT_TYPE ? coerceAuthFallbackPayload(event.payload) : null;
63263
+ if (fallback?.toModel) {
63264
+ const { headline, outcomeClause } = describeAuthFallback(fallback);
63265
+ chat.turnNotices.push(`${headline}, so this turn ${outcomeClause}.`);
63266
+ }
63233
63267
  if (event.type === AGENT_QUOTA_EXHAUSTED_EVENT_TYPE) {
63234
63268
  chat.quotaExhaustion = agentQuotaExhaustedPayloadSchema.safeParse(event.payload).data ?? null;
63235
63269
  }
@@ -63538,6 +63572,8 @@ ${note}`;
63538
63572
  const linearSessionId = ENGINE_ENV.REPLICAS_LINEAR_SESSION_ID;
63539
63573
  const errors = chat.persisted.parentChatId === null ? chat.lastTurnErrors : null;
63540
63574
  chat.lastTurnErrors = null;
63575
+ const notices = errors?.length ? [] : chat.turnNotices;
63576
+ chat.turnNotices = [];
63541
63577
  const errorNotificationTargets = chat.activeErrorNotificationTargets;
63542
63578
  chat.activeErrorNotificationTargets = [];
63543
63579
  const observedBranches = chat.observedBranchesByRepo;
@@ -63563,8 +63599,9 @@ ${note}`;
63563
63599
  repoStatuses,
63564
63600
  ...unlinkedPullRequestUrls.length > 0 ? { unlinkedPullRequestUrls } : {},
63565
63601
  ...errors?.length ? { errors } : {},
63602
+ ...notices.length ? { notices } : {},
63566
63603
  ...turnLost ? { turnLost } : {},
63567
- ...(errors?.length || quotaExhaustion) && errorNotificationTargets.length > 0 ? { errorNotificationTargets } : {},
63604
+ ...(errors?.length || notices.length || quotaExhaustion) && errorNotificationTargets.length > 0 ? { errorNotificationTargets } : {},
63568
63605
  ...quotaExhaustion ? { quotaExhaustion } : {},
63569
63606
  ...isPullRequestFeedbackChat(chat.persisted) ? { pullRequestFeedback: true } : {}
63570
63607
  };
@@ -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-MOE3YPCA.js";
6
+ } from "./chunk-2NPZJAON.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-66OYINQO.js";
12
+ } from "./chunk-7NLNGNK3.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-66OYINQO.js";
14
+ } from "./chunk-7NLNGNK3.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.1577",
3
+ "version": "0.1.1579",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",