@pixelml/agenticflow-sdk 1.0.0
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 +253 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +183 -0
- package/dist/core.js.map +1 -0
- package/dist/exceptions.d.ts +50 -0
- package/dist/exceptions.d.ts.map +1 -0
- package/dist/exceptions.js +78 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/http.d.ts +20 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +99 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/agents.d.ts +37 -0
- package/dist/resources/agents.d.ts.map +1 -0
- package/dist/resources/agents.js +88 -0
- package/dist/resources/agents.js.map +1 -0
- package/dist/resources/connections.d.ts +36 -0
- package/dist/resources/connections.d.ts.map +1 -0
- package/dist/resources/connections.js +77 -0
- package/dist/resources/connections.js.map +1 -0
- package/dist/resources/index.d.ts +6 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +6 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/node-types.d.ts +21 -0
- package/dist/resources/node-types.d.ts.map +1 -0
- package/dist/resources/node-types.js +73 -0
- package/dist/resources/node-types.js.map +1 -0
- package/dist/resources/uploads.d.ts +12 -0
- package/dist/resources/uploads.d.ts.map +1 -0
- package/dist/resources/uploads.js +16 -0
- package/dist/resources/uploads.js.map +1 -0
- package/dist/resources/workflows.d.ts +45 -0
- package/dist/resources/workflows.d.ts.map +1 -0
- package/dist/resources/workflows.js +107 -0
- package/dist/resources/workflows.js.map +1 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +37 -0
- package/dist/types.js.map +1 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# AgenticFlow JavaScript SDK
|
|
2
|
+
|
|
3
|
+
A typed JavaScript/TypeScript SDK for building applications with
|
|
4
|
+
the [AgenticFlow](https://agenticflow.ai) platform. Manage agents, workflows,
|
|
5
|
+
connections, and more — all from a single client.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @pixelml/agenticflow-sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @pixelml/agenticflow-sdk
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @pixelml/agenticflow-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { createClient } from "@pixelml/agenticflow-sdk";
|
|
21
|
+
|
|
22
|
+
const client = createClient({
|
|
23
|
+
apiKey: process.env.AGENTICFLOW_API_KEY,
|
|
24
|
+
workspaceId: process.env.AGENTICFLOW_WORKSPACE_ID,
|
|
25
|
+
projectId: process.env.AGENTICFLOW_PROJECT_ID,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// List all agents
|
|
29
|
+
const agents = await client.agents.list();
|
|
30
|
+
console.log(agents.data);
|
|
31
|
+
|
|
32
|
+
// Run a workflow
|
|
33
|
+
const run = await client.workflows.run({
|
|
34
|
+
workflow_id: "wf-abc123",
|
|
35
|
+
input: { prompt: "Hello!" },
|
|
36
|
+
});
|
|
37
|
+
console.log(run.data);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Authentication
|
|
41
|
+
|
|
42
|
+
The SDK uses API key authentication via the `Authorization: Bearer` header.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const client = createClient({
|
|
46
|
+
apiKey: "sk-...",
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The `apiKey` can also be read automatically from the `AGENTICFLOW_API_KEY`
|
|
51
|
+
environment variable if not provided explicitly.
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
| Option | Env Variable | Description |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `apiKey` | `AGENTICFLOW_API_KEY` | API key for authentication |
|
|
58
|
+
| `workspaceId` | `AGENTICFLOW_WORKSPACE_ID` | Default workspace ID |
|
|
59
|
+
| `projectId` | `AGENTICFLOW_PROJECT_ID` | Default project ID |
|
|
60
|
+
| `baseUrl` | — | API base URL (default: `https://api.agenticflow.ai/`) |
|
|
61
|
+
| `timeout` | — | Request timeout |
|
|
62
|
+
| `defaultHeaders` | — | Custom headers for all requests |
|
|
63
|
+
|
|
64
|
+
## Resources
|
|
65
|
+
|
|
66
|
+
### Agents
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// List agents (with optional filters)
|
|
70
|
+
await client.agents.list({ limit: 20, offset: 0 });
|
|
71
|
+
|
|
72
|
+
// CRUD
|
|
73
|
+
await client.agents.create({ name: "My Agent", ... });
|
|
74
|
+
await client.agents.get("agent-id");
|
|
75
|
+
await client.agents.update("agent-id", { name: "Updated" });
|
|
76
|
+
await client.agents.delete("agent-id");
|
|
77
|
+
|
|
78
|
+
// Streaming
|
|
79
|
+
await client.agents.stream("agent-id", { input: "Hello" });
|
|
80
|
+
|
|
81
|
+
// Publishing
|
|
82
|
+
await client.agents.getPublishInfo("agent-id", { platform: "telegram" });
|
|
83
|
+
await client.agents.publish("agent-id", { platform: "web" });
|
|
84
|
+
await client.agents.unpublish("agent-id", { platform: "web" });
|
|
85
|
+
|
|
86
|
+
// File uploads
|
|
87
|
+
await client.agents.uploadFile("agent-id", filePayload);
|
|
88
|
+
await client.agents.getUploadSession("agent-id", "session-id");
|
|
89
|
+
|
|
90
|
+
// Misc
|
|
91
|
+
await client.agents.getReferenceImpact("agent-id");
|
|
92
|
+
await client.agents.saveAsTemplate("agent-id", templatePayload);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Workflows
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
// List workflows in a workspace
|
|
99
|
+
await client.workflows.list({ limit: 10, searchQuery: "my flow" });
|
|
100
|
+
|
|
101
|
+
// CRUD
|
|
102
|
+
await client.workflows.create({ name: "New Workflow", ... });
|
|
103
|
+
await client.workflows.get("workflow-id");
|
|
104
|
+
await client.workflows.update("workflow-id", updatePayload);
|
|
105
|
+
await client.workflows.delete("workflow-id");
|
|
106
|
+
|
|
107
|
+
// Run a workflow
|
|
108
|
+
const run = await client.workflows.run({
|
|
109
|
+
workflow_id: "workflow-id",
|
|
110
|
+
input: { key: "value" },
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Check run status
|
|
114
|
+
await client.workflows.getRun("run-id");
|
|
115
|
+
|
|
116
|
+
// List runs for a workflow
|
|
117
|
+
await client.workflows.listRuns("workflow-id", { limit: 50 });
|
|
118
|
+
|
|
119
|
+
// Run history
|
|
120
|
+
await client.workflows.runHistory("workflow-id");
|
|
121
|
+
|
|
122
|
+
// Validate a workflow definition
|
|
123
|
+
await client.workflows.validate(workflowPayload);
|
|
124
|
+
|
|
125
|
+
// Reference impact analysis
|
|
126
|
+
await client.workflows.getReferenceImpact("workflow-id");
|
|
127
|
+
|
|
128
|
+
// Like / Unlike
|
|
129
|
+
await client.workflows.like("workflow-id");
|
|
130
|
+
await client.workflows.unlike("workflow-id");
|
|
131
|
+
await client.workflows.getLikeStatus("workflow-id");
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Connections
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// List connections (requires projectId)
|
|
138
|
+
await client.connections.list();
|
|
139
|
+
|
|
140
|
+
// CRUD
|
|
141
|
+
await client.connections.create(connectionPayload);
|
|
142
|
+
await client.connections.update("conn-id", updatePayload);
|
|
143
|
+
await client.connections.delete("conn-id");
|
|
144
|
+
|
|
145
|
+
// Get default connection for a category
|
|
146
|
+
await client.connections.getDefault({ categoryName: "llm" });
|
|
147
|
+
|
|
148
|
+
// List connection categories
|
|
149
|
+
await client.connections.categories();
|
|
150
|
+
|
|
151
|
+
// Health checks
|
|
152
|
+
await client.connections.healthCheckPreCreate(configPayload);
|
|
153
|
+
await client.connections.healthCheckPostCreate("conn-id");
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Node Types
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
// List all node types
|
|
160
|
+
await client.nodeTypes.list();
|
|
161
|
+
|
|
162
|
+
// Get a specific node type by name
|
|
163
|
+
await client.nodeTypes.get("node-type-name");
|
|
164
|
+
|
|
165
|
+
// Search node types
|
|
166
|
+
await client.nodeTypes.search("text generation");
|
|
167
|
+
|
|
168
|
+
// Get dynamic options for a node type field
|
|
169
|
+
await client.nodeTypes.dynamicOptions({
|
|
170
|
+
name: "node-type-name",
|
|
171
|
+
fieldName: "model",
|
|
172
|
+
connection: "conn-id",
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Uploads
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
// Create an anonymous upload session
|
|
180
|
+
await client.uploads.inputCreate({ filename: "data.csv", ... });
|
|
181
|
+
|
|
182
|
+
// Check upload session status
|
|
183
|
+
await client.uploads.inputStatus("session-id");
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Error Handling
|
|
187
|
+
|
|
188
|
+
The SDK throws typed errors for different HTTP status codes:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import {
|
|
192
|
+
AuthenticationError,
|
|
193
|
+
AuthorizationError,
|
|
194
|
+
NotFoundError,
|
|
195
|
+
ValidationError,
|
|
196
|
+
RateLimitError,
|
|
197
|
+
ServerError,
|
|
198
|
+
} from "@pixelml/agenticflow-sdk";
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
await client.agents.get("invalid-id");
|
|
202
|
+
} catch (err) {
|
|
203
|
+
if (err instanceof NotFoundError) {
|
|
204
|
+
console.log("Agent not found:", err.message);
|
|
205
|
+
} else if (err instanceof AuthenticationError) {
|
|
206
|
+
console.log("Invalid API key");
|
|
207
|
+
} else if (err instanceof RateLimitError) {
|
|
208
|
+
console.log("Rate limited, retry later");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
| Error Class | HTTP Status |
|
|
214
|
+
|---|---|
|
|
215
|
+
| `ValidationError` | 400, 422 |
|
|
216
|
+
| `AuthenticationError` | 401 |
|
|
217
|
+
| `AuthorizationError` | 403 |
|
|
218
|
+
| `NotFoundError` | 404 |
|
|
219
|
+
| `ConflictError` | 409 |
|
|
220
|
+
| `RateLimitError` | 429 |
|
|
221
|
+
| `ServerError` | 5xx |
|
|
222
|
+
|
|
223
|
+
## Low-Level Access
|
|
224
|
+
|
|
225
|
+
For endpoints not covered by resource classes, use the underlying SDK instance:
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
const response = await client.sdk.get("/v1/custom/endpoint");
|
|
229
|
+
const response = await client.sdk.post("/v1/custom/endpoint", {
|
|
230
|
+
json: { key: "value" },
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Available methods: `get`, `post`, `put`, `patch`, `delete`.
|
|
235
|
+
|
|
236
|
+
## Response Format
|
|
237
|
+
|
|
238
|
+
All resource methods return an `APIResponse` object:
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
interface APIResponse {
|
|
242
|
+
ok: boolean;
|
|
243
|
+
statusCode: number;
|
|
244
|
+
data: unknown;
|
|
245
|
+
text: string;
|
|
246
|
+
headers: Record<string, string>;
|
|
247
|
+
requestId: string | null;
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## License
|
|
252
|
+
|
|
253
|
+
Apache-2.0
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core AgenticFlow SDK client implementation.
|
|
3
|
+
*/
|
|
4
|
+
import { type Timeout } from "./http.js";
|
|
5
|
+
import { type APIResponse } from "./types.js";
|
|
6
|
+
export declare const DEFAULT_BASE_URL = "https://api.agenticflow.ai/";
|
|
7
|
+
export declare const AGENTICFLOW_API_KEY = "AGENTICFLOW_API_KEY";
|
|
8
|
+
export declare const WORKSPACE_ID = "AGENTICFLOW_WORKSPACE_ID";
|
|
9
|
+
export declare const PROJECT_ID = "AGENTICFLOW_PROJECT_ID";
|
|
10
|
+
export interface AgenticFlowSDKOptions {
|
|
11
|
+
apiKey?: string | null;
|
|
12
|
+
workspaceId?: string | null;
|
|
13
|
+
projectId?: string | null;
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
timeout?: Timeout;
|
|
16
|
+
defaultHeaders?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export declare class AgenticFlowSDK {
|
|
19
|
+
readonly apiKey: string | null;
|
|
20
|
+
readonly workspaceId: string | null;
|
|
21
|
+
readonly projectId: string | null;
|
|
22
|
+
readonly baseUrl: string;
|
|
23
|
+
private transport;
|
|
24
|
+
private defaultHeaders;
|
|
25
|
+
constructor(options?: AgenticFlowSDKOptions);
|
|
26
|
+
request(method: string, path: string, options?: {
|
|
27
|
+
pathParams?: Record<string, unknown> | null;
|
|
28
|
+
queryParams?: Record<string, unknown> | null;
|
|
29
|
+
headers?: Record<string, string> | null;
|
|
30
|
+
json?: unknown;
|
|
31
|
+
body?: unknown;
|
|
32
|
+
data?: unknown;
|
|
33
|
+
timeout?: Timeout | null;
|
|
34
|
+
}): Promise<APIResponse>;
|
|
35
|
+
call(operation: string, options?: {
|
|
36
|
+
method?: string;
|
|
37
|
+
path?: string | null;
|
|
38
|
+
pathParams?: Record<string, unknown> | null;
|
|
39
|
+
queryParams?: Record<string, unknown> | null;
|
|
40
|
+
headers?: Record<string, string> | null;
|
|
41
|
+
json?: unknown;
|
|
42
|
+
body?: unknown;
|
|
43
|
+
data?: unknown;
|
|
44
|
+
timeout?: Timeout | null;
|
|
45
|
+
}): Promise<APIResponse>;
|
|
46
|
+
get(path: string, options?: Parameters<AgenticFlowSDK["request"]>[2]): Promise<APIResponse>;
|
|
47
|
+
post(path: string, options?: Parameters<AgenticFlowSDK["request"]>[2]): Promise<APIResponse>;
|
|
48
|
+
put(path: string, options?: Parameters<AgenticFlowSDK["request"]>[2]): Promise<APIResponse>;
|
|
49
|
+
patch(path: string, options?: Parameters<AgenticFlowSDK["request"]>[2]): Promise<APIResponse>;
|
|
50
|
+
delete(path: string, options?: Parameters<AgenticFlowSDK["request"]>[2]): Promise<APIResponse>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,OAAO,EAA2B,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,gBAAgB,gCAAgC,CAAC;AAC9D,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AACzD,eAAO,MAAM,YAAY,6BAA6B,CAAC;AACvD,eAAO,MAAM,UAAU,2BAA2B,CAAC;AAGnD,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED,qBAAa,cAAc;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAA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,CAAC;IAevB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAI3F,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAI5F,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAI3F,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAI7F,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;CAG/F"}
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core AgenticFlow SDK client implementation.
|
|
3
|
+
*/
|
|
4
|
+
import { APIError, AuthenticationError, AuthorizationError, ConflictError, NotFoundError, RateLimitError, ServerError, ValidationError, } from "./exceptions.js";
|
|
5
|
+
import { DeterministicHTTPClient } from "./http.js";
|
|
6
|
+
import { fromFetchResponse } from "./types.js";
|
|
7
|
+
export const DEFAULT_BASE_URL = "https://api.agenticflow.ai/";
|
|
8
|
+
export const AGENTICFLOW_API_KEY = "AGENTICFLOW_API_KEY";
|
|
9
|
+
export const WORKSPACE_ID = "AGENTICFLOW_WORKSPACE_ID";
|
|
10
|
+
export const PROJECT_ID = "AGENTICFLOW_PROJECT_ID";
|
|
11
|
+
const PATH_PARAM_RE = /\{([^{}]+)\}/g;
|
|
12
|
+
export class AgenticFlowSDK {
|
|
13
|
+
apiKey;
|
|
14
|
+
workspaceId;
|
|
15
|
+
projectId;
|
|
16
|
+
baseUrl;
|
|
17
|
+
transport;
|
|
18
|
+
defaultHeaders;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.apiKey = resolveApiKey(options.apiKey);
|
|
21
|
+
this.workspaceId = resolveEnvValue(options.workspaceId, WORKSPACE_ID);
|
|
22
|
+
this.projectId = resolveEnvValue(options.projectId, PROJECT_ID);
|
|
23
|
+
this.baseUrl = normalizeBaseUrl(options.baseUrl ?? DEFAULT_BASE_URL);
|
|
24
|
+
this.transport = new DeterministicHTTPClient({ timeout: options.timeout });
|
|
25
|
+
this.defaultHeaders = { Accept: "application/json" };
|
|
26
|
+
if (options.defaultHeaders) {
|
|
27
|
+
Object.assign(this.defaultHeaders, options.defaultHeaders);
|
|
28
|
+
}
|
|
29
|
+
if (this.apiKey) {
|
|
30
|
+
this.defaultHeaders["Authorization"] = `Bearer ${this.apiKey}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async request(method, path, options = {}) {
|
|
34
|
+
if (options.json != null && options.body != null) {
|
|
35
|
+
throw new Error("Provide either `json` or `body`, but not both.");
|
|
36
|
+
}
|
|
37
|
+
const requestJson = options.json ?? options.body ?? undefined;
|
|
38
|
+
const mergedHeaders = { ...this.defaultHeaders };
|
|
39
|
+
if (options.headers) {
|
|
40
|
+
Object.assign(mergedHeaders, options.headers);
|
|
41
|
+
}
|
|
42
|
+
if (this.apiKey && !hasAuthorization(mergedHeaders)) {
|
|
43
|
+
mergedHeaders["Authorization"] = `Bearer ${this.apiKey}`;
|
|
44
|
+
}
|
|
45
|
+
const response = await this.transport.request({
|
|
46
|
+
method,
|
|
47
|
+
url: `${this.baseUrl}${resolvePath(path, options.pathParams)}`,
|
|
48
|
+
params: options.queryParams,
|
|
49
|
+
headers: mergedHeaders,
|
|
50
|
+
json: requestJson,
|
|
51
|
+
data: options.data,
|
|
52
|
+
timeout: options.timeout ?? undefined,
|
|
53
|
+
});
|
|
54
|
+
const normalized = await fromFetchResponse(response, method);
|
|
55
|
+
raiseForStatus(normalized);
|
|
56
|
+
return normalized;
|
|
57
|
+
}
|
|
58
|
+
async call(operation, options = {}) {
|
|
59
|
+
const method = options.method ?? "GET";
|
|
60
|
+
const target = options.path ?? (operation.startsWith("/") ? operation : `/${operation}`);
|
|
61
|
+
return this.request(method, target, {
|
|
62
|
+
pathParams: options.pathParams,
|
|
63
|
+
queryParams: options.queryParams,
|
|
64
|
+
headers: options.headers,
|
|
65
|
+
json: options.json,
|
|
66
|
+
body: options.body,
|
|
67
|
+
data: options.data,
|
|
68
|
+
timeout: options.timeout,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
get(path, options) {
|
|
72
|
+
return this.request("GET", path, options);
|
|
73
|
+
}
|
|
74
|
+
post(path, options) {
|
|
75
|
+
return this.request("POST", path, options);
|
|
76
|
+
}
|
|
77
|
+
put(path, options) {
|
|
78
|
+
return this.request("PUT", path, options);
|
|
79
|
+
}
|
|
80
|
+
patch(path, options) {
|
|
81
|
+
return this.request("PATCH", path, options);
|
|
82
|
+
}
|
|
83
|
+
delete(path, options) {
|
|
84
|
+
return this.request("DELETE", path, options);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// --- Helpers ---
|
|
88
|
+
function hasAuthorization(headers) {
|
|
89
|
+
return Object.keys(headers).some((k) => k.toLowerCase() === "authorization");
|
|
90
|
+
}
|
|
91
|
+
function resolveApiKey(apiKey) {
|
|
92
|
+
if (apiKey && apiKey.trim())
|
|
93
|
+
return apiKey;
|
|
94
|
+
return process.env[AGENTICFLOW_API_KEY] ?? null;
|
|
95
|
+
}
|
|
96
|
+
function resolveEnvValue(value, envKey) {
|
|
97
|
+
if (value && value.trim())
|
|
98
|
+
return value;
|
|
99
|
+
if (envKey)
|
|
100
|
+
return process.env[envKey] ?? null;
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
function normalizeBaseUrl(baseUrl) {
|
|
104
|
+
const normalized = baseUrl.trim();
|
|
105
|
+
if (!normalized)
|
|
106
|
+
throw new Error("baseUrl cannot be empty");
|
|
107
|
+
return normalized.endsWith("/") ? normalized.slice(0, -1) : normalized;
|
|
108
|
+
}
|
|
109
|
+
function resolvePath(path, pathParams) {
|
|
110
|
+
if (!path)
|
|
111
|
+
throw new Error("path cannot be empty");
|
|
112
|
+
let basePath = path.startsWith("/") ? path : `/${path}`;
|
|
113
|
+
const requiredParams = [];
|
|
114
|
+
let match;
|
|
115
|
+
const re = new RegExp(PATH_PARAM_RE);
|
|
116
|
+
while ((match = re.exec(basePath)) !== null) {
|
|
117
|
+
requiredParams.push(match[1]);
|
|
118
|
+
}
|
|
119
|
+
if (requiredParams.length === 0)
|
|
120
|
+
return basePath;
|
|
121
|
+
if (!pathParams) {
|
|
122
|
+
const missing = [...new Set(requiredParams)].sort().join(", ");
|
|
123
|
+
throw new Error(`Missing required path parameters: ${missing}`);
|
|
124
|
+
}
|
|
125
|
+
for (const key of [...new Set(requiredParams)].sort()) {
|
|
126
|
+
if (!(key in pathParams)) {
|
|
127
|
+
const missing = [...new Set(requiredParams)].sort().join(", ");
|
|
128
|
+
throw new Error(`Missing required path parameters: ${missing}`);
|
|
129
|
+
}
|
|
130
|
+
const value = pathParams[key];
|
|
131
|
+
if (value == null) {
|
|
132
|
+
throw new Error(`Missing required path parameter: ${key}`);
|
|
133
|
+
}
|
|
134
|
+
basePath = basePath.replaceAll(`{${key}}`, encodeURIComponent(String(value)));
|
|
135
|
+
}
|
|
136
|
+
return basePath;
|
|
137
|
+
}
|
|
138
|
+
function extractErrorMessage(payload, fallback) {
|
|
139
|
+
if (typeof payload === "string" && payload.trim())
|
|
140
|
+
return payload.trim();
|
|
141
|
+
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
|
|
142
|
+
const obj = payload;
|
|
143
|
+
for (const key of ["detail", "message", "error", "errors", "description"]) {
|
|
144
|
+
const value = obj[key];
|
|
145
|
+
if (typeof value === "string" && value.trim())
|
|
146
|
+
return value.trim();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (payload != null) {
|
|
150
|
+
const asText = String(payload).trim();
|
|
151
|
+
if (asText)
|
|
152
|
+
return asText;
|
|
153
|
+
}
|
|
154
|
+
return typeof fallback === "string" ? fallback.trim() : "An unknown API error occurred.";
|
|
155
|
+
}
|
|
156
|
+
function raiseForStatus(response) {
|
|
157
|
+
if (response.ok)
|
|
158
|
+
return;
|
|
159
|
+
const detail = extractErrorMessage(response.data, response.text);
|
|
160
|
+
const message = `Request failed with status ${response.statusCode}: ${detail}`;
|
|
161
|
+
const opts = {
|
|
162
|
+
statusCode: response.statusCode,
|
|
163
|
+
message,
|
|
164
|
+
payload: response.data,
|
|
165
|
+
requestId: response.requestId,
|
|
166
|
+
};
|
|
167
|
+
if (response.statusCode === 400 || response.statusCode === 422)
|
|
168
|
+
throw new ValidationError(opts);
|
|
169
|
+
if (response.statusCode === 401)
|
|
170
|
+
throw new AuthenticationError(opts);
|
|
171
|
+
if (response.statusCode === 403)
|
|
172
|
+
throw new AuthorizationError(opts);
|
|
173
|
+
if (response.statusCode === 404)
|
|
174
|
+
throw new NotFoundError(opts);
|
|
175
|
+
if (response.statusCode === 409)
|
|
176
|
+
throw new ConflictError(opts);
|
|
177
|
+
if (response.statusCode === 429)
|
|
178
|
+
throw new RateLimitError(opts);
|
|
179
|
+
if (response.statusCode >= 500)
|
|
180
|
+
throw new ServerError(opts);
|
|
181
|
+
throw new APIError(opts);
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,QAAQ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Error extends AgenticFlowError {
|
|
8
|
+
cause?: Error;
|
|
9
|
+
constructor(message: string, options?: {
|
|
10
|
+
cause?: Error;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export declare class RequestTimeoutError extends NetworkError {
|
|
14
|
+
constructor(message?: string, options?: {
|
|
15
|
+
cause?: Error;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export declare class APIError extends AgenticFlowError {
|
|
19
|
+
statusCode: number;
|
|
20
|
+
payload: unknown;
|
|
21
|
+
requestId: string | null;
|
|
22
|
+
constructor(options: {
|
|
23
|
+
statusCode: number;
|
|
24
|
+
message: string;
|
|
25
|
+
payload?: unknown;
|
|
26
|
+
requestId?: string | null;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export declare class ValidationError extends APIError {
|
|
30
|
+
constructor(options: ConstructorParameters<typeof APIError>[0]);
|
|
31
|
+
}
|
|
32
|
+
export declare class AuthenticationError extends APIError {
|
|
33
|
+
constructor(options: ConstructorParameters<typeof APIError>[0]);
|
|
34
|
+
}
|
|
35
|
+
export declare class AuthorizationError extends APIError {
|
|
36
|
+
constructor(options: ConstructorParameters<typeof APIError>[0]);
|
|
37
|
+
}
|
|
38
|
+
export declare class NotFoundError extends APIError {
|
|
39
|
+
constructor(options: ConstructorParameters<typeof APIError>[0]);
|
|
40
|
+
}
|
|
41
|
+
export declare class ConflictError extends APIError {
|
|
42
|
+
constructor(options: ConstructorParameters<typeof APIError>[0]);
|
|
43
|
+
}
|
|
44
|
+
export declare class RateLimitError extends APIError {
|
|
45
|
+
constructor(options: ConstructorParameters<typeof APIError>[0]);
|
|
46
|
+
}
|
|
47
|
+
export declare class ServerError extends APIError {
|
|
48
|
+
constructor(options: ConstructorParameters<typeof APIError>[0]);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/except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AAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;CAI/D;AAED,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;CAI/D;AAED,qBAAa,WAAY,SAAQ,QAAQ;gBAC3B,OAAO,EAAE,qBAAqB,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;CAI/D"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exception hierarchy for the AgenticFlow SDK.
|
|
3
|
+
*/
|
|
4
|
+
export class AgenticFlowError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "AgenticFlowError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class NetworkError extends AgenticFlowError {
|
|
11
|
+
cause;
|
|
12
|
+
constructor(message, options) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "NetworkError";
|
|
15
|
+
this.cause = options?.cause;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class RequestTimeoutError extends NetworkError {
|
|
19
|
+
constructor(message = "Request timed out.", options) {
|
|
20
|
+
super(message, options);
|
|
21
|
+
this.name = "RequestTimeoutError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class APIError extends AgenticFlowError {
|
|
25
|
+
statusCode;
|
|
26
|
+
payload;
|
|
27
|
+
requestId;
|
|
28
|
+
constructor(options) {
|
|
29
|
+
super(options.message);
|
|
30
|
+
this.name = "APIError";
|
|
31
|
+
this.statusCode = options.statusCode;
|
|
32
|
+
this.payload = options.payload ?? null;
|
|
33
|
+
this.requestId = options.requestId ?? null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export class ValidationError extends APIError {
|
|
37
|
+
constructor(options) {
|
|
38
|
+
super(options);
|
|
39
|
+
this.name = "ValidationError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class AuthenticationError extends APIError {
|
|
43
|
+
constructor(options) {
|
|
44
|
+
super(options);
|
|
45
|
+
this.name = "AuthenticationError";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class AuthorizationError extends APIError {
|
|
49
|
+
constructor(options) {
|
|
50
|
+
super(options);
|
|
51
|
+
this.name = "AuthorizationError";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export class NotFoundError extends APIError {
|
|
55
|
+
constructor(options) {
|
|
56
|
+
super(options);
|
|
57
|
+
this.name = "NotFoundError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export class ConflictError extends APIError {
|
|
61
|
+
constructor(options) {
|
|
62
|
+
super(options);
|
|
63
|
+
this.name = "ConflictError";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export class RateLimitError extends APIError {
|
|
67
|
+
constructor(options) {
|
|
68
|
+
super(options);
|
|
69
|
+
this.name = "RateLimitError";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export class ServerError extends APIError {
|
|
73
|
+
constructor(options) {
|
|
74
|
+
super(options);
|
|
75
|
+
this.name = "ServerError";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=exceptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,gBAAgB;IAChD,KAAK,CAAS;IAEd,YAAY,OAAe,EAAE,OAA2B;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,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I,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,aAAc,SAAQ,QAAQ;IACzC,YAAY,OAAkD;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C,YAAY,OAAkD;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACvC,YAAY,OAAkD;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic HTTP transport layer used by the SDK core.
|
|
3
|
+
*/
|
|
4
|
+
export type Timeout = number;
|
|
5
|
+
export declare class DeterministicHTTPClient {
|
|
6
|
+
private timeout;
|
|
7
|
+
constructor(options?: {
|
|
8
|
+
timeout?: Timeout;
|
|
9
|
+
});
|
|
10
|
+
request(options: {
|
|
11
|
+
method: string;
|
|
12
|
+
url: string;
|
|
13
|
+
params?: Record<string, unknown> | null;
|
|
14
|
+
headers?: Record<string, string> | null;
|
|
15
|
+
json?: unknown;
|
|
16
|
+
data?: unknown;
|
|
17
|
+
timeout?: Timeout | null;
|
|
18
|
+
}): Promise<Response>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,qBAAa,uBAAuB;IAClC,OAAO,CAAC,OAAO,CAAU;gBAEb,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;IAIrC,OAAO,CAAC,OAAO,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;QACxC,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;KAC1B,GAAG,OAAO,CAAC,QAAQ,CAAC;CAoDtB"}
|