@capybara-hq/plugin-sdk 0.1.0-rc.59 → 0.1.0-rc.60
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/agent-docs/plugin-format.md +1 -4
- package/dist/device-denied-paths.d.ts +6 -3
- package/dist/device-denied-paths.js +31 -4
- package/dist/device-operation.d.ts +14 -1
- package/dist/device-protocol.js +19 -0
- package/dist/device-provider.d.ts +16 -2
- package/dist/device-provider.js +13 -2
- package/dist/dial-in.d.ts +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/setup-guide-parse.d.ts +1 -15
- package/dist/setup-guide-parse.js +1 -58
- package/dist/setup-guide-render.d.ts +2 -7
- package/dist/setup-guide-render.js +1 -17
- package/dist/setup-guide.d.ts +3 -11
- package/dist/setup-guide.js +8 -20
- package/dist/shell-capabilities.d.ts +0 -76
- package/dist/shell-capabilities.js +0 -1
- package/dist/shell-environment.js +0 -1
- package/package.json +1 -1
|
@@ -97,10 +97,7 @@ A guide is CommonMark + GFM:
|
|
|
97
97
|
`connector-connected`, `oauth-token-endpoint`). The label is plain text, at most 80 characters.
|
|
98
98
|
- Code fences: `<language> title="<text>"`; every block gets a copy button. Indented code blocks are
|
|
99
99
|
refused. Raw HTML shows as text, images are never loaded, and only `https:` links stay links.
|
|
100
|
-
-
|
|
101
|
-
<label>` in column 0 is a button that asks the native shell to connect the machine the page runs
|
|
102
|
-
on; at most 4 per document, the label is plain text (at most 80 characters, no variables).
|
|
103
|
-
- The zh document has the same sections, the same check ids, the same shell actions and byte-equal code blocks.
|
|
100
|
+
- The zh document has the same sections, the same check ids and byte-equal code blocks.
|
|
104
101
|
- Limits: 64 KiB per document, 24 code blocks, 16 checks, 16 sections.
|
|
105
102
|
|
|
106
103
|
`capybara-plugin pack` and `check` validate the documents; `capybara-plugin guide <id> [--locale zh]
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* to `~` (spec §13.6, extended by ruling R19): SSH keys, cloud CLI credentials, container and
|
|
4
4
|
* Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, the
|
|
5
5
|
* browser profile directories, other tool credential stores (cargo, 1Password, Vault, Terraform,
|
|
6
|
-
* Claude, Codex, keyrings, pass, rclone, s3cmd, mise
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Claude, Codex, keyrings, pass, rclone, s3cmd), mise's config directory and the config files it
|
|
7
|
+
* loads from the home (an `[env]` section may hold tokens; globbed names like `~/mise.<env>.toml`
|
|
8
|
+
* are not listed), Maven and Gradle credential files, and shell histories. One source for
|
|
9
|
+
* the device, which denies them (and its own state directory), and the kernel, which never proposes
|
|
10
|
+
* an approval for a path under one. Full access and auto mode run as the owner and do not apply
|
|
11
|
+
* them: the command review does.
|
|
9
12
|
*/
|
|
10
13
|
export declare const DEVICE_DENIED_SECRET_PATHS: readonly string[];
|
|
11
14
|
/**
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* to `~` (spec §13.6, extended by ruling R19): SSH keys, cloud CLI credentials, container and
|
|
4
4
|
* Kubernetes credentials, netrc, GnuPG, git / npm / PyPI tokens, the macOS keychains, the
|
|
5
5
|
* browser profile directories, other tool credential stores (cargo, 1Password, Vault, Terraform,
|
|
6
|
-
* Claude, Codex, keyrings, pass, rclone, s3cmd, mise
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Claude, Codex, keyrings, pass, rclone, s3cmd), mise's config directory and the config files it
|
|
7
|
+
* loads from the home (an `[env]` section may hold tokens; globbed names like `~/mise.<env>.toml`
|
|
8
|
+
* are not listed), Maven and Gradle credential files, and shell histories. One source for
|
|
9
|
+
* the device, which denies them (and its own state directory), and the kernel, which never proposes
|
|
10
|
+
* an approval for a path under one. Full access and auto mode run as the owner and do not apply
|
|
11
|
+
* them: the command review does.
|
|
9
12
|
*/
|
|
10
13
|
export const DEVICE_DENIED_SECRET_PATHS = Object.freeze([
|
|
11
14
|
"~/.ssh",
|
|
@@ -46,7 +49,31 @@ export const DEVICE_DENIED_SECRET_PATHS = Object.freeze([
|
|
|
46
49
|
"~/.password-store",
|
|
47
50
|
"~/.config/rclone",
|
|
48
51
|
"~/.s3cfg",
|
|
49
|
-
|
|
52
|
+
// mise: its whole config directory (config files with [env] sections, the sops age key; its
|
|
53
|
+
// data lives in ~/.local/share/mise) and the config files it walks up to in the home. Globbed
|
|
54
|
+
// spellings such as ~/mise.<env>.toml cannot be listed here and stay readable.
|
|
55
|
+
"~/.config/mise",
|
|
56
|
+
"~/.config/mise.toml",
|
|
57
|
+
"~/.config/mise.local.toml",
|
|
58
|
+
"~/.mise.toml",
|
|
59
|
+
"~/.mise.local.toml",
|
|
60
|
+
"~/.mise",
|
|
61
|
+
"~/mise.toml",
|
|
62
|
+
"~/mise.local.toml",
|
|
63
|
+
"~/mise/config.toml",
|
|
64
|
+
"~/mise/config.local.toml",
|
|
65
|
+
"~/mise/conf.d",
|
|
66
|
+
// mise's legacy (rtx) names
|
|
67
|
+
"~/.rtx.toml",
|
|
68
|
+
"~/.rtx.local.toml",
|
|
69
|
+
// Maven server passwords (and their master keys), Gradle repository credentials and Develocity
|
|
70
|
+
// (Gradle Enterprise) access keys
|
|
71
|
+
"~/.m2/settings.xml",
|
|
72
|
+
"~/.m2/settings-security.xml",
|
|
73
|
+
"~/.m2/settings-security4.xml",
|
|
74
|
+
"~/.gradle/gradle.properties",
|
|
75
|
+
"~/.gradle/develocity/keys.properties",
|
|
76
|
+
"~/.gradle/enterprise/keys.properties",
|
|
50
77
|
"~/.bash_history",
|
|
51
78
|
"~/.zsh_history",
|
|
52
79
|
]);
|
|
@@ -124,7 +124,8 @@ export type SandboxBoundary = "operation" | "instance";
|
|
|
124
124
|
* Runtime support, version 2 (approval-only profiles design, "SDK and protocol"). `boundary:
|
|
125
125
|
* "instance"` with `restricted: null` is a supported device whose scope is the whole instance.
|
|
126
126
|
* `outsideSandbox` says whether a call can run outside the sandbox (an escalated call). Runtime
|
|
127
|
-
* support, not consent.
|
|
127
|
+
* support, not consent. `limitedBy` names who keeps a crossing closed when it is not the provider
|
|
128
|
+
* itself ({@link SandboxSupportLimitedBy}); absent, a closed crossing is the provider's own limit.
|
|
128
129
|
*/
|
|
129
130
|
export interface SandboxPermissionSupport {
|
|
130
131
|
readonly version: 2;
|
|
@@ -143,6 +144,18 @@ export interface SandboxPermissionSupport {
|
|
|
143
144
|
readonly outsideSandbox: boolean;
|
|
144
145
|
readonly background: boolean;
|
|
145
146
|
readonly unavailableReason?: string;
|
|
147
|
+
readonly limitedBy?: SandboxSupportLimitedBy;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Who keeps a closed crossing of a {@link SandboxPermissionSupport} closed, when it is not the
|
|
151
|
+
* provider itself: `owner` is the owner of the machine the device runs on (for example a local
|
|
152
|
+
* connection's owner ceiling, set on that machine). Only a closed crossing may name one:
|
|
153
|
+
* `outsideSandbox` with `outsideSandbox: false`, `openPublic` with `network.openPublic: false`.
|
|
154
|
+
* Display only: the kernel names that layer in its refusals and never enforces from it.
|
|
155
|
+
*/
|
|
156
|
+
export interface SandboxSupportLimitedBy {
|
|
157
|
+
readonly outsideSandbox?: "owner";
|
|
158
|
+
readonly openPublic?: "owner";
|
|
146
159
|
}
|
|
147
160
|
/**
|
|
148
161
|
* Whether a report is a supported instance boundary: `boundary: "instance"` with no
|
package/dist/device-protocol.js
CHANGED
|
@@ -491,6 +491,7 @@ export function parseSandboxPermissionSupport(value) {
|
|
|
491
491
|
"outsideSandbox",
|
|
492
492
|
"background",
|
|
493
493
|
"unavailableReason",
|
|
494
|
+
"limitedBy",
|
|
494
495
|
], what);
|
|
495
496
|
if (o.version !== 2)
|
|
496
497
|
throw new DeviceProtocolError(`Invalid ${what}: expected version 2`);
|
|
@@ -523,6 +524,23 @@ export function parseSandboxPermissionSupport(value) {
|
|
|
523
524
|
throw new DeviceProtocolError(`Invalid ${what}: an instance boundary claims no restricted scope, outside escalation or per-operation hosts`);
|
|
524
525
|
if (o.unavailableReason !== undefined)
|
|
525
526
|
string(o.unavailableReason, 4096);
|
|
527
|
+
let limitedBy;
|
|
528
|
+
if (o.limitedBy !== undefined) {
|
|
529
|
+
const l = strictRecord(o.limitedBy, ["outsideSandbox", "openPublic"], `${what} limitedBy`);
|
|
530
|
+
limitedBy = {};
|
|
531
|
+
for (const [key, open] of [
|
|
532
|
+
["outsideSandbox", outsideSandbox],
|
|
533
|
+
["openPublic", network.openPublic],
|
|
534
|
+
]) {
|
|
535
|
+
if (l[key] === undefined)
|
|
536
|
+
continue;
|
|
537
|
+
if (l[key] !== "owner")
|
|
538
|
+
throw new DeviceProtocolError(`Invalid ${what}: limitedBy.${key} must be owner`);
|
|
539
|
+
if (open)
|
|
540
|
+
throw new DeviceProtocolError(`Invalid ${what}: limitedBy.${key} names who keeps a closed crossing closed, but it is open`);
|
|
541
|
+
limitedBy[key] = "owner";
|
|
542
|
+
}
|
|
543
|
+
}
|
|
526
544
|
return freeze({
|
|
527
545
|
version: 2,
|
|
528
546
|
boundary: o.boundary,
|
|
@@ -533,6 +551,7 @@ export function parseSandboxPermissionSupport(value) {
|
|
|
533
551
|
...(o.unavailableReason !== undefined
|
|
534
552
|
? { unavailableReason: o.unavailableReason }
|
|
535
553
|
: {}),
|
|
554
|
+
...(limitedBy !== undefined && Object.keys(limitedBy).length > 0 ? { limitedBy } : {}),
|
|
536
555
|
});
|
|
537
556
|
}
|
|
538
557
|
/**
|
|
@@ -150,8 +150,20 @@ export interface DeviceReportLimit {
|
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* What a provider tells about a device ({@link DeviceProvider.report}): shown to people, never
|
|
153
|
-
* used for enforcement. `revision`
|
|
154
|
-
*
|
|
153
|
+
* used for enforcement. `revision` must change whenever anything that affects what was approved
|
|
154
|
+
* against the report changes (how operations are confined, what the device may reach): a new
|
|
155
|
+
* revision invalidates the approvals, grants and pending admissions bound to the old one.
|
|
156
|
+
* Display-only facts (for example the shared project roots shown as a limit line) may change
|
|
157
|
+
* without a revision change: announce such a change with `ctx.devices.reportChanged`, and the
|
|
158
|
+
* kernel stores the new text without invalidating anything. `home` is the owner's home directory
|
|
159
|
+
* (absolute) or null; `reset` says whether the provider can reset the device's files.
|
|
160
|
+
*
|
|
161
|
+
* `changeHint` (optional) says in the provider's own words who can change the device's limits and
|
|
162
|
+
* how (for a local connection: the machine's owner, with a command on that machine; for a
|
|
163
|
+
* container: the super admin's deployment config of the extension). The device page shows it
|
|
164
|
+
* under the limits, and the kernel appends it to a refusal that cites the report (an escalated
|
|
165
|
+
* call the provider does not allow now), so a person and the model learn the way out. State the
|
|
166
|
+
* mechanism, not advice for one situation.
|
|
155
167
|
*/
|
|
156
168
|
export interface DeviceReport {
|
|
157
169
|
revision: string;
|
|
@@ -159,6 +171,7 @@ export interface DeviceReport {
|
|
|
159
171
|
home: string | null;
|
|
160
172
|
limits: DeviceReportLimit[];
|
|
161
173
|
reset: boolean;
|
|
174
|
+
changeHint?: DeviceText;
|
|
162
175
|
}
|
|
163
176
|
/** Size limits {@link parseDeviceReport} enforces. */
|
|
164
177
|
export declare const DEVICE_REPORT_LIMITS: Readonly<{
|
|
@@ -168,6 +181,7 @@ export declare const DEVICE_REPORT_LIMITS: Readonly<{
|
|
|
168
181
|
limitLabelChars: 60;
|
|
169
182
|
limitValueChars: 60;
|
|
170
183
|
homeChars: 4096;
|
|
184
|
+
changeHintChars: 400;
|
|
171
185
|
}>;
|
|
172
186
|
/** Checks a provider's report; throws `TypeError` on any other shape, returns a clean copy. */
|
|
173
187
|
export declare function parseDeviceReport(value: unknown): DeviceReport;
|
package/dist/device-provider.js
CHANGED
|
@@ -77,6 +77,7 @@ export const DEVICE_REPORT_LIMITS = Object.freeze({
|
|
|
77
77
|
limitLabelChars: 60,
|
|
78
78
|
limitValueChars: 60,
|
|
79
79
|
homeChars: 4096,
|
|
80
|
+
changeHintChars: 400,
|
|
80
81
|
});
|
|
81
82
|
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
82
83
|
function exactKeys(v, keys, what) {
|
|
@@ -105,7 +106,7 @@ export function parseDeviceReport(value) {
|
|
|
105
106
|
const L = DEVICE_REPORT_LIMITS;
|
|
106
107
|
if (!isRecord(value))
|
|
107
108
|
throw new TypeError("device report must be an object");
|
|
108
|
-
exactKeys(value, ["revision", "description", "home", "limits", "reset"], "device report");
|
|
109
|
+
exactKeys(value, ["revision", "description", "home", "limits", "reset", "changeHint"], "device report");
|
|
109
110
|
const { revision, home, limits, reset } = value;
|
|
110
111
|
if (typeof revision !== "string" || revision === "" || revision.length > L.revisionChars) {
|
|
111
112
|
throw new TypeError(`device report revision must be a non-empty string of at most ${L.revisionChars} characters`);
|
|
@@ -134,7 +135,17 @@ export function parseDeviceReport(value) {
|
|
|
134
135
|
});
|
|
135
136
|
if (typeof reset !== "boolean")
|
|
136
137
|
throw new TypeError("device report reset must be a boolean");
|
|
137
|
-
|
|
138
|
+
const changeHint = value.changeHint === undefined
|
|
139
|
+
? undefined
|
|
140
|
+
: parseText(value.changeHint, L.changeHintChars, "device report changeHint");
|
|
141
|
+
return {
|
|
142
|
+
revision,
|
|
143
|
+
description,
|
|
144
|
+
home,
|
|
145
|
+
limits: parsedLimits,
|
|
146
|
+
reset,
|
|
147
|
+
...(changeHint !== undefined && { changeHint }),
|
|
148
|
+
};
|
|
138
149
|
}
|
|
139
150
|
/**
|
|
140
151
|
* The provider refuses a project directory (`projects` operations: it lies where the provider
|
package/dist/dial-in.d.ts
CHANGED
|
@@ -158,8 +158,10 @@ export interface DialInChannel {
|
|
|
158
158
|
export interface DevicesCtx {
|
|
159
159
|
/**
|
|
160
160
|
* The device's report (`DeviceProvider.report`) or its permission support may have changed: the
|
|
161
|
-
* kernel reads the report
|
|
162
|
-
* against the old
|
|
161
|
+
* kernel reads the report (and the permission support of the device's instance, if any) again
|
|
162
|
+
* and stores them. When the revision changed, it invalidates what was approved against the old
|
|
163
|
+
* one; when only display text changed under the same revision, the new text is stored and no
|
|
164
|
+
* approval is invalidated.
|
|
163
165
|
*/
|
|
164
166
|
reportChanged(deviceId: string): Promise<void>;
|
|
165
167
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -39,14 +39,6 @@ export interface SetupGuideCheckLine {
|
|
|
39
39
|
/** Index of the innermost enclosing section, or null. */
|
|
40
40
|
section: number | null;
|
|
41
41
|
}
|
|
42
|
-
/** A `::shell-action` line of a document. */
|
|
43
|
-
export interface SetupGuideShellActionLine {
|
|
44
|
-
action: string;
|
|
45
|
-
label: string;
|
|
46
|
-
line: number;
|
|
47
|
-
/** Index of the innermost enclosing section, or null. */
|
|
48
|
-
section: number | null;
|
|
49
|
-
}
|
|
50
42
|
/** A fenced code block of a document. */
|
|
51
43
|
export interface SetupGuideCodeBlock {
|
|
52
44
|
/** The info string's first word; empty when missing. */
|
|
@@ -63,12 +55,11 @@ export interface ParsedSetupGuide {
|
|
|
63
55
|
title: string | null;
|
|
64
56
|
sections: SetupGuideSection[];
|
|
65
57
|
checks: SetupGuideCheckLine[];
|
|
66
|
-
shellActions: SetupGuideShellActionLine[];
|
|
67
58
|
codeBlocks: SetupGuideCodeBlock[];
|
|
68
59
|
/** Structural problems (place independent: modes, audiences and variables are not judged). */
|
|
69
60
|
issues: SetupGuideParseIssue[];
|
|
70
61
|
}
|
|
71
|
-
type LineKind = "text" | "fence" | "section-open" | "section-close" | "check"
|
|
62
|
+
type LineKind = "text" | "fence" | "section-open" | "section-close" | "check";
|
|
72
63
|
/** @internal The scanner's result. */
|
|
73
64
|
export interface GuideScan {
|
|
74
65
|
lines: string[];
|
|
@@ -77,11 +68,8 @@ export interface GuideScan {
|
|
|
77
68
|
stacks: number[][];
|
|
78
69
|
/** Check index of each check line. */
|
|
79
70
|
checkAt: Map<number, number>;
|
|
80
|
-
/** Shell action index of each shell action line. */
|
|
81
|
-
shellActionAt: Map<number, number>;
|
|
82
71
|
sections: SetupGuideSection[];
|
|
83
72
|
checks: SetupGuideCheckLine[];
|
|
84
|
-
shellActions: SetupGuideShellActionLine[];
|
|
85
73
|
issues: SetupGuideParseIssue[];
|
|
86
74
|
}
|
|
87
75
|
/** LF line endings. */
|
|
@@ -99,8 +87,6 @@ export declare function preparedGuideText(scan: GuideScan, include: (i: number)
|
|
|
99
87
|
export declare function parseGuideMarkdown(text: string): Root;
|
|
100
88
|
/** @internal The check index of a marker heading, or undefined. */
|
|
101
89
|
export declare function checkMarkerIndex(node: Nodes): number | undefined;
|
|
102
|
-
/** @internal The shell action index of a marker heading, or undefined. */
|
|
103
|
-
export declare function shellActionMarkerIndex(node: Nodes): number | undefined;
|
|
104
90
|
/** @internal The plain text of a node (values and image alts, joined). */
|
|
105
91
|
export declare function nodeText(node: Nodes): string;
|
|
106
92
|
/** @internal Visits nodes depth first in document order, with their depth (root's children = 1). */
|
|
@@ -6,7 +6,6 @@ import { SETUP_CHECK_ID_RE } from "./setup-check.js";
|
|
|
6
6
|
const LIMITS = {
|
|
7
7
|
codeBlocks: 24,
|
|
8
8
|
checks: 16,
|
|
9
|
-
shellActions: 4,
|
|
10
9
|
sections: 16,
|
|
11
10
|
titleChars: 100,
|
|
12
11
|
checkLabelChars: 80,
|
|
@@ -25,15 +24,12 @@ const FENCE_OPEN_RE = /^( {0,3})(`{3,}|~{3,})(.*)$/;
|
|
|
25
24
|
const FENCE_CLOSE_RE = /^ {0,3}(`{3,}|~{3,})[ \t]*$/;
|
|
26
25
|
const SECTION_RE = /^(mode|audience)[ \t]+(\S+)$/;
|
|
27
26
|
const CHECK_LINE_RE = /^::check[ \t]+(\S+)(?:[ \t]+(.*?))?[ \t]*$/;
|
|
28
|
-
const SHELL_ACTION_LINE_RE = /^::shell-action[ \t]+(\S+)(?:[ \t]+(.*?))?[ \t]*$/;
|
|
29
27
|
const FENCE_TITLE_RE = /^title="([^"]*)"$/;
|
|
30
28
|
/** Variable sentinel: `<n>`, n indexing the occurrences. */
|
|
31
29
|
export const SENTINEL_RE = /(\d+)/g;
|
|
32
30
|
/** The same sentinel percent-encoded, as micromark leaves it in a link destination. */
|
|
33
31
|
export const ENCODED_SENTINEL_RE = /%EE%80%80(\d+)%EE%80%81/gi;
|
|
34
32
|
const CHECK_MARKER_RE = /^(\d+)$/;
|
|
35
|
-
// a shell action line is a marker heading of its own: a different private-use pair than a check's
|
|
36
|
-
const SHELL_ACTION_MARKER_RE = /^(\d+)$/;
|
|
37
33
|
/** LF line endings. */
|
|
38
34
|
export function normalizeGuideSource(source) {
|
|
39
35
|
return source.replace(/\r\n?/g, "\n");
|
|
@@ -44,10 +40,8 @@ export function scanGuide(source) {
|
|
|
44
40
|
const kinds = [];
|
|
45
41
|
const stacks = [];
|
|
46
42
|
const checkAt = new Map();
|
|
47
|
-
const shellActionAt = new Map();
|
|
48
43
|
const sections = [];
|
|
49
44
|
const checks = [];
|
|
50
|
-
const shellActions = [];
|
|
51
45
|
const issues = [];
|
|
52
46
|
const err = (line, message) => issues.push({ level: "error", line, message });
|
|
53
47
|
const stack = [];
|
|
@@ -137,35 +131,13 @@ export function scanGuide(source) {
|
|
|
137
131
|
kinds.push("check");
|
|
138
132
|
return;
|
|
139
133
|
}
|
|
140
|
-
if (/^::shell-action(?:\s|$)/.test(text)) {
|
|
141
|
-
const m = SHELL_ACTION_LINE_RE.exec(text);
|
|
142
|
-
if (m === null) {
|
|
143
|
-
err(line, "a shell action line is `::shell-action <action> <label>`");
|
|
144
|
-
kinds.push("text");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const action = m[1];
|
|
148
|
-
const label = (m[2] ?? "").trim();
|
|
149
|
-
if (label === "") {
|
|
150
|
-
err(line, `shell action ${action} needs a label: \`::shell-action ${action} <label>\``);
|
|
151
|
-
}
|
|
152
|
-
else if ([...label].length > LIMITS.checkLabelChars) {
|
|
153
|
-
err(line, `the label of shell action ${action} is longer than ${LIMITS.checkLabelChars} characters`);
|
|
154
|
-
}
|
|
155
|
-
if (text.includes("{{"))
|
|
156
|
-
err(line, "directive lines hold no variables (shell action labels are plain text)");
|
|
157
|
-
shellActions.push({ action, label, line, section: stack.at(-1) ?? null });
|
|
158
|
-
shellActionAt.set(i, shellActions.length - 1);
|
|
159
|
-
kinds.push("shell-action");
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
134
|
kinds.push("text");
|
|
163
135
|
});
|
|
164
136
|
for (const open of stack) {
|
|
165
137
|
const s = sections[open];
|
|
166
138
|
err(s.line, `the section "::: ${s.type} ${s.value}" opened at line ${s.line} is not closed`);
|
|
167
139
|
}
|
|
168
|
-
return { lines, kinds, stacks, checkAt,
|
|
140
|
+
return { lines, kinds, stacks, checkAt, sections, checks, issues };
|
|
169
141
|
}
|
|
170
142
|
/** @internal Whether line `i` is in the sections of `mode` and `audience`. */
|
|
171
143
|
export function lineSelected(scan, i, mode, audience) {
|
|
@@ -190,8 +162,6 @@ export function preparedGuideText(scan, include, subst = (t) => t) {
|
|
|
190
162
|
return "";
|
|
191
163
|
if (kind === "check")
|
|
192
164
|
return `###### ${scan.checkAt.get(i)}`;
|
|
193
|
-
if (kind === "shell-action")
|
|
194
|
-
return `###### ${scan.shellActionAt.get(i)}`;
|
|
195
165
|
return subst(text, i);
|
|
196
166
|
})
|
|
197
167
|
.join("\n");
|
|
@@ -210,16 +180,6 @@ export function checkMarkerIndex(node) {
|
|
|
210
180
|
const m = CHECK_MARKER_RE.exec(t.value);
|
|
211
181
|
return m === null ? undefined : Number(m[1]);
|
|
212
182
|
}
|
|
213
|
-
/** @internal The shell action index of a marker heading, or undefined. */
|
|
214
|
-
export function shellActionMarkerIndex(node) {
|
|
215
|
-
if (node.type !== "heading" || node.depth !== 6 || node.children.length !== 1)
|
|
216
|
-
return undefined;
|
|
217
|
-
const t = node.children[0];
|
|
218
|
-
if (t?.type !== "text")
|
|
219
|
-
return undefined;
|
|
220
|
-
const m = SHELL_ACTION_MARKER_RE.exec(t.value);
|
|
221
|
-
return m === null ? undefined : Number(m[1]);
|
|
222
|
-
}
|
|
223
183
|
/** @internal The plain text of a node (values and image alts, joined). */
|
|
224
184
|
export function nodeText(node) {
|
|
225
185
|
if ("value" in node)
|
|
@@ -306,8 +266,6 @@ export function analyzeSetupGuide(source) {
|
|
|
306
266
|
if (node.type === "heading") {
|
|
307
267
|
if (checkMarkerIndex(node) !== undefined)
|
|
308
268
|
return;
|
|
309
|
-
if (shellActionMarkerIndex(node) !== undefined)
|
|
310
|
-
return;
|
|
311
269
|
if (node === first && title !== null)
|
|
312
270
|
return;
|
|
313
271
|
if (node.depth === 1) {
|
|
@@ -363,17 +321,6 @@ export function analyzeSetupGuide(source) {
|
|
|
363
321
|
err(c.line, `check ${c.id} is inside raw HTML and would not show; end the HTML with a blank line before the check line`);
|
|
364
322
|
}
|
|
365
323
|
});
|
|
366
|
-
const placedActions = new Set();
|
|
367
|
-
for (const n of tree.children) {
|
|
368
|
-
const a = shellActionMarkerIndex(n);
|
|
369
|
-
if (a !== undefined)
|
|
370
|
-
placedActions.add(a);
|
|
371
|
-
}
|
|
372
|
-
scan.shellActions.forEach((a, i) => {
|
|
373
|
-
if (!placedActions.has(i)) {
|
|
374
|
-
err(a.line, `shell action ${a.action} is inside raw HTML and would not show; end the HTML with a blank line before the line`);
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
324
|
if (deepest > LIMITS.depth)
|
|
378
325
|
err(deepLine, `content is nested deeper than ${LIMITS.depth} levels`);
|
|
379
326
|
if (codeBlocks.length > LIMITS.codeBlocks) {
|
|
@@ -382,9 +329,6 @@ export function analyzeSetupGuide(source) {
|
|
|
382
329
|
if (scan.checks.length > LIMITS.checks) {
|
|
383
330
|
err(undefined, `the document has ${scan.checks.length} check lines; at most ${LIMITS.checks}`);
|
|
384
331
|
}
|
|
385
|
-
if (scan.shellActions.length > LIMITS.shellActions) {
|
|
386
|
-
err(undefined, `the document has ${scan.shellActions.length} shell action lines; at most ${LIMITS.shellActions}`);
|
|
387
|
-
}
|
|
388
332
|
if (scan.sections.length > LIMITS.sections) {
|
|
389
333
|
err(undefined, `the document has ${scan.sections.length} sections; at most ${LIMITS.sections}`);
|
|
390
334
|
}
|
|
@@ -394,7 +338,6 @@ export function analyzeSetupGuide(source) {
|
|
|
394
338
|
title,
|
|
395
339
|
sections: scan.sections,
|
|
396
340
|
checks: scan.checks,
|
|
397
|
-
shellActions: scan.shellActions,
|
|
398
341
|
codeBlocks,
|
|
399
342
|
issues,
|
|
400
343
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type SetupGuideAudience, type SetupGuidePlace
|
|
2
|
-
/** A block of a rendered guide: sanitized Markdown, a code block
|
|
3
|
-
* shell action button. */
|
|
1
|
+
import { type SetupGuideAudience, type SetupGuidePlace } from "./setup-guide.js";
|
|
2
|
+
/** A block of a rendered guide: sanitized Markdown, a code block or a check row. */
|
|
4
3
|
export type SetupGuideBlock = {
|
|
5
4
|
kind: "markdown";
|
|
6
5
|
text: string;
|
|
@@ -13,10 +12,6 @@ export type SetupGuideBlock = {
|
|
|
13
12
|
kind: "check";
|
|
14
13
|
id: string;
|
|
15
14
|
label: string;
|
|
16
|
-
} | {
|
|
17
|
-
kind: "shell-action";
|
|
18
|
-
action: SetupGuideShellAction;
|
|
19
|
-
label: string;
|
|
20
15
|
};
|
|
21
16
|
/** A guide document rendered for one mode, audience and set of values. */
|
|
22
17
|
export interface RenderedSetupGuideDoc {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gfmToMarkdown } from "mdast-util-gfm";
|
|
2
2
|
import { toMarkdown } from "mdast-util-to-markdown";
|
|
3
3
|
import { SETUP_GUIDE_LIMITS, SETUP_GUIDE_PLACE_INFO, } from "./setup-guide.js";
|
|
4
|
-
import { checkMarkerIndex, fenceTitle, lineSelected, nodeText, normalizeGuideSource, parseGuideMarkdown, preparedGuideText, revertSentinels, SETUP_GUIDE_VARIABLE_RE, scanGuide,
|
|
4
|
+
import { checkMarkerIndex, fenceTitle, lineSelected, nodeText, normalizeGuideSource, parseGuideMarkdown, preparedGuideText, revertSentinels, SETUP_GUIDE_VARIABLE_RE, scanGuide, } from "./setup-guide-parse.js";
|
|
5
5
|
// biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what is replaced
|
|
6
6
|
const CONTROL_RE = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g;
|
|
7
7
|
/** What `JSON.stringify` leaves raw but a YAML parser may refuse or read as a line break. */
|
|
@@ -321,22 +321,6 @@ export function renderSetupGuide(source, input) {
|
|
|
321
321
|
}
|
|
322
322
|
continue;
|
|
323
323
|
}
|
|
324
|
-
const a = shellActionMarkerIndex(node);
|
|
325
|
-
if (a !== undefined) {
|
|
326
|
-
const sa = scan.shellActions[a];
|
|
327
|
-
if (sa !== undefined) {
|
|
328
|
-
flush();
|
|
329
|
-
// the validator limits the action to the place's; a stored guide of another shape is skipped
|
|
330
|
-
if (info.shellActions.includes(sa.action)) {
|
|
331
|
-
blocks.push({
|
|
332
|
-
kind: "shell-action",
|
|
333
|
-
action: sa.action,
|
|
334
|
-
label: sa.label,
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
continue;
|
|
339
|
-
}
|
|
340
324
|
if (node.type === "code") {
|
|
341
325
|
flush();
|
|
342
326
|
const lang = revert(node.lang ?? "");
|
package/dist/setup-guide.d.ts
CHANGED
|
@@ -15,21 +15,15 @@ export type SetupGuideAudience = "admin" | "member";
|
|
|
15
15
|
*/
|
|
16
16
|
export type SetupGuideVariableType = "url" | "text" | "token";
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
19
|
-
* connect the machine the page runs on as a device (the web shows the button only where the shell
|
|
20
|
-
* declares the capability).
|
|
21
|
-
*/
|
|
22
|
-
export type SetupGuideShellAction = "connect-this-machine";
|
|
23
|
-
/**
|
|
24
|
-
* What a place defines: its modes, audiences and variables, whether its targets record acks, and
|
|
25
|
-
* the shell actions its guides may use.
|
|
18
|
+
* What a place defines: its modes, audiences and variables, and whether its targets record acks.
|
|
26
19
|
*/
|
|
27
20
|
export interface SetupGuidePlaceInfo {
|
|
28
21
|
modes: readonly string[];
|
|
29
22
|
audiences: readonly SetupGuideAudience[];
|
|
30
23
|
variables: Readonly<Record<string, SetupGuideVariableType>>;
|
|
31
24
|
drift: boolean;
|
|
32
|
-
|
|
25
|
+
/** Whether guides of the place may use check lines (a place with no target has nothing to check). */
|
|
26
|
+
checks: boolean;
|
|
33
27
|
}
|
|
34
28
|
/** The place registry. None of the variables is a secret. */
|
|
35
29
|
export declare const SETUP_GUIDE_PLACE_INFO: Readonly<Record<SetupGuidePlace, SetupGuidePlaceInfo>>;
|
|
@@ -45,8 +39,6 @@ export declare const SETUP_GUIDE_LIMITS: {
|
|
|
45
39
|
readonly codeBlocks: 24;
|
|
46
40
|
/** Check lines per document. */
|
|
47
41
|
readonly checks: 16;
|
|
48
|
-
/** Shell action lines per document. */
|
|
49
|
-
readonly shellActions: 4;
|
|
50
42
|
/** Sections per document. */
|
|
51
43
|
readonly sections: 16;
|
|
52
44
|
/** Characters of the title and of a heading. */
|
package/dist/setup-guide.js
CHANGED
|
@@ -43,7 +43,7 @@ export const SETUP_GUIDE_PLACE_INFO = {
|
|
|
43
43
|
connectionName: "text",
|
|
44
44
|
},
|
|
45
45
|
drift: true,
|
|
46
|
-
|
|
46
|
+
checks: true,
|
|
47
47
|
},
|
|
48
48
|
"connector-template": {
|
|
49
49
|
modes: [],
|
|
@@ -57,21 +57,21 @@ export const SETUP_GUIDE_PLACE_INFO = {
|
|
|
57
57
|
connectorName: "text",
|
|
58
58
|
},
|
|
59
59
|
drift: true,
|
|
60
|
-
|
|
60
|
+
checks: true,
|
|
61
61
|
},
|
|
62
62
|
"extension-deployment": {
|
|
63
63
|
modes: [],
|
|
64
64
|
audiences: ["admin"],
|
|
65
65
|
variables: { ...COMMON_VARIABLES, pluginName: "text", signInCallbackUrl: "url" },
|
|
66
66
|
drift: false,
|
|
67
|
-
|
|
67
|
+
checks: true,
|
|
68
68
|
},
|
|
69
69
|
"device-connection": {
|
|
70
70
|
modes: [],
|
|
71
71
|
audiences: ["member"],
|
|
72
72
|
variables: { publicUrl: "url", orgId: "token", orgName: "text", pluginName: "token" },
|
|
73
73
|
drift: false,
|
|
74
|
-
|
|
74
|
+
checks: false,
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
77
|
/** Limits of setup guides. */
|
|
@@ -86,8 +86,6 @@ export const SETUP_GUIDE_LIMITS = {
|
|
|
86
86
|
codeBlocks: 24,
|
|
87
87
|
/** Check lines per document. */
|
|
88
88
|
checks: 16,
|
|
89
|
-
/** Shell action lines per document. */
|
|
90
|
-
shellActions: 4,
|
|
91
89
|
/** Sections per document. */
|
|
92
90
|
sections: 16,
|
|
93
91
|
/** Characters of the title and of a heading. */
|
|
@@ -180,15 +178,12 @@ export function validateSetupGuide(input) {
|
|
|
180
178
|
err(s.line, `audience "${s.value}" is not one of the audiences of place ${input.place}: ${info.audiences.join(", ")}`);
|
|
181
179
|
}
|
|
182
180
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
err(
|
|
186
|
-
}
|
|
187
|
-
else if (!info.shellActions.includes(a.action)) {
|
|
188
|
-
err(a.line, `unknown shell action "${a.action}" (known: ${info.shellActions.join(", ")})`);
|
|
181
|
+
if (!info.checks) {
|
|
182
|
+
for (const c of parsed.checks) {
|
|
183
|
+
err(c.line, `check ${c.id} is not allowed in place ${input.place}${input.id !== undefined ? ` (guide ${input.id})` : ""}: guides of this place have no target to check, so remove the line`);
|
|
189
184
|
}
|
|
190
185
|
}
|
|
191
|
-
if (input.pluginChecks !== undefined) {
|
|
186
|
+
if (input.pluginChecks !== undefined && info.checks) {
|
|
192
187
|
for (const c of parsed.checks) {
|
|
193
188
|
if (c.source === "plugin" && !input.pluginChecks.includes(c.id)) {
|
|
194
189
|
err(c.line, `check ${c.id} is not declared in the extension's permissions.setupChecks`);
|
|
@@ -305,13 +300,6 @@ export function validateSetupGuide(input) {
|
|
|
305
300
|
message: `${zhFile}: the checks differ from ${enFile}; both languages need the same check ids in the same sections`,
|
|
306
301
|
});
|
|
307
302
|
}
|
|
308
|
-
const act = (p) => JSON.stringify(p.shellActions.map((a) => [a.section, a.action]));
|
|
309
|
-
if (act(en) !== act(zh)) {
|
|
310
|
-
out.push({
|
|
311
|
-
level: "error",
|
|
312
|
-
message: `${zhFile}: the shell actions differ from ${enFile}; both languages need the same actions in the same sections`,
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
303
|
if (en.codeBlocks.length !== zh.codeBlocks.length) {
|
|
316
304
|
out.push({
|
|
317
305
|
level: "error",
|
|
@@ -8,7 +8,6 @@ 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@2";
|
|
12
11
|
readonly notify: "notify@1";
|
|
13
12
|
readonly openExternal: "openExternal@1";
|
|
14
13
|
readonly signIn: "signIn@1";
|
|
@@ -19,83 +18,8 @@ export declare const SHELL_CAPABILITY_KEYS: {
|
|
|
19
18
|
readonly profiles: "profiles@1";
|
|
20
19
|
readonly push: "push@1";
|
|
21
20
|
};
|
|
22
|
-
export type KeepAwakeMode = "off" | "while-busy" | "connected";
|
|
23
|
-
export type DeviceConnection = "starting" | "online" | "offline" | "draining" | "stopped";
|
|
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 {
|
|
29
|
-
deviceId: string;
|
|
30
|
-
orgId: string;
|
|
31
|
-
mode: "os" | "docker";
|
|
32
|
-
connection: DeviceConnection;
|
|
33
|
-
offlineReason?: string;
|
|
34
|
-
serviceInstalled: boolean;
|
|
35
|
-
keepAwake: {
|
|
36
|
-
mode: KeepAwakeMode;
|
|
37
|
-
held: boolean;
|
|
38
|
-
unavailable?: string;
|
|
39
|
-
};
|
|
40
|
-
lastWakeAt?: string;
|
|
41
|
-
}
|
|
42
|
-
/** One operation running on this machine for one of its devices. */
|
|
43
|
-
export interface DeviceRunningOp {
|
|
44
|
-
tag: string;
|
|
45
|
-
conversationId: string | null;
|
|
46
|
-
accountId: string | null;
|
|
47
|
-
isolation: "restricted" | "full";
|
|
48
|
-
startedAt: string;
|
|
49
|
-
}
|
|
50
21
|
/** The `code` of a rejected shell call. */
|
|
51
22
|
export type ShellCallError = "busy" | "no_activation" | "cancelled" | "failed";
|
|
52
|
-
/**
|
|
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.
|
|
58
|
-
*/
|
|
59
|
-
export interface DeviceCeilingRequest {
|
|
60
|
-
outsideSandbox?: boolean;
|
|
61
|
-
network?: "open" | "allowlist";
|
|
62
|
-
projectReach?: "machine" | "paths" | "workspace";
|
|
63
|
-
}
|
|
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: {
|
|
78
|
-
orgId: string;
|
|
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">;
|
|
98
|
-
}
|
|
99
23
|
/** `notify@1`: a native notification; `path` is the in-app path opened on click. */
|
|
100
24
|
export interface NotifyCapabilityV1 {
|
|
101
25
|
notify(input: {
|
|
@@ -8,7 +8,6 @@
|
|
|
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@2", owner: "device provider spec (2026-11-21-device-provider-design.md), §9" },
|
|
12
11
|
{ key: "notify@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md)" },
|
|
13
12
|
{ key: "openExternal@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md)" },
|
|
14
13
|
{ key: "signIn@1", owner: "desktop client spec (2026-11-07-desktop-client-design.md), §6.5" },
|