@reduck-ai/sdk 1.1.13 → 1.1.18
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/dist/client.d.ts +0 -1
- package/dist/client.js +4 -26
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/schemas.d.ts +562 -0
- package/dist/schemas.js +98 -0
- package/dist/types.d.ts +13 -83
- package/package.json +3 -2
package/dist/client.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export declare class ReduckClient {
|
|
|
5
5
|
private readonly _appBaseUrl;
|
|
6
6
|
private readonly _headers;
|
|
7
7
|
constructor(opts: ReduckClientOptions);
|
|
8
|
-
consentNotice(): Promise<void>;
|
|
9
8
|
run(query: string, { mount, deviceId, method, methodArgs, pasteSlots, outputSchema, slug }: RunOptions): Run;
|
|
10
9
|
listDevices(): Promise<Device[]>;
|
|
11
10
|
listRuns(page?: number): Promise<RunsPage>;
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { cp, mkdir } from "node:fs/promises";
|
|
2
|
-
import { createInterface } from "node:readline";
|
|
3
2
|
import { basename, join } from "node:path";
|
|
4
3
|
import { homedir } from "node:os";
|
|
5
4
|
import { ReduckError } from "./errors.js";
|
|
@@ -19,29 +18,6 @@ export class ReduckClient {
|
|
|
19
18
|
this._appBaseUrl = (opts.appBaseUrl ?? APP_URL).replace(/\/$/, "");
|
|
20
19
|
this._headers = { ...opts.headers, ...authHeader(opts) };
|
|
21
20
|
}
|
|
22
|
-
async consentNotice() {
|
|
23
|
-
const res = await fetch(`${this._runnerBaseUrl}/consent-notice`, {
|
|
24
|
-
headers: this._headers,
|
|
25
|
-
});
|
|
26
|
-
if (!res.ok)
|
|
27
|
-
throw ReduckError.fromResponse("GET /consent-notice", res.status);
|
|
28
|
-
const data = (await res.json());
|
|
29
|
-
if (!data.content)
|
|
30
|
-
return;
|
|
31
|
-
const answer = await new Promise((resolve) => {
|
|
32
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
33
|
-
rl.question(`${data.content} (y/n) `, (a) => { rl.close(); resolve(a.trim().toLowerCase()); });
|
|
34
|
-
});
|
|
35
|
-
if (answer !== "y" && answer !== "yes")
|
|
36
|
-
throw new ReduckError("Consent not accepted", { code: "CONSENT_REFUSED" });
|
|
37
|
-
const post = await fetch(`${this._runnerBaseUrl}/consent-notice`, {
|
|
38
|
-
method: "POST",
|
|
39
|
-
headers: { "Content-Type": "application/json", ...this._headers },
|
|
40
|
-
body: JSON.stringify({ version: data.version }),
|
|
41
|
-
});
|
|
42
|
-
if (!post.ok)
|
|
43
|
-
throw ReduckError.fromResponse("POST /consent-notice", post.status);
|
|
44
|
-
}
|
|
45
21
|
run(query, { mount, deviceId, method, methodArgs, pasteSlots, outputSchema, slug }) {
|
|
46
22
|
if (!deviceId)
|
|
47
23
|
throw new ReduckError("deviceId is required to start a run", { code: "MISSING_DEVICE" });
|
|
@@ -91,8 +67,10 @@ export class ReduckClient {
|
|
|
91
67
|
...(outputSchema ? { output_schema: outputSchema, slug: slug ?? "summary" } : {}),
|
|
92
68
|
}),
|
|
93
69
|
});
|
|
94
|
-
if (!res.ok)
|
|
95
|
-
|
|
70
|
+
if (!res.ok) {
|
|
71
|
+
const detail = await res.json().then((d) => d?.error).catch(() => undefined);
|
|
72
|
+
throw ReduckError.fromResponse("POST /query", res.status, detail);
|
|
73
|
+
}
|
|
96
74
|
return (await res.json());
|
|
97
75
|
}
|
|
98
76
|
async _mount(paths) {
|
package/dist/errors.d.ts
CHANGED
package/dist/errors.js
CHANGED
|
@@ -13,8 +13,9 @@ export class ReduckError extends Error {
|
|
|
13
13
|
this.code = opts.code ?? "INTERNAL_ERROR";
|
|
14
14
|
this.status = opts.status;
|
|
15
15
|
}
|
|
16
|
-
static fromResponse(endpoint, status) {
|
|
16
|
+
static fromResponse(endpoint, status, detail) {
|
|
17
17
|
const hint = STATUS_MESSAGES[status] ?? `HTTP ${status}`;
|
|
18
|
-
|
|
18
|
+
const message = detail ? `${endpoint}: ${hint} — ${detail}` : `${endpoint}: ${hint}`;
|
|
19
|
+
return new ReduckError(message, { code: "HTTP_ERROR", status });
|
|
19
20
|
}
|
|
20
21
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ReduckClient } from "./client.js";
|
|
2
2
|
export { ReduckError } from "./errors.js";
|
|
3
3
|
export { Run } from "./run.js";
|
|
4
|
-
export type { Device, Method, RunEvent, RunOptions, RunRecord, RunsPage, ReduckClientOptions, Site } from "./types.js";
|
|
4
|
+
export type { Device, Method, RunEvent, RunResult, RunOptions, RunRecord, RunsPage, ReduckClientOptions, Site } from "./types.js";
|
|
5
|
+
export * as schemas from "./schemas.js";
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DeviceSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodNullable<z.ZodString>;
|
|
5
|
+
browser: z.ZodNullable<z.ZodString>;
|
|
6
|
+
os: z.ZodNullable<z.ZodString>;
|
|
7
|
+
reachable: z.ZodBoolean;
|
|
8
|
+
created_at: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string | null;
|
|
12
|
+
browser: string | null;
|
|
13
|
+
os: string | null;
|
|
14
|
+
reachable: boolean;
|
|
15
|
+
created_at: string;
|
|
16
|
+
}, {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string | null;
|
|
19
|
+
browser: string | null;
|
|
20
|
+
os: string | null;
|
|
21
|
+
reachable: boolean;
|
|
22
|
+
created_at: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const RunEventSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
25
|
+
run_id: z.ZodString;
|
|
26
|
+
device_id: z.ZodString;
|
|
27
|
+
} & {
|
|
28
|
+
type: z.ZodLiteral<"run_requested">;
|
|
29
|
+
query: z.ZodString;
|
|
30
|
+
args: z.ZodObject<{
|
|
31
|
+
mount: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
32
|
+
method: z.ZodOptional<z.ZodString>;
|
|
33
|
+
method_args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
34
|
+
paste_slots: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
35
|
+
output_schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
36
|
+
}, "strip", z.ZodTypeAny, {
|
|
37
|
+
mount?: string[] | undefined;
|
|
38
|
+
method?: string | undefined;
|
|
39
|
+
method_args?: Record<string, string> | undefined;
|
|
40
|
+
paste_slots?: Record<string, string> | undefined;
|
|
41
|
+
output_schema?: Record<string, unknown> | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
mount?: string[] | undefined;
|
|
44
|
+
method?: string | undefined;
|
|
45
|
+
method_args?: Record<string, string> | undefined;
|
|
46
|
+
paste_slots?: Record<string, string> | undefined;
|
|
47
|
+
output_schema?: Record<string, unknown> | undefined;
|
|
48
|
+
}>;
|
|
49
|
+
cli_args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
type: "run_requested";
|
|
52
|
+
run_id: string;
|
|
53
|
+
device_id: string;
|
|
54
|
+
query: string;
|
|
55
|
+
args: {
|
|
56
|
+
mount?: string[] | undefined;
|
|
57
|
+
method?: string | undefined;
|
|
58
|
+
method_args?: Record<string, string> | undefined;
|
|
59
|
+
paste_slots?: Record<string, string> | undefined;
|
|
60
|
+
output_schema?: Record<string, unknown> | undefined;
|
|
61
|
+
};
|
|
62
|
+
cli_args?: Record<string, unknown> | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
type: "run_requested";
|
|
65
|
+
run_id: string;
|
|
66
|
+
device_id: string;
|
|
67
|
+
query: string;
|
|
68
|
+
args: {
|
|
69
|
+
mount?: string[] | undefined;
|
|
70
|
+
method?: string | undefined;
|
|
71
|
+
method_args?: Record<string, string> | undefined;
|
|
72
|
+
paste_slots?: Record<string, string> | undefined;
|
|
73
|
+
output_schema?: Record<string, unknown> | undefined;
|
|
74
|
+
};
|
|
75
|
+
cli_args?: Record<string, unknown> | undefined;
|
|
76
|
+
}>, z.ZodObject<{
|
|
77
|
+
run_id: z.ZodString;
|
|
78
|
+
device_id: z.ZodString;
|
|
79
|
+
} & {
|
|
80
|
+
type: z.ZodLiteral<"progress">;
|
|
81
|
+
text: z.ZodString;
|
|
82
|
+
timestamp: z.ZodNumber;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
type: "progress";
|
|
85
|
+
run_id: string;
|
|
86
|
+
device_id: string;
|
|
87
|
+
text: string;
|
|
88
|
+
timestamp: number;
|
|
89
|
+
}, {
|
|
90
|
+
type: "progress";
|
|
91
|
+
run_id: string;
|
|
92
|
+
device_id: string;
|
|
93
|
+
text: string;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
}>, z.ZodObject<{
|
|
96
|
+
run_id: z.ZodString;
|
|
97
|
+
device_id: z.ZodString;
|
|
98
|
+
} & {
|
|
99
|
+
type: z.ZodLiteral<"assistant">;
|
|
100
|
+
text: z.ZodString;
|
|
101
|
+
timestamp: z.ZodNumber;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
type: "assistant";
|
|
104
|
+
run_id: string;
|
|
105
|
+
device_id: string;
|
|
106
|
+
text: string;
|
|
107
|
+
timestamp: number;
|
|
108
|
+
}, {
|
|
109
|
+
type: "assistant";
|
|
110
|
+
run_id: string;
|
|
111
|
+
device_id: string;
|
|
112
|
+
text: string;
|
|
113
|
+
timestamp: number;
|
|
114
|
+
}>, z.ZodObject<{
|
|
115
|
+
run_id: z.ZodString;
|
|
116
|
+
device_id: z.ZodString;
|
|
117
|
+
} & {
|
|
118
|
+
type: z.ZodLiteral<"turn_completed">;
|
|
119
|
+
timestamp: z.ZodNumber;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
type: "turn_completed";
|
|
122
|
+
run_id: string;
|
|
123
|
+
device_id: string;
|
|
124
|
+
timestamp: number;
|
|
125
|
+
}, {
|
|
126
|
+
type: "turn_completed";
|
|
127
|
+
run_id: string;
|
|
128
|
+
device_id: string;
|
|
129
|
+
timestamp: number;
|
|
130
|
+
}>, z.ZodObject<{
|
|
131
|
+
run_id: z.ZodString;
|
|
132
|
+
device_id: z.ZodString;
|
|
133
|
+
} & {
|
|
134
|
+
type: z.ZodLiteral<"run_started">;
|
|
135
|
+
timestamp: z.ZodNumber;
|
|
136
|
+
}, "strip", z.ZodTypeAny, {
|
|
137
|
+
type: "run_started";
|
|
138
|
+
run_id: string;
|
|
139
|
+
device_id: string;
|
|
140
|
+
timestamp: number;
|
|
141
|
+
}, {
|
|
142
|
+
type: "run_started";
|
|
143
|
+
run_id: string;
|
|
144
|
+
device_id: string;
|
|
145
|
+
timestamp: number;
|
|
146
|
+
}>, z.ZodObject<{
|
|
147
|
+
run_id: z.ZodString;
|
|
148
|
+
device_id: z.ZodString;
|
|
149
|
+
} & {
|
|
150
|
+
type: z.ZodLiteral<"run_completed">;
|
|
151
|
+
timestamp: z.ZodNumber;
|
|
152
|
+
}, "strip", z.ZodTypeAny, {
|
|
153
|
+
type: "run_completed";
|
|
154
|
+
run_id: string;
|
|
155
|
+
device_id: string;
|
|
156
|
+
timestamp: number;
|
|
157
|
+
}, {
|
|
158
|
+
type: "run_completed";
|
|
159
|
+
run_id: string;
|
|
160
|
+
device_id: string;
|
|
161
|
+
timestamp: number;
|
|
162
|
+
}>, z.ZodObject<{
|
|
163
|
+
run_id: z.ZodString;
|
|
164
|
+
device_id: z.ZodString;
|
|
165
|
+
} & {
|
|
166
|
+
type: z.ZodLiteral<"done">;
|
|
167
|
+
success: z.ZodBoolean;
|
|
168
|
+
output: z.ZodOptional<z.ZodString>;
|
|
169
|
+
final_url: z.ZodOptional<z.ZodString>;
|
|
170
|
+
extractions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
171
|
+
host: z.ZodString;
|
|
172
|
+
slug: z.ZodString;
|
|
173
|
+
records: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
|
|
174
|
+
output_schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
output_schema: Record<string, unknown>;
|
|
177
|
+
host: string;
|
|
178
|
+
slug: string;
|
|
179
|
+
records: Record<string, unknown>[];
|
|
180
|
+
}, {
|
|
181
|
+
output_schema: Record<string, unknown>;
|
|
182
|
+
host: string;
|
|
183
|
+
slug: string;
|
|
184
|
+
records: Record<string, unknown>[];
|
|
185
|
+
}>, "many">>;
|
|
186
|
+
downloads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
187
|
+
filename: z.ZodString;
|
|
188
|
+
path: z.ZodOptional<z.ZodString>;
|
|
189
|
+
mimetype: z.ZodOptional<z.ZodString>;
|
|
190
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
filename: string;
|
|
193
|
+
path?: string | undefined;
|
|
194
|
+
mimetype?: string | undefined;
|
|
195
|
+
url?: string | null | undefined;
|
|
196
|
+
}, {
|
|
197
|
+
filename: string;
|
|
198
|
+
path?: string | undefined;
|
|
199
|
+
mimetype?: string | undefined;
|
|
200
|
+
url?: string | null | undefined;
|
|
201
|
+
}>, "many">>;
|
|
202
|
+
}, "strip", z.ZodTypeAny, {
|
|
203
|
+
type: "done";
|
|
204
|
+
run_id: string;
|
|
205
|
+
device_id: string;
|
|
206
|
+
success: boolean;
|
|
207
|
+
output?: string | undefined;
|
|
208
|
+
final_url?: string | undefined;
|
|
209
|
+
extractions?: {
|
|
210
|
+
output_schema: Record<string, unknown>;
|
|
211
|
+
host: string;
|
|
212
|
+
slug: string;
|
|
213
|
+
records: Record<string, unknown>[];
|
|
214
|
+
}[] | undefined;
|
|
215
|
+
downloads?: {
|
|
216
|
+
filename: string;
|
|
217
|
+
path?: string | undefined;
|
|
218
|
+
mimetype?: string | undefined;
|
|
219
|
+
url?: string | null | undefined;
|
|
220
|
+
}[] | undefined;
|
|
221
|
+
}, {
|
|
222
|
+
type: "done";
|
|
223
|
+
run_id: string;
|
|
224
|
+
device_id: string;
|
|
225
|
+
success: boolean;
|
|
226
|
+
output?: string | undefined;
|
|
227
|
+
final_url?: string | undefined;
|
|
228
|
+
extractions?: {
|
|
229
|
+
output_schema: Record<string, unknown>;
|
|
230
|
+
host: string;
|
|
231
|
+
slug: string;
|
|
232
|
+
records: Record<string, unknown>[];
|
|
233
|
+
}[] | undefined;
|
|
234
|
+
downloads?: {
|
|
235
|
+
filename: string;
|
|
236
|
+
path?: string | undefined;
|
|
237
|
+
mimetype?: string | undefined;
|
|
238
|
+
url?: string | null | undefined;
|
|
239
|
+
}[] | undefined;
|
|
240
|
+
}>, z.ZodObject<{
|
|
241
|
+
run_id: z.ZodString;
|
|
242
|
+
device_id: z.ZodString;
|
|
243
|
+
} & {
|
|
244
|
+
type: z.ZodLiteral<"failure">;
|
|
245
|
+
error: z.ZodString;
|
|
246
|
+
}, "strip", z.ZodTypeAny, {
|
|
247
|
+
type: "failure";
|
|
248
|
+
run_id: string;
|
|
249
|
+
device_id: string;
|
|
250
|
+
error: string;
|
|
251
|
+
}, {
|
|
252
|
+
type: "failure";
|
|
253
|
+
run_id: string;
|
|
254
|
+
device_id: string;
|
|
255
|
+
error: string;
|
|
256
|
+
}>, z.ZodObject<{
|
|
257
|
+
run_id: z.ZodString;
|
|
258
|
+
device_id: z.ZodString;
|
|
259
|
+
} & {
|
|
260
|
+
type: z.ZodLiteral<"cancel">;
|
|
261
|
+
}, "strip", z.ZodTypeAny, {
|
|
262
|
+
type: "cancel";
|
|
263
|
+
run_id: string;
|
|
264
|
+
device_id: string;
|
|
265
|
+
}, {
|
|
266
|
+
type: "cancel";
|
|
267
|
+
run_id: string;
|
|
268
|
+
device_id: string;
|
|
269
|
+
}>]>;
|
|
270
|
+
export declare const RunResultSchema: z.ZodObject<{
|
|
271
|
+
run_id: z.ZodString;
|
|
272
|
+
device_id: z.ZodString;
|
|
273
|
+
} & {
|
|
274
|
+
type: z.ZodLiteral<"done">;
|
|
275
|
+
success: z.ZodBoolean;
|
|
276
|
+
output: z.ZodOptional<z.ZodString>;
|
|
277
|
+
final_url: z.ZodOptional<z.ZodString>;
|
|
278
|
+
extractions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
279
|
+
host: z.ZodString;
|
|
280
|
+
slug: z.ZodString;
|
|
281
|
+
records: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
|
|
282
|
+
output_schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
283
|
+
}, "strip", z.ZodTypeAny, {
|
|
284
|
+
output_schema: Record<string, unknown>;
|
|
285
|
+
host: string;
|
|
286
|
+
slug: string;
|
|
287
|
+
records: Record<string, unknown>[];
|
|
288
|
+
}, {
|
|
289
|
+
output_schema: Record<string, unknown>;
|
|
290
|
+
host: string;
|
|
291
|
+
slug: string;
|
|
292
|
+
records: Record<string, unknown>[];
|
|
293
|
+
}>, "many">>;
|
|
294
|
+
downloads: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
295
|
+
filename: z.ZodString;
|
|
296
|
+
path: z.ZodOptional<z.ZodString>;
|
|
297
|
+
mimetype: z.ZodOptional<z.ZodString>;
|
|
298
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
299
|
+
}, "strip", z.ZodTypeAny, {
|
|
300
|
+
filename: string;
|
|
301
|
+
path?: string | undefined;
|
|
302
|
+
mimetype?: string | undefined;
|
|
303
|
+
url?: string | null | undefined;
|
|
304
|
+
}, {
|
|
305
|
+
filename: string;
|
|
306
|
+
path?: string | undefined;
|
|
307
|
+
mimetype?: string | undefined;
|
|
308
|
+
url?: string | null | undefined;
|
|
309
|
+
}>, "many">>;
|
|
310
|
+
}, "strip", z.ZodTypeAny, {
|
|
311
|
+
type: "done";
|
|
312
|
+
run_id: string;
|
|
313
|
+
device_id: string;
|
|
314
|
+
success: boolean;
|
|
315
|
+
output?: string | undefined;
|
|
316
|
+
final_url?: string | undefined;
|
|
317
|
+
extractions?: {
|
|
318
|
+
output_schema: Record<string, unknown>;
|
|
319
|
+
host: string;
|
|
320
|
+
slug: string;
|
|
321
|
+
records: Record<string, unknown>[];
|
|
322
|
+
}[] | undefined;
|
|
323
|
+
downloads?: {
|
|
324
|
+
filename: string;
|
|
325
|
+
path?: string | undefined;
|
|
326
|
+
mimetype?: string | undefined;
|
|
327
|
+
url?: string | null | undefined;
|
|
328
|
+
}[] | undefined;
|
|
329
|
+
}, {
|
|
330
|
+
type: "done";
|
|
331
|
+
run_id: string;
|
|
332
|
+
device_id: string;
|
|
333
|
+
success: boolean;
|
|
334
|
+
output?: string | undefined;
|
|
335
|
+
final_url?: string | undefined;
|
|
336
|
+
extractions?: {
|
|
337
|
+
output_schema: Record<string, unknown>;
|
|
338
|
+
host: string;
|
|
339
|
+
slug: string;
|
|
340
|
+
records: Record<string, unknown>[];
|
|
341
|
+
}[] | undefined;
|
|
342
|
+
downloads?: {
|
|
343
|
+
filename: string;
|
|
344
|
+
path?: string | undefined;
|
|
345
|
+
mimetype?: string | undefined;
|
|
346
|
+
url?: string | null | undefined;
|
|
347
|
+
}[] | undefined;
|
|
348
|
+
}>;
|
|
349
|
+
export declare const RunRecordSchema: z.ZodObject<{
|
|
350
|
+
id: z.ZodString;
|
|
351
|
+
started_at: z.ZodString;
|
|
352
|
+
finished_at: z.ZodNullable<z.ZodString>;
|
|
353
|
+
result: z.ZodNullable<z.ZodObject<{
|
|
354
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
355
|
+
cancelled: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
356
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
357
|
+
output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
358
|
+
}, "strip", z.ZodTypeAny, {
|
|
359
|
+
success?: boolean | null | undefined;
|
|
360
|
+
output?: string | null | undefined;
|
|
361
|
+
cancelled?: boolean | null | undefined;
|
|
362
|
+
reason?: string | null | undefined;
|
|
363
|
+
}, {
|
|
364
|
+
success?: boolean | null | undefined;
|
|
365
|
+
output?: string | null | undefined;
|
|
366
|
+
cancelled?: boolean | null | undefined;
|
|
367
|
+
reason?: string | null | undefined;
|
|
368
|
+
}>>;
|
|
369
|
+
resolved: z.ZodNullable<z.ZodObject<{
|
|
370
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
371
|
+
prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
372
|
+
}, "strip", z.ZodTypeAny, {
|
|
373
|
+
url?: string | null | undefined;
|
|
374
|
+
prompt?: string | null | undefined;
|
|
375
|
+
}, {
|
|
376
|
+
url?: string | null | undefined;
|
|
377
|
+
prompt?: string | null | undefined;
|
|
378
|
+
}>>;
|
|
379
|
+
}, "strip", z.ZodTypeAny, {
|
|
380
|
+
id: string;
|
|
381
|
+
started_at: string;
|
|
382
|
+
finished_at: string | null;
|
|
383
|
+
result: {
|
|
384
|
+
success?: boolean | null | undefined;
|
|
385
|
+
output?: string | null | undefined;
|
|
386
|
+
cancelled?: boolean | null | undefined;
|
|
387
|
+
reason?: string | null | undefined;
|
|
388
|
+
} | null;
|
|
389
|
+
resolved: {
|
|
390
|
+
url?: string | null | undefined;
|
|
391
|
+
prompt?: string | null | undefined;
|
|
392
|
+
} | null;
|
|
393
|
+
}, {
|
|
394
|
+
id: string;
|
|
395
|
+
started_at: string;
|
|
396
|
+
finished_at: string | null;
|
|
397
|
+
result: {
|
|
398
|
+
success?: boolean | null | undefined;
|
|
399
|
+
output?: string | null | undefined;
|
|
400
|
+
cancelled?: boolean | null | undefined;
|
|
401
|
+
reason?: string | null | undefined;
|
|
402
|
+
} | null;
|
|
403
|
+
resolved: {
|
|
404
|
+
url?: string | null | undefined;
|
|
405
|
+
prompt?: string | null | undefined;
|
|
406
|
+
} | null;
|
|
407
|
+
}>;
|
|
408
|
+
export declare const RunsPageSchema: z.ZodObject<{
|
|
409
|
+
data: z.ZodArray<z.ZodObject<{
|
|
410
|
+
id: z.ZodString;
|
|
411
|
+
started_at: z.ZodString;
|
|
412
|
+
finished_at: z.ZodNullable<z.ZodString>;
|
|
413
|
+
result: z.ZodNullable<z.ZodObject<{
|
|
414
|
+
success: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
415
|
+
cancelled: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
416
|
+
reason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
417
|
+
output: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
418
|
+
}, "strip", z.ZodTypeAny, {
|
|
419
|
+
success?: boolean | null | undefined;
|
|
420
|
+
output?: string | null | undefined;
|
|
421
|
+
cancelled?: boolean | null | undefined;
|
|
422
|
+
reason?: string | null | undefined;
|
|
423
|
+
}, {
|
|
424
|
+
success?: boolean | null | undefined;
|
|
425
|
+
output?: string | null | undefined;
|
|
426
|
+
cancelled?: boolean | null | undefined;
|
|
427
|
+
reason?: string | null | undefined;
|
|
428
|
+
}>>;
|
|
429
|
+
resolved: z.ZodNullable<z.ZodObject<{
|
|
430
|
+
url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
431
|
+
prompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
432
|
+
}, "strip", z.ZodTypeAny, {
|
|
433
|
+
url?: string | null | undefined;
|
|
434
|
+
prompt?: string | null | undefined;
|
|
435
|
+
}, {
|
|
436
|
+
url?: string | null | undefined;
|
|
437
|
+
prompt?: string | null | undefined;
|
|
438
|
+
}>>;
|
|
439
|
+
}, "strip", z.ZodTypeAny, {
|
|
440
|
+
id: string;
|
|
441
|
+
started_at: string;
|
|
442
|
+
finished_at: string | null;
|
|
443
|
+
result: {
|
|
444
|
+
success?: boolean | null | undefined;
|
|
445
|
+
output?: string | null | undefined;
|
|
446
|
+
cancelled?: boolean | null | undefined;
|
|
447
|
+
reason?: string | null | undefined;
|
|
448
|
+
} | null;
|
|
449
|
+
resolved: {
|
|
450
|
+
url?: string | null | undefined;
|
|
451
|
+
prompt?: string | null | undefined;
|
|
452
|
+
} | null;
|
|
453
|
+
}, {
|
|
454
|
+
id: string;
|
|
455
|
+
started_at: string;
|
|
456
|
+
finished_at: string | null;
|
|
457
|
+
result: {
|
|
458
|
+
success?: boolean | null | undefined;
|
|
459
|
+
output?: string | null | undefined;
|
|
460
|
+
cancelled?: boolean | null | undefined;
|
|
461
|
+
reason?: string | null | undefined;
|
|
462
|
+
} | null;
|
|
463
|
+
resolved: {
|
|
464
|
+
url?: string | null | undefined;
|
|
465
|
+
prompt?: string | null | undefined;
|
|
466
|
+
} | null;
|
|
467
|
+
}>, "many">;
|
|
468
|
+
hasNextPage: z.ZodBoolean;
|
|
469
|
+
}, "strip", z.ZodTypeAny, {
|
|
470
|
+
data: {
|
|
471
|
+
id: string;
|
|
472
|
+
started_at: string;
|
|
473
|
+
finished_at: string | null;
|
|
474
|
+
result: {
|
|
475
|
+
success?: boolean | null | undefined;
|
|
476
|
+
output?: string | null | undefined;
|
|
477
|
+
cancelled?: boolean | null | undefined;
|
|
478
|
+
reason?: string | null | undefined;
|
|
479
|
+
} | null;
|
|
480
|
+
resolved: {
|
|
481
|
+
url?: string | null | undefined;
|
|
482
|
+
prompt?: string | null | undefined;
|
|
483
|
+
} | null;
|
|
484
|
+
}[];
|
|
485
|
+
hasNextPage: boolean;
|
|
486
|
+
}, {
|
|
487
|
+
data: {
|
|
488
|
+
id: string;
|
|
489
|
+
started_at: string;
|
|
490
|
+
finished_at: string | null;
|
|
491
|
+
result: {
|
|
492
|
+
success?: boolean | null | undefined;
|
|
493
|
+
output?: string | null | undefined;
|
|
494
|
+
cancelled?: boolean | null | undefined;
|
|
495
|
+
reason?: string | null | undefined;
|
|
496
|
+
} | null;
|
|
497
|
+
resolved: {
|
|
498
|
+
url?: string | null | undefined;
|
|
499
|
+
prompt?: string | null | undefined;
|
|
500
|
+
} | null;
|
|
501
|
+
}[];
|
|
502
|
+
hasNextPage: boolean;
|
|
503
|
+
}>;
|
|
504
|
+
export declare const MethodSchema: z.ZodObject<{
|
|
505
|
+
host: z.ZodString;
|
|
506
|
+
method_slug: z.ZodString;
|
|
507
|
+
description: z.ZodString;
|
|
508
|
+
args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
509
|
+
output_schema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
510
|
+
}, "strip", z.ZodTypeAny, {
|
|
511
|
+
output_schema: Record<string, unknown> | null;
|
|
512
|
+
args: Record<string, unknown>;
|
|
513
|
+
host: string;
|
|
514
|
+
method_slug: string;
|
|
515
|
+
description: string;
|
|
516
|
+
}, {
|
|
517
|
+
output_schema: Record<string, unknown> | null;
|
|
518
|
+
args: Record<string, unknown>;
|
|
519
|
+
host: string;
|
|
520
|
+
method_slug: string;
|
|
521
|
+
description: string;
|
|
522
|
+
}>;
|
|
523
|
+
export declare const SiteSchema: z.ZodObject<{
|
|
524
|
+
host: z.ZodString;
|
|
525
|
+
methods: z.ZodArray<z.ZodObject<{
|
|
526
|
+
host: z.ZodString;
|
|
527
|
+
method_slug: z.ZodString;
|
|
528
|
+
description: z.ZodString;
|
|
529
|
+
args: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
530
|
+
output_schema: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
531
|
+
}, "strip", z.ZodTypeAny, {
|
|
532
|
+
output_schema: Record<string, unknown> | null;
|
|
533
|
+
args: Record<string, unknown>;
|
|
534
|
+
host: string;
|
|
535
|
+
method_slug: string;
|
|
536
|
+
description: string;
|
|
537
|
+
}, {
|
|
538
|
+
output_schema: Record<string, unknown> | null;
|
|
539
|
+
args: Record<string, unknown>;
|
|
540
|
+
host: string;
|
|
541
|
+
method_slug: string;
|
|
542
|
+
description: string;
|
|
543
|
+
}>, "many">;
|
|
544
|
+
}, "strip", z.ZodTypeAny, {
|
|
545
|
+
host: string;
|
|
546
|
+
methods: {
|
|
547
|
+
output_schema: Record<string, unknown> | null;
|
|
548
|
+
args: Record<string, unknown>;
|
|
549
|
+
host: string;
|
|
550
|
+
method_slug: string;
|
|
551
|
+
description: string;
|
|
552
|
+
}[];
|
|
553
|
+
}, {
|
|
554
|
+
host: string;
|
|
555
|
+
methods: {
|
|
556
|
+
output_schema: Record<string, unknown> | null;
|
|
557
|
+
args: Record<string, unknown>;
|
|
558
|
+
host: string;
|
|
559
|
+
method_slug: string;
|
|
560
|
+
description: string;
|
|
561
|
+
}[];
|
|
562
|
+
}>;
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const DeviceSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
name: z.string().nullable(),
|
|
5
|
+
browser: z.string().nullable(),
|
|
6
|
+
os: z.string().nullable(),
|
|
7
|
+
reachable: z.boolean(),
|
|
8
|
+
created_at: z.string(),
|
|
9
|
+
});
|
|
10
|
+
const RunEventBase = z.object({ run_id: z.string(), device_id: z.string() });
|
|
11
|
+
const RunRequestedArgsSchema = z.object({
|
|
12
|
+
mount: z.array(z.string()).optional(),
|
|
13
|
+
method: z.string().optional(),
|
|
14
|
+
method_args: z.record(z.string()).optional(),
|
|
15
|
+
paste_slots: z.record(z.string()).optional(),
|
|
16
|
+
output_schema: z.record(z.unknown()).optional(),
|
|
17
|
+
});
|
|
18
|
+
export const RunEventSchema = z.discriminatedUnion("type", [
|
|
19
|
+
RunEventBase.extend({
|
|
20
|
+
type: z.literal("run_requested"),
|
|
21
|
+
query: z.string(),
|
|
22
|
+
args: RunRequestedArgsSchema,
|
|
23
|
+
cli_args: z.record(z.unknown()).optional(),
|
|
24
|
+
}),
|
|
25
|
+
RunEventBase.extend({ type: z.literal("progress"), text: z.string(), timestamp: z.number() }),
|
|
26
|
+
RunEventBase.extend({ type: z.literal("assistant"), text: z.string(), timestamp: z.number() }),
|
|
27
|
+
RunEventBase.extend({ type: z.literal("turn_completed"), timestamp: z.number() }),
|
|
28
|
+
RunEventBase.extend({ type: z.literal("run_started"), timestamp: z.number() }),
|
|
29
|
+
RunEventBase.extend({ type: z.literal("run_completed"), timestamp: z.number() }),
|
|
30
|
+
RunEventBase.extend({
|
|
31
|
+
type: z.literal("done"),
|
|
32
|
+
success: z.boolean(),
|
|
33
|
+
output: z.string().optional(),
|
|
34
|
+
final_url: z.string().optional(),
|
|
35
|
+
extractions: z.array(z.object({
|
|
36
|
+
host: z.string(),
|
|
37
|
+
slug: z.string(),
|
|
38
|
+
records: z.array(z.record(z.unknown())),
|
|
39
|
+
output_schema: z.record(z.unknown()),
|
|
40
|
+
})).optional(),
|
|
41
|
+
downloads: z.array(z.object({
|
|
42
|
+
filename: z.string(),
|
|
43
|
+
path: z.string().optional(),
|
|
44
|
+
mimetype: z.string().optional(),
|
|
45
|
+
url: z.string().nullable().optional(),
|
|
46
|
+
})).optional(),
|
|
47
|
+
}),
|
|
48
|
+
RunEventBase.extend({ type: z.literal("failure"), error: z.string() }),
|
|
49
|
+
RunEventBase.extend({ type: z.literal("cancel") }),
|
|
50
|
+
]);
|
|
51
|
+
export const RunResultSchema = RunEventBase.extend({
|
|
52
|
+
type: z.literal("done"),
|
|
53
|
+
success: z.boolean(),
|
|
54
|
+
output: z.string().optional(),
|
|
55
|
+
final_url: z.string().optional(),
|
|
56
|
+
extractions: z.array(z.object({
|
|
57
|
+
host: z.string(),
|
|
58
|
+
slug: z.string(),
|
|
59
|
+
records: z.array(z.record(z.unknown())),
|
|
60
|
+
output_schema: z.record(z.unknown()),
|
|
61
|
+
})).optional(),
|
|
62
|
+
downloads: z.array(z.object({
|
|
63
|
+
filename: z.string(),
|
|
64
|
+
path: z.string().optional(),
|
|
65
|
+
mimetype: z.string().optional(),
|
|
66
|
+
url: z.string().nullable().optional(),
|
|
67
|
+
})).optional(),
|
|
68
|
+
});
|
|
69
|
+
export const RunRecordSchema = z.object({
|
|
70
|
+
id: z.string(),
|
|
71
|
+
started_at: z.string(),
|
|
72
|
+
finished_at: z.string().nullable(),
|
|
73
|
+
result: z.object({
|
|
74
|
+
success: z.boolean().nullable().optional(),
|
|
75
|
+
cancelled: z.boolean().nullable().optional(),
|
|
76
|
+
reason: z.string().nullable().optional(),
|
|
77
|
+
output: z.string().nullable().optional(),
|
|
78
|
+
}).nullable(),
|
|
79
|
+
resolved: z.object({
|
|
80
|
+
url: z.string().nullable().optional(),
|
|
81
|
+
prompt: z.string().nullable().optional(),
|
|
82
|
+
}).nullable(),
|
|
83
|
+
});
|
|
84
|
+
export const RunsPageSchema = z.object({
|
|
85
|
+
data: z.array(RunRecordSchema),
|
|
86
|
+
hasNextPage: z.boolean(),
|
|
87
|
+
});
|
|
88
|
+
export const MethodSchema = z.object({
|
|
89
|
+
host: z.string(),
|
|
90
|
+
method_slug: z.string(),
|
|
91
|
+
description: z.string(),
|
|
92
|
+
args: z.record(z.unknown()),
|
|
93
|
+
output_schema: z.record(z.unknown()).nullable(),
|
|
94
|
+
});
|
|
95
|
+
export const SiteSchema = z.object({
|
|
96
|
+
host: z.string(),
|
|
97
|
+
methods: z.array(MethodSchema),
|
|
98
|
+
});
|
package/dist/types.d.ts
CHANGED
|
@@ -1,47 +1,16 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
export type RunRequestedEvent = RunEventBase & {
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import * as S from "./schemas.js";
|
|
3
|
+
export type Device = z.infer<typeof S.DeviceSchema>;
|
|
4
|
+
export type RunEvent = z.infer<typeof S.RunEventSchema>;
|
|
5
|
+
export type RunResult = z.infer<typeof S.RunResultSchema>;
|
|
6
|
+
export type RunRecord = z.infer<typeof S.RunRecordSchema>;
|
|
7
|
+
export type RunsPage = z.infer<typeof S.RunsPageSchema>;
|
|
8
|
+
export type Method = z.infer<typeof S.MethodSchema>;
|
|
9
|
+
export type Site = z.infer<typeof S.SiteSchema>;
|
|
10
|
+
export type RunRequestedEvent = Extract<RunEvent, {
|
|
13
11
|
type: "run_requested";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
cli_args?: Record<string, unknown>;
|
|
17
|
-
};
|
|
18
|
-
export type RunEvent = RunRequestedEvent | (RunEventBase & {
|
|
19
|
-
type: "progress";
|
|
20
|
-
text: string;
|
|
21
|
-
timestamp: number;
|
|
22
|
-
}) | (RunEventBase & {
|
|
23
|
-
type: "assistant";
|
|
24
|
-
text: string;
|
|
25
|
-
timestamp: number;
|
|
26
|
-
}) | (RunEventBase & {
|
|
27
|
-
type: "turn_completed";
|
|
28
|
-
timestamp: number;
|
|
29
|
-
}) | (RunEventBase & {
|
|
30
|
-
type: "run_started";
|
|
31
|
-
timestamp: number;
|
|
32
|
-
}) | (RunEventBase & {
|
|
33
|
-
type: "run_completed";
|
|
34
|
-
timestamp: number;
|
|
35
|
-
}) | (RunEventBase & {
|
|
36
|
-
type: "done";
|
|
37
|
-
success: boolean;
|
|
38
|
-
output?: string;
|
|
39
|
-
}) | (RunEventBase & {
|
|
40
|
-
type: "failure";
|
|
41
|
-
error: string;
|
|
42
|
-
}) | (RunEventBase & {
|
|
43
|
-
type: "cancel";
|
|
44
|
-
});
|
|
12
|
+
}>;
|
|
13
|
+
export type RunRequestedArgs = RunRequestedEvent["args"];
|
|
45
14
|
export interface RunOptions {
|
|
46
15
|
deviceId: string;
|
|
47
16
|
mount?: string[];
|
|
@@ -51,34 +20,6 @@ export interface RunOptions {
|
|
|
51
20
|
outputSchema?: object;
|
|
52
21
|
slug?: string;
|
|
53
22
|
}
|
|
54
|
-
export declare function authHeader(opts: ReduckClientOptions): Record<string, string>;
|
|
55
|
-
export interface Device {
|
|
56
|
-
id: string;
|
|
57
|
-
name: string | null;
|
|
58
|
-
browser: string | null;
|
|
59
|
-
os: string | null;
|
|
60
|
-
reachable: boolean;
|
|
61
|
-
created_at: string;
|
|
62
|
-
}
|
|
63
|
-
export interface RunRecord {
|
|
64
|
-
id: string;
|
|
65
|
-
started_at: string;
|
|
66
|
-
finished_at: string | null;
|
|
67
|
-
result: {
|
|
68
|
-
success?: boolean;
|
|
69
|
-
cancelled?: boolean;
|
|
70
|
-
reason?: string;
|
|
71
|
-
output?: string;
|
|
72
|
-
} | null;
|
|
73
|
-
resolved: {
|
|
74
|
-
url?: string;
|
|
75
|
-
prompt?: string;
|
|
76
|
-
} | null;
|
|
77
|
-
}
|
|
78
|
-
export interface RunsPage {
|
|
79
|
-
data: RunRecord[];
|
|
80
|
-
hasNextPage: boolean;
|
|
81
|
-
}
|
|
82
23
|
export interface ReduckClientOptions {
|
|
83
24
|
oauthToken?: string;
|
|
84
25
|
apiKey?: string;
|
|
@@ -86,15 +27,4 @@ export interface ReduckClientOptions {
|
|
|
86
27
|
appBaseUrl?: string;
|
|
87
28
|
headers?: Record<string, string>;
|
|
88
29
|
}
|
|
89
|
-
export
|
|
90
|
-
host: string;
|
|
91
|
-
method_slug: string;
|
|
92
|
-
description: string;
|
|
93
|
-
args: Record<string, unknown>;
|
|
94
|
-
output_schema: Record<string, unknown> | null;
|
|
95
|
-
}
|
|
96
|
-
export interface Site {
|
|
97
|
-
host: string;
|
|
98
|
-
methods: Method[];
|
|
99
|
-
}
|
|
100
|
-
export {};
|
|
30
|
+
export declare function authHeader(opts: ReduckClientOptions): Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reduck-ai/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.18",
|
|
4
4
|
"description": "TypeScript SDK for Reduck — run browser automations programmatically.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Reduck AI <contact@reduck.ai> (https://reduck.ai)",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"dev": "pnpm exec tsc --watch"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"ws": "^8.0.0"
|
|
47
|
+
"ws": "^8.0.0",
|
|
48
|
+
"zod": "^3.24.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@types/ws": "^8.0.0",
|