@getmodus/sdk 0.8.0 → 0.10.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.
@@ -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,58 +11,178 @@ import {
10
11
  omitUndefined,
11
12
  validateId,
12
13
  validatePageSize
13
- } from "../chunk-GFS7CNON.js";
14
+ } from "../chunk-BMYCORZF.js";
15
+
16
+ // src/_generated/resources/management/workflows.ts
17
+ var WorkflowsResourceBase = class {
18
+ /** @internal */
19
+ constructor(http, config) {
20
+ this.http = http;
21
+ this.config = config;
22
+ }
23
+ /**
24
+ * List workflows.
25
+ *
26
+ * Returns a paginated page of workflows the caller can at least `use`. Workflows the caller
27
+ * cannot see are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
28
+ *
29
+ * **Requires:** `workflows:read`
30
+ *
31
+ * @param options.pageSize - Items per page. Defaults to 25.
32
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
33
+ * for the first page.
34
+ * @param options.search - Case-insensitive substring filter on workflow name.
35
+ * @param options.type - Filter by workflow type.
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.
39
+ * @param options.includeVariation - Include the requested variation payload (`trigger`,
40
+ * `workflowStructure`, `agentSelection`) on list rows.
41
+ * @returns A page of workflows.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const mgmt = new ModusManagement()
46
+ * for await (const wf of (await mgmt.workflows.list({ search: 'digest' })).autoPagingIter()) {
47
+ * console.log(wf.id, wf.name, wf.status)
48
+ * }
49
+ * ```
50
+ */
51
+ list(options = {}) {
52
+ const pageSize = options.pageSize ?? 25;
53
+ validatePageSize(pageSize);
54
+ return this.listPage(pageSize, options.pageToken, options.search, options.type, options.view, options.includeVariation);
55
+ }
56
+ async listPage(pageSize, pageToken, search, type, view, includeVariation) {
57
+ const extra = {};
58
+ if (search !== void 0) extra.search = search;
59
+ if (type !== void 0) extra.type = type;
60
+ if (view !== void 0) extra.view = view;
61
+ if (includeVariation !== void 0) extra.includeVariation = includeVariation;
62
+ const data = asRecord(
63
+ await invokeWithRetry(this.config, this.http, "WorkflowsController_list", {
64
+ query: aipListParams(pageSize, pageToken, extra)
65
+ })
66
+ );
67
+ return buildAipPage(
68
+ data,
69
+ "workflows",
70
+ (raw) => raw,
71
+ (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
72
+ );
73
+ }
74
+ /**
75
+ * Delete a workflow.
76
+ *
77
+ * Deletes a workflow and stops its schedule. The workflow can be restored later with POST
78
+ * /workflows/{id}/restore. Returns 404 if the workflow does not exist or is already deleted.
79
+ *
80
+ * **Requires:** `workflows:write`
81
+ *
82
+ * @param workflowId - Numeric workflow id.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const mgmt = new ModusManagement()
87
+ * await mgmt.workflows.delete('PLACEHOLDER_WORKFLOW_ID')
88
+ * ```
89
+ */
90
+ async delete(workflowId) {
91
+ validateId(workflowId, "workflow_id");
92
+ await invokeWithRetry(this.config, this.http, "WorkflowsController_delete", {
93
+ pathParams: { id: workflowId }
94
+ });
95
+ }
96
+ /**
97
+ * Restore a deleted workflow.
98
+ *
99
+ * Restores a previously deleted workflow and returns it. The workflow’s schedule is not resumed
100
+ * automatically — re-enable it if it should run again. Restoring an active workflow returns it
101
+ * unchanged.
102
+ *
103
+ * **Requires:** `workflows:write`
104
+ *
105
+ * @param workflowId - Numeric workflow id.
106
+ */
107
+ async restore(workflowId) {
108
+ validateId(workflowId, "workflow_id");
109
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_restore", {
110
+ pathParams: { id: workflowId },
111
+ jsonBody: {}
112
+ });
113
+ return data;
114
+ }
115
+ /**
116
+ * Cancel ownership transfer.
117
+ *
118
+ * Cancels a pending ownership transfer. The current owner may cancel; the pending recipient may
119
+ * decline.
120
+ *
121
+ * **Requires:** `workflows:write`
122
+ *
123
+ * @param workflowId - Numeric workflow id.
124
+ */
125
+ async cancelOwnershipTransfer(workflowId) {
126
+ validateId(workflowId, "workflow_id");
127
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_cancelOwnershipTransfer", {
128
+ pathParams: { id: workflowId }
129
+ });
130
+ return data;
131
+ }
132
+ /**
133
+ * Accept ownership transfer.
134
+ *
135
+ * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.
136
+ *
137
+ * **Requires:** `workflows:write`
138
+ *
139
+ * @param workflowId - Numeric workflow id.
140
+ */
141
+ async acceptOwnershipTransfer(workflowId) {
142
+ validateId(workflowId, "workflow_id");
143
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_acceptOwnershipTransfer", {
144
+ pathParams: { id: workflowId },
145
+ jsonBody: {}
146
+ });
147
+ return data;
148
+ }
149
+ };
14
150
 
15
151
  // src/_query.ts
16
152
  function updateMaskQuery(updateMask) {
17
153
  if (updateMask === void 0) return void 0;
18
154
  if (!updateMask.trim()) {
19
- throw new Error("update_mask must be a non-empty comma-separated list of field names");
155
+ throw new ValidationError("update_mask must be a non-empty comma-separated list of field names");
20
156
  }
21
157
  return { updateMask };
22
158
  }
23
-
24
- // src/management/_access-config.ts
25
- var EVERYONE_GROUP_ID = "__everyone__";
26
- function accessConfigWireForCreate(guardrails) {
27
- return {
28
- visibility: "shared",
29
- groupPermissions: { [EVERYONE_GROUP_ID]: { use: true, manage: true } },
30
- guardrails,
31
- sharedWith: []
32
- };
33
- }
34
- function accessConfigWireForUpdate(existing, guardrails) {
35
- if (!existing || Object.keys(existing).length === 0) {
36
- return accessConfigWireForCreate(guardrails);
37
- }
38
- return { ...existing, guardrails };
39
- }
40
- function accessFromSkillResponse(raw) {
41
- const value = raw.accessConfig ?? raw.access_config;
42
- if (value && typeof value === "object" && !Array.isArray(value)) {
43
- return value;
44
- }
45
- return {};
46
- }
47
- function accessConfigBodyForCreate(guardrails) {
48
- if (guardrails === void 0) return void 0;
49
- return accessConfigWireForCreate(guardrails);
50
- }
51
- async function accessConfigBodyForUpdate(guardrails, loadResource) {
52
- if (guardrails === void 0) return void 0;
53
- const existing = accessFromSkillResponse(await loadResource());
54
- 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;
55
168
  }
56
169
 
57
- // src/management/workflows/interfaces.ts
58
- var WorkflowInterfacesResource = class {
170
+ // src/_generated/resources/management/workflows/interfaces.ts
171
+ var WorkflowsInterfacesResourceBase = class {
172
+ /** @internal */
59
173
  constructor(http, config, workflowId) {
60
174
  this.http = http;
61
175
  this.config = config;
62
176
  this.workflowId = workflowId;
63
177
  }
64
- /** List interfaces attached to this workflow. */
178
+ /**
179
+ * List interfaces attached to a workflow.
180
+ *
181
+ * Returns every Slack, MCP, or Teams interface bound to the workflow. Requires manage permission
182
+ * on the workflow: returns 403 if you can only use it, and 404 if you cannot access it.
183
+ *
184
+ * **Requires:** `workflows:read`
185
+ */
65
186
  async list() {
66
187
  validateId(this.workflowId, "workflow_id");
67
188
  const data = await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_list", {
@@ -69,6 +190,40 @@ var WorkflowInterfacesResource = class {
69
190
  });
70
191
  return data.interfaces;
71
192
  }
193
+ /**
194
+ * Remove every interface from a workflow.
195
+ *
196
+ * Deletes all interface rows attached to the workflow. Useful when recreating the interface set
197
+ * from scratch.
198
+ *
199
+ * **Requires:** `workflows:write`
200
+ */
201
+ async deleteAll() {
202
+ validateId(this.workflowId, "workflow_id");
203
+ await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_deleteAll", {
204
+ pathParams: { id: this.workflowId }
205
+ });
206
+ }
207
+ /**
208
+ * Remove a workflow interface.
209
+ *
210
+ * Deletes one interface row. For MCP interfaces, bound MCP tokens are revoked best-effort.
211
+ *
212
+ * **Requires:** `workflows:write`
213
+ *
214
+ * @param interfaceId - Interface row id (UUID).
215
+ */
216
+ async delete(interfaceId) {
217
+ validateId(this.workflowId, "workflow_id");
218
+ validateId(interfaceId, "interface_id");
219
+ await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_delete", {
220
+ pathParams: { id: this.workflowId, interfaceId }
221
+ });
222
+ }
223
+ };
224
+
225
+ // src/management/workflows/interfaces.ts
226
+ var WorkflowInterfacesResource = class extends WorkflowsInterfacesResourceBase {
72
227
  /**
73
228
  * Add an interface to this workflow.
74
229
  *
@@ -96,26 +251,7 @@ var WorkflowInterfacesResource = class {
96
251
  return await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_update", {
97
252
  pathParams: { id: this.workflowId, interfaceId },
98
253
  query: updateMaskQuery(updateMask),
99
- jsonBody: updateMask === void 0 ? omitUndefined(options) : options
100
- });
101
- }
102
- /**
103
- * Delete an interface from this workflow.
104
- *
105
- * @param interfaceId - Interface id.
106
- */
107
- async delete(interfaceId) {
108
- validateId(this.workflowId, "workflow_id");
109
- validateId(interfaceId, "interface_id");
110
- await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_delete", {
111
- pathParams: { id: this.workflowId, interfaceId }
112
- });
113
- }
114
- /** Delete every interface from this workflow. */
115
- async deleteAll() {
116
- validateId(this.workflowId, "workflow_id");
117
- await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_deleteAll", {
118
- pathParams: { id: this.workflowId }
254
+ jsonBody: updateBody(options, updateMask)
119
255
  });
120
256
  }
121
257
  };
@@ -134,76 +270,25 @@ var MANAGEMENT_WORKFLOW_OPERATIONS = {
134
270
  acceptOwnershipTransfer: "WorkflowsController_acceptOwnershipTransfer",
135
271
  toggle: "WorkflowsController_toggle"
136
272
  };
137
- function workflowsListParams(pageSize, pageToken, search, type, view, includeVariation) {
138
- const extra = {};
139
- if (search !== void 0) extra.search = search;
140
- if (type !== void 0) extra.type = type;
141
- if (view !== void 0) extra.view = view;
142
- if (includeVariation !== void 0) extra.includeVariation = includeVariation;
143
- return aipListParams(pageSize, pageToken, extra);
144
- }
145
273
  function parseWorkflow(raw) {
146
274
  return raw;
147
275
  }
148
- var ManagementWorkflowsResource = class {
149
- constructor(http, config) {
150
- this.http = http;
151
- this.config = config;
276
+ var ManagementWorkflowsResource = class extends WorkflowsResourceBase {
277
+ constructor() {
278
+ super(...arguments);
152
279
  this.ops = MANAGEMENT_WORKFLOW_OPERATIONS;
153
280
  }
154
- /**
155
- * List workflows in the organization.
156
- *
157
- * @param options.pageSize - Maximum items per page (default 25).
158
- * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
159
- * @param options.search - Case-insensitive substring filter on the workflow name.
160
- * @param options.type - Filter by workflow type: `"task"` or `"workflow"`.
161
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
162
- * @param options.includeVariation - Include variation payload on each list row.
163
- * @returns A page of workflows.
164
- * @example
165
- * ```ts
166
- * const mgmt = new ModusManagement()
167
- * for await (const wf of (await mgmt.workflows.list({ search: 'digest' })).autoPagingIter()) {
168
- * console.log(wf.id, wf.name, wf.status)
169
- * }
170
- * ```
171
- */
172
- list(options = {}) {
173
- const pageSize = options.pageSize ?? 25;
174
- validatePageSize(pageSize);
175
- return this.listPage(
176
- pageSize,
177
- options.pageToken,
178
- options.search,
179
- options.type,
180
- options.view,
181
- options.includeVariation
182
- );
183
- }
184
- async listPage(pageSize, pageToken, search, type, view, includeVariation) {
185
- const data = asRecord(
186
- await invokeWithRetry(this.config, this.http, this.ops.list, {
187
- query: workflowsListParams(pageSize, pageToken, search, type, view, includeVariation)
188
- })
189
- );
190
- return buildAipPage(
191
- data,
192
- "workflows",
193
- parseWorkflow,
194
- (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
195
- );
196
- }
197
281
  /**
198
282
  * Retrieve a workflow with full configuration.
199
283
  *
200
- * @param workflowId - Workflow id.
201
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
284
+ * @param workflowId - Numeric workflow id.
285
+ * @param options.view - Variation view: `"active"` (deployed), `"draft"`, or `"published"` (published workflow you can use).
202
286
  * @returns The workflow.
203
287
  * @example
204
288
  * ```ts
205
289
  * const mgmt = new ModusManagement()
206
- * const wf = await mgmt.workflows.get('weekly-digest')
290
+ * const [first] = (await mgmt.workflows.list()).items
291
+ * const wf = await mgmt.workflows.get(first.id)
207
292
  * console.log(wf.name, wf.status)
208
293
  * ```
209
294
  */
@@ -229,14 +314,13 @@ var ManagementWorkflowsResource = class {
229
314
  * Create a new workflow in the organization.
230
315
  *
231
316
  * @param options.name - Display name for the workflow.
232
- * @param options.type - `"task"` for single-step orchestration, or `"workflow"` for a multi-step graph.
317
+ * @param options.type - `"workflow"`. `"task"` is a deprecated alias the server stores as `"workflow"`.
233
318
  * @param options.trigger - Optional trigger configuration.
234
- * @param options.guardrails - Runtime guardrail labels (for example `"no-pii"`). Omit to create with no guardrails.
235
319
  * @returns The created workflow (draft).
236
320
  * @example
237
321
  * ```ts
238
322
  * const mgmt = new ModusManagement()
239
- * const wf = await mgmt.workflows.create({ name: 'Daily report', type: 'task' })
323
+ * const wf = await mgmt.workflows.create({ name: 'Daily report', type: 'workflow' })
240
324
  * ```
241
325
  */
242
326
  async create(options) {
@@ -246,8 +330,7 @@ var ManagementWorkflowsResource = class {
246
330
  description: options.description,
247
331
  trigger: options.trigger,
248
332
  agentSelection: options.agentSelection,
249
- workflowStructure: options.workflowStructure,
250
- accessConfig: accessConfigBodyForCreate(options.guardrails)
333
+ workflowStructure: options.workflowStructure
251
334
  });
252
335
  const data = await invokeWithRetry(this.config, this.http, this.ops.create, {
253
336
  jsonBody: body
@@ -258,10 +341,10 @@ var ManagementWorkflowsResource = class {
258
341
  * Update a workflow's configuration.
259
342
  *
260
343
  * Only the fields you pass are changed. To clear a field, name it in
261
- * `updateMask` and leave its argument unset.
344
+ * `updateMask` and leave its argument unset: it is sent as `null`.
262
345
  *
263
- * @param workflowId - Workflow id.
264
- * @param options.guardrails - Guardrail labels to set. Fetches the current workflow first to merge. Pass `[]` to clear all.
346
+ * @param workflowId - Numeric workflow id.
347
+ * @param options.type - Only `"workflow"` is accepted; `"task"` is rejected with a 422.
265
348
  * @param options.updateMask - Comma-separated field names to update or clear.
266
349
  * @returns The updated workflow.
267
350
  * @example
@@ -272,24 +355,15 @@ var ManagementWorkflowsResource = class {
272
355
  */
273
356
  async update(workflowId, options = {}) {
274
357
  validateId(workflowId, "workflow_id");
275
- const accessConfig = await accessConfigBodyForUpdate(
276
- options.guardrails,
277
- async () => asRecord(
278
- await invokeWithRetry(this.config, this.http, this.ops.get, {
279
- pathParams: { id: workflowId }
280
- })
281
- )
282
- );
283
358
  const fields = {
284
359
  name: options.name,
285
360
  type: options.type,
286
361
  description: options.description,
287
362
  trigger: options.trigger,
288
363
  agentSelection: options.agentSelection,
289
- workflowStructure: options.workflowStructure,
290
- accessConfig
364
+ workflowStructure: options.workflowStructure
291
365
  };
292
- const body = options.updateMask !== void 0 ? fields : omitUndefined(fields);
366
+ const body = updateBody(fields, options.updateMask);
293
367
  const data = await invokeWithRetry(this.config, this.http, this.ops.update, {
294
368
  pathParams: { id: workflowId },
295
369
  query: updateMaskQuery(options.updateMask),
@@ -334,37 +408,6 @@ var ManagementWorkflowsResource = class {
334
408
  });
335
409
  return parseWorkflow(data);
336
410
  }
337
- /**
338
- * Delete a workflow.
339
- *
340
- * @param workflowId - Workflow id.
341
- * @returns Resolves when the workflow is deleted.
342
- * @example
343
- * ```ts
344
- * const mgmt = new ModusManagement()
345
- * await mgmt.workflows.delete('PLACEHOLDER_WORKFLOW_ID')
346
- * ```
347
- */
348
- async delete(workflowId) {
349
- validateId(workflowId, "workflow_id");
350
- await invokeWithRetry(this.config, this.http, this.ops.delete, {
351
- pathParams: { id: workflowId }
352
- });
353
- }
354
- /**
355
- * Restore a previously deleted workflow.
356
- *
357
- * @param workflowId - Workflow id.
358
- * @returns The restored workflow.
359
- */
360
- async restore(workflowId) {
361
- validateId(workflowId, "workflow_id");
362
- const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
363
- pathParams: { id: workflowId },
364
- jsonBody: {}
365
- });
366
- return parseWorkflow(data);
367
- }
368
411
  /**
369
412
  * Start transferring ownership of a workflow to another organization member.
370
413
  *
@@ -385,28 +428,6 @@ var ManagementWorkflowsResource = class {
385
428
  );
386
429
  return parseWorkflow(data);
387
430
  }
388
- /** Cancel a pending workflow ownership transfer. */
389
- async cancelOwnershipTransfer(workflowId) {
390
- validateId(workflowId, "workflow_id");
391
- const data = await invokeWithRetry(
392
- this.config,
393
- this.http,
394
- this.ops.cancelOwnershipTransfer,
395
- { pathParams: { id: workflowId } }
396
- );
397
- return parseWorkflow(data);
398
- }
399
- /** Accept a pending workflow ownership transfer. */
400
- async acceptOwnershipTransfer(workflowId) {
401
- validateId(workflowId, "workflow_id");
402
- const data = await invokeWithRetry(
403
- this.config,
404
- this.http,
405
- this.ops.acceptOwnershipTransfer,
406
- { pathParams: { id: workflowId }, jsonBody: {} }
407
- );
408
- return parseWorkflow(data);
409
- }
410
431
  };
411
432
 
412
433
  // src/types/context.ts
@@ -417,10 +438,10 @@ function withCreatedUid(data) {
417
438
  // src/management/context/_content-merge.ts
418
439
  function requireContentDict(item, contextType) {
419
440
  if (item.contextType !== contextType) {
420
- throw new Error(`Expected contextType ${contextType}, got ${item.contextType}.`);
441
+ throw new ValidationError(`Expected contextType ${contextType}, got ${item.contextType}.`);
421
442
  }
422
443
  if (!item.content || typeof item.content !== "object" || Array.isArray(item.content)) {
423
- throw new Error(`Context item ${item.uid} has no object content; cannot merge ${contextType} fields.`);
444
+ throw new ValidationError(`Context item ${item.uid} has no object content; cannot merge ${contextType} fields.`);
424
445
  }
425
446
  return item.content;
426
447
  }
@@ -477,28 +498,194 @@ async function resolveAndUpdateSavedQuery(items, uid, options) {
477
498
  }
478
499
  async function resolveAndUpdateLink(items, uid, options) {
479
500
  if (options.title === void 0 && options.url === void 0 && options.description === void 0 && options.userFeedback === void 0 && options.topics === void 0) {
480
- throw new Error("Provide at least one field to update.");
501
+ throw new ValidationError("Provide at least one field to update.");
502
+ }
503
+ if (options.title === void 0 && options.url === void 0) {
504
+ return items.update(uid, {
505
+ description: options.description,
506
+ userFeedback: options.userFeedback,
507
+ topics: options.topics
508
+ });
509
+ }
510
+ const content = await resolveExistingContent(items, uid, "link", options.existing);
511
+ return updateWithMergedContent(items, uid, {
512
+ contextType: "link",
513
+ mergedContent: mergeLinkContent(content, { title: options.title, url: options.url }),
514
+ existing: options.existing,
515
+ description: options.description,
516
+ userFeedback: options.userFeedback,
517
+ topics: options.topics
518
+ });
519
+ }
520
+
521
+ // src/_generated/resources/management/context/dashboards.ts
522
+ var ContextDashboardsResourceBase = class {
523
+ /** @internal */
524
+ constructor(http, config) {
525
+ this.http = http;
526
+ this.config = config;
527
+ }
528
+ /**
529
+ * Delete a dashboard.
530
+ *
531
+ * Removes the dashboard from every listing and deletes its alert workflows. It cannot be restored
532
+ * through the API.
533
+ *
534
+ * **Requires:** `context:write`
535
+ *
536
+ * @param dashboardId - Dashboard id, as shown in the app URL.
537
+ *
538
+ * @example
539
+ * ```ts
540
+ * await mgmt.context.dashboards.delete('DASHBOARD_ID')
541
+ * ```
542
+ */
543
+ async delete(dashboardId) {
544
+ validateId(dashboardId, "dashboardId");
545
+ await invokeWithRetry(this.config, this.http, "DashboardsController_delete", {
546
+ pathParams: { dashboardId }
547
+ });
548
+ }
549
+ /**
550
+ * List dashboard draft snapshots.
551
+ *
552
+ * Returns ids and timestamps of the most recent draft snapshots. Editors only.
553
+ *
554
+ * **Requires:** `context:read`
555
+ *
556
+ * @param dashboardId - Dashboard id, as shown in the app URL.
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * const snapshots = await mgmt.context.dashboards.listDraftSnapshots('DASHBOARD_ID')
561
+ * snapshots.map((snapshot) => snapshot.uid)
562
+ * ```
563
+ */
564
+ async listDraftSnapshots(dashboardId) {
565
+ validateId(dashboardId, "dashboardId");
566
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listDraftSnapshots", {
567
+ pathParams: { dashboardId }
568
+ });
569
+ return asRecord(data).snapshots;
481
570
  }
482
- if (options.title === void 0 && options.url === void 0) {
483
- return items.update(uid, {
484
- description: options.description,
485
- userFeedback: options.userFeedback,
486
- topics: options.topics
571
+ /**
572
+ * Cancel an ownership transfer.
573
+ *
574
+ * Owner only. Clears the pending transfer and returns the dashboard.
575
+ *
576
+ * **Requires:** `context:write`
577
+ *
578
+ * @param dashboardId - Dashboard id, as shown in the app URL.
579
+ *
580
+ * @example
581
+ * ```ts
582
+ * await mgmt.context.dashboards.cancelOwnershipTransfer('DASHBOARD_ID')
583
+ * ```
584
+ */
585
+ async cancelOwnershipTransfer(dashboardId) {
586
+ validateId(dashboardId, "dashboardId");
587
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_cancelOwnership", {
588
+ pathParams: { dashboardId }
487
589
  });
590
+ return asRecord(data);
488
591
  }
489
- const content = await resolveExistingContent(items, uid, "link", options.existing);
490
- return updateWithMergedContent(items, uid, {
491
- contextType: "link",
492
- mergedContent: mergeLinkContent(content, { title: options.title, url: options.url }),
493
- existing: options.existing,
494
- description: options.description,
495
- userFeedback: options.userFeedback,
496
- topics: options.topics
497
- });
498
- }
592
+ /**
593
+ * Accept an ownership transfer.
594
+ *
595
+ * Recipient only. Makes you the owner and clears the pending transfer.
596
+ *
597
+ * **Requires:** `context:write`
598
+ *
599
+ * @param dashboardId - Dashboard id, as shown in the app URL.
600
+ *
601
+ * @example
602
+ * ```ts
603
+ * await mgmt.context.dashboards.acceptOwnershipTransfer('DASHBOARD_ID')
604
+ * ```
605
+ */
606
+ async acceptOwnershipTransfer(dashboardId) {
607
+ validateId(dashboardId, "dashboardId");
608
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_acceptOwnership", {
609
+ pathParams: { dashboardId }
610
+ });
611
+ return asRecord(data);
612
+ }
613
+ /**
614
+ * List dashboard versions.
615
+ *
616
+ * Returns the published versions, newest first, each with its full definition. Draft snapshots
617
+ * are not included. The response is not paginated and can be large.
618
+ *
619
+ * **Requires:** `context:read`
620
+ *
621
+ * @param dashboardId - Dashboard id, as shown in the app URL.
622
+ *
623
+ * @example
624
+ * ```ts
625
+ * const versions = await mgmt.context.dashboards.listVersions('DASHBOARD_ID')
626
+ * versions.map((version) => [version.uid, version.versionNumber])
627
+ * ```
628
+ */
629
+ async listVersions(dashboardId) {
630
+ validateId(dashboardId, "dashboardId");
631
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listVersions", {
632
+ pathParams: { dashboardId }
633
+ });
634
+ return asRecord(data).versions;
635
+ }
636
+ /**
637
+ * Get a dashboard version.
638
+ *
639
+ * Returns the dashboard as it was in the given version. For a draft snapshot (editors only) the
640
+ * view is reported as active and selectedVersion.versionNumber is null.
641
+ *
642
+ * **Requires:** `context:read`
643
+ *
644
+ * @param dashboardId - Dashboard id, as shown in the app URL.
645
+ * @param versionId - Version id, or a draft snapshot id for editors.
646
+ *
647
+ * @example
648
+ * ```ts
649
+ * const old = await mgmt.context.dashboards.getVersion('DASHBOARD_ID', 'VERSION_ID')
650
+ * old.selectedVersion.versionNumber
651
+ * ```
652
+ */
653
+ async getVersion(dashboardId, versionId) {
654
+ validateId(dashboardId, "dashboardId");
655
+ validateId(versionId, "versionId");
656
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_getVersion", {
657
+ pathParams: { dashboardId, versionId }
658
+ });
659
+ return asRecord(data);
660
+ }
661
+ /**
662
+ * Restore a dashboard version.
663
+ *
664
+ * Replaces the current draft with the content of the given version. The outgoing draft is kept as
665
+ * a draft snapshot. Returns the draft view.
666
+ *
667
+ * **Requires:** `context:write`
668
+ *
669
+ * @param dashboardId - Dashboard id, as shown in the app URL.
670
+ * @param versionId - Version id, or a draft snapshot id for editors.
671
+ *
672
+ * @example
673
+ * ```ts
674
+ * await mgmt.context.dashboards.restoreVersion('DASHBOARD_ID', 'VERSION_ID')
675
+ * ```
676
+ */
677
+ async restoreVersion(dashboardId, versionId) {
678
+ validateId(dashboardId, "dashboardId");
679
+ validateId(versionId, "versionId");
680
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_restore", {
681
+ pathParams: { dashboardId, versionId }
682
+ });
683
+ return asRecord(data);
684
+ }
685
+ };
499
686
 
500
- // src/management/context/dashboards.ts
501
- var ManagementDashboardElementsResource = class {
687
+ // src/_generated/resources/management/context/dashboards/elements.ts
688
+ var ContextDashboardsElementsResourceBase = class {
502
689
  /** @internal */
503
690
  constructor(http, config, dashboardId) {
504
691
  this.http = http;
@@ -506,11 +693,14 @@ var ManagementDashboardElementsResource = class {
506
693
  this.dashboardId = dashboardId;
507
694
  }
508
695
  /**
509
- * List every tile and filter on the dashboard draft.
696
+ * List dashboard elements.
697
+ *
698
+ * Lists every tile and filter on the dashboard draft with id, kind, title and layout. Filters
699
+ * also carry sqlReferences, the exact templates tile SQL must use to reference them. Returns the
700
+ * current draftRevision.
701
+ *
702
+ * **Requires:** `context:read`
510
703
  *
511
- * @returns Each element's id, kind, title and grid position, plus the current
512
- * `draftRevision` to pass as `expectedRevision` on the next change.
513
- * @throws NotFoundError - The dashboard does not exist or you cannot edit it.
514
704
  * @example
515
705
  * ```ts
516
706
  * const listed = await mgmt.context.dashboards.elements('DASHBOARD_ID').list()
@@ -518,19 +708,21 @@ var ManagementDashboardElementsResource = class {
518
708
  * ```
519
709
  */
520
710
  async list() {
521
- return asRecord(
522
- await invokeWithRetry(this.config, this.http, "DashboardsController_listElements", {
523
- pathParams: { dashboardId: this.dashboardId }
524
- })
525
- );
711
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listElements", {
712
+ pathParams: { dashboardId: this.dashboardId }
713
+ });
714
+ return asRecord(data);
526
715
  }
527
716
  /**
528
- * Get the full draft settings of one tile or filter.
717
+ * Get a dashboard element.
718
+ *
719
+ * Returns the full draft configuration of one dashboard element, including SQL, chart settings
720
+ * and filter options, with the current draftRevision.
721
+ *
722
+ * **Requires:** `context:read`
723
+ *
724
+ * @param elementId - The dashboard element id to read.
529
725
  *
530
- * @param elementId - Id of the tile or filter, as returned by `list()`.
531
- * @returns The element's settings and the current `draftRevision`.
532
- * @throws NotFoundError - The dashboard or the element does not exist, or you cannot
533
- * edit the dashboard.
534
726
  * @example
535
727
  * ```ts
536
728
  * const result = await mgmt.context.dashboards.elements('DASHBOARD_ID').get('ELEMENT_ID')
@@ -539,11 +731,18 @@ var ManagementDashboardElementsResource = class {
539
731
  */
540
732
  async get(elementId) {
541
733
  validateId(elementId, "elementId");
542
- return asRecord(
543
- await invokeWithRetry(this.config, this.http, "DashboardsController_getElement", {
544
- pathParams: { dashboardId: this.dashboardId, elementId }
545
- })
546
- );
734
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_getElement", {
735
+ pathParams: { dashboardId: this.dashboardId, elementId }
736
+ });
737
+ return asRecord(data);
738
+ }
739
+ };
740
+
741
+ // src/management/context/dashboards.ts
742
+ var ManagementDashboardElementsResource = class extends ContextDashboardsElementsResourceBase {
743
+ /** @internal */
744
+ constructor(http, config, dashboardId) {
745
+ super(http, config, dashboardId);
547
746
  }
548
747
  /**
549
748
  * Add a blank tile or filter to the dashboard draft.
@@ -608,11 +807,10 @@ var ManagementDashboardElementsResource = class {
608
807
  );
609
808
  }
610
809
  };
611
- var ManagementDashboardsResource = class {
810
+ var ManagementDashboardsResource = class extends ContextDashboardsResourceBase {
612
811
  /** @internal */
613
812
  constructor(http, config) {
614
- this.http = http;
615
- this.config = config;
813
+ super(http, config);
616
814
  }
617
815
  /**
618
816
  * List dashboards with their full definitions.
@@ -753,117 +951,6 @@ var ManagementDashboardsResource = class {
753
951
  })
754
952
  );
755
953
  }
756
- /**
757
- * Delete a dashboard and the alert workflows defined on it.
758
- *
759
- * A deleted dashboard cannot be restored.
760
- *
761
- * @param dashboardId - Id of the dashboard.
762
- * @throws NotFoundError - The dashboard does not exist or you cannot edit it.
763
- * @example
764
- * ```ts
765
- * await mgmt.context.dashboards.delete('DASHBOARD_ID')
766
- * ```
767
- */
768
- async delete(dashboardId) {
769
- validateId(dashboardId, "dashboardId");
770
- await invokeWithRetry(this.config, this.http, "DashboardsController_delete", {
771
- pathParams: { dashboardId }
772
- });
773
- }
774
- /**
775
- * List the published versions of a dashboard, newest first.
776
- *
777
- * @param dashboardId - Id of the dashboard.
778
- * @returns Every published version with its full definition. Definitions are
779
- * returned as stored, so older versions may lack newer fields. The list is
780
- * not paginated.
781
- * @throws NotFoundError - The dashboard does not exist or you cannot open it.
782
- * @example
783
- * ```ts
784
- * const versions = await mgmt.context.dashboards.listVersions('DASHBOARD_ID')
785
- * versions.map((version) => [version.uid, version.versionNumber])
786
- * ```
787
- */
788
- async listVersions(dashboardId) {
789
- validateId(dashboardId, "dashboardId");
790
- const data = asRecord(
791
- await invokeWithRetry(this.config, this.http, "DashboardsController_listVersions", {
792
- pathParams: { dashboardId }
793
- })
794
- );
795
- return data.versions;
796
- }
797
- /**
798
- * Get a dashboard as it was in one version.
799
- *
800
- * @param dashboardId - Id of the dashboard.
801
- * @param versionId - Id of the version, as returned by `listVersions()`.
802
- * @returns The dashboard with that version's definition.
803
- * @throws NotFoundError - The dashboard or the version does not exist, or you cannot
804
- * open the dashboard.
805
- * @example
806
- * ```ts
807
- * const old = await mgmt.context.dashboards.getVersion('DASHBOARD_ID', 'VERSION_ID')
808
- * old.selectedVersion.versionNumber
809
- * ```
810
- */
811
- async getVersion(dashboardId, versionId) {
812
- validateId(dashboardId, "dashboardId");
813
- validateId(versionId, "versionId");
814
- return asRecord(
815
- await invokeWithRetry(this.config, this.http, "DashboardsController_getVersion", {
816
- pathParams: { dashboardId, versionId }
817
- })
818
- );
819
- }
820
- /**
821
- * Replace the draft with the content of an earlier version.
822
- *
823
- * The draft being replaced is kept as a draft snapshot. Call `publish()`
824
- * afterwards to make the restored content visible.
825
- *
826
- * @param dashboardId - Id of the dashboard.
827
- * @param versionId - Id of the version or draft snapshot to restore.
828
- * @returns The dashboard draft after the restore.
829
- * @throws NotFoundError - The dashboard or the version does not exist, or you cannot
830
- * edit the dashboard.
831
- * @example
832
- * ```ts
833
- * await mgmt.context.dashboards.restoreVersion('DASHBOARD_ID', 'VERSION_ID')
834
- * ```
835
- */
836
- async restoreVersion(dashboardId, versionId) {
837
- validateId(dashboardId, "dashboardId");
838
- validateId(versionId, "versionId");
839
- return asRecord(
840
- await invokeWithRetry(this.config, this.http, "DashboardsController_restore", {
841
- pathParams: { dashboardId, versionId }
842
- })
843
- );
844
- }
845
- /**
846
- * List recent snapshots of the dashboard draft, newest first.
847
- *
848
- * @param dashboardId - Id of the dashboard.
849
- * @returns Up to 100 snapshots with their id, author and time. Pass an id to
850
- * `restoreVersion()` to bring that draft back.
851
- * @throws NotFoundError - The dashboard does not exist or you cannot edit it.
852
- * @example
853
- * ```ts
854
- * const snapshots = await mgmt.context.dashboards.listDraftSnapshots('DASHBOARD_ID')
855
- * snapshots.map((snapshot) => snapshot.uid)
856
- * ```
857
- */
858
- async listDraftSnapshots(dashboardId) {
859
- validateId(dashboardId, "dashboardId");
860
- const data = asRecord(
861
- await invokeWithRetry(this.config, this.http, "DashboardsController_listDraftSnapshots", {
862
- pathParams: { dashboardId }
863
- })
864
- );
865
- return data.snapshots;
866
- }
867
954
  /**
868
955
  * Replace who can open and edit a dashboard.
869
956
  *
@@ -929,96 +1016,110 @@ var ManagementDashboardsResource = class {
929
1016
  );
930
1017
  }
931
1018
  /**
932
- * Accept a pending ownership transfer and become the dashboard owner.
933
- *
934
- * Only the requested recipient can accept.
1019
+ * Work with the tiles and filters of one dashboard draft.
935
1020
  *
936
1021
  * @param dashboardId - Id of the dashboard.
937
- * @returns The dashboard with you as its owner.
938
- * @throws NotFoundError - The dashboard does not exist, or it has no pending transfer
939
- * addressed to you.
1022
+ * @returns A resource bound to that dashboard.
940
1023
  * @example
941
1024
  * ```ts
942
- * await mgmt.context.dashboards.acceptOwnershipTransfer('DASHBOARD_ID')
1025
+ * await mgmt.context.dashboards.elements('DASHBOARD_ID').list()
943
1026
  * ```
944
1027
  */
945
- async acceptOwnershipTransfer(dashboardId) {
1028
+ elements(dashboardId) {
946
1029
  validateId(dashboardId, "dashboardId");
947
- return asRecord(
948
- await invokeWithRetry(this.config, this.http, "DashboardsController_acceptOwnership", {
949
- pathParams: { dashboardId }
950
- })
951
- );
1030
+ return new ManagementDashboardElementsResource(this.http, this.config, dashboardId);
952
1031
  }
953
1032
  /**
954
- * Cancel a pending ownership transfer.
955
- *
956
- * Only the owner can cancel.
1033
+ * Move or resize several tiles and filters in one change.
957
1034
  *
958
1035
  * @param dashboardId - Id of the dashboard.
959
- * @returns The dashboard with no pending transfer.
960
- * @throws NotFoundError - The dashboard does not exist, you cannot open it, or you are
961
- * not the owner.
1036
+ * @param input.expectedRevision - The `draftRevision` your change is based on.
1037
+ * @param input.elements - Every element to place, each with `elementId` and its
1038
+ * final `layout`.
1039
+ * @returns The whole dashboard after the change, including the new `draftRevision`.
1040
+ * @throws ConflictError - The draft changed since `expectedRevision`.
962
1041
  * @example
963
1042
  * ```ts
964
- * await mgmt.context.dashboards.cancelOwnershipTransfer('DASHBOARD_ID')
1043
+ * await mgmt.context.dashboards.updateLayout('DASHBOARD_ID', {
1044
+ * expectedRevision: 3,
1045
+ * elements: [{ elementId: 'ELEMENT_ID', layout: { x: 0, y: 0, w: 12, h: 2 } }],
1046
+ * })
965
1047
  * ```
966
1048
  */
967
- async cancelOwnershipTransfer(dashboardId) {
1049
+ async updateLayout(dashboardId, input) {
968
1050
  validateId(dashboardId, "dashboardId");
969
1051
  return asRecord(
970
- await invokeWithRetry(this.config, this.http, "DashboardsController_cancelOwnership", {
971
- pathParams: { dashboardId }
1052
+ await invokeWithRetry(this.config, this.http, "DashboardsController_updateLayout", {
1053
+ pathParams: { dashboardId },
1054
+ jsonBody: { expectedRevision: input.expectedRevision, elements: input.elements }
972
1055
  })
973
1056
  );
974
1057
  }
1058
+ };
1059
+
1060
+ // src/management/context/files.ts
1061
+ import { readdir, readFile, stat } from "fs/promises";
1062
+ import { dirname, join, relative } from "path";
1063
+
1064
+ // src/_generated/resources/management/context/files.ts
1065
+ var ContextFilesResourceBase = class {
1066
+ /** @internal */
1067
+ constructor(http, config) {
1068
+ this.http = http;
1069
+ this.config = config;
1070
+ }
975
1071
  /**
976
- * Work with the tiles and filters of one dashboard draft.
1072
+ * List file uploads.
977
1073
  *
978
- * @param dashboardId - Id of the dashboard.
979
- * @returns A resource bound to that dashboard.
980
- * @example
981
- * ```ts
982
- * await mgmt.context.dashboards.elements('DASHBOARD_ID').list()
983
- * ```
1074
+ * Returns a page of durable landed file uploads. Uploads that have not landed yet are visible via
1075
+ * `GET /context/files/{uploadId}`, not this list.
1076
+ *
1077
+ * **Requires:** `context:read`
1078
+ *
1079
+ * @param options.pageSize - Items per page. Defaults to 50.
1080
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
1081
+ * for the first page.
1082
+ * @returns A page of files.
984
1083
  */
985
- elements(dashboardId) {
986
- validateId(dashboardId, "dashboardId");
987
- return new ManagementDashboardElementsResource(this.http, this.config, dashboardId);
1084
+ list(options = {}) {
1085
+ const pageSize = options.pageSize ?? 50;
1086
+ validatePageSize(pageSize, 200);
1087
+ return this.listPage(pageSize, options.pageToken);
1088
+ }
1089
+ async listPage(pageSize, pageToken) {
1090
+ const data = asRecord(
1091
+ await invokeWithRetry(this.config, this.http, "ContextFilesController_list", {
1092
+ query: aipListParams(pageSize, pageToken)
1093
+ })
1094
+ );
1095
+ return buildAipPage(
1096
+ data,
1097
+ "files",
1098
+ (raw) => raw,
1099
+ (token) => this.listPage(pageSize, token)
1100
+ );
988
1101
  }
989
1102
  /**
990
- * Move or resize several tiles and filters in one change.
1103
+ * Get a file upload.
991
1104
  *
992
- * @param dashboardId - Id of the dashboard.
993
- * @param input.expectedRevision - The `draftRevision` your change is based on.
994
- * @param input.elements - Every element to place, each with `elementId` and its
995
- * final `layout`.
996
- * @returns The whole dashboard after the change, including the new `draftRevision`.
997
- * @throws ConflictError - The draft changed since `expectedRevision`.
998
- * @example
999
- * ```ts
1000
- * await mgmt.context.dashboards.updateLayout('DASHBOARD_ID', {
1001
- * expectedRevision: 3,
1002
- * elements: [{ elementId: 'ELEMENT_ID', layout: { x: 0, y: 0, w: 12, h: 2 } }],
1003
- * })
1004
- * ```
1105
+ * Returns status + metadata for one upload. Prefers the durable landed context item; falls back
1106
+ * to in-flight upload status while the object has not landed yet. 404 if neither exists.
1107
+ *
1108
+ * **Requires:** `context:read`
1109
+ *
1110
+ * @param uploadId - Upload id returned by `createUploadUrl` / `createUploadUrls`.
1005
1111
  */
1006
- async updateLayout(dashboardId, input) {
1007
- validateId(dashboardId, "dashboardId");
1008
- return asRecord(
1009
- await invokeWithRetry(this.config, this.http, "DashboardsController_updateLayout", {
1010
- pathParams: { dashboardId },
1011
- jsonBody: { expectedRevision: input.expectedRevision, elements: input.elements }
1012
- })
1013
- );
1112
+ async get(uploadId) {
1113
+ validateId(uploadId, "uploadId");
1114
+ const data = await invokeWithRetry(this.config, this.http, "ContextFilesController_get", {
1115
+ pathParams: { uploadId }
1116
+ });
1117
+ return asRecord(data);
1014
1118
  }
1015
1119
  };
1016
1120
 
1017
1121
  // src/management/context/files.ts
1018
- import { readdir, readFile, stat } from "fs/promises";
1019
- import { dirname, join, relative } from "path";
1020
1122
  var MAX_BULK_UPLOAD_FILES = 100;
1021
- var DEFAULT_LIST_PAGE_SIZE = 50;
1022
1123
  var DEFAULT_PUT_TIMEOUT_MS = 6e4;
1023
1124
  var DEFAULT_POLL_INTERVAL_MS = 500;
1024
1125
  var DEFAULT_UPLOAD_TIMEOUT_MS = 12e4;
@@ -1026,15 +1127,24 @@ var DEFAULT_CONCURRENCY = 10;
1026
1127
  var STATUS_ORDER = { pending: 0, processing: 1, ready: 2 };
1027
1128
  var WAIT_UNTIL_VALUES = /* @__PURE__ */ new Set(["processing", "ready"]);
1028
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
+ }
1029
1139
  function validateWaitUntil(waitUntil) {
1030
1140
  if (!WAIT_UNTIL_VALUES.has(waitUntil)) {
1031
- throw new Error(`waitUntil must be one of ${[...WAIT_UNTIL_VALUES].join(", ")}, got ${waitUntil}`);
1141
+ throw new ValidationError(`waitUntil must be one of ${[...WAIT_UNTIL_VALUES].join(", ")}, got ${waitUntil}`);
1032
1142
  }
1033
1143
  }
1034
1144
  function validateBulkSize(count, name) {
1035
- if (count === 0) throw new Error(`${name} must not be empty`);
1145
+ if (count === 0) throw new ValidationError(`${name} must not be empty`);
1036
1146
  if (count > MAX_BULK_UPLOAD_FILES) {
1037
- throw new Error(`${name} must have at most ${MAX_BULK_UPLOAD_FILES} entries, got ${count}`);
1147
+ throw new ValidationError(`${name} must have at most ${MAX_BULK_UPLOAD_FILES} entries, got ${count}`);
1038
1148
  }
1039
1149
  }
1040
1150
  function statusSatisfies(status, waitUntil) {
@@ -1136,11 +1246,10 @@ function assignSlots(batch, result, failed) {
1136
1246
  }
1137
1247
  return assignments;
1138
1248
  }
1139
- var ManagementContextFilesResource = class {
1249
+ var ManagementContextFilesResource = class extends ContextFilesResourceBase {
1140
1250
  /** @internal */
1141
1251
  constructor(http, config) {
1142
- this.http = http;
1143
- this.config = config;
1252
+ super(http, config);
1144
1253
  }
1145
1254
  /**
1146
1255
  * Get a presigned S3 PUT URL for one file.
@@ -1212,41 +1321,6 @@ var ManagementContextFilesResource = class {
1212
1321
  })
1213
1322
  );
1214
1323
  }
1215
- /**
1216
- * Fetch one file upload by its id.
1217
- *
1218
- * @param uploadId - Upload id returned by `createUploadUrl` / `uploadFromUrl`.
1219
- * @returns The file upload resource, including its processing `status`.
1220
- */
1221
- async get(uploadId) {
1222
- validateId(uploadId, "uploadId");
1223
- return asRecord(
1224
- await invokeWithRetry(this.config, this.http, "ContextFilesController_get", {
1225
- pathParams: { uploadId }
1226
- })
1227
- );
1228
- }
1229
- /**
1230
- * List durable file uploads.
1231
- *
1232
- * @param options.pageSize - Items per page (default 50).
1233
- * @param options.pageToken - Opaque token from a previous page's `nextPageToken`.
1234
- * @returns Page of file uploads. Uploads that only have a pending row (not yet
1235
- * landed) aren't included here — use `get(uploadId)` for those.
1236
- */
1237
- list(options = {}) {
1238
- const pageSize = options.pageSize ?? DEFAULT_LIST_PAGE_SIZE;
1239
- validatePageSize(pageSize, 200);
1240
- return this.listPage(pageSize, options.pageToken);
1241
- }
1242
- async listPage(pageSize, pageToken) {
1243
- const data = asRecord(
1244
- await invokeWithRetry(this.config, this.http, "ContextFilesController_list", {
1245
- query: aipListParams(pageSize, pageToken)
1246
- })
1247
- );
1248
- return buildAipPage(data, "files", (raw) => raw, (token) => this.listPage(pageSize, token));
1249
- }
1250
1324
  /**
1251
1325
  * Turn a file already PUT to a presigned URL into durable context.
1252
1326
  *
@@ -1339,8 +1413,8 @@ var ManagementContextFilesResource = class {
1339
1413
  async upload(path, options = {}) {
1340
1414
  const waitUntil = options.waitUntil ?? "processing";
1341
1415
  validateWaitUntil(waitUntil);
1342
- const fileStat = await stat(path);
1343
- if (!fileStat.isFile()) throw new Error(`Not a file: ${path}`);
1416
+ const fileStat = await statInput(path);
1417
+ if (!fileStat.isFile()) throw new ValidationError(`Not a file: ${path}`);
1344
1418
  const fileName = path.split(/[/\\]/).pop();
1345
1419
  const slot = await this.createUploadUrl({
1346
1420
  fileName,
@@ -1402,9 +1476,9 @@ var ManagementContextFilesResource = class {
1402
1476
  const waitUntil = options.waitUntil ?? "processing";
1403
1477
  validateWaitUntil(waitUntil);
1404
1478
  const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
1405
- if (concurrency < 1) throw new Error(`concurrency must be >= 1, got ${concurrency}`);
1406
- const dirStat = await stat(path);
1407
- if (!dirStat.isDirectory()) throw new Error(`Not a directory: ${path}`);
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}`);
1408
1482
  const files = await walkFiles(path, options.recursive ?? true);
1409
1483
  return this.uploadPaths(files.map((file) => {
1410
1484
  const folderPath = relative(path, dirname(file)).replace(/\\/g, "/");
@@ -1417,7 +1491,7 @@ var ManagementContextFilesResource = class {
1417
1491
  const waitUntil = options.waitUntil ?? "processing";
1418
1492
  validateWaitUntil(waitUntil);
1419
1493
  const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
1420
- if (concurrency < 1) throw new Error(`concurrency must be >= 1, got ${concurrency}`);
1494
+ if (concurrency < 1) throw new ValidationError(`concurrency must be >= 1, got ${concurrency}`);
1421
1495
  const prefixed = files.map((file) => {
1422
1496
  const folderPath = joinDestination(options.folderPath, file.folderPath);
1423
1497
  return { path: file.path, ...folderPath !== void 0 ? { folderPath } : {} };
@@ -1630,7 +1704,7 @@ var ManagementContextItemsResource = class {
1630
1704
  * Update a context item.
1631
1705
  *
1632
1706
  * Only the fields you pass are changed. To clear a field, name it in
1633
- * `updateMask` and leave its argument unset.
1707
+ * `updateMask` and leave its argument unset: it is sent as `null`.
1634
1708
  *
1635
1709
  * @param uid - Context item uid.
1636
1710
  * @param options.content - Replacement type-specific content.
@@ -1642,19 +1716,13 @@ var ManagementContextItemsResource = class {
1642
1716
  * @returns The updated context item.
1643
1717
  */
1644
1718
  async update(uid, options = {}) {
1645
- const body = options.updateMask !== void 0 ? {
1646
- content: options.content,
1647
- contextType: options.contextType,
1648
- description: options.description,
1649
- userFeedback: options.userFeedback,
1650
- topics: options.topics
1651
- } : omitUndefined({
1719
+ const body = updateBody({
1652
1720
  content: options.content,
1653
1721
  contextType: options.contextType,
1654
1722
  description: options.description,
1655
1723
  userFeedback: options.userFeedback,
1656
1724
  topics: options.topics
1657
- });
1725
+ }, options.updateMask);
1658
1726
  await invokeWithRetry(this.config, this.http, "ContextItemsController_update", {
1659
1727
  pathParams: { uid },
1660
1728
  query: updateMaskQuery(options.updateMask),
@@ -1712,6 +1780,50 @@ var ManagementContextItemsResource = class {
1712
1780
  );
1713
1781
  return data;
1714
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
+ }
1715
1827
  };
1716
1828
 
1717
1829
  // src/management/context/context.ts
@@ -1869,22 +1981,244 @@ var ManagementContextResource = class {
1869
1981
  }
1870
1982
  };
1871
1983
 
1872
- // src/management/scopes/memories.ts
1873
- function parseMemory(raw) {
1874
- return raw;
1984
+ // src/_generated/resources/management/scopes.ts
1985
+ var ScopesResourceBase = class {
1986
+ /** @internal */
1987
+ constructor(http, config) {
1988
+ this.http = http;
1989
+ this.config = config;
1990
+ }
1991
+ /**
1992
+ * List scopes.
1993
+ *
1994
+ * Returns a paginated page of scopes the caller can at least `use`. Scopes the caller cannot see
1995
+ * are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
1996
+ *
1997
+ * **Requires:** `scopes:read`
1998
+ *
1999
+ * @param options.pageSize - Items per page. Defaults to 25.
2000
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
2001
+ * for the first page.
2002
+ * @param options.search - Case-insensitive substring filter on scope name.
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.
2006
+ * @param options.managerId - Return only scopes supervised by this manager scope id.
2007
+ * @returns A page of scopes.
2008
+ *
2009
+ * @example
2010
+ * ```ts
2011
+ * const mgmt = new ModusManagement()
2012
+ * for await (const scope of (await mgmt.scopes.list()).autoPagingIter()) {
2013
+ * console.log(scope.id, scope.name, scope.status)
2014
+ * }
2015
+ * ```
2016
+ */
2017
+ list(options = {}) {
2018
+ const pageSize = options.pageSize ?? 25;
2019
+ validatePageSize(pageSize);
2020
+ return this.listPage(pageSize, options.pageToken, options.search, options.view, options.managerId);
2021
+ }
2022
+ async listPage(pageSize, pageToken, search, view, managerId) {
2023
+ const extra = {};
2024
+ if (search !== void 0) extra.search = search;
2025
+ if (view !== void 0) extra.view = view;
2026
+ if (managerId !== void 0) extra.managerId = managerId;
2027
+ const data = asRecord(
2028
+ await invokeWithRetry(this.config, this.http, "ScopesController_list", {
2029
+ query: aipListParams(pageSize, pageToken, extra)
2030
+ })
2031
+ );
2032
+ return buildAipPage(
2033
+ data,
2034
+ "scopes",
2035
+ (raw) => raw,
2036
+ (token) => this.listPage(pageSize, token, search, view, managerId)
2037
+ );
2038
+ }
2039
+ /**
2040
+ * Get a scope.
2041
+ *
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.
2045
+ *
2046
+ * **Requires:** `scopes:read`
2047
+ *
2048
+ * @param scopeId - Numeric scope id.
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.
2051
+ *
2052
+ * @example
2053
+ * ```ts
2054
+ * const mgmt = new ModusManagement()
2055
+ * const scope = await mgmt.scopes.get('PLACEHOLDER_SCOPE_ID')
2056
+ * console.log(scope.name, scope.status)
2057
+ * ```
2058
+ */
2059
+ async get(scopeId, options = {}) {
2060
+ validateId(scopeId, "scope_id");
2061
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_get", {
2062
+ pathParams: { id: scopeId },
2063
+ query: { view: options.view }
2064
+ });
2065
+ return data;
2066
+ }
2067
+ /**
2068
+ * Delete a scope.
2069
+ *
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.
2072
+ *
2073
+ * **Requires:** `scopes:write`
2074
+ *
2075
+ * @param scopeId - Numeric scope id.
2076
+ *
2077
+ * @example
2078
+ * ```ts
2079
+ * const mgmt = new ModusManagement()
2080
+ * await mgmt.scopes.delete('PLACEHOLDER_SCOPE_ID')
2081
+ * ```
2082
+ */
2083
+ async delete(scopeId) {
2084
+ validateId(scopeId, "scope_id");
2085
+ await invokeWithRetry(this.config, this.http, "ScopesController_delete", {
2086
+ pathParams: { id: scopeId }
2087
+ });
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
+ }
2115
+ /**
2116
+ * Restore a deleted scope.
2117
+ *
2118
+ * Restores a previously deleted scope and returns it. Restoring a scope that is already active
2119
+ * returns it unchanged.
2120
+ *
2121
+ * **Requires:** `scopes:write`
2122
+ *
2123
+ * @param scopeId - Numeric scope id.
2124
+ */
2125
+ async restore(scopeId) {
2126
+ validateId(scopeId, "scope_id");
2127
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_restore", {
2128
+ pathParams: { id: scopeId },
2129
+ jsonBody: {}
2130
+ });
2131
+ return data;
2132
+ }
2133
+ /**
2134
+ * Cancel ownership transfer.
2135
+ *
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.
2138
+ *
2139
+ * **Requires:** `scopes:write`
2140
+ *
2141
+ * @param scopeId - Numeric scope id.
2142
+ */
2143
+ async cancelOwnershipTransfer(scopeId) {
2144
+ validateId(scopeId, "scope_id");
2145
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_cancelOwnershipTransfer", {
2146
+ pathParams: { id: scopeId }
2147
+ });
2148
+ return data;
2149
+ }
2150
+ /**
2151
+ * Accept ownership transfer.
2152
+ *
2153
+ * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.
2154
+ *
2155
+ * **Requires:** `scopes:write`
2156
+ *
2157
+ * @param scopeId - Numeric scope id.
2158
+ */
2159
+ async acceptOwnershipTransfer(scopeId) {
2160
+ validateId(scopeId, "scope_id");
2161
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_acceptOwnershipTransfer", {
2162
+ pathParams: { id: scopeId },
2163
+ jsonBody: {}
2164
+ });
2165
+ return data;
2166
+ }
2167
+ };
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);
1875
2200
  }
1876
- var ScopeMemoriesResource = class {
2201
+
2202
+ // src/_generated/resources/management/scopes/memories.ts
2203
+ var ScopesMemoriesResourceBase = class {
2204
+ /** @internal */
1877
2205
  constructor(http, config, scopeId) {
1878
2206
  this.http = http;
1879
2207
  this.config = config;
1880
2208
  this.scopeId = scopeId;
1881
2209
  }
1882
2210
  /**
1883
- * List memories stored for this scope.
2211
+ * List scope memories.
1884
2212
  *
1885
- * @param options.pageSize - Items per page (default 25).
1886
- * @param options.pageToken - Token from a previous page's `nextPageToken`.
1887
- * @param options.userId - Optional end-user id when memories are scoped per user.
2213
+ * Returns a page of the scope’s memories (up to 1000 total). Pass `nextPageToken` as `pageToken`
2214
+ * to fetch the next page. Optional `userId` filters to one end user.
2215
+ *
2216
+ * **Requires:** `scopes:read`
2217
+ *
2218
+ * @param options.pageSize - Items per page. Defaults to 25.
2219
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
2220
+ * for the first page.
2221
+ * @param options.userId - Narrow results to memories tagged with this end-user id.
1888
2222
  * @returns A page of memories.
1889
2223
  */
1890
2224
  list(options = {}) {
@@ -1905,15 +2239,20 @@ var ScopeMemoriesResource = class {
1905
2239
  return buildAipPage(
1906
2240
  data,
1907
2241
  "memories",
1908
- parseMemory,
2242
+ (raw) => raw,
1909
2243
  (token) => this.listPage(pageSize, token, userId)
1910
2244
  );
1911
2245
  }
1912
2246
  /**
1913
- * Search this scope's memories by natural-language query.
2247
+ * Search scope memories.
1914
2248
  *
1915
- * @param request - Query text and optional `userId` / `limit`.
1916
- * @returns Matching memories and relevance scores.
2249
+ * Returns memories ranked by semantic similarity to the supplied `query`. Caller must at least
2250
+ * `use` the scope. Optional `userId` and `limit` body fields narrow the result set (legacy parity
2251
+ * with `search-memories`).
2252
+ *
2253
+ * **Requires:** `scopes:read`
2254
+ *
2255
+ * @param request - Request body; see `MemorySearchRequest`.
1917
2256
  */
1918
2257
  async search(request) {
1919
2258
  validateId(this.scopeId, "scope_id");
@@ -1924,24 +2263,36 @@ var ScopeMemoriesResource = class {
1924
2263
  return data;
1925
2264
  }
1926
2265
  /**
1927
- * Update one memory. Requires manage permission on the scope.
2266
+ * Update a memory.
2267
+ *
2268
+ * Updates one memory. Supply at least one of `memory` or `metadata`. Use `updateMask` to limit
2269
+ * which fields change.
2270
+ *
2271
+ * **Requires:** `scopes:write`
1928
2272
  *
1929
- * @param memoryId - Id from list or search.
1930
- * @param update - Fields to change (`memory` and/or `metadata`).
1931
- * @param options.updateMask - Optional comma-separated field names to update.
1932
- * @returns The updated memory.
2273
+ * @param memoryId - Opaque memory id as returned by the list / search endpoints.
2274
+ * @param update - Request body; see `MemoryUpdate`.
2275
+ * @param options.updateMask - Comma-separated list of fields to update. Omit to update all
2276
+ * provided fields.
1933
2277
  */
1934
2278
  async update(memoryId, update, options = {}) {
1935
2279
  validateId(memoryId, "memory_id");
1936
2280
  validateId(this.scopeId, "scope_id");
1937
- const data = await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_update", {
2281
+ await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_update", {
1938
2282
  pathParams: { id: this.scopeId, memoryId },
1939
2283
  query: updateMaskQuery(options.updateMask),
1940
2284
  jsonBody: omitUndefined(update)
1941
2285
  });
1942
- return parseMemory(data);
1943
2286
  }
1944
- /** Delete one memory (idempotent). */
2287
+ /**
2288
+ * Delete a memory.
2289
+ *
2290
+ * Deletes one memory. Returns 404 if the memory does not exist or is already deleted.
2291
+ *
2292
+ * **Requires:** `scopes:write`
2293
+ *
2294
+ * @param memoryId - Opaque memory id as returned by the list / search endpoints.
2295
+ */
1945
2296
  async delete(memoryId) {
1946
2297
  validateId(memoryId, "memory_id");
1947
2298
  validateId(this.scopeId, "scope_id");
@@ -1951,32 +2302,45 @@ var ScopeMemoriesResource = class {
1951
2302
  }
1952
2303
  };
1953
2304
 
2305
+ // src/management/scopes/memories.ts
2306
+ var ScopeMemoriesResource = class extends ScopesMemoriesResourceBase {
2307
+ };
2308
+
1954
2309
  // src/management/scopes/evaluations.ts
1955
- function parseConfig(raw) {
1956
- return raw;
1957
- }
1958
- function parseRun(raw) {
1959
- return raw;
1960
- }
1961
- var ScopeEvaluationsResource = class {
2310
+ import { randomUUID } from "crypto";
2311
+
2312
+ // src/_generated/resources/management/scopes/evaluations.ts
2313
+ var ScopesEvaluationsResourceBase = class {
2314
+ /** @internal */
1962
2315
  constructor(http, config, scopeId) {
1963
2316
  this.http = http;
1964
2317
  this.config = config;
1965
2318
  this.scopeId = scopeId;
1966
2319
  }
1967
- /** Get the evaluation configuration for this scope. */
2320
+ /**
2321
+ * Get evaluation configuration.
2322
+ *
2323
+ * Returns the evaluation configuration for a scope, including judge settings, schedule cadence,
2324
+ * and notification preferences.
2325
+ *
2326
+ * **Requires:** `scopes:read`
2327
+ */
1968
2328
  async getConfig() {
1969
2329
  validateId(this.scopeId, "scope_id");
1970
2330
  const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_getConfig", {
1971
2331
  pathParams: { id: this.scopeId }
1972
2332
  });
1973
- return parseConfig(data);
2333
+ return data;
1974
2334
  }
1975
2335
  /**
1976
- * Update the evaluation configuration for this scope.
2336
+ * Update evaluation configuration.
2337
+ *
2338
+ * Updates the evaluation configuration for a scope. Changes to the schedule cadence are synced
2339
+ * automatically.
1977
2340
  *
1978
- * @param update - Configuration fields to change.
1979
- * @returns The updated evaluation configuration.
2341
+ * **Requires:** `scopes:write`
2342
+ *
2343
+ * @param update - Request body; see `UpdateEvaluationConfig`.
1980
2344
  */
1981
2345
  async updateConfig(update) {
1982
2346
  validateId(this.scopeId, "scope_id");
@@ -1984,12 +2348,17 @@ var ScopeEvaluationsResource = class {
1984
2348
  pathParams: { id: this.scopeId },
1985
2349
  jsonBody: omitUndefined(update)
1986
2350
  });
1987
- return parseConfig(data);
2351
+ return data;
1988
2352
  }
1989
2353
  /**
1990
- * Trigger a manual evaluation run for this scope.
2354
+ * Trigger evaluation run.
2355
+ *
2356
+ * Triggers a manual evaluation run for the scope. The run executes asynchronously.
2357
+ *
2358
+ * **Requires:** `scopes:write`
1991
2359
  *
1992
- * @returns The triggered run id and status.
2360
+ * @returns Evaluation run accepted and queued. The run executes asynchronously; poll `GET
2361
+ * /scopes/{id}/evaluations/runs/{runId}` for status.
1993
2362
  */
1994
2363
  async triggerRun() {
1995
2364
  validateId(this.scopeId, "scope_id");
@@ -1999,11 +2368,16 @@ var ScopeEvaluationsResource = class {
1999
2368
  return data;
2000
2369
  }
2001
2370
  /**
2002
- * List evaluation runs for this scope.
2371
+ * List evaluation runs.
2003
2372
  *
2004
- * @param options.pageSize - Items per page (default 25).
2005
- * @param options.pageToken - Token from a previous page's `nextPageToken`.
2006
- * @returns A page of evaluation runs.
2373
+ * Returns a paginated list of evaluation runs for the scope, ordered by most recent first.
2374
+ *
2375
+ * **Requires:** `scopes:read`
2376
+ *
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.
2380
+ * @returns A page of runs.
2007
2381
  */
2008
2382
  listRuns(options = {}) {
2009
2383
  const pageSize = options.pageSize ?? 25;
@@ -2018,13 +2392,21 @@ var ScopeEvaluationsResource = class {
2018
2392
  query: aipListParams(pageSize, pageToken)
2019
2393
  })
2020
2394
  );
2021
- return buildAipPage(data, "runs", parseRun, (token) => this.listRunsPage(pageSize, token));
2395
+ return buildAipPage(
2396
+ data,
2397
+ "runs",
2398
+ (raw) => raw,
2399
+ (token) => this.listRunsPage(pageSize, token)
2400
+ );
2022
2401
  }
2023
2402
  /**
2024
- * Retrieve one evaluation run with full results.
2403
+ * Get evaluation run.
2404
+ *
2405
+ * Returns details of an evaluation run including all per-case results.
2025
2406
  *
2026
- * @param runId - Evaluation run id.
2027
- * @returns The run and its result details.
2407
+ * **Requires:** `scopes:read`
2408
+ *
2409
+ * @param runId - Run ID.
2028
2410
  */
2029
2411
  async getRun(runId) {
2030
2412
  validateId(this.scopeId, "scope_id");
@@ -2036,14 +2418,94 @@ var ScopeEvaluationsResource = class {
2036
2418
  }
2037
2419
  };
2038
2420
 
2039
- // src/management/scopes/interfaces.ts
2040
- var ScopeInterfacesResource = class {
2421
+ // src/management/scopes/evaluations.ts
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
+ }
2491
+ };
2492
+
2493
+ // src/_generated/resources/management/scopes/interfaces.ts
2494
+ var ScopesInterfacesResourceBase = class {
2495
+ /** @internal */
2041
2496
  constructor(http, config, scopeId) {
2042
2497
  this.http = http;
2043
2498
  this.config = config;
2044
2499
  this.scopeId = scopeId;
2045
2500
  }
2046
- /** List the Slack and Microsoft Teams interfaces on this scope. */
2501
+ /**
2502
+ * List the chat interfaces of a scope.
2503
+ *
2504
+ * Returns the chat interfaces (at most one per chat platform) that let people use this scope from
2505
+ * chat. Requires manage permission on the scope, because the config lists allowed emails.
2506
+ *
2507
+ * **Requires:** `scopes:read`
2508
+ */
2047
2509
  async list() {
2048
2510
  validateId(this.scopeId, "scope_id");
2049
2511
  const data = await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_list", {
@@ -2051,6 +2513,27 @@ var ScopeInterfacesResource = class {
2051
2513
  });
2052
2514
  return data.interfaces;
2053
2515
  }
2516
+ /**
2517
+ * Remove a scope interface.
2518
+ *
2519
+ * Removes one chat interface from the scope. Mentions on that chat platform stop reaching this
2520
+ * scope immediately.
2521
+ *
2522
+ * **Requires:** `scopes:write`
2523
+ *
2524
+ * @param interfaceId - Interface id (UUID).
2525
+ */
2526
+ async delete(interfaceId) {
2527
+ validateId(this.scopeId, "scope_id");
2528
+ validateId(interfaceId, "interface_id");
2529
+ await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_delete", {
2530
+ pathParams: { id: this.scopeId, interfaceId }
2531
+ });
2532
+ }
2533
+ };
2534
+
2535
+ // src/management/scopes/interfaces.ts
2536
+ var ScopeInterfacesResource = class extends ScopesInterfacesResourceBase {
2054
2537
  /**
2055
2538
  * Add a Slack or Microsoft Teams interface to this scope.
2056
2539
  *
@@ -2078,70 +2561,82 @@ var ScopeInterfacesResource = class {
2078
2561
  return await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_update", {
2079
2562
  pathParams: { id: this.scopeId, interfaceId },
2080
2563
  query: updateMaskQuery(updateMask),
2081
- jsonBody: updateMask === void 0 ? omitUndefined(options) : options
2082
- });
2083
- }
2084
- /**
2085
- * Remove an interface from this scope.
2086
- *
2087
- * @param interfaceId - Interface id.
2088
- */
2089
- async delete(interfaceId) {
2090
- validateId(this.scopeId, "scope_id");
2091
- validateId(interfaceId, "interface_id");
2092
- await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_delete", {
2093
- pathParams: { id: this.scopeId, interfaceId }
2564
+ jsonBody: updateBody(options, updateMask)
2094
2565
  });
2095
2566
  }
2096
2567
  };
2097
2568
 
2098
- // src/management/scopes/supervision.ts
2099
- var ScopeSupervisionResource = class {
2569
+ // src/_generated/resources/management/scopes/supervision.ts
2570
+ var ScopesSupervisionResourceBase = class {
2571
+ /** @internal */
2100
2572
  constructor(http, config, scopeId) {
2101
2573
  this.http = http;
2102
2574
  this.config = config;
2103
2575
  this.scopeId = scopeId;
2104
2576
  }
2105
2577
  /**
2106
- * Get this scope's supervision configuration.
2578
+ * Read the scope subordinate supervision list.
2579
+ *
2580
+ * Returns the list of subordinate scope ids managed by this scope. `?view=active` (default) reads
2581
+ * the deployed supervision set; `?view=draft` reads the most recent builder snapshot. Returns 404
2582
+ * when the caller cannot at least `use` the scope.
2107
2583
  *
2108
- * @param options.view - Optional scope variation to inspect.
2109
- * @returns The supervision configuration.
2584
+ * **Requires:** `scopes:read`
2585
+ *
2586
+ * @param options.view - Which variation snapshot to read. Defaults to `active`.
2110
2587
  */
2111
2588
  async get(options = {}) {
2112
2589
  validateId(this.scopeId, "scope_id");
2113
- return await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_get", {
2590
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_get", {
2114
2591
  pathParams: { id: this.scopeId },
2115
- query: options.view === void 0 ? void 0 : { view: options.view }
2592
+ query: { view: options.view }
2116
2593
  });
2594
+ return data;
2117
2595
  }
2118
2596
  /**
2119
- * Replace this scope's subordinate scopes.
2597
+ * Replace draft subordinate supervision list.
2598
+ *
2599
+ * Writes the supplied subordinate id list into the draft variation. Replaces the previous list
2600
+ * fully — supply an empty array to clear all subordinates. Requires manage permission on the
2601
+ * supervisor; the change is not visible to runners until the scope is deployed.
2602
+ *
2603
+ * **Requires:** `scopes:write`
2120
2604
  *
2121
- * @param request - Replacement supervision configuration.
2122
- * @returns The updated supervision configuration.
2605
+ * @param request - Request body; see `SetSupervisionRequest`.
2123
2606
  */
2124
2607
  async set(request) {
2125
- return this.write("ScopeSupervisionController_set", request);
2608
+ validateId(this.scopeId, "scope_id");
2609
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_set", {
2610
+ pathParams: { id: this.scopeId },
2611
+ jsonBody: request
2612
+ });
2613
+ return data;
2126
2614
  }
2127
2615
  /**
2128
- * Replace subordinate scopes on the active (deployed) scope version.
2616
+ * Replace active subordinate supervision list.
2617
+ *
2618
+ * Writes directly into the active variation supervision set, bypassing the draft deploy cycle.
2619
+ * Requires `scopes:write` plus manage permission on the supervisor. Use to correct a live
2620
+ * supervision graph without going through the builder.
2129
2621
  *
2130
- * @param request - Replacement supervision configuration.
2131
- * @returns The updated supervision configuration.
2622
+ * **Requires:** `scopes:write`
2623
+ *
2624
+ * @param request - Request body; see `SetSupervisionRequest`.
2132
2625
  */
2133
2626
  async setActive(request) {
2134
- return this.write("ScopeSupervisionController_setActive", request);
2135
- }
2136
- async write(operation, request) {
2137
2627
  validateId(this.scopeId, "scope_id");
2138
- return await invokeWithRetry(this.config, this.http, operation, {
2628
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_setActive", {
2139
2629
  pathParams: { id: this.scopeId },
2140
2630
  jsonBody: request
2141
2631
  });
2632
+ return data;
2142
2633
  }
2143
2634
  };
2144
2635
 
2636
+ // src/management/scopes/supervision.ts
2637
+ var ScopeSupervisionResource = class extends ScopesSupervisionResourceBase {
2638
+ };
2639
+
2145
2640
  // src/management/scopes/skills.ts
2146
2641
  var MANAGEMENT_SCOPE_OPERATIONS = {
2147
2642
  list: "ScopesController_list",
@@ -2149,6 +2644,7 @@ var MANAGEMENT_SCOPE_OPERATIONS = {
2149
2644
  create: "ScopesController_create",
2150
2645
  update: "ScopesController_update",
2151
2646
  deploy: "ScopesController_deploy",
2647
+ applySelectionOps: "ScopesController_applySelectionOps",
2152
2648
  delete: "ScopesController_delete",
2153
2649
  restore: "ScopesController_restore",
2154
2650
  requestOwnershipTransfer: "ScopesController_requestOwnershipTransfer",
@@ -2157,21 +2653,12 @@ var MANAGEMENT_SCOPE_OPERATIONS = {
2157
2653
  patchMcpConfig: "ScopesController_patchMcpConfig",
2158
2654
  getVariation: "ScopesController_getVariation"
2159
2655
  };
2160
- function scopesListParams(pageSize, pageToken, search, view, managerId) {
2161
- const extra = {};
2162
- if (search !== void 0) extra.search = search;
2163
- if (view !== void 0) extra.view = view;
2164
- if (managerId !== void 0) extra.managerId = managerId;
2165
- return aipListParams(pageSize, pageToken, extra);
2166
- }
2167
2656
  function parseScope(raw) {
2168
2657
  return raw;
2169
2658
  }
2170
- var ManagementScopesResource = class {
2171
- /** @internal */
2172
- constructor(http, config) {
2173
- this.http = http;
2174
- this.config = config;
2659
+ var ManagementScopesResource = class extends ScopesResourceBase {
2660
+ constructor() {
2661
+ super(...arguments);
2175
2662
  this.ops = MANAGEMENT_SCOPE_OPERATIONS;
2176
2663
  }
2177
2664
  /**
@@ -2219,69 +2706,6 @@ var ManagementScopesResource = class {
2219
2706
  interfaces(scopeId) {
2220
2707
  return new ScopeInterfacesResource(this.http, this.config, scopeId);
2221
2708
  }
2222
- /**
2223
- * List scopes in the organization.
2224
- *
2225
- * @param options.pageSize - Maximum items per page (default 25).
2226
- * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
2227
- * @param options.search - Case-insensitive substring filter on the scope name.
2228
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
2229
- * @param options.managerId - Return only scopes supervised by this manager scope id.
2230
- * @returns A page of scopes — use `.autoPagingIter()` for all pages.
2231
- * @example
2232
- * ```ts
2233
- * const mgmt = new ModusManagement()
2234
- * for await (const scope of (await mgmt.scopes.list()).autoPagingIter()) {
2235
- * console.log(scope.id, scope.name, scope.status)
2236
- * }
2237
- * ```
2238
- */
2239
- list(options = {}) {
2240
- const pageSize = options.pageSize ?? 25;
2241
- validatePageSize(pageSize);
2242
- return this.listPage(
2243
- pageSize,
2244
- options.pageToken,
2245
- options.search,
2246
- options.view,
2247
- options.managerId
2248
- );
2249
- }
2250
- async listPage(pageSize, pageToken, search, view, managerId) {
2251
- const data = asRecord(
2252
- await invokeWithRetry(this.config, this.http, this.ops.list, {
2253
- query: scopesListParams(pageSize, pageToken, search, view, managerId)
2254
- })
2255
- );
2256
- return buildAipPage(
2257
- data,
2258
- "scopes",
2259
- parseScope,
2260
- (token) => this.listPage(pageSize, token, search, view, managerId)
2261
- );
2262
- }
2263
- /**
2264
- * Retrieve a scope with full configuration.
2265
- *
2266
- * @param scopeId - Scope id.
2267
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
2268
- * @returns The scope.
2269
- * @example
2270
- * ```ts
2271
- * const mgmt = new ModusManagement()
2272
- * const scope = await mgmt.scopes.get('PLACEHOLDER_SCOPE_ID')
2273
- * console.log(scope.name, scope.status)
2274
- * ```
2275
- */
2276
- async get(scopeId, options = {}) {
2277
- validateId(scopeId, "scope_id");
2278
- const query = options.view !== void 0 ? { view: options.view } : void 0;
2279
- const data = await invokeWithRetry(this.config, this.http, this.ops.get, {
2280
- pathParams: { id: scopeId },
2281
- query
2282
- });
2283
- return parseScope(data);
2284
- }
2285
2709
  /**
2286
2710
  * Create a new scope in the organization.
2287
2711
  *
@@ -2323,10 +2747,13 @@ var ManagementScopesResource = class {
2323
2747
  * Update a scope's configuration.
2324
2748
  *
2325
2749
  * Only the fields you pass are changed. To clear a field, name it in
2326
- * `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`.
2327
2752
  *
2328
- * @param scopeId - Scope id.
2753
+ * @param scopeId - Numeric scope id.
2329
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.
2330
2757
  * @param options.updateMask - Comma-separated field names to update or clear.
2331
2758
  * @returns The updated scope.
2332
2759
  * @example
@@ -2362,7 +2789,7 @@ var ManagementScopesResource = class {
2362
2789
  evaluations: options.evaluations,
2363
2790
  supervisionSubordinateDescriptions: options.supervisionSubordinateDescriptions
2364
2791
  };
2365
- const body = options.updateMask !== void 0 ? fields : omitUndefined(fields);
2792
+ const body = updateBody(fields, options.updateMask);
2366
2793
  const data = await invokeWithRetry(this.config, this.http, this.ops.update, {
2367
2794
  pathParams: { id: scopeId },
2368
2795
  query: updateMaskQuery(options.updateMask),
@@ -2394,39 +2821,47 @@ var ManagementScopesResource = class {
2394
2821
  return parseScope(data.scope);
2395
2822
  }
2396
2823
  /**
2397
- * Delete a scope.
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. `selectRoot`, `deselectRoot`, and `setRootDeepRules`
2828
+ * are deprecated; send `setConnectionPreferences`.
2398
2829
  *
2399
2830
  * @param scopeId - Scope id.
2400
- * @returns Resolves when the scope is deleted.
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.
2401
2835
  * @example
2402
2836
  * ```ts
2403
2837
  * const mgmt = new ModusManagement()
2404
- * await mgmt.scopes.delete('PLACEHOLDER_SCOPE_ID')
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)
2405
2844
  * ```
2406
2845
  */
2407
- async delete(scopeId) {
2408
- validateId(scopeId, "scope_id");
2409
- await invokeWithRetry(this.config, this.http, this.ops.delete, {
2410
- pathParams: { id: scopeId }
2411
- });
2412
- }
2413
- /**
2414
- * Restore a previously deleted scope.
2415
- *
2416
- * @param scopeId - Scope id.
2417
- * @returns The restored scope.
2418
- */
2419
- async restore(scopeId) {
2846
+ async applySelectionOps(scopeId, ops, options) {
2420
2847
  validateId(scopeId, "scope_id");
2421
- const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
2848
+ const data = await invokeWithRetry(this.config, this.http, this.ops.applySelectionOps, {
2422
2849
  pathParams: { id: scopeId },
2423
- jsonBody: {}
2850
+ jsonBody: omitUndefined({
2851
+ ops,
2852
+ toolset: options?.toolset,
2853
+ validateOnly: options?.validateOnly ? true : void 0
2854
+ })
2424
2855
  });
2425
2856
  return parseScope(data);
2426
2857
  }
2427
2858
  /**
2428
2859
  * Start transferring ownership of a scope to another organization member.
2429
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
+ *
2430
2865
  * @param scopeId - Scope id.
2431
2866
  * @param options.newOwnerUserId - User id of the proposed new owner.
2432
2867
  * @returns The scope with a pending ownership transfer.
@@ -2444,28 +2879,6 @@ var ManagementScopesResource = class {
2444
2879
  );
2445
2880
  return parseScope(data);
2446
2881
  }
2447
- /** Cancel a pending scope ownership transfer. */
2448
- async cancelOwnershipTransfer(scopeId) {
2449
- validateId(scopeId, "scope_id");
2450
- const data = await invokeWithRetry(
2451
- this.config,
2452
- this.http,
2453
- this.ops.cancelOwnershipTransfer,
2454
- { pathParams: { id: scopeId } }
2455
- );
2456
- return parseScope(data);
2457
- }
2458
- /** Accept a pending scope ownership transfer. */
2459
- async acceptOwnershipTransfer(scopeId) {
2460
- validateId(scopeId, "scope_id");
2461
- const data = await invokeWithRetry(
2462
- this.config,
2463
- this.http,
2464
- this.ops.acceptOwnershipTransfer,
2465
- { pathParams: { id: scopeId }, jsonBody: {} }
2466
- );
2467
- return parseScope(data);
2468
- }
2469
2882
  /**
2470
2883
  * Update MCP server configuration for a scope.
2471
2884
  *
@@ -2496,12 +2909,35 @@ var ManagementScopesResource = class {
2496
2909
  }
2497
2910
  };
2498
2911
 
2499
- // src/management/usage.ts
2500
- var ManagementUsageResource = class {
2912
+ // src/_generated/resources/management/usage.ts
2913
+ var UsageResourceBase = class {
2914
+ /** @internal */
2501
2915
  constructor(http, config) {
2502
2916
  this.http = http;
2503
2917
  this.config = config;
2504
2918
  }
2919
+ /**
2920
+ * List usage users.
2921
+ *
2922
+ * Returns the distinct acting-user emails that appear in your organization's LLM usage over the
2923
+ * `[since, until)` window. Feeds the usage page's user filter (includes non-Modus Slack/Teams
2924
+ * users). Scoped to your organization.
2925
+ *
2926
+ * **Requires:** `usage:read`
2927
+ *
2928
+ * @param options.since - ISO8601 start of the query window (inclusive).
2929
+ * @param options.until - ISO8601 end of the query window (exclusive).
2930
+ */
2931
+ async listUsers(options) {
2932
+ const data = await invokeWithRetry(this.config, this.http, "UsageController_listUsers", {
2933
+ query: { since: options.since, until: options.until }
2934
+ });
2935
+ return data;
2936
+ }
2937
+ };
2938
+
2939
+ // src/management/usage.ts
2940
+ var ManagementUsageResource = class extends UsageResourceBase {
2505
2941
  /**
2506
2942
  * List usage metrics for your organization over a time window.
2507
2943
  *
@@ -2525,42 +2961,27 @@ var ManagementUsageResource = class {
2525
2961
  const data = await invokeWithRetry(this.config, this.http, "UsageController_list", { query });
2526
2962
  return data;
2527
2963
  }
2528
- /**
2529
- * List distinct acting-user emails observed in a time window.
2530
- *
2531
- * @param options.since - Start of the window (ISO 8601, inclusive).
2532
- * @param options.until - End of the window (ISO 8601, exclusive).
2533
- * @returns User emails seen in usage during the window.
2534
- * @throws {UnprocessableError} When the request is rejected by the API.
2535
- * @throws {AuthenticationError} When the API key is invalid or missing.
2536
- */
2537
- async listUsers(options) {
2538
- const query = {
2539
- since: options.since,
2540
- until: options.until
2541
- };
2542
- const data = await invokeWithRetry(this.config, this.http, "UsageController_listUsers", {
2543
- query
2544
- });
2545
- return data;
2546
- }
2547
2964
  };
2548
2965
 
2549
- // src/management/tools.ts
2550
- function parseToolCatalogEntry(raw) {
2551
- return raw;
2552
- }
2553
- var ManagementToolsResource = class {
2966
+ // src/_generated/resources/management/tools.ts
2967
+ var ToolsResourceBase = class {
2968
+ /** @internal */
2554
2969
  constructor(http, config) {
2555
2970
  this.http = http;
2556
2971
  this.config = config;
2557
2972
  }
2558
2973
  /**
2559
- * List tool and integration surfaces a scope can select in its toolset.
2974
+ * List available tools.
2560
2975
  *
2561
- * @param options.pageSize - Maximum items per page (default 25).
2562
- * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
2563
- * @returns A page of tool catalog entries.
2976
+ * Returns a page of known tool/integration surfaces a scope can select in its toolset, with the
2977
+ * fixed actions for built-in tools.
2978
+ *
2979
+ * **Requires:** `scopes:read`
2980
+ *
2981
+ * @param options.pageSize - Items per page. Defaults to 25.
2982
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
2983
+ * for the first page.
2984
+ * @returns A page of tools.
2564
2985
  */
2565
2986
  list(options = {}) {
2566
2987
  const pageSize = options.pageSize ?? 25;
@@ -2573,10 +2994,19 @@ var ManagementToolsResource = class {
2573
2994
  query: aipListParams(pageSize, pageToken)
2574
2995
  })
2575
2996
  );
2576
- return buildAipPage(data, "tools", parseToolCatalogEntry, (token) => this.listPage(pageSize, token));
2997
+ return buildAipPage(
2998
+ data,
2999
+ "tools",
3000
+ (raw) => raw,
3001
+ (token) => this.listPage(pageSize, token)
3002
+ );
2577
3003
  }
2578
3004
  };
2579
3005
 
3006
+ // src/management/tools.ts
3007
+ var ManagementToolsResource = class extends ToolsResourceBase {
3008
+ };
3009
+
2580
3010
  // src/management/users.ts
2581
3011
  var ManagementUsersResource = class {
2582
3012
  constructor(http, config) {