@capybara-hq/plugin-device-local 0.1.0-rc.4 → 0.1.0-rc.6
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 +2 -2
- package/README.md +9 -7
- package/dist/index.mjs +22 -8
- package/guides/connect.md +20 -10
- package/guides/connect.zh.md +6 -7
- 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.6",
|
|
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.6",
|
|
27
27
|
"sdk": "^0.1.0-rc.56",
|
|
28
28
|
"provides": [
|
|
29
29
|
"device-provider@1"
|
package/README.md
CHANGED
|
@@ -58,7 +58,9 @@ generation under another runtime identity is refused (`local.invalid_hello`,
|
|
|
58
58
|
- **`report()`** answers from the rows only: a description of the owner's ceiling (project reach
|
|
59
59
|
`machine` / `paths` / `workspace`, always `workspace` in Docker mode; outside the sandbox;
|
|
60
60
|
network) in English and Chinese, the owner's home (OS mode), the machine's own
|
|
61
|
-
narrowing as read-only limits
|
|
61
|
+
narrowing as read-only limits, `reset: false` and `changeHint`: only the computer's owner changes
|
|
62
|
+
the limits, on that computer, with `capybara-device ceiling set -c <device id> …` (the
|
|
63
|
+
connection's real id). Its revision is a hash of everything it is made
|
|
62
64
|
of plus the machine epoch (moved when the machine is revoked or replaced), the instance
|
|
63
65
|
generation, its runtime identity and its stored support; times and connection ids are left out,
|
|
64
66
|
so a reconnect with the same facts keeps it. After a hello or event moved the revision the
|
|
@@ -81,8 +83,9 @@ generation under another runtime identity is refused (`local.invalid_hello`,
|
|
|
81
83
|
- **`permissionSupport()`** answers from the rows only, never a machine round trip: the support the
|
|
82
84
|
machine attested for the installed binding, with outside-the-sandbox and the open public
|
|
83
85
|
internet narrowed to what the owner allows now (no open public internet while the owner's
|
|
84
|
-
network is an allowlist or the owner facts are blocked or missing)
|
|
85
|
-
|
|
86
|
+
network is an allowlist or the owner facts are blocked or missing), and `limitedBy` naming the
|
|
87
|
+
owner for each crossing the machine attested but the owner keeps closed (so the kernel names the
|
|
88
|
+
owner's limit, not the provider's); closed when no binding is installed or no hello is stored.
|
|
86
89
|
|
|
87
90
|
A handle the machine will never serve again (the device's binding is a newer generation, or the
|
|
88
91
|
machine's last hello did not attest it) still reads its installed support, because the kernel
|
|
@@ -98,10 +101,9 @@ on it.
|
|
|
98
101
|
|
|
99
102
|
## Connecting a computer
|
|
100
103
|
|
|
101
|
-
The member guide `guides/connect.md` (place `device-connection
|
|
102
|
-
`
|
|
103
|
-
`capybara-device
|
|
104
|
-
`service start` (or `capybara-device start` in the foreground). Dial-in limits are the kernel's
|
|
104
|
+
The member guide `guides/connect.md` (place `device-connection`): `npm install -g @capybara-hq/device@next`,
|
|
105
|
+
`capybara-device login --url <deployment>`, then `capybara-device service install -c <device id>`
|
|
106
|
+
(it also starts the service; or `capybara-device start -c <device id>` in the foreground). Dial-in limits are the kernel's
|
|
105
107
|
`CAPYBARA_DEVICES__DIAL_IN__*` settings.
|
|
106
108
|
|
|
107
109
|
## Existing local devices
|
package/dist/index.mjs
CHANGED
|
@@ -226,7 +226,10 @@ function describeLocalDevice(c) {
|
|
|
226
226
|
const outside = c.outsideSandbox ? {
|
|
227
227
|
en: "runs outside the sandbox only per approved call",
|
|
228
228
|
zh: "仅在获批的单次调用中在沙箱外运行"
|
|
229
|
-
} : {
|
|
229
|
+
} : {
|
|
230
|
+
en: "the machine's owner keeps every call in the sandbox",
|
|
231
|
+
zh: "本机所有者让每个调用都留在沙箱内"
|
|
232
|
+
};
|
|
230
233
|
return { en: `${reads.en}; ${outside.en}`, zh: `${reads.zh};${outside.zh}` };
|
|
231
234
|
}
|
|
232
235
|
function describe(c, owner) {
|
|
@@ -274,6 +277,13 @@ function limitsOf(c, owner) {
|
|
|
274
277
|
lines.push({ label: SHARED_LABEL, value: sharedRootsValue(c.sharedProjectRoots) });
|
|
275
278
|
return lines;
|
|
276
279
|
}
|
|
280
|
+
function localChangeHint(deviceId) {
|
|
281
|
+
const command = `capybara-device ceiling set -c ${deviceId} --outside-sandbox on|off --network open|allowlist --project-reach machine|paths|workspace`;
|
|
282
|
+
return {
|
|
283
|
+
en: `Only the owner of the computer changes these limits, on that computer: ${command}`,
|
|
284
|
+
zh: `只有这台电脑的所有者能在电脑上更改这些限制:${command}`
|
|
285
|
+
};
|
|
286
|
+
}
|
|
277
287
|
function deviceReportOf(c, b) {
|
|
278
288
|
const revision = revisionOf(c, b);
|
|
279
289
|
if (!c)
|
|
@@ -295,7 +305,8 @@ function deviceReportOf(c, b) {
|
|
|
295
305
|
home: c.mode === "os" ? c.home : null,
|
|
296
306
|
limits: limitsOf(c, owner),
|
|
297
307
|
// the files are the machine owner's directory: the provider never resets them
|
|
298
|
-
reset: false
|
|
308
|
+
reset: false,
|
|
309
|
+
changeHint: localChangeHint(c.deviceId)
|
|
299
310
|
};
|
|
300
311
|
}
|
|
301
312
|
function supportOf(h, c, b) {
|
|
@@ -307,17 +318,20 @@ function supportOf(h, c, b) {
|
|
|
307
318
|
if (!c)
|
|
308
319
|
return closedSupport("The machine has not said hello yet; connect it with capybara-device");
|
|
309
320
|
const owner = ownerFactsOf(c.ownerReport);
|
|
310
|
-
const attested = b.installed.permissionSupport;
|
|
321
|
+
const { limitedBy: _attested, ...attested } = b.installed.permissionSupport;
|
|
322
|
+
const ownerOpen = owner.state === "report" && owner.network === "open";
|
|
323
|
+
const limitedBy = {
|
|
324
|
+
...attested.outsideSandbox && !owner.outsideSandbox && { outsideSandbox: "owner" },
|
|
325
|
+
...attested.network.openPublic && !ownerOpen && { openPublic: "owner" }
|
|
326
|
+
};
|
|
311
327
|
return parseSandboxPermissionSupport({
|
|
312
328
|
...attested,
|
|
313
329
|
// never wider than the owner allows now (a ceiling change since the binding narrows it)
|
|
314
330
|
outsideSandbox: attested.outsideSandbox && owner.outsideSandbox,
|
|
315
331
|
// the open public internet only while the owner's sandbox network is open (an allowlist, or
|
|
316
332
|
// blocked or missing facts, narrow every command's egress on the machine)
|
|
317
|
-
network: {
|
|
318
|
-
|
|
319
|
-
openPublic: attested.network.openPublic && owner.state === "report" && owner.network === "open"
|
|
320
|
-
}
|
|
333
|
+
network: { ...attested.network, openPublic: attested.network.openPublic && ownerOpen },
|
|
334
|
+
...Object.keys(limitedBy).length > 0 && { limitedBy }
|
|
321
335
|
});
|
|
322
336
|
}
|
|
323
337
|
async function reportFor(store, device) {
|
|
@@ -4921,7 +4935,7 @@ function createDeviceLocalProvider(ctx, store, opts = {}) {
|
|
|
4921
4935
|
// src/index.ts
|
|
4922
4936
|
var plugin = defineExtension({
|
|
4923
4937
|
name: "device-local",
|
|
4924
|
-
version: "0.1.0-rc.
|
|
4938
|
+
version: "0.1.0-rc.6",
|
|
4925
4939
|
// ctx.dialIn.capacity and the handlers' connection argument are the rc.56 SDK's
|
|
4926
4940
|
sdk: "^0.1.0-rc.56",
|
|
4927
4941
|
provides: [DEVICE_PROVIDER_EXTENSION_POINT],
|
package/guides/connect.md
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
# Connect this machine
|
|
2
2
|
|
|
3
|
-
::shell-action connect-this-machine Connect this machine
|
|
4
|
-
|
|
5
3
|
A device on your own computer: the computer connects to the platform with the `capybara-device`
|
|
6
|
-
program and serves the device, and you limit what it may do there.
|
|
7
|
-
above connects the computer it runs on. Anywhere else, run these steps in a terminal on the
|
|
4
|
+
program and serves the device, and you limit what it may do there. Run these steps in a terminal on the
|
|
8
5
|
computer you want to connect (macOS or Linux, Node 22.12 or newer; on Windows use WSL).
|
|
9
6
|
|
|
10
7
|
## 1. Install the program
|
|
@@ -27,19 +24,32 @@ another computer into the same device replaces the first one.
|
|
|
27
24
|
## 3. Keep it online
|
|
28
25
|
|
|
29
26
|
```bash title="Connect at login (recommended)"
|
|
30
|
-
capybara-device service install
|
|
31
|
-
capybara-device service start
|
|
27
|
+
capybara-device service install -c <device id>
|
|
32
28
|
```
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
This is the command `login` printed at its end, with your device id: it installs the service,
|
|
31
|
+
starts it right away and connects again at every login. Or run
|
|
32
|
+
`capybara-device start -c <device id>` to connect in the foreground until you stop it. The device
|
|
33
|
+
shows as online once the program is connected; while it is offline, agents cannot use it.
|
|
34
|
+
|
|
35
|
+
**If this computer is already connected elsewhere.** Each device this computer serves is one
|
|
36
|
+
connection, kept under its device id, with its own service. Choosing a new device in the browser, or
|
|
37
|
+
moving a device here from another computer, adds a connection; signing in again to a device this
|
|
38
|
+
computer already serves keeps its connection (only the sign-in is renewed; then run
|
|
39
|
+
`capybara-device service restart -c <device id>` if its service is installed). With more than one
|
|
40
|
+
connection every command needs `-c <device id>` (or the device name or host, when it is unique);
|
|
41
|
+
with only one, `-c` may be left out. `capybara-device status` lists the connections with their ids,
|
|
42
|
+
and `login` prints the exact next command, id included, at its end.
|
|
36
43
|
|
|
37
44
|
## What it may do
|
|
38
45
|
|
|
39
46
|
Commands run in a sandbox on your computer, inside the device's directory
|
|
40
47
|
(`~/capybara-device/<device id>`). You set the owner ceiling on the computer:
|
|
41
|
-
`capybara-device ceiling show
|
|
42
|
-
the sandbox, the network, project reach)
|
|
48
|
+
`capybara-device ceiling show -c <device id>` shows it, `capybara-device ceiling set -c <device id>`
|
|
49
|
+
changes it (running outside the sandbox, the network, project reach); each connection has its own.
|
|
50
|
+
A new connection allows running outside the sandbox: a call that asks to is approved as the
|
|
51
|
+
conversation's permission profile decides; `--outside-sandbox off` keeps every call in the sandbox.
|
|
52
|
+
The organization's and the platform's settings apply as
|
|
43
53
|
well; the narrowest wins. In OS mode commands run as your user with no CPU or memory limits.
|
|
44
54
|
|
|
45
55
|
Deleting the device revokes the computer's sign-in and stops the program; the files stay on your
|
package/guides/connect.zh.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# 连接本机
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
在你自己的电脑上使用的设备:电脑用 `capybara-device` 程序连接到平台并为这台设备服务,由你在本机限制它能做什么。在桌面应用里,点上面的按钮即可连接正在运行它的这台电脑;在其他地方,请在要连接的电脑的终端里依次执行下面的步骤(macOS 或 Linux,Node 22.12 或更高版本;Windows 请使用 WSL)。
|
|
3
|
+
在你自己的电脑上使用的设备:电脑用 `capybara-device` 程序连接到平台并为这台设备服务,由你在本机限制它能做什么。请在要连接的电脑的终端里依次执行下面的步骤(macOS 或 Linux,Node 22.12 或更高版本;Windows 请使用 WSL)。
|
|
6
4
|
|
|
7
5
|
## 1. 安装连接程序
|
|
8
6
|
|
|
@@ -21,15 +19,16 @@ capybara-device login --url {{publicUrl}}
|
|
|
21
19
|
## 3. 保持在线
|
|
22
20
|
|
|
23
21
|
```bash title="开机自动连接(推荐)"
|
|
24
|
-
capybara-device service install
|
|
25
|
-
capybara-device service start
|
|
22
|
+
capybara-device service install -c <device id>
|
|
26
23
|
```
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
这就是 `login` 在结尾打印的命令(带着你的设备 id):它会安装服务并立即启动,之后每次登录都会自动连接。也可以运行 `capybara-device start -c <设备 id>` 在前台连接,直到你停止它。程序连接后设备显示为在线;离线时智能体无法使用它。
|
|
26
|
+
|
|
27
|
+
**如果这台电脑已经连接了其他平台或组织。** 这台电脑服务的每台设备对应一个连接,以设备 id 保存,各有自己的服务。在浏览器里选择新建设备,或把另一台电脑上的设备移到这里,都会新增一个连接;重新登录这台电脑已在服务的设备,则沿用原来的连接(只更新登录凭据;若已安装它的服务,接着运行 `capybara-device service restart -c <设备 id>`)。有多个连接时,每条命令都需要加 `-c <设备 id>`(设备名称或主机名唯一时也可以用它们);只有一个连接时可以省略 `-c`。`capybara-device status` 会列出所有连接及其 id,`login` 的结尾会打印带有 id 的下一步命令。
|
|
29
28
|
|
|
30
29
|
## 它能做什么
|
|
31
30
|
|
|
32
|
-
命令在你电脑上的沙箱里运行,位于设备目录(`~/capybara-device/<设备 id>`)内。你在本机设置所有者上限:`capybara-device ceiling show
|
|
31
|
+
命令在你电脑上的沙箱里运行,位于设备目录(`~/capybara-device/<设备 id>`)内。你在本机设置所有者上限:`capybara-device ceiling show -c <设备 id>` 查看,`capybara-device ceiling set -c <设备 id>` 修改(是否允许在沙箱外运行、网络、项目范围),每个连接各有一份。新连接默认允许在沙箱外运行:请求在沙箱外运行的调用按会话的权限模式审批;`--outside-sandbox off` 让每个调用都留在沙箱内。组织和平台的设置同样生效,以最严格的为准。OS 模式下命令以你的用户身份运行,没有 CPU 和内存限制。
|
|
33
32
|
|
|
34
33
|
删除设备会撤销这台电脑的登录并停止程序,文件仍保留在你的电脑上。
|
|
35
34
|
|
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.6",
|
|
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",
|