lemma-sdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -36
- package/dist/browser/lemma-client.js +244 -518
- package/dist/client.d.ts +2 -0
- package/dist/client.js +6 -3
- package/dist/http.d.ts +18 -5
- package/dist/http.js +77 -22
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -0
- package/dist/namespaces/assistants.d.ts +55 -15
- package/dist/namespaces/assistants.js +108 -19
- package/dist/namespaces/resources.d.ts +16 -0
- package/dist/namespaces/resources.js +32 -0
- package/dist/namespaces/tasks.d.ts +15 -9
- package/dist/namespaces/tasks.js +43 -11
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +2 -0
- package/dist/react/useAgentRun.d.ts +17 -0
- package/dist/react/useAgentRun.js +66 -0
- package/dist/react/useAssistantRun.d.ts +18 -0
- package/dist/react/useAssistantRun.js +82 -0
- package/dist/streams.d.ts +10 -0
- package/dist/streams.js +68 -0
- package/dist/types.d.ts +27 -1
- package/package.json +5 -5
|
@@ -42,6 +42,7 @@ const assistants_js_1 = require("./namespaces/assistants.js");
|
|
|
42
42
|
const workflows_js_1 = require("./namespaces/workflows.js");
|
|
43
43
|
const desks_js_1 = require("./namespaces/desks.js");
|
|
44
44
|
const integrations_js_1 = require("./namespaces/integrations.js");
|
|
45
|
+
const resources_js_1 = require("./namespaces/resources.js");
|
|
45
46
|
class LemmaClient {
|
|
46
47
|
constructor(overrides = {}) {
|
|
47
48
|
this._config = (0, config_js_1.resolveConfig)(overrides);
|
|
@@ -62,12 +63,13 @@ class LemmaClient {
|
|
|
62
63
|
this.files = new files_js_1.FilesNamespace(this._generated, this._http, podIdFn);
|
|
63
64
|
this.functions = new functions_js_1.FunctionsNamespace(this._generated, podIdFn);
|
|
64
65
|
this.agents = new agents_js_1.AgentsNamespace(this._generated, podIdFn);
|
|
65
|
-
this.tasks = new tasks_js_1.TasksNamespace(this.
|
|
66
|
-
this.assistants = new assistants_js_1.AssistantsNamespace(this.
|
|
67
|
-
this.conversations = new assistants_js_1.ConversationsNamespace(this.
|
|
66
|
+
this.tasks = new tasks_js_1.TasksNamespace(this._http, podIdFn);
|
|
67
|
+
this.assistants = new assistants_js_1.AssistantsNamespace(this._http, podIdFn);
|
|
68
|
+
this.conversations = new assistants_js_1.ConversationsNamespace(this._http, podIdFn);
|
|
68
69
|
this.workflows = new workflows_js_1.WorkflowsNamespace(this._generated, podIdFn);
|
|
69
70
|
this.desks = new desks_js_1.DesksNamespace(this._generated, this._http, podIdFn);
|
|
70
71
|
this.integrations = new integrations_js_1.IntegrationsNamespace(this._generated);
|
|
72
|
+
this.resources = new resources_js_1.ResourcesNamespace(this._http);
|
|
71
73
|
}
|
|
72
74
|
/** Change the active pod ID for subsequent calls. */
|
|
73
75
|
setPodId(podId) {
|
|
@@ -479,6 +481,35 @@ class HttpClient {
|
|
|
479
481
|
this.apiUrl = apiUrl;
|
|
480
482
|
this.auth = auth;
|
|
481
483
|
}
|
|
484
|
+
getBaseUrl() {
|
|
485
|
+
return this.apiUrl;
|
|
486
|
+
}
|
|
487
|
+
buildUrl(path, params) {
|
|
488
|
+
let url = `${this.apiUrl}${path}`;
|
|
489
|
+
if (!params) {
|
|
490
|
+
return url;
|
|
491
|
+
}
|
|
492
|
+
const qs = Object.entries(params)
|
|
493
|
+
.filter(([, value]) => value !== undefined && value !== null)
|
|
494
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
|
|
495
|
+
.join("&");
|
|
496
|
+
if (qs) {
|
|
497
|
+
url += `?${qs}`;
|
|
498
|
+
}
|
|
499
|
+
return url;
|
|
500
|
+
}
|
|
501
|
+
mergeHeaders(base, extra) {
|
|
502
|
+
if (!extra) {
|
|
503
|
+
return base;
|
|
504
|
+
}
|
|
505
|
+
const merged = new Headers(base.headers ?? {});
|
|
506
|
+
const extraHeaders = new Headers(extra);
|
|
507
|
+
extraHeaders.forEach((value, key) => merged.set(key, value));
|
|
508
|
+
return {
|
|
509
|
+
...base,
|
|
510
|
+
headers: merged,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
482
513
|
async parseError(response) {
|
|
483
514
|
let message = response.statusText || "Request failed";
|
|
484
515
|
let code;
|
|
@@ -488,9 +519,14 @@ class HttpClient {
|
|
|
488
519
|
const body = await response.json();
|
|
489
520
|
raw = body;
|
|
490
521
|
if (body && typeof body === "object") {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
522
|
+
const record = body;
|
|
523
|
+
if (typeof record.message === "string") {
|
|
524
|
+
message = record.message;
|
|
525
|
+
}
|
|
526
|
+
if (typeof record.code === "string") {
|
|
527
|
+
code = record.code;
|
|
528
|
+
}
|
|
529
|
+
details = record.details;
|
|
494
530
|
}
|
|
495
531
|
}
|
|
496
532
|
catch {
|
|
@@ -498,31 +534,33 @@ class HttpClient {
|
|
|
498
534
|
}
|
|
499
535
|
return new ApiError(response.status, message, code, details, raw);
|
|
500
536
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
const qs = Object.entries(options.params)
|
|
505
|
-
.filter(([, v]) => v !== undefined && v !== null)
|
|
506
|
-
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
|
|
507
|
-
.join("&");
|
|
508
|
-
if (qs) {
|
|
509
|
-
url += `?${qs}`;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
const initBase = { method };
|
|
513
|
-
if (options.body !== undefined && !options.isFormData) {
|
|
514
|
-
initBase.body = JSON.stringify(options.body);
|
|
537
|
+
getRequestBody(options) {
|
|
538
|
+
if (options.body === undefined) {
|
|
539
|
+
return undefined;
|
|
515
540
|
}
|
|
516
|
-
|
|
517
|
-
|
|
541
|
+
if (options.isFormData && options.body instanceof FormData) {
|
|
542
|
+
return options.body;
|
|
518
543
|
}
|
|
519
|
-
|
|
520
|
-
|
|
544
|
+
return JSON.stringify(options.body);
|
|
545
|
+
}
|
|
546
|
+
buildRequestInit(method, options) {
|
|
547
|
+
const initBase = {
|
|
548
|
+
method,
|
|
549
|
+
body: this.getRequestBody(options),
|
|
550
|
+
signal: options.signal,
|
|
551
|
+
};
|
|
552
|
+
// For FormData, let the browser set Content-Type with boundary.
|
|
553
|
+
const withAuth = options.isFormData
|
|
521
554
|
? {
|
|
522
555
|
...this.auth.getRequestInit(initBase),
|
|
523
|
-
headers: Object.fromEntries(Object.entries(this.auth.getRequestInit(initBase).headers ?? {}).filter(([
|
|
556
|
+
headers: Object.fromEntries(Object.entries(this.auth.getRequestInit(initBase).headers ?? {}).filter(([key]) => key.toLowerCase() !== "content-type")),
|
|
524
557
|
}
|
|
525
558
|
: this.auth.getRequestInit(initBase);
|
|
559
|
+
return this.mergeHeaders(withAuth, options.headers);
|
|
560
|
+
}
|
|
561
|
+
async request(method, path, options = {}) {
|
|
562
|
+
const url = this.buildUrl(path, options.params);
|
|
563
|
+
const init = this.buildRequestInit(method, options);
|
|
526
564
|
const response = await fetch(url, init);
|
|
527
565
|
// Only 401 means the session is gone — 403 is a permission/RLS error, not an auth failure
|
|
528
566
|
if (response.status === 401) {
|
|
@@ -540,6 +578,25 @@ class HttpClient {
|
|
|
540
578
|
}
|
|
541
579
|
return response.text();
|
|
542
580
|
}
|
|
581
|
+
async stream(path, options = {}) {
|
|
582
|
+
const response = await fetch(this.buildUrl(path, options.params), this.buildRequestInit(options.method ?? "GET", {
|
|
583
|
+
...options,
|
|
584
|
+
headers: {
|
|
585
|
+
Accept: "text/event-stream",
|
|
586
|
+
...options.headers,
|
|
587
|
+
},
|
|
588
|
+
}));
|
|
589
|
+
if (response.status === 401) {
|
|
590
|
+
this.auth.markUnauthenticated();
|
|
591
|
+
}
|
|
592
|
+
if (!response.ok) {
|
|
593
|
+
throw await this.parseError(response);
|
|
594
|
+
}
|
|
595
|
+
if (!response.body) {
|
|
596
|
+
throw new ApiError(response.status, "Stream response had no body.");
|
|
597
|
+
}
|
|
598
|
+
return response.body;
|
|
599
|
+
}
|
|
543
600
|
async requestBytes(method, path) {
|
|
544
601
|
const url = `${this.apiUrl}${path}`;
|
|
545
602
|
const response = await fetch(url, this.auth.getRequestInit({ method }));
|
|
@@ -2478,574 +2535,205 @@ exports.AgentsService = AgentsService;
|
|
|
2478
2535
|
"use strict";
|
|
2479
2536
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2480
2537
|
exports.TasksNamespace = void 0;
|
|
2481
|
-
const TasksService_js_1 = require("./openapi_client/services/TasksService.js");
|
|
2482
2538
|
class TasksNamespace {
|
|
2483
|
-
constructor(
|
|
2484
|
-
this.
|
|
2539
|
+
constructor(http, podId) {
|
|
2540
|
+
this.http = http;
|
|
2485
2541
|
this.podId = podId;
|
|
2486
2542
|
this.messages = {
|
|
2487
|
-
list: (taskId, options = {}) => this.
|
|
2543
|
+
list: (taskId, options = {}) => this.http.request("GET", `/pods/${this.podId()}/tasks/${taskId}/messages`, {
|
|
2544
|
+
params: {
|
|
2545
|
+
limit: options.limit ?? 100,
|
|
2546
|
+
page_token: options.pageToken ?? options.cursor,
|
|
2547
|
+
cursor: options.cursor,
|
|
2548
|
+
},
|
|
2549
|
+
}),
|
|
2488
2550
|
add: (taskId, content) => {
|
|
2489
2551
|
const payload = { content };
|
|
2490
|
-
return this.
|
|
2552
|
+
return this.http.request("POST", `/pods/${this.podId()}/tasks/${taskId}/messages`, {
|
|
2553
|
+
body: payload,
|
|
2554
|
+
});
|
|
2491
2555
|
},
|
|
2492
2556
|
};
|
|
2493
2557
|
}
|
|
2494
2558
|
list(options = {}) {
|
|
2495
|
-
return this.
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
return this.client.request(() => TasksService_js_1.TasksService.taskGet(this.podId(), taskId));
|
|
2503
|
-
}
|
|
2504
|
-
stop(taskId) {
|
|
2505
|
-
return this.client.request(() => TasksService_js_1.TasksService.taskStop(this.podId(), taskId));
|
|
2506
|
-
}
|
|
2507
|
-
}
|
|
2508
|
-
exports.TasksNamespace = TasksNamespace;
|
|
2509
|
-
|
|
2510
|
-
},
|
|
2511
|
-
"./openapi_client/services/TasksService.js": function (module, exports, require) {
|
|
2512
|
-
"use strict";
|
|
2513
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2514
|
-
exports.TasksService = void 0;
|
|
2515
|
-
const OpenAPI_js_1 = require("./openapi_client/core/OpenAPI.js");
|
|
2516
|
-
const request_js_1 = require("./openapi_client/core/request.js");
|
|
2517
|
-
class TasksService {
|
|
2518
|
-
/**
|
|
2519
|
-
* Create Task
|
|
2520
|
-
* Create and start a new task
|
|
2521
|
-
* @param podId
|
|
2522
|
-
* @param requestBody
|
|
2523
|
-
* @returns TaskResponse Successful Response
|
|
2524
|
-
* @throws ApiError
|
|
2525
|
-
*/
|
|
2526
|
-
static taskCreate(podId, requestBody) {
|
|
2527
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2528
|
-
method: 'POST',
|
|
2529
|
-
url: '/pods/{pod_id}/tasks',
|
|
2530
|
-
path: {
|
|
2531
|
-
'pod_id': podId,
|
|
2532
|
-
},
|
|
2533
|
-
body: requestBody,
|
|
2534
|
-
mediaType: 'application/json',
|
|
2535
|
-
errors: {
|
|
2536
|
-
422: `Validation Error`,
|
|
2559
|
+
return this.http.request("GET", `/pods/${this.podId()}/tasks`, {
|
|
2560
|
+
params: {
|
|
2561
|
+
agent_name: options.agentName,
|
|
2562
|
+
agent_id: options.agentId,
|
|
2563
|
+
limit: options.limit ?? 100,
|
|
2564
|
+
page_token: options.pageToken ?? options.cursor,
|
|
2565
|
+
cursor: options.cursor,
|
|
2537
2566
|
},
|
|
2538
2567
|
});
|
|
2539
2568
|
}
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
static taskList(podId, agentName, limit = 100, pageToken) {
|
|
2551
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2552
|
-
method: 'GET',
|
|
2553
|
-
url: '/pods/{pod_id}/tasks',
|
|
2554
|
-
path: {
|
|
2555
|
-
'pod_id': podId,
|
|
2556
|
-
},
|
|
2557
|
-
query: {
|
|
2558
|
-
'agent_name': agentName,
|
|
2559
|
-
'limit': limit,
|
|
2560
|
-
'page_token': pageToken,
|
|
2561
|
-
},
|
|
2562
|
-
errors: {
|
|
2563
|
-
422: `Validation Error`,
|
|
2564
|
-
},
|
|
2565
|
-
});
|
|
2566
|
-
}
|
|
2567
|
-
/**
|
|
2568
|
-
* Get Task
|
|
2569
|
-
* Get a task by ID
|
|
2570
|
-
* @param podId
|
|
2571
|
-
* @param taskId
|
|
2572
|
-
* @returns TaskResponse Successful Response
|
|
2573
|
-
* @throws ApiError
|
|
2574
|
-
*/
|
|
2575
|
-
static taskGet(podId, taskId) {
|
|
2576
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2577
|
-
method: 'GET',
|
|
2578
|
-
url: '/pods/{pod_id}/tasks/{task_id}',
|
|
2579
|
-
path: {
|
|
2580
|
-
'pod_id': podId,
|
|
2581
|
-
'task_id': taskId,
|
|
2582
|
-
},
|
|
2583
|
-
errors: {
|
|
2584
|
-
422: `Validation Error`,
|
|
2585
|
-
},
|
|
2586
|
-
});
|
|
2587
|
-
}
|
|
2588
|
-
/**
|
|
2589
|
-
* Stop Task
|
|
2590
|
-
* Stop a running task
|
|
2591
|
-
* @param podId
|
|
2592
|
-
* @param taskId
|
|
2593
|
-
* @returns TaskResponse Successful Response
|
|
2594
|
-
* @throws ApiError
|
|
2595
|
-
*/
|
|
2596
|
-
static taskStop(podId, taskId) {
|
|
2597
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2598
|
-
method: 'PATCH',
|
|
2599
|
-
url: '/pods/{pod_id}/tasks/{task_id}/stop',
|
|
2600
|
-
path: {
|
|
2601
|
-
'pod_id': podId,
|
|
2602
|
-
'task_id': taskId,
|
|
2603
|
-
},
|
|
2604
|
-
errors: {
|
|
2605
|
-
422: `Validation Error`,
|
|
2569
|
+
create(options) {
|
|
2570
|
+
if (!options.agentId && !options.agentName) {
|
|
2571
|
+
throw new Error("Either agentId or agentName is required.");
|
|
2572
|
+
}
|
|
2573
|
+
return this.http.request("POST", `/pods/${this.podId()}/tasks`, {
|
|
2574
|
+
body: {
|
|
2575
|
+
agent_id: options.agentId,
|
|
2576
|
+
agent_name: options.agentName ?? options.agentId,
|
|
2577
|
+
input_data: options.input,
|
|
2578
|
+
runtime_account_ids: options.runtimeAccountIds,
|
|
2606
2579
|
},
|
|
2607
2580
|
});
|
|
2608
2581
|
}
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
* Add a message to a task
|
|
2612
|
-
* @param podId
|
|
2613
|
-
* @param taskId
|
|
2614
|
-
* @param requestBody
|
|
2615
|
-
* @returns TaskResponse Successful Response
|
|
2616
|
-
* @throws ApiError
|
|
2617
|
-
*/
|
|
2618
|
-
static taskMessageAdd(podId, taskId, requestBody) {
|
|
2619
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2620
|
-
method: 'POST',
|
|
2621
|
-
url: '/pods/{pod_id}/tasks/{task_id}/messages',
|
|
2622
|
-
path: {
|
|
2623
|
-
'pod_id': podId,
|
|
2624
|
-
'task_id': taskId,
|
|
2625
|
-
},
|
|
2626
|
-
body: requestBody,
|
|
2627
|
-
mediaType: 'application/json',
|
|
2628
|
-
errors: {
|
|
2629
|
-
422: `Validation Error`,
|
|
2630
|
-
},
|
|
2631
|
-
});
|
|
2582
|
+
get(taskId) {
|
|
2583
|
+
return this.http.request("GET", `/pods/${this.podId()}/tasks/${taskId}`);
|
|
2632
2584
|
}
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
* List messages for a task
|
|
2636
|
-
* @param podId
|
|
2637
|
-
* @param taskId
|
|
2638
|
-
* @param limit
|
|
2639
|
-
* @param pageToken
|
|
2640
|
-
* @returns TaskMessageListResponse Successful Response
|
|
2641
|
-
* @throws ApiError
|
|
2642
|
-
*/
|
|
2643
|
-
static taskMessageList(podId, taskId, limit = 100, pageToken) {
|
|
2644
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2645
|
-
method: 'GET',
|
|
2646
|
-
url: '/pods/{pod_id}/tasks/{task_id}/messages',
|
|
2647
|
-
path: {
|
|
2648
|
-
'pod_id': podId,
|
|
2649
|
-
'task_id': taskId,
|
|
2650
|
-
},
|
|
2651
|
-
query: {
|
|
2652
|
-
'limit': limit,
|
|
2653
|
-
'page_token': pageToken,
|
|
2654
|
-
},
|
|
2655
|
-
errors: {
|
|
2656
|
-
422: `Validation Error`,
|
|
2657
|
-
},
|
|
2658
|
-
});
|
|
2585
|
+
stop(taskId) {
|
|
2586
|
+
return this.http.request("PATCH", `/pods/${this.podId()}/tasks/${taskId}/stop`);
|
|
2659
2587
|
}
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
* @returns any Successful Response
|
|
2666
|
-
* @throws ApiError
|
|
2667
|
-
*/
|
|
2668
|
-
static taskStream(podId, taskId) {
|
|
2669
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2670
|
-
method: 'GET',
|
|
2671
|
-
url: '/pods/{pod_id}/tasks/{task_id}/stream',
|
|
2672
|
-
path: {
|
|
2673
|
-
'pod_id': podId,
|
|
2674
|
-
'task_id': taskId,
|
|
2675
|
-
},
|
|
2676
|
-
errors: {
|
|
2677
|
-
422: `Validation Error`,
|
|
2588
|
+
stream(taskId, options = {}) {
|
|
2589
|
+
return this.http.stream(`/pods/${this.podId()}/tasks/${taskId}/stream`, {
|
|
2590
|
+
signal: options.signal,
|
|
2591
|
+
headers: {
|
|
2592
|
+
Accept: "text/event-stream",
|
|
2678
2593
|
},
|
|
2679
2594
|
});
|
|
2680
2595
|
}
|
|
2681
2596
|
}
|
|
2682
|
-
exports.
|
|
2597
|
+
exports.TasksNamespace = TasksNamespace;
|
|
2683
2598
|
|
|
2684
2599
|
},
|
|
2685
2600
|
"./namespaces/assistants.js": function (module, exports, require) {
|
|
2686
2601
|
"use strict";
|
|
2687
2602
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2688
2603
|
exports.ConversationsNamespace = exports.AssistantsNamespace = void 0;
|
|
2689
|
-
const AssistantsService_js_1 = require("./openapi_client/services/AssistantsService.js");
|
|
2690
|
-
const ConversationsService_js_1 = require("./openapi_client/services/ConversationsService.js");
|
|
2691
2604
|
class AssistantsNamespace {
|
|
2692
|
-
constructor(
|
|
2693
|
-
this.
|
|
2605
|
+
constructor(http, podId) {
|
|
2606
|
+
this.http = http;
|
|
2694
2607
|
this.podId = podId;
|
|
2695
2608
|
}
|
|
2696
2609
|
list(options = {}) {
|
|
2697
|
-
return this.
|
|
2610
|
+
return this.http.request("GET", `/pods/${this.podId()}/assistants`, {
|
|
2611
|
+
params: {
|
|
2612
|
+
limit: options.limit ?? 100,
|
|
2613
|
+
page_token: options.pageToken ?? options.cursor,
|
|
2614
|
+
cursor: options.cursor,
|
|
2615
|
+
},
|
|
2616
|
+
});
|
|
2698
2617
|
}
|
|
2699
2618
|
create(payload) {
|
|
2700
|
-
return this.
|
|
2619
|
+
return this.http.request("POST", `/pods/${this.podId()}/assistants`, { body: payload });
|
|
2701
2620
|
}
|
|
2702
2621
|
get(assistantName) {
|
|
2703
|
-
return this.
|
|
2622
|
+
return this.http.request("GET", `/pods/${this.podId()}/assistants/${assistantName}`);
|
|
2704
2623
|
}
|
|
2705
2624
|
update(assistantName, payload) {
|
|
2706
|
-
return this.
|
|
2625
|
+
return this.http.request("PATCH", `/pods/${this.podId()}/assistants/${assistantName}`, {
|
|
2626
|
+
body: payload,
|
|
2627
|
+
});
|
|
2707
2628
|
}
|
|
2708
2629
|
delete(assistantName) {
|
|
2709
|
-
return this.
|
|
2630
|
+
return this.http.request("DELETE", `/pods/${this.podId()}/assistants/${assistantName}`);
|
|
2710
2631
|
}
|
|
2711
2632
|
}
|
|
2712
2633
|
exports.AssistantsNamespace = AssistantsNamespace;
|
|
2713
2634
|
class ConversationsNamespace {
|
|
2714
|
-
constructor(
|
|
2715
|
-
this.
|
|
2635
|
+
constructor(http, podId) {
|
|
2636
|
+
this.http = http;
|
|
2716
2637
|
this.podId = podId;
|
|
2717
2638
|
this.messages = {
|
|
2718
|
-
list: (conversationId, options = {}) => this.
|
|
2719
|
-
|
|
2639
|
+
list: (conversationId, options = {}) => this.http.request("GET", `/conversations/${conversationId}/messages`, {
|
|
2640
|
+
params: {
|
|
2641
|
+
pod_id: options.podId ?? this.podId(),
|
|
2642
|
+
limit: options.limit ?? 20,
|
|
2643
|
+
page_token: options.pageToken ?? options.cursor,
|
|
2644
|
+
cursor: options.cursor,
|
|
2645
|
+
order: options.order,
|
|
2646
|
+
},
|
|
2647
|
+
}),
|
|
2648
|
+
send: (conversationId, payload, options = {}) => this.http.request("POST", `/conversations/${conversationId}/messages`, {
|
|
2649
|
+
params: {
|
|
2650
|
+
pod_id: options.podId ?? this.podId(),
|
|
2651
|
+
},
|
|
2652
|
+
body: payload,
|
|
2653
|
+
}),
|
|
2720
2654
|
};
|
|
2721
2655
|
}
|
|
2722
2656
|
list(options = {}) {
|
|
2723
|
-
return this.
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
}
|
|
2732
|
-
exports.ConversationsNamespace = ConversationsNamespace;
|
|
2733
|
-
|
|
2734
|
-
},
|
|
2735
|
-
"./openapi_client/services/AssistantsService.js": function (module, exports, require) {
|
|
2736
|
-
"use strict";
|
|
2737
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2738
|
-
exports.AssistantsService = void 0;
|
|
2739
|
-
const OpenAPI_js_1 = require("./openapi_client/core/OpenAPI.js");
|
|
2740
|
-
const request_js_1 = require("./openapi_client/core/request.js");
|
|
2741
|
-
class AssistantsService {
|
|
2742
|
-
/**
|
|
2743
|
-
* Create Assistant
|
|
2744
|
-
* @param podId
|
|
2745
|
-
* @param requestBody
|
|
2746
|
-
* @returns AssistantResponse Successful Response
|
|
2747
|
-
* @throws ApiError
|
|
2748
|
-
*/
|
|
2749
|
-
static assistantCreate(podId, requestBody) {
|
|
2750
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2751
|
-
method: 'POST',
|
|
2752
|
-
url: '/pods/{pod_id}/assistants',
|
|
2753
|
-
path: {
|
|
2754
|
-
'pod_id': podId,
|
|
2755
|
-
},
|
|
2756
|
-
body: requestBody,
|
|
2757
|
-
mediaType: 'application/json',
|
|
2758
|
-
errors: {
|
|
2759
|
-
422: `Validation Error`,
|
|
2760
|
-
},
|
|
2761
|
-
});
|
|
2762
|
-
}
|
|
2763
|
-
/**
|
|
2764
|
-
* List Assistants
|
|
2765
|
-
* @param podId
|
|
2766
|
-
* @param limit
|
|
2767
|
-
* @param pageToken
|
|
2768
|
-
* @returns AssistantListResponse Successful Response
|
|
2769
|
-
* @throws ApiError
|
|
2770
|
-
*/
|
|
2771
|
-
static assistantList(podId, limit = 100, pageToken) {
|
|
2772
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2773
|
-
method: 'GET',
|
|
2774
|
-
url: '/pods/{pod_id}/assistants',
|
|
2775
|
-
path: {
|
|
2776
|
-
'pod_id': podId,
|
|
2777
|
-
},
|
|
2778
|
-
query: {
|
|
2779
|
-
'limit': limit,
|
|
2780
|
-
'page_token': pageToken,
|
|
2781
|
-
},
|
|
2782
|
-
errors: {
|
|
2783
|
-
422: `Validation Error`,
|
|
2657
|
+
return this.http.request("GET", "/conversations", {
|
|
2658
|
+
params: {
|
|
2659
|
+
assistant_id: options.assistantName ?? options.assistantId,
|
|
2660
|
+
pod_id: options.podId ?? this.podId(),
|
|
2661
|
+
organization_id: options.organizationId,
|
|
2662
|
+
limit: options.limit ?? 20,
|
|
2663
|
+
page_token: options.pageToken ?? options.cursor,
|
|
2664
|
+
cursor: options.cursor,
|
|
2784
2665
|
},
|
|
2785
2666
|
});
|
|
2786
2667
|
}
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
* @param podId
|
|
2790
|
-
* @param assistantName
|
|
2791
|
-
* @returns AssistantResponse Successful Response
|
|
2792
|
-
* @throws ApiError
|
|
2793
|
-
*/
|
|
2794
|
-
static assistantGet(podId, assistantName) {
|
|
2795
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2796
|
-
method: 'GET',
|
|
2797
|
-
url: '/pods/{pod_id}/assistants/{assistant_name}',
|
|
2798
|
-
path: {
|
|
2799
|
-
'pod_id': podId,
|
|
2800
|
-
'assistant_name': assistantName,
|
|
2801
|
-
},
|
|
2802
|
-
errors: {
|
|
2803
|
-
422: `Validation Error`,
|
|
2804
|
-
},
|
|
2805
|
-
});
|
|
2668
|
+
listByAssistant(assistantName, options = {}) {
|
|
2669
|
+
return this.list({ ...options, assistantName });
|
|
2806
2670
|
}
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
* @throws ApiError
|
|
2814
|
-
*/
|
|
2815
|
-
static assistantUpdate(podId, assistantName, requestBody) {
|
|
2816
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2817
|
-
method: 'PATCH',
|
|
2818
|
-
url: '/pods/{pod_id}/assistants/{assistant_name}',
|
|
2819
|
-
path: {
|
|
2820
|
-
'pod_id': podId,
|
|
2821
|
-
'assistant_name': assistantName,
|
|
2822
|
-
},
|
|
2823
|
-
body: requestBody,
|
|
2824
|
-
mediaType: 'application/json',
|
|
2825
|
-
errors: {
|
|
2826
|
-
422: `Validation Error`,
|
|
2671
|
+
create(payload) {
|
|
2672
|
+
return this.http.request("POST", "/conversations", {
|
|
2673
|
+
body: {
|
|
2674
|
+
...payload,
|
|
2675
|
+
assistant_id: payload.assistant_id ?? payload.assistant_name,
|
|
2676
|
+
pod_id: payload.pod_id ?? this.podId(),
|
|
2827
2677
|
},
|
|
2828
2678
|
});
|
|
2829
2679
|
}
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
* @throws ApiError
|
|
2836
|
-
*/
|
|
2837
|
-
static assistantDelete(podId, assistantName) {
|
|
2838
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2839
|
-
method: 'DELETE',
|
|
2840
|
-
url: '/pods/{pod_id}/assistants/{assistant_name}',
|
|
2841
|
-
path: {
|
|
2842
|
-
'pod_id': podId,
|
|
2843
|
-
'assistant_name': assistantName,
|
|
2844
|
-
},
|
|
2845
|
-
errors: {
|
|
2846
|
-
422: `Validation Error`,
|
|
2847
|
-
},
|
|
2680
|
+
createForAssistant(assistantName, payload = {}) {
|
|
2681
|
+
return this.create({
|
|
2682
|
+
...payload,
|
|
2683
|
+
assistant_name: assistantName,
|
|
2684
|
+
pod_id: payload.pod_id ?? this.podId(),
|
|
2848
2685
|
});
|
|
2849
2686
|
}
|
|
2850
|
-
}
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
"./openapi_client/services/ConversationsService.js": function (module, exports, require) {
|
|
2855
|
-
"use strict";
|
|
2856
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2857
|
-
exports.ConversationsService = void 0;
|
|
2858
|
-
const OpenAPI_js_1 = require("./openapi_client/core/OpenAPI.js");
|
|
2859
|
-
const request_js_1 = require("./openapi_client/core/request.js");
|
|
2860
|
-
class ConversationsService {
|
|
2861
|
-
/**
|
|
2862
|
-
* Create Conversation
|
|
2863
|
-
* @param requestBody
|
|
2864
|
-
* @returns ConversationResponse Successful Response
|
|
2865
|
-
* @throws ApiError
|
|
2866
|
-
*/
|
|
2867
|
-
static conversationCreate(requestBody) {
|
|
2868
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2869
|
-
method: 'POST',
|
|
2870
|
-
url: '/conversations',
|
|
2871
|
-
body: requestBody,
|
|
2872
|
-
mediaType: 'application/json',
|
|
2873
|
-
errors: {
|
|
2874
|
-
422: `Validation Error`,
|
|
2687
|
+
get(conversationId, options = {}) {
|
|
2688
|
+
return this.http.request("GET", `/conversations/${conversationId}`, {
|
|
2689
|
+
params: {
|
|
2690
|
+
pod_id: options.podId ?? this.podId(),
|
|
2875
2691
|
},
|
|
2876
2692
|
});
|
|
2877
2693
|
}
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
* @param organizationId
|
|
2883
|
-
* @param pageToken
|
|
2884
|
-
* @param limit
|
|
2885
|
-
* @returns ConversationListResponse Successful Response
|
|
2886
|
-
* @throws ApiError
|
|
2887
|
-
*/
|
|
2888
|
-
static conversationList(assistantId, podId, organizationId, pageToken, limit = 20) {
|
|
2889
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2890
|
-
method: 'GET',
|
|
2891
|
-
url: '/conversations',
|
|
2892
|
-
query: {
|
|
2893
|
-
'assistant_id': assistantId,
|
|
2894
|
-
'pod_id': podId,
|
|
2895
|
-
'organization_id': organizationId,
|
|
2896
|
-
'page_token': pageToken,
|
|
2897
|
-
'limit': limit,
|
|
2898
|
-
},
|
|
2899
|
-
errors: {
|
|
2900
|
-
422: `Validation Error`,
|
|
2694
|
+
update(conversationId, payload, options = {}) {
|
|
2695
|
+
return this.http.request("PATCH", `/conversations/${conversationId}`, {
|
|
2696
|
+
params: {
|
|
2697
|
+
pod_id: options.podId ?? this.podId(),
|
|
2901
2698
|
},
|
|
2699
|
+
body: payload,
|
|
2902
2700
|
});
|
|
2903
2701
|
}
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
* @throws ApiError
|
|
2910
|
-
*/
|
|
2911
|
-
static conversationGet(conversationId, podId) {
|
|
2912
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2913
|
-
method: 'GET',
|
|
2914
|
-
url: '/conversations/{conversation_id}',
|
|
2915
|
-
path: {
|
|
2916
|
-
'conversation_id': conversationId,
|
|
2702
|
+
sendMessageStream(conversationId, payload, options = {}) {
|
|
2703
|
+
return this.http.stream(`/conversations/${conversationId}/messages`, {
|
|
2704
|
+
method: "POST",
|
|
2705
|
+
params: {
|
|
2706
|
+
pod_id: options.podId ?? this.podId(),
|
|
2917
2707
|
},
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
},
|
|
2924
|
-
});
|
|
2925
|
-
}
|
|
2926
|
-
/**
|
|
2927
|
-
* Update Conversation
|
|
2928
|
-
* @param conversationId
|
|
2929
|
-
* @param requestBody
|
|
2930
|
-
* @param podId
|
|
2931
|
-
* @returns ConversationResponse Successful Response
|
|
2932
|
-
* @throws ApiError
|
|
2933
|
-
*/
|
|
2934
|
-
static conversationUpdate(conversationId, requestBody, podId) {
|
|
2935
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2936
|
-
method: 'PATCH',
|
|
2937
|
-
url: '/conversations/{conversation_id}',
|
|
2938
|
-
path: {
|
|
2939
|
-
'conversation_id': conversationId,
|
|
2940
|
-
},
|
|
2941
|
-
query: {
|
|
2942
|
-
'pod_id': podId,
|
|
2943
|
-
},
|
|
2944
|
-
body: requestBody,
|
|
2945
|
-
mediaType: 'application/json',
|
|
2946
|
-
errors: {
|
|
2947
|
-
422: `Validation Error`,
|
|
2948
|
-
},
|
|
2949
|
-
});
|
|
2950
|
-
}
|
|
2951
|
-
/**
|
|
2952
|
-
* List Messages
|
|
2953
|
-
* List messages in a conversation with token pagination. Use `page_token` to fetch older messages.
|
|
2954
|
-
* @param conversationId
|
|
2955
|
-
* @param podId
|
|
2956
|
-
* @param pageToken
|
|
2957
|
-
* @param limit
|
|
2958
|
-
* @returns ConversationMessageListResponse Successful Response
|
|
2959
|
-
* @throws ApiError
|
|
2960
|
-
*/
|
|
2961
|
-
static conversationMessageList(conversationId, podId, pageToken, limit = 20) {
|
|
2962
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2963
|
-
method: 'GET',
|
|
2964
|
-
url: '/conversations/{conversation_id}/messages',
|
|
2965
|
-
path: {
|
|
2966
|
-
'conversation_id': conversationId,
|
|
2967
|
-
},
|
|
2968
|
-
query: {
|
|
2969
|
-
'pod_id': podId,
|
|
2970
|
-
'page_token': pageToken,
|
|
2971
|
-
'limit': limit,
|
|
2972
|
-
},
|
|
2973
|
-
errors: {
|
|
2974
|
-
422: `Validation Error`,
|
|
2975
|
-
},
|
|
2976
|
-
});
|
|
2977
|
-
}
|
|
2978
|
-
/**
|
|
2979
|
-
* Send Message (Stream)
|
|
2980
|
-
* @param conversationId
|
|
2981
|
-
* @param requestBody
|
|
2982
|
-
* @param podId
|
|
2983
|
-
* @returns any Server-Sent Events
|
|
2984
|
-
* @throws ApiError
|
|
2985
|
-
*/
|
|
2986
|
-
static conversationMessageCreate(conversationId, requestBody, podId) {
|
|
2987
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
2988
|
-
method: 'POST',
|
|
2989
|
-
url: '/conversations/{conversation_id}/messages',
|
|
2990
|
-
path: {
|
|
2991
|
-
'conversation_id': conversationId,
|
|
2992
|
-
},
|
|
2993
|
-
query: {
|
|
2994
|
-
'pod_id': podId,
|
|
2995
|
-
},
|
|
2996
|
-
body: requestBody,
|
|
2997
|
-
mediaType: 'application/json',
|
|
2998
|
-
errors: {
|
|
2999
|
-
422: `Validation Error`,
|
|
2708
|
+
body: payload,
|
|
2709
|
+
signal: options.signal,
|
|
2710
|
+
headers: {
|
|
2711
|
+
"Content-Type": "application/json",
|
|
2712
|
+
Accept: "text/event-stream",
|
|
3000
2713
|
},
|
|
3001
2714
|
});
|
|
3002
2715
|
}
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
* @returns any Server-Sent Events for an already-running conversation.
|
|
3008
|
-
* @throws ApiError
|
|
3009
|
-
*/
|
|
3010
|
-
static conversationStreamResume(conversationId, podId) {
|
|
3011
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
3012
|
-
method: 'GET',
|
|
3013
|
-
url: '/conversations/{conversation_id}/stream',
|
|
3014
|
-
path: {
|
|
3015
|
-
'conversation_id': conversationId,
|
|
2716
|
+
resumeStream(conversationId, options = {}) {
|
|
2717
|
+
return this.http.stream(`/conversations/${conversationId}/stream`, {
|
|
2718
|
+
params: {
|
|
2719
|
+
pod_id: options.podId ?? this.podId(),
|
|
3016
2720
|
},
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
errors: {
|
|
3021
|
-
422: `Validation Error`,
|
|
2721
|
+
signal: options.signal,
|
|
2722
|
+
headers: {
|
|
2723
|
+
Accept: "text/event-stream",
|
|
3022
2724
|
},
|
|
3023
2725
|
});
|
|
3024
2726
|
}
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
* @returns any Successful Response
|
|
3030
|
-
* @throws ApiError
|
|
3031
|
-
*/
|
|
3032
|
-
static conversationRunStop(conversationId, podId) {
|
|
3033
|
-
return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
|
|
3034
|
-
method: 'PATCH',
|
|
3035
|
-
url: '/conversations/{conversation_id}/stop',
|
|
3036
|
-
path: {
|
|
3037
|
-
'conversation_id': conversationId,
|
|
3038
|
-
},
|
|
3039
|
-
query: {
|
|
3040
|
-
'pod_id': podId,
|
|
3041
|
-
},
|
|
3042
|
-
errors: {
|
|
3043
|
-
422: `Validation Error`,
|
|
2727
|
+
stopRun(conversationId, options = {}) {
|
|
2728
|
+
return this.http.request("PATCH", `/conversations/${conversationId}/stop`, {
|
|
2729
|
+
params: {
|
|
2730
|
+
pod_id: options.podId ?? this.podId(),
|
|
3044
2731
|
},
|
|
2732
|
+
body: {},
|
|
3045
2733
|
});
|
|
3046
2734
|
}
|
|
3047
2735
|
}
|
|
3048
|
-
exports.
|
|
2736
|
+
exports.ConversationsNamespace = ConversationsNamespace;
|
|
3049
2737
|
|
|
3050
2738
|
},
|
|
3051
2739
|
"./namespaces/workflows.js": function (module, exports, require) {
|
|
@@ -3996,6 +3684,44 @@ class IntegrationsService {
|
|
|
3996
3684
|
}
|
|
3997
3685
|
exports.IntegrationsService = IntegrationsService;
|
|
3998
3686
|
|
|
3687
|
+
},
|
|
3688
|
+
"./namespaces/resources.js": function (module, exports, require) {
|
|
3689
|
+
"use strict";
|
|
3690
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3691
|
+
exports.ResourcesNamespace = void 0;
|
|
3692
|
+
class ResourcesNamespace {
|
|
3693
|
+
constructor(http) {
|
|
3694
|
+
this.http = http;
|
|
3695
|
+
}
|
|
3696
|
+
list(resourceType, resourceId, options = {}) {
|
|
3697
|
+
return this.http.request("GET", `/files/${resourceType}/${resourceId}/list`, {
|
|
3698
|
+
params: {
|
|
3699
|
+
path: options.path,
|
|
3700
|
+
},
|
|
3701
|
+
});
|
|
3702
|
+
}
|
|
3703
|
+
upload(resourceType, resourceId, file, options = {}) {
|
|
3704
|
+
const formData = new FormData();
|
|
3705
|
+
const fieldName = options.fieldName ?? "file";
|
|
3706
|
+
const name = options.name ?? (file instanceof File ? file.name : "upload.bin");
|
|
3707
|
+
formData.append(fieldName, file, name);
|
|
3708
|
+
return this.http.request("POST", `/files/${resourceType}/${resourceId}/upload`, {
|
|
3709
|
+
params: {
|
|
3710
|
+
path: options.path,
|
|
3711
|
+
},
|
|
3712
|
+
body: formData,
|
|
3713
|
+
isFormData: true,
|
|
3714
|
+
});
|
|
3715
|
+
}
|
|
3716
|
+
delete(resourceType, resourceId, filePath) {
|
|
3717
|
+
return this.http.request("DELETE", `/files/${resourceType}/${resourceId}/delete/${filePath}`);
|
|
3718
|
+
}
|
|
3719
|
+
download(resourceType, resourceId, filePath) {
|
|
3720
|
+
return this.http.requestBytes("GET", `/files/${resourceType}/${resourceId}/download/${filePath}`);
|
|
3721
|
+
}
|
|
3722
|
+
}
|
|
3723
|
+
exports.ResourcesNamespace = ResourcesNamespace;
|
|
3724
|
+
|
|
3999
3725
|
}
|
|
4000
3726
|
};
|
|
4001
3727
|
|