@tiny-fish/sdk 0.0.6 → 0.0.7

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 (50) hide show
  1. package/README.md +175 -305
  2. package/dist/_utils/client.d.ts +2 -2
  3. package/dist/_utils/client.d.ts.map +1 -1
  4. package/dist/_utils/client.js.map +1 -1
  5. package/dist/agent/index.d.ts.map +1 -1
  6. package/dist/agent/index.js +34 -63
  7. package/dist/agent/index.js.map +1 -1
  8. package/dist/agent/types.d.ts +255 -129
  9. package/dist/agent/types.d.ts.map +1 -1
  10. package/dist/agent/types.js +133 -41
  11. package/dist/agent/types.js.map +1 -1
  12. package/dist/browser/index.d.ts +2 -4
  13. package/dist/browser/index.d.ts.map +1 -1
  14. package/dist/browser/index.js +10 -2
  15. package/dist/browser/index.js.map +1 -1
  16. package/dist/browser/types.d.ts +13 -9
  17. package/dist/browser/types.d.ts.map +1 -1
  18. package/dist/browser/types.js +12 -2
  19. package/dist/browser/types.js.map +1 -1
  20. package/dist/fetch/index.d.ts +1 -1
  21. package/dist/fetch/index.d.ts.map +1 -1
  22. package/dist/fetch/index.js +21 -13
  23. package/dist/fetch/index.js.map +1 -1
  24. package/dist/fetch/types.d.ts +167 -49
  25. package/dist/fetch/types.d.ts.map +1 -1
  26. package/dist/fetch/types.js +65 -7
  27. package/dist/fetch/types.js.map +1 -1
  28. package/dist/index.d.ts +7 -5
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +7 -3
  31. package/dist/index.js.map +1 -1
  32. package/dist/runs/index.d.ts +1 -1
  33. package/dist/runs/index.d.ts.map +1 -1
  34. package/dist/runs/index.js +25 -16
  35. package/dist/runs/index.js.map +1 -1
  36. package/dist/runs/types.d.ts +114 -66
  37. package/dist/runs/types.d.ts.map +1 -1
  38. package/dist/runs/types.js +48 -6
  39. package/dist/runs/types.js.map +1 -1
  40. package/dist/search/index.d.ts +2 -6
  41. package/dist/search/index.d.ts.map +1 -1
  42. package/dist/search/index.js +13 -8
  43. package/dist/search/index.js.map +1 -1
  44. package/dist/search/types.d.ts +29 -21
  45. package/dist/search/types.d.ts.map +1 -1
  46. package/dist/search/types.js +22 -2
  47. package/dist/search/types.js.map +1 -1
  48. package/dist/version.d.ts +1 -1
  49. package/dist/version.js +1 -1
  50. package/package.json +3 -2
@@ -1,42 +1,75 @@
1
1
  /**
2
- * Agent automation request/response types.
2
+ * Agent automation request/response types and schemas.
3
3
  */
4
+ import { z } from "zod";
4
5
  /** Browser profile for execution. */
5
- export declare enum BrowserProfile {
6
- LITE = "lite",
7
- STEALTH = "stealth"
8
- }
6
+ export declare const BrowserProfile: {
7
+ readonly LITE: "lite";
8
+ readonly STEALTH: "stealth";
9
+ };
10
+ export declare const browserProfileSchema: z.ZodEnum<{
11
+ readonly LITE: "lite";
12
+ readonly STEALTH: "stealth";
13
+ }>;
14
+ export type BrowserProfile = z.infer<typeof browserProfileSchema>;
9
15
  /** ISO 3166-1 alpha-2 country code for proxy location. */
10
- export declare enum ProxyCountryCode {
11
- US = "US",
12
- GB = "GB",
13
- CA = "CA",
14
- DE = "DE",
15
- FR = "FR",
16
- JP = "JP",
17
- AU = "AU"
18
- }
16
+ export declare const ProxyCountryCode: {
17
+ readonly US: "US";
18
+ readonly GB: "GB";
19
+ readonly CA: "CA";
20
+ readonly DE: "DE";
21
+ readonly FR: "FR";
22
+ readonly JP: "JP";
23
+ readonly AU: "AU";
24
+ };
25
+ export declare const proxyCountryCodeSchema: z.ZodEnum<{
26
+ readonly US: "US";
27
+ readonly GB: "GB";
28
+ readonly CA: "CA";
29
+ readonly DE: "DE";
30
+ readonly FR: "FR";
31
+ readonly JP: "JP";
32
+ readonly AU: "AU";
33
+ }>;
34
+ export type ProxyCountryCode = z.infer<typeof proxyCountryCodeSchema>;
19
35
  /** Proxy configuration for browser automation. */
20
- export interface ProxyConfig {
21
- /** Enable proxy for this automation run. */
22
- enabled: boolean;
23
- /** ISO 3166-1 alpha-2 country code for proxy location. */
24
- country_code?: ProxyCountryCode;
25
- }
36
+ export declare const proxyConfigSchema: z.ZodObject<{
37
+ enabled: z.ZodBoolean;
38
+ country_code: z.ZodOptional<z.ZodEnum<{
39
+ readonly US: "US";
40
+ readonly GB: "GB";
41
+ readonly CA: "CA";
42
+ readonly DE: "DE";
43
+ readonly FR: "FR";
44
+ readonly JP: "JP";
45
+ readonly AU: "AU";
46
+ }>>;
47
+ }, z.core.$strict>;
48
+ export type ProxyConfig = z.infer<typeof proxyConfigSchema>;
26
49
  /** Parameters for a synchronous agent run. */
27
- export interface AgentRunParams {
28
- /** Natural language description of what to do on the page. */
29
- goal: string;
30
- /** The URL to open the browser on. */
31
- url: string;
32
- /** `"lite"` (default) or `"stealth"` (anti-detection). */
33
- browser_profile?: BrowserProfile;
34
- /** Optional proxy settings. */
35
- proxy_config?: ProxyConfig;
36
- }
37
- /** Per-request transport controls for agent calls. */
50
+ export declare const agentRunParamsSchema: z.ZodObject<{
51
+ goal: z.ZodString;
52
+ url: z.ZodString;
53
+ browser_profile: z.ZodOptional<z.ZodEnum<{
54
+ readonly LITE: "lite";
55
+ readonly STEALTH: "stealth";
56
+ }>>;
57
+ proxy_config: z.ZodOptional<z.ZodObject<{
58
+ enabled: z.ZodBoolean;
59
+ country_code: z.ZodOptional<z.ZodEnum<{
60
+ readonly US: "US";
61
+ readonly GB: "GB";
62
+ readonly CA: "CA";
63
+ readonly DE: "DE";
64
+ readonly FR: "FR";
65
+ readonly JP: "JP";
66
+ readonly AU: "AU";
67
+ }>>;
68
+ }, z.core.$strict>>;
69
+ }, z.core.$strict>;
70
+ export type AgentRunParams = z.infer<typeof agentRunParamsSchema>;
71
+ /** Request-scoped options that are not part of the API wire contract. */
38
72
  export interface AgentRequestOptions {
39
- /** Abort this specific request without changing the client-wide timeout. */
40
73
  signal?: AbortSignal;
41
74
  }
42
75
  /**
@@ -46,13 +79,21 @@ export interface AgentRequestOptions {
46
79
  * on run status — your IDE will autocomplete the options and typos become
47
80
  * type errors.
48
81
  */
49
- export declare enum RunStatus {
50
- PENDING = "PENDING",
51
- RUNNING = "RUNNING",
52
- COMPLETED = "COMPLETED",
53
- FAILED = "FAILED",
54
- CANCELLED = "CANCELLED"
55
- }
82
+ export declare const RunStatus: {
83
+ readonly PENDING: "PENDING";
84
+ readonly RUNNING: "RUNNING";
85
+ readonly COMPLETED: "COMPLETED";
86
+ readonly FAILED: "FAILED";
87
+ readonly CANCELLED: "CANCELLED";
88
+ };
89
+ export declare const runStatusSchema: z.ZodEnum<{
90
+ readonly PENDING: "PENDING";
91
+ readonly RUNNING: "RUNNING";
92
+ readonly COMPLETED: "COMPLETED";
93
+ readonly FAILED: "FAILED";
94
+ readonly CANCELLED: "CANCELLED";
95
+ }>;
96
+ export type RunStatus = z.infer<typeof runStatusSchema>;
56
97
  /**
57
98
  * Error category indicating the source of failure.
58
99
  *
@@ -60,24 +101,30 @@ export declare enum RunStatus {
60
101
  * - `AGENT_FAILURE` — Problem with the run itself, fix the input.
61
102
  * - `UNKNOWN` — Unclassified, treat as retryable.
62
103
  */
63
- export declare enum ErrorCategory {
64
- SYSTEM_FAILURE = "SYSTEM_FAILURE",
65
- AGENT_FAILURE = "AGENT_FAILURE",
66
- UNKNOWN = "UNKNOWN"
67
- }
104
+ export declare const ErrorCategory: {
105
+ readonly SYSTEM_FAILURE: "SYSTEM_FAILURE";
106
+ readonly AGENT_FAILURE: "AGENT_FAILURE";
107
+ readonly UNKNOWN: "UNKNOWN";
108
+ };
109
+ export declare const errorCategorySchema: z.ZodEnum<{
110
+ readonly SYSTEM_FAILURE: "SYSTEM_FAILURE";
111
+ readonly AGENT_FAILURE: "AGENT_FAILURE";
112
+ readonly UNKNOWN: "UNKNOWN";
113
+ }>;
114
+ export type ErrorCategory = z.infer<typeof errorCategorySchema>;
68
115
  /** Error details for failed runs. */
69
- export interface RunError {
70
- /** Error message describing why the run failed. */
71
- message: string;
72
- /** Error category indicating the source of failure. */
73
- category: ErrorCategory;
74
- /** Suggested retry delay in whole seconds (integer). */
75
- retry_after: number | null;
76
- /** URL to troubleshooting docs. */
77
- help_url?: string;
78
- /** Human-readable guidance. */
79
- help_message?: string;
80
- }
116
+ export declare const runErrorSchema: z.ZodObject<{
117
+ message: z.ZodString;
118
+ category: z.ZodEnum<{
119
+ readonly SYSTEM_FAILURE: "SYSTEM_FAILURE";
120
+ readonly AGENT_FAILURE: "AGENT_FAILURE";
121
+ readonly UNKNOWN: "UNKNOWN";
122
+ }>;
123
+ retry_after: z.ZodNullable<z.ZodNumber>;
124
+ help_url: z.ZodOptional<z.ZodString>;
125
+ help_message: z.ZodOptional<z.ZodString>;
126
+ }, z.core.$strip>;
127
+ export type RunError = z.infer<typeof runErrorSchema>;
81
128
  /**
82
129
  * Response from synchronous automation execution.
83
130
  *
@@ -85,92 +132,171 @@ export interface RunError {
85
132
  * - On success: `result` is populated, `error` is `null`.
86
133
  * - On failure: `result` is `null`, `error` contains the message.
87
134
  */
88
- export interface AgentRunResponse {
89
- /** Final status of the automation run. */
90
- status: RunStatus;
91
- /** Unique identifier for the automation run. */
92
- run_id: string | null;
93
- /** Structured JSON result extracted from the automation. `null` if the run failed. */
94
- result: Record<string, unknown> | null;
95
- /** Error details. `null` if the run succeeded. */
96
- error: RunError | null;
97
- /** Number of steps taken during the automation. */
98
- num_of_steps: number;
99
- /** ISO 8601 timestamp when the run started. */
100
- started_at: string | null;
101
- /** ISO 8601 timestamp when the run finished. */
102
- finished_at: string | null;
103
- }
135
+ export declare const agentRunResponseSchema: z.ZodObject<{
136
+ status: z.ZodEnum<{
137
+ readonly PENDING: "PENDING";
138
+ readonly RUNNING: "RUNNING";
139
+ readonly COMPLETED: "COMPLETED";
140
+ readonly FAILED: "FAILED";
141
+ readonly CANCELLED: "CANCELLED";
142
+ }>;
143
+ run_id: z.ZodNullable<z.ZodString>;
144
+ result: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
145
+ error: z.ZodNullable<z.ZodObject<{
146
+ message: z.ZodString;
147
+ category: z.ZodEnum<{
148
+ readonly SYSTEM_FAILURE: "SYSTEM_FAILURE";
149
+ readonly AGENT_FAILURE: "AGENT_FAILURE";
150
+ readonly UNKNOWN: "UNKNOWN";
151
+ }>;
152
+ retry_after: z.ZodNullable<z.ZodNumber>;
153
+ help_url: z.ZodOptional<z.ZodString>;
154
+ help_message: z.ZodOptional<z.ZodString>;
155
+ }, z.core.$strip>>;
156
+ num_of_steps: z.ZodNullable<z.ZodNumber>;
157
+ started_at: z.ZodNullable<z.ZodString>;
158
+ finished_at: z.ZodNullable<z.ZodString>;
159
+ }, z.core.$strip>;
160
+ export type AgentRunResponse = z.infer<typeof agentRunResponseSchema>;
104
161
  /**
105
162
  * Response from asynchronous automation execution.
106
163
  *
107
164
  * Returns `run_id` immediately without waiting for completion.
108
165
  * Use `client.runs.get(run_id)` to check status later.
109
- *
110
- * This is a discriminated union — check `error` to narrow the type:
111
- * ```typescript
112
- * const response = await client.agent.queue({ goal, url });
113
- * if (response.error) {
114
- * // response.run_id is null here
115
- * console.error(response.error.message);
116
- * } else {
117
- * // response.run_id is string here
118
- * const run = await client.runs.get(response.run_id);
119
- * }
120
- * ```
121
166
  */
122
- export type AgentRunAsyncResponse = {
123
- /** Unique identifier for the created automation run. */ run_id: string /** No error. */;
124
- error: null;
125
- } | {
126
- run_id: null /** Error details. */;
127
- error: RunError;
128
- };
167
+ export declare const agentRunAsyncResponseSchema: z.ZodUnion<readonly [z.ZodObject<{
168
+ run_id: z.ZodString;
169
+ error: z.ZodNull;
170
+ }, z.core.$strip>, z.ZodObject<{
171
+ run_id: z.ZodNull;
172
+ error: z.ZodObject<{
173
+ message: z.ZodString;
174
+ category: z.ZodEnum<{
175
+ readonly SYSTEM_FAILURE: "SYSTEM_FAILURE";
176
+ readonly AGENT_FAILURE: "AGENT_FAILURE";
177
+ readonly UNKNOWN: "UNKNOWN";
178
+ }>;
179
+ retry_after: z.ZodNullable<z.ZodNumber>;
180
+ help_url: z.ZodOptional<z.ZodString>;
181
+ help_message: z.ZodOptional<z.ZodString>;
182
+ }, z.core.$strip>;
183
+ }, z.core.$strip>]>;
184
+ export type AgentRunAsyncResponse = z.infer<typeof agentRunAsyncResponseSchema>;
129
185
  /** SSE event type discriminator. */
130
- export declare enum EventType {
131
- STARTED = "STARTED",
132
- STREAMING_URL = "STREAMING_URL",
133
- PROGRESS = "PROGRESS",
134
- HEARTBEAT = "HEARTBEAT",
135
- COMPLETE = "COMPLETE"
136
- }
186
+ export declare const EventType: {
187
+ readonly STARTED: "STARTED";
188
+ readonly STREAMING_URL: "STREAMING_URL";
189
+ readonly PROGRESS: "PROGRESS";
190
+ readonly HEARTBEAT: "HEARTBEAT";
191
+ readonly COMPLETE: "COMPLETE";
192
+ };
193
+ export declare const eventTypeSchema: z.ZodEnum<{
194
+ readonly STARTED: "STARTED";
195
+ readonly STREAMING_URL: "STREAMING_URL";
196
+ readonly PROGRESS: "PROGRESS";
197
+ readonly HEARTBEAT: "HEARTBEAT";
198
+ readonly COMPLETE: "COMPLETE";
199
+ }>;
200
+ export type EventType = z.infer<typeof eventTypeSchema>;
137
201
  /** SSE event indicating the automation run has started. */
138
- export interface StartedEvent {
139
- type: "STARTED";
140
- run_id: string;
141
- timestamp: string;
142
- }
202
+ export declare const startedEventSchema: z.ZodObject<{
203
+ type: z.ZodLiteral<"STARTED">;
204
+ run_id: z.ZodString;
205
+ timestamp: z.ZodString;
206
+ }, z.core.$strip>;
207
+ export type StartedEvent = z.infer<typeof startedEventSchema>;
143
208
  /** SSE event providing the live browser streaming URL. */
144
- export interface StreamingUrlEvent {
145
- type: "STREAMING_URL";
146
- run_id: string;
147
- streaming_url: string;
148
- timestamp: string;
149
- }
209
+ export declare const streamingUrlEventSchema: z.ZodObject<{
210
+ type: z.ZodLiteral<"STREAMING_URL">;
211
+ run_id: z.ZodString;
212
+ streaming_url: z.ZodString;
213
+ timestamp: z.ZodString;
214
+ }, z.core.$strip>;
215
+ export type StreamingUrlEvent = z.infer<typeof streamingUrlEventSchema>;
150
216
  /** SSE event indicating automation progress/activity. */
151
- export interface ProgressEvent {
152
- type: "PROGRESS";
153
- run_id: string;
154
- purpose: string;
155
- timestamp: string;
156
- }
217
+ export declare const progressEventSchema: z.ZodObject<{
218
+ type: z.ZodLiteral<"PROGRESS">;
219
+ run_id: z.ZodString;
220
+ purpose: z.ZodString;
221
+ timestamp: z.ZodString;
222
+ }, z.core.$strip>;
223
+ export type ProgressEvent = z.infer<typeof progressEventSchema>;
157
224
  /** SSE event for connection keepalive. */
158
- export interface HeartbeatEvent {
159
- type: "HEARTBEAT";
160
- timestamp: string;
161
- }
225
+ export declare const heartbeatEventSchema: z.ZodObject<{
226
+ type: z.ZodLiteral<"HEARTBEAT">;
227
+ timestamp: z.ZodString;
228
+ }, z.core.$strip>;
229
+ export type HeartbeatEvent = z.infer<typeof heartbeatEventSchema>;
162
230
  /** SSE event indicating the automation run has completed. */
163
- export interface CompleteEvent {
164
- type: "COMPLETE";
165
- run_id: string;
166
- status: RunStatus;
167
- timestamp: string;
168
- result: Record<string, unknown> | null;
169
- error: RunError | null;
170
- }
231
+ export declare const completeEventSchema: z.ZodObject<{
232
+ type: z.ZodLiteral<"COMPLETE">;
233
+ run_id: z.ZodString;
234
+ status: z.ZodEnum<{
235
+ readonly PENDING: "PENDING";
236
+ readonly RUNNING: "RUNNING";
237
+ readonly COMPLETED: "COMPLETED";
238
+ readonly FAILED: "FAILED";
239
+ readonly CANCELLED: "CANCELLED";
240
+ }>;
241
+ timestamp: z.ZodString;
242
+ result: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
243
+ error: z.ZodNullable<z.ZodObject<{
244
+ message: z.ZodString;
245
+ category: z.ZodEnum<{
246
+ readonly SYSTEM_FAILURE: "SYSTEM_FAILURE";
247
+ readonly AGENT_FAILURE: "AGENT_FAILURE";
248
+ readonly UNKNOWN: "UNKNOWN";
249
+ }>;
250
+ retry_after: z.ZodNullable<z.ZodNumber>;
251
+ help_url: z.ZodOptional<z.ZodString>;
252
+ help_message: z.ZodOptional<z.ZodString>;
253
+ }, z.core.$strip>>;
254
+ }, z.core.$strip>;
255
+ export type CompleteEvent = z.infer<typeof completeEventSchema>;
171
256
  /** Union type for all possible SSE streaming events. */
172
- export type AgentRunWithStreamingResponse = StartedEvent | StreamingUrlEvent | ProgressEvent | HeartbeatEvent | CompleteEvent;
173
- /** Optional callbacks for stream events. */
257
+ export declare const agentRunWithStreamingResponseSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
258
+ type: z.ZodLiteral<"STARTED">;
259
+ run_id: z.ZodString;
260
+ timestamp: z.ZodString;
261
+ }, z.core.$strip>, z.ZodObject<{
262
+ type: z.ZodLiteral<"STREAMING_URL">;
263
+ run_id: z.ZodString;
264
+ streaming_url: z.ZodString;
265
+ timestamp: z.ZodString;
266
+ }, z.core.$strip>, z.ZodObject<{
267
+ type: z.ZodLiteral<"PROGRESS">;
268
+ run_id: z.ZodString;
269
+ purpose: z.ZodString;
270
+ timestamp: z.ZodString;
271
+ }, z.core.$strip>, z.ZodObject<{
272
+ type: z.ZodLiteral<"HEARTBEAT">;
273
+ timestamp: z.ZodString;
274
+ }, z.core.$strip>, z.ZodObject<{
275
+ type: z.ZodLiteral<"COMPLETE">;
276
+ run_id: z.ZodString;
277
+ status: z.ZodEnum<{
278
+ readonly PENDING: "PENDING";
279
+ readonly RUNNING: "RUNNING";
280
+ readonly COMPLETED: "COMPLETED";
281
+ readonly FAILED: "FAILED";
282
+ readonly CANCELLED: "CANCELLED";
283
+ }>;
284
+ timestamp: z.ZodString;
285
+ result: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
286
+ error: z.ZodNullable<z.ZodObject<{
287
+ message: z.ZodString;
288
+ category: z.ZodEnum<{
289
+ readonly SYSTEM_FAILURE: "SYSTEM_FAILURE";
290
+ readonly AGENT_FAILURE: "AGENT_FAILURE";
291
+ readonly UNKNOWN: "UNKNOWN";
292
+ }>;
293
+ retry_after: z.ZodNullable<z.ZodNumber>;
294
+ help_url: z.ZodOptional<z.ZodString>;
295
+ help_message: z.ZodOptional<z.ZodString>;
296
+ }, z.core.$strip>>;
297
+ }, z.core.$strip>], "type">;
298
+ export type AgentRunWithStreamingResponse = z.infer<typeof agentRunWithStreamingResponseSchema>;
299
+ /** Optional callbacks for stream events plus request-scoped options. */
174
300
  export interface StreamOptions extends AgentRequestOptions {
175
301
  onStarted?: (event: StartedEvent) => void;
176
302
  onStreamingUrl?: (event: StreamingUrlEvent) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,qCAAqC;AACrC,oBAAY,cAAc;IACzB,IAAI,SAAS;IACb,OAAO,YAAY;CACnB;AAED,0DAA0D;AAC1D,oBAAY,gBAAgB;IAC3B,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;CACT;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC3B,4CAA4C;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC9B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,+BAA+B;IAC/B,YAAY,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IACnC,4EAA4E;IAC5E,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAID;;;;;;GAMG;AACH,oBAAY,SAAS;IACpB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,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,CAAC,CAAC;AAEhE,0CAA0C;AAC1C,eAAO,MAAM,oBAAoB;;;iBAG/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;iBAO9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,wDAAwD;AACxD,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAM9C,CAAC;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAEhG,wEAAwE;AACxE,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACzD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACpD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C"}
@@ -1,25 +1,36 @@
1
1
  /**
2
- * Agent automation request/response types.
2
+ * Agent automation request/response types and schemas.
3
3
  */
4
- // -- Input types --
4
+ import { z } from "zod";
5
5
  /** Browser profile for execution. */
6
- export var BrowserProfile;
7
- (function (BrowserProfile) {
8
- BrowserProfile["LITE"] = "lite";
9
- BrowserProfile["STEALTH"] = "stealth";
10
- })(BrowserProfile || (BrowserProfile = {}));
6
+ export const BrowserProfile = {
7
+ LITE: "lite",
8
+ STEALTH: "stealth",
9
+ };
10
+ export const browserProfileSchema = z.enum(BrowserProfile);
11
11
  /** ISO 3166-1 alpha-2 country code for proxy location. */
12
- export var ProxyCountryCode;
13
- (function (ProxyCountryCode) {
14
- ProxyCountryCode["US"] = "US";
15
- ProxyCountryCode["GB"] = "GB";
16
- ProxyCountryCode["CA"] = "CA";
17
- ProxyCountryCode["DE"] = "DE";
18
- ProxyCountryCode["FR"] = "FR";
19
- ProxyCountryCode["JP"] = "JP";
20
- ProxyCountryCode["AU"] = "AU";
21
- })(ProxyCountryCode || (ProxyCountryCode = {}));
22
- // -- Response types (shared with runs later) --
12
+ export const ProxyCountryCode = {
13
+ US: "US",
14
+ GB: "GB",
15
+ CA: "CA",
16
+ DE: "DE",
17
+ FR: "FR",
18
+ JP: "JP",
19
+ AU: "AU",
20
+ };
21
+ export const proxyCountryCodeSchema = z.enum(ProxyCountryCode);
22
+ /** Proxy configuration for browser automation. */
23
+ export const proxyConfigSchema = z.strictObject({
24
+ enabled: z.boolean(),
25
+ country_code: proxyCountryCodeSchema.optional(),
26
+ });
27
+ /** Parameters for a synchronous agent run. */
28
+ export const agentRunParamsSchema = z.strictObject({
29
+ goal: z.string(),
30
+ url: z.string(),
31
+ browser_profile: browserProfileSchema.optional(),
32
+ proxy_config: proxyConfigSchema.optional(),
33
+ });
23
34
  /**
24
35
  * Status of an automation run.
25
36
  *
@@ -27,14 +38,14 @@ export var ProxyCountryCode;
27
38
  * on run status — your IDE will autocomplete the options and typos become
28
39
  * type errors.
29
40
  */
30
- export var RunStatus;
31
- (function (RunStatus) {
32
- RunStatus["PENDING"] = "PENDING";
33
- RunStatus["RUNNING"] = "RUNNING";
34
- RunStatus["COMPLETED"] = "COMPLETED";
35
- RunStatus["FAILED"] = "FAILED";
36
- RunStatus["CANCELLED"] = "CANCELLED";
37
- })(RunStatus || (RunStatus = {}));
41
+ export const RunStatus = {
42
+ PENDING: "PENDING",
43
+ RUNNING: "RUNNING",
44
+ COMPLETED: "COMPLETED",
45
+ FAILED: "FAILED",
46
+ CANCELLED: "CANCELLED",
47
+ };
48
+ export const runStatusSchema = z.enum(RunStatus);
38
49
  /**
39
50
  * Error category indicating the source of failure.
40
51
  *
@@ -42,20 +53,101 @@ export var RunStatus;
42
53
  * - `AGENT_FAILURE` — Problem with the run itself, fix the input.
43
54
  * - `UNKNOWN` — Unclassified, treat as retryable.
44
55
  */
45
- export var ErrorCategory;
46
- (function (ErrorCategory) {
47
- ErrorCategory["SYSTEM_FAILURE"] = "SYSTEM_FAILURE";
48
- ErrorCategory["AGENT_FAILURE"] = "AGENT_FAILURE";
49
- ErrorCategory["UNKNOWN"] = "UNKNOWN";
50
- })(ErrorCategory || (ErrorCategory = {}));
51
- // -- SSE streaming event types --
56
+ export const ErrorCategory = {
57
+ SYSTEM_FAILURE: "SYSTEM_FAILURE",
58
+ AGENT_FAILURE: "AGENT_FAILURE",
59
+ UNKNOWN: "UNKNOWN",
60
+ };
61
+ export const errorCategorySchema = z.enum(ErrorCategory);
62
+ /** Error details for failed runs. */
63
+ export const runErrorSchema = z.object({
64
+ message: z.string(),
65
+ category: errorCategorySchema,
66
+ retry_after: z.number().nullable(),
67
+ help_url: z.string().optional(),
68
+ help_message: z.string().optional(),
69
+ });
70
+ /**
71
+ * Response from synchronous automation execution.
72
+ *
73
+ * Check `status` to determine success/failure:
74
+ * - On success: `result` is populated, `error` is `null`.
75
+ * - On failure: `result` is `null`, `error` contains the message.
76
+ */
77
+ export const agentRunResponseSchema = z.object({
78
+ status: runStatusSchema,
79
+ run_id: z.string().nullable(),
80
+ result: z.record(z.string(), z.unknown()).nullable(),
81
+ error: runErrorSchema.nullable(),
82
+ num_of_steps: z.number().nullable(),
83
+ started_at: z.string().nullable(),
84
+ finished_at: z.string().nullable(),
85
+ });
86
+ /**
87
+ * Response from asynchronous automation execution.
88
+ *
89
+ * Returns `run_id` immediately without waiting for completion.
90
+ * Use `client.runs.get(run_id)` to check status later.
91
+ */
92
+ export const agentRunAsyncResponseSchema = z.union([
93
+ z.object({
94
+ run_id: z.string(),
95
+ error: z.null(),
96
+ }),
97
+ z.object({
98
+ run_id: z.null(),
99
+ error: runErrorSchema,
100
+ }),
101
+ ]);
52
102
  /** SSE event type discriminator. */
53
- export var EventType;
54
- (function (EventType) {
55
- EventType["STARTED"] = "STARTED";
56
- EventType["STREAMING_URL"] = "STREAMING_URL";
57
- EventType["PROGRESS"] = "PROGRESS";
58
- EventType["HEARTBEAT"] = "HEARTBEAT";
59
- EventType["COMPLETE"] = "COMPLETE";
60
- })(EventType || (EventType = {}));
103
+ export const EventType = {
104
+ STARTED: "STARTED",
105
+ STREAMING_URL: "STREAMING_URL",
106
+ PROGRESS: "PROGRESS",
107
+ HEARTBEAT: "HEARTBEAT",
108
+ COMPLETE: "COMPLETE",
109
+ };
110
+ export const eventTypeSchema = z.enum(EventType);
111
+ /** SSE event indicating the automation run has started. */
112
+ export const startedEventSchema = z.object({
113
+ type: z.literal(EventType.STARTED),
114
+ run_id: z.string(),
115
+ timestamp: z.string(),
116
+ });
117
+ /** SSE event providing the live browser streaming URL. */
118
+ export const streamingUrlEventSchema = z.object({
119
+ type: z.literal(EventType.STREAMING_URL),
120
+ run_id: z.string(),
121
+ streaming_url: z.string(),
122
+ timestamp: z.string(),
123
+ });
124
+ /** SSE event indicating automation progress/activity. */
125
+ export const progressEventSchema = z.object({
126
+ type: z.literal(EventType.PROGRESS),
127
+ run_id: z.string(),
128
+ purpose: z.string(),
129
+ timestamp: z.string(),
130
+ });
131
+ /** SSE event for connection keepalive. */
132
+ export const heartbeatEventSchema = z.object({
133
+ type: z.literal(EventType.HEARTBEAT),
134
+ timestamp: z.string(),
135
+ });
136
+ /** SSE event indicating the automation run has completed. */
137
+ export const completeEventSchema = z.object({
138
+ type: z.literal(EventType.COMPLETE),
139
+ run_id: z.string(),
140
+ status: runStatusSchema,
141
+ timestamp: z.string(),
142
+ result: z.record(z.string(), z.unknown()).nullable(),
143
+ error: runErrorSchema.nullable(),
144
+ });
145
+ /** Union type for all possible SSE streaming events. */
146
+ export const agentRunWithStreamingResponseSchema = z.discriminatedUnion("type", [
147
+ startedEventSchema,
148
+ streamingUrlEventSchema,
149
+ progressEventSchema,
150
+ heartbeatEventSchema,
151
+ completeEventSchema,
152
+ ]);
61
153
  //# sourceMappingURL=types.js.map