turno-cli 0.3.0 → 0.5.0
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/CHANGELOG.md +140 -0
- package/README.md +9 -5
- package/dist/cli/args.js +2 -78
- package/dist/cli/commands/browser-do-session.js +69 -0
- package/dist/cli/commands/browser-do.js +241 -0
- package/dist/cli/commands/browser.js +134 -303
- package/dist/cli/commands/identity.js +101 -94
- package/dist/cli/commands/mcp-call.js +4 -40
- package/dist/cli/exit.js +2 -64
- package/dist/cli/group.js +2 -61
- package/dist/cli/highlight.js +2 -235
- package/dist/cli/hints.js +5 -12
- package/dist/cli/io.js +2 -206
- package/dist/cli/output.js +2 -122
- package/dist/cli/registry.js +3 -2
- package/dist/cli/secret-input.js +2 -62
- package/dist/cli/style.js +2 -289
- package/dist/cli/topics.js +17 -0
- package/dist/core/paths.js +2 -9
- package/dist/mcpd/health.js +1 -1
- package/dist/mcpd/instances.js +11 -1
- package/dist/mcpd/middleware.js +15 -3
- package/dist/mcpd/peerpid.js +52 -18
- package/npm-shrinkwrap.json +5 -5
- package/package.json +3 -3
- package/dist/cli/commands/browser-identity.js +0 -514
- package/dist/cli/commands/browser-session.js +0 -102
- package/dist/cli/commands/browser-vault.js +0 -193
|
@@ -1,23 +1,18 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import { loadManifest } from "../../core/manifest.js";
|
|
1
3
|
import { paths, tildify } from "../../core/paths.js";
|
|
2
|
-
import {
|
|
3
|
-
import { group } from "../group.js";
|
|
4
|
-
import { fail, needsAnswer, paint } from "../io.js";
|
|
4
|
+
import { hintsOn } from "../hints.js";
|
|
5
5
|
import { OPTIONAL, loadOptional, notInstalled } from "../optional.js";
|
|
6
|
-
import {
|
|
7
|
-
import * as ident from "./browser-identity.js";
|
|
8
|
-
import * as session from "./browser-session.js";
|
|
9
|
-
import { vaultCommand } from "./browser-vault.js";
|
|
10
|
-
/** `turno browser bench --json`: turno-browser's report. */
|
|
11
|
-
const BENCH_JSON = jsonOutput(["version", "startedAt", "finishedAt", "engines", "results", "file"]);
|
|
12
|
-
/** `turno browser identities --json`: one element per identity. */
|
|
13
|
-
const IDENTITIES_JSON = jsonOutput(["id", "inUse", "dir"]);
|
|
6
|
+
import { defaultDoDeps, mcpdTransport } from "./browser-do.js";
|
|
14
7
|
/**
|
|
15
8
|
* The API version this turno was built against. Typed by the package's own constant, so a
|
|
16
9
|
* change of its API_VERSION in the workspace fails the typecheck until this line follows.
|
|
17
10
|
*/
|
|
18
|
-
export const BROWSER_API = { major: 1, minor:
|
|
11
|
+
export const BROWSER_API = { major: 1, minor: 12 };
|
|
19
12
|
export const INSTALL_HINT = OPTIONAL.browser.install;
|
|
20
13
|
export const NOT_INSTALLED = notInstalled(OPTIONAL.browser);
|
|
14
|
+
/** The summary in `turno help` (registry.ts HELP_SUMMARY). */
|
|
15
|
+
const SUMMARY = "developer tool: compare browser engines (needs turno-browser)";
|
|
21
16
|
/** A turno-browser this command can drive: its API object has the calls every subcommand needs. */
|
|
22
17
|
function isBrowserPackage(mod) {
|
|
23
18
|
const api = mod?.api;
|
|
@@ -25,7 +20,7 @@ function isBrowserPackage(mod) {
|
|
|
25
20
|
api !== null &&
|
|
26
21
|
Array.isArray(api.ENGINES) &&
|
|
27
22
|
typeof api.listIdentities === "function" &&
|
|
28
|
-
typeof api.
|
|
23
|
+
typeof api.cli === "function");
|
|
29
24
|
}
|
|
30
25
|
/**
|
|
31
26
|
* Load turno-browser's API: next to this install first, then (with `global`) from the global
|
|
@@ -51,306 +46,142 @@ export const defaultDeps = {
|
|
|
51
46
|
interactive: (io) => Boolean(io.ask),
|
|
52
47
|
confirm: (question) => askOnTerminal(question),
|
|
53
48
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"no-detectors": { type: "boolean" },
|
|
71
|
-
yes: { type: "boolean", short: "y" },
|
|
72
|
-
...JSON_FLAG,
|
|
73
|
-
};
|
|
74
|
-
export const BENCH_PROMPT = "This opens Chrome and visits third-party test pages. Continue? [y/N] ";
|
|
75
|
-
const URLS_PROMPT = "This opens Chrome and visits the URLs you gave. Continue? [y/N] ";
|
|
76
|
-
async function bench(mod, args, io, deps) {
|
|
77
|
-
const p = parseFlags(args, BENCH_FLAGS, 0);
|
|
78
|
-
const list = (name) => (p.values[name] ?? [])
|
|
79
|
-
.flatMap((v) => v.split(","))
|
|
80
|
-
.map((v) => v.trim())
|
|
81
|
-
.filter(Boolean);
|
|
82
|
-
const given = list("engine");
|
|
83
|
-
const urls = p.values.url ?? [];
|
|
84
|
-
const onlyUrls = bool(p, "only-urls") || bool(p, "no-detectors");
|
|
85
|
-
const engines = [];
|
|
86
|
-
for (const e of given) {
|
|
87
|
-
const id = mod.engineId(e);
|
|
88
|
-
if (!id)
|
|
89
|
-
return fail(`unknown engine "${e}" (known: ${mod.ENGINES.join(", ")})`);
|
|
90
|
-
engines.push(id);
|
|
91
|
-
}
|
|
92
|
-
for (const u of urls) {
|
|
93
|
-
if (!/^https?:\/\//.test(u))
|
|
94
|
-
return fail(`--url must start with http:// or https://: ${u}`);
|
|
95
|
-
}
|
|
96
|
-
if (onlyUrls && urls.length === 0)
|
|
97
|
-
return fail("--only-urls needs at least one --url");
|
|
98
|
-
// Opening a browser on outside pages needs a yes from a person: --json is not consent.
|
|
99
|
-
if (!bool(p, "yes")) {
|
|
100
|
-
if (!deps.interactive(io)) {
|
|
101
|
-
io.err("browser bench opens Chrome and visits third-party test pages.");
|
|
102
|
-
return needsAnswer("browser bench");
|
|
103
|
-
}
|
|
104
|
-
if (!(await deps.confirm(onlyUrls ? URLS_PROMPT : BENCH_PROMPT, io))) {
|
|
105
|
-
io.err("Cancelled; nothing was opened.");
|
|
106
|
-
return 1;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const report = await mod.runBench({
|
|
110
|
-
engines,
|
|
111
|
-
urls,
|
|
112
|
-
detectors: !onlyUrls,
|
|
113
|
-
env: io.env,
|
|
114
|
-
onProgress: (m) => io.err(paint(io, m, "2")),
|
|
115
|
-
});
|
|
116
|
-
if (bool(p, "json")) {
|
|
117
|
-
emit(io, p, BENCH_JSON, report);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
io.out(mod.formatBenchTable(report));
|
|
121
|
-
if (report.file)
|
|
122
|
-
io.out(`\nreport: ${tildify(report.file, io.env)}`);
|
|
123
|
-
}
|
|
124
|
-
return 0;
|
|
125
|
-
}
|
|
126
|
-
function identities(mod, args, io) {
|
|
127
|
-
const p = parseFlags(args, JSON_FLAG, 0);
|
|
128
|
-
const list = mod.listIdentities(io.env);
|
|
129
|
-
if (bool(p, "json")) {
|
|
130
|
-
emit(io, p, IDENTITIES_JSON, list.map((i) => ({ id: i.id, inUse: i.inUse, dir: tildify(i.dir, io.env) })));
|
|
131
|
-
return 0;
|
|
132
|
-
}
|
|
133
|
-
if (!list.length) {
|
|
134
|
-
io.out("No browser identities yet. Create one with `turno identity add browser:<id>`.");
|
|
135
|
-
return 0;
|
|
136
|
-
}
|
|
137
|
-
const width = Math.max(...list.map((i) => i.id.length));
|
|
138
|
-
for (const i of list) {
|
|
139
|
-
const state = i.inUse ? paint(io, "in use", "33") : paint(io, "free ", "32");
|
|
140
|
-
io.out(`${i.id.padEnd(width)} ${state} ${tildify(i.dir, io.env)}`);
|
|
141
|
-
}
|
|
142
|
-
return 0;
|
|
49
|
+
const FOOTER = `A developer diagnostic for browser engine compatibility. It needs the separate
|
|
50
|
+
turno-browser package (${INSTALL_HINT}).
|
|
51
|
+
Identities are persistent Chrome profiles served by turno-browser-mcp, one session at a time
|
|
52
|
+
through mcpd; turno identity manages them too (browser:<id>). Ids use lowercase letters,
|
|
53
|
+
digits, "-" and "_", for example "school".
|
|
54
|
+
turno browser do <id> <action> runs one action (open, snapshot, click, type, read...) on an
|
|
55
|
+
identity's browser through mcpd, for coding agents that prefer shell commands (do --help).`;
|
|
56
|
+
/** The value of `--flag v` or `--flag=v` in a server's args. */
|
|
57
|
+
function flagValue(args, flag) {
|
|
58
|
+
for (let i = 0; i < args.length; i++) {
|
|
59
|
+
if (args[i] === flag)
|
|
60
|
+
return args[i + 1];
|
|
61
|
+
if (args[i].startsWith(`${flag}=`))
|
|
62
|
+
return args[i].slice(flag.length + 1);
|
|
63
|
+
}
|
|
64
|
+
return undefined;
|
|
143
65
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
66
|
+
/**
|
|
67
|
+
* The mcp.toml servers that run turno-browser-mcp for an identity, for the doctor's check of
|
|
68
|
+
* `exclusive` against the identity's `sharing`. An unreadable mcp.toml gives none (`turno doctor`
|
|
69
|
+
* reports it).
|
|
70
|
+
*/
|
|
71
|
+
export function servedIdentities(env) {
|
|
72
|
+
let manifest;
|
|
73
|
+
try {
|
|
74
|
+
manifest = loadManifest(env);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
const out = [];
|
|
80
|
+
for (const [name, server] of Object.entries(manifest.servers)) {
|
|
81
|
+
if (server.kind !== "stdio")
|
|
82
|
+
continue;
|
|
83
|
+
const runs = [server.command, ...server.args].some((a) => basename(a) === "turno-browser-mcp");
|
|
84
|
+
const identity = flagValue(server.args, "--identity");
|
|
85
|
+
if (!runs || !identity)
|
|
86
|
+
continue;
|
|
87
|
+
const sharing = flagValue(server.args, "--sharing");
|
|
88
|
+
out.push({
|
|
89
|
+
name,
|
|
90
|
+
identity: identity.replace(/^browser:/, ""),
|
|
91
|
+
exclusive: server.exclusive,
|
|
92
|
+
scope: server.scope,
|
|
93
|
+
...(sharing ? { sharing } : {}),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
159
97
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
98
|
+
/** turno's host for turno-browser's commands: what only turno has. */
|
|
99
|
+
export function turnoHost(mod, doDeps = defaultDoDeps) {
|
|
100
|
+
const mcpFile = (env) => tildify(paths(env).mcpFile, env);
|
|
101
|
+
return {
|
|
102
|
+
names: {
|
|
103
|
+
program: "turno",
|
|
104
|
+
browser: "turno browser",
|
|
105
|
+
subject: "browser ",
|
|
106
|
+
identity: (sub, id) => `turno identity ${sub} browser:${id}`,
|
|
107
|
+
secretSet: (item) => `turno secret set ${item}`,
|
|
108
|
+
secretStore: "turno secret set",
|
|
109
|
+
},
|
|
110
|
+
footer: FOOTER,
|
|
111
|
+
addSummary: "create an identity (pinned to this time zone) and print its mcp.toml block",
|
|
112
|
+
connect(id, settings, io) {
|
|
113
|
+
io.out(`\nAdd this to ${mcpFile(io.env)}, then run \`turno mcp sync\`:\n`);
|
|
114
|
+
io.out(settings.sharing === "tabs" ? mod.manifestSnippet(id, { sharing: "tabs" }) : mod.manifestSnippet(id));
|
|
115
|
+
io.out(`Sign in to your sites once with \`turno identity login browser:${id}\`.`);
|
|
116
|
+
},
|
|
117
|
+
removed(id, io) {
|
|
118
|
+
io.out(`Remove its [server.browser-${id}] block from ${mcpFile(io.env)} if you added one.`);
|
|
119
|
+
},
|
|
120
|
+
// mcpd decides how many sessions reach the server, so `sharing` needs mcp.toml to follow.
|
|
121
|
+
sharingNote: (id, sharing) => sharing === "tabs"
|
|
122
|
+
? `In mcp.toml, set exclusive = false for [server.browser-${id}] (and drop lease), then run \`turno mcp sync\`: mcpd then lets every session in, and each gets its own tabs.`
|
|
123
|
+
: `In mcp.toml, set exclusive = true for [server.browser-${id}], then run \`turno mcp sync\`: one agent session at a time.`,
|
|
124
|
+
busy: { holder: "probably an MCP session through mcpd", end: "its lease to end" },
|
|
125
|
+
restart: "a new agent session, or turno mcp daemon restart",
|
|
126
|
+
servers: servedIdentities,
|
|
127
|
+
doTransport: mcpdTransport(doDeps),
|
|
128
|
+
hints: hintsOn,
|
|
129
|
+
};
|
|
177
130
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (mod.isInUse(id, io.env)) {
|
|
188
|
-
return fail(`identity "${id}" is in use by a running Chrome (probably an MCP session through mcpd). Close that session or wait for its lease to end, then retry.`);
|
|
189
|
-
}
|
|
190
|
-
io.out(`Opening Chrome for identity "${id}". Sign in to your sites, then close the window to save the session.`);
|
|
191
|
-
const options = { env: io.env };
|
|
192
|
-
if (url)
|
|
193
|
-
options.url = url;
|
|
194
|
-
await mod.loginIdentity(id, options);
|
|
195
|
-
io.out(`saved. Sessions using browser-${id} now start signed in.`);
|
|
196
|
-
return 0;
|
|
131
|
+
/** turno-browser's commands with turno's host, on the functions of `mod`. */
|
|
132
|
+
export function browserCli(mod, deps = defaultDeps, doDeps = defaultDoDeps) {
|
|
133
|
+
return mod.cli(turnoHost(mod, doDeps), {
|
|
134
|
+
api: mod,
|
|
135
|
+
interactive: deps.interactive,
|
|
136
|
+
confirm: deps.confirm,
|
|
137
|
+
...(deps.openUrl ? { openUrl: deps.openUrl } : {}),
|
|
138
|
+
...(doDeps.stdin ? { stdin: doDeps.stdin } : {}),
|
|
139
|
+
});
|
|
197
140
|
}
|
|
198
141
|
/** Run one browser subcommand with a loaded module. `identity` uses it for browser:<id>. */
|
|
199
|
-
export
|
|
200
|
-
|
|
201
|
-
switch (sub) {
|
|
202
|
-
case "identities":
|
|
203
|
-
case "list":
|
|
204
|
-
return identities(mod, rest, io);
|
|
205
|
-
case "add":
|
|
206
|
-
return add(mod, rest, io);
|
|
207
|
-
case "remove":
|
|
208
|
-
case "rm":
|
|
209
|
-
return await remove(mod, rest, io);
|
|
210
|
-
case "login":
|
|
211
|
-
return await login(mod, rest, io);
|
|
212
|
-
case "bench":
|
|
213
|
-
return await bench(mod, rest, io, deps);
|
|
214
|
-
case "export":
|
|
215
|
-
return await session.exportSession(mod, rest, io);
|
|
216
|
-
case "import":
|
|
217
|
-
return await session.importSession(mod, rest, io, deps);
|
|
218
|
-
case "show":
|
|
219
|
-
return ident.show(mod, checkId(mod, rest.find((a) => !a.startsWith("-")), "show"), rest, io);
|
|
220
|
-
case "set":
|
|
221
|
-
return ident.set(mod, checkId(mod, rest.find((a) => !a.startsWith("-")), "set"), rest, io);
|
|
222
|
-
case "doctor":
|
|
223
|
-
return await ident.doctor(mod, rest, io);
|
|
224
|
-
case "reputation":
|
|
225
|
-
return ident.reputation(mod, rest, io, (id) => checkId(mod, id, "reputation"));
|
|
226
|
-
default:
|
|
227
|
-
return fail(`unknown browser command "${sub}"`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
catch (err) {
|
|
231
|
-
const name = err.name;
|
|
232
|
-
if (name === "IdentityError" || name === "VaultError" || name === "SealError")
|
|
233
|
-
return fail(err.message);
|
|
234
|
-
throw err;
|
|
235
|
-
}
|
|
142
|
+
export function dispatch(mod, sub, rest, io, deps = defaultDeps) {
|
|
143
|
+
return browserCli(mod, deps).run(sub, rest, io);
|
|
236
144
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
145
|
+
/** `turno browser` before turno-browser is there: the usage says how to install it. */
|
|
146
|
+
const FALLBACK_USAGE = `Usage:
|
|
147
|
+
turno browser <command> [args]
|
|
148
|
+
|
|
149
|
+
${FOOTER}`;
|
|
150
|
+
/**
|
|
151
|
+
* The `browser` command. `preloaded` is the module the registry loaded to describe the
|
|
152
|
+
* subcommands (help, completion, the docs); null when it is not installed. Without it the
|
|
153
|
+
* command loads the module when it runs, with `deps` (tests inject a fake).
|
|
154
|
+
*/
|
|
155
|
+
export function browserCommand(deps = defaultDeps, doDeps = defaultDoDeps, preloaded) {
|
|
156
|
+
const run = async (args, io) => {
|
|
157
|
+
const mod = preloaded === null ? undefined : (preloaded ?? (await deps.load(io)));
|
|
246
158
|
if (!mod) {
|
|
159
|
+
if (!args.length || args[0] === "--help" || args[0] === "-h" || args[0] === "help" || args.includes("--help")) {
|
|
160
|
+
io.out(FALLBACK_USAGE);
|
|
161
|
+
return 0;
|
|
162
|
+
}
|
|
247
163
|
io.err(`turno: ${NOT_INSTALLED}`);
|
|
248
164
|
return 1;
|
|
249
165
|
}
|
|
250
|
-
return
|
|
251
|
-
};
|
|
252
|
-
const subs = {
|
|
253
|
-
identities: {
|
|
254
|
-
summary: "list browser identities and whether they are in use",
|
|
255
|
-
synopsis: "[--json]",
|
|
256
|
-
flags: ["--json"],
|
|
257
|
-
json: IDENTITIES_JSON,
|
|
258
|
-
run: withModule("identities"),
|
|
259
|
-
},
|
|
260
|
-
list: { summary: "same as identities", hidden: true, run: withModule("identities") },
|
|
261
|
-
add: {
|
|
262
|
-
summary: "create an identity (pinned to this time zone) and print its mcp.toml block",
|
|
263
|
-
synopsis: "<id> [--timezone <zone>] [--locale <tag>] [--languages <tag,...>] [--region <CC>] [--health-url <url> --health-text <text>] [--dry-run]",
|
|
264
|
-
flags: ["--dry-run", ...ident.SETTINGS_FLAG_NAMES],
|
|
265
|
-
run: withModule("add"),
|
|
266
|
-
},
|
|
267
|
-
show: {
|
|
268
|
-
summary: "an identity's settings, session health and who holds it",
|
|
269
|
-
synopsis: "<id> [--json]",
|
|
270
|
-
flags: ["--json"],
|
|
271
|
-
json: ident.SHOW_JSON,
|
|
272
|
-
run: withModule("show"),
|
|
273
|
-
},
|
|
274
|
-
set: {
|
|
275
|
-
summary: "change an identity's identity.json (an empty value removes a setting)",
|
|
276
|
-
synopsis: `<id> ${ident.SET_SYNOPSIS}`,
|
|
277
|
-
details: ident.SET_DETAILS,
|
|
278
|
-
flags: ident.SET_FLAG_NAMES,
|
|
279
|
-
json: ident.SET_JSON,
|
|
280
|
-
run: withModule("set"),
|
|
281
|
-
},
|
|
282
|
-
doctor: {
|
|
283
|
-
summary: "check Chrome, a test launch and every identity (settings, lock, sign-in), with fixes",
|
|
284
|
-
synopsis: "[--fix] [--no-launch] [--json]",
|
|
285
|
-
flags: ["--fix", "--no-launch", "--json"],
|
|
286
|
-
json: ident.DOCTOR_JSON,
|
|
287
|
-
run: withModule("doctor"),
|
|
288
|
-
},
|
|
289
|
-
reputation: {
|
|
290
|
-
summary: "challenges each identity met per site (captcha, verify it's you, block) and their trend",
|
|
291
|
-
synopsis: "[<id>] [--json]",
|
|
292
|
-
flags: ["--json"],
|
|
293
|
-
json: ident.REPUTATION_JSON,
|
|
294
|
-
run: withModule("reputation"),
|
|
295
|
-
},
|
|
296
|
-
vault: {
|
|
297
|
-
summary: "credentials browser_login fills without showing them to the agent",
|
|
298
|
-
synopsis: "add|list|remove|submit <id> ...",
|
|
299
|
-
ownHelp: true,
|
|
300
|
-
run: (args, io) => vaultCommand(deps).run(args, io),
|
|
301
|
-
},
|
|
302
|
-
export: {
|
|
303
|
-
summary: "write an identity's cookies and site storage to a file encrypted with a passphrase",
|
|
304
|
-
synopsis: "<id> --out <file> [--expires 7d] [--force]",
|
|
305
|
-
flags: ["--out", "--expires", "--force"],
|
|
306
|
-
run: withModule("export"),
|
|
307
|
-
},
|
|
308
|
-
import: {
|
|
309
|
-
summary: "replace an identity's session with an export (asks first), or create it",
|
|
310
|
-
synopsis: "<file> [--as <id>] [--yes] [--dry-run]",
|
|
311
|
-
flags: ["--as", "--yes", "--dry-run"],
|
|
312
|
-
run: withModule("import"),
|
|
313
|
-
},
|
|
314
|
-
remove: {
|
|
315
|
-
summary: "delete an identity, its saved logins and its vault",
|
|
316
|
-
synopsis: "<id> [--dry-run]",
|
|
317
|
-
flags: ["--dry-run"],
|
|
318
|
-
run: withModule("remove"),
|
|
319
|
-
},
|
|
320
|
-
rm: { summary: "same as remove", hidden: true, run: withModule("remove") },
|
|
321
|
-
login: {
|
|
322
|
-
summary: "open the identity's Chrome to sign in by hand once",
|
|
323
|
-
synopsis: "<id> [--url <url>]",
|
|
324
|
-
flags: ["--url"],
|
|
325
|
-
run: withModule("login"),
|
|
326
|
-
},
|
|
327
|
-
bench: {
|
|
328
|
-
summary: "check how each browser engine loads reference test pages and your URLs (asks first)",
|
|
329
|
-
synopsis: "[--engine <name>]... [--url <url>]... [--only-urls] [--yes] [--json]",
|
|
330
|
-
flags: ["--engine", "--url", "--only-urls", "--yes", "--json"],
|
|
331
|
-
json: BENCH_JSON,
|
|
332
|
-
run: withModule("bench"),
|
|
333
|
-
},
|
|
166
|
+
return browserCli(mod, deps, doDeps).command.run(args, io);
|
|
334
167
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
});
|
|
168
|
+
if (!preloaded)
|
|
169
|
+
return { summary: SUMMARY, usage: FALLBACK_USAGE, run };
|
|
170
|
+
const described = browserCli(preloaded, deps, doDeps).command;
|
|
171
|
+
return { ...described, summary: SUMMARY, run };
|
|
172
|
+
}
|
|
173
|
+
/** turno-browser when it loads without a word, for the registry: undefined when it does not. */
|
|
174
|
+
export async function preload() {
|
|
175
|
+
try {
|
|
176
|
+
return (await loadBrowser({ global: true, env: process.env })) ?? null;
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
// An API that does not fit: the command loads it again when it runs, and says what to update.
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** The command as the registry loads it: described by the installed turno-browser. */
|
|
184
|
+
export async function loadCommand() {
|
|
185
|
+
return browserCommand(defaultDeps, defaultDoDeps, await preload());
|
|
354
186
|
}
|
|
355
|
-
export const command = browserCommand();
|
|
356
187
|
//# sourceMappingURL=browser.js.map
|