@tiny-fish/sdk 0.0.5 → 0.0.6
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 +165 -10
- package/dist/_utils/client.d.ts +14 -9
- package/dist/_utils/client.d.ts.map +1 -1
- package/dist/_utils/client.js +93 -41
- package/dist/_utils/client.js.map +1 -1
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +5 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/types.d.ts +6 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/browser/index.d.ts +18 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +21 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/types.d.ts +13 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +5 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -0
- package/dist/client.js.map +1 -1
- package/dist/fetch/index.d.ts +10 -0
- package/dist/fetch/index.d.ts.map +1 -0
- package/dist/fetch/index.js +29 -0
- package/dist/fetch/index.js.map +1 -0
- package/dist/fetch/types.d.ts +58 -0
- package/dist/fetch/types.d.ts.map +1 -0
- package/dist/fetch/types.js +11 -0
- package/dist/fetch/types.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/search/index.d.ts +14 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +24 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/types.d.ts +26 -0
- package/dist/search/types.d.ts.map +1 -0
- package/dist/search/types.js +5 -0
- package/dist/search/types.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
The official TypeScript SDK for [TinyFish](https://agent.tinyfish.ai)
|
|
4
4
|
|
|
5
|
+
For SDK design conventions and how new API surfaces should be added, see [ARCHITECTURE.md](ARCHITECTURE.md).
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
npm install
|
|
10
|
+
npm install @tiny-fish/sdk
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
Requires Node.js 18+. Also works with Bun and Deno.
|
|
@@ -17,7 +19,7 @@ Sign up and grab your key at [agent.tinyfish.ai/api-keys](https://agent.tinyfish
|
|
|
17
19
|
## Quickstart
|
|
18
20
|
|
|
19
21
|
```typescript
|
|
20
|
-
import { TinyFish } from "
|
|
22
|
+
import { TinyFish } from "@tiny-fish/sdk";
|
|
21
23
|
|
|
22
24
|
const client = new TinyFish({ apiKey: "your-api-key" });
|
|
23
25
|
|
|
@@ -37,6 +39,24 @@ for await (const event of stream) {
|
|
|
37
39
|
}
|
|
38
40
|
```
|
|
39
41
|
|
|
42
|
+
Need per-request cancellation without changing the client-wide timeout? Pass an `AbortSignal` as the optional second argument:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
|
|
47
|
+
const stream = await client.agent.stream(
|
|
48
|
+
{
|
|
49
|
+
goal: "Extract the top 5 headlines",
|
|
50
|
+
url: "https://news.ycombinator.com",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
signal: controller.signal,
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
controller.abort();
|
|
58
|
+
```
|
|
59
|
+
|
|
40
60
|
Or set the `TINYFISH_API_KEY` environment variable and omit `apiKey`:
|
|
41
61
|
|
|
42
62
|
```typescript
|
|
@@ -52,8 +72,11 @@ const client = new TinyFish();
|
|
|
52
72
|
| [`agent.stream()`](#agentstream--real-time-events) | Stream live SSE events as the agent works | `AgentStream` | No |
|
|
53
73
|
| [`agent.run()`](#agentrun--block-until-done) | Run an automation, wait for the result | `AgentRunResponse` | Yes |
|
|
54
74
|
| [`agent.queue()`](#agentqueue--fire-and-forget) | Start an automation, return immediately | `AgentRunAsyncResponse` | No |
|
|
75
|
+
| [`browser.sessions.create()`](#browsersessionscreate--create-a-browser-session) | Create a remote browser session | `BrowserSession` | — |
|
|
76
|
+
| [`fetch.getContents()`](#fetchgetcontents--fetch-and-extract-content) | Fetch URLs and return extracted content | `FetchResponse` | — |
|
|
55
77
|
| [`runs.get()`](#runsget--retrieve-a-single-run) | Retrieve a single run by ID | `Run` | — |
|
|
56
78
|
| [`runs.list()`](#runslist--list-and-filter-runs) | List runs with filtering, sorting, pagination | `RunListResponse` | — |
|
|
79
|
+
| [`search.query()`](#searchquery--run-a-web-search) | Run a web search query | `SearchQueryResponse` | — |
|
|
57
80
|
|
|
58
81
|
---
|
|
59
82
|
|
|
@@ -62,7 +85,7 @@ const client = new TinyFish();
|
|
|
62
85
|
Opens a Server-Sent Events stream. You get live progress updates as the agent works, plus a URL for a live browser preview. This is the recommended integration method.
|
|
63
86
|
|
|
64
87
|
```typescript
|
|
65
|
-
import { TinyFish } from "
|
|
88
|
+
import { TinyFish } from "@tiny-fish/sdk";
|
|
66
89
|
|
|
67
90
|
const client = new TinyFish();
|
|
68
91
|
|
|
@@ -92,6 +115,25 @@ for await (const event of stream) {
|
|
|
92
115
|
|
|
93
116
|
Call `stream.close()` to abort early and stop yielding events.
|
|
94
117
|
|
|
118
|
+
The second argument also accepts `signal` for request-scoped cancellation:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const controller = new AbortController();
|
|
122
|
+
|
|
123
|
+
const stream = await client.agent.stream(
|
|
124
|
+
{
|
|
125
|
+
goal: "Extract the top 5 headlines",
|
|
126
|
+
url: "https://news.ycombinator.com",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
signal: controller.signal,
|
|
130
|
+
onProgress: (e) => console.log(e.purpose),
|
|
131
|
+
},
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
controller.abort();
|
|
135
|
+
```
|
|
136
|
+
|
|
95
137
|
See the [Streaming Guide](docs/streaming-guide.md) for the full event lifecycle, event types, and advanced patterns.
|
|
96
138
|
|
|
97
139
|
---
|
|
@@ -101,8 +143,8 @@ See the [Streaming Guide](docs/streaming-guide.md) for the full event lifecycle,
|
|
|
101
143
|
Sends the automation and waits for it to finish. Returns the full result in one shot.
|
|
102
144
|
|
|
103
145
|
```typescript
|
|
104
|
-
import { TinyFish, RunStatus, BrowserProfile, ProxyCountryCode } from "
|
|
105
|
-
import type { ProxyConfig } from "
|
|
146
|
+
import { TinyFish, RunStatus, BrowserProfile, ProxyCountryCode } from "@tiny-fish/sdk";
|
|
147
|
+
import type { ProxyConfig } from "@tiny-fish/sdk";
|
|
106
148
|
|
|
107
149
|
const client = new TinyFish();
|
|
108
150
|
|
|
@@ -123,6 +165,22 @@ if (response.status === RunStatus.COMPLETED) {
|
|
|
123
165
|
}
|
|
124
166
|
```
|
|
125
167
|
|
|
168
|
+
Like `stream()`, `run()` accepts an optional second argument with `signal`:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const controller = new AbortController();
|
|
172
|
+
|
|
173
|
+
const response = await client.agent.run(
|
|
174
|
+
{
|
|
175
|
+
goal: "Extract the top 5 headlines",
|
|
176
|
+
url: "https://news.ycombinator.com",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
signal: controller.signal,
|
|
180
|
+
},
|
|
181
|
+
);
|
|
182
|
+
```
|
|
183
|
+
|
|
126
184
|
**Returns `AgentRunResponse`:**
|
|
127
185
|
|
|
128
186
|
| Field | Type | Description |
|
|
@@ -142,7 +200,7 @@ if (response.status === RunStatus.COMPLETED) {
|
|
|
142
200
|
Starts the automation in the background and returns a `run_id` immediately. Poll with `runs.get()` when you're ready for the result.
|
|
143
201
|
|
|
144
202
|
```typescript
|
|
145
|
-
import { TinyFish, RunStatus } from "
|
|
203
|
+
import { TinyFish, RunStatus } from "@tiny-fish/sdk";
|
|
146
204
|
|
|
147
205
|
const client = new TinyFish();
|
|
148
206
|
|
|
@@ -169,6 +227,8 @@ while (true) {
|
|
|
169
227
|
}
|
|
170
228
|
```
|
|
171
229
|
|
|
230
|
+
`queue()` also accepts an optional `{ signal }` second argument when you want to cancel just that enqueue request.
|
|
231
|
+
|
|
172
232
|
**Returns `AgentRunAsyncResponse`** — a discriminated union. Check `error` to narrow the type:
|
|
173
233
|
|
|
174
234
|
```typescript
|
|
@@ -189,6 +249,69 @@ if (response.error) {
|
|
|
189
249
|
|
|
190
250
|
---
|
|
191
251
|
|
|
252
|
+
### `browser.sessions.create()` — create a browser session
|
|
253
|
+
|
|
254
|
+
Create a remote browser session and get back the connection details for direct CDP control. Pass a `url` to hint routing and start the session on a target page, or omit it to start at `about:blank`.
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
import { TinyFish } from "@tiny-fish/sdk";
|
|
258
|
+
|
|
259
|
+
const client = new TinyFish();
|
|
260
|
+
|
|
261
|
+
const session = await client.browser.sessions.create({
|
|
262
|
+
url: "https://example.com",
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
console.log(session.session_id);
|
|
266
|
+
console.log(session.cdp_url);
|
|
267
|
+
console.log(session.base_url);
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Returns `BrowserSession`:**
|
|
271
|
+
|
|
272
|
+
| Field | Type | Description |
|
|
273
|
+
|-------|------|-------------|
|
|
274
|
+
| `session_id` | `string` | Unique browser session identifier |
|
|
275
|
+
| `cdp_url` | `string` | CDP WebSocket URL for connecting to the browser |
|
|
276
|
+
| `base_url` | `string` | HTTPS base URL for the browser session |
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
### `fetch.getContents()` — fetch and extract content
|
|
281
|
+
|
|
282
|
+
Fetch one or more URLs and return clean extracted content in markdown, html, or json form.
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
import { FetchFormat, TinyFish } from "@tiny-fish/sdk";
|
|
286
|
+
|
|
287
|
+
const client = new TinyFish();
|
|
288
|
+
|
|
289
|
+
const response = await client.fetch.getContents({
|
|
290
|
+
urls: ["https://example.com"],
|
|
291
|
+
format: FetchFormat.Markdown,
|
|
292
|
+
links: true,
|
|
293
|
+
image_links: false,
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
console.log(response.results);
|
|
297
|
+
console.log(response.errors);
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Returns `FetchResponse`:**
|
|
301
|
+
|
|
302
|
+
| Field | Type | Description |
|
|
303
|
+
|-------|------|-------------|
|
|
304
|
+
| `results` | `FetchResult[]` | Successfully fetched URLs and extracted content |
|
|
305
|
+
| `errors` | `FetchError[]` | URLs that failed to fetch |
|
|
306
|
+
|
|
307
|
+
`FetchResult.text` is:
|
|
308
|
+
|
|
309
|
+
- `string` for `markdown` and `html`
|
|
310
|
+
- `Record<string, unknown>` for `json`
|
|
311
|
+
- `null` if extraction failed for that item
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
192
315
|
### `runs.get()` — retrieve a single run
|
|
193
316
|
|
|
194
317
|
Fetch the full details of a run by its ID.
|
|
@@ -228,7 +351,7 @@ console.log(run.browser_config); // proxy/browser settings that were used
|
|
|
228
351
|
List runs with optional filtering, sorting, and cursor-based pagination. All parameters are optional.
|
|
229
352
|
|
|
230
353
|
```typescript
|
|
231
|
-
import { RunStatus, SortDirection } from "
|
|
354
|
+
import { RunStatus, SortDirection } from "@tiny-fish/sdk";
|
|
232
355
|
|
|
233
356
|
const response = await client.runs.list({
|
|
234
357
|
status: RunStatus.COMPLETED, // optional — filter by status
|
|
@@ -263,6 +386,38 @@ See the [Pagination Guide](docs/pagination-guide.md) for full pagination loop ex
|
|
|
263
386
|
|
|
264
387
|
---
|
|
265
388
|
|
|
389
|
+
### `search.query()` — run a web search
|
|
390
|
+
|
|
391
|
+
Run a typed search query through the TinyFish Search API.
|
|
392
|
+
|
|
393
|
+
```typescript
|
|
394
|
+
import { TinyFish } from "@tiny-fish/sdk";
|
|
395
|
+
|
|
396
|
+
const client = new TinyFish();
|
|
397
|
+
|
|
398
|
+
const response = await client.search.query({
|
|
399
|
+
query: "tinyfish sdk",
|
|
400
|
+
location: "US",
|
|
401
|
+
language: "en",
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
console.log(response.query);
|
|
405
|
+
console.log(response.total_results);
|
|
406
|
+
console.log(response.results[0]?.title);
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Returns `SearchQueryResponse`:**
|
|
410
|
+
|
|
411
|
+
| Field | Type | Description |
|
|
412
|
+
|-------|------|-------------|
|
|
413
|
+
| `query` | `string` | The query that was executed |
|
|
414
|
+
| `results` | `SearchResult[]` | Search results returned by the backend |
|
|
415
|
+
| `total_results` | `number` | Total number of results returned |
|
|
416
|
+
|
|
417
|
+
**Throws:** `SDKError` if `query` is empty. Standard API errors are handled by the shared SDK error hierarchy.
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
266
421
|
## Configuration
|
|
267
422
|
|
|
268
423
|
### Client options
|
|
@@ -286,7 +441,7 @@ Control the browser environment with `browser_profile`:
|
|
|
286
441
|
- **`stealth`** — anti-detection mode. Use for sites with bot protection.
|
|
287
442
|
|
|
288
443
|
```typescript
|
|
289
|
-
import { BrowserProfile } from "
|
|
444
|
+
import { BrowserProfile } from "@tiny-fish/sdk";
|
|
290
445
|
|
|
291
446
|
const response = await client.agent.run({
|
|
292
447
|
goal: "...",
|
|
@@ -300,7 +455,7 @@ const response = await client.agent.run({
|
|
|
300
455
|
Route requests through a proxy, optionally pinned to a country:
|
|
301
456
|
|
|
302
457
|
```typescript
|
|
303
|
-
import { ProxyCountryCode } from "
|
|
458
|
+
import { ProxyCountryCode } from "@tiny-fish/sdk";
|
|
304
459
|
|
|
305
460
|
const response = await client.agent.run({
|
|
306
461
|
goal: "...",
|
|
@@ -316,7 +471,7 @@ See the [Proxy & Browser Profiles Guide](docs/proxy-and-browser-profiles.md) for
|
|
|
316
471
|
## Error handling
|
|
317
472
|
|
|
318
473
|
```typescript
|
|
319
|
-
import { TinyFish, AuthenticationError, RateLimitError, SDKError } from "
|
|
474
|
+
import { TinyFish, AuthenticationError, RateLimitError, SDKError } from "@tiny-fish/sdk";
|
|
320
475
|
|
|
321
476
|
const client = new TinyFish();
|
|
322
477
|
|
package/dist/_utils/client.d.ts
CHANGED
|
@@ -7,6 +7,15 @@ export interface ClientOptions {
|
|
|
7
7
|
timeout?: number;
|
|
8
8
|
maxRetries?: number;
|
|
9
9
|
}
|
|
10
|
+
interface RequestOptions {
|
|
11
|
+
signal?: AbortSignal | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface GetRequestOptions extends RequestOptions {
|
|
14
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
15
|
+
}
|
|
16
|
+
interface PostRequestOptions extends RequestOptions {
|
|
17
|
+
json?: unknown;
|
|
18
|
+
}
|
|
10
19
|
export declare class BaseClient {
|
|
11
20
|
private readonly _apiKey;
|
|
12
21
|
readonly baseURL: string;
|
|
@@ -20,6 +29,7 @@ export declare class BaseClient {
|
|
|
20
29
|
protected _buildHeaders(): Record<string, string>;
|
|
21
30
|
/** Inject api_integration from TF_API_INTEGRATION env var into JSON body. */
|
|
22
31
|
private static _injectIntegration;
|
|
32
|
+
private _buildRequestSignal;
|
|
23
33
|
/**
|
|
24
34
|
* Core request method with retry and error mapping.
|
|
25
35
|
* All public methods (get, post, postStream) delegate here.
|
|
@@ -33,14 +43,9 @@ export declare class BaseClient {
|
|
|
33
43
|
private _parseErrorMessage;
|
|
34
44
|
/** Maps HTTP status codes to typed error classes. Matches Python SDK's _make_status_error. */
|
|
35
45
|
private _makeStatusError;
|
|
36
|
-
get<T>(path: string, options?:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
post<T>(path: string, options?: {
|
|
40
|
-
json?: unknown;
|
|
41
|
-
}): Promise<T>;
|
|
42
|
-
postStream(path: string, options?: {
|
|
43
|
-
json?: unknown;
|
|
44
|
-
}): Promise<ReadableStream<string>>;
|
|
46
|
+
get<T>(path: string, options?: GetRequestOptions): Promise<T>;
|
|
47
|
+
post<T>(path: string, options?: PostRequestOptions): Promise<T>;
|
|
48
|
+
postStream(path: string, options?: PostRequestOptions): Promise<ReadableStream<string>>;
|
|
45
49
|
}
|
|
50
|
+
export {};
|
|
46
51
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/_utils/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAqBH,MAAM,WAAW,aAAa;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/_utils/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAqBH,MAAM,WAAW,aAAa;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,cAAc;IACvB,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CACjC;AAED,UAAU,iBAAkB,SAAQ,cAAc;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;CAC/D;AAED,UAAU,kBAAmB,SAAQ,cAAc;IAClD,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAYD,qBAAa,UAAU;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,OAAO,GAAE,aAAkB;IAcvC;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAejC,SAAS,CAAC,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAUjD,6EAA6E;IAC7E,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAYjC,OAAO,CAAC,mBAAmB;IAyC3B;;;OAGG;YACW,QAAQ;IAmFtB;;;;OAIG;YACW,kBAAkB;IAuBhC,8FAA8F;YAChF,gBAAgB;IAmCxB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC;IAgB7D,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAK/D,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;CAS7F"}
|
package/dist/_utils/client.js
CHANGED
|
@@ -58,53 +58,105 @@ export class BaseClient {
|
|
|
58
58
|
}
|
|
59
59
|
return nextBody;
|
|
60
60
|
}
|
|
61
|
+
_buildRequestSignal(callerSignal) {
|
|
62
|
+
const timeoutSignal = AbortSignal.timeout(this.timeout);
|
|
63
|
+
if (!callerSignal) {
|
|
64
|
+
return {
|
|
65
|
+
signal: timeoutSignal,
|
|
66
|
+
timeoutSignal,
|
|
67
|
+
cleanup: () => { },
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (typeof AbortSignal.any === "function") {
|
|
71
|
+
return {
|
|
72
|
+
signal: AbortSignal.any([callerSignal, timeoutSignal]),
|
|
73
|
+
timeoutSignal,
|
|
74
|
+
cleanup: () => { },
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const controller = new AbortController();
|
|
78
|
+
const abortFromCaller = () => controller.abort(callerSignal.reason);
|
|
79
|
+
const abortFromTimeout = () => controller.abort(timeoutSignal.reason);
|
|
80
|
+
if (callerSignal.aborted) {
|
|
81
|
+
abortFromCaller();
|
|
82
|
+
}
|
|
83
|
+
else if (timeoutSignal.aborted) {
|
|
84
|
+
abortFromTimeout();
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
callerSignal.addEventListener("abort", abortFromCaller, { once: true });
|
|
88
|
+
timeoutSignal.addEventListener("abort", abortFromTimeout, { once: true });
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
signal: controller.signal,
|
|
92
|
+
timeoutSignal,
|
|
93
|
+
cleanup: () => {
|
|
94
|
+
callerSignal.removeEventListener("abort", abortFromCaller);
|
|
95
|
+
timeoutSignal.removeEventListener("abort", abortFromTimeout);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
}
|
|
61
99
|
/**
|
|
62
100
|
* Core request method with retry and error mapping.
|
|
63
101
|
* All public methods (get, post, postStream) delegate here.
|
|
64
102
|
*/
|
|
65
|
-
async _request(method, path, body) {
|
|
103
|
+
async _request(method, path, body, options) {
|
|
66
104
|
const url = `${this.baseURL}${path}`;
|
|
67
105
|
const headers = this._buildHeaders();
|
|
68
106
|
const requestBody = BaseClient._injectIntegration(body);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (error instanceof AbortError || error instanceof SDKError) {
|
|
92
|
-
throw error;
|
|
107
|
+
// The timeout signal spans the entire retry sequence, not each individual attempt.
|
|
108
|
+
const { signal: requestSignal, timeoutSignal, cleanup, } = this._buildRequestSignal(options?.signal);
|
|
109
|
+
try {
|
|
110
|
+
return await pRetry(async () => {
|
|
111
|
+
try {
|
|
112
|
+
const response = await fetch(url, {
|
|
113
|
+
method,
|
|
114
|
+
headers,
|
|
115
|
+
body: requestBody !== undefined ? JSON.stringify(requestBody) : undefined,
|
|
116
|
+
signal: requestSignal,
|
|
117
|
+
});
|
|
118
|
+
if (response.ok) {
|
|
119
|
+
return response;
|
|
120
|
+
}
|
|
121
|
+
const sdkError = await this._makeStatusError(response);
|
|
122
|
+
// Non-retryable status codes abort immediately
|
|
123
|
+
const status = response.status;
|
|
124
|
+
if (status !== 408 && status !== 429 && status < 500) {
|
|
125
|
+
throw new AbortError(sdkError);
|
|
126
|
+
}
|
|
127
|
+
// Retryable — let p-retry handle backoff
|
|
128
|
+
throw sdkError;
|
|
93
129
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
130
|
+
catch (error) {
|
|
131
|
+
// Re-throw AbortError and SDK errors as-is
|
|
132
|
+
if (error instanceof AbortError || error instanceof SDKError) {
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
if (options?.signal?.aborted && !timeoutSignal.aborted) {
|
|
136
|
+
const reason = options.signal.reason instanceof Error
|
|
137
|
+
? options.signal.reason
|
|
138
|
+
: new DOMException("Request aborted", "AbortError");
|
|
139
|
+
throw new AbortError(reason);
|
|
140
|
+
}
|
|
141
|
+
// AbortSignal.timeout throws a DOMException with name "TimeoutError"
|
|
142
|
+
// Not retried — timeouts indicate the operation is slow, not a transient issue
|
|
143
|
+
if (timeoutSignal.aborted ||
|
|
144
|
+
(error instanceof DOMException && error.name === "TimeoutError")) {
|
|
145
|
+
throw new AbortError(new APITimeoutError(`Request timed out after ${this.timeout}ms`));
|
|
146
|
+
}
|
|
147
|
+
// Network failures (DNS, refused, etc.)
|
|
148
|
+
throw new APIConnectionError(error instanceof Error ? error.message : "Connection failed");
|
|
98
149
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
150
|
+
}, {
|
|
151
|
+
retries: this.maxRetries,
|
|
152
|
+
minTimeout: 500,
|
|
153
|
+
maxTimeout: 8_000,
|
|
154
|
+
factor: 2,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
cleanup();
|
|
159
|
+
}
|
|
108
160
|
}
|
|
109
161
|
/**
|
|
110
162
|
* Extracts a human-readable error message from the response body.
|
|
@@ -180,15 +232,15 @@ export class BaseClient {
|
|
|
180
232
|
const searchParams = new URLSearchParams(filtered);
|
|
181
233
|
url = `${path}?${searchParams.toString()}`;
|
|
182
234
|
}
|
|
183
|
-
const response = await this._request("GET", url);
|
|
235
|
+
const response = await this._request("GET", url, undefined, options);
|
|
184
236
|
return (await response.json());
|
|
185
237
|
}
|
|
186
238
|
async post(path, options) {
|
|
187
|
-
const response = await this._request("POST", path, options?.json);
|
|
239
|
+
const response = await this._request("POST", path, options?.json, options);
|
|
188
240
|
return (await response.json());
|
|
189
241
|
}
|
|
190
242
|
async postStream(path, options) {
|
|
191
|
-
const response = await this._request("POST", path, options?.json);
|
|
243
|
+
const response = await this._request("POST", path, options?.json, options);
|
|
192
244
|
if (!response.body) {
|
|
193
245
|
throw new SDKError("Response body is null — server did not return a stream");
|
|
194
246
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/_utils/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC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AAC,IAAI,CAAI,IAAY,EAAE,OAA4B;QACvD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3E,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAY,EAAE,OAA4B;QAC1D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAE3E,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,QAAQ,CAAC,wDAAwD,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;IAC3D,CAAC;CACD"}
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Browser automation resource.
|
|
3
3
|
*/
|
|
4
4
|
import { APIResource } from "../_utils/resource.js";
|
|
5
|
-
import { type AgentRunAsyncResponse, type AgentRunParams, type AgentRunResponse, type AgentRunWithStreamingResponse, type StreamOptions } from "./types.js";
|
|
5
|
+
import { type AgentRequestOptions, type AgentRunAsyncResponse, type AgentRunParams, type AgentRunResponse, type AgentRunWithStreamingResponse, type StreamOptions } from "./types.js";
|
|
6
6
|
/** Async-iterable wrapper around an SSE event stream, this is what we return when they call the stream endpoint */
|
|
7
7
|
export declare class AgentStream {
|
|
8
8
|
private _generator;
|
|
@@ -19,14 +19,14 @@ export declare class AgentResource extends APIResource {
|
|
|
19
19
|
*
|
|
20
20
|
* Returns a promise that resolves with the completed agent run output.
|
|
21
21
|
*/
|
|
22
|
-
run(params: AgentRunParams): Promise<AgentRunResponse>;
|
|
22
|
+
run(params: AgentRunParams, options?: AgentRequestOptions): Promise<AgentRunResponse>;
|
|
23
23
|
/**
|
|
24
24
|
* Queue a browser automation and return immediately.
|
|
25
25
|
*
|
|
26
26
|
* Does not wait for the run to complete — returns a `run_id` straight away.
|
|
27
27
|
* Use `client.runs.get(run_id)` to poll for the result.
|
|
28
28
|
*/
|
|
29
|
-
queue(params: AgentRunParams): Promise<AgentRunAsyncResponse>;
|
|
29
|
+
queue(params: AgentRunParams, options?: AgentRequestOptions): Promise<AgentRunAsyncResponse>;
|
|
30
30
|
/**
|
|
31
31
|
* Stream live events from a browser automation run.
|
|
32
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EASlC,KAAK,aAAa,EAElB,MAAM,YAAY,CAAC;AAqBpB,mHAAmH;AACnH,qBAAa,WAAW;IACvB,OAAO,CAAC,UAAU,CAAgD;IAClE,OAAO,CAAC,UAAU,CAAyB;gBAG1C,SAAS,EAAE,cAAc,CAAC,6BAA6B,CAAC,EACxD,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC;IAMlC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,6BAA6B,CAAC;IAIvE,iEAAiE;IAC3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B;AAqHD,kCAAkC;AAClC,qBAAa,aAAc,SAAQ,WAAW;IAC7C;;;;OAIG;IACG,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,6BAA6B,EASlC,KAAK,aAAa,EAElB,MAAM,YAAY,CAAC;AAqBpB,mHAAmH;AACnH,qBAAa,WAAW;IACvB,OAAO,CAAC,UAAU,CAAgD;IAClE,OAAO,CAAC,UAAU,CAAyB;gBAG1C,SAAS,EAAE,cAAc,CAAC,6BAA6B,CAAC,EACxD,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC;IAMlC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,6BAA6B,CAAC;IAIvE,iEAAiE;IAC3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B;AAqHD,kCAAkC;AAClC,qBAAa,aAAc,SAAQ,WAAW;IAC7C;;;;OAIG;IACG,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAO/F;;;;;OAKG;IACG,KAAK,CACV,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,mBAAwB,GAC/B,OAAO,CAAC,qBAAqB,CAAC;IAOjC;;;;;;;;;;;;;;;OAeG;IACG,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;CAiBvF"}
|
package/dist/agent/index.js
CHANGED
|
@@ -137,9 +137,10 @@ export class AgentResource extends APIResource {
|
|
|
137
137
|
*
|
|
138
138
|
* Returns a promise that resolves with the completed agent run output.
|
|
139
139
|
*/
|
|
140
|
-
async run(params) {
|
|
140
|
+
async run(params, options = {}) {
|
|
141
141
|
return this._client.post("/v1/automation/run", {
|
|
142
142
|
json: buildRunBody(params),
|
|
143
|
+
signal: options.signal,
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
/**
|
|
@@ -148,9 +149,10 @@ export class AgentResource extends APIResource {
|
|
|
148
149
|
* Does not wait for the run to complete — returns a `run_id` straight away.
|
|
149
150
|
* Use `client.runs.get(run_id)` to poll for the result.
|
|
150
151
|
*/
|
|
151
|
-
async queue(params) {
|
|
152
|
+
async queue(params, options = {}) {
|
|
152
153
|
return this._client.post("/v1/automation/run-async", {
|
|
153
154
|
json: buildRunBody(params),
|
|
155
|
+
signal: options.signal,
|
|
154
156
|
});
|
|
155
157
|
}
|
|
156
158
|
/**
|
|
@@ -172,6 +174,7 @@ export class AgentResource extends APIResource {
|
|
|
172
174
|
async stream(params, options = {}) {
|
|
173
175
|
const raw = await this._client.postStream("/v1/automation/run-sse", {
|
|
174
176
|
json: buildRunBody(params),
|
|
177
|
+
signal: options.signal,
|
|
175
178
|
});
|
|
176
179
|
async function* generate() {
|
|
177
180
|
for await (const data of parseSSEStream(raw)) {
|
package/dist/agent/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAYN,SAAS,GAIT,MAAM,YAAY,CAAC;AAUpB;;;GAGG;AACH,SAAS,YAAY,CAAC,MAAsB;IAC3C,MAAM,IAAI,GAAiB,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC;IAClE,IAAI,MAAM,CAAC,eAAe,KAAK,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K,EAAE,MAAM,IAAI,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC3C,IAAI,KAAK,EAAE,CAAC;oBACX,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;CACD"}
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -34,6 +34,11 @@ export interface AgentRunParams {
|
|
|
34
34
|
/** Optional proxy settings. */
|
|
35
35
|
proxy_config?: ProxyConfig;
|
|
36
36
|
}
|
|
37
|
+
/** Per-request transport controls for agent calls. */
|
|
38
|
+
export interface AgentRequestOptions {
|
|
39
|
+
/** Abort this specific request without changing the client-wide timeout. */
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
}
|
|
37
42
|
/**
|
|
38
43
|
* Status of an automation run.
|
|
39
44
|
*
|
|
@@ -166,7 +171,7 @@ export interface CompleteEvent {
|
|
|
166
171
|
/** Union type for all possible SSE streaming events. */
|
|
167
172
|
export type AgentRunWithStreamingResponse = StartedEvent | StreamingUrlEvent | ProgressEvent | HeartbeatEvent | CompleteEvent;
|
|
168
173
|
/** Optional callbacks for stream events. */
|
|
169
|
-
export interface StreamOptions {
|
|
174
|
+
export interface StreamOptions extends AgentRequestOptions {
|
|
170
175
|
onStarted?: (event: StartedEvent) => void;
|
|
171
176
|
onStreamingUrl?: (event: StreamingUrlEvent) => void;
|
|
172
177
|
onProgress?: (event: ProgressEvent) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,qCAAqC;AACrC,oBAAY,cAAc;IACzB,IAAI,SAAS;IACb,OAAO,YAAY;CACnB;AAED,0DAA0D;AAC1D,oBAA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,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACpD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C"}
|
package/dist/agent/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAoB;AAEpB,qCAAqC;AACrC,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACzB,+BAAa,CAAA;IACb,qCAAmB,CAAA;AACpB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,0DAA0D;AAC1D,MAAM,CAAN,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC3B,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;AACV,CAAC,EARW,gBAAgB,KAAhB,gBAAgB,QAQ3B;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAoB;AAEpB,qCAAqC;AACrC,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACzB,+BAAa,CAAA;IACb,qCAAmB,CAAA;AACpB,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB;AAED,0DAA0D;AAC1D,MAAM,CAAN,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC3B,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;IACT,6BAAS,CAAA;AACV,CAAC,EARW,gBAAgB,KAAhB,gBAAgB,QAQ3B;AA4BD,gDAAgD;AAEhD;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;IACpB,gCAAmB,CAAA;IACnB,gCAAmB,CAAA;IACnB,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;IACjB,oCAAuB,CAAA;AACxB,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB;AAED;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACxB,kDAAiC,CAAA;IACjC,gDAA+B,CAAA;IAC/B,oCAAmB,CAAA;AACpB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAiED,kCAAkC;AAElC,oCAAoC;AACpC,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;IACpB,gCAAmB,CAAA;IACnB,4CAA+B,CAAA;IAC/B,kCAAqB,CAAA;IACrB,oCAAuB,CAAA;IACvB,kCAAqB,CAAA;AACtB,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser API resource.
|
|
3
|
+
*/
|
|
4
|
+
import { APIResource } from "../_utils/resource.js";
|
|
5
|
+
import type { BrowserSession } from "./types.js";
|
|
6
|
+
/** Create remote browser sessions. */
|
|
7
|
+
declare class BrowserSessionsResource extends APIResource {
|
|
8
|
+
create(params?: {
|
|
9
|
+
url?: string;
|
|
10
|
+
}): Promise<BrowserSession>;
|
|
11
|
+
}
|
|
12
|
+
/** Browser API namespace. */
|
|
13
|
+
export declare class BrowserResource extends APIResource {
|
|
14
|
+
readonly sessions: BrowserSessionsResource;
|
|
15
|
+
constructor(client: APIResource["_client"]);
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,sCAAsC;AACtC,cAAM,uBAAwB,SAAQ,WAAW;IAC1C,MAAM,CAAC,MAAM,GAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,cAAc,CAAC;CAKpE;AAED,6BAA6B;AAC7B,qBAAa,eAAgB,SAAQ,WAAW;IAC/C,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAC;gBAE/B,MAAM,EAAE,WAAW,CAAC,SAAS,CAAC;CAI1C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser API resource.
|
|
3
|
+
*/
|
|
4
|
+
import { APIResource } from "../_utils/resource.js";
|
|
5
|
+
/** Create remote browser sessions. */
|
|
6
|
+
class BrowserSessionsResource extends APIResource {
|
|
7
|
+
async create(params = {}) {
|
|
8
|
+
return this._client.post("/v1/browser", {
|
|
9
|
+
json: params,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Browser API namespace. */
|
|
14
|
+
export class BrowserResource extends APIResource {
|
|
15
|
+
sessions;
|
|
16
|
+
constructor(client) {
|
|
17
|
+
super(client);
|
|
18
|
+
this.sessions = new BrowserSessionsResource(client);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,sCAAsC;AACtC,MAAM,uBAAwB,SAAQ,WAAW;IAChD,KAAK,CAAC,MAAM,CAAC,SAA2B,EAAE;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAiB,aAAa,EAAE;YACvD,IAAI,EAAE,MAAM;SACZ,CAAC,CAAC;IACJ,CAAC;CACD;AAED,6BAA6B;AAC7B,MAAM,OAAO,eAAgB,SAAQ,WAAW;IACtC,QAAQ,CAA0B;IAE3C,YAAY,MAA8B;QACzC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;CACD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser API request/response types.
|
|
3
|
+
*/
|
|
4
|
+
/** Public response for `POST /v1/browser`. */
|
|
5
|
+
export interface BrowserSession {
|
|
6
|
+
/** Unique session identifier returned by the browser infrastructure. */
|
|
7
|
+
session_id: string;
|
|
8
|
+
/** CDP WebSocket URL for direct browser connection. */
|
|
9
|
+
cdp_url: string;
|
|
10
|
+
/** HTTPS base URL for the browser session. */
|
|
11
|
+
base_url: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/browser/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC9B,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/browser/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/client.d.ts
CHANGED
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
import { BaseClient } from "./_utils/client.js";
|
|
5
5
|
import type { ClientOptions } from "./_utils/client.js";
|
|
6
6
|
import { AgentResource } from "./agent/index.js";
|
|
7
|
+
import { BrowserResource } from "./browser/index.js";
|
|
8
|
+
import { FetchResource } from "./fetch/index.js";
|
|
7
9
|
import { RunsResource } from "./runs/index.js";
|
|
10
|
+
import { SearchResource } from "./search/index.js";
|
|
8
11
|
export declare class TinyFish extends BaseClient {
|
|
9
12
|
readonly agent: AgentResource;
|
|
13
|
+
readonly browser: BrowserResource;
|
|
14
|
+
readonly fetch: FetchResource;
|
|
10
15
|
readonly runs: RunsResource;
|
|
16
|
+
readonly search: SearchResource;
|
|
11
17
|
constructor(options?: ClientOptions);
|
|
12
18
|
}
|
|
13
19
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,qBAAa,QAAS,SAAQ,UAAU;IACvC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;gBAEpB,OAAO,CAAC,EAAE,aAAa;CAQnC"}
|
package/dist/client.js
CHANGED
|
@@ -3,14 +3,23 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { BaseClient } from "./_utils/client.js";
|
|
5
5
|
import { AgentResource } from "./agent/index.js";
|
|
6
|
+
import { BrowserResource } from "./browser/index.js";
|
|
7
|
+
import { FetchResource } from "./fetch/index.js";
|
|
6
8
|
import { RunsResource } from "./runs/index.js";
|
|
9
|
+
import { SearchResource } from "./search/index.js";
|
|
7
10
|
export class TinyFish extends BaseClient {
|
|
8
11
|
agent;
|
|
12
|
+
browser;
|
|
13
|
+
fetch;
|
|
9
14
|
runs;
|
|
15
|
+
search;
|
|
10
16
|
constructor(options) {
|
|
11
17
|
super(options);
|
|
12
18
|
this.agent = new AgentResource(this);
|
|
19
|
+
this.browser = new BrowserResource(this);
|
|
20
|
+
this.fetch = new FetchResource(this);
|
|
13
21
|
this.runs = new RunsResource(this);
|
|
22
|
+
this.search = new SearchResource(this);
|
|
14
23
|
}
|
|
15
24
|
}
|
|
16
25
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,OAAO,QAAS,SAAQ,UAAU;IAC9B,KAAK,CAAgB;IACrB,OAAO,CAAkB;IACzB,KAAK,CAAgB;IACrB,IAAI,CAAe;IACnB,MAAM,CAAiB;IAEhC,YAAY,OAAuB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch API resource.
|
|
3
|
+
*/
|
|
4
|
+
import { APIResource } from "../_utils/resource.js";
|
|
5
|
+
import type { FetchGetContentsParams, FetchResponse } from "./types.js";
|
|
6
|
+
/** Fetch and extract clean content from URL inputs. */
|
|
7
|
+
export declare class FetchResource extends APIResource {
|
|
8
|
+
getContents(params: FetchGetContentsParams): Promise<FetchResponse>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAExE,uDAAuD;AACvD,qBAAa,aAAc,SAAQ,WAAW;IACvC,WAAW,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC;CAoBzE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch API resource.
|
|
3
|
+
*/
|
|
4
|
+
import { SDKError } from "../_utils/errors.js";
|
|
5
|
+
import { APIResource } from "../_utils/resource.js";
|
|
6
|
+
/** Fetch and extract clean content from URL inputs. */
|
|
7
|
+
export class FetchResource extends APIResource {
|
|
8
|
+
async getContents(params) {
|
|
9
|
+
if (!Array.isArray(params.urls) || params.urls.length === 0) {
|
|
10
|
+
throw new SDKError("urls must be a non-empty array");
|
|
11
|
+
}
|
|
12
|
+
if (params.urls.length > 10) {
|
|
13
|
+
throw new SDKError("urls must contain at most 10 items");
|
|
14
|
+
}
|
|
15
|
+
const body = {
|
|
16
|
+
urls: params.urls,
|
|
17
|
+
};
|
|
18
|
+
if (params.format !== undefined)
|
|
19
|
+
body["format"] = params.format;
|
|
20
|
+
if (params.links !== undefined)
|
|
21
|
+
body["links"] = params.links;
|
|
22
|
+
if (params.image_links !== undefined)
|
|
23
|
+
body["image_links"] = params.image_links;
|
|
24
|
+
return this._client.post("/v1/fetch", {
|
|
25
|
+
json: body,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fetch/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,uDAAuD;AACvD,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC7C,KAAK,CAAC,WAAW,CAAC,MAA8B;QAC/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,QAAQ,CAAC,gCAAgC,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YAC7B,MAAM,IAAI,QAAQ,CAAC,oCAAoC,CAAC,CAAC;QAC1D,CAAC;QAED,MAAM,IAAI,GAA4B;YACrC,IAAI,EAAE,MAAM,CAAC,IAAI;SACjB,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QAChE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,IAAI,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QAC7D,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC;QAE/E,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAgB,WAAW,EAAE;YACpD,IAAI,EAAE,IAAI;SACV,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch API request/response types.
|
|
3
|
+
*/
|
|
4
|
+
/** Supported output formats for `POST /v1/fetch`. */
|
|
5
|
+
export declare enum FetchFormat {
|
|
6
|
+
Markdown = "markdown",
|
|
7
|
+
Html = "html",
|
|
8
|
+
Json = "json"
|
|
9
|
+
}
|
|
10
|
+
export type FetchJSONValue = string | number | boolean | null | FetchJSONObject | FetchJSONValue[];
|
|
11
|
+
export interface FetchJSONObject {
|
|
12
|
+
[key: string]: FetchJSONValue;
|
|
13
|
+
}
|
|
14
|
+
/** Parameters for `client.fetch.getContents(...)`. */
|
|
15
|
+
export interface FetchGetContentsParams {
|
|
16
|
+
/** Array of URLs to fetch. The public API currently allows 1-10 URLs. */
|
|
17
|
+
urls: string[];
|
|
18
|
+
/** Output format for extracted content. */
|
|
19
|
+
format?: FetchFormat;
|
|
20
|
+
/** Include extracted links in the response. */
|
|
21
|
+
links?: boolean;
|
|
22
|
+
/** Include extracted image links in the response. */
|
|
23
|
+
image_links?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface BaseFetchResult {
|
|
26
|
+
url: string;
|
|
27
|
+
final_url: string | null;
|
|
28
|
+
title: string | null;
|
|
29
|
+
description: string | null;
|
|
30
|
+
language: string | null;
|
|
31
|
+
author: string | null;
|
|
32
|
+
published_date: string | null;
|
|
33
|
+
links?: string[];
|
|
34
|
+
image_links?: string[];
|
|
35
|
+
latency_ms?: number | null;
|
|
36
|
+
}
|
|
37
|
+
export interface FetchMarkupResult extends BaseFetchResult {
|
|
38
|
+
format: FetchFormat.Markdown | FetchFormat.Html;
|
|
39
|
+
text: string | null;
|
|
40
|
+
}
|
|
41
|
+
export interface FetchJSONResult extends BaseFetchResult {
|
|
42
|
+
format: FetchFormat.Json;
|
|
43
|
+
text: FetchJSONObject | null;
|
|
44
|
+
}
|
|
45
|
+
/** A single successfully fetched URL result. */
|
|
46
|
+
export type FetchResult = FetchMarkupResult | FetchJSONResult;
|
|
47
|
+
/** A single failed fetch result. */
|
|
48
|
+
export interface FetchError {
|
|
49
|
+
url: string;
|
|
50
|
+
error: string;
|
|
51
|
+
}
|
|
52
|
+
/** Public response for `POST /v1/fetch`. */
|
|
53
|
+
export interface FetchResponse {
|
|
54
|
+
results: FetchResult[];
|
|
55
|
+
errors: FetchError[];
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/fetch/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qDAAqD;AACrD,oBAAY,WAAW;IACtB,QAAQ,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;CACb;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,eAAe,GAAG,cAAc,EAAE,CAAC;AAEnG,MAAM,WAAW,eAAe;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC9B;AAED,sDAAsD;AACtD,MAAM,WAAW,sBAAsB;IACtC,yEAAyE;IACzE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,2CAA2C;IAC3C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,eAAe;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACzD,MAAM,EAAE,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC;IAChD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACvD,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC;IACzB,IAAI,EAAE,eAAe,GAAG,IAAI,CAAC;CAC7B;AAED,gDAAgD;AAChD,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE9D,oCAAoC;AACpC,MAAM,WAAW,UAAU;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACd;AAED,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,MAAM,EAAE,UAAU,EAAE,CAAC;CACrB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch API request/response types.
|
|
3
|
+
*/
|
|
4
|
+
/** Supported output formats for `POST /v1/fetch`. */
|
|
5
|
+
export var FetchFormat;
|
|
6
|
+
(function (FetchFormat) {
|
|
7
|
+
FetchFormat["Markdown"] = "markdown";
|
|
8
|
+
FetchFormat["Html"] = "html";
|
|
9
|
+
FetchFormat["Json"] = "json";
|
|
10
|
+
})(FetchFormat || (FetchFormat = {}));
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/fetch/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qDAAqD;AACrD,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACtB,oCAAqB,CAAA;IACrB,4BAAa,CAAA;IACb,4BAAa,CAAA;AACd,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
export type { ClientOptions } from "./_utils/client.js";
|
|
5
5
|
export { TinyFish } from "./client.js";
|
|
6
6
|
export { AgentStream } from "./agent/index.js";
|
|
7
|
+
export type { BrowserSession } from "./browser/types.js";
|
|
8
|
+
export { FetchFormat } from "./fetch/types.js";
|
|
9
|
+
export type { FetchGetContentsParams, FetchJSONObject, FetchJSONResult, FetchJSONValue, FetchResult, FetchMarkupResult, FetchError, FetchResponse, } from "./fetch/types.js";
|
|
7
10
|
export { BrowserProfile, ProxyCountryCode, RunStatus, ErrorCategory, EventType, } from "./agent/types.js";
|
|
8
|
-
export type { ProxyConfig, AgentRunParams, AgentRunResponse, AgentRunAsyncResponse, RunError, StartedEvent, StreamingUrlEvent, ProgressEvent, HeartbeatEvent, CompleteEvent, AgentRunWithStreamingResponse, StreamOptions, } from "./agent/types.js";
|
|
11
|
+
export type { ProxyConfig, AgentRunParams, AgentRequestOptions, AgentRunResponse, AgentRunAsyncResponse, RunError, StartedEvent, StreamingUrlEvent, ProgressEvent, HeartbeatEvent, CompleteEvent, AgentRunWithStreamingResponse, StreamOptions, } from "./agent/types.js";
|
|
9
12
|
export { SortDirection } from "./runs/types.js";
|
|
10
13
|
export type { BrowserConfig, Run, PaginationInfo, RunListResponse, RunListParams, } from "./runs/types.js";
|
|
14
|
+
export type { SearchResult, SearchQueryResponse } from "./search/types.js";
|
|
11
15
|
export { SDKError, SSEParseError, APIError, APIConnectionError, APITimeoutError, APIStatusError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, RequestTimeoutError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_utils/errors.js";
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,C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,EACT,aAAa,EACb,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACX,WAAW,EACX,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,QAAQ,EACR,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,aAAa,EACb,6BAA6B,EAC7B,aAAa,GACb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACX,aAAa,EACb,GAAG,EACH,cAAc,EACd,eAAe,EACf,aAAa,GACb,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG3E,OAAO,EACN,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,mBAAmB,GACnB,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
export { TinyFish } from "./client.js";
|
|
6
6
|
// Resources
|
|
7
7
|
export { AgentStream } from "./agent/index.js";
|
|
8
|
+
// Fetch types
|
|
9
|
+
export { FetchFormat } from "./fetch/types.js";
|
|
8
10
|
// Agent types
|
|
9
11
|
export { BrowserProfile, ProxyCountryCode, RunStatus, ErrorCategory, EventType, } from "./agent/types.js";
|
|
10
12
|
// Runs types
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,SAAS;AACT,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,SAAS;AACT,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAK/C,cAAc;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAY/C,cAAc;AACd,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,SAAS,GACT,MAAM,kBAAkB,CAAC;AAiB1B,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAYhD,kBAAkB;AAClB,OAAO,EACN,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,mBAAmB,GACnB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search API resource.
|
|
3
|
+
*/
|
|
4
|
+
import { APIResource } from "../_utils/resource.js";
|
|
5
|
+
import type { SearchQueryResponse } from "./types.js";
|
|
6
|
+
/** Query the Search API. */
|
|
7
|
+
export declare class SearchResource extends APIResource {
|
|
8
|
+
query(params: {
|
|
9
|
+
query: string;
|
|
10
|
+
location?: string;
|
|
11
|
+
language?: string;
|
|
12
|
+
}): Promise<SearchQueryResponse>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,4BAA4B;AAC5B,qBAAa,cAAe,SAAQ,WAAW;IACxC,KAAK,CAAC,MAAM,EAAE;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAehC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search API resource.
|
|
3
|
+
*/
|
|
4
|
+
import { SDKError } from "../_utils/errors.js";
|
|
5
|
+
import { APIResource } from "../_utils/resource.js";
|
|
6
|
+
/** Query the Search API. */
|
|
7
|
+
export class SearchResource extends APIResource {
|
|
8
|
+
async query(params) {
|
|
9
|
+
if (typeof params.query !== "string" || !params.query.trim()) {
|
|
10
|
+
throw new SDKError("query must be a non-empty string");
|
|
11
|
+
}
|
|
12
|
+
const queryParams = {
|
|
13
|
+
query: params.query,
|
|
14
|
+
};
|
|
15
|
+
if (params.location !== undefined)
|
|
16
|
+
queryParams["location"] = params.location;
|
|
17
|
+
if (params.language !== undefined)
|
|
18
|
+
queryParams["language"] = params.language;
|
|
19
|
+
return this._client.get("/v1/search", {
|
|
20
|
+
params: queryParams,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/search/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,4BAA4B;AAC5B,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC9C,KAAK,CAAC,KAAK,CAAC,MAIX;QACA,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9D,MAAM,IAAI,QAAQ,CAAC,kCAAkC,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,WAAW,GAA8C;YAC9D,KAAK,EAAE,MAAM,CAAC,KAAK;SACnB,CAAC;QACF,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;YAAE,WAAW,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC7E,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;YAAE,WAAW,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;QAE7E,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAsB,YAAY,EAAE;YAC1D,MAAM,EAAE,WAAW;SACnB,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search API request/response types.
|
|
3
|
+
*/
|
|
4
|
+
/** A single search result item. */
|
|
5
|
+
export interface SearchResult {
|
|
6
|
+
/** Position in the result set. */
|
|
7
|
+
position: number;
|
|
8
|
+
/** Site name for the result. */
|
|
9
|
+
site_name: string;
|
|
10
|
+
/** Search snippet text. */
|
|
11
|
+
snippet: string;
|
|
12
|
+
/** Result title. */
|
|
13
|
+
title: string;
|
|
14
|
+
/** Result URL. */
|
|
15
|
+
url: string;
|
|
16
|
+
}
|
|
17
|
+
/** Public response for `GET /v1/search`. */
|
|
18
|
+
export interface SearchQueryResponse {
|
|
19
|
+
/** Query that was executed. */
|
|
20
|
+
query: string;
|
|
21
|
+
/** Search results. */
|
|
22
|
+
results: SearchResult[];
|
|
23
|
+
/** Total results returned by the backend. */
|
|
24
|
+
total_results: number;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/search/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC5B,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IACnC,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,6CAA6C;IAC7C,aAAa,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/search/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.
|
|
1
|
+
export declare const VERSION = "0.0.6";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED