@getmodus/sdk 0.12.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 +88 -0
- package/dist/_client-base-DQgSSU83.d.cts +71876 -0
- package/dist/_client-base-DQgSSU83.d.ts +71876 -0
- package/dist/{chunk-QHA3LF2Q.cjs → chunk-QNATP2BM.cjs} +2625 -406
- package/dist/chunk-QNATP2BM.cjs.map +1 -0
- package/dist/{chunk-3CKUUDEJ.js → chunk-SDGHNRZY.js} +2628 -409
- package/dist/chunk-SDGHNRZY.js.map +1 -0
- package/dist/index.cjs +559 -171
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +337 -37
- package/dist/index.d.ts +337 -37
- package/dist/index.js +434 -46
- 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 +3940 -1400
- package/dist/management/index.d.ts +3940 -1400
- package/dist/management/index.js +5049 -2051
- package/dist/management/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/_client-base-DvrAQWuU.d.cts +0 -30305
- package/dist/_client-base-DvrAQWuU.d.ts +0 -30305
- package/dist/chunk-3CKUUDEJ.js.map +0 -1
- package/dist/chunk-QHA3LF2Q.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
validateChatModel,
|
|
32
32
|
validateId,
|
|
33
33
|
validatePageSize
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-SDGHNRZY.js";
|
|
35
35
|
|
|
36
36
|
// src/_agent_run_request.ts
|
|
37
37
|
import { randomUUID } from "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 || tool?.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 {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const proposal = result;
|
|
101
|
+
if (proposal?.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,6 +176,7 @@ 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) {
|
|
@@ -261,10 +280,15 @@ var ChatSession = class _ChatSession {
|
|
|
261
280
|
}
|
|
262
281
|
const { runId, threadId } = this.final;
|
|
263
282
|
validateId(runId, "run_id");
|
|
283
|
+
const builder = this.request.path.includes("/builder/runs");
|
|
284
|
+
if (builder && (!this.approval?.toolName || !this.approval.args)) {
|
|
285
|
+
throw new 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
|
}
|
|
@@ -332,7 +356,7 @@ function startChat(http, config, target, message, options) {
|
|
|
332
356
|
}
|
|
333
357
|
function chatRequest(config, target, message, options) {
|
|
334
358
|
if (target.kind !== "modus") validateId(target.id, `${target.kind.slice(0, -1)}_id`);
|
|
335
|
-
const runsWithOwnModels = target.kind === "workflows";
|
|
359
|
+
const runsWithOwnModels = target.kind === "workflows" || target.kind === "scope-builder";
|
|
336
360
|
if (!runsWithOwnModels) validateChatModel(options.model);
|
|
337
361
|
const baseUrl = requireAgentHost(config);
|
|
338
362
|
const sessionId = resolveAgentRunSessionId(effectiveThreadId(options.threadId));
|
|
@@ -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
|
+
validateId(scopeId, "scope_id");
|
|
377
|
+
validateId(runId, "run_id");
|
|
378
|
+
validateId(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: requireAgentHost(config)
|
|
385
|
+
});
|
|
386
|
+
}
|
|
351
387
|
|
|
352
388
|
// src/types/workflows.ts
|
|
353
389
|
var WorkflowType = {
|
|
@@ -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
|
+
validateId(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
|
+
validateId(dashboardId, "dashboard_id");
|
|
710
|
+
validateId(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
|
+
validateId(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
|
+
validateId(dashboardId, "dashboard_id");
|
|
737
|
+
validateId(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
|
+
validateId(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
|
+
validateId(suggestionId, "suggestion_id");
|
|
798
|
+
validateId(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
|
*
|
|
@@ -833,6 +985,21 @@ var WorkflowRunsResource = class {
|
|
|
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
|
+
validateId(workflowId, "workflow_id");
|
|
1001
|
+
return this.createRun("PublicWorkflowCopilotController_create", body, { workflowId }, options);
|
|
1002
|
+
}
|
|
836
1003
|
createRun(operationId, body, pathParams, options) {
|
|
837
1004
|
const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId();
|
|
838
1005
|
const sessionId = sessionIdFromBody(body);
|
|
@@ -1004,10 +1171,57 @@ var ConnectionsResourceBase = class {
|
|
|
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
|
+
validateId(connectionId, "connection_id");
|
|
1183
|
+
validateId(operation, "operation");
|
|
1184
|
+
const data = await invokeWithRetry(this.config, this.http, "HostedConnectionsController_invokePublicOperation", {
|
|
1185
|
+
pathParams: { connectionId, operationName: operation },
|
|
1186
|
+
jsonBody: omitUndefined(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 invokeWithRetry(this.config, this.http, "PipedreamController_categorizePublicActions", {
|
|
1199
|
+
jsonBody: omitUndefined(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
|
+
validateId(connectionId, "connectionId");
|
|
1219
|
+
validateId(operation, "operation");
|
|
1220
|
+
return asRecord(asRecord(await invokeWithRetry(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
|
*
|
|
@@ -1032,54 +1246,34 @@ var ConnectionsResource = class extends ConnectionsResourceBase {
|
|
|
1032
1246
|
} while (token !== void 0);
|
|
1033
1247
|
return void 0;
|
|
1034
1248
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
* for await (const unit of client.connections.iterSelections('7a3f9d2c-1111-4000-a000-000000000abc')) {
|
|
1044
|
-
* console.log(unit.objectType, unit.path)
|
|
1045
|
-
* }
|
|
1046
|
-
*/
|
|
1047
|
-
listSelections(connectionId, options = {}) {
|
|
1048
|
-
validateId(connectionId, "connection_id");
|
|
1049
|
-
const pageSize = options.pageSize ?? 25;
|
|
1050
|
-
validatePageSize(pageSize);
|
|
1051
|
-
return this.listSelectionsPage(connectionId, pageSize, options.pageToken);
|
|
1052
|
-
}
|
|
1053
|
-
async listSelectionsPage(connectionId, pageSize, pageToken) {
|
|
1054
|
-
const data = asRecord(
|
|
1055
|
-
await invokeWithRetry(this.config, this.http, "ConnectionsController_listSelections", {
|
|
1056
|
-
pathParams: { connectionId },
|
|
1057
|
-
query: aipListParams(pageSize, pageToken)
|
|
1058
|
-
})
|
|
1059
|
-
);
|
|
1060
|
-
return buildAipPage(
|
|
1061
|
-
data,
|
|
1062
|
-
"selections",
|
|
1063
|
-
(raw) => raw,
|
|
1064
|
-
(token) => this.listSelectionsPage(connectionId, pageSize, token)
|
|
1065
|
-
);
|
|
1249
|
+
};
|
|
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;
|
|
1066
1257
|
}
|
|
1067
1258
|
/**
|
|
1068
|
-
*
|
|
1259
|
+
* Generate a text completion.
|
|
1069
1260
|
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1072
|
-
* @
|
|
1073
|
-
* for await (const unit of client.connections.iterSelections('7a3f9d2c-1111-4000-a000-000000000abc')) {
|
|
1074
|
-
* console.log(unit.objectType, unit.displayName)
|
|
1075
|
-
* }
|
|
1261
|
+
* **Requires:** one of `workflows:invoke`, `connections:manage`
|
|
1262
|
+
*
|
|
1263
|
+
* @param request - Request body; see `CompletionRequest`.
|
|
1076
1264
|
*/
|
|
1077
|
-
async
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1265
|
+
async create(request) {
|
|
1266
|
+
const data = await invokeWithRetry(this.config, this.http, "CompletionsController_createCompletion", {
|
|
1267
|
+
jsonBody: omitUndefined(request)
|
|
1268
|
+
});
|
|
1269
|
+
return data;
|
|
1080
1270
|
}
|
|
1081
1271
|
};
|
|
1082
1272
|
|
|
1273
|
+
// src/resources/completions.ts
|
|
1274
|
+
var CompletionsResource = class extends CompletionsResourceBase {
|
|
1275
|
+
};
|
|
1276
|
+
|
|
1083
1277
|
// src/_generated/resources/consumption/context/items.ts
|
|
1084
1278
|
var ContextItemsResourceBase = class {
|
|
1085
1279
|
/** @internal */
|
|
@@ -1409,6 +1603,99 @@ var ModusConversationsResourceBase = class {
|
|
|
1409
1603
|
});
|
|
1410
1604
|
return data;
|
|
1411
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 invokeWithRetry(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
|
+
validateId(threadId, "thread_id");
|
|
1645
|
+
const data = await invokeWithRetry(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
|
+
validateId(threadId, "thread_id");
|
|
1670
|
+
validateId(userId, "user_id");
|
|
1671
|
+
await invokeWithRetry(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
|
+
validateId(threadId, "thread_id");
|
|
1694
|
+
validateId(userId, "user_id");
|
|
1695
|
+
await invokeWithRetry(this.config, this.http, "ConversationSharingController_revoke", {
|
|
1696
|
+
pathParams: { threadId, userId }
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1412
1699
|
};
|
|
1413
1700
|
|
|
1414
1701
|
// src/resources/modus/conversations.ts
|
|
@@ -1608,6 +1895,98 @@ var ScopesResourceBase = class {
|
|
|
1608
1895
|
});
|
|
1609
1896
|
return data;
|
|
1610
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 invokeWithRetry(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
|
+
validateId(threadId, "thread_id");
|
|
1926
|
+
const data = await invokeWithRetry(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
|
+
validateId(threadId, "thread_id");
|
|
1945
|
+
validateId(uploadId, "upload_id");
|
|
1946
|
+
const data = await invokeWithRetry(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
|
+
validateId(threadId, "thread_id");
|
|
1965
|
+
validateId(uploadId, "upload_id");
|
|
1966
|
+
const data = await invokeWithRetry(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
|
+
validateId(threadId, "thread_id");
|
|
1984
|
+
const data = await invokeWithRetry(this.config, this.http, "AssistantsController_history", {
|
|
1985
|
+
pathParams: { threadId },
|
|
1986
|
+
query: { beforeMessageIndex: options.beforeMessageIndex }
|
|
1987
|
+
});
|
|
1988
|
+
return data;
|
|
1989
|
+
}
|
|
1611
1990
|
};
|
|
1612
1991
|
|
|
1613
1992
|
// src/resources/scopes.ts
|
|
@@ -1659,6 +2038,14 @@ var ScopesResource = class extends ScopesResourceBase {
|
|
|
1659
2038
|
});
|
|
1660
2039
|
return data;
|
|
1661
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
|
+
}
|
|
1662
2049
|
/**
|
|
1663
2050
|
* Chat with a published scope. The reply streams live from the agent host:
|
|
1664
2051
|
* iterate `textStream()` for tokens, or `await` the result for the final
|
|
@@ -1764,6 +2151,7 @@ var Modus = class extends ModusClientBase {
|
|
|
1764
2151
|
this.workflows = new WorkflowsResource(this.http, this.config);
|
|
1765
2152
|
this.context = new ContextResource(this.http, this.config);
|
|
1766
2153
|
this.connections = new ConnectionsResource(this.http, this.config);
|
|
2154
|
+
this.completions = new CompletionsResource(this.http, this.config);
|
|
1767
2155
|
this.suggestions = new SuggestionsResource(this.http, this.config);
|
|
1768
2156
|
this.ingestedData = new IngestedDataResource(this.http, this.config);
|
|
1769
2157
|
}
|