@chibitek/chibi 0.1.191 → 0.1.193
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-D8Eovq0F.js → TerminalPanel-BtDirrJJ.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-CPvuUneJ.js → abnfDiagram-O67JEVCF-C37-IeyR.js} +1 -1
- package/dist/assets/{arc-aMP_0t5b.js → arc-glzbadrM.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-yyXrFi66.js → architectureDiagram-NJMV4G6O-Bcx1rmTd.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-BQN3ZvRc.js → blockDiagram-BEXU5L5S-B6KUNaLE.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-BieilTo4.js → c4Diagram-YGBWAQC7-DZ__tNnZ.js} +1 -1
- package/dist/assets/channel-C2UiHr1q.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-Df4lxXIM.js → chunk-2Q5K7J3B-Dn-yLeEA.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-su_KXf5y.js → chunk-3FUC2YCW-BB0MhLD8.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-DL3rM5tY.js → chunk-5VM5RSS4-B0MU1Lq4.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-53Ovfw1t.js → chunk-GTNCS2PH-BmT88VI9.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BkeiDfwS.js → chunk-GWA4HPMP-hgdMCsOk.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CvsdGjCO.js → chunk-JWPE2WC7-zlkz0m7Z.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-BngSjMee.js → chunk-NETBCI7D-Dz15-399.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-DitKn6fq.js → chunk-WEXAMYUT-CrWvQLTH.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Czjvl52d.js → chunk-XXDRQBXY-BRuLbyd6.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-COr4Qzpk.js → classDiagram-v2-NBCMYWYE-BoexnyNG.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-Eg0tlzqp.js → cose-bilkent-JH36ORCC-CPTjVRUh.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-BjtG84WL.js → cynefin-OW5HDTMX-DtqtEAnC.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-BzZtwDD4.js → cynefinDiagram-VND7K2PF-BVP8JLg8.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-TrLQ507j.js → dagre-6A5THRUB-BBDMxGXp.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BDQDC-33.js → diagram-22UHCM2B-BRZ8cAsI.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-Cm_mzSfE.js → diagram-3UASUU5V-D3lhs7ty.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-CAI_i4oy.js → diagram-ATOU4E4O-n8v1YvKt.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-9GjNyQXn.js → diagram-CDSNMT55-B6jeaO-z.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-ETDg4UN-.js → diagram-MLGK6HIB-BLmKtNgD.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-8_8dZKgW.js → diagram-MPIPVDR6-CNWlEkJQ.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-BiYh2ZYM.js → ebnfDiagram-ZINNZB2B-C0uBXIgJ.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-5u6sMYIg.js → elk-276RUBZZ-DCjvJpgP.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-Dm6semJ3.js → erDiagram-OPXOYQCR-BryVWOsq.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-DbQ12CeV.js → flowDiagram-KWPJA3E3-Cq-t83b3.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-C12s51S6.js → ganttDiagram-FUAMR5RP-4vyfI4a8.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-BhkwBL2T.js → gitGraphDiagram-X574FWY7-DxZIWlPq.js} +1 -1
- package/dist/assets/{index-D4BfC2Zf.js → index-C2Rnf5Lg.js} +1 -1
- package/dist/assets/{index-WT8Xwc4G.js → index-DtMmBnv1.js} +163 -163
- package/dist/assets/{infoDiagram-VRGFBTTK-IvWqyiSM.js → infoDiagram-VRGFBTTK-CdS4oDZm.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-N2ZxLyoE.js → ishikawaDiagram-OU5B5YK6-7FJ6XPAt.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-UWy3ala_.js → journeyDiagram-ZHPQQLJL-DK5jSuP5.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-Cutk-kDA.js → kanban-definition-PNTS6WVX-LSLVTPp1.js} +1 -1
- package/dist/assets/{linear-dPnV_-aA.js → linear-C8T48PcW.js} +1 -1
- package/dist/assets/{mermaid.core-QdldWb2L.js → mermaid.core-CajU6Pki.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-pkXW8CYn.js → mindmap-definition-NLK3R4M7-26gQ6jip.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-DhKkEQzV.js → pegDiagram-GJSIUBJH-rvhqKdDP.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DMehGrxw.js → pieDiagram-5QR66LMP-BOFsvwEp.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-oNzYf4fg.js → quadrantDiagram-O4NWA36T-BGd_kb8s.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-pkMOwYja.js → railroadDiagram-XR7U4H2S-DROi1ea2.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-J29GrlJj.js → requirementDiagram-PLB6GJNP-BLFC_C4R.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-YuyCeGY6.js → sankeyDiagram-IPEJSGJF-bCdrWFYF.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-BjxLu0JW.js → sequenceDiagram-PO4LG4MO-CaCPCA52.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BESOD3ec.js → sizeCapture-INFHLROL-DZr2YdGO.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-DF2yvbZA.js → stateDiagram-v2-GCMORJYK-BymY8iLv.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-Bzp4ze7n.js → swimlanes-2SLR337P-NumTJ1tl.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-CjJ-nT3Z.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-CnLbXs4R.js → timeline-definition-EJHVYXUP-d9-CUPKk.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-nuJhbhCv.js → usecaseDiagram-POWQR4AR-CGvoockc.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-D_hzVg9h.js → vennDiagram-UO4OBE2U-CUkwrnK7.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-hgmpI4iu.js → wardleyDiagram-VNRHLVJA-DALQej81.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DwnJWdDn.js → xychartDiagram-PMCCYNJV-2oukzPo1.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/container-mcp.js +2 -1
- package/dist-server/index.js +642 -207
- package/dist-server/mcp-server.js +36 -1
- package/dist-server/openmausbot.js +257 -66
- package/dist-server/pair-cli.js +257 -66
- 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/nexus-memory/backoff.js +41 -0
- package/dist-server/server/nexus-memory/client.js +55 -11
- package/dist-server/server/nexus-memory/index.js +4 -23
- 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/vault/store.js +8 -4
- 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 +23 -2
- package/dist-server/shared/vault.js +3 -2
- package/dist-server/vps-container-mcp.js +2 -1
- package/package.json +1 -1
- package/dist/assets/channel-Bw54wjTR.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-B6y4ZZ5q.js +0 -8
- package/dist-server/server/session-fallback.js +0 -76
package/dist-server/index.js
CHANGED
|
@@ -31390,10 +31390,12 @@ function toModelClass(value) {
|
|
|
31390
31390
|
}
|
|
31391
31391
|
var classBelow = (modelClass) => MODEL_CLASSES[MODEL_CLASSES.indexOf(modelClass) + 1];
|
|
31392
31392
|
var DEFAULT_CLASS_BANDS = { Mezcal: 50, Plata: 44, Reposado: 38 };
|
|
31393
|
-
var
|
|
31394
|
-
var
|
|
31393
|
+
var ATOMIC_AUTO_RUNG = Object.freeze({ engine: "atomic-engine", model: "atomic/auto" });
|
|
31394
|
+
var CHIBI_DEFAULT_RUNG = Object.freeze({ engine: "claudeAgent", model: "claude-opus-5", modelClass: "Plata" });
|
|
31395
|
+
var CHIBI_DEFAULTS_VERSION = 2;
|
|
31395
31396
|
var DEFAULT_LADDERS = {
|
|
31396
31397
|
orchestrator: [
|
|
31398
|
+
{ ...ATOMIC_AUTO_RUNG },
|
|
31397
31399
|
{ ...CHIBI_DEFAULT_RUNG },
|
|
31398
31400
|
{ engine: "claudeAgent", model: "claude-opus-5-5", modelClass: "Plata" },
|
|
31399
31401
|
{ engine: "codex", model: "gpt-6-sol" },
|
|
@@ -31412,6 +31414,7 @@ var DEFAULT_LADDERS = {
|
|
|
31412
31414
|
{ engine: "hermesAgent", model: "openai-codex:gpt-6.1-sol", modelClass: "Plata" }
|
|
31413
31415
|
],
|
|
31414
31416
|
engineering: [
|
|
31417
|
+
{ ...ATOMIC_AUTO_RUNG },
|
|
31415
31418
|
{ engine: "codex", model: "gpt-6-astra", modelClass: "Mezcal" },
|
|
31416
31419
|
{ engine: "claude", model: "claude-opus-5-5" },
|
|
31417
31420
|
{ engine: "claudeAgent", model: "claude-opus-5-5" },
|
|
@@ -31427,6 +31430,7 @@ var DEFAULT_LADDERS = {
|
|
|
31427
31430
|
{ engine: "cursorAgent", model: "auto" }
|
|
31428
31431
|
],
|
|
31429
31432
|
research: [
|
|
31433
|
+
{ ...ATOMIC_AUTO_RUNG },
|
|
31430
31434
|
{ engine: "openai-compat", model: "MiniMax-M2.5" },
|
|
31431
31435
|
{ engine: "vibe", model: "mistral-medium-3.5" },
|
|
31432
31436
|
{ engine: "antigravityAgent", model: "gemini-3.8-flash-low" },
|
|
@@ -31440,6 +31444,7 @@ var DEFAULT_LADDERS = {
|
|
|
31440
31444
|
{ engine: "opencodeGo", model: "opencode/claude-opus-5", modelClass: "Plata" }
|
|
31441
31445
|
],
|
|
31442
31446
|
writing: [
|
|
31447
|
+
{ ...ATOMIC_AUTO_RUNG },
|
|
31443
31448
|
{ engine: "claudeAgent", model: "claude-sonnet-5-5" },
|
|
31444
31449
|
{ engine: "claude", model: "claude-sonnet-5-5" },
|
|
31445
31450
|
{ engine: "codex", model: "gpt-5.6-luna" },
|
|
@@ -31448,6 +31453,7 @@ var DEFAULT_LADDERS = {
|
|
|
31448
31453
|
{ engine: "hermes", model: "nous:moonshotai/kimi-k3" }
|
|
31449
31454
|
],
|
|
31450
31455
|
routine: [
|
|
31456
|
+
{ ...ATOMIC_AUTO_RUNG },
|
|
31451
31457
|
{ engine: "antigravityAgent", model: "gemini-3.8-flash-low" },
|
|
31452
31458
|
{ engine: "antigravity", model: "gemini-3.8-flash-low" },
|
|
31453
31459
|
{ engine: "openai-compat", model: "MiniMax-M2.5" },
|
|
@@ -33781,7 +33787,9 @@ var ACCOUNT_PROVIDERS = [
|
|
|
33781
33787
|
keyUrl: "https://console.mistral.ai/api-keys"
|
|
33782
33788
|
},
|
|
33783
33789
|
{
|
|
33784
|
-
// Ollama's Free, Pro and
|
|
33790
|
+
// Ollama's Free, Pro, Max and Team plans each include a monthly credit.
|
|
33791
|
+
// Unused credit does not carry over (use it or lose it); use past it is
|
|
33792
|
+
// billed by Ollama (Erick, 2026-11-15).
|
|
33785
33793
|
id: "ollamaCloud",
|
|
33786
33794
|
kind: "apiKey",
|
|
33787
33795
|
label: "Ollama Cloud",
|
|
@@ -33792,17 +33800,19 @@ var ACCOUNT_PROVIDERS = [
|
|
|
33792
33800
|
config: {},
|
|
33793
33801
|
keyTest: { provider: "ollamaCloud" },
|
|
33794
33802
|
keyUrl: "https://ollama.com/settings/keys",
|
|
33795
|
-
signupUrl: "https://ollama.com/pricing"
|
|
33803
|
+
signupUrl: "https://ollama.com/pricing",
|
|
33804
|
+
plan: { kind: "includedCredit", unusedCredit: "expires", afterCredit: "overage" }
|
|
33796
33805
|
},
|
|
33797
33806
|
{
|
|
33798
33807
|
// Nous Portal's OpenAI-compatible API with a portal key: no Hermes needed
|
|
33799
|
-
// (Erick, 2026-11-08).
|
|
33800
|
-
//
|
|
33801
|
-
//
|
|
33808
|
+
// (Erick, 2026-11-08). Counted as the person's Nous subscription, not pay
|
|
33809
|
+
// per use (Erick, 2026-11-15, reversing the 2026-11-13 per-use reading of
|
|
33810
|
+
// Portal's terms): it walks with the subscriptions and Atomic Engine uses
|
|
33811
|
+
// it as the `nous-api` provider (server/atomic-engine-accounts.ts).
|
|
33802
33812
|
id: "nous",
|
|
33803
33813
|
kind: "apiKey",
|
|
33804
33814
|
label: "Nous Research",
|
|
33805
|
-
billing: "
|
|
33815
|
+
billing: "subscription",
|
|
33806
33816
|
driver: "openai-compat",
|
|
33807
33817
|
envVar: "NOUS_API_KEY",
|
|
33808
33818
|
config: { url: "https://inference-api.nousresearch.com/v1", apiKeyEnv: "NOUS_API_KEY", model: "Hermes-4-405B", provider: "" },
|
|
@@ -33889,6 +33899,24 @@ var ACCOUNT_PROVIDERS = [
|
|
|
33889
33899
|
signupUrl: "https://build.nvidia.com/"
|
|
33890
33900
|
}
|
|
33891
33901
|
];
|
|
33902
|
+
function planTerms(provider) {
|
|
33903
|
+
if (provider.kind === "signIn") return { kind: "signIn" };
|
|
33904
|
+
if (provider.plan) return provider.plan;
|
|
33905
|
+
if (provider.billing === "subscription") return { kind: "flatPlan" };
|
|
33906
|
+
return provider.billing === "free" ? { kind: "free" } : { kind: "perToken" };
|
|
33907
|
+
}
|
|
33908
|
+
function billingWithCredit(terms, creditLeftUsd) {
|
|
33909
|
+
switch (terms.kind) {
|
|
33910
|
+
case "includedCredit":
|
|
33911
|
+
return creditLeftUsd !== void 0 && creditLeftUsd <= 0 && terms.afterCredit === "overage" ? "payPerUse" : "subscription";
|
|
33912
|
+
case "perToken":
|
|
33913
|
+
return "payPerUse";
|
|
33914
|
+
case "free":
|
|
33915
|
+
return "free";
|
|
33916
|
+
default:
|
|
33917
|
+
return "subscription";
|
|
33918
|
+
}
|
|
33919
|
+
}
|
|
33892
33920
|
function accountProvider(id) {
|
|
33893
33921
|
return ACCOUNT_PROVIDERS.find((provider) => provider.id === id);
|
|
33894
33922
|
}
|
|
@@ -34591,7 +34619,8 @@ var instanceConfigSchema = external_exports.object({
|
|
|
34591
34619
|
environment: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
34592
34620
|
enabled: external_exports.boolean().optional(),
|
|
34593
34621
|
config: external_exports.json().optional(),
|
|
34594
|
-
account: external_exports.string().trim().min(1).max(64).optional()
|
|
34622
|
+
account: external_exports.string().trim().min(1).max(64).optional(),
|
|
34623
|
+
planCreditUsd: external_exports.number().positive().max(1e6).optional()
|
|
34595
34624
|
});
|
|
34596
34625
|
var instanceConfigMapSchema = external_exports.record(external_exports.string(), instanceConfigSchema);
|
|
34597
34626
|
var defaultModelSelectionSchema = external_exports.object({
|
|
@@ -39208,9 +39237,9 @@ var ClaudeDriver = {
|
|
|
39208
39237
|
sessionAllows: {
|
|
39209
39238
|
has: (key5) => sessionAllows.get(threadId)?.has(key5) ?? false,
|
|
39210
39239
|
add: (key5) => {
|
|
39211
|
-
const
|
|
39212
|
-
|
|
39213
|
-
sessionAllows.set(threadId,
|
|
39240
|
+
const remembered2 = sessionAllows.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
39241
|
+
remembered2.add(key5);
|
|
39242
|
+
sessionAllows.set(threadId, remembered2);
|
|
39214
39243
|
}
|
|
39215
39244
|
},
|
|
39216
39245
|
// host control stays one action at a time
|
|
@@ -47364,9 +47393,9 @@ async function sleepManagedBox(cfg2, owners, boxId, claim) {
|
|
|
47364
47393
|
}
|
|
47365
47394
|
async function deleteManagedBox(cfg2, owners, boxId, confirmName, claim, options = {}) {
|
|
47366
47395
|
cfg2 = snapshotBoxConfig(cfg2);
|
|
47367
|
-
const
|
|
47368
|
-
if (
|
|
47369
|
-
const reconciled = await reconcileRecordedBoxDeletion(cfg2,
|
|
47396
|
+
const remembered2 = getBoxDeletion(boxId);
|
|
47397
|
+
if (remembered2) {
|
|
47398
|
+
const reconciled = await reconcileRecordedBoxDeletion(cfg2, remembered2, [0]);
|
|
47370
47399
|
if (reconciled === "confirmed") return { ok: true };
|
|
47371
47400
|
const current4 = getBoxDeletion(boxId);
|
|
47372
47401
|
if (current4?.phase === "accepted") {
|
|
@@ -47569,9 +47598,9 @@ async function createBox(cfg2, botId, env) {
|
|
|
47569
47598
|
return trialTtl === null ? first : requestBoxCreate(cfg2, botId, trialTtl, env);
|
|
47570
47599
|
}
|
|
47571
47600
|
async function finishPriorDeletionBeforeProvision(cfg2, botId) {
|
|
47572
|
-
const
|
|
47573
|
-
if (!
|
|
47574
|
-
for (const deletion of
|
|
47601
|
+
const remembered2 = boxDeletionSnapshot().filter((record12) => record12.ownerBotId === botId);
|
|
47602
|
+
if (!remembered2.length) return;
|
|
47603
|
+
for (const deletion of remembered2) {
|
|
47575
47604
|
let state2 = await reconcileRecordedBoxDeletion(cfg2, deletion, [0]);
|
|
47576
47605
|
if (state2 !== "confirmed") {
|
|
47577
47606
|
const current4 = getBoxDeletion(deletion.boxId);
|
|
@@ -49107,12 +49136,12 @@ async function containerComputerScreenshot(runner = sh, platform = process.platf
|
|
|
49107
49136
|
return `data:image/${format};base64,${png}`;
|
|
49108
49137
|
}
|
|
49109
49138
|
var screenshotStatusCache = /* @__PURE__ */ new Map();
|
|
49110
|
-
async function recentContainerComputerStatus(target = SHARED_LOCAL_VM_TARGET, runner = sh, platform = process.platform,
|
|
49111
|
-
const cached3 =
|
|
49139
|
+
async function recentContainerComputerStatus(target = SHARED_LOCAL_VM_TARGET, runner = sh, platform = process.platform, cache3 = runner === sh && platform === process.platform ? screenshotStatusCache : null) {
|
|
49140
|
+
const cached3 = cache3?.get(target.key);
|
|
49112
49141
|
if (cached3 && cached3.expiresAt > Date.now()) return cached3.status;
|
|
49113
49142
|
const status = await containerComputerStatus(runner, platform, target);
|
|
49114
|
-
if (
|
|
49115
|
-
else
|
|
49143
|
+
if (cache3 && status.ready) cache3.set(target.key, { status, expiresAt: Date.now() + SCREENSHOT_STATUS_TTL_MS });
|
|
49144
|
+
else cache3?.delete(target.key);
|
|
49116
49145
|
return status;
|
|
49117
49146
|
}
|
|
49118
49147
|
var containerMcpPath = SPAWNED_PROXIES.containerMcp;
|
|
@@ -52767,6 +52796,47 @@ function runNpm(args, env, cwd, timeoutMs, launch = npmLaunch(), onOutput) {
|
|
|
52767
52796
|
});
|
|
52768
52797
|
}
|
|
52769
52798
|
|
|
52799
|
+
// server/plan-credit.ts
|
|
52800
|
+
var CACHE_MS = 15e3;
|
|
52801
|
+
var cache = /* @__PURE__ */ new Map();
|
|
52802
|
+
var monthOf = (now) => now.toISOString().slice(0, 7);
|
|
52803
|
+
var costOf = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
52804
|
+
function monthToDateByInstance(dataDir2, now = /* @__PURE__ */ new Date()) {
|
|
52805
|
+
const month = monthOf(now);
|
|
52806
|
+
const hit = cache.get(dataDir2);
|
|
52807
|
+
if (hit && hit.month === month && now.getTime() - hit.at < CACHE_MS) return hit.byInstance;
|
|
52808
|
+
const from = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
|
|
52809
|
+
const byInstance = /* @__PURE__ */ new Map();
|
|
52810
|
+
for (const row of readUsage(dataDir2, { from, to: now })) {
|
|
52811
|
+
byInstance.set(row.instanceId, (byInstance.get(row.instanceId) ?? 0) + costOf(row.costUsd));
|
|
52812
|
+
}
|
|
52813
|
+
cache.set(dataDir2, { at: now.getTime(), month, byInstance });
|
|
52814
|
+
return byInstance;
|
|
52815
|
+
}
|
|
52816
|
+
function resetPlanCreditCache() {
|
|
52817
|
+
cache.clear();
|
|
52818
|
+
}
|
|
52819
|
+
function providerOf(entry) {
|
|
52820
|
+
if (entry.account !== void 0) return accountProvider(entry.account);
|
|
52821
|
+
return accountProvider(entry.driver === "ollamaCloud" ? "ollamaCloud" : void 0);
|
|
52822
|
+
}
|
|
52823
|
+
function planCredit(instanceId, entry, spent) {
|
|
52824
|
+
const provider = providerOf(entry);
|
|
52825
|
+
if (!provider) return void 0;
|
|
52826
|
+
const terms = planTerms(provider);
|
|
52827
|
+
if (terms.kind !== "includedCredit") return void 0;
|
|
52828
|
+
const monthlyCreditUsd = entry.planCreditUsd ?? terms.monthlyCreditUsd;
|
|
52829
|
+
if (monthlyCreditUsd === void 0 || !(monthlyCreditUsd > 0)) return void 0;
|
|
52830
|
+
const spentUsd = spent.get(instanceId) ?? 0;
|
|
52831
|
+
const leftUsd = Math.max(0, monthlyCreditUsd - spentUsd);
|
|
52832
|
+
return { monthlyCreditUsd, spentUsd, leftUsd, billing: billingWithCredit(terms, monthlyCreditUsd - spentUsd) };
|
|
52833
|
+
}
|
|
52834
|
+
function accountBilling(instanceId, entry, dataDir2) {
|
|
52835
|
+
if (!entry) return void 0;
|
|
52836
|
+
const credit = planCredit(instanceId, entry, monthToDateByInstance(dataDir2));
|
|
52837
|
+
return credit?.billing ?? (entry.account === void 0 ? void 0 : accountProvider(entry.account)?.billing);
|
|
52838
|
+
}
|
|
52839
|
+
|
|
52770
52840
|
// server/group-thread-usage.ts
|
|
52771
52841
|
import { readdirSync as readdirSync7, readFileSync as readFileSync27, statSync as statSync7 } from "node:fs";
|
|
52772
52842
|
import { join as join34 } from "node:path";
|
|
@@ -53190,21 +53260,21 @@ function describeEdition(status) {
|
|
|
53190
53260
|
|
|
53191
53261
|
// server/spend.ts
|
|
53192
53262
|
var DEFAULT_WARN_AT_PERCENT = 80;
|
|
53193
|
-
var
|
|
53194
|
-
var
|
|
53263
|
+
var CACHE_MS2 = 15e3;
|
|
53264
|
+
var cache2 = /* @__PURE__ */ new Map();
|
|
53195
53265
|
var unwritten = /* @__PURE__ */ new Map();
|
|
53196
|
-
function
|
|
53266
|
+
function monthOf2(now) {
|
|
53197
53267
|
return now.toISOString().slice(0, 7);
|
|
53198
53268
|
}
|
|
53199
|
-
var
|
|
53269
|
+
var costOf2 = (value) => typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
53200
53270
|
function monthToDateSpend(dataDir2, now = /* @__PURE__ */ new Date()) {
|
|
53201
|
-
const month =
|
|
53202
|
-
let read =
|
|
53203
|
-
if (!read || read.month !== month || now.getTime() - read.at >=
|
|
53271
|
+
const month = monthOf2(now);
|
|
53272
|
+
let read = cache2.get(dataDir2);
|
|
53273
|
+
if (!read || read.month !== month || now.getTime() - read.at >= CACHE_MS2) {
|
|
53204
53274
|
const from = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
|
|
53205
53275
|
const rows = readUsage(dataDir2, { from, to: now });
|
|
53206
|
-
read = { at: now.getTime(), month, fileUsd: rows.reduce((sum, row) => sum +
|
|
53207
|
-
|
|
53276
|
+
read = { at: now.getTime(), month, fileUsd: rows.reduce((sum, row) => sum + costOf2(row.costUsd), 0), keys: new Set(rows.map(usageRowKey)) };
|
|
53277
|
+
cache2.set(dataDir2, read);
|
|
53208
53278
|
}
|
|
53209
53279
|
let pending2 = 0;
|
|
53210
53280
|
for (const [key5, entry] of unwritten.get(dataDir2) ?? []) {
|
|
@@ -53213,7 +53283,7 @@ function monthToDateSpend(dataDir2, now = /* @__PURE__ */ new Date()) {
|
|
|
53213
53283
|
return read.fileUsd + pending2;
|
|
53214
53284
|
}
|
|
53215
53285
|
function noteSpend(dataDir2, row, written) {
|
|
53216
|
-
const costUsd =
|
|
53286
|
+
const costUsd = costOf2(row.costUsd);
|
|
53217
53287
|
if (!costUsd) return;
|
|
53218
53288
|
const key5 = usageRowKey(row);
|
|
53219
53289
|
const month = row.at.slice(0, 7);
|
|
@@ -53223,7 +53293,7 @@ function noteSpend(dataDir2, row, written) {
|
|
|
53223
53293
|
void written.then((landed) => {
|
|
53224
53294
|
entries2.delete(key5);
|
|
53225
53295
|
if (entries2.size === 0 && unwritten.get(dataDir2) === entries2) unwritten.delete(dataDir2);
|
|
53226
|
-
const read =
|
|
53296
|
+
const read = cache2.get(dataDir2);
|
|
53227
53297
|
if (landed && read && read.month === month && !read.keys.has(key5)) {
|
|
53228
53298
|
read.fileUsd += costUsd;
|
|
53229
53299
|
read.keys.add(key5);
|
|
@@ -53237,7 +53307,7 @@ function spendState(cfg2, dataDir2, now = /* @__PURE__ */ new Date(), isEntitled
|
|
|
53237
53307
|
const warnAtPercent = cfg2.budgets?.warnAtPercent ?? DEFAULT_WARN_AT_PERCENT;
|
|
53238
53308
|
const percent = Math.min(999, Math.round(spentUsd / monthlyUsd * 100));
|
|
53239
53309
|
return {
|
|
53240
|
-
month:
|
|
53310
|
+
month: monthOf2(now),
|
|
53241
53311
|
monthlyUsd,
|
|
53242
53312
|
spentUsd,
|
|
53243
53313
|
percent,
|
|
@@ -62080,9 +62150,9 @@ function createAcpDriver(support12) {
|
|
|
62080
62150
|
const named = isQuestion && behavior === "answer" ? options.filter((option) => option.optionId === message4 || option.name?.trim() === message4) : [];
|
|
62081
62151
|
const optionId = behavior === "cancel" ? null : isQuestion ? named.length === 1 && typeof named[0].optionId === "string" ? named[0].optionId : null : forSession ? optionAlways ?? optionFor2("allow") : optionFor2(want);
|
|
62082
62152
|
if (forSession && !optionAlways && optionId && operationKey) {
|
|
62083
|
-
const
|
|
62084
|
-
|
|
62085
|
-
sessionAllows.set(threadId,
|
|
62153
|
+
const remembered2 = sessionAllows.get(threadId) ?? /* @__PURE__ */ new Set();
|
|
62154
|
+
remembered2.add(operationKey);
|
|
62155
|
+
sessionAllows.set(threadId, remembered2);
|
|
62086
62156
|
}
|
|
62087
62157
|
if (behavior !== "cancel" && !optionId) missing(isQuestion ? "matching answer" : want);
|
|
62088
62158
|
send2({
|
|
@@ -69262,8 +69332,8 @@ var Connection = class {
|
|
|
69262
69332
|
if (memory2 !== void 0 && memory2.signature !== signature2) {
|
|
69263
69333
|
throw new ProtocolError(`commandId ${commandId} was reused with a different payload`);
|
|
69264
69334
|
}
|
|
69265
|
-
const
|
|
69266
|
-
this.#commands.set(commandId,
|
|
69335
|
+
const remembered2 = memory2 ?? { signature: signature2 };
|
|
69336
|
+
this.#commands.set(commandId, remembered2);
|
|
69267
69337
|
const maxAttempts = Math.max(1, options?.maxAttempts ?? 3);
|
|
69268
69338
|
const retryDelay = options?.retryDelay ?? defaultRetryDelay;
|
|
69269
69339
|
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
@@ -69273,10 +69343,10 @@ var Connection = class {
|
|
|
69273
69343
|
throw new ProtocolError(`${method} ack commandId ${String(ack["commandId"])} did not echo ${commandId}`);
|
|
69274
69344
|
}
|
|
69275
69345
|
const ackFingerprint = fingerprint2(canonical2(ack));
|
|
69276
|
-
if (
|
|
69346
|
+
if (remembered2.ack !== void 0 && remembered2.ack !== ackFingerprint) {
|
|
69277
69347
|
throw new ProtocolError(`${method} replay for commandId ${commandId} did not return a value-identical ack`);
|
|
69278
69348
|
}
|
|
69279
|
-
|
|
69349
|
+
remembered2.ack = ackFingerprint;
|
|
69280
69350
|
return ack;
|
|
69281
69351
|
} catch (error51) {
|
|
69282
69352
|
const retryableNothingAdmitted = error51 instanceof MspError && (error51.code === -32001 && error51.kind === "overloaded" || error51.code === -32031 && error51.kind === "backpressured");
|
|
@@ -71932,13 +72002,70 @@ import { basename as basename12, join as join59 } from "node:path";
|
|
|
71932
72002
|
import { mkdirSync as mkdirSync25, readFileSync as readFileSync45, writeFileSync as writeFileSync19 } from "node:fs";
|
|
71933
72003
|
import { homedir as homedir28 } from "node:os";
|
|
71934
72004
|
import { join as join55 } from "node:path";
|
|
72005
|
+
|
|
72006
|
+
// server/atomic-engine-classes.ts
|
|
72007
|
+
var PROVIDER_DRIVER = {
|
|
72008
|
+
anthropic: "claudeAgent",
|
|
72009
|
+
"openai-codex": "codex",
|
|
72010
|
+
"ollama-cloud": "ollamaCloud",
|
|
72011
|
+
minimax: "minimax"
|
|
72012
|
+
};
|
|
72013
|
+
var engineModelId = (provider, model2) => provider === "ollama-cloud" ? model2.replace(/:cloud$/i, "") : model2;
|
|
72014
|
+
function classPick(provider, models, order) {
|
|
72015
|
+
const driverKind = PROVIDER_DRIVER[provider];
|
|
72016
|
+
if (!driverKind) return void 0;
|
|
72017
|
+
for (const modelClass of order) {
|
|
72018
|
+
for (const graded of models) {
|
|
72019
|
+
if (graded.modelClass !== modelClass) continue;
|
|
72020
|
+
const run7 = graded.runs.find((candidate) => candidate.driverKind === driverKind);
|
|
72021
|
+
if (run7) return { model: engineModelId(provider, run7.model), modelClass };
|
|
72022
|
+
}
|
|
72023
|
+
}
|
|
72024
|
+
return void 0;
|
|
72025
|
+
}
|
|
72026
|
+
|
|
72027
|
+
// server/atomic-engine-local.ts
|
|
72028
|
+
var remembered = [];
|
|
72029
|
+
function localPicks(options) {
|
|
72030
|
+
const byHost = /* @__PURE__ */ new Map();
|
|
72031
|
+
const seenUrls = /* @__PURE__ */ new Set();
|
|
72032
|
+
for (const option of options) {
|
|
72033
|
+
const inject = decodeInjectId(option.id);
|
|
72034
|
+
const host = inject ? localHost(inject.host) : void 0;
|
|
72035
|
+
if (!inject || !host || isOllamaCloudModel(inject.model)) continue;
|
|
72036
|
+
const current4 = byHost.get(host.id);
|
|
72037
|
+
if (current4 && (current4.loaded || !option.loaded)) continue;
|
|
72038
|
+
if (!current4 && seenUrls.has(host.baseUrl)) continue;
|
|
72039
|
+
seenUrls.add(host.baseUrl);
|
|
72040
|
+
byHost.set(host.id, { host, model: inject.model, loaded: option.loaded === true });
|
|
72041
|
+
}
|
|
72042
|
+
return [...byHost.values()].map(({ host, model: model2 }) => ({ host, model: model2 }));
|
|
72043
|
+
}
|
|
72044
|
+
function rememberLocalModels(options) {
|
|
72045
|
+
remembered = localPicks(options);
|
|
72046
|
+
}
|
|
72047
|
+
function rememberedLocalModels() {
|
|
72048
|
+
return remembered;
|
|
72049
|
+
}
|
|
72050
|
+
|
|
72051
|
+
// server/atomic-engine-accounts.ts
|
|
71935
72052
|
var ACCOUNTS_ENV = "ATOMIC_ENGINE_ACCOUNTS";
|
|
71936
72053
|
var ACCOUNTS_FILE = "atomic-accounts.json";
|
|
71937
72054
|
var KEY_ENV_PREFIX = "ATOMIC_ACCOUNT_KEY_";
|
|
71938
72055
|
var FAILOVER_MODEL = {
|
|
71939
|
-
anthropic: "claude-
|
|
72056
|
+
anthropic: CHIBI_DEFAULT_RUNG.model ?? "claude-opus-5",
|
|
71940
72057
|
"openai-codex": "gpt-5.6-sol",
|
|
71941
|
-
"ollama-cloud": "kimi-k3"
|
|
72058
|
+
"ollama-cloud": "kimi-k3",
|
|
72059
|
+
// Atomic's MiniMax engine default (server/drivers/minimax.ts) and the
|
|
72060
|
+
// engine's own MiniMax default.
|
|
72061
|
+
minimax: "MiniMax-M3"
|
|
72062
|
+
};
|
|
72063
|
+
var KEY_PLAN_PROVIDER = {
|
|
72064
|
+
qwenCodingPlan: "alibaba-coding-plan",
|
|
72065
|
+
minimaxPlan: "minimax",
|
|
72066
|
+
zai: "zai",
|
|
72067
|
+
opencodeGo: "opencode-go",
|
|
72068
|
+
nous: "nous-api"
|
|
71942
72069
|
};
|
|
71943
72070
|
function rawConfig2(entry) {
|
|
71944
72071
|
return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config) ? entry.config : {};
|
|
@@ -71992,15 +72119,17 @@ function asAccount(id, entry) {
|
|
|
71992
72119
|
model: FAILOVER_MODEL["ollama-cloud"]
|
|
71993
72120
|
}, key: key5 };
|
|
71994
72121
|
}
|
|
71995
|
-
|
|
72122
|
+
const keyProvider = added?.kind === "apiKey" && added.billing === "subscription" ? KEY_PLAN_PROVIDER[added.id] : void 0;
|
|
72123
|
+
if (added?.kind === "apiKey" && keyProvider) {
|
|
71996
72124
|
const key5 = entry.environment?.[added.envVar]?.trim();
|
|
71997
72125
|
if (!key5) return null;
|
|
71998
72126
|
const config2 = rawConfig2(entry);
|
|
71999
|
-
const model2 = typeof config2.model === "string" && config2.model ? config2.model : added.config.model;
|
|
72000
|
-
const
|
|
72127
|
+
const model2 = typeof config2.model === "string" && config2.model ? config2.model : added.config.model ?? FAILOVER_MODEL[keyProvider];
|
|
72128
|
+
const ownUrl = entry.driver === "openai-compat" && typeof config2.url === "string" && config2.url ? config2.url : void 0;
|
|
72129
|
+
const baseUrl = ownUrl ?? added.config.url;
|
|
72001
72130
|
return { account: {
|
|
72002
72131
|
id,
|
|
72003
|
-
provider:
|
|
72132
|
+
provider: keyProvider,
|
|
72004
72133
|
kind: "api-key",
|
|
72005
72134
|
label,
|
|
72006
72135
|
billing: "subscription",
|
|
@@ -72010,7 +72139,7 @@ function asAccount(id, entry) {
|
|
|
72010
72139
|
}
|
|
72011
72140
|
return null;
|
|
72012
72141
|
}
|
|
72013
|
-
var KIND_ORDER = { "claude-code": 0, "codex-cli": 1, "api-key": 2 };
|
|
72142
|
+
var KIND_ORDER = { "claude-code": 0, "codex-cli": 1, "api-key": 2, local: 3 };
|
|
72014
72143
|
function atomicEngineAccounts(input) {
|
|
72015
72144
|
const engineOwner2 = input.owner(input.engineInstanceId);
|
|
72016
72145
|
const rows = [];
|
|
@@ -72021,9 +72150,26 @@ function atomicEngineAccounts(input) {
|
|
|
72021
72150
|
if (!found) continue;
|
|
72022
72151
|
const resting = input.restingUntil?.(id);
|
|
72023
72152
|
if (resting && resting > Date.now()) found.account.restingUntil = resting;
|
|
72153
|
+
const pick4 = input.classModels && input.classOrder ? classPick(found.account.provider, input.classModels, input.classOrder) : void 0;
|
|
72154
|
+
if (pick4) Object.assign(found.account, pick4);
|
|
72024
72155
|
rows.push({ ...found, order: order++ });
|
|
72025
72156
|
}
|
|
72026
|
-
|
|
72157
|
+
const classRank = (account2) => {
|
|
72158
|
+
const at2 = account2.modelClass ? (input.classOrder ?? MODEL_CLASSES).indexOf(account2.modelClass) : -1;
|
|
72159
|
+
return at2 < 0 ? MODEL_CLASSES.length : at2;
|
|
72160
|
+
};
|
|
72161
|
+
rows.sort((a, b3) => classRank(a.account) - classRank(b3.account) || KIND_ORDER[a.account.kind] - KIND_ORDER[b3.account.kind] || a.order - b3.order);
|
|
72162
|
+
for (const { host, model: model2 } of input.local ?? rememberedLocalModels()) {
|
|
72163
|
+
rows.push({ account: {
|
|
72164
|
+
id: `local-${host.id}`,
|
|
72165
|
+
provider: "custom",
|
|
72166
|
+
kind: "local",
|
|
72167
|
+
label: host.label,
|
|
72168
|
+
billing: "local",
|
|
72169
|
+
baseUrl: host.baseUrl,
|
|
72170
|
+
model: model2
|
|
72171
|
+
}, key: hostApiKey(host), order: order++ });
|
|
72172
|
+
}
|
|
72027
72173
|
const env = {};
|
|
72028
72174
|
rows.forEach((row, index2) => {
|
|
72029
72175
|
if (row.key === void 0) return;
|
|
@@ -72065,6 +72211,9 @@ function currentAtomicEngineAccounts() {
|
|
|
72065
72211
|
}
|
|
72066
72212
|
}
|
|
72067
72213
|
|
|
72214
|
+
// shared/atomic-auto.ts
|
|
72215
|
+
var ATOMIC_AUTO_MODEL = "atomic/auto";
|
|
72216
|
+
|
|
72068
72217
|
// server/atomic-engine-release.ts
|
|
72069
72218
|
var ASSETS = [
|
|
72070
72219
|
{
|
|
@@ -72772,8 +72921,10 @@ function lockAtomicEngineMemory(env, instanceId, cli) {
|
|
|
72772
72921
|
}
|
|
72773
72922
|
async function customAcpModels(env, config2, instanceId, fetchImpl = fetch) {
|
|
72774
72923
|
if (!isAtomicEngine(instanceId, config2?.cli)) return PASSTHROUGH;
|
|
72775
|
-
const own3 = { default:
|
|
72776
|
-
|
|
72924
|
+
const own3 = { default: ATOMIC_AUTO_MODEL, options: [{ id: ATOMIC_AUTO_MODEL, label: "Atomic Engine (Auto)", custom: true }] };
|
|
72925
|
+
const catalog2 = await mergeLocalInject(own3, env, fetchImpl);
|
|
72926
|
+
rememberLocalModels(catalog2.options);
|
|
72927
|
+
return catalog2;
|
|
72777
72928
|
}
|
|
72778
72929
|
function customAcpTurnModel(model2, env) {
|
|
72779
72930
|
if (model2 && decodeInjectId(model2)) ensureHermesInjectProvider(model2, env, atomicEngineHome2(env));
|
|
@@ -75053,7 +75204,10 @@ var DEFAULT_HARNESS_WEIGHTS = {
|
|
|
75053
75204
|
kimiAgent: 1,
|
|
75054
75205
|
vibeAgent: 1,
|
|
75055
75206
|
qwenAgent: 1,
|
|
75207
|
+
// Atomic Engine is Hermes under the hood, run on the person's Atomic
|
|
75208
|
+
// accounts: the same weight (Erick, 2026-11-15).
|
|
75056
75209
|
hermesAgent: 0.9,
|
|
75210
|
+
atomicEngine: 0.9,
|
|
75057
75211
|
cursorAgent: 0.8,
|
|
75058
75212
|
opencodeGo: 0.8,
|
|
75059
75213
|
droidAgent: 0.8,
|
|
@@ -75161,8 +75315,8 @@ var paidCandidate = (candidate) => {
|
|
|
75161
75315
|
return candidate.snapshot.billing === "metered" || PER_TOKEN_KINDS.has(candidate.driverKind) || candidate.snapshot.account?.method === "api-key";
|
|
75162
75316
|
};
|
|
75163
75317
|
var freeCandidate = (candidate) => candidate.billing === "free";
|
|
75164
|
-
var FLAT_PLAN_PROVIDERS = /* @__PURE__ */ new Set(["nous", "kimi-coding", "opencode-go", "openai-codex", "copilot", "qwen-oauth", "zai-coding-plan"]);
|
|
75165
|
-
var LOCAL_PROVIDERS = /* @__PURE__ */ new Set(["custom", "lmstudio", "ollama", "vllm", "llamacpp"]);
|
|
75318
|
+
var FLAT_PLAN_PROVIDERS = /* @__PURE__ */ new Set(["nous", "nous-api", "kimi-coding", "opencode-go", "openai-codex", "copilot", "qwen-oauth", "zai-coding-plan"]);
|
|
75319
|
+
var LOCAL_PROVIDERS = /* @__PURE__ */ new Set(["custom", "lmstudio", "ollama", "vllm", "llamacpp", "omlx", "exo", "unsloth"]);
|
|
75166
75320
|
var multiProviderEngine = (candidate) => candidate.driverKind === "hermesAgent" || candidate.instanceId === ATOMIC_ENGINE_INSTANCE;
|
|
75167
75321
|
function modelProvider(candidate, model2) {
|
|
75168
75322
|
if (!multiProviderEngine(candidate) || decodeInjectId(model2)) return void 0;
|
|
@@ -75271,7 +75425,7 @@ function harnessOption(name2, candidates) {
|
|
|
75271
75425
|
var TIER_PREFERRED_DRIVERS = {
|
|
75272
75426
|
orchestrator: ["claudeAgent"]
|
|
75273
75427
|
};
|
|
75274
|
-
var PREFERRED_RUNGS =
|
|
75428
|
+
var PREFERRED_RUNGS = 3;
|
|
75275
75429
|
function classRungs(models, modelClass) {
|
|
75276
75430
|
const out = [];
|
|
75277
75431
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -75294,7 +75448,7 @@ function generateLadders(models, classes) {
|
|
|
75294
75448
|
const seen = /* @__PURE__ */ new Set();
|
|
75295
75449
|
const rungs = classRungs(models, classes[tier]);
|
|
75296
75450
|
const drivers = TIER_PREFERRED_DRIVERS[tier] ?? [];
|
|
75297
|
-
const preferred = [...tier === "orchestrator" && classes[tier] === CHIBI_DEFAULT_RUNG.modelClass ? [{ ...CHIBI_DEFAULT_RUNG }] : [], ...rungs.filter((entry) => drivers.includes(entry.engine)), ...drivers.map((engine) => ({ engine }))];
|
|
75451
|
+
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 }))];
|
|
75298
75452
|
const pinned = Math.min(PREFERRED_RUNGS, preferred.length);
|
|
75299
75453
|
const ordered = [...preferred, ...rungs].filter((entry) => {
|
|
75300
75454
|
const key5 = entryKey(entry);
|
|
@@ -75454,7 +75608,7 @@ function resolveLadder(ladder, stored, context) {
|
|
|
75454
75608
|
subscription.sort((a, b3) => atomicFirst(a.candidate) - atomicFirst(b3.candidate) || a.step - b3.step);
|
|
75455
75609
|
key5.sort((a, b3) => a.step - b3.step || storedFirst(a.candidate, b3.candidate) || a.index - b3.index);
|
|
75456
75610
|
free.sort((a, b3) => a.step - b3.step || storedFirst(a.candidate, b3.candidate) || a.index - b3.index);
|
|
75457
|
-
for (const { step, entry, candidate, band } of [...subscription, ...
|
|
75611
|
+
for (const { step, entry, candidate, band } of [...subscription, ...free, ...key5]) {
|
|
75458
75612
|
const reason = band === "free" && !context.includeFree ? "free-off" : band === "free" && context.clientData ? "client-data" : skipReason(entry, candidate, context, step < ladder.length) ?? (band === "key" && context.keyBandPaused ? "paused" : void 0);
|
|
75459
75613
|
if (reason) {
|
|
75460
75614
|
skipped2.push({ step, instanceId: candidate.instanceId, reason, band });
|
|
@@ -75508,13 +75662,13 @@ function resolveFailover(request4) {
|
|
|
75508
75662
|
const ladders = new Map(classes.map((modelClass) => [modelClass, ladderOf(modelClass)]));
|
|
75509
75663
|
const all2 = [];
|
|
75510
75664
|
let lastPassSkipped;
|
|
75511
|
-
for (const stage of ["subscription", "
|
|
75665
|
+
for (const stage of ["subscription", "free", "key"]) {
|
|
75512
75666
|
for (const modelClass of classes) {
|
|
75513
75667
|
const { ladder, vouched } = ladders.get(modelClass);
|
|
75514
75668
|
const effective = (candidate, model2, entry, step) => entry?.modelClass ?? request4.classOf(candidate, model2) ?? (step < vouched ? modelClass : "A\xF1ejo");
|
|
75515
75669
|
const accept = (candidate, model2, entry, named) => {
|
|
75516
75670
|
if (request4.tried.has(candidate.instanceId)) return "tried";
|
|
75517
|
-
if (
|
|
75671
|
+
if (freeCandidate(candidate) !== (stage === "free")) return "key-later";
|
|
75518
75672
|
if (stage === "subscription" && (keyBased(candidate) || perTokenModel(candidate, model2))) return "key-later";
|
|
75519
75673
|
if (!named && request4.isLocal?.(candidate, model2) && !(request4.localAllowed && modelClass === "A\xF1ejo")) return "local";
|
|
75520
75674
|
const step = named ? ladder.indexOf(entry) : ladder.length;
|
|
@@ -75522,7 +75676,7 @@ function resolveFailover(request4) {
|
|
|
75522
75676
|
};
|
|
75523
75677
|
const resolution = resolveLadder(ladder, request4.failed, { ...request4.context, accept });
|
|
75524
75678
|
all2.push(...resolution.skipped);
|
|
75525
|
-
if (stage === "
|
|
75679
|
+
if (stage === "key" && modelClass === request4.modelClass) lastPassSkipped = resolution.skipped;
|
|
75526
75680
|
if (resolution.choice) {
|
|
75527
75681
|
const { choice } = resolution;
|
|
75528
75682
|
const named = choice.step < ladder.length;
|
|
@@ -80893,6 +81047,8 @@ function createSummaryScheduler(deps) {
|
|
|
80893
81047
|
|
|
80894
81048
|
// server/default-model-selection.ts
|
|
80895
81049
|
var claudeFirst = (instances) => instances.find((instance) => instance.driverKind === "claudeAgent") ?? instances[0];
|
|
81050
|
+
var ATOMIC_AUTO = { instanceId: "atomic-engine", model: "atomic/auto" };
|
|
81051
|
+
var atomicAuto = (instances) => instances.find((instance) => instance.instanceId === ATOMIC_AUTO.instanceId && instance.snapshot.authenticated !== false && instance.models.options.some((model2) => model2.id === ATOMIC_AUTO.model));
|
|
80896
81052
|
function selectDefaultModelSelection(instances, preferred, context = {}) {
|
|
80897
81053
|
if (preferred) {
|
|
80898
81054
|
const instance = instances.find((candidate) => candidate.instanceId === preferred.instanceId);
|
|
@@ -80906,6 +81062,7 @@ function selectDefaultModelSelection(instances, preferred, context = {}) {
|
|
|
80906
81062
|
return selection;
|
|
80907
81063
|
}
|
|
80908
81064
|
const available = instances.filter((instance) => instance.snapshot.state === "available" && instance.capabilities?.chatOnly !== true && context.refusal?.(instance) === void 0);
|
|
81065
|
+
if (atomicAuto(available)) return { ...ATOMIC_AUTO };
|
|
80909
81066
|
const company = context.company;
|
|
80910
81067
|
let pick4;
|
|
80911
81068
|
if (company && instances.some((instance) => company(instance.instanceId))) {
|
|
@@ -82087,29 +82244,6 @@ import { createHash as createHash28 } from "node:crypto";
|
|
|
82087
82244
|
import { existsSync as existsSync39, mkdirSync as mkdirSync38, readFileSync as readFileSync58, statSync as statSync14 } from "node:fs";
|
|
82088
82245
|
import { basename as basename14, dirname as dirname17, isAbsolute as isAbsolute13, join as join74, resolve as resolve18 } from "node:path";
|
|
82089
82246
|
|
|
82090
|
-
// server/nexus-memory/backoff.ts
|
|
82091
|
-
var WAITS_MS = [6e4, 3e5, 9e5, 18e5];
|
|
82092
|
-
var SAME_OUTAGE_MS = 2 * WAITS_MS[WAITS_MS.length - 1];
|
|
82093
|
-
var UnavailableBackoff = class {
|
|
82094
|
-
until = 0;
|
|
82095
|
-
failures = 0;
|
|
82096
|
-
lastAt = 0;
|
|
82097
|
-
/** How much longer to wait; 0 when calls may go through. */
|
|
82098
|
-
remainingMs(now) {
|
|
82099
|
-
return Math.max(0, this.until - now);
|
|
82100
|
-
}
|
|
82101
|
-
failed(now) {
|
|
82102
|
-
if (now - this.lastAt > SAME_OUTAGE_MS) this.failures = 0;
|
|
82103
|
-
this.lastAt = now;
|
|
82104
|
-
this.failures += 1;
|
|
82105
|
-
this.until = now + WAITS_MS[Math.min(this.failures - 1, WAITS_MS.length - 1)];
|
|
82106
|
-
}
|
|
82107
|
-
succeeded() {
|
|
82108
|
-
this.failures = 0;
|
|
82109
|
-
this.until = 0;
|
|
82110
|
-
}
|
|
82111
|
-
};
|
|
82112
|
-
|
|
82113
82247
|
// server/nexus-memory/client.ts
|
|
82114
82248
|
var NexusUnavailableError = class extends Error {
|
|
82115
82249
|
constructor(message4) {
|
|
@@ -82117,6 +82251,12 @@ var NexusUnavailableError = class extends Error {
|
|
|
82117
82251
|
this.name = "NexusUnavailableError";
|
|
82118
82252
|
}
|
|
82119
82253
|
};
|
|
82254
|
+
var NexusInitializeError = class extends NexusUnavailableError {
|
|
82255
|
+
constructor(message4) {
|
|
82256
|
+
super(message4);
|
|
82257
|
+
this.name = "NexusInitializeError";
|
|
82258
|
+
}
|
|
82259
|
+
};
|
|
82120
82260
|
var NexusRejectedError = class extends Error {
|
|
82121
82261
|
constructor(message4) {
|
|
82122
82262
|
super(message4);
|
|
@@ -82127,6 +82267,12 @@ var DEFAULT_TIMEOUT_MS3 = 2e4;
|
|
|
82127
82267
|
var PROTOCOL_VERSION2 = "2025-06-18";
|
|
82128
82268
|
var PRIVATE_SCOPE_ANSWER = /\b(?:private_scope_\w+|private_proof_invalid|personal_scope_requires_private_bot|personal_memory_cannot_be_shared)\b/;
|
|
82129
82269
|
var TRANSIENT = /unauthori[sz]ed|sign ?in|token|timed? ?out|timeout|ECONN|ENOTFOUND|EAI_AGAIN|fetch failed|network|socket|503|502|504|429|temporar|unavailable|not provisioned/i;
|
|
82270
|
+
var BRIDGE_URL = /https?:\/\/[^\s"'<>]+/gi;
|
|
82271
|
+
var BRIDGE_SECRET = /\b(bearer|token|access_token|refresh_token|id_token|authorization|client_secret|api[_-]?key|password|code)\b(\s*[:=]\s*)\S+/gi;
|
|
82272
|
+
var BRIDGE_JWT = /\beyJ[A-Za-z0-9_-]{8,}(?:\.[A-Za-z0-9_-]{8,}){2}\b/g;
|
|
82273
|
+
function redactBridgeLine(line3) {
|
|
82274
|
+
return line3.replace(BRIDGE_URL, "[url]").replace(BRIDGE_SECRET, "$1$2[redacted]").replace(BRIDGE_JWT, "[jwt]").trim().slice(0, 240);
|
|
82275
|
+
}
|
|
82130
82276
|
function isRecord7(value) {
|
|
82131
82277
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
82132
82278
|
}
|
|
@@ -82158,12 +82304,17 @@ var HttpNexusClient = class {
|
|
|
82158
82304
|
connect(signal) {
|
|
82159
82305
|
this.ready ??= (async () => {
|
|
82160
82306
|
const client = new RemoteMcpClient(this.spec);
|
|
82161
|
-
|
|
82307
|
+
try {
|
|
82308
|
+
await client.initialize("Atomic Nexus writeback", signal);
|
|
82309
|
+
} catch (error51) {
|
|
82310
|
+
await client.close().catch(() => void 0);
|
|
82311
|
+
throw new NexusInitializeError(error51 instanceof Error ? error51.message : "Nexus initialize failed");
|
|
82312
|
+
}
|
|
82162
82313
|
this.client = client;
|
|
82163
82314
|
return client;
|
|
82164
82315
|
})().catch((error51) => {
|
|
82165
82316
|
this.ready = null;
|
|
82166
|
-
throw error51;
|
|
82317
|
+
throw error51 instanceof NexusInitializeError ? error51 : new NexusInitializeError(error51 instanceof Error ? error51.message : "Nexus initialize failed");
|
|
82167
82318
|
});
|
|
82168
82319
|
return this.ready;
|
|
82169
82320
|
}
|
|
@@ -82199,8 +82350,10 @@ var StdioNexusClient = class {
|
|
|
82199
82350
|
idle;
|
|
82200
82351
|
spec;
|
|
82201
82352
|
idleMs;
|
|
82202
|
-
|
|
82353
|
+
log;
|
|
82354
|
+
constructor(spec, log, idleMs = 6e4) {
|
|
82203
82355
|
this.spec = spec;
|
|
82356
|
+
this.log = log;
|
|
82204
82357
|
this.idleMs = idleMs;
|
|
82205
82358
|
}
|
|
82206
82359
|
env() {
|
|
@@ -82270,9 +82423,22 @@ var StdioNexusClient = class {
|
|
|
82270
82423
|
} else entry.resolve(frame.result);
|
|
82271
82424
|
});
|
|
82272
82425
|
child.stdout.on("data", (chunk) => splitter.push(chunk));
|
|
82273
|
-
|
|
82274
|
-
|
|
82275
|
-
|
|
82426
|
+
let logged = 0;
|
|
82427
|
+
let handshook = false;
|
|
82428
|
+
const errSplit = createLineSplitter((line3) => {
|
|
82429
|
+
const redacted = redactBridgeLine(line3);
|
|
82430
|
+
if (!redacted || logged >= 20) return;
|
|
82431
|
+
logged += 1;
|
|
82432
|
+
this.log?.(`bridge: ${redacted}`);
|
|
82433
|
+
});
|
|
82434
|
+
child.stderr.on("data", (chunk) => errSplit.push(chunk));
|
|
82435
|
+
const gone = (message4) => {
|
|
82436
|
+
errSplit.flush();
|
|
82437
|
+
if (this.child !== child) return;
|
|
82438
|
+
this.fail(handshook ? new NexusUnavailableError(message4) : new NexusInitializeError(message4));
|
|
82439
|
+
};
|
|
82440
|
+
child.once("error", () => gone("Nexus bridge failed"));
|
|
82441
|
+
child.once("close", () => gone("Nexus bridge stopped"));
|
|
82276
82442
|
await this.send("initialize", {
|
|
82277
82443
|
protocolVersion: PROTOCOL_VERSION2,
|
|
82278
82444
|
capabilities: {},
|
|
@@ -82280,9 +82446,11 @@ var StdioNexusClient = class {
|
|
|
82280
82446
|
}, timeoutMs);
|
|
82281
82447
|
child.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" })}
|
|
82282
82448
|
`);
|
|
82449
|
+
handshook = true;
|
|
82283
82450
|
})().catch((error51) => {
|
|
82284
|
-
|
|
82285
|
-
|
|
82451
|
+
const message4 = error51 instanceof Error ? error51.message : String(error51);
|
|
82452
|
+
this.fail(error51 instanceof Error ? error51 : new Error(message4));
|
|
82453
|
+
throw error51 instanceof NexusInitializeError ? error51 : new NexusInitializeError(message4);
|
|
82286
82454
|
});
|
|
82287
82455
|
return this.ready;
|
|
82288
82456
|
}
|
|
@@ -82301,9 +82469,63 @@ var StdioNexusClient = class {
|
|
|
82301
82469
|
this.fail(new NexusUnavailableError("Nexus bridge closed"));
|
|
82302
82470
|
}
|
|
82303
82471
|
};
|
|
82304
|
-
function nexusClientFor(spec) {
|
|
82472
|
+
function nexusClientFor(spec, log) {
|
|
82305
82473
|
if (!spec) return null;
|
|
82306
|
-
return isRemoteMcpServer(spec) ? new HttpNexusClient(spec) : new StdioNexusClient(spec);
|
|
82474
|
+
return isRemoteMcpServer(spec) ? new HttpNexusClient(spec) : new StdioNexusClient(spec, log);
|
|
82475
|
+
}
|
|
82476
|
+
|
|
82477
|
+
// server/nexus-memory/backoff.ts
|
|
82478
|
+
var WAITS_MS = [6e4, 3e5, 9e5, 18e5];
|
|
82479
|
+
var SAME_OUTAGE_MS = 2 * WAITS_MS[WAITS_MS.length - 1];
|
|
82480
|
+
var UnavailableBackoff = class {
|
|
82481
|
+
until = 0;
|
|
82482
|
+
failures = 0;
|
|
82483
|
+
lastAt = 0;
|
|
82484
|
+
/** How much longer to wait; 0 when calls may go through. */
|
|
82485
|
+
remainingMs(now) {
|
|
82486
|
+
return Math.max(0, this.until - now);
|
|
82487
|
+
}
|
|
82488
|
+
failed(now) {
|
|
82489
|
+
if (now - this.lastAt > SAME_OUTAGE_MS) this.failures = 0;
|
|
82490
|
+
this.lastAt = now;
|
|
82491
|
+
this.failures += 1;
|
|
82492
|
+
this.until = now + WAITS_MS[Math.min(this.failures - 1, WAITS_MS.length - 1)];
|
|
82493
|
+
}
|
|
82494
|
+
succeeded() {
|
|
82495
|
+
this.failures = 0;
|
|
82496
|
+
this.until = 0;
|
|
82497
|
+
}
|
|
82498
|
+
};
|
|
82499
|
+
function guardNexusClient(client, backoff, now, log) {
|
|
82500
|
+
const finish = async (tool2, args, timeoutMs) => {
|
|
82501
|
+
try {
|
|
82502
|
+
const result = await client.call(tool2, args, timeoutMs);
|
|
82503
|
+
backoff.succeeded();
|
|
82504
|
+
return result;
|
|
82505
|
+
} catch (error51) {
|
|
82506
|
+
if (!(error51 instanceof NexusInitializeError) && error51 instanceof NexusUnavailableError) backoff.failed(now());
|
|
82507
|
+
throw error51;
|
|
82508
|
+
}
|
|
82509
|
+
};
|
|
82510
|
+
return {
|
|
82511
|
+
call: async (tool2, args, timeoutMs) => {
|
|
82512
|
+
const remaining = backoff.remainingMs(now());
|
|
82513
|
+
if (remaining > 0) throw new NexusUnavailableError(`waiting before trying Nexus again (next try in ${Math.ceil(remaining / 6e4)} min)`);
|
|
82514
|
+
try {
|
|
82515
|
+
return await finish(tool2, args, timeoutMs);
|
|
82516
|
+
} catch (error51) {
|
|
82517
|
+
if (!(error51 instanceof NexusInitializeError)) throw error51;
|
|
82518
|
+
log("Nexus initialize failed; retrying once");
|
|
82519
|
+
try {
|
|
82520
|
+
return await finish(tool2, args, timeoutMs);
|
|
82521
|
+
} catch (again) {
|
|
82522
|
+
if (again instanceof NexusInitializeError) backoff.failed(now());
|
|
82523
|
+
throw again;
|
|
82524
|
+
}
|
|
82525
|
+
}
|
|
82526
|
+
},
|
|
82527
|
+
close: () => client.close()
|
|
82528
|
+
};
|
|
82307
82529
|
}
|
|
82308
82530
|
|
|
82309
82531
|
// server/nexus-memory/outcome.ts
|
|
@@ -84142,32 +84364,16 @@ var NexusMemory = class {
|
|
|
84142
84364
|
const key5 = JSON.stringify(spec ?? null);
|
|
84143
84365
|
if (key5 !== this.clientKey) {
|
|
84144
84366
|
void this.client?.close();
|
|
84145
|
-
this.client = nexusClientFor(spec);
|
|
84367
|
+
this.client = nexusClientFor(spec, (message4) => this.log(message4));
|
|
84146
84368
|
this.clientKey = key5;
|
|
84147
84369
|
}
|
|
84148
84370
|
return this.client;
|
|
84149
84371
|
}
|
|
84150
|
-
/** The client behind one shared back-off (see backoff.ts)
|
|
84151
|
-
* fails, nothing calls it again until the wait is over. Writes keep
|
|
84152
|
-
* queuing on disk meanwhile. */
|
|
84372
|
+
/** The client behind one shared back-off (see backoff.ts). */
|
|
84153
84373
|
getClient() {
|
|
84154
84374
|
const client = this.rawClient();
|
|
84155
84375
|
if (!client) return null;
|
|
84156
|
-
return
|
|
84157
|
-
call: async (tool2, args, timeoutMs) => {
|
|
84158
|
-
const remaining = this.backoff.remainingMs(this.now());
|
|
84159
|
-
if (remaining > 0) throw new NexusUnavailableError(`waiting before trying Nexus again (next try in ${Math.ceil(remaining / 6e4)} min)`);
|
|
84160
|
-
try {
|
|
84161
|
-
const result = await client.call(tool2, args, timeoutMs);
|
|
84162
|
-
this.backoff.succeeded();
|
|
84163
|
-
return result;
|
|
84164
|
-
} catch (error51) {
|
|
84165
|
-
if (error51 instanceof NexusUnavailableError) this.backoff.failed(this.now());
|
|
84166
|
-
throw error51;
|
|
84167
|
-
}
|
|
84168
|
-
},
|
|
84169
|
-
close: () => client.close()
|
|
84170
|
-
};
|
|
84376
|
+
return guardNexusClient(client, this.backoff, this.now, this.log);
|
|
84171
84377
|
}
|
|
84172
84378
|
// ── the Private Bot's signed calls ─────────────────────────────────────
|
|
84173
84379
|
privateKey() {
|
|
@@ -90887,8 +91093,9 @@ var vaultInputSchema = external_exports.discriminatedUnion("kind", [
|
|
|
90887
91093
|
...base2,
|
|
90888
91094
|
kind: external_exports.literal("apiKey"),
|
|
90889
91095
|
origins: external_exports.array(origin).max(50),
|
|
90890
|
-
|
|
90891
|
-
|
|
91096
|
+
authMode: external_exports.enum(["auto", "custom"]).optional(),
|
|
91097
|
+
header: external_exports.string().regex(/^[A-Za-z0-9-]{1,64}$/).default("Authorization"),
|
|
91098
|
+
prefix: external_exports.string().regex(/^[\x20-\x7E]{0,32}$/).default("Bearer "),
|
|
90892
91099
|
secret: external_exports.string().regex(/^[\x21-\x7E]{1,8192}$/)
|
|
90893
91100
|
}).strict()
|
|
90894
91101
|
]);
|
|
@@ -90905,7 +91112,7 @@ function vaultMetadata(item) {
|
|
|
90905
91112
|
...item.kind === "login" ? { username: item.username } : {},
|
|
90906
91113
|
...item.kind === "card" ? { lastFour: item.number.slice(-4), expiryMonth: item.expiryMonth, expiryYear: item.expiryYear, billing: { ...item.billing } } : {},
|
|
90907
91114
|
...item.kind === "contact" ? { address: { ...item.address }, email: item.email, phone: item.phone } : {},
|
|
90908
|
-
...item.kind === "apiKey" ? { header: item.header, prefix: item.prefix } : {},
|
|
91115
|
+
...item.kind === "apiKey" ? { header: item.header, prefix: item.prefix, ...item.authMode ? { authMode: item.authMode } : {} } : {},
|
|
90909
91116
|
createdAt: item.createdAt,
|
|
90910
91117
|
updatedAt: item.updatedAt
|
|
90911
91118
|
};
|
|
@@ -90916,6 +91123,66 @@ function vaultUseAllowed(item, actor, now) {
|
|
|
90916
91123
|
return Number.isSafeInteger(now) && now >= 0 && item.ownerId === actor.ownerId && vaultGranted(item, actor.botId) && (item.expiresAt === null || now < item.expiresAt) && destination !== null && (item.kind === "login" ? item.website === destination : item.origins.includes(destination));
|
|
90917
91124
|
}
|
|
90918
91125
|
|
|
91126
|
+
// shared/vault-api-providers.ts
|
|
91127
|
+
var bearer = (name2, ...origins) => ({ name: name2, origins, header: "Authorization", prefix: "Bearer " });
|
|
91128
|
+
var keyed = (name2, header3, ...origins) => ({ name: name2, origins, header: header3, prefix: "" });
|
|
91129
|
+
var API_PROVIDERS = [
|
|
91130
|
+
// Voice, video and media
|
|
91131
|
+
{ ...keyed(/\b(?:eleven\s*labs|11\s*labs)\b/i, "xi-api-key", "https://api.elevenlabs.io"), automatic: true },
|
|
91132
|
+
{ ...keyed(/\bheygen\b/i, "X-Api-Key", "https://api.heygen.com"), automatic: true },
|
|
91133
|
+
bearer(/\breplicate\b/i, "https://api.replicate.com"),
|
|
91134
|
+
// Model providers and routers
|
|
91135
|
+
bearer(/\bopen\s*router\b/i, "https://openrouter.ai"),
|
|
91136
|
+
bearer(/\bollama\b/i, "https://ollama.com"),
|
|
91137
|
+
bearer(/\b(?:hugging\s*face|hf)\b/i, "https://huggingface.co", "https://router.huggingface.co", "https://api-inference.huggingface.co"),
|
|
91138
|
+
bearer(/\b(?:nous(?:\s*research)?|hermes)\b/i, "https://inference-api.nousresearch.com"),
|
|
91139
|
+
keyed(/\b(?:anthropic|claude)\b/i, "x-api-key", "https://api.anthropic.com"),
|
|
91140
|
+
keyed(/\b(?:gemini|google\s+ai|ai\s+studio)\b/i, "x-goog-api-key", "https://generativelanguage.googleapis.com"),
|
|
91141
|
+
bearer(/\b(?:openai|chatgpt)\b/i, "https://api.openai.com"),
|
|
91142
|
+
bearer(/\bgroq\b/i, "https://api.groq.com"),
|
|
91143
|
+
bearer(/\bmistral\b/i, "https://api.mistral.ai"),
|
|
91144
|
+
bearer(/\bdeepseek\b/i, "https://api.deepseek.com"),
|
|
91145
|
+
bearer(/\b(?:xai|x\.ai|grok)\b/i, "https://api.x.ai"),
|
|
91146
|
+
bearer(/\bperplexity\b/i, "https://api.perplexity.ai"),
|
|
91147
|
+
bearer(/\b(?:kimi|moonshot)\b/i, "https://api.moonshot.ai"),
|
|
91148
|
+
bearer(/\bminimax\b/i, "https://api.minimax.io"),
|
|
91149
|
+
bearer(/\b(?:z\.ai|zai|zhipu|glm)\b/i, "https://api.z.ai"),
|
|
91150
|
+
bearer(/\btogether(?:\s*ai)?\b/i, "https://api.together.xyz"),
|
|
91151
|
+
bearer(/\bfireworks\b/i, "https://api.fireworks.ai"),
|
|
91152
|
+
bearer(/\bcohere\b/i, "https://api.cohere.com"),
|
|
91153
|
+
// Hosting and developer platforms
|
|
91154
|
+
bearer(/\bvercel\b/i, "https://api.vercel.com"),
|
|
91155
|
+
bearer(/\bsupabase\b/i, "https://api.supabase.com"),
|
|
91156
|
+
bearer(/\brailway\b/i, "https://backboard.railway.com"),
|
|
91157
|
+
bearer(/\bgithub\b/i, "https://api.github.com"),
|
|
91158
|
+
bearer(/\bcloudflare\b/i, "https://api.cloudflare.com"),
|
|
91159
|
+
// Business services
|
|
91160
|
+
bearer(/\bstripe\b/i, "https://api.stripe.com"),
|
|
91161
|
+
bearer(/\bresend\b/i, "https://api.resend.com"),
|
|
91162
|
+
bearer(/\bsendgrid\b/i, "https://api.sendgrid.com"),
|
|
91163
|
+
bearer(/\bnotion\b/i, "https://api.notion.com"),
|
|
91164
|
+
bearer(/\bslack\b/i, "https://slack.com"),
|
|
91165
|
+
// Search and web
|
|
91166
|
+
bearer(/\btavily\b/i, "https://api.tavily.com"),
|
|
91167
|
+
bearer(/\bfirecrawl\b/i, "https://api.firecrawl.dev"),
|
|
91168
|
+
keyed(/\bbrave\b/i, "X-Subscription-Token", "https://api.search.brave.com")
|
|
91169
|
+
];
|
|
91170
|
+
function apiProviderFor(name2) {
|
|
91171
|
+
return API_PROVIDERS.find((provider) => provider.name.test(name2));
|
|
91172
|
+
}
|
|
91173
|
+
function vaultAuthMode(saved) {
|
|
91174
|
+
return saved.authMode ?? ((saved.header ?? "Authorization").toLowerCase() === "authorization" && (saved.prefix ?? "Bearer ") === "Bearer " ? "auto" : "custom");
|
|
91175
|
+
}
|
|
91176
|
+
function apiAuthFor(destination, saved) {
|
|
91177
|
+
const origin2 = new URL(destination).origin;
|
|
91178
|
+
const provider = API_PROVIDERS.find((candidate) => candidate.automatic && candidate.origins.includes(origin2));
|
|
91179
|
+
if (provider?.prefix === "" && saved.header.toLowerCase() === provider.header.toLowerCase() && saved.prefix === "Bearer ") {
|
|
91180
|
+
return { header: saved.header, prefix: "" };
|
|
91181
|
+
}
|
|
91182
|
+
if (vaultAuthMode(saved) === "custom") return saved;
|
|
91183
|
+
return provider ?? saved;
|
|
91184
|
+
}
|
|
91185
|
+
|
|
90919
91186
|
// server/vault/store.ts
|
|
90920
91187
|
var MAX_BYTES2 = 16 * 1024 * 1024;
|
|
90921
91188
|
var MAX_ITEMS3 = 3e3;
|
|
@@ -91052,7 +91319,8 @@ var VaultStore = class {
|
|
|
91052
91319
|
owner(actor.ownerId);
|
|
91053
91320
|
const item = this.read().find((candidate) => candidate.id === id);
|
|
91054
91321
|
if (!item || item.kind !== "apiKey" || !vaultUseAllowed(item, actor, now)) return null;
|
|
91055
|
-
|
|
91322
|
+
const { header: header3, prefix } = apiAuthFor(actor.destination, item);
|
|
91323
|
+
return { header: header3, value: prefix + item.secret, secret: item.secret };
|
|
91056
91324
|
}
|
|
91057
91325
|
create(ownerId, input) {
|
|
91058
91326
|
owner(ownerId);
|
|
@@ -91118,7 +91386,9 @@ ${item.label}`;
|
|
|
91118
91386
|
const current4 = items[index2];
|
|
91119
91387
|
if (!current4) throw new VaultError("Vault item is unavailable.");
|
|
91120
91388
|
const { id: _id, ownerId: _owner, createdAt: _created, updatedAt: _updated, ...previous2 } = current4;
|
|
91121
|
-
const
|
|
91389
|
+
const patch = { ...input };
|
|
91390
|
+
if (current4.kind === "apiKey" && typeof patch.secret === "string" && !patch.secret.trim()) delete patch.secret;
|
|
91391
|
+
const parsed = vaultInputSchema.safeParse({ ...previous2, ...patch });
|
|
91122
91392
|
if (!parsed.success) throw new VaultError("Invalid Vault item.");
|
|
91123
91393
|
if (current4.kind !== parsed.data.kind) throw new VaultError("A Vault item's category cannot change.");
|
|
91124
91394
|
const item = { ...parsed.data, id, ownerId, createdAt: current4.createdAt, updatedAt: Date.now() };
|
|
@@ -91139,54 +91409,6 @@ ${item.label}`;
|
|
|
91139
91409
|
// server/vault/runtime.ts
|
|
91140
91410
|
import { join as join88 } from "node:path";
|
|
91141
91411
|
|
|
91142
|
-
// shared/vault-api-providers.ts
|
|
91143
|
-
var bearer = (name2, ...origins) => ({ name: name2, origins, header: "Authorization", prefix: "Bearer " });
|
|
91144
|
-
var keyed = (name2, header3, ...origins) => ({ name: name2, origins, header: header3, prefix: "" });
|
|
91145
|
-
var API_PROVIDERS = [
|
|
91146
|
-
// Voice, video and media
|
|
91147
|
-
keyed(/\b(?:eleven\s*labs|11\s*labs)\b/i, "xi-api-key", "https://api.elevenlabs.io"),
|
|
91148
|
-
keyed(/\bheygen\b/i, "X-Api-Key", "https://api.heygen.com"),
|
|
91149
|
-
bearer(/\breplicate\b/i, "https://api.replicate.com"),
|
|
91150
|
-
// Model providers and routers
|
|
91151
|
-
bearer(/\bopen\s*router\b/i, "https://openrouter.ai"),
|
|
91152
|
-
bearer(/\bollama\b/i, "https://ollama.com"),
|
|
91153
|
-
bearer(/\b(?:hugging\s*face|hf)\b/i, "https://huggingface.co", "https://router.huggingface.co", "https://api-inference.huggingface.co"),
|
|
91154
|
-
bearer(/\b(?:nous(?:\s*research)?|hermes)\b/i, "https://inference-api.nousresearch.com"),
|
|
91155
|
-
keyed(/\b(?:anthropic|claude)\b/i, "x-api-key", "https://api.anthropic.com"),
|
|
91156
|
-
keyed(/\b(?:gemini|google\s+ai|ai\s+studio)\b/i, "x-goog-api-key", "https://generativelanguage.googleapis.com"),
|
|
91157
|
-
bearer(/\b(?:openai|chatgpt)\b/i, "https://api.openai.com"),
|
|
91158
|
-
bearer(/\bgroq\b/i, "https://api.groq.com"),
|
|
91159
|
-
bearer(/\bmistral\b/i, "https://api.mistral.ai"),
|
|
91160
|
-
bearer(/\bdeepseek\b/i, "https://api.deepseek.com"),
|
|
91161
|
-
bearer(/\b(?:xai|x\.ai|grok)\b/i, "https://api.x.ai"),
|
|
91162
|
-
bearer(/\bperplexity\b/i, "https://api.perplexity.ai"),
|
|
91163
|
-
bearer(/\b(?:kimi|moonshot)\b/i, "https://api.moonshot.ai"),
|
|
91164
|
-
bearer(/\bminimax\b/i, "https://api.minimax.io"),
|
|
91165
|
-
bearer(/\b(?:z\.ai|zai|zhipu|glm)\b/i, "https://api.z.ai"),
|
|
91166
|
-
bearer(/\btogether(?:\s*ai)?\b/i, "https://api.together.xyz"),
|
|
91167
|
-
bearer(/\bfireworks\b/i, "https://api.fireworks.ai"),
|
|
91168
|
-
bearer(/\bcohere\b/i, "https://api.cohere.com"),
|
|
91169
|
-
// Hosting and developer platforms
|
|
91170
|
-
bearer(/\bvercel\b/i, "https://api.vercel.com"),
|
|
91171
|
-
bearer(/\bsupabase\b/i, "https://api.supabase.com"),
|
|
91172
|
-
bearer(/\brailway\b/i, "https://backboard.railway.com"),
|
|
91173
|
-
bearer(/\bgithub\b/i, "https://api.github.com"),
|
|
91174
|
-
bearer(/\bcloudflare\b/i, "https://api.cloudflare.com"),
|
|
91175
|
-
// Business services
|
|
91176
|
-
bearer(/\bstripe\b/i, "https://api.stripe.com"),
|
|
91177
|
-
bearer(/\bresend\b/i, "https://api.resend.com"),
|
|
91178
|
-
bearer(/\bsendgrid\b/i, "https://api.sendgrid.com"),
|
|
91179
|
-
bearer(/\bnotion\b/i, "https://api.notion.com"),
|
|
91180
|
-
bearer(/\bslack\b/i, "https://slack.com"),
|
|
91181
|
-
// Search and web
|
|
91182
|
-
bearer(/\btavily\b/i, "https://api.tavily.com"),
|
|
91183
|
-
bearer(/\bfirecrawl\b/i, "https://api.firecrawl.dev"),
|
|
91184
|
-
keyed(/\bbrave\b/i, "X-Subscription-Token", "https://api.search.brave.com")
|
|
91185
|
-
];
|
|
91186
|
-
function apiProviderFor(name2) {
|
|
91187
|
-
return API_PROVIDERS.find((provider) => provider.name.test(name2));
|
|
91188
|
-
}
|
|
91189
|
-
|
|
91190
91412
|
// shared/vault-csv.ts
|
|
91191
91413
|
var VaultCsvError = class extends Error {
|
|
91192
91414
|
};
|
|
@@ -98704,7 +98926,7 @@ function scanMcpTools(name2, tools) {
|
|
|
98704
98926
|
snippet: "description far longer than a tool needs"
|
|
98705
98927
|
})))]);
|
|
98706
98928
|
}
|
|
98707
|
-
var
|
|
98929
|
+
var CACHE_MS3 = 30 * 6e4;
|
|
98708
98930
|
var packageCache = /* @__PURE__ */ new Map();
|
|
98709
98931
|
async function scanMcpServerWithPackage(name2, spec, fetcher = fetch) {
|
|
98710
98932
|
const definition2 = scanMcpServer(name2, spec);
|
|
@@ -98713,7 +98935,7 @@ async function scanMcpServerWithPackage(name2, spec, fetcher = fetch) {
|
|
|
98713
98935
|
const key5 = `${pkg.name}@${pkg.version ?? "latest"}`;
|
|
98714
98936
|
const cached3 = packageCache.get(key5);
|
|
98715
98937
|
let packageResult;
|
|
98716
|
-
if (cached3 && Date.now() - cached3.at <
|
|
98938
|
+
if (cached3 && Date.now() - cached3.at < CACHE_MS3) {
|
|
98717
98939
|
packageResult = cached3.result;
|
|
98718
98940
|
} else {
|
|
98719
98941
|
try {
|
|
@@ -98892,9 +99114,9 @@ import { readFileSync as readFileSync77 } from "node:fs";
|
|
|
98892
99114
|
import { join as join101 } from "node:path";
|
|
98893
99115
|
var ADDON_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
98894
99116
|
var RELEASES_API = process.env.OMB_ADDON_RELEASES_API || "https://api.github.com";
|
|
98895
|
-
async function refreshAddonReleases(
|
|
98896
|
-
if (now -
|
|
98897
|
-
const releases = { ...
|
|
99117
|
+
async function refreshAddonReleases(cache3, { now = Date.now(), fetchImpl = fetch, api = RELEASES_API } = {}) {
|
|
99118
|
+
if (now - cache3.checkedAt < ADDON_CHECK_INTERVAL_MS) return cache3;
|
|
99119
|
+
const releases = { ...cache3.releases };
|
|
98898
99120
|
for (const addon of ADDONS) {
|
|
98899
99121
|
if (!addon.upstream) continue;
|
|
98900
99122
|
try {
|
|
@@ -98912,9 +99134,9 @@ async function refreshAddonReleases(cache2, { now = Date.now(), fetchImpl = fetc
|
|
|
98912
99134
|
}
|
|
98913
99135
|
return { checkedAt: now, releases };
|
|
98914
99136
|
}
|
|
98915
|
-
function addonStatusesFrom(
|
|
99137
|
+
function addonStatusesFrom(cache3, enabled2, local = () => ({})) {
|
|
98916
99138
|
return Object.fromEntries(ADDONS.map((addon) => {
|
|
98917
|
-
const release2 =
|
|
99139
|
+
const release2 = cache3.releases[addon.id];
|
|
98918
99140
|
const update = release2 && isNewerVersion(release2.version, addon.version) ? { update: release2 } : {};
|
|
98919
99141
|
return [addon.id, { enabled: enabled2(addon.id), ...update, ...local(addon.id) }];
|
|
98920
99142
|
}));
|
|
@@ -105483,7 +105705,10 @@ var ASSISTANT_ALLOW = [
|
|
|
105483
105705
|
{ methods: ["GET"], path: /^\/api\/threads\/[\w-]+\/images(?:\/[\w.-]+)?$/ },
|
|
105484
105706
|
{ methods: ["POST"], path: /^\/api\/groups\/[\w-]+\/messages$/ },
|
|
105485
105707
|
{ methods: ["POST"], path: /^\/api\/bots$/, create: true },
|
|
105486
|
-
{ methods: ["POST"], path: /^\/api\/groups$/, create: true }
|
|
105708
|
+
{ methods: ["POST"], path: /^\/api\/groups$/, create: true },
|
|
105709
|
+
// Atomic as a model source, `atomic/auto` (server/model-gateway/route.ts).
|
|
105710
|
+
{ methods: ["GET"], path: /^\/api\/v1\/models$/ },
|
|
105711
|
+
{ methods: ["POST"], path: /^\/api\/v1\/(?:responses|chat\/completions|messages)$/ }
|
|
105487
105712
|
];
|
|
105488
105713
|
function assistantAllowed(method, path2, assistant) {
|
|
105489
105714
|
const upper = method.toUpperCase();
|
|
@@ -106132,7 +106357,9 @@ function editorTargets(home = homedir44(), platform = process.platform, env = pr
|
|
|
106132
106357
|
{ id: "antigravity-ide", label: "Antigravity IDE", configPath: join119(home, ".gemini", "antigravity-ide", "mcp_config.json"), format: "mcp-servers", installedAt: [...apps("Antigravity IDE"), join119(home, ".gemini", "antigravity-ide")] },
|
|
106133
106358
|
// Xcode 26.3+ shares one MCP server list with all of its coding agents (Claude, Codex, Gemini). macOS only.
|
|
106134
106359
|
...platform === "darwin" ? [{ id: "xcode", label: "Xcode", configPath: join119(home, "Library", "Developer", "Xcode", "CodingAssistant", "mcp-servers.json"), format: "mcp-servers", installedAt: [...apps("Xcode"), join119(home, "Library", "Developer", "Xcode", "CodingAssistant")] }] : [],
|
|
106135
|
-
{ id: "opencode", label: "OpenCode", configPath: join119(xdgConfig, "opencode", "opencode.json"), format: "opencode", installedAt: [join119(home, ".opencode"), join119(xdgConfig, "opencode")] }
|
|
106360
|
+
{ id: "opencode", label: "OpenCode", configPath: join119(xdgConfig, "opencode", "opencode.json"), format: "opencode", installedAt: [join119(home, ".opencode"), join119(xdgConfig, "opencode")] },
|
|
106361
|
+
// Codex (CLI and app) reads [mcp_servers.*] from its TOML config; with it, Codex can hand work to Atomic Engine (atomic_engine).
|
|
106362
|
+
{ id: "codex", label: "Codex", configPath: join119(env.CODEX_HOME || join119(home, ".codex"), "config.toml"), format: "codex-toml", installedAt: [...apps("Codex"), env.CODEX_HOME || join119(home, ".codex")] }
|
|
106136
106363
|
];
|
|
106137
106364
|
}
|
|
106138
106365
|
function editorTarget(id, targets = editorTargets()) {
|
|
@@ -106154,6 +106381,27 @@ function readConfig(path2) {
|
|
|
106154
106381
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${path2} is not a JSON object`);
|
|
106155
106382
|
return parsed;
|
|
106156
106383
|
}
|
|
106384
|
+
var CODEX_TABLE = new RegExp(`^\\s*\\[mcp_servers\\.${CLAUDE_CODE_SERVER_NAME}(\\.[^\\]]+)?\\]\\s*$`);
|
|
106385
|
+
function withoutCodexEntry(toml) {
|
|
106386
|
+
const out = [];
|
|
106387
|
+
let skipping = false;
|
|
106388
|
+
for (const line3 of toml.split("\n")) {
|
|
106389
|
+
if (/^\s*\[/.test(line3)) skipping = CODEX_TABLE.test(line3);
|
|
106390
|
+
if (!skipping) out.push(line3);
|
|
106391
|
+
}
|
|
106392
|
+
return out.join("\n").replace(/\s+$/, "");
|
|
106393
|
+
}
|
|
106394
|
+
function withCodexEntry(toml, entry) {
|
|
106395
|
+
const table = [`[mcp_servers.${CLAUDE_CODE_SERVER_NAME}]`, `command = ${JSON.stringify(entry.command)}`, `args = ${JSON.stringify(entry.args)}`];
|
|
106396
|
+
const env = Object.entries(entry.env ?? {});
|
|
106397
|
+
if (env.length) table.push("", `[mcp_servers.${CLAUDE_CODE_SERVER_NAME}.env]`, ...env.map(([key5, value]) => `${JSON.stringify(key5)} = ${JSON.stringify(value)}`));
|
|
106398
|
+
const rest = withoutCodexEntry(toml);
|
|
106399
|
+
return `${rest ? `${rest}
|
|
106400
|
+
|
|
106401
|
+
` : ""}${table.join("\n")}
|
|
106402
|
+
`;
|
|
106403
|
+
}
|
|
106404
|
+
var codexHasEntry = (toml) => toml.split("\n").some((line3) => CODEX_TABLE.test(line3) && !line3.includes(`${CLAUDE_CODE_SERVER_NAME}.`));
|
|
106157
106405
|
function writeConfig(path2, config2, now) {
|
|
106158
106406
|
let mode = 384;
|
|
106159
106407
|
if (existsSync66(path2)) {
|
|
@@ -106162,10 +106410,12 @@ function writeConfig(path2, config2, now) {
|
|
|
106162
106410
|
} else {
|
|
106163
106411
|
mkdirSync62(dirname34(path2), { recursive: true });
|
|
106164
106412
|
}
|
|
106165
|
-
writeFileAtomic(path2, `${JSON.stringify(config2, null, 2)}
|
|
106413
|
+
writeFileAtomic(path2, typeof config2 === "string" ? config2 : `${JSON.stringify(config2, null, 2)}
|
|
106166
106414
|
`, { mode });
|
|
106167
106415
|
}
|
|
106416
|
+
var readText6 = (path2) => existsSync66(path2) ? readFileSync93(path2, "utf8") : "";
|
|
106168
106417
|
function registerWithEditor(target, entry, now = /* @__PURE__ */ new Date()) {
|
|
106418
|
+
if (target.format === "codex-toml") return writeConfig(target.configPath, withCodexEntry(readText6(target.configPath), entry), now);
|
|
106169
106419
|
const config2 = readConfig(target.configPath);
|
|
106170
106420
|
const key5 = serversKey(target.format);
|
|
106171
106421
|
const servers = config2[key5] && typeof config2[key5] === "object" && !Array.isArray(config2[key5]) ? config2[key5] : {};
|
|
@@ -106173,6 +106423,12 @@ function registerWithEditor(target, entry, now = /* @__PURE__ */ new Date()) {
|
|
|
106173
106423
|
}
|
|
106174
106424
|
function unregisterFromEditor(target, now = /* @__PURE__ */ new Date()) {
|
|
106175
106425
|
if (!existsSync66(target.configPath)) return;
|
|
106426
|
+
if (target.format === "codex-toml") {
|
|
106427
|
+
const toml = readText6(target.configPath);
|
|
106428
|
+
if (codexHasEntry(toml)) writeConfig(target.configPath, `${withoutCodexEntry(toml)}
|
|
106429
|
+
`, now);
|
|
106430
|
+
return;
|
|
106431
|
+
}
|
|
106176
106432
|
const config2 = readConfig(target.configPath);
|
|
106177
106433
|
const key5 = serversKey(target.format);
|
|
106178
106434
|
const servers = config2[key5];
|
|
@@ -106182,6 +106438,7 @@ function unregisterFromEditor(target, now = /* @__PURE__ */ new Date()) {
|
|
|
106182
106438
|
}
|
|
106183
106439
|
function editorHasEntry(target) {
|
|
106184
106440
|
try {
|
|
106441
|
+
if (target.format === "codex-toml") return codexHasEntry(readText6(target.configPath));
|
|
106185
106442
|
const servers = readConfig(target.configPath)[serversKey(target.format)];
|
|
106186
106443
|
return Boolean(servers && typeof servers === "object" && CLAUDE_CODE_SERVER_NAME in servers);
|
|
106187
106444
|
} catch {
|
|
@@ -113506,10 +113763,10 @@ function createLocalModelRoutes(deps) {
|
|
|
113506
113763
|
if (deps.fromBot?.(req)) return json5(res, 403, { error: "Bots cannot manage local models." });
|
|
113507
113764
|
if (deps.disabled()) return json5(res, 403, { error: "Local models are managed by this server's administrator." });
|
|
113508
113765
|
if (path2 === "/api/local-models" && method === "GET") {
|
|
113509
|
-
const [
|
|
113766
|
+
const [ollama2, others] = await Promise.all([status(), deps.otherServers().catch(() => [])]);
|
|
113510
113767
|
let models = [];
|
|
113511
113768
|
let error51;
|
|
113512
|
-
if (
|
|
113769
|
+
if (ollama2.state === "running") {
|
|
113513
113770
|
try {
|
|
113514
113771
|
const response = await fetchImpl(`${base5}/api/tags`, { signal: AbortSignal.timeout(PROBE_TIMEOUT_MS) });
|
|
113515
113772
|
if (response.ok) models = installedModelsFromTags(await response.json(), deps.bots(), deps.engines());
|
|
@@ -113519,7 +113776,7 @@ function createLocalModelRoutes(deps) {
|
|
|
113519
113776
|
}
|
|
113520
113777
|
}
|
|
113521
113778
|
return json5(res, 200, {
|
|
113522
|
-
ollama: { ...
|
|
113779
|
+
ollama: { ...ollama2, models, ...error51 ? { error: error51 } : {}, downloadUrl: OLLAMA_DOWNLOAD_URL },
|
|
113523
113780
|
others: others.filter((server2) => server2.models.length > 0),
|
|
113524
113781
|
memoryBytes: deps.totalMemory()
|
|
113525
113782
|
});
|
|
@@ -113527,8 +113784,8 @@ function createLocalModelRoutes(deps) {
|
|
|
113527
113784
|
if (path2 === "/api/local-models" && method === "DELETE") {
|
|
113528
113785
|
const name2 = url2.searchParams.get("name") ?? "";
|
|
113529
113786
|
if (!validLocalModelTag(name2)) return json5(res, 400, { error: "Choose a model to remove." });
|
|
113530
|
-
const
|
|
113531
|
-
if (
|
|
113787
|
+
const ollama2 = await status();
|
|
113788
|
+
if (ollama2.state !== "running") return json5(res, 503, notRunning(ollama2.state));
|
|
113532
113789
|
const users = localModelUsage(name2, deps.bots(), deps.engines());
|
|
113533
113790
|
if (users.length) return json5(res, 409, { error: `${users.map((use) => use.name).join(", ")} still use this model. Choose another model for them first.`, usedBy: users });
|
|
113534
113791
|
const response = await fetchImpl(`${base5}/api/delete`, {
|
|
@@ -113548,8 +113805,8 @@ function createLocalModelRoutes(deps) {
|
|
|
113548
113805
|
const body = await readBody2(req, 4096);
|
|
113549
113806
|
const name2 = typeof body?.name === "string" ? body.name.trim() : "";
|
|
113550
113807
|
if (!validLocalModelTag(name2)) return json5(res, 400, { error: "Enter a model name like qwen3:8b." });
|
|
113551
|
-
const
|
|
113552
|
-
if (
|
|
113808
|
+
const ollama2 = await status();
|
|
113809
|
+
if (ollama2.state !== "running") return json5(res, 503, notRunning(ollama2.state));
|
|
113553
113810
|
const upstream = new AbortController();
|
|
113554
113811
|
res.on("close", () => {
|
|
113555
113812
|
if (!res.writableFinished) upstream.abort();
|
|
@@ -114097,11 +114354,11 @@ function createSetupRoutes(deps) {
|
|
|
114097
114354
|
if (deps.disabled()) return json5(res, 403, { error: "This server's administrator manages its setup." });
|
|
114098
114355
|
if (path2 === "/api/setup/machine" && method === "GET") {
|
|
114099
114356
|
const machine = deps.machine();
|
|
114100
|
-
const [
|
|
114357
|
+
const [ollama2, podman] = await Promise.all([deps.ollama().catch(() => "missing"), deps.podman().catch(() => ({ installed: false, path: null, running: false }))]);
|
|
114101
114358
|
return json5(res, 200, {
|
|
114102
114359
|
...machine,
|
|
114103
114360
|
npm: deps.npm(),
|
|
114104
|
-
ollama,
|
|
114361
|
+
ollama: ollama2,
|
|
114105
114362
|
podman: { installed: podman.installed, running: podman.running },
|
|
114106
114363
|
localModel: recommendLocalModel(machine)
|
|
114107
114364
|
});
|
|
@@ -114233,6 +114490,7 @@ var addAccountSchema = external_exports.object({
|
|
|
114233
114490
|
owner: external_exports.enum(["company", "personal"]).optional()
|
|
114234
114491
|
}).strict();
|
|
114235
114492
|
var renameAccountSchema = external_exports.object({ displayName: displayName2 }).strict();
|
|
114493
|
+
var planCreditSchema = external_exports.object({ planCreditUsd: external_exports.number().positive().max(1e6).nullable() }).strict();
|
|
114236
114494
|
var accountKeySchema = external_exports.object({ key: key4 }).strict();
|
|
114237
114495
|
var DEFAULT_HOME = {
|
|
114238
114496
|
CODEX_HOME: ".codex",
|
|
@@ -114352,9 +114610,17 @@ var ACCOUNT = /^\/api\/provider-accounts\/([\w.-]+)(?:\/(key|test))?$/;
|
|
|
114352
114610
|
function removable(instanceId, entry) {
|
|
114353
114611
|
return entry.account !== void 0 || entry.driver === "claudeAgent" && instanceId !== "claude";
|
|
114354
114612
|
}
|
|
114355
|
-
function
|
|
114613
|
+
function creditFields(instanceId, entry, spent) {
|
|
114614
|
+
const credit = planCredit(instanceId, entry, spent);
|
|
114615
|
+
return {
|
|
114616
|
+
...entry.planCreditUsd !== void 0 ? { planCreditUsd: entry.planCreditUsd } : {},
|
|
114617
|
+
...credit ? { planCredit: credit } : {}
|
|
114618
|
+
};
|
|
114619
|
+
}
|
|
114620
|
+
function account(provider, instanceId, entry, described, owner4, spent) {
|
|
114356
114621
|
const tag = owner4?.(instanceId);
|
|
114357
114622
|
const base5 = {
|
|
114623
|
+
...planTerms(provider).kind === "includedCredit" ? creditFields(instanceId, entry, spent) : {},
|
|
114358
114624
|
instanceId,
|
|
114359
114625
|
...tag ? { owner: tag.owner, ownerLocked: tag.locked } : {},
|
|
114360
114626
|
displayName: described?.displayName ?? entry.displayName ?? provider.label,
|
|
@@ -114383,6 +114649,8 @@ function account(provider, instanceId, entry, described, owner4) {
|
|
|
114383
114649
|
async function listing(deps) {
|
|
114384
114650
|
const instances = persistableInstanceConfigs(deps.config());
|
|
114385
114651
|
const described = new Map((await deps.describe()).map((instance) => [instance.instanceId, instance]));
|
|
114652
|
+
const spent = monthToDateByInstance(deps.dataDir);
|
|
114653
|
+
const mainOllama = Object.entries(instances).find(([, entry]) => entry.driver === "ollamaCloud" && entry.account === void 0);
|
|
114386
114654
|
return {
|
|
114387
114655
|
providers: ACCOUNT_PROVIDERS.map((provider) => ({
|
|
114388
114656
|
id: provider.id,
|
|
@@ -114393,7 +114661,8 @@ async function listing(deps) {
|
|
|
114393
114661
|
...provider.icon ? { icon: provider.icon } : {},
|
|
114394
114662
|
...provider.kind === "apiKey" ? { keyUrl: provider.keyUrl, ...provider.keyTest ? { keyTest: provider.keyTest } : {} } : {},
|
|
114395
114663
|
...provider.signupUrl ? { signupUrl: provider.signupUrl } : {},
|
|
114396
|
-
accounts: Object.entries(instances).filter(([, entry]) => accountProviderFor(entry)?.id === provider.id).map(([instanceId, entry]) => account(provider, instanceId, entry, described.get(instanceId), deps.owner))
|
|
114664
|
+
accounts: Object.entries(instances).filter(([, entry]) => accountProviderFor(entry)?.id === provider.id).map(([instanceId, entry]) => account(provider, instanceId, entry, described.get(instanceId), deps.owner, spent)),
|
|
114665
|
+
...provider.id === "ollamaCloud" && mainOllama ? { main: { instanceId: mainOllama[0], ...creditFields(mainOllama[0], mainOllama[1], spent) } } : {}
|
|
114397
114666
|
}))
|
|
114398
114667
|
};
|
|
114399
114668
|
}
|
|
@@ -114486,7 +114755,26 @@ function createProviderAccountRoutes(deps) {
|
|
|
114486
114755
|
}
|
|
114487
114756
|
if (!entry || !provider && method !== "PATCH") return json5(res, 404, { error: "unknown account" });
|
|
114488
114757
|
if (method === "PATCH") {
|
|
114489
|
-
const
|
|
114758
|
+
const body = await readBody2(req, 8192);
|
|
114759
|
+
if (body && typeof body === "object" && Object.hasOwn(body, "planCreditUsd")) {
|
|
114760
|
+
const credit = planCreditSchema.safeParse(body);
|
|
114761
|
+
if (!credit.success) return json5(res, 400, { error: "Enter the plan's monthly credit in dollars, more than 0." });
|
|
114762
|
+
const paidThrough = entry.account !== void 0 ? provider : entry.driver === "ollamaCloud" ? accountProvider("ollamaCloud") : void 0;
|
|
114763
|
+
if (!paidThrough || planTerms(paidThrough).kind !== "includedCredit") {
|
|
114764
|
+
return json5(res, 400, { error: "This account's plan has no included monthly credit." });
|
|
114765
|
+
}
|
|
114766
|
+
if (!deps.lock()) return json5(res, 409, { error: "Provider settings are already being updated." });
|
|
114767
|
+
try {
|
|
114768
|
+
if (credit.data.planCreditUsd === null) delete entry.planCreditUsd;
|
|
114769
|
+
else entry.planCreditUsd = credit.data.planCreditUsd;
|
|
114770
|
+
await deps.persist(instanceId, instances);
|
|
114771
|
+
resetPlanCreditCache();
|
|
114772
|
+
return json5(res, 200, await listing(deps));
|
|
114773
|
+
} finally {
|
|
114774
|
+
deps.unlock();
|
|
114775
|
+
}
|
|
114776
|
+
}
|
|
114777
|
+
const parsed = renameAccountSchema.safeParse(body);
|
|
114490
114778
|
if (!parsed.success) return json5(res, 400, { error: "Enter an account name (up to 80 characters)." });
|
|
114491
114779
|
if (deps.busy(instanceId)) return json5(res, 409, { error: "Wait for bots using this account to finish before renaming it." });
|
|
114492
114780
|
if (!deps.lock()) return json5(res, 409, { error: "Provider settings are already being updated." });
|
|
@@ -119925,13 +120213,158 @@ function isChange(value) {
|
|
|
119925
120213
|
return Object.keys(change).every((key5) => ["botId", "tier", "pin", "modelSelection"].includes(key5)) && typeof change.botId === "string" && /^[\w-]{1,128}$/.test(change.botId) && isBotTier(change.tier) && typeof change.pin === "boolean" && (selection === void 0 || typeof selection === "object" && selection !== null && typeof selection.instanceId === "string" && typeof selection.model === "string");
|
|
119926
120214
|
}
|
|
119927
120215
|
|
|
120216
|
+
// server/model-gateway/route.ts
|
|
120217
|
+
import { Readable as Readable3 } from "node:stream";
|
|
120218
|
+
|
|
120219
|
+
// server/model-gateway/failover.ts
|
|
120220
|
+
var REST_MS = 10 * 6e4;
|
|
120221
|
+
function failsOver(status, body) {
|
|
120222
|
+
if (status === 401 || status === 402 || status === 403 || status === 404 || status === 408 || status === 429 || status >= 500) return true;
|
|
120223
|
+
return status >= 400 && classifyEngineFailure(body) !== null;
|
|
120224
|
+
}
|
|
120225
|
+
var GatewayRests = class {
|
|
120226
|
+
until = /* @__PURE__ */ new Map();
|
|
120227
|
+
now;
|
|
120228
|
+
constructor(now = Date.now) {
|
|
120229
|
+
this.now = now;
|
|
120230
|
+
}
|
|
120231
|
+
rest(model2, ms2 = REST_MS) {
|
|
120232
|
+
this.until.set(model2, this.now() + ms2);
|
|
120233
|
+
}
|
|
120234
|
+
resting = (model2) => (this.until.get(model2) ?? 0) > this.now();
|
|
120235
|
+
};
|
|
120236
|
+
async function firstAnswer(models, send2, rests) {
|
|
120237
|
+
const failovers = [];
|
|
120238
|
+
let last = { status: 404, error: "No model is available behind Atomic right now. Start Ollama, or sign in to Ollama for its cloud models." };
|
|
120239
|
+
for (const model2 of models) {
|
|
120240
|
+
let response;
|
|
120241
|
+
try {
|
|
120242
|
+
response = await send2(model2);
|
|
120243
|
+
} catch (error51) {
|
|
120244
|
+
failovers.push(model2);
|
|
120245
|
+
last = { status: 502, error: `Ollama did not answer (${error51.message}).` };
|
|
120246
|
+
continue;
|
|
120247
|
+
}
|
|
120248
|
+
if (response.ok) return { ok: true, model: model2, response, failovers };
|
|
120249
|
+
const body = await response.text().catch(() => "");
|
|
120250
|
+
if (!failsOver(response.status, body)) return { ok: true, model: model2, response: new Response(body, { status: response.status, headers: response.headers }), failovers };
|
|
120251
|
+
if (response.status === 429 || response.status === 402) rests?.rest(model2);
|
|
120252
|
+
failovers.push(model2);
|
|
120253
|
+
last = { status: response.status, error: `${model2} could not answer (${response.status}).` };
|
|
120254
|
+
}
|
|
120255
|
+
return { ok: false, ...last, failovers };
|
|
120256
|
+
}
|
|
120257
|
+
|
|
120258
|
+
// server/model-gateway/ladder.ts
|
|
120259
|
+
var ATOMIC_AUTO_GATEWAY_MODEL = "atomic/auto";
|
|
120260
|
+
var LOCKED_CLOUD_ORDER = ["glm-5.3:cloud", "deepseek-v4-pro:cloud", "qwen3.5:cloud"];
|
|
120261
|
+
var isCloud = (model2) => /(^|[:-])cloud$/.test(model2);
|
|
120262
|
+
function autoLadder(available, resting = () => false, locked = LOCKED_CLOUD_ORDER) {
|
|
120263
|
+
const unique = [...new Set(available.filter((model2) => model2 && model2 !== ATOMIC_AUTO_GATEWAY_MODEL))];
|
|
120264
|
+
const ordered = [
|
|
120265
|
+
...locked.filter((model2) => unique.includes(model2)),
|
|
120266
|
+
...unique.filter((model2) => isCloud(model2) && !locked.includes(model2)),
|
|
120267
|
+
...unique.filter((model2) => !isCloud(model2))
|
|
120268
|
+
];
|
|
120269
|
+
const awake = ordered.filter((model2) => !resting(model2));
|
|
120270
|
+
return awake.length ? awake : ordered;
|
|
120271
|
+
}
|
|
120272
|
+
function modelsFor(asked, available, resting) {
|
|
120273
|
+
if (asked === ATOMIC_AUTO_GATEWAY_MODEL) return autoLadder(available, resting);
|
|
120274
|
+
return available.includes(asked) ? [asked] : [];
|
|
120275
|
+
}
|
|
120276
|
+
|
|
120277
|
+
// server/model-gateway/route.ts
|
|
120278
|
+
var PREFIX3 = "/api/v1/";
|
|
120279
|
+
var PASS_THROUGH = /* @__PURE__ */ new Set(["responses", "chat/completions", "messages"]);
|
|
120280
|
+
var MAX_BODY = 32 * 1024 * 1024;
|
|
120281
|
+
var LOOPBACK = /* @__PURE__ */ new Set(["127.0.0.1", "::1", "::ffff:127.0.0.1", "localhost"]);
|
|
120282
|
+
function fromLoopback(remoteAddress, host) {
|
|
120283
|
+
if (!remoteAddress || !LOOPBACK.has(remoteAddress)) return false;
|
|
120284
|
+
if (!host) return true;
|
|
120285
|
+
const name2 = host.startsWith("[") ? host.slice(1, host.indexOf("]")) : host.replace(/:\d+$/, "");
|
|
120286
|
+
return LOOPBACK.has(name2.toLowerCase());
|
|
120287
|
+
}
|
|
120288
|
+
function ollama() {
|
|
120289
|
+
const host = localHost("ollama");
|
|
120290
|
+
return host ? { baseUrl: host.baseUrl.replace(/\/+$/, ""), apiKey: hostApiKey(host) } : null;
|
|
120291
|
+
}
|
|
120292
|
+
function createModelGatewayRoutes(deps = {}) {
|
|
120293
|
+
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
120294
|
+
const rests = deps.rests ?? new GatewayRests();
|
|
120295
|
+
const log = deps.log ?? ((line3) => console.info(line3));
|
|
120296
|
+
const upstream = () => (deps.upstream ?? ollama)();
|
|
120297
|
+
async function served() {
|
|
120298
|
+
const base5 = upstream();
|
|
120299
|
+
if (!base5) return [];
|
|
120300
|
+
try {
|
|
120301
|
+
const res = await fetchImpl(`${base5.baseUrl}/models`, { headers: base5.apiKey ? { authorization: `Bearer ${base5.apiKey}` } : {}, signal: AbortSignal.timeout(5e3) });
|
|
120302
|
+
const body = res.ok ? await res.json() : {};
|
|
120303
|
+
return (body.data ?? []).map((row) => row.id).filter((id) => typeof id === "string" && id.length > 0);
|
|
120304
|
+
} catch {
|
|
120305
|
+
return [];
|
|
120306
|
+
}
|
|
120307
|
+
}
|
|
120308
|
+
return async ({ req, res, path: path2, method, auth, json: json5, readBody: readBody2 }) => {
|
|
120309
|
+
if (!path2.startsWith(PREFIX3)) return PASS;
|
|
120310
|
+
const tail3 = path2.slice(PREFIX3.length);
|
|
120311
|
+
if (!(tail3 === "models" && method === "GET") && !(PASS_THROUGH.has(tail3) && method === "POST")) return PASS;
|
|
120312
|
+
if (!fromLoopback(req.socket.remoteAddress, req.headers.host)) return json5(res, 403, { error: "Atomic's model source answers only on this computer." });
|
|
120313
|
+
if (auth.kind !== "assistant") return json5(res, 401, { error: "Send a connected assistant's token from Atomic Settings \u2192 Connected assistants." });
|
|
120314
|
+
const available = await served();
|
|
120315
|
+
if (tail3 === "models") {
|
|
120316
|
+
const ids2 = [ATOMIC_AUTO_GATEWAY_MODEL, ...available];
|
|
120317
|
+
return json5(res, 200, { object: "list", data: ids2.map((id) => ({ id, object: "model", owned_by: id === ATOMIC_AUTO_GATEWAY_MODEL ? "atomic" : "ollama", ...id === ATOMIC_AUTO_GATEWAY_MODEL ? { display_name: "Atomic Engine (Auto)" } : {} })) });
|
|
120318
|
+
}
|
|
120319
|
+
let body;
|
|
120320
|
+
try {
|
|
120321
|
+
body = await readBody2(req, MAX_BODY);
|
|
120322
|
+
} catch (error51) {
|
|
120323
|
+
return json5(res, error51.status ?? 400, { error: error51.message });
|
|
120324
|
+
}
|
|
120325
|
+
const asked = typeof body.model === "string" ? body.model : "";
|
|
120326
|
+
const models = modelsFor(asked, available, rests.resting);
|
|
120327
|
+
if (!models.length) {
|
|
120328
|
+
return json5(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." });
|
|
120329
|
+
}
|
|
120330
|
+
const base5 = upstream();
|
|
120331
|
+
const headers = { "content-type": "application/json" };
|
|
120332
|
+
if (base5.apiKey) headers.authorization = `Bearer ${base5.apiKey}`;
|
|
120333
|
+
if (tail3 === "messages") {
|
|
120334
|
+
headers["x-api-key"] = base5.apiKey ?? "ollama";
|
|
120335
|
+
headers["anthropic-version"] = String(req.headers["anthropic-version"] ?? "2023-06-01");
|
|
120336
|
+
}
|
|
120337
|
+
const answer2 = await firstAnswer(models, (model2) => fetchImpl(`${base5.baseUrl}/${tail3}`, { method: "POST", headers, body: JSON.stringify({ ...body, model: model2 }) }), rests);
|
|
120338
|
+
log(`[model-gateway] ${tail3} asked=${asked} used=${answer2.ok ? answer2.model : "none"} failovers=${answer2.failovers.join(",") || "none"}`);
|
|
120339
|
+
if (!answer2.ok) return json5(res, answer2.status === 404 ? 503 : answer2.status, { error: answer2.error });
|
|
120340
|
+
const type = answer2.response.headers.get("content-type") ?? "application/json";
|
|
120341
|
+
res.writeHead(answer2.response.status, { "content-type": type, "cache-control": "no-cache", "x-atomic-model": answer2.model });
|
|
120342
|
+
if (!answer2.response.body) return void res.end();
|
|
120343
|
+
await new Promise((resolve32) => {
|
|
120344
|
+
const stream = Readable3.fromWeb(answer2.response.body);
|
|
120345
|
+
stream.on("error", () => {
|
|
120346
|
+
res.destroy();
|
|
120347
|
+
resolve32();
|
|
120348
|
+
});
|
|
120349
|
+
res.on("close", () => {
|
|
120350
|
+
stream.destroy();
|
|
120351
|
+
resolve32();
|
|
120352
|
+
});
|
|
120353
|
+
stream.pipe(res).on("finish", () => resolve32());
|
|
120354
|
+
});
|
|
120355
|
+
};
|
|
120356
|
+
}
|
|
120357
|
+
|
|
119928
120358
|
// server/chibi-defaults.ts
|
|
119929
120359
|
import { existsSync as existsSync78, readFileSync as readFileSync103 } from "node:fs";
|
|
119930
120360
|
import { join as join133 } from "node:path";
|
|
119931
120361
|
var CHIBI_DEFAULTS_FILE = "chibi-defaults.json";
|
|
119932
120362
|
var NEAREST_CLASSES = ["Plata", "Reposado", "Mezcal", "A\xF1ejo"];
|
|
119933
120363
|
function chibiDefaultSelection(engines, refused, models = []) {
|
|
119934
|
-
const
|
|
120364
|
+
const usable = engines.filter((engine) => engine.snapshot.state === "available" && engine.snapshot.authenticated !== false && refused(engine) === void 0);
|
|
120365
|
+
const atomic = usable.find((engine) => engine.instanceId === ATOMIC_AUTO_RUNG.engine && engine.models.options.some((option) => option.id === ATOMIC_AUTO_RUNG.model));
|
|
120366
|
+
if (atomic) return { instanceId: atomic.instanceId, model: ATOMIC_AUTO_RUNG.model };
|
|
120367
|
+
const ready2 = usable.filter((engine) => engine.instanceId !== ATOMIC_AUTO_RUNG.engine);
|
|
119935
120368
|
const on = (driverKind, model2) => {
|
|
119936
120369
|
for (const engine of ready2) {
|
|
119937
120370
|
if (engine.driverKind !== driverKind) continue;
|
|
@@ -119985,7 +120418,7 @@ async function applyChibiDefaults(deps) {
|
|
|
119985
120418
|
for (const task2 of chibi.tasks ?? []) deps.store.setThreadEngineClass(chibi.id, task2.threadId, "tier");
|
|
119986
120419
|
writeFileAtomic(join133(deps.dataDir, CHIBI_DEFAULTS_FILE), `${JSON.stringify({ version: CHIBI_DEFAULTS_VERSION, appliedAt: (/* @__PURE__ */ new Date()).toISOString() })}
|
|
119987
120420
|
`);
|
|
119988
|
-
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)"}`);
|
|
120421
|
+
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)"}`);
|
|
119989
120422
|
return true;
|
|
119990
120423
|
}
|
|
119991
120424
|
|
|
@@ -123657,21 +124090,21 @@ var LocalModelInventory = class {
|
|
|
123657
124090
|
}
|
|
123658
124091
|
async read() {
|
|
123659
124092
|
const found = [];
|
|
123660
|
-
const
|
|
123661
|
-
if (
|
|
123662
|
-
const [tags, ps2] = await Promise.all([hostJson(
|
|
124093
|
+
const ollama2 = probedLocalHost("ollama");
|
|
124094
|
+
if (ollama2) {
|
|
124095
|
+
const [tags, ps2] = await Promise.all([hostJson(ollama2, "/api/tags", this.fetchImpl), hostJson(ollama2, "/api/ps", this.fetchImpl)]);
|
|
123663
124096
|
const shows = /* @__PURE__ */ new Map();
|
|
123664
124097
|
await Promise.all(records(tags, "models").map(async (row) => {
|
|
123665
124098
|
const name2 = rowName(row);
|
|
123666
124099
|
if (!name2 || isOllamaCloudModel({ ...row, name: name2 }) || EMBEDDING.test(name2)) return;
|
|
123667
124100
|
const key5 = `${name2}@${typeof row.digest === "string" ? row.digest : ""}`;
|
|
123668
124101
|
if (!this.shows.has(key5)) {
|
|
123669
|
-
const show = await hostJson(
|
|
124102
|
+
const show = await hostJson(ollama2, "/api/show", this.fetchImpl, { model: name2 });
|
|
123670
124103
|
if (show !== void 0) this.shows.set(key5, show);
|
|
123671
124104
|
}
|
|
123672
124105
|
if (this.shows.has(key5)) shows.set(name2, this.shows.get(key5));
|
|
123673
124106
|
}));
|
|
123674
|
-
found.push(...ollamaChatModels(tags, ps2, shows,
|
|
124107
|
+
found.push(...ollamaChatModels(tags, ps2, shows, ollama2.id));
|
|
123675
124108
|
}
|
|
123676
124109
|
const lmStudio = probedLocalHost("lmstudio");
|
|
123677
124110
|
if (lmStudio) found.push(...lmStudioChatModels(await hostJson(lmStudio, "/api/v0/models", this.fetchImpl), lmStudio.id));
|
|
@@ -126543,9 +126976,9 @@ var workspaceAccess = null;
|
|
|
126543
126976
|
var DESKTOP_MANAGED = process.env.OMB_DESKTOP_PARENT === "1";
|
|
126544
126977
|
var SHARED_WORKSPACE_FULL_ACCESS = sharedWorkspaceFullAccessConfigured();
|
|
126545
126978
|
var sharedWorkspaceFullAccessEnabled = () => SHARED_WORKSPACE_FULL_ACCESS && Boolean(workspaceAccess) && entitled("admin");
|
|
126546
|
-
var
|
|
126979
|
+
var LOOPBACK2 = resolveLoopbackTrust({ desktopManaged: DESKTOP_MANAGED, hostedWorkspace: HOSTED_WORKSPACE });
|
|
126547
126980
|
var cliOwnerToken;
|
|
126548
|
-
if (process.env.OMB_CLI_OWNER_STDIN === "1" &&
|
|
126981
|
+
if (process.env.OMB_CLI_OWNER_STDIN === "1" && LOOPBACK2.trust === "service" && process.stdin) {
|
|
126549
126982
|
let received = "";
|
|
126550
126983
|
process.stdin.setEncoding("utf8");
|
|
126551
126984
|
process.stdin.on("error", () => {
|
|
@@ -127933,8 +128366,7 @@ var tierCandidates = (described) => {
|
|
|
127933
128366
|
if (hostedModels) return [];
|
|
127934
128367
|
const configs = providerConfigs();
|
|
127935
128368
|
return described.filter((instance) => policyModelRefusal(instance) === void 0).map((instance) => {
|
|
127936
|
-
const
|
|
127937
|
-
const billing = account2 === void 0 ? void 0 : accountProvider(account2)?.billing;
|
|
128369
|
+
const billing = accountBilling(instance.instanceId, configs[instance.instanceId], DATA_DIR);
|
|
127938
128370
|
return billing ? { ...instance, billing } : instance;
|
|
127939
128371
|
});
|
|
127940
128372
|
};
|
|
@@ -128139,8 +128571,7 @@ var subscriptionFacts = {
|
|
|
128139
128571
|
function subscriptionCandidate(instanceId) {
|
|
128140
128572
|
const described = engineSnapshots.current()?.find((candidate) => candidate.instanceId === instanceId);
|
|
128141
128573
|
if (described) return described;
|
|
128142
|
-
const
|
|
128143
|
-
const billing = account2 === void 0 ? void 0 : accountProvider(account2)?.billing;
|
|
128574
|
+
const billing = accountBilling(instanceId, providerConfigs()[instanceId], DATA_DIR);
|
|
128144
128575
|
return {
|
|
128145
128576
|
instanceId,
|
|
128146
128577
|
driverKind: registry3.get(instanceId)?.driverKind ?? "",
|
|
@@ -128759,6 +129190,9 @@ var needsPerson = (instanceId) => engineRests.active().some((entry) => entry.ins
|
|
|
128759
129190
|
bindAtomicEngineAccountSource(() => ({
|
|
128760
129191
|
instances: providerConfigs(),
|
|
128761
129192
|
engineInstanceId: "atomic-engine",
|
|
129193
|
+
classModels: classedModels(),
|
|
129194
|
+
classOrder: failoverClassOrder(engineTierClasses(cfg.engineTiers).orchestrator),
|
|
129195
|
+
// class Auto (server/atomic-engine-classes.ts)
|
|
128762
129196
|
owner: instanceOwner,
|
|
128763
129197
|
restingUntil: (instanceId) => engineRests.active().filter((entry) => entry.instanceId === instanceId && !entry.scope && entry.reason !== "stalled").reduce((latest, entry) => Math.max(latest ?? 0, entry.until), void 0)
|
|
128764
129198
|
}));
|
|
@@ -128869,6 +129303,7 @@ function botClassChoices(profile, threadId) {
|
|
|
128869
129303
|
tier,
|
|
128870
129304
|
tierClass: engineTierClasses(cfg.engineTiers)[tier],
|
|
128871
129305
|
bot: botEngineMode(profile),
|
|
129306
|
+
includeFree: engineTiersIncludeFree(cfg.engineTiers),
|
|
128872
129307
|
...task2 ? { thread: threadEngineMode(profile, task2) } : {}
|
|
128873
129308
|
};
|
|
128874
129309
|
const projected = store.projectBotForTask(profile.id, threadId);
|
|
@@ -129335,7 +129770,7 @@ async function jevAnswerCheck(c) {
|
|
|
129335
129770
|
settings: answerCheckSettings(cfg.jevAnswerChecks),
|
|
129336
129771
|
policy: {
|
|
129337
129772
|
keySet: Boolean(route),
|
|
129338
|
-
hostedWorkspace: Boolean(hostedModels) || HOSTED_WORKSPACE ||
|
|
129773
|
+
hostedWorkspace: Boolean(hostedModels) || HOSTED_WORKSPACE || LOOPBACK2.trust === "service",
|
|
129339
129774
|
hipaaWorkspace: workspaceHipaa().enabled,
|
|
129340
129775
|
hipaaBot: profile.hipaa === true
|
|
129341
129776
|
},
|
|
@@ -137892,7 +138327,7 @@ var workspaceBackupRoutes = createWorkspaceBackupRoutes({
|
|
|
137892
138327
|
url: new URL(req.url ?? "/", `http://localhost:${PORT}`),
|
|
137893
138328
|
loopbackMutationToken: desktopMutationToken,
|
|
137894
138329
|
companionMutationToken,
|
|
137895
|
-
loopbackTrust:
|
|
138330
|
+
loopbackTrust: LOOPBACK2.trust,
|
|
137896
138331
|
cliOwnerToken
|
|
137897
138332
|
}).auth;
|
|
137898
138333
|
return Boolean(current4?.scopes.includes("admin") && current4.kind === original.kind && (current4.kind !== "session" || original.kind === "session" && current4.session.id === original.session.id));
|
|
@@ -138042,7 +138477,7 @@ ROUTES.push(createJevRoutes({
|
|
|
138042
138477
|
cfg.jevAnswerChecks = value;
|
|
138043
138478
|
},
|
|
138044
138479
|
route: () => jevRoute(),
|
|
138045
|
-
hosted: () => Boolean(hostedModels) || HOSTED_WORKSPACE ||
|
|
138480
|
+
hosted: () => Boolean(hostedModels) || HOSTED_WORKSPACE || LOOPBACK2.trust === "service",
|
|
138046
138481
|
hipaa: () => workspaceHipaa().enabled,
|
|
138047
138482
|
fromBot: (req) => authorizedInternalCapability(req.headers.authorization) !== null
|
|
138048
138483
|
}));
|
|
@@ -138063,7 +138498,7 @@ ROUTES.push(createDictationRoutes({
|
|
|
138063
138498
|
return { onDevice, subscription: allowSubscriptions ? dictationSubscription() : null };
|
|
138064
138499
|
},
|
|
138065
138500
|
fromBot: (req) => authorizedInternalCapability(req.headers.authorization) !== null,
|
|
138066
|
-
hosted: () => Boolean(hostedModels) || HOSTED_WORKSPACE ||
|
|
138501
|
+
hosted: () => Boolean(hostedModels) || HOSTED_WORKSPACE || LOOPBACK2.trust === "service"
|
|
138067
138502
|
}));
|
|
138068
138503
|
var watchRemoteFlags = new RemoteFlags((url2, init) => fetch(url2, init));
|
|
138069
138504
|
var watchTranscriptCounts = new TranscriptCounts();
|
|
@@ -138858,7 +139293,7 @@ var deliverableAccess = (senderId, auth) => sharedDeliverableAccess(sharedDelive
|
|
|
138858
139293
|
canSeeGroup: auth ? (id) => visibleTo(viewerFor(auth)).group(id) : () => true
|
|
138859
139294
|
});
|
|
138860
139295
|
ROUTES.push(createSharedDeliverablesRoutes(sharedDeliverables, () => deliverableAccess(void 0).sharedBlockedRoots ?? []));
|
|
138861
|
-
ROUTES.push(createMessageFileRoutes({ store, attachments: ATTACHMENTS_DIR, workspaceDir, access: deliverableAccess }));
|
|
139296
|
+
ROUTES.push(createMessageFileRoutes({ store, attachments: ATTACHMENTS_DIR, workspaceDir, access: deliverableAccess }), createModelGatewayRoutes());
|
|
138862
139297
|
ROUTES.push(createPinOrderRoutes({ store, visible: (auth) => visibleTo(viewerFor(auth)), personalHidden: personalBotHidden, fromBot: (req) => authorizedInternalCapability(req.headers.authorization) !== null }));
|
|
138863
139298
|
ROUTES.push(createRepoRoutes({
|
|
138864
139299
|
registry: repoRegistry,
|
|
@@ -139017,7 +139452,7 @@ var handleRequest = async (req, res) => {
|
|
|
139017
139452
|
loopbackMutationToken: desktopMutationToken,
|
|
139018
139453
|
companionMutationToken,
|
|
139019
139454
|
features: { sharedComputers: sharedComputersEnabled(cfg) },
|
|
139020
|
-
loopbackTrust:
|
|
139455
|
+
loopbackTrust: LOOPBACK2.trust,
|
|
139021
139456
|
cliOwnerToken,
|
|
139022
139457
|
assistants
|
|
139023
139458
|
});
|
|
@@ -145919,8 +146354,8 @@ calendarCalls.start();
|
|
|
145919
146354
|
console.log(describeEdition(await loadEnterpriseLayer()));
|
|
145920
146355
|
var startupLicenseWarning = licenseWarning(editionStatus());
|
|
145921
146356
|
if (startupLicenseWarning) console.warn(startupLicenseWarning);
|
|
145922
|
-
console.log(
|
|
145923
|
-
if (
|
|
146357
|
+
console.log(LOOPBACK2.trust === "service" ? `local requests: service trust (${LOOPBACK2.reason}); without a session, loopback may use only health, the Slack worker's guarded routes and bot capability routes` : `local requests: owner trust (${LOOPBACK2.reason})`);
|
|
146358
|
+
if (LOOPBACK2.warning) console.warn(`local requests: ${LOOPBACK2.warning}`);
|
|
145924
146359
|
for (const group of store.groups) settleRoomFloor(group);
|
|
145925
146360
|
var pruneDecisionLog = () => {
|
|
145926
146361
|
void pruneDecisions(DATA_DIR, decisionRetentionDays(cfg.decisions?.retentionDays));
|