@reduck-ai/sdk 1.1.19 → 1.1.20

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 (2) hide show
  1. package/README.md +74 -19
  2. package/package.json +12 -12
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reduck-ai/sdk",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
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
+ }