@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.
- package/README.md +175 -305
- package/dist/_utils/client.d.ts +2 -2
- package/dist/_utils/client.d.ts.map +1 -1
- package/dist/_utils/client.js.map +1 -1
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +34 -63
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/types.d.ts +255 -129
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js +133 -41
- package/dist/agent/types.js.map +1 -1
- package/dist/browser/index.d.ts +2 -4
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js +10 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types.d.ts +13 -9
- package/dist/browser/types.d.ts.map +1 -1
- package/dist/browser/types.js +12 -2
- package/dist/browser/types.js.map +1 -1
- package/dist/fetch/index.d.ts +1 -1
- package/dist/fetch/index.d.ts.map +1 -1
- package/dist/fetch/index.js +21 -13
- package/dist/fetch/index.js.map +1 -1
- package/dist/fetch/types.d.ts +167 -49
- package/dist/fetch/types.d.ts.map +1 -1
- package/dist/fetch/types.js +65 -7
- package/dist/fetch/types.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/runs/index.d.ts +1 -1
- package/dist/runs/index.d.ts.map +1 -1
- package/dist/runs/index.js +25 -16
- package/dist/runs/index.js.map +1 -1
- package/dist/runs/types.d.ts +114 -66
- package/dist/runs/types.d.ts.map +1 -1
- package/dist/runs/types.js +48 -6
- package/dist/runs/types.js.map +1 -1
- package/dist/search/index.d.ts +2 -6
- package/dist/search/index.d.ts.map +1 -1
- package/dist/search/index.js +13 -8
- package/dist/search/index.js.map +1 -1
- package/dist/search/types.d.ts +29 -21
- package/dist/search/types.d.ts.map +1 -1
- package/dist/search/types.js +22 -2
- package/dist/search/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -2
package/dist/agent/types.d.ts
CHANGED
|
@@ -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
|
|
6
|
-
LITE
|
|
7
|
-
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
|
|
11
|
-
US
|
|
12
|
-
GB
|
|
13
|
-
CA
|
|
14
|
-
DE
|
|
15
|
-
FR
|
|
16
|
-
JP
|
|
17
|
-
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
50
|
-
PENDING
|
|
51
|
-
RUNNING
|
|
52
|
-
COMPLETED
|
|
53
|
-
FAILED
|
|
54
|
-
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
|
|
64
|
-
SYSTEM_FAILURE
|
|
65
|
-
AGENT_FAILURE
|
|
66
|
-
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
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
help_url
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
|
123
|
-
|
|
124
|
-
error:
|
|
125
|
-
}
|
|
126
|
-
run_id:
|
|
127
|
-
error:
|
|
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
|
|
131
|
-
STARTED
|
|
132
|
-
STREAMING_URL
|
|
133
|
-
PROGRESS
|
|
134
|
-
HEARTBEAT
|
|
135
|
-
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
|
|
139
|
-
type: "STARTED"
|
|
140
|
-
run_id:
|
|
141
|
-
timestamp:
|
|
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
|
|
145
|
-
type: "STREAMING_URL"
|
|
146
|
-
run_id:
|
|
147
|
-
streaming_url:
|
|
148
|
-
timestamp:
|
|
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
|
|
152
|
-
type: "PROGRESS"
|
|
153
|
-
run_id:
|
|
154
|
-
purpose:
|
|
155
|
-
timestamp:
|
|
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
|
|
159
|
-
type: "HEARTBEAT"
|
|
160
|
-
timestamp:
|
|
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
|
|
164
|
-
type: "COMPLETE"
|
|
165
|
-
run_id:
|
|
166
|
-
status:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
|
173
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qCAAqC;AACrC,eAAO,MAAM,cAAc;;;CAGjB,CAAC;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AO,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"}
|
package/dist/agent/types.js
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Agent automation request/response types.
|
|
2
|
+
* Agent automation request/response types and schemas.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import { z } from "zod";
|
|
5
5
|
/** Browser profile for execution. */
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|