@intentic/sandbox-contract 1.423.0 → 1.425.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 (224) hide show
  1. package/dist/contracts/access-profiles.contract.d.ts +7 -3
  2. package/dist/contracts/access-profiles.contract.d.ts.map +1 -1
  3. package/dist/contracts/agent.contract.d.ts +51 -10
  4. package/dist/contracts/agent.contract.d.ts.map +1 -1
  5. package/dist/contracts/agent.contract.js +1 -1
  6. package/dist/contracts/agent.contract.js.map +1 -1
  7. package/dist/contracts/agents.contract.d.ts +13 -5
  8. package/dist/contracts/agents.contract.d.ts.map +1 -1
  9. package/dist/contracts/agents.contract.js +1 -1
  10. package/dist/contracts/agents.contract.js.map +1 -1
  11. package/dist/contracts/approvals.contract.d.ts +1 -1
  12. package/dist/contracts/needs.contract.d.ts +41 -26
  13. package/dist/contracts/needs.contract.d.ts.map +1 -1
  14. package/dist/contracts/needs.contract.js +2 -2
  15. package/dist/contracts/needs.contract.js.map +1 -1
  16. package/dist/contracts/org.contract.d.ts +3 -0
  17. package/dist/contracts/org.contract.d.ts.map +1 -1
  18. package/dist/contracts/{personas.contract.d.ts → roles.contract.d.ts} +3 -39
  19. package/dist/contracts/roles.contract.d.ts.map +1 -0
  20. package/dist/contracts/roles.contract.js +78 -0
  21. package/dist/contracts/roles.contract.js.map +1 -0
  22. package/dist/contracts/runner.contract.d.ts +276 -252
  23. package/dist/contracts/runner.contract.d.ts.map +1 -1
  24. package/dist/contracts/seal.contract.d.ts +1 -25
  25. package/dist/contracts/seal.contract.d.ts.map +1 -1
  26. package/dist/contracts/seal.contract.js +3 -14
  27. package/dist/contracts/seal.contract.js.map +1 -1
  28. package/dist/contracts/sessions.contract.d.ts +5 -1
  29. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  30. package/dist/contracts/settings.contract.d.ts +2 -2
  31. package/dist/contracts/skills.contract.d.ts +3 -3
  32. package/dist/contracts/skills.contract.js +1 -1
  33. package/dist/contracts/skills.contract.js.map +1 -1
  34. package/dist/contracts/system.contract.d.ts +11 -16
  35. package/dist/contracts/system.contract.d.ts.map +1 -1
  36. package/dist/events/agent-events.d.ts +20 -4
  37. package/dist/events/agent-events.d.ts.map +1 -1
  38. package/dist/events/agent-transcript.d.ts +5 -1
  39. package/dist/events/agent-transcript.d.ts.map +1 -1
  40. package/dist/events/system-events.d.ts +7 -7
  41. package/dist/events/system-events.d.ts.map +1 -1
  42. package/dist/events/system-events.js +3 -3
  43. package/dist/events/system-events.js.map +1 -1
  44. package/dist/events/transcript.d.ts +25 -5
  45. package/dist/events/transcript.d.ts.map +1 -1
  46. package/dist/index.d.ts +2 -2
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +2 -2
  49. package/dist/index.js.map +1 -1
  50. package/dist/models/model-roles.d.ts +1 -1
  51. package/dist/models/model-roles.d.ts.map +1 -1
  52. package/dist/models/model-roles.js +1 -1
  53. package/dist/models/model-roles.js.map +1 -1
  54. package/dist/policy/org-locks.d.ts +1 -1
  55. package/dist/policy/org-locks.d.ts.map +1 -1
  56. package/dist/policy/org-locks.js +1 -1
  57. package/dist/policy/org-locks.js.map +1 -1
  58. package/dist/policy/role-capability.d.ts +7 -0
  59. package/dist/policy/role-capability.d.ts.map +1 -0
  60. package/dist/policy/role-capability.js +3 -0
  61. package/dist/policy/role-capability.js.map +1 -0
  62. package/dist/policy/role-home.d.ts +9 -0
  63. package/dist/policy/role-home.d.ts.map +1 -0
  64. package/dist/policy/role-home.js +7 -0
  65. package/dist/policy/role-home.js.map +1 -0
  66. package/dist/protocol/member-reach.d.ts +4 -4
  67. package/dist/protocol/member-reach.js +3 -3
  68. package/dist/protocol/raw/raw-json-routes.d.ts +29 -23
  69. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  70. package/dist/protocol/route-meta.d.ts +4 -4
  71. package/dist/schemas/access-profiles.d.ts +10 -4
  72. package/dist/schemas/access-profiles.d.ts.map +1 -1
  73. package/dist/schemas/access-profiles.js +9 -4
  74. package/dist/schemas/access-profiles.js.map +1 -1
  75. package/dist/schemas/agent.js +3 -3
  76. package/dist/schemas/agent.js.map +1 -1
  77. package/dist/schemas/agents.js +2 -2
  78. package/dist/schemas/agents.js.map +1 -1
  79. package/dist/schemas/approvals.d.ts +3 -3
  80. package/dist/schemas/approvals.js +3 -3
  81. package/dist/schemas/approvals.js.map +1 -1
  82. package/dist/schemas/automations.js +6 -6
  83. package/dist/schemas/automations.js.map +1 -1
  84. package/dist/schemas/chat-route.d.ts +7 -2
  85. package/dist/schemas/chat-route.d.ts.map +1 -1
  86. package/dist/schemas/chat-route.js +11 -6
  87. package/dist/schemas/chat-route.js.map +1 -1
  88. package/dist/schemas/context-trim.js +1 -1
  89. package/dist/schemas/context-trim.js.map +1 -1
  90. package/dist/schemas/diagnostics.d.ts +3 -3
  91. package/dist/schemas/git/git.js +1 -1
  92. package/dist/schemas/git/git.js.map +1 -1
  93. package/dist/schemas/links.d.ts +1 -1
  94. package/dist/schemas/links.js +4 -4
  95. package/dist/schemas/links.js.map +1 -1
  96. package/dist/schemas/loops.js +1 -1
  97. package/dist/schemas/loops.js.map +1 -1
  98. package/dist/schemas/members.d.ts +162 -20
  99. package/dist/schemas/members.d.ts.map +1 -1
  100. package/dist/schemas/members.js +19 -16
  101. package/dist/schemas/members.js.map +1 -1
  102. package/dist/schemas/needs.d.ts +37 -42
  103. package/dist/schemas/needs.d.ts.map +1 -1
  104. package/dist/schemas/needs.js +18 -16
  105. package/dist/schemas/needs.js.map +1 -1
  106. package/dist/schemas/organisation.d.ts +10 -0
  107. package/dist/schemas/organisation.d.ts.map +1 -1
  108. package/dist/schemas/organisation.js.map +1 -1
  109. package/dist/schemas/{personas.d.ts → roles.d.ts} +37 -72
  110. package/dist/schemas/roles.d.ts.map +1 -0
  111. package/dist/schemas/{personas.js → roles.js} +45 -67
  112. package/dist/schemas/roles.js.map +1 -0
  113. package/dist/schemas/seal.d.ts +2 -21
  114. package/dist/schemas/seal.d.ts.map +1 -1
  115. package/dist/schemas/seal.js +1 -16
  116. package/dist/schemas/seal.js.map +1 -1
  117. package/dist/schemas/settings-history.d.ts +1 -1
  118. package/dist/schemas/settings-history.d.ts.map +1 -1
  119. package/dist/schemas/settings-history.js +2 -1
  120. package/dist/schemas/settings-history.js.map +1 -1
  121. package/dist/schemas/settings.d.ts +11 -11
  122. package/dist/schemas/settings.d.ts.map +1 -1
  123. package/dist/schemas/settings.js +3 -3
  124. package/dist/schemas/settings.js.map +1 -1
  125. package/dist/schemas/shared.d.ts +6 -5
  126. package/dist/schemas/shared.d.ts.map +1 -1
  127. package/dist/schemas/shared.js +14 -5
  128. package/dist/schemas/shared.js.map +1 -1
  129. package/dist/schemas/system-prompt.d.ts +12 -12
  130. package/dist/schemas/system-prompt.d.ts.map +1 -1
  131. package/dist/schemas/system-prompt.js +1 -1
  132. package/dist/schemas/system-prompt.js.map +1 -1
  133. package/dist/schemas/terminal.d.ts +18 -0
  134. package/dist/schemas/terminal.d.ts.map +1 -1
  135. package/dist/schemas/terminal.js +16 -1
  136. package/dist/schemas/terminal.js.map +1 -1
  137. package/dist/schemas/tool-ceiling.d.ts +4 -2
  138. package/dist/schemas/tool-ceiling.d.ts.map +1 -1
  139. package/dist/schemas/tool-ceiling.js +29 -3
  140. package/dist/schemas/tool-ceiling.js.map +1 -1
  141. package/dist/schemas/workflows.js +1 -1
  142. package/dist/schemas/workflows.js.map +1 -1
  143. package/dist/state/definition.d.ts +4 -4
  144. package/dist/state/workspace-state.d.ts +4 -4
  145. package/dist/state/workspace-state.d.ts.map +1 -1
  146. package/dist/state/workspace-state.js +2 -2
  147. package/dist/state/workspace-state.js.map +1 -1
  148. package/package.json +5 -5
  149. package/src/contracts/agent.contract.ts +2 -2
  150. package/src/contracts/agents.contract.ts +1 -1
  151. package/src/contracts/automations.contract.ts +1 -1
  152. package/src/contracts/logs.contract.ts +1 -1
  153. package/src/contracts/needs.contract.ts +2 -2
  154. package/src/contracts/roles.contract.ts +108 -0
  155. package/src/contracts/seal.contract.ts +3 -18
  156. package/src/contracts/skills.contract.ts +2 -2
  157. package/src/events/system-events.ts +5 -4
  158. package/src/index.ts +3 -3
  159. package/src/models/agent-runtimes.ts +8 -8
  160. package/src/models/model-roles.ts +3 -3
  161. package/src/policy/control-scopes.ts +1 -1
  162. package/src/policy/fence-paths.ts +2 -2
  163. package/src/policy/org-locks.ts +2 -1
  164. package/src/policy/role-capability.ts +29 -0
  165. package/src/policy/role-home.ts +29 -0
  166. package/src/policy/tests/fence-paths.test.ts +1 -1
  167. package/src/policy/tests/role-home.test.ts +40 -0
  168. package/src/protocol/member-reach.test.ts +17 -17
  169. package/src/protocol/member-reach.ts +7 -7
  170. package/src/protocol/route-meta.ts +6 -6
  171. package/src/schemas/access-profiles.ts +20 -9
  172. package/src/schemas/agent.ts +4 -4
  173. package/src/schemas/agents.ts +2 -2
  174. package/src/schemas/approvals.ts +3 -3
  175. package/src/schemas/automations.ts +14 -14
  176. package/src/schemas/capabilities.ts +1 -1
  177. package/src/schemas/chat-route.ts +18 -9
  178. package/src/schemas/context-trim.ts +1 -1
  179. package/src/schemas/diagnostics.ts +1 -1
  180. package/src/schemas/git/git.ts +1 -1
  181. package/src/schemas/internal.ts +1 -1
  182. package/src/schemas/links.ts +7 -7
  183. package/src/schemas/loops.ts +1 -1
  184. package/src/schemas/members.test.ts +31 -31
  185. package/src/schemas/members.ts +37 -29
  186. package/src/schemas/needs.ts +35 -22
  187. package/src/schemas/organisation.ts +2 -0
  188. package/src/schemas/{personas.ts → roles.ts} +83 -113
  189. package/src/schemas/seal.ts +5 -30
  190. package/src/schemas/settings-history.ts +3 -1
  191. package/src/schemas/settings.ts +10 -6
  192. package/src/schemas/shared.ts +24 -10
  193. package/src/schemas/state-plan.test.ts +3 -3
  194. package/src/schemas/system-prompt.ts +2 -1
  195. package/src/schemas/terminal.ts +18 -1
  196. package/src/schemas/tool-ceiling.test.ts +14 -8
  197. package/src/schemas/tool-ceiling.ts +42 -11
  198. package/src/schemas/workflows.ts +1 -1
  199. package/src/state/auth-state.ts +1 -1
  200. package/src/state/definition.ts +1 -1
  201. package/src/state/workspace-state.test.ts +5 -5
  202. package/src/state/workspace-state.ts +11 -11
  203. package/dist/contracts/personas.contract.d.ts.map +0 -1
  204. package/dist/contracts/personas.contract.js +0 -78
  205. package/dist/contracts/personas.contract.js.map +0 -1
  206. package/dist/policy/persona-capability.d.ts +0 -14
  207. package/dist/policy/persona-capability.d.ts.map +0 -1
  208. package/dist/policy/persona-capability.js +0 -24
  209. package/dist/policy/persona-capability.js.map +0 -1
  210. package/dist/policy/persona-home.d.ts +0 -10
  211. package/dist/policy/persona-home.d.ts.map +0 -1
  212. package/dist/policy/persona-home.js +0 -11
  213. package/dist/policy/persona-home.js.map +0 -1
  214. package/dist/schemas/personas.d.ts.map +0 -1
  215. package/dist/schemas/personas.js.map +0 -1
  216. package/dist/schemas/seal-proof.d.ts +0 -20
  217. package/dist/schemas/seal-proof.d.ts.map +0 -1
  218. package/dist/schemas/seal-proof.js +0 -8
  219. package/dist/schemas/seal-proof.js.map +0 -1
  220. package/src/contracts/personas.contract.ts +0 -106
  221. package/src/policy/persona-capability.ts +0 -64
  222. package/src/policy/persona-home.ts +0 -39
  223. package/src/policy/tests/persona-home.test.ts +0 -51
  224. package/src/schemas/seal-proof.ts +0 -12
@@ -22,6 +22,8 @@ export const ORG_SECTIONS = [
22
22
  "extensions",
23
23
  "access",
24
24
  "areas",
25
+ // The Roles section. Its id predates the name (personas were renamed roles on 2026-11-18) and stays: organisations'
26
+ // stored policies name it, and a daemon from before reads a section it does not know as a broken policy.
25
27
  "personas",
26
28
  "updates",
27
29
  ] as const;
@@ -1,19 +1,18 @@
1
- // The named faces a sandbox shows the outside world: which accounts each speaks for, what a session wearing one may do,
2
- // and where it works.
1
+ // The named faces a sandbox shows the outside world: which accounts each speaks for, where it works, what it is told and
2
+ // what it runs on. What a conversation wearing one may reach is access, not the card (docs/architecture/access.md).
3
3
  import { z } from "zod";
4
4
  import { type ModelSource, readyChain } from "../models/model-pins.js";
5
5
  import { type ModelPin, ModelPinSchema } from "./agent.js";
6
6
  import { entryId } from "./internal.js";
7
7
  import { SkillDraftSchema, SkillNameSchema, SYSTEM_PROMPT_MAX, SystemPromptModeSchema } from "./settings.js";
8
- // A named face the sandbox shows outward: who it speaks as, what it may do, where it works, what it's told, what it
9
- // runs on. No credential lives on the card; accounts stay private, per-sandbox. POSTURE, NOT ACCESS
10
- // (docs/architecture/access.md): what a turn may reach is decided by who it acts for, the people in its conversation
11
- // or the service an unattended run acts as, each held to an access profile. A card only narrows inside that, for a
12
- // watched chat and an unattended run alike, and never widens it.
13
- // Narrowing is enforced by absence (`connectors`/`devices`/`mcp`: no credential injected) or by removing tools from
14
- // context; `shell` decides, since with it a session can reach anything else fenced off, turning the rest into defaults,
15
- // not limits. Absent `powers` means the full toolbox, inside whatever the principals allow.
16
- export const PersonaPowersSchema = z.object({
8
+ import { ceilingWords, ExtensionIdSchema, intersectCeilings, type ToolCeiling } from "./tool-ceiling.js";
9
+ // THE SHELVES A TURN HOLDS, fully resolved: no card carries them any more. A card's limits are an access profile that
10
+ // lists it (schemas/access-profiles.ts `roles`), held like every other limit in the principal chain, so a turn's shelves
11
+ // are the full toolbox under the ceiling of everything it acts for, its role's profile included (roles.ts
12
+ // `turnRole`, `capRole` in the daemon). Kept as one shape because every runtime reads a turn's shelves from it.
13
+ // Narrowing is enforced by absence (no credential injected) or by removing tools from context; `shell` decides, since
14
+ // with it a session can reach anything else fenced off, turning the rest into defaults, not limits.
15
+ export const RolePowersSchema = z.object({
17
16
  // "read" is look-and-search only; "write" adds creating and changing; "none" removes both.
18
17
  files: z
19
18
  .enum(["none", "read", "write"])
@@ -39,55 +38,40 @@ export const PersonaPowersSchema = z.object({
39
38
  // Sandbox settings, manifests, and the public outbox; enforced as a path refusal, not a tool switch — there's no
40
39
  // such tool to remove.
41
40
  sandbox: z.boolean().default(true),
42
- // By id; absent means every one of them (an untouched card's default), empty means none — a tri-state that is why
43
- // these are optional arrays, not defaulted ones.
44
- connectors: z.array(entryId).max(100).optional(),
45
- devices: z.array(entryId).max(50).optional(),
46
- mcp: z.array(entryId).max(50).optional(),
47
- // By extension id (`publisher.name`, or a git install's card id), the same tri-state. A card an extension serves
48
- // rides `connectors`; this is what the extension brings of its own.
41
+ // By extension id (`publisher.name`, or a git install's card id): absent means every enabled one, empty means none.
42
+ // Resolved from the access the turn runs under (tool-ceiling.ts `extensions`). Which connectors, devices and servers
43
+ // it gets is decided by its credential reach, never by these shelves (secrets/credential-reach.ts in the daemon).
49
44
  extensions: z
50
- .array(
51
- z
52
- .string()
53
- .min(1)
54
- .max(121)
55
- .regex(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/),
56
- )
45
+ .array(ExtensionIdSchema)
57
46
  .max(100)
58
47
  .optional()
59
48
  .describe(
60
- "Which extensions' own agent tools and agent plugin (skills, commands, subagents) it gets, by extension id. Absent means every enabled one; empty means none. The tools an extension serves for a connected card follow the connectors list instead.",
49
+ "Which extensions' own agent tools and agent plugin (skills, commands, subagents) it gets, by extension id. Absent means every enabled one; empty means none. The tools an extension serves for a connected card follow that card's credential instead.",
61
50
  ),
62
51
  });
63
- export type PersonaPowers = z.infer<typeof PersonaPowersSchema>;
64
- // `folders` only refuses file-tool calls outside it; it stops a misread instruction, not a shell. The container is the
65
- // real workspace-wide fence, and a conversation started by a fenced person is narrower still — the turn works inside
66
- // this persona's folders AND that person's areas, never the wider of the two.
67
- // A plain folder list rather than a named area (schemas/areas.ts), because the two answer different questions: a
68
- // persona's fence is written once for that persona, while an area is a grant several people hold and one edit has to
69
- // move all of them.
52
+ export type RolePowers = z.infer<typeof RolePowersSchema>;
53
+ // Where a conversation wearing the card opens. Which folders it may touch is access: the areas of a profile that lists the
54
+ // card (2026-11-18: `folders` left the card for that, carried into a profile by roles/role-access-step.ts).
70
55
  // No placement field, by decision: every session already opens in its own private copy, never the shared tree.
71
- export const PersonaWorkspaceSchema = z.object({
56
+ export const RoleWorkspaceSchema = z.object({
72
57
  // Absent means the workspace root.
73
58
  startIn: z.string().max(200).optional().describe("Which folder a conversation opens in."),
74
- folders: z.array(z.string().min(1)).max(50).optional().describe("Which folders it may touch at all. Absent means the whole workspace."),
75
59
  });
76
- export type PersonaWorkspace = z.infer<typeof PersonaWorkspaceSchema>;
77
- // Which nested repos a checkout holds, distinct from `workspace.folders` (what file tools may touch inside it). The
60
+ export type RoleWorkspace = z.infer<typeof RoleWorkspaceSchema>;
61
+ // Which nested repos a checkout holds, distinct from the areas its access fences file tools to. The
78
62
  // root repo is always carried, never listed; absent means every repository. An object, not a list, for future sibling
79
63
  // fields.
80
- export const PersonaContextSchema = z.object({
64
+ export const RoleContextSchema = z.object({
81
65
  repos: z
82
66
  .array(z.string().min(1).max(200))
83
67
  .max(50)
84
68
  .describe(
85
- "Which nested repositories a conversation on this persona carries, by workspace-relative path. The workspace itself is always carried; empty means the workspace alone.",
69
+ "Which nested repositories a conversation on this role carries, by workspace-relative path. The workspace itself is always carried; empty means the workspace alone.",
86
70
  ),
87
71
  });
88
- export type PersonaContext = z.infer<typeof PersonaContextSchema>;
72
+ export type RoleContext = z.infer<typeof RoleContextSchema>;
89
73
  // What the sandbox puts in front of a user's message before the model reads it — the rows the chat shows under "Sent
90
- // with your message" — and which of them a persona card may drop. The vocabulary lives beside the card because the card
74
+ // with your message" — and which of them a role card may drop. The vocabulary lives beside the card because the card
91
75
  // editor has to name the same rows the transcript does, and two lists would drift into two vocabularies for one thing.
92
76
  // Ids, not titles, are what a card stores: a title is display text and gets reworded, and a reworded title must not
93
77
  // silently switch a note back on. The daemon maps each id to the titles it covers (agent/prompt/turn-briefing.ts).
@@ -190,23 +174,23 @@ export const TURN_BRIEFING_FIXTURES: readonly TurnBriefingFixture[] = [
190
174
  // What the sandbox tells a turn before the user's own words (the notes above). A deny list, not a pick list:
191
175
  // an id absent from `omit` is sent, so a note added later rides every card that never said otherwise. An object, like
192
176
  // `context`, for future sibling fields.
193
- export const PersonaBriefingSchema = z.object({
177
+ export const RoleBriefingSchema = z.object({
194
178
  omit: z
195
179
  .array(TurnBriefingNoteIdSchema)
196
180
  .max(20)
197
181
  .describe(
198
- "Which of the notes the sandbox prepends to each message a conversation on this persona does NOT get. Everything not named here is sent as usual; the notes that keep a turn inside its own branch or explain a missing account cannot be named at all.",
182
+ "Which of the notes the sandbox prepends to each message a conversation on this role does NOT get. Everything not named here is sent as usual; the notes that keep a turn inside its own branch or explain a missing account cannot be named at all.",
199
183
  ),
200
184
  });
201
- export type PersonaBriefing = z.infer<typeof PersonaBriefingSchema>;
202
- export const PersonaSchema = z.object({
203
- id: entryId.describe("The persona's id."),
185
+ export type RoleBriefing = z.infer<typeof RoleBriefingSchema>;
186
+ export const RoleSchema = z.object({
187
+ id: entryId.describe("The role's id."),
204
188
  label: z.string().max(60).optional().describe("What to call it on screen. Absent falls back to the id, which somebody chose anyway."),
205
189
  capabilities: z
206
190
  .array(entryId)
207
191
  .max(50)
208
192
  .describe(
209
- "Which connected accounts it speaks through. Named individually rather than by site, because two accounts on one site is the whole problem this solves. It narrows: an account here is still reached only when whoever the turn acts for may use it. Naming one that is not connected yet is not an error: it is a card describing an account this sandbox has still to sign into.",
193
+ "Which signed-in accounts it speaks through: who it is to the outside world, the one thing a card decides about reach. Named individually rather than by site, because two accounts on one site is the whole problem this solves. An account here is still reached only when whoever the turn acts for may use it. Naming one that is not connected yet is not an error: it is a card describing an account this sandbox has still to sign into.",
210
194
  ),
211
195
  // Owner-written, not derived: a classifier routes better on prose than on a list of account ids. Absent, the router
212
196
  // has less to go on but still tries.
@@ -215,17 +199,14 @@ export const PersonaSchema = z.object({
215
199
  .max(200)
216
200
  .optional()
217
201
  .describe(
218
- "What this persona is for, in one line. A new chat is routed onto a persona by this sentence, and the Personas page shows it under the name.",
202
+ "What this role is for, in one line. A new chat is routed onto a role by this sentence, and the Roles page shows it under the name.",
219
203
  ),
220
- powers: PersonaPowersSchema.optional().describe(
221
- "What a conversation wearing it may do, inside what whoever it acts for may. Absent means the full toolbox, so a card written before this existed behaves exactly as it did.",
222
- ),
223
- workspace: PersonaWorkspaceSchema.optional().describe("Where it works. Absent means the whole workspace."),
224
- context: PersonaContextSchema.optional().describe(
204
+ workspace: RoleWorkspaceSchema.optional().describe("Where a conversation wearing it opens. Absent means the workspace root."),
205
+ context: RoleContextSchema.optional().describe(
225
206
  "Which part of the workspace a conversation wearing it carries: the repositories its checkout holds. Absent means every repository.",
226
207
  ),
227
208
  // Sits beside `context` on purpose: one says what the tree holds, the other what the turn is handed about it.
228
- briefing: PersonaBriefingSchema.optional().describe(
209
+ briefing: RoleBriefingSchema.optional().describe(
229
210
  "Which of the notes the sandbox prepends to every message this card's conversations do without. Absent means all of them, which is what a card written before this existed keeps.",
230
211
  ),
231
212
  // Ladder shape (a single pin is a single point of failure); picking the card moves the composer's model pill to its
@@ -242,88 +223,77 @@ export const PersonaSchema = z.object({
242
223
  // prompt.
243
224
  systemPromptMode: SystemPromptModeSchema.optional(),
244
225
  });
245
- export type Persona = z.infer<typeof PersonaSchema>;
226
+ export type Role = z.infer<typeof RoleSchema>;
246
227
  // Ladder filtered to connected providers, deduplicated. Empty (absent, or every provider disconnected) means the card
247
228
  // has no opinion — the caller decides, not "run nothing".
248
- export const personaModels = (card: Pick<Persona, "models">, sources: readonly ModelSource[]): readonly ModelPin[] =>
229
+ export const roleModels = (card: Pick<Role, "models">, sources: readonly ModelSource[]): readonly ModelPin[] =>
249
230
  readyChain(sources, card.models ?? []);
250
- // Which persona a new chat belongs to is asked with what it runs on, in one reading: chat-route.ts.
251
- // The one stock persona id; lives here because the daemon and the automations form are separate packages that must
231
+ // Which role a new chat belongs to is asked with what it runs on, in one reading: chat-route.ts.
232
+ // The one stock role id; lives here because the daemon and the automations form are separate packages that must
252
233
  // agree on it exactly, or a Visitor chat pins to a card nobody creates.
253
- export const VISITOR_CHAT_PERSONA = "visitor-chat";
254
- // THE TWO BUILT-IN PERSONAS, postures like any card: every turn wears one, and a turn naming no card wears one of these,
255
- // picked by whether a person is watching (personas.ts `turnPersona` in the daemon). They are constants rather than cards
256
- // in personas.json: that file is tracked in git, and "every account" is not something a card's account list can say,
234
+ export const VISITOR_CHAT_ROLE = "visitor-chat";
235
+ // THE TWO BUILT-IN ROLES, postures like any card: every turn wears one, and a turn naming no card wears one of these,
236
+ // picked by whether a person is watching (roles.ts `turnRole` in the daemon). They are constants rather than cards
237
+ // in roles.json: that file is tracked in git, and "every account" is not something a card's account list can say,
257
238
  // since the list is written once and accounts are connected later. Neither can be edited or removed, and no card may
258
239
  // take either id. Both stay inside what the turn's principals may (docs/architecture/access.md): "every account" is
259
240
  // every account they may use.
260
- // Full access: every tool and every signed-in account, what a chat a person starts without picking anyone acts as.
261
- export const FULL_ACCESS_PERSONA = "full-access";
262
- // No accounts: every tool but no signed-in account, what a run nobody watches acts as when it names no one, since
241
+ // All accounts: every signed-in account, what a chat a person starts without picking anyone acts as. Its id predates
242
+ // the label (it was "Full access" until 2026-11-18, a name the Full access tier of a person's access also carries) and
243
+ // is stored on automations, sender rules and links, so it stays.
244
+ export const FULL_ACCESS_ROLE = "full-access";
245
+ // No accounts: no signed-in account, what a run nobody watches acts as when it names no one, since
263
246
  // whatever woke it may have put somebody else's words in its prompt.
264
- export const NO_ACCOUNTS_PERSONA = "no-accounts";
265
- export type BuiltInPersonaId = typeof FULL_ACCESS_PERSONA | typeof NO_ACCOUNTS_PERSONA;
266
- export interface BuiltInPersona {
267
- readonly id: BuiltInPersonaId;
247
+ export const NO_ACCOUNTS_ROLE = "no-accounts";
248
+ export type BuiltInRoleId = typeof FULL_ACCESS_ROLE | typeof NO_ACCOUNTS_ROLE;
249
+ export interface BuiltInRole {
250
+ readonly id: BuiltInRoleId;
268
251
  // English, for the daemon's own words (a turn's standing, its notes); every screen says it through its own catalog.
269
252
  readonly label: string;
270
253
  // Whether its turns reach the sandbox's signed-in accounts: all of them, or none.
271
254
  readonly accounts: "all" | "none";
272
255
  }
273
- const FULL_ACCESS: BuiltInPersona = { id: FULL_ACCESS_PERSONA, label: "Full access", accounts: "all" };
274
- const NO_ACCOUNTS: BuiltInPersona = { id: NO_ACCOUNTS_PERSONA, label: "No accounts", accounts: "none" };
275
- export const BUILT_IN_PERSONAS: readonly BuiltInPersona[] = [FULL_ACCESS, NO_ACCOUNTS];
276
- export const isBuiltInPersona = (id: string | undefined): id is BuiltInPersonaId => id === FULL_ACCESS_PERSONA || id === NO_ACCOUNTS_PERSONA;
277
- export const builtInPersona = (id: BuiltInPersonaId): BuiltInPersona => (id === FULL_ACCESS_PERSONA ? FULL_ACCESS : NO_ACCOUNTS);
278
- // Who a turn naming no card acts as: Full access with a person watching, No accounts without.
279
- export const defaultPersona = (unattended: boolean): BuiltInPersonaId => (unattended ? NO_ACCOUNTS_PERSONA : FULL_ACCESS_PERSONA);
280
- // An unwatched run's persona pick with No accounts read as no pick: an unwatched turn naming none wears No accounts
256
+ const FULL_ACCESS: BuiltInRole = { id: FULL_ACCESS_ROLE, label: "All accounts", accounts: "all" };
257
+ const NO_ACCOUNTS: BuiltInRole = { id: NO_ACCOUNTS_ROLE, label: "No accounts", accounts: "none" };
258
+ export const BUILT_IN_ROLES: readonly BuiltInRole[] = [FULL_ACCESS, NO_ACCOUNTS];
259
+ export const isBuiltInRole = (id: string | undefined): id is BuiltInRoleId => id === FULL_ACCESS_ROLE || id === NO_ACCOUNTS_ROLE;
260
+ export const builtInRole = (id: BuiltInRoleId): BuiltInRole => (id === FULL_ACCESS_ROLE ? FULL_ACCESS : NO_ACCOUNTS);
261
+ // Who a turn naming no card acts as: All accounts with a person watching, No accounts without.
262
+ export const defaultRole = (unattended: boolean): BuiltInRoleId => (unattended ? NO_ACCOUNTS_ROLE : FULL_ACCESS_ROLE);
263
+ // An unwatched run's role pick with No accounts read as no pick: an unwatched turn naming none wears No accounts
281
264
  // anyway, so the two are one choice, and a form shows them as one row.
282
- export const unwatchedPick = (actsAs: string | undefined): string | undefined => (actsAs === NO_ACCOUNTS_PERSONA ? undefined : actsAs);
283
- // One phrase describing how bounded a card is, shared so the Personas page and the automation picker can't grow
284
- // different vocabularies for the same card. "Read-only"/"no shell" are named; everything else collapses to a count.
285
- export const personaBounds = (persona: Persona): string => {
286
- const powers = persona.powers;
287
- if (powers === undefined) {
288
- return "Full powers";
289
- }
290
- const resolved = PersonaPowersSchema.parse(powers);
291
- if (resolved.files === "read" && !resolved.shell) {
265
+ export const unwatchedPick = (actsAs: string | undefined): string | undefined => (actsAs === NO_ACCOUNTS_ROLE ? undefined : actsAs);
266
+ // One phrase describing how bounded a card is, from the access profiles that list it (schemas/access-profiles.ts
267
+ // `roles`), shared so the Roles page and the automation picker can't grow different vocabularies for the same card.
268
+ // "Read-only"/"no shell" are named; everything else collapses to a count.
269
+ export const roleBounds = (held: readonly { readonly tools?: ToolCeiling | undefined; readonly areas?: readonly string[] | undefined; readonly credentials?: unknown }[]): string => {
270
+ const ceiling = held.reduce<ToolCeiling | undefined>((at, profile) => intersectCeilings(at, profile.tools), undefined);
271
+ if (ceiling?.files === "read" && ceiling.shell === false) {
292
272
  return "Read-only";
293
273
  }
294
- if (!resolved.shell) {
274
+ if (ceiling?.shell === false) {
295
275
  return "No shell";
296
276
  }
297
- const limits = [
298
- resolved.files === "none",
299
- !resolved.code,
300
- !resolved.web,
301
- !resolved.browser,
302
- !resolved.delegate,
303
- !resolved.sandbox,
304
- resolved.connectors !== undefined,
305
- resolved.devices !== undefined,
306
- resolved.mcp !== undefined,
307
- ].filter(Boolean).length;
277
+ const limits = ceilingWords(ceiling).length + (held.some((profile) => profile.areas !== undefined) ? 1 : 0) + (held.some((profile) => profile.credentials !== undefined) ? 1 : 0);
308
278
  return limits === 0 ? "Full powers" : `${limits} limit${limits === 1 ? "" : "s"}`;
309
279
  };
310
- export const PersonaIdParamSchema = z.object({ id: entryId.describe("Which persona.") });
311
- // `connected` is what makes a freshly cloned workspace honest: every persona shows even though most can't act yet. An
280
+ export const RoleIdParamSchema = z.object({ id: entryId.describe("Which role.") });
281
+ // `connected` is what makes a freshly cloned workspace honest: every role shows even though most can't act yet. An
312
282
  // id with no capability at all is `connected: false` too.
313
- export const PersonasListSchema = z.object({
314
- personas: z.array(PersonaSchema).describe("The characters an agent can wear."),
283
+ export const RolesListSchema = z.object({
284
+ roles: z.array(RoleSchema).describe("The characters an agent can wear."),
315
285
  connected: z
316
286
  .array(z.string())
317
287
  .describe(
318
- "Which accounts are actually connected right now, so a persona naming one that has since been disconnected can be shown as broken rather than as working.",
288
+ "Which accounts are actually connected right now, so a role naming one that has since been disconnected can be shown as broken rather than as working.",
319
289
  ),
320
290
  });
321
291
  // One route for the kit's prompt and skills, one folder and one screen. Skills come back as name/description only; an
322
292
  // empty prompt means no PROMPT.md yet, sent as "" since the field is a textarea.
323
- export const PersonaKitSchema = z.object({
293
+ export const RoleKitSchema = z.object({
324
294
  prompt: z
325
295
  .string()
326
- .describe("What this persona is told, on top of everything else. Empty means it simply follows the sandbox's own instructions."),
296
+ .describe("What this role is told, on top of everything else. Empty means it simply follows the sandbox's own instructions."),
327
297
  skills: z
328
298
  .array(
329
299
  z.object({
@@ -332,22 +302,22 @@ export const PersonaKitSchema = z.object({
332
302
  }),
333
303
  )
334
304
  .describe(
335
- "Skills only this persona's conversations can reach. A different question from what the agent knows generally, with a different answer.",
305
+ "Skills only this role's conversations can reach. A different question from what the agent knows generally, with a different answer.",
336
306
  ),
337
307
  });
338
- export type PersonaKit = z.infer<typeof PersonaKitSchema>;
339
- export const PersonaPromptSchema = PersonaIdParamSchema.extend({
308
+ export type RoleKit = z.infer<typeof RoleKitSchema>;
309
+ export const RolePromptSchema = RoleIdParamSchema.extend({
340
310
  prompt: z
341
311
  .string()
342
312
  .max(SYSTEM_PROMPT_MAX)
343
313
  .describe(
344
- "What to tell this persona. Sending an empty one removes it entirely rather than storing a blank, so the persona falls back to the sandbox's own instructions.",
314
+ "What to tell this role. Sending an empty one removes it entirely rather than storing a blank, so the role falls back to the sandbox's own instructions.",
345
315
  ),
346
316
  });
347
- export const PersonaSkillSchema = PersonaIdParamSchema.extend(SkillDraftSchema.shape);
348
- export const PersonaSkillNameSchema = PersonaIdParamSchema.extend({ name: SkillNameSchema.describe("Which skill.") });
317
+ export const RoleSkillSchema = RoleIdParamSchema.extend(SkillDraftSchema.shape);
318
+ export const RoleSkillNameSchema = RoleIdParamSchema.extend({ name: SkillNameSchema.describe("Which skill.") });
349
319
  // Same listing/body split the sandbox's own skills make, for editing.
350
- export const PersonaSkillBodySchema = z.object({
320
+ export const RoleSkillBodySchema = z.object({
351
321
  name: z.string().describe("The skill's name."),
352
322
  description: z.string().describe("What it is for."),
353
323
  body: z.string().describe("The skill itself, in full."),
@@ -4,8 +4,8 @@
4
4
  // event: whose it is, which lane it stands in, and its diff once there is work to land. Never its title.
5
5
  //
6
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.
7
+ // without asking: the sandbox owner alone (never Full access, never an agent), with a written reason, read-only for a
8
+ // day, told to the author at once and recorded on the conversation for good.
9
9
  import { z } from "zod";
10
10
 
11
11
  // ---- The house rule ----
@@ -139,37 +139,12 @@ export const SealAnswerSchema = SealIdSchema.extend({
139
139
  });
140
140
  export type SealAnswer = z.infer<typeof SealAnswerSchema>;
141
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>;
142
+ // The owner's opening without asking: which conversation, and the reason its author reads.
143
+ export const SealOpenRequestSchema = SealIdSchema.extend({ reason: z.string().trim().min(SEAL_REASON_MIN).max(SEAL_REASON_MAX) });
144
+ export type SealOpenRequest = z.infer<typeof SealOpenRequestSchema>;
167
145
 
168
146
  export const SealApproveSchema = SealIdSchema.extend({
169
147
  open: z.string().min(1).describe("Which opening."),
170
148
  agree: z.boolean(),
171
149
  });
172
150
  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);
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { at, drop, dropAll, fold, isJsonObject, type JsonObject, mapValue, retype, transform } from "../documents/conversions.js";
2
+ import { at, drop, dropAll, fold, isJsonObject, type JsonObject, mapValue, rename, retype, transform } from "../documents/conversions.js";
3
3
  import { type ModelRole, ModelRoleSchema } from "../models/model-roles.js";
4
4
  import { setupsFromRoleLists } from "../models/model-setups.js";
5
5
  import { ModelPinSchema, type ModelPin } from "./agent.js";
@@ -180,4 +180,6 @@ export const SETTINGS_HISTORY = [
180
180
  // iq (2026-11-18): teaching agents the workspace search tool moved neither cost, calls nor searches against a held-out
181
181
  // half over 1,480 conversations, and the tool itself was removed.
182
182
  ...dropAll(["iqSearch", "iqSearchHoldout"]),
183
+ // Personas were renamed roles (2026-11-18): the switch that matches a new chat to one moves with them.
184
+ rename("personaRouting", "roleRouting"),
183
185
  ] as const;
@@ -33,7 +33,7 @@ export const SystemPromptModeSchema = z.enum(["intentic", "claude", "custom"]);
33
33
  export type SystemPromptMode = z.infer<typeof SystemPromptModeSchema>;
34
34
  // Excludes "custom": there is nothing to fetch, it's whatever the owner already typed into the settings field.
35
35
  export const BuiltinPromptSchema = z.object({ base: z.enum(["intentic", "claude"]) });
36
- // Longest an owner's own system prompt may be, the sandbox's or a persona's; named so an editor can refuse a save the
36
+ // Longest an owner's own system prompt may be, the sandbox's or a role's; named so an editor can refuse a save the
37
37
  // daemon would refuse, rather than copy the number.
38
38
  export const SYSTEM_PROMPT_MAX = 20_000;
39
39
  // Longest the guidance the New chat routing job reads may be (`autoModelGuidance` below).
@@ -143,10 +143,14 @@ export type RuleFirings = z.infer<typeof RuleFiringsSchema>;
143
143
  // capability: something connected brought it (a CLI tool, a machine, a browser account, a VPN).
144
144
  // extension: an installed extension ships it inside its checkout.
145
145
  // plugin: a plugin capability cloned a repo that holds it.
146
- // persona: one card's own kit carries it; only turns wearing that card see it.
146
+ // role: one card's own kit carries it; only turns wearing that card see it.
147
147
  // dropped: sitting in the loaded folder by hand or by the agent, claimed by nothing else.
148
148
  // Not a capability kind: a capability can be broken and wants a status light, a skill either exists or it doesn't.
149
- export const SkillOriginSchema = z.enum(["builtin", "own", "capability", "extension", "plugin", "persona", "dropped"]);
149
+ // "role" was "persona" until personas were renamed roles (2026-11-18), which a daemon from before still answers.
150
+ export const SkillOriginSchema = z.preprocess(
151
+ (origin) => (origin === "persona" ? "role" : origin),
152
+ z.enum(["builtin", "own", "capability", "extension", "plugin", "role", "dropped"]),
153
+ );
150
154
  export type SkillOrigin = z.infer<typeof SkillOriginSchema>;
151
155
  // Same slug shape the SDK's loader accepts, checked here so a bad name is a refused save, not a skill that silently
152
156
  // never loads.
@@ -289,11 +293,11 @@ export const SandboxSettingsSchema = z.object({
289
293
  // message and one line per card are put to the same model that chooses what the chat runs on, in the same call.
290
294
  // Never asked of a draft: only a sent message is a finished one. Attended chats only: routing onto a card would
291
295
  // grant an unwatched wake accounts nobody named for it.
292
- personaRouting: z
296
+ roleRouting: z
293
297
  .boolean()
294
298
  .default(true)
295
299
  .describe(
296
- "Whether a new chat is matched to one of your personas from its first message. It is read once the message is sent, in the same single call that chooses what the chat runs on (the New chat routing job under Models), and the chat says in its own transcript which persona it landed on. Never applies to unwatched runs, which name their persona themselves.",
300
+ "Whether a new chat is matched to one of your roles from its first message. It is read once the message is sent, in the same single call that chooses what the chat runs on (the New chat routing job under Models), and the chat says in its own transcript which role it landed on. Never applies to unwatched runs, which name their role themselves.",
297
301
  ),
298
302
  // The `show_page`/`ask_page` tools and the guidance that names them (agent/pages/page-tools.ts); off, a turn is
299
303
  // offered neither and draws no page, which costs it nothing.
@@ -344,7 +348,7 @@ export const SandboxSettingsSchema = z.object({
344
348
  "Your own instructions, used only when the mode above says custom. Then it is the whole of them: both built-in bases go, and so does everything this product would otherwise add, including the guidance the chat's own cards are driven by. That is the price of total control.",
345
349
  ),
346
350
  ...claudeExperimentSettings,
347
- // Rooted at the run's own starting folder (a persona's, an isolated conversation's worktree), not the workspace
351
+ // Rooted at the run's own starting folder (a role's, an isolated conversation's worktree), not the workspace
348
352
  // root — it maps the project containing that folder. On for new sandboxes from 2026-11-04, kept off for older ones
349
353
  // (the daemon's settings-store.ts pins the old default, settings/earlier-defaults-step.ts writes it down where never
350
354
  // saved).
@@ -1,6 +1,6 @@
1
1
  // Named imports rather than the `z` namespace: this module is bundled into the browser extension, where the
2
2
  // namespace keeps zod's 60 locales (~250 kB) that esbuild can otherwise drop. _devices/webext/scripts/size-budget.mjs holds the ceiling.
3
- import { enum as zEnum, literal, object, string } from "zod";
3
+ import { enum as zEnum, literal, looseObject, object, optional, preprocess, string, undefined as zUndefined } from "zod";
4
4
  import type * as z from "zod";
5
5
  // Success ack for routes that only report completion (push, disconnect, self-host register). A paused turn or missing
6
6
  // repo/path throws an ORPCError instead.
@@ -8,19 +8,33 @@ export const OkSchema = object({
8
8
  ok: literal(true)
9
9
  .describe("Always true. A route that answers this either did the thing or refused with a status; there is no third outcome to report."),
10
10
  });
11
- // Trust tiers, ordered low to high: guest talks to the persona cards it was handed and sees nothing else, viewer
11
+ // Trust tiers, ordered low to high: guest talks to the role cards it was handed and sees nothing else, viewer
12
12
  // watches, collaborator's outward actions become requests, writer changes files inside the areas it holds and ships
13
13
  // none of them, maintainer holds the owner's authority but is revocable, owner is the one bound identity and not a
14
14
  // grant.
15
- export const MemberRoleSchema = zEnum(["guest", "viewer", "collaborator", "writer", "maintainer", "owner"]);
16
- export type MemberRole = z.infer<typeof MemberRoleSchema>;
17
- // Roles an invite can grant: everything but owner, which binds at first sign-in and is never granted.
18
- export const GrantedRoleSchema = zEnum(["guest", "viewer", "collaborator", "writer", "maintainer"]);
19
- export type GrantedRole = z.infer<typeof GrantedRoleSchema>;
20
- // Single source for role order; every surface that gates on a role reads this ranking. A guest is below every
15
+ export const MemberTierSchema = zEnum(["guest", "viewer", "collaborator", "writer", "maintainer", "owner"]);
16
+ export type MemberTier = z.infer<typeof MemberTierSchema>;
17
+ // Tiers an invite can grant: everything but owner, which binds at first sign-in and is never granted. Called roles until
18
+ // 2026-11-18, when personas were renamed roles; the wire key a tier rides under moved from `role` to `tier`.
19
+ export const GrantedTierSchema = zEnum(["guest", "viewer", "collaborator", "writer", "maintainer"]);
20
+ export type GrantedTier = z.infer<typeof GrantedTierSchema>;
21
+ // Single source for tier order; every surface that gates on a tier reads this ranking. A guest is below every
21
22
  // floor: its routes are an allowlist of its own (protocol/member-reach.ts guestReach), never a floor it can clear.
22
- const MEMBER_ROLE_RANK: Record<MemberRole, number> = { guest: 0, viewer: 1, collaborator: 2, writer: 3, maintainer: 4, owner: 5 };
23
- export const roleAtLeast = (role: MemberRole, floor: MemberRole): boolean => MEMBER_ROLE_RANK[role] >= MEMBER_ROLE_RANK[floor];
23
+ const MEMBER_TIER_RANK: Record<MemberTier, number> = { guest: 0, viewer: 1, collaborator: 2, writer: 3, maintainer: 4, owner: 5 };
24
+ export const tierAtLeast = (tier: MemberTier, floor: MemberTier): boolean => MEMBER_TIER_RANK[tier] >= MEMBER_TIER_RANK[floor];
25
+ // A tier rode under `role` on the wire until 2026-11-18. What a sender from before writes (an older daemon's roster,
26
+ // presence or profile holders; an older editor's grant) is read as `tier`; a value that already says `tier` is read
27
+ // as it is.
28
+ const LegacyTierSchema = looseObject({ role: string(), tier: optional(zUndefined()) });
29
+ export const withLegacyTier = <S extends z.ZodType>(schema: S) =>
30
+ preprocess((raw) => {
31
+ const legacy = LegacyTierSchema.safeParse(raw);
32
+ if (!legacy.success) {
33
+ return raw;
34
+ }
35
+ const { role, tier: _absent, ...rest } = legacy.data;
36
+ return { ...rest, tier: role };
37
+ }, schema);
24
38
  // Rotating a door credential (event webhook, release gate, bug intake): the old value stops working immediately; the
25
39
  // new one is shown once to be saved.
26
40
  export const DoorTokenSchema = object({
@@ -21,12 +21,12 @@ const clear: StatePlan = {
21
21
  failures: [],
22
22
  steps: [
23
23
  { document: "conversations-db-schema", change: "upgrades the conversations database schema" },
24
- { document: `${STATE_DIR}/config/personas.json`, change: `moves it from ${STATE_DIR}/identities.json` },
24
+ { document: `${STATE_DIR}/config/roles.json`, change: `moves it from ${STATE_DIR}/identities.json` },
25
25
  ],
26
26
  converts: [
27
- { document: `${STATE_DIR}/config/settings.json`, change: "converts personaRouting from its old values", detail: '"suggest" became true' },
27
+ { document: `${STATE_DIR}/config/settings.json`, change: "converts roleRouting from its old values", detail: '"suggest" became true' },
28
28
  ],
29
- files: [`${STATE_DIR}/config/personas.json`],
29
+ files: [`${STATE_DIR}/config/roles.json`],
30
30
  };
31
31
 
32
32
  const refused: StatePlan = {
@@ -3,7 +3,8 @@ import { z } from "zod";
3
3
  import { SystemPromptModeSchema } from "./settings.js";
4
4
 
5
5
  // Every section names its mechanism: the reader asks "did my AGENTS.md arrive", not "what does paragraph nine say".
6
- export const PromptSectionSourceSchema = z.enum(["guidance", "persona", "memory"]);
6
+ // "role" was "persona" until personas were renamed roles (2026-11-18), which a daemon from before still answers.
7
+ export const PromptSectionSourceSchema = z.preprocess((source) => (source === "persona" ? "role" : source), z.enum(["guidance", "role", "memory"]));
7
8
  export type PromptSectionSource = z.infer<typeof PromptSectionSourceSchema>;
8
9
 
9
10
  export const PromptSectionSchema = z.object({
@@ -74,9 +74,26 @@ export const BrowserPageSchema = z.object({
74
74
  ),
75
75
  // The page's title; absent mid-navigation, when a tab still needs to render.
76
76
  title: z.string().optional().describe("The page's title. Absent mid-navigation, which is exactly when a tab still has to be drawn."),
77
- url: z.string().describe("Where it is."),
77
+ url: z.string().describe("Where it is. On the browser's error page, the address that failed to load."),
78
78
  // The page the agent last drove; for a finished session, the one it ended on. Exactly one page has it.
79
79
  active: z.boolean().describe("The one the agent last touched, or for a finished session, the one it ended on. Exactly one page has this."),
80
+ // What a browser's own chrome says about a tab between two addresses, which the picture crops away: it turns, it
81
+ // names the host it waits on, and it says why it gave up. All absent from a daemon older than them.
82
+ loading: z
83
+ .boolean()
84
+ .optional()
85
+ .describe("It is on its way somewhere: a navigation in flight, or its page still loading. Absent once it has finished."),
86
+ navigation: z
87
+ .object({
88
+ url: z.string().describe("The address being fetched now; each redirect along the way replaces it."),
89
+ since: z.number().describe("When the navigation set off, in milliseconds."),
90
+ })
91
+ .optional()
92
+ .describe("A navigation that has set off and not arrived yet: where it is waiting, and for how long. Absent once it arrives or fails."),
93
+ error: z
94
+ .string()
95
+ .optional()
96
+ .describe("Why the last navigation failed, in the browser's own words (net::ERR_CONNECTION_TIMED_OUT), while the page shows its error page."),
80
97
  });
81
98
  export const BrowserSessionSchema = z.object({
82
99
  name: z.string().describe("Its id, and what the close route takes."),
@@ -1,9 +1,9 @@
1
- import { PersonaPowersSchema } from "./personas.js";
1
+ import { RolePowersSchema } from "./roles.js";
2
2
  import { capPowers, ceilingLimits, ceilingWithholds, ceilingWords, intersectCeilings } from "./tool-ceiling.js";
3
3
 
4
4
  // A ceiling is an upper bound per shelf: an answer left out limits nothing, and two held together keep the lower of each.
5
5
 
6
- const FULL = PersonaPowersSchema.parse({});
6
+ const FULL = RolePowersSchema.parse({});
7
7
 
8
8
  describe(`intersectCeilings`, () => {
9
9
  it(`keeps the lower answer of each shelf`, () => {
@@ -23,22 +23,28 @@ describe(`intersectCeilings`, () => {
23
23
  });
24
24
 
25
25
  describe(`capPowers`, () => {
26
- it(`lowers a persona's shelves to the ceiling and keeps its connector lists`, () => {
27
- const powers = { ...FULL, connectors: [`github`] };
28
- expect(capPowers(powers, { files: `read`, shell: false, delegate: false })).toEqual({
29
- ...powers,
26
+ it(`lowers a turn's shelves to the ceiling`, () => {
27
+ expect(capPowers(FULL, { files: `read`, shell: false, delegate: false })).toEqual({
28
+ ...FULL,
30
29
  files: `read`,
31
30
  shell: false,
32
31
  delegate: false,
33
32
  });
34
33
  });
35
34
 
36
- it(`never raises a shelf the persona switched off`, () => {
35
+ it(`keeps only the extensions both the shelves and the ceiling allow`, () => {
36
+ expect(capPowers(FULL, { extensions: [`acme.crm`] }).extensions).toEqual([`acme.crm`]);
37
+ expect(capPowers({ ...FULL, extensions: [`acme.crm`, `acme.mail`] }, { extensions: [`acme.mail`] }).extensions).toEqual([`acme.mail`]);
38
+ expect(intersectCeilings({ extensions: [`a`, `b`] }, { extensions: [`b`, `c`] })).toEqual({ extensions: [`b`] });
39
+ expect(ceilingLimits({ extensions: [] })).toBe(true);
40
+ });
41
+
42
+ it(`never raises a shelf already off`, () => {
37
43
  const readOnly = { ...FULL, files: `read` as const, shell: false };
38
44
  expect(capPowers(readOnly, { files: `write`, shell: true })).toEqual(readOnly);
39
45
  });
40
46
 
41
- it(`returns the persona's own shelves when the ceiling limits nothing`, () => {
47
+ it(`returns the shelves as they were when the ceiling limits nothing`, () => {
42
48
  expect(capPowers(FULL, undefined)).toBe(FULL);
43
49
  expect(capPowers(FULL, { files: `write`, web: true })).toBe(FULL);
44
50
  });