@capybara-hq/kernel 0.1.0-rc.49 → 0.1.0-rc.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/admin.schemas.d.ts +0 -6
- package/dist/background/launch.d.ts +7 -61
- package/dist/background/launch.js +8 -133
- package/dist/background/poll.job.d.ts +19 -23
- package/dist/background/poll.job.js +30 -66
- package/dist/background/render.d.ts +9 -0
- package/dist/background/render.js +19 -0
- package/dist/background/session.d.ts +3 -66
- package/dist/background/session.js +3 -114
- package/dist/background/stop.d.ts +26 -33
- package/dist/background/stop.js +59 -90
- package/dist/background/store.d.ts +26 -60
- package/dist/background/store.js +23 -108
- package/dist/background/tasks.service.d.ts +9 -29
- package/dist/background/tasks.service.js +18 -115
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/cards.d.ts +3 -0
- package/dist/channels/cards.js +29 -2
- package/dist/channels/phrases.d.ts +35 -0
- package/dist/channels/phrases.js +32 -0
- package/dist/config/load.d.ts +3 -10
- package/dist/config/load.js +26 -21
- package/dist/config/schema.js +3 -3
- package/dist/conversations/events.d.ts +45 -2
- package/dist/conversations/events.js +44 -4
- package/dist/db/kernel-schema.d.ts +9 -4
- package/dist/devices/devices.service.js +1 -1
- package/dist/devices/errors.d.ts +5 -0
- package/dist/devices/errors.js +5 -0
- package/dist/devices/project-rules.d.ts +2 -2
- package/dist/errors.d.ts +9 -11
- package/dist/errors.js +9 -11
- package/dist/identity/settings.d.ts +4 -17
- package/dist/identity/settings.js +9 -32
- package/dist/infra/config/kernel-config.service.js +2 -9
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/local-devices/device-auth.controller.d.ts +1 -1
- package/dist/local-devices/device-auth.controller.js +1 -1
- package/dist/local-devices/device-auth.d.ts +4 -3
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +6 -6
- package/dist/local-devices/device-routes.d.ts +4 -2
- package/dist/local-devices/device-routes.js +7 -6
- package/dist/local-devices/instance-bindings.d.ts +4 -4
- package/dist/local-devices/instance-bindings.js +2 -2
- package/dist/local-devices/local-device-gateway.d.ts +12 -12
- package/dist/local-devices/local-device-gateway.js +94 -129
- package/dist/local-devices/local-device-provider.d.ts +19 -87
- package/dist/local-devices/local-device-provider.js +43 -158
- package/dist/local-devices/local-devices.module.d.ts +4 -5
- package/dist/local-devices/local-devices.module.js +6 -9
- package/dist/local-devices/machines.d.ts +6 -6
- package/dist/local-devices/machines.js +4 -4
- package/dist/local-devices/owner-report.d.ts +3 -3
- package/dist/local-devices/owner-report.js +4 -4
- package/dist/local-devices/owner-reports.js +2 -2
- package/dist/local-devices/policy-summary.js +2 -2
- package/dist/local-devices/relay.d.ts +12 -25
- package/dist/local-devices/relay.js +17 -31
- package/dist/orgs/settings.controller.d.ts +1 -4
- package/dist/orgs/settings.controller.js +3 -3
- package/dist/orgs/settings.service.d.ts +7 -21
- package/dist/orgs/settings.service.js +16 -40
- package/dist/overrides.d.ts +3 -3
- package/dist/platform/ops/admin.ops.js +6 -8
- package/dist/platform/ops/org-settings.ops.js +4 -4
- package/dist/platform/ops/orgs.ops.js +0 -1
- package/dist/runtime/maintenance.d.ts +1 -1
- package/dist/runtime/maintenance.js +7 -1
- package/dist/runtime/run-steps.js +2 -2
- package/dist/sandbox/held-operations.d.ts +7 -0
- package/dist/sandbox/held-operations.js +25 -1
- package/dist/sandbox/leases.d.ts +6 -3
- package/dist/sandbox/leases.js +16 -10
- package/dist/sandbox/legacy-retirement.d.ts +0 -19
- package/dist/sandbox/legacy-retirement.js +6 -37
- package/dist/sandbox/managed-device-context.d.ts +12 -0
- package/dist/sandbox/managed-device-context.js +49 -1
- package/dist/sandbox/modes.d.ts +9 -8
- package/dist/sandbox/modes.js +4 -15
- package/dist/sandbox/operation-authority-types.d.ts +18 -1
- package/dist/sandbox/operation-authority-types.js +20 -1
- package/dist/sandbox/operation-authority.d.ts +14 -0
- package/dist/sandbox/operation-authority.js +120 -18
- package/dist/sandbox/operation-intents.d.ts +43 -0
- package/dist/sandbox/operation-intents.js +107 -4
- package/dist/sandbox/operation-reconcile.job.d.ts +12 -1
- package/dist/sandbox/operation-reconcile.job.js +53 -6
- package/dist/sandbox/permission-call-grants.d.ts +4 -0
- package/dist/sandbox/permission-call-grants.js +32 -3
- package/dist/sandbox/permission-call-types.d.ts +27 -2
- package/dist/sandbox/permission-ceiling-writes.js +2 -1
- package/dist/sandbox/permission-context-types.d.ts +2 -2
- package/dist/sandbox/permission-context-types.js +2 -2
- package/dist/sandbox/permission-facts.js +10 -2
- package/dist/sandbox/platform-full-access.d.ts +8 -26
- package/dist/sandbox/platform-full-access.js +8 -20
- package/dist/sandbox/review/classifier.d.ts +2 -2
- package/dist/sandbox/review/classifier.js +18 -5
- package/dist/sandbox/review/permission-candidate.d.ts +59 -3
- package/dist/sandbox/review/permission-candidate.js +192 -25
- package/dist/sandbox/review/review.service.d.ts +18 -0
- package/dist/sandbox/review/review.service.js +158 -12
- package/dist/sandbox/sandbox.service.d.ts +71 -47
- package/dist/sandbox/sandbox.service.js +234 -133
- package/dist/tools/approvals.service.d.ts +6 -1
- package/dist/tools/approvals.service.js +10 -0
- package/dist/tools/builtins/builtin-tools.d.ts +1 -4
- package/dist/tools/builtins/builtin-tools.js +13 -18
- package/dist/tools/builtins/sandbox/bash.d.ts +16 -3
- package/dist/tools/builtins/sandbox/bash.js +92 -270
- package/dist/tools/builtins/sandbox/common.d.ts +15 -9
- package/dist/tools/builtins/sandbox/common.js +55 -19
- package/dist/tools/builtins/sandbox/device-owner.d.ts +13 -0
- package/dist/tools/builtins/sandbox/device-owner.js +14 -0
- package/dist/tools/builtins/sandbox/task-list.js +2 -2
- package/dist/tools/builtins/sandbox/task-output.d.ts +14 -57
- package/dist/tools/builtins/sandbox/task-output.js +88 -210
- package/dist/tools/builtins/sandbox/task-stop.d.ts +2 -2
- package/dist/tools/builtins/sandbox/task-stop.js +15 -26
- package/dist/tools/pipeline.d.ts +31 -2
- package/dist/tools/pipeline.js +273 -43
- package/dist/tools/registry.d.ts +7 -0
- package/package.json +4 -4
- package/src/migrations/0162_permission_call_escalation.sql +9 -0
- package/dist/background/status.d.ts +0 -35
- package/dist/background/status.js +0 -57
|
@@ -7,15 +7,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { parseDeviceFrame, parseOperationResult, parseSandboxBrowseScope, parseSandboxOperationScope, parseSandboxPreparationScope, SandboxPermissionUnsupportedError, } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
|
-
import { projectsUnsupported } from "../devices/errors.js";
|
|
13
|
-
import { ApiError } from "../errors.js";
|
|
14
12
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
15
|
-
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
16
13
|
import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
|
|
17
14
|
import { deviceNotFound, SandboxService } from "../sandbox/sandbox.service.js";
|
|
18
|
-
import { grantsWithin,
|
|
15
|
+
import { grantsWithin, relayer } from "./network-grants.js";
|
|
19
16
|
import { deviceOffline, LocalDeviceRelay } from "./relay.js";
|
|
20
17
|
import { DeviceTargets, sameRoots } from "./targets.js";
|
|
21
18
|
/** Extra time the machine gets beyond a command's own timeout (spawn, output, the trip back). */
|
|
@@ -33,14 +30,8 @@ export { projectsUnsupported } from "../devices/errors.js";
|
|
|
33
30
|
export const maxReadBytes = (maxFrameBytes) => Math.max(0, Math.floor((maxFrameBytes - FRAME_ENVELOPE_BYTES) / 4) * 3);
|
|
34
31
|
const NAME_PREFIX = "cap-device-";
|
|
35
32
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* machine switched locally is refused at the next command.
|
|
39
|
-
*/
|
|
40
|
-
export const AUTO_MODE_NOT_ALLOWED_TEXT = "This device's machine runs in auto mode, which your organization does not allow. Run `capybara-device mode sandbox` on that machine to switch it to sandbox mode.";
|
|
41
|
-
/**
|
|
42
|
-
* A raw protocol 2 method on the staged provider: refused before anything is queued (a v3
|
|
43
|
-
* machine runs work only under an admitted operation scope; there is no raw fallback).
|
|
33
|
+
* A raw protocol 2 method: refused before anything is queued (a v3 machine runs work only under
|
|
34
|
+
* an admitted operation scope; there is no raw fallback).
|
|
44
35
|
*/
|
|
45
36
|
const refuseRaw = (method) => async (..._args) => {
|
|
46
37
|
throw new SandboxPermissionUnsupportedError(`${method} without an operation scope is not available on a protocol 3 device; run it through an admitted operation scope`);
|
|
@@ -66,18 +57,14 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
66
57
|
targets;
|
|
67
58
|
sandbox;
|
|
68
59
|
config;
|
|
69
|
-
grants;
|
|
70
|
-
log;
|
|
71
60
|
callGrants;
|
|
72
61
|
concurrentExec = true;
|
|
73
62
|
sessionIsolation = false;
|
|
74
|
-
constructor(relay, targets, sandbox, config,
|
|
63
|
+
constructor(relay, targets, sandbox, config, callGrants) {
|
|
75
64
|
this.relay = relay;
|
|
76
65
|
this.targets = targets;
|
|
77
66
|
this.sandbox = sandbox;
|
|
78
67
|
this.config = config;
|
|
79
|
-
this.grants = grants;
|
|
80
|
-
this.log = log;
|
|
81
68
|
this.callGrants = callGrants;
|
|
82
69
|
}
|
|
83
70
|
/**
|
|
@@ -92,15 +79,12 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
92
79
|
* missing operation support never falls back to them.
|
|
93
80
|
*
|
|
94
81
|
* A v3 machine has no `killAll` / `killTagged` (permission runtime cutover B-1), so both are
|
|
95
|
-
* no-ops that queue nothing
|
|
96
|
-
* exactly (`revokeOperation` per intent): `SandboxService`
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* the dead tokens, not the started-or-unknown intents of live holders of the instance; and
|
|
102
|
-
* tokens `claimDeadHolders` already deleted are lost when `revokeHolders` then throws. Revoking
|
|
103
|
-
* every started-or-unknown intent of the generation on a v3 resume is W5-P3a's kernel change.
|
|
82
|
+
* no-ops that queue nothing; the kernel never calls them anyway. What reaches the machine is
|
|
83
|
+
* only what the kernel revokes exactly (`revokeOperation` per intent): `SandboxService` owes a
|
|
84
|
+
* crashed holder's revocation in an outbox row before it forgets the holder record, revokes that
|
|
85
|
+
* holder's admitted, dispatching and started-or-unknown intents, and, under the exclusive lease
|
|
86
|
+
* on an incarnation nobody else holds (a resume, a failed limits change, a quarantine), every
|
|
87
|
+
* started-or-unknown intent of that generation; the owed revokes are delivered by operation id.
|
|
104
88
|
*/
|
|
105
89
|
staged(transport) {
|
|
106
90
|
const ops = this.stagedOperations(transport);
|
|
@@ -108,21 +92,9 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
108
92
|
...ops,
|
|
109
93
|
create: async (args) => {
|
|
110
94
|
const id = args.fileSystem.id;
|
|
111
|
-
const r =
|
|
95
|
+
const r = parseOperationResult("create", await transport.call(id, "create", { limits: args.limits }, { deadlineMs: OP_DEADLINE_MS, signal: args.signal }));
|
|
112
96
|
return { id, roots: r.roots, limits: args.limits };
|
|
113
97
|
},
|
|
114
|
-
exec: refuseRaw("exec"),
|
|
115
|
-
readFile: refuseRaw("readFile"),
|
|
116
|
-
writeFile: refuseRaw("writeFile"),
|
|
117
|
-
stat: refuseRaw("stat"),
|
|
118
|
-
list: refuseRaw("list"),
|
|
119
|
-
scan: refuseRaw("scan"),
|
|
120
|
-
killAll: async (_h, signal) => {
|
|
121
|
-
signal.throwIfAborted();
|
|
122
|
-
},
|
|
123
|
-
killTagged: async (_h, _tags, signal) => {
|
|
124
|
-
signal.throwIfAborted();
|
|
125
|
-
},
|
|
126
98
|
};
|
|
127
99
|
// the shared lifecycle methods keep this provider as their receiver (relay, targets, config)
|
|
128
100
|
return Object.assign(Object.create(this), overrides);
|
|
@@ -133,7 +105,7 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
133
105
|
const send = async (op, args, signal) => {
|
|
134
106
|
const name = (prefix ? prefix + op.charAt(0).toUpperCase() + op.slice(1) : op);
|
|
135
107
|
const result = await transport.call(h.id, name, { scope, ...args }, { deadlineMs: OP_DEADLINE_MS, signal: AbortSignal.any([factorySignal, signal]) });
|
|
136
|
-
return
|
|
108
|
+
return parseOperationResult(name, result);
|
|
137
109
|
};
|
|
138
110
|
return {
|
|
139
111
|
exec: async () => {
|
|
@@ -171,15 +143,16 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
171
143
|
const background = {
|
|
172
144
|
start: async (h, input, args) => {
|
|
173
145
|
const scope = parseSandboxOperationScope(input);
|
|
174
|
-
|
|
146
|
+
// the device knows its bound generation: a kernel generation never goes on the wire
|
|
147
|
+
const { signal, instanceGeneration: _generation, ...rest } = args;
|
|
175
148
|
const authority = await execArgs(h.id, scope, "backgroundStart", rest);
|
|
176
149
|
signal.throwIfAborted();
|
|
177
|
-
return
|
|
150
|
+
return parseOperationResult("backgroundStart", await transport.call(h.id, "backgroundStart", { scope, ...rest, ...authority }, { deadlineMs: args.timeoutMs + EXEC_DEADLINE_MARGIN_MS, signal }));
|
|
178
151
|
},
|
|
179
|
-
status: async (h, ref, signal) =>
|
|
152
|
+
status: async (h, ref, signal) => parseOperationResult("backgroundStatus", await transport.call(h.id, "backgroundStatus", { ref }, { deadlineMs: OP_DEADLINE_MS, signal })),
|
|
180
153
|
readOutput: async (h, ref, opts) => {
|
|
181
154
|
opts.signal.throwIfAborted();
|
|
182
|
-
|
|
155
|
+
parseDeviceFrame(JSON.stringify({
|
|
183
156
|
type: "req",
|
|
184
157
|
id: "validate",
|
|
185
158
|
op: "backgroundReadOutput",
|
|
@@ -190,7 +163,7 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
190
163
|
const connection = await this.relay.connection(h.id);
|
|
191
164
|
const capacity = Math.min(65536, maxReadBytes(connection.maxFrameBytes));
|
|
192
165
|
const request = { ref, offset: opts.offset, maxBytes: Math.min(opts.maxBytes, capacity) };
|
|
193
|
-
const result =
|
|
166
|
+
const result = parseOperationResult("backgroundReadOutput", await transport.call(h.id, "backgroundReadOutput", request, {
|
|
194
167
|
deadlineMs: OP_DEADLINE_MS,
|
|
195
168
|
signal: opts.signal,
|
|
196
169
|
connection,
|
|
@@ -208,10 +181,10 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
208
181
|
};
|
|
209
182
|
},
|
|
210
183
|
tail: async (h, ref, opts) => {
|
|
211
|
-
const r =
|
|
184
|
+
const r = parseOperationResult("backgroundTail", await transport.call(h.id, "backgroundTail", { ref, maxBytes: opts.maxBytes }, { deadlineMs: OP_DEADLINE_MS, signal: opts.signal }));
|
|
212
185
|
return "unavailable" in r ? r : { data: bytesOf(r.dataB64), truncated: r.truncated };
|
|
213
186
|
},
|
|
214
|
-
stop: async (h, ref, opts) =>
|
|
187
|
+
stop: async (h, ref, opts) => parseOperationResult("backgroundStop", await transport.call(h.id, "backgroundStop", { ref, graceMs: opts.graceMs }, { deadlineMs: OP_DEADLINE_MS, signal: opts.signal })),
|
|
215
188
|
};
|
|
216
189
|
return {
|
|
217
190
|
permissionSupport: (h, signal) => transport.permissionSupport(h.id, signal),
|
|
@@ -225,7 +198,15 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
225
198
|
const authority = await execArgs(h.id, scope, "exec", rest);
|
|
226
199
|
const combined = AbortSignal.any([signal, callSignal]);
|
|
227
200
|
combined.throwIfAborted();
|
|
228
|
-
|
|
201
|
+
const result = parseOperationResult("exec", await transport.call(h.id, "exec", { scope, ...rest, ...authority }, { deadlineMs: args.timeoutMs + EXEC_DEADLINE_MARGIN_MS, signal: combined }));
|
|
202
|
+
// the kernel's own layer for the machine's report, as on protocol 2: a host the org
|
|
203
|
+
// does not allow is `org` (only an admin can lift it), never a question to the owner
|
|
204
|
+
if (result.network?.blocked === undefined)
|
|
205
|
+
return result;
|
|
206
|
+
return {
|
|
207
|
+
...result,
|
|
208
|
+
network: { blocked: relayer(result.network.blocked, authority.limits) },
|
|
209
|
+
};
|
|
229
210
|
},
|
|
230
211
|
};
|
|
231
212
|
},
|
|
@@ -290,114 +271,20 @@ let LocalDeviceProvider = class LocalDeviceProvider {
|
|
|
290
271
|
async destroyByName(_name, signal) {
|
|
291
272
|
signal.throwIfAborted();
|
|
292
273
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
296
|
-
async killTagged(h, tags, signal) {
|
|
297
|
-
await this.relay.call(h.id, "killTagged", { tags }, { deadlineMs: OP_DEADLINE_MS, signal });
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Runs the command on the machine with the org's limits now (ruling R27) and, for a command of a
|
|
301
|
-
* run, the hosts the kernel allows that run on this device beyond the local policy (network
|
|
302
|
-
* ask-to-allow spec §6.3; only those the org's limits admit, sent only when there are some). The
|
|
303
|
-
* device's report of refused hosts is re-layered against the limits this exec carried: the
|
|
304
|
-
* kernel never takes the device's word that the org allows a host (auto mode spec §4.2).
|
|
305
|
-
*
|
|
306
|
-
* The exec args carry `mode: allowedMode` (the machine cuts its own choice to it), the
|
|
307
|
-
* sandbox-mode allowlist and the run's grants. A machine whose local policy is auto mode while
|
|
308
|
-
* the organization allows only sandbox mode is refused at every exec
|
|
309
|
-
* (`device.auto_mode_not_allowed`), before anything is relayed to it.
|
|
310
|
-
*/
|
|
311
|
-
async exec(h, args) {
|
|
312
|
-
const { signal, ...rest } = args;
|
|
274
|
+
/** A v3 machine has no broad kill (permission runtime cutover B-1): nothing is queued. */
|
|
275
|
+
async killAll(_h, signal) {
|
|
313
276
|
signal.throwIfAborted();
|
|
314
|
-
const runId = rest.actor?.runId;
|
|
315
|
-
const { orgId, limits } = await this.currentLimits(h.id);
|
|
316
|
-
// the run's grants for this device, cut to what the org allows now
|
|
317
|
-
const grants = runId !== undefined
|
|
318
|
-
? grantsWithin(await this.grants.forExec({ orgId, runId, deviceId: h.id }), limits)
|
|
319
|
-
: undefined;
|
|
320
|
-
signal.throwIfAborted();
|
|
321
|
-
let result;
|
|
322
|
-
try {
|
|
323
|
-
result = await this.relay.call(h.id, "exec", { ...rest, limits, ...(grants !== undefined && { grants }) }, { deadlineMs: args.timeoutMs + EXEC_DEADLINE_MARGIN_MS, signal });
|
|
324
|
-
}
|
|
325
|
-
catch (e) {
|
|
326
|
-
// the contract: an exec aborted after it was sent resolves with exitCode null (the relay
|
|
327
|
-
// queued a cancel, which kills the command on the machine); the output stays there
|
|
328
|
-
if (signal.aborted && e === signal.reason) {
|
|
329
|
-
return { exitCode: null, stdout: "", stderr: "", truncated: false, timedOut: false };
|
|
330
|
-
}
|
|
331
|
-
throw e;
|
|
332
|
-
}
|
|
333
|
-
if (result.network?.blocked === undefined)
|
|
334
|
-
return result;
|
|
335
|
-
return { ...result, network: { blocked: relayer(result.network.blocked, limits) } };
|
|
336
|
-
}
|
|
337
|
-
async readFile(h, path, opts) {
|
|
338
|
-
const { limits } = await this.currentLimits(h.id);
|
|
339
|
-
// the answer must fit one frame: a larger file comes back truncated (Deliver: too large)
|
|
340
|
-
const maxBytes = Math.min(opts.maxBytes, maxReadBytes(this.config.get().devices.local.maxFrameBytes));
|
|
341
|
-
const r = await this.relay.call(h.id, "readFile", { path, maxBytes, limits: { mode: limits.mode } }, { deadlineMs: OP_DEADLINE_MS, signal: opts.signal });
|
|
342
|
-
return r === null ? null : { data: bytesOf(r.dataB64), truncated: r.truncated };
|
|
343
|
-
}
|
|
344
|
-
async writeFile(h, path, data, signal) {
|
|
345
|
-
const dataB64 = Buffer.from(data.buffer, data.byteOffset, data.byteLength).toString("base64");
|
|
346
|
-
await this.relay.call(h.id, "writeFile", { path, dataB64 }, { deadlineMs: OP_DEADLINE_MS, signal });
|
|
347
277
|
}
|
|
348
|
-
async
|
|
349
|
-
|
|
350
|
-
return this.relay.call(h.id, "stat", { path, limits: { mode: limits.mode } }, { deadlineMs: OP_DEADLINE_MS, signal });
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Lists one directory on the machine (the `list` op, project root §4.1), read in the mode the
|
|
354
|
-
* kernel's current ceiling gives. A machine that did not announce `projects` throws
|
|
355
|
-
* `device.projects_unsupported` (never null, which would read as "does not exist").
|
|
356
|
-
*/
|
|
357
|
-
async list(h, path, opts) {
|
|
358
|
-
await this.requireProjects(h.id);
|
|
359
|
-
opts.signal.throwIfAborted();
|
|
360
|
-
return this.relay.call(h.id, "list", { path, limit: opts.limit, limits: { mode: opts.limits.mode } }, { deadlineMs: OP_DEADLINE_MS, signal: opts.signal });
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Looks for project-like directories under `base` on the machine (the `scan` op, project root
|
|
364
|
-
* §4.1), read in the mode the kernel's current ceiling gives. A machine that did not announce
|
|
365
|
-
* `projects` throws `device.projects_unsupported`.
|
|
366
|
-
*/
|
|
367
|
-
async scan(h, base, opts) {
|
|
368
|
-
await this.requireProjects(h.id);
|
|
369
|
-
opts.signal.throwIfAborted();
|
|
370
|
-
return this.relay.call(h.id, "scan", { base, limits: { mode: opts.limits.mode } }, { deadlineMs: OP_DEADLINE_MS, signal: opts.signal });
|
|
371
|
-
}
|
|
372
|
-
/** The kernel never sends `list` or `scan` to a machine that did not announce `projects`. */
|
|
373
|
-
async requireProjects(deviceId) {
|
|
374
|
-
if (!(await this.targets.machineFeatures(deviceId)).includes("projects")) {
|
|
375
|
-
throw projectsUnsupported(true);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* The device's org and current limits for an exec or file read (ruling R27): the effective policy's
|
|
380
|
-
* `allowedMode` and the sandbox-mode allowlist. A deleted device is not found. A machine whose
|
|
381
|
-
* local policy is auto mode while the organization allows only sandbox mode is refused here, at
|
|
382
|
-
* every such operation, so a machine switched locally is not used until it is switched back.
|
|
383
|
-
*/
|
|
384
|
-
async currentLimits(deviceId) {
|
|
385
|
-
const orgId = await this.targets.orgOf(deviceId);
|
|
386
|
-
if (orgId === null)
|
|
387
|
-
throw deviceNotFound();
|
|
388
|
-
const [policy, reported] = await Promise.all([
|
|
389
|
-
this.sandbox.devicePolicy({ orgId, deviceId }),
|
|
390
|
-
this.grants.reportedMode(deviceId),
|
|
391
|
-
]);
|
|
392
|
-
if (policy.allowedMode === "sandbox" && reported === "auto") {
|
|
393
|
-
this.log.warn("device operation refused on a machine that reports auto mode", { deviceId });
|
|
394
|
-
throw new ApiError("device.auto_mode_not_allowed", AUTO_MODE_NOT_ALLOWED_TEXT);
|
|
395
|
-
}
|
|
396
|
-
return {
|
|
397
|
-
orgId,
|
|
398
|
-
limits: await this.sandbox.deviceLimits({ orgId, deviceId }, { policy, source: "local" }),
|
|
399
|
-
};
|
|
278
|
+
async killTagged(_h, _tags, signal) {
|
|
279
|
+
signal.throwIfAborted();
|
|
400
280
|
}
|
|
281
|
+
// The raw protocol 2 methods: a v3 machine runs work only under an admitted operation scope
|
|
282
|
+
exec = refuseRaw("exec");
|
|
283
|
+
readFile = refuseRaw("readFile");
|
|
284
|
+
writeFile = refuseRaw("writeFile");
|
|
285
|
+
stat = refuseRaw("stat");
|
|
286
|
+
list = refuseRaw("list");
|
|
287
|
+
scan = refuseRaw("scan");
|
|
401
288
|
};
|
|
402
289
|
LocalDeviceProvider = __decorate([
|
|
403
290
|
Injectable(),
|
|
@@ -405,9 +292,7 @@ LocalDeviceProvider = __decorate([
|
|
|
405
292
|
__param(1, Inject(DeviceTargets)),
|
|
406
293
|
__param(2, Inject(SandboxService)),
|
|
407
294
|
__param(3, Inject(KernelConfigService)),
|
|
408
|
-
__param(4,
|
|
409
|
-
__param(
|
|
410
|
-
__param(6, Optional()),
|
|
411
|
-
__param(6, Inject(PermissionCallGrants))
|
|
295
|
+
__param(4, Optional()),
|
|
296
|
+
__param(4, Inject(PermissionCallGrants))
|
|
412
297
|
], LocalDeviceProvider);
|
|
413
298
|
export { LocalDeviceProvider };
|
|
@@ -3,7 +3,6 @@ import { type SandboxProviderEntry, SandboxProviders } from "../sandbox/provider
|
|
|
3
3
|
import { LocalInstanceBindings } from "./instance-bindings.js";
|
|
4
4
|
import { LocalDeviceProvider } from "./local-device-provider.js";
|
|
5
5
|
import { LocalDeviceRelay } from "./relay.js";
|
|
6
|
-
export { stagedDeviceProtocolActive } from "./relay.js";
|
|
7
6
|
/**
|
|
8
7
|
* Connected machines (environments spec §6, §13): the caller side of the device relay and the
|
|
9
8
|
* kernel-internal `@local` sandbox provider, registered with {@link SandboxProviders} on init, and
|
|
@@ -21,11 +20,11 @@ export declare class LocalDevicesModule implements OnModuleInit {
|
|
|
21
20
|
onModuleInit(): void;
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
|
-
* The `@local` registration: protocol
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* The `@local` registration: the protocol 3 provider ({@link LocalDeviceProvider.staged}: scoped
|
|
24
|
+
* operations, no broad kill) with its instance binder, which binds every committed generation
|
|
25
|
+
* before shared use (B-8).
|
|
27
26
|
*/
|
|
28
|
-
export declare function localProviderEntry(
|
|
27
|
+
export declare function localProviderEntry(deps: {
|
|
29
28
|
provider: LocalDeviceProvider;
|
|
30
29
|
relay: LocalDeviceRelay;
|
|
31
30
|
bindings: LocalInstanceBindings;
|
|
@@ -19,9 +19,8 @@ import { MachinesService } from "./machines.js";
|
|
|
19
19
|
import { NetworkGrants } from "./network-grants.js";
|
|
20
20
|
import { NetworkGrantsModule } from "./network-grants.module.js";
|
|
21
21
|
import { OwnerReports } from "./owner-reports.js";
|
|
22
|
-
import { LocalDeviceRelay
|
|
22
|
+
import { LocalDeviceRelay } from "./relay.js";
|
|
23
23
|
import { DeviceTargets } from "./targets.js";
|
|
24
|
-
export { stagedDeviceProtocolActive } from "./relay.js";
|
|
25
24
|
/**
|
|
26
25
|
* Connected machines (environments spec §6, §13): the caller side of the device relay and the
|
|
27
26
|
* kernel-internal `@local` sandbox provider, registered with {@link SandboxProviders} on init, and
|
|
@@ -42,7 +41,7 @@ let LocalDevicesModule = class LocalDevicesModule {
|
|
|
42
41
|
this.bindings = bindings;
|
|
43
42
|
}
|
|
44
43
|
onModuleInit() {
|
|
45
|
-
this.providers.register(localProviderEntry(
|
|
44
|
+
this.providers.register(localProviderEntry({
|
|
46
45
|
provider: this.provider,
|
|
47
46
|
relay: this.relay,
|
|
48
47
|
bindings: this.bindings,
|
|
@@ -83,13 +82,11 @@ LocalDevicesModule = __decorate([
|
|
|
83
82
|
], LocalDevicesModule);
|
|
84
83
|
export { LocalDevicesModule };
|
|
85
84
|
/**
|
|
86
|
-
* The `@local` registration: protocol
|
|
87
|
-
*
|
|
88
|
-
*
|
|
85
|
+
* The `@local` registration: the protocol 3 provider ({@link LocalDeviceProvider.staged}: scoped
|
|
86
|
+
* operations, no broad kill) with its instance binder, which binds every committed generation
|
|
87
|
+
* before shared use (B-8).
|
|
89
88
|
*/
|
|
90
|
-
export function localProviderEntry(
|
|
91
|
-
if (!staged)
|
|
92
|
-
return { plugin: LOCAL_PROVIDER, impl: deps.provider };
|
|
89
|
+
export function localProviderEntry(deps) {
|
|
93
90
|
return {
|
|
94
91
|
plugin: LOCAL_PROVIDER,
|
|
95
92
|
impl: deps.provider.staged({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DeviceFeature,
|
|
2
|
-
import { type
|
|
1
|
+
import type { DeviceFeature, DeviceLocalPolicySummary, DeviceStopArgs, ExtensionContext, LegacyDeviceHello } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { type DeviceHello, type DeviceOwnerCeiling } from "@capybara-hq/plugin-sdk";
|
|
3
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
4
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
5
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
@@ -100,10 +100,10 @@ export declare class MachinesService {
|
|
|
100
100
|
* platform's ops still pending on the row ({@link backfillOps}). The owner's home directory
|
|
101
101
|
* (`home`) replaces the stored one too (null when the hello has none).
|
|
102
102
|
*/
|
|
103
|
-
recordHello(machineId: string, hello:
|
|
103
|
+
recordHello(machineId: string, hello: LegacyDeviceHello, rawPolicy?: unknown,
|
|
104
104
|
/** A v3 hello's authenticated owner report (B2): it, not the summary, decides publication. */
|
|
105
105
|
owner?: {
|
|
106
|
-
report:
|
|
106
|
+
report: DeviceOwnerCeiling;
|
|
107
107
|
connectionId: string | null;
|
|
108
108
|
}): Promise<void>;
|
|
109
109
|
/**
|
|
@@ -119,7 +119,7 @@ export declare class MachinesService {
|
|
|
119
119
|
*/
|
|
120
120
|
private backfillOps;
|
|
121
121
|
/** Dormant authenticated hello adapter; the active gateway still accepts only protocol 2. */
|
|
122
|
-
recordHelloV3(machineId: string, hello:
|
|
122
|
+
recordHelloV3(machineId: string, hello: DeviceHello, connectionId?: string | null): Promise<void>;
|
|
123
123
|
/**
|
|
124
124
|
* The runtime identity a v3 hello may attest (B4): only a bound hello re-reporting exactly the
|
|
125
125
|
* identity of the current instance generation's installed binding. An unbound hello, another
|
|
@@ -148,7 +148,7 @@ export declare class MachinesService {
|
|
|
148
148
|
* null. When both the stored and the reported summary are readable and what the owner sets
|
|
149
149
|
* changed ({@link localPolicyDiff}) by no `policy` op the platform sent ({@link opExplains}: its
|
|
150
150
|
* answer may come after the machine's own report), the owner changed it on the machine
|
|
151
|
-
* (`capybara-device
|
|
151
|
+
* (`capybara-device ceiling set ...`): the host changes are audited
|
|
152
152
|
* `device.policy_changed` and the mode change `device.mode_changed`, both `via: "device"`, so the
|
|
153
153
|
* device page lists them beside the platform's changes; one an op explains is not audited here
|
|
154
154
|
* (the op's answer is). A summary reported again is no change. Runs in the caller's transaction,
|
|
@@ -8,7 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { randomBytes } from "node:crypto";
|
|
11
|
-
import {
|
|
11
|
+
import { parseDeviceFrame, } from "@capybara-hq/plugin-sdk";
|
|
12
12
|
import { Inject, Injectable } from "@nestjs/common";
|
|
13
13
|
import { sql } from "kysely";
|
|
14
14
|
import { audit } from "../identity/audit.js";
|
|
@@ -347,7 +347,7 @@ let MachinesService = class MachinesService {
|
|
|
347
347
|
}
|
|
348
348
|
/** Dormant authenticated hello adapter; the active gateway still accepts only protocol 2. */
|
|
349
349
|
async recordHelloV3(machineId, hello, connectionId = null) {
|
|
350
|
-
const parsed =
|
|
350
|
+
const parsed = parseDeviceFrame(JSON.stringify(hello), "device");
|
|
351
351
|
if (parsed.type !== "hello")
|
|
352
352
|
throw new Error("Expected a validated operation hello");
|
|
353
353
|
await this.recordHello(machineId, parsed, parsed.policy, {
|
|
@@ -446,7 +446,7 @@ let MachinesService = class MachinesService {
|
|
|
446
446
|
* while the authenticated owner report alone decides what changed ({@link OwnerReports}).
|
|
447
447
|
*/
|
|
448
448
|
async recordPolicyV3(machineId, frame, connectionId = null) {
|
|
449
|
-
const parsed =
|
|
449
|
+
const parsed = parseDeviceFrame(JSON.stringify(frame), "device");
|
|
450
450
|
if (parsed.type !== "policy")
|
|
451
451
|
throw new Error("Expected a validated policy frame");
|
|
452
452
|
const subject = await this.db
|
|
@@ -475,7 +475,7 @@ let MachinesService = class MachinesService {
|
|
|
475
475
|
* null. When both the stored and the reported summary are readable and what the owner sets
|
|
476
476
|
* changed ({@link localPolicyDiff}) by no `policy` op the platform sent ({@link opExplains}: its
|
|
477
477
|
* answer may come after the machine's own report), the owner changed it on the machine
|
|
478
|
-
* (`capybara-device
|
|
478
|
+
* (`capybara-device ceiling set ...`): the host changes are audited
|
|
479
479
|
* `device.policy_changed` and the mode change `device.mode_changed`, both `via: "device"`, so the
|
|
480
480
|
* device page lists them beside the platform's changes; one an op explains is not audited here
|
|
481
481
|
* (the op's answer is). A summary reported again is no change. Runs in the caller's transaction,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type DeviceOwnerCeiling, type SandboxBrowseScope, type SandboxOperationScope } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
/** How far restricted (non-Full) operations and project browsing may reach on a machine. */
|
|
3
3
|
export type RestrictedProjectReach = "workspace" | "os-user";
|
|
4
4
|
/** Which message carried a report (audit and diagnostics only). */
|
|
@@ -8,7 +8,7 @@ export type OwnerReportVia = "hello" | "policy" | "policy-result" | "bind";
|
|
|
8
8
|
* strict report, the connection and time it arrived, and a block set by an out-of-order report.
|
|
9
9
|
*/
|
|
10
10
|
export interface StoredOwnerReport {
|
|
11
|
-
report:
|
|
11
|
+
report: DeviceOwnerCeiling;
|
|
12
12
|
connectionId: string | null;
|
|
13
13
|
observedAt: string;
|
|
14
14
|
via: OwnerReportVia;
|
|
@@ -26,7 +26,7 @@ export declare function storedOwnerReportOf(v: unknown): StoredOwnerReport | nul
|
|
|
26
26
|
* same sequence, revision and bytes is idempotent; a lower sequence is stale; the same sequence
|
|
27
27
|
* with other bytes is a protocol conflict.
|
|
28
28
|
*/
|
|
29
|
-
export declare function decideOwnerReport(stored: StoredOwnerReport | null, incoming:
|
|
29
|
+
export declare function decideOwnerReport(stored: StoredOwnerReport | null, incoming: DeviceOwnerCeiling): "record" | "same" | "stale" | "conflict";
|
|
30
30
|
/**
|
|
31
31
|
* The owner facts the kernel decides with (B2), never inferred wider than reported:
|
|
32
32
|
* - `report`: an authenticated version-2 report (Full and reach independent);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseOwnerCeilingReport, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { coversHost } from "../sandbox/modes.js";
|
|
3
|
-
import { isExecutionMethod } from "../sandbox/operation-authority-types.js";
|
|
3
|
+
import { isExecutionMethod, isFullExecutionScope } from "../sandbox/operation-authority-types.js";
|
|
4
4
|
import { localModeOf, localPolicyOf } from "./policy-summary.js";
|
|
5
5
|
/** The stored report in `v`, or null (absent or malformed: never trusted). */
|
|
6
6
|
export function storedOwnerReportOf(v) {
|
|
@@ -9,7 +9,7 @@ export function storedOwnerReportOf(v) {
|
|
|
9
9
|
const o = v;
|
|
10
10
|
let report;
|
|
11
11
|
try {
|
|
12
|
-
report =
|
|
12
|
+
report = parseOwnerCeilingReport(o.report);
|
|
13
13
|
}
|
|
14
14
|
catch {
|
|
15
15
|
return null;
|
|
@@ -117,7 +117,7 @@ export function ownerReportRevokes(next, scope, method, grantedHosts, machineRoo
|
|
|
117
117
|
const inMachine = (root) => machineRoots.some((r) => within(root, r));
|
|
118
118
|
if (!("profile" in scope))
|
|
119
119
|
return (next.restrictedProjectReach === "workspace" && scope.readRoots.some((r) => !inMachine(r)));
|
|
120
|
-
if (scope
|
|
120
|
+
if (isFullExecutionScope(scope))
|
|
121
121
|
return !next.fullAccess;
|
|
122
122
|
if (next.restrictedProjectReach === "workspace" && outsideMachineRoots(scope, machineRoots))
|
|
123
123
|
return true;
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { parseOwnerCeilingReport } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { audit } from "../identity/audit.js";
|
|
13
13
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -54,7 +54,7 @@ let OwnerReports = class OwnerReports {
|
|
|
54
54
|
* which already resets Full consent and revokes everything (folded into one publication).
|
|
55
55
|
*/
|
|
56
56
|
async recordLocked(machineId, raw, meta) {
|
|
57
|
-
const report =
|
|
57
|
+
const report = parseOwnerCeilingReport(raw);
|
|
58
58
|
const row = await this.db
|
|
59
59
|
.selectFrom("device_machines")
|
|
60
60
|
.select([
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { coversHost } from "../sandbox/modes.js";
|
|
2
|
-
import { isExecutionMethod } from "../sandbox/operation-authority-types.js";
|
|
2
|
+
import { isExecutionMethod, isFullExecutionScope } from "../sandbox/operation-authority-types.js";
|
|
3
3
|
const KNOWN_FEATURES = [
|
|
4
4
|
"networkReport",
|
|
5
5
|
"policyOp",
|
|
@@ -191,7 +191,7 @@ export function ownerPolicyRevokes(next, scope, method, grantedHosts) {
|
|
|
191
191
|
return true;
|
|
192
192
|
if (!("profile" in scope))
|
|
193
193
|
return next.mode !== "auto" && scope.readRoots.includes("/");
|
|
194
|
-
if (scope
|
|
194
|
+
if (isFullExecutionScope(scope))
|
|
195
195
|
return next.mode !== "auto";
|
|
196
196
|
if (!isExecutionMethod(method) || scope.network.kind !== "allowlist")
|
|
197
197
|
return false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DeviceOp, type
|
|
1
|
+
import { type DeviceOp, type DeviceOperation, type DeviceOpResults, DeviceProtocolError, type DeviceStopArgs, type ExtensionContext } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
3
|
import { ApiError } from "../errors.js";
|
|
4
4
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
@@ -8,11 +8,7 @@ import { DeviceRequestNotSentError, isDeviceRequestNotSent } from "../sandbox/re
|
|
|
8
8
|
import { DeviceTargets } from "./targets.js";
|
|
9
9
|
/** The device's connected machine is not connected (no replica holds its lease). */
|
|
10
10
|
export declare const deviceOffline: () => ApiError;
|
|
11
|
-
|
|
12
|
-
* The device's machine was disconnected (revoked, signed out): 403 `device.forbidden`
|
|
13
|
-
* with `details: [{ reason: "machine_revoked" }]`, so the tools tell the model what to ask for.
|
|
14
|
-
*/
|
|
15
|
-
export declare const machineRevoked: () => ApiError;
|
|
11
|
+
export { machineRevoked } from "../devices/errors.js";
|
|
16
12
|
/** The text a machine's `policy` refusal reaches the model with. */
|
|
17
13
|
export declare const POLICY_REFUSAL_PREFIX = "Refused by the machine's local policy: ";
|
|
18
14
|
/** The text a machine's `error` result reaches the model with (ruling R28). */
|
|
@@ -28,11 +24,6 @@ export { DeviceRequestNotSentError, isDeviceRequestNotSent };
|
|
|
28
24
|
* before the frame goes out; a frame for another machine is dropped).
|
|
29
25
|
*/
|
|
30
26
|
export declare const STOP_MACHINE: "machineId";
|
|
31
|
-
/**
|
|
32
|
-
* Whether the deployment speaks the staged device protocol: the single gate is the SDK's protocol
|
|
33
|
-
* constant (flipped to 3 at the paired activation). Until then the active wire stays protocol 2.
|
|
34
|
-
*/
|
|
35
|
-
export declare const stagedDeviceProtocolActive: () => boolean;
|
|
36
27
|
/** The longest one lease check of a waiting caller may take before it counts as "unknown". */
|
|
37
28
|
export declare const LEASE_CHECK_TIMEOUT_MS = 2000;
|
|
38
29
|
/** How often a waiting caller checks that a replica still holds the machine's connection. */
|
|
@@ -77,9 +68,9 @@ export interface DeviceCallOptions {
|
|
|
77
68
|
* list and forwards the frames to the machine.
|
|
78
69
|
*
|
|
79
70
|
* **The holder's half of the wire** (Task 6 follows it): items on the list are `KernelReq` or
|
|
80
|
-
* `KernelCancel` frames as JSON text, to be parsed with `
|
|
71
|
+
* `KernelCancel` frames as JSON text, to be parsed with `parseLegacyDeviceFrame(item, "kernel")`; the
|
|
81
72
|
* nudge's payload is `{ id }`. For each `res` frame the machine sends, the holder writes the frame
|
|
82
|
-
* (the JSON text as validated by `
|
|
73
|
+
* (the JSON text as validated by `parseLegacyDeviceFrame(…, "device")`) under
|
|
83
74
|
* `capk:device-res:<requestId>` with a TTL and publishes the same frame object on
|
|
84
75
|
* `device.res.<requestId>`.
|
|
85
76
|
*
|
|
@@ -103,16 +94,9 @@ export declare class LocalDeviceRelay {
|
|
|
103
94
|
/** Whether a gateway replica holds the machine's connection now. */
|
|
104
95
|
holderLive(deviceId: string): Promise<boolean>;
|
|
105
96
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
stagedProtocolActive: () => boolean;
|
|
110
|
-
/**
|
|
111
|
-
* The negotiated transport of the device's connection when the platform's own controls (policy
|
|
112
|
-
* ops) must speak protocol 3 to it, else null (protocol 2). With the gate closed every
|
|
113
|
-
* connection is protocol 2: nothing is looked up (no lease or transport read per op). With it
|
|
114
|
-
* open every connection is staged, so this is {@link connection} (a missing or unready one
|
|
115
|
-
* throws its typed error).
|
|
97
|
+
* The negotiated transport of the device's connection for the platform's own controls (policy
|
|
98
|
+
* ops): every connection speaks protocol 3, so this is {@link connection} (a missing or unready
|
|
99
|
+
* one throws its typed error).
|
|
116
100
|
*/
|
|
117
101
|
stagedTransport(deviceId: string): Promise<{
|
|
118
102
|
connectionId: string;
|
|
@@ -147,8 +131,11 @@ export declare class LocalDeviceRelay {
|
|
|
147
131
|
* abort reason is thrown.
|
|
148
132
|
*/
|
|
149
133
|
call<Op extends DeviceOp>(deviceId: string, op: Op, args: unknown, opts: DeviceCallOptions): Promise<DeviceOpResults[Op]>;
|
|
150
|
-
/**
|
|
151
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Runs a protocol 3 operation on the device's machine over its current staged connection and
|
|
136
|
+
* returns its validated result; the request is checked against the protocol 3 codec first.
|
|
137
|
+
*/
|
|
138
|
+
callV3(deviceId: string, op: DeviceOperation, args: Record<string, unknown>, opts: DeviceCallOptions): Promise<unknown>;
|
|
152
139
|
private callWithCodec;
|
|
153
140
|
/** {@link holderLive}, or undefined when it takes longer than {@link LEASE_CHECK_TIMEOUT_MS}. */
|
|
154
141
|
private leaseCheck;
|