@capybara-hq/kernel 0.1.0-rc.31 → 0.1.0-rc.33
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/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/inbound.d.ts +0 -25
- package/dist/channels/inbound.js +26 -1
- package/dist/channels/phrases.d.ts +28 -0
- package/dist/channels/phrases.js +28 -0
- package/dist/conversations/conversations.controller.d.ts +4 -1
- package/dist/conversations/conversations.controller.js +14 -2
- package/dist/conversations/conversations.service.d.ts +43 -3
- package/dist/conversations/conversations.service.js +93 -19
- package/dist/conversations/event-log.d.ts +3 -3
- package/dist/conversations/event-log.js +3 -3
- package/dist/conversations/events.d.ts +24 -0
- package/dist/conversations/events.js +69 -0
- package/dist/ctx/create-ctx.d.ts +26 -4
- package/dist/ctx/create-ctx.js +54 -34
- package/dist/db/kernel-schema.d.ts +20 -0
- package/dist/devices/conversation-devices.d.ts +57 -3
- package/dist/devices/conversation-devices.js +63 -11
- package/dist/devices/device-projects.service.d.ts +162 -0
- package/dist/devices/device-projects.service.js +503 -0
- package/dist/devices/devices.controller.d.ts +15 -2
- package/dist/devices/devices.controller.js +60 -3
- package/dist/devices/devices.module.js +15 -2
- package/dist/devices/devices.schemas.js +9 -1
- package/dist/devices/dto.d.ts +31 -0
- package/dist/devices/dto.js +38 -1
- package/dist/devices/working-root.d.ts +41 -0
- package/dist/devices/working-root.js +50 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.js +39 -0
- package/dist/evals/run-replay.d.ts +9 -1
- package/dist/evals/run-replay.js +15 -1
- package/dist/extensions/permission-set.d.ts +7 -6
- package/dist/extensions/permission-set.js +9 -6
- package/dist/extensions/permission-view.d.ts +4 -4
- package/dist/extensions/permission-view.js +10 -5
- package/dist/http/app.d.ts +8 -2
- package/dist/http/app.js +12 -2
- package/dist/http/plugin-dispatch.d.ts +55 -18
- package/dist/http/plugin-dispatch.js +124 -29
- package/dist/http/plugin-route-access.d.ts +56 -0
- package/dist/http/plugin-route-access.js +192 -0
- package/dist/identity/auth.guard.d.ts +26 -12
- package/dist/identity/auth.guard.js +62 -33
- package/dist/infra/throttler/named-throttlers.d.ts +3 -0
- package/dist/infra/throttler/named-throttlers.js +16 -0
- package/dist/infra/throttler/throttler.guard.d.ts +2 -1
- package/dist/infra/throttler/throttler.guard.js +2 -1
- package/dist/kernel.module.js +3 -0
- package/dist/local-devices/local-device-provider.d.ts +37 -1
- package/dist/local-devices/local-device-provider.js +33 -0
- package/dist/local-devices/machines.d.ts +2 -1
- package/dist/local-devices/machines.js +4 -1
- package/dist/local-devices/policy-summary.js +1 -0
- package/dist/local-devices/relay.d.ts +2 -0
- package/dist/local-devices/relay.js +3 -1
- package/dist/local-devices/targets.d.ts +6 -1
- package/dist/local-devices/targets.js +14 -0
- package/dist/overrides.d.ts +7 -0
- package/dist/overrides.js +4 -0
- package/dist/platform/ops/agent-skills.ops.js +2 -1
- package/dist/platform/ops/devices.ops.d.ts +3 -1
- package/dist/platform/ops/devices.ops.js +136 -3
- package/dist/runtime/context/build.d.ts +3 -0
- package/dist/runtime/context/build.js +14 -0
- package/dist/runtime/context/compaction.js +2 -0
- package/dist/runtime/context/project-root.d.ts +43 -0
- package/dist/runtime/context/project-root.js +85 -0
- package/dist/runtime/model-call.js +25 -1
- package/dist/runtime/project/knowledge.d.ts +129 -0
- package/dist/runtime/project/knowledge.js +248 -0
- package/dist/runtime/project/knowledge.service.d.ts +85 -0
- package/dist/runtime/project/knowledge.service.js +288 -0
- package/dist/runtime/run-worker.d.ts +5 -0
- package/dist/runtime/run-worker.js +27 -6
- package/dist/runtime/runtime.module.js +7 -0
- package/dist/sandbox/review/review.service.d.ts +14 -2
- package/dist/sandbox/review/review.service.js +2 -0
- package/dist/sandbox/review/rules.d.ts +6 -4
- package/dist/sandbox/review/rules.js +185 -62
- package/dist/sandbox/review/types.d.ts +14 -0
- package/dist/sandbox/sandbox.service.d.ts +16 -1
- package/dist/sandbox/sandbox.service.js +75 -3
- package/dist/skills/catalog.d.ts +6 -1
- package/dist/skills/catalog.js +18 -4
- package/dist/skills/invoke.d.ts +64 -2
- package/dist/skills/invoke.js +214 -6
- package/dist/skills/skills.module.js +5 -0
- package/dist/tools/approvals.service.d.ts +6 -0
- package/dist/tools/builtins/sandbox/bash.js +19 -4
- package/dist/tools/builtins/sandbox/common.d.ts +36 -6
- package/dist/tools/builtins/sandbox/common.js +69 -8
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/glob.js +3 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -1
- package/dist/tools/builtins/sandbox/read.js +3 -3
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.d.ts +47 -2
- package/dist/tools/builtins/skill-load.js +160 -2
- package/dist/tools/pipeline.d.ts +1 -1
- package/dist/tools/pipeline.js +53 -8
- package/dist/tools/registry.d.ts +6 -0
- package/package.json +3 -3
- package/src/migrations/0133_project_root.sql +30 -0
|
@@ -2,8 +2,9 @@ import type { DeviceLocalPolicySummary } from "@capybara-hq/plugin-sdk";
|
|
|
2
2
|
import type { z } from "zod";
|
|
3
3
|
import { type Principal } from "../identity/principal.js";
|
|
4
4
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
5
|
+
import { type DeviceProjectCandidates, type DeviceProjectList, DeviceProjectsService, type DeviceProjectView } from "./device-projects.service.js";
|
|
5
6
|
import { type DeviceList, DevicesService, type DeviceView } from "./devices.service.js";
|
|
6
|
-
import { type DeviceNameBody, type DeviceParams, type DevicePatchBody, type DevicePolicyBody } from "./dto.js";
|
|
7
|
+
import { type DeviceNameBody, type DeviceParams, type DevicePatchBody, type DevicePolicyBody, type DeviceProjectAddBody, type DeviceProjectParams } from "./dto.js";
|
|
7
8
|
/**
|
|
8
9
|
* A person's devices in an org (`/api/v1/orgs/:orgId/devices`, spec
|
|
9
10
|
* 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
|
|
@@ -29,10 +30,16 @@ import { type DeviceNameBody, type DeviceParams, type DevicePatchBody, type Devi
|
|
|
29
30
|
* a person changes their own machine's network policy, nothing model-driven does. Offline → 503
|
|
30
31
|
* `device.offline`; cloud or an older program → 409 `device.policy_unsupported`; the machine's
|
|
31
32
|
* refusal → 409 `device.policy_refused`.
|
|
33
|
+
* - a device's projects (project root design §4.1, §4.2), owner only (anyone else:
|
|
34
|
+
* `device.not_found`): `GET /:id/projects` → the ones its current mode can read;
|
|
35
|
+
* `GET /:id/projects/candidates` → the device's suggestions under its base;
|
|
36
|
+
* `POST /:id/projects { path, name? }` → 201 `{ project }` (path relative to the base);
|
|
37
|
+
* `DELETE /:id/projects/:name` → 204 (idempotent).
|
|
32
38
|
*/
|
|
33
39
|
export declare class DevicesController {
|
|
34
40
|
private readonly devices;
|
|
35
|
-
|
|
41
|
+
private readonly projects;
|
|
42
|
+
constructor(devices: DevicesService, projects: DeviceProjectsService);
|
|
36
43
|
list(principal: Principal, org: OrgContext): Promise<DeviceList>;
|
|
37
44
|
create(principal: Principal, org: OrgContext, body: z.infer<typeof DeviceNameBody>): Promise<{
|
|
38
45
|
device: DeviceView;
|
|
@@ -49,4 +56,10 @@ export declare class DevicesController {
|
|
|
49
56
|
changePolicy(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>, body: z.infer<typeof DevicePolicyBody>): Promise<{
|
|
50
57
|
policy: DeviceLocalPolicySummary;
|
|
51
58
|
}>;
|
|
59
|
+
listProjects(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<DeviceProjectList>;
|
|
60
|
+
projectCandidates(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>): Promise<DeviceProjectCandidates>;
|
|
61
|
+
addProject(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceParams>, body: z.infer<typeof DeviceProjectAddBody>): Promise<{
|
|
62
|
+
project: DeviceProjectView;
|
|
63
|
+
}>;
|
|
64
|
+
removeProject(principal: Principal, org: OrgContext, params: z.infer<typeof DeviceProjectParams>): Promise<void>;
|
|
52
65
|
}
|
|
@@ -12,8 +12,9 @@ import { ApiError } from "../errors.js";
|
|
|
12
12
|
import { CurrentPrincipal, patTokenId, requireUser, SessionOnly, } from "../identity/principal.js";
|
|
13
13
|
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
14
14
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
15
|
+
import { DeviceProjectsService, } from "./device-projects.service.js";
|
|
15
16
|
import { DevicesService } from "./devices.service.js";
|
|
16
|
-
import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DevicePolicyBodyDto, } from "./dto.js";
|
|
17
|
+
import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DevicePolicyBodyDto, DeviceProjectAddBodyDto, DeviceProjectParamsDto, } from "./dto.js";
|
|
17
18
|
/**
|
|
18
19
|
* A person's devices in an org (`/api/v1/orgs/:orgId/devices`, spec
|
|
19
20
|
* 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
|
|
@@ -39,11 +40,18 @@ import { DeviceCreateBodyDto, DeviceParamsDto, DevicePatchBodyDto, DevicePolicyB
|
|
|
39
40
|
* a person changes their own machine's network policy, nothing model-driven does. Offline → 503
|
|
40
41
|
* `device.offline`; cloud or an older program → 409 `device.policy_unsupported`; the machine's
|
|
41
42
|
* refusal → 409 `device.policy_refused`.
|
|
43
|
+
* - a device's projects (project root design §4.1, §4.2), owner only (anyone else:
|
|
44
|
+
* `device.not_found`): `GET /:id/projects` → the ones its current mode can read;
|
|
45
|
+
* `GET /:id/projects/candidates` → the device's suggestions under its base;
|
|
46
|
+
* `POST /:id/projects { path, name? }` → 201 `{ project }` (path relative to the base);
|
|
47
|
+
* `DELETE /:id/projects/:name` → 204 (idempotent).
|
|
42
48
|
*/
|
|
43
49
|
let DevicesController = class DevicesController {
|
|
44
50
|
devices;
|
|
45
|
-
|
|
51
|
+
projects;
|
|
52
|
+
constructor(devices, projects) {
|
|
46
53
|
this.devices = devices;
|
|
54
|
+
this.projects = projects;
|
|
47
55
|
}
|
|
48
56
|
async list(principal, org) {
|
|
49
57
|
const p = requireUser(principal);
|
|
@@ -92,6 +100,24 @@ let DevicesController = class DevicesController {
|
|
|
92
100
|
policy: await this.devices.changePolicy(org.orgId, p.account, params.id, body),
|
|
93
101
|
};
|
|
94
102
|
}
|
|
103
|
+
async listProjects(principal, org, params) {
|
|
104
|
+
const p = requireUser(principal);
|
|
105
|
+
return this.projects.list(org.orgId, p.account.id, params.id);
|
|
106
|
+
}
|
|
107
|
+
async projectCandidates(principal, org, params) {
|
|
108
|
+
const p = requireUser(principal);
|
|
109
|
+
return this.projects.candidates(org.orgId, p.account.id, params.id);
|
|
110
|
+
}
|
|
111
|
+
async addProject(principal, org, params, body) {
|
|
112
|
+
const p = requireUser(principal);
|
|
113
|
+
return {
|
|
114
|
+
project: await this.projects.add(org.orgId, p.account.id, params.id, { path: body.path, ...(body.name !== undefined && { name: body.name }) }, patTokenId(p)),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async removeProject(principal, org, params) {
|
|
118
|
+
const p = requireUser(principal);
|
|
119
|
+
await this.projects.remove(org.orgId, p.account.id, params.id, params.name, patTokenId(p));
|
|
120
|
+
}
|
|
95
121
|
};
|
|
96
122
|
__decorate([
|
|
97
123
|
Get(),
|
|
@@ -155,8 +181,39 @@ __decorate([
|
|
|
155
181
|
__param(2, ZParam(DeviceParamsDto)),
|
|
156
182
|
__param(3, ZBody(DevicePolicyBodyDto))
|
|
157
183
|
], DevicesController.prototype, "changePolicy", null);
|
|
184
|
+
__decorate([
|
|
185
|
+
Get(":id/projects"),
|
|
186
|
+
OrgAction("agents.use"),
|
|
187
|
+
__param(0, CurrentPrincipal()),
|
|
188
|
+
__param(1, CurrentOrg()),
|
|
189
|
+
__param(2, ZParam(DeviceParamsDto))
|
|
190
|
+
], DevicesController.prototype, "listProjects", null);
|
|
191
|
+
__decorate([
|
|
192
|
+
Get(":id/projects/candidates"),
|
|
193
|
+
OrgAction("agents.use"),
|
|
194
|
+
__param(0, CurrentPrincipal()),
|
|
195
|
+
__param(1, CurrentOrg()),
|
|
196
|
+
__param(2, ZParam(DeviceParamsDto))
|
|
197
|
+
], DevicesController.prototype, "projectCandidates", null);
|
|
198
|
+
__decorate([
|
|
199
|
+
Post(":id/projects"),
|
|
200
|
+
OrgAction("agents.use"),
|
|
201
|
+
__param(0, CurrentPrincipal()),
|
|
202
|
+
__param(1, CurrentOrg()),
|
|
203
|
+
__param(2, ZParam(DeviceParamsDto)),
|
|
204
|
+
__param(3, ZBody(DeviceProjectAddBodyDto))
|
|
205
|
+
], DevicesController.prototype, "addProject", null);
|
|
206
|
+
__decorate([
|
|
207
|
+
Delete(":id/projects/:name"),
|
|
208
|
+
HttpCode(204),
|
|
209
|
+
OrgAction("agents.use"),
|
|
210
|
+
__param(0, CurrentPrincipal()),
|
|
211
|
+
__param(1, CurrentOrg()),
|
|
212
|
+
__param(2, ZParam(DeviceProjectParamsDto))
|
|
213
|
+
], DevicesController.prototype, "removeProject", null);
|
|
158
214
|
DevicesController = __decorate([
|
|
159
215
|
Controller("api/v1/orgs/:orgId/devices"),
|
|
160
|
-
__param(0, Inject(DevicesService))
|
|
216
|
+
__param(0, Inject(DevicesService)),
|
|
217
|
+
__param(1, Inject(DeviceProjectsService))
|
|
161
218
|
], DevicesController);
|
|
162
219
|
export { DevicesController };
|
|
@@ -11,6 +11,7 @@ import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
|
11
11
|
import { SandboxFileReader } from "../sandbox/sandbox-file-reader.js";
|
|
12
12
|
import { DeviceAccess } from "./access.js";
|
|
13
13
|
import { ConversationDevices } from "./conversation-devices.js";
|
|
14
|
+
import { DeviceProjectsService } from "./device-projects.service.js";
|
|
14
15
|
import { DevicesService } from "./devices.service.js";
|
|
15
16
|
/**
|
|
16
17
|
* Devices (spec 2026-11-07-environments-design): a person's devices
|
|
@@ -27,8 +28,20 @@ DevicesModule = __decorate([
|
|
|
27
28
|
imports: [SandboxModule, ExtensionsModule, LocalDevicesModule],
|
|
28
29
|
// SandboxFileReader lives here, not in SandboxModule: it needs ConversationDevices, and this
|
|
29
30
|
// module already imports SandboxModule (the other way would be a module cycle)
|
|
30
|
-
providers: [
|
|
31
|
-
|
|
31
|
+
providers: [
|
|
32
|
+
DeviceAccess,
|
|
33
|
+
DevicesService,
|
|
34
|
+
ConversationDevices,
|
|
35
|
+
SandboxFileReader,
|
|
36
|
+
DeviceProjectsService,
|
|
37
|
+
],
|
|
38
|
+
exports: [
|
|
39
|
+
DeviceAccess,
|
|
40
|
+
DevicesService,
|
|
41
|
+
ConversationDevices,
|
|
42
|
+
SandboxFileReader,
|
|
43
|
+
DeviceProjectsService,
|
|
44
|
+
],
|
|
32
45
|
})
|
|
33
46
|
], DevicesModule);
|
|
34
47
|
export { DevicesModule };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DeviceNameBody, DeviceParams, DevicePatchBody } from "./dto.js";
|
|
1
|
+
import { DeviceNameBody, DeviceParams, DevicePatchBody, DeviceProjectAddBody, DeviceProjectParams, } from "./dto.js";
|
|
2
2
|
/** The body of the excluded `POST /devices/:id/policy` route (human-only). */
|
|
3
3
|
export { DevicePolicyBody } from "./dto.js";
|
|
4
4
|
/**
|
|
@@ -19,4 +19,12 @@ export const DEVICE_ROUTES = [
|
|
|
19
19
|
},
|
|
20
20
|
{ route: "DELETE /api/v1/orgs/:orgId/devices/:id", params: DeviceParams },
|
|
21
21
|
{ route: "POST /api/v1/orgs/:orgId/devices/:id/files/reset", params: DeviceParams },
|
|
22
|
+
{ route: "GET /api/v1/orgs/:orgId/devices/:id/projects", params: DeviceParams },
|
|
23
|
+
{ route: "GET /api/v1/orgs/:orgId/devices/:id/projects/candidates", params: DeviceParams },
|
|
24
|
+
{
|
|
25
|
+
route: "POST /api/v1/orgs/:orgId/devices/:id/projects",
|
|
26
|
+
params: DeviceParams,
|
|
27
|
+
body: DeviceProjectAddBody,
|
|
28
|
+
},
|
|
29
|
+
{ route: "DELETE /api/v1/orgs/:orgId/devices/:id/projects/:name", params: DeviceProjectParams },
|
|
22
30
|
];
|
package/dist/devices/dto.d.ts
CHANGED
|
@@ -29,6 +29,25 @@ export declare const DevicePolicyBody: z.ZodObject<{
|
|
|
29
29
|
remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
30
|
mode: z.ZodOptional<z.ZodLiteral<"sandbox">>;
|
|
31
31
|
}, z.core.$strict>;
|
|
32
|
+
/**
|
|
33
|
+
* A project's name (project root §4.1, `isDeviceProjectName`): 1-64 UTF-16 code units, not `.` or
|
|
34
|
+
* `..`, no `/`, no control characters, no leading or trailing whitespace; unique on its device.
|
|
35
|
+
*/
|
|
36
|
+
export declare const DeviceProjectName: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
37
|
+
/**
|
|
38
|
+
* `POST /devices/:id/projects`: `path` is relative to the device's base in its current mode (the
|
|
39
|
+
* workspace in sandbox mode and on a cloud device, the owner's home in auto mode; empty or `.`:
|
|
40
|
+
* the base itself), never absolute; `name` defaults to the directory's basename.
|
|
41
|
+
*/
|
|
42
|
+
export declare const DeviceProjectAddBody: z.ZodObject<{
|
|
43
|
+
path: z.ZodString;
|
|
44
|
+
name: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
/** `DELETE /devices/:id/projects/:name`. */
|
|
47
|
+
export declare const DeviceProjectParams: z.ZodObject<{
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
name: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
32
51
|
declare const DeviceCreateBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
33
52
|
name: z.ZodString;
|
|
34
53
|
}, z.core.$strict>>;
|
|
@@ -52,4 +71,16 @@ declare const DevicePolicyBodyDto_base: import("../infra/validation/create-zod-d
|
|
|
52
71
|
}, z.core.$strict>>;
|
|
53
72
|
export declare class DevicePolicyBodyDto extends DevicePolicyBodyDto_base {
|
|
54
73
|
}
|
|
74
|
+
declare const DeviceProjectAddBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
75
|
+
path: z.ZodString;
|
|
76
|
+
name: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
|
77
|
+
}, z.core.$strict>>;
|
|
78
|
+
export declare class DeviceProjectAddBodyDto extends DeviceProjectAddBodyDto_base {
|
|
79
|
+
}
|
|
80
|
+
declare const DeviceProjectParamsDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
81
|
+
id: z.ZodString;
|
|
82
|
+
name: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
export declare class DeviceProjectParamsDto extends DeviceProjectParamsDto_base {
|
|
85
|
+
}
|
|
55
86
|
export {};
|
package/dist/devices/dto.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateAllowHost } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { isDeviceProjectName, MAX_DEVICE_PROJECT_NAME_LENGTH, validateAllowHost, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
4
4
|
import { publicSuffixWildcard } from "./public-suffix.js";
|
|
@@ -49,6 +49,39 @@ export const DevicePolicyBody = z
|
|
|
49
49
|
.refine((b) => b.add !== undefined || b.remove !== undefined || b.mode !== undefined, {
|
|
50
50
|
message: "Give at least one of add, remove or mode",
|
|
51
51
|
});
|
|
52
|
+
/**
|
|
53
|
+
* A project's name (project root §4.1, `isDeviceProjectName`): 1-64 UTF-16 code units, not `.` or
|
|
54
|
+
* `..`, no `/`, no control characters, no leading or trailing whitespace; unique on its device.
|
|
55
|
+
*/
|
|
56
|
+
export const DeviceProjectName = z
|
|
57
|
+
.string()
|
|
58
|
+
.max(MAX_DEVICE_PROJECT_NAME_LENGTH)
|
|
59
|
+
.refine(isDeviceProjectName, {
|
|
60
|
+
message: "A project name is 1-64 characters, not . or .., without / or control characters, and without leading or trailing spaces",
|
|
61
|
+
});
|
|
62
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it refuses
|
|
63
|
+
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
64
|
+
/**
|
|
65
|
+
* `POST /devices/:id/projects`: `path` is relative to the device's base in its current mode (the
|
|
66
|
+
* workspace in sandbox mode and on a cloud device, the owner's home in auto mode; empty or `.`:
|
|
67
|
+
* the base itself), never absolute; `name` defaults to the directory's basename.
|
|
68
|
+
*/
|
|
69
|
+
export const DeviceProjectAddBody = z
|
|
70
|
+
.object({
|
|
71
|
+
path: z
|
|
72
|
+
.string()
|
|
73
|
+
.max(4096)
|
|
74
|
+
.refine((p) => !p.startsWith("/"), {
|
|
75
|
+
message: "Give the path relative to the device's base, not an absolute path",
|
|
76
|
+
})
|
|
77
|
+
.refine((p) => !CONTROL.test(p) && !p.includes("\\"), {
|
|
78
|
+
message: "The path must not contain control characters or backslashes",
|
|
79
|
+
}),
|
|
80
|
+
name: DeviceProjectName.optional(),
|
|
81
|
+
})
|
|
82
|
+
.strict();
|
|
83
|
+
/** `DELETE /devices/:id/projects/:name`. */
|
|
84
|
+
export const DeviceProjectParams = DeviceParams.extend({ name: DeviceProjectName });
|
|
52
85
|
export class DeviceCreateBodyDto extends createZodDto(DeviceNameBody, "DeviceCreateBody") {
|
|
53
86
|
}
|
|
54
87
|
export class DevicePatchBodyDto extends createZodDto(DevicePatchBody, "DevicePatchBody") {
|
|
@@ -57,3 +90,7 @@ export class DeviceParamsDto extends createZodDto(DeviceParams, "DeviceParams")
|
|
|
57
90
|
}
|
|
58
91
|
export class DevicePolicyBodyDto extends createZodDto(DevicePolicyBody, "DevicePolicyBody") {
|
|
59
92
|
}
|
|
93
|
+
export class DeviceProjectAddBodyDto extends createZodDto(DeviceProjectAddBody, "DeviceProjectAddBody") {
|
|
94
|
+
}
|
|
95
|
+
export class DeviceProjectParamsDto extends createZodDto(DeviceProjectParams, "DeviceProjectParams") {
|
|
96
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { SandboxMode } from "../sandbox/modes.js";
|
|
2
|
+
/**
|
|
3
|
+
* What decides a conversation's working root (project root spec §4.3): the latest `project_root`
|
|
4
|
+
* event of its root conversation (sub-agents inherit their root's binding). Null: the conversation
|
|
5
|
+
* is free, or no run of it has recorded a snapshot yet (a bound conversation before its first run
|
|
6
|
+
* start, an older log).
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkingProject {
|
|
9
|
+
/** The project's root on the device, as the event recorded it. */
|
|
10
|
+
root: string;
|
|
11
|
+
/** The event says the run cannot use the project (`unavailable` set). */
|
|
12
|
+
unavailable: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A root above the owner's home: `/`, every ancestor of the reported `home` (`/var/lib` for
|
|
16
|
+
* `/var/lib/u`), and `/home` / `/Users` whatever the home and in any case (a macOS volume is
|
|
17
|
+
* case-insensitive: `/users` is `/Users`). Too broad to be the review's workspace
|
|
18
|
+
* (other users' files would be ordinary writes), so it is never the working root. The owner's home
|
|
19
|
+
* itself may be: the review judges its home-level sensitive paths (shell rc files, SSH,
|
|
20
|
+
* credentials) inside the workspace too.
|
|
21
|
+
*/
|
|
22
|
+
export declare function aboveHome(root: string, home: string | null | undefined): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The working root of a conversation (project root spec §4.3): the directory `Bash` runs in, where
|
|
25
|
+
* `Glob` and `Grep` search by default, what a relative file-tool path resolves against, and the
|
|
26
|
+
* command review's `workspace` fact. It is the project's root when the latest snapshot is usable,
|
|
27
|
+
* else the device's `workspace` (free mode). It never widens anything: a root that is not a clean
|
|
28
|
+
* absolute path, one the run cannot use, one outside the workspace in sandbox mode (where the
|
|
29
|
+
* device reads nothing else), and one above the owner's home ({@link aboveHome}) all fall back
|
|
30
|
+
* to the device's workspace.
|
|
31
|
+
*/
|
|
32
|
+
export declare function workingRootOf(project: WorkingProject | null | undefined, device: {
|
|
33
|
+
mode: SandboxMode;
|
|
34
|
+
workspace: string;
|
|
35
|
+
home?: string | null;
|
|
36
|
+
}): string;
|
|
37
|
+
/**
|
|
38
|
+
* A file-tool path as the command review judged it, for the person approving it: a relative path
|
|
39
|
+
* joined to the working root and normalized; an absolute or `~` path as given.
|
|
40
|
+
*/
|
|
41
|
+
export declare function pathAgainstWorkingRoot(path: string, workingRoot: string): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import { validateSandboxPathShape } from "@capybara-hq/plugin-sdk";
|
|
3
|
+
/** The fixed parents of home directories, lower-cased (compared case-insensitively). */
|
|
4
|
+
const HOME_PARENTS = new Set(["/home", "/users"]);
|
|
5
|
+
/**
|
|
6
|
+
* A root above the owner's home: `/`, every ancestor of the reported `home` (`/var/lib` for
|
|
7
|
+
* `/var/lib/u`), and `/home` / `/Users` whatever the home and in any case (a macOS volume is
|
|
8
|
+
* case-insensitive: `/users` is `/Users`). Too broad to be the review's workspace
|
|
9
|
+
* (other users' files would be ordinary writes), so it is never the working root. The owner's home
|
|
10
|
+
* itself may be: the review judges its home-level sensitive paths (shell rc files, SSH,
|
|
11
|
+
* credentials) inside the workspace too.
|
|
12
|
+
*/
|
|
13
|
+
export function aboveHome(root, home) {
|
|
14
|
+
if (root === "/" || HOME_PARENTS.has(root.toLowerCase()))
|
|
15
|
+
return true;
|
|
16
|
+
return home != null && home !== root && isInside(home, root);
|
|
17
|
+
}
|
|
18
|
+
const isInside = (path, dir) => path === dir || path.startsWith(dir === "/" ? "/" : `${dir}/`);
|
|
19
|
+
/**
|
|
20
|
+
* The working root of a conversation (project root spec §4.3): the directory `Bash` runs in, where
|
|
21
|
+
* `Glob` and `Grep` search by default, what a relative file-tool path resolves against, and the
|
|
22
|
+
* command review's `workspace` fact. It is the project's root when the latest snapshot is usable,
|
|
23
|
+
* else the device's `workspace` (free mode). It never widens anything: a root that is not a clean
|
|
24
|
+
* absolute path, one the run cannot use, one outside the workspace in sandbox mode (where the
|
|
25
|
+
* device reads nothing else), and one above the owner's home ({@link aboveHome}) all fall back
|
|
26
|
+
* to the device's workspace.
|
|
27
|
+
*/
|
|
28
|
+
export function workingRootOf(project, device) {
|
|
29
|
+
if (project == null || project.unavailable)
|
|
30
|
+
return device.workspace;
|
|
31
|
+
const root = project.root.length > 1 && project.root.endsWith("/")
|
|
32
|
+
? project.root.slice(0, -1)
|
|
33
|
+
: project.root;
|
|
34
|
+
if (validateSandboxPathShape(root).length > 0)
|
|
35
|
+
return device.workspace;
|
|
36
|
+
if (device.mode !== "auto" && !isInside(root, device.workspace))
|
|
37
|
+
return device.workspace;
|
|
38
|
+
if (aboveHome(root, device.home))
|
|
39
|
+
return device.workspace;
|
|
40
|
+
return root;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A file-tool path as the command review judged it, for the person approving it: a relative path
|
|
44
|
+
* joined to the working root and normalized; an absolute or `~` path as given.
|
|
45
|
+
*/
|
|
46
|
+
export function pathAgainstWorkingRoot(path, workingRoot) {
|
|
47
|
+
if (path.startsWith("/") || path.startsWith("~") || path === "")
|
|
48
|
+
return path;
|
|
49
|
+
return posix.normalize(posix.join(workingRoot, path));
|
|
50
|
+
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -391,6 +391,37 @@ export declare const ERROR_CODES: {
|
|
|
391
391
|
* only its owner in a web session changes it (hardening spec D2, K4).
|
|
392
392
|
*/
|
|
393
393
|
readonly "device.mode_requires_session": 403;
|
|
394
|
+
/**
|
|
395
|
+
* The device offers no projects (project root §4.1): its `capybara-device` does not announce
|
|
396
|
+
* `projects` (update it), or its cloud sandbox provider has no `list` / `scan`.
|
|
397
|
+
*/
|
|
398
|
+
readonly "device.projects_unsupported": 409;
|
|
399
|
+
/** The device could not be asked about its directories now; the message says why. */
|
|
400
|
+
readonly "device.projects_unavailable": 503;
|
|
401
|
+
/** Not a valid project name (1-64 characters, no `/`, no control characters, not `.` / `..`). */
|
|
402
|
+
readonly "device.project_name_invalid": 422;
|
|
403
|
+
/** The device already has a project with this name. */
|
|
404
|
+
readonly "device.project_name_taken": 409;
|
|
405
|
+
/** The device already has the most projects allowed (100). */
|
|
406
|
+
readonly "device.project_limit_reached": 409;
|
|
407
|
+
/** The device has no project with this name. */
|
|
408
|
+
readonly "device.project_not_found": 404;
|
|
409
|
+
/**
|
|
410
|
+
* The project's path is outside what the device may read in its current mode (sandbox mode and
|
|
411
|
+
* cloud devices: the workspace; project root §4.2).
|
|
412
|
+
*/
|
|
413
|
+
readonly "device.project_outside_mode": 422;
|
|
414
|
+
/** Auto mode resolves a relative path against the owner's home, which the device has not reported. */
|
|
415
|
+
readonly "device.project_home_unknown": 409;
|
|
416
|
+
/**
|
|
417
|
+
* The project's path lies above the owner's home (`/`, `/home`, `/Users`, an ancestor of the
|
|
418
|
+
* reported home): too broad to be a project.
|
|
419
|
+
*/
|
|
420
|
+
readonly "device.project_path_too_broad": 422;
|
|
421
|
+
/** The project's directory does not exist on the device. */
|
|
422
|
+
readonly "device.project_path_missing": 422;
|
|
423
|
+
/** The project's path is a file, cannot be read, or the device refused it in its current mode. */
|
|
424
|
+
readonly "device.project_path_unreadable": 422;
|
|
394
425
|
/** Device sign-in (RFC 8628 style): the person has not approved the code yet; keep polling. */
|
|
395
426
|
readonly "device_sign_in.authorization_pending": 400;
|
|
396
427
|
/** Device sign-in: the program polls faster than the interval; add 5 seconds and keep polling. */
|
|
@@ -443,6 +474,14 @@ export declare const ERROR_CODES: {
|
|
|
443
474
|
* (`details: [{ reason: "not_found" }]`) or is hidden from the menu (`not_user_invocable`).
|
|
444
475
|
*/
|
|
445
476
|
readonly "skill.not_invocable": 400;
|
|
477
|
+
/**
|
|
478
|
+
* A person's `/project:<name>`: the conversation's project lists the skill but it cannot be used
|
|
479
|
+
* now (project root spec §4.6, §4.7). `details: [{ reason }]`: `gone` (the project or its
|
|
480
|
+
* SKILL.md is no longer on the device), `outside_mode` (the device's current mode cannot read
|
|
481
|
+
* it), `unreadable` (the read failed), `unparsable` (not a valid SKILL.md), `unsupported` (the
|
|
482
|
+
* device offers no projects). Never sent as text instead: the person is told.
|
|
483
|
+
*/
|
|
484
|
+
readonly "skill.project_unavailable": 422;
|
|
446
485
|
/**
|
|
447
486
|
* Uploading or sharing a skill: an org-level skill with this name already exists in the org
|
|
448
487
|
* (P3-24, F18).
|
package/dist/errors.js
CHANGED
|
@@ -391,6 +391,37 @@ export const ERROR_CODES = {
|
|
|
391
391
|
* only its owner in a web session changes it (hardening spec D2, K4).
|
|
392
392
|
*/
|
|
393
393
|
"device.mode_requires_session": 403,
|
|
394
|
+
/**
|
|
395
|
+
* The device offers no projects (project root §4.1): its `capybara-device` does not announce
|
|
396
|
+
* `projects` (update it), or its cloud sandbox provider has no `list` / `scan`.
|
|
397
|
+
*/
|
|
398
|
+
"device.projects_unsupported": 409,
|
|
399
|
+
/** The device could not be asked about its directories now; the message says why. */
|
|
400
|
+
"device.projects_unavailable": 503,
|
|
401
|
+
/** Not a valid project name (1-64 characters, no `/`, no control characters, not `.` / `..`). */
|
|
402
|
+
"device.project_name_invalid": 422,
|
|
403
|
+
/** The device already has a project with this name. */
|
|
404
|
+
"device.project_name_taken": 409,
|
|
405
|
+
/** The device already has the most projects allowed (100). */
|
|
406
|
+
"device.project_limit_reached": 409,
|
|
407
|
+
/** The device has no project with this name. */
|
|
408
|
+
"device.project_not_found": 404,
|
|
409
|
+
/**
|
|
410
|
+
* The project's path is outside what the device may read in its current mode (sandbox mode and
|
|
411
|
+
* cloud devices: the workspace; project root §4.2).
|
|
412
|
+
*/
|
|
413
|
+
"device.project_outside_mode": 422,
|
|
414
|
+
/** Auto mode resolves a relative path against the owner's home, which the device has not reported. */
|
|
415
|
+
"device.project_home_unknown": 409,
|
|
416
|
+
/**
|
|
417
|
+
* The project's path lies above the owner's home (`/`, `/home`, `/Users`, an ancestor of the
|
|
418
|
+
* reported home): too broad to be a project.
|
|
419
|
+
*/
|
|
420
|
+
"device.project_path_too_broad": 422,
|
|
421
|
+
/** The project's directory does not exist on the device. */
|
|
422
|
+
"device.project_path_missing": 422,
|
|
423
|
+
/** The project's path is a file, cannot be read, or the device refused it in its current mode. */
|
|
424
|
+
"device.project_path_unreadable": 422,
|
|
394
425
|
/** Device sign-in (RFC 8628 style): the person has not approved the code yet; keep polling. */
|
|
395
426
|
"device_sign_in.authorization_pending": 400,
|
|
396
427
|
/** Device sign-in: the program polls faster than the interval; add 5 seconds and keep polling. */
|
|
@@ -443,6 +474,14 @@ export const ERROR_CODES = {
|
|
|
443
474
|
* (`details: [{ reason: "not_found" }]`) or is hidden from the menu (`not_user_invocable`).
|
|
444
475
|
*/
|
|
445
476
|
"skill.not_invocable": 400,
|
|
477
|
+
/**
|
|
478
|
+
* A person's `/project:<name>`: the conversation's project lists the skill but it cannot be used
|
|
479
|
+
* now (project root spec §4.6, §4.7). `details: [{ reason }]`: `gone` (the project or its
|
|
480
|
+
* SKILL.md is no longer on the device), `outside_mode` (the device's current mode cannot read
|
|
481
|
+
* it), `unreadable` (the read failed), `unparsable` (not a valid SKILL.md), `unsupported` (the
|
|
482
|
+
* device offers no projects). Never sent as text instead: the person is told.
|
|
483
|
+
*/
|
|
484
|
+
"skill.project_unavailable": 422,
|
|
446
485
|
/**
|
|
447
486
|
* Uploading or sharing a skill: an org-level skill with this name already exists in the org
|
|
448
487
|
* (P3-24, F18).
|
|
@@ -132,11 +132,19 @@ export interface ReplaySeed {
|
|
|
132
132
|
plugin: string;
|
|
133
133
|
};
|
|
134
134
|
}[];
|
|
135
|
+
/**
|
|
136
|
+
* The original run's `project_root` event (project root spec §5), copied as is: a candidate sees
|
|
137
|
+
* the project as the original run read it; replays never read a device.
|
|
138
|
+
*/
|
|
139
|
+
projectRoot: {
|
|
140
|
+
payload: unknown;
|
|
141
|
+
} | undefined;
|
|
135
142
|
}
|
|
136
143
|
/**
|
|
137
144
|
* The seed of a full-run replay (C6): the `kind = 'eval'` conversation with the events before the
|
|
138
145
|
* original run at their original seqs, the run row and its `run_started` (and the original
|
|
139
|
-
* `skills_catalog`, `run_context` and `
|
|
146
|
+
* `skills_catalog`, `run_context`, `plugin_context` and `project_root` events), in one transaction
|
|
147
|
+
* of its own.
|
|
140
148
|
*/
|
|
141
149
|
export declare class EvalReplaySeeder {
|
|
142
150
|
private readonly db;
|
package/dist/evals/run-replay.js
CHANGED
|
@@ -22,6 +22,7 @@ import { pluginContextIdemKey } from "../runtime/context/plugin-context.js";
|
|
|
22
22
|
import { estimateTokens } from "../runtime/context/tokens.js";
|
|
23
23
|
import { runDeadline, tightestLimit } from "../runtime/limits.js";
|
|
24
24
|
import { RunError } from "../runtime/model-call.js";
|
|
25
|
+
import { projectRootIdemKey } from "../runtime/project/knowledge.js";
|
|
25
26
|
import { runContextIdemKey } from "../runtime/run-context.service.js";
|
|
26
27
|
import { recordedSkillForks } from "../runtime/subagents/skill-fork.js";
|
|
27
28
|
import { skillsCatalogIdemKey } from "../skills/catalog.js";
|
|
@@ -37,7 +38,8 @@ export class ReplayClaimLost extends Error {
|
|
|
37
38
|
/**
|
|
38
39
|
* The seed of a full-run replay (C6): the `kind = 'eval'` conversation with the events before the
|
|
39
40
|
* original run at their original seqs, the run row and its `run_started` (and the original
|
|
40
|
-
* `skills_catalog`, `run_context` and `
|
|
41
|
+
* `skills_catalog`, `run_context`, `plugin_context` and `project_root` events), in one transaction
|
|
42
|
+
* of its own.
|
|
41
43
|
*/
|
|
42
44
|
let EvalReplaySeeder = class EvalReplaySeeder {
|
|
43
45
|
db;
|
|
@@ -141,6 +143,16 @@ let EvalReplaySeeder = class EvalReplaySeeder {
|
|
|
141
143
|
idemKey: pluginContextIdemKey(runId, c.payload.plugin),
|
|
142
144
|
payload: c.payload,
|
|
143
145
|
})),
|
|
146
|
+
...(p.projectRoot
|
|
147
|
+
? [
|
|
148
|
+
{
|
|
149
|
+
type: "project_root",
|
|
150
|
+
runId,
|
|
151
|
+
idemKey: projectRootIdemKey(runId),
|
|
152
|
+
payload: p.projectRoot.payload,
|
|
153
|
+
},
|
|
154
|
+
]
|
|
155
|
+
: []),
|
|
144
156
|
]);
|
|
145
157
|
if (onSeeded && !(await onSeeded(conversationId)))
|
|
146
158
|
throw new ReplayClaimLost();
|
|
@@ -344,6 +356,7 @@ export async function replayRun(d, s, candidate, evalRunId, signal) {
|
|
|
344
356
|
const pluginContexts = s.events
|
|
345
357
|
.filter((e) => e.runId === s.runId && e.type === "plugin_context" && e.seq > R)
|
|
346
358
|
.map((e) => ({ payload: e.payload }));
|
|
359
|
+
const projectRoot = s.events.find((e) => e.runId === s.runId && e.type === "project_root" && e.seq > R);
|
|
347
360
|
// a sub-agent's case (spec §15.3) runs the effective definition frozen in its subagent_started
|
|
348
361
|
// (the request renders that event's preamble and instructions; its tools come from it too), with
|
|
349
362
|
// only the candidate's model and params, and the logged step limit
|
|
@@ -381,6 +394,7 @@ export async function replayRun(d, s, candidate, evalRunId, signal) {
|
|
|
381
394
|
catalog,
|
|
382
395
|
runContext,
|
|
383
396
|
pluginContexts,
|
|
397
|
+
projectRoot,
|
|
384
398
|
}, d.onSeeded);
|
|
385
399
|
await d.hooks?.afterRunSeeded?.(evalRunId, conversationId);
|
|
386
400
|
// 停止:取消 / 越限 / 熔断 / 失去认领 / 截止时间 → 中止 loop(进行中的请求立即停下,loop 以 aborted 返回)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ExtensionManifest, ExtensionPermissions } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import type { ExtensionManifest, ExtensionPermissions, HttpAccess } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
/** 一个配置字段:点路径(根即叶子时为空串)与是否密钥。 */
|
|
3
3
|
export interface PermissionConfigField {
|
|
4
4
|
path: string;
|
|
@@ -25,7 +25,7 @@ export interface PermissionSet {
|
|
|
25
25
|
http: {
|
|
26
26
|
method: string;
|
|
27
27
|
path: string;
|
|
28
|
-
|
|
28
|
+
access: HttpAccess;
|
|
29
29
|
}[];
|
|
30
30
|
tools: string[];
|
|
31
31
|
hooks: string[];
|
|
@@ -107,10 +107,11 @@ export declare function buildPermissionSet(input: {
|
|
|
107
107
|
warningsDigest?: string | undefined;
|
|
108
108
|
}): PermissionSet;
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
111
|
-
* `
|
|
112
|
-
* `permissions.
|
|
113
|
-
*
|
|
110
|
+
* The stable string keys of a permission set (sorted), such as `provides:channel@1`,
|
|
111
|
+
* `config.org.secret:apiKey`, `table:todos`, `permissions.tools:write`,
|
|
112
|
+
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
113
|
+
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`.
|
|
114
|
+
* Tolerates old snapshots missing fields (read as empty), so format changes never throw.
|
|
114
115
|
*/
|
|
115
116
|
export declare function permissionKeys(set: PermissionSet): string[];
|
|
116
117
|
/**
|
|
@@ -95,7 +95,7 @@ export function buildPermissionSet(input) {
|
|
|
95
95
|
secrets: p.secrets === true,
|
|
96
96
|
storage: p.storage === true,
|
|
97
97
|
http: (p.http ?? [])
|
|
98
|
-
.map((r) => ({ method: r.method, path: r.path,
|
|
98
|
+
.map((r) => ({ method: r.method, path: r.path, access: r.access }))
|
|
99
99
|
.sort((a, b) => cmp(`${a.method} ${a.path}`, `${b.method} ${b.path}`)),
|
|
100
100
|
tools: sortedUnique(p.tools),
|
|
101
101
|
hooks: sortedUnique(p.hooks),
|
|
@@ -122,10 +122,11 @@ export function buildPermissionSet(input) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
*
|
|
126
|
-
* `
|
|
127
|
-
* `permissions.
|
|
128
|
-
*
|
|
125
|
+
* The stable string keys of a permission set (sorted), such as `provides:channel@1`,
|
|
126
|
+
* `config.org.secret:apiKey`, `table:todos`, `permissions.tools:write`,
|
|
127
|
+
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
128
|
+
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`.
|
|
129
|
+
* Tolerates old snapshots missing fields (read as empty), so format changes never throw.
|
|
129
130
|
*/
|
|
130
131
|
export function permissionKeys(set) {
|
|
131
132
|
const s = (set ?? {});
|
|
@@ -149,7 +150,9 @@ export function permissionKeys(set) {
|
|
|
149
150
|
if (p.storage)
|
|
150
151
|
keys.push("permissions.storage");
|
|
151
152
|
for (const r of p.http ?? []) {
|
|
152
|
-
|
|
153
|
+
// a snapshot from before route access has no `access`: its key matches no current key, so the
|
|
154
|
+
// extension waits for re-approval
|
|
155
|
+
keys.push(`permissions.http${r.access ? `.${r.access}` : ""}:${r.method} ${r.path}`);
|
|
153
156
|
}
|
|
154
157
|
for (const t of p.tools ?? [])
|
|
155
158
|
keys.push(`permissions.tools:${t}`);
|