@intentic/sandbox-contract 1.362.0 → 1.364.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/README.md +4 -0
- package/dist/contracts/access-profiles.contract.d.ts +91 -0
- package/dist/contracts/access-profiles.contract.d.ts.map +1 -0
- package/dist/contracts/access-profiles.contract.js +33 -0
- package/dist/contracts/access-profiles.contract.js.map +1 -0
- package/dist/contracts/agent.contract.d.ts +18 -0
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.d.ts +7 -0
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/automations.contract.d.ts +5 -0
- package/dist/contracts/automations.contract.d.ts.map +1 -1
- package/dist/contracts/extensions.contract.d.ts +6 -0
- package/dist/contracts/extensions.contract.d.ts.map +1 -1
- package/dist/contracts/needs.contract.d.ts +14 -0
- package/dist/contracts/needs.contract.d.ts.map +1 -1
- package/dist/contracts/org.contract.d.ts +49 -0
- package/dist/contracts/org.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.d.ts +9 -2
- package/dist/contracts/runner.contract.d.ts.map +1 -1
- package/dist/contracts/services.contract.d.ts +26 -0
- package/dist/contracts/services.contract.d.ts.map +1 -0
- package/dist/contracts/services.contract.js +33 -0
- package/dist/contracts/services.contract.js.map +1 -0
- package/dist/contracts/sessions.contract.d.ts +2 -0
- package/dist/contracts/sessions.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.d.ts +3 -0
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/events/agent-events.d.ts +10 -0
- package/dist/events/agent-events.d.ts.map +1 -1
- package/dist/events/agent-events.js +1 -0
- package/dist/events/agent-events.js.map +1 -1
- package/dist/events/agent-transcript.d.ts +2 -0
- package/dist/events/agent-transcript.d.ts.map +1 -1
- package/dist/events/transcript.d.ts +10 -0
- package/dist/events/transcript.d.ts.map +1 -1
- package/dist/index.d.ts +219 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/models/model-setups.d.ts.map +1 -1
- package/dist/models/model-setups.js.map +1 -1
- package/dist/policy/control-scopes.d.ts +3 -0
- package/dist/policy/control-scopes.d.ts.map +1 -1
- package/dist/policy/control-scopes.js +2 -0
- package/dist/policy/control-scopes.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 +3 -1
- package/dist/policy/org-locks.js.map +1 -1
- package/dist/policy/turned-away.d.ts.map +1 -1
- package/dist/policy/turned-away.js +2 -0
- package/dist/policy/turned-away.js.map +1 -1
- package/dist/protocol/raw/raw-json-routes.d.ts +314 -1
- package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-json-routes.js +3 -1
- package/dist/protocol/raw/raw-json-routes.js.map +1 -1
- package/dist/protocol/raw/raw-routes.d.ts +2 -0
- package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-routes.js +2 -0
- package/dist/protocol/raw/raw-routes.js.map +1 -1
- package/dist/schemas/access-profiles.d.ts +153 -0
- package/dist/schemas/access-profiles.d.ts.map +1 -0
- package/dist/schemas/access-profiles.js +56 -0
- package/dist/schemas/access-profiles.js.map +1 -0
- package/dist/schemas/agents-list.d.ts +1 -0
- package/dist/schemas/agents-list.d.ts.map +1 -1
- package/dist/schemas/automations.d.ts +10 -0
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/automations.js +7 -0
- package/dist/schemas/automations.js.map +1 -1
- package/dist/schemas/dev-rebuild-log.d.ts +16 -0
- package/dist/schemas/dev-rebuild-log.d.ts.map +1 -1
- package/dist/schemas/dev-rebuild-log.js +38 -2
- package/dist/schemas/dev-rebuild-log.js.map +1 -1
- package/dist/schemas/device-commands.d.ts +7 -1
- package/dist/schemas/device-commands.d.ts.map +1 -1
- package/dist/schemas/device-commands.js +14 -2
- package/dist/schemas/device-commands.js.map +1 -1
- package/dist/schemas/environment.d.ts +27 -0
- package/dist/schemas/environment.d.ts.map +1 -1
- package/dist/schemas/environment.js +9 -0
- package/dist/schemas/environment.js.map +1 -1
- package/dist/schemas/extension-updates.d.ts +12 -0
- package/dist/schemas/extension-updates.d.ts.map +1 -1
- package/dist/schemas/links.d.ts +6 -1
- package/dist/schemas/links.d.ts.map +1 -1
- package/dist/schemas/links.js +8 -1
- package/dist/schemas/links.js.map +1 -1
- package/dist/schemas/members.d.ts +83 -0
- package/dist/schemas/members.d.ts.map +1 -1
- package/dist/schemas/members.js +33 -0
- package/dist/schemas/members.js.map +1 -1
- package/dist/schemas/needs.d.ts +16 -0
- package/dist/schemas/needs.d.ts.map +1 -1
- package/dist/schemas/organisation.d.ts +164 -0
- package/dist/schemas/organisation.d.ts.map +1 -1
- package/dist/schemas/organisation.js +17 -0
- package/dist/schemas/organisation.js.map +1 -1
- package/dist/schemas/personas.d.ts.map +1 -1
- package/dist/schemas/personas.js +2 -2
- package/dist/schemas/personas.js.map +1 -1
- package/dist/schemas/services.d.ts +24 -0
- package/dist/schemas/services.d.ts.map +1 -0
- package/dist/schemas/services.js +19 -0
- package/dist/schemas/services.js.map +1 -0
- 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/tool-ceiling.d.ts +24 -0
- package/dist/schemas/tool-ceiling.d.ts.map +1 -0
- package/dist/schemas/tool-ceiling.js +86 -0
- package/dist/schemas/tool-ceiling.js.map +1 -0
- package/dist/state/locked-folders.d.ts +2 -0
- package/dist/state/locked-folders.d.ts.map +1 -0
- package/dist/state/locked-folders.js +11 -0
- package/dist/state/locked-folders.js.map +1 -0
- package/package.json +5 -5
- package/src/contracts/access-profiles.contract.ts +43 -0
- package/src/contracts/services.contract.ts +40 -0
- package/src/events/agent-events.ts +4 -0
- package/src/index.ts +4 -0
- package/src/models/model-roles.ts +2 -2
- package/src/models/model-setups.ts +3 -4
- package/src/policy/control-scopes.ts +5 -0
- package/src/policy/org-locks.ts +5 -2
- package/src/policy/turned-away.ts +3 -0
- package/src/protocol/raw/raw-json-routes.ts +3 -0
- package/src/protocol/raw/raw-routes.ts +2 -0
- package/src/schemas/access-profiles.test.ts +50 -0
- package/src/schemas/access-profiles.ts +104 -0
- package/src/schemas/automations.ts +15 -1
- package/src/schemas/dev-rebuild-log.test.ts +46 -1
- package/src/schemas/dev-rebuild-log.ts +71 -3
- package/src/schemas/device-commands.ts +30 -2
- package/src/schemas/environment.ts +22 -0
- package/src/schemas/links.ts +13 -2
- package/src/schemas/members.ts +67 -1
- package/src/schemas/organisation.ts +25 -0
- package/src/schemas/personas.ts +15 -11
- package/src/schemas/services.ts +32 -0
- package/src/schemas/settings.test.ts +23 -1
- package/src/schemas/settings.ts +5 -4
- package/src/schemas/tool-ceiling.test.ts +70 -0
- package/src/schemas/tool-ceiling.ts +113 -0
- package/src/state/locked-folders.test.ts +29 -0
- package/src/state/locked-folders.ts +17 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { entryId } from "./internal.js";
|
|
3
|
+
import {
|
|
4
|
+
type AgentAccess,
|
|
5
|
+
AgentAccessSchema,
|
|
6
|
+
AiAccountKeySchema,
|
|
7
|
+
CredentialReachSchema,
|
|
8
|
+
type EditScope,
|
|
9
|
+
EditScopeSchema,
|
|
10
|
+
type MemberAccess,
|
|
11
|
+
} from "./members.js";
|
|
12
|
+
import { GrantedRoleSchema } from "./shared.js";
|
|
13
|
+
import { ToolCeilingSchema } from "./tool-ceiling.js";
|
|
14
|
+
|
|
15
|
+
// AN ACCESS PROFILE: the hard half of access, named and reusable (docs/architecture/access.md). One shape serves every
|
|
16
|
+
// kind of principal: a person holds one instead of answers of their own, and a service (schemas/services.ts) holds one
|
|
17
|
+
// to narrow what it does for its steward. So an intern and the marketing bot can be pointed at the same thing, and
|
|
18
|
+
// widening what both may spend is one edit.
|
|
19
|
+
// Every answer means what the same field on a roster row means (schemas/members.ts), absent included: absent areas is
|
|
20
|
+
// the whole workspace, absent credentials every one, absent AI accounts every one, absent tools no limit. `agents`,
|
|
21
|
+
// `edit`, `lands` and `assistants` are a person's answers and mean nothing for a service, which drives no editor.
|
|
22
|
+
// A profile cannot make a maintainer: that tier holds the owner's operating authority and is granted to a person,
|
|
23
|
+
// never through something shared.
|
|
24
|
+
export const AccessProfileSchema = z.object({
|
|
25
|
+
id: entryId.describe("The profile's id, the name a roster row or a service points at."),
|
|
26
|
+
label: z.string().max(60).optional().describe("What to call it on screen. Absent falls back to the id."),
|
|
27
|
+
brief: z.string().max(200).optional().describe("What this access is for, in one line, so whoever grants it can tell what they are handing over."),
|
|
28
|
+
areas: z
|
|
29
|
+
.array(z.string().min(1))
|
|
30
|
+
.max(20)
|
|
31
|
+
.optional()
|
|
32
|
+
.describe("The areas its holders see and their agents work in. Absent means the whole workspace."),
|
|
33
|
+
agents: AgentAccessSchema.optional().describe(
|
|
34
|
+
"For a person: whether their conversations run agents (off, chat, run, home). Absent means run. A service ignores it.",
|
|
35
|
+
),
|
|
36
|
+
edit: EditScopeSchema.optional().describe("For a person: where they change files by hand. Absent means nowhere. A service ignores it."),
|
|
37
|
+
lands: z
|
|
38
|
+
.boolean()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("For a home-only person: whether their home conversation lands its work by itself. Absent means no."),
|
|
41
|
+
credentials: CredentialReachSchema.optional().describe(
|
|
42
|
+
"The connected capabilities and stored secrets its holders' conversations may spend. Absent means every one, including any connected later.",
|
|
43
|
+
),
|
|
44
|
+
aiAccounts: z
|
|
45
|
+
.array(AiAccountKeySchema)
|
|
46
|
+
.max(500)
|
|
47
|
+
.optional()
|
|
48
|
+
.describe("The AI accounts its holders' turns may run on, `provider:account` or a provider alone. Absent means every one."),
|
|
49
|
+
tools: ToolCeilingSchema.optional().describe("The most its holders' turns' tools may be; a persona only narrows inside it. Absent means no limit."),
|
|
50
|
+
assistants: z
|
|
51
|
+
.array(entryId)
|
|
52
|
+
.max(50)
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("For a guest who chats: which assistants working in their areas they may talk to. Absent means every one that works there."),
|
|
55
|
+
});
|
|
56
|
+
export type AccessProfile = z.infer<typeof AccessProfileSchema>;
|
|
57
|
+
|
|
58
|
+
// Where a profile listed beside the sandbox's own came from: the sandbox, or the organisation it is bound to, whose
|
|
59
|
+
// profiles arrive with its policy (schemas/organisation.ts) and are read-only here.
|
|
60
|
+
export const AccessProfileOriginSchema = z.enum(["sandbox", "org"]);
|
|
61
|
+
export type AccessProfileOrigin = z.infer<typeof AccessProfileOriginSchema>;
|
|
62
|
+
|
|
63
|
+
export const AccessProfileEntrySchema = AccessProfileSchema.extend({
|
|
64
|
+
origin: AccessProfileOriginSchema.describe("The sandbox's own, or the organisation's, which nobody here can change."),
|
|
65
|
+
});
|
|
66
|
+
export type AccessProfileEntry = z.infer<typeof AccessProfileEntrySchema>;
|
|
67
|
+
|
|
68
|
+
export const AccessProfilesListSchema = z.object({
|
|
69
|
+
profiles: z.array(AccessProfileEntrySchema).describe("Every profile this sandbox grants: its own, then its organisation's."),
|
|
70
|
+
});
|
|
71
|
+
export type AccessProfilesList = z.infer<typeof AccessProfilesListSchema>;
|
|
72
|
+
|
|
73
|
+
export const AccessProfileIdParamSchema = z.object({ id: entryId.describe("Which profile.") });
|
|
74
|
+
|
|
75
|
+
// What a profile save answers: each person holding it, with the tier their rewritten row now makes, so the editor can
|
|
76
|
+
// bring the platform's copy of their tier along (the daemon only enforces its own).
|
|
77
|
+
export const AccessProfileHolderSchema = z.object({
|
|
78
|
+
email: z.string().describe("Who holds it, lowercased."),
|
|
79
|
+
role: GrantedRoleSchema.exclude(["maintainer"]).describe("The tier the profile makes for them now."),
|
|
80
|
+
});
|
|
81
|
+
export const AccessProfileSavedSchema = z.object({
|
|
82
|
+
ok: z.literal(true),
|
|
83
|
+
holders: z.array(AccessProfileHolderSchema).describe("The people whose rows were rewritten, with the tier each now holds."),
|
|
84
|
+
});
|
|
85
|
+
export type AccessProfileSaved = z.infer<typeof AccessProfileSavedSchema>;
|
|
86
|
+
|
|
87
|
+
// The fields of a profile that decide a person's access, in the shape `memberAccess` reads a row in.
|
|
88
|
+
interface ProfileAccessFields {
|
|
89
|
+
readonly areas?: readonly string[] | undefined;
|
|
90
|
+
readonly agents?: AgentAccess | undefined;
|
|
91
|
+
readonly edit?: EditScope | undefined;
|
|
92
|
+
readonly lands?: boolean | undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The access a profile gives a person: never managing, `run` when it does not say, and no hand edits for a chatting or
|
|
97
|
+
* home-only one, as a roster row reads (schemas/members.ts `memberAccess`). Its tier is `tierOf` of this.
|
|
98
|
+
*/
|
|
99
|
+
export const profileAccess = (profile: ProfileAccessFields): MemberAccess => {
|
|
100
|
+
const agents = profile.agents ?? "run";
|
|
101
|
+
const handsOff = agents === "chat" || agents === "home";
|
|
102
|
+
const access: MemberAccess = { manage: false, agents, see: profile.areas, edit: handsOff ? "none" : (profile.edit ?? "none") };
|
|
103
|
+
return profile.lands === true && agents === "home" ? { ...access, lands: true } : access;
|
|
104
|
+
};
|
|
@@ -308,6 +308,11 @@ export const SenderRuleSchema = z
|
|
|
308
308
|
.optional()
|
|
309
309
|
.describe("Group ids the service reports on a sender, a Discord role. Only for a source whose messages carry them."),
|
|
310
310
|
actsAs: entryId.optional().describe("Which persona their wakes speak as. Absent is no persona: the full toolbox, reaching no account."),
|
|
311
|
+
// The service (schemas/services.ts) their wakes act as, in place of the automation's own: a narrower one for
|
|
312
|
+
// strangers, a wider one for people the owner trusts. Never more than that service's steward may.
|
|
313
|
+
runAs: entryId
|
|
314
|
+
.optional()
|
|
315
|
+
.describe("Which service their wakes act as, in place of the automation's own. Absent means the automation's own service."),
|
|
311
316
|
// Tightens, never loosens: the automation's own `requireApproval` still holds everyone.
|
|
312
317
|
requireApproval: z.boolean().optional().describe("Hold their wakes for a person, even when the automation itself does not."),
|
|
313
318
|
})
|
|
@@ -397,8 +402,15 @@ export const AutomationSchema = z.object({
|
|
|
397
402
|
// is watching to notice a stuck one.
|
|
398
403
|
account: z.string().optional().describe("Which account pays for it."),
|
|
399
404
|
// Absent means the wake reaches no logged-in account at all, the strictest default here, since nobody is at the
|
|
400
|
-
// composer when it fires.
|
|
405
|
+
// composer when it fires. Posture only: what the wake may reach is `runAs`'s (docs/architecture/access.md).
|
|
401
406
|
actsAs: entryId.optional().describe("Which persona it speaks as. An unwatched turn naming none reaches no signed-in account at all."),
|
|
407
|
+
// Who its wakes act for (schemas/services.ts): that service's steward, held to the service's access profile. Absent
|
|
408
|
+
// keeps what a wake always did: it acts for the sandbox's owner with no profile, its persona the only narrowing.
|
|
409
|
+
runAs: entryId
|
|
410
|
+
.optional()
|
|
411
|
+
.describe(
|
|
412
|
+
"Which service it acts as: whose authority its wakes use, held to that service's access profile. Absent means the sandbox's owner, limited only by its persona.",
|
|
413
|
+
),
|
|
402
414
|
// Listener triggers on a source that identifies senders only (TriggerSource.sender); refused elsewhere at upsert.
|
|
403
415
|
// Absent means everyone the filters admit, wearing `actsAs`.
|
|
404
416
|
senders: SendersSchema.optional().describe(
|
|
@@ -462,6 +474,8 @@ export const AutomationApprovalSchema = z.object({
|
|
|
462
474
|
// The persona the fire resolved to (a sender rule's, or the automation's), snapshotted at hold time and worn by the
|
|
463
475
|
// approved run; also what a project-scoped board files the wake under.
|
|
464
476
|
actsAs: entryId.optional().describe("Which persona the approved run speaks as, decided when it was held."),
|
|
477
|
+
// The service the fire resolved to (a sender rule's, or the automation's), snapshotted beside the persona.
|
|
478
|
+
runAs: entryId.optional().describe("Which service the approved run acts as, decided when it was held."),
|
|
465
479
|
createdAt: z.number().describe("When it started waiting, in milliseconds."),
|
|
466
480
|
// When the daemon may run this itself, for a `holdForSeconds` hold; absent for a `requireApproval` hold, which only
|
|
467
481
|
// the owner releases.
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DEV_REBUILD_CANCEL_MARK,
|
|
3
|
+
DEV_REBUILD_EXIT_MARK,
|
|
4
|
+
DEV_REBUILD_HOLD_MARK,
|
|
5
|
+
DEV_REBUILD_QUIET_MARK,
|
|
6
|
+
DEV_REBUILD_SWAP_MARK,
|
|
7
|
+
DEV_REBUILD_TASKS_MARK,
|
|
8
|
+
DEV_REBUILD_WAITING_MARK,
|
|
9
|
+
devRebuildHoldPath,
|
|
10
|
+
devRebuildLogPath,
|
|
11
|
+
readDevRebuildLog,
|
|
12
|
+
} from "./dev-rebuild-log.js";
|
|
2
13
|
|
|
3
14
|
// The one account a detached rebuild gives of itself. The daemon builds the shell that writes this text and the browser
|
|
4
15
|
// draws what it means, so the grammar is pinned here, where both of them read it.
|
|
@@ -52,3 +63,37 @@ test("treats an answer with no marks as log text, not as an error", () => {
|
|
|
52
63
|
test("names one log per sandbox, beside the logs ic writes for its own recreates", () => {
|
|
53
64
|
expect(devRebuildLogPath("work-abc")).toBe("~/.intentic/logs/dev-rebuild-work-abc.log");
|
|
54
65
|
});
|
|
66
|
+
|
|
67
|
+
test("reads the hold file's state and turbo's count, which the read prints before the tail", () => {
|
|
68
|
+
const log = readDevRebuildLog(answer("3", `${DEV_REBUILD_HOLD_MARK} 1`, `${DEV_REBUILD_TASKS_MARK} 23 -`, "@intentic/sandbox:build: $ tsc"));
|
|
69
|
+
expect(log).toMatchObject({ hold: true, tasks: { started: 23, total: undefined } });
|
|
70
|
+
expect(log.lines).toEqual(["@intentic/sandbox:build: $ tsc"]);
|
|
71
|
+
expect(readDevRebuildLog(answer("3", `${DEV_REBUILD_HOLD_MARK} 0`, `${DEV_REBUILD_TASKS_MARK} 48 48`))).toMatchObject({
|
|
72
|
+
hold: false,
|
|
73
|
+
tasks: { started: 48, total: 48 },
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// An older daemon's read says neither, which is "unknown" rather than "not held": the card then offers no choice.
|
|
78
|
+
test("leaves the hold and the count unknown when the read does not print them", () => {
|
|
79
|
+
expect(readDevRebuildLog(answer("3", "building"))).toMatchObject({ hold: undefined, tasks: undefined });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// The gate's two words, in order: holding, then let through. Whichever came last is where it stands.
|
|
83
|
+
test("reads the gate holding until it says it let the swap through", () => {
|
|
84
|
+
const holding = readDevRebuildLog(answer("40", "#27 naming to intentic-sandbox:dev", DEV_REBUILD_WAITING_MARK));
|
|
85
|
+
expect(holding).toMatchObject({ waiting: true, swapping: false });
|
|
86
|
+
expect(holding.lines).toEqual(["#27 naming to intentic-sandbox:dev"]);
|
|
87
|
+
const through = readDevRebuildLog(answer("1", DEV_REBUILD_WAITING_MARK, DEV_REBUILD_SWAP_MARK, "intentic: [recreate] starting"));
|
|
88
|
+
expect(through).toMatchObject({ waiting: false, swapping: true });
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("reads a cancelled build as ended by somebody asking, not as a failure of its own", () => {
|
|
92
|
+
const log = readDevRebuildLog(answer("0", "#12 [builder 4/9] RUN pnpm install", "", DEV_REBUILD_CANCEL_MARK, `${DEV_REBUILD_EXIT_MARK} 130`));
|
|
93
|
+
expect(log).toMatchObject({ cancelled: true, exitCode: 130, waiting: false });
|
|
94
|
+
expect(log.lines).toEqual(["#12 [builder 4/9] RUN pnpm install"]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("keeps the gate's hold file beside the log it belongs to", () => {
|
|
98
|
+
expect(devRebuildHoldPath("work-abc")).toBe("~/.intentic/logs/dev-rebuild-work-abc.hold");
|
|
99
|
+
});
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
// browser names the same path to a reader whose rebuild never came back.
|
|
9
9
|
export const devRebuildLogPath = (slug: string): string => `~/.intentic/logs/dev-rebuild-${slug}.log`;
|
|
10
10
|
|
|
11
|
+
// THE SWAP GATE'S FILE. While it exists, ic stops a dev recreate after the images are built and before anything touches
|
|
12
|
+
// the container (INTENTIC_SWAP_GATE, recreate.rs), and waits for it to go. `dev-rebuild-hold` makes it, `dev-rebuild-release`
|
|
13
|
+
// removes it, and `dev-rebuild` clears one a previous run left behind before it starts.
|
|
14
|
+
export const devRebuildHoldPath = (slug: string): string => `~/.intentic/logs/dev-rebuild-${slug}.hold`;
|
|
15
|
+
|
|
16
|
+
// The build's process: its session leader, written by the build's own shell as it starts, so `dev-rebuild-cancel` can
|
|
17
|
+
// stop the whole tree (pnpm, turbo, docker's client, ic) rather than the one shell it would otherwise know about.
|
|
18
|
+
export const devRebuildPidPath = (slug: string): string => `~/.intentic/logs/dev-rebuild-${slug}.pid`;
|
|
19
|
+
|
|
11
20
|
// The build's own shell appends this when the build ends, with its exit status: since the log outlives the daemon, the
|
|
12
21
|
// container and the page that started it, this mark is the only thing that can say a rebuild is OVER rather than slow.
|
|
13
22
|
export const DEV_REBUILD_EXIT_MARK = "@intentic-rebuild-exit";
|
|
@@ -15,6 +24,27 @@ export const DEV_REBUILD_EXIT_MARK = "@intentic-rebuild-exit";
|
|
|
15
24
|
// that machine at all. A running build goes quiet for a minute at a time inside a docker layer; a build whose machine
|
|
16
25
|
// slept never writes its exit mark, and only this tells the two apart.
|
|
17
26
|
export const DEV_REBUILD_QUIET_MARK = "@intentic-rebuild-quiet";
|
|
27
|
+
// `dev-rebuild-log` prints whether the hold file is there right now: `1` held, `0` not. Absent from an older daemon's read.
|
|
28
|
+
export const DEV_REBUILD_HOLD_MARK = "@intentic-rebuild-hold";
|
|
29
|
+
// `dev-rebuild-log` prints how many of turbo's tasks have started in the WHOLE log, not the tail — the tail is 80 lines
|
|
30
|
+
// of a log that runs to thousands, so a count kept from it would miss most of them. Turbo names no total up front (its
|
|
31
|
+
// "Running build in N packages" is the packages in scope, a quarter of the tasks), so the total is `-` until turbo's own
|
|
32
|
+
// summary line says it at the end; a reader that remembers the last run's total is what gives "of 48" before then.
|
|
33
|
+
export const DEV_REBUILD_TASKS_MARK = "@intentic-rebuild-tasks";
|
|
34
|
+
// The gate's own words, printed into the log by ic: it is holding (built, waiting for the hold file to go), and it let
|
|
35
|
+
// the swap through. Past the second, the container is being replaced and nothing may stop the build any more.
|
|
36
|
+
export const DEV_REBUILD_WAITING_MARK = "@intentic-rebuild-waiting";
|
|
37
|
+
export const DEV_REBUILD_SWAP_MARK = "@intentic-rebuild-swap";
|
|
38
|
+
// `dev-rebuild-cancel` appends this, then an exit mark of 130, once it has stopped the build: a run that ended because
|
|
39
|
+
// somebody asked, rather than one that failed.
|
|
40
|
+
export const DEV_REBUILD_CANCEL_MARK = "@intentic-rebuild-cancelled";
|
|
41
|
+
|
|
42
|
+
export interface DevRebuildTasks {
|
|
43
|
+
/** Turbo's tasks that have started, cache hits included. */
|
|
44
|
+
readonly started: number;
|
|
45
|
+
/** How many it runs in all, once its summary has said; undefined before. */
|
|
46
|
+
readonly total: number | undefined;
|
|
47
|
+
}
|
|
18
48
|
|
|
19
49
|
export interface DevRebuildLog {
|
|
20
50
|
/** Nothing has ever rebuilt this sandbox from a checkout on that machine. */
|
|
@@ -23,30 +53,66 @@ export interface DevRebuildLog {
|
|
|
23
53
|
readonly quietFor: number | undefined;
|
|
24
54
|
/** The build's own exit status, present only once it has ended. */
|
|
25
55
|
readonly exitCode: number | undefined;
|
|
26
|
-
/**
|
|
56
|
+
/** Ended because somebody cancelled it (`dev-rebuild-cancel`), not because it failed. */
|
|
57
|
+
readonly cancelled: boolean;
|
|
58
|
+
/** Whether the hold file is there; undefined from a daemon too old to say. */
|
|
59
|
+
readonly hold: boolean | undefined;
|
|
60
|
+
/** The gate is holding right now: the images are built, the container untouched, the restart waiting to be let through. */
|
|
61
|
+
readonly waiting: boolean;
|
|
62
|
+
/** The gate let the swap through: the container is being replaced. */
|
|
63
|
+
readonly swapping: boolean;
|
|
64
|
+
/** Turbo's count, from the whole log; undefined from a daemon too old to count. */
|
|
65
|
+
readonly tasks: DevRebuildTasks | undefined;
|
|
66
|
+
/** The tail as the machine printed it, every mark removed. */
|
|
27
67
|
readonly lines: readonly string[];
|
|
28
68
|
}
|
|
29
69
|
|
|
30
70
|
// Reads `dev-rebuild-log`'s stdout. Shared rather than parsed at the reader, so the shell line that produces this and the
|
|
31
71
|
// card that draws it cannot drift apart. Unparseable is never an error: an answer with no marks at all is simply a log
|
|
32
72
|
// with nothing to say yet.
|
|
33
|
-
const markValue = (line: string, mark: string): string | undefined =>
|
|
73
|
+
const markValue = (line: string, mark: string): string | undefined =>
|
|
74
|
+
line === mark ? `` : line.startsWith(`${mark} `) ? line.slice(mark.length + 1).trim() : undefined;
|
|
34
75
|
const wholeNumber = (value: string): number | undefined => (/^\d+$/.test(value) ? Number(value) : undefined);
|
|
35
76
|
|
|
77
|
+
const readTasks = (value: string): DevRebuildTasks | undefined => {
|
|
78
|
+
const [started, total] = value.split(/\s+/);
|
|
79
|
+
const count = wholeNumber(started ?? ``);
|
|
80
|
+
return count === undefined ? undefined : { started: count, total: wholeNumber(total ?? ``) };
|
|
81
|
+
};
|
|
82
|
+
|
|
36
83
|
export const readDevRebuildLog = (text: string): DevRebuildLog => {
|
|
37
84
|
let missing = false;
|
|
38
85
|
let quietFor: number | undefined;
|
|
39
86
|
let exitCode: number | undefined;
|
|
87
|
+
let cancelled = false;
|
|
88
|
+
let hold: boolean | undefined;
|
|
89
|
+
let tasks: DevRebuildTasks | undefined;
|
|
90
|
+
// The last of the gate's two words: the tail is in order, so whichever came last is where the gate stands.
|
|
91
|
+
let gate: `waiting` | `swap` | undefined;
|
|
92
|
+
let swapping = false;
|
|
40
93
|
const lines: string[] = [];
|
|
41
94
|
for (const line of text.split(/\r?\n/)) {
|
|
42
95
|
const quiet = markValue(line, DEV_REBUILD_QUIET_MARK);
|
|
43
96
|
const exit = markValue(line, DEV_REBUILD_EXIT_MARK);
|
|
97
|
+
const held = markValue(line, DEV_REBUILD_HOLD_MARK);
|
|
98
|
+
const counted = markValue(line, DEV_REBUILD_TASKS_MARK);
|
|
44
99
|
if (quiet !== undefined) {
|
|
45
100
|
missing = quiet === "-";
|
|
46
101
|
quietFor = wholeNumber(quiet);
|
|
47
102
|
} else if (exit !== undefined) {
|
|
48
103
|
// A mark whose status is unreadable still means the build ENDED, and not well.
|
|
49
104
|
exitCode = wholeNumber(exit) ?? 1;
|
|
105
|
+
} else if (held !== undefined) {
|
|
106
|
+
hold = held === `1`;
|
|
107
|
+
} else if (counted !== undefined) {
|
|
108
|
+
tasks = readTasks(counted);
|
|
109
|
+
} else if (markValue(line, DEV_REBUILD_CANCEL_MARK) !== undefined) {
|
|
110
|
+
cancelled = true;
|
|
111
|
+
} else if (markValue(line, DEV_REBUILD_WAITING_MARK) !== undefined) {
|
|
112
|
+
gate = `waiting`;
|
|
113
|
+
} else if (markValue(line, DEV_REBUILD_SWAP_MARK) !== undefined) {
|
|
114
|
+
gate = `swap`;
|
|
115
|
+
swapping = true;
|
|
50
116
|
} else {
|
|
51
117
|
lines.push(line);
|
|
52
118
|
}
|
|
@@ -54,5 +120,7 @@ export const readDevRebuildLog = (text: string): DevRebuildLog => {
|
|
|
54
120
|
while (lines.at(-1)?.trim() === "") {
|
|
55
121
|
lines.pop();
|
|
56
122
|
}
|
|
57
|
-
|
|
123
|
+
// A gate still holding has printed nothing since its word, and a build that ended is holding nothing.
|
|
124
|
+
const waiting = gate === `waiting` && exitCode === undefined;
|
|
125
|
+
return { missing, quietFor, exitCode, cancelled, hold, waiting, swapping, tasks, lines };
|
|
58
126
|
};
|
|
@@ -16,17 +16,45 @@ export const DeviceCommandSchema = z.enum([
|
|
|
16
16
|
"dev-restart",
|
|
17
17
|
"dev-rebuild",
|
|
18
18
|
"dev-rebuild-log",
|
|
19
|
+
// The rebuild's three levers, each a file beside its log on the machine (dev-rebuild-log.ts): hold the restart at
|
|
20
|
+
// the swap gate, let it through, or stop the build before the gate is passed.
|
|
21
|
+
"dev-rebuild-hold",
|
|
22
|
+
"dev-rebuild-release",
|
|
23
|
+
"dev-rebuild-cancel",
|
|
19
24
|
"sync-install",
|
|
20
25
|
]);
|
|
21
26
|
export type DeviceCommand = z.infer<typeof DeviceCommandSchema>;
|
|
22
27
|
// The reversible sync switches: the subset a device's own row drives with a pair of buttons, as opposed to the two
|
|
23
28
|
// commands a card elsewhere issues once. Its own type so those button tables stay total without carrying entries for
|
|
24
29
|
// commands they can never send.
|
|
25
|
-
export const DeviceSyncSwitchSchema = DeviceCommandSchema.exclude([
|
|
30
|
+
export const DeviceSyncSwitchSchema = DeviceCommandSchema.exclude([
|
|
31
|
+
"dev-restart",
|
|
32
|
+
"dev-rebuild",
|
|
33
|
+
"dev-rebuild-log",
|
|
34
|
+
"dev-rebuild-hold",
|
|
35
|
+
"dev-rebuild-release",
|
|
36
|
+
"dev-rebuild-cancel",
|
|
37
|
+
"sync-install",
|
|
38
|
+
"sync-clean",
|
|
39
|
+
]);
|
|
26
40
|
export type DeviceSyncSwitch = z.infer<typeof DeviceSyncSwitchSchema>;
|
|
27
41
|
|
|
28
42
|
// Where a detached rebuild reports itself, and the reader of that report (dev-rebuild-log.ts).
|
|
29
|
-
export {
|
|
43
|
+
export {
|
|
44
|
+
DEV_REBUILD_CANCEL_MARK,
|
|
45
|
+
DEV_REBUILD_EXIT_MARK,
|
|
46
|
+
DEV_REBUILD_HOLD_MARK,
|
|
47
|
+
DEV_REBUILD_QUIET_MARK,
|
|
48
|
+
DEV_REBUILD_SWAP_MARK,
|
|
49
|
+
DEV_REBUILD_TASKS_MARK,
|
|
50
|
+
DEV_REBUILD_WAITING_MARK,
|
|
51
|
+
type DevRebuildLog,
|
|
52
|
+
type DevRebuildTasks,
|
|
53
|
+
devRebuildHoldPath,
|
|
54
|
+
devRebuildLogPath,
|
|
55
|
+
devRebuildPidPath,
|
|
56
|
+
readDevRebuildLog,
|
|
57
|
+
} from "./dev-rebuild-log.js";
|
|
30
58
|
|
|
31
59
|
// Machine's sandbox id (absent = every paired sandbox); must start alphanumeric, else it parses as a CLI flag.
|
|
32
60
|
export const DeviceSandboxIdSchema = z
|
|
@@ -125,6 +125,26 @@ export type EnvironmentRebuildWait = z.infer<typeof EnvironmentRebuildWaitSchema
|
|
|
125
125
|
// Asks for that rebuild: the approved overlay's hash and the device that rebuilds this sandbox.
|
|
126
126
|
export const EnvironmentRebuildWhenIdleSchema = z.object({ host: z.string().min(1), hash: z.string().min(1) });
|
|
127
127
|
export type EnvironmentRebuildWhenIdle = z.infer<typeof EnvironmentRebuildWhenIdleSchema>;
|
|
128
|
+
// A CHECKOUT REBUILD'S RESTART, LET THROUGH ONCE NO AGENT IS MID-TURN. The rebuild holds at its swap gate (the hold file,
|
|
129
|
+
// dev-rebuild-log.ts) and the sandbox, which is the one that knows who is mid-turn, lets it through when nobody is. Kept
|
|
130
|
+
// by the sandbox for the same reason as the rebuild wait above, and in memory for the same reason: this sandbox
|
|
131
|
+
// restarting for anything else is the interruption it was waiting to spare.
|
|
132
|
+
export const EnvironmentDevSwapWaitSchema = z.object({
|
|
133
|
+
// The connected device that runs the rebuild, and so holds its gate.
|
|
134
|
+
host: z.string(),
|
|
135
|
+
requestedAt: z.number(),
|
|
136
|
+
// waiting: the gate is held until nobody is mid-turn. released: let through, the restart is under way.
|
|
137
|
+
// failed: the device could not be told; said until the owner picks again.
|
|
138
|
+
phase: z.enum(["waiting", "released", "failed"]),
|
|
139
|
+
// Who it waits on, by the title the board shows them under; empty once it is no longer waiting.
|
|
140
|
+
waitingOn: z.array(z.string()),
|
|
141
|
+
// The device's own words for a failed one.
|
|
142
|
+
message: z.string().optional(),
|
|
143
|
+
});
|
|
144
|
+
export type EnvironmentDevSwapWait = z.infer<typeof EnvironmentDevSwapWaitSchema>;
|
|
145
|
+
// Asks for that wait: the device the rebuild runs on.
|
|
146
|
+
export const EnvironmentDevSwapWhenIdleSchema = z.object({ host: z.string().min(1) });
|
|
147
|
+
export type EnvironmentDevSwapWhenIdle = z.infer<typeof EnvironmentDevSwapWhenIdleSchema>;
|
|
128
148
|
export const EnvironmentSchema = z.object({
|
|
129
149
|
proposal: environmentFileSchema.optional(),
|
|
130
150
|
// The owner-approved agent-written custom section (.intentic/config/environment.custom.Dockerfile).
|
|
@@ -142,6 +162,8 @@ export const EnvironmentSchema = z.object({
|
|
|
142
162
|
localImage: EnvironmentLocalImageSchema.optional(),
|
|
143
163
|
// A rebuild waiting for the agents to be idle, or started or refused once they were; absent when none is asked.
|
|
144
164
|
rebuildWhenIdle: EnvironmentRebuildWaitSchema.optional(),
|
|
165
|
+
// A checkout rebuild's restart held until no agent is mid-turn; absent when none is asked.
|
|
166
|
+
devSwapWhenIdle: EnvironmentDevSwapWaitSchema.optional(),
|
|
145
167
|
// This sandbox can hold a rebuild until no agent is mid-turn (POST /environment/rebuild-when-idle), and resume the
|
|
146
168
|
// turns a restart the owner starts cuts when asked (a device swap's `resumeTurns`). Absent from one too old to,
|
|
147
169
|
// where the rebuild dialog offers only "Rebuild now" and the cut turns wait to be continued, as before.
|
package/src/schemas/links.ts
CHANGED
|
@@ -27,6 +27,12 @@ export const LinkTermsSchema = z.object({
|
|
|
27
27
|
.describe(
|
|
28
28
|
"The persona every task through this link wears: its accounts, its shelves, its folders, its model. Absent, the task runs with no signed-in account and the full toolbox, as any unattended wake does.",
|
|
29
29
|
),
|
|
30
|
+
// Who the link's tasks act for (schemas/services.ts), the hard half beside the persona's posture.
|
|
31
|
+
runAs: entryId
|
|
32
|
+
.optional()
|
|
33
|
+
.describe(
|
|
34
|
+
"The service every task through this link acts as: whose authority it uses, held to that service's access profile. Absent means this sandbox's owner, limited only by the persona.",
|
|
35
|
+
),
|
|
30
36
|
approve: z
|
|
31
37
|
.boolean()
|
|
32
38
|
.default(false)
|
|
@@ -84,8 +90,13 @@ export type InboundLinkMint = z.infer<typeof InboundLinkMintSchema>;
|
|
|
84
90
|
// The raw token, shown exactly once.
|
|
85
91
|
export const InboundLinkMintedSchema = z.object({ id: z.string(), token: z.string() });
|
|
86
92
|
export type InboundLinkMinted = z.infer<typeof InboundLinkMintedSchema>;
|
|
87
|
-
// POST /system/links/{id}: new terms, whole fields replaced, the rest kept.
|
|
88
|
-
|
|
93
|
+
// POST /system/links/{id}: new terms, whole fields replaced, the rest kept. `null` on the persona or the service takes it
|
|
94
|
+
// off (2026-10-26): absence keeps a field, so before this neither could be cleared once set.
|
|
95
|
+
export const InboundLinkTermsUpdateSchema = LinkTermsSchema.partial().extend({
|
|
96
|
+
label: z.string().trim().min(1).max(60).optional(),
|
|
97
|
+
actsAs: entryId.nullable().optional().describe("The persona every task wears; null takes it off."),
|
|
98
|
+
runAs: entryId.nullable().optional().describe("The service every task acts as; null takes it off, so tasks act for this sandbox's owner."),
|
|
99
|
+
});
|
|
89
100
|
export type InboundLinkTermsUpdate = z.infer<typeof InboundLinkTermsUpdateSchema>;
|
|
90
101
|
// POST /system/links/{id}/requests/{request}: the owner's answer to one waiting task.
|
|
91
102
|
export const LinkRequestDecisionSchema = z.object({ approve: z.boolean() });
|
package/src/schemas/members.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// members: the daemon's shared-access roster (GET/POST/DELETE /members), who besides the owner reaches this sandbox
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { CapabilityKind } from "./capabilities.js";
|
|
4
|
+
import { entryId } from "./internal.js";
|
|
4
5
|
import { type GrantedRole, GrantedRoleSchema, MemberRoleSchema } from "./shared.js";
|
|
6
|
+
import { ToolCeilingSchema } from "./tool-ceiling.js";
|
|
5
7
|
|
|
6
8
|
// WHAT A PERSON'S CONVERSATIONS MAY SPEND: the connected capabilities (by id) and the stored secrets (by name) an agent
|
|
7
9
|
// working for them is handed. Enforced by the daemon, not told to the model: a capability outside it is never mounted
|
|
@@ -36,6 +38,31 @@ export const REACHABLE_CREDENTIAL_KINDS: readonly CapabilityKind[] = [
|
|
|
36
38
|
"link",
|
|
37
39
|
];
|
|
38
40
|
|
|
41
|
+
// WHICH AI ACCOUNTS A PERSON'S CONVERSATIONS MAY RUN ON: the model accounts that pay for a turn (a Claude or Codex
|
|
42
|
+
// subscription, a routed provider's sign-in, an API-key endpoint), as distinct from the connections above, which are
|
|
43
|
+
// what a turn's agent works WITH. Kept apart from `credentials` because the two are narrowed for different reasons
|
|
44
|
+
// (whose allowance a person spends, against what they may touch) and because narrowing one must never empty the other:
|
|
45
|
+
// a reach listing no AI account would leave a person who runs agents unable to run any.
|
|
46
|
+
// An entry is `<provider>:<account>`, one account of a provider that holds accounts (its id as the provider's account
|
|
47
|
+
// list names it), or `<provider>` alone, every account of that provider including any connected later: how an API-key
|
|
48
|
+
// endpoint or an installed agent, which hold no accounts of their own, are named. Enforced where the daemon decides the
|
|
49
|
+
// account a turn runs on (agent/run/decide): a turn naming an account outside it is refused, one left to the sandbox's
|
|
50
|
+
// pick runs only on an account inside it, and a conversation remembering one outside it is moved onto one inside it.
|
|
51
|
+
// A conversation runs only on what every person who has written in it may, as with `credentials`.
|
|
52
|
+
export const AiAccountKeySchema = z.string().min(1).max(300);
|
|
53
|
+
|
|
54
|
+
/** The key an AI account is listed under: the provider alone for every account of it, else `provider:account`. */
|
|
55
|
+
export const aiAccountKey = (provider: string, account?: string): string => (account === undefined ? provider : `${provider}:${account}`);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Whether a list of AI account keys lets a turn run on one account of a provider. `account` undefined asks about the
|
|
59
|
+
* provider as a whole (one that holds no accounts of its own): only its own key answers yes then.
|
|
60
|
+
*/
|
|
61
|
+
export const aiAccountAllowed = (keys: Iterable<string>, provider: string, account: string | undefined): boolean => {
|
|
62
|
+
const held = new Set(keys);
|
|
63
|
+
return held.has(provider) || (account !== undefined && held.has(aiAccountKey(provider, account)));
|
|
64
|
+
};
|
|
65
|
+
|
|
39
66
|
// WHAT ONE PERSON MAY DO, as three independent answers rather than one rung of a ladder: whether their conversations
|
|
40
67
|
// run agents (`agents`), where they may look (`areas`, the fence their agents run inside too) and where they may change
|
|
41
68
|
// files by hand (`edit`), and whether they manage the sandbox (the maintainer tier, which implies every other answer).
|
|
@@ -159,6 +186,28 @@ export const MemberSchema = z.object({
|
|
|
159
186
|
credentials: CredentialReachSchema.optional().describe(
|
|
160
187
|
"The capabilities and secrets their conversations may spend. Absent means every one, including any connected later.",
|
|
161
188
|
),
|
|
189
|
+
aiAccounts: z
|
|
190
|
+
.array(AiAccountKeySchema)
|
|
191
|
+
.max(500)
|
|
192
|
+
.optional()
|
|
193
|
+
.describe(
|
|
194
|
+
"The AI accounts their conversations may run on, each `provider:account`, or a provider's id alone for every account of it (how an API-key endpoint is named). Absent means every one, including any connected later.",
|
|
195
|
+
),
|
|
196
|
+
tools: ToolCeilingSchema.optional().describe(
|
|
197
|
+
"The most their conversations' tools may be, shelf by shelf; a persona only narrows inside it. Absent means no limit.",
|
|
198
|
+
),
|
|
199
|
+
assistants: z
|
|
200
|
+
.array(entryId)
|
|
201
|
+
.max(50)
|
|
202
|
+
.optional()
|
|
203
|
+
.describe(
|
|
204
|
+
"For a guest who chats: which of the assistants working in their areas they may talk to, by persona id. Absent means every one that works there.",
|
|
205
|
+
),
|
|
206
|
+
profile: entryId
|
|
207
|
+
.optional()
|
|
208
|
+
.describe(
|
|
209
|
+
"The access profile their answers come from (docs/architecture/access.md). Its answers are written out on this row too, and saving the profile rewrites them. Absent means answers of their own.",
|
|
210
|
+
),
|
|
162
211
|
});
|
|
163
212
|
export type Member = z.infer<typeof MemberSchema>;
|
|
164
213
|
|
|
@@ -181,7 +230,13 @@ export type MembersRoster = z.infer<typeof MembersRosterSchema>;
|
|
|
181
230
|
// `agents` and `edit` decide the rest of the access; absent, the role's own meaning stands, so an editor that predates
|
|
182
231
|
// them still grants what it always did. `lands` is written as sent: absent is no, so a re-grade that never mentions it
|
|
183
232
|
// can never hand a home-only person's agent the authority to land. The role sent must be the tier the access makes (`tierOf`): two answers to one
|
|
184
|
-
// question are refused rather than one of them guessed away.
|
|
233
|
+
// question are refused rather than one of them guessed away. `aiAccounts` reads as `credentials` does: `all` lifts it, a
|
|
234
|
+
// list sets it, absent keeps the row's; a maintainer is refused a list, since the tier runs on every account. `tools` and
|
|
235
|
+
// `assistants` read the same way.
|
|
236
|
+
// `profile` names an access profile instead of answering on the row: the daemon writes that profile's answers out on
|
|
237
|
+
// the row and ignores the access fields sent beside it, and the role sent must still be the tier the profile makes.
|
|
238
|
+
// Absent is answers of the row's own, so a re-grade from an editor that predates profiles unlinks the row, keeping
|
|
239
|
+
// the answers it carried, rather than leaving a link the grant did not mean. A maintainer is refused one.
|
|
185
240
|
export const MemberGrantSchema = z.object({
|
|
186
241
|
email: z.string(),
|
|
187
242
|
role: GrantedRoleSchema,
|
|
@@ -191,6 +246,10 @@ export const MemberGrantSchema = z.object({
|
|
|
191
246
|
lands: z.boolean().optional(),
|
|
192
247
|
emailSignIn: z.boolean().optional(),
|
|
193
248
|
credentials: z.union([z.literal("all"), CredentialReachSchema]).optional(),
|
|
249
|
+
aiAccounts: z.union([z.literal("all"), z.array(AiAccountKeySchema).max(500)]).optional(),
|
|
250
|
+
tools: z.union([z.literal("all"), ToolCeilingSchema]).optional(),
|
|
251
|
+
assistants: z.union([z.literal("all"), z.array(entryId).max(50)]).optional(),
|
|
252
|
+
profile: entryId.optional(),
|
|
194
253
|
});
|
|
195
254
|
export type MemberGrant = z.infer<typeof MemberGrantSchema>;
|
|
196
255
|
|
|
@@ -205,6 +264,13 @@ export const MemberSelfSchema = z.object({
|
|
|
205
264
|
.boolean()
|
|
206
265
|
.optional()
|
|
207
266
|
.describe("Whether work done for them lands by itself and they may land it: a maintainer's everywhere, a home-only person's on their home. Absent means no."),
|
|
267
|
+
aiAccounts: z
|
|
268
|
+
.array(AiAccountKeySchema)
|
|
269
|
+
.optional()
|
|
270
|
+
.describe("The AI accounts their conversations may run on, as the roster keys them, so a picker offers only those. Absent means every one."),
|
|
271
|
+
tools: ToolCeilingSchema.optional().describe("The most their conversations' tools may be. Absent means no limit."),
|
|
272
|
+
assistants: z.array(entryId).optional().describe("For a guest who chats: the assistants they may talk to. Absent means every one in their areas."),
|
|
273
|
+
profile: entryId.optional().describe("The access profile their access comes from. Absent means answers of their own."),
|
|
208
274
|
});
|
|
209
275
|
export type MemberSelf = z.infer<typeof MemberSelfSchema>;
|
|
210
276
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { AccessProfileSchema } from "./access-profiles.js";
|
|
2
3
|
import { PRESET_GROUPS, type PresetGroup, PresetGroupSchema } from "./compliance.js";
|
|
4
|
+
import { AiAccountKeySchema } from "./members.js";
|
|
5
|
+
import { ToolCeilingSchema } from "./tool-ceiling.js";
|
|
3
6
|
|
|
4
7
|
// An ORGANISATION'S POLICY as a sandbox holds it (docs/architecture/organisations.md). A sandbox that belongs to an
|
|
5
8
|
// organisation is handed this by the platform it is registered with; a personal sandbox never holds one, and nothing
|
|
@@ -30,6 +33,20 @@ export type OrgSection = z.infer<typeof OrgSectionSchema>;
|
|
|
30
33
|
export const OrgSectionModeSchema = z.enum(["open", "locked", "hidden"]);
|
|
31
34
|
export type OrgSectionMode = z.infer<typeof OrgSectionModeSchema>;
|
|
32
35
|
|
|
36
|
+
// THE ORGANISATION'S CEILING: one more limit in every turn of a bound sandbox, the owner's included
|
|
37
|
+
// (docs/architecture/access.md). Only what means the same in every sandbox: tool shelves, and the AI accounts a turn may
|
|
38
|
+
// run on, by provider (`claude`) or by one provider's account. Connections and areas are each sandbox's own ids, so an
|
|
39
|
+
// organisation holds those through the profiles it hands out instead.
|
|
40
|
+
export const OrgCeilingSchema = z.object({
|
|
41
|
+
tools: ToolCeilingSchema.optional().describe("The most any turn's tools may be, shelf by shelf. Absent means no limit."),
|
|
42
|
+
aiAccounts: z
|
|
43
|
+
.array(AiAccountKeySchema)
|
|
44
|
+
.max(100)
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("The AI accounts any turn may run on, a provider alone or `provider:account`. Absent means every one."),
|
|
47
|
+
});
|
|
48
|
+
export type OrgCeiling = z.infer<typeof OrgCeilingSchema>;
|
|
49
|
+
|
|
33
50
|
// Omitted policy sections stay open. preset pins effective settings and refuses undoing writes, regardless of underlying files.
|
|
34
51
|
// Unknown preset groups are skipped/reported as unenforced so newer policies still reach older daemons; the platform validates saved names.
|
|
35
52
|
// membersOnly fences roster grants/removals by organisation membership, excluding the owner who is not a roster entry.
|
|
@@ -48,6 +65,14 @@ export const OrgPolicyRulesSchema = z.object({
|
|
|
48
65
|
.boolean()
|
|
49
66
|
.optional()
|
|
50
67
|
.describe("Only the organisation's members may be on a bound sandbox's roster; removing someone from the organisation removes them everywhere."),
|
|
68
|
+
// Listed in every bound sandbox beside its own profiles, read-only there; a local profile cannot take one's id.
|
|
69
|
+
// Optional like the rest, so a policy stored before them hands out none.
|
|
70
|
+
profiles: z
|
|
71
|
+
.array(AccessProfileSchema)
|
|
72
|
+
.max(50)
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("Access profiles every bound sandbox may grant, read-only there. Areas and connections they name are each sandbox's own ids."),
|
|
75
|
+
ceiling: OrgCeilingSchema.optional().describe("What no turn in a bound sandbox may exceed, the owner's included."),
|
|
51
76
|
});
|
|
52
77
|
export type OrgPolicyRules = z.infer<typeof OrgPolicyRulesSchema>;
|
|
53
78
|
|