@intentic/sandbox-contract 1.431.0 → 1.432.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 (362) hide show
  1. package/README.md +10 -3
  2. package/dist/briefs/agent-ask.d.ts +10 -0
  3. package/dist/briefs/agent-ask.d.ts.map +1 -0
  4. package/dist/briefs/agent-ask.js +2 -0
  5. package/dist/briefs/agent-ask.js.map +1 -0
  6. package/dist/{chores/extension-update.d.ts → briefs/extension-update-brief.d.ts} +1 -1
  7. package/dist/briefs/extension-update-brief.d.ts.map +1 -0
  8. package/dist/{chores/extension-update.js → briefs/extension-update-brief.js} +2 -2
  9. package/dist/briefs/extension-update-brief.js.map +1 -0
  10. package/dist/chores/digest.d.ts.map +1 -1
  11. package/dist/chores/digest.js.map +1 -1
  12. package/dist/chores/index.d.ts +2 -2
  13. package/dist/chores/index.d.ts.map +1 -1
  14. package/dist/chores/index.js +1 -1
  15. package/dist/chores/index.js.map +1 -1
  16. package/dist/chores/prompt.d.ts +1 -9
  17. package/dist/chores/prompt.d.ts.map +1 -1
  18. package/dist/chores/prompt.js +1 -1
  19. package/dist/chores/prompt.js.map +1 -1
  20. package/dist/chores/stack.d.ts.map +1 -1
  21. package/dist/chores/stack.js.map +1 -1
  22. package/dist/chores/verdict.d.ts.map +1 -1
  23. package/dist/chores/verdict.js.map +1 -1
  24. package/dist/chores/workspace-scope.d.ts +1 -3
  25. package/dist/chores/workspace-scope.d.ts.map +1 -1
  26. package/dist/chores/workspace-scope.js +1 -3
  27. package/dist/chores/workspace-scope.js.map +1 -1
  28. package/dist/contracts/agent.contract.d.ts +869 -12
  29. package/dist/contracts/agent.contract.d.ts.map +1 -1
  30. package/dist/contracts/agents.contract.d.ts +291 -4
  31. package/dist/contracts/agents.contract.d.ts.map +1 -1
  32. package/dist/contracts/automations.contract.d.ts +59 -8
  33. package/dist/contracts/automations.contract.d.ts.map +1 -1
  34. package/dist/contracts/capabilities.contract.d.ts +37 -0
  35. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  36. package/dist/contracts/capabilities.contract.js +21 -0
  37. package/dist/contracts/capabilities.contract.js.map +1 -1
  38. package/dist/contracts/ci.contract.d.ts +222 -95
  39. package/dist/contracts/ci.contract.d.ts.map +1 -1
  40. package/dist/contracts/ci.contract.js +87 -26
  41. package/dist/contracts/ci.contract.js.map +1 -1
  42. package/dist/contracts/device-stacks.contract.d.ts +129 -0
  43. package/dist/contracts/device-stacks.contract.d.ts.map +1 -0
  44. package/dist/contracts/device-stacks.contract.js +66 -0
  45. package/dist/contracts/device-stacks.contract.js.map +1 -0
  46. package/dist/contracts/device.contract.d.ts +47 -0
  47. package/dist/contracts/device.contract.d.ts.map +1 -1
  48. package/dist/contracts/extensions.contract.d.ts +603 -0
  49. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  50. package/dist/contracts/extensions.contract.js +10 -1
  51. package/dist/contracts/extensions.contract.js.map +1 -1
  52. package/dist/contracts/needs.contract.d.ts +689 -18
  53. package/dist/contracts/needs.contract.d.ts.map +1 -1
  54. package/dist/contracts/offload.contract.d.ts +21 -0
  55. package/dist/contracts/offload.contract.d.ts.map +1 -1
  56. package/dist/contracts/runner.contract.d.ts +501 -8
  57. package/dist/contracts/runner.contract.d.ts.map +1 -1
  58. package/dist/contracts/seal.contract.d.ts +15 -0
  59. package/dist/contracts/seal.contract.d.ts.map +1 -1
  60. package/dist/contracts/secrets.contract.d.ts +15 -0
  61. package/dist/contracts/secrets.contract.d.ts.map +1 -1
  62. package/dist/contracts/secrets.contract.js +21 -1
  63. package/dist/contracts/secrets.contract.js.map +1 -1
  64. package/dist/contracts/sessions.contract.d.ts +111 -2
  65. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  66. package/dist/contracts/settings.contract.d.ts +57 -42
  67. package/dist/contracts/settings.contract.d.ts.map +1 -1
  68. package/dist/contracts/settings.contract.js +18 -0
  69. package/dist/contracts/settings.contract.js.map +1 -1
  70. package/dist/contracts/stack-grants.contract.d.ts +418 -0
  71. package/dist/contracts/stack-grants.contract.d.ts.map +1 -0
  72. package/dist/contracts/stack-grants.contract.js +46 -0
  73. package/dist/contracts/stack-grants.contract.js.map +1 -0
  74. package/dist/contracts/system.contract.d.ts +188 -69
  75. package/dist/contracts/system.contract.d.ts.map +1 -1
  76. package/dist/contracts/system.contract.js +12 -42
  77. package/dist/contracts/system.contract.js.map +1 -1
  78. package/dist/contracts/workspace.contract.d.ts +0 -55
  79. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  80. package/dist/contracts/workspace.contract.js +0 -19
  81. package/dist/contracts/workspace.contract.js.map +1 -1
  82. package/dist/events/agent-events.d.ts +421 -8
  83. package/dist/events/agent-events.d.ts.map +1 -1
  84. package/dist/events/agent-transcript.d.ts +111 -2
  85. package/dist/events/agent-transcript.d.ts.map +1 -1
  86. package/dist/events/agent-words.d.ts.map +1 -1
  87. package/dist/events/agent-words.js +2 -1
  88. package/dist/events/agent-words.js.map +1 -1
  89. package/dist/events/child-news.d.ts +32 -0
  90. package/dist/events/child-news.d.ts.map +1 -0
  91. package/dist/events/child-news.js +171 -0
  92. package/dist/events/child-news.js.map +1 -0
  93. package/dist/events/prompt-origins.d.ts +42 -0
  94. package/dist/events/prompt-origins.d.ts.map +1 -1
  95. package/dist/events/prompt-origins.js +28 -0
  96. package/dist/events/prompt-origins.js.map +1 -1
  97. package/dist/events/requests.d.ts +14 -0
  98. package/dist/events/requests.d.ts.map +1 -1
  99. package/dist/events/requests.js +12 -0
  100. package/dist/events/requests.js.map +1 -1
  101. package/dist/events/system-events.d.ts +12 -0
  102. package/dist/events/system-events.d.ts.map +1 -1
  103. package/dist/events/transcript.d.ts +559 -10
  104. package/dist/events/transcript.d.ts.map +1 -1
  105. package/dist/events/transcript.js +2 -1
  106. package/dist/events/transcript.js.map +1 -1
  107. package/dist/index.d.ts +2 -4
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js +2 -4
  110. package/dist/index.js.map +1 -1
  111. package/dist/models/model-roles.d.ts +91 -37
  112. package/dist/models/model-roles.d.ts.map +1 -1
  113. package/dist/models/model-roles.js +106 -35
  114. package/dist/models/model-roles.js.map +1 -1
  115. package/dist/models/model-setups.d.ts +10 -8
  116. package/dist/models/model-setups.d.ts.map +1 -1
  117. package/dist/models/model-setups.js +15 -15
  118. package/dist/models/model-setups.js.map +1 -1
  119. package/dist/policy/approvals-execution.d.ts +5 -2
  120. package/dist/policy/approvals-execution.d.ts.map +1 -1
  121. package/dist/policy/approvals-execution.js +3 -4
  122. package/dist/policy/approvals-execution.js.map +1 -1
  123. package/dist/policy/batch-runs.d.ts +1 -1
  124. package/dist/policy/batch-runs.d.ts.map +1 -1
  125. package/dist/policy/batch-runs.js +2 -1
  126. package/dist/policy/batch-runs.js.map +1 -1
  127. package/dist/policy/message-limits.d.ts.map +1 -1
  128. package/dist/policy/message-limits.js.map +1 -1
  129. package/dist/policy/org-locks.d.ts +1 -1
  130. package/dist/policy/org-locks.d.ts.map +1 -1
  131. package/dist/policy/org-locks.js +1 -0
  132. package/dist/policy/org-locks.js.map +1 -1
  133. package/dist/policy/shell/workspace-root-exclude.d.ts +4 -0
  134. package/dist/policy/shell/workspace-root-exclude.d.ts.map +1 -0
  135. package/dist/policy/shell/workspace-root-exclude.js +4 -0
  136. package/dist/policy/shell/workspace-root-exclude.js.map +1 -0
  137. package/dist/protocol/doors/listener-protocol.d.ts +7 -0
  138. package/dist/protocol/doors/listener-protocol.d.ts.map +1 -1
  139. package/dist/protocol/doors/listener-protocol.js +1 -0
  140. package/dist/protocol/doors/listener-protocol.js.map +1 -1
  141. package/dist/protocol/doors/webext-links.d.ts.map +1 -1
  142. package/dist/protocol/doors/webext-links.js.map +1 -1
  143. package/dist/protocol/raw/extension-protocol.d.ts +518 -0
  144. package/dist/protocol/raw/extension-protocol.d.ts.map +1 -1
  145. package/dist/protocol/raw/extension-protocol.js +276 -0
  146. package/dist/protocol/raw/extension-protocol.js.map +1 -1
  147. package/dist/protocol/raw/raw-json-routes.d.ts +60 -0
  148. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  149. package/dist/protocol/raw/raw-routes.d.ts +81 -1
  150. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  151. package/dist/protocol/raw/raw-routes.js +16 -1
  152. package/dist/protocol/raw/raw-routes.js.map +1 -1
  153. package/dist/schemas/activity.d.ts.map +1 -1
  154. package/dist/schemas/activity.js.map +1 -1
  155. package/dist/schemas/agent.d.ts +4 -0
  156. package/dist/schemas/agent.d.ts.map +1 -1
  157. package/dist/schemas/agent.js +4 -2
  158. package/dist/schemas/agent.js.map +1 -1
  159. package/dist/schemas/agents-list.d.ts +6 -0
  160. package/dist/schemas/agents-list.d.ts.map +1 -1
  161. package/dist/schemas/agents.d.ts +12 -0
  162. package/dist/schemas/agents.d.ts.map +1 -1
  163. package/dist/schemas/automations.d.ts +87 -27
  164. package/dist/schemas/automations.d.ts.map +1 -1
  165. package/dist/schemas/automations.js +15 -33
  166. package/dist/schemas/automations.js.map +1 -1
  167. package/dist/schemas/ci-deployments.d.ts +30 -0
  168. package/dist/schemas/ci-deployments.d.ts.map +1 -0
  169. package/dist/schemas/ci-deployments.js +18 -0
  170. package/dist/schemas/ci-deployments.js.map +1 -0
  171. package/dist/schemas/ci.d.ts +348 -21
  172. package/dist/schemas/ci.d.ts.map +1 -1
  173. package/dist/schemas/ci.js +110 -19
  174. package/dist/schemas/ci.js.map +1 -1
  175. package/dist/schemas/command-run.d.ts +29 -0
  176. package/dist/schemas/command-run.d.ts.map +1 -0
  177. package/dist/schemas/command-run.js +20 -0
  178. package/dist/schemas/command-run.js.map +1 -0
  179. package/dist/schemas/data-protection.d.ts +15 -2
  180. package/dist/schemas/data-protection.d.ts.map +1 -1
  181. package/dist/schemas/data-protection.js +15 -23
  182. package/dist/schemas/data-protection.js.map +1 -1
  183. package/dist/schemas/device-stacks.d.ts +131 -0
  184. package/dist/schemas/device-stacks.d.ts.map +1 -1
  185. package/dist/schemas/device-stacks.js +81 -0
  186. package/dist/schemas/device-stacks.js.map +1 -1
  187. package/dist/schemas/devices.d.ts +73 -0
  188. package/dist/schemas/devices.d.ts.map +1 -1
  189. package/dist/schemas/devices.js +6 -2
  190. package/dist/schemas/devices.js.map +1 -1
  191. package/dist/schemas/extension-updates.d.ts +1184 -0
  192. package/dist/schemas/extension-updates.d.ts.map +1 -1
  193. package/dist/schemas/extension-updates.js +18 -4
  194. package/dist/schemas/extension-updates.js.map +1 -1
  195. package/dist/schemas/host-power.d.ts +22 -0
  196. package/dist/schemas/host-power.d.ts.map +1 -1
  197. package/dist/schemas/host-power.js +55 -0
  198. package/dist/schemas/host-power.js.map +1 -1
  199. package/dist/schemas/hosts.d.ts +226 -0
  200. package/dist/schemas/hosts.d.ts.map +1 -1
  201. package/dist/schemas/hosts.js +24 -0
  202. package/dist/schemas/hosts.js.map +1 -1
  203. package/dist/schemas/issues.d.ts +35 -249
  204. package/dist/schemas/issues.d.ts.map +1 -1
  205. package/dist/schemas/issues.js +9 -43
  206. package/dist/schemas/issues.js.map +1 -1
  207. package/dist/schemas/maintenance.d.ts.map +1 -1
  208. package/dist/schemas/maintenance.js.map +1 -1
  209. package/dist/schemas/metrics.d.ts +25 -0
  210. package/dist/schemas/metrics.d.ts.map +1 -1
  211. package/dist/schemas/metrics.js +18 -0
  212. package/dist/schemas/metrics.js.map +1 -1
  213. package/dist/schemas/need-kinds.d.ts +19 -0
  214. package/dist/schemas/need-kinds.d.ts.map +1 -0
  215. package/dist/schemas/need-kinds.js +7 -0
  216. package/dist/schemas/need-kinds.js.map +1 -0
  217. package/dist/schemas/needs.d.ts +523 -30
  218. package/dist/schemas/needs.d.ts.map +1 -1
  219. package/dist/schemas/needs.js +36 -6
  220. package/dist/schemas/needs.js.map +1 -1
  221. package/dist/schemas/offload.d.ts +52 -0
  222. package/dist/schemas/offload.d.ts.map +1 -1
  223. package/dist/schemas/offload.js +12 -0
  224. package/dist/schemas/offload.js.map +1 -1
  225. package/dist/schemas/outward-action.d.ts +39 -0
  226. package/dist/schemas/outward-action.d.ts.map +1 -0
  227. package/dist/schemas/outward-action.js +40 -0
  228. package/dist/schemas/outward-action.js.map +1 -0
  229. package/dist/schemas/providers/plan-limits.d.ts +1 -0
  230. package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
  231. package/dist/schemas/providers/plan-limits.js +1 -0
  232. package/dist/schemas/providers/plan-limits.js.map +1 -1
  233. package/dist/schemas/secrets.d.ts +17 -0
  234. package/dist/schemas/secrets.d.ts.map +1 -1
  235. package/dist/schemas/secrets.js +12 -5
  236. package/dist/schemas/secrets.js.map +1 -1
  237. package/dist/schemas/settings-history.d.ts +1 -1
  238. package/dist/schemas/settings-history.d.ts.map +1 -1
  239. package/dist/schemas/settings-history.js +5 -4
  240. package/dist/schemas/settings-history.js.map +1 -1
  241. package/dist/schemas/settings-savings.d.ts +58 -0
  242. package/dist/schemas/settings-savings.d.ts.map +1 -1
  243. package/dist/schemas/settings-savings.js +22 -0
  244. package/dist/schemas/settings-savings.js.map +1 -1
  245. package/dist/schemas/settings.d.ts +2 -42
  246. package/dist/schemas/settings.d.ts.map +1 -1
  247. package/dist/schemas/settings.js +5 -6
  248. package/dist/schemas/settings.js.map +1 -1
  249. package/dist/schemas/stack-grants.d.ts +60 -0
  250. package/dist/schemas/stack-grants.d.ts.map +1 -0
  251. package/dist/schemas/stack-grants.js +33 -0
  252. package/dist/schemas/stack-grants.js.map +1 -0
  253. package/dist/schemas/watch-sources.d.ts +72 -0
  254. package/dist/schemas/watch-sources.d.ts.map +1 -0
  255. package/dist/schemas/watch-sources.js +88 -0
  256. package/dist/schemas/watch-sources.js.map +1 -0
  257. package/dist/schemas/workspace/workspace-search.d.ts.map +1 -1
  258. package/dist/schemas/workspace/workspace-search.js +1 -1
  259. package/dist/schemas/workspace/workspace-search.js.map +1 -1
  260. package/dist/schemas/wsl-memory.d.ts +76 -0
  261. package/dist/schemas/wsl-memory.d.ts.map +1 -0
  262. package/dist/schemas/wsl-memory.js +36 -0
  263. package/dist/schemas/wsl-memory.js.map +1 -0
  264. package/dist/state/auth-state.d.ts.map +1 -1
  265. package/dist/state/auth-state.js +2 -0
  266. package/dist/state/auth-state.js.map +1 -1
  267. package/dist/state/definition.d.ts +4 -8
  268. package/dist/state/definition.d.ts.map +1 -1
  269. package/dist/state/workspace-state.d.ts +8 -3
  270. package/dist/state/workspace-state.d.ts.map +1 -1
  271. package/dist/state/workspace-state.js +8 -3
  272. package/dist/state/workspace-state.js.map +1 -1
  273. package/package.json +5 -5
  274. package/src/briefs/agent-ask.ts +23 -0
  275. package/src/{chores/extension-update.ts → briefs/extension-update-brief.ts} +3 -2
  276. package/src/chores/digest.ts +1 -0
  277. package/src/chores/index.ts +13 -2
  278. package/src/chores/prompt.ts +3 -18
  279. package/src/chores/stack.ts +1 -0
  280. package/src/chores/verdict.ts +1 -0
  281. package/src/chores/workspace-scope.ts +3 -8
  282. package/src/contracts/capabilities.contract.ts +24 -0
  283. package/src/contracts/ci.contract.ts +119 -37
  284. package/src/contracts/device-stacks.contract.ts +97 -0
  285. package/src/contracts/extensions.contract.ts +11 -0
  286. package/src/contracts/secrets.contract.ts +27 -0
  287. package/src/contracts/settings.contract.ts +24 -0
  288. package/src/contracts/stack-grants.contract.ts +51 -0
  289. package/src/contracts/system.contract.ts +16 -59
  290. package/src/contracts/workspace.contract.ts +0 -22
  291. package/src/events/agent-words.ts +3 -1
  292. package/src/events/child-news.test.ts +91 -0
  293. package/src/events/child-news.ts +269 -0
  294. package/src/events/prompt-origins.ts +35 -0
  295. package/src/events/requests.ts +18 -0
  296. package/src/events/transcript.ts +10 -1
  297. package/src/index.ts +3 -6
  298. package/src/models/model-roles.test.ts +61 -4
  299. package/src/models/model-roles.ts +153 -49
  300. package/src/models/model-setups.ts +49 -26
  301. package/src/policy/approvals-execution.ts +11 -6
  302. package/src/policy/batch-runs.ts +2 -2
  303. package/src/policy/message-limits.ts +8 -4
  304. package/src/policy/org-locks.ts +1 -0
  305. package/src/policy/shell/workspace-root-exclude.ts +11 -0
  306. package/src/protocol/doors/listener-protocol.ts +14 -0
  307. package/src/protocol/doors/webext-links.ts +3 -1
  308. package/src/protocol/raw/extension-protocol.ts +469 -2
  309. package/src/protocol/raw/raw-routes.ts +45 -4
  310. package/src/schemas/activity.ts +2 -1
  311. package/src/schemas/agent.test.ts +3 -0
  312. package/src/schemas/agent.ts +10 -4
  313. package/src/schemas/automations.ts +25 -41
  314. package/src/schemas/ci-deployments.ts +26 -0
  315. package/src/schemas/ci.ts +185 -45
  316. package/src/schemas/command-run.ts +44 -0
  317. package/src/schemas/data-protection.ts +28 -34
  318. package/src/schemas/device-stacks.ts +162 -3
  319. package/src/schemas/devices.ts +13 -2
  320. package/src/schemas/extension-updates.ts +27 -7
  321. package/src/schemas/host-power.test.ts +53 -0
  322. package/src/schemas/host-power.ts +96 -2
  323. package/src/schemas/hosts.test.ts +32 -0
  324. package/src/schemas/hosts.ts +62 -0
  325. package/src/schemas/issues.ts +29 -86
  326. package/src/schemas/maintenance.ts +4 -3
  327. package/src/schemas/metrics.ts +35 -0
  328. package/src/schemas/need-kinds.ts +13 -0
  329. package/src/schemas/needs.ts +57 -16
  330. package/src/schemas/offload.ts +31 -0
  331. package/src/schemas/outward-action.ts +47 -0
  332. package/src/schemas/providers/plan-limits.ts +1 -0
  333. package/src/schemas/secrets.ts +23 -5
  334. package/src/schemas/settings-history.ts +10 -5
  335. package/src/schemas/settings-savings.ts +29 -0
  336. package/src/schemas/settings.test.ts +23 -23
  337. package/src/schemas/settings.ts +10 -12
  338. package/src/schemas/stack-grants.ts +59 -0
  339. package/src/schemas/version-seam.test.ts +4 -1
  340. package/src/schemas/watch-sources.ts +127 -0
  341. package/src/schemas/workspace/workspace-search.ts +5 -2
  342. package/src/schemas/wsl-memory.ts +59 -0
  343. package/src/state/auth-state.ts +7 -0
  344. package/src/state/workspace-state.ts +18 -18
  345. package/src/text/embed.ts +2 -2
  346. package/dist/chores/extension-update.d.ts.map +0 -1
  347. package/dist/chores/extension-update.js.map +0 -1
  348. package/dist/contracts/chores.contract.d.ts +0 -213
  349. package/dist/contracts/chores.contract.d.ts.map +0 -1
  350. package/dist/contracts/chores.contract.js +0 -32
  351. package/dist/contracts/chores.contract.js.map +0 -1
  352. package/dist/contracts/issues.contract.d.ts +0 -106
  353. package/dist/contracts/issues.contract.d.ts.map +0 -1
  354. package/dist/contracts/issues.contract.js +0 -50
  355. package/dist/contracts/issues.contract.js.map +0 -1
  356. package/src/chores/chores.test.ts +0 -24
  357. package/src/chores/digest.test.ts +0 -27
  358. package/src/chores/probes.integration.test.ts +0 -494
  359. package/src/chores/stack.test.ts +0 -140
  360. package/src/chores/verdict.test.ts +0 -761
  361. package/src/contracts/chores.contract.ts +0 -39
  362. package/src/contracts/issues.contract.ts +0 -53
@@ -30,6 +30,16 @@ export const StackServiceSchema = z.object({
30
30
  });
31
31
  export type StackService = z.infer<typeof StackServiceSchema>;
32
32
 
33
+ // (2026-11-25) Who deployed a stack: the machine records the calling sandbox (its link, never a value the call names) in
34
+ // `.intentic-deploy.json`, and refuses deploy_stack, stack_action and stack_logs on that stack to every other sandbox.
35
+ // `list_stacks` shows it on managed stacks so a board can say "deployed by another sandbox" instead of offering buttons.
36
+ export const StackOwnerSchema = z.object({
37
+ // The sandbox's URL as the link knows it, and whether that is the caller.
38
+ sandbox: z.string(),
39
+ you: z.boolean(),
40
+ });
41
+ export type StackOwner = z.infer<typeof StackOwnerSchema>;
42
+
33
43
  export const DeviceStackSchema = z.object({
34
44
  name: StackNameSchema,
35
45
  // Compose's own summary ("running(2)", "exited(1), running(1)"), passed through.
@@ -41,6 +51,9 @@ export const DeviceStackSchema = z.object({
41
51
  workingDir: z.string().optional(),
42
52
  // Deployed by Intentic into the machine's stacks folder (`root`), rather than started by hand or by another tool.
43
53
  managed: z.boolean(),
54
+ // (2026-11-25) The sandbox that deployed a managed stack, from an agent with `stacks-managed`; absent on an unmanaged
55
+ // stack, on one deployed before the agent recorded owners, and from an older agent.
56
+ owner: StackOwnerSchema.optional(),
44
57
  // A project whose containers belong to an Intentic sandbox (`dev.intentic.kind`): the Devices view drives those,
45
58
  // not a deployments board.
46
59
  sandbox: z.boolean(),
@@ -90,8 +103,9 @@ export type DeviceStackLogsInput = z.infer<typeof DeviceStackLogsInputSchema>;
90
103
 
91
104
  // Deploy a workspace repository's COMMITTED tree (its HEAD, never the uncommitted edits around it) to a device as a
92
105
  // compose stack: the daemon packs it, carries it over the device link, and the machine copies it into `<root>/<name>`
93
- // and brings it up with `--build`. A `.env` already in that folder is kept and never overwritten or sent: secrets are
94
- // placed there through an agent turn, where every secret gate applies.
106
+ // and brings it up with `--build`. A `.env` already in that folder is kept and never overwritten or sent. A managed
107
+ // deploy (DeviceStackManagedDeployInputSchema below) is how the Deployments extension deploys a stack a repository
108
+ // declares, its `.env` filled from the sandbox's secrets under that stack's grant (stack-grants.ts).
95
109
  export const DeviceStackDeployInputSchema = z.object({
96
110
  id: DeviceIdSchema,
97
111
  name: StackNameSchema,
@@ -113,14 +127,159 @@ export const DeviceStackDeployResultSchema = z.object({
113
127
  });
114
128
  export type DeviceStackDeployResult = z.infer<typeof DeviceStackDeployResultSchema>;
115
129
 
130
+ // (2026-11-25) MANAGED DEPLOYS: what a managed deploy (DeviceStackManagedDeployInputSchema) adds to the machine's deploy
131
+ // tool. The daemon renders every `{{secret:…}}` before sending, so these fields carry values, over the
132
+ // device link only, and the machine writes them where compose and docker read them and nowhere else. Sent only to an
133
+ // agent advertising `stacks-managed` (hosts.ts): the args are strict, and an older agent rejects a field it lacks.
134
+
135
+ // How the stack's images come to be: `build` is `up --build` from the deployed tree (what every deploy did before),
136
+ // `images` pulls what the compose file names and never builds.
137
+ export const StackDeployModeSchema = z.enum(["images", "build"]);
138
+ export type StackDeployMode = z.infer<typeof StackDeployModeSchema>;
139
+
140
+ // A registry login, rendered: written into the stack's OWN docker config (`<stack>/.intentic-stack/docker/config.json`), never
141
+ // the machine's, and handed to compose as DOCKER_CONFIG for this stack's pulls alone.
142
+ export const StackRegistryLoginSchema = z
143
+ .object({
144
+ host: z
145
+ .string()
146
+ .min(1)
147
+ .max(253)
148
+ .regex(/^[A-Za-z0-9.-]+(?::\d{1,5})?$/, "a registry host, like ghcr.io or registry.gitlab.com"),
149
+ username: z.string().min(1).max(200),
150
+ password: z.string().min(1).max(10_000),
151
+ })
152
+ .strict();
153
+ export type StackRegistryLogin = z.infer<typeof StackRegistryLoginSchema>;
154
+
155
+ // A command run by the machine's shell in the stack's folder (`sh -c` on Linux and macOS), with COMPOSE_PROJECT_NAME set
156
+ // to the stack. `preDeploy` runs after the new files are in place and before compose touches a container, and a non-zero
157
+ // exit stops the deploy there; `postDeploy` runs once the stack is healthy, and its failure fails the deploy.
158
+ export const StackHookSchema = z.string().min(1).max(4000);
159
+ export const StackHooksSchema = z.object({ preDeploy: StackHookSchema.optional(), postDeploy: StackHookSchema.optional() }).strict();
160
+ export type StackHooks = z.infer<typeof StackHooksSchema>;
161
+
162
+ export const STACK_HEALTH_TIMEOUT_DEFAULT_S = 180;
163
+ // At most ten minutes: the whole deploy (files, hooks, pull, up, health) is one device call under the daemon's ceiling.
164
+ export const STACK_HEALTH_TIMEOUT_MAX_S = 600;
165
+ // How the machine decides a deploy came up: every service running and none restarting, each healthcheck a service
166
+ // declares `healthy`, and each `http` URL (fetched from the machine, so a stack's own loopback ports count) answering
167
+ // 2xx, all within `timeoutSeconds`. The first seconds are not trusted: an old container may still be answering.
168
+ export const StackHealthSchema = z
169
+ .object({
170
+ timeoutSeconds: z.number().int().min(10).max(STACK_HEALTH_TIMEOUT_MAX_S).default(STACK_HEALTH_TIMEOUT_DEFAULT_S),
171
+ http: z.array(z.string().url().max(2000)).max(5).default([]),
172
+ })
173
+ .strict();
174
+ export type StackHealth = z.infer<typeof StackHealthSchema>;
175
+
176
+ // service → image reference pinned by digest (`ghcr.io/o/api@sha256:…`), laid over the compose file as an override
177
+ // (`<stack>/.intentic-stack/pins.yaml`): how a rollback runs exactly the images the earlier deploy ran.
178
+ export const StackImagePinsSchema = z.record(z.string().min(1).max(200), z.string().min(1).max(500));
179
+ export type StackImagePins = z.infer<typeof StackImagePinsSchema>;
180
+
116
181
  // The machine's own tool arguments for a deploy: the folder `stageArtifact` unpacked the bundle into, the stack name,
117
- // the compose file inside it and the commit, recorded beside the stack.
182
+ // the compose file inside it and the commit, recorded beside the stack. Every field after `commit` is a managed deploy's
183
+ // (`stacks-managed`), absent from a plain one, which behaves exactly as before: `--build`, and any `.env` there kept.
118
184
  export const DeployStackToolArgsSchema = z
119
185
  .object({
120
186
  source: z.string().min(1),
121
187
  name: StackNameSchema,
122
188
  composeFile: ComposeFilePathSchema,
123
189
  commit: z.string().regex(/^[0-9a-f]{40,64}$/),
190
+ mode: StackDeployModeSchema.optional(),
191
+ // The whole `.env`, rendered (dotenv lines). Written 0600 and atomically, its sha256 kept in the deploy record; a
192
+ // `.env` there that is not the one the last managed deploy wrote (hand-placed, or edited since) is refused, never
193
+ // overwritten, and the refusal says so. Absent: a `.env` there is left as it is.
194
+ env: z.string().max(256 * 1024).optional(),
195
+ registries: z.array(StackRegistryLoginSchema).max(10).optional(),
196
+ hooks: StackHooksSchema.optional(),
197
+ health: StackHealthSchema.optional(),
198
+ pins: StackImagePinsSchema.optional(),
199
+ // Take over a compose project of this name that no deploy put here (a stack another tool ran, such as Komodo),
200
+ // when none of its containers is running: its named volumes, which compose prefixes with the project name, carry
201
+ // over. A running one is still refused.
202
+ adopt: z.boolean().optional(),
124
203
  })
125
204
  .strict();
126
205
  export type DeployStackToolArgs = z.infer<typeof DeployStackToolArgsSchema>;
206
+
207
+ // service → the image it runs, pinned (`repo@sha256:…`); a locally built image has no registry digest and reads as its
208
+ // image id (`sha256:…`).
209
+ export const StackImageDigestsSchema = z.record(z.string(), z.string());
210
+ export type StackImageDigests = z.infer<typeof StackImageDigestsSchema>;
211
+
212
+ // What `deploy_stack` answers. A plain deploy answers `path` and `output` alone, as it always did; a managed one adds
213
+ // what it ran and how it came up. A failure is a tool error carrying the same story in words.
214
+ export const DeployStackToolResultSchema = z.object({
215
+ path: z.string(),
216
+ output: z.string(),
217
+ digests: StackImageDigestsSchema.optional(),
218
+ // sha256 (hex) of the `.env` this deploy wrote; absent when it wrote none.
219
+ envDigest: z.string().optional(),
220
+ // How long the stack took to come up healthy, in seconds.
221
+ healthySeconds: z.number().optional(),
222
+ });
223
+ export type DeployStackToolResult = z.infer<typeof DeployStackToolResultSchema>;
224
+
225
+ // ---- (2026-11-25) the managed deploy route: the core primitive the Deployments extension's engine stands on ----------
226
+ // The extension holds the policy (its stacks manifest, queue, history, triggers, rollback); the daemon holds what no
227
+ // extension may: secret VALUES. The extension sends `env` and registry passwords with `{{secret:NAME}}` references in
228
+ // them (its own placeholders already filled); the daemon checks the stack's grant (stack-grants.ts), fills the
229
+ // references from its own secret store, logs each use, packs the repository at the commit, carries it to the computer
230
+ // and relays `deploy_stack`. No value reaches the extension: not in the answer, not in an error.
231
+ export const DeviceStackManagedDeployInputSchema = z
232
+ .object({
233
+ id: DeviceIdSchema,
234
+ name: StackNameSchema,
235
+ repo: z.string().min(1).max(500),
236
+ // A full or abbreviated commit, fetched from the repository's remote when the checkout lacks it. Absent: HEAD.
237
+ commit: z
238
+ .string()
239
+ .regex(/^[0-9a-f]{7,64}$/)
240
+ .optional(),
241
+ composeFile: ComposeFilePathSchema.optional(),
242
+ mode: StackDeployModeSchema,
243
+ // Variable → value; a value may hold `{{secret:NAME}}` references, filled here and nowhere else.
244
+ env: z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/), z.string().max(64 * 1024)).optional(),
245
+ // `password` is normally a `{{secret:NAME}}` reference; `host` and `username` are never filled.
246
+ registries: z.array(StackRegistryLoginSchema).max(10).optional(),
247
+ hooks: StackHooksSchema.optional(),
248
+ health: StackHealthSchema.optional(),
249
+ pins: StackImagePinsSchema.optional(),
250
+ adopt: z.boolean().optional(),
251
+ // One line for the secret-use log: what started it ("CI job images-platform", "by a@b.c").
252
+ reason: z.string().max(200).optional(),
253
+ })
254
+ .strict();
255
+ export type DeviceStackManagedDeployInput = z.infer<typeof DeviceStackManagedDeployInputSchema>;
256
+
257
+ export const DeviceStackManagedDeployResultSchema = DeployStackToolResultSchema.extend({
258
+ stack: StackNameSchema,
259
+ // The full commit that went.
260
+ commit: z.string(),
261
+ // The secret names filled in (never a value), and a keyed mark of each value as it went (secrets.ts
262
+ // SecretMarksResponseSchema): what lets the extension tell later that one changed in the store, never holding it.
263
+ secretNames: z.array(z.string()),
264
+ secretMarks: z.record(z.string(), z.string()),
265
+ });
266
+ export type DeviceStackManagedDeployResult = z.infer<typeof DeviceStackManagedDeployResultSchema>;
267
+
268
+ // What `host_stats` answers (device feature `host-stats`), relayed by `GET /system/devices/{id}/host-stats`.
269
+ export const HostStatsSchema = z.object({
270
+ disks: z.array(
271
+ z.object({
272
+ // What the path is: Docker's data root, the stacks folder.
273
+ role: z.enum(["docker", "stacks"]),
274
+ path: z.string(),
275
+ totalBytes: z.number(),
276
+ freeBytes: z.number(),
277
+ }),
278
+ ),
279
+ memory: z.object({ totalBytes: z.number(), availableBytes: z.number() }),
280
+ // 1, 5 and 15 minute load averages; zeros where the OS keeps none (Windows).
281
+ load: z.tuple([z.number(), z.number(), z.number()]),
282
+ cpus: z.number(),
283
+ });
284
+ export type HostStats = z.infer<typeof HostStatsSchema>;
285
+ export const DeviceHostStatsInputSchema = z.object({ id: DeviceIdSchema });
@@ -220,9 +220,20 @@ export type DeviceFlowLine = z.infer<typeof DeviceFlowLineSchema>;
220
220
  // eight minutes), and one sandbox's button disconnected the machine from another.
221
221
  // `power-stay-on` (2026-11-22) changes the power settings that would sleep the computer through scheduled work, on mains
222
222
  // power only (`intentic-machine power stay-on`, `DeviceFacts.power`); only an agent advertising DEVICE_FEATURE_POWER has it.
223
- export const DeviceAgentOpSchema = z.enum(["upgrade", "restart", "forget-unreachable", "power-stay-on"]);
223
+ // `update-pause` and `before-sign-in` (2026-11-27) answer Windows Update's night restarts (`update-restart` in
224
+ // host-power.ts): Windows Update paused until `until`, and Windows' boot task that starts the agent, and with it intentic's
225
+ // engine, before anyone signs in (Windows asks for permission on that PC's screen); only an agent advertising
226
+ // DEVICE_FEATURE_POWER_RESTART has them.
227
+ export const DeviceAgentOpSchema = z.enum(["upgrade", "restart", "forget-unreachable", "power-stay-on", "wsl-memory", "update-pause", "before-sign-in"]);
224
228
  export type DeviceAgentOp = z.infer<typeof DeviceAgentOpSchema>;
225
- export const DeviceAgentFlowSchema = z.strictObject({ op: DeviceAgentOpSchema });
229
+ // (2026-11-26) `memoryGb` goes with `wsl-memory` alone, the size the owner approved; sent only to an agent that advertises
230
+ // `wsl-memory`, since the input is strict and an older agent refuses a field it does not know. (2026-11-27) `until` goes
231
+ // with `update-pause` alone, the moment (epoch ms) Windows Update stays paused until.
232
+ export const DeviceAgentFlowSchema = z.strictObject({
233
+ op: DeviceAgentOpSchema,
234
+ memoryGb: z.number().int().min(1).max(1024).optional(),
235
+ until: z.number().int().positive().optional(),
236
+ });
226
237
  export type DeviceAgentFlow = z.infer<typeof DeviceAgentFlowSchema>;
227
238
  // Adds the device id to the flow input.
228
239
  export const DeviceAgentFlowInputSchema = DeviceAgentFlowSchema.extend({ id: z.string().min(1) });
@@ -11,9 +11,10 @@ const extensionId = z
11
11
  .min(1)
12
12
  .max(121)
13
13
  .regex(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/);
14
- // Owner's per-extension update posture.
15
- // updates: notify (default, badge and wait), agent (also prepares an agent diff-read), auto (apply unattended if
16
- // verified and powers didn't grow, health-watched with auto-revert; otherwise falls back to notify).
14
+ // Owner's update posture, for one extension or as the sandbox's default for every extension without its own answer.
15
+ // updates: auto (the default: apply unattended any release its registry admitted whose powers didn't grow and whose
16
+ // engines this app satisfies, health-watched with auto-revert; anything else waits as with notify), notify (badge and
17
+ // wait) or agent (also prepares an agent diff-read).
17
18
  // advisories: auto-disable (default, since disabling runs no new code) or notify.
18
19
  export const ExtensionUpdatePolicySchema = z.object({
19
20
  updates: z.enum(["notify", "agent", "auto"]),
@@ -41,7 +42,7 @@ export const ExtensionUpdateSchema = z.object({
41
42
  .string()
42
43
  .optional()
43
44
  .describe(
44
- "Why this one was not taken automatically and is asking for a person instead: it wants more than it used to, or nobody has vouched for it.",
45
+ "Why this one was not taken automatically and is asking for a person instead: it wants more than it used to, needs a newer sandbox, or taking it failed.",
45
46
  ),
46
47
  review: z
47
48
  .object({
@@ -78,6 +79,10 @@ export const ExtensionHealthSchema = z.object({
78
79
  .boolean()
79
80
  .optional()
80
81
  .describe("The update was already rolled back without anybody asking. The record stays rather than pretending the attempt never happened."),
82
+ automatic: z
83
+ .boolean()
84
+ .optional()
85
+ .describe("The update was taken by itself under the owner's automatic-updates answer, not by anybody pressing Update."),
81
86
  });
82
87
  export type ExtensionHealth = z.infer<typeof ExtensionHealthSchema>;
83
88
  // Mechanical comparison of two manifests' declared reach (`diffPowers`), as plain sentences the update dialog can
@@ -122,11 +127,19 @@ export const ExtensionUpdateAppliedSchema = z.object({
122
127
  export const ExtensionUpdatePolicyInputSchema = z.object({
123
128
  id: extensionId.describe("Which extension."),
124
129
  updates: z
125
- .enum(["notify", "agent", "auto"])
130
+ .enum(["notify", "agent", "auto", "default"])
126
131
  .optional()
127
- .describe("What to do about a newer version: tell you, have an agent read the difference first, or just take it."),
132
+ .describe(
133
+ "What to do about a newer version: tell you, have an agent read the difference first, or just take it. `default` drops this extension's own answer, so it follows the sandbox's.",
134
+ ),
128
135
  advisories: z.enum(["auto-disable", "notify"]).optional().describe("What to do about a security warning: switch it off at once, or tell you."),
129
136
  });
137
+ // The sandbox's answer for every installed extension that has none of its own.
138
+ export const ExtensionUpdateDefaultsInputSchema = z.object({
139
+ updates: z
140
+ .enum(["notify", "agent", "auto"])
141
+ .describe("What every extension without its own answer does about a newer version: tell you, have an agent read it first, or take it."),
142
+ });
130
143
  export const ExtensionUpdatesCheckedSchema = z.object({
131
144
  ok: z.literal(true).describe("The check ran."),
132
145
  checkedAt: z.string().describe("When, so a screen can date the answer."),
@@ -240,8 +253,12 @@ export const ExtensionSummarySchema = z.object({
240
253
  .optional()
241
254
  .describe("The version kept one step back, which is what going back means."),
242
255
  updatePolicy: ExtensionUpdatePolicySchema.optional().describe(
243
- "The owner's standing answer for this one: tell me, have an agent look, or just do it.",
256
+ "The standing answer that applies to this one: tell me, have an agent look, or just do it. Its own when `updatePolicyOwn`, else the sandbox's default.",
244
257
  ),
258
+ updatePolicyOwn: z
259
+ .boolean()
260
+ .optional()
261
+ .describe("This extension has its own answer about updates, set for it alone. Absent or false means it follows the sandbox's default."),
245
262
  dev: ExtensionDevSchema.optional().describe(
246
263
  "Set while an extension installed from a repository is pointed at a source checkout in this workspace, for working on the extension itself: its code is served from there instead of the pinned copy. `commit` keeps naming the pinned version, which is what updates and the registry compare against.",
247
264
  ),
@@ -353,6 +370,9 @@ export const ExtensionsListSchema = z.object({
353
370
  .describe(
354
371
  "When updates were last looked for. Absent until the first check has run. Sent so a screen can say checked an hour ago rather than presenting staleness as certainty.",
355
372
  ),
373
+ updateDefaults: ExtensionUpdatePolicySchema.optional().describe(
374
+ "The sandbox's answer for every extension installed from a repository that has none of its own. Absent from a sandbox that predates it.",
375
+ ),
356
376
  });
357
377
  // Persisted at .intentic/config/extension-settings.json, keyed by extension id so a re-clone never loses them. Secret
358
378
  // values are stripped from `settings`; `secretsSet` names which ones are set.
@@ -0,0 +1,53 @@
1
+ import { HostPowerFindingSchema, pauseUntilFor, restartBlocks, UPDATE_PAUSE_MAX_MS } from "./host-power.js";
2
+
3
+ // What answers Windows Update's night restart (2026-11-27): how long a pause holds for work booked on the PC, and whether
4
+ // a restart still stops that work once paused or once the PC starts its sandboxes by itself.
5
+
6
+ const HOUR = 3_600_000;
7
+ // 2026-11-26 23:35 UTC: 00:35 on 2026-11-27 on rog, an hour east of UTC.
8
+ const NOW = Date.UTC(2026, 10, 26, 23, 35);
9
+ const ROG = 60;
10
+ // rog's restart window: outside active hours 08:00 to 02:00.
11
+ const NIGHT = { window: { fromHour: 2, toHour: 8 } };
12
+ // The work booked on rog for Friday 05:00 local, which is 04:00 UTC.
13
+ const FRIDAY_FIVE = Date.UTC(2026, 10, 28, 4, 0);
14
+
15
+ describe("pauseUntilFor", () => {
16
+ it("holds Windows Update until the end of the restart window the work falls in, on the PC's own clock", () => {
17
+ // Friday 08:00 local is 07:00 UTC.
18
+ expect(pauseUntilFor(NIGHT, ROG, NOW, FRIDAY_FIVE)).toBe(Date.UTC(2026, 10, 28, 7, 0));
19
+ });
20
+
21
+ it("holds through the next window when the work falls outside one, so a restart never lands just after it", () => {
22
+ // Friday 10:00 local: the next window ends Saturday 08:00 local.
23
+ expect(pauseUntilFor(NIGHT, ROG, NOW, Date.UTC(2026, 10, 28, 9, 0))).toBe(Date.UTC(2026, 10, 29, 7, 0));
24
+ // Exactly at the window's end is the end.
25
+ expect(pauseUntilFor(NIGHT, ROG, NOW, Date.UTC(2026, 10, 28, 7, 0))).toBe(Date.UTC(2026, 10, 28, 7, 0));
26
+ });
27
+
28
+ it("holds two hours past the work where no window was said, and refuses what Windows could not pause for", () => {
29
+ expect(pauseUntilFor({}, ROG, NOW, FRIDAY_FIVE)).toBe(FRIDAY_FIVE + 2 * HOUR);
30
+ expect(pauseUntilFor({}, ROG, NOW, NOW + UPDATE_PAUSE_MAX_MS)).toBeUndefined();
31
+ expect(pauseUntilFor({}, ROG, NOW, NOW + UPDATE_PAUSE_MAX_MS - 2 * HOUR)).toBe(NOW + UPDATE_PAUSE_MAX_MS);
32
+ });
33
+ });
34
+
35
+ describe("restartBlocks", () => {
36
+ it("stops work whose span crosses the window, and not once paused past the work or once the PC brings its sandboxes back", () => {
37
+ expect(restartBlocks(NIGHT, ROG, NOW, FRIDAY_FIVE)).toBe(true);
38
+ expect(restartBlocks({ ...NIGHT, pausedUntil: Date.UTC(2026, 10, 28, 7, 0) }, ROG, NOW, FRIDAY_FIVE)).toBe(false);
39
+ expect(restartBlocks({ ...NIGHT, comesBack: "boot" }, ROG, NOW, FRIDAY_FIVE)).toBe(false);
40
+ // A pause ending Thursday 06:00 local leaves Friday's window from 02:00.
41
+ expect(restartBlocks({ ...NIGHT, pausedUntil: Date.UTC(2026, 10, 27, 5, 0) }, ROG, NOW, FRIDAY_FIVE)).toBe(true);
42
+ });
43
+ });
44
+
45
+ describe("HostPowerFindingSchema", () => {
46
+ it("reads what brings the sandboxes back as unknown when a newer agent says something this build does not know", () => {
47
+ expect(HostPowerFindingSchema.parse({ id: "update-restart", fixable: false, text: "x", comesBack: "wake-on-lan" }).comesBack).toBeUndefined();
48
+ expect(HostPowerFindingSchema.parse({ id: "update-restart", fixable: false, text: "x", comesBack: "boot", offers: ["update-pause"] })).toMatchObject({
49
+ comesBack: "boot",
50
+ offers: ["update-pause"],
51
+ });
52
+ });
53
+ });
@@ -24,13 +24,31 @@ export const POWER_FINDING = {
24
24
  standbyNetwork: "standby-network",
25
25
  // Windows: on battery it still sleeps (after `afterSeconds`, or when the lid closes). Reported, never changed.
26
26
  batterySleep: "battery-sleep",
27
- // Windows Update may restart the computer outside its active hours (`window`), and after a restart nothing runs
28
- // until somebody signs in. Reported, never changed.
27
+ // Windows Update may restart the computer outside its active hours (`window`). Never changed by `power-stay-on`; the
28
+ // agent's `update-pause` and `before-sign-in` ops answer it (`offers`, POWER_REMEDY), and `comesBack` says whether the
29
+ // computer's sandboxes start again by themselves after it or wait for somebody to sign in.
29
30
  updateRestart: "update-restart",
30
31
  // Linux or macOS: the OS may suspend the computer; the fix needs root, so `command` says what to run.
31
32
  osSleep: "os-sleep",
32
33
  } as const;
33
34
 
35
+ /* WHAT ANSWERS A NIGHT RESTART (2026-11-27). The card about Windows Update used to say what would happen and offer nothing
36
+ but "Not now": the restart window is Windows', and after one nothing ran until somebody signed in. Two answers, each an
37
+ agent op the owner's yes runs (DeviceAgentOpSchema): Windows Update paused until after the booked work (`update-pause`,
38
+ for the night in question), and Windows' boot task (`before-sign-in`), which starts the agent with no session, and the
39
+ agent then starts intentic's engine and the sandboxes on it, so a restart costs minutes rather than the night. The
40
+ second needs intentic's engine: Docker Desktop is a program with a window and starts only at a sign-in, so the agent
41
+ offers it only where the sandboxes run on intentic's engine. */
42
+ export const POWER_REMEDY = {
43
+ pauseUpdates: "update-pause",
44
+ beforeSignIn: "before-sign-in",
45
+ } as const;
46
+
47
+ // The longest Windows lets updates be paused for: five weeks, as its own Settings page offers.
48
+ export const UPDATE_PAUSE_MAX_MS = 35 * 24 * 3_600_000;
49
+ // Where the agent did not say when restarts may happen, how long past the booked work a pause holds.
50
+ const PAUSE_PAST_DUE_MS = 2 * 3_600_000;
51
+
34
52
  export const HostPowerFindingSchema = z.object({
35
53
  id: z.string().min(1).describe("Which setting or behaviour (POWER_FINDING), as a string so a newer agent's id still parses."),
36
54
  power: z.enum(["ac", "dc"]).optional().describe("The power source it applies to: ac is mains, dc is battery. Absent where that does not matter."),
@@ -46,6 +64,20 @@ export const HostPowerFindingSchema = z.object({
46
64
  plans: z.array(z.string()).optional().describe("Windows: the power plans that hold the value, by name. A vendor may switch between them by itself."),
47
65
  fixable: z.boolean().describe("Whether the agent's `power-stay-on` op changes it."),
48
66
  command: z.string().optional().describe("Where the agent cannot change it: the command a person runs on that computer."),
67
+ offers: z
68
+ .array(z.string())
69
+ .optional()
70
+ .describe("The agent ops other than `power-stay-on` that answer it (POWER_REMEDY), as strings so a newer agent's still parses."),
71
+ pausedUntil: z.number().optional().describe("For an update restart: Windows Update is paused until then (epoch ms), so it restarts nothing before it."),
72
+ restartPending: z
73
+ .boolean()
74
+ .optional()
75
+ .describe("For an update restart: an update is already installed and waiting for a restart, which a pause may not hold off."),
76
+ comesBack: z
77
+ .enum(["sign-in", "boot"])
78
+ .optional()
79
+ .catch(undefined)
80
+ .describe("For an update restart: what starts this computer's sandboxes again after it, somebody signing in or the computer starting."),
49
81
  text: z.string().min(1).describe("What it does now, in the agent's words (English), for a reader with none of its own for this id."),
50
82
  });
51
83
  export type HostPowerFinding = z.infer<typeof HostPowerFindingSchema>;
@@ -77,3 +109,65 @@ export const insideLocalWindow = (at: number, window: NonNullable<HostPowerFindi
77
109
  }
78
110
  return window.fromHour < window.toHour ? hour >= window.fromHour && hour < window.toHour : hour >= window.fromHour || hour < window.toHour;
79
111
  };
112
+
113
+ /**
114
+ * When `update-pause` should hold Windows Update until, for work due at `dueAt`: the end of the first restart window
115
+ * that ends at or after it, so the night the work runs in is left alone, or two hours past it where the finding names no
116
+ * window. Undefined where that is further off than Windows lets updates be paused from `now`. Pure.
117
+ */
118
+ export const pauseUntilFor = (finding: Pick<HostPowerFinding, "window">, utcOffsetMinutes: number, now: number, dueAt: number): number | undefined => {
119
+ const window = finding.window;
120
+ let until = dueAt + PAUSE_PAST_DUE_MS;
121
+ if (window !== undefined && window.fromHour !== window.toHour) {
122
+ // The next local `toHour` o'clock at or after dueAt, on the computer's own clock.
123
+ const local = new Date(dueAt + utcOffsetMinutes * 60_000);
124
+ const end = Date.UTC(local.getUTCFullYear(), local.getUTCMonth(), local.getUTCDate(), window.toHour) - utcOffsetMinutes * 60_000;
125
+ until = end >= dueAt ? end : end + 24 * 3_600_000;
126
+ }
127
+ return until - now > UPDATE_PAUSE_MAX_MS ? undefined : until;
128
+ };
129
+
130
+ const HOUR_MS = 3_600_000;
131
+ // A local-hours window repeats daily, so a day of hour starts visits every hour it could hold.
132
+ const HOURS_A_DAY = 24;
133
+
134
+ /**
135
+ * Whether any moment from `from` to `to` (epoch ms) falls inside a local-hours window on a computer `utcOffsetMinutes`
136
+ * from UTC. The window is whole local hours, so it is enough to look at `from` and at each local hour's start up to `to`,
137
+ * for at most a day: past that the same hours only come round again. Pure.
138
+ */
139
+ export const windowMeets = (window: NonNullable<HostPowerFinding["window"]>, utcOffsetMinutes: number, from: number, to: number): boolean => {
140
+ if (insideLocalWindow(from, window, utcOffsetMinutes)) {
141
+ return true;
142
+ }
143
+ // The next local hour's start: an offset like +05:30 puts the computer's hours off UTC's.
144
+ const local = from + utcOffsetMinutes * 60_000;
145
+ let at = from - (((local % HOUR_MS) + HOUR_MS) % HOUR_MS) + HOUR_MS;
146
+ for (let step = 0; step < HOURS_A_DAY && at <= to; step += 1, at += HOUR_MS) {
147
+ if (insideLocalWindow(at, window, utcOffsetMinutes)) {
148
+ return true;
149
+ }
150
+ }
151
+ return false;
152
+ };
153
+
154
+ /**
155
+ * Whether an `update-restart` finding would stop work due at `dueAt`, read at `now`: a restart inside its hours between
156
+ * now (or the end of Windows Update's pause, if later) and the work, after which the sandboxes wait for a sign-in. Never
157
+ * where they start again with the computer (`comesBack: boot`), and at any hour where the agent did not say which. Pure.
158
+ */
159
+ export const restartBlocks = (
160
+ finding: Pick<HostPowerFinding, "window" | "pausedUntil" | "comesBack">,
161
+ utcOffsetMinutes: number,
162
+ now: number,
163
+ dueAt: number,
164
+ ): boolean => {
165
+ if (finding.comesBack === "boot") {
166
+ return false;
167
+ }
168
+ const from = Math.max(now, finding.pausedUntil ?? now);
169
+ if (from >= dueAt && finding.pausedUntil !== undefined) {
170
+ return false;
171
+ }
172
+ return finding.window === undefined || windowMeets(finding.window, utcOffsetMinutes, from, dueAt);
173
+ };
@@ -0,0 +1,32 @@
1
+ import { DevicePingSchema } from "./hosts.js";
2
+
3
+ const GIB = 1024 ** 3;
4
+
5
+ // rog on 2026-11-26: Windows at its low line, the VM holding 18.4 GiB, 1.7 GiB of its free memory in blocks under 128 KiB.
6
+ const memory = {
7
+ availableBytes: 3.2 * GIB,
8
+ totalBytes: 31.4 * GIB,
9
+ vm: { workingSetBytes: 18.4 * GIB, at: 1_800_000_000_000 },
10
+ guestFree: { reportableBytes: 1.2 * GIB, strandedBytes: 1.7 * GIB, reportingOrder: 5, at: 1_800_000_000_000 },
11
+ };
12
+
13
+ test("a heartbeat from an agent older than the VM's figures still reads, with Windows' own", () => {
14
+ expect(DevicePingSchema.parse({ ok: true, memory: { availableBytes: 3.2 * GIB, totalBytes: 31.4 * GIB } })).toEqual({
15
+ ok: true,
16
+ memory: { availableBytes: 3.2 * GIB, totalBytes: 31.4 * GIB },
17
+ });
18
+ });
19
+
20
+ test("the VM's footprint and the guest's stranded memory ride the heartbeat whole", () => {
21
+ expect(DevicePingSchema.parse({ ok: true, memory })).toEqual({ ok: true, memory });
22
+ const lowered = { ...memory, guestFree: { ...memory.guestFree, reportingOrder: 2, loweredFrom: 5 } };
23
+ expect(DevicePingSchema.parse({ ok: true, memory: lowered }).memory?.guestFree).toEqual(lowered.guestFree);
24
+ });
25
+
26
+ test("a malformed VM figure reads as missing and never costs Windows' own", () => {
27
+ const parsed = DevicePingSchema.parse({
28
+ ok: true,
29
+ memory: { ...memory, vm: { workingSetBytes: -1, at: 1 }, guestFree: { strandedBytes: "lots" } },
30
+ });
31
+ expect(parsed.memory).toEqual({ availableBytes: memory.availableBytes, totalBytes: memory.totalBytes, vm: undefined, guestFree: undefined });
32
+ });
@@ -1,6 +1,7 @@
1
1
  // hosts: the user's own connected devices (the `host` capability's live half)
2
2
  import { z } from "zod";
3
3
  import { HostPowerSchema } from "./host-power.js";
4
+ import { WslMemorySchema } from "./wsl-memory.js";
4
5
  import { IntenticOsFactsSchema } from "./intentic-os.js";
5
6
  // Manifest says which machines are intended; this says which actually hold a socket now. Nothing persists across a
6
7
  // daemon restart except the enrollment itself, so a closed laptop reads offline within a heartbeat.
@@ -112,9 +113,46 @@ export const DeviceFactsSchema = z.object({
112
113
  // settings (Windows' native side, a Linux or macOS host), never by a WSL distro. Absent from an agent older than the
113
114
  // field, and where the settings could not be read.
114
115
  power: HostPowerSchema.optional(),
116
+ // (2026-11-26) The WSL2 VM's `memory=` and, when it is too big for this PC, the size proposed for it (WslMemorySchema,
117
+ // wsl-memory.ts). Said by Windows' own side alone, once it has read `.wslconfig`; absent everywhere else and from an
118
+ // agent older than the field.
119
+ wslMemory: WslMemorySchema.optional(),
115
120
  });
116
121
  export type DeviceFacts = z.infer<typeof DeviceFactsSchema>;
117
122
 
123
+ /* WHAT THE WSL2 VM HOLDS OF IT, AND WHAT IT HAS FREE BUT CANNOT GIVE BACK (2026-11-26). The VM hands free memory back to
124
+ Windows through free page reporting, which reports only free blocks of at least 2^page_reporting_order pages (WSL's
125
+ kernel line sets 5: 128 KiB). Free memory in smaller blocks stays charged to Windows as the VM's. On rog that day it
126
+ was 2.0-2.6 GB most of the time, and 5.3 of the 8.4 GB a cache drop had just freed. So beside Windows' own figures the
127
+ Windows side says the VM's footprint (`vm`) and, when a distro is already running to read it through (WSL is never
128
+ booted for this), the guest's free memory split at the reporting order (`guestFree`, from /proc/buddyinfo). Both are
129
+ read on their own pace, not per heartbeat, so each carries when; both are absent from an agent older than them, from a
130
+ PC whose VM is not running, and from every side but Windows'. */
131
+ const HostVmMemorySchema = z.object({
132
+ // vmmemWSL's working set: the VM's footprint in Windows' RAM, in bytes. 0: the VM was not running.
133
+ workingSetBytes: z.number().nonnegative(),
134
+ // vmmemWSL's private bytes: what Windows charges the VM, in RAM or pushed out of it, in bytes. Above the working set
135
+ // by what Windows has pushed out (3.5 GiB on rog, 2026-11-26). Absent where only the working set was read.
136
+ privateBytes: z.number().nonnegative().optional(),
137
+ // When it was read, in epoch ms.
138
+ at: z.number(),
139
+ });
140
+ export type HostVmMemory = z.infer<typeof HostVmMemorySchema>;
141
+
142
+ const GuestFreeMemorySchema = z.object({
143
+ // Free inside the VM in blocks free page reporting hands back to Windows (2^reportingOrder pages or larger), in bytes.
144
+ reportableBytes: z.number().nonnegative(),
145
+ // Free inside the VM in smaller blocks: memory the VM does not use, still charged to Windows. In bytes.
146
+ strandedBytes: z.number().nonnegative(),
147
+ // The kernel's page_reporting_order as read.
148
+ reportingOrder: z.number().int().nonnegative(),
149
+ // The order the agent lowered it from, while it holds it lowered (machine `environments/wsl-page-reporting.ts`).
150
+ loweredFrom: z.number().int().nonnegative().optional(),
151
+ // When it was read, in epoch ms.
152
+ at: z.number(),
153
+ });
154
+ export type GuestFreeMemory = z.infer<typeof GuestFreeMemorySchema>;
155
+
118
156
  /* THE HOST'S OWN MEMORY, ON EVERY HEARTBEAT (2026-11-02). A sandbox on a Windows PC runs inside Docker Desktop's WSL2
119
157
  VM, so everything it reads about memory (its cgroup, the VM's /proc/meminfo) is the VM's. On 2026-11-02 rog's Windows
120
158
  was down to 1.1 GB available while the VM held 20 GB, half of it file cache, and the sandbox's heavy-command queue
@@ -127,6 +165,9 @@ const HostMemorySchema = z.object({
127
165
  // Physical memory the OS could hand out now (Windows' ullAvailPhys, standby cache included), in bytes.
128
166
  availableBytes: z.number().nonnegative(),
129
167
  totalBytes: z.number().positive(),
168
+ // A malformed one reads as missing rather than costing the sandbox Windows' own figures above.
169
+ vm: HostVmMemorySchema.optional().catch(undefined),
170
+ guestFree: GuestFreeMemorySchema.optional().catch(undefined),
130
171
  });
131
172
  export type HostMemory = z.infer<typeof HostMemorySchema>;
132
173
 
@@ -229,6 +270,23 @@ export const DeviceFeatureSchema = z.enum([
229
270
  // self-hosted GitHub Actions runners on this computer, read and driven from the Pipelines view
230
271
  // (schemas/ci-fleet.ts). Advertised by a Linux agent: the runners are systemd units.
231
272
  "ci-runners",
273
+ // (2026-11-25) `deploy_stack`'s managed fields (schemas/device-stacks.ts DeployStackToolArgsSchema): a daemon-rendered
274
+ // `.env`, `images` mode (pull, never build), registry logins kept in the stack's own docker config, pre/post-deploy
275
+ // hooks, a health wait, image pins and adopting a stopped project; and every stack recording the sandbox that
276
+ // deployed it, with ops, logs and deploys from any other sandbox refused (stack-grants.ts, and the Deployments extension that owns managed stacks). An agent without it
277
+ // rejects those fields, so the daemon sends them only to one that advertises this.
278
+ "stacks-managed",
279
+ // (2026-11-25) `host_stats`: disk free under Docker's root and the stacks folder, memory and load, for the deploys
280
+ // monitor's low-disk and low-memory alerts (HostStatsSchema in schemas/device-stacks.ts).
281
+ "host-stats",
282
+ // (2026-11-26) The `wsl-memory` agent op: `memory=` in this PC's `.wslconfig` rewritten to the size the owner approved
283
+ // on a card (`DeviceFacts.wslMemory`), by `intentic-machine wsl-memory apply`. Advertised by Windows' own side.
284
+ "wsl-memory",
285
+ // (2026-11-27) The `update-pause` and `before-sign-in` agent ops, the two answers to Windows Update restarting the PC at
286
+ // night (host-power.ts, `update-restart`): Windows Update paused until after work booked here, and Windows' boot task
287
+ // that starts the agent, and with it intentic's engine and its sandboxes, before anyone signs in. Advertised by
288
+ // Windows' own side.
289
+ "power-restart",
232
290
  ]);
233
291
  export type DeviceFeature = z.infer<typeof DeviceFeatureSchema>;
234
292
  export const DEVICE_FEATURE_RESHAPE_LATER: DeviceFeature = "reshape-later";
@@ -252,6 +310,10 @@ export const DEVICE_FEATURE_REMOTE_ICE: DeviceFeature = "remote-ice";
252
310
  export const DEVICE_FEATURE_REMOTE_SERVICE: DeviceFeature = "remote-service";
253
311
  export const DEVICE_FEATURE_POWER: DeviceFeature = "power";
254
312
  export const DEVICE_FEATURE_ADMIN_RUN: DeviceFeature = "admin-run";
313
+ export const DEVICE_FEATURE_STACKS_MANAGED: DeviceFeature = "stacks-managed";
314
+ export const DEVICE_FEATURE_HOST_STATS: DeviceFeature = "host-stats";
315
+ export const DEVICE_FEATURE_WSL_MEMORY: DeviceFeature = "wsl-memory";
316
+ export const DEVICE_FEATURE_POWER_RESTART: DeviceFeature = "power-restart";
255
317
  // What `ic features --json` answers (_hosts/ic/src/features.rs, golden/ic-features.json): the optional ops that ic
256
318
  // implements, as strings, since a newer ic's word means nothing to an older agent.
257
319
  export const IcFeaturesAnswerSchema = z.object({ features: z.array(z.string()) });