@capybara-hq/plugin-sdk 0.1.0-rc.8 → 0.1.0-rc.80
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 +1 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +11 -3
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/device-provider.md +15 -0
- package/agent-docs/extension-points/file-preview.md +3 -1
- package/agent-docs/extension-points/identity-source.md +2 -0
- package/agent-docs/extension-points/model-provider.md +3 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extensions.md +77 -4
- package/agent-docs/plugin-format.md +45 -10
- package/agent-docs/setup.md +54 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/avatar-presets.d.ts +8 -0
- package/dist/avatar-presets.js +17 -0
- package/dist/bootstrap.d.ts +109 -1
- package/dist/bootstrap.js +185 -2
- package/dist/cards.d.ts +60 -13
- package/dist/cards.js +88 -18
- package/dist/channel.d.ts +128 -47
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +28 -6
- package/dist/config-ui.js +88 -25
- package/dist/config-url-fetch.d.ts +19 -0
- package/dist/config-url-fetch.js +43 -0
- package/dist/connector-auth.d.ts +13 -2
- package/dist/connector-auth.js +82 -8
- package/dist/connector.d.ts +74 -32
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +224 -30
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +23 -13
- package/dist/define-extension.js +19 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +339 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +285 -50
- package/dist/device-protocol.js +755 -90
- package/dist/device-provider.d.ts +780 -0
- package/dist/device-provider.js +409 -0
- package/dist/device-service.d.ts +126 -0
- package/dist/device-service.js +211 -0
- package/dist/dial-in.d.ts +286 -0
- package/dist/dial-in.js +213 -0
- package/dist/directory.d.ts +15 -12
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +7 -3
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +43 -10
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +125 -20
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +71 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +70 -9
- package/dist/identity.js +46 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.js +28 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +210 -75
- package/dist/model.js +152 -19
- package/dist/native-failure.d.ts +13 -0
- package/dist/native-failure.js +31 -0
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/network-classes.d.ts +98 -0
- package/dist/network-classes.js +291 -0
- package/dist/permissions.d.ts +65 -22
- package/dist/permissions.js +139 -43
- package/dist/platform-only.d.ts +27 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +30 -6
- package/dist/plugin-manifest.js +147 -55
- package/dist/plugin-package.d.ts +82 -39
- package/dist/plugin-package.js +68 -41
- package/dist/push.d.ts +75 -0
- package/dist/push.js +87 -0
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +2343 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +480 -0
- package/dist/sandbox-runtime-source.d.ts +47 -0
- package/dist/sandbox-runtime-source.js +73 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +8 -2
- package/dist/secret.js +11 -4
- package/dist/setup-check.d.ts +128 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +356 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +86 -72
- package/dist/setup-guide.js +340 -108
- package/dist/shell-capabilities.d.ts +211 -0
- package/dist/shell-capabilities.js +44 -0
- package/dist/shell-environment.d.ts +57 -0
- package/dist/shell-environment.js +21 -0
- package/dist/skill-invocation.d.ts +5 -0
- package/dist/skill-invocation.js +4 -3
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +40 -26
- package/dist/storage.d.ts +52 -25
- package/dist/svg-viewbox.d.ts +10 -0
- package/dist/svg-viewbox.js +24 -0
- package/dist/theme-assets.d.ts +25 -9
- package/dist/theme-assets.js +87 -47
- package/dist/theme-tokens.generated.d.ts +26 -2
- package/dist/theme-tokens.generated.js +17 -0
- package/dist/theme.d.ts +48 -10
- package/dist/theme.js +100 -21
- package/dist/tool.d.ts +156 -30
- package/dist/tool.js +91 -9
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +385 -0
- package/dist/ui-resolve.d.ts +35 -0
- package/dist/ui-resolve.js +42 -0
- package/dist/ui-slots.d.ts +65 -0
- package/dist/ui-slots.js +261 -0
- package/dist/ui.d.ts +245 -77
- package/dist/ui.js +104 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/dist/web.d.ts +26 -20
- package/package.json +12 -1
- package/schemas/bootstrap-extra.v1.schema.json +186 -0
- package/schemas/bootstrap.v1.schema.json +20 -0
- package/schemas/connector-template.v1.schema.json +62 -4
- package/schemas/plugin.v1.schema.json +74 -143
- package/schemas/theme.v1.schema.json +77 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
|
@@ -1,54 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* (a connected machine that serves as
|
|
2
|
+
* The device protocol: the WebSocket frames between the kernel and a `capybara-device` program
|
|
3
|
+
* (a connected machine that serves as a device). Pure types and hand-written guards.
|
|
4
|
+
*
|
|
5
|
+
* The bodies of the dial-in envelope are parsed by `parseDeviceFrame` (second half of this file);
|
|
6
|
+
* the per-operation argument and result guards of the first half are its value guards.
|
|
4
7
|
*/
|
|
5
|
-
import { type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
import { type SandboxPermissionSupport } from "./device-operation.js";
|
|
9
|
+
import { type ExecResult, type SandboxActor, type SandboxLimits, type SandboxRoots } from "./device-provider.js";
|
|
10
|
+
/** The major version of {@link DEVICE_DIAL_IN_PROTOCOL}. */
|
|
11
|
+
export declare const DEVICE_PROTOCOL_VERSION = 6;
|
|
12
|
+
/**
|
|
13
|
+
* The dial-in protocol `capybara-device` speaks (`<name>/<major>`, see `DIAL_IN_PROTOCOL_RE`): the
|
|
14
|
+
* value of the `X-Capybara-Device-Protocol` header, of the hello envelope's `protocol` and of the
|
|
15
|
+
* sign-in's `protocol`. The provider serving its devices declares it as `permissions.dialIn`.
|
|
16
|
+
* The kernel checks only the envelope (`DialInMachineFrame`); the bodies the envelope carries are
|
|
17
|
+
* this module's ({@link parseDeviceFrame}).
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEVICE_DIAL_IN_PROTOCOL: "capybara-device/6";
|
|
8
20
|
/** The operations the kernel asks a device to run. */
|
|
9
|
-
export type DeviceOp = "create" | "exec" | "readFile" | "writeFile" | "stat" | "killTagged" | "killAll" | "stop";
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
export type DeviceOp = "create" | "exec" | "readFile" | "writeFile" | "stat" | "killTagged" | "killAll" | "stop" | "list" | "scan";
|
|
22
|
+
/**
|
|
23
|
+
* Optional capabilities a device announces in its hello: `networkReport` means exec results may
|
|
24
|
+
* carry `network`; `projects` means the device serves `list` and `scan` (the provider never sends
|
|
25
|
+
* `list` or `scan` to a device that did not announce `projects`).
|
|
26
|
+
*/
|
|
27
|
+
export type DeviceFeature = "networkReport" | "projects";
|
|
28
|
+
/**
|
|
29
|
+
* What a device knows of its local policy and reports (in the hello or a `policy` event). The owner
|
|
30
|
+
* ceiling travels separately, in the owner report ({@link DeviceOwnerCeiling}).
|
|
31
|
+
*/
|
|
32
|
+
export interface DeviceLocalPolicySummary {
|
|
33
|
+
/** The device's sandbox allowlist (the owner's `allowedDomains`). */
|
|
34
|
+
allowedDomains: string[];
|
|
35
|
+
/**
|
|
36
|
+
* This connection's project directories that another connection on the same machine also uses,
|
|
37
|
+
* only those the owner listed explicitly for this connection (its `projectPaths`): a directory
|
|
38
|
+
* the deployment picked itself is never reported, shared or not (absolute paths,
|
|
39
|
+
* {@link validateSandboxPathShape}; at most {@link MAX_DEVICE_SHARED_PROJECT_ROOTS}). Never names
|
|
40
|
+
* the other connection. Absent from an older device; a malformed value is dropped by the parser
|
|
41
|
+
* (the rest of the summary is kept).
|
|
42
|
+
*/
|
|
43
|
+
sharedProjectRoots?: string[];
|
|
20
44
|
}
|
|
45
|
+
/** The most project directories a policy summary's `sharedProjectRoots` lists. */
|
|
46
|
+
export declare const MAX_DEVICE_SHARED_PROJECT_ROOTS = 256;
|
|
47
|
+
/**
|
|
48
|
+
* A directory a `scan` found that looks like a project (it holds `.git` or `AGENTS.md`): a
|
|
49
|
+
* suggestion, not a project. `path` is absolute ({@link validateSandboxPathShape});
|
|
50
|
+
* `suggestedName` is a guess from its basename ({@link isDeviceProjectName}) the owner may change.
|
|
51
|
+
*/
|
|
52
|
+
export interface DeviceProjectCandidate {
|
|
53
|
+
path: string;
|
|
54
|
+
suggestedName: string;
|
|
55
|
+
}
|
|
56
|
+
/** The most blocked hosts an exec result reports; the parser cuts longer lists. */
|
|
57
|
+
export declare const MAX_NETWORK_BLOCKED_HOSTS = 20;
|
|
58
|
+
/**
|
|
59
|
+
* The identity of a host's OS boot or of a program run: 1 to 128 characters of letters, digits,
|
|
60
|
+
* `.`, `_`, `:` and `-`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const DEVICE_BOOT_ID_RE: RegExp;
|
|
63
|
+
/** Whether `v` is a well-formed boot or program-run identity ({@link DEVICE_BOOT_ID_RE}). */
|
|
64
|
+
export declare function isDeviceBootId(v: unknown): v is string;
|
|
21
65
|
/** Error kinds a device reports for a failed request. */
|
|
22
66
|
export type DeviceErrorKind = "gone" | "fs_gone" | "policy" | "error";
|
|
23
|
-
/** The device's answer to a {@link KernelReq}. */
|
|
24
|
-
export type DeviceRes = {
|
|
25
|
-
type: "res";
|
|
26
|
-
id: string;
|
|
27
|
-
ok: true;
|
|
28
|
-
result: unknown;
|
|
29
|
-
} | {
|
|
30
|
-
type: "res";
|
|
31
|
-
id: string;
|
|
32
|
-
ok: false;
|
|
33
|
-
error: {
|
|
34
|
-
kind: DeviceErrorKind;
|
|
35
|
-
message: string;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
/** A request from the kernel. */
|
|
39
|
-
export interface KernelReq {
|
|
40
|
-
type: "req";
|
|
41
|
-
id: string;
|
|
42
|
-
op: DeviceOp;
|
|
43
|
-
args: unknown;
|
|
44
|
-
deadlineMs: number;
|
|
45
|
-
}
|
|
46
|
-
/** The kernel gives up on a request (abort or deadline). */
|
|
47
|
-
export interface KernelCancel {
|
|
48
|
-
type: "cancel";
|
|
49
|
-
id: string;
|
|
50
|
-
}
|
|
51
|
-
export type DeviceFrame = DeviceHello | DeviceRes | KernelReq | KernelCancel;
|
|
52
67
|
export interface DeviceExecArgs {
|
|
53
68
|
command: string;
|
|
54
69
|
cwd?: string;
|
|
@@ -58,6 +73,22 @@ export interface DeviceExecArgs {
|
|
|
58
73
|
tag: string;
|
|
59
74
|
actor: SandboxActor;
|
|
60
75
|
limits: SandboxLimits;
|
|
76
|
+
/**
|
|
77
|
+
* Hosts the kernel allows for this command beyond the local policy (a run's "Allow this time" or
|
|
78
|
+
* a
|
|
79
|
+
* scheduled task's grants). A device applies them only in sandbox mode, within `limits`; a
|
|
80
|
+
* device without the feature ignores the field.
|
|
81
|
+
*/
|
|
82
|
+
grants?: DeviceExecGrants;
|
|
83
|
+
}
|
|
84
|
+
/** Extra hosts for one exec and where they come from (logged by the device with the command). */
|
|
85
|
+
export interface DeviceExecGrants {
|
|
86
|
+
hosts: string[];
|
|
87
|
+
source: {
|
|
88
|
+
kind: "run" | "task";
|
|
89
|
+
id: string;
|
|
90
|
+
accountId: string;
|
|
91
|
+
};
|
|
61
92
|
}
|
|
62
93
|
export type DeviceExecResult = ExecResult;
|
|
63
94
|
export interface DeviceReadFileArgs {
|
|
@@ -93,7 +124,50 @@ export interface DeviceCreateResult {
|
|
|
93
124
|
export interface DeviceStopArgs {
|
|
94
125
|
reason: "revoked" | "deleted";
|
|
95
126
|
}
|
|
96
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* Lists one directory (absolute `path`, {@link validateSandboxPathShape}): at most `limit` entries
|
|
129
|
+
* (at most {@link MAX_DEVICE_LIST_ENTRIES}), read within the operation's scope. See
|
|
130
|
+
* `DeviceProvider.list` for the semantics.
|
|
131
|
+
*/
|
|
132
|
+
export interface DeviceListArgs {
|
|
133
|
+
path: string;
|
|
134
|
+
limit: number;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* One entry of a listed directory: `name` is never empty, `.` or `..` and holds no `/`. `isDir`
|
|
138
|
+
* follows symbolic links (stat semantics): a link to a directory is `true`, a dangling link `false`,
|
|
139
|
+
* and so is a link whose target the request's mode cannot reach.
|
|
140
|
+
*/
|
|
141
|
+
export interface DeviceListEntry {
|
|
142
|
+
name: string;
|
|
143
|
+
isDir: boolean;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The directory's entries sorted by code unit, `truncated` when more than `limit` exist; null only
|
|
147
|
+
* when the path does not exist and the request's mode could reach it (like `stat` / `readFile`).
|
|
148
|
+
* A file, an unreadable directory, or a path the request's mode cannot reach is an error (the
|
|
149
|
+
* latter a `policy` refusal), never null.
|
|
150
|
+
*/
|
|
151
|
+
export type DeviceListResult = {
|
|
152
|
+
entries: DeviceListEntry[];
|
|
153
|
+
truncated: boolean;
|
|
154
|
+
} | null;
|
|
155
|
+
/**
|
|
156
|
+
* Looks for project-like directories under `base` (absolute, {@link validateSandboxPathShape}),
|
|
157
|
+
* read within the operation's scope. A `base` that does not exist answers `[]`; a `base` that is a
|
|
158
|
+
* file, unreadable, or outside the request's scope is an error. See `DeviceProvider.scan` for the
|
|
159
|
+
* traversal.
|
|
160
|
+
*/
|
|
161
|
+
export interface DeviceScanArgs {
|
|
162
|
+
base: string;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* `base` itself and the directories at most {@link MAX_DEVICE_SCAN_DEPTH} levels below it that
|
|
166
|
+
* hold a `.git` entry or an `AGENTS.md` file, sorted by `path` in code-unit order and cut to the
|
|
167
|
+
* first {@link MAX_DEVICE_SCAN_RESULTS}. Never file contents. See `DeviceProvider.scan`.
|
|
168
|
+
*/
|
|
169
|
+
export type DeviceScanResult = DeviceProjectCandidate[];
|
|
170
|
+
/** A frame that is not valid device protocol (or came from the wrong side). */
|
|
97
171
|
export declare class DeviceProtocolError extends Error {
|
|
98
172
|
constructor(message: string);
|
|
99
173
|
}
|
|
@@ -107,12 +181,173 @@ export interface DeviceOpResults {
|
|
|
107
181
|
killTagged: null;
|
|
108
182
|
killAll: null;
|
|
109
183
|
stop: null;
|
|
184
|
+
list: DeviceListResult;
|
|
185
|
+
scan: DeviceScanResult;
|
|
110
186
|
}
|
|
111
187
|
/** Validates the `result` of a successful `res` for `op`; throws {@link DeviceProtocolError}. */
|
|
112
188
|
export declare function parseOpResult<Op extends DeviceOp>(op: Op, result: unknown): DeviceOpResults[Op];
|
|
113
189
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
190
|
+
* The operations the kernel asks a protocol 6 device to run: every user operation carries its
|
|
191
|
+
* admitted scope; there is no broad kill (`killTagged` / `killAll`) and no deployment-side change
|
|
192
|
+
* of the machine's policy: the owner changes it on the machine and the device reports the change
|
|
193
|
+
* ({@link DevicePolicyChanged}).
|
|
194
|
+
*/
|
|
195
|
+
export type DeviceOperation = Exclude<DeviceOp, "killTagged" | "killAll"> | "prepareReadFile" | "prepareWriteFile" | "prepareStat" | "browseStat" | "browseList" | "browseScan" | "backgroundStart" | "backgroundStatus" | "backgroundTail" | "backgroundReadOutput" | "backgroundStop" | "revokeOperation" | "bindInstance";
|
|
196
|
+
/**
|
|
197
|
+
* How far a connection's project paths reach: `machine` (any path the deny list leaves), `paths`
|
|
198
|
+
* (the listed project paths) or `workspace` (the connection's working directory only).
|
|
199
|
+
*/
|
|
200
|
+
export type DeviceProjectReach = "machine" | "paths" | "workspace";
|
|
201
|
+
/** Why a device refused a project path: the `refusal` of a `project_refused` outcome. */
|
|
202
|
+
export type DeviceProjectRefusal = "other-connection" | "outside-reach" | "denied";
|
|
203
|
+
/** The sandbox network of a device: the open public internet or an allowlist. */
|
|
204
|
+
export type DeviceNetworkMode = "open" | "allowlist";
|
|
205
|
+
/**
|
|
206
|
+
* The owner ceiling of protocol 6 (approval-only profiles design, "Settings model"): the device
|
|
207
|
+
* sandbox for every profile. `outsideSandbox` is whether a call may be granted escalation outside
|
|
208
|
+
* the sandbox; `network` and `allowedDomains` are the sandbox network.
|
|
209
|
+
*/
|
|
210
|
+
export interface DeviceOwnerCeiling {
|
|
211
|
+
readonly version: 3;
|
|
212
|
+
readonly sequence: number;
|
|
213
|
+
readonly revision: string;
|
|
214
|
+
readonly outsideSandbox: boolean;
|
|
215
|
+
readonly network: DeviceNetworkMode;
|
|
216
|
+
readonly allowedDomains: readonly string[];
|
|
217
|
+
readonly projectReach: DeviceProjectReach;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* An event body (the envelope's `event`): the owner changed the machine's policy or owner ceiling
|
|
221
|
+
* while connected. `policy` is absent when the summary was unreadable.
|
|
222
|
+
*/
|
|
223
|
+
export interface DevicePolicyChanged {
|
|
224
|
+
type: "policy";
|
|
225
|
+
policy?: DeviceLocalPolicySummary;
|
|
226
|
+
ownerCeiling: DeviceOwnerCeiling;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The hello body (the envelope's `hello` carries the program facts: protocol, program version,
|
|
230
|
+
* os, arch, boot and run identities, frame capacity). `policy` and `ownerCeiling` are the
|
|
231
|
+
* machine's own narrowing, read by the provider serving the device.
|
|
232
|
+
*/
|
|
233
|
+
export interface DeviceHello {
|
|
234
|
+
mode: "os" | "docker";
|
|
235
|
+
roots: SandboxRoots;
|
|
236
|
+
sessionIsolation: boolean;
|
|
237
|
+
/** Optional capabilities (unknown entries are dropped by the parser). */
|
|
238
|
+
features?: DeviceFeature[];
|
|
239
|
+
/** The device's local policy summary (dropped by the parser when unreadable). */
|
|
240
|
+
policy?: DeviceLocalPolicySummary;
|
|
241
|
+
/**
|
|
242
|
+
* The owner's home directory, an absolute path (a local device; the base of an auto-mode
|
|
243
|
+
* project's relative path). A malformed value is dropped by the parser.
|
|
244
|
+
*/
|
|
245
|
+
home?: string;
|
|
246
|
+
permissionSupport: SandboxPermissionSupport;
|
|
247
|
+
ownerCeiling: DeviceOwnerCeiling;
|
|
248
|
+
instanceGeneration: string | null;
|
|
249
|
+
/** Absent until the program can attest actual installed runtime/helper/environment bytes. */
|
|
250
|
+
runtimeIdentity?: DeviceRuntimeIdentity;
|
|
251
|
+
}
|
|
252
|
+
/** A verified installed runtime/helper/environment identity bound to one instance generation. */
|
|
253
|
+
export interface DeviceRuntimeIdentity {
|
|
254
|
+
runtimeHash: string;
|
|
255
|
+
helperHash: string;
|
|
256
|
+
imageFingerprint: string;
|
|
257
|
+
instanceGeneration: string;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Private lifecycle request (permission runtime cutover B4): binds the kernel's committed instance
|
|
261
|
+
* generation to the device after commit. It carries no path, policy or manifest.
|
|
262
|
+
*/
|
|
263
|
+
export interface BindInstanceRequest {
|
|
264
|
+
instanceId: string;
|
|
265
|
+
instanceGeneration: string;
|
|
266
|
+
bindingId: string;
|
|
267
|
+
expectedPreviousGeneration: string | null;
|
|
268
|
+
}
|
|
269
|
+
export interface BindInstanceResult {
|
|
270
|
+
instanceId: string;
|
|
271
|
+
instanceGeneration: string;
|
|
272
|
+
bindingId: string;
|
|
273
|
+
runtimeIdentity: DeviceRuntimeIdentity;
|
|
274
|
+
permissionSupport: SandboxPermissionSupport;
|
|
275
|
+
ownerCeiling: DeviceOwnerCeiling;
|
|
276
|
+
}
|
|
277
|
+
export interface BackgroundReadOutputRequest {
|
|
278
|
+
offset: number;
|
|
279
|
+
maxBytes: number;
|
|
280
|
+
}
|
|
281
|
+
export type BackgroundReadOutputResult = {
|
|
282
|
+
dataB64: string;
|
|
283
|
+
offset: number;
|
|
284
|
+
nextOffset: number;
|
|
285
|
+
totalBytes: number;
|
|
286
|
+
} | {
|
|
287
|
+
unavailable: "lost" | "expired";
|
|
288
|
+
};
|
|
289
|
+
/** A request body (the envelope's `req`): one operation and its arguments. */
|
|
290
|
+
export interface DeviceRequestBody {
|
|
291
|
+
op: DeviceOperation;
|
|
292
|
+
args: Readonly<Record<string, unknown>>;
|
|
293
|
+
}
|
|
294
|
+
/** A request as the device serves it: its body with the envelope's `id` and `deadlineMs`. */
|
|
295
|
+
export interface KernelRequest extends DeviceRequestBody {
|
|
296
|
+
type: "req";
|
|
297
|
+
id: string;
|
|
298
|
+
deadlineMs: number;
|
|
299
|
+
}
|
|
300
|
+
/** A response body (the envelope's `res`): the result, or the typed failure. */
|
|
301
|
+
export type DeviceResponseBody = {
|
|
302
|
+
ok: true;
|
|
303
|
+
result: unknown;
|
|
304
|
+
} | {
|
|
305
|
+
ok: false;
|
|
306
|
+
error: {
|
|
307
|
+
/**
|
|
308
|
+
* The typed failure: `denied`, `unsupported`, `unknown` and `invalid` carry the SDK's
|
|
309
|
+
* scope denial, unsupported permission, unknown outcome and scope validation errors.
|
|
310
|
+
* `invalid` never proves the operation had no effect (a skewed device may have parsed
|
|
311
|
+
* part of it): it must never join the not-run refusals (`isRefusal`, `failureKindOf`).
|
|
312
|
+
*/
|
|
313
|
+
kind: "gone" | "fs_gone" | "policy" | "error" | "denied" | "unsupported" | "unsettled" | "unknown" | "invalid" | "project_refused";
|
|
314
|
+
message: string;
|
|
315
|
+
/** Present on `project_refused` only: why the project path was refused. */
|
|
316
|
+
refusal?: DeviceProjectRefusal;
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
/** A response as the device produces it: its body with the envelope's `id`. */
|
|
320
|
+
export type DeviceResponse = {
|
|
321
|
+
type: "res";
|
|
322
|
+
id: string;
|
|
323
|
+
} & DeviceResponseBody;
|
|
324
|
+
/** The bodies of protocol 6, by the envelope frame that carries them. */
|
|
325
|
+
export interface DeviceBodies {
|
|
326
|
+
hello: DeviceHello;
|
|
327
|
+
req: DeviceRequestBody;
|
|
328
|
+
res: DeviceResponseBody;
|
|
329
|
+
event: DevicePolicyChanged;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Strictly parses a runtime permission report, version 2 (the protocol 4 `permissionSupport`, also
|
|
333
|
+
* the shape a cloud provider reports), and returns a frozen copy; throws {@link DeviceProtocolError}.
|
|
334
|
+
* Restricted support is all four claims or `null`; per-operation hosts need the allowlist; an
|
|
335
|
+
* operation boundary without restricted support claims no sandbox network at all. An
|
|
336
|
+
* instance boundary is the whole instance: it claims no restricted per-operation scope, no
|
|
337
|
+
* outside-sandbox escalation and no per-operation hosts (a host joins the device's list instead).
|
|
338
|
+
*/
|
|
339
|
+
export declare function parseSandboxPermissionSupport(value: unknown): SandboxPermissionSupport;
|
|
340
|
+
/**
|
|
341
|
+
* Strictly parses one authenticated owner-ceiling report of protocol 6 and returns a frozen copy;
|
|
342
|
+
* throws {@link DeviceProtocolError}. Unknown fields (the protocol 3 `fullAccess` and
|
|
343
|
+
* `restrictedAllowedDomains` among them) are refused.
|
|
344
|
+
*/
|
|
345
|
+
export declare function parseOwnerCeilingReport(value: unknown): DeviceOwnerCeiling;
|
|
346
|
+
/**
|
|
347
|
+
* Strictly parses one protocol 6 body, as carried by the dial-in envelope frame of type `kind`
|
|
348
|
+
* (`hello`, `event` and `res` from the device, `req` from the kernel), and returns a frozen copy;
|
|
349
|
+
* throws {@link DeviceProtocolError}. The envelope (its ids, deadline and size bound) is checked
|
|
350
|
+
* before: `parseDialInMachineFrame` on the kernel, `parseDialInKernelFrame` on the machine.
|
|
117
351
|
*/
|
|
118
|
-
export declare function parseDeviceFrame(
|
|
352
|
+
export declare function parseDeviceFrame<K extends keyof DeviceBodies>(body: unknown, kind: K): DeviceBodies[K];
|
|
353
|
+
export declare function parseOperationResult(op: DeviceOperation, result: unknown, request?: BackgroundReadOutputRequest | BindInstanceRequest): unknown;
|