@getmodus/sdk 0.7.0 → 0.9.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.
@@ -10,7 +10,141 @@ import {
10
10
  omitUndefined,
11
11
  validateId,
12
12
  validatePageSize
13
- } from "../chunk-JMFT5KO5.js";
13
+ } from "../chunk-SP4UYRYG.js";
14
+
15
+ // src/_generated/resources/management/workflows.ts
16
+ var WorkflowsResourceBase = class {
17
+ /** @internal */
18
+ constructor(http, config) {
19
+ this.http = http;
20
+ this.config = config;
21
+ }
22
+ /**
23
+ * List workflows.
24
+ *
25
+ * Returns a paginated page of workflows the caller can at least `use`. Workflows the caller
26
+ * cannot see are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
27
+ *
28
+ * **Requires:** `workflows:read`
29
+ *
30
+ * @param options.pageSize - Items per page. Defaults to 25.
31
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
32
+ * for the first page.
33
+ * @param options.search - Case-insensitive substring filter on workflow name.
34
+ * @param options.type - Filter by workflow type.
35
+ * @param options.view - Variation view. `active` reads deployed; `draft` reads the latest builder
36
+ * snapshot.
37
+ * @param options.includeVariation - Include the requested variation payload (`trigger`,
38
+ * `workflowStructure`, `agentSelection`) on list rows.
39
+ * @returns A page of workflows.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const mgmt = new ModusManagement()
44
+ * for await (const wf of (await mgmt.workflows.list({ search: 'digest' })).autoPagingIter()) {
45
+ * console.log(wf.id, wf.name, wf.status)
46
+ * }
47
+ * ```
48
+ */
49
+ list(options = {}) {
50
+ const pageSize = options.pageSize ?? 25;
51
+ validatePageSize(pageSize);
52
+ return this.listPage(pageSize, options.pageToken, options.search, options.type, options.view, options.includeVariation);
53
+ }
54
+ async listPage(pageSize, pageToken, search, type, view, includeVariation) {
55
+ const extra = {};
56
+ if (search !== void 0) extra.search = search;
57
+ if (type !== void 0) extra.type = type;
58
+ if (view !== void 0) extra.view = view;
59
+ if (includeVariation !== void 0) extra.includeVariation = includeVariation;
60
+ const data = asRecord(
61
+ await invokeWithRetry(this.config, this.http, "WorkflowsController_list", {
62
+ query: aipListParams(pageSize, pageToken, extra)
63
+ })
64
+ );
65
+ return buildAipPage(
66
+ data,
67
+ "workflows",
68
+ (raw) => raw,
69
+ (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
70
+ );
71
+ }
72
+ /**
73
+ * Delete a workflow.
74
+ *
75
+ * Deletes a workflow and stops its schedule. The workflow can be restored later with POST
76
+ * /workflows/{id}/restore. Deleting an already-deleted workflow is a no-op.
77
+ *
78
+ * **Requires:** `workflows:write`
79
+ *
80
+ * @param workflowId - Numeric workflow id.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * const mgmt = new ModusManagement()
85
+ * await mgmt.workflows.delete('PLACEHOLDER_WORKFLOW_ID')
86
+ * ```
87
+ */
88
+ async delete(workflowId) {
89
+ validateId(workflowId, "workflow_id");
90
+ await invokeWithRetry(this.config, this.http, "WorkflowsController_delete", {
91
+ pathParams: { id: workflowId }
92
+ });
93
+ }
94
+ /**
95
+ * Restore a deleted workflow.
96
+ *
97
+ * Restores a previously deleted workflow and returns it. The workflow’s schedule is not resumed
98
+ * automatically — re-enable it if it should run again. Restoring an active workflow returns it
99
+ * unchanged.
100
+ *
101
+ * **Requires:** `workflows:write`
102
+ *
103
+ * @param workflowId - Numeric workflow id.
104
+ */
105
+ async restore(workflowId) {
106
+ validateId(workflowId, "workflow_id");
107
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_restore", {
108
+ pathParams: { id: workflowId },
109
+ jsonBody: {}
110
+ });
111
+ return data;
112
+ }
113
+ /**
114
+ * Cancel ownership transfer.
115
+ *
116
+ * Cancels a pending ownership transfer. The current owner may cancel; the pending recipient may
117
+ * decline.
118
+ *
119
+ * **Requires:** `workflows:write`
120
+ *
121
+ * @param workflowId - Numeric workflow id.
122
+ */
123
+ async cancelOwnershipTransfer(workflowId) {
124
+ validateId(workflowId, "workflow_id");
125
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_cancelOwnershipTransfer", {
126
+ pathParams: { id: workflowId }
127
+ });
128
+ return data;
129
+ }
130
+ /**
131
+ * Accept ownership transfer.
132
+ *
133
+ * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.
134
+ *
135
+ * **Requires:** `workflows:write`
136
+ *
137
+ * @param workflowId - Numeric workflow id.
138
+ */
139
+ async acceptOwnershipTransfer(workflowId) {
140
+ validateId(workflowId, "workflow_id");
141
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_acceptOwnershipTransfer", {
142
+ pathParams: { id: workflowId },
143
+ jsonBody: {}
144
+ });
145
+ return data;
146
+ }
147
+ };
14
148
 
15
149
  // src/_query.ts
16
150
  function updateMaskQuery(updateMask) {
@@ -54,14 +188,22 @@ async function accessConfigBodyForUpdate(guardrails, loadResource) {
54
188
  return accessConfigWireForUpdate(existing, guardrails);
55
189
  }
56
190
 
57
- // src/management/workflows/interfaces.ts
58
- var WorkflowInterfacesResource = class {
191
+ // src/_generated/resources/management/workflows/interfaces.ts
192
+ var WorkflowsInterfacesResourceBase = class {
193
+ /** @internal */
59
194
  constructor(http, config, workflowId) {
60
195
  this.http = http;
61
196
  this.config = config;
62
197
  this.workflowId = workflowId;
63
198
  }
64
- /** List interfaces attached to this workflow. */
199
+ /**
200
+ * List interfaces attached to a workflow.
201
+ *
202
+ * Returns every Slack, MCP, or Teams interface bound to the workflow. Requires manage permission
203
+ * on the workflow.
204
+ *
205
+ * **Requires:** `workflows:read`
206
+ */
65
207
  async list() {
66
208
  validateId(this.workflowId, "workflow_id");
67
209
  const data = await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_list", {
@@ -69,6 +211,40 @@ var WorkflowInterfacesResource = class {
69
211
  });
70
212
  return data.interfaces;
71
213
  }
214
+ /**
215
+ * Remove every interface from a workflow.
216
+ *
217
+ * Deletes all interface rows attached to the workflow. Useful when recreating the interface set
218
+ * from scratch.
219
+ *
220
+ * **Requires:** `workflows:write`
221
+ */
222
+ async deleteAll() {
223
+ validateId(this.workflowId, "workflow_id");
224
+ await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_deleteAll", {
225
+ pathParams: { id: this.workflowId }
226
+ });
227
+ }
228
+ /**
229
+ * Remove a workflow interface.
230
+ *
231
+ * Deletes one interface row. For MCP interfaces, bound MCP tokens are revoked best-effort.
232
+ *
233
+ * **Requires:** `workflows:write`
234
+ *
235
+ * @param interfaceId - Interface row id (UUID).
236
+ */
237
+ async delete(interfaceId) {
238
+ validateId(this.workflowId, "workflow_id");
239
+ validateId(interfaceId, "interface_id");
240
+ await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_delete", {
241
+ pathParams: { id: this.workflowId, interfaceId }
242
+ });
243
+ }
244
+ };
245
+
246
+ // src/management/workflows/interfaces.ts
247
+ var WorkflowInterfacesResource = class extends WorkflowsInterfacesResourceBase {
72
248
  /**
73
249
  * Add an interface to this workflow.
74
250
  *
@@ -99,25 +275,6 @@ var WorkflowInterfacesResource = class {
99
275
  jsonBody: updateMask === void 0 ? omitUndefined(options) : options
100
276
  });
101
277
  }
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 }
119
- });
120
- }
121
278
  };
122
279
 
123
280
  // src/management/workflows/agents.ts
@@ -134,66 +291,14 @@ var MANAGEMENT_WORKFLOW_OPERATIONS = {
134
291
  acceptOwnershipTransfer: "WorkflowsController_acceptOwnershipTransfer",
135
292
  toggle: "WorkflowsController_toggle"
136
293
  };
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
294
  function parseWorkflow(raw) {
146
295
  return raw;
147
296
  }
148
- var ManagementWorkflowsResource = class {
149
- constructor(http, config) {
150
- this.http = http;
151
- this.config = config;
297
+ var ManagementWorkflowsResource = class extends WorkflowsResourceBase {
298
+ constructor() {
299
+ super(...arguments);
152
300
  this.ops = MANAGEMENT_WORKFLOW_OPERATIONS;
153
301
  }
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
302
  /**
198
303
  * Retrieve a workflow with full configuration.
199
304
  *
@@ -334,37 +439,6 @@ var ManagementWorkflowsResource = class {
334
439
  });
335
440
  return parseWorkflow(data);
336
441
  }
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
442
  /**
369
443
  * Start transferring ownership of a workflow to another organization member.
370
444
  *
@@ -385,28 +459,6 @@ var ManagementWorkflowsResource = class {
385
459
  );
386
460
  return parseWorkflow(data);
387
461
  }
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
462
  };
411
463
 
412
464
  // src/types/context.ts
@@ -497,8 +549,174 @@ async function resolveAndUpdateLink(items, uid, options) {
497
549
  });
498
550
  }
499
551
 
500
- // src/management/context/dashboards.ts
501
- var ManagementDashboardElementsResource = class {
552
+ // src/_generated/resources/management/context/dashboards.ts
553
+ var ContextDashboardsResourceBase = class {
554
+ /** @internal */
555
+ constructor(http, config) {
556
+ this.http = http;
557
+ this.config = config;
558
+ }
559
+ /**
560
+ * Delete a dashboard.
561
+ *
562
+ * Removes the dashboard from every listing and deletes its alert workflows. It cannot be restored
563
+ * through the API.
564
+ *
565
+ * **Requires:** `context:write`
566
+ *
567
+ * @param dashboardId - Dashboard id, as shown in the app URL.
568
+ *
569
+ * @example
570
+ * ```ts
571
+ * await mgmt.context.dashboards.delete('DASHBOARD_ID')
572
+ * ```
573
+ */
574
+ async delete(dashboardId) {
575
+ validateId(dashboardId, "dashboardId");
576
+ await invokeWithRetry(this.config, this.http, "DashboardsController_delete", {
577
+ pathParams: { dashboardId }
578
+ });
579
+ }
580
+ /**
581
+ * List dashboard draft snapshots.
582
+ *
583
+ * Returns ids and timestamps of the most recent draft snapshots. Editors only.
584
+ *
585
+ * **Requires:** `context:read`
586
+ *
587
+ * @param dashboardId - Dashboard id, as shown in the app URL.
588
+ *
589
+ * @example
590
+ * ```ts
591
+ * const snapshots = await mgmt.context.dashboards.listDraftSnapshots('DASHBOARD_ID')
592
+ * snapshots.map((snapshot) => snapshot.uid)
593
+ * ```
594
+ */
595
+ async listDraftSnapshots(dashboardId) {
596
+ validateId(dashboardId, "dashboardId");
597
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listDraftSnapshots", {
598
+ pathParams: { dashboardId }
599
+ });
600
+ return asRecord(data).snapshots;
601
+ }
602
+ /**
603
+ * Cancel an ownership transfer.
604
+ *
605
+ * Owner only. Clears the pending transfer and returns the dashboard.
606
+ *
607
+ * **Requires:** `context:write`
608
+ *
609
+ * @param dashboardId - Dashboard id, as shown in the app URL.
610
+ *
611
+ * @example
612
+ * ```ts
613
+ * await mgmt.context.dashboards.cancelOwnershipTransfer('DASHBOARD_ID')
614
+ * ```
615
+ */
616
+ async cancelOwnershipTransfer(dashboardId) {
617
+ validateId(dashboardId, "dashboardId");
618
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_cancelOwnership", {
619
+ pathParams: { dashboardId }
620
+ });
621
+ return asRecord(data);
622
+ }
623
+ /**
624
+ * Accept an ownership transfer.
625
+ *
626
+ * Recipient only. Makes you the owner and clears the pending transfer.
627
+ *
628
+ * **Requires:** `context:write`
629
+ *
630
+ * @param dashboardId - Dashboard id, as shown in the app URL.
631
+ *
632
+ * @example
633
+ * ```ts
634
+ * await mgmt.context.dashboards.acceptOwnershipTransfer('DASHBOARD_ID')
635
+ * ```
636
+ */
637
+ async acceptOwnershipTransfer(dashboardId) {
638
+ validateId(dashboardId, "dashboardId");
639
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_acceptOwnership", {
640
+ pathParams: { dashboardId }
641
+ });
642
+ return asRecord(data);
643
+ }
644
+ /**
645
+ * List dashboard versions.
646
+ *
647
+ * Returns the published versions, newest first, each with its full definition. Draft snapshots
648
+ * are not included. The response is not paginated and can be large.
649
+ *
650
+ * **Requires:** `context:read`
651
+ *
652
+ * @param dashboardId - Dashboard id, as shown in the app URL.
653
+ *
654
+ * @example
655
+ * ```ts
656
+ * const versions = await mgmt.context.dashboards.listVersions('DASHBOARD_ID')
657
+ * versions.map((version) => [version.uid, version.versionNumber])
658
+ * ```
659
+ */
660
+ async listVersions(dashboardId) {
661
+ validateId(dashboardId, "dashboardId");
662
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listVersions", {
663
+ pathParams: { dashboardId }
664
+ });
665
+ return asRecord(data).versions;
666
+ }
667
+ /**
668
+ * Get a dashboard version.
669
+ *
670
+ * Returns the dashboard as it was in the given version. For a draft snapshot (editors only) the
671
+ * view is reported as active and selectedVersion.versionNumber is null.
672
+ *
673
+ * **Requires:** `context:read`
674
+ *
675
+ * @param dashboardId - Dashboard id, as shown in the app URL.
676
+ * @param versionId - Version id, or a draft snapshot id for editors.
677
+ *
678
+ * @example
679
+ * ```ts
680
+ * const old = await mgmt.context.dashboards.getVersion('DASHBOARD_ID', 'VERSION_ID')
681
+ * old.selectedVersion.versionNumber
682
+ * ```
683
+ */
684
+ async getVersion(dashboardId, versionId) {
685
+ validateId(dashboardId, "dashboardId");
686
+ validateId(versionId, "versionId");
687
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_getVersion", {
688
+ pathParams: { dashboardId, versionId }
689
+ });
690
+ return asRecord(data);
691
+ }
692
+ /**
693
+ * Restore a dashboard version.
694
+ *
695
+ * Replaces the current draft with the content of the given version. The outgoing draft is kept as
696
+ * a draft snapshot. Returns the draft view.
697
+ *
698
+ * **Requires:** `context:write`
699
+ *
700
+ * @param dashboardId - Dashboard id, as shown in the app URL.
701
+ * @param versionId - Version id, or a draft snapshot id for editors.
702
+ *
703
+ * @example
704
+ * ```ts
705
+ * await mgmt.context.dashboards.restoreVersion('DASHBOARD_ID', 'VERSION_ID')
706
+ * ```
707
+ */
708
+ async restoreVersion(dashboardId, versionId) {
709
+ validateId(dashboardId, "dashboardId");
710
+ validateId(versionId, "versionId");
711
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_restore", {
712
+ pathParams: { dashboardId, versionId }
713
+ });
714
+ return asRecord(data);
715
+ }
716
+ };
717
+
718
+ // src/_generated/resources/management/context/dashboards/elements.ts
719
+ var ContextDashboardsElementsResourceBase = class {
502
720
  /** @internal */
503
721
  constructor(http, config, dashboardId) {
504
722
  this.http = http;
@@ -506,11 +724,14 @@ var ManagementDashboardElementsResource = class {
506
724
  this.dashboardId = dashboardId;
507
725
  }
508
726
  /**
509
- * List every tile and filter on the dashboard draft.
727
+ * List dashboard elements.
728
+ *
729
+ * Lists every tile and filter on the dashboard draft with id, kind, title and layout. Filters
730
+ * also carry sqlReferences, the exact templates tile SQL must use to reference them. Returns the
731
+ * current draftRevision.
732
+ *
733
+ * **Requires:** `context:read`
510
734
  *
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
735
  * @example
515
736
  * ```ts
516
737
  * const listed = await mgmt.context.dashboards.elements('DASHBOARD_ID').list()
@@ -518,19 +739,21 @@ var ManagementDashboardElementsResource = class {
518
739
  * ```
519
740
  */
520
741
  async list() {
521
- return asRecord(
522
- await invokeWithRetry(this.config, this.http, "DashboardsController_listElements", {
523
- pathParams: { dashboardId: this.dashboardId }
524
- })
525
- );
742
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listElements", {
743
+ pathParams: { dashboardId: this.dashboardId }
744
+ });
745
+ return asRecord(data);
526
746
  }
527
747
  /**
528
- * Get the full draft settings of one tile or filter.
748
+ * Get a dashboard element.
749
+ *
750
+ * Returns the full draft configuration of one dashboard element, including SQL, chart settings
751
+ * and filter options, with the current draftRevision.
752
+ *
753
+ * **Requires:** `context:read`
754
+ *
755
+ * @param elementId - The dashboard element id to read.
529
756
  *
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
757
  * @example
535
758
  * ```ts
536
759
  * const result = await mgmt.context.dashboards.elements('DASHBOARD_ID').get('ELEMENT_ID')
@@ -539,11 +762,18 @@ var ManagementDashboardElementsResource = class {
539
762
  */
540
763
  async get(elementId) {
541
764
  validateId(elementId, "elementId");
542
- return asRecord(
543
- await invokeWithRetry(this.config, this.http, "DashboardsController_getElement", {
544
- pathParams: { dashboardId: this.dashboardId, elementId }
545
- })
546
- );
765
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_getElement", {
766
+ pathParams: { dashboardId: this.dashboardId, elementId }
767
+ });
768
+ return asRecord(data);
769
+ }
770
+ };
771
+
772
+ // src/management/context/dashboards.ts
773
+ var ManagementDashboardElementsResource = class extends ContextDashboardsElementsResourceBase {
774
+ /** @internal */
775
+ constructor(http, config, dashboardId) {
776
+ super(http, config, dashboardId);
547
777
  }
548
778
  /**
549
779
  * Add a blank tile or filter to the dashboard draft.
@@ -608,11 +838,10 @@ var ManagementDashboardElementsResource = class {
608
838
  );
609
839
  }
610
840
  };
611
- var ManagementDashboardsResource = class {
841
+ var ManagementDashboardsResource = class extends ContextDashboardsResourceBase {
612
842
  /** @internal */
613
843
  constructor(http, config) {
614
- this.http = http;
615
- this.config = config;
844
+ super(http, config);
616
845
  }
617
846
  /**
618
847
  * List dashboards with their full definitions.
@@ -731,138 +960,27 @@ var ManagementDashboardsResource = class {
731
960
  /**
732
961
  * Publish the draft as a new version that everyone with access sees.
733
962
  *
734
- * Alert workflows defined on the dashboard are updated to match.
735
- *
736
- * @param dashboardId - Id of the dashboard.
737
- * @param input.expectedRevision - The `draftRevision` you reviewed and want to publish.
738
- * @returns The published `dashboard` and the new `version`.
739
- * @throws ConflictError - The draft changed since `expectedRevision`.
740
- * @throws NotFoundError - The dashboard does not exist or you cannot edit it.
741
- * @example
742
- * ```ts
743
- * const result = await mgmt.context.dashboards.publish('DASHBOARD_ID', { expectedRevision: 4 })
744
- * result.version.versionNumber
745
- * ```
746
- */
747
- async publish(dashboardId, input) {
748
- validateId(dashboardId, "dashboardId");
749
- return asRecord(
750
- await invokeWithRetry(this.config, this.http, "DashboardsController_publish", {
751
- pathParams: { dashboardId },
752
- jsonBody: { expectedRevision: input.expectedRevision }
753
- })
754
- );
755
- }
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
- *
963
+ * Alert workflows defined on the dashboard are updated to match.
964
+ *
848
965
  * @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.
966
+ * @param input.expectedRevision - The `draftRevision` you reviewed and want to publish.
967
+ * @returns The published `dashboard` and the new `version`.
968
+ * @throws ConflictError - The draft changed since `expectedRevision`.
851
969
  * @throws NotFoundError - The dashboard does not exist or you cannot edit it.
852
970
  * @example
853
971
  * ```ts
854
- * const snapshots = await mgmt.context.dashboards.listDraftSnapshots('DASHBOARD_ID')
855
- * snapshots.map((snapshot) => snapshot.uid)
972
+ * const result = await mgmt.context.dashboards.publish('DASHBOARD_ID', { expectedRevision: 4 })
973
+ * result.version.versionNumber
856
974
  * ```
857
975
  */
858
- async listDraftSnapshots(dashboardId) {
976
+ async publish(dashboardId, input) {
859
977
  validateId(dashboardId, "dashboardId");
860
- const data = asRecord(
861
- await invokeWithRetry(this.config, this.http, "DashboardsController_listDraftSnapshots", {
862
- pathParams: { dashboardId }
978
+ return asRecord(
979
+ await invokeWithRetry(this.config, this.http, "DashboardsController_publish", {
980
+ pathParams: { dashboardId },
981
+ jsonBody: { expectedRevision: input.expectedRevision }
863
982
  })
864
983
  );
865
- return data.snapshots;
866
984
  }
867
985
  /**
868
986
  * Replace who can open and edit a dashboard.
@@ -928,50 +1046,6 @@ var ManagementDashboardsResource = class {
928
1046
  })
929
1047
  );
930
1048
  }
931
- /**
932
- * Accept a pending ownership transfer and become the dashboard owner.
933
- *
934
- * Only the requested recipient can accept.
935
- *
936
- * @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.
940
- * @example
941
- * ```ts
942
- * await mgmt.context.dashboards.acceptOwnershipTransfer('DASHBOARD_ID')
943
- * ```
944
- */
945
- async acceptOwnershipTransfer(dashboardId) {
946
- validateId(dashboardId, "dashboardId");
947
- return asRecord(
948
- await invokeWithRetry(this.config, this.http, "DashboardsController_acceptOwnership", {
949
- pathParams: { dashboardId }
950
- })
951
- );
952
- }
953
- /**
954
- * Cancel a pending ownership transfer.
955
- *
956
- * Only the owner can cancel.
957
- *
958
- * @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.
962
- * @example
963
- * ```ts
964
- * await mgmt.context.dashboards.cancelOwnershipTransfer('DASHBOARD_ID')
965
- * ```
966
- */
967
- async cancelOwnershipTransfer(dashboardId) {
968
- validateId(dashboardId, "dashboardId");
969
- return asRecord(
970
- await invokeWithRetry(this.config, this.http, "DashboardsController_cancelOwnership", {
971
- pathParams: { dashboardId }
972
- })
973
- );
974
- }
975
1049
  /**
976
1050
  * Work with the tiles and filters of one dashboard draft.
977
1051
  *
@@ -1017,8 +1091,66 @@ var ManagementDashboardsResource = class {
1017
1091
  // src/management/context/files.ts
1018
1092
  import { readdir, readFile, stat } from "fs/promises";
1019
1093
  import { dirname, join, relative } from "path";
1094
+
1095
+ // src/_generated/resources/management/context/files.ts
1096
+ var ContextFilesResourceBase = class {
1097
+ /** @internal */
1098
+ constructor(http, config) {
1099
+ this.http = http;
1100
+ this.config = config;
1101
+ }
1102
+ /**
1103
+ * List file uploads.
1104
+ *
1105
+ * Returns a page of durable landed file uploads. Uploads that have not landed yet are visible via
1106
+ * `GET /context/files/{uploadId}`, not this list.
1107
+ *
1108
+ * **Requires:** `context:read`
1109
+ *
1110
+ * @param options.pageSize - Items per page. Defaults to 50.
1111
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
1112
+ * for the first page.
1113
+ * @returns A page of files.
1114
+ */
1115
+ list(options = {}) {
1116
+ const pageSize = options.pageSize ?? 50;
1117
+ validatePageSize(pageSize, 200);
1118
+ return this.listPage(pageSize, options.pageToken);
1119
+ }
1120
+ async listPage(pageSize, pageToken) {
1121
+ const data = asRecord(
1122
+ await invokeWithRetry(this.config, this.http, "ContextFilesController_list", {
1123
+ query: aipListParams(pageSize, pageToken)
1124
+ })
1125
+ );
1126
+ return buildAipPage(
1127
+ data,
1128
+ "files",
1129
+ (raw) => raw,
1130
+ (token) => this.listPage(pageSize, token)
1131
+ );
1132
+ }
1133
+ /**
1134
+ * Get a file upload.
1135
+ *
1136
+ * Returns status + metadata for one upload. Prefers the durable landed context item; falls back
1137
+ * to in-flight upload status while the object has not landed yet. 404 if neither exists.
1138
+ *
1139
+ * **Requires:** `context:read`
1140
+ *
1141
+ * @param uploadId - Upload id returned by `createUploadUrl` / `createUploadUrls`.
1142
+ */
1143
+ async get(uploadId) {
1144
+ validateId(uploadId, "uploadId");
1145
+ const data = await invokeWithRetry(this.config, this.http, "ContextFilesController_get", {
1146
+ pathParams: { uploadId }
1147
+ });
1148
+ return asRecord(data);
1149
+ }
1150
+ };
1151
+
1152
+ // src/management/context/files.ts
1020
1153
  var MAX_BULK_UPLOAD_FILES = 100;
1021
- var DEFAULT_LIST_PAGE_SIZE = 50;
1022
1154
  var DEFAULT_PUT_TIMEOUT_MS = 6e4;
1023
1155
  var DEFAULT_POLL_INTERVAL_MS = 500;
1024
1156
  var DEFAULT_UPLOAD_TIMEOUT_MS = 12e4;
@@ -1049,6 +1181,12 @@ function chunked(items, size) {
1049
1181
  for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
1050
1182
  return out;
1051
1183
  }
1184
+ function joinDestination(prefix, relative2) {
1185
+ const head = prefix === void 0 || prefix.length === 0 ? void 0 : prefix;
1186
+ const tail = relative2 === void 0 || relative2.length === 0 ? void 0 : relative2;
1187
+ if (head !== void 0 && tail !== void 0) return `${head}/${tail}`;
1188
+ return head ?? tail;
1189
+ }
1052
1190
  async function mapWithConcurrency(items, concurrency, worker, onItemDone) {
1053
1191
  const results = new Array(items.length);
1054
1192
  let cursor = 0;
@@ -1082,11 +1220,11 @@ async function walkFiles(root, recursive) {
1082
1220
  await walk(root);
1083
1221
  return out;
1084
1222
  }
1085
- async function putBytes(fetchImpl, url, data, contentType, timeoutMs) {
1086
- const response = await fetchImpl(url, {
1223
+ async function putBytes(fetchImpl, slot, data, timeoutMs) {
1224
+ const response = await fetchImpl(slot.uploadUrl, {
1087
1225
  method: "PUT",
1088
1226
  body: data,
1089
- headers: { "Content-Type": contentType },
1227
+ headers: { "Content-Type": slot.contentType, ...slot.headers },
1090
1228
  signal: AbortSignal.timeout(timeoutMs)
1091
1229
  });
1092
1230
  if (!response.ok) {
@@ -1130,11 +1268,10 @@ function assignSlots(batch, result, failed) {
1130
1268
  }
1131
1269
  return assignments;
1132
1270
  }
1133
- var ManagementContextFilesResource = class {
1271
+ var ManagementContextFilesResource = class extends ContextFilesResourceBase {
1134
1272
  /** @internal */
1135
1273
  constructor(http, config) {
1136
- this.http = http;
1137
- this.config = config;
1274
+ super(http, config);
1138
1275
  }
1139
1276
  /**
1140
1277
  * Get a presigned S3 PUT URL for one file.
@@ -1144,7 +1281,7 @@ var ManagementContextFilesResource = class {
1144
1281
  * Office/OpenDocument documents, audio, and video.
1145
1282
  * @param input.fileSize - File size in bytes. Rejected above 50MB.
1146
1283
  * @returns Presigned upload slot. PUT the raw bytes to `uploadUrl` within 15
1147
- * minutes, then call `finalize(slot.uploadId, slot.fileName)`. Pass the
1284
+ * minutes, sending `headers` unchanged, then call `finalize(slot.uploadId, slot.fileName)`. Pass the
1148
1285
  * slot's own `fileName` rather than your local basename — the server may
1149
1286
  * sanitize the requested name when it mints the key, and finalization
1150
1287
  * re-derives the key from `uploadId` and `fileName`.
@@ -1177,6 +1314,7 @@ var ManagementContextFilesResource = class {
1177
1314
  * @param url - Source URL to fetch (SSRF-guarded, 50MB cap, same MIME
1178
1315
  * allow-list as `createUploadUrl`).
1179
1316
  * @param options.fileName - Override file name. Inferred from the URL path when omitted.
1317
+ * @param options.folderPath - Root-relative folder to upload under.
1180
1318
  * @returns File upload resource with status `processing` — parsing continues async.
1181
1319
  */
1182
1320
  async uploadFromUrl(url, options = {}) {
@@ -1205,41 +1343,6 @@ var ManagementContextFilesResource = class {
1205
1343
  })
1206
1344
  );
1207
1345
  }
1208
- /**
1209
- * Fetch one file upload by its id.
1210
- *
1211
- * @param uploadId - Upload id returned by `createUploadUrl` / `uploadFromUrl`.
1212
- * @returns The file upload resource, including its processing `status`.
1213
- */
1214
- async get(uploadId) {
1215
- validateId(uploadId, "uploadId");
1216
- return asRecord(
1217
- await invokeWithRetry(this.config, this.http, "ContextFilesController_get", {
1218
- pathParams: { uploadId }
1219
- })
1220
- );
1221
- }
1222
- /**
1223
- * List durable file uploads.
1224
- *
1225
- * @param options.pageSize - Items per page (default 50).
1226
- * @param options.pageToken - Opaque token from a previous page's `nextPageToken`.
1227
- * @returns Page of file uploads. Uploads that only have a pending row (not yet
1228
- * landed) aren't included here — use `get(uploadId)` for those.
1229
- */
1230
- list(options = {}) {
1231
- const pageSize = options.pageSize ?? DEFAULT_LIST_PAGE_SIZE;
1232
- validatePageSize(pageSize, 200);
1233
- return this.listPage(pageSize, options.pageToken);
1234
- }
1235
- async listPage(pageSize, pageToken) {
1236
- const data = asRecord(
1237
- await invokeWithRetry(this.config, this.http, "ContextFilesController_list", {
1238
- query: aipListParams(pageSize, pageToken)
1239
- })
1240
- );
1241
- return buildAipPage(data, "files", (raw) => raw, (token) => this.listPage(pageSize, token));
1242
- }
1243
1346
  /**
1244
1347
  * Turn a file already PUT to a presigned URL into durable context.
1245
1348
  *
@@ -1294,6 +1397,16 @@ var ManagementContextFilesResource = class {
1294
1397
  * @param options.concurrency - Max concurrent PUTs (default 10).
1295
1398
  * @param options.waitUntil - `"processing"` (default) or `"ready"`.
1296
1399
  * @param options.onProgress - Optional progress callback after each file.
1400
+ * @param options.folderPath - Root-relative folder to upload under. Nested
1401
+ * files keep their existing relative folder labels under this prefix.
1402
+ * @example
1403
+ * ```ts
1404
+ * const mgmt = new ModusManagement()
1405
+ * const result = await mgmt.context.files.uploadFiles(
1406
+ * ['./q3.pdf', './notes.md'],
1407
+ * { folderPath: 'reports/2026' },
1408
+ * )
1409
+ * ```
1297
1410
  */
1298
1411
  async uploadFiles(paths, options = {}) {
1299
1412
  return this.uploadPaths(paths.map((input) => typeof input === "string" ? { path: input } : input), options);
@@ -1301,16 +1414,23 @@ var ManagementContextFilesResource = class {
1301
1414
  /**
1302
1415
  * Upload a local file and wait for it to reach `"processing"` or `"ready"`.
1303
1416
  *
1304
- * Gets a presigned URL, PUTs the file bytes, then polls `get()` until the
1305
- * upload leaves `"pending"` (or reaches `"ready"`/`"failed"`).
1417
+ * Gets a presigned URL, PUTs the file bytes, then polls `get()`
1418
+ * until the upload leaves `"pending"` (or reaches `"ready"`/`"failed"`).
1306
1419
  *
1307
1420
  * @param path - Path to a local file.
1308
1421
  * @param options.waitUntil - `"processing"` (parsing started, default) or
1309
1422
  * `"ready"` (parsing finished).
1310
1423
  * @param options.pollIntervalMs - Milliseconds between status polls.
1311
1424
  * @param options.timeoutMs - Max milliseconds to wait before raising.
1425
+ * @param options.folderPath - Root-relative folder to upload under. Example:
1426
+ * `{ folderPath: 'reports/2026' }` places `./report.pdf` at `reports/2026`.
1312
1427
  * @returns The file upload resource once it reaches `waitUntil` (or `"failed"`).
1313
1428
  * @throws {ModusError} If the PUT fails, or polling times out.
1429
+ * @example
1430
+ * ```ts
1431
+ * const mgmt = new ModusManagement()
1432
+ * const file = await mgmt.context.files.upload('./report.pdf', { folderPath: 'reports/2026' })
1433
+ * ```
1314
1434
  */
1315
1435
  async upload(path, options = {}) {
1316
1436
  const waitUntil = options.waitUntil ?? "processing";
@@ -1324,8 +1444,10 @@ var ManagementContextFilesResource = class {
1324
1444
  fileSize: fileStat.size
1325
1445
  });
1326
1446
  const data = await readFile(path);
1327
- await putBytes(this.config.fetch, slot.uploadUrl, data, slot.contentType, DEFAULT_PUT_TIMEOUT_MS);
1328
- const finalized = await this.finalize(slot.uploadId, slot.fileName);
1447
+ await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS);
1448
+ const finalized = await this.finalize(slot.uploadId, slot.fileName, {
1449
+ ...options.folderPath !== void 0 ? { folderPath: options.folderPath } : {}
1450
+ });
1329
1451
  if (statusSatisfies(finalized.status, waitUntil)) return finalized;
1330
1452
  return this.pollUntil(
1331
1453
  slot.uploadId,
@@ -1360,8 +1482,17 @@ var ManagementContextFilesResource = class {
1360
1482
  * @param options.concurrency - Max concurrent PUT+poll operations (default 10).
1361
1483
  * @param options.waitUntil - `"processing"` (default) or `"ready"` — same as `upload()`.
1362
1484
  * @param options.onProgress - Optional progress callback after each file.
1485
+ * @param options.folderPath - Root-relative folder to upload under. Nested
1486
+ * files keep their path relative to `path` under this prefix. Example:
1487
+ * `uploadDir('./docs', { folderPath: 'reports' })` places `./docs/a.txt` at
1488
+ * `reports` and `./docs/nested/b.txt` at `reports/nested`.
1363
1489
  * @returns `UploadDirResult` with every successful `FileUpload` and every
1364
1490
  * per-file failure (slot creation or PUT/poll), each tagged with its local path.
1491
+ * @example
1492
+ * ```ts
1493
+ * const mgmt = new ModusManagement()
1494
+ * const result = await mgmt.context.files.uploadDir('./docs', { folderPath: 'reports' })
1495
+ * ```
1365
1496
  */
1366
1497
  async uploadDir(path, options = {}) {
1367
1498
  const waitUntil = options.waitUntil ?? "processing";
@@ -1383,6 +1514,10 @@ var ManagementContextFilesResource = class {
1383
1514
  validateWaitUntil(waitUntil);
1384
1515
  const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
1385
1516
  if (concurrency < 1) throw new Error(`concurrency must be >= 1, got ${concurrency}`);
1517
+ const prefixed = files.map((file) => {
1518
+ const folderPath = joinDestination(options.folderPath, file.folderPath);
1519
+ return { path: file.path, ...folderPath !== void 0 ? { folderPath } : {} };
1520
+ });
1386
1521
  const uploaded = [];
1387
1522
  const failed = [];
1388
1523
  const total = files.length;
@@ -1396,7 +1531,7 @@ var ManagementContextFilesResource = class {
1396
1531
  failed: failed.length
1397
1532
  });
1398
1533
  };
1399
- for (const batch of chunked(files, MAX_BULK_UPLOAD_FILES)) {
1534
+ for (const batch of chunked(prefixed, MAX_BULK_UPLOAD_FILES)) {
1400
1535
  const failedBefore = failed.length;
1401
1536
  const slots = await this.createSlots(batch, failed);
1402
1537
  for (let reported = failedBefore + 1; reported <= failed.length; reported += 1) {
@@ -1438,7 +1573,7 @@ var ManagementContextFilesResource = class {
1438
1573
  async ({ path, folderPath, slot }) => {
1439
1574
  try {
1440
1575
  const data = await readFile(path);
1441
- await putBytes(this.config.fetch, slot.uploadUrl, data, slot.contentType, DEFAULT_PUT_TIMEOUT_MS);
1576
+ await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS);
1442
1577
  return { landed: { path, ...folderPath !== void 0 ? { folderPath } : {}, slot } };
1443
1578
  } catch (error) {
1444
1579
  const message = error instanceof Error ? error.message : String(error);
@@ -1503,9 +1638,18 @@ var ManagementContextFilesResource = class {
1503
1638
  };
1504
1639
 
1505
1640
  // src/management/context/items.ts
1506
- function contextListParams(pageSize, pageToken, contextType) {
1641
+ function contextListParams(pageSize, pageToken, filters = {}) {
1507
1642
  const extra = {};
1508
- if (contextType !== void 0) extra.contextTypes = [contextType];
1643
+ if (filters.contextType !== void 0) extra.contextTypes = [filters.contextType];
1644
+ if (filters.parentUids !== void 0) {
1645
+ extra.parentUids = filters.parentUids.length === 0 ? "" : [...filters.parentUids];
1646
+ }
1647
+ if (filters.ancestorUids !== void 0) {
1648
+ extra.ancestorUids = filters.ancestorUids.length === 0 ? "" : [...filters.ancestorUids];
1649
+ }
1650
+ if (filters.connectionIds !== void 0) {
1651
+ extra.connectionIds = filters.connectionIds.length === 0 ? "" : [...filters.connectionIds];
1652
+ }
1509
1653
  return aipListParams(pageSize, pageToken, extra);
1510
1654
  }
1511
1655
  function parseContextItem(raw) {
@@ -1522,24 +1666,48 @@ var ManagementContextItemsResource = class {
1522
1666
  * @param options.pageSize - Items per page (default 25).
1523
1667
  * @param options.pageToken - Token from a previous page's `nextPageToken`.
1524
1668
  * @param options.contextType - Filter to one context type (for example `"note"`).
1669
+ * @param options.parentUids - Exact ordered native ancestry chain for direct
1670
+ * children. Omit to leave parent unrestricted; pass `[]` for the known-empty
1671
+ * root. Native UIDs are exact tokens; for a folder's children send ancestry
1672
+ * UIDs plus the last `dataPath` token, not the hashed context-item `uid`.
1673
+ * @param options.ancestorUids - Ordered UID ancestry prefix for strict
1674
+ * descendants. Omit to leave unrestricted; pass `[]` for every item with
1675
+ * non-null ancestry.
1676
+ * @param options.connectionIds - Restrict to these connection ids. Omit to
1677
+ * leave unfiltered; pass `[]` to match none. The Files root is
1678
+ * `connectionIds: ['files']` with `parentUids: []`.
1525
1679
  * @returns A page of context items.
1680
+ *
1681
+ * @example
1682
+ * ```ts
1683
+ * const rootFiles = await mgmt.context.items.list({
1684
+ * connectionIds: ['files'],
1685
+ * contextType: 'file_upload',
1686
+ * parentUids: [],
1687
+ * })
1688
+ * ```
1526
1689
  */
1527
1690
  list(options = {}) {
1528
1691
  const pageSize = options.pageSize ?? 25;
1529
1692
  validatePageSize(pageSize);
1530
- return this.listPage(pageSize, options.pageToken, options.contextType);
1693
+ return this.listPage(pageSize, options.pageToken, {
1694
+ contextType: options.contextType,
1695
+ parentUids: options.parentUids,
1696
+ ancestorUids: options.ancestorUids,
1697
+ connectionIds: options.connectionIds
1698
+ });
1531
1699
  }
1532
- async listPage(pageSize, pageToken, contextType) {
1700
+ async listPage(pageSize, pageToken, filters) {
1533
1701
  const data = asRecord(
1534
1702
  await invokeWithRetry(this.config, this.http, "ContextItemsController_list", {
1535
- query: contextListParams(pageSize, pageToken, contextType)
1703
+ query: contextListParams(pageSize, pageToken, filters)
1536
1704
  })
1537
1705
  );
1538
1706
  return buildAipPage(
1539
1707
  data,
1540
1708
  "contextItems",
1541
1709
  parseContextItem,
1542
- (token) => this.listPage(pageSize, token, contextType)
1710
+ (token) => this.listPage(pageSize, token, filters)
1543
1711
  );
1544
1712
  }
1545
1713
  /**
@@ -1591,7 +1759,7 @@ var ManagementContextItemsResource = class {
1591
1759
  return this.get(uid);
1592
1760
  }
1593
1761
  /**
1594
- * Delete a context item.
1762
+ * Delete a context item. Deleting a Files folder also deletes all its contents.
1595
1763
  *
1596
1764
  * @param uid - Context item uid.
1597
1765
  * @returns Deletion confirmation details.
@@ -1602,6 +1770,44 @@ var ManagementContextItemsResource = class {
1602
1770
  });
1603
1771
  return data;
1604
1772
  }
1773
+ /**
1774
+ * Move a live file or Files folder.
1775
+ *
1776
+ * Pass `destinationFolderUid: null` to move to the Files root. The
1777
+ * destination folder must already exist. Same-parent moves succeed as a
1778
+ * no-op. Does not rename or merge folders.
1779
+ *
1780
+ * @param uid - Stored context-item uid of the file or folder to move.
1781
+ * @param options.destinationFolderUid - Stored context-item uid of the
1782
+ * destination folder, or `null` for the Files root.
1783
+ * @returns How many items changed parent (`0` is a successful no-op).
1784
+ * @throws {NotFoundError} The source is missing or not visible.
1785
+ * @throws {ModusError} The destination is missing, not a Files folder, or
1786
+ * the move would create a cycle (HTTP 400).
1787
+ * @throws {PermissionDeniedError} The destination exists but is not writable
1788
+ * for this caller.
1789
+ * @throws {ConflictError} A sibling with the same name already exists.
1790
+ *
1791
+ * @example
1792
+ * ```ts
1793
+ * const moved = await mgmt.context.items.move('PLACEHOLDER_UID', {
1794
+ * destinationFolderUid: 'PLACEHOLDER_FOLDER_UID',
1795
+ * })
1796
+ * console.log(moved.movedItems)
1797
+ * ```
1798
+ */
1799
+ async move(uid, options) {
1800
+ const data = await invokeWithRetry(
1801
+ this.config,
1802
+ this.http,
1803
+ "ContextItemsController_move",
1804
+ {
1805
+ pathParams: { uid },
1806
+ jsonBody: { destinationFolderUid: options.destinationFolderUid }
1807
+ }
1808
+ );
1809
+ return data;
1810
+ }
1605
1811
  };
1606
1812
 
1607
1813
  // src/management/context/context.ts
@@ -1759,22 +1965,182 @@ var ManagementContextResource = class {
1759
1965
  }
1760
1966
  };
1761
1967
 
1762
- // src/management/scopes/memories.ts
1763
- function parseMemory(raw) {
1764
- return raw;
1765
- }
1766
- var ScopeMemoriesResource = class {
1968
+ // src/_generated/resources/management/scopes.ts
1969
+ var ScopesResourceBase = class {
1970
+ /** @internal */
1971
+ constructor(http, config) {
1972
+ this.http = http;
1973
+ this.config = config;
1974
+ }
1975
+ /**
1976
+ * List scopes.
1977
+ *
1978
+ * Returns a paginated page of scopes the caller can at least `use`. Scopes the caller cannot see
1979
+ * are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
1980
+ *
1981
+ * **Requires:** `scopes:read`
1982
+ *
1983
+ * @param options.pageSize - Items per page. Defaults to 25.
1984
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
1985
+ * for the first page.
1986
+ * @param options.search - Case-insensitive substring filter on scope name.
1987
+ * @param options.view - Variation view. `active` reads deployed; `draft` reads the latest builder
1988
+ * snapshot.
1989
+ * @param options.managerId - Return only scopes supervised by this manager scope id.
1990
+ * @returns A page of scopes.
1991
+ *
1992
+ * @example
1993
+ * ```ts
1994
+ * const mgmt = new ModusManagement()
1995
+ * for await (const scope of (await mgmt.scopes.list()).autoPagingIter()) {
1996
+ * console.log(scope.id, scope.name, scope.status)
1997
+ * }
1998
+ * ```
1999
+ */
2000
+ list(options = {}) {
2001
+ const pageSize = options.pageSize ?? 25;
2002
+ validatePageSize(pageSize);
2003
+ return this.listPage(pageSize, options.pageToken, options.search, options.view, options.managerId);
2004
+ }
2005
+ async listPage(pageSize, pageToken, search, view, managerId) {
2006
+ const extra = {};
2007
+ if (search !== void 0) extra.search = search;
2008
+ if (view !== void 0) extra.view = view;
2009
+ if (managerId !== void 0) extra.managerId = managerId;
2010
+ const data = asRecord(
2011
+ await invokeWithRetry(this.config, this.http, "ScopesController_list", {
2012
+ query: aipListParams(pageSize, pageToken, extra)
2013
+ })
2014
+ );
2015
+ return buildAipPage(
2016
+ data,
2017
+ "scopes",
2018
+ (raw) => raw,
2019
+ (token) => this.listPage(pageSize, token, search, view, managerId)
2020
+ );
2021
+ }
2022
+ /**
2023
+ * Get a scope.
2024
+ *
2025
+ * Returns a scope. `view=active` (default) returns the deployed version; `view=draft` returns the
2026
+ * latest unpublished edits. Returns 404 if you cannot access the scope.
2027
+ *
2028
+ * **Requires:** `scopes:read`
2029
+ *
2030
+ * @param scopeId - Numeric scope id.
2031
+ * @param options.view - Which variation snapshot to read. Defaults to `active`.
2032
+ *
2033
+ * @example
2034
+ * ```ts
2035
+ * const mgmt = new ModusManagement()
2036
+ * const scope = await mgmt.scopes.get('PLACEHOLDER_SCOPE_ID')
2037
+ * console.log(scope.name, scope.status)
2038
+ * ```
2039
+ */
2040
+ async get(scopeId, options = {}) {
2041
+ validateId(scopeId, "scope_id");
2042
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_get", {
2043
+ pathParams: { id: scopeId },
2044
+ query: { view: options.view }
2045
+ });
2046
+ return data;
2047
+ }
2048
+ /**
2049
+ * Delete a scope.
2050
+ *
2051
+ * Deletes a scope. The scope can be restored later with POST /scopes/{id}/restore. Deleting an
2052
+ * already-deleted scope is a no-op.
2053
+ *
2054
+ * **Requires:** `scopes:write`
2055
+ *
2056
+ * @param scopeId - Numeric scope id.
2057
+ *
2058
+ * @example
2059
+ * ```ts
2060
+ * const mgmt = new ModusManagement()
2061
+ * await mgmt.scopes.delete('PLACEHOLDER_SCOPE_ID')
2062
+ * ```
2063
+ */
2064
+ async delete(scopeId) {
2065
+ validateId(scopeId, "scope_id");
2066
+ await invokeWithRetry(this.config, this.http, "ScopesController_delete", {
2067
+ pathParams: { id: scopeId }
2068
+ });
2069
+ }
2070
+ /**
2071
+ * Restore a deleted scope.
2072
+ *
2073
+ * Restores a previously deleted scope and returns it. Restoring a scope that is already active
2074
+ * returns it unchanged.
2075
+ *
2076
+ * **Requires:** `scopes:write`
2077
+ *
2078
+ * @param scopeId - Numeric scope id.
2079
+ */
2080
+ async restore(scopeId) {
2081
+ validateId(scopeId, "scope_id");
2082
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_restore", {
2083
+ pathParams: { id: scopeId },
2084
+ jsonBody: {}
2085
+ });
2086
+ return data;
2087
+ }
2088
+ /**
2089
+ * Cancel ownership transfer.
2090
+ *
2091
+ * Cancels a pending ownership transfer. The current owner may cancel; the pending recipient may
2092
+ * decline.
2093
+ *
2094
+ * **Requires:** `scopes:write`
2095
+ *
2096
+ * @param scopeId - Numeric scope id.
2097
+ */
2098
+ async cancelOwnershipTransfer(scopeId) {
2099
+ validateId(scopeId, "scope_id");
2100
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_cancelOwnershipTransfer", {
2101
+ pathParams: { id: scopeId }
2102
+ });
2103
+ return data;
2104
+ }
2105
+ /**
2106
+ * Accept ownership transfer.
2107
+ *
2108
+ * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.
2109
+ *
2110
+ * **Requires:** `scopes:write`
2111
+ *
2112
+ * @param scopeId - Numeric scope id.
2113
+ */
2114
+ async acceptOwnershipTransfer(scopeId) {
2115
+ validateId(scopeId, "scope_id");
2116
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_acceptOwnershipTransfer", {
2117
+ pathParams: { id: scopeId },
2118
+ jsonBody: {}
2119
+ });
2120
+ return data;
2121
+ }
2122
+ };
2123
+
2124
+ // src/_generated/resources/management/scopes/memories.ts
2125
+ var ScopesMemoriesResourceBase = class {
2126
+ /** @internal */
1767
2127
  constructor(http, config, scopeId) {
1768
2128
  this.http = http;
1769
2129
  this.config = config;
1770
2130
  this.scopeId = scopeId;
1771
2131
  }
1772
2132
  /**
1773
- * List memories stored for this scope.
2133
+ * List scope memories.
1774
2134
  *
1775
- * @param options.pageSize - Items per page (default 25).
1776
- * @param options.pageToken - Token from a previous page's `nextPageToken`.
1777
- * @param options.userId - Optional end-user id when memories are scoped per user.
2135
+ * Returns a page of the scope’s memories (up to 1000 total). Pass `nextPageToken` as `pageToken`
2136
+ * to fetch the next page. Optional `userId` filters to one end user.
2137
+ *
2138
+ * **Requires:** `scopes:read`
2139
+ *
2140
+ * @param options.pageSize - Items per page. Defaults to 25.
2141
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
2142
+ * for the first page.
2143
+ * @param options.userId - Narrow results to memories tagged with this end-user id.
1778
2144
  * @returns A page of memories.
1779
2145
  */
1780
2146
  list(options = {}) {
@@ -1795,15 +2161,20 @@ var ScopeMemoriesResource = class {
1795
2161
  return buildAipPage(
1796
2162
  data,
1797
2163
  "memories",
1798
- parseMemory,
2164
+ (raw) => raw,
1799
2165
  (token) => this.listPage(pageSize, token, userId)
1800
2166
  );
1801
2167
  }
1802
2168
  /**
1803
- * Search this scope's memories by natural-language query.
2169
+ * Search scope memories.
2170
+ *
2171
+ * Returns memories ranked by semantic similarity to the supplied `query`. Caller must at least
2172
+ * `use` the scope. Optional `userId` and `limit` body fields narrow the result set (legacy parity
2173
+ * with `search-memories`).
1804
2174
  *
1805
- * @param request - Query text and optional `userId` / `limit`.
1806
- * @returns Matching memories and relevance scores.
2175
+ * **Requires:** `scopes:read`
2176
+ *
2177
+ * @param request - Request body; see `MemorySearchRequest`.
1807
2178
  */
1808
2179
  async search(request) {
1809
2180
  validateId(this.scopeId, "scope_id");
@@ -1814,12 +2185,17 @@ var ScopeMemoriesResource = class {
1814
2185
  return data;
1815
2186
  }
1816
2187
  /**
1817
- * Update one memory. Requires manage permission on the scope.
2188
+ * Update a memory.
2189
+ *
2190
+ * Updates one memory. Supply at least one of `memory` or `metadata`. Use `updateMask` to limit
2191
+ * which fields change.
1818
2192
  *
1819
- * @param memoryId - Id from list or search.
1820
- * @param update - Fields to change (`memory` and/or `metadata`).
1821
- * @param options.updateMask - Optional comma-separated field names to update.
1822
- * @returns The updated memory.
2193
+ * **Requires:** `scopes:write`
2194
+ *
2195
+ * @param memoryId - Opaque memory id as returned by the list / search endpoints.
2196
+ * @param update - Request body; see `MemoryUpdate`.
2197
+ * @param options.updateMask - Comma-separated list of fields to update. Omit to update all
2198
+ * provided fields.
1823
2199
  */
1824
2200
  async update(memoryId, update, options = {}) {
1825
2201
  validateId(memoryId, "memory_id");
@@ -1829,9 +2205,17 @@ var ScopeMemoriesResource = class {
1829
2205
  query: updateMaskQuery(options.updateMask),
1830
2206
  jsonBody: omitUndefined(update)
1831
2207
  });
1832
- return parseMemory(data);
2208
+ return data;
1833
2209
  }
1834
- /** Delete one memory (idempotent). */
2210
+ /**
2211
+ * Delete a memory.
2212
+ *
2213
+ * Deletes one memory. Deleting an already-deleted memory is a no-op.
2214
+ *
2215
+ * **Requires:** `scopes:write`
2216
+ *
2217
+ * @param memoryId - Opaque memory id as returned by the list / search endpoints.
2218
+ */
1835
2219
  async delete(memoryId) {
1836
2220
  validateId(memoryId, "memory_id");
1837
2221
  validateId(this.scopeId, "scope_id");
@@ -1841,32 +2225,42 @@ var ScopeMemoriesResource = class {
1841
2225
  }
1842
2226
  };
1843
2227
 
1844
- // src/management/scopes/evaluations.ts
1845
- function parseConfig(raw) {
1846
- return raw;
1847
- }
1848
- function parseRun(raw) {
1849
- return raw;
1850
- }
1851
- var ScopeEvaluationsResource = class {
2228
+ // src/management/scopes/memories.ts
2229
+ var ScopeMemoriesResource = class extends ScopesMemoriesResourceBase {
2230
+ };
2231
+
2232
+ // src/_generated/resources/management/scopes/evaluations.ts
2233
+ var ScopesEvaluationsResourceBase = class {
2234
+ /** @internal */
1852
2235
  constructor(http, config, scopeId) {
1853
2236
  this.http = http;
1854
2237
  this.config = config;
1855
2238
  this.scopeId = scopeId;
1856
2239
  }
1857
- /** Get the evaluation configuration for this scope. */
2240
+ /**
2241
+ * Get evaluation configuration.
2242
+ *
2243
+ * Returns the evaluation configuration for a scope, including judge settings, schedule cadence,
2244
+ * and notification preferences.
2245
+ *
2246
+ * **Requires:** `scopes:read`
2247
+ */
1858
2248
  async getConfig() {
1859
2249
  validateId(this.scopeId, "scope_id");
1860
2250
  const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_getConfig", {
1861
2251
  pathParams: { id: this.scopeId }
1862
2252
  });
1863
- return parseConfig(data);
2253
+ return data;
1864
2254
  }
1865
2255
  /**
1866
- * Update the evaluation configuration for this scope.
2256
+ * Update evaluation configuration.
2257
+ *
2258
+ * Updates the evaluation configuration for a scope. Changes to the schedule cadence are synced
2259
+ * automatically.
1867
2260
  *
1868
- * @param update - Configuration fields to change.
1869
- * @returns The updated evaluation configuration.
2261
+ * **Requires:** `scopes:write`
2262
+ *
2263
+ * @param update - Request body; see `UpdateEvaluationConfig`.
1870
2264
  */
1871
2265
  async updateConfig(update) {
1872
2266
  validateId(this.scopeId, "scope_id");
@@ -1874,12 +2268,17 @@ var ScopeEvaluationsResource = class {
1874
2268
  pathParams: { id: this.scopeId },
1875
2269
  jsonBody: omitUndefined(update)
1876
2270
  });
1877
- return parseConfig(data);
2271
+ return data;
1878
2272
  }
1879
2273
  /**
1880
- * Trigger a manual evaluation run for this scope.
2274
+ * Trigger evaluation run.
1881
2275
  *
1882
- * @returns The triggered run id and status.
2276
+ * Triggers a manual evaluation run for the scope. The run executes asynchronously.
2277
+ *
2278
+ * **Requires:** `scopes:write`
2279
+ *
2280
+ * @returns Evaluation run accepted and queued. The run executes asynchronously; poll `GET
2281
+ * /scopes/{id}/evaluations/runs/{runId}` for status.
1883
2282
  */
1884
2283
  async triggerRun() {
1885
2284
  validateId(this.scopeId, "scope_id");
@@ -1889,11 +2288,14 @@ var ScopeEvaluationsResource = class {
1889
2288
  return data;
1890
2289
  }
1891
2290
  /**
1892
- * List evaluation runs for this scope.
2291
+ * List evaluation runs.
1893
2292
  *
1894
- * @param options.pageSize - Items per page (default 25).
1895
- * @param options.pageToken - Token from a previous page's `nextPageToken`.
1896
- * @returns A page of evaluation runs.
2293
+ * Returns a paginated list of evaluation runs for the scope, ordered by most recent first.
2294
+ *
2295
+ * **Requires:** `scopes:read`
2296
+ *
2297
+ * @param options.pageSize - Items per page. Defaults to 25.
2298
+ * @returns A page of runs.
1897
2299
  */
1898
2300
  listRuns(options = {}) {
1899
2301
  const pageSize = options.pageSize ?? 25;
@@ -1908,13 +2310,21 @@ var ScopeEvaluationsResource = class {
1908
2310
  query: aipListParams(pageSize, pageToken)
1909
2311
  })
1910
2312
  );
1911
- return buildAipPage(data, "runs", parseRun, (token) => this.listRunsPage(pageSize, token));
2313
+ return buildAipPage(
2314
+ data,
2315
+ "runs",
2316
+ (raw) => raw,
2317
+ (token) => this.listRunsPage(pageSize, token)
2318
+ );
1912
2319
  }
1913
2320
  /**
1914
- * Retrieve one evaluation run with full results.
2321
+ * Get evaluation run.
2322
+ *
2323
+ * Returns details of an evaluation run including all per-case results.
1915
2324
  *
1916
- * @param runId - Evaluation run id.
1917
- * @returns The run and its result details.
2325
+ * **Requires:** `scopes:read`
2326
+ *
2327
+ * @param runId - Run ID.
1918
2328
  */
1919
2329
  async getRun(runId) {
1920
2330
  validateId(this.scopeId, "scope_id");
@@ -1926,53 +2336,157 @@ var ScopeEvaluationsResource = class {
1926
2336
  }
1927
2337
  };
1928
2338
 
1929
- // src/management/scopes/supervision.ts
1930
- var ScopeSupervisionResource = class {
2339
+ // src/management/scopes/evaluations.ts
2340
+ var ScopeEvaluationsResource = class extends ScopesEvaluationsResourceBase {
2341
+ };
2342
+
2343
+ // src/_generated/resources/management/scopes/interfaces.ts
2344
+ var ScopesInterfacesResourceBase = class {
2345
+ /** @internal */
2346
+ constructor(http, config, scopeId) {
2347
+ this.http = http;
2348
+ this.config = config;
2349
+ this.scopeId = scopeId;
2350
+ }
2351
+ /**
2352
+ * List the chat interfaces of a scope.
2353
+ *
2354
+ * Returns the chat interfaces (at most one per chat platform) that let people use this scope from
2355
+ * chat. Requires manage permission on the scope, because the config lists allowed emails.
2356
+ *
2357
+ * **Requires:** `scopes:read`
2358
+ */
2359
+ async list() {
2360
+ validateId(this.scopeId, "scope_id");
2361
+ const data = await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_list", {
2362
+ pathParams: { id: this.scopeId }
2363
+ });
2364
+ return data.interfaces;
2365
+ }
2366
+ /**
2367
+ * Remove a scope interface.
2368
+ *
2369
+ * Removes one chat interface from the scope. Mentions on that chat platform stop reaching this
2370
+ * scope immediately.
2371
+ *
2372
+ * **Requires:** `scopes:write`
2373
+ *
2374
+ * @param interfaceId - Interface id (UUID).
2375
+ */
2376
+ async delete(interfaceId) {
2377
+ validateId(this.scopeId, "scope_id");
2378
+ validateId(interfaceId, "interface_id");
2379
+ await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_delete", {
2380
+ pathParams: { id: this.scopeId, interfaceId }
2381
+ });
2382
+ }
2383
+ };
2384
+
2385
+ // src/management/scopes/interfaces.ts
2386
+ var ScopeInterfacesResource = class extends ScopesInterfacesResourceBase {
2387
+ /**
2388
+ * Add a Slack or Microsoft Teams interface to this scope.
2389
+ *
2390
+ * @param options - Interface type, optional name and config.
2391
+ * @returns The created interface.
2392
+ */
2393
+ async create(options) {
2394
+ validateId(this.scopeId, "scope_id");
2395
+ return await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_add", {
2396
+ pathParams: { id: this.scopeId },
2397
+ jsonBody: omitUndefined(options)
2398
+ });
2399
+ }
2400
+ /**
2401
+ * Update an interface on this scope.
2402
+ *
2403
+ * @param interfaceId - Interface id.
2404
+ * @param options - Updated name and/or config.
2405
+ * @param updateMask - Optional comma-separated field names to update.
2406
+ * @returns The updated interface.
2407
+ */
2408
+ async update(interfaceId, options, updateMask) {
2409
+ validateId(this.scopeId, "scope_id");
2410
+ validateId(interfaceId, "interface_id");
2411
+ return await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_update", {
2412
+ pathParams: { id: this.scopeId, interfaceId },
2413
+ query: updateMaskQuery(updateMask),
2414
+ jsonBody: updateMask === void 0 ? omitUndefined(options) : options
2415
+ });
2416
+ }
2417
+ };
2418
+
2419
+ // src/_generated/resources/management/scopes/supervision.ts
2420
+ var ScopesSupervisionResourceBase = class {
2421
+ /** @internal */
1931
2422
  constructor(http, config, scopeId) {
1932
2423
  this.http = http;
1933
2424
  this.config = config;
1934
2425
  this.scopeId = scopeId;
1935
2426
  }
1936
2427
  /**
1937
- * Get this scope's supervision configuration.
2428
+ * Read the scope subordinate supervision list.
2429
+ *
2430
+ * Returns the list of subordinate scope ids managed by this scope. `?view=active` (default) reads
2431
+ * the deployed supervision set; `?view=draft` reads the most recent builder snapshot. Returns 404
2432
+ * when the caller cannot at least `use` the scope.
1938
2433
  *
1939
- * @param options.view - Optional scope variation to inspect.
1940
- * @returns The supervision configuration.
2434
+ * **Requires:** `scopes:read`
2435
+ *
2436
+ * @param options.view - Which variation snapshot to read. Defaults to `active`.
1941
2437
  */
1942
2438
  async get(options = {}) {
1943
2439
  validateId(this.scopeId, "scope_id");
1944
- return await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_get", {
2440
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_get", {
1945
2441
  pathParams: { id: this.scopeId },
1946
- query: options.view === void 0 ? void 0 : { view: options.view }
2442
+ query: { view: options.view }
1947
2443
  });
2444
+ return data;
1948
2445
  }
1949
2446
  /**
1950
- * Replace this scope's subordinate scopes.
2447
+ * Replace draft subordinate supervision list.
1951
2448
  *
1952
- * @param request - Replacement supervision configuration.
1953
- * @returns The updated supervision configuration.
2449
+ * Writes the supplied subordinate id list into the draft variation. Replaces the previous list
2450
+ * fully — supply an empty array to clear all subordinates. Requires manage permission on the
2451
+ * supervisor; the change is not visible to runners until the scope is deployed.
2452
+ *
2453
+ * **Requires:** `scopes:write`
2454
+ *
2455
+ * @param request - Request body; see `SetSupervisionRequest`.
1954
2456
  */
1955
2457
  async set(request) {
1956
- return this.write("ScopeSupervisionController_set", request);
2458
+ validateId(this.scopeId, "scope_id");
2459
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_set", {
2460
+ pathParams: { id: this.scopeId },
2461
+ jsonBody: request
2462
+ });
2463
+ return data;
1957
2464
  }
1958
2465
  /**
1959
- * Replace subordinate scopes on the active (deployed) scope version.
2466
+ * Replace active subordinate supervision list.
2467
+ *
2468
+ * Writes directly into the active variation supervision set, bypassing the draft deploy cycle.
2469
+ * Requires `scopes:write` plus manage permission on the supervisor. Use to correct a live
2470
+ * supervision graph without going through the builder.
1960
2471
  *
1961
- * @param request - Replacement supervision configuration.
1962
- * @returns The updated supervision configuration.
2472
+ * **Requires:** `scopes:write`
2473
+ *
2474
+ * @param request - Request body; see `SetSupervisionRequest`.
1963
2475
  */
1964
2476
  async setActive(request) {
1965
- return this.write("ScopeSupervisionController_setActive", request);
1966
- }
1967
- async write(operation, request) {
1968
2477
  validateId(this.scopeId, "scope_id");
1969
- return await invokeWithRetry(this.config, this.http, operation, {
2478
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_setActive", {
1970
2479
  pathParams: { id: this.scopeId },
1971
2480
  jsonBody: request
1972
2481
  });
2482
+ return data;
1973
2483
  }
1974
2484
  };
1975
2485
 
2486
+ // src/management/scopes/supervision.ts
2487
+ var ScopeSupervisionResource = class extends ScopesSupervisionResourceBase {
2488
+ };
2489
+
1976
2490
  // src/management/scopes/skills.ts
1977
2491
  var MANAGEMENT_SCOPE_OPERATIONS = {
1978
2492
  list: "ScopesController_list",
@@ -1988,21 +2502,12 @@ var MANAGEMENT_SCOPE_OPERATIONS = {
1988
2502
  patchMcpConfig: "ScopesController_patchMcpConfig",
1989
2503
  getVariation: "ScopesController_getVariation"
1990
2504
  };
1991
- function scopesListParams(pageSize, pageToken, search, view, managerId) {
1992
- const extra = {};
1993
- if (search !== void 0) extra.search = search;
1994
- if (view !== void 0) extra.view = view;
1995
- if (managerId !== void 0) extra.managerId = managerId;
1996
- return aipListParams(pageSize, pageToken, extra);
1997
- }
1998
2505
  function parseScope(raw) {
1999
2506
  return raw;
2000
2507
  }
2001
- var ManagementScopesResource = class {
2002
- /** @internal */
2003
- constructor(http, config) {
2004
- this.http = http;
2005
- this.config = config;
2508
+ var ManagementScopesResource = class extends ScopesResourceBase {
2509
+ constructor() {
2510
+ super(...arguments);
2006
2511
  this.ops = MANAGEMENT_SCOPE_OPERATIONS;
2007
2512
  }
2008
2513
  /**
@@ -2042,67 +2547,13 @@ var ManagementScopesResource = class {
2042
2547
  return new ScopeSupervisionResource(this.http, this.config, scopeId);
2043
2548
  }
2044
2549
  /**
2045
- * List scopes in the organization.
2046
- *
2047
- * @param options.pageSize - Maximum items per page (default 25).
2048
- * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
2049
- * @param options.search - Case-insensitive substring filter on the scope name.
2050
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
2051
- * @param options.managerId - Return only scopes supervised by this manager scope id.
2052
- * @returns A page of scopes — use `.autoPagingIter()` for all pages.
2053
- * @example
2054
- * ```ts
2055
- * const mgmt = new ModusManagement()
2056
- * for await (const scope of (await mgmt.scopes.list()).autoPagingIter()) {
2057
- * console.log(scope.id, scope.name, scope.status)
2058
- * }
2059
- * ```
2060
- */
2061
- list(options = {}) {
2062
- const pageSize = options.pageSize ?? 25;
2063
- validatePageSize(pageSize);
2064
- return this.listPage(
2065
- pageSize,
2066
- options.pageToken,
2067
- options.search,
2068
- options.view,
2069
- options.managerId
2070
- );
2071
- }
2072
- async listPage(pageSize, pageToken, search, view, managerId) {
2073
- const data = asRecord(
2074
- await invokeWithRetry(this.config, this.http, this.ops.list, {
2075
- query: scopesListParams(pageSize, pageToken, search, view, managerId)
2076
- })
2077
- );
2078
- return buildAipPage(
2079
- data,
2080
- "scopes",
2081
- parseScope,
2082
- (token) => this.listPage(pageSize, token, search, view, managerId)
2083
- );
2084
- }
2085
- /**
2086
- * Retrieve a scope with full configuration.
2550
+ * Slack and Microsoft Teams interfaces for a scope.
2087
2551
  *
2088
2552
  * @param scopeId - Scope id.
2089
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
2090
- * @returns The scope.
2091
- * @example
2092
- * ```ts
2093
- * const mgmt = new ModusManagement()
2094
- * const scope = await mgmt.scopes.get('PLACEHOLDER_SCOPE_ID')
2095
- * console.log(scope.name, scope.status)
2096
- * ```
2553
+ * @returns An interfaces resource scoped to the scope.
2097
2554
  */
2098
- async get(scopeId, options = {}) {
2099
- validateId(scopeId, "scope_id");
2100
- const query = options.view !== void 0 ? { view: options.view } : void 0;
2101
- const data = await invokeWithRetry(this.config, this.http, this.ops.get, {
2102
- pathParams: { id: scopeId },
2103
- query
2104
- });
2105
- return parseScope(data);
2555
+ interfaces(scopeId) {
2556
+ return new ScopeInterfacesResource(this.http, this.config, scopeId);
2106
2557
  }
2107
2558
  /**
2108
2559
  * Create a new scope in the organization.
@@ -2112,6 +2563,7 @@ var ManagementScopesResource = class {
2112
2563
  * @param options.instructions - Optional system instructions.
2113
2564
  * @param options.model - Optional model id.
2114
2565
  * @param options.toolset - Optional tool selection for the scope.
2566
+ * @param options.includeOwnLearnings - Whether the scope reads what is taught while using it. Defaults to true.
2115
2567
  * @param options.guardrails - Runtime guardrail labels (for example `"no-pii"`). Omit to create with no guardrails.
2116
2568
  * @returns The created scope (draft).
2117
2569
  * @example
@@ -2131,6 +2583,7 @@ var ManagementScopesResource = class {
2131
2583
  model: options.model,
2132
2584
  connectionSet: options.connectionSet,
2133
2585
  contextSelections: options.contextSelections,
2586
+ includeOwnLearnings: options.includeOwnLearnings,
2134
2587
  interfaces: options.interfaces,
2135
2588
  accessConfig: accessConfigBodyForCreate(options.guardrails)
2136
2589
  });
@@ -2213,37 +2666,6 @@ var ManagementScopesResource = class {
2213
2666
  );
2214
2667
  return parseScope(data.scope);
2215
2668
  }
2216
- /**
2217
- * Delete a scope.
2218
- *
2219
- * @param scopeId - Scope id.
2220
- * @returns Resolves when the scope is deleted.
2221
- * @example
2222
- * ```ts
2223
- * const mgmt = new ModusManagement()
2224
- * await mgmt.scopes.delete('PLACEHOLDER_SCOPE_ID')
2225
- * ```
2226
- */
2227
- async delete(scopeId) {
2228
- validateId(scopeId, "scope_id");
2229
- await invokeWithRetry(this.config, this.http, this.ops.delete, {
2230
- pathParams: { id: scopeId }
2231
- });
2232
- }
2233
- /**
2234
- * Restore a previously deleted scope.
2235
- *
2236
- * @param scopeId - Scope id.
2237
- * @returns The restored scope.
2238
- */
2239
- async restore(scopeId) {
2240
- validateId(scopeId, "scope_id");
2241
- const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
2242
- pathParams: { id: scopeId },
2243
- jsonBody: {}
2244
- });
2245
- return parseScope(data);
2246
- }
2247
2669
  /**
2248
2670
  * Start transferring ownership of a scope to another organization member.
2249
2671
  *
@@ -2264,28 +2686,6 @@ var ManagementScopesResource = class {
2264
2686
  );
2265
2687
  return parseScope(data);
2266
2688
  }
2267
- /** Cancel a pending scope ownership transfer. */
2268
- async cancelOwnershipTransfer(scopeId) {
2269
- validateId(scopeId, "scope_id");
2270
- const data = await invokeWithRetry(
2271
- this.config,
2272
- this.http,
2273
- this.ops.cancelOwnershipTransfer,
2274
- { pathParams: { id: scopeId } }
2275
- );
2276
- return parseScope(data);
2277
- }
2278
- /** Accept a pending scope ownership transfer. */
2279
- async acceptOwnershipTransfer(scopeId) {
2280
- validateId(scopeId, "scope_id");
2281
- const data = await invokeWithRetry(
2282
- this.config,
2283
- this.http,
2284
- this.ops.acceptOwnershipTransfer,
2285
- { pathParams: { id: scopeId }, jsonBody: {} }
2286
- );
2287
- return parseScope(data);
2288
- }
2289
2689
  /**
2290
2690
  * Update MCP server configuration for a scope.
2291
2691
  *
@@ -2316,12 +2716,35 @@ var ManagementScopesResource = class {
2316
2716
  }
2317
2717
  };
2318
2718
 
2319
- // src/management/usage.ts
2320
- var ManagementUsageResource = class {
2719
+ // src/_generated/resources/management/usage.ts
2720
+ var UsageResourceBase = class {
2721
+ /** @internal */
2321
2722
  constructor(http, config) {
2322
2723
  this.http = http;
2323
2724
  this.config = config;
2324
2725
  }
2726
+ /**
2727
+ * List usage users.
2728
+ *
2729
+ * Returns the distinct acting-user emails that appear in your organization's LLM usage over the
2730
+ * `[since, until)` window. Feeds the usage page's user filter (includes non-Modus Slack/Teams
2731
+ * users). Scoped to your organization.
2732
+ *
2733
+ * **Requires:** `usage:read`
2734
+ *
2735
+ * @param options.since - ISO8601 start of the query window (inclusive).
2736
+ * @param options.until - ISO8601 end of the query window (exclusive).
2737
+ */
2738
+ async listUsers(options) {
2739
+ const data = await invokeWithRetry(this.config, this.http, "UsageController_listUsers", {
2740
+ query: { since: options.since, until: options.until }
2741
+ });
2742
+ return data;
2743
+ }
2744
+ };
2745
+
2746
+ // src/management/usage.ts
2747
+ var ManagementUsageResource = class extends UsageResourceBase {
2325
2748
  /**
2326
2749
  * List usage metrics for your organization over a time window.
2327
2750
  *
@@ -2345,42 +2768,27 @@ var ManagementUsageResource = class {
2345
2768
  const data = await invokeWithRetry(this.config, this.http, "UsageController_list", { query });
2346
2769
  return data;
2347
2770
  }
2348
- /**
2349
- * List distinct acting-user emails observed in a time window.
2350
- *
2351
- * @param options.since - Start of the window (ISO 8601, inclusive).
2352
- * @param options.until - End of the window (ISO 8601, exclusive).
2353
- * @returns User emails seen in usage during the window.
2354
- * @throws {UnprocessableError} When the request is rejected by the API.
2355
- * @throws {AuthenticationError} When the API key is invalid or missing.
2356
- */
2357
- async listUsers(options) {
2358
- const query = {
2359
- since: options.since,
2360
- until: options.until
2361
- };
2362
- const data = await invokeWithRetry(this.config, this.http, "UsageController_listUsers", {
2363
- query
2364
- });
2365
- return data;
2366
- }
2367
2771
  };
2368
2772
 
2369
- // src/management/tools.ts
2370
- function parseToolCatalogEntry(raw) {
2371
- return raw;
2372
- }
2373
- var ManagementToolsResource = class {
2773
+ // src/_generated/resources/management/tools.ts
2774
+ var ToolsResourceBase = class {
2775
+ /** @internal */
2374
2776
  constructor(http, config) {
2375
2777
  this.http = http;
2376
2778
  this.config = config;
2377
2779
  }
2378
2780
  /**
2379
- * List tool and integration surfaces a scope can select in its toolset.
2781
+ * List available tools.
2380
2782
  *
2381
- * @param options.pageSize - Maximum items per page (default 25).
2382
- * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
2383
- * @returns A page of tool catalog entries.
2783
+ * Returns a page of known tool/integration surfaces a scope can select in its toolset, with the
2784
+ * fixed actions for built-in tools.
2785
+ *
2786
+ * **Requires:** `scopes:read`
2787
+ *
2788
+ * @param options.pageSize - Items per page. Defaults to 25.
2789
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
2790
+ * for the first page.
2791
+ * @returns A page of tools.
2384
2792
  */
2385
2793
  list(options = {}) {
2386
2794
  const pageSize = options.pageSize ?? 25;
@@ -2393,10 +2801,19 @@ var ManagementToolsResource = class {
2393
2801
  query: aipListParams(pageSize, pageToken)
2394
2802
  })
2395
2803
  );
2396
- return buildAipPage(data, "tools", parseToolCatalogEntry, (token) => this.listPage(pageSize, token));
2804
+ return buildAipPage(
2805
+ data,
2806
+ "tools",
2807
+ (raw) => raw,
2808
+ (token) => this.listPage(pageSize, token)
2809
+ );
2397
2810
  }
2398
2811
  };
2399
2812
 
2813
+ // src/management/tools.ts
2814
+ var ManagementToolsResource = class extends ToolsResourceBase {
2815
+ };
2816
+
2400
2817
  // src/management/users.ts
2401
2818
  var ManagementUsersResource = class {
2402
2819
  constructor(http, config) {