@agent-nexus/cli 0.1.8 → 0.1.11
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 +35 -31
- package/dist/index.js +2837 -160
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -166,7 +166,7 @@ var require_package = __commonJS({
|
|
|
166
166
|
"package.json"(exports2, module2) {
|
|
167
167
|
module2.exports = {
|
|
168
168
|
name: "@agent-nexus/cli",
|
|
169
|
-
version: "0.1.
|
|
169
|
+
version: "0.1.11",
|
|
170
170
|
description: "Official CLI for the Nexus AI agent platform.",
|
|
171
171
|
license: "MIT",
|
|
172
172
|
keywords: [
|
|
@@ -202,10 +202,10 @@ var require_package = __commonJS({
|
|
|
202
202
|
prepublishOnly: "pnpm run build"
|
|
203
203
|
},
|
|
204
204
|
dependencies: {
|
|
205
|
-
"@agent-nexus/sdk": "workspace:*",
|
|
206
205
|
commander: "^13.0.0"
|
|
207
206
|
},
|
|
208
207
|
devDependencies: {
|
|
208
|
+
"@agent-nexus/sdk": "workspace:*",
|
|
209
209
|
"@types/node": "24.6.2",
|
|
210
210
|
tsup: "^8.5.0",
|
|
211
211
|
typescript: "^5.8.3"
|
|
@@ -244,8 +244,2224 @@ function getBanner(version) {
|
|
|
244
244
|
return lines.join("\n");
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
//
|
|
248
|
-
var
|
|
247
|
+
// ../sdk/dist/index.mjs
|
|
248
|
+
var NexusError = class extends Error {
|
|
249
|
+
constructor(message) {
|
|
250
|
+
super(message);
|
|
251
|
+
this.name = "NexusError";
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
var NexusApiError = class extends NexusError {
|
|
255
|
+
constructor(code, message, status, details) {
|
|
256
|
+
super(message);
|
|
257
|
+
this.name = "NexusApiError";
|
|
258
|
+
this.code = code;
|
|
259
|
+
this.status = status;
|
|
260
|
+
this.details = details;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var NexusAuthenticationError = class extends NexusApiError {
|
|
264
|
+
constructor(message = "Invalid or missing API key") {
|
|
265
|
+
super("UNAUTHORIZED", message, 401);
|
|
266
|
+
this.name = "NexusAuthenticationError";
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
var NexusConnectionError = class extends NexusError {
|
|
270
|
+
constructor(message, cause) {
|
|
271
|
+
super(message);
|
|
272
|
+
this.name = "NexusConnectionError";
|
|
273
|
+
this.cause = cause;
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
var HttpClient = class {
|
|
277
|
+
constructor(opts) {
|
|
278
|
+
this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
|
|
279
|
+
this.apiKey = opts.apiKey;
|
|
280
|
+
this.fetchFn = opts.fetch ?? globalThis.fetch;
|
|
281
|
+
this.defaultHeaders = opts.defaultHeaders ?? {};
|
|
282
|
+
this.timeout = opts.timeout ?? 3e4;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Make a request and return the unwrapped `data` field.
|
|
286
|
+
*
|
|
287
|
+
* @param method - HTTP method (GET, POST, PATCH, DELETE).
|
|
288
|
+
* @param path - API path relative to `/api/public/v1` (e.g. `"/agents"`).
|
|
289
|
+
* @param opts - Optional body, query params, and headers.
|
|
290
|
+
* @returns The response `data` field, typed as `T`.
|
|
291
|
+
* @throws {NexusAuthenticationError} On 401 responses.
|
|
292
|
+
* @throws {NexusApiError} On other error responses.
|
|
293
|
+
* @throws {NexusConnectionError} On network failures or timeouts.
|
|
294
|
+
*/
|
|
295
|
+
async request(method, path5, opts = {}) {
|
|
296
|
+
const { data } = await this.requestWithMeta(method, path5, opts);
|
|
297
|
+
return data;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Make a request and return the raw response text.
|
|
301
|
+
* Useful for endpoints that return non-JSON responses (e.g. CSV exports).
|
|
302
|
+
*/
|
|
303
|
+
async requestRaw(method, path5, opts = {}) {
|
|
304
|
+
const url = new URL(`${this.baseUrl}/api/public/v1${path5}`);
|
|
305
|
+
if (opts.query) {
|
|
306
|
+
for (const [k, v] of Object.entries(opts.query)) {
|
|
307
|
+
if (v !== void 0) url.searchParams.set(k, String(v));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const headers = {
|
|
311
|
+
...this.defaultHeaders,
|
|
312
|
+
...opts.headers,
|
|
313
|
+
"api-key": this.apiKey
|
|
314
|
+
};
|
|
315
|
+
const controller = new AbortController();
|
|
316
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
317
|
+
let res;
|
|
318
|
+
try {
|
|
319
|
+
res = await this.fetchFn(url.toString(), { method, headers, signal: controller.signal });
|
|
320
|
+
} catch (err) {
|
|
321
|
+
clearTimeout(timer);
|
|
322
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
323
|
+
throw new NexusConnectionError(`Request timed out after ${this.timeout}ms`);
|
|
324
|
+
}
|
|
325
|
+
throw new NexusConnectionError(
|
|
326
|
+
err instanceof Error ? err.message : "Network request failed",
|
|
327
|
+
err instanceof Error ? err : void 0
|
|
328
|
+
);
|
|
329
|
+
} finally {
|
|
330
|
+
clearTimeout(timer);
|
|
331
|
+
}
|
|
332
|
+
if (!res.ok) {
|
|
333
|
+
if (res.status === 401) throw new NexusAuthenticationError();
|
|
334
|
+
throw new NexusApiError("HTTP_ERROR", `Request failed with status ${res.status}`, res.status);
|
|
335
|
+
}
|
|
336
|
+
return res.text();
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Make a request and return `{ data, meta }` (useful for paginated lists).
|
|
340
|
+
*
|
|
341
|
+
* @param method - HTTP method.
|
|
342
|
+
* @param path - API path relative to `/api/public/v1`.
|
|
343
|
+
* @param opts - Optional body, query params, and headers.
|
|
344
|
+
* @returns The response `data` and optional pagination `meta`.
|
|
345
|
+
* @throws {NexusAuthenticationError} On 401 responses.
|
|
346
|
+
* @throws {NexusApiError} On other error responses.
|
|
347
|
+
* @throws {NexusConnectionError} On network failures or timeouts.
|
|
348
|
+
*/
|
|
349
|
+
async requestWithMeta(method, path5, opts = {}) {
|
|
350
|
+
const url = new URL(`${this.baseUrl}/api/public/v1${path5}`);
|
|
351
|
+
if (opts.query) {
|
|
352
|
+
for (const [k, v] of Object.entries(opts.query)) {
|
|
353
|
+
if (v !== void 0) url.searchParams.set(k, String(v));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const headers = {
|
|
357
|
+
...this.defaultHeaders,
|
|
358
|
+
...opts.headers,
|
|
359
|
+
"api-key": this.apiKey,
|
|
360
|
+
Accept: "application/json"
|
|
361
|
+
};
|
|
362
|
+
const fetchInit = { method, headers };
|
|
363
|
+
if (opts.body !== void 0) {
|
|
364
|
+
if (opts.body instanceof FormData) {
|
|
365
|
+
fetchInit.body = opts.body;
|
|
366
|
+
} else {
|
|
367
|
+
headers["Content-Type"] = "application/json";
|
|
368
|
+
fetchInit.body = JSON.stringify(opts.body);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const controller = new AbortController();
|
|
372
|
+
fetchInit.signal = controller.signal;
|
|
373
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
374
|
+
let res;
|
|
375
|
+
try {
|
|
376
|
+
res = await this.fetchFn(url.toString(), fetchInit);
|
|
377
|
+
} catch (err) {
|
|
378
|
+
clearTimeout(timer);
|
|
379
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
380
|
+
throw new NexusConnectionError(`Request timed out after ${this.timeout}ms`);
|
|
381
|
+
}
|
|
382
|
+
throw new NexusConnectionError(
|
|
383
|
+
err instanceof Error ? err.message : "Network request failed",
|
|
384
|
+
err instanceof Error ? err : void 0
|
|
385
|
+
);
|
|
386
|
+
} finally {
|
|
387
|
+
clearTimeout(timer);
|
|
388
|
+
}
|
|
389
|
+
if (res.status === 204) {
|
|
390
|
+
return { data: {}, meta: void 0 };
|
|
391
|
+
}
|
|
392
|
+
let json;
|
|
393
|
+
try {
|
|
394
|
+
json = await res.json();
|
|
395
|
+
} catch {
|
|
396
|
+
throw new NexusApiError(
|
|
397
|
+
"PARSE_ERROR",
|
|
398
|
+
`Failed to parse response body (status ${res.status})`,
|
|
399
|
+
res.status
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
if (!json.success) {
|
|
403
|
+
const err = json.error;
|
|
404
|
+
if (!err || typeof err !== "object") {
|
|
405
|
+
const raw = json;
|
|
406
|
+
const msg = raw.message ?? `Request failed with status ${res.status}`;
|
|
407
|
+
const code = raw.error ?? `HTTP_${res.status}`;
|
|
408
|
+
if (res.status === 401) {
|
|
409
|
+
throw new NexusAuthenticationError(msg);
|
|
410
|
+
}
|
|
411
|
+
throw new NexusApiError(code, msg, res.status);
|
|
412
|
+
}
|
|
413
|
+
if (res.status === 401) {
|
|
414
|
+
throw new NexusAuthenticationError(err.message);
|
|
415
|
+
}
|
|
416
|
+
throw new NexusApiError(err.code, err.message, res.status, err.details);
|
|
417
|
+
}
|
|
418
|
+
const success = json;
|
|
419
|
+
return { data: success.data, meta: success.meta };
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
var BaseResource = class {
|
|
423
|
+
constructor(http) {
|
|
424
|
+
this.http = http;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
var AgentCollectionsResource = class extends BaseResource {
|
|
428
|
+
async list(agentId) {
|
|
429
|
+
return this.http.request("GET", `/agents/${agentId}/collections`);
|
|
430
|
+
}
|
|
431
|
+
async attach(agentId, body) {
|
|
432
|
+
return this.http.request("POST", `/agents/${agentId}/collections`, { body });
|
|
433
|
+
}
|
|
434
|
+
async detach(agentId, body) {
|
|
435
|
+
return this.http.request("DELETE", `/agents/${agentId}/collections`, { body });
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
var AgentToolsResource = class extends BaseResource {
|
|
439
|
+
/**
|
|
440
|
+
* List all tool configurations for an agent.
|
|
441
|
+
*
|
|
442
|
+
* @param agentId - Agent UUID.
|
|
443
|
+
* @returns Array of tool configurations.
|
|
444
|
+
*/
|
|
445
|
+
async list(agentId) {
|
|
446
|
+
return this.http.request("GET", `/agents/${agentId}/tools`);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Get a specific tool configuration.
|
|
450
|
+
*
|
|
451
|
+
* @param agentId - Agent UUID.
|
|
452
|
+
* @param toolId - Tool config UUID.
|
|
453
|
+
* @returns Tool configuration detail.
|
|
454
|
+
*/
|
|
455
|
+
async get(agentId, toolId) {
|
|
456
|
+
return this.http.request("GET", `/agents/${agentId}/tools/${toolId}`);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Add a new tool configuration to an agent.
|
|
460
|
+
*
|
|
461
|
+
* @param agentId - Agent UUID.
|
|
462
|
+
* @param body - Tool configuration. `label` and `type` are required.
|
|
463
|
+
* @returns The created tool configuration.
|
|
464
|
+
*/
|
|
465
|
+
async create(agentId, body) {
|
|
466
|
+
return this.http.request("POST", `/agents/${agentId}/tools`, { body });
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Update an existing tool configuration. Only provided fields are updated.
|
|
470
|
+
*
|
|
471
|
+
* @param agentId - Agent UUID.
|
|
472
|
+
* @param toolId - Tool config UUID.
|
|
473
|
+
* @param body - Fields to update.
|
|
474
|
+
* @returns The updated tool configuration.
|
|
475
|
+
*/
|
|
476
|
+
async update(agentId, toolId, body) {
|
|
477
|
+
return this.http.request("PATCH", `/agents/${agentId}/tools/${toolId}`, {
|
|
478
|
+
body
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Remove a tool configuration from an agent.
|
|
483
|
+
*
|
|
484
|
+
* @param agentId - Agent UUID.
|
|
485
|
+
* @param toolId - Tool config UUID.
|
|
486
|
+
* @returns Confirmation with the deleted tool config's ID.
|
|
487
|
+
*/
|
|
488
|
+
async delete(agentId, toolId) {
|
|
489
|
+
return this.http.request("DELETE", `/agents/${agentId}/tools/${toolId}`);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Attach a knowledge collection to an agent.
|
|
493
|
+
*
|
|
494
|
+
* Creates a COLLECTION-type tool that allows the agent to search the
|
|
495
|
+
* collection during conversations. If `label` is omitted, the collection
|
|
496
|
+
* name is used.
|
|
497
|
+
*
|
|
498
|
+
* @param agentId - Agent UUID.
|
|
499
|
+
* @param body - Collection ID and optional label/description/instructions.
|
|
500
|
+
* @returns The created tool configuration.
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```ts
|
|
504
|
+
* const tool = await client.agents.tools.attachCollection("agent-uuid", {
|
|
505
|
+
* collectionId: "collection-uuid"
|
|
506
|
+
* });
|
|
507
|
+
* ```
|
|
508
|
+
*/
|
|
509
|
+
async attachCollection(agentId, body) {
|
|
510
|
+
return this.http.request(
|
|
511
|
+
"POST",
|
|
512
|
+
`/agents/${agentId}/tools/attach-collection`,
|
|
513
|
+
{ body }
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
var VersionsResource = class extends BaseResource {
|
|
518
|
+
/**
|
|
519
|
+
* List prompt versions for an agent (paginated).
|
|
520
|
+
*
|
|
521
|
+
* @param agentId - Agent UUID.
|
|
522
|
+
* @param params - Optional type filter and pagination.
|
|
523
|
+
* @returns Paginated list of version summaries.
|
|
524
|
+
*/
|
|
525
|
+
async list(agentId, params) {
|
|
526
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
527
|
+
"GET",
|
|
528
|
+
`/agents/${agentId}/versions`,
|
|
529
|
+
{ query: params }
|
|
530
|
+
);
|
|
531
|
+
return { data, meta };
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Get detailed information about a specific version, including the full prompt content.
|
|
535
|
+
*
|
|
536
|
+
* @param agentId - Agent UUID.
|
|
537
|
+
* @param versionId - Version UUID.
|
|
538
|
+
* @returns Version detail with the prompt text.
|
|
539
|
+
*/
|
|
540
|
+
async get(agentId, versionId) {
|
|
541
|
+
return this.http.request("GET", `/agents/${agentId}/versions/${versionId}`);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Create a named checkpoint of the agent's current prompt.
|
|
545
|
+
*
|
|
546
|
+
* @param agentId - Agent UUID.
|
|
547
|
+
* @param body - Optional name and description for the checkpoint.
|
|
548
|
+
* @returns The created checkpoint version.
|
|
549
|
+
*/
|
|
550
|
+
async createCheckpoint(agentId, body) {
|
|
551
|
+
return this.http.request("POST", `/agents/${agentId}/versions`, {
|
|
552
|
+
body: body ?? {}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Update a version's metadata (name or description).
|
|
557
|
+
*
|
|
558
|
+
* @param agentId - Agent UUID.
|
|
559
|
+
* @param versionId - Version UUID.
|
|
560
|
+
* @param body - Fields to update.
|
|
561
|
+
* @returns The updated version detail.
|
|
562
|
+
*/
|
|
563
|
+
async update(agentId, versionId, body) {
|
|
564
|
+
return this.http.request("PATCH", `/agents/${agentId}/versions/${versionId}`, {
|
|
565
|
+
body
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* Delete a prompt version. Cannot delete the current production version.
|
|
570
|
+
*
|
|
571
|
+
* @param agentId - Agent UUID.
|
|
572
|
+
* @param versionId - Version UUID.
|
|
573
|
+
* @returns Confirmation with the deleted version's ID.
|
|
574
|
+
*/
|
|
575
|
+
async delete(agentId, versionId) {
|
|
576
|
+
return this.http.request("DELETE", `/agents/${agentId}/versions/${versionId}`);
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Restore the agent's prompt to a specific version. This overwrites the
|
|
580
|
+
* agent's current prompt with the content from the specified version.
|
|
581
|
+
*
|
|
582
|
+
* @param agentId - Agent UUID.
|
|
583
|
+
* @param versionId - Version UUID to restore.
|
|
584
|
+
* @returns The restored prompt content and a confirmation message.
|
|
585
|
+
*/
|
|
586
|
+
async restore(agentId, versionId) {
|
|
587
|
+
return this.http.request(
|
|
588
|
+
"POST",
|
|
589
|
+
`/agents/${agentId}/versions/${versionId}/restore`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Publish a version to production. This marks the version as the active
|
|
594
|
+
* production version for the agent.
|
|
595
|
+
*
|
|
596
|
+
* @param agentId - Agent UUID.
|
|
597
|
+
* @param versionId - Version UUID to publish.
|
|
598
|
+
* @returns The published version detail with `isProduction: true`.
|
|
599
|
+
*/
|
|
600
|
+
async publish(agentId, versionId) {
|
|
601
|
+
return this.http.request(
|
|
602
|
+
"POST",
|
|
603
|
+
`/agents/${agentId}/versions/${versionId}/publish`
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
var AgentsResource = class extends BaseResource {
|
|
608
|
+
constructor(http) {
|
|
609
|
+
super(http);
|
|
610
|
+
this.tools = new AgentToolsResource(http);
|
|
611
|
+
this.versions = new VersionsResource(http);
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* List agents with optional filtering and pagination.
|
|
615
|
+
*
|
|
616
|
+
* @param params - Optional filters and pagination.
|
|
617
|
+
* @returns Paginated list of agent summaries.
|
|
618
|
+
*/
|
|
619
|
+
async list(params) {
|
|
620
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/agents", {
|
|
621
|
+
query: params
|
|
622
|
+
});
|
|
623
|
+
return { data, meta };
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Get detailed information about a specific agent.
|
|
627
|
+
*
|
|
628
|
+
* @param agentId - Agent UUID.
|
|
629
|
+
* @returns Full agent detail including prompt, behaviour rules, and model configuration.
|
|
630
|
+
*/
|
|
631
|
+
async get(agentId) {
|
|
632
|
+
return this.http.request("GET", `/agents/${agentId}`);
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Create a new agent.
|
|
636
|
+
*
|
|
637
|
+
* @param body - Agent properties. `firstName`, `lastName`, and `role` are required.
|
|
638
|
+
* @returns The created agent detail.
|
|
639
|
+
*/
|
|
640
|
+
async create(body) {
|
|
641
|
+
return this.http.request("POST", "/agents", { body });
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Update an existing agent's properties. Only provided fields are updated.
|
|
645
|
+
*
|
|
646
|
+
* @param agentId - Agent UUID.
|
|
647
|
+
* @param body - Fields to update.
|
|
648
|
+
* @returns The updated agent detail.
|
|
649
|
+
*/
|
|
650
|
+
async update(agentId, body) {
|
|
651
|
+
return this.http.request("PATCH", `/agents/${agentId}`, { body });
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Permanently delete an agent and all its tool configurations and versions.
|
|
655
|
+
*
|
|
656
|
+
* @param agentId - Agent UUID.
|
|
657
|
+
* @returns Confirmation with the deleted agent's ID.
|
|
658
|
+
*/
|
|
659
|
+
async delete(agentId) {
|
|
660
|
+
return this.http.request("DELETE", `/agents/${agentId}`);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Create a copy of an existing agent, including its configuration and tools.
|
|
664
|
+
*
|
|
665
|
+
* @param agentId - Agent UUID to duplicate.
|
|
666
|
+
* @returns The newly created agent detail.
|
|
667
|
+
*/
|
|
668
|
+
async duplicate(agentId) {
|
|
669
|
+
return this.http.request("POST", `/agents/${agentId}/duplicate`);
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Upload a profile picture for an agent.
|
|
673
|
+
*
|
|
674
|
+
* @param agentId - Agent UUID.
|
|
675
|
+
* @param file - Image file as a Blob or File.
|
|
676
|
+
* @returns URL to the uploaded profile picture.
|
|
677
|
+
*/
|
|
678
|
+
async uploadProfilePicture(agentId, file) {
|
|
679
|
+
const formData = new FormData();
|
|
680
|
+
formData.append("file", file);
|
|
681
|
+
return this.http.request(
|
|
682
|
+
"POST",
|
|
683
|
+
`/agents/${agentId}/profile-picture`,
|
|
684
|
+
{ body: formData }
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Generate an AI profile picture for an agent using its name and role.
|
|
689
|
+
*
|
|
690
|
+
* @param agentId - Agent UUID.
|
|
691
|
+
* @param body - Optional custom prompt to guide image style.
|
|
692
|
+
* @returns URLs of the generated profile picture in multiple sizes.
|
|
693
|
+
*/
|
|
694
|
+
async generateProfilePicture(agentId, body) {
|
|
695
|
+
return this.http.request("POST", `/agents/${agentId}/generate-profile-picture`, { body });
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
var ChannelsResource = class extends BaseResource {
|
|
699
|
+
// ===========================================================================
|
|
700
|
+
// Setup Orchestrator
|
|
701
|
+
// ===========================================================================
|
|
702
|
+
async getSetupStatus(type) {
|
|
703
|
+
return this.http.request("GET", "/channels/setup", {
|
|
704
|
+
query: { type }
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
async autoProvision(body) {
|
|
708
|
+
return this.http.request("POST", "/channels/setup", { body });
|
|
709
|
+
}
|
|
710
|
+
// ===========================================================================
|
|
711
|
+
// Connections
|
|
712
|
+
// ===========================================================================
|
|
713
|
+
async listConnections() {
|
|
714
|
+
return this.http.request("GET", "/channels/connections");
|
|
715
|
+
}
|
|
716
|
+
async createConnection(body) {
|
|
717
|
+
return this.http.request("POST", "/channels/connections", { body: body ?? {} });
|
|
718
|
+
}
|
|
719
|
+
async getConnection(connectionId) {
|
|
720
|
+
return this.http.request("GET", `/channels/connections/${connectionId}`);
|
|
721
|
+
}
|
|
722
|
+
// ===========================================================================
|
|
723
|
+
// Phone Numbers (mirrors /phone-numbers under /channels/)
|
|
724
|
+
// ===========================================================================
|
|
725
|
+
async searchAvailablePhoneNumbers(params) {
|
|
726
|
+
return this.http.request("GET", "/channels/phone-numbers/available", {
|
|
727
|
+
query: params
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
async buyPhoneNumber(body) {
|
|
731
|
+
return this.http.request("POST", "/channels/phone-numbers/buy", { body });
|
|
732
|
+
}
|
|
733
|
+
async listPhoneNumbers() {
|
|
734
|
+
return this.http.request("GET", "/channels/phone-numbers");
|
|
735
|
+
}
|
|
736
|
+
async getPhoneNumber(phoneNumberId) {
|
|
737
|
+
return this.http.request("GET", `/channels/phone-numbers/${phoneNumberId}`);
|
|
738
|
+
}
|
|
739
|
+
// ===========================================================================
|
|
740
|
+
// WhatsApp Senders
|
|
741
|
+
// ===========================================================================
|
|
742
|
+
async listWhatsAppSenders() {
|
|
743
|
+
return this.http.request("GET", "/channels/whatsapp-senders");
|
|
744
|
+
}
|
|
745
|
+
async createWhatsAppSender(body) {
|
|
746
|
+
return this.http.request("POST", "/channels/whatsapp-senders", { body });
|
|
747
|
+
}
|
|
748
|
+
async getWhatsAppSender(senderId) {
|
|
749
|
+
return this.http.request("GET", `/channels/whatsapp-senders/${senderId}`);
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
var AnalyticsResource = class extends BaseResource {
|
|
753
|
+
async getOverview(params) {
|
|
754
|
+
return this.http.request("GET", "/analytics/overview", {
|
|
755
|
+
query: params
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
async exportCsv(params) {
|
|
759
|
+
return this.http.requestRaw("GET", "/analytics/export", {
|
|
760
|
+
query: params
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
async listFeedback(params) {
|
|
764
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/analytics/feedback", {
|
|
765
|
+
query: params
|
|
766
|
+
});
|
|
767
|
+
return { data, meta };
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
var CloudImportsResource = class extends BaseResource {
|
|
771
|
+
// Google Drive
|
|
772
|
+
async googleDriveAuth(body) {
|
|
773
|
+
return this.http.request("POST", "/documents/google-drive/auth", { body });
|
|
774
|
+
}
|
|
775
|
+
async googleDriveRefresh(body) {
|
|
776
|
+
return this.http.request("POST", "/documents/google-drive/refresh", { body });
|
|
777
|
+
}
|
|
778
|
+
async listGoogleDriveFiles(params) {
|
|
779
|
+
return this.http.request("GET", "/documents/google-drive/files", {
|
|
780
|
+
query: params
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
async importGoogleDrive(body) {
|
|
784
|
+
return this.http.request("POST", "/documents/google-drive/import", { body });
|
|
785
|
+
}
|
|
786
|
+
// SharePoint
|
|
787
|
+
async sharePointAuth(body) {
|
|
788
|
+
return this.http.request("POST", "/documents/sharepoint/auth", { body });
|
|
789
|
+
}
|
|
790
|
+
async sharePointRefresh(body) {
|
|
791
|
+
return this.http.request("POST", "/documents/sharepoint/refresh", { body });
|
|
792
|
+
}
|
|
793
|
+
async listSharePointSites(params) {
|
|
794
|
+
return this.http.request("GET", "/documents/sharepoint/sites", {
|
|
795
|
+
query: params
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
async listSharePointFiles(params) {
|
|
799
|
+
return this.http.request("GET", "/documents/sharepoint/files", {
|
|
800
|
+
query: params
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
async importSharePoint(body) {
|
|
804
|
+
return this.http.request("POST", "/documents/sharepoint/import", { body });
|
|
805
|
+
}
|
|
806
|
+
// Notion
|
|
807
|
+
async notionAuth(body) {
|
|
808
|
+
return this.http.request("POST", "/documents/notion/auth", { body });
|
|
809
|
+
}
|
|
810
|
+
async searchNotion(params) {
|
|
811
|
+
return this.http.request("GET", "/documents/notion/search", {
|
|
812
|
+
query: params
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
async importNotion(body) {
|
|
816
|
+
return this.http.request("POST", "/documents/notion/import", { body });
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
var CustomModelsResource = class extends BaseResource {
|
|
820
|
+
/**
|
|
821
|
+
* List all custom models for the organization.
|
|
822
|
+
*/
|
|
823
|
+
async list() {
|
|
824
|
+
return this.http.request("GET", "/custom-models");
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Get a custom model by ID.
|
|
828
|
+
*/
|
|
829
|
+
async get(customModelId) {
|
|
830
|
+
return this.http.request("GET", `/custom-models/${customModelId}`);
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Create a new custom model.
|
|
834
|
+
*/
|
|
835
|
+
async create(body) {
|
|
836
|
+
return this.http.request("POST", "/custom-models", { body });
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Update a custom model.
|
|
840
|
+
*/
|
|
841
|
+
async update(customModelId, body) {
|
|
842
|
+
return this.http.request("PATCH", `/custom-models/${customModelId}`, {
|
|
843
|
+
body
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Delete a custom model.
|
|
848
|
+
*/
|
|
849
|
+
async delete(customModelId) {
|
|
850
|
+
return this.http.request("DELETE", `/custom-models/${customModelId}`);
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
var DeploymentFoldersResource = class extends BaseResource {
|
|
854
|
+
async list() {
|
|
855
|
+
return this.http.request("GET", "/deployment-folders");
|
|
856
|
+
}
|
|
857
|
+
async create(body) {
|
|
858
|
+
return this.http.request("POST", "/deployment-folders", { body });
|
|
859
|
+
}
|
|
860
|
+
async update(folderId, body) {
|
|
861
|
+
return this.http.request("PATCH", `/deployment-folders/${folderId}`, { body });
|
|
862
|
+
}
|
|
863
|
+
async delete(folderId) {
|
|
864
|
+
return this.http.request("DELETE", `/deployment-folders/${folderId}`);
|
|
865
|
+
}
|
|
866
|
+
async assign(body) {
|
|
867
|
+
return this.http.request("POST", "/deployment-folders/assign", { body });
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
var DeploymentsResource = class extends BaseResource {
|
|
871
|
+
async list(params) {
|
|
872
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/deployments", {
|
|
873
|
+
query: params
|
|
874
|
+
});
|
|
875
|
+
return { data, meta };
|
|
876
|
+
}
|
|
877
|
+
async create(body) {
|
|
878
|
+
return this.http.request("POST", "/deployments", { body });
|
|
879
|
+
}
|
|
880
|
+
async get(deploymentId) {
|
|
881
|
+
return this.http.request("GET", `/deployments/${deploymentId}`);
|
|
882
|
+
}
|
|
883
|
+
async update(deploymentId, body) {
|
|
884
|
+
return this.http.request("PATCH", `/deployments/${deploymentId}`, { body });
|
|
885
|
+
}
|
|
886
|
+
async delete(deploymentId) {
|
|
887
|
+
return this.http.request("DELETE", `/deployments/${deploymentId}`);
|
|
888
|
+
}
|
|
889
|
+
async duplicate(deploymentId) {
|
|
890
|
+
return this.http.request("POST", `/deployments/${deploymentId}/duplicate`);
|
|
891
|
+
}
|
|
892
|
+
async getStatistics(deploymentId) {
|
|
893
|
+
return this.http.request("GET", `/deployments/${deploymentId}/statistics`);
|
|
894
|
+
}
|
|
895
|
+
async getEmbedConfig(deploymentId) {
|
|
896
|
+
return this.http.request("GET", `/deployments/${deploymentId}/embed-config`);
|
|
897
|
+
}
|
|
898
|
+
async updateEmbedConfig(deploymentId, body) {
|
|
899
|
+
return this.http.request("PATCH", `/deployments/${deploymentId}/embed-config`, { body });
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
var DocumentTemplateFoldersResource = class extends BaseResource {
|
|
903
|
+
async list() {
|
|
904
|
+
return this.http.request("GET", "/document-template-folders");
|
|
905
|
+
}
|
|
906
|
+
async create(body) {
|
|
907
|
+
return this.http.request("POST", "/document-template-folders", { body });
|
|
908
|
+
}
|
|
909
|
+
async update(folderId, body) {
|
|
910
|
+
return this.http.request("PATCH", `/document-template-folders/${folderId}`, { body });
|
|
911
|
+
}
|
|
912
|
+
async delete(folderId) {
|
|
913
|
+
return this.http.request("DELETE", `/document-template-folders/${folderId}`);
|
|
914
|
+
}
|
|
915
|
+
async assign(body) {
|
|
916
|
+
return this.http.request("POST", "/document-template-folders/assign", { body });
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
var DocumentsResource = class extends BaseResource {
|
|
920
|
+
/**
|
|
921
|
+
* Get a document by ID.
|
|
922
|
+
*
|
|
923
|
+
* @param documentId - The document's UUID.
|
|
924
|
+
* @returns Detailed document information.
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* ```ts
|
|
928
|
+
* const doc = await client.documents.get("doc-uuid");
|
|
929
|
+
* console.log(doc.name, doc.status, doc.processingProgress);
|
|
930
|
+
* ```
|
|
931
|
+
*/
|
|
932
|
+
async get(documentId) {
|
|
933
|
+
return this.http.request("GET", `/documents/${documentId}`);
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* Upload a file as a new document.
|
|
937
|
+
*
|
|
938
|
+
* @param file - File as a `Blob`, `File`, or `Buffer`.
|
|
939
|
+
* @param fileName - File name (required when passing a `Blob` or `Buffer`).
|
|
940
|
+
* @param description - Optional description.
|
|
941
|
+
* @returns Created document info.
|
|
942
|
+
*
|
|
943
|
+
* @example
|
|
944
|
+
* ```ts
|
|
945
|
+
* import fs from "fs";
|
|
946
|
+
*
|
|
947
|
+
* const buffer = fs.readFileSync("report.pdf");
|
|
948
|
+
* const doc = await client.documents.uploadFile(
|
|
949
|
+
* new Blob([buffer]),
|
|
950
|
+
* "report.pdf",
|
|
951
|
+
* "Q4 financial report"
|
|
952
|
+
* );
|
|
953
|
+
* console.log(doc.id, doc.status);
|
|
954
|
+
* ```
|
|
955
|
+
*/
|
|
956
|
+
async uploadFile(file, fileName, description) {
|
|
957
|
+
const formData = new FormData();
|
|
958
|
+
formData.append("file", file, fileName);
|
|
959
|
+
if (description) {
|
|
960
|
+
formData.append("description", description);
|
|
961
|
+
}
|
|
962
|
+
return this.http.request("POST", "/documents/file", { body: formData });
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Create a new document from inline text content.
|
|
966
|
+
*
|
|
967
|
+
* @param body - Document name, content, and optional description.
|
|
968
|
+
* @returns Created document info.
|
|
969
|
+
*
|
|
970
|
+
* @example
|
|
971
|
+
* ```ts
|
|
972
|
+
* const doc = await client.documents.createText({
|
|
973
|
+
* name: "Meeting Notes",
|
|
974
|
+
* content: "Key decisions from today's meeting..."
|
|
975
|
+
* });
|
|
976
|
+
* ```
|
|
977
|
+
*/
|
|
978
|
+
async createText(body) {
|
|
979
|
+
return this.http.request("POST", "/documents/text", { body });
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Crawl a website and create document(s) from the content.
|
|
983
|
+
*
|
|
984
|
+
* @param body - URL, crawl mode, optional config and description.
|
|
985
|
+
* @returns Created document info (folder for crawled pages).
|
|
986
|
+
*
|
|
987
|
+
* @example
|
|
988
|
+
* ```ts
|
|
989
|
+
* const doc = await client.documents.addWebsite({
|
|
990
|
+
* url: "https://docs.example.com",
|
|
991
|
+
* mode: "sitemap"
|
|
992
|
+
* });
|
|
993
|
+
* ```
|
|
994
|
+
*/
|
|
995
|
+
async addWebsite(body) {
|
|
996
|
+
return this.http.request("POST", "/documents/website", { body });
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Import a Google Sheet as document(s).
|
|
1000
|
+
*
|
|
1001
|
+
* @param body - Sheet name, URL, and optional metadata.
|
|
1002
|
+
* @returns Folder document, individual sheet documents, and status message.
|
|
1003
|
+
*
|
|
1004
|
+
* @example
|
|
1005
|
+
* ```ts
|
|
1006
|
+
* const result = await client.documents.createGoogleSheet({
|
|
1007
|
+
* name: "Product Catalog",
|
|
1008
|
+
* url: "https://docs.google.com/spreadsheets/d/..."
|
|
1009
|
+
* });
|
|
1010
|
+
* console.log(result.folder.id, result.sheets.length);
|
|
1011
|
+
* ```
|
|
1012
|
+
*/
|
|
1013
|
+
async createGoogleSheet(body) {
|
|
1014
|
+
return this.http.request("POST", "/documents/google-sheet", { body });
|
|
1015
|
+
}
|
|
1016
|
+
async list(params) {
|
|
1017
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/documents", {
|
|
1018
|
+
query: params
|
|
1019
|
+
});
|
|
1020
|
+
return { data, meta };
|
|
1021
|
+
}
|
|
1022
|
+
async update(documentId, body) {
|
|
1023
|
+
return this.http.request("PATCH", `/documents/${documentId}`, { body });
|
|
1024
|
+
}
|
|
1025
|
+
async delete(documentId) {
|
|
1026
|
+
return this.http.request("DELETE", `/documents/${documentId}`);
|
|
1027
|
+
}
|
|
1028
|
+
async getDownloadUrl(documentId) {
|
|
1029
|
+
return this.http.request(
|
|
1030
|
+
"GET",
|
|
1031
|
+
`/documents/${documentId}/download`
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1034
|
+
async listChildren(documentId, params) {
|
|
1035
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
1036
|
+
"GET",
|
|
1037
|
+
`/documents/${documentId}/children`,
|
|
1038
|
+
{
|
|
1039
|
+
query: params
|
|
1040
|
+
}
|
|
1041
|
+
);
|
|
1042
|
+
return { data, meta };
|
|
1043
|
+
}
|
|
1044
|
+
async reprocess(documentId) {
|
|
1045
|
+
return this.http.request("POST", `/documents/${documentId}/reprocess`);
|
|
1046
|
+
}
|
|
1047
|
+
async createFolder(body) {
|
|
1048
|
+
return this.http.request("POST", "/documents/folder", { body });
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
var EmulatorResource = class extends BaseResource {
|
|
1052
|
+
// ─── Sessions ───────────────────────────────────────────────────────────────
|
|
1053
|
+
/** Create a new emulator session for a deployment. */
|
|
1054
|
+
async createSession(deploymentId, body) {
|
|
1055
|
+
return this.http.request("POST", `/emulator/${deploymentId}/sessions`, {
|
|
1056
|
+
body
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
/** List emulator sessions for a deployment. */
|
|
1060
|
+
async listSessions(deploymentId) {
|
|
1061
|
+
return this.http.request("GET", `/emulator/${deploymentId}/sessions`);
|
|
1062
|
+
}
|
|
1063
|
+
/** Get detailed information about an emulator session, including messages. */
|
|
1064
|
+
async getSession(deploymentId, sessionId) {
|
|
1065
|
+
return this.http.request(
|
|
1066
|
+
"GET",
|
|
1067
|
+
`/emulator/${deploymentId}/sessions/${sessionId}`
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
/** Send a message in an emulator session. Returns debug info about agent execution. */
|
|
1071
|
+
async sendMessage(deploymentId, sessionId, body) {
|
|
1072
|
+
return this.http.request(
|
|
1073
|
+
"POST",
|
|
1074
|
+
`/emulator/${deploymentId}/sessions/${sessionId}/messages`,
|
|
1075
|
+
{ body }
|
|
1076
|
+
);
|
|
1077
|
+
}
|
|
1078
|
+
/** Delete an emulator session. */
|
|
1079
|
+
async deleteSession(deploymentId, sessionId) {
|
|
1080
|
+
await this.http.request("DELETE", `/emulator/${deploymentId}/sessions/${sessionId}`);
|
|
1081
|
+
}
|
|
1082
|
+
// ─── Scenarios ──────────────────────────────────────────────────────────────
|
|
1083
|
+
/** Save a scenario from an existing emulator session. */
|
|
1084
|
+
async saveScenario(body) {
|
|
1085
|
+
return this.http.request("POST", "/emulator/scenarios", {
|
|
1086
|
+
body
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
/** List scenarios, optionally filtered by deployment. */
|
|
1090
|
+
async listScenarios(params) {
|
|
1091
|
+
return this.http.request("GET", "/emulator/scenarios", {
|
|
1092
|
+
query: params
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
/** Get detailed information about a scenario, including its messages. */
|
|
1096
|
+
async getScenario(scenarioId) {
|
|
1097
|
+
return this.http.request("GET", `/emulator/scenarios/${scenarioId}`);
|
|
1098
|
+
}
|
|
1099
|
+
/** Replay a scenario against a deployment. Runs asynchronously. */
|
|
1100
|
+
async replayScenario(scenarioId, body) {
|
|
1101
|
+
return this.http.request("POST", `/emulator/scenarios/${scenarioId}/replay`, { body });
|
|
1102
|
+
}
|
|
1103
|
+
/** Delete a scenario. */
|
|
1104
|
+
async deleteScenario(scenarioId) {
|
|
1105
|
+
await this.http.request("DELETE", `/emulator/scenarios/${scenarioId}`);
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
var EvaluationsResource = class extends BaseResource {
|
|
1109
|
+
async createSession(taskId, body) {
|
|
1110
|
+
return this.http.request("POST", `/skills/tasks/${taskId}/evaluations`, { body });
|
|
1111
|
+
}
|
|
1112
|
+
async listSessions(taskId, params) {
|
|
1113
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
1114
|
+
"GET",
|
|
1115
|
+
`/skills/tasks/${taskId}/evaluations`,
|
|
1116
|
+
{
|
|
1117
|
+
query: params
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
return { data, meta };
|
|
1121
|
+
}
|
|
1122
|
+
async getSession(taskId, sessionId) {
|
|
1123
|
+
return this.http.request("GET", `/skills/tasks/${taskId}/evaluations/${sessionId}`);
|
|
1124
|
+
}
|
|
1125
|
+
async deleteSession(taskId, sessionId) {
|
|
1126
|
+
return this.http.request("DELETE", `/skills/tasks/${taskId}/evaluations/${sessionId}`);
|
|
1127
|
+
}
|
|
1128
|
+
async getDatasetRows(taskId, sessionId, params) {
|
|
1129
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
1130
|
+
"GET",
|
|
1131
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/dataset`,
|
|
1132
|
+
{
|
|
1133
|
+
query: params
|
|
1134
|
+
}
|
|
1135
|
+
);
|
|
1136
|
+
return { data, meta };
|
|
1137
|
+
}
|
|
1138
|
+
async addDatasetRow(taskId, sessionId, body) {
|
|
1139
|
+
return this.http.request(
|
|
1140
|
+
"POST",
|
|
1141
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/dataset/rows`,
|
|
1142
|
+
{ body }
|
|
1143
|
+
);
|
|
1144
|
+
}
|
|
1145
|
+
async execute(taskId, sessionId) {
|
|
1146
|
+
return this.http.request(
|
|
1147
|
+
"POST",
|
|
1148
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/execute`
|
|
1149
|
+
);
|
|
1150
|
+
}
|
|
1151
|
+
async judge(taskId, sessionId, body) {
|
|
1152
|
+
return this.http.request(
|
|
1153
|
+
"POST",
|
|
1154
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/judge`,
|
|
1155
|
+
{ body }
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
async getResults(taskId, sessionId, params) {
|
|
1159
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
1160
|
+
"GET",
|
|
1161
|
+
`/skills/tasks/${taskId}/evaluations/${sessionId}/results`,
|
|
1162
|
+
{
|
|
1163
|
+
query: params
|
|
1164
|
+
}
|
|
1165
|
+
);
|
|
1166
|
+
return { data, meta };
|
|
1167
|
+
}
|
|
1168
|
+
async listFormats() {
|
|
1169
|
+
return this.http.request("GET", "/skills/evaluations/formats");
|
|
1170
|
+
}
|
|
1171
|
+
async listJudges() {
|
|
1172
|
+
return this.http.request("GET", "/skills/evaluations/judges");
|
|
1173
|
+
}
|
|
1174
|
+
};
|
|
1175
|
+
var FoldersResource = class extends BaseResource {
|
|
1176
|
+
/**
|
|
1177
|
+
* List all folders and their agent assignments.
|
|
1178
|
+
*
|
|
1179
|
+
* @returns All folders and a flat list of agent-to-folder assignments.
|
|
1180
|
+
*/
|
|
1181
|
+
async list() {
|
|
1182
|
+
return this.http.request("GET", "/folders");
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Create a new folder for organizing agents.
|
|
1186
|
+
*
|
|
1187
|
+
* @param body - Folder properties. `name` is required. Set `parentId` for nesting.
|
|
1188
|
+
* @returns The created folder.
|
|
1189
|
+
*/
|
|
1190
|
+
async create(body) {
|
|
1191
|
+
return this.http.request("POST", "/folders", { body });
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Update a folder's properties.
|
|
1195
|
+
*
|
|
1196
|
+
* @param folderId - Folder UUID.
|
|
1197
|
+
* @param body - Fields to update. Set `parentId` to `null` to move to root level.
|
|
1198
|
+
* @returns The updated folder.
|
|
1199
|
+
*/
|
|
1200
|
+
async update(folderId, body) {
|
|
1201
|
+
return this.http.request("PATCH", `/folders/${folderId}`, { body });
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Delete a folder. Agents in the folder are unassigned, not deleted.
|
|
1205
|
+
*
|
|
1206
|
+
* @param folderId - Folder UUID.
|
|
1207
|
+
* @returns Confirmation with the deleted folder's ID.
|
|
1208
|
+
*/
|
|
1209
|
+
async delete(folderId) {
|
|
1210
|
+
return this.http.request("DELETE", `/folders/${folderId}`);
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Assign an agent to a folder, or remove from folder.
|
|
1214
|
+
*
|
|
1215
|
+
* @param body - Agent ID and target folder ID. Set `folderId` to `null` to remove the agent from its folder.
|
|
1216
|
+
* @returns Confirmation of the assignment.
|
|
1217
|
+
*/
|
|
1218
|
+
async assignAgent(body) {
|
|
1219
|
+
return this.http.request("POST", "/folders/assign", {
|
|
1220
|
+
body
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
var MeResource = class extends BaseResource {
|
|
1225
|
+
constructor(http) {
|
|
1226
|
+
super(http);
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Get organization info for the current API key.
|
|
1230
|
+
*
|
|
1231
|
+
* @returns Organization ID and name.
|
|
1232
|
+
*/
|
|
1233
|
+
async get() {
|
|
1234
|
+
return this.http.request("GET", "/me");
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
var ModelsResource = class extends BaseResource {
|
|
1238
|
+
constructor(http) {
|
|
1239
|
+
super(http);
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* List all enabled AI models available for agents.
|
|
1243
|
+
*
|
|
1244
|
+
* @returns Array of model summaries with identifiers, providers, and capabilities.
|
|
1245
|
+
*/
|
|
1246
|
+
async list() {
|
|
1247
|
+
return this.http.request("GET", "/models");
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
var PhoneNumbersResource = class extends BaseResource {
|
|
1251
|
+
async searchAvailable(params) {
|
|
1252
|
+
return this.http.request("GET", "/phone-numbers/available", {
|
|
1253
|
+
query: params
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
async buy(body) {
|
|
1257
|
+
return this.http.request("POST", "/phone-numbers/buy", { body });
|
|
1258
|
+
}
|
|
1259
|
+
async list() {
|
|
1260
|
+
return this.http.request("GET", "/phone-numbers");
|
|
1261
|
+
}
|
|
1262
|
+
async get(phoneNumberId) {
|
|
1263
|
+
return this.http.request("GET", `/phone-numbers/${phoneNumberId}`);
|
|
1264
|
+
}
|
|
1265
|
+
async release(phoneNumberId) {
|
|
1266
|
+
return this.http.request("DELETE", `/phone-numbers/${phoneNumberId}`);
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
var PromptAssistantResource = class extends BaseResource {
|
|
1270
|
+
async chat(body) {
|
|
1271
|
+
return this.http.request("POST", "/prompt-assistant/chat", {
|
|
1272
|
+
body
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
async getThread(threadId) {
|
|
1276
|
+
return this.http.request(
|
|
1277
|
+
"GET",
|
|
1278
|
+
`/prompt-assistant/threads/${threadId}`
|
|
1279
|
+
);
|
|
1280
|
+
}
|
|
1281
|
+
async deleteThread(threadId) {
|
|
1282
|
+
return this.http.request(
|
|
1283
|
+
"DELETE",
|
|
1284
|
+
`/prompt-assistant/threads/${threadId}`
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
var SkillsResource = class extends BaseResource {
|
|
1289
|
+
/**
|
|
1290
|
+
* List the organization's workflows.
|
|
1291
|
+
*
|
|
1292
|
+
* @param params - Optional search, limit, and offset.
|
|
1293
|
+
* @returns Matching workflows with `agentInputSchema` and total count.
|
|
1294
|
+
*
|
|
1295
|
+
* @example
|
|
1296
|
+
* ```ts
|
|
1297
|
+
* const { items, total } = await client.skills.listWorkflows({ search: "onboarding" });
|
|
1298
|
+
* for (const wf of items) {
|
|
1299
|
+
* console.log(`${wf.name} (${wf.status}) - trigger: ${wf.triggerType}`);
|
|
1300
|
+
* }
|
|
1301
|
+
* ```
|
|
1302
|
+
*/
|
|
1303
|
+
async listWorkflows(params) {
|
|
1304
|
+
return this.http.request("GET", "/skills/workflows", {
|
|
1305
|
+
query: params
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Get a single workflow by ID.
|
|
1310
|
+
*
|
|
1311
|
+
* @param workflowId - Workflow UUID.
|
|
1312
|
+
* @returns Full workflow detail including `agentInputSchema`.
|
|
1313
|
+
*
|
|
1314
|
+
* @example
|
|
1315
|
+
* ```ts
|
|
1316
|
+
* const wf = await client.skills.getWorkflow("workflow-uuid");
|
|
1317
|
+
* console.log(wf.agentInputSchema); // JSON Schema the agent fills
|
|
1318
|
+
* ```
|
|
1319
|
+
*/
|
|
1320
|
+
async getWorkflow(workflowId) {
|
|
1321
|
+
return this.http.request("GET", `/skills/workflows/${workflowId}`);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* List the organization's AI tasks.
|
|
1325
|
+
*
|
|
1326
|
+
* @param params - Optional search, limit, and offset.
|
|
1327
|
+
* @returns Matching tasks (summary view) and total count.
|
|
1328
|
+
*
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```ts
|
|
1331
|
+
* const { items, total } = await client.skills.listTasks({ limit: 50 });
|
|
1332
|
+
* for (const task of items) {
|
|
1333
|
+
* console.log(`${task.name} (${task.category}) - ${task.inputFormat} → ${task.outputFormat}`);
|
|
1334
|
+
* }
|
|
1335
|
+
* ```
|
|
1336
|
+
*/
|
|
1337
|
+
async listTasks(params) {
|
|
1338
|
+
return this.http.request("GET", "/skills/tasks", {
|
|
1339
|
+
query: params
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1343
|
+
* Get a single AI task by ID with full detail.
|
|
1344
|
+
*
|
|
1345
|
+
* Includes `jsonInputSchema` and `jsonOutputSchema` when the task uses
|
|
1346
|
+
* structured JSON input/output.
|
|
1347
|
+
*
|
|
1348
|
+
* @param taskId - AI Task UUID.
|
|
1349
|
+
* @returns Full task detail.
|
|
1350
|
+
*
|
|
1351
|
+
* @example
|
|
1352
|
+
* ```ts
|
|
1353
|
+
* const task = await client.skills.getTask("task-uuid");
|
|
1354
|
+
* if (task.jsonInputSchema) {
|
|
1355
|
+
* console.log("Input schema:", task.jsonInputSchema);
|
|
1356
|
+
* }
|
|
1357
|
+
* ```
|
|
1358
|
+
*/
|
|
1359
|
+
async getTask(taskId) {
|
|
1360
|
+
return this.http.request("GET", `/skills/tasks/${taskId}`);
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* List the organization's knowledge collections.
|
|
1364
|
+
*
|
|
1365
|
+
* @param params - Optional search, limit, and offset.
|
|
1366
|
+
* @returns Matching collections (summary view) and total count.
|
|
1367
|
+
*
|
|
1368
|
+
* @example
|
|
1369
|
+
* ```ts
|
|
1370
|
+
* const { items } = await client.skills.listCollections();
|
|
1371
|
+
* for (const col of items) {
|
|
1372
|
+
* console.log(`${col.name}: ${col.documentCount} documents`);
|
|
1373
|
+
* }
|
|
1374
|
+
* ```
|
|
1375
|
+
*/
|
|
1376
|
+
async listCollections(params) {
|
|
1377
|
+
return this.http.request("GET", "/skills/collections", {
|
|
1378
|
+
query: params
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Get a single knowledge collection by ID with retrieval settings.
|
|
1383
|
+
*
|
|
1384
|
+
* @param collectionId - Collection UUID.
|
|
1385
|
+
* @returns Full collection detail with `k`, `reranker`, etc.
|
|
1386
|
+
*
|
|
1387
|
+
* @example
|
|
1388
|
+
* ```ts
|
|
1389
|
+
* const col = await client.skills.getCollection("collection-uuid");
|
|
1390
|
+
* console.log(`k=${col.k}, reranker=${col.reranker}`);
|
|
1391
|
+
* ```
|
|
1392
|
+
*/
|
|
1393
|
+
async getCollection(collectionId) {
|
|
1394
|
+
return this.http.request("GET", `/skills/collections/${collectionId}`);
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* List the organization's document templates.
|
|
1398
|
+
*
|
|
1399
|
+
* @param params - Optional search, limit, and offset.
|
|
1400
|
+
* @returns Matching templates (summary view) and total count.
|
|
1401
|
+
*
|
|
1402
|
+
* @example
|
|
1403
|
+
* ```ts
|
|
1404
|
+
* const { items } = await client.skills.listDocumentTemplates({ search: "invoice" });
|
|
1405
|
+
* for (const tpl of items) {
|
|
1406
|
+
* console.log(`${tpl.name} (${tpl.type}) - ${tpl.status}`);
|
|
1407
|
+
* }
|
|
1408
|
+
* ```
|
|
1409
|
+
*/
|
|
1410
|
+
async listDocumentTemplates(params) {
|
|
1411
|
+
return this.http.request("GET", "/skills/document-templates", {
|
|
1412
|
+
query: params
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* Get a single document template by ID with full detail.
|
|
1417
|
+
*
|
|
1418
|
+
* Includes `inputFormat` (JSON schema of required inputs) and
|
|
1419
|
+
* `slidesInputFormat` (per-slide schemas for presentations).
|
|
1420
|
+
*
|
|
1421
|
+
* @param templateId - Document template UUID.
|
|
1422
|
+
* @returns Full template detail.
|
|
1423
|
+
*
|
|
1424
|
+
* @example
|
|
1425
|
+
* ```ts
|
|
1426
|
+
* const tpl = await client.skills.getDocumentTemplate("template-uuid");
|
|
1427
|
+
* console.log("Input format:", tpl.inputFormat);
|
|
1428
|
+
* ```
|
|
1429
|
+
*/
|
|
1430
|
+
async getDocumentTemplate(templateId) {
|
|
1431
|
+
return this.http.request(
|
|
1432
|
+
"GET",
|
|
1433
|
+
`/skills/document-templates/${templateId}`
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
// =========================================================================
|
|
1437
|
+
// CREATE OPERATIONS
|
|
1438
|
+
// =========================================================================
|
|
1439
|
+
/**
|
|
1440
|
+
* Create a new document template (metadata only).
|
|
1441
|
+
*
|
|
1442
|
+
* Upload a file separately with `uploadDocumentTemplateFile`.
|
|
1443
|
+
*
|
|
1444
|
+
* @param body - Template name, optional description, and type.
|
|
1445
|
+
* @returns Created template detail.
|
|
1446
|
+
*
|
|
1447
|
+
* @example
|
|
1448
|
+
* ```ts
|
|
1449
|
+
* const tpl = await client.skills.createDocumentTemplate({
|
|
1450
|
+
* name: "Invoice",
|
|
1451
|
+
* type: "WORD_FORMAT"
|
|
1452
|
+
* });
|
|
1453
|
+
* ```
|
|
1454
|
+
*/
|
|
1455
|
+
async createDocumentTemplate(body) {
|
|
1456
|
+
return this.http.request("POST", "/skills/document-templates", {
|
|
1457
|
+
body
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Upload a file and link it to an existing document template.
|
|
1462
|
+
*
|
|
1463
|
+
* @param templateId - Document template UUID.
|
|
1464
|
+
* @param file - File as a `Blob`, `File`, or `Buffer`.
|
|
1465
|
+
* @param fileName - File name (required when passing a `Blob` or `Buffer`).
|
|
1466
|
+
* @returns Updated template detail with `fileUrl` populated.
|
|
1467
|
+
*
|
|
1468
|
+
* @example
|
|
1469
|
+
* ```ts
|
|
1470
|
+
* import fs from "fs";
|
|
1471
|
+
*
|
|
1472
|
+
* const buffer = fs.readFileSync("template.docx");
|
|
1473
|
+
* const tpl = await client.skills.uploadDocumentTemplateFile(
|
|
1474
|
+
* "template-uuid",
|
|
1475
|
+
* new Blob([buffer]),
|
|
1476
|
+
* "template.docx"
|
|
1477
|
+
* );
|
|
1478
|
+
* console.log(tpl.fileUrl);
|
|
1479
|
+
* ```
|
|
1480
|
+
*/
|
|
1481
|
+
async uploadDocumentTemplateFile(templateId, file, fileName) {
|
|
1482
|
+
const formData = new FormData();
|
|
1483
|
+
formData.append("file", file, fileName);
|
|
1484
|
+
return this.http.request(
|
|
1485
|
+
"POST",
|
|
1486
|
+
`/skills/document-templates/${templateId}/upload-file`,
|
|
1487
|
+
{ body: formData }
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Create a new GENERATION AI task.
|
|
1492
|
+
*
|
|
1493
|
+
* The category is hardcoded to "GENERATION". The `modelName` is validated
|
|
1494
|
+
* against the available AI models — on invalid model, returns 400 with
|
|
1495
|
+
* the list of valid model names.
|
|
1496
|
+
*
|
|
1497
|
+
* @param body - Task definition.
|
|
1498
|
+
* @returns Created task detail.
|
|
1499
|
+
*
|
|
1500
|
+
* @example
|
|
1501
|
+
* ```ts
|
|
1502
|
+
* const task = await client.skills.createTask({
|
|
1503
|
+
* name: "Summarize Email",
|
|
1504
|
+
* modelName: "gpt-4o",
|
|
1505
|
+
* modelProvider: "OPEN_AI",
|
|
1506
|
+
* generation: {
|
|
1507
|
+
* expectedInput: "Raw email text",
|
|
1508
|
+
* expectedOutput: "A concise 2-sentence summary"
|
|
1509
|
+
* }
|
|
1510
|
+
* });
|
|
1511
|
+
* ```
|
|
1512
|
+
*/
|
|
1513
|
+
async createTask(body) {
|
|
1514
|
+
return this.http.request("POST", "/skills/tasks", { body });
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Create a new knowledge collection.
|
|
1518
|
+
*
|
|
1519
|
+
* @param body - Collection name and optional settings.
|
|
1520
|
+
* @returns Created collection detail.
|
|
1521
|
+
*
|
|
1522
|
+
* @example
|
|
1523
|
+
* ```ts
|
|
1524
|
+
* const col = await client.skills.createCollection({
|
|
1525
|
+
* name: "product-docs",
|
|
1526
|
+
* displayName: "Product Documentation",
|
|
1527
|
+
* k: 15
|
|
1528
|
+
* });
|
|
1529
|
+
* ```
|
|
1530
|
+
*/
|
|
1531
|
+
async createCollection(body) {
|
|
1532
|
+
return this.http.request("POST", "/skills/collections", { body });
|
|
1533
|
+
}
|
|
1534
|
+
// =========================================================================
|
|
1535
|
+
// EXTERNAL TOOLS (CUSTOM_MANIFEST)
|
|
1536
|
+
// =========================================================================
|
|
1537
|
+
/**
|
|
1538
|
+
* List the organization's external tools (CUSTOM_MANIFEST).
|
|
1539
|
+
*
|
|
1540
|
+
* @param params - Optional search, limit, and offset.
|
|
1541
|
+
* @returns Matching external tools and total count.
|
|
1542
|
+
*
|
|
1543
|
+
* @example
|
|
1544
|
+
* ```ts
|
|
1545
|
+
* const { items, total } = await client.skills.listExternalTools({ search: "weather" });
|
|
1546
|
+
* for (const tool of items) {
|
|
1547
|
+
* console.log(`${tool.name} (${tool.actionsCount} actions) - auth: ${tool.authType}`);
|
|
1548
|
+
* }
|
|
1549
|
+
* ```
|
|
1550
|
+
*/
|
|
1551
|
+
async listExternalTools(params) {
|
|
1552
|
+
return this.http.request("GET", "/skills/external-tools", {
|
|
1553
|
+
query: params
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
/**
|
|
1557
|
+
* Get a single external tool by ID.
|
|
1558
|
+
*
|
|
1559
|
+
* @param externalToolId - External tool UUID.
|
|
1560
|
+
* @returns Full external tool detail.
|
|
1561
|
+
*
|
|
1562
|
+
* @example
|
|
1563
|
+
* ```ts
|
|
1564
|
+
* const tool = await client.skills.getExternalTool("tool-uuid");
|
|
1565
|
+
* console.log(`${tool.name}: ${tool.actionsCount} actions, auth: ${tool.authType}`);
|
|
1566
|
+
* ```
|
|
1567
|
+
*/
|
|
1568
|
+
async getExternalTool(externalToolId) {
|
|
1569
|
+
return this.http.request("GET", `/skills/external-tools/${externalToolId}`);
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Create a new external tool from an OpenAPI spec.
|
|
1573
|
+
*
|
|
1574
|
+
* Parses the provided OpenAPI spec (JSON or YAML), extracts actions,
|
|
1575
|
+
* and creates the tool with the specified auth configuration.
|
|
1576
|
+
*
|
|
1577
|
+
* @param body - Tool name, OpenAPI spec, endpoint URL, and auth config.
|
|
1578
|
+
* @returns Created external tool detail with `actionsCount`.
|
|
1579
|
+
*
|
|
1580
|
+
* @example
|
|
1581
|
+
* ```ts
|
|
1582
|
+
* const tool = await client.skills.createExternalTool({
|
|
1583
|
+
* name: "Weather API",
|
|
1584
|
+
* openApiSpec: '{"openapi":"3.0.0",...}',
|
|
1585
|
+
* endpointUrl: "https://api.weather.com",
|
|
1586
|
+
* auth: { type: "service_http", apiKey: "sk-...", authorization_type: "bearer" }
|
|
1587
|
+
* });
|
|
1588
|
+
* console.log(`Created: ${tool.name} with ${tool.actionsCount} actions`);
|
|
1589
|
+
* ```
|
|
1590
|
+
*/
|
|
1591
|
+
async createExternalTool(body) {
|
|
1592
|
+
return this.http.request("POST", "/skills/external-tools", { body });
|
|
1593
|
+
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Test an external tool action by operationId with input parameters.
|
|
1596
|
+
*
|
|
1597
|
+
* Executes a specific action on an external tool and returns the result.
|
|
1598
|
+
* Optionally uses stored credentials for authentication.
|
|
1599
|
+
*
|
|
1600
|
+
* @param externalToolId - External tool UUID.
|
|
1601
|
+
* @param body - operationId, input params, and optional toolCredentialId.
|
|
1602
|
+
* @returns Execution result with status, output, and timing.
|
|
1603
|
+
*
|
|
1604
|
+
* @example
|
|
1605
|
+
* ```ts
|
|
1606
|
+
* const result = await client.skills.testExternalTool("tool-uuid", {
|
|
1607
|
+
* operationId: "getWeather",
|
|
1608
|
+
* input: { city: "London" }
|
|
1609
|
+
* });
|
|
1610
|
+
* console.log(`${result.status} in ${result.executionTimeMs}ms:`, result.output);
|
|
1611
|
+
* ```
|
|
1612
|
+
*/
|
|
1613
|
+
async testExternalTool(externalToolId, body) {
|
|
1614
|
+
return this.http.request(
|
|
1615
|
+
"POST",
|
|
1616
|
+
`/skills/external-tools/${externalToolId}/test`,
|
|
1617
|
+
{ body }
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1620
|
+
// =========================================================================
|
|
1621
|
+
// COLLECTION DOCUMENT LINKING
|
|
1622
|
+
// =========================================================================
|
|
1623
|
+
/**
|
|
1624
|
+
* Attach existing documents to a knowledge collection.
|
|
1625
|
+
*
|
|
1626
|
+
* @param collectionId - Collection UUID.
|
|
1627
|
+
* @param body - Array of document IDs to link.
|
|
1628
|
+
* @returns Status message.
|
|
1629
|
+
*
|
|
1630
|
+
* @example
|
|
1631
|
+
* ```ts
|
|
1632
|
+
* await client.skills.attachDocumentsToCollection("collection-uuid", {
|
|
1633
|
+
* documentIds: ["doc-1", "doc-2"]
|
|
1634
|
+
* });
|
|
1635
|
+
* ```
|
|
1636
|
+
*/
|
|
1637
|
+
async attachDocumentsToCollection(collectionId, body) {
|
|
1638
|
+
return this.http.request(
|
|
1639
|
+
"POST",
|
|
1640
|
+
`/skills/collections/${collectionId}/documents`,
|
|
1641
|
+
{ body }
|
|
1642
|
+
);
|
|
1643
|
+
}
|
|
1644
|
+
// =========================================================================
|
|
1645
|
+
// EXECUTION OPERATIONS
|
|
1646
|
+
// =========================================================================
|
|
1647
|
+
/**
|
|
1648
|
+
* Generate a document from a template with variable values.
|
|
1649
|
+
*
|
|
1650
|
+
* @param templateId - Document template UUID.
|
|
1651
|
+
* @param body - Variables to fill in the template.
|
|
1652
|
+
* @returns URL to the generated document.
|
|
1653
|
+
*
|
|
1654
|
+
* @example
|
|
1655
|
+
* ```ts
|
|
1656
|
+
* const { url } = await client.skills.generateDocumentTemplate("template-uuid", {
|
|
1657
|
+
* variables: { name: "John", date: "2025-01-01" }
|
|
1658
|
+
* });
|
|
1659
|
+
* console.log("Generated document:", url);
|
|
1660
|
+
* ```
|
|
1661
|
+
*/
|
|
1662
|
+
async generateDocumentTemplate(templateId, body) {
|
|
1663
|
+
return this.http.request(
|
|
1664
|
+
"POST",
|
|
1665
|
+
`/skills/document-templates/${templateId}/generate`,
|
|
1666
|
+
{ body }
|
|
1667
|
+
);
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* Execute an AI task with input and get the output.
|
|
1671
|
+
*
|
|
1672
|
+
* @param taskId - AI Task UUID.
|
|
1673
|
+
* @param body - Input to the task.
|
|
1674
|
+
* @returns Task output and output type.
|
|
1675
|
+
*
|
|
1676
|
+
* @example
|
|
1677
|
+
* ```ts
|
|
1678
|
+
* const { output, outputType } = await client.skills.executeTask("task-uuid", {
|
|
1679
|
+
* input: "Summarize this document"
|
|
1680
|
+
* });
|
|
1681
|
+
* console.log(`Output (${outputType}):`, output);
|
|
1682
|
+
* ```
|
|
1683
|
+
*/
|
|
1684
|
+
async executeTask(taskId, body) {
|
|
1685
|
+
return this.http.request("POST", `/skills/tasks/${taskId}/execute`, {
|
|
1686
|
+
body
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
// ===== COLLECTION MANAGEMENT (Enhanced) =====
|
|
1690
|
+
async listCollectionDocuments(collectionId, params) {
|
|
1691
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
1692
|
+
"GET",
|
|
1693
|
+
`/skills/collections/${collectionId}/documents`,
|
|
1694
|
+
{
|
|
1695
|
+
query: params
|
|
1696
|
+
}
|
|
1697
|
+
);
|
|
1698
|
+
return { data, meta };
|
|
1699
|
+
}
|
|
1700
|
+
async removeCollectionDocument(collectionId, documentId) {
|
|
1701
|
+
return this.http.request(
|
|
1702
|
+
"DELETE",
|
|
1703
|
+
`/skills/collections/${collectionId}/documents/${documentId}`
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
async getCollectionStatistics(collectionId) {
|
|
1707
|
+
return this.http.request("GET", `/skills/collections/${collectionId}/statistics`);
|
|
1708
|
+
}
|
|
1709
|
+
async searchCollection(collectionId, body) {
|
|
1710
|
+
return this.http.request("POST", `/skills/collections/${collectionId}/search`, { body });
|
|
1711
|
+
}
|
|
1712
|
+
async searchMultipleCollections(body) {
|
|
1713
|
+
return this.http.request("POST", "/skills/collections/search", { body });
|
|
1714
|
+
}
|
|
1715
|
+
async updateCollection(collectionId, body) {
|
|
1716
|
+
return this.http.request("PATCH", `/skills/collections/${collectionId}`, { body });
|
|
1717
|
+
}
|
|
1718
|
+
async deleteCollection(collectionId) {
|
|
1719
|
+
return this.http.request("DELETE", `/skills/collections/${collectionId}`);
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
var TicketsResource = class extends BaseResource {
|
|
1723
|
+
constructor(http) {
|
|
1724
|
+
super(http);
|
|
1725
|
+
}
|
|
1726
|
+
async list(params) {
|
|
1727
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/tickets", {
|
|
1728
|
+
query: params
|
|
1729
|
+
});
|
|
1730
|
+
return { data, meta };
|
|
1731
|
+
}
|
|
1732
|
+
async get(ticketId) {
|
|
1733
|
+
return this.http.request("GET", `/tickets/${ticketId}`);
|
|
1734
|
+
}
|
|
1735
|
+
async create(body) {
|
|
1736
|
+
return this.http.request("POST", "/tickets", { body });
|
|
1737
|
+
}
|
|
1738
|
+
async update(ticketId, body) {
|
|
1739
|
+
return this.http.request("PATCH", `/tickets/${ticketId}`, { body });
|
|
1740
|
+
}
|
|
1741
|
+
async addComment(ticketId, body) {
|
|
1742
|
+
return this.http.request("POST", `/tickets/${ticketId}/comments`, { body });
|
|
1743
|
+
}
|
|
1744
|
+
async listComments(ticketId) {
|
|
1745
|
+
return this.http.request("GET", `/tickets/${ticketId}/comments`);
|
|
1746
|
+
}
|
|
1747
|
+
async uploadAttachment(ticketId, file) {
|
|
1748
|
+
const formData = new FormData();
|
|
1749
|
+
formData.append("file", file);
|
|
1750
|
+
return this.http.request("POST", `/tickets/${ticketId}/attachments`, {
|
|
1751
|
+
body: formData
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1754
|
+
async listAttachments(ticketId) {
|
|
1755
|
+
return this.http.request(
|
|
1756
|
+
"GET",
|
|
1757
|
+
`/tickets/${ticketId}/attachments`
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
var ToolConnectionResource = class extends BaseResource {
|
|
1762
|
+
/**
|
|
1763
|
+
* Initiate a tool connection via OAuth or create an HTTP credential directly.
|
|
1764
|
+
*
|
|
1765
|
+
* For OAuth, returns an `authorizationUrl` the user must visit, plus a
|
|
1766
|
+
* `handshakeId` for polling. For HTTP, creates the credential immediately.
|
|
1767
|
+
*
|
|
1768
|
+
* @param toolId - Marketplace tool ID.
|
|
1769
|
+
* @param body - Connection type and parameters.
|
|
1770
|
+
* @returns OAuth authorization details or the created HTTP credential.
|
|
1771
|
+
*/
|
|
1772
|
+
async connect(toolId, body) {
|
|
1773
|
+
return this.http.request(
|
|
1774
|
+
"POST",
|
|
1775
|
+
`/tools/${toolId}/connect`,
|
|
1776
|
+
{ body }
|
|
1777
|
+
);
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Poll the status of an OAuth handshake.
|
|
1781
|
+
*
|
|
1782
|
+
* @param handshakeId - Handshake UUID returned by `connect()`.
|
|
1783
|
+
* @returns Current handshake status and connection ID if completed.
|
|
1784
|
+
*/
|
|
1785
|
+
async pollStatus(handshakeId) {
|
|
1786
|
+
return this.http.request(
|
|
1787
|
+
"GET",
|
|
1788
|
+
`/tools/connect/${handshakeId}/status`
|
|
1789
|
+
);
|
|
1790
|
+
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Wait for an OAuth handshake to complete by polling at regular intervals.
|
|
1793
|
+
*
|
|
1794
|
+
* Resolves when the status changes from `PENDING` to any terminal state
|
|
1795
|
+
* (`COMPLETED`, `FAILED`, or `EXPIRED`), or when the timeout is reached.
|
|
1796
|
+
*
|
|
1797
|
+
* @param handshakeId - Handshake UUID returned by `connect()`.
|
|
1798
|
+
* @param opts - Optional timeout (default 5 min) and polling interval (default 2 s).
|
|
1799
|
+
* @returns Final handshake status.
|
|
1800
|
+
*/
|
|
1801
|
+
async waitForConnection(handshakeId, opts) {
|
|
1802
|
+
const timeout = opts?.timeoutMs ?? 5 * 60 * 1e3;
|
|
1803
|
+
const interval = opts?.intervalMs ?? 2e3;
|
|
1804
|
+
const deadline = Date.now() + timeout;
|
|
1805
|
+
while (Date.now() < deadline) {
|
|
1806
|
+
const status = await this.pollStatus(handshakeId);
|
|
1807
|
+
if (status.status !== "PENDING") return status;
|
|
1808
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
1809
|
+
}
|
|
1810
|
+
return {
|
|
1811
|
+
status: "EXPIRED",
|
|
1812
|
+
connectionId: null,
|
|
1813
|
+
errorMessage: "Polling timed out",
|
|
1814
|
+
expiresAt: null
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* Delete a credential (connected account) from a tool.
|
|
1819
|
+
*
|
|
1820
|
+
* @param toolId - Marketplace tool ID.
|
|
1821
|
+
* @param credentialId - Credential UUID to delete.
|
|
1822
|
+
*/
|
|
1823
|
+
async deleteCredential(toolId, credentialId) {
|
|
1824
|
+
await this.http.request("DELETE", `/tools/${toolId}/credentials/${credentialId}`);
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
var ToolDiscoveryResource = class extends BaseResource {
|
|
1828
|
+
/**
|
|
1829
|
+
* Search marketplace tools by keyword with optional category and type filters.
|
|
1830
|
+
* Uses Typesense full-text search with SQL fallback.
|
|
1831
|
+
*
|
|
1832
|
+
* @param params - Search query and filters.
|
|
1833
|
+
* @returns Matching tools, category facets, and total count.
|
|
1834
|
+
*
|
|
1835
|
+
* @example
|
|
1836
|
+
* ```ts
|
|
1837
|
+
* const result = await client.tools.search({ q: "gmail", limit: 5 });
|
|
1838
|
+
* console.log(`Found ${result.total} tools`);
|
|
1839
|
+
* for (const tool of result.tools) {
|
|
1840
|
+
* console.log(`${tool.name} (${tool.type}): ${tool.description}`);
|
|
1841
|
+
* }
|
|
1842
|
+
* ```
|
|
1843
|
+
*/
|
|
1844
|
+
async search(params) {
|
|
1845
|
+
return this.http.request("GET", "/tools/search", {
|
|
1846
|
+
query: params
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Get full marketplace tool detail including actions and their parameter schemas.
|
|
1851
|
+
*
|
|
1852
|
+
* For Pipedream tools, each action's parameters are enriched with the full
|
|
1853
|
+
* component definition including types, descriptions, defaults, and
|
|
1854
|
+
* `remoteOptions` flags indicating which fields need dynamic option resolution.
|
|
1855
|
+
*
|
|
1856
|
+
* @param toolId - Marketplace tool ID (from search results).
|
|
1857
|
+
* @param params - Optional pagination/filter params for actions.
|
|
1858
|
+
* @returns Full tool detail with actions and parameter schemas.
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* ```ts
|
|
1862
|
+
* // Get all actions
|
|
1863
|
+
* const detail = await client.tools.get("tool-uuid");
|
|
1864
|
+
* console.log(`${detail.totalActions} total actions`);
|
|
1865
|
+
*
|
|
1866
|
+
* // Paginate actions
|
|
1867
|
+
* const page = await client.tools.get("tool-uuid", { actionsLimit: 10, actionsOffset: 20 });
|
|
1868
|
+
*
|
|
1869
|
+
* // Search for a specific action
|
|
1870
|
+
* const filtered = await client.tools.get("tool-uuid", { actionsSearch: "get-values" });
|
|
1871
|
+
* ```
|
|
1872
|
+
*/
|
|
1873
|
+
async get(toolId, params) {
|
|
1874
|
+
return this.http.request("GET", `/tools/${toolId}`, {
|
|
1875
|
+
query: params
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* List existing credentials (connected accounts) for a marketplace tool.
|
|
1880
|
+
*
|
|
1881
|
+
* Credentials represent authenticated connections (e.g. a Gmail OAuth token).
|
|
1882
|
+
* They are read-only through this endpoint — users create credentials via the
|
|
1883
|
+
* Nexus dashboard. Use the credential `id` when calling `resolveOptions()` or
|
|
1884
|
+
* when configuring an agent tool.
|
|
1885
|
+
*
|
|
1886
|
+
* @param toolId - Marketplace tool ID.
|
|
1887
|
+
* @returns List of credentials for this tool in the organization.
|
|
1888
|
+
*
|
|
1889
|
+
* @example
|
|
1890
|
+
* ```ts
|
|
1891
|
+
* const { credentials } = await client.tools.credentials("tool-uuid");
|
|
1892
|
+
* if (credentials.length === 0) {
|
|
1893
|
+
* console.log("No credentials — user must connect account in dashboard first");
|
|
1894
|
+
* }
|
|
1895
|
+
* ```
|
|
1896
|
+
*/
|
|
1897
|
+
async credentials(toolId) {
|
|
1898
|
+
return this.http.request("GET", `/tools/${toolId}/credentials`);
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Resolve dynamic dropdown options for a tool action parameter.
|
|
1902
|
+
*
|
|
1903
|
+
* Some parameters (those with `remoteOptions: true` in the tool detail) have
|
|
1904
|
+
* values that depend on the user's connected account — for example, a list of
|
|
1905
|
+
* Gmail labels or Slack channels. This method fetches those options at runtime.
|
|
1906
|
+
*
|
|
1907
|
+
* For cascading dependencies (e.g. "select folder" → "select file in folder"),
|
|
1908
|
+
* pass previously selected values in `configuredProps`.
|
|
1909
|
+
*
|
|
1910
|
+
* @param toolId - Marketplace tool ID.
|
|
1911
|
+
* @param body - Component ID, parameter name, credential, and current values.
|
|
1912
|
+
* @returns Available options for the specified parameter.
|
|
1913
|
+
*
|
|
1914
|
+
* @example
|
|
1915
|
+
* ```ts
|
|
1916
|
+
* const { options } = await client.tools.resolveOptions("tool-uuid", {
|
|
1917
|
+
* componentId: "gmail-send-email", // from ToolAction.key
|
|
1918
|
+
* propName: "label", // from ToolActionParameter.name
|
|
1919
|
+
* credentialId: "cred-uuid", // from ToolCredential.id
|
|
1920
|
+
* configuredProps: {} // previously selected values
|
|
1921
|
+
* });
|
|
1922
|
+
* for (const opt of options) {
|
|
1923
|
+
* console.log(`${opt.label}: ${opt.value}`);
|
|
1924
|
+
* }
|
|
1925
|
+
* ```
|
|
1926
|
+
*/
|
|
1927
|
+
async resolveOptions(toolId, body) {
|
|
1928
|
+
return this.http.request(
|
|
1929
|
+
"POST",
|
|
1930
|
+
`/tools/${toolId}/resolve-options`,
|
|
1931
|
+
{ body }
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* List the organization's skills — workflows, AI tasks, and collections.
|
|
1936
|
+
*
|
|
1937
|
+
* Skills are org-owned assets that can be attached to agents as tool
|
|
1938
|
+
* configurations of type WORKFLOW, TASK, or COLLECTION (as opposed to
|
|
1939
|
+
* marketplace PLUGIN tools).
|
|
1940
|
+
*
|
|
1941
|
+
* @param params - Optional type filter, search, and pagination.
|
|
1942
|
+
* @returns Matching skills and total count.
|
|
1943
|
+
*
|
|
1944
|
+
* @example
|
|
1945
|
+
* ```ts
|
|
1946
|
+
* // List all workflows
|
|
1947
|
+
* const { skills, total } = await client.tools.skills({ type: "WORKFLOW" });
|
|
1948
|
+
* console.log(`${total} workflows found`);
|
|
1949
|
+
*
|
|
1950
|
+
* // Search across all skill types
|
|
1951
|
+
* const result = await client.tools.skills({ search: "onboarding", limit: 10 });
|
|
1952
|
+
* ```
|
|
1953
|
+
*/
|
|
1954
|
+
async skills(params) {
|
|
1955
|
+
return this.http.request("GET", "/tools/skills", {
|
|
1956
|
+
query: params
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
/**
|
|
1960
|
+
* Test-execute a configured agent tool with sample input.
|
|
1961
|
+
*
|
|
1962
|
+
* This runs the tool using its saved configuration (action, credentials,
|
|
1963
|
+
* parameter setup) and returns the execution result. Use this to verify a
|
|
1964
|
+
* tool is correctly configured before deploying the agent.
|
|
1965
|
+
*
|
|
1966
|
+
* @param agentId - Agent UUID that owns the tool config.
|
|
1967
|
+
* @param toolConfigId - Agent tool configuration UUID (from `client.agents.tools.list()`).
|
|
1968
|
+
* @param body - Sample input values to pass to the tool.
|
|
1969
|
+
* @returns Execution result with status, output, and timing.
|
|
1970
|
+
*
|
|
1971
|
+
* @example
|
|
1972
|
+
* ```ts
|
|
1973
|
+
* const result = await client.tools.test("agent-uuid", "tool-config-uuid", {
|
|
1974
|
+
* input: { to: "test@example.com", subject: "Hello", body: "Test email" }
|
|
1975
|
+
* });
|
|
1976
|
+
* if (result.status === "success") {
|
|
1977
|
+
* console.log(`Executed in ${result.executionTimeMs}ms`, result.output);
|
|
1978
|
+
* } else {
|
|
1979
|
+
* console.error(`Tool error: ${result.error}`);
|
|
1980
|
+
* }
|
|
1981
|
+
* ```
|
|
1982
|
+
*/
|
|
1983
|
+
async test(agentId, toolConfigId, body) {
|
|
1984
|
+
return this.http.request(
|
|
1985
|
+
"POST",
|
|
1986
|
+
`/agents/${agentId}/tools/${toolConfigId}/test`,
|
|
1987
|
+
{ body }
|
|
1988
|
+
);
|
|
1989
|
+
}
|
|
1990
|
+
};
|
|
1991
|
+
var WorkflowExecutionsResource = class extends BaseResource {
|
|
1992
|
+
async list(params) {
|
|
1993
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/workflows/executions", {
|
|
1994
|
+
query: params
|
|
1995
|
+
});
|
|
1996
|
+
return { data, meta };
|
|
1997
|
+
}
|
|
1998
|
+
async listByWorkflow(workflowId, params) {
|
|
1999
|
+
const { data, meta } = await this.http.requestWithMeta(
|
|
2000
|
+
"GET",
|
|
2001
|
+
`/workflows/${workflowId}/executions`,
|
|
2002
|
+
{
|
|
2003
|
+
query: params
|
|
2004
|
+
}
|
|
2005
|
+
);
|
|
2006
|
+
return { data, meta };
|
|
2007
|
+
}
|
|
2008
|
+
async get(executionId) {
|
|
2009
|
+
return this.http.request("GET", `/workflows/executions/${executionId}`);
|
|
2010
|
+
}
|
|
2011
|
+
async getGraph(executionId) {
|
|
2012
|
+
return this.http.request("GET", `/workflows/executions/${executionId}/graph`);
|
|
2013
|
+
}
|
|
2014
|
+
async getNodeResult(executionId, nodeId) {
|
|
2015
|
+
return this.http.request("GET", `/workflows/executions/${executionId}/nodes/${nodeId}`);
|
|
2016
|
+
}
|
|
2017
|
+
async getOutput(executionId) {
|
|
2018
|
+
return this.http.request("GET", `/workflows/executions/${executionId}/output`);
|
|
2019
|
+
}
|
|
2020
|
+
async retryNode(executionId, nodeId) {
|
|
2021
|
+
return this.http.request(
|
|
2022
|
+
"POST",
|
|
2023
|
+
`/workflows/executions/${executionId}/nodes/${nodeId}/retry`
|
|
2024
|
+
);
|
|
2025
|
+
}
|
|
2026
|
+
async export(executionId) {
|
|
2027
|
+
return this.http.request("POST", `/workflows/executions/${executionId}/export`);
|
|
2028
|
+
}
|
|
2029
|
+
};
|
|
2030
|
+
var WorkflowsResource = class extends BaseResource {
|
|
2031
|
+
// =========================================================================
|
|
2032
|
+
// CRUD
|
|
2033
|
+
// =========================================================================
|
|
2034
|
+
/**
|
|
2035
|
+
* List workflows with optional filtering and pagination.
|
|
2036
|
+
*
|
|
2037
|
+
* @param params - Optional status filter, search, and pagination.
|
|
2038
|
+
* @returns Paginated list of workflow summaries.
|
|
2039
|
+
*/
|
|
2040
|
+
async list(params) {
|
|
2041
|
+
const { data, meta } = await this.http.requestWithMeta("GET", "/workflows", {
|
|
2042
|
+
query: params
|
|
2043
|
+
});
|
|
2044
|
+
return { data, meta };
|
|
2045
|
+
}
|
|
2046
|
+
/**
|
|
2047
|
+
* Create a new workflow.
|
|
2048
|
+
*
|
|
2049
|
+
* @param body - Workflow name and optional description.
|
|
2050
|
+
* @returns The created workflow detail.
|
|
2051
|
+
*/
|
|
2052
|
+
async create(body) {
|
|
2053
|
+
return this.http.request("POST", "/workflows", { body });
|
|
2054
|
+
}
|
|
2055
|
+
/**
|
|
2056
|
+
* Get detailed information about a specific workflow, including nodes and edges.
|
|
2057
|
+
*
|
|
2058
|
+
* @param workflowId - Workflow UUID.
|
|
2059
|
+
* @returns Full workflow detail.
|
|
2060
|
+
*/
|
|
2061
|
+
async get(workflowId) {
|
|
2062
|
+
return this.http.request("GET", `/workflows/${workflowId}`);
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Update an existing workflow's properties. Only provided fields are updated.
|
|
2066
|
+
*
|
|
2067
|
+
* @param workflowId - Workflow UUID.
|
|
2068
|
+
* @param body - Fields to update.
|
|
2069
|
+
* @returns The updated workflow detail.
|
|
2070
|
+
*/
|
|
2071
|
+
async update(workflowId, body) {
|
|
2072
|
+
return this.http.request("PATCH", `/workflows/${workflowId}`, { body });
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Permanently delete a workflow and all its nodes, edges, and executions.
|
|
2076
|
+
*
|
|
2077
|
+
* @param workflowId - Workflow UUID.
|
|
2078
|
+
* @returns Confirmation with the deleted workflow's ID.
|
|
2079
|
+
*/
|
|
2080
|
+
async delete(workflowId) {
|
|
2081
|
+
return this.http.request("DELETE", `/workflows/${workflowId}`);
|
|
2082
|
+
}
|
|
2083
|
+
/**
|
|
2084
|
+
* Create a copy of an existing workflow.
|
|
2085
|
+
*
|
|
2086
|
+
* @param workflowId - Workflow UUID to duplicate.
|
|
2087
|
+
* @returns The newly created workflow detail.
|
|
2088
|
+
*/
|
|
2089
|
+
async duplicate(workflowId) {
|
|
2090
|
+
return this.http.request("POST", `/workflows/${workflowId}/duplicate`);
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Publish a workflow, making it available for execution.
|
|
2094
|
+
*
|
|
2095
|
+
* @param workflowId - Workflow UUID.
|
|
2096
|
+
* @returns Publish confirmation with updated status.
|
|
2097
|
+
*/
|
|
2098
|
+
async publish(workflowId) {
|
|
2099
|
+
return this.http.request("POST", `/workflows/${workflowId}/publish`);
|
|
2100
|
+
}
|
|
2101
|
+
/**
|
|
2102
|
+
* Unpublish a workflow, reverting it to draft status.
|
|
2103
|
+
*
|
|
2104
|
+
* @param workflowId - Workflow UUID.
|
|
2105
|
+
* @returns Unpublish confirmation with updated status.
|
|
2106
|
+
*/
|
|
2107
|
+
async unpublish(workflowId) {
|
|
2108
|
+
return this.http.request("POST", `/workflows/${workflowId}/unpublish`);
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* Upload an icon image for a workflow.
|
|
2112
|
+
*
|
|
2113
|
+
* @param workflowId - Workflow UUID.
|
|
2114
|
+
* @param file - Image file as a Blob or File.
|
|
2115
|
+
* @returns URL of the uploaded icon.
|
|
2116
|
+
*/
|
|
2117
|
+
async uploadIcon(workflowId, file) {
|
|
2118
|
+
const formData = new FormData();
|
|
2119
|
+
formData.append("file", file);
|
|
2120
|
+
return this.http.request("POST", `/workflows/${workflowId}/icon`, {
|
|
2121
|
+
body: formData
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
// =========================================================================
|
|
2125
|
+
// BUILDER (Node Types)
|
|
2126
|
+
// =========================================================================
|
|
2127
|
+
/**
|
|
2128
|
+
* List all available node types for the workflow builder.
|
|
2129
|
+
*
|
|
2130
|
+
* @returns Array of node type summaries.
|
|
2131
|
+
*/
|
|
2132
|
+
async listNodeTypes() {
|
|
2133
|
+
return this.http.request("GET", "/workflows/node-types");
|
|
2134
|
+
}
|
|
2135
|
+
/**
|
|
2136
|
+
* Get the full schema for a specific node type, including fields and connection rules.
|
|
2137
|
+
*
|
|
2138
|
+
* @param nodeType - Node type identifier.
|
|
2139
|
+
* @returns Node type schema with fields, configuration steps, and defaults.
|
|
2140
|
+
*/
|
|
2141
|
+
async getNodeTypeSchema(nodeType) {
|
|
2142
|
+
return this.http.request("GET", `/workflows/node-types/${nodeType}`);
|
|
2143
|
+
}
|
|
2144
|
+
// =========================================================================
|
|
2145
|
+
// NODES
|
|
2146
|
+
// =========================================================================
|
|
2147
|
+
/**
|
|
2148
|
+
* Create a new node in a workflow.
|
|
2149
|
+
*
|
|
2150
|
+
* @param workflowId - Workflow UUID.
|
|
2151
|
+
* @param body - Node type, position, data, and optional parent.
|
|
2152
|
+
* @returns The created node.
|
|
2153
|
+
*/
|
|
2154
|
+
async createNode(workflowId, body) {
|
|
2155
|
+
return this.http.request("POST", `/workflows/${workflowId}/nodes`, { body });
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Get a specific node within a workflow.
|
|
2159
|
+
*
|
|
2160
|
+
* @param workflowId - Workflow UUID.
|
|
2161
|
+
* @param nodeId - Node UUID.
|
|
2162
|
+
* @returns The node detail.
|
|
2163
|
+
*/
|
|
2164
|
+
async getNode(workflowId, nodeId) {
|
|
2165
|
+
return this.http.request("GET", `/workflows/${workflowId}/nodes/${nodeId}`);
|
|
2166
|
+
}
|
|
2167
|
+
/**
|
|
2168
|
+
* Update a node's data. Only the `data` field is replaced.
|
|
2169
|
+
*
|
|
2170
|
+
* @param workflowId - Workflow UUID.
|
|
2171
|
+
* @param nodeId - Node UUID.
|
|
2172
|
+
* @param body - New data for the node.
|
|
2173
|
+
* @returns The updated node.
|
|
2174
|
+
*/
|
|
2175
|
+
async updateNode(workflowId, nodeId, body) {
|
|
2176
|
+
return this.http.request("PATCH", `/workflows/${workflowId}/nodes/${nodeId}`, {
|
|
2177
|
+
body
|
|
2178
|
+
});
|
|
2179
|
+
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Delete a node from a workflow. Connected edges are also removed.
|
|
2182
|
+
*
|
|
2183
|
+
* @param workflowId - Workflow UUID.
|
|
2184
|
+
* @param nodeId - Node UUID.
|
|
2185
|
+
* @returns Confirmation with the deleted node's ID.
|
|
2186
|
+
*/
|
|
2187
|
+
async deleteNode(workflowId, nodeId) {
|
|
2188
|
+
return this.http.request("DELETE", `/workflows/${workflowId}/nodes/${nodeId}`);
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Reload dynamic properties for a node (e.g. after selecting a tool or action).
|
|
2192
|
+
*
|
|
2193
|
+
* @param workflowId - Workflow UUID.
|
|
2194
|
+
* @param nodeId - Node UUID.
|
|
2195
|
+
* @param body - Currently configured props and optional dynamic props ID.
|
|
2196
|
+
* @returns Updated parameters setup and any errors.
|
|
2197
|
+
*/
|
|
2198
|
+
async reloadProps(workflowId, nodeId, body) {
|
|
2199
|
+
return this.http.request(
|
|
2200
|
+
"POST",
|
|
2201
|
+
`/workflows/${workflowId}/nodes/${nodeId}/reload-props`,
|
|
2202
|
+
{ body }
|
|
2203
|
+
);
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Replace the trigger node of a workflow with a different trigger type.
|
|
2207
|
+
*
|
|
2208
|
+
* @param workflowId - Workflow UUID.
|
|
2209
|
+
* @param body - New trigger type.
|
|
2210
|
+
* @returns The updated workflow detail.
|
|
2211
|
+
*/
|
|
2212
|
+
async replaceTrigger(workflowId, body) {
|
|
2213
|
+
return this.http.request("PUT", `/workflows/${workflowId}/trigger`, { body });
|
|
2214
|
+
}
|
|
2215
|
+
// =========================================================================
|
|
2216
|
+
// BRANCHES
|
|
2217
|
+
// =========================================================================
|
|
2218
|
+
/**
|
|
2219
|
+
* List branches on a conditional or router node.
|
|
2220
|
+
*
|
|
2221
|
+
* @param workflowId - Workflow UUID.
|
|
2222
|
+
* @param nodeId - Node UUID.
|
|
2223
|
+
* @returns Array of branches.
|
|
2224
|
+
*/
|
|
2225
|
+
async listBranches(workflowId, nodeId) {
|
|
2226
|
+
return this.http.request("GET", `/workflows/${workflowId}/nodes/${nodeId}/branches`);
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Create a new branch on a conditional or router node.
|
|
2230
|
+
*
|
|
2231
|
+
* @param workflowId - Workflow UUID.
|
|
2232
|
+
* @param nodeId - Node UUID.
|
|
2233
|
+
* @param body - Branch name and optional description.
|
|
2234
|
+
* @returns The created branch.
|
|
2235
|
+
*/
|
|
2236
|
+
async createBranch(workflowId, nodeId, body) {
|
|
2237
|
+
return this.http.request("POST", `/workflows/${workflowId}/nodes/${nodeId}/branches`, {
|
|
2238
|
+
body
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2241
|
+
/**
|
|
2242
|
+
* Update a branch on a node.
|
|
2243
|
+
*
|
|
2244
|
+
* @param workflowId - Workflow UUID.
|
|
2245
|
+
* @param nodeId - Node UUID.
|
|
2246
|
+
* @param branchId - Branch UUID.
|
|
2247
|
+
* @param body - Fields to update.
|
|
2248
|
+
* @returns The updated branch.
|
|
2249
|
+
*/
|
|
2250
|
+
async updateBranch(workflowId, nodeId, branchId, body) {
|
|
2251
|
+
return this.http.request(
|
|
2252
|
+
"PATCH",
|
|
2253
|
+
`/workflows/${workflowId}/nodes/${nodeId}/branches/${branchId}`,
|
|
2254
|
+
{ body }
|
|
2255
|
+
);
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* Delete a branch from a node.
|
|
2259
|
+
*
|
|
2260
|
+
* @param workflowId - Workflow UUID.
|
|
2261
|
+
* @param nodeId - Node UUID.
|
|
2262
|
+
* @param branchId - Branch UUID.
|
|
2263
|
+
* @returns Confirmation with the deleted branch's ID.
|
|
2264
|
+
*/
|
|
2265
|
+
async deleteBranch(workflowId, nodeId, branchId) {
|
|
2266
|
+
return this.http.request(
|
|
2267
|
+
"DELETE",
|
|
2268
|
+
`/workflows/${workflowId}/nodes/${nodeId}/branches/${branchId}`
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2271
|
+
// =========================================================================
|
|
2272
|
+
// EDGES
|
|
2273
|
+
// =========================================================================
|
|
2274
|
+
/**
|
|
2275
|
+
* Create an edge between two nodes in a workflow.
|
|
2276
|
+
*
|
|
2277
|
+
* @param workflowId - Workflow UUID.
|
|
2278
|
+
* @param body - Source node, target node, optional handle and type.
|
|
2279
|
+
* @returns The created edge.
|
|
2280
|
+
*/
|
|
2281
|
+
async createEdge(workflowId, body) {
|
|
2282
|
+
return this.http.request("POST", `/workflows/${workflowId}/edges`, { body });
|
|
2283
|
+
}
|
|
2284
|
+
/**
|
|
2285
|
+
* Delete an edge from a workflow.
|
|
2286
|
+
*
|
|
2287
|
+
* @param workflowId - Workflow UUID.
|
|
2288
|
+
* @param edgeId - Edge UUID.
|
|
2289
|
+
* @returns Confirmation with the deleted edge's ID.
|
|
2290
|
+
*/
|
|
2291
|
+
async deleteEdge(workflowId, edgeId) {
|
|
2292
|
+
return this.http.request("DELETE", `/workflows/${workflowId}/edges/${edgeId}`);
|
|
2293
|
+
}
|
|
2294
|
+
// =========================================================================
|
|
2295
|
+
// OVERVIEW
|
|
2296
|
+
// =========================================================================
|
|
2297
|
+
/**
|
|
2298
|
+
* Get a high-level overview of a workflow with node summaries.
|
|
2299
|
+
*
|
|
2300
|
+
* @param workflowId - Workflow UUID.
|
|
2301
|
+
* @returns Workflow overview with node labels and config statuses.
|
|
2302
|
+
*/
|
|
2303
|
+
async getOverview(workflowId) {
|
|
2304
|
+
return this.http.request("GET", `/workflows/${workflowId}/overview`);
|
|
2305
|
+
}
|
|
2306
|
+
/**
|
|
2307
|
+
* Auto-layout the nodes in a workflow graph.
|
|
2308
|
+
*
|
|
2309
|
+
* @param workflowId - Workflow UUID.
|
|
2310
|
+
* @returns The updated workflow detail with new node positions.
|
|
2311
|
+
*/
|
|
2312
|
+
async layout(workflowId) {
|
|
2313
|
+
return this.http.request("POST", `/workflows/${workflowId}/layout`);
|
|
2314
|
+
}
|
|
2315
|
+
/**
|
|
2316
|
+
* Get variables available to a specific node from upstream nodes.
|
|
2317
|
+
*
|
|
2318
|
+
* @param workflowId - Workflow UUID.
|
|
2319
|
+
* @param nodeId - Node UUID.
|
|
2320
|
+
* @returns Array of available variables grouped by source node.
|
|
2321
|
+
*/
|
|
2322
|
+
async getAvailableVariables(workflowId, nodeId) {
|
|
2323
|
+
return this.http.request(
|
|
2324
|
+
"GET",
|
|
2325
|
+
`/workflows/${workflowId}/nodes/${nodeId}/available-variables`
|
|
2326
|
+
);
|
|
2327
|
+
}
|
|
2328
|
+
/**
|
|
2329
|
+
* Get the output format definition for a specific node.
|
|
2330
|
+
*
|
|
2331
|
+
* @param workflowId - Workflow UUID.
|
|
2332
|
+
* @param nodeId - Node UUID.
|
|
2333
|
+
* @returns Output format with source indicator.
|
|
2334
|
+
*/
|
|
2335
|
+
async getOutputFormat(workflowId, nodeId) {
|
|
2336
|
+
return this.http.request(
|
|
2337
|
+
"GET",
|
|
2338
|
+
`/workflows/${workflowId}/nodes/${nodeId}/output-format`
|
|
2339
|
+
);
|
|
2340
|
+
}
|
|
2341
|
+
/**
|
|
2342
|
+
* Validate a workflow for completeness and correctness.
|
|
2343
|
+
*
|
|
2344
|
+
* @param workflowId - Workflow UUID.
|
|
2345
|
+
* @returns Validation report with node issues and graph issues.
|
|
2346
|
+
*/
|
|
2347
|
+
async validate(workflowId) {
|
|
2348
|
+
return this.http.request("GET", `/workflows/${workflowId}/validate`);
|
|
2349
|
+
}
|
|
2350
|
+
// =========================================================================
|
|
2351
|
+
// TESTING
|
|
2352
|
+
// =========================================================================
|
|
2353
|
+
/**
|
|
2354
|
+
* Test-execute a single node with optional input.
|
|
2355
|
+
*
|
|
2356
|
+
* @param workflowId - Workflow UUID.
|
|
2357
|
+
* @param nodeId - Node UUID.
|
|
2358
|
+
* @param body - Optional input data for the node.
|
|
2359
|
+
* @returns Execution ID for polling status.
|
|
2360
|
+
*/
|
|
2361
|
+
async testNode(workflowId, nodeId, body) {
|
|
2362
|
+
return this.http.request("POST", `/workflows/${workflowId}/nodes/${nodeId}/test`, {
|
|
2363
|
+
body
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
/**
|
|
2367
|
+
* Test-execute an entire workflow with optional trigger data.
|
|
2368
|
+
*
|
|
2369
|
+
* @param workflowId - Workflow UUID.
|
|
2370
|
+
* @param body - Optional trigger data to start the workflow.
|
|
2371
|
+
* @returns Execution ID for polling status.
|
|
2372
|
+
*/
|
|
2373
|
+
async testWorkflow(workflowId, body) {
|
|
2374
|
+
return this.http.request("POST", `/workflows/${workflowId}/test`, { body });
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Get the status of a workflow execution.
|
|
2378
|
+
*
|
|
2379
|
+
* @param workflowId - Workflow UUID.
|
|
2380
|
+
* @param executionId - Execution UUID.
|
|
2381
|
+
* @returns Execution status with per-node statuses.
|
|
2382
|
+
*/
|
|
2383
|
+
async getExecutionStatus(workflowId, executionId) {
|
|
2384
|
+
return this.http.request(
|
|
2385
|
+
"GET",
|
|
2386
|
+
`/workflows/${workflowId}/executions/${executionId}`
|
|
2387
|
+
);
|
|
2388
|
+
}
|
|
2389
|
+
/**
|
|
2390
|
+
* Get the execution result for a specific node within a workflow execution.
|
|
2391
|
+
*
|
|
2392
|
+
* @param workflowId - Workflow UUID.
|
|
2393
|
+
* @param executionId - Execution UUID.
|
|
2394
|
+
* @param nodeId - Node UUID.
|
|
2395
|
+
* @returns Node execution result with input, output, and logs.
|
|
2396
|
+
*/
|
|
2397
|
+
async getNodeExecutionResult(workflowId, executionId, nodeId) {
|
|
2398
|
+
return this.http.request(
|
|
2399
|
+
"GET",
|
|
2400
|
+
`/workflows/${workflowId}/executions/${executionId}/nodes/${nodeId}`
|
|
2401
|
+
);
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* Stop a running workflow execution.
|
|
2405
|
+
*
|
|
2406
|
+
* @param workflowId - Workflow UUID.
|
|
2407
|
+
* @param executionId - Execution UUID.
|
|
2408
|
+
* @returns Updated execution status.
|
|
2409
|
+
*/
|
|
2410
|
+
async stopExecution(workflowId, executionId) {
|
|
2411
|
+
return this.http.request(
|
|
2412
|
+
"POST",
|
|
2413
|
+
`/workflows/${workflowId}/executions/${executionId}/stop`
|
|
2414
|
+
);
|
|
2415
|
+
}
|
|
2416
|
+
};
|
|
2417
|
+
function getEnv(key) {
|
|
2418
|
+
try {
|
|
2419
|
+
return typeof process !== "undefined" ? process.env[key] : void 0;
|
|
2420
|
+
} catch {
|
|
2421
|
+
return void 0;
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
var NexusClient = class {
|
|
2425
|
+
constructor(opts = {}) {
|
|
2426
|
+
const apiKey = opts.apiKey ?? getEnv("NEXUS_API_KEY");
|
|
2427
|
+
if (!apiKey) {
|
|
2428
|
+
throw new NexusError(
|
|
2429
|
+
"No API key provided. Pass `apiKey` in options or set the NEXUS_API_KEY environment variable."
|
|
2430
|
+
);
|
|
2431
|
+
}
|
|
2432
|
+
const baseUrl = opts.baseUrl ?? getEnv("NEXUS_BASE_URL") ?? "https://api.nexusgpt.io";
|
|
2433
|
+
const http = new HttpClient({
|
|
2434
|
+
baseUrl,
|
|
2435
|
+
apiKey,
|
|
2436
|
+
fetch: opts.fetch,
|
|
2437
|
+
defaultHeaders: opts.defaultHeaders,
|
|
2438
|
+
timeout: opts.timeout
|
|
2439
|
+
});
|
|
2440
|
+
this.agents = new AgentsResource(http);
|
|
2441
|
+
this.documents = new DocumentsResource(http);
|
|
2442
|
+
this.folders = new FoldersResource(http);
|
|
2443
|
+
this.me = new MeResource(http);
|
|
2444
|
+
this.models = new ModelsResource(http);
|
|
2445
|
+
this.customModels = new CustomModelsResource(http);
|
|
2446
|
+
this.tools = new ToolDiscoveryResource(http);
|
|
2447
|
+
this.skills = new SkillsResource(http);
|
|
2448
|
+
this.workflows = new WorkflowsResource(http);
|
|
2449
|
+
this.toolConnection = new ToolConnectionResource(http);
|
|
2450
|
+
this.deployments = new DeploymentsResource(http);
|
|
2451
|
+
this.emulator = new EmulatorResource(http);
|
|
2452
|
+
this.deploymentFolders = new DeploymentFoldersResource(http);
|
|
2453
|
+
this.documentTemplateFolders = new DocumentTemplateFoldersResource(http);
|
|
2454
|
+
this.analytics = new AnalyticsResource(http);
|
|
2455
|
+
this.agentCollections = new AgentCollectionsResource(http);
|
|
2456
|
+
this.workflowExecutions = new WorkflowExecutionsResource(http);
|
|
2457
|
+
this.evaluations = new EvaluationsResource(http);
|
|
2458
|
+
this.cloudImports = new CloudImportsResource(http);
|
|
2459
|
+
this.promptAssistant = new PromptAssistantResource(http);
|
|
2460
|
+
this.phoneNumbers = new PhoneNumbersResource(http);
|
|
2461
|
+
this.tickets = new TicketsResource(http);
|
|
2462
|
+
this.channels = new ChannelsResource(http);
|
|
2463
|
+
}
|
|
2464
|
+
};
|
|
249
2465
|
|
|
250
2466
|
// src/config.ts
|
|
251
2467
|
var import_node_fs = __toESM(require("fs"));
|
|
@@ -447,24 +2663,23 @@ var _lastResolved = null;
|
|
|
447
2663
|
function createClient(opts) {
|
|
448
2664
|
const resolved = resolveProfile(opts);
|
|
449
2665
|
_lastResolved = resolved;
|
|
450
|
-
return new
|
|
2666
|
+
return new NexusClient({
|
|
451
2667
|
apiKey: resolved.profile.apiKey,
|
|
452
2668
|
baseUrl: resolved.profile.baseUrl ?? resolveBaseUrl(opts?.baseUrl)
|
|
453
2669
|
});
|
|
454
2670
|
}
|
|
455
2671
|
|
|
456
2672
|
// src/errors.ts
|
|
457
|
-
var import_sdk2 = require("@agent-nexus/sdk");
|
|
458
2673
|
init_output();
|
|
459
2674
|
function handleError(err) {
|
|
460
|
-
if (err instanceof
|
|
2675
|
+
if (err instanceof NexusAuthenticationError) {
|
|
461
2676
|
printCliError(
|
|
462
2677
|
"Authentication failed \u2014 invalid or missing API key.",
|
|
463
2678
|
'Run "nexus auth login" to re-authenticate, or set NEXUS_API_KEY.'
|
|
464
2679
|
);
|
|
465
2680
|
return 1;
|
|
466
2681
|
}
|
|
467
|
-
if (err instanceof
|
|
2682
|
+
if (err instanceof NexusApiError) {
|
|
468
2683
|
if (err.status === 404) {
|
|
469
2684
|
printCliError(
|
|
470
2685
|
`Not found: ${err.message}`,
|
|
@@ -480,14 +2695,14 @@ function handleError(err) {
|
|
|
480
2695
|
}
|
|
481
2696
|
return 1;
|
|
482
2697
|
}
|
|
483
|
-
if (err instanceof
|
|
2698
|
+
if (err instanceof NexusConnectionError) {
|
|
484
2699
|
printCliError(
|
|
485
2700
|
"Could not reach the Nexus API.",
|
|
486
2701
|
"Check your network connection and base URL configuration."
|
|
487
2702
|
);
|
|
488
2703
|
return 1;
|
|
489
2704
|
}
|
|
490
|
-
if (err instanceof
|
|
2705
|
+
if (err instanceof NexusError) {
|
|
491
2706
|
printCliError(err.message);
|
|
492
2707
|
return 1;
|
|
493
2708
|
}
|
|
@@ -987,7 +3202,6 @@ Notes:
|
|
|
987
3202
|
}
|
|
988
3203
|
|
|
989
3204
|
// src/commands/api.ts
|
|
990
|
-
var import_sdk3 = require("@agent-nexus/sdk");
|
|
991
3205
|
init_output();
|
|
992
3206
|
function registerApiCommand(program2) {
|
|
993
3207
|
program2.command("api").description("Call any Nexus API endpoint directly").argument("<method>", "HTTP method (GET, POST, PATCH, PUT, DELETE)").argument("<path>", "API path relative to /api/public/v1 (e.g. /models)").option("--body <json>", "Request body as JSON string, .json file path, or '-' for stdin").option("--query <key=value...>", "Query parameters (repeatable)", collect, []).addHelpText(
|
|
@@ -1002,7 +3216,7 @@ Examples:
|
|
|
1002
3216
|
).action(async (method, path5, opts) => {
|
|
1003
3217
|
try {
|
|
1004
3218
|
const globals = program2.optsWithGlobals();
|
|
1005
|
-
const http = new
|
|
3219
|
+
const http = new HttpClient({
|
|
1006
3220
|
baseUrl: resolveBaseUrl(globals.baseUrl),
|
|
1007
3221
|
apiKey: resolveApiKey(globals.apiKey)
|
|
1008
3222
|
});
|
|
@@ -1295,63 +3509,224 @@ Notes:
|
|
|
1295
3509
|
Use "nexus auth pin <profile>" to pin a directory to a profile via .nexusrc.`
|
|
1296
3510
|
).action(() => {
|
|
1297
3511
|
try {
|
|
1298
|
-
const resolved = resolveProfile(program2.optsWithGlobals());
|
|
1299
|
-
const sourceExplanation = {
|
|
1300
|
-
flag: "--profile flag",
|
|
1301
|
-
env: "NEXUS_PROFILE environment variable",
|
|
1302
|
-
directory: `.nexusrc at ${resolved.rcPath}`,
|
|
1303
|
-
active: "active profile in config",
|
|
1304
|
-
default: 'fallback to "default" profile',
|
|
1305
|
-
override: "--api-key flag or NEXUS_API_KEY env"
|
|
1306
|
-
};
|
|
1307
|
-
const orgPart = resolved.profile.orgName ? ` (${resolved.profile.orgName})` : "";
|
|
1308
|
-
console.log(
|
|
1309
|
-
`Using profile ${color.cyan(`"${resolved.name}"`)}${orgPart} \u2014 ${color.dim(sourceExplanation[resolved.source])}`
|
|
1310
|
-
);
|
|
1311
|
-
console.log(
|
|
1312
|
-
` ${color.dim("key:")} ${resolved.profile.apiKey.slice(0, 8)}...${resolved.profile.apiKey.slice(-4)}`
|
|
1313
|
-
);
|
|
1314
|
-
console.log(` ${color.dim("api:")} ${resolved.profile.baseUrl ?? resolveBaseUrl()}`);
|
|
3512
|
+
const resolved = resolveProfile(program2.optsWithGlobals());
|
|
3513
|
+
const sourceExplanation = {
|
|
3514
|
+
flag: "--profile flag",
|
|
3515
|
+
env: "NEXUS_PROFILE environment variable",
|
|
3516
|
+
directory: `.nexusrc at ${resolved.rcPath}`,
|
|
3517
|
+
active: "active profile in config",
|
|
3518
|
+
default: 'fallback to "default" profile',
|
|
3519
|
+
override: "--api-key flag or NEXUS_API_KEY env"
|
|
3520
|
+
};
|
|
3521
|
+
const orgPart = resolved.profile.orgName ? ` (${resolved.profile.orgName})` : "";
|
|
3522
|
+
console.log(
|
|
3523
|
+
`Using profile ${color.cyan(`"${resolved.name}"`)}${orgPart} \u2014 ${color.dim(sourceExplanation[resolved.source])}`
|
|
3524
|
+
);
|
|
3525
|
+
console.log(
|
|
3526
|
+
` ${color.dim("key:")} ${resolved.profile.apiKey.slice(0, 8)}...${resolved.profile.apiKey.slice(-4)}`
|
|
3527
|
+
);
|
|
3528
|
+
console.log(` ${color.dim("api:")} ${resolved.profile.baseUrl ?? resolveBaseUrl()}`);
|
|
3529
|
+
} catch (err) {
|
|
3530
|
+
console.error(color.red("Error:") + " " + err.message);
|
|
3531
|
+
process.exitCode = 1;
|
|
3532
|
+
}
|
|
3533
|
+
});
|
|
3534
|
+
auth.command("whoami").description("Show current authentication status").addHelpText(
|
|
3535
|
+
"after",
|
|
3536
|
+
`
|
|
3537
|
+
Examples:
|
|
3538
|
+
$ nexus auth whoami`
|
|
3539
|
+
).action(async () => {
|
|
3540
|
+
try {
|
|
3541
|
+
const resolved = resolveProfile(program2.optsWithGlobals());
|
|
3542
|
+
const baseUrl = resolved.profile.baseUrl ?? resolveBaseUrl();
|
|
3543
|
+
const res = await fetch(`${baseUrl}/api/public/v1/agents?limit=1`, {
|
|
3544
|
+
headers: { "api-key": resolved.profile.apiKey, Accept: "application/json" }
|
|
3545
|
+
});
|
|
3546
|
+
if (!res.ok) {
|
|
3547
|
+
console.error(
|
|
3548
|
+
color.red("Error:") + " API key is invalid or expired. Run: nexus auth login"
|
|
3549
|
+
);
|
|
3550
|
+
process.exitCode = 1;
|
|
3551
|
+
return;
|
|
3552
|
+
}
|
|
3553
|
+
printSuccess("Authenticated.", {
|
|
3554
|
+
profile: resolved.name,
|
|
3555
|
+
...resolved.profile.orgName ? { organization: resolved.profile.orgName } : {},
|
|
3556
|
+
api: baseUrl,
|
|
3557
|
+
key: resolved.profile.apiKey.slice(0, 8) + "..." + resolved.profile.apiKey.slice(-4)
|
|
3558
|
+
});
|
|
3559
|
+
} catch (err) {
|
|
3560
|
+
console.error(color.red("Error:") + " Not logged in. Run: nexus auth login");
|
|
3561
|
+
process.exitCode = 1;
|
|
3562
|
+
}
|
|
3563
|
+
});
|
|
3564
|
+
}
|
|
3565
|
+
function openUrl(url) {
|
|
3566
|
+
const platform = process.platform;
|
|
3567
|
+
const cmd = platform === "darwin" ? "open" : platform === "win32" ? "start" : "xdg-open";
|
|
3568
|
+
(0, import_node_child_process.exec)(`${cmd} ${JSON.stringify(url)}`);
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
// src/commands/channel.ts
|
|
3572
|
+
var import_node_child_process2 = require("child_process");
|
|
3573
|
+
init_output();
|
|
3574
|
+
function openUrl2(url) {
|
|
3575
|
+
const platform = process.platform;
|
|
3576
|
+
const cmd = platform === "darwin" ? "open" : platform === "win32" ? "start" : "xdg-open";
|
|
3577
|
+
(0, import_node_child_process2.exec)(`${cmd} ${JSON.stringify(url)}`);
|
|
3578
|
+
}
|
|
3579
|
+
function registerChannelCommands(program2) {
|
|
3580
|
+
const channel = program2.command("channel").description("Set up deployment channels: connections, phone numbers, WhatsApp senders");
|
|
3581
|
+
channel.command("setup").description("Check or auto-provision channel setup prerequisites").requiredOption("--type <type>", "Deployment type (WHATSAPP, TWILIO_SMS, TWILIO_VOICE, EMBED, etc.)").option("--auto", "Auto-provision what is possible (e.g., create messaging connection)").option("--region <region>", "Region for auto-provisioning (us1 or ie1)", "us1").addHelpText(
|
|
3582
|
+
"after",
|
|
3583
|
+
`
|
|
3584
|
+
Examples:
|
|
3585
|
+
$ nexus channel setup --type WHATSAPP
|
|
3586
|
+
$ nexus channel setup --type WHATSAPP --auto
|
|
3587
|
+
$ nexus channel setup --type TWILIO_SMS --json`
|
|
3588
|
+
).action(async (opts) => {
|
|
3589
|
+
try {
|
|
3590
|
+
const client = createClient(program2.optsWithGlobals());
|
|
3591
|
+
let result;
|
|
3592
|
+
if (opts.auto) {
|
|
3593
|
+
result = await client.channels.autoProvision({
|
|
3594
|
+
type: opts.type,
|
|
3595
|
+
region: opts.region
|
|
3596
|
+
});
|
|
3597
|
+
} else {
|
|
3598
|
+
result = await client.channels.getSetupStatus(opts.type);
|
|
3599
|
+
}
|
|
3600
|
+
const data = result?.data ?? result;
|
|
3601
|
+
printTable(data.steps, [
|
|
3602
|
+
{ key: "step", label: "#", width: 3 },
|
|
3603
|
+
{ key: "label", label: "STEP", width: 25 },
|
|
3604
|
+
{ key: "status", label: "STATUS", width: 16 },
|
|
3605
|
+
{ key: "description", label: "DESCRIPTION", width: 45 }
|
|
3606
|
+
]);
|
|
3607
|
+
if (data.ready) {
|
|
3608
|
+
printSuccess("All prerequisites met. Ready to create deployment.");
|
|
3609
|
+
}
|
|
3610
|
+
} catch (err) {
|
|
3611
|
+
process.exitCode = handleError(err);
|
|
3612
|
+
}
|
|
3613
|
+
});
|
|
3614
|
+
channel.command("connect-waba").description("Open browser to connect your WhatsApp Business Account (Meta signup)").addHelpText(
|
|
3615
|
+
"after",
|
|
3616
|
+
`
|
|
3617
|
+
This step requires a browser \u2014 it cannot be done via API.
|
|
3618
|
+
Opens the Nexus dashboard where you can click "Connect with Meta"
|
|
3619
|
+
to link your WhatsApp Business Account.
|
|
3620
|
+
|
|
3621
|
+
Examples:
|
|
3622
|
+
$ nexus channel connect-waba`
|
|
3623
|
+
).action(async () => {
|
|
3624
|
+
try {
|
|
3625
|
+
const dashboardUrl = process.env.NEXUS_DASHBOARD_URL ?? "https://gpt.nexus";
|
|
3626
|
+
const url = `${dashboardUrl}/app/settings/phone-number`;
|
|
3627
|
+
console.log(`Opening ${color.cyan(url)} ...`);
|
|
3628
|
+
console.log("");
|
|
3629
|
+
console.log('Complete the "Connect with Meta" flow in your browser, then verify:');
|
|
3630
|
+
console.log(` ${color.dim("nexus channel setup --type WHATSAPP")}`);
|
|
3631
|
+
openUrl2(url);
|
|
3632
|
+
} catch (err) {
|
|
3633
|
+
process.exitCode = handleError(err);
|
|
3634
|
+
}
|
|
3635
|
+
});
|
|
3636
|
+
const connection = channel.command("connection").description("Manage messaging connections");
|
|
3637
|
+
connection.command("list").description("List messaging connections").action(async () => {
|
|
3638
|
+
try {
|
|
3639
|
+
const client = createClient(program2.optsWithGlobals());
|
|
3640
|
+
const result = await client.channels.listConnections();
|
|
3641
|
+
const data = result?.data ?? result;
|
|
3642
|
+
printTable(Array.isArray(data) ? data : [data], [
|
|
3643
|
+
{ key: "id", label: "ID", width: 38 },
|
|
3644
|
+
{ key: "name", label: "NAME", width: 20 },
|
|
3645
|
+
{ key: "region", label: "REGION", width: 8 },
|
|
3646
|
+
{ key: "status", label: "STATUS", width: 12 }
|
|
3647
|
+
]);
|
|
3648
|
+
} catch (err) {
|
|
3649
|
+
process.exitCode = handleError(err);
|
|
3650
|
+
}
|
|
3651
|
+
});
|
|
3652
|
+
connection.command("create").description("Create a messaging connection (max 1 per organization)").option("--region <region>", "Region: us1 or ie1", "us1").action(async (opts) => {
|
|
3653
|
+
try {
|
|
3654
|
+
const client = createClient(program2.optsWithGlobals());
|
|
3655
|
+
const result = await client.channels.createConnection({ region: opts.region });
|
|
3656
|
+
const data = result?.data ?? result;
|
|
3657
|
+
printRecord(data, [
|
|
3658
|
+
{ key: "id", label: "ID" },
|
|
3659
|
+
{ key: "name", label: "Name" },
|
|
3660
|
+
{ key: "accountSid", label: "Account SID" },
|
|
3661
|
+
{ key: "region", label: "Region" },
|
|
3662
|
+
{ key: "status", label: "Status" }
|
|
3663
|
+
]);
|
|
3664
|
+
printSuccess("Messaging connection created.");
|
|
3665
|
+
} catch (err) {
|
|
3666
|
+
process.exitCode = handleError(err);
|
|
3667
|
+
}
|
|
3668
|
+
});
|
|
3669
|
+
const waSender = channel.command("whatsapp-sender").description("Manage WhatsApp senders");
|
|
3670
|
+
waSender.command("list").description("List WhatsApp senders").action(async () => {
|
|
3671
|
+
try {
|
|
3672
|
+
const client = createClient(program2.optsWithGlobals());
|
|
3673
|
+
const result = await client.channels.listWhatsAppSenders();
|
|
3674
|
+
const data = result?.data ?? result;
|
|
3675
|
+
printTable(Array.isArray(data) ? data : [data], [
|
|
3676
|
+
{ key: "id", label: "ID", width: 38 },
|
|
3677
|
+
{ key: "name", label: "NAME", width: 20 },
|
|
3678
|
+
{ key: "status", label: "STATUS", width: 10 },
|
|
3679
|
+
{ key: "phoneNumberId", label: "PHONE NUMBER ID", width: 38 }
|
|
3680
|
+
]);
|
|
1315
3681
|
} catch (err) {
|
|
1316
|
-
|
|
1317
|
-
process.exitCode = 1;
|
|
3682
|
+
process.exitCode = handleError(err);
|
|
1318
3683
|
}
|
|
1319
3684
|
});
|
|
1320
|
-
|
|
3685
|
+
waSender.command("create").description("Create a WhatsApp sender (registers phone with WhatsApp Business)").requiredOption("--connection-id <id>", "Messaging connection ID").requiredOption("--phone-number-id <id>", "Phone number ID").requiredOption("--sender-name <name>", "Display name for the WhatsApp sender").option("--waba-id <id>", "WhatsApp Business Account ID (reads from connection if omitted)").addHelpText(
|
|
1321
3686
|
"after",
|
|
1322
3687
|
`
|
|
1323
3688
|
Examples:
|
|
1324
|
-
$ nexus
|
|
1325
|
-
|
|
3689
|
+
$ nexus channel whatsapp-sender create --connection-id abc --phone-number-id def --sender-name "My Business"
|
|
3690
|
+
$ nexus channel whatsapp-sender create --connection-id abc --phone-number-id def --sender-name "EU Support" --json`
|
|
3691
|
+
).action(async (opts) => {
|
|
1326
3692
|
try {
|
|
1327
|
-
const
|
|
1328
|
-
const
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
console.error(
|
|
1334
|
-
color.red("Error:") + " API key is invalid or expired. Run: nexus auth login"
|
|
1335
|
-
);
|
|
1336
|
-
process.exitCode = 1;
|
|
1337
|
-
return;
|
|
1338
|
-
}
|
|
1339
|
-
printSuccess("Authenticated.", {
|
|
1340
|
-
profile: resolved.name,
|
|
1341
|
-
...resolved.profile.orgName ? { organization: resolved.profile.orgName } : {},
|
|
1342
|
-
api: baseUrl,
|
|
1343
|
-
key: resolved.profile.apiKey.slice(0, 8) + "..." + resolved.profile.apiKey.slice(-4)
|
|
3693
|
+
const client = createClient(program2.optsWithGlobals());
|
|
3694
|
+
const result = await client.channels.createWhatsAppSender({
|
|
3695
|
+
connectionId: opts.connectionId,
|
|
3696
|
+
phoneNumberId: opts.phoneNumberId,
|
|
3697
|
+
senderName: opts.senderName,
|
|
3698
|
+
wabaId: opts.wabaId
|
|
1344
3699
|
});
|
|
3700
|
+
const data = result?.data ?? result;
|
|
3701
|
+
printRecord(data, [
|
|
3702
|
+
{ key: "id", label: "ID" },
|
|
3703
|
+
{ key: "senderId", label: "Sender ID" },
|
|
3704
|
+
{ key: "name", label: "Name" },
|
|
3705
|
+
{ key: "wabaId", label: "WABA ID" },
|
|
3706
|
+
{ key: "phoneNumberId", label: "Phone Number ID" }
|
|
3707
|
+
]);
|
|
3708
|
+
printSuccess("WhatsApp sender created. Status may be OFFLINE while Meta approves.");
|
|
1345
3709
|
} catch (err) {
|
|
1346
|
-
|
|
1347
|
-
|
|
3710
|
+
process.exitCode = handleError(err);
|
|
3711
|
+
}
|
|
3712
|
+
});
|
|
3713
|
+
waSender.command("get").description("Get WhatsApp sender details").argument("<id>", "Sender ID").action(async (id) => {
|
|
3714
|
+
try {
|
|
3715
|
+
const client = createClient(program2.optsWithGlobals());
|
|
3716
|
+
const result = await client.channels.getWhatsAppSender(id);
|
|
3717
|
+
const data = result?.data ?? result;
|
|
3718
|
+
printRecord(data, [
|
|
3719
|
+
{ key: "id", label: "ID" },
|
|
3720
|
+
{ key: "senderId", label: "Sender ID" },
|
|
3721
|
+
{ key: "name", label: "Name" },
|
|
3722
|
+
{ key: "status", label: "Status" },
|
|
3723
|
+
{ key: "wabaId", label: "WABA ID" },
|
|
3724
|
+
{ key: "phoneNumberId", label: "Phone Number ID" }
|
|
3725
|
+
]);
|
|
3726
|
+
} catch (err) {
|
|
3727
|
+
process.exitCode = handleError(err);
|
|
1348
3728
|
}
|
|
1349
3729
|
});
|
|
1350
|
-
}
|
|
1351
|
-
function openUrl(url) {
|
|
1352
|
-
const platform = process.platform;
|
|
1353
|
-
const cmd = platform === "darwin" ? "open" : platform === "win32" ? "start" : "xdg-open";
|
|
1354
|
-
(0, import_node_child_process.exec)(`${cmd} ${JSON.stringify(url)}`);
|
|
1355
3730
|
}
|
|
1356
3731
|
|
|
1357
3732
|
// src/commands/collection.ts
|
|
@@ -1588,6 +3963,145 @@ Examples:
|
|
|
1588
3963
|
});
|
|
1589
3964
|
}
|
|
1590
3965
|
|
|
3966
|
+
// src/commands/custom-model.ts
|
|
3967
|
+
init_output();
|
|
3968
|
+
function registerCustomModelCommands(program2) {
|
|
3969
|
+
const customModel = program2.command("custom-model").description("Manage custom AI models with OpenAI-compatible endpoints");
|
|
3970
|
+
customModel.command("list").description("List custom models").addHelpText(
|
|
3971
|
+
"after",
|
|
3972
|
+
`
|
|
3973
|
+
Examples:
|
|
3974
|
+
$ nexus custom-model list
|
|
3975
|
+
$ nexus custom-model list --json`
|
|
3976
|
+
).action(async () => {
|
|
3977
|
+
try {
|
|
3978
|
+
const client = createClient(program2.optsWithGlobals());
|
|
3979
|
+
const result = await client.customModels.list();
|
|
3980
|
+
const items = Array.isArray(result) ? result : result.data ?? result;
|
|
3981
|
+
printList(items, void 0, [
|
|
3982
|
+
{ key: "id", label: "ID", width: 36 },
|
|
3983
|
+
{ key: "displayName", label: "NAME", width: 25 },
|
|
3984
|
+
{ key: "modelName", label: "MODEL", width: 25 },
|
|
3985
|
+
{ key: "protocol", label: "PROTOCOL", width: 10 },
|
|
3986
|
+
{
|
|
3987
|
+
key: "enabled",
|
|
3988
|
+
label: "ENABLED",
|
|
3989
|
+
width: 8,
|
|
3990
|
+
format: (v) => v ? "yes" : "no"
|
|
3991
|
+
}
|
|
3992
|
+
]);
|
|
3993
|
+
} catch (err) {
|
|
3994
|
+
process.exitCode = handleError(err);
|
|
3995
|
+
}
|
|
3996
|
+
});
|
|
3997
|
+
customModel.command("get").description("Get custom model details").argument("<id>", "Custom model ID").addHelpText(
|
|
3998
|
+
"after",
|
|
3999
|
+
`
|
|
4000
|
+
Examples:
|
|
4001
|
+
$ nexus custom-model get cm-123
|
|
4002
|
+
$ nexus custom-model get cm-123 --json`
|
|
4003
|
+
).action(async (id) => {
|
|
4004
|
+
try {
|
|
4005
|
+
const client = createClient(program2.optsWithGlobals());
|
|
4006
|
+
const model = await client.customModels.get(id);
|
|
4007
|
+
printRecord(model, [
|
|
4008
|
+
{ key: "id", label: "ID" },
|
|
4009
|
+
{ key: "displayName", label: "Display Name" },
|
|
4010
|
+
{ key: "modelName", label: "Model Name" },
|
|
4011
|
+
{ key: "baseUrl", label: "Base URL" },
|
|
4012
|
+
{ key: "protocol", label: "Protocol" },
|
|
4013
|
+
{ key: "enabled", label: "Enabled", format: (v) => v ? "yes" : "no" },
|
|
4014
|
+
{ key: "createdAt", label: "Created" },
|
|
4015
|
+
{ key: "updatedAt", label: "Updated" }
|
|
4016
|
+
]);
|
|
4017
|
+
} catch (err) {
|
|
4018
|
+
process.exitCode = handleError(err);
|
|
4019
|
+
}
|
|
4020
|
+
});
|
|
4021
|
+
customModel.command("create").description("Create a custom model").requiredOption("--display-name <name>", "Human-readable display name").requiredOption("--model-name <name>", "API model ID (e.g. llama-3-70b)").requiredOption("--base-url <url>", "OpenAI-compatible API base URL (HTTPS)").requiredOption("--api-key <key>", "API key for the custom endpoint").option("--protocol <protocol>", "Inference protocol (default: openai)", "openai").option("--body <json>", "Request body as JSON, .json file, or '-' for stdin").addHelpText(
|
|
4022
|
+
"after",
|
|
4023
|
+
`
|
|
4024
|
+
Examples:
|
|
4025
|
+
$ nexus custom-model create --display-name "My LLaMA" --model-name llama-3-70b \\
|
|
4026
|
+
--base-url https://api.example.com/v1 --api-key sk-xxx
|
|
4027
|
+
$ nexus custom-model create --body '{"displayName":"My Model","modelName":"gpt-4","baseUrl":"https://api.example.com/v1","apiKey":"sk-xxx"}'`
|
|
4028
|
+
).action(async (opts) => {
|
|
4029
|
+
try {
|
|
4030
|
+
const client = createClient(program2.optsWithGlobals());
|
|
4031
|
+
const base = await resolveBody(opts.body);
|
|
4032
|
+
const body = mergeBodyWithFlags(base, {
|
|
4033
|
+
...opts.displayName !== void 0 && { displayName: opts.displayName },
|
|
4034
|
+
...opts.modelName !== void 0 && { modelName: opts.modelName },
|
|
4035
|
+
...opts.baseUrl !== void 0 && { baseUrl: opts.baseUrl },
|
|
4036
|
+
...opts.apiKey !== void 0 && { apiKey: opts.apiKey },
|
|
4037
|
+
...opts.protocol !== void 0 && { protocol: opts.protocol }
|
|
4038
|
+
});
|
|
4039
|
+
const model = await client.customModels.create(body);
|
|
4040
|
+
printSuccess("Custom model created.", {
|
|
4041
|
+
id: model.id,
|
|
4042
|
+
displayName: model.displayName
|
|
4043
|
+
});
|
|
4044
|
+
} catch (err) {
|
|
4045
|
+
process.exitCode = handleError(err);
|
|
4046
|
+
}
|
|
4047
|
+
});
|
|
4048
|
+
customModel.command("update").description("Update a custom model").argument("<id>", "Custom model ID").option("--display-name <name>", "Display name").option("--model-name <name>", "API model ID").option("--base-url <url>", "API base URL").option("--api-key <key>", "API key").option("--protocol <protocol>", "Inference protocol").option("--enabled <bool>", "Enable/disable (true/false)").option("--body <json>", "Request body as JSON, .json file, or '-' for stdin").addHelpText(
|
|
4049
|
+
"after",
|
|
4050
|
+
`
|
|
4051
|
+
Examples:
|
|
4052
|
+
$ nexus custom-model update cm-123 --display-name "Renamed Model"
|
|
4053
|
+
$ nexus custom-model update cm-123 --enabled false
|
|
4054
|
+
$ nexus custom-model update cm-123 --api-key sk-newkey`
|
|
4055
|
+
).action(async (id, opts) => {
|
|
4056
|
+
try {
|
|
4057
|
+
const client = createClient(program2.optsWithGlobals());
|
|
4058
|
+
const base = await resolveBody(opts.body);
|
|
4059
|
+
const flags = {};
|
|
4060
|
+
if (opts.displayName !== void 0) flags.displayName = opts.displayName;
|
|
4061
|
+
if (opts.modelName !== void 0) flags.modelName = opts.modelName;
|
|
4062
|
+
if (opts.baseUrl !== void 0) flags.baseUrl = opts.baseUrl;
|
|
4063
|
+
if (opts.apiKey !== void 0) flags.apiKey = opts.apiKey;
|
|
4064
|
+
if (opts.protocol !== void 0) flags.protocol = opts.protocol;
|
|
4065
|
+
if (opts.enabled !== void 0) flags.enabled = opts.enabled === "true";
|
|
4066
|
+
const body = mergeBodyWithFlags(base, flags);
|
|
4067
|
+
await client.customModels.update(id, body);
|
|
4068
|
+
printSuccess("Custom model updated.", { id });
|
|
4069
|
+
} catch (err) {
|
|
4070
|
+
process.exitCode = handleError(err);
|
|
4071
|
+
}
|
|
4072
|
+
});
|
|
4073
|
+
customModel.command("delete").description("Delete a custom model").argument("<id>", "Custom model ID").option("--yes", "Skip confirmation").addHelpText(
|
|
4074
|
+
"after",
|
|
4075
|
+
`
|
|
4076
|
+
Examples:
|
|
4077
|
+
$ nexus custom-model delete cm-123
|
|
4078
|
+
$ nexus custom-model delete cm-123 --yes`
|
|
4079
|
+
).action(async (id, opts) => {
|
|
4080
|
+
try {
|
|
4081
|
+
const client = createClient(program2.optsWithGlobals());
|
|
4082
|
+
if (!opts.yes && process.stdout.isTTY) {
|
|
4083
|
+
const readline2 = await import("readline/promises");
|
|
4084
|
+
const rl = readline2.createInterface({
|
|
4085
|
+
input: process.stdin,
|
|
4086
|
+
output: process.stdout
|
|
4087
|
+
});
|
|
4088
|
+
const answer = await rl.question(
|
|
4089
|
+
`Delete custom model ${id}? This cannot be undone. [y/N] `
|
|
4090
|
+
);
|
|
4091
|
+
rl.close();
|
|
4092
|
+
if (answer.toLowerCase() !== "y") {
|
|
4093
|
+
console.log("Aborted.");
|
|
4094
|
+
return;
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
await client.customModels.delete(id);
|
|
4098
|
+
printSuccess("Custom model deleted.", { id });
|
|
4099
|
+
} catch (err) {
|
|
4100
|
+
process.exitCode = handleError(err);
|
|
4101
|
+
}
|
|
4102
|
+
});
|
|
4103
|
+
}
|
|
4104
|
+
|
|
1591
4105
|
// src/commands/deployment.ts
|
|
1592
4106
|
init_output();
|
|
1593
4107
|
function registerDeploymentCommands(program2) {
|
|
@@ -2101,14 +4615,14 @@ nexus auth status
|
|
|
2101
4615
|
|
|
2102
4616
|
When determining which profile to use, the CLI checks (first match wins):
|
|
2103
4617
|
|
|
2104
|
-
| Priority | Source
|
|
2105
|
-
|
|
2106
|
-
| 1
|
|
2107
|
-
| 2
|
|
2108
|
-
| 3
|
|
2109
|
-
| 4
|
|
2110
|
-
| 5
|
|
2111
|
-
| 6
|
|
4618
|
+
| Priority | Source | Example |
|
|
4619
|
+
| -------- | --------------------------------------- | ------------------------------------------ |
|
|
4620
|
+
| 1 | \`--api-key\` flag or \`NEXUS_API_KEY\` env | Bypasses profiles entirely |
|
|
4621
|
+
| 2 | \`--profile\` flag | \`nexus agent list --profile work\` |
|
|
4622
|
+
| 3 | \`NEXUS_PROFILE\` env var | \`export NEXUS_PROFILE=work\` |
|
|
4623
|
+
| 4 | \`.nexusrc\` file | Walks up directory tree to find \`.nexusrc\` |
|
|
4624
|
+
| 5 | Active profile | Set by \`nexus auth switch\` |
|
|
4625
|
+
| 6 | \`"default"\` profile | Fallback |
|
|
2112
4626
|
|
|
2113
4627
|
#### Remove profiles
|
|
2114
4628
|
|
|
@@ -2178,13 +4692,13 @@ These flags are available on every command:
|
|
|
2178
4692
|
|
|
2179
4693
|
| Flag | Description |
|
|
2180
4694
|
| ------------------ | ------------------------------------------------- |
|
|
2181
|
-
| \`--json\`
|
|
2182
|
-
| \`--api-key <key>\`
|
|
2183
|
-
| \`--base-url <url>\`
|
|
2184
|
-
| \`--profile <name>\`
|
|
2185
|
-
| \`--no-auto-update\`
|
|
2186
|
-
| \`-v, --version\`
|
|
2187
|
-
| \`--help\`
|
|
4695
|
+
| \`--json\` | Output results as JSON (for scripting and piping) |
|
|
4696
|
+
| \`--api-key <key>\` | Override the API key for this invocation |
|
|
4697
|
+
| \`--base-url <url>\` | Override the API base URL |
|
|
4698
|
+
| \`--profile <name>\` | Use a specific named profile |
|
|
4699
|
+
| \`--no-auto-update\` | Disable automatic CLI updates for this invocation |
|
|
4700
|
+
| \`-v, --version\` | Print the CLI version and exit |
|
|
4701
|
+
| \`--help\` | Show help for any command or subcommand |
|
|
2188
4702
|
|
|
2189
4703
|
### Environment Variables
|
|
2190
4704
|
|
|
@@ -2333,14 +4847,14 @@ All commands follow the pattern: \`nexus <group> <action> [arguments] [options]\
|
|
|
2333
4847
|
|
|
2334
4848
|
### Core Platform
|
|
2335
4849
|
|
|
2336
|
-
| Command | Subcommands
|
|
2337
|
-
| ---------------------------------------------------------- |
|
|
4850
|
+
| Command | Subcommands | Description |
|
|
4851
|
+
| ---------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------- |
|
|
2338
4852
|
| [\`auth\`](docs/command-reference.md#nexus-auth) | \`login\` \`logout\` \`switch\` \`list\` \`pin\` \`unpin\` \`status\` \`whoami\` | Authentication |
|
|
2339
|
-
| [\`agent\`](docs/command-reference.md#nexus-agent) | \`list\` \`get\` \`create\` \`update\` \`delete\` \`duplicate\`
|
|
2340
|
-
| [\`agent-tool\`](docs/command-reference.md#nexus-agent-tool) | \`list\` \`get\` \`create\` \`update\` \`delete\`
|
|
2341
|
-
| [\`version\`](docs/command-reference.md#nexus-version) | \`list\` \`get\` \`create\` \`update\` \`delete\` \`restore\` \`publish\`
|
|
2342
|
-
| [\`folder\`](docs/command-reference.md#nexus-folder) | \`list\` \`create\` \`update\` \`delete\` \`assign\`
|
|
2343
|
-
| [\`model\`](docs/command-reference.md#nexus-model) | \`list\`
|
|
4853
|
+
| [\`agent\`](docs/command-reference.md#nexus-agent) | \`list\` \`get\` \`create\` \`update\` \`delete\` \`duplicate\` | AI agent management |
|
|
4854
|
+
| [\`agent-tool\`](docs/command-reference.md#nexus-agent-tool) | \`list\` \`get\` \`create\` \`update\` \`delete\` | Agent tool configurations |
|
|
4855
|
+
| [\`version\`](docs/command-reference.md#nexus-version) | \`list\` \`get\` \`create\` \`update\` \`delete\` \`restore\` \`publish\` | Prompt version management |
|
|
4856
|
+
| [\`folder\`](docs/command-reference.md#nexus-folder) | \`list\` \`create\` \`update\` \`delete\` \`assign\` | Agent folder organization |
|
|
4857
|
+
| [\`model\`](docs/command-reference.md#nexus-model) | \`list\` | Available AI models |
|
|
2344
4858
|
|
|
2345
4859
|
### Workflows & Execution
|
|
2346
4860
|
|
|
@@ -2391,15 +4905,16 @@ All commands follow the pattern: \`nexus <group> <action> [arguments] [options]\
|
|
|
2391
4905
|
| [\`eval\`](docs/command-reference.md#nexus-eval) | (subgroups: \`session\`, \`dataset\`, \`execute\`, \`judge\`, \`results\`, \`formats\`, \`judges\`) | AI task evaluation |
|
|
2392
4906
|
| [\`ticket\`](docs/command-reference.md#nexus-ticket) | \`list\` \`get\` \`create\` \`update\` \`comment\` \`comments\` | Bug and feature tracking |
|
|
2393
4907
|
| [\`phone-number\`](docs/command-reference.md#nexus-phone-number) | \`search\` \`buy\` \`list\` \`get\` \`release\` | Phone number management |
|
|
4908
|
+
| [\`channel\`](docs/command-reference.md#nexus-channel) | \`setup\` \`connection list\\|create\` \`whatsapp-sender list\\|create\\|get\` | Channel setup orchestrator |
|
|
2394
4909
|
| [\`prompt-assistant\`](docs/command-reference.md#nexus-prompt-assistant) | \`chat\` \`get-thread\` \`delete-thread\` | AI-assisted prompt writing |
|
|
2395
4910
|
|
|
2396
4911
|
### Utility
|
|
2397
4912
|
|
|
2398
|
-
| Command | Subcommands
|
|
2399
|
-
| ---------------------------------------------------- |
|
|
2400
|
-
| [\`api\`](docs/command-reference.md#nexus-api) | (passthrough)
|
|
4913
|
+
| Command | Subcommands | Description |
|
|
4914
|
+
| ---------------------------------------------------- | --------------- | ------------------------------ |
|
|
4915
|
+
| [\`api\`](docs/command-reference.md#nexus-api) | (passthrough) | Call any API endpoint directly |
|
|
2401
4916
|
| [\`docs\`](docs/command-reference.md#nexus-docs) | (topic browser) | View built-in documentation |
|
|
2402
|
-
| [\`upgrade\`](docs/command-reference.md#nexus-upgrade) | (self-update)
|
|
4917
|
+
| [\`upgrade\`](docs/command-reference.md#nexus-upgrade) | (self-update) | Upgrade the CLI to latest |
|
|
2403
4918
|
|
|
2404
4919
|
> **Full reference:** See [docs/command-reference.md](docs/command-reference.md) for complete documentation of every command, option, and example.
|
|
2405
4920
|
|
|
@@ -2521,6 +5036,9 @@ Every CLI command maps to an SDK method. Use the SDK (\`@agent-nexus/sdk\`) when
|
|
|
2521
5036
|
| \`nexus model list\` | \`client.models.list()\` |
|
|
2522
5037
|
| \`nexus ticket create --title X ...\` | \`client.tickets.create({ title: "X", ... })\` |
|
|
2523
5038
|
| \`nexus phone-number list\` | \`client.phoneNumbers.list()\` |
|
|
5039
|
+
| \`nexus channel setup --type WHATSAPP\` | \`client.channels.getSetupStatus("WHATSAPP")\` |
|
|
5040
|
+
| \`nexus channel connection create\` | \`client.channels.createConnection()\` |
|
|
5041
|
+
| \`nexus channel whatsapp-sender create\` | \`client.channels.createWhatsAppSender({ ... })\` |
|
|
2524
5042
|
|
|
2525
5043
|
> **Full SDK documentation:** See [@agent-nexus/sdk README](../sdk/README.md)
|
|
2526
5044
|
|
|
@@ -2625,11 +5143,11 @@ sudo npm install -g @agent-nexus/cli@latest
|
|
|
2625
5143
|
|
|
2626
5144
|
## Configuration Files
|
|
2627
5145
|
|
|
2628
|
-
| File
|
|
2629
|
-
|
|
2630
|
-
| \`~/.nexus-mcp/config.json\`
|
|
2631
|
-
| \`~/.nexus-mcp/version-check.json\` | Update check cache (auto-managed, checked once/day)
|
|
2632
|
-
| \`.nexusrc\`
|
|
5146
|
+
| File | Purpose | Permissions |
|
|
5147
|
+
| --------------------------------- | ------------------------------------------------------------- | ----------- |
|
|
5148
|
+
| \`~/.nexus-mcp/config.json\` | Profiles with API keys and base URLs | \`0600\` |
|
|
5149
|
+
| \`~/.nexus-mcp/version-check.json\` | Update check cache (auto-managed, checked once/day) | \`0600\` |
|
|
5150
|
+
| \`.nexusrc\` | Directory-level profile pinning (created by \`nexus auth pin\`) | \u2014 |
|
|
2633
5151
|
|
|
2634
5152
|
The \`~/.nexus-mcp/\` directory is created with \`0700\` permissions. This path is shared with the [\`@nexus/mcp-server\`](../mcp-server/) package.
|
|
2635
5153
|
|
|
@@ -2698,15 +5216,15 @@ Complete reference for all \`@agent-nexus/cli\` commands. For installation and c
|
|
|
2698
5216
|
|
|
2699
5217
|
These options are available on every command:
|
|
2700
5218
|
|
|
2701
|
-
| Option | Description
|
|
2702
|
-
| ------------------ |
|
|
2703
|
-
| \`--json\`
|
|
2704
|
-
| \`--api-key <key>\`
|
|
2705
|
-
| \`--base-url <url>\`
|
|
2706
|
-
| \`--profile <name>\`
|
|
2707
|
-
| \`--no-auto-update\`
|
|
2708
|
-
| \`-v, --version\`
|
|
2709
|
-
| \`--help\`
|
|
5219
|
+
| Option | Description |
|
|
5220
|
+
| ------------------ | ------------------------------------------------- |
|
|
5221
|
+
| \`--json\` | Output raw JSON instead of formatted tables |
|
|
5222
|
+
| \`--api-key <key>\` | Override API key for this invocation |
|
|
5223
|
+
| \`--base-url <url>\` | Override the API base URL |
|
|
5224
|
+
| \`--profile <name>\` | Use a specific named profile |
|
|
5225
|
+
| \`--no-auto-update\` | Disable automatic CLI updates for this invocation |
|
|
5226
|
+
| \`-v, --version\` | Print CLI version |
|
|
5227
|
+
| \`--help\` | Show help for any command |
|
|
2710
5228
|
|
|
2711
5229
|
---
|
|
2712
5230
|
|
|
@@ -2722,11 +5240,11 @@ Authenticate with the Nexus API and create a profile.
|
|
|
2722
5240
|
nexus auth login [options]
|
|
2723
5241
|
\`\`\`
|
|
2724
5242
|
|
|
2725
|
-
| Option
|
|
2726
|
-
|
|
2727
|
-
| \`--api-key <key>\`
|
|
2728
|
-
| \`--profile <name>\` | Profile name to save as
|
|
2729
|
-
| \`--env <env>\`
|
|
5243
|
+
| Option | Description |
|
|
5244
|
+
| ------------------ | ---------------------------------------------------------- |
|
|
5245
|
+
| \`--api-key <key>\` | API key (skip interactive prompt) |
|
|
5246
|
+
| \`--profile <name>\` | Profile name to save as |
|
|
5247
|
+
| \`--env <env>\` | Environment: \`dev\` or \`production\` (default: \`production\`) |
|
|
2730
5248
|
|
|
2731
5249
|
\`\`\`bash
|
|
2732
5250
|
nexus auth login
|
|
@@ -2743,12 +5261,12 @@ Remove stored credentials.
|
|
|
2743
5261
|
nexus auth logout [name] [options]
|
|
2744
5262
|
\`\`\`
|
|
2745
5263
|
|
|
2746
|
-
| Argument | Description
|
|
2747
|
-
|
|
2748
|
-
| \`name\`
|
|
5264
|
+
| Argument | Description |
|
|
5265
|
+
| -------- | ---------------------------------------------------- |
|
|
5266
|
+
| \`name\` | Specific profile to remove (default: active profile) |
|
|
2749
5267
|
|
|
2750
|
-
| Option
|
|
2751
|
-
|
|
5268
|
+
| Option | Description |
|
|
5269
|
+
| ------- | ------------------- |
|
|
2752
5270
|
| \`--all\` | Remove all profiles |
|
|
2753
5271
|
|
|
2754
5272
|
\`\`\`bash
|
|
@@ -3418,7 +5936,7 @@ nexus deployment list [options]
|
|
|
3418
5936
|
| Option | Description |
|
|
3419
5937
|
| ------------------ | --------------------------------------------- |
|
|
3420
5938
|
| \`--agent-id <id>\` | Filter by agent ID |
|
|
3421
|
-
| \`--type <type>\` | Filter by type (\`
|
|
5939
|
+
| \`--type <type>\` | Filter by type (\`EMBED\`, \`API\`, \`WHATSAPP\`, \`TWILIO_SMS\`, etc.) |
|
|
3422
5940
|
| \`--page <number>\` | Page number |
|
|
3423
5941
|
| \`--limit <number>\` | Items per page |
|
|
3424
5942
|
|
|
@@ -3457,21 +5975,31 @@ Create a new deployment.
|
|
|
3457
5975
|
nexus deployment create [options]
|
|
3458
5976
|
\`\`\`
|
|
3459
5977
|
|
|
3460
|
-
| Option | Required | Description
|
|
3461
|
-
| ---------------------- | -------- |
|
|
3462
|
-
| \`--
|
|
3463
|
-
| \`--
|
|
3464
|
-
| \`--
|
|
3465
|
-
| \`--description <text>\` | No | Deployment description
|
|
3466
|
-
| \`--body <json>\` | No | Request body as JSON, \`.json\` file, or \`-\` for stdin
|
|
5978
|
+
| Option | Required | Description |
|
|
5979
|
+
| ---------------------- | -------- | --------------------------------------------------------------------------- |
|
|
5980
|
+
| \`--name <name>\` | Yes | Deployment name |
|
|
5981
|
+
| \`--type <type>\` | Yes | Deployment type: \`EMBED\`, \`API\`, \`WHATSAPP\`, \`TWILIO_SMS\`, \`TWILIO_VOICE\`, \`TELEGRAM\`, \`SLACK\`, \`GMAIL\`, \`OUTLOOK\`, \`TEAMS\` |
|
|
5982
|
+
| \`--agent-id <id>\` | No | Agent ID |
|
|
5983
|
+
| \`--description <text>\` | No | Deployment description |
|
|
5984
|
+
| \`--body <json>\` | No | Request body as JSON, \`.json\` file, or \`-\` for stdin |
|
|
5985
|
+
|
|
5986
|
+
**Important:** Channel deployments (WhatsApp, SMS, Voice, etc.) have prerequisites. Run \`nexus channel setup --type <TYPE>\` first to see what's needed.
|
|
3467
5987
|
|
|
3468
5988
|
\`\`\`bash
|
|
3469
|
-
|
|
3470
|
-
nexus deployment create --
|
|
3471
|
-
nexus deployment create --
|
|
5989
|
+
# Simple deployments (no prerequisites)
|
|
5990
|
+
nexus deployment create --name "Website Chat" --type EMBED --agent-id agt-123
|
|
5991
|
+
nexus deployment create --name "Support API" --type API --agent-id agt-123
|
|
5992
|
+
|
|
5993
|
+
# Channel deployments (require connection + phone + optional sender)
|
|
5994
|
+
# First check prerequisites:
|
|
5995
|
+
nexus channel setup --type WHATSAPP
|
|
5996
|
+
|
|
5997
|
+
# Then create with connection fields via --body:
|
|
5998
|
+
nexus deployment create --name "WhatsApp Support" --type WHATSAPP --agent-id agt-123 \\
|
|
5999
|
+
--body '{"phoneNumberId":"phn-456","apiKeyConnectionId":"conn-789"}'
|
|
3472
6000
|
\`\`\`
|
|
3473
6001
|
|
|
3474
|
-
**SDK equivalent:** \`client.deployments.create({ agentId,
|
|
6002
|
+
**SDK equivalent:** \`client.deployments.create({ name, type, agentId, phoneNumberId, apiKeyConnectionId, ... })\`
|
|
3475
6003
|
|
|
3476
6004
|
### deployment update
|
|
3477
6005
|
|
|
@@ -6157,9 +8685,142 @@ nexus model list --search "gpt-4"
|
|
|
6157
8685
|
|
|
6158
8686
|
---
|
|
6159
8687
|
|
|
8688
|
+
## nexus channel
|
|
8689
|
+
|
|
8690
|
+
Set up deployment channels: connections, phone numbers, and WhatsApp senders. Use \`nexus channel setup\` to see what's needed before creating any non-EMBED/API deployment.
|
|
8691
|
+
|
|
8692
|
+
### channel setup
|
|
8693
|
+
|
|
8694
|
+
Check or auto-provision channel setup prerequisites. Returns a step-by-step checklist.
|
|
8695
|
+
|
|
8696
|
+
\`\`\`
|
|
8697
|
+
nexus channel setup [options]
|
|
8698
|
+
\`\`\`
|
|
8699
|
+
|
|
8700
|
+
| Option | Required | Description |
|
|
8701
|
+
| ----------------- | -------- | ---------------------------------------------------------------- |
|
|
8702
|
+
| \`--type <type>\` | Yes | Deployment type (\`WHATSAPP\`, \`TWILIO_SMS\`, \`TWILIO_VOICE\`, etc.) |
|
|
8703
|
+
| \`--auto\` | No | Auto-provision what is possible (e.g., create messaging connection) |
|
|
8704
|
+
| \`--region <region>\` | No | Region for auto-provisioning: \`us1\` or \`ie1\` (default: \`us1\`) |
|
|
8705
|
+
|
|
8706
|
+
\`\`\`bash
|
|
8707
|
+
nexus channel setup --type WHATSAPP
|
|
8708
|
+
nexus channel setup --type WHATSAPP --auto
|
|
8709
|
+
nexus channel setup --type TWILIO_SMS --json
|
|
8710
|
+
\`\`\`
|
|
8711
|
+
|
|
8712
|
+
**SDK equivalent:** \`client.channels.getSetupStatus(type)\` / \`client.channels.autoProvision({ type, region })\`
|
|
8713
|
+
|
|
8714
|
+
### channel connect-waba
|
|
8715
|
+
|
|
8716
|
+
Open the browser to connect your WhatsApp Business Account via Meta's Embedded Signup. This step **requires a browser** and cannot be done via API.
|
|
8717
|
+
|
|
8718
|
+
\`\`\`
|
|
8719
|
+
nexus channel connect-waba
|
|
8720
|
+
\`\`\`
|
|
8721
|
+
|
|
8722
|
+
Opens \`{NEXUS_DASHBOARD_URL}/app/settings/phone-number\` in your default browser. Complete the "Connect with Meta" flow, then verify with \`nexus channel setup --type WHATSAPP\`.
|
|
8723
|
+
|
|
8724
|
+
\`\`\`bash
|
|
8725
|
+
nexus channel connect-waba
|
|
8726
|
+
\`\`\`
|
|
8727
|
+
|
|
8728
|
+
**SDK equivalent:** N/A (browser-only step)
|
|
8729
|
+
|
|
8730
|
+
### channel connection list
|
|
8731
|
+
|
|
8732
|
+
List messaging connections for the organization.
|
|
8733
|
+
|
|
8734
|
+
\`\`\`
|
|
8735
|
+
nexus channel connection list
|
|
8736
|
+
\`\`\`
|
|
8737
|
+
|
|
8738
|
+
\`\`\`bash
|
|
8739
|
+
nexus channel connection list --json
|
|
8740
|
+
\`\`\`
|
|
8741
|
+
|
|
8742
|
+
**SDK equivalent:** \`client.channels.listConnections()\`
|
|
8743
|
+
|
|
8744
|
+
### channel connection create
|
|
8745
|
+
|
|
8746
|
+
Create a messaging connection (max 1 per organization via the API).
|
|
8747
|
+
|
|
8748
|
+
\`\`\`
|
|
8749
|
+
nexus channel connection create [options]
|
|
8750
|
+
\`\`\`
|
|
8751
|
+
|
|
8752
|
+
| Option | Description |
|
|
8753
|
+
| ------------------ | ------------------------------- |
|
|
8754
|
+
| \`--region <region>\` | Region: \`us1\` or \`ie1\` (default: \`us1\`) |
|
|
8755
|
+
|
|
8756
|
+
\`\`\`bash
|
|
8757
|
+
nexus channel connection create
|
|
8758
|
+
nexus channel connection create --region ie1 --json
|
|
8759
|
+
\`\`\`
|
|
8760
|
+
|
|
8761
|
+
**SDK equivalent:** \`client.channels.createConnection({ region })\`
|
|
8762
|
+
|
|
8763
|
+
### channel whatsapp-sender list
|
|
8764
|
+
|
|
8765
|
+
List WhatsApp senders for the organization.
|
|
8766
|
+
|
|
8767
|
+
\`\`\`
|
|
8768
|
+
nexus channel whatsapp-sender list
|
|
8769
|
+
\`\`\`
|
|
8770
|
+
|
|
8771
|
+
\`\`\`bash
|
|
8772
|
+
nexus channel whatsapp-sender list --json
|
|
8773
|
+
\`\`\`
|
|
8774
|
+
|
|
8775
|
+
**SDK equivalent:** \`client.channels.listWhatsAppSenders()\`
|
|
8776
|
+
|
|
8777
|
+
### channel whatsapp-sender create
|
|
8778
|
+
|
|
8779
|
+
Create a WhatsApp sender (registers a phone number with WhatsApp Business via Meta).
|
|
8780
|
+
|
|
8781
|
+
\`\`\`
|
|
8782
|
+
nexus channel whatsapp-sender create [options]
|
|
8783
|
+
\`\`\`
|
|
8784
|
+
|
|
8785
|
+
| Option | Required | Description |
|
|
8786
|
+
| -------------------------- | -------- | ----------------------------------------------------- |
|
|
8787
|
+
| \`--connection-id <id>\` | Yes | Messaging connection ID |
|
|
8788
|
+
| \`--phone-number-id <id>\` | Yes | Phone number ID |
|
|
8789
|
+
| \`--sender-name <name>\` | Yes | Display name for the WhatsApp sender |
|
|
8790
|
+
| \`--waba-id <id>\` | No | WhatsApp Business Account ID (reads from connection if omitted) |
|
|
8791
|
+
|
|
8792
|
+
\`\`\`bash
|
|
8793
|
+
nexus channel whatsapp-sender create \\
|
|
8794
|
+
--connection-id conn-123 \\
|
|
8795
|
+
--phone-number-id phn-456 \\
|
|
8796
|
+
--sender-name "My Business"
|
|
8797
|
+
\`\`\`
|
|
8798
|
+
|
|
8799
|
+
**SDK equivalent:** \`client.channels.createWhatsAppSender({ connectionId, phoneNumberId, senderName, wabaId })\`
|
|
8800
|
+
|
|
8801
|
+
### channel whatsapp-sender get
|
|
8802
|
+
|
|
8803
|
+
Get WhatsApp sender details including status.
|
|
8804
|
+
|
|
8805
|
+
\`\`\`
|
|
8806
|
+
nexus channel whatsapp-sender get <id>
|
|
8807
|
+
\`\`\`
|
|
8808
|
+
|
|
8809
|
+
| Argument | Description |
|
|
8810
|
+
| -------- | ----------- |
|
|
8811
|
+
| \`id\` | Sender ID |
|
|
8812
|
+
|
|
8813
|
+
\`\`\`bash
|
|
8814
|
+
nexus channel whatsapp-sender get sender-123 --json
|
|
8815
|
+
\`\`\`
|
|
8816
|
+
|
|
8817
|
+
**SDK equivalent:** \`client.channels.getWhatsAppSender(id)\`
|
|
8818
|
+
|
|
8819
|
+
---
|
|
8820
|
+
|
|
6160
8821
|
## nexus phone-number
|
|
6161
8822
|
|
|
6162
|
-
Manage phone numbers for
|
|
8823
|
+
Manage phone numbers for SMS, Voice, and WhatsApp deployments.
|
|
6163
8824
|
|
|
6164
8825
|
### phone-number search
|
|
6165
8826
|
|
|
@@ -6277,13 +8938,13 @@ View built-in CLI documentation.
|
|
|
6277
8938
|
nexus docs [topic] [options]
|
|
6278
8939
|
\`\`\`
|
|
6279
8940
|
|
|
6280
|
-
| Argument | Description
|
|
6281
|
-
|
|
6282
|
-
| \`topic\`
|
|
8941
|
+
| Argument | Description |
|
|
8942
|
+
| -------- | ---------------------------------------------------------------------------- |
|
|
8943
|
+
| \`topic\` | Specific topic: \`overview\`, \`commands\`, \`gotchas\`, \`input-output\`, \`recipes\` |
|
|
6283
8944
|
|
|
6284
|
-
| Option
|
|
6285
|
-
|
|
6286
|
-
| \`--list\`
|
|
8945
|
+
| Option | Description |
|
|
8946
|
+
| ------------------ | ------------------------- |
|
|
8947
|
+
| \`--list\` | List available topics |
|
|
6287
8948
|
| \`--search <query>\` | Search docs for a keyword |
|
|
6288
8949
|
|
|
6289
8950
|
\`\`\`bash
|
|
@@ -6972,6 +9633,7 @@ Before every command's output, the CLI prints a one-line context banner to stder
|
|
|
6972
9633
|
The format is: \`\u25B8 <profile-name> (<org-name>) \xB7 <source>\`
|
|
6973
9634
|
|
|
6974
9635
|
Where source is one of:
|
|
9636
|
+
|
|
6975
9637
|
- \`flag override\` \u2014 \`--profile\` flag was used
|
|
6976
9638
|
- \`env\` \u2014 \`NEXUS_PROFILE\` env var
|
|
6977
9639
|
- \`.nexusrc\` \u2014 found a \`.nexusrc\` file in directory tree
|
|
@@ -6980,6 +9642,7 @@ Where source is one of:
|
|
|
6980
9642
|
- \`api-key override\` \u2014 \`--api-key\` flag or \`NEXUS_API_KEY\` env (bypasses profiles)
|
|
6981
9643
|
|
|
6982
9644
|
The banner is **suppressed** when:
|
|
9645
|
+
|
|
6983
9646
|
- \`--json\` mode is active
|
|
6984
9647
|
- stdout is not a TTY (piped)
|
|
6985
9648
|
- Running auth, upgrade, or version commands (they handle their own output)
|
|
@@ -7230,34 +9893,46 @@ Deploy the same agent to multiple channels and monitor analytics.
|
|
|
7230
9893
|
# 1. Create an agent (or use an existing one)
|
|
7231
9894
|
AGENT_ID="your-agent-id"
|
|
7232
9895
|
|
|
7233
|
-
# 2. Deploy to web widget
|
|
9896
|
+
# 2. Deploy to web widget (no prerequisites)
|
|
7234
9897
|
WEB_DEP=$(nexus deployment create \\
|
|
7235
9898
|
--name "Website Widget" \\
|
|
7236
|
-
--type
|
|
9899
|
+
--type EMBED \\
|
|
7237
9900
|
--agent-id $AGENT_ID \\
|
|
7238
9901
|
--json | jq -r '.id')
|
|
7239
9902
|
|
|
7240
|
-
# 3. Deploy to WhatsApp
|
|
9903
|
+
# 3. Deploy to WhatsApp (requires channel setup first!)
|
|
9904
|
+
# Check what's needed:
|
|
9905
|
+
nexus channel setup --type WHATSAPP
|
|
9906
|
+
|
|
9907
|
+
# Auto-provision messaging connection:
|
|
9908
|
+
nexus channel setup --type WHATSAPP --auto
|
|
9909
|
+
|
|
9910
|
+
# Buy a phone number:
|
|
9911
|
+
nexus phone-number search --country US --sms
|
|
9912
|
+
nexus phone-number buy --phone-number "+12025551234" --country US --price 1.15
|
|
9913
|
+
|
|
9914
|
+
# Create WhatsApp sender (register with Meta):
|
|
9915
|
+
CONN_ID=$(nexus channel connection list --json | jq -r '.[0].id')
|
|
9916
|
+
PHONE_ID=$(nexus phone-number list --json | jq -r '.[0].id')
|
|
9917
|
+
nexus channel whatsapp-sender create \\
|
|
9918
|
+
--connection-id $CONN_ID \\
|
|
9919
|
+
--phone-number-id $PHONE_ID \\
|
|
9920
|
+
--sender-name "My Business"
|
|
9921
|
+
|
|
9922
|
+
# Now create the WhatsApp deployment:
|
|
7241
9923
|
WA_DEP=$(nexus deployment create \\
|
|
7242
9924
|
--name "WhatsApp Support" \\
|
|
7243
|
-
--type
|
|
9925
|
+
--type WHATSAPP \\
|
|
7244
9926
|
--agent-id $AGENT_ID \\
|
|
9927
|
+
--body "{\\"phoneNumberId\\":\\"$PHONE_ID\\",\\"apiKeyConnectionId\\":\\"$CONN_ID\\"}" \\
|
|
7245
9928
|
--json | jq -r '.id')
|
|
7246
9929
|
|
|
7247
|
-
# 4.
|
|
7248
|
-
SLACK_DEP=$(nexus deployment create \\
|
|
7249
|
-
--name "Slack Bot" \\
|
|
7250
|
-
--type slack \\
|
|
7251
|
-
--agent-id $AGENT_ID \\
|
|
7252
|
-
--json | jq -r '.id')
|
|
7253
|
-
|
|
7254
|
-
# 5. Organize deployments in a folder
|
|
9930
|
+
# 4. Organize deployments in a folder
|
|
7255
9931
|
FOLDER_ID=$(nexus deployment folder create --name "Production" --json | jq -r '.id')
|
|
7256
9932
|
nexus deployment folder assign --deployment-id $WEB_DEP --folder-id $FOLDER_ID
|
|
7257
9933
|
nexus deployment folder assign --deployment-id $WA_DEP --folder-id $FOLDER_ID
|
|
7258
|
-
nexus deployment folder assign --deployment-id $SLACK_DEP --folder-id $FOLDER_ID
|
|
7259
9934
|
|
|
7260
|
-
#
|
|
9935
|
+
# 5. Get the web widget embed configuration
|
|
7261
9936
|
nexus deployment embed-config $WEB_DEP
|
|
7262
9937
|
|
|
7263
9938
|
# 7. Customize the widget
|
|
@@ -7436,13 +10111,13 @@ jobs:
|
|
|
7436
10111
|
|
|
7437
10112
|
### Key Flags for CI
|
|
7438
10113
|
|
|
7439
|
-
| Flag
|
|
7440
|
-
|
|
7441
|
-
| \`--json\`
|
|
7442
|
-
| \`--yes\`
|
|
7443
|
-
| \`--no-auto-update\` | Prevent auto-updates in CI
|
|
7444
|
-
| \`--api-key\`
|
|
7445
|
-
| \`--profile\`
|
|
10114
|
+
| Flag | Purpose |
|
|
10115
|
+
| ------------------ | -------------------------------- |
|
|
10116
|
+
| \`--json\` | Machine-readable output |
|
|
10117
|
+
| \`--yes\` | Skip confirmation prompts |
|
|
10118
|
+
| \`--no-auto-update\` | Prevent auto-updates in CI |
|
|
10119
|
+
| \`--api-key\` | Override credentials per-command |
|
|
10120
|
+
| \`--profile\` | Use a specific profile |`
|
|
7446
10121
|
}
|
|
7447
10122
|
};
|
|
7448
10123
|
var TOPIC_LIST = ["overview", "commands", "gotchas", "input-output", "recipes"];
|
|
@@ -7525,9 +10200,11 @@ ${TOPIC_LIST.map((t) => ` ${t.padEnd(14)} ${TOPIC_DESCRIPTIONS[t]}`).join("\n")
|
|
|
7525
10200
|
return;
|
|
7526
10201
|
}
|
|
7527
10202
|
for (const result of results) {
|
|
7528
|
-
console.log(
|
|
10203
|
+
console.log(
|
|
10204
|
+
color.bold(`
|
|
7529
10205
|
\u2500\u2500 ${DOCS[result.topic].title} (nexus docs ${result.topic}) \u2500\u2500
|
|
7530
|
-
`)
|
|
10206
|
+
`)
|
|
10207
|
+
);
|
|
7531
10208
|
for (const chunk of result.lines) {
|
|
7532
10209
|
console.log(chunk);
|
|
7533
10210
|
console.log();
|
|
@@ -7836,7 +10513,7 @@ Examples:
|
|
|
7836
10513
|
`
|
|
7837
10514
|
Examples:
|
|
7838
10515
|
$ nexus emulator send dep-123 sess-456 --text "Hello, agent!"
|
|
7839
|
-
$ nexus emulator send dep-123 sess-456 --body '{"
|
|
10516
|
+
$ nexus emulator send dep-123 sess-456 --body '{"content":"Hi","participantId":"user-1"}'
|
|
7840
10517
|
$ nexus emulator send dep-123 sess-456 --text "Test" --json
|
|
7841
10518
|
|
|
7842
10519
|
Notes:
|
|
@@ -7848,7 +10525,7 @@ Notes:
|
|
|
7848
10525
|
const client = createClient(program2.optsWithGlobals());
|
|
7849
10526
|
const base = await resolveBody(opts.body);
|
|
7850
10527
|
const body = mergeBodyWithFlags(base, {
|
|
7851
|
-
|
|
10528
|
+
content: opts.text
|
|
7852
10529
|
});
|
|
7853
10530
|
const result = await client.emulator.sendMessage(deploymentId, sessionId, body);
|
|
7854
10531
|
printRecord(result);
|
|
@@ -8290,8 +10967,8 @@ Examples:
|
|
|
8290
10967
|
).action(async (id) => {
|
|
8291
10968
|
try {
|
|
8292
10969
|
const client = createClient(program2.optsWithGlobals());
|
|
8293
|
-
const
|
|
8294
|
-
printRecord(
|
|
10970
|
+
const exec3 = await client.workflowExecutions.get(id);
|
|
10971
|
+
printRecord(exec3, [
|
|
8295
10972
|
{ key: "id", label: "ID" },
|
|
8296
10973
|
{ key: "workflowId", label: "Workflow" },
|
|
8297
10974
|
{ key: "status", label: "Status" },
|
|
@@ -9354,7 +12031,7 @@ Examples:
|
|
|
9354
12031
|
}
|
|
9355
12032
|
|
|
9356
12033
|
// src/commands/upgrade.ts
|
|
9357
|
-
var
|
|
12034
|
+
var import_node_child_process3 = require("child_process");
|
|
9358
12035
|
init_output();
|
|
9359
12036
|
|
|
9360
12037
|
// src/util/package-manager.ts
|
|
@@ -9519,17 +12196,15 @@ Examples:
|
|
|
9519
12196
|
`);
|
|
9520
12197
|
try {
|
|
9521
12198
|
const installCmd = getGlobalInstallCommand(PACKAGE_NAME2);
|
|
9522
|
-
(0,
|
|
12199
|
+
(0, import_node_child_process3.execSync)(installCmd, { stdio: "inherit" });
|
|
9523
12200
|
printSuccess(`Successfully upgraded to ${latest}.`, { from: currentVersion, to: latest });
|
|
9524
12201
|
} catch {
|
|
9525
12202
|
const fallbackCmd = getGlobalInstallCommand(PACKAGE_NAME2);
|
|
9526
12203
|
process.stderr.write(
|
|
9527
|
-
color.red(
|
|
9528
|
-
`
|
|
12204
|
+
color.red(`
|
|
9529
12205
|
Upgrade failed. Try running manually:
|
|
9530
12206
|
${fallbackCmd}
|
|
9531
|
-
`
|
|
9532
|
-
)
|
|
12207
|
+
`)
|
|
9533
12208
|
);
|
|
9534
12209
|
process.exitCode = 1;
|
|
9535
12210
|
}
|
|
@@ -10376,7 +13051,9 @@ registerTemplateCommands(program);
|
|
|
10376
13051
|
registerExternalToolCommands(program);
|
|
10377
13052
|
registerPromptAssistantCommands(program);
|
|
10378
13053
|
registerModelCommands(program);
|
|
13054
|
+
registerCustomModelCommands(program);
|
|
10379
13055
|
registerPhoneNumberCommands(program);
|
|
13056
|
+
registerChannelCommands(program);
|
|
10380
13057
|
registerUpgradeCommand(program);
|
|
10381
13058
|
registerDocsCommand(program);
|
|
10382
13059
|
if (process.argv.length <= 2) {
|