@getmodus/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +79 -0
- package/dist/chunk-VLHNZJBG.js +1681 -0
- package/dist/chunk-VLHNZJBG.js.map +1 -0
- package/dist/conversations-nx1ujbiv.d.cts +19329 -0
- package/dist/conversations-nx1ujbiv.d.ts +19329 -0
- package/dist/index.cjs +2546 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +365 -0
- package/dist/index.d.ts +365 -0
- package/dist/index.js +888 -0
- package/dist/index.js.map +1 -0
- package/dist/management/index.cjs +2514 -0
- package/dist/management/index.cjs.map +1 -0
- package/dist/management/index.d.cts +351 -0
- package/dist/management/index.d.ts +351 -0
- package/dist/management/index.js +896 -0
- package/dist/management/index.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,896 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CustomContextItemsResource,
|
|
3
|
+
ModusClientBase,
|
|
4
|
+
ScopeConversationsResource,
|
|
5
|
+
aipListParams,
|
|
6
|
+
asRecord,
|
|
7
|
+
buildAipPage,
|
|
8
|
+
invokeWithRetry,
|
|
9
|
+
omitUndefined,
|
|
10
|
+
validateId,
|
|
11
|
+
validatePageSize
|
|
12
|
+
} from "../chunk-VLHNZJBG.js";
|
|
13
|
+
|
|
14
|
+
// src/_query.ts
|
|
15
|
+
function updateMaskQuery(updateMask) {
|
|
16
|
+
if (updateMask === void 0) return void 0;
|
|
17
|
+
if (!updateMask.trim()) {
|
|
18
|
+
throw new Error("update_mask must be a non-empty comma-separated list of field names");
|
|
19
|
+
}
|
|
20
|
+
return { updateMask };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/management/_access-config.ts
|
|
24
|
+
var EVERYONE_GROUP_ID = "__everyone__";
|
|
25
|
+
function accessConfigWireForCreate(guardrails) {
|
|
26
|
+
return {
|
|
27
|
+
visibility: "shared",
|
|
28
|
+
groupPermissions: { [EVERYONE_GROUP_ID]: { use: true, manage: true } },
|
|
29
|
+
guardrails,
|
|
30
|
+
sharedWith: []
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function accessConfigWireForUpdate(existing, guardrails) {
|
|
34
|
+
if (!existing || Object.keys(existing).length === 0) {
|
|
35
|
+
return accessConfigWireForCreate(guardrails);
|
|
36
|
+
}
|
|
37
|
+
return { ...existing, guardrails };
|
|
38
|
+
}
|
|
39
|
+
function accessFromSkillResponse(raw) {
|
|
40
|
+
const value = raw.accessConfig ?? raw.access_config;
|
|
41
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
function accessConfigBodyForCreate(guardrails) {
|
|
47
|
+
if (guardrails === void 0) return void 0;
|
|
48
|
+
return accessConfigWireForCreate(guardrails);
|
|
49
|
+
}
|
|
50
|
+
async function accessConfigBodyForUpdate(guardrails, loadResource) {
|
|
51
|
+
if (guardrails === void 0) return void 0;
|
|
52
|
+
const existing = accessFromSkillResponse(await loadResource());
|
|
53
|
+
return accessConfigWireForUpdate(existing, guardrails);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/management/agents/interfaces.ts
|
|
57
|
+
var WorkflowInterfacesResource = class {
|
|
58
|
+
constructor(http, config, workflowId) {
|
|
59
|
+
this.http = http;
|
|
60
|
+
this.config = config;
|
|
61
|
+
this.workflowId = workflowId;
|
|
62
|
+
}
|
|
63
|
+
async list() {
|
|
64
|
+
validateId(this.workflowId, "workflow_id");
|
|
65
|
+
const data = await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_list", {
|
|
66
|
+
pathParams: { id: this.workflowId }
|
|
67
|
+
});
|
|
68
|
+
return data.interfaces;
|
|
69
|
+
}
|
|
70
|
+
async create(options) {
|
|
71
|
+
validateId(this.workflowId, "workflow_id");
|
|
72
|
+
return await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_add", {
|
|
73
|
+
pathParams: { id: this.workflowId },
|
|
74
|
+
jsonBody: omitUndefined(options)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async update(interfaceId, options, updateMask) {
|
|
78
|
+
validateId(this.workflowId, "workflow_id");
|
|
79
|
+
validateId(interfaceId, "interface_id");
|
|
80
|
+
return await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_update", {
|
|
81
|
+
pathParams: { id: this.workflowId, interfaceId },
|
|
82
|
+
query: updateMaskQuery(updateMask),
|
|
83
|
+
jsonBody: updateMask === void 0 ? omitUndefined(options) : options
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async delete(interfaceId) {
|
|
87
|
+
validateId(this.workflowId, "workflow_id");
|
|
88
|
+
validateId(interfaceId, "interface_id");
|
|
89
|
+
await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_delete", {
|
|
90
|
+
pathParams: { id: this.workflowId, interfaceId }
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async deleteAll() {
|
|
94
|
+
validateId(this.workflowId, "workflow_id");
|
|
95
|
+
await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_deleteAll", {
|
|
96
|
+
pathParams: { id: this.workflowId }
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/management/agents/agents.ts
|
|
102
|
+
var MANAGEMENT_WORKFLOW_OPERATIONS = {
|
|
103
|
+
list: "WorkflowsController_list",
|
|
104
|
+
get: "WorkflowsController_get",
|
|
105
|
+
create: "WorkflowsController_create",
|
|
106
|
+
update: "WorkflowsController_update",
|
|
107
|
+
deploy: "WorkflowsController_deploy",
|
|
108
|
+
delete: "WorkflowsController_delete",
|
|
109
|
+
restore: "WorkflowsController_restore",
|
|
110
|
+
requestOwnershipTransfer: "WorkflowsController_requestOwnershipTransfer",
|
|
111
|
+
cancelOwnershipTransfer: "WorkflowsController_cancelOwnershipTransfer",
|
|
112
|
+
acceptOwnershipTransfer: "WorkflowsController_acceptOwnershipTransfer",
|
|
113
|
+
toggle: "WorkflowsController_toggle"
|
|
114
|
+
};
|
|
115
|
+
function workflowsListParams(pageSize, pageToken, search, type, view, includeVariation) {
|
|
116
|
+
const extra = {};
|
|
117
|
+
if (search !== void 0) extra.search = search;
|
|
118
|
+
if (type !== void 0) extra.type = type;
|
|
119
|
+
if (view !== void 0) extra.view = view;
|
|
120
|
+
if (includeVariation !== void 0) extra.includeVariation = includeVariation;
|
|
121
|
+
return aipListParams(pageSize, pageToken, extra);
|
|
122
|
+
}
|
|
123
|
+
function parseWorkflow(raw) {
|
|
124
|
+
return raw;
|
|
125
|
+
}
|
|
126
|
+
var ManagementWorkflowsResource = class {
|
|
127
|
+
constructor(http, config) {
|
|
128
|
+
this.http = http;
|
|
129
|
+
this.config = config;
|
|
130
|
+
this.ops = MANAGEMENT_WORKFLOW_OPERATIONS;
|
|
131
|
+
}
|
|
132
|
+
list(options = {}) {
|
|
133
|
+
const pageSize = options.pageSize ?? 25;
|
|
134
|
+
validatePageSize(pageSize);
|
|
135
|
+
return this.listPage(
|
|
136
|
+
pageSize,
|
|
137
|
+
options.pageToken,
|
|
138
|
+
options.search,
|
|
139
|
+
options.type,
|
|
140
|
+
options.view,
|
|
141
|
+
options.includeVariation
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
async listPage(pageSize, pageToken, search, type, view, includeVariation) {
|
|
145
|
+
const data = asRecord(
|
|
146
|
+
await invokeWithRetry(this.config, this.http, this.ops.list, {
|
|
147
|
+
query: workflowsListParams(pageSize, pageToken, search, type, view, includeVariation)
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
return buildAipPage(
|
|
151
|
+
data,
|
|
152
|
+
"agents",
|
|
153
|
+
parseWorkflow,
|
|
154
|
+
(token) => this.listPage(pageSize, token, search, type, view, includeVariation)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
async get(workflowId, options = {}) {
|
|
158
|
+
validateId(workflowId, "workflow_id");
|
|
159
|
+
const query = options.view !== void 0 ? { view: options.view } : void 0;
|
|
160
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.get, {
|
|
161
|
+
pathParams: { id: workflowId },
|
|
162
|
+
query
|
|
163
|
+
});
|
|
164
|
+
return parseWorkflow(data);
|
|
165
|
+
}
|
|
166
|
+
interfaces(workflowId) {
|
|
167
|
+
return new WorkflowInterfacesResource(this.http, this.config, workflowId);
|
|
168
|
+
}
|
|
169
|
+
async create(options) {
|
|
170
|
+
const body = omitUndefined({
|
|
171
|
+
name: options.name,
|
|
172
|
+
type: options.type,
|
|
173
|
+
description: options.description,
|
|
174
|
+
trigger: options.trigger,
|
|
175
|
+
agentSelection: options.agentSelection,
|
|
176
|
+
workflowStructure: options.workflowStructure,
|
|
177
|
+
accessConfig: accessConfigBodyForCreate(options.guardrails)
|
|
178
|
+
});
|
|
179
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.create, {
|
|
180
|
+
jsonBody: body
|
|
181
|
+
});
|
|
182
|
+
return parseWorkflow(data);
|
|
183
|
+
}
|
|
184
|
+
async update(workflowId, options = {}) {
|
|
185
|
+
validateId(workflowId, "workflow_id");
|
|
186
|
+
const accessConfig = await accessConfigBodyForUpdate(
|
|
187
|
+
options.guardrails,
|
|
188
|
+
async () => asRecord(
|
|
189
|
+
await invokeWithRetry(this.config, this.http, this.ops.get, {
|
|
190
|
+
pathParams: { id: workflowId }
|
|
191
|
+
})
|
|
192
|
+
)
|
|
193
|
+
);
|
|
194
|
+
const fields = {
|
|
195
|
+
name: options.name,
|
|
196
|
+
type: options.type,
|
|
197
|
+
description: options.description,
|
|
198
|
+
trigger: options.trigger,
|
|
199
|
+
agentSelection: options.agentSelection,
|
|
200
|
+
workflowStructure: options.workflowStructure,
|
|
201
|
+
accessConfig
|
|
202
|
+
};
|
|
203
|
+
const body = options.updateMask !== void 0 ? fields : omitUndefined(fields);
|
|
204
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.update, {
|
|
205
|
+
pathParams: { id: workflowId },
|
|
206
|
+
query: updateMaskQuery(options.updateMask),
|
|
207
|
+
jsonBody: body
|
|
208
|
+
});
|
|
209
|
+
return parseWorkflow(data);
|
|
210
|
+
}
|
|
211
|
+
async deploy(workflowId) {
|
|
212
|
+
validateId(workflowId, "workflow_id");
|
|
213
|
+
const data = asRecord(
|
|
214
|
+
await invokeWithRetry(this.config, this.http, this.ops.deploy, {
|
|
215
|
+
pathParams: { id: workflowId },
|
|
216
|
+
jsonBody: {}
|
|
217
|
+
})
|
|
218
|
+
);
|
|
219
|
+
return parseWorkflow(data.agent);
|
|
220
|
+
}
|
|
221
|
+
async toggle(workflowId, options) {
|
|
222
|
+
validateId(workflowId, "workflow_id");
|
|
223
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.toggle, {
|
|
224
|
+
pathParams: { id: workflowId },
|
|
225
|
+
jsonBody: { active: options.active }
|
|
226
|
+
});
|
|
227
|
+
return parseWorkflow(data);
|
|
228
|
+
}
|
|
229
|
+
async delete(workflowId) {
|
|
230
|
+
validateId(workflowId, "workflow_id");
|
|
231
|
+
await invokeWithRetry(this.config, this.http, this.ops.delete, {
|
|
232
|
+
pathParams: { id: workflowId }
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
async restore(workflowId) {
|
|
236
|
+
validateId(workflowId, "workflow_id");
|
|
237
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
|
|
238
|
+
pathParams: { id: workflowId },
|
|
239
|
+
jsonBody: {}
|
|
240
|
+
});
|
|
241
|
+
return parseWorkflow(data);
|
|
242
|
+
}
|
|
243
|
+
async requestOwnershipTransfer(workflowId, options) {
|
|
244
|
+
validateId(workflowId, "workflow_id");
|
|
245
|
+
const data = await invokeWithRetry(
|
|
246
|
+
this.config,
|
|
247
|
+
this.http,
|
|
248
|
+
this.ops.requestOwnershipTransfer,
|
|
249
|
+
{
|
|
250
|
+
pathParams: { id: workflowId },
|
|
251
|
+
jsonBody: omitUndefined({ newOwnerUserId: options.newOwnerUserId })
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
return parseWorkflow(data);
|
|
255
|
+
}
|
|
256
|
+
async cancelOwnershipTransfer(workflowId) {
|
|
257
|
+
validateId(workflowId, "workflow_id");
|
|
258
|
+
const data = await invokeWithRetry(
|
|
259
|
+
this.config,
|
|
260
|
+
this.http,
|
|
261
|
+
this.ops.cancelOwnershipTransfer,
|
|
262
|
+
{ pathParams: { id: workflowId } }
|
|
263
|
+
);
|
|
264
|
+
return parseWorkflow(data);
|
|
265
|
+
}
|
|
266
|
+
async acceptOwnershipTransfer(workflowId) {
|
|
267
|
+
validateId(workflowId, "workflow_id");
|
|
268
|
+
const data = await invokeWithRetry(
|
|
269
|
+
this.config,
|
|
270
|
+
this.http,
|
|
271
|
+
this.ops.acceptOwnershipTransfer,
|
|
272
|
+
{ pathParams: { id: workflowId }, jsonBody: {} }
|
|
273
|
+
);
|
|
274
|
+
return parseWorkflow(data);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// src/management/context/_content-merge.ts
|
|
279
|
+
function requireContentDict(item, contextType) {
|
|
280
|
+
if (item.contextType !== contextType) {
|
|
281
|
+
throw new Error(`Expected contextType ${contextType}, got ${item.contextType}.`);
|
|
282
|
+
}
|
|
283
|
+
if (!item.content || typeof item.content !== "object" || Array.isArray(item.content)) {
|
|
284
|
+
throw new Error(`Context item ${item.uid} has no object content; cannot merge ${contextType} fields.`);
|
|
285
|
+
}
|
|
286
|
+
return item.content;
|
|
287
|
+
}
|
|
288
|
+
function mergeNoteContent(existing, options) {
|
|
289
|
+
return { ...existing, title: options.title, content: options.body };
|
|
290
|
+
}
|
|
291
|
+
function mergeLinkContent(existing, options) {
|
|
292
|
+
const merged = { ...existing };
|
|
293
|
+
if (options.title !== void 0) merged.title = options.title;
|
|
294
|
+
if (options.url !== void 0) merged.url = options.url;
|
|
295
|
+
return merged;
|
|
296
|
+
}
|
|
297
|
+
function mergeSavedQueryContent(existing, options) {
|
|
298
|
+
const merged = { ...existing, name: options.name, query: options.query };
|
|
299
|
+
if (options.connectionId !== void 0) merged.connectionId = options.connectionId;
|
|
300
|
+
if (options.path !== void 0) merged.path = options.path;
|
|
301
|
+
return merged;
|
|
302
|
+
}
|
|
303
|
+
async function resolveExistingContent(items, uid, contextType, existing) {
|
|
304
|
+
const item = existing ?? await items.get(uid);
|
|
305
|
+
return requireContentDict(item, contextType);
|
|
306
|
+
}
|
|
307
|
+
async function updateWithMergedContent(items, uid, options) {
|
|
308
|
+
if (options.existing) requireContentDict(options.existing, options.contextType);
|
|
309
|
+
return items.update(uid, {
|
|
310
|
+
contextType: options.contextType,
|
|
311
|
+
content: options.mergedContent,
|
|
312
|
+
description: options.description,
|
|
313
|
+
userFeedback: options.userFeedback,
|
|
314
|
+
topics: options.topics
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
async function resolveAndUpdateNote(items, uid, options) {
|
|
318
|
+
const content = await resolveExistingContent(items, uid, "note", options.existing);
|
|
319
|
+
return updateWithMergedContent(items, uid, {
|
|
320
|
+
contextType: "note",
|
|
321
|
+
mergedContent: mergeNoteContent(content, { title: options.title, body: options.body }),
|
|
322
|
+
existing: options.existing,
|
|
323
|
+
description: options.description,
|
|
324
|
+
userFeedback: options.userFeedback,
|
|
325
|
+
topics: options.topics
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
async function resolveAndUpdateSavedQuery(items, uid, options) {
|
|
329
|
+
const content = await resolveExistingContent(items, uid, "saved_query", options.existing);
|
|
330
|
+
return updateWithMergedContent(items, uid, {
|
|
331
|
+
contextType: "saved_query",
|
|
332
|
+
mergedContent: mergeSavedQueryContent(content, options),
|
|
333
|
+
existing: options.existing,
|
|
334
|
+
description: options.description,
|
|
335
|
+
userFeedback: options.userFeedback,
|
|
336
|
+
topics: options.topics
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
async function resolveAndUpdateLink(items, uid, options) {
|
|
340
|
+
if (options.title === void 0 && options.url === void 0 && options.description === void 0 && options.userFeedback === void 0 && options.topics === void 0) {
|
|
341
|
+
throw new Error("Provide at least one field to update.");
|
|
342
|
+
}
|
|
343
|
+
if (options.title === void 0 && options.url === void 0) {
|
|
344
|
+
return items.update(uid, {
|
|
345
|
+
description: options.description,
|
|
346
|
+
userFeedback: options.userFeedback,
|
|
347
|
+
topics: options.topics
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
const content = await resolveExistingContent(items, uid, "link", options.existing);
|
|
351
|
+
return updateWithMergedContent(items, uid, {
|
|
352
|
+
contextType: "link",
|
|
353
|
+
mergedContent: mergeLinkContent(content, { title: options.title, url: options.url }),
|
|
354
|
+
existing: options.existing,
|
|
355
|
+
description: options.description,
|
|
356
|
+
userFeedback: options.userFeedback,
|
|
357
|
+
topics: options.topics
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/management/context/items.ts
|
|
362
|
+
function contextListParams(pageSize, pageToken, contextType) {
|
|
363
|
+
const extra = {};
|
|
364
|
+
if (contextType !== void 0) extra.contextTypes = [contextType];
|
|
365
|
+
return aipListParams(pageSize, pageToken, extra);
|
|
366
|
+
}
|
|
367
|
+
function parseContextItem(raw) {
|
|
368
|
+
return raw;
|
|
369
|
+
}
|
|
370
|
+
var ManagementContextItemsResource = class {
|
|
371
|
+
constructor(http, config) {
|
|
372
|
+
this.http = http;
|
|
373
|
+
this.config = config;
|
|
374
|
+
}
|
|
375
|
+
list(options = {}) {
|
|
376
|
+
const pageSize = options.pageSize ?? 25;
|
|
377
|
+
validatePageSize(pageSize);
|
|
378
|
+
return this.listPage(pageSize, options.pageToken, options.contextType);
|
|
379
|
+
}
|
|
380
|
+
async listPage(pageSize, pageToken, contextType) {
|
|
381
|
+
const data = asRecord(
|
|
382
|
+
await invokeWithRetry(this.config, this.http, "ContextItemsController_list", {
|
|
383
|
+
query: contextListParams(pageSize, pageToken, contextType)
|
|
384
|
+
})
|
|
385
|
+
);
|
|
386
|
+
return buildAipPage(
|
|
387
|
+
data,
|
|
388
|
+
"contextItems",
|
|
389
|
+
parseContextItem,
|
|
390
|
+
(token) => this.listPage(pageSize, token, contextType)
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
async get(uid) {
|
|
394
|
+
const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_get", {
|
|
395
|
+
pathParams: { uid }
|
|
396
|
+
});
|
|
397
|
+
return parseContextItem(data);
|
|
398
|
+
}
|
|
399
|
+
async update(uid, options = {}) {
|
|
400
|
+
const body = options.updateMask !== void 0 ? {
|
|
401
|
+
content: options.content,
|
|
402
|
+
contextType: options.contextType,
|
|
403
|
+
description: options.description,
|
|
404
|
+
userFeedback: options.userFeedback,
|
|
405
|
+
topics: options.topics
|
|
406
|
+
} : omitUndefined({
|
|
407
|
+
content: options.content,
|
|
408
|
+
contextType: options.contextType,
|
|
409
|
+
description: options.description,
|
|
410
|
+
userFeedback: options.userFeedback,
|
|
411
|
+
topics: options.topics
|
|
412
|
+
});
|
|
413
|
+
await invokeWithRetry(this.config, this.http, "ContextItemsController_update", {
|
|
414
|
+
pathParams: { uid },
|
|
415
|
+
query: updateMaskQuery(options.updateMask),
|
|
416
|
+
jsonBody: body
|
|
417
|
+
});
|
|
418
|
+
return this.get(uid);
|
|
419
|
+
}
|
|
420
|
+
async delete(uid) {
|
|
421
|
+
const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_delete", {
|
|
422
|
+
pathParams: { uid }
|
|
423
|
+
});
|
|
424
|
+
return data;
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
// src/management/context/context.ts
|
|
429
|
+
var ManagementContextResource = class {
|
|
430
|
+
constructor(http, config) {
|
|
431
|
+
this.http = http;
|
|
432
|
+
this.config = config;
|
|
433
|
+
this.items = new ManagementContextItemsResource(http, config);
|
|
434
|
+
this.customItems = new CustomContextItemsResource(http, config);
|
|
435
|
+
}
|
|
436
|
+
async create(operationId, payload) {
|
|
437
|
+
const data = await invokeWithRetry(this.config, this.http, operationId, {
|
|
438
|
+
jsonBody: payload
|
|
439
|
+
});
|
|
440
|
+
return data;
|
|
441
|
+
}
|
|
442
|
+
createNote(title, content) {
|
|
443
|
+
return this.create("ContextCreatorsController_createNote", omitUndefined({ title, content }));
|
|
444
|
+
}
|
|
445
|
+
updateNote(uid, options) {
|
|
446
|
+
return resolveAndUpdateNote(this.items, uid, options);
|
|
447
|
+
}
|
|
448
|
+
createSavedQuery(name, options) {
|
|
449
|
+
return this.create(
|
|
450
|
+
"ContextCreatorsController_createSavedQuery",
|
|
451
|
+
omitUndefined({
|
|
452
|
+
name,
|
|
453
|
+
query: options.query,
|
|
454
|
+
connectionId: options.connectionId,
|
|
455
|
+
description: options.description,
|
|
456
|
+
path: options.path
|
|
457
|
+
})
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
updateSavedQuery(uid, options) {
|
|
461
|
+
return resolveAndUpdateSavedQuery(this.items, uid, options);
|
|
462
|
+
}
|
|
463
|
+
createLink(url, options = {}) {
|
|
464
|
+
return this.create(
|
|
465
|
+
"ContextCreatorsController_createLink",
|
|
466
|
+
omitUndefined({
|
|
467
|
+
url,
|
|
468
|
+
title: options.title,
|
|
469
|
+
isCrawl: options.isCrawl,
|
|
470
|
+
pageLimit: options.pageLimit
|
|
471
|
+
})
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
updateLink(uid, options) {
|
|
475
|
+
return resolveAndUpdateLink(this.items, uid, options);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// src/management/organization.ts
|
|
480
|
+
var ManagementOrganizationResource = class {
|
|
481
|
+
constructor(http, config) {
|
|
482
|
+
this.http = http;
|
|
483
|
+
this.config = config;
|
|
484
|
+
}
|
|
485
|
+
async delete() {
|
|
486
|
+
await invokeWithRetry(this.config, this.http, "OrganizationController_deleteOrganization");
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// src/management/skills/memories.ts
|
|
491
|
+
function parseMemory(raw) {
|
|
492
|
+
return raw;
|
|
493
|
+
}
|
|
494
|
+
var ScopeMemoriesResource = class {
|
|
495
|
+
constructor(http, config, scopeId) {
|
|
496
|
+
this.http = http;
|
|
497
|
+
this.config = config;
|
|
498
|
+
this.scopeId = scopeId;
|
|
499
|
+
}
|
|
500
|
+
list(options = {}) {
|
|
501
|
+
const pageSize = options.pageSize ?? 25;
|
|
502
|
+
validatePageSize(pageSize);
|
|
503
|
+
return this.listPage(pageSize, options.pageToken, options.userId);
|
|
504
|
+
}
|
|
505
|
+
async listPage(pageSize, pageToken, userId) {
|
|
506
|
+
validateId(this.scopeId, "scope_id");
|
|
507
|
+
const extra = {};
|
|
508
|
+
if (userId !== void 0) extra.userId = userId;
|
|
509
|
+
const data = asRecord(
|
|
510
|
+
await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_list", {
|
|
511
|
+
pathParams: { id: this.scopeId },
|
|
512
|
+
query: aipListParams(pageSize, pageToken, extra)
|
|
513
|
+
})
|
|
514
|
+
);
|
|
515
|
+
return buildAipPage(
|
|
516
|
+
data,
|
|
517
|
+
"memories",
|
|
518
|
+
parseMemory,
|
|
519
|
+
(token) => this.listPage(pageSize, token, userId)
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
async search(request) {
|
|
523
|
+
validateId(this.scopeId, "scope_id");
|
|
524
|
+
const data = await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_search", {
|
|
525
|
+
pathParams: { id: this.scopeId },
|
|
526
|
+
jsonBody: omitUndefined(request)
|
|
527
|
+
});
|
|
528
|
+
return data;
|
|
529
|
+
}
|
|
530
|
+
async update(memoryId, update, options = {}) {
|
|
531
|
+
validateId(memoryId, "memory_id");
|
|
532
|
+
validateId(this.scopeId, "scope_id");
|
|
533
|
+
const data = await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_update", {
|
|
534
|
+
pathParams: { id: this.scopeId, memoryId },
|
|
535
|
+
query: updateMaskQuery(options.updateMask),
|
|
536
|
+
jsonBody: omitUndefined(update)
|
|
537
|
+
});
|
|
538
|
+
return parseMemory(data);
|
|
539
|
+
}
|
|
540
|
+
async delete(memoryId) {
|
|
541
|
+
validateId(memoryId, "memory_id");
|
|
542
|
+
validateId(this.scopeId, "scope_id");
|
|
543
|
+
await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_delete", {
|
|
544
|
+
pathParams: { id: this.scopeId, memoryId }
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
// src/management/skills/evaluations.ts
|
|
550
|
+
function parseConfig(raw) {
|
|
551
|
+
return raw;
|
|
552
|
+
}
|
|
553
|
+
function parseRun(raw) {
|
|
554
|
+
return raw;
|
|
555
|
+
}
|
|
556
|
+
var ScopeEvaluationsResource = class {
|
|
557
|
+
constructor(http, config, scopeId) {
|
|
558
|
+
this.http = http;
|
|
559
|
+
this.config = config;
|
|
560
|
+
this.scopeId = scopeId;
|
|
561
|
+
}
|
|
562
|
+
async getConfig() {
|
|
563
|
+
validateId(this.scopeId, "scope_id");
|
|
564
|
+
const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_getConfig", {
|
|
565
|
+
pathParams: { id: this.scopeId }
|
|
566
|
+
});
|
|
567
|
+
return parseConfig(data);
|
|
568
|
+
}
|
|
569
|
+
async updateConfig(update) {
|
|
570
|
+
validateId(this.scopeId, "scope_id");
|
|
571
|
+
const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_updateConfig", {
|
|
572
|
+
pathParams: { id: this.scopeId },
|
|
573
|
+
jsonBody: omitUndefined(update)
|
|
574
|
+
});
|
|
575
|
+
return parseConfig(data);
|
|
576
|
+
}
|
|
577
|
+
async triggerRun() {
|
|
578
|
+
validateId(this.scopeId, "scope_id");
|
|
579
|
+
const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_triggerRun", {
|
|
580
|
+
pathParams: { id: this.scopeId }
|
|
581
|
+
});
|
|
582
|
+
return data;
|
|
583
|
+
}
|
|
584
|
+
listRuns(options = {}) {
|
|
585
|
+
const pageSize = options.pageSize ?? 25;
|
|
586
|
+
validatePageSize(pageSize);
|
|
587
|
+
return this.listRunsPage(pageSize, options.pageToken);
|
|
588
|
+
}
|
|
589
|
+
async listRunsPage(pageSize, pageToken) {
|
|
590
|
+
validateId(this.scopeId, "scope_id");
|
|
591
|
+
const data = asRecord(
|
|
592
|
+
await invokeWithRetry(this.config, this.http, "EvaluationsController_listRuns", {
|
|
593
|
+
pathParams: { id: this.scopeId },
|
|
594
|
+
query: aipListParams(pageSize, pageToken)
|
|
595
|
+
})
|
|
596
|
+
);
|
|
597
|
+
return buildAipPage(data, "runs", parseRun, (token) => this.listRunsPage(pageSize, token));
|
|
598
|
+
}
|
|
599
|
+
async getRun(runId) {
|
|
600
|
+
validateId(this.scopeId, "scope_id");
|
|
601
|
+
validateId(runId, "run_id");
|
|
602
|
+
const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_getRun", {
|
|
603
|
+
pathParams: { id: this.scopeId, runId }
|
|
604
|
+
});
|
|
605
|
+
return data;
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
// src/management/skills/supervision.ts
|
|
610
|
+
var ScopeSupervisionResource = class {
|
|
611
|
+
constructor(http, config, scopeId) {
|
|
612
|
+
this.http = http;
|
|
613
|
+
this.config = config;
|
|
614
|
+
this.scopeId = scopeId;
|
|
615
|
+
}
|
|
616
|
+
async get(options = {}) {
|
|
617
|
+
validateId(this.scopeId, "scope_id");
|
|
618
|
+
return await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_get", {
|
|
619
|
+
pathParams: { id: this.scopeId },
|
|
620
|
+
query: options.view === void 0 ? void 0 : { view: options.view }
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
async set(request) {
|
|
624
|
+
return this.write("ScopeSupervisionController_set", request);
|
|
625
|
+
}
|
|
626
|
+
async setActive(request) {
|
|
627
|
+
return this.write("ScopeSupervisionController_setActive", request);
|
|
628
|
+
}
|
|
629
|
+
async write(operation, request) {
|
|
630
|
+
validateId(this.scopeId, "scope_id");
|
|
631
|
+
return await invokeWithRetry(this.config, this.http, operation, {
|
|
632
|
+
pathParams: { id: this.scopeId },
|
|
633
|
+
jsonBody: request
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
// src/management/skills/skills.ts
|
|
639
|
+
var MANAGEMENT_SCOPE_OPERATIONS = {
|
|
640
|
+
list: "ScopesController_list",
|
|
641
|
+
get: "ScopesController_get",
|
|
642
|
+
create: "ScopesController_create",
|
|
643
|
+
update: "ScopesController_update",
|
|
644
|
+
deploy: "ScopesController_deploy",
|
|
645
|
+
delete: "ScopesController_delete",
|
|
646
|
+
restore: "ScopesController_restore",
|
|
647
|
+
requestOwnershipTransfer: "ScopesController_requestOwnershipTransfer",
|
|
648
|
+
cancelOwnershipTransfer: "ScopesController_cancelOwnershipTransfer",
|
|
649
|
+
acceptOwnershipTransfer: "ScopesController_acceptOwnershipTransfer",
|
|
650
|
+
patchMcpConfig: "ScopesController_patchMcpConfig",
|
|
651
|
+
getVariation: "ScopesController_getVariation"
|
|
652
|
+
};
|
|
653
|
+
function scopesListParams(pageSize, pageToken, search, view, managerId) {
|
|
654
|
+
const extra = {};
|
|
655
|
+
if (search !== void 0) extra.search = search;
|
|
656
|
+
if (view !== void 0) extra.view = view;
|
|
657
|
+
if (managerId !== void 0) extra.managerId = managerId;
|
|
658
|
+
return aipListParams(pageSize, pageToken, extra);
|
|
659
|
+
}
|
|
660
|
+
function parseScope(raw) {
|
|
661
|
+
return raw;
|
|
662
|
+
}
|
|
663
|
+
var ManagementScopesResource = class {
|
|
664
|
+
constructor(http, config) {
|
|
665
|
+
this.http = http;
|
|
666
|
+
this.config = config;
|
|
667
|
+
this.ops = MANAGEMENT_SCOPE_OPERATIONS;
|
|
668
|
+
}
|
|
669
|
+
conversations(scopeId) {
|
|
670
|
+
return new ScopeConversationsResource(this.http, this.config, scopeId);
|
|
671
|
+
}
|
|
672
|
+
memories(scopeId) {
|
|
673
|
+
return new ScopeMemoriesResource(this.http, this.config, scopeId);
|
|
674
|
+
}
|
|
675
|
+
evaluations(scopeId) {
|
|
676
|
+
return new ScopeEvaluationsResource(this.http, this.config, scopeId);
|
|
677
|
+
}
|
|
678
|
+
supervision(scopeId) {
|
|
679
|
+
return new ScopeSupervisionResource(this.http, this.config, scopeId);
|
|
680
|
+
}
|
|
681
|
+
list(options = {}) {
|
|
682
|
+
const pageSize = options.pageSize ?? 25;
|
|
683
|
+
validatePageSize(pageSize);
|
|
684
|
+
return this.listPage(
|
|
685
|
+
pageSize,
|
|
686
|
+
options.pageToken,
|
|
687
|
+
options.search,
|
|
688
|
+
options.view,
|
|
689
|
+
options.managerId
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
async listPage(pageSize, pageToken, search, view, managerId) {
|
|
693
|
+
const data = asRecord(
|
|
694
|
+
await invokeWithRetry(this.config, this.http, this.ops.list, {
|
|
695
|
+
query: scopesListParams(pageSize, pageToken, search, view, managerId)
|
|
696
|
+
})
|
|
697
|
+
);
|
|
698
|
+
return buildAipPage(
|
|
699
|
+
data,
|
|
700
|
+
"skills",
|
|
701
|
+
parseScope,
|
|
702
|
+
(token) => this.listPage(pageSize, token, search, view, managerId)
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
async get(scopeId, options = {}) {
|
|
706
|
+
validateId(scopeId, "scope_id");
|
|
707
|
+
const query = options.view !== void 0 ? { view: options.view } : void 0;
|
|
708
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.get, {
|
|
709
|
+
pathParams: { id: scopeId },
|
|
710
|
+
query
|
|
711
|
+
});
|
|
712
|
+
return parseScope(data);
|
|
713
|
+
}
|
|
714
|
+
async create(options) {
|
|
715
|
+
const body = omitUndefined({
|
|
716
|
+
name: options.name,
|
|
717
|
+
description: options.description,
|
|
718
|
+
expectedOutput: options.expectedOutput,
|
|
719
|
+
instructions: options.instructions,
|
|
720
|
+
toolset: options.toolset,
|
|
721
|
+
model: options.model,
|
|
722
|
+
connectionSet: options.connectionSet,
|
|
723
|
+
contextSelections: options.contextSelections,
|
|
724
|
+
interfaces: options.interfaces,
|
|
725
|
+
accessConfig: accessConfigBodyForCreate(options.guardrails)
|
|
726
|
+
});
|
|
727
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.create, {
|
|
728
|
+
jsonBody: body
|
|
729
|
+
});
|
|
730
|
+
return parseScope(data);
|
|
731
|
+
}
|
|
732
|
+
async update(scopeId, options = {}) {
|
|
733
|
+
validateId(scopeId, "scope_id");
|
|
734
|
+
const accessConfig = await accessConfigBodyForUpdate(
|
|
735
|
+
options.guardrails,
|
|
736
|
+
async () => asRecord(
|
|
737
|
+
await invokeWithRetry(this.config, this.http, this.ops.get, {
|
|
738
|
+
pathParams: { id: scopeId }
|
|
739
|
+
})
|
|
740
|
+
)
|
|
741
|
+
);
|
|
742
|
+
const fields = {
|
|
743
|
+
name: options.name,
|
|
744
|
+
description: options.description,
|
|
745
|
+
expectedOutput: options.expectedOutput,
|
|
746
|
+
instructions: options.instructions,
|
|
747
|
+
toolset: options.toolset,
|
|
748
|
+
model: options.model,
|
|
749
|
+
connectionSet: options.connectionSet,
|
|
750
|
+
contextSelections: options.contextSelections,
|
|
751
|
+
interfaces: options.interfaces,
|
|
752
|
+
accessConfig,
|
|
753
|
+
managerId: options.managerId,
|
|
754
|
+
evaluations: options.evaluations,
|
|
755
|
+
supervisionSubordinateDescriptions: options.supervisionSubordinateDescriptions
|
|
756
|
+
};
|
|
757
|
+
const body = options.updateMask !== void 0 ? fields : omitUndefined(fields);
|
|
758
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.update, {
|
|
759
|
+
pathParams: { id: scopeId },
|
|
760
|
+
query: updateMaskQuery(options.updateMask),
|
|
761
|
+
jsonBody: body
|
|
762
|
+
});
|
|
763
|
+
return parseScope(data);
|
|
764
|
+
}
|
|
765
|
+
async deploy(scopeId) {
|
|
766
|
+
validateId(scopeId, "scope_id");
|
|
767
|
+
const data = asRecord(
|
|
768
|
+
await invokeWithRetry(this.config, this.http, this.ops.deploy, {
|
|
769
|
+
pathParams: { id: scopeId },
|
|
770
|
+
jsonBody: {}
|
|
771
|
+
})
|
|
772
|
+
);
|
|
773
|
+
return parseScope(data.skill);
|
|
774
|
+
}
|
|
775
|
+
async delete(scopeId) {
|
|
776
|
+
validateId(scopeId, "scope_id");
|
|
777
|
+
await invokeWithRetry(this.config, this.http, this.ops.delete, {
|
|
778
|
+
pathParams: { id: scopeId }
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
async restore(scopeId) {
|
|
782
|
+
validateId(scopeId, "scope_id");
|
|
783
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
|
|
784
|
+
pathParams: { id: scopeId },
|
|
785
|
+
jsonBody: {}
|
|
786
|
+
});
|
|
787
|
+
return parseScope(data);
|
|
788
|
+
}
|
|
789
|
+
async requestOwnershipTransfer(scopeId, options) {
|
|
790
|
+
validateId(scopeId, "scope_id");
|
|
791
|
+
const data = await invokeWithRetry(
|
|
792
|
+
this.config,
|
|
793
|
+
this.http,
|
|
794
|
+
this.ops.requestOwnershipTransfer,
|
|
795
|
+
{
|
|
796
|
+
pathParams: { id: scopeId },
|
|
797
|
+
jsonBody: omitUndefined({ newOwnerUserId: options.newOwnerUserId })
|
|
798
|
+
}
|
|
799
|
+
);
|
|
800
|
+
return parseScope(data);
|
|
801
|
+
}
|
|
802
|
+
async cancelOwnershipTransfer(scopeId) {
|
|
803
|
+
validateId(scopeId, "scope_id");
|
|
804
|
+
const data = await invokeWithRetry(
|
|
805
|
+
this.config,
|
|
806
|
+
this.http,
|
|
807
|
+
this.ops.cancelOwnershipTransfer,
|
|
808
|
+
{ pathParams: { id: scopeId } }
|
|
809
|
+
);
|
|
810
|
+
return parseScope(data);
|
|
811
|
+
}
|
|
812
|
+
async acceptOwnershipTransfer(scopeId) {
|
|
813
|
+
validateId(scopeId, "scope_id");
|
|
814
|
+
const data = await invokeWithRetry(
|
|
815
|
+
this.config,
|
|
816
|
+
this.http,
|
|
817
|
+
this.ops.acceptOwnershipTransfer,
|
|
818
|
+
{ pathParams: { id: scopeId }, jsonBody: {} }
|
|
819
|
+
);
|
|
820
|
+
return parseScope(data);
|
|
821
|
+
}
|
|
822
|
+
async patchMcpConfig(scopeId, options) {
|
|
823
|
+
validateId(scopeId, "scope_id");
|
|
824
|
+
await invokeWithRetry(this.config, this.http, this.ops.patchMcpConfig, {
|
|
825
|
+
pathParams: { id: scopeId },
|
|
826
|
+
jsonBody: omitUndefined({ config: options.mcpConfig })
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
async getVariation(scopeId, options) {
|
|
830
|
+
validateId(scopeId, "scope_id");
|
|
831
|
+
validateId(options.variationUid, "variation_uid");
|
|
832
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.getVariation, {
|
|
833
|
+
pathParams: { id: scopeId, variationUid: options.variationUid }
|
|
834
|
+
});
|
|
835
|
+
return parseScope(data);
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
// src/management/usage.ts
|
|
840
|
+
var ManagementUsageResource = class {
|
|
841
|
+
constructor(http, config) {
|
|
842
|
+
this.http = http;
|
|
843
|
+
this.config = config;
|
|
844
|
+
}
|
|
845
|
+
async list(options) {
|
|
846
|
+
const query = {
|
|
847
|
+
since: options.since,
|
|
848
|
+
until: options.until,
|
|
849
|
+
rollup: options.rollup
|
|
850
|
+
};
|
|
851
|
+
if (options.model !== void 0) query.model = options.model;
|
|
852
|
+
const data = await invokeWithRetry(this.config, this.http, "UsageController_list", { query });
|
|
853
|
+
return data;
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
// src/management/users.ts
|
|
858
|
+
var ManagementUsersResource = class {
|
|
859
|
+
constructor(http, config) {
|
|
860
|
+
this.http = http;
|
|
861
|
+
this.config = config;
|
|
862
|
+
}
|
|
863
|
+
async listMemberGroups() {
|
|
864
|
+
const data = await invokeWithRetry(
|
|
865
|
+
this.config,
|
|
866
|
+
this.http,
|
|
867
|
+
"MemberGroupsController_list"
|
|
868
|
+
);
|
|
869
|
+
return data.groups;
|
|
870
|
+
}
|
|
871
|
+
async listOrgMembers() {
|
|
872
|
+
const data = await invokeWithRetry(
|
|
873
|
+
this.config,
|
|
874
|
+
this.http,
|
|
875
|
+
"OrgMembersController_list"
|
|
876
|
+
);
|
|
877
|
+
return data.members;
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
// src/management/index.ts
|
|
882
|
+
var ModusManagement = class extends ModusClientBase {
|
|
883
|
+
constructor(options = {}) {
|
|
884
|
+
super(options);
|
|
885
|
+
this.scopes = new ManagementScopesResource(this.http, this.config);
|
|
886
|
+
this.workflows = new ManagementWorkflowsResource(this.http, this.config);
|
|
887
|
+
this.context = new ManagementContextResource(this.http, this.config);
|
|
888
|
+
this.usage = new ManagementUsageResource(this.http, this.config);
|
|
889
|
+
this.organization = new ManagementOrganizationResource(this.http, this.config);
|
|
890
|
+
this.users = new ManagementUsersResource(this.http, this.config);
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
export {
|
|
894
|
+
ModusManagement
|
|
895
|
+
};
|
|
896
|
+
//# sourceMappingURL=index.js.map
|