turno-browser 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.
Files changed (131) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/README.md +95 -123
  3. package/dist/act-model.d.ts +85 -0
  4. package/dist/act-model.js +117 -0
  5. package/dist/act.d.ts +37 -0
  6. package/dist/act.js +600 -0
  7. package/dist/api.d.ts +90 -2
  8. package/dist/api.js +41 -4
  9. package/dist/argv.d.ts +16 -2
  10. package/dist/argv.js +100 -3
  11. package/dist/background-state.d.ts +54 -0
  12. package/dist/background-state.js +97 -0
  13. package/dist/background.d.ts +69 -0
  14. package/dist/background.js +458 -0
  15. package/dist/batch.d.ts +5 -0
  16. package/dist/batch.js +3 -3
  17. package/dist/bin/mcp.js +103 -6
  18. package/dist/captcha.d.ts +77 -0
  19. package/dist/captcha.js +334 -0
  20. package/dist/cdp-relay.d.ts +20 -0
  21. package/dist/cdp-relay.js +101 -0
  22. package/dist/chrome-features.d.ts +23 -0
  23. package/dist/chrome-features.js +44 -0
  24. package/dist/cli/background.d.ts +11 -0
  25. package/dist/cli/background.js +132 -0
  26. package/dist/cli/commands.d.ts +16 -0
  27. package/dist/cli/commands.js +515 -0
  28. package/dist/cli/context.d.ts +75 -0
  29. package/dist/cli/context.js +44 -0
  30. package/dist/cli/do-background.d.ts +27 -0
  31. package/dist/cli/do-background.js +212 -0
  32. package/dist/cli/do.d.ts +85 -0
  33. package/dist/cli/do.js +558 -0
  34. package/dist/cli/flows.d.ts +28 -0
  35. package/dist/cli/flows.js +303 -0
  36. package/dist/cli/identity.d.ts +37 -0
  37. package/dist/cli/identity.js +906 -0
  38. package/dist/cli/live.d.ts +7 -0
  39. package/dist/cli/live.js +99 -0
  40. package/dist/cli/main.d.ts +16 -0
  41. package/dist/cli/main.js +171 -0
  42. package/dist/cli/secret.d.ts +4 -0
  43. package/dist/cli/secret.js +151 -0
  44. package/dist/cli/session.d.ts +6 -0
  45. package/dist/cli/session.js +106 -0
  46. package/dist/cli/setup.d.ts +7 -0
  47. package/dist/cli/setup.js +180 -0
  48. package/dist/cli/vault.d.ts +5 -0
  49. package/dist/cli/vault.js +192 -0
  50. package/dist/client.d.ts +82 -0
  51. package/dist/client.js +303 -0
  52. package/dist/diagnose.d.ts +7 -0
  53. package/dist/diagnose.js +61 -6
  54. package/dist/doctor.d.ts +37 -3
  55. package/dist/doctor.js +264 -6
  56. package/dist/engine-attach.d.ts +27 -0
  57. package/dist/engine-attach.js +165 -0
  58. package/dist/engine-camoufox.d.ts +32 -0
  59. package/dist/engine-camoufox.js +271 -0
  60. package/dist/engine-lightpanda.d.ts +72 -0
  61. package/dist/engine-lightpanda.js +293 -0
  62. package/dist/engine.d.ts +63 -11
  63. package/dist/engine.js +106 -29
  64. package/dist/flows.d.ts +127 -0
  65. package/dist/flows.js +294 -0
  66. package/dist/governor.d.ts +42 -7
  67. package/dist/governor.js +82 -32
  68. package/dist/health.js +2 -1
  69. package/dist/host.d.ts +38 -2
  70. package/dist/host.js +689 -52
  71. package/dist/human-input.d.ts +84 -0
  72. package/dist/human-input.js +448 -0
  73. package/dist/humanize.d.ts +123 -0
  74. package/dist/humanize.js +241 -0
  75. package/dist/identities.js +4 -1
  76. package/dist/idle-timer.d.ts +12 -0
  77. package/dist/idle-timer.js +25 -0
  78. package/dist/index.d.ts +13 -4
  79. package/dist/index.js +7 -1
  80. package/dist/lifecycle.d.ts +11 -1
  81. package/dist/lifecycle.js +11 -2
  82. package/dist/live-client.d.ts +22 -0
  83. package/dist/live-client.js +95 -0
  84. package/dist/live-page.d.ts +4 -0
  85. package/dist/live-page.js +144 -0
  86. package/dist/live-server.d.ts +173 -0
  87. package/dist/live-server.js +643 -0
  88. package/dist/live.d.ts +120 -0
  89. package/dist/live.js +204 -0
  90. package/dist/login-tool.d.ts +13 -0
  91. package/dist/login-tool.js +8 -3
  92. package/dist/login.d.ts +4 -1
  93. package/dist/login.js +12 -2
  94. package/dist/names.d.ts +28 -0
  95. package/dist/names.js +25 -0
  96. package/dist/network-chrome.d.ts +74 -0
  97. package/dist/network-chrome.js +178 -0
  98. package/dist/network.d.ts +125 -0
  99. package/dist/network.js +264 -0
  100. package/dist/opt-in-settings.d.ts +69 -0
  101. package/dist/opt-in-settings.js +152 -0
  102. package/dist/recorder.d.ts +88 -0
  103. package/dist/recorder.js +538 -0
  104. package/dist/recordings.d.ts +116 -0
  105. package/dist/recordings.js +474 -0
  106. package/dist/redact.d.ts +7 -0
  107. package/dist/redact.js +18 -0
  108. package/dist/replay.d.ts +20 -0
  109. package/dist/replay.js +383 -0
  110. package/dist/reputation.d.ts +24 -2
  111. package/dist/reputation.js +63 -17
  112. package/dist/runtime-lock.js +3 -2
  113. package/dist/session-export.js +1 -1
  114. package/dist/session.d.ts +10 -2
  115. package/dist/session.js +10 -2
  116. package/dist/settings.d.ts +104 -2
  117. package/dist/settings.js +204 -6
  118. package/dist/sharing.d.ts +96 -0
  119. package/dist/sharing.js +269 -0
  120. package/dist/snippet.d.ts +8 -2
  121. package/dist/snippet.js +10 -4
  122. package/dist/tab-locks.d.ts +63 -0
  123. package/dist/tab-locks.js +179 -0
  124. package/dist/tools.d.ts +38 -0
  125. package/dist/tools.js +20 -1
  126. package/dist/tuning.d.ts +14 -0
  127. package/dist/tuning.js +9 -0
  128. package/dist/upstream.d.ts +11 -0
  129. package/dist/vault.js +5 -4
  130. package/npm-shrinkwrap.json +6 -5
  131. package/package.json +13 -7
@@ -0,0 +1,180 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { JSON_FLAG, bool, emit, fail, jsonOutput, parseFlags, str } from "turno-core/cli";
3
+ import { findOnPath } from "turno-core/paths";
4
+ /**
5
+ * `turno-browser setup <agent> [--identity <id>]`: the MCP config that gives a coding agent one
6
+ * identity's browser, printed for the person to run or paste. It never writes a file: an
7
+ * agent's config is the person's (inside turno, `turno mcp sync` writes it from mcp.toml).
8
+ */
9
+ const SETUP_AGENTS = ["claude-code", "codex", "cursor", "copilot", "gemini", "json"];
10
+ /** `setup --json`: one object. */
11
+ export const SETUP_JSON = jsonOutput([
12
+ "agent",
13
+ "identity",
14
+ "server",
15
+ "command",
16
+ "args",
17
+ "file",
18
+ "shell",
19
+ "config",
20
+ "notes",
21
+ ]);
22
+ const SETUP_FLAGS = { identity: { type: "string" }, ...JSON_FLAG };
23
+ /** One word for a shell line: as it is when it needs no quotes. */
24
+ function shellWord(word) {
25
+ return /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replace(/'/g, `'\\''`)}'`;
26
+ }
27
+ function line(words) {
28
+ return words.map(shellWord).join(" ");
29
+ }
30
+ function json(v) {
31
+ return JSON.stringify(v, null, 2);
32
+ }
33
+ /**
34
+ * The command an agent runs: `turno-browser-mcp` when it is on the PATH, else this install's
35
+ * full path (a `pnpm add` or a local checkout puts it nowhere on the PATH).
36
+ */
37
+ function mcpCommand(env) {
38
+ if (findOnPath("turno-browser-mcp", env))
39
+ return { command: "turno-browser-mcp", onPath: true };
40
+ return { command: fileURLToPath(new URL("../bin/mcp.js", import.meta.url)), onPath: false };
41
+ }
42
+ /** The config of `agent` for identity `id`, run as `command`. */
43
+ function setupConfig(agent, id, command) {
44
+ const server = `browser-${id}`;
45
+ const args = ["--identity", id];
46
+ const base = { agent, identity: id, server, command, args };
47
+ const stdio = { command, args };
48
+ switch (agent) {
49
+ case "claude-code":
50
+ return {
51
+ ...base,
52
+ file: null,
53
+ shell: line(["claude", "mcp", "add", "--scope", "user", server, "--", command, ...args]),
54
+ config: null,
55
+ notes: ["--scope user adds it to every project; leave it out to add it to the current folder only."],
56
+ };
57
+ case "codex":
58
+ return {
59
+ ...base,
60
+ file: "~/.codex/config.toml",
61
+ shell: line(["codex", "mcp", "add", server, "--", command, ...args]),
62
+ config: `[mcp_servers.${server}]\ncommand = ${JSON.stringify(command)}\nargs = ${JSON.stringify(args).replace(/","/g, '", "')}`,
63
+ notes: [],
64
+ };
65
+ case "cursor":
66
+ return {
67
+ ...base,
68
+ file: "~/.cursor/mcp.json (every project) or .cursor/mcp.json (one project)",
69
+ shell: null,
70
+ config: json({ mcpServers: { [server]: { type: "stdio", ...stdio } } }),
71
+ notes: [`When the file has other servers, add the "${server}" entry to its mcpServers.`],
72
+ };
73
+ case "copilot":
74
+ return {
75
+ ...base,
76
+ file: "~/.copilot/mcp-config.json",
77
+ shell: line(["copilot", "mcp", "add", server, "--", command, ...args]),
78
+ config: json({ mcpServers: { [server]: { type: "local", ...stdio, tools: ["*"] } } }),
79
+ notes: [`When the file has other servers, add the "${server}" entry to its mcpServers.`],
80
+ };
81
+ case "gemini":
82
+ return {
83
+ ...base,
84
+ file: "~/.gemini/settings.json (or .gemini/settings.json in a project)",
85
+ shell: line(["gemini", "mcp", "add", "-s", "user", server, command, "--", ...args]),
86
+ config: json({ mcpServers: { [server]: stdio } }),
87
+ notes: [`When the file has other settings, add the "${server}" entry to its mcpServers.`],
88
+ };
89
+ case "json":
90
+ return {
91
+ ...base,
92
+ file: null,
93
+ shell: null,
94
+ config: json({ mcpServers: { [server]: stdio } }),
95
+ notes: ["The mcpServers entry for an MCP client that reads this format; the command speaks MCP over stdio."],
96
+ };
97
+ }
98
+ }
99
+ const AGENT_NAMES = {
100
+ "claude-code": "Claude Code",
101
+ codex: "Codex",
102
+ cursor: "Cursor",
103
+ copilot: "GitHub Copilot CLI",
104
+ gemini: "Gemini CLI",
105
+ json: "any MCP client",
106
+ };
107
+ export const SETUP_DETAILS = `Prints how a coding agent gets one identity's browser: the command to run, or the block to
108
+ paste into its config file. It writes nothing; run or paste it yourself.
109
+
110
+ Agents:
111
+ claude-code a claude mcp add command
112
+ codex a [mcp_servers] block for ~/.codex/config.toml, and the codex mcp add command
113
+ cursor an mcpServers entry for ~/.cursor/mcp.json
114
+ copilot an mcpServers entry for ~/.copilot/mcp-config.json, and the copilot mcp add command
115
+ gemini an mcpServers entry for ~/.gemini/settings.json, and the gemini mcp add command
116
+ json the generic mcpServers entry other MCP clients read
117
+
118
+ Without --identity it uses the only identity there is. The agent then starts turno-browser-mcp
119
+ for the identity when it needs the browser.`;
120
+ /** The identity `setup` is for: --identity, or the only one there is. */
121
+ function pickIdentity(c, flag, io) {
122
+ const b = c.names.browser;
123
+ if (flag !== undefined) {
124
+ try {
125
+ c.api.assertIdentityId(flag);
126
+ }
127
+ catch (err) {
128
+ return fail(err.message);
129
+ }
130
+ if (!c.api.identityExists(flag, io.env))
131
+ return fail(`identity "${flag}" does not exist (${b} add ${flag})`);
132
+ return flag;
133
+ }
134
+ const ids = c.api.listIdentities(io.env).map((i) => i.id);
135
+ if (ids.length === 1)
136
+ return ids[0];
137
+ if (!ids.length)
138
+ return fail(`no identity yet: create one with ${b} add <id>, then ${b} setup <agent> --identity <id>`);
139
+ return fail(`pick an identity with --identity: ${ids.join(", ")}`);
140
+ }
141
+ /** `<browser> setup <agent> [--identity <id>] [--json]`. */
142
+ export function setup(c, args, io) {
143
+ const p = parseFlags(args, SETUP_FLAGS, 1);
144
+ const agent = p.positionals[0];
145
+ const b = c.names.browser;
146
+ if (!agent)
147
+ return fail(`setup needs an agent: ${b} setup <${SETUP_AGENTS.join("|")}> [--identity <id>]`);
148
+ if (!SETUP_AGENTS.includes(agent))
149
+ return fail(`unknown agent "${agent}" (agents: ${SETUP_AGENTS.join(", ")})`);
150
+ const id = pickIdentity(c, str(p, "identity"), io);
151
+ const { command, onPath } = mcpCommand(io.env);
152
+ const cfg = setupConfig(agent, id, command);
153
+ if (!onPath)
154
+ cfg.notes.push("turno-browser-mcp is not on the PATH here, so this names it by its full path.");
155
+ if (bool(p, "json")) {
156
+ emit(io, p, SETUP_JSON, cfg);
157
+ return 0;
158
+ }
159
+ const name = AGENT_NAMES[cfg.agent];
160
+ if (cfg.agent === "claude-code") {
161
+ io.out(`Run this once to give ${name} the browser identity "${id}":\n`);
162
+ io.out(cfg.shell);
163
+ }
164
+ else if (cfg.file) {
165
+ io.out(`Add this to ${cfg.file} to give ${name} the browser identity "${id}":\n`);
166
+ io.out(cfg.config);
167
+ if (cfg.shell)
168
+ io.out(`\nOr run: ${cfg.shell}`);
169
+ }
170
+ else {
171
+ io.out(`The browser identity "${id}" for ${name}:\n`);
172
+ io.out(cfg.config);
173
+ }
174
+ io.out("");
175
+ for (const n of cfg.notes)
176
+ io.out(n);
177
+ io.out(`Start a new agent session to load it. Sign in to your sites once with ${b} login ${id}.`);
178
+ return 0;
179
+ }
180
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1,5 @@
1
+ import { type Command } from "turno-core/cli";
2
+ import type { Ctx, VaultInput } from "./context.js";
3
+ export declare const terminalInput: VaultInput;
4
+ /** The `vault` group. */
5
+ export declare function vaultCommand(c: Ctx): Command;
@@ -0,0 +1,192 @@
1
+ import { DRY_RUN, JSON_FLAG, bool, emit, fail, flagsOf, group, jsonOutput, needsAnswer, nextStep, noInputReason, parseFlags, readHidden, readStdinText, readVisible, stdinIsTty, str, } from "turno-core/cli";
2
+ /**
3
+ * `vault`: the credential vault of a browser identity. Values go
4
+ * from a hidden prompt or stdin straight to turno-browser, which keeps them in the secret store;
5
+ * nothing here prints, logs or passes one as an argument.
6
+ */
7
+ /** `vault list --json`. */
8
+ const VAULT_JSON = jsonOutput(["identity", "submit", "sites"]);
9
+ export const terminalInput = {
10
+ isTty: stdinIsTty,
11
+ hidden: readHidden,
12
+ visible: readVisible,
13
+ stdin: readStdinText,
14
+ };
15
+ const ADD_FLAGS = {
16
+ url: { type: "string", multiple: true },
17
+ username: { type: "string" },
18
+ totp: { type: "boolean" },
19
+ ...DRY_RUN,
20
+ };
21
+ function ids(c, io, args, count, usage) {
22
+ const mod = c.api;
23
+ const words = args.slice(0, count);
24
+ if (words.length < count || words.some((w) => !w))
25
+ return fail(`usage: ${c.names.browser} vault ${usage}`);
26
+ try {
27
+ mod.assertIdentityId(words[0]);
28
+ }
29
+ catch (err) {
30
+ return fail(err.message);
31
+ }
32
+ if (!mod.identityExists(words[0], io.env))
33
+ return fail(`browser identity "${words[0]}" does not exist (${c.names.browser} add ${words[0]})`);
34
+ return words;
35
+ }
36
+ async function add(c, args, io, input) {
37
+ const mod = c.api;
38
+ const p = parseFlags(args, ADD_FLAGS, 2);
39
+ const [id, site] = ids(c, io, p.positionals, 2, "add <identity> <site> --url <sign-in page> [--username <name>] [--totp]");
40
+ const urls = p.values.url ?? [];
41
+ if (!urls.length)
42
+ return fail("give the sign-in page with --url (for example --url https://github.com/login)");
43
+ const withTotp = bool(p, "totp");
44
+ if (bool(p, "dry-run")) {
45
+ io.out(`(dry run) would store a username, a password${withTotp ? " and a TOTP secret" : ""} for ${site} in browser identity "${id}"`);
46
+ return 0;
47
+ }
48
+ let username = str(p, "username");
49
+ let password;
50
+ let totp;
51
+ if (input.isTty()) {
52
+ // Hidden prompts wait for a person: never with --no-input or inside an agent session.
53
+ if (noInputReason(io.env))
54
+ needsAnswer(`${c.names.subject}vault add`, "the password on stdin (and --username)");
55
+ username ??= await input.visible(`Username for ${site}: `);
56
+ password = await input.hidden(`Password for ${site} (input hidden): `);
57
+ if (withTotp)
58
+ totp = await input.hidden("TOTP secret or otpauth:// URI (input hidden): ");
59
+ }
60
+ else {
61
+ if (!username)
62
+ return fail("give --username when the password comes on stdin");
63
+ const lines = (await input.stdin()).split(/\r?\n/);
64
+ password = lines[0] ?? "";
65
+ if (withTotp)
66
+ totp = lines[1]?.trim() || undefined;
67
+ if (withTotp && !totp)
68
+ return fail("--totp reads the TOTP secret from the second line of stdin, and it is empty");
69
+ }
70
+ if (!password)
71
+ return fail("the password is empty; nothing was stored");
72
+ const entry = await mod.vaultAdd(id, site, { urls, username: username ?? "", password, ...(totp ? { totp } : {}) }, { env: io.env });
73
+ io.out(`stored the credentials of ${entry.site} for browser identity "${id}" (username, password${entry.totp ? ", TOTP secret" : ""}) in the secret store`);
74
+ io.out(`origins: ${entry.origins.join(", ")}`);
75
+ nextStep(io, `an agent on browser-${id} signs in with the browser_login tool (site "${entry.site}") on that sign-in page`, { enabled: (env) => c.host.hints?.(env) ?? true });
76
+ return 0;
77
+ }
78
+ async function list(c, args, io) {
79
+ const mod = c.api;
80
+ const p = parseFlags(args, JSON_FLAG, 1);
81
+ const [id] = ids(c, io, p.positionals, 1, "list <identity> [--json]");
82
+ const info = await mod.vaultList(id, { env: io.env });
83
+ if (bool(p, "json")) {
84
+ emit(io, p, VAULT_JSON, info);
85
+ return 0;
86
+ }
87
+ io.out(`browser identity "${id}": ${info.submit === "auto" ? "browser_login submits the form itself" : "browser_login fills, the agent clicks sign in"} (${c.names.browser} vault submit ${id} auto|confirm)`);
88
+ if (!info.sites.length) {
89
+ io.out(`No credentials yet. Add some with \`${c.names.browser} vault add ${id} <site> --url <sign-in page>\`.`);
90
+ return 0;
91
+ }
92
+ const width = Math.max(...info.sites.map((s) => s.site.length));
93
+ for (const s of info.sites) {
94
+ const state = s.stored ? "" : " MISSING from the secret store";
95
+ io.out(`${s.site.padEnd(width)} ${s.totp ? "password+totp" : "password "} ${s.origins.join(", ")}${state}`);
96
+ }
97
+ return info.sites.every((s) => s.stored) ? 0 : 1;
98
+ }
99
+ async function remove(c, args, io) {
100
+ const mod = c.api;
101
+ const p = parseFlags(args, DRY_RUN, 2);
102
+ const [id, site] = ids(c, io, p.positionals, 2, "remove <identity> <site> [--dry-run]");
103
+ if (bool(p, "dry-run")) {
104
+ io.out(`(dry run) would delete the credentials of ${site} from browser identity "${id}"`);
105
+ return 0;
106
+ }
107
+ if (!(await mod.vaultRemove(id, site, { env: io.env }))) {
108
+ io.out(`browser identity "${id}" has no credentials for ${site}`);
109
+ return 1;
110
+ }
111
+ io.out(`removed the credentials of ${site} from browser identity "${id}"`);
112
+ return 0;
113
+ }
114
+ function submit(c, args, io) {
115
+ const mod = c.api;
116
+ const p = parseFlags(args, DRY_RUN, 2);
117
+ const [id, mode] = ids(c, io, p.positionals, 2, "submit <identity> <confirm|auto>");
118
+ if (mode !== "confirm" && mode !== "auto")
119
+ return fail(`submit takes "confirm" (the agent clicks sign in) or "auto" (browser_login submits), not "${mode}"`);
120
+ if (bool(p, "dry-run")) {
121
+ io.out(`(dry run) would set browser_login of "${id}" to ${mode}`);
122
+ return 0;
123
+ }
124
+ mod.vaultSetSubmit(id, mode, { env: io.env });
125
+ io.out(mode === "auto"
126
+ ? `browser_login now submits the sign-in form itself for "${id}"`
127
+ : `browser_login now only fills the form for "${id}"; the agent clicks sign in`);
128
+ return 0;
129
+ }
130
+ const FOOTER = `The vault keeps a username, a password and optionally a TOTP secret per site for one
131
+ browser identity, only in the secret store (the macOS Keychain or the Linux Secret Service).
132
+ The browser_login tool fills them into the site's sign-in page without the agent seeing them,
133
+ and only on the origins given with --url. In a terminal the password and the TOTP secret are
134
+ asked with hidden prompts; from a pipe, the first line of stdin is the password and, with
135
+ --totp, the second line is the TOTP secret (base32, or the otpauth:// URI of the QR code).`;
136
+ /** The `vault` group. */
137
+ export function vaultCommand(c) {
138
+ const input = c.deps.input ?? terminalInput;
139
+ const b = c.names.browser;
140
+ const withModule = (run) => async (args, io) => {
141
+ try {
142
+ return await run(c, args, io);
143
+ }
144
+ catch (err) {
145
+ const name = err.name;
146
+ if (name === "VaultError" || name === "IdentityError" || name === "TotpError")
147
+ return fail(err.message);
148
+ throw err;
149
+ }
150
+ };
151
+ const subs = {
152
+ add: {
153
+ summary: "store a site's username, password and optional TOTP secret (asked hidden, or on stdin)",
154
+ synopsis: "<identity> <site> --url <sign-in page> [--url <url>]... [--username <name>] [--totp] [--dry-run]",
155
+ flags: flagsOf(ADD_FLAGS),
156
+ run: withModule((c, args, io) => add(c, args, io, input)),
157
+ },
158
+ list: {
159
+ summary: "the sites in an identity's vault (never the values)",
160
+ synopsis: "<identity> [--json]",
161
+ flags: ["--json"],
162
+ json: VAULT_JSON,
163
+ run: withModule(list),
164
+ },
165
+ remove: {
166
+ summary: "delete a site's credentials",
167
+ synopsis: "<identity> <site> [--dry-run]",
168
+ flags: ["--dry-run"],
169
+ run: withModule(remove),
170
+ },
171
+ rm: { summary: "same as remove", hidden: true, run: withModule(remove) },
172
+ submit: {
173
+ summary: "let browser_login submit the form (auto) or leave the click to the agent (confirm, default)",
174
+ synopsis: "<identity> <confirm|auto> [--dry-run]",
175
+ flags: ["--dry-run"],
176
+ run: withModule(submit),
177
+ },
178
+ };
179
+ return group(`${c.names.subject}vault`, "credentials browser_login fills without showing them", subs, {
180
+ footer: FOOTER,
181
+ prefix: `${b} vault`,
182
+ examples: [
183
+ `${b} vault add work github --url https://github.com/login --username alice --totp`,
184
+ `printf '%s\\n' "$PASSWORD" | ${b} vault add work mail --url https://mail.example.com --username alice@example.com`,
185
+ `${b} vault list work`,
186
+ `${b} vault list work --json`,
187
+ `${b} vault submit work auto`,
188
+ `${b} vault remove work github --dry-run`,
189
+ ],
190
+ });
191
+ }
192
+ //# sourceMappingURL=vault.js.map
@@ -0,0 +1,82 @@
1
+ import type { CallToolResult, Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import { type BackgroundState } from "./background-state.js";
3
+ /**
4
+ * The client of an identity's background server (`background.ts`): start it when it is not
5
+ * running, open or continue an MCP session on it, call tools, end the session, stop the server.
6
+ * `turno-browser do` uses it when turno's gateway is not there.
7
+ *
8
+ * A session is the unit that keeps a tab: with `"sharing": "tabs"` each session has its own tabs,
9
+ * with `"sharing": "session"` one session at a time holds the browser. To continue a session from
10
+ * another process, save `id` and `protocolVersion` of an open one and pass them as `session`; a
11
+ * session the server no longer knows (it restarted) is replaced by a new one (`resumed: false`).
12
+ */
13
+ export { BackgroundError } from "./background.js";
14
+ export type { BackgroundState } from "./background-state.js";
15
+ export interface BackgroundClientOptions {
16
+ env?: NodeJS.ProcessEnv;
17
+ }
18
+ export interface StartBackgroundOptions extends BackgroundClientOptions {
19
+ /** More `turno-browser-mcp` flags for a server this call starts (`--headless`, `--background-idle 30m`). */
20
+ args?: string[];
21
+ /** How long to wait until the server is ready (default 30 seconds). */
22
+ timeoutMs?: number;
23
+ /** The `turno-browser-mcp` script to run (default: this install's). */
24
+ bin?: string;
25
+ }
26
+ export interface StartedBackground {
27
+ state: BackgroundState;
28
+ /** False when it was already running. */
29
+ started: boolean;
30
+ }
31
+ export interface OpenSessionOptions extends BackgroundClientOptions {
32
+ /** A session to continue (`BackgroundSession.id` and `protocolVersion` of an earlier one). */
33
+ session?: {
34
+ id: string;
35
+ protocolVersion?: string;
36
+ };
37
+ /** The process the session belongs to: the server ends the session when it exits. */
38
+ owner?: number;
39
+ /** Start the server when it is not running (default true); options for that start. */
40
+ start?: boolean | StartBackgroundOptions;
41
+ /** The client name the server sees (default "turno-browser"). */
42
+ clientName?: string;
43
+ }
44
+ export interface CallOptions {
45
+ /** Default 120 seconds; progress from the server restarts it. */
46
+ timeoutMs?: number;
47
+ signal?: AbortSignal;
48
+ }
49
+ export interface BackgroundSession {
50
+ /** The session id (`Mcp-Session-Id`): what continues this session from another process. */
51
+ readonly id: string;
52
+ readonly protocolVersion: string | undefined;
53
+ /** True when it continued the session asked for, false when it opened a new one. */
54
+ readonly resumed: boolean;
55
+ readonly state: BackgroundState;
56
+ listTools(): Promise<Tool[]>;
57
+ callTool(name: string, args?: Record<string, unknown>, options?: CallOptions): Promise<CallToolResult>;
58
+ /** Ends the session on the server (its tabs and lease go) and disconnects. */
59
+ end(): Promise<void>;
60
+ /** Disconnects and keeps the session for the next process that continues it. */
61
+ close(): Promise<void>;
62
+ }
63
+ /** The running background server of the identity, or undefined (a state left by a killed one is removed). */
64
+ export declare function backgroundStatus(id: string, options?: BackgroundClientOptions): BackgroundState | undefined;
65
+ /**
66
+ * Starts the identity's background server unless it runs: detached from this process, its
67
+ * output in `server.log` of its folder. Resolves when it is ready; rejects with what it wrote
68
+ * when it exits first (the identity is in use, a bad flag) or after the timeout.
69
+ */
70
+ export declare function startBackground(id: string, options?: StartBackgroundOptions): Promise<StartedBackground>;
71
+ /**
72
+ * Stops the identity's background server (SIGTERM: it closes its sessions and Chrome, then
73
+ * exits). Resolves true when one ran, false when none did.
74
+ */
75
+ export declare function stopBackground(id: string, options?: BackgroundClientOptions & {
76
+ timeoutMs?: number;
77
+ }): Promise<boolean>;
78
+ /**
79
+ * Opens a session on the identity's background server, or continues `options.session`,
80
+ * starting the server first unless `start` is false.
81
+ */
82
+ export declare function openBackgroundSession(id: string, options?: OpenSessionOptions): Promise<BackgroundSession>;