@chibitek/chibi 0.1.209 → 0.1.211
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-CHGq3udb.js → TerminalPanel-Dro3aeVy.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-BMaKhJ-b.js → abnfDiagram-O67JEVCF-kzAr7vQ8.js} +1 -1
- package/dist/assets/{arc-CYAiNWN8.js → arc-DKMhcYud.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-CxJFFlbO.js → architectureDiagram-NJMV4G6O-_XDnZ7Jz.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-C7AbPjRB.js → blockDiagram-BEXU5L5S-D5MoWro9.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-DfVnCJmT.js → c4Diagram-YGBWAQC7-CGvTMpGE.js} +1 -1
- package/dist/assets/channel-YcZdlysP.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-CzAUFkgv.js → chunk-2Q5K7J3B-pjTwr5y0.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-BgeBXphm.js → chunk-3FUC2YCW-BR6zkd-l.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-DPRdTAXc.js → chunk-5VM5RSS4-CfVFFBeH.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-BS-_dIVl.js → chunk-GTNCS2PH-TIoAkccw.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-D6I7xMmd.js → chunk-GWA4HPMP-BNFBgzbt.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BKSKe7C9.js → chunk-JWPE2WC7-B_3QFchU.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-R48UYTRN.js → chunk-NETBCI7D-Cj9q80P-.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-C8z4mL-2.js → chunk-WEXAMYUT-DFZPGo9K.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-Bml3ZRJ5.js → chunk-XXDRQBXY-CekDrT9T.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-w5wo22FO.js → classDiagram-v2-NBCMYWYE-C3R6Z4Qe.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-Cum9v--4.js → cose-bilkent-JH36ORCC-C1CKyj0L.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-BzN0-KsP.js → cynefin-OW5HDTMX-Deh9QGb0.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-CkOpm32D.js → cynefinDiagram-VND7K2PF-BIlWyG_M.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-BItQkKZD.js → dagre-6A5THRUB-Dx4bWOog.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BI0zDn7c.js → diagram-22UHCM2B-DPxb-FUO.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-jwcDxsu6.js → diagram-3UASUU5V-BLPCNc4m.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-2RnY9egJ.js → diagram-ATOU4E4O-DOCbp2Dw.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-eVdEZmEF.js → diagram-CDSNMT55-62uSG-tn.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-BCDGCJJ0.js → diagram-MLGK6HIB-De1ZAWVZ.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-DtN5uO5w.js → diagram-MPIPVDR6-CIGX9tku.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-B9GpXSEs.js → ebnfDiagram-ZINNZB2B-CegjStdk.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-Bk_eaK4T.js → elk-276RUBZZ-ClI52Pqm.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-BiGoW6C6.js → erDiagram-OPXOYQCR-BQuzjt2-.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-ZW5w0BaJ.js → flowDiagram-KWPJA3E3-D1xbKgbB.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-yyrKgsx1.js → ganttDiagram-FUAMR5RP-CH1jGSZz.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-CeiDikzD.js → gitGraphDiagram-X574FWY7-BvAUPEmQ.js} +1 -1
- package/dist/assets/{index-CZGnshrJ.js → index-BcXDfnlQ.js} +197 -197
- package/dist/assets/{index-DUFlRZuA.js → index-DbkR_erP.js} +1 -1
- package/dist/assets/index-H8vkXbLq.css +1 -0
- package/dist/assets/{infoDiagram-VRGFBTTK-q2B-KJFm.js → infoDiagram-VRGFBTTK-CyMmMbMv.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-D8gXFuc0.js → ishikawaDiagram-OU5B5YK6-Uw-hE1tO.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-BmHL2mbq.js → journeyDiagram-ZHPQQLJL-ClEDnNRB.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-B9Ll2WkA.js → kanban-definition-PNTS6WVX-erx0BEal.js} +1 -1
- package/dist/assets/{linear-CMVGYrKx.js → linear-CSSxpyL0.js} +1 -1
- package/dist/assets/{mermaid.core-qO11n1kV.js → mermaid.core-n13K6vlC.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-CxLGFX45.js → mindmap-definition-NLK3R4M7-BcTEIqpD.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-CxK1MJG4.js → pegDiagram-GJSIUBJH-CJdsm3en.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-H5jiF5Eu.js → pieDiagram-5QR66LMP-C7rk-ash.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-CKaqCruv.js → quadrantDiagram-O4NWA36T-BSXOYov0.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-BCzKiQOd.js → railroadDiagram-XR7U4H2S-Cmg_FtZY.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-Cqtr43DT.js → requirementDiagram-PLB6GJNP-B_9aE6Mg.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-B2tQewX8.js → sankeyDiagram-IPEJSGJF-DyxaQPy3.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-nggwQyrw.js → sequenceDiagram-PO4LG4MO-D5CJeESq.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-qSPXJBv2.js → sizeCapture-INFHLROL-9-Q4eosQ.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-DraPbL2T.js → stateDiagram-v2-GCMORJYK-jgsHnEQl.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-C6HVkIDA.js → swimlanes-2SLR337P-MIVacUbv.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-Dekwo1KL.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-DZmPRTsx.js → timeline-definition-EJHVYXUP-Ch8ins-D.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-CsVuROW_.js → usecaseDiagram-POWQR4AR-BDwBIuhZ.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-B9IRbuhp.js → vennDiagram-UO4OBE2U-BiiDxcHO.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-CGmVK53n.js → wardleyDiagram-VNRHLVJA-D79CK2__.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-BAw-x9Y1.js → xychartDiagram-PMCCYNJV-CI7S0o-6.js} +1 -1
- package/dist/index.html +4 -2
- package/dist-server/accounts-proxy.js +19 -12
- package/dist-server/browser-proxy.js +19 -14
- package/dist-server/container-mcp.js +165 -93
- package/dist-server/drivers/agents-proxy.js +109 -94
- package/dist-server/drivers/phone-proxy.js +21 -13
- package/dist-server/index.js +6487 -4926
- package/dist-server/local-computer-proxy.js +77 -11
- package/dist-server/local-computer.js +2 -1
- package/dist-server/mcp-gate.js +53 -4
- package/dist-server/mcp-server.js +1 -1
- package/dist-server/openmausbot.js +1068 -642
- package/dist-server/pair-cli.js +1068 -642
- package/dist-server/server/accounts-proxy.js +3 -17
- package/dist-server/server/atomic-engine-release.js +7 -0
- package/dist-server/server/auto-approve.js +12 -0
- package/dist-server/server/browser-proxy.js +3 -17
- package/dist-server/server/child-env.js +79 -0
- package/dist-server/server/config.js +11 -5
- package/dist-server/server/container-computer.js +1 -1
- package/dist-server/server/container-mcp.js +3 -2
- package/dist-server/server/control-client.js +7 -6
- package/dist-server/server/delegated-full-access.js +98 -0
- package/dist-server/server/desktop-loopback-gate.js +57 -0
- package/dist-server/server/drivers/acp/core.js +4 -4
- package/dist-server/server/drivers/acp/custom.js +3 -1
- package/dist-server/server/drivers/acp/hermes.js +2 -1
- package/dist-server/server/drivers/acp/session-key.js +8 -0
- package/dist-server/server/drivers/agents-client.js +2 -14
- package/dist-server/server/drivers/gcloud-token.js +28 -0
- package/dist-server/server/drivers/github-copilot.js +152 -0
- package/dist-server/server/drivers/hermes-context-floor.js +68 -0
- package/dist-server/server/drivers/openai-chat-protocol.js +8 -0
- package/dist-server/server/drivers/openai-chat.js +10 -8
- package/dist-server/server/drivers/openai-compat.js +44 -9
- package/dist-server/server/drivers/phone-proxy.js +5 -18
- package/dist-server/server/engine-tiers.js +9 -9
- package/dist-server/server/god-mode-goal.js +78 -0
- package/dist-server/server/god-mode-run-host.js +69 -0
- package/dist-server/server/harness/http.js +47 -1
- package/dist-server/server/index.js +86 -86
- package/dist-server/server/ladder-pick.js +18 -0
- package/dist-server/server/local-computer-proxy.js +3 -2
- package/dist-server/server/local-computer.js +1 -0
- package/dist-server/server/mcp-bridge.js +3 -2
- package/dist-server/server/mcp-gate.js +2 -1
- package/dist-server/server/mcp-registry.js +5 -1
- package/dist-server/server/model-fallback-repair.js +20 -0
- package/dist-server/server/model-gateway/failover.js +4 -1
- package/dist-server/server/model-gateway/route.js +64 -14
- package/dist-server/server/model-gateway/usage.js +66 -0
- package/dist-server/server/model-levels/aa-scale.js +42 -0
- package/dist-server/server/model-levels/aliases.js +16 -3
- package/dist-server/server/model-levels/index.js +8 -3
- package/dist-server/server/model-levels/rankings-build.js +76 -0
- package/dist-server/server/model-prices.js +6 -0
- package/dist-server/server/nexus-memory/index.js +5 -13
- package/dist-server/server/nexus-memory/policy.js +5 -17
- package/dist-server/server/oauth-account-vault.js +7 -2
- package/dist-server/server/personal-goal-runtime.js +29 -3
- package/dist-server/server/personal-goal-turn.js +2 -1
- package/dist-server/server/personal-goals.js +20 -2
- package/dist-server/server/provider-accounts.js +20 -1
- package/dist-server/server/provider-key-check.js +31 -1
- package/dist-server/server/registry-load.js +88 -0
- package/dist-server/server/request-auth.js +6 -28
- package/dist-server/server/routes/provider-accounts.js +124 -6
- package/dist-server/server/routine-daily-schedule.js +20 -0
- package/dist-server/server/routine-prompt-escape.js +18 -0
- package/dist-server/server/routine-tick-guard.js +16 -0
- package/dist-server/server/routine-tool-problems.js +36 -0
- package/dist-server/server/routines.js +36 -38
- package/dist-server/server/shutdown-triggers.js +18 -0
- package/dist-server/server/spend.js +23 -13
- package/dist-server/server/store.js +4 -13
- package/dist-server/server/terminal.js +2 -1
- package/dist-server/server/turn-token-file.js +79 -0
- package/dist-server/server/turn-token.js +23 -0
- package/dist-server/server/vps-container-mcp.js +3 -2
- package/dist-server/server/webhook-ingress.js +11 -1
- package/dist-server/server/webhook-prompt.js +82 -0
- package/dist-server/server/webhooks.js +8 -65
- package/dist-server/server/workspace-backup-policy.js +3 -3
- package/dist-server/server/workspace-backup.js +1 -1
- package/dist-server/server/workspace-time-zone.js +47 -0
- package/dist-server/shared/engine-choices.js +12 -1
- package/dist-server/shared/god-mode-run.js +173 -0
- package/dist-server/shared/personal-goal.js +42 -0
- package/dist-server/shared/provider-accounts.js +114 -2
- package/dist-server/shared/zoned-time.js +55 -0
- package/dist-server/vps-container-mcp.js +165 -93
- package/package.json +1 -1
- package/dist/assets/channel-DxL_mLhm.js +0 -1
- package/dist/assets/index-Bi3hprmz.css +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-gQUGsELo.js +0 -8
- package/dist-server/server/agents-token-file.js +0 -26
|
@@ -4,6 +4,7 @@ import { dirname } from "node:path";
|
|
|
4
4
|
import { StringDecoder } from "node:string_decoder";
|
|
5
5
|
import { writeFileAtomic } from "./atomic.js";
|
|
6
6
|
import { CONTROL_REFUSAL_PLAIN, createControlClient } from "./control-client.js";
|
|
7
|
+
import { childEnv } from "./child-env.js";
|
|
7
8
|
import { augmentedPath } from "./env-path.js";
|
|
8
9
|
import { createToolListNormalizer } from "./mcp-tool-schema.js";
|
|
9
10
|
// 45s of TOTAL silence before the bridge even probes. An MCP session is
|
|
@@ -20,7 +21,7 @@ export function runLivenessProbe(probe, timeoutMs = PROBE_TIMEOUT_MS) {
|
|
|
20
21
|
return new Promise((resolve) => {
|
|
21
22
|
const child = spawnCommand(probe.command, probe.args, {
|
|
22
23
|
shell: false,
|
|
23
|
-
env:
|
|
24
|
+
env: childEnv(process.env, { PATH: augmentedPath() }),
|
|
24
25
|
stdio: ["ignore", "ignore", "ignore"],
|
|
25
26
|
});
|
|
26
27
|
const timer = setTimeout(() => {
|
|
@@ -333,7 +334,7 @@ export function runMcpBridge(options) {
|
|
|
333
334
|
// npx, uvx and friends are .cmd shims on Windows: spawnCommand runs them.
|
|
334
335
|
const started = spawnCommand(options.command, options.args, {
|
|
335
336
|
shell: false,
|
|
336
|
-
env: options.env ??
|
|
337
|
+
env: options.env ?? childEnv(process.env, { PATH: augmentedPath() }),
|
|
337
338
|
stdio: ["pipe", "pipe", "pipe"],
|
|
338
339
|
});
|
|
339
340
|
child = started;
|
|
@@ -20,6 +20,7 @@ import { spawn } from "node:child_process";
|
|
|
20
20
|
import { mkdirSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
21
21
|
import { join } from "node:path";
|
|
22
22
|
import { createInterface } from "node:readline";
|
|
23
|
+
import { childEnv as upstreamEnv } from "./child-env.js";
|
|
23
24
|
import { resolveCliSpawn } from "./env-path.js";
|
|
24
25
|
import { planOptions } from "./spawn-command.js";
|
|
25
26
|
import { DEFAULT_RESULT_BUDGET, trimResultText, trimStructured } from "./mcp-trim.js";
|
|
@@ -142,7 +143,7 @@ function trimCallResult(result, tool) {
|
|
|
142
143
|
const spec = upstreamSpec();
|
|
143
144
|
if (SPILL_DIR)
|
|
144
145
|
sweepSpill(SPILL_DIR);
|
|
145
|
-
const childEnv =
|
|
146
|
+
const childEnv = upstreamEnv(process.env, spec.env);
|
|
146
147
|
for (const key of GATE_ENV_KEYS)
|
|
147
148
|
delete childEnv[key];
|
|
148
149
|
// The CLI used to spawn this server itself, on every platform, so the gate
|
|
@@ -14,7 +14,11 @@ export function mcpReadOnlyAutoAllow(raw, name) {
|
|
|
14
14
|
export function isRemoteMcpServer(server) {
|
|
15
15
|
return "url" in server;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
/** A guard against a runaway config, not a budget: a person may add as many
|
|
18
|
+
* servers as they use (Erick, 2026-11-22, "remove this limitation"). An
|
|
19
|
+
* engine that takes fewer per session is capped by its own driver
|
|
20
|
+
* (AcpSupport.mcpServerLimit: Hermes 16), never by refusing to add one. */
|
|
21
|
+
export const MAX_MCP_SERVERS = 500;
|
|
18
22
|
const MAX_ARGS = 64;
|
|
19
23
|
const MAX_ENV = 64;
|
|
20
24
|
const MAX_HEADERS = 32;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const names = (selection, refused) => selection?.instanceId === refused.instanceId && selection.model === refused.requested;
|
|
2
|
+
const replaced = (selection, model) => {
|
|
3
|
+
// A variant or effort belonged to the refused model.
|
|
4
|
+
const { variant: _variant, effort: _effort, ...rest } = selection;
|
|
5
|
+
return { ...rest, model };
|
|
6
|
+
};
|
|
7
|
+
/** Saves the model that ran over the refused one. Returns what changed. */
|
|
8
|
+
export function repairRefusedModel(store, botId, threadId, refused) {
|
|
9
|
+
const task = store.taskByThread(botId, threadId);
|
|
10
|
+
const thread = Boolean(task?.modelSelection && names(task.modelSelection, refused) &&
|
|
11
|
+
store.patchTask(botId, threadId, { modelSelection: replaced(task.modelSelection, refused.model) }));
|
|
12
|
+
const current = store.bot(botId);
|
|
13
|
+
const bot = Boolean(current && names(current.modelSelection, refused) &&
|
|
14
|
+
store.patchBot(botId, { modelSelection: replaced(current.modelSelection, refused.model) }));
|
|
15
|
+
return { thread, bot };
|
|
16
|
+
}
|
|
17
|
+
/** The thread's one line about it. */
|
|
18
|
+
export function refusedModelLine(refused) {
|
|
19
|
+
return `this engine cannot run ${refused.requested}: this thread now uses ${refused.model}`;
|
|
20
|
+
}
|
|
@@ -17,7 +17,7 @@ export class GatewayRests {
|
|
|
17
17
|
rest(model, ms = REST_MS) { this.until.set(model, this.now() + ms); }
|
|
18
18
|
resting = (model) => (this.until.get(model) ?? 0) > this.now();
|
|
19
19
|
}
|
|
20
|
-
export async function firstAnswer(models, send, rests) {
|
|
20
|
+
export async function firstAnswer(models, send, rests, gone) {
|
|
21
21
|
const failovers = [];
|
|
22
22
|
let last = { status: 404, error: "No model is available behind Atomic right now. Start Ollama, or sign in to Ollama for its cloud models." };
|
|
23
23
|
for (const model of models) {
|
|
@@ -27,6 +27,9 @@ export async function firstAnswer(models, send, rests) {
|
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
29
|
failovers.push(model);
|
|
30
|
+
// The caller hung up: there is no one left to try the next model for.
|
|
31
|
+
if (gone?.aborted)
|
|
32
|
+
return { ok: false, status: 499, error: "The caller went away.", failovers };
|
|
30
33
|
last = { status: 502, error: `Ollama did not answer (${error.message}).` };
|
|
31
34
|
continue;
|
|
32
35
|
}
|
|
@@ -12,12 +12,31 @@
|
|
|
12
12
|
// answers every other GET path.
|
|
13
13
|
import { Readable } from "node:stream";
|
|
14
14
|
import { hostApiKey, localHost } from "../drivers/local-inject.js";
|
|
15
|
+
import { DEFAULT_IDLE_TIMEOUT_MS } from "../drivers/openai-compat.js";
|
|
15
16
|
import { PASS } from "../routes/table.js";
|
|
16
17
|
import { firstAnswer, GatewayRests } from "./failover.js";
|
|
17
18
|
import { ATOMIC_AUTO_GATEWAY_MODEL, modelsFor } from "./ladder.js";
|
|
19
|
+
import { usageMeter } from "./usage.js";
|
|
18
20
|
const PREFIX = "/api/v1/";
|
|
19
21
|
const PASS_THROUGH = new Set(["responses", "chat/completions", "messages"]);
|
|
20
22
|
const MAX_BODY = 32 * 1024 * 1024;
|
|
23
|
+
const LOG_MAX = 120;
|
|
24
|
+
/** A caller's string made safe for one log line: printable ASCII, bounded. */
|
|
25
|
+
export function forLog(value) {
|
|
26
|
+
return value.slice(0, LOG_MAX).replace(/[^\x20-\x7e]/g, "?") + (value.length > LOG_MAX ? "..." : "");
|
|
27
|
+
}
|
|
28
|
+
/** Aborts when nothing has arrived for `ms`; `touch` on every byte. */
|
|
29
|
+
function idleWatch(ms) {
|
|
30
|
+
const controller = new AbortController();
|
|
31
|
+
let timer;
|
|
32
|
+
const clear = () => clearTimeout(timer);
|
|
33
|
+
const touch = () => {
|
|
34
|
+
clear();
|
|
35
|
+
timer = setTimeout(() => controller.abort(new Error(`no answer in ${Math.round(ms / 1000)} seconds`)), ms);
|
|
36
|
+
};
|
|
37
|
+
touch();
|
|
38
|
+
return { signal: controller.signal, touch, clear };
|
|
39
|
+
}
|
|
21
40
|
const LOOPBACK = new Set(["127.0.0.1", "::1", "::ffff:127.0.0.1", "localhost"]);
|
|
22
41
|
/** The socket and the Host header both name this computer. */
|
|
23
42
|
export function fromLoopback(remoteAddress, host) {
|
|
@@ -37,12 +56,13 @@ export function createModelGatewayRoutes(deps = {}) {
|
|
|
37
56
|
const rests = deps.rests ?? new GatewayRests();
|
|
38
57
|
const log = deps.log ?? ((line) => console.info(line));
|
|
39
58
|
const upstream = () => (deps.upstream ?? ollama)();
|
|
40
|
-
|
|
59
|
+
const idleMs = deps.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS;
|
|
60
|
+
async function served(gone) {
|
|
41
61
|
const base = upstream();
|
|
42
62
|
if (!base)
|
|
43
63
|
return [];
|
|
44
64
|
try {
|
|
45
|
-
const res = await fetchImpl(`${base.baseUrl}/models`, { headers: base.apiKey ? { authorization: `Bearer ${base.apiKey}` } : {}, signal: AbortSignal.timeout(5_000) });
|
|
65
|
+
const res = await fetchImpl(`${base.baseUrl}/models`, { headers: base.apiKey ? { authorization: `Bearer ${base.apiKey}` } : {}, signal: AbortSignal.any([AbortSignal.timeout(5_000), gone]) });
|
|
46
66
|
const body = res.ok ? await res.json() : {};
|
|
47
67
|
return (body.data ?? []).map((row) => row.id).filter((id) => typeof id === "string" && id.length > 0);
|
|
48
68
|
}
|
|
@@ -60,7 +80,18 @@ export function createModelGatewayRoutes(deps = {}) {
|
|
|
60
80
|
return json(res, 403, { error: "Atomic's model source answers only on this computer." });
|
|
61
81
|
if (auth.kind !== "assistant")
|
|
62
82
|
return json(res, 401, { error: "Send a connected assistant's token from Atomic Settings → Connected assistants." });
|
|
63
|
-
|
|
83
|
+
if (method === "POST") {
|
|
84
|
+
try {
|
|
85
|
+
deps.withinBudget?.();
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
return json(res, 409, { error: error instanceof Error ? error.message : String(error), code: "spend_cap" });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// A caller that hangs up takes its upstream request with it.
|
|
92
|
+
const closed = new AbortController();
|
|
93
|
+
res.on("close", () => closed.abort());
|
|
94
|
+
const available = await served(closed.signal);
|
|
64
95
|
if (tail === "models") {
|
|
65
96
|
const ids = [ATOMIC_AUTO_GATEWAY_MODEL, ...available];
|
|
66
97
|
return json(res, 200, { object: "list", data: ids.map((id) => ({ id, object: "model", owned_by: id === ATOMIC_AUTO_GATEWAY_MODEL ? "atomic" : "ollama", ...(id === ATOMIC_AUTO_GATEWAY_MODEL ? { display_name: "Atomic Engine (Auto)" } : {}) })) });
|
|
@@ -85,20 +116,39 @@ export function createModelGatewayRoutes(deps = {}) {
|
|
|
85
116
|
headers["x-api-key"] = base.apiKey ?? "ollama";
|
|
86
117
|
headers["anthropic-version"] = String(req.headers["anthropic-version"] ?? "2023-06-01");
|
|
87
118
|
}
|
|
88
|
-
|
|
89
|
-
|
|
119
|
+
let watch;
|
|
120
|
+
const send = (model) => {
|
|
121
|
+
watch?.clear();
|
|
122
|
+
watch = idleWatch(idleMs);
|
|
123
|
+
return fetchImpl(`${base.baseUrl}/${tail}`, { method: "POST", headers, body: JSON.stringify({ ...body, model }), signal: AbortSignal.any([closed.signal, watch.signal]) });
|
|
124
|
+
};
|
|
125
|
+
const answer = await firstAnswer(models, send, rests, closed.signal);
|
|
126
|
+
log(`[model-gateway] ${tail} asked=${forLog(asked)} used=${answer.ok ? forLog(answer.model) : "none"} failovers=${forLog(answer.failovers.join(",")) || "none"}`);
|
|
127
|
+
if (closed.signal.aborted)
|
|
128
|
+
return void watch?.clear();
|
|
90
129
|
if (!answer.ok)
|
|
91
|
-
return json(res, answer.status === 404 ? 503 : answer.status, { error: answer.error });
|
|
130
|
+
return void (watch?.clear(), json(res, answer.status === 404 ? 503 : answer.status, { error: answer.error }));
|
|
92
131
|
const type = answer.response.headers.get("content-type") ?? "application/json";
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return void res.end();
|
|
132
|
+
const meter = usageMeter(type);
|
|
133
|
+
res.writeHead(answer.response.status, { "content-type": type, "cache-control": "no-cache", "x-atomic-model": forLog(answer.model) });
|
|
96
134
|
// Past the first byte there is no failing over: the harness has started reading.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
135
|
+
if (answer.response.body)
|
|
136
|
+
await new Promise((resolve) => {
|
|
137
|
+
const stream = Readable.fromWeb(answer.response.body);
|
|
138
|
+
stream.on("data", (chunk) => { watch?.touch(); meter.push(chunk); });
|
|
139
|
+
stream.on("error", () => { res.destroy(); resolve(); });
|
|
140
|
+
res.on("close", () => { stream.destroy(); resolve(); });
|
|
141
|
+
stream.pipe(res).on("finish", () => resolve());
|
|
142
|
+
});
|
|
143
|
+
else
|
|
144
|
+
res.end();
|
|
145
|
+
watch?.clear();
|
|
146
|
+
if (!answer.response.ok)
|
|
147
|
+
return;
|
|
148
|
+
const usage = meter.total();
|
|
149
|
+
deps.book?.({
|
|
150
|
+
botId: `assistant:${auth.assistant.id}`, botName: auth.assistant.label, threadId: "model-gateway", instanceId: "ollama", driverKind: "ollama",
|
|
151
|
+
model: answer.model, input: usage?.input ?? 0, output: usage?.output ?? 0, costUsd: null, trigger: { kind: "owner" }, source: "atomic/auto",
|
|
102
152
|
});
|
|
103
153
|
};
|
|
104
154
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Token counts out of an answer as it passes through the gateway, for the
|
|
2
|
+
// usage ledger. Reads only `usage` objects (OpenAI Responses and Chat
|
|
3
|
+
// Completions, Anthropic Messages; whole JSON or event stream); message text
|
|
4
|
+
// is never kept past the line or body it arrived in.
|
|
5
|
+
const MAX_JSON = 4 * 1024 * 1024;
|
|
6
|
+
const MAX_LINE = 256 * 1024;
|
|
7
|
+
const count = (value) => (typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : 0);
|
|
8
|
+
const record = (value) => (typeof value === "object" && value !== null ? value : null);
|
|
9
|
+
function usageIn(value) {
|
|
10
|
+
const body = record(value);
|
|
11
|
+
const usage = record(body?.usage) ?? record(record(body?.response)?.usage) ?? record(record(body?.message)?.usage);
|
|
12
|
+
if (!usage)
|
|
13
|
+
return null;
|
|
14
|
+
return { input: count(usage.input_tokens ?? usage.prompt_tokens), output: count(usage.output_tokens ?? usage.completion_tokens) };
|
|
15
|
+
}
|
|
16
|
+
function parsed(text) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(text);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Feed it the answer's bytes; `total()` is the usage the upstream reported, or null. */
|
|
25
|
+
export function usageMeter(contentType) {
|
|
26
|
+
const stream = contentType.includes("event-stream");
|
|
27
|
+
const decoder = new TextDecoder();
|
|
28
|
+
let pending = "";
|
|
29
|
+
let overflow = false;
|
|
30
|
+
let seen = null;
|
|
31
|
+
const take = (usage) => {
|
|
32
|
+
if (usage)
|
|
33
|
+
seen = { input: Math.max(seen?.input ?? 0, usage.input), output: Math.max(seen?.output ?? 0, usage.output) };
|
|
34
|
+
};
|
|
35
|
+
const line = (text) => {
|
|
36
|
+
if (text.startsWith("data:") && text.includes("\"usage\""))
|
|
37
|
+
take(usageIn(parsed(text.slice(5))));
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
push(chunk) {
|
|
41
|
+
if (overflow)
|
|
42
|
+
return;
|
|
43
|
+
pending += decoder.decode(chunk, { stream: true });
|
|
44
|
+
if (stream) {
|
|
45
|
+
const lines = pending.split("\n");
|
|
46
|
+
pending = lines.pop() ?? "";
|
|
47
|
+
for (const text of lines)
|
|
48
|
+
line(text.trimEnd());
|
|
49
|
+
if (pending.length > MAX_LINE)
|
|
50
|
+
pending = "";
|
|
51
|
+
}
|
|
52
|
+
else if (pending.length > MAX_JSON) {
|
|
53
|
+
overflow = true;
|
|
54
|
+
pending = "";
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
total() {
|
|
58
|
+
if (stream)
|
|
59
|
+
line(pending.trimEnd());
|
|
60
|
+
else if (!overflow)
|
|
61
|
+
take(usageIn(parsed(pending)));
|
|
62
|
+
pending = "";
|
|
63
|
+
return seen;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Fewer shared rows than this and the fetch is used as it is. */
|
|
2
|
+
export const MIN_SCALE_PAIRS = 8;
|
|
3
|
+
/** Mean gap (points) under which the two are taken to be the same scale. */
|
|
4
|
+
export const SAME_SCALE_POINTS = 1;
|
|
5
|
+
const round3 = (value) => Math.round(value * 1000) / 1000;
|
|
6
|
+
/** The fit from `fetched` onto `baseline`'s scale; null when the two agree
|
|
7
|
+
* or too few rows are shared to say. */
|
|
8
|
+
export function aaScale(fetched, baseline) {
|
|
9
|
+
const byId = new Map(baseline.map((row) => [row.id, row]));
|
|
10
|
+
const bySlug = new Map(baseline.map((row) => [row.slug, row]));
|
|
11
|
+
const pairs = [];
|
|
12
|
+
for (const row of fetched) {
|
|
13
|
+
const base = byId.get(row.id) ?? bySlug.get(row.slug);
|
|
14
|
+
if (base && Number.isFinite(row.intelligence) && Number.isFinite(base.intelligence))
|
|
15
|
+
pairs.push([row.intelligence, base.intelligence]);
|
|
16
|
+
}
|
|
17
|
+
if (pairs.length < MIN_SCALE_PAIRS)
|
|
18
|
+
return null;
|
|
19
|
+
const n = pairs.length;
|
|
20
|
+
const meanX = pairs.reduce((sum, [x]) => sum + x, 0) / n;
|
|
21
|
+
const meanY = pairs.reduce((sum, [, y]) => sum + y, 0) / n;
|
|
22
|
+
const meanGap = pairs.reduce((sum, [x, y]) => sum + Math.abs(y - x), 0) / n;
|
|
23
|
+
if (meanGap < SAME_SCALE_POINTS)
|
|
24
|
+
return null;
|
|
25
|
+
const sxx = pairs.reduce((sum, [x]) => sum + (x - meanX) ** 2, 0);
|
|
26
|
+
const sxy = pairs.reduce((sum, [x, y]) => sum + (x - meanX) * (y - meanY), 0);
|
|
27
|
+
// A flat or upside-down fit means the rows disagree, not a rescale: shift
|
|
28
|
+
// by the mean gap instead of stretching.
|
|
29
|
+
const fitted = sxx > 0 ? sxy / sxx : 0;
|
|
30
|
+
const slope = fitted >= 0.5 && fitted <= 2 ? fitted : 1;
|
|
31
|
+
return { pairs: n, slope: round3(slope), intercept: round3(meanY - slope * meanX) };
|
|
32
|
+
}
|
|
33
|
+
/** The fetch with every score on the baseline's scale (one decimal, as the
|
|
34
|
+
* index is published); unchanged when `scale` is null. */
|
|
35
|
+
export function onBaselineScale(snapshot, scale) {
|
|
36
|
+
if (!scale)
|
|
37
|
+
return snapshot;
|
|
38
|
+
return {
|
|
39
|
+
...snapshot,
|
|
40
|
+
rows: snapshot.rows.map((row) => ({ ...row, intelligence: Math.round((scale.slope * row.intelligence + scale.intercept) * 10) / 10 })),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -196,7 +196,7 @@ export const MODEL_CATALOG = [
|
|
|
196
196
|
id: "gemini-3.8-flash", label: "Gemini 3.8 Flash",
|
|
197
197
|
aa: ["Gemini 3.8 Flash"], leaderboard: ["Gemini 3.8 Flash (High)", "gemini-3.8-flash-high"],
|
|
198
198
|
runs: [run("antigravityAgent", "gemini-3.8-flash-high", "high"), run("antigravityAgent", "gemini-3.8-flash-medium", "medium"),
|
|
199
|
-
run("antigravityAgent", "gemini-3.8-flash-low", "low"), opencode("gemini-3.8-flash"), hermes("google/gemini-3.8-flash")],
|
|
199
|
+
run("antigravityAgent", "gemini-3.8-flash-low", "low"), opencode("gemini-3.8-flash"), hermes("google/gemini-3.8-flash"), run("openai-compat", "google/gemini-3.8-flash")],
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
id: "gemini-3.7-flash", label: "Gemini 3.7 Flash",
|
|
@@ -247,19 +247,32 @@ export const MODEL_CATALOG = [
|
|
|
247
247
|
{
|
|
248
248
|
id: "deepseek-v4-pro", label: "DeepSeek V4 Pro",
|
|
249
249
|
aa: ["DeepSeek V4 Pro 0813"], leaderboard: ["DeepSeek V4 Pro", "DeepSeek V4 Pro (High) (0813)", "deepseek-v4-pro", "deepseek-v4-pro-high-20260813"],
|
|
250
|
-
runs: [opencode("deepseek-v4-pro"), hermes("deepseek/deepseek-v4-pro")],
|
|
250
|
+
runs: [opencode("deepseek-v4-pro"), hermes("deepseek/deepseek-v4-pro"), run("openai-compat", "deepseek-v4-pro")],
|
|
251
251
|
ollama: ["deepseek-v4-pro:cloud"],
|
|
252
252
|
},
|
|
253
253
|
{
|
|
254
254
|
id: "deepseek-v4.1-flash", label: "DeepSeek V4.1 Flash",
|
|
255
255
|
aa: ["DeepSeek V4.1 Flash"], leaderboard: ["Deepseek V4.1 Flash (Max)", "deepseek-v4.1-flash-max"],
|
|
256
|
-
|
|
256
|
+
// DeepSeek's own API serves V4.1 Flash as "deepseek-flash" (api-docs, 2026-11-22).
|
|
257
|
+
runs: [opencode("deepseek-v4.1-flash"), hermes("deepseek/deepseek-v4.1-flash"), run("openai-compat", "deepseek-flash")],
|
|
257
258
|
},
|
|
258
259
|
{
|
|
259
260
|
id: "deepseek-v4-flash", label: "DeepSeek V4 Flash",
|
|
260
261
|
leaderboard: ["deepseek-v4-flash", "deepseek-v4-flash-high"],
|
|
261
262
|
runs: [codex("deepseek-v4-flash:cloud"), opencode("deepseek-v4-flash")],
|
|
262
263
|
},
|
|
264
|
+
// OpenAI's open-weight models on OpenAI-compatible hosts: Pollinations'
|
|
265
|
+
// keyless "openai-fast" is gpt-oss-20b (its answers name the model);
|
|
266
|
+
// Hugging Face and Cerebras serve gpt-oss-120b.
|
|
267
|
+
{
|
|
268
|
+
id: "gpt-oss-20b", label: "gpt-oss-20b", leaderboard: ["gpt-oss-20b"],
|
|
269
|
+
runs: [run("openai-compat", "openai-fast"), run("openai-compat", "openai/gpt-oss-20b"), run("openai-compat", "gpt-oss-20b")],
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: "gpt-oss-120b", label: "gpt-oss-120b", leaderboard: ["gpt-oss-120b"],
|
|
273
|
+
// Hugging Face, Together, Groq and Cerebras name it plainly; Fireworks and Bedrock add a prefix.
|
|
274
|
+
runs: [run("openai-compat", "openai/gpt-oss-120b"), run("openai-compat", "gpt-oss-120b"), run("openai-compat", "accounts/fireworks/models/gpt-oss-120b"), run("openai-compat", "openai.gpt-oss-120b-1:0")],
|
|
275
|
+
},
|
|
263
276
|
// Meta, through Muse Code (ids from dev.meta.ai/docs/models, 2026-10-23).
|
|
264
277
|
// Muse Wonder 1.0 is not listed: the boards now carry "Muse Wonder" and
|
|
265
278
|
// "Muse Wonder Full", and which of the two it is has not been settled, so
|
|
@@ -19,6 +19,7 @@ import { BASELINE } from "./baseline.js";
|
|
|
19
19
|
import { AA_CACHE_FILE, CACHE_FILE, readAaCache, readCache, validSnapshots, writeAaCache, writeCache } from "./cache.js";
|
|
20
20
|
import { setPublishedHarnessWeights } from "../ladder-order.js";
|
|
21
21
|
import { CHIBITEK_RANKINGS_CACHE, fetchRankings, parseRankings, readRankingsCache, writeRankingsCache } from "./chibitek-rankings.js";
|
|
22
|
+
import { aaScale, onBaselineScale } from "./aa-scale.js";
|
|
22
23
|
import { AA_STALE_AFTER_DAYS, byClass, classifyModels, gradedFamilies, inheritedClass, matchAaRows } from "./classes.js";
|
|
23
24
|
import { fetchSource } from "./fetch.js";
|
|
24
25
|
import { PERCENTILE_CUTOFFS, gradeCapabilities } from "./grade.js";
|
|
@@ -89,7 +90,10 @@ export function createModelLevels(options) {
|
|
|
89
90
|
const { overrides, problems } = readOverrides(overridesPath);
|
|
90
91
|
const fetchedLmarena = current().filter((snapshot) => origins.get(snapshot.source) !== "baseline");
|
|
91
92
|
const lmarena = lmarenaInput(current(), overrides.aliases);
|
|
92
|
-
|
|
93
|
+
// A fetch on a newer Intelligence Index is read on the baseline's scale,
|
|
94
|
+
// the one the bands were set on (aa-scale.ts).
|
|
95
|
+
const scale = aaFetched && aaBaseline ? aaScale(aaFetched.rows, aaBaseline.rows) : null;
|
|
96
|
+
const aa = aaFetched ? matchAaRows(onBaselineScale(aaFetched, scale).rows, catalog, overrides.aliases) : undefined;
|
|
93
97
|
const aaBase = aaBaseline ? matchAaRows(aaBaseline.rows, catalog, overrides.aliases) : undefined;
|
|
94
98
|
const models = classifyModels({
|
|
95
99
|
catalog,
|
|
@@ -105,7 +109,7 @@ export function createModelLevels(options) {
|
|
|
105
109
|
const unmatched = new Map();
|
|
106
110
|
for (const entry of [...(aa ?? aaBase)?.unmatched ?? [], ...lmarena.unmatched])
|
|
107
111
|
unmatched.set(`${entry.sources[0]}:${entry.name}`, entry);
|
|
108
|
-
return { models, unmatched: [...unmatched.values()], problems, bands: overrides.bands };
|
|
112
|
+
return { models, unmatched: [...unmatched.values()], problems, bands: overrides.bands, scale };
|
|
109
113
|
};
|
|
110
114
|
// Classes are read on every turn start and failover; they are cached until
|
|
111
115
|
// a refresh, an override, or a change to the overrides file on disk.
|
|
@@ -126,7 +130,7 @@ export function createModelLevels(options) {
|
|
|
126
130
|
return memo.value;
|
|
127
131
|
};
|
|
128
132
|
const report = () => {
|
|
129
|
-
const { models, unmatched, problems, bands } = classified();
|
|
133
|
+
const { models, unmatched, problems, bands, scale } = classified();
|
|
130
134
|
return {
|
|
131
135
|
generatedAt: now().toISOString(),
|
|
132
136
|
attribution: { artificialAnalysis: AA_ATTRIBUTION, lmarena: ATTRIBUTION },
|
|
@@ -136,6 +140,7 @@ export function createModelLevels(options) {
|
|
|
136
140
|
fetchedAt: (aaFetched ?? aaBaseline)?.fetchedAt ?? null,
|
|
137
141
|
origin: aaOrigin,
|
|
138
142
|
rows: (aaFetched ?? aaBaseline)?.rows.length ?? 0,
|
|
143
|
+
scale,
|
|
139
144
|
},
|
|
140
145
|
chibitekRankings: rankings
|
|
141
146
|
? { week: rankings.week, fetchedAt: rankings.fetchedAt, rows: rankings.rows.length }
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Builds the weekly Chibitek rankings document (chibitek-rankings.ts) from
|
|
2
|
+
// the same live public sources Atomic grades classes from, so the document
|
|
3
|
+
// is real data with its sources named inside it, never hand-typed numbers:
|
|
4
|
+
// - Artificial Analysis Intelligence Index (live with a key, else the
|
|
5
|
+
// bundled rows, dated), the class and the order inside the class;
|
|
6
|
+
// - LMArena boards (Hugging Face datasets, fetched live, no key), for
|
|
7
|
+
// models Artificial Analysis does not list.
|
|
8
|
+
// The weekly document itself is never read back while building (its URL is
|
|
9
|
+
// answered "not published" here), so a week never ranks from last week.
|
|
10
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { DEFAULT_CLASS_BANDS, MODEL_CLASSES, classForScore } from "../../shared/engine-tiers.js";
|
|
14
|
+
import { AA_ATTRIBUTION, AA_MODELS_URL } from "./artificial-analysis.js";
|
|
15
|
+
import { CHIBITEK_RANKINGS_URL } from "./chibitek-rankings.js";
|
|
16
|
+
import { scoreVariants } from "./classes.js";
|
|
17
|
+
import { createModelLevels } from "./index.js";
|
|
18
|
+
const GRADED = new Set(["artificial-analysis", "lmarena", "baseline"]);
|
|
19
|
+
/** A model's class: banded from its Artificial Analysis score (medium/high
|
|
20
|
+
* rule, on the bands' scale) when it has one, the documented primary scorer;
|
|
21
|
+
* else Atomic's own grade (LMArena). The order inside a class: that score,
|
|
22
|
+
* highest first; then models only LMArena grades, by percentile. */
|
|
23
|
+
export function rankingsFromReport(report, week, generatedAt) {
|
|
24
|
+
const rows = [];
|
|
25
|
+
for (const model of report.models) {
|
|
26
|
+
const grade = model.modelClass;
|
|
27
|
+
if (model.overrideOnly || !GRADED.has(grade.source))
|
|
28
|
+
continue;
|
|
29
|
+
const aa = grade.score ?? scoreVariants(grade.variants)?.score;
|
|
30
|
+
const basis = { source: grade.baselineOf ? `baseline:${grade.baselineOf}` : grade.source };
|
|
31
|
+
if (grade.sourceDate)
|
|
32
|
+
basis.sourceDate = grade.sourceDate;
|
|
33
|
+
if (aa !== undefined)
|
|
34
|
+
basis.aaIntelligence = aa;
|
|
35
|
+
if (grade.percentile !== undefined)
|
|
36
|
+
basis.lmarenaPercentile = grade.percentile;
|
|
37
|
+
const modelClass = aa !== undefined ? classForScore(aa, report.bands ?? DEFAULT_CLASS_BANDS) : grade.modelClass;
|
|
38
|
+
basis.classFrom = aa !== undefined ? "artificial-analysis" : basis.source;
|
|
39
|
+
rows.push({ id: model.id, label: model.label, modelClass, ...(aa !== undefined ? { aa } : {}), ...(grade.percentile !== undefined ? { percentile: grade.percentile } : {}), basis });
|
|
40
|
+
}
|
|
41
|
+
const models = [];
|
|
42
|
+
for (const modelClass of MODEL_CLASSES) {
|
|
43
|
+
const inClass = rows.filter((row) => row.modelClass === modelClass).sort((a, b) => (a.aa === undefined ? 1 : 0) - (b.aa === undefined ? 1 : 0) || (b.aa ?? 0) - (a.aa ?? 0) ||
|
|
44
|
+
(b.percentile ?? -1) - (a.percentile ?? -1) || a.id.localeCompare(b.id));
|
|
45
|
+
inClass.forEach((row, index) => models.push({ id: row.id, label: row.label, class: modelClass, rank: index + 1, basis: row.basis }));
|
|
46
|
+
}
|
|
47
|
+
const aa = report.artificialAnalysis;
|
|
48
|
+
return {
|
|
49
|
+
week, generatedAt,
|
|
50
|
+
method: "Class: the Artificial Analysis Intelligence Index (mean of medium and high effort) on the class bands (Mezcal 50, Plata 44, Reposado 38); a model Artificial Analysis does not list keeps Atomic's LMArena grade. Rank inside a class: that index, highest first, then LMArena overall percentile. docs/chibitek/engine-tiers.md, Model classes.",
|
|
51
|
+
sources: [
|
|
52
|
+
{ name: `Artificial Analysis (${AA_ATTRIBUTION})`, url: AA_MODELS_URL, date: aa.fetchedAt?.slice(0, 10) ?? null, origin: aa.origin, rows: aa.rows },
|
|
53
|
+
...report.sources.map((source) => ({ name: `LMArena ${source.id}`, url: source.url, date: source.publishDate, origin: source.origin, rows: source.rows })),
|
|
54
|
+
],
|
|
55
|
+
models,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Refreshes every source live into a scratch directory and builds the
|
|
59
|
+
* document. `apiKey` absent: Artificial Analysis comes from the bundled rows. */
|
|
60
|
+
export async function buildRankings(options = {}) {
|
|
61
|
+
const base = options.fetch ?? globalThis.fetch;
|
|
62
|
+
const fetch = async (url, init) => (String(url) === CHIBITEK_RANKINGS_URL
|
|
63
|
+
? { ok: false, status: 404, headers: { get: () => null }, json: async () => ({}) }
|
|
64
|
+
: base(url, init));
|
|
65
|
+
const now = options.now ?? (() => new Date());
|
|
66
|
+
const dataDir = mkdtempSync(join(tmpdir(), "chibitek-rankings-"));
|
|
67
|
+
try {
|
|
68
|
+
const levels = createModelLevels({ dataDir, fetch, now, apiKey: options.apiKey ?? (() => undefined), log: () => { } });
|
|
69
|
+
const refresh = await levels.refresh();
|
|
70
|
+
const at = now();
|
|
71
|
+
return { document: rankingsFromReport(levels.report(), at.toISOString().slice(0, 10), at.toISOString()), errors: refresh.errors };
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
rmSync(dataDir, { recursive: true, force: true });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -10,6 +10,9 @@ const MINIMAX = "https://platform.minimax.io/docs/guides/pricing-paygo";
|
|
|
10
10
|
// models, so these are read from that list rather than copied from the
|
|
11
11
|
// vendors. Its 5.5% fee on buying credits is not a per-token price.
|
|
12
12
|
const OPENROUTER = "https://openrouter.ai/api/v1/models";
|
|
13
|
+
// DeepSeek bills half price off-peak; these are the PEAK rates (01:00-04:00
|
|
14
|
+
// and 06:00-10:00 UTC on weekdays), so an estimate never runs under the bill.
|
|
15
|
+
const DEEPSEEK = "https://api-docs.deepseek.com/quick_start/pricing";
|
|
13
16
|
const price = (source, input, cached, output, extra = {}) => ({
|
|
14
17
|
inputPerMillion: input,
|
|
15
18
|
cachedInputPerMillion: cached,
|
|
@@ -78,6 +81,9 @@ export const LIST_PRICES = {
|
|
|
78
81
|
"google/gemini-3.8-flash": price(OPENROUTER, 0.75, 0.075, 3.75),
|
|
79
82
|
"minimax/minimax-m3": price(OPENROUTER, 0.3, 0.06, 1.2),
|
|
80
83
|
"minimax/minimax-m2.7": price(OPENROUTER, 0.3, 0.06, 1.2),
|
|
84
|
+
// DeepSeek's own API, peak rates, read 2026-11-22.
|
|
85
|
+
"deepseek-flash": price(DEEPSEEK, 0.3, 0.006, 1.2, { asOf: "2026-11-22" }),
|
|
86
|
+
"deepseek-v4-pro": price(DEEPSEEK, 1.32, 0.044, 3.96, { asOf: "2026-11-22" }),
|
|
81
87
|
};
|
|
82
88
|
/** Catalog ids that name a listed model with a setting attached: the
|
|
83
89
|
* Antigravity picker offers Gemini 3.8 Flash at three thinking levels. */
|
|
@@ -33,7 +33,7 @@ import { guardNexusClient, UnavailableBackoff } from "./backoff.js";
|
|
|
33
33
|
import { nexusClientFor, NexusRejectedError, NexusUnavailableError } from "./client.js";
|
|
34
34
|
import { buildSessionOutcome, promptText } from "./outcome.js";
|
|
35
35
|
import { NexusOutbox } from "./outbox.js";
|
|
36
|
-
import { classifyBotFile, containsSecret, desktopSurface, hipaaModeOn, isMediaMime, isTextMime,
|
|
36
|
+
import { classifyBotFile, containsSecret, desktopSurface, hipaaModeOn, isMediaMime, isTextMime, mimeForPath, scopeForBot, scrubSecrets, } from "./policy.js";
|
|
37
37
|
import { DEFAULT_BUDGET_CHARS, fetchReadBack, formatReadBack } from "./readback.js";
|
|
38
38
|
import { hostname } from "node:os";
|
|
39
39
|
import { isPersonalBot } from "../../shared/personal-bot.js";
|
|
@@ -323,8 +323,7 @@ export class NexusMemory {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
queueOutcome(turn, hipaa) {
|
|
326
|
-
if (hipaa
|
|
327
|
-
turn.toolResults?.some((tool) => markedPatientData({ text: tool.output ?? "", bot: turn.bot }))))
|
|
326
|
+
if (hipaa)
|
|
328
327
|
return "hipaa";
|
|
329
328
|
const outcome = buildSessionOutcome({
|
|
330
329
|
botName: turn.bot.name,
|
|
@@ -373,7 +372,7 @@ export class NexusMemory {
|
|
|
373
372
|
const route = nexusRouteFor(input.bot, settings.personalConnection);
|
|
374
373
|
if (route.to === "local")
|
|
375
374
|
return route.reason;
|
|
376
|
-
if (hipaaModeOn(this.hipaaContext(), input.bot)
|
|
375
|
+
if (hipaaModeOn(this.hipaaContext(), input.bot))
|
|
377
376
|
return "hipaa";
|
|
378
377
|
const source = this.writeSource(input.bot, input.threadId);
|
|
379
378
|
const queued = this.outbox.enqueue({
|
|
@@ -427,10 +426,7 @@ export class NexusMemory {
|
|
|
427
426
|
const media = isMediaMime(mime);
|
|
428
427
|
if (media && !settings.saveMedia)
|
|
429
428
|
return "media_off";
|
|
430
|
-
|
|
431
|
-
// The whole local path is checked (a patients/ folder anywhere above the
|
|
432
|
-
// file counts); it is only read here, never sent.
|
|
433
|
-
if (hipaa && markedPatientData({ path: `${input.path}\n${display}`, bot: input.bot }))
|
|
429
|
+
if (hipaaModeOn(this.hipaaContext(), input.bot))
|
|
434
430
|
return "hipaa";
|
|
435
431
|
let size;
|
|
436
432
|
try {
|
|
@@ -463,8 +459,6 @@ export class NexusMemory {
|
|
|
463
459
|
this.log(`refused to upload ${basename(display)}: it looks like it contains a secret`);
|
|
464
460
|
return "secret";
|
|
465
461
|
}
|
|
466
|
-
if (hipaa && isTextMime(mime) && markedPatientData({ text: asText }))
|
|
467
|
-
return "hipaa";
|
|
468
462
|
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
469
463
|
const queued = this.outbox.enqueue({
|
|
470
464
|
private: isPersonalBot(input.bot),
|
|
@@ -656,7 +650,7 @@ export class NexusMemory {
|
|
|
656
650
|
state = "not_connected";
|
|
657
651
|
else if (!settings.alwaysSave)
|
|
658
652
|
state = "off";
|
|
659
|
-
else if (bot.hipaa === true)
|
|
653
|
+
else if (bot.hipaa === true || settings.hipaa)
|
|
660
654
|
state = "hipaa_bot";
|
|
661
655
|
else
|
|
662
656
|
state = "connected";
|
|
@@ -745,8 +739,6 @@ export class NexusMemory {
|
|
|
745
739
|
const view = this.botView(bot);
|
|
746
740
|
if (view.state !== "connected")
|
|
747
741
|
return view.state;
|
|
748
|
-
if (view.hipaaMode && markedPatientData({ text: body }))
|
|
749
|
-
return "hipaa";
|
|
750
742
|
const hash = createHash("sha256").update(body).digest("hex");
|
|
751
743
|
const current = this.notes[bot.id];
|
|
752
744
|
if (current?.hash === hash && current.scope === view.scope)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// What Atomic may write back to Nexus, and under which scope and surface.
|
|
2
2
|
// Pure rules, shared by the writer, the read-back and their tests:
|
|
3
3
|
// - The Private Bot writes to the person's personal scope only, never work.
|
|
4
|
-
// - HIPAA mode
|
|
4
|
+
// - HIPAA mode keeps memory on this computer: nothing is written, marked
|
|
5
|
+
// as patient data or not. A rule that trusts markers protects only the
|
|
6
|
+
// text someone remembered to mark.
|
|
5
7
|
// - Nothing that looks like a secret is ever uploaded.
|
|
6
8
|
// - Only handoffs, documents and media are uploaded, never source code.
|
|
7
9
|
import { extname, basename } from "node:path";
|
|
@@ -31,25 +33,11 @@ export function surfaceForRequest(origin, platform = process.platform) {
|
|
|
31
33
|
return "cli";
|
|
32
34
|
return desktopSurface(platform);
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const PATIENT_MARKERS = /#patient-?data\b|\[(?:PHI|patient data)\]|\bpatient[-_ ]data:|\bPHI:/i;
|
|
37
|
-
/** Folders and file names that hold patient data. */
|
|
38
|
-
const PATIENT_PATH = /(?:^|[\\/_.\- ])(?:phi|patients?|patient[-_ ]?data|hipaa)(?:[\\/_.\- ]|$)/i;
|
|
36
|
+
/** True when nothing of this bot's may be written to Nexus: the workspace or
|
|
37
|
+
* the organization is in HIPAA mode, or the bot is flagged for HIPAA work. */
|
|
39
38
|
export function hipaaModeOn(ctx, bot) {
|
|
40
39
|
return ctx.workspace || ctx.managed || bot?.hipaa === true;
|
|
41
40
|
}
|
|
42
|
-
/** True when this text or path is marked as patient data. A bot flagged for
|
|
43
|
-
* HIPAA work is treated as handling patient data in everything it does. */
|
|
44
|
-
export function markedPatientData(item) {
|
|
45
|
-
if (item.bot?.hipaa === true)
|
|
46
|
-
return true;
|
|
47
|
-
if (item.text && PATIENT_MARKERS.test(item.text))
|
|
48
|
-
return true;
|
|
49
|
-
if (item.path && (PATIENT_PATH.test(item.path) || PATIENT_MARKERS.test(item.path)))
|
|
50
|
-
return true;
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
41
|
// ── secrets ──────────────────────────────────────────────────────────────
|
|
54
42
|
/** True when text carries anything the release scanner or the transcript
|
|
55
43
|
* redactor would treat as a credential. */
|