@chibitek/chibi 0.1.177 → 0.1.178

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 (89) hide show
  1. package/dist/assets/{abnfDiagram-O67JEVCF-D66KKLXq.js → abnfDiagram-O67JEVCF-dWHl3jkm.js} +1 -1
  2. package/dist/assets/{arc-Chl6g0yq.js → arc-CZzCs6es.js} +1 -1
  3. package/dist/assets/{architectureDiagram-NJMV4G6O-ChT8017v.js → architectureDiagram-NJMV4G6O-YwZAu6Y7.js} +1 -1
  4. package/dist/assets/{blockDiagram-BEXU5L5S-DSOAtPXh.js → blockDiagram-BEXU5L5S-WmC_extb.js} +1 -1
  5. package/dist/assets/{c4Diagram-YGBWAQC7-CAyzcis4.js → c4Diagram-YGBWAQC7-B65Jnm1V.js} +1 -1
  6. package/dist/assets/channel-ClZ5TVsZ.js +1 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-DG7zWvl1.js → chunk-2Q5K7J3B-CKo9M6W3.js} +1 -1
  8. package/dist/assets/{chunk-3FUC2YCW-CNQ37WCV.js → chunk-3FUC2YCW-7yQVJbNw.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-Dvv3U9Ci.js → chunk-5VM5RSS4-De0KYP62.js} +1 -1
  10. package/dist/assets/{chunk-GTNCS2PH-DyQrY0Ij.js → chunk-GTNCS2PH-CLr-nzve.js} +1 -1
  11. package/dist/assets/{chunk-GWA4HPMP-BLgrTe-Y.js → chunk-GWA4HPMP-CtuDeI-a.js} +1 -1
  12. package/dist/assets/{chunk-JWPE2WC7-Bi7RU6mT.js → chunk-JWPE2WC7-y52neVCm.js} +1 -1
  13. package/dist/assets/{chunk-NETBCI7D-bBBVBfAd.js → chunk-NETBCI7D-CTQRNeEv.js} +1 -1
  14. package/dist/assets/{chunk-WEXAMYUT-CE_h60fU.js → chunk-WEXAMYUT-7zNFA7Tc.js} +1 -1
  15. package/dist/assets/{chunk-XXDRQBXY-f6P9rCRq.js → chunk-XXDRQBXY-CF0jLMvs.js} +1 -1
  16. package/dist/assets/{classDiagram-v2-NBCMYWYE-6Uq3JzmJ.js → classDiagram-v2-NBCMYWYE-WBfBG6F9.js} +1 -1
  17. package/dist/assets/{cose-bilkent-JH36ORCC-BxvkL31E.js → cose-bilkent-JH36ORCC-BN-OWUOQ.js} +1 -1
  18. package/dist/assets/{cynefin-OW5HDTMX-Dlcwlw2F.js → cynefin-OW5HDTMX-icxZUnEx.js} +1 -1
  19. package/dist/assets/{cynefinDiagram-VND7K2PF-D3NOeWUy.js → cynefinDiagram-VND7K2PF-Clgujiet.js} +1 -1
  20. package/dist/assets/{dagre-6A5THRUB-IGmT7nsP.js → dagre-6A5THRUB-B-mr-ojn.js} +1 -1
  21. package/dist/assets/{diagram-22UHCM2B-D0K8tG3k.js → diagram-22UHCM2B-0VKN1h9d.js} +1 -1
  22. package/dist/assets/{diagram-3UASUU5V-CSkDkOvw.js → diagram-3UASUU5V-9Nvuaj11.js} +1 -1
  23. package/dist/assets/{diagram-ATOU4E4O-CX5EXBJ_.js → diagram-ATOU4E4O-B-uzDb8p.js} +1 -1
  24. package/dist/assets/{diagram-CDSNMT55-D0FQ7x1J.js → diagram-CDSNMT55-CTvDjLvE.js} +1 -1
  25. package/dist/assets/{diagram-MLGK6HIB-BymN_w7h.js → diagram-MLGK6HIB-DxDrNPv6.js} +1 -1
  26. package/dist/assets/{diagram-MPIPVDR6-ugKqp8yy.js → diagram-MPIPVDR6-CGHXB_-s.js} +1 -1
  27. package/dist/assets/{ebnfDiagram-ZINNZB2B-DROFb0r3.js → ebnfDiagram-ZINNZB2B-DNkShTCq.js} +1 -1
  28. package/dist/assets/{elk-276RUBZZ-CNVCU2l7.js → elk-276RUBZZ-CNZgZP06.js} +1 -1
  29. package/dist/assets/{erDiagram-OPXOYQCR-BQj5bZ7y.js → erDiagram-OPXOYQCR-CVlJu0RH.js} +1 -1
  30. package/dist/assets/{flowDiagram-KWPJA3E3-C3cBXKRL.js → flowDiagram-KWPJA3E3-ZWXAAVoE.js} +1 -1
  31. package/dist/assets/{ganttDiagram-FUAMR5RP-CdNdC_Vp.js → ganttDiagram-FUAMR5RP-BaPFE0m8.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-X574FWY7-v_LM9fGO.js → gitGraphDiagram-X574FWY7-B__eRHIL.js} +1 -1
  33. package/dist/assets/index-CI0vGAif.css +1 -0
  34. package/dist/assets/{index-fnHp_1ly.js → index-CluLWh67.js} +1 -1
  35. package/dist/assets/{index-UICHeO5x.js → index-DxRLJ091.js} +197 -195
  36. package/dist/assets/{infoDiagram-VRGFBTTK-0fzWO21Z.js → infoDiagram-VRGFBTTK-DQkxDIsw.js} +1 -1
  37. package/dist/assets/{ishikawaDiagram-OU5B5YK6-BmqyKWCK.js → ishikawaDiagram-OU5B5YK6-dc12aZx1.js} +1 -1
  38. package/dist/assets/{journeyDiagram-ZHPQQLJL-BSihTjOI.js → journeyDiagram-ZHPQQLJL-BUQgOHxW.js} +1 -1
  39. package/dist/assets/{kanban-definition-PNTS6WVX-LAP03jiI.js → kanban-definition-PNTS6WVX-0G8FTiwC.js} +1 -1
  40. package/dist/assets/{linear-BoSfZT4X.js → linear-BsZ0eCh6.js} +1 -1
  41. package/dist/assets/{mermaid.core-KciMRs_R.js → mermaid.core-CBJIrEjV.js} +5 -5
  42. package/dist/assets/{mindmap-definition-NLK3R4M7-CEGLBEfc.js → mindmap-definition-NLK3R4M7-oSFMOeAf.js} +1 -1
  43. package/dist/assets/{pegDiagram-GJSIUBJH-DLwMHvoR.js → pegDiagram-GJSIUBJH-DfF1Bylk.js} +1 -1
  44. package/dist/assets/{pieDiagram-5QR66LMP-DHnlu96s.js → pieDiagram-5QR66LMP-B75tQFJV.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-O4NWA36T-C_aIseXA.js → quadrantDiagram-O4NWA36T-Bzost4vl.js} +1 -1
  46. package/dist/assets/{railroadDiagram-XR7U4H2S-DOXDQ14n.js → railroadDiagram-XR7U4H2S-Kj-_EJse.js} +1 -1
  47. package/dist/assets/{requirementDiagram-PLB6GJNP-C49u1hle.js → requirementDiagram-PLB6GJNP-DgGyLbhO.js} +1 -1
  48. package/dist/assets/{sankeyDiagram-IPEJSGJF-TO8i3aYk.js → sankeyDiagram-IPEJSGJF-Ds7nNV4g.js} +1 -1
  49. package/dist/assets/{sequenceDiagram-PO4LG4MO-CqByM3om.js → sequenceDiagram-PO4LG4MO-BherGJTE.js} +1 -1
  50. package/dist/assets/{sizeCapture-INFHLROL-BVsTiKjg.js → sizeCapture-INFHLROL-his3_ohk.js} +1 -1
  51. package/dist/assets/{stateDiagram-v2-GCMORJYK-0AUlHnV-.js → stateDiagram-v2-GCMORJYK-Dm1QWOxb.js} +1 -1
  52. package/dist/assets/{swimlanes-2SLR337P-D_wUrvq4.js → swimlanes-2SLR337P-CCDiiGy4.js} +1 -1
  53. package/dist/assets/swimlanesDiagram-TC7HE7FX-7bU41JJL.js +8 -0
  54. package/dist/assets/{timeline-definition-EJHVYXUP-qf2wxQef.js → timeline-definition-EJHVYXUP-CTgG6kVO.js} +1 -1
  55. package/dist/assets/{usecaseDiagram-POWQR4AR-Blqc8FjE.js → usecaseDiagram-POWQR4AR-B9FjIil8.js} +1 -1
  56. package/dist/assets/{vennDiagram-UO4OBE2U-Df3HJl0f.js → vennDiagram-UO4OBE2U-D_WKiutd.js} +1 -1
  57. package/dist/assets/{wardleyDiagram-VNRHLVJA-B-QhMirM.js → wardleyDiagram-VNRHLVJA-DqAabdPt.js} +1 -1
  58. package/dist/assets/{xychartDiagram-PMCCYNJV-DsZdyUlm.js → xychartDiagram-PMCCYNJV-CYpL8DXw.js} +1 -1
  59. package/dist/index.html +2 -2
  60. package/dist-server/drivers/agents-proxy.js +3 -2
  61. package/dist-server/index.js +1822 -1618
  62. package/dist-server/openmausbot.js +649 -490
  63. package/dist-server/pair-cli.js +649 -490
  64. package/dist-server/server/drivers/acp/core.js +10 -37
  65. package/dist-server/server/drivers/acp/droid.js +1 -0
  66. package/dist-server/server/drivers/acp/gemini.js +10 -0
  67. package/dist-server/server/drivers/acp/kimi.js +1 -0
  68. package/dist-server/server/drivers/acp/mode-readback.js +72 -0
  69. package/dist-server/server/drivers/acp/qwen.js +12 -0
  70. package/dist-server/server/drivers/acp/tool-log.js +40 -0
  71. package/dist-server/server/drivers/acp/vibe.js +14 -1
  72. package/dist-server/server/drivers/agents-catalog.js +2 -2
  73. package/dist-server/server/drivers/chat-mcp-tools.js +21 -1
  74. package/dist-server/server/drivers/openai-chat.js +1 -1
  75. package/dist-server/server/engine-tiers.js +1 -1
  76. package/dist-server/server/free-turn-guard.js +32 -0
  77. package/dist-server/server/incidents.js +9 -2
  78. package/dist-server/server/index.js +40 -21
  79. package/dist-server/server/mcp-secrets.js +33 -5
  80. package/dist-server/server/routes/engine-tiers.js +3 -1
  81. package/dist-server/server/vault/routes.js +1 -1
  82. package/dist-server/server/vault/store.js +1 -1
  83. package/dist-server/shared/approval-readback.js +52 -0
  84. package/dist-server/shared/provider-accounts.js +4 -4
  85. package/dist-server/shared/vault-csv.js +32 -10
  86. package/package.json +1 -1
  87. package/dist/assets/channel-DGEfaLnD.js +0 -1
  88. package/dist/assets/index-D17LLrYN.css +0 -1
  89. package/dist/assets/swimlanesDiagram-TC7HE7FX-HihkzjzX.js +0 -8
@@ -54,6 +54,8 @@ import { isModelRejection } from "../retry.js";
54
54
  import { engineFailureFromCode, isCredentialDead, isOpaqueRequestRejection, logAuthFailure, parseResetAt, resetHintFromData } from "../../engine-failure.js";
55
55
  import { turnMcpServers } from "../turn-mcp.js";
56
56
  import { volatileNote, volatileSectionsOf, withNote } from "../volatile-notes.js";
57
+ import { sanitizeAcpToolMessage } from "./tool-log.js";
58
+ import { armModeReadback, forgetStaleModeReport, noteModeReport, noteModeUpdate } from "./mode-readback.js";
57
59
  /** ACP vendors put the actionable cause in error.data while keeping the
58
60
  * JSON-RPC message generic. Only surface known text fields, never a response
59
61
  * body/config dump, and redact before bounding the displayed diagnostic. */
@@ -171,7 +173,6 @@ function acpVariantOption(result) {
171
173
  ...(typeof option.currentValue === "string" ? { currentValue: option.currentValue } : {}),
172
174
  };
173
175
  }
174
- const TOOL_LOG_TEXT_LIMIT = 64_000;
175
176
  async function readAcpImageBlocks(images) {
176
177
  return Promise.all(images.map(async (image) => ({
177
178
  type: "image",
@@ -179,42 +180,6 @@ async function readAcpImageBlocks(images) {
179
180
  mimeType: image.mime,
180
181
  })));
181
182
  }
182
- function sanitizeToolLogValue(value, budget, depth = 0) {
183
- if (depth > 12 || budget.nodes-- <= 0)
184
- return undefined;
185
- if (typeof value === "string") {
186
- if (/^data:image\//iu.test(value) || budget.text <= 0)
187
- return undefined;
188
- const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
189
- const text = value.length <= limit ? value : `[Earlier output truncated]\n\n${value.slice(-limit)}`;
190
- budget.text -= text.length;
191
- return text;
192
- }
193
- if (Array.isArray(value)) {
194
- return value.flatMap((entry) => {
195
- const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
196
- return sanitized === undefined ? [] : [sanitized];
197
- });
198
- }
199
- if (!value || typeof value !== "object")
200
- return value;
201
- const record = value;
202
- return Object.fromEntries(Object.entries(record).flatMap(([key, entry]) => {
203
- if ((record.type === "image" && (key === "data" || key === "blob")) ||
204
- (key === "blob" && typeof record.mimeType === "string" && record.mimeType.startsWith("image/")))
205
- return [];
206
- const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
207
- return sanitized === undefined ? [] : [[key, sanitized]];
208
- }));
209
- }
210
- function sanitizeAcpToolMessage(message) {
211
- const isToolUpdate = message?.method === "session/update"
212
- && ["tool_call", "tool_call_update"].includes(message?.params?.update?.sessionUpdate);
213
- const isPermission = message?.method === "session/request_permission";
214
- if (!isToolUpdate && !isPermission)
215
- return message;
216
- return sanitizeToolLogValue(message, { nodes: 512, text: TOOL_LOG_TEXT_LIMIT });
217
- }
218
183
  function decodeAcpConfig(defaultCli) {
219
184
  return (raw) => {
220
185
  const o = (raw ?? {});
@@ -796,6 +761,8 @@ export function createAcpDriver(support) {
796
761
  current.receiveModelVariants(p.update);
797
762
  return;
798
763
  }
764
+ if (noteModeUpdate(session, p))
765
+ return;
799
766
  if (!current || !current.state.promptSent)
800
767
  return;
801
768
  const u = p.update ?? {};
@@ -1264,6 +1231,7 @@ export function createAcpDriver(support) {
1264
1231
  loaded = true;
1265
1232
  session.sessionId = cursor;
1266
1233
  session.sessionKey = sessionKey;
1234
+ noteModeReport(session, result);
1267
1235
  receiveModelVariants(result);
1268
1236
  }
1269
1237
  });
@@ -1319,6 +1287,7 @@ export function createAcpDriver(support) {
1319
1287
  sessionResult = await request("session/new", { cwd, mcpServers: sessionServers }, NEW_SESSION_TIMEOUT, (result) => {
1320
1288
  session.sessionId = typeof result?.sessionId === "string" ? result.sessionId : null;
1321
1289
  session.sessionKey = sessionKey;
1290
+ noteModeReport(session, result);
1322
1291
  receiveModelVariants(result);
1323
1292
  });
1324
1293
  break;
@@ -1356,6 +1325,7 @@ export function createAcpDriver(support) {
1356
1325
  }
1357
1326
  }
1358
1327
  if (support.configureSession) {
1328
+ forgetStaleModeReport(session, support);
1359
1329
  const sessionModels = Array.isArray(sessionResult?.models?.availableModels) ? sessionResult.models.availableModels : [];
1360
1330
  const configure = (model) => support.configureSession({
1361
1331
  request: (method, params, timeoutMs) => request(method, params, timeoutMs ?? SESSION_CONFIG_TIMEOUT),
@@ -1436,6 +1406,9 @@ export function createAcpDriver(support) {
1436
1406
  if (turn.variant !== undefined && requestedVariantOption().currentValue !== turn.variant) {
1437
1407
  throw new Error(`${support.displayName} changed variant before the prompt`);
1438
1408
  }
1409
+ armModeReadback({ support, session, config: turnConfig, turn: cliTurn, isCurrent: () => session.current === current && !current.state.settled,
1410
+ log: (readback) => appendNative(threadId, { dir: "out", source: SOURCE, msg: { approvalReadback: readback } }),
1411
+ stop: (message) => { emit({ ...base(threadId, turnId), type: "runtime.error", message }); interrupt(); } });
1439
1412
  state.promptSent = true;
1440
1413
  const promptIdleMs = promptIdleTimeoutMs(support, cliTurn.model);
1441
1414
  const result = await request("session/prompt", { sessionId, prompt: [{ type: "text", text }, ...imageBlocks] }, undefined, undefined, promptIdleMs, `${DRIVER_KIND} went fully silent ${Math.round(promptIdleMs / 1000)} s after the message and the turn was stopped. ` +
@@ -177,6 +177,7 @@ const MODELS = {
177
177
  };
178
178
  const support = {
179
179
  driverKind: "droidAgent",
180
+ approvalModeReadback: { ladder: "droidAgent", expected: (config) => (config.fullAuto ? MODE_FULL_AUTO : MODE_DEFAULT), setsModeOverWire: true },
180
181
  displayName: "Droid",
181
182
  models: MODELS,
182
183
  defaultCli: "droid",
@@ -74,8 +74,18 @@ export function geminiApprovalArgs(fullAuto, approvalMode) {
74
74
  return ["--approval-mode", "auto_edit"];
75
75
  return [];
76
76
  }
77
+ /** The ACP session mode geminiApprovalArgs should leave Gemini in. */
78
+ export function geminiExpectedMode(fullAuto, approvalMode) {
79
+ if (fullAuto)
80
+ return "yolo";
81
+ if (approvalMode === "edits")
82
+ return "autoEdit";
83
+ return "default";
84
+ }
77
85
  const support = {
78
86
  driverKind: "geminiAgent",
87
+ // Gemini takes the mode on argv; session/new reports the one it applied.
88
+ approvalModeReadback: { ladder: "geminiAgent", expected: (config, turn) => geminiExpectedMode(config.fullAuto, turn.approvalMode) },
79
89
  displayName: "Gemini",
80
90
  models: {
81
91
  default: "gemini-2.5-pro",
@@ -507,6 +507,7 @@ function readKimiModelCatalog(env) {
507
507
  }
508
508
  const support = {
509
509
  driverKind: "kimiAgent",
510
+ approvalModeReadback: { ladder: "kimiAgent", expected: (config) => kimiSessionMode(config.fullAuto), setsModeOverWire: true },
510
511
  displayName: "Kimi",
511
512
  // Aliases from the CLI's own catalog (~/.kimi-code/config.toml
512
513
  // [models."kimi-code/…"] — `kimi provider list` reports the same four).
@@ -0,0 +1,72 @@
1
+ // ACP engines: read back the approval mode the agent actually applied
2
+ // (shared/approval-readback.ts has the comparison and the wording).
3
+ //
4
+ // The agent reports its mode in session/new or session/load
5
+ // (`modes.currentModeId`) and in `current_mode_update` notifications. A turn
6
+ // whose agent reports a LOOSER mode than requested is stopped before the
7
+ // prompt is sent, or interrupted if the report arrives mid-turn. An agent
8
+ // that does not report is logged as unverified: Atomic's permission broker
9
+ // still sees every request it does send.
10
+ import { compareEffectiveMode, looserModeMessage } from "../../../shared/approval-readback.js";
11
+ const states = new WeakMap();
12
+ const stateOf = (session) => {
13
+ let state = states.get(session);
14
+ if (!state)
15
+ states.set(session, (state = { reported: null }));
16
+ return state;
17
+ };
18
+ /** The mode the agent last reported on this native session, if any. */
19
+ export function reportedMode(session) {
20
+ return states.get(session)?.reported ?? null;
21
+ }
22
+ /** session/new or session/load answered: keep `modes.currentModeId`. */
23
+ export function noteModeReport(session, result) {
24
+ const id = result?.modes?.currentModeId;
25
+ if (typeof id === "string" && id)
26
+ stateOf(session).reported = id;
27
+ }
28
+ /** A session/update params object. True when it was a current_mode_update
29
+ * (recorded, and re-checked against a running turn). */
30
+ export function noteModeUpdate(session, raw) {
31
+ const params = raw;
32
+ if (params?.update?.sessionUpdate !== "current_mode_update")
33
+ return false;
34
+ if (session.sessionId && params.sessionId === session.sessionId && typeof params.update.currentModeId === "string") {
35
+ const state = stateOf(session);
36
+ state.reported = params.update.currentModeId;
37
+ state.onReported?.();
38
+ }
39
+ return true;
40
+ }
41
+ /** Before configureSession sends session/set_mode, an earlier report is stale. */
42
+ export function forgetStaleModeReport(session, support) {
43
+ if (support.approvalModeReadback?.setsModeOverWire)
44
+ stateOf(session).reported = null;
45
+ }
46
+ /** Compare what this turn asked for with what the agent reported. */
47
+ export function approvalReadbackFor(support, config, turn, reported) {
48
+ const rules = support.approvalModeReadback;
49
+ if (!rules)
50
+ return { status: "unverified", requested: null, reported };
51
+ return compareEffectiveMode(rules.ladder, rules.expected(config, turn), reported);
52
+ }
53
+ /** Called right before session/prompt. Throws (the turn fails) when the agent
54
+ * already reported a looser mode; logs an unverified one; and watches for a
55
+ * later looser report while the turn runs. */
56
+ export function armModeReadback(input) {
57
+ const { support, session, config, turn } = input;
58
+ const state = stateOf(session);
59
+ const now = approvalReadbackFor(support, config, turn, state.reported);
60
+ if (now.status === "looser")
61
+ throw new Error(looserModeMessage(support.displayName, now));
62
+ if (now.status === "unverified")
63
+ input.log(now);
64
+ state.onReported = () => {
65
+ if (!input.isCurrent())
66
+ return;
67
+ const later = approvalReadbackFor(support, config, turn, state.reported);
68
+ input.log(later);
69
+ if (later.status === "looser")
70
+ input.stop(looserModeMessage(support.displayName, later));
71
+ };
72
+ }
@@ -220,8 +220,20 @@ export function qwenApprovalArgs(fullAuto, approvalMode) {
220
220
  return ["--approval-mode", "auto-edit"];
221
221
  return [];
222
222
  }
223
+ /** The ACP session mode qwenApprovalArgs should leave Qwen in. */
224
+ export function qwenExpectedMode(fullAuto, approvalMode) {
225
+ if (fullAuto)
226
+ return "yolo";
227
+ if (approvalMode === "auto")
228
+ return "auto";
229
+ if (approvalMode === "edits")
230
+ return "auto-edit";
231
+ return "default";
232
+ }
223
233
  const support = {
224
234
  driverKind: "qwenAgent",
235
+ // Qwen takes the mode on argv; session/new reports the one it applied.
236
+ approvalModeReadback: { ladder: "qwenAgent", expected: (config, turn) => qwenExpectedMode(config.fullAuto, turn.approvalMode) },
225
237
  displayName: "Qwen",
226
238
  access: "custom",
227
239
  models: EMPTY,
@@ -0,0 +1,40 @@
1
+ // Native-log copies of ACP tool traffic, kept small: image bytes are dropped
2
+ // and long text is cut to its tail. Moved out of core.ts unchanged.
3
+ const TOOL_LOG_TEXT_LIMIT = 64_000;
4
+ function sanitizeToolLogValue(value, budget, depth = 0) {
5
+ if (depth > 12 || budget.nodes-- <= 0)
6
+ return undefined;
7
+ if (typeof value === "string") {
8
+ if (/^data:image\//iu.test(value) || budget.text <= 0)
9
+ return undefined;
10
+ const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
11
+ const text = value.length <= limit ? value : `[Earlier output truncated]\n\n${value.slice(-limit)}`;
12
+ budget.text -= text.length;
13
+ return text;
14
+ }
15
+ if (Array.isArray(value)) {
16
+ return value.flatMap((entry) => {
17
+ const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
18
+ return sanitized === undefined ? [] : [sanitized];
19
+ });
20
+ }
21
+ if (!value || typeof value !== "object")
22
+ return value;
23
+ const record = value;
24
+ return Object.fromEntries(Object.entries(record).flatMap(([key, entry]) => {
25
+ if ((record.type === "image" && (key === "data" || key === "blob")) ||
26
+ (key === "blob" && typeof record.mimeType === "string" && record.mimeType.startsWith("image/")))
27
+ return [];
28
+ const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
29
+ return sanitized === undefined ? [] : [[key, sanitized]];
30
+ }));
31
+ }
32
+ export function sanitizeAcpToolMessage(message) {
33
+ const m = message;
34
+ const isToolUpdate = m?.method === "session/update"
35
+ && ["tool_call", "tool_call_update"].includes(m?.params?.update?.sessionUpdate);
36
+ const isPermission = m?.method === "session/request_permission";
37
+ if (!isToolUpdate && !isPermission)
38
+ return message;
39
+ return sanitizeToolLogValue(message, { nodes: 512, text: TOOL_LOG_TEXT_LIMIT });
40
+ }
@@ -2,6 +2,7 @@ import { PROVIDER_CREDENTIAL_ENV, stripControlPlaneEnv, WORKSPACE_CREDENTIAL_ENV
2
2
  import { augmentedPath } from "../../env-path.js";
3
3
  import { VibeLoginController, vibeSignedIn } from "../vibe-login.js";
4
4
  import { createAcpDriver } from "./core.js";
5
+ import { assertEffectiveModeNotLooser } from "../../../shared/approval-readback.js";
5
6
  export const VIBE_DRIVER_KIND = "vibeAgent";
6
7
  /** Vibe's own model aliases (vibe/core/config/vibe_schema.py, 3.x): Medium
7
8
  * 3.5 is its default, a 256K-context model Mistral tunes for coding. */
@@ -14,6 +15,14 @@ const MODELS = {
14
15
  * tool call and asks only for risky ones), Edits is `accept-edits`, and every
15
16
  * other level is `ask`, so a session Vibe saved in a looser mode never
16
17
  * carries into an Ask turn. */
18
+ /** The "mode" option's current value in a set_config_option reply, if any. */
19
+ export function vibeReportedMode(reply) {
20
+ const options = reply?.configOptions;
21
+ if (!Array.isArray(options))
22
+ return null;
23
+ const mode = options.find((option) => option && typeof option === "object" && option.id === "mode");
24
+ return typeof mode?.currentValue === "string" ? mode.currentValue : null;
25
+ }
17
26
  export function vibeSessionMode(fullAuto, approvalMode) {
18
27
  if (fullAuto)
19
28
  return "auto-approve";
@@ -63,12 +72,16 @@ const support = {
63
72
  isAuthenticated: (env, config, instanceId) => cachedSignedIn(`${instanceId}:${env.VIBE_HOME ?? ""}`, () => vibeSignedIn(config.cli || "vibe-acp", env)),
64
73
  async configureSession({ request, sessionId, config, turn }) {
65
74
  const value = vibeSessionMode(config.fullAuto, turn.approvalMode);
75
+ let reply;
66
76
  try {
67
- await request("session/set_config_option", { sessionId, configId: "mode", value });
77
+ reply = await request("session/set_config_option", { sessionId, configId: "mode", value });
68
78
  }
69
79
  catch (e) {
70
80
  throw new Error(`Mistral Vibe rejected permission mode "${value}": ${e.message}. Update Mistral Vibe (3.0 or newer).`);
71
81
  }
82
+ // The reply carries the config options as applied: the mode must not
83
+ // come back looser than asked (shared/approval-readback.ts).
84
+ assertEffectiveModeNotLooser("Mistral Vibe", "vibeAgent", value, vibeReportedMode(reply));
72
85
  },
73
86
  buildPromptText: (turn) => (turn.system ? `${turn.system}\n\n${turn.text}` : turn.text),
74
87
  };
@@ -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", freeModel: env.OMB_FREE_MODEL === "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 = profile.threatScan ? ALL_TOOLS : ALL_TOOLS.filter((tool) => tool.name !== "threat_scan");
755
+ const TOOLS = ALL_TOOLS.filter((tool) => (profile.threatScan || tool.name !== "threat_scan") && !(profile.freeModel && tool.name.startsWith("nexus_")));
756
756
  const AUTHORING_TOOLS = profile.skillAuthoring
757
757
  ? TOOLS
758
758
  : TOOLS.filter((tool) => !SKILL_TOOL_NAMES.has(tool.name));
@@ -1,5 +1,6 @@
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";
3
4
  import { Ajv } from "ajv";
4
5
  import { Ajv2020 } from "ajv/dist/2020.js";
5
6
  import formats from "ajv-formats";
@@ -274,7 +275,23 @@ function boundedText(value) {
274
275
  * that will not start, advertises tools this runtime cannot use, or breaks
275
276
  * during a call is dropped for the rest of the turn, the model is told, and
276
277
  * the harness hears (`report`). Atomic's own servers stay all-or-nothing. */
277
- export async function mountChatTools(integrations, signal, computerUse = false, report = reportMcpFailure) {
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 = []) {
278
295
  const servers = [];
279
296
  if (computerUse && integrations?.computer)
280
297
  servers.push(["computer", integrations.computer]);
@@ -421,6 +438,9 @@ export async function mountChatTools(integrations, signal, computerUse = false,
421
438
  throw new Error(`The "${tool.server}" tools stopped working earlier in this turn and are unavailable now; carry on without them.`);
422
439
  if (!object(args) || !tool.schema(args))
423
440
  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
+ }
424
444
  };
425
445
  return {
426
446
  definitions, validate, close,
@@ -298,7 +298,7 @@ export function createOpenAIChatRuntime(options) {
298
298
  const denials = [];
299
299
  const seenCalls = new Set();
300
300
  try {
301
- tools = await mountChatTools(options.tools === false ? undefined : turn.integrations, abort.signal, options.computerUse);
301
+ tools = await mountChatTools(options.tools === false ? undefined : turn.integrations, abort.signal, options.computerUse, undefined, turn.blockedPaths);
302
302
  for (let round = 0; round < 16; round++) {
303
303
  abort.signal.throwIfAborted();
304
304
  native("out", options.nativeLog.outgoing(turn, messages, model));
@@ -463,7 +463,7 @@ export function engineLabel(candidates, selection) {
463
463
  const candidate = candidates.find((entry) => entry.instanceId === selection.instanceId);
464
464
  const name = candidate?.displayName ?? selection.instanceId;
465
465
  const model = candidate?.models.options.find((option) => option.id === selection.model)?.label ?? selection.model;
466
- return model && model !== name ? `${name} · ${model}` : name;
466
+ return `${model && model !== name ? `${name} · ${model}` : name}${candidate && freeCandidate(candidate) ? " · free" : ""}`;
467
467
  }
468
468
  /** The account an engine is signed in to, as resting keys it. */
469
469
  export const engineAccount = (candidate) => candidate.snapshot.account?.email ?? candidate.snapshot.account?.organization;
@@ -0,0 +1,32 @@
1
+ // A turn on a free-tier engine never sees Nexus or PAW (docs/specs/free-models-in-auto).
2
+ // Free providers may keep and train on what they are sent, so such a turn gets
3
+ // no Nexus tools, no PAW, ICM, Nexus or About-the-user context, and no tool
4
+ // call that names the PAW or ICM folders.
5
+ import { accountProvider } from "../shared/provider-accounts.js";
6
+ import { isChibitekNexus } from "./company-mcp-tenancy.js";
7
+ /** Threads whose current turn runs on a free-tier engine. */
8
+ const freeTurnThreads = new Set();
9
+ /** Marks the thread's turn free or paid and, when free, strips the Nexus MCP
10
+ * server and the nexus_recall / nexus_file tools from its integrations.
11
+ * Returns the folders its tool calls may not name, or undefined on a paid turn. */
12
+ export function guardFreeTurn(threadId, account, integrations, roots) {
13
+ if (accountProvider(account)?.billing !== "free") {
14
+ freeTurnThreads.delete(threadId);
15
+ return undefined;
16
+ }
17
+ freeTurnThreads.add(threadId);
18
+ if (integrations.custom) {
19
+ integrations.custom = Object.fromEntries(Object.entries(integrations.custom).filter(([, server]) => !isChibitekNexus(server)));
20
+ if (!Object.keys(integrations.custom).length)
21
+ delete integrations.custom;
22
+ }
23
+ if (integrations.agents)
24
+ integrations.agents.env = { ...integrations.agents.env, OMB_FREE_MODEL: "1" };
25
+ return roots.filter(Boolean);
26
+ }
27
+ /** Why the Nexus endpoint refuses this thread's turn, if it does. */
28
+ export function freeTurnNexusRefusal(threadId) {
29
+ return freeTurnThreads.has(threadId)
30
+ ? "This turn runs on a free model, so Nexus is off limits: free providers may keep and train on what they are sent."
31
+ : undefined;
32
+ }
@@ -11,6 +11,9 @@
11
11
  // The policy here is pure so it can be read and tested on its own; the
12
12
  // harness (server/index.ts) supplies the store and starts the turns.
13
13
  import { canAccessTeam, peerAllowed, reachesEveryTeam } from "./peer-roster.js";
14
+ /** A fallback, or a turn that ran on without a broken tool server: the run
15
+ * went on, nothing needs a retry. */
16
+ export const runWentOn = (kind) => kind === "model-fallback" || kind === "engine-fallback" || kind === "free-fallback" || kind === "mcp-unavailable";
14
17
  export const INCIDENTS_THREAD_TITLE = "Team incidents";
15
18
  const sectionKey = (section) => section?.trim() || "";
16
19
  /** The Chief responsible for a bot: the Chief of the bot's own section, else
@@ -78,6 +81,8 @@ function whatHappened(incident) {
78
81
  return `${incident.bot.name}'s run ${where} continued on another model because its engine refused the one it was set to${detail}`;
79
82
  case "engine-fallback":
80
83
  return `${incident.bot.name}'s run ${where} continued on another engine after its selected engine failed${detail}`;
84
+ case "free-fallback":
85
+ return `${incident.bot.name}'s run ${where} ran on a free model because no subscription or pay-per-use engine could take it${detail}`;
81
86
  case "mcp-unavailable":
82
87
  return `${incident.bot.name}'s run ${where} continued without one of its tool servers${detail}`;
83
88
  default:
@@ -101,7 +106,7 @@ export function incidentText(incident, count) {
101
106
  lines.push(`${incident.bot.name} last said: "${fold(incident.lastReply, 300)}"`);
102
107
  if (count.count > 1)
103
108
  lines.push(`This is the ${ordinal(count.count)} incident on that thread within the hour.`);
104
- if (incident.kind === "model-fallback" || incident.kind === "engine-fallback" || incident.kind === "mcp-unavailable") {
109
+ if (runWentOn(incident.kind)) {
105
110
  // Nothing broke: the turn ran. The failed selection, engine or tool
106
111
  // server still needs attention, but the completed work must never be retried.
107
112
  lines.push("The run was not interrupted and needs no retry; do not call retry_thread.");
@@ -109,7 +114,9 @@ export function incidentText(incident, count) {
109
114
  ? "Tell the person in one or two plain sentences that this engine no longer offers that model and that the bot's or the conversation's model setting should be changed, then stop."
110
115
  : incident.kind === "mcp-unavailable"
111
116
  ? "Tell the person in one or two plain sentences which tool server is not working, that bots carry on without it until it answers again, and that its command and settings in Settings may need a look, then stop."
112
- : "Use the incident detail to correct the failed engine if action is needed, then report what happened in one or two plain sentences and stop.");
117
+ : incident.kind === "free-fallback"
118
+ ? "Tell the person in one or two plain sentences that the turn ran on a free model, which engines were out, and that a subscription or key needs attention to stop relying on the free band, then stop."
119
+ : "Use the incident detail to correct the failed engine if action is needed, then report what happened in one or two plain sentences and stop.");
113
120
  return lines.join("\n");
114
121
  }
115
122
  lines.push(count.mayRetry