@chibitek/chibi 0.1.184 → 0.1.185

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.
Files changed (74) hide show
  1. package/dist/assets/{abnfDiagram-O67JEVCF-D63grDEy.js → abnfDiagram-O67JEVCF-CVenv9f1.js} +1 -1
  2. package/dist/assets/{arc-bQvylCdS.js → arc-CIRWjkSZ.js} +1 -1
  3. package/dist/assets/{architectureDiagram-NJMV4G6O-BOAFaaj7.js → architectureDiagram-NJMV4G6O-DmIpOaYd.js} +1 -1
  4. package/dist/assets/{blockDiagram-BEXU5L5S-ewLAgFlb.js → blockDiagram-BEXU5L5S-BYhb8Ycm.js} +1 -1
  5. package/dist/assets/{c4Diagram-YGBWAQC7-Dn_C6A7b.js → c4Diagram-YGBWAQC7-B9rBcCno.js} +1 -1
  6. package/dist/assets/channel-NYf_L8uU.js +1 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-DpB_wNSI.js → chunk-2Q5K7J3B-CV6TX9gt.js} +1 -1
  8. package/dist/assets/{chunk-3FUC2YCW-DIelvlCV.js → chunk-3FUC2YCW-DiOotfQU.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-O-aALIul.js → chunk-5VM5RSS4-Br5QWC-1.js} +1 -1
  10. package/dist/assets/{chunk-GTNCS2PH-Dqe5r4Ji.js → chunk-GTNCS2PH-BmvI8RMK.js} +1 -1
  11. package/dist/assets/{chunk-GWA4HPMP-FzFr6U_I.js → chunk-GWA4HPMP-Do93bTCh.js} +1 -1
  12. package/dist/assets/{chunk-JWPE2WC7-BuJO0Fyh.js → chunk-JWPE2WC7-qIjG-mTw.js} +1 -1
  13. package/dist/assets/{chunk-NETBCI7D-DMgFuMgZ.js → chunk-NETBCI7D-DZFFFHT2.js} +1 -1
  14. package/dist/assets/{chunk-WEXAMYUT-BYXYAyMu.js → chunk-WEXAMYUT-qqsVaC1g.js} +1 -1
  15. package/dist/assets/{chunk-XXDRQBXY-s_OT2iv7.js → chunk-XXDRQBXY-EI-aQ-Wn.js} +1 -1
  16. package/dist/assets/{classDiagram-v2-NBCMYWYE-Cdbr4CZV.js → classDiagram-v2-NBCMYWYE-D9D8dkAx.js} +1 -1
  17. package/dist/assets/{cose-bilkent-JH36ORCC-CXjx4058.js → cose-bilkent-JH36ORCC-m575JDuA.js} +1 -1
  18. package/dist/assets/{cynefin-OW5HDTMX-Cc2YqzW6.js → cynefin-OW5HDTMX-BMm2bhgv.js} +1 -1
  19. package/dist/assets/{cynefinDiagram-VND7K2PF-Cze_i1Vk.js → cynefinDiagram-VND7K2PF-Dl2MlsqG.js} +1 -1
  20. package/dist/assets/{dagre-6A5THRUB-oPouQ7XU.js → dagre-6A5THRUB-Cw8yJ-SY.js} +1 -1
  21. package/dist/assets/{diagram-22UHCM2B-DNRc977u.js → diagram-22UHCM2B-DyY0F1qK.js} +1 -1
  22. package/dist/assets/{diagram-3UASUU5V-B8vBo05Y.js → diagram-3UASUU5V-sMOszbgV.js} +1 -1
  23. package/dist/assets/{diagram-ATOU4E4O-dCch9eKa.js → diagram-ATOU4E4O-DPo3fHpo.js} +1 -1
  24. package/dist/assets/{diagram-CDSNMT55-CYJSen9G.js → diagram-CDSNMT55-BAHqm-cq.js} +1 -1
  25. package/dist/assets/{diagram-MLGK6HIB-RxYVGgc6.js → diagram-MLGK6HIB-BdI4Tf9M.js} +1 -1
  26. package/dist/assets/{diagram-MPIPVDR6-B-UyrObe.js → diagram-MPIPVDR6-BxqEl_S5.js} +1 -1
  27. package/dist/assets/{ebnfDiagram-ZINNZB2B-CxGXwVT7.js → ebnfDiagram-ZINNZB2B-DLJ3VRtx.js} +1 -1
  28. package/dist/assets/{elk-276RUBZZ-CHGRRKuJ.js → elk-276RUBZZ-Yhxabhx6.js} +1 -1
  29. package/dist/assets/{erDiagram-OPXOYQCR-BMJusoDl.js → erDiagram-OPXOYQCR-DZ4Es64N.js} +1 -1
  30. package/dist/assets/{flowDiagram-KWPJA3E3-DtiBETZe.js → flowDiagram-KWPJA3E3-E36WtrEY.js} +1 -1
  31. package/dist/assets/{ganttDiagram-FUAMR5RP-DAXqRUQM.js → ganttDiagram-FUAMR5RP-OpUEVvtU.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-X574FWY7-Cx_M7do1.js → gitGraphDiagram-X574FWY7-DTZFNsL8.js} +1 -1
  33. package/dist/assets/{index-COCy7XsD.js → index-Bgf1dXAl.js} +3 -3
  34. package/dist/assets/{index-DKt9qb9g.js → index-Bzph058J.js} +1 -1
  35. package/dist/assets/{infoDiagram-VRGFBTTK-CNgfLxed.js → infoDiagram-VRGFBTTK-mCP2UtfM.js} +1 -1
  36. package/dist/assets/{ishikawaDiagram-OU5B5YK6-BvdGqyOz.js → ishikawaDiagram-OU5B5YK6-M71dvinX.js} +1 -1
  37. package/dist/assets/{journeyDiagram-ZHPQQLJL-atzjOsJ2.js → journeyDiagram-ZHPQQLJL-B2VdVbYS.js} +1 -1
  38. package/dist/assets/{kanban-definition-PNTS6WVX-miq8ywtS.js → kanban-definition-PNTS6WVX-l4HpN_KC.js} +1 -1
  39. package/dist/assets/{linear-3skQIwEd.js → linear-CN0tWTVj.js} +1 -1
  40. package/dist/assets/{mermaid.core-CcefVt63.js → mermaid.core-DpBToEGQ.js} +5 -5
  41. package/dist/assets/{mindmap-definition-NLK3R4M7-CyJLiFXW.js → mindmap-definition-NLK3R4M7--DJgZ72R.js} +1 -1
  42. package/dist/assets/{pegDiagram-GJSIUBJH-DdBX63bl.js → pegDiagram-GJSIUBJH-DmTBsA2I.js} +1 -1
  43. package/dist/assets/{pieDiagram-5QR66LMP-DNO9-2f5.js → pieDiagram-5QR66LMP-Cy6JwGMR.js} +1 -1
  44. package/dist/assets/{quadrantDiagram-O4NWA36T-BciZP71K.js → quadrantDiagram-O4NWA36T-DjTftbBA.js} +1 -1
  45. package/dist/assets/{railroadDiagram-XR7U4H2S-4IdVOKPa.js → railroadDiagram-XR7U4H2S-DeKIQoik.js} +1 -1
  46. package/dist/assets/{requirementDiagram-PLB6GJNP-DFdsFYy-.js → requirementDiagram-PLB6GJNP-B02KsDuy.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-IPEJSGJF-HH2WFlmw.js → sankeyDiagram-IPEJSGJF-4RLO5vMI.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-PO4LG4MO-CP91Sy-s.js → sequenceDiagram-PO4LG4MO-CcBW737M.js} +1 -1
  49. package/dist/assets/{sizeCapture-INFHLROL-DhZiuL4S.js → sizeCapture-INFHLROL-CaLSjl7R.js} +1 -1
  50. package/dist/assets/{stateDiagram-v2-GCMORJYK-DIa0uzhR.js → stateDiagram-v2-GCMORJYK-blyzRgvD.js} +1 -1
  51. package/dist/assets/{swimlanes-2SLR337P-CXr7kql9.js → swimlanes-2SLR337P-BIi-tuCD.js} +1 -1
  52. package/dist/assets/swimlanesDiagram-TC7HE7FX-DWtkSjpb.js +8 -0
  53. package/dist/assets/{timeline-definition-EJHVYXUP-BidOWl1X.js → timeline-definition-EJHVYXUP-oNE7PiRv.js} +1 -1
  54. package/dist/assets/{usecaseDiagram-POWQR4AR-Dt0DqsBc.js → usecaseDiagram-POWQR4AR-DzmCYS5I.js} +1 -1
  55. package/dist/assets/{vennDiagram-UO4OBE2U-DMfDgcZH.js → vennDiagram-UO4OBE2U-T51P02io.js} +1 -1
  56. package/dist/assets/{wardleyDiagram-VNRHLVJA-jgsJZ4n4.js → wardleyDiagram-VNRHLVJA-1GfD8Fys.js} +1 -1
  57. package/dist/assets/{xychartDiagram-PMCCYNJV-AllqBdcw.js → xychartDiagram-PMCCYNJV-BhNMe0uk.js} +1 -1
  58. package/dist/index.html +1 -1
  59. package/dist-server/index.js +947 -884
  60. package/dist-server/openmausbot.js +224 -176
  61. package/dist-server/pair-cli.js +224 -176
  62. package/dist-server/server/computer-stop-names.js +35 -0
  63. package/dist-server/server/connection-cap-failover.js +1 -1
  64. package/dist-server/server/drivers/claude-auth-status.js +25 -0
  65. package/dist-server/server/drivers/claude.js +6 -5
  66. package/dist-server/server/drivers/retry.js +1 -0
  67. package/dist-server/server/engine-failover.js +14 -5
  68. package/dist-server/server/engine-failure.js +4 -4
  69. package/dist-server/server/index.js +13 -14
  70. package/dist-server/server/injected-model-rest.js +9 -0
  71. package/dist-server/server/model-access-refusal.js +62 -0
  72. package/package.json +1 -1
  73. package/dist/assets/channel-DaRjZag9.js +0 -1
  74. package/dist/assets/swimlanesDiagram-TC7HE7FX-CtuksGU4.js +0 -8
@@ -0,0 +1,35 @@
1
+ // The names a stop line gives, on a turn that must drive a computer, for the
2
+ // engines a ladder passed over (restingLine's `computer` argument). Both stop
3
+ // paths use it: restingStop at a turn's start and finalizeConnectionCapPick
4
+ // mid-turn.
5
+ import { canDriveComputer, engineHealth } from "./engine-tiers.js";
6
+ /** Of these engines, which cannot drive `computer`, and which could but were
7
+ * skipped as signed out or unavailable before any rest was read (once
8
+ * dropped from the line, 2026-11-10, so "Codex needs sign-in" never showed).
9
+ * Each engine once, by display name.
10
+ *
11
+ * The ladder's own skip reason decides, so an engine it passed over for
12
+ * something else (refused, no model, resting) is never named as one sign-in
13
+ * away. An entry with no reason (the bot's own engine, which the ladder does
14
+ * not list) is read from its health. */
15
+ export function computerStopNames(candidates, skipped, computer) {
16
+ const names = { engines: [], signedOut: [], unavailable: [] };
17
+ const reasons = new Map();
18
+ for (const skip of skipped)
19
+ reasons.set(skip.instanceId, reasons.get(skip.instanceId) ?? skip.reason);
20
+ for (const [instanceId, reason] of reasons) {
21
+ const candidate = candidates.find((entry) => entry.instanceId === instanceId);
22
+ if (!candidate)
23
+ continue;
24
+ if (!canDriveComputer(candidate, computer)) {
25
+ names.engines.push(candidate.displayName);
26
+ continue;
27
+ }
28
+ const why = reason ?? engineHealth(candidate);
29
+ if (why === "signed-out")
30
+ names.signedOut.push(candidate.displayName);
31
+ else if (why === "unavailable")
32
+ names.unavailable.push(candidate.displayName);
33
+ }
34
+ return names;
35
+ }
@@ -155,7 +155,7 @@ export function finalizeConnectionCapPick(input) {
155
155
  const named = input.restingNamed([input.failedInstanceId, ...input.alreadyTried, ...resting]);
156
156
  return {
157
157
  line: restingLine(named, input.formatTime, input.cannotDrive, { capped: input.triedCount >= MAX_ENGINES_PER_TURN }),
158
- category: named.some((engine) => engine.needsSignIn || engine.keyExpired) ? "account" : "failover_exhausted",
158
+ category: named.some((engine) => engine.needsSignIn || engine.keyExpired) || input.cannotDrive?.signedOut?.length ? "account" : "failover_exhausted",
159
159
  };
160
160
  }
161
161
  if (input.failureKind === "usage_limited") {
@@ -1,4 +1,29 @@
1
+ import { join } from "node:path";
1
2
  import { execCli } from "../procs.js";
3
+ /** Keep the CLI off the machine's Anthropic profile (the `ant` CLI's store,
4
+ * ~/.config/anthropic, chosen by `ANTHROPIC_PROFILE`) unless this account's
5
+ * own settings name one on purpose.
6
+ *
7
+ * 2026-11-10: that store held an access token that had expired in August
8
+ * and has no refresh token. Claude Code used it, `claude auth status`
9
+ * answered `loggedIn: true, authMethod: "oauth_token"` without checking the
10
+ * expiry, and every turn ended "Login expired · ... re-authenticate your
11
+ * Anthropic profile". Settings showed Claude signed in while it rested as
12
+ * "needs sign-in" every half hour for three days. Pointing the CLI's profile
13
+ * folder at one that never exists leaves it its own login (Keychain or
14
+ * CLAUDE_CONFIG_DIR), so the probe and the turn both tell the truth.
15
+ *
16
+ * The CLI's own tools inherit this, so `ant` or an SDK script a bot runs
17
+ * finds no profile either, like the API keys this launch already removes. */
18
+ export function isolateAnthropicProfile(env, instanceEnvironment, dataDir) {
19
+ if (choseAnthropicProfile(instanceEnvironment))
20
+ return;
21
+ delete env.ANTHROPIC_PROFILE;
22
+ env.ANTHROPIC_CONFIG_DIR = join(dataDir, "claude-no-anthropic-profile");
23
+ }
24
+ /** Whether this account's own settings name an Anthropic profile on purpose:
25
+ * then the profile's token is its sign-in, for a named account too. */
26
+ export const choseAnthropicProfile = (instanceEnvironment) => Boolean(instanceEnvironment.ANTHROPIC_PROFILE || instanceEnvironment.ANTHROPIC_CONFIG_DIR);
2
27
  /** Whether a parsed `claude auth status --json` answer is this account's own
3
28
  * sign-in.
4
29
  *
@@ -22,12 +22,12 @@ import { brokerSocketPath, describeSpawnFailure, execCli, killCliTree, resolveCl
22
22
  import { parseClaudeMcpList, parseClaudeMcpLocalNames } from "../claude-account-connectors.js";
23
23
  import { classifyResumeFailure, mayReplay, recoveryPromptFor } from "../resume-recovery.js";
24
24
  import { ClaudeLoginController } from "./claude-login-auth.js";
25
- import { claudeAuthStatus } from "./claude-auth-status.js";
25
+ import { choseAnthropicProfile, claudeAuthStatus, isolateAnthropicProfile } from "./claude-auth-status.js";
26
26
  export { claudeSignedIn } from "./claude-auth-status.js";
27
27
  import { gateServer, resultBudget } from "../mcp-gate-config.js";
28
28
  import { newEventId, newId } from "../contracts.js";
29
29
  import { askInputSummary, commandSummary, toolDetailPreview } from "../tool-summary.js";
30
- import { classifyError, computeBackoff, computeCredentialRefreshBackoff, CREDENTIAL_REFRESH_CONFLICT, interruptibleDelay, RETRY_MAX_ATTEMPTS, } from "./retry.js";
30
+ import { classifyError, computeBackoff, computeCredentialRefreshBackoff, CREDENTIAL_REFRESH_CONFLICT, interruptibleDelay, isModelAccessRefused, RETRY_MAX_ATTEMPTS, } from "./retry.js";
31
31
  import { applyClaudeInject, decodeInjectId, mergeLocalInject, probeLocalInjects, resolveInjectId, } from "./local-inject.js";
32
32
  import { appendNative } from "./native.js";
33
33
  import { SPAWNED_PROXIES } from "../proxy-paths.js";
@@ -76,7 +76,7 @@ export function resolveClaudeConfigDir(configDir, env = process.env) {
76
76
  export function claudeAuthFailure(frame, text) {
77
77
  if (frame.is_api_error_message !== true && typeof frame.error !== "string")
78
78
  return false;
79
- return frame.error === "authentication_failed" || classifyError({ text }).reason === "auth_failed";
79
+ return !isModelAccessRefused(text) && (frame.error === "authentication_failed" || classifyError({ text }).reason === "auth_failed");
80
80
  }
81
81
  /** Whether a stream frame is the CLI reporting that it lost a race to renew
82
82
  * the shared OAuth token ("Failed to refresh OAuth token: another Claude
@@ -118,7 +118,7 @@ export function claudeResultStopReason(o) {
118
118
  * Keeping the probe and turn environments identical prevents setup from
119
119
  * claiming an API-key login that the turn itself would deliberately remove.
120
120
  */
121
- function claudeEnvironment(model, source = process.env, configDir, instanceEnvironment = {}) {
121
+ export function claudeEnvironment(model, source = process.env, configDir, instanceEnvironment = {}) {
122
122
  const env = { ...source, PATH: augmentedPath(), NPM_CONFIG_LOGLEVEL: "error" };
123
123
  if (configDir?.trim()) {
124
124
  env.CLAUDE_CONFIG_DIR = resolveClaudeConfigDir(configDir, env);
@@ -135,6 +135,7 @@ function claudeEnvironment(model, source = process.env, configDir, instanceEnvir
135
135
  }
136
136
  delete env.CLAUDECODE;
137
137
  delete env.CLAUDE_CODE_ENTRYPOINT;
138
+ isolateAnthropicProfile(env, instanceEnvironment, DATA_DIR);
138
139
  // The harness process may hold workspace credentials (xai/box/voice keys,
139
140
  // env-injected at boot); none of them are this CLI's to see.
140
141
  stripWorkspaceCredentialEnv(env);
@@ -844,7 +845,7 @@ export const ClaudeDriver = {
844
845
  const environment = (model) => claudeEnvironment(config.managed ? undefined : model, { ...process.env, ...input.environment }, config.configDir, input.environment);
845
846
  const catalogEnv = environment();
846
847
  // An account with its own folder signs in there, never on a borrowed login (claudeOwnLogin).
847
- const namedAccount = Boolean(config.configDir?.trim());
848
+ const namedAccount = Boolean(config.configDir?.trim()) && !choseAnthropicProfile(input.environment);
848
849
  // Say it once where a headless or source run reads its logs; the Engines
849
850
  // page carries the same warning for the desktop (claudeInheritWarning).
850
851
  if (inheritsUserConfig(catalogEnv)) {
@@ -1,5 +1,6 @@
1
1
  import { isProviderSafetyBlock } from "../../shared/provider-safety.js";
2
2
  import { classifyEngineFailure } from "../engine-failure.js";
3
+ export { isModelAccessRefused } from "../model-access-refusal.js";
3
4
  /** Retries after the first try (docs/chibitek/engine-tiers.md, "Automatic
4
5
  * failover"): two, with backoff. */
5
6
  export const RETRY_MAX_RETRIES = 2;
@@ -255,11 +255,20 @@ export function restingLine(engines, formatTime, computer, options = {}) {
255
255
  : engine.needsSignIn ? `${engine.label} needs sign-in`
256
256
  : engine.notResponding ? `${engine.label} is not responding`
257
257
  : `${engine.label} is resting until ${formatTime(engine.until)}`));
258
- const hint = listed.some((engine) => engine.keyExpired || engine.needsSignIn) ? ` ${ACCOUNTS_HINT}` : "";
259
- const cannot = (computer?.engines ?? []).filter((label) => !seen.has(label) && seen.add(label))
260
- .map((label) => `${label} can't control ${computer.place}`);
261
- if (cannot.length)
262
- return `No engine that can work on ${computer.place} is free, so this turn stopped: ${[...parts, ...cannot].join("; ")}.${hint}`;
258
+ // Engines that could work on the place but were passed over before any
259
+ // rest was read: signed out, or not ready on this computer. Named so the
260
+ // line never hides a way back (an engine one sign-in away).
261
+ const fresh = (labels) => (labels ?? []).filter((label) => !seen.has(label) && seen.add(label));
262
+ const signedOut = fresh(computer?.signedOut).map((label) => `${label} needs sign-in`);
263
+ const unavailable = fresh(computer?.unavailable).map((label) => `${label} is unavailable`);
264
+ const hint = listed.some((engine) => engine.keyExpired || engine.needsSignIn) || signedOut.length ? ` ${ACCOUNTS_HINT}` : "";
265
+ const cannot = fresh(computer?.engines).map((label) => `${label} can't control ${computer.place}`);
266
+ // After the two-try cap the cap line says more, unless an engine cannot
267
+ // control the place at all; the passed-over engines are named either way.
268
+ if (cannot.length || ((signedOut.length || unavailable.length) && !options.capped)) {
269
+ return `No engine that can work on ${computer.place} is free, so this turn stopped: ${[...parts, ...signedOut, ...unavailable, ...cannot].join("; ")}.${hint}`;
270
+ }
271
+ parts.push(...signedOut, ...unavailable);
263
272
  // The two-try cap, not an empty ladder: say so, with what each engine hit.
264
273
  if (options.capped) {
265
274
  const count = MAX_ENGINES_PER_TURN === 2 ? "two" : String(MAX_ENGINES_PER_TURN);
@@ -1,3 +1,4 @@
1
+ import { AUTH_STATUS, isModelAccessRefused } from "./model-access-refusal.js";
1
2
  /** resetAt and resetText, when the text states a reset; else, for a rolling
2
3
  * window, its length. */
3
4
  export function statedReset(text, now = Date.now()) {
@@ -109,13 +110,10 @@ const AUTH_FAILED = [
109
110
  // Claude Code: "Not logged in · Please run /login", "Login expired · Run /login ...", "Invalid API key · ...";
110
111
  // Anthropic API: 401 authentication_error "invalid x-api-key";
111
112
  // OpenAI: "Incorrect API key provided"; ACP agents: -32000 "Authentication required".
112
- /\b40[13]\b/,
113
+ ...AUTH_STATUS, // a 401/403 as a status or beside sign-in words, never a bare number
113
114
  /\bunauthori[sz]ed\b|\bunauthenticated\b|\bforbidden\b/i,
114
115
  /\bauthentication[_ ](?:error|failed|required)\b|\binvalid_credentials\b|\bAUTH_REQUIRED\b/i,
115
116
  /\b(?:invalid|incorrect)[ _-]?(?:x-)?api[ _-]?key\b|\bapi key (?:is )?(?:invalid|expired|revoked|not valid)\b/i,
116
- // OpenCode, 2026-10-19, as a JSON-RPC internal error: "Internal error:
117
- // This API key has expired. Create a new API key in OpenCode Console ..."
118
- /\bapi[ _-]?key (?:has |was )(?:been )?(?:expired|revoked|disabled)\b/i,
119
117
  /\bnot (?:logged|signed) in\b|\b(?:logged|signed) out\b|\b(?:please )?run \/login\b|\b(?:login|sign-?in) (?:has )?expired\b|\bmissing bearer\b/i,
120
118
  /\b(?:token|session|credentials?) (?:has |have )?expired\b|\bexpired (?:token|session|credentials?)\b/i,
121
119
  ];
@@ -149,6 +147,8 @@ export function classifyEngineFailure(text, now = Date.now()) {
149
147
  }
150
148
  if (isCredentialDead(text))
151
149
  return { kind: "auth_failed", permanent: true };
150
+ if (isModelAccessRefused(text))
151
+ return { kind: "request_rejected" }; // the model rests, not the login
152
152
  if (AUTH_FAILED.some((pattern) => pattern.test(text)))
153
153
  return { kind: "auth_failed" };
154
154
  if (STALLED.some((pattern) => pattern.test(text)))
@@ -275,7 +275,7 @@ import { localHost, probeLocalInjects } from "./drivers/local-inject.js";
275
275
  import { totalmem } from "node:os";
276
276
  import { loadInstanceKeys } from "./instance-keys.js";
277
277
  import { createProviderAccountRoutes } from "./routes/provider-accounts.js";
278
- import { accountStops, injectedModel, restScope } from "./injected-model-rest.js";
278
+ import { accountStops, injectedModel, modelScope, refusedModelScope, restScope } from "./injected-model-rest.js";
279
279
  import { accountProvider } from "../shared/provider-accounts.js";
280
280
  import { createAccountRoutes } from "./routes/accounts.js";
281
281
  import { installNativeVault } from "./vault/runtime.js";
@@ -302,6 +302,7 @@ import { MODEL_CLASSES, TIERS_THAT_MAY_DROP_A_CLASS, botEngineMode, isBotTier, m
302
302
  import { EngineRestStore } from "./engine-rest.js";
303
303
  import { bindAtomicEngineAccountSource } from "./atomic-engine-accounts.js";
304
304
  import { classifyEngineFailure } from "./engine-failure.js";
305
+ import { computerStopNames } from "./computer-stop-names.js";
305
306
  import { PayPerUseEpisodes } from "./pay-per-use.js";
306
307
  import { PersonalBotMdm, connectionsFor, engineOwner, isPrivateChibiPair, migrateEngineOwners, ownerAllows, ownerPickRefusal, personalBotPatchRefusal, personalConfig, privateBotAccountView, privateBotInternalRefusal, privateChibiLinkAudit, privateChibiLinked, setPrivateChibiLinkReader, withChibiLink, withEngineOwner, withPersonalConnection, withReadWorkMemory, withUseLocalModels, withoutEngineOwner, } from "./personal-bot.js";
307
308
  import { PERSONAL_BOT_REFUSALS, chibiPrivateBotLinkPrompt, isPersonalBot, personalStopLine, personalTime, privateBotPrompt } from "../shared/personal-bot.js";
@@ -3177,7 +3178,8 @@ function restingStop(candidates, skipped, ownId, computer) {
3177
3178
  return entry ? [{ label: candidate?.displayName ?? instanceId, until: entry.until, needsSignIn: entry.needsSignIn, keyExpired: entry.keyExpired,
3178
3179
  notResponding: entry.notResponding }] : [];
3179
3180
  });
3180
- return Object.assign(new Error(restingLine(engines, restTime, cannotDriveNamed(candidates, [ownId, ...skipped.map((skip) => skip.instanceId)], computer))), { status: 409, code: "engines_resting", category: engines.some((engine) => engine.needsSignIn || engine.keyExpired) ? "account" : "failover_exhausted" });
3181
+ const named = cannotDriveNamed(candidates, [{ instanceId: ownId }, ...skipped], computer);
3182
+ return Object.assign(new Error(restingLine(engines, restTime, named)), { status: 409, code: "engines_resting", category: engines.some((engine) => engine.needsSignIn || engine.keyExpired) || named?.signedOut.length ? "account" : "failover_exhausted" });
3181
3183
  }
3182
3184
  /** The computer a turn's engine must drive itself: the bot's or the
3183
3185
  * conversation's explicit "Works on" place, as dispatch mounts it. Auto, Off,
@@ -3191,16 +3193,12 @@ function turnComputer(bot, threadId, runOn) {
3191
3193
  return "vps";
3192
3194
  return undefined;
3193
3195
  }
3194
- /** For a stop line: which of these engines cannot drive the turn's computer,
3195
- * by name, and what that place is called. */
3196
- function cannotDriveNamed(candidates, instanceIds, computer) {
3196
+ /** For a stop line: what the turn's computer is called, and which engines cannot drive it or
3197
+ * could but were skipped as signed out or unavailable (computerStopNames). */
3198
+ function cannotDriveNamed(candidates, skipped, computer) {
3197
3199
  if (!computer)
3198
3200
  return undefined;
3199
- const engines = [...new Set(instanceIds)].flatMap((instanceId) => {
3200
- const candidate = candidates.find((entry) => entry.instanceId === instanceId);
3201
- return candidate && !canDriveComputer(candidate, computer) ? [candidate.displayName] : [];
3202
- });
3203
- return { place: surfaceLabel(computer === "vps" ? "cloud" : computer), engines };
3201
+ return { place: surfaceLabel(computer === "vps" ? "cloud" : computer), ...computerStopNames(candidates, skipped, computer) };
3204
3202
  }
3205
3203
  // ── the Primary Bot sweep's engine (server/primary-bot.ts) ───────────────
3206
3204
  // Chibi is always the Orchestrator, but a sweep is Routine work: it runs on
@@ -3455,7 +3453,7 @@ const engineProbes = new EngineProbes({
3455
3453
  });
3456
3454
  engineProbes.start();
3457
3455
  const engineResting = (candidate, model) => restingOnRoute(candidate, model, engineSnapshots.current() ?? [], // twins: sameRoute
3458
- (entry) => engineRests.resting(entry.instanceId, engineAccount(entry), restScope(entry, model), injectedModel(model))); // restScope: an `ollama::` model on Claude rests alone
3456
+ (entry) => engineRests.resting(entry.instanceId, engineAccount(entry), restScope(entry, model), injectedModel(model)) ?? engineRests.resting(entry.instanceId, engineAccount(entry), modelScope(model), true)); // restScope: an `ollama::` model on Claude rests alone; modelScope: so does a model the plan refused
3459
3457
  /** A model's class, when a source or a person's override grades it (a local
3460
3458
  * Ollama model is Añejo); undefined otherwise (server/model-levels). */
3461
3459
  function modelClassOf(driverKind, model) {
@@ -3615,7 +3613,8 @@ function noteEngineBack(event) {
3615
3613
  const candidate = engineSnapshots.current()?.find((entry) => entry.instanceId === instanceId);
3616
3614
  const selection = directTurnBots.get(event.threadId)?.modelSelection;
3617
3615
  const model = selection?.instanceId === instanceId ? selection.model : undefined;
3618
- engineRests.noteBack(instanceId, candidate ? engineAccount(candidate) : undefined, candidate ? restScope(candidate, model) : undefined);
3616
+ for (const scope of new Set([candidate ? restScope(candidate, model) : undefined, modelScope(model)]))
3617
+ engineRests.noteBack(instanceId, candidate ? engineAccount(candidate) : undefined, scope);
3619
3618
  }
3620
3619
  /** Rest a refused engine and continue on an eligible engine, or show an actionable line. */
3621
3620
  function engineFailover(turn, completion) {
@@ -3636,7 +3635,7 @@ function engineFailover(turn, completion) {
3636
3635
  // that provider rests, the engine's others stay free. A stall is the engine's.
3637
3636
  // A dead key is the whole account's, whichever provider the model ran on:
3638
3637
  // the rest names no provider, so Atomic Engine skips the account too.
3639
- const scope = failure.kind === "stalled" || failure.permanent || !failedCandidate ? undefined : restScope(failedCandidate, ran?.model);
3638
+ const scope = failure.kind === "stalled" || failure.permanent || !failedCandidate ? undefined : restScope(failedCandidate, ran?.model) ?? refusedModelScope(failure.message, ran?.model);
3640
3639
  const restFailed = () => engineRests.rest(turn.instanceId, failedCandidate ? engineAccount(failedCandidate) : undefined, failure.kind, { resetAt: failure.resetAt, resetText: failure.resetText, windowMs: failure.windowMs, message: redactSecretsInText(failure.message),
3641
3640
  ...(failure.permanent ? { permanent: true } : {}), ...(scope ? { scope } : {}), ...(ran?.model ? { model: ran.model } : {}),
3642
3641
  ...(failure.kind === "auth_failed" && failedCandidate ? { reportedSignedIn: failedCandidate.snapshot.state === "available" && failedCandidate.snapshot.authenticated === true } : {}) });
@@ -3888,7 +3887,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
3888
3887
  choice, fallback, subscriptionLine: subscriptionMove?.line, failureKind: turn.failure?.kind,
3889
3888
  pausedUntil: payPerUse.pausedUntil(), skipped: resolution.skipped, payPerUsePausedLine, restingNamed,
3890
3889
  failedInstanceId: turn.instanceId, alreadyTried: attempt.tried, triedCount: tried.size,
3891
- cannotDrive: cannotDriveNamed(candidates, resolution.skipped.map((skip) => skip.instanceId), computer),
3890
+ cannotDrive: cannotDriveNamed(candidates, resolution.skipped, computer),
3892
3891
  policy: connectionRunOutPolicy(cfg.engineTiers), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
3893
3892
  local: Boolean(placed.local), currentLabel: engineLabel(candidates, attempt.selection),
3894
3893
  nextLabel: choice ? engineLabel(candidates, choice.selection) : undefined,
@@ -9,6 +9,7 @@
9
9
  // session limit was moved off its Ollama model onto another Claude account.
10
10
  import { decodeInjectId } from "./drivers/local-inject.js";
11
11
  import { modelProvider } from "./harness-import/engine-policy.js";
12
+ import { isModelAccessRefused } from "./model-access-refusal.js";
12
13
  /** The rest scope of a model whose turns go to another host. */
13
14
  export const INJECTED_SCOPE = "injected";
14
15
  /** Whether this model goes to another host than the engine's own account. */
@@ -21,5 +22,13 @@ export function restScope(candidate, model) {
21
22
  return undefined;
22
23
  return injectedModel(model) ? INJECTED_SCOPE : modelProvider(candidate, model);
23
24
  }
25
+ /** The scope of a rest for one model its account may not use, on an engine
26
+ * with no providers to rest instead (Claude, Codex): `model:<id>`. */
27
+ export const modelScope = (model) => (model ? `model:${model}` : undefined);
28
+ /** That scope when the failure is a model refusal (a plan that does not open
29
+ * the model, an unknown id; model-access-refusal.ts), else undefined. Without
30
+ * it the rest had no scope and one bot on a refused model benched every bot
31
+ * on the engine's other models. */
32
+ export const refusedModelScope = (message, model) => (message && isModelAccessRefused(message) ? modelScope(model) : undefined);
24
33
  /** Whether the engine's account state (signed out, resting) stops this model. */
25
34
  export const accountStops = (model) => !injectedModel(model);
@@ -0,0 +1,62 @@
1
+ // When a provider's 401/403 means "signed out" and when it means "this
2
+ // model is not open to you" (server/engine-failure.ts reads both).
3
+ //
4
+ // Written 2026-11-10 while chasing "Claude needs sign-in" on a Mac whose
5
+ // Claude subscription was active. That stop turned out to be a real expired
6
+ // login (the borrowed Anthropic profile token; see isolateAnthropicProfile in
7
+ // server/drivers/claude-auth-status.ts), not a misread. What stays here is the
8
+ // guard the search showed was missing: the sign-in patterns matched a bare
9
+ // 401 or 403 anywhere in the text, and a model the signed-in plan does not
10
+ // open is not fixed by a new sign-in, so it must not rest the whole account.
11
+ /** A 401 or 403 that is a failed sign-in: written as a status ("API Error:
12
+ * 401", "HTTP 403", "status 401") or beside sign-in words, never a bare
13
+ * number in a usage, plan or new-model message. */
14
+ export const AUTH_STATUS = [
15
+ // "API Error: 401", "HTTP 403", "HTTP/1.1 403", "status code 401", "error
16
+ // code: 403", JSON "status":401. A bare "code" is not enough ("exited with
17
+ // code 403" is a process), and neither is a count ("Error 403 files").
18
+ /\b(?:api error|http(?:\/\d(?:\.\d)?)?|(?:status|error|response)(?:[ _]?code)?)\b["\s:=([]*40[13]\b(?!\s+(?:of|files?|rows?|items?|messages?|tokens?|results?|lines?|bytes|tests?|errors?|warnings?|seconds?|minutes?|ms|times)\b)|"code"\s*:\s*40[13]\b/i,
19
+ // OpenCode's ACP shape, "Upstream request failed: [401] ...". The bracket
20
+ // alone is not a status: "[403] indexing files" is a log line.
21
+ /\b(?:failed|error|rejected)\b[^\n[]{0,12}\[40[13]\]/i,
22
+ // "Request failed with 401", "Request failed (403)": the number ends the
23
+ // thought.
24
+ /\b(?:failed|rejected|responded|answered)(?: with)?(?: (?:a|an|status|http|code))* \(?40[13]\)?(?=\s*(?:$|[.,;:)\]]|from\b|error\b|response\b))/i,
25
+ // "received 403 from upstream". These verbs also count things ("returned
26
+ // 401."), so the number needs what it came from.
27
+ /\b(?:returned|received|got) (?:a |an )?\(?40[13]\)?(?=\s*(?:from\b|error\b|response\b))/i,
28
+ /\b40[13]\b[^\n]{0,160}\b(?:unauthori[sz]ed|unauthenticated|authenticat\w*|api[ _-]?key|oauth|(?:access |bearer )?token|credentials?|log(?:ged)?[ -]?in|sign(?:ed)?[ -]?in)\b/i,
29
+ ];
30
+ // The shapes read. The second is Claude Code's own wording; the first is the
31
+ // Anthropic API's permission_error shape and was not captured from a live
32
+ // failure:
33
+ // "API Error: 403 {"type":"error","error":{"type":"permission_error",
34
+ // "message":"Your plan does not include access to claude-fable-5-2."}}"
35
+ // "There's an issue with the selected model (claude-fable-5-2). It may not
36
+ // exist or you may not have access to it. Run /model to pick a different
37
+ // model."
38
+ // Every pattern needs the word "model" or a model's own name. A product name
39
+ // alone does not count: "Your account does not have access to Claude. Please
40
+ // login again" is the wrong account signed in, which is a sign-in.
41
+ const MODEL_NAME = "model|claude-[\\w.-]+|gpt-[\\w.-]+|gemini-[\\w.-]+|grok-[\\w.-]+|opus|sonnet|haiku|fable";
42
+ const MODEL_ACCESS_REFUSED = [
43
+ /\bissue with the selected model\b|\bmodel\b[^\n]{0,120}\b(?:may|does) not exist or you (?:may |do )?not have access\b/i,
44
+ /\b(?:do(?:es)?n['’]?t|do(?:es)? not) (?:currently )?have access to (?:the |this |that )?(?:model\b|claude-|gpt-|gemini-|grok-|o\d)/i,
45
+ new RegExp(`\\b(?:plan|subscription|organi[sz]ation|account|tier) (?:does not|doesn['’]?t) (?:include|support|allow|have access to)\\b[^.\\n]{0,80}\\b(?:${MODEL_NAME})\\b`, "i"),
46
+ /\b(?:model|claude-[\w.-]+|opus|sonnet|haiku|fable)\b(?:[^.\n]|\.\d){0,80}\b(?:is |are )?(?:not available|unavailable|not included|not enabled|not supported) (?:on|in|for|with) (?:your|this|the) (?:current )?(?:plan|subscription|account|organi[sz]ation|tier)\b/i,
47
+ /\bmodel_not_found\b|\bnot_found_error\b[^\n]{0,200}\bmodel\b|\bmodel\b[^\n]{0,40}\bnot_found_error\b/i,
48
+ new RegExp(`\\bpermission_error\\b[^\\n]{0,240}\\b(?:${MODEL_NAME})\\b`, "i"),
49
+ ];
50
+ // Real sign-in or dead-credential words win, whatever model the message
51
+ // names: "OAuth token expired", "token has been revoked", "login again",
52
+ // "OAuth token does not meet scope requirement".
53
+ const SIGN_IN_WORDS = /\bnot (?:logged|signed) in\b|\b(?:please )?run \/login\b|\blog ?in again\b|\bsign ?in again\b|\bre-?authenticat\w*|\b(?:login|sign-?in|token|session|credentials?) (?:has |have )?expired\b|\b(?:token|key|credentials?|session) (?:has |have |was |were )?(?:been )?revoked\b|\bauthentication_error\b|\boauth\b|\bscope requirement\b|\binvalid[ _-]?(?:x-)?api[ _-]?key\b|\bkey (?:has |was )?(?:been )?(?:expired|revoked)\b/i;
54
+ /** Whether the text says the signed-in account may not use this model (a
55
+ * plan, organization or model-id refusal). That model rests
56
+ * (request_rejected, scoped to it); the login and the engine's other models
57
+ * stay good. */
58
+ export function isModelAccessRefused(text) {
59
+ if (!text || SIGN_IN_WORDS.test(text))
60
+ return false;
61
+ return MODEL_ACCESS_REFUSED.some((pattern) => pattern.test(text));
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chibitek/chibi",
3
- "version": "0.1.184",
3
+ "version": "0.1.185",
4
4
  "description": "Atomic by Chibitek: run your AI team's server anywhere and pair your devices to it",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-CcefVt63.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1,8 +0,0 @@
1
- import{c as r,s as e}from"./flowDiagram-KWPJA3E3-DtiBETZe.js";import{_ as a}from"./mermaid.core-CcefVt63.js";import"./chunk-5VM5RSS4-O-aALIul.js";import"./chunk-XXDRQBXY-s_OT2iv7.js";import"./chunk-WEXAMYUT-BYXYAyMu.js";import"./chunk-GWA4HPMP-FzFr6U_I.js";import"./channel-DaRjZag9.js";import"./index-COCy7XsD.js";var o=a(t=>`${e(t)}
2
- .swimlane.cluster:not([data-color-id]) rect {
3
- stroke: ${t.clusterBorder} !important;
4
- }
5
- [data-look="neo"].cluster rect {
6
- filter: none;
7
- }
8
- `,"getStyles"),s=o,u=r({styles:s});export{u as diagram};