@spicrawl/mcp 0.0.0-stage → 0.1.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 (49) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +61 -0
  3. package/README.md +411 -2
  4. package/dist/client.d.ts +89 -0
  5. package/dist/client.js +187 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/http.d.ts +27 -0
  8. package/dist/http.js +220 -0
  9. package/dist/http.js.map +1 -0
  10. package/dist/index.d.ts +30 -0
  11. package/dist/index.js +79 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/server.d.ts +16 -0
  14. package/dist/server.js +141 -0
  15. package/dist/server.js.map +1 -0
  16. package/dist/tools/actions.d.ts +534 -0
  17. package/dist/tools/actions.js +103 -0
  18. package/dist/tools/actions.js.map +1 -0
  19. package/dist/tools/batch.d.ts +2 -0
  20. package/dist/tools/batch.js +307 -0
  21. package/dist/tools/batch.js.map +1 -0
  22. package/dist/tools/browser.d.ts +2 -0
  23. package/dist/tools/browser.js +101 -0
  24. package/dist/tools/browser.js.map +1 -0
  25. package/dist/tools/common.d.ts +64 -0
  26. package/dist/tools/common.js +64 -0
  27. package/dist/tools/common.js.map +1 -0
  28. package/dist/tools/docs.d.ts +12 -0
  29. package/dist/tools/docs.js +277 -0
  30. package/dist/tools/docs.js.map +1 -0
  31. package/dist/tools/pdf.d.ts +11 -0
  32. package/dist/tools/pdf.js +36 -0
  33. package/dist/tools/pdf.js.map +1 -0
  34. package/dist/tools/requests.d.ts +2 -0
  35. package/dist/tools/requests.js +71 -0
  36. package/dist/tools/requests.js.map +1 -0
  37. package/dist/tools/scrape.d.ts +2 -0
  38. package/dist/tools/scrape.js +213 -0
  39. package/dist/tools/scrape.js.map +1 -0
  40. package/dist/tools/screenshots.d.ts +15 -0
  41. package/dist/tools/screenshots.js +69 -0
  42. package/dist/tools/screenshots.js.map +1 -0
  43. package/dist/tools/sessions.d.ts +2 -0
  44. package/dist/tools/sessions.js +145 -0
  45. package/dist/tools/sessions.js.map +1 -0
  46. package/dist/tools/usage.d.ts +2 -0
  47. package/dist/tools/usage.js +93 -0
  48. package/dist/tools/usage.js.map +1 -0
  49. package/package.json +75 -4
package/dist/server.js ADDED
@@ -0,0 +1,141 @@
1
+ import { z } from "zod";
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { PACKAGE_VERSION } from "./client.js";
4
+ import { registerScrapeTools } from "./tools/scrape.js";
5
+ import { registerBatchTools } from "./tools/batch.js";
6
+ import { registerSessionsTools } from "./tools/sessions.js";
7
+ import { registerUsageTools } from "./tools/usage.js";
8
+ import { registerRequestsTools } from "./tools/requests.js";
9
+ import { registerBrowserTools } from "./tools/browser.js";
10
+ import { registerDocsTools } from "./tools/docs.js";
11
+ export const SERVER_NAME = "spicrawl-mcp-server";
12
+ export const SERVER_VERSION = PACKAGE_VERSION;
13
+ // ---------------------------------------------------------------------------
14
+ // Unknown arguments are refused, never dropped.
15
+ //
16
+ // zod's default object strips keys it does not know, so `js_render: true` (the
17
+ // REST name; the tool calls it `render`) used to become a silent plain fetch —
18
+ // the customer believes rendering is on and is billed for something else. The
19
+ // Spicrawl API refuses unknown fields for exactly this reason; the MCP layer must
20
+ // not bypass that. Every tool's top-level arguments are therefore a strict
21
+ // object: an unknown key fails validation with a message naming it (and the
22
+ // closest real argument), and tools/list advertises `additionalProperties:
23
+ // false`. Free-form maps inside a tool (headers, JSON Schemas, records) stay open.
24
+ // ---------------------------------------------------------------------------
25
+ /** Names an agent is likely to guess (REST / other-scraper spellings) -> the tool's name. */
26
+ const ALIASES = {
27
+ js_render: "render",
28
+ javascript: "render",
29
+ response_format: "format",
30
+ formats: "format",
31
+ only_main_content: "main_content_only",
32
+ onlyMainContent: "main_content_only",
33
+ includeTags: "include_tags",
34
+ excludeTags: "exclude_tags",
35
+ waitFor: "wait_for",
36
+ headers: "custom_headers",
37
+ country: "proxy_country",
38
+ };
39
+ const normalise = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, "");
40
+ function levenshtein(a, b) {
41
+ let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
42
+ for (let i = 1; i <= a.length; i++) {
43
+ const cur = [i];
44
+ for (let j = 1; j <= b.length; j++) {
45
+ cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
46
+ }
47
+ prev = cur;
48
+ }
49
+ return prev[b.length];
50
+ }
51
+ /** The valid argument closest to `key`, if one is close enough to be a plausible typo. */
52
+ function closestArgument(key, valid) {
53
+ const alias = ALIASES[key];
54
+ if (alias && valid.includes(alias))
55
+ return alias;
56
+ const nk = normalise(key);
57
+ // Candidates: every valid name, plus every alias whose target is valid (so a
58
+ // typo of a REST name, e.g. `js_rendr`, still lands on `render`).
59
+ const candidates = valid.map((v) => [v, v]);
60
+ for (const [a, target] of Object.entries(ALIASES))
61
+ if (valid.includes(target))
62
+ candidates.push([a, target]);
63
+ let best;
64
+ let bestDistance = Infinity;
65
+ for (const [spelling, target] of candidates) {
66
+ const d = levenshtein(nk, normalise(spelling));
67
+ if (d < bestDistance)
68
+ [best, bestDistance] = [target, d];
69
+ }
70
+ return bestDistance <= Math.max(1, Math.floor(nk.length / 3)) ? best : undefined;
71
+ }
72
+ function unknownArgumentsMessage(keys, valid) {
73
+ let unresolved = false;
74
+ const parts = keys.map((k) => {
75
+ const s = closestArgument(k, valid);
76
+ if (!s)
77
+ unresolved = true;
78
+ return s ? `unknown argument \`${k}\`; did you mean \`${s}\`?` : `unknown argument \`${k}\``;
79
+ });
80
+ let msg = parts.join("; ");
81
+ if (unresolved) {
82
+ msg += valid.length
83
+ ? ` (valid arguments: ${valid.map((v) => `\`${v}\``).join(", ")})`
84
+ : " (this tool takes no arguments)";
85
+ }
86
+ return msg;
87
+ }
88
+ /**
89
+ * Wraps a raw zod shape into a strict object: unknown keys are a validation
90
+ * error naming them (with a did-you-mean), and the JSON Schema carries
91
+ * `additionalProperties: false`. Descriptions and defaults are untouched.
92
+ */
93
+ export function strictArgs(shape) {
94
+ const valid = Object.keys(shape);
95
+ const errorMap = (issue, ctx) => issue.code === z.ZodIssueCode.unrecognized_keys
96
+ ? { message: unknownArgumentsMessage(issue.keys, valid) }
97
+ : { message: ctx.defaultError };
98
+ return z.object(shape, { errorMap }).strict();
99
+ }
100
+ /** Makes a registerTool inputSchema strict: raw shapes and non-strict zod objects. */
101
+ function strictInputSchema(schema) {
102
+ if (schema === undefined)
103
+ return undefined; // no schema -> SDK passes no args at all
104
+ if (schema instanceof z.ZodObject) {
105
+ return schema._def.unknownKeys === "strip" ? strictArgs(schema.shape) : schema;
106
+ }
107
+ const isSchemaInstance = "_def" in schema || "_zod" in schema;
108
+ return isSchemaInstance ? schema : strictArgs(schema);
109
+ }
110
+ /**
111
+ * McpServer whose registerTool makes every tool's input schema strict. Tools
112
+ * keep declaring plain raw shapes; this one place guarantees none of them (or
113
+ * any tool added later) can silently drop an argument.
114
+ */
115
+ class StrictArgsMcpServer extends McpServer {
116
+ registerTool(name, config, cb) {
117
+ // The strict object parses to exactly what the raw shape did, so the
118
+ // callback's argument type is unchanged; only the declared type widens.
119
+ return super.registerTool(name, { ...config, inputSchema: strictInputSchema(config.inputSchema) }, cb);
120
+ }
121
+ }
122
+ /**
123
+ * One MCP server bound to one caller's API key. The stdio entry builds one for
124
+ * the process; the HTTP entry builds one per session, from that session's key.
125
+ */
126
+ export function buildServer(client) {
127
+ const server = new StrictArgsMcpServer({ name: SERVER_NAME, version: SERVER_VERSION });
128
+ for (const register of [
129
+ registerScrapeTools,
130
+ registerBatchTools,
131
+ registerSessionsTools,
132
+ registerUsageTools,
133
+ registerRequestsTools,
134
+ registerBrowserTools,
135
+ registerDocsTools,
136
+ ]) {
137
+ register(server, client);
138
+ }
139
+ return server;
140
+ }
141
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/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,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACjF,CAAC;IACD,MAAM,gBAAgB,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC;IAC9D,OAAO,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,MAAuB,CAAC,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,MAAM,mBAAoB,SAAQ,SAAS;IAChC,YAAY,CAInB,IAAY,EACZ,MAOC,EACD,EAA2B;QAE3B,qEAAqE;QACrE,wEAAwE;QACxE,OAAO,KAAK,CAAC,YAAY,CACvB,IAAI,EACJ,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAc,EAAE,EAC9E,EAAE,CACH,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAoB;IAC9C,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IACvF,KAAK,MAAM,QAAQ,IAAI;QACrB,mBAAmB;QACnB,kBAAkB;QAClB,qBAAqB;QACrB,kBAAkB;QAClB,qBAAqB;QACrB,oBAAoB;QACpB,iBAAiB;KAClB,EAAE,CAAC;QACF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,534 @@
1
+ import { z } from "zod";
2
+ export declare const ActionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3
+ type: z.ZodLiteral<"click">;
4
+ } & {
5
+ selector: z.ZodString;
6
+ wait_for_navigation: z.ZodOptional<z.ZodBoolean>;
7
+ until: z.ZodOptional<z.ZodEnum<["load", "domcontentloaded", "networkidle"]>>;
8
+ } & {
9
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
10
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
11
+ label: z.ZodOptional<z.ZodString>;
12
+ }, "strict", z.ZodTypeAny, {
13
+ type: "click";
14
+ selector: string;
15
+ timeout_ms?: number | undefined;
16
+ on_error?: "fail" | "skip" | undefined;
17
+ label?: string | undefined;
18
+ wait_for_navigation?: boolean | undefined;
19
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
20
+ }, {
21
+ type: "click";
22
+ selector: string;
23
+ timeout_ms?: number | undefined;
24
+ on_error?: "fail" | "skip" | undefined;
25
+ label?: string | undefined;
26
+ wait_for_navigation?: boolean | undefined;
27
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
28
+ }>, z.ZodObject<{
29
+ type: z.ZodLiteral<"fill">;
30
+ } & {
31
+ selector: z.ZodString;
32
+ value: z.ZodString;
33
+ secret: z.ZodOptional<z.ZodBoolean>;
34
+ } & {
35
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
36
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
37
+ label: z.ZodOptional<z.ZodString>;
38
+ }, "strict", z.ZodTypeAny, {
39
+ type: "fill";
40
+ value: string;
41
+ selector: string;
42
+ timeout_ms?: number | undefined;
43
+ on_error?: "fail" | "skip" | undefined;
44
+ label?: string | undefined;
45
+ secret?: boolean | undefined;
46
+ }, {
47
+ type: "fill";
48
+ value: string;
49
+ selector: string;
50
+ timeout_ms?: number | undefined;
51
+ on_error?: "fail" | "skip" | undefined;
52
+ label?: string | undefined;
53
+ secret?: boolean | undefined;
54
+ }>, z.ZodObject<{
55
+ type: z.ZodLiteral<"wait_for">;
56
+ } & {
57
+ selector: z.ZodOptional<z.ZodString>;
58
+ ms: z.ZodOptional<z.ZodNumber>;
59
+ } & {
60
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
61
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
62
+ label: z.ZodOptional<z.ZodString>;
63
+ }, "strict", z.ZodTypeAny, {
64
+ type: "wait_for";
65
+ timeout_ms?: number | undefined;
66
+ on_error?: "fail" | "skip" | undefined;
67
+ label?: string | undefined;
68
+ selector?: string | undefined;
69
+ ms?: number | undefined;
70
+ }, {
71
+ type: "wait_for";
72
+ timeout_ms?: number | undefined;
73
+ on_error?: "fail" | "skip" | undefined;
74
+ label?: string | undefined;
75
+ selector?: string | undefined;
76
+ ms?: number | undefined;
77
+ }>, z.ZodObject<{
78
+ type: z.ZodLiteral<"wait_for_navigation">;
79
+ } & {
80
+ until: z.ZodOptional<z.ZodEnum<["load", "domcontentloaded", "networkidle"]>>;
81
+ } & {
82
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
83
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
84
+ label: z.ZodOptional<z.ZodString>;
85
+ }, "strict", z.ZodTypeAny, {
86
+ type: "wait_for_navigation";
87
+ timeout_ms?: number | undefined;
88
+ on_error?: "fail" | "skip" | undefined;
89
+ label?: string | undefined;
90
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
91
+ }, {
92
+ type: "wait_for_navigation";
93
+ timeout_ms?: number | undefined;
94
+ on_error?: "fail" | "skip" | undefined;
95
+ label?: string | undefined;
96
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
97
+ }>, z.ZodObject<{
98
+ type: z.ZodLiteral<"scroll">;
99
+ } & {
100
+ y: z.ZodOptional<z.ZodNumber>;
101
+ to_bottom: z.ZodOptional<z.ZodBoolean>;
102
+ selector: z.ZodOptional<z.ZodString>;
103
+ } & {
104
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
105
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
106
+ label: z.ZodOptional<z.ZodString>;
107
+ }, "strict", z.ZodTypeAny, {
108
+ type: "scroll";
109
+ timeout_ms?: number | undefined;
110
+ on_error?: "fail" | "skip" | undefined;
111
+ label?: string | undefined;
112
+ selector?: string | undefined;
113
+ y?: number | undefined;
114
+ to_bottom?: boolean | undefined;
115
+ }, {
116
+ type: "scroll";
117
+ timeout_ms?: number | undefined;
118
+ on_error?: "fail" | "skip" | undefined;
119
+ label?: string | undefined;
120
+ selector?: string | undefined;
121
+ y?: number | undefined;
122
+ to_bottom?: boolean | undefined;
123
+ }>, z.ZodObject<{
124
+ type: z.ZodLiteral<"select">;
125
+ } & {
126
+ selector: z.ZodString;
127
+ value: z.ZodOptional<z.ZodString>;
128
+ values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
129
+ } & {
130
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
131
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
132
+ label: z.ZodOptional<z.ZodString>;
133
+ }, "strict", z.ZodTypeAny, {
134
+ type: "select";
135
+ selector: string;
136
+ values?: string[] | undefined;
137
+ value?: string | undefined;
138
+ timeout_ms?: number | undefined;
139
+ on_error?: "fail" | "skip" | undefined;
140
+ label?: string | undefined;
141
+ }, {
142
+ type: "select";
143
+ selector: string;
144
+ values?: string[] | undefined;
145
+ value?: string | undefined;
146
+ timeout_ms?: number | undefined;
147
+ on_error?: "fail" | "skip" | undefined;
148
+ label?: string | undefined;
149
+ }>, z.ZodObject<{
150
+ type: z.ZodLiteral<"evaluate">;
151
+ } & {
152
+ expression: z.ZodString;
153
+ return_value: z.ZodOptional<z.ZodBoolean>;
154
+ await_promise: z.ZodOptional<z.ZodBoolean>;
155
+ } & {
156
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
157
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
158
+ label: z.ZodOptional<z.ZodString>;
159
+ }, "strict", z.ZodTypeAny, {
160
+ type: "evaluate";
161
+ expression: string;
162
+ timeout_ms?: number | undefined;
163
+ on_error?: "fail" | "skip" | undefined;
164
+ label?: string | undefined;
165
+ return_value?: boolean | undefined;
166
+ await_promise?: boolean | undefined;
167
+ }, {
168
+ type: "evaluate";
169
+ expression: string;
170
+ timeout_ms?: number | undefined;
171
+ on_error?: "fail" | "skip" | undefined;
172
+ label?: string | undefined;
173
+ return_value?: boolean | undefined;
174
+ await_promise?: boolean | undefined;
175
+ }>, z.ZodObject<{
176
+ type: z.ZodLiteral<"screenshot">;
177
+ } & {
178
+ full_page: z.ZodOptional<z.ZodBoolean>;
179
+ selector: z.ZodOptional<z.ZodString>;
180
+ format: z.ZodOptional<z.ZodEnum<["png", "jpeg", "webp"]>>;
181
+ quality: z.ZodOptional<z.ZodNumber>;
182
+ } & {
183
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
184
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
185
+ label: z.ZodOptional<z.ZodString>;
186
+ }, "strict", z.ZodTypeAny, {
187
+ type: "screenshot";
188
+ format?: "png" | "jpeg" | "webp" | undefined;
189
+ timeout_ms?: number | undefined;
190
+ on_error?: "fail" | "skip" | undefined;
191
+ label?: string | undefined;
192
+ selector?: string | undefined;
193
+ full_page?: boolean | undefined;
194
+ quality?: number | undefined;
195
+ }, {
196
+ type: "screenshot";
197
+ format?: "png" | "jpeg" | "webp" | undefined;
198
+ timeout_ms?: number | undefined;
199
+ on_error?: "fail" | "skip" | undefined;
200
+ label?: string | undefined;
201
+ selector?: string | undefined;
202
+ full_page?: boolean | undefined;
203
+ quality?: number | undefined;
204
+ }>]>;
205
+ export type Action = z.infer<typeof ActionSchema>;
206
+ export declare const ActionsSchema: z.ZodEffects<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
207
+ type: z.ZodLiteral<"click">;
208
+ } & {
209
+ selector: z.ZodString;
210
+ wait_for_navigation: z.ZodOptional<z.ZodBoolean>;
211
+ until: z.ZodOptional<z.ZodEnum<["load", "domcontentloaded", "networkidle"]>>;
212
+ } & {
213
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
214
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
215
+ label: z.ZodOptional<z.ZodString>;
216
+ }, "strict", z.ZodTypeAny, {
217
+ type: "click";
218
+ selector: string;
219
+ timeout_ms?: number | undefined;
220
+ on_error?: "fail" | "skip" | undefined;
221
+ label?: string | undefined;
222
+ wait_for_navigation?: boolean | undefined;
223
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
224
+ }, {
225
+ type: "click";
226
+ selector: string;
227
+ timeout_ms?: number | undefined;
228
+ on_error?: "fail" | "skip" | undefined;
229
+ label?: string | undefined;
230
+ wait_for_navigation?: boolean | undefined;
231
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
232
+ }>, z.ZodObject<{
233
+ type: z.ZodLiteral<"fill">;
234
+ } & {
235
+ selector: z.ZodString;
236
+ value: z.ZodString;
237
+ secret: z.ZodOptional<z.ZodBoolean>;
238
+ } & {
239
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
240
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
241
+ label: z.ZodOptional<z.ZodString>;
242
+ }, "strict", z.ZodTypeAny, {
243
+ type: "fill";
244
+ value: string;
245
+ selector: string;
246
+ timeout_ms?: number | undefined;
247
+ on_error?: "fail" | "skip" | undefined;
248
+ label?: string | undefined;
249
+ secret?: boolean | undefined;
250
+ }, {
251
+ type: "fill";
252
+ value: string;
253
+ selector: string;
254
+ timeout_ms?: number | undefined;
255
+ on_error?: "fail" | "skip" | undefined;
256
+ label?: string | undefined;
257
+ secret?: boolean | undefined;
258
+ }>, z.ZodObject<{
259
+ type: z.ZodLiteral<"wait_for">;
260
+ } & {
261
+ selector: z.ZodOptional<z.ZodString>;
262
+ ms: z.ZodOptional<z.ZodNumber>;
263
+ } & {
264
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
265
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
266
+ label: z.ZodOptional<z.ZodString>;
267
+ }, "strict", z.ZodTypeAny, {
268
+ type: "wait_for";
269
+ timeout_ms?: number | undefined;
270
+ on_error?: "fail" | "skip" | undefined;
271
+ label?: string | undefined;
272
+ selector?: string | undefined;
273
+ ms?: number | undefined;
274
+ }, {
275
+ type: "wait_for";
276
+ timeout_ms?: number | undefined;
277
+ on_error?: "fail" | "skip" | undefined;
278
+ label?: string | undefined;
279
+ selector?: string | undefined;
280
+ ms?: number | undefined;
281
+ }>, z.ZodObject<{
282
+ type: z.ZodLiteral<"wait_for_navigation">;
283
+ } & {
284
+ until: z.ZodOptional<z.ZodEnum<["load", "domcontentloaded", "networkidle"]>>;
285
+ } & {
286
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
287
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
288
+ label: z.ZodOptional<z.ZodString>;
289
+ }, "strict", z.ZodTypeAny, {
290
+ type: "wait_for_navigation";
291
+ timeout_ms?: number | undefined;
292
+ on_error?: "fail" | "skip" | undefined;
293
+ label?: string | undefined;
294
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
295
+ }, {
296
+ type: "wait_for_navigation";
297
+ timeout_ms?: number | undefined;
298
+ on_error?: "fail" | "skip" | undefined;
299
+ label?: string | undefined;
300
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
301
+ }>, z.ZodObject<{
302
+ type: z.ZodLiteral<"scroll">;
303
+ } & {
304
+ y: z.ZodOptional<z.ZodNumber>;
305
+ to_bottom: z.ZodOptional<z.ZodBoolean>;
306
+ selector: z.ZodOptional<z.ZodString>;
307
+ } & {
308
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
309
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
310
+ label: z.ZodOptional<z.ZodString>;
311
+ }, "strict", z.ZodTypeAny, {
312
+ type: "scroll";
313
+ timeout_ms?: number | undefined;
314
+ on_error?: "fail" | "skip" | undefined;
315
+ label?: string | undefined;
316
+ selector?: string | undefined;
317
+ y?: number | undefined;
318
+ to_bottom?: boolean | undefined;
319
+ }, {
320
+ type: "scroll";
321
+ timeout_ms?: number | undefined;
322
+ on_error?: "fail" | "skip" | undefined;
323
+ label?: string | undefined;
324
+ selector?: string | undefined;
325
+ y?: number | undefined;
326
+ to_bottom?: boolean | undefined;
327
+ }>, z.ZodObject<{
328
+ type: z.ZodLiteral<"select">;
329
+ } & {
330
+ selector: z.ZodString;
331
+ value: z.ZodOptional<z.ZodString>;
332
+ values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
333
+ } & {
334
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
335
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
336
+ label: z.ZodOptional<z.ZodString>;
337
+ }, "strict", z.ZodTypeAny, {
338
+ type: "select";
339
+ selector: string;
340
+ values?: string[] | undefined;
341
+ value?: string | undefined;
342
+ timeout_ms?: number | undefined;
343
+ on_error?: "fail" | "skip" | undefined;
344
+ label?: string | undefined;
345
+ }, {
346
+ type: "select";
347
+ selector: string;
348
+ values?: string[] | undefined;
349
+ value?: string | undefined;
350
+ timeout_ms?: number | undefined;
351
+ on_error?: "fail" | "skip" | undefined;
352
+ label?: string | undefined;
353
+ }>, z.ZodObject<{
354
+ type: z.ZodLiteral<"evaluate">;
355
+ } & {
356
+ expression: z.ZodString;
357
+ return_value: z.ZodOptional<z.ZodBoolean>;
358
+ await_promise: z.ZodOptional<z.ZodBoolean>;
359
+ } & {
360
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
361
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
362
+ label: z.ZodOptional<z.ZodString>;
363
+ }, "strict", z.ZodTypeAny, {
364
+ type: "evaluate";
365
+ expression: string;
366
+ timeout_ms?: number | undefined;
367
+ on_error?: "fail" | "skip" | undefined;
368
+ label?: string | undefined;
369
+ return_value?: boolean | undefined;
370
+ await_promise?: boolean | undefined;
371
+ }, {
372
+ type: "evaluate";
373
+ expression: string;
374
+ timeout_ms?: number | undefined;
375
+ on_error?: "fail" | "skip" | undefined;
376
+ label?: string | undefined;
377
+ return_value?: boolean | undefined;
378
+ await_promise?: boolean | undefined;
379
+ }>, z.ZodObject<{
380
+ type: z.ZodLiteral<"screenshot">;
381
+ } & {
382
+ full_page: z.ZodOptional<z.ZodBoolean>;
383
+ selector: z.ZodOptional<z.ZodString>;
384
+ format: z.ZodOptional<z.ZodEnum<["png", "jpeg", "webp"]>>;
385
+ quality: z.ZodOptional<z.ZodNumber>;
386
+ } & {
387
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
388
+ on_error: z.ZodOptional<z.ZodEnum<["fail", "skip"]>>;
389
+ label: z.ZodOptional<z.ZodString>;
390
+ }, "strict", z.ZodTypeAny, {
391
+ type: "screenshot";
392
+ format?: "png" | "jpeg" | "webp" | undefined;
393
+ timeout_ms?: number | undefined;
394
+ on_error?: "fail" | "skip" | undefined;
395
+ label?: string | undefined;
396
+ selector?: string | undefined;
397
+ full_page?: boolean | undefined;
398
+ quality?: number | undefined;
399
+ }, {
400
+ type: "screenshot";
401
+ format?: "png" | "jpeg" | "webp" | undefined;
402
+ timeout_ms?: number | undefined;
403
+ on_error?: "fail" | "skip" | undefined;
404
+ label?: string | undefined;
405
+ selector?: string | undefined;
406
+ full_page?: boolean | undefined;
407
+ quality?: number | undefined;
408
+ }>]>, "many">, ({
409
+ type: "click";
410
+ selector: string;
411
+ timeout_ms?: number | undefined;
412
+ on_error?: "fail" | "skip" | undefined;
413
+ label?: string | undefined;
414
+ wait_for_navigation?: boolean | undefined;
415
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
416
+ } | {
417
+ type: "fill";
418
+ value: string;
419
+ selector: string;
420
+ timeout_ms?: number | undefined;
421
+ on_error?: "fail" | "skip" | undefined;
422
+ label?: string | undefined;
423
+ secret?: boolean | undefined;
424
+ } | {
425
+ type: "wait_for";
426
+ timeout_ms?: number | undefined;
427
+ on_error?: "fail" | "skip" | undefined;
428
+ label?: string | undefined;
429
+ selector?: string | undefined;
430
+ ms?: number | undefined;
431
+ } | {
432
+ type: "wait_for_navigation";
433
+ timeout_ms?: number | undefined;
434
+ on_error?: "fail" | "skip" | undefined;
435
+ label?: string | undefined;
436
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
437
+ } | {
438
+ type: "scroll";
439
+ timeout_ms?: number | undefined;
440
+ on_error?: "fail" | "skip" | undefined;
441
+ label?: string | undefined;
442
+ selector?: string | undefined;
443
+ y?: number | undefined;
444
+ to_bottom?: boolean | undefined;
445
+ } | {
446
+ type: "select";
447
+ selector: string;
448
+ values?: string[] | undefined;
449
+ value?: string | undefined;
450
+ timeout_ms?: number | undefined;
451
+ on_error?: "fail" | "skip" | undefined;
452
+ label?: string | undefined;
453
+ } | {
454
+ type: "evaluate";
455
+ expression: string;
456
+ timeout_ms?: number | undefined;
457
+ on_error?: "fail" | "skip" | undefined;
458
+ label?: string | undefined;
459
+ return_value?: boolean | undefined;
460
+ await_promise?: boolean | undefined;
461
+ } | {
462
+ type: "screenshot";
463
+ format?: "png" | "jpeg" | "webp" | undefined;
464
+ timeout_ms?: number | undefined;
465
+ on_error?: "fail" | "skip" | undefined;
466
+ label?: string | undefined;
467
+ selector?: string | undefined;
468
+ full_page?: boolean | undefined;
469
+ quality?: number | undefined;
470
+ })[], ({
471
+ type: "click";
472
+ selector: string;
473
+ timeout_ms?: number | undefined;
474
+ on_error?: "fail" | "skip" | undefined;
475
+ label?: string | undefined;
476
+ wait_for_navigation?: boolean | undefined;
477
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
478
+ } | {
479
+ type: "fill";
480
+ value: string;
481
+ selector: string;
482
+ timeout_ms?: number | undefined;
483
+ on_error?: "fail" | "skip" | undefined;
484
+ label?: string | undefined;
485
+ secret?: boolean | undefined;
486
+ } | {
487
+ type: "wait_for";
488
+ timeout_ms?: number | undefined;
489
+ on_error?: "fail" | "skip" | undefined;
490
+ label?: string | undefined;
491
+ selector?: string | undefined;
492
+ ms?: number | undefined;
493
+ } | {
494
+ type: "wait_for_navigation";
495
+ timeout_ms?: number | undefined;
496
+ on_error?: "fail" | "skip" | undefined;
497
+ label?: string | undefined;
498
+ until?: "load" | "domcontentloaded" | "networkidle" | undefined;
499
+ } | {
500
+ type: "scroll";
501
+ timeout_ms?: number | undefined;
502
+ on_error?: "fail" | "skip" | undefined;
503
+ label?: string | undefined;
504
+ selector?: string | undefined;
505
+ y?: number | undefined;
506
+ to_bottom?: boolean | undefined;
507
+ } | {
508
+ type: "select";
509
+ selector: string;
510
+ values?: string[] | undefined;
511
+ value?: string | undefined;
512
+ timeout_ms?: number | undefined;
513
+ on_error?: "fail" | "skip" | undefined;
514
+ label?: string | undefined;
515
+ } | {
516
+ type: "evaluate";
517
+ expression: string;
518
+ timeout_ms?: number | undefined;
519
+ on_error?: "fail" | "skip" | undefined;
520
+ label?: string | undefined;
521
+ return_value?: boolean | undefined;
522
+ await_promise?: boolean | undefined;
523
+ } | {
524
+ type: "screenshot";
525
+ format?: "png" | "jpeg" | "webp" | undefined;
526
+ timeout_ms?: number | undefined;
527
+ on_error?: "fail" | "skip" | undefined;
528
+ label?: string | undefined;
529
+ selector?: string | undefined;
530
+ full_page?: boolean | undefined;
531
+ quality?: number | undefined;
532
+ })[]>;
533
+ /** Map typed steps onto the API's keyed shape: {kind: {fields}, timeout_ms?, on_error?, label?}. */
534
+ export declare function toApiActions(steps: Action[]): Record<string, unknown>[];