@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.
- package/dist/contracts/access-profiles.contract.d.ts +7 -3
- package/dist/contracts/access-profiles.contract.d.ts.map +1 -1
- package/dist/contracts/agent.contract.d.ts +51 -10
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agent.contract.js +1 -1
- package/dist/contracts/agent.contract.js.map +1 -1
- package/dist/contracts/agents.contract.d.ts +13 -5
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.js +1 -1
- package/dist/contracts/agents.contract.js.map +1 -1
- package/dist/contracts/approvals.contract.d.ts +1 -1
- package/dist/contracts/needs.contract.d.ts +41 -26
- package/dist/contracts/needs.contract.d.ts.map +1 -1
- package/dist/contracts/needs.contract.js +2 -2
- package/dist/contracts/needs.contract.js.map +1 -1
- package/dist/contracts/org.contract.d.ts +3 -0
- package/dist/contracts/org.contract.d.ts.map +1 -1
- package/dist/contracts/{personas.contract.d.ts → roles.contract.d.ts} +3 -39
- package/dist/contracts/roles.contract.d.ts.map +1 -0
- package/dist/contracts/roles.contract.js +78 -0
- package/dist/contracts/roles.contract.js.map +1 -0
- package/dist/contracts/runner.contract.d.ts +30 -6
- package/dist/contracts/runner.contract.d.ts.map +1 -1
- package/dist/contracts/sessions.contract.d.ts +5 -1
- package/dist/contracts/sessions.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.d.ts +2 -2
- package/dist/contracts/skills.contract.d.ts +3 -3
- package/dist/contracts/skills.contract.js +1 -1
- package/dist/contracts/skills.contract.js.map +1 -1
- package/dist/contracts/system.contract.d.ts +11 -16
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/events/agent-events.d.ts +20 -4
- package/dist/events/agent-events.d.ts.map +1 -1
- package/dist/events/agent-transcript.d.ts +5 -1
- package/dist/events/agent-transcript.d.ts.map +1 -1
- package/dist/events/system-events.d.ts +7 -7
- package/dist/events/system-events.d.ts.map +1 -1
- package/dist/events/system-events.js +3 -3
- package/dist/events/system-events.js.map +1 -1
- package/dist/events/transcript.d.ts +25 -5
- package/dist/events/transcript.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/models/model-roles.d.ts +1 -1
- package/dist/models/model-roles.d.ts.map +1 -1
- package/dist/models/model-roles.js +1 -1
- package/dist/models/model-roles.js.map +1 -1
- package/dist/policy/org-locks.d.ts +1 -1
- package/dist/policy/org-locks.d.ts.map +1 -1
- package/dist/policy/org-locks.js +1 -1
- package/dist/policy/org-locks.js.map +1 -1
- package/dist/policy/role-capability.d.ts +7 -0
- package/dist/policy/role-capability.d.ts.map +1 -0
- package/dist/policy/role-capability.js +3 -0
- package/dist/policy/role-capability.js.map +1 -0
- package/dist/policy/role-home.d.ts +9 -0
- package/dist/policy/role-home.d.ts.map +1 -0
- package/dist/policy/role-home.js +7 -0
- package/dist/policy/role-home.js.map +1 -0
- package/dist/protocol/member-reach.d.ts +4 -4
- package/dist/protocol/member-reach.js +3 -3
- package/dist/protocol/raw/raw-json-routes.d.ts +29 -23
- package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
- package/dist/protocol/route-meta.d.ts +4 -4
- package/dist/schemas/access-profiles.d.ts +10 -4
- package/dist/schemas/access-profiles.d.ts.map +1 -1
- package/dist/schemas/access-profiles.js +9 -4
- package/dist/schemas/access-profiles.js.map +1 -1
- package/dist/schemas/agent.js +3 -3
- package/dist/schemas/agent.js.map +1 -1
- package/dist/schemas/agents.js +2 -2
- package/dist/schemas/agents.js.map +1 -1
- package/dist/schemas/approvals.d.ts +3 -3
- package/dist/schemas/approvals.js +3 -3
- package/dist/schemas/approvals.js.map +1 -1
- package/dist/schemas/automations.js +6 -6
- package/dist/schemas/automations.js.map +1 -1
- package/dist/schemas/chat-route.d.ts +7 -2
- package/dist/schemas/chat-route.d.ts.map +1 -1
- package/dist/schemas/chat-route.js +11 -6
- package/dist/schemas/chat-route.js.map +1 -1
- package/dist/schemas/context-trim.js +1 -1
- package/dist/schemas/context-trim.js.map +1 -1
- package/dist/schemas/diagnostics.d.ts +3 -3
- package/dist/schemas/git/git.js +1 -1
- package/dist/schemas/git/git.js.map +1 -1
- package/dist/schemas/links.d.ts +1 -1
- package/dist/schemas/links.js +4 -4
- package/dist/schemas/links.js.map +1 -1
- package/dist/schemas/loops.js +1 -1
- package/dist/schemas/loops.js.map +1 -1
- package/dist/schemas/members.d.ts +162 -20
- package/dist/schemas/members.d.ts.map +1 -1
- package/dist/schemas/members.js +19 -16
- package/dist/schemas/members.js.map +1 -1
- package/dist/schemas/needs.d.ts +37 -42
- package/dist/schemas/needs.d.ts.map +1 -1
- package/dist/schemas/needs.js +18 -16
- package/dist/schemas/needs.js.map +1 -1
- package/dist/schemas/organisation.d.ts +10 -0
- package/dist/schemas/organisation.d.ts.map +1 -1
- package/dist/schemas/organisation.js.map +1 -1
- package/dist/schemas/{personas.d.ts → roles.d.ts} +37 -72
- package/dist/schemas/roles.d.ts.map +1 -0
- package/dist/schemas/{personas.js → roles.js} +45 -67
- package/dist/schemas/roles.js.map +1 -0
- package/dist/schemas/settings-history.d.ts +1 -1
- package/dist/schemas/settings-history.d.ts.map +1 -1
- package/dist/schemas/settings-history.js +2 -1
- package/dist/schemas/settings-history.js.map +1 -1
- package/dist/schemas/settings.d.ts +11 -11
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +3 -3
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/shared.d.ts +6 -5
- package/dist/schemas/shared.d.ts.map +1 -1
- package/dist/schemas/shared.js +14 -5
- package/dist/schemas/shared.js.map +1 -1
- package/dist/schemas/system-prompt.d.ts +12 -12
- package/dist/schemas/system-prompt.d.ts.map +1 -1
- package/dist/schemas/system-prompt.js +1 -1
- package/dist/schemas/system-prompt.js.map +1 -1
- package/dist/schemas/terminal.d.ts +18 -0
- package/dist/schemas/terminal.d.ts.map +1 -1
- package/dist/schemas/terminal.js +16 -1
- package/dist/schemas/terminal.js.map +1 -1
- package/dist/schemas/tool-ceiling.d.ts +4 -2
- package/dist/schemas/tool-ceiling.d.ts.map +1 -1
- package/dist/schemas/tool-ceiling.js +29 -3
- package/dist/schemas/tool-ceiling.js.map +1 -1
- package/dist/schemas/workflows.js +1 -1
- package/dist/schemas/workflows.js.map +1 -1
- package/dist/state/definition.d.ts +4 -4
- package/dist/state/workspace-state.d.ts +4 -4
- package/dist/state/workspace-state.d.ts.map +1 -1
- package/dist/state/workspace-state.js +2 -2
- package/dist/state/workspace-state.js.map +1 -1
- package/package.json +5 -5
- package/src/contracts/agent.contract.ts +2 -2
- package/src/contracts/agents.contract.ts +1 -1
- package/src/contracts/automations.contract.ts +1 -1
- package/src/contracts/logs.contract.ts +1 -1
- package/src/contracts/needs.contract.ts +2 -2
- package/src/contracts/roles.contract.ts +108 -0
- package/src/contracts/skills.contract.ts +2 -2
- package/src/events/system-events.ts +5 -4
- package/src/index.ts +3 -3
- package/src/models/agent-runtimes.ts +8 -8
- package/src/models/model-roles.ts +3 -3
- package/src/policy/control-scopes.ts +1 -1
- package/src/policy/fence-paths.ts +2 -2
- package/src/policy/org-locks.ts +2 -1
- package/src/policy/role-capability.ts +29 -0
- package/src/policy/role-home.ts +29 -0
- package/src/policy/tests/fence-paths.test.ts +1 -1
- package/src/policy/tests/role-home.test.ts +40 -0
- package/src/protocol/member-reach.test.ts +17 -17
- package/src/protocol/member-reach.ts +7 -7
- package/src/protocol/route-meta.ts +6 -6
- package/src/schemas/access-profiles.ts +20 -9
- package/src/schemas/agent.ts +4 -4
- package/src/schemas/agents.ts +2 -2
- package/src/schemas/approvals.ts +3 -3
- package/src/schemas/automations.ts +14 -14
- package/src/schemas/capabilities.ts +1 -1
- package/src/schemas/chat-route.ts +18 -9
- package/src/schemas/context-trim.ts +1 -1
- package/src/schemas/diagnostics.ts +1 -1
- package/src/schemas/git/git.ts +1 -1
- package/src/schemas/internal.ts +1 -1
- package/src/schemas/links.ts +7 -7
- package/src/schemas/loops.ts +1 -1
- package/src/schemas/members.test.ts +31 -31
- package/src/schemas/members.ts +37 -29
- package/src/schemas/needs.ts +35 -22
- package/src/schemas/organisation.ts +2 -0
- package/src/schemas/{personas.ts → roles.ts} +83 -113
- package/src/schemas/settings-history.ts +3 -1
- package/src/schemas/settings.ts +10 -6
- package/src/schemas/shared.ts +24 -10
- package/src/schemas/state-plan.test.ts +3 -3
- package/src/schemas/system-prompt.ts +2 -1
- package/src/schemas/terminal.ts +18 -1
- package/src/schemas/tool-ceiling.test.ts +14 -8
- package/src/schemas/tool-ceiling.ts +42 -11
- package/src/schemas/workflows.ts +1 -1
- package/src/state/auth-state.ts +1 -1
- package/src/state/definition.ts +1 -1
- package/src/state/workspace-state.test.ts +5 -5
- package/src/state/workspace-state.ts +11 -11
- package/dist/contracts/personas.contract.d.ts.map +0 -1
- package/dist/contracts/personas.contract.js +0 -78
- package/dist/contracts/personas.contract.js.map +0 -1
- package/dist/policy/persona-capability.d.ts +0 -14
- package/dist/policy/persona-capability.d.ts.map +0 -1
- package/dist/policy/persona-capability.js +0 -24
- package/dist/policy/persona-capability.js.map +0 -1
- package/dist/policy/persona-home.d.ts +0 -10
- package/dist/policy/persona-home.d.ts.map +0 -1
- package/dist/policy/persona-home.js +0 -11
- package/dist/policy/persona-home.js.map +0 -1
- package/dist/schemas/personas.d.ts.map +0 -1
- package/dist/schemas/personas.js.map +0 -1
- package/src/contracts/personas.contract.ts +0 -106
- package/src/policy/persona-capability.ts +0 -64
- package/src/policy/persona-home.ts +0 -39
- package/src/policy/tests/persona-home.test.ts +0 -51
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { procedure } from "../protocol/route-meta.js";
|
|
2
|
+
import {
|
|
3
|
+
RoleIdParamSchema,
|
|
4
|
+
RoleKitSchema,
|
|
5
|
+
RolePromptSchema,
|
|
6
|
+
RoleSchema,
|
|
7
|
+
RoleSkillBodySchema,
|
|
8
|
+
RoleSkillNameSchema,
|
|
9
|
+
RoleSkillSchema,
|
|
10
|
+
RolesListSchema,
|
|
11
|
+
} from "../schemas/roles.js";
|
|
12
|
+
import { OkSchema } from "../schemas/shared.js";
|
|
13
|
+
|
|
14
|
+
// Named roles (RoleSchema): accounts each speaks for, where it opens, what it is told; what it may reach is the access
|
|
15
|
+
// profiles that list it (access-profiles.ts `roles`). Card CRUD provisions nothing, only a decision about existing
|
|
16
|
+
// accounts. The paths keep the word they had before personas were renamed roles (2026-11-18), so an editor or a script
|
|
17
|
+
// written against a daemon from before calls the same addresses either side of the rename. The kit routes below edit its files (prompt, skills only its turns
|
|
18
|
+
// reach) per verb, not one whole-kit PUT, so one skill's edit cannot delete another.
|
|
19
|
+
export const rolesContract = {
|
|
20
|
+
list: procedure
|
|
21
|
+
.route({
|
|
22
|
+
method: "GET",
|
|
23
|
+
path: "/personas",
|
|
24
|
+
summary: "The characters an agent can wear",
|
|
25
|
+
description:
|
|
26
|
+
"Each role with the connected accounts it speaks for, where a conversation wearing it opens, and what it is told. What it may reach is the access profiles that list it.",
|
|
27
|
+
})
|
|
28
|
+
.meta({ guest: true })
|
|
29
|
+
.output(RolesListSchema),
|
|
30
|
+
// Upsert by id, re-saving the same id edits that card.
|
|
31
|
+
save: procedure
|
|
32
|
+
.route({
|
|
33
|
+
method: "POST",
|
|
34
|
+
path: "/personas",
|
|
35
|
+
summary: "Create or edit a role",
|
|
36
|
+
description:
|
|
37
|
+
"Writes the whole card; sending an id that exists edits it. Nothing is connected, installed or spent by saving one, because a role only records a decision about accounts that already exist. It is stored as a file you can equally well edit by hand, which is why this writes the card whole rather than patching a field: a round trip through a screen should leave a change a reviewer recognises.",
|
|
38
|
+
})
|
|
39
|
+
.input(RoleSchema)
|
|
40
|
+
.output(OkSchema),
|
|
41
|
+
// Never removes the account; an automation pinned to this id resolves as no accounts, and goes quiet.
|
|
42
|
+
// Also deletes the role's kit folder (prompt + skills), rather than leaving it orphaned on disk.
|
|
43
|
+
remove: procedure
|
|
44
|
+
.route({
|
|
45
|
+
method: "DELETE",
|
|
46
|
+
path: "/personas/{id}",
|
|
47
|
+
summary: "Delete a role",
|
|
48
|
+
description:
|
|
49
|
+
"Takes away the character, never the accounts: every login it named stays connected. Its own prompt and skills go with it, since a folder nothing can reach is worse than deleting what somebody just asked to delete. Anything still pointed at it goes quiet rather than falling back to speaking as everyone.",
|
|
50
|
+
})
|
|
51
|
+
.input(RoleIdParamSchema)
|
|
52
|
+
.output(OkSchema),
|
|
53
|
+
|
|
54
|
+
// Which role a new chat belongs to is answered by `agent.routeChat`, in the same reading that chooses its model.
|
|
55
|
+
|
|
56
|
+
// The kit: what this card is told, and the skills only it reaches.
|
|
57
|
+
|
|
58
|
+
kit: procedure
|
|
59
|
+
.route({
|
|
60
|
+
method: "GET",
|
|
61
|
+
path: "/personas/{id}/kit",
|
|
62
|
+
summary: "What one role carries",
|
|
63
|
+
description:
|
|
64
|
+
"The instructions this role is given and the skills only its conversations can reach. A different question from what the agent knows generally, with a different answer.",
|
|
65
|
+
})
|
|
66
|
+
.input(RoleIdParamSchema)
|
|
67
|
+
.output(RoleKitSchema),
|
|
68
|
+
// An empty prompt deletes the file rather than storing a blank; it then falls back to the sandbox's own prompt.
|
|
69
|
+
savePrompt: procedure
|
|
70
|
+
.route({
|
|
71
|
+
method: "POST",
|
|
72
|
+
path: "/personas/{id}/prompt",
|
|
73
|
+
summary: "Write a role's instructions",
|
|
74
|
+
description:
|
|
75
|
+
"Sets what this role is told. Saving an empty one removes it entirely rather than storing a blank, so the role simply falls back to the sandbox's own instructions.",
|
|
76
|
+
})
|
|
77
|
+
.input(RolePromptSchema)
|
|
78
|
+
.output(OkSchema),
|
|
79
|
+
readSkill: procedure
|
|
80
|
+
.route({
|
|
81
|
+
method: "GET",
|
|
82
|
+
path: "/personas/{id}/skills/read",
|
|
83
|
+
summary: "Read one of a role's skills",
|
|
84
|
+
description: "The full text of a single skill belonging to this role.",
|
|
85
|
+
})
|
|
86
|
+
.input(RoleSkillNameSchema)
|
|
87
|
+
.output(RoleSkillBodySchema),
|
|
88
|
+
// Upsert by name, no enabled list to write: a kit skill is on exactly when its role is worn.
|
|
89
|
+
saveSkill: procedure
|
|
90
|
+
.route({
|
|
91
|
+
method: "POST",
|
|
92
|
+
path: "/personas/{id}/skills",
|
|
93
|
+
summary: "Write one of a role's skills",
|
|
94
|
+
description:
|
|
95
|
+
"Creates or replaces a skill by name. There is nothing to switch on: a role's skill is available exactly when that role is worn, which is what belonging to it has to mean.",
|
|
96
|
+
})
|
|
97
|
+
.input(RoleSkillSchema)
|
|
98
|
+
.output(OkSchema),
|
|
99
|
+
removeSkill: procedure
|
|
100
|
+
.route({
|
|
101
|
+
method: "POST",
|
|
102
|
+
path: "/personas/{id}/skills/remove",
|
|
103
|
+
summary: "Delete one of a role's skills",
|
|
104
|
+
description: "Removes a single skill from this role and leaves the rest of its kit alone.",
|
|
105
|
+
})
|
|
106
|
+
.input(RoleSkillNameSchema)
|
|
107
|
+
.output(OkSchema),
|
|
108
|
+
};
|
|
@@ -3,7 +3,7 @@ import { SkillBodySchema, SkillDraftSchema, SkillIdSchema, SkillRemoveSchema, Sk
|
|
|
3
3
|
import { OkSchema } from "../schemas/shared.js";
|
|
4
4
|
|
|
5
5
|
// What the agent knows and which half the owner controls; `list` joins every source (the owner's own, the settings,
|
|
6
|
-
// connections, plugin checkouts, extension folders,
|
|
6
|
+
// connections, plugin checkouts, extension folders, role kits). A baked tool's switch rides settings' `skills`
|
|
7
7
|
// array; an own skill is on while the agent's copy of it exists, which `switch` moves and `save`/`remove` write
|
|
8
8
|
// together with the text. `read` takes the id in the query, since an id can name an owner and won't fit a path
|
|
9
9
|
// template.
|
|
@@ -14,7 +14,7 @@ export const skillsContract = {
|
|
|
14
14
|
path: "/skills",
|
|
15
15
|
summary: "What the agent knows how to do",
|
|
16
16
|
description:
|
|
17
|
-
"Every skill available here and whether it is switched on, joined from all the places they come from: the owner's own, the settings, plugins a connection installed, folders inside extensions, and
|
|
17
|
+
"Every skill available here and whether it is switched on, joined from all the places they come from: the owner's own, the settings, plugins a connection installed, folders inside extensions, and role kits.",
|
|
18
18
|
})
|
|
19
19
|
.output(SkillsListSchema),
|
|
20
20
|
read: procedure
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AgentSummarySchema } from "../schemas/agents.js";
|
|
3
3
|
import { AccountUsageSchema, type ProviderRefusal, ProviderRefusalSchema } from "../schemas/providers/plan-limits.js";
|
|
4
|
-
import {
|
|
4
|
+
import { MemberTierSchema, withLegacyTier } from "../schemas/shared.js";
|
|
5
5
|
import { SwitchOffsSchema } from "../schemas/providers/refusals.js";
|
|
6
6
|
import { WorkspaceTreeDeltaSchema } from "../schemas/workspace/workspace-tree.js";
|
|
7
7
|
|
|
@@ -166,8 +166,9 @@ export const PresenceUserSchema = z.object({
|
|
|
166
166
|
email: z.string(),
|
|
167
167
|
name: z.string().optional(),
|
|
168
168
|
picture: z.string().optional(),
|
|
169
|
-
// The caller's trust tier, resolved at connection time; on the roster so a tab can also read its own role
|
|
170
|
-
|
|
169
|
+
// The caller's trust tier, resolved at connection time; on the roster so a tab can also read its own. Sent as `role`
|
|
170
|
+
// until 2026-11-18 (schemas/members.ts legacyTier), which an older daemon still does.
|
|
171
|
+
tier: MemberTierSchema,
|
|
171
172
|
idle: z.boolean(),
|
|
172
173
|
// On screen, but untouched for several minutes (PresenceReport's `away`); absent reads as not away.
|
|
173
174
|
away: z.boolean().optional(),
|
|
@@ -182,7 +183,7 @@ export type PresenceUser = z.infer<typeof PresenceUserSchema>;
|
|
|
182
183
|
|
|
183
184
|
// The full roster of connected members, broadcast on every change; snapshot not diff, so a reconnecting browser is
|
|
184
185
|
// consistent from its first frame.
|
|
185
|
-
export const PresenceSchema = z.object({ kind: z.literal("presence"), users: z.array(PresenceUserSchema) });
|
|
186
|
+
export const PresenceSchema = z.object({ kind: z.literal("presence"), users: z.array(withLegacyTier(PresenceUserSchema)) });
|
|
186
187
|
export type Presence = z.infer<typeof PresenceSchema>;
|
|
187
188
|
|
|
188
189
|
// The full fleet roster, snapshot per change; unlike presence, not last-frame-wins: the browser applies a frame only if
|
package/src/index.ts
CHANGED
|
@@ -32,7 +32,7 @@ import { offloadContract } from "./contracts/offload.contract.js";
|
|
|
32
32
|
import { orgContract } from "./contracts/org.contract.js";
|
|
33
33
|
import { pagesContract } from "./contracts/pages.contract.js";
|
|
34
34
|
import { panelsContract } from "./contracts/panels.contract.js";
|
|
35
|
-
import {
|
|
35
|
+
import { rolesContract } from "./contracts/roles.contract.js";
|
|
36
36
|
import { portsContract } from "./contracts/ports.contract.js";
|
|
37
37
|
import { privacyContract } from "./contracts/privacy.contract.js";
|
|
38
38
|
import { providersContract } from "./contracts/providers.contract.js";
|
|
@@ -89,7 +89,7 @@ export const sandboxContract: {
|
|
|
89
89
|
org: typeof orgContract;
|
|
90
90
|
pages: typeof pagesContract;
|
|
91
91
|
panels: typeof panelsContract;
|
|
92
|
-
|
|
92
|
+
roles: typeof rolesContract;
|
|
93
93
|
ports: typeof portsContract;
|
|
94
94
|
privacy: typeof privacyContract;
|
|
95
95
|
providers: typeof providersContract;
|
|
@@ -140,7 +140,7 @@ export const sandboxContract: {
|
|
|
140
140
|
org: orgContract,
|
|
141
141
|
pages: pagesContract,
|
|
142
142
|
panels: panelsContract,
|
|
143
|
-
|
|
143
|
+
roles: rolesContract,
|
|
144
144
|
ports: portsContract,
|
|
145
145
|
privacy: privacyContract,
|
|
146
146
|
providers: providersContract,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// listed only if something reads it: a gate, a control, or limitationsOf. This file is the bottom of the provider graph
|
|
3
3
|
// and imports nothing from the rest of the contract, so the arrow points one way.
|
|
4
4
|
|
|
5
|
-
// An execution backend: one way a turn runs its own work, named for AgentCapabilities.execution and the
|
|
5
|
+
// An execution backend: one way a turn runs its own work, named for AgentCapabilities.execution and the role switch
|
|
6
6
|
// that grants it.
|
|
7
7
|
export type ExecutionBackend = "shell" | "js";
|
|
8
8
|
|
|
@@ -55,7 +55,7 @@ export interface AgentCapabilities {
|
|
|
55
55
|
// session opens with (the sandbox's agent/run/decide/turn-skills.ts), less the ones the turn may not use:
|
|
56
56
|
// workspace - the workspace's loaded skills (.agents/skills, or the .claude/skills projection of them);
|
|
57
57
|
// builtIn - the product's own skills the image bakes (/root/.claude/skills);
|
|
58
|
-
// kit - the worn
|
|
58
|
+
// kit - the worn role's own skills, which the daemon hands the loader per turn.
|
|
59
59
|
readonly skillDiscovery: SkillDiscovery;
|
|
60
60
|
// Whether the owner's safety policy reaches this runtime, and how:
|
|
61
61
|
// hooks - its own pre-execution hook can park a call and wait for a card (Claude Code only).
|
|
@@ -152,7 +152,7 @@ export const CODEX: AgentCapabilities = {
|
|
|
152
152
|
// thread/start's own fields: baseInstructions replaces Codex's base prompt, developerInstructions adds a developer
|
|
153
153
|
// message.
|
|
154
154
|
instructions: "replace",
|
|
155
|
-
// Codex reads the workspace's `.agents/skills` itself; the built-ins and a
|
|
155
|
+
// Codex reads the workspace's `.agents/skills` itself; the built-ins and a role's kit are named in the note.
|
|
156
156
|
skillDiscovery: { workspace: true, builtIn: false, kit: false },
|
|
157
157
|
// A per-thread PreToolUse hook puts every function tool (the shell, apply_patch, every MCP tool, spawn_agent) to the
|
|
158
158
|
// door's gate before it runs, which may park it on a card (codex-hooks.ts). Codex fails a hook open, so the gate is
|
|
@@ -219,7 +219,7 @@ export const OPENCODE: AgentCapabilities = {
|
|
|
219
219
|
// A prompt that replaces the base (the owner's own under `custom`, a small window's paragraph) runs on the daemon's
|
|
220
220
|
// twin agents, whose base is blank, so it is the whole system text; anything else is added to OpenCode's own base.
|
|
221
221
|
instructions: "replace",
|
|
222
|
-
// The server's skill roots are the workspace's loaded skills and the built-ins (opencode.ts serverConfig); a
|
|
222
|
+
// The server's skill roots are the workspace's loaded skills and the built-ins (opencode.ts serverConfig); a role's
|
|
223
223
|
// kit, which changes per turn on a server shared by every turn, is named in the note.
|
|
224
224
|
skillDiscovery: { workspace: true, builtIn: true, kit: false },
|
|
225
225
|
// OpenCode raises its permission asks for every shell command, a subagent's included (the server's own rules ask about
|
|
@@ -283,7 +283,7 @@ export const ACP: AgentCapabilities = {
|
|
|
283
283
|
// (turn-watchdog.ts expiredFrame), so a turn the provider dropped is re-run once it is back, as every loop's is.
|
|
284
284
|
recovery: true,
|
|
285
285
|
warm: false,
|
|
286
|
-
// ACP's calls carry no system field: the agent owns its instructions, the
|
|
286
|
+
// ACP's calls carry no system field: the agent owns its instructions, the role note rides the message.
|
|
287
287
|
instructions: "none",
|
|
288
288
|
skillDiscovery: NO_SKILL_LOADER,
|
|
289
289
|
// In the protocol floor, so every agent has it; which calls it asks about is entirely its own choice. A terminal the
|
|
@@ -366,7 +366,7 @@ export const PI: AgentCapabilities = {
|
|
|
366
366
|
// `--system-prompt` replaces Pi's base and `--append-system-prompt` adds to it, both per process; `--no-context-files`
|
|
367
367
|
// keeps Pi from loading AGENTS.md a second time beside the daemon's own note.
|
|
368
368
|
instructions: "replace",
|
|
369
|
-
// `--skill` per loaded skill, the
|
|
369
|
+
// `--skill` per loaded skill, the role's filter applied, with Pi's own discovery off (`--no-skills`).
|
|
370
370
|
// Pi's own discovery is off, and every skill the turn may use is handed to it by path (`--skill`, pi-adapter.ts).
|
|
371
371
|
skillDiscovery: EVERY_SKILL,
|
|
372
372
|
// The daemon's extension, loaded with `-e` ahead of any other and whatever the card's command says of discovery, puts
|
|
@@ -431,9 +431,9 @@ export const CURSOR: AgentCapabilities = {
|
|
|
431
431
|
// (cursor-agent.ts); everything else the daemon adds always rides that append.
|
|
432
432
|
instructions: "replace",
|
|
433
433
|
// Cursor's own loader reads every SKILL.md under `.agents/skills/` of each workspace root it is given: the cwd holds
|
|
434
|
-
// the loaded skills, and the worn
|
|
434
|
+
// the loaded skills, and the worn role's kit is laid out as a second root (`local.dirs`); a skill the role
|
|
435
435
|
// withholds is refused at the read tool, the seam the Claude loop's `Skill(<name>)` denial is (cursor-skills.ts).
|
|
436
|
-
// The workspace's skills from the turn's own tree and the
|
|
436
|
+
// The workspace's skills from the turn's own tree and the role's kit as a projected root (cursor-skills.ts); the
|
|
437
437
|
// built-ins, outside every root it is given, are named in the note.
|
|
438
438
|
skillDiscovery: { workspace: true, builtIn: false, kit: true },
|
|
439
439
|
// The full hook tier, the only foreign runtime to reach it: a hold parks since the vendor waits on the hook.
|
|
@@ -85,12 +85,12 @@ export const MODEL_ROLES = [
|
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
// One reading answering both halves of "what does this chat open on": an offered `provider:model` line with an
|
|
88
|
-
// effort and an account, and a
|
|
89
|
-
// id predates the
|
|
88
|
+
// effort and an account, and a role id, each a classification over a fixed list rather than free text. The
|
|
89
|
+
// id predates the role half and stays as it is, since it is what a settings file already carries.
|
|
90
90
|
// Prompt carries live account headroom, so it must not be a model whose own allowance it is reading.
|
|
91
91
|
id: "model-router",
|
|
92
92
|
label: "New chat routing",
|
|
93
|
-
blurb: "Which model reads a new chat's first message and picks what it opens on: the model, effort and account, and the
|
|
93
|
+
blurb: "Which model reads a new chat's first message and picks what it opens on: the model, effort and account, and the role.",
|
|
94
94
|
kind: "helper",
|
|
95
95
|
icon: "sparkles",
|
|
96
96
|
setup: "low",
|
|
@@ -13,7 +13,7 @@ export interface ControlScopeReach {
|
|
|
13
13
|
readonly note: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// Derived in the daemon from the same
|
|
16
|
+
// Derived in the daemon from the same tier floors a member holds (read=viewer, drive=collaborator).
|
|
17
17
|
export const CONTROL_SCOPE_REACH: readonly ControlScopeReach[] = [
|
|
18
18
|
{
|
|
19
19
|
scope: "editor",
|
|
@@ -39,7 +39,7 @@ export const pathInsideFolder = (folder: string, path: string): boolean => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// "Change the sandbox" as paths: the daemon's own configuration, and the outbox the internet reads. One list, read by
|
|
42
|
-
// the
|
|
42
|
+
// the role hook that judges a turn's writes and by the area schema that decides what a grant may name.
|
|
43
43
|
export const SANDBOX_PATHS: readonly string[] = [STATE_DIR, PUBLIC_DIR];
|
|
44
44
|
|
|
45
45
|
// Whether a path is one of those folders or sits inside one, by segment: `publications` is not `public`.
|
|
@@ -82,7 +82,7 @@ export const fenceCovers = (outer: Fence, inner: Fence): boolean => {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* The tighter of two fences: what a turn may touch when a
|
|
85
|
+
* The tighter of two fences: what a turn may touch when a role's folders meet the member's own. Undefined on both
|
|
86
86
|
* sides is the whole workspace; either side alone narrows to itself.
|
|
87
87
|
*/
|
|
88
88
|
export const fenceIntersection = (left: Fence, right: Fence): Fence => {
|
package/src/policy/org-locks.ts
CHANGED
|
@@ -93,7 +93,8 @@ export const ORG_SECTION_ROUTES = {
|
|
|
93
93
|
],
|
|
94
94
|
},
|
|
95
95
|
areas: { changes: ["areas.save", "areas.remove"] },
|
|
96
|
-
|
|
96
|
+
// The Roles section, under the id it had as Personas (organisation.ts ORG_SECTIONS).
|
|
97
|
+
personas: { changes: ["roles.save", "roles.remove", "roles.savePrompt", "roles.saveSkill", "roles.removeSkill"] },
|
|
97
98
|
updates: { changes: ["system.autoUpdate", "system.skipUpdate"] },
|
|
98
99
|
} as const satisfies Readonly<Record<OrgSection, SectionRoutes>>;
|
|
99
100
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// WHETHER A ROLE LETS A TURN ACT THROUGH ONE CONNECTED CAPABILITY. Pure and shared, because the daemon mounts a turn's
|
|
2
|
+
// tools on this answer (roles/roles.ts `turnRole`) and the Sandbox ▸ Map view draws who reaches what from it,
|
|
3
|
+
// and two implementations would disagree at exactly the boundary that matters.
|
|
4
|
+
// A card decides one thing about reach: which signed-in accounts it speaks through. Every other limit on a conversation
|
|
5
|
+
// wearing it (connectors, devices, servers, shelves, folders) is an access profile that lists the card
|
|
6
|
+
// (schemas/access-profiles.ts `roles`), held in the principal chain like a person's or a service's.
|
|
7
|
+
|
|
8
|
+
// The two fields of a connection the rule reads; structural, so neither side has to hand over its own record type.
|
|
9
|
+
export interface CapabilityRef {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly kind: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The kinds that are someone signed in: a site account, the identity whose browser holds every account born of it, and
|
|
16
|
+
* the owner's own browser (its extension), which holds every session they have. The last one was missing until
|
|
17
|
+
* 2026-10-25, and it fell through to "passes untouched": an X-only role's unattended run reached the owner's Brave,
|
|
18
|
+
* and an unpinned wake that lost every sandbox account kept it.
|
|
19
|
+
*/
|
|
20
|
+
export const isSignedInAccount = (kind: string): boolean => kind === "browser" || kind === "identity" || kind === "webext";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Whether a role speaking through these accounts (its `capabilities`) may act through a capability. Granting an
|
|
24
|
+
* account (`reddit-work`) grants its hands; granting the identity itself grants the someone. The owner's own browser is
|
|
25
|
+
* named the same way: a role reaches it only when its list says so. Every other kind passes here and is decided by
|
|
26
|
+
* access.
|
|
27
|
+
*/
|
|
28
|
+
export const roleAllowsCapability = (capability: CapabilityRef, accounts: readonly string[]): boolean =>
|
|
29
|
+
!isSignedInAccount(capability.kind) || accounts.includes(capability.id);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Fence, fenceCovers } from "./fence-paths.js";
|
|
2
|
+
|
|
3
|
+
// Where a role card LIVES, and therefore who may act through it. A card is not granted per person any more: a
|
|
4
|
+
// person holds areas, an area is folders, and a card whose home those folders cover is one that person may wear.
|
|
5
|
+
// Pure and shared, because the daemon refuses on this answer and the Access tab draws the consequence from it, and
|
|
6
|
+
// two implementations would disagree at exactly the boundary that matters.
|
|
7
|
+
|
|
8
|
+
// The field a card names a place with; structural rather than the Role type, so this stays free of the schema
|
|
9
|
+
// layer that imports it.
|
|
10
|
+
export interface RolePlace {
|
|
11
|
+
readonly workspace?: { readonly startIn?: string | undefined } | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The card's home as a fence: the folder it opens in, else undefined, the workspace root, which only somebody holding
|
|
16
|
+
* the whole workspace covers. Where a conversation OPENS is the one place the card certainly works. (Until 2026-11-18 a
|
|
17
|
+
* card with no `startIn` was homed in its own folder list; those folders are a profile's areas now, and the step that
|
|
18
|
+
* moved them gave a card with a single folder that folder as its `startIn`.)
|
|
19
|
+
*/
|
|
20
|
+
export const roleHome = (card: RolePlace): Fence => {
|
|
21
|
+
const startIn = card.workspace?.startIn;
|
|
22
|
+
return startIn !== undefined && startIn !== "" ? [startIn] : undefined;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether a person fenced to these folders may act through this card. An unfenced holder reaches every card; a fenced
|
|
27
|
+
* one reaches those homed inside its folders, and never a card that lives at the workspace root.
|
|
28
|
+
*/
|
|
29
|
+
export const fenceHoldsRole = (fence: Fence, card: RolePlace): boolean => fenceCovers(fence, roleHome(card));
|
|
@@ -96,7 +96,7 @@ describe("fenceIntersection", () => {
|
|
|
96
96
|
expect(fenceIntersection(undefined, undefined)).toBeUndefined();
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
// The narrower of the pair survives, whichever side it came from, so a
|
|
99
|
+
// The narrower of the pair survives, whichever side it came from, so a role asking for more than its starter
|
|
100
100
|
// holds gets the starter's answer.
|
|
101
101
|
test("the tighter folder is what survives, from whichever side", () => {
|
|
102
102
|
expect(fenceIntersection(["apps"], ["apps/web"])).toEqual(["apps/web"]);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { fenceHoldsRole, roleHome } from "../role-home.js";
|
|
2
|
+
|
|
3
|
+
// Where a card lives, and therefore who may wear it. This is the whole of the rule the Access tab draws and the
|
|
4
|
+
// daemon refuses on, so both shapes a card can name a place in are each pinned here.
|
|
5
|
+
|
|
6
|
+
describe("roleHome", () => {
|
|
7
|
+
test("the folder it opens in is its home", () => {
|
|
8
|
+
expect(roleHome({ workspace: { startIn: "support" } })).toEqual(["support"]);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("naming no place at all is the workspace root, which is not a folder any fence can hold", () => {
|
|
12
|
+
expect(roleHome({})).toBeUndefined();
|
|
13
|
+
expect(roleHome({ workspace: {} })).toBeUndefined();
|
|
14
|
+
expect(roleHome({ workspace: { startIn: "" } })).toBeUndefined();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("fenceHoldsRole", () => {
|
|
19
|
+
const support = { workspace: { startIn: "support/inbox" } };
|
|
20
|
+
const finance = { workspace: { startIn: "finance" } };
|
|
21
|
+
|
|
22
|
+
test("an unfenced holder wears every card, root-homed ones included", () => {
|
|
23
|
+
expect(fenceHoldsRole(undefined, support)).toBe(true);
|
|
24
|
+
expect(fenceHoldsRole(undefined, {})).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("a fenced holder wears the cards homed inside its folders and no others", () => {
|
|
28
|
+
expect(fenceHoldsRole(["support"], support)).toBe(true);
|
|
29
|
+
expect(fenceHoldsRole(["support"], finance)).toBe(false);
|
|
30
|
+
// By segment, not by string prefix: `support2` is not inside `support`.
|
|
31
|
+
expect(fenceHoldsRole(["support"], { workspace: { startIn: "support2" } })).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// The one card no fence can reach, whatever it names: everything is inside the root, so holding it would be
|
|
35
|
+
// holding the workspace.
|
|
36
|
+
test("a card homed at the root is the owner's alone", () => {
|
|
37
|
+
expect(fenceHoldsRole(["support"], {})).toBe(false);
|
|
38
|
+
expect(fenceHoldsRole([], {})).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -94,7 +94,7 @@ describe("routeFloor", () => {
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
describe("memberRefusal for a person given part of the sandbox", () => {
|
|
97
|
-
const collaborator = {
|
|
97
|
+
const collaborator = { tier: "collaborator" as const, agents: "run" as const };
|
|
98
98
|
|
|
99
99
|
test("People & access opens the roster, its requests, areas, profiles and the preview guard, and nothing else", () => {
|
|
100
100
|
const people = { ...collaborator, manages: ["people" as const] };
|
|
@@ -139,7 +139,7 @@ describe("memberRefusal for a person given part of the sandbox", () => {
|
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
test("Full access reaches what the owner ran alone before, short of the owner's own door", () => {
|
|
142
|
-
const maintainer = {
|
|
142
|
+
const maintainer = { tier: "maintainer" as const };
|
|
143
143
|
expect(memberRefusal(maintainer, "GET", "/members")).toBeUndefined();
|
|
144
144
|
expect(memberRefusal(maintainer, "POST", "/privacy/reveal")).toBeUndefined();
|
|
145
145
|
expect(memberRefusal(maintainer, "POST", "/settings/agent-domain")).toBeUndefined();
|
|
@@ -196,33 +196,33 @@ describe("guestReach", () => {
|
|
|
196
196
|
|
|
197
197
|
describe("memberRefusal", () => {
|
|
198
198
|
test("a tier below the floor is refused with the floor named; a guest off its list with its own sentence", () => {
|
|
199
|
-
expect(memberRefusal({
|
|
200
|
-
expect(memberRefusal({
|
|
201
|
-
expect(memberRefusal({
|
|
202
|
-
expect(memberRefusal({
|
|
199
|
+
expect(memberRefusal({ tier: "viewer" }, "POST", "/agent")).toEqual({ error: "collaborator access required", floor: "collaborator", reason: "floor" });
|
|
200
|
+
expect(memberRefusal({ tier: "collaborator" }, "POST", "/agent")).toBeUndefined();
|
|
201
|
+
expect(memberRefusal({ tier: "guest", areas: ["support"] }, "POST", "/agent")).toBeUndefined();
|
|
202
|
+
expect(memberRefusal({ tier: "guest", areas: ["support"] }, "POST", "/workspace/move")).toEqual({
|
|
203
203
|
error: "not open to a guest member",
|
|
204
204
|
floor: "viewer",
|
|
205
205
|
reason: "guest",
|
|
206
206
|
});
|
|
207
207
|
// A guest never clears a floor by rank: the list is the whole of its admission.
|
|
208
|
-
expect(memberRefusal({
|
|
208
|
+
expect(memberRefusal({ tier: "guest", areas: ["support"] }, "GET", "/no/such/route")).toEqual({
|
|
209
209
|
error: "not open to a guest member",
|
|
210
210
|
floor: "viewer",
|
|
211
211
|
reason: "guest",
|
|
212
212
|
});
|
|
213
|
-
expect(memberRefusal({
|
|
213
|
+
expect(memberRefusal({ tier: "viewer" }, "GET", "/no/such/route")).toBeUndefined();
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
test("a writer clears the file routes and nothing that ships or operates", () => {
|
|
217
|
-
expect(memberRefusal({
|
|
218
|
-
expect(memberRefusal({
|
|
219
|
-
expect(memberRefusal({
|
|
220
|
-
expect(memberRefusal({
|
|
217
|
+
expect(memberRefusal({ tier: "writer", areas: ["support"] }, "POST", "/workspace/move")).toBeUndefined();
|
|
218
|
+
expect(memberRefusal({ tier: "writer", areas: ["support"] }, "POST", "/workspace/upload", "support/note.md")).toBeUndefined();
|
|
219
|
+
expect(memberRefusal({ tier: "collaborator" }, "POST", "/workspace/move")).toEqual({ error: "writer access required", floor: "writer", reason: "floor" });
|
|
220
|
+
expect(memberRefusal({ tier: "writer", areas: ["support"] }, "POST", "/agents/abc/land")).toEqual({
|
|
221
221
|
error: "maintainer access required",
|
|
222
222
|
floor: "maintainer",
|
|
223
223
|
reason: "floor",
|
|
224
224
|
});
|
|
225
|
-
expect(memberRefusal({
|
|
225
|
+
expect(memberRefusal({ tier: "writer", areas: ["support"] }, "GET", "/secrets")).toEqual({
|
|
226
226
|
error: "maintainer access required",
|
|
227
227
|
floor: "maintainer",
|
|
228
228
|
reason: "floor",
|
|
@@ -234,19 +234,19 @@ describe("memberRefusal", () => {
|
|
|
234
234
|
// which clears the collaborator floor by rank, and is kept off it by their own answer.
|
|
235
235
|
describe("memberRefusal for a person with agents off", () => {
|
|
236
236
|
test("refuses every agent door and keeps the file doors open", () => {
|
|
237
|
-
const editor = {
|
|
237
|
+
const editor = { tier: "writer" as const, agents: "off" as const };
|
|
238
238
|
expect(memberRefusal(editor, "POST", "/agent")).toEqual({ error: "running agents is not on for you here", floor: "collaborator", reason: "agents-off" });
|
|
239
239
|
expect(memberRefusal(editor, "POST", "/agents/abc/request-land")).toMatchObject({ floor: "collaborator" });
|
|
240
240
|
expect(memberRefusal(editor, "POST", "/workspace/dir")).toBeUndefined();
|
|
241
241
|
expect(memberRefusal(editor, "GET", "/workspace/tree")).toBeUndefined();
|
|
242
|
-
expect(memberRefusal({
|
|
242
|
+
expect(memberRefusal({ tier: "writer", agents: "run" }, "POST", "/agent")).toBeUndefined();
|
|
243
243
|
});
|
|
244
244
|
});
|
|
245
245
|
|
|
246
246
|
// A home-only member is a guest whose one conversation is its home (conversations/home/home-conversation.ts): the guest
|
|
247
247
|
// list, and the land press when its home lands by itself, which the route then admits on that home alone.
|
|
248
248
|
describe("a home-only member", () => {
|
|
249
|
-
const homeOnly = {
|
|
249
|
+
const homeOnly = { tier: "guest", agents: "home" } as const;
|
|
250
250
|
|
|
251
251
|
test("reaches what a guest reaches, and the land press only when its work lands by itself", () => {
|
|
252
252
|
expect(memberRefusal(homeOnly, "POST", "/agent")).toBeUndefined();
|
|
@@ -268,7 +268,7 @@ describe("a home-only member", () => {
|
|
|
268
268
|
});
|
|
269
269
|
|
|
270
270
|
test("a chatting guest granted nothing of the kind does not reach the land press", () => {
|
|
271
|
-
expect(memberRefusal({
|
|
271
|
+
expect(memberRefusal({ tier: "guest", agents: "chat", lands: true }, "POST", "/agents/abc/land")).toEqual({
|
|
272
272
|
error: "not open to a guest member",
|
|
273
273
|
floor: "viewer",
|
|
274
274
|
reason: "guest",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AgentAccess, ManageRight } from "../schemas/members.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type MemberTier, tierAtLeast } from "../schemas/shared.js";
|
|
3
3
|
import { defaultFloor } from "./route-meta.js";
|
|
4
4
|
import { isAttachmentPath } from "../state/workspace-state.js";
|
|
5
5
|
import { sandboxRouteFor } from "../index.js";
|
|
6
6
|
|
|
7
7
|
// Role floors: the minimum trust tier each route demands, read from the route's own RouteMeta (route-meta.ts). One
|
|
8
|
-
// function for both sides: the daemon's bearer middleware refuses with it right after the caller's
|
|
8
|
+
// function for both sides: the daemon's bearer middleware refuses with it right after the caller's tier resolves, and
|
|
9
9
|
// the editor asks it before sending, so a request the daemon would refuse is never sent and the two cannot disagree.
|
|
10
10
|
// A floor, not the whole answer: operating routes still keep their own in-route gates (members.ts `holdsRight`,
|
|
11
11
|
// `peopleChangeRefusal`). A route that runs one part of the sandbox names it (`right`), and a person given that part
|
|
@@ -22,7 +22,7 @@ export type MemberRefusalReason = "floor" | "agents-off" | "guest";
|
|
|
22
22
|
// The body of that refusal, as the daemon sends it and as the editor predicts it before sending.
|
|
23
23
|
export interface MemberRefusal {
|
|
24
24
|
readonly error: string;
|
|
25
|
-
readonly floor:
|
|
25
|
+
readonly floor: MemberTier;
|
|
26
26
|
readonly reason: MemberRefusalReason;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -31,7 +31,7 @@ export interface MemberRefusal {
|
|
|
31
31
|
// the bytes land.
|
|
32
32
|
export const memberRefusal = (
|
|
33
33
|
caller: {
|
|
34
|
-
readonly
|
|
34
|
+
readonly tier: MemberTier;
|
|
35
35
|
readonly areas?: readonly string[] | undefined;
|
|
36
36
|
readonly agents?: AgentAccess | undefined;
|
|
37
37
|
readonly lands?: true | undefined;
|
|
@@ -41,13 +41,13 @@ export const memberRefusal = (
|
|
|
41
41
|
path: string,
|
|
42
42
|
target?: string,
|
|
43
43
|
): MemberRefusal | undefined => {
|
|
44
|
-
if (caller.
|
|
44
|
+
if (caller.tier === "guest") {
|
|
45
45
|
return guestReach(method, path, target) || homeReach(caller, method, path)
|
|
46
46
|
? undefined
|
|
47
47
|
: { error: "not open to a guest member", floor: "viewer", reason: "guest" };
|
|
48
48
|
}
|
|
49
49
|
const floor = routeFloor(method, path, target);
|
|
50
|
-
if (!
|
|
50
|
+
if (!tierAtLeast(caller.tier, floor) && !givenRight(caller, method, path)) {
|
|
51
51
|
return { error: `${floor} access required`, floor, reason: "floor" };
|
|
52
52
|
}
|
|
53
53
|
// The collaborator floor is driving agents. A person who edits files by hand without running agents holds the
|
|
@@ -77,7 +77,7 @@ const homeReach = (caller: { readonly agents?: AgentAccess | undefined; readonly
|
|
|
77
77
|
export const homeLandReach = (method: string, path: string): boolean => sandboxRouteFor(method, path)?.meta.home === "land";
|
|
78
78
|
|
|
79
79
|
// `target` is the workspace path a byte-write addresses (upload's `?path=`); absent for every other route.
|
|
80
|
-
export const routeFloor = (method: string, path: string, target?: string):
|
|
80
|
+
export const routeFloor = (method: string, path: string, target?: string): MemberTier => {
|
|
81
81
|
const meta = sandboxRouteFor(method, path)?.meta;
|
|
82
82
|
if (meta?.attachmentFloor !== undefined && attachment(target)) {
|
|
83
83
|
return meta.attachmentFloor;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { oc } from "@orpc/contract";
|
|
2
2
|
import type { ManageRight } from "../schemas/members.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { MemberTier } from "../schemas/shared.js";
|
|
4
4
|
|
|
5
5
|
// Every route's policy, declared beside it: how a request authenticates, which member tier and which machine
|
|
6
6
|
// credentials reach it, and how the daemon's outer middleware treats it. Each field has a default, so most routes
|
|
7
|
-
// declare nothing; the daemon's bearer, boot, timer,
|
|
7
|
+
// declare nothing; the daemon's bearer, boot, timer, tier-floor and grant decisions all derive from this.
|
|
8
8
|
|
|
9
9
|
// How far a control token reaches a route beyond what its floor alone gives the `read`/`drive` rungs.
|
|
10
10
|
// `never`: no rung; `editor`: the editor slice too; `read`: the read rung and the editor slice, though no GET (watching
|
|
@@ -20,8 +20,8 @@ export interface RouteMeta {
|
|
|
20
20
|
readonly beforeBoot?: true;
|
|
21
21
|
// Held open by design, so the request timer leaves it out.
|
|
22
22
|
readonly stream?: true;
|
|
23
|
-
// The lowest member
|
|
24
|
-
readonly floor?:
|
|
23
|
+
// The lowest member tier that may call it. Absent: viewer for a read (GET, HEAD), maintainer for anything else.
|
|
24
|
+
readonly floor?: MemberTier;
|
|
25
25
|
// The part of the sandbox it runs (members.ts `ManageRightSchema`): a person below the floor who was given that part
|
|
26
26
|
// reaches it too. The handler holds anything finer (members.ts `peopleChangeRefusal`).
|
|
27
27
|
readonly right?: ManageRight;
|
|
@@ -31,7 +31,7 @@ export interface RouteMeta {
|
|
|
31
31
|
// (`landsHere`): `land` is the press on their own home conversation, the one conversation the handler then admits.
|
|
32
32
|
readonly home?: "land";
|
|
33
33
|
// The floor an upload aimed inside ATTACHMENTS_DIR gets instead, one a guest may also make.
|
|
34
|
-
readonly attachmentFloor?:
|
|
34
|
+
readonly attachmentFloor?: MemberTier;
|
|
35
35
|
// A passkey-registration door: a proof with no passkey yet may pass the require-passkey policy.
|
|
36
36
|
readonly enrolment?: true;
|
|
37
37
|
// The agent token, which the CLIs on the agent's PATH carry, reaches it.
|
|
@@ -50,7 +50,7 @@ export interface RouteMeta {
|
|
|
50
50
|
|
|
51
51
|
// The floor a route gets when it declares none: a read (GET, HEAD) floors at viewer, anything else (`ALL` included) at
|
|
52
52
|
// maintainer, so a route nobody classified can under-serve, never over-grant.
|
|
53
|
-
export const defaultFloor = (method: string):
|
|
53
|
+
export const defaultFloor = (method: string): MemberTier => (method === "GET" || method === "HEAD" ? "viewer" : "maintainer");
|
|
54
54
|
|
|
55
55
|
// The fields that say how a request travels, not who may send it; every other RouteMeta field decides reach.
|
|
56
56
|
type TransportField = "lane" | "netd";
|