@inhuman.tools/turn 0.0.0-stage → 0.1.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 (346) hide show
  1. package/LICENSE.md +7 -0
  2. package/dist/agent-calls/acceptance.d.ts +12 -0
  3. package/dist/agent-calls/acceptance.d.ts.map +1 -0
  4. package/dist/agent-calls/acceptance.js +64 -0
  5. package/dist/agent-calls/acceptance.js.map +1 -0
  6. package/dist/agent-calls/callbacks.d.ts +14 -0
  7. package/dist/agent-calls/callbacks.d.ts.map +1 -0
  8. package/dist/agent-calls/callbacks.js +59 -0
  9. package/dist/agent-calls/callbacks.js.map +1 -0
  10. package/dist/agent-calls/delivery.d.ts +7 -0
  11. package/dist/agent-calls/delivery.d.ts.map +1 -0
  12. package/dist/agent-calls/delivery.js +16 -0
  13. package/dist/agent-calls/delivery.js.map +1 -0
  14. package/dist/agent-calls/index.d.ts +7 -0
  15. package/dist/agent-calls/index.d.ts.map +1 -0
  16. package/dist/agent-calls/index.js +6 -0
  17. package/dist/agent-calls/index.js.map +1 -0
  18. package/dist/agent-calls/operator.d.ts +21 -0
  19. package/dist/agent-calls/operator.d.ts.map +1 -0
  20. package/dist/agent-calls/operator.js +78 -0
  21. package/dist/agent-calls/operator.js.map +1 -0
  22. package/dist/agent-calls/runtime.d.ts +99 -0
  23. package/dist/agent-calls/runtime.d.ts.map +1 -0
  24. package/dist/agent-calls/runtime.js +245 -0
  25. package/dist/agent-calls/runtime.js.map +1 -0
  26. package/dist/agent-calls/types.d.ts +31 -0
  27. package/dist/agent-calls/types.d.ts.map +1 -0
  28. package/dist/agent-calls/types.js +2 -0
  29. package/dist/agent-calls/types.js.map +1 -0
  30. package/dist/context/compact-floors.d.ts +43 -0
  31. package/dist/context/compact-floors.d.ts.map +1 -0
  32. package/dist/context/compact-floors.js +52 -0
  33. package/dist/context/compact-floors.js.map +1 -0
  34. package/dist/context/compact.d.ts +42 -0
  35. package/dist/context/compact.d.ts.map +1 -0
  36. package/dist/context/compact.js +155 -0
  37. package/dist/context/compact.js.map +1 -0
  38. package/dist/context/delivery.d.ts +13 -0
  39. package/dist/context/delivery.d.ts.map +1 -0
  40. package/dist/context/delivery.js +6 -0
  41. package/dist/context/delivery.js.map +1 -0
  42. package/dist/context/history.d.ts +66 -0
  43. package/dist/context/history.d.ts.map +1 -0
  44. package/dist/context/history.js +573 -0
  45. package/dist/context/history.js.map +1 -0
  46. package/dist/context/index.d.ts +10 -0
  47. package/dist/context/index.d.ts.map +1 -0
  48. package/dist/context/index.js +10 -0
  49. package/dist/context/index.js.map +1 -0
  50. package/dist/context/observations.d.ts +7 -0
  51. package/dist/context/observations.d.ts.map +1 -0
  52. package/dist/context/observations.js +11 -0
  53. package/dist/context/observations.js.map +1 -0
  54. package/dist/context/retention/defaults.d.ts +10 -0
  55. package/dist/context/retention/defaults.d.ts.map +1 -0
  56. package/dist/context/retention/defaults.js +47 -0
  57. package/dist/context/retention/defaults.js.map +1 -0
  58. package/dist/context/retention/index.d.ts +14 -0
  59. package/dist/context/retention/index.d.ts.map +1 -0
  60. package/dist/context/retention/index.js +21 -0
  61. package/dist/context/retention/index.js.map +1 -0
  62. package/dist/context/retention/narrow.d.ts +22 -0
  63. package/dist/context/retention/narrow.d.ts.map +1 -0
  64. package/dist/context/retention/narrow.js +140 -0
  65. package/dist/context/retention/narrow.js.map +1 -0
  66. package/dist/context/retention/render.d.ts +37 -0
  67. package/dist/context/retention/render.d.ts.map +1 -0
  68. package/dist/context/retention/render.js +149 -0
  69. package/dist/context/retention/render.js.map +1 -0
  70. package/dist/context/retention/resolve.d.ts +51 -0
  71. package/dist/context/retention/resolve.d.ts.map +1 -0
  72. package/dist/context/retention/resolve.js +254 -0
  73. package/dist/context/retention/resolve.js.map +1 -0
  74. package/dist/context/retention/schema.d.ts +345 -0
  75. package/dist/context/retention/schema.d.ts.map +1 -0
  76. package/dist/context/retention/schema.js +149 -0
  77. package/dist/context/retention/schema.js.map +1 -0
  78. package/dist/context/retention/stamp.d.ts +25 -0
  79. package/dist/context/retention/stamp.d.ts.map +1 -0
  80. package/dist/context/retention/stamp.js +103 -0
  81. package/dist/context/retention/stamp.js.map +1 -0
  82. package/dist/context/retention/step.d.ts +33 -0
  83. package/dist/context/retention/step.d.ts.map +1 -0
  84. package/dist/context/retention/step.js +74 -0
  85. package/dist/context/retention/step.js.map +1 -0
  86. package/dist/context/retention/view.d.ts +57 -0
  87. package/dist/context/retention/view.d.ts.map +1 -0
  88. package/dist/context/retention/view.js +121 -0
  89. package/dist/context/retention/view.js.map +1 -0
  90. package/dist/context/squeeze.d.ts +45 -0
  91. package/dist/context/squeeze.d.ts.map +1 -0
  92. package/dist/context/squeeze.js +182 -0
  93. package/dist/context/squeeze.js.map +1 -0
  94. package/dist/context/tools.d.ts +16 -0
  95. package/dist/context/tools.d.ts.map +1 -0
  96. package/dist/context/tools.js +73 -0
  97. package/dist/context/tools.js.map +1 -0
  98. package/dist/context/transcript.d.ts +151 -0
  99. package/dist/context/transcript.d.ts.map +1 -0
  100. package/dist/context/transcript.js +659 -0
  101. package/dist/context/transcript.js.map +1 -0
  102. package/dist/policy-processor/bypass.d.ts +95 -0
  103. package/dist/policy-processor/bypass.d.ts.map +1 -0
  104. package/dist/policy-processor/bypass.js +188 -0
  105. package/dist/policy-processor/bypass.js.map +1 -0
  106. package/dist/policy-processor/classifier.d.ts +47 -0
  107. package/dist/policy-processor/classifier.d.ts.map +1 -0
  108. package/dist/policy-processor/classifier.js +671 -0
  109. package/dist/policy-processor/classifier.js.map +1 -0
  110. package/dist/policy-processor/cluster.d.ts +7 -0
  111. package/dist/policy-processor/cluster.d.ts.map +1 -0
  112. package/dist/policy-processor/cluster.js +32 -0
  113. package/dist/policy-processor/cluster.js.map +1 -0
  114. package/dist/policy-processor/evidence.d.ts +26 -0
  115. package/dist/policy-processor/evidence.d.ts.map +1 -0
  116. package/dist/policy-processor/evidence.js +204 -0
  117. package/dist/policy-processor/evidence.js.map +1 -0
  118. package/dist/policy-processor/explain.d.ts +59 -0
  119. package/dist/policy-processor/explain.d.ts.map +1 -0
  120. package/dist/policy-processor/explain.js +224 -0
  121. package/dist/policy-processor/explain.js.map +1 -0
  122. package/dist/policy-processor/index.d.ts +6 -0
  123. package/dist/policy-processor/index.d.ts.map +1 -0
  124. package/dist/policy-processor/index.js +6 -0
  125. package/dist/policy-processor/index.js.map +1 -0
  126. package/dist/policy-processor/license.d.ts +23 -0
  127. package/dist/policy-processor/license.d.ts.map +1 -0
  128. package/dist/policy-processor/license.js +47 -0
  129. package/dist/policy-processor/license.js.map +1 -0
  130. package/dist/policy-processor/peel-cwd.d.ts +2 -0
  131. package/dist/policy-processor/peel-cwd.d.ts.map +1 -0
  132. package/dist/policy-processor/peel-cwd.js +2 -0
  133. package/dist/policy-processor/peel-cwd.js.map +1 -0
  134. package/dist/policy-processor/real-path.d.ts +7 -0
  135. package/dist/policy-processor/real-path.d.ts.map +1 -0
  136. package/dist/policy-processor/real-path.js +42 -0
  137. package/dist/policy-processor/real-path.js.map +1 -0
  138. package/dist/policy-processor/scope.d.ts +111 -0
  139. package/dist/policy-processor/scope.d.ts.map +1 -0
  140. package/dist/policy-processor/scope.js +629 -0
  141. package/dist/policy-processor/scope.js.map +1 -0
  142. package/dist/policy-processor/self-protect.d.ts +10 -0
  143. package/dist/policy-processor/self-protect.d.ts.map +1 -0
  144. package/dist/policy-processor/self-protect.js +48 -0
  145. package/dist/policy-processor/self-protect.js.map +1 -0
  146. package/dist/policy-processor/soft-deny.d.ts +75 -0
  147. package/dist/policy-processor/soft-deny.d.ts.map +1 -0
  148. package/dist/policy-processor/soft-deny.js +185 -0
  149. package/dist/policy-processor/soft-deny.js.map +1 -0
  150. package/dist/policy-processor/unattended-guard.d.ts +28 -0
  151. package/dist/policy-processor/unattended-guard.d.ts.map +1 -0
  152. package/dist/policy-processor/unattended-guard.js +145 -0
  153. package/dist/policy-processor/unattended-guard.js.map +1 -0
  154. package/dist/session/cancel.d.ts +14 -0
  155. package/dist/session/cancel.d.ts.map +1 -0
  156. package/dist/session/cancel.js +32 -0
  157. package/dist/session/cancel.js.map +1 -0
  158. package/dist/session/commands.d.ts +41 -0
  159. package/dist/session/commands.d.ts.map +1 -0
  160. package/dist/session/commands.js +241 -0
  161. package/dist/session/commands.js.map +1 -0
  162. package/dist/session/compact-actor.d.ts +23 -0
  163. package/dist/session/compact-actor.d.ts.map +1 -0
  164. package/dist/session/compact-actor.js +91 -0
  165. package/dist/session/compact-actor.js.map +1 -0
  166. package/dist/session/compact-env.d.ts +54 -0
  167. package/dist/session/compact-env.d.ts.map +1 -0
  168. package/dist/session/compact-env.js +345 -0
  169. package/dist/session/compact-env.js.map +1 -0
  170. package/dist/session/compact.d.ts +42 -0
  171. package/dist/session/compact.d.ts.map +1 -0
  172. package/dist/session/compact.js +68 -0
  173. package/dist/session/compact.js.map +1 -0
  174. package/dist/session/index.d.ts +9 -0
  175. package/dist/session/index.d.ts.map +1 -0
  176. package/dist/session/index.js +8 -0
  177. package/dist/session/index.js.map +1 -0
  178. package/dist/session/park.d.ts +16 -0
  179. package/dist/session/park.d.ts.map +1 -0
  180. package/dist/session/park.js +73 -0
  181. package/dist/session/park.js.map +1 -0
  182. package/dist/session/side-channel-reminder.d.ts +41 -0
  183. package/dist/session/side-channel-reminder.d.ts.map +1 -0
  184. package/dist/session/side-channel-reminder.js +132 -0
  185. package/dist/session/side-channel-reminder.js.map +1 -0
  186. package/dist/session/types.d.ts +44 -0
  187. package/dist/session/types.d.ts.map +1 -0
  188. package/dist/session/types.js +2 -0
  189. package/dist/session/types.js.map +1 -0
  190. package/dist/tool-catalog/catalog.d.ts +77 -0
  191. package/dist/tool-catalog/catalog.d.ts.map +1 -0
  192. package/dist/tool-catalog/catalog.js +380 -0
  193. package/dist/tool-catalog/catalog.js.map +1 -0
  194. package/dist/tool-catalog/index.d.ts +4 -0
  195. package/dist/tool-catalog/index.d.ts.map +1 -0
  196. package/dist/tool-catalog/index.js +3 -0
  197. package/dist/tool-catalog/index.js.map +1 -0
  198. package/dist/tool-catalog/recipes.d.ts +36 -0
  199. package/dist/tool-catalog/recipes.d.ts.map +1 -0
  200. package/dist/tool-catalog/recipes.js +121 -0
  201. package/dist/tool-catalog/recipes.js.map +1 -0
  202. package/dist/tool-catalog/types.d.ts +103 -0
  203. package/dist/tool-catalog/types.d.ts.map +1 -0
  204. package/dist/tool-catalog/types.js +5 -0
  205. package/dist/tool-catalog/types.js.map +1 -0
  206. package/dist/tool-runtime/approval/approved.d.ts +13 -0
  207. package/dist/tool-runtime/approval/approved.d.ts.map +1 -0
  208. package/dist/tool-runtime/approval/approved.js +20 -0
  209. package/dist/tool-runtime/approval/approved.js.map +1 -0
  210. package/dist/tool-runtime/approval/dist.d.ts +6 -0
  211. package/dist/tool-runtime/approval/dist.d.ts.map +1 -0
  212. package/dist/tool-runtime/approval/dist.js +28 -0
  213. package/dist/tool-runtime/approval/dist.js.map +1 -0
  214. package/dist/tool-runtime/approval/inbound.d.ts +7 -0
  215. package/dist/tool-runtime/approval/inbound.d.ts.map +1 -0
  216. package/dist/tool-runtime/approval/inbound.js +48 -0
  217. package/dist/tool-runtime/approval/inbound.js.map +1 -0
  218. package/dist/tool-runtime/approval/unattended.d.ts +8 -0
  219. package/dist/tool-runtime/approval/unattended.d.ts.map +1 -0
  220. package/dist/tool-runtime/approval/unattended.js +23 -0
  221. package/dist/tool-runtime/approval/unattended.js.map +1 -0
  222. package/dist/tool-runtime/blob-port.d.ts +46 -0
  223. package/dist/tool-runtime/blob-port.d.ts.map +1 -0
  224. package/dist/tool-runtime/blob-port.js +47 -0
  225. package/dist/tool-runtime/blob-port.js.map +1 -0
  226. package/dist/tool-runtime/extra-root.d.ts +3 -0
  227. package/dist/tool-runtime/extra-root.d.ts.map +1 -0
  228. package/dist/tool-runtime/extra-root.js +14 -0
  229. package/dist/tool-runtime/extra-root.js.map +1 -0
  230. package/dist/tool-runtime/handler.d.ts +29 -0
  231. package/dist/tool-runtime/handler.d.ts.map +1 -0
  232. package/dist/tool-runtime/handler.js +460 -0
  233. package/dist/tool-runtime/handler.js.map +1 -0
  234. package/dist/tool-runtime/index.d.ts +14 -0
  235. package/dist/tool-runtime/index.d.ts.map +1 -0
  236. package/dist/tool-runtime/index.js +14 -0
  237. package/dist/tool-runtime/index.js.map +1 -0
  238. package/dist/tool-runtime/peel.d.ts +19 -0
  239. package/dist/tool-runtime/peel.d.ts.map +1 -0
  240. package/dist/tool-runtime/peel.js +74 -0
  241. package/dist/tool-runtime/peel.js.map +1 -0
  242. package/dist/tool-runtime/plugin-context.d.ts +13 -0
  243. package/dist/tool-runtime/plugin-context.d.ts.map +1 -0
  244. package/dist/tool-runtime/plugin-context.js +55 -0
  245. package/dist/tool-runtime/plugin-context.js.map +1 -0
  246. package/dist/tool-runtime/recall.d.ts +18 -0
  247. package/dist/tool-runtime/recall.d.ts.map +1 -0
  248. package/dist/tool-runtime/recall.js +100 -0
  249. package/dist/tool-runtime/recall.js.map +1 -0
  250. package/dist/tool-runtime/run-system-tool.d.ts +13 -0
  251. package/dist/tool-runtime/run-system-tool.d.ts.map +1 -0
  252. package/dist/tool-runtime/run-system-tool.js +230 -0
  253. package/dist/tool-runtime/run-system-tool.js.map +1 -0
  254. package/dist/tool-runtime/tool-error.d.ts +6 -0
  255. package/dist/tool-runtime/tool-error.d.ts.map +1 -0
  256. package/dist/tool-runtime/tool-error.js +6 -0
  257. package/dist/tool-runtime/tool-error.js.map +1 -0
  258. package/dist/tool-runtime/worker-tools.d.ts +8 -0
  259. package/dist/tool-runtime/worker-tools.d.ts.map +1 -0
  260. package/dist/tool-runtime/worker-tools.js +65 -0
  261. package/dist/tool-runtime/worker-tools.js.map +1 -0
  262. package/dist/tool-runtime/write-admit.d.ts +21 -0
  263. package/dist/tool-runtime/write-admit.d.ts.map +1 -0
  264. package/dist/tool-runtime/write-admit.js +89 -0
  265. package/dist/tool-runtime/write-admit.js.map +1 -0
  266. package/package.json +114 -3
  267. package/policy/auto-mode-ask.scm +201 -0
  268. package/policy/bypass-detect.prompt +55 -0
  269. package/policy/classifier-bash-incomplete.prompt +46 -0
  270. package/policy/classifier-bash.prompt +45 -0
  271. package/policy/classifier-mcp.prompt +45 -0
  272. package/policy/classifier-read.prompt +44 -0
  273. package/policy/classifier-write-outside.prompt +46 -0
  274. package/policy/classifier-write-risky.prompt +45 -0
  275. package/policy/classifier-write-workspace.prompt +46 -0
  276. package/policy/classifier-write.prompt +45 -0
  277. package/policy/soft-deny-round1.prompt +51 -0
  278. package/policy/soft-deny-round2.prompt +60 -0
  279. package/src/agent-calls/acceptance.ts +71 -0
  280. package/src/agent-calls/callbacks.ts +75 -0
  281. package/src/agent-calls/delivery.ts +15 -0
  282. package/src/agent-calls/index.ts +16 -0
  283. package/src/agent-calls/operator.ts +99 -0
  284. package/src/agent-calls/runtime.ts +310 -0
  285. package/src/agent-calls/types.ts +33 -0
  286. package/src/context/compact-floors.ts +76 -0
  287. package/src/context/compact.ts +176 -0
  288. package/src/context/delivery.ts +15 -0
  289. package/src/context/history.ts +725 -0
  290. package/src/context/index.ts +35 -0
  291. package/src/context/observations.ts +13 -0
  292. package/src/context/retention/defaults.ts +58 -0
  293. package/src/context/retention/index.ts +45 -0
  294. package/src/context/retention/narrow.ts +123 -0
  295. package/src/context/retention/render.ts +177 -0
  296. package/src/context/retention/resolve.ts +306 -0
  297. package/src/context/retention/schema.ts +173 -0
  298. package/src/context/retention/stamp.ts +121 -0
  299. package/src/context/retention/step.ts +85 -0
  300. package/src/context/retention/view.ts +161 -0
  301. package/src/context/squeeze.ts +218 -0
  302. package/src/context/tools.ts +92 -0
  303. package/src/context/transcript.ts +705 -0
  304. package/src/policy-processor/README.md +43 -0
  305. package/src/policy-processor/bypass.ts +246 -0
  306. package/src/policy-processor/classifier.ts +711 -0
  307. package/src/policy-processor/cluster.ts +31 -0
  308. package/src/policy-processor/evidence.ts +214 -0
  309. package/src/policy-processor/explain.ts +310 -0
  310. package/src/policy-processor/index.ts +6 -0
  311. package/src/policy-processor/license.ts +45 -0
  312. package/src/policy-processor/peel-cwd.ts +1 -0
  313. package/src/policy-processor/real-path.ts +41 -0
  314. package/src/policy-processor/scope.ts +655 -0
  315. package/src/policy-processor/self-protect.ts +46 -0
  316. package/src/policy-processor/soft-deny.ts +225 -0
  317. package/src/policy-processor/unattended-guard.ts +158 -0
  318. package/src/session/cancel.ts +34 -0
  319. package/src/session/commands.ts +292 -0
  320. package/src/session/compact-actor.ts +132 -0
  321. package/src/session/compact-env.ts +539 -0
  322. package/src/session/compact.ts +95 -0
  323. package/src/session/index.ts +18 -0
  324. package/src/session/park.ts +73 -0
  325. package/src/session/side-channel-reminder.ts +148 -0
  326. package/src/session/types.ts +50 -0
  327. package/src/tool-catalog/catalog.ts +282 -0
  328. package/src/tool-catalog/index.ts +26 -0
  329. package/src/tool-catalog/recipes.ts +154 -0
  330. package/src/tool-catalog/types.ts +110 -0
  331. package/src/tool-runtime/approval/approved.ts +20 -0
  332. package/src/tool-runtime/approval/dist.ts +29 -0
  333. package/src/tool-runtime/approval/inbound.ts +50 -0
  334. package/src/tool-runtime/approval/unattended.ts +24 -0
  335. package/src/tool-runtime/blob-port.ts +64 -0
  336. package/src/tool-runtime/extra-root.ts +16 -0
  337. package/src/tool-runtime/handler.ts +576 -0
  338. package/src/tool-runtime/index.ts +21 -0
  339. package/src/tool-runtime/peel.ts +91 -0
  340. package/src/tool-runtime/plugin-context.ts +68 -0
  341. package/src/tool-runtime/recall.ts +104 -0
  342. package/src/tool-runtime/run-system-tool.ts +273 -0
  343. package/src/tool-runtime/tool-error.ts +6 -0
  344. package/src/tool-runtime/worker-tools.ts +76 -0
  345. package/src/tool-runtime/write-admit.ts +90 -0
  346. package/README.md +0 -3
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Catalog row identity. wireName is a model-edge projection — never durable
3
+ * routing. Connection tools route by connectionKey + serverToolName.
4
+ */
5
+ import type { RuleInput } from "../context/retention/schema.js";
6
+ export type CatalogSource = {
7
+ readonly kind: "pack";
8
+ readonly pluginName: string;
9
+ } | {
10
+ readonly kind: "connection";
11
+ /** Kernel `connections` map key (slug). Lawful cross-doc pointer to ConnectionSpec. */
12
+ readonly connectionKey: string;
13
+ readonly serverToolName: string;
14
+ };
15
+ export type CatalogExecute = (raw: unknown, ctx: {
16
+ root?: string;
17
+ signal?: AbortSignal;
18
+ sessionId?: string;
19
+ background?: unknown;
20
+ catalog?: unknown;
21
+ onPriorContent?: (text: string | null) => void;
22
+ invocation?: unknown;
23
+ shellTailBytes?: number;
24
+ onTail?: (frame: {
25
+ readonly text: string;
26
+ readonly totalBytes: number;
27
+ }) => void;
28
+ }) => Promise<unknown>;
29
+ /** `tool` is completions tools[]. `symbol` is a scheme_repl name. `both` is both. */
30
+ export type ToolRepresentation = "tool" | "symbol" | "both";
31
+ export type PackToolMeta = {
32
+ readonly kind: "function";
33
+ } | {
34
+ readonly kind: "bot-call";
35
+ readonly pluginName: string;
36
+ readonly target: string;
37
+ readonly background: boolean;
38
+ readonly lifetime: "turn" | "call";
39
+ readonly show: "result" | "omit" | "turn";
40
+ readonly deadlineMs?: number;
41
+ readonly supportsNotify: boolean;
42
+ };
43
+ export type CatalogEntry = {
44
+ readonly wireName: string;
45
+ readonly description: string;
46
+ readonly parameters: Record<string, unknown>;
47
+ /** Catalog class: `read` | `write` | `effect` | `meta`. Missing / unknown → `effect`. */
48
+ readonly class: string;
49
+ /**
50
+ * Model face. Omitted is a scheme symbol and stays off completions tools[].
51
+ * Native tools set this on `InhumanTool`; the catalog row copies it.
52
+ */
53
+ readonly representation?: ToolRepresentation;
54
+ readonly source: CatalogSource;
55
+ /**
56
+ * Pack / host plugins carry execute (InhumanTool.execute).
57
+ * Connection tools are projection-only — BODY is MCP PEW on the connection.
58
+ */
59
+ readonly execute?: CatalogExecute;
60
+ readonly packMeta?: PackToolMeta;
61
+ readonly triggersReactLoop?: boolean;
62
+ /** Skips the license floor. Copied from the tool that declared it. */
63
+ readonly isSideChannel?: boolean;
64
+ readonly tapeHidden?: boolean;
65
+ /**
66
+ * Self-declared retention hint (e.g. ephemeral output). Narrowing only, and
67
+ * only for this tool's own key: it can shorten what the policy says, never lengthen it.
68
+ */
69
+ readonly retention?: RuleInput;
70
+ /** Mustache the TUI paints while the call is open, after it seals, and as a caption. */
71
+ readonly question?: string | null;
72
+ readonly effect?: string | null;
73
+ readonly caption?: string | null;
74
+ /**
75
+ * Exam admit bag. Structural so this package does not import plugin-sdk.
76
+ * Plugin ExamAdmit is assignable.
77
+ */
78
+ readonly exam?: {
79
+ readonly program: (state: any, input: any) => string | {
80
+ readonly error: string;
81
+ };
82
+ readonly admit: (state: any, input: any) => any;
83
+ readonly settle?: (state: any, input: any, result: any) => any;
84
+ };
85
+ };
86
+ /** What a recipe needs to grant a wire beyond its plain tool list. */
87
+ export type RecipeGrantSpec = {
88
+ readonly recipeScope: "session" | "project" | "global";
89
+ readonly mcpJson: string;
90
+ readonly tools: readonly string[];
91
+ };
92
+ /**
93
+ * Host-owned parts of the worker tool ceiling (bot-granted MCP, private plugin MCP). The ceiling
94
+ * itself lives in one place, `workerToolAllowed`; the host only answers these two questions.
95
+ */
96
+ export type WorkerToolHost = {
97
+ /** Does the recipe grant this wire through its tool list or its `mcpJson` grants? */
98
+ readonly recipeGrantsWire: (catalog: object, spec: RecipeGrantSpec, wire: string, projectPath: string) => boolean;
99
+ /** Is this wire one of the recipe's private plugin MCP tools, not (yet) in the catalog view? */
100
+ readonly privateWireAllowed: (recipeName: string, wire: string, sessionRoot: object | undefined) => boolean;
101
+ };
102
+ export declare const PLAIN_WORKER_HOST: WorkerToolHost;
103
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tool-catalog/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,IAAI,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AE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QAClF,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;QAChD,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;KAChE,CAAC;CACH,CAAC;AAEF,sEAAsE;AACtE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,WAAW,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,qFAAqF;IACrF,QAAQ,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;IAClH,gGAAgG;IAChG,QAAQ,CAAC,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC;CAC7G,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,cAG/B,CAAC"}
@@ -0,0 +1,5 @@
1
+ export const PLAIN_WORKER_HOST = {
2
+ recipeGrantsWire: (_catalog, spec, wire) => spec.tools.includes(wire),
3
+ privateWireAllowed: () => false,
4
+ };
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tool-catalog/types.ts"],"names":[],"mappings":"AA0GA,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C,gBAAgB,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;IACrE,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK;CAChC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Cancel and generic outcome stamps on the leaf. Payload construction lives
3
+ * in harness-model. Cancel writes `cancelled`, not `approved`. Human
4
+ * `approvalComment` is a `TurnApprovalNoteChunk`, not this receipt.
5
+ */
6
+ import { ApprovableJob } from "@inhuman.tools/harness-model";
7
+ export declare function stampToolOutcome(leaf: ApprovableJob, text: "denied" | "cancelled", reason?: unknown): void;
8
+ /**
9
+ * Unstarted (or allow-side but not yet BODY) cancel. Does not write
10
+ * `approved` or `orchestrationResult`.
11
+ */
12
+ export declare const cancelUnstartedTool: (leaf: ApprovableJob, reason?: unknown) => void;
13
+ //# sourceMappingURL=approved.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approved.d.ts","sourceRoot":"","sources":["../../../src/tool-runtime/approval/approved.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,aAAa,EAA4C,MAAM,8BAA8B,CAAC;AAGvG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,CAE1G;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,SAAiB,aAAa,WAAW,OAAO,KAAG,IAGjF,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Cancel and generic outcome stamps on the leaf. Payload construction lives
3
+ * in harness-model. Cancel writes `cancelled`, not `approved`. Human
4
+ * `approvalComment` is a `TurnApprovalNoteChunk`, not this receipt.
5
+ */
6
+ import { applyToolOutcomeReceipt, cancelUnstarted } from "@inhuman.tools/harness-model";
7
+ import { action } from "mobx";
8
+ export function stampToolOutcome(leaf, text, reason) {
9
+ applyToolOutcomeReceipt(leaf, text, reason);
10
+ }
11
+ /**
12
+ * Unstarted (or allow-side but not yet BODY) cancel. Does not write
13
+ * `approved` or `orchestrationResult`.
14
+ */
15
+ export const cancelUnstartedTool = action((leaf, reason) => {
16
+ if (leaf.completed || leaf.cancelled)
17
+ return;
18
+ cancelUnstarted(leaf, reason);
19
+ });
20
+ //# sourceMappingURL=approved.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approved.js","sourceRoot":"","sources":["../../../src/tool-runtime/approval/approved.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAiB,uBAAuB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACvG,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,MAAM,UAAU,gBAAgB,CAAC,IAAmB,EAAE,IAA4B,EAAE,MAAgB;IAClG,uBAAuB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,CAAC,IAAmB,EAAE,MAAgB,EAAQ,EAAE;IACxF,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO;IAC7C,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function distPolicySource(): string;
2
+ /**
3
+ * Body of the one policy program. Never throws. Missing operator → dist.
4
+ */
5
+ export declare function loadPolicySource(kernelFsRoot: string): string | undefined;
6
+ //# sourceMappingURL=dist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dist.d.ts","sourceRoot":"","sources":["../../../src/tool-runtime/approval/dist.ts"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAYD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEzE"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Dist `policy.json` is the never-throwing program in policy-processor.
3
+ * `{kernelFsRoot}/policy.json` wins when present and non-empty.
4
+ */
5
+ import { readFileSync } from "node:fs";
6
+ import { join } from "node:path";
7
+ import { reasonableDefaultsSource } from "@inhuman.tools/policy/floor";
8
+ export function distPolicySource() {
9
+ return reasonableDefaultsSource;
10
+ }
11
+ function readOperatorPolicySource(kernelFsRoot) {
12
+ try {
13
+ const user = readFileSync(join(kernelFsRoot, "policy.json"), "utf8");
14
+ if (user.trim() !== "")
15
+ return user;
16
+ }
17
+ catch {
18
+ /* missing operator policy is dist */
19
+ }
20
+ return undefined;
21
+ }
22
+ /**
23
+ * Body of the one policy program. Never throws. Missing operator → dist.
24
+ */
25
+ export function loadPolicySource(kernelFsRoot) {
26
+ return readOperatorPolicySource(kernelFsRoot) ?? distPolicySource();
27
+ }
28
+ //# sourceMappingURL=dist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dist.js","sourceRoot":"","sources":["../../../src/tool-runtime/approval/dist.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED,SAAS,wBAAwB,CAAC,YAAoB;IACpD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,CAAC;QACrE,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,qCAAqC;IACvC,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,YAAoB;IACnD,OAAO,wBAAwB,CAAC,YAAY,CAAC,IAAI,gBAAgB,EAAE,CAAC;AACtE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ApprovableJob, SessionTurn, type PermissionMode, type SessionPlexus } from "@inhuman.tools/harness-model";
2
+ /** Sequence guard: wait, then true. Never false — that would deny BODY. */
3
+ export declare function inboundTurnGuard(turn: SessionTurn): boolean | Promise<true>;
4
+ export declare function publishPolicyError(session: SessionPlexus, text: string | null): void;
5
+ /** Floor produce is policy-processor `license`. `_policy` is unused — writing it would fork the receipt. */
6
+ export declare function stampLicenseDeny(leaf: ApprovableJob, _policy: PermissionMode): void;
7
+ //# sourceMappingURL=inbound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound.d.ts","sourceRoot":"","sources":["../../../src/tool-runtime/approval/inbound.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EAEb,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AAgBtC,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAM3E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAQpF;AAED,4GAA4G;AAC5G,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAEnF"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * LICENSE WHEN is the Approvable guard. Sequences typically return true;
3
+ * inbound Turn waits predecessors without returning false (false is deny).
4
+ */
5
+ import { FieldAwareness } from "@here.build/plexus";
6
+ import { applyDenyReceipt, SessionTurn, } from "@inhuman.tools/harness-model";
7
+ import { when } from "mobx";
8
+ function inboundPredecessorClosed(turn) {
9
+ if (!turn.inbound)
10
+ return true;
11
+ const seen = new Set([turn]);
12
+ let prior = turn.turnTail;
13
+ while (prior instanceof SessionTurn && !seen.has(prior)) {
14
+ seen.add(prior);
15
+ if (!prior.reducerExited)
16
+ return false;
17
+ if (!prior.inbound)
18
+ break;
19
+ prior = prior.turnTail;
20
+ }
21
+ return true;
22
+ }
23
+ /** Sequence guard: wait, then true. Never false — that would deny BODY. */
24
+ export function inboundTurnGuard(turn) {
25
+ if (inboundPredecessorClosed(turn))
26
+ return true;
27
+ return (async () => {
28
+ await when(() => inboundPredecessorClosed(turn) || turn.cancelled || turn.completed);
29
+ return true;
30
+ })();
31
+ }
32
+ export function publishPolicyError(session, text) {
33
+ try {
34
+ const lane = new FieldAwareness(session.awareness, "policyError");
35
+ if (text == null || text === "")
36
+ lane.clear();
37
+ else
38
+ lane.set(text);
39
+ }
40
+ catch {
41
+ /* presence must not block the floor vote */
42
+ }
43
+ }
44
+ /** Floor produce is policy-processor `license`. `_policy` is unused — writing it would fork the receipt. */
45
+ export function stampLicenseDeny(leaf, _policy) {
46
+ applyDenyReceipt(leaf);
47
+ }
48
+ //# sourceMappingURL=inbound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound.js","sourceRoot":"","sources":["../../../src/tool-runtime/approval/inbound.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAEL,gBAAgB,EAChB,WAAW,GAGZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,SAAS,wBAAwB,CAAC,IAAiB;IACjD,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,IAAI,KAAK,GAAG,IAAI,CAAC,QAAQ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the judge, not
3
+ * `policy_denied`. Operator throw is awareness + dist, not `policy_error`.
4
+ */
5
+ import { type EvalFailureCode, type EvalPermissionMode } from "@inhuman.tools/harness-model";
6
+ export declare function resolveEvalPermissionMode(policy: string): EvalPermissionMode | null;
7
+ export declare function unattendedFailureText(code: EvalFailureCode, policyId: string, reason?: string): string;
8
+ //# sourceMappingURL=unattended.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unattended.d.ts","sourceRoot":"","sources":["../../../src/tool-runtime/approval/unattended.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAwB,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEnH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAEnF;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAatG"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Unattended coded receipts. Residual ask under auto is the judge, not
3
+ * `policy_denied`. Operator throw is awareness + dist, not `policy_error`.
4
+ */
5
+ import { isEvalPermissionMode } from "@inhuman.tools/harness-model";
6
+ export function resolveEvalPermissionMode(policy) {
7
+ return isEvalPermissionMode(policy) ? policy : null;
8
+ }
9
+ export function unattendedFailureText(code, policyId, reason) {
10
+ switch (code) {
11
+ case "interaction_required":
12
+ return `Operation requires human authorization under policy ${policyId}`;
13
+ case "policy_denied":
14
+ return `Operation denied under policy ${policyId}`;
15
+ case "policy_error":
16
+ return reason != null && reason !== ""
17
+ ? `Policy evaluation failed under policy ${policyId}: ${reason}`
18
+ : `Policy evaluation failed under policy ${policyId}`;
19
+ case "policy_unavailable":
20
+ return `Policy ${policyId} is not available`;
21
+ }
22
+ }
23
+ //# sourceMappingURL=unattended.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unattended.js","sourceRoot":"","sources":["../../../src/tool-runtime/approval/unattended.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAiD,MAAM,8BAA8B,CAAC;AAEnH,MAAM,UAAU,yBAAyB,CAAC,MAAc;IACtD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAqB,EAAE,QAAgB,EAAE,MAAe;IAC5F,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,sBAAsB;YACzB,OAAO,uDAAuD,QAAQ,EAAE,CAAC;QAC3E,KAAK,eAAe;YAClB,OAAO,iCAAiC,QAAQ,EAAE,CAAC;QACrD,KAAK,cAAc;YACjB,OAAO,MAAM,IAAI,IAAI,IAAI,MAAM,KAAK,EAAE;gBACpC,CAAC,CAAC,yCAAyC,QAAQ,KAAK,MAAM,EAAE;gBAChE,CAAC,CAAC,yCAAyC,QAAQ,EAAE,CAAC;QAC1D,KAAK,oBAAoB;YACvB,OAAO,UAAU,QAAQ,mBAAmB,CAAC;IACjD,CAAC;AACH,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Write seam for blobs that leave the session document. The kernel's bucket
3
+ * belongs to the daemon; the places that stamp a large text (a file's prior,
4
+ * an isolated completion's prompt, the vacuum of a stored session) put through
5
+ * here and never import the store. Reads go the other way, through
6
+ * `readBlob` in harness-provider-sdk.
7
+ */
8
+ import { type BlobRef } from "@inhuman.tools/harness-model";
9
+ /** Synchronous because the stamping paths are: admit mints a job in one tick. */
10
+ export type BlobWriter = (bytes: Uint8Array, mime: string) => BlobRef;
11
+ /** What a `FileMutateToolJob` takes for its prior text: the text itself, or the reference to it. */
12
+ export type PriorProps = {
13
+ readonly priorContent: string;
14
+ } | {
15
+ readonly priorBlobJson: string;
16
+ };
17
+ /**
18
+ * What {@link externalizeText} decided for a text. `inline` is the text itself. `blob` carries what the
19
+ * document keeps instead: the head for the text field, and the reference (a `StoredBlob` as JSON) for the
20
+ * `*BlobJson` field beside it.
21
+ */
22
+ export type TextStamp = {
23
+ readonly kind: "inline";
24
+ readonly text: string;
25
+ } | {
26
+ readonly kind: "blob";
27
+ readonly head: string;
28
+ readonly blobJson: string;
29
+ };
30
+ /** The host that owns the bucket binds it once at boot. `null` unbinds. */
31
+ export declare function bindBlobWriter(write: BlobWriter | null): void;
32
+ /**
33
+ * Puts bytes through the bound writer and returns the reference. Throws while no writer is bound and when the
34
+ * bucket refuses. For a path that has no inline fallback (the vacuum moves text that is already in the
35
+ * document; a refused put must stop it, not pass silently). The stamping paths use {@link externalizeText}.
36
+ */
37
+ export declare function writeBlob(bytes: Uint8Array, mime: string): BlobRef;
38
+ /**
39
+ * Text within the inline limit stays inline. Larger text goes to the bucket as UTF-8 and the document keeps the
40
+ * reference with the head that paint and stubs read. With no writer bound, or a bucket that refuses the write,
41
+ * the text stays inline as it always did: a text is never lost to a full disk.
42
+ */
43
+ export declare function externalizeText(text: string, mime?: string): TextStamp;
44
+ /** {@link externalizeText} in the shape a `FileMutateToolJob` takes. */
45
+ export declare function externalizePrior(text: string): PriorProps;
46
+ //# sourceMappingURL=blob-port.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-port.d.ts","sourceRoot":"","sources":["../../src/tool-runtime/blob-port.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAgD,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAE1G,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;AAEtE,oGAAoG;AACpG,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAMhF,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAGlE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,SAAS,CASjF;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAGzD"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Write seam for blobs that leave the session document. The kernel's bucket
3
+ * belongs to the daemon; the places that stamp a large text (a file's prior,
4
+ * an isolated completion's prompt, the vacuum of a stored session) put through
5
+ * here and never import the store. Reads go the other way, through
6
+ * `readBlob` in harness-provider-sdk.
7
+ */
8
+ import { blobHeadOf, exceedsInlineMax, storedBlobJson } from "@inhuman.tools/harness-model";
9
+ const TEXT_MIME = "text/plain";
10
+ let writer = null;
11
+ /** The host that owns the bucket binds it once at boot. `null` unbinds. */
12
+ export function bindBlobWriter(write) {
13
+ writer = write;
14
+ }
15
+ /**
16
+ * Puts bytes through the bound writer and returns the reference. Throws while no writer is bound and when the
17
+ * bucket refuses. For a path that has no inline fallback (the vacuum moves text that is already in the
18
+ * document; a refused put must stop it, not pass silently). The stamping paths use {@link externalizeText}.
19
+ */
20
+ export function writeBlob(bytes, mime) {
21
+ if (writer === null)
22
+ throw new Error("no blob writer is bound");
23
+ return writer(bytes, mime);
24
+ }
25
+ /**
26
+ * Text within the inline limit stays inline. Larger text goes to the bucket as UTF-8 and the document keeps the
27
+ * reference with the head that paint and stubs read. With no writer bound, or a bucket that refuses the write,
28
+ * the text stays inline as it always did: a text is never lost to a full disk.
29
+ */
30
+ export function externalizeText(text, mime = TEXT_MIME) {
31
+ if (writer === null || !exceedsInlineMax(text))
32
+ return { kind: "inline", text };
33
+ try {
34
+ const ref = writer(Buffer.from(text, "utf8"), mime);
35
+ const head = blobHeadOf(text);
36
+ return { kind: "blob", head, blobJson: storedBlobJson({ ...ref, head }) };
37
+ }
38
+ catch {
39
+ return { kind: "inline", text };
40
+ }
41
+ }
42
+ /** {@link externalizeText} in the shape a `FileMutateToolJob` takes. */
43
+ export function externalizePrior(text) {
44
+ const stamp = externalizeText(text);
45
+ return stamp.kind === "inline" ? { priorContent: stamp.text } : { priorBlobJson: stamp.blobJson };
46
+ }
47
+ //# sourceMappingURL=blob-port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blob-port.js","sourceRoot":"","sources":["../../src/tool-runtime/blob-port.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAgB,MAAM,8BAA8B,CAAC;AAiB1G,MAAM,SAAS,GAAG,YAAY,CAAC;AAE/B,IAAI,MAAM,GAAsB,IAAI,CAAC;AAErC,2EAA2E;AAC3E,MAAM,UAAU,cAAc,CAAC,KAAwB;IACrD,MAAM,GAAG,KAAK,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,KAAiB,EAAE,IAAY;IACvD,IAAI,MAAM,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAChE,OAAO,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,OAAe,SAAS;IACpE,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAChF,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;QACpD,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAC5E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAClC,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;AACpG,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function runWithExtraRoot<T>(allow: boolean, fn: () => T): T;
2
+ export declare function extraRootAllowed(): boolean;
3
+ //# sourceMappingURL=extra-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extra-root.d.ts","sourceRoot":"","sources":["../../src/tool-runtime/extra-root.ts"],"names":[],"mappings":"AASA,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAElE;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Dispatch-time extra-root flag. Human allow / remainder grant / yolo
3
+ * shell is this spawn, not a file-read grant. Effect bodies read it;
4
+ * they do not set it.
5
+ */
6
+ import { AsyncLocalStorage } from "node:async_hooks";
7
+ const extraRootAls = new AsyncLocalStorage();
8
+ export function runWithExtraRoot(allow, fn) {
9
+ return extraRootAls.run(allow, fn);
10
+ }
11
+ export function extraRootAllowed() {
12
+ return extraRootAls.getStore() === true;
13
+ }
14
+ //# sourceMappingURL=extra-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extra-root.js","sourceRoot":"","sources":["../../src/tool-runtime/extra-root.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,YAAY,GAAG,IAAI,iBAAiB,EAAW,CAAC;AAEtD,MAAM,UAAU,gBAAgB,CAAI,KAAc,EAAE,EAAW;IAC7D,OAAO,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,YAAY,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { AgentCallJob, BotCallJob, CallJob, ProgrammaticJob, SessionRoot, SessionTurn, SystemToolJob, ToolCallJob } from "@inhuman.tools/harness-model";
2
+ import type { ToolCall } from "@inhuman.tools/tool-call-normalize";
3
+ import { type KernelToolCatalog } from "../tool-catalog/index.js";
4
+ /** Catalog face the handler proxies to. A kernel host satisfies this. */
5
+ export type ToolCallKernel = {
6
+ readonly catalog: KernelToolCatalog;
7
+ };
8
+ export type AdmitContext = {
9
+ readonly session?: SessionRoot;
10
+ readonly originTurn?: SessionTurn;
11
+ readonly loadAgentCall?: (uuid: string) => CallJob | undefined;
12
+ /**
13
+ * Receives the job before admit returns. A reachable child can start, so pass
14
+ * this only for a call that may start.
15
+ */
16
+ readonly parent?: {
17
+ registerJob(child: AdmittedCall): void;
18
+ };
19
+ };
20
+ export type AdmittedCall = ToolCallJob | ProgrammaticJob;
21
+ /** Standing bot or owned child from an `agent__ask` / `agent__send` wire. Unknown recipes seal the ceiling. */
22
+ export declare function agentCallFromWire(call: ToolCall, catalog: KernelToolCatalog, ctx?: AdmitContext): BotCallJob | AgentCallJob | SystemToolJob;
23
+ export declare class ToolCallHandler {
24
+ #private;
25
+ readonly kernel: ToolCallKernel;
26
+ constructor(kernel: ToolCallKernel);
27
+ admit(call: ToolCall, catalog?: KernelToolCatalog, ctx?: AdmitContext): AdmittedCall;
28
+ }
29
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/tool-runtime/handler.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,OAAO,EAoBP,eAAe,EAGf,WAAW,EACX,WAAW,EAEX,aAAa,EACb,WAAW,EAQZ,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAQnE,OAAO,EAA8C,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE9G,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CAAC;IAC/D;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAA;KAA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