@capybara-hq/plugin-sdk 0.1.0-rc.16 → 0.1.0-rc.18
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/dist/dev-hosts.js +4 -1
- package/dist/device-protocol.d.ts +21 -2
- package/dist/device-protocol.js +27 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/theme-tokens.generated.js +5 -0
- package/package.json +1 -1
package/dist/dev-hosts.js
CHANGED
|
@@ -39,7 +39,10 @@ export const DEV_HOSTS = Object.freeze([
|
|
|
39
39
|
"registry-1.docker.io",
|
|
40
40
|
"auth.docker.io",
|
|
41
41
|
"production.cloudflare.docker.com",
|
|
42
|
-
// Playwright browsers
|
|
42
|
+
// Playwright browsers (`npx playwright install`, checked against playwright-core 1.64): Firefox,
|
|
43
|
+
// WebKit and ffmpeg come from the Playwright CDN and its Microsoft mirror; Chromium is Chrome
|
|
44
|
+
// for Testing, which cdn.playwright.dev redirects to storage.googleapis.com
|
|
43
45
|
"cdn.playwright.dev",
|
|
44
46
|
"playwright.download.prss.microsoft.com",
|
|
47
|
+
"storage.googleapis.com",
|
|
45
48
|
]);
|
|
@@ -35,6 +35,14 @@ export interface DeviceLocalPolicySummary {
|
|
|
35
35
|
allowedDomains: string[];
|
|
36
36
|
remoteGrants: DeviceRemoteGrants;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* The first line of the kernel's background task launch command (`Bash` `run_in_background`), a
|
|
40
|
+
* shell comment. A device kills what a foreground exec leaves running once the exec ends; an exec
|
|
41
|
+
* whose command starts with this line detaches a task on purpose, and its processes are left alone.
|
|
42
|
+
*/
|
|
43
|
+
export declare const BACKGROUND_LAUNCH_LINE = "# capybara: background task launch";
|
|
44
|
+
/** Whether an exec's command is a background task launch ({@link BACKGROUND_LAUNCH_LINE}). */
|
|
45
|
+
export declare function isBackgroundLaunch(command: string): boolean;
|
|
38
46
|
/** The most blocked hosts an exec result reports; the parser cuts longer lists. */
|
|
39
47
|
export declare const MAX_NETWORK_BLOCKED_HOSTS = 20;
|
|
40
48
|
/** First frame from the device after the WebSocket opens. */
|
|
@@ -82,7 +90,17 @@ export interface KernelCancel {
|
|
|
82
90
|
type: "cancel";
|
|
83
91
|
id: string;
|
|
84
92
|
}
|
|
85
|
-
|
|
93
|
+
/**
|
|
94
|
+
* The device's local policy changed while connected (its file was edited on the machine, the
|
|
95
|
+
* localhost proxy guard flipped, a new tier ceiling): the summary as it is now, sent only when it
|
|
96
|
+
* differs from the last one sent on this connection. `policy` is absent when the frame's summary
|
|
97
|
+
* was unreadable; the kernel then keeps only its isolation, from the raw frame, as for the hello.
|
|
98
|
+
*/
|
|
99
|
+
export interface DevicePolicyChanged {
|
|
100
|
+
type: "policy";
|
|
101
|
+
policy?: DeviceLocalPolicySummary;
|
|
102
|
+
}
|
|
103
|
+
export type DeviceFrame = DeviceHello | DeviceRes | DevicePolicyChanged | KernelReq | KernelCancel;
|
|
86
104
|
export interface DeviceExecArgs {
|
|
87
105
|
command: string;
|
|
88
106
|
cwd?: string;
|
|
@@ -187,7 +205,8 @@ export interface DeviceOpResults {
|
|
|
187
205
|
/** Validates the `result` of a successful `res` for `op`; throws {@link DeviceProtocolError}. */
|
|
188
206
|
export declare function parseOpResult<Op extends DeviceOp>(op: Op, result: unknown): DeviceOpResults[Op];
|
|
189
207
|
/**
|
|
190
|
-
* Parses one WebSocket text frame. `from` is the sender: a device may send `hello
|
|
208
|
+
* Parses one WebSocket text frame. `from` is the sender: a device may send `hello`, `res` and
|
|
209
|
+
* `policy`, the
|
|
191
210
|
* kernel `req` and `cancel`. Throws {@link DeviceProtocolError} on bad JSON, an unknown `type`,
|
|
192
211
|
* missing fields or a frame of the wrong direction.
|
|
193
212
|
*/
|
package/dist/device-protocol.js
CHANGED
|
@@ -17,6 +17,16 @@ const DEVICE_OPS = [
|
|
|
17
17
|
"policy",
|
|
18
18
|
];
|
|
19
19
|
const DEVICE_FEATURES = ["networkReport", "policyOp", "tiers"];
|
|
20
|
+
/**
|
|
21
|
+
* The first line of the kernel's background task launch command (`Bash` `run_in_background`), a
|
|
22
|
+
* shell comment. A device kills what a foreground exec leaves running once the exec ends; an exec
|
|
23
|
+
* whose command starts with this line detaches a task on purpose, and its processes are left alone.
|
|
24
|
+
*/
|
|
25
|
+
export const BACKGROUND_LAUNCH_LINE = "# capybara: background task launch";
|
|
26
|
+
/** Whether an exec's command is a background task launch ({@link BACKGROUND_LAUNCH_LINE}). */
|
|
27
|
+
export function isBackgroundLaunch(command) {
|
|
28
|
+
return command === BACKGROUND_LAUNCH_LINE || command.startsWith(`${BACKGROUND_LAUNCH_LINE}\n`);
|
|
29
|
+
}
|
|
20
30
|
/** The most blocked hosts an exec result reports; the parser cuts longer lists. */
|
|
21
31
|
export const MAX_NETWORK_BLOCKED_HOSTS = 20;
|
|
22
32
|
/** The most hosts a `policy` op's `add` / `remove` or an exec's `grants` may carry. */
|
|
@@ -168,15 +178,19 @@ function optionalHelloFields(o) {
|
|
|
168
178
|
if (Array.isArray(o.features)) {
|
|
169
179
|
out.features = DEVICE_FEATURES.filter((f) => o.features.includes(f));
|
|
170
180
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
return { ...out, ...optionalPolicy(o.policy) };
|
|
182
|
+
}
|
|
183
|
+
/** A summary field that is dropped when absent or unreadable. */
|
|
184
|
+
function optionalPolicy(v) {
|
|
185
|
+
if (v === undefined)
|
|
186
|
+
return {};
|
|
187
|
+
try {
|
|
188
|
+
return { policy: parsePolicySummary(v) };
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
// an unreadable summary is the same as none: the kernel learns the policy later
|
|
192
|
+
return {};
|
|
178
193
|
}
|
|
179
|
-
return out;
|
|
180
194
|
}
|
|
181
195
|
const BLOCK_LAYERS = ["device", "org", "address", "unknown"];
|
|
182
196
|
/**
|
|
@@ -387,7 +401,8 @@ export function parseOpResult(op, result) {
|
|
|
387
401
|
}
|
|
388
402
|
}
|
|
389
403
|
/**
|
|
390
|
-
* Parses one WebSocket text frame. `from` is the sender: a device may send `hello
|
|
404
|
+
* Parses one WebSocket text frame. `from` is the sender: a device may send `hello`, `res` and
|
|
405
|
+
* `policy`, the
|
|
391
406
|
* kernel `req` and `cancel`. Throws {@link DeviceProtocolError} on bad JSON, an unknown `type`,
|
|
392
407
|
* missing fields or a frame of the wrong direction.
|
|
393
408
|
*/
|
|
@@ -405,8 +420,11 @@ export function parseDeviceFrame(raw, from) {
|
|
|
405
420
|
switch (type) {
|
|
406
421
|
case "hello":
|
|
407
422
|
case "res":
|
|
423
|
+
case "policy":
|
|
408
424
|
if (from !== "device")
|
|
409
425
|
throw new DeviceProtocolError(`"${type}" must come from the device`);
|
|
426
|
+
if (type === "policy")
|
|
427
|
+
return { type, ...optionalPolicy(o.policy) };
|
|
410
428
|
return type === "hello" ? parseHello(o) : parseRes(o);
|
|
411
429
|
case "req":
|
|
412
430
|
case "cancel":
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -125,6 +125,11 @@ export const THEME_CONTRAST = [
|
|
|
125
125
|
["muted", "raised", 4.5],
|
|
126
126
|
["muted", "selected", 4.5],
|
|
127
127
|
["muted", "hover", 4.5],
|
|
128
|
+
["ink", "hover", 4.5, "panel"],
|
|
129
|
+
["ink", "selected", 4.5, "panel"],
|
|
130
|
+
["muted", "hover", 4.5, "panel"],
|
|
131
|
+
["fail", "selected", 4.5, "panel"],
|
|
132
|
+
["accent", "selected", 3, "panel"],
|
|
128
133
|
["disabled", "bg", 3],
|
|
129
134
|
["disabled", "panel", 3],
|
|
130
135
|
["disabled", "hover", 3],
|