@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
@@ -3,9 +3,9 @@ import { AgentProviderSchema } from "./agent.js";
3
3
  import { entryId } from "./internal.js";
4
4
 
5
5
  // One reading, asked once per chat on the message it opens with, answering whichever of two questions the chat still
6
- // has: which persona handles it, and what it runs on. Both are the same classification over lists the sandbox supplies,
6
+ // has: which role handles it, and what it runs on. Both are the same classification over lists the sandbox supplies,
7
7
  // both are only answerable before anything has run, and neither is worth a model call of its own — so there is one
8
- // call, and `model`/`persona` on the ask say which halves it is being paid to answer.
8
+ // call, and `model`/`role` on the ask say which halves it is being paid to answer.
9
9
 
10
10
  export const ChatRouteAskSchema = z.object({
11
11
  prompt: z.string().min(1).max(20000).describe("The message a new chat is about to open with."),
@@ -13,14 +13,20 @@ export const ChatRouteAskSchema = z.object({
13
13
  .array(z.string().min(1).max(500))
14
14
  .max(50)
15
15
  .default([])
16
- .describe("Workspace paths the message names: uploads, @-mentions, the editor's own file. How much real code the work touches, and which persona's ground it stands on."),
16
+ .describe("Workspace paths the message names: uploads, @-mentions, the editor's own file. How much real code the work touches, and which role's ground it stands on."),
17
17
  folder: z.string().max(200).optional().describe("The workspace folder the chat was opened in, when it was opened in one."),
18
18
  editorContext: z.boolean().optional().describe("Whether the message carries a file and selection the user pointed at, so it is about real code."),
19
19
  planMode: z.boolean().optional().describe("Whether the chat opens in plan mode, which is a request to think before acting."),
20
- // The two halves, each a fact about THIS chat rather than a setting: a chat already pointed at a model or a persona
20
+ // The two halves, each a fact about THIS chat rather than a setting: a chat already pointed at a model or a role
21
21
  // by hand has nothing left to ask about it, whatever the sandbox's settings say.
22
22
  model: z.boolean().describe("Whether to choose the model, effort and account: true when the chat is on Auto and nothing has been picked by hand."),
23
- persona: z.boolean().describe("Whether to choose the persona: true when persona matching is on and the chat has not been pointed at one by hand."),
23
+ // Optional with its former name beside it, for one release either side of personas being renamed roles (2026-11-18):
24
+ // an editor sends both, so a daemon from before reads `persona`; this daemon reads `role`, else `persona`.
25
+ role: z
26
+ .boolean()
27
+ .optional()
28
+ .describe("Whether to choose the role: true when role matching is on and the chat has not been pointed at one by hand. Absent reads `persona`."),
29
+ persona: z.boolean().optional().describe("Deprecated: `role`, under its name before personas were renamed roles."),
24
30
  });
25
31
  export type ChatRouteAsk = z.infer<typeof ChatRouteAskSchema>;
26
32
 
@@ -36,9 +42,9 @@ export const ModelPickSchema = z.object({
36
42
  export type ModelPick = z.infer<typeof ModelPickSchema>;
37
43
 
38
44
  // Absent `id` is a real, safe answer: the chat stays open to every account, and the reason says why nothing was named.
39
- export const PersonaVerdictSchema = z.object({
40
- id: entryId.optional().describe("The persona this message belongs to, or absent when none does."),
41
- reason: z.string().describe("Why, in the one clause a chat can show. Present whether or not a persona was named."),
45
+ export const RoleVerdictSchema = z.object({
46
+ id: entryId.optional().describe("The role this message belongs to, or absent when none does."),
47
+ reason: z.string().describe("Why, in the one clause a chat can show. Present whether or not a role was named."),
42
48
  });
43
49
 
44
50
  // Absent `pick` is a real, safe answer: the chat runs on whatever the picker remembered, and the reason says why.
@@ -49,7 +55,10 @@ export const ModelVerdictSchema = z.object({
49
55
 
50
56
  // One verdict per half asked for; a half that wasn't asked is absent, never a verdict with an empty answer.
51
57
  export const ChatRouteSchema = z.object({
52
- persona: PersonaVerdictSchema.optional().describe("The persona half's answer, present only when it was asked for."),
58
+ role: RoleVerdictSchema.optional().describe("The role half's answer, present only when it was asked for."),
59
+ // What a daemon from before personas were renamed roles (2026-11-18) answers the role half under; an editor reads it
60
+ // where `role` is absent.
61
+ persona: RoleVerdictSchema.optional().describe("Deprecated: the role half's answer, as a daemon from before the rename names it."),
53
62
  model: ModelVerdictSchema.optional().describe("The model half's answer, present only when it was asked for."),
54
63
  // Absent means nothing was spent: a folder match, the only runnable model, an unset role, a spent chain, or the
55
64
  // deadline passing before any rung answered.
@@ -30,5 +30,5 @@ export const contextTrimLine = (trim: ContextTrim): string => {
30
30
  const { window, omitted, base } = contextTrimNotice(trim).params;
31
31
  const swapped = base ? ` The agent's own base instructions were swapped for a short paragraph, too.` : ``;
32
32
  const left = omitted === undefined ? `` : ` — left out: ${omitted}`;
33
- return `Sent thin for this model's ${window} window${left}.${swapped}` + ` Your workspace rules, this turn's persona and where its files live still rode.`;
33
+ return `Sent thin for this model's ${window} window${left}.${swapped}` + ` Your workspace rules, this turn's role and where its files live still rode.`;
34
34
  };
@@ -184,7 +184,7 @@ export const ConversationBundleSchema = z.object({
184
184
  show: z.unknown(),
185
185
  // The record as stored, newest last, bounded: `total` says how many rows it has.
186
186
  transcript: z.unknown(),
187
- // What its last turn was told before its own words: the base prompt and what the sandbox added (guidance, persona,
187
+ // What its last turn was told before its own words: the base prompt and what the sandbox added (guidance, role,
188
188
  // memory), the environment it worked in. Absent when no turn has been recorded, and from an older sandbox.
189
189
  prompt: SystemPromptDisclosureSchema.optional().describe("The system prompt the conversation's most recent turn ran on."),
190
190
  // The diagnostics answers about it, each as the `diagnostics` command words it.
@@ -471,7 +471,7 @@ export const OutsideCheckoutSchema = z.object({
471
471
  reason: z
472
472
  .enum(["unborn", "unreadable", "not-carried"])
473
473
  .describe(
474
- "Why the copy does not carry it: `unborn` has no commit yet to start from, and is taken in on the conversation's next turn once it has one; `unreadable` is a repository git cannot read; `not-carried` is one the conversation was set up without, such as a persona that names other repositories.",
474
+ "Why the copy does not carry it: `unborn` has no commit yet to start from, and is taken in on the conversation's next turn once it has one; `unreadable` is a repository git cannot read; `not-carried` is one the conversation was set up without, such as a role that names other repositories.",
475
475
  ),
476
476
  files: z.number().describe("How many files the copy holds at its path. A floor past a thousand, which is where the count stops."),
477
477
  });
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- // A manifest entry id (capabilities + automations + personas), also the `mcp__<id>__…` server name for mcp
2
+ // A manifest entry id (capabilities + automations + roles), also the `mcp__<id>__…` server name for mcp
3
3
  // capabilities, so it's a safe identifier.
4
4
  export const entryId = z
5
5
  .string()
@@ -5,7 +5,7 @@ import { entryId } from "./internal.js";
5
5
  // LINKED SANDBOXES: one of the owner's sandboxes handing tasks to another. The sandbox that hands work over holds a
6
6
  // `link` capability card (schemas/capabilities.ts LinkConfigSchema); the one that takes it holds an inbound link, minted
7
7
  // by its owner, whose token is that card's credential. Everything the taking side does with a task is decided there, by
8
- // the terms on its own link: which persona the work wears, whether each task waits for its owner, how many turns an hour.
8
+ // the terms on its own link: which role the work wears, whether each task waits for its owner, how many turns an hour.
9
9
  // The handing side only asks, reads and stops, and operates this sandbox only while its terms say it may (`operate`).
10
10
 
11
11
  // What a link token looks like: issuer-prefixed like a control token (`ict_`), and never the same credential.
@@ -50,13 +50,13 @@ export const LinkTermsSchema = z.object({
50
50
  actsAs: entryId
51
51
  .optional()
52
52
  .describe(
53
- "The persona every task through this link wears: its accounts, its shelves, its folders, its model. Absent, the task runs with no signed-in account and the full toolbox, as any unattended wake does.",
53
+ "The role every task through this link wears: its accounts, its shelves, its folders, its model. Absent, the task runs with no signed-in account and the full toolbox, as any unattended wake does.",
54
54
  ),
55
- // Who the link's tasks act for (schemas/services.ts), the hard half beside the persona's posture.
55
+ // Who the link's tasks act for (schemas/services.ts), the hard half beside the role's posture.
56
56
  runAs: entryId
57
57
  .optional()
58
58
  .describe(
59
- "The service every task through this link acts as: whose authority it uses, held to that service's access profile. Absent means this sandbox's owner, limited only by the persona.",
59
+ "The service every task through this link acts as: whose authority it uses, held to that service's access profile. Absent means this sandbox's owner, limited only by the role.",
60
60
  ),
61
61
  approve: approveTerm.default(false),
62
62
  turnsPerHour: turnsPerHourTerm.default(LINK_TURNS_PER_HOUR_DEFAULT),
@@ -109,13 +109,13 @@ export type InboundLinkMint = z.infer<typeof InboundLinkMintSchema>;
109
109
  // The raw token, shown exactly once.
110
110
  export const InboundLinkMintedSchema = z.object({ id: z.string(), token: z.string() });
111
111
  export type InboundLinkMinted = z.infer<typeof InboundLinkMintedSchema>;
112
- // POST /system/links/{id}: new terms, whole fields replaced, the rest kept. `null` on the persona or the service takes it
112
+ // POST /system/links/{id}: new terms, whole fields replaced, the rest kept. `null` on the role or the service takes it
113
113
  // off (2026-10-26): absence keeps a field, so before this neither could be cleared once set. Spelled field by field rather
114
114
  // than as LinkTermsSchema.partial(): zod still fills a partial's inner defaults, so a change naming one field would read
115
115
  // as `approve: false, turnsPerHour: 20, tasks: true` and quietly reset the rest (2026-10-29).
116
116
  export const InboundLinkTermsUpdateSchema = z.object({
117
117
  label: z.string().trim().min(1).max(60).optional(),
118
- actsAs: entryId.nullable().optional().describe("The persona every task wears; null takes it off."),
118
+ actsAs: entryId.nullable().optional().describe("The role every task wears; null takes it off."),
119
119
  runAs: entryId.nullable().optional().describe("The service every task acts as; null takes it off, so tasks act for this sandbox's owner."),
120
120
  approve: approveTerm.optional(),
121
121
  turnsPerHour: turnsPerHourTerm.optional(),
@@ -137,7 +137,7 @@ export const LinkHelloSchema = z.object({
137
137
  terms: z.object({
138
138
  approve: z.boolean(),
139
139
  turnsPerHour: z.number().int(),
140
- persona: z.string().optional().describe("The name of the persona its tasks wear, when they wear one."),
140
+ role: z.string().optional().describe("The name of the role its tasks wear, when they wear one."),
141
141
  // Absent from a sandbox older than 2026-10-29, which takes tasks.
142
142
  tasks: z.boolean().optional(),
143
143
  // Absent from a sandbox older than records over links, which shares none.
@@ -144,7 +144,7 @@ export const LoopSchema = z.object({
144
144
  actsAs: entryId
145
145
  .optional()
146
146
  .describe(
147
- "Which persona the rounds act as. It matters here: every round is unwatched, and an unwatched turn naming no persona reaches no signed-in account at all, so pinning one is how a loop gets hands.",
147
+ "Which role the rounds act as. It matters here: every round is unwatched, and an unwatched turn naming no role reaches no signed-in account at all, so pinning one is how a loop gets hands.",
148
148
  ),
149
149
  // Also stops a later iteration from inheriting the sandbox's global auto-land posture.
150
150
  worktreeBase: z
@@ -5,16 +5,16 @@ import { accessRefusal, holdsRight, landsHere, memberAccess, peopleChangeRefusal
5
5
 
6
6
  describe(`memberAccess`, () => {
7
7
  it(`reads a row written before agents and edit as its role meant`, () => {
8
- expect(memberAccess({ role: `guest`, areas: [`support`] })).toEqual({ manage: false, agents: `chat`, see: [`support`], edit: `none` });
9
- expect(memberAccess({ role: `viewer` })).toEqual({ manage: false, agents: `off`, see: undefined, edit: `none` });
10
- expect(memberAccess({ role: `collaborator`, areas: [`web`] })).toEqual({ manage: false, agents: `run`, see: [`web`], edit: `none` });
11
- expect(memberAccess({ role: `writer`, areas: [`web`] })).toEqual({ manage: false, agents: `run`, see: [`web`], edit: [`web`] });
12
- expect(memberAccess({ role: `maintainer`, areas: [`web`] })).toEqual({ manage: true, agents: `run`, see: undefined, edit: `all` });
8
+ expect(memberAccess({ tier: `guest`, areas: [`support`] })).toEqual({ manage: false, agents: `chat`, see: [`support`], edit: `none` });
9
+ expect(memberAccess({ tier: `viewer` })).toEqual({ manage: false, agents: `off`, see: undefined, edit: `none` });
10
+ expect(memberAccess({ tier: `collaborator`, areas: [`web`] })).toEqual({ manage: false, agents: `run`, see: [`web`], edit: `none` });
11
+ expect(memberAccess({ tier: `writer`, areas: [`web`] })).toEqual({ manage: false, agents: `run`, see: [`web`], edit: [`web`] });
12
+ expect(memberAccess({ tier: `maintainer`, areas: [`web`] })).toEqual({ manage: true, agents: `run`, see: undefined, edit: `all` });
13
13
  });
14
14
 
15
15
  it(`takes what a row says when it says it, and never lets a chat edit`, () => {
16
- expect(memberAccess({ role: `writer`, agents: `off`, edit: [`web`] })).toEqual({ manage: false, agents: `off`, see: undefined, edit: [`web`] });
17
- expect(memberAccess({ role: `guest`, agents: `chat`, areas: [`support`], edit: `all` }).edit).toBe(`none`);
16
+ expect(memberAccess({ tier: `writer`, agents: `off`, edit: [`web`] })).toEqual({ manage: false, agents: `off`, see: undefined, edit: [`web`] });
17
+ expect(memberAccess({ tier: `guest`, agents: `chat`, areas: [`support`], edit: `all` }).edit).toBe(`none`);
18
18
  });
19
19
  });
20
20
 
@@ -49,8 +49,8 @@ describe(`accessRefusal`, () => {
49
49
  // Home only: a guest whose one conversation is its home, and whose home lands by itself exactly when they may land it.
50
50
  describe(`home-only access`, () => {
51
51
  it(`is a guest that edits nothing and needs no area, carrying its answer to landing`, () => {
52
- expect(memberAccess({ role: `guest`, agents: `home` })).toEqual({ manage: false, agents: `home`, see: undefined, edit: `none` });
53
- expect(memberAccess({ role: `guest`, agents: `home`, edit: `all`, lands: true })).toEqual({
52
+ expect(memberAccess({ tier: `guest`, agents: `home` })).toEqual({ manage: false, agents: `home`, see: undefined, edit: `none` });
53
+ expect(memberAccess({ tier: `guest`, agents: `home`, edit: `all`, lands: true })).toEqual({
54
54
  manage: false,
55
55
  agents: `home`,
56
56
  see: undefined,
@@ -76,18 +76,18 @@ describe(`home-only access`, () => {
76
76
 
77
77
  describe(`rights`, () => {
78
78
  test(`the owner and Full access run every part; anyone else what their row names`, () => {
79
- expect(holdsRight({ role: `owner` }, `people`)).toBe(true);
80
- expect(holdsRight({ role: `maintainer` }, `secrets`)).toBe(true);
81
- expect(holdsRight({ role: `collaborator`, manages: [`people`] }, `people`)).toBe(true);
82
- expect(holdsRight({ role: `collaborator`, manages: [`people`] }, `secrets`)).toBe(false);
83
- expect(holdsRight({ role: `writer` }, `privacy`)).toBe(false);
79
+ expect(holdsRight({ tier: `owner` }, `people`)).toBe(true);
80
+ expect(holdsRight({ tier: `maintainer` }, `secrets`)).toBe(true);
81
+ expect(holdsRight({ tier: `collaborator`, manages: [`people`] }, `people`)).toBe(true);
82
+ expect(holdsRight({ tier: `collaborator`, manages: [`people`] }, `secrets`)).toBe(false);
83
+ expect(holdsRight({ tier: `writer` }, `privacy`)).toBe(false);
84
84
  });
85
85
 
86
86
  test(`a row's rights ride on its access, and never make a tier`, () => {
87
- const access = memberAccess({ role: `collaborator`, agents: `run`, manages: [`people`, `ownAccounts`] });
87
+ const access = memberAccess({ tier: `collaborator`, agents: `run`, manages: [`people`, `ownAccounts`] });
88
88
  expect(access.manages).toEqual([`people`, `ownAccounts`]);
89
89
  expect(tierOf(access)).toBe(`collaborator`);
90
- expect(memberAccess({ role: `collaborator`, agents: `run`, manages: [] }).manages).toBeUndefined();
90
+ expect(memberAccess({ tier: `collaborator`, agents: `run`, manages: [] }).manages).toBeUndefined();
91
91
  });
92
92
 
93
93
  test(`someone who only chats or works through their home holds none`, () => {
@@ -98,30 +98,30 @@ describe(`rights`, () => {
98
98
  });
99
99
 
100
100
  describe(`peopleChangeRefusal`, () => {
101
- const lead = { email: `lead@example.com`, role: `collaborator` as const, manages: [`people` as const, `ownAccounts` as const] };
101
+ const lead = { email: `lead@example.com`, tier: `collaborator` as const, manages: [`people` as const, `ownAccounts` as const] };
102
102
 
103
103
  test(`the owner and Full access change anyone, themselves included`, () => {
104
- expect(peopleChangeRefusal({ email: `o@example.com`, role: `owner` }, { email: `x@example.com`, after: { role: `maintainer` } })).toBeUndefined();
105
- const full = { email: `m@example.com`, role: `maintainer` as const };
106
- expect(peopleChangeRefusal(full, { email: `m@example.com`, before: { role: `maintainer` }, after: { role: `collaborator` } })).toBeUndefined();
107
- expect(peopleChangeRefusal(full, { email: `x@example.com`, before: { role: `maintainer` } })).toBeUndefined();
104
+ expect(peopleChangeRefusal({ email: `o@example.com`, tier: `owner` }, { email: `x@example.com`, after: { tier: `maintainer` } })).toBeUndefined();
105
+ const full = { email: `m@example.com`, tier: `maintainer` as const };
106
+ expect(peopleChangeRefusal(full, { email: `m@example.com`, before: { tier: `maintainer` }, after: { tier: `collaborator` } })).toBeUndefined();
107
+ expect(peopleChangeRefusal(full, { email: `x@example.com`, before: { tier: `maintainer` } })).toBeUndefined();
108
108
  });
109
109
 
110
110
  test(`People & access changes anyone below Full access but its holder`, () => {
111
- expect(peopleChangeRefusal(lead, { email: `new@example.com`, after: { role: `writer` } })).toBeUndefined();
112
- expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { role: `viewer` } })).toBeUndefined();
113
- expect(peopleChangeRefusal(lead, { email: `LEAD@example.com`, before: { role: `collaborator` }, after: { role: `writer` } })).toContain(`your own access`);
114
- expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { role: `maintainer` } })).toContain(`Full access is granted`);
115
- expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { role: `maintainer` } })).toContain(`Full access person`);
116
- expect(peopleChangeRefusal({ ...lead, manages: [] }, { email: `x@example.com`, after: { role: `viewer` } })).toContain(`People & access`);
111
+ expect(peopleChangeRefusal(lead, { email: `new@example.com`, after: { tier: `writer` } })).toBeUndefined();
112
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { tier: `viewer` } })).toBeUndefined();
113
+ expect(peopleChangeRefusal(lead, { email: `LEAD@example.com`, before: { tier: `collaborator` }, after: { tier: `writer` } })).toContain(`your own access`);
114
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { tier: `maintainer` } })).toContain(`Full access is granted`);
115
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { tier: `maintainer` } })).toContain(`Full access person`);
116
+ expect(peopleChangeRefusal({ ...lead, manages: [] }, { email: `x@example.com`, after: { tier: `viewer` } })).toContain(`People & access`);
117
117
  });
118
118
 
119
119
  test(`it hands out only the rights its holder has, and leaves the ones already held alone`, () => {
120
- expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { role: `viewer`, manages: [`people`, `ownAccounts`] } })).toBeUndefined();
121
- expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { role: `viewer`, manages: [`secrets`] } })).toContain(`secrets`);
120
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { tier: `viewer`, manages: [`people`, `ownAccounts`] } })).toBeUndefined();
121
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { tier: `viewer`, manages: [`secrets`] } })).toContain(`secrets`);
122
122
  expect(
123
- peopleChangeRefusal(lead, { email: `x@example.com`, before: { role: `viewer`, manages: [`secrets`] }, after: { role: `writer`, manages: [`secrets`] } }),
123
+ peopleChangeRefusal(lead, { email: `x@example.com`, before: { tier: `viewer`, manages: [`secrets`] }, after: { tier: `writer`, manages: [`secrets`] } }),
124
124
  ).toBeUndefined();
125
- expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { role: `viewer`, manages: [`secrets`] }, after: { role: `writer` } })).toBeUndefined();
125
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { tier: `viewer`, manages: [`secrets`] }, after: { tier: `writer` } })).toBeUndefined();
126
126
  });
127
127
  });
@@ -2,7 +2,7 @@
2
2
  import { z } from "zod";
3
3
  import type { CapabilityKind } from "./capabilities.js";
4
4
  import { entryId } from "./internal.js";
5
- import { type GrantedRole, GrantedRoleSchema, type MemberRole, MemberRoleSchema } from "./shared.js";
5
+ import { type GrantedTier, GrantedTierSchema, type MemberTier, MemberTierSchema, withLegacyTier } from "./shared.js";
6
6
  import { ToolCeilingSchema } from "./tool-ceiling.js";
7
7
 
8
8
  // WHAT A PERSON MAY RUN BESIDES THEIR OWN WORK, one part of the sandbox at a time. Full access (the maintainer tier) holds
@@ -20,8 +20,8 @@ export type ManageRight = z.infer<typeof ManageRightSchema>;
20
20
  export const MANAGE_RIGHTS: readonly ManageRight[] = ManageRightSchema.options;
21
21
 
22
22
  /** Whether this person may run one part of the sandbox: the owner and Full access run every part, anyone else what their row names. */
23
- export const holdsRight = (caller: { readonly role: MemberRole; readonly manages?: readonly ManageRight[] | undefined }, right: ManageRight): boolean =>
24
- caller.role === "owner" || caller.role === "maintainer" || (caller.manages?.includes(right) ?? false);
23
+ export const holdsRight = (caller: { readonly tier: MemberTier; readonly manages?: readonly ManageRight[] | undefined }, right: ManageRight): boolean =>
24
+ caller.tier === "owner" || caller.tier === "maintainer" || (caller.manages?.includes(right) ?? false);
25
25
 
26
26
  /**
27
27
  * Why someone who manages people may not make this change to one person's access; undefined when they may. The owner and
@@ -31,14 +31,14 @@ export const holdsRight = (caller: { readonly role: MemberRole; readonly manages
31
31
  * its `manages` absent keeps the row's, as a grant reads it.
32
32
  */
33
33
  export const peopleChangeRefusal = (
34
- manager: { readonly email: string; readonly role: MemberRole; readonly manages?: readonly ManageRight[] | undefined },
34
+ manager: { readonly email: string; readonly tier: MemberTier; readonly manages?: readonly ManageRight[] | undefined },
35
35
  target: {
36
36
  readonly email: string;
37
- readonly before?: { readonly role: GrantedRole; readonly manages?: readonly ManageRight[] | undefined } | undefined;
38
- readonly after?: { readonly role: GrantedRole; readonly manages?: readonly ManageRight[] | undefined } | undefined;
37
+ readonly before?: { readonly tier: GrantedTier; readonly manages?: readonly ManageRight[] | undefined } | undefined;
38
+ readonly after?: { readonly tier: GrantedTier; readonly manages?: readonly ManageRight[] | undefined } | undefined;
39
39
  },
40
40
  ): string | undefined => {
41
- if (manager.role === "owner" || manager.role === "maintainer") {
41
+ if (manager.tier === "owner" || manager.tier === "maintainer") {
42
42
  return undefined;
43
43
  }
44
44
  if (!holdsRight(manager, "people")) {
@@ -47,10 +47,10 @@ export const peopleChangeRefusal = (
47
47
  if (manager.email.toLowerCase() === target.email.toLowerCase()) {
48
48
  return "your own access is changed by the owner or someone with Full access";
49
49
  }
50
- if (target.before?.role === "maintainer") {
50
+ if (target.before?.tier === "maintainer") {
51
51
  return "a Full access person's access is changed by the owner or someone with Full access";
52
52
  }
53
- if (target.after?.role === "maintainer") {
53
+ if (target.after?.tier === "maintainer") {
54
54
  return "Full access is granted by the owner or someone with Full access";
55
55
  }
56
56
  const had = new Set(target.before?.manages ?? []);
@@ -119,7 +119,7 @@ export const aiAccountAllowed = (keys: Iterable<string>, provider: string, accou
119
119
  // WHAT ONE PERSON MAY DO, as three independent answers rather than one rung of a ladder: whether their conversations
120
120
  // run agents (`agents`), where they may look (`areas`, the fence their agents run inside too) and where they may change
121
121
  // files by hand (`edit`), and whether they manage the sandbox (the maintainer tier, which implies every other answer).
122
- // The `role` a row carries is the tier those answers make (`tierOf`), kept because the platform's invite record, the
122
+ // The `tier` a row carries is the tier those answers make (`tierOf`), kept because the platform's invite record, the
123
123
  // presence list and every route's floor read a tier; a row written before the answers existed reads as its role meant
124
124
  // (`memberAccess`).
125
125
  // `chat` is the guest's way of working: it talks to the assistants that work in its areas and is shown nothing else of
@@ -150,7 +150,7 @@ export interface MemberAccess {
150
150
 
151
151
  // The fields of a row or a grant that decide a person's access.
152
152
  interface AccessFields {
153
- readonly role: GrantedRole;
153
+ readonly tier: GrantedTier;
154
154
  readonly areas?: readonly string[] | undefined;
155
155
  readonly agents?: AgentAccess | undefined;
156
156
  readonly edit?: EditScope | undefined;
@@ -160,12 +160,12 @@ interface AccessFields {
160
160
 
161
161
  /** A row's access: what it says, and for a row written before `agents` and `edit` existed, what its role meant then. */
162
162
  export const memberAccess = (row: AccessFields): MemberAccess => {
163
- if (row.role === "maintainer") {
163
+ if (row.tier === "maintainer") {
164
164
  return { manage: true, agents: "run", see: undefined, edit: "all" };
165
165
  }
166
- const agents = row.agents ?? (row.role === "guest" ? "chat" : row.role === "viewer" ? "off" : "run");
166
+ const agents = row.agents ?? (row.tier === "guest" ? "chat" : row.tier === "viewer" ? "off" : "run");
167
167
  // A writer from before `edit` changes files where it sees them, which its areas always named.
168
- const edit = row.edit ?? (row.role === "writer" && row.areas !== undefined ? [...row.areas] : "none");
168
+ const edit = row.edit ?? (row.tier === "writer" && row.areas !== undefined ? [...row.areas] : "none");
169
169
  const base: MemberAccess = { manage: false, agents, see: row.areas, edit: agents === "chat" || agents === "home" ? "none" : edit };
170
170
  const access = row.manages !== undefined && row.manages.length > 0 ? { ...base, manages: [...row.manages] } : base;
171
171
  return row.lands === true ? { ...access, lands: true } : access;
@@ -180,7 +180,7 @@ export const landsHere = (access: Pick<MemberAccess, "manage" | "agents" | "land
180
180
  access.manage || (access.agents === "home" && access.lands === true);
181
181
 
182
182
  /** The tier an access makes: what every route's floor, the platform's record and the presence list read. */
183
- export const tierOf = (access: MemberAccess): GrantedRole => {
183
+ export const tierOf = (access: MemberAccess): GrantedTier => {
184
184
  if (access.manage) {
185
185
  return "maintainer";
186
186
  }
@@ -230,14 +230,18 @@ const editRefusal = (access: MemberAccess): string | undefined => {
230
230
  /** Why an access cannot be granted on its face, before any area or assistant is looked up; undefined when it can. */
231
231
  export const accessRefusal = (access: MemberAccess): string | undefined => (access.manage ? undefined : (workingRefusal(access) ?? editRefusal(access)));
232
232
 
233
+ // A member's tier rode under `role` on the wire until 2026-11-18, when personas were renamed roles. What a sender
234
+ // from before writes is read as `tier` here, so an editor reads an older daemon's roster, and a daemon an older editor's
235
+ // grant (MemberGrantInputSchema). A row that already says `tier` is read as it is.
236
+
233
237
  // One person on the roster as the daemon answers it. `areas` fences what of the workspace they reach, and with it which
234
238
  // assistants they may talk to: absent is the whole workspace, empty is nothing.
235
- export const MemberSchema = z.object({
239
+ export const MemberRowSchema = z.object({
236
240
  email: z.string().describe("Who, lowercased."),
237
- role: GrantedRoleSchema.describe("The tier their access makes: maintainer when they manage the sandbox, else what `agents` and `edit` add up to."),
241
+ tier: GrantedTierSchema.describe("The tier their access makes: maintainer when they manage the sandbox, else what `agents` and `edit` add up to."),
238
242
  areas: z.array(z.string()).optional().describe("The areas they may see, and their agents work in. Absent means the whole workspace."),
239
243
  agents: AgentAccessSchema.optional().describe(
240
- "Whether their conversations run agents: off (they watch), chat (only with the assistants in their areas, nothing else of the sandbox), run, or home (only their own home conversation, nothing else of the sandbox). Absent means what their role meant.",
244
+ "Whether their conversations run agents: off (they watch), chat (only with the assistants in their areas, nothing else of the sandbox), run, or home (only their own home conversation, nothing else of the sandbox). Absent means what their tier meant.",
241
245
  ),
242
246
  edit: EditScopeSchema.optional().describe(
243
247
  "Where they may change files by hand: everything they see, or these areas. Absent means nowhere, or for a writer its areas.",
@@ -261,14 +265,14 @@ export const MemberSchema = z.object({
261
265
  "The AI accounts their conversations may run on, each `provider:account`, or a provider's id alone for every account of it (how an API-key endpoint is named). Absent means every one, including any connected later.",
262
266
  ),
263
267
  tools: ToolCeilingSchema.optional().describe(
264
- "The most their conversations' tools may be, shelf by shelf; a persona only narrows inside it. Absent means no limit.",
268
+ "The most their conversations' tools may be, shelf by shelf; a role only narrows inside it. Absent means no limit.",
265
269
  ),
266
270
  assistants: z
267
271
  .array(entryId)
268
272
  .max(50)
269
273
  .optional()
270
274
  .describe(
271
- "For a guest who chats: which of the assistants working in their areas they may talk to, by persona id. Absent means every one that works there.",
275
+ "For a guest who chats: which of the assistants working in their areas they may talk to, by role id. Absent means every one that works there.",
272
276
  ),
273
277
  profile: entryId
274
278
  .optional()
@@ -282,7 +286,8 @@ export const MemberSchema = z.object({
282
286
  "The parts of the sandbox they run besides their own work: people and access, secrets, the privacy shield, AI accounts of their own. Never on a maintainer, who runs every part. Absent means none.",
283
287
  ),
284
288
  });
285
- export type Member = z.infer<typeof MemberSchema>;
289
+ export const MemberSchema = withLegacyTier(MemberRowSchema);
290
+ export type Member = z.infer<typeof MemberRowSchema>;
286
291
 
287
292
  // What every roster write answers: the roster after it.
288
293
  export const MembersListSchema = z.object({ members: z.array(MemberSchema) });
@@ -293,21 +298,21 @@ export type MembersList = z.infer<typeof MembersListSchema>;
293
298
  export const MembersRosterSchema = MembersListSchema.extend({ owner: z.string().optional() });
294
299
  export type MembersRoster = z.infer<typeof MembersRosterSchema>;
295
300
 
296
- // POST /members: the role is required, the tier the grant makes. Areas are optional, their absence being the whole
301
+ // POST /members: the tier is required, the one the grant makes. Areas are optional, their absence being the whole
297
302
  // workspace; chatting with assistants needs them, since the assistants working there are the whole of that access.
298
303
  // `emailSignIn` lets the platform's identity assertion open this sandbox for them (policy/identity-assertion.ts): true
299
304
  // allows it, false takes it back, absent keeps what the row already says, so a re-grade from an editor that predates
300
305
  // the field never drops it. `credentials` the same way: `all` lifts a reach, a list sets one, absent keeps the row's,
301
306
  // so a re-grade that never mentions it can never widen what a person's conversations may spend. A maintainer may hold
302
307
  // a list too: managing the sandbox and spending all of it are separate answers (docs/architecture/access.md).
303
- // `agents` and `edit` decide the rest of the access; absent, the role's own meaning stands, so an editor that predates
308
+ // `agents` and `edit` decide the rest of the access; absent, the tier's own meaning stands, so an editor that predates
304
309
  // them still grants what it always did. `lands` is written as sent: absent is no, so a re-grade that never mentions it
305
- // can never hand a home-only person's agent the authority to land. The role sent must be the tier the access makes (`tierOf`): two answers to one
310
+ // can never hand a home-only person's agent the authority to land. The tier sent must be the one the access makes (`tierOf`): two answers to one
306
311
  // question are refused rather than one of them guessed away. `aiAccounts` reads as `credentials` does: `all` lifts it, a
307
312
  // list sets it, absent keeps the row's, a maintainer's included. `tools` and `assistants` read the same way, except that
308
313
  // a maintainer is refused a tool ceiling, since the tier runs every tool.
309
314
  // `profile` names an access profile instead of answering on the row: the daemon writes that profile's answers out on
310
- // the row and ignores the access fields sent beside it, and the role sent must still be the tier the profile makes.
315
+ // the row and ignores the access fields sent beside it, and the tier sent must still be the one the profile makes.
311
316
  // Absent is answers of the row's own, so a re-grade from an editor that predates profiles unlinks the row, keeping
312
317
  // the answers it carried, rather than leaving a link the grant did not mean. A maintainer is refused one.
313
318
  // `manages` reads as `credentials` does: a list sets the rights, `[]` takes them all back, absent keeps the row's, so a
@@ -316,7 +321,7 @@ export type MembersRoster = z.infer<typeof MembersRosterSchema>;
316
321
  // sandbox is handed to a person, never through something shared.
317
322
  export const MemberGrantSchema = z.object({
318
323
  email: z.string(),
319
- role: GrantedRoleSchema,
324
+ tier: GrantedTierSchema,
320
325
  areas: z.array(z.string().min(1)).max(20).optional(),
321
326
  agents: AgentAccessSchema.optional(),
322
327
  edit: EditScopeSchema.optional(),
@@ -330,11 +335,13 @@ export const MemberGrantSchema = z.object({
330
335
  manages: z.array(ManageRightSchema).max(10).optional(),
331
336
  });
332
337
  export type MemberGrant = z.infer<typeof MemberGrantSchema>;
338
+ // The grant as the daemon reads it off the wire: an editor from before 2026-11-18 sends the tier as `role`.
339
+ export const MemberGrantInputSchema = withLegacyTier(MemberGrantSchema);
333
340
 
334
341
  // GET /members/self: what the signed-in person may do here, for an editor that offers only what will be taken. The
335
342
  // owner reads as managing everything.
336
- export const MemberSelfSchema = z.object({
337
- role: MemberRoleSchema.describe("Their tier on this sandbox."),
343
+ export const MemberSelfRowSchema = z.object({
344
+ tier: MemberTierSchema.describe("Their tier on this sandbox."),
338
345
  agents: AgentAccessSchema.describe("Whether their conversations run agents."),
339
346
  areas: z.array(z.string()).optional().describe("The areas they may see. Absent means the whole workspace."),
340
347
  edit: z.union([z.literal("none"), EditScopeSchema]).describe("Where they may change files by hand."),
@@ -359,7 +366,8 @@ export const MemberSelfSchema = z.object({
359
366
  .optional()
360
367
  .describe("When they asked the owner for more access, while that request is still open (POST /members/requests). Absent when they have not, or it was answered."),
361
368
  });
362
- export type MemberSelf = z.infer<typeof MemberSelfSchema>;
369
+ export const MemberSelfSchema = withLegacyTier(MemberSelfRowSchema);
370
+ export type MemberSelf = z.infer<typeof MemberSelfRowSchema>;
363
371
 
364
372
  // ASKING FOR MORE ACCESS, from where the person was refused: the editor draws an "Ask for access" press on a place or an
365
373
  // action their access refuses, and whoever runs people and access sees each open request beside the roster (Access ▸
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { KeyringShareModeSchema } from "./keyring.js";
3
3
  import { AutomationSchema } from "./automations.js";
4
+ import { entryId } from "./internal.js";
4
5
 
5
6
  // A need: something an agent cannot finish its task without that only a person can provide (a connection, a secret's
6
7
  // value, wider reach, a tool in the image). Unlike a parked card it outlives the turn that raised it: the sandbox keeps
@@ -92,7 +93,7 @@ export type SecretNeed = z.infer<typeof SecretNeedSchema>;
92
93
  export const GrantSubjectSchema = z
93
94
  .enum(["capability", "folder", "shelf", "site"])
94
95
  .describe(
95
- "A connected capability the persona leaves out, a folder outside the conversation's reach, a whole shelf of tools, or a site in the person's own browser, which only their browser extension can allow.",
96
+ "A connected capability the conversation's role or access leaves out, a folder outside its reach, a whole shelf of tools, or a site in the person's own browser, which only their browser extension can allow.",
96
97
  );
97
98
  export type GrantSubject = z.infer<typeof GrantSubjectSchema>;
98
99
 
@@ -109,18 +110,36 @@ export const GRANT_SHELVES = ["files", "shell", "code", "web", "browser", "deleg
109
110
  export const GrantShelfSchema = z.enum(GRANT_SHELVES);
110
111
  export type GrantShelf = z.infer<typeof GrantShelfSchema>;
111
112
 
113
+ // How far a yes went on a grant answered before 2026-11-18, when a card could lift what a role (then called a persona)
114
+ // withheld. Kept so those needs still read, under the words they were stored with; nothing answers with it any more.
112
115
  export const GrantScopeSchema = z
113
116
  .enum(["conversation", "persona"])
114
- .describe("How far a yes goes: this conversation only, or the persona itself, for every conversation that wears it.");
117
+ .describe("How far a yes went, on a need answered before a role's limits became access: this conversation only, or the role itself (stored as `persona`).");
115
118
  export type GrantScope = z.infer<typeof GrantScopeSchema>;
116
119
 
120
+ // A role a grant need offers to switch the conversation to: one whose access allows what was asked for.
121
+ export const GrantRoleSchema = z.object({
122
+ id: entryId.describe("The role's id, or a built-in's."),
123
+ label: z.string().describe("Its name on screen."),
124
+ });
125
+ export type GrantRole = z.infer<typeof GrantRoleSchema>;
126
+
127
+ // What a role withholds is access (docs/architecture/access.md), and no card lifts access. What a card offers instead
128
+ // is to switch the conversation to a role that has it: `roles` lists them, and the answer names one.
117
129
  export const GrantNeedSchema = z.object({
118
130
  kind: z.literal("grant"),
119
131
  subject: GrantSubjectSchema,
120
132
  what: z.string().min(1).describe("The capability's id, the folder, or the shelf."),
121
133
  label: z.string().describe("What it is, in the daemon's words: the account and its kind, the folder, the shelf's name."),
122
- persona: z.string().optional().describe("The persona that withholds it, when one does."),
123
- scope: GrantScopeSchema.optional().describe("How far the yes went, once there was one."),
134
+ // Stored as `persona` until 2026-11-18 (needs-store.ts converts it).
135
+ role: z.string().optional().describe("The role that withholds it, when one does."),
136
+ // Added 2026-11-18, optional: a need raised before offered a grant instead.
137
+ roles: z
138
+ .array(GrantRoleSchema)
139
+ .max(50)
140
+ .optional()
141
+ .describe("The roles whose access allows it, any of which the conversation may be switched to. Empty or absent for a site."),
142
+ scope: GrantScopeSchema.optional().describe("How far the yes went, on a need answered before roles were switched instead."),
124
143
  });
125
144
  export type GrantNeed = z.infer<typeof GrantNeedSchema>;
126
145
 
@@ -141,7 +160,7 @@ export type EnvironmentNeed = z.infer<typeof EnvironmentNeedSchema>;
141
160
 
142
161
  // What its check sees today, run once as the automation was proposed, so the person deciding reads the watch working
143
162
  // rather than a promise that it would. Absent for a guard command, which the agent ran itself before asking: run here
144
- // it would carry the proposed persona's credentials before anyone approved them.
163
+ // it would carry the proposed role's credentials before anyone approved them.
145
164
  export const AutomationFirstCheckSchema = z.object({
146
165
  pass: z.boolean().describe("Whether the check passes today, which for a watch waiting on one thing means it would fire at once."),
147
166
  saw: z.string().describe("What it saw, or what it is still waiting for."),
@@ -195,7 +214,7 @@ export const NeedSchema = z.object({
195
214
  export type Need = z.infer<typeof NeedSchema>;
196
215
 
197
216
  // What an agent may send: the kind and what it can know about it. Names, titles and every other field the card shows are
198
- // the daemon's to fill in, from the catalog, the persona, the gate policy.
217
+ // the daemon's to fill in, from the catalog, the role, the gate policy.
199
218
  export const NeedAskSchema = z.discriminatedUnion("kind", [
200
219
  z.object({
201
220
  kind: z.literal("capability"),
@@ -259,7 +278,8 @@ export const NeedAnswerSchema = z.discriminatedUnion("kind", [
259
278
  z.object({ kind: z.literal("accept") }),
260
279
  // A change to a connected capability's settings, or its removal, applied as the card showed it.
261
280
  z.object({ kind: z.literal("apply") }),
262
- z.object({ kind: z.literal("grant"), scope: GrantScopeSchema }),
281
+ // 2026-11-18: was `{ scope }`, a yes that lifted what the role withheld; now the role the conversation switches to.
282
+ z.object({ kind: z.literal("grant"), role: entryId.describe("Which of the need's roles the conversation switches to.") }),
263
283
  z.object({ kind: z.literal("release") }),
264
284
  z.object({ kind: z.literal("approve") }),
265
285
  ]);
@@ -335,12 +355,10 @@ export const BrokerRulePassSchema = z.object({
335
355
  });
336
356
  export type BrokerRulePass = z.infer<typeof BrokerRulePassSchema>;
337
357
 
338
- // What a person allowed one conversation beyond its persona and area, from a grant need's card
339
- // (personas/conversation-grants.ts). Honoured from that conversation's next turn on, and revocable on the Grants page.
358
+ // What a person allowed one conversation (roles/conversation-grants.ts), revocable on the Grants page. Each is a
359
+ // release inside its access, never a widening of it: until 2026-11-18 it also held capabilities, folders and shelves a
360
+ // card lifted past the conversation's role, retired when a role's limits became access.
340
361
  export const ConversationGrantSchema = z.object({
341
- capabilities: z.array(z.string()).default([]).describe("Connected capabilities it may use although its persona leaves them out."),
342
- folders: z.array(z.string()).default([]).describe("Workspace folders its file tools may touch beyond its fence."),
343
- shelves: z.array(GrantShelfSchema).default([]).describe("Shelves of tools opened for it."),
344
362
  // Answered on an install card's "Allow installs for this conversation", read live by the command gate, so it holds
345
363
  // from the install that asked onward, this turn included, and across restarts.
346
364
  installs: z
@@ -400,15 +418,12 @@ export const OwnerGrantSchema = z.discriminatedUnion("kind", [
400
418
  ]);
401
419
  export type OwnerGrant = z.infer<typeof OwnerGrantSchema>;
402
420
 
403
- // Every yes still standing, by conversation: what its grants widened past its persona or area, and which gated
404
- // credentials a named person released to it. Reviewed and taken back from Needs you.
421
+ // Every yes still standing, by conversation, and which gated credentials a named person released to it. Reviewed and
422
+ // taken back from Needs you.
405
423
  export const StandingGrantsSchema = z.object({
406
424
  conversations: z.array(
407
425
  z.object({
408
426
  conversationId: z.string(),
409
- capabilities: z.array(z.string()).describe("Connected capabilities allowed although its persona leaves them out."),
410
- folders: z.array(z.string()).describe("Workspace folders its file tools may touch beyond its fence."),
411
- shelves: z.array(GrantShelfSchema).describe("Shelves of tools opened for it."),
412
427
  installs: z.boolean().default(false).describe("Whether its own dependency installs run without asking."),
413
428
  secrets: z.array(z.string()).default([]).describe("Secrets it may send past their host guard without asking."),
414
429
  everything: z.boolean().default(false).describe("Whether every request an allow-once could settle is allowed without asking."),
@@ -434,13 +449,11 @@ export type StandingGrants = z.infer<typeof StandingGrantsSchema>;
434
449
  export const ConversationGrantRevokeSchema = z.object({
435
450
  conversationId: z.string(),
436
451
  kind: z
437
- .enum(["capability", "folder", "shelf", "release", "install", "secret", "everything", "rule"])
452
+ .enum(["release", "install", "secret", "everything", "rule"])
438
453
  .describe(
439
- "Which kind of yes: a grant past the persona or area, a credential's release, letting its installs run unasked, a secret sent past its host guard, allowing everything, or a credential gateway rule that stopped asking.",
454
+ "Which kind of yes: a credential's release, letting its installs run unasked, a secret sent past its host guard, allowing everything, or a credential gateway rule that stopped asking.",
440
455
  ),
441
- what: z
442
- .string()
443
- .describe("The capability id, folder, shelf, released credential or secret it named, or the rule's identity; empty for installs and everything."),
456
+ what: z.string().describe("The released credential or secret it named, or the rule's identity; empty for installs and everything."),
444
457
  capability: z.string().optional().describe("For a rule, the capability whose rule it is; a rule's identity alone does not say."),
445
458
  });
446
459
  export type ConversationGrantRevoke = z.infer<typeof ConversationGrantRevokeSchema>;