turno-cli 0.1.1 → 0.3.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 +432 -0
- package/README.md +228 -73
- package/dist/accounts/audit.js +154 -12
- package/dist/accounts/builtin.js +100 -25
- package/dist/accounts/delegate.js +199 -35
- package/dist/accounts/policy.js +79 -0
- package/dist/accounts/registry.js +39 -21
- package/dist/agents/adapter.js +29 -0
- package/dist/agents/claude.js +246 -0
- package/dist/agents/codex.js +186 -0
- package/dist/agents/copilot.js +56 -0
- package/dist/agents/cursor.js +58 -0
- package/dist/agents/index.js +26 -86
- package/dist/agents/snippets.js +43 -13
- package/dist/cli/args.js +38 -6
- package/dist/cli/commands/accounts.js +119 -52
- package/dist/cli/commands/auto.js +121 -33
- package/dist/cli/commands/browser-identity.js +514 -0
- package/dist/cli/commands/browser-session.js +102 -0
- package/dist/cli/commands/browser-vault.js +193 -0
- package/dist/cli/commands/browser.js +319 -138
- package/dist/cli/commands/complete.js +14 -3
- package/dist/cli/commands/completion.js +8 -2
- package/dist/cli/commands/config.js +186 -24
- package/dist/cli/commands/demo.js +321 -0
- package/dist/cli/commands/doctor.js +525 -123
- package/dist/cli/commands/handoff.js +33 -22
- package/dist/cli/commands/identity.js +192 -54
- package/dist/cli/commands/init.js +648 -0
- package/dist/cli/commands/limit.js +84 -16
- package/dist/cli/commands/mcp-call.js +240 -0
- package/dist/cli/commands/mcp-oauth.js +221 -0
- package/dist/cli/commands/mcp-observe.js +539 -0
- package/dist/cli/commands/mcp-share.js +201 -0
- package/dist/cli/commands/mcp.js +816 -187
- package/dist/cli/commands/mcpd.js +388 -76
- package/dist/cli/commands/migrate.js +6 -4
- package/dist/cli/commands/open.js +115 -27
- package/dist/cli/commands/profile.js +396 -78
- package/dist/cli/commands/resolve.js +14 -3
- package/dist/cli/commands/run.js +36 -6
- package/dist/cli/commands/secret.js +80 -76
- package/dist/cli/commands/session.js +17 -6
- package/dist/cli/commands/sessions.js +48 -12
- package/dist/cli/commands/setup.js +214 -164
- package/dist/cli/commands/status.js +227 -44
- package/dist/cli/commands/statusline.js +311 -114
- package/dist/cli/commands/ui.js +78 -68
- package/dist/cli/commands/undo.js +193 -18
- package/dist/cli/commands/uninstall.js +481 -0
- package/dist/cli/commands/upgrade.js +172 -79
- package/dist/cli/commands/usage.js +125 -51
- package/dist/cli/commands/version.js +21 -7
- package/dist/cli/commands/which.js +9 -24
- package/dist/cli/compile-cache.js +32 -0
- package/dist/cli/diagnostics.js +184 -0
- package/dist/cli/exit.js +65 -0
- package/dist/cli/group.js +24 -12
- package/dist/cli/help.js +62 -0
- package/dist/cli/highlight.js +236 -0
- package/dist/cli/hints.js +30 -0
- package/dist/cli/io.js +186 -1
- package/dist/cli/launch.js +52 -39
- package/dist/cli/launchers.js +161 -95
- package/dist/cli/main.js +201 -31
- package/dist/cli/optional.js +144 -0
- package/dist/cli/output.js +123 -0
- package/dist/cli/picker.js +459 -0
- package/dist/cli/registry.js +61 -6
- package/dist/cli/safe.js +87 -0
- package/dist/cli/secret-input.js +63 -0
- package/dist/cli/security.js +561 -0
- package/dist/cli/style.js +311 -0
- package/dist/cli/topics.js +142 -0
- package/dist/core/config.js +181 -23
- package/dist/core/exhausted.js +6 -8
- package/dist/core/fsutil.js +39 -0
- package/dist/core/journal.js +294 -16
- package/dist/core/manifest.js +153 -6
- package/dist/core/paths.js +14 -13
- package/dist/core/profiles.js +160 -10
- package/dist/core/resolve.js +139 -23
- package/dist/core/secrets.js +68 -23
- package/dist/core/sessions.js +13 -20
- package/dist/core/state-file.js +107 -0
- package/dist/core/update.js +31 -18
- package/dist/core/version.js +57 -10
- package/dist/demo/server.js +42 -0
- package/dist/mcpd/cache.js +23 -10
- package/dist/mcpd/calllog.js +254 -0
- package/dist/mcpd/client-names.js +46 -0
- package/dist/mcpd/connectors.js +188 -18
- package/dist/mcpd/daemon.js +472 -115
- package/dist/mcpd/folder-sets.js +42 -0
- package/dist/mcpd/gateway.js +473 -51
- package/dist/mcpd/health.js +313 -0
- package/dist/mcpd/importer.js +453 -36
- package/dist/mcpd/instances.js +453 -65
- package/dist/mcpd/jsonrpc.js +11 -1
- package/dist/mcpd/launchd.js +65 -48
- package/dist/mcpd/middleware.js +144 -0
- package/dist/mcpd/modern.js +686 -0
- package/dist/mcpd/oauth.js +845 -0
- package/dist/mcpd/peerpid.js +134 -6
- package/dist/mcpd/pressure.js +88 -0
- package/dist/mcpd/rss.js +166 -0
- package/dist/mcpd/service.js +191 -0
- package/dist/mcpd/share.js +217 -0
- package/dist/mcpd/state.js +183 -0
- package/dist/mcpd/sync.js +72 -87
- package/dist/mcpd/systemd.js +83 -0
- package/dist/mcpd/tokens.js +85 -0
- package/dist/mcpd/upstream.js +163 -46
- package/dist/statusline/cost.js +167 -44
- package/dist/statusline/input.js +78 -0
- package/dist/statusline/render.js +9 -3
- package/dist/ui/fonts.js +8 -3
- package/dist/ui/settings.js +33 -16
- package/npm-shrinkwrap.json +1102 -0
- package/package.json +10 -9
- package/dist/cli/commands/available.js +0 -18
|
@@ -1,33 +1,59 @@
|
|
|
1
1
|
import { paths, tildify } from "../../core/paths.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import { DRY_RUN, JSON_FLAG, bool, parseFlags, str } from "../args.js";
|
|
3
|
+
import { group } from "../group.js";
|
|
4
|
+
import { fail, needsAnswer, paint } from "../io.js";
|
|
5
|
+
import { OPTIONAL, loadOptional, notInstalled } from "../optional.js";
|
|
6
|
+
import { emit, jsonOutput } from "../output.js";
|
|
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"]);
|
|
14
|
+
/**
|
|
15
|
+
* The API version this turno was built against. Typed by the package's own constant, so a
|
|
16
|
+
* change of its API_VERSION in the workspace fails the typecheck until this line follows.
|
|
17
|
+
*/
|
|
18
|
+
export const BROWSER_API = { major: 1, minor: 2 };
|
|
19
|
+
export const INSTALL_HINT = OPTIONAL.browser.install;
|
|
20
|
+
export const NOT_INSTALLED = notInstalled(OPTIONAL.browser);
|
|
21
|
+
/** A turno-browser this command can drive: its API object has the calls every subcommand needs. */
|
|
22
|
+
function isBrowserPackage(mod) {
|
|
23
|
+
const api = mod?.api;
|
|
24
|
+
return (typeof api === "object" &&
|
|
25
|
+
api !== null &&
|
|
26
|
+
Array.isArray(api.ENGINES) &&
|
|
27
|
+
typeof api.listIdentities === "function" &&
|
|
28
|
+
typeof api.runBench === "function");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load turno-browser's API: next to this install first, then (with `global`) from the global
|
|
32
|
+
* npm folder, which a Homebrew or npx install of turno cannot see on its own (loadOptional). A
|
|
33
|
+
* package whose API_VERSION does not fit is refused with one message that says what to update.
|
|
34
|
+
*/
|
|
35
|
+
export async function loadBrowser(options = {}) {
|
|
36
|
+
const mod = await loadOptional(OPTIONAL.browser, { ...options, api: BROWSER_API, guard: isBrowserPackage });
|
|
37
|
+
return mod?.api;
|
|
38
|
+
}
|
|
39
|
+
async function askOnTerminal(question) {
|
|
40
|
+
const { createInterface } = await import("node:readline/promises");
|
|
41
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
18
42
|
try {
|
|
19
|
-
return (await
|
|
43
|
+
return /^y(es)?$/i.test((await rl.question(question)).trim());
|
|
20
44
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED")
|
|
24
|
-
return undefined;
|
|
25
|
-
throw err;
|
|
45
|
+
finally {
|
|
46
|
+
rl.close();
|
|
26
47
|
}
|
|
27
48
|
}
|
|
28
|
-
|
|
49
|
+
export const defaultDeps = {
|
|
50
|
+
load: (io) => loadBrowser({ global: true, env: io.env }),
|
|
51
|
+
interactive: (io) => Boolean(io.ask),
|
|
52
|
+
confirm: (question) => askOnTerminal(question),
|
|
53
|
+
};
|
|
54
|
+
function checkId(mod, id, sub) {
|
|
29
55
|
if (!id)
|
|
30
|
-
return fail(`browser ${sub} needs an identity id
|
|
56
|
+
return fail(`browser ${sub} needs an identity id (for example: turno browser ${sub} school)`);
|
|
31
57
|
try {
|
|
32
58
|
mod.assertIdentityId(id);
|
|
33
59
|
}
|
|
@@ -36,56 +62,59 @@ function requireId(mod, id, sub) {
|
|
|
36
62
|
}
|
|
37
63
|
return id;
|
|
38
64
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const rest = urls.rest;
|
|
64
|
-
const json = rest.includes("--json");
|
|
65
|
-
const detectors = !rest.includes("--no-detectors");
|
|
66
|
-
const unknown = rest.filter((a) => a !== "--json" && a !== "--no-detectors");
|
|
67
|
-
if (unknown.length)
|
|
68
|
-
return fail(`unknown bench argument: ${unknown[0]}\n\n${USAGE}`);
|
|
69
|
-
const engineNames = engines.values.flatMap((v) => v.split(",")).map((v) => v.trim()).filter(Boolean);
|
|
70
|
-
for (const e of engineNames) {
|
|
71
|
-
if (!mod.ENGINES.includes(e))
|
|
65
|
+
const BENCH_FLAGS = {
|
|
66
|
+
engine: { type: "string", multiple: true },
|
|
67
|
+
url: { type: "string", multiple: true },
|
|
68
|
+
"only-urls": { type: "boolean" },
|
|
69
|
+
// Older name of --only-urls, kept so scripts keep working.
|
|
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)
|
|
72
89
|
return fail(`unknown engine "${e}" (known: ${mod.ENGINES.join(", ")})`);
|
|
90
|
+
engines.push(id);
|
|
73
91
|
}
|
|
74
|
-
for (const u of urls
|
|
92
|
+
for (const u of urls) {
|
|
75
93
|
if (!/^https?:\/\//.test(u))
|
|
76
94
|
return fail(`--url must start with http:// or https://: ${u}`);
|
|
77
95
|
}
|
|
78
|
-
if (
|
|
79
|
-
return fail("--
|
|
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
|
+
}
|
|
80
109
|
const report = await mod.runBench({
|
|
81
|
-
engines
|
|
82
|
-
urls
|
|
83
|
-
detectors,
|
|
110
|
+
engines,
|
|
111
|
+
urls,
|
|
112
|
+
detectors: !onlyUrls,
|
|
84
113
|
env: io.env,
|
|
85
114
|
onProgress: (m) => io.err(paint(io, m, "2")),
|
|
86
115
|
});
|
|
87
|
-
if (json) {
|
|
88
|
-
io
|
|
116
|
+
if (bool(p, "json")) {
|
|
117
|
+
emit(io, p, BENCH_JSON, report);
|
|
89
118
|
}
|
|
90
119
|
else {
|
|
91
120
|
io.out(mod.formatBenchTable(report));
|
|
@@ -94,82 +123,234 @@ async function bench(mod, args, io) {
|
|
|
94
123
|
}
|
|
95
124
|
return 0;
|
|
96
125
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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;
|
|
143
|
+
}
|
|
144
|
+
function add(mod, args, io) {
|
|
145
|
+
const p = parseFlags(args, { ...DRY_RUN, ...ident.SETTINGS_FLAGS }, 1);
|
|
146
|
+
const id = checkId(mod, p.positionals[0], "add");
|
|
147
|
+
const settings = ident.settingsPatch(p);
|
|
148
|
+
if (bool(p, "dry-run")) {
|
|
149
|
+
io.out(`(dry run) would create browser identity "${id}"`);
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
const info = ident.hasSettings(settings) ? mod.addIdentity(id, io.env, settings) : mod.addIdentity(id, io.env);
|
|
153
|
+
io.out(`identity "${id}" ready at ${tildify(info.dir, io.env)}`);
|
|
154
|
+
io.out(`settings (time zone, languages, health check) in ${tildify(mod.identitySettingsPath(id, io.env), io.env)}`);
|
|
155
|
+
io.out(`\nAdd this to ${tildify(paths(io.env).mcpFile, io.env)}, then run \`turno mcp sync\`:\n`);
|
|
156
|
+
io.out(mod.manifestSnippet(id));
|
|
157
|
+
io.out(`Sign in to your sites once with \`turno identity login browser:${id}\`.`);
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
async function remove(mod, args, io) {
|
|
161
|
+
const p = parseFlags(args, DRY_RUN, 1);
|
|
162
|
+
const id = checkId(mod, p.positionals[0], "remove");
|
|
163
|
+
if (bool(p, "dry-run")) {
|
|
164
|
+
io.out(`(dry run) would delete browser identity "${id}", its saved logins and its vault credentials`);
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
if (mod.isInUse(id, io.env))
|
|
168
|
+
return fail(`identity "${id}" is in use by a running Chrome; close it first`);
|
|
169
|
+
// The vault's secret store items first: removeIdentity refuses while they exist.
|
|
170
|
+
const cleared = await mod.vaultClear(id, { env: io.env });
|
|
171
|
+
if (cleared)
|
|
172
|
+
io.out(`deleted ${cleared} vault credential${cleared === 1 ? "" : "s"} of "${id}" from the secret store`);
|
|
173
|
+
mod.removeIdentity(id, io.env);
|
|
174
|
+
io.out(`removed identity "${id}" and its saved browser data`);
|
|
175
|
+
io.out(`Remove its [server.browser-${id}] block from ${tildify(paths(io.env).mcpFile, io.env)} if you added one.`);
|
|
176
|
+
return 0;
|
|
177
|
+
}
|
|
178
|
+
async function login(mod, args, io) {
|
|
179
|
+
const p = parseFlags(args, { url: { type: "string" } }, 1);
|
|
180
|
+
const id = checkId(mod, p.positionals[0], "login");
|
|
181
|
+
const url = str(p, "url");
|
|
182
|
+
if (url !== undefined && !/^https?:\/\//.test(url))
|
|
183
|
+
return fail(`--url must start with http:// or https://: ${url}`);
|
|
184
|
+
const holder = mod.inUseBy(id, io.env);
|
|
185
|
+
if (holder)
|
|
186
|
+
return fail(holder);
|
|
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;
|
|
197
|
+
}
|
|
198
|
+
/** Run one browser subcommand with a loaded module. `identity` uses it for browser:<id>. */
|
|
199
|
+
export async function dispatch(mod, sub, rest, io, deps = defaultDeps) {
|
|
200
|
+
try {
|
|
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
|
+
}
|
|
236
|
+
}
|
|
237
|
+
const FOOTER = `A developer diagnostic for browser engine compatibility. It needs the separate
|
|
238
|
+
turno-browser package (${INSTALL_HINT}).
|
|
239
|
+
Identities are persistent Chrome profiles served by turno-browser-mcp, one session at a time
|
|
240
|
+
through mcpd; turno identity manages them too (browser:<id>). Ids use lowercase letters,
|
|
241
|
+
digits, "-" and "_", for example "school".`;
|
|
242
|
+
/** The `browser` command, with its loader and prompt injectable for tests. */
|
|
243
|
+
export function browserCommand(deps = defaultDeps) {
|
|
244
|
+
const withModule = (sub) => async (args, io) => {
|
|
245
|
+
const mod = await deps.load(io);
|
|
106
246
|
if (!mod) {
|
|
107
247
|
io.err(`turno: ${NOT_INSTALLED}`);
|
|
108
248
|
return 1;
|
|
109
249
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
250
|
+
return dispatch(mod, sub, args, io, deps);
|
|
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
|
+
},
|
|
334
|
+
};
|
|
335
|
+
return group("browser", "developer tool: compare browser engines (needs turno-browser)", subs, {
|
|
336
|
+
footer: FOOTER,
|
|
337
|
+
examples: [
|
|
338
|
+
"turno browser identities",
|
|
339
|
+
"turno browser add school --languages es-MX,es,en",
|
|
340
|
+
"turno browser show school",
|
|
341
|
+
"turno browser set school --health-url https://mail.example.com/ --health-text Inbox",
|
|
342
|
+
"turno browser set school --tabs-max 5 --tabs-popups keep --settle 250ms",
|
|
343
|
+
"turno browser set school --block-trackers true --cache --json",
|
|
344
|
+
"turno browser login school --url https://example.com",
|
|
345
|
+
"turno browser doctor --fix",
|
|
346
|
+
"turno browser reputation school --json",
|
|
347
|
+
"turno browser vault add school mail --url https://mail.example.com --username alice",
|
|
348
|
+
"turno browser export school --out school.session --expires 2d",
|
|
349
|
+
"turno browser import school.session --as school-laptop",
|
|
350
|
+
"turno browser remove school --dry-run",
|
|
351
|
+
"turno browser bench --only-urls --url https://example.com --yes",
|
|
352
|
+
],
|
|
353
|
+
});
|
|
174
354
|
}
|
|
355
|
+
export const command = browserCommand();
|
|
175
356
|
//# sourceMappingURL=browser.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { loadRegistry } from "../../accounts/registry.js";
|
|
2
|
+
import { AGENT_IDS, DEFAULT_AGENT } from "../../agents/index.js";
|
|
2
3
|
import { loadConfig } from "../../core/config.js";
|
|
3
4
|
import { listJournals } from "../../core/journal.js";
|
|
4
5
|
import { loadManifest } from "../../core/manifest.js";
|
|
@@ -47,10 +48,19 @@ async function values(kind, env) {
|
|
|
47
48
|
case "server":
|
|
48
49
|
return safe(() => Object.keys(loadManifest(env).servers), []);
|
|
49
50
|
case "stamp":
|
|
50
|
-
return [
|
|
51
|
+
return [
|
|
52
|
+
"last",
|
|
53
|
+
...listJournals(env)
|
|
54
|
+
.filter((j) => j.manifest)
|
|
55
|
+
.map((j) => j.stamp),
|
|
56
|
+
];
|
|
51
57
|
case "key": {
|
|
52
58
|
const { CONFIG_KEYS } = await import("./config.js");
|
|
53
|
-
return CONFIG_KEYS.flatMap((k) =>
|
|
59
|
+
return CONFIG_KEYS.flatMap((k) => k.includes("<name>")
|
|
60
|
+
? profiles().map((p) => k.replace("<name>", p))
|
|
61
|
+
: k.includes("<agent>")
|
|
62
|
+
? AGENT_IDS.filter((a) => a !== DEFAULT_AGENT).map((a) => k.replace("<agent>", a))
|
|
63
|
+
: [k]);
|
|
54
64
|
}
|
|
55
65
|
case "shell":
|
|
56
66
|
return ["zsh", "bash", "fish"];
|
|
@@ -91,7 +101,8 @@ export async function complete(words, env) {
|
|
|
91
101
|
return match(comp.flags ?? []);
|
|
92
102
|
const positionals = args.filter((a, i) => !a.startsWith("-") && !(i > 0 && FLAG_VALUES[args[i - 1]]));
|
|
93
103
|
const kinds = comp.args ?? [];
|
|
94
|
-
const kind = kinds[positionals.length] ??
|
|
104
|
+
const kind = kinds[positionals.length] ??
|
|
105
|
+
(kinds[kinds.length - 1] === "profile" && kinds.length === 1 && name === "profile" ? "profile" : undefined);
|
|
95
106
|
if (!kind)
|
|
96
107
|
return [];
|
|
97
108
|
if (kind === "dir")
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseFlags } from "../args.js";
|
|
1
2
|
import { fail } from "../io.js";
|
|
2
3
|
const ZSH = `#compdef turno
|
|
3
4
|
# turno completion for zsh. Load it with: source <(turno completion zsh)
|
|
@@ -44,11 +45,16 @@ export const command = {
|
|
|
44
45
|
" zsh echo 'source <(turno completion zsh)' >> ~/.zshrc",
|
|
45
46
|
" bash echo 'source <(turno completion bash)' >> ~/.bashrc",
|
|
46
47
|
" fish turno completion fish > ~/.config/fish/completions/turno.fish",
|
|
48
|
+
"",
|
|
49
|
+
"Examples:",
|
|
50
|
+
" $ turno completion zsh",
|
|
51
|
+
" $ turno completion fish > ~/.config/fish/completions/turno.fish",
|
|
47
52
|
].join("\n"),
|
|
48
53
|
args: ["shell"],
|
|
49
54
|
async run(args, io) {
|
|
50
|
-
const
|
|
51
|
-
|
|
55
|
+
const p = parseFlags(args, {}, 1);
|
|
56
|
+
const script = SCRIPTS[p.positionals[0] ?? ""];
|
|
57
|
+
if (!script)
|
|
52
58
|
return fail("usage: turno completion <zsh|bash|fish>");
|
|
53
59
|
io.out(script.trimEnd());
|
|
54
60
|
return 0;
|