@intentic/sandbox-contract 1.408.1 → 1.410.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 (211) hide show
  1. package/dist/contracts/accounts.contract.d.ts +0 -16
  2. package/dist/contracts/accounts.contract.d.ts.map +1 -1
  3. package/dist/contracts/agent.contract.d.ts +54 -0
  4. package/dist/contracts/agent.contract.d.ts.map +1 -1
  5. package/dist/contracts/agents.contract.d.ts +12 -0
  6. package/dist/contracts/agents.contract.d.ts.map +1 -1
  7. package/dist/contracts/automations.contract.d.ts.map +1 -1
  8. package/dist/contracts/automations.contract.js +1 -0
  9. package/dist/contracts/automations.contract.js.map +1 -1
  10. package/dist/contracts/capabilities.contract.d.ts +504 -8
  11. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  12. package/dist/contracts/capabilities.contract.js +74 -1
  13. package/dist/contracts/capabilities.contract.js.map +1 -1
  14. package/dist/contracts/device.contract.d.ts +23 -0
  15. package/dist/contracts/device.contract.d.ts.map +1 -1
  16. package/dist/contracts/extensions.contract.d.ts +350 -4
  17. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  18. package/dist/contracts/hub.contract.d.ts +121 -0
  19. package/dist/contracts/hub.contract.d.ts.map +1 -0
  20. package/dist/contracts/hub.contract.js +32 -0
  21. package/dist/contracts/hub.contract.js.map +1 -0
  22. package/dist/contracts/needs.contract.d.ts +9 -0
  23. package/dist/contracts/needs.contract.d.ts.map +1 -1
  24. package/dist/contracts/runner.contract.d.ts +288 -250
  25. package/dist/contracts/runner.contract.d.ts.map +1 -1
  26. package/dist/contracts/secrets.contract.d.ts +1 -73
  27. package/dist/contracts/secrets.contract.d.ts.map +1 -1
  28. package/dist/contracts/secrets.contract.js +4 -20
  29. package/dist/contracts/secrets.contract.js.map +1 -1
  30. package/dist/contracts/sessions.contract.d.ts +6 -0
  31. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  32. package/dist/contracts/system.contract.d.ts +27 -0
  33. package/dist/contracts/system.contract.d.ts.map +1 -1
  34. package/dist/events/agent-events.d.ts +26 -0
  35. package/dist/events/agent-events.d.ts.map +1 -1
  36. package/dist/events/agent-events.js +3 -0
  37. package/dist/events/agent-events.js.map +1 -1
  38. package/dist/events/agent-transcript.d.ts +6 -0
  39. package/dist/events/agent-transcript.d.ts.map +1 -1
  40. package/dist/events/prompt-origins.d.ts +54 -0
  41. package/dist/events/prompt-origins.d.ts.map +1 -0
  42. package/dist/events/prompt-origins.js +44 -0
  43. package/dist/events/prompt-origins.js.map +1 -0
  44. package/dist/events/transcript.d.ts +31 -45
  45. package/dist/events/transcript.d.ts.map +1 -1
  46. package/dist/events/transcript.js +3 -27
  47. package/dist/events/transcript.js.map +1 -1
  48. package/dist/index.d.ts +2 -2
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +2 -2
  51. package/dist/index.js.map +1 -1
  52. package/dist/netd/generated/wire.d.ts +4 -0
  53. package/dist/netd/generated/wire.d.ts.map +1 -1
  54. package/dist/oauth/google-workspace.d.ts +4 -0
  55. package/dist/oauth/google-workspace.d.ts.map +1 -0
  56. package/dist/oauth/google-workspace.js +6 -0
  57. package/dist/oauth/google-workspace.js.map +1 -0
  58. package/dist/policy/failure-codes.d.ts +4 -0
  59. package/dist/policy/failure-codes.d.ts.map +1 -1
  60. package/dist/policy/failure-codes.js +1 -0
  61. package/dist/policy/failure-codes.js.map +1 -1
  62. package/dist/policy/git/git-connections.d.ts +15 -0
  63. package/dist/policy/git/git-connections.d.ts.map +1 -0
  64. package/dist/policy/git/git-connections.js +34 -0
  65. package/dist/policy/git/git-connections.js.map +1 -0
  66. package/dist/policy/org-locks.d.ts +1 -1
  67. package/dist/policy/org-locks.d.ts.map +1 -1
  68. package/dist/policy/org-locks.js +1 -0
  69. package/dist/policy/org-locks.js.map +1 -1
  70. package/dist/protocol/doors/runner-wake.d.ts +46 -0
  71. package/dist/protocol/doors/runner-wake.d.ts.map +1 -0
  72. package/dist/protocol/doors/runner-wake.js +21 -0
  73. package/dist/protocol/doors/runner-wake.js.map +1 -0
  74. package/dist/protocol/raw/raw-json-routes.d.ts +135 -145
  75. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  76. package/dist/protocol/raw/raw-json-routes.js +7 -7
  77. package/dist/protocol/raw/raw-json-routes.js.map +1 -1
  78. package/dist/protocol/raw/raw-routes.d.ts +19 -4
  79. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  80. package/dist/protocol/raw/raw-routes.js +8 -4
  81. package/dist/protocol/raw/raw-routes.js.map +1 -1
  82. package/dist/schemas/capabilities.d.ts +8 -24
  83. package/dist/schemas/capabilities.d.ts.map +1 -1
  84. package/dist/schemas/capabilities.js +12 -43
  85. package/dist/schemas/capabilities.js.map +1 -1
  86. package/dist/schemas/certificate-request.d.ts +38 -0
  87. package/dist/schemas/certificate-request.d.ts.map +1 -0
  88. package/dist/schemas/certificate-request.js +18 -0
  89. package/dist/schemas/certificate-request.js.map +1 -0
  90. package/dist/schemas/connection-hub.d.ts +347 -0
  91. package/dist/schemas/connection-hub.d.ts.map +1 -0
  92. package/dist/schemas/connection-hub.js +118 -0
  93. package/dist/schemas/connection-hub.js.map +1 -0
  94. package/dist/schemas/device-move.d.ts +46 -0
  95. package/dist/schemas/device-move.d.ts.map +1 -0
  96. package/dist/schemas/device-move.js +34 -0
  97. package/dist/schemas/device-move.js.map +1 -0
  98. package/dist/schemas/device-sign-in.d.ts +25 -0
  99. package/dist/schemas/device-sign-in.d.ts.map +1 -0
  100. package/dist/schemas/device-sign-in.js +24 -0
  101. package/dist/schemas/device-sign-in.js.map +1 -0
  102. package/dist/schemas/devices.d.ts +50 -0
  103. package/dist/schemas/devices.d.ts.map +1 -1
  104. package/dist/schemas/devices.js +6 -0
  105. package/dist/schemas/devices.js.map +1 -1
  106. package/dist/schemas/diagnostics.d.ts +22 -1
  107. package/dist/schemas/diagnostics.d.ts.map +1 -1
  108. package/dist/schemas/diagnostics.js +13 -1
  109. package/dist/schemas/diagnostics.js.map +1 -1
  110. package/dist/schemas/extension-updates.d.ts +700 -8
  111. package/dist/schemas/extension-updates.d.ts.map +1 -1
  112. package/dist/schemas/git/remote-refs.d.ts +1 -0
  113. package/dist/schemas/git/remote-refs.d.ts.map +1 -1
  114. package/dist/schemas/git/remote-refs.js +5 -0
  115. package/dist/schemas/git/remote-refs.js.map +1 -1
  116. package/dist/schemas/git-installs.d.ts +20 -0
  117. package/dist/schemas/git-installs.d.ts.map +1 -0
  118. package/dist/schemas/git-installs.js +46 -0
  119. package/dist/schemas/git-installs.js.map +1 -0
  120. package/dist/schemas/hosts.d.ts +2 -0
  121. package/dist/schemas/hosts.d.ts.map +1 -1
  122. package/dist/schemas/hosts.js +2 -0
  123. package/dist/schemas/hosts.js.map +1 -1
  124. package/dist/schemas/links.d.ts +89 -21
  125. package/dist/schemas/links.d.ts.map +1 -1
  126. package/dist/schemas/links.js +73 -9
  127. package/dist/schemas/links.js.map +1 -1
  128. package/dist/schemas/mcp-sign-in.d.ts +46 -0
  129. package/dist/schemas/mcp-sign-in.d.ts.map +1 -0
  130. package/dist/schemas/mcp-sign-in.js +54 -0
  131. package/dist/schemas/mcp-sign-in.js.map +1 -0
  132. package/dist/schemas/needs.d.ts +8 -0
  133. package/dist/schemas/needs.d.ts.map +1 -1
  134. package/dist/schemas/needs.js +5 -1
  135. package/dist/schemas/needs.js.map +1 -1
  136. package/dist/schemas/providers/provider-oauth.d.ts +0 -16
  137. package/dist/schemas/providers/provider-oauth.d.ts.map +1 -1
  138. package/dist/schemas/providers/provider-oauth.js +0 -4
  139. package/dist/schemas/providers/provider-oauth.js.map +1 -1
  140. package/dist/schemas/sandbox-passwords.d.ts +0 -142
  141. package/dist/schemas/sandbox-passwords.d.ts.map +1 -1
  142. package/dist/schemas/sandbox-passwords.js +1 -33
  143. package/dist/schemas/sandbox-passwords.js.map +1 -1
  144. package/dist/schemas/system.d.ts +4 -0
  145. package/dist/schemas/system.d.ts.map +1 -1
  146. package/dist/schemas/system.js +4 -0
  147. package/dist/schemas/system.js.map +1 -1
  148. package/dist/state/auth-state.d.ts.map +1 -1
  149. package/dist/state/auth-state.js +1 -0
  150. package/dist/state/auth-state.js.map +1 -1
  151. package/dist/state/definition.d.ts +6 -8
  152. package/dist/state/definition.d.ts.map +1 -1
  153. package/dist/text/mentions.d.ts +5 -0
  154. package/dist/text/mentions.d.ts.map +1 -1
  155. package/dist/text/mentions.js +15 -3
  156. package/dist/text/mentions.js.map +1 -1
  157. package/dist/text/transcript-fold.d.ts.map +1 -1
  158. package/dist/text/transcript-fold.js +4 -8
  159. package/dist/text/transcript-fold.js.map +1 -1
  160. package/package.json +5 -5
  161. package/src/contracts/automations.contract.ts +3 -0
  162. package/src/contracts/capabilities.contract.ts +98 -0
  163. package/src/contracts/hub.contract.ts +39 -0
  164. package/src/contracts/secrets.contract.ts +5 -21
  165. package/src/events/agent-events.ts +5 -0
  166. package/src/events/prompt-origins.ts +65 -0
  167. package/src/events/transcript.ts +4 -40
  168. package/src/index.ts +3 -3
  169. package/src/netd/generated/netd-wire.json +24 -0
  170. package/src/netd/generated/wire.ts +8 -2
  171. package/src/oauth/google-workspace.ts +16 -0
  172. package/src/policy/failure-codes.ts +1 -0
  173. package/src/policy/git/git-connections.test.ts +46 -0
  174. package/src/policy/git/git-connections.ts +68 -0
  175. package/src/policy/org-locks.ts +1 -0
  176. package/src/policy/tests/failure-codes.test.ts +3 -1
  177. package/src/protocol/doors/runner-wake.ts +36 -0
  178. package/src/protocol/raw/raw-json-routes.ts +13 -10
  179. package/src/protocol/raw/raw-routes.ts +15 -7
  180. package/src/schemas/capabilities.ts +16 -64
  181. package/src/schemas/certificate-request.ts +28 -0
  182. package/src/schemas/connection-hub.test.ts +28 -0
  183. package/src/schemas/connection-hub.ts +191 -0
  184. package/src/schemas/device-move.ts +54 -0
  185. package/src/schemas/device-sign-in.ts +37 -0
  186. package/src/schemas/devices.ts +11 -0
  187. package/src/schemas/diagnostics.ts +19 -2
  188. package/src/schemas/git/remote-refs.ts +7 -0
  189. package/src/schemas/git-installs.ts +72 -0
  190. package/src/schemas/hosts.ts +4 -0
  191. package/src/schemas/links.ts +108 -14
  192. package/src/schemas/mcp-sign-in.ts +72 -0
  193. package/src/schemas/needs.ts +8 -1
  194. package/src/schemas/providers/provider-oauth.ts +0 -6
  195. package/src/schemas/sandbox-passwords.ts +5 -46
  196. package/src/schemas/system.ts +6 -0
  197. package/src/state/auth-state.ts +3 -0
  198. package/src/text/mentions.test.ts +16 -1
  199. package/src/text/mentions.ts +18 -4
  200. package/src/text/transcript-fold.test.ts +8 -0
  201. package/src/text/transcript-fold.ts +4 -8
  202. package/dist/contracts/sharing.contract.d.ts +0 -58
  203. package/dist/contracts/sharing.contract.d.ts.map +0 -1
  204. package/dist/contracts/sharing.contract.js +0 -41
  205. package/dist/contracts/sharing.contract.js.map +0 -1
  206. package/dist/schemas/providers/account-sharing.d.ts +0 -277
  207. package/dist/schemas/providers/account-sharing.d.ts.map +0 -1
  208. package/dist/schemas/providers/account-sharing.js +0 -68
  209. package/dist/schemas/providers/account-sharing.js.map +0 -1
  210. package/src/contracts/sharing.contract.ts +0 -54
  211. package/src/schemas/providers/account-sharing.ts +0 -123
@@ -142,6 +142,7 @@ export const RAW_ROUTES = {
142
142
  "GET /sandboxes": { agent: true },
143
143
  "POST /sandboxes": { agent: true },
144
144
  "POST /sandboxes/remove": { agent: true },
145
+ "POST /sandboxes/move": { agent: true },
145
146
  // The `wallet` CLI; spend is bounded by the owner's policy and the key never enters the container.
146
147
  "GET /wallet/status": { agent: true, control: "never" },
147
148
  "POST /wallet/fetch": { agent: true, control: "never" },
@@ -210,6 +211,9 @@ export const RAW_ROUTES = {
210
211
  "GET /extension/events": { floor: "maintainer", panel: false, control: "never", stream: true },
211
212
  // The CI webhook receiver, gated by the per-sandbox webhook secret.
212
213
  "POST /ci/webhook/{host}": { auth: "door" },
214
+ // Where an MCP server's authorization server sends the browser back (capabilities/mcp-oauth/): gated by the state of
215
+ // a sign-in this daemon started, and worth nothing without the PKCE verifier only the daemon holds.
216
+ "GET /oauth/mcp/callback": { auth: "door", control: "never" },
213
217
  // Below maintainer a pairing is capped to port-mirror, so a collaborator may mint a preview tunnel.
214
218
  "POST /system/sync/pair": { floor: "collaborator", control: "never" },
215
219
  // A copy-paste command's short code, redeemed by the install script it was handed to: a device's first contact,
@@ -266,6 +270,8 @@ export const RAW_ROUTES = {
266
270
  "POST /system/runners/git/{repo}/git-receive-pack": { auth: "door", control: "never", lane: "bulk" },
267
271
  "POST /system/runners/credentials": { auth: "door", control: "never" },
268
272
  "POST /system/runners/credentials/refresh": { auth: "door", control: "never" },
273
+ // A runner's wake for a conversation dispatched there (runner-wake.ts): said here, so its turn is the parent's.
274
+ "POST /system/runners/wake": { auth: "door", control: "never" },
269
275
  [`ALL ${runnerTranslatorPath}/*` as const]: { auth: "door", control: "never" },
270
276
  // The privacy shield's gateway: every shielded runtime's model requests, on the signed session its base URL carries
271
277
  // (privacy/gateway/session-token.ts), which names the provider and the only upstream it may forward to. Held open
@@ -301,13 +307,15 @@ export const RAW_ROUTES = {
301
307
  "GET /link/records/fleet/{handle}": { auth: "door", control: "never" },
302
308
  "GET /link/records/fleet/{handle}/bundle": { auth: "door", control: "never" },
303
309
  "POST /link/records/diagnostics": { auth: "door", control: "never" },
304
- // An accounts link's doors (schemas/providers/account-sharing.ts): the accounts its terms name, a static key's copy,
305
- // and a lent sign-in's access token per turn, re-minted mid-turn. The refresh token never leaves; each door checks the
306
- // link token itself and answers only for what the terms name.
307
- "GET /link/accounts": { auth: "door", control: "never" },
308
- "POST /link/accounts/copy": { auth: "door", control: "never" },
309
- "POST /link/credentials": { auth: "door", control: "never" },
310
- "POST /link/credentials/refresh": { auth: "door", control: "never" },
310
+ // A link's operating doors (schemas/links.ts `operate`): the asking sandbox running commands and reading and writing
311
+ // files here as this sandbox's owner does in their own terminal. Each checks the link token itself and answers only
312
+ // while the link's terms allow operating; a command is followed by reading it again, and only the link that started
313
+ // it reads or stops it.
314
+ "POST /link/operate/exec": { auth: "door", control: "never" },
315
+ "GET /link/operate/exec/{id}": { auth: "door", control: "never" },
316
+ "POST /link/operate/exec/{id}/stop": { auth: "door", control: "never" },
317
+ "POST /link/operate/read": { auth: "door", control: "never" },
318
+ "POST /link/operate/write": { auth: "door", control: "never" },
311
319
  "POST /system/control/tokens": { control: "never" },
312
320
  "GET /system/control/tokens": { floor: "maintainer", control: "never" },
313
321
  "DELETE /system/control/tokens/{id}": { control: "never" },
@@ -2,6 +2,7 @@
2
2
  // them, and what the Capabilities page reads (status, probe, connect/rename/sign-in inputs).
3
3
  import { z } from "zod";
4
4
  import { ExitConfigSchema } from "./exit.js";
5
+ import { ExtensionConfigSchema, PluginConfigSchema } from "./git-installs.js";
5
6
  import { entryId } from "./internal.js";
6
7
  import { NetdiskConfigSchema } from "./netdisk.js";
7
8
  import { VpnConfigSchema } from "./vpn.js";
@@ -41,7 +42,8 @@ export type CapabilityState = z.infer<typeof CapabilityStateSchema>;
41
42
  // Per-kind config. Secrets (an mcp token) live here and are denylisted like tools.json.
42
43
  export const McpConfigSchema = z.object({
43
44
  url: z.url().describe("Where the tool server answers."),
44
- token: z.string().optional().describe("The credential it needs, if any. Stored, never echoed back."),
45
+ // A sign-in's session (schemas/mcp-sign-in.ts) is one JSON value holding both tokens, which the sandbox renews.
46
+ token: z.string().optional().describe("The credential it needs, if any: a pasted token, or a sign-in's session. Stored, never echoed back."),
45
47
  });
46
48
  // Gives the agent an authenticated CLI tool: credential plus any non-secret URL, injected into the agent's env each
47
49
  // turn, taught via an .agents/skills/<id> cheatsheet. Provider fields are data in an extension's
@@ -56,61 +58,6 @@ export const CliConfigSchema = z
56
58
  ),
57
59
  })
58
60
  .catchall(z.string());
59
- // A Claude Code plugin from a git repo; the daemon only owns the checkout, the Agent SDK's plugin loader reads its
60
- // internals. `path` is a subdirectory for a plugin inside a larger checkout; `token` is https auth for a private repo.
61
- export const PluginConfigSchema = z.object({
62
- url: z.url().describe("The repository to take the plugin from."),
63
- // Branch / tag / commit sha to install from; absent = the default branch's HEAD. Either way `commit` pins it.
64
- ref: z
65
- .string()
66
- .min(1)
67
- .optional()
68
- .describe(
69
- "A branch, tag or commit to install from. Leave it out for the default branch. The install pins the commit it names at that moment.",
70
- ),
71
- path: z
72
- .string()
73
- .min(1)
74
- .refine((value) => !value.split("/").includes(".."), { message: "path must stay inside the checkout" })
75
- .optional()
76
- .describe("Where inside the repository the plugin lives, for one that sits in a larger checkout."),
77
- token: z.string().min(1).optional().describe("A credential for a private repository. Stored, never echoed back."),
78
- // Set by the sandbox at install, never by the form: re-applying a stored entry (a rotated token, a migration)
79
- // checks this out again, and only adding the plugin anew moves it.
80
- commit: z
81
- .string()
82
- .regex(/^[0-9a-f]{40}$/, "commit must be a full 40-character commit sha")
83
- .optional()
84
- .describe(
85
- "The exact commit installed, in full, resolved from the branch, tag or commit when the plugin was added. Its hooks run inside the agent's session, so it stays at this commit until it is added again.",
86
- ),
87
- });
88
- // An intentic extension from a git repo (UI bundle + agent contributions + processes). Unlike `plugin`, `ref` must be a
89
- // full commit sha, since extension code runs trusted in the owner's browser and every update is a deliberate re-add at
90
- // a new sha.
91
- export const ExtensionConfigSchema = z.object({
92
- url: z.url().describe("The repository to take the extension from."),
93
- ref: z
94
- .string()
95
- .regex(/^[0-9a-f]{40}$/, "ref must be a full 40-character commit sha")
96
- .describe(
97
- "The exact commit to install, in full. Required rather than optional because extension code runs with your browser's trust: the owner approves precisely the code that runs, and an update is a deliberate re-install at a new commit.",
98
- ),
99
- path: z
100
- .string()
101
- .min(1)
102
- .refine((value) => !value.split("/").includes(".."), { message: "path must stay inside the checkout" })
103
- .optional()
104
- .describe("Where inside the repository the extension lives, for one that sits in a larger checkout."),
105
- token: z.string().min(1).optional().describe("A credential for a private repository. Stored, never echoed back."),
106
- // What update checks and advisories are read against; absent falls back to the official registry.
107
- registry: z
108
- .url()
109
- .optional()
110
- .describe(
111
- "Which registry this install came from, which is what update checks and security advisories are read against. Absent falls back to the official one.",
112
- ),
113
- });
114
61
  // What lets the agent act as an administrator on the machine, the same for every way of signing in. Optional: most
115
62
  // machines are reached as a user who needs no more. The password is vaulted like the login one (it is not echoed), so
116
63
  // the agent spends it as `{{secret:<alias>/adminPassword}}` and never reads it; `adminPasswordOf` says whose it is,
@@ -389,6 +336,14 @@ export type WalletConfig = z.infer<typeof WalletConfigSchema>;
389
336
  // create is only an approval while the agent cannot mint a claim behind it.
390
337
  export const FleetConfigSchema = z.object({
391
338
  token: z.string().min(1).describe("A provisioning token from Settings ▸ Tokens. Stored, never echoed back."),
339
+ // (2026-11-11) The platform's id for a token the editor minted for this card (its Allow), which tells it from one
340
+ // pasted in, perhaps shared with another sandbox: only a minted one is revoked when the card goes or its token is replaced.
341
+ tokenId: z
342
+ .string()
343
+ .min(1)
344
+ .max(100)
345
+ .optional()
346
+ .describe("The platform's id for a token minted for this card, revoked when the card is removed or its token replaced."),
392
347
  });
393
348
  export type FleetConfig = z.infer<typeof FleetConfigSchema>;
394
349
  // Another of the owner's sandboxes this one may hand tasks to (schemas/links.ts). The token is an inbound link that
@@ -399,18 +354,10 @@ export const LinkConfigSchema = z.object({
399
354
  token: z.string().min(1).describe("The link token that sandbox minted for this one. Stored, never echoed back."),
400
355
  name: z.string().max(100).optional().describe("What the other sandbox is called, as its owner named it."),
401
356
  sandboxId: z.string().max(100).optional().describe("The other sandbox's id on the owner's account."),
402
- purpose: z
403
- .enum(["tasks", "accounts"])
404
- .optional()
405
- .describe(
406
- "What the link is for: tasks to hand over (absent), or model accounts this sandbox borrows from that one (schemas/providers/account-sharing.ts), which mounts no delegate tool.",
407
- ),
408
357
  });
409
358
  export type LinkConfig = z.infer<typeof LinkConfigSchema>;
410
359
  export type McpConfig = z.infer<typeof McpConfigSchema>;
411
360
  export type CliConfig = z.infer<typeof CliConfigSchema>;
412
- export type PluginConfig = z.infer<typeof PluginConfigSchema>;
413
- export type ExtensionConfig = z.infer<typeof ExtensionConfigSchema>;
414
361
  export type SshConfig = z.infer<typeof SshConfigSchema>;
415
362
  export type DockerConfig = z.infer<typeof DockerConfigSchema>;
416
363
  export type BrowserConfig = z.infer<typeof BrowserConfigSchema>;
@@ -554,6 +501,11 @@ export const CapabilityRefreshTokenInputSchema = z.object({
554
501
  refreshToken: z.string().min(1).max(32768).describe("The new refresh token. Never echoed back."),
555
502
  login: z.boolean().optional().describe("A fresh interactive sign-in rather than a rotation: restarts the card's listener."),
556
503
  });
504
+ // POST /capabilities/{id}/oauth-access: an hour of access for a card signed in through the platform's own OAuth client.
505
+ export const CapabilityAccessTokenSchema = z.object({
506
+ accessToken: z.string().describe("Bearer for the provider's APIs, good for about an hour. Cache it; never store it on the card."),
507
+ expiresIn: z.number().describe("Seconds until it expires."),
508
+ });
557
509
  // POST /capabilities/{id}/rename: a capability's id is the agent's handle for it (skill file, tool prefix, env suffix,
558
510
  // ssh alias), so renaming is a migration, not a label edit. Which kinds may be renamed is the handler's own answer, not
559
511
  // this schema's.
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import { CapabilityKindSchema } from "./capabilities.js";
3
+
4
+ // A key the sandbox makes for a card whose service issues a certificate from a request (a field declaring `keyRequest`
5
+ // in its manifest): the form gets the request to send the issuer, and a stash marker (`stashedMarker`) for the field the
6
+ // private key goes in, the way a generated SSH key arrives. The key never reaches the browser.
7
+
8
+ // POST /capabilities/certificate-request.
9
+ export const CertificateRequestInputSchema = z.object({
10
+ kind: CapabilityKindSchema.describe("The kind of card the key is for."),
11
+ provider: z.string().min(1).optional().describe("For a kind several cards share, the card: a cli card's provider (`e-doreczenia`)."),
12
+ field: z.string().min(1).describe("The field declaring `keyRequest`, which the private key goes in."),
13
+ values: z
14
+ .record(z.string(), z.string())
15
+ .describe("The form's answers the request's subject is filled from (`keyRequest.subject`). Never a credential: only the fields the subject names are read."),
16
+ });
17
+ export type CertificateRequestInput = z.infer<typeof CertificateRequestInputSchema>;
18
+
19
+ export const CertificateRequestSchema = z.object({
20
+ request: z.string().describe("The PKCS#10 certificate signing request, armored (`-----BEGIN CERTIFICATE REQUEST-----`), to send the issuer."),
21
+ subject: z.string().describe("Its subject as the issuer reads it: `C=PL, O=…, CN=…`."),
22
+ token: z
23
+ .string()
24
+ .describe(
25
+ "Stands for the private key, which never leaves the sandbox. Sent wrapped as a marker in that field, it installs the key once, on the card it was made for; it lapses after thirty minutes.",
26
+ ),
27
+ });
28
+ export type CertificateRequest = z.infer<typeof CertificateRequestSchema>;
@@ -0,0 +1,28 @@
1
+ import { KEYRING_NAME_RE } from "./keyring.js";
2
+ import { ConnectionEnvelopeSchema, hubEntryName, hubHostOf, isHubEntryName, wantOfItem, withoutHubEntries } from "./connection-hub.js";
3
+
4
+ // A hub entry is found by its host and kept apart from the copies an agent spends, so these rules are what makes a saved
5
+ // connection reachable from another sandbox and unreachable as a raw value.
6
+
7
+ test("a connector's card is asked for by its connector alone; a tool server or endpoint by its kind", () => {
8
+ const github = { type: "card", id: "github", kind: "cli", connector: "github", config: { provider: "github", token: "t" } } as const;
9
+ expect(hubHostOf(wantOfItem(github))).toBe("github.cli.connections.invalid");
10
+ expect(hubHostOf({ type: "card", kind: "cli", connector: "cloudflare" })).not.toBe(hubHostOf(wantOfItem(github)));
11
+ expect(hubHostOf(wantOfItem({ type: "card", id: "notion", kind: "mcp", config: { url: "https://mcp.notion.com" } }))).toBe("mcp.connections.invalid");
12
+ expect(hubHostOf({ type: "account", provider: "cursor" })).toBe("cursor.account.connections.invalid");
13
+ });
14
+
15
+ test("an entry name is a keyring name that says what it holds, and only those are the hub's", () => {
16
+ const name = hubEntryName({ type: "card", id: "gh", kind: "cli", connector: "git-hub", config: {} }, "a1f3");
17
+ expect(name).toBe("CONNECTION_GIT_HUB_A1F3");
18
+ expect(KEYRING_NAME_RE.test(name)).toBe(true);
19
+ expect(isHubEntryName(name)).toBe(true);
20
+ expect(withoutHubEntries({ [name]: "{}", VPN_PASSWORD: "x" })).toEqual({ VPN_PASSWORD: "x" });
21
+ });
22
+
23
+ test("an envelope with a field this build does not know is refused rather than half read", () => {
24
+ const envelope = { intentic: "connection", v: 1, label: "Cursor", from: { sandbox: "dev", at: 1 }, item: { type: "account", provider: "cursor", account: { apiKey: "k" } } };
25
+ expect(ConnectionEnvelopeSchema.safeParse(envelope).success).toBe(true);
26
+ expect(ConnectionEnvelopeSchema.safeParse({ ...envelope, extra: true }).success).toBe(false);
27
+ expect(ConnectionEnvelopeSchema.safeParse({ ...envelope, item: { ...envelope.item, provider: "claude" } }).success).toBe(false);
28
+ });
@@ -0,0 +1,191 @@
1
+ import { z } from "zod";
2
+ import { KEYRING_NAME_RE } from "./keyring.js";
3
+
4
+ // THE CONNECTIONS HUB: the keyring on one of the owner's computers as the place their connections live, so a sandbox can
5
+ // put one there and any other of their sandboxes can take it. Nothing new runs on the computer: a hub item is an
6
+ // ordinary keyring `text` entry whose value is the envelope below, put there through the keyring's inbox (a person's
7
+ // yes at the computer) and shared back in `copy` mode, so a sandbox holds a sealed copy that works with the computer off
8
+ // and changes when the entry does. The sandbox turns each copy it holds into the card or account the envelope describes,
9
+ // and takes it away again when the computer stops sharing it.
10
+ //
11
+ // Only credentials that do not rotate travel. A sign-in whose refresh token is renewed (a Claude or Codex subscription,
12
+ // an OAuth card) would sign the other copies out at its first renewal, so each sandbox signs in to those itself.
13
+
14
+ // Every hub entry's name starts so; the rest is a readable slug and a random tail, since a sandbox cannot see the entries
15
+ // another put there and an inbox item under a name already taken replaces that entry.
16
+ export const HUB_ENTRY_PREFIX = "CONNECTION_";
17
+ export const isHubEntryName = (name: string): boolean => name.startsWith(HUB_ENTRY_PREFIX) && KEYRING_NAME_RE.test(name);
18
+
19
+ /** The keyring copies an agent may spend by name: every one but the hub's own, which only the daemon reads. */
20
+ export const withoutHubEntries = (copies: Readonly<Record<string, string>>): Readonly<Record<string, string>> =>
21
+ Object.fromEntries(Object.entries(copies).filter(([name]) => !isHubEntryName(name)));
22
+
23
+ // The guard a hub entry carries as its only host. `.invalid` never resolves (RFC 2606), so the copy, which the sandbox
24
+ // keeps like any secret, can never be sent anywhere by a `{{secret:…}}` reference; and a sandbox asking for one finds it
25
+ // by this host through the keyring's ordinary need, which matches entries by host.
26
+ export const HUB_HOST_SUFFIX = "connections.invalid";
27
+
28
+ // The card kinds that travel: a CLI connector (its provider's own card), a remote tool server, a model endpoint. Every
29
+ // other kind is tied to where it was made (a computer, a disk, a link) or runs something of its own.
30
+ export const HubCardKindSchema = z.enum(["cli", "mcp", "endpoint"]);
31
+ export type HubCardKind = z.infer<typeof HubCardKindSchema>;
32
+
33
+ // The model providers whose account is a key that does not rotate: what a sign-in there would write is the whole
34
+ // account: Cursor and Devin keys, and the minted Z.ai and Meta keys. (Endpoints are cards, above.)
35
+ export const HUB_ACCOUNT_PROVIDERS = ["cursor", "devin", "zai", "meta"] as const;
36
+ export const HubAccountProviderSchema = z.enum(HUB_ACCOUNT_PROVIDERS);
37
+ export type HubAccountProvider = z.infer<typeof HubAccountProviderSchema>;
38
+
39
+ // One static account, the fields every static store keeps. Only a sandbox's daemon ever reads one.
40
+ export const StaticAccountCopySchema = z.object({
41
+ label: z.string().max(200).optional(),
42
+ email: z.string().max(320).optional(),
43
+ variant: z.string().max(100).optional().describe("Which sign-in estate a minted key belongs to (Z.ai's international or mainland plan)."),
44
+ plan: z.string().max(100).optional(),
45
+ apiKey: z.string().min(1).max(8192),
46
+ apiKeyExpiresAtMs: z.number().optional(),
47
+ backendUrl: z.string().max(500).optional(),
48
+ });
49
+ export type StaticAccountCopy = z.infer<typeof StaticAccountCopySchema>;
50
+
51
+ const SLUG_RE = /^[a-z0-9][a-z0-9-]{0,40}$/u;
52
+
53
+ // What one hub entry holds. `card.config` carries the card's credential fields beside its settings, which the receiving
54
+ // sandbox vaults exactly as a card added there would be; it is checked against that sandbox's own card schema there.
55
+ export const HubCardItemSchema = z
56
+ .object({
57
+ type: z.literal("card"),
58
+ id: z.string().min(1).max(60).describe("The card's id where it was saved, kept where it is free."),
59
+ kind: HubCardKindSchema,
60
+ connector: z.string().regex(SLUG_RE).optional().describe("A CLI card's connector (its `provider`), which another sandbox asks for it by."),
61
+ config: z.record(z.string(), z.unknown()),
62
+ })
63
+ .strict();
64
+ export const HubAccountItemSchema = z.object({ type: z.literal("account"), provider: HubAccountProviderSchema, account: StaticAccountCopySchema }).strict();
65
+ export const HubItemSchema = z.discriminatedUnion("type", [HubCardItemSchema, HubAccountItemSchema]);
66
+ export type HubItem = z.infer<typeof HubItemSchema>;
67
+
68
+ export const ConnectionEnvelopeSchema = z
69
+ .object({
70
+ intentic: z.literal("connection"),
71
+ v: z.literal(1),
72
+ label: z.string().min(1).max(200).describe("What the connection is called, for the rows that list it."),
73
+ from: z.object({ sandbox: z.string().max(200), at: z.number() }).strict().describe("Where and when it was saved."),
74
+ item: HubItemSchema,
75
+ })
76
+ .strict();
77
+ export type ConnectionEnvelope = z.infer<typeof ConnectionEnvelopeSchema>;
78
+
79
+ // What a sandbox asks the computer for: one connector's card, any card of a kind that has no connector (a tool server,
80
+ // a model endpoint), or one provider's static account.
81
+ export const HubWantSchema = z.discriminatedUnion("type", [
82
+ z.object({ type: z.literal("card"), kind: HubCardKindSchema, connector: z.string().regex(SLUG_RE).optional() }).strict(),
83
+ z.object({ type: z.literal("account"), provider: HubAccountProviderSchema }).strict(),
84
+ ]);
85
+ export type HubWant = z.infer<typeof HubWantSchema>;
86
+
87
+ /** The host a hub entry for `want` carries, and a need for it asks by. A connector's card is found by its connector alone. */
88
+ export const hubHostOf = (want: HubWant): string => {
89
+ if (want.type === "account") {
90
+ return `${want.provider}.account.${HUB_HOST_SUFFIX}`;
91
+ }
92
+ return want.kind === "cli" && want.connector !== undefined ? `${hubSlug(want.connector)}.cli.${HUB_HOST_SUFFIX}` : `${want.kind}.${HUB_HOST_SUFFIX}`;
93
+ };
94
+
95
+ /** What a hub item answers to: the want a sandbox would ask with to be offered it. */
96
+ export const wantOfItem = (item: HubItem): HubWant => {
97
+ if (item.type === "account") {
98
+ return { type: "account", provider: item.provider };
99
+ }
100
+ return item.kind === "cli" && item.connector !== undefined ? { type: "card", kind: item.kind, connector: item.connector } : { type: "card", kind: item.kind };
101
+ };
102
+
103
+ /** A fresh entry name for an item: readable in the Passwords app, and unlikely to meet another sandbox's. */
104
+ export const hubEntryName = (item: HubItem, tail: string): string => {
105
+ const what = item.type === "account" ? item.provider : (item.connector ?? item.kind);
106
+ const readable = what
107
+ .toUpperCase()
108
+ .replace(/[^A-Z0-9]+/gu, "_")
109
+ .replace(/^_+|_+$/gu, "")
110
+ .slice(0, 40);
111
+ return `${HUB_ENTRY_PREFIX}${readable === "" ? "ITEM" : readable}_${tail.toUpperCase().replace(/[^A-Z0-9]/gu, "")}`;
112
+ };
113
+
114
+ /** A connector id as a hub slug: lower case, letters, digits and dashes. */
115
+ export const hubSlug = (value: string): string =>
116
+ value
117
+ .toLowerCase()
118
+ .replace(/[^a-z0-9-]+/gu, "-")
119
+ .replace(/^-+|-+$/gu, "")
120
+ .slice(0, 40) || "x";
121
+
122
+ /* THE ROUTES, called by the owner's editor. */
123
+
124
+ // What a saved or taken connection is here: a card by its id, or a provider's account by its id there.
125
+ export const HubTargetSchema = z.discriminatedUnion("type", [
126
+ z.object({ type: z.literal("card"), id: z.string().min(1).max(60) }).strict(),
127
+ z.object({ type: z.literal("account"), provider: HubAccountProviderSchema, id: z.string().min(1).max(200) }).strict(),
128
+ ]);
129
+ export type HubTarget = z.infer<typeof HubTargetSchema>;
130
+ export const sameHubTarget = (a: HubTarget, b: HubTarget): boolean =>
131
+ a.type === "card" ? b.type === "card" && a.id === b.id : b.type === "account" && a.provider === b.provider && a.id === b.id;
132
+
133
+ // A computer whose keyring could hold the hub.
134
+ export const HubComputerSchema = z.object({
135
+ machine: z.string(),
136
+ online: z.boolean(),
137
+ setUp: z.boolean().describe("Its keyring is installed and set up, so it can take a connection in."),
138
+ locked: z.boolean().optional(),
139
+ });
140
+ export type HubComputer = z.infer<typeof HubComputerSchema>;
141
+
142
+ // One card or account held here, and whether it can go to the hub.
143
+ export const HubHoldingSchema = z.object({
144
+ target: HubTargetSchema,
145
+ label: z.string(),
146
+ want: HubWantSchema.optional().describe("What another sandbox asks with to be offered it. Absent when it cannot go."),
147
+ reason: z.string().optional().describe("Why it cannot go to the hub, in words a person can act on. Absent when it can."),
148
+ saved: z
149
+ .object({
150
+ entry: z.string().regex(KEYRING_NAME_RE),
151
+ machine: z.string(),
152
+ at: z.number(),
153
+ pending: z.boolean().describe("It waits for a yes at the computer (the keyring was locked when it was sent)."),
154
+ })
155
+ .optional()
156
+ .describe("It was saved to the hub from here: which entry, on which computer."),
157
+ from: z
158
+ .object({ entry: z.string(), machine: z.string().optional() })
159
+ .optional()
160
+ .describe("It was made here from a hub entry: which, and the computer that shares it. It goes when that computer stops sharing it."),
161
+ });
162
+ export type HubHolding = z.infer<typeof HubHoldingSchema>;
163
+
164
+ // A hub entry shared here that could not be turned into a connection, with why.
165
+ export const HubFailureSchema = z.object({ entry: z.string(), machine: z.string().optional(), message: z.string(), at: z.number() });
166
+ export type HubFailure = z.infer<typeof HubFailureSchema>;
167
+
168
+ export const HubStateSchema = z.object({
169
+ computers: z.array(HubComputerSchema),
170
+ holdings: z.array(HubHoldingSchema),
171
+ failures: z.array(HubFailureSchema),
172
+ });
173
+ export type HubState = z.infer<typeof HubStateSchema>;
174
+
175
+ export const HubSaveSchema = z.object({ target: HubTargetSchema, machine: z.string().min(1).max(128) }).strict();
176
+ export type HubSave = z.infer<typeof HubSaveSchema>;
177
+ export const HubSavedSchema = z.object({
178
+ entry: z.string(),
179
+ machine: z.string(),
180
+ pending: z.boolean().describe("It waits for the next unlock at that computer, where the person says yes."),
181
+ });
182
+ export type HubSaved = z.infer<typeof HubSavedSchema>;
183
+
184
+ export const HubTakeSchema = z.object({ want: HubWantSchema, why: z.string().min(1).max(300).optional() }).strict();
185
+ export type HubTake = z.infer<typeof HubTakeSchema>;
186
+ export const HubTakenSchema = z.object({
187
+ outcome: z.enum(["taken", "waiting", "none"]).describe("Shared and made here; waiting for a yes at the computer; nothing saved there answers it."),
188
+ message: z.string(),
189
+ target: HubTargetSchema.optional().describe("What it was made into here, once taken."),
190
+ });
191
+ export type HubTaken = z.infer<typeof HubTakenSchema>;
@@ -0,0 +1,54 @@
1
+ import { parseJsonWith } from "@intentic/base/json";
2
+ import { z } from "zod";
3
+
4
+ /* THE STEPS OF A MOVE BETWEEN COMPUTERS (2026-11-11, the `move-prepare`/`move-out`/`move-in` ops): the flow field the daemon
5
+ fills, and the lines both ics print, read by the daemon's move gate (sandboxes/move-gate.ts). */
6
+
7
+ // The plan is ic's own (`ic sandbox move-out --plan-only`), read here only for what the owner's card says: loose, so
8
+ // everything ic put in it reaches the target's ic unchanged, and the target's ic checks it whole.
9
+ export const DeviceMovePlanSchema = z.looseObject({
10
+ v: z.number().int(),
11
+ slug: z.string().min(1),
12
+ // Every byte the copy carries: the volumes, and an image the target cannot pull or build.
13
+ bytes: z.number().nonnegative(),
14
+ running: z.boolean().optional(),
15
+ });
16
+ export type DeviceMovePlan = z.infer<typeof DeviceMovePlanSchema>;
17
+ // One `intentic-move: {json}` line either ic prints during a move: its step, and the fields the daemon reads. Loose,
18
+ // since each step carries fields of its own (a volume's `done`/`total`) that are only relayed.
19
+ export const DeviceMoveStepSchema = z.looseObject({
20
+ step: z.string().min(1),
21
+ plan: DeviceMovePlanSchema.optional(),
22
+ publicKey: z.string().optional(),
23
+ listen: z.array(z.string()).optional(),
24
+ port: z.number().int().positive().optional(),
25
+ reason: z.string().optional(),
26
+ // On the source's `failed`: everything was sent and the connection broke before the target's verdict, so the source
27
+ // stays stopped rather than risk two copies running; the daemon starts it again only if the target failed.
28
+ ambiguous: z.boolean().optional(),
29
+ });
30
+ export type DeviceMoveStep = z.infer<typeof DeviceMoveStepSchema>;
31
+ const DEVICE_MOVE_LINE_PREFIX = "intentic-move: ";
32
+ // The step a printed line carries, or undefined for narration (and for a marker that is not one, printed as it came).
33
+ export const deviceMoveStepOf = (text: string): DeviceMoveStep | undefined => {
34
+ if (!text.startsWith(DEVICE_MOVE_LINE_PREFIX)) {
35
+ return undefined;
36
+ }
37
+ return parseJsonWith(text.slice(DEVICE_MOVE_LINE_PREFIX.length), DeviceMoveStepSchema);
38
+ };
39
+ // The move ops' own fields, daemon-filled and never the caller's. `id` names the move on both computers (ic's journal
40
+ // and the file `move-in` hands the key through). `stage` says which half of `move-out` runs: the read-only `plan`
41
+ // before the owner's card, or the `send`. `plan` is the source ic's own answer, carried verbatim to the target, which
42
+ // checks it again. `peer` is the other side's ephemeral public key, which only the daemon carries between the flows;
43
+ // marked secret so no log or view prints it, though it is no secret (the move's keys never leave either process).
44
+ // `connect` is where the target listens, `listen` lets the source fall back to a loopback port the daemon relays.
45
+ export const DeviceSandboxMoveSchema = z.strictObject({
46
+ id: z.string().regex(/^[0-9a-f]{8,64}$/),
47
+ stage: z.enum(["plan", "send"]).optional(),
48
+ plan: DeviceMovePlanSchema.optional(),
49
+ peer: z.string().min(1).optional().meta({ secret: true }),
50
+ connect: z.array(z.string().min(1)).optional(),
51
+ listen: z.boolean().optional(),
52
+ manager: z.enum(["ic", "compose"]).optional(),
53
+ });
54
+ export type DeviceSandboxMove = z.infer<typeof DeviceSandboxMoveSchema>;
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+
3
+ // A connection's form signing in on its own with a device code (RFC 8628), for a card whose field declares `signIn` and
4
+ // whose manifest says how (`refreshToken.deviceCode`): the provider's endpoints answer no browser, so the sandbox asks
5
+ // for the code, and it is the sandbox that asks the provider, while a wait is open, whether the person has finished on
6
+ // its page. The token never reaches the browser: the form gets a stash marker (`stashedMarker`, schemas/capabilities.ts)
7
+ // for the field, the same way a generated SSH key arrives, and the add that saves the form installs it.
8
+
9
+ // POST /capabilities/device-sign-in: starts one; the form shows the code with the page and waits on `flow`.
10
+ export const DeviceSignInStartSchema = z.object({
11
+ flow: z.string().describe("Stands for this sign-in, to wait on. Lapses with the code."),
12
+ userCode: z.string().describe("What the person types on the provider's page."),
13
+ verificationUri: z.string().describe("The provider's own page for it, to open in a new tab."),
14
+ expiresIn: z.number().describe("Seconds until the code lapses."),
15
+ });
16
+ export type DeviceSignInStart = z.infer<typeof DeviceSignInStartSchema>;
17
+
18
+ // POST /capabilities/device-sign-in/wait: answers as soon as the sign-in ends, or `waiting` after a while.
19
+ export const DeviceSignInWaitInputSchema = z.object({ flow: z.string().min(1).describe("The sign-in, as its start answered.") });
20
+ export const DeviceSignInWaitSchema = z.discriminatedUnion("state", [
21
+ z.object({ state: z.literal("waiting").describe("Nobody has finished on the provider's page yet. Ask again.") }),
22
+ z.object({
23
+ state: z.literal("done"),
24
+ token: z
25
+ .string()
26
+ .describe(
27
+ "Stands for the refresh token, which never leaves the sandbox. Sent wrapped as a stash marker in the field that declares `signIn`, it installs that token once, while the fields the sign-in is bound to still hold what they held; it lapses after thirty minutes.",
28
+ ),
29
+ who: z.string().optional().describe("Who signed in, as the card's own test or the sign-in itself names them."),
30
+ granted: z.array(z.string()).describe("What the provider granted, each permission by its short name (`Mail.Read`)."),
31
+ bound: z
32
+ .array(z.string())
33
+ .describe("The fields the sign-in is only good for as they are now (`refreshToken.boundTo`): changing one before Save needs a new sign-in."),
34
+ }),
35
+ z.object({ state: z.literal("failed"), message: z.string().describe("Why it did not finish, in words a person can act on.") }),
36
+ ]);
37
+ export type DeviceSignInWait = z.infer<typeof DeviceSignInWaitSchema>;
@@ -9,6 +9,7 @@ import {
9
9
  type SandboxShapeWhen,
10
10
  } from "./device-resources.js";
11
11
  import { PortNumberSchema } from "./device-commands.js";
12
+ import { DeviceSandboxMoveSchema } from "./device-move.js";
12
13
  import { DeviceBridgeHoldSchema, DeviceConflictSchema, DeviceCopySchema, DeviceLowDiskSchema } from "./device-folder.js";
13
14
  import { parseHostConnection, type DeviceFacts, DeviceFactsSchema, MachineIdentitySchema, MachineIdSchema, userDistrosOf, WslEnvironmentSchema } from "./hosts.js";
14
15
  import { EgressOwnerKeysSchema, EgressPolicySchema, EgressProofSchema, EgressStatusSchema } from "./egress.js";
@@ -117,6 +118,13 @@ export const DeviceSandboxOpSchema = z.enum([
117
118
  "create",
118
119
  "runner-up",
119
120
  "runner-remove",
121
+ // (2026-11-11) A sandbox carried to another of the owner's computers (`sandboxes move`, the daemon's move-gate.ts),
122
+ // each through `ic` with the flow's `move` object: `move-out` on the computer that runs it (its plan, then the send),
123
+ // `move-prepare` on the one it goes to (checks, image, then the receive, one long run), and `move-in` there to hand
124
+ // the waiting receive the sender's public key. Sent only to an agent advertising `sandbox-move`.
125
+ "move-prepare",
126
+ "move-out",
127
+ "move-in",
120
128
  ]);
121
129
  export type DeviceSandboxOp = z.infer<typeof DeviceSandboxOpSchema>;
122
130
  // STRICT, like every input a device is sent: an agent rejects a field it does not know instead of dropping it and doing
@@ -162,6 +170,8 @@ export const DeviceSandboxFlowSchema = z.strictObject({
162
170
  definition: z.string().optional(),
163
171
  overlay: z.string().optional(),
164
172
  overlayHash: z.string().optional(),
173
+ // The three move ops only, daemon-filled (DeviceSandboxMoveSchema).
174
+ move: DeviceSandboxMoveSchema.optional(),
165
175
  });
166
176
  export type DeviceSandboxFlow = z.infer<typeof DeviceSandboxFlowSchema>;
167
177
  // The `ic` argv for the shape and power ops, the one place any caller spells them: the machine agent runs it and the
@@ -211,6 +221,7 @@ export type DeviceAgentFlow = z.infer<typeof DeviceAgentFlowSchema>;
211
221
  export const DeviceAgentFlowInputSchema = DeviceAgentFlowSchema.extend({ id: z.string().min(1) });
212
222
  export type DeviceAgentFlowInput = z.infer<typeof DeviceAgentFlowInputSchema>;
213
223
  export * from "./device-commands.js";
224
+ export * from "./device-move.js";
214
225
 
215
226
  // What a synced folder reports beyond Mutagen's word, its conflicts and what the device holds back (device-folder.ts).
216
227
  export * from "./device-folder.js";
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
2
 
3
3
  // THE DIAGNOSTICS QUERIES: read-only questions over what a sandbox's daemon already recorded (its log, the editor's
4
- // reports, slow spans and rollups, the turn ledger, the resource series, its boots, one conversation's timeline). One
4
+ // reports, slow spans and rollups, the turn ledger, the resource series, its boots, one conversation's timeline, the
5
+ // commands agents ran that failed). One
5
6
  // set of arguments serves every door that asks them: the `diagnostics` tools a turn mounts, the `diagnostics` command on
6
7
  // the agent's PATH (POST /diagnostics), and a linked sandbox reading this one's records (POST /link/records/diagnostics).
7
8
  // Each answers with text written to be read, never the raw lines, and each takes a window.
@@ -102,6 +103,21 @@ export const DiagnosticsTimelineArgs = {
102
103
  limit: z.number().int().min(1).max(DIAGNOSTICS_MAX_LINES).optional().describe("The newest this many events. Defaults to 100."),
103
104
  };
104
105
 
106
+ /** `failures`: the shell commands agents ran that failed, kept a month, grouped by kind across conversations. */
107
+ export const DiagnosticsFailuresArgs = {
108
+ sinceMinutes: minutes().describe("How far back to look. Leave it out for everything kept (about a month)."),
109
+ conversationId: z.string().max(200).optional().describe("Narrow to one conversation; its failures are then listed one by one."),
110
+ contains: z.string().max(200).optional().describe("Case-insensitive substring of the failure's line: a program, a path, an error."),
111
+ group: z
112
+ .boolean()
113
+ .optional()
114
+ .describe(
115
+ "true: one row per kind of failure (program and error), most widespread first, each marked ongoing, stopped or quiet. " +
116
+ "false: every failure, newest first. Left out, kinds are grouped unless a conversation is named.",
117
+ ),
118
+ limit: limit(),
119
+ };
120
+
105
121
  // One query, named by `query`, with that query's own arguments.
106
122
  export const DiagnosticsQuerySchema = z.discriminatedUnion("query", [
107
123
  z.object({ query: z.literal("errors"), ...DiagnosticsErrorsArgs }),
@@ -110,10 +126,11 @@ export const DiagnosticsQuerySchema = z.discriminatedUnion("query", [
110
126
  z.object({ query: z.literal("resources"), ...DiagnosticsResourcesArgs }),
111
127
  z.object({ query: z.literal("restarts"), ...DiagnosticsRestartsArgs }),
112
128
  z.object({ query: z.literal("timeline"), ...DiagnosticsTimelineArgs }),
129
+ z.object({ query: z.literal("failures"), ...DiagnosticsFailuresArgs }),
113
130
  ]);
114
131
  export type DiagnosticsQuery = z.infer<typeof DiagnosticsQuerySchema>;
115
132
  export type DiagnosticsQueryName = DiagnosticsQuery["query"];
116
- export const DIAGNOSTICS_QUERY_NAMES = ["errors", "slow", "turns", "resources", "restarts", "timeline"] as const satisfies readonly DiagnosticsQueryName[];
133
+ export const DIAGNOSTICS_QUERY_NAMES = ["errors", "slow", "turns", "resources", "restarts", "timeline", "failures"] as const satisfies readonly DiagnosticsQueryName[];
117
134
 
118
135
  // POST /diagnostics: one query of this sandbox's records, or, with `on`, of the linked sandbox that card names, read
119
136
  // through the link (its owner must share records on it).
@@ -17,6 +17,13 @@ export const RemoteRefsRequestSchema = z.object({
17
17
  .min(1)
18
18
  .optional()
19
19
  .describe("Which connection a VAULTED token belongs to. Ignored when a real token is sent."),
20
+ gitConnection: z
21
+ .string()
22
+ .min(1)
23
+ .optional()
24
+ .describe(
25
+ "The GitHub or GitLab connection, by its id, whose token reads a private repository on its host, as the install will. Used when no token is sent; left out, the first such connection by id is used.",
26
+ ),
20
27
  });
21
28
 
22
29
  export const RemoteRefSchema = z.object({