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