@capybara-hq/kernel 0.1.0-rc.32 → 0.1.0-rc.34
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/bootstrap.json +3 -3
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/requests.service.d.ts +8 -6
- package/dist/catalog/requests.service.js +52 -29
- 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/config/schema.d.ts +4 -0
- package/dist/config/schema.js +7 -1
- 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/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/devices.service.js +8 -4
- 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/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/network-grants.d.ts +1 -1
- package/dist/local-devices/network-grants.js +2 -3
- 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/orgs/settings.controller.d.ts +3 -1
- package/dist/orgs/settings.controller.js +7 -3
- package/dist/orgs/settings.service.d.ts +78 -31
- package/dist/orgs/settings.service.js +109 -52
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -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/platform/ops/org-settings.ops.js +20 -10
- 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/modes.d.ts +31 -19
- package/dist/sandbox/modes.js +43 -24
- 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 +20 -2
- package/dist/sandbox/sandbox.service.js +86 -3
- package/dist/schedules/grant-rules.d.ts +2 -0
- package/dist/schedules/grant-rules.js +3 -1
- package/dist/schedules/schedule-math.js +21 -2
- package/dist/schedules/scheduled-tasks.service.js +3 -1
- 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/network-asks.d.ts +7 -0
- package/dist/tools/network-asks.js +11 -1
- package/dist/tools/pipeline.d.ts +1 -1
- package/dist/tools/pipeline.js +60 -9
- package/dist/tools/registry.d.ts +6 -0
- package/package.json +2 -2
- package/src/migrations/0133_project_root.sql +30 -0
- package/src/migrations/0134_org_cloud_network_delta.sql +38 -0
|
@@ -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
|
];
|
|
@@ -1043,16 +1043,20 @@ killSwitch = false) {
|
|
|
1043
1043
|
const networkKind = local ? "allowlist" : policy.network.kind;
|
|
1044
1044
|
const org = settings.cloudNetwork;
|
|
1045
1045
|
// "org" only when the org supplied what is in effect: the kill switch always wins; auto mode
|
|
1046
|
-
// ignores the org's network; a local device's list is the org's only when the org
|
|
1047
|
-
// a sandbox cloud device's kind is the org's when it
|
|
1046
|
+
// ignores the org's network; a local device's list is the org's only when the org changed the
|
|
1047
|
+
// platform's (its own base or a delta); a sandbox cloud device's kind is the org's when it
|
|
1048
|
+
// matches the mode the org chose (the platform ceiling may force the allowlist)
|
|
1049
|
+
const orgHosts = org?.base === "none" ||
|
|
1050
|
+
(org?.extraHosts?.length ?? 0) > 0 ||
|
|
1051
|
+
(org?.excludedHosts?.length ?? 0) > 0;
|
|
1048
1052
|
const source = killSwitch
|
|
1049
1053
|
? "platform"
|
|
1050
1054
|
: local
|
|
1051
|
-
? policy.mode === "sandbox" &&
|
|
1055
|
+
? policy.mode === "sandbox" && orgHosts
|
|
1052
1056
|
? "org"
|
|
1053
1057
|
: "platform"
|
|
1054
1058
|
: policy.mode === "sandbox" &&
|
|
1055
|
-
org !== undefined &&
|
|
1059
|
+
org?.mode !== undefined &&
|
|
1056
1060
|
(org.mode === "open" ? networkKind === "open-public" : networkKind === "allowlist")
|
|
1057
1061
|
? "org"
|
|
1058
1062
|
: "platform";
|
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,5 @@
|
|
|
1
1
|
import type { ExecResult, FileSystemHandle, SandboxHandle, SandboxLimits, SandboxProvider, SandboxRoots } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { ApiError } from "../errors.js";
|
|
2
3
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
4
|
import type { KernelLogger } from "../log.js";
|
|
4
5
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
@@ -17,6 +18,11 @@ export declare const OP_DEADLINE_MS = 30000;
|
|
|
17
18
|
export declare const FRAME_ENVELOPE_BYTES: number;
|
|
18
19
|
/** The most raw bytes whose base64 plus {@link FRAME_ENVELOPE_BYTES} fit in `maxFrameBytes`. */
|
|
19
20
|
export declare const maxReadBytes: (maxFrameBytes: number) => number;
|
|
21
|
+
/**
|
|
22
|
+
* The device offers no projects (project root §4.1): a local machine whose `capybara-device`
|
|
23
|
+
* does not announce `projects`, or a cloud provider without `list` / `scan`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const projectsUnsupported: (local: boolean) => ApiError;
|
|
20
26
|
/**
|
|
21
27
|
* The refusal of a command on a machine whose local policy is auto mode while the organization (or
|
|
22
28
|
* the platform) allows only sandbox mode (auto mode spec §4.3): re-checked at every exec, so a
|
|
@@ -54,7 +60,7 @@ export declare class LocalDeviceProvider implements SandboxProvider {
|
|
|
54
60
|
private readonly log;
|
|
55
61
|
readonly concurrentExec: true;
|
|
56
62
|
readonly sessionIsolation = false;
|
|
57
|
-
constructor(relay: LocalDeviceRelay, targets: Pick<DeviceTargets, "orgOf" | "machineRoots">, sandbox: Pick<SandboxService, "devicePolicy" | "deviceLimits">, config: Pick<KernelConfigService, "get">, grants: Pick<NetworkGrants, "forExec" | "reportedMode">, log: Pick<KernelLogger, "warn">);
|
|
63
|
+
constructor(relay: LocalDeviceRelay, targets: Pick<DeviceTargets, "orgOf" | "machineRoots" | "machineFeatures">, sandbox: Pick<SandboxService, "devicePolicy" | "deviceLimits">, config: Pick<KernelConfigService, "get">, grants: Pick<NetworkGrants, "forExec" | "reportedMode">, log: Pick<KernelLogger, "warn">);
|
|
58
64
|
createFileSystem(args: {
|
|
59
65
|
name: string;
|
|
60
66
|
limits: SandboxLimits;
|
|
@@ -106,6 +112,36 @@ export declare class LocalDeviceProvider implements SandboxProvider {
|
|
|
106
112
|
size: number;
|
|
107
113
|
isDir: boolean;
|
|
108
114
|
} | null>;
|
|
115
|
+
/**
|
|
116
|
+
* Lists one directory on the machine (the `list` op, project root §4.1), read in the mode the
|
|
117
|
+
* kernel's current ceiling gives. A machine that did not announce `projects` throws
|
|
118
|
+
* `device.projects_unsupported` (never null, which would read as "does not exist").
|
|
119
|
+
*/
|
|
120
|
+
list(h: SandboxHandle, path: string, opts: {
|
|
121
|
+
limit: number;
|
|
122
|
+
limits: Pick<SandboxLimits, "mode">;
|
|
123
|
+
signal: AbortSignal;
|
|
124
|
+
}): Promise<{
|
|
125
|
+
entries: {
|
|
126
|
+
name: string;
|
|
127
|
+
isDir: boolean;
|
|
128
|
+
}[];
|
|
129
|
+
truncated: boolean;
|
|
130
|
+
} | null>;
|
|
131
|
+
/**
|
|
132
|
+
* Looks for project-like directories under `base` on the machine (the `scan` op, project root
|
|
133
|
+
* §4.1), read in the mode the kernel's current ceiling gives. A machine that did not announce
|
|
134
|
+
* `projects` throws `device.projects_unsupported`.
|
|
135
|
+
*/
|
|
136
|
+
scan(h: SandboxHandle, base: string, opts: {
|
|
137
|
+
limits: Pick<SandboxLimits, "mode">;
|
|
138
|
+
signal: AbortSignal;
|
|
139
|
+
}): Promise<{
|
|
140
|
+
path: string;
|
|
141
|
+
suggestedName: string;
|
|
142
|
+
}[]>;
|
|
143
|
+
/** The kernel never sends `list` or `scan` to a machine that did not announce `projects`. */
|
|
144
|
+
private requireProjects;
|
|
109
145
|
/**
|
|
110
146
|
* The device's org and the limits of one exec now (ruling R27): the effective policy's
|
|
111
147
|
* `allowedMode` and the sandbox-mode allowlist. A deleted device is not found. A machine whose
|
|
@@ -28,6 +28,13 @@ export const FRAME_ENVELOPE_BYTES = 64 * 1024;
|
|
|
28
28
|
/** The most raw bytes whose base64 plus {@link FRAME_ENVELOPE_BYTES} fit in `maxFrameBytes`. */
|
|
29
29
|
export const maxReadBytes = (maxFrameBytes) => Math.max(0, Math.floor((maxFrameBytes - FRAME_ENVELOPE_BYTES) / 4) * 3);
|
|
30
30
|
const NAME_PREFIX = "cap-device-";
|
|
31
|
+
/**
|
|
32
|
+
* The device offers no projects (project root §4.1): a local machine whose `capybara-device`
|
|
33
|
+
* does not announce `projects`, or a cloud provider without `list` / `scan`.
|
|
34
|
+
*/
|
|
35
|
+
export const projectsUnsupported = (local) => new ApiError("device.projects_unsupported", local
|
|
36
|
+
? "This device's capybara-device does not support projects; update capybara-device on that machine and reconnect it."
|
|
37
|
+
: "This device's sandbox provider does not support projects; its conversations work without one.");
|
|
31
38
|
/**
|
|
32
39
|
* The refusal of a command on a machine whose local policy is auto mode while the organization (or
|
|
33
40
|
* the platform) allows only sandbox mode (auto mode spec §4.3): re-checked at every exec, so a
|
|
@@ -167,6 +174,32 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
167
174
|
async stat(h, path, signal) {
|
|
168
175
|
return this.relay.call(h.id, "stat", { path }, { deadlineMs: OP_DEADLINE_MS, signal });
|
|
169
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Lists one directory on the machine (the `list` op, project root §4.1), read in the mode the
|
|
179
|
+
* kernel's current ceiling gives. A machine that did not announce `projects` throws
|
|
180
|
+
* `device.projects_unsupported` (never null, which would read as "does not exist").
|
|
181
|
+
*/
|
|
182
|
+
async list(h, path, opts) {
|
|
183
|
+
await this.requireProjects(h.id);
|
|
184
|
+
opts.signal.throwIfAborted();
|
|
185
|
+
return this.relay.call(h.id, "list", { path, limit: opts.limit, limits: { mode: opts.limits.mode } }, { deadlineMs: OP_DEADLINE_MS, signal: opts.signal });
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Looks for project-like directories under `base` on the machine (the `scan` op, project root
|
|
189
|
+
* §4.1), read in the mode the kernel's current ceiling gives. A machine that did not announce
|
|
190
|
+
* `projects` throws `device.projects_unsupported`.
|
|
191
|
+
*/
|
|
192
|
+
async scan(h, base, opts) {
|
|
193
|
+
await this.requireProjects(h.id);
|
|
194
|
+
opts.signal.throwIfAborted();
|
|
195
|
+
return this.relay.call(h.id, "scan", { base, limits: { mode: opts.limits.mode } }, { deadlineMs: OP_DEADLINE_MS, signal: opts.signal });
|
|
196
|
+
}
|
|
197
|
+
/** The kernel never sends `list` or `scan` to a machine that did not announce `projects`. */
|
|
198
|
+
async requireProjects(deviceId) {
|
|
199
|
+
if (!(await this.targets.machineFeatures(deviceId)).includes("projects")) {
|
|
200
|
+
throw projectsUnsupported(true);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
170
203
|
/**
|
|
171
204
|
* The device's org and the limits of one exec now (ruling R27): the effective policy's
|
|
172
205
|
* `allowedMode` and the sandbox-mode allowlist. A deleted device is not found. A machine whose
|
|
@@ -95,7 +95,8 @@ export declare class MachinesService {
|
|
|
95
95
|
* device's mode and sandbox-mode allowlist; a change of what the owner sets, made on the machine
|
|
96
96
|
* while it was away, is audited `device.policy_changed` / `device.mode_changed`
|
|
97
97
|
* ({@link reportedPolicy}). The outcomes of its recent policy ops (`recentOps`) backfill the
|
|
98
|
-
* platform's ops still pending on the row ({@link backfillOps}).
|
|
98
|
+
* platform's ops still pending on the row ({@link backfillOps}). The owner's home directory
|
|
99
|
+
* (`home`) replaces the stored one too (null when the hello has none).
|
|
99
100
|
*/
|
|
100
101
|
recordHello(machineId: string, hello: DeviceHello, rawPolicy?: unknown): Promise<void>;
|
|
101
102
|
/**
|
|
@@ -166,7 +166,8 @@ let MachinesService = class MachinesService {
|
|
|
166
166
|
* device's mode and sandbox-mode allowlist; a change of what the owner sets, made on the machine
|
|
167
167
|
* while it was away, is audited `device.policy_changed` / `device.mode_changed`
|
|
168
168
|
* ({@link reportedPolicy}). The outcomes of its recent policy ops (`recentOps`) backfill the
|
|
169
|
-
* platform's ops still pending on the row ({@link backfillOps}).
|
|
169
|
+
* platform's ops still pending on the row ({@link backfillOps}). The owner's home directory
|
|
170
|
+
* (`home`) replaces the stored one too (null when the hello has none).
|
|
170
171
|
*/
|
|
171
172
|
async recordHello(machineId, hello, rawPolicy = hello.policy) {
|
|
172
173
|
const self = await this.db
|
|
@@ -224,6 +225,8 @@ let MachinesService = class MachinesService {
|
|
|
224
225
|
session_isolation: hello.sessionIsolation,
|
|
225
226
|
features: deviceFeaturesOf(hello.features),
|
|
226
227
|
local_policy: jsonOrNull(policy),
|
|
228
|
+
// the base of an auto-mode project's relative path (project root §4.2); absent: unknown
|
|
229
|
+
home: hello.home ?? null,
|
|
227
230
|
last_seen_at: sql `now()`,
|
|
228
231
|
})
|
|
229
232
|
.where("id", "=", machineId)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type DeviceExecGrants, type NetworkBlockedHost, type SandboxLimits } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type SandboxMode } from "../sandbox/modes.js";
|
|
4
4
|
/** The most hosts one exec's grants carry (the device protocol's limit). */
|
|
5
5
|
export declare const MAX_GRANT_HOSTS = 100;
|
|
6
6
|
/** What a run tree's network asks add up to (network ask-to-allow spec §6.8). */
|
|
@@ -12,6 +12,7 @@ import { Inject, Injectable } from "@nestjs/common";
|
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
14
|
import { budgetRunOf } from "../runtime/subagents/limits.js";
|
|
15
|
+
import { coversHost } from "../sandbox/modes.js";
|
|
15
16
|
import { taskGrantsRunOf } from "../schedules/unattended.js";
|
|
16
17
|
import { localModeOf } from "./policy-summary.js";
|
|
17
18
|
/** The most hosts one exec's grants carry (the device protocol's limit). */
|
|
@@ -229,14 +230,12 @@ const normalize = (host) => {
|
|
|
229
230
|
const h = host.toLowerCase();
|
|
230
231
|
return h.endsWith(".") ? h.slice(0, -1) : h;
|
|
231
232
|
};
|
|
232
|
-
/** Whether the allowlist entry `pattern` admits `host` (`*.x.com`: subdomains, never the apex). */
|
|
233
|
-
const covers = (pattern, host) => pattern === host || (pattern.startsWith("*.") && host.endsWith(pattern.slice(1)));
|
|
234
233
|
/** Whether the org's sandbox-mode network lets a command reach `host`. */
|
|
235
234
|
export function orgAllows(host, limits) {
|
|
236
235
|
if (limits.network.kind === "open-public")
|
|
237
236
|
return true;
|
|
238
237
|
const h = normalize(host);
|
|
239
|
-
return limits.network.hosts.some((p) =>
|
|
238
|
+
return limits.network.hosts.some((p) => coversHost(p.toLowerCase(), h));
|
|
240
239
|
}
|
|
241
240
|
/**
|
|
242
241
|
* The kernel's own layer for a device's report (auto mode spec §4.2): it trusts the device's word
|
|
@@ -12,6 +12,8 @@ export declare const deviceOffline: () => ApiError;
|
|
|
12
12
|
* with `details: [{ reason: "machine_revoked" }]`, so the tools tell the model what to ask for.
|
|
13
13
|
*/
|
|
14
14
|
export declare const machineRevoked: () => ApiError;
|
|
15
|
+
/** The text a machine's `policy` refusal reaches the model with. */
|
|
16
|
+
export declare const POLICY_REFUSAL_PREFIX = "Refused by the machine's local policy: ";
|
|
15
17
|
/** The text a machine's `error` result reaches the model with (ruling R28). */
|
|
16
18
|
export declare const ON_MACHINE_PREFIX = "On the connected machine: ";
|
|
17
19
|
/** The longest one lease check of a waiting caller may take before it counts as "unknown". */
|
|
@@ -24,6 +24,8 @@ export const deviceOffline = () => new ApiError("device.offline", "The machine o
|
|
|
24
24
|
* with `details: [{ reason: "machine_revoked" }]`, so the tools tell the model what to ask for.
|
|
25
25
|
*/
|
|
26
26
|
export const machineRevoked = () => new ApiError("device.forbidden", "The machine of this local device was disconnected. Run capybara-device logout, then capybara-device login on it, or pick another device.", [{ reason: "machine_revoked" }]);
|
|
27
|
+
/** The text a machine's `policy` refusal reaches the model with. */
|
|
28
|
+
export const POLICY_REFUSAL_PREFIX = "Refused by the machine's local policy: ";
|
|
27
29
|
/** The text a machine's `error` result reaches the model with (ruling R28). */
|
|
28
30
|
export const ON_MACHINE_PREFIX = "On the connected machine: ";
|
|
29
31
|
/** The longest one lease check of a waiting caller may take before it counts as "unknown". */
|
|
@@ -355,7 +357,7 @@ let LocalDeviceRelay = class LocalDeviceRelay {
|
|
|
355
357
|
case "fs_gone":
|
|
356
358
|
throw new FileSystemGoneError(message);
|
|
357
359
|
case "policy":
|
|
358
|
-
throw new ToolError(
|
|
360
|
+
throw new ToolError(`${POLICY_REFUSAL_PREFIX}${message}`);
|
|
359
361
|
default:
|
|
360
362
|
throw new ToolError(`${ON_MACHINE_PREFIX}${message}`);
|
|
361
363
|
}
|