@jackwener/browsermcp 0.0.42-embedded.0 → 0.0.43

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 (102) hide show
  1. package/CHANGELOG.md +3 -60
  2. package/README.md +0 -91
  3. package/dist/docs/api-use.md +2 -0
  4. package/dist/src/api/api.js +3 -1
  5. package/dist/src/api/api.js.map +1 -1
  6. package/dist/src/api/tab.js +70 -0
  7. package/dist/src/api/tab.js.map +1 -1
  8. package/dist/src/docs/manifest.js +3 -6
  9. package/dist/src/docs/manifest.js.map +1 -1
  10. package/dist/src/mcp/server.js +3 -2
  11. package/dist/src/mcp/server.js.map +1 -1
  12. package/dist/src/runtime/runtime.js +28 -2
  13. package/dist/src/runtime/runtime.js.map +1 -1
  14. package/docs/api-use.md +2 -0
  15. package/package.json +2 -11
  16. package/dist/src/api/action-input.d.ts +0 -87
  17. package/dist/src/api/agent.d.ts +0 -10
  18. package/dist/src/api/api.d.ts +0 -54
  19. package/dist/src/api/browser.d.ts +0 -93
  20. package/dist/src/api/commands.d.ts +0 -514
  21. package/dist/src/api/content-wait.d.ts +0 -18
  22. package/dist/src/api/context.d.ts +0 -7
  23. package/dist/src/api/diff.d.ts +0 -8
  24. package/dist/src/api/errors.d.ts +0 -14
  25. package/dist/src/api/network.d.ts +0 -10
  26. package/dist/src/api/observation.d.ts +0 -4
  27. package/dist/src/api/streams.d.ts +0 -13
  28. package/dist/src/api/tab.d.ts +0 -352
  29. package/dist/src/api/webmcp.d.ts +0 -19
  30. package/dist/src/backends/backend.d.ts +0 -14
  31. package/dist/src/backends/browser-helpers.d.ts +0 -17
  32. package/dist/src/backends/extension-page.d.ts +0 -5
  33. package/dist/src/backends/managed-page.d.ts +0 -50
  34. package/dist/src/backends/page-transport.d.ts +0 -10
  35. package/dist/src/backends/page-types.d.ts +0 -82
  36. package/dist/src/docs/embedded.d.ts +0 -2
  37. package/dist/src/docs/embedded.js +0 -40
  38. package/dist/src/docs/embedded.js.map +0 -1
  39. package/dist/src/docs/manifest.d.ts +0 -23
  40. package/dist/src/docs/surface.d.ts +0 -12
  41. package/dist/src/electron/backend.d.ts +0 -50
  42. package/dist/src/electron/backend.js +0 -377
  43. package/dist/src/electron/backend.js.map +0 -1
  44. package/dist/src/electron/chrome.d.ts +0 -24
  45. package/dist/src/electron/chrome.js +0 -133
  46. package/dist/src/electron/chrome.js.map +0 -1
  47. package/dist/src/electron/driver.d.ts +0 -70
  48. package/dist/src/electron/driver.js +0 -316
  49. package/dist/src/electron/driver.js.map +0 -1
  50. package/dist/src/electron/event-buffer.d.ts +0 -16
  51. package/dist/src/electron/event-buffer.js +0 -59
  52. package/dist/src/electron/event-buffer.js.map +0 -1
  53. package/dist/src/electron/page.js +0 -1030
  54. package/dist/src/electron/registry.d.ts +0 -104
  55. package/dist/src/electron/registry.js +0 -316
  56. package/dist/src/electron/registry.js.map +0 -1
  57. package/dist/src/electron/streams.d.ts +0 -16
  58. package/dist/src/electron/streams.js +0 -48
  59. package/dist/src/electron/streams.js.map +0 -1
  60. package/dist/src/embedded/index.d.ts +0 -49
  61. package/dist/src/embedded/index.js +0 -85
  62. package/dist/src/embedded/index.js.map +0 -1
  63. package/dist/src/host/bridge.d.ts +0 -50
  64. package/dist/src/host/doctor.d.ts +0 -34
  65. package/dist/src/host/extension.d.ts +0 -3
  66. package/dist/src/host/host.d.ts +0 -3
  67. package/dist/src/host/ipc.d.ts +0 -14
  68. package/dist/src/host/jsonc-config.d.ts +0 -1
  69. package/dist/src/host/launch.d.ts +0 -11
  70. package/dist/src/host/native-messaging.d.ts +0 -28
  71. package/dist/src/host/opencode.d.ts +0 -6
  72. package/dist/src/host/pi.d.ts +0 -6
  73. package/dist/src/host/registration.d.ts +0 -24
  74. package/dist/src/host/setup.d.ts +0 -7
  75. package/dist/src/host/socket.d.ts +0 -25
  76. package/dist/src/host/state.d.ts +0 -39
  77. package/dist/src/launcher/stdio.d.ts +0 -3
  78. package/dist/src/lib/paths.d.ts +0 -1
  79. package/dist/src/lib/sources.d.ts +0 -5
  80. package/dist/src/main.d.ts +0 -2
  81. package/dist/src/mcp/catalog.d.ts +0 -202
  82. package/dist/src/mcp/js-session.d.ts +0 -64
  83. package/dist/src/mcp/server.d.ts +0 -15
  84. package/dist/src/protocol.d.ts +0 -340
  85. package/dist/src/recon/analyzer.d.ts +0 -43
  86. package/dist/src/recon/discover.d.ts +0 -48
  87. package/dist/src/runtime/runtime.d.ts +0 -230
  88. package/dist/src/shared/api-contract.d.ts +0 -86
  89. package/dist/src/shared/aria-tree.d.ts +0 -2
  90. package/dist/src/shared/closed-shadow.d.ts +0 -10
  91. package/dist/src/shared/element-ref.d.ts +0 -4
  92. package/dist/src/shared/engine.d.ts +0 -62
  93. package/dist/src/shared/inflight.d.ts +0 -14
  94. package/dist/src/shared/injected-source.d.ts +0 -2
  95. package/dist/src/shared/page-contract.d.ts +0 -278
  96. package/dist/src/sites/define.d.ts +0 -28
  97. package/dist/src/sites/drafts.d.ts +0 -39
  98. package/dist/src/sites/executor.d.ts +0 -34
  99. package/dist/src/sites/loader.d.ts +0 -101
  100. package/dist/src/sites/manifest.d.ts +0 -5
  101. package/dist/src/sites/schema.d.ts +0 -11
  102. package/dist/src/version.d.ts +0 -2
@@ -1,86 +0,0 @@
1
- /** Executable contracts shared by the public API, backend discovery and documentation. */
2
- import { z } from 'zod';
3
- /** Internal RPC function source; user data objects cannot impersonate this marker. */
4
- export declare class PageFunction {
5
- readonly source: string;
6
- constructor(source: string);
7
- }
8
- export declare function parseInput<T>(method: string, schema: z.ZodType<T>, input: unknown): T;
9
- export declare function checkArity(method: string, count: number, min: number, max: number): void;
10
- export declare const evaluateOptions: z.ZodObject<{
11
- arg: z.ZodOptional<z.ZodUnknown>;
12
- frame: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>]>>;
13
- timeoutMs: z.ZodOptional<z.ZodNumber>;
14
- }, z.core.$strict>;
15
- export type EvaluateOptions = z.infer<typeof evaluateOptions>;
16
- /** Reject values that JSON would silently drop or alter. Undefined is only allowed as the root argument. */
17
- export declare function pageArgument(value: unknown): string;
18
- export declare const discoveryOptions: z.ZodObject<{
19
- query: z.ZodOptional<z.ZodString>;
20
- limit: z.ZodOptional<z.ZodNumber>;
21
- offset: z.ZodOptional<z.ZodNumber>;
22
- }, z.core.$strict>;
23
- export type TabDiscoveryOptions = z.infer<typeof discoveryOptions>;
24
- export declare const userTabInfo: z.ZodObject<{
25
- tabId: z.ZodNumber;
26
- title: z.ZodOptional<z.ZodString>;
27
- url: z.ZodOptional<z.ZodString>;
28
- windowId: z.ZodNumber;
29
- active: z.ZodBoolean;
30
- groupId: z.ZodOptional<z.ZodNumber>;
31
- lastAccessed: z.ZodOptional<z.ZodNumber>;
32
- lifecycle: z.ZodOptional<z.ZodEnum<{
33
- ready: "ready";
34
- loading: "loading";
35
- dormant: "dormant";
36
- }>>;
37
- availability: z.ZodOptional<z.ZodEnum<{
38
- ready: "ready";
39
- load_required: "load_required";
40
- host_attachment_required: "host_attachment_required";
41
- }>>;
42
- }, z.core.$strict>;
43
- export type UserTabInfo = z.infer<typeof userTabInfo>;
44
- export declare const discoveryResult: z.ZodObject<{
45
- scope: z.ZodLiteral<"unclaimed">;
46
- query: z.ZodString;
47
- matching: z.ZodLiteral<"case-insensitive-substring">;
48
- totalVisible: z.ZodNumber;
49
- totalInScope: z.ZodNumber;
50
- excluded: z.ZodObject<{
51
- owned: z.ZodNumber;
52
- unsupported: z.ZodNumber;
53
- }, z.core.$strict>;
54
- matched: z.ZodNumber;
55
- offset: z.ZodNumber;
56
- limit: z.ZodNumber;
57
- hasMore: z.ZodBoolean;
58
- nextOffset: z.ZodOptional<z.ZodNumber>;
59
- items: z.ZodArray<z.ZodObject<{
60
- tabId: z.ZodNumber;
61
- title: z.ZodOptional<z.ZodString>;
62
- url: z.ZodOptional<z.ZodString>;
63
- windowId: z.ZodNumber;
64
- active: z.ZodBoolean;
65
- groupId: z.ZodOptional<z.ZodNumber>;
66
- lastAccessed: z.ZodOptional<z.ZodNumber>;
67
- lifecycle: z.ZodOptional<z.ZodEnum<{
68
- ready: "ready";
69
- loading: "loading";
70
- dormant: "dormant";
71
- }>>;
72
- availability: z.ZodOptional<z.ZodEnum<{
73
- ready: "ready";
74
- load_required: "load_required";
75
- host_attachment_required: "host_attachment_required";
76
- }>>;
77
- }, z.core.$strict>>;
78
- }, z.core.$strict>;
79
- export type TabDiscoveryResult = z.infer<typeof discoveryResult>;
80
- export type TabInventoryEntry = {
81
- tab: UserTabInfo;
82
- owned: boolean;
83
- supported: boolean;
84
- };
85
- /** One snapshot, then scope → literal query → recency order → pagination. Never loads or claims a tab. */
86
- export declare function discoverTabs(inventory: TabInventoryEntry[], input?: TabDiscoveryOptions): TabDiscoveryResult;
@@ -1,2 +0,0 @@
1
- /** Compact a serialized ARIA tree without discarding unique names or control state. */
2
- export declare function compactAria(text: string): string;
@@ -1,10 +0,0 @@
1
- export interface ShadowIO {
2
- /** Evaluate in the frame's engine world and return a remote object id (undefined for null/undefined results). */
3
- evaluateHandle(expression: string): Promise<string | undefined>;
4
- /** A CDP command on the session that owns the frame. */
5
- cdp(method: string, params: Record<string, unknown>): Promise<any>;
6
- /** The engine world's execution context id on that session. */
7
- engineContextId(): Promise<number>;
8
- }
9
- /** Adopt the closed shadow roots of new candidate hosts. Returns how many were adopted; never throws. */
10
- export declare function adoptClosedShadowRoots(io: ShadowIO): Promise<number>;
@@ -1,4 +0,0 @@
1
- /** Public element refs are opaque; older connected extensions may still emit unscoped refs. */
2
- export declare const ELEMENT_REF_SOURCE: string;
3
- export declare const ELEMENT_REF: RegExp;
4
- export declare const ARIA_REF_LINE: RegExp;
@@ -1,62 +0,0 @@
1
- import type { ActSpec, ActResult, ActTarget, FrameStep } from '../protocol.js';
2
- export { ENGINE_GLOBAL, PAGE_GLOBAL } from './page-contract.js';
3
- /** Evaluate once per world: installs Playwright's InjectedScript as globalThis.__browsermcpInjected, then the page module. */
4
- export declare function installEngineJs(injectedSource: string, pageModuleSource: string): string;
5
- /** The expression the host evaluates in a world to call one page-module function with JSON arguments. */
6
- export declare function pageCallJs(fn: string, args: unknown): string;
7
- export declare class ActError extends Error {
8
- readonly code: string;
9
- readonly hint?: string | undefined;
10
- readonly extra?: Record<string, unknown> | undefined;
11
- constructor(code: string, message: string, hint?: string | undefined, extra?: Record<string, unknown> | undefined);
12
- }
13
- /** Restore page errors after the JSON boundary, including observation and frame-routing failures. */
14
- export declare function unwrapPageResult(value: unknown): unknown;
15
- /** Compile an agent target into a Playwright selector (the same engines the plugin uses). */
16
- export declare function targetToSelector(t: ActTarget): string | null;
17
- /** Secondary selector tried when the primary finds nothing (e.g. label → placeholder). */
18
- export declare function fallbackSelector(t: ActTarget): string | null;
19
- /** Normalize `target.frame` into ordered steps (outermost first); accepts arrays and Codex's `a >> internal:control=enter-frame >> b`. */
20
- export declare function frameSteps(frame: FrameStep | FrameStep[] | undefined): FrameStep[];
21
- type KeyDef = {
22
- key: string;
23
- code: string;
24
- keyCode: number;
25
- text?: string;
26
- };
27
- export declare function parseKey(spec: string): {
28
- def: KeyDef;
29
- modifiers: number;
30
- };
31
- /** What a runtime edge provides: page-module calls in the target world, raw CDP on the attached target, cursor, navigation wait. */
32
- export interface ActIO {
33
- /** Call `globalThis.__browsermcpPage.<fn>(args)` in the world the action targets. */
34
- call(fn: string, args?: unknown, timeoutMs?: number): Promise<unknown>;
35
- cdp(method: string, params?: Record<string, unknown>): Promise<unknown>;
36
- /** Set files on the remembered Element in its owning isolated world/session. */
37
- setFiles?(files: string[]): Promise<void>;
38
- cursor?(x: number, y: number): Promise<unknown>;
39
- /** Resolve after a navigation the action triggered has finished (or when none started within classifyMs). */
40
- waitForNavigation?(classifyMs: number, timeoutMs: number): Promise<{
41
- navigated: boolean;
42
- url?: string;
43
- }>;
44
- /** When the world is a child frame: the frame's position in the top viewport — input events are dispatched on the tab. */
45
- pointOffset?: {
46
- x: number;
47
- y: number;
48
- };
49
- /** When the world is a child frame: call the same page-module function in the top document. */
50
- callTop?(fn: string, args?: unknown, timeoutMs?: number): Promise<unknown>;
51
- /** Requests started at or after `since` (Date.now() ms) still in flight, and ms since their last event. */
52
- network?(since: number): Promise<{
53
- pending: number;
54
- idleMs: number;
55
- }> | {
56
- pending: number;
57
- idleMs: number;
58
- };
59
- }
60
- /** Upper bound of the post-action wait. A quiet page ends it after QUIET_MS; only a busy page waits this long. */
61
- export declare const DEFAULT_SETTLE_MS = 1000;
62
- export declare function performAct(io: ActIO, spec: ActSpec): Promise<ActResult>;
@@ -1,14 +0,0 @@
1
- export declare class InflightRequests {
2
- private readonly started;
3
- private lastEventAt;
4
- note(method: string, params: {
5
- requestId?: string;
6
- type?: string;
7
- } | undefined): void;
8
- /** Requests started at or after `since` (Date.now() ms) still in flight, and ms since the last request event. */
9
- activity(since: number): {
10
- pending: number;
11
- idleMs: number;
12
- };
13
- private forgetHung;
14
- }
@@ -1,2 +0,0 @@
1
- export declare const INJECTED_SOURCE: string;
2
- export declare const INJECTED_VERSION = "1.63.0";
@@ -1,278 +0,0 @@
1
- import type { FrameStep } from '../protocol.js';
2
- /**
3
- * Contract between the host-side engine (src/shared/engine.ts) and the page-side module
4
- * (extension/src/page/index.ts) that runs inside the extension's isolated world next to Playwright's
5
- * InjectedScript. Only plain JSON crosses this boundary: the host calls `globalThis.__browsermcpPage.<fn>(args)`.
6
- */
7
- export declare const ENGINE_GLOBAL = "__browsermcpInjected";
8
- export declare const PAGE_GLOBAL = "__browsermcpPage";
9
- export interface ResolveArgs {
10
- selector: string;
11
- fallback: string | null;
12
- /** strict: several matches are only accepted when exactly one is visible */
13
- strict: boolean;
14
- /** actionability states to require, e.g. ['visible','enabled','editable'] */
15
- states: string[];
16
- align: {
17
- block: string;
18
- inline: string;
19
- };
20
- /** The requested accessible name: of several substring matches, the one whose whole name equals it is the target. */
21
- name?: string;
22
- }
23
- /** One of several matches: ref to act on, accessible role and name, and the region it sits in (named landmark, form, dialog or shadow host). */
24
- export interface Candidate {
25
- ref: string | null;
26
- role: string;
27
- name: string;
28
- within: string;
29
- tag: string;
30
- text: string;
31
- visible: boolean;
32
- box: Box;
33
- }
34
- export interface Box {
35
- x: number;
36
- y: number;
37
- w: number;
38
- h: number;
39
- }
40
- export interface Resolved {
41
- ok: true;
42
- x: number;
43
- y: number;
44
- matches_n: number;
45
- tag: string;
46
- hit: 'target' | 'other';
47
- blocker: string | null;
48
- editable: boolean;
49
- checkable: boolean;
50
- checked: boolean;
51
- isSelect: boolean;
52
- /** opaque Element ref shared across observation and action */
53
- ref: string | null;
54
- /** Playwright-generated selector for replay */
55
- selector: string | null;
56
- usedSelector: string;
57
- }
58
- export interface ResolveFail {
59
- error: {
60
- code: string;
61
- message: string;
62
- hint?: string;
63
- candidates?: Candidate[];
64
- };
65
- retry?: boolean;
66
- }
67
- export type ResolveOutcome = Resolved | ResolveFail;
68
- export interface FindArgs {
69
- name?: string;
70
- selector: string;
71
- fallback: string | null;
72
- limit: number;
73
- }
74
- export interface FindEntry {
75
- nth: number;
76
- ref: string | null;
77
- selector: string | null;
78
- tag: string;
79
- role: string;
80
- name: string;
81
- text: string;
82
- attrs: Record<string, string>;
83
- visible: boolean;
84
- enabled: boolean | null;
85
- editable: boolean | null;
86
- box: Box;
87
- }
88
- export interface FindResult {
89
- matches_n: number;
90
- visible_n: number;
91
- selector: string;
92
- entries: FindEntry[];
93
- }
94
- export interface QueryFindResult {
95
- matches_n: number;
96
- entries: Array<FindEntry & {
97
- path: string[];
98
- interactiveAncestorRef: string | null;
99
- }>;
100
- }
101
- export interface AriaArgs {
102
- name?: string;
103
- selector?: string;
104
- fallback?: string | null;
105
- /** only the subtree of elements intersecting the viewport */
106
- viewport?: boolean;
107
- /** open one branch of a previous snapshot (opaque ref). Ignores viewport so an off-screen branch can be read. */
108
- ref?: string;
109
- }
110
- /** Compact DOM evidence. Truncated fields can be read exactly with tab.read({target:{ref}}). */
111
- export interface DomEntry {
112
- ref: string;
113
- tag: string;
114
- text: string;
115
- attrs: Record<string, string>;
116
- truncated: boolean;
117
- }
118
- export interface DomSnapshot {
119
- entries: DomEntry[];
120
- total: number;
121
- start: number;
122
- nextStart?: number;
123
- scope: 'viewport' | 'document'; /** Continue the live control list with tab.observe(dom.next). */
124
- next?: {
125
- format: 'dom';
126
- frame?: FrameStep[];
127
- target?: Target;
128
- start: number;
129
- limit?: number;
130
- viewport: boolean;
131
- includeFrames: false;
132
- };
133
- }
134
- export interface ObserveFrameArgs extends AriaArgs {
135
- format?: 'aria' | 'dom';
136
- start?: number;
137
- limit?: number;
138
- }
139
- export interface FrameOwner {
140
- ref: string;
141
- id: string;
142
- name: string;
143
- src: string;
144
- }
145
- export interface FrameObservation {
146
- state?: string;
147
- dom?: DomSnapshot;
148
- children: FrameOwner[];
149
- warnings?: string[];
150
- }
151
- /** Full current DOM evidence for one element; no preview clipping. */
152
- export interface ElementDetails {
153
- ref: string;
154
- tag: string;
155
- name: string;
156
- text: string;
157
- attrs: Record<string, string>;
158
- }
159
- export interface ReadTextArgs {
160
- maxChars?: number;
161
- start?: number;
162
- readId?: string;
163
- maxSteps?: number;
164
- waitMs?: number;
165
- }
166
- /** Linear document text from one bounded scan. `readId` and `nextStart` continue that same capture. */
167
- export interface ReadTextResult {
168
- readId: string;
169
- text: string;
170
- complete: boolean;
171
- reason?: 'budget' | 'scan_limit' | 'unbounded' | 'stale';
172
- chars: number;
173
- start: number;
174
- nextStart?: number;
175
- }
176
- export interface DomClickArgs {
177
- name?: string;
178
- selector: string;
179
- fallback: string | null;
180
- }
181
- export interface UploadTarget {
182
- ok: true;
183
- ref: string | null;
184
- selector: string | null;
185
- matches_n: number;
186
- }
187
- export interface DomClickOk {
188
- ok: true;
189
- ref: string | null;
190
- tag: string;
191
- selector: string | null;
192
- x: number;
193
- y: number;
194
- }
195
- export type DomClickResult = DomClickOk | ResolveFail;
196
- export interface PointInfo {
197
- tag: string;
198
- editable: boolean;
199
- isSelect: boolean;
200
- }
201
- export interface FrameProbeResult {
202
- found: boolean;
203
- sameOrigin?: boolean;
204
- x?: number;
205
- y?: number;
206
- src?: string;
207
- }
208
- /** Page activity in the action's document: `n` counts real changes, `idleMs` is the time since the last one. */
209
- /** Rendered content of a document: its own URL, parse state, visible text length and first 200 characters. */
210
- export interface ContentProbe {
211
- href: string;
212
- ready: DocumentReadyState;
213
- chars: number;
214
- head: string;
215
- }
216
- export interface ActivityInfo {
217
- n: number;
218
- idleMs: number;
219
- ready: DocumentReadyState;
220
- url: string;
221
- doc: string;
222
- }
223
- export interface SelectResult {
224
- selected?: string[];
225
- error?: string;
226
- available?: string[];
227
- }
228
- export interface ElementAtResult {
229
- matches_n: number;
230
- entries: FindEntry[];
231
- }
232
- /** What a flow expects of the page at a step; every field given must hold. */
233
- export type Target = ({
234
- frame?: FrameStep | FrameStep[]; /** container (css/selector/ref) to resolve inside */
235
- within?: string;
236
- }) & ({
237
- ref: number | string;
238
- } | {
239
- selector: string;
240
- nth?: number;
241
- } | {
242
- role?: string;
243
- name?: string;
244
- label?: string;
245
- text?: string;
246
- testid?: string;
247
- nth?: number;
248
- } | {
249
- x: number;
250
- y: number;
251
- });
252
- export interface Expectation {
253
- target?: Target;
254
- text?: string;
255
- notText?: string;
256
- url?: string;
257
- title?: string;
258
- visible?: boolean;
259
- value?: string;
260
- checked?: boolean;
261
- selected?: string[];
262
- enabled?: boolean;
263
- }
264
- /** Compiled once by the host; evaluated in the target document. */
265
- /** targetText: the text of a text locator, so `visible` asks whether that text (not its container) is on screen. */
266
- export interface CheckArgs extends Omit<Expectation, 'target'> {
267
- selector?: string;
268
- fallback?: string | null;
269
- targetText?: string;
270
- targetName?: string;
271
- }
272
- export interface CheckResult {
273
- ok: boolean;
274
- failed: string[];
275
- url: string;
276
- title: string;
277
- actual?: Record<string, unknown>;
278
- }
@@ -1,28 +0,0 @@
1
- import type { Arg } from '@jackwener/browsermcp/adapter-sdk';
2
- export type { Arg } from '@jackwener/browsermcp/adapter-sdk';
3
- export interface ToolDefinition {
4
- site: string;
5
- name: string;
6
- description: string;
7
- access: 'read' | 'write';
8
- domain?: string;
9
- result?: {
10
- kind: 'rows' | 'value';
11
- description: string;
12
- fields?: Record<string, string>;
13
- paginated?: boolean;
14
- };
15
- args?: Arg[];
16
- /** JS source of the adapter body: `async ({ tab, args, sites, recon }) => …` */
17
- func: string;
18
- }
19
- export declare function validateDefinition(def: ToolDefinition): void;
20
- /** Ensure the user source dir can resolve the SDK subpath of this browsermcp installation. */
21
- export declare function ensureUserSource(userAdaptersDir: string): string;
22
- export declare function renderAdapterModule(def: ToolDefinition): string;
23
- export declare function deleteTool(site: string, name: string, userAdaptersDir: string): boolean;
24
- export declare function listDefinedTools(userAdaptersDir: string): Array<{
25
- site: string;
26
- name: string;
27
- file: string;
28
- }>;
@@ -1,39 +0,0 @@
1
- import { type ToolDefinition } from './define.js';
2
- import type { CommandRunResult, CommandRunError } from './executor.js';
3
- import { type Arg } from './schema.js';
4
- import { type AdapterCommand } from './loader.js';
5
- export interface DraftExpectation {
6
- path?: string;
7
- equals?: unknown;
8
- minRows?: number;
9
- }
10
- export declare function createDraftStore(userAdaptersDir: string): {
11
- createDraft: (def: ToolDefinition, activeFile?: string) => Promise<{
12
- draftId: string;
13
- site: string;
14
- name: string;
15
- args: Arg[];
16
- }>;
17
- tryDraft: (run: (cmd: AdapterCommand, args: Record<string, unknown>) => Promise<CommandRunResult | CommandRunError>, id: string, args: Record<string, unknown>, expect: DraftExpectation) => Promise<{
18
- result: CommandRunResult | CommandRunError;
19
- verification: ReturnType<(result: CommandRunResult | CommandRunError, expect: DraftExpectation) => {
20
- passed: boolean;
21
- checks: Array<{
22
- check: string;
23
- passed: boolean;
24
- actual?: unknown;
25
- }>;
26
- }>;
27
- }>;
28
- activateDraft: (id: string, sourceFile: (site: string, name: string) => string | undefined) => {
29
- site: string;
30
- name: string;
31
- file: string;
32
- verifiedAt: string;
33
- };
34
- discardDraft: (id: string) => {
35
- draftId: string;
36
- discarded: true;
37
- };
38
- };
39
- export type DraftStore = ReturnType<typeof createDraftStore>;
@@ -1,34 +0,0 @@
1
- import type { AdapterCommand } from './loader.js';
2
- import type { RuntimePage } from '../backends/page-types.js';
3
- export interface PageProvider {
4
- getAdapterPage(site: string): Promise<RuntimePage>;
5
- browserAvailable(): boolean;
6
- /** The object model bound to a page: the same `tab`/`sites`/`recon` an agent uses in `js`. */
7
- toolContext(page: RuntimePage, site: string): Promise<Record<string, unknown>>;
8
- }
9
- export interface CommandRunResult {
10
- ok: true;
11
- site: string;
12
- name: string;
13
- rows?: unknown[];
14
- value?: unknown;
15
- nextCursor?: string;
16
- elapsedMs: number;
17
- }
18
- export interface CommandRunError {
19
- ok: false;
20
- site: string;
21
- name: string;
22
- error: {
23
- code: string;
24
- message: string;
25
- hint?: string;
26
- details?: Record<string, unknown>;
27
- };
28
- elapsedMs: number;
29
- }
30
- export declare const DEFAULT_TIMEOUT_MS = 120000;
31
- export declare function runAdapter(provider: PageProvider, cmd: AdapterCommand, rawArgs: Record<string, unknown>, opts?: {
32
- timeoutMs?: number;
33
- signal?: AbortSignal;
34
- }): Promise<CommandRunResult | CommandRunError>;
@@ -1,101 +0,0 @@
1
- import { type Arg, type ArgView } from './schema.js';
2
- export type SourceKind = 'builtin' | 'user';
3
- export interface Source {
4
- dir: string;
5
- kind: SourceKind;
6
- }
7
- export interface AdapterContext {
8
- args: Record<string, unknown>;
9
- tab: unknown;
10
- sites: unknown;
11
- recon: unknown;
12
- signal?: AbortSignal;
13
- }
14
- /** A loaded adapter: the descriptor from the module plus its path-derived identity. */
15
- export interface AdapterCommand {
16
- site: string;
17
- name: string;
18
- description: string;
19
- access: 'read' | 'write';
20
- domain?: string;
21
- result?: {
22
- kind: 'rows' | 'value';
23
- description: string;
24
- fields?: Record<string, string>;
25
- paginated?: boolean;
26
- };
27
- args: Arg[];
28
- aliases?: string[];
29
- source: SourceKind;
30
- run: (ctx: AdapterContext) => Promise<unknown>;
31
- }
32
- /** One descriptor validation path for built-in, user, and draft adapters. */
33
- export declare function adapterCommandFromDescriptor(site: string, name: string, source: SourceKind, descriptor: Record<string, unknown>): AdapterCommand;
34
- /** A command's metadata as the index and a source manifest hold it: the descriptor minus `run` and identity. */
35
- export type AdapterMetadata = Omit<AdapterCommand, 'site' | 'name' | 'source' | 'run'>;
36
- /** `<source>/manifest.json`: the generated, static description of a read-only source's commands. */
37
- export declare const ADAPTER_MANIFEST_FILE = "manifest.json";
38
- export declare const ADAPTER_MANIFEST_FORMAT = 1;
39
- export interface AdapterManifest {
40
- format: number;
41
- sites: Record<string, Record<string, AdapterMetadata>>;
42
- }
43
- /** The metadata of a validated command, in index field order (also what a manifest stores). */
44
- export declare function adapterMetadata(cmd: AdapterCommand): AdapterMetadata;
45
- export declare class SiteRegistry {
46
- private sources;
47
- loadedAt: number | null;
48
- private index;
49
- private indexStamp;
50
- private manifests;
51
- constructor(sources?: Source[]);
52
- /** Replace the source list (later overrides earlier). */
53
- setSources(sources: Source[]): void;
54
- addSource(source: Source): void;
55
- load(): Promise<void>;
56
- private existingDirs;
57
- /** Include file identity: replacing an adapter does not update its parent directory mtime. A source with a
58
- * manifest is described by the manifest, so its identity is the manifest's plus its file names. */
59
- private stamp;
60
- private manifestKey;
61
- /** A source's manifest, re-read only when the file changes; null when it has none or it cannot be used. */
62
- private manifest;
63
- private siteDirs;
64
- private siteAliases;
65
- /** site -> command-name -> absolute file path (later source wins). */
66
- private map;
67
- private sourceOf;
68
- private kindOf;
69
- private importDescriptor;
70
- private toCommand;
71
- private buildIndex;
72
- private all;
73
- has(site: string): boolean;
74
- sites(): Array<{
75
- site: string;
76
- aliases: string[];
77
- commands: number;
78
- read: number;
79
- write: number;
80
- domains: string[];
81
- source: SourceKind;
82
- sample: string[];
83
- }>;
84
- commandNames(site: string): string[];
85
- sourceFile(site: string, name: string): string | undefined;
86
- /** Command metadata for a site (from the index; loads it if cold). */
87
- commands(site: string): Promise<Array<Omit<AdapterCommand, 'run'>>>;
88
- /** Rank commands for a free-text query, using the in-memory index. */
89
- search(query: string, limit?: number): Promise<Array<{
90
- site: string;
91
- name: string;
92
- description: string;
93
- score: number;
94
- access: string;
95
- domain?: string;
96
- args: ArgView[];
97
- result?: AdapterCommand['result'];
98
- }>>;
99
- /** Load a command with its `run` implementation. Resolves aliases via the index. */
100
- resolve(site: string, name: string): Promise<AdapterCommand>;
101
- }
@@ -1,5 +0,0 @@
1
- import { type AdapterManifest } from './loader.js';
2
- /** Import and validate every command in `dir`; throws on any adapter that would fail to load at runtime. */
3
- export declare function generateAdapterManifest(dir: string): Promise<AdapterManifest>;
4
- export declare function renderAdapterManifest(manifest: AdapterManifest): string;
5
- export declare function manifestPath(dir: string): string;