@intentic/sandbox-contract 1.363.0 → 1.364.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 (139) hide show
  1. package/README.md +4 -0
  2. package/dist/contracts/access-profiles.contract.d.ts +91 -0
  3. package/dist/contracts/access-profiles.contract.d.ts.map +1 -0
  4. package/dist/contracts/access-profiles.contract.js +33 -0
  5. package/dist/contracts/access-profiles.contract.js.map +1 -0
  6. package/dist/contracts/agent.contract.d.ts +18 -0
  7. package/dist/contracts/agent.contract.d.ts.map +1 -1
  8. package/dist/contracts/agents.contract.d.ts +7 -0
  9. package/dist/contracts/agents.contract.d.ts.map +1 -1
  10. package/dist/contracts/automations.contract.d.ts +5 -0
  11. package/dist/contracts/automations.contract.d.ts.map +1 -1
  12. package/dist/contracts/extensions.contract.d.ts +6 -0
  13. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  14. package/dist/contracts/needs.contract.d.ts +14 -0
  15. package/dist/contracts/needs.contract.d.ts.map +1 -1
  16. package/dist/contracts/org.contract.d.ts +49 -0
  17. package/dist/contracts/org.contract.d.ts.map +1 -1
  18. package/dist/contracts/runner.contract.d.ts +6 -0
  19. package/dist/contracts/runner.contract.d.ts.map +1 -1
  20. package/dist/contracts/services.contract.d.ts +26 -0
  21. package/dist/contracts/services.contract.d.ts.map +1 -0
  22. package/dist/contracts/services.contract.js +33 -0
  23. package/dist/contracts/services.contract.js.map +1 -0
  24. package/dist/contracts/sessions.contract.d.ts +2 -0
  25. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  26. package/dist/contracts/system.contract.d.ts +3 -0
  27. package/dist/contracts/system.contract.d.ts.map +1 -1
  28. package/dist/events/agent-events.d.ts +8 -0
  29. package/dist/events/agent-events.d.ts.map +1 -1
  30. package/dist/events/agent-transcript.d.ts +2 -0
  31. package/dist/events/agent-transcript.d.ts.map +1 -1
  32. package/dist/events/transcript.d.ts +10 -0
  33. package/dist/events/transcript.d.ts.map +1 -1
  34. package/dist/index.d.ts +219 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +4 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/models/model-setups.d.ts.map +1 -1
  39. package/dist/models/model-setups.js.map +1 -1
  40. package/dist/policy/control-scopes.d.ts +3 -0
  41. package/dist/policy/control-scopes.d.ts.map +1 -1
  42. package/dist/policy/control-scopes.js +2 -0
  43. package/dist/policy/control-scopes.js.map +1 -1
  44. package/dist/policy/org-locks.d.ts +1 -1
  45. package/dist/policy/org-locks.d.ts.map +1 -1
  46. package/dist/policy/org-locks.js +3 -1
  47. package/dist/policy/org-locks.js.map +1 -1
  48. package/dist/protocol/raw/raw-json-routes.d.ts +309 -1
  49. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  50. package/dist/protocol/raw/raw-json-routes.js +3 -1
  51. package/dist/protocol/raw/raw-json-routes.js.map +1 -1
  52. package/dist/protocol/raw/raw-routes.d.ts +2 -0
  53. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  54. package/dist/protocol/raw/raw-routes.js +2 -0
  55. package/dist/protocol/raw/raw-routes.js.map +1 -1
  56. package/dist/schemas/access-profiles.d.ts +153 -0
  57. package/dist/schemas/access-profiles.d.ts.map +1 -0
  58. package/dist/schemas/access-profiles.js +56 -0
  59. package/dist/schemas/access-profiles.js.map +1 -0
  60. package/dist/schemas/agents-list.d.ts +1 -0
  61. package/dist/schemas/agents-list.d.ts.map +1 -1
  62. package/dist/schemas/automations.d.ts +10 -0
  63. package/dist/schemas/automations.d.ts.map +1 -1
  64. package/dist/schemas/automations.js +7 -0
  65. package/dist/schemas/automations.js.map +1 -1
  66. package/dist/schemas/dev-rebuild-log.d.ts +16 -0
  67. package/dist/schemas/dev-rebuild-log.d.ts.map +1 -1
  68. package/dist/schemas/dev-rebuild-log.js +38 -2
  69. package/dist/schemas/dev-rebuild-log.js.map +1 -1
  70. package/dist/schemas/device-commands.d.ts +7 -1
  71. package/dist/schemas/device-commands.d.ts.map +1 -1
  72. package/dist/schemas/device-commands.js +14 -2
  73. package/dist/schemas/device-commands.js.map +1 -1
  74. package/dist/schemas/environment.d.ts +27 -0
  75. package/dist/schemas/environment.d.ts.map +1 -1
  76. package/dist/schemas/environment.js +9 -0
  77. package/dist/schemas/environment.js.map +1 -1
  78. package/dist/schemas/extension-updates.d.ts +12 -0
  79. package/dist/schemas/extension-updates.d.ts.map +1 -1
  80. package/dist/schemas/links.d.ts +6 -1
  81. package/dist/schemas/links.d.ts.map +1 -1
  82. package/dist/schemas/links.js +8 -1
  83. package/dist/schemas/links.js.map +1 -1
  84. package/dist/schemas/members.d.ts +75 -0
  85. package/dist/schemas/members.d.ts.map +1 -1
  86. package/dist/schemas/members.js +17 -0
  87. package/dist/schemas/members.js.map +1 -1
  88. package/dist/schemas/needs.d.ts +16 -0
  89. package/dist/schemas/needs.d.ts.map +1 -1
  90. package/dist/schemas/organisation.d.ts +164 -0
  91. package/dist/schemas/organisation.d.ts.map +1 -1
  92. package/dist/schemas/organisation.js +17 -0
  93. package/dist/schemas/organisation.js.map +1 -1
  94. package/dist/schemas/personas.d.ts.map +1 -1
  95. package/dist/schemas/personas.js +2 -2
  96. package/dist/schemas/personas.js.map +1 -1
  97. package/dist/schemas/services.d.ts +24 -0
  98. package/dist/schemas/services.d.ts.map +1 -0
  99. package/dist/schemas/services.js +19 -0
  100. package/dist/schemas/services.js.map +1 -0
  101. package/dist/schemas/settings.d.ts.map +1 -1
  102. package/dist/schemas/settings.js +3 -3
  103. package/dist/schemas/settings.js.map +1 -1
  104. package/dist/schemas/tool-ceiling.d.ts +24 -0
  105. package/dist/schemas/tool-ceiling.d.ts.map +1 -0
  106. package/dist/schemas/tool-ceiling.js +86 -0
  107. package/dist/schemas/tool-ceiling.js.map +1 -0
  108. package/dist/state/locked-folders.d.ts +2 -0
  109. package/dist/state/locked-folders.d.ts.map +1 -0
  110. package/dist/state/locked-folders.js +11 -0
  111. package/dist/state/locked-folders.js.map +1 -0
  112. package/package.json +5 -5
  113. package/src/contracts/access-profiles.contract.ts +43 -0
  114. package/src/contracts/services.contract.ts +40 -0
  115. package/src/index.ts +4 -0
  116. package/src/models/model-roles.ts +2 -2
  117. package/src/models/model-setups.ts +3 -4
  118. package/src/policy/control-scopes.ts +5 -0
  119. package/src/policy/org-locks.ts +5 -2
  120. package/src/protocol/raw/raw-json-routes.ts +3 -0
  121. package/src/protocol/raw/raw-routes.ts +2 -0
  122. package/src/schemas/access-profiles.test.ts +50 -0
  123. package/src/schemas/access-profiles.ts +104 -0
  124. package/src/schemas/automations.ts +15 -1
  125. package/src/schemas/dev-rebuild-log.test.ts +46 -1
  126. package/src/schemas/dev-rebuild-log.ts +71 -3
  127. package/src/schemas/device-commands.ts +30 -2
  128. package/src/schemas/environment.ts +22 -0
  129. package/src/schemas/links.ts +13 -2
  130. package/src/schemas/members.ts +29 -1
  131. package/src/schemas/organisation.ts +25 -0
  132. package/src/schemas/personas.ts +15 -11
  133. package/src/schemas/services.ts +32 -0
  134. package/src/schemas/settings.test.ts +23 -1
  135. package/src/schemas/settings.ts +5 -4
  136. package/src/schemas/tool-ceiling.test.ts +70 -0
  137. package/src/schemas/tool-ceiling.ts +113 -0
  138. package/src/state/locked-folders.test.ts +29 -0
  139. package/src/state/locked-folders.ts +17 -0
@@ -308,6 +308,11 @@ export const SenderRuleSchema = z
308
308
  .optional()
309
309
  .describe("Group ids the service reports on a sender, a Discord role. Only for a source whose messages carry them."),
310
310
  actsAs: entryId.optional().describe("Which persona their wakes speak as. Absent is no persona: the full toolbox, reaching no account."),
311
+ // The service (schemas/services.ts) their wakes act as, in place of the automation's own: a narrower one for
312
+ // strangers, a wider one for people the owner trusts. Never more than that service's steward may.
313
+ runAs: entryId
314
+ .optional()
315
+ .describe("Which service their wakes act as, in place of the automation's own. Absent means the automation's own service."),
311
316
  // Tightens, never loosens: the automation's own `requireApproval` still holds everyone.
312
317
  requireApproval: z.boolean().optional().describe("Hold their wakes for a person, even when the automation itself does not."),
313
318
  })
@@ -397,8 +402,15 @@ export const AutomationSchema = z.object({
397
402
  // is watching to notice a stuck one.
398
403
  account: z.string().optional().describe("Which account pays for it."),
399
404
  // Absent means the wake reaches no logged-in account at all, the strictest default here, since nobody is at the
400
- // composer when it fires.
405
+ // composer when it fires. Posture only: what the wake may reach is `runAs`'s (docs/architecture/access.md).
401
406
  actsAs: entryId.optional().describe("Which persona it speaks as. An unwatched turn naming none reaches no signed-in account at all."),
407
+ // Who its wakes act for (schemas/services.ts): that service's steward, held to the service's access profile. Absent
408
+ // keeps what a wake always did: it acts for the sandbox's owner with no profile, its persona the only narrowing.
409
+ runAs: entryId
410
+ .optional()
411
+ .describe(
412
+ "Which service it acts as: whose authority its wakes use, held to that service's access profile. Absent means the sandbox's owner, limited only by its persona.",
413
+ ),
402
414
  // Listener triggers on a source that identifies senders only (TriggerSource.sender); refused elsewhere at upsert.
403
415
  // Absent means everyone the filters admit, wearing `actsAs`.
404
416
  senders: SendersSchema.optional().describe(
@@ -462,6 +474,8 @@ export const AutomationApprovalSchema = z.object({
462
474
  // The persona the fire resolved to (a sender rule's, or the automation's), snapshotted at hold time and worn by the
463
475
  // approved run; also what a project-scoped board files the wake under.
464
476
  actsAs: entryId.optional().describe("Which persona the approved run speaks as, decided when it was held."),
477
+ // The service the fire resolved to (a sender rule's, or the automation's), snapshotted beside the persona.
478
+ runAs: entryId.optional().describe("Which service the approved run acts as, decided when it was held."),
465
479
  createdAt: z.number().describe("When it started waiting, in milliseconds."),
466
480
  // When the daemon may run this itself, for a `holdForSeconds` hold; absent for a `requireApproval` hold, which only
467
481
  // the owner releases.
@@ -1,4 +1,15 @@
1
- import { DEV_REBUILD_EXIT_MARK, DEV_REBUILD_QUIET_MARK, devRebuildLogPath, readDevRebuildLog } from "./dev-rebuild-log.js";
1
+ import {
2
+ DEV_REBUILD_CANCEL_MARK,
3
+ DEV_REBUILD_EXIT_MARK,
4
+ DEV_REBUILD_HOLD_MARK,
5
+ DEV_REBUILD_QUIET_MARK,
6
+ DEV_REBUILD_SWAP_MARK,
7
+ DEV_REBUILD_TASKS_MARK,
8
+ DEV_REBUILD_WAITING_MARK,
9
+ devRebuildHoldPath,
10
+ devRebuildLogPath,
11
+ readDevRebuildLog,
12
+ } from "./dev-rebuild-log.js";
2
13
 
3
14
  // The one account a detached rebuild gives of itself. The daemon builds the shell that writes this text and the browser
4
15
  // draws what it means, so the grammar is pinned here, where both of them read it.
@@ -52,3 +63,37 @@ test("treats an answer with no marks as log text, not as an error", () => {
52
63
  test("names one log per sandbox, beside the logs ic writes for its own recreates", () => {
53
64
  expect(devRebuildLogPath("work-abc")).toBe("~/.intentic/logs/dev-rebuild-work-abc.log");
54
65
  });
66
+
67
+ test("reads the hold file's state and turbo's count, which the read prints before the tail", () => {
68
+ const log = readDevRebuildLog(answer("3", `${DEV_REBUILD_HOLD_MARK} 1`, `${DEV_REBUILD_TASKS_MARK} 23 -`, "@intentic/sandbox:build: $ tsc"));
69
+ expect(log).toMatchObject({ hold: true, tasks: { started: 23, total: undefined } });
70
+ expect(log.lines).toEqual(["@intentic/sandbox:build: $ tsc"]);
71
+ expect(readDevRebuildLog(answer("3", `${DEV_REBUILD_HOLD_MARK} 0`, `${DEV_REBUILD_TASKS_MARK} 48 48`))).toMatchObject({
72
+ hold: false,
73
+ tasks: { started: 48, total: 48 },
74
+ });
75
+ });
76
+
77
+ // An older daemon's read says neither, which is "unknown" rather than "not held": the card then offers no choice.
78
+ test("leaves the hold and the count unknown when the read does not print them", () => {
79
+ expect(readDevRebuildLog(answer("3", "building"))).toMatchObject({ hold: undefined, tasks: undefined });
80
+ });
81
+
82
+ // The gate's two words, in order: holding, then let through. Whichever came last is where it stands.
83
+ test("reads the gate holding until it says it let the swap through", () => {
84
+ const holding = readDevRebuildLog(answer("40", "#27 naming to intentic-sandbox:dev", DEV_REBUILD_WAITING_MARK));
85
+ expect(holding).toMatchObject({ waiting: true, swapping: false });
86
+ expect(holding.lines).toEqual(["#27 naming to intentic-sandbox:dev"]);
87
+ const through = readDevRebuildLog(answer("1", DEV_REBUILD_WAITING_MARK, DEV_REBUILD_SWAP_MARK, "intentic: [recreate] starting"));
88
+ expect(through).toMatchObject({ waiting: false, swapping: true });
89
+ });
90
+
91
+ test("reads a cancelled build as ended by somebody asking, not as a failure of its own", () => {
92
+ const log = readDevRebuildLog(answer("0", "#12 [builder 4/9] RUN pnpm install", "", DEV_REBUILD_CANCEL_MARK, `${DEV_REBUILD_EXIT_MARK} 130`));
93
+ expect(log).toMatchObject({ cancelled: true, exitCode: 130, waiting: false });
94
+ expect(log.lines).toEqual(["#12 [builder 4/9] RUN pnpm install"]);
95
+ });
96
+
97
+ test("keeps the gate's hold file beside the log it belongs to", () => {
98
+ expect(devRebuildHoldPath("work-abc")).toBe("~/.intentic/logs/dev-rebuild-work-abc.hold");
99
+ });
@@ -8,6 +8,15 @@
8
8
  // browser names the same path to a reader whose rebuild never came back.
9
9
  export const devRebuildLogPath = (slug: string): string => `~/.intentic/logs/dev-rebuild-${slug}.log`;
10
10
 
11
+ // THE SWAP GATE'S FILE. While it exists, ic stops a dev recreate after the images are built and before anything touches
12
+ // the container (INTENTIC_SWAP_GATE, recreate.rs), and waits for it to go. `dev-rebuild-hold` makes it, `dev-rebuild-release`
13
+ // removes it, and `dev-rebuild` clears one a previous run left behind before it starts.
14
+ export const devRebuildHoldPath = (slug: string): string => `~/.intentic/logs/dev-rebuild-${slug}.hold`;
15
+
16
+ // The build's process: its session leader, written by the build's own shell as it starts, so `dev-rebuild-cancel` can
17
+ // stop the whole tree (pnpm, turbo, docker's client, ic) rather than the one shell it would otherwise know about.
18
+ export const devRebuildPidPath = (slug: string): string => `~/.intentic/logs/dev-rebuild-${slug}.pid`;
19
+
11
20
  // The build's own shell appends this when the build ends, with its exit status: since the log outlives the daemon, the
12
21
  // container and the page that started it, this mark is the only thing that can say a rebuild is OVER rather than slow.
13
22
  export const DEV_REBUILD_EXIT_MARK = "@intentic-rebuild-exit";
@@ -15,6 +24,27 @@ export const DEV_REBUILD_EXIT_MARK = "@intentic-rebuild-exit";
15
24
  // that machine at all. A running build goes quiet for a minute at a time inside a docker layer; a build whose machine
16
25
  // slept never writes its exit mark, and only this tells the two apart.
17
26
  export const DEV_REBUILD_QUIET_MARK = "@intentic-rebuild-quiet";
27
+ // `dev-rebuild-log` prints whether the hold file is there right now: `1` held, `0` not. Absent from an older daemon's read.
28
+ export const DEV_REBUILD_HOLD_MARK = "@intentic-rebuild-hold";
29
+ // `dev-rebuild-log` prints how many of turbo's tasks have started in the WHOLE log, not the tail — the tail is 80 lines
30
+ // of a log that runs to thousands, so a count kept from it would miss most of them. Turbo names no total up front (its
31
+ // "Running build in N packages" is the packages in scope, a quarter of the tasks), so the total is `-` until turbo's own
32
+ // summary line says it at the end; a reader that remembers the last run's total is what gives "of 48" before then.
33
+ export const DEV_REBUILD_TASKS_MARK = "@intentic-rebuild-tasks";
34
+ // The gate's own words, printed into the log by ic: it is holding (built, waiting for the hold file to go), and it let
35
+ // the swap through. Past the second, the container is being replaced and nothing may stop the build any more.
36
+ export const DEV_REBUILD_WAITING_MARK = "@intentic-rebuild-waiting";
37
+ export const DEV_REBUILD_SWAP_MARK = "@intentic-rebuild-swap";
38
+ // `dev-rebuild-cancel` appends this, then an exit mark of 130, once it has stopped the build: a run that ended because
39
+ // somebody asked, rather than one that failed.
40
+ export const DEV_REBUILD_CANCEL_MARK = "@intentic-rebuild-cancelled";
41
+
42
+ export interface DevRebuildTasks {
43
+ /** Turbo's tasks that have started, cache hits included. */
44
+ readonly started: number;
45
+ /** How many it runs in all, once its summary has said; undefined before. */
46
+ readonly total: number | undefined;
47
+ }
18
48
 
19
49
  export interface DevRebuildLog {
20
50
  /** Nothing has ever rebuilt this sandbox from a checkout on that machine. */
@@ -23,30 +53,66 @@ export interface DevRebuildLog {
23
53
  readonly quietFor: number | undefined;
24
54
  /** The build's own exit status, present only once it has ended. */
25
55
  readonly exitCode: number | undefined;
26
- /** The tail as the machine printed it, both marks removed. */
56
+ /** Ended because somebody cancelled it (`dev-rebuild-cancel`), not because it failed. */
57
+ readonly cancelled: boolean;
58
+ /** Whether the hold file is there; undefined from a daemon too old to say. */
59
+ readonly hold: boolean | undefined;
60
+ /** The gate is holding right now: the images are built, the container untouched, the restart waiting to be let through. */
61
+ readonly waiting: boolean;
62
+ /** The gate let the swap through: the container is being replaced. */
63
+ readonly swapping: boolean;
64
+ /** Turbo's count, from the whole log; undefined from a daemon too old to count. */
65
+ readonly tasks: DevRebuildTasks | undefined;
66
+ /** The tail as the machine printed it, every mark removed. */
27
67
  readonly lines: readonly string[];
28
68
  }
29
69
 
30
70
  // Reads `dev-rebuild-log`'s stdout. Shared rather than parsed at the reader, so the shell line that produces this and the
31
71
  // card that draws it cannot drift apart. Unparseable is never an error: an answer with no marks at all is simply a log
32
72
  // with nothing to say yet.
33
- const markValue = (line: string, mark: string): string | undefined => (line.startsWith(`${mark} `) ? line.slice(mark.length + 1).trim() : undefined);
73
+ const markValue = (line: string, mark: string): string | undefined =>
74
+ line === mark ? `` : line.startsWith(`${mark} `) ? line.slice(mark.length + 1).trim() : undefined;
34
75
  const wholeNumber = (value: string): number | undefined => (/^\d+$/.test(value) ? Number(value) : undefined);
35
76
 
77
+ const readTasks = (value: string): DevRebuildTasks | undefined => {
78
+ const [started, total] = value.split(/\s+/);
79
+ const count = wholeNumber(started ?? ``);
80
+ return count === undefined ? undefined : { started: count, total: wholeNumber(total ?? ``) };
81
+ };
82
+
36
83
  export const readDevRebuildLog = (text: string): DevRebuildLog => {
37
84
  let missing = false;
38
85
  let quietFor: number | undefined;
39
86
  let exitCode: number | undefined;
87
+ let cancelled = false;
88
+ let hold: boolean | undefined;
89
+ let tasks: DevRebuildTasks | undefined;
90
+ // The last of the gate's two words: the tail is in order, so whichever came last is where the gate stands.
91
+ let gate: `waiting` | `swap` | undefined;
92
+ let swapping = false;
40
93
  const lines: string[] = [];
41
94
  for (const line of text.split(/\r?\n/)) {
42
95
  const quiet = markValue(line, DEV_REBUILD_QUIET_MARK);
43
96
  const exit = markValue(line, DEV_REBUILD_EXIT_MARK);
97
+ const held = markValue(line, DEV_REBUILD_HOLD_MARK);
98
+ const counted = markValue(line, DEV_REBUILD_TASKS_MARK);
44
99
  if (quiet !== undefined) {
45
100
  missing = quiet === "-";
46
101
  quietFor = wholeNumber(quiet);
47
102
  } else if (exit !== undefined) {
48
103
  // A mark whose status is unreadable still means the build ENDED, and not well.
49
104
  exitCode = wholeNumber(exit) ?? 1;
105
+ } else if (held !== undefined) {
106
+ hold = held === `1`;
107
+ } else if (counted !== undefined) {
108
+ tasks = readTasks(counted);
109
+ } else if (markValue(line, DEV_REBUILD_CANCEL_MARK) !== undefined) {
110
+ cancelled = true;
111
+ } else if (markValue(line, DEV_REBUILD_WAITING_MARK) !== undefined) {
112
+ gate = `waiting`;
113
+ } else if (markValue(line, DEV_REBUILD_SWAP_MARK) !== undefined) {
114
+ gate = `swap`;
115
+ swapping = true;
50
116
  } else {
51
117
  lines.push(line);
52
118
  }
@@ -54,5 +120,7 @@ export const readDevRebuildLog = (text: string): DevRebuildLog => {
54
120
  while (lines.at(-1)?.trim() === "") {
55
121
  lines.pop();
56
122
  }
57
- return { missing, quietFor, exitCode, lines };
123
+ // A gate still holding has printed nothing since its word, and a build that ended is holding nothing.
124
+ const waiting = gate === `waiting` && exitCode === undefined;
125
+ return { missing, quietFor, exitCode, cancelled, hold, waiting, swapping, tasks, lines };
58
126
  };
@@ -16,17 +16,45 @@ export const DeviceCommandSchema = z.enum([
16
16
  "dev-restart",
17
17
  "dev-rebuild",
18
18
  "dev-rebuild-log",
19
+ // The rebuild's three levers, each a file beside its log on the machine (dev-rebuild-log.ts): hold the restart at
20
+ // the swap gate, let it through, or stop the build before the gate is passed.
21
+ "dev-rebuild-hold",
22
+ "dev-rebuild-release",
23
+ "dev-rebuild-cancel",
19
24
  "sync-install",
20
25
  ]);
21
26
  export type DeviceCommand = z.infer<typeof DeviceCommandSchema>;
22
27
  // The reversible sync switches: the subset a device's own row drives with a pair of buttons, as opposed to the two
23
28
  // commands a card elsewhere issues once. Its own type so those button tables stay total without carrying entries for
24
29
  // commands they can never send.
25
- export const DeviceSyncSwitchSchema = DeviceCommandSchema.exclude(["dev-restart", "dev-rebuild", "dev-rebuild-log", "sync-install", "sync-clean"]);
30
+ export const DeviceSyncSwitchSchema = DeviceCommandSchema.exclude([
31
+ "dev-restart",
32
+ "dev-rebuild",
33
+ "dev-rebuild-log",
34
+ "dev-rebuild-hold",
35
+ "dev-rebuild-release",
36
+ "dev-rebuild-cancel",
37
+ "sync-install",
38
+ "sync-clean",
39
+ ]);
26
40
  export type DeviceSyncSwitch = z.infer<typeof DeviceSyncSwitchSchema>;
27
41
 
28
42
  // Where a detached rebuild reports itself, and the reader of that report (dev-rebuild-log.ts).
29
- export { DEV_REBUILD_EXIT_MARK, DEV_REBUILD_QUIET_MARK, type DevRebuildLog, devRebuildLogPath, readDevRebuildLog } from "./dev-rebuild-log.js";
43
+ export {
44
+ DEV_REBUILD_CANCEL_MARK,
45
+ DEV_REBUILD_EXIT_MARK,
46
+ DEV_REBUILD_HOLD_MARK,
47
+ DEV_REBUILD_QUIET_MARK,
48
+ DEV_REBUILD_SWAP_MARK,
49
+ DEV_REBUILD_TASKS_MARK,
50
+ DEV_REBUILD_WAITING_MARK,
51
+ type DevRebuildLog,
52
+ type DevRebuildTasks,
53
+ devRebuildHoldPath,
54
+ devRebuildLogPath,
55
+ devRebuildPidPath,
56
+ readDevRebuildLog,
57
+ } from "./dev-rebuild-log.js";
30
58
 
31
59
  // Machine's sandbox id (absent = every paired sandbox); must start alphanumeric, else it parses as a CLI flag.
32
60
  export const DeviceSandboxIdSchema = z
@@ -125,6 +125,26 @@ export type EnvironmentRebuildWait = z.infer<typeof EnvironmentRebuildWaitSchema
125
125
  // Asks for that rebuild: the approved overlay's hash and the device that rebuilds this sandbox.
126
126
  export const EnvironmentRebuildWhenIdleSchema = z.object({ host: z.string().min(1), hash: z.string().min(1) });
127
127
  export type EnvironmentRebuildWhenIdle = z.infer<typeof EnvironmentRebuildWhenIdleSchema>;
128
+ // A CHECKOUT REBUILD'S RESTART, LET THROUGH ONCE NO AGENT IS MID-TURN. The rebuild holds at its swap gate (the hold file,
129
+ // dev-rebuild-log.ts) and the sandbox, which is the one that knows who is mid-turn, lets it through when nobody is. Kept
130
+ // by the sandbox for the same reason as the rebuild wait above, and in memory for the same reason: this sandbox
131
+ // restarting for anything else is the interruption it was waiting to spare.
132
+ export const EnvironmentDevSwapWaitSchema = z.object({
133
+ // The connected device that runs the rebuild, and so holds its gate.
134
+ host: z.string(),
135
+ requestedAt: z.number(),
136
+ // waiting: the gate is held until nobody is mid-turn. released: let through, the restart is under way.
137
+ // failed: the device could not be told; said until the owner picks again.
138
+ phase: z.enum(["waiting", "released", "failed"]),
139
+ // Who it waits on, by the title the board shows them under; empty once it is no longer waiting.
140
+ waitingOn: z.array(z.string()),
141
+ // The device's own words for a failed one.
142
+ message: z.string().optional(),
143
+ });
144
+ export type EnvironmentDevSwapWait = z.infer<typeof EnvironmentDevSwapWaitSchema>;
145
+ // Asks for that wait: the device the rebuild runs on.
146
+ export const EnvironmentDevSwapWhenIdleSchema = z.object({ host: z.string().min(1) });
147
+ export type EnvironmentDevSwapWhenIdle = z.infer<typeof EnvironmentDevSwapWhenIdleSchema>;
128
148
  export const EnvironmentSchema = z.object({
129
149
  proposal: environmentFileSchema.optional(),
130
150
  // The owner-approved agent-written custom section (.intentic/config/environment.custom.Dockerfile).
@@ -142,6 +162,8 @@ export const EnvironmentSchema = z.object({
142
162
  localImage: EnvironmentLocalImageSchema.optional(),
143
163
  // A rebuild waiting for the agents to be idle, or started or refused once they were; absent when none is asked.
144
164
  rebuildWhenIdle: EnvironmentRebuildWaitSchema.optional(),
165
+ // A checkout rebuild's restart held until no agent is mid-turn; absent when none is asked.
166
+ devSwapWhenIdle: EnvironmentDevSwapWaitSchema.optional(),
145
167
  // This sandbox can hold a rebuild until no agent is mid-turn (POST /environment/rebuild-when-idle), and resume the
146
168
  // turns a restart the owner starts cuts when asked (a device swap's `resumeTurns`). Absent from one too old to,
147
169
  // where the rebuild dialog offers only "Rebuild now" and the cut turns wait to be continued, as before.
@@ -27,6 +27,12 @@ export const LinkTermsSchema = z.object({
27
27
  .describe(
28
28
  "The persona every task through this link wears: its accounts, its shelves, its folders, its model. Absent, the task runs with no signed-in account and the full toolbox, as any unattended wake does.",
29
29
  ),
30
+ // Who the link's tasks act for (schemas/services.ts), the hard half beside the persona's posture.
31
+ runAs: entryId
32
+ .optional()
33
+ .describe(
34
+ "The service every task through this link acts as: whose authority it uses, held to that service's access profile. Absent means this sandbox's owner, limited only by the persona.",
35
+ ),
30
36
  approve: z
31
37
  .boolean()
32
38
  .default(false)
@@ -84,8 +90,13 @@ export type InboundLinkMint = z.infer<typeof InboundLinkMintSchema>;
84
90
  // The raw token, shown exactly once.
85
91
  export const InboundLinkMintedSchema = z.object({ id: z.string(), token: z.string() });
86
92
  export type InboundLinkMinted = z.infer<typeof InboundLinkMintedSchema>;
87
- // POST /system/links/{id}: new terms, whole fields replaced, the rest kept.
88
- export const InboundLinkTermsUpdateSchema = LinkTermsSchema.partial().extend({ label: z.string().trim().min(1).max(60).optional() });
93
+ // POST /system/links/{id}: new terms, whole fields replaced, the rest kept. `null` on the persona or the service takes it
94
+ // off (2026-10-26): absence keeps a field, so before this neither could be cleared once set.
95
+ export const InboundLinkTermsUpdateSchema = LinkTermsSchema.partial().extend({
96
+ label: z.string().trim().min(1).max(60).optional(),
97
+ actsAs: entryId.nullable().optional().describe("The persona every task wears; null takes it off."),
98
+ runAs: entryId.nullable().optional().describe("The service every task acts as; null takes it off, so tasks act for this sandbox's owner."),
99
+ });
89
100
  export type InboundLinkTermsUpdate = z.infer<typeof InboundLinkTermsUpdateSchema>;
90
101
  // POST /system/links/{id}/requests/{request}: the owner's answer to one waiting task.
91
102
  export const LinkRequestDecisionSchema = z.object({ approve: z.boolean() });
@@ -1,7 +1,9 @@
1
1
  // members: the daemon's shared-access roster (GET/POST/DELETE /members), who besides the owner reaches this sandbox
2
2
  import { z } from "zod";
3
3
  import type { CapabilityKind } from "./capabilities.js";
4
+ import { entryId } from "./internal.js";
4
5
  import { type GrantedRole, GrantedRoleSchema, MemberRoleSchema } from "./shared.js";
6
+ import { ToolCeilingSchema } from "./tool-ceiling.js";
5
7
 
6
8
  // WHAT A PERSON'S CONVERSATIONS MAY SPEND: the connected capabilities (by id) and the stored secrets (by name) an agent
7
9
  // working for them is handed. Enforced by the daemon, not told to the model: a capability outside it is never mounted
@@ -191,6 +193,21 @@ export const MemberSchema = z.object({
191
193
  .describe(
192
194
  "The AI accounts their conversations may run on, each `provider:account`, or a provider's id alone for every account of it (how an API-key endpoint is named). Absent means every one, including any connected later.",
193
195
  ),
196
+ tools: ToolCeilingSchema.optional().describe(
197
+ "The most their conversations' tools may be, shelf by shelf; a persona only narrows inside it. Absent means no limit.",
198
+ ),
199
+ assistants: z
200
+ .array(entryId)
201
+ .max(50)
202
+ .optional()
203
+ .describe(
204
+ "For a guest who chats: which of the assistants working in their areas they may talk to, by persona id. Absent means every one that works there.",
205
+ ),
206
+ profile: entryId
207
+ .optional()
208
+ .describe(
209
+ "The access profile their answers come from (docs/architecture/access.md). Its answers are written out on this row too, and saving the profile rewrites them. Absent means answers of their own.",
210
+ ),
194
211
  });
195
212
  export type Member = z.infer<typeof MemberSchema>;
196
213
 
@@ -214,7 +231,12 @@ export type MembersRoster = z.infer<typeof MembersRosterSchema>;
214
231
  // them still grants what it always did. `lands` is written as sent: absent is no, so a re-grade that never mentions it
215
232
  // can never hand a home-only person's agent the authority to land. The role sent must be the tier the access makes (`tierOf`): two answers to one
216
233
  // question are refused rather than one of them guessed away. `aiAccounts` reads as `credentials` does: `all` lifts it, a
217
- // list sets it, absent keeps the row's; a maintainer is refused a list, since the tier runs on every account.
234
+ // list sets it, absent keeps the row's; a maintainer is refused a list, since the tier runs on every account. `tools` and
235
+ // `assistants` read the same way.
236
+ // `profile` names an access profile instead of answering on the row: the daemon writes that profile's answers out on
237
+ // the row and ignores the access fields sent beside it, and the role sent must still be the tier the profile makes.
238
+ // Absent is answers of the row's own, so a re-grade from an editor that predates profiles unlinks the row, keeping
239
+ // the answers it carried, rather than leaving a link the grant did not mean. A maintainer is refused one.
218
240
  export const MemberGrantSchema = z.object({
219
241
  email: z.string(),
220
242
  role: GrantedRoleSchema,
@@ -225,6 +247,9 @@ export const MemberGrantSchema = z.object({
225
247
  emailSignIn: z.boolean().optional(),
226
248
  credentials: z.union([z.literal("all"), CredentialReachSchema]).optional(),
227
249
  aiAccounts: z.union([z.literal("all"), z.array(AiAccountKeySchema).max(500)]).optional(),
250
+ tools: z.union([z.literal("all"), ToolCeilingSchema]).optional(),
251
+ assistants: z.union([z.literal("all"), z.array(entryId).max(50)]).optional(),
252
+ profile: entryId.optional(),
228
253
  });
229
254
  export type MemberGrant = z.infer<typeof MemberGrantSchema>;
230
255
 
@@ -243,6 +268,9 @@ export const MemberSelfSchema = z.object({
243
268
  .array(AiAccountKeySchema)
244
269
  .optional()
245
270
  .describe("The AI accounts their conversations may run on, as the roster keys them, so a picker offers only those. Absent means every one."),
271
+ tools: ToolCeilingSchema.optional().describe("The most their conversations' tools may be. Absent means no limit."),
272
+ assistants: z.array(entryId).optional().describe("For a guest who chats: the assistants they may talk to. Absent means every one in their areas."),
273
+ profile: entryId.optional().describe("The access profile their access comes from. Absent means answers of their own."),
246
274
  });
247
275
  export type MemberSelf = z.infer<typeof MemberSelfSchema>;
248
276
 
@@ -1,5 +1,8 @@
1
1
  import { z } from "zod";
2
+ import { AccessProfileSchema } from "./access-profiles.js";
2
3
  import { PRESET_GROUPS, type PresetGroup, PresetGroupSchema } from "./compliance.js";
4
+ import { AiAccountKeySchema } from "./members.js";
5
+ import { ToolCeilingSchema } from "./tool-ceiling.js";
3
6
 
4
7
  // An ORGANISATION'S POLICY as a sandbox holds it (docs/architecture/organisations.md). A sandbox that belongs to an
5
8
  // organisation is handed this by the platform it is registered with; a personal sandbox never holds one, and nothing
@@ -30,6 +33,20 @@ export type OrgSection = z.infer<typeof OrgSectionSchema>;
30
33
  export const OrgSectionModeSchema = z.enum(["open", "locked", "hidden"]);
31
34
  export type OrgSectionMode = z.infer<typeof OrgSectionModeSchema>;
32
35
 
36
+ // THE ORGANISATION'S CEILING: one more limit in every turn of a bound sandbox, the owner's included
37
+ // (docs/architecture/access.md). Only what means the same in every sandbox: tool shelves, and the AI accounts a turn may
38
+ // run on, by provider (`claude`) or by one provider's account. Connections and areas are each sandbox's own ids, so an
39
+ // organisation holds those through the profiles it hands out instead.
40
+ export const OrgCeilingSchema = z.object({
41
+ tools: ToolCeilingSchema.optional().describe("The most any turn's tools may be, shelf by shelf. Absent means no limit."),
42
+ aiAccounts: z
43
+ .array(AiAccountKeySchema)
44
+ .max(100)
45
+ .optional()
46
+ .describe("The AI accounts any turn may run on, a provider alone or `provider:account`. Absent means every one."),
47
+ });
48
+ export type OrgCeiling = z.infer<typeof OrgCeilingSchema>;
49
+
33
50
  // Omitted policy sections stay open. preset pins effective settings and refuses undoing writes, regardless of underlying files.
34
51
  // Unknown preset groups are skipped/reported as unenforced so newer policies still reach older daemons; the platform validates saved names.
35
52
  // membersOnly fences roster grants/removals by organisation membership, excluding the owner who is not a roster entry.
@@ -48,6 +65,14 @@ export const OrgPolicyRulesSchema = z.object({
48
65
  .boolean()
49
66
  .optional()
50
67
  .describe("Only the organisation's members may be on a bound sandbox's roster; removing someone from the organisation removes them everywhere."),
68
+ // Listed in every bound sandbox beside its own profiles, read-only there; a local profile cannot take one's id.
69
+ // Optional like the rest, so a policy stored before them hands out none.
70
+ profiles: z
71
+ .array(AccessProfileSchema)
72
+ .max(50)
73
+ .optional()
74
+ .describe("Access profiles every bound sandbox may grant, read-only there. Areas and connections they name are each sandbox's own ids."),
75
+ ceiling: OrgCeilingSchema.optional().describe("What no turn in a bound sandbox may exceed, the owner's included."),
51
76
  });
52
77
  export type OrgPolicyRules = z.infer<typeof OrgPolicyRulesSchema>;
53
78
 
@@ -6,11 +6,13 @@ import { type ModelPin, ModelPinSchema } from "./agent.js";
6
6
  import { entryId } from "./internal.js";
7
7
  import { SkillDraftSchema, SkillNameSchema, SYSTEM_PROMPT_MAX, SystemPromptModeSchema } from "./settings.js";
8
8
  // A named face the sandbox shows outward: who it speaks as, what it may do, where it works, what it's told, what it
9
- // runs on. No credential lives on the card; accounts stay private, per-sandbox. Not a security boundary for a watched
10
- // chat — a real fence only for an unattended turn, whose resolver defaults to nothing.
11
- // Enforced by absence (`connectors`/`devices`/`mcp`: no credential injected) or by removing tools from context; `shell`
12
- // decides, since with it a session can reach anything else fenced off, turning the rest into defaults, not limits.
13
- // Absent `powers` means the full toolbox.
9
+ // runs on. No credential lives on the card; accounts stay private, per-sandbox. POSTURE, NOT ACCESS
10
+ // (docs/architecture/access.md): what a turn may reach is decided by who it acts for, the people in its conversation
11
+ // or the service an unattended run acts as, each held to an access profile. A card only narrows inside that, for a
12
+ // watched chat and an unattended run alike, and never widens it.
13
+ // Narrowing is enforced by absence (`connectors`/`devices`/`mcp`: no credential injected) or by removing tools from
14
+ // context; `shell` decides, since with it a session can reach anything else fenced off, turning the rest into defaults,
15
+ // not limits. Absent `powers` means the full toolbox, inside whatever the principals allow.
14
16
  export const PersonaPowersSchema = z.object({
15
17
  // "read" is look-and-search only; "write" adds creating and changing; "none" removes both.
16
18
  files: z
@@ -208,7 +210,7 @@ export const PersonaSchema = z.object({
208
210
  .array(entryId)
209
211
  .max(50)
210
212
  .describe(
211
- "Which connected accounts are its hands. Named individually rather than by site, because two accounts on one site is the whole problem this solves. Naming one that is not connected yet is not an error: it is a card describing an account this sandbox has still to sign into.",
213
+ "Which connected accounts it speaks through. Named individually rather than by site, because two accounts on one site is the whole problem this solves. It narrows: an account here is still reached only when whoever the turn acts for may use it. Naming one that is not connected yet is not an error: it is a card describing an account this sandbox has still to sign into.",
212
214
  ),
213
215
  // Owner-written, not derived: a classifier routes better on prose than on a list of account ids. Absent, the router
214
216
  // has less to go on but still tries.
@@ -220,7 +222,7 @@ export const PersonaSchema = z.object({
220
222
  "What this persona is for, in one line. A new chat is routed onto a persona by this sentence, and the Personas page shows it under the name.",
221
223
  ),
222
224
  powers: PersonaPowersSchema.optional().describe(
223
- "What a conversation wearing it may do. Absent means the full toolbox, so a card written before this existed behaves exactly as it did.",
225
+ "What a conversation wearing it may do, inside what whoever it acts for may. Absent means the full toolbox, so a card written before this existed behaves exactly as it did.",
224
226
  ),
225
227
  workspace: PersonaWorkspaceSchema.optional().describe("Where it works. Absent means the whole workspace."),
226
228
  context: PersonaContextSchema.optional().describe(
@@ -253,10 +255,12 @@ export const personaModels = (card: Pick<Persona, "models">, sources: readonly M
253
255
  // The one stock persona id; lives here because the daemon and the automations form are separate packages that must
254
256
  // agree on it exactly, or a Visitor chat pins to a card nobody creates.
255
257
  export const VISITOR_CHAT_PERSONA = "visitor-chat";
256
- // THE TWO BUILT-IN PERSONAS. Every turn acts as somebody: a turn naming no card wears one of these, picked by whether a
257
- // person is watching (personas.ts `turnPersona` in the daemon). They are constants rather than cards in personas.json:
258
- // that file is tracked in git, and "every account" is not something a card's account list can say, since the list is
259
- // written once and accounts are connected later. Neither can be edited or removed, and no card may take either id.
258
+ // THE TWO BUILT-IN PERSONAS, postures like any card: every turn wears one, and a turn naming no card wears one of these,
259
+ // picked by whether a person is watching (personas.ts `turnPersona` in the daemon). They are constants rather than cards
260
+ // in personas.json: that file is tracked in git, and "every account" is not something a card's account list can say,
261
+ // since the list is written once and accounts are connected later. Neither can be edited or removed, and no card may
262
+ // take either id. Both stay inside what the turn's principals may (docs/architecture/access.md): "every account" is
263
+ // every account they may use.
260
264
  // Full access: every tool and every signed-in account, what a chat a person starts without picking anyone acts as.
261
265
  export const FULL_ACCESS_PERSONA = "full-access";
262
266
  // No accounts: every tool but no signed-in account, what a run nobody watches acts as when it names no one, since
@@ -0,0 +1,32 @@
1
+ import { z } from "zod";
2
+ import { entryId } from "./internal.js";
3
+
4
+ // A SERVICE: a named non-human principal unattended work acts as (docs/architecture/access.md). An automation, one of its
5
+ // sender rules, an inbound link or a control token names one in `runAs`, and every turn it starts acts for the service's
6
+ // steward, a person, narrowed by the service's access profile. An agent so never holds more than the person it acts for,
7
+ // and a steward who leaves the roster takes the reach of every service they steward with them.
8
+ // Holds no credential: a steward is an address on the roster, a profile an id.
9
+ export const ServiceSchema = z.object({
10
+ id: entryId.describe("The service's id, what `runAs` names."),
11
+ label: z.string().max(60).optional().describe("What to call it on screen, like 'Marketing bot'. Absent falls back to the id."),
12
+ brief: z.string().max(200).optional().describe("What it does, in one line."),
13
+ steward: z
14
+ .string()
15
+ .min(3)
16
+ .max(320)
17
+ .describe(
18
+ "Who it acts for, by email: the sandbox's owner or someone on its roster. Its runs reach at most what this person may, and nothing once they leave.",
19
+ ),
20
+ profile: entryId
21
+ .optional()
22
+ .describe("The access profile its runs are held to, inside what its steward may. Absent means everything its steward may."),
23
+ });
24
+ export type Service = z.infer<typeof ServiceSchema>;
25
+
26
+ export const ServicesListSchema = z.object({ services: z.array(ServiceSchema).describe("Every service unattended work here may run as.") });
27
+ export type ServicesList = z.infer<typeof ServicesListSchema>;
28
+
29
+ export const ServiceIdParamSchema = z.object({ id: entryId.describe("Which service.") });
30
+
31
+ // What a `runAs` holds: one service's id.
32
+ export const ServiceRefSchema = entryId.describe("Which service it acts as.");
@@ -1,5 +1,5 @@
1
1
  import { convertDocument } from "../documents/conversions.js";
2
- import type { ModelRole } from "../models/model-roles.js";
2
+ import { MODEL_ROLES, type ModelRole } from "../models/model-roles.js";
3
3
  import { rolePins } from "../models/model-setups.js";
4
4
  import { SETTINGS_HISTORY } from "./settings-history.js";
5
5
  import { RepoChecksFileSchema, RuleSchema, SandboxSettingsSchema, SandboxSettingsWriteSchema } from "./settings.js";
@@ -245,3 +245,25 @@ describe(`restore points' retention, renamed so a stored zero is the owner's own
245
245
  expect(read({ restorePointDays: 0, restorePointKeepDays: 5 }).retention.restorePointKeepDays).toBe(5);
246
246
  });
247
247
  });
248
+
249
+ describe(`default job setups`, () => {
250
+ test(`new settings place every job on its suggested preset`, () => {
251
+ const settings = SandboxSettingsSchema.parse({});
252
+ expect(settings.roleSetups).toEqual(Object.fromEntries(MODEL_ROLES.map((role) => [role.id, role.setup])));
253
+ expect(settings.roleSetups[`commit-message`]).toBe(`low`);
254
+ expect(settings.roleSetups[`safety-judge`]).toBe(`medium`);
255
+ expect(settings.roleSetups[`pipeline-fix`]).toBe(`high`);
256
+ const sources = [{ provider: `claude`, ready: true, models: [`claude-haiku-4-5`, `claude-sonnet-5`, `claude-opus-5`] }] as const;
257
+ expect(rolePins(settings, `commit-message`, sources)).toEqual([{ provider: `claude`, model: `claude-haiku-4-5` }]);
258
+ expect(rolePins(settings, `safety-judge`, sources)).toEqual([{ provider: `claude`, model: `claude-sonnet-5` }]);
259
+ expect(rolePins(settings, `pipeline-fix`, sources)).toEqual([{ provider: `claude`, model: `claude-opus-5` }]);
260
+ expect(rolePins(settings, `pipeline-fix`, [])).toEqual([]);
261
+ });
262
+
263
+ test(`saved assignments keep their choices and jobs left off`, () => {
264
+ expect(SandboxSettingsSchema.parse({ roleSetups: {} }).roleSetups).toEqual({});
265
+ expect(SandboxSettingsSchema.parse({ roleSetups: { "commit-message": `high` } }).roleSetups).toEqual({ "commit-message": `high` });
266
+ const saved = SandboxSettingsSchema.parse({ roleSetups: {} });
267
+ expect(SandboxSettingsWriteSchema.parse({ ...saved, commandJudge: `watch` }).roleSetups).toEqual({});
268
+ });
269
+ });
@@ -2,7 +2,7 @@
2
2
  import { z } from "zod";
3
3
  import { claudeExperimentSettings, iqSearchSettings } from "./settings-experiments.js";
4
4
  import { CommandJudgeModeSchema, ProjectInstallModeSchema } from "../policy/safety-policy.js";
5
- import { ModelRoleSchema } from "../models/model-roles.js";
5
+ import { MODEL_ROLES, ModelRoleSchema } from "../models/model-roles.js";
6
6
  import { MODEL_SETUP_ID, ModelSetupSchema } from "../models/model-setups.js";
7
7
  import { AdmissionPolicySchema, AdmissionRuleSchema } from "./command-admission.js";
8
8
  import { KeepWarmSettingsSchema } from "./keep-warm.js";
@@ -383,12 +383,13 @@ export const SandboxSettingsSchema = z.object({
383
383
  "The model setups jobs run on: Low, Medium and High, which every sandbox has, and any you make. Each is an ordered list of models, tried in order so one spent account does not take its jobs down. A preset left out of this list, or listed without models, is worked out from the accounts you have connected. A setup runs only the jobs put on it (`roleSetups`).",
384
384
  ),
385
385
  // `partialRecord`, not `record`: an exhaustive one would force every settings file to list every role, and adding
386
- // one would invalidate them all. Absent IS "on no setup": nothing runs a job nobody placed.
386
+ // one would invalidate them all. A fresh sandbox places every job on its suggested preset; an explicit
387
+ // map stays as written, including an empty one or a job removed from it.
387
388
  roleSetups: z
388
389
  .partialRecord(ModelRoleSchema, z.string().regex(MODEL_SETUP_ID))
389
- .default({})
390
+ .default(() => Object.fromEntries(MODEL_ROLES.map((role) => [role.id, role.setup])))
390
391
  .describe(
391
- "Which setup each job runs on: commit messages, session titles, the safety judge, pipeline fixes and every other place this sandbox picks a model for you. Nothing is chosen for you: a job left out, or on a setup with no models, has none, so a one-shot job does not run and a whole session opens on whatever your own chat is set to.",
392
+ "Which setup each job runs on: commit messages, session titles, the safety judge, pipeline fixes and every other place this sandbox picks a model for you. Defaults to each job’s suggested Low, Medium or High setup. In a saved map, a job left out, or on a setup with no models, has none, so a one-shot job does not run and a whole session opens on whatever your own chat is set to.",
392
393
  ),
393
394
  // Folded into the router's prompt (agent/prompt/chat-router.ts), never into a turn's own. Capped small on
394
395
  // purpose: the reading runs under a 5s deadline, and this text is paid for on every chat that opens on Auto.