@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
@@ -0,0 +1,68 @@
1
+ import { audienceOfMode, effectiveAudience, handsOffChanges, handsOffRules, MANAGED_RULE_IDS, managedRule } from "./sandbox-mode.js";
2
+ import { type Rule, RuleSchema, SandboxSettingsSchema } from "./settings.js";
3
+
4
+ // A hands-off sandbox owns three rules and leaves every other one alone: the owner's hold still decides first, a managed
5
+ // rule they narrowed or switched off stands again where it was, a missing one goes at the end, and a list that already
6
+ // is hands-off comes back as the very same array.
7
+
8
+ const hold: Rule = RuleSchema.parse({
9
+ id: "hold-payments",
10
+ label: "Hold work on payments",
11
+ moment: "agent.finished",
12
+ when: { paths: ["payments/"] },
13
+ action: { kind: "verdict", verdict: "hold" },
14
+ });
15
+
16
+ const ids = (rules: readonly Rule[]): string[] => rules.map((rule) => rule.id);
17
+
18
+ test("an empty list gains the three rules, in the order they act", () => {
19
+ expect(ids(handsOffRules([]))).toEqual(["auto-land", "auto-version", "auto-push"]);
20
+ expect(handsOffChanges([])).toEqual(["land", "version", "push"]);
21
+ });
22
+
23
+ test("an owner's hold stays ahead of the land, so it still decides first", () => {
24
+ const rules = handsOffRules([hold]);
25
+ expect(ids(rules)).toEqual(["hold-payments", "auto-land", "auto-version", "auto-push"]);
26
+ expect(rules[0]).toBe(hold);
27
+ });
28
+
29
+ test("a managed rule switched off or narrowed stands again where it was", () => {
30
+ const off = { ...managedRule("land"), enabled: false };
31
+ const narrowed = { ...managedRule("version"), when: { repo: "site" } };
32
+ const rules = handsOffRules([off, hold, narrowed]);
33
+
34
+ expect(ids(rules)).toEqual(["auto-land", "hold-payments", "auto-version", "auto-push"]);
35
+ expect(rules[0]).toEqual(managedRule("land"));
36
+ expect(rules[2]).toEqual(managedRule("version"));
37
+ expect(handsOffChanges([off, hold, narrowed])).toEqual(["land", "version", "push"]);
38
+ });
39
+
40
+ test("a list that already is hands-off comes back as the same array", () => {
41
+ const already = handsOffRules([hold]);
42
+ expect(handsOffRules(already)).toBe(already);
43
+ expect(handsOffChanges(already)).toEqual([]);
44
+ });
45
+
46
+ test("every managed rule is one the settings take", () => {
47
+ const rules = handsOffRules([]);
48
+ expect(SandboxSettingsSchema.parse({ mode: "hands-off", rules }).rules).toEqual(rules);
49
+ expect(ids(rules)).toEqual(Object.values(MANAGED_RULE_IDS));
50
+ });
51
+
52
+ test("a managed rule handed out is a copy", () => {
53
+ const first = managedRule("push");
54
+ first.enabled = false;
55
+ expect(managedRule("push").enabled).toBe(true);
56
+ });
57
+
58
+ test("the words follow the mode unless a person chose their own", () => {
59
+ expect(audienceOfMode("hands-off")).toBe("maker");
60
+ expect(audienceOfMode("hands-on")).toBe("developer");
61
+ expect(effectiveAudience("hands-off", undefined)).toBe("maker");
62
+ expect(effectiveAudience("hands-off", "developer")).toBe("developer");
63
+ expect(effectiveAudience("hands-on", "maker")).toBe("maker");
64
+ });
65
+
66
+ test("a sandbox that never said runs hands-on", () => {
67
+ expect(SandboxSettingsSchema.parse({}).mode).toBe("hands-on");
68
+ });
@@ -0,0 +1,93 @@
1
+ import { DEFAULT_SANDBOX_MODE, SANDBOX_MODES, type SandboxMode } from "@intentic/constants";
2
+ import { z } from "zod";
3
+ import type { Audience, Rule } from "./settings.js";
4
+
5
+ // HOW A SANDBOX RUNS (@intentic/constants sandbox-mode.ts), as its settings carry it and as both sides act on it.
6
+ //
7
+ // A hands-off sandbox owns the three rules that decide what becomes of finished work: it lands, it is saved as a
8
+ // version, and that version is backed up wherever a branch tracks a remote (a branch that tracks none is skipped by the
9
+ // push itself, so the third rule costs nothing until there is somewhere to send it). While the sandbox runs hands-off
10
+ // those rules stand, switched on, whatever a save or a hand edit says; the daemon's settings store applies that on
11
+ // every read and every write, so the land, the version and the push all read the same table the Agent tab shows.
12
+ // Switching back to hands-on changes no rule: what stood is the owner's from then on.
13
+
14
+ export const SandboxModeSchema = z.enum(SANDBOX_MODES);
15
+
16
+ export { DEFAULT_SANDBOX_MODE, type SandboxMode };
17
+
18
+ // The ids the Agent tab has always named these rules by (editor models/sandbox/environment/rules.ts), so a sandbox
19
+ // whose owner switched one on by hand before the mode existed keeps that very rule, and its firing history with it.
20
+ export const MANAGED_RULE_IDS = { land: "auto-land", version: "auto-version", push: "auto-push" } as const;
21
+
22
+ export type ManagedRule = keyof typeof MANAGED_RULE_IDS;
23
+
24
+ // The rules themselves, in the order they act. The labels are the English the Agent tab writes; it shows each by its
25
+ // own row, never by this label, which only a held-work line or an exported definition repeats.
26
+ const MANAGED = {
27
+ land: {
28
+ id: MANAGED_RULE_IDS.land,
29
+ label: "Land finished work automatically",
30
+ moment: "agent.finished",
31
+ action: { kind: "verdict", verdict: "allow" },
32
+ enabled: true,
33
+ },
34
+ version: {
35
+ id: MANAGED_RULE_IDS.version,
36
+ label: "Save a version of accepted work",
37
+ moment: "agent.landed",
38
+ action: { kind: "builtin", name: "version-landed" },
39
+ enabled: true,
40
+ },
41
+ push: {
42
+ id: MANAGED_RULE_IDS.push,
43
+ label: "Back up each saved version",
44
+ moment: "agent.landed",
45
+ action: { kind: "builtin", name: "push-landed" },
46
+ enabled: true,
47
+ },
48
+ } satisfies Record<ManagedRule, Rule>;
49
+
50
+ const MANAGED_ORDER: readonly ManagedRule[] = ["land", "version", "push"];
51
+
52
+ // A copy, so a caller that edits what it was handed never edits the table.
53
+ export const managedRule = (which: ManagedRule): Rule => structuredClone(MANAGED[which]);
54
+
55
+ // Whether a rule already is the managed one: switched on, unconditioned, acting as the managed one acts. A rule under
56
+ // a managed id that the owner narrowed (a repository, some paths) is not: hands-off means every piece of finished work.
57
+ const standsAsManaged = (rule: Rule, which: ManagedRule): boolean =>
58
+ rule.enabled && rule.when === undefined && rule.moment === MANAGED[which].moment && JSON.stringify(rule.action) === JSON.stringify(MANAGED[which].action);
59
+
60
+ /** Which managed rules a list lacks, has switched off, or has narrowed: what taking over would change, in acting order. */
61
+ export const handsOffChanges = (rules: readonly Rule[]): ManagedRule[] =>
62
+ MANAGED_ORDER.filter((which) => {
63
+ const held = rules.find((rule) => rule.id === MANAGED_RULE_IDS[which]);
64
+ return held === undefined || !standsAsManaged(held, which);
65
+ });
66
+
67
+ /**
68
+ * A rule list as a hands-off sandbox runs it: the owner's own rules untouched, and each managed rule standing as the
69
+ * managed one. One already in the list is replaced where it stands, so a hold the owner put ahead of it still decides
70
+ * first; a missing one goes at the end. Answers the same array when nothing changes, so a reader can tell cheaply.
71
+ */
72
+ export const handsOffRules = <T extends readonly Rule[]>(rules: T): T | Rule[] => {
73
+ const changes = handsOffChanges(rules);
74
+ if (changes.length === 0) {
75
+ return rules;
76
+ }
77
+ const next = rules.map((rule) => {
78
+ const which = MANAGED_ORDER.find((managed) => MANAGED_RULE_IDS[managed] === rule.id);
79
+ return which !== undefined && changes.includes(which) ? managedRule(which) : rule;
80
+ });
81
+ for (const which of changes) {
82
+ if (!next.some((rule) => rule.id === MANAGED_RULE_IDS[which])) {
83
+ next.push(managedRule(which));
84
+ }
85
+ }
86
+ return next;
87
+ };
88
+
89
+ /** The words a sandbox speaks to everyone who has not chosen for themselves. */
90
+ export const audienceOfMode = (mode: SandboxMode): Audience => (mode === "hands-off" ? "maker" : "developer");
91
+
92
+ /** The words one person reads: their own choice when they made one here, otherwise the sandbox's. */
93
+ export const effectiveAudience = (mode: SandboxMode, override: Audience | undefined): Audience => override ?? audienceOfMode(mode);
@@ -0,0 +1,12 @@
1
+ // The owner's signed yes to opening a private conversation without asking (seal.ts SealOpenDocumentSchema). Apart from
2
+ // seal.ts because the passkey shapes live in system.ts, whose event frames import the conversation summary, which imports
3
+ // seal.ts: keeping this here is what keeps that a line rather than a circle.
4
+ import { z } from "zod";
5
+ import { SealIdSchema } from "./seal.js";
6
+ import { AuthenticationResponseSchema } from "./system.js";
7
+
8
+ export const SealOpenProofSchema = SealIdSchema.extend({
9
+ document: z.string().min(1).max(4096).describe("The document text, byte for byte what the challenge hashed."),
10
+ assertion: AuthenticationResponseSchema,
11
+ });
12
+ export type SealOpenProof = z.infer<typeof SealOpenProofSchema>;
@@ -0,0 +1,175 @@
1
+ // seal: private conversations (docs/architecture/access.md, "Private conversations"). A conversation's WORDS can be
2
+ // sealed to the people its author names; its WORK is not: the diff stays on the board for whoever lands it, and what lands
3
+ // is the team's. A person who cannot read a sealed conversation sees it as a calendar shows someone else's private
4
+ // event: whose it is, which lane it stands in, and its diff once there is work to land. Never its title.
5
+ //
6
+ // The owner reads a sealed conversation the way anyone else does, by asking its author. The one other door is opening it
7
+ // without asking: the sandbox owner alone (never Full access, never an agent), with a written reason and the owner's
8
+ // passkey over it, read-only for a day, told to the author at once and recorded on the conversation for good.
9
+ import { z } from "zod";
10
+
11
+ // ---- The house rule ----
12
+
13
+ // `everyone`: every conversation is readable by everyone who can see its part of the workspace, as before private
14
+ // conversations existed; no new one can be made private. `chooses`: each author decides, new conversations starting as
15
+ // their own default says. `private`: new conversations start private, and the author may share one.
16
+ // Changing the rule never opens a conversation that is already private: only its author or an opening does.
17
+ export const SealModeSchema = z.enum(["everyone", "chooses", "private"]);
18
+ export type SealMode = z.infer<typeof SealModeSchema>;
19
+ export const SEAL_MODE_DEFAULT: SealMode = "everyone";
20
+
21
+ // What GET /seal answers: the house rule as it binds, and what the caller's own new conversations start as.
22
+ export const SealHouseSchema = z.object({
23
+ mode: SealModeSchema.describe("The house rule: who reads whose conversations in this sandbox."),
24
+ locked: z
25
+ .boolean()
26
+ .describe("Whether the sandbox's organisation fixed the house rule, so nobody here can change it. False on a sandbox no organisation holds."),
27
+ twoPerson: z
28
+ .boolean()
29
+ .describe(
30
+ "Whether opening a private conversation without asking also needs a second person with Full access to agree, as the sandbox's organisation requires.",
31
+ ),
32
+ hosted: z
33
+ .boolean()
34
+ .describe(
35
+ "Whether intentic runs this sandbox, so nobody here has a shell on the machine beneath it. False for a sandbox on the owner's own computer or server, where a shell on that machine can read its files.",
36
+ ),
37
+ sealed: z.number().int().min(0).describe("How many conversations are private right now, live and archived."),
38
+ startsPrivate: z.boolean().describe("Whether a conversation the caller starts now begins private."),
39
+ ownDefault: z
40
+ .boolean()
41
+ .optional()
42
+ .describe("The caller's own answer to whether their new conversations start private, when the house rule lets them choose. Absent: never answered."),
43
+ });
44
+ export type SealHouse = z.infer<typeof SealHouseSchema>;
45
+
46
+ export const SealSetHouseSchema = z.object({ mode: SealModeSchema });
47
+ export const SealSetDefaultSchema = z.object({ private: z.boolean().describe("Whether the caller's new conversations start private.") });
48
+
49
+ // ---- One conversation's seal ----
50
+
51
+ // A person, as the seal names them: the address they sign in with, lowercased, and a name when one is known.
52
+ export const SealPersonSchema = z.object({
53
+ email: z.string().min(3).max(320),
54
+ name: z.string().max(200).optional(),
55
+ });
56
+ export type SealPerson = z.infer<typeof SealPersonSchema>;
57
+
58
+ // Somebody the author let read it for a while (Show for a day): read-only, until `until`.
59
+ export const SealGrantSchema = SealPersonSchema.extend({
60
+ until: z.number().describe("Until when they may read it, in milliseconds."),
61
+ by: z.string().describe("Who let them, by address."),
62
+ });
63
+ export type SealGrant = z.infer<typeof SealGrantSchema>;
64
+
65
+ // Somebody who asked to read it and has not been answered.
66
+ export const SealAskSchema = SealPersonSchema.extend({ at: z.number() });
67
+ export type SealAsk = z.infer<typeof SealAskSchema>;
68
+
69
+ export const SEAL_OPEN_HOURS = 24;
70
+ export const SEAL_REASON_MIN = 10;
71
+ export const SEAL_REASON_MAX = 500;
72
+
73
+ // An opening without asking. Kept on the conversation for good; no route removes one. `approvedBy` is the second
74
+ // person an organisation's two-person rule asked for; `pending` means that second person has not agreed yet, and nothing
75
+ // can be read until they do. `refusedBy` ends a pending one without it ever opening.
76
+ export const SealOpenSchema = SealPersonSchema.extend({
77
+ id: z.string().describe("The opening's own id."),
78
+ at: z.number().describe("When it was asked for, in milliseconds."),
79
+ until: z.number().describe("Until when it may be read, in milliseconds. Counted from the second person's yes when one was needed."),
80
+ reason: z.string().min(SEAL_REASON_MIN).max(SEAL_REASON_MAX).describe("Why, in the opener's words, as the author is shown them."),
81
+ approvedBy: SealPersonSchema.extend({ at: z.number() }).optional(),
82
+ refusedBy: SealPersonSchema.extend({ at: z.number() }).optional(),
83
+ pending: z.literal(true).optional(),
84
+ });
85
+ export type SealOpen = z.infer<typeof SealOpenSchema>;
86
+
87
+ // How a conversation is sealed, as the registry keeps it. `from` names the conversation a subagent, a review or a fork
88
+ // took its seal from: changing that one's seal changes this one's with it, since its words are that one's work in prose.
89
+ export const SealSchema = z.object({
90
+ since: z.number().describe("When it was made private, in milliseconds."),
91
+ readers: z.array(SealPersonSchema).max(50).describe("Who reads it besides an opening: its author first, then the people they added."),
92
+ grants: z.array(SealGrantSchema).max(50).optional(),
93
+ asks: z.array(SealAskSchema).max(50).optional(),
94
+ opens: z.array(SealOpenSchema).max(200).optional(),
95
+ from: z.string().optional(),
96
+ });
97
+ export type Seal = z.infer<typeof SealSchema>;
98
+
99
+ // How the caller reads it: a reader, someone let in for a while, or an opening without asking. The last two are
100
+ // read-only: nothing they press may write into it.
101
+ export const SealViaSchema = z.enum(["reader", "grant", "open"]);
102
+ export type SealVia = z.infer<typeof SealViaSchema>;
103
+
104
+ // The seal as one caller is shown it on a conversation's summary. A reader sees all of it. Anyone else sees the summary
105
+ // cut to a sealed card (`sealed: true`): whether they already asked, and an opening waiting on a second person when they
106
+ // are someone who could be it, or the one who asked for it.
107
+ export const SealViewSchema = z.object({
108
+ sealed: z.literal(true).optional().describe("The caller cannot read this conversation: the summary is cut to whose it is, where it stands and its diff."),
109
+ via: SealViaSchema.optional().describe("How the caller reads it. Absent on a sealed card."),
110
+ until: z.number().optional().describe("Until when the caller may read it, for a grant or an opening."),
111
+ readers: z.array(SealPersonSchema).optional(),
112
+ grants: z.array(SealGrantSchema).optional(),
113
+ asks: z.array(SealAskSchema).optional(),
114
+ opens: z.array(SealOpenSchema).optional(),
115
+ asked: z.literal(true).optional().describe("On a sealed card: the caller asked to read it and has not been answered."),
116
+ pending: SealOpenSchema.optional().describe("An opening without asking that waits on a second person, shown to its opener and to whoever could agree."),
117
+ canOpen: z.literal(true).optional().describe("On a sealed card: the caller may open it without asking (the sandbox owner)."),
118
+ canApprove: z.literal(true).optional().describe("The caller may agree to the pending opening, as the second person."),
119
+ });
120
+ export type SealView = z.infer<typeof SealViewSchema>;
121
+ export const SEAL_VIEW_DESCRIPTION =
122
+ "Set on a private conversation: how the caller reads it, or, with `sealed`, that they cannot and this summary is cut to whose it is, where it stands and its diff. Absent on a conversation everyone who sees it may read.";
123
+
124
+ // ---- Route bodies ----
125
+
126
+ export const SealIdSchema = z.object({ id: z.string().min(1).describe("The conversation.") });
127
+
128
+ // Make it private (with who besides its author reads it) or shared again. Only its author, or a reader when nobody
129
+ // answers for it, may.
130
+ export const SealSetSchema = SealIdSchema.extend({
131
+ private: z.boolean(),
132
+ readers: z.array(z.string().min(3).max(320)).max(49).optional().describe("Who besides its author may read it, by address. Absent keeps the list it has."),
133
+ });
134
+ export type SealSet = z.infer<typeof SealSetSchema>;
135
+
136
+ export const SealAnswerSchema = SealIdSchema.extend({
137
+ email: z.string().min(3).max(320).describe("Whose ask this answers."),
138
+ answer: z.enum(["day", "always", "decline"]).describe("Show it to them for a day, add them as a reader, or say no."),
139
+ });
140
+ export type SealAnswer = z.infer<typeof SealAnswerSchema>;
141
+
142
+ // What the owner's passkey signs to open a conversation without asking. The challenge is the sha256 of this document's
143
+ // text exactly as `SealOpenProof.document` carries it, so the daemon checks the same bytes it parses.
144
+ export const SealOpenDocumentSchema = z.strictObject({
145
+ v: z.literal(1),
146
+ purpose: z.literal("intentic-conversation-open"),
147
+ conversationId: z.string().min(1),
148
+ reason: z.string().min(SEAL_REASON_MIN).max(SEAL_REASON_MAX),
149
+ nonce: z.string().min(16).max(64),
150
+ expiresAt: z.number().int().positive(),
151
+ });
152
+ export type SealOpenDocument = z.infer<typeof SealOpenDocumentSchema>;
153
+ export const SEAL_PROOF_MAX_AGE_MS = 5 * 60_000;
154
+
155
+ export const SealOpenPrepareSchema = SealIdSchema.extend({ reason: z.string().trim().min(SEAL_REASON_MIN).max(SEAL_REASON_MAX) });
156
+
157
+ // The signed document travels as `SealOpenProofSchema` (seal-proof.ts), apart from this file so the summary schema that
158
+ // reads this one does not import the passkey shapes, which sit behind the event frames that import the summary.
159
+
160
+ // What the editor needs to run the ceremony: the document text to hash, the relying party and the owner's credentials.
161
+ export const SealOpenCeremonySchema = z.object({
162
+ document: z.string().min(1).max(4096),
163
+ rpId: z.string().min(1),
164
+ credentials: z.array(z.object({ id: z.string(), transports: z.array(z.string()).optional() })),
165
+ });
166
+ export type SealOpenCeremony = z.infer<typeof SealOpenCeremonySchema>;
167
+
168
+ export const SealApproveSchema = SealIdSchema.extend({
169
+ open: z.string().min(1).describe("Which opening."),
170
+ agree: z.boolean(),
171
+ });
172
+ export type SealApprove = z.infer<typeof SealApproveSchema>;
173
+
174
+ /** The document's text as it is signed and sent. */
175
+ export const sealOpenDocumentText = (document: SealOpenDocument): string => JSON.stringify(document);
@@ -68,10 +68,12 @@ export const claudeExperimentSettings = {
68
68
  ),
69
69
  };
70
70
 
71
+ // On for new sandboxes from 2026-11-04; one from before keeps it off unless its owner switched it on (the daemon's
72
+ // settings-store.ts pins the old default, settings/earlier-defaults-step.ts writes it down where never saved).
71
73
  export const iqSearchSettings = {
72
74
  iqSearch: z
73
75
  .boolean()
74
- .default(false)
76
+ .default(true)
75
77
  .describe("Teach the agent how to use this workspace's own search tool, rather than leaving it to grep around."),
76
78
  iqSearchHoldout: z
77
79
  .number()
@@ -15,6 +15,13 @@ describe(`which built-in stands at which moment`, () => {
15
15
  expect(rule(`turn.ending`, { kind: `builtin`, name: `version-landed` }).success).toBe(false);
16
16
  });
17
17
 
18
+ // It pushes what the versioner committed, which only the landed moment has.
19
+ test(`the back-up stands at the landed moment and nowhere else`, () => {
20
+ expect(rule(`agent.landed`, { kind: `builtin`, name: `push-landed` }).success).toBe(true);
21
+ expect(rule(`agent.finished`, { kind: `builtin`, name: `push-landed` }).success).toBe(false);
22
+ expect(rule(`turn.ending`, { kind: `builtin`, name: `push-landed` }).success).toBe(false);
23
+ });
24
+
18
25
  test(`the look stands at the turn's end and not at the landing`, () => {
19
26
  expect(rule(`turn.ending`, { kind: `builtin`, name: `verify-ui-edits` }).success).toBe(true);
20
27
  expect(rule(`agent.landed`, { kind: `builtin`, name: `verify-ui-edits` }).success).toBe(false);
@@ -218,6 +225,15 @@ test("disk retention defaults bound checkouts and restore points while preservin
218
225
  expect(existing.retention.restorePointKeepDays).toBe(0);
219
226
  });
220
227
 
228
+ test("build output defaults: six idle hours, reaping under 15% free, full debug info", () => {
229
+ const defaults = SandboxSettingsSchema.parse({});
230
+ expect(defaults.buildOutputIdleHours).toBe(6);
231
+ expect(defaults.diskReapBelowPercent).toBe(15);
232
+ expect(defaults.leanRustBuilds).toBe(false);
233
+ expect(SandboxSettingsSchema.safeParse({ buildOutputIdleHours: 0 }).success).toBe(false);
234
+ expect(SandboxSettingsSchema.safeParse({ diskReapBelowPercent: 4 }).success).toBe(false);
235
+ });
236
+
221
237
  describe(`restore points' retention, renamed so a stored zero is the owner's own (2026-10-18)`, () => {
222
238
  const read = (retention: Record<string, unknown>) => {
223
239
  const converted = convertDocument(SETTINGS_HISTORY, `object`, { retention: { transcriptDays: 7, ...retention } }, true);