turno-browser 0.6.0 → 0.8.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 (76) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +13 -5
  3. package/dist/act.js +4 -29
  4. package/dist/agent-cursor-overlay.d.ts +95 -0
  5. package/dist/agent-cursor-overlay.js +358 -0
  6. package/dist/agent-cursor.d.ts +191 -0
  7. package/dist/agent-cursor.js +494 -0
  8. package/dist/api.d.ts +8 -3
  9. package/dist/api.js +6 -3
  10. package/dist/argv.d.ts +2 -1
  11. package/dist/argv.js +7 -1
  12. package/dist/bin/mcp.js +5 -0
  13. package/dist/cli/commands.js +12 -3
  14. package/dist/cli/completion.js +3 -0
  15. package/dist/cli/context.d.ts +2 -0
  16. package/dist/cli/context.js +8 -4
  17. package/dist/cli/do-background.d.ts +2 -0
  18. package/dist/cli/do-background.js +15 -0
  19. package/dist/cli/do.d.ts +4 -0
  20. package/dist/cli/do.js +17 -1
  21. package/dist/cli/flows.js +3 -0
  22. package/dist/cli/identity.d.ts +2 -0
  23. package/dist/cli/identity.js +67 -11
  24. package/dist/cli/init.d.ts +12 -0
  25. package/dist/cli/init.js +219 -0
  26. package/dist/cli/login-summary.d.ts +6 -0
  27. package/dist/cli/login-summary.js +11 -0
  28. package/dist/cli/main.js +3 -0
  29. package/dist/cli/setup.d.ts +32 -0
  30. package/dist/cli/setup.js +32 -23
  31. package/dist/doctor.js +18 -2
  32. package/dist/engine-camoufox.js +1 -0
  33. package/dist/engine-lightpanda.js +1 -0
  34. package/dist/host.d.ts +7 -0
  35. package/dist/host.js +330 -68
  36. package/dist/human-input.d.ts +5 -0
  37. package/dist/human-input.js +1 -1
  38. package/dist/human-step-overlay.d.ts +73 -0
  39. package/dist/human-step-overlay.js +285 -0
  40. package/dist/human-step.d.ts +128 -0
  41. package/dist/human-step.js +521 -0
  42. package/dist/index.d.ts +2 -2
  43. package/dist/index.js +2 -2
  44. package/dist/live-server.d.ts +7 -3
  45. package/dist/live-server.js +13 -15
  46. package/dist/live.d.ts +20 -1
  47. package/dist/live.js +52 -10
  48. package/dist/login.d.ts +22 -2
  49. package/dist/login.js +95 -7
  50. package/dist/network-redact.d.ts +28 -0
  51. package/dist/network-redact.js +202 -0
  52. package/dist/recorder.d.ts +0 -21
  53. package/dist/recorder.js +1 -41
  54. package/dist/recordings.d.ts +5 -0
  55. package/dist/recordings.js +4 -2
  56. package/dist/redact.d.ts +7 -0
  57. package/dist/redact.js +32 -1
  58. package/dist/replay.d.ts +2 -0
  59. package/dist/replay.js +33 -14
  60. package/dist/reputation.d.ts +5 -0
  61. package/dist/reputation.js +12 -7
  62. package/dist/sensitive.d.ts +79 -0
  63. package/dist/sensitive.js +275 -0
  64. package/dist/session.d.ts +12 -0
  65. package/dist/session.js +24 -0
  66. package/dist/settings.d.ts +12 -2
  67. package/dist/settings.js +14 -2
  68. package/dist/tools.d.ts +5 -0
  69. package/dist/tools.js +9 -1
  70. package/dist/tuning.d.ts +4 -1
  71. package/dist/tuning.js +1 -0
  72. package/dist/upstream.d.ts +5 -0
  73. package/dist/watch.d.ts +60 -0
  74. package/dist/watch.js +114 -0
  75. package/npm-shrinkwrap.json +2 -2
  76. package/package.json +1 -1
package/dist/recorder.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AUTO_PREFIX, FlowError, FLOW_FORMAT_VERSION, MAX_FLOW_STEPS, assertFlowName, describeStep, flowPath, getPath, rotateAutoFlows, setPath, writeFlow, } from "./flows.js";
2
2
  import { existsSync } from "node:fs";
3
+ import { secretField } from "./sensitive.js";
3
4
  import { upstream } from "./upstream.js";
4
5
  /**
5
6
  * Flow recording. While a session records (the agent called `browser_record`, or the
@@ -47,47 +48,6 @@ function recordsTool(name, args) {
47
48
  // Listing tabs changes nothing.
48
49
  return !(name === "browser_tabs" && (args.action ?? "list") === "list");
49
50
  }
50
- export const SECRET_AUTOCOMPLETE = /(^|\s)(current-password|new-password|one-time-code|cc-number|cc-csc|cc-exp(-month|-year)?)(\s|$)/i;
51
- export const SECRET_NAME = /pass(word|wd|code)?|pwd|otp|totp|2fa|mfa|(^|[^a-z])pin([^a-z]|$)|cvv|cvc|csc|secret|token|ssn/i;
52
- /** A field whose typed value must never be stored. */
53
- export function secretField(info) {
54
- if (info.type === "password")
55
- return true;
56
- if (SECRET_AUTOCOMPLETE.test(info.autocomplete))
57
- return true;
58
- return SECRET_NAME.test(`${info.name} ${info.id}`);
59
- }
60
- /**
61
- * The values a `browser_type` or `browser_fill_form` call is about to put into secret fields
62
- * (`secretField`), so a recording can stop its trace first. A target the page cannot resolve
63
- * counts as not secret: the call then fails the same way.
64
- */
65
- export async function secretValues(page, tool, args) {
66
- const pairs = tool === "browser_type"
67
- ? [[args.target, args.text]]
68
- : tool === "browser_fill_form" && Array.isArray(args.fields)
69
- ? args.fields
70
- .filter((f) => f.type === "textbox")
71
- .map((f) => [f.target, f.value])
72
- : [];
73
- const out = [];
74
- for (const [target, value] of pairs) {
75
- if (typeof target !== "string" || typeof value !== "string" || !value)
76
- continue;
77
- const locator = page.locator(REF.test(target) ? `aria-ref=${target}` : target);
78
- const info = await locator
79
- .evaluate((el) => ({
80
- type: (el.type || "").toLowerCase(),
81
- autocomplete: el.getAttribute("autocomplete") ?? "",
82
- name: el.getAttribute("name") ?? "",
83
- id: el.id,
84
- }), undefined, { timeout: 2_000 })
85
- .catch(() => undefined);
86
- if (info && secretField(info))
87
- out.push(value);
88
- }
89
- return out;
90
- }
91
51
  /** Playwright's attribute value syntax: `"Sign in"s` (exact) for role and text selectors. */
92
52
  function quoteExact(text) {
93
53
  return `"${text.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"s`;
@@ -58,6 +58,11 @@ export interface RecordingOptions {
58
58
  idleMs?: number;
59
59
  /** Why traces cannot be recorded in this session (another trace owner); screenshots still are. */
60
60
  noTraces?: string;
61
+ /**
62
+ * Runs before a trace is saved: the host reads the sensitive fields of every page, so a value
63
+ * the person typed since the last tool call joins the redactor and the search below finds it.
64
+ */
65
+ beforeSave?: () => Promise<void>;
61
66
  now?: () => Date;
62
67
  }
63
68
  /** The recording of one browser session (one launch). */
@@ -21,8 +21,9 @@ import { parseSize } from "./units.js";
21
21
  * - It starts again at the first call after every page that holds those values has navigated
22
22
  * away (the vault guard), so neither the filled form nor the request that sends it is traced.
23
23
  * - Each saved trace is read back and searched for the passwords, one-time codes and sensitive
24
- * values this server knows, in the encodings the redactor knows; a trace that holds one, or
25
- * that cannot be read while such values exist, is deleted.
24
+ * values this server knows (the values of the pages' password and one-time code fields are
25
+ * read just before), in the encodings the redactor knows; a trace that holds one, or that
26
+ * cannot be read while such values exist, is deleted.
26
27
  * - No screenshot is taken of a page while it holds those values. There is no video: a video
27
28
  * cannot leave the sign-in out.
28
29
  *
@@ -326,6 +327,7 @@ export class Recording {
326
327
  const entry = { file: name, from: this.segmentFrom, to: this.index.steps.length };
327
328
  if (entry.to < entry.from)
328
329
  entry.from = entry.to = 0;
330
+ await this.o.beforeSave?.().catch(() => { });
329
331
  try {
330
332
  await this.o.context.tracing.stop({ path: file });
331
333
  }
package/dist/redact.d.ts CHANGED
@@ -4,8 +4,15 @@ import type { ToolResult } from "./upstream.js";
4
4
  export declare function variantsOf(value: string): string[];
5
5
  export declare class Redactor {
6
6
  private readonly entries;
7
+ private readonly fields;
7
8
  /** Redact `value` from now on, shown as `[vault: <label>]`; `ttlMs` for a one-time code. */
8
9
  add(value: string, label: string, ttlMs?: number, now?: number): void;
10
+ /**
11
+ * Redact a value read from a sensitive field of a page, whoever typed it (the person, a page
12
+ * script), shown as `mark`; `ttlMs` for a one-time code. A value the vault already hides
13
+ * keeps its vault label.
14
+ */
15
+ addField(value: string, mark: string, ttlMs?: number, now?: number): void;
9
16
  /** True when there is something to redact. */
10
17
  get active(): boolean;
11
18
  /** True when `text` holds a value this redactor hides, in any of its forms. */
package/dist/redact.js CHANGED
@@ -32,18 +32,48 @@ export function variantsOf(value) {
32
32
  out.add(htmlEscape(value));
33
33
  return [...out].filter((v) => v.length >= MIN_LENGTH);
34
34
  }
35
+ /** Most values read from sensitive fields kept at once; the oldest go first. */
36
+ const MAX_FIELD_VALUES = 256;
35
37
  export class Redactor {
36
38
  entries = new Map();
39
+ fields = new Set();
37
40
  /** Redact `value` from now on, shown as `[vault: <label>]`; `ttlMs` for a one-time code. */
38
41
  add(value, label, ttlMs, now = Date.now()) {
39
42
  if (value.length < MIN_LENGTH)
40
43
  return;
44
+ this.fields.delete(value);
41
45
  this.entries.set(value, {
42
46
  label,
43
47
  variants: variantsOf(value),
44
48
  ...(ttlMs !== undefined ? { until: now + ttlMs } : {}),
45
49
  });
46
50
  }
51
+ /**
52
+ * Redact a value read from a sensitive field of a page, whoever typed it (the person, a page
53
+ * script), shown as `mark`; `ttlMs` for a one-time code. A value the vault already hides
54
+ * keeps its vault label.
55
+ */
56
+ addField(value, mark, ttlMs, now = Date.now()) {
57
+ if (value.length < MIN_LENGTH)
58
+ return;
59
+ const known = this.entries.get(value);
60
+ if (known && !this.fields.has(value))
61
+ return;
62
+ this.fields.delete(value);
63
+ this.fields.add(value);
64
+ this.entries.set(value, {
65
+ label: "sensitive field",
66
+ mark,
67
+ variants: variantsOf(value),
68
+ ...(ttlMs !== undefined ? { until: now + ttlMs } : {}),
69
+ });
70
+ for (const old of this.fields) {
71
+ if (this.fields.size <= MAX_FIELD_VALUES)
72
+ break;
73
+ this.fields.delete(old);
74
+ this.entries.delete(old);
75
+ }
76
+ }
47
77
  /** True when there is something to redact. */
48
78
  get active() {
49
79
  return this.entries.size > 0;
@@ -73,10 +103,11 @@ export class Redactor {
73
103
  for (const [value, e] of this.entries) {
74
104
  if (e.until !== undefined && now > e.until) {
75
105
  this.entries.delete(value);
106
+ this.fields.delete(value);
76
107
  continue;
77
108
  }
78
109
  for (const v of e.variants)
79
- pairs.push([v, `[vault: ${e.label}]`]);
110
+ pairs.push([v, e.mark ?? `[vault: ${e.label}]`]);
80
111
  }
81
112
  // Longest first, so a value inside another value's encoding is handled by the longer one.
82
113
  pairs.sort((a, b) => b[0].length - a[0].length);
package/dist/replay.d.ts CHANGED
@@ -5,6 +5,8 @@ export declare function replayTool(): TurnoTool;
5
5
  export declare function flowsTool(): TurnoTool;
6
6
  export interface ReplayOptions {
7
7
  params?: Record<string, string>;
8
+ /** The sensitive parameters the person typed at a hidden prompt, so they may go into a password field. */
9
+ prompted?: readonly string[];
8
10
  from?: number;
9
11
  headless?: boolean;
10
12
  env?: NodeJS.ProcessEnv;
package/dist/replay.js CHANGED
@@ -70,11 +70,9 @@ async function findTarget(stock, target, ms, signal) {
70
70
  await sleep(250);
71
71
  }
72
72
  }
73
- /** Whether a step puts a sensitive value into the page. */
74
- function typesSecret(step, secret) {
75
- return paramRefs(step.args).some((name) => secret.has(name));
76
- }
77
- async function runStep(run, step, values, secret) {
73
+ async function runStep(run, step, values, secret,
74
+ /** The sensitive parameters the agent did not pass: read from the secret store, or typed by the person. */
75
+ trusted) {
78
76
  const { ctx, stock } = run;
79
77
  if (step.tool === "browser_login") {
80
78
  try {
@@ -102,7 +100,7 @@ async function runStep(run, step, values, secret) {
102
100
  const prepared = await prepareParams(ctx, inner, given);
103
101
  if ("error" in prepared)
104
102
  return { ok: false, message: prepared.error };
105
- const state = await runSteps({ ...run, depth: run.depth + 1 }, inner, prepared.values, prepared.secret, 1);
103
+ const state = await runSteps({ ...run, depth: run.depth + 1 }, inner, prepared.values, prepared.secret, prepared.trusted, 1);
106
104
  if (state.failure)
107
105
  return {
108
106
  ok: false,
@@ -139,19 +137,25 @@ async function runStep(run, step, values, secret) {
139
137
  const parsed = schema.safeParse(args);
140
138
  if (!parsed.success)
141
139
  return { ok: false, message: `invalid arguments: ${stock.formatError(parsed.error)}` };
142
- if (typesSecret(step, secret))
140
+ const secrets = paramRefs(step.args).filter((name) => secret.has(name));
141
+ if (secrets.length)
143
142
  await ctx.recording?.pauseForSecret(stock.currentPage());
144
- const result = await stock.call(step.tool, args, { snapshot: false });
143
+ // A password or one-time code field takes only a value the agent did not pass.
144
+ const fromSecretStore = secrets.length > 0 && secrets.every((name) => trusted.has(name));
145
+ const result = await stock.call(step.tool, args, {
146
+ snapshot: false,
147
+ ...(fromSecretStore ? { fromSecretStore } : {}),
148
+ });
145
149
  if (result.isError)
146
150
  return { ok: false, message: sections(textOf(result)).get("Error") ?? textOf(result) };
147
151
  return { ok: true, ...(used.length ? { note: `found by ${used.join(", ")}` } : {}) };
148
152
  }
149
- async function runSteps(run, flow, values, secret, from) {
153
+ async function runSteps(run, flow, values, secret, trusted, from) {
150
154
  const state = { lines: [] };
151
155
  const total = flow.steps.length;
152
156
  for (let i = from - 1; i < total; i++) {
153
157
  const step = flow.steps[i];
154
- const done = await runStep(run, step, values, secret);
158
+ const done = await runStep(run, step, values, secret, trusted);
155
159
  if (!done.ok) {
156
160
  state.lines.push(`${i + 1}. ${describeStep(step)}: failed`);
157
161
  state.failure = { n: i + 1, total, step, message: done.message };
@@ -178,6 +182,9 @@ async function prepareParams(ctx, flow, given) {
178
182
  };
179
183
  const secret = new Set();
180
184
  const refs = new Set();
185
+ // Sensitive values the person typed at the hidden prompt of `turno-browser replay`.
186
+ const prompted = new Set((vault.identity.env[PROMPTED_ENV] ?? "").split(",").filter(Boolean));
187
+ const trusted = new Set();
181
188
  for (const p of flow.params) {
182
189
  let v = values[p.name];
183
190
  if (v.startsWith("keychain:")) {
@@ -193,14 +200,18 @@ async function prepareParams(ctx, flow, given) {
193
200
  v = read;
194
201
  values[p.name] = v;
195
202
  refs.add(p.name);
203
+ trusted.add(p.name);
196
204
  secret.add(p.name);
197
205
  }
198
- else if (p.sensitive)
206
+ else if (p.sensitive) {
199
207
  secret.add(p.name);
208
+ if (prompted.has(p.name))
209
+ trusted.add(p.name);
210
+ }
200
211
  if (secret.has(p.name))
201
212
  vault.redactor.add(v, `sensitive parameter ${p.name}`);
202
213
  }
203
- return { values, secret, refs };
214
+ return { values, secret, refs, trusted };
204
215
  }
205
216
  function replaySchema() {
206
217
  const z = upstream().utils.z;
@@ -266,7 +277,7 @@ export function replayTool() {
266
277
  if ("error" in prepared)
267
278
  return { content: [{ type: "text", text: `### Error\nNothing ran: ${prepared.error}` }], isError: true };
268
279
  const run = { ctx, stock, waitMs: wait * 1000, depth: 0 };
269
- const exec = () => runSteps(run, flow, prepared.values, prepared.secret, from);
280
+ const exec = () => runSteps(run, flow, prepared.values, prepared.secret, prepared.trusted, from);
270
281
  const state = ctx.recorder ? await ctx.recorder.suspend(exec) : await exec();
271
282
  const out = [];
272
283
  if (state.failure) {
@@ -345,6 +356,11 @@ export function flowsTool() {
345
356
  },
346
357
  };
347
358
  }
359
+ /**
360
+ * Names the parameters of `ReplayOptions.prompted` for the server `replayFlow` starts. Only
361
+ * that server, which serves this one replay and no agent, reads it.
362
+ */
363
+ const PROMPTED_ENV = "TURNO_BROWSER_PROMPTED_PARAMS";
348
364
  /**
349
365
  * Replays a flow outside an agent (`turno browser replay`): starts this package's MCP server
350
366
  * on the identity and calls `browser_replay`, so the run goes through exactly the path an agent's
@@ -358,7 +374,10 @@ export async function replayFlow(id, flow, options = {}) {
358
374
  const transport = new StdioClientTransport({
359
375
  command: process.execPath,
360
376
  args: [bin, "--identity", id, ...(options.headless ? ["--headless"] : [])],
361
- env: Object.fromEntries(Object.entries(env).filter((e) => e[1] !== undefined)),
377
+ env: {
378
+ ...Object.fromEntries(Object.entries(env).filter((e) => e[1] !== undefined && e[0] !== PROMPTED_ENV)),
379
+ ...(options.prompted?.length ? { [PROMPTED_ENV]: options.prompted.join(",") } : {}),
380
+ },
362
381
  stderr: "pipe",
363
382
  });
364
383
  const client = new Client({ name: `${names().browser} replay`, version: "1" });
@@ -80,6 +80,11 @@ export interface WatchOptions {
80
80
  /** The same site and kind within this long counts once (a reload loop). */
81
81
  dedupeMs?: number;
82
82
  now?: () => number;
83
+ /**
84
+ * Hears every check of a page load as it starts, with what it will find (any challenge, also
85
+ * one the log counts once), so a tool result can say the page it ended on is one.
86
+ */
87
+ onCheck?: (page: WatchedPage, found: Promise<Omit<ChallengeEvent, "ts"> | undefined>) => void;
83
88
  }
84
89
  /**
85
90
  * Looks at every page the context loads (each main frame `load`, popups included) and reports
@@ -162,30 +162,35 @@ export function watchChallenges(context, onChallenge, opts = {}) {
162
162
  try {
163
163
  const url = new URL(page.url());
164
164
  if (url.protocol !== "http:" && url.protocol !== "https:")
165
- return;
165
+ return undefined;
166
166
  site = url.hostname;
167
167
  }
168
168
  catch {
169
- return;
169
+ return undefined;
170
170
  }
171
171
  const html = await page.content().catch(() => undefined);
172
172
  if (stopped || html === undefined)
173
- return;
173
+ return undefined;
174
174
  const found = classifyChallenge(html);
175
175
  if (!found)
176
- return;
176
+ return undefined;
177
+ const event = { site, kind: found.kind, markers: found.markers };
177
178
  const key = `${site}\n${found.kind}`;
178
179
  const t = now();
179
180
  const previous = last.get(key);
180
181
  if (previous !== undefined && t - previous < dedupeMs)
181
- return;
182
+ return event;
182
183
  last.set(key, t);
183
- onChallenge({ site, kind: found.kind, markers: found.markers });
184
+ onChallenge(event);
185
+ return event;
184
186
  };
185
187
  const attach = (page) => {
186
188
  if (listeners.has(page))
187
189
  return;
188
- const listener = () => void inspect(page).catch(() => { });
190
+ const listener = () => {
191
+ const found = inspect(page).catch(() => undefined);
192
+ opts.onCheck?.(page, found);
193
+ };
189
194
  listeners.set(page, listener);
190
195
  page.on("load", listener);
191
196
  };
@@ -0,0 +1,79 @@
1
+ import type { Page } from "patchright-core";
2
+ /**
3
+ * Sensitive fields: the one classifier for the inputs whose value the model must never read
4
+ * or write, shared by the host (snapshots, results, the refusal of `browser_type`), flow
5
+ * recording and natural language actions.
6
+ *
7
+ * - `password` and `one-time code` are the sensitive fields: an input of type password, an
8
+ * `autocomplete` of `current-password`, `new-password` or `one-time-code`, or a name or id
9
+ * that reads like one (`password`, `passcode`, `otp`, `totp`, `2fa`, `mfa`, `oneTimeCode`). The
10
+ * host masks their values in every snapshot, hides them in every result, and refuses an agent
11
+ * that types into them: the person types those, or `browser_login` fills them from the vault.
12
+ * - `card` and `secret` (a card number, a PIN, a field named like a token or a secret) are
13
+ * never kept in a flow and never sent to a natural language model, but the agent may fill them.
14
+ *
15
+ * The page is read once per frame (open shadow roots included); the values never leave this
16
+ * process except as the redactor's placeholders.
17
+ */
18
+ export type FieldKind = "password" | "one-time code" | "card" | "secret";
19
+ /** What the page says about an input, enough to classify it. */
20
+ export interface FieldInfo {
21
+ type: string;
22
+ autocomplete: string;
23
+ name: string;
24
+ id: string;
25
+ }
26
+ /** An input of the page with a value, as `pageFields` reads it. */
27
+ export interface PageField extends FieldInfo {
28
+ value: string;
29
+ /** The snapshot ref Playwright gave the element (`e12`, `f1e3`), when it is in a snapshot. */
30
+ ref?: string;
31
+ kind?: FieldKind;
32
+ }
33
+ /** What a masked value reads in a snapshot. */
34
+ export declare const SENSITIVE_MARK = "[sensitive field]";
35
+ /** The words of a name: `newPassword`, `new-password` and `new_password` are `new password`. */
36
+ export declare function wordsOf(name: string): string[];
37
+ /** The kind of a field, or undefined when its value is nobody's secret. */
38
+ export declare function fieldKind(info: FieldInfo): FieldKind | undefined;
39
+ /** A field whose typed value must never be stored (a flow, a natural language prompt). */
40
+ export declare function secretField(info: FieldInfo): boolean;
41
+ /**
42
+ * The inputs with a value in every frame of `page` and the kind of each: one evaluate per
43
+ * frame, in parallel. A frame that cannot be read (navigating, detached) is skipped.
44
+ */
45
+ export declare function pageFields(page: Page): Promise<PageField[]>;
46
+ /** The sensitive fields (`sensitiveKind`) of `page` that hold a value. */
47
+ export declare function sensitiveFields(page: Page): Promise<PageField[]>;
48
+ /**
49
+ * An aria snapshot (`mode: "ai"`) with the value of each element in `refs` replaced by
50
+ * `SENSITIVE_MARK`: `- textbox "Password" [ref=e6]: hunter2` reads
51
+ * `- textbox "Password" [ref=e6]: [sensitive field]`, whatever the length of the value.
52
+ */
53
+ export declare function maskSnapshot(text: string, refs: ReadonlySet<string>): string;
54
+ /** The same masking on the JSON form of an aria snapshot (`ariaSnapshotJSON`). */
55
+ export declare function maskSnapshotJSON<T>(json: T, refs: ReadonlySet<string>): T;
56
+ /** The refs of the sensitive fields among `fields`. */
57
+ export declare function sensitiveRefs(fields: readonly PageField[]): Set<string>;
58
+ /**
59
+ * Makes every aria snapshot of `page` mask its sensitive fields: Playwright MCP takes the page
60
+ * snapshot of a tool result with `page.ariaSnapshot` (or `ariaSnapshotJSON` in JSON mode), and
61
+ * writes it to a file or puts it in the result right after. The fields are read after the
62
+ * snapshot, so the refs are the ones it just gave; `onFields` hears them first (the host's
63
+ * redactor learns the values, for the rest of the result). Undone with the returned function.
64
+ */
65
+ export declare function maskSnapshots(page: Page, onFields: (fields: PageField[]) => void): () => void;
66
+ /** The stock tools that type text, and the arguments that say where. */
67
+ export declare const TYPING_TOOLS: ReadonlySet<string>;
68
+ /**
69
+ * The kind of sensitive field a typing call would put text into, or undefined. A target the
70
+ * page cannot resolve counts as not sensitive: the call then fails the same way.
71
+ */
72
+ export declare function typesIntoSensitive(page: Page, tool: string, args: Record<string, unknown>): Promise<"password" | "one-time code" | undefined>;
73
+ /** The error of a typing call into a sensitive field. */
74
+ export declare function sensitiveRefusal(tool: string, kind: "password" | "one-time code"): string;
75
+ /**
76
+ * The values `browser_type` or `browser_fill_form` would put into secret fields (`secretField`),
77
+ * so a recording can stop its trace first.
78
+ */
79
+ export declare function secretValues(page: Page, tool: string, args: Record<string, unknown>): Promise<string[]>;