@intentic/sandbox-contract 1.406.0 → 1.408.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 (109) hide show
  1. package/dist/contracts/agent.contract.d.ts +1 -0
  2. package/dist/contracts/agent.contract.d.ts.map +1 -1
  3. package/dist/contracts/capabilities.contract.d.ts +2 -0
  4. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  5. package/dist/contracts/device.contract.d.ts +4 -0
  6. package/dist/contracts/device.contract.d.ts.map +1 -1
  7. package/dist/contracts/netdisk.contract.d.ts +1 -0
  8. package/dist/contracts/netdisk.contract.d.ts.map +1 -1
  9. package/dist/contracts/runner.contract.d.ts +252 -250
  10. package/dist/contracts/runner.contract.d.ts.map +1 -1
  11. package/dist/contracts/settings.contract.d.ts +2 -0
  12. package/dist/contracts/settings.contract.d.ts.map +1 -1
  13. package/dist/contracts/system.contract.d.ts +15 -0
  14. package/dist/contracts/system.contract.d.ts.map +1 -1
  15. package/dist/contracts/system.contract.js +19 -1
  16. package/dist/contracts/system.contract.js.map +1 -1
  17. package/dist/events/agent-events.d.ts +2 -0
  18. package/dist/events/agent-events.d.ts.map +1 -1
  19. package/dist/events/agent-events.js +1 -0
  20. package/dist/events/agent-events.js.map +1 -1
  21. package/dist/events/sandbox-notice.d.ts +5 -0
  22. package/dist/events/sandbox-notice.d.ts.map +1 -1
  23. package/dist/events/sandbox-notice.js +1 -0
  24. package/dist/events/sandbox-notice.js.map +1 -1
  25. package/dist/ids/conversation-ids.d.ts +5 -0
  26. package/dist/ids/conversation-ids.d.ts.map +1 -1
  27. package/dist/ids/conversation-ids.js +20 -109
  28. package/dist/ids/conversation-ids.js.map +1 -1
  29. package/dist/ids/conversation-words.d.ts +2 -0
  30. package/dist/ids/conversation-words.d.ts.map +1 -0
  31. package/dist/ids/conversation-words.js +35 -0
  32. package/dist/ids/conversation-words.js.map +1 -0
  33. package/dist/models/model-roles.d.ts +8 -0
  34. package/dist/models/model-roles.d.ts.map +1 -1
  35. package/dist/models/model-roles.js +8 -0
  36. package/dist/models/model-roles.js.map +1 -1
  37. package/dist/policy/failure-codes.d.ts +5 -0
  38. package/dist/policy/failure-codes.d.ts.map +1 -1
  39. package/dist/policy/failure-codes.js +1 -0
  40. package/dist/policy/failure-codes.js.map +1 -1
  41. package/dist/protocol/doors/runner-protocol.d.ts +17 -0
  42. package/dist/protocol/doors/runner-protocol.d.ts.map +1 -1
  43. package/dist/protocol/doors/runner-protocol.js +22 -0
  44. package/dist/protocol/doors/runner-protocol.js.map +1 -1
  45. package/dist/protocol/peer-dial.d.ts +1 -0
  46. package/dist/protocol/peer-dial.d.ts.map +1 -1
  47. package/dist/protocol/peer-dial.js +1 -1
  48. package/dist/protocol/peer-dial.js.map +1 -1
  49. package/dist/schemas/agent.d.ts +4 -0
  50. package/dist/schemas/agent.d.ts.map +1 -1
  51. package/dist/schemas/capabilities.d.ts +1 -0
  52. package/dist/schemas/capabilities.d.ts.map +1 -1
  53. package/dist/schemas/device-artifacts.d.ts +4 -0
  54. package/dist/schemas/device-artifacts.d.ts.map +1 -1
  55. package/dist/schemas/device-artifacts.js +8 -0
  56. package/dist/schemas/device-artifacts.js.map +1 -1
  57. package/dist/schemas/hosts.d.ts +2 -0
  58. package/dist/schemas/hosts.d.ts.map +1 -1
  59. package/dist/schemas/hosts.js +2 -0
  60. package/dist/schemas/hosts.js.map +1 -1
  61. package/dist/schemas/keyring.d.ts +6 -0
  62. package/dist/schemas/keyring.d.ts.map +1 -1
  63. package/dist/schemas/keyring.js +3 -0
  64. package/dist/schemas/keyring.js.map +1 -1
  65. package/dist/schemas/netdisk.d.ts +4 -0
  66. package/dist/schemas/netdisk.d.ts.map +1 -1
  67. package/dist/schemas/netdisk.js +7 -0
  68. package/dist/schemas/netdisk.js.map +1 -1
  69. package/dist/schemas/offload.d.ts +5 -0
  70. package/dist/schemas/offload.d.ts.map +1 -1
  71. package/dist/schemas/offload.js +2 -0
  72. package/dist/schemas/offload.js.map +1 -1
  73. package/dist/schemas/push.d.ts +6 -0
  74. package/dist/schemas/push.d.ts.map +1 -1
  75. package/dist/schemas/push.js +2 -0
  76. package/dist/schemas/push.js.map +1 -1
  77. package/dist/schemas/settings.d.ts +2 -0
  78. package/dist/schemas/settings.d.ts.map +1 -1
  79. package/dist/schemas/settings.js +1 -1
  80. package/dist/schemas/settings.js.map +1 -1
  81. package/dist/schemas/system.d.ts +23 -0
  82. package/dist/schemas/system.d.ts.map +1 -1
  83. package/dist/schemas/system.js +13 -0
  84. package/dist/schemas/system.js.map +1 -1
  85. package/dist/state/definition.d.ts +6 -4
  86. package/dist/state/definition.d.ts.map +1 -1
  87. package/package.json +5 -5
  88. package/src/contracts/system.contract.ts +33 -1
  89. package/src/events/agent-events.ts +3 -0
  90. package/src/events/sandbox-notice.ts +3 -0
  91. package/src/ids/conversation-ids.test.ts +83 -12
  92. package/src/ids/conversation-ids.ts +39 -117
  93. package/src/ids/conversation-words.ts +40 -0
  94. package/src/models/model-roles.ts +10 -0
  95. package/src/policy/failure-codes.ts +3 -0
  96. package/src/policy/tests/failure-codes.test.ts +4 -1
  97. package/src/protocol/doors/runner-protocol.test.ts +22 -0
  98. package/src/protocol/doors/runner-protocol.ts +44 -0
  99. package/src/protocol/peer-dial.test.ts +30 -1
  100. package/src/protocol/peer-dial.ts +4 -1
  101. package/src/schemas/device-artifacts.ts +19 -3
  102. package/src/schemas/hosts.ts +4 -0
  103. package/src/schemas/keyring.ts +4 -0
  104. package/src/schemas/netdisk.ts +13 -0
  105. package/src/schemas/offload.ts +13 -1
  106. package/src/schemas/push.ts +7 -0
  107. package/src/schemas/settings.ts +3 -2
  108. package/src/schemas/system.ts +25 -0
  109. package/src/schemas/version-seam.test.ts +7 -0
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { NeedsActionSchema } from "../../policy/needs-action.js";
3
+ import type { PeerLink } from "../peer-dial.js";
3
4
 
4
5
  // The runner link's edges: the /system/runners/connect handshake, boot env, and turn placement (procedures live in
5
6
  // contracts/runner.contract.ts). A runner is a sandbox image in runner mode, no browser owner or tunnel, that dials its
@@ -42,6 +43,49 @@ export const RUNNER_HEARTBEAT_MS = 30_000;
42
43
 
43
44
  export const runnerConnectUrl = (parentUrl: string): string => `${parentUrl.replace(/^http/, "ws").replace(/\/$/, "")}/system/runners/connect`;
44
45
 
46
+ /* WHAT A RUNNER SAYS OF ITS OWN LINK, FOR THE MACHINE IT RUNS ON (2026-11-09). A runner can be up, its daemon answering,
47
+ and still be no use to anyone: its socket to the parent is the whole point of it, and only the runner can see it. It
48
+ writes this file inside its container (never on /health, which answers the public address) on every change of the
49
+ link and once a minute, and the machine agent's keeper reads it through `docker exec` to bring back a runner whose
50
+ link stays down while its parent answers that machine (machine: device/sandbox-rounds/runner-keeper.ts). */
51
+ export const RUNNER_LINK_PATH = "/run/intentic/runner-link.json";
52
+
53
+ export const RunnerLinkReadingSchema = z.object({
54
+ // When this was written: a reading that stops moving is a daemon that stopped writing it.
55
+ at: z.number(),
56
+ // The parent's public address, which the keeper asks from the machine itself before it blames the runner.
57
+ parent: z.string(),
58
+ state: z.enum(["open", "connecting", "closed"]),
59
+ // The first failure of the outage the link is in, absent while it is open or before its first attempt has failed.
60
+ since: z.number().optional(),
61
+ failures: z.number().optional(),
62
+ // The parent refused this runner's enrollment (close 1008): its loop has stopped, and only re-pairing brings it back.
63
+ revoked: z.boolean().optional(),
64
+ // Work a restart would cut (bootstrap/working-now.ts, purpose "restart"): a held turn carries on with its parent away.
65
+ working: z.number(),
66
+ });
67
+ export type RunnerLinkReading = z.infer<typeof RunnerLinkReadingSchema>;
68
+
69
+ // The reading the machine's keeper judges the link by (RUNNER_LINK_PATH above). Pure.
70
+ export const runnerLinkReading = (
71
+ link: Pick<PeerLink, "state" | "outage">,
72
+ parent: string,
73
+ revoked: boolean,
74
+ working: number,
75
+ now: number,
76
+ ): RunnerLinkReading => {
77
+ const outage = link.outage();
78
+ const reading: RunnerLinkReading = { at: now, parent, state: link.state(), working };
79
+ if (outage !== undefined) {
80
+ reading.since = outage.since;
81
+ reading.failures = outage.failures;
82
+ }
83
+ if (revoked) {
84
+ reading.revoked = true;
85
+ }
86
+ return reading;
87
+ };
88
+
45
89
  // Where a runner redeems its pairing for a durable token, once, over plain HTTPS.
46
90
  export const runnerEnrollUrl = (parentUrl: string): string => `${parentUrl.replace(/\/$/, "")}/system/runners/enroll`;
47
91
 
@@ -65,7 +65,7 @@ const ladder = (delay = 1_000) => {
65
65
  return rungs;
66
66
  };
67
67
 
68
- const dialling = (delay?: number) => {
68
+ const dialling = (delay?: number, longOutageMs?: number) => {
69
69
  const sockets: FakeSocket[] = [];
70
70
  const attached: FakeSocket[] = [];
71
71
  const said: string[] = [];
@@ -81,6 +81,7 @@ const dialling = (delay?: number) => {
81
81
  attach: (socket) => void attached.push(socket),
82
82
  backoff,
83
83
  silenceMs: SILENCE_MS,
84
+ longOutageMs,
84
85
  log: (message) => void said.push(message),
85
86
  revoked,
86
87
  });
@@ -273,6 +274,34 @@ test.each([
273
274
  // The ladder caps at 30s and would stay there forever. Right for the first minutes, absurd after the first week: a
274
275
  // link to a sandbox that no longer exists spent 2,880 attempts a day saying so. It is never given up — a laptop closed
275
276
  // for a fortnight has to find its sandboxes again — it just stops asking every half minute.
277
+ // A runner exists for its parent alone: the parent coming back (a restart, an update, a wake) is when it is wanted, so
278
+ // its long outage rests a minute between tries rather than a quarter of an hour (runners/runner-link.ts).
279
+ test("a door can rest a long outage for less than the default, and still rests past the ladder", async () => {
280
+ jest.useFakeTimers();
281
+ try {
282
+ const RUNG_MS = 30_000;
283
+ const REST_MS = 60_000;
284
+ const { link, sockets } = dialling(RUNG_MS, REST_MS);
285
+ for (let attempt = 1; attempt <= LONG_OUTAGE_ATTEMPTS; attempt += 1) {
286
+ // one drop per attempt is serial by definition
287
+ await waitFor(() => expect(sockets).toHaveLength(attempt));
288
+ sockets.at(-1)?.drops(1006);
289
+ if (attempt < LONG_OUTAGE_ATTEMPTS) {
290
+ // ditto
291
+ await advanceTimersByTimeAsync(RUNG_MS);
292
+ }
293
+ }
294
+ await advanceTimersByTimeAsync(REST_MS + RUNG_MS - 1);
295
+ expect(sockets).toHaveLength(LONG_OUTAGE_ATTEMPTS);
296
+ await advanceTimersByTimeAsync(1);
297
+ await waitFor(() => expect(sockets).toHaveLength(LONG_OUTAGE_ATTEMPTS + 1));
298
+ link.stop();
299
+ await link.done;
300
+ } finally {
301
+ jest.useRealTimers();
302
+ }
303
+ });
304
+
276
305
  test("a link nobody has answered in a long time rests between tries, and is never given up", async () => {
277
306
  jest.useFakeTimers();
278
307
  try {
@@ -63,6 +63,9 @@ export interface PeerDialSpec<S extends SocketLike> {
63
63
  readonly backoff: { readonly next: (heldMs: number) => number; readonly reset: () => void };
64
64
  /* How long this socket may hear nothing before the link is presumed dead: `peerLinkSilenceMs` of the heartbeat the door's own hub pings on. */
65
65
  readonly silenceMs: number;
66
+ /* The rest a long outage takes between tries (LONG_OUTAGE_MS when absent). A door whose far end is the only reason it
67
+ exists, a runner and its parent, rests far less: the parent coming back is the moment it is wanted. */
68
+ readonly longOutageMs?: number | undefined;
66
69
  readonly log: (message: string) => void;
67
70
  // Sandbox refused the enrollment (1008); the loop has already stopped, this is where the peer says so.
68
71
  readonly revoked: () => void;
@@ -197,7 +200,7 @@ export const dialPeer = <S extends SocketLike>(spec: PeerDialSpec<S>): PeerLink
197
200
  openedAt = undefined;
198
201
  // The rest is added to the ladder's draw rather than replacing it: a flat fifteen minutes would bring back in
199
202
  // lockstep every link that entered the long outage together.
200
- const delay = outage.fail() >= LONG_OUTAGE_ATTEMPTS ? LONG_OUTAGE_MS + rung : rung;
203
+ const delay = outage.fail() >= LONG_OUTAGE_ATTEMPTS ? (spec.longOutageMs ?? LONG_OUTAGE_MS) + rung : rung;
201
204
  outage.complain(said, delay);
202
205
  ladder.wait(delay, open);
203
206
  };
@@ -77,23 +77,39 @@ export const PushedArtifactSchema = z.object({
77
77
  });
78
78
  export type PushedArtifact = z.infer<typeof PushedArtifactSchema>;
79
79
 
80
- // A DEVICE'S LOOPBACK PORT, REACHED FROM THE SANDBOX (`devices reach`, hosts/device-tunnels.ts). The sandbox listens on
81
- // its own 127.0.0.1:<localPort>; each connection asks the device to dial its own 127.0.0.1:<devicePort> and open a
82
- // WebSocket back to /system/hosts/tunnel carrying the ticket below, and the two are pumped together.
80
+ // A PORT THE DEVICE REACHES, REACHED FROM THE SANDBOX (`devices reach`, hosts/device-tunnels.ts). The sandbox listens on
81
+ // its own 127.0.0.1:<localPort>; each connection asks the device to dial <port> and open a WebSocket back to
82
+ // /system/hosts/tunnel carrying the ticket below, and the two are pumped together. Without `host` the device dials its
83
+ // own loopback; with one (2026-11-10) it dials that host as any program on it would, so its LAN, its own VPN client,
84
+ // its resolvers (a VPN's DNS, NetBIOS and mDNS names, its hosts file) all apply: how a sandbox reaches a NAS or a
85
+ // server that only the owner's computer can. Sent only to an agent advertising `reach-network`: an older one's strict
86
+ // schema refuses the field. The procedure keeps its name, which older agents answer for loopback.
87
+ // A hostname, an IPv4 address or a bare IPv6 address: one token, nothing a resolver would read as two.
88
+ export const DialHostSchema = z
89
+ .string()
90
+ .min(1)
91
+ .max(253)
92
+ .regex(/^[A-Za-z0-9._:-]+$/, "a hostname or an address: letters, digits, dots, dashes, underscores and colons");
83
93
  export const DialLoopbackSchema = z
84
94
  .object({
85
95
  ticket: z.string().regex(/^[0-9a-f]{48}$/),
86
96
  port: z.int().min(1).max(65535),
97
+ host: DialHostSchema.optional(),
87
98
  })
88
99
  .strict();
89
100
  export type DialLoopback = z.infer<typeof DialLoopbackSchema>;
90
101
 
91
102
  export const DeviceTunnelSchema = z.object({
92
103
  device: z.string(),
104
+ // The host the device dials, absent for its own loopback.
105
+ host: z.string().optional(),
93
106
  devicePort: z.int().min(1).max(65535),
94
107
  localPort: z.int().min(1).max(65535),
95
108
  // What a program in the sandbox opens to reach the device's port.
96
109
  url: z.string(),
97
110
  openedAt: z.string(),
111
+ // What the device said the last time it could not dial (a name it cannot resolve, a host that does not answer from
112
+ // there), absent once a connection went through: why a program in the sandbox saw its connection cut.
113
+ failure: z.string().optional(),
98
114
  });
99
115
  export type DeviceTunnel = z.infer<typeof DeviceTunnelSchema>;
@@ -186,6 +186,9 @@ export const DeviceFeatureSchema = z.enum([
186
186
  "reachable-ways-back",
187
187
  // (2026-10-27) The `set-egress` op and the `egress` field on its sandbox rows: an ic with `ic sandbox egress`.
188
188
  "egress",
189
+ // (2026-11-10) `dialLoopback` with a `host`: the agent dials a host on its own network, not only its loopback
190
+ // (`devices reach <device> <host>:<port>`, a network disk reached through a computer).
191
+ "reach-network",
189
192
  ]);
190
193
  export type DeviceFeature = z.infer<typeof DeviceFeatureSchema>;
191
194
  export const DEVICE_FEATURE_RESHAPE_LATER: DeviceFeature = "reshape-later";
@@ -199,6 +202,7 @@ export const DEVICE_FEATURE_KEYRING: DeviceFeature = "keyring";
199
202
  export const DEVICE_FEATURE_SLEEP: DeviceFeature = "sleep";
200
203
  export const DEVICE_FEATURE_EGRESS: DeviceFeature = "egress";
201
204
  export const DEVICE_FEATURE_REACHABLE_WAYS_BACK: DeviceFeature = "reachable-ways-back";
205
+ export const DEVICE_FEATURE_REACH_NETWORK: DeviceFeature = "reach-network";
202
206
  // What `ic features --json` answers (_sandbox/ic/src/features.rs, golden/ic-features.json): the optional ops that ic
203
207
  // implements, as strings, since a newer ic's word means nothing to an older agent.
204
208
  export const IcFeaturesAnswerSchema = z.object({ features: z.array(z.string()) });
@@ -104,6 +104,10 @@ export const KeyringStateSchema = z.object({
104
104
  pendingInbox: z.number().int().nonnegative().describe("Values sent to be kept that wait for the next unlock."),
105
105
  pendingCaptures: z.number().int().nonnegative().optional().describe("Credentials seen in use while locked, kept sealed until the next unlock. Absent from a keyring older than 2026-10-19."),
106
106
  remember: KeyringRememberSchema.optional().describe("Which sources the person let the keyring remember passwords from, so a collector knows whether to send one. Absent before setup and from an older keyring."),
107
+ // The fields below are absent before setup and from a keyring older than 2026-11-09.
108
+ helloAddable: z.boolean().optional().describe("Windows Hello signs here but the vault was set up without it, so it asks for the recovery key: `add-hello` turns Hello on."),
109
+ masterPassword: z.boolean().optional().describe("The person set a master password, asked for instead of the recovery key where Hello or polkit cannot answer."),
110
+ recentlyDeleted: z.number().int().nonnegative().optional().describe("Removed entries kept in Recently deleted, which `undo-remove` puts back."),
107
111
  });
108
112
  export type KeyringState = z.infer<typeof KeyringStateSchema>;
109
113
 
@@ -37,6 +37,18 @@ export const SmbNetdiskConfigSchema = z.object({
37
37
  domain: z.string().optional().describe("The Windows domain or workgroup, only where the server asks for one."),
38
38
  access: NetdiskAccessSchema.default("read").describe("Whether the agent may write to it. Read-only is the default."),
39
39
  version: SmbVersionSchema.default("auto").describe("The SMB dialect to insist on. Leave on auto unless the server refuses."),
40
+ // (2026-11-10) The owner's computer whose own network reaches the server. The sandbox's packets leave through
41
+ // Docker's NAT and its names resolve on public DNS, so a share the PC opens through its VPN client, or by a name only
42
+ // the PC's resolvers know, is out of the sandbox's reach; through `via` the computer's agent dials the server itself
43
+ // (a `devices reach` relay) and the kernel mounts through the relay's port here. Absent: the sandbox dials it.
44
+ via: z
45
+ .string()
46
+ .min(1)
47
+ .refine((value) => !/\s/.test(value), { message: "Reach it through is one computer's name, without spaces." })
48
+ .optional()
49
+ .describe(
50
+ "A connected computer of the owner's (its name as its tools are mounted, mcp__<name>__…) whose own network reaches the server: its LAN, its VPN client, its name resolution. The disk is reached through it. Leave empty when the sandbox reaches the server itself.",
51
+ ),
40
52
  autoMount,
41
53
  });
42
54
  export const NetdiskConfigSchema = z.discriminatedUnion("provider", [SmbNetdiskConfigSchema]);
@@ -62,6 +74,7 @@ export const NetdiskLinkSchema = z.object({
62
74
  target: z.string().describe("What it mounts, as //server/share. For display only, and never a credential."),
63
75
  mountPoint: z.string().describe("Where its files appear inside the sandbox."),
64
76
  access: NetdiskAccessSchema.describe("What the card asked for: read, or read and write."),
77
+ via: z.string().optional().describe("The computer the share is reached through, absent when the sandbox reaches it itself."),
65
78
  // What the kernel actually enforces on the live mount; absent unless mounted. Disagreeing with `access` is the
66
79
  // invariant the daemon patrols.
67
80
  writable: z.boolean().optional().describe("Whether the live mount accepts writes, as the kernel has it. Absent unless mounted."),
@@ -6,7 +6,9 @@ import { AgentHarnessSchema, AgentProviderSchema } from "./agent.js";
6
6
  // sandbox hands a runner on one of the owner's machines instead of running it itself.
7
7
 
8
8
  // Whether a runner can take a line right now, asked before the tree is snapshotted, so a machine that is asleep costs
9
- // nothing. `name` is the machine the runner sits on, the word the owner picked it by.
9
+ // nothing. `name` is the machine the runner sits on, the word the owner picked it by. Asked for OFFLOAD_ANY_RUNNER, it
10
+ // answers with the runner it picked, or not ready with no `why` when this sandbox has room, which runs the line here
11
+ // in silence.
10
12
  export const OffloadTargetSchema = z.object({
11
13
  runner: z.string().min(1),
12
14
  name: z.string().min(1),
@@ -16,6 +18,11 @@ export const OffloadTargetSchema = z.object({
16
18
  });
17
19
  export type OffloadTarget = z.infer<typeof OffloadTargetSchema>;
18
20
 
21
+ // What settings `offload.commands` names instead of one runner: whichever has the most room at the moment the command
22
+ // starts, and only while this sandbox is busy (runners/fleet-advice.ts `roomierRunner`). While this sandbox is calm the
23
+ // command runs here without a word. Reserved: no runner is ever enrolled under it.
24
+ export const OFFLOAD_ANY_RUNNER = "auto";
25
+
19
26
  export const OffloadRunSchema = RunnerCommandSchema.extend({ runner: z.string().min(1) });
20
27
  export type OffloadRun = z.infer<typeof OffloadRunSchema>;
21
28
 
@@ -118,3 +125,8 @@ export const FleetAdviceSchema = z.object({
118
125
  suggestion: z.object({ runner: z.string().min(1), name: z.string().min(1) }).optional(),
119
126
  });
120
127
  export type FleetAdvice = z.infer<typeof FleetAdviceSchema>;
128
+
129
+ // While this sandbox is full and at least one runner is calm, the machines with room by the word the owner knows each by:
130
+ // what a turn is told so that work it can send elsewhere goes there. Absent otherwise.
131
+ export const FleetPressureSchema = z.object({ roomy: z.array(z.string().min(1)).min(1) });
132
+ export type FleetPressure = z.infer<typeof FleetPressureSchema>;
@@ -35,6 +35,13 @@ export const RelayChannelSchema = z.object({
35
35
  ),
36
36
  });
37
37
  export type RelayChannel = z.infer<typeof RelayChannelSchema>;
38
+ // The relay's own word that a relay channel will never deliver again: the device is gone, the relay has no row for it, or
39
+ // its secret was rotated. It rides as the `data` of the relay's refusal (the platform's push-relay.routes.ts), and the
40
+ // daemon forgets a channel only on it (push/senders/relay.ts). (2026-11-09) A status alone used to be enough, and a 403
41
+ // or 404 is also what a proxy in front of a platform that is down answers (an HTML page, Cloudflare's), so an outage
42
+ // silently unregistered every phone.
43
+ export const RELAY_CHANNEL_GONE = "gone";
44
+ export const RelayGoneSchema = z.object({ data: z.object({ channel: z.literal(RELAY_CHANNEL_GONE) }) });
38
45
  export const PushChannelSchema = z.discriminatedUnion("kind", [WebPushChannelSchema, RelayChannelSchema]);
39
46
  export type PushChannel = z.infer<typeof PushChannelSchema>;
40
47
  // The one identity every push route uses (subscribe, unsubscribe, config); derived from the channel's own shape so the
@@ -547,7 +547,8 @@ export const SandboxSettingsSchema = z.object({
547
547
  "Whether each workspace repo keeps up with the remote branch it tracks. Every couple of minutes it is fetched, and what arrived is brought into the main tree: a fast-forward when you have no commits of your own, else a merge commit. Only while it is quiet (no turn working in the main tree, no merge or rebase of yours open), and never half-way: a conflict, or an uncommitted file in the way, leaves the repo exactly as it was until the next try. Following never pushes; the back-up rule does that, when you switch it on. Off, nothing is fetched.",
548
548
  ),
549
549
  // Where heavy work runs: a runner (the same image, on one of the owner's machines) instead of this sandbox. Keyed by
550
- // the heavy-command rule an agent's command matched (workload/heavy-commands.ts), each naming a runner id. A
550
+ // the heavy-command rule an agent's command matched (workload/heavy-commands.ts), each naming a runner id, or "auto"
551
+ // (OFFLOAD_ANY_RUNNER) for whichever runner has the most room while this sandbox is busy. A
551
552
  // runner that is offline, outdated or full hands the work back here, which the command's output says. Never pushed
552
553
  // to a runner itself (definition/definition.ts), which must not pass work on again.
553
554
  // `sessions`: what a new conversation is told when this machine is busy and a runner has room
@@ -560,7 +561,7 @@ export const SandboxSettingsSchema = z.object({
560
561
  })
561
562
  .default({ commands: {}, sessions: "suggest" })
562
563
  .describe(
563
- "Which work runs on a runner on one of your machines instead of this sandbox. `commands`: agents' heavy commands by the kind the heavy-command rules sort them into (tests, typechecks, verify…); the code travels as it stands, uncommitted work included, the output streams back, and any file the command changed comes back with it, while a machine that is offline, outdated or busy hands the work back to this sandbox, and the output says so. `sessions`: what happens to a new conversation while this machine is busy and one of your runners has room: `suggest` offers that machine above the composer, `auto` starts it there unless you keep it here, `off` says nothing.",
564
+ "Which work runs on a runner on one of your machines instead of this sandbox. `commands`: agents' heavy commands by the kind the heavy-command rules sort them into (tests, typechecks, verify…), each sent to one runner, or to `auto`: whichever runner has the most room at the moment the command starts, and only while this sandbox is busy (while it is calm the command runs here as usual). The code travels as it stands, uncommitted work included, the output streams back, and any file the command changed comes back with it, while a machine that is offline, outdated or busy hands the work back to this sandbox, and the output says so. `sessions`: what happens to a new conversation while this machine is busy and one of your runners has room: `suggest` offers that machine above the composer, `auto` starts it there unless you keep it here, `off` says nothing.",
564
565
  ),
565
566
  // A person answering a need is exactly the moment they want the work to go on (docs/architecture/needs.md), unlike a
566
567
  // restart nobody watched, so this one is on to begin with.
@@ -217,6 +217,31 @@ export const DaemonSessionSchema = z.object({
217
217
  });
218
218
  export type DaemonSession = z.infer<typeof DaemonSessionSchema>;
219
219
 
220
+ // (2026-11-09) The owner's name for the sandbox and its switcher logo, as the sandbox last heard them from the platform,
221
+ // which holds them. The sandbox keeps a copy so a client that reaches it while the platform is down still shows both.
222
+ // Its own routes (system.presentation, system.presentationRefresh) rather than fields on /info: /info is read often,
223
+ // and a logo is a data URL of up to 150 KB.
224
+ export const SandboxPresentationSchema = z.object({
225
+ name: z.string().describe("What the owner calls this sandbox, as the switcher shows it."),
226
+ image: z.string().nullable().describe("Its logo, as an image data URL. Null for none: the switcher draws the name's monogram instead."),
227
+ at: z.string().describe("When the sandbox heard this copy from the platform (ISO)."),
228
+ });
229
+ export type SandboxPresentation = z.infer<typeof SandboxPresentationSchema>;
230
+ export const PresentationReadSchema = z.object({
231
+ presentation: SandboxPresentationSchema.nullable().describe(
232
+ "The copy the sandbox holds. Null until it has heard one, which takes reaching the platform once.",
233
+ ),
234
+ });
235
+ export type PresentationRead = z.infer<typeof PresentationReadSchema>;
236
+ export const PresentationRefreshSchema = PresentationReadSchema.extend({
237
+ refreshed: z
238
+ .boolean()
239
+ .describe(
240
+ "Whether the platform answered. False means it could not be reached or refused, and `presentation` is the copy the sandbox already held, which a failed ask never removes.",
241
+ ),
242
+ });
243
+ export type PresentationRefresh = z.infer<typeof PresentationRefreshSchema>;
244
+
220
245
  // Passkeys registered with one sandbox, and the owner's rule that a passkey is the only proof that opens it. The
221
246
  // daemon is the WebAuthn relying party; these are the shapes its /system/passkeys routes and the 428 step-up carry.
222
247
 
@@ -73,3 +73,10 @@ test("server and share are single names, and the folder inside stays inside", ()
73
73
  expect(SmbNetdiskConfigSchema.safeParse({ ...smb, path: "/2026" }).success).toBe(false);
74
74
  expect(SmbNetdiskConfigSchema.safeParse({ ...smb, path: "../etc" }).success).toBe(false);
75
75
  });
76
+
77
+ test("a network disk is reached by the sandbox itself unless it names a computer to reach it through", () => {
78
+ expect(SmbNetdiskConfigSchema.parse(smb).via).toBeUndefined();
79
+ expect(SmbNetdiskConfigSchema.parse({ ...smb, via: "rog" }).via).toBe("rog");
80
+ expect(SmbNetdiskConfigSchema.safeParse({ ...smb, via: "my pc" }).success).toBe(false);
81
+ expect(SmbNetdiskConfigSchema.safeParse({ ...smb, via: "" }).success).toBe(false);
82
+ });