@capybara-hq/plugin-sdk 0.1.0-rc.56 → 0.1.0-rc.58

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.
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Paths a local device never opens to restricted work (Request approval, Approve for me), relative
3
3
  * to `~` (spec §13.6, extended by ruling R19): SSH keys, cloud CLI credentials, container and
4
- * Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, and the
5
- * browser profile directories. One source for the device, which denies them (and its own state
4
+ * Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, the
5
+ * browser profile directories, other tool credential stores (cargo, 1Password, Vault, Terraform,
6
+ * Claude, Codex, keyrings, pass, rclone, s3cmd, mise) and shell histories. One source for the device, which denies them (and its own state
6
7
  * directory), and the kernel, which never proposes an approval for a path under one. Full access
7
8
  * and auto mode run as the owner and do not apply them: the command review does.
8
9
  */
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Paths a local device never opens to restricted work (Request approval, Approve for me), relative
3
3
  * to `~` (spec §13.6, extended by ruling R19): SSH keys, cloud CLI credentials, container and
4
- * Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, and the
5
- * browser profile directories. One source for the device, which denies them (and its own state
4
+ * Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, the
5
+ * browser profile directories, other tool credential stores (cargo, 1Password, Vault, Terraform,
6
+ * Claude, Codex, keyrings, pass, rclone, s3cmd, mise) and shell histories. One source for the device, which denies them (and its own state
6
7
  * directory), and the kernel, which never proposes an approval for a path under one. Full access
7
8
  * and auto mode run as the owner and do not apply them: the command review does.
8
9
  */
@@ -33,6 +34,21 @@ export const DEVICE_DENIED_SECRET_PATHS = Object.freeze([
33
34
  "~/Library/Application Support/Arc",
34
35
  "~/.config/BraveSoftware",
35
36
  "~/.config/microsoft-edge",
37
+ // Machine reach reads the whole home, so more tool credential stores and shell histories.
38
+ "~/.cargo/credentials",
39
+ "~/.cargo/credentials.toml",
40
+ "~/.config/op",
41
+ "~/.vault-token",
42
+ "~/.terraform.d/credentials.tfrc.json",
43
+ "~/.claude/.credentials.json",
44
+ "~/.codex/auth.json",
45
+ "~/.local/share/keyrings",
46
+ "~/.password-store",
47
+ "~/.config/rclone",
48
+ "~/.s3cfg",
49
+ "~/.config/mise/config.toml",
50
+ "~/.bash_history",
51
+ "~/.zsh_history",
36
52
  ]);
37
53
  /**
38
54
  * The device program's default state directory (`$XDG_CONFIG_HOME/capybara-device` when that is
@@ -8,7 +8,7 @@
8
8
  import { type SandboxPermissionSupport } from "./device-operation.js";
9
9
  import { type ExecResult, type SandboxActor, type SandboxLimits, type SandboxRoots } from "./device-provider.js";
10
10
  /** The major version of {@link DEVICE_DIAL_IN_PROTOCOL}. */
11
- export declare const DEVICE_PROTOCOL_VERSION = 5;
11
+ export declare const DEVICE_PROTOCOL_VERSION = 6;
12
12
  /**
13
13
  * The dial-in protocol `capybara-device` speaks (`<name>/<major>`, see `DIAL_IN_PROTOCOL_RE`): the
14
14
  * value of the `X-Capybara-Device-Protocol` header, of the hello envelope's `protocol` and of the
@@ -16,7 +16,7 @@ export declare const DEVICE_PROTOCOL_VERSION = 5;
16
16
  * The kernel checks only the envelope (`DialInMachineFrame`); the bodies the envelope carries are
17
17
  * this module's ({@link parseDeviceFrame}).
18
18
  */
19
- export declare const DEVICE_DIAL_IN_PROTOCOL: "capybara-device/5";
19
+ export declare const DEVICE_DIAL_IN_PROTOCOL: "capybara-device/6";
20
20
  /** The operations the kernel asks a device to run. */
21
21
  export type DeviceOp = "create" | "exec" | "readFile" | "writeFile" | "stat" | "killTagged" | "killAll" | "stop" | "list" | "scan";
22
22
  /**
@@ -32,7 +32,18 @@ export type DeviceFeature = "networkReport" | "projects";
32
32
  export interface DeviceLocalPolicySummary {
33
33
  /** The device's sandbox allowlist (the owner's `allowedDomains`). */
34
34
  allowedDomains: string[];
35
+ /**
36
+ * This connection's project directories that another connection on the same machine also uses,
37
+ * only those the owner listed explicitly for this connection (its `projectPaths`): a directory
38
+ * the deployment picked itself is never reported, shared or not (absolute paths,
39
+ * {@link validateSandboxPathShape}; at most {@link MAX_DEVICE_SHARED_PROJECT_ROOTS}). Never names
40
+ * the other connection. Absent from an older device; a malformed value is dropped by the parser
41
+ * (the rest of the summary is kept).
42
+ */
43
+ sharedProjectRoots?: string[];
35
44
  }
45
+ /** The most project directories a policy summary's `sharedProjectRoots` lists. */
46
+ export declare const MAX_DEVICE_SHARED_PROJECT_ROOTS = 256;
36
47
  /**
37
48
  * A directory a `scan` found that looks like a project (it holds `.git` or `AGENTS.md`): a
38
49
  * suggestion, not a project. `path` is absolute ({@link validateSandboxPathShape});
@@ -176,16 +187,23 @@ export interface DeviceOpResults {
176
187
  /** Validates the `result` of a successful `res` for `op`; throws {@link DeviceProtocolError}. */
177
188
  export declare function parseOpResult<Op extends DeviceOp>(op: Op, result: unknown): DeviceOpResults[Op];
178
189
  /**
179
- * The operations the kernel asks a protocol 5 device to run: every user operation carries its
190
+ * The operations the kernel asks a protocol 6 device to run: every user operation carries its
180
191
  * admitted scope; there is no broad kill (`killTagged` / `killAll`) and no deployment-side change
181
192
  * of the machine's policy: the owner changes it on the machine and the device reports the change
182
193
  * ({@link DevicePolicyChanged}).
183
194
  */
184
195
  export type DeviceOperation = Exclude<DeviceOp, "killTagged" | "killAll"> | "prepareReadFile" | "prepareWriteFile" | "prepareStat" | "browseStat" | "browseList" | "browseScan" | "backgroundStart" | "backgroundStatus" | "backgroundTail" | "backgroundReadOutput" | "backgroundStop" | "revokeOperation" | "bindInstance";
196
+ /**
197
+ * How far a connection's project paths reach: `machine` (any path the deny list leaves), `paths`
198
+ * (the listed project paths) or `workspace` (the connection's working directory only).
199
+ */
200
+ export type DeviceProjectReach = "machine" | "paths" | "workspace";
201
+ /** Why a device refused a project path: the `refusal` of a `project_refused` outcome. */
202
+ export type DeviceProjectRefusal = "other-connection" | "outside-reach" | "denied";
185
203
  /** The sandbox network of a device: the open public internet or an allowlist. */
186
204
  export type DeviceNetworkMode = "open" | "allowlist";
187
205
  /**
188
- * The owner ceiling of protocol 4 (approval-only profiles design, "Settings model"): the device
206
+ * The owner ceiling of protocol 6 (approval-only profiles design, "Settings model"): the device
189
207
  * sandbox for every profile. `outsideSandbox` is whether a call may be granted escalation outside
190
208
  * the sandbox; `network` and `allowedDomains` are the sandbox network.
191
209
  */
@@ -196,19 +214,7 @@ export interface DeviceOwnerCeiling {
196
214
  readonly outsideSandbox: boolean;
197
215
  readonly network: DeviceNetworkMode;
198
216
  readonly allowedDomains: readonly string[];
199
- readonly restrictedProjectReach: "workspace" | "os-user";
200
- }
201
- /**
202
- * The narrowing of protocol 4: the kernel may switch the network to `allowlist`, remove hosts, turn
203
- * `outsideSandbox` off or narrow the project reach. Never a widening: widening is decided on the
204
- * machine by its owner (`capybara-device ceiling set`), never over the wire.
205
- */
206
- export interface DeviceOwnerCeilingNarrowing {
207
- readonly outsideSandbox?: false;
208
- readonly network?: "allowlist";
209
- /** Hosts to remove from `allowedDomains`; a host not on the list is ignored. */
210
- readonly removeAllowedDomains?: readonly string[];
211
- readonly restrictedProjectReach?: "workspace";
217
+ readonly projectReach: DeviceProjectReach;
212
218
  }
213
219
  /**
214
220
  * An event body (the envelope's `event`): the owner changed the machine's policy or owner ceiling
@@ -304,8 +310,10 @@ export type DeviceResponseBody = {
304
310
  * `invalid` never proves the operation had no effect (a skewed device may have parsed
305
311
  * part of it): it must never join the not-run refusals (`isRefusal`, `failureKindOf`).
306
312
  */
307
- kind: "gone" | "fs_gone" | "policy" | "error" | "denied" | "unsupported" | "unsettled" | "unknown" | "invalid";
313
+ kind: "gone" | "fs_gone" | "policy" | "error" | "denied" | "unsupported" | "unsettled" | "unknown" | "invalid" | "project_refused";
308
314
  message: string;
315
+ /** Present on `project_refused` only: why the project path was refused. */
316
+ refusal?: DeviceProjectRefusal;
309
317
  };
310
318
  };
311
319
  /** A response as the device produces it: its body with the envelope's `id`. */
@@ -313,7 +321,7 @@ export type DeviceResponse = {
313
321
  type: "res";
314
322
  id: string;
315
323
  } & DeviceResponseBody;
316
- /** The bodies of protocol 5, by the envelope frame that carries them. */
324
+ /** The bodies of protocol 6, by the envelope frame that carries them. */
317
325
  export interface DeviceBodies {
318
326
  hello: DeviceHello;
319
327
  req: DeviceRequestBody;
@@ -330,20 +338,13 @@ export interface DeviceBodies {
330
338
  */
331
339
  export declare function parseSandboxPermissionSupport(value: unknown): SandboxPermissionSupport;
332
340
  /**
333
- * Strictly parses one authenticated owner-ceiling report of protocol 4 and returns a frozen copy;
341
+ * Strictly parses one authenticated owner-ceiling report of protocol 6 and returns a frozen copy;
334
342
  * throws {@link DeviceProtocolError}. Unknown fields (the protocol 3 `fullAccess` and
335
343
  * `restrictedAllowedDomains` among them) are refused.
336
344
  */
337
345
  export declare function parseOwnerCeilingReport(value: unknown): DeviceOwnerCeiling;
338
346
  /**
339
- * Strictly parses an owner-ceiling narrowing of protocol 4 and returns a frozen copy; throws
340
- * {@link DeviceProtocolError}. Every field can only narrow: `outsideSandbox` only to `false`,
341
- * `network` only to `allowlist`, the project reach only to `workspace`, and hosts only removed.
342
- * There is no way to name a host to add or a list to replace.
343
- */
344
- export declare function parseOwnerCeilingNarrowing(value: unknown): DeviceOwnerCeilingNarrowing;
345
- /**
346
- * Strictly parses one protocol 5 body, as carried by the dial-in envelope frame of type `kind`
347
+ * Strictly parses one protocol 6 body, as carried by the dial-in envelope frame of type `kind`
347
348
  * (`hello`, `event` and `res` from the device, `req` from the kernel), and returns a frozen copy;
348
349
  * throws {@link DeviceProtocolError}. The envelope (its ids, deadline and size bound) is checked
349
350
  * before: `parseDialInMachineFrame` on the kernel, `parseDialInKernelFrame` on the machine.
@@ -8,7 +8,7 @@
8
8
  import { parseSandboxBrowseScope, parseSandboxExecutionRef, parseSandboxOperationRef, parseSandboxOperationScope, parseSandboxPreparationScope, } from "./device-operation.js";
9
9
  import { isDeviceProjectName, MAX_DEVICE_LIST_ENTRIES, MAX_DEVICE_PROJECT_NAME_LENGTH, MAX_DEVICE_SCAN_DEPTH, MAX_DEVICE_SCAN_RESULTS, validateAllowHost, validateSandboxPathShape, } from "./device-provider.js";
10
10
  /** The major version of {@link DEVICE_DIAL_IN_PROTOCOL}. */
11
- export const DEVICE_PROTOCOL_VERSION = 5;
11
+ export const DEVICE_PROTOCOL_VERSION = 6;
12
12
  /**
13
13
  * The dial-in protocol `capybara-device` speaks (`<name>/<major>`, see `DIAL_IN_PROTOCOL_RE`): the
14
14
  * value of the `X-Capybara-Device-Protocol` header, of the hello envelope's `protocol` and of the
@@ -18,6 +18,8 @@ export const DEVICE_PROTOCOL_VERSION = 5;
18
18
  */
19
19
  export const DEVICE_DIAL_IN_PROTOCOL = `capybara-device/${DEVICE_PROTOCOL_VERSION}`;
20
20
  const DEVICE_FEATURES = ["networkReport", "projects"];
21
+ /** The most project directories a policy summary's `sharedProjectRoots` lists. */
22
+ export const MAX_DEVICE_SHARED_PROJECT_ROOTS = 256;
21
23
  /** The most blocked hosts an exec result reports; the parser cuts longer lists. */
22
24
  export const MAX_NETWORK_BLOCKED_HOSTS = 20;
23
25
  /** The most hosts an exec's `grants` may carry. */
@@ -204,7 +206,22 @@ function parseScanResult(v) {
204
206
  }
205
207
  function parsePolicySummary(v) {
206
208
  const o = obj(v, 'field "policy"');
207
- return { allowedDomains: strArray(o, "allowedDomains") };
209
+ const shared = sharedProjectRoots(o.sharedProjectRoots);
210
+ return {
211
+ allowedDomains: strArray(o, "allowedDomains"),
212
+ ...(shared !== undefined && { sharedProjectRoots: shared }),
213
+ };
214
+ }
215
+ /**
216
+ * A summary's `sharedProjectRoots`: at most {@link MAX_DEVICE_SHARED_PROJECT_ROOTS} absolute paths.
217
+ * Undefined when absent or malformed (an optional field: only it is dropped).
218
+ */
219
+ function sharedProjectRoots(v) {
220
+ if (!Array.isArray(v) || v.length > MAX_DEVICE_SHARED_PROJECT_ROOTS)
221
+ return undefined;
222
+ if (!v.every((p) => typeof p === "string" && validateSandboxPathShape(p).length === 0))
223
+ return undefined;
224
+ return [...v];
208
225
  }
209
226
  /** Optional hello fields: malformed values are ignored so old and new peers interoperate. */
210
227
  function optionalHelloFields(o) {
@@ -411,7 +428,7 @@ function freeze(value) {
411
428
  return value;
412
429
  }
413
430
  /**
414
- * A strict copy of a wire object for the protocol 4 shapes: a plain object of own data properties
431
+ * A strict copy of a wire object for the protocol shapes: a plain object of own data properties
415
432
  * only (no accessor is ever invoked, so a value cannot change between check and use), each key in
416
433
  * `allowed`. Nested values are copied by the caller's own checks.
417
434
  */
@@ -519,7 +536,7 @@ export function parseSandboxPermissionSupport(value) {
519
536
  });
520
537
  }
521
538
  /**
522
- * Strictly parses one authenticated owner-ceiling report of protocol 4 and returns a frozen copy;
539
+ * Strictly parses one authenticated owner-ceiling report of protocol 6 and returns a frozen copy;
523
540
  * throws {@link DeviceProtocolError}. Unknown fields (the protocol 3 `fullAccess` and
524
541
  * `restrictedAllowedDomains` among them) are refused.
525
542
  */
@@ -532,14 +549,14 @@ export function parseOwnerCeilingReport(value) {
532
549
  "outsideSandbox",
533
550
  "network",
534
551
  "allowedDomains",
535
- "restrictedProjectReach",
552
+ "projectReach",
536
553
  ], what);
537
554
  if (o.version !== 3)
538
555
  throw new DeviceProtocolError(`Invalid ${what}: expected version 3`);
539
556
  if (o.network !== "open" && o.network !== "allowlist")
540
557
  throw new DeviceProtocolError(`Invalid ${what}: network must be open or allowlist`);
541
- if (o.restrictedProjectReach !== "workspace" && o.restrictedProjectReach !== "os-user")
542
- throw new DeviceProtocolError(`Invalid ${what}: project reach must be workspace or os-user`);
558
+ if (o.projectReach !== "machine" && o.projectReach !== "paths" && o.projectReach !== "workspace")
559
+ throw new DeviceProtocolError(`Invalid ${what}: project reach must be machine, paths or workspace`);
543
560
  return freeze({
544
561
  version: 3,
545
562
  sequence: integer(o.sequence),
@@ -547,33 +564,7 @@ export function parseOwnerCeilingReport(value) {
547
564
  outsideSandbox: strictBoolean(o, "outsideSandbox", what),
548
565
  network: o.network,
549
566
  allowedDomains: strictHosts(o.allowedDomains, `${what} allowedDomains`),
550
- restrictedProjectReach: o.restrictedProjectReach,
551
- });
552
- }
553
- /**
554
- * Strictly parses an owner-ceiling narrowing of protocol 4 and returns a frozen copy; throws
555
- * {@link DeviceProtocolError}. Every field can only narrow: `outsideSandbox` only to `false`,
556
- * `network` only to `allowlist`, the project reach only to `workspace`, and hosts only removed.
557
- * There is no way to name a host to add or a list to replace.
558
- */
559
- export function parseOwnerCeilingNarrowing(value) {
560
- const what = "owner ceiling narrowing";
561
- const o = strictRecord(value, ["outsideSandbox", "network", "removeAllowedDomains", "restrictedProjectReach"], what);
562
- if ((Object.hasOwn(o, "outsideSandbox") && o.outsideSandbox !== false) ||
563
- (Object.hasOwn(o, "network") && o.network !== "allowlist") ||
564
- (Object.hasOwn(o, "restrictedProjectReach") && o.restrictedProjectReach !== "workspace"))
565
- throw new DeviceProtocolError("The deployment may only narrow the owner ceiling");
566
- return freeze({
567
- ...(Object.hasOwn(o, "outsideSandbox") ? { outsideSandbox: false } : {}),
568
- ...(Object.hasOwn(o, "network") ? { network: "allowlist" } : {}),
569
- ...(Object.hasOwn(o, "removeAllowedDomains")
570
- ? {
571
- removeAllowedDomains: strictHosts(o.removeAllowedDomains, `${what} removeAllowedDomains`),
572
- }
573
- : {}),
574
- ...(Object.hasOwn(o, "restrictedProjectReach")
575
- ? { restrictedProjectReach: "workspace" }
576
- : {}),
567
+ projectReach: o.projectReach,
577
568
  });
578
569
  }
579
570
  const GENERATION = /^[0-9]{1,16}$/;
@@ -716,7 +707,9 @@ const RESPONSE_KINDS = [
716
707
  "unsettled",
717
708
  "unknown",
718
709
  "invalid",
710
+ "project_refused",
719
711
  ];
712
+ const PROJECT_REFUSALS = ["other-connection", "outside-reach", "denied"];
720
713
  function helloBody(value) {
721
714
  const o = object(value);
722
715
  keys(o, [
@@ -777,14 +770,21 @@ function responseBody(value) {
777
770
  throw new DeviceProtocolError('field "ok" must be a boolean');
778
771
  keys(o, ["ok", "error"]);
779
772
  const e = object(o.error);
780
- keys(e, ["kind", "message"]);
773
+ keys(e, e.kind === "project_refused" ? ["kind", "message", "refusal"] : ["kind", "message"]);
781
774
  if (!RESPONSE_KINDS.includes(String(e.kind)))
782
775
  throw new DeviceProtocolError("Unknown outcome kind");
776
+ let refusal;
777
+ if (e.kind === "project_refused") {
778
+ if (!PROJECT_REFUSALS.includes(String(e.refusal)))
779
+ throw new DeviceProtocolError("A project_refused outcome needs a known refusal");
780
+ refusal = e.refusal;
781
+ }
783
782
  return freeze({
784
783
  ok: false,
785
784
  error: {
786
785
  kind: e.kind,
787
786
  message: string(e.message, 8192),
787
+ ...(refusal && { refusal }),
788
788
  },
789
789
  });
790
790
  }
package/dist/dial-in.d.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  */
9
9
  /**
10
10
  * A dial-in protocol: `<name>/<major>`, a lower-case name of 1 to 41 characters and a major
11
- * version from 1 to 9999 (for example `capybara-device/5`). A machine's hello must name exactly
11
+ * version from 1 to 9999 (for example `capybara-device/6`). A machine's hello must name exactly
12
12
  * the protocol of the provider serving its device.
13
13
  */
14
14
  export declare const DIAL_IN_PROTOCOL_RE: RegExp;
package/dist/dial-in.js CHANGED
@@ -9,7 +9,7 @@
9
9
  import { z } from "zod";
10
10
  /**
11
11
  * A dial-in protocol: `<name>/<major>`, a lower-case name of 1 to 41 characters and a major
12
- * version from 1 to 9999 (for example `capybara-device/5`). A machine's hello must name exactly
12
+ * version from 1 to 9999 (for example `capybara-device/6`). A machine's hello must name exactly
13
13
  * the protocol of the provider serving its device.
14
14
  */
15
15
  export const DIAL_IN_PROTOCOL_RE = /^[a-z][a-z0-9-]{0,40}\/[1-9][0-9]{0,3}$/;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.56";
1
+ export declare const SDK_VERSION = "0.1.0-rc.58";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./avatar-presets.js";
4
4
  export * from "./bootstrap.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = "0.1.0-rc.56";
1
+ export const SDK_VERSION = "0.1.0-rc.58";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./avatar-presets.js";
4
4
  export * from "./bootstrap.js";
@@ -8,7 +8,7 @@ import type { PushPlatform } from "./push.js";
8
8
  /** Capability keys, `name@major`; each value is a key of `SHELL_CAPABILITIES`. */
9
9
  export declare const SHELL_CAPABILITY_KEYS: {
10
10
  readonly chrome: "chrome@1";
11
- readonly device: "device@1";
11
+ readonly device: "device@2";
12
12
  readonly notify: "notify@1";
13
13
  readonly openExternal: "openExternal@1";
14
14
  readonly signIn: "signIn@1";
@@ -21,14 +21,11 @@ export declare const SHELL_CAPABILITY_KEYS: {
21
21
  };
22
22
  export type KeepAwakeMode = "off" | "while-busy" | "connected";
23
23
  export type DeviceConnection = "starting" | "online" | "offline" | "draining" | "stopped";
24
- /** What this machine is to the deployment the shell shows. */
25
- export type ThisMachineStatus = {
26
- state: "not_connected";
27
- } | {
28
- state: "connected_elsewhere";
29
- origin: string;
30
- } | {
31
- state: "connected";
24
+ /**
25
+ * One connection of this machine into the deployment the shell shows (a machine may hold several,
26
+ * into one org or several).
27
+ */
28
+ export interface ThisMachineConnection {
32
29
  deviceId: string;
33
30
  orgId: string;
34
31
  mode: "os" | "docker";
@@ -41,9 +38,9 @@ export type ThisMachineStatus = {
41
38
  unavailable?: string;
42
39
  };
43
40
  lastWakeAt?: string;
44
- };
45
- /** One operation running on this machine for the deployment. */
46
- export interface RunningOperationView {
41
+ }
42
+ /** One operation running on this machine for one of its devices. */
43
+ export interface DeviceRunningOp {
47
44
  tag: string;
48
45
  conversationId: string | null;
49
46
  accountId: string | null;
@@ -53,30 +50,51 @@ export interface RunningOperationView {
53
50
  /** The `code` of a rejected shell call. */
54
51
  export type ShellCallError = "busy" | "no_activation" | "cancelled" | "failed";
55
52
  /**
56
- * A change to this machine's owner ceiling, as `capybara-device ceiling set` takes it
57
- * (`--outside-sandbox on|off`, `--network open|allowlist`, `--project-reach workspace|os-user`):
58
- * only the fields to change. A field left out is never touched, so a stale value on the page can
59
- * never narrow it. A widening needs the shell's native confirmation; a narrowing applies at once.
53
+ * A change to a connection's owner ceiling, as `capybara-device ceiling set` takes it
54
+ * (`--outside-sandbox on|off`, `--network open|allowlist`,
55
+ * `--project-reach machine|paths|workspace`): only the fields to change. A field left out is never
56
+ * touched, so a stale value on the page can never narrow it. A widening needs the shell's native
57
+ * confirmation; a narrowing applies at once.
60
58
  */
61
59
  export interface DeviceCeilingRequest {
62
60
  outsideSandbox?: boolean;
63
61
  network?: "open" | "allowlist";
64
- projectReach?: "workspace" | "os-user";
62
+ projectReach?: "machine" | "paths" | "workspace";
65
63
  }
66
- /** `device@1`: connect this machine to the deployment as a device. */
67
- export interface DeviceCapabilityV1 {
68
- status(): Promise<ThisMachineStatus>;
69
- onStatus(listener: (s: ThisMachineStatus) => void): () => void;
70
- running(): Promise<RunningOperationView[]>;
71
- connect(input: {
64
+ /**
65
+ * `device@2`: this machine's connections into the deployment the shell shows. Every action names
66
+ * the connection by its device id; `connect` adds a connection into an org.
67
+ */
68
+ export interface DeviceCapabilityV2 {
69
+ status(): Promise<{
70
+ connections: ThisMachineConnection[];
71
+ }>;
72
+ /** Called when any connection's status changes; read `status()` again. */
73
+ onStatus(cb: () => void): () => void;
74
+ running(a: {
75
+ deviceId: string;
76
+ }): Promise<DeviceRunningOp[]>;
77
+ connect(a: {
72
78
  orgId: string;
73
- deviceId?: string;
74
- }): Promise<"connected" | "cancelled">;
75
- pause(): Promise<void>;
76
- resume(): Promise<"resumed" | "cancelled">;
77
- disconnect(): Promise<void>;
78
- requestCeiling(input: DeviceCeilingRequest): Promise<"applied" | "cancelled">;
79
- setKeepAwake(mode: KeepAwakeMode): Promise<"applied" | "cancelled">;
79
+ }): Promise<"connected" | "cancelled" | {
80
+ error: string;
81
+ }>;
82
+ pause(a: {
83
+ deviceId: string;
84
+ }): Promise<void>;
85
+ resume(a: {
86
+ deviceId: string;
87
+ }): Promise<"resumed" | "cancelled">;
88
+ disconnect(a: {
89
+ deviceId: string;
90
+ }): Promise<void>;
91
+ requestCeiling(a: {
92
+ deviceId: string;
93
+ } & DeviceCeilingRequest): Promise<"applied" | "cancelled">;
94
+ setKeepAwake(a: {
95
+ deviceId: string;
96
+ mode: KeepAwakeMode;
97
+ }): Promise<"applied" | "cancelled">;
80
98
  }
81
99
  /** `notify@1`: a native notification; `path` is the in-app path opened on click. */
82
100
  export interface NotifyCapabilityV1 {
@@ -7,7 +7,7 @@
7
7
  /** Capability keys, `name@major`; each value is a key of `SHELL_CAPABILITIES`. */
8
8
  export const SHELL_CAPABILITY_KEYS = {
9
9
  chrome: "chrome@1",
10
- device: "device@1",
10
+ device: "device@2",
11
11
  notify: "notify@1",
12
12
  openExternal: "openExternal@1",
13
13
  signIn: "signIn@1",
@@ -8,7 +8,7 @@
8
8
  * (key, owner) by the spec that defines it; the owner names the spec holding its functions.
9
9
  */
10
10
  export const SHELL_CAPABILITIES = [
11
- { key: "device@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md)" },
11
+ { key: "device@2", owner: "device provider spec (2026-11-21-device-provider-design.md), §9" },
12
12
  { key: "notify@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md)" },
13
13
  { key: "openExternal@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md)" },
14
14
  { key: "signIn@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md), §6.5" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-sdk",
3
- "version": "0.1.0-rc.56",
3
+ "version": "0.1.0-rc.58",
4
4
  "description": "Capybara plugin SDK: the types and pure functions plugins are written against",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {