turno-cli 0.1.1 → 0.2.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 +284 -0
- package/README.md +120 -53
- package/dist/accounts/audit.js +137 -7
- package/dist/accounts/builtin.js +68 -21
- package/dist/accounts/delegate.js +176 -35
- package/dist/accounts/policy.js +77 -0
- package/dist/accounts/registry.js +37 -21
- package/dist/agents/adapter.js +7 -0
- package/dist/agents/claude.js +195 -0
- package/dist/agents/codex.js +98 -0
- package/dist/agents/copilot.js +39 -0
- package/dist/agents/cursor.js +41 -0
- package/dist/agents/index.js +26 -86
- package/dist/agents/snippets.js +7 -4
- package/dist/cli/args.js +19 -4
- package/dist/cli/commands/accounts.js +96 -51
- package/dist/cli/commands/auto.js +82 -32
- package/dist/cli/commands/browser.js +216 -135
- package/dist/cli/commands/complete.js +2 -1
- package/dist/cli/commands/completion.js +4 -2
- package/dist/cli/commands/config.js +103 -18
- package/dist/cli/commands/demo.js +292 -0
- package/dist/cli/commands/doctor.js +387 -119
- package/dist/cli/commands/handoff.js +33 -22
- package/dist/cli/commands/identity.js +101 -50
- package/dist/cli/commands/init.js +616 -0
- package/dist/cli/commands/limit.js +25 -13
- package/dist/cli/commands/mcp-oauth.js +194 -0
- package/dist/cli/commands/mcp-observe.js +434 -0
- package/dist/cli/commands/mcp.js +653 -185
- package/dist/cli/commands/mcpd.js +323 -75
- package/dist/cli/commands/migrate.js +6 -4
- package/dist/cli/commands/open.js +92 -27
- package/dist/cli/commands/profile.js +205 -69
- package/dist/cli/commands/resolve.js +6 -2
- package/dist/cli/commands/run.js +15 -5
- package/dist/cli/commands/secret.js +61 -42
- package/dist/cli/commands/session.js +2 -2
- package/dist/cli/commands/sessions.js +42 -12
- package/dist/cli/commands/setup.js +136 -158
- package/dist/cli/commands/status.js +172 -41
- package/dist/cli/commands/statusline.js +305 -113
- package/dist/cli/commands/ui.js +64 -66
- package/dist/cli/commands/undo.js +161 -18
- package/dist/cli/commands/uninstall.js +462 -0
- package/dist/cli/commands/upgrade.js +75 -19
- package/dist/cli/commands/usage.js +117 -44
- package/dist/cli/commands/version.js +7 -5
- package/dist/cli/commands/which.js +7 -24
- package/dist/cli/compile-cache.js +32 -0
- package/dist/cli/group.js +10 -10
- package/dist/cli/help.js +57 -0
- package/dist/cli/highlight.js +236 -0
- package/dist/cli/io.js +170 -1
- package/dist/cli/launch.js +21 -37
- package/dist/cli/launchers.js +145 -94
- package/dist/cli/main.js +163 -27
- package/dist/cli/picker.js +447 -0
- package/dist/cli/registry.js +42 -5
- package/dist/cli/security.js +539 -0
- package/dist/cli/style.js +281 -0
- package/dist/core/config.js +145 -23
- package/dist/core/exhausted.js +6 -8
- package/dist/core/fsutil.js +47 -0
- package/dist/core/journal.js +281 -11
- package/dist/core/manifest.js +126 -6
- package/dist/core/paths.js +114 -7
- package/dist/core/profiles.js +139 -9
- package/dist/core/resolve.js +129 -23
- package/dist/core/secrets.js +215 -20
- package/dist/core/sessions.js +13 -20
- package/dist/core/update.js +18 -8
- package/dist/demo/server.js +34 -0
- package/dist/mcpd/cache.js +18 -4
- package/dist/mcpd/calllog.js +253 -0
- package/dist/mcpd/client-names.js +51 -0
- package/dist/mcpd/connectors.js +148 -17
- package/dist/mcpd/daemon.js +452 -116
- package/dist/mcpd/folder-sets.js +39 -0
- package/dist/mcpd/gateway.js +441 -47
- package/dist/mcpd/health.js +269 -0
- package/dist/mcpd/importer.js +356 -36
- package/dist/mcpd/instances.js +425 -65
- package/dist/mcpd/jsonrpc.js +8 -0
- package/dist/mcpd/launchd.js +65 -48
- package/dist/mcpd/modern.js +648 -0
- package/dist/mcpd/oauth.js +791 -0
- package/dist/mcpd/peerpid.js +122 -6
- package/dist/mcpd/pressure.js +85 -0
- package/dist/mcpd/rss.js +151 -0
- package/dist/mcpd/service.js +167 -0
- package/dist/mcpd/state.js +183 -0
- package/dist/mcpd/sync.js +55 -80
- package/dist/mcpd/systemd.js +80 -0
- package/dist/mcpd/tokens.js +89 -0
- package/dist/mcpd/upstream.js +154 -44
- package/dist/statusline/cost.js +154 -44
- package/dist/statusline/input.js +66 -0
- package/dist/statusline/render.js +9 -3
- package/dist/ui/fonts.js +8 -3
- package/dist/ui/settings.js +27 -15
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +6 -6
- package/dist/cli/commands/available.js +0 -18
package/dist/mcpd/jsonrpc.js
CHANGED
|
@@ -2,6 +2,8 @@ export const isRequest = (m) => typeof m.method === "string" && m.id !== undefin
|
|
|
2
2
|
export const isNotification = (m) => typeof m.method === "string" && (m.id === undefined || m.id === null);
|
|
3
3
|
export const isResponse = (m) => m.method === undefined && m.id !== undefined && ("result" in m || "error" in m);
|
|
4
4
|
export const ErrorCode = {
|
|
5
|
+
ParseError: -32700,
|
|
6
|
+
InvalidRequest: -32600,
|
|
5
7
|
MethodNotFound: -32601,
|
|
6
8
|
InvalidParams: -32602,
|
|
7
9
|
Internal: -32603,
|
|
@@ -9,6 +11,12 @@ export const ErrorCode = {
|
|
|
9
11
|
Unavailable: -32002,
|
|
10
12
|
/** Server-defined: an exclusive server is held by another session. */
|
|
11
13
|
Busy: -32003,
|
|
14
|
+
/** Server-defined: a server-to-client request could not be tied to one client session. */
|
|
15
|
+
Ambiguous: -32004,
|
|
16
|
+
/** Same code the SDK uses for a request that ran out of time. */
|
|
17
|
+
RequestTimeout: -32001,
|
|
18
|
+
/** The request was cancelled (by the client, or because the client went away). */
|
|
19
|
+
RequestCancelled: -32800,
|
|
12
20
|
};
|
|
13
21
|
export function toResponse(id, outcome) {
|
|
14
22
|
return "error" in outcome ? { jsonrpc: "2.0", id, error: outcome.error } : { jsonrpc: "2.0", id, result: outcome.result };
|
package/dist/mcpd/launchd.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
1
|
import { join } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const run = promisify(execFile);
|
|
2
|
+
import { ensurePrivateDir, paths } from "../core/paths.js";
|
|
3
|
+
import { ServiceError, runTool, serviceArgs, serviceEnv } from "./service.js";
|
|
7
4
|
export const LABEL = "dev.turno.mcpd";
|
|
8
5
|
export function plistPath(env = process.env) {
|
|
9
6
|
return join(paths(env).home, "Library", "LaunchAgents", `${LABEL}.plist`);
|
|
@@ -11,19 +8,22 @@ export function plistPath(env = process.env) {
|
|
|
11
8
|
function xml(s) {
|
|
12
9
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const envXml = Object.entries(
|
|
11
|
+
function unxml(s) {
|
|
12
|
+
return s.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* LaunchAgent that keeps `turno mcp daemon run` alive. `Interactive` because mcpd answers
|
|
16
|
+
* calls the user is waiting for and starts browsers (a `Background` job gets throttled).
|
|
17
|
+
* KeepAlive only restarts it after a failure: a clean exit (another mcpd already serves) stays down.
|
|
18
|
+
*/
|
|
19
|
+
export function plist(spec) {
|
|
20
|
+
const p = paths(spec.env);
|
|
21
|
+
const envXml = Object.entries(serviceEnv(spec, "launchd"))
|
|
25
22
|
.map(([k, v]) => ` <key>${xml(k)}</key>\n <string>${xml(v)}</string>`)
|
|
26
23
|
.join("\n");
|
|
24
|
+
const args = serviceArgs(spec)
|
|
25
|
+
.map((a) => ` <string>${xml(a)}</string>`)
|
|
26
|
+
.join("\n");
|
|
27
27
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
28
28
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
29
29
|
<plist version="1.0">
|
|
@@ -32,10 +32,7 @@ export function plist(opts) {
|
|
|
32
32
|
<string>${LABEL}</string>
|
|
33
33
|
<key>ProgramArguments</key>
|
|
34
34
|
<array>
|
|
35
|
-
|
|
36
|
-
<string>${xml(opts.script)}</string>
|
|
37
|
-
<string>mcpd</string>
|
|
38
|
-
<string>run</string>
|
|
35
|
+
${args}
|
|
39
36
|
</array>
|
|
40
37
|
<key>EnvironmentVariables</key>
|
|
41
38
|
<dict>
|
|
@@ -44,9 +41,14 @@ ${envXml}
|
|
|
44
41
|
<key>RunAtLoad</key>
|
|
45
42
|
<true/>
|
|
46
43
|
<key>KeepAlive</key>
|
|
47
|
-
<
|
|
44
|
+
<dict>
|
|
45
|
+
<key>SuccessfulExit</key>
|
|
46
|
+
<false/>
|
|
47
|
+
</dict>
|
|
48
|
+
<key>ThrottleInterval</key>
|
|
49
|
+
<integer>10</integer>
|
|
48
50
|
<key>ProcessType</key>
|
|
49
|
-
<string>
|
|
51
|
+
<string>Interactive</string>
|
|
50
52
|
<key>StandardOutPath</key>
|
|
51
53
|
<string>${xml(join(p.logsDir, "mcpd.stdout.log"))}</string>
|
|
52
54
|
<key>StandardErrorPath</key>
|
|
@@ -55,32 +57,47 @@ ${envXml}
|
|
|
55
57
|
</plist>
|
|
56
58
|
`;
|
|
57
59
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export async function install(opts) {
|
|
71
|
-
const file = plistPath(opts.env);
|
|
72
|
-
mkdirSync(join(paths(opts.env).home, "Library", "LaunchAgents"), { recursive: true });
|
|
73
|
-
mkdirSync(paths(opts.env).logsDir, { recursive: true });
|
|
74
|
-
writeFileSync(file, plist(opts));
|
|
75
|
-
if (await isLoaded())
|
|
76
|
-
await run("launchctl", ["bootout", `${domain()}/${LABEL}`], { timeout: 10_000 }).catch(() => { });
|
|
77
|
-
await run("launchctl", ["bootstrap", domain(), file], { timeout: 10_000 });
|
|
78
|
-
return file;
|
|
60
|
+
/** ProgramArguments of a plist written by `plist()` (or an earlier turno). */
|
|
61
|
+
export function plistProgram(text) {
|
|
62
|
+
const m = /<key>ProgramArguments<\/key>\s*<array>([\s\S]*?)<\/array>/.exec(text);
|
|
63
|
+
if (!m)
|
|
64
|
+
return [];
|
|
65
|
+
return [...m[1].matchAll(/<string>([\s\S]*?)<\/string>/g)].map((x) => unxml(x[1]));
|
|
79
66
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
function domain() {
|
|
68
|
+
const uid = process.getuid?.();
|
|
69
|
+
if (uid === undefined)
|
|
70
|
+
throw new ServiceError("cannot tell the user id for launchctl");
|
|
71
|
+
return `gui/${uid}`;
|
|
85
72
|
}
|
|
73
|
+
export const launchd = {
|
|
74
|
+
kind: "launchd",
|
|
75
|
+
noun: "LaunchAgent",
|
|
76
|
+
file: plistPath,
|
|
77
|
+
render: plist,
|
|
78
|
+
programOf: plistProgram,
|
|
79
|
+
async isLoaded(env) {
|
|
80
|
+
try {
|
|
81
|
+
await runTool("launchctl", ["print", `${domain()}/${LABEL}`], env, 5000);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
if (err instanceof ServiceError && /not found on PATH/.test(err.message))
|
|
86
|
+
throw err;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
async load(env) {
|
|
91
|
+
ensurePrivateDir(paths(env).logsDir, env);
|
|
92
|
+
if (await launchd.isLoaded(env))
|
|
93
|
+
await runTool("launchctl", ["bootout", `${domain()}/${LABEL}`], env).catch(() => { });
|
|
94
|
+
await runTool("launchctl", ["bootstrap", domain(), plistPath(env)], env);
|
|
95
|
+
},
|
|
96
|
+
async unload(env) {
|
|
97
|
+
await runTool("launchctl", ["bootout", `${domain()}/${LABEL}`], env);
|
|
98
|
+
},
|
|
99
|
+
async restart(env) {
|
|
100
|
+
await runTool("launchctl", ["kickstart", "-k", `${domain()}/${LABEL}`], env);
|
|
101
|
+
},
|
|
102
|
+
};
|
|
86
103
|
//# sourceMappingURL=launchd.js.map
|