@getmodus/sdk 0.9.0 → 0.11.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 +166 -0
- package/README.md +189 -14
- package/dist/{conversations-D7ffhHIh.d.cts → _client-base-DdnxB9JA.d.cts} +4425 -1674
- package/dist/{conversations-D7ffhHIh.d.ts → _client-base-DdnxB9JA.d.ts} +4425 -1674
- package/dist/chunk-3MHHVC6C.cjs +2678 -0
- package/dist/chunk-3MHHVC6C.cjs.map +1 -0
- package/dist/{chunk-SP4UYRYG.js → chunk-JVTQBBMZ.js} +613 -304
- package/dist/chunk-JVTQBBMZ.js.map +1 -0
- package/dist/index.cjs +585 -2800
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +802 -614
- package/dist/index.d.ts +802 -614
- package/dist/index.js +434 -300
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +555 -2659
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +211 -42
- package/dist/management/index.d.ts +211 -42
- package/dist/management/index.js +291 -98
- package/dist/management/index.js.map +1 -1
- package/package.json +8 -1
- package/dist/chunk-SP4UYRYG.js.map +0 -1
package/dist/management/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ModusClientBase,
|
|
4
4
|
ModusError,
|
|
5
5
|
ScopeConversationsResource,
|
|
6
|
+
ValidationError,
|
|
6
7
|
aipListParams,
|
|
7
8
|
asRecord,
|
|
8
9
|
buildAipPage,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
omitUndefined,
|
|
11
12
|
validateId,
|
|
12
13
|
validatePageSize
|
|
13
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-JVTQBBMZ.js";
|
|
14
15
|
|
|
15
16
|
// src/_generated/resources/management/workflows.ts
|
|
16
17
|
var WorkflowsResourceBase = class {
|
|
@@ -32,8 +33,9 @@ var WorkflowsResourceBase = class {
|
|
|
32
33
|
* for the first page.
|
|
33
34
|
* @param options.search - Case-insensitive substring filter on workflow name.
|
|
34
35
|
* @param options.type - Filter by workflow type.
|
|
35
|
-
* @param options.view - Variation view. `active` reads deployed
|
|
36
|
-
* snapshot.
|
|
36
|
+
* @param options.view - Variation view. `active` reads the deployed version. `draft` reads the
|
|
37
|
+
* latest builder snapshot. `published` reads only a published workflow of type workflow that
|
|
38
|
+
* you can use; tasks are excluded.
|
|
37
39
|
* @param options.includeVariation - Include the requested variation payload (`trigger`,
|
|
38
40
|
* `workflowStructure`, `agentSelection`) on list rows.
|
|
39
41
|
* @returns A page of workflows.
|
|
@@ -73,7 +75,7 @@ var WorkflowsResourceBase = class {
|
|
|
73
75
|
* Delete a workflow.
|
|
74
76
|
*
|
|
75
77
|
* Deletes a workflow and stops its schedule. The workflow can be restored later with POST
|
|
76
|
-
* /workflows/{id}/restore.
|
|
78
|
+
* /workflows/{id}/restore. Returns 404 if the workflow does not exist or is already deleted.
|
|
77
79
|
*
|
|
78
80
|
* **Requires:** `workflows:write`
|
|
79
81
|
*
|
|
@@ -150,42 +152,19 @@ var WorkflowsResourceBase = class {
|
|
|
150
152
|
function updateMaskQuery(updateMask) {
|
|
151
153
|
if (updateMask === void 0) return void 0;
|
|
152
154
|
if (!updateMask.trim()) {
|
|
153
|
-
throw new
|
|
155
|
+
throw new ValidationError("update_mask must be a non-empty comma-separated list of field names");
|
|
154
156
|
}
|
|
155
157
|
return { updateMask };
|
|
156
158
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
function accessConfigWireForUpdate(existing, guardrails) {
|
|
169
|
-
if (!existing || Object.keys(existing).length === 0) {
|
|
170
|
-
return accessConfigWireForCreate(guardrails);
|
|
171
|
-
}
|
|
172
|
-
return { ...existing, guardrails };
|
|
173
|
-
}
|
|
174
|
-
function accessFromSkillResponse(raw) {
|
|
175
|
-
const value = raw.accessConfig ?? raw.access_config;
|
|
176
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
177
|
-
return value;
|
|
178
|
-
}
|
|
179
|
-
return {};
|
|
180
|
-
}
|
|
181
|
-
function accessConfigBodyForCreate(guardrails) {
|
|
182
|
-
if (guardrails === void 0) return void 0;
|
|
183
|
-
return accessConfigWireForCreate(guardrails);
|
|
184
|
-
}
|
|
185
|
-
async function accessConfigBodyForUpdate(guardrails, loadResource) {
|
|
186
|
-
if (guardrails === void 0) return void 0;
|
|
187
|
-
const existing = accessFromSkillResponse(await loadResource());
|
|
188
|
-
return accessConfigWireForUpdate(existing, guardrails);
|
|
159
|
+
function updateBody(fields, updateMask) {
|
|
160
|
+
const body = Object.fromEntries(
|
|
161
|
+
Object.entries(fields).filter(([, value]) => value !== void 0)
|
|
162
|
+
);
|
|
163
|
+
for (const field of updateMask?.split(",") ?? []) {
|
|
164
|
+
const name = field.trim();
|
|
165
|
+
if (name && !name.includes(".") && !(name in body)) body[name] = null;
|
|
166
|
+
}
|
|
167
|
+
return body;
|
|
189
168
|
}
|
|
190
169
|
|
|
191
170
|
// src/_generated/resources/management/workflows/interfaces.ts
|
|
@@ -200,7 +179,7 @@ var WorkflowsInterfacesResourceBase = class {
|
|
|
200
179
|
* List interfaces attached to a workflow.
|
|
201
180
|
*
|
|
202
181
|
* Returns every Slack, MCP, or Teams interface bound to the workflow. Requires manage permission
|
|
203
|
-
* on the workflow.
|
|
182
|
+
* on the workflow: returns 403 if you can only use it, and 404 if you cannot access it.
|
|
204
183
|
*
|
|
205
184
|
* **Requires:** `workflows:read`
|
|
206
185
|
*/
|
|
@@ -272,7 +251,7 @@ var WorkflowInterfacesResource = class extends WorkflowsInterfacesResourceBase {
|
|
|
272
251
|
return await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_update", {
|
|
273
252
|
pathParams: { id: this.workflowId, interfaceId },
|
|
274
253
|
query: updateMaskQuery(updateMask),
|
|
275
|
-
jsonBody:
|
|
254
|
+
jsonBody: updateBody(options, updateMask)
|
|
276
255
|
});
|
|
277
256
|
}
|
|
278
257
|
};
|
|
@@ -302,13 +281,14 @@ var ManagementWorkflowsResource = class extends WorkflowsResourceBase {
|
|
|
302
281
|
/**
|
|
303
282
|
* Retrieve a workflow with full configuration.
|
|
304
283
|
*
|
|
305
|
-
* @param workflowId -
|
|
306
|
-
* @param options.view - Variation view: `"active"` (deployed) or `"
|
|
284
|
+
* @param workflowId - Numeric workflow id.
|
|
285
|
+
* @param options.view - Variation view: `"active"` (deployed), `"draft"`, or `"published"` (published workflow you can use).
|
|
307
286
|
* @returns The workflow.
|
|
308
287
|
* @example
|
|
309
288
|
* ```ts
|
|
310
289
|
* const mgmt = new ModusManagement()
|
|
311
|
-
* const
|
|
290
|
+
* const [first] = (await mgmt.workflows.list()).items
|
|
291
|
+
* const wf = await mgmt.workflows.get(first.id)
|
|
312
292
|
* console.log(wf.name, wf.status)
|
|
313
293
|
* ```
|
|
314
294
|
*/
|
|
@@ -334,14 +314,13 @@ var ManagementWorkflowsResource = class extends WorkflowsResourceBase {
|
|
|
334
314
|
* Create a new workflow in the organization.
|
|
335
315
|
*
|
|
336
316
|
* @param options.name - Display name for the workflow.
|
|
337
|
-
* @param options.type - `"task"`
|
|
317
|
+
* @param options.type - `"workflow"`. `"task"` is a deprecated alias the server stores as `"workflow"`.
|
|
338
318
|
* @param options.trigger - Optional trigger configuration.
|
|
339
|
-
* @param options.guardrails - Runtime guardrail labels (for example `"no-pii"`). Omit to create with no guardrails.
|
|
340
319
|
* @returns The created workflow (draft).
|
|
341
320
|
* @example
|
|
342
321
|
* ```ts
|
|
343
322
|
* const mgmt = new ModusManagement()
|
|
344
|
-
* const wf = await mgmt.workflows.create({ name: 'Daily report', type: '
|
|
323
|
+
* const wf = await mgmt.workflows.create({ name: 'Daily report', type: 'workflow' })
|
|
345
324
|
* ```
|
|
346
325
|
*/
|
|
347
326
|
async create(options) {
|
|
@@ -351,8 +330,7 @@ var ManagementWorkflowsResource = class extends WorkflowsResourceBase {
|
|
|
351
330
|
description: options.description,
|
|
352
331
|
trigger: options.trigger,
|
|
353
332
|
agentSelection: options.agentSelection,
|
|
354
|
-
workflowStructure: options.workflowStructure
|
|
355
|
-
accessConfig: accessConfigBodyForCreate(options.guardrails)
|
|
333
|
+
workflowStructure: options.workflowStructure
|
|
356
334
|
});
|
|
357
335
|
const data = await invokeWithRetry(this.config, this.http, this.ops.create, {
|
|
358
336
|
jsonBody: body
|
|
@@ -363,10 +341,10 @@ var ManagementWorkflowsResource = class extends WorkflowsResourceBase {
|
|
|
363
341
|
* Update a workflow's configuration.
|
|
364
342
|
*
|
|
365
343
|
* Only the fields you pass are changed. To clear a field, name it in
|
|
366
|
-
* `updateMask` and leave its argument unset
|
|
344
|
+
* `updateMask` and leave its argument unset: it is sent as `null`.
|
|
367
345
|
*
|
|
368
|
-
* @param workflowId -
|
|
369
|
-
* @param options.
|
|
346
|
+
* @param workflowId - Numeric workflow id.
|
|
347
|
+
* @param options.type - Only `"workflow"` is accepted; `"task"` is rejected with a 422.
|
|
370
348
|
* @param options.updateMask - Comma-separated field names to update or clear.
|
|
371
349
|
* @returns The updated workflow.
|
|
372
350
|
* @example
|
|
@@ -377,24 +355,15 @@ var ManagementWorkflowsResource = class extends WorkflowsResourceBase {
|
|
|
377
355
|
*/
|
|
378
356
|
async update(workflowId, options = {}) {
|
|
379
357
|
validateId(workflowId, "workflow_id");
|
|
380
|
-
const accessConfig = await accessConfigBodyForUpdate(
|
|
381
|
-
options.guardrails,
|
|
382
|
-
async () => asRecord(
|
|
383
|
-
await invokeWithRetry(this.config, this.http, this.ops.get, {
|
|
384
|
-
pathParams: { id: workflowId }
|
|
385
|
-
})
|
|
386
|
-
)
|
|
387
|
-
);
|
|
388
358
|
const fields = {
|
|
389
359
|
name: options.name,
|
|
390
360
|
type: options.type,
|
|
391
361
|
description: options.description,
|
|
392
362
|
trigger: options.trigger,
|
|
393
363
|
agentSelection: options.agentSelection,
|
|
394
|
-
workflowStructure: options.workflowStructure
|
|
395
|
-
accessConfig
|
|
364
|
+
workflowStructure: options.workflowStructure
|
|
396
365
|
};
|
|
397
|
-
const body = options.updateMask
|
|
366
|
+
const body = updateBody(fields, options.updateMask);
|
|
398
367
|
const data = await invokeWithRetry(this.config, this.http, this.ops.update, {
|
|
399
368
|
pathParams: { id: workflowId },
|
|
400
369
|
query: updateMaskQuery(options.updateMask),
|
|
@@ -469,10 +438,10 @@ function withCreatedUid(data) {
|
|
|
469
438
|
// src/management/context/_content-merge.ts
|
|
470
439
|
function requireContentDict(item, contextType) {
|
|
471
440
|
if (item.contextType !== contextType) {
|
|
472
|
-
throw new
|
|
441
|
+
throw new ValidationError(`Expected contextType ${contextType}, got ${item.contextType}.`);
|
|
473
442
|
}
|
|
474
443
|
if (!item.content || typeof item.content !== "object" || Array.isArray(item.content)) {
|
|
475
|
-
throw new
|
|
444
|
+
throw new ValidationError(`Context item ${item.uid} has no object content; cannot merge ${contextType} fields.`);
|
|
476
445
|
}
|
|
477
446
|
return item.content;
|
|
478
447
|
}
|
|
@@ -529,7 +498,7 @@ async function resolveAndUpdateSavedQuery(items, uid, options) {
|
|
|
529
498
|
}
|
|
530
499
|
async function resolveAndUpdateLink(items, uid, options) {
|
|
531
500
|
if (options.title === void 0 && options.url === void 0 && options.description === void 0 && options.userFeedback === void 0 && options.topics === void 0) {
|
|
532
|
-
throw new
|
|
501
|
+
throw new ValidationError("Provide at least one field to update.");
|
|
533
502
|
}
|
|
534
503
|
if (options.title === void 0 && options.url === void 0) {
|
|
535
504
|
return items.update(uid, {
|
|
@@ -1158,15 +1127,24 @@ var DEFAULT_CONCURRENCY = 10;
|
|
|
1158
1127
|
var STATUS_ORDER = { pending: 0, processing: 1, ready: 2 };
|
|
1159
1128
|
var WAIT_UNTIL_VALUES = /* @__PURE__ */ new Set(["processing", "ready"]);
|
|
1160
1129
|
var DEFER_CONTENT_TYPE_TO_SERVER = "application/octet-stream";
|
|
1130
|
+
async function statInput(path) {
|
|
1131
|
+
try {
|
|
1132
|
+
return await stat(path);
|
|
1133
|
+
} catch (error) {
|
|
1134
|
+
const code = error.code;
|
|
1135
|
+
if (code === "ENOENT" || code === "ENOTDIR") throw new ValidationError(`No such file or directory: ${path}`);
|
|
1136
|
+
throw error;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1161
1139
|
function validateWaitUntil(waitUntil) {
|
|
1162
1140
|
if (!WAIT_UNTIL_VALUES.has(waitUntil)) {
|
|
1163
|
-
throw new
|
|
1141
|
+
throw new ValidationError(`waitUntil must be one of ${[...WAIT_UNTIL_VALUES].join(", ")}, got ${waitUntil}`);
|
|
1164
1142
|
}
|
|
1165
1143
|
}
|
|
1166
1144
|
function validateBulkSize(count, name) {
|
|
1167
|
-
if (count === 0) throw new
|
|
1145
|
+
if (count === 0) throw new ValidationError(`${name} must not be empty`);
|
|
1168
1146
|
if (count > MAX_BULK_UPLOAD_FILES) {
|
|
1169
|
-
throw new
|
|
1147
|
+
throw new ValidationError(`${name} must have at most ${MAX_BULK_UPLOAD_FILES} entries, got ${count}`);
|
|
1170
1148
|
}
|
|
1171
1149
|
}
|
|
1172
1150
|
function statusSatisfies(status, waitUntil) {
|
|
@@ -1435,8 +1413,8 @@ var ManagementContextFilesResource = class extends ContextFilesResourceBase {
|
|
|
1435
1413
|
async upload(path, options = {}) {
|
|
1436
1414
|
const waitUntil = options.waitUntil ?? "processing";
|
|
1437
1415
|
validateWaitUntil(waitUntil);
|
|
1438
|
-
const fileStat = await
|
|
1439
|
-
if (!fileStat.isFile()) throw new
|
|
1416
|
+
const fileStat = await statInput(path);
|
|
1417
|
+
if (!fileStat.isFile()) throw new ValidationError(`Not a file: ${path}`);
|
|
1440
1418
|
const fileName = path.split(/[/\\]/).pop();
|
|
1441
1419
|
const slot = await this.createUploadUrl({
|
|
1442
1420
|
fileName,
|
|
@@ -1498,9 +1476,9 @@ var ManagementContextFilesResource = class extends ContextFilesResourceBase {
|
|
|
1498
1476
|
const waitUntil = options.waitUntil ?? "processing";
|
|
1499
1477
|
validateWaitUntil(waitUntil);
|
|
1500
1478
|
const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
|
|
1501
|
-
if (concurrency < 1) throw new
|
|
1502
|
-
const dirStat = await
|
|
1503
|
-
if (!dirStat.isDirectory()) throw new
|
|
1479
|
+
if (concurrency < 1) throw new ValidationError(`concurrency must be >= 1, got ${concurrency}`);
|
|
1480
|
+
const dirStat = await statInput(path);
|
|
1481
|
+
if (!dirStat.isDirectory()) throw new ValidationError(`Not a directory: ${path}`);
|
|
1504
1482
|
const files = await walkFiles(path, options.recursive ?? true);
|
|
1505
1483
|
return this.uploadPaths(files.map((file) => {
|
|
1506
1484
|
const folderPath = relative(path, dirname(file)).replace(/\\/g, "/");
|
|
@@ -1513,7 +1491,7 @@ var ManagementContextFilesResource = class extends ContextFilesResourceBase {
|
|
|
1513
1491
|
const waitUntil = options.waitUntil ?? "processing";
|
|
1514
1492
|
validateWaitUntil(waitUntil);
|
|
1515
1493
|
const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
|
|
1516
|
-
if (concurrency < 1) throw new
|
|
1494
|
+
if (concurrency < 1) throw new ValidationError(`concurrency must be >= 1, got ${concurrency}`);
|
|
1517
1495
|
const prefixed = files.map((file) => {
|
|
1518
1496
|
const folderPath = joinDestination(options.folderPath, file.folderPath);
|
|
1519
1497
|
return { path: file.path, ...folderPath !== void 0 ? { folderPath } : {} };
|
|
@@ -1726,7 +1704,7 @@ var ManagementContextItemsResource = class {
|
|
|
1726
1704
|
* Update a context item.
|
|
1727
1705
|
*
|
|
1728
1706
|
* Only the fields you pass are changed. To clear a field, name it in
|
|
1729
|
-
* `updateMask` and leave its argument unset
|
|
1707
|
+
* `updateMask` and leave its argument unset: it is sent as `null`.
|
|
1730
1708
|
*
|
|
1731
1709
|
* @param uid - Context item uid.
|
|
1732
1710
|
* @param options.content - Replacement type-specific content.
|
|
@@ -1738,19 +1716,13 @@ var ManagementContextItemsResource = class {
|
|
|
1738
1716
|
* @returns The updated context item.
|
|
1739
1717
|
*/
|
|
1740
1718
|
async update(uid, options = {}) {
|
|
1741
|
-
const body =
|
|
1719
|
+
const body = updateBody({
|
|
1742
1720
|
content: options.content,
|
|
1743
1721
|
contextType: options.contextType,
|
|
1744
1722
|
description: options.description,
|
|
1745
1723
|
userFeedback: options.userFeedback,
|
|
1746
1724
|
topics: options.topics
|
|
1747
|
-
}
|
|
1748
|
-
content: options.content,
|
|
1749
|
-
contextType: options.contextType,
|
|
1750
|
-
description: options.description,
|
|
1751
|
-
userFeedback: options.userFeedback,
|
|
1752
|
-
topics: options.topics
|
|
1753
|
-
});
|
|
1725
|
+
}, options.updateMask);
|
|
1754
1726
|
await invokeWithRetry(this.config, this.http, "ContextItemsController_update", {
|
|
1755
1727
|
pathParams: { uid },
|
|
1756
1728
|
query: updateMaskQuery(options.updateMask),
|
|
@@ -1808,6 +1780,50 @@ var ManagementContextItemsResource = class {
|
|
|
1808
1780
|
);
|
|
1809
1781
|
return data;
|
|
1810
1782
|
}
|
|
1783
|
+
/**
|
|
1784
|
+
* Replace who can view and manage a note, saved query, link or uploaded file.
|
|
1785
|
+
*
|
|
1786
|
+
* All three settings are required and replace the current ones. You cannot
|
|
1787
|
+
* remove your own manage access. An item created before items had owners
|
|
1788
|
+
* becomes yours on the first change.
|
|
1789
|
+
*
|
|
1790
|
+
* @param uid - UUID of the context item.
|
|
1791
|
+
* @param input.visibility - `shared` (the owner plus the groups in
|
|
1792
|
+
* `groupPermissions`) or `private` (the owner plus the users in `sharedWith`).
|
|
1793
|
+
* @param input.groupPermissions - Group id to `{ use, manage }`. Used only when shared.
|
|
1794
|
+
* @param input.sharedWith - Users such as `{ email: 'ana@example.com', permission: 'use' }`.
|
|
1795
|
+
* Used only when private.
|
|
1796
|
+
* @returns The item's new access settings and whether you can still manage it.
|
|
1797
|
+
* @throws {NotFoundError} The item does not exist or you cannot view it.
|
|
1798
|
+
* @throws {PermissionDeniedError} You can view the item but not manage it.
|
|
1799
|
+
* @throws {ModusError} The item is another type, a group or user is invalid,
|
|
1800
|
+
* or the change would remove your own manage access.
|
|
1801
|
+
*
|
|
1802
|
+
* @example
|
|
1803
|
+
* ```ts
|
|
1804
|
+
* await mgmt.context.items.updateAccess('PLACEHOLDER_UID', {
|
|
1805
|
+
* visibility: 'private',
|
|
1806
|
+
* groupPermissions: {},
|
|
1807
|
+
* sharedWith: [{ email: 'ana@example.com', permission: 'use' }],
|
|
1808
|
+
* })
|
|
1809
|
+
* ```
|
|
1810
|
+
*/
|
|
1811
|
+
async updateAccess(uid, input) {
|
|
1812
|
+
const data = await invokeWithRetry(
|
|
1813
|
+
this.config,
|
|
1814
|
+
this.http,
|
|
1815
|
+
"ContextItemAccessController_updateAccess",
|
|
1816
|
+
{
|
|
1817
|
+
pathParams: { uid },
|
|
1818
|
+
jsonBody: {
|
|
1819
|
+
visibility: input.visibility,
|
|
1820
|
+
groupPermissions: input.groupPermissions,
|
|
1821
|
+
sharedWith: input.sharedWith
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
);
|
|
1825
|
+
return data;
|
|
1826
|
+
}
|
|
1811
1827
|
};
|
|
1812
1828
|
|
|
1813
1829
|
// src/management/context/context.ts
|
|
@@ -1984,8 +2000,9 @@ var ScopesResourceBase = class {
|
|
|
1984
2000
|
* @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
|
|
1985
2001
|
* for the first page.
|
|
1986
2002
|
* @param options.search - Case-insensitive substring filter on scope name.
|
|
1987
|
-
* @param options.view - Variation view. `active` reads deployed
|
|
1988
|
-
* snapshot.
|
|
2003
|
+
* @param options.view - Variation view. `active` reads the deployed version, or the latest draft
|
|
2004
|
+
* when nothing is published. `draft` reads the latest builder snapshot. `published` reads only
|
|
2005
|
+
* the published version, and only scopes you can use.
|
|
1989
2006
|
* @param options.managerId - Return only scopes supervised by this manager scope id.
|
|
1990
2007
|
* @returns A page of scopes.
|
|
1991
2008
|
*
|
|
@@ -2022,13 +2039,15 @@ var ScopesResourceBase = class {
|
|
|
2022
2039
|
/**
|
|
2023
2040
|
* Get a scope.
|
|
2024
2041
|
*
|
|
2025
|
-
* Returns a scope. `view=active` (default)
|
|
2026
|
-
*
|
|
2042
|
+
* Returns a scope. `view=active` (default) is the deployed version, or the latest draft when
|
|
2043
|
+
* nothing is published. `view=draft` is the latest edits. `view=published` is only the published
|
|
2044
|
+
* version, and only if you can use the scope. Returns 404 if you cannot access it.
|
|
2027
2045
|
*
|
|
2028
2046
|
* **Requires:** `scopes:read`
|
|
2029
2047
|
*
|
|
2030
2048
|
* @param scopeId - Numeric scope id.
|
|
2031
|
-
* @param options.view - Which
|
|
2049
|
+
* @param options.view - Which version to read. Defaults to `active`. `published` is only the
|
|
2050
|
+
* published version, and only if you can use the scope.
|
|
2032
2051
|
*
|
|
2033
2052
|
* @example
|
|
2034
2053
|
* ```ts
|
|
@@ -2048,8 +2067,8 @@ var ScopesResourceBase = class {
|
|
|
2048
2067
|
/**
|
|
2049
2068
|
* Delete a scope.
|
|
2050
2069
|
*
|
|
2051
|
-
* Deletes a scope. The scope can be restored later with POST /scopes/{id}/restore.
|
|
2052
|
-
*
|
|
2070
|
+
* Deletes a scope. The scope can be restored later with POST /scopes/{id}/restore. Returns 404 if
|
|
2071
|
+
* the scope does not exist or is already deleted.
|
|
2053
2072
|
*
|
|
2054
2073
|
* **Requires:** `scopes:write`
|
|
2055
2074
|
*
|
|
@@ -2067,6 +2086,32 @@ var ScopesResourceBase = class {
|
|
|
2067
2086
|
pathParams: { id: scopeId }
|
|
2068
2087
|
});
|
|
2069
2088
|
}
|
|
2089
|
+
/**
|
|
2090
|
+
* Preview MCP exposure catalog.
|
|
2091
|
+
*
|
|
2092
|
+
* Lists tools this scope can expose to MCP clients. A field you send replaces the current draft;
|
|
2093
|
+
* a field you omit stays as stored. Nothing is saved. Entries you cannot access are left out, and
|
|
2094
|
+
* stored selections on them are counted in hiddenSelectedCount.
|
|
2095
|
+
*
|
|
2096
|
+
* **Requires:** `scopes:write`
|
|
2097
|
+
*
|
|
2098
|
+
* @param scopeId - Numeric scope id.
|
|
2099
|
+
* @param request - Request body; see `McpExposureCatalogRequest`.
|
|
2100
|
+
*
|
|
2101
|
+
* @example
|
|
2102
|
+
* ```ts
|
|
2103
|
+
* const catalog = await mgmt.scopes.mcpExposureCatalog(42, {})
|
|
2104
|
+
* catalog.discoveryAllowed
|
|
2105
|
+
* ```
|
|
2106
|
+
*/
|
|
2107
|
+
async mcpExposureCatalog(scopeId, request) {
|
|
2108
|
+
validateId(scopeId, "scope_id");
|
|
2109
|
+
const data = await invokeWithRetry(this.config, this.http, "ScopesController_mcpExposureCatalog", {
|
|
2110
|
+
pathParams: { id: scopeId },
|
|
2111
|
+
jsonBody: omitUndefined(request)
|
|
2112
|
+
});
|
|
2113
|
+
return data;
|
|
2114
|
+
}
|
|
2070
2115
|
/**
|
|
2071
2116
|
* Restore a deleted scope.
|
|
2072
2117
|
*
|
|
@@ -2088,8 +2133,8 @@ var ScopesResourceBase = class {
|
|
|
2088
2133
|
/**
|
|
2089
2134
|
* Cancel ownership transfer.
|
|
2090
2135
|
*
|
|
2091
|
-
* Cancels a pending ownership transfer. The current owner may cancel
|
|
2092
|
-
* decline.
|
|
2136
|
+
* Cancels a pending ownership transfer. The current owner may cancel, the pending recipient may
|
|
2137
|
+
* decline, and for a scope with no owner an organization owner may cancel.
|
|
2093
2138
|
*
|
|
2094
2139
|
* **Requires:** `scopes:write`
|
|
2095
2140
|
*
|
|
@@ -2121,6 +2166,39 @@ var ScopesResourceBase = class {
|
|
|
2121
2166
|
}
|
|
2122
2167
|
};
|
|
2123
2168
|
|
|
2169
|
+
// src/management/_access-config.ts
|
|
2170
|
+
var EVERYONE_GROUP_ID = "__everyone__";
|
|
2171
|
+
function accessConfigWireForCreate(guardrails) {
|
|
2172
|
+
return {
|
|
2173
|
+
visibility: "shared",
|
|
2174
|
+
groupPermissions: { [EVERYONE_GROUP_ID]: { use: true, manage: true } },
|
|
2175
|
+
guardrails,
|
|
2176
|
+
sharedWith: []
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
function accessConfigWireForUpdate(existing, guardrails) {
|
|
2180
|
+
if (!existing || Object.keys(existing).length === 0) {
|
|
2181
|
+
return accessConfigWireForCreate(guardrails);
|
|
2182
|
+
}
|
|
2183
|
+
return { ...existing, guardrails };
|
|
2184
|
+
}
|
|
2185
|
+
function accessFromSkillResponse(raw) {
|
|
2186
|
+
const value = raw.accessConfig ?? raw.access_config;
|
|
2187
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2188
|
+
return value;
|
|
2189
|
+
}
|
|
2190
|
+
return {};
|
|
2191
|
+
}
|
|
2192
|
+
function accessConfigBodyForCreate(guardrails) {
|
|
2193
|
+
if (guardrails === void 0) return void 0;
|
|
2194
|
+
return accessConfigWireForCreate(guardrails);
|
|
2195
|
+
}
|
|
2196
|
+
async function accessConfigBodyForUpdate(guardrails, loadResource) {
|
|
2197
|
+
if (guardrails === void 0) return void 0;
|
|
2198
|
+
const existing = accessFromSkillResponse(await loadResource());
|
|
2199
|
+
return accessConfigWireForUpdate(existing, guardrails);
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2124
2202
|
// src/_generated/resources/management/scopes/memories.ts
|
|
2125
2203
|
var ScopesMemoriesResourceBase = class {
|
|
2126
2204
|
/** @internal */
|
|
@@ -2200,17 +2278,16 @@ var ScopesMemoriesResourceBase = class {
|
|
|
2200
2278
|
async update(memoryId, update, options = {}) {
|
|
2201
2279
|
validateId(memoryId, "memory_id");
|
|
2202
2280
|
validateId(this.scopeId, "scope_id");
|
|
2203
|
-
|
|
2281
|
+
await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_update", {
|
|
2204
2282
|
pathParams: { id: this.scopeId, memoryId },
|
|
2205
2283
|
query: updateMaskQuery(options.updateMask),
|
|
2206
2284
|
jsonBody: omitUndefined(update)
|
|
2207
2285
|
});
|
|
2208
|
-
return data;
|
|
2209
2286
|
}
|
|
2210
2287
|
/**
|
|
2211
2288
|
* Delete a memory.
|
|
2212
2289
|
*
|
|
2213
|
-
* Deletes one memory.
|
|
2290
|
+
* Deletes one memory. Returns 404 if the memory does not exist or is already deleted.
|
|
2214
2291
|
*
|
|
2215
2292
|
* **Requires:** `scopes:write`
|
|
2216
2293
|
*
|
|
@@ -2229,6 +2306,9 @@ var ScopesMemoriesResourceBase = class {
|
|
|
2229
2306
|
var ScopeMemoriesResource = class extends ScopesMemoriesResourceBase {
|
|
2230
2307
|
};
|
|
2231
2308
|
|
|
2309
|
+
// src/management/scopes/evaluations.ts
|
|
2310
|
+
import { randomUUID } from "crypto";
|
|
2311
|
+
|
|
2232
2312
|
// src/_generated/resources/management/scopes/evaluations.ts
|
|
2233
2313
|
var ScopesEvaluationsResourceBase = class {
|
|
2234
2314
|
/** @internal */
|
|
@@ -2295,6 +2375,8 @@ var ScopesEvaluationsResourceBase = class {
|
|
|
2295
2375
|
* **Requires:** `scopes:read`
|
|
2296
2376
|
*
|
|
2297
2377
|
* @param options.pageSize - Items per page. Defaults to 25.
|
|
2378
|
+
* @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
|
|
2379
|
+
* for the first page.
|
|
2298
2380
|
* @returns A page of runs.
|
|
2299
2381
|
*/
|
|
2300
2382
|
listRuns(options = {}) {
|
|
@@ -2338,6 +2420,74 @@ var ScopesEvaluationsResourceBase = class {
|
|
|
2338
2420
|
|
|
2339
2421
|
// src/management/scopes/evaluations.ts
|
|
2340
2422
|
var ScopeEvaluationsResource = class extends ScopesEvaluationsResourceBase {
|
|
2423
|
+
/**
|
|
2424
|
+
* Add one evaluation case and return the stored case.
|
|
2425
|
+
*
|
|
2426
|
+
* @param input.task - What the scope should do. An empty string is allowed.
|
|
2427
|
+
* @param input.expectedOutput - What a correct result looks like. An empty string is allowed.
|
|
2428
|
+
* @param input.id - Stable id. Omit it and the client assigns one before the request, so a retry sends the same id.
|
|
2429
|
+
* @returns The stored evaluation case, including its id.
|
|
2430
|
+
* @throws ConflictError An evaluation case with this id already exists. A retry after the case was stored returns this error. An identical body is not treated as success.
|
|
2431
|
+
* @example
|
|
2432
|
+
* ```ts
|
|
2433
|
+
* const mgmt = new ModusManagement()
|
|
2434
|
+
* const added = await mgmt.scopes.evaluations(42).addCase({
|
|
2435
|
+
* task: "Summarize last quarter's revenue",
|
|
2436
|
+
* expectedOutput: 'A one-paragraph summary with the total',
|
|
2437
|
+
* })
|
|
2438
|
+
* console.log(added.id)
|
|
2439
|
+
* ```
|
|
2440
|
+
*/
|
|
2441
|
+
async addCase(input) {
|
|
2442
|
+
validateId(this.scopeId, "scope_id");
|
|
2443
|
+
const id = input.id ?? randomUUID();
|
|
2444
|
+
validateId(id, "id");
|
|
2445
|
+
return await invokeWithRetry(this.config, this.http, "ScopesController_addEvaluationCase", {
|
|
2446
|
+
pathParams: { id: this.scopeId },
|
|
2447
|
+
jsonBody: omitUndefined({ ...input, id })
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Change the task, the expected output, or both, for one evaluation case.
|
|
2452
|
+
*
|
|
2453
|
+
* @param caseId - Id of the case to change.
|
|
2454
|
+
* @param patch.task - Replacement task. Omit to leave it unchanged.
|
|
2455
|
+
* @param patch.expectedOutput - Replacement expected output. Omit to leave it unchanged.
|
|
2456
|
+
* @returns The evaluation case after the change.
|
|
2457
|
+
* @example
|
|
2458
|
+
* ```ts
|
|
2459
|
+
* const mgmt = new ModusManagement()
|
|
2460
|
+
* const updated = await mgmt.scopes.evaluations(42).updateCase('CASE_ID', {
|
|
2461
|
+
* task: 'Summarize revenue in two sentences',
|
|
2462
|
+
* })
|
|
2463
|
+
* console.log(updated.task)
|
|
2464
|
+
* ```
|
|
2465
|
+
*/
|
|
2466
|
+
async updateCase(caseId, patch) {
|
|
2467
|
+
validateId(this.scopeId, "scope_id");
|
|
2468
|
+
validateId(caseId, "case_id");
|
|
2469
|
+
return await invokeWithRetry(this.config, this.http, "ScopesController_updateEvaluationCase", {
|
|
2470
|
+
pathParams: { id: this.scopeId, caseId },
|
|
2471
|
+
jsonBody: omitUndefined(patch)
|
|
2472
|
+
});
|
|
2473
|
+
}
|
|
2474
|
+
/**
|
|
2475
|
+
* Remove one evaluation case. The other cases stay as they are.
|
|
2476
|
+
*
|
|
2477
|
+
* @param caseId - Id of the case to remove.
|
|
2478
|
+
* @example
|
|
2479
|
+
* ```ts
|
|
2480
|
+
* const mgmt = new ModusManagement()
|
|
2481
|
+
* await mgmt.scopes.evaluations(42).deleteCase('CASE_ID')
|
|
2482
|
+
* ```
|
|
2483
|
+
*/
|
|
2484
|
+
async deleteCase(caseId) {
|
|
2485
|
+
validateId(this.scopeId, "scope_id");
|
|
2486
|
+
validateId(caseId, "case_id");
|
|
2487
|
+
await invokeWithRetry(this.config, this.http, "ScopesController_deleteEvaluationCase", {
|
|
2488
|
+
pathParams: { id: this.scopeId, caseId }
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2341
2491
|
};
|
|
2342
2492
|
|
|
2343
2493
|
// src/_generated/resources/management/scopes/interfaces.ts
|
|
@@ -2411,7 +2561,7 @@ var ScopeInterfacesResource = class extends ScopesInterfacesResourceBase {
|
|
|
2411
2561
|
return await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_update", {
|
|
2412
2562
|
pathParams: { id: this.scopeId, interfaceId },
|
|
2413
2563
|
query: updateMaskQuery(updateMask),
|
|
2414
|
-
jsonBody:
|
|
2564
|
+
jsonBody: updateBody(options, updateMask)
|
|
2415
2565
|
});
|
|
2416
2566
|
}
|
|
2417
2567
|
};
|
|
@@ -2494,6 +2644,7 @@ var MANAGEMENT_SCOPE_OPERATIONS = {
|
|
|
2494
2644
|
create: "ScopesController_create",
|
|
2495
2645
|
update: "ScopesController_update",
|
|
2496
2646
|
deploy: "ScopesController_deploy",
|
|
2647
|
+
applySelectionOps: "ScopesController_applySelectionOps",
|
|
2497
2648
|
delete: "ScopesController_delete",
|
|
2498
2649
|
restore: "ScopesController_restore",
|
|
2499
2650
|
requestOwnershipTransfer: "ScopesController_requestOwnershipTransfer",
|
|
@@ -2596,10 +2747,13 @@ var ManagementScopesResource = class extends ScopesResourceBase {
|
|
|
2596
2747
|
* Update a scope's configuration.
|
|
2597
2748
|
*
|
|
2598
2749
|
* Only the fields you pass are changed. To clear a field, name it in
|
|
2599
|
-
* `updateMask` (comma-separated field names) and leave its argument unset
|
|
2750
|
+
* `updateMask` (comma-separated field names) and leave its argument unset:
|
|
2751
|
+
* it is sent as `null`.
|
|
2600
2752
|
*
|
|
2601
|
-
* @param scopeId -
|
|
2753
|
+
* @param scopeId - Numeric scope id.
|
|
2602
2754
|
* @param options.guardrails - Guardrail labels to set. Fetches the current scope first to merge. Pass `[]` to clear all.
|
|
2755
|
+
* @param options.managerId - Numeric id of the manager scope to move this scope under, or `null`
|
|
2756
|
+
* to detach it. Send it alone: the server rejects it combined with other fields.
|
|
2603
2757
|
* @param options.updateMask - Comma-separated field names to update or clear.
|
|
2604
2758
|
* @returns The updated scope.
|
|
2605
2759
|
* @example
|
|
@@ -2635,7 +2789,7 @@ var ManagementScopesResource = class extends ScopesResourceBase {
|
|
|
2635
2789
|
evaluations: options.evaluations,
|
|
2636
2790
|
supervisionSubordinateDescriptions: options.supervisionSubordinateDescriptions
|
|
2637
2791
|
};
|
|
2638
|
-
const body = options.updateMask
|
|
2792
|
+
const body = updateBody(fields, options.updateMask);
|
|
2639
2793
|
const data = await invokeWithRetry(this.config, this.http, this.ops.update, {
|
|
2640
2794
|
pathParams: { id: scopeId },
|
|
2641
2795
|
query: updateMaskQuery(options.updateMask),
|
|
@@ -2666,9 +2820,48 @@ var ManagementScopesResource = class extends ScopesResourceBase {
|
|
|
2666
2820
|
);
|
|
2667
2821
|
return parseScope(data.scope);
|
|
2668
2822
|
}
|
|
2823
|
+
/**
|
|
2824
|
+
* Apply selection changes to a scope.
|
|
2825
|
+
*
|
|
2826
|
+
* Pass `validateOnly: true` to run the same checks and return the scope that would
|
|
2827
|
+
* be saved, without writing. Set a connection with `setConnectionPreferences` and
|
|
2828
|
+
* remove it with `removeConnection`.
|
|
2829
|
+
*
|
|
2830
|
+
* @param scopeId - Scope id.
|
|
2831
|
+
* @param ops - Selection changes, applied in order.
|
|
2832
|
+
* @param options.toolset - The scope toolset after the edit, when the edit changed it.
|
|
2833
|
+
* @param options.validateOnly - When true, check and return the planned scope without writing.
|
|
2834
|
+
* @returns The scope, or the scope that would be saved when `validateOnly` is true.
|
|
2835
|
+
* @example
|
|
2836
|
+
* ```ts
|
|
2837
|
+
* const mgmt = new ModusManagement()
|
|
2838
|
+
* const preview = await mgmt.scopes.applySelectionOps(42, [{
|
|
2839
|
+
* op: 'setConnectionPreferences',
|
|
2840
|
+
* connectionId: '11111111-1111-4111-8111-111111111111',
|
|
2841
|
+
* preferences: { schemaVersion: 2, mode: 'all', include: [], exclude: [] },
|
|
2842
|
+
* }], { validateOnly: true })
|
|
2843
|
+
* console.log(preview.id)
|
|
2844
|
+
* ```
|
|
2845
|
+
*/
|
|
2846
|
+
async applySelectionOps(scopeId, ops, options) {
|
|
2847
|
+
validateId(scopeId, "scope_id");
|
|
2848
|
+
const data = await invokeWithRetry(this.config, this.http, this.ops.applySelectionOps, {
|
|
2849
|
+
pathParams: { id: scopeId },
|
|
2850
|
+
jsonBody: omitUndefined({
|
|
2851
|
+
ops,
|
|
2852
|
+
toolset: options?.toolset,
|
|
2853
|
+
validateOnly: options?.validateOnly ? true : void 0
|
|
2854
|
+
})
|
|
2855
|
+
});
|
|
2856
|
+
return parseScope(data);
|
|
2857
|
+
}
|
|
2669
2858
|
/**
|
|
2670
2859
|
* Start transferring ownership of a scope to another organization member.
|
|
2671
2860
|
*
|
|
2861
|
+
* The current owner calls this, and the recipient accepts. A scope with no owner (one
|
|
2862
|
+
* created with a service-account token) can be given one by an organization owner;
|
|
2863
|
+
* assigning yourself takes effect at once.
|
|
2864
|
+
*
|
|
2672
2865
|
* @param scopeId - Scope id.
|
|
2673
2866
|
* @param options.newOwnerUserId - User id of the proposed new owner.
|
|
2674
2867
|
* @returns The scope with a pending ownership transfer.
|