@intentic/sandbox-contract 1.424.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 (209) 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 +30 -6
  23. package/dist/contracts/runner.contract.d.ts.map +1 -1
  24. package/dist/contracts/sessions.contract.d.ts +5 -1
  25. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  26. package/dist/contracts/settings.contract.d.ts +2 -2
  27. package/dist/contracts/skills.contract.d.ts +3 -3
  28. package/dist/contracts/skills.contract.js +1 -1
  29. package/dist/contracts/skills.contract.js.map +1 -1
  30. package/dist/contracts/system.contract.d.ts +11 -16
  31. package/dist/contracts/system.contract.d.ts.map +1 -1
  32. package/dist/events/agent-events.d.ts +20 -4
  33. package/dist/events/agent-events.d.ts.map +1 -1
  34. package/dist/events/agent-transcript.d.ts +5 -1
  35. package/dist/events/agent-transcript.d.ts.map +1 -1
  36. package/dist/events/system-events.d.ts +7 -7
  37. package/dist/events/system-events.d.ts.map +1 -1
  38. package/dist/events/system-events.js +3 -3
  39. package/dist/events/system-events.js.map +1 -1
  40. package/dist/events/transcript.d.ts +25 -5
  41. package/dist/events/transcript.d.ts.map +1 -1
  42. package/dist/index.d.ts +2 -2
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +2 -2
  45. package/dist/index.js.map +1 -1
  46. package/dist/models/model-roles.d.ts +1 -1
  47. package/dist/models/model-roles.d.ts.map +1 -1
  48. package/dist/models/model-roles.js +1 -1
  49. package/dist/models/model-roles.js.map +1 -1
  50. package/dist/policy/org-locks.d.ts +1 -1
  51. package/dist/policy/org-locks.d.ts.map +1 -1
  52. package/dist/policy/org-locks.js +1 -1
  53. package/dist/policy/org-locks.js.map +1 -1
  54. package/dist/policy/role-capability.d.ts +7 -0
  55. package/dist/policy/role-capability.d.ts.map +1 -0
  56. package/dist/policy/role-capability.js +3 -0
  57. package/dist/policy/role-capability.js.map +1 -0
  58. package/dist/policy/role-home.d.ts +9 -0
  59. package/dist/policy/role-home.d.ts.map +1 -0
  60. package/dist/policy/role-home.js +7 -0
  61. package/dist/policy/role-home.js.map +1 -0
  62. package/dist/protocol/member-reach.d.ts +4 -4
  63. package/dist/protocol/member-reach.js +3 -3
  64. package/dist/protocol/raw/raw-json-routes.d.ts +29 -23
  65. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  66. package/dist/protocol/route-meta.d.ts +4 -4
  67. package/dist/schemas/access-profiles.d.ts +10 -4
  68. package/dist/schemas/access-profiles.d.ts.map +1 -1
  69. package/dist/schemas/access-profiles.js +9 -4
  70. package/dist/schemas/access-profiles.js.map +1 -1
  71. package/dist/schemas/agent.js +3 -3
  72. package/dist/schemas/agent.js.map +1 -1
  73. package/dist/schemas/agents.js +2 -2
  74. package/dist/schemas/agents.js.map +1 -1
  75. package/dist/schemas/approvals.d.ts +3 -3
  76. package/dist/schemas/approvals.js +3 -3
  77. package/dist/schemas/approvals.js.map +1 -1
  78. package/dist/schemas/automations.js +6 -6
  79. package/dist/schemas/automations.js.map +1 -1
  80. package/dist/schemas/chat-route.d.ts +7 -2
  81. package/dist/schemas/chat-route.d.ts.map +1 -1
  82. package/dist/schemas/chat-route.js +11 -6
  83. package/dist/schemas/chat-route.js.map +1 -1
  84. package/dist/schemas/context-trim.js +1 -1
  85. package/dist/schemas/context-trim.js.map +1 -1
  86. package/dist/schemas/diagnostics.d.ts +3 -3
  87. package/dist/schemas/git/git.js +1 -1
  88. package/dist/schemas/git/git.js.map +1 -1
  89. package/dist/schemas/links.d.ts +1 -1
  90. package/dist/schemas/links.js +4 -4
  91. package/dist/schemas/links.js.map +1 -1
  92. package/dist/schemas/loops.js +1 -1
  93. package/dist/schemas/loops.js.map +1 -1
  94. package/dist/schemas/members.d.ts +162 -20
  95. package/dist/schemas/members.d.ts.map +1 -1
  96. package/dist/schemas/members.js +19 -16
  97. package/dist/schemas/members.js.map +1 -1
  98. package/dist/schemas/needs.d.ts +37 -42
  99. package/dist/schemas/needs.d.ts.map +1 -1
  100. package/dist/schemas/needs.js +18 -16
  101. package/dist/schemas/needs.js.map +1 -1
  102. package/dist/schemas/organisation.d.ts +10 -0
  103. package/dist/schemas/organisation.d.ts.map +1 -1
  104. package/dist/schemas/organisation.js.map +1 -1
  105. package/dist/schemas/{personas.d.ts → roles.d.ts} +37 -72
  106. package/dist/schemas/roles.d.ts.map +1 -0
  107. package/dist/schemas/{personas.js → roles.js} +45 -67
  108. package/dist/schemas/roles.js.map +1 -0
  109. package/dist/schemas/settings-history.d.ts +1 -1
  110. package/dist/schemas/settings-history.d.ts.map +1 -1
  111. package/dist/schemas/settings-history.js +2 -1
  112. package/dist/schemas/settings-history.js.map +1 -1
  113. package/dist/schemas/settings.d.ts +11 -11
  114. package/dist/schemas/settings.d.ts.map +1 -1
  115. package/dist/schemas/settings.js +3 -3
  116. package/dist/schemas/settings.js.map +1 -1
  117. package/dist/schemas/shared.d.ts +6 -5
  118. package/dist/schemas/shared.d.ts.map +1 -1
  119. package/dist/schemas/shared.js +14 -5
  120. package/dist/schemas/shared.js.map +1 -1
  121. package/dist/schemas/system-prompt.d.ts +12 -12
  122. package/dist/schemas/system-prompt.d.ts.map +1 -1
  123. package/dist/schemas/system-prompt.js +1 -1
  124. package/dist/schemas/system-prompt.js.map +1 -1
  125. package/dist/schemas/terminal.d.ts +18 -0
  126. package/dist/schemas/terminal.d.ts.map +1 -1
  127. package/dist/schemas/terminal.js +16 -1
  128. package/dist/schemas/terminal.js.map +1 -1
  129. package/dist/schemas/tool-ceiling.d.ts +4 -2
  130. package/dist/schemas/tool-ceiling.d.ts.map +1 -1
  131. package/dist/schemas/tool-ceiling.js +29 -3
  132. package/dist/schemas/tool-ceiling.js.map +1 -1
  133. package/dist/schemas/workflows.js +1 -1
  134. package/dist/schemas/workflows.js.map +1 -1
  135. package/dist/state/definition.d.ts +4 -4
  136. package/dist/state/workspace-state.d.ts +4 -4
  137. package/dist/state/workspace-state.d.ts.map +1 -1
  138. package/dist/state/workspace-state.js +2 -2
  139. package/dist/state/workspace-state.js.map +1 -1
  140. package/package.json +5 -5
  141. package/src/contracts/agent.contract.ts +2 -2
  142. package/src/contracts/agents.contract.ts +1 -1
  143. package/src/contracts/automations.contract.ts +1 -1
  144. package/src/contracts/logs.contract.ts +1 -1
  145. package/src/contracts/needs.contract.ts +2 -2
  146. package/src/contracts/roles.contract.ts +108 -0
  147. package/src/contracts/skills.contract.ts +2 -2
  148. package/src/events/system-events.ts +5 -4
  149. package/src/index.ts +3 -3
  150. package/src/models/agent-runtimes.ts +8 -8
  151. package/src/models/model-roles.ts +3 -3
  152. package/src/policy/control-scopes.ts +1 -1
  153. package/src/policy/fence-paths.ts +2 -2
  154. package/src/policy/org-locks.ts +2 -1
  155. package/src/policy/role-capability.ts +29 -0
  156. package/src/policy/role-home.ts +29 -0
  157. package/src/policy/tests/fence-paths.test.ts +1 -1
  158. package/src/policy/tests/role-home.test.ts +40 -0
  159. package/src/protocol/member-reach.test.ts +17 -17
  160. package/src/protocol/member-reach.ts +7 -7
  161. package/src/protocol/route-meta.ts +6 -6
  162. package/src/schemas/access-profiles.ts +20 -9
  163. package/src/schemas/agent.ts +4 -4
  164. package/src/schemas/agents.ts +2 -2
  165. package/src/schemas/approvals.ts +3 -3
  166. package/src/schemas/automations.ts +14 -14
  167. package/src/schemas/capabilities.ts +1 -1
  168. package/src/schemas/chat-route.ts +18 -9
  169. package/src/schemas/context-trim.ts +1 -1
  170. package/src/schemas/diagnostics.ts +1 -1
  171. package/src/schemas/git/git.ts +1 -1
  172. package/src/schemas/internal.ts +1 -1
  173. package/src/schemas/links.ts +7 -7
  174. package/src/schemas/loops.ts +1 -1
  175. package/src/schemas/members.test.ts +31 -31
  176. package/src/schemas/members.ts +37 -29
  177. package/src/schemas/needs.ts +35 -22
  178. package/src/schemas/organisation.ts +2 -0
  179. package/src/schemas/{personas.ts → roles.ts} +83 -113
  180. package/src/schemas/settings-history.ts +3 -1
  181. package/src/schemas/settings.ts +10 -6
  182. package/src/schemas/shared.ts +24 -10
  183. package/src/schemas/state-plan.test.ts +3 -3
  184. package/src/schemas/system-prompt.ts +2 -1
  185. package/src/schemas/terminal.ts +18 -1
  186. package/src/schemas/tool-ceiling.test.ts +14 -8
  187. package/src/schemas/tool-ceiling.ts +42 -11
  188. package/src/schemas/workflows.ts +1 -1
  189. package/src/state/auth-state.ts +1 -1
  190. package/src/state/definition.ts +1 -1
  191. package/src/state/workspace-state.test.ts +5 -5
  192. package/src/state/workspace-state.ts +11 -11
  193. package/dist/contracts/personas.contract.d.ts.map +0 -1
  194. package/dist/contracts/personas.contract.js +0 -78
  195. package/dist/contracts/personas.contract.js.map +0 -1
  196. package/dist/policy/persona-capability.d.ts +0 -14
  197. package/dist/policy/persona-capability.d.ts.map +0 -1
  198. package/dist/policy/persona-capability.js +0 -24
  199. package/dist/policy/persona-capability.js.map +0 -1
  200. package/dist/policy/persona-home.d.ts +0 -10
  201. package/dist/policy/persona-home.d.ts.map +0 -1
  202. package/dist/policy/persona-home.js +0 -11
  203. package/dist/policy/persona-home.js.map +0 -1
  204. package/dist/schemas/personas.d.ts.map +0 -1
  205. package/dist/schemas/personas.js.map +0 -1
  206. package/src/contracts/personas.contract.ts +0 -106
  207. package/src/policy/persona-capability.ts +0 -64
  208. package/src/policy/persona-home.ts +0 -39
  209. package/src/policy/tests/persona-home.test.ts +0 -51
@@ -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>;
@@ -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;