dsh-browser-playwright-codex 0.5.1

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 (45) hide show
  1. package/CHANGELOG.md +486 -0
  2. package/LICENSE +21 -0
  3. package/README.md +322 -0
  4. package/SECURITY.md +114 -0
  5. package/cordis.patch.yml +66 -0
  6. package/lib/cdp-policy.d.ts +69 -0
  7. package/lib/cdp-policy.js +105 -0
  8. package/lib/compat.d.ts +37 -0
  9. package/lib/compat.js +31 -0
  10. package/lib/contract.d.ts +74 -0
  11. package/lib/contract.js +117 -0
  12. package/lib/errors.d.ts +25 -0
  13. package/lib/errors.js +21 -0
  14. package/lib/index.d.ts +20 -0
  15. package/lib/index.js +12 -0
  16. package/lib/injected.d.ts +35 -0
  17. package/lib/injected.js +350 -0
  18. package/lib/playwright.d.ts +647 -0
  19. package/lib/playwright.js +2515 -0
  20. package/lib/runtime-state.d.ts +45 -0
  21. package/lib/runtime-state.js +181 -0
  22. package/lib/service.d.ts +56 -0
  23. package/lib/service.js +96 -0
  24. package/lib/snapshot-aria.d.ts +121 -0
  25. package/lib/snapshot-aria.js +485 -0
  26. package/lib/snapshot-render.d.ts +28 -0
  27. package/lib/snapshot-render.js +100 -0
  28. package/lib/tool.d.ts +77 -0
  29. package/lib/tool.js +907 -0
  30. package/lib/types.d.ts +242 -0
  31. package/lib/types.js +5 -0
  32. package/locale/en.json +6 -0
  33. package/locale/zh.json +6 -0
  34. package/package.json +108 -0
  35. package/scripts/analysis/hl-compare.mjs +149 -0
  36. package/scripts/analysis/live-handoff-probe.mjs +97 -0
  37. package/scripts/analysis/needs-human-probe.mjs +83 -0
  38. package/scripts/analysis/repro-minimize.mjs +112 -0
  39. package/scripts/autocommit.ps1 +23 -0
  40. package/scripts/check-doc-links.py +112 -0
  41. package/scripts/doctor.mjs +144 -0
  42. package/scripts/dsh-browser-verify.mjs +475 -0
  43. package/scripts/measure-prompt-cost.mjs +57 -0
  44. package/scripts/prompt-cost.mjs +73 -0
  45. package/scripts/shipped-gates.mjs +43 -0
package/lib/tool.d.ts ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Model-facing browser tool family: navigate, snapshot with refs, click,
3
+ * hover, fill, press, scroll, history, tabs, screenshot, extract, evaluate,
4
+ * close.
5
+ * Every tool acquires the calling session's browser through ctx.browser, so
6
+ * the browser persists across calls. Persistent mode shares one profile-backed
7
+ * window across sessions (personal-browser style). Outputs follow the
8
+ * canonical-value + pure-render contract.
9
+ * @module dsh-browser-playwright-codex/tool
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ import z from '@deepseek-ai/schemastery';
13
+ /** Cordis plugin name used by loader diagnostics. */
14
+ export declare const name = "browser-tool";
15
+ /** The browser runtime and tool registry this plugin consumes. */
16
+ export declare const inject: string[];
17
+ /** Configuration for the browser tool family. */
18
+ export interface ToolConfig {
19
+ /** Tool name prefix; final names are <prefix>navigate and so on. */
20
+ toolPrefix: string;
21
+ /** Allow browser_evaluate (arbitrary page JavaScript). Defaults to false. */
22
+ allowEvaluate: boolean;
23
+ /** Allow raw CDP inspection commands. Defaults to false. */
24
+ allowCdp: boolean;
25
+ /**
26
+ * Register the gated tools (evaluate, cdp, extract) even when their
27
+ * capability is off, so the model can discover them and read the error that
28
+ * names the switch. Defaults to false: a disabled tool can only error, and
29
+ * its schema would sit in the system prompt on every turn for nothing.
30
+ */
31
+ registerDisabledTools: boolean;
32
+ /** Upper bound for browser_wait in milliseconds. */
33
+ maxWaitMs: number;
34
+ /** Default value of the snapshot tool's interactiveOnly flag. */
35
+ interactiveOnlyDefault: boolean;
36
+ /** Auxiliary extraction configuration; omitted means browser_extract is unconfigured. */
37
+ extract?: {
38
+ provider?: string;
39
+ model?: string;
40
+ maxInputChars: number;
41
+ maxOutputTokens: number;
42
+ };
43
+ }
44
+ /** Minimal node shape the challenge detector walks. */
45
+ interface ChallengeNode {
46
+ readonly name?: string;
47
+ readonly children?: readonly ChallengeNode[];
48
+ }
49
+ /** The slice of a snapshot the challenge detector reads. */
50
+ interface ChallengeSnapshot {
51
+ readonly title?: string;
52
+ readonly url?: string;
53
+ readonly nodes?: readonly ChallengeNode[];
54
+ }
55
+ /** What the challenge detector reports when a page is an anti-bot wall. */
56
+ interface ChallengeMatch {
57
+ engine: string;
58
+ hint: string;
59
+ }
60
+ /** Schemastery validation for {@link ToolConfig}. */
61
+ export declare const Config: z<ToolConfig>;
62
+ /**
63
+ * Detect anti-bot / human-verification challenge pages (Cloudflare
64
+ * interstitial, Turnstile, reCAPTCHA-style) from a snapshot's title, url and
65
+ * visible text. We do NOT try to solve them: the correct move for an agent is
66
+ * to hand the challenge to the human who can see the open window. Returns the
67
+ * engine name when matched, else null. Matching is conservative to avoid
68
+ * false positives on ordinary pages.
69
+ */
70
+ export declare function detectChallenge(snapshot: ChallengeSnapshot): ChallengeMatch | null;
71
+ /**
72
+ * Register the browser tool family on ctx.tools.
73
+ * @param ctx - plugin context carrying browser, tools, and the optional services.
74
+ * @param config - tool naming and safety configuration.
75
+ */
76
+ export declare function apply(ctx: Context, config: ToolConfig): void;
77
+ export {};