@capybara-hq/plugin-sdk 0.1.0-rc.7 → 0.1.0-rc.70

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.
Files changed (146) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +11 -3
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +2 -0
  9. package/agent-docs/extension-points/model-provider.md +3 -1
  10. package/agent-docs/extension-points/object-store.md +2 -0
  11. package/agent-docs/extension-points/push-provider.md +17 -0
  12. package/agent-docs/extensions.md +76 -3
  13. package/agent-docs/plugin-format.md +51 -12
  14. package/agent-docs/setup.md +54 -0
  15. package/dist/agent-template.d.ts +15 -6
  16. package/dist/agent-template.js +32 -13
  17. package/dist/avatar-presets.d.ts +8 -0
  18. package/dist/avatar-presets.js +17 -0
  19. package/dist/bootstrap.d.ts +109 -1
  20. package/dist/bootstrap.js +185 -2
  21. package/dist/cards.d.ts +60 -13
  22. package/dist/cards.js +88 -18
  23. package/dist/channel.d.ts +128 -47
  24. package/dist/channel.js +10 -5
  25. package/dist/client-css.d.ts +36 -0
  26. package/dist/client-css.js +326 -0
  27. package/dist/client-section.d.ts +35 -0
  28. package/dist/client-section.js +133 -0
  29. package/dist/config-ui.d.ts +28 -6
  30. package/dist/config-ui.js +88 -25
  31. package/dist/config-url-fetch.d.ts +19 -0
  32. package/dist/config-url-fetch.js +43 -0
  33. package/dist/connector-auth.d.ts +13 -2
  34. package/dist/connector-auth.js +82 -8
  35. package/dist/connector.d.ts +74 -32
  36. package/dist/context.d.ts +40 -0
  37. package/dist/context.js +2 -0
  38. package/dist/ctx.d.ts +210 -30
  39. package/dist/ctx.js +9 -1
  40. package/dist/define-extension.d.ts +23 -13
  41. package/dist/define-extension.js +19 -5
  42. package/dist/device-denied-paths.d.ts +20 -0
  43. package/dist/device-denied-paths.js +118 -0
  44. package/dist/device-operation.d.ts +339 -0
  45. package/dist/device-operation.js +312 -0
  46. package/dist/device-protocol.d.ts +285 -50
  47. package/dist/device-protocol.js +755 -90
  48. package/dist/device-provider.d.ts +708 -0
  49. package/dist/device-provider.js +325 -0
  50. package/dist/device-service.d.ts +52 -0
  51. package/dist/device-service.js +105 -0
  52. package/dist/dial-in.d.ts +239 -0
  53. package/dist/dial-in.js +155 -0
  54. package/dist/directory.d.ts +15 -12
  55. package/dist/extension-point.d.ts +2 -0
  56. package/dist/extension-point.js +6 -2
  57. package/dist/field-meta.d.ts +19 -0
  58. package/dist/field-meta.js +54 -0
  59. package/dist/file-preview.d.ts +26 -10
  60. package/dist/git-hosts.d.ts +53 -0
  61. package/dist/git-hosts.js +98 -0
  62. package/dist/hooks.d.ts +125 -20
  63. package/dist/hooks.js +5 -0
  64. package/dist/http-access.d.ts +62 -0
  65. package/dist/http-access.js +12 -0
  66. package/dist/identity.d.ts +38 -9
  67. package/dist/identity.js +21 -1
  68. package/dist/index.d.ts +31 -4
  69. package/dist/index.js +31 -4
  70. package/dist/model-params.d.ts +41 -22
  71. package/dist/model-params.js +28 -15
  72. package/dist/model.d.ts +210 -75
  73. package/dist/model.js +152 -19
  74. package/dist/net.d.ts +52 -0
  75. package/dist/net.js +34 -0
  76. package/dist/network-classes.d.ts +98 -0
  77. package/dist/network-classes.js +291 -0
  78. package/dist/permissions.d.ts +65 -22
  79. package/dist/permissions.js +139 -43
  80. package/dist/platform-only.d.ts +27 -0
  81. package/dist/platform-only.js +35 -0
  82. package/dist/plugin-manifest.d.ts +40 -9
  83. package/dist/plugin-manifest.js +171 -60
  84. package/dist/plugin-package.d.ts +82 -39
  85. package/dist/plugin-package.js +68 -41
  86. package/dist/push.d.ts +75 -0
  87. package/dist/push.js +87 -0
  88. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  89. package/dist/sandbox-linux-runtime-source.js +2343 -0
  90. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  91. package/dist/sandbox-native-runtime-source.js +476 -0
  92. package/dist/sandbox-runtime-source.d.ts +47 -0
  93. package/dist/sandbox-runtime-source.js +73 -0
  94. package/dist/sandbox-write-denies.d.ts +139 -0
  95. package/dist/sandbox-write-denies.js +869 -0
  96. package/dist/secret.d.ts +8 -2
  97. package/dist/secret.js +11 -4
  98. package/dist/setup-check.d.ts +128 -0
  99. package/dist/setup-check.js +142 -0
  100. package/dist/setup-guide-parse.d.ts +121 -0
  101. package/dist/setup-guide-parse.js +356 -0
  102. package/dist/setup-guide-render.d.ts +45 -0
  103. package/dist/setup-guide-render.js +351 -0
  104. package/dist/setup-guide.d.ts +86 -72
  105. package/dist/setup-guide.js +340 -108
  106. package/dist/shell-capabilities.d.ts +211 -0
  107. package/dist/shell-capabilities.js +44 -0
  108. package/dist/shell-environment.d.ts +57 -0
  109. package/dist/shell-environment.js +21 -0
  110. package/dist/skill.d.ts +27 -17
  111. package/dist/skill.js +40 -26
  112. package/dist/storage.d.ts +52 -25
  113. package/dist/svg-viewbox.d.ts +10 -0
  114. package/dist/svg-viewbox.js +24 -0
  115. package/dist/theme-assets.d.ts +55 -0
  116. package/dist/theme-assets.js +489 -0
  117. package/dist/theme-readability.d.ts +37 -0
  118. package/dist/theme-readability.js +145 -0
  119. package/dist/theme-tokens.generated.d.ts +299 -0
  120. package/dist/theme-tokens.generated.js +184 -0
  121. package/dist/theme.d.ts +190 -0
  122. package/dist/theme.js +471 -0
  123. package/dist/tool.d.ts +104 -30
  124. package/dist/tool.js +29 -9
  125. package/dist/ui-parts.d.ts +23 -0
  126. package/dist/ui-parts.js +385 -0
  127. package/dist/ui-resolve.d.ts +35 -0
  128. package/dist/ui-resolve.js +42 -0
  129. package/dist/ui-slots.d.ts +65 -0
  130. package/dist/ui-slots.js +261 -0
  131. package/dist/ui.d.ts +221 -77
  132. package/dist/ui.js +104 -27
  133. package/dist/url.d.ts +4 -1
  134. package/dist/url.js +4 -1
  135. package/dist/web.d.ts +26 -20
  136. package/package.json +13 -1
  137. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  138. package/schemas/bootstrap.v1.schema.json +20 -0
  139. package/schemas/connector-template.v1.schema.json +62 -4
  140. package/schemas/plugin.v1.schema.json +93 -143
  141. package/schemas/theme.v1.schema.json +302 -0
  142. package/agent-docs/extension-points/sandbox.md +0 -15
  143. package/dist/org-access.d.ts +0 -27
  144. package/dist/org-access.js +0 -35
  145. package/dist/sandbox.d.ts +0 -254
  146. package/dist/sandbox.js +0 -153
@@ -1,54 +1,69 @@
1
1
  /**
2
- * Device protocol v1: the WebSocket frames between the kernel and a `capybara-device` program
3
- * (a connected machine that serves as an environment). Pure types and hand-written guards.
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 ExecResult, type SandboxActor, type SandboxLimits, type SandboxRoots } from "./sandbox.js";
6
- /** The protocol version carried in `X-Capybara-Device-Protocol` and the hello frame. */
7
- export declare const DEVICE_PROTOCOL_VERSION = 1;
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
- /** First frame from the device after the WebSocket opens. */
11
- export interface DeviceHello {
12
- type: "hello";
13
- protocol: number;
14
- programVersion: string;
15
- os: "darwin" | "linux";
16
- arch: string;
17
- mode: "os" | "docker";
18
- roots: SandboxRoots;
19
- sessionIsolation: boolean;
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
- /** A frame that is not valid protocol v1 (or came from the wrong side). */
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
- * Parses one WebSocket text frame. `from` is the sender: a device may send `hello` and `res`, the
115
- * kernel `req` and `cancel`. Throws {@link DeviceProtocolError} on bad JSON, an unknown `type`,
116
- * missing fields or a frame of the wrong direction.
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(raw: string, from: "device" | "kernel"): DeviceFrame;
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;