@capybara-hq/plugin-sdk 0.1.0-rc.42 → 0.1.0-rc.44

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.
@@ -45,4 +45,6 @@ Fields of `template`:
45
45
  `oauth_code` or `oauth_client`, plus `ownership` (`org` or per member).
46
46
  - `defaultToolPolicies`: tool name to `allow`, `ask` or `deny`. When unsure, do not write `allow`.
47
47
 
48
- Credentials and secret config are entered by people on the web page, never through an agent.
48
+ Credentials and secret config are entered by the person on the `Platform` confirmation card (name
49
+ their paths in `askPerson`), never typed by an agent; only what the card cannot take (secret
50
+ records, custom header credentials) is entered on the web page.
@@ -31,14 +31,22 @@ the person's own decision stays with the person on the web.
31
31
  ## What stays with the person
32
32
 
33
33
  - **Secrets.** Bot tokens, app tokens, signing secrets and OAuth client secrets are typed by the
34
- person into their fields on the `webPath` page. Never ask for a secret in the conversation and
35
- never repeat one; if the person pastes one anyway, tell them to rotate it at the third-party
36
- platform. The guide and the check results never contain secret values, and no setup operation
37
- takes one.
38
- - **Connecting a personal account** (OAuth consent) happens in the browser on the `webPath` page
39
- (for a member, their connections page).
34
+ person, never by you. A write that stores one (a connector credential or OAuth client secret, a
35
+ channel secret, an extension config secret) takes it as a person field: name its path in
36
+ `askPerson` and the person types the value on the `Platform` confirmation card. What the card
37
+ cannot take (secret records, custom header credentials) the person enters on the `webPath` page.
38
+ Never ask for a secret in the conversation and never repeat one; if the person pastes one
39
+ anyway, it counts as leaked: tell them to rotate it at the third-party platform. The guide and
40
+ the check results never contain secret values, and no setup operation takes one.
41
+ - **Connecting a personal account** (OAuth consent) happens in the person's browser: call
42
+ `connectors.connect`, which shows the person a Connect button in the conversation, then check
43
+ `connectors.get` for the connection state.
40
44
  - **Confirming the app was updated** after a guide changed (the drift notice) is the person's
41
- click on the target's page: only they know they changed the app at the third party.
45
+ confirmation: only they know they changed the app at the third party. For a connector,
46
+ `connectors.guide-ack` puts that statement on its confirmation card (the hash `connectors.get`
47
+ shows under `setupGuide`); for a channel connection, `channels.guide-ack` does (the `hash` of
48
+ `setup.read` for the connection, audience admin, its inbound mode). A stale hash is refused
49
+ before the card: read the guide again and walk the person through the change.
42
50
  - **Creating the app** at the third-party platform is outside Capybara: explain it, the person
43
51
  does it.
44
52
 
@@ -101,6 +101,14 @@ export interface LegacyDeviceHello {
101
101
  * A malformed value is dropped by the parser.
102
102
  */
103
103
  bootId?: string;
104
+ /**
105
+ * The identity of this run of the program: random, chosen once when the process starts and
106
+ * the same on every connection it makes (never the OS pid). The results a program keeps for a
107
+ * reconnect live in its memory, so a value that differs from the one a request was sent to
108
+ * proves that request's result can no longer arrive: the kernel ends its wait at once instead of
109
+ * at the deadline. Same format as {@link bootId}; a malformed value is dropped by the parser.
110
+ */
111
+ programRunId?: string;
104
112
  }
105
113
  /** A hello's `bootId`: 1 to 128 characters of letters, digits, `.`, `_`, `:` and `-`. */
106
114
  export declare const DEVICE_BOOT_ID_RE: RegExp;
@@ -278,6 +278,8 @@ function optionalHelloFields(o) {
278
278
  }
279
279
  if (isDeviceBootId(o.bootId))
280
280
  out.bootId = o.bootId;
281
+ if (isDeviceBootId(o.programRunId))
282
+ out.programRunId = o.programRunId;
281
283
  return { ...out, ...optionalPolicy(o.policy) };
282
284
  }
283
285
  /** A summary field that is dropped when absent or unreadable. */
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "0.1.0-rc.42";
1
+ export declare const SDK_VERSION = "0.1.0-rc.44";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./bootstrap.js";
4
4
  export * from "./cards.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = "0.1.0-rc.42";
1
+ export const SDK_VERSION = "0.1.0-rc.44";
2
2
  export * from "./agent-template.js";
3
3
  export * from "./bootstrap.js";
4
4
  export * from "./cards.js";
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Private Python 3 transport: one JSON request on stdin, one result/error on stdout.
3
3
  * The trusted caller supplies already-authorized canonical root paths and inherited directory
4
- * descriptors in roots.read/roots.write ({path, fd}); this helper never selects a profile.
4
+ * descriptors in roots.read/roots.write ({path, fd}); this helper never selects a profile. A read
5
+ * root may be a single file ({path, fd, file: true}): fd is then its parent directory, and only
6
+ * that one name below it is reachable through the root.
5
7
  * Binary data uses dataB64. Callers own launch, signal handling, admission and error translation.
6
8
  * Descriptor-relative native access alone does not establish an OS execution boundary.
7
9
  */
@@ -3,7 +3,9 @@ import { SANDBOX_WRITE_POLICY_PYTHON } from "./sandbox-write-denies.js";
3
3
  /**
4
4
  * Private Python 3 transport: one JSON request on stdin, one result/error on stdout.
5
5
  * The trusted caller supplies already-authorized canonical root paths and inherited directory
6
- * descriptors in roots.read/roots.write ({path, fd}); this helper never selects a profile.
6
+ * descriptors in roots.read/roots.write ({path, fd}); this helper never selects a profile. A read
7
+ * root may be a single file ({path, fd, file: true}): fd is then its parent directory, and only
8
+ * that one name below it is reachable through the root.
7
9
  * Binary data uses dataB64. Callers own launch, signal handling, admission and error translation.
8
10
  * Descriptor-relative native access alone does not establish an OS execution boundary.
9
11
  */
@@ -129,6 +131,8 @@ class NativeFiles:
129
131
  for root in roots["read"] + roots["write"]:
130
132
  if not valid_path(root["path"]) or os.path.normpath(root["path"]) != root["path"]:
131
133
  raise ValueError("Supply canonical absolute root paths")
134
+ if root.get("file") is True and (root in roots["write"] or root["path"] == "/"):
135
+ raise ValueError("Only a read root may be a single file")
132
136
  if not stat.S_ISDIR(os.fstat(root["fd"]).st_mode):
133
137
  raise ValueError("Supply pinned directory descriptors")
134
138
 
@@ -150,6 +154,11 @@ class NativeFiles:
150
154
  fd = os.dup(root["fd"])
151
155
  current = root["path"]
152
156
  parts = os.path.relpath(path, current).split("/")
157
+ if root.get("file") is True:
158
+ # a single-file root: walked from its parent directory, so the file's own name is
159
+ # the first component (anything below it is no directory, so missing for a reader)
160
+ current = os.path.dirname(root["path"])
161
+ parts = [os.path.basename(root["path"])] + ([] if path == root["path"] else parts)
153
162
  result = self.walk(fd, current, parts, write, create, links, must_exist)
154
163
  if write and self.deny_writes and write_denied(result[2]):
155
164
  os.close(result[0])
@@ -241,6 +250,8 @@ class NativeFiles:
241
250
  return None
242
251
  best = None
243
252
  for root in self.roots["read"] + self.roots["write"]:
253
+ if root.get("file") is True:
254
+ continue # its descriptor is the parent directory, not the root's path
244
255
  try:
245
256
  now = os.readlink("/proc/self/fd/%d" % root["fd"]).rstrip("/")
246
257
  except OSError:
@@ -17,7 +17,7 @@ export const SANDBOX_RUNTIME_SOURCE = Object.freeze({
17
17
  Object.freeze({
18
18
  name: "native-files.py",
19
19
  source: NATIVE_FILES_SOURCE,
20
- sha256: "9bde40a697fd60f2c9073b7fc35e84b4cffd045463e3ab5116a2c3435fd55df0",
20
+ sha256: "c1712198af4ffedc0b48f789c28ed4233dc9008521b897300731c4f903168950",
21
21
  }),
22
22
  Object.freeze({
23
23
  name: "linux-sandbox.py",
@@ -6,10 +6,14 @@
6
6
  */
7
7
  /** Capability keys, `name@major`; each value is a key of `SHELL_CAPABILITIES`. */
8
8
  export declare const SHELL_CAPABILITY_KEYS: {
9
+ readonly chrome: "chrome@1";
9
10
  readonly device: "device@1";
10
11
  readonly notify: "notify@1";
11
12
  readonly openExternal: "openExternal@1";
12
13
  readonly signIn: "signIn@1";
14
+ readonly haptics: "haptics@1";
15
+ readonly share: "share@1";
16
+ readonly menu: "menu@1";
13
17
  };
14
18
  export type KeepAwakeMode = "off" | "while-busy" | "connected";
15
19
  export type DeviceConnection = "starting" | "online" | "offline" | "draining" | "stopped";
@@ -86,3 +90,78 @@ export interface OpenExternalCapabilityV1 {
86
90
  export interface SignInCapabilityV1 {
87
91
  start(): Promise<"signedIn" | "cancelled">;
88
92
  }
93
+ /**
94
+ * The page's main color tokens (the computed `--cb-bg`, `--cb-panel`, `--cb-ink`, `--cb-muted`,
95
+ * `--cb-line`, `--cb-accent`, `--cb-on-accent`), each a CSS hex or `rgb()` / `rgba()` color. The
96
+ * shell validates them and uses them only as custom properties of its own pages, never as markup.
97
+ */
98
+ export interface ShellChromeTokens {
99
+ bg: string;
100
+ panel: string;
101
+ ink: string;
102
+ muted: string;
103
+ line: string;
104
+ accent: string;
105
+ onAccent: string;
106
+ }
107
+ /**
108
+ * `chrome@1` (mobile layout spec §9.2): the native chrome (window background, title bar, the
109
+ * shell's own pages) follows the page's theme. `tokens` is sent only when all seven are colors;
110
+ * `singleScheme` is true under a UI theme with one scheme (no light / dark toggle on either side).
111
+ */
112
+ export interface ChromeCapabilityV1 {
113
+ setAppearance(input: {
114
+ scheme: "light" | "dark";
115
+ background: string;
116
+ tokens?: ShellChromeTokens;
117
+ singleScheme?: boolean;
118
+ }): Promise<void>;
119
+ /** The web's first paint is done (mobile app spec §5.2); a shell may leave it out. */
120
+ ready?(): Promise<void>;
121
+ }
122
+ export type HapticKind = "selection" | "light" | "success" | "warning";
123
+ /** `haptics@1`: a haptic impact (mobile app spec §5.2). */
124
+ export interface HapticsCapabilityV1 {
125
+ impact(kind: HapticKind): Promise<void>;
126
+ }
127
+ export interface ShareInputV1 {
128
+ title?: string;
129
+ text?: string;
130
+ url?: string;
131
+ }
132
+ /** `share@1`: the system share sheet; resolves whether shared or dismissed. */
133
+ export interface ShareCapabilityV1 {
134
+ share(input: ShareInputV1): Promise<void>;
135
+ }
136
+ export interface MenuItemV1 {
137
+ id: string;
138
+ label: string;
139
+ destructive?: boolean;
140
+ disabled?: boolean;
141
+ }
142
+ export interface MenuInputV1 {
143
+ title?: string;
144
+ items: MenuItemV1[];
145
+ /** A rect in CSS px from the web view's top-left corner. */
146
+ anchor?: {
147
+ x: number;
148
+ y: number;
149
+ width: number;
150
+ height: number;
151
+ };
152
+ }
153
+ /** `menu@1`: a native menu; resolves the chosen item id, or null when dismissed. */
154
+ export interface MenuCapabilityV1 {
155
+ show(input: MenuInputV1): Promise<string | null>;
156
+ }
157
+ /** The shell validates every input against these (and the web keeps within them). */
158
+ export declare const MOBILE_SHELL_LIMITS: {
159
+ readonly menuItems: 12;
160
+ readonly menuLabel: 64;
161
+ readonly menuTitle: 128;
162
+ readonly shareTitle: 256;
163
+ readonly shareText: 4000;
164
+ readonly url: 2048;
165
+ };
166
+ /** The menu item id pattern, checked on `menu@1.show` (the shell validates every input). */
167
+ export declare const MENU_ITEM_ID: RegExp;
@@ -6,8 +6,23 @@
6
6
  */
7
7
  /** Capability keys, `name@major`; each value is a key of `SHELL_CAPABILITIES`. */
8
8
  export const SHELL_CAPABILITY_KEYS = {
9
+ chrome: "chrome@1",
9
10
  device: "device@1",
10
11
  notify: "notify@1",
11
12
  openExternal: "openExternal@1",
12
13
  signIn: "signIn@1",
14
+ haptics: "haptics@1",
15
+ share: "share@1",
16
+ menu: "menu@1",
13
17
  };
18
+ /** The shell validates every input against these (and the web keeps within them). */
19
+ export const MOBILE_SHELL_LIMITS = {
20
+ menuItems: 12,
21
+ menuLabel: 64,
22
+ menuTitle: 128,
23
+ shareTitle: 256,
24
+ shareText: 4000,
25
+ url: 2048,
26
+ };
27
+ /** The menu item id pattern, checked on `menu@1.show` (the shell validates every input). */
28
+ export const MENU_ITEM_ID = /^[A-Za-z0-9_.-]{1,64}$/;
@@ -13,4 +13,7 @@ export const SHELL_CAPABILITIES = [
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" },
15
15
  { key: "chrome@1", owner: "mobile layout spec (2026-11-19-mobile-layout-design.md)" },
16
+ { key: "haptics@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2" },
17
+ { key: "share@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2" },
18
+ { key: "menu@1", owner: "mobile app spec (2026-11-20-mobile-app-design.md), §5.2" },
16
19
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-sdk",
3
- "version": "0.1.0-rc.42",
3
+ "version": "0.1.0-rc.44",
4
4
  "description": "Capybara plugin SDK: the types and pure functions plugins are written against",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {