@intentic/sandbox-contract 1.312.0 → 1.313.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 (352) hide show
  1. package/README.md +26 -3
  2. package/dist/chores/index.d.ts +0 -1
  3. package/dist/chores/index.d.ts.map +1 -1
  4. package/dist/chores/index.js +0 -1
  5. package/dist/chores/index.js.map +1 -1
  6. package/dist/contracts/accounts.contract.d.ts +57 -0
  7. package/dist/contracts/accounts.contract.d.ts.map +1 -1
  8. package/dist/contracts/agent.contract.d.ts +436 -0
  9. package/dist/contracts/agent.contract.d.ts.map +1 -1
  10. package/dist/contracts/agent.contract.js +11 -1
  11. package/dist/contracts/agent.contract.js.map +1 -1
  12. package/dist/contracts/agents.contract.d.ts +123 -96
  13. package/dist/contracts/agents.contract.d.ts.map +1 -1
  14. package/dist/contracts/capabilities.contract.js +1 -1
  15. package/dist/contracts/capabilities.contract.js.map +1 -1
  16. package/dist/contracts/device.contract.d.ts +19 -4
  17. package/dist/contracts/device.contract.d.ts.map +1 -1
  18. package/dist/contracts/device.contract.js +1 -1
  19. package/dist/contracts/device.contract.js.map +1 -1
  20. package/dist/contracts/extensions.contract.d.ts +11 -0
  21. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  22. package/dist/contracts/git.contract.d.ts +2 -0
  23. package/dist/contracts/git.contract.d.ts.map +1 -1
  24. package/dist/contracts/personas.contract.d.ts +2 -0
  25. package/dist/contracts/personas.contract.d.ts.map +1 -1
  26. package/dist/contracts/runner.contract.d.ts +138 -0
  27. package/dist/contracts/runner.contract.d.ts.map +1 -1
  28. package/dist/contracts/secrets.contract.d.ts.map +1 -1
  29. package/dist/contracts/secrets.contract.js +1 -0
  30. package/dist/contracts/secrets.contract.js.map +1 -1
  31. package/dist/contracts/sessions.contract.d.ts +59 -0
  32. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  33. package/dist/contracts/settings.contract.d.ts +12 -8
  34. package/dist/contracts/settings.contract.d.ts.map +1 -1
  35. package/dist/contracts/settings.contract.js +2 -2
  36. package/dist/contracts/settings.contract.js.map +1 -1
  37. package/dist/contracts/system.contract.d.ts +139 -19
  38. package/dist/contracts/system.contract.d.ts.map +1 -1
  39. package/dist/contracts/translator.contract.d.ts +72 -0
  40. package/dist/contracts/translator.contract.d.ts.map +1 -1
  41. package/dist/contracts/workspace.contract.d.ts +85 -14
  42. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  43. package/dist/documents/index.d.ts +1 -0
  44. package/dist/documents/index.d.ts.map +1 -1
  45. package/dist/documents/index.js +1 -0
  46. package/dist/documents/index.js.map +1 -1
  47. package/dist/documents/read.d.ts +24 -0
  48. package/dist/documents/read.d.ts.map +1 -0
  49. package/dist/documents/read.js +81 -0
  50. package/dist/documents/read.js.map +1 -0
  51. package/dist/events/agent-events.d.ts +235 -0
  52. package/dist/events/agent-events.d.ts.map +1 -1
  53. package/dist/events/agent-events.js +3 -0
  54. package/dist/events/agent-events.js.map +1 -1
  55. package/dist/events/child-run.d.ts +9 -0
  56. package/dist/events/child-run.d.ts.map +1 -0
  57. package/dist/events/child-run.js +41 -0
  58. package/dist/events/child-run.js.map +1 -0
  59. package/dist/events/errands.d.ts +5 -0
  60. package/dist/events/errands.d.ts.map +1 -0
  61. package/dist/events/errands.js +19 -0
  62. package/dist/events/errands.js.map +1 -0
  63. package/dist/events/requests.d.ts +152 -0
  64. package/dist/events/requests.d.ts.map +1 -1
  65. package/dist/events/requests.js +26 -1
  66. package/dist/events/requests.js.map +1 -1
  67. package/dist/events/system-events.d.ts +8 -12
  68. package/dist/events/system-events.d.ts.map +1 -1
  69. package/dist/events/transcript.d.ts +387 -0
  70. package/dist/events/transcript.d.ts.map +1 -1
  71. package/dist/events/transcript.js +3 -0
  72. package/dist/events/transcript.js.map +1 -1
  73. package/dist/front/browser-wire.d.ts +6 -0
  74. package/dist/front/browser-wire.d.ts.map +1 -0
  75. package/dist/front/browser-wire.js +4 -0
  76. package/dist/front/browser-wire.js.map +1 -0
  77. package/dist/front/front-wire.d.ts +6 -0
  78. package/dist/front/front-wire.d.ts.map +1 -0
  79. package/dist/front/front-wire.js +5 -0
  80. package/dist/front/front-wire.js.map +1 -0
  81. package/dist/front/generated/browser-wire.d.ts +19 -0
  82. package/dist/front/generated/browser-wire.d.ts.map +1 -0
  83. package/dist/front/generated/browser-wire.js +2 -0
  84. package/dist/front/generated/browser-wire.js.map +1 -0
  85. package/dist/front/generated/wire.d.ts +36 -30
  86. package/dist/front/generated/wire.d.ts.map +1 -1
  87. package/dist/ids/conversation-ids.d.ts +1 -0
  88. package/dist/ids/conversation-ids.d.ts.map +1 -1
  89. package/dist/ids/conversation-ids.js +2 -2
  90. package/dist/ids/conversation-ids.js.map +1 -1
  91. package/dist/ids/session-names.d.ts +3 -0
  92. package/dist/ids/session-names.d.ts.map +1 -1
  93. package/dist/ids/session-names.js +3 -0
  94. package/dist/ids/session-names.js.map +1 -1
  95. package/dist/index.d.ts +1036 -168
  96. package/dist/index.d.ts.map +1 -1
  97. package/dist/index.js +8 -0
  98. package/dist/index.js.map +1 -1
  99. package/dist/models/agent-catalog.d.ts.map +1 -1
  100. package/dist/models/agent-catalog.js +4 -6
  101. package/dist/models/agent-catalog.js.map +1 -1
  102. package/dist/models/agent-runtimes.d.ts +2 -1
  103. package/dist/models/agent-runtimes.d.ts.map +1 -1
  104. package/dist/models/agent-runtimes.js +7 -1
  105. package/dist/models/agent-runtimes.js.map +1 -1
  106. package/dist/models/plan-pools.d.ts +22 -1
  107. package/dist/models/plan-pools.d.ts.map +1 -1
  108. package/dist/models/plan-pools.js +86 -0
  109. package/dist/models/plan-pools.js.map +1 -1
  110. package/dist/policy/request-status.d.ts +1 -1
  111. package/dist/policy/request-status.d.ts.map +1 -1
  112. package/dist/policy/request-status.js +4 -11
  113. package/dist/policy/request-status.js.map +1 -1
  114. package/dist/policy/reserved-servers.d.ts.map +1 -1
  115. package/dist/policy/reserved-servers.js +2 -1
  116. package/dist/policy/reserved-servers.js.map +1 -1
  117. package/dist/policy/turned-away.d.ts.map +1 -1
  118. package/dist/policy/turned-away.js +1 -0
  119. package/dist/policy/turned-away.js.map +1 -1
  120. package/dist/protocol/edge-verdict.d.ts +2 -1
  121. package/dist/protocol/edge-verdict.d.ts.map +1 -1
  122. package/dist/protocol/edge-verdict.js +1 -1
  123. package/dist/protocol/edge-verdict.js.map +1 -1
  124. package/dist/protocol/ingress-contract.d.ts +1 -1
  125. package/dist/protocol/ingress-contract.d.ts.map +1 -1
  126. package/dist/protocol/ingress-contract.js +1 -1
  127. package/dist/protocol/ingress-contract.js.map +1 -1
  128. package/dist/protocol/raw-routes.d.ts +18 -40
  129. package/dist/protocol/raw-routes.d.ts.map +1 -1
  130. package/dist/protocol/raw-routes.js +5 -16
  131. package/dist/protocol/raw-routes.js.map +1 -1
  132. package/dist/protocol/route-meta.d.ts +20 -0
  133. package/dist/protocol/route-meta.d.ts.map +1 -1
  134. package/dist/protocol/route-meta.js +16 -0
  135. package/dist/protocol/route-meta.js.map +1 -1
  136. package/dist/protocol/tunnel-bulk.d.ts +2 -0
  137. package/dist/protocol/tunnel-bulk.d.ts.map +1 -0
  138. package/dist/protocol/tunnel-bulk.js +3 -0
  139. package/dist/protocol/tunnel-bulk.js.map +1 -0
  140. package/dist/protocol/x402.d.ts +17 -0
  141. package/dist/protocol/x402.d.ts.map +1 -0
  142. package/dist/protocol/x402.js +37 -0
  143. package/dist/protocol/x402.js.map +1 -0
  144. package/dist/schemas/agent.d.ts +25 -0
  145. package/dist/schemas/agent.d.ts.map +1 -1
  146. package/dist/schemas/agent.js +14 -2
  147. package/dist/schemas/agent.js.map +1 -1
  148. package/dist/schemas/agents.d.ts +17 -18
  149. package/dist/schemas/agents.d.ts.map +1 -1
  150. package/dist/schemas/agents.js +16 -3
  151. package/dist/schemas/agents.js.map +1 -1
  152. package/dist/schemas/automations.d.ts +4 -6
  153. package/dist/schemas/automations.d.ts.map +1 -1
  154. package/dist/schemas/automations.js.map +1 -1
  155. package/dist/schemas/devices.d.ts +132 -7
  156. package/dist/schemas/devices.d.ts.map +1 -1
  157. package/dist/schemas/devices.js +43 -18
  158. package/dist/schemas/devices.js.map +1 -1
  159. package/dist/schemas/extension-updates.d.ts +22 -0
  160. package/dist/schemas/extension-updates.d.ts.map +1 -1
  161. package/dist/schemas/extension-updates.js +4 -0
  162. package/dist/schemas/extension-updates.js.map +1 -1
  163. package/dist/schemas/git/git.d.ts +3 -0
  164. package/dist/schemas/git/git.d.ts.map +1 -1
  165. package/dist/schemas/hosts.d.ts +29 -5
  166. package/dist/schemas/hosts.d.ts.map +1 -1
  167. package/dist/schemas/hosts.js +20 -7
  168. package/dist/schemas/hosts.js.map +1 -1
  169. package/dist/schemas/keep-warm.d.ts +2 -12
  170. package/dist/schemas/keep-warm.d.ts.map +1 -1
  171. package/dist/schemas/keep-warm.js +8 -10
  172. package/dist/schemas/keep-warm.js.map +1 -1
  173. package/dist/schemas/metrics.d.ts +22 -0
  174. package/dist/schemas/metrics.d.ts.map +1 -1
  175. package/dist/schemas/metrics.js +18 -3
  176. package/dist/schemas/metrics.js.map +1 -1
  177. package/dist/schemas/personas.d.ts +3 -0
  178. package/dist/schemas/personas.d.ts.map +1 -1
  179. package/dist/schemas/personas.js +9 -0
  180. package/dist/schemas/personas.js.map +1 -1
  181. package/dist/schemas/providers/plan-limits.d.ts +140 -0
  182. package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
  183. package/dist/schemas/providers/plan-limits.js +47 -1
  184. package/dist/schemas/providers/plan-limits.js.map +1 -1
  185. package/dist/schemas/providers/provider-oauth.d.ts +57 -0
  186. package/dist/schemas/providers/provider-oauth.d.ts.map +1 -1
  187. package/dist/schemas/providers/provider-oauth.js +6 -1
  188. package/dist/schemas/providers/provider-oauth.js.map +1 -1
  189. package/dist/schemas/settings-history.d.ts +28 -1
  190. package/dist/schemas/settings-history.d.ts.map +1 -1
  191. package/dist/schemas/settings-history.js +35 -1
  192. package/dist/schemas/settings-history.js.map +1 -1
  193. package/dist/schemas/settings.d.ts +184 -4
  194. package/dist/schemas/settings.d.ts.map +1 -1
  195. package/dist/schemas/settings.js +31 -23
  196. package/dist/schemas/settings.js.map +1 -1
  197. package/dist/schemas/speaker.d.ts +36 -0
  198. package/dist/schemas/speaker.d.ts.map +1 -0
  199. package/dist/schemas/speaker.js +62 -0
  200. package/dist/schemas/speaker.js.map +1 -0
  201. package/dist/schemas/state-plan.d.ts +46 -0
  202. package/dist/schemas/state-plan.d.ts.map +1 -0
  203. package/dist/schemas/state-plan.js +31 -0
  204. package/dist/schemas/state-plan.js.map +1 -0
  205. package/dist/schemas/system.d.ts +48 -8
  206. package/dist/schemas/system.d.ts.map +1 -1
  207. package/dist/schemas/system.js +10 -14
  208. package/dist/schemas/system.js.map +1 -1
  209. package/dist/schemas/workspace/mainline.d.ts +206 -64
  210. package/dist/schemas/workspace/mainline.d.ts.map +1 -1
  211. package/dist/schemas/workspace/mainline.js +73 -25
  212. package/dist/schemas/workspace/mainline.js.map +1 -1
  213. package/dist/state/contract-lock.d.ts +1 -0
  214. package/dist/state/contract-lock.d.ts.map +1 -1
  215. package/dist/state/contract-lock.js +47 -1
  216. package/dist/state/contract-lock.js.map +1 -1
  217. package/dist/state/definition.d.ts +24 -16
  218. package/dist/state/definition.d.ts.map +1 -1
  219. package/dist/state/fix-stance.d.ts +1 -1
  220. package/dist/state/fix-stance.d.ts.map +1 -1
  221. package/dist/state/fix-stance.js +2 -1
  222. package/dist/state/fix-stance.js.map +1 -1
  223. package/dist/state/history-state.d.ts.map +1 -1
  224. package/dist/state/history-state.js +2 -0
  225. package/dist/state/history-state.js.map +1 -1
  226. package/dist/state/landed-commit.d.ts +1 -0
  227. package/dist/state/landed-commit.d.ts.map +1 -1
  228. package/dist/state/landed-commit.js +2 -0
  229. package/dist/state/landed-commit.js.map +1 -1
  230. package/dist/state/red-streak.d.ts +7 -0
  231. package/dist/state/red-streak.d.ts.map +1 -0
  232. package/dist/state/red-streak.js +11 -0
  233. package/dist/state/red-streak.js.map +1 -0
  234. package/dist/state/workspace-state.d.ts +1 -0
  235. package/dist/state/workspace-state.d.ts.map +1 -1
  236. package/dist/state/workspace-state.js +6 -2
  237. package/dist/state/workspace-state.js.map +1 -1
  238. package/dist/text/shell-regions.d.ts +1 -0
  239. package/dist/text/shell-regions.d.ts.map +1 -1
  240. package/dist/text/shell-regions.js +1 -1
  241. package/dist/text/shell-regions.js.map +1 -1
  242. package/dist/text/transcript-fold.d.ts.map +1 -1
  243. package/dist/text/transcript-fold.js +14 -7
  244. package/dist/text/transcript-fold.js.map +1 -1
  245. package/package.json +28 -29
  246. package/src/chores/index.ts +0 -1
  247. package/src/contracts/agent.contract.ts +14 -0
  248. package/src/contracts/capabilities.contract.ts +2 -2
  249. package/src/contracts/device.contract.ts +5 -3
  250. package/src/contracts/secrets.contract.ts +2 -0
  251. package/src/contracts/settings.contract.ts +2 -1
  252. package/src/documents/conversions.ts +3 -3
  253. package/src/documents/index.ts +3 -1
  254. package/src/documents/read.ts +114 -0
  255. package/src/events/agent-events.ts +5 -0
  256. package/src/events/child-run.test.ts +81 -0
  257. package/src/events/child-run.ts +73 -0
  258. package/src/events/errands.test.ts +22 -0
  259. package/src/events/errands.ts +27 -0
  260. package/src/events/requests.ts +40 -1
  261. package/src/events/transcript.ts +8 -0
  262. package/src/front/browser-wire.ts +20 -0
  263. package/src/front/front-wire.ts +15 -0
  264. package/src/front/generated/browser-wire.json +138 -0
  265. package/src/front/generated/browser-wire.ts +16 -0
  266. package/src/front/generated/front-wire.json +793 -0
  267. package/src/front/generated/tunnel.json +38 -0
  268. package/src/front/generated/wire.ts +21 -24
  269. package/src/front/wire-manifests.test.ts +61 -0
  270. package/src/ids/conversation-ids.ts +6 -5
  271. package/src/ids/session-names.ts +7 -0
  272. package/src/index.ts +8 -1
  273. package/src/models/agent-catalog.test.ts +6 -4
  274. package/src/models/agent-catalog.ts +4 -6
  275. package/src/models/agent-runtimes.ts +22 -7
  276. package/src/models/capability-ledger.test.ts +2 -0
  277. package/src/models/plan-pools.test.ts +121 -2
  278. package/src/models/plan-pools.ts +152 -2
  279. package/src/policy/request-status.ts +4 -12
  280. package/src/policy/reserved-servers.test.ts +6 -0
  281. package/src/policy/reserved-servers.ts +13 -10
  282. package/src/policy/turned-away.ts +3 -0
  283. package/src/protocol/edge-verdict.ts +13 -11
  284. package/src/protocol/ingress-contract.fixture.json +13 -0
  285. package/src/protocol/ingress-contract.ts +9 -5
  286. package/src/protocol/raw-routes.ts +10 -21
  287. package/src/protocol/route-meta.ts +36 -1
  288. package/src/protocol/tunnel-bulk.test.ts +37 -0
  289. package/src/protocol/tunnel-bulk.ts +7 -0
  290. package/src/protocol/x402.test.ts +29 -0
  291. package/src/protocol/x402.ts +61 -0
  292. package/src/schemas/agent.ts +28 -3
  293. package/src/schemas/agents.ts +32 -6
  294. package/src/schemas/automations.ts +4 -2
  295. package/src/schemas/devices.ts +106 -39
  296. package/src/schemas/extension-updates.ts +6 -0
  297. package/src/schemas/hosts.ts +62 -19
  298. package/src/schemas/ic-shape-args.test.ts +64 -0
  299. package/src/schemas/keep-warm.test.ts +6 -13
  300. package/src/schemas/keep-warm.ts +15 -20
  301. package/src/schemas/metrics.ts +26 -3
  302. package/src/schemas/personas.ts +15 -0
  303. package/src/schemas/providers/plan-limits.ts +71 -1
  304. package/src/schemas/providers/provider-oauth.ts +10 -1
  305. package/src/schemas/settings-history.ts +50 -3
  306. package/src/schemas/settings.test.ts +54 -1
  307. package/src/schemas/settings.ts +49 -31
  308. package/src/schemas/speaker.ts +89 -0
  309. package/src/schemas/state-plan.test.ts +69 -0
  310. package/src/schemas/state-plan.ts +47 -0
  311. package/src/schemas/system.ts +20 -16
  312. package/src/schemas/workspace/mainline.test.ts +28 -0
  313. package/src/schemas/workspace/mainline.ts +111 -44
  314. package/src/state/contract-lock.test.ts +65 -4
  315. package/src/state/contract-lock.ts +70 -2
  316. package/src/state/fix-stance.test.ts +8 -0
  317. package/src/state/fix-stance.ts +3 -3
  318. package/src/state/history-state.ts +5 -1
  319. package/src/state/landed-commit.test.ts +12 -1
  320. package/src/state/landed-commit.ts +5 -0
  321. package/src/state/red-streak.test.ts +28 -0
  322. package/src/state/red-streak.ts +28 -0
  323. package/src/state/workspace-state.test.ts +7 -1
  324. package/src/state/workspace-state.ts +10 -2
  325. package/src/text/shell-regions.test.ts +38 -0
  326. package/src/text/shell-regions.ts +3 -3
  327. package/src/text/transcript-fold.test.ts +13 -0
  328. package/src/text/transcript-fold.ts +17 -8
  329. package/dist/chores/fix-deps.d.ts +0 -10
  330. package/dist/chores/fix-deps.d.ts.map +0 -1
  331. package/dist/chores/fix-deps.js +0 -19
  332. package/dist/chores/fix-deps.js.map +0 -1
  333. package/dist/front/terminal-frames.d.ts +0 -17
  334. package/dist/front/terminal-frames.d.ts.map +0 -1
  335. package/dist/front/terminal-frames.js +0 -79
  336. package/dist/front/terminal-frames.js.map +0 -1
  337. package/dist/protocol/tunnel-lanes.d.ts +0 -10
  338. package/dist/protocol/tunnel-lanes.d.ts.map +0 -1
  339. package/dist/protocol/tunnel-lanes.js +0 -16
  340. package/dist/protocol/tunnel-lanes.js.map +0 -1
  341. package/dist/protocol/upgrade-relay.d.ts +0 -4
  342. package/dist/protocol/upgrade-relay.d.ts.map +0 -1
  343. package/dist/protocol/upgrade-relay.js +0 -25
  344. package/dist/protocol/upgrade-relay.js.map +0 -1
  345. package/src/chores/fix-deps.ts +0 -23
  346. package/src/front/terminal-frames.fixture.json +0 -55
  347. package/src/front/terminal-frames.test.ts +0 -63
  348. package/src/front/terminal-frames.ts +0 -102
  349. package/src/protocol/tunnel-lanes.json +0 -136
  350. package/src/protocol/tunnel-lanes.test.ts +0 -30
  351. package/src/protocol/tunnel-lanes.ts +0 -32
  352. package/src/protocol/upgrade-relay.ts +0 -28
@@ -0,0 +1,73 @@
1
+ import type { ChildAgentAsk, ChildRun } from "./requests.js";
2
+ import type { AgentReply } from "../schemas/providers/plan-limits.js";
3
+
4
+ // How a child agent's run is compared and replaced, stated once: the card deciding whether the owner changed anything,
5
+ // the settle rule recording what started, and the daemon starting it all replace the same fields in the same way.
6
+
7
+ /** A child's run alone, off anything that carries one; absent fields stay absent rather than arriving as undefined. */
8
+ export const childRunOf = (from: ChildRun): ChildRun => {
9
+ const run: ChildRun = { provider: from.provider, model: from.model };
10
+ if (from.harness !== undefined) {
11
+ run.harness = from.harness;
12
+ }
13
+ if (from.account !== undefined) {
14
+ run.account = from.account;
15
+ }
16
+ if (from.effort !== undefined) {
17
+ run.effort = from.effort;
18
+ }
19
+ if (from.thinking !== undefined) {
20
+ run.thinking = from.thinking;
21
+ }
22
+ if (from.fast !== undefined) {
23
+ run.fast = from.fast;
24
+ }
25
+ return run;
26
+ };
27
+
28
+ /**
29
+ * Whether two runs would start the same child. An absent harness is the provider's own loop, as a named `native` is,
30
+ * and an absent speed is the standard one. An absent effort or thinking setting is the model's own default, which is
31
+ * not the same as naming one.
32
+ */
33
+ export const sameChildRun = (left: ChildRun, right: ChildRun): boolean =>
34
+ left.provider === right.provider &&
35
+ left.model === right.model &&
36
+ (left.harness ?? "native") === (right.harness ?? "native") &&
37
+ left.account === right.account &&
38
+ left.effort === right.effort &&
39
+ left.thinking === right.thinking &&
40
+ (left.fast ?? false) === (right.fast ?? false);
41
+
42
+ /**
43
+ * The request as it reads once the owner started the child on `run`: the run replaced whole, with what the agent asked
44
+ * for kept as `proposed`. The same request, unchanged, when `run` is what the agent asked for anyway.
45
+ */
46
+ export const repointedChild = (ask: ChildAgentAsk, run: ChildRun): ChildAgentAsk => {
47
+ if (sameChildRun(ask, run)) {
48
+ return ask;
49
+ }
50
+ const {
51
+ provider: _provider,
52
+ model: _model,
53
+ harness: _harness,
54
+ account: _account,
55
+ effort: _effort,
56
+ thinking: _thinking,
57
+ fast: _fast,
58
+ ...about
59
+ } = ask;
60
+ return { ...about, ...childRunOf(run), proposed: childRunOf(ask) };
61
+ };
62
+
63
+ /**
64
+ * A permission card as a reply leaves its child: a start the owner allowed on a run of their own reads what actually
65
+ * started, so a settled card never names the model that didn't. Anything else, a no included, keeps the card as asked.
66
+ */
67
+ export const startedChildCard = <P extends { readonly child?: ChildAgentAsk | undefined }>(card: P, reply: AgentReply | undefined): P => {
68
+ const ask = card.child;
69
+ if (ask?.move !== "spawn" || reply?.kind !== "permission" || reply.decision === "deny" || reply.child === undefined) {
70
+ return card;
71
+ }
72
+ return { ...card, child: repointedChild(ask, reply.child) };
73
+ };
@@ -0,0 +1,22 @@
1
+ import { errandOfPrompt, errandOfRow } from "./errands.js";
2
+ import { landBreakagePrompt, landFixPrompt } from "./land-breakage.js";
3
+ import { LAND_CONFLICT_OPENING } from "./land-conflict.js";
4
+ import { verifyNudgePrompt } from "./verify-nudge.js";
5
+
6
+ // A row says what it is for since rows carry `errand`; one written before is still read by its opening.
7
+
8
+ describe(`which errand a message is`, () => {
9
+ test(`is what the row says it is, whatever its words`, () => {
10
+ expect(errandOfRow({ role: `user`, text: `Carry on from where you left off.`, errand: `land-fix-nudge` })).toBe(`land-fix-nudge`);
11
+ });
12
+
13
+ test(`is read by its opening on a row written before rows said, and on nothing but a message`, () => {
14
+ expect(errandOfPrompt(landBreakagePrompt([`- a failure`]))).toBe(`land-breakage`);
15
+ expect(errandOfPrompt(landFixPrompt([`- a failure`]))).toBe(`land-fix`);
16
+ expect(errandOfPrompt(verifyNudgePrompt([`x`]))).toBe(`verify-nudge`);
17
+ expect(errandOfPrompt(`${LAND_CONFLICT_OPENING}\n\nthe files`)).toBe(`land-conflict`);
18
+ expect(errandOfPrompt(`Please fix the parser`)).toBeUndefined();
19
+ expect(errandOfRow({ role: `assistant`, text: landFixPrompt([]) })).toBeUndefined();
20
+ expect(errandOfRow({ role: `user`, text: `hello` })).toBeUndefined();
21
+ });
22
+ });
@@ -0,0 +1,27 @@
1
+ import type { TurnErrand } from "../schemas/speaker.js";
2
+ import type { TranscriptRow } from "./transcript.js";
3
+ import { isLandBreakage, isLandFix } from "./land-breakage.js";
4
+ import { LAND_CONFLICT_OPENING } from "./land-conflict.js";
5
+ import { withoutResumeNote } from "./resume.js";
6
+ import { isVerifyNudge } from "./verify-nudge.js";
7
+
8
+ // Which errand a composed prompt is, read the old way: by its opening paragraph, for the rows and turns written before
9
+ // they carried `errand`. The openings are anchored on here, so each must stay byte-identical forever. A prompt the
10
+ // daemon restarted carries its resume note first, so it is read past.
11
+ export const errandOfPrompt = (prompt: string): TurnErrand | undefined => {
12
+ const text = withoutResumeNote(prompt.trim());
13
+ if (text.startsWith(LAND_CONFLICT_OPENING)) {
14
+ return "land-conflict";
15
+ }
16
+ if (isVerifyNudge(text)) {
17
+ return "verify-nudge";
18
+ }
19
+ if (isLandBreakage(text)) {
20
+ return "land-breakage";
21
+ }
22
+ return isLandFix(text) ? "land-fix" : undefined;
23
+ };
24
+
25
+ /** A message row's errand: what the row says, else what its opening names; none for anything but a message. */
26
+ export const errandOfRow = (row: Pick<TranscriptRow, "role" | "text" | "errand">): TurnErrand | undefined =>
27
+ row.role !== "user" ? undefined : (row.errand ?? errandOfPrompt(row.text));
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { AgentProviderSchema } from "../schemas/agent.js";
2
+ import { AgentHarnessSchema, AgentProviderSchema } from "../schemas/agent.js";
3
3
  import { CredentialGateKindSchema, CredentialGateScopeSchema, CredentialLaneSchema } from "../schemas/secrets.js";
4
4
 
5
5
  // Requests a turn raises to ask the person something mid-turn; each pauses the turn until `POST /agent/reply` answers it.
@@ -40,6 +40,42 @@ export const ProgramAskSchema = z.object({
40
40
  });
41
41
  export type ProgramAsk = z.infer<typeof ProgramAskSchema>;
42
42
 
43
+ // What a child agent runs on: who serves it and how. The child-agent gate's request shows it, and the owner's allow may
44
+ // carry a replacement (the permission reply's `child`, plan-limits.ts).
45
+ export const ChildRunSchema = z.object({
46
+ provider: AgentProviderSchema.describe("Which provider serves it."),
47
+ model: z.string().min(1).describe("Which of that provider's models."),
48
+ harness: AgentHarnessSchema.optional().describe("Which agentic loop runs it. Absent is the provider's own."),
49
+ account: z
50
+ .string()
51
+ .optional()
52
+ .describe("Which of that provider's connected accounts pays for it. Absent is whichever has the most room when it starts."),
53
+ effort: z.string().optional().describe("How hard it thinks, where the model offers a choice. Absent is the model's own default."),
54
+ thinking: z.boolean().optional().describe("Whether it reasons before it answers, where the model offers the choice."),
55
+ fast: z.boolean().optional().describe("Whether it asks for the faster rate, at the higher price."),
56
+ });
57
+ export type ChildRun = z.infer<typeof ChildRunSchema>;
58
+
59
+ // A move a parent makes on a child agent that the owner's rules may hold for a yes.
60
+ export const ChildMoveSchema = z.enum(["spawn", "send", "answer"]);
61
+ export type ChildMove = z.infer<typeof ChildMoveSchema>;
62
+
63
+ // The child a held request is about, as the daemon's own record of the call has it, never as the agent describes it.
64
+ export const ChildAgentAskSchema = ChildRunSchema.extend({
65
+ move: ChildMoveSchema.describe("What the parent asks to do: start a new child, say something to one it started, or answer one's question."),
66
+ child: z.string().optional().describe("The child's id, for one that already exists."),
67
+ task: z.string().optional().describe("What the child is for, in a line."),
68
+ message: z
69
+ .string()
70
+ .optional()
71
+ .describe("What the parent would say to it: the message it sends, or the answers it gives. Clipped for the request."),
72
+ on: z.string().optional().describe('Which machine it runs on, when one is named: a runner, or "here" for this sandbox.'),
73
+ proposed: ChildRunSchema.optional().describe(
74
+ "What the agent asked to start it on, when the owner started it on something else instead. Present only once the request has settled that way.",
75
+ ),
76
+ });
77
+ export type ChildAgentAsk = z.infer<typeof ChildAgentAskSchema>;
78
+
43
79
  // One per-tool permission prompt (SDK's canUseTool, surfaced as a request); the daemon passes the bridge's own rendered
44
80
  // strings through unchanged. `alwaysLabel` is present only when the SDK offered a rule to persist.
45
81
  export const PermissionAskSchema = z.object({
@@ -62,6 +98,9 @@ export const PermissionAskSchema = z.object({
62
98
  program: ProgramAskSchema.optional().describe(
63
99
  "The program this request is holding, when the request is about one. Present on a command gate's request and absent on every other permission ask.",
64
100
  ),
101
+ child: ChildAgentAskSchema.optional().describe(
102
+ "The child agent this request would start or reach, and what it runs on. Present on the child-agent gate's request and absent on every other permission ask.",
103
+ ),
65
104
  // The judge's own sentence, present only when the title can't say it; never written by the agent being gated.
66
105
  explain: z
67
106
  .string()
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { AgentHarnessSchema, AgentProviderSchema } from "../schemas/agent.js";
3
3
  import { ShareDetailSchema } from "../schemas/share.js";
4
+ import { TurnErrandSchema, TurnSpeakerSchema } from "../schemas/speaker.js";
4
5
  import { SubagentKindSchema, SubagentStatusSchema, SubagentVerificationSchema } from "../schemas/terminal.js";
5
6
  import { RetryLadderSchema } from "../schemas/turn-break.js";
6
7
  import type { ToolCallContent, ToolCallLocation, ToolCallStatus, ToolKind} from "./requests.js";
@@ -245,6 +246,13 @@ export const TranscriptRowSchema = z.object({
245
246
  .describe(
246
247
  "What the sandbox added to this message before the model saw it. Carried on the message rather than as rows of their own, because they genuinely were part of what was sent.",
247
248
  ),
249
+ // Who spoke a message row, as the sandbox verified it (schemas/speaker.ts), and what a composed one is for: a reader
250
+ // shows the sandbox's own words as the sandbox's, never as the owner's. Absent on rows written before rows said so,
251
+ // which are read by their opening (events/errands.ts).
252
+ speaker: TurnSpeakerSchema.optional().describe("Who sent this message, as the sandbox verified it. Absent where it does not say."),
253
+ errand: TurnErrandSchema.optional().describe(
254
+ "What this message is for, when the sandbox or the app composed it rather than a person typing it. Absent on a person's own words.",
255
+ ),
248
256
  // The user wrote this as the agent, no turn behind it; marked for a human reader, never surfaced to the agent.
249
257
  placed: z
250
258
  .boolean()
@@ -0,0 +1,20 @@
1
+ // Everything a browser sees of a sandbox's front and of the edge in front of it, outside the daemon's oRPC contract. The
2
+ // Rust crates are the definition (`browser-wire`, and `tunnel` for what the edge declares): their types arrive as
3
+ // TypeScript in generated/, and every value here is held to the manifest they write beside it (wire-manifests.test.ts),
4
+ // which contract.lock.json pins.
5
+
6
+ export type { EdgeVerdict, TerminalClientMessage, TerminalServerMessage } from "./generated/browser-wire.js";
7
+
8
+ // Where a terminal socket opens on a sandbox's address. It is a WebSocket whichever way its bytes ride: over TCP, or on a
9
+ // stream of the edge's WebTransport session, where the editor speaks the same protocol itself.
10
+ export const TERMINAL_PATH = "/system/terminal";
11
+
12
+ // Where a browser opens its WebTransport session, on the address of the sandbox the session's streams reach; the edge
13
+ // answers it, never the sandbox.
14
+ export const WEBTRANSPORT_PATH = "/system/transport";
15
+
16
+ // What an edge may declare it serves beyond HTTPS over TCP (the tunnel crate's `Transport`), each only because its own
17
+ // configuration binds it. Undeclared means not served: an editor opens WebTransport only where `webtransport` is named.
18
+ export type EdgeTransport = "quic" | "h3" | "webtransport";
19
+
20
+ export const EDGE_TRANSPORTS: readonly EdgeTransport[] = ["quic", "h3", "webtransport"];
@@ -0,0 +1,15 @@
1
+ // The control socket between intentic-front and the daemon. The Rust crate `front-wire` is the definition: its types
2
+ // arrive as TypeScript in generated/, and every value here is held to the manifest it writes beside it
3
+ // (wire-manifests.test.ts), which contract.lock.json pins.
4
+
5
+ export type * from "./generated/wire.js";
6
+
7
+ // Set by intentic-front on the daemon it spawns: where to dial the control socket, and where to serve HTTP.
8
+ export const FRONT_SOCKET_ENV = "INTENTIC_FRONT_SOCKET";
9
+ export const NODE_SOCKET_ENV = "INTENTIC_NODE_SOCKET";
10
+
11
+ // How long either side waits for the answer to a question it asked before giving up on it.
12
+ export const ASK_PATIENCE_MS = 5000;
13
+
14
+ // A frame is this many bytes of big-endian length, then that many bytes of JSON.
15
+ export const FRAME_LENGTH_BYTES = 4;
@@ -0,0 +1,138 @@
1
+ {
2
+ "edge": {
3
+ "verdictHeader": "x-intentic-edge",
4
+ "verdicts": {
5
+ "description": "The edge's verdicts, the only values [`VERDICT_HEADER`] carries.",
6
+ "oneOf": [
7
+ {
8
+ "const": "no-tunnel",
9
+ "description": "No tunnel is registered: the box is off, and one that comes back redials within seconds.",
10
+ "type": "string"
11
+ },
12
+ {
13
+ "const": "unknown-sandbox",
14
+ "description": "The platform has no such sandbox, and no tunnel for it will be accepted again.",
15
+ "type": "string"
16
+ },
17
+ {
18
+ "const": "dropped",
19
+ "description": "A tunnel was held and the forward failed mid-flight.",
20
+ "type": "string"
21
+ }
22
+ ],
23
+ "title": "EdgeVerdict"
24
+ }
25
+ },
26
+ "terminal": {
27
+ "client": {
28
+ "description": "What the browser sends on a terminal socket, each a JSON text message.",
29
+ "oneOf": [
30
+ {
31
+ "description": "Keystrokes, a paste or a mouse report, written into the pane as their UTF-8 bytes.",
32
+ "properties": {
33
+ "data": {
34
+ "type": "string"
35
+ },
36
+ "type": {
37
+ "const": "input",
38
+ "type": "string"
39
+ }
40
+ },
41
+ "required": [
42
+ "type",
43
+ "data"
44
+ ],
45
+ "type": "object"
46
+ },
47
+ {
48
+ "properties": {
49
+ "cols": {
50
+ "format": "uint16",
51
+ "maximum": 65535,
52
+ "minimum": 0,
53
+ "type": "integer"
54
+ },
55
+ "rows": {
56
+ "format": "uint16",
57
+ "maximum": 65535,
58
+ "minimum": 0,
59
+ "type": "integer"
60
+ },
61
+ "type": {
62
+ "const": "resize",
63
+ "type": "string"
64
+ }
65
+ },
66
+ "required": [
67
+ "type",
68
+ "cols",
69
+ "rows"
70
+ ],
71
+ "type": "object"
72
+ },
73
+ {
74
+ "description": "The client's liveness, the socket's only one: the editor sends one every 30 s and calls the socket stale after\n90 s without a frame. The front answers `pong`, sends a WebSocket ping only to a client silent for 45 s, and closes\none silent for 90.",
75
+ "properties": {
76
+ "type": {
77
+ "const": "ping",
78
+ "type": "string"
79
+ }
80
+ },
81
+ "required": [
82
+ "type"
83
+ ],
84
+ "type": "object"
85
+ }
86
+ ],
87
+ "title": "TerminalClientMessage"
88
+ },
89
+ "path": "/system/terminal",
90
+ "server": {
91
+ "description": "What a terminal socket sends as JSON text; the pane's own bytes travel as binary messages.",
92
+ "oneOf": [
93
+ {
94
+ "description": "The session is over, and the browser must not reconnect; `reason` is tmux's own words when it had any.",
95
+ "properties": {
96
+ "code": {
97
+ "format": "int32",
98
+ "type": "integer"
99
+ },
100
+ "reason": {
101
+ "type": [
102
+ "string",
103
+ "null"
104
+ ]
105
+ },
106
+ "type": {
107
+ "const": "exit",
108
+ "type": "string"
109
+ }
110
+ },
111
+ "required": [
112
+ "type",
113
+ "code"
114
+ ],
115
+ "type": "object"
116
+ },
117
+ {
118
+ "properties": {
119
+ "type": {
120
+ "const": "pong",
121
+ "type": "string"
122
+ }
123
+ },
124
+ "required": [
125
+ "type"
126
+ ],
127
+ "type": "object"
128
+ }
129
+ ],
130
+ "title": "TerminalServerMessage"
131
+ },
132
+ "upgrade": "websocket"
133
+ },
134
+ "webTransport": {
135
+ "alpn": "h3",
136
+ "path": "/system/transport"
137
+ }
138
+ }
@@ -0,0 +1,16 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+
3
+ /**
4
+ * The edge's verdicts, the only values [`VERDICT_HEADER`] carries.
5
+ */
6
+ export type EdgeVerdict = "no-tunnel" | "unknown-sandbox" | "dropped";
7
+
8
+ /**
9
+ * What the browser sends on a terminal socket, each a JSON text message.
10
+ */
11
+ export type TerminalClientMessage = { "type": "input", data: string, } | { "type": "resize", cols: number, rows: number, } | { "type": "ping" };
12
+
13
+ /**
14
+ * What a terminal socket sends as JSON text; the pane's own bytes travel as binary messages.
15
+ */
16
+ export type TerminalServerMessage = { "type": "exit", code: number, reason?: string, } | { "type": "pong" };