@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.
- package/dist/assets/{TerminalPanel-PcPGVxjJ.js → TerminalPanel-k-bNNesV.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-CrdtKXgW.js → abnfDiagram-O67JEVCF-dJ7qt3uJ.js} +1 -1
- package/dist/assets/{arc-DZp6zTLS.js → arc-EddF6kP_.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-By4YaF8p.js → architectureDiagram-NJMV4G6O-UeAIAzq1.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-b9XT0BEX.js → blockDiagram-BEXU5L5S-CFb6JiNj.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-ClDc6UCa.js → c4Diagram-YGBWAQC7-1hMBdQdo.js} +1 -1
- package/dist/assets/channel-BWPQj1aN.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D8FDC39i.js → chunk-2Q5K7J3B-DNrbOG-A.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-_Lb0IVFX.js → chunk-3FUC2YCW-BxPQB9CL.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-f7re7-dy.js → chunk-5VM5RSS4-B1komt_B.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-Cl4oAWQ1.js → chunk-GTNCS2PH-CxvRNuCM.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-CLO3k8zE.js → chunk-GWA4HPMP-Du9NeFCS.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-kXWDfQP-.js → chunk-JWPE2WC7-SQ6yowId.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-DPtewwHN.js → chunk-NETBCI7D-Bf5p4Mwp.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-B17lA9FX.js → chunk-WEXAMYUT-CGfgwr4k.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-B6RbRjkG.js → chunk-XXDRQBXY-DQiWv_eF.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-BrZPolTO.js → classDiagram-v2-NBCMYWYE-CKfM0GgR.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-DAvSQrfJ.js → cose-bilkent-JH36ORCC-E32mrb9n.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-BBEKoW-B.js → cynefin-OW5HDTMX-BmJl13re.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-DTeD9b7A.js → cynefinDiagram-VND7K2PF-BQmysSe8.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-7Lem_oJB.js → dagre-6A5THRUB-Bvix6bhv.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BBMu1DQ4.js → diagram-22UHCM2B-DMb3_2Yw.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-wTBd45sT.js → diagram-3UASUU5V-C2G2lJWB.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-DejXVMcb.js → diagram-ATOU4E4O-Cnk0-r8a.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-CqYId1m8.js → diagram-CDSNMT55-iWUk11Ac.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-DrOnQ-Zt.js → diagram-MLGK6HIB-pQNwgrXs.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-CHDvidFk.js → diagram-MPIPVDR6-DyGbBWiA.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-BzwpPn5m.js → ebnfDiagram-ZINNZB2B-DQ3Ni6jW.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-E1HDqzYH.js → elk-276RUBZZ-DHKJu9Iv.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-D5E6uaT3.js → erDiagram-OPXOYQCR-PEPG1pKr.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-R1exlkB4.js → flowDiagram-KWPJA3E3-WUiDjhuX.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-B5kjMGRd.js → ganttDiagram-FUAMR5RP-XYcSw8XW.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-BqkJtDvq.js → gitGraphDiagram-X574FWY7-CPDsEL6v.js} +1 -1
- package/dist/assets/{index-DvEhLbPJ.js → index-7tft1G3w.js} +1 -1
- package/dist/assets/{index-D_WPT1i-.js → index-CzsF5HT1.js} +163 -163
- package/dist/assets/{infoDiagram-VRGFBTTK-LXwGqqoO.js → infoDiagram-VRGFBTTK-DA4G5Ada.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-D_E17iEV.js → ishikawaDiagram-OU5B5YK6-CLhBborF.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-BkKKJrLR.js → journeyDiagram-ZHPQQLJL-BoeIpfES.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-y6rjCvyW.js → kanban-definition-PNTS6WVX-BF2VlALx.js} +1 -1
- package/dist/assets/{linear-BYdFcAFG.js → linear-DGY-eezc.js} +1 -1
- package/dist/assets/{mermaid.core-BZnTzEV7.js → mermaid.core-BU5DAfrM.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-HPM-ymN0.js → mindmap-definition-NLK3R4M7-ldVJZIOj.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-X2YHQQDC.js → pegDiagram-GJSIUBJH-dS2C3m-e.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-FQ47RvEb.js → pieDiagram-5QR66LMP-BeX9hffn.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-CZok45i-.js → quadrantDiagram-O4NWA36T-gBxWQRkY.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-CkzgSbiA.js → railroadDiagram-XR7U4H2S-BSOKMMuc.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-B96vOB2k.js → requirementDiagram-PLB6GJNP-Cq4KZXOJ.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-C3OzzNBk.js → sankeyDiagram-IPEJSGJF-C59BLmfb.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-UEjwqc9C.js → sequenceDiagram-PO4LG4MO-De8iVPzU.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-CYlsATAn.js → sizeCapture-INFHLROL-CJLc7kKW.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-i3kPrA1F.js → stateDiagram-v2-GCMORJYK-BQkW_Cs-.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-CwxGl-A-.js → swimlanes-2SLR337P-CDPrdFPs.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-CCgmD5dO.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-B-CIp72A.js → timeline-definition-EJHVYXUP-VJExKP0a.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-CvI2j7z-.js → usecaseDiagram-POWQR4AR-A_h0-hH3.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U--l2Nr666.js → vennDiagram-UO4OBE2U-LeRZF6GK.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-C_WERxNO.js → wardleyDiagram-VNRHLVJA-BtQte254.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-VoRUD4V6.js → xychartDiagram-PMCCYNJV-C5Sdyn-i.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/container-mcp.js +83 -82
- package/dist-server/drivers/agents-proxy.js +81 -81
- package/dist-server/index.js +905 -531
- package/dist-server/mcp-server.js +36 -1
- package/dist-server/openmausbot.js +784 -595
- package/dist-server/pair-cli.js +784 -595
- package/dist-server/server/atomic-engine-accounts.js +64 -12
- package/dist-server/server/atomic-engine-classes.js +30 -0
- package/dist-server/server/atomic-engine-local.js +41 -0
- package/dist-server/server/chibi-defaults.js +14 -8
- package/dist-server/server/config.js +1 -1
- package/dist-server/server/default-model-selection.js +7 -0
- package/dist-server/server/drivers/acp/custom.js +7 -2
- package/dist-server/server/editor-connect.js +39 -2
- package/dist-server/server/engine-tiers.js +19 -19
- package/dist-server/server/harness-import/engine-policy.js +4 -3
- package/dist-server/server/index.js +13 -13
- package/dist-server/server/model-gateway/failover.js +44 -0
- package/dist-server/server/model-gateway/ladder.js +29 -0
- package/dist-server/server/model-gateway/route.js +104 -0
- package/dist-server/server/plan-credit.js +67 -0
- package/dist-server/server/provider-accounts.js +3 -0
- package/dist-server/server/request-auth.js +3 -0
- package/dist-server/server/routes/provider-accounts.js +46 -5
- package/dist-server/server/session-fallback.js +76 -0
- package/dist-server/shared/atomic-auto.js +10 -0
- package/dist-server/shared/engine-tiers.js +24 -8
- package/dist-server/shared/harness-weights.js +3 -1
- package/dist-server/shared/provider-accounts.js +42 -5
- package/dist-server/shared/vault-api-providers.js +9 -2
- package/dist-server/vps-container-mcp.js +83 -82
- package/package.json +1 -1
- package/dist/assets/channel-CP6zTF5h.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BxG6JDb-.js +0 -8
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
// When Atomic starts Atomic Engine it names those accounts in
|
|
5
5
|
// ATOMIC_ENGINE_ACCOUNTS (agent/atomic_accounts.py in chibitek/atomic-engine),
|
|
6
6
|
// in the order the engine should try them: Claude subscriptions, then
|
|
7
|
-
// ChatGPT (Codex), then flat-price plan keys
|
|
7
|
+
// ChatGPT (Codex), then flat-price plan keys (Ollama Cloud, Qwen Coding Plan,
|
|
8
|
+
// MiniMax M Plan, Z.ai GLM Coding Plan, OpenCode Go, Nous Portal). Grok and
|
|
9
|
+
// Kimi Code sign-ins are not passed yet: the engine cannot read those CLIs'
|
|
10
|
+
// login stores. Pay-per-use keys are left out,
|
|
8
11
|
// so when every subscription is resting the engine's turn fails as a usage
|
|
9
12
|
// limit and Atomic's own failover takes it to the pay-per-use band with its
|
|
10
13
|
// one-time notice (server/pay-per-use.ts), exactly as for any other engine.
|
|
@@ -21,17 +24,39 @@
|
|
|
21
24
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
22
25
|
import { homedir } from "node:os";
|
|
23
26
|
import { join } from "node:path";
|
|
27
|
+
import { CHIBI_DEFAULT_RUNG, MODEL_CLASSES } from "../shared/engine-tiers.js";
|
|
24
28
|
import { accountProvider } from "../shared/provider-accounts.js";
|
|
25
29
|
import { configuredAccountDirectory } from "./claude-accounts.js";
|
|
30
|
+
import { classPick } from "./atomic-engine-classes.js";
|
|
31
|
+
import { rememberedLocalModels } from "./atomic-engine-local.js";
|
|
32
|
+
import { hostApiKey } from "./drivers/local-inject.js";
|
|
26
33
|
export const ACCOUNTS_ENV = "ATOMIC_ENGINE_ACCOUNTS";
|
|
27
34
|
export const ACCOUNTS_FILE = "atomic-accounts.json";
|
|
28
35
|
const KEY_ENV_PREFIX = "ATOMIC_ACCOUNT_KEY_";
|
|
29
|
-
/** The model each provider fails over to
|
|
30
|
-
*
|
|
36
|
+
/** The model each provider fails over to. Claude's is Chibi's Plata rung
|
|
37
|
+
* (CHIBI_DEFAULT_RUNG), not the engine's old default Claude Sonnet 5, which
|
|
38
|
+
* Atomic grades Añejo (29.9); the others match the engine's own defaults
|
|
39
|
+
* (chibitek/defaults/user-defaults.yaml). */
|
|
31
40
|
const FAILOVER_MODEL = {
|
|
32
|
-
anthropic: "claude-
|
|
41
|
+
anthropic: CHIBI_DEFAULT_RUNG.model ?? "claude-opus-5",
|
|
33
42
|
"openai-codex": "gpt-5.6-sol",
|
|
34
43
|
"ollama-cloud": "kimi-k3",
|
|
44
|
+
// Atomic's MiniMax engine default (server/drivers/minimax.ts) and the
|
|
45
|
+
// engine's own MiniMax default.
|
|
46
|
+
minimax: "MiniMax-M3",
|
|
47
|
+
};
|
|
48
|
+
/** Flat-price plan keys, by Atomic provider row, and the engine provider
|
|
49
|
+
* each runs as (hermes_cli/auth.py in chibitek/atomic-engine). Every plan key
|
|
50
|
+
* Atomic knows is passed (Erick, 2026-11-15); pay-per-use keys never are. A
|
|
51
|
+
* Nous Portal key counts as the Nous subscription; the engine's `nous`
|
|
52
|
+
* provider is the device-code login, so a key runs as `nous-api`. A plan
|
|
53
|
+
* with no model in its preset leaves the engine on its provider default. */
|
|
54
|
+
const KEY_PLAN_PROVIDER = {
|
|
55
|
+
qwenCodingPlan: "alibaba-coding-plan",
|
|
56
|
+
minimaxPlan: "minimax",
|
|
57
|
+
zai: "zai",
|
|
58
|
+
opencodeGo: "opencode-go",
|
|
59
|
+
nous: "nous-api",
|
|
35
60
|
};
|
|
36
61
|
function rawConfig(entry) {
|
|
37
62
|
return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config)
|
|
@@ -72,19 +97,28 @@ function asAccount(id, entry) {
|
|
|
72
97
|
return { account: { id, provider: "ollama-cloud", kind: "api-key", label, billing: "subscription",
|
|
73
98
|
model: FAILOVER_MODEL["ollama-cloud"] }, key };
|
|
74
99
|
}
|
|
75
|
-
|
|
100
|
+
const keyProvider = added?.kind === "apiKey" && added.billing === "subscription" ? KEY_PLAN_PROVIDER[added.id] : undefined;
|
|
101
|
+
if (added?.kind === "apiKey" && keyProvider) {
|
|
76
102
|
const key = entry.environment?.[added.envVar]?.trim();
|
|
77
103
|
if (!key)
|
|
78
104
|
return null;
|
|
105
|
+
// An OpenAI-compatible instance's url is the plan's endpoint. Another
|
|
106
|
+
// driver's url is its own API shape (MiniMax's is OpenAI-style, the
|
|
107
|
+
// engine's MiniMax provider speaks Anthropic's), so the engine keeps its
|
|
108
|
+
// provider endpoint there. With no model anywhere (OpenCode Go lists its
|
|
109
|
+
// models live) the account is named but stays out of the engine's
|
|
110
|
+
// fallback chain, which needs a model per step.
|
|
79
111
|
const config = rawConfig(entry);
|
|
80
|
-
const model = typeof config.model === "string" && config.model ? config.model
|
|
81
|
-
|
|
82
|
-
|
|
112
|
+
const model = typeof config.model === "string" && config.model ? config.model
|
|
113
|
+
: added.config.model ?? FAILOVER_MODEL[keyProvider];
|
|
114
|
+
const ownUrl = entry.driver === "openai-compat" && typeof config.url === "string" && config.url ? config.url : undefined;
|
|
115
|
+
const baseUrl = ownUrl ?? added.config.url;
|
|
116
|
+
return { account: { id, provider: keyProvider, kind: "api-key", label, billing: "subscription",
|
|
83
117
|
...(baseUrl ? { baseUrl } : {}), ...(model ? { model } : {}) }, key };
|
|
84
118
|
}
|
|
85
119
|
return null;
|
|
86
120
|
}
|
|
87
|
-
const KIND_ORDER = { "claude-code": 0, "codex-cli": 1, "api-key": 2 };
|
|
121
|
+
const KIND_ORDER = { "claude-code": 0, "codex-cli": 1, "api-key": 2, local: 3 };
|
|
88
122
|
/** The accounts Atomic Engine may use, in the order it should try them. */
|
|
89
123
|
export function atomicEngineAccounts(input) {
|
|
90
124
|
const engineOwner = input.owner(input.engineInstanceId);
|
|
@@ -99,11 +133,29 @@ export function atomicEngineAccounts(input) {
|
|
|
99
133
|
const resting = input.restingUntil?.(id);
|
|
100
134
|
if (resting && resting > Date.now())
|
|
101
135
|
found.account.restingUntil = resting;
|
|
136
|
+
const pick = input.classModels && input.classOrder ? classPick(found.account.provider, input.classModels, input.classOrder) : undefined;
|
|
137
|
+
if (pick)
|
|
138
|
+
Object.assign(found.account, pick);
|
|
102
139
|
rows.push({ ...found, order: order++ });
|
|
103
140
|
}
|
|
104
|
-
//
|
|
105
|
-
// in
|
|
106
|
-
|
|
141
|
+
// Class Auto: the asked-for class first across every account, then the
|
|
142
|
+
// next class in failover order; an account Atomic cannot grade comes after
|
|
143
|
+
// the graded ones. Within a class, subscriptions by kind (Claude, then
|
|
144
|
+
// ChatGPT, then plan keys), each kind in the order the person added the
|
|
145
|
+
// accounts; the default login first.
|
|
146
|
+
const classRank = (account) => {
|
|
147
|
+
const at = account.modelClass ? (input.classOrder ?? MODEL_CLASSES).indexOf(account.modelClass) : -1;
|
|
148
|
+
return at < 0 ? MODEL_CLASSES.length : at;
|
|
149
|
+
};
|
|
150
|
+
rows.sort((a, b) => classRank(a.account) - classRank(b.account) ||
|
|
151
|
+
KIND_ORDER[a.account.kind] - KIND_ORDER[b.account.kind] || a.order - b.order);
|
|
152
|
+
// Local model servers after every subscription (Erick, 2026-11-15): the
|
|
153
|
+
// engine reaches them before its turn fails over to Atomic's pay-per-use
|
|
154
|
+
// notice. Free to run, so they are never billed or rested.
|
|
155
|
+
for (const { host, model } of input.local ?? rememberedLocalModels()) {
|
|
156
|
+
rows.push({ account: { id: `local-${host.id}`, provider: "custom", kind: "local", label: host.label, billing: "local",
|
|
157
|
+
baseUrl: host.baseUrl, model }, key: hostApiKey(host), order: order++ });
|
|
158
|
+
}
|
|
107
159
|
const env = {};
|
|
108
160
|
rows.forEach((row, index) => {
|
|
109
161
|
if (row.key === undefined)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** The Atomic driver whose graded runs name a model for each engine
|
|
2
|
+
* provider. Only providers whose Atomic driver runs nothing else: an
|
|
3
|
+
* OpenAI-compatible key (Qwen, Z.ai, Nous) shares `openai-compat` runs with
|
|
4
|
+
* other hosts, so it keeps its plan's own model. */
|
|
5
|
+
const PROVIDER_DRIVER = {
|
|
6
|
+
anthropic: "claudeAgent",
|
|
7
|
+
"openai-codex": "codex",
|
|
8
|
+
"ollama-cloud": "ollamaCloud",
|
|
9
|
+
minimax: "minimax",
|
|
10
|
+
};
|
|
11
|
+
/** Ollama's `:cloud` tag is how a local daemon proxies a cloud model; the
|
|
12
|
+
* engine talks to ollama.com directly, where the model has no tag. */
|
|
13
|
+
const engineModelId = (provider, model) => provider === "ollama-cloud" ? model.replace(/:cloud$/i, "") : model;
|
|
14
|
+
/** The account's model in the first class of `order` that has one for its
|
|
15
|
+
* provider, from `models` in ladder order (best first in each class). */
|
|
16
|
+
export function classPick(provider, models, order) {
|
|
17
|
+
const driverKind = PROVIDER_DRIVER[provider];
|
|
18
|
+
if (!driverKind)
|
|
19
|
+
return undefined;
|
|
20
|
+
for (const modelClass of order) {
|
|
21
|
+
for (const graded of models) {
|
|
22
|
+
if (graded.modelClass !== modelClass)
|
|
23
|
+
continue;
|
|
24
|
+
const run = graded.runs.find((candidate) => candidate.driverKind === driverKind);
|
|
25
|
+
if (run)
|
|
26
|
+
return { model: engineModelId(provider, run.model), modelClass };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Local model servers on Atomic Engine's automatic chain (Erick, 2026-11-15):
|
|
2
|
+
// when Ollama, LM Studio, oMLX, EXO or Unsloth is running on this computer,
|
|
3
|
+
// Atomic Engine may use it after every subscription and before Atomic's
|
|
4
|
+
// pay-per-use notice. Atomic already probes those hosts for the engine's
|
|
5
|
+
// model list (customAcpModels, server/drivers/local-inject.ts); the last
|
|
6
|
+
// probe is kept here, and each host that answered becomes one `local`
|
|
7
|
+
// account at the end of the engine's manifest (server/atomic-engine-accounts.ts).
|
|
8
|
+
//
|
|
9
|
+
// One model per host: one it has loaded, else the first it lists. An Ollama
|
|
10
|
+
// `:cloud` model is the Ollama Cloud plan, not a local model, and is left to
|
|
11
|
+
// that subscription.
|
|
12
|
+
import { isOllamaCloudModel } from "../shared/local-models.js";
|
|
13
|
+
import { decodeInjectId, localHost } from "./drivers/local-inject.js";
|
|
14
|
+
let remembered = [];
|
|
15
|
+
/** The local servers' best model each, from catalog rows (`host::model`). */
|
|
16
|
+
export function localPicks(options) {
|
|
17
|
+
const byHost = new Map();
|
|
18
|
+
const seenUrls = new Set();
|
|
19
|
+
for (const option of options) {
|
|
20
|
+
const inject = decodeInjectId(option.id);
|
|
21
|
+
const host = inject ? localHost(inject.host) : undefined;
|
|
22
|
+
if (!inject || !host || isOllamaCloudModel(inject.model))
|
|
23
|
+
continue;
|
|
24
|
+
const current = byHost.get(host.id);
|
|
25
|
+
if (current && (current.loaded || !option.loaded))
|
|
26
|
+
continue;
|
|
27
|
+
// Two ids for one server (ollama / local_ollama) are one host.
|
|
28
|
+
if (!current && seenUrls.has(host.baseUrl))
|
|
29
|
+
continue;
|
|
30
|
+
seenUrls.add(host.baseUrl);
|
|
31
|
+
byHost.set(host.id, { host, model: inject.model, loaded: option.loaded === true });
|
|
32
|
+
}
|
|
33
|
+
return [...byHost.values()].map(({ host, model }) => ({ host, model }));
|
|
34
|
+
}
|
|
35
|
+
/** Keep the latest probe's picks; called each time the engine's models are listed. */
|
|
36
|
+
export function rememberLocalModels(options) {
|
|
37
|
+
remembered = localPicks(options);
|
|
38
|
+
}
|
|
39
|
+
export function rememberedLocalModels() {
|
|
40
|
+
return remembered;
|
|
41
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
// One default for Chibi on every install
|
|
2
|
-
//
|
|
1
|
+
// One default for Chibi on every install: Automatic, on Atomic Engine (Auto)
|
|
2
|
+
// (ATOMIC_AUTO_RUNG, Erick 2026-11-15), else the Plata class on Claude
|
|
3
|
+
// Opus 5 (CHIBI_DEFAULT_RUNG, Erick 2026-11-13). Installs
|
|
3
4
|
// had drifted apart, so an update puts every Chibi back on it once per
|
|
4
5
|
// CHIBI_DEFAULTS_VERSION, whatever it was set to. What a person changes
|
|
5
6
|
// afterwards holds until the version is raised.
|
|
6
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
8
|
import { join } from "node:path";
|
|
8
|
-
import { CHIBI_DEFAULTS_VERSION, CHIBI_DEFAULT_RUNG } from "../shared/engine-tiers.js";
|
|
9
|
+
import { ATOMIC_AUTO_RUNG, CHIBI_DEFAULTS_VERSION, CHIBI_DEFAULT_RUNG } from "../shared/engine-tiers.js";
|
|
9
10
|
import { writeFileAtomic } from "./atomic.js";
|
|
10
11
|
/** Where the version last applied on this install is kept. */
|
|
11
12
|
export const CHIBI_DEFAULTS_FILE = "chibi-defaults.json";
|
|
@@ -13,15 +14,20 @@ export const CHIBI_DEFAULTS_FILE = "chibi-defaults.json";
|
|
|
13
14
|
* class first, then the class below (the nearest score), then above, then
|
|
14
15
|
* the lowest, where graded local models sit. */
|
|
15
16
|
const NEAREST_CLASSES = ["Plata", "Reposado", "Mezcal", "Añejo"];
|
|
16
|
-
/** The model Chibi is put on.
|
|
17
|
-
* allowed
|
|
17
|
+
/** The model Chibi is put on. Atomic Engine (Auto) when that engine is
|
|
18
|
+
* ready, allowed and lists it; else CHIBI_DEFAULT_RUNG on a ready, allowed
|
|
19
|
+
* account that lists it. An install without one (Gemini through
|
|
18
20
|
* Google Workspace only, ChatGPT only, one API key, a local model) gets the
|
|
19
21
|
* model it does have that grades nearest: `models` in ladder order, class
|
|
20
22
|
* by class. Undefined only when nothing graded is ready; the caller then
|
|
21
23
|
* keeps or picks any working engine, so a bot is never without a model. */
|
|
22
24
|
export function chibiDefaultSelection(engines, refused, models = []) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
+
const usable = engines.filter((engine) => engine.snapshot.state === "available" && engine.snapshot.authenticated !== false && refused(engine) === undefined);
|
|
26
|
+
const atomic = usable.find((engine) => engine.instanceId === ATOMIC_AUTO_RUNG.engine && engine.models.options.some((option) => option.id === ATOMIC_AUTO_RUNG.model));
|
|
27
|
+
if (atomic)
|
|
28
|
+
return { instanceId: atomic.instanceId, model: ATOMIC_AUTO_RUNG.model };
|
|
29
|
+
// Atomic Engine's other models are not Chibi's fallback: they are the engine's own chain.
|
|
30
|
+
const ready = usable.filter((engine) => engine.instanceId !== ATOMIC_AUTO_RUNG.engine);
|
|
25
31
|
const on = (driverKind, model) => {
|
|
26
32
|
for (const engine of ready) {
|
|
27
33
|
if (engine.driverKind !== driverKind)
|
|
@@ -91,6 +97,6 @@ export async function applyChibiDefaults(deps) {
|
|
|
91
97
|
for (const task of chibi.tasks ?? [])
|
|
92
98
|
deps.store.setThreadEngineClass(chibi.id, task.threadId, "tier");
|
|
93
99
|
writeFileAtomic(join(deps.dataDir, CHIBI_DEFAULTS_FILE), `${JSON.stringify({ version: CHIBI_DEFAULTS_VERSION, appliedAt: new Date().toISOString() })}\n`);
|
|
94
|
-
console.log(`[chibi] put on its default: Automatic, ${CHIBI_DEFAULT_RUNG.modelClass}, ${selection ? `${selection.instanceId}/${selection.model}` : "the model it had (no graded model is ready here)"}`);
|
|
100
|
+
console.log(`[chibi] put on its default: Automatic, ${selection?.model === ATOMIC_AUTO_RUNG.model ? "Atomic Engine (Auto)" : CHIBI_DEFAULT_RUNG.modelClass}, ${selection ? `${selection.instanceId}/${selection.model}` : "the model it had (no graded model is ready here)"}`);
|
|
95
101
|
return true;
|
|
96
102
|
}
|
|
@@ -325,7 +325,7 @@ const instanceConfigSchema = z.object({
|
|
|
325
325
|
environment: z.record(z.string(), z.string()).optional(),
|
|
326
326
|
enabled: z.boolean().optional(),
|
|
327
327
|
config: z.json().optional(),
|
|
328
|
-
account: z.string().trim().min(1).max(64).optional(),
|
|
328
|
+
account: z.string().trim().min(1).max(64).optional(), planCreditUsd: z.number().positive().max(1_000_000).optional(),
|
|
329
329
|
});
|
|
330
330
|
const instanceConfigMapSchema = z.record(z.string(), instanceConfigSchema);
|
|
331
331
|
const defaultModelSelectionSchema = z.object({
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
const claudeFirst = (instances) => instances.find((instance) => instance.driverKind === "claudeAgent") ?? instances[0];
|
|
2
|
+
/** New bots are made on Atomic Engine (Auto) when that engine is installed,
|
|
3
|
+
* signed in, allowed and lists it (Erick, 2026-11-15). */
|
|
4
|
+
const ATOMIC_AUTO = { instanceId: "atomic-engine", model: "atomic/auto" };
|
|
5
|
+
const atomicAuto = (instances) => instances.find((instance) => instance.instanceId === ATOMIC_AUTO.instanceId &&
|
|
6
|
+
instance.snapshot.authenticated !== false && instance.models.options.some((model) => model.id === ATOMIC_AUTO.model));
|
|
2
7
|
/** A saved choice is intentional: an unavailable provider or removed model
|
|
3
8
|
* sends new bots to setup instead of silently changing their provider. */
|
|
4
9
|
export function selectDefaultModelSelection(instances, preferred, context = {}) {
|
|
@@ -23,6 +28,8 @@ export function selectDefaultModelSelection(instances, preferred, context = {})
|
|
|
23
28
|
// The organisation's policy is inert (no refusal) unless this desktop is enrolled.
|
|
24
29
|
const available = instances.filter((instance) => instance.snapshot.state === "available" && instance.capabilities?.chatOnly !== true &&
|
|
25
30
|
context.refusal?.(instance) === undefined);
|
|
31
|
+
if (atomicAuto(available))
|
|
32
|
+
return { ...ATOMIC_AUTO };
|
|
26
33
|
const company = context.company;
|
|
27
34
|
let pick;
|
|
28
35
|
if (company && instances.some((instance) => company(instance.instanceId))) {
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
import { homedir } from "node:os";
|
|
18
18
|
import { basename, join } from "node:path";
|
|
19
19
|
import { currentAtomicEngineAccounts, writeAtomicEngineAccountsFile } from "../../atomic-engine-accounts.js";
|
|
20
|
+
import { rememberLocalModels } from "../../atomic-engine-local.js";
|
|
21
|
+
import { ATOMIC_AUTO_MODEL } from "../../../shared/atomic-auto.js";
|
|
20
22
|
import { atomicEngineAsset } from "../../atomic-engine-release.js";
|
|
21
23
|
import { ATOMIC_ENGINE_MODULE_ARGS, installAtomicEngine, managedAtomicEngine } from "../../atomic-engine-runtime.js";
|
|
22
24
|
import { findCliCandidates } from "../../env-path.js";
|
|
@@ -98,8 +100,11 @@ export function lockAtomicEngineMemory(env, instanceId, cli) {
|
|
|
98
100
|
export async function customAcpModels(env, config, instanceId, fetchImpl = fetch) {
|
|
99
101
|
if (!isAtomicEngine(instanceId, config?.cli))
|
|
100
102
|
return PASSTHROUGH;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
// One choice with Automatic (shared/atomic-auto.ts): picking it puts the bot on its tier's ladder.
|
|
104
|
+
const own = { default: ATOMIC_AUTO_MODEL, options: [{ id: ATOMIC_AUTO_MODEL, label: "Atomic Engine (Auto)", custom: true }] };
|
|
105
|
+
const catalog = await mergeLocalInject(own, env, fetchImpl);
|
|
106
|
+
rememberLocalModels(catalog.options); // the engine's local fallbacks (server/atomic-engine-local.ts)
|
|
107
|
+
return catalog;
|
|
103
108
|
}
|
|
104
109
|
/** A turn's model on a custom engine: a `host::model` id (only Atomic
|
|
105
110
|
* Engine lists them) registers the host in Atomic Engine's config.yaml. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Adds (and removes) Atomic as an MCP server in the code editors people use
|
|
2
|
-
// beside it: VS Code, Cursor, Windsurf, Antigravity and
|
|
2
|
+
// beside it: VS Code, Cursor, Windsurf, Antigravity, OpenCode and Codex. Each gets
|
|
3
3
|
// its own connected-assistant token, named after the editor, so it can be
|
|
4
4
|
// revoked on its own; the config names the token FILE, never the token.
|
|
5
5
|
//
|
|
@@ -27,6 +27,8 @@ export function editorTargets(home = homedir(), platform = process.platform, env
|
|
|
27
27
|
// Xcode 26.3+ shares one MCP server list with all of its coding agents (Claude, Codex, Gemini). macOS only.
|
|
28
28
|
...(platform === "darwin" ? [{ id: "xcode", label: "Xcode", configPath: join(home, "Library", "Developer", "Xcode", "CodingAssistant", "mcp-servers.json"), format: "mcp-servers", installedAt: [...apps("Xcode"), join(home, "Library", "Developer", "Xcode", "CodingAssistant")] }] : []),
|
|
29
29
|
{ id: "opencode", label: "OpenCode", configPath: join(xdgConfig, "opencode", "opencode.json"), format: "opencode", installedAt: [join(home, ".opencode"), join(xdgConfig, "opencode")] },
|
|
30
|
+
// Codex (CLI and app) reads [mcp_servers.*] from its TOML config; with it, Codex can hand work to Atomic Engine (atomic_engine).
|
|
31
|
+
{ id: "codex", label: "Codex", configPath: join(env.CODEX_HOME || join(home, ".codex"), "config.toml"), format: "codex-toml", installedAt: [...apps("Codex"), env.CODEX_HOME || join(home, ".codex")] },
|
|
30
32
|
];
|
|
31
33
|
}
|
|
32
34
|
export function editorTarget(id, targets = editorTargets()) {
|
|
@@ -53,6 +55,30 @@ function readConfig(path) {
|
|
|
53
55
|
throw new Error(`${path} is not a JSON object`);
|
|
54
56
|
return parsed;
|
|
55
57
|
}
|
|
58
|
+
// Codex's config is TOML. Only Atomic's own tables are written or removed
|
|
59
|
+
// ([mcp_servers.atomic] and its sub-tables); every other line stays as it
|
|
60
|
+
// was. JSON string escapes are valid TOML basic strings.
|
|
61
|
+
const CODEX_TABLE = new RegExp(`^\\s*\\[mcp_servers\\.${CLAUDE_CODE_SERVER_NAME}(\\.[^\\]]+)?\\]\\s*$`);
|
|
62
|
+
export function withoutCodexEntry(toml) {
|
|
63
|
+
const out = [];
|
|
64
|
+
let skipping = false;
|
|
65
|
+
for (const line of toml.split("\n")) {
|
|
66
|
+
if (/^\s*\[/.test(line))
|
|
67
|
+
skipping = CODEX_TABLE.test(line);
|
|
68
|
+
if (!skipping)
|
|
69
|
+
out.push(line);
|
|
70
|
+
}
|
|
71
|
+
return out.join("\n").replace(/\s+$/, "");
|
|
72
|
+
}
|
|
73
|
+
export function withCodexEntry(toml, entry) {
|
|
74
|
+
const table = [`[mcp_servers.${CLAUDE_CODE_SERVER_NAME}]`, `command = ${JSON.stringify(entry.command)}`, `args = ${JSON.stringify(entry.args)}`];
|
|
75
|
+
const env = Object.entries(entry.env ?? {});
|
|
76
|
+
if (env.length)
|
|
77
|
+
table.push("", `[mcp_servers.${CLAUDE_CODE_SERVER_NAME}.env]`, ...env.map(([key, value]) => `${JSON.stringify(key)} = ${JSON.stringify(value)}`));
|
|
78
|
+
const rest = withoutCodexEntry(toml);
|
|
79
|
+
return `${rest ? `${rest}\n\n` : ""}${table.join("\n")}\n`;
|
|
80
|
+
}
|
|
81
|
+
const codexHasEntry = (toml) => toml.split("\n").some((line) => CODEX_TABLE.test(line) && !line.includes(`${CLAUDE_CODE_SERVER_NAME}.`));
|
|
56
82
|
function writeConfig(path, config, now) {
|
|
57
83
|
let mode = 0o600;
|
|
58
84
|
if (existsSync(path)) {
|
|
@@ -62,9 +88,12 @@ function writeConfig(path, config, now) {
|
|
|
62
88
|
else {
|
|
63
89
|
mkdirSync(dirname(path), { recursive: true });
|
|
64
90
|
}
|
|
65
|
-
writeFileAtomic(path, `${JSON.stringify(config, null, 2)}\n`, { mode });
|
|
91
|
+
writeFileAtomic(path, typeof config === "string" ? config : `${JSON.stringify(config, null, 2)}\n`, { mode });
|
|
66
92
|
}
|
|
93
|
+
const readText = (path) => (existsSync(path) ? readFileSync(path, "utf8") : "");
|
|
67
94
|
export function registerWithEditor(target, entry, now = new Date()) {
|
|
95
|
+
if (target.format === "codex-toml")
|
|
96
|
+
return writeConfig(target.configPath, withCodexEntry(readText(target.configPath), entry), now);
|
|
68
97
|
const config = readConfig(target.configPath);
|
|
69
98
|
const key = serversKey(target.format);
|
|
70
99
|
const servers = (config[key] && typeof config[key] === "object" && !Array.isArray(config[key]) ? config[key] : {});
|
|
@@ -73,6 +102,12 @@ export function registerWithEditor(target, entry, now = new Date()) {
|
|
|
73
102
|
export function unregisterFromEditor(target, now = new Date()) {
|
|
74
103
|
if (!existsSync(target.configPath))
|
|
75
104
|
return;
|
|
105
|
+
if (target.format === "codex-toml") {
|
|
106
|
+
const toml = readText(target.configPath);
|
|
107
|
+
if (codexHasEntry(toml))
|
|
108
|
+
writeConfig(target.configPath, `${withoutCodexEntry(toml)}\n`, now);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
76
111
|
const config = readConfig(target.configPath);
|
|
77
112
|
const key = serversKey(target.format);
|
|
78
113
|
const servers = config[key];
|
|
@@ -83,6 +118,8 @@ export function unregisterFromEditor(target, now = new Date()) {
|
|
|
83
118
|
}
|
|
84
119
|
export function editorHasEntry(target) {
|
|
85
120
|
try {
|
|
121
|
+
if (target.format === "codex-toml")
|
|
122
|
+
return codexHasEntry(readText(target.configPath));
|
|
86
123
|
const servers = readConfig(target.configPath)[serversKey(target.format)];
|
|
87
124
|
return Boolean(servers && typeof servers === "object" && CLAUDE_CODE_SERVER_NAME in servers);
|
|
88
125
|
}
|
|
@@ -3,21 +3,21 @@
|
|
|
3
3
|
// engine of its ladder that is ready. Everything here is pure except the
|
|
4
4
|
// snapshot cache, so the server wires it to the live registry and the tests
|
|
5
5
|
// drive it with plain candidates.
|
|
6
|
-
import { BOT_TIERS, CHIBI_DEFAULT_RUNG, DEFAULT_LADDERS, DEFAULT_TIER_CLASSES, MODEL_CLASSES, classBelow, isBotTier, rungAccounts, toModelClass } from "../shared/engine-tiers.js";
|
|
6
|
+
import { ATOMIC_AUTO_RUNG, BOT_TIERS, CHIBI_DEFAULT_RUNG, DEFAULT_LADDERS, DEFAULT_TIER_CLASSES, MODEL_CLASSES, classBelow, isBotTier, rungAccounts, toModelClass } from "../shared/engine-tiers.js";
|
|
7
7
|
export { DEFAULT_LADDERS };
|
|
8
8
|
import { expandAnySubscription, orderRungs } from "./ladder-order.js";
|
|
9
9
|
import { ATOMIC_ENGINE_INSTANCE, engineIntent, freeCandidate, localModel, modelBilling, modelProvider, paidCandidate, perTokenModel } from "./harness-import/engine-policy.js";
|
|
10
|
-
/** Engines a tier tries first
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
/** Engines a tier tries first after Atomic Engine (Auto), whatever the
|
|
11
|
+
* class catalog order says. Without Atomic Engine, Chibi runs on Claude:
|
|
12
|
+
* Claude's best model graded in its class, then Claude's next (or Claude's
|
|
13
|
+
* own default should the catalog grade only one there); other providers
|
|
14
|
+
* follow only for when no Claude account is free (Erick, 2026-10-13, now
|
|
15
|
+
* the fallback under Atomic Engine (Auto), 2026-11-15). */
|
|
16
16
|
const TIER_PREFERRED_DRIVERS = {
|
|
17
17
|
orchestrator: ["claudeAgent"],
|
|
18
18
|
};
|
|
19
|
-
/** How many of a tier's preferred rungs keep the top of its generated ladder. */
|
|
20
|
-
const PREFERRED_RUNGS =
|
|
19
|
+
/** How many of a tier's preferred rungs keep the top of its generated ladder: Atomic Engine (Auto) and two more. */
|
|
20
|
+
const PREFERRED_RUNGS = 3;
|
|
21
21
|
/** Every engine that runs a model of the class, the models in the order
|
|
22
22
|
* given (cheapest per task, then per token, then fastest), each model's
|
|
23
23
|
* engines in catalog order. */
|
|
@@ -43,7 +43,7 @@ export function classLadder(models, modelClass) {
|
|
|
43
43
|
}
|
|
44
44
|
/** The ladders a refresh generates: each tier asks for its class, and its
|
|
45
45
|
* ladder is every model in that class in harness-aware order (orderRungs)
|
|
46
|
-
* after the tier's first PREFERRED_RUNGS preferred rungs. Subscriptions still
|
|
46
|
+
* after the tier's first PREFERRED_RUNGS preferred rungs (Atomic Engine (Auto) first). Subscriptions still
|
|
47
47
|
* come before API keys when it is walked (resolveLadder). Falls back to the
|
|
48
48
|
* hand-written ladder for a tier whose class has no model. */
|
|
49
49
|
export function generateLadders(models, classes) {
|
|
@@ -51,7 +51,7 @@ export function generateLadders(models, classes) {
|
|
|
51
51
|
const seen = new Set();
|
|
52
52
|
const rungs = classRungs(models, classes[tier]);
|
|
53
53
|
const drivers = TIER_PREFERRED_DRIVERS[tier] ?? [];
|
|
54
|
-
const preferred = [...(tier === "orchestrator" && classes[tier] === CHIBI_DEFAULT_RUNG.modelClass ? [{ ...CHIBI_DEFAULT_RUNG }] : []), ...rungs.filter((entry) => drivers.includes(entry.engine)), ...drivers.map((engine) => ({ engine }))];
|
|
54
|
+
const preferred = [{ ...ATOMIC_AUTO_RUNG }, ...(tier === "orchestrator" && classes[tier] === CHIBI_DEFAULT_RUNG.modelClass ? [{ ...CHIBI_DEFAULT_RUNG }] : []), ...rungs.filter((entry) => drivers.includes(entry.engine)), ...drivers.map((engine) => ({ engine }))];
|
|
55
55
|
const pinned = Math.min(PREFERRED_RUNGS, preferred.length);
|
|
56
56
|
const ordered = [...preferred, ...rungs].filter((entry) => {
|
|
57
57
|
const key = entryKey(entry);
|
|
@@ -287,7 +287,7 @@ export function resolveLadder(ladder, stored, context) {
|
|
|
287
287
|
subscription.sort((a, b) => atomicFirst(a.candidate) - atomicFirst(b.candidate) || a.step - b.step);
|
|
288
288
|
key.sort((a, b) => a.step - b.step || storedFirst(a.candidate, b.candidate) || a.index - b.index);
|
|
289
289
|
free.sort((a, b) => a.step - b.step || storedFirst(a.candidate, b.candidate) || a.index - b.index);
|
|
290
|
-
for (const { step, entry, candidate, band } of [...subscription, ...
|
|
290
|
+
for (const { step, entry, candidate, band } of [...subscription, ...free, ...key]) { // free before pay-per-use (Erick, 2026-11-15)
|
|
291
291
|
// "paused" names a key kept off this turn by policy alone: a key that could not take it anyway (signed out, resting, refused) keeps its real reason.
|
|
292
292
|
const reason = band === "free" && !context.includeFree ? "free-off"
|
|
293
293
|
: band === "free" && context.clientData ? "client-data"
|
|
@@ -338,8 +338,8 @@ export function failoverClassOrder(modelClass) {
|
|
|
338
338
|
* 1. subscriptions in the required class (its ladder, then any other
|
|
339
339
|
* subscription engine whose model is graded in it);
|
|
340
340
|
* 2. subscriptions in each class below it, closest first, then above it;
|
|
341
|
-
* 3. pay-per-use keys in the
|
|
342
|
-
* the same order.
|
|
341
|
+
* 3. free models when allowed, then 4. pay-per-use keys: each in the
|
|
342
|
+
* required class, then the other classes in the same order.
|
|
343
343
|
*
|
|
344
344
|
* A rung's class is the one written on it, else the model's graded class,
|
|
345
345
|
* else, for an engine the required class's ladder names, the class the turn
|
|
@@ -381,16 +381,16 @@ export function resolveFailover(request) {
|
|
|
381
381
|
const ladders = new Map(classes.map((modelClass) => [modelClass, ladderOf(modelClass)]));
|
|
382
382
|
const all = [];
|
|
383
383
|
let lastPassSkipped;
|
|
384
|
-
for (const stage of ["subscription", "
|
|
384
|
+
for (const stage of ["subscription", "free", "key"]) {
|
|
385
385
|
for (const modelClass of classes) {
|
|
386
386
|
const { ladder, vouched } = ladders.get(modelClass);
|
|
387
387
|
const effective = (candidate, model, entry, step) => entry?.modelClass ?? request.classOf(candidate, model) ?? (step < vouched ? modelClass : "Añejo");
|
|
388
388
|
const accept = (candidate, model, entry, named) => {
|
|
389
389
|
if (request.tried.has(candidate.instanceId))
|
|
390
390
|
return "tried";
|
|
391
|
-
// Free
|
|
392
|
-
// in every class,
|
|
393
|
-
if (
|
|
391
|
+
// Free models have their own pass, after subscriptions and before
|
|
392
|
+
// pay-per-use keys in every class (Erick, 2026-11-15).
|
|
393
|
+
if (freeCandidate(candidate) !== (stage === "free"))
|
|
394
394
|
return "key-later";
|
|
395
395
|
if (stage === "subscription" && (keyBased(candidate) || perTokenModel(candidate, model)))
|
|
396
396
|
return "key-later";
|
|
@@ -402,7 +402,7 @@ export function resolveFailover(request) {
|
|
|
402
402
|
};
|
|
403
403
|
const resolution = resolveLadder(ladder, request.failed, { ...request.context, accept });
|
|
404
404
|
all.push(...resolution.skipped);
|
|
405
|
-
if (stage === "
|
|
405
|
+
if (stage === "key" && modelClass === request.modelClass)
|
|
406
406
|
lastPassSkipped = resolution.skipped;
|
|
407
407
|
if (resolution.choice) {
|
|
408
408
|
const { choice } = resolution;
|
|
@@ -73,13 +73,14 @@ export const freeCandidate = (candidate) => candidate.billing === "free";
|
|
|
73
73
|
// they are configured for, as `<provider>:<model>` ("deepinfra:XiaomiMiMo/
|
|
74
74
|
// MiMo-V2.6-Pro", "nous:xiaomi/mimo-v2.6-pro"). The engine is not paid one
|
|
75
75
|
// way: each model is paid as its provider is.
|
|
76
|
-
/** Providers on such engines that are flat plans: Nous Portal
|
|
76
|
+
/** Providers on such engines that are flat plans: Nous Portal (its login and
|
|
77
|
+
* its API key, `nous-api`: Erick, 2026-11-15), the Kimi,
|
|
77
78
|
* Z.ai GLM and OpenCode Go coding plans, and the subscription sign-ins (ChatGPT, GitHub
|
|
78
79
|
* Copilot, Qwen). */
|
|
79
|
-
const FLAT_PLAN_PROVIDERS = new Set(["nous", "kimi-coding", "opencode-go", "openai-codex", "copilot", "qwen-oauth", "zai-coding-plan"]);
|
|
80
|
+
const FLAT_PLAN_PROVIDERS = new Set(["nous", "nous-api", "kimi-coding", "opencode-go", "openai-codex", "copilot", "qwen-oauth", "zai-coding-plan"]);
|
|
80
81
|
/** Providers that run on this machine: free, and never a stand-in for a
|
|
81
82
|
* frontier model (resolveFailover). */
|
|
82
|
-
const LOCAL_PROVIDERS = new Set(["custom", "lmstudio", "ollama", "vllm", "llamacpp"]);
|
|
83
|
+
const LOCAL_PROVIDERS = new Set(["custom", "lmstudio", "ollama", "vllm", "llamacpp", "omlx", "exo", "unsloth"]);
|
|
83
84
|
export const multiProviderEngine = (candidate) => candidate.driverKind === "hermesAgent" || candidate.instanceId === ATOMIC_ENGINE_INSTANCE;
|
|
84
85
|
/** The provider a model runs on, on an engine that runs many; undefined
|
|
85
86
|
* elsewhere, and for an id with no provider (Hermes' own config default).
|
|
@@ -85,6 +85,7 @@ import { augmentedPath, findCliCandidates, resetPathCache, splitCliString } from
|
|
|
85
85
|
import { registerEnginesBinDir } from "./engine-install.js";
|
|
86
86
|
import { setupLog } from "./setup-log.js";
|
|
87
87
|
import { bundledNpmCli, ensureNodeShim, nodeRuntimeStatus } from "./node-runtime.js";
|
|
88
|
+
import { accountBilling } from "./plan-credit.js";
|
|
88
89
|
import { appendUsage, isUsageOwnerFilter, parseUsageRange, readUsage, summarizeUsage, usageCsv, usageForOwner, USAGE_GROUPINGS, flushUsageLedger } from "./usage-ledger.js";
|
|
89
90
|
import { GroupUsageReader } from "./group-thread-usage.js";
|
|
90
91
|
import { ledgerCost } from "./model-prices.js";
|
|
@@ -292,9 +293,10 @@ import { compareWithinClass } from "./model-levels/classes.js";
|
|
|
292
293
|
import { HISTORY_RECEIPT_KIND, historyAttachmentStore } from "./harness-import/history.js";
|
|
293
294
|
import { chooseEngine, engineIntent, freeCandidate, harnessForName, localModel, newBotSelection, paidCandidate, perTokenModel } from "./harness-import/engine-policy.js";
|
|
294
295
|
import { createEngineTierRoutes } from "./routes/engine-tiers.js";
|
|
296
|
+
import { createModelGatewayRoutes } from "./model-gateway/route.js";
|
|
295
297
|
import { applyChibiDefaults, chibiDefaultSelection } from "./chibi-defaults.js";
|
|
296
298
|
import { createPrimaryBotRoutes } from "./routes/primary-bot.js";
|
|
297
|
-
import { EngineSnapshotCache, botTier, canDriveComputer, classLadder, engineAccount, engineHealth, engineLabel, engineTierClasses, engineTierLadders, engineTiersIncludeFree, generateLadders, handlesClientData, ladderForClass, keyBased, needsDelegation, resolveFailover, resolveLadder } from "./engine-tiers.js";
|
|
299
|
+
import { EngineSnapshotCache, botTier, canDriveComputer, classLadder, engineAccount, engineHealth, engineLabel, engineTierClasses, engineTierLadders, failoverClassOrder, engineTiersIncludeFree, generateLadders, handlesClientData, ladderForClass, keyBased, needsDelegation, resolveFailover, resolveLadder } from "./engine-tiers.js";
|
|
298
300
|
import { PRIMARY_BOT_THREAD_TITLE, PRIMARY_BOT_TRIGGER, PrimaryBotStore, routesAsSweep, PrimaryBotSweeper } from "./primary-bot.js";
|
|
299
301
|
import { PRIMARY_BOT_LOCKED, primaryBotChoiceField } from "../shared/primary-bot.js";
|
|
300
302
|
import { moveIntoChibi } from "./move-into-chibi.js";
|
|
@@ -2297,9 +2299,9 @@ async function defaultSelection() {
|
|
|
2297
2299
|
refusal: (instance) => policyModelRefusal(instance),
|
|
2298
2300
|
});
|
|
2299
2301
|
}
|
|
2300
|
-
/** Chibi is made on
|
|
2301
|
-
* on
|
|
2302
|
-
*
|
|
2302
|
+
/** Chibi is made on Atomic Engine (Auto), else its Claude default, when
|
|
2303
|
+
* here (chibiDefaultSelection); otherwise on Atomic Engine's own default when
|
|
2304
|
+
* its CLI is installed and allowed; otherwise on the workspace default. */
|
|
2303
2305
|
async function builtinChibiSelection() {
|
|
2304
2306
|
if (hostedModels)
|
|
2305
2307
|
return defaultSelection();
|
|
@@ -2331,8 +2333,8 @@ const tierCandidates = (described) => {
|
|
|
2331
2333
|
return described.filter((instance) => policyModelRefusal(instance) === undefined).map((instance) => {
|
|
2332
2334
|
// An engine added as a provider account is paid as that account is: a
|
|
2333
2335
|
// flat plan used through a key (the Qwen Coding Plan) is a subscription.
|
|
2334
|
-
|
|
2335
|
-
const billing =
|
|
2336
|
+
// Ollama Team's included credit decides while it lasts (server/plan-credit.ts).
|
|
2337
|
+
const billing = accountBilling(instance.instanceId, configs[instance.instanceId], DATA_DIR);
|
|
2336
2338
|
return billing ? { ...instance, billing } : instance;
|
|
2337
2339
|
});
|
|
2338
2340
|
};
|
|
@@ -2616,8 +2618,7 @@ function subscriptionCandidate(instanceId) {
|
|
|
2616
2618
|
const described = engineSnapshots.current()?.find((candidate) => candidate.instanceId === instanceId);
|
|
2617
2619
|
if (described)
|
|
2618
2620
|
return described;
|
|
2619
|
-
const
|
|
2620
|
-
const billing = account === undefined ? undefined : accountProvider(account)?.billing;
|
|
2621
|
+
const billing = accountBilling(instanceId, providerConfigs()[instanceId], DATA_DIR);
|
|
2621
2622
|
return {
|
|
2622
2623
|
instanceId, driverKind: registry.get(instanceId)?.driverKind ?? "", displayName: instanceId,
|
|
2623
2624
|
snapshot: { state: "available" }, models: { default: "", options: [] }, ...(billing ? { billing } : {}),
|
|
@@ -3387,7 +3388,7 @@ const engineRests = new EngineRestStore(DATA_DIR, undefined, { probeBaseMs: prob
|
|
|
3387
3388
|
// engine's own trouble, not the account's.
|
|
3388
3389
|
bindAtomicEngineAccountSource(() => ({
|
|
3389
3390
|
instances: providerConfigs(),
|
|
3390
|
-
engineInstanceId: "atomic-engine",
|
|
3391
|
+
engineInstanceId: "atomic-engine", classModels: classedModels(), classOrder: failoverClassOrder(engineTierClasses(cfg.engineTiers).orchestrator), // class Auto (server/atomic-engine-classes.ts)
|
|
3391
3392
|
owner: instanceOwner,
|
|
3392
3393
|
restingUntil: (instanceId) => engineRests.active()
|
|
3393
3394
|
.filter((entry) => entry.instanceId === instanceId && !entry.scope && entry.reason !== "stalled")
|
|
@@ -3518,7 +3519,7 @@ function classSelection(profile, projected, candidates, modelClass) {
|
|
|
3518
3519
|
function botClassChoices(profile, threadId) {
|
|
3519
3520
|
const tier = botTier(profile);
|
|
3520
3521
|
const task = store.taskByThread(profile.id, threadId);
|
|
3521
|
-
const base = { tier, tierClass: engineTierClasses(cfg.engineTiers)[tier], bot: botEngineMode(profile),
|
|
3522
|
+
const base = { tier, tierClass: engineTierClasses(cfg.engineTiers)[tier], bot: botEngineMode(profile), includeFree: engineTiersIncludeFree(cfg.engineTiers),
|
|
3522
3523
|
...(task ? { thread: threadEngineMode(profile, task) } : {}) };
|
|
3523
3524
|
const projected = store.projectBotForTask(profile.id, threadId);
|
|
3524
3525
|
if (hostedModels || !projected)
|
|
@@ -16181,7 +16182,7 @@ const deliverableAccess = (senderId, auth) => sharedDeliverableAccess(sharedDeli
|
|
|
16181
16182
|
canSeeGroup: auth ? (id) => visibleTo(viewerFor(auth)).group(id) : () => true,
|
|
16182
16183
|
});
|
|
16183
16184
|
ROUTES.push(createSharedDeliverablesRoutes(sharedDeliverables, () => deliverableAccess(undefined).sharedBlockedRoots ?? []));
|
|
16184
|
-
ROUTES.push(createMessageFileRoutes({ store, attachments: ATTACHMENTS_DIR, workspaceDir, access: deliverableAccess }));
|
|
16185
|
+
ROUTES.push(createMessageFileRoutes({ store, attachments: ATTACHMENTS_DIR, workspaceDir, access: deliverableAccess }), createModelGatewayRoutes());
|
|
16185
16186
|
ROUTES.push(createPinOrderRoutes({ store, visible: (auth) => visibleTo(viewerFor(auth)), personalHidden: personalBotHidden, fromBot: (req) => authorizedInternalCapability(req.headers.authorization) !== null }));
|
|
16186
16187
|
// Linked repos: Settings > Repos, per-thread links and worktrees. See
|
|
16187
16188
|
// server/routes/repos.ts for the routes and docs/chibitek/README.md.
|
|
@@ -16464,8 +16465,7 @@ const handleRequest = async (req, res) => {
|
|
|
16464
16465
|
if (path.startsWith("/api/") && path !== "/api/events" && path !== "/api/health" && !path.startsWith("/api/shared-computers/") && !isWorkspaceBackupSessionControl(method, path)) {
|
|
16465
16466
|
releaseWorkspaceRequest = workspaceMaintenance.request();
|
|
16466
16467
|
}
|
|
16467
|
-
// New routes live in modules registered in server/routes/table.ts and
|
|
16468
|
-
// are tried here, behind the gate above; do not add route `if`s below.
|
|
16468
|
+
// New routes live in modules registered in server/routes/table.ts and are tried here, behind the gate above; no route `if`s below.
|
|
16469
16469
|
if (await dispatchRoutes(ROUTES, { req, res, url, path, method, auth, json, readBody }))
|
|
16470
16470
|
return;
|
|
16471
16471
|
// ── sessions: who am I, tickets, pairing and revocation ─────────────
|