@capybara-hq/device 0.1.0-rc.18 → 0.1.0-rc.19

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 (72) hide show
  1. package/README.md +65 -33
  2. package/dist/api.d.ts +3 -3
  3. package/dist/args.d.ts +8 -3
  4. package/dist/args.js +27 -14
  5. package/dist/cli.js +1 -1
  6. package/dist/client.js +1 -1
  7. package/dist/commands/ceiling.d.ts +3 -2
  8. package/dist/commands/ceiling.js +39 -21
  9. package/dist/commands/login.d.ts +15 -11
  10. package/dist/commands/login.js +46 -33
  11. package/dist/commands/policy.js +16 -10
  12. package/dist/commands/start.d.ts +11 -3
  13. package/dist/commands/start.js +25 -9
  14. package/dist/commands/status.js +10 -6
  15. package/dist/exec/docker-operations.d.ts +14 -2
  16. package/dist/exec/docker-operations.js +32 -5
  17. package/dist/exec/linux-agent.d.ts +13 -3
  18. package/dist/exec/linux-agent.js +450 -43
  19. package/dist/exec/linux-operation-backend.d.ts +27 -6
  20. package/dist/exec/linux-operation-backend.js +30 -9
  21. package/dist/exec/linux-operation-worker.d.ts +51 -3
  22. package/dist/exec/linux-operation-worker.js +55 -3
  23. package/dist/exec/linux-runtime.d.ts +3 -2
  24. package/dist/exec/linux-runtime.js +4 -2
  25. package/dist/exec/mac-operation-backend.d.ts +7 -2
  26. package/dist/exec/mac-operation-backend.js +18 -10
  27. package/dist/exec/mac-write-policy.d.ts +2 -0
  28. package/dist/exec/mac-write-policy.js +1 -1
  29. package/dist/exec/operation-types.d.ts +35 -5
  30. package/dist/exec/operation-types.js +73 -23
  31. package/dist/exec/operation-worker.d.ts +80 -1
  32. package/dist/exec/operation-worker.js +197 -14
  33. package/dist/exec/protected-targets.d.ts +16 -0
  34. package/dist/exec/protected-targets.js +53 -0
  35. package/dist/exec/shared.d.ts +7 -3
  36. package/dist/exec/shared.js +7 -5
  37. package/dist/node_modules/@anthropic-ai/sandbox-runtime/CAPYBARA-MODIFICATIONS.patch +343 -7
  38. package/dist/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/resolved-address-guard.js +220 -6
  39. package/dist/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-config.js +17 -0
  40. package/dist/node_modules/@anthropic-ai/sandbox-runtime/dist/sandbox/sandbox-manager.js +11 -0
  41. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/device-protocol.d.ts +77 -46
  42. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/device-protocol.js +206 -83
  43. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/index.d.ts +3 -2
  44. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/index.js +3 -2
  45. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/network-classes.d.ts +98 -0
  46. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/network-classes.js +291 -0
  47. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/sandbox-linux-runtime-source.js +460 -28
  48. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/sandbox-native-runtime-source.js +143 -3
  49. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/sandbox-operation.d.ts +36 -4
  50. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/sandbox-operation.js +21 -4
  51. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/sandbox-runtime-source.js +2 -2
  52. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/sandbox-write-denies.d.ts +87 -8
  53. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/sandbox-write-denies.js +249 -10
  54. package/dist/node_modules/@capybara-hq/plugin-sdk/dist/sandbox.d.ts +11 -22
  55. package/dist/node_modules/@capybara-hq/plugin-sdk/package.json +1 -1
  56. package/dist/owner-report.d.ts +1 -1
  57. package/dist/owner-report.js +5 -4
  58. package/dist/policy-store.d.ts +2 -1
  59. package/dist/policy-store.js +2 -1
  60. package/dist/policy.d.ts +23 -14
  61. package/dist/policy.js +28 -21
  62. package/dist/runtime-manifest.json +1 -1
  63. package/dist/server-ops.d.ts +30 -5
  64. package/dist/server-ops.js +105 -85
  65. package/dist/staged-connect.d.ts +1 -1
  66. package/dist/staged-connect.js +1 -1
  67. package/dist/staged-device.d.ts +1 -1
  68. package/dist/staged-device.js +7 -5
  69. package/dist/staged-session.d.ts +1 -1
  70. package/dist/state.d.ts +41 -21
  71. package/dist/state.js +102 -45
  72. package/package.json +2 -2
package/README.md CHANGED
@@ -62,7 +62,7 @@ and the platform rebuilds the device on its next use.
62
62
  Commands: `login --url <url> [--no-browser] [--dir <path>] [--mode os|docker]`, `logout`,
63
63
  `status [--json]`, `start`, `stop`,
64
64
  `drain [--wait] [--timeout <seconds>]`,
65
- `ceiling show | ceiling set --full-access allow|deny --project-reach workspace|os-user [--yes]`,
65
+ `ceiling show | ceiling set [--outside-sandbox on|off] [--network open|allowlist] [--project-reach workspace|os-user] [--yes]`,
66
66
  `policy [show | set <key> <value> | add|remove <key> <value>]` and
67
67
  `service install|uninstall|start|stop|restart|status`.
68
68
  `ceiling set` is the only way to change the owner ceiling (`policy set mode` points there); a
@@ -82,32 +82,41 @@ and `tmp/`.
82
82
 
83
83
  ## Permissions
84
84
 
85
- Every operation the deployment sends carries a scope: the conversation's permission profile
86
- (`request-approval` and `approve-for-me` are restricted, `full-access` is Full access), the roots
87
- it may read and write, and its network. The device checks each one against the **owner ceiling**
88
- in `policy.json`, which only you change, on this machine:
89
-
90
- - **Full access** `allow|deny`: whether a conversation set to Full access may run here. Full access
91
- runs as you (in Docker mode, as the container's user): your files, credentials and network; the
92
- deployment reviews every command, but that review is the boundary, not a sandbox.
93
- - **Project reach** `workspace|os-user`: whether restricted work and project browsing may read
85
+ Every operation the deployment sends carries a scope: the roots it may read and write, its network
86
+ and the conversation's permission profile (for the record only: every profile runs in the sandbox,
87
+ Full access included; a profile only decides who approves going beyond it). The device checks each
88
+ scope against the **owner ceiling** in `policy.json`, which only you widen, on this machine:
89
+
90
+ - **Outside the sandbox** `on|off`: whether one approved call may run outside the sandbox
91
+ (`sandbox: "escalated"`). Such a call runs as you (in Docker mode, as the container's user): your
92
+ files, credentials and network, with the program's environment minus every `CAPYBARA_*` variable.
93
+ The person, the review model or a Full access auto-grant approves each one, and each is recorded.
94
+ - **Network** `open|allowlist`: the sandbox network. `open` is the public internet (private, local
95
+ and metadata addresses closed, below); `allowlist` is only the hosts in `allowedDomains` that the
96
+ organization also allows, and the list is then this machine's ceiling for per-call host grants.
97
+ - **Project reach** `workspace|os-user`: whether sandboxed work and project browsing may read
94
98
  projects outside the device's `workspace/`.
95
99
 
96
- A new login starts restricted (`deny`, `workspace`). `login` prints the ceiling and how to widen
97
- it; a widening prints the risk text and needs `--yes` or a `y` at the prompt. The organization and
98
- the platform can switch Full access off on their side; the narrowest setting wins.
100
+ A new login starts with outside-the-sandbox off, the open network and `workspace` reach. `login`
101
+ prints the ceiling and how to widen it; a widening prints the risk text and needs `--yes` or a `y`
102
+ at the prompt. The organization and the platform have their own settings; the narrowest wins. An
103
+ older `policy.json` (protocol 3, `fullAccess`) is converted once on start, never wider: allowed
104
+ becomes outside-the-sandbox on with the open network, denied keeps the allowlist (and `start` prints
105
+ `capybara-device ceiling set --network open`). A logged-in machine without `policy.json` (set up
106
+ before rc.58) ran with no reachable host and keeps that: `start` writes outside-the-sandbox off and
107
+ the allowlist with no host, and prints the same command; a missing file never reads as open.
99
108
 
100
109
  ```bash
101
- capybara-device ceiling show # the owner ceiling, network baseline, revision
102
- capybara-device ceiling show --json # {"fullAccess":…,"projectReach":…,"revision":…} (revision: string | null)
103
- capybara-device ceiling set --full-access deny --project-reach workspace # narrow
104
- capybara-device ceiling set --full-access allow --project-reach os-user --yes # widen
110
+ capybara-device ceiling show # the owner ceiling, network, revision
111
+ capybara-device ceiling show --json # {"outsideSandbox":…,"network":…,"allowedDomains":[…],"projectReach":…,"revision":…} (revision: string | null)
112
+ capybara-device ceiling set --outside-sandbox off --network allowlist --project-reach workspace # narrow
113
+ capybara-device ceiling set --outside-sandbox on --network open --yes # widen
105
114
  capybara-device policy add allowedDomains files.slack.com
106
115
  capybara-device policy remove allowedDomains files.slack.com
107
116
  capybara-device policy show
108
117
  ```
109
118
 
110
- **Restricted work** runs each operation in its own sandbox: macOS uses
119
+ **Sandboxed work** (every operation but an escalated call) runs each operation in its own sandbox: macOS uses
111
120
  `@anthropic-ai/sandbox-runtime` (Seatbelt); Linux and Docker mode use the SDK's restricted Linux
112
121
  runtime (Landlock plus a seccomp broker). Writes stay in the scope's roots; reads stay in them too,
113
122
  plus the system and developer tool directories (on macOS `/System`, `/usr`, `/bin`, `/sbin`,
@@ -115,9 +124,25 @@ plus the system and developer tool directories (on macOS `/System`, `/usr`, `/bi
115
124
  installed JDKs) and the data of the version managers your home uses, read only; other files of the
116
125
  machine, such as the rest of your home, are not readable. Secret paths (`~/.ssh`, cloud CLI
117
126
  credentials, `~/.netrc`, `~/.gnupg`, browser profiles, this program's state directory) stay
118
- unreadable even inside those, and the network reaches only hosts in the local `allowedDomains` that
119
- the organization's allowlist also admits (plus a run's or a task's grants, within that allowlist),
120
- through a proxy that refuses loopback, private addresses and internal names. Restricted work also
127
+ unreadable even inside those. Commands get a minimal environment (`PATH`, `LANG`,
128
+ `HOME` set to the working root, a private temp directory, the tool homes, the proxy variables),
129
+ never this program's. The network is the owner ceiling's: `open` reaches the public
130
+ internet, `allowlist` only hosts in the local `allowedDomains` that the organization's allowlist
131
+ also admits (plus a run's or a task's grants, within that allowlist). Either way traffic goes
132
+ through the operation's own proxy, which decides each connection on the resolved address and dials
133
+ the address it checked: loopback (another program's localhost port), private and LAN, CGNAT, IPv6
134
+ ULA, link-local, cloud metadata and NAT64 addresses and this machine's own addresses stay closed,
135
+ for names and IP literals alike. A client that ignores the proxy variables (plain `ssh`) does not
136
+ connect. No sandboxed client connects to a loopback listener, its own included; on Linux a
137
+ restricted command may listen on loopback for clients outside the sandbox, and on macOS it cannot
138
+ listen at all (a dev server needs an approved call outside the sandbox). Behind a fake-IP resolver (a router or proxy in OpenClash-style fake-IP mode answers
139
+ every name with an address in `198.18.0.0/15`), the proxy re-resolves such a name through
140
+ DNS-over-HTTPS (RFC 8484) to Cloudflare (`1.1.1.1`, `1.0.0.1`) and then Google (`8.8.8.8`,
141
+ `8.8.4.4`), reached by IP over verified TLS within 5 seconds, and judges the real answer; when that
142
+ lookup fails the connection is refused with a reason naming the fake-IP resolver, never dialed to
143
+ the fake address. The open network decides on the address, not on where it routes: a router's
144
+ public WAN address reached by hairpin NAT, a VPN routing public addresses to an intranet, or an
145
+ operator NAT64 prefix are not closed; such a machine should keep the allowlist. Restricted work also
121
146
  follows one write policy (below). On macOS each restricted command also gets its own empty temporary
122
147
  directory (`TMPDIR`, `TMP`, `TEMP`), removed when the command ends; `mktemp` without a template
123
148
  writes to the user's shared temporary directory instead, which stays closed, so give it one (`mktemp
@@ -136,10 +161,10 @@ exactly when the operation ends, is cancelled or its task is stopped; it never k
136
161
 
137
162
  ### Changes from the deployment
138
163
 
139
- The deployment changes the local policy only by narrowing it: it may add or remove
140
- `allowedDomains` (an approval adds an exact host; the device page may add a `*.` wildcard) and
141
- narrow the owner ceiling. It can never widen it. Every host is validated like a local one, and the
142
- change is written under `policy.json.lock`.
164
+ The deployment changes the local policy only by narrowing it: it may remove `allowedDomains`,
165
+ switch the network to `allowlist` and turn outside-the-sandbox off. It can never widen it: a
166
+ `policy` request that adds hosts or carries a `mode` is refused and writes nothing (an approval's
167
+ host grant lasts for its run instead). Every change is written under `policy.json.lock`.
143
168
 
144
169
  ### The command log
145
170
 
@@ -151,13 +176,13 @@ refused or failed ones included. It never holds a command's text, its environmen
151
176
  ```text
152
177
  {"op":"exec","tag":"t1","actor":{"accountId":"acc_123","conversationId":"conv_1"},"exitCode":0,"isolation":"restricted",...}
153
178
  {"op":"policy","detail":"policy add files.slack.com by Ada Lovelace (acc_123) via web, approval apr_456",...}
154
- {"op":"policy","detail":"ceiling set fullAccess allow, projectReach os-user by ada via cli",...}
179
+ {"op":"policy","detail":"ceiling set outsideSandbox on, network open by ada via cli",...}
155
180
  ```
156
181
 
157
182
  Limits to know: the platform's `Grep` tool assumes GNU grep, so on macOS (BSD grep) in OS mode some
158
183
  Grep options behave differently or fail. In OS mode the `cpu` and `memoryMb` ceilings are not
159
- enforced yet, and `allowCredentials` is ignored (Full access already has your credentials,
160
- restricted work gets none).
184
+ enforced yet, and `allowCredentials` is ignored (an escalated call already has your credentials,
185
+ sandboxed work gets none).
161
186
 
162
187
  ### Upgrading from a protocol 2 program
163
188
 
@@ -245,7 +270,7 @@ container has a read-only root file system, a pids limit of 1024, `--cap-drop AL
245
270
  `no-new-privileges`, and the policy's `cpu` and `memoryMb` as `--cpus`, `--memory` and an equal
246
271
  `--memory-swap`.
247
272
 
248
- The container is always on Docker's default bridge: Full access has the container's whole network.
273
+ The container is always on Docker's default bridge: an escalated call has the container's whole network.
249
274
  Restricted work inside it is confined by the Linux launcher (Landlock, the seccomp broker and the
250
275
  proxy with the allowlist above), on the container's paths. The hello reports no home directory, and
251
276
  browsing covers the container's `/workspace` only. The container is reused while its mounts, flags
@@ -297,21 +322,28 @@ times. On Linux, installing again restarts the unit so the new file applies.
297
322
 
298
323
  ## Operation backend
299
324
 
300
- The program speaks device protocol 3 only. It binds each instance generation the deployment creates
325
+ The program speaks device protocol 4 only; the kernel and this program upgrade together (a
326
+ protocol 4 program facing an older deployment says the deployment must be upgraded). It binds each instance generation the deployment creates
301
327
  to a verified, sealed runtime and reports restricted support only once a self-check on that runtime
302
328
  passed (macOS: a write in its root goes through, while a write outside it, reads of a denied secret
303
329
  and of an ordinary file it was never granted, and a local connection are refused) or the runtime's
304
- probe passed (Linux, Docker); there is no Full fallback for restricted work.
330
+ probe passed (Linux, Docker); nothing falls back to running outside the sandbox.
305
331
 
306
332
  Each restricted operation has its own immutable sandbox-runtime process and proxy lifetime.
307
333
  Native methods use the SDK's hash-checked Python helper and pinned directory descriptors, with a
308
- private descriptor-identity handshake before dispatch. Full uses the existing OS user directly.
334
+ private descriptor-identity handshake before dispatch. An escalated call uses the existing OS
335
+ user directly.
309
336
  Execution grants arrive separately over authenticated transport; scope hosts cannot manufacture
310
337
  an owner allowance. Strict fresh owner-policy reads fail closed on missing or malformed policy.
311
338
 
312
339
  Restricted operations follow one write policy on every platform (`sandbox-write-denies.ts` in
313
340
  the SDK): no shell, git-global, direnv, npm, editor, agent or hook-manager configuration; inside
314
- any `.git` only git's ordinary internals; no bare-repository lookalike; no `.git` moved away.
341
+ any `.git` only git's ordinary internals; no bare-repository lookalike; no `.git` moved away; no
342
+ OS persistence location (launch agents, systemd user units, autostart, the crontab spool). At
343
+ operation start each protected home location is resolved link by link (a dotfile manager's
344
+ `~/.zshrc` chain), and every link on the way and the final target are denied, with no move of
345
+ their ancestors. Names starting with `.capybara-staging-` (any case) are reserved for the Linux
346
+ broker's staged directory moves and denied to every sandboxed write.
315
347
  As defence in depth, owners are advised to run
316
348
 
317
349
  git config --global safe.bareRepository explicit
package/dist/api.d.ts CHANGED
@@ -15,10 +15,10 @@ export interface TokenResponse {
15
15
  /** The program uses 16 MiB when it is absent. */
16
16
  maxFrameBytes?: number;
17
17
  /**
18
- * Whether the platform and the organization allow Full access (`allowed`) or not (`off`):
19
- * `login` prints the matching line. Absent counts as allowed.
18
+ * Whether the platform and the organization allow running outside the sandbox (`allowed`) or not
19
+ * (`off`): `login` prints the matching line. Absent counts as allowed.
20
20
  */
21
- fullAccess?: "allowed" | "off";
21
+ outsideSandbox?: "allowed" | "off";
22
22
  }
23
23
  /** An error response of the kernel: `{ error: { code, message } }`. */
24
24
  export declare class ApiError extends Error {
package/dist/args.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { DeviceNetworkMode } from "@capybara-hq/plugin-sdk";
1
2
  import { type KeepAwakeMode, type RestrictedProjectReach } from "./state.js";
2
3
  export type DeviceMode = "os" | "docker";
3
4
  /** A parsed command line. */
@@ -39,8 +40,12 @@ export type Command = {
39
40
  } | {
40
41
  command: "ceiling";
41
42
  action: "set";
42
- fullAccess: boolean;
43
- projectReach: RestrictedProjectReach;
43
+ /** `--outside-sandbox on|off`; absent keeps the current value. */
44
+ outsideSandbox?: boolean;
45
+ /** `--network open|allowlist`; absent keeps the current value. */
46
+ network?: DeviceNetworkMode;
47
+ /** `--project-reach workspace|os-user`; absent keeps the current value. */
48
+ projectReach?: RestrictedProjectReach;
44
49
  /** `--yes`: confirms a widening without asking. */
45
50
  yes?: true;
46
51
  } | {
@@ -62,7 +67,7 @@ export type Command = {
62
67
  } | {
63
68
  command: "help";
64
69
  };
65
- export declare const USAGE = "Usage:\n capybara-device login --url <url> [--no-browser] [--dir <path>] [--mode os|docker] [--json]\n Connect this machine: approve the code in the browser;\n --json prints one JSON event per line (no browser)\n capybara-device logout Forget the credential on this machine\n capybara-device status [--json] Show whether this machine is logged in\n capybara-device start Connect and serve the device\n capybara-device stop Stop the running program\n capybara-device drain [--wait] [--timeout <seconds>]\n Finish running commands, accept no new ones, then stop;\n --wait returns once it has stopped (default limit 600 s)\n capybara-device ceiling show [--json]\n Show this machine's owner ceiling (Full access, project reach)\n capybara-device ceiling set --full-access allow|deny --project-reach workspace|os-user [--yes]\n Set the owner ceiling; widening needs --yes or a y at the prompt\n capybara-device keep-awake [show | off | while-busy | connected] [--yes] [--json]\n Show or set when this computer is kept awake; raising it\n needs --yes or a y at the prompt\n capybara-device policy [show] Show the local policy\n capybara-device policy set <key> <value>\n Replace one field (cpu, memoryMb, allowCredentials)\n capybara-device policy add|remove allowedDomains <host>\n Allow or stop allowing a domain for restricted work\n capybara-device policy add|remove allowCredentials <name>\n Allow or stop allowing a credential for restricted work\n capybara-device service install|uninstall\n Run at login as a user service, or remove it\n capybara-device service start|stop|restart\n Start, stop or restart the login service\n capybara-device service status [--json]\n Report whether the login service is loaded, what is running,\n and whether it is older than the installed program";
70
+ export declare const USAGE = "Usage:\n capybara-device login --url <url> [--no-browser] [--dir <path>] [--mode os|docker] [--json]\n Connect this machine: approve the code in the browser;\n --json prints one JSON event per line (no browser)\n capybara-device logout Forget the credential on this machine\n capybara-device status [--json] Show whether this machine is logged in\n capybara-device start Connect and serve the device\n capybara-device stop Stop the running program\n capybara-device drain [--wait] [--timeout <seconds>]\n Finish running commands, accept no new ones, then stop;\n --wait returns once it has stopped (default limit 600 s)\n capybara-device ceiling show [--json]\n Show this machine's owner ceiling (outside the sandbox, network,\n project reach)\n capybara-device ceiling set [--outside-sandbox on|off] [--network open|allowlist]\n [--project-reach workspace|os-user] [--yes]\n Change the owner ceiling (at least one field; the others stay);\n widening needs --yes or a y at the prompt\n capybara-device keep-awake [show | off | while-busy | connected] [--yes] [--json]\n Show or set when this computer is kept awake; raising it\n needs --yes or a y at the prompt\n capybara-device policy [show] Show the local policy\n capybara-device policy set <key> <value>\n Replace one field (cpu, memoryMb, allowCredentials)\n capybara-device policy add|remove allowedDomains <host>\n Allow or stop allowing a domain on the sandbox allowlist\n capybara-device policy add|remove allowCredentials <name>\n Allow or stop allowing a credential for restricted work\n capybara-device service install|uninstall\n Run at login as a user service, or remove it\n capybara-device service start|stop|restart\n Start, stop or restart the login service\n capybara-device service status [--json]\n Report whether the login service is loaded, what is running,\n and whether it is older than the installed program";
66
71
  /** Thrown for a bad command line; the message is shown with the usage. */
67
72
  export declare class UsageError extends Error {
68
73
  }
package/dist/args.js CHANGED
@@ -12,9 +12,12 @@ export const USAGE = `Usage:
12
12
  Finish running commands, accept no new ones, then stop;
13
13
  --wait returns once it has stopped (default limit 600 s)
14
14
  capybara-device ceiling show [--json]
15
- Show this machine's owner ceiling (Full access, project reach)
16
- capybara-device ceiling set --full-access allow|deny --project-reach workspace|os-user [--yes]
17
- Set the owner ceiling; widening needs --yes or a y at the prompt
15
+ Show this machine's owner ceiling (outside the sandbox, network,
16
+ project reach)
17
+ capybara-device ceiling set [--outside-sandbox on|off] [--network open|allowlist]
18
+ [--project-reach workspace|os-user] [--yes]
19
+ Change the owner ceiling (at least one field; the others stay);
20
+ widening needs --yes or a y at the prompt
18
21
  capybara-device keep-awake [show | off | while-busy | connected] [--yes] [--json]
19
22
  Show or set when this computer is kept awake; raising it
20
23
  needs --yes or a y at the prompt
@@ -22,7 +25,7 @@ export const USAGE = `Usage:
22
25
  capybara-device policy set <key> <value>
23
26
  Replace one field (cpu, memoryMb, allowCredentials)
24
27
  capybara-device policy add|remove allowedDomains <host>
25
- Allow or stop allowing a domain for restricted work
28
+ Allow or stop allowing a domain on the sandbox allowlist
26
29
  capybara-device policy add|remove allowCredentials <name>
27
30
  Allow or stop allowing a credential for restricted work
28
31
  capybara-device service install|uninstall
@@ -128,17 +131,25 @@ export function parseCommandLine(argv) {
128
131
  }
129
132
  case "ceiling": {
130
133
  const { values, positionals } = parse(rest, {
131
- "full-access": { type: "string" },
134
+ "outside-sandbox": { type: "string" },
135
+ network: { type: "string" },
132
136
  "project-reach": { type: "string" },
137
+ "full-access": { type: "string" },
133
138
  yes: { type: "boolean", short: "y" },
134
139
  json: { type: "boolean" },
135
140
  });
136
141
  const [action, ...extra] = positionals;
137
- const usage = "usage: ceiling show | ceiling set --full-access allow|deny --project-reach workspace|os-user [--yes]";
142
+ const usage = "usage: ceiling show | ceiling set [--outside-sandbox on|off] [--network open|allowlist] " +
143
+ "[--project-reach workspace|os-user] [--yes]";
144
+ if (values["full-access"] !== undefined)
145
+ throw new UsageError(`--full-access is gone: Full access always runs in the sandbox now; use --outside-sandbox on|off. ${usage}`);
138
146
  if (extra.length > 0)
139
147
  throw new UsageError(usage);
148
+ const outside = values["outside-sandbox"];
149
+ const network = values.network;
150
+ const reach = values["project-reach"];
140
151
  if (action === "show" || action === undefined) {
141
- if (values["full-access"] !== undefined || values["project-reach"] !== undefined)
152
+ if (outside !== undefined || network !== undefined || reach !== undefined)
142
153
  throw new UsageError(usage);
143
154
  return {
144
155
  command: "ceiling",
@@ -150,18 +161,20 @@ export function parseCommandLine(argv) {
150
161
  throw new UsageError(usage);
151
162
  if (values.json === true)
152
163
  throw new UsageError(usage);
153
- const full = values["full-access"];
154
- const reach = values["project-reach"];
155
- // both fields: one explicit atomic target
156
- if (full !== "allow" && full !== "deny")
164
+ if (outside === undefined && network === undefined && reach === undefined)
165
+ throw new UsageError(usage);
166
+ if (outside !== undefined && outside !== "on" && outside !== "off")
167
+ throw new UsageError(usage);
168
+ if (network !== undefined && network !== "open" && network !== "allowlist")
157
169
  throw new UsageError(usage);
158
- if (reach !== "workspace" && reach !== "os-user")
170
+ if (reach !== undefined && reach !== "workspace" && reach !== "os-user")
159
171
  throw new UsageError(usage);
160
172
  return {
161
173
  command: "ceiling",
162
174
  action: "set",
163
- fullAccess: full === "allow",
164
- projectReach: reach,
175
+ ...(outside !== undefined && { outsideSandbox: outside === "on" }),
176
+ ...(network !== undefined && { network }),
177
+ ...(reach !== undefined && { projectReach: reach }),
165
178
  ...(values.yes === true && { yes: true }),
166
179
  };
167
180
  }
package/dist/cli.js CHANGED
@@ -23,7 +23,7 @@ async function askOnTerminal(question) {
23
23
  }
24
24
  }
25
25
  /**
26
- * The program's parts (device protocol 3): the binder with one operation backend per bound
26
+ * The program's parts (device protocol 4): the binder with one operation backend per bound
27
27
  * generation, built for this host (macOS, Linux) or the device's container (docker mode). Loaded
28
28
  * on demand: only start needs them.
29
29
  */
package/dist/client.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * What the device program's connection shares: the messages it ends with, the reconnect backoff
3
- * and the running connection's interface. The connection itself is the protocol 3 one
3
+ * and the running connection's interface. The connection itself is the protocol 4 one
4
4
  * (`staged-connect.ts`).
5
5
  */
6
6
  import { DEVICE_PROTOCOL_VERSION } from "@capybara-hq/plugin-sdk";
@@ -16,8 +16,9 @@ export interface CeilingDeps {
16
16
  /** True when `next` allows anything `cur` does not. */
17
17
  export declare function widens(cur: OwnerCeilingPolicy, next: OwnerCeilingPolicy): boolean;
18
18
  /**
19
- * `ceiling show` prints the owner ceiling, the restricted network baseline and the revision;
20
- * `ceiling set` writes both fields at once under the policy lock (converting an old-format file).
19
+ * `ceiling show` prints the owner ceiling, the sandbox allowlist and the revision; `ceiling set`
20
+ * changes the named fields under the policy lock, the others as they are then (converting an
21
+ * old-format file).
21
22
  * Narrowing applies directly; widening needs --yes or a confirmed terminal answer. Only the
22
23
  * machine's owner widens it: the deployment may only narrow.
23
24
  */
@@ -3,10 +3,14 @@ import { readStrictOwnerCeilingSync } from "../exec/operation-types.js";
3
3
  import { PolicyStore } from "../policy-store.js";
4
4
  import { policyPath, readCredential } from "../state.js";
5
5
  /** Printed before a widening is applied (by --yes or a confirmed prompt). */
6
- export const CEILING_WIDENING_TEXT = "Widening this machine's owner ceiling lets the deployment ask for more here. Full access lets " +
7
- "a conversation the owner switches to Full run commands as you, with your files, credentials " +
8
- "and network. The os-user project reach lets restricted operations and project browsing read " +
9
- "projects outside the device's workspace. Conversations need fresh Full consent either way.";
6
+ export const CEILING_WIDENING_TEXT = "Widening this machine's owner ceiling lets the deployment ask for more here. Commands always " +
7
+ "run in the sandbox under every profile, Full access included. Allowing outside the sandbox " +
8
+ "lets one approved call run as you, with your files, credentials and any network: the person, " +
9
+ "the review model, or a Full access auto-grant approves each such call, and each one is " +
10
+ "recorded. The open network lets sandboxed commands reach the public internet (private, local " +
11
+ "and metadata addresses stay closed). The os-user project reach lets sandboxed work and " +
12
+ "project browsing read projects outside the device's workspace. Conversations need fresh Full " +
13
+ "access consent either way.";
10
14
  export const CEILING_NEEDS_YES = "Nothing changed. To widen the owner ceiling, add --yes (or answer y at the prompt).";
11
15
  export const CEILING_PROMPT = "Widen this machine's owner ceiling? [y/N] ";
12
16
  /** The strict reader's revision for the logged-in device, or null (logged out, unreadable). */
@@ -26,17 +30,28 @@ function strictRevision(stateDir, home) {
26
30
  class WideningNeedsConfirmation extends Error {
27
31
  }
28
32
  const describe = (c) => [
29
- `Full access: ${c.fullAccess ? "allowed" : "denied"}`,
33
+ `Outside the sandbox: ${c.outsideSandbox ? "on" : "off"}`,
34
+ `Network: ${c.network}`,
30
35
  `Project reach: ${c.restrictedProjectReach}`,
31
36
  ];
32
37
  /** True when `next` allows anything `cur` does not. */
33
38
  export function widens(cur, next) {
34
- return ((!cur.fullAccess && next.fullAccess) ||
39
+ return ((!cur.outsideSandbox && next.outsideSandbox) ||
40
+ (cur.network === "allowlist" && next.network === "open") ||
35
41
  (cur.restrictedProjectReach === "workspace" && next.restrictedProjectReach === "os-user"));
36
42
  }
43
+ /** The target ceiling: the fields the command names, the others as they are in `cur`. */
44
+ function target(cmd, cur) {
45
+ return {
46
+ outsideSandbox: cmd.outsideSandbox ?? cur.outsideSandbox,
47
+ network: cmd.network ?? cur.network,
48
+ restrictedProjectReach: cmd.projectReach ?? cur.restrictedProjectReach,
49
+ };
50
+ }
37
51
  /**
38
- * `ceiling show` prints the owner ceiling, the restricted network baseline and the revision;
39
- * `ceiling set` writes both fields at once under the policy lock (converting an old-format file).
52
+ * `ceiling show` prints the owner ceiling, the sandbox allowlist and the revision; `ceiling set`
53
+ * changes the named fields under the policy lock, the others as they are then (converting an
54
+ * old-format file).
40
55
  * Narrowing applies directly; widening needs --yes or a confirmed terminal answer. Only the
41
56
  * machine's owner widens it: the deployment may only narrow.
42
57
  */
@@ -53,7 +68,9 @@ export async function ceilingCommand(cmd, deps) {
53
68
  const cur = store.current();
54
69
  if (cmd.action === "show" && cmd.json === true) {
55
70
  out(JSON.stringify({
56
- fullAccess: cur.ownerCeiling.fullAccess,
71
+ outsideSandbox: cur.ownerCeiling.outsideSandbox,
72
+ network: cur.ownerCeiling.network,
73
+ allowedDomains: cur.allowedDomains,
57
74
  projectReach: cur.ownerCeiling.restrictedProjectReach,
58
75
  // the strict reader's digest of the policy generation; null while logged out
59
76
  revision: strictRevision(stateDir, deps.home),
@@ -63,7 +80,8 @@ export async function ceilingCommand(cmd, deps) {
63
80
  if (cmd.action === "show") {
64
81
  for (const line of describe(cur.ownerCeiling))
65
82
  out(line);
66
- out(`Restricted network baseline: ${cur.allowedDomains.length > 0 ? cur.allowedDomains.join(", ") : "none"}`);
83
+ out(`Sandbox allowlist: ${cur.allowedDomains.length > 0 ? cur.allowedDomains.join(", ") : "none"}` +
84
+ (cur.ownerCeiling.network === "open" ? " (used while the network is an allowlist)" : ""));
67
85
  const cred = (() => {
68
86
  try {
69
87
  return readCredential(stateDir);
@@ -86,16 +104,12 @@ export async function ceilingCommand(cmd, deps) {
86
104
  out(`Revision: unavailable (${e.message})`);
87
105
  }
88
106
  }
89
- out("The platform and organization Full access settings and this machine's runtime support " +
90
- "apply separately; the deployment's device page shows the effective permissions.");
107
+ out("The platform and organization sandbox settings and this machine's runtime support apply " +
108
+ "separately; the deployment's device page shows the effective permissions.");
91
109
  return 0;
92
110
  }
93
- const next = {
94
- fullAccess: cmd.fullAccess,
95
- restrictedProjectReach: cmd.projectReach,
96
- };
97
111
  let confirmed = cmd.yes === true;
98
- if (widens(cur.ownerCeiling, next)) {
112
+ if (widens(cur.ownerCeiling, target(cmd, cur.ownerCeiling))) {
99
113
  out(CEILING_WIDENING_TEXT);
100
114
  if (!confirmed) {
101
115
  if (deps.ask === undefined) {
@@ -116,9 +130,10 @@ export async function ceilingCommand(cmd, deps) {
116
130
  // decided again on the policy under the lock: a narrowing that landed since the read above
117
131
  // makes this a widening, which needs its own confirmation
118
132
  written = store.update((p) => {
133
+ const next = target(cmd, p.ownerCeiling);
119
134
  if (!confirmed && widens(p.ownerCeiling, next))
120
135
  throw new WideningNeedsConfirmation();
121
- return { ...p, ownerCeiling: { ...next } };
136
+ return { ...p, ownerCeiling: next };
122
137
  }).ownerCeiling;
123
138
  }
124
139
  catch (e) {
@@ -130,12 +145,15 @@ export async function ceilingCommand(cmd, deps) {
130
145
  err(`Cannot change ${policyPath(stateDir)}: ${e.message}`);
131
146
  return 1;
132
147
  }
133
- noteCliPolicyChange(stateDir, `ceiling set fullAccess ${written.fullAccess ? "allow" : "deny"}, projectReach ` +
134
- written.restrictedProjectReach);
148
+ noteCliPolicyChange(stateDir, `ceiling set outsideSandbox ${written.outsideSandbox ? "on" : "off"}, network ` +
149
+ `${written.network}, projectReach ${written.restrictedProjectReach}`);
135
150
  out("This machine's owner ceiling is now:");
136
151
  for (const line of describe(written))
137
152
  out(line);
153
+ if (written.network === "allowlist")
154
+ out("Sandboxed commands reach only the sandbox allowlist (capybara-device policy add " +
155
+ "allowedDomains <host>).");
138
156
  if (written.restrictedProjectReach === "os-user")
139
- out("Restricted operations may reach selected projects outside the device's workspace.");
157
+ out("Sandboxed work may reach selected projects outside the device's workspace.");
140
158
  return 0;
141
159
  }
@@ -1,10 +1,12 @@
1
+ import type { DeviceNetworkMode } from "@capybara-hq/plugin-sdk";
1
2
  import { type FetchFn } from "../api.js";
2
3
  import type { Command } from "../args.js";
3
4
  /**
4
- * Shown once at login when the owner ceiling allows Full access in an organization that allows
5
- * it: the trust model of Full access is command review, not the OS sandbox.
5
+ * Shown once at login when the owner ceiling allows running outside the sandbox in an organization
6
+ * that allows it: an escalated call's trust model is its approval and the command review, not the
7
+ * OS sandbox.
6
8
  */
7
- export declare const FULL_ACCESS_RISK_TEXT: string;
9
+ export declare const OUTSIDE_SANDBOX_RISK_TEXT: string;
8
10
  /** The OS sandbox check `login` uses (default: the runtime's, loaded on demand). */
9
11
  export type SandboxCheck = () => {
10
12
  ok: true;
@@ -14,16 +16,18 @@ export type SandboxCheck = () => {
14
16
  };
15
17
  /** How the owner widens the ceiling, on this machine only (the deployment may only narrow it). */
16
18
  export declare const WIDEN_CEILING_HINT: string;
19
+ /** The sandbox network line of the login output. */
20
+ export declare function networkLoginLine(network: DeviceNetworkMode): string;
17
21
  /**
18
- * The line `login` prints for a restricted owner ceiling (the default of a new setup, B-14): no
19
- * Full access, restricted work in the device's workspace only.
22
+ * The line `login` prints when the owner ceiling keeps every call in the sandbox (the default of a
23
+ * new setup): commands run in the sandbox under every profile, Full access included.
20
24
  */
21
- export declare const RESTRICTED_CEILING_LOGIN_LINE: string;
22
- /** The line `login` prints when the owner ceiling allows Full access. */
23
- export declare const FULL_CEILING_LOGIN_LINE: string;
24
- /** Added when the organization does not allow Full access while the owner ceiling does. */
25
- export declare const FULL_ACCESS_NOT_ALLOWED_LOGIN_LINE = "This organization does not allow Full access, so agents use the restricted profiles here.";
26
- /** The line `login` prints when restricted work cannot run here (no OS sandbox). */
25
+ export declare const SANDBOX_ONLY_LOGIN_LINE: string;
26
+ /** The line `login` prints when the owner ceiling allows running outside the sandbox. */
27
+ export declare const OUTSIDE_SANDBOX_LOGIN_LINE: string;
28
+ /** Added when the organization does not allow running outside the sandbox while the owner does. */
29
+ export declare const OUTSIDE_SANDBOX_NOT_ALLOWED_LOGIN_LINE: string;
30
+ /** The line `login` prints when sandboxed work cannot run here (no OS sandbox). */
27
31
  export declare function restrictedUnavailableLoginLine(reason: string): string;
28
32
  export interface LoginDeps {
29
33
  stateDir: string;