@reduck-ai/sdk 1.1.11 → 1.1.14
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 +1 -4
- package/dist/client.js +2 -32
- package/dist/get.d.ts +1 -2
- package/dist/get.js +0 -8
- package/dist/search.d.ts +1 -2
- package/dist/search.js +0 -7
- package/dist/types.d.ts +2 -2
- package/dist/types.js +2 -2
- package/package.json +12 -12
package/dist/client.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { type Device, type
|
|
1
|
+
import { type Device, 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;
|
|
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>;
|
|
12
11
|
getRun(runId: string): Promise<RunRecord>;
|
|
13
|
-
searchMethods(query: string): Promise<Method[]>;
|
|
14
12
|
searchSites(query: string): Promise<Site[]>;
|
|
15
|
-
getMethod(slug: string): Promise<Method>;
|
|
16
13
|
getSite(host: string): Promise<Site>;
|
|
17
14
|
interrupt(runId: string): Promise<void>;
|
|
18
15
|
private _createRun;
|
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";
|
|
@@ -7,8 +6,8 @@ import { authHeader } from "./types.js";
|
|
|
7
6
|
import { Run } from "./run.js";
|
|
8
7
|
import { fetchDevices } from "./device.js";
|
|
9
8
|
import { fetchRun, fetchRuns } from "./session.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { fetchSearchSites } from "./search.js";
|
|
10
|
+
import { fetchGetSite } from "./get.js";
|
|
12
11
|
import { RUNNER_URL, APP_URL } from "./build-env.generated.js";
|
|
13
12
|
export class ReduckClient {
|
|
14
13
|
_runnerBaseUrl;
|
|
@@ -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" });
|
|
@@ -60,15 +36,9 @@ export class ReduckClient {
|
|
|
60
36
|
async getRun(runId) {
|
|
61
37
|
return fetchRun(this._appBaseUrl, this._headers, runId);
|
|
62
38
|
}
|
|
63
|
-
async searchMethods(query) {
|
|
64
|
-
return fetchSearchMethods(this._runnerBaseUrl, this._headers, query);
|
|
65
|
-
}
|
|
66
39
|
async searchSites(query) {
|
|
67
40
|
return fetchSearchSites(this._runnerBaseUrl, this._headers, query);
|
|
68
41
|
}
|
|
69
|
-
async getMethod(slug) {
|
|
70
|
-
return fetchGetMethod(this._runnerBaseUrl, this._headers, slug);
|
|
71
|
-
}
|
|
72
42
|
async getSite(host) {
|
|
73
43
|
return fetchGetSite(this._runnerBaseUrl, this._headers, host);
|
|
74
44
|
}
|
package/dist/get.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function fetchGetMethod(appBaseUrl: string, headers: Record<string, string>, slug: string): Promise<Method>;
|
|
1
|
+
import type { Site } from "./types.js";
|
|
3
2
|
export declare function fetchGetSite(appBaseUrl: string, headers: Record<string, string>, host: string): Promise<Site>;
|
package/dist/get.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
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
1
|
export async function fetchGetSite(appBaseUrl, headers, host) {
|
|
10
2
|
const res = await fetch(`${appBaseUrl}/sites/${encodeURIComponent(host)}`, { headers });
|
|
11
3
|
if (res.status === 404)
|
package/dist/search.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function fetchSearchMethods(appBaseUrl: string, headers: Record<string, string>, query: string): Promise<Method[]>;
|
|
1
|
+
import type { Site } from "./types.js";
|
|
3
2
|
export declare function fetchSearchSites(appBaseUrl: string, headers: Record<string, string>, query: string): Promise<Site[]>;
|
package/dist/search.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
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
1
|
export async function fetchSearchSites(appBaseUrl, headers, query) {
|
|
9
2
|
const url = `${appBaseUrl}/sites?q=${encodeURIComponent(query)}`;
|
|
10
3
|
const res = await fetch(url, { headers });
|
package/dist/types.d.ts
CHANGED
|
@@ -89,12 +89,12 @@ export interface ReduckClientOptions {
|
|
|
89
89
|
export interface Method {
|
|
90
90
|
host: string;
|
|
91
91
|
method_slug: string;
|
|
92
|
-
display_name: string;
|
|
93
92
|
description: string;
|
|
93
|
+
args: Record<string, unknown>;
|
|
94
|
+
output_schema: Record<string, unknown> | null;
|
|
94
95
|
}
|
|
95
96
|
export interface Site {
|
|
96
97
|
host: string;
|
|
97
|
-
display_name: string;
|
|
98
98
|
methods: Method[];
|
|
99
99
|
}
|
|
100
100
|
export {};
|
package/dist/types.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ReduckError } from "./errors.js";
|
|
2
2
|
export function authHeader(opts) {
|
|
3
3
|
if (opts.oauthToken)
|
|
4
|
-
return { Authorization: `Bearer ${opts.oauthToken}` };
|
|
4
|
+
return { Authorization: `Bearer ${opts.oauthToken.trim()}` };
|
|
5
5
|
if (opts.apiKey)
|
|
6
|
-
return { "X-API-Key": opts.apiKey };
|
|
6
|
+
return { "X-API-Key": opts.apiKey.trim() };
|
|
7
7
|
throw new ReduckError("Either oauthToken or apiKey is required", { code: "MISSING_CREDENTIALS" });
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reduck-ai/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
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
|
},
|
|
@@ -53,5 +43,15 @@
|
|
|
53
43
|
"repository": {
|
|
54
44
|
"type": "git",
|
|
55
45
|
"url": "git+https://github.com/conception-ai/conception-clean-for-real.git"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"generate-env": "node ../scripts/generate-build-env.mjs ./src/build-env.generated.ts",
|
|
49
|
+
"prebuild": "pnpm generate-env",
|
|
50
|
+
"build": "pnpm exec tsc",
|
|
51
|
+
"build:production": "REDUCK_BUILD_ENV=production pnpm build",
|
|
52
|
+
"build:staging": "REDUCK_BUILD_ENV=staging pnpm build",
|
|
53
|
+
"precheck": "pnpm generate-env",
|
|
54
|
+
"check": "pnpm exec tsc --noEmit",
|
|
55
|
+
"dev": "pnpm exec tsc --watch"
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|