turno-cli 0.2.0 → 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 +148 -0
- package/README.md +127 -39
- package/dist/accounts/audit.js +27 -15
- package/dist/accounts/builtin.js +35 -7
- package/dist/accounts/delegate.js +30 -7
- package/dist/accounts/policy.js +4 -2
- package/dist/accounts/registry.js +3 -1
- package/dist/agents/adapter.js +22 -0
- package/dist/agents/claude.js +54 -3
- package/dist/agents/codex.js +94 -6
- package/dist/agents/copilot.js +19 -2
- package/dist/agents/cursor.js +19 -2
- package/dist/agents/index.js +1 -1
- package/dist/agents/snippets.js +37 -10
- package/dist/cli/args.js +32 -15
- package/dist/cli/commands/accounts.js +29 -7
- package/dist/cli/commands/auto.js +50 -12
- 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 +159 -59
- package/dist/cli/commands/complete.js +13 -3
- package/dist/cli/commands/completion.js +4 -0
- package/dist/cli/commands/config.js +90 -13
- package/dist/cli/commands/demo.js +36 -7
- package/dist/cli/commands/doctor.js +170 -36
- package/dist/cli/commands/identity.js +99 -12
- package/dist/cli/commands/init.js +42 -10
- package/dist/cli/commands/limit.js +65 -9
- package/dist/cli/commands/mcp-call.js +240 -0
- package/dist/cli/commands/mcp-oauth.js +33 -6
- package/dist/cli/commands/mcp-observe.js +128 -23
- package/dist/cli/commands/mcp-share.js +201 -0
- package/dist/cli/commands/mcp.js +203 -42
- package/dist/cli/commands/mcpd.js +76 -12
- package/dist/cli/commands/open.js +26 -3
- package/dist/cli/commands/profile.js +212 -30
- package/dist/cli/commands/resolve.js +8 -1
- package/dist/cli/commands/run.js +24 -4
- package/dist/cli/commands/secret.js +23 -38
- package/dist/cli/commands/session.js +16 -5
- package/dist/cli/commands/sessions.js +7 -1
- package/dist/cli/commands/setup.js +83 -11
- package/dist/cli/commands/status.js +67 -15
- package/dist/cli/commands/statusline.js +7 -2
- package/dist/cli/commands/ui.js +17 -5
- package/dist/cli/commands/undo.js +39 -7
- package/dist/cli/commands/uninstall.js +24 -5
- package/dist/cli/commands/upgrade.js +113 -76
- package/dist/cli/commands/usage.js +11 -10
- package/dist/cli/commands/version.js +20 -8
- package/dist/cli/commands/which.js +5 -3
- package/dist/cli/diagnostics.js +184 -0
- package/dist/cli/exit.js +65 -0
- package/dist/cli/group.js +20 -8
- package/dist/cli/help.js +6 -1
- package/dist/cli/hints.js +30 -0
- package/dist/cli/io.js +24 -8
- package/dist/cli/launch.js +31 -2
- package/dist/cli/launchers.js +25 -10
- package/dist/cli/main.js +52 -18
- package/dist/cli/optional.js +144 -0
- package/dist/cli/output.js +123 -0
- package/dist/cli/picker.js +17 -5
- package/dist/cli/registry.js +20 -2
- package/dist/cli/safe.js +87 -0
- package/dist/cli/secret-input.js +63 -0
- package/dist/cli/security.js +31 -9
- package/dist/cli/style.js +35 -5
- package/dist/cli/topics.js +142 -0
- package/dist/core/config.js +39 -3
- package/dist/core/fsutil.js +2 -10
- package/dist/core/journal.js +19 -11
- package/dist/core/manifest.js +28 -1
- package/dist/core/paths.js +6 -112
- package/dist/core/profiles.js +28 -8
- package/dist/core/resolve.js +13 -3
- package/dist/core/secrets.js +4 -154
- package/dist/core/state-file.js +107 -0
- package/dist/core/update.js +14 -11
- package/dist/core/version.js +57 -10
- package/dist/demo/server.js +10 -2
- package/dist/mcpd/cache.js +6 -7
- package/dist/mcpd/calllog.js +10 -9
- package/dist/mcpd/client-names.js +8 -13
- package/dist/mcpd/connectors.js +42 -3
- package/dist/mcpd/daemon.js +29 -8
- package/dist/mcpd/folder-sets.js +5 -2
- package/dist/mcpd/gateway.js +57 -29
- package/dist/mcpd/health.js +69 -25
- package/dist/mcpd/importer.js +106 -9
- package/dist/mcpd/instances.js +59 -31
- package/dist/mcpd/jsonrpc.js +3 -1
- package/dist/mcpd/middleware.js +144 -0
- package/dist/mcpd/modern.js +57 -19
- package/dist/mcpd/oauth.js +71 -17
- package/dist/mcpd/peerpid.js +15 -3
- package/dist/mcpd/pressure.js +4 -1
- package/dist/mcpd/rss.js +34 -19
- package/dist/mcpd/service.js +28 -4
- package/dist/mcpd/share.js +217 -0
- package/dist/mcpd/state.js +16 -16
- package/dist/mcpd/sync.js +22 -12
- package/dist/mcpd/systemd.js +4 -1
- package/dist/mcpd/tokens.js +4 -8
- package/dist/mcpd/upstream.js +12 -5
- package/dist/statusline/cost.js +17 -4
- package/dist/statusline/input.js +15 -3
- package/dist/ui/fonts.js +1 -1
- package/dist/ui/settings.js +6 -1
- package/npm-shrinkwrap.json +12 -3
- package/package.json +7 -6
|
@@ -12,12 +12,15 @@ import { availableUpdate } from "../../core/update.js";
|
|
|
12
12
|
import { packageInfo } from "../../core/version.js";
|
|
13
13
|
import { FALLBACK, checkFonts, userFontDir } from "../../ui/fonts.js";
|
|
14
14
|
import { currentStatusLine, isTurnoStatusLine, statusLineLabel } from "../../ui/settings.js";
|
|
15
|
-
import { JSON_FLAG, bool, parseFlags
|
|
15
|
+
import { JSON_FLAG, bool, parseFlags } from "../args.js";
|
|
16
|
+
import { emit, jsonOutput } from "../output.js";
|
|
16
17
|
import { fail } from "../io.js";
|
|
17
18
|
import { findOnPath } from "../launch.js";
|
|
18
19
|
import { MARKER, isGenerated, launcherName, launcherText } from "../launchers.js";
|
|
19
20
|
import { duration, padEnd, profileColor, style, visibleWidth } from "../style.js";
|
|
20
21
|
import { nerdHere } from "../../ui/terminal-id.js";
|
|
22
|
+
/** `turno doctor --json`. */
|
|
23
|
+
const DOCTOR_JSON = jsonOutput(["ok", "counts", "ms", "next", "checks"]);
|
|
21
24
|
function statusOf(level) {
|
|
22
25
|
return level === "info" ? "skip" : level;
|
|
23
26
|
}
|
|
@@ -55,7 +58,12 @@ export async function mcpdStatus(env, config) {
|
|
|
55
58
|
token = readFileSync(p.mcpdToken, "utf8").trim();
|
|
56
59
|
}
|
|
57
60
|
catch {
|
|
58
|
-
return {
|
|
61
|
+
return {
|
|
62
|
+
level: "info",
|
|
63
|
+
running: false,
|
|
64
|
+
port,
|
|
65
|
+
text: `mcpd: no token at ${tildify(p.mcpdToken, env)} (not started yet: turno mcp daemon start)`,
|
|
66
|
+
};
|
|
59
67
|
}
|
|
60
68
|
try {
|
|
61
69
|
const res = await fetch(`http://127.0.0.1:${port}/status`, {
|
|
@@ -144,14 +152,19 @@ function lexists(path) {
|
|
|
144
152
|
return false;
|
|
145
153
|
}
|
|
146
154
|
}
|
|
147
|
-
/** Launcher, folder, hub links and agent checks of one profile
|
|
155
|
+
/** Launcher, folder, hub links and agent checks of one profile. */
|
|
148
156
|
function profileChecks(name, agent, env) {
|
|
149
157
|
const a = adapter(agent);
|
|
150
158
|
const area = `profile ${name}`;
|
|
151
159
|
const out = [];
|
|
152
160
|
const launcher = join(paths(env).bin, launcherName(name, agent));
|
|
153
161
|
if (!existsSync(launcher))
|
|
154
|
-
out.push({
|
|
162
|
+
out.push({
|
|
163
|
+
area,
|
|
164
|
+
level: "fail",
|
|
165
|
+
text: `profile ${name}: no launcher ${tildify(launcher, env)}`,
|
|
166
|
+
fix: repair(name),
|
|
167
|
+
});
|
|
155
168
|
else if (!isGenerated(launcher)) {
|
|
156
169
|
out.push({
|
|
157
170
|
area,
|
|
@@ -163,11 +176,17 @@ function profileChecks(name, agent, env) {
|
|
|
163
176
|
else {
|
|
164
177
|
// Classic launchers vary with the turno that wrote them: only a bash claudio one is stale.
|
|
165
178
|
const text = readFileSync(launcher, "utf8");
|
|
166
|
-
const stale = a.classicLauncher
|
|
179
|
+
const stale = a.classicLauncher
|
|
180
|
+
? !text.includes(MARKER) && "launcher from the bash claudio"
|
|
181
|
+
: text !== launcherText(name, env, agent) && "launcher is out of date";
|
|
167
182
|
if (stale)
|
|
168
183
|
out.push({ area, level: "warn", text: `profile ${name}: ${stale}`, fix: repair(name) });
|
|
169
184
|
else
|
|
170
|
-
out.push({
|
|
185
|
+
out.push({
|
|
186
|
+
area,
|
|
187
|
+
level: "ok",
|
|
188
|
+
text: `profile ${name}: ${agent === DEFAULT_AGENT ? "" : `${a.label} `}launcher ok`,
|
|
189
|
+
});
|
|
171
190
|
}
|
|
172
191
|
const dir = agentProfileDir(name, agent, env);
|
|
173
192
|
if (!existsSync(dir)) {
|
|
@@ -182,7 +201,12 @@ function profileChecks(name, agent, env) {
|
|
|
182
201
|
if (isLinkTo(path, target))
|
|
183
202
|
continue;
|
|
184
203
|
if (existsSync(path))
|
|
185
|
-
out.push({
|
|
204
|
+
out.push({
|
|
205
|
+
area,
|
|
206
|
+
level: "warn",
|
|
207
|
+
text: `profile ${name}: ${item} is a local copy, not shared`,
|
|
208
|
+
fix: repair(name),
|
|
209
|
+
});
|
|
186
210
|
else if (existsSync(target))
|
|
187
211
|
out.push({ area, level: "warn", text: `profile ${name}: missing link for ${item}`, fix: repair(name) });
|
|
188
212
|
}
|
|
@@ -200,7 +224,11 @@ function profileChecks(name, agent, env) {
|
|
|
200
224
|
for (const item of entries) {
|
|
201
225
|
if (known.has(item) || !lexists(join(dir, item)) || a.perAccount.ignore.test(item))
|
|
202
226
|
continue;
|
|
203
|
-
out.push({
|
|
227
|
+
out.push({
|
|
228
|
+
area,
|
|
229
|
+
level: "info",
|
|
230
|
+
text: `profile ${name}: ${item} is new and unclassified: decide whether to share it`,
|
|
231
|
+
});
|
|
204
232
|
}
|
|
205
233
|
}
|
|
206
234
|
return out;
|
|
@@ -213,7 +241,9 @@ export async function collectChecks(env) {
|
|
|
213
241
|
if (major >= 20)
|
|
214
242
|
add("system", "ok", `node ${process.versions.node}`);
|
|
215
243
|
else
|
|
216
|
-
add("system", "fail", `node ${process.versions.node}, and turno needs 20 or newer`, {
|
|
244
|
+
add("system", "fail", `node ${process.versions.node}, and turno needs 20 or newer`, {
|
|
245
|
+
manual: "install Node.js 20 or newer (https://nodejs.org)",
|
|
246
|
+
});
|
|
217
247
|
// Every agent is listed; only one that a profile uses can fail.
|
|
218
248
|
let early;
|
|
219
249
|
try {
|
|
@@ -246,19 +276,25 @@ export async function collectChecks(env) {
|
|
|
246
276
|
const { secretStoreLabel } = await import("../security.js");
|
|
247
277
|
const store = secretStoreLabel(env);
|
|
248
278
|
if (store === "none")
|
|
249
|
-
add("system", "info", "secret store: none (keychain: references cannot resolve; env: ones work)", {
|
|
279
|
+
add("system", "info", "secret store: none (keychain: references cannot resolve; env: ones work)", {
|
|
280
|
+
manual: "install secret-tool (libsecret) to use keychain: references",
|
|
281
|
+
});
|
|
250
282
|
else
|
|
251
283
|
add("system", "ok", `secret store: ${store}`);
|
|
252
284
|
const chrome = env.TURNO_CHROME_APP || "/Applications/Google Chrome.app";
|
|
253
285
|
if (existsSync(chrome))
|
|
254
286
|
add("system", "ok", "Google Chrome installed");
|
|
255
287
|
else
|
|
256
|
-
add("system", "warn", "Google Chrome not found: claude.ai links open in the default browser", {
|
|
288
|
+
add("system", "warn", "Google Chrome not found: claude.ai links open in the default browser", {
|
|
289
|
+
manual: "install Google Chrome, or set TURNO_CHROME_APP to where it is",
|
|
290
|
+
});
|
|
257
291
|
const { recordedVersion, finishUpgrade } = await import("./upgrade.js");
|
|
258
292
|
const version = packageInfo().version;
|
|
259
293
|
const recorded = recordedVersion(env);
|
|
260
294
|
if (recorded && recorded !== version) {
|
|
261
|
-
add("turno", "warn", `turno ${version} runs, but ${recorded} set up the launchers`, {
|
|
295
|
+
add("turno", "warn", `turno ${version} runs, but ${recorded} set up the launchers`, {
|
|
296
|
+
fix: { label: "turno upgrade --finish", run: (io) => finishUpgrade(io, { sync: "no" }) },
|
|
297
|
+
});
|
|
262
298
|
}
|
|
263
299
|
else
|
|
264
300
|
add("turno", "ok", `turno ${version}`);
|
|
@@ -272,7 +308,9 @@ export async function collectChecks(env) {
|
|
|
272
308
|
if (existsSync(p.configFile))
|
|
273
309
|
add("config", "ok", `${tildify(p.configFile, env)} parses`);
|
|
274
310
|
else if (migrationPending(env))
|
|
275
|
-
add("config", "info", `no ${tildify(p.configFile, env)} yet, but a bash claudio config is there`, {
|
|
311
|
+
add("config", "info", `no ${tildify(p.configFile, env)} yet, but a bash claudio config is there`, {
|
|
312
|
+
hint: "turno migrate",
|
|
313
|
+
});
|
|
276
314
|
else
|
|
277
315
|
add("config", "info", `no ${tildify(p.configFile, env)} (defaults)`);
|
|
278
316
|
for (const f of configFindings(config, env))
|
|
@@ -291,14 +329,19 @@ export async function collectChecks(env) {
|
|
|
291
329
|
add("config", "info", `no ${tildify(p.mcpFile, env)} yet`, { hint: "turno mcp import" });
|
|
292
330
|
}
|
|
293
331
|
catch (err) {
|
|
294
|
-
add("config", "fail", err.message, {
|
|
332
|
+
add("config", "fail", err.message, {
|
|
333
|
+
manual: `correct ${tildify(p.mcpFile, env)} where the error points`,
|
|
334
|
+
});
|
|
295
335
|
}
|
|
296
336
|
if (existsSync(p.accountsFile)) {
|
|
297
337
|
try {
|
|
298
338
|
const reg = loadRegistry(env);
|
|
299
339
|
add("config", "ok", `${tildify(p.accountsFile, env)} parses`);
|
|
300
|
-
// Without read_tools a delegated read is a write
|
|
301
|
-
const noReads = Object.values(reg.accounts)
|
|
340
|
+
// Without read_tools a delegated read is a write: confirmed, with every tool.
|
|
341
|
+
const noReads = Object.values(reg.accounts)
|
|
342
|
+
.filter((a) => !a.readTools?.length)
|
|
343
|
+
.map((a) => a.id)
|
|
344
|
+
.sort();
|
|
302
345
|
if (noReads.length) {
|
|
303
346
|
add("config", "warn", `accounts without read_tools: ${noReads.join(", ")}; delegated reads get every tool of the account and ask like writes`, {
|
|
304
347
|
manual: `add read_tools to each of them in ${tildify(p.accountsFile, env)}`,
|
|
@@ -306,7 +349,9 @@ export async function collectChecks(env) {
|
|
|
306
349
|
}
|
|
307
350
|
}
|
|
308
351
|
catch (err) {
|
|
309
|
-
add("config", "fail", err.message, {
|
|
352
|
+
add("config", "fail", err.message, {
|
|
353
|
+
manual: `correct ${tildify(p.accountsFile, env)} where the error points`,
|
|
354
|
+
});
|
|
310
355
|
}
|
|
311
356
|
}
|
|
312
357
|
if (config) {
|
|
@@ -326,14 +371,16 @@ export async function collectChecks(env) {
|
|
|
326
371
|
for (const s of b.plugins)
|
|
327
372
|
add("mcp", "info", `plugin server ${s.plugin}/${s.name} starts in every session`, { hint: "turno mcp doctor" });
|
|
328
373
|
// turno mcp sync replaces a hub entry with the gateway's when mcp.toml serves it to the profile the hub belongs to.
|
|
329
|
-
const hubProfile = config?.system
|
|
374
|
+
const hubProfile = config?.system || "default";
|
|
330
375
|
for (const d of b.direct) {
|
|
331
376
|
const def = manifest?.servers[d.name];
|
|
332
377
|
const how = !d.inManifest
|
|
333
378
|
? { hint: "turno mcp import" }
|
|
334
379
|
: def && servesProfile(def, hubProfile)
|
|
335
380
|
? { fix: syncFix }
|
|
336
|
-
: {
|
|
381
|
+
: {
|
|
382
|
+
manual: `remove ${d.name} from ${tildify(p.hubConfig, env)}, or serve it to profile ${hubProfile} in mcp.toml`,
|
|
383
|
+
};
|
|
337
384
|
add("mcp", "warn", `${d.name} runs outside mcpd`, how);
|
|
338
385
|
}
|
|
339
386
|
const { describeLogin, oauthLogins } = await import("./mcp-oauth.js");
|
|
@@ -343,7 +390,11 @@ export async function collectChecks(env) {
|
|
|
343
390
|
const said = describeLogin(l);
|
|
344
391
|
// describeLogin ends with the login command; the fix line shows it instead.
|
|
345
392
|
const text = said.endsWith(`: ${login}`) ? said.slice(0, -login.length - 2) : said;
|
|
346
|
-
const how = ok
|
|
393
|
+
const how = ok
|
|
394
|
+
? {}
|
|
395
|
+
: said !== text
|
|
396
|
+
? { hint: login }
|
|
397
|
+
: { manual: "install a secret store (macOS Keychain or secret-tool) so turno can read the login" };
|
|
347
398
|
add("mcp", ok ? "ok" : "warn", `${l.server}${l.variant === "default" ? "" : `@${l.variant}`} OAuth: ${text}`, how);
|
|
348
399
|
}
|
|
349
400
|
}
|
|
@@ -357,7 +408,9 @@ export async function collectChecks(env) {
|
|
|
357
408
|
if (isTurnoStatusLine(line))
|
|
358
409
|
add("look", "ok", "status line: turno statusline");
|
|
359
410
|
else
|
|
360
|
-
add("look", "info", `status line: ${statusLineLabel(line, env)} in ${tildify(settings, env)}`, {
|
|
411
|
+
add("look", "info", `status line: ${statusLineLabel(line, env)} in ${tildify(settings, env)}`, {
|
|
412
|
+
hint: "turno ui install",
|
|
413
|
+
});
|
|
361
414
|
const fontDir = userFontDir(env);
|
|
362
415
|
if (fontDir) {
|
|
363
416
|
const fonts = checkFonts(FALLBACK, fontDir);
|
|
@@ -365,24 +418,26 @@ export async function collectChecks(env) {
|
|
|
365
418
|
if (have === fonts.length)
|
|
366
419
|
add("look", "ok", `font: ${FALLBACK.family} installed`);
|
|
367
420
|
else
|
|
368
|
-
add("look", "info", `font: ${FALLBACK.family} ${have}/${fonts.length} files in ${tildify(fontDir, env)}`, {
|
|
421
|
+
add("look", "info", `font: ${FALLBACK.family} ${have}/${fonts.length} files in ${tildify(fontDir, env)}`, {
|
|
422
|
+
hint: "turno ui install",
|
|
423
|
+
});
|
|
369
424
|
}
|
|
370
425
|
checks.push(...(await mcpdSection(env)));
|
|
371
426
|
return checks;
|
|
372
427
|
}
|
|
373
|
-
// ---- mcpd section
|
|
428
|
+
// ---- mcpd section: service file, token mode, port owner, start errors, synced ports.
|
|
374
429
|
// The checks live in mcpd/health.ts; keep this section separate from the rest of doctor.
|
|
375
430
|
async function mcpdSection(env) {
|
|
376
431
|
const { mcpdChecks } = await import("../../mcpd/health.js");
|
|
377
432
|
return (await mcpdChecks(env)).map((c) => ({ area: "mcpd", ...c }));
|
|
378
433
|
}
|
|
379
434
|
// ---- end of the mcpd section
|
|
380
|
-
// ---- security section
|
|
435
|
+
// ---- security section: `turno doctor --security` runs only these checks.
|
|
381
436
|
async function securitySection(env) {
|
|
382
437
|
return (await import("../security.js")).securityChecks(env);
|
|
383
438
|
}
|
|
384
439
|
// ---- end of the security section
|
|
385
|
-
/** Screen sections in order, and the check areas each one holds
|
|
440
|
+
/** Screen sections in order, and the check areas each one holds. */
|
|
386
441
|
const SECTIONS = [
|
|
387
442
|
["System", (a) => a === "system" || a === "turno"],
|
|
388
443
|
["Config", (a) => a === "config"],
|
|
@@ -497,16 +552,57 @@ function renderDoctor(checks, io, opts) {
|
|
|
497
552
|
const repairable = problems.filter((c) => c.fix).length;
|
|
498
553
|
if (repairable && !opts.fixed) {
|
|
499
554
|
const label = s.lead("next", s.bold(s.accent("Next")));
|
|
500
|
-
const what = repairable === problems.length
|
|
555
|
+
const what = repairable === problems.length
|
|
556
|
+
? `repairs ${repairable === 1 ? "it" : `all ${repairable}`}`
|
|
557
|
+
: `repairs ${repairable} of ${problems.length}; the others name their fix above`;
|
|
501
558
|
out.push(s.wrap(`${label} `, `${s.bold(fixFlag)} ${s.muted(what)}`));
|
|
502
559
|
}
|
|
503
560
|
return out;
|
|
504
561
|
}
|
|
562
|
+
/**
|
|
563
|
+
* `--report`: a Markdown block for an issue (versions, OS, agents, paths, mcpd, the findings),
|
|
564
|
+
* with no tokens or secret values. Exits like doctor does.
|
|
565
|
+
*/
|
|
566
|
+
async function report(io, checks, security) {
|
|
567
|
+
let config;
|
|
568
|
+
try {
|
|
569
|
+
config = loadConfig(io.env);
|
|
570
|
+
}
|
|
571
|
+
catch {
|
|
572
|
+
config = undefined;
|
|
573
|
+
}
|
|
574
|
+
const mcpd = await mcpdStatus(io.env, config);
|
|
575
|
+
let status;
|
|
576
|
+
if (mcpd.running) {
|
|
577
|
+
const { mcpdRequest } = await import("./mcp.js");
|
|
578
|
+
const r = await mcpdRequest(io.env, "GET", "/status");
|
|
579
|
+
if (r !== "down" && r.status === 200 && typeof r.body === "object" && r.body !== null)
|
|
580
|
+
status = r.body;
|
|
581
|
+
}
|
|
582
|
+
const { reportMarkdown } = await import("../diagnostics.js");
|
|
583
|
+
const lines = await reportMarkdown(io.env, {
|
|
584
|
+
counts: countChecks(checks),
|
|
585
|
+
checks: checks.map((c) => ({
|
|
586
|
+
status: statusOf(c.level),
|
|
587
|
+
area: c.area,
|
|
588
|
+
text: c.text,
|
|
589
|
+
...(fixCommand(c) ? { fix: fixCommand(c) } : {}),
|
|
590
|
+
})),
|
|
591
|
+
mcpd,
|
|
592
|
+
...(status ? { status } : {}),
|
|
593
|
+
security,
|
|
594
|
+
});
|
|
595
|
+
for (const l of lines)
|
|
596
|
+
io.out(l);
|
|
597
|
+
return checks.some((c) => c.level === "fail") ? 1 : 0;
|
|
598
|
+
}
|
|
505
599
|
export async function doctor(io, opts = {}) {
|
|
506
600
|
const start = Date.now();
|
|
507
601
|
const collect = opts.security ? securitySection : collectChecks;
|
|
508
602
|
const quiet = opts.json || opts.summary;
|
|
509
603
|
let checks = await collect(io.env);
|
|
604
|
+
if (opts.report)
|
|
605
|
+
return report(io, checks, Boolean(opts.security));
|
|
510
606
|
if (opts.fix) {
|
|
511
607
|
const fixes = new Map();
|
|
512
608
|
for (const c of checks)
|
|
@@ -529,7 +625,7 @@ export async function doctor(io, opts = {}) {
|
|
|
529
625
|
const failed = checks.some((c) => c.level === "fail");
|
|
530
626
|
const ms = Date.now() - start;
|
|
531
627
|
if (opts.json) {
|
|
532
|
-
|
|
628
|
+
emit(io, opts.parsed, DOCTOR_JSON, {
|
|
533
629
|
ok: !failed,
|
|
534
630
|
counts: countChecks(checks),
|
|
535
631
|
ms,
|
|
@@ -537,7 +633,13 @@ export async function doctor(io, opts = {}) {
|
|
|
537
633
|
checks: checks.map(({ fix, hint, manual, ...c }) => {
|
|
538
634
|
const status = statusOf(c.level);
|
|
539
635
|
const command = status === "ok" ? undefined : (fix?.label ?? hint);
|
|
540
|
-
return {
|
|
636
|
+
return {
|
|
637
|
+
...c,
|
|
638
|
+
status,
|
|
639
|
+
fix: command ?? null,
|
|
640
|
+
auto: Boolean(fix) && status !== "ok" && status !== "skip",
|
|
641
|
+
manual: status === "ok" ? null : (manual ?? null),
|
|
642
|
+
};
|
|
541
643
|
}),
|
|
542
644
|
});
|
|
543
645
|
return failed ? 1 : 0;
|
|
@@ -555,7 +657,10 @@ export async function doctor(io, opts = {}) {
|
|
|
555
657
|
function lookOf(env) {
|
|
556
658
|
try {
|
|
557
659
|
const config = loadConfig(env);
|
|
558
|
-
return {
|
|
660
|
+
return {
|
|
661
|
+
nerd: config.icons === "nerd" || (config.icons === "auto" && nerdHere(env, config.nerdTerminals)),
|
|
662
|
+
colors: config.profiles,
|
|
663
|
+
};
|
|
559
664
|
}
|
|
560
665
|
catch {
|
|
561
666
|
return { nerd: false };
|
|
@@ -564,29 +669,58 @@ function lookOf(env) {
|
|
|
564
669
|
export const command = {
|
|
565
670
|
summary: "check everything (system, config, profiles, MCP, look, mcpd) and fix what is safe to fix",
|
|
566
671
|
usage: [
|
|
567
|
-
"Usage: turno doctor [--security] [--fix] [--json | --summary]",
|
|
672
|
+
"Usage: turno doctor [--security] [--fix] [--json | --summary | --report]",
|
|
568
673
|
"",
|
|
569
674
|
"One row per check, in sections. Under each problem: the command that fixes it",
|
|
570
675
|
"(fix: ...) or the manual step. Exits 1 when a check fails; warnings exit 0.",
|
|
571
676
|
"",
|
|
572
|
-
|
|
677
|
+
'--fix runs every repair marked "turno doctor --fix runs it" (relink a profile,',
|
|
573
678
|
"rewrite launchers, finish an upgrade, start mcpd, sync configs), then checks",
|
|
574
679
|
"again. --summary prints one line, the counts and the first fix, for hooks and",
|
|
575
680
|
"status lines. --json gives each check a status (ok, warn, fail or skip), fix (a",
|
|
576
681
|
"command or null), auto (whether --fix runs it) and manual, plus counts, ms and",
|
|
577
682
|
"next (the fix commands, failures first).",
|
|
578
683
|
"",
|
|
684
|
+
"--report prints a Markdown block to paste in an issue: turno, Node and OS",
|
|
685
|
+
"versions, each agent and its version, mcpd's state, the warnings and failures,",
|
|
686
|
+
"and every path turno uses. It holds no tokens or secret values; profile and",
|
|
687
|
+
"server names appear.",
|
|
688
|
+
"",
|
|
579
689
|
"--security runs the security checks instead: who can read turno's folders, who",
|
|
580
690
|
"holds the mcpd port, literal secrets in mcp.toml, agent configs and backups, MCP",
|
|
581
691
|
"servers without an exact version, the age of the mcpd token and the audit log's",
|
|
582
692
|
"hash chain. With --fix it narrows file modes under turno's folders.",
|
|
693
|
+
"",
|
|
694
|
+
"Examples:",
|
|
695
|
+
" $ turno doctor",
|
|
696
|
+
" $ turno doctor --fix",
|
|
697
|
+
" $ turno doctor --summary",
|
|
698
|
+
" $ turno doctor --security --json",
|
|
699
|
+
" $ turno doctor --report | pbcopy # paste it in an issue",
|
|
583
700
|
].join("\n"),
|
|
584
|
-
flags: ["--security", "--fix", "--json", "--summary"],
|
|
701
|
+
flags: ["--security", "--fix", "--json", "--summary", "--report"],
|
|
702
|
+
json: DOCTOR_JSON,
|
|
585
703
|
async run(args, io) {
|
|
586
|
-
const p = parseFlags(args, {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
704
|
+
const p = parseFlags(args, {
|
|
705
|
+
security: { type: "boolean" },
|
|
706
|
+
fix: { type: "boolean" },
|
|
707
|
+
summary: { type: "boolean" },
|
|
708
|
+
report: { type: "boolean" },
|
|
709
|
+
...JSON_FLAG,
|
|
710
|
+
}, 0);
|
|
711
|
+
const modes = ["json", "summary", "report"].filter((m) => bool(p, m));
|
|
712
|
+
if (modes.length > 1)
|
|
713
|
+
return fail(`${modes.map((m) => `--${m}`).join(" and ")} do not go together`);
|
|
714
|
+
if (bool(p, "report") && bool(p, "fix"))
|
|
715
|
+
return fail("--report only reads; run turno doctor --fix first, then --report");
|
|
716
|
+
return doctor(io, {
|
|
717
|
+
fix: bool(p, "fix"),
|
|
718
|
+
json: bool(p, "json"),
|
|
719
|
+
security: bool(p, "security"),
|
|
720
|
+
summary: bool(p, "summary"),
|
|
721
|
+
report: bool(p, "report"),
|
|
722
|
+
parsed: p,
|
|
723
|
+
});
|
|
590
724
|
},
|
|
591
725
|
};
|
|
592
726
|
//# sourceMappingURL=doctor.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { effectivePolicy } from "../../accounts/policy.js";
|
|
2
2
|
import { loadRegistry } from "../../accounts/registry.js";
|
|
3
3
|
import { tildify } from "../../core/paths.js";
|
|
4
|
-
import { DRY_RUN, JSON_FLAG, bool, flagsOf, parseFlags,
|
|
4
|
+
import { DRY_RUN, JSON_FLAG, bool, flagsOf, parseFlags, str } from "../args.js";
|
|
5
|
+
import { emit, jsonOutput } from "../output.js";
|
|
5
6
|
import { group } from "../group.js";
|
|
6
7
|
import { launcherExists } from "../../accounts/delegate.js";
|
|
7
8
|
import { loadConfig } from "../../core/config.js";
|
|
@@ -10,6 +11,7 @@ import { profileColor, style } from "../style.js";
|
|
|
10
11
|
import * as accounts from "./accounts.js";
|
|
11
12
|
import { policyLine } from "./accounts.js";
|
|
12
13
|
import { NOT_INSTALLED, defaultDeps, dispatch } from "./browser.js";
|
|
14
|
+
import { SETTINGS_FLAGS, SETTINGS_FLAG_NAMES, SET_DETAILS, SET_FLAG_NAMES, SET_JSON, SET_SYNOPSIS, SHOW_JSON, } from "./browser-identity.js";
|
|
13
15
|
/**
|
|
14
16
|
* Who acts on an outside service for a session: a service account (`linear:work`, run by a
|
|
15
17
|
* profile through the accounts bridge) or a browser identity (`browser:school`, a Chrome
|
|
@@ -29,13 +31,15 @@ async function browserModule(io) {
|
|
|
29
31
|
function firstId(args) {
|
|
30
32
|
return args.find((a) => !a.startsWith("-"));
|
|
31
33
|
}
|
|
34
|
+
/** `turno identity list --json`. */
|
|
35
|
+
const LIST_JSON = jsonOutput(["services", "browser", "preferences"]);
|
|
32
36
|
async function list(args, io) {
|
|
33
37
|
const p = parseFlags(args, JSON_FLAG, 0);
|
|
34
38
|
const reg = loadRegistry(io.env);
|
|
35
39
|
const mod = await deps.load(io);
|
|
36
40
|
const browsers = mod ? mod.listIdentities(io.env) : [];
|
|
37
41
|
if (bool(p, "json")) {
|
|
38
|
-
|
|
42
|
+
emit(io, p, LIST_JSON, {
|
|
39
43
|
services: Object.values(reg.accounts)
|
|
40
44
|
.sort((a, b) => a.id.localeCompare(b.id))
|
|
41
45
|
.map((a) => ({
|
|
@@ -83,7 +87,12 @@ async function list(args, io) {
|
|
|
83
87
|
if (reg.prefer.length) {
|
|
84
88
|
io.out("");
|
|
85
89
|
io.out(st.header("Folder preferences"));
|
|
86
|
-
for (const l of st.table(reg.prefer.map((r) => [
|
|
90
|
+
for (const l of st.table(reg.prefer.map((r) => [
|
|
91
|
+
tildify(r.path, io.env),
|
|
92
|
+
Object.entries(r.accounts)
|
|
93
|
+
.map(([sv, id]) => `${sv}=${id}`)
|
|
94
|
+
.join(" ") || st.muted("(none)"),
|
|
95
|
+
])))
|
|
87
96
|
io.out(l);
|
|
88
97
|
}
|
|
89
98
|
io.out("");
|
|
@@ -93,22 +102,38 @@ async function list(args, io) {
|
|
|
93
102
|
else if (!browsers.length)
|
|
94
103
|
io.out(` none yet ${st.muted("(turno identity add browser:<id>)")}`);
|
|
95
104
|
else {
|
|
96
|
-
const rows = browsers.map((b) => [
|
|
105
|
+
const rows = browsers.map((b) => [
|
|
106
|
+
st.bold(`${BROWSER}${b.id}`),
|
|
107
|
+
b.inUse ? st.lead("on", st.warn("in use")) : st.lead("off", st.ok("free")),
|
|
108
|
+
st.muted(tildify(b.dir, io.env)),
|
|
109
|
+
]);
|
|
97
110
|
for (const l of st.table(rows))
|
|
98
111
|
io.out(l);
|
|
99
112
|
}
|
|
100
113
|
return 0;
|
|
101
114
|
}
|
|
115
|
+
/** `args` with its `browser:<id>` positional replaced by the bare id, for the browser command. */
|
|
116
|
+
function bareId(args) {
|
|
117
|
+
const at = args.findIndex((a) => !a.startsWith("-"));
|
|
118
|
+
return args.map((a, i) => (i === at ? a.slice(BROWSER.length) : a));
|
|
119
|
+
}
|
|
102
120
|
async function add(args, io) {
|
|
103
121
|
if (!firstId(args)?.startsWith(BROWSER))
|
|
104
122
|
return accounts.add(args, io);
|
|
105
|
-
const p = parseFlags(args, DRY_RUN, 1);
|
|
123
|
+
const p = parseFlags(args, { ...DRY_RUN, ...SETTINGS_FLAGS }, 1);
|
|
106
124
|
const id = p.positionals[0].slice(BROWSER.length);
|
|
107
125
|
if (bool(p, "dry-run")) {
|
|
108
126
|
io.out(`(dry run) would create browser identity "${id}"`);
|
|
109
127
|
return 0;
|
|
110
128
|
}
|
|
111
|
-
return dispatch(await browserModule(io), "add",
|
|
129
|
+
return dispatch(await browserModule(io), "add", bareId(args), io, deps);
|
|
130
|
+
}
|
|
131
|
+
/** `show` and `set` exist for browser identities only. */
|
|
132
|
+
async function browserOnly(sub, args, io) {
|
|
133
|
+
const id = firstId(args);
|
|
134
|
+
if (!id?.startsWith(BROWSER))
|
|
135
|
+
return fail(`identity ${sub} works on browser identities (browser:<id>); service accounts are listed by \`turno identity list\``);
|
|
136
|
+
return dispatch(await browserModule(io), sub, bareId(args), io, deps);
|
|
112
137
|
}
|
|
113
138
|
async function remove(args, io) {
|
|
114
139
|
if (!firstId(args)?.startsWith(BROWSER))
|
|
@@ -138,16 +163,60 @@ export function setBrowserDeps(next) {
|
|
|
138
163
|
return prev;
|
|
139
164
|
}
|
|
140
165
|
export const command = group("identity", "who acts on outside services: service accounts (linear:work) and browser identities (browser:school)", {
|
|
141
|
-
list: {
|
|
166
|
+
list: {
|
|
167
|
+
summary: "service accounts, browser identities and folder preferences",
|
|
168
|
+
synopsis: "[--json]",
|
|
169
|
+
flags: ["--json"],
|
|
170
|
+
json: LIST_JSON,
|
|
171
|
+
run: list,
|
|
172
|
+
},
|
|
142
173
|
add: {
|
|
143
174
|
summary: "add a service account, or create a browser identity (browser:<id>)",
|
|
144
|
-
synopsis: "<service:label> --profile <p> --tools <pattern>[,...] [--read-tools <pattern>[,...]] [--confirm always|writes|never] | browser:<id> [--dry-run]",
|
|
175
|
+
synopsis: "<service:label> --profile <p> --tools <pattern>[,...] [--read-tools <pattern>[,...]] [--confirm always|writes|never] | browser:<id> [--timezone <zone>] [--languages <tag,...>] [--health-url <url> --health-text <text>] [--dry-run]",
|
|
145
176
|
args: ["any"],
|
|
146
|
-
flags: [
|
|
177
|
+
flags: [
|
|
178
|
+
"--profile",
|
|
179
|
+
"--tools",
|
|
180
|
+
"--read-tools",
|
|
181
|
+
"--confirm",
|
|
182
|
+
"--service",
|
|
183
|
+
"--description",
|
|
184
|
+
"--dry-run",
|
|
185
|
+
...SETTINGS_FLAG_NAMES,
|
|
186
|
+
],
|
|
147
187
|
run: add,
|
|
148
188
|
},
|
|
149
|
-
|
|
150
|
-
|
|
189
|
+
show: {
|
|
190
|
+
summary: "a browser identity's settings, session health and who holds it",
|
|
191
|
+
synopsis: "browser:<id> [--json]",
|
|
192
|
+
args: ["identity"],
|
|
193
|
+
flags: ["--json"],
|
|
194
|
+
json: SHOW_JSON,
|
|
195
|
+
run: (a, io) => browserOnly("show", a, io),
|
|
196
|
+
},
|
|
197
|
+
set: {
|
|
198
|
+
summary: "change a browser identity's identity.json: place, languages, health check, tabs, blocking, cache",
|
|
199
|
+
synopsis: `browser:<id> ${SET_SYNOPSIS}`,
|
|
200
|
+
details: SET_DETAILS,
|
|
201
|
+
args: ["identity"],
|
|
202
|
+
flags: SET_FLAG_NAMES,
|
|
203
|
+
json: SET_JSON,
|
|
204
|
+
run: (a, io) => browserOnly("set", a, io),
|
|
205
|
+
},
|
|
206
|
+
remove: {
|
|
207
|
+
summary: "remove a service account, or delete a browser identity and its logins",
|
|
208
|
+
synopsis: "<id> [--dry-run]",
|
|
209
|
+
args: ["identity"],
|
|
210
|
+
flags: ["--dry-run"],
|
|
211
|
+
run: remove,
|
|
212
|
+
},
|
|
213
|
+
login: {
|
|
214
|
+
summary: "open a browser identity's Chrome to sign in by hand once",
|
|
215
|
+
synopsis: "browser:<id> [--url <url>]",
|
|
216
|
+
args: ["identity"],
|
|
217
|
+
flags: ["--url"],
|
|
218
|
+
run: login,
|
|
219
|
+
},
|
|
151
220
|
prefer: {
|
|
152
221
|
summary: "pick the account of a service for a folder (empty account removes it)",
|
|
153
222
|
synopsis: "<dir> <service>=<account> [--dry-run]",
|
|
@@ -159,7 +228,25 @@ export const command = group("identity", "who acts on outside services: service
|
|
|
159
228
|
summary: "recent calls to the accounts bridge; --verify checks the log's hash chain",
|
|
160
229
|
synopsis: "[-n N] [--verify] [--json]",
|
|
161
230
|
flags: flagsOf(accounts.LOG_SPEC),
|
|
231
|
+
json: accounts.LOG_JSON,
|
|
162
232
|
run: async (a, io) => accounts.log(a, io),
|
|
163
233
|
},
|
|
164
|
-
}, {
|
|
234
|
+
}, {
|
|
235
|
+
fallback: "list",
|
|
236
|
+
examples: [
|
|
237
|
+
"turno identity list",
|
|
238
|
+
"turno identity add linear:work --profile work --tools 'mcp__linear__*'",
|
|
239
|
+
"turno identity add browser:school",
|
|
240
|
+
"turno identity login browser:school",
|
|
241
|
+
"turno identity show browser:school",
|
|
242
|
+
"turno identity set browser:school --timezone Europe/Madrid --languages es-ES,es,en",
|
|
243
|
+
"turno identity set browser:school --tabs-max 5 --tabs-park 10m --background-throttling true",
|
|
244
|
+
"turno identity set browser:school --block-trackers true --block-types image,font --cache-max-size 200MB",
|
|
245
|
+
"turno identity set browser:school --settle 500ms --dry-run --json",
|
|
246
|
+
"turno identity set browser:school --no-block --no-cache",
|
|
247
|
+
"turno identity prefer ~/code/acme linear=linear:work",
|
|
248
|
+
"turno identity remove linear:work --dry-run",
|
|
249
|
+
"turno identity log --verify",
|
|
250
|
+
],
|
|
251
|
+
});
|
|
165
252
|
//# sourceMappingURL=identity.js.map
|