@agent-nexus/sdk 0.1.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/LICENSE +21 -0
- package/README.md +260 -0
- package/dist/index.d.mts +3336 -0
- package/dist/index.d.ts +3336 -0
- package/dist/index.js +2182 -0
- package/dist/index.mjs +2129 -0
- package/package.json +56 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2129 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var NexusError = class extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "NexusError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
var NexusApiError = class extends NexusError {
|
|
9
|
+
constructor(code, message, status, details) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "NexusApiError";
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.details = details;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var NexusAuthenticationError = class extends NexusApiError {
|
|
18
|
+
constructor(message = "Invalid or missing API key") {
|
|
19
|
+
super("UNAUTHORIZED", message, 401);
|
|
20
|
+
this.name = "NexusAuthenticationError";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var NexusConnectionError = class extends NexusError {
|
|
24
|
+
constructor(message, cause) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "NexusConnectionError";
|
|
27
|
+
this.cause = cause;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/http-client.ts
|
|
32
|
+
var HttpClient = class {
|
|
33
|
+
constructor(opts) {
|
|
34
|
+
this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
|
|
35
|
+
this.apiKey = opts.apiKey;
|
|
36
|
+
this.fetchFn = opts.fetch ?? globalThis.fetch;
|
|
37
|
+
this.defaultHeaders = opts.defaultHeaders ?? {};
|
|
38
|
+
this.timeout = opts.timeout ?? 3e4;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Make a request and return the unwrapped `data` field.
|
|
42
|
+
*
|
|
43
|
+
* @param method - HTTP method (GET, POST, PATCH, DELETE).
|
|
44
|
+
* @param path - API path relative to `/api/public/v1` (e.g. `"/agents"`).
|
|
45
|
+
* @param opts - Optional body, query params, and headers.
|
|
46
|
+
* @returns The response `data` field, typed as `T`.
|
|
47
|
+
* @throws {NexusAuthenticationError} On 401 responses.
|
|
48
|
+
* @throws {NexusApiError} On other error responses.
|
|
49
|
+
* @throws {NexusConnectionError} On network failures or timeouts.
|
|
50
|
+
*/
|
|
51
|
+
async request(method, path, opts = {}) {
|
|
52
|
+
const { data } = await this.requestWithMeta(method, path, opts);
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Make a request and return `{ data, meta }` (useful for paginated lists).
|
|
57
|
+
*
|
|
58
|
+
* @param method - HTTP method.
|
|
59
|
+
* @param path - API path relative to `/api/public/v1`.
|
|
60
|
+
* @param opts - Optional body, query params, and headers.
|
|
61
|
+
* @returns The response `data` and optional pagination `meta`.
|
|
62
|
+
* @throws {NexusAuthenticationError} On 401 responses.
|
|
63
|
+
* @throws {NexusApiError} On other error responses.
|
|
64
|
+
* @throws {NexusConnectionError} On network failures or timeouts.
|
|
65
|
+
*/
|
|
66
|
+
async requestWithMeta(method, path, opts = {}) {
|
|
67
|
+
const url = new URL(`${this.baseUrl}/api/public/v1${path}`);
|
|
68
|
+
if (opts.query) {
|
|
69
|
+
for (const [k, v] of Object.entries(opts.query)) {
|
|
70
|
+
if (v !== void 0) url.searchParams.set(k, String(v));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const headers = {
|
|
74
|
+
...this.defaultHeaders,
|
|
75
|
+
...opts.headers,
|
|
76
|
+
"api-key": this.apiKey,
|
|
77
|
+
Accept: "application/json"
|
|
78
|
+
};
|
|
79
|
+
const fetchInit = { method, headers };
|
|
80
|
+
if (opts.body !== void 0) {
|
|
81
|
+
if (opts.body instanceof FormData) {
|
|
82
|
+
fetchInit.body = opts.body;
|
|
83
|
+
} else {
|
|
84
|
+
headers["Content-Type"] = "application/json";
|
|
85
|
+
fetchInit.body = JSON.stringify(opts.body);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const controller = new AbortController();
|
|
89
|
+
fetchInit.signal = controller.signal;
|
|
90
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
91
|
+
let res;
|
|
92
|
+
try {
|
|
93
|
+
res = await this.fetchFn(url.toString(), fetchInit);
|
|
94
|
+
} catch (err) {
|
|
95
|
+
clearTimeout(timer);
|
|
96
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
97
|
+
throw new NexusConnectionError(`Request timed out after ${this.timeout}ms`);
|
|
98
|
+
}
|
|
99
|
+
throw new NexusConnectionError(
|
|
100
|
+
err instanceof Error ? err.message : "Network request failed",
|
|
101
|
+
err instanceof Error ? err : void 0
|
|
102
|
+
);
|
|
103
|
+
} finally {
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
}
|
|
106
|
+
let json;
|
|
107
|
+
try {
|
|
108
|
+
json = await res.json();
|
|
109
|
+
} catch {
|
|
110
|
+
throw new NexusApiError(
|
|
111
|
+
"PARSE_ERROR",
|
|
112
|
+
`Failed to parse response body (status ${res.status})`,
|
|
113
|
+
res.status
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (!json.success) {
|
|
117
|
+
const err = json.error;
|
|
118
|
+
if (!err || typeof err !== "object") {
|
|
119
|
+
const raw = json;
|
|
120
|
+
const msg = raw.message ?? `Request failed with status ${res.status}`;
|
|
121
|
+
const code = raw.error ?? `HTTP_${res.status}`;
|
|
122
|
+
if (res.status === 401) {
|
|
123
|
+
throw new NexusAuthenticationError(msg);
|
|
124
|
+
}
|
|
125
|
+
throw new NexusApiError(code, msg, res.status);
|
|
126
|
+
}
|
|
127
|
+
if (res.status === 401) {
|
|
128
|
+
throw new NexusAuthenticationError(err.message);
|
|
129
|
+
}
|
|
130
|
+
throw new NexusApiError(err.code, err.message, res.status, err.details);
|
|
131
|
+
}
|
|
132
|
+
const success = json;
|
|
133
|
+
return { data: success.data, meta: success.meta };
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// src/resources/base-resource.ts
|
|
138
|
+
var BaseResource = class {
|
|
139
|
+
constructor(http) {
|
|
140
|
+
this.http = http;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// src/resources/agent-collections.ts
|
|
145
|
+
var AgentCollectionsResource = class extends BaseResource {
|
|
146
|
+
async list(agentId) {
|
|
147
|
+
return this.http.request("GET", `/agents/${agentId}/collections`);
|
|
148
|
+
}
|
|
149
|
+
async attach(agentId, body) {
|
|
150
|
+
return this.http.request("POST", `/agents/${agentId}/collections`, { body });
|
|
151
|
+
}
|
|
152
|
+
async detach(agentId, body) {
|
|
153
|
+
return this.http.request("DELETE", `/agents/${agentId}/collections`, { body });
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/resources/agent-tools.ts
|
|
158
|
+
var AgentToolsResource = class extends BaseResource {
|
|
159
|
+
/**
|
|
160
|
+
* List all tool configurations for an agent.
|
|
161
|
+
*
|
|
162
|
+
* @param agentId - Agent UUID.
|
|
163
|
+
* @returns Array of tool configurations.
|
|
164
|
+
*/
|
|
165
|
+
async list(agentId) {
|
|
166
|
+
return this.http.request("GET", `/agents/${agentId}/tools`);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get a specific tool configuration.
|
|
170
|
+
*
|
|
171
|
+
* @param agentId - Agent UUID.
|
|
172
|
+
* @param toolId - Tool config UUID.
|
|
173
|
+
* @returns Tool configuration detail.
|
|
174
|
+
*/
|
|
175
|
+
async get(agentId, toolId) {
|
|
176
|
+
return this.http.request("GET", `/agents/${agentId}/tools/${toolId}`);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Add a new tool configuration to an agent.
|
|
180
|
+
*
|
|
181
|
+
* @param agentId - Agent UUID.
|
|
182
|
+
* @param body - Tool configuration. `label` and `type` are required.
|
|
183
|
+
* @returns The created tool configuration.
|
|
184
|
+
*/
|
|
185
|
+
async create(agentId, body) {
|
|
186
|
+
return this.http.request("POST", `/agents/${agentId}/tools`, { body });
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Update an existing tool configuration. Only provided fields are updated.
|
|
190
|
+
*
|
|
191
|
+
* @param agentId - Agent UUID.
|
|
192
|
+
* @param toolId - Tool config UUID.
|
|
193
|
+
* @param body - Fields to update.
|
|
194
|
+
* @returns The updated tool configuration.
|
|
195
|
+
*/
|
|
196
|
+
async update(agentId, toolId, body) {
|
|
197
|
+
return this.http.request("PATCH", `/agents/${agentId}/tools/${toolId}`, {
|
|
198
|
+
body
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Remove a tool configuration from an agent.
|
|
203
|
+
*
|
|
204
|
+
* @param agentId - Agent UUID.
|
|
205
|
+
* @param toolId - Tool config UUID.
|
|
206
|
+
* @returns Confirmation with the deleted tool config's ID.
|
|
207
|
+
*/
|
|
208
|
+
async delete(agentId, toolId) {
|
|
209
|
+
return this.http.request("DELETE", `/agents/${agentId}/tools/${toolId}`);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Attach a knowledge collection to an agent.
|
|
213
|
+
*
|
|
214
|
+
* Creates a COLLECTION-type tool that allows the agent to search the
|
|
215
|
+
* collection during conversations. If `label` is omitted, the collection
|
|
216
|
+
* name is used.
|
|
217
|
+
*
|
|
218
|
+
* @param agentId - Agent UUID.
|
|
219
|
+
* @param body - Collection ID and optional label/description/instructions.
|
|
220
|
+
* @returns The created tool configuration.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* const tool = await client.agents.tools.attachCollection("agent-uuid", {
|
|
225
|
+
* collectionId: "collection-uuid"
|
|
226
|
+
* });
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
async attachCollection(agentId, body) {
|
|
230
|
+
return this.http.request(
|
|
231
|
+
"POST",
|
|
232
|
+
`/agents/${agentId}/tools/attach-collection`,
|
|
233
|
+
{ body }
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
// src/resources/versions.ts
|
|
239
|
+
var VersionsResource = class extends BaseResource {
|
|
240
|
+
/**
|
|
241
|
+
* List prompt versions for an agent (paginated).
|
|
242
|
+
*
|
|
243
|
+
* @param agentId - Agent UUID.
|
|
244
|
+
* @param params - Optional type filter and pagination.
|
|
245
|
+
* @returns Paginated list of version summaries.
|
|
246
|
+
*/
|
|
247
|
+
async list(agentId, params) {
|
|
248
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
249
|
+
"GET",
|
|
250
|
+
`/agents/${agentId}/versions`,
|
|
251
|
+
{ query: params }
|
|
252
|
+
);
|
|
253
|
+
return { data, meta };
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get detailed information about a specific version, including the full prompt content.
|
|
257
|
+
*
|
|
258
|
+
* @param agentId - Agent UUID.
|
|
259
|
+
* @param versionId - Version UUID.
|
|
260
|
+
* @returns Version detail with the prompt text.
|
|
261
|
+
*/
|
|
262
|
+
async get(agentId, versionId) {
|
|
263
|
+
return this.http.request("GET", `/agents/${agentId}/versions/${versionId}`);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Create a named checkpoint of the agent's current prompt.
|
|
267
|
+
*
|
|
268
|
+
* @param agentId - Agent UUID.
|
|
269
|
+
* @param body - Optional name and description for the checkpoint.
|
|
270
|
+
* @returns The created checkpoint version.
|
|
271
|
+
*/
|
|
272
|
+
async createCheckpoint(agentId, body) {
|
|
273
|
+
return this.http.request("POST", `/agents/${agentId}/versions`, {
|
|
274
|
+
body: body ?? {}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Update a version's metadata (name or description).
|
|
279
|
+
*
|
|
280
|
+
* @param agentId - Agent UUID.
|
|
281
|
+
* @param versionId - Version UUID.
|
|
282
|
+
* @param body - Fields to update.
|
|
283
|
+
* @returns The updated version detail.
|
|
284
|
+
*/
|
|
285
|
+
async update(agentId, versionId, body) {
|
|
286
|
+
return this.http.request("PATCH", `/agents/${agentId}/versions/${versionId}`, {
|
|
287
|
+
body
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Delete a prompt version. Cannot delete the current production version.
|
|
292
|
+
*
|
|
293
|
+
* @param agentId - Agent UUID.
|
|
294
|
+
* @param versionId - Version UUID.
|
|
295
|
+
* @returns Confirmation with the deleted version's ID.
|
|
296
|
+
*/
|
|
297
|
+
async delete(agentId, versionId) {
|
|
298
|
+
return this.http.request("DELETE", `/agents/${agentId}/versions/${versionId}`);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Restore the agent's prompt to a specific version. This overwrites the
|
|
302
|
+
* agent's current prompt with the content from the specified version.
|
|
303
|
+
*
|
|
304
|
+
* @param agentId - Agent UUID.
|
|
305
|
+
* @param versionId - Version UUID to restore.
|
|
306
|
+
* @returns The restored prompt content and a confirmation message.
|
|
307
|
+
*/
|
|
308
|
+
async restore(agentId, versionId) {
|
|
309
|
+
return this.http.request(
|
|
310
|
+
"POST",
|
|
311
|
+
`/agents/${agentId}/versions/${versionId}/restore`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Publish a version to production. This marks the version as the active
|
|
316
|
+
* production version for the agent.
|
|
317
|
+
*
|
|
318
|
+
* @param agentId - Agent UUID.
|
|
319
|
+
* @param versionId - Version UUID to publish.
|
|
320
|
+
* @returns The published version detail with `isProduction: true`.
|
|
321
|
+
*/
|
|
322
|
+
async publish(agentId, versionId) {
|
|
323
|
+
return this.http.request(
|
|
324
|
+
"POST",
|
|
325
|
+
`/agents/${agentId}/versions/${versionId}/publish`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/resources/agents.ts
|
|
331
|
+
var AgentsResource = class extends BaseResource {
|
|
332
|
+
constructor(http) {
|
|
333
|
+
super(http);
|
|
334
|
+
this.tools = new AgentToolsResource(http);
|
|
335
|
+
this.versions = new VersionsResource(http);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* List agents with optional filtering and pagination.
|
|
339
|
+
*
|
|
340
|
+
* @param params - Optional filters and pagination.
|
|
341
|
+
* @returns Paginated list of agent summaries.
|
|
342
|
+
*/
|
|
343
|
+
async list(params) {
|
|
344
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/agents", {
|
|
345
|
+
query: params
|
|
346
|
+
});
|
|
347
|
+
return { data, meta };
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Get detailed information about a specific agent.
|
|
351
|
+
*
|
|
352
|
+
* @param agentId - Agent UUID.
|
|
353
|
+
* @returns Full agent detail including prompt, behaviour rules, and model configuration.
|
|
354
|
+
*/
|
|
355
|
+
async get(agentId) {
|
|
356
|
+
return this.http.request("GET", `/agents/${agentId}`);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Create a new agent.
|
|
360
|
+
*
|
|
361
|
+
* @param body - Agent properties. `firstName`, `lastName`, and `role` are required.
|
|
362
|
+
* @returns The created agent detail.
|
|
363
|
+
*/
|
|
364
|
+
async create(body) {
|
|
365
|
+
return this.http.request("POST", "/agents", { body });
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Update an existing agent's properties. Only provided fields are updated.
|
|
369
|
+
*
|
|
370
|
+
* @param agentId - Agent UUID.
|
|
371
|
+
* @param body - Fields to update.
|
|
372
|
+
* @returns The updated agent detail.
|
|
373
|
+
*/
|
|
374
|
+
async update(agentId, body) {
|
|
375
|
+
return this.http.request("PATCH", `/agents/${agentId}`, { body });
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Permanently delete an agent and all its tool configurations and versions.
|
|
379
|
+
*
|
|
380
|
+
* @param agentId - Agent UUID.
|
|
381
|
+
* @returns Confirmation with the deleted agent's ID.
|
|
382
|
+
*/
|
|
383
|
+
async delete(agentId) {
|
|
384
|
+
return this.http.request("DELETE", `/agents/${agentId}`);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Create a copy of an existing agent, including its configuration and tools.
|
|
388
|
+
*
|
|
389
|
+
* @param agentId - Agent UUID to duplicate.
|
|
390
|
+
* @returns The newly created agent detail.
|
|
391
|
+
*/
|
|
392
|
+
async duplicate(agentId) {
|
|
393
|
+
return this.http.request("POST", `/agents/${agentId}/duplicate`);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Upload a profile picture for an agent.
|
|
397
|
+
*
|
|
398
|
+
* @param agentId - Agent UUID.
|
|
399
|
+
* @param file - Image file as a Blob or File.
|
|
400
|
+
* @returns URL to the uploaded profile picture.
|
|
401
|
+
*/
|
|
402
|
+
async uploadProfilePicture(agentId, file) {
|
|
403
|
+
const formData = new FormData();
|
|
404
|
+
formData.append("file", file);
|
|
405
|
+
return this.http.request(
|
|
406
|
+
"POST",
|
|
407
|
+
`/agents/${agentId}/profile-picture`,
|
|
408
|
+
{ body: formData }
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Generate an AI profile picture for an agent using its name and role.
|
|
413
|
+
*
|
|
414
|
+
* @param agentId - Agent UUID.
|
|
415
|
+
* @param body - Optional custom prompt to guide image style.
|
|
416
|
+
* @returns URLs of the generated profile picture in multiple sizes.
|
|
417
|
+
*/
|
|
418
|
+
async generateProfilePicture(agentId, body) {
|
|
419
|
+
return this.http.request("POST", `/agents/${agentId}/generate-profile-picture`, { body });
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// src/resources/analytics.ts
|
|
424
|
+
var AnalyticsResource = class extends BaseResource {
|
|
425
|
+
async getOverview(params) {
|
|
426
|
+
return this.http.request("GET", "/analytics/overview", {
|
|
427
|
+
query: params
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
async exportCsv(params) {
|
|
431
|
+
return this.http.request("GET", "/analytics/export", {
|
|
432
|
+
query: params
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
async listFeedback(params) {
|
|
436
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/analytics/feedback", {
|
|
437
|
+
query: params
|
|
438
|
+
});
|
|
439
|
+
return { data, meta };
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// src/resources/cloud-imports.ts
|
|
444
|
+
var CloudImportsResource = class extends BaseResource {
|
|
445
|
+
// Google Drive
|
|
446
|
+
async googleDriveAuth(body) {
|
|
447
|
+
return this.http.request("POST", "/documents/google-drive/auth", { body });
|
|
448
|
+
}
|
|
449
|
+
async googleDriveRefresh(body) {
|
|
450
|
+
return this.http.request("POST", "/documents/google-drive/refresh", { body });
|
|
451
|
+
}
|
|
452
|
+
async listGoogleDriveFiles(params) {
|
|
453
|
+
return this.http.request("GET", "/documents/google-drive/files", {
|
|
454
|
+
query: params
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
async importGoogleDrive(body) {
|
|
458
|
+
return this.http.request("POST", "/documents/google-drive/import", { body });
|
|
459
|
+
}
|
|
460
|
+
// SharePoint
|
|
461
|
+
async sharePointAuth(body) {
|
|
462
|
+
return this.http.request("POST", "/documents/sharepoint/auth", { body });
|
|
463
|
+
}
|
|
464
|
+
async sharePointRefresh(body) {
|
|
465
|
+
return this.http.request("POST", "/documents/sharepoint/refresh", { body });
|
|
466
|
+
}
|
|
467
|
+
async listSharePointSites(params) {
|
|
468
|
+
return this.http.request("GET", "/documents/sharepoint/sites", {
|
|
469
|
+
query: params
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
async listSharePointFiles(params) {
|
|
473
|
+
return this.http.request("GET", "/documents/sharepoint/files", {
|
|
474
|
+
query: params
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
async importSharePoint(body) {
|
|
478
|
+
return this.http.request("POST", "/documents/sharepoint/import", { body });
|
|
479
|
+
}
|
|
480
|
+
// Notion
|
|
481
|
+
async notionAuth(body) {
|
|
482
|
+
return this.http.request("POST", "/documents/notion/auth", { body });
|
|
483
|
+
}
|
|
484
|
+
async searchNotion(params) {
|
|
485
|
+
return this.http.request("GET", "/documents/notion/search", {
|
|
486
|
+
query: params
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
async importNotion(body) {
|
|
490
|
+
return this.http.request("POST", "/documents/notion/import", { body });
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
// src/resources/deployment-folders.ts
|
|
495
|
+
var DeploymentFoldersResource = class extends BaseResource {
|
|
496
|
+
async list() {
|
|
497
|
+
return this.http.request("GET", "/deployment-folders");
|
|
498
|
+
}
|
|
499
|
+
async create(body) {
|
|
500
|
+
return this.http.request("POST", "/deployment-folders", { body });
|
|
501
|
+
}
|
|
502
|
+
async update(folderId, body) {
|
|
503
|
+
return this.http.request("PATCH", `/deployment-folders/${folderId}`, { body });
|
|
504
|
+
}
|
|
505
|
+
async delete(folderId) {
|
|
506
|
+
return this.http.request("DELETE", `/deployment-folders/${folderId}`);
|
|
507
|
+
}
|
|
508
|
+
async assign(body) {
|
|
509
|
+
return this.http.request("POST", "/deployment-folders/assign", { body });
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
// src/resources/deployments.ts
|
|
514
|
+
var DeploymentsResource = class extends BaseResource {
|
|
515
|
+
async list(params) {
|
|
516
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/deployments", {
|
|
517
|
+
query: params
|
|
518
|
+
});
|
|
519
|
+
return { data, meta };
|
|
520
|
+
}
|
|
521
|
+
async create(body) {
|
|
522
|
+
return this.http.request("POST", "/deployments", { body });
|
|
523
|
+
}
|
|
524
|
+
async get(deploymentId) {
|
|
525
|
+
return this.http.request("GET", `/deployments/${deploymentId}`);
|
|
526
|
+
}
|
|
527
|
+
async update(deploymentId, body) {
|
|
528
|
+
return this.http.request("PATCH", `/deployments/${deploymentId}`, { body });
|
|
529
|
+
}
|
|
530
|
+
async delete(deploymentId) {
|
|
531
|
+
return this.http.request("DELETE", `/deployments/${deploymentId}`);
|
|
532
|
+
}
|
|
533
|
+
async duplicate(deploymentId) {
|
|
534
|
+
return this.http.request("POST", `/deployments/${deploymentId}/duplicate`);
|
|
535
|
+
}
|
|
536
|
+
async getStatistics(deploymentId) {
|
|
537
|
+
return this.http.request("GET", `/deployments/${deploymentId}/statistics`);
|
|
538
|
+
}
|
|
539
|
+
async getEmbedConfig(deploymentId) {
|
|
540
|
+
return this.http.request("GET", `/deployments/${deploymentId}/embed-config`);
|
|
541
|
+
}
|
|
542
|
+
async updateEmbedConfig(deploymentId, body) {
|
|
543
|
+
return this.http.request("PATCH", `/deployments/${deploymentId}/embed-config`, { body });
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
// src/resources/document-template-folders.ts
|
|
548
|
+
var DocumentTemplateFoldersResource = class extends BaseResource {
|
|
549
|
+
async list() {
|
|
550
|
+
return this.http.request("GET", "/document-template-folders");
|
|
551
|
+
}
|
|
552
|
+
async create(body) {
|
|
553
|
+
return this.http.request("POST", "/document-template-folders", { body });
|
|
554
|
+
}
|
|
555
|
+
async update(folderId, body) {
|
|
556
|
+
return this.http.request("PATCH", `/document-template-folders/${folderId}`, { body });
|
|
557
|
+
}
|
|
558
|
+
async delete(folderId) {
|
|
559
|
+
return this.http.request("DELETE", `/document-template-folders/${folderId}`);
|
|
560
|
+
}
|
|
561
|
+
async assign(body) {
|
|
562
|
+
return this.http.request("POST", "/document-template-folders/assign", { body });
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// src/resources/documents.ts
|
|
567
|
+
var DocumentsResource = class extends BaseResource {
|
|
568
|
+
/**
|
|
569
|
+
* Get a document by ID.
|
|
570
|
+
*
|
|
571
|
+
* @param documentId - The document's UUID.
|
|
572
|
+
* @returns Detailed document information.
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```ts
|
|
576
|
+
* const doc = await client.documents.get("doc-uuid");
|
|
577
|
+
* console.log(doc.name, doc.status, doc.processingProgress);
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
580
|
+
async get(documentId) {
|
|
581
|
+
return this.http.request("GET", `/documents/${documentId}`);
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Upload a file as a new document.
|
|
585
|
+
*
|
|
586
|
+
* @param file - File as a `Blob`, `File`, or `Buffer`.
|
|
587
|
+
* @param fileName - File name (required when passing a `Blob` or `Buffer`).
|
|
588
|
+
* @param description - Optional description.
|
|
589
|
+
* @returns Created document info.
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```ts
|
|
593
|
+
* import fs from "fs";
|
|
594
|
+
*
|
|
595
|
+
* const buffer = fs.readFileSync("report.pdf");
|
|
596
|
+
* const doc = await client.documents.uploadFile(
|
|
597
|
+
* new Blob([buffer]),
|
|
598
|
+
* "report.pdf",
|
|
599
|
+
* "Q4 financial report"
|
|
600
|
+
* );
|
|
601
|
+
* console.log(doc.id, doc.status);
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
async uploadFile(file, fileName, description) {
|
|
605
|
+
const formData = new FormData();
|
|
606
|
+
formData.append("file", file, fileName);
|
|
607
|
+
if (description) {
|
|
608
|
+
formData.append("description", description);
|
|
609
|
+
}
|
|
610
|
+
return this.http.request("POST", "/documents/file", { body: formData });
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Create a new document from inline text content.
|
|
614
|
+
*
|
|
615
|
+
* @param body - Document name, content, and optional description.
|
|
616
|
+
* @returns Created document info.
|
|
617
|
+
*
|
|
618
|
+
* @example
|
|
619
|
+
* ```ts
|
|
620
|
+
* const doc = await client.documents.createText({
|
|
621
|
+
* name: "Meeting Notes",
|
|
622
|
+
* content: "Key decisions from today's meeting..."
|
|
623
|
+
* });
|
|
624
|
+
* ```
|
|
625
|
+
*/
|
|
626
|
+
async createText(body) {
|
|
627
|
+
return this.http.request("POST", "/documents/text", { body });
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Crawl a website and create document(s) from the content.
|
|
631
|
+
*
|
|
632
|
+
* @param body - URL, crawl mode, optional config and description.
|
|
633
|
+
* @returns Created document info (folder for crawled pages).
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```ts
|
|
637
|
+
* const doc = await client.documents.addWebsite({
|
|
638
|
+
* url: "https://docs.example.com",
|
|
639
|
+
* mode: "sitemap"
|
|
640
|
+
* });
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
async addWebsite(body) {
|
|
644
|
+
return this.http.request("POST", "/documents/website", { body });
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Import a Google Sheet as document(s).
|
|
648
|
+
*
|
|
649
|
+
* @param body - Sheet name, URL, and optional metadata.
|
|
650
|
+
* @returns Folder document, individual sheet documents, and status message.
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* ```ts
|
|
654
|
+
* const result = await client.documents.createGoogleSheet({
|
|
655
|
+
* name: "Product Catalog",
|
|
656
|
+
* url: "https://docs.google.com/spreadsheets/d/..."
|
|
657
|
+
* });
|
|
658
|
+
* console.log(result.folder.id, result.sheets.length);
|
|
659
|
+
* ```
|
|
660
|
+
*/
|
|
661
|
+
async createGoogleSheet(body) {
|
|
662
|
+
return this.http.request("POST", "/documents/google-sheet", { body });
|
|
663
|
+
}
|
|
664
|
+
async list(params) {
|
|
665
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/documents", {
|
|
666
|
+
query: params
|
|
667
|
+
});
|
|
668
|
+
return { data, meta };
|
|
669
|
+
}
|
|
670
|
+
async update(documentId, body) {
|
|
671
|
+
return this.http.request("PATCH", `/documents/${documentId}`, { body });
|
|
672
|
+
}
|
|
673
|
+
async delete(documentId) {
|
|
674
|
+
return this.http.request("DELETE", `/documents/${documentId}`);
|
|
675
|
+
}
|
|
676
|
+
async getDownloadUrl(documentId) {
|
|
677
|
+
return this.http.request(
|
|
678
|
+
"GET",
|
|
679
|
+
`/documents/${documentId}/download`
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
async listChildren(documentId, params) {
|
|
683
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
684
|
+
"GET",
|
|
685
|
+
`/documents/${documentId}/children`,
|
|
686
|
+
{
|
|
687
|
+
query: params
|
|
688
|
+
}
|
|
689
|
+
);
|
|
690
|
+
return { data, meta };
|
|
691
|
+
}
|
|
692
|
+
async reprocess(documentId) {
|
|
693
|
+
return this.http.request("POST", `/documents/${documentId}/reprocess`);
|
|
694
|
+
}
|
|
695
|
+
async createFolder(body) {
|
|
696
|
+
return this.http.request("POST", "/documents/folder", { body });
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
// src/resources/emulator.ts
|
|
701
|
+
var EmulatorResource = class extends BaseResource {
|
|
702
|
+
// ─── Sessions ───────────────────────────────────────────────────────────────
|
|
703
|
+
/** Create a new emulator session for a deployment. */
|
|
704
|
+
async createSession(deploymentId, body) {
|
|
705
|
+
return this.http.request("POST", `/emulator/${deploymentId}/sessions`, {
|
|
706
|
+
body
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
/** List emulator sessions for a deployment. */
|
|
710
|
+
async listSessions(deploymentId) {
|
|
711
|
+
return this.http.request("GET", `/emulator/${deploymentId}/sessions`);
|
|
712
|
+
}
|
|
713
|
+
/** Get detailed information about an emulator session, including messages. */
|
|
714
|
+
async getSession(deploymentId, sessionId) {
|
|
715
|
+
return this.http.request(
|
|
716
|
+
"GET",
|
|
717
|
+
`/emulator/${deploymentId}/sessions/${sessionId}`
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
/** Send a message in an emulator session. Returns debug info about agent execution. */
|
|
721
|
+
async sendMessage(deploymentId, sessionId, body) {
|
|
722
|
+
return this.http.request(
|
|
723
|
+
"POST",
|
|
724
|
+
`/emulator/${deploymentId}/sessions/${sessionId}/messages`,
|
|
725
|
+
{ body }
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
/** Delete an emulator session. */
|
|
729
|
+
async deleteSession(deploymentId, sessionId) {
|
|
730
|
+
await this.http.request("DELETE", `/emulator/${deploymentId}/sessions/${sessionId}`);
|
|
731
|
+
}
|
|
732
|
+
// ─── Scenarios ──────────────────────────────────────────────────────────────
|
|
733
|
+
/** Save a scenario from an existing emulator session. */
|
|
734
|
+
async saveScenario(body) {
|
|
735
|
+
return this.http.request("POST", "/emulator/scenarios", {
|
|
736
|
+
body
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
/** List scenarios, optionally filtered by deployment. */
|
|
740
|
+
async listScenarios(params) {
|
|
741
|
+
return this.http.request("GET", "/emulator/scenarios", {
|
|
742
|
+
query: params
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
/** Get detailed information about a scenario, including its messages. */
|
|
746
|
+
async getScenario(scenarioId) {
|
|
747
|
+
return this.http.request("GET", `/emulator/scenarios/${scenarioId}`);
|
|
748
|
+
}
|
|
749
|
+
/** Replay a scenario against a deployment. Runs asynchronously. */
|
|
750
|
+
async replayScenario(scenarioId, body) {
|
|
751
|
+
return this.http.request("POST", `/emulator/scenarios/${scenarioId}/replay`, { body });
|
|
752
|
+
}
|
|
753
|
+
/** Delete a scenario. */
|
|
754
|
+
async deleteScenario(scenarioId) {
|
|
755
|
+
await this.http.request("DELETE", `/emulator/scenarios/${scenarioId}`);
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
// src/resources/evaluations.ts
|
|
760
|
+
var EvaluationsResource = class extends BaseResource {
|
|
761
|
+
async createSession(taskId, body) {
|
|
762
|
+
return this.http.request("POST", `/skills/tasks/${taskId}/evaluations`, { body });
|
|
763
|
+
}
|
|
764
|
+
async listSessions(taskId, params) {
|
|
765
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
766
|
+
"GET",
|
|
767
|
+
`/skills/tasks/${taskId}/evaluations`,
|
|
768
|
+
{
|
|
769
|
+
query: params
|
|
770
|
+
}
|
|
771
|
+
);
|
|
772
|
+
return { data, meta };
|
|
773
|
+
}
|
|
774
|
+
async getSession(taskId, sessionId) {
|
|
775
|
+
return this.http.request("GET", `/skills/tasks/${taskId}/evaluations/${sessionId}`);
|
|
776
|
+
}
|
|
777
|
+
async deleteSession(taskId, sessionId) {
|
|
778
|
+
return this.http.request("DELETE", `/skills/tasks/${taskId}/evaluations/${sessionId}`);
|
|
779
|
+
}
|
|
780
|
+
async getDatasetRows(taskId, sessionId, params) {
|
|
781
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
782
|
+
"GET",
|
|
783
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/dataset`,
|
|
784
|
+
{
|
|
785
|
+
query: params
|
|
786
|
+
}
|
|
787
|
+
);
|
|
788
|
+
return { data, meta };
|
|
789
|
+
}
|
|
790
|
+
async addDatasetRow(taskId, sessionId, body) {
|
|
791
|
+
return this.http.request(
|
|
792
|
+
"POST",
|
|
793
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/dataset/rows`,
|
|
794
|
+
{ body }
|
|
795
|
+
);
|
|
796
|
+
}
|
|
797
|
+
async execute(taskId, sessionId) {
|
|
798
|
+
return this.http.request(
|
|
799
|
+
"POST",
|
|
800
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/execute`
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
async judge(taskId, sessionId, body) {
|
|
804
|
+
return this.http.request(
|
|
805
|
+
"POST",
|
|
806
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/judge`,
|
|
807
|
+
{ body }
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
async getResults(taskId, sessionId, params) {
|
|
811
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
812
|
+
"GET",
|
|
813
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/results`,
|
|
814
|
+
{
|
|
815
|
+
query: params
|
|
816
|
+
}
|
|
817
|
+
);
|
|
818
|
+
return { data, meta };
|
|
819
|
+
}
|
|
820
|
+
async listFormats() {
|
|
821
|
+
return this.http.request("GET", "/skills/evaluations/formats");
|
|
822
|
+
}
|
|
823
|
+
async listJudges() {
|
|
824
|
+
return this.http.request("GET", "/skills/evaluations/judges");
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
// src/resources/folders.ts
|
|
829
|
+
var FoldersResource = class extends BaseResource {
|
|
830
|
+
/**
|
|
831
|
+
* List all folders and their agent assignments.
|
|
832
|
+
*
|
|
833
|
+
* @returns All folders and a flat list of agent-to-folder assignments.
|
|
834
|
+
*/
|
|
835
|
+
async list() {
|
|
836
|
+
return this.http.request("GET", "/folders");
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Create a new folder for organizing agents.
|
|
840
|
+
*
|
|
841
|
+
* @param body - Folder properties. `name` is required. Set `parentId` for nesting.
|
|
842
|
+
* @returns The created folder.
|
|
843
|
+
*/
|
|
844
|
+
async create(body) {
|
|
845
|
+
return this.http.request("POST", "/folders", { body });
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Update a folder's properties.
|
|
849
|
+
*
|
|
850
|
+
* @param folderId - Folder UUID.
|
|
851
|
+
* @param body - Fields to update. Set `parentId` to `null` to move to root level.
|
|
852
|
+
* @returns The updated folder.
|
|
853
|
+
*/
|
|
854
|
+
async update(folderId, body) {
|
|
855
|
+
return this.http.request("PATCH", `/folders/${folderId}`, { body });
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Delete a folder. Agents in the folder are unassigned, not deleted.
|
|
859
|
+
*
|
|
860
|
+
* @param folderId - Folder UUID.
|
|
861
|
+
* @returns Confirmation with the deleted folder's ID.
|
|
862
|
+
*/
|
|
863
|
+
async delete(folderId) {
|
|
864
|
+
return this.http.request("DELETE", `/folders/${folderId}`);
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Assign an agent to a folder, or remove from folder.
|
|
868
|
+
*
|
|
869
|
+
* @param body - Agent ID and target folder ID. Set `folderId` to `null` to remove the agent from its folder.
|
|
870
|
+
* @returns Confirmation of the assignment.
|
|
871
|
+
*/
|
|
872
|
+
async assignAgent(body) {
|
|
873
|
+
return this.http.request("POST", "/folders/assign", {
|
|
874
|
+
body
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
// src/resources/models.ts
|
|
880
|
+
var ModelsResource = class extends BaseResource {
|
|
881
|
+
constructor(http) {
|
|
882
|
+
super(http);
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* List all enabled AI models available for agents.
|
|
886
|
+
*
|
|
887
|
+
* @returns Array of model summaries with identifiers, providers, and capabilities.
|
|
888
|
+
*/
|
|
889
|
+
async list() {
|
|
890
|
+
return this.http.request("GET", "/models");
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
|
|
894
|
+
// src/resources/prompt-assistant.ts
|
|
895
|
+
var PromptAssistantResource = class extends BaseResource {
|
|
896
|
+
async chat(body) {
|
|
897
|
+
return this.http.request("POST", "/prompt-assistant/chat", {
|
|
898
|
+
body
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
async getThread(threadId) {
|
|
902
|
+
return this.http.request(
|
|
903
|
+
"GET",
|
|
904
|
+
`/prompt-assistant/threads/${threadId}`
|
|
905
|
+
);
|
|
906
|
+
}
|
|
907
|
+
async deleteThread(threadId) {
|
|
908
|
+
return this.http.request(
|
|
909
|
+
"DELETE",
|
|
910
|
+
`/prompt-assistant/threads/${threadId}`
|
|
911
|
+
);
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
// src/resources/skills.ts
|
|
916
|
+
var SkillsResource = class extends BaseResource {
|
|
917
|
+
/**
|
|
918
|
+
* List the organization's workflows.
|
|
919
|
+
*
|
|
920
|
+
* @param params - Optional search, limit, and offset.
|
|
921
|
+
* @returns Matching workflows with `agentInputSchema` and total count.
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```ts
|
|
925
|
+
* const { items, total } = await client.skills.listWorkflows({ search: "onboarding" });
|
|
926
|
+
* for (const wf of items) {
|
|
927
|
+
* console.log(`${wf.name} (${wf.status}) - trigger: ${wf.triggerType}`);
|
|
928
|
+
* }
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
async listWorkflows(params) {
|
|
932
|
+
return this.http.request("GET", "/skills/workflows", {
|
|
933
|
+
query: params
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Get a single workflow by ID.
|
|
938
|
+
*
|
|
939
|
+
* @param workflowId - Workflow UUID.
|
|
940
|
+
* @returns Full workflow detail including `agentInputSchema`.
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* ```ts
|
|
944
|
+
* const wf = await client.skills.getWorkflow("workflow-uuid");
|
|
945
|
+
* console.log(wf.agentInputSchema); // JSON Schema the agent fills
|
|
946
|
+
* ```
|
|
947
|
+
*/
|
|
948
|
+
async getWorkflow(workflowId) {
|
|
949
|
+
return this.http.request("GET", `/skills/workflows/${workflowId}`);
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* List the organization's AI tasks.
|
|
953
|
+
*
|
|
954
|
+
* @param params - Optional search, limit, and offset.
|
|
955
|
+
* @returns Matching tasks (summary view) and total count.
|
|
956
|
+
*
|
|
957
|
+
* @example
|
|
958
|
+
* ```ts
|
|
959
|
+
* const { items, total } = await client.skills.listTasks({ limit: 50 });
|
|
960
|
+
* for (const task of items) {
|
|
961
|
+
* console.log(`${task.name} (${task.category}) - ${task.inputFormat} → ${task.outputFormat}`);
|
|
962
|
+
* }
|
|
963
|
+
* ```
|
|
964
|
+
*/
|
|
965
|
+
async listTasks(params) {
|
|
966
|
+
return this.http.request("GET", "/skills/tasks", {
|
|
967
|
+
query: params
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Get a single AI task by ID with full detail.
|
|
972
|
+
*
|
|
973
|
+
* Includes `jsonInputSchema` and `jsonOutputSchema` when the task uses
|
|
974
|
+
* structured JSON input/output.
|
|
975
|
+
*
|
|
976
|
+
* @param taskId - AI Task UUID.
|
|
977
|
+
* @returns Full task detail.
|
|
978
|
+
*
|
|
979
|
+
* @example
|
|
980
|
+
* ```ts
|
|
981
|
+
* const task = await client.skills.getTask("task-uuid");
|
|
982
|
+
* if (task.jsonInputSchema) {
|
|
983
|
+
* console.log("Input schema:", task.jsonInputSchema);
|
|
984
|
+
* }
|
|
985
|
+
* ```
|
|
986
|
+
*/
|
|
987
|
+
async getTask(taskId) {
|
|
988
|
+
return this.http.request("GET", `/skills/tasks/${taskId}`);
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* List the organization's knowledge collections.
|
|
992
|
+
*
|
|
993
|
+
* @param params - Optional search, limit, and offset.
|
|
994
|
+
* @returns Matching collections (summary view) and total count.
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* ```ts
|
|
998
|
+
* const { items } = await client.skills.listCollections();
|
|
999
|
+
* for (const col of items) {
|
|
1000
|
+
* console.log(`${col.name}: ${col.documentCount} documents`);
|
|
1001
|
+
* }
|
|
1002
|
+
* ```
|
|
1003
|
+
*/
|
|
1004
|
+
async listCollections(params) {
|
|
1005
|
+
return this.http.request("GET", "/skills/collections", {
|
|
1006
|
+
query: params
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Get a single knowledge collection by ID with retrieval settings.
|
|
1011
|
+
*
|
|
1012
|
+
* @param collectionId - Collection UUID.
|
|
1013
|
+
* @returns Full collection detail with `k`, `reranker`, etc.
|
|
1014
|
+
*
|
|
1015
|
+
* @example
|
|
1016
|
+
* ```ts
|
|
1017
|
+
* const col = await client.skills.getCollection("collection-uuid");
|
|
1018
|
+
* console.log(`k=${col.k}, reranker=${col.reranker}`);
|
|
1019
|
+
* ```
|
|
1020
|
+
*/
|
|
1021
|
+
async getCollection(collectionId) {
|
|
1022
|
+
return this.http.request("GET", `/skills/collections/${collectionId}`);
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* List the organization's document templates.
|
|
1026
|
+
*
|
|
1027
|
+
* @param params - Optional search, limit, and offset.
|
|
1028
|
+
* @returns Matching templates (summary view) and total count.
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* const { items } = await client.skills.listDocumentTemplates({ search: "invoice" });
|
|
1033
|
+
* for (const tpl of items) {
|
|
1034
|
+
* console.log(`${tpl.name} (${tpl.type}) - ${tpl.status}`);
|
|
1035
|
+
* }
|
|
1036
|
+
* ```
|
|
1037
|
+
*/
|
|
1038
|
+
async listDocumentTemplates(params) {
|
|
1039
|
+
return this.http.request("GET", "/skills/document-templates", {
|
|
1040
|
+
query: params
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Get a single document template by ID with full detail.
|
|
1045
|
+
*
|
|
1046
|
+
* Includes `inputFormat` (JSON schema of required inputs) and
|
|
1047
|
+
* `slidesInputFormat` (per-slide schemas for presentations).
|
|
1048
|
+
*
|
|
1049
|
+
* @param templateId - Document template UUID.
|
|
1050
|
+
* @returns Full template detail.
|
|
1051
|
+
*
|
|
1052
|
+
* @example
|
|
1053
|
+
* ```ts
|
|
1054
|
+
* const tpl = await client.skills.getDocumentTemplate("template-uuid");
|
|
1055
|
+
* console.log("Input format:", tpl.inputFormat);
|
|
1056
|
+
* ```
|
|
1057
|
+
*/
|
|
1058
|
+
async getDocumentTemplate(templateId) {
|
|
1059
|
+
return this.http.request(
|
|
1060
|
+
"GET",
|
|
1061
|
+
`/skills/document-templates/${templateId}`
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
// =========================================================================
|
|
1065
|
+
// CREATE OPERATIONS
|
|
1066
|
+
// =========================================================================
|
|
1067
|
+
/**
|
|
1068
|
+
* Create a new document template (metadata only).
|
|
1069
|
+
*
|
|
1070
|
+
* Upload a file separately with `uploadDocumentTemplateFile`.
|
|
1071
|
+
*
|
|
1072
|
+
* @param body - Template name, optional description, and type.
|
|
1073
|
+
* @returns Created template detail.
|
|
1074
|
+
*
|
|
1075
|
+
* @example
|
|
1076
|
+
* ```ts
|
|
1077
|
+
* const tpl = await client.skills.createDocumentTemplate({
|
|
1078
|
+
* name: "Invoice",
|
|
1079
|
+
* type: "WORD_FORMAT"
|
|
1080
|
+
* });
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
async createDocumentTemplate(body) {
|
|
1084
|
+
return this.http.request("POST", "/skills/document-templates", {
|
|
1085
|
+
body
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Upload a file and link it to an existing document template.
|
|
1090
|
+
*
|
|
1091
|
+
* @param templateId - Document template UUID.
|
|
1092
|
+
* @param file - File as a `Blob`, `File`, or `Buffer`.
|
|
1093
|
+
* @param fileName - File name (required when passing a `Blob` or `Buffer`).
|
|
1094
|
+
* @returns Updated template detail with `fileUrl` populated.
|
|
1095
|
+
*
|
|
1096
|
+
* @example
|
|
1097
|
+
* ```ts
|
|
1098
|
+
* import fs from "fs";
|
|
1099
|
+
*
|
|
1100
|
+
* const buffer = fs.readFileSync("template.docx");
|
|
1101
|
+
* const tpl = await client.skills.uploadDocumentTemplateFile(
|
|
1102
|
+
* "template-uuid",
|
|
1103
|
+
* new Blob([buffer]),
|
|
1104
|
+
* "template.docx"
|
|
1105
|
+
* );
|
|
1106
|
+
* console.log(tpl.fileUrl);
|
|
1107
|
+
* ```
|
|
1108
|
+
*/
|
|
1109
|
+
async uploadDocumentTemplateFile(templateId, file, fileName) {
|
|
1110
|
+
const formData = new FormData();
|
|
1111
|
+
formData.append("file", file, fileName);
|
|
1112
|
+
return this.http.request(
|
|
1113
|
+
"POST",
|
|
1114
|
+
`/skills/document-templates/${templateId}/upload-file`,
|
|
1115
|
+
{ body: formData }
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Create a new GENERATION AI task.
|
|
1120
|
+
*
|
|
1121
|
+
* The category is hardcoded to "GENERATION". The `modelName` is validated
|
|
1122
|
+
* against the available AI models — on invalid model, returns 400 with
|
|
1123
|
+
* the list of valid model names.
|
|
1124
|
+
*
|
|
1125
|
+
* @param body - Task definition.
|
|
1126
|
+
* @returns Created task detail.
|
|
1127
|
+
*
|
|
1128
|
+
* @example
|
|
1129
|
+
* ```ts
|
|
1130
|
+
* const task = await client.skills.createTask({
|
|
1131
|
+
* name: "Summarize Email",
|
|
1132
|
+
* modelName: "gpt-4o",
|
|
1133
|
+
* modelProvider: "OPEN_AI",
|
|
1134
|
+
* generation: {
|
|
1135
|
+
* expectedInput: "Raw email text",
|
|
1136
|
+
* expectedOutput: "A concise 2-sentence summary"
|
|
1137
|
+
* }
|
|
1138
|
+
* });
|
|
1139
|
+
* ```
|
|
1140
|
+
*/
|
|
1141
|
+
async createTask(body) {
|
|
1142
|
+
return this.http.request("POST", "/skills/tasks", { body });
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Create a new knowledge collection.
|
|
1146
|
+
*
|
|
1147
|
+
* @param body - Collection name and optional settings.
|
|
1148
|
+
* @returns Created collection detail.
|
|
1149
|
+
*
|
|
1150
|
+
* @example
|
|
1151
|
+
* ```ts
|
|
1152
|
+
* const col = await client.skills.createCollection({
|
|
1153
|
+
* name: "product-docs",
|
|
1154
|
+
* displayName: "Product Documentation",
|
|
1155
|
+
* k: 15
|
|
1156
|
+
* });
|
|
1157
|
+
* ```
|
|
1158
|
+
*/
|
|
1159
|
+
async createCollection(body) {
|
|
1160
|
+
return this.http.request("POST", "/skills/collections", { body });
|
|
1161
|
+
}
|
|
1162
|
+
// =========================================================================
|
|
1163
|
+
// EXTERNAL TOOLS (CUSTOM_MANIFEST)
|
|
1164
|
+
// =========================================================================
|
|
1165
|
+
/**
|
|
1166
|
+
* List the organization's external tools (CUSTOM_MANIFEST).
|
|
1167
|
+
*
|
|
1168
|
+
* @param params - Optional search, limit, and offset.
|
|
1169
|
+
* @returns Matching external tools and total count.
|
|
1170
|
+
*
|
|
1171
|
+
* @example
|
|
1172
|
+
* ```ts
|
|
1173
|
+
* const { items, total } = await client.skills.listExternalTools({ search: "weather" });
|
|
1174
|
+
* for (const tool of items) {
|
|
1175
|
+
* console.log(`${tool.name} (${tool.actionsCount} actions) - auth: ${tool.authType}`);
|
|
1176
|
+
* }
|
|
1177
|
+
* ```
|
|
1178
|
+
*/
|
|
1179
|
+
async listExternalTools(params) {
|
|
1180
|
+
return this.http.request("GET", "/skills/external-tools", {
|
|
1181
|
+
query: params
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Get a single external tool by ID.
|
|
1186
|
+
*
|
|
1187
|
+
* @param externalToolId - External tool UUID.
|
|
1188
|
+
* @returns Full external tool detail.
|
|
1189
|
+
*
|
|
1190
|
+
* @example
|
|
1191
|
+
* ```ts
|
|
1192
|
+
* const tool = await client.skills.getExternalTool("tool-uuid");
|
|
1193
|
+
* console.log(`${tool.name}: ${tool.actionsCount} actions, auth: ${tool.authType}`);
|
|
1194
|
+
* ```
|
|
1195
|
+
*/
|
|
1196
|
+
async getExternalTool(externalToolId) {
|
|
1197
|
+
return this.http.request("GET", `/skills/external-tools/${externalToolId}`);
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Create a new external tool from an OpenAPI spec.
|
|
1201
|
+
*
|
|
1202
|
+
* Parses the provided OpenAPI spec (JSON or YAML), extracts actions,
|
|
1203
|
+
* and creates the tool with the specified auth configuration.
|
|
1204
|
+
*
|
|
1205
|
+
* @param body - Tool name, OpenAPI spec, endpoint URL, and auth config.
|
|
1206
|
+
* @returns Created external tool detail with `actionsCount`.
|
|
1207
|
+
*
|
|
1208
|
+
* @example
|
|
1209
|
+
* ```ts
|
|
1210
|
+
* const tool = await client.skills.createExternalTool({
|
|
1211
|
+
* name: "Weather API",
|
|
1212
|
+
* openApiSpec: '{"openapi":"3.0.0",...}',
|
|
1213
|
+
* endpointUrl: "https://api.weather.com",
|
|
1214
|
+
* auth: { type: "service_http", apiKey: "sk-...", authorization_type: "bearer" }
|
|
1215
|
+
* });
|
|
1216
|
+
* console.log(`Created: ${tool.name} with ${tool.actionsCount} actions`);
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
1219
|
+
async createExternalTool(body) {
|
|
1220
|
+
return this.http.request("POST", "/skills/external-tools", { body });
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Test an external tool action by operationId with input parameters.
|
|
1224
|
+
*
|
|
1225
|
+
* Executes a specific action on an external tool and returns the result.
|
|
1226
|
+
* Optionally uses stored credentials for authentication.
|
|
1227
|
+
*
|
|
1228
|
+
* @param externalToolId - External tool UUID.
|
|
1229
|
+
* @param body - operationId, input params, and optional toolCredentialId.
|
|
1230
|
+
* @returns Execution result with status, output, and timing.
|
|
1231
|
+
*
|
|
1232
|
+
* @example
|
|
1233
|
+
* ```ts
|
|
1234
|
+
* const result = await client.skills.testExternalTool("tool-uuid", {
|
|
1235
|
+
* operationId: "getWeather",
|
|
1236
|
+
* input: { city: "London" }
|
|
1237
|
+
* });
|
|
1238
|
+
* console.log(`${result.status} in ${result.executionTimeMs}ms:`, result.output);
|
|
1239
|
+
* ```
|
|
1240
|
+
*/
|
|
1241
|
+
async testExternalTool(externalToolId, body) {
|
|
1242
|
+
return this.http.request(
|
|
1243
|
+
"POST",
|
|
1244
|
+
`/skills/external-tools/${externalToolId}/test`,
|
|
1245
|
+
{ body }
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
// =========================================================================
|
|
1249
|
+
// COLLECTION DOCUMENT LINKING
|
|
1250
|
+
// =========================================================================
|
|
1251
|
+
/**
|
|
1252
|
+
* Attach existing documents to a knowledge collection.
|
|
1253
|
+
*
|
|
1254
|
+
* @param collectionId - Collection UUID.
|
|
1255
|
+
* @param body - Array of document IDs to link.
|
|
1256
|
+
* @returns Status message.
|
|
1257
|
+
*
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```ts
|
|
1260
|
+
* await client.skills.attachDocumentsToCollection("collection-uuid", {
|
|
1261
|
+
* documentIds: ["doc-1", "doc-2"]
|
|
1262
|
+
* });
|
|
1263
|
+
* ```
|
|
1264
|
+
*/
|
|
1265
|
+
async attachDocumentsToCollection(collectionId, body) {
|
|
1266
|
+
return this.http.request(
|
|
1267
|
+
"POST",
|
|
1268
|
+
`/skills/collections/${collectionId}/documents`,
|
|
1269
|
+
{ body }
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
// =========================================================================
|
|
1273
|
+
// EXECUTION OPERATIONS
|
|
1274
|
+
// =========================================================================
|
|
1275
|
+
/**
|
|
1276
|
+
* Generate a document from a template with variable values.
|
|
1277
|
+
*
|
|
1278
|
+
* @param templateId - Document template UUID.
|
|
1279
|
+
* @param body - Variables to fill in the template.
|
|
1280
|
+
* @returns URL to the generated document.
|
|
1281
|
+
*
|
|
1282
|
+
* @example
|
|
1283
|
+
* ```ts
|
|
1284
|
+
* const { url } = await client.skills.generateDocumentTemplate("template-uuid", {
|
|
1285
|
+
* variables: { name: "John", date: "2025-01-01" }
|
|
1286
|
+
* });
|
|
1287
|
+
* console.log("Generated document:", url);
|
|
1288
|
+
* ```
|
|
1289
|
+
*/
|
|
1290
|
+
async generateDocumentTemplate(templateId, body) {
|
|
1291
|
+
return this.http.request(
|
|
1292
|
+
"POST",
|
|
1293
|
+
`/skills/document-templates/${templateId}/generate`,
|
|
1294
|
+
{ body }
|
|
1295
|
+
);
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Execute an AI task with input and get the output.
|
|
1299
|
+
*
|
|
1300
|
+
* @param taskId - AI Task UUID.
|
|
1301
|
+
* @param body - Input to the task.
|
|
1302
|
+
* @returns Task output and output type.
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* ```ts
|
|
1306
|
+
* const { output, outputType } = await client.skills.executeTask("task-uuid", {
|
|
1307
|
+
* input: "Summarize this document"
|
|
1308
|
+
* });
|
|
1309
|
+
* console.log(`Output (${outputType}):`, output);
|
|
1310
|
+
* ```
|
|
1311
|
+
*/
|
|
1312
|
+
async executeTask(taskId, body) {
|
|
1313
|
+
return this.http.request("POST", `/skills/tasks/${taskId}/execute`, {
|
|
1314
|
+
body
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
// ===== COLLECTION MANAGEMENT (Enhanced) =====
|
|
1318
|
+
async listCollectionDocuments(collectionId, params) {
|
|
1319
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
1320
|
+
"GET",
|
|
1321
|
+
`/skills/collections/${collectionId}/documents`,
|
|
1322
|
+
{
|
|
1323
|
+
query: params
|
|
1324
|
+
}
|
|
1325
|
+
);
|
|
1326
|
+
return { data, meta };
|
|
1327
|
+
}
|
|
1328
|
+
async removeCollectionDocument(collectionId, documentId) {
|
|
1329
|
+
return this.http.request(
|
|
1330
|
+
"DELETE",
|
|
1331
|
+
`/skills/collections/${collectionId}/documents/${documentId}`
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
async getCollectionStatistics(collectionId) {
|
|
1335
|
+
return this.http.request("GET", `/skills/collections/${collectionId}/statistics`);
|
|
1336
|
+
}
|
|
1337
|
+
async searchCollection(collectionId, body) {
|
|
1338
|
+
return this.http.request("POST", `/skills/collections/${collectionId}/search`, { body });
|
|
1339
|
+
}
|
|
1340
|
+
async searchMultipleCollections(body) {
|
|
1341
|
+
return this.http.request("POST", "/skills/collections/search", { body });
|
|
1342
|
+
}
|
|
1343
|
+
async updateCollection(collectionId, body) {
|
|
1344
|
+
return this.http.request("PATCH", `/skills/collections/${collectionId}`, { body });
|
|
1345
|
+
}
|
|
1346
|
+
async deleteCollection(collectionId) {
|
|
1347
|
+
return this.http.request("DELETE", `/skills/collections/${collectionId}`);
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
// src/resources/tickets.ts
|
|
1352
|
+
var TicketsResource = class extends BaseResource {
|
|
1353
|
+
constructor(http) {
|
|
1354
|
+
super(http);
|
|
1355
|
+
}
|
|
1356
|
+
async list(params) {
|
|
1357
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/tickets", {
|
|
1358
|
+
query: params
|
|
1359
|
+
});
|
|
1360
|
+
return { data, meta };
|
|
1361
|
+
}
|
|
1362
|
+
async get(ticketId) {
|
|
1363
|
+
return this.http.request("GET", `/tickets/${ticketId}`);
|
|
1364
|
+
}
|
|
1365
|
+
async create(body) {
|
|
1366
|
+
return this.http.request("POST", "/tickets", { body });
|
|
1367
|
+
}
|
|
1368
|
+
async update(ticketId, body) {
|
|
1369
|
+
return this.http.request("PATCH", `/tickets/${ticketId}`, { body });
|
|
1370
|
+
}
|
|
1371
|
+
async addComment(ticketId, body) {
|
|
1372
|
+
return this.http.request("POST", `/tickets/${ticketId}/comments`, { body });
|
|
1373
|
+
}
|
|
1374
|
+
async listComments(ticketId) {
|
|
1375
|
+
return this.http.request("GET", `/tickets/${ticketId}/comments`);
|
|
1376
|
+
}
|
|
1377
|
+
async uploadAttachment(ticketId, file) {
|
|
1378
|
+
const formData = new FormData();
|
|
1379
|
+
formData.append("file", file);
|
|
1380
|
+
return this.http.request("POST", `/tickets/${ticketId}/attachments`, {
|
|
1381
|
+
body: formData
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
async listAttachments(ticketId) {
|
|
1385
|
+
return this.http.request(
|
|
1386
|
+
"GET",
|
|
1387
|
+
`/tickets/${ticketId}/attachments`
|
|
1388
|
+
);
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
// src/resources/tool-connection.ts
|
|
1393
|
+
var ToolConnectionResource = class extends BaseResource {
|
|
1394
|
+
/**
|
|
1395
|
+
* Initiate a tool connection via OAuth or create an HTTP credential directly.
|
|
1396
|
+
*
|
|
1397
|
+
* For OAuth, returns an `authorizationUrl` the user must visit, plus a
|
|
1398
|
+
* `handshakeId` for polling. For HTTP, creates the credential immediately.
|
|
1399
|
+
*
|
|
1400
|
+
* @param toolId - Marketplace tool ID.
|
|
1401
|
+
* @param body - Connection type and parameters.
|
|
1402
|
+
* @returns OAuth authorization details or the created HTTP credential.
|
|
1403
|
+
*/
|
|
1404
|
+
async connect(toolId, body) {
|
|
1405
|
+
return this.http.request(
|
|
1406
|
+
"POST",
|
|
1407
|
+
`/tools/${toolId}/connect`,
|
|
1408
|
+
{ body }
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Poll the status of an OAuth handshake.
|
|
1413
|
+
*
|
|
1414
|
+
* @param handshakeId - Handshake UUID returned by `connect()`.
|
|
1415
|
+
* @returns Current handshake status and connection ID if completed.
|
|
1416
|
+
*/
|
|
1417
|
+
async pollStatus(handshakeId) {
|
|
1418
|
+
return this.http.request(
|
|
1419
|
+
"GET",
|
|
1420
|
+
`/tools/connect/${handshakeId}/status`
|
|
1421
|
+
);
|
|
1422
|
+
}
|
|
1423
|
+
/**
|
|
1424
|
+
* Wait for an OAuth handshake to complete by polling at regular intervals.
|
|
1425
|
+
*
|
|
1426
|
+
* Resolves when the status changes from `PENDING` to any terminal state
|
|
1427
|
+
* (`COMPLETED`, `FAILED`, or `EXPIRED`), or when the timeout is reached.
|
|
1428
|
+
*
|
|
1429
|
+
* @param handshakeId - Handshake UUID returned by `connect()`.
|
|
1430
|
+
* @param opts - Optional timeout (default 5 min) and polling interval (default 2 s).
|
|
1431
|
+
* @returns Final handshake status.
|
|
1432
|
+
*/
|
|
1433
|
+
async waitForConnection(handshakeId, opts) {
|
|
1434
|
+
const timeout = opts?.timeoutMs ?? 5 * 60 * 1e3;
|
|
1435
|
+
const interval = opts?.intervalMs ?? 2e3;
|
|
1436
|
+
const deadline = Date.now() + timeout;
|
|
1437
|
+
while (Date.now() < deadline) {
|
|
1438
|
+
const status = await this.pollStatus(handshakeId);
|
|
1439
|
+
if (status.status !== "PENDING") return status;
|
|
1440
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
1441
|
+
}
|
|
1442
|
+
return {
|
|
1443
|
+
status: "EXPIRED",
|
|
1444
|
+
connectionId: null,
|
|
1445
|
+
errorMessage: "Polling timed out",
|
|
1446
|
+
expiresAt: null
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* Delete a credential (connected account) from a tool.
|
|
1451
|
+
*
|
|
1452
|
+
* @param toolId - Marketplace tool ID.
|
|
1453
|
+
* @param credentialId - Credential UUID to delete.
|
|
1454
|
+
*/
|
|
1455
|
+
async deleteCredential(toolId, credentialId) {
|
|
1456
|
+
await this.http.request("DELETE", `/tools/${toolId}/credentials/${credentialId}`);
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
// src/resources/tool-discovery.ts
|
|
1461
|
+
var ToolDiscoveryResource = class extends BaseResource {
|
|
1462
|
+
/**
|
|
1463
|
+
* Search marketplace tools by keyword with optional category and type filters.
|
|
1464
|
+
* Uses Typesense full-text search with SQL fallback.
|
|
1465
|
+
*
|
|
1466
|
+
* @param params - Search query and filters.
|
|
1467
|
+
* @returns Matching tools, category facets, and total count.
|
|
1468
|
+
*
|
|
1469
|
+
* @example
|
|
1470
|
+
* ```ts
|
|
1471
|
+
* const result = await client.tools.search({ q: "gmail", limit: 5 });
|
|
1472
|
+
* console.log(`Found ${result.total} tools`);
|
|
1473
|
+
* for (const tool of result.tools) {
|
|
1474
|
+
* console.log(`${tool.name} (${tool.type}): ${tool.description}`);
|
|
1475
|
+
* }
|
|
1476
|
+
* ```
|
|
1477
|
+
*/
|
|
1478
|
+
async search(params) {
|
|
1479
|
+
return this.http.request("GET", "/tools/search", {
|
|
1480
|
+
query: params
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Get full marketplace tool detail including actions and their parameter schemas.
|
|
1485
|
+
*
|
|
1486
|
+
* For Pipedream tools, each action's parameters are enriched with the full
|
|
1487
|
+
* component definition including types, descriptions, defaults, and
|
|
1488
|
+
* `remoteOptions` flags indicating which fields need dynamic option resolution.
|
|
1489
|
+
*
|
|
1490
|
+
* @param toolId - Marketplace tool ID (from search results).
|
|
1491
|
+
* @param params - Optional pagination/filter params for actions.
|
|
1492
|
+
* @returns Full tool detail with actions and parameter schemas.
|
|
1493
|
+
*
|
|
1494
|
+
* @example
|
|
1495
|
+
* ```ts
|
|
1496
|
+
* // Get all actions
|
|
1497
|
+
* const detail = await client.tools.get("tool-uuid");
|
|
1498
|
+
* console.log(`${detail.totalActions} total actions`);
|
|
1499
|
+
*
|
|
1500
|
+
* // Paginate actions
|
|
1501
|
+
* const page = await client.tools.get("tool-uuid", { actionsLimit: 10, actionsOffset: 20 });
|
|
1502
|
+
*
|
|
1503
|
+
* // Search for a specific action
|
|
1504
|
+
* const filtered = await client.tools.get("tool-uuid", { actionsSearch: "get-values" });
|
|
1505
|
+
* ```
|
|
1506
|
+
*/
|
|
1507
|
+
async get(toolId, params) {
|
|
1508
|
+
return this.http.request("GET", `/tools/${toolId}`, {
|
|
1509
|
+
query: params
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
/**
|
|
1513
|
+
* List existing credentials (connected accounts) for a marketplace tool.
|
|
1514
|
+
*
|
|
1515
|
+
* Credentials represent authenticated connections (e.g. a Gmail OAuth token).
|
|
1516
|
+
* They are read-only through this endpoint — users create credentials via the
|
|
1517
|
+
* Nexus dashboard. Use the credential `id` when calling `resolveOptions()` or
|
|
1518
|
+
* when configuring an agent tool.
|
|
1519
|
+
*
|
|
1520
|
+
* @param toolId - Marketplace tool ID.
|
|
1521
|
+
* @returns List of credentials for this tool in the organization.
|
|
1522
|
+
*
|
|
1523
|
+
* @example
|
|
1524
|
+
* ```ts
|
|
1525
|
+
* const { credentials } = await client.tools.credentials("tool-uuid");
|
|
1526
|
+
* if (credentials.length === 0) {
|
|
1527
|
+
* console.log("No credentials — user must connect account in dashboard first");
|
|
1528
|
+
* }
|
|
1529
|
+
* ```
|
|
1530
|
+
*/
|
|
1531
|
+
async credentials(toolId) {
|
|
1532
|
+
return this.http.request("GET", `/tools/${toolId}/credentials`);
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Resolve dynamic dropdown options for a tool action parameter.
|
|
1536
|
+
*
|
|
1537
|
+
* Some parameters (those with `remoteOptions: true` in the tool detail) have
|
|
1538
|
+
* values that depend on the user's connected account — for example, a list of
|
|
1539
|
+
* Gmail labels or Slack channels. This method fetches those options at runtime.
|
|
1540
|
+
*
|
|
1541
|
+
* For cascading dependencies (e.g. "select folder" → "select file in folder"),
|
|
1542
|
+
* pass previously selected values in `configuredProps`.
|
|
1543
|
+
*
|
|
1544
|
+
* @param toolId - Marketplace tool ID.
|
|
1545
|
+
* @param body - Component ID, parameter name, credential, and current values.
|
|
1546
|
+
* @returns Available options for the specified parameter.
|
|
1547
|
+
*
|
|
1548
|
+
* @example
|
|
1549
|
+
* ```ts
|
|
1550
|
+
* const { options } = await client.tools.resolveOptions("tool-uuid", {
|
|
1551
|
+
* componentId: "gmail-send-email", // from ToolAction.key
|
|
1552
|
+
* propName: "label", // from ToolActionParameter.name
|
|
1553
|
+
* credentialId: "cred-uuid", // from ToolCredential.id
|
|
1554
|
+
* configuredProps: {} // previously selected values
|
|
1555
|
+
* });
|
|
1556
|
+
* for (const opt of options) {
|
|
1557
|
+
* console.log(`${opt.label}: ${opt.value}`);
|
|
1558
|
+
* }
|
|
1559
|
+
* ```
|
|
1560
|
+
*/
|
|
1561
|
+
async resolveOptions(toolId, body) {
|
|
1562
|
+
return this.http.request(
|
|
1563
|
+
"POST",
|
|
1564
|
+
`/tools/${toolId}/resolve-options`,
|
|
1565
|
+
{ body }
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* List the organization's skills — workflows, AI tasks, and collections.
|
|
1570
|
+
*
|
|
1571
|
+
* Skills are org-owned assets that can be attached to agents as tool
|
|
1572
|
+
* configurations of type WORKFLOW, TASK, or COLLECTION (as opposed to
|
|
1573
|
+
* marketplace PLUGIN tools).
|
|
1574
|
+
*
|
|
1575
|
+
* @param params - Optional type filter, search, and pagination.
|
|
1576
|
+
* @returns Matching skills and total count.
|
|
1577
|
+
*
|
|
1578
|
+
* @example
|
|
1579
|
+
* ```ts
|
|
1580
|
+
* // List all workflows
|
|
1581
|
+
* const { skills, total } = await client.tools.skills({ type: "WORKFLOW" });
|
|
1582
|
+
* console.log(`${total} workflows found`);
|
|
1583
|
+
*
|
|
1584
|
+
* // Search across all skill types
|
|
1585
|
+
* const result = await client.tools.skills({ search: "onboarding", limit: 10 });
|
|
1586
|
+
* ```
|
|
1587
|
+
*/
|
|
1588
|
+
async skills(params) {
|
|
1589
|
+
return this.http.request("GET", "/tools/skills", {
|
|
1590
|
+
query: params
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Test-execute a configured agent tool with sample input.
|
|
1595
|
+
*
|
|
1596
|
+
* This runs the tool using its saved configuration (action, credentials,
|
|
1597
|
+
* parameter setup) and returns the execution result. Use this to verify a
|
|
1598
|
+
* tool is correctly configured before deploying the agent.
|
|
1599
|
+
*
|
|
1600
|
+
* @param agentId - Agent UUID that owns the tool config.
|
|
1601
|
+
* @param toolConfigId - Agent tool configuration UUID (from `client.agents.tools.list()`).
|
|
1602
|
+
* @param body - Sample input values to pass to the tool.
|
|
1603
|
+
* @returns Execution result with status, output, and timing.
|
|
1604
|
+
*
|
|
1605
|
+
* @example
|
|
1606
|
+
* ```ts
|
|
1607
|
+
* const result = await client.tools.test("agent-uuid", "tool-config-uuid", {
|
|
1608
|
+
* input: { to: "test@example.com", subject: "Hello", body: "Test email" }
|
|
1609
|
+
* });
|
|
1610
|
+
* if (result.status === "success") {
|
|
1611
|
+
* console.log(`Executed in ${result.executionTimeMs}ms`, result.output);
|
|
1612
|
+
* } else {
|
|
1613
|
+
* console.error(`Tool error: ${result.error}`);
|
|
1614
|
+
* }
|
|
1615
|
+
* ```
|
|
1616
|
+
*/
|
|
1617
|
+
async test(agentId, toolConfigId, body) {
|
|
1618
|
+
return this.http.request(
|
|
1619
|
+
"POST",
|
|
1620
|
+
`/agents/${agentId}/tools/${toolConfigId}/test`,
|
|
1621
|
+
{ body }
|
|
1622
|
+
);
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
|
|
1626
|
+
// src/resources/workflow-executions.ts
|
|
1627
|
+
var WorkflowExecutionsResource = class extends BaseResource {
|
|
1628
|
+
async list(params) {
|
|
1629
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/workflows/executions", {
|
|
1630
|
+
query: params
|
|
1631
|
+
});
|
|
1632
|
+
return { data, meta };
|
|
1633
|
+
}
|
|
1634
|
+
async listByWorkflow(workflowId, params) {
|
|
1635
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
1636
|
+
"GET",
|
|
1637
|
+
`/workflows/${workflowId}/executions`,
|
|
1638
|
+
{
|
|
1639
|
+
query: params
|
|
1640
|
+
}
|
|
1641
|
+
);
|
|
1642
|
+
return { data, meta };
|
|
1643
|
+
}
|
|
1644
|
+
async get(executionId) {
|
|
1645
|
+
return this.http.request("GET", `/workflows/executions/${executionId}`);
|
|
1646
|
+
}
|
|
1647
|
+
async getGraph(executionId) {
|
|
1648
|
+
return this.http.request("GET", `/workflows/executions/${executionId}/graph`);
|
|
1649
|
+
}
|
|
1650
|
+
async getNodeResult(executionId, nodeId) {
|
|
1651
|
+
return this.http.request("GET", `/workflows/executions/${executionId}/nodes/${nodeId}`);
|
|
1652
|
+
}
|
|
1653
|
+
async getOutput(executionId) {
|
|
1654
|
+
return this.http.request("GET", `/workflows/executions/${executionId}/output`);
|
|
1655
|
+
}
|
|
1656
|
+
async retryNode(executionId, nodeId) {
|
|
1657
|
+
return this.http.request(
|
|
1658
|
+
"POST",
|
|
1659
|
+
`/workflows/executions/${executionId}/nodes/${nodeId}/retry`
|
|
1660
|
+
);
|
|
1661
|
+
}
|
|
1662
|
+
async export(executionId) {
|
|
1663
|
+
return this.http.request("POST", `/workflows/executions/${executionId}/export`);
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
|
|
1667
|
+
// src/resources/workflows.ts
|
|
1668
|
+
var WorkflowsResource = class extends BaseResource {
|
|
1669
|
+
// =========================================================================
|
|
1670
|
+
// CRUD
|
|
1671
|
+
// =========================================================================
|
|
1672
|
+
/**
|
|
1673
|
+
* List workflows with optional filtering and pagination.
|
|
1674
|
+
*
|
|
1675
|
+
* @param params - Optional status filter, search, and pagination.
|
|
1676
|
+
* @returns Paginated list of workflow summaries.
|
|
1677
|
+
*/
|
|
1678
|
+
async list(params) {
|
|
1679
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/workflows", {
|
|
1680
|
+
query: params
|
|
1681
|
+
});
|
|
1682
|
+
return { data, meta };
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Create a new workflow.
|
|
1686
|
+
*
|
|
1687
|
+
* @param body - Workflow name and optional description.
|
|
1688
|
+
* @returns The created workflow detail.
|
|
1689
|
+
*/
|
|
1690
|
+
async create(body) {
|
|
1691
|
+
return this.http.request("POST", "/workflows", { body });
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Get detailed information about a specific workflow, including nodes and edges.
|
|
1695
|
+
*
|
|
1696
|
+
* @param workflowId - Workflow UUID.
|
|
1697
|
+
* @returns Full workflow detail.
|
|
1698
|
+
*/
|
|
1699
|
+
async get(workflowId) {
|
|
1700
|
+
return this.http.request("GET", `/workflows/${workflowId}`);
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Update an existing workflow's properties. Only provided fields are updated.
|
|
1704
|
+
*
|
|
1705
|
+
* @param workflowId - Workflow UUID.
|
|
1706
|
+
* @param body - Fields to update.
|
|
1707
|
+
* @returns The updated workflow detail.
|
|
1708
|
+
*/
|
|
1709
|
+
async update(workflowId, body) {
|
|
1710
|
+
return this.http.request("PATCH", `/workflows/${workflowId}`, { body });
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Permanently delete a workflow and all its nodes, edges, and executions.
|
|
1714
|
+
*
|
|
1715
|
+
* @param workflowId - Workflow UUID.
|
|
1716
|
+
* @returns Confirmation with the deleted workflow's ID.
|
|
1717
|
+
*/
|
|
1718
|
+
async delete(workflowId) {
|
|
1719
|
+
return this.http.request("DELETE", `/workflows/${workflowId}`);
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Create a copy of an existing workflow.
|
|
1723
|
+
*
|
|
1724
|
+
* @param workflowId - Workflow UUID to duplicate.
|
|
1725
|
+
* @returns The newly created workflow detail.
|
|
1726
|
+
*/
|
|
1727
|
+
async duplicate(workflowId) {
|
|
1728
|
+
return this.http.request("POST", `/workflows/${workflowId}/duplicate`);
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Publish a workflow, making it available for execution.
|
|
1732
|
+
*
|
|
1733
|
+
* @param workflowId - Workflow UUID.
|
|
1734
|
+
* @returns Publish confirmation with updated status.
|
|
1735
|
+
*/
|
|
1736
|
+
async publish(workflowId) {
|
|
1737
|
+
return this.http.request("POST", `/workflows/${workflowId}/publish`);
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* Unpublish a workflow, reverting it to draft status.
|
|
1741
|
+
*
|
|
1742
|
+
* @param workflowId - Workflow UUID.
|
|
1743
|
+
* @returns Unpublish confirmation with updated status.
|
|
1744
|
+
*/
|
|
1745
|
+
async unpublish(workflowId) {
|
|
1746
|
+
return this.http.request("POST", `/workflows/${workflowId}/unpublish`);
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Upload an icon image for a workflow.
|
|
1750
|
+
*
|
|
1751
|
+
* @param workflowId - Workflow UUID.
|
|
1752
|
+
* @param file - Image file as a Blob or File.
|
|
1753
|
+
* @returns URL of the uploaded icon.
|
|
1754
|
+
*/
|
|
1755
|
+
async uploadIcon(workflowId, file) {
|
|
1756
|
+
const formData = new FormData();
|
|
1757
|
+
formData.append("file", file);
|
|
1758
|
+
return this.http.request("POST", `/workflows/${workflowId}/icon`, {
|
|
1759
|
+
body: formData
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
// =========================================================================
|
|
1763
|
+
// BUILDER (Node Types)
|
|
1764
|
+
// =========================================================================
|
|
1765
|
+
/**
|
|
1766
|
+
* List all available node types for the workflow builder.
|
|
1767
|
+
*
|
|
1768
|
+
* @returns Array of node type summaries.
|
|
1769
|
+
*/
|
|
1770
|
+
async listNodeTypes() {
|
|
1771
|
+
return this.http.request("GET", "/workflows/node-types");
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* Get the full schema for a specific node type, including fields and connection rules.
|
|
1775
|
+
*
|
|
1776
|
+
* @param nodeType - Node type identifier.
|
|
1777
|
+
* @returns Node type schema with fields, configuration steps, and defaults.
|
|
1778
|
+
*/
|
|
1779
|
+
async getNodeTypeSchema(nodeType) {
|
|
1780
|
+
return this.http.request("GET", `/workflows/node-types/${nodeType}`);
|
|
1781
|
+
}
|
|
1782
|
+
// =========================================================================
|
|
1783
|
+
// NODES
|
|
1784
|
+
// =========================================================================
|
|
1785
|
+
/**
|
|
1786
|
+
* Create a new node in a workflow.
|
|
1787
|
+
*
|
|
1788
|
+
* @param workflowId - Workflow UUID.
|
|
1789
|
+
* @param body - Node type, position, data, and optional parent.
|
|
1790
|
+
* @returns The created node.
|
|
1791
|
+
*/
|
|
1792
|
+
async createNode(workflowId, body) {
|
|
1793
|
+
return this.http.request("POST", `/workflows/${workflowId}/nodes`, { body });
|
|
1794
|
+
}
|
|
1795
|
+
/**
|
|
1796
|
+
* Get a specific node within a workflow.
|
|
1797
|
+
*
|
|
1798
|
+
* @param workflowId - Workflow UUID.
|
|
1799
|
+
* @param nodeId - Node UUID.
|
|
1800
|
+
* @returns The node detail.
|
|
1801
|
+
*/
|
|
1802
|
+
async getNode(workflowId, nodeId) {
|
|
1803
|
+
return this.http.request("GET", `/workflows/${workflowId}/nodes/${nodeId}`);
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Update a node's data. Only the `data` field is replaced.
|
|
1807
|
+
*
|
|
1808
|
+
* @param workflowId - Workflow UUID.
|
|
1809
|
+
* @param nodeId - Node UUID.
|
|
1810
|
+
* @param body - New data for the node.
|
|
1811
|
+
* @returns The updated node.
|
|
1812
|
+
*/
|
|
1813
|
+
async updateNode(workflowId, nodeId, body) {
|
|
1814
|
+
return this.http.request("PATCH", `/workflows/${workflowId}/nodes/${nodeId}`, {
|
|
1815
|
+
body
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Delete a node from a workflow. Connected edges are also removed.
|
|
1820
|
+
*
|
|
1821
|
+
* @param workflowId - Workflow UUID.
|
|
1822
|
+
* @param nodeId - Node UUID.
|
|
1823
|
+
* @returns Confirmation with the deleted node's ID.
|
|
1824
|
+
*/
|
|
1825
|
+
async deleteNode(workflowId, nodeId) {
|
|
1826
|
+
return this.http.request("DELETE", `/workflows/${workflowId}/nodes/${nodeId}`);
|
|
1827
|
+
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Reload dynamic properties for a node (e.g. after selecting a tool or action).
|
|
1830
|
+
*
|
|
1831
|
+
* @param workflowId - Workflow UUID.
|
|
1832
|
+
* @param nodeId - Node UUID.
|
|
1833
|
+
* @param body - Currently configured props and optional dynamic props ID.
|
|
1834
|
+
* @returns Updated parameters setup and any errors.
|
|
1835
|
+
*/
|
|
1836
|
+
async reloadProps(workflowId, nodeId, body) {
|
|
1837
|
+
return this.http.request(
|
|
1838
|
+
"POST",
|
|
1839
|
+
`/workflows/${workflowId}/nodes/${nodeId}/reload-props`,
|
|
1840
|
+
{ body }
|
|
1841
|
+
);
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* Replace the trigger node of a workflow with a different trigger type.
|
|
1845
|
+
*
|
|
1846
|
+
* @param workflowId - Workflow UUID.
|
|
1847
|
+
* @param body - New trigger type.
|
|
1848
|
+
* @returns The updated workflow detail.
|
|
1849
|
+
*/
|
|
1850
|
+
async replaceTrigger(workflowId, body) {
|
|
1851
|
+
return this.http.request("PUT", `/workflows/${workflowId}/trigger`, { body });
|
|
1852
|
+
}
|
|
1853
|
+
// =========================================================================
|
|
1854
|
+
// BRANCHES
|
|
1855
|
+
// =========================================================================
|
|
1856
|
+
/**
|
|
1857
|
+
* List branches on a conditional or router node.
|
|
1858
|
+
*
|
|
1859
|
+
* @param workflowId - Workflow UUID.
|
|
1860
|
+
* @param nodeId - Node UUID.
|
|
1861
|
+
* @returns Array of branches.
|
|
1862
|
+
*/
|
|
1863
|
+
async listBranches(workflowId, nodeId) {
|
|
1864
|
+
return this.http.request("GET", `/workflows/${workflowId}/nodes/${nodeId}/branches`);
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Create a new branch on a conditional or router node.
|
|
1868
|
+
*
|
|
1869
|
+
* @param workflowId - Workflow UUID.
|
|
1870
|
+
* @param nodeId - Node UUID.
|
|
1871
|
+
* @param body - Branch name and optional description.
|
|
1872
|
+
* @returns The created branch.
|
|
1873
|
+
*/
|
|
1874
|
+
async createBranch(workflowId, nodeId, body) {
|
|
1875
|
+
return this.http.request("POST", `/workflows/${workflowId}/nodes/${nodeId}/branches`, {
|
|
1876
|
+
body
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Update a branch on a node.
|
|
1881
|
+
*
|
|
1882
|
+
* @param workflowId - Workflow UUID.
|
|
1883
|
+
* @param nodeId - Node UUID.
|
|
1884
|
+
* @param branchId - Branch UUID.
|
|
1885
|
+
* @param body - Fields to update.
|
|
1886
|
+
* @returns The updated branch.
|
|
1887
|
+
*/
|
|
1888
|
+
async updateBranch(workflowId, nodeId, branchId, body) {
|
|
1889
|
+
return this.http.request(
|
|
1890
|
+
"PATCH",
|
|
1891
|
+
`/workflows/${workflowId}/nodes/${nodeId}/branches/${branchId}`,
|
|
1892
|
+
{ body }
|
|
1893
|
+
);
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* Delete a branch from a node.
|
|
1897
|
+
*
|
|
1898
|
+
* @param workflowId - Workflow UUID.
|
|
1899
|
+
* @param nodeId - Node UUID.
|
|
1900
|
+
* @param branchId - Branch UUID.
|
|
1901
|
+
* @returns Confirmation with the deleted branch's ID.
|
|
1902
|
+
*/
|
|
1903
|
+
async deleteBranch(workflowId, nodeId, branchId) {
|
|
1904
|
+
return this.http.request(
|
|
1905
|
+
"DELETE",
|
|
1906
|
+
`/workflows/${workflowId}/nodes/${nodeId}/branches/${branchId}`
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1909
|
+
// =========================================================================
|
|
1910
|
+
// EDGES
|
|
1911
|
+
// =========================================================================
|
|
1912
|
+
/**
|
|
1913
|
+
* Create an edge between two nodes in a workflow.
|
|
1914
|
+
*
|
|
1915
|
+
* @param workflowId - Workflow UUID.
|
|
1916
|
+
* @param body - Source node, target node, optional handle and type.
|
|
1917
|
+
* @returns The created edge.
|
|
1918
|
+
*/
|
|
1919
|
+
async createEdge(workflowId, body) {
|
|
1920
|
+
return this.http.request("POST", `/workflows/${workflowId}/edges`, { body });
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* Delete an edge from a workflow.
|
|
1924
|
+
*
|
|
1925
|
+
* @param workflowId - Workflow UUID.
|
|
1926
|
+
* @param edgeId - Edge UUID.
|
|
1927
|
+
* @returns Confirmation with the deleted edge's ID.
|
|
1928
|
+
*/
|
|
1929
|
+
async deleteEdge(workflowId, edgeId) {
|
|
1930
|
+
return this.http.request("DELETE", `/workflows/${workflowId}/edges/${edgeId}`);
|
|
1931
|
+
}
|
|
1932
|
+
// =========================================================================
|
|
1933
|
+
// OVERVIEW
|
|
1934
|
+
// =========================================================================
|
|
1935
|
+
/**
|
|
1936
|
+
* Get a high-level overview of a workflow with node summaries.
|
|
1937
|
+
*
|
|
1938
|
+
* @param workflowId - Workflow UUID.
|
|
1939
|
+
* @returns Workflow overview with node labels and config statuses.
|
|
1940
|
+
*/
|
|
1941
|
+
async getOverview(workflowId) {
|
|
1942
|
+
return this.http.request("GET", `/workflows/${workflowId}/overview`);
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* Auto-layout the nodes in a workflow graph.
|
|
1946
|
+
*
|
|
1947
|
+
* @param workflowId - Workflow UUID.
|
|
1948
|
+
* @returns The updated workflow detail with new node positions.
|
|
1949
|
+
*/
|
|
1950
|
+
async layout(workflowId) {
|
|
1951
|
+
return this.http.request("POST", `/workflows/${workflowId}/layout`);
|
|
1952
|
+
}
|
|
1953
|
+
/**
|
|
1954
|
+
* Get variables available to a specific node from upstream nodes.
|
|
1955
|
+
*
|
|
1956
|
+
* @param workflowId - Workflow UUID.
|
|
1957
|
+
* @param nodeId - Node UUID.
|
|
1958
|
+
* @returns Array of available variables grouped by source node.
|
|
1959
|
+
*/
|
|
1960
|
+
async getAvailableVariables(workflowId, nodeId) {
|
|
1961
|
+
return this.http.request(
|
|
1962
|
+
"GET",
|
|
1963
|
+
`/workflows/${workflowId}/nodes/${nodeId}/available-variables`
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Get the output format definition for a specific node.
|
|
1968
|
+
*
|
|
1969
|
+
* @param workflowId - Workflow UUID.
|
|
1970
|
+
* @param nodeId - Node UUID.
|
|
1971
|
+
* @returns Output format with source indicator.
|
|
1972
|
+
*/
|
|
1973
|
+
async getOutputFormat(workflowId, nodeId) {
|
|
1974
|
+
return this.http.request(
|
|
1975
|
+
"GET",
|
|
1976
|
+
`/workflows/${workflowId}/nodes/${nodeId}/output-format`
|
|
1977
|
+
);
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
1980
|
+
* Validate a workflow for completeness and correctness.
|
|
1981
|
+
*
|
|
1982
|
+
* @param workflowId - Workflow UUID.
|
|
1983
|
+
* @returns Validation report with node issues and graph issues.
|
|
1984
|
+
*/
|
|
1985
|
+
async validate(workflowId) {
|
|
1986
|
+
return this.http.request("GET", `/workflows/${workflowId}/validate`);
|
|
1987
|
+
}
|
|
1988
|
+
// =========================================================================
|
|
1989
|
+
// TESTING
|
|
1990
|
+
// =========================================================================
|
|
1991
|
+
/**
|
|
1992
|
+
* Test-execute a single node with optional input.
|
|
1993
|
+
*
|
|
1994
|
+
* @param workflowId - Workflow UUID.
|
|
1995
|
+
* @param nodeId - Node UUID.
|
|
1996
|
+
* @param body - Optional input data for the node.
|
|
1997
|
+
* @returns Execution ID for polling status.
|
|
1998
|
+
*/
|
|
1999
|
+
async testNode(workflowId, nodeId, body) {
|
|
2000
|
+
return this.http.request("POST", `/workflows/${workflowId}/nodes/${nodeId}/test`, {
|
|
2001
|
+
body
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* Test-execute an entire workflow with optional trigger data.
|
|
2006
|
+
*
|
|
2007
|
+
* @param workflowId - Workflow UUID.
|
|
2008
|
+
* @param body - Optional trigger data to start the workflow.
|
|
2009
|
+
* @returns Execution ID for polling status.
|
|
2010
|
+
*/
|
|
2011
|
+
async testWorkflow(workflowId, body) {
|
|
2012
|
+
return this.http.request("POST", `/workflows/${workflowId}/test`, { body });
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* Get the status of a workflow execution.
|
|
2016
|
+
*
|
|
2017
|
+
* @param workflowId - Workflow UUID.
|
|
2018
|
+
* @param executionId - Execution UUID.
|
|
2019
|
+
* @returns Execution status with per-node statuses.
|
|
2020
|
+
*/
|
|
2021
|
+
async getExecutionStatus(workflowId, executionId) {
|
|
2022
|
+
return this.http.request(
|
|
2023
|
+
"GET",
|
|
2024
|
+
`/workflows/${workflowId}/executions/${executionId}`
|
|
2025
|
+
);
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Get the execution result for a specific node within a workflow execution.
|
|
2029
|
+
*
|
|
2030
|
+
* @param workflowId - Workflow UUID.
|
|
2031
|
+
* @param executionId - Execution UUID.
|
|
2032
|
+
* @param nodeId - Node UUID.
|
|
2033
|
+
* @returns Node execution result with input, output, and logs.
|
|
2034
|
+
*/
|
|
2035
|
+
async getNodeExecutionResult(workflowId, executionId, nodeId) {
|
|
2036
|
+
return this.http.request(
|
|
2037
|
+
"GET",
|
|
2038
|
+
`/workflows/${workflowId}/executions/${executionId}/nodes/${nodeId}`
|
|
2039
|
+
);
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Stop a running workflow execution.
|
|
2043
|
+
*
|
|
2044
|
+
* @param workflowId - Workflow UUID.
|
|
2045
|
+
* @param executionId - Execution UUID.
|
|
2046
|
+
* @returns Updated execution status.
|
|
2047
|
+
*/
|
|
2048
|
+
async stopExecution(workflowId, executionId) {
|
|
2049
|
+
return this.http.request(
|
|
2050
|
+
"POST",
|
|
2051
|
+
`/workflows/${workflowId}/executions/${executionId}/stop`
|
|
2052
|
+
);
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2055
|
+
|
|
2056
|
+
// src/client.ts
|
|
2057
|
+
function getEnv(key) {
|
|
2058
|
+
try {
|
|
2059
|
+
return typeof process !== "undefined" ? process.env[key] : void 0;
|
|
2060
|
+
} catch {
|
|
2061
|
+
return void 0;
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
var NexusClient = class {
|
|
2065
|
+
constructor(opts = {}) {
|
|
2066
|
+
const apiKey = opts.apiKey ?? getEnv("NEXUS_API_KEY");
|
|
2067
|
+
if (!apiKey) {
|
|
2068
|
+
throw new NexusError(
|
|
2069
|
+
"No API key provided. Pass `apiKey` in options or set the NEXUS_API_KEY environment variable."
|
|
2070
|
+
);
|
|
2071
|
+
}
|
|
2072
|
+
const baseUrl = opts.baseUrl ?? getEnv("NEXUS_BASE_URL") ?? "https://api.nexusgpt.io";
|
|
2073
|
+
const http = new HttpClient({
|
|
2074
|
+
baseUrl,
|
|
2075
|
+
apiKey,
|
|
2076
|
+
fetch: opts.fetch,
|
|
2077
|
+
defaultHeaders: opts.defaultHeaders,
|
|
2078
|
+
timeout: opts.timeout
|
|
2079
|
+
});
|
|
2080
|
+
this.agents = new AgentsResource(http);
|
|
2081
|
+
this.documents = new DocumentsResource(http);
|
|
2082
|
+
this.folders = new FoldersResource(http);
|
|
2083
|
+
this.models = new ModelsResource(http);
|
|
2084
|
+
this.tools = new ToolDiscoveryResource(http);
|
|
2085
|
+
this.skills = new SkillsResource(http);
|
|
2086
|
+
this.workflows = new WorkflowsResource(http);
|
|
2087
|
+
this.toolConnection = new ToolConnectionResource(http);
|
|
2088
|
+
this.deployments = new DeploymentsResource(http);
|
|
2089
|
+
this.emulator = new EmulatorResource(http);
|
|
2090
|
+
this.deploymentFolders = new DeploymentFoldersResource(http);
|
|
2091
|
+
this.documentTemplateFolders = new DocumentTemplateFoldersResource(http);
|
|
2092
|
+
this.analytics = new AnalyticsResource(http);
|
|
2093
|
+
this.agentCollections = new AgentCollectionsResource(http);
|
|
2094
|
+
this.workflowExecutions = new WorkflowExecutionsResource(http);
|
|
2095
|
+
this.evaluations = new EvaluationsResource(http);
|
|
2096
|
+
this.cloudImports = new CloudImportsResource(http);
|
|
2097
|
+
this.promptAssistant = new PromptAssistantResource(http);
|
|
2098
|
+
this.tickets = new TicketsResource(http);
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
export {
|
|
2102
|
+
AgentCollectionsResource,
|
|
2103
|
+
AgentToolsResource,
|
|
2104
|
+
AgentsResource,
|
|
2105
|
+
AnalyticsResource,
|
|
2106
|
+
CloudImportsResource,
|
|
2107
|
+
DeploymentFoldersResource,
|
|
2108
|
+
DeploymentsResource,
|
|
2109
|
+
DocumentTemplateFoldersResource,
|
|
2110
|
+
DocumentsResource,
|
|
2111
|
+
EmulatorResource,
|
|
2112
|
+
EvaluationsResource,
|
|
2113
|
+
FoldersResource,
|
|
2114
|
+
HttpClient,
|
|
2115
|
+
ModelsResource,
|
|
2116
|
+
NexusApiError,
|
|
2117
|
+
NexusAuthenticationError,
|
|
2118
|
+
NexusClient,
|
|
2119
|
+
NexusConnectionError,
|
|
2120
|
+
NexusError,
|
|
2121
|
+
PromptAssistantResource,
|
|
2122
|
+
SkillsResource,
|
|
2123
|
+
TicketsResource,
|
|
2124
|
+
ToolConnectionResource,
|
|
2125
|
+
ToolDiscoveryResource,
|
|
2126
|
+
VersionsResource,
|
|
2127
|
+
WorkflowExecutionsResource,
|
|
2128
|
+
WorkflowsResource
|
|
2129
|
+
};
|