@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
package/src/schemas/personas.ts
CHANGED
|
@@ -6,11 +6,13 @@ import { type ModelPin, ModelPinSchema } from "./agent.js";
|
|
|
6
6
|
import { entryId } from "./internal.js";
|
|
7
7
|
import { SkillDraftSchema, SkillNameSchema, SYSTEM_PROMPT_MAX, SystemPromptModeSchema } from "./settings.js";
|
|
8
8
|
// A named face the sandbox shows outward: who it speaks as, what it may do, where it works, what it's told, what it
|
|
9
|
-
// runs on. No credential lives on the card; accounts stay private, per-sandbox.
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
9
|
+
// runs on. No credential lives on the card; accounts stay private, per-sandbox. POSTURE, NOT ACCESS
|
|
10
|
+
// (docs/architecture/access.md): what a turn may reach is decided by who it acts for, the people in its conversation
|
|
11
|
+
// or the service an unattended run acts as, each held to an access profile. A card only narrows inside that, for a
|
|
12
|
+
// watched chat and an unattended run alike, and never widens it.
|
|
13
|
+
// Narrowing is enforced by absence (`connectors`/`devices`/`mcp`: no credential injected) or by removing tools from
|
|
14
|
+
// context; `shell` decides, since with it a session can reach anything else fenced off, turning the rest into defaults,
|
|
15
|
+
// not limits. Absent `powers` means the full toolbox, inside whatever the principals allow.
|
|
14
16
|
export const PersonaPowersSchema = z.object({
|
|
15
17
|
// "read" is look-and-search only; "write" adds creating and changing; "none" removes both.
|
|
16
18
|
files: z
|
|
@@ -208,7 +210,7 @@ export const PersonaSchema = z.object({
|
|
|
208
210
|
.array(entryId)
|
|
209
211
|
.max(50)
|
|
210
212
|
.describe(
|
|
211
|
-
"Which connected accounts
|
|
213
|
+
"Which connected accounts it speaks through. Named individually rather than by site, because two accounts on one site is the whole problem this solves. It narrows: an account here is still reached only when whoever the turn acts for may use it. Naming one that is not connected yet is not an error: it is a card describing an account this sandbox has still to sign into.",
|
|
212
214
|
),
|
|
213
215
|
// Owner-written, not derived: a classifier routes better on prose than on a list of account ids. Absent, the router
|
|
214
216
|
// has less to go on but still tries.
|
|
@@ -220,7 +222,7 @@ export const PersonaSchema = z.object({
|
|
|
220
222
|
"What this persona is for, in one line. A new chat is routed onto a persona by this sentence, and the Personas page shows it under the name.",
|
|
221
223
|
),
|
|
222
224
|
powers: PersonaPowersSchema.optional().describe(
|
|
223
|
-
"What a conversation wearing it may do. Absent means the full toolbox, so a card written before this existed behaves exactly as it did.",
|
|
225
|
+
"What a conversation wearing it may do, inside what whoever it acts for may. Absent means the full toolbox, so a card written before this existed behaves exactly as it did.",
|
|
224
226
|
),
|
|
225
227
|
workspace: PersonaWorkspaceSchema.optional().describe("Where it works. Absent means the whole workspace."),
|
|
226
228
|
context: PersonaContextSchema.optional().describe(
|
|
@@ -253,10 +255,12 @@ export const personaModels = (card: Pick<Persona, "models">, sources: readonly M
|
|
|
253
255
|
// The one stock persona id; lives here because the daemon and the automations form are separate packages that must
|
|
254
256
|
// agree on it exactly, or a Visitor chat pins to a card nobody creates.
|
|
255
257
|
export const VISITOR_CHAT_PERSONA = "visitor-chat";
|
|
256
|
-
// THE TWO BUILT-IN PERSONAS
|
|
257
|
-
// person is watching (personas.ts `turnPersona` in the daemon). They are constants rather than cards
|
|
258
|
-
// that file is tracked in git, and "every account" is not something a card's account list can say,
|
|
259
|
-
// written once and accounts are connected later. Neither can be edited or removed, and no card may
|
|
258
|
+
// THE TWO BUILT-IN PERSONAS, postures like any card: every turn wears one, and a turn naming no card wears one of these,
|
|
259
|
+
// picked by whether a person is watching (personas.ts `turnPersona` in the daemon). They are constants rather than cards
|
|
260
|
+
// in personas.json: that file is tracked in git, and "every account" is not something a card's account list can say,
|
|
261
|
+
// since the list is written once and accounts are connected later. Neither can be edited or removed, and no card may
|
|
262
|
+
// take either id. Both stay inside what the turn's principals may (docs/architecture/access.md): "every account" is
|
|
263
|
+
// every account they may use.
|
|
260
264
|
// Full access: every tool and every signed-in account, what a chat a person starts without picking anyone acts as.
|
|
261
265
|
export const FULL_ACCESS_PERSONA = "full-access";
|
|
262
266
|
// No accounts: every tool but no signed-in account, what a run nobody watches acts as when it names no one, since
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { entryId } from "./internal.js";
|
|
3
|
+
|
|
4
|
+
// A SERVICE: a named non-human principal unattended work acts as (docs/architecture/access.md). An automation, one of its
|
|
5
|
+
// sender rules, an inbound link or a control token names one in `runAs`, and every turn it starts acts for the service's
|
|
6
|
+
// steward, a person, narrowed by the service's access profile. An agent so never holds more than the person it acts for,
|
|
7
|
+
// and a steward who leaves the roster takes the reach of every service they steward with them.
|
|
8
|
+
// Holds no credential: a steward is an address on the roster, a profile an id.
|
|
9
|
+
export const ServiceSchema = z.object({
|
|
10
|
+
id: entryId.describe("The service's id, what `runAs` names."),
|
|
11
|
+
label: z.string().max(60).optional().describe("What to call it on screen, like 'Marketing bot'. Absent falls back to the id."),
|
|
12
|
+
brief: z.string().max(200).optional().describe("What it does, in one line."),
|
|
13
|
+
steward: z
|
|
14
|
+
.string()
|
|
15
|
+
.min(3)
|
|
16
|
+
.max(320)
|
|
17
|
+
.describe(
|
|
18
|
+
"Who it acts for, by email: the sandbox's owner or someone on its roster. Its runs reach at most what this person may, and nothing once they leave.",
|
|
19
|
+
),
|
|
20
|
+
profile: entryId
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("The access profile its runs are held to, inside what its steward may. Absent means everything its steward may."),
|
|
23
|
+
});
|
|
24
|
+
export type Service = z.infer<typeof ServiceSchema>;
|
|
25
|
+
|
|
26
|
+
export const ServicesListSchema = z.object({ services: z.array(ServiceSchema).describe("Every service unattended work here may run as.") });
|
|
27
|
+
export type ServicesList = z.infer<typeof ServicesListSchema>;
|
|
28
|
+
|
|
29
|
+
export const ServiceIdParamSchema = z.object({ id: entryId.describe("Which service.") });
|
|
30
|
+
|
|
31
|
+
// What a `runAs` holds: one service's id.
|
|
32
|
+
export const ServiceRefSchema = entryId.describe("Which service it acts as.");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { convertDocument } from "../documents/conversions.js";
|
|
2
|
-
import type
|
|
2
|
+
import { MODEL_ROLES, type ModelRole } from "../models/model-roles.js";
|
|
3
3
|
import { rolePins } from "../models/model-setups.js";
|
|
4
4
|
import { SETTINGS_HISTORY } from "./settings-history.js";
|
|
5
5
|
import { RepoChecksFileSchema, RuleSchema, SandboxSettingsSchema, SandboxSettingsWriteSchema } from "./settings.js";
|
|
@@ -245,3 +245,25 @@ describe(`restore points' retention, renamed so a stored zero is the owner's own
|
|
|
245
245
|
expect(read({ restorePointDays: 0, restorePointKeepDays: 5 }).retention.restorePointKeepDays).toBe(5);
|
|
246
246
|
});
|
|
247
247
|
});
|
|
248
|
+
|
|
249
|
+
describe(`default job setups`, () => {
|
|
250
|
+
test(`new settings place every job on its suggested preset`, () => {
|
|
251
|
+
const settings = SandboxSettingsSchema.parse({});
|
|
252
|
+
expect(settings.roleSetups).toEqual(Object.fromEntries(MODEL_ROLES.map((role) => [role.id, role.setup])));
|
|
253
|
+
expect(settings.roleSetups[`commit-message`]).toBe(`low`);
|
|
254
|
+
expect(settings.roleSetups[`safety-judge`]).toBe(`medium`);
|
|
255
|
+
expect(settings.roleSetups[`pipeline-fix`]).toBe(`high`);
|
|
256
|
+
const sources = [{ provider: `claude`, ready: true, models: [`claude-haiku-4-5`, `claude-sonnet-5`, `claude-opus-5`] }] as const;
|
|
257
|
+
expect(rolePins(settings, `commit-message`, sources)).toEqual([{ provider: `claude`, model: `claude-haiku-4-5` }]);
|
|
258
|
+
expect(rolePins(settings, `safety-judge`, sources)).toEqual([{ provider: `claude`, model: `claude-sonnet-5` }]);
|
|
259
|
+
expect(rolePins(settings, `pipeline-fix`, sources)).toEqual([{ provider: `claude`, model: `claude-opus-5` }]);
|
|
260
|
+
expect(rolePins(settings, `pipeline-fix`, [])).toEqual([]);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
test(`saved assignments keep their choices and jobs left off`, () => {
|
|
264
|
+
expect(SandboxSettingsSchema.parse({ roleSetups: {} }).roleSetups).toEqual({});
|
|
265
|
+
expect(SandboxSettingsSchema.parse({ roleSetups: { "commit-message": `high` } }).roleSetups).toEqual({ "commit-message": `high` });
|
|
266
|
+
const saved = SandboxSettingsSchema.parse({ roleSetups: {} });
|
|
267
|
+
expect(SandboxSettingsWriteSchema.parse({ ...saved, commandJudge: `watch` }).roleSetups).toEqual({});
|
|
268
|
+
});
|
|
269
|
+
});
|
package/src/schemas/settings.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { claudeExperimentSettings, iqSearchSettings } from "./settings-experiments.js";
|
|
4
4
|
import { CommandJudgeModeSchema, ProjectInstallModeSchema } from "../policy/safety-policy.js";
|
|
5
|
-
import { ModelRoleSchema } from "../models/model-roles.js";
|
|
5
|
+
import { MODEL_ROLES, ModelRoleSchema } from "../models/model-roles.js";
|
|
6
6
|
import { MODEL_SETUP_ID, ModelSetupSchema } from "../models/model-setups.js";
|
|
7
7
|
import { AdmissionPolicySchema, AdmissionRuleSchema } from "./command-admission.js";
|
|
8
8
|
import { KeepWarmSettingsSchema } from "./keep-warm.js";
|
|
@@ -383,12 +383,13 @@ export const SandboxSettingsSchema = z.object({
|
|
|
383
383
|
"The model setups jobs run on: Low, Medium and High, which every sandbox has, and any you make. Each is an ordered list of models, tried in order so one spent account does not take its jobs down. A preset left out of this list, or listed without models, is worked out from the accounts you have connected. A setup runs only the jobs put on it (`roleSetups`).",
|
|
384
384
|
),
|
|
385
385
|
// `partialRecord`, not `record`: an exhaustive one would force every settings file to list every role, and adding
|
|
386
|
-
// one would invalidate them all.
|
|
386
|
+
// one would invalidate them all. A fresh sandbox places every job on its suggested preset; an explicit
|
|
387
|
+
// map stays as written, including an empty one or a job removed from it.
|
|
387
388
|
roleSetups: z
|
|
388
389
|
.partialRecord(ModelRoleSchema, z.string().regex(MODEL_SETUP_ID))
|
|
389
|
-
.default(
|
|
390
|
+
.default(() => Object.fromEntries(MODEL_ROLES.map((role) => [role.id, role.setup])))
|
|
390
391
|
.describe(
|
|
391
|
-
"Which setup each job runs on: commit messages, session titles, the safety judge, pipeline fixes and every other place this sandbox picks a model for you.
|
|
392
|
+
"Which setup each job runs on: commit messages, session titles, the safety judge, pipeline fixes and every other place this sandbox picks a model for you. Defaults to each job’s suggested Low, Medium or High setup. In a saved map, a job left out, or on a setup with no models, has none, so a one-shot job does not run and a whole session opens on whatever your own chat is set to.",
|
|
392
393
|
),
|
|
393
394
|
// Folded into the router's prompt (agent/prompt/chat-router.ts), never into a turn's own. Capped small on
|
|
394
395
|
// purpose: the reading runs under a 5s deadline, and this text is paid for on every chat that opens on Auto.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { PersonaPowersSchema } from "./personas.js";
|
|
2
|
+
import { capPowers, ceilingLimits, ceilingWithholds, ceilingWords, intersectCeilings } from "./tool-ceiling.js";
|
|
3
|
+
|
|
4
|
+
// A ceiling is an upper bound per shelf: an answer left out limits nothing, and two held together keep the lower of each.
|
|
5
|
+
|
|
6
|
+
const FULL = PersonaPowersSchema.parse({});
|
|
7
|
+
|
|
8
|
+
describe(`intersectCeilings`, () => {
|
|
9
|
+
it(`keeps the lower answer of each shelf`, () => {
|
|
10
|
+
expect(intersectCeilings({ files: `read`, shell: false }, { files: `none`, web: false })).toEqual({ files: `none`, shell: false, web: false });
|
|
11
|
+
expect(intersectCeilings({ files: `write` }, { files: `read` })).toEqual({ files: `read` });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it(`reads undefined as no ceiling at all`, () => {
|
|
15
|
+
expect(intersectCeilings(undefined, { shell: false })).toEqual({ shell: false });
|
|
16
|
+
expect(intersectCeilings({ code: false }, undefined)).toEqual({ code: false });
|
|
17
|
+
expect(intersectCeilings(undefined, undefined)).toBeUndefined();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it(`drops a shelf both answer true, since true is no limit`, () => {
|
|
21
|
+
expect(intersectCeilings({ shell: true }, { shell: true })).toEqual({});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe(`capPowers`, () => {
|
|
26
|
+
it(`lowers a persona's shelves to the ceiling and keeps its connector lists`, () => {
|
|
27
|
+
const powers = { ...FULL, connectors: [`github`] };
|
|
28
|
+
expect(capPowers(powers, { files: `read`, shell: false, delegate: false })).toEqual({
|
|
29
|
+
...powers,
|
|
30
|
+
files: `read`,
|
|
31
|
+
shell: false,
|
|
32
|
+
delegate: false,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it(`never raises a shelf the persona switched off`, () => {
|
|
37
|
+
const readOnly = { ...FULL, files: `read` as const, shell: false };
|
|
38
|
+
expect(capPowers(readOnly, { files: `write`, shell: true })).toEqual(readOnly);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it(`returns the persona's own shelves when the ceiling limits nothing`, () => {
|
|
42
|
+
expect(capPowers(FULL, undefined)).toBe(FULL);
|
|
43
|
+
expect(capPowers(FULL, { files: `write`, web: true })).toBe(FULL);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe(`ceilingLimits and ceilingWithholds`, () => {
|
|
48
|
+
it(`counts only an answer below the top as a limit`, () => {
|
|
49
|
+
expect(ceilingLimits(undefined)).toBe(false);
|
|
50
|
+
expect(ceilingLimits({ files: `write`, shell: true })).toBe(false);
|
|
51
|
+
expect(ceilingLimits({ files: `read` })).toBe(true);
|
|
52
|
+
expect(ceilingLimits({ browser: false })).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it(`withholds files below write, and a switch answered false`, () => {
|
|
56
|
+
expect(ceilingWithholds({ files: `read` }, `files`)).toBe(true);
|
|
57
|
+
expect(ceilingWithholds({ files: `write` }, `files`)).toBe(false);
|
|
58
|
+
expect(ceilingWithholds({ shell: false }, `shell`)).toBe(true);
|
|
59
|
+
expect(ceilingWithholds({ shell: false }, `web`)).toBe(false);
|
|
60
|
+
expect(ceilingWithholds(undefined, `shell`)).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe(`ceilingWords`, () => {
|
|
65
|
+
it(`names each limit in the order the shelves are listed`, () => {
|
|
66
|
+
expect(ceilingWords({ files: `read`, shell: false, sandbox: false })).toEqual([`read-only files`, `no commands`, `no sandbox settings`]);
|
|
67
|
+
expect(ceilingWords({ files: `none` })).toEqual([`no files`]);
|
|
68
|
+
expect(ceilingWords(undefined)).toEqual([]);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { PersonaPowers } from "./personas.js";
|
|
3
|
+
|
|
4
|
+
// THE MOST A TURN'S TOOLS MAY BE, as the principals it acts for are held to it (docs/architecture/access.md): one answer
|
|
5
|
+
// per persona shelf, each an upper bound. A shelf left out is not limited. A persona's own shelves are posture and only
|
|
6
|
+
// narrow inside this; a conversation grant lifts what a persona withheld and never what a ceiling did.
|
|
7
|
+
// The same names and order as a persona's shelves (schemas/personas.ts PersonaPowersSchema), so one vocabulary covers
|
|
8
|
+
// both, with no defaults: an absent answer here is "no limit", where an absent shelf on a card is "on".
|
|
9
|
+
export const ToolCeilingSchema = z.object({
|
|
10
|
+
files: z.enum(["none", "read", "write"]).optional().describe("The most it may do with files: nothing, look and search, or also create and change."),
|
|
11
|
+
shell: z
|
|
12
|
+
.boolean()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("False takes commands away, and with them the terminals and every tool on the image. The switch the strength of the others depends on."),
|
|
15
|
+
code: z.boolean().optional().describe("False takes away writing and running a script."),
|
|
16
|
+
web: z.boolean().optional().describe("False takes away fetching a page and searching the web."),
|
|
17
|
+
browser: z.boolean().optional().describe("False takes away the credential-free browser."),
|
|
18
|
+
delegate: z.boolean().optional().describe("False takes away spawning subagents and running workflows."),
|
|
19
|
+
sandbox: z.boolean().optional().describe("False takes away changing the sandbox's own settings, manifests and public outbox."),
|
|
20
|
+
});
|
|
21
|
+
export type ToolCeiling = z.infer<typeof ToolCeilingSchema>;
|
|
22
|
+
|
|
23
|
+
// The shelves a ceiling answers, other than `files`, which is ranked rather than switched.
|
|
24
|
+
export const CEILING_SWITCHES = ["shell", "code", "web", "browser", "delegate", "sandbox"] as const;
|
|
25
|
+
export type CeilingSwitch = (typeof CEILING_SWITCHES)[number];
|
|
26
|
+
|
|
27
|
+
const FILES_RANK = { none: 0, read: 1, write: 2 } as const;
|
|
28
|
+
type FilesAnswer = keyof typeof FILES_RANK;
|
|
29
|
+
|
|
30
|
+
const lowerFiles = (left: FilesAnswer | undefined, right: FilesAnswer | undefined): FilesAnswer | undefined => {
|
|
31
|
+
if (left === undefined) {
|
|
32
|
+
return right;
|
|
33
|
+
}
|
|
34
|
+
if (right === undefined) {
|
|
35
|
+
return left;
|
|
36
|
+
}
|
|
37
|
+
return FILES_RANK[left] <= FILES_RANK[right] ? left : right;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Whether a ceiling limits anything at all; undefined and an empty one do not. */
|
|
41
|
+
export const ceilingLimits = (ceiling: ToolCeiling | undefined): boolean =>
|
|
42
|
+
ceiling !== undefined && ((ceiling.files !== undefined && ceiling.files !== "write") || CEILING_SWITCHES.some((shelf) => ceiling[shelf] === false));
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Two ceilings held together: the lower answer of each shelf, so a turn acting for several principals is held to what
|
|
46
|
+
* every one of them may. Undefined is no ceiling, and holding it beside another changes nothing.
|
|
47
|
+
*/
|
|
48
|
+
export const intersectCeilings = (left: ToolCeiling | undefined, right: ToolCeiling | undefined): ToolCeiling | undefined => {
|
|
49
|
+
if (left === undefined) {
|
|
50
|
+
return right;
|
|
51
|
+
}
|
|
52
|
+
if (right === undefined) {
|
|
53
|
+
return left;
|
|
54
|
+
}
|
|
55
|
+
const files = lowerFiles(left.files, right.files);
|
|
56
|
+
const held: ToolCeiling = files === undefined ? {} : { files };
|
|
57
|
+
for (const shelf of CEILING_SWITCHES) {
|
|
58
|
+
if (left[shelf] === false || right[shelf] === false) {
|
|
59
|
+
held[shelf] = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return held;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** A persona's shelves held under a ceiling: each shelf the lower of the two, connector lists untouched. */
|
|
66
|
+
export const capPowers = (powers: PersonaPowers, ceiling: ToolCeiling | undefined): PersonaPowers => {
|
|
67
|
+
if (!ceilingLimits(ceiling) || ceiling === undefined) {
|
|
68
|
+
return powers;
|
|
69
|
+
}
|
|
70
|
+
const capped: PersonaPowers = { ...powers, files: lowerFiles(powers.files, ceiling.files) ?? powers.files };
|
|
71
|
+
for (const shelf of CEILING_SWITCHES) {
|
|
72
|
+
if (ceiling[shelf] === false) {
|
|
73
|
+
capped[shelf] = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return capped;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Whether a ceiling holds one shelf below what a grant would open it to (`files` opens to write). */
|
|
80
|
+
export const ceilingWithholds = (ceiling: ToolCeiling | undefined, shelf: "files" | CeilingSwitch): boolean => {
|
|
81
|
+
if (ceiling === undefined) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return shelf === "files" ? ceiling.files !== undefined && ceiling.files !== "write" : ceiling[shelf] === false;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const SWITCH_WORDS = {
|
|
88
|
+
shell: "no commands",
|
|
89
|
+
code: "no scripts",
|
|
90
|
+
web: "no web",
|
|
91
|
+
browser: "no browser",
|
|
92
|
+
delegate: "no subagents",
|
|
93
|
+
sandbox: "no sandbox settings",
|
|
94
|
+
} as const satisfies Record<CeilingSwitch, string>;
|
|
95
|
+
|
|
96
|
+
/** What a ceiling withholds, in words its owner would recognise; empty when it limits nothing. */
|
|
97
|
+
export const ceilingWords = (ceiling: ToolCeiling | undefined): string[] => {
|
|
98
|
+
if (ceiling === undefined) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const words: string[] = [];
|
|
102
|
+
if (ceiling.files === "none") {
|
|
103
|
+
words.push("no files");
|
|
104
|
+
} else if (ceiling.files === "read") {
|
|
105
|
+
words.push("read-only files");
|
|
106
|
+
}
|
|
107
|
+
for (const shelf of CEILING_SWITCHES) {
|
|
108
|
+
if (ceiling[shelf] === false) {
|
|
109
|
+
words.push(SWITCH_WORDS[shelf]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return words;
|
|
113
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { holdsLockedWorkspacePath } from "./locked-folders.js";
|
|
2
|
+
import { PLAN_DOCUMENTS_DIR } from "./workspace-state.js";
|
|
3
|
+
|
|
4
|
+
// The folders the lock reaches through: deleting or moving one would carry the locked entries inside it.
|
|
5
|
+
describe(`holdsLockedWorkspacePath`, () => {
|
|
6
|
+
it(`holds the root state dir and every group in it, whichever slash`, () => {
|
|
7
|
+
expect(
|
|
8
|
+
[`.intentic`, `./.intentic/`, `.intentic/config`, `.intentic/identity`, `.intentic/secrets`, `.intentic/records`, `.intentic\\local`].map(
|
|
9
|
+
holdsLockedWorkspacePath,
|
|
10
|
+
),
|
|
11
|
+
).toEqual([true, true, true, true, true, true, true]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it(`leaves ordinary state, the locked entries themselves, and anyone else's .intentic alone`, () => {
|
|
15
|
+
expect(
|
|
16
|
+
[
|
|
17
|
+
`.intentic/config/approvals`,
|
|
18
|
+
`.intentic/records/artifacts`,
|
|
19
|
+
PLAN_DOCUMENTS_DIR,
|
|
20
|
+
`.intentic/secrets/auth`,
|
|
21
|
+
`.intentic/records/sessions`,
|
|
22
|
+
`myrepo/.intentic`,
|
|
23
|
+
`.git`,
|
|
24
|
+
``,
|
|
25
|
+
`src`,
|
|
26
|
+
].map(holdsLockedWorkspacePath),
|
|
27
|
+
).toEqual([false, false, false, false, false, false, false, false, false]);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { STATE_DIR } from "@intentic/constants";
|
|
2
|
+
import { LOCKED_STATE_ENTRIES } from "./workspace-state.js";
|
|
3
|
+
|
|
4
|
+
// Whether a path is a folder a locked entry sits in (workspace-state.ts): the root's `.intentic` and each of its groups.
|
|
5
|
+
// Such a folder is opened, read and written inside like any other, but never deleted, moved, renamed or copied onto,
|
|
6
|
+
// for anyone. Deleting or moving it would carry the locked bytes out from under the lock, and the sandbox's settings,
|
|
7
|
+
// sign-ins and history with them, and the file trash sits in `.intentic/local`, so it would leave no Undo either. A
|
|
8
|
+
// copy onto it merges, overwriting the locked files. The file API refuses all of these and the explorer leaves them
|
|
9
|
+
// out. Accepts either slash.
|
|
10
|
+
export const holdsLockedWorkspacePath = (relPath: string): boolean => {
|
|
11
|
+
const segments = relPath.split(/[\\/]/).filter((segment) => segment !== "" && segment !== ".");
|
|
12
|
+
if (segments[0] !== STATE_DIR) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const inside = segments.slice(1).join("/");
|
|
16
|
+
return inside === "" || [...LOCKED_STATE_ENTRIES].some((entry) => entry.startsWith(`${inside}/`));
|
|
17
|
+
};
|