@reduck-ai/sdk 1.1.19 → 1.1.21

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 CHANGED
@@ -19,7 +19,6 @@ import { ReduckClient } from "@reduck-ai/sdk"
19
19
 
20
20
  const client = new ReduckClient({ apiKey: "your-api-key" })
21
21
 
22
- // Run an inline task
23
22
  const devices = await client.listDevices()
24
23
  const run = client.run("Go to google.com and search for 'reduck ai'", {
25
24
  deviceId: devices[0].id,
@@ -28,13 +27,15 @@ const run = client.run("Go to google.com and search for 'reduck ai'", {
28
27
  for await (const event of run) {
29
28
  if (event.type === "run_requested") console.log("started:", event.run_id)
30
29
  if (event.type === "progress") console.log(event.text)
31
- if (event.type === "done") console.log(event.success ? "Done" : "Failed", event.output)
30
+ if (event.type === "done") {
31
+ console.log(event.success ? "Done" : "Failed", event.output)
32
+ if (event.extractions) console.log("records:", event.extractions)
33
+ }
32
34
  }
33
35
 
34
- // Discover what's available
36
+ // Site discovery
35
37
  const sites = await client.searchSites("messaging")
36
38
  const site = await client.getSite("linkedin.com")
37
- const method = await client.getMethod("linkedin.com/get_profile_info")
38
39
  ```
39
40
 
40
41
  ## Authentication
@@ -67,14 +68,17 @@ One of `apiKey` or `oauthToken` is required.
67
68
 
68
69
  Starts an automation and returns a `Run` — an `AsyncIterable<RunEvent>` that streams events in real-time via WebSocket. The first event yielded is `run_requested` (synchronously after the server accepts the run, before WebSocket events flow).
69
70
 
71
+ When invoking a typed method, pass `query: ""` and set `method` + `methodArgs`.
72
+
70
73
  | Option | Type | Description |
71
74
  |---|---|---|
72
75
  | `deviceId` | `string` | Target device ID (required) |
73
- | `method` | `string` | Invoke a typed method `<host>/<slug>` (mutually exclusive with `query`) |
76
+ | `method` | `string` | Invoke a typed method `<host>/<slug>` (mutually exclusive with `outputSchema`) |
74
77
  | `methodArgs` | `Record<string, string>` | Arguments rendered into the method's `prompt_template`. Requires `method` |
75
78
  | `mount` | `string[]` | Local file paths to upload and make available to `click_upload` |
76
79
  | `pasteSlots` | `Record<string, string>` | Named slots inserted via `paste(slot=...)` |
77
80
  | `outputSchema` | `object` | Inline vision extractor JSON schema (mutually exclusive with `method`) |
81
+ | `slug` | `string` | Custom extractor slug for inline `outputSchema` (default: `summary`) |
78
82
 
79
83
  ### `run.id`
80
84
 
@@ -124,6 +128,9 @@ interface RunRecord {
124
128
  cancelled?: boolean
125
129
  output?: string
126
130
  error?: { code: string; message: string } | null
131
+ final_url?: string
132
+ extractions?: SlugExtraction[]
133
+ downloads?: DownloadedFile[]
127
134
  } | null
128
135
  resolved: {
129
136
  url?: string
@@ -136,53 +143,101 @@ interface RunRecord {
136
143
 
137
144
  Interrupts a run by ID.
138
145
 
139
- ### Method discovery
146
+ ### Site discovery
140
147
 
141
148
  ```typescript
142
- // Rank methods by semantic match
143
- const matches = await client.searchMethods("linkedin profile info")
144
-
145
- // Rank sites by best matching method
149
+ // Sites whose host matches the query
146
150
  const sites = await client.searchSites("messaging")
147
151
 
148
- // Read a method's full surface
149
- const method = await client.getMethod("linkedin.com/get_profile_info")
150
-
151
- // Read a site's public surface
152
+ // Full surface of a host
152
153
  const site = await client.getSite("linkedin.com")
153
154
  ```
154
155
 
156
+ `Site` shape:
157
+
158
+ ```typescript
159
+ interface Site {
160
+ host: string
161
+ notes: string
162
+ methods: Method[]
163
+ }
164
+
165
+ interface Method {
166
+ method_slug: string
167
+ description: string
168
+ args: Record<string, unknown> // JSON Schema for method args
169
+ output_schema: Record<string, unknown> | null
170
+ }
171
+ ```
172
+
155
173
  ## Events
156
174
 
157
175
  The `run` async iterable yields these events. Every event carries `run_id` and `device_id` for correlation.
158
176
 
159
177
  | Type | Extra fields | Description |
160
178
  |---|---|---|
161
- | `run_requested` | `query`, `args` | Server accepted the run; emitted before WebSocket connection |
179
+ | `run_requested` | `query?`, `args` | Server accepted the run; emitted before WebSocket connection |
162
180
  | `run_started` | `timestamp` | Agent loop has started |
163
181
  | `progress` | `text`, `timestamp` | Step-by-step progress update |
164
182
  | `assistant` | `text`, `timestamp` | Assistant reasoning between tool calls |
165
183
  | `turn_completed` | `timestamp` | Agent turn (one LLM call) completed |
166
184
  | `run_completed` | `timestamp` | Agent loop finished |
167
- | `done` | `success`, `output?` | Agent called `done` — final result |
168
- | `failure` | `error`, `error_code?` | Run failed |
185
+ | `done` | `success`, `output?`, `final_url?`, `extractions?`, `downloads?` | Agent called `done` — final result with collected data |
186
+ | `failure` | `error` | Run failed |
169
187
  | `cancel` | — | Run was cancelled |
170
188
 
171
189
  ```typescript
172
190
  type RunEventBase = { run_id: string; device_id: string }
173
191
 
174
192
  type RunEvent =
175
- | (RunEventBase & { type: "run_requested"; query: string; args: RunRequestedArgs })
193
+ | (RunEventBase & { type: "run_requested"; query?: string; args: RunRequestedArgs })
176
194
  | (RunEventBase & { type: "run_started"; timestamp: number })
177
195
  | (RunEventBase & { type: "progress"; text: string; timestamp: number })
178
196
  | (RunEventBase & { type: "assistant"; text: string; timestamp: number })
179
197
  | (RunEventBase & { type: "turn_completed"; timestamp: number })
180
198
  | (RunEventBase & { type: "run_completed"; timestamp: number })
181
- | (RunEventBase & { type: "done"; success: boolean; output?: string })
199
+ | (RunEventBase & {
200
+ type: "done"
201
+ success: boolean
202
+ output?: string
203
+ final_url?: string
204
+ extractions?: SlugExtraction[]
205
+ downloads?: DownloadedFile[]
206
+ })
182
207
  | (RunEventBase & { type: "failure"; error: string })
183
208
  | (RunEventBase & { type: "cancel" })
209
+
210
+ interface SlugExtraction {
211
+ host: string
212
+ slug: string
213
+ records: object[]
214
+ output_schema: object
215
+ }
216
+
217
+ interface DownloadedFile {
218
+ filename: string
219
+ path?: string // full path on the runner — re-usable as `mount` in a follow-up run
220
+ mimetype?: string
221
+ url?: string | null
222
+ }
184
223
  ```
185
224
 
225
+ `final_url`, `extractions`, and `downloads` on the `done` event are present only when the run produced them. `downloads[].path` can be reused as `mount` in a follow-up `client.run(...)` to chain workflows.
226
+
227
+ ## Schemas as JSON Schema
228
+
229
+ All public shapes are also exposed as Zod schemas via the `schemas` namespace:
230
+
231
+ ```typescript
232
+ import { schemas } from "@reduck-ai/sdk"
233
+
234
+ schemas.RunEventSchema.parse(json) // validate at runtime
235
+ schemas.RunResultSchema // the final `done` event shape
236
+ schemas.SiteSchema, schemas.MethodSchema, schemas.DeviceSchema, ...
237
+ ```
238
+
239
+ The `reduck schema <name>` CLI command emits these as JSON Schema (draft-7) for non-TS consumers.
240
+
186
241
  ## License
187
242
 
188
243
  MIT
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Device, type ReduckClientOptions, type RunOptions, type RunRecord, type RunsPage, type Site } from "./types.js";
1
+ import { type Device, type ListMethodsOptions, type ListSitesOptions, type Method, type MethodsPage, type ReduckClientOptions, type RunOptions, type RunRecord, type RunsPage, type Site, type SitesPage } from "./types.js";
2
2
  import { Run } from "./run.js";
3
3
  export declare class ReduckClient {
4
4
  private readonly _runnerBaseUrl;
@@ -9,8 +9,10 @@ export declare class ReduckClient {
9
9
  listDevices(): Promise<Device[]>;
10
10
  listRuns(page?: number): Promise<RunsPage>;
11
11
  getRun(runId: string): Promise<RunRecord>;
12
- searchSites(query: string): Promise<Site[]>;
12
+ listSites(options?: ListSitesOptions): Promise<SitesPage>;
13
13
  getSite(host: string): Promise<Site>;
14
+ listMethods(options?: ListMethodsOptions): Promise<MethodsPage>;
15
+ getMethod(host: string, slug: string): Promise<Method>;
14
16
  interrupt(runId: string): Promise<void>;
15
17
  private _createRun;
16
18
  private _mount;
package/dist/client.js CHANGED
@@ -6,8 +6,8 @@ import { authHeader } from "./types.js";
6
6
  import { Run } from "./run.js";
7
7
  import { fetchDevices } from "./device.js";
8
8
  import { fetchRun, fetchRuns } from "./session.js";
9
- import { fetchSearchSites } from "./search.js";
10
- import { fetchGetSite } from "./get.js";
9
+ import { fetchSite, fetchSites } from "./site.js";
10
+ import { fetchMethod, fetchMethods } from "./method.js";
11
11
  import { RUNNER_URL, APP_URL } from "./build-env.generated.js";
12
12
  export class ReduckClient {
13
13
  _runnerBaseUrl;
@@ -36,11 +36,17 @@ export class ReduckClient {
36
36
  async getRun(runId) {
37
37
  return fetchRun(this._appBaseUrl, this._headers, runId);
38
38
  }
39
- async searchSites(query) {
40
- return fetchSearchSites(this._runnerBaseUrl, this._headers, query);
39
+ async listSites(options = {}) {
40
+ return fetchSites(this._appBaseUrl, this._headers, options);
41
41
  }
42
42
  async getSite(host) {
43
- return fetchGetSite(this._runnerBaseUrl, this._headers, host);
43
+ return fetchSite(this._appBaseUrl, this._headers, host);
44
+ }
45
+ async listMethods(options = {}) {
46
+ return fetchMethods(this._appBaseUrl, this._headers, options);
47
+ }
48
+ async getMethod(host, slug) {
49
+ return fetchMethod(this._appBaseUrl, this._headers, host, slug);
44
50
  }
45
51
  async interrupt(runId) {
46
52
  await fetch(`${this._runnerBaseUrl}/run/${runId}/cancel`, {
package/dist/index.d.ts CHANGED
@@ -1,5 +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, RunResult, RunOptions, RunRecord, RunsPage, ReduckClientOptions, Site } from "./types.js";
4
+ export type { Device, ListMethodsOptions, ListSitesOptions, Method, MethodsPage, PaginationParameters, ReduckClientOptions, RunEvent, RunOptions, RunRecord, RunResult, RunsPage, Site, SitesPage, } from "./types.js";
5
5
  export * as schemas from "./schemas.js";
@@ -0,0 +1,3 @@
1
+ import type { ListMethodsOptions, Method, MethodsPage } from "./types.js";
2
+ export declare function fetchMethods(appBaseUrl: string, headers: Record<string, string>, options?: ListMethodsOptions): Promise<MethodsPage>;
3
+ export declare function fetchMethod(appBaseUrl: string, headers: Record<string, string>, host: string, slug: string): Promise<Method>;
package/dist/method.js ADDED
@@ -0,0 +1,23 @@
1
+ import { ReduckError } from "./errors.js";
2
+ export async function fetchMethods(appBaseUrl, headers, options = {}) {
3
+ const params = new URLSearchParams();
4
+ if (options.q)
5
+ params.set("q", options.q);
6
+ if (options.host)
7
+ params.set("host", options.host);
8
+ if (options.page !== undefined)
9
+ params.set("page", String(options.page));
10
+ if (options.pageSize !== undefined)
11
+ params.set("pageSize", String(options.pageSize));
12
+ const qs = params.toString();
13
+ const res = await fetch(`${appBaseUrl}/api/methods${qs ? `?${qs}` : ""}`, { headers });
14
+ if (!res.ok)
15
+ throw ReduckError.fromResponse("GET /api/methods", res.status);
16
+ return (await res.json());
17
+ }
18
+ export async function fetchMethod(appBaseUrl, headers, host, slug) {
19
+ const res = await fetch(`${appBaseUrl}/api/methods/${encodeURIComponent(host)}/${encodeURIComponent(slug)}`, { headers });
20
+ if (!res.ok)
21
+ throw ReduckError.fromResponse(`GET /api/methods/${host}/${slug}`, res.status);
22
+ return (await res.json());
23
+ }
package/dist/schemas.d.ts CHANGED
@@ -523,7 +523,40 @@ export declare const MethodSchema: z.ZodObject<{
523
523
  export declare const SiteSchema: z.ZodObject<{
524
524
  host: z.ZodString;
525
525
  notes: z.ZodDefault<z.ZodString>;
526
- methods: z.ZodArray<z.ZodObject<{
526
+ }, "strip", z.ZodTypeAny, {
527
+ host: string;
528
+ notes: string;
529
+ }, {
530
+ host: string;
531
+ notes?: string | undefined;
532
+ }>;
533
+ export declare const SitesPageSchema: z.ZodObject<{
534
+ data: z.ZodArray<z.ZodObject<{
535
+ host: z.ZodString;
536
+ notes: z.ZodDefault<z.ZodString>;
537
+ }, "strip", z.ZodTypeAny, {
538
+ host: string;
539
+ notes: string;
540
+ }, {
541
+ host: string;
542
+ notes?: string | undefined;
543
+ }>, "many">;
544
+ hasNextPage: z.ZodBoolean;
545
+ }, "strip", z.ZodTypeAny, {
546
+ data: {
547
+ host: string;
548
+ notes: string;
549
+ }[];
550
+ hasNextPage: boolean;
551
+ }, {
552
+ data: {
553
+ host: string;
554
+ notes?: string | undefined;
555
+ }[];
556
+ hasNextPage: boolean;
557
+ }>;
558
+ export declare const MethodsPageSchema: z.ZodObject<{
559
+ data: z.ZodArray<z.ZodObject<{
527
560
  host: z.ZodString;
528
561
  method_slug: z.ZodString;
529
562
  description: z.ZodString;
@@ -542,24 +575,23 @@ export declare const SiteSchema: z.ZodObject<{
542
575
  method_slug: string;
543
576
  description: string;
544
577
  }>, "many">;
578
+ hasNextPage: z.ZodBoolean;
545
579
  }, "strip", z.ZodTypeAny, {
546
- host: string;
547
- notes: string;
548
- methods: {
580
+ data: {
549
581
  output_schema: Record<string, unknown> | null;
550
582
  args: Record<string, unknown>;
551
583
  host: string;
552
584
  method_slug: string;
553
585
  description: string;
554
586
  }[];
587
+ hasNextPage: boolean;
555
588
  }, {
556
- host: string;
557
- methods: {
589
+ data: {
558
590
  output_schema: Record<string, unknown> | null;
559
591
  args: Record<string, unknown>;
560
592
  host: string;
561
593
  method_slug: string;
562
594
  description: string;
563
595
  }[];
564
- notes?: string | undefined;
596
+ hasNextPage: boolean;
565
597
  }>;
package/dist/schemas.js CHANGED
@@ -95,5 +95,12 @@ export const MethodSchema = z.object({
95
95
  export const SiteSchema = z.object({
96
96
  host: z.string(),
97
97
  notes: z.string().default(""),
98
- methods: z.array(MethodSchema),
98
+ });
99
+ export const SitesPageSchema = z.object({
100
+ data: z.array(SiteSchema),
101
+ hasNextPage: z.boolean(),
102
+ });
103
+ export const MethodsPageSchema = z.object({
104
+ data: z.array(MethodSchema),
105
+ hasNextPage: z.boolean(),
99
106
  });
package/dist/site.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { ListSitesOptions, Site, SitesPage } from "./types.js";
2
+ export declare function fetchSites(appBaseUrl: string, headers: Record<string, string>, options?: ListSitesOptions): Promise<SitesPage>;
3
+ export declare function fetchSite(appBaseUrl: string, headers: Record<string, string>, host: string): Promise<Site>;
package/dist/site.js ADDED
@@ -0,0 +1,21 @@
1
+ import { ReduckError } from "./errors.js";
2
+ export async function fetchSites(appBaseUrl, headers, options = {}) {
3
+ const params = new URLSearchParams();
4
+ if (options.q)
5
+ params.set("q", options.q);
6
+ if (options.page !== undefined)
7
+ params.set("page", String(options.page));
8
+ if (options.pageSize !== undefined)
9
+ params.set("pageSize", String(options.pageSize));
10
+ const qs = params.toString();
11
+ const res = await fetch(`${appBaseUrl}/api/sites${qs ? `?${qs}` : ""}`, { headers });
12
+ if (!res.ok)
13
+ throw ReduckError.fromResponse("GET /api/sites", res.status);
14
+ return (await res.json());
15
+ }
16
+ export async function fetchSite(appBaseUrl, headers, host) {
17
+ const res = await fetch(`${appBaseUrl}/api/sites/${encodeURIComponent(host)}`, { headers });
18
+ if (!res.ok)
19
+ throw ReduckError.fromResponse(`GET /api/sites/${host}`, res.status);
20
+ return (await res.json());
21
+ }
package/dist/types.d.ts CHANGED
@@ -6,7 +6,20 @@ export type RunResult = z.infer<typeof S.RunResultSchema>;
6
6
  export type RunRecord = z.infer<typeof S.RunRecordSchema>;
7
7
  export type RunsPage = z.infer<typeof S.RunsPageSchema>;
8
8
  export type Method = z.infer<typeof S.MethodSchema>;
9
+ export type MethodsPage = z.infer<typeof S.MethodsPageSchema>;
9
10
  export type Site = z.infer<typeof S.SiteSchema>;
11
+ export type SitesPage = z.infer<typeof S.SitesPageSchema>;
12
+ export interface PaginationParameters {
13
+ page?: number;
14
+ pageSize?: number;
15
+ }
16
+ export interface ListSitesOptions extends PaginationParameters {
17
+ q?: string;
18
+ }
19
+ export interface ListMethodsOptions extends PaginationParameters {
20
+ q?: string;
21
+ host?: string;
22
+ }
10
23
  export type RunRequestedEvent = Extract<RunEvent, {
11
24
  type: "run_requested";
12
25
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reduck-ai/sdk",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
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)",
@@ -33,16 +33,6 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "scripts": {
37
- "generate-env": "node ../scripts/generate-build-env.mjs ./src/build-env.generated.ts",
38
- "prebuild": "pnpm generate-env",
39
- "build": "pnpm exec tsc",
40
- "build:production": "REDUCK_BUILD_ENV=production pnpm build",
41
- "build:staging": "REDUCK_BUILD_ENV=staging pnpm build",
42
- "precheck": "pnpm generate-env",
43
- "check": "pnpm exec tsc --noEmit",
44
- "dev": "pnpm exec tsc --watch"
45
- },
46
36
  "dependencies": {
47
37
  "ws": "^8.0.0",
48
38
  "zod": "^3.24.0"
@@ -54,5 +44,15 @@
54
44
  "repository": {
55
45
  "type": "git",
56
46
  "url": "git+https://github.com/conception-ai/conception-clean-for-real.git"
47
+ },
48
+ "scripts": {
49
+ "generate-env": "node ../scripts/generate-build-env.mjs ./src/build-env.generated.ts",
50
+ "prebuild": "pnpm generate-env",
51
+ "build": "pnpm exec tsc",
52
+ "build:production": "REDUCK_BUILD_ENV=production pnpm build",
53
+ "build:staging": "REDUCK_BUILD_ENV=staging pnpm build",
54
+ "precheck": "pnpm generate-env",
55
+ "check": "pnpm exec tsc --noEmit",
56
+ "dev": "pnpm exec tsc --watch"
57
57
  }
58
- }
58
+ }
package/dist/get.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { Site } from "./types.js";
2
- export declare function fetchGetSite(appBaseUrl: string, headers: Record<string, string>, host: string): Promise<Site>;
package/dist/get.js DELETED
@@ -1,8 +0,0 @@
1
- export async function fetchGetSite(appBaseUrl, headers, host) {
2
- const res = await fetch(`${appBaseUrl}/sites/${encodeURIComponent(host)}`, { headers });
3
- if (res.status === 404)
4
- throw new Error(`Site not found: ${host}`);
5
- if (!res.ok)
6
- throw new Error(`Get site failed (HTTP ${res.status})`);
7
- return res.json();
8
- }
package/dist/search.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { Site } from "./types.js";
2
- export declare function fetchSearchSites(appBaseUrl: string, headers: Record<string, string>, query: string): Promise<Site[]>;
package/dist/search.js DELETED
@@ -1,7 +0,0 @@
1
- export async function fetchSearchSites(appBaseUrl, headers, query) {
2
- const url = `${appBaseUrl}/sites?q=${encodeURIComponent(query)}`;
3
- const res = await fetch(url, { headers });
4
- if (!res.ok)
5
- throw new Error(`Search sites failed (HTTP ${res.status})`);
6
- return res.json();
7
- }