turno-browser 0.5.0 → 0.6.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # turno-browser
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cd53ee9: `turno-browser completion <zsh|bash|fish>` prints a shell completion script: commands, identity
8
+ names, setup agents, `do` actions and each command's flags. It only reads identity folders, so
9
+ completing never starts Chrome or reads the secret store. The scripts come from turno-core, which
10
+ turno uses too.
11
+
12
+ ### Patch Changes
13
+
14
+ - cd53ee9: - `turno --help | head` and `turno-browser --help | head` end quietly instead of printing an
15
+ EPIPE stack trace when the reader stops early.
16
+ - Bash completion works on the bash 3.2 macOS ships: each word reaches turno on its own, and
17
+ the script loads with `eval "$(turno completion bash)"`, since bash 3.2 cannot source `<(...)`.
18
+ - `turno mcp daemon run` stops by itself when its home folder is removed (a throwaway HOME
19
+ someone deleted), instead of running on with nothing left to serve.
20
+ - Updated dependencies [cd53ee9]
21
+ - Updated dependencies [cd53ee9]
22
+ - turno-core@0.3.0
23
+
3
24
  ## 0.5.0
4
25
 
5
26
  ### Minor Changes
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Shell completion for the turno-browser program: `turno-browser completion <shell>` prints the
3
+ * script, and the script calls `turno-browser __complete -- <words...>` for candidates. It only
4
+ * reads identity folders: completing never starts Chrome or reads the secret store.
5
+ */
6
+ import { type Sub } from "turno-core/cli";
7
+ /** Candidates for the last word, given the words before it (both after `turno-browser`). */
8
+ export declare function complete(words: readonly string[], subs: Record<string, Sub>, env: NodeJS.ProcessEnv): string[];
9
+ /** `turno-browser completion <shell>`: the script, or undefined for an unknown shell. */
10
+ export declare function completionScript(program: string, shell: string | undefined): string | undefined;
11
+ export declare const COMPLETION_USAGE: (program: string) => string;
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Shell completion for the turno-browser program: `turno-browser completion <shell>` prints the
3
+ * script, and the script calls `turno-browser __complete -- <words...>` for candidates. It only
4
+ * reads identity folders: completing never starts Chrome or reads the secret store.
5
+ */
6
+ import { SHELLS, completionScripts } from "turno-core/cli";
7
+ import { listIdentities } from "../identities.js";
8
+ import { ACTION_NAMES } from "./do.js";
9
+ import { SETUP_AGENTS } from "./setup.js";
10
+ /** Commands whose first argument is an identity. */
11
+ const IDENTITY_FIRST = new Set([
12
+ "show",
13
+ "set",
14
+ "login",
15
+ "remove",
16
+ "export",
17
+ "record",
18
+ "flows",
19
+ "replay",
20
+ "traces",
21
+ "live",
22
+ "pause",
23
+ "resume",
24
+ "do",
25
+ "reputation",
26
+ ]);
27
+ /** Commands with their own subcommands, and whether an identity follows the subcommand. */
28
+ const NESTED = {
29
+ background: { subs: ["status", "start", "stop"], identity: true },
30
+ vault: { subs: ["add", "list", "remove", "submit"], identity: true },
31
+ secret: { subs: ["set", "has", "list", "remove"], identity: false },
32
+ };
33
+ /** Flags whose value can be completed: a list, or the identities, or a path. */
34
+ const FLAG_VALUES = {
35
+ "--identity": "identity",
36
+ "--engine": ["chrome", "lightpanda", "camoufox"],
37
+ "--out": "file",
38
+ "--color": ["auto", "always", "never"],
39
+ };
40
+ const GLOBAL_FLAGS = ["--help", "--version", "--no-input", "--color"];
41
+ function identities(env) {
42
+ try {
43
+ return listIdentities(env).map((i) => i.id);
44
+ }
45
+ catch {
46
+ return [];
47
+ }
48
+ }
49
+ /** Candidates for the last word, given the words before it (both after `turno-browser`). */
50
+ export function complete(words, subs, env) {
51
+ const cur = words[words.length - 1] ?? "";
52
+ const before = words.slice(0, -1);
53
+ const match = (list) => [...new Set(list)].filter((c) => c.startsWith(cur));
54
+ const visible = Object.keys(subs).filter((s) => !subs[s].hidden);
55
+ const commands = [...visible, "help", "completion"];
56
+ if (before.length === 0)
57
+ return match(cur.startsWith("-") ? GLOBAL_FLAGS : commands);
58
+ const [name, ...rest] = before;
59
+ const prev = before[before.length - 1];
60
+ const value = FLAG_VALUES[prev];
61
+ if (value && before.length > 1) {
62
+ if (value === "file")
63
+ return [":file"];
64
+ return match(value === "identity" ? identities(env) : value);
65
+ }
66
+ if (name === "help")
67
+ return before.length === 1 ? match(visible) : [];
68
+ if (name === "completion")
69
+ return before.length === 1 ? match(SHELLS) : [];
70
+ const sub = subs[name];
71
+ if (!sub)
72
+ return [];
73
+ if (cur.startsWith("-"))
74
+ return match([...(sub.flags ?? []), "--help"]);
75
+ // The positional arguments typed so far, without flags and the values they took.
76
+ const positionals = rest.filter((a, i) => !a.startsWith("-") && !(i > 0 && FLAG_VALUES[rest[i - 1]]));
77
+ const n = positionals.length;
78
+ const nested = NESTED[name];
79
+ if (nested) {
80
+ if (n === 0)
81
+ return match(nested.subs);
82
+ return n === 1 && nested.identity ? match(identities(env)) : [];
83
+ }
84
+ if (name === "setup")
85
+ return n === 0 ? match(SETUP_AGENTS) : [];
86
+ if (name === "import")
87
+ return n === 0 ? [":file"] : [];
88
+ if (IDENTITY_FIRST.has(name) && n === 0)
89
+ return match(identities(env));
90
+ if (name === "do" && n === 1)
91
+ return match(ACTION_NAMES);
92
+ return [];
93
+ }
94
+ /** `turno-browser completion <shell>`: the script, or undefined for an unknown shell. */
95
+ export function completionScript(program, shell) {
96
+ const scripts = completionScripts(program);
97
+ return shell && shell in scripts ? scripts[shell] : undefined;
98
+ }
99
+ export const COMPLETION_USAGE = (program) => [
100
+ `Usage: ${program} completion <zsh|bash|fish>`,
101
+ "",
102
+ "Prints the completion script: commands, identities, flags and do actions. To load it in every shell:",
103
+ ` zsh echo 'source <(${program} completion zsh)' >> ~/.zshrc`,
104
+ ` bash echo 'eval "$(${program} completion bash)"' >> ~/.bashrc`,
105
+ ` fish ${program} completion fish > ~/.config/fish/completions/${program}.fish`,
106
+ ].join("\n");
107
+ //# sourceMappingURL=completion.js.map
package/dist/cli/main.js CHANGED
@@ -5,6 +5,7 @@ import { CliError, Exit, UsageError, columns, confirm, defaultIo, exitName, fail
5
5
  import { api } from "../api.js";
6
6
  import { browserCli } from "./commands.js";
7
7
  import { standaloneHost } from "./context.js";
8
+ import { COMPLETION_USAGE, complete, completionScript } from "./completion.js";
8
9
  /**
9
10
  * `turno-browser <command>`: the identity commands on their own, without turno-cli. The same
10
11
  * commands run inside turno as `turno browser <command>`; only the names in help and hints
@@ -40,6 +41,7 @@ export function renderHelp(io, cli) {
40
41
  [`${PROGRAM} <command> [flags]`, "manage identities: persistent Chrome profiles your agents sign in with"],
41
42
  [`${PROGRAM} <command> --help`, "the flags and examples of one command"],
42
43
  ["turno-browser-mcp --identity <id>", "the MCP server an agent runs for one identity (--help)"],
44
+ [`${PROGRAM} completion <zsh|bash|fish>`, "shell completion for commands, identities and flags (--help)"],
43
45
  ]));
44
46
  const left = Math.max(...SECTIONS.flatMap((x) => x.commands.map((n) => n.length)));
45
47
  for (const section of SECTIONS) {
@@ -142,6 +144,27 @@ export async function main(args, io = defaultIo()) {
142
144
  io.out(`${PROGRAM} ${version()}`);
143
145
  return Exit.ok;
144
146
  }
147
+ if (head === "__complete") {
148
+ const words = tail[0] === "--" ? tail.slice(1) : tail;
149
+ for (const c of complete(words.length ? words : [""], cli.subs, io.env))
150
+ io.out(c);
151
+ return Exit.ok;
152
+ }
153
+ if (head === "completion") {
154
+ if (tail[0] === "--help" || tail[0] === "-h") {
155
+ io.out(COMPLETION_USAGE(PROGRAM));
156
+ return Exit.ok;
157
+ }
158
+ const script = completionScript(PROGRAM, tail[0]);
159
+ if (!script || tail.length > 1)
160
+ throw new UsageError(`usage: ${PROGRAM} completion <zsh|bash|fish>`);
161
+ io.out(script.trimEnd());
162
+ return Exit.ok;
163
+ }
164
+ if (head === "help" && tail[0] === "completion") {
165
+ io.out(COMPLETION_USAGE(PROGRAM));
166
+ return Exit.ok;
167
+ }
145
168
  if (head === "help")
146
169
  return await cli.command.run([...tail, "--help"], io);
147
170
  if (head.startsWith("-"))
@@ -1,5 +1,11 @@
1
1
  import { type Io } from "turno-core/cli";
2
2
  import type { Ctx } from "./context.js";
3
+ /**
4
+ * `turno-browser setup <agent> [--identity <id>]`: the MCP config that gives a coding agent one
5
+ * identity's browser, printed for the person to run or paste. It never writes a file: an
6
+ * agent's config is the person's (inside turno, `turno mcp sync` writes it from mcp.toml).
7
+ */
8
+ export declare const SETUP_AGENTS: readonly ["claude-code", "codex", "cursor", "copilot", "gemini", "json"];
3
9
  /** `setup --json`: one object. */
4
10
  export declare const SETUP_JSON: import("turno-core/cli").JsonOutput;
5
11
  export declare const SETUP_DETAILS = "Prints how a coding agent gets one identity's browser: the command to run, or the block to\npaste into its config file. It writes nothing; run or paste it yourself.\n\nAgents:\n claude-code a claude mcp add command\n codex a [mcp_servers] block for ~/.codex/config.toml, and the codex mcp add command\n cursor an mcpServers entry for ~/.cursor/mcp.json\n copilot an mcpServers entry for ~/.copilot/mcp-config.json, and the copilot mcp add command\n gemini an mcpServers entry for ~/.gemini/settings.json, and the gemini mcp add command\n json the generic mcpServers entry other MCP clients read\n\nWithout --identity it uses the only identity there is. The agent then starts turno-browser-mcp\nfor the identity when it needs the browser.";
package/dist/cli/setup.js CHANGED
@@ -6,7 +6,7 @@ import { findOnPath } from "turno-core/paths";
6
6
  * identity's browser, printed for the person to run or paste. It never writes a file: an
7
7
  * agent's config is the person's (inside turno, `turno mcp sync` writes it from mcp.toml).
8
8
  */
9
- const SETUP_AGENTS = ["claude-code", "codex", "cursor", "copilot", "gemini", "json"];
9
+ export const SETUP_AGENTS = ["claude-code", "codex", "cursor", "copilot", "gemini", "json"];
10
10
  /** `setup --json`: one object. */
11
11
  export const SETUP_JSON = jsonOutput([
12
12
  "agent",
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "turno-browser",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "turno-browser",
9
- "version": "0.5.0",
9
+ "version": "0.6.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/sdk": "1.32.2",
13
13
  "patchright-core": "1.64.3",
14
- "turno-core": "0.2.0"
14
+ "turno-core": "0.3.0"
15
15
  },
16
16
  "bin": {
17
17
  "turno-browser": "dist/cli/main.js",
@@ -1018,8 +1018,8 @@
1018
1018
  }
1019
1019
  },
1020
1020
  "node_modules/turno-core": {
1021
- "version": "0.2.0",
1022
- "resolved": "https://registry.npmjs.org/turno-core/-/turno-core-0.2.0.tgz",
1021
+ "version": "0.3.0",
1022
+ "resolved": "https://registry.npmjs.org/turno-core/-/turno-core-0.3.0.tgz",
1023
1023
  "license": "Apache-2.0",
1024
1024
  "engines": {
1025
1025
  "node": ">=22.11"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turno-browser",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "A browser your agents use with your accounts. It stays light on your machine, and the model never sees your passwords.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "William Frank Monroy Mamani (https://github.com/william-monroy)",
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "@modelcontextprotocol/sdk": "1.32.2",
44
44
  "patchright-core": "1.64.3",
45
- "turno-core": "0.2.0"
45
+ "turno-core": "0.3.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^26.6.6",