@capybara-hq/plugin-device-local 0.1.0-rc.1 → 0.1.0-rc.3
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/.capybara-plugin/plugin.json +3 -3
- package/README.md +19 -5
- package/dist/index.mjs +132 -31
- package/migrations/0002_shared_project_roots.sql +4 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"name": "device-local",
|
|
4
|
-
"version": "0.1.0-rc.
|
|
4
|
+
"version": "0.1.0-rc.3",
|
|
5
5
|
"publisher": "Capybara",
|
|
6
6
|
"description": {
|
|
7
7
|
"en": "Devices on people's own computers: a machine connected with capybara-device serves the device over the dial-in channel, and its owner limits it there",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"entry": "./dist/index.mjs",
|
|
24
24
|
"manifest": {
|
|
25
25
|
"name": "device-local",
|
|
26
|
-
"version": "0.1.0-rc.
|
|
26
|
+
"version": "0.1.0-rc.3",
|
|
27
27
|
"sdk": "^0.1.0-rc.56",
|
|
28
28
|
"provides": [
|
|
29
29
|
"device-provider@1"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"optional": [],
|
|
33
33
|
"permissions": {
|
|
34
34
|
"dialIn": {
|
|
35
|
-
"protocol": "capybara-device/
|
|
35
|
+
"protocol": "capybara-device/6"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"config": {
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Devices on people's own computers (`device-provider@1` over the kernel's dial-in channel). A machine
|
|
4
4
|
signs in with [`capybara-device`](https://www.npmjs.com/package/@capybara-hq/device) (protocol
|
|
5
|
-
`capybara-device/
|
|
5
|
+
`capybara-device/6`, declared as `permissions.dialIn`) and serves one device; every operation of the
|
|
6
6
|
device is relayed to it through `ctx.dialIn`. The kernel holds the machine's socket and relays the
|
|
7
7
|
frames without reading them; this plugin checks every request before it is sent and parses every
|
|
8
8
|
answer strictly (the machine is not trusted).
|
|
@@ -15,8 +15,8 @@ answer strictly (the machine is not trusted).
|
|
|
15
15
|
| `create` | `create` (ends the previous generation's background work, answers the directory's roots), then `bindInstance` of a new instance generation; the handle is handed out only once the machine attested the binding |
|
|
16
16
|
| `resume` | Needs the machine online. `create` again (ends any background work a suspension could not reach), then the identical `bindInstance`; `gone` when the roots changed (a new login into another directory or mode) or the machine can no longer hold the generation (its runtime changed) |
|
|
17
17
|
| `suspend` / `destroy` | `create` when the machine is online: the generation's tracked background work ends, files are kept. Never fails while the machine is offline |
|
|
18
|
-
| `operation` / `prepare` / `browse` / `background` / `revokeOperation` | The scoped protocol
|
|
19
|
-
| raw `exec` / `readFile` / … , `killAll` / `killTagged` | Refused or nothing: a protocol
|
|
18
|
+
| `operation` / `prepare` / `browse` / `background` / `revokeOperation` | The scoped protocol 6 operations, each with its admitted scope |
|
|
19
|
+
| raw `exec` / `readFile` / … , `killAll` / `killTagged` | Refused or nothing: a protocol 6 machine runs work only under an admitted operation scope |
|
|
20
20
|
|
|
21
21
|
A command carries the instance's resources and, as its outer network, the network the kernel
|
|
22
22
|
admitted for the operation (its scope); the machine intersects it with its owner's ceiling. The
|
|
@@ -55,14 +55,28 @@ generation under another runtime identity is refused (`local.invalid_hello`,
|
|
|
55
55
|
- **Attestation.** An unbound hello (the program restarted, typically under a new runtime after an
|
|
56
56
|
upgrade) marks the installed binding unattested: the instance is gone and the kernel recreates
|
|
57
57
|
it, which binds a new generation.
|
|
58
|
-
- **`report()`** answers from the rows only: a description of the owner's ceiling (reach
|
|
59
|
-
|
|
58
|
+
- **`report()`** answers from the rows only: a description of the owner's ceiling (project reach
|
|
59
|
+
`machine` / `paths` / `workspace`, always `workspace` in Docker mode; outside the sandbox;
|
|
60
|
+
network) in English and Chinese, the owner's home (OS mode), the machine's own
|
|
60
61
|
narrowing as read-only limits and `reset: false`. Its revision is a hash of everything it is made
|
|
61
62
|
of plus the machine epoch (moved when the machine is revoked or replaced), the instance
|
|
62
63
|
generation, its runtime identity and its stored support; times and connection ids are left out,
|
|
63
64
|
so a reconnect with the same facts keeps it. After a hello or event moved the revision the
|
|
64
65
|
provider calls `ctx.devices.reportChanged`; after a create or resume the kernel reads the report
|
|
65
66
|
again itself.
|
|
67
|
+
- **Shared project directories.** The machine's policy summary (hello and `policy` event) may carry
|
|
68
|
+
`sharedProjectRoots`: this connection's project directories another connection on the same
|
|
69
|
+
computer also uses, only those the owner listed in this connection's `projectPaths`, never naming
|
|
70
|
+
the other connection. The report lists them as "Also used by another connection on this
|
|
71
|
+
computer" (no line when none, or from an older device). They are left out of the revision: the
|
|
72
|
+
kernel moves the device authority epoch on every new revision and they change nothing the device
|
|
73
|
+
may do, so a change calls `ctx.devices.reportChanged` once with the revision kept and the kernel
|
|
74
|
+
stores the new text without invalidating approvals. A stale or conflicting `policy` event never
|
|
75
|
+
changes them; an unreadable summary keeps them.
|
|
76
|
+
- **Refused project paths.** A machine's `project_refused` outcome becomes
|
|
77
|
+
`ProjectPathRefusedError` with the fixed English and Chinese text of its refusal code
|
|
78
|
+
(`other-connection`, `outside-reach`, `denied`; `PROJECT_REFUSAL_TEXT`): the machine is not
|
|
79
|
+
trusted, so its message text never reaches the person.
|
|
66
80
|
- **`permissionSupport()`** answers from the rows only, never a machine round trip: the support the
|
|
67
81
|
machine attested for the installed binding, with outside-the-sandbox and the open public
|
|
68
82
|
internet narrowed to what the owner allows now (no open public internet while the owner's
|
package/dist/index.mjs
CHANGED
|
@@ -49,7 +49,7 @@ var canonicalReport = (r) => ({
|
|
|
49
49
|
outsideSandbox: r.outsideSandbox,
|
|
50
50
|
network: r.network,
|
|
51
51
|
allowedDomains: [...r.allowedDomains],
|
|
52
|
-
|
|
52
|
+
projectReach: r.projectReach
|
|
53
53
|
});
|
|
54
54
|
var sameOwnerReport = (a, b) => JSON.stringify(canonicalReport(a)) === JSON.stringify(canonicalReport(b));
|
|
55
55
|
function decideOwnerReport(stored, incoming) {
|
|
@@ -61,7 +61,7 @@ function decideOwnerReport(stored, incoming) {
|
|
|
61
61
|
}
|
|
62
62
|
var FAIL_CLOSED = {
|
|
63
63
|
outsideSandbox: false,
|
|
64
|
-
|
|
64
|
+
projectReach: "workspace",
|
|
65
65
|
allowedDomains: [],
|
|
66
66
|
network: "allowlist"
|
|
67
67
|
};
|
|
@@ -77,7 +77,7 @@ function ownerFactsOf(stored) {
|
|
|
77
77
|
return {
|
|
78
78
|
state: "report",
|
|
79
79
|
outsideSandbox: stored.report.outsideSandbox,
|
|
80
|
-
|
|
80
|
+
projectReach: stored.report.projectReach,
|
|
81
81
|
allowedDomains: [...stored.report.allowedDomains],
|
|
82
82
|
network: stored.report.network,
|
|
83
83
|
revision: stored.report.revision,
|
|
@@ -101,7 +101,12 @@ function applyOwnerReport(stored, incoming, via, now) {
|
|
|
101
101
|
|
|
102
102
|
// src/report.ts
|
|
103
103
|
import { createHash } from "node:crypto";
|
|
104
|
-
import {
|
|
104
|
+
import {
|
|
105
|
+
DEVICE_REPORT_LIMITS
|
|
106
|
+
} from "@capybara-hq/plugin-sdk";
|
|
107
|
+
import {
|
|
108
|
+
parseSandboxPermissionSupport
|
|
109
|
+
} from "@capybara-hq/plugin-sdk/device-protocol";
|
|
105
110
|
function closedSupport(unavailableReason) {
|
|
106
111
|
return parseSandboxPermissionSupport({
|
|
107
112
|
version: 2,
|
|
@@ -148,7 +153,7 @@ function revisionFacts(c, b) {
|
|
|
148
153
|
sequence: owner.sequence,
|
|
149
154
|
revision: owner.revision,
|
|
150
155
|
outsideSandbox: owner.outsideSandbox,
|
|
151
|
-
|
|
156
|
+
projectReach: owner.projectReach,
|
|
152
157
|
network: owner.network,
|
|
153
158
|
allowedDomains: [...owner.allowedDomains].sort()
|
|
154
159
|
}
|
|
@@ -167,7 +172,57 @@ function revisionFacts(c, b) {
|
|
|
167
172
|
};
|
|
168
173
|
}
|
|
169
174
|
var revisionOf = (c, b) => createHash("sha256").update(JSON.stringify(revisionFacts(c, b))).digest("hex");
|
|
175
|
+
function sharedRootsOf(policy, prev) {
|
|
176
|
+
if (!policy) return [...prev];
|
|
177
|
+
return [...new Set(policy.sharedProjectRoots ?? [])].sort();
|
|
178
|
+
}
|
|
179
|
+
var sameRoots = (a, b) => a.length === b.length && a.every((r, i) => r === b[i]);
|
|
180
|
+
var reportMoved = (before, after) => revisionOf(before.connection, before.binding) !== revisionOf(after.connection, after.binding) || !sameRoots(
|
|
181
|
+
before.connection?.sharedProjectRoots ?? [],
|
|
182
|
+
after.connection?.sharedProjectRoots ?? []
|
|
183
|
+
);
|
|
184
|
+
var SHARED_LABEL = {
|
|
185
|
+
en: "Also used by another connection on this computer",
|
|
186
|
+
zh: "本机的另一个连接也在使用"
|
|
187
|
+
};
|
|
188
|
+
function sharedRootsValue(roots) {
|
|
189
|
+
const max = DEVICE_REPORT_LIMITS.limitValueChars;
|
|
190
|
+
for (let k = roots.length; k >= 1; k--) {
|
|
191
|
+
const more2 = k < roots.length ? ` +${roots.length - k} more` : "";
|
|
192
|
+
const value = `${roots.slice(0, k).join(", ")}${more2}`;
|
|
193
|
+
if (value.length <= max) return value;
|
|
194
|
+
}
|
|
195
|
+
const more = roots.length > 1 ? ` +${roots.length - 1} more` : "";
|
|
196
|
+
const chars = Array.from(roots[0] ?? "");
|
|
197
|
+
let tail = "";
|
|
198
|
+
for (let i = chars.length - 1; i >= 0; i--) {
|
|
199
|
+
const next = `${chars[i]}${tail}`;
|
|
200
|
+
if (`…${next}${more}`.length > max) break;
|
|
201
|
+
tail = next;
|
|
202
|
+
}
|
|
203
|
+
return `…${tail}${more}`;
|
|
204
|
+
}
|
|
170
205
|
var hosts = (n) => n === 1 ? { en: "1 allowed host", zh: "允许 1 个主机" } : { en: `${n} allowed hosts`, zh: `允许 ${n} 个主机` };
|
|
206
|
+
var effectiveReach = (mode, reach) => mode === "docker" ? "workspace" : reach;
|
|
207
|
+
var READS = {
|
|
208
|
+
machine: {
|
|
209
|
+
en: "Reads the whole machine except secrets and other connections; writes only in the project and workspace",
|
|
210
|
+
zh: "读取本机全部文件(密钥和其他连接除外);只在项目和工作区写入"
|
|
211
|
+
},
|
|
212
|
+
paths: {
|
|
213
|
+
en: "Reads only the project directories the machine's owner listed; writes only in the project and workspace",
|
|
214
|
+
zh: "只读取本机所有者列出的项目目录;只在项目和工作区写入"
|
|
215
|
+
},
|
|
216
|
+
workspace: { en: "Reads and writes only the device's workspace", zh: "只读写设备的工作区" }
|
|
217
|
+
};
|
|
218
|
+
function describeLocalDevice(c) {
|
|
219
|
+
const reads = READS[effectiveReach(c.mode, c.projectReach)];
|
|
220
|
+
const outside = c.outsideSandbox ? {
|
|
221
|
+
en: "runs outside the sandbox only per approved call",
|
|
222
|
+
zh: "仅在获批的单次调用中在沙箱外运行"
|
|
223
|
+
} : { en: "never runs outside the sandbox", zh: "从不在沙箱外运行" };
|
|
224
|
+
return { en: `${reads.en}; ${outside.en}`, zh: `${reads.zh};${outside.zh}` };
|
|
225
|
+
}
|
|
171
226
|
function describe(c, owner) {
|
|
172
227
|
const docker = c.mode === "docker";
|
|
173
228
|
if (owner.state !== "report")
|
|
@@ -175,20 +230,22 @@ function describe(c, owner) {
|
|
|
175
230
|
en: "The computer's owner settings are unreadable or arrived out of order, so it runs as narrowly as possible (workspace only, never outside the sandbox) until it reports them again.",
|
|
176
231
|
zh: "电脑所有者的设置无法读取或报告顺序异常,在重新报告前按最窄的方式运行(只用工作区,从不在沙箱外运行)。"
|
|
177
232
|
};
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
en: "runs outside the sandbox only per approved call",
|
|
184
|
-
zh: "仅对批准的单次调用在沙箱外运行"
|
|
185
|
-
} : { en: "never runs outside the sandbox", zh: "从不在沙箱外运行" };
|
|
233
|
+
const what = describeLocalDevice({
|
|
234
|
+
projectReach: owner.projectReach,
|
|
235
|
+
outsideSandbox: owner.outsideSandbox,
|
|
236
|
+
mode: c.mode
|
|
237
|
+
});
|
|
186
238
|
const net = owner.network === "open" ? { en: "the open internet", zh: "开放的互联网" } : hosts(owner.allowedDomains.length);
|
|
187
239
|
return {
|
|
188
|
-
en: `${docker ? "In a Docker container: " : ""}${
|
|
189
|
-
zh: `${docker ? "在 Docker 容器中:" : ""}${
|
|
240
|
+
en: `${docker ? "In a Docker container: " : ""}${what.en}; network: ${net.en}.`,
|
|
241
|
+
zh: `${docker ? "在 Docker 容器中:" : ""}${what.zh};网络:${net.zh}。`
|
|
190
242
|
};
|
|
191
243
|
}
|
|
244
|
+
var REACH_VALUE = {
|
|
245
|
+
machine: "machine",
|
|
246
|
+
paths: "listed directories",
|
|
247
|
+
workspace: "workspace"
|
|
248
|
+
};
|
|
192
249
|
function limitsOf(c, owner) {
|
|
193
250
|
const lines = [
|
|
194
251
|
{ label: { en: "Mode", zh: "模式" }, value: c.mode },
|
|
@@ -198,7 +255,7 @@ function limitsOf(c, owner) {
|
|
|
198
255
|
},
|
|
199
256
|
{
|
|
200
257
|
label: { en: "Project reach", zh: "项目范围" },
|
|
201
|
-
value: owner.
|
|
258
|
+
value: REACH_VALUE[effectiveReach(c.mode, owner.projectReach)]
|
|
202
259
|
},
|
|
203
260
|
{ label: { en: "Network", zh: "网络" }, value: owner.network }
|
|
204
261
|
];
|
|
@@ -207,6 +264,8 @@ function limitsOf(c, owner) {
|
|
|
207
264
|
label: { en: "Allowed hosts", zh: "允许的主机" },
|
|
208
265
|
value: String(owner.allowedDomains.length)
|
|
209
266
|
});
|
|
267
|
+
if (c.sharedProjectRoots.length > 0)
|
|
268
|
+
lines.push({ label: SHARED_LABEL, value: sharedRootsValue(c.sharedProjectRoots) });
|
|
210
269
|
return lines;
|
|
211
270
|
}
|
|
212
271
|
function deviceReportOf(c, b) {
|
|
@@ -337,6 +396,8 @@ function decideHello(s, deviceId, hello, conn, now) {
|
|
|
337
396
|
features: [...hello.features ?? []],
|
|
338
397
|
permissionSupport: hello.permissionSupport,
|
|
339
398
|
ownerReport: applied.next ?? stored?.ownerReport ?? null,
|
|
399
|
+
// a hello restarts what the machine said: an unreadable summary shows none
|
|
400
|
+
sharedProjectRoots: sharedRootsOf(hello.policy, []),
|
|
340
401
|
instanceGeneration: gen,
|
|
341
402
|
runtimeIdentity: hello.runtimeIdentity ?? null
|
|
342
403
|
};
|
|
@@ -375,8 +436,10 @@ function createDialInHandler(ctx, store, now = () => (/* @__PURE__ */ new Date()
|
|
|
375
436
|
const out = await store.change(deviceId, (s) => {
|
|
376
437
|
const c = fn(s);
|
|
377
438
|
if ("ok" in c) return { result: c };
|
|
378
|
-
|
|
379
|
-
|
|
439
|
+
moved = reportMoved(s, {
|
|
440
|
+
connection: c.connection ?? s.connection,
|
|
441
|
+
binding: c.binding ?? s.binding
|
|
442
|
+
});
|
|
380
443
|
return c;
|
|
381
444
|
});
|
|
382
445
|
if (moved) await tell(deviceId);
|
|
@@ -403,10 +466,13 @@ function createDialInHandler(ctx, store, now = () => (/* @__PURE__ */ new Date()
|
|
|
403
466
|
return { ok: true };
|
|
404
467
|
},
|
|
405
468
|
/**
|
|
406
|
-
* A `policy` event: the owner changed the machine's ceiling while connected.
|
|
407
|
-
* the owner-report rule (stale ignored, conflicting blocks);
|
|
408
|
-
*
|
|
409
|
-
*
|
|
469
|
+
* A `policy` event: the owner changed the machine's ceiling or policy while connected. The
|
|
470
|
+
* ceiling is recorded through the owner-report rule (stale ignored, conflicting blocks); the
|
|
471
|
+
* summary's shared project directories are taken only with a current ceiling (recorded or the
|
|
472
|
+
* same again; an unreadable summary keeps them), never from a stale or conflicting event. An
|
|
473
|
+
* invalid body is logged and dropped (the kernel keeps the connection; the machine's own
|
|
474
|
+
* enforcement stands), and so is a frame of any connection other than the one whose hello was
|
|
475
|
+
* recorded last.
|
|
410
476
|
*/
|
|
411
477
|
async onFrame(deviceId, frame, conn) {
|
|
412
478
|
let event;
|
|
@@ -426,7 +492,12 @@ function createDialInHandler(ctx, store, now = () => (/* @__PURE__ */ new Date()
|
|
|
426
492
|
);
|
|
427
493
|
if (applied.outcome === "conflict")
|
|
428
494
|
ctx.log.warn("a machine's owner report conflicts with the recorded one", { deviceId });
|
|
429
|
-
|
|
495
|
+
const current = applied.outcome === "recorded" || applied.outcome === "same";
|
|
496
|
+
const sharedProjectRoots = current ? sharedRootsOf(event.policy, s.connection.sharedProjectRoots) : s.connection.sharedProjectRoots;
|
|
497
|
+
return applied.next ? {
|
|
498
|
+
result: applied.outcome,
|
|
499
|
+
connection: { ...s.connection, ownerReport: applied.next, sharedProjectRoots }
|
|
500
|
+
} : { result: applied.outcome };
|
|
430
501
|
});
|
|
431
502
|
},
|
|
432
503
|
/**
|
|
@@ -4238,6 +4309,7 @@ function connectionOf(r) {
|
|
|
4238
4309
|
features: FEATURES.filter((f) => features.includes(f)),
|
|
4239
4310
|
permissionSupport,
|
|
4240
4311
|
ownerReport: storedOwnerReportOf(json(r.owner_report)),
|
|
4312
|
+
sharedProjectRoots: Array.isArray(r.shared_project_roots) ? r.shared_project_roots.filter((p) => typeof p === "string") : [],
|
|
4241
4313
|
instanceGeneration: typeof r.instance_generation === "string" ? r.instance_generation : null,
|
|
4242
4314
|
runtimeIdentity: identityOf(r.runtime_identity)
|
|
4243
4315
|
};
|
|
@@ -4263,6 +4335,7 @@ async function writeConnection(db, c) {
|
|
|
4263
4335
|
features: c.features,
|
|
4264
4336
|
permission_support: JSON.stringify(c.permissionSupport),
|
|
4265
4337
|
owner_report: c.ownerReport === null ? null : JSON.stringify(c.ownerReport),
|
|
4338
|
+
shared_project_roots: c.sharedProjectRoots,
|
|
4266
4339
|
instance_generation: c.instanceGeneration,
|
|
4267
4340
|
runtime_identity: c.runtimeIdentity === null ? null : JSON.stringify(c.runtimeIdentity),
|
|
4268
4341
|
updated_at: sql`now()`
|
|
@@ -4344,7 +4417,6 @@ import {
|
|
|
4344
4417
|
// src/frames.ts
|
|
4345
4418
|
import {
|
|
4346
4419
|
FileSystemGoneError,
|
|
4347
|
-
ProjectPathRefusedError,
|
|
4348
4420
|
SandboxGoneError,
|
|
4349
4421
|
SandboxOperationOutcomeUnknownError,
|
|
4350
4422
|
SandboxPermissionUnsupportedError,
|
|
@@ -4357,6 +4429,29 @@ import {
|
|
|
4357
4429
|
parseDeviceFrame as parseDeviceFrame2,
|
|
4358
4430
|
parseOperationResult
|
|
4359
4431
|
} from "@capybara-hq/plugin-sdk/device-protocol";
|
|
4432
|
+
|
|
4433
|
+
// src/project-refusal.ts
|
|
4434
|
+
import { ProjectPathRefusedError } from "@capybara-hq/plugin-sdk";
|
|
4435
|
+
var PROJECT_REFUSAL_TEXT = Object.freeze({
|
|
4436
|
+
"other-connection": Object.freeze({
|
|
4437
|
+
en: "This directory belongs to another connection on this machine.",
|
|
4438
|
+
zh: "这个目录属于本机上的另一个连接。"
|
|
4439
|
+
}),
|
|
4440
|
+
"outside-reach": Object.freeze({
|
|
4441
|
+
en: "This directory is outside the project reach the machine's owner set for this device.",
|
|
4442
|
+
zh: "这个目录不在本机所有者为此设备设定的项目范围内。"
|
|
4443
|
+
}),
|
|
4444
|
+
denied: Object.freeze({
|
|
4445
|
+
en: "This directory holds secrets or the device program's own state.",
|
|
4446
|
+
zh: "这个目录存放密钥或设备程序自身的状态。"
|
|
4447
|
+
})
|
|
4448
|
+
});
|
|
4449
|
+
function projectRefusalError(refusal) {
|
|
4450
|
+
const text = PROJECT_REFUSAL_TEXT[refusal];
|
|
4451
|
+
return new ProjectPathRefusedError({ en: text.en, zh: text.zh });
|
|
4452
|
+
}
|
|
4453
|
+
|
|
4454
|
+
// src/frames.ts
|
|
4360
4455
|
var POLICY_REFUSAL_PREFIX = "Refused by the machine's local policy: ";
|
|
4361
4456
|
var ON_MACHINE_PREFIX = "On the connected machine: ";
|
|
4362
4457
|
var EXEC_DEADLINE_MARGIN_MS = 5e3;
|
|
@@ -4391,9 +4486,12 @@ function requestOf(op, args) {
|
|
|
4391
4486
|
if (op === "bindInstance") return args;
|
|
4392
4487
|
return void 0;
|
|
4393
4488
|
}
|
|
4394
|
-
var isProjectListing = (op) => op === "list" || op === "scan" || op === "browseList" || op === "browseScan";
|
|
4395
4489
|
function failureOf(error, op) {
|
|
4396
4490
|
const { kind, message } = error;
|
|
4491
|
+
if (kind === "project_refused") {
|
|
4492
|
+
if (error.refusal === void 0) return invalidAnswer(op, "a project refusal without a code");
|
|
4493
|
+
return projectRefusalError(error.refusal);
|
|
4494
|
+
}
|
|
4397
4495
|
switch (kind) {
|
|
4398
4496
|
case "denied":
|
|
4399
4497
|
return new SandboxScopeDeniedError(message);
|
|
@@ -4410,8 +4508,6 @@ function failureOf(error, op) {
|
|
|
4410
4508
|
case "fs_gone":
|
|
4411
4509
|
return new FileSystemGoneError(message);
|
|
4412
4510
|
case "policy":
|
|
4413
|
-
if (isProjectListing(op))
|
|
4414
|
-
return new ProjectPathRefusedError({ en: `${POLICY_REFUSAL_PREFIX}${message}` });
|
|
4415
4511
|
return new ToolError(
|
|
4416
4512
|
`${POLICY_REFUSAL_PREFIX}${message} (ask the machine's owner to allow it, or use another way)`
|
|
4417
4513
|
);
|
|
@@ -4552,7 +4648,7 @@ function localHandle(h) {
|
|
|
4552
4648
|
const l = h;
|
|
4553
4649
|
return l.roots && l.limits && typeof l.generation === "string" ? h : void 0;
|
|
4554
4650
|
}
|
|
4555
|
-
var
|
|
4651
|
+
var sameRoots2 = (a, b) => a.workspace === b.workspace && a.skills === b.skills && a.tmp === b.tmp;
|
|
4556
4652
|
var bytesOf = (b64) => new Uint8Array(Buffer.from(b64, "base64"));
|
|
4557
4653
|
var b64Of = (data) => Buffer.from(data).toString("base64");
|
|
4558
4654
|
var refuseRaw = (method) => async (..._args) => {
|
|
@@ -4784,7 +4880,7 @@ function createDeviceLocalProvider(ctx, store, opts = {}) {
|
|
|
4784
4880
|
const current = await store.binding(l.id);
|
|
4785
4881
|
if (current?.generation !== l.generation) return "gone";
|
|
4786
4882
|
const roots = await machineCreate(l.id, l.limits, signal);
|
|
4787
|
-
if (!
|
|
4883
|
+
if (!sameRoots2(roots, l.roots)) return "gone";
|
|
4788
4884
|
return await bindings.rebind(l.id, l.generation, signal) === "bound" ? "resumed" : "gone";
|
|
4789
4885
|
},
|
|
4790
4886
|
async suspend(h, signal) {
|
|
@@ -4800,7 +4896,7 @@ function createDeviceLocalProvider(ctx, store, opts = {}) {
|
|
|
4800
4896
|
async destroyByName(_name, signal) {
|
|
4801
4897
|
signal.throwIfAborted();
|
|
4802
4898
|
},
|
|
4803
|
-
/** A protocol
|
|
4899
|
+
/** A protocol 6 machine has no broad kill: the kernel revokes exact operations instead. */
|
|
4804
4900
|
async killAll(_h, signal) {
|
|
4805
4901
|
signal.throwIfAborted();
|
|
4806
4902
|
},
|
|
@@ -4819,7 +4915,7 @@ function createDeviceLocalProvider(ctx, store, opts = {}) {
|
|
|
4819
4915
|
// src/index.ts
|
|
4820
4916
|
var plugin = defineExtension({
|
|
4821
4917
|
name: "device-local",
|
|
4822
|
-
version: "0.1.0-rc.
|
|
4918
|
+
version: "0.1.0-rc.3",
|
|
4823
4919
|
// ctx.dialIn.capacity and the handlers' connection argument are the rc.56 SDK's
|
|
4824
4920
|
sdk: "^0.1.0-rc.56",
|
|
4825
4921
|
provides: [DEVICE_PROVIDER_EXTENSION_POINT],
|
|
@@ -4852,6 +4948,7 @@ export {
|
|
|
4852
4948
|
ON_MACHINE_PREFIX,
|
|
4853
4949
|
OP_DEADLINE_MS,
|
|
4854
4950
|
POLICY_REFUSAL_PREFIX,
|
|
4951
|
+
PROJECT_REFUSAL_TEXT,
|
|
4855
4952
|
applyOwnerReport,
|
|
4856
4953
|
closedSupport,
|
|
4857
4954
|
commandLimits,
|
|
@@ -4861,6 +4958,7 @@ export {
|
|
|
4861
4958
|
decideHello,
|
|
4862
4959
|
decideOwnerReport,
|
|
4863
4960
|
index_default as default,
|
|
4961
|
+
describeLocalDevice,
|
|
4864
4962
|
deviceIdOfName,
|
|
4865
4963
|
deviceReportOf,
|
|
4866
4964
|
failureOf,
|
|
@@ -4870,9 +4968,12 @@ export {
|
|
|
4870
4968
|
nextGeneration,
|
|
4871
4969
|
ownerFactsOf,
|
|
4872
4970
|
pgRows,
|
|
4971
|
+
projectRefusalError,
|
|
4873
4972
|
relayer,
|
|
4874
4973
|
reportFor,
|
|
4974
|
+
reportMoved,
|
|
4875
4975
|
revisionOf,
|
|
4976
|
+
sharedRootsValue,
|
|
4876
4977
|
storeOver,
|
|
4877
4978
|
storedOwnerReportOf,
|
|
4878
4979
|
supportFor,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
-- The project directories of the connection that another connection on the same machine also
|
|
2
|
+
-- uses, from the machine's last policy summary (only directories the owner listed for this
|
|
3
|
+
-- connection; never naming the other connection). Shown in the device report only.
|
|
4
|
+
ALTER TABLE connections ADD COLUMN IF NOT EXISTS shared_project_roots text[] NOT NULL DEFAULT '{}';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/plugin-device-local",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Devices on people's own computers: a machine connected with capybara-device serves the device over the dial-in channel, and its owner limits it there",
|