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,59 +1,147 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import { existsSync
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
3
|
import { loadConfig } from "../../core/config.js";
|
|
4
|
+
import { ensurePrivateDir, findOnPath } from "../../core/paths.js";
|
|
4
5
|
import { profileFromConfigDir } from "../../core/profiles.js";
|
|
5
6
|
import { fail } from "../io.js";
|
|
6
7
|
import { checkName } from "./setup.js";
|
|
8
|
+
const USAGE = [
|
|
9
|
+
"Usage: turno open [profile] <url>",
|
|
10
|
+
"",
|
|
11
|
+
"claude.ai and claude.com links open in the profile's isolated Google Chrome profile,",
|
|
12
|
+
'or in the default browser when profiles.<name>.browser = "default". Other links',
|
|
13
|
+
"always open in the default browser. Only http(s) and mailto links are accepted.",
|
|
14
|
+
"Claude Code calls this through $BROWSER. Typed in a terminal outside a profile's session,",
|
|
15
|
+
"a claude.ai link without a profile shows the profiles to choose from.",
|
|
16
|
+
"",
|
|
17
|
+
"Examples:",
|
|
18
|
+
" $ turno open https://claude.ai/new",
|
|
19
|
+
" $ turno open work https://claude.ai/new",
|
|
20
|
+
].join("\n");
|
|
7
21
|
/** claude.ai and claude.com links (and their subdomains) open with the profile's account. */
|
|
8
22
|
export function isClaudeUrl(url) {
|
|
9
23
|
return /^https:\/\/([A-Za-z0-9-]+\.)*claude\.(ai|com)\//.test(url);
|
|
10
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Links turno hands to the system opener: http(s) and mailto only. `open` and `xdg-open` also
|
|
27
|
+
* run file paths, file:// URLs and custom schemes, and read a leading `-` as an option.
|
|
28
|
+
*/
|
|
29
|
+
export function isOpenableUrl(url) {
|
|
30
|
+
return !url.startsWith("-") && /^(https?:\/\/[^\s]+|mailto:[^\s]+)$/i.test(url);
|
|
31
|
+
}
|
|
32
|
+
/** Chrome executables looked up on PATH on Linux, in order. */
|
|
33
|
+
export const LINUX_CHROMES = ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"];
|
|
11
34
|
function chromeApp(env) {
|
|
12
35
|
return env.TURNO_CHROME_APP || "/Applications/Google Chrome.app";
|
|
13
36
|
}
|
|
14
|
-
/** The
|
|
15
|
-
|
|
37
|
+
/** The Chrome profile a claude.ai link opens in, or undefined for the default browser. */
|
|
38
|
+
function chromeProfile(profile, url, env) {
|
|
16
39
|
if (!isClaudeUrl(url))
|
|
17
|
-
return
|
|
40
|
+
return undefined;
|
|
18
41
|
const config = loadConfig(env);
|
|
19
42
|
const name = profile ?? profileFromConfigDir(env.CLAUDE_CONFIG_DIR, config, env) ?? config.system;
|
|
20
43
|
if (!name)
|
|
21
|
-
return
|
|
44
|
+
return undefined;
|
|
22
45
|
checkName(name);
|
|
23
46
|
if (config.profiles[name]?.browser === "default")
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
47
|
+
return undefined;
|
|
48
|
+
return { name, dir: config.open.chromeDir };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The command that opens `url` on `platform`: `open` on macOS (Chrome through the app bundle),
|
|
52
|
+
* `xdg-open` on Linux (Chrome found on PATH). Throws a usage error for anything that is not an
|
|
53
|
+
* http(s) or mailto link, and on other platforms.
|
|
54
|
+
*/
|
|
55
|
+
export function openInvocation(profile, url, env = process.env, platform = process.platform) {
|
|
56
|
+
if (!isOpenableUrl(url))
|
|
57
|
+
fail(`refusing to open ${JSON.stringify(url)}: only http(s) and mailto links`);
|
|
58
|
+
if (platform !== "darwin" && platform !== "linux")
|
|
59
|
+
fail(`turno open supports macOS and Linux, not ${platform}`);
|
|
60
|
+
const chrome = chromeProfile(profile, url, env);
|
|
61
|
+
if (platform === "darwin") {
|
|
62
|
+
if (!chrome || !existsSync(chromeApp(env)))
|
|
63
|
+
return { command: "open", args: [url] };
|
|
64
|
+
ensurePrivateDir(chrome.dir, env);
|
|
65
|
+
return {
|
|
66
|
+
command: "open",
|
|
67
|
+
args: [
|
|
68
|
+
"-na",
|
|
69
|
+
"Google Chrome",
|
|
70
|
+
"--args",
|
|
71
|
+
`--user-data-dir=${chrome.dir}`,
|
|
72
|
+
`--profile-directory=${chrome.name}`,
|
|
73
|
+
url,
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const bin = chrome && (env.TURNO_CHROME_BIN || LINUX_CHROMES.map((c) => findOnPath(c, env)).find(Boolean));
|
|
78
|
+
if (chrome && bin) {
|
|
79
|
+
ensurePrivateDir(chrome.dir, env);
|
|
80
|
+
return {
|
|
81
|
+
command: bin,
|
|
82
|
+
args: [`--user-data-dir=${chrome.dir}`, `--profile-directory=${chrome.name}`, url],
|
|
83
|
+
detach: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (!findOnPath("xdg-open", env))
|
|
87
|
+
fail("cannot open links: xdg-open is not installed (package xdg-utils)");
|
|
88
|
+
return { command: "xdg-open", args: [url] };
|
|
89
|
+
}
|
|
90
|
+
/** The `open` argv on macOS (kept for callers that only target macOS). */
|
|
91
|
+
export function openArgs(profile, url, env = process.env) {
|
|
92
|
+
return openInvocation(profile, url, env, "darwin").args;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The profile for a claude.ai link typed in a terminal without one: outside a profile's session
|
|
96
|
+
* a person chooses (the system profile first). Claude Code calling through $BROWSER, a script or
|
|
97
|
+
* an agent never sees the picker and keeps the default.
|
|
98
|
+
*/
|
|
99
|
+
async function chooseProfile(url, io) {
|
|
100
|
+
if (!io.ask || !isOpenableUrl(url) || !isClaudeUrl(url))
|
|
101
|
+
return undefined;
|
|
102
|
+
const config = loadConfig(io.env);
|
|
103
|
+
// A profile's session (its launcher sets CLAUDE_CONFIG_DIR) opens links with its own account.
|
|
104
|
+
if (io.env.CLAUDE_CONFIG_DIR && profileFromConfigDir(io.env.CLAUDE_CONFIG_DIR, config, io.env))
|
|
105
|
+
return undefined;
|
|
106
|
+
const { pickProfile } = await import("../picker.js");
|
|
107
|
+
return pickProfile(io, {
|
|
108
|
+
command: "open",
|
|
109
|
+
title: "Open the link with",
|
|
110
|
+
agent: "claude",
|
|
111
|
+
...(config.system ? { initial: config.system } : {}),
|
|
112
|
+
});
|
|
29
113
|
}
|
|
30
114
|
export const command = {
|
|
31
115
|
summary: "open a claude.ai link with an account (default: the session's)",
|
|
32
|
-
usage:
|
|
33
|
-
"Usage: turno open [profile] <url>",
|
|
34
|
-
"",
|
|
35
|
-
"claude.ai and claude.com links open in the profile's isolated Google Chrome profile,",
|
|
36
|
-
'or in the default browser when profiles.<name>.browser = "default". Other links',
|
|
37
|
-
"always open in the default browser. Claude Code calls this through $BROWSER.",
|
|
38
|
-
].join("\n"),
|
|
116
|
+
usage: USAGE,
|
|
39
117
|
async run(args, io) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
profile = rest[0];
|
|
44
|
-
rest = rest.slice(1);
|
|
118
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
119
|
+
io.out(USAGE);
|
|
120
|
+
return 0;
|
|
45
121
|
}
|
|
46
|
-
|
|
122
|
+
if (args.length > 2)
|
|
123
|
+
fail("usage: turno open [profile] <url>");
|
|
124
|
+
let [profile, url] = args.length === 2 ? [args[0], args[1]] : [undefined, args[0]];
|
|
47
125
|
if (!url)
|
|
48
126
|
fail("usage: turno open [profile] <url>");
|
|
49
|
-
|
|
127
|
+
profile ??= await chooseProfile(url, io);
|
|
128
|
+
const inv = openInvocation(profile, url, io.env);
|
|
50
129
|
return new Promise((resolve) => {
|
|
51
|
-
const child = spawn("
|
|
130
|
+
const child = spawn(inv.command, inv.args, inv.detach ? { stdio: "ignore", env: io.env, detached: true } : { stdio: "inherit", env: io.env });
|
|
52
131
|
child.on("error", (err) => {
|
|
53
|
-
io.err(`turno: open: ${err.message}`);
|
|
132
|
+
io.err(`turno: open: ${err.code === "ENOENT" ? `${inv.command} not found` : err.message}`);
|
|
54
133
|
resolve(1);
|
|
55
134
|
});
|
|
56
|
-
|
|
135
|
+
if (inv.detach) {
|
|
136
|
+
// Chrome either hands the link to a running instance and exits, or becomes the browser.
|
|
137
|
+
child.on("spawn", () => {
|
|
138
|
+
child.unref();
|
|
139
|
+
resolve(0);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
child.on("exit", (code) => resolve(code ?? 1));
|
|
144
|
+
}
|
|
57
145
|
});
|
|
58
146
|
},
|
|
59
147
|
};
|