@getmodus/sdk 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/dist/_client-base-DQgSSU83.d.cts +71876 -0
- package/dist/_client-base-DQgSSU83.d.ts +71876 -0
- package/dist/{chunk-RK4NLJIN.cjs → chunk-QNATP2BM.cjs} +2630 -401
- package/dist/chunk-QNATP2BM.cjs.map +1 -0
- package/dist/{chunk-KX2P3TAH.js → chunk-SDGHNRZY.js} +2629 -400
- package/dist/chunk-SDGHNRZY.js.map +1 -0
- package/dist/index.cjs +564 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +335 -4
- package/dist/index.d.ts +335 -4
- package/dist/index.js +439 -5
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +5112 -2114
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +3941 -1403
- package/dist/management/index.d.ts +3941 -1403
- package/dist/management/index.js +5049 -2051
- package/dist/management/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/_client-base-CGqIZtrm.d.cts +0 -30124
- package/dist/_client-base-CGqIZtrm.d.ts +0 -30124
- package/dist/chunk-KX2P3TAH.js.map +0 -1
- package/dist/chunk-RK4NLJIN.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _chunkQNATP2BMcjs = require('./chunk-QNATP2BM.cjs');
|
|
35
35
|
|
|
36
36
|
// src/_agent_run_request.ts
|
|
37
37
|
var _crypto = require('crypto');
|
|
@@ -86,6 +86,24 @@ function* parseData(data, id) {
|
|
|
86
86
|
...withId
|
|
87
87
|
};
|
|
88
88
|
yield event;
|
|
89
|
+
} else if (eventType === "tool_end") {
|
|
90
|
+
const tool = data.tool;
|
|
91
|
+
if (data.subAgent || _optionalChain([tool, 'optionalAccess', _ => _.toolName]) !== "propose_browser_edit" || tool.success !== true) return;
|
|
92
|
+
let result = tool.result;
|
|
93
|
+
if (typeof result === "string") {
|
|
94
|
+
try {
|
|
95
|
+
result = JSON.parse(result);
|
|
96
|
+
} catch (e2) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const proposal = result;
|
|
101
|
+
if (_optionalChain([proposal, 'optionalAccess', _2 => _2.kind]) !== "browser_edit" || proposal.status !== "awaiting_user_application") return;
|
|
102
|
+
const { targetId, expectedValue, text } = proposal;
|
|
103
|
+
if (typeof targetId === "string" && typeof expectedValue === "string" && typeof text === "string" && text.length <= 1e5) {
|
|
104
|
+
const event = { type: "browser_draft", targetId, expectedValue, text, ...withId };
|
|
105
|
+
yield event;
|
|
106
|
+
}
|
|
89
107
|
} else if (eventType === "approval_required") {
|
|
90
108
|
const event = { type: "approval_required" };
|
|
91
109
|
for (const key of ["toolId", "toolName", "title", "description", "nodeId", "prompt"]) {
|
|
@@ -158,12 +176,13 @@ function effectiveThreadId(threadId) {
|
|
|
158
176
|
}
|
|
159
177
|
function runsPath(target) {
|
|
160
178
|
if (target.kind === "modus") return "/agent/v1/modus/runs";
|
|
179
|
+
if (target.kind === "scope-builder") return `/agent/v1/scopes/${encodeURIComponent(String(target.id))}/builder/runs`;
|
|
161
180
|
return `/agent/v1/${target.kind}/${encodeURIComponent(String(target.id))}/runs`;
|
|
162
181
|
}
|
|
163
182
|
function raiseForEvent(event) {
|
|
164
|
-
if (event.type === "error") throw new (0,
|
|
165
|
-
if (event.type === "cancelled") throw new (0,
|
|
166
|
-
if (event.type === "stream_timeout") throw new (0,
|
|
183
|
+
if (event.type === "error") throw new (0, _chunkQNATP2BMcjs.ModusError)(event.message, { requestId: event.requestId });
|
|
184
|
+
if (event.type === "cancelled") throw new (0, _chunkQNATP2BMcjs.RunCancelledError)();
|
|
185
|
+
if (event.type === "stream_timeout") throw new (0, _chunkQNATP2BMcjs.StreamTimeoutError)();
|
|
167
186
|
return event;
|
|
168
187
|
}
|
|
169
188
|
var ChatSession = class _ChatSession {
|
|
@@ -223,7 +242,7 @@ var ChatSession = class _ChatSession {
|
|
|
223
242
|
async result() {
|
|
224
243
|
for await (const _event of this.replay(true)) {
|
|
225
244
|
}
|
|
226
|
-
if (this.final === void 0) throw new (0,
|
|
245
|
+
if (this.final === void 0) throw new (0, _chunkQNATP2BMcjs.ModusError)("Chat stream ended without a done event");
|
|
227
246
|
return this.final;
|
|
228
247
|
}
|
|
229
248
|
/** Resolve with the final {@link ChatResult}, so the session can be awaited. */
|
|
@@ -257,14 +276,19 @@ var ChatSession = class _ChatSession {
|
|
|
257
276
|
*/
|
|
258
277
|
resume(input) {
|
|
259
278
|
if (this.final === void 0) {
|
|
260
|
-
throw new (0,
|
|
279
|
+
throw new (0, _chunkQNATP2BMcjs.ModusError)("resume() needs a finished run: await the chat first");
|
|
261
280
|
}
|
|
262
281
|
const { runId, threadId } = this.final;
|
|
263
|
-
|
|
282
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
283
|
+
const builder = this.request.path.includes("/builder/runs");
|
|
284
|
+
if (builder && (!_optionalChain([this, 'access', _3 => _3.approval, 'optionalAccess', _4 => _4.toolName]) || !this.approval.args)) {
|
|
285
|
+
throw new (0, _chunkQNATP2BMcjs.ModusError)("Scope builder resume requires its publish approval");
|
|
286
|
+
}
|
|
287
|
+
const sessionId = builder ? this.request.sessionId : threadId;
|
|
264
288
|
return new _ChatSession(this.http, {
|
|
265
|
-
path: `/agent/v1/runs/${encodeURIComponent(runId)}/resume`,
|
|
266
|
-
body: { sessionId
|
|
267
|
-
sessionId
|
|
289
|
+
path: builder ? `${this.request.path}/${encodeURIComponent(runId)}/resume` : `/agent/v1/runs/${encodeURIComponent(runId)}/resume`,
|
|
290
|
+
body: { sessionId, decision: input.decision, ...builder ? { approvalTarget: { toolName: this.approval.toolName, args: this.approval.args } } : {} },
|
|
291
|
+
sessionId,
|
|
268
292
|
baseUrl: this.request.baseUrl
|
|
269
293
|
});
|
|
270
294
|
}
|
|
@@ -275,7 +299,7 @@ var ChatSession = class _ChatSession {
|
|
|
275
299
|
*/
|
|
276
300
|
async close() {
|
|
277
301
|
this.finished = true;
|
|
278
|
-
await _optionalChain([this, 'access',
|
|
302
|
+
await _optionalChain([this, 'access', _5 => _5.live, 'optionalAccess', _6 => _6.return, 'call', _7 => _7(void 0)]);
|
|
279
303
|
}
|
|
280
304
|
// ponytail: one consumer at a time; concurrent iterators would race on `live`.
|
|
281
305
|
async *replay(resetAware) {
|
|
@@ -331,10 +355,10 @@ function startChat(http, config, target, message, options) {
|
|
|
331
355
|
}
|
|
332
356
|
}
|
|
333
357
|
function chatRequest(config, target, message, options) {
|
|
334
|
-
if (target.kind !== "modus")
|
|
335
|
-
const runsWithOwnModels = target.kind === "workflows";
|
|
336
|
-
if (!runsWithOwnModels)
|
|
337
|
-
const baseUrl =
|
|
358
|
+
if (target.kind !== "modus") _chunkQNATP2BMcjs.validateId.call(void 0, target.id, `${target.kind.slice(0, -1)}_id`);
|
|
359
|
+
const runsWithOwnModels = target.kind === "workflows" || target.kind === "scope-builder";
|
|
360
|
+
if (!runsWithOwnModels) _chunkQNATP2BMcjs.validateChatModel.call(void 0, options.model);
|
|
361
|
+
const baseUrl = _chunkQNATP2BMcjs.requireAgentHost.call(void 0, config);
|
|
338
362
|
const sessionId = resolveAgentRunSessionId(effectiveThreadId(options.threadId));
|
|
339
363
|
return {
|
|
340
364
|
path: runsPath(target),
|
|
@@ -348,6 +372,18 @@ function chatRequest(config, target, message, options) {
|
|
|
348
372
|
baseUrl
|
|
349
373
|
};
|
|
350
374
|
}
|
|
375
|
+
function resumeScopeBuilder(http, config, scopeId, runId, input) {
|
|
376
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, scopeId, "scope_id");
|
|
377
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
378
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, input.sessionId, "session_id");
|
|
379
|
+
const sessionId = input.sessionId;
|
|
380
|
+
return new ChatSession(http, {
|
|
381
|
+
path: `/agent/v1/scopes/${encodeURIComponent(String(scopeId))}/builder/runs/${encodeURIComponent(runId)}/resume`,
|
|
382
|
+
body: { ...input },
|
|
383
|
+
sessionId,
|
|
384
|
+
baseUrl: _chunkQNATP2BMcjs.requireAgentHost.call(void 0, config)
|
|
385
|
+
});
|
|
386
|
+
}
|
|
351
387
|
|
|
352
388
|
// src/types/workflows.ts
|
|
353
389
|
var WorkflowType = {
|
|
@@ -400,7 +436,7 @@ var WorkflowsResourceBase = class {
|
|
|
400
436
|
*/
|
|
401
437
|
list(options = {}) {
|
|
402
438
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
|
|
403
|
-
|
|
439
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize);
|
|
404
440
|
return this.listPage(pageSize, options.pageToken, options.search, options.type, options.view, options.includeVariation);
|
|
405
441
|
}
|
|
406
442
|
async listPage(pageSize, pageToken, search, type, view, includeVariation) {
|
|
@@ -409,12 +445,12 @@ var WorkflowsResourceBase = class {
|
|
|
409
445
|
if (type !== void 0) extra.type = type;
|
|
410
446
|
if (view !== void 0) extra.view = view;
|
|
411
447
|
if (includeVariation !== void 0) extra.includeVariation = includeVariation;
|
|
412
|
-
const data =
|
|
413
|
-
await
|
|
414
|
-
query:
|
|
448
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
449
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowsController_list", {
|
|
450
|
+
query: _chunkQNATP2BMcjs.aipListParams.call(void 0, pageSize, pageToken, extra)
|
|
415
451
|
})
|
|
416
452
|
);
|
|
417
|
-
return
|
|
453
|
+
return _chunkQNATP2BMcjs.buildAipPage.call(void 0,
|
|
418
454
|
data,
|
|
419
455
|
"workflows",
|
|
420
456
|
(raw) => raw,
|
|
@@ -428,7 +464,7 @@ var WorkflowsResourceBase = class {
|
|
|
428
464
|
var RUNS_MAX_PAGE_SIZE = 100;
|
|
429
465
|
function runsListParams(pageSize, pageToken, status, timeframe, approvalScope, search) {
|
|
430
466
|
const params = { pageSize };
|
|
431
|
-
const token =
|
|
467
|
+
const token = _chunkQNATP2BMcjs.normalizePageToken.call(void 0, pageToken);
|
|
432
468
|
if (token !== void 0) params.pageToken = token;
|
|
433
469
|
if (status !== void 0) params.status = status;
|
|
434
470
|
if (timeframe !== void 0) params.timeframe = timeframe;
|
|
@@ -438,7 +474,7 @@ function runsListParams(pageSize, pageToken, status, timeframe, approvalScope, s
|
|
|
438
474
|
}
|
|
439
475
|
function activeRunsParams(pageSize, pageToken) {
|
|
440
476
|
const params = { pageSize };
|
|
441
|
-
const token =
|
|
477
|
+
const token = _chunkQNATP2BMcjs.normalizePageToken.call(void 0, pageToken);
|
|
442
478
|
if (token !== void 0) params.pageToken = token;
|
|
443
479
|
return params;
|
|
444
480
|
}
|
|
@@ -446,26 +482,26 @@ function parseRun(raw) {
|
|
|
446
482
|
return raw;
|
|
447
483
|
}
|
|
448
484
|
function parseActiveRunsArray(raw) {
|
|
449
|
-
const data =
|
|
485
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0, raw);
|
|
450
486
|
const runs = data.runs;
|
|
451
487
|
if (!Array.isArray(runs)) {
|
|
452
|
-
throw new (0,
|
|
488
|
+
throw new (0, _chunkQNATP2BMcjs.ModusError)(
|
|
453
489
|
`Unexpected active runs response shape: runs must be a list, got ${typeof runs}.`
|
|
454
490
|
);
|
|
455
491
|
}
|
|
456
492
|
return runs;
|
|
457
493
|
}
|
|
458
494
|
function parseActiveRunsPage(raw, fetchPage) {
|
|
459
|
-
const data =
|
|
495
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0, raw);
|
|
460
496
|
const runs = data.runs;
|
|
461
497
|
if (!Array.isArray(runs)) {
|
|
462
|
-
throw new (0,
|
|
498
|
+
throw new (0, _chunkQNATP2BMcjs.ModusError)(
|
|
463
499
|
`Unexpected active runs response shape: runs must be a list, got ${typeof runs}.`
|
|
464
500
|
);
|
|
465
501
|
}
|
|
466
|
-
return new (0,
|
|
502
|
+
return new (0, _chunkQNATP2BMcjs.Page)(
|
|
467
503
|
runs,
|
|
468
|
-
|
|
504
|
+
_chunkQNATP2BMcjs.normalizePageToken.call(void 0,
|
|
469
505
|
typeof data.nextPageToken === "string" ? data.nextPageToken : void 0
|
|
470
506
|
),
|
|
471
507
|
fetchPage
|
|
@@ -478,8 +514,8 @@ function sessionIdFromBody(body) {
|
|
|
478
514
|
return resolveAgentRunSessionId(body.sessionId);
|
|
479
515
|
}
|
|
480
516
|
function requireSessionId(sessionId) {
|
|
481
|
-
if (!_optionalChain([sessionId, 'optionalAccess',
|
|
482
|
-
throw new (0,
|
|
517
|
+
if (!_optionalChain([sessionId, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()])) {
|
|
518
|
+
throw new (0, _chunkQNATP2BMcjs.ValidationError)("sessionId must be the run's conversation id (a non-empty string)");
|
|
483
519
|
}
|
|
484
520
|
}
|
|
485
521
|
function makeAgentRunStream(runId, events) {
|
|
@@ -519,14 +555,14 @@ var WorkflowRunsResource = class {
|
|
|
519
555
|
* ```
|
|
520
556
|
*/
|
|
521
557
|
list(workflowId, options = {}) {
|
|
522
|
-
|
|
558
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, workflowId, "workflow_id");
|
|
523
559
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
|
|
524
|
-
|
|
560
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize, RUNS_MAX_PAGE_SIZE);
|
|
525
561
|
return this.listPage(workflowId, pageSize, options.pageToken, options);
|
|
526
562
|
}
|
|
527
563
|
async listPage(workflowId, pageSize, pageToken, filters) {
|
|
528
|
-
const data =
|
|
529
|
-
await
|
|
564
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
565
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowRunsController_list", {
|
|
530
566
|
pathParams: { id: workflowId },
|
|
531
567
|
query: runsListParams(
|
|
532
568
|
pageSize,
|
|
@@ -540,13 +576,13 @@ var WorkflowRunsResource = class {
|
|
|
540
576
|
);
|
|
541
577
|
const runs = data.runs;
|
|
542
578
|
if (!Array.isArray(runs)) {
|
|
543
|
-
throw new (0,
|
|
579
|
+
throw new (0, _chunkQNATP2BMcjs.ModusError)(
|
|
544
580
|
`Unexpected list response shape: runs must be a list, got ${typeof runs}.`
|
|
545
581
|
);
|
|
546
582
|
}
|
|
547
|
-
return new (0,
|
|
583
|
+
return new (0, _chunkQNATP2BMcjs.Page)(
|
|
548
584
|
runs,
|
|
549
|
-
|
|
585
|
+
_chunkQNATP2BMcjs.normalizePageToken.call(void 0,
|
|
550
586
|
typeof data.nextPageToken === "string" ? data.nextPageToken : void 0
|
|
551
587
|
),
|
|
552
588
|
(token) => this.listPage(workflowId, pageSize, token, filters)
|
|
@@ -568,10 +604,10 @@ var WorkflowRunsResource = class {
|
|
|
568
604
|
* ```
|
|
569
605
|
*/
|
|
570
606
|
async get(workflowId, runId, options = {}) {
|
|
571
|
-
|
|
572
|
-
if (!runId.trim()) throw new (0,
|
|
607
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, workflowId, "workflow_id");
|
|
608
|
+
if (!runId.trim()) throw new (0, _chunkQNATP2BMcjs.ValidationError)("run_id must be a non-empty string");
|
|
573
609
|
const query = options.temporalRunId !== void 0 ? { temporalRunId: options.temporalRunId } : void 0;
|
|
574
|
-
const data = await
|
|
610
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowRunsController_get", {
|
|
575
611
|
pathParams: { id: workflowId, runId },
|
|
576
612
|
query
|
|
577
613
|
});
|
|
@@ -598,7 +634,7 @@ var WorkflowRunsResource = class {
|
|
|
598
634
|
* ```
|
|
599
635
|
*/
|
|
600
636
|
create(workflowId, body, options = {}) {
|
|
601
|
-
|
|
637
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, workflowId, "workflow_id");
|
|
602
638
|
return this.createRun("WorkflowRunsController_create", body, { id: workflowId }, options);
|
|
603
639
|
}
|
|
604
640
|
/**
|
|
@@ -623,7 +659,7 @@ var WorkflowRunsResource = class {
|
|
|
623
659
|
* ```
|
|
624
660
|
*/
|
|
625
661
|
createScope(scopeId, body, options = {}) {
|
|
626
|
-
|
|
662
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, scopeId, "scope_id");
|
|
627
663
|
return this.createRun("ScopeRunsController_create", body, { id: scopeId }, options);
|
|
628
664
|
}
|
|
629
665
|
/**
|
|
@@ -647,6 +683,122 @@ var WorkflowRunsResource = class {
|
|
|
647
683
|
createModus(body, options = {}) {
|
|
648
684
|
return this.createRun("ModusRunsController_create", body, {}, options);
|
|
649
685
|
}
|
|
686
|
+
/**
|
|
687
|
+
* Ask about the authorized dashboard.
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```ts
|
|
691
|
+
* const run = client.workflows.runs.askDashboard('DASHBOARD_ID', { message: 'Explain the results.', view: { filters: {} } })
|
|
692
|
+
* for await (const event of run) console.log(event.type)
|
|
693
|
+
* ```
|
|
694
|
+
*/
|
|
695
|
+
askDashboard(dashboardId, body, options = {}) {
|
|
696
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, dashboardId, "dashboard_id");
|
|
697
|
+
return this.createRun("DashboardAssistantController_createDashboard", body, { dashboardId }, options);
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Ask about a selected tile in the authorized dashboard.
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```ts
|
|
704
|
+
* const run = client.workflows.runs.askDashboardElement('DASHBOARD_ID', 'ELEMENT_ID', { message: 'Explain this tile.', view: { filters: {} } })
|
|
705
|
+
* for await (const event of run) console.log(event.type)
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
askDashboardElement(dashboardId, elementId, body, options = {}) {
|
|
709
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, dashboardId, "dashboard_id");
|
|
710
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, elementId, "element_id");
|
|
711
|
+
return this.createRun("DashboardAssistantController_create", body, { dashboardId, elementId }, options);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Edit the authorized dashboard working copy with the copilot.
|
|
715
|
+
*
|
|
716
|
+
* @example
|
|
717
|
+
* ```ts
|
|
718
|
+
* const run = client.workflows.runs.editDashboard('DASHBOARD_ID', { message: 'Group related tiles together.' })
|
|
719
|
+
* for await (const event of run) console.log(event.type)
|
|
720
|
+
* ```
|
|
721
|
+
*/
|
|
722
|
+
editDashboard(dashboardId, body, options = {}) {
|
|
723
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, dashboardId, "dashboard_id");
|
|
724
|
+
return this.createRun("DashboardCopilotController_createDashboard", body, { dashboardId }, options);
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Edit a selected element in the authorized dashboard working copy.
|
|
728
|
+
*
|
|
729
|
+
* @example
|
|
730
|
+
* ```ts
|
|
731
|
+
* const run = client.workflows.runs.editDashboardElement('DASHBOARD_ID', 'ELEMENT_ID', { message: 'Clarify this tile’s title.' })
|
|
732
|
+
* for await (const event of run) console.log(event.type)
|
|
733
|
+
* ```
|
|
734
|
+
*/
|
|
735
|
+
editDashboardElement(dashboardId, elementId, body, options = {}) {
|
|
736
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, dashboardId, "dashboard_id");
|
|
737
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, elementId, "element_id");
|
|
738
|
+
return this.createRun("DashboardCopilotController_create", body, { dashboardId, elementId }, options);
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Stream a proposal for replacement text using the selected published scopes.
|
|
742
|
+
* The proposal is returned in a typed `browser_draft` event.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```ts
|
|
746
|
+
* const draft = client.workflows.runs.createBrowserDraft({
|
|
747
|
+
* message: 'Rewrite this as a short reply.',
|
|
748
|
+
* subordinateSkillIds: [42],
|
|
749
|
+
* target: { id: 'reply', value: 'Thanks for sharing these notes.' },
|
|
750
|
+
* })
|
|
751
|
+
* for await (const event of draft) if (event.type === 'browser_draft') console.log(event.text)
|
|
752
|
+
* ```
|
|
753
|
+
*/
|
|
754
|
+
createBrowserDraft(body, options = {}) {
|
|
755
|
+
return this.createRun("BrowserDraftController_create", body, {}, options);
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Start or continue an assistant discussion for a Context suggestion.
|
|
759
|
+
*
|
|
760
|
+
* @param suggestionId - ID of the suggestion to discuss.
|
|
761
|
+
* @param body - Message and optional session ID to reuse on the next turn.
|
|
762
|
+
* @param options.idempotencyKey - Client key for retrying a request safely.
|
|
763
|
+
* @returns A stream of run events, including any proposed change awaiting approval.
|
|
764
|
+
*
|
|
765
|
+
* @example
|
|
766
|
+
* ```ts
|
|
767
|
+
* const stream = client.workflows.runs.createSuggestion('SUGGESTION_ID', {
|
|
768
|
+
* message: 'Explain the pros and cons of this change.',
|
|
769
|
+
* sessionId: 'suggestion-discussion',
|
|
770
|
+
* })
|
|
771
|
+
* for await (const event of stream) console.log(event.type)
|
|
772
|
+
* ```
|
|
773
|
+
*/
|
|
774
|
+
createSuggestion(suggestionId, body, options = {}) {
|
|
775
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, suggestionId, "suggestion_id");
|
|
776
|
+
return this.createRun("ContextSuggestionController_create", body, { suggestionId }, options);
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Answer a proposed change awaiting approval in a Context suggestion discussion.
|
|
780
|
+
*
|
|
781
|
+
* @param suggestionId - The suggestion discussed on the interrupted run.
|
|
782
|
+
* @param runId - ID of the interrupted run.
|
|
783
|
+
* @param body - Approval decision and the discussion session ID. An approval requires the exact `approvalTarget` from the pending event.
|
|
784
|
+
* @param options.idempotencyKey - Client key for retrying a request safely.
|
|
785
|
+
* @returns A stream of run events for the continuation.
|
|
786
|
+
*
|
|
787
|
+
* @example
|
|
788
|
+
* ```ts
|
|
789
|
+
* const stream = client.workflows.runs.resumeSuggestion('SUGGESTION_ID', 'RUN_ID', {
|
|
790
|
+
* decision: 'deny',
|
|
791
|
+
* sessionId: 'suggestion-discussion',
|
|
792
|
+
* })
|
|
793
|
+
* for await (const event of stream) console.log(event.type)
|
|
794
|
+
* ```
|
|
795
|
+
*/
|
|
796
|
+
resumeSuggestion(suggestionId, runId, body, options = {}) {
|
|
797
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, suggestionId, "suggestion_id");
|
|
798
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
799
|
+
requireSessionId(body.sessionId);
|
|
800
|
+
return this.createRun("ContextSuggestionController_resume", body, { suggestionId, runId }, options);
|
|
801
|
+
}
|
|
650
802
|
/**
|
|
651
803
|
* Resume a run paused at an approval or connect interrupt, and stream the continuation's events.
|
|
652
804
|
*
|
|
@@ -671,7 +823,7 @@ var WorkflowRunsResource = class {
|
|
|
671
823
|
* ```
|
|
672
824
|
*/
|
|
673
825
|
resume(runId, body, options = {}) {
|
|
674
|
-
|
|
826
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
675
827
|
requireSessionId(body.sessionId);
|
|
676
828
|
return this.createRun("ResumeRunsController_create", body, { runId }, options);
|
|
677
829
|
}
|
|
@@ -686,8 +838,8 @@ var WorkflowRunsResource = class {
|
|
|
686
838
|
* ```
|
|
687
839
|
*/
|
|
688
840
|
async cancel(runId) {
|
|
689
|
-
|
|
690
|
-
await
|
|
841
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
842
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_cancel", {
|
|
691
843
|
pathParams: { runId },
|
|
692
844
|
jsonBody: {}
|
|
693
845
|
});
|
|
@@ -700,8 +852,8 @@ var WorkflowRunsResource = class {
|
|
|
700
852
|
* `status` and `done`.
|
|
701
853
|
*/
|
|
702
854
|
async events(runId) {
|
|
703
|
-
|
|
704
|
-
return await
|
|
855
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
856
|
+
return await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_events", {
|
|
705
857
|
pathParams: { runId }
|
|
706
858
|
});
|
|
707
859
|
}
|
|
@@ -732,13 +884,13 @@ var WorkflowRunsResource = class {
|
|
|
732
884
|
* ```
|
|
733
885
|
*/
|
|
734
886
|
async interrupt(runId, nextRun, options = {}) {
|
|
735
|
-
|
|
887
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
736
888
|
requireSessionId(nextRun.sessionId);
|
|
737
889
|
const jsonBody = {
|
|
738
|
-
nextRun: { ...nextRun, runId: _optionalChain([nextRun, 'access',
|
|
890
|
+
nextRun: { ...nextRun, runId: _optionalChain([nextRun, 'access', _10 => _10.runId, 'optionalAccess', _11 => _11.trim, 'call', _12 => _12()]) || randomRunId() },
|
|
739
891
|
...options.lastSeenEventId ? { lastSeenEventId: options.lastSeenEventId } : {}
|
|
740
892
|
};
|
|
741
|
-
return await
|
|
893
|
+
return await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_interrupt", {
|
|
742
894
|
pathParams: { runId },
|
|
743
895
|
jsonBody
|
|
744
896
|
});
|
|
@@ -761,9 +913,9 @@ var WorkflowRunsResource = class {
|
|
|
761
913
|
* ```
|
|
762
914
|
*/
|
|
763
915
|
async editQueued(runId, nextRun) {
|
|
764
|
-
|
|
916
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
765
917
|
requireSessionId(nextRun.sessionId);
|
|
766
|
-
return await
|
|
918
|
+
return await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_editQueued", {
|
|
767
919
|
pathParams: { runId },
|
|
768
920
|
jsonBody: { nextRun }
|
|
769
921
|
});
|
|
@@ -777,12 +929,12 @@ var WorkflowRunsResource = class {
|
|
|
777
929
|
*/
|
|
778
930
|
active(options = {}) {
|
|
779
931
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 50));
|
|
780
|
-
|
|
932
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize, RUNS_MAX_PAGE_SIZE);
|
|
781
933
|
return this.activePage(pageSize, options.pageToken);
|
|
782
934
|
}
|
|
783
935
|
async activePage(pageSize, pageToken) {
|
|
784
936
|
return parseActiveRunsPage(
|
|
785
|
-
await
|
|
937
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_active", {
|
|
786
938
|
query: activeRunsParams(pageSize, pageToken)
|
|
787
939
|
}),
|
|
788
940
|
(token) => this.activePage(pageSize, token)
|
|
@@ -798,10 +950,10 @@ var WorkflowRunsResource = class {
|
|
|
798
950
|
async activeBySession(sessionIds) {
|
|
799
951
|
const uniqueSessionIds = [...new Set(sessionIds.map((id) => id.trim()).filter(Boolean))];
|
|
800
952
|
if (uniqueSessionIds.length > 100) {
|
|
801
|
-
throw new (0,
|
|
953
|
+
throw new (0, _chunkQNATP2BMcjs.ValidationError)("sessionIds must contain at most 100 ids");
|
|
802
954
|
}
|
|
803
955
|
return parseActiveRunsArray(
|
|
804
|
-
await
|
|
956
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "RunLifecycleController_activeBySession", {
|
|
805
957
|
jsonBody: { sessionIds: uniqueSessionIds }
|
|
806
958
|
})
|
|
807
959
|
);
|
|
@@ -824,26 +976,41 @@ var WorkflowRunsResource = class {
|
|
|
824
976
|
* ```
|
|
825
977
|
*/
|
|
826
978
|
stream(runId, options = {}) {
|
|
827
|
-
|
|
828
|
-
const op =
|
|
829
|
-
const path =
|
|
979
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
980
|
+
const op = _chunkQNATP2BMcjs.getOperation.call(void 0, "RunLifecycleController_stream");
|
|
981
|
+
const path = _chunkQNATP2BMcjs.formatOperationPath.call(void 0, "RunLifecycleController_stream", { runId });
|
|
830
982
|
const lines = this.http.streamGet(path, void 0, {
|
|
831
|
-
baseUrl:
|
|
983
|
+
baseUrl: _chunkQNATP2BMcjs.operationBaseUrl.call(void 0, this.http, op),
|
|
832
984
|
headers: options.lastEventId ? { "Last-Event-ID": options.lastEventId } : void 0
|
|
833
985
|
});
|
|
834
986
|
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
835
987
|
}
|
|
988
|
+
/**
|
|
989
|
+
* Stream a workflow builder turn. The editor can inspect other accessible workflows
|
|
990
|
+
* and change the one identified by workflowId.
|
|
991
|
+
*
|
|
992
|
+
* @example
|
|
993
|
+
* ```ts
|
|
994
|
+
* for await (const event of client.workflows.runs.createCopilot(42, { message: 'Explain this draft.' })) {
|
|
995
|
+
* console.log(event.type)
|
|
996
|
+
* }
|
|
997
|
+
* ```
|
|
998
|
+
*/
|
|
999
|
+
createCopilot(workflowId, body, options = {}) {
|
|
1000
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, workflowId, "workflow_id");
|
|
1001
|
+
return this.createRun("PublicWorkflowCopilotController_create", body, { workflowId }, options);
|
|
1002
|
+
}
|
|
836
1003
|
createRun(operationId, body, pathParams, options) {
|
|
837
|
-
const runId = _optionalChain([options, 'access',
|
|
1004
|
+
const runId = _optionalChain([options, 'access', _13 => _13.idempotencyKey, 'optionalAccess', _14 => _14.trim, 'call', _15 => _15()]) || _optionalChain([body, 'access', _16 => _16.runId, 'optionalAccess', _17 => _17.trim, 'call', _18 => _18()]) || randomRunId();
|
|
838
1005
|
const sessionId = sessionIdFromBody(body);
|
|
839
|
-
const op =
|
|
840
|
-
const path =
|
|
1006
|
+
const op = _chunkQNATP2BMcjs.getOperation.call(void 0, operationId);
|
|
1007
|
+
const path = _chunkQNATP2BMcjs.formatOperationPath.call(void 0, operationId, pathParams);
|
|
841
1008
|
const lines = this.http.streamPost(path, {
|
|
842
1009
|
...body,
|
|
843
1010
|
sessionId,
|
|
844
1011
|
streamProtocolVersion: 2
|
|
845
1012
|
}, {
|
|
846
|
-
baseUrl:
|
|
1013
|
+
baseUrl: _chunkQNATP2BMcjs.operationBaseUrl.call(void 0, this.http, op),
|
|
847
1014
|
headers: { "Idempotency-Key": runId }
|
|
848
1015
|
});
|
|
849
1016
|
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
@@ -872,11 +1039,11 @@ var AgentWorkflowActionsResource = class {
|
|
|
872
1039
|
* @returns A stream of run events for the action execution.
|
|
873
1040
|
*/
|
|
874
1041
|
execute(body, options = {}) {
|
|
875
|
-
const runId = _optionalChain([options, 'access',
|
|
876
|
-
const op =
|
|
877
|
-
const path =
|
|
1042
|
+
const runId = _optionalChain([options, 'access', _19 => _19.idempotencyKey, 'optionalAccess', _20 => _20.trim, 'call', _21 => _21()]) || _optionalChain([body, 'access', _22 => _22.runId, 'optionalAccess', _23 => _23.trim, 'call', _24 => _24()]) || randomRunId2();
|
|
1043
|
+
const op = _chunkQNATP2BMcjs.getOperation.call(void 0, "WorkflowActionsController_execute");
|
|
1044
|
+
const path = _chunkQNATP2BMcjs.formatOperationPath.call(void 0, "WorkflowActionsController_execute");
|
|
878
1045
|
const lines = this.http.streamPost(path, body, {
|
|
879
|
-
baseUrl:
|
|
1046
|
+
baseUrl: _chunkQNATP2BMcjs.operationBaseUrl.call(void 0, this.http, op),
|
|
880
1047
|
headers: { "Idempotency-Key": runId }
|
|
881
1048
|
});
|
|
882
1049
|
return makeAgentRunStream(runId, this.parseEvents(lines));
|
|
@@ -887,8 +1054,8 @@ var AgentWorkflowActionsResource = class {
|
|
|
887
1054
|
* @param runId - Action run id to cancel.
|
|
888
1055
|
*/
|
|
889
1056
|
async cancel(runId) {
|
|
890
|
-
|
|
891
|
-
await
|
|
1057
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, runId, "run_id");
|
|
1058
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowActionsController_cancel", {
|
|
892
1059
|
pathParams: { runId },
|
|
893
1060
|
jsonBody: {}
|
|
894
1061
|
});
|
|
@@ -926,13 +1093,13 @@ var WorkflowsResource = class extends WorkflowsResourceBase {
|
|
|
926
1093
|
* ```
|
|
927
1094
|
*/
|
|
928
1095
|
async get(workflowId, options = {}) {
|
|
929
|
-
|
|
1096
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, workflowId, "workflow_id");
|
|
930
1097
|
const query = {};
|
|
931
1098
|
if (options.view !== void 0) query.view = options.view;
|
|
932
1099
|
if (options.includeVariation !== void 0) {
|
|
933
1100
|
query.includeVariation = options.includeVariation;
|
|
934
1101
|
}
|
|
935
|
-
const data = await
|
|
1102
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "WorkflowsController_get", {
|
|
936
1103
|
pathParams: { id: workflowId },
|
|
937
1104
|
query: Object.keys(query).length > 0 ? query : void 0
|
|
938
1105
|
});
|
|
@@ -986,28 +1153,75 @@ var ConnectionsResourceBase = class {
|
|
|
986
1153
|
*/
|
|
987
1154
|
list(options = {}) {
|
|
988
1155
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
|
|
989
|
-
|
|
1156
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize);
|
|
990
1157
|
return this.listPage(pageSize, options.pageToken, options.type);
|
|
991
1158
|
}
|
|
992
1159
|
async listPage(pageSize, pageToken, type) {
|
|
993
1160
|
const extra = {};
|
|
994
1161
|
if (type !== void 0) extra.type = type;
|
|
995
|
-
const data =
|
|
996
|
-
await
|
|
997
|
-
query:
|
|
1162
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
1163
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ConnectionsController_list", {
|
|
1164
|
+
query: _chunkQNATP2BMcjs.aipListParams.call(void 0, pageSize, pageToken, extra)
|
|
998
1165
|
})
|
|
999
1166
|
);
|
|
1000
|
-
return
|
|
1167
|
+
return _chunkQNATP2BMcjs.buildAipPage.call(void 0,
|
|
1001
1168
|
data,
|
|
1002
1169
|
"connections",
|
|
1003
1170
|
(raw) => raw,
|
|
1004
1171
|
(token) => this.listPage(pageSize, token, type)
|
|
1005
1172
|
);
|
|
1006
1173
|
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Invoke an integration action.
|
|
1176
|
+
*
|
|
1177
|
+
* **Requires:** one of `workflows:invoke`, `connections:manage`
|
|
1178
|
+
*
|
|
1179
|
+
* @param request - Request body; see `InvokeConnectionAction`.
|
|
1180
|
+
*/
|
|
1181
|
+
async invokeAction(connectionId, operation, request) {
|
|
1182
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, connectionId, "connection_id");
|
|
1183
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, operation, "operation");
|
|
1184
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "HostedConnectionsController_invokePublicOperation", {
|
|
1185
|
+
pathParams: { connectionId, operationName: operation },
|
|
1186
|
+
jsonBody: _chunkQNATP2BMcjs.omitUndefined.call(void 0, request)
|
|
1187
|
+
});
|
|
1188
|
+
return data;
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Categorize integration app actions.
|
|
1192
|
+
*
|
|
1193
|
+
* **Requires:** one of `workflows:invoke`, `connections:manage`
|
|
1194
|
+
*
|
|
1195
|
+
* @param request - Request body; see `CategorizeIntegrationActions`.
|
|
1196
|
+
*/
|
|
1197
|
+
async categorizeActions(request) {
|
|
1198
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "PipedreamController_categorizePublicActions", {
|
|
1199
|
+
jsonBody: _chunkQNATP2BMcjs.omitUndefined.call(void 0, request)
|
|
1200
|
+
});
|
|
1201
|
+
return data;
|
|
1202
|
+
}
|
|
1007
1203
|
};
|
|
1008
1204
|
|
|
1009
1205
|
// src/resources/connections.ts
|
|
1010
1206
|
var ConnectionsResource = class extends ConnectionsResourceBase {
|
|
1207
|
+
/**
|
|
1208
|
+
* Read from a connection using an operation declared by its platform.
|
|
1209
|
+
*
|
|
1210
|
+
* @param connectionId - Connection ID.
|
|
1211
|
+
* @param operation - Platform read operation.
|
|
1212
|
+
* @param input - Operation-specific input.
|
|
1213
|
+
* @returns The operation-specific response.
|
|
1214
|
+
* @example
|
|
1215
|
+
* await client.connections.read('connection-id', 'query', { sql: 'SELECT 1' })
|
|
1216
|
+
*/
|
|
1217
|
+
async read(connectionId, operation, input = {}) {
|
|
1218
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, connectionId, "connectionId");
|
|
1219
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, operation, "operation");
|
|
1220
|
+
return _chunkQNATP2BMcjs.asRecord.call(void 0, _chunkQNATP2BMcjs.asRecord.call(void 0, await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ConnectionCapabilitiesController_readConnection", {
|
|
1221
|
+
pathParams: { connectionId, operationName: operation },
|
|
1222
|
+
jsonBody: { input }
|
|
1223
|
+
})).result);
|
|
1224
|
+
}
|
|
1011
1225
|
/**
|
|
1012
1226
|
* Find the first connection whose name matches (case-insensitive).
|
|
1013
1227
|
*
|
|
@@ -1020,12 +1234,12 @@ var ConnectionsResource = class extends ConnectionsResourceBase {
|
|
|
1020
1234
|
*/
|
|
1021
1235
|
async find(options) {
|
|
1022
1236
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
|
|
1023
|
-
|
|
1237
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize);
|
|
1024
1238
|
const target = options.name.trim().toLowerCase();
|
|
1025
1239
|
let token;
|
|
1026
1240
|
do {
|
|
1027
1241
|
const page = await this.listPage(pageSize, token, options.type);
|
|
1028
|
-
const match = page.items.find((c) => _optionalChain([c, 'access',
|
|
1242
|
+
const match = page.items.find((c) => _optionalChain([c, 'access', _25 => _25.name, 'optionalAccess', _26 => _26.toLowerCase, 'call', _27 => _27()]) === target);
|
|
1029
1243
|
if (match) return match;
|
|
1030
1244
|
if (!page.hasNextPage()) break;
|
|
1031
1245
|
token = page.nextPageToken;
|
|
@@ -1034,6 +1248,32 @@ var ConnectionsResource = class extends ConnectionsResourceBase {
|
|
|
1034
1248
|
}
|
|
1035
1249
|
};
|
|
1036
1250
|
|
|
1251
|
+
// src/_generated/resources/consumption/completions.ts
|
|
1252
|
+
var CompletionsResourceBase = class {
|
|
1253
|
+
/** @internal */
|
|
1254
|
+
constructor(http, config) {
|
|
1255
|
+
this.http = http;
|
|
1256
|
+
this.config = config;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Generate a text completion.
|
|
1260
|
+
*
|
|
1261
|
+
* **Requires:** one of `workflows:invoke`, `connections:manage`
|
|
1262
|
+
*
|
|
1263
|
+
* @param request - Request body; see `CompletionRequest`.
|
|
1264
|
+
*/
|
|
1265
|
+
async create(request) {
|
|
1266
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "CompletionsController_createCompletion", {
|
|
1267
|
+
jsonBody: _chunkQNATP2BMcjs.omitUndefined.call(void 0, request)
|
|
1268
|
+
});
|
|
1269
|
+
return data;
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
|
|
1273
|
+
// src/resources/completions.ts
|
|
1274
|
+
var CompletionsResource = class extends CompletionsResourceBase {
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1037
1277
|
// src/_generated/resources/consumption/context/items.ts
|
|
1038
1278
|
var ContextItemsResourceBase = class {
|
|
1039
1279
|
/** @internal */
|
|
@@ -1061,8 +1301,8 @@ var ContextItemsResourceBase = class {
|
|
|
1061
1301
|
* ```
|
|
1062
1302
|
*/
|
|
1063
1303
|
async query(query) {
|
|
1064
|
-
const data = await
|
|
1065
|
-
jsonBody:
|
|
1304
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsQueryController_query", {
|
|
1305
|
+
jsonBody: _chunkQNATP2BMcjs.omitUndefined.call(void 0, query)
|
|
1066
1306
|
});
|
|
1067
1307
|
return data;
|
|
1068
1308
|
}
|
|
@@ -1081,7 +1321,7 @@ function contextListParams(pageSize, pageToken, filters = {}) {
|
|
|
1081
1321
|
if (filters.connectionIds !== void 0) {
|
|
1082
1322
|
extra.connectionIds = filters.connectionIds.length === 0 ? "" : [...filters.connectionIds];
|
|
1083
1323
|
}
|
|
1084
|
-
return
|
|
1324
|
+
return _chunkQNATP2BMcjs.aipListParams.call(void 0, pageSize, pageToken, extra);
|
|
1085
1325
|
}
|
|
1086
1326
|
function parseContextItem(raw) {
|
|
1087
1327
|
return raw;
|
|
@@ -1143,7 +1383,7 @@ var ContextItemsResource = class extends ContextItemsResourceBase {
|
|
|
1143
1383
|
*/
|
|
1144
1384
|
list(options = {}) {
|
|
1145
1385
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
|
|
1146
|
-
|
|
1386
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize);
|
|
1147
1387
|
return this.listPage(pageSize, options.pageToken, {
|
|
1148
1388
|
contextType: options.contextType,
|
|
1149
1389
|
parentUids: options.parentUids,
|
|
@@ -1152,12 +1392,12 @@ var ContextItemsResource = class extends ContextItemsResourceBase {
|
|
|
1152
1392
|
});
|
|
1153
1393
|
}
|
|
1154
1394
|
async listPage(pageSize, pageToken, filters) {
|
|
1155
|
-
const data =
|
|
1156
|
-
await
|
|
1395
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
1396
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsController_list", {
|
|
1157
1397
|
query: contextListParams(pageSize, pageToken, filters)
|
|
1158
1398
|
})
|
|
1159
1399
|
);
|
|
1160
|
-
return
|
|
1400
|
+
return _chunkQNATP2BMcjs.buildAipPage.call(void 0,
|
|
1161
1401
|
data,
|
|
1162
1402
|
"contextItems",
|
|
1163
1403
|
parseContextItem,
|
|
@@ -1178,7 +1418,7 @@ var ContextItemsResource = class extends ContextItemsResourceBase {
|
|
|
1178
1418
|
* ```
|
|
1179
1419
|
*/
|
|
1180
1420
|
async get(uid) {
|
|
1181
|
-
const data = await
|
|
1421
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsController_get", {
|
|
1182
1422
|
pathParams: { uid }
|
|
1183
1423
|
});
|
|
1184
1424
|
return parseContextItem(data);
|
|
@@ -1201,20 +1441,20 @@ var ContextItemsResource = class extends ContextItemsResourceBase {
|
|
|
1201
1441
|
* ```
|
|
1202
1442
|
*/
|
|
1203
1443
|
async lookup(options) {
|
|
1204
|
-
const body =
|
|
1444
|
+
const body = _chunkQNATP2BMcjs.omitUndefined.call(void 0, {
|
|
1205
1445
|
contextType: options.contextType,
|
|
1206
1446
|
dataPath: options.dataPath,
|
|
1207
1447
|
contentProjection: options.contentProjection
|
|
1208
1448
|
});
|
|
1209
1449
|
try {
|
|
1210
|
-
const raw =
|
|
1211
|
-
await
|
|
1450
|
+
const raw = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
1451
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsController_lookup", {
|
|
1212
1452
|
jsonBody: body
|
|
1213
1453
|
})
|
|
1214
1454
|
);
|
|
1215
1455
|
return parseLookupResponse(raw);
|
|
1216
1456
|
} catch (error) {
|
|
1217
|
-
if (error instanceof
|
|
1457
|
+
if (error instanceof _chunkQNATP2BMcjs.NotFoundError) return void 0;
|
|
1218
1458
|
throw error;
|
|
1219
1459
|
}
|
|
1220
1460
|
}
|
|
@@ -1247,7 +1487,7 @@ var ContextItemsResource = class extends ContextItemsResourceBase {
|
|
|
1247
1487
|
*/
|
|
1248
1488
|
listValues(uid, contextType, contentKeyPath, options = {}) {
|
|
1249
1489
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
|
|
1250
|
-
|
|
1490
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize, _chunkQNATP2BMcjs.DEFAULT_MAX_PAGE_SIZE);
|
|
1251
1491
|
return this.listValuesPage(uid, contextType, contentKeyPath, pageSize, options.pageToken);
|
|
1252
1492
|
}
|
|
1253
1493
|
/**
|
|
@@ -1271,16 +1511,16 @@ var ContextItemsResource = class extends ContextItemsResourceBase {
|
|
|
1271
1511
|
return this.listValues(item.uid, item.contextType, contentKeyPath, options);
|
|
1272
1512
|
}
|
|
1273
1513
|
async listValuesPage(uid, contextType, contentKeyPath, pageSize, pageToken) {
|
|
1274
|
-
const data =
|
|
1275
|
-
await
|
|
1514
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
1515
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ContextItemsController_listValues", {
|
|
1276
1516
|
pathParams: { uid },
|
|
1277
|
-
query:
|
|
1517
|
+
query: _chunkQNATP2BMcjs.aipListParams.call(void 0, pageSize, pageToken, {
|
|
1278
1518
|
contextType,
|
|
1279
1519
|
contentKeyPath
|
|
1280
1520
|
})
|
|
1281
1521
|
})
|
|
1282
1522
|
);
|
|
1283
|
-
return
|
|
1523
|
+
return _chunkQNATP2BMcjs.buildAipPage.call(void 0,
|
|
1284
1524
|
data,
|
|
1285
1525
|
"values",
|
|
1286
1526
|
parseContextValueRow,
|
|
@@ -1294,7 +1534,7 @@ var ContextResource = class {
|
|
|
1294
1534
|
/** @internal */
|
|
1295
1535
|
constructor(http, config) {
|
|
1296
1536
|
this.items = new ContextItemsResource(http, config);
|
|
1297
|
-
this.customItems = new (0,
|
|
1537
|
+
this.customItems = new (0, _chunkQNATP2BMcjs.CustomContextItemsResource)(http, config);
|
|
1298
1538
|
}
|
|
1299
1539
|
};
|
|
1300
1540
|
|
|
@@ -1329,7 +1569,7 @@ var IngestedDataResource = class {
|
|
|
1329
1569
|
* ```
|
|
1330
1570
|
*/
|
|
1331
1571
|
async upload(options) {
|
|
1332
|
-
const data = await
|
|
1572
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "IngestedDataController_upload", {
|
|
1333
1573
|
jsonBody: {
|
|
1334
1574
|
integration_type: options.integrationType,
|
|
1335
1575
|
request: options.request,
|
|
@@ -1357,19 +1597,112 @@ var ModusConversationsResourceBase = class {
|
|
|
1357
1597
|
* @param threadId - Thread id from a conversation list or chat response.
|
|
1358
1598
|
*/
|
|
1359
1599
|
async get(threadId) {
|
|
1360
|
-
|
|
1361
|
-
const data = await
|
|
1600
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, threadId, "thread_id");
|
|
1601
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ModusConversationsController_get", {
|
|
1362
1602
|
pathParams: { threadId }
|
|
1363
1603
|
});
|
|
1364
1604
|
return data;
|
|
1365
1605
|
}
|
|
1606
|
+
/**
|
|
1607
|
+
* List shared conversations.
|
|
1608
|
+
*
|
|
1609
|
+
* Returns conversations shared with the authenticated user.
|
|
1610
|
+
*
|
|
1611
|
+
* **Requires:** `scopes:read`
|
|
1612
|
+
*
|
|
1613
|
+
* @param options.pageToken - Token from the previous page.
|
|
1614
|
+
* @param options.pageSize - Maximum results per page; defaults to 100.
|
|
1615
|
+
*
|
|
1616
|
+
* @example
|
|
1617
|
+
* ```ts
|
|
1618
|
+
* const shared = await client.modus.conversations.listShared()
|
|
1619
|
+
* ```
|
|
1620
|
+
*/
|
|
1621
|
+
async listShared(options = {}) {
|
|
1622
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ConversationSharingController_received", {
|
|
1623
|
+
query: { pageToken: options.pageToken, pageSize: options.pageSize }
|
|
1624
|
+
});
|
|
1625
|
+
return data;
|
|
1626
|
+
}
|
|
1627
|
+
/**
|
|
1628
|
+
* List conversation recipients.
|
|
1629
|
+
*
|
|
1630
|
+
* Returns user IDs with access to a conversation owned by the caller.
|
|
1631
|
+
*
|
|
1632
|
+
* **Requires:** `scopes:read`
|
|
1633
|
+
*
|
|
1634
|
+
* @param threadId - Conversation thread ID.
|
|
1635
|
+
* @param options.pageToken - Token from the previous page.
|
|
1636
|
+
* @param options.pageSize - Maximum results per page; defaults to 100.
|
|
1637
|
+
*
|
|
1638
|
+
* @example
|
|
1639
|
+
* ```ts
|
|
1640
|
+
* const readers = await client.modus.conversations.listRecipients(threadId)
|
|
1641
|
+
* ```
|
|
1642
|
+
*/
|
|
1643
|
+
async listRecipients(threadId, options = {}) {
|
|
1644
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, threadId, "thread_id");
|
|
1645
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ConversationSharingController_recipients", {
|
|
1646
|
+
pathParams: { threadId },
|
|
1647
|
+
query: { pageToken: options.pageToken, pageSize: options.pageSize }
|
|
1648
|
+
});
|
|
1649
|
+
return data;
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Share a conversation.
|
|
1653
|
+
*
|
|
1654
|
+
* Grants a member of the organization read access to the conversation and its files.
|
|
1655
|
+
*
|
|
1656
|
+
* **Requires:** `scopes:write`
|
|
1657
|
+
*
|
|
1658
|
+
* @param threadId - Conversation thread ID.
|
|
1659
|
+
* @param userId - Organization member user ID.
|
|
1660
|
+
* @param request - Request body; see `ShareConversationRequest`.
|
|
1661
|
+
* @returns Conversation access granted.
|
|
1662
|
+
*
|
|
1663
|
+
* @example
|
|
1664
|
+
* ```ts
|
|
1665
|
+
* await client.modus.conversations.share(threadId, userId, { title: 'Quarterly review' })
|
|
1666
|
+
* ```
|
|
1667
|
+
*/
|
|
1668
|
+
async share(threadId, userId, request) {
|
|
1669
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, threadId, "thread_id");
|
|
1670
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, userId, "user_id");
|
|
1671
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ConversationSharingController_share", {
|
|
1672
|
+
pathParams: { threadId, userId },
|
|
1673
|
+
jsonBody: request
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Revoke conversation access.
|
|
1678
|
+
*
|
|
1679
|
+
* Revokes a member’s access to a shared conversation.
|
|
1680
|
+
*
|
|
1681
|
+
* **Requires:** `scopes:write`
|
|
1682
|
+
*
|
|
1683
|
+
* @param threadId - Conversation thread ID.
|
|
1684
|
+
* @param userId - Organization member user ID.
|
|
1685
|
+
* @returns Conversation access revoked.
|
|
1686
|
+
*
|
|
1687
|
+
* @example
|
|
1688
|
+
* ```ts
|
|
1689
|
+
* await client.modus.conversations.revokeShare(threadId, userId)
|
|
1690
|
+
* ```
|
|
1691
|
+
*/
|
|
1692
|
+
async revokeShare(threadId, userId) {
|
|
1693
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, threadId, "thread_id");
|
|
1694
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, userId, "user_id");
|
|
1695
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ConversationSharingController_revoke", {
|
|
1696
|
+
pathParams: { threadId, userId }
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1366
1699
|
};
|
|
1367
1700
|
|
|
1368
1701
|
// src/resources/modus/conversations.ts
|
|
1369
1702
|
var ALLOWED_KINDS = /* @__PURE__ */ new Set(["all", "modus", "scopes"]);
|
|
1370
1703
|
function listParams(pageSize, pageToken, kind, source, sourceRef) {
|
|
1371
1704
|
if (kind !== void 0 && !ALLOWED_KINDS.has(kind)) {
|
|
1372
|
-
throw new (0,
|
|
1705
|
+
throw new (0, _chunkQNATP2BMcjs.ValidationError)(
|
|
1373
1706
|
`kind must be one of ${[...ALLOWED_KINDS].sort().join(", ")}, got ${JSON.stringify(kind)}`
|
|
1374
1707
|
);
|
|
1375
1708
|
}
|
|
@@ -1377,7 +1710,7 @@ function listParams(pageSize, pageToken, kind, source, sourceRef) {
|
|
|
1377
1710
|
if (kind !== void 0) extra.kind = kind;
|
|
1378
1711
|
if (source !== void 0) extra.source = source;
|
|
1379
1712
|
if (sourceRef !== void 0) extra.sourceRef = sourceRef;
|
|
1380
|
-
return
|
|
1713
|
+
return _chunkQNATP2BMcjs.aipListParams.call(void 0, pageSize, pageToken, extra);
|
|
1381
1714
|
}
|
|
1382
1715
|
function parseListItem(raw) {
|
|
1383
1716
|
return raw;
|
|
@@ -1404,16 +1737,16 @@ var ModusConversationsResource = class extends ModusConversationsResourceBase {
|
|
|
1404
1737
|
*/
|
|
1405
1738
|
list(options = {}) {
|
|
1406
1739
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
|
|
1407
|
-
|
|
1740
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize);
|
|
1408
1741
|
return this.listPage(pageSize, options.pageToken, options.kind, options.source, options.sourceRef);
|
|
1409
1742
|
}
|
|
1410
1743
|
async listPage(pageSize, pageToken, kind, source, sourceRef) {
|
|
1411
|
-
const data =
|
|
1412
|
-
await
|
|
1744
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
1745
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ModusConversationsController_list", {
|
|
1413
1746
|
query: listParams(pageSize, pageToken, kind, source, sourceRef)
|
|
1414
1747
|
})
|
|
1415
1748
|
);
|
|
1416
|
-
return
|
|
1749
|
+
return _chunkQNATP2BMcjs.buildAipPage.call(void 0,
|
|
1417
1750
|
data,
|
|
1418
1751
|
"conversations",
|
|
1419
1752
|
parseListItem,
|
|
@@ -1446,8 +1779,8 @@ var ModusResource = class {
|
|
|
1446
1779
|
* ```
|
|
1447
1780
|
*/
|
|
1448
1781
|
async getContext(message, options = {}) {
|
|
1449
|
-
const data = await
|
|
1450
|
-
jsonBody:
|
|
1782
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ModusContextComposeController_compose", {
|
|
1783
|
+
jsonBody: _chunkQNATP2BMcjs.omitUndefined.call(void 0, { message, limit: options.limit })
|
|
1451
1784
|
});
|
|
1452
1785
|
return data;
|
|
1453
1786
|
}
|
|
@@ -1514,7 +1847,7 @@ var ScopesResourceBase = class {
|
|
|
1514
1847
|
*/
|
|
1515
1848
|
list(options = {}) {
|
|
1516
1849
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( 25));
|
|
1517
|
-
|
|
1850
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize);
|
|
1518
1851
|
return this.listPage(pageSize, options.pageToken, options.search, options.view, options.managerId);
|
|
1519
1852
|
}
|
|
1520
1853
|
async listPage(pageSize, pageToken, search, view, managerId) {
|
|
@@ -1522,12 +1855,12 @@ var ScopesResourceBase = class {
|
|
|
1522
1855
|
if (search !== void 0) extra.search = search;
|
|
1523
1856
|
if (view !== void 0) extra.view = view;
|
|
1524
1857
|
if (managerId !== void 0) extra.managerId = managerId;
|
|
1525
|
-
const data =
|
|
1526
|
-
await
|
|
1527
|
-
query:
|
|
1858
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
1859
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ScopesController_list", {
|
|
1860
|
+
query: _chunkQNATP2BMcjs.aipListParams.call(void 0, pageSize, pageToken, extra)
|
|
1528
1861
|
})
|
|
1529
1862
|
);
|
|
1530
|
-
return
|
|
1863
|
+
return _chunkQNATP2BMcjs.buildAipPage.call(void 0,
|
|
1531
1864
|
data,
|
|
1532
1865
|
"scopes",
|
|
1533
1866
|
(raw) => raw,
|
|
@@ -1555,13 +1888,105 @@ var ScopesResourceBase = class {
|
|
|
1555
1888
|
* ```
|
|
1556
1889
|
*/
|
|
1557
1890
|
async get(scopeId, options = {}) {
|
|
1558
|
-
|
|
1559
|
-
const data = await
|
|
1891
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, scopeId, "scope_id");
|
|
1892
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ScopesController_get", {
|
|
1560
1893
|
pathParams: { id: scopeId },
|
|
1561
1894
|
query: { view: options.view }
|
|
1562
1895
|
});
|
|
1563
1896
|
return data;
|
|
1564
1897
|
}
|
|
1898
|
+
/**
|
|
1899
|
+
* Pick the scope for a chat message.
|
|
1900
|
+
*
|
|
1901
|
+
* Picks which of the published scopes the caller may use fits a chat message, or the scopes to
|
|
1902
|
+
* offer the caller when it cannot pick one.
|
|
1903
|
+
*
|
|
1904
|
+
* **Requires:** `scopes:read`
|
|
1905
|
+
*
|
|
1906
|
+
* @param request - Request body; see `ScopeRouteRequest`.
|
|
1907
|
+
*/
|
|
1908
|
+
async route(request) {
|
|
1909
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ScopeRoutingController_route", {
|
|
1910
|
+
jsonBody: request
|
|
1911
|
+
});
|
|
1912
|
+
return data;
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Create a conversation upload URL.
|
|
1916
|
+
*
|
|
1917
|
+
* Creates a short-lived URL for uploading a file to a conversation.
|
|
1918
|
+
*
|
|
1919
|
+
* **Requires:** `scopes:invoke`
|
|
1920
|
+
*
|
|
1921
|
+
* @param threadId - Conversation thread identifier.
|
|
1922
|
+
* @param request - Request body; see `ThreadUploadRequest`.
|
|
1923
|
+
*/
|
|
1924
|
+
async createUploadUrl(threadId, request) {
|
|
1925
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, threadId, "thread_id");
|
|
1926
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ThreadUploadsController_uploadUrl", {
|
|
1927
|
+
pathParams: { threadId },
|
|
1928
|
+
jsonBody: request
|
|
1929
|
+
});
|
|
1930
|
+
return data;
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Finalize a conversation upload.
|
|
1934
|
+
*
|
|
1935
|
+
* Finalizes an uploaded file so it can be used in a conversation.
|
|
1936
|
+
*
|
|
1937
|
+
* **Requires:** `scopes:invoke`
|
|
1938
|
+
*
|
|
1939
|
+
* @param threadId - Conversation thread identifier.
|
|
1940
|
+
* @param uploadId - Upload identifier.
|
|
1941
|
+
* @param request - Request body; see `ThreadUploadFileName`.
|
|
1942
|
+
*/
|
|
1943
|
+
async finalizeUpload(threadId, uploadId, request) {
|
|
1944
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, threadId, "thread_id");
|
|
1945
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, uploadId, "upload_id");
|
|
1946
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ThreadUploadsController_finalize", {
|
|
1947
|
+
pathParams: { threadId, uploadId },
|
|
1948
|
+
jsonBody: request
|
|
1949
|
+
});
|
|
1950
|
+
return data;
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1953
|
+
* Get conversation upload content URL.
|
|
1954
|
+
*
|
|
1955
|
+
* Returns a short-lived URL for the parsed content of an uploaded file.
|
|
1956
|
+
*
|
|
1957
|
+
* **Requires:** `scopes:invoke`
|
|
1958
|
+
*
|
|
1959
|
+
* @param threadId - Conversation thread identifier.
|
|
1960
|
+
* @param uploadId - Upload identifier.
|
|
1961
|
+
* @param request - Request body; see `ThreadUploadFileName`.
|
|
1962
|
+
*/
|
|
1963
|
+
async getUploadContentUrl(threadId, uploadId, request) {
|
|
1964
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, threadId, "thread_id");
|
|
1965
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, uploadId, "upload_id");
|
|
1966
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ThreadUploadsController_content", {
|
|
1967
|
+
pathParams: { threadId, uploadId },
|
|
1968
|
+
jsonBody: request
|
|
1969
|
+
});
|
|
1970
|
+
return data;
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Get assistant conversation history.
|
|
1974
|
+
*
|
|
1975
|
+
* Returns the caller’s assistant conversation, with an optional earlier message window.
|
|
1976
|
+
*
|
|
1977
|
+
* **Requires:** `scopes:read`
|
|
1978
|
+
*
|
|
1979
|
+
* @param threadId - Assistant conversation thread id.
|
|
1980
|
+
* @param options.beforeMessageIndex - Read messages before this index.
|
|
1981
|
+
*/
|
|
1982
|
+
async getAssistantHistory(threadId, options = {}) {
|
|
1983
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, threadId, "thread_id");
|
|
1984
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "AssistantsController_history", {
|
|
1985
|
+
pathParams: { threadId },
|
|
1986
|
+
query: { beforeMessageIndex: options.beforeMessageIndex }
|
|
1987
|
+
});
|
|
1988
|
+
return data;
|
|
1989
|
+
}
|
|
1565
1990
|
};
|
|
1566
1991
|
|
|
1567
1992
|
// src/resources/scopes.ts
|
|
@@ -1582,7 +2007,7 @@ var ScopesResource = class extends ScopesResourceBase {
|
|
|
1582
2007
|
* ```
|
|
1583
2008
|
*/
|
|
1584
2009
|
conversations(scopeId) {
|
|
1585
|
-
return new (0,
|
|
2010
|
+
return new (0, _chunkQNATP2BMcjs.ScopeConversationsResource)(this.http, this.config, scopeId);
|
|
1586
2011
|
}
|
|
1587
2012
|
/**
|
|
1588
2013
|
* Compose context this scope would use for an intent, without running chat.
|
|
@@ -1606,13 +2031,21 @@ var ScopesResource = class extends ScopesResourceBase {
|
|
|
1606
2031
|
* ```
|
|
1607
2032
|
*/
|
|
1608
2033
|
async getContext(scopeId, message, options = {}) {
|
|
1609
|
-
|
|
1610
|
-
const data = await
|
|
2034
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, scopeId, "scope_id");
|
|
2035
|
+
const data = await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "ScopeContextComposeController_compose", {
|
|
1611
2036
|
pathParams: { id: scopeId },
|
|
1612
|
-
jsonBody:
|
|
2037
|
+
jsonBody: _chunkQNATP2BMcjs.omitUndefined.call(void 0, { message, limit: options.limit })
|
|
1613
2038
|
});
|
|
1614
2039
|
return data;
|
|
1615
2040
|
}
|
|
2041
|
+
/** Start a builder turn for a scope the caller can manage. */
|
|
2042
|
+
build(scopeId, message, options = {}) {
|
|
2043
|
+
return startChat(this.http, this.config, { kind: "scope-builder", id: scopeId }, message, options);
|
|
2044
|
+
}
|
|
2045
|
+
/** Resume a stopped scope builder using the approval target emitted by the run. */
|
|
2046
|
+
resumeBuild(scopeId, runId, input) {
|
|
2047
|
+
return resumeScopeBuilder(this.http, this.config, scopeId, runId, input);
|
|
2048
|
+
}
|
|
1616
2049
|
/**
|
|
1617
2050
|
* Chat with a published scope. The reply streams live from the agent host:
|
|
1618
2051
|
* iterate `textStream()` for tokens, or `await` the result for the final
|
|
@@ -1655,7 +2088,7 @@ function suggestionListParams(options) {
|
|
|
1655
2088
|
pageSize: options.pageSize,
|
|
1656
2089
|
pageToken: options.pageToken,
|
|
1657
2090
|
scopeId: options.scopeId,
|
|
1658
|
-
scopeIds: _optionalChain([options, 'access',
|
|
2091
|
+
scopeIds: _optionalChain([options, 'access', _28 => _28.scopeIds, 'optionalAccess', _29 => _29.join, 'call', _30 => _30(",")])
|
|
1659
2092
|
};
|
|
1660
2093
|
}
|
|
1661
2094
|
var SuggestionsResource = class {
|
|
@@ -1675,19 +2108,19 @@ var SuggestionsResource = class {
|
|
|
1675
2108
|
*/
|
|
1676
2109
|
list(options = {}) {
|
|
1677
2110
|
const pageSize = _nullishCoalesce(options.pageSize, () => ( DEFAULT_SUGGESTIONS_PAGE_SIZE));
|
|
1678
|
-
|
|
1679
|
-
if (_optionalChain([options, 'access',
|
|
1680
|
-
throw new (0,
|
|
2111
|
+
_chunkQNATP2BMcjs.validatePageSize.call(void 0, pageSize, MAX_SUGGESTIONS_PAGE_SIZE);
|
|
2112
|
+
if (_optionalChain([options, 'access', _31 => _31.scopeIds, 'optionalAccess', _32 => _32.length]) === 0) {
|
|
2113
|
+
throw new (0, _chunkQNATP2BMcjs.ValidationError)("scopeIds requires at least one id; omit it to list suggestions for every scope");
|
|
1681
2114
|
}
|
|
1682
2115
|
return this.listPage(pageSize, options.pageToken, options.scopeId, options.scopeIds);
|
|
1683
2116
|
}
|
|
1684
2117
|
async listPage(pageSize, pageToken, scopeId, scopeIds) {
|
|
1685
|
-
const data =
|
|
1686
|
-
await
|
|
2118
|
+
const data = _chunkQNATP2BMcjs.asRecord.call(void 0,
|
|
2119
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "SuggestionsController_listApproved", {
|
|
1687
2120
|
query: suggestionListParams({ pageSize, pageToken, scopeId, scopeIds })
|
|
1688
2121
|
})
|
|
1689
2122
|
);
|
|
1690
|
-
return
|
|
2123
|
+
return _chunkQNATP2BMcjs.buildAipPage.call(void 0,
|
|
1691
2124
|
data,
|
|
1692
2125
|
"suggestions",
|
|
1693
2126
|
parseSuggestion,
|
|
@@ -1701,8 +2134,8 @@ var SuggestionsResource = class {
|
|
|
1701
2134
|
* @param event - Event details, including `eventType` (`shown`, `clicked`, `dismissed`, or `submitted`).
|
|
1702
2135
|
*/
|
|
1703
2136
|
async recordEvent(id, event) {
|
|
1704
|
-
|
|
1705
|
-
await
|
|
2137
|
+
_chunkQNATP2BMcjs.validateId.call(void 0, id, "id");
|
|
2138
|
+
await _chunkQNATP2BMcjs.invokeWithRetry.call(void 0, this.config, this.http, "SuggestionsController_recordEvent", {
|
|
1706
2139
|
pathParams: { id },
|
|
1707
2140
|
jsonBody: event
|
|
1708
2141
|
});
|
|
@@ -1710,7 +2143,7 @@ var SuggestionsResource = class {
|
|
|
1710
2143
|
};
|
|
1711
2144
|
|
|
1712
2145
|
// src/index.ts
|
|
1713
|
-
var Modus = class extends
|
|
2146
|
+
var Modus = class extends _chunkQNATP2BMcjs.ModusClientBase {
|
|
1714
2147
|
constructor(options = {}) {
|
|
1715
2148
|
super(options);
|
|
1716
2149
|
this.scopes = new ScopesResource(this.http, this.config);
|
|
@@ -1718,6 +2151,7 @@ var Modus = class extends _chunkRK4NLJINcjs.ModusClientBase {
|
|
|
1718
2151
|
this.workflows = new WorkflowsResource(this.http, this.config);
|
|
1719
2152
|
this.context = new ContextResource(this.http, this.config);
|
|
1720
2153
|
this.connections = new ConnectionsResource(this.http, this.config);
|
|
2154
|
+
this.completions = new CompletionsResource(this.http, this.config);
|
|
1721
2155
|
this.suggestions = new SuggestionsResource(this.http, this.config);
|
|
1722
2156
|
this.ingestedData = new IngestedDataResource(this.http, this.config);
|
|
1723
2157
|
}
|
|
@@ -1744,5 +2178,5 @@ var Modus = class extends _chunkRK4NLJINcjs.ModusClientBase {
|
|
|
1744
2178
|
|
|
1745
2179
|
|
|
1746
2180
|
|
|
1747
|
-
exports.APIConnectionError =
|
|
2181
|
+
exports.APIConnectionError = _chunkQNATP2BMcjs.APIConnectionError; exports.AgentType = AgentType; exports.AuthenticationError = _chunkQNATP2BMcjs.AuthenticationError; exports.BadRequestError = _chunkQNATP2BMcjs.BadRequestError; exports.ChatSession = ChatSession; exports.ConflictError = _chunkQNATP2BMcjs.ConflictError; exports.InternalServerError = _chunkQNATP2BMcjs.InternalServerError; exports.Modus = Modus; exports.ModusError = _chunkQNATP2BMcjs.ModusError; exports.NotFoundError = _chunkQNATP2BMcjs.NotFoundError; exports.OPERATIONS = _chunkQNATP2BMcjs.OPERATIONS; exports.Page = _chunkQNATP2BMcjs.Page; exports.PermissionDeniedError = _chunkQNATP2BMcjs.PermissionDeniedError; exports.RateLimitError = _chunkQNATP2BMcjs.RateLimitError; exports.RunCancelledError = _chunkQNATP2BMcjs.RunCancelledError; exports.StreamTimeoutError = _chunkQNATP2BMcjs.StreamTimeoutError; exports.UnprocessableError = _chunkQNATP2BMcjs.UnprocessableError; exports.ValidationError = _chunkQNATP2BMcjs.ValidationError; exports.WorkflowType = WorkflowType; exports.conversationScopeId = conversationScopeId; exports.conversationSkillId = conversationSkillId;
|
|
1748
2182
|
//# sourceMappingURL=index.cjs.map
|