@chibitek/chibi 0.1.210 → 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.
Files changed (91) hide show
  1. package/dist/assets/{TerminalPanel-DxQoOfkY.js → TerminalPanel-mkQO42zG.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-Ds2qYdjS.js → abnfDiagram-O67JEVCF-D_YvZb12.js} +1 -1
  3. package/dist/assets/{arc-1O9tchZk.js → arc-u7NcCAzn.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-CWuQ1x2F.js → architectureDiagram-NJMV4G6O-CvoIt_0y.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-CNcEkXEx.js → blockDiagram-BEXU5L5S-B0Ry3uOJ.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-BKI_wi9I.js → c4Diagram-YGBWAQC7-DQQBHqDt.js} +1 -1
  7. package/dist/assets/channel-BG3AR6Y6.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-gO88emfN.js → chunk-2Q5K7J3B-B4IxGiPz.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-DbKNT_-r.js → chunk-3FUC2YCW-BxR5i6Mq.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-BbJCoZVg.js → chunk-5VM5RSS4-CqmFQLrB.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-DXurSCcp.js → chunk-GTNCS2PH-C9lKwjYE.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-BWyt0I_m.js → chunk-GWA4HPMP-DKAnucqk.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-6iWSsogl.js → chunk-JWPE2WC7-CE4DRhto.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-CFoqO9Hw.js → chunk-NETBCI7D-UziBzgi9.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-BZEzAlNi.js → chunk-WEXAMYUT-DVo_P12S.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-W4hfC50f.js → chunk-XXDRQBXY-CBwStBk5.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-BsGmL9e7.js → classDiagram-v2-NBCMYWYE-D4xfjrAt.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-CYtTgIzk.js → cose-bilkent-JH36ORCC-DNpZWduJ.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-DLOi2Q2V.js → cynefin-OW5HDTMX-CMegK4fD.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-BXcXJ3hv.js → cynefinDiagram-VND7K2PF-BBRJHq6u.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-BdBOiuzt.js → dagre-6A5THRUB-BwneJkAI.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-DCf3M4WE.js → diagram-22UHCM2B-p4tq7l1f.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-CzdF-UXi.js → diagram-3UASUU5V-C8BCnB5c.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-_UmmlMOD.js → diagram-ATOU4E4O-Da-Fc2pA.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-DrQODVuX.js → diagram-CDSNMT55-CH7l4Als.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-CE16iJlJ.js → diagram-MLGK6HIB-xO-efOVl.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-DJuTbhbP.js → diagram-MPIPVDR6-CjWQ4FpH.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-f1VEI2Po.js → ebnfDiagram-ZINNZB2B-DbyEj47I.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-BRbs9WzY.js → elk-276RUBZZ-B0uak8Gs.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-DvMp_cQr.js → erDiagram-OPXOYQCR-DHYzl46p.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-CYS1A0fu.js → flowDiagram-KWPJA3E3-CjUIIif9.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-qya_JE9x.js → ganttDiagram-FUAMR5RP-CPjVOkNO.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-ChMUJ3hH.js → gitGraphDiagram-X574FWY7-DnI_xNjh.js} +1 -1
  34. package/dist/assets/{index-COH7BlyH.js → index-C8wABnWu.js} +177 -177
  35. package/dist/assets/{index-xE4Li_H2.js → index-kYL6p_po.js} +1 -1
  36. package/dist/assets/{infoDiagram-VRGFBTTK-B2VudqsE.js → infoDiagram-VRGFBTTK-SXQSkFFT.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-Bdk47y0t.js → ishikawaDiagram-OU5B5YK6-DF3AQU1D.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-A4StgNQ9.js → journeyDiagram-ZHPQQLJL-IWRv1Evh.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-DZo45dQw.js → kanban-definition-PNTS6WVX-BKpuGZmD.js} +1 -1
  40. package/dist/assets/{linear-D_rK-Ord.js → linear-S9gqQWWc.js} +1 -1
  41. package/dist/assets/{mermaid.core-C7CvDDvz.js → mermaid.core-BHRIdye5.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-6fmVPMyc.js → mindmap-definition-NLK3R4M7-BTD52Pxv.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-CD4Qg24h.js → pegDiagram-GJSIUBJH-C91CNvYA.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-DmzQ883B.js → pieDiagram-5QR66LMP-0aP3PVSg.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-BW37utPZ.js → quadrantDiagram-O4NWA36T-CN-CB1dj.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-CWXiMlAb.js → railroadDiagram-XR7U4H2S-DUwKNVqn.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-DHSfr9U3.js → requirementDiagram-PLB6GJNP-BwiKCqXR.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-PebTt4eq.js → sankeyDiagram-IPEJSGJF-DK2nk983.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-DPwp8fia.js → sequenceDiagram-PO4LG4MO-DGQaL2CK.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-BX_46o3S.js → sizeCapture-INFHLROL-DjxAs07q.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-W2e0RRrZ.js → stateDiagram-v2-GCMORJYK-DfhvmAHx.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-CkyXpQX9.js → swimlanes-2SLR337P-g4YraApj.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-BnxrvDBt.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-BS-sCjlN.js → timeline-definition-EJHVYXUP-Bh6Ow15M.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-BQre-k6x.js → usecaseDiagram-POWQR4AR-wRtBj8_e.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U-CEWCsi_s.js → vennDiagram-UO4OBE2U-D4QR4Odj.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-CXUxqghG.js → wardleyDiagram-VNRHLVJA-DthL_SDi.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-DBgVMpwp.js → xychartDiagram-PMCCYNJV-CK-QrbHO.js} +1 -1
  59. package/dist/handbook/atomic-handbook.html +1 -1
  60. package/dist/index.html +1 -1
  61. package/dist-server/drivers/agents-proxy.js +2 -3
  62. package/dist-server/index.js +2405 -1990
  63. package/dist-server/openmausbot.js +180 -95
  64. package/dist-server/pair-cli.js +180 -95
  65. package/dist-server/server/auto-approve.js +12 -0
  66. package/dist-server/server/drivers/acp/core.js +4 -6
  67. package/dist-server/server/drivers/acp/custom.js +3 -1
  68. package/dist-server/server/drivers/acp/hermes.js +2 -1
  69. package/dist-server/server/drivers/agents-catalog.js +2 -2
  70. package/dist-server/server/drivers/chat-mcp-tools.js +1 -21
  71. package/dist-server/server/drivers/claude.js +69 -66
  72. package/dist-server/server/drivers/codex.js +4 -3
  73. package/dist-server/server/drivers/hermes-context-floor.js +68 -0
  74. package/dist-server/server/drivers/openai-chat.js +1 -1
  75. package/dist-server/server/drivers/session-allow-key.js +22 -5
  76. package/dist-server/server/engine-tiers.js +3 -7
  77. package/dist-server/server/god-mode-goal.js +78 -0
  78. package/dist-server/server/god-mode-run-host.js +69 -0
  79. package/dist-server/server/index.js +70 -73
  80. package/dist-server/server/model-fallback-repair.js +20 -0
  81. package/dist-server/server/new-bot-defaults.js +3 -1
  82. package/dist-server/server/personal-goal-runtime.js +29 -3
  83. package/dist-server/server/personal-goal-turn.js +2 -1
  84. package/dist-server/server/personal-goals.js +20 -2
  85. package/dist-server/server/routes/thread-stop.js +15 -2
  86. package/dist-server/server/surface.js +1 -1
  87. package/dist-server/shared/god-mode-run.js +173 -0
  88. package/dist-server/shared/personal-goal.js +42 -0
  89. package/package.json +1 -1
  90. package/dist/assets/channel-CT5xRPK0.js +0 -1
  91. package/dist/assets/swimlanesDiagram-TC7HE7FX-BH9Yry0J.js +0 -8
@@ -13,6 +13,7 @@
13
13
  // Questions never come through here: a bot's question always reaches a human.
14
14
  import { supportsApprovalMode } from "../shared/approval-mode.js";
15
15
  import { isElicitationTool } from "./mcp-elicitation.js";
16
+ import { godModeHardLimit } from "../shared/god-mode-run.js";
16
17
  /** A failed delivery is a runtime error, not another permission decision.
17
18
  * An expired ask must never become a fresh Allow/Deny card. */
18
19
  export async function deliverFullAccessApproval(adapter, threadId, requestId, turnId, isCurrent = () => false) {
@@ -75,6 +76,14 @@ export function autoVerdict(mode, tool, context) {
75
76
  // request.opened caller invokes this for permissions only, never questions.
76
77
  // GOD MODE is the same promise as Full, made for the whole workspace, so
77
78
  // it answers on every engine, whether or not the engine implements Full.
79
+ // Its hard limits are the exception: no money, no deleting data outside
80
+ // the task, no production deploys or force pushes, no local Postgres. The
81
+ // card stays for the person, with the reason.
82
+ if (context?.godModeLimits && (context.godMode || mode === "full")) {
83
+ const limit = godModeHardLimit(tool, context.godModeLimits.summary ?? "", context.godModeLimits.workspace);
84
+ if (limit)
85
+ return { approve: null, source: "god-mode-limit", limit };
86
+ }
78
87
  if (context?.godMode)
79
88
  return { approve: `approved ${tool} (GOD MODE)`, source: "god-mode" };
80
89
  if (mode === "full")
@@ -101,6 +110,7 @@ export const HELD_NOTE = {
101
110
  "approval.held.sandbox": "This changes the provider sandbox, so only GOD MODE can approve it automatically.",
102
111
  "approval.held.undeliveredFull": "GOD MODE couldn't deliver this approval.",
103
112
  "approval.held.undelivered": "Approve for me couldn't answer this one.",
113
+ "approval.held.godModeLimit": "GOD MODE never does this on its own: it is one of its hard limits.",
104
114
  };
105
115
  /** Which note, as a key. approvalHeldReason is this plus the English text, so
106
116
  * the branching that decides the note lives in exactly one place. */
@@ -109,6 +119,8 @@ export function approvalHeldNote(context) {
109
119
  return undefined;
110
120
  if (context.source === "explicit-approval-block")
111
121
  return "approval.held.sandbox";
122
+ if (context.source === "god-mode-limit")
123
+ return "approval.held.godModeLimit";
112
124
  if (context.source === "native-approval")
113
125
  return "approval.held.native";
114
126
  return undefined;
@@ -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 = setTimeout(() => {
703
- emit({ ...base(threadId, current.turnId), type: "runtime.error", message: DENY_TIMEOUT_NOTE });
704
- finish("deny", "timeout");
705
- }, 15 * 60_000);
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,6 +23,7 @@ import { atomicEngineAsset } from "../../atomic-engine-release.js";
23
23
  import { ATOMIC_ENGINE_MODULE_ARGS, installAtomicEngine, managedAtomicEngine } from "../../atomic-engine-runtime.js";
24
24
  import { findCliCandidates } from "../../env-path.js";
25
25
  import { execCli } from "../../procs.js";
26
+ import { withoutUnderSizedLocalModels } from "../hermes-context-floor.js";
26
27
  import { decodeInjectId, mergeLocalInject } from "../local-inject.js";
27
28
  import { createAcpDriver, versionFromProbe } from "./core.js";
28
29
  import { lockHermesMemory } from "./hermes-memory-lock.js";
@@ -102,7 +103,8 @@ export async function customAcpModels(env, config, instanceId, fetchImpl = fetch
102
103
  return PASSTHROUGH;
103
104
  // One choice with Automatic (shared/atomic-auto.ts): picking it puts the bot on its tier's ladder.
104
105
  const own = { default: ATOMIC_AUTO_MODEL, options: [{ id: ATOMIC_AUTO_MODEL, label: "Atomic Engine (Auto)", custom: true }] };
105
- const catalog = await mergeLocalInject(own, env, fetchImpl);
106
+ // Hermes underneath refuses a model under 64k context (drivers/hermes-context-floor.ts).
107
+ const catalog = await withoutUnderSizedLocalModels(await mergeLocalInject(own, env, fetchImpl), env, fetchImpl);
106
108
  rememberLocalModels(catalog.options); // the engine's local fallbacks (server/atomic-engine-local.ts)
107
109
  return catalog;
108
110
  }
@@ -12,6 +12,7 @@ import { parse as parseYaml } from "yaml";
12
12
  import { resolveCli } from "../../procs.js";
13
13
  import { planOptions } from "../../spawn-command.js";
14
14
  import { decodeInjectId, hostApiKey, INJECT_SEP, localHost, mergeLocalInject } from "../local-inject.js";
15
+ import { withoutUnderSizedLocalModels } from "../hermes-context-floor.js";
15
16
  import { createAcpDriver } from "./core.js";
16
17
  import { hermesOnlyHosts } from "./hermes-hosts.js";
17
18
  import { lockHermesMemory } from "./hermes-memory-lock.js";
@@ -542,7 +543,7 @@ export async function fetchHermesAcpModels(cli, env) {
542
543
  });
543
544
  }
544
545
  export async function resolveHermesModels(env, config) {
545
- const catalog = await mergeLocalInject(EMPTY, env);
546
+ const catalog = await withoutUnderSizedLocalModels(await mergeLocalInject(EMPTY, env), env); // the engine refuses <64k
546
547
  const configured = hermesConfiguredModel(env);
547
548
  const hostDefault = hermesConfiguredHostModel(env);
548
549
  const signedIn = hermesAuthStoreModels(env);
@@ -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", freeModel: env.OMB_FREE_MODEL === "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) => (profile.threatScan || tool.name !== "threat_scan") && !(profile.freeModel && tool.name.startsWith("nexus_")));
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
- /** Whether any string in a tool call's arguments names a path inside one of
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
- // A readable prefix alone is not unique: ids that agree on their first
497
- // characters ("t-perm-dup-1", "t-perm-dup-2") would share a socket. POSIX
498
- // hides that — a new broker's listen replaces the socket FILE, so the name
499
- // always points at the fresh server — but Windows named pipes live in a
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
- // server.close() only stops accepting NEW connections — it does not touch
543
- // a connection that's already open. A still-alive child's MCP proxy can
544
- // keep sending asks on such a connection after the turn has ended, and
545
- // this handler stays fully wired to it. Without this flag those asks would
546
- // become new `pending` entries and `request.opened` cards for a turn the
547
- // driver already forgot (`active.delete(threadId)` already ran), which can
548
- // never be answered — the "zombie card" in issue #211.
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
- // Closure is terminal and takes precedence over every active-turn
573
- // rule, including duplicate-id rejection. Never register a pending
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
- // A retained Claude process keeps its proxy connection between
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
- // `pending` is server-scoped, not per-connection: two asks with the
594
- // same id — a buggy/adversarial client, never a legitimate retry
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
- clearTimeout(timer);
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 timer = setTimeout(() => kind === "question"
650
- ? finish("answer", QUESTION_TIMEOUT_NOTE, "timeout")
651
- : finish("deny", DENY_TIMEOUT_NOTE, "timeout"), timeoutMs);
652
- timer.unref?.();
653
- pending.set(askId, { ask, finish });
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. A broker that
659
- // never came up used to be silent — every approval then timed out into a
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
- // The installed CLI's version as snapshot() last read it, so a flag the
851
- // CLI does not know is never passed to it (CLAUDE_FLAG_FLOORS). The
852
- // harness snapshots every instance whenever it describes them — app
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
- // A --resume that the CLI never acknowledged: it exited without
1957
- // an `init` frame, so it never read the prompt and this turn has
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 = setTimeout(() => (isQuestion ? finish("answer", QUESTION_TIMEOUT_NOTE, "timeout") : finish("deny", DENY_TIMEOUT_NOTE, "timeout")), 15 * 60_000);
950
- timer.unref?.();
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),
@@ -0,0 +1,68 @@
1
+ // Hermes, and Atomic Engine built on it, refuses a model whose context
2
+ // window is under 64,000 tokens (agent/agent_init.py _enforce_minimum_context
3
+ // in the engine). A local Ollama model such as qwen3:8b (40,960) was still
4
+ // listed in their pickers, so a bot pinned to it hit the refusal on every
5
+ // turn and ran on the engine's default instead (Erick, 2026-11-22). Their
6
+ // catalogs leave such a model out, measured the way the engine measures it.
7
+ import { isOllamaCloudModel } from "../../shared/local-models.js";
8
+ import { anthropicBaseUrl, decodeInjectId, hostApiKey, localHost } from "./local-inject.js";
9
+ /** The engine's MINIMUM_CONTEXT_LENGTH (agent/model_metadata.py). */
10
+ export const HERMES_MIN_CONTEXT = 64_000;
11
+ const OLLAMA_HOSTS = new Set(["ollama", "local_ollama"]);
12
+ /** The window Ollama serves a model at, from its /api/show payload, read as
13
+ * the engine reads it for a local server: the Modelfile's num_ctx, else the
14
+ * model's own context_length. */
15
+ export function ollamaServedWindow(show) {
16
+ if (!show || typeof show !== "object")
17
+ return undefined;
18
+ const { parameters, model_info: info } = show;
19
+ if (typeof parameters === "string") {
20
+ for (const line of parameters.split("\n")) {
21
+ const parts = line.trim().split(/\s+/);
22
+ const value = Number(parts.at(-1));
23
+ if (parts[0] === "num_ctx" && Number.isInteger(value) && value > 0)
24
+ return value;
25
+ }
26
+ }
27
+ if (info && typeof info === "object") {
28
+ for (const [key, value] of Object.entries(info)) {
29
+ if (key.endsWith("context_length") && typeof value === "number" && value > 0)
30
+ return value;
31
+ }
32
+ }
33
+ return undefined;
34
+ }
35
+ async function ollamaShow(host, model, env, fetchImpl) {
36
+ try {
37
+ const response = await fetchImpl(`${anthropicBaseUrl(host)}/api/show`, {
38
+ method: "POST",
39
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${hostApiKey(host, env)}` },
40
+ body: JSON.stringify({ model }),
41
+ signal: AbortSignal.timeout(1500),
42
+ });
43
+ return response.ok ? await response.json() : null;
44
+ }
45
+ catch {
46
+ return null;
47
+ }
48
+ }
49
+ /** The window Hermes would see for a catalog row, when Atomic can tell: an
50
+ * Ollama model's /api/show (/api/ps's figure is only what is loaded now, and
51
+ * the engine asks Ollama for the larger window itself). */
52
+ async function hermesWindow(id, env, fetchImpl) {
53
+ const inject = decodeInjectId(id);
54
+ const host = inject ? localHost(inject.host) : undefined;
55
+ if (!inject || !host || !OLLAMA_HOSTS.has(host.id) || isOllamaCloudModel(inject.model))
56
+ return undefined;
57
+ return ollamaServedWindow(await ollamaShow(host, inject.model, env, fetchImpl));
58
+ }
59
+ /** A Hermes-family catalog without the local models the engine would refuse.
60
+ * A window Atomic cannot read keeps the row: the engine is the judge then. */
61
+ export async function withoutUnderSizedLocalModels(catalog, env = process.env, fetchImpl = fetch) {
62
+ const windows = await Promise.all(catalog.options.map((option) => hermesWindow(option.id, env, fetchImpl)));
63
+ const options = catalog.options.filter((_, index) => (windows[index] ?? HERMES_MIN_CONTEXT) >= HERMES_MIN_CONTEXT);
64
+ if (options.length === catalog.options.length)
65
+ return catalog;
66
+ const kept = new Set(options.map((option) => option.id));
67
+ return { default: kept.has(catalog.default) ? catalog.default : (options[0]?.id ?? ""), options };
68
+ }
@@ -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, undefined, turn.blockedPaths);
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); a command that chains or redirects keeps
9
- * to its exact text. Every other tool (Edit, WebFetch...) only for this
10
- * exact input, keys sorted so two identical asks key alike. null when the
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
- const command = isShellTool(tool) && typeof ask.input?.command === "string" ? commandPrefix(ask.input.command) : null;
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/clientData below): no rung
279
- // ever names one, same as how a key-based engine joins automatically.
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 === "free" && context.clientData ? "client-data"
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;