turno-browser 0.4.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 (70) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +92 -149
  3. package/dist/act-model.js +4 -3
  4. package/dist/act.js +2 -1
  5. package/dist/api.d.ts +63 -2
  6. package/dist/api.js +14 -4
  7. package/dist/background-state.d.ts +54 -0
  8. package/dist/background-state.js +97 -0
  9. package/dist/background.d.ts +69 -0
  10. package/dist/background.js +458 -0
  11. package/dist/bin/mcp.js +48 -8
  12. package/dist/captcha.js +3 -2
  13. package/dist/cli/background.d.ts +11 -0
  14. package/dist/cli/background.js +132 -0
  15. package/dist/cli/commands.d.ts +16 -0
  16. package/dist/cli/commands.js +515 -0
  17. package/dist/cli/context.d.ts +75 -0
  18. package/dist/cli/context.js +44 -0
  19. package/dist/cli/do-background.d.ts +27 -0
  20. package/dist/cli/do-background.js +212 -0
  21. package/dist/cli/do.d.ts +85 -0
  22. package/dist/cli/do.js +558 -0
  23. package/dist/cli/flows.d.ts +28 -0
  24. package/dist/cli/flows.js +303 -0
  25. package/dist/cli/identity.d.ts +37 -0
  26. package/dist/cli/identity.js +906 -0
  27. package/dist/cli/live.d.ts +7 -0
  28. package/dist/cli/live.js +99 -0
  29. package/dist/cli/main.d.ts +16 -0
  30. package/dist/cli/main.js +171 -0
  31. package/dist/cli/secret.d.ts +4 -0
  32. package/dist/cli/secret.js +151 -0
  33. package/dist/cli/session.d.ts +6 -0
  34. package/dist/cli/session.js +106 -0
  35. package/dist/cli/setup.d.ts +7 -0
  36. package/dist/cli/setup.js +180 -0
  37. package/dist/cli/vault.d.ts +5 -0
  38. package/dist/cli/vault.js +192 -0
  39. package/dist/client.d.ts +82 -0
  40. package/dist/client.js +303 -0
  41. package/dist/doctor.js +34 -1
  42. package/dist/engine-camoufox.js +5 -4
  43. package/dist/engine-lightpanda.js +3 -2
  44. package/dist/engine.js +2 -1
  45. package/dist/health.js +2 -1
  46. package/dist/host.d.ts +21 -0
  47. package/dist/host.js +75 -15
  48. package/dist/human-input.js +7 -2
  49. package/dist/identities.js +2 -1
  50. package/dist/index.d.ts +5 -1
  51. package/dist/index.js +2 -0
  52. package/dist/lifecycle.d.ts +2 -0
  53. package/dist/lifecycle.js +2 -1
  54. package/dist/live-client.js +8 -6
  55. package/dist/live-page.d.ts +0 -7
  56. package/dist/live-page.js +3 -2
  57. package/dist/live-server.js +6 -3
  58. package/dist/live.js +2 -1
  59. package/dist/login-tool.js +3 -2
  60. package/dist/login.js +2 -1
  61. package/dist/names.d.ts +28 -0
  62. package/dist/names.js +25 -0
  63. package/dist/network.d.ts +1 -1
  64. package/dist/network.js +4 -3
  65. package/dist/opt-in-settings.js +3 -2
  66. package/dist/replay.js +4 -3
  67. package/dist/runtime-lock.js +3 -2
  68. package/dist/vault.js +5 -4
  69. package/npm-shrinkwrap.json +6 -5
  70. package/package.json +13 -7
@@ -0,0 +1,906 @@
1
+ import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { dirname, join } from "node:path";
4
+ import { Exit, JSON_FLAG, bool, emit, fail, jsonOutput, parseFlags, str, style, } from "turno-core/cli";
5
+ import { tildify } from "turno-core/paths";
6
+ /** `show --json` (`turno identity show browser:<id> --json` in turno). */
7
+ export const SHOW_JSON = jsonOutput(["id", "dir", "settingsFile", "settings", "problems", "inUse", "holder", "health"]);
8
+ /** `set --json`: what changed, or would. */
9
+ export const SET_JSON = jsonOutput(["id", "settingsFile", "dryRun", "changes", "settings"]);
10
+ /** `doctor --json`: the shape of `turno doctor --json`. */
11
+ export const DOCTOR_JSON = jsonOutput(["ok", "counts", "checks", "fixed"]);
12
+ /** `reputation --json`: one element per identity. */
13
+ export const REPUTATION_JSON = jsonOutput(["id", "file", "total", "sites"]);
14
+ /** Flags that write identity.json, shared by `add` and `set`. An empty value removes the key. */
15
+ export const SETTINGS_FLAGS = {
16
+ timezone: { type: "string" },
17
+ locale: { type: "string" },
18
+ languages: { type: "string" },
19
+ region: { type: "string" },
20
+ "health-url": { type: "string" },
21
+ "health-text": { type: "string" },
22
+ "health-selector": { type: "string" },
23
+ "no-health": { type: "boolean" },
24
+ // How the host runs this identity's Chrome (format 2 of identity.json): the tab governor,
25
+ // background throttling, settle, resource blocking and cache.
26
+ "tabs-max": { type: "string" },
27
+ "tabs-popups": { type: "string" },
28
+ "tabs-park": { type: "string" },
29
+ "tabs-close": { type: "string" },
30
+ "no-tabs": { type: "boolean" },
31
+ "background-throttling": { type: "string" },
32
+ settle: { type: "string" },
33
+ "block-trackers": { type: "string" },
34
+ "block-types": { type: "string" },
35
+ "block-patterns": { type: "string" },
36
+ "no-block": { type: "boolean" },
37
+ cache: { type: "boolean" },
38
+ "cache-max-size": { type: "string" },
39
+ "no-cache": { type: "boolean" },
40
+ // Human-like input (format 4): off, light, full or adaptive.
41
+ humanize: { type: "string" },
42
+ // How many agent sessions use the identity's browser at once (format 5), and with tabs how
43
+ // long a call waits for a held tab and when an idle session lets go (format 8).
44
+ sharing: { type: "string" },
45
+ "tab-lock-wait": { type: "string" },
46
+ "tab-lock-release": { type: "string" },
47
+ // Which engine runs the identity (format 6): read mode on Lightpanda, or attach mode.
48
+ engine: { type: "string" },
49
+ attach: { type: "string" },
50
+ // What turno-browser records for this identity (format 7): flows, traces, screenshots.
51
+ "record-flows": { type: "string" },
52
+ "record-traces": { type: "string" },
53
+ "record-screenshots": { type: "string" },
54
+ "record-max-size": { type: "string" },
55
+ "no-record": { type: "boolean" },
56
+ // Natural language actions and captcha solving (format 8): off by default, opt-in only.
57
+ act: { type: "boolean" },
58
+ "act-sampling": { type: "string" },
59
+ "act-provider": { type: "string" },
60
+ "act-endpoint": { type: "string" },
61
+ "act-model": { type: "string" },
62
+ "act-key": { type: "string" },
63
+ "act-max-steps": { type: "string" },
64
+ "act-max-tokens": { type: "string" },
65
+ "act-timeout": { type: "string" },
66
+ "no-act": { type: "boolean" },
67
+ "captcha-provider": { type: "string" },
68
+ "captcha-endpoint": { type: "string" },
69
+ "captcha-key": { type: "string" },
70
+ "captcha-timeout": { type: "string" },
71
+ "no-captcha": { type: "boolean" },
72
+ // The live view and take-over (format 10).
73
+ live: { type: "string" },
74
+ "live-wait": { type: "string" },
75
+ "no-live": { type: "boolean" },
76
+ // Opt-in network and user agent settings (format 11), all off by default.
77
+ "user-agent": { type: "string" },
78
+ "proxy-server": { type: "string" },
79
+ "proxy-username": { type: "string" },
80
+ "proxy-password": { type: "string" },
81
+ "no-proxy": { type: "boolean" },
82
+ };
83
+ /** The identity.json key behind each tuning flag, so the package's messages name the flag. */
84
+ const KEY_FLAGS = [
85
+ ["tabs.max", "--tabs-max"],
86
+ ["tabs.popups", "--tabs-popups"],
87
+ ["tabs.park", "--tabs-park"],
88
+ ["tabs.close", "--tabs-close"],
89
+ ["backgroundThrottling", "--background-throttling"],
90
+ ["settle", "--settle"],
91
+ ["block.trackers", "--block-trackers"],
92
+ ["block.types", "--block-types"],
93
+ ["block.patterns", "--block-patterns"],
94
+ ["cache.maxSize", "--cache-max-size"],
95
+ ["humanize.level", "--humanize"],
96
+ ["sharing", "--sharing"],
97
+ ["tabLocks.wait", "--tab-lock-wait"],
98
+ ["tabLocks.release", "--tab-lock-release"],
99
+ ["engine", "--engine"],
100
+ ["attach", "--attach"],
101
+ ["record.flows", "--record-flows"],
102
+ ["record.traces", "--record-traces"],
103
+ ["record.screenshots", "--record-screenshots"],
104
+ ["record.maxSize", "--record-max-size"],
105
+ ["act.sampling", "--act-sampling"],
106
+ ["act.provider", "--act-provider"],
107
+ ["act.endpoint", "--act-endpoint"],
108
+ ["act.model", "--act-model"],
109
+ ["act.key", "--act-key"],
110
+ ["act.maxSteps", "--act-max-steps"],
111
+ ["act.maxTokens", "--act-max-tokens"],
112
+ ["act.timeout", "--act-timeout"],
113
+ ["captcha.provider", "--captcha-provider"],
114
+ ["captcha.endpoint", "--captcha-endpoint"],
115
+ ["captcha.key", "--captcha-key"],
116
+ ["captcha.timeout", "--captcha-timeout"],
117
+ ["live.enabled", "--live"],
118
+ ["live.wait", "--live-wait"],
119
+ ["userAgent", "--user-agent"],
120
+ ["proxy.server", "--proxy-server"],
121
+ ["proxy.username", "--proxy-username"],
122
+ ["proxy.password", "--proxy-password"],
123
+ ];
124
+ const TABS_MAX_PROBLEM = "--tabs-max must be a whole number from 0 (no cap) to 100";
125
+ /**
126
+ * A rejected identity.json with each problem of a tuning key told as its flag: the package
127
+ * says `identity "school": settle must be ...`, the command line says `--settle must be ...`.
128
+ * Other messages stay as the package wrote them.
129
+ */
130
+ function flagMessage(message) {
131
+ const problems = message.replace(/^identity "[^"]*": /, "").split("; ");
132
+ const told = problems.map((p) => {
133
+ const hit = KEY_FLAGS.find(([key]) => p.startsWith(`${key} `));
134
+ return hit ? `${hit[1]}${p.slice(hit[0].length)}` : undefined;
135
+ });
136
+ return told.every((t) => t !== undefined) ? told.join("; ") : message;
137
+ }
138
+ /** A true or false flag value; also on/off and yes/no. */
139
+ function booleanValue(flag, v) {
140
+ const word = v.toLowerCase();
141
+ if (["true", "on", "yes"].includes(word))
142
+ return true;
143
+ if (["false", "off", "no"].includes(word))
144
+ return false;
145
+ return fail(`${flag} must be true or false (an empty value removes it)`);
146
+ }
147
+ const list = (v) => v
148
+ .split(",")
149
+ .map((x) => x.trim())
150
+ .filter(Boolean);
151
+ /**
152
+ * A group of identity.json (tabs, block, cache) after the flags: `parts` set or (with null)
153
+ * remove its keys, the rest of `base` stays. Null when nothing is left, so the key goes.
154
+ */
155
+ function mergeGroup(base, parts) {
156
+ const next = { ...base };
157
+ for (const [k, v] of Object.entries(parts)) {
158
+ if (v === undefined)
159
+ continue;
160
+ if (v === null)
161
+ delete next[k];
162
+ else
163
+ next[k] = v;
164
+ }
165
+ return Object.keys(next).length ? next : null;
166
+ }
167
+ export const SETTINGS_FLAG_NAMES = Object.keys(SETTINGS_FLAGS).map((f) => `--${f}`);
168
+ /** The identity.json change the flags ask for; `current` fills the parts of health not given. */
169
+ export function settingsPatch(p, current) {
170
+ const patch = {};
171
+ const value = (name) => {
172
+ const v = str(p, name);
173
+ return v === undefined ? undefined : v.trim() === "" ? null : v.trim();
174
+ };
175
+ for (const key of ["timezone", "locale", "region"]) {
176
+ const v = value(key);
177
+ if (v !== undefined)
178
+ patch[key] = v;
179
+ }
180
+ const langs = value("languages");
181
+ if (langs !== undefined)
182
+ patch.languages =
183
+ langs === null
184
+ ? null
185
+ : langs
186
+ .split(",")
187
+ .map((l) => l.trim())
188
+ .filter(Boolean);
189
+ const url = value("health-url");
190
+ const text = value("health-text");
191
+ const selector = value("health-selector");
192
+ if (bool(p, "no-health")) {
193
+ if (url !== undefined || text !== undefined || selector !== undefined)
194
+ fail("--no-health does not go with the other --health flags");
195
+ patch.health = null;
196
+ }
197
+ else if (url !== undefined || text !== undefined || selector !== undefined) {
198
+ const base = current?.health;
199
+ const health = { url: url ?? base?.url ?? "" };
200
+ const t = text === undefined ? base?.text : (text ?? undefined);
201
+ const s = selector === undefined ? base?.selector : (selector ?? undefined);
202
+ if (t)
203
+ health.text = t;
204
+ if (s)
205
+ health.selector = s;
206
+ if (!health.url)
207
+ fail("a health check needs --health-url (a page only a signed-in user sees)");
208
+ if (!health.text && !health.selector)
209
+ fail("a health check needs --health-text or --health-selector (what that page shows when signed in)");
210
+ patch.health = health;
211
+ }
212
+ tuningPatch(p, value, patch, current);
213
+ const engine = value("engine");
214
+ if (engine !== undefined)
215
+ patch.engine = engine;
216
+ const attach = value("attach");
217
+ if (attach !== undefined)
218
+ patch.attach = attach;
219
+ networkPatch(p, value, patch, current);
220
+ return patch;
221
+ }
222
+ /** The format 11 keys: `userAgent` and `proxy`. The package checks the values. */
223
+ function networkPatch(p, value, patch, current) {
224
+ const userAgent = value("user-agent");
225
+ if (userAgent !== undefined)
226
+ patch.userAgent = userAgent;
227
+ const parts = {
228
+ server: value("proxy-server"),
229
+ username: value("proxy-username"),
230
+ password: value("proxy-password"),
231
+ };
232
+ const given = Object.values(parts).some((v) => v !== undefined);
233
+ if (bool(p, "no-proxy")) {
234
+ if (given)
235
+ fail("--no-proxy does not go with the other --proxy flags");
236
+ patch.proxy = null;
237
+ }
238
+ else if (given) {
239
+ patch.proxy = mergeGroup(current?.proxy, parts);
240
+ }
241
+ }
242
+ /** The format 2 keys of the patch: tabs, backgroundThrottling, settle, block and cache. */
243
+ function tuningPatch(p, value, patch, current) {
244
+ const tabs = {
245
+ max: value("tabs-max"),
246
+ popups: value("tabs-popups"),
247
+ park: value("tabs-park"),
248
+ close: value("tabs-close"),
249
+ };
250
+ if (bool(p, "no-tabs")) {
251
+ if (Object.values(tabs).some((v) => v !== undefined))
252
+ fail("--no-tabs does not go with the other --tabs flags");
253
+ patch.tabs = null;
254
+ }
255
+ else if (Object.values(tabs).some((v) => v !== undefined)) {
256
+ let max;
257
+ if (typeof tabs.max === "string") {
258
+ if (!/^\d+$/.test(tabs.max))
259
+ fail(TABS_MAX_PROBLEM);
260
+ max = Number(tabs.max);
261
+ }
262
+ else
263
+ max = tabs.max;
264
+ patch.tabs = mergeGroup(current?.tabs, { ...tabs, max });
265
+ }
266
+ const throttling = value("background-throttling");
267
+ if (throttling !== undefined)
268
+ patch.backgroundThrottling = throttling === null ? null : booleanValue("--background-throttling", throttling);
269
+ const settle = value("settle");
270
+ if (settle !== undefined)
271
+ patch.settle = settle;
272
+ const trackers = value("block-trackers");
273
+ const types = value("block-types");
274
+ const patterns = value("block-patterns");
275
+ if (bool(p, "no-block")) {
276
+ if (trackers !== undefined || types !== undefined || patterns !== undefined)
277
+ fail("--no-block does not go with the other --block flags");
278
+ patch.block = null;
279
+ }
280
+ else if (trackers !== undefined || types !== undefined || patterns !== undefined) {
281
+ patch.block = mergeGroup(current?.block, {
282
+ trackers: typeof trackers === "string" ? booleanValue("--block-trackers", trackers) : trackers,
283
+ types: typeof types === "string" ? list(types) : types,
284
+ patterns: typeof patterns === "string" ? list(patterns) : patterns,
285
+ });
286
+ }
287
+ const maxSize = value("cache-max-size");
288
+ if (bool(p, "no-cache")) {
289
+ if (bool(p, "cache") || maxSize !== undefined)
290
+ fail("--no-cache does not go with --cache or --cache-max-size");
291
+ patch.cache = null;
292
+ }
293
+ else if (bool(p, "cache") || maxSize !== undefined) {
294
+ // The cache stays on when its size is removed: {} is on with the default size.
295
+ patch.cache = mergeGroup(current?.cache, { maxSize }) ?? {};
296
+ }
297
+ // An empty value removes the whole group (the seed with it); a level keeps a seed set by hand.
298
+ const humanize = value("humanize");
299
+ if (humanize !== undefined)
300
+ patch.humanize = humanize === null ? null : { ...current?.humanize, level: humanize };
301
+ // Checked by the package: an unknown value comes back as `--sharing must be ...`.
302
+ const sharing = value("sharing");
303
+ if (sharing !== undefined)
304
+ patch.sharing = sharing;
305
+ const locks = { wait: value("tab-lock-wait"), release: value("tab-lock-release") };
306
+ if (locks.wait !== undefined || locks.release !== undefined)
307
+ patch.tabLocks = mergeGroup(current?.tabLocks, locks);
308
+ recordPatch(p, value, patch, current);
309
+ actPatch(p, value, patch, current);
310
+ captchaPatch(p, value, patch, current);
311
+ livePatch(p, value, patch, current);
312
+ }
313
+ /** A whole number flag value as a number; anything else goes to the package, which says why. */
314
+ const wholeNumber = (v) => (typeof v === "string" && /^\d+$/.test(v) ? Number(v) : v);
315
+ /** The format 8 `act` key: natural language actions, with MCP sampling or a provider. */
316
+ function actPatch(p, value, patch, current) {
317
+ const sampling = value("act-sampling");
318
+ const parts = {
319
+ sampling: typeof sampling === "string" ? booleanValue("--act-sampling", sampling) : sampling,
320
+ provider: value("act-provider"),
321
+ endpoint: value("act-endpoint"),
322
+ model: value("act-model"),
323
+ key: value("act-key"),
324
+ maxSteps: wholeNumber(value("act-max-steps")),
325
+ maxTokens: wholeNumber(value("act-max-tokens")),
326
+ timeout: value("act-timeout"),
327
+ };
328
+ const given = Object.values(parts).some((v) => v !== undefined);
329
+ if (bool(p, "no-act")) {
330
+ if (given || bool(p, "act"))
331
+ fail("--no-act does not go with the other --act flags");
332
+ patch.act = null;
333
+ }
334
+ else if (given || bool(p, "act")) {
335
+ patch.act = mergeGroup(current?.act, parts) ?? {};
336
+ }
337
+ }
338
+ /** The format 8 `captcha` key: a solver service and its key's secret store reference. */
339
+ function captchaPatch(p, value, patch, current) {
340
+ const parts = {
341
+ provider: value("captcha-provider"),
342
+ endpoint: value("captcha-endpoint"),
343
+ key: value("captcha-key"),
344
+ timeout: value("captcha-timeout"),
345
+ };
346
+ const given = Object.values(parts).some((v) => v !== undefined);
347
+ if (bool(p, "no-captcha")) {
348
+ if (given)
349
+ fail("--no-captcha does not go with the other --captcha flags");
350
+ patch.captcha = null;
351
+ }
352
+ else if (given) {
353
+ patch.captcha = mergeGroup(current?.captcha, parts);
354
+ }
355
+ }
356
+ /** How an identity's natural language actions get a model, in a few words. */
357
+ function describeAct(a) {
358
+ if (!a)
359
+ return undefined;
360
+ const provider = a.provider ? `${a.provider} ${a.model ?? ""} at ${a.endpoint ?? ""}`.replace(/\s+/g, " ") : "";
361
+ const how = a.sampling === false
362
+ ? provider
363
+ : provider
364
+ ? `MCP sampling, else ${provider}`
365
+ : "MCP sampling (your client's model)";
366
+ return `on: ${how}`;
367
+ }
368
+ /** The format 10 `live` key: the live view and take-over. */
369
+ function livePatch(p, value, patch, current) {
370
+ const enabled = value("live");
371
+ const wait = value("live-wait");
372
+ if (bool(p, "no-live")) {
373
+ if (enabled !== undefined || wait !== undefined)
374
+ fail("--no-live does not go with --live or --live-wait");
375
+ patch.live = null;
376
+ }
377
+ else if (enabled !== undefined || wait !== undefined) {
378
+ patch.live = mergeGroup(current?.live, {
379
+ enabled: typeof enabled === "string" ? booleanValue("--live", enabled) : enabled,
380
+ wait,
381
+ });
382
+ }
383
+ }
384
+ /** The format 7 `record` key: what turno-browser records for this identity. */
385
+ function recordPatch(p, value, patch, current) {
386
+ const parts = {
387
+ flows: value("record-flows"),
388
+ traces: value("record-traces"),
389
+ screenshots: value("record-screenshots"),
390
+ maxSize: value("record-max-size"),
391
+ };
392
+ const given = Object.values(parts).some((v) => v !== undefined);
393
+ if (bool(p, "no-record")) {
394
+ if (given)
395
+ fail("--no-record does not go with the other --record flags");
396
+ patch.record = null;
397
+ }
398
+ else if (given) {
399
+ const flag = (name, v) => typeof v === "string" ? booleanValue(`--record-${name}`, v) : v;
400
+ patch.record = mergeGroup(current?.record, {
401
+ flows: flag("flows", parts.flows),
402
+ traces: flag("traces", parts.traces),
403
+ screenshots: flag("screenshots", parts.screenshots),
404
+ maxSize: parts.maxSize,
405
+ });
406
+ }
407
+ }
408
+ /** What an identity records, in a few words: "flows, traces (up to 200MB)". */
409
+ export function describeRecord(r) {
410
+ if (!r)
411
+ return undefined;
412
+ const on = ["flows", "traces", "screenshots"].filter((k) => r[k]);
413
+ if (!on.length)
414
+ return undefined;
415
+ const files = r.traces || r.screenshots;
416
+ return `${on.join(", ")}${files ? ` (up to ${r.maxSize ?? "200MB"})` : ""}`;
417
+ }
418
+ export function hasSettings(patch) {
419
+ return Object.keys(patch).length > 0;
420
+ }
421
+ /** A proxy for `show`: the server and where the credentials come from, never their value. */
422
+ function describeProxy(p) {
423
+ const who = p.username ? `, signs in as ${p.username} with ${p.password}` : "";
424
+ return `${p.server}${who}`;
425
+ }
426
+ function describeHealth(h) {
427
+ return [h.url, h.text ? `shows "${h.text}"` : "", h.selector ? `has ${h.selector}` : ""].filter(Boolean).join(" ");
428
+ }
429
+ function describeTabs(t) {
430
+ const parts = [];
431
+ if (t.max !== undefined)
432
+ parts.push(t.max === 0 ? "no cap on open tabs" : `at most ${t.max} open`);
433
+ if (t.popups)
434
+ parts.push(t.popups === "keep" ? "popups kept" : "popups closed");
435
+ if (t.park !== undefined)
436
+ parts.push(t.park === "0" ? "never parked" : `parked after ${t.park}`);
437
+ if (t.close !== undefined)
438
+ parts.push(t.close === "0" ? "never closed when unused" : `closed after ${t.close}`);
439
+ return parts.join(", ");
440
+ }
441
+ function describeBlock(b) {
442
+ const n = b.patterns?.length ?? 0;
443
+ return [b.trackers ? "trackers" : "", ...(b.types ?? []), n ? `${n} pattern${n === 1 ? "" : "s"}` : ""]
444
+ .filter(Boolean)
445
+ .join(", ");
446
+ }
447
+ /** What each humanize level does, for `show`. */
448
+ const HUMANIZE_TEXT = {
449
+ off: "Playwright's own (humanize off)",
450
+ light: "human-like pointer and typing (light)",
451
+ full: "human-like pointer, typing and scrolling (full)",
452
+ adaptive: "light, full on sites that showed a challenge (adaptive)",
453
+ };
454
+ export function show(c, id, args, io) {
455
+ const m = c.api;
456
+ const p = parseFlags(args, JSON_FLAG, 1);
457
+ if (!m.identityExists(id, io.env))
458
+ return fail(`identity "${id}" does not exist (${c.names.identity("add", id)})`);
459
+ const { path, settings, problems } = m.checkIdentitySettings(id, io.env);
460
+ const holder = m.inUseBy(id, io.env);
461
+ const health = m.readHealth(id, io.env);
462
+ if (bool(p, "json")) {
463
+ emit(io, p, SHOW_JSON, {
464
+ id: `browser:${id}`,
465
+ dir: tildify(m.identityDir(id, io.env), io.env),
466
+ settingsFile: tildify(path, io.env),
467
+ settings: settings ?? null,
468
+ problems,
469
+ inUse: holder !== undefined,
470
+ holder: holder ?? null,
471
+ health: health ?? null,
472
+ });
473
+ return Exit.ok;
474
+ }
475
+ const s = style(io);
476
+ const rows = [
477
+ ["profile", tildify(m.identityDir(id, io.env), io.env)],
478
+ [
479
+ "settings",
480
+ `${tildify(path, io.env)}${settings || problems.length ? "" : s.muted(" (none: Chrome's own time zone and languages)")}`,
481
+ ],
482
+ ];
483
+ if (settings) {
484
+ rows.push(["time zone", settings.timezone ?? s.muted("(the system's)")]);
485
+ if (settings.locale)
486
+ rows.push(["locale", settings.locale]);
487
+ rows.push([
488
+ "languages",
489
+ settings.languages?.join(", ") ?? s.muted(settings.locale ? "(from the locale)" : "(Chrome's)"),
490
+ ]);
491
+ if (settings.region)
492
+ rows.push(["region", settings.region]);
493
+ rows.push(["health check", settings.health ? describeHealth(settings.health) : s.muted("(none)")]);
494
+ if (settings.tabs)
495
+ rows.push(["tabs", `${describeTabs(settings.tabs)}${s.muted(" (the rest as default)")}`]);
496
+ if (settings.backgroundThrottling !== undefined)
497
+ rows.push([
498
+ "throttling",
499
+ settings.backgroundThrottling ? "background tabs throttled" : "every tab at full speed",
500
+ ]);
501
+ if (settings.settle !== undefined)
502
+ rows.push(["settle", settings.settle]);
503
+ if (settings.block)
504
+ rows.push(["blocking", describeBlock(settings.block) || s.muted("(nothing)")]);
505
+ if (settings.cache)
506
+ rows.push(["cache", `on, up to ${settings.cache.maxSize ?? "100MB"}`]);
507
+ if (settings.keychain === "system")
508
+ rows.push(["cookie key", "the system keychain (identity.json keychain)"]);
509
+ if (settings.humanize)
510
+ rows.push([
511
+ "input",
512
+ `${HUMANIZE_TEXT[settings.humanize.level] ?? settings.humanize.level}${settings.humanize.seed === undefined ? "" : s.muted(` (seed ${settings.humanize.seed})`)}`,
513
+ ]);
514
+ if (settings.sharing === "tabs")
515
+ rows.push(["sharing", "every agent session at once, each in its own tabs"]);
516
+ if (settings.tabLocks)
517
+ rows.push([
518
+ "tab locks",
519
+ `${[
520
+ settings.tabLocks.wait !== undefined ? `wait ${settings.tabLocks.wait}` : "",
521
+ settings.tabLocks.release !== undefined ? `release after ${settings.tabLocks.release}` : "",
522
+ ]
523
+ .filter(Boolean)
524
+ .join(", ")}${s.muted(settings.sharing === "tabs" ? "" : ' (used with "sharing": "tabs")')}`,
525
+ ]);
526
+ if (settings.engine === "lightpanda")
527
+ rows.push(["engine", "Lightpanda (read mode)"]);
528
+ if (settings.engine === "camoufox")
529
+ rows.push(["engine", "Camoufox (its own Firefox profile)"]);
530
+ if (settings.userAgent === "coherent")
531
+ rows.push(["user agent", "the installed Chrome's own, checked at every launch (coherent)"]);
532
+ if (settings.proxy)
533
+ rows.push(["proxy", describeProxy(settings.proxy)]);
534
+ if (settings.attach !== undefined)
535
+ rows.push(["engine", `attach to your Chrome (${settings.attach})`]);
536
+ const recorded = describeRecord(settings.record);
537
+ if (recorded)
538
+ rows.push(["recording", recorded]);
539
+ const act = describeAct(settings.act);
540
+ if (act)
541
+ rows.push(["act", act]);
542
+ if (settings.captcha)
543
+ rows.push(["captcha", `on: ${settings.captcha.provider} at ${settings.captcha.endpoint}`]);
544
+ if (settings.live?.enabled)
545
+ rows.push([
546
+ "live view",
547
+ `on (${c.names.browser} live ${id}); a paused call waits up to ${settings.live.wait ?? "2m"}`,
548
+ ]);
549
+ rows.push(["created", settings.created]);
550
+ rows.push(["updated", settings.updated]);
551
+ }
552
+ if (health) {
553
+ const state = health.status === "ok"
554
+ ? s.ok("signed in")
555
+ : health.status === "needs_auth"
556
+ ? s.err("NEEDS_AUTH")
557
+ : s.warn("check failed");
558
+ rows.push(["last check", `${state} ${s.muted(`${health.checkedAt}${health.detail ? `: ${health.detail}` : ""}`)}`]);
559
+ }
560
+ rows.push([
561
+ "state",
562
+ holder ? s.warn(holder.replace(/^browser identity "[^"]+" is /, "").replace(/\. .*$/, "")) : s.ok("free"),
563
+ ]);
564
+ io.out(s.bold(`browser:${id}`));
565
+ const width = Math.max(...rows.map(([k]) => k.length));
566
+ for (const [k, v] of rows)
567
+ io.out(s.kv(k, v, width));
568
+ for (const problem of problems)
569
+ io.out(s.note("err", `identity.json ${problem}`));
570
+ if (health?.status === "needs_auth")
571
+ io.out(s.note("info", `sign in again: ${c.names.browser} login ${id}`));
572
+ return Exit.ok;
573
+ }
574
+ const SET_FLAGS = { ...SETTINGS_FLAGS, "dry-run": { type: "boolean" }, ...JSON_FLAG };
575
+ /** The arguments of `set` after the identity, for the usage line. */
576
+ export const SET_SYNOPSIS = "[--timezone <zone>] [--locale <tag>] [--languages <tag,...>] [--region <CC>] [--health-url <url>] [--health-text <text>] [--health-selector <css>] [--no-health] " +
577
+ "[--tabs-max <n>] [--tabs-popups close|keep] [--tabs-park <duration>] [--tabs-close <duration>] [--no-tabs] [--background-throttling true|false] [--settle <duration>] " +
578
+ "[--block-trackers true|false] [--block-types image,media,font] [--block-patterns <host|glob>,...] [--no-block] [--cache] [--cache-max-size <size>] [--no-cache] [--humanize off|light|full|adaptive] [--sharing session|tabs] [--tab-lock-wait <duration>] [--tab-lock-release <duration>] " +
579
+ "[--engine chrome|lightpanda] [--attach auto|<dir>|<url>] [--record-flows true|false] [--record-traces true|false] [--record-screenshots true|false] [--record-max-size <size>] [--no-record] " +
580
+ "[--act] [--act-sampling true|false] [--act-provider chat-completions] [--act-endpoint <url>] [--act-model <name>] [--act-key keychain:<item>] [--act-max-steps <n>] [--act-max-tokens <n>] [--act-timeout <duration>] [--no-act] " +
581
+ "[--captcha-provider task-api] [--captcha-endpoint <url>] [--captcha-key keychain:<item>] [--captcha-timeout <duration>] [--no-captcha] [--live true|false] [--live-wait <duration>] [--no-live] " +
582
+ "[--user-agent coherent] [--proxy-server <url>] [--proxy-username <name|keychain:item>] [--proxy-password keychain:<item>] [--no-proxy] [--dry-run] [--json]";
583
+ /** More help for `set`: what each tuning flag writes to identity.json, with the host's command names. */
584
+ export function setDetails(n) {
585
+ const b = n.browser;
586
+ return `Each flag writes one key of identity.json; an empty value (--settle "") removes it, and
587
+ --no-health, --no-tabs, --no-block and --no-cache remove a whole group. A flag of a group
588
+ changes only its part: the rest of that group stays.
589
+
590
+ How the host runs this identity's Chrome (read at every Chrome start):
591
+ --tabs-max <n> most tabs open at once, 0 for no cap (default 8)
592
+ --tabs-popups close|keep close popups the agent did not open (default close)
593
+ --tabs-park <duration> park an unused tab on about:blank, "0" never (default 5m)
594
+ --tabs-close <duration> close an unused tab, "0" never (default 15m)
595
+ --background-throttling <bool> let Chrome slow tabs that are not in front (default false)
596
+ --settle <duration> wait after each action for the work it started, "0" to "10s"
597
+ --block-trackers <bool> block a built-in list of ad and analytics hosts
598
+ --block-types <list> block image, media and font requests (never the page itself)
599
+ --block-patterns <list> block host names (and subdomains) or URL globs with *
600
+ --cache keep images, fonts, styles and scripts on disk (100MB)
601
+ --cache-max-size <size> the cache's size, "1MB" to "10GB"; turns the cache on
602
+ --sharing session|tabs "tabs": every agent session at once, each in its own locked
603
+ tabs (default "session": one at a time); mcp.toml then needs
604
+ exclusive = false for the identity's server
605
+ --tab-lock-wait <duration> with tabs: how long a call waits for a tab another session
606
+ holds, "0" (fail at once) to "10m" (default 10s)
607
+ --tab-lock-release <duration> with tabs: a session without calls lets go of its tabs after
608
+ this, "0" (free between calls) to "24h" (default 5m)
609
+
610
+ Blocking without the cache turns Chrome's own HTTP cache off: use them together.
611
+
612
+ Input:
613
+ --humanize <level> off (default), light (the pointer travels a curve to a point
614
+ inside the target, keys typed with human delays), full (plus
615
+ overshoot, reading pauses, wheel scrolling) or adaptive
616
+ (light, full on a site after a challenge page there)
617
+
618
+ Which engine runs this identity (all off by default):
619
+ --engine lightpanda read mode: Lightpanda instead of Chrome, for reading pages;
620
+ needs lightpanda on PATH (${b} doctor says how)
621
+ --engine camoufox Camoufox (a Firefox build) with its own profile; not
622
+ recommended for your own accounts; needs Camoufox and
623
+ playwright-core (${b} doctor says how); no captcha
624
+ solving, and no picture in the live view
625
+ --attach auto|<dir>|<url> use the Chrome you have open instead of the identity's own:
626
+ "auto" is your default Chrome profile, after you turn on
627
+ chrome://inspect/#remote-debugging; Chrome asks you to allow
628
+ each connection, and the agent then sees all its windows
629
+
630
+ What turno-browser records for this identity (all off by default; ${b} record):
631
+ --record-flows <bool> keep every session's actions as a flow (auto-<time>, newest 20)
632
+ --record-traces <bool> a Playwright trace of each browser session (${b} traces)
633
+ --record-screenshots <bool> a screenshot after each action
634
+ --record-max-size <size> cap of the traces and screenshots, "10MB" to "10GB" (default 200MB)
635
+ Vault sign-ins and passwords never reach a flow, a trace or a screenshot.
636
+
637
+ Off by default, for your own accounts only (they send page content to a third
638
+ party you pick, and many sites' terms forbid them; the server lists their tools from its next start):
639
+ --act natural language actions (browser_act, browser_extract,
640
+ browser_observe) with your client's model (MCP sampling)
641
+ --act-provider chat-completions a model API to use when the client has no sampling, with
642
+ --act-endpoint <url> its base URL (https, or http on this machine),
643
+ --act-model <name> the model name it expects and
644
+ --act-key keychain:<item> its key in the secret store (${n.secretSet("<item>")})
645
+ --act-sampling <bool> false: never ask the client, always use the provider
646
+ --act-max-steps <n> most actions per call, 1 to 30 (default 10)
647
+ --act-max-tokens <n> most model tokens per call (default 50000)
648
+ --act-timeout <duration> longest call, "10s" to "10m" (default 2m)
649
+ --captcha-provider task-api solve captcha widgets (browser_solve_captcha) through a solver
650
+ --captcha-endpoint <url> service that speaks the createTask protocol, at this URL,
651
+ --captcha-key keychain:<item> with its account key in the secret store
652
+ --captcha-timeout <duration> longest wait for a solution (default 3m)
653
+ --no-act, --no-captcha turn them off
654
+
655
+ The live view and take-over (off by default; ${b} live, pause, resume):
656
+ --live <bool> serve a view of the agent's tab on 127.0.0.1 and let you pause
657
+ the agent to take the controls (from the next server start)
658
+ --live-wait <duration> how long a paused call waits for you, "5s" to "30m" (default 2m)
659
+
660
+ Network and user agent (all off by default; for your own accounts and sites you may automate):
661
+ --user-agent coherent the installed Chrome's own user agent and client hints, with
662
+ this identity's languages and time zone, checked at every
663
+ launch (a headless Chrome stops saying HeadlessChrome); turno
664
+ never takes a typed user agent
665
+ --proxy-server <url> send this identity's traffic through a proxy: http://,
666
+ https://, socks4:// or socks5://host:port; its operator sees
667
+ where you go, and sites see its address
668
+ --proxy-username <name> the proxy user name, or keychain:<item>
669
+ --proxy-password keychain:<item> the password, only from the secret store (${n.secretStore ?? n.secretSet("<item>")})
670
+ --no-proxy remove the proxy`;
671
+ }
672
+ /** The flags of `set`, for completion. */
673
+ export const SET_FLAG_NAMES = ["--dry-run", "--json", ...SETTINGS_FLAG_NAMES];
674
+ /**
675
+ * The package's own validation, run on a copy: identity.json is copied to a throwaway data
676
+ * folder and the patch written there, so `--dry-run` refuses exactly what the write would and
677
+ * shows the file it would leave, without touching the real one.
678
+ */
679
+ function rehearse(m, id, patch, env) {
680
+ const dir = mkdtempSync(join(env.TMPDIR || tmpdir(), "turno-identity-"));
681
+ try {
682
+ const copy = { ...env, TURNO_DATA_DIR: dir };
683
+ const from = m.identitySettingsPath(id, env);
684
+ const to = m.identitySettingsPath(id, copy);
685
+ mkdirSync(dirname(to), { recursive: true, mode: 0o700 });
686
+ if (existsSync(from))
687
+ copyFileSync(from, to);
688
+ return m.writeIdentitySettings(id, patch, copy);
689
+ }
690
+ finally {
691
+ rmSync(dir, { recursive: true, force: true });
692
+ }
693
+ }
694
+ /** What turning on natural language actions or captcha solving costs, said once at `set`. */
695
+ function optInNotes(c, id, patch) {
696
+ const notes = [];
697
+ const restart = `its tools are listed once browser-${id} starts again (${c.host.restart})`;
698
+ if (patch.act)
699
+ notes.push(`natural language actions: each call sends the instruction and a snapshot of the page to the model (your client's, or the provider you set), with vault values and sensitive fields hidden; ${restart}. Undo with --no-act.`);
700
+ if (patch.captcha)
701
+ notes.push(`captcha solving: the solver service sees the page address and the captcha, and solving a site's captchas by machine may break its terms; use it only for your own accounts. Every use goes to the reputation log; ${restart}. Undo with --no-captcha.`);
702
+ const own = "Meant for your own accounts and sites you may automate.";
703
+ if (typeof patch.userAgent === "string")
704
+ notes.push(`userAgent coherent: Chrome's real version and platform are kept, so a site sees one coherent browser; a site may still notice automation by other means. ${own}`);
705
+ if (patch.proxy)
706
+ notes.push(`proxy ${patch.proxy.server}: its operator sees where this identity goes, sites see the proxy's address instead of yours, and a sign-in from a new network can lock an account; many sites' terms forbid it. ${own}`);
707
+ if (patch.engine === "camoufox")
708
+ notes.push(`engine camoufox: a Firefox build that reports values other than the computer's own is something sites look for, the Chrome profile's sign-ins do not carry over, and it needs Camoufox and playwright-core (${c.names.browser} doctor). ${own}`);
709
+ return notes;
710
+ }
711
+ export function set(c, id, args, io) {
712
+ const m = c.api;
713
+ const p = parseFlags(args, SET_FLAGS, 1);
714
+ if (!m.identityExists(id, io.env))
715
+ return fail(`identity "${id}" does not exist (${c.names.identity("add", id)})`);
716
+ const patch = settingsPatch(p, m.checkIdentitySettings(id, io.env).settings);
717
+ if (!hasSettings(patch))
718
+ return fail(`nothing to set: pass ${SETTINGS_FLAG_NAMES.join(", ")} (an empty value removes one)`);
719
+ const dryRun = bool(p, "dry-run");
720
+ let settings;
721
+ try {
722
+ settings = dryRun ? rehearse(m, id, patch, io.env) : m.writeIdentitySettings(id, patch, io.env);
723
+ }
724
+ catch (err) {
725
+ if (err.name === "IdentityError")
726
+ return fail(flagMessage(err.message));
727
+ throw err;
728
+ }
729
+ if (bool(p, "json")) {
730
+ emit(io, p, SET_JSON, {
731
+ id: `browser:${id}`,
732
+ settingsFile: tildify(m.identitySettingsPath(id, io.env), io.env),
733
+ dryRun,
734
+ changes: patch,
735
+ settings,
736
+ });
737
+ return Exit.ok;
738
+ }
739
+ if (dryRun) {
740
+ io.out(`(dry run) would update identity.json of "${id}": ${JSON.stringify(patch)}`);
741
+ return Exit.ok;
742
+ }
743
+ io.out(`updated identity.json of "${id}"; the next Chrome start of browser-${id} uses it\n`);
744
+ const code = show(c, id, [], io);
745
+ const sharing = patch.sharing !== undefined ? c.host.sharingNote?.(id, settings.sharing) : undefined;
746
+ if (sharing)
747
+ io.out(`\n${sharing}`);
748
+ for (const note of optInNotes(c, id, patch))
749
+ io.out(style(io).note("warn", note));
750
+ if (typeof patch.attach === "string") {
751
+ const s = style(io);
752
+ io.out(s.note("warn", "attach mode: the agent works in your own Chrome and sees every window and signed-in site of that profile. " +
753
+ "Turn on remote debugging at chrome://inspect/#remote-debugging and allow each connection Chrome asks about; " +
754
+ 'turno closes only the tabs it opened. Undo with --attach "".'));
755
+ }
756
+ return code;
757
+ }
758
+ const DOCTOR_FLAGS = { fix: { type: "boolean" }, "no-launch": { type: "boolean" }, ...JSON_FLAG };
759
+ const SECTIONS = [
760
+ ["Chrome", (a) => a === "chrome"],
761
+ ["System", (a) => a === "system"],
762
+ ["Engines", (a) => a === "engines"],
763
+ ["Identities", (a) => a === "identities" || a.startsWith("identity ")],
764
+ ];
765
+ export async function doctor(c, args, io) {
766
+ const m = c.api;
767
+ const p = parseFlags(args, DOCTOR_FLAGS, 0);
768
+ const json = bool(p, "json");
769
+ const report = await m.runDoctor({
770
+ env: io.env,
771
+ fix: bool(p, "fix"),
772
+ launch: !bool(p, "no-launch"),
773
+ servers: c.host.servers?.(io.env) ?? [],
774
+ });
775
+ const failed = report.checks.some((c) => c.level === "fail");
776
+ const exit = failed ? Exit.failure : Exit.ok;
777
+ const status = (c) => (c.level === "info" ? "skip" : c.level);
778
+ const n = (l) => report.checks.filter((c) => c.level === l).length;
779
+ if (json) {
780
+ emit(io, p, DOCTOR_JSON, {
781
+ ok: !failed,
782
+ counts: { ok: n("ok"), warn: n("warn"), fail: n("fail"), skip: n("info") },
783
+ fixed: report.fixed,
784
+ checks: report.checks.map((c) => ({
785
+ area: c.area,
786
+ status: status(c),
787
+ text: c.text,
788
+ fix: c.level === "ok" ? null : (c.fix ?? null),
789
+ auto: Boolean(c.auto) && (c.level === "warn" || c.level === "fail"),
790
+ manual: c.level === "ok" ? null : (c.manual ?? null),
791
+ })),
792
+ });
793
+ return exit;
794
+ }
795
+ const s = style(io);
796
+ for (const f of report.fixed)
797
+ io.out(s.check("ok", `fixed: ${f}`));
798
+ if (report.fixed.length)
799
+ io.out("");
800
+ const ICON = { ok: "ok", warn: "warn", fail: "err", info: "skip" };
801
+ let first = true;
802
+ for (const [title, has] of SECTIONS) {
803
+ const rows = report.checks.filter((c) => has(c.area));
804
+ if (!rows.length)
805
+ continue;
806
+ if (!first)
807
+ io.out("");
808
+ first = false;
809
+ io.out(s.header(title));
810
+ let area = "";
811
+ for (const c of rows) {
812
+ if (c.area.startsWith("identity ") && c.area !== area)
813
+ io.out(` ${s.bold(`browser:${c.area.slice("identity ".length)}`)}`);
814
+ area = c.area;
815
+ const indent = c.area.startsWith("identity ") ? 4 : 2;
816
+ const text = c.level === "fail" ? s.err(c.text) : c.level === "info" ? s.muted(c.text) : c.text;
817
+ io.out(s.note(ICON[c.level], text, indent));
818
+ if (c.level === "ok")
819
+ continue;
820
+ const under = " ".repeat(indent + 2);
821
+ const label = c.level === "info" ? "optional:" : "fix:";
822
+ if (c.fix)
823
+ io.out(s.wrap(`${under}${s.muted(label)} `, `${c.level === "info" ? s.muted(c.fix) : s.bold(c.fix)}${c.auto ? s.muted(" (runs with --fix)") : ""}`));
824
+ else if (c.manual)
825
+ io.out(s.wrap(`${under}${s.muted("manual:")} `, c.manual));
826
+ }
827
+ }
828
+ io.out("");
829
+ io.out([
830
+ `${n("ok")} ok`,
831
+ n("warn") ? `${n("warn")} warning${n("warn") === 1 ? "" : "s"}` : "",
832
+ n("fail") ? `${n("fail")} failure${n("fail") === 1 ? "" : "s"}` : "",
833
+ ]
834
+ .filter(Boolean)
835
+ .join(", "));
836
+ return exit;
837
+ }
838
+ export function reputation(c, args, io, checkId) {
839
+ const m = c.api;
840
+ const p = parseFlags(args, JSON_FLAG, 1);
841
+ const id = p.positionals[0] === undefined ? undefined : checkId(p.positionals[0].replace(/^browser:/, ""));
842
+ let report;
843
+ try {
844
+ report = m.reputationReport(io.env, id ? [id] : undefined);
845
+ }
846
+ catch (err) {
847
+ return fail(err.message);
848
+ }
849
+ if (bool(p, "json")) {
850
+ emit(io, p, REPUTATION_JSON, report.identities.map((i) => ({
851
+ id: `browser:${i.id}`,
852
+ file: tildify(i.file, io.env),
853
+ total: i.total,
854
+ sites: i.sites,
855
+ })));
856
+ return Exit.ok;
857
+ }
858
+ const s = style(io);
859
+ if (!report.identities.length) {
860
+ io.out(`No browser identities yet. Create one with \`${c.names.identity("add", "<id>")}\`.`);
861
+ return Exit.ok;
862
+ }
863
+ const TREND = { up: s.warn("up"), down: s.ok("down"), flat: s.muted("flat") };
864
+ for (const [i, ident] of report.identities.entries()) {
865
+ if (i)
866
+ io.out("");
867
+ io.out(s.header(`browser:${ident.id}`));
868
+ if (!ident.sites.length) {
869
+ io.out(` ${s.muted("no challenges recorded")}`);
870
+ continue;
871
+ }
872
+ // The solved column shows only once a captcha solver answered (identity.json `captcha`).
873
+ const solved = ident.sites.some((x) => x.solved > 0);
874
+ const head = [
875
+ "site",
876
+ "total",
877
+ "captcha",
878
+ "verify",
879
+ "block",
880
+ ...(solved ? ["solved"] : []),
881
+ "7d",
882
+ "prev 7d",
883
+ "trend",
884
+ "last seen",
885
+ ].map((h) => s.muted(h));
886
+ const rows = ident.sites.map((x) => [
887
+ x.site,
888
+ String(x.total),
889
+ String(x.captcha),
890
+ String(x.verify),
891
+ String(x.block),
892
+ ...(solved ? [String(x.solved)] : []),
893
+ String(x.last7d),
894
+ String(x.prev7d),
895
+ TREND[x.trend],
896
+ x.lastSeen,
897
+ ]);
898
+ const right = { align: "right" };
899
+ for (const l of s.table([head, ...rows], {
900
+ columns: [{}, right, right, right, right, ...(solved ? [right] : []), right, right, {}, { drop: 1 }],
901
+ }))
902
+ io.out(l);
903
+ }
904
+ return Exit.ok;
905
+ }
906
+ //# sourceMappingURL=identity.js.map