@reduck-ai/sdk 1.1.2 → 1.1.11

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/LICENSE CHANGED
@@ -1,190 +1,21 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to the Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by the Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding any notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- Copyright 2025 Conception AI
179
-
180
- Licensed under the Apache License, Version 2.0 (the "License");
181
- you may not use this file except in compliance with the License.
182
- You may obtain a copy of the License at
183
-
184
- http://www.apache.org/licenses/LICENSE-2.0
185
-
186
- Unless required by applicable law or agreed to in writing, software
187
- distributed under the License is distributed on an "AS IS" BASIS,
188
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
- See the License for the specific language governing permissions and
190
- limitations under the License.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Reduck AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -17,32 +17,34 @@ npm install @reduck-ai/sdk
17
17
  ```typescript
18
18
  import { ReduckClient } from "@reduck-ai/sdk"
19
19
 
20
- const client = new ReduckClient({
21
- apiKey: "your-api-key",
22
- })
20
+ const client = new ReduckClient({ apiKey: "your-api-key" })
23
21
 
22
+ // Run an inline task
24
23
  const devices = await client.listDevices()
25
-
26
24
  const run = client.run("Go to google.com and search for 'reduck ai'", {
27
25
  deviceId: devices[0].id,
28
26
  })
29
27
 
30
28
  for await (const event of run) {
29
+ if (event.type === "run_requested") console.log("started:", event.run_id)
31
30
  if (event.type === "progress") console.log(event.text)
32
- if (event.type === "done") console.log(event.success ? "Done" : "Failed")
31
+ if (event.type === "done") console.log(event.success ? "Done" : "Failed", event.output)
33
32
  }
33
+
34
+ // Discover what's available
35
+ const sites = await client.searchSites("messaging")
36
+ const site = await client.getSite("linkedin.com")
37
+ const method = await client.getMethod("linkedin.com/get_profile_info")
34
38
  ```
35
39
 
36
40
  ## Authentication
37
41
 
38
- Pass either an API key or an OAuth token:
39
-
40
42
  ```typescript
41
43
  // API key (recommended for server-side)
42
- const client = new ReduckClient({ apiKey: "rk_..." })
44
+ const client = new ReduckClient({ apiKey: "<your-api-key>" })
43
45
 
44
46
  // OAuth token (for user-facing apps)
45
- const client = new ReduckClient({ oauthToken: "..." })
47
+ const client = new ReduckClient({ oauthToken: "<your-oauth-token>" })
46
48
  ```
47
49
 
48
50
  Generate an API key from your [Reduck dashboard](https://reduck.ai).
@@ -55,9 +57,33 @@ Generate an API key from your [Reduck dashboard](https://reduck.ai).
55
57
  |---|---|---|
56
58
  | `apiKey` | `string` | API key authentication |
57
59
  | `oauthToken` | `string` | OAuth bearer token authentication |
60
+ | `runnerBaseUrl` | `string` | Override runner base URL (default: hosted) |
61
+ | `appBaseUrl` | `string` | Override app base URL (default: hosted) |
62
+ | `headers` | `Record<string, string>` | Extra headers to send on every request |
58
63
 
59
64
  One of `apiKey` or `oauthToken` is required.
60
65
 
66
+ ### `client.run(query, options)`
67
+
68
+ 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
+ | Option | Type | Description |
71
+ |---|---|---|
72
+ | `deviceId` | `string` | Target device ID (required) |
73
+ | `method` | `string` | Invoke a typed method `<host>/<slug>` (mutually exclusive with `query`) |
74
+ | `methodArgs` | `Record<string, string>` | Arguments rendered into the method's `prompt_template`. Requires `method` |
75
+ | `mount` | `string[]` | Local file paths to upload and make available to `click_upload` |
76
+ | `pasteSlots` | `Record<string, string>` | Named slots inserted via `paste(slot=...)` |
77
+ | `outputSchema` | `object` | Inline vision extractor JSON schema (mutually exclusive with `method`) |
78
+
79
+ ### `run.id`
80
+
81
+ `Promise<string>` — resolves to the run ID once the server accepts the run.
82
+
83
+ ### `run.cancel()`
84
+
85
+ Cancels the running automation.
86
+
61
87
  ### `client.listDevices()`
62
88
 
63
89
  Returns `Promise<Device[]>` — all devices for the authenticated user.
@@ -73,26 +99,9 @@ interface Device {
73
99
  }
74
100
  ```
75
101
 
76
- ### `client.run(prompt, options)`
77
-
78
- Starts an automation and returns a `Run` — an `AsyncIterable<RunEvent>` that streams events in real-time via WebSocket.
79
-
80
- | Option | Type | Description |
81
- |---|---|---|
82
- | `deviceId` | `string` | Target device ID (required) |
83
- | `mount` | `string[]` | Local file paths to upload and make available |
84
-
85
- ### `run.id`
86
-
87
- `Promise<string>` — resolves to the run ID once the server accepts it.
88
-
89
- ### `run.cancel()`
90
-
91
- Cancels the running automation.
92
-
93
102
  ### `client.listRuns(page?)`
94
103
 
95
- Returns `Promise<RunsPage>` — a paginated list of runs (sessions) for the authenticated user.
104
+ Returns `Promise<RunsPage>` — a paginated list of runs.
96
105
 
97
106
  ```typescript
98
107
  interface RunsPage {
@@ -101,10 +110,6 @@ interface RunsPage {
101
110
  }
102
111
  ```
103
112
 
104
- | Option | Type | Default | Description |
105
- |---|---|---|---|
106
- | `page` | `number` | `0` | Zero-based page index |
107
-
108
113
  ### `client.getRun(runId)`
109
114
 
110
115
  Returns `Promise<RunRecord>` — a single run by ID.
@@ -117,8 +122,8 @@ interface RunRecord {
117
122
  result: {
118
123
  success?: boolean
119
124
  cancelled?: boolean
120
- reason?: string
121
125
  output?: string
126
+ error?: { code: string; message: string } | null
122
127
  } | null
123
128
  resolved: {
124
129
  url?: string
@@ -131,21 +136,53 @@ interface RunRecord {
131
136
 
132
137
  Interrupts a run by ID.
133
138
 
139
+ ### Method discovery
140
+
141
+ ```typescript
142
+ // Rank methods by semantic match
143
+ const matches = await client.searchMethods("linkedin profile info")
144
+
145
+ // Rank sites by best matching method
146
+ const sites = await client.searchSites("messaging")
147
+
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
+ const site = await client.getSite("linkedin.com")
153
+ ```
154
+
134
155
  ## Events
135
156
 
136
- The `run` async iterable yields these events:
157
+ The `run` async iterable yields these events. Every event carries `run_id` and `device_id` for correlation.
137
158
 
138
- | Type | Fields | Description |
159
+ | Type | Extra fields | Description |
139
160
  |---|---|---|
140
- | `run_started` | `timestamp` | Automation has started |
161
+ | `run_requested` | `query`, `args` | Server accepted the run; emitted before WebSocket connection |
162
+ | `run_started` | `timestamp` | Agent loop has started |
141
163
  | `progress` | `text`, `timestamp` | Step-by-step progress update |
142
- | `assistant` | `text`, `timestamp` | Assistant message |
143
- | `turn_completed` | `timestamp` | Agent turn completed |
144
- | `run_completed` | `timestamp` | Automation finished executing |
145
- | `done` | `success`, `output?` | Final result |
146
- | `failure` | `error` | Automation failed |
147
- | `cancel` | — | Automation was cancelled |
164
+ | `assistant` | `text`, `timestamp` | Assistant reasoning between tool calls |
165
+ | `turn_completed` | `timestamp` | Agent turn (one LLM call) completed |
166
+ | `run_completed` | `timestamp` | Agent loop finished |
167
+ | `done` | `success`, `output?` | Agent called `done` — final result |
168
+ | `failure` | `error`, `error_code?` | Run failed |
169
+ | `cancel` | — | Run was cancelled |
170
+
171
+ ```typescript
172
+ type RunEventBase = { run_id: string; device_id: string }
173
+
174
+ type RunEvent =
175
+ | (RunEventBase & { type: "run_requested"; query: string; args: RunRequestedArgs })
176
+ | (RunEventBase & { type: "run_started"; timestamp: number })
177
+ | (RunEventBase & { type: "progress"; text: string; timestamp: number })
178
+ | (RunEventBase & { type: "assistant"; text: string; timestamp: number })
179
+ | (RunEventBase & { type: "turn_completed"; timestamp: number })
180
+ | (RunEventBase & { type: "run_completed"; timestamp: number })
181
+ | (RunEventBase & { type: "done"; success: boolean; output?: string })
182
+ | (RunEventBase & { type: "failure"; error: string })
183
+ | (RunEventBase & { type: "cancel" })
184
+ ```
148
185
 
149
186
  ## License
150
187
 
151
- Apache-2.0
188
+ MIT
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Device, type ReduckClientOptions, type RunOptions, type RunRecord, type RunsPage } from "./types.js";
1
+ import { type Device, type Method, type ReduckClientOptions, type RunOptions, type RunRecord, type RunsPage, type Site } from "./types.js";
2
2
  import { Run } from "./run.js";
3
3
  export declare class ReduckClient {
4
4
  private readonly _runnerBaseUrl;
@@ -6,11 +6,16 @@ export declare class ReduckClient {
6
6
  private readonly _headers;
7
7
  constructor(opts: ReduckClientOptions);
8
8
  consentNotice(): Promise<void>;
9
- run(prompt: string, { mount, deviceId }: RunOptions): Run;
9
+ run(query: string, { mount, deviceId, method, methodArgs, pasteSlots, outputSchema, slug }: RunOptions): Run;
10
10
  listDevices(): Promise<Device[]>;
11
11
  listRuns(page?: number): Promise<RunsPage>;
12
12
  getRun(runId: string): Promise<RunRecord>;
13
+ searchMethods(query: string): Promise<Method[]>;
14
+ searchSites(query: string): Promise<Site[]>;
15
+ getMethod(slug: string): Promise<Method>;
16
+ getSite(host: string): Promise<Site>;
13
17
  interrupt(runId: string): Promise<void>;
14
18
  private _createRun;
15
19
  private _mount;
20
+ private _pasteFiles;
16
21
  }
package/dist/client.js CHANGED
@@ -7,6 +7,8 @@ import { authHeader } from "./types.js";
7
7
  import { Run } from "./run.js";
8
8
  import { fetchDevices } from "./device.js";
9
9
  import { fetchRun, fetchRuns } from "./session.js";
10
+ import { fetchSearchMethods, fetchSearchSites } from "./search.js";
11
+ import { fetchGetMethod, fetchGetSite } from "./get.js";
10
12
  import { RUNNER_URL, APP_URL } from "./build-env.generated.js";
11
13
  export class ReduckClient {
12
14
  _runnerBaseUrl;
@@ -40,14 +42,14 @@ export class ReduckClient {
40
42
  if (!post.ok)
41
43
  throw ReduckError.fromResponse("POST /consent-notice", post.status);
42
44
  }
43
- run(prompt, { mount, deviceId }) {
45
+ run(query, { mount, deviceId, method, methodArgs, pasteSlots, outputSchema, slug }) {
44
46
  if (!deviceId)
45
47
  throw new ReduckError("deviceId is required to start a run", { code: "MISSING_DEVICE" });
46
- const runIdPromise = this._createRun(deviceId, prompt, mount);
48
+ const requestedPromise = this._createRun(deviceId, query, mount, method, methodArgs, pasteSlots, outputSchema, slug);
47
49
  const wsBase = this._runnerBaseUrl
48
50
  .replace("https://", "wss://")
49
51
  .replace("http://", "ws://");
50
- return new Run(runIdPromise, wsBase, this._headers);
52
+ return new Run(requestedPromise, wsBase, this._headers);
51
53
  }
52
54
  async listDevices() {
53
55
  return fetchDevices(this._appBaseUrl, this._headers);
@@ -58,14 +60,27 @@ export class ReduckClient {
58
60
  async getRun(runId) {
59
61
  return fetchRun(this._appBaseUrl, this._headers, runId);
60
62
  }
63
+ async searchMethods(query) {
64
+ return fetchSearchMethods(this._runnerBaseUrl, this._headers, query);
65
+ }
66
+ async searchSites(query) {
67
+ return fetchSearchSites(this._runnerBaseUrl, this._headers, query);
68
+ }
69
+ async getMethod(slug) {
70
+ return fetchGetMethod(this._runnerBaseUrl, this._headers, slug);
71
+ }
72
+ async getSite(host) {
73
+ return fetchGetSite(this._runnerBaseUrl, this._headers, host);
74
+ }
61
75
  async interrupt(runId) {
62
76
  await fetch(`${this._runnerBaseUrl}/run/${runId}/cancel`, {
63
77
  method: "POST",
64
78
  headers: this._headers,
65
79
  });
66
80
  }
67
- async _createRun(deviceId, prompt, mount) {
81
+ async _createRun(deviceId, query, mount, method, methodArgs, pasteSlots, outputSchema, slug) {
68
82
  const mountedPaths = mount?.length ? await this._mount(mount) : undefined;
83
+ const stagedPaste = pasteSlots ? await this._pasteFiles(pasteSlots) : undefined;
69
84
  const res = await fetch(`${this._runnerBaseUrl}/query`, {
70
85
  method: "POST",
71
86
  headers: {
@@ -73,15 +88,18 @@ export class ReduckClient {
73
88
  ...this._headers,
74
89
  },
75
90
  body: JSON.stringify({
76
- prompt,
91
+ query,
77
92
  device_id: deviceId,
78
93
  ...(mountedPaths?.length ? { mount: mountedPaths } : {}),
94
+ ...(method ? { method } : {}),
95
+ ...(methodArgs && Object.keys(methodArgs).length ? { method_args: methodArgs } : {}),
96
+ ...(stagedPaste && Object.keys(stagedPaste).length ? { paste_slots: stagedPaste } : {}),
97
+ ...(outputSchema ? { output_schema: outputSchema, slug: slug ?? "summary" } : {}),
79
98
  }),
80
99
  });
81
100
  if (!res.ok)
82
101
  throw ReduckError.fromResponse("POST /query", res.status);
83
- const data = (await res.json());
84
- return data.run_id;
102
+ return (await res.json());
85
103
  }
86
104
  async _mount(paths) {
87
105
  const destDir = join(homedir(), "Downloads", ".reduck");
@@ -92,4 +110,21 @@ export class ReduckClient {
92
110
  return dest;
93
111
  }));
94
112
  }
113
+ async _pasteFiles(slots) {
114
+ const destDir = join(homedir(), "Downloads", ".reduck", "paste");
115
+ await mkdir(destDir, { recursive: true });
116
+ const result = {};
117
+ await Promise.all(Object.entries(slots).map(async ([key, val]) => {
118
+ if (val.startsWith("@")) {
119
+ const src = val.slice(1);
120
+ const dest = join(destDir, basename(src));
121
+ await cp(src, dest);
122
+ result[key] = dest;
123
+ }
124
+ else {
125
+ result[key] = val;
126
+ }
127
+ }));
128
+ return result;
129
+ }
95
130
  }
package/dist/get.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { Method, Site } from "./types.js";
2
+ export declare function fetchGetMethod(appBaseUrl: string, headers: Record<string, string>, slug: string): Promise<Method>;
3
+ export declare function fetchGetSite(appBaseUrl: string, headers: Record<string, string>, host: string): Promise<Site>;
package/dist/get.js ADDED
@@ -0,0 +1,16 @@
1
+ export async function fetchGetMethod(appBaseUrl, headers, slug) {
2
+ const res = await fetch(`${appBaseUrl}/methods/${encodeURIComponent(slug)}`, { headers });
3
+ if (res.status === 404)
4
+ throw new Error(`Method not found: ${slug}`);
5
+ if (!res.ok)
6
+ throw new Error(`Get method failed (HTTP ${res.status})`);
7
+ return res.json();
8
+ }
9
+ export async function fetchGetSite(appBaseUrl, headers, host) {
10
+ const res = await fetch(`${appBaseUrl}/sites/${encodeURIComponent(host)}`, { headers });
11
+ if (res.status === 404)
12
+ throw new Error(`Site not found: ${host}`);
13
+ if (!res.ok)
14
+ throw new Error(`Get site failed (HTTP ${res.status})`);
15
+ return res.json();
16
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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, RunEvent, RunOptions, RunRecord, RunsPage, ReduckClientOptions } from "./types.js";
4
+ export type { Device, Method, RunEvent, RunOptions, RunRecord, RunsPage, ReduckClientOptions, Site } from "./types.js";
package/dist/run.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { RunEvent } from "./types.js";
1
+ import type { RunEvent, RunRequestedEvent } from "./types.js";
2
2
  export declare class Run implements AsyncIterable<RunEvent> {
3
- private readonly _runIdPromise;
3
+ private readonly _requestedPromise;
4
4
  private readonly _wsBase;
5
5
  private readonly _headers;
6
6
  private _ws;
7
- constructor(runIdPromise: Promise<string>, wsBase: string, headers: Record<string, string>);
7
+ constructor(requestedPromise: Promise<RunRequestedEvent>, wsBase: string, headers: Record<string, string>);
8
8
  get id(): Promise<string>;
9
9
  [Symbol.asyncIterator](): AsyncGenerator<RunEvent>;
10
10
  private _stream;
package/dist/run.js CHANGED
@@ -1,23 +1,25 @@
1
1
  import WebSocket from "ws";
2
2
  import { ReduckError } from "./errors.js";
3
3
  export class Run {
4
- _runIdPromise;
4
+ _requestedPromise;
5
5
  _wsBase;
6
6
  _headers;
7
7
  _ws = null;
8
- constructor(runIdPromise, wsBase, headers) {
9
- this._runIdPromise = runIdPromise;
8
+ constructor(requestedPromise, wsBase, headers) {
9
+ this._requestedPromise = requestedPromise;
10
10
  this._wsBase = wsBase;
11
11
  this._headers = headers;
12
12
  }
13
13
  get id() {
14
- return this._runIdPromise;
14
+ return this._requestedPromise.then((e) => e.run_id);
15
15
  }
16
16
  [Symbol.asyncIterator]() {
17
17
  return this._stream();
18
18
  }
19
19
  async *_stream() {
20
- const runId = await this._runIdPromise;
20
+ const requested = await this._requestedPromise;
21
+ yield requested;
22
+ const runId = requested.run_id;
21
23
  const wsUrl = `${this._wsBase}/run/${runId}/events`;
22
24
  const ws = new WebSocket(wsUrl, { headers: this._headers });
23
25
  this._ws = ws;
@@ -59,7 +61,7 @@ export class Run {
59
61
  }
60
62
  }
61
63
  async cancel() {
62
- const runId = await this._runIdPromise;
64
+ const runId = (await this._requestedPromise).run_id;
63
65
  const baseUrl = this._wsBase
64
66
  .replace("wss://", "https://")
65
67
  .replace("ws://", "http://");
@@ -0,0 +1,3 @@
1
+ import type { Method, Site } from "./types.js";
2
+ export declare function fetchSearchMethods(appBaseUrl: string, headers: Record<string, string>, query: string): Promise<Method[]>;
3
+ export declare function fetchSearchSites(appBaseUrl: string, headers: Record<string, string>, query: string): Promise<Site[]>;
package/dist/search.js ADDED
@@ -0,0 +1,14 @@
1
+ export async function fetchSearchMethods(appBaseUrl, headers, query) {
2
+ const url = `${appBaseUrl}/methods?q=${encodeURIComponent(query)}`;
3
+ const res = await fetch(url, { headers });
4
+ if (!res.ok)
5
+ throw new Error(`Search methods failed (HTTP ${res.status})`);
6
+ return res.json();
7
+ }
8
+ export async function fetchSearchSites(appBaseUrl, headers, query) {
9
+ const url = `${appBaseUrl}/sites?q=${encodeURIComponent(query)}`;
10
+ const res = await fetch(url, { headers });
11
+ if (!res.ok)
12
+ throw new Error(`Search sites failed (HTTP ${res.status})`);
13
+ return res.json();
14
+ }
package/dist/types.d.ts CHANGED
@@ -1,33 +1,55 @@
1
- export type RunEvent = {
1
+ type RunEventBase = {
2
+ run_id: string;
3
+ device_id: string;
4
+ };
5
+ export interface RunRequestedArgs {
6
+ mount?: string[];
7
+ method?: string;
8
+ method_args?: Record<string, string>;
9
+ paste_slots?: Record<string, string>;
10
+ output_schema?: object;
11
+ }
12
+ export type RunRequestedEvent = RunEventBase & {
13
+ type: "run_requested";
14
+ query: string;
15
+ args: RunRequestedArgs;
16
+ cli_args?: Record<string, unknown>;
17
+ };
18
+ export type RunEvent = RunRequestedEvent | (RunEventBase & {
2
19
  type: "progress";
3
20
  text: string;
4
21
  timestamp: number;
5
- } | {
22
+ }) | (RunEventBase & {
6
23
  type: "assistant";
7
24
  text: string;
8
25
  timestamp: number;
9
- } | {
26
+ }) | (RunEventBase & {
10
27
  type: "turn_completed";
11
28
  timestamp: number;
12
- } | {
29
+ }) | (RunEventBase & {
13
30
  type: "run_started";
14
31
  timestamp: number;
15
- } | {
32
+ }) | (RunEventBase & {
16
33
  type: "run_completed";
17
34
  timestamp: number;
18
- } | {
35
+ }) | (RunEventBase & {
19
36
  type: "done";
20
37
  success: boolean;
21
38
  output?: string;
22
- } | {
39
+ }) | (RunEventBase & {
23
40
  type: "failure";
24
41
  error: string;
25
- } | {
42
+ }) | (RunEventBase & {
26
43
  type: "cancel";
27
- };
44
+ });
28
45
  export interface RunOptions {
29
46
  deviceId: string;
30
47
  mount?: string[];
48
+ method?: string;
49
+ methodArgs?: Record<string, string>;
50
+ pasteSlots?: Record<string, string>;
51
+ outputSchema?: object;
52
+ slug?: string;
31
53
  }
32
54
  export declare function authHeader(opts: ReduckClientOptions): Record<string, string>;
33
55
  export interface Device {
@@ -64,3 +86,15 @@ export interface ReduckClientOptions {
64
86
  appBaseUrl?: string;
65
87
  headers?: Record<string, string>;
66
88
  }
89
+ export interface Method {
90
+ host: string;
91
+ method_slug: string;
92
+ display_name: string;
93
+ description: string;
94
+ }
95
+ export interface Site {
96
+ host: string;
97
+ display_name: string;
98
+ methods: Method[];
99
+ }
100
+ export {};
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@reduck-ai/sdk",
3
- "version": "1.1.2",
3
+ "version": "1.1.11",
4
4
  "description": "TypeScript SDK for Reduck — run browser automations programmatically.",
5
- "license": "Apache-2.0",
5
+ "license": "MIT",
6
6
  "author": "Reduck AI <contact@reduck.ai> (https://reduck.ai)",
7
7
  "homepage": "https://reduck.ai",
8
- "keywords": ["reduck", "browser-automation", "sdk", "ai", "rpa"],
8
+ "keywords": [
9
+ "reduck",
10
+ "browser-automation",
11
+ "sdk",
12
+ "ai",
13
+ "rpa"
14
+ ],
9
15
  "funding": "https://reduck.ai",
10
16
  "sideEffects": false,
11
17
  "type": "module",