@intentic/sandbox-contract 1.393.0 → 1.395.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 (259) hide show
  1. package/README.md +26 -0
  2. package/dist/app-routes/app-pages.d.ts +97 -0
  3. package/dist/app-routes/app-pages.d.ts.map +1 -0
  4. package/dist/app-routes/app-pages.js +71 -0
  5. package/dist/app-routes/app-pages.js.map +1 -0
  6. package/dist/app-routes/index.d.ts +5 -0
  7. package/dist/app-routes/index.d.ts.map +1 -0
  8. package/dist/app-routes/index.js +5 -0
  9. package/dist/app-routes/index.js.map +1 -0
  10. package/dist/app-routes/legacy.d.ts +10 -0
  11. package/dist/app-routes/legacy.d.ts.map +1 -0
  12. package/dist/app-routes/legacy.js +92 -0
  13. package/dist/app-routes/legacy.js.map +1 -0
  14. package/dist/app-routes/paths.d.ts +38 -0
  15. package/dist/app-routes/paths.d.ts.map +1 -0
  16. package/dist/app-routes/paths.js +89 -0
  17. package/dist/app-routes/paths.js.map +1 -0
  18. package/dist/app-routes/patterns.d.ts +5 -0
  19. package/dist/app-routes/patterns.d.ts.map +1 -0
  20. package/dist/app-routes/patterns.js +94 -0
  21. package/dist/app-routes/patterns.js.map +1 -0
  22. package/dist/chores/stack.d.ts.map +1 -1
  23. package/dist/chores/stack.js +13 -2
  24. package/dist/chores/stack.js.map +1 -1
  25. package/dist/contracts/agent.contract.d.ts +115 -0
  26. package/dist/contracts/agent.contract.d.ts.map +1 -1
  27. package/dist/contracts/agents.contract.d.ts +1300 -11
  28. package/dist/contracts/agents.contract.d.ts.map +1 -1
  29. package/dist/contracts/agents.contract.js +11 -1
  30. package/dist/contracts/agents.contract.js.map +1 -1
  31. package/dist/contracts/capabilities.contract.d.ts +8 -0
  32. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  33. package/dist/contracts/endpoints.contract.d.ts +45 -0
  34. package/dist/contracts/endpoints.contract.d.ts.map +1 -1
  35. package/dist/contracts/endpoints.contract.js +9 -0
  36. package/dist/contracts/endpoints.contract.js.map +1 -1
  37. package/dist/contracts/git.contract.d.ts +5 -0
  38. package/dist/contracts/git.contract.d.ts.map +1 -1
  39. package/dist/contracts/org.contract.d.ts +8 -0
  40. package/dist/contracts/org.contract.d.ts.map +1 -1
  41. package/dist/contracts/runner.contract.d.ts +87 -0
  42. package/dist/contracts/runner.contract.d.ts.map +1 -1
  43. package/dist/contracts/seal.contract.d.ts +2760 -0
  44. package/dist/contracts/seal.contract.d.ts.map +1 -0
  45. package/dist/contracts/seal.contract.js +95 -0
  46. package/dist/contracts/seal.contract.js.map +1 -0
  47. package/dist/contracts/sessions.contract.d.ts +16 -0
  48. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  49. package/dist/contracts/settings.contract.d.ts +97 -2
  50. package/dist/contracts/settings.contract.d.ts.map +1 -1
  51. package/dist/contracts/settings.contract.js +21 -3
  52. package/dist/contracts/settings.contract.js.map +1 -1
  53. package/dist/contracts/system.contract.d.ts +422 -194
  54. package/dist/contracts/system.contract.d.ts.map +1 -1
  55. package/dist/contracts/system.contract.js +11 -2
  56. package/dist/contracts/system.contract.js.map +1 -1
  57. package/dist/contracts/webext.contract.d.ts +4 -0
  58. package/dist/contracts/webext.contract.d.ts.map +1 -1
  59. package/dist/contracts/workspace.contract.d.ts +6 -0
  60. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  61. package/dist/contracts/workspace.contract.js +11 -1
  62. package/dist/contracts/workspace.contract.js.map +1 -1
  63. package/dist/events/agent-events.d.ts +80 -1
  64. package/dist/events/agent-events.d.ts.map +1 -1
  65. package/dist/events/agent-events.js +16 -0
  66. package/dist/events/agent-events.js.map +1 -1
  67. package/dist/events/agent-transcript.d.ts +16 -0
  68. package/dist/events/agent-transcript.d.ts.map +1 -1
  69. package/dist/events/requests.d.ts +2 -0
  70. package/dist/events/requests.d.ts.map +1 -1
  71. package/dist/events/requests.js +4 -0
  72. package/dist/events/requests.js.map +1 -1
  73. package/dist/events/system-events.d.ts +292 -62
  74. package/dist/events/system-events.d.ts.map +1 -1
  75. package/dist/events/system-events.js +3 -0
  76. package/dist/events/system-events.js.map +1 -1
  77. package/dist/events/transcript.d.ts +96 -0
  78. package/dist/events/transcript.d.ts.map +1 -1
  79. package/dist/events/transcript.js +7 -1
  80. package/dist/events/transcript.js.map +1 -1
  81. package/dist/ids/row-ids.d.ts.map +1 -1
  82. package/dist/ids/row-ids.js +7 -2
  83. package/dist/ids/row-ids.js.map +1 -1
  84. package/dist/index.d.ts +107 -34467
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +7 -3
  87. package/dist/index.js.map +1 -1
  88. package/dist/models/model-roles.d.ts +8 -0
  89. package/dist/models/model-roles.d.ts.map +1 -1
  90. package/dist/models/model-roles.js +8 -0
  91. package/dist/models/model-roles.js.map +1 -1
  92. package/dist/policy/org-locks.d.ts +1 -1
  93. package/dist/policy/org-locks.d.ts.map +1 -1
  94. package/dist/policy/org-locks.js +9 -1
  95. package/dist/policy/org-locks.js.map +1 -1
  96. package/dist/policy/request-status.d.ts.map +1 -1
  97. package/dist/policy/request-status.js +26 -10
  98. package/dist/policy/request-status.js.map +1 -1
  99. package/dist/protocol/raw/raw-json-routes.d.ts +6 -0
  100. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  101. package/dist/protocol/routes.d.ts +6 -0
  102. package/dist/protocol/routes.d.ts.map +1 -1
  103. package/dist/protocol/routes.js +64 -8
  104. package/dist/protocol/routes.js.map +1 -1
  105. package/dist/protocol/sse.d.ts.map +1 -1
  106. package/dist/protocol/sse.js +5 -1
  107. package/dist/protocol/sse.js.map +1 -1
  108. package/dist/schemas/agent-land.d.ts +78 -0
  109. package/dist/schemas/agent-land.d.ts.map +1 -0
  110. package/dist/schemas/agent-land.js +47 -0
  111. package/dist/schemas/agent-land.js.map +1 -0
  112. package/dist/schemas/agent.d.ts +4 -0
  113. package/dist/schemas/agent.d.ts.map +1 -1
  114. package/dist/schemas/agent.js +1 -0
  115. package/dist/schemas/agent.js.map +1 -1
  116. package/dist/schemas/agents-list.d.ts +130 -0
  117. package/dist/schemas/agents-list.d.ts.map +1 -1
  118. package/dist/schemas/agents.d.ts +196 -76
  119. package/dist/schemas/agents.d.ts.map +1 -1
  120. package/dist/schemas/agents.js +5 -46
  121. package/dist/schemas/agents.js.map +1 -1
  122. package/dist/schemas/capabilities.d.ts +4 -0
  123. package/dist/schemas/capabilities.d.ts.map +1 -1
  124. package/dist/schemas/commit-attribution.d.ts +41 -0
  125. package/dist/schemas/commit-attribution.d.ts.map +1 -0
  126. package/dist/schemas/commit-attribution.js +16 -0
  127. package/dist/schemas/commit-attribution.js.map +1 -0
  128. package/dist/schemas/composer-drafts.d.ts +19 -0
  129. package/dist/schemas/composer-drafts.d.ts.map +1 -1
  130. package/dist/schemas/composer-drafts.js +10 -0
  131. package/dist/schemas/composer-drafts.js.map +1 -1
  132. package/dist/schemas/environment.d.ts +12 -0
  133. package/dist/schemas/environment.d.ts.map +1 -1
  134. package/dist/schemas/environment.js +1 -0
  135. package/dist/schemas/environment.js.map +1 -1
  136. package/dist/schemas/git/git-history.d.ts +10 -0
  137. package/dist/schemas/git/git-history.d.ts.map +1 -1
  138. package/dist/schemas/git/git-history.js +8 -0
  139. package/dist/schemas/git/git-history.js.map +1 -1
  140. package/dist/schemas/gpu-settings.d.ts +15 -0
  141. package/dist/schemas/gpu-settings.d.ts.map +1 -0
  142. package/dist/schemas/gpu-settings.js +18 -0
  143. package/dist/schemas/gpu-settings.js.map +1 -0
  144. package/dist/schemas/metrics.d.ts +39 -2
  145. package/dist/schemas/metrics.d.ts.map +1 -1
  146. package/dist/schemas/metrics.js +40 -1
  147. package/dist/schemas/metrics.js.map +1 -1
  148. package/dist/schemas/night-hours.d.ts +31 -0
  149. package/dist/schemas/night-hours.d.ts.map +1 -0
  150. package/dist/schemas/night-hours.js +33 -0
  151. package/dist/schemas/night-hours.js.map +1 -0
  152. package/dist/schemas/organisation.d.ts +33 -0
  153. package/dist/schemas/organisation.d.ts.map +1 -1
  154. package/dist/schemas/organisation.js +9 -0
  155. package/dist/schemas/organisation.js.map +1 -1
  156. package/dist/schemas/privacy.d.ts +1 -0
  157. package/dist/schemas/privacy.d.ts.map +1 -1
  158. package/dist/schemas/privacy.js +1 -0
  159. package/dist/schemas/privacy.js.map +1 -1
  160. package/dist/schemas/providers/plan-limits.d.ts +16 -0
  161. package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
  162. package/dist/schemas/providers/plan-limits.js +3 -0
  163. package/dist/schemas/providers/plan-limits.js.map +1 -1
  164. package/dist/schemas/sandbox-mode.d.ts +20 -0
  165. package/dist/schemas/sandbox-mode.d.ts.map +1 -0
  166. package/dist/schemas/sandbox-mode.js +54 -0
  167. package/dist/schemas/sandbox-mode.js.map +1 -0
  168. package/dist/schemas/seal-proof.d.ts +20 -0
  169. package/dist/schemas/seal-proof.d.ts.map +1 -0
  170. package/dist/schemas/seal-proof.js +8 -0
  171. package/dist/schemas/seal-proof.js.map +1 -0
  172. package/dist/schemas/seal.d.ts +235 -0
  173. package/dist/schemas/seal.d.ts.map +1 -0
  174. package/dist/schemas/seal.js +97 -0
  175. package/dist/schemas/seal.js.map +1 -0
  176. package/dist/schemas/settings-experiments.d.ts.map +1 -1
  177. package/dist/schemas/settings-experiments.js +1 -1
  178. package/dist/schemas/settings-experiments.js.map +1 -1
  179. package/dist/schemas/settings-history.d.ts +2 -2
  180. package/dist/schemas/settings.d.ts +67 -15
  181. package/dist/schemas/settings.d.ts.map +1 -1
  182. package/dist/schemas/settings.js +45 -27
  183. package/dist/schemas/settings.js.map +1 -1
  184. package/dist/schemas/webext.d.ts +9 -0
  185. package/dist/schemas/webext.d.ts.map +1 -1
  186. package/dist/schemas/webext.js +2 -0
  187. package/dist/schemas/webext.js.map +1 -1
  188. package/dist/schemas/workspace/workspace-tree.d.ts +8 -0
  189. package/dist/schemas/workspace/workspace-tree.d.ts.map +1 -1
  190. package/dist/schemas/workspace/workspace-tree.js +16 -0
  191. package/dist/schemas/workspace/workspace-tree.js.map +1 -1
  192. package/dist/state/definition.d.ts +64 -8
  193. package/dist/state/definition.d.ts.map +1 -1
  194. package/dist/text/mentions.d.ts.map +1 -1
  195. package/dist/text/mentions.js +8 -1
  196. package/dist/text/mentions.js.map +1 -1
  197. package/dist/text/pages.d.ts.map +1 -1
  198. package/dist/text/pages.js +5 -2
  199. package/dist/text/pages.js.map +1 -1
  200. package/dist/text/transcript-fold.d.ts.map +1 -1
  201. package/dist/text/transcript-fold.js +1 -0
  202. package/dist/text/transcript-fold.js.map +1 -1
  203. package/package.json +16 -5
  204. package/src/app-routes/app-pages.ts +148 -0
  205. package/src/app-routes/app-routes.test.ts +183 -0
  206. package/src/app-routes/index.ts +6 -0
  207. package/src/app-routes/legacy.ts +144 -0
  208. package/src/app-routes/paths.ts +160 -0
  209. package/src/app-routes/patterns.ts +145 -0
  210. package/src/chores/stack.ts +14 -2
  211. package/src/contracts/agents.contract.ts +15 -1
  212. package/src/contracts/endpoints.contract.ts +12 -0
  213. package/src/contracts/seal.contract.ts +117 -0
  214. package/src/contracts/settings.contract.ts +30 -6
  215. package/src/contracts/system.contract.ts +21 -2
  216. package/src/contracts/workspace.contract.ts +16 -0
  217. package/src/events/agent-events.ts +20 -0
  218. package/src/events/requests.ts +8 -0
  219. package/src/events/system-events.ts +39 -4
  220. package/src/events/transcript.ts +9 -1
  221. package/src/ids/row-ids.test.ts +31 -0
  222. package/src/ids/row-ids.ts +10 -2
  223. package/src/index.ts +65 -5
  224. package/src/models/model-roles.ts +10 -0
  225. package/src/policy/org-locks.ts +9 -1
  226. package/src/policy/request-status.ts +38 -10
  227. package/src/protocol/routes.test.ts +75 -2
  228. package/src/protocol/routes.ts +119 -11
  229. package/src/protocol/sse.ts +6 -1
  230. package/src/schemas/agent-land.ts +98 -0
  231. package/src/schemas/agent.ts +3 -0
  232. package/src/schemas/agents.ts +6 -94
  233. package/src/schemas/capabilities.ts +1 -1
  234. package/src/schemas/commit-attribution.ts +38 -0
  235. package/src/schemas/composer-drafts.ts +17 -0
  236. package/src/schemas/environment.ts +4 -0
  237. package/src/schemas/git/git-history.ts +10 -0
  238. package/src/schemas/gpu-settings.ts +31 -0
  239. package/src/schemas/metrics.ts +83 -4
  240. package/src/schemas/night-hours.test.ts +54 -0
  241. package/src/schemas/night-hours.ts +70 -0
  242. package/src/schemas/organisation.ts +15 -0
  243. package/src/schemas/privacy.test.ts +8 -1
  244. package/src/schemas/privacy.ts +10 -1
  245. package/src/schemas/providers/plan-limits.ts +5 -0
  246. package/src/schemas/sandbox-mode.test.ts +68 -0
  247. package/src/schemas/sandbox-mode.ts +93 -0
  248. package/src/schemas/seal-proof.ts +12 -0
  249. package/src/schemas/seal.ts +175 -0
  250. package/src/schemas/settings-experiments.ts +3 -1
  251. package/src/schemas/settings.test.ts +16 -0
  252. package/src/schemas/settings.ts +97 -48
  253. package/src/schemas/webext.ts +8 -0
  254. package/src/schemas/workspace/workspace-tree.ts +23 -0
  255. package/src/state/daemon-floor.test.ts +1 -0
  256. package/src/text/mentions.ts +10 -1
  257. package/src/text/pages.test.ts +1 -0
  258. package/src/text/pages.ts +10 -2
  259. package/src/text/transcript-fold.ts +1 -0
@@ -15,6 +15,8 @@ import { EMOJI_MAX_LENGTH, isSingleEmoji } from "../text/emoji.js";
15
15
  import { ProgramAskSchema } from "../events/requests.js";
16
16
  import { ReviewTallySchema, TurnProofSchema } from "./work-assurance.js";
17
17
  import { AgentReactionSchema, SessionOwnerSchema } from "./agent-people.js";
18
+ import { SEAL_VIEW_DESCRIPTION, SealViewSchema } from "./seal.js";
19
+ import { LandConflictReasonSchema } from "./agent-land.js";
18
20
  export { AgentReactionSchema, ReactorSchema, SessionOwnerSchema, type AgentReaction, type Reactor, type SessionOwner } from "./agent-people.js";
19
21
  // A fleet agent is any conversation with a registry entry, keyed by conversationId. Isolated ones own a git worktree
20
22
  // (branch agent/<id>); workspace conversations have none, but both share one status/activity/cost lifecycle.
@@ -231,14 +233,6 @@ export const LandedMessageDraftSchema = z.object({
231
233
  finishedAt: z.number().optional().describe("When it ended, in milliseconds."),
232
234
  });
233
235
  export type LandedMessageDraft = z.infer<typeof LandedMessageDraftSchema>;
234
- // Why a path would not land:
235
- // workspace: your own uncommitted edits are on that path
236
- // diverged: the main tree's committed content moved under the agent since it branched; nothing of yours is at risk
237
- // binary: git cannot three-way merge the file at all
238
- // Declared here rather than beside the conflict report below, since the roster carries the causes too: a card cannot
239
- // offer the press that clears a refusal without knowing whose refusal it is.
240
- export const LandConflictReasonSchema = z.enum(["workspace", "diverged", "binary"]);
241
- export type LandConflictReason = z.infer<typeof LandConflictReasonSchema>;
242
236
  // One land of a home conversation's, as committed: the land its transcript row names, and each repository's commit.
243
237
  export const HomeCommitSchema = z.object({
244
238
  land: z.string().describe("The land's id, as its `landed` transcript row names it."),
@@ -402,13 +396,15 @@ export const AgentSummarySchema = z.object({
402
396
  ),
403
397
  // Latched by the opening compose (placement.branches): the repositories it works on a branch of, which its land commits onto.
404
398
  branches: z.array(RepoBranchSchema).optional().describe(FROM_BRANCHES_DESCRIPTION),
399
+ // Decides who may read the row at all (auth/fleet-scope.ts visibleTo); a caller who may not gets a sealed card.
400
+ seal: SealViewSchema.optional().describe(SEAL_VIEW_DESCRIPTION),
405
401
  // Latched on the opening turn (ids/conversation-ids.ts homeConversationId). Rides the summary because it decides who
406
402
  // may see the row at all (auth/fleet-scope.ts visibleTo): its owner, and the sandbox's owner.
407
403
  home: z
408
404
  .literal(true)
409
405
  .optional()
410
406
  .describe(
411
- "This is its owner's home conversation in this sandbox: the one long-running chat the master view opens, which orchestrates its own subagents, holds their work until it accepts it, and lands and commits by itself. Only its owner and the sandbox's owner see it. Absent for every other conversation.",
407
+ "This is its owner's home conversation in this sandbox: the one long-running chat the master view opens, which orchestrates its own subagents, holds their work until it accepts it, and lands and commits by itself. Only its owner and the sandbox's owner see it, and under a house rule that lets conversations be private only its owner reads it. Absent for every other conversation.",
412
408
  ),
413
409
  // A home's own record of what its lands became in history (conversations/land/version-landed.ts): each land's commit,
414
410
  // under the land id its transcript row names (`landed` notice), so the chat can say what was committed and offer its
@@ -908,88 +904,4 @@ export const AgentFileDiffQuerySchema = z.object({
908
904
  repo: z.string().min(1).describe("Which repository."),
909
905
  path: z.string().min(1).describe("Which file, relative to that repository."),
910
906
  });
911
- export const LandConflictPathSchema = z.object({
912
- path: z.string().describe("Which file."),
913
- reason: LandConflictReasonSchema.describe(
914
- "Why it would not merge, and the three have nothing in common but the symptom. Your own uncommitted edits on that path, where yours is the copy at risk. The shared tree having moved under the conversation since it started, where nothing of yours is at risk. Or a file git cannot merge at all, where no automatic answer exists.",
915
- ),
916
- });
917
- // `paths` are files that genuinely failed to apply, not the whole delta; empty `paths` with `clean: 0` means the repo
918
- // itself was unreachable.
919
- export const LandConflictSchema = z.object({
920
- repo: z.string().describe("Which repository."),
921
- paths: z
922
- .array(LandConflictPathSchema)
923
- .describe(
924
- "The files that genuinely would not apply. Not the whole change: reporting everything whenever the cause could not be pinned down turned four real conflicts into a wall of fourteen.",
925
- ),
926
- clean: z
927
- .number()
928
- .describe(
929
- "How many files in this repository passed but remain held with the refused composition. Zero alongside an empty list means the repository could not be reached at all.",
930
- ),
931
- // The branch to rebase onto; carried since an isolated turn's worktree hides it from the agent's own view.
932
- mainBranch: z
933
- .string()
934
- .optional()
935
- .describe(
936
- "The branch your own checkout is on, which is what the conversation has to rebase onto. Carried because only the sandbox can see it. Absent where there is no name to give.",
937
- ),
938
- });
939
- export type LandConflict = z.infer<typeof LandConflictSchema>;
940
- // Land's outcome for the whole composed change: the ordinary mode preflights every repo, all-or-nothing, so a refusal
941
- // leaves the tree untouched. `resolving` only appears for a `merge` land, whose conflict markers the user finishes by
942
- // hand.
943
- export const LandResultSchema = z.object({
944
- landed: z.boolean().describe("Whether the entire composed change was applied."),
945
- // Merged and nothing moved is the one outcome with nothing to show for itself; without this the caller cannot tell
946
- // it from a merge that carried work, and a press that did nothing looked exactly like a press that worked.
947
- changed: z
948
- .boolean()
949
- .describe(
950
- "Whether anything actually moved. False alongside merged means there was nothing on the branch to apply: the work is already in your tree, or the branch never carried any.",
951
- ),
952
- conflicts: z.array(LandConflictSchema).optional().describe("What stopped the whole composed change, grouped per repository."),
953
- resolving: z
954
- .array(
955
- z.object({
956
- repo: z.string().describe("Which repository."),
957
- paths: z.array(z.string()).describe("Which files now hold conflict markers to sort out by hand."),
958
- }),
959
- )
960
- .optional()
961
- .describe("Files left half-merged when you asked to carry the whole composition with its conflicts marked for resolution."),
962
- // A `measure` outcome with work still on the branch; `landed: false` alone can't say that, since alone it means
963
- // refusal.
964
- held: z
965
- .boolean()
966
- .optional()
967
- .describe(
968
- "Nothing was applied and nothing failed: there is work waiting on the branch for a deliberate merge. Not merged on its own cannot say that, because on its own it means refused.",
969
- ),
970
- });
971
- export type LandResult = z.infer<typeof LandResultSchema>;
972
- // check: safe default, preflights every repo and applies only if all of it does, so a refusal leaves the tree
973
- // byte-identical
974
- // merge: opt-in escape hatch; three-way applies the whole composition, leaving conflict markers to resolve in place
975
- // measure: does everything but touch the main trees, so a held agent's card stays current while its delta waits
976
- export const LandModeSchema = z.enum(["check", "merge", "measure"]);
977
- export type LandMode = z.infer<typeof LandModeSchema>;
978
- // outstanding: only what hasn't landed yet, from the last landed tip (the default; what a second land applies)
979
- // cumulative: the agent's whole output from where its branch left main; what the review lists and what "Land again"
980
- // applies. Not a double application: it's the way back when landed work was discarded from the tree, since paths
981
- // already there drop out per file.
982
- export const AgentSpanSchema = z.enum(["cumulative", "outstanding"]);
983
- export type AgentSpan = z.infer<typeof AgentSpanSchema>;
984
- // Overrides the guard against landing mid-turn; safe since a land arrives as uncommitted changes the user reviews, and
985
- // the rest of the turn lands on top of it later. Doesn't apply to a turn parked on a question, which needs no override
986
- // at all.
987
- export const AgentLandSchema = z.object({
988
- includeDocuments: z.boolean().optional().describe("Include recorded result documents, even when ignored or classified as scratch."),
989
- id: z.string().min(1).describe("Which conversation's work to merge."),
990
- mode: LandModeSchema.optional().describe(
991
- "How to apply it. The default applies every repository or none, so a refusal leaves the workspace exactly as it was. The other carries the whole composition and leaves conflicted paths with markers to resolve by hand.",
992
- ),
993
- span: AgentSpanSchema.optional().describe("How much of the work to take. Leave it out for everything not yet merged."),
994
- force: z.boolean().optional().describe("Go ahead despite a check that would otherwise refuse."),
995
- });
907
+ export { LandConflictReasonSchema, type LandConflictReason, LandConflictPathSchema, LandConflictSchema, type LandConflict, LandResultSchema, type LandResult, LandModeSchema, type LandMode, AgentSpanSchema, type AgentSpan, AgentLandSchema } from "./agent-land.js";
@@ -285,7 +285,7 @@ export const LOCAL_MODEL_WINDOW_MAX = 1_048_576;
285
285
  // rather than down: over-reserving costs a rung, under-reserving costs an allocation failure a card had promised
286
286
  // against.
287
287
  export const LOCAL_MODEL_KV_BYTES_PER_TOKEN = 65_536;
288
- // What a rung honestly serves. `instant` is the one the connect view prefetches — it downloads in under a minute and
288
+ // What a rung honestly serves. `instant` is the small one the connect view offers first — it downloads in under a minute and
289
289
  // cannot drive a full agent turn, so its catalog row is helper-only (Model.helperOnly): the chat picker does not offer
290
290
  // it and the daemon refuses a turn on it. `work` is what that view recommends for real use.
291
291
  export type LocalModelTier = "instant" | "work";
@@ -0,0 +1,38 @@
1
+ import { z } from "zod";
2
+
3
+ // WHO A COMMIT NAMES (2026-11-04). Every commit the daemon makes was `intentic <agent@intentic.dev>`, so nobody could
4
+ // trace work to the person who asked for it. Each value says how much of that person goes into history, and the
5
+ // default keeps every address out of git until the owner chooses, since a pushed commit publishes it for good:
6
+ // `person` makes them the author (intentic stays the committer), `trailer` keeps intentic the author and adds a
7
+ // `Co-authored-by:` line for them, `intentic` names nobody. A person is named only by the commit address they set
8
+ // themselves (`settings.commitIdentity`), never by their sign-in address. Read where commits are made
9
+ // (git/attribution/commit-attribution.ts) and in every agent's shell (agent/run/harness/turn-env.ts).
10
+ export const CommitAttributionSchema = z.enum(["person", "trailer", "intentic"]);
11
+ export type CommitAttribution = z.infer<typeof CommitAttributionSchema>;
12
+
13
+ // A name and address as a commit carries them.
14
+ export const GitPersonSchema = z.object({
15
+ name: z.string().trim().min(1).max(120).describe("The name a commit shows, such as Ada Lovelace."),
16
+ email: z.string().trim().email().max(254).describe("The address a commit shows. Pushed commits publish it; a provider's noreply address keeps yours private."),
17
+ });
18
+ export type GitPerson = z.infer<typeof GitPersonSchema>;
19
+
20
+ // The sandbox setting itself, declared here so settings.ts carries one line for it.
21
+ export const commitAttributionSetting = CommitAttributionSchema.default("trailer").describe(
22
+ "How commits made here name the person behind them. `person`: they are the commit's author and intentic its committer. `trailer` (the default): intentic stays the author and a Co-authored-by line names them. `intentic`: commits name nobody. Either way a person is named only by the commit name and address they set themselves, never by the address they sign in with; until they set one, their commits name nobody.",
23
+ );
24
+
25
+ // The caller's own commit name and address on this sandbox, and what it would name them as when they have none: the
26
+ // connected git account's identity for the sandbox's owner (its noreply address when the account keeps its email
27
+ // private), nothing for anyone else. A suggestion is never used until they save it.
28
+ export const CommitIdentityStateSchema = z.object({
29
+ identity: GitPersonSchema.optional().describe("The name and address your commits here carry. Absent until you set one, and until then your commits name nobody."),
30
+ suggested: GitPersonSchema.optional().describe("What to offer you before you have set one: the connected git account's name and commit address, for the sandbox's owner. Never used until saved."),
31
+ attribution: CommitAttributionSchema.describe("How this sandbox's commits use it (settings.commitAttribution)."),
32
+ });
33
+ export type CommitIdentityState = z.infer<typeof CommitIdentityStateSchema>;
34
+
35
+ export const CommitIdentityAnswerSchema = z.object({
36
+ identity: GitPersonSchema.nullable().describe("The name and address your commits here carry; null forgets yours, and your commits name nobody again."),
37
+ });
38
+ export type CommitIdentityAnswer = z.infer<typeof CommitIdentityAnswerSchema>;
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { ATTACHMENT_LIMIT, ConversationIdSchema, ForkOfSchema, FreshOfSchema, QueuedServingSchema } from "./agent.js";
3
+ import { AgentReactionSchema } from "./agent-people.js";
3
4
 
4
5
  // A PERSON'S UNSENT WORDS FOR ONE CONVERSATION, held by the sandbox. Until 2026-10-20 a composer's words lived only in the
5
6
  // browser: in each window's tab snapshot, moved into a per-browser "closed drafts" set when the tab closed and back out
@@ -47,6 +48,12 @@ export const ComposerDraftsSchema = z.object({
47
48
  .describe(
48
49
  "The newest revision handed out when this list was read. A draft you hold at a revision past it was written after the read, so its absence here says nothing about it.",
49
50
  ),
51
+ reactions: z
52
+ .record(z.string(), z.array(AgentReactionSchema))
53
+ .optional()
54
+ .describe(
55
+ "Your marks on conversations no turn has started yet (`agents.reactDraft`), by conversation, each mark wearing only you. Kept apart from the words: a conversation may carry marks with no draft at all. Absent from a sandbox that keeps none.",
56
+ ),
50
57
  });
51
58
  export type ComposerDrafts = z.infer<typeof ComposerDraftsSchema>;
52
59
 
@@ -84,3 +91,13 @@ export const DraftClearSchema = z.object({
84
91
  .describe("Clear it only while it is still this revision, so words written since in another window survive. Leave it out to clear whatever is there."),
85
92
  });
86
93
  export type DraftClear = z.infer<typeof DraftClearSchema>;
94
+
95
+ // A MARK ON A CONVERSATION NOBODY HAS STARTED YET. The registry keeps a conversation's reactions (`agents.react`), and has
96
+ // no entry until the first turn, so until then the sandbox keeps the person's marks beside their draft: private as the
97
+ // draft is, never touched by a write or a clear of the words, and moved onto the conversation's own card by its first turn.
98
+ export const DraftReactionsSchema = z.object({
99
+ reactions: z
100
+ .array(AgentReactionSchema)
101
+ .describe("Your marks on the conversation as they now stand, one entry per emoji in the order you first used them, each wearing only you. Empty once you have taken back the last one."),
102
+ });
103
+ export type DraftReactions = z.infer<typeof DraftReactionsSchema>;
@@ -200,6 +200,10 @@ export const EnvironmentItemSchema = z.object({
200
200
  origin: z.enum(["custom", "capability", "base"]),
201
201
  // Which capability/extension/pack pulled it in, for an origin the reader did not choose item by item.
202
202
  originLabel: z.string().optional(),
203
+ // What kind of thing pulled a capability row in, so the reader is sent to the place that turns it off: a connected
204
+ // capability, a workspace extension, a connected AI account's runtime, or the privacy shield's readers (which no
205
+ // capability card holds). Absent on custom and base rows, and from a sandbox older than the distinction.
206
+ source: z.enum(["capability", "extension", "provider", "privacy"]).optional(),
203
207
  // Observed, not inferred:
204
208
  // active: the probe found it.
205
209
  // after-rebuild: the recipe has it, the container does not yet.
@@ -22,6 +22,16 @@ export const GitCommitSchema = z.object({
22
22
  at: z.number().describe("When they wrote it, in milliseconds."),
23
23
  refs: z.array(z.string()).describe("Branches and tags sitting on it."),
24
24
  head: z.boolean().describe("Whether this is where the repository currently stands."),
25
+ // Resolved by the sandbox from the commit's Conversation-Id trailer, so history says who asked for agent work even
26
+ // where the commit itself names nobody (settings.commitAttribution).
27
+ requestedBy: z
28
+ .object({
29
+ conversation: z.string().describe("The conversation the commit came from, by its Conversation-Id trailer."),
30
+ name: z.string().optional().describe("What to call the person who answers for that conversation."),
31
+ email: z.string().optional().describe("Their sign-in address. Absent when nobody answers for it, such as one an automation opened."),
32
+ })
33
+ .optional()
34
+ .describe("Who the work in this commit was done for, read from its Conversation-Id trailer. Absent on a commit that names no conversation."),
25
35
  });
26
36
  export type GitCommit = z.infer<typeof GitCommitSchema>;
27
37
  // One repo's log: commits newest-first across all refs, not just the checked-out branch, since branch topology is the
@@ -0,0 +1,31 @@
1
+ // The host GPU settings, apart from settings.ts for its size; settings.ts re-exports them for every reader.
2
+ import { z } from "zod";
3
+
4
+ /* THE HOST GPU, FOR A SANDBOX WHOSE GPU SWITCH IS ON (2026-11-03). On a Windows PC that GPU is the owner's display GPU,
5
+ shared through WSL (/dev/dxg). Until 2026-11-03 the engine put its driver libraries on every process's library path,
6
+ so 65 conversations' browsers and shells rendered on it unasked, and one GPU hang powered rog off. Now nothing uses it
7
+ unless asked: `gpu-run <command>` runs one command with it (bin/gpu-run), and `shells: "all"` gives it to every
8
+ command an agent runs. Read by the daemon (gpu/gpu-state.ts), which hands gpu-run what it needs in a state file. */
9
+ export const GpuShellsSchema = z.enum(["on-request", "all"]);
10
+ export const GpuSettingsSchema = z.object({
11
+ shells: GpuShellsSchema.default("on-request").describe(
12
+ "Which of an agent's commands may use this sandbox's GPU. `on-request` (the default): only a command run through `gpu-run`, so a browser, a test run or a build never lands on your display GPU by accident. `all`: every command an agent runs, as if each one went through gpu-run.",
13
+ ),
14
+ timeoutMinutes: z
15
+ .number()
16
+ .int()
17
+ .min(0)
18
+ .max(24 * 60)
19
+ .default(0)
20
+ .describe("How long one gpu-run command may run before it is stopped, in minutes. Zero (the default) never stops it; `gpu-run --timeout` sets it for one command."),
21
+ // Written by the daemon when the computer this sandbox runs on reported a GPU reset (hosts/host-crashes.ts); cleared
22
+ // by the owner, which is the "resume" press. A sentence, so whoever reads the file sees why.
23
+ pausedFor: z
24
+ .string()
25
+ .max(400)
26
+ .optional()
27
+ .describe(
28
+ "Set by the sandbox when the computer it runs on reported that its GPU was reset or hung, naming the event: while it is set, gpu-run refuses, and every command runs without the GPU. Clear it once you have looked, to let agents use the GPU again.",
29
+ ),
30
+ });
31
+ export type GpuSettings = z.infer<typeof GpuSettingsSchema>;
@@ -261,6 +261,24 @@ export const StorageCategoryUsageSchema = z.object({
261
261
  });
262
262
  export type StorageCategoryUsage = z.infer<typeof StorageCategoryUsageSchema>;
263
263
 
264
+ // One conversation's directories on the history volume as the scan measured them (2026-11-03): every checkout, not the
265
+ // eight biggest a category lists, so the Storage card can say which conversation holds what.
266
+ // The checkout shapes are named, never inferred, like agent-press.ts's: spelled out inside the two storage routes they
267
+ // took the aggregated contract's type past what the declaration emitter will write (TS7056).
268
+ const CheckoutSizeFields = z.object({
269
+ id: z.string().describe("The directory's name under worktrees/ or overlays/: a conversation id, whether or not a conversation still owns it."),
270
+ bytes: z.number().describe("The checkout without its build output: the repositories' files and anything else its turns wrote there."),
271
+ buildOutputBytes: z.number().describe("Build output inside the checkout (a Rust `target/`, Gradle and Flutter output)."),
272
+ overlayBytes: z.number().describe("What its turns installed over the main tree's dependencies."),
273
+ });
274
+ export interface CheckoutSize {
275
+ readonly id: string;
276
+ readonly bytes: number;
277
+ readonly buildOutputBytes: number;
278
+ readonly overlayBytes: number;
279
+ }
280
+ export const CheckoutSizeSchema: z.ZodType<CheckoutSize, CheckoutSize> = CheckoutSizeFields;
281
+
264
282
  export const StorageScanSchema = z.object({
265
283
  startedAt: z.number().describe("When the scan began, in milliseconds."),
266
284
  finishedAt: z.number().describe("When it ended, in milliseconds: the moment these sizes describe."),
@@ -275,11 +293,44 @@ export const StorageScanSchema = z.object({
275
293
  .optional()
276
294
  .describe("The volume as a whole. Absent when the volume would not say."),
277
295
  categories: z.array(StorageCategoryUsageSchema).describe("Every category that holds anything, largest first."),
296
+ checkouts: z
297
+ .array(CheckoutSizeSchema)
298
+ .optional()
299
+ .describe("Every conversation directory on the history volume, largest first. Absent from a scan made before this was measured."),
278
300
  unreadable: z.number().describe("Files and folders the scan could not read, and so did not count."),
279
301
  });
280
302
  export type StorageScan = z.infer<typeof StorageScanSchema>;
281
303
 
282
- export const StorageReportSchema = z.object({
304
+ // Where a measured checkout stands now, for what may be done with it: `working` has a turn, a background command or a
305
+ // child at work in it; `held` has work nobody has landed; `archived` is a conversation put away whose checkout is still
306
+ // on disk; `leftover` is a directory no conversation owns.
307
+ export type CheckoutState = "working" | "idle" | "held" | "landed" | "archived" | "leftover";
308
+ export const CheckoutStateSchema: z.ZodType<CheckoutState, CheckoutState> = z.enum(["working", "idle", "held", "landed", "archived", "leftover"]);
309
+
310
+ export interface CheckoutUsage extends CheckoutSize {
311
+ readonly state: CheckoutState;
312
+ readonly title?: string | undefined;
313
+ readonly updatedAt?: number | undefined;
314
+ readonly can: { readonly cleanBuildOutput: boolean; readonly release: boolean; readonly trash: boolean };
315
+ }
316
+ export const CheckoutUsageSchema: z.ZodType<CheckoutUsage, CheckoutUsage> = CheckoutSizeFields.extend({
317
+ state: CheckoutStateSchema,
318
+ title: z.string().optional().describe("The conversation's title, when it has one."),
319
+ updatedAt: z.number().optional().describe("When the conversation last moved, in milliseconds. Absent for a leftover."),
320
+ can: z
321
+ .object({
322
+ cleanBuildOutput: z.boolean().describe("Its build output may be removed now: it has some, and nothing runs in the conversation."),
323
+ release: z
324
+ .boolean()
325
+ .describe(
326
+ "Its checkout may be freed now: what it holds is committed onto its branch, the checkout and overlay go, and its next turn brings them back.",
327
+ ),
328
+ trash: z.boolean().describe("A leftover that may be moved to the trash now, where it waits a while before it is emptied."),
329
+ })
330
+ .describe("What may be done with it now, by the same rules the daemon applies when asked."),
331
+ });
332
+
333
+ const StorageReportFields = z.object({
283
334
  scan: StorageScanSchema.optional().describe(
284
335
  "The last scan that finished, kept across restarts; its `finishedAt` says how old it is. Absent until one has.",
285
336
  ),
@@ -303,12 +354,40 @@ export const StorageReportSchema = z.object({
303
354
  )
304
355
  .optional()
305
356
  .describe("Live repositories' checkout costs, cached per repository and commit. Repositories without a readable HEAD are omitted."),
357
+ checkouts: z
358
+ .array(CheckoutUsageSchema)
359
+ .optional()
360
+ .describe(
361
+ "The last scan's conversation directories, largest first, each with where its conversation stands now. Sizes are as of the scan; a directory gone since is left out. Absent until a scan has measured them.",
362
+ ),
363
+ });
364
+ // An interface, named like the checkout shapes above: the report is the output of two routes, each of which spelled it
365
+ // out whole, and an alias of the inferred type is spelled out all the same.
366
+ export interface StorageReport extends z.infer<typeof StorageReportFields> {}
367
+ export const StorageReportSchema: z.ZodType<StorageReport, StorageReport> = StorageReportFields;
368
+
369
+ export type CheckoutPress = "cleanBuildOutput" | "release" | "trash";
370
+ export interface CheckoutPressInput {
371
+ readonly id: string;
372
+ readonly press: CheckoutPress;
373
+ }
374
+ export const CheckoutPressInputSchema: z.ZodType<CheckoutPressInput, CheckoutPressInput> = z.object({
375
+ id: z.string().describe("The conversation id the directory is named by."),
376
+ press: z.enum(["cleanBuildOutput", "release", "trash"]).describe("What to do with it, as the row's `can` allows."),
377
+ });
378
+
379
+ export interface CheckoutPressResult {
380
+ readonly id: string;
381
+ readonly removed: readonly string[];
382
+ }
383
+ export const CheckoutPressResultSchema: z.ZodType<CheckoutPressResult, CheckoutPressResult> = z.object({
384
+ id: z.string(),
385
+ removed: z.array(z.string()).describe("Build output folders removed, relative to the checkout; empty for a release or a trash."),
306
386
  });
307
- export type StorageReport = z.infer<typeof StorageReportSchema>;
308
387
 
309
388
  // How close the history volume is to full, as the daemon's disk-pressure watch last read it (GET /system/disk-pressure).
310
- // `reaping`: under 15% free, settled checkouts' build output is being removed; `low` and `critical` are under 10% and
311
- // 5%, which the owner is told about once each.
389
+ // `reaping`: under the settings' `diskReapBelowPercent` free (15% by default), settled checkouts' build output is being
390
+ // removed; `low` and `critical` are under 10% and 5%, which the owner is told about once each.
312
391
  export const DiskPressureLevelSchema = z.enum(["ok", "reaping", "low", "critical"]);
313
392
  export type DiskPressureLevel = z.infer<typeof DiskPressureLevelSchema>;
314
393
 
@@ -0,0 +1,54 @@
1
+ import { asZone, UTC } from "../time/zone.js";
2
+ import { NightHoursSchema, nightLength, withinNight } from "./night-hours.js";
3
+
4
+ // The window is read on a named clock, so every instant below is built in that zone's own terms.
5
+ const WARSAW = asZone("Europe/Warsaw")!;
6
+ const at = (iso: string): number => Date.parse(iso);
7
+
8
+ test("nothing is decided for anyone until the owner sets the hours: off by default", () => {
9
+ expect(NightHoursSchema.parse({})).toEqual({ on: false, from: "23:00", to: "07:00", questions: "decide" });
10
+ });
11
+
12
+ test("a window that crosses midnight holds both sides of it, and not the day between", () => {
13
+ const night = { from: "23:00", to: "07:00" };
14
+ expect(withinNight(night, UTC, at("2026-11-04T23:00:00Z"))).toBe(true);
15
+ expect(withinNight(night, UTC, at("2026-11-05T03:30:00Z"))).toBe(true);
16
+ // `to` itself is morning already.
17
+ expect(withinNight(night, UTC, at("2026-11-05T07:00:00Z"))).toBe(false);
18
+ expect(withinNight(night, UTC, at("2026-11-04T22:59:00Z"))).toBe(false);
19
+ expect(withinNight(night, UTC, at("2026-11-04T12:00:00Z"))).toBe(false);
20
+ });
21
+
22
+ test("a window inside one day, for someone who sleeps after midnight", () => {
23
+ const night = { from: "01:30", to: "09:15" };
24
+ expect(withinNight(night, UTC, at("2026-11-04T01:30:00Z"))).toBe(true);
25
+ expect(withinNight(night, UTC, at("2026-11-04T09:14:00Z"))).toBe(true);
26
+ expect(withinNight(night, UTC, at("2026-11-04T09:15:00Z"))).toBe(false);
27
+ expect(withinNight(night, UTC, at("2026-11-04T00:00:00Z"))).toBe(false);
28
+ });
29
+
30
+ test("a window that begins where it ends is no night at all, not a whole day", () => {
31
+ expect(withinNight({ from: "07:00", to: "07:00" }, UTC, at("2026-11-04T07:00:00Z"))).toBe(false);
32
+ expect(withinNight({ from: "07:00", to: "07:00" }, UTC, at("2026-11-04T02:00:00Z"))).toBe(false);
33
+ });
34
+
35
+ test("read on the sandbox's own clock, summer and winter alike, not the container's UTC", () => {
36
+ const night = { from: "23:00", to: "07:00" };
37
+ // 22:30 UTC in November is 23:30 in Warsaw (UTC+1); in July (UTC+2) 21:30 UTC is 23:30.
38
+ expect(withinNight(night, WARSAW, at("2026-11-04T22:30:00Z"))).toBe(true);
39
+ expect(withinNight(night, WARSAW, at("2026-07-04T21:30:00Z"))).toBe(true);
40
+ // 06:30 UTC in November is 07:30 in Warsaw: morning there, though still before 07:00 UTC.
41
+ expect(withinNight(night, WARSAW, at("2026-11-05T06:30:00Z"))).toBe(false);
42
+ });
43
+
44
+ test("its length is said in minutes across midnight", () => {
45
+ expect(nightLength({ from: "23:00", to: "07:00" })).toBe(8 * 60);
46
+ expect(nightLength({ from: "01:30", to: "09:15" })).toBe(7 * 60 + 45);
47
+ expect(nightLength({ from: "07:00", to: "07:00" })).toBe(0);
48
+ });
49
+
50
+ test("a time that is not a wall-clock time is refused at the edge", () => {
51
+ expect(NightHoursSchema.safeParse({ from: "24:00" }).success).toBe(false);
52
+ expect(NightHoursSchema.safeParse({ to: "7:00" }).success).toBe(false);
53
+ expect(NightHoursSchema.safeParse({ from: "22:45", to: "06:10" }).success).toBe(true);
54
+ });
@@ -0,0 +1,70 @@
1
+ // NIGHT HOURS: the hours the owner sleeps, set on purpose, during which an agent that would stop to ask them something
2
+ // carries on instead. A turn left running for the night used to park on its first question until morning, and the
3
+ // owner woke to a question rather than to work.
4
+ //
5
+ // Read on the sandbox's own clock (`timezone`, the zone every wall-clock rule here is meant in), and only in force while
6
+ // nobody is at the editor: someone up past their night's start and at a screen is asked as on any other evening.
7
+
8
+ import { z } from "zod";
9
+ import type { Zone } from "../time/zone.js";
10
+
11
+ /** A time of day on a wall clock, as `HH:MM` from 00:00 to 23:59. */
12
+ export const ClockTimeSchema = z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "A time of day as HH:MM, 00:00 to 23:59.");
13
+ export type ClockTime = z.infer<typeof ClockTimeSchema>;
14
+
15
+ // What a question an agent asks during night hours gets. `decide`: the sandbox answers it with the option the agent
16
+ // recommends, and the agent lists what was decided for the owner in its last message. `defer`: the sandbox tells the
17
+ // agent the question waits for the morning, and the agent finishes everything that does not hang on it, then ends with
18
+ // the question.
19
+ export const NightQuestionsSchema = z.enum(["decide", "defer"]);
20
+ export type NightQuestions = z.infer<typeof NightQuestionsSchema>;
21
+
22
+ export const NightHoursSchema = z.object({
23
+ on: z
24
+ .boolean()
25
+ .default(false)
26
+ .describe("Whether the sandbox keeps night hours at all. Off, every question waits for an answer, whatever the hour."),
27
+ from: ClockTimeSchema.default("23:00").describe("When the night begins, as HH:MM on the sandbox's clock."),
28
+ to: ClockTimeSchema.default("07:00").describe("When it ends, as HH:MM on the sandbox's clock. Earlier than `from` runs past midnight; equal to it is no night at all."),
29
+ questions: NightQuestionsSchema.default("decide").describe(
30
+ "What a question an agent asks during night hours, with nobody at the editor, gets. `decide`: it is answered with the option the agent recommends, and the agent lists what was decided for you in its last message, so you can overturn any of it. `defer`: the agent is told it waits for the morning, finishes everything that does not depend on the answer, and ends with the question at the top of its last message.",
31
+ ),
32
+ });
33
+ export type NightHours = z.infer<typeof NightHoursSchema>;
34
+
35
+ const minutesOf = (time: ClockTime): number => Number(time.slice(0, 2)) * 60 + Number(time.slice(3, 5));
36
+
37
+ // The minute of the day a named clock shows at an instant. `h23`, since `hour12: false` reads midnight as 24 in some
38
+ // engines.
39
+ const minuteIn = (at: number, zone: Zone): number => {
40
+ const parts = new Intl.DateTimeFormat("en-GB", { timeZone: zone, hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).formatToParts(at);
41
+ const part = (type: "hour" | "minute"): number => Number(parts.find((candidate) => candidate.type === type)?.value ?? 0);
42
+ return (part("hour") % 24) * 60 + part("minute");
43
+ };
44
+
45
+ /**
46
+ * Whether an instant falls inside the night window on a named clock, the switch aside: from `from` (inclusive) to `to`
47
+ * (exclusive), across midnight when `to` is the earlier time. A window that begins where it ends is empty.
48
+ */
49
+ export const withinNight = (hours: Pick<NightHours, "from" | "to">, zone: Zone, at: number): boolean => {
50
+ const from = minutesOf(hours.from);
51
+ const to = minutesOf(hours.to);
52
+ const now = minuteIn(at, zone);
53
+ if (from === to) {
54
+ return false;
55
+ }
56
+ return from < to ? now >= from && now < to : now >= from || now < to;
57
+ };
58
+
59
+ /** How long a night window lasts, in minutes: what the settings row says beside the two times. */
60
+ export const nightLength = (hours: Pick<NightHours, "from" | "to">): number => (minutesOf(hours.to) - minutesOf(hours.from) + 24 * 60) % (24 * 60);
61
+
62
+ // What a card carries once night hours answered it rather than a person, on the reply and on the frozen card: which of
63
+ // the answers it got, and when that night ended, so the agent and the morning reader can both tell it apart from a pick
64
+ // somebody made. `picked`: a question answered with the agent's own recommendation; `saved`: a question kept for the
65
+ // morning; `approved`: a plan the agent chose to make, approved so the work could go on.
66
+ export const NightAnswerSchema = z.object({
67
+ outcome: z.enum(["picked", "saved", "approved"]).describe("How night hours answered it: picked the agent's recommendation, saved the question for the morning, or approved the plan."),
68
+ until: ClockTimeSchema.describe("When the night hours it fell in end, as HH:MM on the sandbox's clock."),
69
+ });
70
+ export type NightAnswer = z.infer<typeof NightAnswerSchema>;
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { AccessProfileSchema } from "./access-profiles.js";
3
3
  import { PRESET_GROUPS, type PresetGroup, PresetGroupSchema } from "./compliance.js";
4
4
  import { AiAccountKeySchema } from "./members.js";
5
+ import { SealModeSchema } from "./seal.js";
5
6
  import { ToolCeilingSchema } from "./tool-ceiling.js";
6
7
 
7
8
  // An ORGANISATION'S POLICY as a sandbox holds it (docs/architecture/organisations.md). A sandbox that belongs to an
@@ -47,6 +48,17 @@ export const OrgCeilingSchema = z.object({
47
48
  });
48
49
  export type OrgCeiling = z.infer<typeof OrgCeilingSchema>;
49
50
 
51
+ // How an organisation holds private conversations in its sandboxes: `mode` fixes the house rule (absent leaves it to each
52
+ // sandbox), `twoPerson` makes an opening without asking wait for a second person with Full access.
53
+ export const OrgConversationsSchema = z.object({
54
+ mode: SealModeSchema.optional().describe("The house rule every bound sandbox holds. Absent leaves it to each sandbox."),
55
+ twoPerson: z
56
+ .boolean()
57
+ .optional()
58
+ .describe("Opening a private conversation without asking needs a second person with Full access to agree, besides the owner."),
59
+ });
60
+ export type OrgConversations = z.infer<typeof OrgConversationsSchema>;
61
+
50
62
  // Omitted policy sections stay open. preset pins effective settings and refuses undoing writes, regardless of underlying files.
51
63
  // Unknown preset groups are skipped/reported as unenforced so newer policies still reach older daemons; the platform validates saved names.
52
64
  // membersOnly fences roster grants/removals by organisation membership, excluding the owner who is not a roster entry.
@@ -73,6 +85,9 @@ export const OrgPolicyRulesSchema = z.object({
73
85
  .optional()
74
86
  .describe("Access profiles every bound sandbox may grant, read-only there. Areas and connections they name are each sandbox's own ids."),
75
87
  ceiling: OrgCeilingSchema.optional().describe("What no turn in a bound sandbox may exceed, the owner's included."),
88
+ // Private conversations (seal.ts): the house rule every bound sandbox holds, and whether opening one without asking
89
+ // needs a second person. Optional like the rest: a policy stored before it fixes neither.
90
+ conversations: OrgConversationsSchema.optional().describe("Who reads whose conversations in every bound sandbox, and how one is opened without asking."),
76
91
  });
77
92
  export type OrgPolicyRules = z.infer<typeof OrgPolicyRulesSchema>;
78
93
 
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PRIVACY_SHIELD, PRIVACY_PATTERN_MAX, PrivacyShieldPolicySchema, patternProblem } from "./privacy.js";
1
+ import { DEFAULT_PRIVACY_SHIELD, FRESH_PRIVACY_SHIELD, PRIVACY_PATTERN_MAX, PrivacyShieldPolicySchema, patternProblem } from "./privacy.js";
2
2
 
3
3
  // The owner's own patterns run on every string bound for an untrusted provider, in the daemon's one thread: one that
4
4
  // cannot compile, matches empty text or nests a repeat inside a repeat is refused before it is saved.
@@ -45,6 +45,13 @@ describe(`PrivacyShieldPolicySchema`, () => {
45
45
  expect(DEFAULT_PRIVACY_SHIELD.rules).toEqual([]);
46
46
  });
47
47
 
48
+ // New sandboxes start shielded (2026-11-04), while a stored policy that leaves `mode` out still reads off. Shielded
49
+ // without the readers that need local models, so a new sandbox is not asked for a rebuild it never chose.
50
+ it(`starts a sandbox that never wrote a policy masking, images as they are, every other field at its default`, () => {
51
+ expect(FRESH_PRIVACY_SHIELD).toEqual({ ...DEFAULT_PRIVACY_SHIELD, mode: `on`, images: `allow` });
52
+ expect(DEFAULT_PRIVACY_SHIELD.mode).toBe(`off`);
53
+ });
54
+
48
55
  it(`fills a rule's defaults and keeps a stored pattern whatever a later build judges of it`, () => {
49
56
  const parsed = PrivacyShieldPolicySchema.parse({
50
57
  rules: [{ id: `r1`, title: `Nested`, class: `identity-document`, match: `pattern`, pattern: `(a+)+` }],
@@ -286,9 +286,18 @@ export const withConversationTrust = (policy: PrivacyShieldPolicy, conversationI
286
286
  return { ...policy, conversations: on ? [...others, { conversationId, provider }].slice(-PRIVACY_CONVERSATIONS_MAX) : others };
287
287
  };
288
288
 
289
- // The policy a sandbox that never wrote one runs on.
289
+ // Every field at its schema default, the shield off: what a policy that names nothing reads as.
290
290
  export const DEFAULT_PRIVACY_SHIELD: PrivacyShieldPolicy = PrivacyShieldPolicySchema.parse({});
291
291
 
292
+ // The policy a sandbox that never wrote one runs on: the shield masking (2026-11-04, new sandboxes start shielded). The
293
+ // schema's own default stays off, so a stored policy that leaves `mode` out reads as it always did; a sandbox from
294
+ // before the change gets an off policy written down at its next boot (the daemon's settings/earlier-defaults-step.ts).
295
+ // Images go as they are and names come from the dictionary: both other answers need the privacy pack's local models
296
+ // (OCR and the name model, about 255 MB) that no image bakes, so a shield masking images from the start asked every new
297
+ // sandbox for a rebuild within minutes and held its images until then. Downloading local models is the owner's decision,
298
+ // made where they switch image masking or the name model on.
299
+ export const FRESH_PRIVACY_SHIELD: PrivacyShieldPolicy = PrivacyShieldPolicySchema.parse({ mode: "on", images: "allow", names: "dictionary" });
300
+
292
301
  // How a provider stands against the gateway, for the trusted list: whether its traffic can be shielded at all, and
293
302
  // whether it never leaves this machine.
294
303
  export const PrivacyProviderSchema = z.object({
@@ -4,6 +4,7 @@ import { TRANSLATOR_PROVIDERS, type TranslatorProvider } from "../../models/prov
4
4
  import { AgentHarnessSchema, AgentProviderSchema, ConversationIdSchema, EditorContextSchema } from "../agent.js";
5
5
  import { MENTION_LIMIT } from "../../text/mentions.js";
6
6
  import { HandoffModeSchema } from "./handoff.js";
7
+ import { NightAnswerSchema } from "../night-hours.js";
7
8
  // Headroom is one shape shared by every provider, not a Claude idea others imitate: a native account and a routed
8
9
  // subscription differ in who holds the credential, never in what a reading is. Every surface that draws a percentage
9
10
  // reads this one type.
@@ -199,6 +200,7 @@ export const AgentReplySchema = z.discriminatedUnion("kind", [
199
200
  "Whether to go ahead. Approving means the plan then runs without a prompt per tool, because being asked whether a plan you just approved may run its first command is not a question worth having.",
200
201
  ),
201
202
  feedback: z.string().optional().describe("Instructions to follow while executing an approved plan, or changes requested when rejecting it."),
203
+ night: NightAnswerSchema.optional().describe("Set by the sandbox alone, when night hours approved the plan with nobody at the editor. A person's reply never carries it."),
202
204
  }),
203
205
  // Keyed by question text, valued by chosen option label(s), including free-text "Other".
204
206
  z.object({
@@ -218,6 +220,9 @@ export const AgentReplySchema = z.discriminatedUnion("kind", [
218
220
  .boolean()
219
221
  .optional()
220
222
  .describe("Dismissing it instead, which tells the agent to carry on using sensible defaults rather than leaving it waiting."),
223
+ night: NightAnswerSchema.optional().describe(
224
+ "Set by the sandbox alone, when night hours answered it with nobody at the editor: with the agent's recommendation, or by keeping it for the morning. A person's reply never carries it.",
225
+ ),
221
226
  }),
222
227
  // "always" may be narrowed further by the SDK's own suggestions. "everything" is the conversation-wide yes the card's
223
228
  // Allow menu offers: this call, and every later request in the conversation a person could have allowed once.