@tiny-fish/sdk 0.0.1
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 +5 -0
- package/dist/_utils/client.d.ts +40 -0
- package/dist/_utils/client.d.ts.map +1 -0
- package/dist/_utils/client.js +168 -0
- package/dist/_utils/client.js.map +1 -0
- package/dist/_utils/errors.d.ts +109 -0
- package/dist/_utils/errors.d.ts.map +1 -0
- package/dist/_utils/errors.js +123 -0
- package/dist/_utils/errors.js.map +1 -0
- package/dist/_utils/index.d.ts +15 -0
- package/dist/_utils/index.d.ts.map +1 -0
- package/dist/_utils/index.js +14 -0
- package/dist/_utils/index.js.map +1 -0
- package/dist/_utils/resource.d.ts +6 -0
- package/dist/_utils/resource.d.ts.map +1 -0
- package/dist/_utils/resource.js +7 -0
- package/dist/_utils/resource.js.map +1 -0
- package/dist/_utils/sse.d.ts +15 -0
- package/dist/_utils/sse.d.ts.map +1 -0
- package/dist/_utils/sse.js +62 -0
- package/dist/_utils/sse.js.map +1 -0
- package/dist/agent/index.d.ts +47 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +168 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/types.d.ts +163 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +61 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/client.d.ts +13 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +16 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/runs/index.d.ts +25 -0
- package/dist/runs/index.d.ts.map +1 -0
- package/dist/runs/index.js +47 -0
- package/dist/runs/index.js.map +1 -0
- package/dist/runs/types.d.ts +75 -0
- package/dist/runs/types.d.ts.map +1 -0
- package/dist/runs/types.js +10 -0
- package/dist/runs/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +43 -0
- package/src/_utils/client.ts +219 -0
- package/src/_utils/errors.ts +153 -0
- package/src/_utils/index.ts +31 -0
- package/src/_utils/resource.ts +9 -0
- package/src/_utils/sse.ts +72 -0
- package/src/agent/index.ts +210 -0
- package/src/agent/types.ts +190 -0
- package/src/client.ts +19 -0
- package/src/index.ts +64 -0
- package/src/runs/index.ts +47 -0
- package/src/runs/types.ts +81 -0
- package/src/version.ts +2 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser automation resource.
|
|
3
|
+
*/
|
|
4
|
+
import { APIResource } from "../_utils/resource.js";
|
|
5
|
+
import type { AgentRunAsyncResponse, AgentRunParams, AgentRunResponse, AgentRunWithStreamingResponse, StreamOptions } from "./types.js";
|
|
6
|
+
/** Async-iterable wrapper around an SSE event stream, this is what we return when they call the stream endpoint */
|
|
7
|
+
export declare class AgentStream {
|
|
8
|
+
private _generator;
|
|
9
|
+
constructor(generator: AsyncGenerator<AgentRunWithStreamingResponse>);
|
|
10
|
+
[Symbol.asyncIterator](): AsyncGenerator<AgentRunWithStreamingResponse>;
|
|
11
|
+
/** Abort the underlying stream. */
|
|
12
|
+
close(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/** Browser automation methods. */
|
|
15
|
+
export declare class AgentResource extends APIResource {
|
|
16
|
+
/**
|
|
17
|
+
* Run a browser automation.
|
|
18
|
+
*
|
|
19
|
+
* Returns a promise that resolves with the completed agent run output.
|
|
20
|
+
*/
|
|
21
|
+
run(params: AgentRunParams): Promise<AgentRunResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Queue a browser automation and return immediately.
|
|
24
|
+
*
|
|
25
|
+
* Does not wait for the run to complete — returns a `run_id` straight away.
|
|
26
|
+
* Use `client.runs.get(run_id)` to poll for the result.
|
|
27
|
+
*/
|
|
28
|
+
queue(params: AgentRunParams): Promise<AgentRunAsyncResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Stream live events from a browser automation run.
|
|
31
|
+
*
|
|
32
|
+
* Returns an `AgentStream` that yields typed SSE events in real time:
|
|
33
|
+
* STARTED → STREAMING_URL → PROGRESS (repeated) → COMPLETE.
|
|
34
|
+
*
|
|
35
|
+
* Use the `on*` callbacks for a reactive style, or iterate over
|
|
36
|
+
* the stream for a sequential style:
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const stream = await client.agent.stream({ goal: "...", url: "..." });
|
|
40
|
+
* for await (const event of stream) {
|
|
41
|
+
* if (event.type === "PROGRESS") console.log(event.purpose);
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
stream(params: AgentRunParams, options?: StreamOptions): Promise<AgentStream>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,KAAK,EACX,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAS7B,aAAa,EAEb,MAAM,YAAY,CAAC;AAqBpB,mHAAmH;AACnH,qBAAa,WAAW;IACvB,OAAO,CAAC,UAAU,CAAgD;gBAEtD,SAAS,EAAE,cAAc,CAAC,6BAA6B,CAAC;IAIpE,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,6BAA6B,CAAC;IAIvE,mCAAmC;IAC7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B;AA8FD,kCAAkC;AAClC,qBAAa,aAAc,SAAQ,WAAW;IAC7C;;;;OAIG;IACG,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAM5D;;;;;OAKG;IACG,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMnE;;;;;;;;;;;;;;;OAeG;IACG,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;CAgBvF"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser automation resource.
|
|
3
|
+
*/
|
|
4
|
+
import { APIResource } from "../_utils/resource.js";
|
|
5
|
+
import { parseSSEStream } from "../_utils/sse.js";
|
|
6
|
+
/**
|
|
7
|
+
* Build the JSON request body from typed params.
|
|
8
|
+
* Optional fields are omitted rather than sent as undefined/null.
|
|
9
|
+
*/
|
|
10
|
+
function buildRunBody(params) {
|
|
11
|
+
const body = { goal: params.goal, url: params.url };
|
|
12
|
+
if (params.browser_profile !== undefined)
|
|
13
|
+
body.browser_profile = params.browser_profile;
|
|
14
|
+
if (params.proxy_config !== undefined)
|
|
15
|
+
body.proxy_config = params.proxy_config;
|
|
16
|
+
return body;
|
|
17
|
+
}
|
|
18
|
+
/** Async-iterable wrapper around an SSE event stream, this is what we return when they call the stream endpoint */
|
|
19
|
+
export class AgentStream {
|
|
20
|
+
_generator;
|
|
21
|
+
constructor(generator) {
|
|
22
|
+
this._generator = generator;
|
|
23
|
+
}
|
|
24
|
+
[Symbol.asyncIterator]() {
|
|
25
|
+
return this._generator;
|
|
26
|
+
}
|
|
27
|
+
/** Abort the underlying stream. */
|
|
28
|
+
async close() {
|
|
29
|
+
await this._generator.return(undefined);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Validate raw SSE data into a typed event. Returns null for malformed or unknown events. */
|
|
33
|
+
function validateEvent(data) {
|
|
34
|
+
const type = data["type"];
|
|
35
|
+
if (typeof type !== "string")
|
|
36
|
+
return null;
|
|
37
|
+
switch (type) {
|
|
38
|
+
case "STARTED": {
|
|
39
|
+
if (typeof data["runId"] !== "string" || typeof data["timestamp"] !== "string")
|
|
40
|
+
return null;
|
|
41
|
+
return { type: "STARTED", runId: data["runId"], timestamp: data["timestamp"] };
|
|
42
|
+
}
|
|
43
|
+
case "STREAMING_URL": {
|
|
44
|
+
if (typeof data["runId"] !== "string" ||
|
|
45
|
+
typeof data["streamingUrl"] !== "string" ||
|
|
46
|
+
typeof data["timestamp"] !== "string")
|
|
47
|
+
return null;
|
|
48
|
+
return {
|
|
49
|
+
type: "STREAMING_URL",
|
|
50
|
+
runId: data["runId"],
|
|
51
|
+
streamingUrl: data["streamingUrl"],
|
|
52
|
+
timestamp: data["timestamp"],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
case "PROGRESS": {
|
|
56
|
+
if (typeof data["runId"] !== "string" ||
|
|
57
|
+
typeof data["purpose"] !== "string" ||
|
|
58
|
+
typeof data["timestamp"] !== "string")
|
|
59
|
+
return null;
|
|
60
|
+
return {
|
|
61
|
+
type: "PROGRESS",
|
|
62
|
+
runId: data["runId"],
|
|
63
|
+
purpose: data["purpose"],
|
|
64
|
+
timestamp: data["timestamp"],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
case "HEARTBEAT": {
|
|
68
|
+
if (typeof data["timestamp"] !== "string")
|
|
69
|
+
return null;
|
|
70
|
+
return { type: "HEARTBEAT", timestamp: data["timestamp"] };
|
|
71
|
+
}
|
|
72
|
+
case "COMPLETE": {
|
|
73
|
+
if (typeof data["runId"] !== "string" ||
|
|
74
|
+
typeof data["status"] !== "string" ||
|
|
75
|
+
typeof data["timestamp"] !== "string")
|
|
76
|
+
return null;
|
|
77
|
+
return {
|
|
78
|
+
type: "COMPLETE",
|
|
79
|
+
runId: data["runId"],
|
|
80
|
+
status: data["status"],
|
|
81
|
+
timestamp: data["timestamp"],
|
|
82
|
+
resultJson: data["resultJson"] ?? null,
|
|
83
|
+
error: data["error"] ?? null,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Validate raw event data, fire the matching callback, and return the typed event. */
|
|
91
|
+
function dispatchEvent(data, options) {
|
|
92
|
+
const event = validateEvent(data);
|
|
93
|
+
if (!event)
|
|
94
|
+
return null;
|
|
95
|
+
switch (event.type) {
|
|
96
|
+
case "STARTED":
|
|
97
|
+
options.onStarted?.(event);
|
|
98
|
+
break;
|
|
99
|
+
case "STREAMING_URL":
|
|
100
|
+
options.onStreamingUrl?.(event);
|
|
101
|
+
break;
|
|
102
|
+
case "PROGRESS":
|
|
103
|
+
options.onProgress?.(event);
|
|
104
|
+
break;
|
|
105
|
+
case "HEARTBEAT":
|
|
106
|
+
options.onHeartbeat?.(event);
|
|
107
|
+
break;
|
|
108
|
+
case "COMPLETE":
|
|
109
|
+
options.onComplete?.(event);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
return event;
|
|
113
|
+
}
|
|
114
|
+
/** Browser automation methods. */
|
|
115
|
+
export class AgentResource extends APIResource {
|
|
116
|
+
/**
|
|
117
|
+
* Run a browser automation.
|
|
118
|
+
*
|
|
119
|
+
* Returns a promise that resolves with the completed agent run output.
|
|
120
|
+
*/
|
|
121
|
+
async run(params) {
|
|
122
|
+
return this._client.post("/v1/automation/run", {
|
|
123
|
+
json: buildRunBody(params),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Queue a browser automation and return immediately.
|
|
128
|
+
*
|
|
129
|
+
* Does not wait for the run to complete — returns a `run_id` straight away.
|
|
130
|
+
* Use `client.runs.get(run_id)` to poll for the result.
|
|
131
|
+
*/
|
|
132
|
+
async queue(params) {
|
|
133
|
+
return this._client.post("/v1/automation/run-async", {
|
|
134
|
+
json: buildRunBody(params),
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Stream live events from a browser automation run.
|
|
139
|
+
*
|
|
140
|
+
* Returns an `AgentStream` that yields typed SSE events in real time:
|
|
141
|
+
* STARTED → STREAMING_URL → PROGRESS (repeated) → COMPLETE.
|
|
142
|
+
*
|
|
143
|
+
* Use the `on*` callbacks for a reactive style, or iterate over
|
|
144
|
+
* the stream for a sequential style:
|
|
145
|
+
*
|
|
146
|
+
* ```ts
|
|
147
|
+
* const stream = await client.agent.stream({ goal: "...", url: "..." });
|
|
148
|
+
* for await (const event of stream) {
|
|
149
|
+
* if (event.type === "PROGRESS") console.log(event.purpose);
|
|
150
|
+
* }
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
async stream(params, options = {}) {
|
|
154
|
+
const raw = await this._client.postStream("/v1/automation/run-sse", {
|
|
155
|
+
json: buildRunBody(params),
|
|
156
|
+
});
|
|
157
|
+
async function* generate() {
|
|
158
|
+
for await (const data of parseSSEStream(raw)) {
|
|
159
|
+
const event = dispatchEvent(data, options);
|
|
160
|
+
if (event) {
|
|
161
|
+
yield event;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return new AgentStream(generate());
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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;AA0BlD;;;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,SAAS;QAAE,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;IACxF,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS;QAAE,IAAI,CAAC,YAAY,GAAG,MAAM,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MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,wBAAwB,EAAE;YACnE,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC;SAC1B,CAAC,CAAC;QAEH,KAAK,SAAS,CAAC,CAAC,QAAQ;YACvB,IAAI,KAAK,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,CAAC,CAAC;IACpC,CAAC;CACD"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent automation request/response types.
|
|
3
|
+
*/
|
|
4
|
+
/** Browser profile for execution. */
|
|
5
|
+
export declare enum BrowserProfile {
|
|
6
|
+
LITE = "lite",
|
|
7
|
+
STEALTH = "stealth"
|
|
8
|
+
}
|
|
9
|
+
/** ISO 3166-1 alpha-2 country code for proxy location. */
|
|
10
|
+
export declare enum ProxyCountryCode {
|
|
11
|
+
US = "US",
|
|
12
|
+
GB = "GB",
|
|
13
|
+
CA = "CA",
|
|
14
|
+
DE = "DE",
|
|
15
|
+
FR = "FR",
|
|
16
|
+
JP = "JP",
|
|
17
|
+
AU = "AU"
|
|
18
|
+
}
|
|
19
|
+
/** Proxy configuration for browser automation. */
|
|
20
|
+
export interface ProxyConfig {
|
|
21
|
+
/** Enable proxy for this automation run. */
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
/** ISO 3166-1 alpha-2 country code for proxy location. */
|
|
24
|
+
country_code?: ProxyCountryCode;
|
|
25
|
+
}
|
|
26
|
+
/** Parameters for a synchronous agent run. */
|
|
27
|
+
export interface AgentRunParams {
|
|
28
|
+
/** Natural language description of what to do on the page. */
|
|
29
|
+
goal: string;
|
|
30
|
+
/** The URL to open the browser on. */
|
|
31
|
+
url: string;
|
|
32
|
+
/** `"lite"` (default) or `"stealth"` (anti-detection). */
|
|
33
|
+
browser_profile?: BrowserProfile;
|
|
34
|
+
/** Optional proxy settings. */
|
|
35
|
+
proxy_config?: ProxyConfig;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Status of an automation run.
|
|
39
|
+
*
|
|
40
|
+
* Use these constants instead of raw strings when filtering or branching
|
|
41
|
+
* on run status — your IDE will autocomplete the options and typos become
|
|
42
|
+
* type errors.
|
|
43
|
+
*/
|
|
44
|
+
export declare enum RunStatus {
|
|
45
|
+
PENDING = "PENDING",
|
|
46
|
+
RUNNING = "RUNNING",
|
|
47
|
+
COMPLETED = "COMPLETED",
|
|
48
|
+
FAILED = "FAILED",
|
|
49
|
+
CANCELLED = "CANCELLED"
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Error category indicating the source of failure.
|
|
53
|
+
*
|
|
54
|
+
* - `SYSTEM_FAILURE` — TinyFish infrastructure issue, safe to retry.
|
|
55
|
+
* - `AGENT_FAILURE` — Problem with the run itself, fix the input.
|
|
56
|
+
* - `UNKNOWN` — Unclassified, treat as retryable.
|
|
57
|
+
*/
|
|
58
|
+
export declare enum ErrorCategory {
|
|
59
|
+
SYSTEM_FAILURE = "SYSTEM_FAILURE",
|
|
60
|
+
AGENT_FAILURE = "AGENT_FAILURE",
|
|
61
|
+
UNKNOWN = "UNKNOWN"
|
|
62
|
+
}
|
|
63
|
+
/** Error details for failed runs. */
|
|
64
|
+
export interface RunError {
|
|
65
|
+
/** Error message describing why the run failed. */
|
|
66
|
+
message: string;
|
|
67
|
+
/** Error category indicating the source of failure. */
|
|
68
|
+
category: ErrorCategory;
|
|
69
|
+
/** Suggested retry delay in whole seconds (integer). */
|
|
70
|
+
retry_after: number | null;
|
|
71
|
+
/** URL to troubleshooting docs. */
|
|
72
|
+
help_url?: string;
|
|
73
|
+
/** Human-readable guidance. */
|
|
74
|
+
help_message?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Response from synchronous automation execution.
|
|
78
|
+
*
|
|
79
|
+
* Check `status` to determine success/failure:
|
|
80
|
+
* - On success: `result` is populated, `error` is `null`.
|
|
81
|
+
* - On failure: `result` is `null`, `error` contains the message.
|
|
82
|
+
*/
|
|
83
|
+
export interface AgentRunResponse {
|
|
84
|
+
/** Final status of the automation run. */
|
|
85
|
+
status: RunStatus;
|
|
86
|
+
/** Unique identifier for the automation run. */
|
|
87
|
+
run_id: string | null;
|
|
88
|
+
/** Structured JSON result extracted from the automation. `null` if the run failed. */
|
|
89
|
+
result: Record<string, unknown> | null;
|
|
90
|
+
/** Error details. `null` if the run succeeded. */
|
|
91
|
+
error: RunError | null;
|
|
92
|
+
/** Number of steps taken during the automation. */
|
|
93
|
+
num_of_steps: number;
|
|
94
|
+
/** ISO 8601 timestamp when the run started. */
|
|
95
|
+
started_at: string | null;
|
|
96
|
+
/** ISO 8601 timestamp when the run finished. */
|
|
97
|
+
finished_at: string | null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Response from asynchronous automation execution.
|
|
101
|
+
*
|
|
102
|
+
* Returns `run_id` immediately without waiting for completion.
|
|
103
|
+
* Use `client.runs.get(run_id)` to check status later.
|
|
104
|
+
*/
|
|
105
|
+
export interface AgentRunAsyncResponse {
|
|
106
|
+
/** Unique identifier for the created automation run. */
|
|
107
|
+
run_id: string | null;
|
|
108
|
+
/** Error details. `null` if successful. */
|
|
109
|
+
error: RunError | null;
|
|
110
|
+
}
|
|
111
|
+
/** SSE event type discriminator. */
|
|
112
|
+
export declare enum EventType {
|
|
113
|
+
STARTED = "STARTED",
|
|
114
|
+
STREAMING_URL = "STREAMING_URL",
|
|
115
|
+
PROGRESS = "PROGRESS",
|
|
116
|
+
HEARTBEAT = "HEARTBEAT",
|
|
117
|
+
COMPLETE = "COMPLETE"
|
|
118
|
+
}
|
|
119
|
+
/** SSE event indicating the automation run has started. */
|
|
120
|
+
export interface StartedEvent {
|
|
121
|
+
type: "STARTED";
|
|
122
|
+
runId: string;
|
|
123
|
+
timestamp: string;
|
|
124
|
+
}
|
|
125
|
+
/** SSE event providing the live browser streaming URL. */
|
|
126
|
+
export interface StreamingUrlEvent {
|
|
127
|
+
type: "STREAMING_URL";
|
|
128
|
+
runId: string;
|
|
129
|
+
streamingUrl: string;
|
|
130
|
+
timestamp: string;
|
|
131
|
+
}
|
|
132
|
+
/** SSE event indicating automation progress/activity. */
|
|
133
|
+
export interface ProgressEvent {
|
|
134
|
+
type: "PROGRESS";
|
|
135
|
+
runId: string;
|
|
136
|
+
purpose: string;
|
|
137
|
+
timestamp: string;
|
|
138
|
+
}
|
|
139
|
+
/** SSE event for connection keepalive. */
|
|
140
|
+
export interface HeartbeatEvent {
|
|
141
|
+
type: "HEARTBEAT";
|
|
142
|
+
timestamp: string;
|
|
143
|
+
}
|
|
144
|
+
/** SSE event indicating the automation run has completed. */
|
|
145
|
+
export interface CompleteEvent {
|
|
146
|
+
type: "COMPLETE";
|
|
147
|
+
runId: string;
|
|
148
|
+
status: RunStatus;
|
|
149
|
+
timestamp: string;
|
|
150
|
+
resultJson: Record<string, unknown> | null;
|
|
151
|
+
error: RunError | null;
|
|
152
|
+
}
|
|
153
|
+
/** Union type for all possible SSE streaming events. */
|
|
154
|
+
export type AgentRunWithStreamingResponse = StartedEvent | StreamingUrlEvent | ProgressEvent | HeartbeatEvent | CompleteEvent;
|
|
155
|
+
/** Optional callbacks for stream events. */
|
|
156
|
+
export interface StreamOptions {
|
|
157
|
+
onStarted?: (event: StartedEvent) => void;
|
|
158
|
+
onStreamingUrl?: (event: StreamingUrlEvent) => void;
|
|
159
|
+
onProgress?: (event: ProgressEvent) => void;
|
|
160
|
+
onHeartbeat?: (event: HeartbeatEvent) => void;
|
|
161
|
+
onComplete?: (event: CompleteEvent) => void;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1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AED,0CAA0C;AAC1C,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,6DAA6D;AAC7D,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,SAAS,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3C,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACvB;AAED,wDAAwD;AACxD,MAAM,MAAM,6BAA6B,GACtC,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,cAAc,GACd,aAAa,CAAC;AAEjB,4CAA4C;AAC5C,MAAM,WAAW,aAAa;IAC7B,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,cAAc,CAAC,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"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent automation request/response types.
|
|
3
|
+
*/
|
|
4
|
+
// -- Input types --
|
|
5
|
+
/** Browser profile for execution. */
|
|
6
|
+
export var BrowserProfile;
|
|
7
|
+
(function (BrowserProfile) {
|
|
8
|
+
BrowserProfile["LITE"] = "lite";
|
|
9
|
+
BrowserProfile["STEALTH"] = "stealth";
|
|
10
|
+
})(BrowserProfile || (BrowserProfile = {}));
|
|
11
|
+
/** ISO 3166-1 alpha-2 country code for proxy location. */
|
|
12
|
+
export var ProxyCountryCode;
|
|
13
|
+
(function (ProxyCountryCode) {
|
|
14
|
+
ProxyCountryCode["US"] = "US";
|
|
15
|
+
ProxyCountryCode["GB"] = "GB";
|
|
16
|
+
ProxyCountryCode["CA"] = "CA";
|
|
17
|
+
ProxyCountryCode["DE"] = "DE";
|
|
18
|
+
ProxyCountryCode["FR"] = "FR";
|
|
19
|
+
ProxyCountryCode["JP"] = "JP";
|
|
20
|
+
ProxyCountryCode["AU"] = "AU";
|
|
21
|
+
})(ProxyCountryCode || (ProxyCountryCode = {}));
|
|
22
|
+
// -- Response types (shared with runs later) --
|
|
23
|
+
/**
|
|
24
|
+
* Status of an automation run.
|
|
25
|
+
*
|
|
26
|
+
* Use these constants instead of raw strings when filtering or branching
|
|
27
|
+
* on run status — your IDE will autocomplete the options and typos become
|
|
28
|
+
* type errors.
|
|
29
|
+
*/
|
|
30
|
+
export var RunStatus;
|
|
31
|
+
(function (RunStatus) {
|
|
32
|
+
RunStatus["PENDING"] = "PENDING";
|
|
33
|
+
RunStatus["RUNNING"] = "RUNNING";
|
|
34
|
+
RunStatus["COMPLETED"] = "COMPLETED";
|
|
35
|
+
RunStatus["FAILED"] = "FAILED";
|
|
36
|
+
RunStatus["CANCELLED"] = "CANCELLED";
|
|
37
|
+
})(RunStatus || (RunStatus = {}));
|
|
38
|
+
/**
|
|
39
|
+
* Error category indicating the source of failure.
|
|
40
|
+
*
|
|
41
|
+
* - `SYSTEM_FAILURE` — TinyFish infrastructure issue, safe to retry.
|
|
42
|
+
* - `AGENT_FAILURE` — Problem with the run itself, fix the input.
|
|
43
|
+
* - `UNKNOWN` — Unclassified, treat as retryable.
|
|
44
|
+
*/
|
|
45
|
+
export var ErrorCategory;
|
|
46
|
+
(function (ErrorCategory) {
|
|
47
|
+
ErrorCategory["SYSTEM_FAILURE"] = "SYSTEM_FAILURE";
|
|
48
|
+
ErrorCategory["AGENT_FAILURE"] = "AGENT_FAILURE";
|
|
49
|
+
ErrorCategory["UNKNOWN"] = "UNKNOWN";
|
|
50
|
+
})(ErrorCategory || (ErrorCategory = {}));
|
|
51
|
+
// -- SSE streaming event types --
|
|
52
|
+
/** SSE event type discriminator. */
|
|
53
|
+
export var EventType;
|
|
54
|
+
(function (EventType) {
|
|
55
|
+
EventType["STARTED"] = "STARTED";
|
|
56
|
+
EventType["STREAMING_URL"] = "STREAMING_URL";
|
|
57
|
+
EventType["PROGRESS"] = "PROGRESS";
|
|
58
|
+
EventType["HEARTBEAT"] = "HEARTBEAT";
|
|
59
|
+
EventType["COMPLETE"] = "COMPLETE";
|
|
60
|
+
})(EventType || (EventType = {}));
|
|
61
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +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;AAsBD,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;AAqDD,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"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyFish TypeScript SDK client.
|
|
3
|
+
*/
|
|
4
|
+
import { BaseClient } from "./_utils/client.js";
|
|
5
|
+
import type { ClientOptions } from "./_utils/client.js";
|
|
6
|
+
import { AgentResource } from "./agent/index.js";
|
|
7
|
+
import { RunsResource } from "./runs/index.js";
|
|
8
|
+
export declare class TinyFish extends BaseClient {
|
|
9
|
+
readonly agent: AgentResource;
|
|
10
|
+
readonly runs: RunsResource;
|
|
11
|
+
constructor(options?: ClientOptions);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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;AAE/C,qBAAa,QAAS,SAAQ,UAAU;IACvC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;gBAEhB,OAAO,CAAC,EAAE,aAAa;CAKnC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyFish TypeScript SDK client.
|
|
3
|
+
*/
|
|
4
|
+
import { BaseClient } from "./_utils/client.js";
|
|
5
|
+
import { AgentResource } from "./agent/index.js";
|
|
6
|
+
import { RunsResource } from "./runs/index.js";
|
|
7
|
+
export class TinyFish extends BaseClient {
|
|
8
|
+
agent;
|
|
9
|
+
runs;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super(options);
|
|
12
|
+
this.agent = new AgentResource(this);
|
|
13
|
+
this.runs = new RunsResource(this);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +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;AAE/C,MAAM,OAAO,QAAS,SAAQ,UAAU;IAC9B,KAAK,CAAgB;IACrB,IAAI,CAAe;IAE5B,YAAY,OAAuB;QAClC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyFish TypeScript SDK — State-of-the-art web agents in an API.
|
|
3
|
+
*/
|
|
4
|
+
export { VERSION } from "./version.js";
|
|
5
|
+
export type { ClientOptions } from "./_utils/client.js";
|
|
6
|
+
export { TinyFish } from "./client.js";
|
|
7
|
+
export { AgentStream } from "./agent/index.js";
|
|
8
|
+
export { BrowserProfile, ProxyCountryCode, RunStatus, ErrorCategory, EventType, } from "./agent/types.js";
|
|
9
|
+
export type { ProxyConfig, AgentRunParams, AgentRunResponse, AgentRunAsyncResponse, RunError, StartedEvent, StreamingUrlEvent, ProgressEvent, HeartbeatEvent, CompleteEvent, AgentRunWithStreamingResponse, StreamOptions, } from "./agent/types.js";
|
|
10
|
+
export { SortDirection } from "./runs/types.js";
|
|
11
|
+
export type { BrowserConfig, Run, PaginationInfo, RunListResponse, RunListParams, } from "./runs/types.js";
|
|
12
|
+
export { SDKError, SSEParseError, APIError, APIConnectionError, APITimeoutError, APIStatusError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, RequestTimeoutError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_utils/errors.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,SAAS,GACT,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACX,WAAW,EACX,cAAc,EACd,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,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
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyFish TypeScript SDK — State-of-the-art web agents in an API.
|
|
3
|
+
*/
|
|
4
|
+
export { VERSION } from "./version.js";
|
|
5
|
+
// Client
|
|
6
|
+
export { TinyFish } from "./client.js";
|
|
7
|
+
// Resources
|
|
8
|
+
export { AgentStream } from "./agent/index.js";
|
|
9
|
+
// Agent types
|
|
10
|
+
export { BrowserProfile, ProxyCountryCode, RunStatus, ErrorCategory, EventType, } from "./agent/types.js";
|
|
11
|
+
// Runs types
|
|
12
|
+
export { SortDirection } from "./runs/types.js";
|
|
13
|
+
// Error hierarchy
|
|
14
|
+
export { SDKError, SSEParseError, APIError, APIConnectionError, APITimeoutError, APIStatusError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, RequestTimeoutError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_utils/errors.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,SAAS;AACT,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,cAAc;AACd,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,SAAS,GACT,MAAM,kBAAkB,CAAC;AAgB1B,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAShD,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,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs resource for retrieving and listing automation runs.
|
|
3
|
+
*/
|
|
4
|
+
import { APIResource } from "../_utils/resource.js";
|
|
5
|
+
import type { Run, RunListParams, RunListResponse } from "./types.js";
|
|
6
|
+
/** Retrieve and list automation runs. */
|
|
7
|
+
export declare class RunsResource extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieve a single run by its ID.
|
|
10
|
+
*
|
|
11
|
+
* Returns a promise that resolves with the full run details
|
|
12
|
+
* including status, result, error, and browser configuration.
|
|
13
|
+
*
|
|
14
|
+
* @param runId - The run ID returned by `agent.queue()` or any run response.
|
|
15
|
+
*/
|
|
16
|
+
get(runId: string): Promise<Run>;
|
|
17
|
+
/**
|
|
18
|
+
* List automation runs, with optional filtering and pagination.
|
|
19
|
+
*
|
|
20
|
+
* Returns a promise that resolves with a paginated list of runs
|
|
21
|
+
* and pagination info (total count, next cursor).
|
|
22
|
+
*/
|
|
23
|
+
list(params?: RunListParams): Promise<RunListResponse>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runs/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEtE,yCAAyC;AACzC,qBAAa,YAAa,SAAQ,WAAW;IAC5C;;;;;;;OAOG;IACG,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAOtC;;;;;OAKG;IACG,IAAI,CAAC,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;CAgBhE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs resource for retrieving and listing automation runs.
|
|
3
|
+
*/
|
|
4
|
+
import { APIResource } from "../_utils/resource.js";
|
|
5
|
+
/** Retrieve and list automation runs. */
|
|
6
|
+
export class RunsResource extends APIResource {
|
|
7
|
+
/**
|
|
8
|
+
* Retrieve a single run by its ID.
|
|
9
|
+
*
|
|
10
|
+
* Returns a promise that resolves with the full run details
|
|
11
|
+
* including status, result, error, and browser configuration.
|
|
12
|
+
*
|
|
13
|
+
* @param runId - The run ID returned by `agent.queue()` or any run response.
|
|
14
|
+
*/
|
|
15
|
+
async get(runId) {
|
|
16
|
+
if (typeof runId !== "string" || !runId.trim()) {
|
|
17
|
+
throw new Error("run_id must be a non-empty string");
|
|
18
|
+
}
|
|
19
|
+
return this._client.get(`/v1/runs/${encodeURIComponent(runId)}`);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* List automation runs, with optional filtering and pagination.
|
|
23
|
+
*
|
|
24
|
+
* Returns a promise that resolves with a paginated list of runs
|
|
25
|
+
* and pagination info (total count, next cursor).
|
|
26
|
+
*/
|
|
27
|
+
async list(params = {}) {
|
|
28
|
+
const queryParams = {};
|
|
29
|
+
if (params.cursor !== undefined)
|
|
30
|
+
queryParams["cursor"] = params.cursor;
|
|
31
|
+
if (params.limit !== undefined)
|
|
32
|
+
queryParams["limit"] = params.limit;
|
|
33
|
+
if (params.status !== undefined)
|
|
34
|
+
queryParams["status"] = params.status;
|
|
35
|
+
if (params.goal !== undefined)
|
|
36
|
+
queryParams["goal"] = params.goal;
|
|
37
|
+
if (params.created_after !== undefined)
|
|
38
|
+
queryParams["created_after"] = params.created_after;
|
|
39
|
+
if (params.created_before !== undefined)
|
|
40
|
+
queryParams["created_before"] = params.created_before;
|
|
41
|
+
if (params.sort_direction !== undefined)
|
|
42
|
+
queryParams["sort_direction"] = params.sort_direction;
|
|
43
|
+
const hasParams = Object.keys(queryParams).length > 0;
|
|
44
|
+
return this._client.get("/v1/runs", hasParams ? { params: queryParams } : undefined);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runs/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,yCAAyC;AACzC,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC5C;;;;;;;OAOG;IACH,KAAK,CAAC,GAAG,CAAC,KAAa;QACtB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAM,YAAY,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,SAAwB,EAAE;QACpC,MAAM,WAAW,GAA8C,EAAE,CAAC;QAClE,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;YAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;QACvE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,WAAW,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,KAA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