@nodetool-ai/browser 0.8.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 (43) hide show
  1. package/README.md +60 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/actions.d.ts +64 -0
  4. package/dist/actions.d.ts.map +1 -0
  5. package/dist/actions.js +468 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/capture.d.ts +17 -0
  8. package/dist/capture.d.ts.map +1 -0
  9. package/dist/capture.js +95 -0
  10. package/dist/capture.js.map +1 -0
  11. package/dist/cdp-page.d.ts +125 -0
  12. package/dist/cdp-page.d.ts.map +1 -0
  13. package/dist/cdp-page.js +458 -0
  14. package/dist/cdp-page.js.map +1 -0
  15. package/dist/extension/channel.d.ts +28 -0
  16. package/dist/extension/channel.d.ts.map +1 -0
  17. package/dist/extension/channel.js +30 -0
  18. package/dist/extension/channel.js.map +1 -0
  19. package/dist/extension/client.d.ts +129 -0
  20. package/dist/extension/client.d.ts.map +1 -0
  21. package/dist/extension/client.js +352 -0
  22. package/dist/extension/client.js.map +1 -0
  23. package/dist/extension/page.d.ts +38 -0
  24. package/dist/extension/page.d.ts.map +1 -0
  25. package/dist/extension/page.js +50 -0
  26. package/dist/extension/page.js.map +1 -0
  27. package/dist/extension/protocol.d.ts +162 -0
  28. package/dist/extension/protocol.d.ts.map +1 -0
  29. package/dist/extension/protocol.js +45 -0
  30. package/dist/extension/protocol.js.map +1 -0
  31. package/dist/index.d.ts +30 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +30 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/schemas.d.ts +698 -0
  36. package/dist/schemas.d.ts.map +1 -0
  37. package/dist/schemas.js +262 -0
  38. package/dist/schemas.js.map +1 -0
  39. package/dist/upload.d.ts +24 -0
  40. package/dist/upload.d.ts.map +1 -0
  41. package/dist/upload.js +144 -0
  42. package/dist/upload.js.map +1 -0
  43. package/package.json +66 -0
@@ -0,0 +1,262 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Browser tool schemas.
4
+ *
5
+ * The browser exposes TWO addressing modes for every action that hits an
6
+ * element:
7
+ * - index: numeric id from the element index (produced by browser_view),
8
+ * cheapest and most reliable for known web apps
9
+ * - coordinate_x/y: viewport coordinates, required for arbitrary GUI-like
10
+ * interactions (canvas, custom widgets, drag handles)
11
+ *
12
+ * At least one must be provided; index wins if both are set.
13
+ */
14
+ const ElementRef = z
15
+ .object({
16
+ index: z.number().int().nonnegative().optional(),
17
+ coordinate_x: z.number().int().optional(),
18
+ coordinate_y: z.number().int().optional()
19
+ })
20
+ .refine((v) => v.index !== undefined ||
21
+ (v.coordinate_x !== undefined && v.coordinate_y !== undefined), { message: "provide either index or (coordinate_x, coordinate_y)" });
22
+ export const BrowserViewInput = z.object({
23
+ include_screenshot: z.boolean().optional()
24
+ });
25
+ export const BrowserElement = z.object({
26
+ index: z.number().int().nonnegative(),
27
+ tag: z.string(),
28
+ role: z.string().nullable(),
29
+ text: z.string(),
30
+ attributes: z.record(z.string(), z.string()),
31
+ bbox: z.object({
32
+ x: z.number(),
33
+ y: z.number(),
34
+ width: z.number(),
35
+ height: z.number()
36
+ })
37
+ });
38
+ export const BrowserViewOutput = z.object({
39
+ url: z.string(),
40
+ title: z.string(),
41
+ viewport: z.object({ width: z.number(), height: z.number() }),
42
+ elements: z.array(BrowserElement),
43
+ screenshot_png_b64: z.string().nullable()
44
+ });
45
+ export const BrowserNavigateInput = z.object({
46
+ url: z.string().min(1),
47
+ wait_until: z.enum(["load", "domcontentloaded", "networkidle"]).optional()
48
+ });
49
+ export const BrowserNavigateOutput = z.object({
50
+ url: z.string(),
51
+ title: z.string(),
52
+ status: z.number().int().nullable()
53
+ });
54
+ /**
55
+ * `transport` is how a caller switches between the headless Chrome this
56
+ * process launches and the user's own logged-in Chrome behind the extension
57
+ * relay. It only takes effect on a restart: the session is a process
58
+ * singleton, so switching means tearing the current one down.
59
+ */
60
+ export const BrowserTransport = z.enum(["local", "extension"]);
61
+ export const BrowserRestartInput = z.object({
62
+ url: z.string().optional(),
63
+ transport: BrowserTransport.optional()
64
+ });
65
+ export const BrowserRestartOutput = z.object({
66
+ url: z.string(),
67
+ transport: BrowserTransport
68
+ });
69
+ /** What `browser_status` answers without opening a session. */
70
+ export const BrowserStatusOutput = z.object({
71
+ transport: BrowserTransport,
72
+ /** Whether a page session is already open in this process. */
73
+ session_open: z.boolean(),
74
+ /**
75
+ * Whether a Chrome extension currently holds the `/ws/extension` socket.
76
+ * `null` when this process cannot answer — it is not the server holding the
77
+ * bridge, so it would have to open a socket to find out.
78
+ */
79
+ extension_connected: z.boolean().nullable(),
80
+ url: z.string().nullable(),
81
+ title: z.string().nullable(),
82
+ /** What to do next when the session cannot be driven as configured. */
83
+ hint: z.string().nullable()
84
+ });
85
+ export const BrowserClickInput = ElementRef;
86
+ export const BrowserClickOutput = z.object({
87
+ clicked: z.literal(true)
88
+ });
89
+ export const BrowserInputTextInput = z
90
+ .object({
91
+ text: z.string(),
92
+ press_enter: z.boolean().optional(),
93
+ index: z.number().int().nonnegative().optional(),
94
+ coordinate_x: z.number().int().optional(),
95
+ coordinate_y: z.number().int().optional()
96
+ })
97
+ .refine((v) => v.index !== undefined ||
98
+ (v.coordinate_x !== undefined && v.coordinate_y !== undefined), { message: "provide either index or (coordinate_x, coordinate_y)" });
99
+ export const BrowserInputTextOutput = z.object({
100
+ typed: z.literal(true)
101
+ });
102
+ export const BrowserMoveMouseInput = z.object({
103
+ coordinate_x: z.number().int(),
104
+ coordinate_y: z.number().int()
105
+ });
106
+ export const BrowserMoveMouseOutput = z.object({
107
+ moved: z.literal(true)
108
+ });
109
+ export const BrowserPressKeyInput = z.object({
110
+ key: z.string().min(1)
111
+ });
112
+ export const BrowserPressKeyOutput = z.object({
113
+ pressed: z.literal(true)
114
+ });
115
+ export const BrowserSelectOptionInput = z.object({
116
+ index: z.number().int().nonnegative(),
117
+ option: z.string()
118
+ });
119
+ export const BrowserSelectOptionOutput = z.object({
120
+ selected: z.array(z.string())
121
+ });
122
+ export const BrowserScrollInput = z.object({
123
+ to_top: z.boolean().optional(),
124
+ to_bottom: z.boolean().optional(),
125
+ pixels: z.number().int().optional()
126
+ });
127
+ export const BrowserScrollOutput = z.object({
128
+ scroll_y: z.number()
129
+ });
130
+ export const BrowserConsoleExecInput = z.object({
131
+ javascript: z.string().min(1)
132
+ });
133
+ export const BrowserConsoleExecOutput = z.object({
134
+ result_json: z.string()
135
+ });
136
+ export const BrowserConsoleViewInput = z.object({
137
+ max_lines: z.number().int().positive().optional()
138
+ });
139
+ export const BrowserConsoleMessage = z.object({
140
+ type: z.string(),
141
+ text: z.string(),
142
+ timestamp: z.number()
143
+ });
144
+ export const BrowserConsoleViewOutput = z.object({
145
+ messages: z.array(BrowserConsoleMessage)
146
+ });
147
+ /**
148
+ * Capture generated media (image/video/audio) from the current page into bytes.
149
+ *
150
+ * Three addressing modes, in priority order:
151
+ * - index: an element from the most recent browser_view (a <video>/<audio>/
152
+ * <img> whose currentSrc/src points at the media)
153
+ * - resource_url: a network resource URL the page already fetched; the host
154
+ * attempts Network.getResponseBody for a tracked requestId first
155
+ * - url: an arbitrary absolute (or blob:) URL to fetch from inside the page
156
+ *
157
+ * At least one of index / url / resource_url must be provided. `media_type`
158
+ * is an optional hint ("image" | "video" | "audio") that biases element
159
+ * resolution and the inferred MIME when the source doesn't declare one.
160
+ */
161
+ export const BrowserCaptureMediaInput = z
162
+ .object({
163
+ index: z.number().int().nonnegative().optional(),
164
+ url: z.string().optional(),
165
+ resource_url: z.string().optional(),
166
+ media_type: z.enum(["image", "video", "audio"]).optional()
167
+ })
168
+ .refine((v) => v.index !== undefined ||
169
+ (v.url !== undefined && v.url.length > 0) ||
170
+ (v.resource_url !== undefined && v.resource_url.length > 0), { message: "provide one of index, url, or resource_url" });
171
+ /**
172
+ * Raw capture result from the action. Carries the bytes as base64 plus the
173
+ * resolved MIME and source URL. The host-side tool wrapper persists these
174
+ * bytes via the same `persistOutput` path screenshots use and replaces this
175
+ * shape with a {@link BrowserCaptureMediaOutput} AssetRef.
176
+ */
177
+ export const BrowserCaptureMediaRaw = z.object({
178
+ /** Base64-encoded media bytes. */
179
+ media_b64: z.string(),
180
+ /** Resolved MIME type of the captured bytes. */
181
+ mime_type: z.string(),
182
+ /** The URL the bytes were read from (`blob:`/`http(s):`/element currentSrc). */
183
+ source_url: z.string().nullable(),
184
+ /** Which rung of the capture ladder produced the bytes. */
185
+ via: z.enum(["response_body", "in_page_fetch", "downloads"])
186
+ });
187
+ /**
188
+ * AssetRef-shaped capture output returned to the agent. Mirrors the `screenshot`
189
+ * ref produced by browser_view: a persisted asset with `asset_id`/`asset_uri`
190
+ * (when the context exposes `createAsset`) or a workspace file `path`.
191
+ */
192
+ export const BrowserCaptureMediaOutput = z.object({
193
+ type: z.enum(["image", "video", "audio"]),
194
+ asset_id: z.string().optional(),
195
+ asset_uri: z.string().optional(),
196
+ uri: z.string().nullable(),
197
+ path: z.string().optional(),
198
+ mime_type: z.string(),
199
+ bytes: z.number(),
200
+ source_url: z.string().nullable()
201
+ });
202
+ /**
203
+ * Inject an existing NodeTool asset into a page `<input type="file">`.
204
+ *
205
+ * The agent addresses the file input the same way every other element action
206
+ * does (index from the most recent browser_view, or viewport coordinates) and
207
+ * names the asset to inject by `asset_id` or `uri`. `file_name` overrides the
208
+ * name the website sees; otherwise it is derived from the asset.
209
+ *
210
+ * The agent-facing shape carries only the asset handle — the host-side tool
211
+ * wrapper resolves the bytes (via the same asset-read path other nodes use) and
212
+ * forwards a {@link BrowserUploadAssetRaw} to the action. At least one of
213
+ * asset_id / uri, and at least one of index / (coordinate_x, coordinate_y),
214
+ * must be provided.
215
+ */
216
+ export const BrowserUploadAssetInput = z
217
+ .object({
218
+ index: z.number().int().nonnegative().optional(),
219
+ coordinate_x: z.number().int().optional(),
220
+ coordinate_y: z.number().int().optional(),
221
+ asset_id: z.string().optional(),
222
+ uri: z.string().optional(),
223
+ file_name: z.string().optional()
224
+ })
225
+ .refine((v) => (v.asset_id !== undefined && v.asset_id.length > 0) ||
226
+ (v.uri !== undefined && v.uri.length > 0), { message: "provide either asset_id or uri" })
227
+ .refine((v) => v.index !== undefined ||
228
+ (v.coordinate_x !== undefined && v.coordinate_y !== undefined), { message: "provide either index or (coordinate_x, coordinate_y)" });
229
+ /**
230
+ * The wire input the upload_asset action actually consumes: the file input's
231
+ * {@link ElementRef} plus the asset bytes resolved host-side (base64), the file
232
+ * name the website should see, and the MIME type. The host tool wrapper builds
233
+ * this from a {@link BrowserUploadAssetInput} after reading the asset.
234
+ */
235
+ export const BrowserUploadAssetRaw = z
236
+ .object({
237
+ index: z.number().int().nonnegative().optional(),
238
+ coordinate_x: z.number().int().optional(),
239
+ coordinate_y: z.number().int().optional(),
240
+ /** Base64-encoded file bytes. */
241
+ file_b64: z.string(),
242
+ /** File name the website sees on the injected File. */
243
+ file_name: z.string().min(1),
244
+ /** MIME type stamped on the injected File. */
245
+ mime_type: z.string().min(1)
246
+ })
247
+ .refine((v) => v.index !== undefined ||
248
+ (v.coordinate_x !== undefined && v.coordinate_y !== undefined), { message: "provide either index or (coordinate_x, coordinate_y)" });
249
+ /**
250
+ * Result of injecting an asset into a file input. `via` records which path
251
+ * succeeded: `native` is `DOM.setFileInputFiles` against a real filesystem path
252
+ * Chrome can reach; `data_transfer` is the in-page DataTransfer/`File`
253
+ * fallback used when no path is reachable (e.g. the extension driving the
254
+ * user's own machine from the server).
255
+ */
256
+ export const BrowserUploadAssetOutput = z.object({
257
+ uploaded: z.literal(true),
258
+ file_name: z.string(),
259
+ bytes: z.number(),
260
+ via: z.enum(["native", "data_transfer"])
261
+ });
262
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;GAWG;AAEH,MAA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D,EAAE,CACpE,CAAC;AAGJ;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IACzB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;CACzC,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Inject a NodeTool asset into a page `<input type="file">`.
3
+ *
4
+ * Two paths, tried in order:
5
+ *
6
+ * 1. NATIVE — write the bytes to a real temp file Chrome can reach, resolve
7
+ * the input to a CDP nodeId, and `DOM.setFileInputFiles`. This is the
8
+ * faithful upload most sites accept. Requires the file to live on the
9
+ * same machine as Chrome (the host process).
10
+ * 2. DATA_TRANSFER — when no reachable path exists (the extension transport
11
+ * drives the user's own Chrome from the server), build a `File` from the
12
+ * base64 bytes via `DataTransfer` inside the page, assign it to
13
+ * `input.files`, and dispatch `input`/`change`. Some upload widgets reject
14
+ * a programmatic `FileList`, but it is the only option without a shared
15
+ * filesystem.
16
+ */
17
+ import type { BrowserUploadAssetRaw, BrowserUploadAssetOutput } from "./schemas.js";
18
+ import type { CdpPage } from "./cdp-page.js";
19
+ /**
20
+ * Inject the asset into the addressed file input, trying the native path first
21
+ * and falling back to the in-page DataTransfer injection automatically.
22
+ */
23
+ export declare function uploadAssetToInput(page: CdpPage, input: BrowserUploadAssetRaw): Promise<BrowserUploadAssetOutput>;
24
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA4H7C;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,wBAAwB,CAAC,CAwBnC"}
package/dist/upload.js ADDED
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Inject a NodeTool asset into a page `<input type="file">`.
3
+ *
4
+ * Two paths, tried in order:
5
+ *
6
+ * 1. NATIVE — write the bytes to a real temp file Chrome can reach, resolve
7
+ * the input to a CDP nodeId, and `DOM.setFileInputFiles`. This is the
8
+ * faithful upload most sites accept. Requires the file to live on the
9
+ * same machine as Chrome (the host process).
10
+ * 2. DATA_TRANSFER — when no reachable path exists (the extension transport
11
+ * drives the user's own Chrome from the server), build a `File` from the
12
+ * base64 bytes via `DataTransfer` inside the page, assign it to
13
+ * `input.files`, and dispatch `input`/`change`. Some upload widgets reject
14
+ * a programmatic `FileList`, but it is the only option without a shared
15
+ * filesystem.
16
+ */
17
+ import { Buffer } from "node:buffer";
18
+ import { promises as fs, rmSync } from "node:fs";
19
+ import os from "node:os";
20
+ import path from "node:path";
21
+ import { randomUUID } from "node:crypto";
22
+ /**
23
+ * Temp dirs holding files handed to `DOM.setFileInputFiles`. Chrome reads the
24
+ * file lazily (on form submit / `File` byte access), so we must NOT delete it
25
+ * right after the command — that would zero the upload. We keep each file for
26
+ * the process lifetime and sweep them on exit.
27
+ */
28
+ const pendingUploadDirs = new Set();
29
+ let uploadExitHookInstalled = false;
30
+ function trackUploadDir(dir) {
31
+ pendingUploadDirs.add(dir);
32
+ if (!uploadExitHookInstalled) {
33
+ uploadExitHookInstalled = true;
34
+ process.once("exit", () => {
35
+ for (const d of pendingUploadDirs) {
36
+ try {
37
+ rmSync(d, { recursive: true, force: true });
38
+ }
39
+ catch {
40
+ /* best-effort */
41
+ }
42
+ }
43
+ });
44
+ }
45
+ }
46
+ /** Temp-tag attribute used to address a coordinate-located input for native upload. */
47
+ const UPLOAD_TAG_ATTR = "data-nt-upload";
48
+ /**
49
+ * Resolve a CSS selector that uniquely addresses the target file input.
50
+ *
51
+ * Index refs map directly to the `data-nt-idx` tag browser_view assigns.
52
+ * Coordinate refs have no stable selector, so we tag the element under the
53
+ * point with a one-shot attribute and return that selector; the caller is
54
+ * responsible for nothing further — the tag is harmless and overwritten on the
55
+ * next view.
56
+ */
57
+ async function resolveInputSelector(page, input) {
58
+ if (input.index !== undefined) {
59
+ return `[data-nt-idx="${input.index}"]`;
60
+ }
61
+ const tag = `${randomUUID()}`;
62
+ const ok = await page.evaluate((x, y, attr, value) => {
63
+ const at = document.elementFromPoint(x, y);
64
+ const el = (at?.closest("input[type='file']") ??
65
+ at);
66
+ if (!el)
67
+ return false;
68
+ el.setAttribute(attr, value);
69
+ return true;
70
+ }, input.coordinate_x, input.coordinate_y, UPLOAD_TAG_ATTR, tag);
71
+ if (!ok) {
72
+ throw new Error(`No element at coordinates (${input.coordinate_x}, ${input.coordinate_y})`);
73
+ }
74
+ return `[${UPLOAD_TAG_ATTR}="${tag}"]`;
75
+ }
76
+ /**
77
+ * Native upload: materialize the bytes to a temp file on the local filesystem
78
+ * and hand the path to Chrome via `DOM.setFileInputFiles`. The temp file is
79
+ * removed afterwards. Throws if the path isn't reachable by this Chrome.
80
+ */
81
+ async function uploadNative(page, selector, input, bytes) {
82
+ const dir = await fs.mkdtemp(path.join(os.tmpdir(), "nt-upload-"));
83
+ const filePath = path.join(dir, input.file_name);
84
+ await fs.writeFile(filePath, bytes);
85
+ // Keep the file until process exit: Chrome reads it lazily when the page
86
+ // submits the form, well after this call returns.
87
+ trackUploadDir(dir);
88
+ await page.setFileInputFiles(selector, [filePath]);
89
+ }
90
+ /**
91
+ * DataTransfer fallback: build a `File` in the page from base64 bytes, assign
92
+ * it to the input's `files`, and dispatch the events sites listen for. Runs
93
+ * entirely in-page so it works without a shared filesystem.
94
+ */
95
+ async function uploadDataTransfer(page, selector, input) {
96
+ const ok = await page.evaluate((sel, b64, name, mime) => {
97
+ const el = document.querySelector(sel);
98
+ if (!el || el.tagName !== "INPUT" || el.type !== "file")
99
+ return false;
100
+ const binary = atob(b64);
101
+ const buf = new Uint8Array(binary.length);
102
+ for (let i = 0; i < binary.length; i++)
103
+ buf[i] = binary.charCodeAt(i);
104
+ const file = new File([buf], name, { type: mime });
105
+ const dt = new DataTransfer();
106
+ dt.items.add(file);
107
+ el.files = dt.files;
108
+ el.dispatchEvent(new Event("input", { bubbles: true }));
109
+ el.dispatchEvent(new Event("change", { bubbles: true }));
110
+ return true;
111
+ }, selector, input.file_b64, input.file_name, input.mime_type);
112
+ if (!ok) {
113
+ throw new Error(`No <input type="file"> matched by ${selector}`);
114
+ }
115
+ }
116
+ /**
117
+ * Inject the asset into the addressed file input, trying the native path first
118
+ * and falling back to the in-page DataTransfer injection automatically.
119
+ */
120
+ export async function uploadAssetToInput(page, input) {
121
+ const bytes = Buffer.from(input.file_b64, "base64");
122
+ const selector = await resolveInputSelector(page, input);
123
+ try {
124
+ await uploadNative(page, selector, input, bytes);
125
+ return {
126
+ uploaded: true,
127
+ file_name: input.file_name,
128
+ bytes: bytes.length,
129
+ via: "native"
130
+ };
131
+ }
132
+ catch {
133
+ // No reachable filesystem path (or native injection rejected) — fall back
134
+ // to the in-page DataTransfer File injection.
135
+ }
136
+ await uploadDataTransfer(page, selector, input);
137
+ return {
138
+ uploaded: true,
139
+ file_name: input.file_name,
140
+ bytes: bytes.length,
141
+ via: "data_transfer"
142
+ };
143
+ }
144
+ //# sourceMappingURL=upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,MAA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ED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,IAAa,EACb,KAA4B;IAE5B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEzD,IAAI,CAAC;QACH,MAAM,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,GAAG,EAAE,QAAQ;SACd,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,0EAA0E;QAC1E,8CAA8C;IAChD,CAAC;IAED,MAAM,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,KAAK,EAAE,KAAK,CAAC,MAAM;QACnB,GAAG,EAAE,eAAe;KACrB,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@nodetool-ai/browser",
3
+ "version": "0.8.1",
4
+ "description": "Driving one real Chrome page over CDP: the action loop, element indexing, media capture, file upload, and the Chrome-extension relay that reaches the user's own signed-in browser",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=22.0.0"
8
+ },
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "scripts": {
12
+ "build": "node ../../scripts/build-typescript-workspace.mjs",
13
+ "check": "npm run lint && npm run test",
14
+ "test": "node ../../scripts/run-vitest.mjs run",
15
+ "test:watch": "node ../../scripts/run-vitest.mjs",
16
+ "test:integration": "npm --prefix ../../chrome-extension run build && npx -y @puppeteer/browsers install chrome@stable --path ../../chrome && vitest run --config vitest.integration.config.ts",
17
+ "lint": "node ../../scripts/run-tsc.mjs --noEmit"
18
+ },
19
+ "dependencies": {
20
+ "@nodetool-ai/config": "^0.8.1",
21
+ "chrome-launcher": "^1.2.0",
22
+ "chrome-remote-interface": "^0.34.0",
23
+ "ws": "^8.18.0",
24
+ "zod": "^3.24.1"
25
+ },
26
+ "devDependencies": {
27
+ "@types/chrome-remote-interface": "^0.33.0",
28
+ "@types/node": "^22.0.0",
29
+ "@types/ws": "^8.5.0",
30
+ "typescript": "npm:@typescript/typescript6@6.0.2",
31
+ "vitest": "^5.0.1"
32
+ },
33
+ "exports": {
34
+ ".": {
35
+ "nodetool-dev": "./src/index.ts",
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js",
38
+ "default": "./dist/index.js"
39
+ }
40
+ },
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/nodetool-ai/nodetool.git",
45
+ "directory": "packages/browser"
46
+ },
47
+ "homepage": "https://nodetool.ai",
48
+ "bugs": {
49
+ "url": "https://github.com/nodetool-ai/nodetool/issues"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "files": [
55
+ "dist",
56
+ "README.md"
57
+ ],
58
+ "keywords": [
59
+ "nodetool",
60
+ "browser-automation",
61
+ "chrome-devtools-protocol",
62
+ "cdp",
63
+ "chrome-extension",
64
+ "typescript"
65
+ ]
66
+ }