@chibitek/chibi 0.1.192 → 0.1.194

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 (93) hide show
  1. package/dist/assets/{TerminalPanel-PcPGVxjJ.js → TerminalPanel-k-bNNesV.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-CrdtKXgW.js → abnfDiagram-O67JEVCF-dJ7qt3uJ.js} +1 -1
  3. package/dist/assets/{arc-DZp6zTLS.js → arc-EddF6kP_.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-By4YaF8p.js → architectureDiagram-NJMV4G6O-UeAIAzq1.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-b9XT0BEX.js → blockDiagram-BEXU5L5S-CFb6JiNj.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-ClDc6UCa.js → c4Diagram-YGBWAQC7-1hMBdQdo.js} +1 -1
  7. package/dist/assets/channel-BWPQj1aN.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-D8FDC39i.js → chunk-2Q5K7J3B-DNrbOG-A.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-_Lb0IVFX.js → chunk-3FUC2YCW-BxPQB9CL.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-f7re7-dy.js → chunk-5VM5RSS4-B1komt_B.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-Cl4oAWQ1.js → chunk-GTNCS2PH-CxvRNuCM.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-CLO3k8zE.js → chunk-GWA4HPMP-Du9NeFCS.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-kXWDfQP-.js → chunk-JWPE2WC7-SQ6yowId.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-DPtewwHN.js → chunk-NETBCI7D-Bf5p4Mwp.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-B17lA9FX.js → chunk-WEXAMYUT-CGfgwr4k.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-B6RbRjkG.js → chunk-XXDRQBXY-DQiWv_eF.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-BrZPolTO.js → classDiagram-v2-NBCMYWYE-CKfM0GgR.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-DAvSQrfJ.js → cose-bilkent-JH36ORCC-E32mrb9n.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-BBEKoW-B.js → cynefin-OW5HDTMX-BmJl13re.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-DTeD9b7A.js → cynefinDiagram-VND7K2PF-BQmysSe8.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-7Lem_oJB.js → dagre-6A5THRUB-Bvix6bhv.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-BBMu1DQ4.js → diagram-22UHCM2B-DMb3_2Yw.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-wTBd45sT.js → diagram-3UASUU5V-C2G2lJWB.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-DejXVMcb.js → diagram-ATOU4E4O-Cnk0-r8a.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-CqYId1m8.js → diagram-CDSNMT55-iWUk11Ac.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-DrOnQ-Zt.js → diagram-MLGK6HIB-pQNwgrXs.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-CHDvidFk.js → diagram-MPIPVDR6-DyGbBWiA.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-BzwpPn5m.js → ebnfDiagram-ZINNZB2B-DQ3Ni6jW.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-E1HDqzYH.js → elk-276RUBZZ-DHKJu9Iv.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-D5E6uaT3.js → erDiagram-OPXOYQCR-PEPG1pKr.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-R1exlkB4.js → flowDiagram-KWPJA3E3-WUiDjhuX.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-B5kjMGRd.js → ganttDiagram-FUAMR5RP-XYcSw8XW.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-BqkJtDvq.js → gitGraphDiagram-X574FWY7-CPDsEL6v.js} +1 -1
  34. package/dist/assets/{index-DvEhLbPJ.js → index-7tft1G3w.js} +1 -1
  35. package/dist/assets/{index-D_WPT1i-.js → index-CzsF5HT1.js} +163 -163
  36. package/dist/assets/{infoDiagram-VRGFBTTK-LXwGqqoO.js → infoDiagram-VRGFBTTK-DA4G5Ada.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-D_E17iEV.js → ishikawaDiagram-OU5B5YK6-CLhBborF.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-BkKKJrLR.js → journeyDiagram-ZHPQQLJL-BoeIpfES.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-y6rjCvyW.js → kanban-definition-PNTS6WVX-BF2VlALx.js} +1 -1
  40. package/dist/assets/{linear-BYdFcAFG.js → linear-DGY-eezc.js} +1 -1
  41. package/dist/assets/{mermaid.core-BZnTzEV7.js → mermaid.core-BU5DAfrM.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-HPM-ymN0.js → mindmap-definition-NLK3R4M7-ldVJZIOj.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-X2YHQQDC.js → pegDiagram-GJSIUBJH-dS2C3m-e.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-FQ47RvEb.js → pieDiagram-5QR66LMP-BeX9hffn.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-CZok45i-.js → quadrantDiagram-O4NWA36T-gBxWQRkY.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-CkzgSbiA.js → railroadDiagram-XR7U4H2S-BSOKMMuc.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-B96vOB2k.js → requirementDiagram-PLB6GJNP-Cq4KZXOJ.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-C3OzzNBk.js → sankeyDiagram-IPEJSGJF-C59BLmfb.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-UEjwqc9C.js → sequenceDiagram-PO4LG4MO-De8iVPzU.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-CYlsATAn.js → sizeCapture-INFHLROL-CJLc7kKW.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-i3kPrA1F.js → stateDiagram-v2-GCMORJYK-BQkW_Cs-.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-CwxGl-A-.js → swimlanes-2SLR337P-CDPrdFPs.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-CCgmD5dO.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-B-CIp72A.js → timeline-definition-EJHVYXUP-VJExKP0a.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-CvI2j7z-.js → usecaseDiagram-POWQR4AR-A_h0-hH3.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U--l2Nr666.js → vennDiagram-UO4OBE2U-LeRZF6GK.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-C_WERxNO.js → wardleyDiagram-VNRHLVJA-BtQte254.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-VoRUD4V6.js → xychartDiagram-PMCCYNJV-C5Sdyn-i.js} +1 -1
  59. package/dist/index.html +1 -1
  60. package/dist-server/container-mcp.js +83 -82
  61. package/dist-server/drivers/agents-proxy.js +81 -81
  62. package/dist-server/index.js +905 -531
  63. package/dist-server/mcp-server.js +36 -1
  64. package/dist-server/openmausbot.js +784 -595
  65. package/dist-server/pair-cli.js +784 -595
  66. package/dist-server/server/atomic-engine-accounts.js +64 -12
  67. package/dist-server/server/atomic-engine-classes.js +30 -0
  68. package/dist-server/server/atomic-engine-local.js +41 -0
  69. package/dist-server/server/chibi-defaults.js +14 -8
  70. package/dist-server/server/config.js +1 -1
  71. package/dist-server/server/default-model-selection.js +7 -0
  72. package/dist-server/server/drivers/acp/custom.js +7 -2
  73. package/dist-server/server/editor-connect.js +39 -2
  74. package/dist-server/server/engine-tiers.js +19 -19
  75. package/dist-server/server/harness-import/engine-policy.js +4 -3
  76. package/dist-server/server/index.js +13 -13
  77. package/dist-server/server/model-gateway/failover.js +44 -0
  78. package/dist-server/server/model-gateway/ladder.js +29 -0
  79. package/dist-server/server/model-gateway/route.js +104 -0
  80. package/dist-server/server/plan-credit.js +67 -0
  81. package/dist-server/server/provider-accounts.js +3 -0
  82. package/dist-server/server/request-auth.js +3 -0
  83. package/dist-server/server/routes/provider-accounts.js +46 -5
  84. package/dist-server/server/session-fallback.js +76 -0
  85. package/dist-server/shared/atomic-auto.js +10 -0
  86. package/dist-server/shared/engine-tiers.js +24 -8
  87. package/dist-server/shared/harness-weights.js +3 -1
  88. package/dist-server/shared/provider-accounts.js +42 -5
  89. package/dist-server/shared/vault-api-providers.js +9 -2
  90. package/dist-server/vps-container-mcp.js +83 -82
  91. package/package.json +1 -1
  92. package/dist/assets/channel-CP6zTF5h.js +0 -1
  93. package/dist/assets/swimlanesDiagram-TC7HE7FX-BxG6JDb-.js +0 -8
@@ -0,0 +1,44 @@
1
+ // Try the next model before the first byte reaches the harness, never after
2
+ // (docs/specs/atomic-model-source, Testing strategy). Pure apart from the
3
+ // `send` it is handed, so tests drive it with a fake upstream.
4
+ import { classifyEngineFailure } from "../engine-failure.js";
5
+ const REST_MS = 10 * 60_000;
6
+ /** Statuses that mean "this model cannot answer right now", worth the next one. */
7
+ export function failsOver(status, body) {
8
+ if (status === 401 || status === 402 || status === 403 || status === 404 || status === 408 || status === 429 || status >= 500)
9
+ return true;
10
+ return status >= 400 && classifyEngineFailure(body) !== null;
11
+ }
12
+ /** A model that hit a limit rests a while, so the next request starts lower. */
13
+ export class GatewayRests {
14
+ until = new Map();
15
+ now;
16
+ constructor(now = Date.now) { this.now = now; }
17
+ rest(model, ms = REST_MS) { this.until.set(model, this.now() + ms); }
18
+ resting = (model) => (this.until.get(model) ?? 0) > this.now();
19
+ }
20
+ export async function firstAnswer(models, send, rests) {
21
+ const failovers = [];
22
+ let last = { status: 404, error: "No model is available behind Atomic right now. Start Ollama, or sign in to Ollama for its cloud models." };
23
+ for (const model of models) {
24
+ let response;
25
+ try {
26
+ response = await send(model);
27
+ }
28
+ catch (error) {
29
+ failovers.push(model);
30
+ last = { status: 502, error: `Ollama did not answer (${error.message}).` };
31
+ continue;
32
+ }
33
+ if (response.ok)
34
+ return { ok: true, model, response, failovers };
35
+ const body = await response.text().catch(() => "");
36
+ if (!failsOver(response.status, body))
37
+ return { ok: true, model, response: new Response(body, { status: response.status, headers: response.headers }), failovers };
38
+ if (response.status === 429 || response.status === 402)
39
+ rests?.rest(model);
40
+ failovers.push(model);
41
+ last = { status: response.status, error: `${model} could not answer (${response.status}).` };
42
+ }
43
+ return { ok: false, ...last, failovers };
44
+ }
@@ -0,0 +1,29 @@
1
+ // The order `atomic/auto` walks when Claude Code or Codex use Atomic as a
2
+ // model source (docs/specs/atomic-model-source). Pure, so it tests without a
3
+ // server. Only models the local Ollama daemon serves are here: its `:cloud`
4
+ // models run on the Ollama Teams subscription, the rest run on this computer.
5
+ // Claude and ChatGPT sign-ins are never behind the gateway (spec, Boundaries).
6
+ export const ATOMIC_AUTO_GATEWAY_MODEL = "atomic/auto";
7
+ /** Erick's locked backup order (spec, Open questions): first when served. */
8
+ export const LOCKED_CLOUD_ORDER = ["glm-5.3:cloud", "deepseek-v4-pro:cloud", "qwen3.5:cloud"];
9
+ const isCloud = (model) => /(^|[:-])cloud$/.test(model);
10
+ /** Subscription first (the locked cloud order, then every other `:cloud`
11
+ * model in the order Ollama lists them), then local models. A model that is
12
+ * resting after a usage or rate limit is skipped; when every model rests the
13
+ * whole list is tried anyway, since a rest is only an estimate. */
14
+ export function autoLadder(available, resting = () => false, locked = LOCKED_CLOUD_ORDER) {
15
+ const unique = [...new Set(available.filter((model) => model && model !== ATOMIC_AUTO_GATEWAY_MODEL))];
16
+ const ordered = [
17
+ ...locked.filter((model) => unique.includes(model)),
18
+ ...unique.filter((model) => isCloud(model) && !locked.includes(model)),
19
+ ...unique.filter((model) => !isCloud(model)),
20
+ ];
21
+ const awake = ordered.filter((model) => !resting(model));
22
+ return awake.length ? awake : ordered;
23
+ }
24
+ /** What one request walks: the ladder for `atomic/auto`, else the one model asked for. */
25
+ export function modelsFor(asked, available, resting) {
26
+ if (asked === ATOMIC_AUTO_GATEWAY_MODEL)
27
+ return autoLadder(available, resting);
28
+ return available.includes(asked) ? [asked] : [];
29
+ }
@@ -0,0 +1,104 @@
1
+ // Atomic as a model source for Claude Code and Codex: the model id
2
+ // `atomic/auto` (docs/chibitek/model-source.md, docs/specs/atomic-model-source).
3
+ // GET /api/v1/models atomic/auto, then every model Ollama serves
4
+ // POST /api/v1/responses OpenAI Responses (Codex)
5
+ // POST /api/v1/chat/completions OpenAI Chat Completions (OpenCode, Cline)
6
+ // POST /api/v1/messages Anthropic Messages (Claude Code, ANTHROPIC_BASE_URL)
7
+ // Each call is passed through to the local Ollama daemon unchanged except for
8
+ // the model, walking the `atomic/auto` ladder until one model answers; the
9
+ // caller's token never leaves Atomic. Loopback only, and only with a
10
+ // connected assistant's token (request-auth.ts ASSISTANT_ALLOW). Prompt and
11
+ // completion text are never logged. Under /api/ because the static app
12
+ // answers every other GET path.
13
+ import { Readable } from "node:stream";
14
+ import { hostApiKey, localHost } from "../drivers/local-inject.js";
15
+ import { PASS } from "../routes/table.js";
16
+ import { firstAnswer, GatewayRests } from "./failover.js";
17
+ import { ATOMIC_AUTO_GATEWAY_MODEL, modelsFor } from "./ladder.js";
18
+ const PREFIX = "/api/v1/";
19
+ const PASS_THROUGH = new Set(["responses", "chat/completions", "messages"]);
20
+ const MAX_BODY = 32 * 1024 * 1024;
21
+ const LOOPBACK = new Set(["127.0.0.1", "::1", "::ffff:127.0.0.1", "localhost"]);
22
+ /** The socket and the Host header both name this computer. */
23
+ export function fromLoopback(remoteAddress, host) {
24
+ if (!remoteAddress || !LOOPBACK.has(remoteAddress))
25
+ return false;
26
+ if (!host)
27
+ return true;
28
+ const name = host.startsWith("[") ? host.slice(1, host.indexOf("]")) : host.replace(/:\d+$/, "");
29
+ return LOOPBACK.has(name.toLowerCase());
30
+ }
31
+ function ollama() {
32
+ const host = localHost("ollama");
33
+ return host ? { baseUrl: host.baseUrl.replace(/\/+$/, ""), apiKey: hostApiKey(host) } : null;
34
+ }
35
+ export function createModelGatewayRoutes(deps = {}) {
36
+ const fetchImpl = deps.fetchImpl ?? fetch;
37
+ const rests = deps.rests ?? new GatewayRests();
38
+ const log = deps.log ?? ((line) => console.info(line));
39
+ const upstream = () => (deps.upstream ?? ollama)();
40
+ async function served() {
41
+ const base = upstream();
42
+ if (!base)
43
+ return [];
44
+ try {
45
+ const res = await fetchImpl(`${base.baseUrl}/models`, { headers: base.apiKey ? { authorization: `Bearer ${base.apiKey}` } : {}, signal: AbortSignal.timeout(5_000) });
46
+ const body = res.ok ? await res.json() : {};
47
+ return (body.data ?? []).map((row) => row.id).filter((id) => typeof id === "string" && id.length > 0);
48
+ }
49
+ catch {
50
+ return [];
51
+ }
52
+ }
53
+ return async ({ req, res, path, method, auth, json, readBody }) => {
54
+ if (!path.startsWith(PREFIX))
55
+ return PASS;
56
+ const tail = path.slice(PREFIX.length);
57
+ if (!(tail === "models" && method === "GET") && !(PASS_THROUGH.has(tail) && method === "POST"))
58
+ return PASS;
59
+ if (!fromLoopback(req.socket.remoteAddress, req.headers.host))
60
+ return json(res, 403, { error: "Atomic's model source answers only on this computer." });
61
+ if (auth.kind !== "assistant")
62
+ return json(res, 401, { error: "Send a connected assistant's token from Atomic Settings → Connected assistants." });
63
+ const available = await served();
64
+ if (tail === "models") {
65
+ const ids = [ATOMIC_AUTO_GATEWAY_MODEL, ...available];
66
+ return json(res, 200, { object: "list", data: ids.map((id) => ({ id, object: "model", owned_by: id === ATOMIC_AUTO_GATEWAY_MODEL ? "atomic" : "ollama", ...(id === ATOMIC_AUTO_GATEWAY_MODEL ? { display_name: "Atomic Engine (Auto)" } : {}) })) });
67
+ }
68
+ let body;
69
+ try {
70
+ body = await readBody(req, MAX_BODY);
71
+ }
72
+ catch (error) {
73
+ return json(res, error.status ?? 400, { error: error.message });
74
+ }
75
+ const asked = typeof body.model === "string" ? body.model : "";
76
+ const models = modelsFor(asked, available, rests.resting);
77
+ if (!models.length) {
78
+ return json(res, 404, { error: available.length ? `Atomic does not serve "${asked}". Use ${ATOMIC_AUTO_GATEWAY_MODEL} or a model from /api/v1/models.` : "No model is available behind Atomic right now. Start Ollama, or sign in to Ollama for its cloud models." });
79
+ }
80
+ const base = upstream();
81
+ const headers = { "content-type": "application/json" };
82
+ if (base.apiKey)
83
+ headers.authorization = `Bearer ${base.apiKey}`;
84
+ if (tail === "messages") {
85
+ headers["x-api-key"] = base.apiKey ?? "ollama";
86
+ headers["anthropic-version"] = String(req.headers["anthropic-version"] ?? "2023-06-01");
87
+ }
88
+ const answer = await firstAnswer(models, (model) => fetchImpl(`${base.baseUrl}/${tail}`, { method: "POST", headers, body: JSON.stringify({ ...body, model }) }), rests);
89
+ log(`[model-gateway] ${tail} asked=${asked} used=${answer.ok ? answer.model : "none"} failovers=${answer.failovers.join(",") || "none"}`);
90
+ if (!answer.ok)
91
+ return json(res, answer.status === 404 ? 503 : answer.status, { error: answer.error });
92
+ const type = answer.response.headers.get("content-type") ?? "application/json";
93
+ res.writeHead(answer.response.status, { "content-type": type, "cache-control": "no-cache", "x-atomic-model": answer.model });
94
+ if (!answer.response.body)
95
+ return void res.end();
96
+ // Past the first byte there is no failing over: the harness has started reading.
97
+ await new Promise((resolve) => {
98
+ const stream = Readable.fromWeb(answer.response.body);
99
+ stream.on("error", () => { res.destroy(); resolve(); });
100
+ res.on("close", () => { stream.destroy(); resolve(); });
101
+ stream.pipe(res).on("finish", () => resolve());
102
+ });
103
+ };
104
+ }
@@ -0,0 +1,67 @@
1
+ // Included monthly credit on a provider account (shared/provider-accounts.ts,
2
+ // PlanTerms "includedCredit"). Ollama's Team plan includes $1,000 a month;
3
+ // unused credit is lost at month end and use past it is billed by Ollama
4
+ // (Erick, 2026-11-15). Atomic tracks the credit against its own usage ledger
5
+ // (server/usage-ledger.ts): the reported or estimated cost of every turn that
6
+ // account ran this calendar month (UTC, like the spend cap in server/spend.ts).
7
+ // While credit is left the account is a subscription. Once it is used up an
8
+ // overage plan walks with the pay-per-use keys, so the one-time pay-per-use
9
+ // notice opens before any overage is spent. The month rolls over on its own:
10
+ // nothing carries over.
11
+ import { accountProvider, billingWithCredit, planTerms } from "../shared/provider-accounts.js";
12
+ import { readUsage } from "./usage-ledger.js";
13
+ const CACHE_MS = 15_000;
14
+ const cache = new Map();
15
+ const monthOf = (now) => now.toISOString().slice(0, 7);
16
+ const costOf = (value) => (typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0);
17
+ /** Cost booked this month per engine instance, read at most every CACHE_MS. */
18
+ export function monthToDateByInstance(dataDir, now = new Date()) {
19
+ const month = monthOf(now);
20
+ const hit = cache.get(dataDir);
21
+ if (hit && hit.month === month && now.getTime() - hit.at < CACHE_MS)
22
+ return hit.byInstance;
23
+ const from = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
24
+ const byInstance = new Map();
25
+ for (const row of readUsage(dataDir, { from, to: now })) {
26
+ byInstance.set(row.instanceId, (byInstance.get(row.instanceId) ?? 0) + costOf(row.costUsd));
27
+ }
28
+ cache.set(dataDir, { at: now.getTime(), month, byInstance });
29
+ return byInstance;
30
+ }
31
+ /** Forget the cached month (tests, and after a ledger restore). */
32
+ export function resetPlanCreditCache() {
33
+ cache.clear();
34
+ }
35
+ /** The provider an instance is paid through: its added account, else the
36
+ * key-based provider whose driver it runs (the Ollama Cloud main key). */
37
+ function providerOf(entry) {
38
+ if (entry.account !== undefined)
39
+ return accountProvider(entry.account);
40
+ return accountProvider(entry.driver === "ollamaCloud" ? "ollamaCloud" : undefined);
41
+ }
42
+ /** This account's credit this month, when it has an included-credit plan and
43
+ * a monthly figure (the account's own, else the plan's). Undefined otherwise:
44
+ * then the account is paid exactly as its provider row says. */
45
+ export function planCredit(instanceId, entry, spent) {
46
+ const provider = providerOf(entry);
47
+ if (!provider)
48
+ return undefined;
49
+ const terms = planTerms(provider);
50
+ if (terms.kind !== "includedCredit")
51
+ return undefined;
52
+ const monthlyCreditUsd = entry.planCreditUsd ?? terms.monthlyCreditUsd;
53
+ if (monthlyCreditUsd === undefined || !(monthlyCreditUsd > 0))
54
+ return undefined;
55
+ const spentUsd = spent.get(instanceId) ?? 0;
56
+ const leftUsd = Math.max(0, monthlyCreditUsd - spentUsd);
57
+ return { monthlyCreditUsd, spentUsd, leftUsd, billing: billingWithCredit(terms, monthlyCreditUsd - spentUsd) };
58
+ }
59
+ /** How an engine is paid now: its included credit while that decides, else
60
+ * the billing of the provider account it was added as. Undefined for an
61
+ * engine that is not an account and has no credit (its driver decides). */
62
+ export function accountBilling(instanceId, entry, dataDir) {
63
+ if (!entry)
64
+ return undefined;
65
+ const credit = planCredit(instanceId, entry, monthToDateByInstance(dataDir));
66
+ return credit?.billing ?? (entry.account === undefined ? undefined : accountProvider(entry.account)?.billing);
67
+ }
@@ -26,6 +26,9 @@ export const addAccountSchema = z.object({
26
26
  owner: z.enum(["company", "personal"]).optional(),
27
27
  }).strict();
28
28
  export const renameAccountSchema = z.object({ displayName }).strict();
29
+ /** PATCH body that sets (a number) or clears (null) an account's included
30
+ * monthly credit. */
31
+ export const planCreditSchema = z.object({ planCreditUsd: z.number().positive().max(1_000_000).nullable() }).strict();
29
32
  export const accountKeySchema = z.object({ key }).strict();
30
33
  const DEFAULT_HOME = {
31
34
  CODEX_HOME: ".codex",
@@ -338,6 +338,9 @@ export const ASSISTANT_ALLOW = [
338
338
  { methods: ["POST"], path: /^\/api\/groups\/[\w-]+\/messages$/ },
339
339
  { methods: ["POST"], path: /^\/api\/bots$/, create: true },
340
340
  { methods: ["POST"], path: /^\/api\/groups$/, create: true },
341
+ // Atomic as a model source, `atomic/auto` (server/model-gateway/route.ts).
342
+ { methods: ["GET"], path: /^\/api\/v1\/models$/ },
343
+ { methods: ["POST"], path: /^\/api\/v1\/(?:responses|chat\/completions|messages)$/ },
341
344
  ];
342
345
  export function assistantAllowed(method, path, assistant) {
343
346
  const upper = method.toUpperCase();
@@ -1,16 +1,26 @@
1
- import { ACCOUNT_PROVIDERS, accountProvider } from "../../shared/provider-accounts.js";
1
+ import { ACCOUNT_PROVIDERS, accountProvider, planTerms } from "../../shared/provider-accounts.js";
2
+ import { monthToDateByInstance, planCredit, resetPlanCreditCache } from "../plan-credit.js";
2
3
  import { persistableInstanceConfigs } from "../config.js";
3
4
  import { instanceKeys, removeInstanceKey, saveInstanceKey } from "../instance-keys.js";
4
- import { accountHome, accountKeySchema, accountProviderFor, addAccountSchema, homeSignInCommand, newApiKeyAccount, newSignInAccount, renameAccountSchema, } from "../provider-accounts.js";
5
+ import { accountHome, accountKeySchema, accountProviderFor, addAccountSchema, homeSignInCommand, newApiKeyAccount, newSignInAccount, planCreditSchema, renameAccountSchema, } from "../provider-accounts.js";
5
6
  import { PASS } from "./table.js";
6
7
  const ACCOUNT = /^\/api\/provider-accounts\/([\w.-]+)(?:\/(key|test))?$/;
7
8
  function removable(instanceId, entry) {
8
9
  // Claude accounts added before this registry carry no marker.
9
10
  return entry.account !== undefined || (entry.driver === "claudeAgent" && instanceId !== "claude");
10
11
  }
11
- function account(provider, instanceId, entry, described, owner) {
12
+ /** An included-credit account's figure and this month's use of it. */
13
+ function creditFields(instanceId, entry, spent) {
14
+ const credit = planCredit(instanceId, entry, spent);
15
+ return {
16
+ ...(entry.planCreditUsd !== undefined ? { planCreditUsd: entry.planCreditUsd } : {}),
17
+ ...(credit ? { planCredit: credit } : {}),
18
+ };
19
+ }
20
+ function account(provider, instanceId, entry, described, owner, spent) {
12
21
  const tag = owner?.(instanceId);
13
22
  const base = {
23
+ ...(planTerms(provider).kind === "includedCredit" ? creditFields(instanceId, entry, spent) : {}),
14
24
  instanceId,
15
25
  ...(tag ? { owner: tag.owner, ownerLocked: tag.locked } : {}),
16
26
  displayName: described?.displayName ?? entry.displayName ?? provider.label,
@@ -44,6 +54,10 @@ function account(provider, instanceId, entry, described, owner) {
44
54
  async function listing(deps) {
45
55
  const instances = persistableInstanceConfigs(deps.config());
46
56
  const described = new Map((await deps.describe()).map((instance) => [instance.instanceId, instance]));
57
+ const spent = monthToDateByInstance(deps.dataDir);
58
+ // The Ollama Cloud key saved before accounts existed runs the built-in
59
+ // ollamaCloud engine, not an added account: its credit is listed here.
60
+ const mainOllama = Object.entries(instances).find(([, entry]) => entry.driver === "ollamaCloud" && entry.account === undefined);
47
61
  return {
48
62
  providers: ACCOUNT_PROVIDERS.map((provider) => ({
49
63
  id: provider.id,
@@ -56,7 +70,10 @@ async function listing(deps) {
56
70
  ...(provider.signupUrl ? { signupUrl: provider.signupUrl } : {}),
57
71
  accounts: Object.entries(instances)
58
72
  .filter(([, entry]) => accountProviderFor(entry)?.id === provider.id)
59
- .map(([instanceId, entry]) => account(provider, instanceId, entry, described.get(instanceId), deps.owner)),
73
+ .map(([instanceId, entry]) => account(provider, instanceId, entry, described.get(instanceId), deps.owner, spent)),
74
+ ...(provider.id === "ollamaCloud" && mainOllama
75
+ ? { main: { instanceId: mainOllama[0], ...creditFields(mainOllama[0], mainOllama[1], spent) } }
76
+ : {}),
60
77
  })),
61
78
  };
62
79
  }
@@ -186,7 +203,31 @@ export function createProviderAccountRoutes(deps) {
186
203
  if (!entry || (!provider && method !== "PATCH"))
187
204
  return json(res, 404, { error: "unknown account" });
188
205
  if (method === "PATCH") {
189
- const parsed = renameAccountSchema.safeParse(await readBody(req, 8_192));
206
+ const body = await readBody(req, 8_192);
207
+ if (body && typeof body === "object" && Object.hasOwn(body, "planCreditUsd")) {
208
+ const credit = planCreditSchema.safeParse(body);
209
+ if (!credit.success)
210
+ return json(res, 400, { error: "Enter the plan's monthly credit in dollars, more than 0." });
211
+ const paidThrough = entry.account !== undefined ? provider : entry.driver === "ollamaCloud" ? accountProvider("ollamaCloud") : undefined;
212
+ if (!paidThrough || planTerms(paidThrough).kind !== "includedCredit") {
213
+ return json(res, 400, { error: "This account's plan has no included monthly credit." });
214
+ }
215
+ if (!deps.lock())
216
+ return json(res, 409, { error: "Provider settings are already being updated." });
217
+ try {
218
+ if (credit.data.planCreditUsd === null)
219
+ delete entry.planCreditUsd;
220
+ else
221
+ entry.planCreditUsd = credit.data.planCreditUsd;
222
+ await deps.persist(instanceId, instances);
223
+ resetPlanCreditCache(); // show this month's use as of now
224
+ return json(res, 200, await listing(deps));
225
+ }
226
+ finally {
227
+ deps.unlock();
228
+ }
229
+ }
230
+ const parsed = renameAccountSchema.safeParse(body);
190
231
  if (!parsed.success)
191
232
  return json(res, 400, { error: "Enter an account name (up to 80 characters)." });
192
233
  if (deps.busy(instanceId))
@@ -0,0 +1,76 @@
1
+ // Session fallback for company subscription bots (docs/chibitek/engine-tiers.md,
2
+ // "Subscription bots: the one failover exception"). When no account of the
3
+ // bot's own provider can take a turn, one conversation may run on the same
4
+ // class from another provider's subscription for up to SESSION_FALLBACK_TURNS
5
+ // turns. The bot's own default never changes; the next turn tries its own
6
+ // provider first again.
7
+ import { SESSION_FALLBACK_TURNS } from "../shared/subscription-bots.js";
8
+ export { SESSION_FALLBACK_TURNS };
9
+ // ponytail: in memory, so a restart gives a conversation its 50 turns again;
10
+ // persist on the task record if that matters.
11
+ const fallbacks = new Map();
12
+ /** The thread's own provider took this turn: it leaves the fallback (its count stays). */
13
+ export function leaveSessionFallback(threadId) {
14
+ const entry = fallbacks.get(threadId);
15
+ if (entry)
16
+ entry.active = false;
17
+ }
18
+ /** Enter (or stay on) the fallback for this thread. A new turn counts one;
19
+ * a failover within a turn already on it counts nothing. False once the
20
+ * conversation has used its turns. */
21
+ export function enterSessionFallback(threadId, newTurn) {
22
+ const entry = fallbacks.get(threadId) ?? { turns: 0, active: false };
23
+ if (entry.active && !newTurn)
24
+ return true;
25
+ if (entry.turns >= SESSION_FALLBACK_TURNS) {
26
+ entry.active = false;
27
+ fallbacks.set(threadId, entry);
28
+ return false;
29
+ }
30
+ entry.turns += 1;
31
+ entry.active = true;
32
+ fallbacks.set(threadId, entry);
33
+ return true;
34
+ }
35
+ /** Turn start for a subscription bot: its own provider's engine (which
36
+ * leaves the fallback), else, on its stop, the fallback's, counted as a
37
+ * turn. No fallback keeps the stop; past the limit, `spent` of it. */
38
+ export function ownOrFallback(threadId, own, fallback, isStop, spent) {
39
+ try {
40
+ const choice = own();
41
+ leaveSessionFallback(threadId);
42
+ return choice;
43
+ }
44
+ catch (stop) {
45
+ if (!isStop(stop))
46
+ throw stop;
47
+ let choice;
48
+ try {
49
+ choice = fallback();
50
+ }
51
+ catch {
52
+ choice = undefined;
53
+ }
54
+ if (choice === undefined)
55
+ throw stop;
56
+ if (!enterSessionFallback(threadId, true))
57
+ throw spent(stop);
58
+ return choice;
59
+ }
60
+ }
61
+ export function onSessionFallback(threadId) {
62
+ return fallbacks.get(threadId)?.active === true;
63
+ }
64
+ export function sessionFallbackTurns(threadId) {
65
+ return fallbacks.get(threadId)?.turns ?? 0;
66
+ }
67
+ /** The bot as a fallback turn runs it: an ordinary company bot, so the
68
+ * ladder and every gate read it without the provider lock. */
69
+ export function withoutSubscription(bot) {
70
+ const { subscription: _subscription, ...rest } = bot;
71
+ return rest;
72
+ }
73
+ /** The line a company subscription bot stops with once its fallback turns are used. */
74
+ export function sessionFallbackSpentLine(line) {
75
+ return `${line} This conversation already used its ${SESSION_FALLBACK_TURNS} turns on another provider; download a handoff or hand it to another bot.`;
76
+ }
@@ -0,0 +1,10 @@
1
+ // "Atomic Engine (Auto)" (Erick, 2026-11-15): Automatic and Atomic Engine's
2
+ // own Auto are one choice. In Atomic's picker it is the top row of the class
3
+ // menu (a bot or thread on its tier's ladder, which Atomic Engine leads);
4
+ // other harnesses (Claude Code, Codex) see it as the model id `atomic/auto`.
5
+ // The short form "Atomic Engine Auto" is for tight spaces; the Atomic Engine
6
+ // name is never dropped.
7
+ export const ATOMIC_AUTO_MODEL = "atomic/auto";
8
+ /** Atomic Engine's model id before 2026-11-15; a saved one still means Auto. */
9
+ export const LEGACY_ATOMIC_ENGINE_MODEL = "agent-default";
10
+ export const isAtomicAuto = (model) => model === ATOMIC_AUTO_MODEL || model === LEGACY_ATOMIC_ENGINE_MODEL;
@@ -47,18 +47,30 @@ export const DEFAULT_CLASS_BANDS = { Mezcal: 50, Plata: 44, Reposado: 38 };
47
47
  * ("claude-<uuid>") reduced to its driver kind so a fresh install matches
48
48
  * whatever account it has (matchesEngine); the exact engine+model
49
49
  * duplicates that collapse created are dropped. */
50
- /** Chibi's default on every install (Erick, 2026-11-13): Automatic, the
51
- * Plata class, starting on Claude Sonnet 5.5. It is the first rung of the
52
- * Orchestrator's ladder, hand-written or generated, and the model Chibi is
53
- * made on. The rung carries its class, so failover treats it as Plata
54
- * whatever a leaderboard scores it. */
55
- export const CHIBI_DEFAULT_RUNG = Object.freeze({ engine: "claudeAgent", model: "claude-sonnet-5-5", modelClass: "Plata" });
50
+ /** Atomic Engine (Auto): the first rung of every tier's ladder, hand-written
51
+ * or generated, and the model Chibi and new bots are made on (Erick,
52
+ * 2026-11-15, replacing 2026-10-13's "Chibi runs on Claude"). The engine
53
+ * walks its own accounts (subscriptions, then local models, then pay per
54
+ * use) and fails over by itself; the rungs after it are the fallback when
55
+ * Atomic Engine is not installed, signed out or refused. */
56
+ export const ATOMIC_AUTO_RUNG = Object.freeze({ engine: "atomic-engine", model: "atomic/auto" });
57
+ /** Chibi's fallback on an install without Atomic Engine (Erick, 2026-11-13):
58
+ * Automatic, the Plata class, on Claude. It is the Orchestrator's rung right
59
+ * after Atomic Engine (Auto), hand-written or generated. The rung carries its
60
+ * class, so it must be a Plata model: Claude Opus 5 (Artificial Analysis
61
+ * medium 44.8, high 48.1: 46.5). It was Claude Sonnet 5.5 until 2026-11-15,
62
+ * which grades Reposado by Atomic's own rule (medium 40.8, high 46.8 on
63
+ * Intelligence Index v4.3.2: 43.8, under Plata's 44) and was only labelled
64
+ * Plata here. */
65
+ export const CHIBI_DEFAULT_RUNG = Object.freeze({ engine: "claudeAgent", model: "claude-opus-5", modelClass: "Plata" });
56
66
  /** Raised whenever Chibi's default changes: each install whose Chibi holds
57
67
  * an older number is put back on the default once, whatever it was set to
58
- * (BotRecord.chibiDefaults, server/store.ts applyChibiDefaults). */
59
- export const CHIBI_DEFAULTS_VERSION = 1;
68
+ * (BotRecord.chibiDefaults, server/store.ts applyChibiDefaults). 2: Atomic
69
+ * Engine (Auto) (2026-11-15). */
70
+ export const CHIBI_DEFAULTS_VERSION = 2;
60
71
  export const DEFAULT_LADDERS = {
61
72
  orchestrator: [
73
+ { ...ATOMIC_AUTO_RUNG },
62
74
  { ...CHIBI_DEFAULT_RUNG },
63
75
  { engine: "claudeAgent", model: "claude-opus-5-5", modelClass: "Plata" },
64
76
  { engine: "codex", model: "gpt-6-sol" },
@@ -77,6 +89,7 @@ export const DEFAULT_LADDERS = {
77
89
  { engine: "hermesAgent", model: "openai-codex:gpt-6.1-sol", modelClass: "Plata" },
78
90
  ],
79
91
  engineering: [
92
+ { ...ATOMIC_AUTO_RUNG },
80
93
  { engine: "codex", model: "gpt-6-astra", modelClass: "Mezcal" },
81
94
  { engine: "claude", model: "claude-opus-5-5" },
82
95
  { engine: "claudeAgent", model: "claude-opus-5-5" },
@@ -92,6 +105,7 @@ export const DEFAULT_LADDERS = {
92
105
  { engine: "cursorAgent", model: "auto" },
93
106
  ],
94
107
  research: [
108
+ { ...ATOMIC_AUTO_RUNG },
95
109
  { engine: "openai-compat", model: "MiniMax-M2.5" },
96
110
  { engine: "vibe", model: "mistral-medium-3.5" },
97
111
  { engine: "antigravityAgent", model: "gemini-3.8-flash-low" },
@@ -105,6 +119,7 @@ export const DEFAULT_LADDERS = {
105
119
  { engine: "opencodeGo", model: "opencode/claude-opus-5", modelClass: "Plata" },
106
120
  ],
107
121
  writing: [
122
+ { ...ATOMIC_AUTO_RUNG },
108
123
  { engine: "claudeAgent", model: "claude-sonnet-5-5" },
109
124
  { engine: "claude", model: "claude-sonnet-5-5" },
110
125
  { engine: "codex", model: "gpt-5.6-luna" },
@@ -113,6 +128,7 @@ export const DEFAULT_LADDERS = {
113
128
  { engine: "hermes", model: "nous:moonshotai/kimi-k3" },
114
129
  ],
115
130
  routine: [
131
+ { ...ATOMIC_AUTO_RUNG },
116
132
  { engine: "antigravityAgent", model: "gemini-3.8-flash-low" },
117
133
  { engine: "antigravity", model: "gemini-3.8-flash-low" },
118
134
  { engine: "openai-compat", model: "MiniMax-M2.5" },
@@ -12,7 +12,9 @@
12
12
  * wrapper with no agent loop of its own is lowest. */
13
13
  export const DEFAULT_HARNESS_WEIGHTS = {
14
14
  claudeAgent: 1, codex: 1, grokAgent: 1, antigravityAgent: 1, museCode: 1, kimiAgent: 1, vibeAgent: 1, qwenAgent: 1,
15
- hermesAgent: 0.9,
15
+ // Atomic Engine is Hermes under the hood, run on the person's Atomic
16
+ // accounts: the same weight (Erick, 2026-11-15).
17
+ hermesAgent: 0.9, atomicEngine: 0.9,
16
18
  cursorAgent: 0.8, opencodeGo: 0.8, droidAgent: 0.8,
17
19
  ollamaCloud: 0.5, "openai-compat": 0.5, mistral: 0.5, minimax: 0.5,
18
20
  };
@@ -60,16 +60,20 @@ export const ACCOUNT_PROVIDERS = [
60
60
  config: {}, keyTest: { provider: "mistral" }, keyUrl: "https://console.mistral.ai/api-keys",
61
61
  },
62
62
  {
63
- // Ollama's Free, Pro and Max plans; use past a plan's monthly credit is billed by Ollama.
63
+ // Ollama's Free, Pro, Max and Team plans each include a monthly credit.
64
+ // Unused credit does not carry over (use it or lose it); use past it is
65
+ // billed by Ollama (Erick, 2026-11-15).
64
66
  id: "ollamaCloud", kind: "apiKey", label: "Ollama Cloud", billing: "subscription", driver: "ollamaCloud", envVar: "OLLAMA_API_KEY", icon: "ollama",
65
67
  config: {}, keyTest: { provider: "ollamaCloud" }, keyUrl: "https://ollama.com/settings/keys", signupUrl: "https://ollama.com/pricing",
68
+ plan: { kind: "includedCredit", unusedCredit: "expires", afterCredit: "overage" },
66
69
  },
67
70
  {
68
71
  // Nous Portal's OpenAI-compatible API with a portal key: no Hermes needed
69
- // (Erick, 2026-11-08). Charged per use: Nous Portal states that API keys
70
- // always use credits, never the plan's included usage (checked
71
- // 2026-11-13). The subscription is the sign-in, through Hermes.
72
- id: "nous", kind: "apiKey", label: "Nous Research", billing: "payPerUse", driver: "openai-compat", envVar: "NOUS_API_KEY",
72
+ // (Erick, 2026-11-08). Counted as the person's Nous subscription, not pay
73
+ // per use (Erick, 2026-11-15, reversing the 2026-11-13 per-use reading of
74
+ // Portal's terms): it walks with the subscriptions and Atomic Engine uses
75
+ // it as the `nous-api` provider (server/atomic-engine-accounts.ts).
76
+ id: "nous", kind: "apiKey", label: "Nous Research", billing: "subscription", driver: "openai-compat", envVar: "NOUS_API_KEY",
73
77
  config: { url: "https://inference-api.nousresearch.com/v1", apiKeyEnv: "NOUS_API_KEY", model: "Hermes-4-405B", provider: "" },
74
78
  keyTest: { provider: "openaiCompat", url: "https://inference-api.nousresearch.com/v1" }, keyUrl: "https://portal.nousresearch.com/", signupUrl: "https://portal.nousresearch.com/",
75
79
  },
@@ -108,6 +112,39 @@ export const ACCOUNT_PROVIDERS = [
108
112
  keyTest: { provider: "openaiCompat", url: "https://integrate.api.nvidia.com/v1" }, keyUrl: "https://build.nvidia.com/settings/api-keys", signupUrl: "https://build.nvidia.com/",
109
113
  },
110
114
  ];
115
+ /** A provider's plan terms: its own `plan` when it names one, else read
116
+ * from `billing` (a sign-in is `signIn`, a subscription key a `flatPlan`). */
117
+ export function planTerms(provider) {
118
+ if (provider.kind === "signIn")
119
+ return { kind: "signIn" };
120
+ if (provider.plan)
121
+ return provider.plan;
122
+ if (provider.billing === "subscription")
123
+ return { kind: "flatPlan" };
124
+ return provider.billing === "free" ? { kind: "free" } : { kind: "perToken" };
125
+ }
126
+ /** The band an account is in this month. An included-credit plan is a
127
+ * subscription while credit is left (or while Atomic cannot tell); once the
128
+ * credit is used up, an `overage` plan bills per use and so walks with the
129
+ * pay-per-use keys, which opens the one-time notice. A `stops` plan stays a
130
+ * subscription and simply runs out like any other. Other terms keep their
131
+ * plain billing. */
132
+ export function billingWithCredit(terms, creditLeftUsd) {
133
+ switch (terms.kind) {
134
+ case "includedCredit":
135
+ return creditLeftUsd !== undefined && creditLeftUsd <= 0 && terms.afterCredit === "overage" ? "payPerUse" : "subscription";
136
+ case "perToken":
137
+ return "payPerUse";
138
+ case "free":
139
+ return "free";
140
+ default:
141
+ return "subscription";
142
+ }
143
+ }
144
+ /** Ollama's Team plan includes this much credit each month (Erick,
145
+ * 2026-11-15). Free, Pro and Max differ and are not tracked unless the person
146
+ * enters their own figure. */
147
+ export const OLLAMA_TEAM_MONTHLY_CREDIT_USD = 1000;
111
148
  export function accountProvider(id) {
112
149
  return ACCOUNT_PROVIDERS.find((provider) => provider.id === id);
113
150
  }
@@ -55,8 +55,15 @@ export function vaultAuthMode(saved) {
55
55
  return saved.authMode ?? ((saved.header ?? "Authorization").toLowerCase() === "authorization" && (saved.prefix ?? "Bearer ") === "Bearer " ? "auto" : "custom");
56
56
  }
57
57
  export function apiAuthFor(destination, saved) {
58
+ const origin = new URL(destination).origin;
59
+ const provider = API_PROVIDERS.find((candidate) => candidate.automatic && candidate.origins.includes(origin));
60
+ // Changing the old Authorization default to a vendor key header could
61
+ // leave its Bearer prefix behind. These verified key headers take raw keys,
62
+ // including when the saved item explicitly uses custom mode.
63
+ if (provider?.prefix === "" && saved.header.toLowerCase() === provider.header.toLowerCase() && saved.prefix === "Bearer ") {
64
+ return { header: saved.header, prefix: "" };
65
+ }
58
66
  if (vaultAuthMode(saved) === "custom")
59
67
  return saved;
60
- const origin = new URL(destination).origin;
61
- return API_PROVIDERS.find((provider) => provider.automatic && provider.origins.includes(origin)) ?? saved;
68
+ return provider ?? saved;
62
69
  }