@monoes/monomindcli 2.13.0 → 2.14.0

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 (136) hide show
  1. package/dist/src/commands/doctor-mcp-probe.d.ts +48 -0
  2. package/dist/src/commands/doctor-mcp-probe.d.ts.map +1 -0
  3. package/dist/src/commands/doctor-mcp-probe.js +205 -0
  4. package/dist/src/commands/doctor-mcp-probe.js.map +1 -0
  5. package/dist/src/commands/doctor-project-checks.d.ts +12 -1
  6. package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
  7. package/dist/src/commands/doctor-project-checks.js +55 -4
  8. package/dist/src/commands/doctor-project-checks.js.map +1 -1
  9. package/dist/src/commands/doctor.d.ts.map +1 -1
  10. package/dist/src/commands/doctor.js +10 -1
  11. package/dist/src/commands/doctor.js.map +1 -1
  12. package/dist/src/commands/init.d.ts.map +1 -1
  13. package/dist/src/commands/init.js +17 -0
  14. package/dist/src/commands/init.js.map +1 -1
  15. package/dist/src/commands/mcp.d.ts.map +1 -1
  16. package/dist/src/commands/mcp.js +4 -3
  17. package/dist/src/commands/mcp.js.map +1 -1
  18. package/dist/src/commands/org-observe.d.ts.map +1 -1
  19. package/dist/src/commands/org-observe.js +14 -0
  20. package/dist/src/commands/org-observe.js.map +1 -1
  21. package/dist/src/commands/org.d.ts.map +1 -1
  22. package/dist/src/commands/org.js +12 -2
  23. package/dist/src/commands/org.js.map +1 -1
  24. package/dist/src/init/claudemd-generator.d.ts.map +1 -1
  25. package/dist/src/init/claudemd-generator.js +2 -1
  26. package/dist/src/init/claudemd-generator.js.map +1 -1
  27. package/dist/src/init/mcp-generator.d.ts.map +1 -1
  28. package/dist/src/init/mcp-generator.js +3 -3
  29. package/dist/src/init/mcp-generator.js.map +1 -1
  30. package/dist/src/init/types.d.ts +6 -0
  31. package/dist/src/init/types.d.ts.map +1 -1
  32. package/dist/src/init/types.js.map +1 -1
  33. package/dist/src/init/write-runtime-config.d.ts.map +1 -1
  34. package/dist/src/init/write-runtime-config.js +12 -2
  35. package/dist/src/init/write-runtime-config.js.map +1 -1
  36. package/dist/src/orgrt/agent-runner.d.ts +38 -0
  37. package/dist/src/orgrt/agent-runner.d.ts.map +1 -1
  38. package/dist/src/orgrt/agent-runner.js +47 -0
  39. package/dist/src/orgrt/agent-runner.js.map +1 -1
  40. package/dist/src/orgrt/checkpoint.d.ts +12 -1
  41. package/dist/src/orgrt/checkpoint.d.ts.map +1 -1
  42. package/dist/src/orgrt/checkpoint.js +15 -6
  43. package/dist/src/orgrt/checkpoint.js.map +1 -1
  44. package/dist/src/orgrt/completion-gate.d.ts +74 -0
  45. package/dist/src/orgrt/completion-gate.d.ts.map +1 -1
  46. package/dist/src/orgrt/completion-gate.js +45 -0
  47. package/dist/src/orgrt/completion-gate.js.map +1 -1
  48. package/dist/src/orgrt/cost-tier.d.ts +144 -0
  49. package/dist/src/orgrt/cost-tier.d.ts.map +1 -0
  50. package/dist/src/orgrt/cost-tier.js +183 -0
  51. package/dist/src/orgrt/cost-tier.js.map +1 -0
  52. package/dist/src/orgrt/cross-org.d.ts.map +1 -1
  53. package/dist/src/orgrt/cross-org.js +14 -0
  54. package/dist/src/orgrt/cross-org.js.map +1 -1
  55. package/dist/src/orgrt/daemon.d.ts +12 -1
  56. package/dist/src/orgrt/daemon.d.ts.map +1 -1
  57. package/dist/src/orgrt/daemon.js +216 -49
  58. package/dist/src/orgrt/daemon.js.map +1 -1
  59. package/dist/src/orgrt/decisions.d.ts +14 -2
  60. package/dist/src/orgrt/decisions.d.ts.map +1 -1
  61. package/dist/src/orgrt/decisions.js +216 -10
  62. package/dist/src/orgrt/decisions.js.map +1 -1
  63. package/dist/src/orgrt/file-roots.d.ts +7 -0
  64. package/dist/src/orgrt/file-roots.d.ts.map +1 -1
  65. package/dist/src/orgrt/file-roots.js +38 -1
  66. package/dist/src/orgrt/file-roots.js.map +1 -1
  67. package/dist/src/orgrt/forwarder.d.ts.map +1 -1
  68. package/dist/src/orgrt/forwarder.js +16 -2
  69. package/dist/src/orgrt/forwarder.js.map +1 -1
  70. package/dist/src/orgrt/idle-deadline.d.ts +74 -1
  71. package/dist/src/orgrt/idle-deadline.d.ts.map +1 -1
  72. package/dist/src/orgrt/idle-deadline.js +52 -2
  73. package/dist/src/orgrt/idle-deadline.js.map +1 -1
  74. package/dist/src/orgrt/loadouts.d.ts +38 -0
  75. package/dist/src/orgrt/loadouts.d.ts.map +1 -0
  76. package/dist/src/orgrt/loadouts.js +129 -0
  77. package/dist/src/orgrt/loadouts.js.map +1 -0
  78. package/dist/src/orgrt/mailbox.d.ts +17 -1
  79. package/dist/src/orgrt/mailbox.d.ts.map +1 -1
  80. package/dist/src/orgrt/mailbox.js +50 -3
  81. package/dist/src/orgrt/mailbox.js.map +1 -1
  82. package/dist/src/orgrt/policy.d.ts +42 -2
  83. package/dist/src/orgrt/policy.d.ts.map +1 -1
  84. package/dist/src/orgrt/policy.js +53 -8
  85. package/dist/src/orgrt/policy.js.map +1 -1
  86. package/dist/src/orgrt/prompt-vars.d.ts +11 -0
  87. package/dist/src/orgrt/prompt-vars.d.ts.map +1 -0
  88. package/dist/src/orgrt/prompt-vars.js +49 -0
  89. package/dist/src/orgrt/prompt-vars.js.map +1 -0
  90. package/dist/src/orgrt/questions.d.ts +22 -1
  91. package/dist/src/orgrt/questions.d.ts.map +1 -1
  92. package/dist/src/orgrt/questions.js +24 -3
  93. package/dist/src/orgrt/questions.js.map +1 -1
  94. package/dist/src/orgrt/review-packet.d.ts +29 -0
  95. package/dist/src/orgrt/review-packet.d.ts.map +1 -0
  96. package/dist/src/orgrt/review-packet.js +67 -0
  97. package/dist/src/orgrt/review-packet.js.map +1 -0
  98. package/dist/src/orgrt/role-sandbox.d.ts.map +1 -1
  99. package/dist/src/orgrt/role-sandbox.js +16 -3
  100. package/dist/src/orgrt/role-sandbox.js.map +1 -1
  101. package/dist/src/orgrt/session-ledger.d.ts +61 -0
  102. package/dist/src/orgrt/session-ledger.d.ts.map +1 -0
  103. package/dist/src/orgrt/session-ledger.js +113 -0
  104. package/dist/src/orgrt/session-ledger.js.map +1 -0
  105. package/dist/src/orgrt/session.d.ts +45 -5
  106. package/dist/src/orgrt/session.d.ts.map +1 -1
  107. package/dist/src/orgrt/session.js +384 -27
  108. package/dist/src/orgrt/session.js.map +1 -1
  109. package/dist/src/orgrt/task-dag.d.ts +34 -1
  110. package/dist/src/orgrt/task-dag.d.ts.map +1 -1
  111. package/dist/src/orgrt/task-dag.js +58 -7
  112. package/dist/src/orgrt/task-dag.js.map +1 -1
  113. package/dist/src/orgrt/tool-spill.d.ts +94 -0
  114. package/dist/src/orgrt/tool-spill.d.ts.map +1 -0
  115. package/dist/src/orgrt/tool-spill.js +180 -0
  116. package/dist/src/orgrt/tool-spill.js.map +1 -0
  117. package/dist/src/orgrt/types.d.ts +138 -0
  118. package/dist/src/orgrt/types.d.ts.map +1 -1
  119. package/dist/src/orgrt/types.js +148 -0
  120. package/dist/src/orgrt/types.js.map +1 -1
  121. package/dist/src/platform-adapters/renderers/mcp.d.ts +20 -2
  122. package/dist/src/platform-adapters/renderers/mcp.d.ts.map +1 -1
  123. package/dist/src/platform-adapters/renderers/mcp.js +25 -5
  124. package/dist/src/platform-adapters/renderers/mcp.js.map +1 -1
  125. package/dist/src/protocol-capabilities.d.ts +2 -1
  126. package/dist/src/protocol-capabilities.d.ts.map +1 -1
  127. package/dist/src/protocol-capabilities.js +2 -1
  128. package/dist/src/protocol-capabilities.js.map +1 -1
  129. package/dist/src/ui/dashboard.html +450 -164
  130. package/dist/src/ui/org-hil.mjs +276 -0
  131. package/dist/src/ui/org-runtime.mjs +350 -0
  132. package/dist/src/ui/orgs.html +15 -4
  133. package/dist/src/ui/routes-org.mjs +290 -541
  134. package/dist/src/ui/server.mjs +25 -5
  135. package/dist/tsconfig.tsbuildinfo +1 -1
  136. package/package.json +6 -5
@@ -0,0 +1,180 @@
1
+ // packages/@monomind/cli/src/orgrt/tool-spill.ts
2
+ /**
3
+ * ADR-O001 D2 — spill-and-reference for tool results.
4
+ *
5
+ * Measured on one real run: tool results are 76% of all context mass (Bash
6
+ * 4,387 calls / 5.7M chars and Read 420 / 2.0M chars are 97% of that), while
7
+ * inter-agent mail is 0.1%. A role holds ONE SDK session for its whole life
8
+ * with no truncation anywhere in orgrt/, so every tool result it ever saw is
9
+ * re-sent on every later turn — cost is roughly quadratic in turns.
10
+ *
11
+ * The mechanism already existed, pointed at the 0.1% channel: cross-org.ts's
12
+ * `mailBody` writes an oversized mail body to `.mail/<id>.md` and leaves a
13
+ * 1,024-char digest plus a path in context. This is the same shape, applied to
14
+ * the channel that carries the mass — same "write in full FIRST, digest
15
+ * second" ordering, same "on write failure deliver in full rather than lose
16
+ * content" fallback.
17
+ *
18
+ * ── Threshold arithmetic (why 2,048) ──────────────────────────────────────
19
+ * Result sizes: p50 451, p75 1,583, p90 3,506, p95 5,138, p99 11,739, max
20
+ * 59,805, mean 1,370. It is a long tail of SMALL results, so the usual "only
21
+ * spill the monsters" instinct recovers almost nothing:
22
+ *
23
+ * threshold spilled calls net tool mass recovered
24
+ * 11,739 (p99) 1.0% 21%
25
+ * 5,138 (p95) 5.0% 37%
26
+ * 4,096 (mail's) 8.2% 42%
27
+ * 3,506 (p90) 10.0% 45%
28
+ * 2,048 21.4% 52% ← chosen
29
+ * 1,536 (p75) 26.0% 52%
30
+ *
31
+ * Two constraints fix the choice. Below, a spilled result still costs its
32
+ * digest (1,536) plus a reference line (~160) — about 1,700 chars — so any
33
+ * threshold under ~1,700 ADDS mass instead of removing it; that is the floor.
34
+ * Above, the curve is flat from 1,536 to ~3,000 and then falls away, so 2,048
35
+ * (= 2× the mail digest) sits at the knee: it takes essentially all the
36
+ * recoverable mass while leaving four fifths of all calls untouched, which is
37
+ * what keeps a role able to do its job.
38
+ *
39
+ * ── Digest strategy ───────────────────────────────────────────────────────
40
+ * Never a blind one-sided truncation. A Bash result puts what matters at the
41
+ * END (assertion failures, the summary line, the exit status); a Read puts it
42
+ * at the START. So the digest is always head + elision note + tail, with the
43
+ * WEIGHT flipped by tool: 1/3 head + 2/3 tail for command-shaped tools
44
+ * (the default, since Bash dominates), 2/3 head + 1/3 tail for file-shaped
45
+ * ones.
46
+ *
47
+ * The response object's SHAPE is preserved — only its long string leaves are
48
+ * digested, and the budget is water-filled across them smallest-first, so a
49
+ * short `stderr` next to a huge `stdout` survives whole.
50
+ */
51
+ import { mkdirSync, writeFileSync } from 'node:fs';
52
+ import { join } from 'node:path';
53
+ /** Results at or under this stay byte-identical. See the threshold arithmetic
54
+ * in the module comment — this is the knee of the recovery curve, not a
55
+ * round number. */
56
+ export const TOOL_RESULT_MAX = 2048;
57
+ /** Total digest text a spilled result may keep in context, across all of its
58
+ * string leaves. 1.5× cross-org.ts's MAIL_DIGEST_CHARS: a tool result has to
59
+ * carry a stack trace where a mail body only has to carry a subject. */
60
+ export const TOOL_DIGEST_CHARS = 1536;
61
+ /** Tools whose output is read top-down — the head is the useful end. Everything
62
+ * else is treated as command-shaped (tail-weighted), because Bash is 76% of
63
+ * the calls and an unknown tool is far more likely to be command-shaped. */
64
+ const HEAD_WEIGHTED = new Set(['Read', 'NotebookRead', 'Glob', 'Grep', 'WebFetch']);
65
+ /** Every string leaf of a tool response, in a stable traversal order that
66
+ * `rebuild` replays exactly. */
67
+ function collect(value, label, out) {
68
+ if (typeof value === 'string') {
69
+ out.push({ value, label });
70
+ return;
71
+ }
72
+ if (Array.isArray(value)) {
73
+ value.forEach((v, i) => collect(v, label ? `${label}[${i}]` : `[${i}]`, out));
74
+ return;
75
+ }
76
+ if (value && typeof value === 'object')
77
+ for (const [k, v] of Object.entries(value))
78
+ collect(v, label ? `${label}.${k}` : k, out);
79
+ }
80
+ /** Same traversal as `collect`, substituting each leaf from `next` in order. */
81
+ function rebuild(value, next) {
82
+ if (typeof value === 'string')
83
+ return next();
84
+ if (Array.isArray(value))
85
+ return value.map((v) => rebuild(v, next));
86
+ if (value && typeof value === 'object')
87
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, rebuild(v, next)]));
88
+ return value;
89
+ }
90
+ /** head + note + tail, weighted by tool kind. `keep` is the character budget
91
+ * for the retained text; the note is on top of it (it is the pointer, not
92
+ * content, and dropping it would make the spill unrecoverable). */
93
+ function digest(value, keep, headWeighted, file) {
94
+ if (value.length <= keep)
95
+ return value;
96
+ const head = Math.round(keep * (headWeighted ? 2 / 3 : 1 / 3));
97
+ const tail = keep - head;
98
+ const elided = value.length - keep;
99
+ const note = `\n\n[... ${elided} chars elided — full tool result at ${file} — Read it if needed]\n\n`;
100
+ return value.slice(0, head) + note + (tail > 0 ? value.slice(value.length - tail) : '');
101
+ }
102
+ /** What gets written to disk: the raw text when only one leaf carries content
103
+ * (the overwhelmingly common case — Bash with an empty stderr, or a plain
104
+ * string response), otherwise labelled sections so a multi-leaf response
105
+ * stays readable AND attributable. Empty leaves are omitted: they carry no
106
+ * data and a `=== stderr ===` with nothing under it only makes the file
107
+ * harder to read. */
108
+ function renderFull(leaves) {
109
+ const filled = leaves.filter((l) => l.value.length > 0);
110
+ if (filled.length === 1)
111
+ return filled[0].value;
112
+ return filled.map((l) => `=== ${l.label} ===\n${l.value}`).join('\n\n');
113
+ }
114
+ /**
115
+ * Bound one tool result. Returns undefined when nothing needs doing (the
116
+ * result is at or under TOOL_RESULT_MAX) or when the spill write failed — in
117
+ * both cases the caller leaves the original result alone, so content is never
118
+ * lost to a disk error.
119
+ */
120
+ export function spillToolResult(dir, toolName, toolUseId, response) {
121
+ const leaves = [];
122
+ collect(response, '', leaves);
123
+ const total = leaves.reduce((n, l) => n + l.value.length, 0);
124
+ if (total <= TOOL_RESULT_MAX)
125
+ return undefined;
126
+ // Full body to disk FIRST — nothing is elided until it is recoverable.
127
+ const file = join(dir, `${toolUseId.replace(/[^a-zA-Z0-9_-]/g, '_')}.txt`);
128
+ try {
129
+ mkdirSync(dir, { recursive: true });
130
+ writeFileSync(file, renderFull(leaves));
131
+ }
132
+ catch {
133
+ return undefined; // spill failed — deliver in full rather than lose content
134
+ }
135
+ // Water-fill the digest budget smallest-leaf-first: short leaves (a 200-char
136
+ // stderr) keep every character, and whatever is left over goes to the leaf
137
+ // that actually carries the mass. Total retained text <= TOOL_DIGEST_CHARS.
138
+ const headWeighted = HEAD_WEIGHTED.has(toolName);
139
+ const keeps = new Map();
140
+ let remaining = TOOL_DIGEST_CHARS;
141
+ const ascending = [...leaves].sort((a, b) => a.value.length - b.value.length);
142
+ ascending.forEach((leaf, i) => {
143
+ const share = Math.floor(remaining / (ascending.length - i));
144
+ const keep = Math.min(leaf.value.length, share);
145
+ keeps.set(leaf, keep);
146
+ remaining -= keep;
147
+ });
148
+ let i = 0;
149
+ const output = rebuild(response, () => {
150
+ const leaf = leaves[i++];
151
+ return digest(leaf.value, keeps.get(leaf) ?? 0, headWeighted, file);
152
+ });
153
+ return { output, file };
154
+ }
155
+ /**
156
+ * A `PostToolUse` hook for the Claude Agent SDK. This is the ONLY layer that
157
+ * can rewrite a tool result before it reaches the model: Bash and Read run
158
+ * inside the SDK's own CLI process, so the org runtime never touches their
159
+ * output — `agent-runner.ts`'s `tool_result` stream is read-only observation,
160
+ * emitted after the transcript already holds the full text. The SDK does
161
+ * expose the seam we need here (`PostToolUseHookSpecificOutput.
162
+ * updatedToolOutput`: "Replaces the tool output before it is sent to the
163
+ * model"), so the clean approach is achievable — for the Claude path. The
164
+ * vendor runners (codex/opencode/qwen/…) drive their own CLIs and have no
165
+ * equivalent, so they are out of scope here.
166
+ */
167
+ export function toolResultSpillHook(dir) {
168
+ return async (input) => {
169
+ const spilled = spillToolResult(dir, String(input.tool_name ?? ''), String(input.tool_use_id ?? `t${Date.now()}`), input.tool_response);
170
+ if (!spilled)
171
+ return {};
172
+ return {
173
+ hookSpecificOutput: {
174
+ hookEventName: 'PostToolUse',
175
+ updatedToolOutput: spilled.output,
176
+ },
177
+ };
178
+ };
179
+ }
180
+ //# sourceMappingURL=tool-spill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool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I,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAC;AAWD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAW;IAEX,OAAO,KAAK,EAAE,KAAuB,EAAE,EAAE;QACvC,MAAM,OAAO,GAAG,eAAe,CAC7B,GAAG,EACH,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,EAC7B,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,EAC7C,KAAK,CAAC,aAAa,CACpB,CAAC;QACF,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,CAAC;QACxB,OAAO;YACL,kBAAkB,EAAE;gBAClB,aAAa,EAAE,aAAa;gBAC5B,iBAAiB,EAAE,OAAO,CAAC,MAAM;aAClC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -142,6 +142,10 @@ export declare const RolePolicySchema: z.ZodObject<{
142
142
  fileRead: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
143
143
  webAllow: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
144
144
  maxTokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
145
+ maxTokensBasis: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
146
+ billable: "billable";
147
+ uncached: "uncached";
148
+ }>>>;
145
149
  maxUsd: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
146
150
  git: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
147
151
  commit: "commit";
@@ -276,6 +280,10 @@ export declare const RoleSchema: z.ZodObject<{
276
280
  fileRead: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
277
281
  webAllow: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
278
282
  maxTokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
283
+ maxTokensBasis: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
284
+ billable: "billable";
285
+ uncached: "uncached";
286
+ }>>>;
279
287
  maxUsd: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
280
288
  git: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
281
289
  commit: "commit";
@@ -323,6 +331,13 @@ export declare const RoleSchema: z.ZodObject<{
323
331
  autoApproveTools: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
324
332
  approvalTools: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
325
333
  }, z.core.$loose>>;
334
+ session_scope: z.ZodOptional<z.ZodEnum<{
335
+ role: "role";
336
+ task: "task";
337
+ }>>;
338
+ review_input: z.ZodOptional<z.ZodEnum<{
339
+ "artifact-only": "artifact-only";
340
+ }>>;
326
341
  runtime: z.ZodOptional<z.ZodEnum<{
327
342
  antigravity: "antigravity";
328
343
  claude: "claude";
@@ -371,6 +386,56 @@ export declare const RoleSchema: z.ZodObject<{
371
386
  * Set run_config.max_turns_per_message (or a role's own
372
387
  * max_turns_per_message) to cap turns when you want a hard limit. */
373
388
  export declare const DEFAULT_MAX_TURNS_PER_MESSAGE = 100000;
389
+ export declare const CostTiersSchema: z.ZodObject<{
390
+ default: z.ZodOptional<z.ZodString>;
391
+ roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
392
+ tier: z.ZodString;
393
+ effort: z.ZodOptional<z.ZodEnum<{
394
+ high: "high";
395
+ low: "low";
396
+ max: "max";
397
+ medium: "medium";
398
+ off: "off";
399
+ xhigh: "xhigh";
400
+ }>>;
401
+ }, z.core.$loose>]>>>;
402
+ tiers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
403
+ model: z.ZodString;
404
+ effort: z.ZodOptional<z.ZodEnum<{
405
+ high: "high";
406
+ low: "low";
407
+ max: "max";
408
+ medium: "medium";
409
+ off: "off";
410
+ xhigh: "xhigh";
411
+ }>>;
412
+ }, z.core.$loose>>>>;
413
+ providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
414
+ effort_env: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
415
+ high: "high";
416
+ low: "low";
417
+ max: "max";
418
+ medium: "medium";
419
+ off: "off";
420
+ xhigh: "xhigh";
421
+ }> & z.core.$partial, z.ZodRecord<z.ZodString, z.ZodString>>>;
422
+ }, z.core.$loose>>>;
423
+ }, z.core.$loose>;
424
+ /** ADR-O001 D7: one named loadout — a stable bundle of role-prompt text and
425
+ * skills that becomes part of the SYSTEM PROMPT of the session serving a
426
+ * task. Validation (catalog size, names, skills, file) and resolution live in
427
+ * orgrt/loadouts.ts. */
428
+ export declare const LoadoutSchema: z.ZodObject<{
429
+ description: z.ZodOptional<z.ZodString>;
430
+ prompt: z.ZodOptional<z.ZodString>;
431
+ skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
432
+ instructions_file: z.ZodOptional<z.ZodString>;
433
+ }, z.core.$loose>;
434
+ /** ADR-O001 D4's number: three failed evidence checks on one task, then
435
+ * escalate instead of handing it back again. Exported so the call site can
436
+ * fall back to it for an org definition that never went through the schema
437
+ * (a hand-built RunningOrg, a config written before this field existed). */
438
+ export declare const DEFAULT_MAX_EVIDENCE_ATTEMPTS = 3;
374
439
  export declare const OrgDefSchema: z.ZodObject<{
375
440
  name: z.ZodString;
376
441
  goal: z.ZodDefault<z.ZodString>;
@@ -379,6 +444,10 @@ export declare const OrgDefSchema: z.ZodObject<{
379
444
  run_config: z.ZodPipe<z.ZodDefault<z.ZodObject<{
380
445
  max_concurrent_agents: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
381
446
  budget_tokens: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
447
+ budget_tokens_basis: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
448
+ billable: "billable";
449
+ uncached: "uncached";
450
+ }>>>;
382
451
  memory_namespace: z.ZodOptional<z.ZodOptional<z.ZodString>>;
383
452
  max_turns_per_message: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
384
453
  idle_minutes: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
@@ -386,6 +455,13 @@ export declare const OrgDefSchema: z.ZodObject<{
386
455
  boss: "boss";
387
456
  dag: "dag";
388
457
  }>>>;
458
+ completion_evidence: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
459
+ max_evidence_attempts: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
460
+ session_scope: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
461
+ role: "role";
462
+ task: "task";
463
+ }>>>;
464
+ session_idle_exit_ms: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
389
465
  workspace: z.ZodOptional<z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"repo">, z.ZodLiteral<"isolated">, z.ZodLiteral<"worktree">, z.ZodLiteral<"worktree-per-role">, z.ZodString]>>>;
390
466
  circuit_breaker: z.ZodOptional<z.ZodOptional<z.ZodObject<{
391
467
  failure_threshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
@@ -411,6 +487,8 @@ export declare const OrgDefSchema: z.ZodObject<{
411
487
  }, z.core.$loose>>, z.ZodTransform<{
412
488
  memory_namespace?: string | undefined;
413
489
  idle_minutes?: number | undefined;
490
+ session_scope?: "role" | "task" | undefined;
491
+ session_idle_exit_ms?: number | undefined;
414
492
  circuit_breaker?: {
415
493
  failure_threshold?: number | undefined;
416
494
  cooldown_ms?: number | undefined;
@@ -429,11 +507,14 @@ export declare const OrgDefSchema: z.ZodObject<{
429
507
  }[] | undefined;
430
508
  max_concurrent_agents: number;
431
509
  budget_tokens: number;
510
+ budget_tokens_basis: "billable" | "uncached";
432
511
  max_turns_per_message: number;
433
512
  workspace: string;
434
513
  stale_base_threshold: number;
435
514
  max_role_respawns: number;
436
515
  completion: "boss" | "dag";
516
+ completion_evidence: boolean;
517
+ max_evidence_attempts: number;
437
518
  respawn_drain_timeout_ms: number;
438
519
  respawn_force_stop_timeout_ms: number;
439
520
  respawn_start_timeout_ms: number;
@@ -441,10 +522,15 @@ export declare const OrgDefSchema: z.ZodObject<{
441
522
  [x: string]: unknown;
442
523
  max_concurrent_agents?: number | undefined;
443
524
  budget_tokens?: number | undefined;
525
+ budget_tokens_basis?: "billable" | "uncached" | undefined;
444
526
  memory_namespace?: string | undefined;
445
527
  max_turns_per_message?: number | undefined;
446
528
  idle_minutes?: number | undefined;
447
529
  completion?: "boss" | "dag" | undefined;
530
+ completion_evidence?: boolean | undefined;
531
+ max_evidence_attempts?: number | undefined;
532
+ session_scope?: "role" | "task" | undefined;
533
+ session_idle_exit_ms?: number | undefined;
448
534
  workspace?: string | undefined;
449
535
  circuit_breaker?: {
450
536
  failure_threshold?: number | undefined;
@@ -498,6 +584,47 @@ export declare const OrgDefSchema: z.ZodObject<{
498
584
  allow_from: z.ZodOptional<z.ZodArray<z.ZodString>>;
499
585
  allow_to: z.ZodOptional<z.ZodArray<z.ZodString>>;
500
586
  }, z.core.$loose>>;
587
+ cost_tiers: z.ZodOptional<z.ZodObject<{
588
+ default: z.ZodOptional<z.ZodString>;
589
+ roles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
590
+ tier: z.ZodString;
591
+ effort: z.ZodOptional<z.ZodEnum<{
592
+ high: "high";
593
+ low: "low";
594
+ max: "max";
595
+ medium: "medium";
596
+ off: "off";
597
+ xhigh: "xhigh";
598
+ }>>;
599
+ }, z.core.$loose>]>>>;
600
+ tiers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
601
+ model: z.ZodString;
602
+ effort: z.ZodOptional<z.ZodEnum<{
603
+ high: "high";
604
+ low: "low";
605
+ max: "max";
606
+ medium: "medium";
607
+ off: "off";
608
+ xhigh: "xhigh";
609
+ }>>;
610
+ }, z.core.$loose>>>>;
611
+ providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
612
+ effort_env: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
613
+ high: "high";
614
+ low: "low";
615
+ max: "max";
616
+ medium: "medium";
617
+ off: "off";
618
+ xhigh: "xhigh";
619
+ }> & z.core.$partial, z.ZodRecord<z.ZodString, z.ZodString>>>;
620
+ }, z.core.$loose>>>;
621
+ }, z.core.$loose>>;
622
+ loadouts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
623
+ description: z.ZodOptional<z.ZodString>;
624
+ prompt: z.ZodOptional<z.ZodString>;
625
+ skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
626
+ instructions_file: z.ZodOptional<z.ZodString>;
627
+ }, z.core.$loose>>>;
501
628
  roles: z.ZodArray<z.ZodObject<{
502
629
  id: z.ZodString;
503
630
  title: z.ZodDefault<z.ZodString>;
@@ -562,6 +689,10 @@ export declare const OrgDefSchema: z.ZodObject<{
562
689
  fileRead: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
563
690
  webAllow: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
564
691
  maxTokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
692
+ maxTokensBasis: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
693
+ billable: "billable";
694
+ uncached: "uncached";
695
+ }>>>;
565
696
  maxUsd: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
566
697
  git: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
567
698
  commit: "commit";
@@ -609,6 +740,13 @@ export declare const OrgDefSchema: z.ZodObject<{
609
740
  autoApproveTools: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
610
741
  approvalTools: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString>>>;
611
742
  }, z.core.$loose>>;
743
+ session_scope: z.ZodOptional<z.ZodEnum<{
744
+ role: "role";
745
+ task: "task";
746
+ }>>;
747
+ review_input: z.ZodOptional<z.ZodEnum<{
748
+ "artifact-only": "artifact-only";
749
+ }>>;
612
750
  runtime: z.ZodOptional<z.ZodEnum<{
613
751
  antigravity: "antigravity";
614
752
  claude: "claude";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/orgrt/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;;;iBAAwD,CAAC;AACxF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,eAAO,MAAM,iBAAiB;;;iBAAqE,CAAC;AACpG,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,eAAO,MAAM,qBAAqB;;;iBAGhC,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;iBAM3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,oBAAoB;;;;;;;iBAYrB,CAAC;AACb,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;;;sCASsC;AACtC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6DhB,CAAC;AAcZ,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;iBAOnC,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;iBAWd,CAAC;AAEjB,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,kBAAk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
4
  export const ContextSliceSchema = z.object({ source: z.string(), summary: z.string() });
4
5
  export const ArtifactRefSchema = z.object({ path: z.string(), description: z.string().optional() });
5
6
  export const HandoffDecisionSchema = z.object({
@@ -141,6 +142,13 @@ export const RolePolicySchema = z
141
142
  * 'api.example.com'), '*.example.com' wildcard, or '*' for any host. */
142
143
  webAllow: z.array(z.string()).optional(),
143
144
  maxTokens: z.number().int().positive().optional(),
145
+ /** ADR-O001 D1: which token basis `maxTokens` is compared against.
146
+ * 'uncached' (default) — input + output only, the basis every existing
147
+ * budget_tokens value was written against. 'billable' — also counts
148
+ * cache reads and cache writes, i.e. what is actually billed. Derived by
149
+ * the daemon from `run_config.budget_tokens_basis`; never set per role in
150
+ * a config. */
151
+ maxTokensBasis: z.enum(['uncached', 'billable']).optional(),
144
152
  /** USD spend cap for this role (ORG-7). Enforced the same way maxTokens/overBudget
145
153
  * is: PolicyEngine.decide() denies once accumulated cost meets or exceeds it. */
146
154
  maxUsd: z.number().positive().optional(),
@@ -252,6 +260,13 @@ export const RoleSchema = z
252
260
  .optional(),
253
261
  provider: ProviderSchema.optional(),
254
262
  policy: RolePolicySchema.optional(),
263
+ /** ADR-O001 D3: overrides run_config.session_scope for this role. */
264
+ session_scope: z.enum(['role', 'task']).optional(),
265
+ /** ADR-O001 D6: 'artifact-only' makes this a cold reviewer — a new model
266
+ * session per message, fed only runtime-built review packets
267
+ * (org_review); other agents' org_send to it is refused, so the doer's
268
+ * framing cannot reach it. Absent = an ordinary role. */
269
+ review_input: z.enum(['artifact-only']).optional(),
255
270
  /** Per-role runtime override: when set, this role's sessions run on the given
256
271
  * agent runtime regardless of the org-level `runtime` field or the
257
272
  * MONOMIND_RUNTIME env var ('claude' explicitly forces the Claude default).
@@ -303,6 +318,73 @@ export const RoleSchema = z
303
318
  * Set run_config.max_turns_per_message (or a role's own
304
319
  * max_turns_per_message) to cap turns when you want a hard limit. */
305
320
  export const DEFAULT_MAX_TURNS_PER_MESSAGE = 100_000;
321
+ /** ADR-O001 D8 cost tiers. Keys are provider keys — a Vercel vendor slug
322
+ * (`glm`, `openai`, …) when the role has one, else the role's runtime id
323
+ * (`claude`, `codex`, `kimicode`, …) — so a tier is expressible for a
324
+ * provider this code has never heard of without touching code. Resolution,
325
+ * the built-in Claude catalog and the deliberative-role warning live in
326
+ * orgrt/cost-tier.ts. */
327
+ const EffortLevelSchema = z.enum(ORG_EFFORT_LEVELS);
328
+ export const CostTiersSchema = z
329
+ .object({
330
+ /** Tier applied to every role with no `roles` entry of its own. */
331
+ default: z.string().optional(),
332
+ /** Per-role tier. A bare string is a tier name or `"exempt"`; the object
333
+ * form also overrides the tier's effort — how "patrol roles drop effort
334
+ * since they do simpler, more repetitive work" is expressed. */
335
+ roles: z
336
+ .record(z.string(), z.union([
337
+ z.string(),
338
+ z.object({ tier: z.string(), effort: EffortLevelSchema.optional() }).passthrough(),
339
+ ]))
340
+ .optional(),
341
+ /** tier name → provider key → { model, effort }. Merged over the built-in
342
+ * catalog per provider, so adding one provider to a built-in tier keeps
343
+ * the rest of that tier. */
344
+ tiers: z
345
+ .record(z.string(), z.record(z.string(), z
346
+ .object({ model: z.string().min(1), effort: EffortLevelSchema.optional() })
347
+ .passthrough()))
348
+ .optional(),
349
+ /** provider key → how that provider expresses an effort level. Claude is
350
+ * handled natively (the SDK's own `effort`/`thinking` options); anything
351
+ * else declares env vars here, or encodes effort in the per-tier model id
352
+ * (e.g. `gemini-3.6-flash-high`). A provider with neither ignores it. */
353
+ providers: z
354
+ .record(z.string(), z
355
+ .object({
356
+ // partialRecord, not record: z.record() over an enum key demands
357
+ // EVERY level be present, so an org declaring only `low` would be
358
+ // rejected for not also declaring medium/high/xhigh/max.
359
+ effort_env: z
360
+ .partialRecord(EffortLevelSchema, z.record(z.string(), z.string()))
361
+ .optional(),
362
+ })
363
+ .passthrough())
364
+ .optional(),
365
+ })
366
+ .passthrough();
367
+ /** ADR-O001 D7: one named loadout — a stable bundle of role-prompt text and
368
+ * skills that becomes part of the SYSTEM PROMPT of the session serving a
369
+ * task. Validation (catalog size, names, skills, file) and resolution live in
370
+ * orgrt/loadouts.ts. */
371
+ export const LoadoutSchema = z
372
+ .object({
373
+ /** One line shown to the boss in org_task's description, to select by. */
374
+ description: z.string().optional(),
375
+ /** Role-prompt text for this kind of work. */
376
+ prompt: z.string().optional(),
377
+ /** Built-in role skills (orgrt/role-skills/<name>.md) to include. */
378
+ skills: z.array(z.string()).optional(),
379
+ /** Extra guidance file, resolved against the project root. */
380
+ instructions_file: z.string().optional(),
381
+ })
382
+ .passthrough();
383
+ /** ADR-O001 D4's number: three failed evidence checks on one task, then
384
+ * escalate instead of handing it back again. Exported so the call site can
385
+ * fall back to it for an org definition that never went through the schema
386
+ * (a hand-built RunningOrg, a config written before this field existed). */
387
+ export const DEFAULT_MAX_EVIDENCE_ATTEMPTS = 3;
306
388
  export const OrgDefSchema = z
307
389
  .object({
308
390
  name: z.string().min(1),
@@ -313,6 +395,15 @@ export const OrgDefSchema = z
313
395
  .object({
314
396
  max_concurrent_agents: z.number().int().positive().default(4),
315
397
  budget_tokens: z.number().int().positive().default(1_000_000),
398
+ /** ADR-O001 D1: which token basis `budget_tokens` is enforced on.
399
+ * 'uncached' (default) counts input + output, the basis this value
400
+ * has always meant. 'billable' also counts cache reads/writes — the
401
+ * honest basis, but ~100x larger on a well-cached run, so opting in
402
+ * means re-sizing budget_tokens. The meter itself is always billable
403
+ * (usage events, checkpoints, dashboards); this knob only governs
404
+ * enforcement, so switching it can never change what is reported.
405
+ * Prefer `budget_usd`, which needs no basis. */
406
+ budget_tokens_basis: z.enum(['uncached', 'billable']).optional(),
316
407
  memory_namespace: z.string().optional(),
317
408
  max_turns_per_message: z.number().int().positive().default(DEFAULT_MAX_TURNS_PER_MESSAGE),
318
409
  /** idle watchdog window in minutes (fractions allowed); 0 disables. Default 10. */
@@ -326,6 +417,36 @@ export const OrgDefSchema = z
326
417
  * with no populated DAG (the common case today) gets no benefit
327
418
  * from it, only a new refusal path. See completion-gate.ts. */
328
419
  completion: z.enum(['boss', 'dag']).optional(),
420
+ /** ADR-O001 D5: gate `org_task_done` on machine-checkable evidence —
421
+ * acceptance commands with their real exit codes, pinned to the
422
+ * workspace's current commit sha. Adjacent FLAG rather than a third
423
+ * `completion` value because it constrains a different call
424
+ * (org_task_done, per item) than `completion` does (org_complete,
425
+ * per run): an org wants to choose both independently. Default
426
+ * false — turning it on refuses task completions that previously
427
+ * succeeded, which is the point, but must not happen on upgrade.
428
+ * See completion-gate.ts's `checkTaskEvidence`. */
429
+ completion_evidence: z.boolean().optional(),
430
+ /** ADR-O001 D4 ("bound retries (3) and escalate"): how many times one
431
+ * task may fail the `completion_evidence` gate before the runtime
432
+ * stops handing it back to its assignee and escalates it to the boss
433
+ * instead. Counted per task and carried by the checkpoint (see
434
+ * `OrgTask.evidenceFailures`). Only meaningful with
435
+ * `completion_evidence` on — without the gate nothing fails. */
436
+ max_evidence_attempts: z.number().int().positive().default(3),
437
+ /** ADR-O001 D3: how a role's MODEL sessions are keyed. 'role'
438
+ * (the default, and the behaviour before D3) keeps one session for
439
+ * the role's life. 'task' keeps one per task: the role's process
440
+ * exits at a task boundary and the next wake resumes that task's
441
+ * session from the run's session ledger. Applies to every role
442
+ * except the coordinator, whose work spans tasks — a role's own
443
+ * `session_scope` overrides it either way. */
444
+ session_scope: z.enum(['role', 'task']).optional(),
445
+ /** ADR-O001 D3: end a role's process after this many ms with no mail;
446
+ * the next message resumes the same model session. Absent = never
447
+ * (the process parks, as before). Idle residency costs no tokens,
448
+ * so this is about process count, not spend. */
449
+ session_idle_exit_ms: z.number().int().positive().optional(),
329
450
  /** Where role sessions run.
330
451
  * 'repo' (default) — the project root, so roles can Read/Edit real files.
331
452
  * 'isolated' — a scratch dir under .monomind/orgs/<name>/workspace, which the
@@ -378,11 +499,14 @@ export const OrgDefSchema = z
378
499
  .transform((rc) => ({
379
500
  max_concurrent_agents: 4,
380
501
  budget_tokens: 1_000_000,
502
+ budget_tokens_basis: 'uncached',
381
503
  max_turns_per_message: DEFAULT_MAX_TURNS_PER_MESSAGE,
382
504
  workspace: 'repo',
383
505
  stale_base_threshold: 0,
384
506
  max_role_respawns: 0,
385
507
  completion: 'boss',
508
+ completion_evidence: false,
509
+ max_evidence_attempts: DEFAULT_MAX_EVIDENCE_ATTEMPTS,
386
510
  respawn_drain_timeout_ms: 30_000,
387
511
  respawn_force_stop_timeout_ms: 5_000,
388
512
  respawn_start_timeout_ms: 60_000,
@@ -399,6 +523,30 @@ export const OrgDefSchema = z
399
523
  })
400
524
  .passthrough()
401
525
  .optional(),
526
+ /** ADR-O001 D8: named cost tiers, each setting BOTH the model AND the
527
+ * reasoning/thinking effort for a role, per provider. Absent (the
528
+ * default) = no tiering at all and today's model resolution, unchanged.
529
+ *
530
+ * Precedence at session start: an explicit `adapter_config.model` wins
531
+ * over the tier's model; the tier wins over a named provider's default
532
+ * and the runtime default. A tier's EFFORT applies either way, since it
533
+ * is a separate axis from which model to run.
534
+ *
535
+ * DO NOT TIER A DELIBERATIVE ROLE INTO A WEAK VOICE. The ADR is explicit:
536
+ * tier by *difficulty of the judgement*, not by role label — "a cheap
537
+ * model in a debate produces cheap arguments and the synthesiser cannot
538
+ * tell". Assign `"exempt"` to any role whose value is the quality of its
539
+ * disagreement (design reviewer, red-teamer, debate synthesiser) and
540
+ * control its cost with a budget instead. See orgrt/cost-tier.ts. */
541
+ cost_tiers: CostTiersSchema.optional(),
542
+ /** ADR-O001 D7: the org's catalog of named loadouts (target 5–15; more
543
+ * than 15 fails `org validate` and `org run`). When present, org_task and
544
+ * org_plan_graph take an optional `loadout` the boss SELECTS by name; it
545
+ * is recorded on the task row and every re-dispatch reuses it. Absent
546
+ * (the default) = no loadout argument and byte-identical prompts/tools.
547
+ * Deliberative work that wants many one-off perspectives belongs in its
548
+ * own org (ADR-O001, "What this does NOT apply to"). See orgrt/loadouts.ts. */
549
+ loadouts: z.record(z.string(), LoadoutSchema).optional(),
402
550
  roles: z.array(RoleSchema).min(1),
403
551
  /** Which agent runtime hosts this org's role sessions. When absent, the
404
552
  * MONOMIND_RUNTIME env var is honored, falling back to the default Claude