@chibitek/chibi 0.1.186 → 0.1.190
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/{abnfDiagram-O67JEVCF-T4rFqxxY.js → abnfDiagram-O67JEVCF-Bz3wlNsQ.js} +1 -1
- package/dist/assets/{arc-BE0n08tb.js → arc-CX0dJSa0.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-W248FhnN.js → architectureDiagram-NJMV4G6O-APIM9yGf.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-YQUaYL76.js → blockDiagram-BEXU5L5S-DNmNNaVY.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-DvtNnJ7Q.js → c4Diagram-YGBWAQC7-CAPPUeMU.js} +1 -1
- package/dist/assets/channel-CnfDal05.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-r9zB0AN4.js → chunk-2Q5K7J3B-DfCDsQgU.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-DcaWZ44l.js → chunk-3FUC2YCW-vdffwGmy.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-B9BoCCOM.js → chunk-5VM5RSS4-BazIL_2e.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-jiyufqr5.js → chunk-GTNCS2PH-GpKjNZ-V.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-86KjuKSi.js → chunk-GWA4HPMP-BuRq21LZ.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-P-CZmlpX.js → chunk-JWPE2WC7-CqNGOyHV.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-DOwQkah7.js → chunk-NETBCI7D-B1DpzVCP.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-BYpUWdau.js → chunk-WEXAMYUT-DcH1Euc6.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-BNWicp85.js → chunk-XXDRQBXY-M1JLd_cm.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-DeSoK71a.js → classDiagram-v2-NBCMYWYE-C8mBZ7i2.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-DRvyy4x6.js → cose-bilkent-JH36ORCC-Cr3TqHDz.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-BPgTdM9o.js → cynefin-OW5HDTMX-BKPr6l0I.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-CVqWmCzX.js → cynefinDiagram-VND7K2PF-Cbg5mrIM.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-C8Nn1Pd7.js → dagre-6A5THRUB-9I9X1J3r.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BoFPCHMw.js → diagram-22UHCM2B-B43b8pqQ.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-Bw55J1mb.js → diagram-3UASUU5V-CIehgEkZ.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-DGQrBqML.js → diagram-ATOU4E4O-gx8nkXLZ.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-COdY5ptf.js → diagram-CDSNMT55-BZzWgYHa.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-BPZDoncY.js → diagram-MLGK6HIB-BqoCqkZD.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-Fi29WkCR.js → diagram-MPIPVDR6-Bsc7x0UT.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-BXquz6x1.js → ebnfDiagram-ZINNZB2B-8HjdD_s8.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-C_e9eijP.js → elk-276RUBZZ-bmxiEFtT.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-C4PKtrfT.js → erDiagram-OPXOYQCR-BU-sRLe3.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-BlEulfZP.js → flowDiagram-KWPJA3E3-D45vn40U.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-BksDszQx.js → ganttDiagram-FUAMR5RP-CArB98Hu.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-EYJKMot5.js → gitGraphDiagram-X574FWY7-fPB1k-W7.js} +1 -1
- package/dist/assets/{index-Bf2yMkX_.js → index-QsXeEMxJ.js} +142 -142
- package/dist/assets/{index-Do0zrygp.js → index-u1wvoacp.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-BuX8YJRd.js → infoDiagram-VRGFBTTK-ZRVWXAr4.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-BOOBBq5e.js → ishikawaDiagram-OU5B5YK6-DOaurRbX.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-2VfxHa4O.js → journeyDiagram-ZHPQQLJL-Ca9B-09w.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-DniBc17b.js → kanban-definition-PNTS6WVX-CA2XswEJ.js} +1 -1
- package/dist/assets/{linear-CrF1eGjn.js → linear-B-F7icip.js} +1 -1
- package/dist/assets/{mermaid.core-BL_dHjXO.js → mermaid.core-ymtCpbZ5.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-DUGzdUse.js → mindmap-definition-NLK3R4M7-02vIazCi.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-CO3xT6J0.js → pegDiagram-GJSIUBJH-DRb7Pn72.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-8gmuAKxu.js → pieDiagram-5QR66LMP-B2YwP3S_.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-D0I0xUDm.js → quadrantDiagram-O4NWA36T-CbR573mu.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-DY0BvxgQ.js → railroadDiagram-XR7U4H2S-CqHuDCnM.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-DhGe1AaP.js → requirementDiagram-PLB6GJNP-BSeC-H1j.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-CeCrbMFN.js → sankeyDiagram-IPEJSGJF-BMFuhoh1.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-fWSeitKd.js → sequenceDiagram-PO4LG4MO-DRT_EI9u.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-Dtg_1bqe.js → sizeCapture-INFHLROL-BLFT4fV7.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-DGUAiQQE.js → stateDiagram-v2-GCMORJYK-C8vB_69H.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-DebVwPYw.js → swimlanes-2SLR337P-T6BBolT8.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BIY4fGCv.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-Dg7oYgtr.js → timeline-definition-EJHVYXUP-DjdjBRQV.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-uqTnPXSC.js → usecaseDiagram-POWQR4AR-CDGccZMN.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-CzMUwXwR.js → vennDiagram-UO4OBE2U-CgYSihtW.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-BsyaKB_7.js → wardleyDiagram-VNRHLVJA-Bub5ScM8.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-7hUye0pF.js → xychartDiagram-PMCCYNJV-DK5iMX67.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/drivers/agents-proxy.js +52 -2
- package/dist-server/index.js +4413 -3656
- package/dist-server/openmausbot.js +1432 -878
- package/dist-server/pair-cli.js +1432 -878
- package/dist-server/server/about-me-sync.js +16 -5
- package/dist-server/server/box.js +18 -14
- package/dist-server/server/browser-engine.js +4 -26
- package/dist-server/server/browser-runtime.js +41 -5
- package/dist-server/server/calendar-calls.js +2 -1
- package/dist-server/server/capped-body.js +26 -0
- package/dist-server/server/chibi-defaults.js +96 -0
- package/dist-server/server/cli-login.js +4 -0
- package/dist-server/server/connection-cap-failover.js +0 -2
- package/dist-server/server/container-computer.js +9 -9
- package/dist-server/server/drivers/agents-call.js +3 -3
- package/dist-server/server/drivers/agents-catalog.js +2 -2
- package/dist-server/server/drivers/agents-credential.js +6 -0
- package/dist-server/server/drivers/agents-vault.js +36 -0
- package/dist-server/server/engine-failover.js +6 -3
- package/dist-server/server/engine-tiers.js +8 -8
- package/dist-server/server/hidden-ai-text.js +56 -0
- package/dist-server/server/index.js +37 -41
- package/dist-server/server/local-vm-run.js +10 -0
- package/dist-server/server/model-levels/aliases.js +7 -2
- package/dist-server/server/model-levels/index.js +7 -0
- package/dist-server/server/request-auth.js +15 -18
- package/dist-server/server/routes/message-file.js +1 -1
- package/dist-server/server/routines.js +6 -6
- package/dist-server/server/store.js +1 -1
- package/dist-server/server/stream-tail.js +25 -0
- package/dist-server/server/system-prompt.js +17 -2
- package/dist-server/server/team-rooms/backend.js +9 -4
- package/dist-server/server/team-rooms/service.js +1 -1
- package/dist-server/server/team-rooms/testing/fake-rooms-backend.js +10 -4
- package/dist-server/server/vault/fill.js +338 -0
- package/dist-server/server/vault/request.js +178 -0
- package/dist-server/server/vault/routes.js +14 -2
- package/dist-server/server/vault/runtime.js +27 -3
- package/dist-server/server/vault/store.js +60 -5
- package/dist-server/server/vps-computer.js +12 -30
- package/dist-server/server/watch-along/budget.js +11 -3
- package/dist-server/server/watch-along/live.js +4 -2
- package/dist-server/shared/engine-tiers.js +23 -1
- package/dist-server/shared/provider-accounts.js +5 -3
- package/dist-server/shared/subscription-bots.js +14 -6
- package/dist-server/shared/vault-api-providers.js +48 -0
- package/dist-server/shared/vault-csv.js +62 -14
- package/dist-server/shared/vault.js +20 -2
- package/dist-server/vps-container-mcp.js +3 -1
- package/package.json +1 -1
- package/dist/assets/channel-DhsCc8Nd.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-B5p2N9qd.js +0 -8
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { writeFileAtomic } from "./atomic.js";
|
|
9
|
+
import { isPlaceholderText } from "./paw/fill.js";
|
|
9
10
|
export const ABOUT_ME_SIDES = ["atomic", "paw", "nexus"];
|
|
10
11
|
const norm = (text) => text.replace(/\r\n?/g, "\n").trim();
|
|
11
12
|
/** One pass. `now` holds each reachable side's text (a side left out is
|
|
@@ -14,19 +15,29 @@ const norm = (text) => text.replace(/\r\n?/g, "\n").trim();
|
|
|
14
15
|
* edit reaches every other side. Two different edits, or a side seen for
|
|
15
16
|
* the first time that disagrees with the rest, are a conflict: nothing is
|
|
16
17
|
* written. `legacy` (an ICM "Who I am") fills everything when all sides are
|
|
17
|
-
* empty, and a profile still holding it counts as empty.
|
|
18
|
+
* empty, and a profile still holding it counts as empty. A PAW template
|
|
19
|
+
* placeholder ("(fill in)" scaffolding) also counts as empty: it is starter
|
|
20
|
+
* text Atomic wrote itself, never the person's words. A profile the person
|
|
21
|
+
* emptied in Settings since the last pass is a deliberate clear, and it
|
|
22
|
+
* reaches the other sides the way an edit does. Only the profile clears: a
|
|
23
|
+
* PAW file or Nexus read that comes back blank may be a missing folder or a
|
|
24
|
+
* bad response, so it is refilled and never wipes the rest. */
|
|
18
25
|
export function reconcileAboutMe(now, seen, legacy = "") {
|
|
19
26
|
const sides = ABOUT_ME_SIDES.filter((side) => now[side] !== undefined);
|
|
20
|
-
const text = (side) =>
|
|
27
|
+
const text = (side) => {
|
|
28
|
+
const value = side === "atomic" && norm(legacy) && norm(now.atomic) === norm(legacy) ? "" : norm(now[side]);
|
|
29
|
+
return isPlaceholderText(value) ? "" : value;
|
|
30
|
+
};
|
|
21
31
|
const filled = sides.filter((side) => text(side));
|
|
32
|
+
const cleared = sides.filter((side) => side === "atomic" && !norm(now[side]) && norm(seen[side] ?? ""));
|
|
22
33
|
const edited = filled.filter((side) => text(side) !== norm(seen[side] ?? ""));
|
|
23
34
|
const kept = filled.filter((side) => !edited.includes(side));
|
|
24
35
|
const firstContact = edited.some((side) => seen[side] === undefined) && kept.some((side) => text(side) !== text(edited[0]));
|
|
25
|
-
if (new Set(edited.map(text)).size > 1 || firstContact)
|
|
36
|
+
if (new Set(edited.map(text)).size > 1 || firstContact || (cleared.length > 0 && edited.length > 0))
|
|
26
37
|
return { writes: {}, seen, conflict: filled };
|
|
27
38
|
const source = edited[0] ?? kept[0];
|
|
28
|
-
const target = source ? now[source] : legacy;
|
|
29
|
-
if (!norm(target))
|
|
39
|
+
const target = cleared.length ? "" : source ? now[source] : legacy;
|
|
40
|
+
if (!norm(target) && !cleared.length)
|
|
30
41
|
return { writes: {}, seen, conflict: [] };
|
|
31
42
|
const writes = {};
|
|
32
43
|
for (const side of sides)
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// - X11 desktop with Chrome + Ghostty; passwordless sudo; node 24.
|
|
12
12
|
// - the dedicated IP rotates across archive/resume — never persist it.
|
|
13
13
|
import { createHash } from "node:crypto";
|
|
14
|
+
import { readBodyCapped } from "./capped-body.js";
|
|
14
15
|
import { DATA_DIR } from "./config.js";
|
|
15
16
|
import { loadEnvironmentId } from "./environment.js";
|
|
16
17
|
import { adoptResolvedBox, beginBoxCreate, boxCreateRecoverySnapshot, discardBoxCreate, rememberCreatedBox, resolveBoxCreate, retireDeletedBoxCreate, } from "./box-create-idempotency.js";
|
|
@@ -1235,33 +1236,36 @@ const SHOT_CMD = panelShotCommand();
|
|
|
1235
1236
|
// response cannot exhaust memory.
|
|
1236
1237
|
const MAX_FRAME_BYTES = 8 * 1024 * 1024;
|
|
1237
1238
|
const FRAME_TOO_LARGE = "the box frame exceeds the 8 MB limit";
|
|
1239
|
+
// The files fallback wraps the frame in base64 (4/3) plus a small envelope.
|
|
1240
|
+
const MAX_FRAME_JSON_BYTES = Math.ceil(MAX_FRAME_BYTES / 3) * 4 + 4096;
|
|
1238
1241
|
/** Read a file off the box as base64 — raw artifact bytes when the API
|
|
1239
1242
|
* supports it (33% less transfer, no JSON envelope), else the files API. */
|
|
1240
1243
|
async function readFileBase64(cfg, boxId, path, signal) {
|
|
1241
|
-
let bytes
|
|
1242
|
-
let tooLarge = false;
|
|
1244
|
+
let bytes;
|
|
1243
1245
|
try {
|
|
1244
1246
|
const res = await boxFetch(cfg, `/boxes/${boxId}/artifacts?path=${encodeURIComponent(path)}`, { signal });
|
|
1245
|
-
if (res.ok)
|
|
1246
|
-
|
|
1247
|
-
if (declaredLength !== null && Number(declaredLength) > MAX_FRAME_BYTES)
|
|
1248
|
-
tooLarge = true;
|
|
1249
|
-
else
|
|
1250
|
-
bytes = Buffer.from(await res.arrayBuffer());
|
|
1251
|
-
}
|
|
1247
|
+
if (res.ok)
|
|
1248
|
+
bytes = await readBodyCapped(res, MAX_FRAME_BYTES);
|
|
1252
1249
|
}
|
|
1253
1250
|
catch {
|
|
1254
|
-
/* fall through */
|
|
1251
|
+
/* fall through to the files API */
|
|
1255
1252
|
}
|
|
1256
|
-
if (
|
|
1253
|
+
if (bytes === null)
|
|
1257
1254
|
throw new Error(FRAME_TOO_LARGE);
|
|
1258
|
-
}
|
|
1259
1255
|
if (bytes?.length)
|
|
1260
1256
|
return bytes.toString("base64");
|
|
1261
1257
|
signal?.throwIfAborted();
|
|
1262
|
-
const
|
|
1258
|
+
const res = await boxFetch(cfg, `/boxes/${boxId}/files?path=${encodeURIComponent(path)}&encoding=base64`, { signal });
|
|
1259
|
+
const raw = await readBodyCapped(res, MAX_FRAME_JSON_BYTES).catch(() => undefined);
|
|
1260
|
+
if (raw === null)
|
|
1261
|
+
throw new Error(FRAME_TOO_LARGE);
|
|
1262
|
+
let body = null;
|
|
1263
|
+
try {
|
|
1264
|
+
body = JSON.parse(raw?.toString("utf8") ?? "");
|
|
1265
|
+
}
|
|
1266
|
+
catch { /* unusable envelope */ }
|
|
1263
1267
|
const content = body?.content;
|
|
1264
|
-
if (ok && typeof content === "string" && content) {
|
|
1268
|
+
if (res.ok && body?.ok !== false && typeof content === "string" && content) {
|
|
1265
1269
|
if (Buffer.byteLength(content, "base64") > MAX_FRAME_BYTES)
|
|
1266
1270
|
throw new Error(FRAME_TOO_LARGE);
|
|
1267
1271
|
return content;
|
|
@@ -15,6 +15,7 @@ import { homedir, tmpdir } from "node:os";
|
|
|
15
15
|
import { delimiter, dirname, join, resolve } from "node:path";
|
|
16
16
|
import { sweepRoot } from "../electron/bundle-process-sweep.mjs";
|
|
17
17
|
import { writeFileAtomic } from "./atomic.js";
|
|
18
|
+
import { readBodyCapped } from "./capped-body.js";
|
|
18
19
|
import { DATA_DIR } from "./config.js";
|
|
19
20
|
import { browserBundlePaths } from "./browser-bundle-release.js";
|
|
20
21
|
import { browserRuntimeEnv } from "./browser-runtime.js";
|
|
@@ -298,32 +299,9 @@ export async function installAgentBrowserBinary(options = {}) {
|
|
|
298
299
|
const declared = Number(response.headers.get("content-length") ?? NaN);
|
|
299
300
|
if (Number.isFinite(declared) && declared !== asset.bytes)
|
|
300
301
|
throw new Error("the agent-browser download did not match its pinned size; nothing was installed");
|
|
301
|
-
// Stream, never buffer whole: a body past the pin is cut off mid-flight
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if (response.body) {
|
|
305
|
-
try {
|
|
306
|
-
for await (const chunk of response.body) {
|
|
307
|
-
chunks.push(chunk);
|
|
308
|
-
received += chunk.byteLength;
|
|
309
|
-
if (received > asset.bytes) {
|
|
310
|
-
controller.abort();
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
catch (error) {
|
|
316
|
-
// Only the abort we asked for is swallowed; the size check reports it.
|
|
317
|
-
if (received <= asset.bytes)
|
|
318
|
-
throw error;
|
|
319
|
-
}
|
|
320
|
-
body = Buffer.concat(chunks);
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
body = Buffer.from(await response.arrayBuffer());
|
|
324
|
-
if (body.length > asset.bytes)
|
|
325
|
-
controller.abort();
|
|
326
|
-
}
|
|
302
|
+
// Stream, never buffer whole: a body past the pin is cut off mid-flight,
|
|
303
|
+
// and the empty buffer it leaves behind fails the exact-size check below.
|
|
304
|
+
body = (await readBodyCapped(response, asset.bytes)) ?? Buffer.alloc(0);
|
|
327
305
|
}
|
|
328
306
|
finally {
|
|
329
307
|
clearTimeout(timer);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { killCliTree, spawnCli } from "./procs.js";
|
|
2
|
+
import { unlockedVault, vaultFillStateFile } from "./vault/runtime.js";
|
|
3
|
+
import { VAULT_FILL_TOOL, VaultFill, withVaultFillTool } from "./vault/fill.js";
|
|
2
4
|
import { DEFAULT_BROWSER_RESULT_BUDGET, shapeBrowserToolResult, slimBrowserToolList, stripHarnessOwnedArguments } from "./browser-tool-shape.js";
|
|
5
|
+
import { flagHiddenAiText } from "./hidden-ai-text.js";
|
|
3
6
|
export const BROWSER_CONTROL_REFUSAL = "Browser tools are paused while a person controls this browser. Wait for them to hand control back; do not try another browser or execution tool.";
|
|
4
7
|
const MAX_REQUEST_BYTES = 1_048_576;
|
|
5
8
|
const MAX_RESPONSE_BYTES = 16_777_216;
|
|
@@ -243,7 +246,19 @@ export class BrowserRuntime {
|
|
|
243
246
|
this.changed(gate);
|
|
244
247
|
}
|
|
245
248
|
}
|
|
246
|
-
|
|
249
|
+
/** Vault login fill and the guards that follow it, per browser session. */
|
|
250
|
+
vaultFill = new VaultFill(vaultFillStateFile);
|
|
251
|
+
/** The unlocked vault. A field so a verification run can supply its own. */
|
|
252
|
+
vaultAccess = unlockedVault;
|
|
253
|
+
/** A transcript preview frame. None is taken once a Vault password was
|
|
254
|
+
* filled: a stored frame cannot be checked or recalled the way a tool
|
|
255
|
+
* result can. The live viewer still shows the person the page. */
|
|
256
|
+
frame(session, capture) {
|
|
257
|
+
if (this.vaultFill.tainted(session))
|
|
258
|
+
throw new Error("Preview frames are paused in this browser because a Vault password was filled.");
|
|
259
|
+
return capture();
|
|
260
|
+
}
|
|
261
|
+
async agentRpc(session, spec, method, params, beforeDispatch, botId) {
|
|
247
262
|
if (method !== "tools/list" && method !== "tools/call")
|
|
248
263
|
throw new Error("Unsupported browser method.");
|
|
249
264
|
// tools/list bypasses withAgentAction (a human may hold control), so it
|
|
@@ -278,12 +293,31 @@ export class BrowserRuntime {
|
|
|
278
293
|
try {
|
|
279
294
|
// The model sees slimmed schemas and text-only, bounded results; the
|
|
280
295
|
// launch/session parameters OMB owns never reach the engine from a call.
|
|
281
|
-
|
|
296
|
+
let request = method === "tools/call" ? stripHarnessOwnedArguments(params) : params;
|
|
297
|
+
const toolName = request && typeof request === "object" && typeof request.name === "string" ? request.name : undefined;
|
|
298
|
+
// Atomic's own calls on the engine, in this session, unseen by the bot.
|
|
299
|
+
const engine = (name, args) => entry.client.rpc("tools/call", { name, arguments: args });
|
|
300
|
+
if (method === "tools/call" && toolName) {
|
|
301
|
+
const given = request.arguments;
|
|
302
|
+
const args = given && typeof given === "object" && !Array.isArray(given) ? given : {};
|
|
303
|
+
if (toolName === VAULT_FILL_TOOL) {
|
|
304
|
+
const vault = this.vaultAccess();
|
|
305
|
+
return this.vaultFill.fill(session, vault && botId ? { ...vault, botId } : null, args, engine);
|
|
306
|
+
}
|
|
307
|
+
const guarded = this.vaultFill.before(session, toolName, args);
|
|
308
|
+
if ("refuse" in guarded)
|
|
309
|
+
return guarded.refuse;
|
|
310
|
+
const held = await this.vaultFill.guard(session, toolName, guarded.args, engine);
|
|
311
|
+
if (held)
|
|
312
|
+
return held;
|
|
313
|
+
request = { ...request, arguments: guarded.args };
|
|
314
|
+
}
|
|
282
315
|
let result = await entry.client.rpc(method, request);
|
|
283
316
|
beforeDispatch?.(); // A turn revoked while the tool ran receives no result.
|
|
284
317
|
if (method === "tools/list")
|
|
285
|
-
return slimBrowserToolList(result);
|
|
286
|
-
|
|
318
|
+
return withVaultFillTool(slimBrowserToolList(result));
|
|
319
|
+
if (toolName === "agent_browser_close")
|
|
320
|
+
this.vaultFill.clear(session);
|
|
287
321
|
if (toolName === "agent_browser_open" && result && typeof result === "object" &&
|
|
288
322
|
result.isError !== true) {
|
|
289
323
|
// Navigation alone does not prove that the requested page loaded.
|
|
@@ -320,7 +354,8 @@ export class BrowserRuntime {
|
|
|
320
354
|
...(!observed ? { isError: true } : {}),
|
|
321
355
|
};
|
|
322
356
|
}
|
|
323
|
-
|
|
357
|
+
// Text on the page written for an AI is named at the top of the result (server/hidden-ai-text.ts).
|
|
358
|
+
return this.vaultFill.after(session, flagHiddenAiText(shapeBrowserToolResult(this.vaultFill.scrub(session, result), { toolName, budget: this.options.resultBudget })), engine);
|
|
324
359
|
}
|
|
325
360
|
catch (error) {
|
|
326
361
|
// An MCP timeout cannot prove the independent daemon stopped an
|
|
@@ -429,6 +464,7 @@ export class BrowserRuntime {
|
|
|
429
464
|
this.changed(gate);
|
|
430
465
|
try {
|
|
431
466
|
await closeBrowser();
|
|
467
|
+
this.vaultFill.clear(session);
|
|
432
468
|
await this.clients.get(session)?.client.stop();
|
|
433
469
|
// A tools/list admitted before closing set in can register a client
|
|
434
470
|
// while that stop awaits; registration is synchronous, so one re-check
|
|
@@ -191,11 +191,12 @@ export class CalendarCallManager {
|
|
|
191
191
|
durationMinutes: patch.durationMinutes ?? previous.durationMinutes,
|
|
192
192
|
attachments: patch.attachments ?? previous.attachments,
|
|
193
193
|
}, this.botExists);
|
|
194
|
+
const scheduleChanged = JSON.stringify(clean.schedule) !== JSON.stringify(previous.schedule);
|
|
194
195
|
const updated = {
|
|
195
196
|
id: previous.id,
|
|
196
197
|
...clean,
|
|
197
198
|
roomId: patch.botIds && !sameRoster(clean.botIds, previous.botIds) ? undefined : previous.roomId,
|
|
198
|
-
nextRunAt: this.initialOccurrence(clean.schedule, this.now()),
|
|
199
|
+
nextRunAt: scheduleChanged ? this.initialOccurrence(clean.schedule, this.now()) : previous.nextRunAt,
|
|
199
200
|
createdAt: previous.createdAt,
|
|
200
201
|
updatedAt: this.now(),
|
|
201
202
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Read a fetch Response body into a Buffer while never holding more than
|
|
2
|
+
* `maxBytes` of it: a longer body is cut off mid-flight and reported as null,
|
|
3
|
+
* so one hostile or broken response cannot exhaust server memory. A declared
|
|
4
|
+
* content-length over the cap skips the read entirely. */
|
|
5
|
+
export async function readBodyCapped(res, maxBytes) {
|
|
6
|
+
const declared = Number(res.headers.get("content-length") ?? NaN);
|
|
7
|
+
if (Number.isFinite(declared) && declared > maxBytes) {
|
|
8
|
+
await res.body?.cancel().catch(() => undefined);
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (!res.body) {
|
|
12
|
+
const bytes = Buffer.from(await res.arrayBuffer());
|
|
13
|
+
return bytes.length > maxBytes ? null : bytes;
|
|
14
|
+
}
|
|
15
|
+
const chunks = [];
|
|
16
|
+
let received = 0;
|
|
17
|
+
// returning out of for await cancels the stream, so nothing past the cap
|
|
18
|
+
// is pulled off the socket, let alone buffered
|
|
19
|
+
for await (const chunk of res.body) {
|
|
20
|
+
received += chunk.byteLength;
|
|
21
|
+
if (received > maxBytes)
|
|
22
|
+
return null;
|
|
23
|
+
chunks.push(chunk);
|
|
24
|
+
}
|
|
25
|
+
return Buffer.concat(chunks);
|
|
26
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// One default for Chibi on every install (Erick, 2026-11-13): Automatic, the
|
|
2
|
+
// Plata class, starting on Claude Sonnet 5.5 (CHIBI_DEFAULT_RUNG). Installs
|
|
3
|
+
// had drifted apart, so an update puts every Chibi back on it once per
|
|
4
|
+
// CHIBI_DEFAULTS_VERSION, whatever it was set to. What a person changes
|
|
5
|
+
// afterwards holds until the version is raised.
|
|
6
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { CHIBI_DEFAULTS_VERSION, CHIBI_DEFAULT_RUNG } from "../shared/engine-tiers.js";
|
|
9
|
+
import { writeFileAtomic } from "./atomic.js";
|
|
10
|
+
/** Where the version last applied on this install is kept. */
|
|
11
|
+
export const CHIBI_DEFAULTS_FILE = "chibi-defaults.json";
|
|
12
|
+
/** Where to look when the default model's account is not here: its own
|
|
13
|
+
* class first, then the class below (the nearest score), then above, then
|
|
14
|
+
* the lowest, where graded local models sit. */
|
|
15
|
+
const NEAREST_CLASSES = ["Plata", "Reposado", "Mezcal", "Añejo"];
|
|
16
|
+
/** The model Chibi is put on. Its default (CHIBI_DEFAULT_RUNG) on a ready,
|
|
17
|
+
* allowed account that lists it. An install without one (Gemini through
|
|
18
|
+
* Google Workspace only, ChatGPT only, one API key, a local model) gets the
|
|
19
|
+
* model it does have that grades nearest: `models` in ladder order, class
|
|
20
|
+
* by class. Undefined only when nothing graded is ready; the caller then
|
|
21
|
+
* keeps or picks any working engine, so a bot is never without a model. */
|
|
22
|
+
export function chibiDefaultSelection(engines, refused, models = []) {
|
|
23
|
+
const ready = engines.filter((engine) => engine.instanceId !== "atomic-engine" && engine.snapshot.state === "available" &&
|
|
24
|
+
engine.snapshot.authenticated !== false && refused(engine) === undefined);
|
|
25
|
+
const on = (driverKind, model) => {
|
|
26
|
+
for (const engine of ready) {
|
|
27
|
+
if (engine.driverKind !== driverKind)
|
|
28
|
+
continue;
|
|
29
|
+
const option = engine.models.options.find((candidate) => candidate.id.toLowerCase() === model.toLowerCase());
|
|
30
|
+
if (option)
|
|
31
|
+
return { instanceId: engine.instanceId, model: option.id };
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
};
|
|
35
|
+
const preferred = CHIBI_DEFAULT_RUNG.model ? on(CHIBI_DEFAULT_RUNG.engine, CHIBI_DEFAULT_RUNG.model) : undefined;
|
|
36
|
+
if (preferred)
|
|
37
|
+
return preferred;
|
|
38
|
+
for (const modelClass of NEAREST_CLASSES) {
|
|
39
|
+
for (const graded of models) {
|
|
40
|
+
if (graded.modelClass !== modelClass)
|
|
41
|
+
continue;
|
|
42
|
+
for (const run of graded.runs) {
|
|
43
|
+
const selection = on(run.driverKind, run.model);
|
|
44
|
+
if (selection)
|
|
45
|
+
return selection;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
/** config.json's `engineTiers` with one tier back on its defaults: a
|
|
52
|
+
* person's own ladder and class for it dropped, everything else kept (the
|
|
53
|
+
* other tiers, includeFree). Undefined when the tier had neither. */
|
|
54
|
+
export function withoutTierEdits(engineTiers, tier) {
|
|
55
|
+
const part = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
56
|
+
const config = part(engineTiers);
|
|
57
|
+
const { [tier]: ladder, ...ladders } = part(config.ladders);
|
|
58
|
+
const { [tier]: tierClass, ...classes } = part(config.classes);
|
|
59
|
+
if (ladder === undefined && tierClass === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
const { classes: _classes, ...rest } = config;
|
|
62
|
+
return { ...rest, ladders, ...(Object.keys(classes).length ? { classes } : {}) };
|
|
63
|
+
}
|
|
64
|
+
export function appliedChibiDefaults(dataDir) {
|
|
65
|
+
const file = join(dataDir, CHIBI_DEFAULTS_FILE);
|
|
66
|
+
if (!existsSync(file))
|
|
67
|
+
return 0;
|
|
68
|
+
try {
|
|
69
|
+
const version = JSON.parse(readFileSync(file, "utf8")).version;
|
|
70
|
+
return typeof version === "number" && Number.isInteger(version) ? version : 0;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Put this install's Chibi on the default, once per version: the
|
|
77
|
+
* Orchestrator tier back on its own class and generated ladder, Chibi on
|
|
78
|
+
* Automatic and (when its account is here) the default model, and every
|
|
79
|
+
* thread of its following it again. True when it applied. */
|
|
80
|
+
export async function applyChibiDefaults(deps) {
|
|
81
|
+
const chibi = deps.store.builtinChibi();
|
|
82
|
+
if (!chibi || appliedChibiDefaults(deps.dataDir) >= CHIBI_DEFAULTS_VERSION)
|
|
83
|
+
return false;
|
|
84
|
+
const engineTiers = withoutTierEdits(deps.cfg.engineTiers, "orchestrator");
|
|
85
|
+
if (engineTiers) {
|
|
86
|
+
deps.saveConfig({ engineTiers });
|
|
87
|
+
deps.cfg.engineTiers = engineTiers;
|
|
88
|
+
}
|
|
89
|
+
const selection = chibiDefaultSelection(await deps.engines(), deps.refused, deps.models());
|
|
90
|
+
deps.store.setEngineTier(chibi.id, { enginePin: false, modelClass: null, ...(selection ? { modelSelection: selection } : {}) });
|
|
91
|
+
for (const task of chibi.tasks ?? [])
|
|
92
|
+
deps.store.setThreadEngineClass(chibi.id, task.threadId, "tier");
|
|
93
|
+
writeFileAtomic(join(deps.dataDir, CHIBI_DEFAULTS_FILE), `${JSON.stringify({ version: CHIBI_DEFAULTS_VERSION, appliedAt: new Date().toISOString() })}\n`);
|
|
94
|
+
console.log(`[chibi] put on its default: Automatic, ${CHIBI_DEFAULT_RUNG.modelClass}, ${selection ? `${selection.instanceId}/${selection.model}` : "the model it had (no graded model is ready here)"}`);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
@@ -10,6 +10,10 @@ export const CLI_LOGINS = Object.freeze({
|
|
|
10
10
|
grokAgent: { args: ["login", "--device-auth"], hosts: ["x.ai", "grok.com"] },
|
|
11
11
|
cursorAgent: { args: ["login"], hosts: ["cursor.com", "cursor.sh"], env: { NO_OPEN_BROWSER: "1" } },
|
|
12
12
|
kimiAgent: { args: ["login"], hosts: ["kimi.com", "moonshot.cn", "moonshot.ai"] },
|
|
13
|
+
// Hermes signs in to Nous Portal with the person's Nous account (their
|
|
14
|
+
// subscription), where the person installed Hermes themselves. Only the
|
|
15
|
+
// sign-in: `hermes portal` would also change Hermes' model and tools.
|
|
16
|
+
hermesAgent: { args: ["auth", "add", "nous", "--type", "oauth", "--no-browser"], hosts: ["nousresearch.com"] },
|
|
13
17
|
});
|
|
14
18
|
const MAX_OUTPUT = 32 * 1024;
|
|
15
19
|
const FLOW_TTL_MS = 15 * 60_000;
|
|
@@ -134,8 +134,6 @@ export function finalizeConnectionCapPick(input) {
|
|
|
134
134
|
return { line: transientThrottleStopLine(input.currentLabel), category: "failover_exhausted" };
|
|
135
135
|
}
|
|
136
136
|
const { choice } = input;
|
|
137
|
-
if (!choice && input.fallback)
|
|
138
|
-
return { line: input.subscriptionLine ?? "No engine is available for this turn, so it stopped." };
|
|
139
137
|
if (!choice && input.failureKind === "provider_error")
|
|
140
138
|
return { passthrough: true };
|
|
141
139
|
if (!choice) {
|
|
@@ -17,6 +17,7 @@ import { spawnOptionsFor } from "./spawn-command.js";
|
|
|
17
17
|
import { DATA_DIR } from "./config.js";
|
|
18
18
|
import { SPAWNED_PROXIES } from "./proxy-paths.js";
|
|
19
19
|
import { localVmStartableWhenStopped } from "./local-vm-start.js";
|
|
20
|
+
import { viewerSecretToEnv } from "./local-vm-run.js";
|
|
20
21
|
export { localVmStartableWhenStopped };
|
|
21
22
|
const run = promisify(execFile);
|
|
22
23
|
const SCREENSHOT_STATUS_TTL_MS = 10_000;
|
|
@@ -184,7 +185,7 @@ LABEL ${MANAGED_LABEL}="1" \\
|
|
|
184
185
|
${IMAGE_LAYER_LABEL}="${IMAGE_LAYER_VERSION}"
|
|
185
186
|
`;
|
|
186
187
|
}
|
|
187
|
-
async function sh(cmd, args, timeout = 8000) {
|
|
188
|
+
async function sh(cmd, args, timeout = 8000, secrets) {
|
|
188
189
|
const resolved = resolveCliSpawn(cmd, args);
|
|
189
190
|
const { stdout } = await run(resolved.command, resolved.args, spawnOptionsFor(resolved, {
|
|
190
191
|
timeout,
|
|
@@ -193,8 +194,8 @@ async function sh(cmd, args, timeout = 8000) {
|
|
|
193
194
|
// Every docker call on a Mac goes to Colima's socket, whatever docker
|
|
194
195
|
// context Docker Desktop may have left active.
|
|
195
196
|
env: cmd === "docker"
|
|
196
|
-
? dockerEnvForColima({ ...process.env, PATH: augmentedPath() })
|
|
197
|
-
: { ...process.env, PATH: augmentedPath() },
|
|
197
|
+
? dockerEnvForColima({ ...process.env, ...secrets, PATH: augmentedPath() })
|
|
198
|
+
: { ...process.env, ...secrets, PATH: augmentedPath() },
|
|
198
199
|
}));
|
|
199
200
|
return { stdout };
|
|
200
201
|
}
|
|
@@ -805,12 +806,11 @@ export async function containerComputerAction(action, runner = sh, platform = pr
|
|
|
805
806
|
await ensureVmWorkspace(platform, target);
|
|
806
807
|
if (action === "remove")
|
|
807
808
|
await rescueFirefoxProfile(runtime, runner, platform, target);
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
await runner(runtime, args, 2 * 60_000);
|
|
809
|
+
const runArgs = () => containerRunArgs(runtime, randomBytes(6).toString("base64url"), target);
|
|
810
|
+
const launch = action === "run" ? viewerSecretToEnv(runtime, runArgs()) : null;
|
|
811
|
+
const removal = ["rm", runtime === "container" ? "--force" : "-f", target.containerName];
|
|
812
|
+
const args = launch?.args ?? (action === "remove" ? removal : [action, target.containerName]);
|
|
813
|
+
await runner(runtime, args, 2 * 60_000, launch?.env);
|
|
814
814
|
}
|
|
815
815
|
return containerComputerStatus(runner, platform, target);
|
|
816
816
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// Nothing here reads the environment or holds state of its own. The caller
|
|
8
8
|
// passes a ToolCallContext, and the per-turn counters live on it.
|
|
9
|
-
import {
|
|
9
|
+
import { callCredentialTool } from "./agents-credential.js";
|
|
10
10
|
import { normalizeCronSchedule } from "../../shared/routine-schedule.js";
|
|
11
11
|
import { peerRecallSpeaker } from "../peer-provenance.js";
|
|
12
12
|
import { peerName } from "../peer-roster.js";
|
|
@@ -835,8 +835,8 @@ export async function callTool(name, args, context) {
|
|
|
835
835
|
const message = typeof r.message === "string" ? r.message : `Updated room ${roomId}.`;
|
|
836
836
|
return { text: message };
|
|
837
837
|
}
|
|
838
|
-
if (name === "request_credential")
|
|
839
|
-
return
|
|
838
|
+
if (name === "request_credential" || name.startsWith("vault_"))
|
|
839
|
+
return callCredentialTool(name, args, BOT_ID, THREAD_ID, api);
|
|
840
840
|
if (name === "list_routines") {
|
|
841
841
|
const query = new URLSearchParams({ fromBotId: BOT_ID, fromThreadId: THREAD_ID });
|
|
842
842
|
const r = await api(`/api/internal/routines?${query.toString()}`);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// turn. It is pinned byte for byte, and its size budgeted, by
|
|
11
11
|
// agents-catalog-wire.test.ts: change a description or a schema on purpose,
|
|
12
12
|
// then update the goldens there.
|
|
13
|
-
import { credentialTool } from "./agents-credential.js";
|
|
13
|
+
import { credentialTool, vaultTools } from "./agents-credential.js";
|
|
14
14
|
import { PRIVATE_BOT_HIDDEN_TOOLS, agentToolAnnotations } from "../agent-tool-policy.js";
|
|
15
15
|
/** The profile a spawned proxy was given. Everything is off unless the
|
|
16
16
|
* harness says "1". */
|
|
@@ -450,7 +450,7 @@ const toolDefinitions = (externalRuntime) => [
|
|
|
450
450
|
required: ["room_id", "action"],
|
|
451
451
|
},
|
|
452
452
|
},
|
|
453
|
-
credentialTool,
|
|
453
|
+
credentialTool, ...vaultTools,
|
|
454
454
|
{
|
|
455
455
|
name: "marketplace_search",
|
|
456
456
|
description: "Find an app or service the person wants connected in Atomic's Marketplace: official servers Atomic connects, and official apps through their Claude account. Then call open_marketplace. Never offer to build a connection or a community server.",
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { CREDENTIAL_TARGETS, isCredentialTargetId } from "../../shared/credential-request.js";
|
|
2
|
+
import { callVaultTool, vaultTools } from "./agents-vault.js";
|
|
3
|
+
export { vaultTools };
|
|
4
|
+
/** request_credential and the Vault tools: every way a bot reaches a secret it never sees. */
|
|
5
|
+
export function callCredentialTool(name, args, BOT_ID, THREAD_ID, api) {
|
|
6
|
+
return name === "request_credential" ? requestCredential(args, BOT_ID, THREAD_ID, api) : callVaultTool(args, api);
|
|
7
|
+
}
|
|
2
8
|
export async function requestCredential(args, BOT_ID, THREAD_ID, api) {
|
|
3
9
|
const credentialId = args.credential_id;
|
|
4
10
|
if (!isCredentialTargetId(credentialId)) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export async function callVaultTool(args, api) {
|
|
2
|
+
try {
|
|
3
|
+
if (args.item_id === undefined && args.url === undefined) {
|
|
4
|
+
const r = await api("/api/internal/vault/keys");
|
|
5
|
+
const items = Array.isArray(r.items) ? r.items : [];
|
|
6
|
+
const logins = Array.isArray(r.logins) ? r.logins : [];
|
|
7
|
+
if (!items.length && !logins.length) {
|
|
8
|
+
return { text: "Nothing in the Vault is shared with you. The person can add an API key or a login in Settings > Vault and tick your name under Allowed bots." };
|
|
9
|
+
}
|
|
10
|
+
return { text: JSON.stringify({ apiKeys: items, logins, howToUseLogins: "Open the login's website in the browser, then call the browser tool vault_fill_login with its id." }, null, 2) };
|
|
11
|
+
}
|
|
12
|
+
const r = await api("/api/internal/vault/request", { method: "POST", body: JSON.stringify(args) });
|
|
13
|
+
return { text: JSON.stringify(r, null, 2) };
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
return { text: error instanceof Error ? error.message : "Vault could not complete the request.", isError: true };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export const vaultTools = [
|
|
20
|
+
{
|
|
21
|
+
name: "vault_request",
|
|
22
|
+
description: "Use an API key from the person's Atomic Vault without seeing it. No arguments: list the keys shared with you (id, name, allowed HTTPS addresses, header). With item_id and url: Atomic sends that request and adds the key header itself, so never set it. Text comes back; other files are saved and their path returned. Check here before asking for an API key.",
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: {
|
|
26
|
+
item_id: { type: "string" },
|
|
27
|
+
url: { type: "string", description: "https:// endpoint at one of the item's addresses." },
|
|
28
|
+
method: { type: "string", enum: ["GET", "POST", "PUT", "PATCH", "DELETE"] },
|
|
29
|
+
headers: { type: "object", additionalProperties: { type: "string" } },
|
|
30
|
+
body: { type: "string" },
|
|
31
|
+
save_as: { type: "string", description: "File name for a response to keep." },
|
|
32
|
+
},
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
];
|
|
@@ -64,10 +64,13 @@ export const NO_ANSWER_FAILURE = "The engine ended the turn without an answer.";
|
|
|
64
64
|
function unrecognisedFailure(turn) {
|
|
65
65
|
return { kind: "provider_error", message: turn.lastError ?? NO_ANSWER_FAILURE };
|
|
66
66
|
}
|
|
67
|
-
/** Stops that must not dispatch the request again: cancellation
|
|
68
|
-
* checkpoint whose accepted prompt may already have executed actions
|
|
67
|
+
/** Stops that must not dispatch the request again: cancellation, a broken
|
|
68
|
+
* checkpoint whose accepted prompt may already have executed actions, and a
|
|
69
|
+
* turn ended over failed or denied tool runs (tool_error). Tools are the
|
|
70
|
+
* harness's, not the engine's, so another engine faces the same failure or
|
|
71
|
+
* the same human denial; it must not settle a turn the person refused.
|
|
69
72
|
* The next explicit turn rebuilds that checkpoint from retained history. */
|
|
70
|
-
const NOT_A_PROVIDER_FAILURE = new Set(["interrupted", "cancelled", "invalid_checkpoint"]);
|
|
73
|
+
const NOT_A_PROVIDER_FAILURE = new Set(["interrupted", "cancelled", "invalid_checkpoint", "tool_error"]);
|
|
71
74
|
export class FailoverGate {
|
|
72
75
|
turns = new Map();
|
|
73
76
|
onFailure;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// engine of its ladder that is ready. Everything here is pure except the
|
|
4
4
|
// snapshot cache, so the server wires it to the live registry and the tests
|
|
5
5
|
// drive it with plain candidates.
|
|
6
|
-
import { BOT_TIERS, DEFAULT_LADDERS, DEFAULT_TIER_CLASSES, MODEL_CLASSES, classBelow, isBotTier, toModelClass } from "../shared/engine-tiers.js";
|
|
6
|
+
import { BOT_TIERS, CHIBI_DEFAULT_RUNG, DEFAULT_LADDERS, DEFAULT_TIER_CLASSES, MODEL_CLASSES, classBelow, isBotTier, rungAccounts, toModelClass } from "../shared/engine-tiers.js";
|
|
7
7
|
import { modelHost } from "../shared/engine-choices.js";
|
|
8
8
|
export { DEFAULT_LADDERS };
|
|
9
9
|
import { subscriptionProviderForDriver } from "../shared/subscription-bots.js";
|
|
@@ -82,7 +82,7 @@ export function generateLadders(models, classes) {
|
|
|
82
82
|
const seen = new Set();
|
|
83
83
|
const rungs = classRungs(models, classes[tier]);
|
|
84
84
|
const drivers = TIER_PREFERRED_DRIVERS[tier] ?? [];
|
|
85
|
-
const preferred = [...rungs.filter((entry) => drivers.includes(entry.engine)), ...drivers.map((engine) => ({ engine }))];
|
|
85
|
+
const preferred = [...(tier === "orchestrator" && classes[tier] === CHIBI_DEFAULT_RUNG.modelClass ? [{ ...CHIBI_DEFAULT_RUNG }] : []), ...rungs.filter((entry) => drivers.includes(entry.engine)), ...drivers.map((engine) => ({ engine }))];
|
|
86
86
|
const ordered = [...preferred, ...rungs].filter((entry) => {
|
|
87
87
|
const key = entryKey(entry);
|
|
88
88
|
if (seen.has(key))
|
|
@@ -120,7 +120,7 @@ export function parseLadderEntry(value) {
|
|
|
120
120
|
const modelClass = toModelClass(raw.modelClass) ?? toModelClass(raw.level);
|
|
121
121
|
if (modelClass)
|
|
122
122
|
entry.modelClass = modelClass;
|
|
123
|
-
return entry;
|
|
123
|
+
return raw.anyAccount === true ? { ...entry, anyAccount: true } : entry;
|
|
124
124
|
}
|
|
125
125
|
const entryKey = (entry) => `${entry.engine}\u0000${(entry.model ?? "").toLowerCase()}`;
|
|
126
126
|
/** A ladder as stored, or undefined when the value is not a list. Invalid
|
|
@@ -286,7 +286,7 @@ export function resolveLadder(ladder, stored, context) {
|
|
|
286
286
|
const storedFirst = (a, b) => Number(b.instanceId === stored.instanceId) - Number(a.instanceId === stored.instanceId);
|
|
287
287
|
for (const [step, entry] of ladder.entries()) {
|
|
288
288
|
const matching = context.candidates.filter((candidate) => !keyBased(candidate) && !freeCandidate(candidate) && matchesEngine(entry, candidate));
|
|
289
|
-
for (const candidate of matching.sort(storedFirst)) {
|
|
289
|
+
for (const candidate of rungAccounts(entry, matching.sort(storedFirst), context.refuse)) {
|
|
290
290
|
const band = perTokenModel(candidate, entryModel(entry, candidate)) ? "key" : "subscription";
|
|
291
291
|
(band === "key" ? key : subscription).push({ step, entry, candidate, band, index: context.candidates.indexOf(candidate) });
|
|
292
292
|
}
|
|
@@ -318,10 +318,10 @@ export function resolveLadder(ladder, stored, context) {
|
|
|
318
318
|
key.sort((a, b) => a.step - b.step || storedFirst(a.candidate, b.candidate) || a.index - b.index);
|
|
319
319
|
free.sort((a, b) => a.step - b.step || storedFirst(a.candidate, b.candidate) || a.index - b.index);
|
|
320
320
|
for (const { step, entry, candidate, band } of [...subscription, ...key, ...free]) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
321
|
+
// "paused" names a key kept off this turn by policy alone: a key that could not take it anyway (signed out, resting, refused) keeps its real reason.
|
|
322
|
+
const reason = band === "free" && !context.includeFree ? "free-off"
|
|
323
|
+
: band === "free" && context.clientData ? "client-data"
|
|
324
|
+
: skipReason(entry, candidate, context, step < ladder.length) ?? (band === "key" && context.keyBandPaused ? "paused" : undefined);
|
|
325
325
|
if (reason) {
|
|
326
326
|
skipped.push({ step, instanceId: candidate.instanceId, reason, band });
|
|
327
327
|
continue;
|