@chibitek/chibi 0.1.211 → 0.1.213
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-Dro3aeVy.js → TerminalPanel-mkQO42zG.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-kzAr7vQ8.js → abnfDiagram-O67JEVCF-D_YvZb12.js} +1 -1
- package/dist/assets/{arc-DKMhcYud.js → arc-u7NcCAzn.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-_XDnZ7Jz.js → architectureDiagram-NJMV4G6O-CvoIt_0y.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-D5MoWro9.js → blockDiagram-BEXU5L5S-B0Ry3uOJ.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-CGvTMpGE.js → c4Diagram-YGBWAQC7-DQQBHqDt.js} +1 -1
- package/dist/assets/channel-BG3AR6Y6.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-pjTwr5y0.js → chunk-2Q5K7J3B-B4IxGiPz.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-BR6zkd-l.js → chunk-3FUC2YCW-BxR5i6Mq.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-CfVFFBeH.js → chunk-5VM5RSS4-CqmFQLrB.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-TIoAkccw.js → chunk-GTNCS2PH-C9lKwjYE.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BNFBgzbt.js → chunk-GWA4HPMP-DKAnucqk.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-B_3QFchU.js → chunk-JWPE2WC7-CE4DRhto.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-Cj9q80P-.js → chunk-NETBCI7D-UziBzgi9.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-DFZPGo9K.js → chunk-WEXAMYUT-DVo_P12S.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-CekDrT9T.js → chunk-XXDRQBXY-CBwStBk5.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-C3R6Z4Qe.js → classDiagram-v2-NBCMYWYE-D4xfjrAt.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-C1CKyj0L.js → cose-bilkent-JH36ORCC-DNpZWduJ.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-Deh9QGb0.js → cynefin-OW5HDTMX-CMegK4fD.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-BIlWyG_M.js → cynefinDiagram-VND7K2PF-BBRJHq6u.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-Dx4bWOog.js → dagre-6A5THRUB-BwneJkAI.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-DPxb-FUO.js → diagram-22UHCM2B-p4tq7l1f.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-BLPCNc4m.js → diagram-3UASUU5V-C8BCnB5c.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-DOCbp2Dw.js → diagram-ATOU4E4O-Da-Fc2pA.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-62uSG-tn.js → diagram-CDSNMT55-CH7l4Als.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-De1ZAWVZ.js → diagram-MLGK6HIB-xO-efOVl.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-CIGX9tku.js → diagram-MPIPVDR6-CjWQ4FpH.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-CegjStdk.js → ebnfDiagram-ZINNZB2B-DbyEj47I.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-ClI52Pqm.js → elk-276RUBZZ-B0uak8Gs.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-BQuzjt2-.js → erDiagram-OPXOYQCR-DHYzl46p.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-D1xbKgbB.js → flowDiagram-KWPJA3E3-CjUIIif9.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-CH1jGSZz.js → ganttDiagram-FUAMR5RP-CPjVOkNO.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-BvAUPEmQ.js → gitGraphDiagram-X574FWY7-DnI_xNjh.js} +1 -1
- package/dist/assets/{index-BcXDfnlQ.js → index-C8wABnWu.js} +131 -131
- package/dist/assets/{index-DbkR_erP.js → index-kYL6p_po.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-CyMmMbMv.js → infoDiagram-VRGFBTTK-SXQSkFFT.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-Uw-hE1tO.js → ishikawaDiagram-OU5B5YK6-DF3AQU1D.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-ClEDnNRB.js → journeyDiagram-ZHPQQLJL-IWRv1Evh.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-erx0BEal.js → kanban-definition-PNTS6WVX-BKpuGZmD.js} +1 -1
- package/dist/assets/{linear-CSSxpyL0.js → linear-S9gqQWWc.js} +1 -1
- package/dist/assets/{mermaid.core-n13K6vlC.js → mermaid.core-BHRIdye5.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-BcTEIqpD.js → mindmap-definition-NLK3R4M7-BTD52Pxv.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-CJdsm3en.js → pegDiagram-GJSIUBJH-C91CNvYA.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-C7rk-ash.js → pieDiagram-5QR66LMP-0aP3PVSg.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-BSXOYov0.js → quadrantDiagram-O4NWA36T-CN-CB1dj.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-Cmg_FtZY.js → railroadDiagram-XR7U4H2S-DUwKNVqn.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-B_9aE6Mg.js → requirementDiagram-PLB6GJNP-BwiKCqXR.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-DyxaQPy3.js → sankeyDiagram-IPEJSGJF-DK2nk983.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-D5CJeESq.js → sequenceDiagram-PO4LG4MO-DGQaL2CK.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-9-Q4eosQ.js → sizeCapture-INFHLROL-DjxAs07q.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-jgsHnEQl.js → stateDiagram-v2-GCMORJYK-DfhvmAHx.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-MIVacUbv.js → swimlanes-2SLR337P-g4YraApj.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BnxrvDBt.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-Ch8ins-D.js → timeline-definition-EJHVYXUP-Bh6Ow15M.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-BDwBIuhZ.js → usecaseDiagram-POWQR4AR-wRtBj8_e.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-BiiDxcHO.js → vennDiagram-UO4OBE2U-D4QR4Odj.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-D79CK2__.js → wardleyDiagram-VNRHLVJA-DthL_SDi.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-CI7S0o-6.js → xychartDiagram-PMCCYNJV-CK-QrbHO.js} +1 -1
- package/dist/handbook/atomic-handbook.html +1 -1
- package/dist/index.html +1 -1
- package/dist-server/container-mcp.js +81 -81
- package/dist-server/drivers/agents-proxy.js +83 -84
- package/dist-server/index.js +730 -701
- package/dist-server/openmausbot.js +687 -659
- package/dist-server/pair-cli.js +687 -659
- package/dist-server/server/agents-token-file.js +26 -0
- package/dist-server/server/drivers/acp/core.js +4 -6
- package/dist-server/server/drivers/agents-catalog.js +2 -2
- package/dist-server/server/drivers/chat-mcp-tools.js +1 -21
- package/dist-server/server/drivers/claude.js +69 -66
- package/dist-server/server/drivers/codex.js +4 -3
- package/dist-server/server/drivers/openai-chat.js +1 -1
- package/dist-server/server/drivers/session-allow-key.js +22 -5
- package/dist-server/server/engine-tiers.js +3 -7
- package/dist-server/server/index.js +37 -40
- package/dist-server/server/new-bot-defaults.js +3 -1
- package/dist-server/server/routes/thread-stop.js +15 -2
- package/dist-server/server/surface.js +1 -1
- package/dist-server/vps-container-mcp.js +81 -81
- package/package.json +1 -1
- package/dist/assets/channel-YcZdlysP.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-Dekwo1KL.js +0 -8
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// A spawned proxy's current bearer, on disk. The harness rewrites it every
|
|
2
|
+
// turn; the proxy reads it per call. An ACP engine keeps the proxy process it
|
|
3
|
+
// connected at session/new for the whole pooled session (Hermes skips
|
|
4
|
+
// already-connected MCP names on session/load), so a token carried only in
|
|
5
|
+
// the spawn environment is revoked by turn two and every tool call through
|
|
6
|
+
// that proxy answers INTERNAL_CAPABILITY_EXPIRED until the session idles out.
|
|
7
|
+
// Applies to every turn-scoped proxy (agents, accounts, phone, browser). Same
|
|
8
|
+
// pattern as the Claude driver's hook tokens; never exported in a backup.
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import { mkdirSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { writeFileAtomic } from "./atomic.js";
|
|
13
|
+
import { DATA_DIR } from "./config.js";
|
|
14
|
+
// "agents" keeps its historical bare name so a pooled agents proxy spawned by
|
|
15
|
+
// an older harness build still finds its file after an update.
|
|
16
|
+
export function agentsTokenFile(botId, threadId, dataDir = DATA_DIR, kind = "agents") {
|
|
17
|
+
const digest = createHash("sha256").update(`${botId}\0${threadId}`).digest("hex").slice(0, 24);
|
|
18
|
+
return join(dataDir, "agents-tokens", kind === "agents" ? `${digest}.token` : `${digest}.${kind}.token`);
|
|
19
|
+
}
|
|
20
|
+
/** Writes this turn's token (0600) and returns the path the proxy reads. */
|
|
21
|
+
export function writeAgentsTokenFile(botId, threadId, token, dataDir = DATA_DIR, kind = "agents") {
|
|
22
|
+
const path = agentsTokenFile(botId, threadId, dataDir, kind);
|
|
23
|
+
mkdirSync(join(dataDir, "agents-tokens"), { recursive: true, mode: 0o700 });
|
|
24
|
+
writeFileAtomic(path, token, { mode: 0o600 });
|
|
25
|
+
return path;
|
|
26
|
+
}
|
|
@@ -205,7 +205,6 @@ export function createAcpDriver(support) {
|
|
|
205
205
|
const DRIVER_KIND = support.driverKind;
|
|
206
206
|
const SOURCE = support.nativeSource;
|
|
207
207
|
const decodeConfig = decodeAcpConfig(support.defaultCli);
|
|
208
|
-
const DENY_TIMEOUT_NOTE = "Atomic: nobody answered this permission request in time. Skip this action and finish what you can without it.";
|
|
209
208
|
return {
|
|
210
209
|
driverKind: DRIVER_KIND,
|
|
211
210
|
metadata: {
|
|
@@ -699,11 +698,10 @@ export function createAcpDriver(support) {
|
|
|
699
698
|
approvalScope: current.controlsHost ? "local-computer" : undefined,
|
|
700
699
|
});
|
|
701
700
|
};
|
|
702
|
-
const timer =
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
timer.unref?.();
|
|
701
|
+
const timer = isQuestion
|
|
702
|
+
? setTimeout(() => finish("answer", "timeout"), 15 * 60_000)
|
|
703
|
+
: undefined;
|
|
704
|
+
timer?.unref?.();
|
|
707
705
|
current.asks.set(requestId, finish);
|
|
708
706
|
emit({
|
|
709
707
|
...base(threadId, current.turnId),
|
|
@@ -23,7 +23,7 @@ export function catalogProfileFromEnv(env) {
|
|
|
23
23
|
skillAuthoring: env.OMB_SKILL_AUTHORING_ENABLED === "1",
|
|
24
24
|
sharedComputers: env.OMB_SHARED_COMPUTERS_ENABLED === "1",
|
|
25
25
|
threatScan: env.OMB_THREAT_SCAN_ENABLED === "1",
|
|
26
|
-
botId: env.OMB_BOT_ID ?? "", privateBot: env.OMB_PRIVATE_BOT === "1",
|
|
26
|
+
botId: env.OMB_BOT_ID ?? "", privateBot: env.OMB_PRIVATE_BOT === "1",
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
export const WEEKDAYS = [
|
|
@@ -752,7 +752,7 @@ function adminToolEntry(deferred) {
|
|
|
752
752
|
/** Every tool a profile may call, admin tools written out in full. */
|
|
753
753
|
function profileTools(profile) {
|
|
754
754
|
const ALL_TOOLS = toolDefinitions(profile.externalRuntime);
|
|
755
|
-
const TOOLS = ALL_TOOLS.filter((tool) =>
|
|
755
|
+
const TOOLS = ALL_TOOLS.filter((tool) => profile.threatScan || tool.name !== "threat_scan");
|
|
756
756
|
const AUTHORING_TOOLS = profile.skillAuthoring
|
|
757
757
|
? TOOLS
|
|
758
758
|
: TOOLS.filter((tool) => !SKILL_TOOL_NAMES.has(tool.name));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Per-turn MCP transport for the shared Chat Completions runtime. Approval is
|
|
2
2
|
// owned by the caller; only registered, schema-validated calls reach this file.
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
3
|
import { Ajv } from "ajv";
|
|
5
4
|
import { Ajv2020 } from "ajv/dist/2020.js";
|
|
6
5
|
import formats from "ajv-formats";
|
|
@@ -275,23 +274,7 @@ function boundedText(value) {
|
|
|
275
274
|
* that will not start, advertises tools this runtime cannot use, or breaks
|
|
276
275
|
* during a call is dropped for the rest of the turn, the model is told, and
|
|
277
276
|
* the harness hears (`report`). Atomic's own servers stay all-or-nothing. */
|
|
278
|
-
|
|
279
|
-
* `roots`: absolute, `~/`, or home-relative, with either slash. Substring
|
|
280
|
-
* matching on purpose, so a path inside a shell command counts too. */
|
|
281
|
-
export function namesBlockedPath(args, roots, home = homedir()) {
|
|
282
|
-
const slash = (text) => text.replaceAll("\\", "/").toLowerCase();
|
|
283
|
-
const needles = roots.flatMap((root) => {
|
|
284
|
-
const full = slash(root).replace(/\/+$/, "");
|
|
285
|
-
const base = slash(home).replace(/\/+$/, "");
|
|
286
|
-
return full.startsWith(`${base}/`) ? [full, `~/${full.slice(base.length + 1)}`, full.slice(base.length + 1)] : [full];
|
|
287
|
-
});
|
|
288
|
-
const visit = (value) => typeof value === "string"
|
|
289
|
-
? needles.some((needle) => slash(value).includes(needle))
|
|
290
|
-
: Array.isArray(value) ? value.some(visit)
|
|
291
|
-
: object(value) ? Object.values(value).some(visit) : false;
|
|
292
|
-
return needles.length > 0 && visit(args);
|
|
293
|
-
}
|
|
294
|
-
export async function mountChatTools(integrations, signal, computerUse = false, report = reportMcpFailure, blockedPaths = []) {
|
|
277
|
+
export async function mountChatTools(integrations, signal, computerUse = false, report = reportMcpFailure) {
|
|
295
278
|
const servers = [];
|
|
296
279
|
if (computerUse && integrations?.computer)
|
|
297
280
|
servers.push(["computer", integrations.computer]);
|
|
@@ -438,9 +421,6 @@ export async function mountChatTools(integrations, signal, computerUse = false,
|
|
|
438
421
|
throw new Error(`The "${tool.server}" tools stopped working earlier in this turn and are unavailable now; carry on without them.`);
|
|
439
422
|
if (!object(args) || !tool.schema(args))
|
|
440
423
|
throw new Error("Tool arguments do not match the advertised input schema; use its required fields and types");
|
|
441
|
-
if (namesBlockedPath(args, blockedPaths)) {
|
|
442
|
-
throw new Error("This turn runs on a free model, so the PAW and ICM folders are off limits. Work only from the message itself.");
|
|
443
|
-
}
|
|
444
424
|
};
|
|
445
425
|
return {
|
|
446
426
|
definitions, validate, close,
|
|
@@ -429,7 +429,6 @@ function removePrivateTempDir(filePath) {
|
|
|
429
429
|
return false;
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
const DENY_TIMEOUT_NOTE = "Atomic: nobody answered this permission request in time. Skip this action and finish what you can without it.";
|
|
433
432
|
const QUESTION_TIMEOUT_NOTE = "Atomic: nobody answered in time. Use your best judgment and continue.";
|
|
434
433
|
const DUPLICATE_ASK_ID_NOTE = "Atomic: duplicate ask id — skipping this request.";
|
|
435
434
|
/** The system-source reply for an ask that outlives the turn — used both to
|
|
@@ -493,22 +492,10 @@ export function rtkInputOnAllow(ask, rtk, cwd, rewrite = rtkRewrite) {
|
|
|
493
492
|
return command ? { ...ask.input, command } : undefined;
|
|
494
493
|
}
|
|
495
494
|
export function permissionSocketPath(threadId, botId) {
|
|
496
|
-
//
|
|
497
|
-
//
|
|
498
|
-
//
|
|
499
|
-
//
|
|
500
|
-
// global namespace that is never unlinked, and a reused name races the
|
|
501
|
-
// previous broker's async teardown. Half the tag is a digest of the FULL
|
|
502
|
-
// id so distinct threads get distinct sockets; the tag stays at 8 chars
|
|
503
|
-
// total because the POSIX path already brushes the 104-byte sun_path
|
|
504
|
-
// limit under deep tmp home dirs.
|
|
505
|
-
//
|
|
506
|
-
// botId is folded into the digest too (#1017): the driver's session/broker
|
|
507
|
-
// maps are a single process-wide table keyed on threadId alone, so a
|
|
508
|
-
// delegated child turn whose threadId ever coincides with its still-open
|
|
509
|
-
// parent's (or any other bot's) would otherwise collide on the exact same
|
|
510
|
-
// socket. Namespacing by bot makes that collision structurally impossible
|
|
511
|
-
// regardless of how two turns end up sharing a threadId.
|
|
495
|
+
// The socket tag is a digest of the full thread id (prefixes collide) and
|
|
496
|
+
// botId (#1017: maps are keyed on threadId alone). It stays 8 chars for the
|
|
497
|
+
// 104-byte sun_path limit; Windows named pipes also cannot reuse a name
|
|
498
|
+
// that a previous broker is still tearing down.
|
|
512
499
|
const key = botId ? `${botId}\0${threadId}` : threadId;
|
|
513
500
|
const prefix = threadId.replace(/[^\w-]/g, "").slice(0, 4);
|
|
514
501
|
const digest = createHash("sha256").update(key).digest("hex").slice(0, 4);
|
|
@@ -539,13 +526,20 @@ export function brokerSocketCandidates(threadId, botId) {
|
|
|
539
526
|
export async function createPermissionBroker(opts) {
|
|
540
527
|
const timeoutMs = opts.timeoutMs ?? 15 * 60_000;
|
|
541
528
|
const pending = new Map();
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
529
|
+
let holding = false;
|
|
530
|
+
const holdAsk = (askId) => {
|
|
531
|
+
const p = pending.get(askId);
|
|
532
|
+
if (!p)
|
|
533
|
+
return;
|
|
534
|
+
if (p.timer) {
|
|
535
|
+
clearTimeout(p.timer);
|
|
536
|
+
p.timer = undefined;
|
|
537
|
+
}
|
|
538
|
+
holding = true;
|
|
539
|
+
opts.onHold?.(p.ask);
|
|
540
|
+
};
|
|
541
|
+
// server.close() does not drop open connections. A late ask on a retained
|
|
542
|
+
// proxy must not become a card for a turn the driver already forgot (#211).
|
|
549
543
|
let closed = false;
|
|
550
544
|
let boundPath = opts.socketPaths[0] ?? "";
|
|
551
545
|
const connectionHandler = (conn) => {
|
|
@@ -569,20 +563,15 @@ export async function createPermissionBroker(opts) {
|
|
|
569
563
|
const askId = String(msg.id ?? newId());
|
|
570
564
|
const kind = msg.kind === "question" ? "question" : "permission";
|
|
571
565
|
if (closed) {
|
|
572
|
-
//
|
|
573
|
-
//
|
|
574
|
-
// entry or notify onAsk, but always answer an existing connection:
|
|
575
|
-
// permission-proxy.ts only resolves on an explicit answer (or a
|
|
576
|
-
// connection error/close), so a silent drop would hang the tool.
|
|
566
|
+
// Closed: answer the connection (a silent drop hangs the proxy) and
|
|
567
|
+
// do not open a card.
|
|
577
568
|
try {
|
|
578
569
|
conn.write(JSON.stringify({ t: "answer", id: askId, ...systemEndedReply(kind) }) + "\n");
|
|
579
570
|
}
|
|
580
571
|
catch { }
|
|
581
572
|
continue;
|
|
582
573
|
}
|
|
583
|
-
//
|
|
584
|
-
// turns. Late/background asks must still fail closed without opening
|
|
585
|
-
// a card for a turn that has already settled.
|
|
574
|
+
// Between turns, late asks fail closed without opening a card.
|
|
586
575
|
if (opts.isActive && !opts.isActive()) {
|
|
587
576
|
try {
|
|
588
577
|
conn.write(JSON.stringify({ t: "answer", id: askId, ...systemEndedReply(kind) }) + "\n");
|
|
@@ -590,13 +579,8 @@ export async function createPermissionBroker(opts) {
|
|
|
590
579
|
catch { }
|
|
591
580
|
continue;
|
|
592
581
|
}
|
|
593
|
-
//
|
|
594
|
-
//
|
|
595
|
-
// (permission-proxy mints a fresh randomUUID per ask) — would
|
|
596
|
-
// otherwise let the second `pending.set` silently overwrite the
|
|
597
|
-
// first, orphaning it as an unanswerable card once the first
|
|
598
|
-
// resolves and deletes the shared key. Reject before either ask
|
|
599
|
-
// becomes visible to onAsk.
|
|
582
|
+
// Duplicate ask ids would overwrite the first pending entry and
|
|
583
|
+
// orphan its card. Reject before onAsk (proxy mints a fresh id).
|
|
600
584
|
if (pending.has(askId)) {
|
|
601
585
|
// askId is client-controlled; JSON.stringify escapes newlines and
|
|
602
586
|
// control characters so it can't corrupt the log line or terminal.
|
|
@@ -627,9 +611,11 @@ export async function createPermissionBroker(opts) {
|
|
|
627
611
|
continue;
|
|
628
612
|
}
|
|
629
613
|
const finish = (behavior, message, source, always) => {
|
|
614
|
+
const current = pending.get(askId);
|
|
630
615
|
if (!pending.delete(askId))
|
|
631
616
|
return;
|
|
632
|
-
|
|
617
|
+
if (current?.timer)
|
|
618
|
+
clearTimeout(current.timer);
|
|
633
619
|
// The CLI never hands the proxy its suggested rules, so `always`
|
|
634
620
|
// alone would allow just this once: the broker keeps the allow.
|
|
635
621
|
if (always && behavior === "allow" && source === "user" && sessionKey)
|
|
@@ -646,19 +632,23 @@ export async function createPermissionBroker(opts) {
|
|
|
646
632
|
catch { }
|
|
647
633
|
opts.onResolve({ ...ask, behavior, source });
|
|
648
634
|
};
|
|
649
|
-
const
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
635
|
+
const entry = { ask, finish };
|
|
636
|
+
if (!(kind === "permission" && holding)) {
|
|
637
|
+
entry.timer = setTimeout(() => kind === "question"
|
|
638
|
+
? finish("answer", QUESTION_TIMEOUT_NOTE, "timeout")
|
|
639
|
+
: holdAsk(askId), timeoutMs);
|
|
640
|
+
entry.timer.unref?.();
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
opts.onHold?.(ask);
|
|
644
|
+
}
|
|
645
|
+
pending.set(askId, entry);
|
|
654
646
|
opts.onAsk(ask);
|
|
655
647
|
}
|
|
656
648
|
});
|
|
657
649
|
};
|
|
658
|
-
// Bind the first candidate that will take a listener.
|
|
659
|
-
//
|
|
660
|
-
// deny nobody could explain. Keep the turn fail-closed on total failure,
|
|
661
|
-
// but leave an actionable diagnostic either way.
|
|
650
|
+
// Bind the first candidate that will take a listener. Fail closed, with a
|
|
651
|
+
// diagnostic, if none will — a silent miss used to deny every approval.
|
|
662
652
|
let server = null;
|
|
663
653
|
for (const [index, candidate] of opts.socketPaths.entries()) {
|
|
664
654
|
const attempt = createNetServer(connectionHandler);
|
|
@@ -736,6 +726,17 @@ export async function createPermissionBroker(opts) {
|
|
|
736
726
|
pause() {
|
|
737
727
|
drain();
|
|
738
728
|
},
|
|
729
|
+
hold() {
|
|
730
|
+
holding = true;
|
|
731
|
+
for (const id of Array.from(pending.keys()))
|
|
732
|
+
holdAsk(id);
|
|
733
|
+
},
|
|
734
|
+
resumeHold() {
|
|
735
|
+
holding = false;
|
|
736
|
+
},
|
|
737
|
+
isHolding() {
|
|
738
|
+
return holding;
|
|
739
|
+
},
|
|
739
740
|
close() {
|
|
740
741
|
closed = true;
|
|
741
742
|
drain();
|
|
@@ -847,14 +848,9 @@ export const ClaudeDriver = {
|
|
|
847
848
|
}
|
|
848
849
|
};
|
|
849
850
|
await refreshModels();
|
|
850
|
-
//
|
|
851
|
-
//
|
|
852
|
-
//
|
|
853
|
-
// load, the Engines page, and right after `claude update`, which is
|
|
854
|
-
// exactly when the answer changes — so a turn normally finds it filled.
|
|
855
|
-
// Most turns before any snapshot assume a current CLI. A coordinated
|
|
856
|
-
// turn checks first because the snapshot-refresh flag is newer than the
|
|
857
|
-
// other context controls and an unknown flag would reject that request.
|
|
851
|
+
// Installed CLI version from snapshot(), so unknown flags are never
|
|
852
|
+
// passed (CLAUDE_FLAG_FLOORS). Coordinated turns check first: the
|
|
853
|
+
// snapshot-refresh flag is newer than the other context controls.
|
|
858
854
|
let cliVersion = null;
|
|
859
855
|
let cliVersionChecked = false;
|
|
860
856
|
const readCliVersion = (env) => new Promise((resolve) => {
|
|
@@ -1953,15 +1949,8 @@ export const ClaudeDriver = {
|
|
|
1953
1949
|
relaunchTurn(verdict.reason, verdict.reason === "credential_refresh" ? computeCredentialRefreshBackoff : computeBackoff);
|
|
1954
1950
|
return;
|
|
1955
1951
|
}
|
|
1956
|
-
//
|
|
1957
|
-
//
|
|
1958
|
-
// caused nothing. Without this the thread is BRICKED — the dead
|
|
1959
|
-
// cursor is never cleared, so every later turn resumes the same
|
|
1960
|
-
// missing session and fails identically, and the user has no way
|
|
1961
|
-
// back except switching engines. One fresh session, carrying the
|
|
1962
|
-
// harness's rebuild of the conversation. Exactly one: the relaunch
|
|
1963
|
-
// offers no cursor, so `attempted` is false there and a second
|
|
1964
|
-
// failure is reported like any other.
|
|
1952
|
+
// --resume was never acknowledged (no `init`): one fresh session
|
|
1953
|
+
// from the harness rebuild, or the dead cursor bricks the thread.
|
|
1965
1954
|
const resumeFailure = classifyResumeFailure({
|
|
1966
1955
|
attempted: Boolean(sessionId),
|
|
1967
1956
|
rejected: !session.sawInit,
|
|
@@ -2238,6 +2227,20 @@ export const ClaudeDriver = {
|
|
|
2238
2227
|
sendTurn,
|
|
2239
2228
|
steer,
|
|
2240
2229
|
interruptTurn: async (threadId) => active.get(threadId)?.stop(),
|
|
2230
|
+
holdTurn: async (threadId) => {
|
|
2231
|
+
const broker = active.get(threadId)?.broker ?? sessions.get(threadId)?.broker;
|
|
2232
|
+
if (!broker)
|
|
2233
|
+
return "unavailable";
|
|
2234
|
+
broker.hold();
|
|
2235
|
+
return "held";
|
|
2236
|
+
},
|
|
2237
|
+
resumeTurn: async (threadId) => {
|
|
2238
|
+
const broker = active.get(threadId)?.broker ?? sessions.get(threadId)?.broker;
|
|
2239
|
+
if (!broker)
|
|
2240
|
+
return "unavailable";
|
|
2241
|
+
broker.resumeHold();
|
|
2242
|
+
return "resumed";
|
|
2243
|
+
},
|
|
2241
2244
|
respondToRequest: async (threadId, requestId, decision) => {
|
|
2242
2245
|
const confirmation = elicitations.respond(threadId, requestId, decision);
|
|
2243
2246
|
if (confirmation)
|
|
@@ -154,7 +154,6 @@ export function managedCodexArgs(config) {
|
|
|
154
154
|
];
|
|
155
155
|
}
|
|
156
156
|
const QUESTION_TIMEOUT_NOTE = "No answer was given — use your best judgment.";
|
|
157
|
-
const DENY_TIMEOUT_NOTE = "Atomic: nobody answered this permission request in time. Skip this action and finish what you can without it.";
|
|
158
157
|
const notedMcpServers = new Set();
|
|
159
158
|
/** Logged once per server and reason: a rename or a left-out server is deliberate, not a lost one. */
|
|
160
159
|
function noteMcpServerOnce(key, line) {
|
|
@@ -946,8 +945,10 @@ export const CodexDriver = {
|
|
|
946
945
|
}
|
|
947
946
|
emit({ ...base(threadId, turnId), type: "request.resolved", requestId, behavior, source });
|
|
948
947
|
};
|
|
949
|
-
const timer =
|
|
950
|
-
|
|
948
|
+
const timer = isQuestion
|
|
949
|
+
? setTimeout(() => finish("answer", QUESTION_TIMEOUT_NOTE, "timeout"), 15 * 60_000)
|
|
950
|
+
: undefined;
|
|
951
|
+
timer?.unref?.();
|
|
951
952
|
asks.set(requestId, finish);
|
|
952
953
|
emit({
|
|
953
954
|
...base(threadId, turnId),
|
|
@@ -288,7 +288,7 @@ export function createOpenAIChatRuntime(options) {
|
|
|
288
288
|
const denials = [];
|
|
289
289
|
const seenCalls = new Set();
|
|
290
290
|
try {
|
|
291
|
-
tools = await mountChatTools(options.tools === false ? undefined : turn.integrations, abort.signal, options.computerUse
|
|
291
|
+
tools = await mountChatTools(options.tools === false ? undefined : turn.integrations, abort.signal, options.computerUse);
|
|
292
292
|
for (let round = 0; round < 16; round++) {
|
|
293
293
|
abort.signal.throwIfAborted();
|
|
294
294
|
native("out", options.nativeLog.outgoing(turn, messages, model));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
1
3
|
import { commandPrefix, isShellTool } from "../approval-grants.js";
|
|
2
4
|
/** What "this action" means for "Always allow this session". The claude CLI
|
|
3
5
|
* calls --permission-prompt-tool with only tool_name, input and tool_use_id,
|
|
@@ -5,17 +7,32 @@ import { commandPrefix, isShellTool } from "../approval-grants.js";
|
|
|
5
7
|
* MCP tool is allowed by name, the rule Claude would have suggested for it.
|
|
6
8
|
* A shell command is allowed by its program and subcommand (`git push`,
|
|
7
9
|
* `pnpm test`), the same scope a delegated Always allow covers
|
|
8
|
-
* (approval-grants commandPrefix)
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* ask names no tool. */
|
|
10
|
+
* (approval-grants commandPrefix). A literal cd wrapper adds directory scope;
|
|
11
|
+
* other chains and redirects keep exact-input scope. Read/Edit on an existing
|
|
12
|
+
* absolute file cover only that operation on the resolved file. Other tools
|
|
13
|
+
* keep exact-input scope. null when the ask names no tool. */
|
|
12
14
|
export function sessionAllowKey(ask) {
|
|
13
15
|
const tool = typeof ask.tool === "string" ? ask.tool.trim() : "";
|
|
14
16
|
if (!tool)
|
|
15
17
|
return null;
|
|
16
18
|
if (tool.startsWith("mcp__"))
|
|
17
19
|
return JSON.stringify(["tool", tool]);
|
|
18
|
-
|
|
20
|
+
if ((tool === "Read" || tool === "Edit") && typeof ask.input?.file_path === "string" && isAbsolute(ask.input.file_path)) {
|
|
21
|
+
try {
|
|
22
|
+
return JSON.stringify(["file", tool, realpathSync(ask.input.file_path)]);
|
|
23
|
+
}
|
|
24
|
+
catch { /* Unresolved paths keep the exact-input scope below. */ }
|
|
25
|
+
}
|
|
26
|
+
const shell = isShellTool(tool) && typeof ask.input?.command === "string" ? ask.input.command : null;
|
|
27
|
+
// Only one literal absolute-directory wrapper. Expansions, escaped paths,
|
|
28
|
+
// newlines, pipes, redirects and further commands keep exact-input scope.
|
|
29
|
+
const cd = shell && !/[\r\n]/.test(shell)
|
|
30
|
+
? /^\s*cd\s+(?:--\s+)?(?:"(\/[\w ./-]*)"|'(\/[\w ./-]*)'|(\/[\w./-]*))\s+&&\s+(.+)$/.exec(shell)
|
|
31
|
+
: null;
|
|
32
|
+
const prefix = cd ? commandPrefix(cd[4]) : null;
|
|
33
|
+
if (cd && prefix)
|
|
34
|
+
return JSON.stringify(["directory-command", tool, cd[1] ?? cd[2] ?? cd[3], prefix]);
|
|
35
|
+
const command = shell && !/[\r\n]/.test(shell) ? commandPrefix(shell) : null;
|
|
19
36
|
if (command)
|
|
20
37
|
return JSON.stringify(["command", tool, command]);
|
|
21
38
|
const stable = (value) => Array.isArray(value)
|
|
@@ -139,9 +139,6 @@ export function engineTierClasses(engineTiers) {
|
|
|
139
139
|
const classes = stored && typeof stored === "object" && !Array.isArray(stored) ? stored : {};
|
|
140
140
|
return Object.fromEntries(BOT_TIERS.map((tier) => [tier, toModelClass(classes[tier]) ?? DEFAULT_TIER_CLASSES[tier]]));
|
|
141
141
|
}
|
|
142
|
-
/** A bot counts as handling client data unless switched off (WireBot.clientData),
|
|
143
|
-
* so a free-tier model is never the default for one. */
|
|
144
|
-
export const handlesClientData = (bot) => bot.clientData !== false;
|
|
145
142
|
/** "Include free models in Auto" (config.json engineTiers.includeFree): off by default. */
|
|
146
143
|
export function engineTiersIncludeFree(engineTiers) {
|
|
147
144
|
return configObject(engineTiers).includeFree === true;
|
|
@@ -275,8 +272,8 @@ export function resolveLadder(ladder, stored, context) {
|
|
|
275
272
|
subscription.push({ step: ladder.length, entry: { engine: candidate.instanceId }, candidate, band: "subscription", index });
|
|
276
273
|
}
|
|
277
274
|
// A free-tier account joins every ladder by itself, in its own
|
|
278
|
-
// last-resort band (gated by includeFree
|
|
279
|
-
//
|
|
275
|
+
// last-resort band (gated by includeFree below): no rung ever names
|
|
276
|
+
// one, same as how a key-based engine joins automatically.
|
|
280
277
|
if (freeCandidate(candidate)) {
|
|
281
278
|
const step = rungOf(candidate);
|
|
282
279
|
free.push({ step, entry: ownRung(ladder[step], candidate), candidate, band: "free", index });
|
|
@@ -293,8 +290,7 @@ export function resolveLadder(ladder, stored, context) {
|
|
|
293
290
|
for (const { step, entry, candidate, band } of [...subscription, ...free, ...key]) { // free before pay-per-use (Erick, 2026-11-15)
|
|
294
291
|
// "paused" names a key kept off this turn by policy alone: a key that could not take it anyway (signed out, resting, refused) keeps its real reason.
|
|
295
292
|
const reason = band === "free" && !context.includeFree ? "free-off"
|
|
296
|
-
: band === "
|
|
297
|
-
: skipReason(entry, candidate, context, step < ladder.length) ?? (band === "key" && context.keyBandPaused ? "paused" : undefined);
|
|
293
|
+
: skipReason(entry, candidate, context, step < ladder.length) ?? (band === "key" && context.keyBandPaused ? "paused" : undefined);
|
|
298
294
|
if (reason) {
|
|
299
295
|
skipped.push({ step, instanceId: candidate.instanceId, reason, band });
|
|
300
296
|
continue;
|