@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.
@@ -201,6 +201,7 @@ function createModusConfig(options = {}) {
201
201
  }),
202
202
  timeoutMs: resolveTimeoutMs(options.timeoutMs) ?? DEFAULT_TIMEOUT_MS,
203
203
  maxRetries,
204
+ defaultHeaders: Object.freeze({ ...options.defaultHeaders }),
204
205
  fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
205
206
  });
206
207
  }
@@ -216,7 +217,7 @@ function formatConfigForLog(config) {
216
217
  }
217
218
 
218
219
  // src/_http.ts
219
- var USER_AGENT = `modus-typescript/${"0.7.0"} (node/${process.version}; ${process.platform})`;
220
+ var USER_AGENT = `modus-typescript/${"0.9.0"} (node/${process.version}; ${process.platform})`;
220
221
  function buildUrl(baseUrl, path, params) {
221
222
  const url = new URL(path.startsWith("/") ? path : `/${path}`, baseUrl);
222
223
  if (params) {
@@ -231,6 +232,15 @@ function buildUrl(baseUrl, path, params) {
231
232
  }
232
233
  return url.toString();
233
234
  }
235
+ function mergeHeaders(...layers) {
236
+ const merged = /* @__PURE__ */ new Map();
237
+ for (const layer of layers) {
238
+ for (const [name, value] of Object.entries(layer ?? {})) {
239
+ merged.set(name.toLowerCase(), [name, value]);
240
+ }
241
+ }
242
+ return Object.fromEntries(merged.values());
243
+ }
234
244
  function headersToRecord(headers) {
235
245
  const out = {};
236
246
  headers.forEach((value, key) => {
@@ -336,12 +346,15 @@ var HttpClient = class {
336
346
  this.config = config;
337
347
  }
338
348
  defaultHeaders() {
339
- return {
340
- ...authHeaders(this.config.apiKey),
341
- Accept: "application/json",
342
- "Content-Type": "application/json",
343
- "User-Agent": USER_AGENT
344
- };
349
+ return mergeHeaders(
350
+ {
351
+ Accept: "application/json",
352
+ "Content-Type": "application/json",
353
+ "User-Agent": USER_AGENT,
354
+ "X-Modus-Client": "sdk"
355
+ },
356
+ this.config.defaultHeaders
357
+ );
345
358
  }
346
359
  async request(method, path, options = {}) {
347
360
  const baseUrl = options.baseUrl ?? this.config.baseUrl;
@@ -349,7 +362,7 @@ var HttpClient = class {
349
362
  try {
350
363
  const response = await this.config.fetch(url, {
351
364
  method,
352
- headers: { ...this.defaultHeaders(), ...options.headers },
365
+ headers: mergeHeaders(this.defaultHeaders(), options.headers, authHeaders(this.config.apiKey)),
353
366
  body: options.json !== void 0 ? JSON.stringify(options.json) : void 0,
354
367
  signal: AbortSignal.timeout(this.config.timeoutMs)
355
368
  });
@@ -388,11 +401,12 @@ var HttpClient = class {
388
401
  method,
389
402
  // Agent-service negotiates SSE vs JSON polling on Accept; JSON-only
390
403
  // Accept returns {"runId","status":"pending"} instead of token SSE.
391
- headers: {
392
- ...this.defaultHeaders(),
393
- ...options.headers,
394
- Accept: "text/event-stream"
395
- },
404
+ headers: mergeHeaders(
405
+ this.defaultHeaders(),
406
+ options.headers,
407
+ { Accept: "text/event-stream" },
408
+ authHeaders(this.config.apiKey)
409
+ ),
396
410
  body: options.json !== void 0 ? JSON.stringify(options.json) : void 0,
397
411
  signal: AbortSignal.timeout(this.config.timeoutMs)
398
412
  });
@@ -458,15 +472,6 @@ var ModusClientBase = class {
458
472
  }
459
473
  };
460
474
 
461
- // src/_query.ts
462
- function updateMaskQuery(updateMask) {
463
- if (updateMask === void 0) return void 0;
464
- if (!updateMask.trim()) {
465
- throw new Error("update_mask must be a non-empty comma-separated list of field names");
466
- }
467
- return { updateMask };
468
- }
469
-
470
475
  // src/_pagination.ts
471
476
  var Page = class {
472
477
  constructor(items, nextPageToken, fetchPage) {
@@ -562,6 +567,16 @@ var OPERATIONS = {
562
567
  requestSchema: null,
563
568
  responseSchema: "ListConnectionsResponseDto"
564
569
  },
570
+ "ConnectionsController_listSelections": {
571
+ method: "GET",
572
+ path: "/api/v1/connections/{connectionId}/selections",
573
+ service: "modus-api",
574
+ serverUrl: "https://api.getmodus.com",
575
+ pathParams: ["connectionId"],
576
+ queryParams: ["pageToken", "pageSize"],
577
+ requestSchema: null,
578
+ responseSchema: "ListConnectionSelectionsResponseDto"
579
+ },
565
580
  "ContextCreatorsController_createLink": {
566
581
  method: "POST",
567
582
  path: "/api/v1/context/links",
@@ -698,7 +713,7 @@ var OPERATIONS = {
698
713
  service: "modus-api",
699
714
  serverUrl: "https://api.getmodus.com",
700
715
  pathParams: [],
701
- queryParams: ["pageToken", "pageSize", "contextTypes", "verificationStatuses", "searchQuery", "topics"],
716
+ queryParams: ["pageToken", "pageSize", "contextTypes", "verificationStatuses", "searchQuery", "topics", "connectionIds", "parentUids", "ancestorUids"],
702
717
  requestSchema: null,
703
718
  responseSchema: "ListContextItemsResponseDto"
704
719
  },
@@ -722,6 +737,16 @@ var OPERATIONS = {
722
737
  requestSchema: "LookupContextItemDto",
723
738
  responseSchema: "LookupContextItemResponseDto"
724
739
  },
740
+ "ContextItemsController_move": {
741
+ method: "POST",
742
+ path: "/api/v1/context/items/{uid}/move",
743
+ service: "modus-api",
744
+ serverUrl: "https://api.getmodus.com",
745
+ pathParams: ["uid"],
746
+ queryParams: [],
747
+ requestSchema: "MoveContextItemDto",
748
+ responseSchema: "MoveContextItemResponseDto"
749
+ },
725
750
  "ContextItemsController_update": {
726
751
  method: "PATCH",
727
752
  path: "/api/v1/context/items/{uid}",
@@ -1262,6 +1287,46 @@ var OPERATIONS = {
1262
1287
  requestSchema: null,
1263
1288
  responseSchema: "ListConversationsResponseDto"
1264
1289
  },
1290
+ "ScopeInterfacesController_add": {
1291
+ method: "POST",
1292
+ path: "/api/v1/scopes/{id}/interfaces",
1293
+ service: "modus-api",
1294
+ serverUrl: "https://api.getmodus.com",
1295
+ pathParams: ["id"],
1296
+ queryParams: [],
1297
+ requestSchema: "AddScopeInterfaceDto",
1298
+ responseSchema: "ScopeInterfaceDto"
1299
+ },
1300
+ "ScopeInterfacesController_delete": {
1301
+ method: "DELETE",
1302
+ path: "/api/v1/scopes/{id}/interfaces/{interfaceId}",
1303
+ service: "modus-api",
1304
+ serverUrl: "https://api.getmodus.com",
1305
+ pathParams: ["id", "interfaceId"],
1306
+ queryParams: [],
1307
+ requestSchema: null,
1308
+ responseSchema: null
1309
+ },
1310
+ "ScopeInterfacesController_list": {
1311
+ method: "GET",
1312
+ path: "/api/v1/scopes/{id}/interfaces",
1313
+ service: "modus-api",
1314
+ serverUrl: "https://api.getmodus.com",
1315
+ pathParams: ["id"],
1316
+ queryParams: [],
1317
+ requestSchema: null,
1318
+ responseSchema: "ListScopeInterfacesResponseDto"
1319
+ },
1320
+ "ScopeInterfacesController_update": {
1321
+ method: "PATCH",
1322
+ path: "/api/v1/scopes/{id}/interfaces/{interfaceId}",
1323
+ service: "modus-api",
1324
+ serverUrl: "https://api.getmodus.com",
1325
+ pathParams: ["id", "interfaceId"],
1326
+ queryParams: ["updateMask"],
1327
+ requestSchema: "UpdateScopeInterfaceDto",
1328
+ responseSchema: "ScopeInterfaceDto"
1329
+ },
1265
1330
  "ScopeMemoriesController_delete": {
1266
1331
  method: "DELETE",
1267
1332
  path: "/api/v1/scopes/{id}/memories/{memoryId}",
@@ -1818,6 +1883,7 @@ var WRITE_BODY_ALLOWED_KEYS = {
1818
1883
  ContextFilesController_uploadUrl: ["fileName", "contentType", "fileSize"],
1819
1884
  ContextFilesController_uploadUrls: ["files"],
1820
1885
  ContextItemsController_lookup: ["contextType", "dataPath", "contentProjection"],
1886
+ ContextItemsController_move: ["destinationFolderUid"],
1821
1887
  ContextItemsController_update: ["contextType", "content", "description", "userFeedback", "topics"],
1822
1888
  CustomContextItemsController_batchCreate: ["items"],
1823
1889
  CustomContextItemsController_create: ["kind", "sourceId", "sourceName", "collectionId", "collectionName", "externalId", "fieldName", "name", "entityType", "description", "content", "url", "attributes", "dataType", "value", "samples", "raw", "topics", "idempotencyKey", "access"],
@@ -1843,11 +1909,13 @@ var WRITE_BODY_ALLOWED_KEYS = {
1843
1909
  RunLifecycleController_interrupt: [],
1844
1910
  ScopeChatController_chat: ["message", "model"],
1845
1911
  ScopeContextController_compose: ["message", "limit"],
1912
+ ScopeInterfacesController_add: ["type", "name", "config"],
1913
+ ScopeInterfacesController_update: ["name", "config"],
1846
1914
  ScopeMemoriesController_search: ["query", "userId", "limit"],
1847
1915
  ScopeMemoriesController_update: ["memory", "metadata"],
1848
1916
  ScopeRunsController_create: ["message", "sessionId", "organizationId", "version", "fileThreadId", "config", "attachments", "userContext", "source", "runId", "subordinateSkillIds"],
1849
1917
  ScopesController_acceptOwnershipTransfer: [],
1850
- ScopesController_create: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "interfaces", "accessConfig"],
1918
+ ScopesController_create: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "includeOwnLearnings", "interfaces", "accessConfig"],
1851
1919
  ScopesController_deploy: [],
1852
1920
  ScopesController_patchMcpConfig: ["config"],
1853
1921
  ScopesController_requestOwnershipTransfer: ["newOwnerUserId"],
@@ -1921,6 +1989,149 @@ function asRecord(data) {
1921
1989
  throw new Error(`Expected object response, got ${typeof data}`);
1922
1990
  }
1923
1991
 
1992
+ // src/_generated/resources/management/workflows.ts
1993
+ var WorkflowsResourceBase = class {
1994
+ /** @internal */
1995
+ constructor(http, config) {
1996
+ this.http = http;
1997
+ this.config = config;
1998
+ }
1999
+ /**
2000
+ * List workflows.
2001
+ *
2002
+ * Returns a paginated page of workflows the caller can at least `use`. Workflows the caller
2003
+ * cannot see are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
2004
+ *
2005
+ * **Requires:** `workflows:read`
2006
+ *
2007
+ * @param options.pageSize - Items per page. Defaults to 25.
2008
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
2009
+ * for the first page.
2010
+ * @param options.search - Case-insensitive substring filter on workflow name.
2011
+ * @param options.type - Filter by workflow type.
2012
+ * @param options.view - Variation view. `active` reads deployed; `draft` reads the latest builder
2013
+ * snapshot.
2014
+ * @param options.includeVariation - Include the requested variation payload (`trigger`,
2015
+ * `workflowStructure`, `agentSelection`) on list rows.
2016
+ * @returns A page of workflows.
2017
+ *
2018
+ * @example
2019
+ * ```ts
2020
+ * const mgmt = new ModusManagement()
2021
+ * for await (const wf of (await mgmt.workflows.list({ search: 'digest' })).autoPagingIter()) {
2022
+ * console.log(wf.id, wf.name, wf.status)
2023
+ * }
2024
+ * ```
2025
+ */
2026
+ list(options = {}) {
2027
+ const pageSize = options.pageSize ?? 25;
2028
+ validatePageSize(pageSize);
2029
+ return this.listPage(pageSize, options.pageToken, options.search, options.type, options.view, options.includeVariation);
2030
+ }
2031
+ async listPage(pageSize, pageToken, search, type, view, includeVariation) {
2032
+ const extra = {};
2033
+ if (search !== void 0) extra.search = search;
2034
+ if (type !== void 0) extra.type = type;
2035
+ if (view !== void 0) extra.view = view;
2036
+ if (includeVariation !== void 0) extra.includeVariation = includeVariation;
2037
+ const data = asRecord(
2038
+ await invokeWithRetry(this.config, this.http, "WorkflowsController_list", {
2039
+ query: aipListParams(pageSize, pageToken, extra)
2040
+ })
2041
+ );
2042
+ return buildAipPage(
2043
+ data,
2044
+ "workflows",
2045
+ (raw) => raw,
2046
+ (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
2047
+ );
2048
+ }
2049
+ /**
2050
+ * Delete a workflow.
2051
+ *
2052
+ * Deletes a workflow and stops its schedule. The workflow can be restored later with POST
2053
+ * /workflows/{id}/restore. Deleting an already-deleted workflow is a no-op.
2054
+ *
2055
+ * **Requires:** `workflows:write`
2056
+ *
2057
+ * @param workflowId - Numeric workflow id.
2058
+ *
2059
+ * @example
2060
+ * ```ts
2061
+ * const mgmt = new ModusManagement()
2062
+ * await mgmt.workflows.delete('PLACEHOLDER_WORKFLOW_ID')
2063
+ * ```
2064
+ */
2065
+ async delete(workflowId) {
2066
+ validateId(workflowId, "workflow_id");
2067
+ await invokeWithRetry(this.config, this.http, "WorkflowsController_delete", {
2068
+ pathParams: { id: workflowId }
2069
+ });
2070
+ }
2071
+ /**
2072
+ * Restore a deleted workflow.
2073
+ *
2074
+ * Restores a previously deleted workflow and returns it. The workflow’s schedule is not resumed
2075
+ * automatically — re-enable it if it should run again. Restoring an active workflow returns it
2076
+ * unchanged.
2077
+ *
2078
+ * **Requires:** `workflows:write`
2079
+ *
2080
+ * @param workflowId - Numeric workflow id.
2081
+ */
2082
+ async restore(workflowId) {
2083
+ validateId(workflowId, "workflow_id");
2084
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_restore", {
2085
+ pathParams: { id: workflowId },
2086
+ jsonBody: {}
2087
+ });
2088
+ return data;
2089
+ }
2090
+ /**
2091
+ * Cancel ownership transfer.
2092
+ *
2093
+ * Cancels a pending ownership transfer. The current owner may cancel; the pending recipient may
2094
+ * decline.
2095
+ *
2096
+ * **Requires:** `workflows:write`
2097
+ *
2098
+ * @param workflowId - Numeric workflow id.
2099
+ */
2100
+ async cancelOwnershipTransfer(workflowId) {
2101
+ validateId(workflowId, "workflow_id");
2102
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_cancelOwnershipTransfer", {
2103
+ pathParams: { id: workflowId }
2104
+ });
2105
+ return data;
2106
+ }
2107
+ /**
2108
+ * Accept ownership transfer.
2109
+ *
2110
+ * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.
2111
+ *
2112
+ * **Requires:** `workflows:write`
2113
+ *
2114
+ * @param workflowId - Numeric workflow id.
2115
+ */
2116
+ async acceptOwnershipTransfer(workflowId) {
2117
+ validateId(workflowId, "workflow_id");
2118
+ const data = await invokeWithRetry(this.config, this.http, "WorkflowsController_acceptOwnershipTransfer", {
2119
+ pathParams: { id: workflowId },
2120
+ jsonBody: {}
2121
+ });
2122
+ return data;
2123
+ }
2124
+ };
2125
+
2126
+ // src/_query.ts
2127
+ function updateMaskQuery(updateMask) {
2128
+ if (updateMask === void 0) return void 0;
2129
+ if (!updateMask.trim()) {
2130
+ throw new Error("update_mask must be a non-empty comma-separated list of field names");
2131
+ }
2132
+ return { updateMask };
2133
+ }
2134
+
1924
2135
  // src/management/_access-config.ts
1925
2136
  var EVERYONE_GROUP_ID = "__everyone__";
1926
2137
  function accessConfigWireForCreate(guardrails) {
@@ -1954,14 +2165,22 @@ async function accessConfigBodyForUpdate(guardrails, loadResource) {
1954
2165
  return accessConfigWireForUpdate(existing, guardrails);
1955
2166
  }
1956
2167
 
1957
- // src/management/workflows/interfaces.ts
1958
- var WorkflowInterfacesResource = class {
2168
+ // src/_generated/resources/management/workflows/interfaces.ts
2169
+ var WorkflowsInterfacesResourceBase = class {
2170
+ /** @internal */
1959
2171
  constructor(http, config, workflowId) {
1960
2172
  this.http = http;
1961
2173
  this.config = config;
1962
2174
  this.workflowId = workflowId;
1963
2175
  }
1964
- /** List interfaces attached to this workflow. */
2176
+ /**
2177
+ * List interfaces attached to a workflow.
2178
+ *
2179
+ * Returns every Slack, MCP, or Teams interface bound to the workflow. Requires manage permission
2180
+ * on the workflow.
2181
+ *
2182
+ * **Requires:** `workflows:read`
2183
+ */
1965
2184
  async list() {
1966
2185
  validateId(this.workflowId, "workflow_id");
1967
2186
  const data = await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_list", {
@@ -1969,6 +2188,40 @@ var WorkflowInterfacesResource = class {
1969
2188
  });
1970
2189
  return data.interfaces;
1971
2190
  }
2191
+ /**
2192
+ * Remove every interface from a workflow.
2193
+ *
2194
+ * Deletes all interface rows attached to the workflow. Useful when recreating the interface set
2195
+ * from scratch.
2196
+ *
2197
+ * **Requires:** `workflows:write`
2198
+ */
2199
+ async deleteAll() {
2200
+ validateId(this.workflowId, "workflow_id");
2201
+ await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_deleteAll", {
2202
+ pathParams: { id: this.workflowId }
2203
+ });
2204
+ }
2205
+ /**
2206
+ * Remove a workflow interface.
2207
+ *
2208
+ * Deletes one interface row. For MCP interfaces, bound MCP tokens are revoked best-effort.
2209
+ *
2210
+ * **Requires:** `workflows:write`
2211
+ *
2212
+ * @param interfaceId - Interface row id (UUID).
2213
+ */
2214
+ async delete(interfaceId) {
2215
+ validateId(this.workflowId, "workflow_id");
2216
+ validateId(interfaceId, "interface_id");
2217
+ await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_delete", {
2218
+ pathParams: { id: this.workflowId, interfaceId }
2219
+ });
2220
+ }
2221
+ };
2222
+
2223
+ // src/management/workflows/interfaces.ts
2224
+ var WorkflowInterfacesResource = class extends WorkflowsInterfacesResourceBase {
1972
2225
  /**
1973
2226
  * Add an interface to this workflow.
1974
2227
  *
@@ -1999,25 +2252,6 @@ var WorkflowInterfacesResource = class {
1999
2252
  jsonBody: updateMask === void 0 ? omitUndefined(options) : options
2000
2253
  });
2001
2254
  }
2002
- /**
2003
- * Delete an interface from this workflow.
2004
- *
2005
- * @param interfaceId - Interface id.
2006
- */
2007
- async delete(interfaceId) {
2008
- validateId(this.workflowId, "workflow_id");
2009
- validateId(interfaceId, "interface_id");
2010
- await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_delete", {
2011
- pathParams: { id: this.workflowId, interfaceId }
2012
- });
2013
- }
2014
- /** Delete every interface from this workflow. */
2015
- async deleteAll() {
2016
- validateId(this.workflowId, "workflow_id");
2017
- await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_deleteAll", {
2018
- pathParams: { id: this.workflowId }
2019
- });
2020
- }
2021
2255
  };
2022
2256
 
2023
2257
  // src/management/workflows/agents.ts
@@ -2034,66 +2268,14 @@ var MANAGEMENT_WORKFLOW_OPERATIONS = {
2034
2268
  acceptOwnershipTransfer: "WorkflowsController_acceptOwnershipTransfer",
2035
2269
  toggle: "WorkflowsController_toggle"
2036
2270
  };
2037
- function workflowsListParams(pageSize, pageToken, search, type, view, includeVariation) {
2038
- const extra = {};
2039
- if (search !== void 0) extra.search = search;
2040
- if (type !== void 0) extra.type = type;
2041
- if (view !== void 0) extra.view = view;
2042
- if (includeVariation !== void 0) extra.includeVariation = includeVariation;
2043
- return aipListParams(pageSize, pageToken, extra);
2044
- }
2045
2271
  function parseWorkflow(raw) {
2046
2272
  return raw;
2047
2273
  }
2048
- var ManagementWorkflowsResource = class {
2049
- constructor(http, config) {
2050
- this.http = http;
2051
- this.config = config;
2274
+ var ManagementWorkflowsResource = class extends WorkflowsResourceBase {
2275
+ constructor() {
2276
+ super(...arguments);
2052
2277
  this.ops = MANAGEMENT_WORKFLOW_OPERATIONS;
2053
2278
  }
2054
- /**
2055
- * List workflows in the organization.
2056
- *
2057
- * @param options.pageSize - Maximum items per page (default 25).
2058
- * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
2059
- * @param options.search - Case-insensitive substring filter on the workflow name.
2060
- * @param options.type - Filter by workflow type: `"task"` or `"workflow"`.
2061
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
2062
- * @param options.includeVariation - Include variation payload on each list row.
2063
- * @returns A page of workflows.
2064
- * @example
2065
- * ```ts
2066
- * const mgmt = new ModusManagement()
2067
- * for await (const wf of (await mgmt.workflows.list({ search: 'digest' })).autoPagingIter()) {
2068
- * console.log(wf.id, wf.name, wf.status)
2069
- * }
2070
- * ```
2071
- */
2072
- list(options = {}) {
2073
- const pageSize = options.pageSize ?? 25;
2074
- validatePageSize(pageSize);
2075
- return this.listPage(
2076
- pageSize,
2077
- options.pageToken,
2078
- options.search,
2079
- options.type,
2080
- options.view,
2081
- options.includeVariation
2082
- );
2083
- }
2084
- async listPage(pageSize, pageToken, search, type, view, includeVariation) {
2085
- const data = asRecord(
2086
- await invokeWithRetry(this.config, this.http, this.ops.list, {
2087
- query: workflowsListParams(pageSize, pageToken, search, type, view, includeVariation)
2088
- })
2089
- );
2090
- return buildAipPage(
2091
- data,
2092
- "workflows",
2093
- parseWorkflow,
2094
- (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
2095
- );
2096
- }
2097
2279
  /**
2098
2280
  * Retrieve a workflow with full configuration.
2099
2281
  *
@@ -2235,44 +2417,13 @@ var ManagementWorkflowsResource = class {
2235
2417
  return parseWorkflow(data);
2236
2418
  }
2237
2419
  /**
2238
- * Delete a workflow.
2239
- *
2240
- * @param workflowId - Workflow id.
2241
- * @returns Resolves when the workflow is deleted.
2242
- * @example
2243
- * ```ts
2244
- * const mgmt = new ModusManagement()
2245
- * await mgmt.workflows.delete('PLACEHOLDER_WORKFLOW_ID')
2246
- * ```
2247
- */
2248
- async delete(workflowId) {
2249
- validateId(workflowId, "workflow_id");
2250
- await invokeWithRetry(this.config, this.http, this.ops.delete, {
2251
- pathParams: { id: workflowId }
2252
- });
2253
- }
2254
- /**
2255
- * Restore a previously deleted workflow.
2420
+ * Start transferring ownership of a workflow to another organization member.
2256
2421
  *
2257
2422
  * @param workflowId - Workflow id.
2258
- * @returns The restored workflow.
2423
+ * @param options.newOwnerUserId - User id of the proposed new owner.
2424
+ * @returns The workflow with a pending ownership transfer.
2259
2425
  */
2260
- async restore(workflowId) {
2261
- validateId(workflowId, "workflow_id");
2262
- const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
2263
- pathParams: { id: workflowId },
2264
- jsonBody: {}
2265
- });
2266
- return parseWorkflow(data);
2267
- }
2268
- /**
2269
- * Start transferring ownership of a workflow to another organization member.
2270
- *
2271
- * @param workflowId - Workflow id.
2272
- * @param options.newOwnerUserId - User id of the proposed new owner.
2273
- * @returns The workflow with a pending ownership transfer.
2274
- */
2275
- async requestOwnershipTransfer(workflowId, options) {
2426
+ async requestOwnershipTransfer(workflowId, options) {
2276
2427
  validateId(workflowId, "workflow_id");
2277
2428
  const data = await invokeWithRetry(
2278
2429
  this.config,
@@ -2285,28 +2436,6 @@ var ManagementWorkflowsResource = class {
2285
2436
  );
2286
2437
  return parseWorkflow(data);
2287
2438
  }
2288
- /** Cancel a pending workflow ownership transfer. */
2289
- async cancelOwnershipTransfer(workflowId) {
2290
- validateId(workflowId, "workflow_id");
2291
- const data = await invokeWithRetry(
2292
- this.config,
2293
- this.http,
2294
- this.ops.cancelOwnershipTransfer,
2295
- { pathParams: { id: workflowId } }
2296
- );
2297
- return parseWorkflow(data);
2298
- }
2299
- /** Accept a pending workflow ownership transfer. */
2300
- async acceptOwnershipTransfer(workflowId) {
2301
- validateId(workflowId, "workflow_id");
2302
- const data = await invokeWithRetry(
2303
- this.config,
2304
- this.http,
2305
- this.ops.acceptOwnershipTransfer,
2306
- { pathParams: { id: workflowId }, jsonBody: {} }
2307
- );
2308
- return parseWorkflow(data);
2309
- }
2310
2439
  };
2311
2440
 
2312
2441
  // src/types/context.ts
@@ -2346,7 +2475,7 @@ var CustomContextItemsResource = class {
2346
2475
  *
2347
2476
  * @param options.pageSize - Maximum items per page (default 25).
2348
2477
  * @param options.pageToken - Opaque token from a previous page.
2349
- * @param options.searchQuery - Free-text search filter.
2478
+ * @param options.searchQuery - Word search: returns rows that contain every word of the query, case-insensitive.
2350
2479
  * @param options.topics - Filter to items tagged with any of these topics.
2351
2480
  * @returns A page of custom context items.
2352
2481
  * @example
@@ -2409,12 +2538,16 @@ var CustomContextItemsResource = class {
2409
2538
  * @example
2410
2539
  * ```ts
2411
2540
  * const client = new Modus()
2541
+ * // Create the source and collection first, or use batchCreate as shown below.
2412
2542
  * const created = await client.context.customItems.create({
2413
2543
  * kind: 'entity',
2414
- * sourceId: 'my-source',
2544
+ * sourceId: 'billing-db',
2545
+ * collectionId: 'contracts',
2546
+ * externalId: 'contract-123',
2415
2547
  * name: 'Q3 churn notes',
2416
2548
  * content: { summary: 'Key findings…' },
2417
2549
  * })
2550
+ * console.log(created.uid, created.dataPath)
2418
2551
  * ```
2419
2552
  */
2420
2553
  async create(input) {
@@ -2434,9 +2567,22 @@ var CustomContextItemsResource = class {
2434
2567
  * ```ts
2435
2568
  * const client = new Modus()
2436
2569
  * const created = await client.context.customItems.batchCreate([
2437
- * { kind: 'field', sourceId: 'src', fieldName: 'region', dataType: 'string' },
2438
- * { kind: 'field', sourceId: 'src', fieldName: 'amount', dataType: 'number' },
2570
+ * { kind: 'source', sourceId: 'billing-db', name: 'Billing database' },
2571
+ * {
2572
+ * kind: 'collection',
2573
+ * sourceId: 'billing-db',
2574
+ * collectionId: 'contracts',
2575
+ * name: 'Contracts',
2576
+ * },
2577
+ * {
2578
+ * kind: 'entity',
2579
+ * sourceId: 'billing-db',
2580
+ * collectionId: 'contracts',
2581
+ * externalId: 'contract-123',
2582
+ * name: 'Acme renewal',
2583
+ * },
2439
2584
  * ])
2585
+ * console.log(created.map((item) => item.dataPath))
2440
2586
  * ```
2441
2587
  */
2442
2588
  async batchCreate(inputs) {
@@ -2601,8 +2747,174 @@ async function resolveAndUpdateLink(items, uid, options) {
2601
2747
  });
2602
2748
  }
2603
2749
 
2604
- // src/management/context/dashboards.ts
2605
- var ManagementDashboardElementsResource = class {
2750
+ // src/_generated/resources/management/context/dashboards.ts
2751
+ var ContextDashboardsResourceBase = class {
2752
+ /** @internal */
2753
+ constructor(http, config) {
2754
+ this.http = http;
2755
+ this.config = config;
2756
+ }
2757
+ /**
2758
+ * Delete a dashboard.
2759
+ *
2760
+ * Removes the dashboard from every listing and deletes its alert workflows. It cannot be restored
2761
+ * through the API.
2762
+ *
2763
+ * **Requires:** `context:write`
2764
+ *
2765
+ * @param dashboardId - Dashboard id, as shown in the app URL.
2766
+ *
2767
+ * @example
2768
+ * ```ts
2769
+ * await mgmt.context.dashboards.delete('DASHBOARD_ID')
2770
+ * ```
2771
+ */
2772
+ async delete(dashboardId) {
2773
+ validateId(dashboardId, "dashboardId");
2774
+ await invokeWithRetry(this.config, this.http, "DashboardsController_delete", {
2775
+ pathParams: { dashboardId }
2776
+ });
2777
+ }
2778
+ /**
2779
+ * List dashboard draft snapshots.
2780
+ *
2781
+ * Returns ids and timestamps of the most recent draft snapshots. Editors only.
2782
+ *
2783
+ * **Requires:** `context:read`
2784
+ *
2785
+ * @param dashboardId - Dashboard id, as shown in the app URL.
2786
+ *
2787
+ * @example
2788
+ * ```ts
2789
+ * const snapshots = await mgmt.context.dashboards.listDraftSnapshots('DASHBOARD_ID')
2790
+ * snapshots.map((snapshot) => snapshot.uid)
2791
+ * ```
2792
+ */
2793
+ async listDraftSnapshots(dashboardId) {
2794
+ validateId(dashboardId, "dashboardId");
2795
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listDraftSnapshots", {
2796
+ pathParams: { dashboardId }
2797
+ });
2798
+ return asRecord(data).snapshots;
2799
+ }
2800
+ /**
2801
+ * Cancel an ownership transfer.
2802
+ *
2803
+ * Owner only. Clears the pending transfer and returns the dashboard.
2804
+ *
2805
+ * **Requires:** `context:write`
2806
+ *
2807
+ * @param dashboardId - Dashboard id, as shown in the app URL.
2808
+ *
2809
+ * @example
2810
+ * ```ts
2811
+ * await mgmt.context.dashboards.cancelOwnershipTransfer('DASHBOARD_ID')
2812
+ * ```
2813
+ */
2814
+ async cancelOwnershipTransfer(dashboardId) {
2815
+ validateId(dashboardId, "dashboardId");
2816
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_cancelOwnership", {
2817
+ pathParams: { dashboardId }
2818
+ });
2819
+ return asRecord(data);
2820
+ }
2821
+ /**
2822
+ * Accept an ownership transfer.
2823
+ *
2824
+ * Recipient only. Makes you the owner and clears the pending transfer.
2825
+ *
2826
+ * **Requires:** `context:write`
2827
+ *
2828
+ * @param dashboardId - Dashboard id, as shown in the app URL.
2829
+ *
2830
+ * @example
2831
+ * ```ts
2832
+ * await mgmt.context.dashboards.acceptOwnershipTransfer('DASHBOARD_ID')
2833
+ * ```
2834
+ */
2835
+ async acceptOwnershipTransfer(dashboardId) {
2836
+ validateId(dashboardId, "dashboardId");
2837
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_acceptOwnership", {
2838
+ pathParams: { dashboardId }
2839
+ });
2840
+ return asRecord(data);
2841
+ }
2842
+ /**
2843
+ * List dashboard versions.
2844
+ *
2845
+ * Returns the published versions, newest first, each with its full definition. Draft snapshots
2846
+ * are not included. The response is not paginated and can be large.
2847
+ *
2848
+ * **Requires:** `context:read`
2849
+ *
2850
+ * @param dashboardId - Dashboard id, as shown in the app URL.
2851
+ *
2852
+ * @example
2853
+ * ```ts
2854
+ * const versions = await mgmt.context.dashboards.listVersions('DASHBOARD_ID')
2855
+ * versions.map((version) => [version.uid, version.versionNumber])
2856
+ * ```
2857
+ */
2858
+ async listVersions(dashboardId) {
2859
+ validateId(dashboardId, "dashboardId");
2860
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listVersions", {
2861
+ pathParams: { dashboardId }
2862
+ });
2863
+ return asRecord(data).versions;
2864
+ }
2865
+ /**
2866
+ * Get a dashboard version.
2867
+ *
2868
+ * Returns the dashboard as it was in the given version. For a draft snapshot (editors only) the
2869
+ * view is reported as active and selectedVersion.versionNumber is null.
2870
+ *
2871
+ * **Requires:** `context:read`
2872
+ *
2873
+ * @param dashboardId - Dashboard id, as shown in the app URL.
2874
+ * @param versionId - Version id, or a draft snapshot id for editors.
2875
+ *
2876
+ * @example
2877
+ * ```ts
2878
+ * const old = await mgmt.context.dashboards.getVersion('DASHBOARD_ID', 'VERSION_ID')
2879
+ * old.selectedVersion.versionNumber
2880
+ * ```
2881
+ */
2882
+ async getVersion(dashboardId, versionId) {
2883
+ validateId(dashboardId, "dashboardId");
2884
+ validateId(versionId, "versionId");
2885
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_getVersion", {
2886
+ pathParams: { dashboardId, versionId }
2887
+ });
2888
+ return asRecord(data);
2889
+ }
2890
+ /**
2891
+ * Restore a dashboard version.
2892
+ *
2893
+ * Replaces the current draft with the content of the given version. The outgoing draft is kept as
2894
+ * a draft snapshot. Returns the draft view.
2895
+ *
2896
+ * **Requires:** `context:write`
2897
+ *
2898
+ * @param dashboardId - Dashboard id, as shown in the app URL.
2899
+ * @param versionId - Version id, or a draft snapshot id for editors.
2900
+ *
2901
+ * @example
2902
+ * ```ts
2903
+ * await mgmt.context.dashboards.restoreVersion('DASHBOARD_ID', 'VERSION_ID')
2904
+ * ```
2905
+ */
2906
+ async restoreVersion(dashboardId, versionId) {
2907
+ validateId(dashboardId, "dashboardId");
2908
+ validateId(versionId, "versionId");
2909
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_restore", {
2910
+ pathParams: { dashboardId, versionId }
2911
+ });
2912
+ return asRecord(data);
2913
+ }
2914
+ };
2915
+
2916
+ // src/_generated/resources/management/context/dashboards/elements.ts
2917
+ var ContextDashboardsElementsResourceBase = class {
2606
2918
  /** @internal */
2607
2919
  constructor(http, config, dashboardId) {
2608
2920
  this.http = http;
@@ -2610,11 +2922,14 @@ var ManagementDashboardElementsResource = class {
2610
2922
  this.dashboardId = dashboardId;
2611
2923
  }
2612
2924
  /**
2613
- * List every tile and filter on the dashboard draft.
2925
+ * List dashboard elements.
2926
+ *
2927
+ * Lists every tile and filter on the dashboard draft with id, kind, title and layout. Filters
2928
+ * also carry sqlReferences, the exact templates tile SQL must use to reference them. Returns the
2929
+ * current draftRevision.
2930
+ *
2931
+ * **Requires:** `context:read`
2614
2932
  *
2615
- * @returns Each element's id, kind, title and grid position, plus the current
2616
- * `draftRevision` to pass as `expectedRevision` on the next change.
2617
- * @throws NotFoundError - The dashboard does not exist or you cannot edit it.
2618
2933
  * @example
2619
2934
  * ```ts
2620
2935
  * const listed = await mgmt.context.dashboards.elements('DASHBOARD_ID').list()
@@ -2622,19 +2937,21 @@ var ManagementDashboardElementsResource = class {
2622
2937
  * ```
2623
2938
  */
2624
2939
  async list() {
2625
- return asRecord(
2626
- await invokeWithRetry(this.config, this.http, "DashboardsController_listElements", {
2627
- pathParams: { dashboardId: this.dashboardId }
2628
- })
2629
- );
2940
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_listElements", {
2941
+ pathParams: { dashboardId: this.dashboardId }
2942
+ });
2943
+ return asRecord(data);
2630
2944
  }
2631
2945
  /**
2632
- * Get the full draft settings of one tile or filter.
2946
+ * Get a dashboard element.
2947
+ *
2948
+ * Returns the full draft configuration of one dashboard element, including SQL, chart settings
2949
+ * and filter options, with the current draftRevision.
2950
+ *
2951
+ * **Requires:** `context:read`
2952
+ *
2953
+ * @param elementId - The dashboard element id to read.
2633
2954
  *
2634
- * @param elementId - Id of the tile or filter, as returned by `list()`.
2635
- * @returns The element's settings and the current `draftRevision`.
2636
- * @throws NotFoundError - The dashboard or the element does not exist, or you cannot
2637
- * edit the dashboard.
2638
2955
  * @example
2639
2956
  * ```ts
2640
2957
  * const result = await mgmt.context.dashboards.elements('DASHBOARD_ID').get('ELEMENT_ID')
@@ -2643,11 +2960,18 @@ var ManagementDashboardElementsResource = class {
2643
2960
  */
2644
2961
  async get(elementId) {
2645
2962
  validateId(elementId, "elementId");
2646
- return asRecord(
2647
- await invokeWithRetry(this.config, this.http, "DashboardsController_getElement", {
2648
- pathParams: { dashboardId: this.dashboardId, elementId }
2649
- })
2650
- );
2963
+ const data = await invokeWithRetry(this.config, this.http, "DashboardsController_getElement", {
2964
+ pathParams: { dashboardId: this.dashboardId, elementId }
2965
+ });
2966
+ return asRecord(data);
2967
+ }
2968
+ };
2969
+
2970
+ // src/management/context/dashboards.ts
2971
+ var ManagementDashboardElementsResource = class extends ContextDashboardsElementsResourceBase {
2972
+ /** @internal */
2973
+ constructor(http, config, dashboardId) {
2974
+ super(http, config, dashboardId);
2651
2975
  }
2652
2976
  /**
2653
2977
  * Add a blank tile or filter to the dashboard draft.
@@ -2712,11 +3036,10 @@ var ManagementDashboardElementsResource = class {
2712
3036
  );
2713
3037
  }
2714
3038
  };
2715
- var ManagementDashboardsResource = class {
3039
+ var ManagementDashboardsResource = class extends ContextDashboardsResourceBase {
2716
3040
  /** @internal */
2717
3041
  constructor(http, config) {
2718
- this.http = http;
2719
- this.config = config;
3042
+ super(http, config);
2720
3043
  }
2721
3044
  /**
2722
3045
  * List dashboards with their full definitions.
@@ -2857,117 +3180,6 @@ var ManagementDashboardsResource = class {
2857
3180
  })
2858
3181
  );
2859
3182
  }
2860
- /**
2861
- * Delete a dashboard and the alert workflows defined on it.
2862
- *
2863
- * A deleted dashboard cannot be restored.
2864
- *
2865
- * @param dashboardId - Id of the dashboard.
2866
- * @throws NotFoundError - The dashboard does not exist or you cannot edit it.
2867
- * @example
2868
- * ```ts
2869
- * await mgmt.context.dashboards.delete('DASHBOARD_ID')
2870
- * ```
2871
- */
2872
- async delete(dashboardId) {
2873
- validateId(dashboardId, "dashboardId");
2874
- await invokeWithRetry(this.config, this.http, "DashboardsController_delete", {
2875
- pathParams: { dashboardId }
2876
- });
2877
- }
2878
- /**
2879
- * List the published versions of a dashboard, newest first.
2880
- *
2881
- * @param dashboardId - Id of the dashboard.
2882
- * @returns Every published version with its full definition. Definitions are
2883
- * returned as stored, so older versions may lack newer fields. The list is
2884
- * not paginated.
2885
- * @throws NotFoundError - The dashboard does not exist or you cannot open it.
2886
- * @example
2887
- * ```ts
2888
- * const versions = await mgmt.context.dashboards.listVersions('DASHBOARD_ID')
2889
- * versions.map((version) => [version.uid, version.versionNumber])
2890
- * ```
2891
- */
2892
- async listVersions(dashboardId) {
2893
- validateId(dashboardId, "dashboardId");
2894
- const data = asRecord(
2895
- await invokeWithRetry(this.config, this.http, "DashboardsController_listVersions", {
2896
- pathParams: { dashboardId }
2897
- })
2898
- );
2899
- return data.versions;
2900
- }
2901
- /**
2902
- * Get a dashboard as it was in one version.
2903
- *
2904
- * @param dashboardId - Id of the dashboard.
2905
- * @param versionId - Id of the version, as returned by `listVersions()`.
2906
- * @returns The dashboard with that version's definition.
2907
- * @throws NotFoundError - The dashboard or the version does not exist, or you cannot
2908
- * open the dashboard.
2909
- * @example
2910
- * ```ts
2911
- * const old = await mgmt.context.dashboards.getVersion('DASHBOARD_ID', 'VERSION_ID')
2912
- * old.selectedVersion.versionNumber
2913
- * ```
2914
- */
2915
- async getVersion(dashboardId, versionId) {
2916
- validateId(dashboardId, "dashboardId");
2917
- validateId(versionId, "versionId");
2918
- return asRecord(
2919
- await invokeWithRetry(this.config, this.http, "DashboardsController_getVersion", {
2920
- pathParams: { dashboardId, versionId }
2921
- })
2922
- );
2923
- }
2924
- /**
2925
- * Replace the draft with the content of an earlier version.
2926
- *
2927
- * The draft being replaced is kept as a draft snapshot. Call `publish()`
2928
- * afterwards to make the restored content visible.
2929
- *
2930
- * @param dashboardId - Id of the dashboard.
2931
- * @param versionId - Id of the version or draft snapshot to restore.
2932
- * @returns The dashboard draft after the restore.
2933
- * @throws NotFoundError - The dashboard or the version does not exist, or you cannot
2934
- * edit the dashboard.
2935
- * @example
2936
- * ```ts
2937
- * await mgmt.context.dashboards.restoreVersion('DASHBOARD_ID', 'VERSION_ID')
2938
- * ```
2939
- */
2940
- async restoreVersion(dashboardId, versionId) {
2941
- validateId(dashboardId, "dashboardId");
2942
- validateId(versionId, "versionId");
2943
- return asRecord(
2944
- await invokeWithRetry(this.config, this.http, "DashboardsController_restore", {
2945
- pathParams: { dashboardId, versionId }
2946
- })
2947
- );
2948
- }
2949
- /**
2950
- * List recent snapshots of the dashboard draft, newest first.
2951
- *
2952
- * @param dashboardId - Id of the dashboard.
2953
- * @returns Up to 100 snapshots with their id, author and time. Pass an id to
2954
- * `restoreVersion()` to bring that draft back.
2955
- * @throws NotFoundError - The dashboard does not exist or you cannot edit it.
2956
- * @example
2957
- * ```ts
2958
- * const snapshots = await mgmt.context.dashboards.listDraftSnapshots('DASHBOARD_ID')
2959
- * snapshots.map((snapshot) => snapshot.uid)
2960
- * ```
2961
- */
2962
- async listDraftSnapshots(dashboardId) {
2963
- validateId(dashboardId, "dashboardId");
2964
- const data = asRecord(
2965
- await invokeWithRetry(this.config, this.http, "DashboardsController_listDraftSnapshots", {
2966
- pathParams: { dashboardId }
2967
- })
2968
- );
2969
- return data.snapshots;
2970
- }
2971
3183
  /**
2972
3184
  * Replace who can open and edit a dashboard.
2973
3185
  *
@@ -3033,54 +3245,10 @@ var ManagementDashboardsResource = class {
3033
3245
  );
3034
3246
  }
3035
3247
  /**
3036
- * Accept a pending ownership transfer and become the dashboard owner.
3037
- *
3038
- * Only the requested recipient can accept.
3248
+ * Work with the tiles and filters of one dashboard draft.
3039
3249
  *
3040
3250
  * @param dashboardId - Id of the dashboard.
3041
- * @returns The dashboard with you as its owner.
3042
- * @throws NotFoundError - The dashboard does not exist, or it has no pending transfer
3043
- * addressed to you.
3044
- * @example
3045
- * ```ts
3046
- * await mgmt.context.dashboards.acceptOwnershipTransfer('DASHBOARD_ID')
3047
- * ```
3048
- */
3049
- async acceptOwnershipTransfer(dashboardId) {
3050
- validateId(dashboardId, "dashboardId");
3051
- return asRecord(
3052
- await invokeWithRetry(this.config, this.http, "DashboardsController_acceptOwnership", {
3053
- pathParams: { dashboardId }
3054
- })
3055
- );
3056
- }
3057
- /**
3058
- * Cancel a pending ownership transfer.
3059
- *
3060
- * Only the owner can cancel.
3061
- *
3062
- * @param dashboardId - Id of the dashboard.
3063
- * @returns The dashboard with no pending transfer.
3064
- * @throws NotFoundError - The dashboard does not exist, you cannot open it, or you are
3065
- * not the owner.
3066
- * @example
3067
- * ```ts
3068
- * await mgmt.context.dashboards.cancelOwnershipTransfer('DASHBOARD_ID')
3069
- * ```
3070
- */
3071
- async cancelOwnershipTransfer(dashboardId) {
3072
- validateId(dashboardId, "dashboardId");
3073
- return asRecord(
3074
- await invokeWithRetry(this.config, this.http, "DashboardsController_cancelOwnership", {
3075
- pathParams: { dashboardId }
3076
- })
3077
- );
3078
- }
3079
- /**
3080
- * Work with the tiles and filters of one dashboard draft.
3081
- *
3082
- * @param dashboardId - Id of the dashboard.
3083
- * @returns A resource bound to that dashboard.
3251
+ * @returns A resource bound to that dashboard.
3084
3252
  * @example
3085
3253
  * ```ts
3086
3254
  * await mgmt.context.dashboards.elements('DASHBOARD_ID').list()
@@ -3121,8 +3289,66 @@ var ManagementDashboardsResource = class {
3121
3289
  // src/management/context/files.ts
3122
3290
  var import_promises = require("fs/promises");
3123
3291
  var import_node_path = require("path");
3292
+
3293
+ // src/_generated/resources/management/context/files.ts
3294
+ var ContextFilesResourceBase = class {
3295
+ /** @internal */
3296
+ constructor(http, config) {
3297
+ this.http = http;
3298
+ this.config = config;
3299
+ }
3300
+ /**
3301
+ * List file uploads.
3302
+ *
3303
+ * Returns a page of durable landed file uploads. Uploads that have not landed yet are visible via
3304
+ * `GET /context/files/{uploadId}`, not this list.
3305
+ *
3306
+ * **Requires:** `context:read`
3307
+ *
3308
+ * @param options.pageSize - Items per page. Defaults to 50.
3309
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
3310
+ * for the first page.
3311
+ * @returns A page of files.
3312
+ */
3313
+ list(options = {}) {
3314
+ const pageSize = options.pageSize ?? 50;
3315
+ validatePageSize(pageSize, 200);
3316
+ return this.listPage(pageSize, options.pageToken);
3317
+ }
3318
+ async listPage(pageSize, pageToken) {
3319
+ const data = asRecord(
3320
+ await invokeWithRetry(this.config, this.http, "ContextFilesController_list", {
3321
+ query: aipListParams(pageSize, pageToken)
3322
+ })
3323
+ );
3324
+ return buildAipPage(
3325
+ data,
3326
+ "files",
3327
+ (raw) => raw,
3328
+ (token) => this.listPage(pageSize, token)
3329
+ );
3330
+ }
3331
+ /**
3332
+ * Get a file upload.
3333
+ *
3334
+ * Returns status + metadata for one upload. Prefers the durable landed context item; falls back
3335
+ * to in-flight upload status while the object has not landed yet. 404 if neither exists.
3336
+ *
3337
+ * **Requires:** `context:read`
3338
+ *
3339
+ * @param uploadId - Upload id returned by `createUploadUrl` / `createUploadUrls`.
3340
+ */
3341
+ async get(uploadId) {
3342
+ validateId(uploadId, "uploadId");
3343
+ const data = await invokeWithRetry(this.config, this.http, "ContextFilesController_get", {
3344
+ pathParams: { uploadId }
3345
+ });
3346
+ return asRecord(data);
3347
+ }
3348
+ };
3349
+
3350
+ // src/management/context/files.ts
3124
3351
  var MAX_BULK_UPLOAD_FILES = 100;
3125
- var DEFAULT_LIST_PAGE_SIZE = 50;
3126
3352
  var DEFAULT_PUT_TIMEOUT_MS = 6e4;
3127
3353
  var DEFAULT_POLL_INTERVAL_MS = 500;
3128
3354
  var DEFAULT_UPLOAD_TIMEOUT_MS = 12e4;
@@ -3153,6 +3379,12 @@ function chunked(items, size) {
3153
3379
  for (let i = 0; i < items.length; i += size) out.push(items.slice(i, i + size));
3154
3380
  return out;
3155
3381
  }
3382
+ function joinDestination(prefix, relative2) {
3383
+ const head = prefix === void 0 || prefix.length === 0 ? void 0 : prefix;
3384
+ const tail = relative2 === void 0 || relative2.length === 0 ? void 0 : relative2;
3385
+ if (head !== void 0 && tail !== void 0) return `${head}/${tail}`;
3386
+ return head ?? tail;
3387
+ }
3156
3388
  async function mapWithConcurrency(items, concurrency, worker, onItemDone) {
3157
3389
  const results = new Array(items.length);
3158
3390
  let cursor = 0;
@@ -3186,11 +3418,11 @@ async function walkFiles(root, recursive) {
3186
3418
  await walk(root);
3187
3419
  return out;
3188
3420
  }
3189
- async function putBytes(fetchImpl, url, data, contentType, timeoutMs) {
3190
- const response = await fetchImpl(url, {
3421
+ async function putBytes(fetchImpl, slot, data, timeoutMs) {
3422
+ const response = await fetchImpl(slot.uploadUrl, {
3191
3423
  method: "PUT",
3192
3424
  body: data,
3193
- headers: { "Content-Type": contentType },
3425
+ headers: { "Content-Type": slot.contentType, ...slot.headers },
3194
3426
  signal: AbortSignal.timeout(timeoutMs)
3195
3427
  });
3196
3428
  if (!response.ok) {
@@ -3234,11 +3466,10 @@ function assignSlots(batch, result, failed) {
3234
3466
  }
3235
3467
  return assignments;
3236
3468
  }
3237
- var ManagementContextFilesResource = class {
3469
+ var ManagementContextFilesResource = class extends ContextFilesResourceBase {
3238
3470
  /** @internal */
3239
3471
  constructor(http, config) {
3240
- this.http = http;
3241
- this.config = config;
3472
+ super(http, config);
3242
3473
  }
3243
3474
  /**
3244
3475
  * Get a presigned S3 PUT URL for one file.
@@ -3248,7 +3479,7 @@ var ManagementContextFilesResource = class {
3248
3479
  * Office/OpenDocument documents, audio, and video.
3249
3480
  * @param input.fileSize - File size in bytes. Rejected above 50MB.
3250
3481
  * @returns Presigned upload slot. PUT the raw bytes to `uploadUrl` within 15
3251
- * minutes, then call `finalize(slot.uploadId, slot.fileName)`. Pass the
3482
+ * minutes, sending `headers` unchanged, then call `finalize(slot.uploadId, slot.fileName)`. Pass the
3252
3483
  * slot's own `fileName` rather than your local basename — the server may
3253
3484
  * sanitize the requested name when it mints the key, and finalization
3254
3485
  * re-derives the key from `uploadId` and `fileName`.
@@ -3281,6 +3512,7 @@ var ManagementContextFilesResource = class {
3281
3512
  * @param url - Source URL to fetch (SSRF-guarded, 50MB cap, same MIME
3282
3513
  * allow-list as `createUploadUrl`).
3283
3514
  * @param options.fileName - Override file name. Inferred from the URL path when omitted.
3515
+ * @param options.folderPath - Root-relative folder to upload under.
3284
3516
  * @returns File upload resource with status `processing` — parsing continues async.
3285
3517
  */
3286
3518
  async uploadFromUrl(url, options = {}) {
@@ -3309,41 +3541,6 @@ var ManagementContextFilesResource = class {
3309
3541
  })
3310
3542
  );
3311
3543
  }
3312
- /**
3313
- * Fetch one file upload by its id.
3314
- *
3315
- * @param uploadId - Upload id returned by `createUploadUrl` / `uploadFromUrl`.
3316
- * @returns The file upload resource, including its processing `status`.
3317
- */
3318
- async get(uploadId) {
3319
- validateId(uploadId, "uploadId");
3320
- return asRecord(
3321
- await invokeWithRetry(this.config, this.http, "ContextFilesController_get", {
3322
- pathParams: { uploadId }
3323
- })
3324
- );
3325
- }
3326
- /**
3327
- * List durable file uploads.
3328
- *
3329
- * @param options.pageSize - Items per page (default 50).
3330
- * @param options.pageToken - Opaque token from a previous page's `nextPageToken`.
3331
- * @returns Page of file uploads. Uploads that only have a pending row (not yet
3332
- * landed) aren't included here — use `get(uploadId)` for those.
3333
- */
3334
- list(options = {}) {
3335
- const pageSize = options.pageSize ?? DEFAULT_LIST_PAGE_SIZE;
3336
- validatePageSize(pageSize, 200);
3337
- return this.listPage(pageSize, options.pageToken);
3338
- }
3339
- async listPage(pageSize, pageToken) {
3340
- const data = asRecord(
3341
- await invokeWithRetry(this.config, this.http, "ContextFilesController_list", {
3342
- query: aipListParams(pageSize, pageToken)
3343
- })
3344
- );
3345
- return buildAipPage(data, "files", (raw) => raw, (token) => this.listPage(pageSize, token));
3346
- }
3347
3544
  /**
3348
3545
  * Turn a file already PUT to a presigned URL into durable context.
3349
3546
  *
@@ -3398,6 +3595,16 @@ var ManagementContextFilesResource = class {
3398
3595
  * @param options.concurrency - Max concurrent PUTs (default 10).
3399
3596
  * @param options.waitUntil - `"processing"` (default) or `"ready"`.
3400
3597
  * @param options.onProgress - Optional progress callback after each file.
3598
+ * @param options.folderPath - Root-relative folder to upload under. Nested
3599
+ * files keep their existing relative folder labels under this prefix.
3600
+ * @example
3601
+ * ```ts
3602
+ * const mgmt = new ModusManagement()
3603
+ * const result = await mgmt.context.files.uploadFiles(
3604
+ * ['./q3.pdf', './notes.md'],
3605
+ * { folderPath: 'reports/2026' },
3606
+ * )
3607
+ * ```
3401
3608
  */
3402
3609
  async uploadFiles(paths, options = {}) {
3403
3610
  return this.uploadPaths(paths.map((input) => typeof input === "string" ? { path: input } : input), options);
@@ -3405,16 +3612,23 @@ var ManagementContextFilesResource = class {
3405
3612
  /**
3406
3613
  * Upload a local file and wait for it to reach `"processing"` or `"ready"`.
3407
3614
  *
3408
- * Gets a presigned URL, PUTs the file bytes, then polls `get()` until the
3409
- * upload leaves `"pending"` (or reaches `"ready"`/`"failed"`).
3615
+ * Gets a presigned URL, PUTs the file bytes, then polls `get()`
3616
+ * until the upload leaves `"pending"` (or reaches `"ready"`/`"failed"`).
3410
3617
  *
3411
3618
  * @param path - Path to a local file.
3412
3619
  * @param options.waitUntil - `"processing"` (parsing started, default) or
3413
3620
  * `"ready"` (parsing finished).
3414
3621
  * @param options.pollIntervalMs - Milliseconds between status polls.
3415
3622
  * @param options.timeoutMs - Max milliseconds to wait before raising.
3623
+ * @param options.folderPath - Root-relative folder to upload under. Example:
3624
+ * `{ folderPath: 'reports/2026' }` places `./report.pdf` at `reports/2026`.
3416
3625
  * @returns The file upload resource once it reaches `waitUntil` (or `"failed"`).
3417
3626
  * @throws {ModusError} If the PUT fails, or polling times out.
3627
+ * @example
3628
+ * ```ts
3629
+ * const mgmt = new ModusManagement()
3630
+ * const file = await mgmt.context.files.upload('./report.pdf', { folderPath: 'reports/2026' })
3631
+ * ```
3418
3632
  */
3419
3633
  async upload(path, options = {}) {
3420
3634
  const waitUntil = options.waitUntil ?? "processing";
@@ -3428,8 +3642,10 @@ var ManagementContextFilesResource = class {
3428
3642
  fileSize: fileStat.size
3429
3643
  });
3430
3644
  const data = await (0, import_promises.readFile)(path);
3431
- await putBytes(this.config.fetch, slot.uploadUrl, data, slot.contentType, DEFAULT_PUT_TIMEOUT_MS);
3432
- const finalized = await this.finalize(slot.uploadId, slot.fileName);
3645
+ await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS);
3646
+ const finalized = await this.finalize(slot.uploadId, slot.fileName, {
3647
+ ...options.folderPath !== void 0 ? { folderPath: options.folderPath } : {}
3648
+ });
3433
3649
  if (statusSatisfies(finalized.status, waitUntil)) return finalized;
3434
3650
  return this.pollUntil(
3435
3651
  slot.uploadId,
@@ -3464,8 +3680,17 @@ var ManagementContextFilesResource = class {
3464
3680
  * @param options.concurrency - Max concurrent PUT+poll operations (default 10).
3465
3681
  * @param options.waitUntil - `"processing"` (default) or `"ready"` — same as `upload()`.
3466
3682
  * @param options.onProgress - Optional progress callback after each file.
3683
+ * @param options.folderPath - Root-relative folder to upload under. Nested
3684
+ * files keep their path relative to `path` under this prefix. Example:
3685
+ * `uploadDir('./docs', { folderPath: 'reports' })` places `./docs/a.txt` at
3686
+ * `reports` and `./docs/nested/b.txt` at `reports/nested`.
3467
3687
  * @returns `UploadDirResult` with every successful `FileUpload` and every
3468
3688
  * per-file failure (slot creation or PUT/poll), each tagged with its local path.
3689
+ * @example
3690
+ * ```ts
3691
+ * const mgmt = new ModusManagement()
3692
+ * const result = await mgmt.context.files.uploadDir('./docs', { folderPath: 'reports' })
3693
+ * ```
3469
3694
  */
3470
3695
  async uploadDir(path, options = {}) {
3471
3696
  const waitUntil = options.waitUntil ?? "processing";
@@ -3487,6 +3712,10 @@ var ManagementContextFilesResource = class {
3487
3712
  validateWaitUntil(waitUntil);
3488
3713
  const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
3489
3714
  if (concurrency < 1) throw new Error(`concurrency must be >= 1, got ${concurrency}`);
3715
+ const prefixed = files.map((file) => {
3716
+ const folderPath = joinDestination(options.folderPath, file.folderPath);
3717
+ return { path: file.path, ...folderPath !== void 0 ? { folderPath } : {} };
3718
+ });
3490
3719
  const uploaded = [];
3491
3720
  const failed = [];
3492
3721
  const total = files.length;
@@ -3500,7 +3729,7 @@ var ManagementContextFilesResource = class {
3500
3729
  failed: failed.length
3501
3730
  });
3502
3731
  };
3503
- for (const batch of chunked(files, MAX_BULK_UPLOAD_FILES)) {
3732
+ for (const batch of chunked(prefixed, MAX_BULK_UPLOAD_FILES)) {
3504
3733
  const failedBefore = failed.length;
3505
3734
  const slots = await this.createSlots(batch, failed);
3506
3735
  for (let reported = failedBefore + 1; reported <= failed.length; reported += 1) {
@@ -3542,7 +3771,7 @@ var ManagementContextFilesResource = class {
3542
3771
  async ({ path, folderPath, slot }) => {
3543
3772
  try {
3544
3773
  const data = await (0, import_promises.readFile)(path);
3545
- await putBytes(this.config.fetch, slot.uploadUrl, data, slot.contentType, DEFAULT_PUT_TIMEOUT_MS);
3774
+ await putBytes(this.config.fetch, slot, data, DEFAULT_PUT_TIMEOUT_MS);
3546
3775
  return { landed: { path, ...folderPath !== void 0 ? { folderPath } : {}, slot } };
3547
3776
  } catch (error) {
3548
3777
  const message = error instanceof Error ? error.message : String(error);
@@ -3607,9 +3836,18 @@ var ManagementContextFilesResource = class {
3607
3836
  };
3608
3837
 
3609
3838
  // src/management/context/items.ts
3610
- function contextListParams(pageSize, pageToken, contextType) {
3839
+ function contextListParams(pageSize, pageToken, filters = {}) {
3611
3840
  const extra = {};
3612
- if (contextType !== void 0) extra.contextTypes = [contextType];
3841
+ if (filters.contextType !== void 0) extra.contextTypes = [filters.contextType];
3842
+ if (filters.parentUids !== void 0) {
3843
+ extra.parentUids = filters.parentUids.length === 0 ? "" : [...filters.parentUids];
3844
+ }
3845
+ if (filters.ancestorUids !== void 0) {
3846
+ extra.ancestorUids = filters.ancestorUids.length === 0 ? "" : [...filters.ancestorUids];
3847
+ }
3848
+ if (filters.connectionIds !== void 0) {
3849
+ extra.connectionIds = filters.connectionIds.length === 0 ? "" : [...filters.connectionIds];
3850
+ }
3613
3851
  return aipListParams(pageSize, pageToken, extra);
3614
3852
  }
3615
3853
  function parseContextItem2(raw) {
@@ -3626,24 +3864,48 @@ var ManagementContextItemsResource = class {
3626
3864
  * @param options.pageSize - Items per page (default 25).
3627
3865
  * @param options.pageToken - Token from a previous page's `nextPageToken`.
3628
3866
  * @param options.contextType - Filter to one context type (for example `"note"`).
3867
+ * @param options.parentUids - Exact ordered native ancestry chain for direct
3868
+ * children. Omit to leave parent unrestricted; pass `[]` for the known-empty
3869
+ * root. Native UIDs are exact tokens; for a folder's children send ancestry
3870
+ * UIDs plus the last `dataPath` token, not the hashed context-item `uid`.
3871
+ * @param options.ancestorUids - Ordered UID ancestry prefix for strict
3872
+ * descendants. Omit to leave unrestricted; pass `[]` for every item with
3873
+ * non-null ancestry.
3874
+ * @param options.connectionIds - Restrict to these connection ids. Omit to
3875
+ * leave unfiltered; pass `[]` to match none. The Files root is
3876
+ * `connectionIds: ['files']` with `parentUids: []`.
3629
3877
  * @returns A page of context items.
3878
+ *
3879
+ * @example
3880
+ * ```ts
3881
+ * const rootFiles = await mgmt.context.items.list({
3882
+ * connectionIds: ['files'],
3883
+ * contextType: 'file_upload',
3884
+ * parentUids: [],
3885
+ * })
3886
+ * ```
3630
3887
  */
3631
3888
  list(options = {}) {
3632
3889
  const pageSize = options.pageSize ?? 25;
3633
3890
  validatePageSize(pageSize);
3634
- return this.listPage(pageSize, options.pageToken, options.contextType);
3891
+ return this.listPage(pageSize, options.pageToken, {
3892
+ contextType: options.contextType,
3893
+ parentUids: options.parentUids,
3894
+ ancestorUids: options.ancestorUids,
3895
+ connectionIds: options.connectionIds
3896
+ });
3635
3897
  }
3636
- async listPage(pageSize, pageToken, contextType) {
3898
+ async listPage(pageSize, pageToken, filters) {
3637
3899
  const data = asRecord(
3638
3900
  await invokeWithRetry(this.config, this.http, "ContextItemsController_list", {
3639
- query: contextListParams(pageSize, pageToken, contextType)
3901
+ query: contextListParams(pageSize, pageToken, filters)
3640
3902
  })
3641
3903
  );
3642
3904
  return buildAipPage(
3643
3905
  data,
3644
3906
  "contextItems",
3645
3907
  parseContextItem2,
3646
- (token) => this.listPage(pageSize, token, contextType)
3908
+ (token) => this.listPage(pageSize, token, filters)
3647
3909
  );
3648
3910
  }
3649
3911
  /**
@@ -3695,7 +3957,7 @@ var ManagementContextItemsResource = class {
3695
3957
  return this.get(uid);
3696
3958
  }
3697
3959
  /**
3698
- * Delete a context item.
3960
+ * Delete a context item. Deleting a Files folder also deletes all its contents.
3699
3961
  *
3700
3962
  * @param uid - Context item uid.
3701
3963
  * @returns Deletion confirmation details.
@@ -3706,6 +3968,44 @@ var ManagementContextItemsResource = class {
3706
3968
  });
3707
3969
  return data;
3708
3970
  }
3971
+ /**
3972
+ * Move a live file or Files folder.
3973
+ *
3974
+ * Pass `destinationFolderUid: null` to move to the Files root. The
3975
+ * destination folder must already exist. Same-parent moves succeed as a
3976
+ * no-op. Does not rename or merge folders.
3977
+ *
3978
+ * @param uid - Stored context-item uid of the file or folder to move.
3979
+ * @param options.destinationFolderUid - Stored context-item uid of the
3980
+ * destination folder, or `null` for the Files root.
3981
+ * @returns How many items changed parent (`0` is a successful no-op).
3982
+ * @throws {NotFoundError} The source is missing or not visible.
3983
+ * @throws {ModusError} The destination is missing, not a Files folder, or
3984
+ * the move would create a cycle (HTTP 400).
3985
+ * @throws {PermissionDeniedError} The destination exists but is not writable
3986
+ * for this caller.
3987
+ * @throws {ConflictError} A sibling with the same name already exists.
3988
+ *
3989
+ * @example
3990
+ * ```ts
3991
+ * const moved = await mgmt.context.items.move('PLACEHOLDER_UID', {
3992
+ * destinationFolderUid: 'PLACEHOLDER_FOLDER_UID',
3993
+ * })
3994
+ * console.log(moved.movedItems)
3995
+ * ```
3996
+ */
3997
+ async move(uid, options) {
3998
+ const data = await invokeWithRetry(
3999
+ this.config,
4000
+ this.http,
4001
+ "ContextItemsController_move",
4002
+ {
4003
+ pathParams: { uid },
4004
+ jsonBody: { destinationFolderUid: options.destinationFolderUid }
4005
+ }
4006
+ );
4007
+ return data;
4008
+ }
3709
4009
  };
3710
4010
 
3711
4011
  // src/management/context/context.ts
@@ -3863,158 +4163,335 @@ var ManagementContextResource = class {
3863
4163
  }
3864
4164
  };
3865
4165
 
3866
- // src/resources/scopes/conversations.ts
3867
- function parseListItem(raw) {
3868
- return raw;
3869
- }
3870
- function parseConversation(raw) {
3871
- return raw;
3872
- }
3873
- var ScopeConversationsResource = class {
3874
- constructor(http, config, scopeId) {
4166
+ // src/_generated/resources/management/scopes.ts
4167
+ var ScopesResourceBase = class {
4168
+ /** @internal */
4169
+ constructor(http, config) {
3875
4170
  this.http = http;
3876
4171
  this.config = config;
3877
- this.scopeId = scopeId;
3878
4172
  }
3879
4173
  /**
3880
- * List conversation threads for this scope, newest first.
4174
+ * List scopes.
3881
4175
  *
3882
- * @param options.pageSize - Items per page (default 25).
3883
- * @param options.pageToken - Opaque token from a previous page.
3884
- * @param options.source - Restrict to conversations started from this UI surface
3885
- * (e.g. `"context_chat"`, `"dashboard_copilot"`, `"slack"`).
3886
- * @param options.sourceRef - Narrow `source` to one instance of that surface — for
3887
- * `"dashboard_copilot"`, a dashboard id. Requires `source`; the API throws an
3888
- * `UnprocessableError` (422) if sent on its own. Conversations recorded before
3889
- * this filter shipped carry no instance key and never match it.
3890
- * @returns Page of conversation list items (`threadId`, `firstMessage`, `messageCount`).
4176
+ * Returns a paginated page of scopes the caller can at least `use`. Scopes the caller cannot see
4177
+ * are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
4178
+ *
4179
+ * **Requires:** `scopes:read`
4180
+ *
4181
+ * @param options.pageSize - Items per page. Defaults to 25.
4182
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
4183
+ * for the first page.
4184
+ * @param options.search - Case-insensitive substring filter on scope name.
4185
+ * @param options.view - Variation view. `active` reads deployed; `draft` reads the latest builder
4186
+ * snapshot.
4187
+ * @param options.managerId - Return only scopes supervised by this manager scope id.
4188
+ * @returns A page of scopes.
3891
4189
  *
3892
4190
  * @example
3893
4191
  * ```ts
3894
- * for await (const row of (
3895
- * await client.scopes.conversations(scopeId).list({ pageSize: 10 })
3896
- * ).autoPagingIter()) {
3897
- * console.log(row.threadId, row.firstMessage, row.messageCount)
4192
+ * const mgmt = new ModusManagement()
4193
+ * for await (const scope of (await mgmt.scopes.list()).autoPagingIter()) {
4194
+ * console.log(scope.id, scope.name, scope.status)
3898
4195
  * }
3899
4196
  * ```
3900
4197
  */
3901
4198
  list(options = {}) {
3902
4199
  const pageSize = options.pageSize ?? 25;
3903
4200
  validatePageSize(pageSize);
3904
- return this.listPage(pageSize, options.pageToken, options.source, options.sourceRef);
4201
+ return this.listPage(pageSize, options.pageToken, options.search, options.view, options.managerId);
3905
4202
  }
3906
- async listPage(pageSize, pageToken, source, sourceRef) {
3907
- validateId(this.scopeId, "scope_id");
4203
+ async listPage(pageSize, pageToken, search, view, managerId) {
3908
4204
  const extra = {};
3909
- if (source !== void 0) extra.source = source;
3910
- if (sourceRef !== void 0) extra.sourceRef = sourceRef;
4205
+ if (search !== void 0) extra.search = search;
4206
+ if (view !== void 0) extra.view = view;
4207
+ if (managerId !== void 0) extra.managerId = managerId;
3911
4208
  const data = asRecord(
3912
- await invokeWithRetry(this.config, this.http, "ScopeConversationsController_list", {
3913
- pathParams: { id: this.scopeId },
4209
+ await invokeWithRetry(this.config, this.http, "ScopesController_list", {
3914
4210
  query: aipListParams(pageSize, pageToken, extra)
3915
4211
  })
3916
4212
  );
3917
4213
  return buildAipPage(
3918
4214
  data,
3919
- "conversations",
3920
- parseListItem,
3921
- (token) => this.listPage(pageSize, token, source, sourceRef)
4215
+ "scopes",
4216
+ (raw) => raw,
4217
+ (token) => this.listPage(pageSize, token, search, view, managerId)
3922
4218
  );
3923
4219
  }
3924
4220
  /**
3925
- * Retrieve a thread with full message history.
4221
+ * Get a scope.
3926
4222
  *
3927
- * @param threadId - Conversation thread id.
3928
- * @param options.messageLimit - Maximum messages to return (1–100).
3929
- * @param options.beforeMessageIndex - Return messages before this index (requires messageLimit).
3930
- * @returns Conversation with `messages` (`type`, `content`).
4223
+ * Returns a scope. `view=active` (default) returns the deployed version; `view=draft` returns the
4224
+ * latest unpublished edits. Returns 404 if you cannot access the scope.
4225
+ *
4226
+ * **Requires:** `scopes:read`
4227
+ *
4228
+ * @param scopeId - Numeric scope id.
4229
+ * @param options.view - Which variation snapshot to read. Defaults to `active`.
3931
4230
  *
3932
4231
  * @example
3933
4232
  * ```ts
3934
- * const thread = await client.scopes.conversations(scopeId).get(row.threadId)
3935
- * for (const msg of thread.messages) {
3936
- * console.log(msg.type, String(msg.content).slice(0, 80))
3937
- * }
4233
+ * const mgmt = new ModusManagement()
4234
+ * const scope = await mgmt.scopes.get('PLACEHOLDER_SCOPE_ID')
4235
+ * console.log(scope.name, scope.status)
3938
4236
  * ```
3939
4237
  */
3940
- async get(threadId, options = {}) {
3941
- validateId(this.scopeId, "scope_id");
3942
- validateId(threadId, "thread_id");
3943
- if (options.beforeMessageIndex !== void 0 && options.messageLimit === void 0) {
3944
- throw new Error("beforeMessageIndex requires messageLimit");
3945
- }
3946
- const data = await invokeWithRetry(this.config, this.http, "ScopeConversationsController_get", {
3947
- pathParams: { id: this.scopeId, threadId },
3948
- query: {
3949
- messageLimit: options.messageLimit,
3950
- beforeMessageIndex: options.beforeMessageIndex
3951
- }
4238
+ async get(scopeId, options = {}) {
4239
+ validateId(scopeId, "scope_id");
4240
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_get", {
4241
+ pathParams: { id: scopeId },
4242
+ query: { view: options.view }
3952
4243
  });
3953
- return parseConversation(data);
3954
- }
3955
- };
3956
-
3957
- // src/management/scopes/memories.ts
3958
- function parseMemory(raw) {
3959
- return raw;
3960
- }
3961
- var ScopeMemoriesResource = class {
3962
- constructor(http, config, scopeId) {
3963
- this.http = http;
3964
- this.config = config;
3965
- this.scopeId = scopeId;
4244
+ return data;
3966
4245
  }
3967
4246
  /**
3968
- * List memories stored for this scope.
4247
+ * Delete a scope.
3969
4248
  *
3970
- * @param options.pageSize - Items per page (default 25).
3971
- * @param options.pageToken - Token from a previous page's `nextPageToken`.
3972
- * @param options.userId - Optional end-user id when memories are scoped per user.
3973
- * @returns A page of memories.
3974
- */
3975
- list(options = {}) {
3976
- const pageSize = options.pageSize ?? 25;
3977
- validatePageSize(pageSize);
3978
- return this.listPage(pageSize, options.pageToken, options.userId);
3979
- }
3980
- async listPage(pageSize, pageToken, userId) {
3981
- validateId(this.scopeId, "scope_id");
3982
- const extra = {};
3983
- if (userId !== void 0) extra.userId = userId;
3984
- const data = asRecord(
3985
- await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_list", {
3986
- pathParams: { id: this.scopeId },
3987
- query: aipListParams(pageSize, pageToken, extra)
3988
- })
3989
- );
3990
- return buildAipPage(
3991
- data,
3992
- "memories",
3993
- parseMemory,
3994
- (token) => this.listPage(pageSize, token, userId)
3995
- );
3996
- }
3997
- /**
3998
- * Search this scope's memories by natural-language query.
4249
+ * Deletes a scope. The scope can be restored later with POST /scopes/{id}/restore. Deleting an
4250
+ * already-deleted scope is a no-op.
4251
+ *
4252
+ * **Requires:** `scopes:write`
4253
+ *
4254
+ * @param scopeId - Numeric scope id.
3999
4255
  *
4000
- * @param request - Query text and optional `userId` / `limit`.
4001
- * @returns Matching memories and relevance scores.
4256
+ * @example
4257
+ * ```ts
4258
+ * const mgmt = new ModusManagement()
4259
+ * await mgmt.scopes.delete('PLACEHOLDER_SCOPE_ID')
4260
+ * ```
4002
4261
  */
4003
- async search(request) {
4004
- validateId(this.scopeId, "scope_id");
4005
- const data = await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_search", {
4006
- pathParams: { id: this.scopeId },
4007
- jsonBody: omitUndefined(request)
4262
+ async delete(scopeId) {
4263
+ validateId(scopeId, "scope_id");
4264
+ await invokeWithRetry(this.config, this.http, "ScopesController_delete", {
4265
+ pathParams: { id: scopeId }
4008
4266
  });
4009
- return data;
4010
4267
  }
4011
4268
  /**
4012
- * Update one memory. Requires manage permission on the scope.
4269
+ * Restore a deleted scope.
4270
+ *
4271
+ * Restores a previously deleted scope and returns it. Restoring a scope that is already active
4272
+ * returns it unchanged.
4273
+ *
4274
+ * **Requires:** `scopes:write`
4013
4275
  *
4014
- * @param memoryId - Id from list or search.
4015
- * @param update - Fields to change (`memory` and/or `metadata`).
4016
- * @param options.updateMask - Optional comma-separated field names to update.
4017
- * @returns The updated memory.
4276
+ * @param scopeId - Numeric scope id.
4277
+ */
4278
+ async restore(scopeId) {
4279
+ validateId(scopeId, "scope_id");
4280
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_restore", {
4281
+ pathParams: { id: scopeId },
4282
+ jsonBody: {}
4283
+ });
4284
+ return data;
4285
+ }
4286
+ /**
4287
+ * Cancel ownership transfer.
4288
+ *
4289
+ * Cancels a pending ownership transfer. The current owner may cancel; the pending recipient may
4290
+ * decline.
4291
+ *
4292
+ * **Requires:** `scopes:write`
4293
+ *
4294
+ * @param scopeId - Numeric scope id.
4295
+ */
4296
+ async cancelOwnershipTransfer(scopeId) {
4297
+ validateId(scopeId, "scope_id");
4298
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_cancelOwnershipTransfer", {
4299
+ pathParams: { id: scopeId }
4300
+ });
4301
+ return data;
4302
+ }
4303
+ /**
4304
+ * Accept ownership transfer.
4305
+ *
4306
+ * Accepts a pending ownership transfer. Only the pending recipient may invoke this action.
4307
+ *
4308
+ * **Requires:** `scopes:write`
4309
+ *
4310
+ * @param scopeId - Numeric scope id.
4311
+ */
4312
+ async acceptOwnershipTransfer(scopeId) {
4313
+ validateId(scopeId, "scope_id");
4314
+ const data = await invokeWithRetry(this.config, this.http, "ScopesController_acceptOwnershipTransfer", {
4315
+ pathParams: { id: scopeId },
4316
+ jsonBody: {}
4317
+ });
4318
+ return data;
4319
+ }
4320
+ };
4321
+
4322
+ // src/_generated/resources/consumption/scopes/conversations.ts
4323
+ var ScopesConversationsResourceBase = class {
4324
+ /** @internal */
4325
+ constructor(http, config, scopeId) {
4326
+ this.http = http;
4327
+ this.config = config;
4328
+ this.scopeId = scopeId;
4329
+ }
4330
+ /**
4331
+ * List scope conversations.
4332
+ *
4333
+ * Returns a page of conversation summaries (most recently updated first) for a scope. Use `id=0`
4334
+ * for your cross-scope recent history. Pass `nextPageToken` as `pageToken` to fetch the next
4335
+ * page.
4336
+ *
4337
+ * **Requires:** `scopes:read`
4338
+ *
4339
+ * @param options.pageSize - Items per page. Defaults to 25.
4340
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
4341
+ * for the first page.
4342
+ * @param options.source - Return only conversations started from this UI surface.
4343
+ * @param options.sourceRef - Narrow `source` to one instance of that surface — for
4344
+ * `dashboard_copilot` or `dashboard_assistant`, a dashboard id (both scope conversation history
4345
+ * per dashboard). Requires `source`; sent alone it is a 422.
4346
+ * @returns A page of conversations.
4347
+ *
4348
+ * @example
4349
+ * ```ts
4350
+ * for await (const row of (
4351
+ * await client.scopes.conversations(scopeId).list({ pageSize: 10 })
4352
+ * ).autoPagingIter()) {
4353
+ * console.log(row.threadId, row.firstMessage, row.messageCount)
4354
+ * }
4355
+ * ```
4356
+ */
4357
+ list(options = {}) {
4358
+ const pageSize = options.pageSize ?? 25;
4359
+ validatePageSize(pageSize);
4360
+ return this.listPage(pageSize, options.pageToken, options.source, options.sourceRef);
4361
+ }
4362
+ async listPage(pageSize, pageToken, source, sourceRef) {
4363
+ validateId(this.scopeId, "scope_id");
4364
+ const extra = {};
4365
+ if (source !== void 0) extra.source = source;
4366
+ if (sourceRef !== void 0) extra.sourceRef = sourceRef;
4367
+ const data = asRecord(
4368
+ await invokeWithRetry(this.config, this.http, "ScopeConversationsController_list", {
4369
+ pathParams: { id: this.scopeId },
4370
+ query: aipListParams(pageSize, pageToken, extra)
4371
+ })
4372
+ );
4373
+ return buildAipPage(
4374
+ data,
4375
+ "conversations",
4376
+ (raw) => raw,
4377
+ (token) => this.listPage(pageSize, token, source, sourceRef)
4378
+ );
4379
+ }
4380
+ };
4381
+
4382
+ // src/resources/scopes/conversations.ts
4383
+ function parseConversation(raw) {
4384
+ return raw;
4385
+ }
4386
+ var ScopeConversationsResource = class extends ScopesConversationsResourceBase {
4387
+ /**
4388
+ * Retrieve a thread with full message history.
4389
+ *
4390
+ * @param threadId - Conversation thread id.
4391
+ * @param options.messageLimit - Maximum messages to return (1–100).
4392
+ * @param options.beforeMessageIndex - Return messages before this index (requires messageLimit).
4393
+ * @returns Conversation with `messages` (`type`, `content`).
4394
+ *
4395
+ * @example
4396
+ * ```ts
4397
+ * const thread = await client.scopes.conversations(scopeId).get(row.threadId)
4398
+ * for (const msg of thread.messages) {
4399
+ * console.log(msg.type, String(msg.content).slice(0, 80))
4400
+ * }
4401
+ * ```
4402
+ */
4403
+ async get(threadId, options = {}) {
4404
+ validateId(this.scopeId, "scope_id");
4405
+ validateId(threadId, "thread_id");
4406
+ if (options.beforeMessageIndex !== void 0 && options.messageLimit === void 0) {
4407
+ throw new Error("beforeMessageIndex requires messageLimit");
4408
+ }
4409
+ const data = await invokeWithRetry(this.config, this.http, "ScopeConversationsController_get", {
4410
+ pathParams: { id: this.scopeId, threadId },
4411
+ query: {
4412
+ messageLimit: options.messageLimit,
4413
+ beforeMessageIndex: options.beforeMessageIndex
4414
+ }
4415
+ });
4416
+ return parseConversation(data);
4417
+ }
4418
+ };
4419
+
4420
+ // src/_generated/resources/management/scopes/memories.ts
4421
+ var ScopesMemoriesResourceBase = class {
4422
+ /** @internal */
4423
+ constructor(http, config, scopeId) {
4424
+ this.http = http;
4425
+ this.config = config;
4426
+ this.scopeId = scopeId;
4427
+ }
4428
+ /**
4429
+ * List scope memories.
4430
+ *
4431
+ * Returns a page of the scope’s memories (up to 1000 total). Pass `nextPageToken` as `pageToken`
4432
+ * to fetch the next page. Optional `userId` filters to one end user.
4433
+ *
4434
+ * **Requires:** `scopes:read`
4435
+ *
4436
+ * @param options.pageSize - Items per page. Defaults to 25.
4437
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
4438
+ * for the first page.
4439
+ * @param options.userId - Narrow results to memories tagged with this end-user id.
4440
+ * @returns A page of memories.
4441
+ */
4442
+ list(options = {}) {
4443
+ const pageSize = options.pageSize ?? 25;
4444
+ validatePageSize(pageSize);
4445
+ return this.listPage(pageSize, options.pageToken, options.userId);
4446
+ }
4447
+ async listPage(pageSize, pageToken, userId) {
4448
+ validateId(this.scopeId, "scope_id");
4449
+ const extra = {};
4450
+ if (userId !== void 0) extra.userId = userId;
4451
+ const data = asRecord(
4452
+ await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_list", {
4453
+ pathParams: { id: this.scopeId },
4454
+ query: aipListParams(pageSize, pageToken, extra)
4455
+ })
4456
+ );
4457
+ return buildAipPage(
4458
+ data,
4459
+ "memories",
4460
+ (raw) => raw,
4461
+ (token) => this.listPage(pageSize, token, userId)
4462
+ );
4463
+ }
4464
+ /**
4465
+ * Search scope memories.
4466
+ *
4467
+ * Returns memories ranked by semantic similarity to the supplied `query`. Caller must at least
4468
+ * `use` the scope. Optional `userId` and `limit` body fields narrow the result set (legacy parity
4469
+ * with `search-memories`).
4470
+ *
4471
+ * **Requires:** `scopes:read`
4472
+ *
4473
+ * @param request - Request body; see `MemorySearchRequest`.
4474
+ */
4475
+ async search(request) {
4476
+ validateId(this.scopeId, "scope_id");
4477
+ const data = await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_search", {
4478
+ pathParams: { id: this.scopeId },
4479
+ jsonBody: omitUndefined(request)
4480
+ });
4481
+ return data;
4482
+ }
4483
+ /**
4484
+ * Update a memory.
4485
+ *
4486
+ * Updates one memory. Supply at least one of `memory` or `metadata`. Use `updateMask` to limit
4487
+ * which fields change.
4488
+ *
4489
+ * **Requires:** `scopes:write`
4490
+ *
4491
+ * @param memoryId - Opaque memory id as returned by the list / search endpoints.
4492
+ * @param update - Request body; see `MemoryUpdate`.
4493
+ * @param options.updateMask - Comma-separated list of fields to update. Omit to update all
4494
+ * provided fields.
4018
4495
  */
4019
4496
  async update(memoryId, update, options = {}) {
4020
4497
  validateId(memoryId, "memory_id");
@@ -4024,9 +4501,17 @@ var ScopeMemoriesResource = class {
4024
4501
  query: updateMaskQuery(options.updateMask),
4025
4502
  jsonBody: omitUndefined(update)
4026
4503
  });
4027
- return parseMemory(data);
4504
+ return data;
4028
4505
  }
4029
- /** Delete one memory (idempotent). */
4506
+ /**
4507
+ * Delete a memory.
4508
+ *
4509
+ * Deletes one memory. Deleting an already-deleted memory is a no-op.
4510
+ *
4511
+ * **Requires:** `scopes:write`
4512
+ *
4513
+ * @param memoryId - Opaque memory id as returned by the list / search endpoints.
4514
+ */
4030
4515
  async delete(memoryId) {
4031
4516
  validateId(memoryId, "memory_id");
4032
4517
  validateId(this.scopeId, "scope_id");
@@ -4036,32 +4521,42 @@ var ScopeMemoriesResource = class {
4036
4521
  }
4037
4522
  };
4038
4523
 
4039
- // src/management/scopes/evaluations.ts
4040
- function parseConfig(raw) {
4041
- return raw;
4042
- }
4043
- function parseRun(raw) {
4044
- return raw;
4045
- }
4046
- var ScopeEvaluationsResource = class {
4524
+ // src/management/scopes/memories.ts
4525
+ var ScopeMemoriesResource = class extends ScopesMemoriesResourceBase {
4526
+ };
4527
+
4528
+ // src/_generated/resources/management/scopes/evaluations.ts
4529
+ var ScopesEvaluationsResourceBase = class {
4530
+ /** @internal */
4047
4531
  constructor(http, config, scopeId) {
4048
4532
  this.http = http;
4049
4533
  this.config = config;
4050
4534
  this.scopeId = scopeId;
4051
4535
  }
4052
- /** Get the evaluation configuration for this scope. */
4536
+ /**
4537
+ * Get evaluation configuration.
4538
+ *
4539
+ * Returns the evaluation configuration for a scope, including judge settings, schedule cadence,
4540
+ * and notification preferences.
4541
+ *
4542
+ * **Requires:** `scopes:read`
4543
+ */
4053
4544
  async getConfig() {
4054
4545
  validateId(this.scopeId, "scope_id");
4055
4546
  const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_getConfig", {
4056
4547
  pathParams: { id: this.scopeId }
4057
4548
  });
4058
- return parseConfig(data);
4549
+ return data;
4059
4550
  }
4060
4551
  /**
4061
- * Update the evaluation configuration for this scope.
4552
+ * Update evaluation configuration.
4553
+ *
4554
+ * Updates the evaluation configuration for a scope. Changes to the schedule cadence are synced
4555
+ * automatically.
4556
+ *
4557
+ * **Requires:** `scopes:write`
4062
4558
  *
4063
- * @param update - Configuration fields to change.
4064
- * @returns The updated evaluation configuration.
4559
+ * @param update - Request body; see `UpdateEvaluationConfig`.
4065
4560
  */
4066
4561
  async updateConfig(update) {
4067
4562
  validateId(this.scopeId, "scope_id");
@@ -4069,12 +4564,17 @@ var ScopeEvaluationsResource = class {
4069
4564
  pathParams: { id: this.scopeId },
4070
4565
  jsonBody: omitUndefined(update)
4071
4566
  });
4072
- return parseConfig(data);
4567
+ return data;
4073
4568
  }
4074
4569
  /**
4075
- * Trigger a manual evaluation run for this scope.
4570
+ * Trigger evaluation run.
4571
+ *
4572
+ * Triggers a manual evaluation run for the scope. The run executes asynchronously.
4573
+ *
4574
+ * **Requires:** `scopes:write`
4076
4575
  *
4077
- * @returns The triggered run id and status.
4576
+ * @returns Evaluation run accepted and queued. The run executes asynchronously; poll `GET
4577
+ * /scopes/{id}/evaluations/runs/{runId}` for status.
4078
4578
  */
4079
4579
  async triggerRun() {
4080
4580
  validateId(this.scopeId, "scope_id");
@@ -4084,11 +4584,14 @@ var ScopeEvaluationsResource = class {
4084
4584
  return data;
4085
4585
  }
4086
4586
  /**
4087
- * List evaluation runs for this scope.
4587
+ * List evaluation runs.
4088
4588
  *
4089
- * @param options.pageSize - Items per page (default 25).
4090
- * @param options.pageToken - Token from a previous page's `nextPageToken`.
4091
- * @returns A page of evaluation runs.
4589
+ * Returns a paginated list of evaluation runs for the scope, ordered by most recent first.
4590
+ *
4591
+ * **Requires:** `scopes:read`
4592
+ *
4593
+ * @param options.pageSize - Items per page. Defaults to 25.
4594
+ * @returns A page of runs.
4092
4595
  */
4093
4596
  listRuns(options = {}) {
4094
4597
  const pageSize = options.pageSize ?? 25;
@@ -4103,13 +4606,21 @@ var ScopeEvaluationsResource = class {
4103
4606
  query: aipListParams(pageSize, pageToken)
4104
4607
  })
4105
4608
  );
4106
- return buildAipPage(data, "runs", parseRun, (token) => this.listRunsPage(pageSize, token));
4609
+ return buildAipPage(
4610
+ data,
4611
+ "runs",
4612
+ (raw) => raw,
4613
+ (token) => this.listRunsPage(pageSize, token)
4614
+ );
4107
4615
  }
4108
4616
  /**
4109
- * Retrieve one evaluation run with full results.
4617
+ * Get evaluation run.
4618
+ *
4619
+ * Returns details of an evaluation run including all per-case results.
4620
+ *
4621
+ * **Requires:** `scopes:read`
4110
4622
  *
4111
- * @param runId - Evaluation run id.
4112
- * @returns The run and its result details.
4623
+ * @param runId - Run ID.
4113
4624
  */
4114
4625
  async getRun(runId) {
4115
4626
  validateId(this.scopeId, "scope_id");
@@ -4121,53 +4632,157 @@ var ScopeEvaluationsResource = class {
4121
4632
  }
4122
4633
  };
4123
4634
 
4124
- // src/management/scopes/supervision.ts
4125
- var ScopeSupervisionResource = class {
4635
+ // src/management/scopes/evaluations.ts
4636
+ var ScopeEvaluationsResource = class extends ScopesEvaluationsResourceBase {
4637
+ };
4638
+
4639
+ // src/_generated/resources/management/scopes/interfaces.ts
4640
+ var ScopesInterfacesResourceBase = class {
4641
+ /** @internal */
4642
+ constructor(http, config, scopeId) {
4643
+ this.http = http;
4644
+ this.config = config;
4645
+ this.scopeId = scopeId;
4646
+ }
4647
+ /**
4648
+ * List the chat interfaces of a scope.
4649
+ *
4650
+ * Returns the chat interfaces (at most one per chat platform) that let people use this scope from
4651
+ * chat. Requires manage permission on the scope, because the config lists allowed emails.
4652
+ *
4653
+ * **Requires:** `scopes:read`
4654
+ */
4655
+ async list() {
4656
+ validateId(this.scopeId, "scope_id");
4657
+ const data = await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_list", {
4658
+ pathParams: { id: this.scopeId }
4659
+ });
4660
+ return data.interfaces;
4661
+ }
4662
+ /**
4663
+ * Remove a scope interface.
4664
+ *
4665
+ * Removes one chat interface from the scope. Mentions on that chat platform stop reaching this
4666
+ * scope immediately.
4667
+ *
4668
+ * **Requires:** `scopes:write`
4669
+ *
4670
+ * @param interfaceId - Interface id (UUID).
4671
+ */
4672
+ async delete(interfaceId) {
4673
+ validateId(this.scopeId, "scope_id");
4674
+ validateId(interfaceId, "interface_id");
4675
+ await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_delete", {
4676
+ pathParams: { id: this.scopeId, interfaceId }
4677
+ });
4678
+ }
4679
+ };
4680
+
4681
+ // src/management/scopes/interfaces.ts
4682
+ var ScopeInterfacesResource = class extends ScopesInterfacesResourceBase {
4683
+ /**
4684
+ * Add a Slack or Microsoft Teams interface to this scope.
4685
+ *
4686
+ * @param options - Interface type, optional name and config.
4687
+ * @returns The created interface.
4688
+ */
4689
+ async create(options) {
4690
+ validateId(this.scopeId, "scope_id");
4691
+ return await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_add", {
4692
+ pathParams: { id: this.scopeId },
4693
+ jsonBody: omitUndefined(options)
4694
+ });
4695
+ }
4696
+ /**
4697
+ * Update an interface on this scope.
4698
+ *
4699
+ * @param interfaceId - Interface id.
4700
+ * @param options - Updated name and/or config.
4701
+ * @param updateMask - Optional comma-separated field names to update.
4702
+ * @returns The updated interface.
4703
+ */
4704
+ async update(interfaceId, options, updateMask) {
4705
+ validateId(this.scopeId, "scope_id");
4706
+ validateId(interfaceId, "interface_id");
4707
+ return await invokeWithRetry(this.config, this.http, "ScopeInterfacesController_update", {
4708
+ pathParams: { id: this.scopeId, interfaceId },
4709
+ query: updateMaskQuery(updateMask),
4710
+ jsonBody: updateMask === void 0 ? omitUndefined(options) : options
4711
+ });
4712
+ }
4713
+ };
4714
+
4715
+ // src/_generated/resources/management/scopes/supervision.ts
4716
+ var ScopesSupervisionResourceBase = class {
4717
+ /** @internal */
4126
4718
  constructor(http, config, scopeId) {
4127
4719
  this.http = http;
4128
4720
  this.config = config;
4129
4721
  this.scopeId = scopeId;
4130
4722
  }
4131
4723
  /**
4132
- * Get this scope's supervision configuration.
4724
+ * Read the scope subordinate supervision list.
4133
4725
  *
4134
- * @param options.view - Optional scope variation to inspect.
4135
- * @returns The supervision configuration.
4726
+ * Returns the list of subordinate scope ids managed by this scope. `?view=active` (default) reads
4727
+ * the deployed supervision set; `?view=draft` reads the most recent builder snapshot. Returns 404
4728
+ * when the caller cannot at least `use` the scope.
4729
+ *
4730
+ * **Requires:** `scopes:read`
4731
+ *
4732
+ * @param options.view - Which variation snapshot to read. Defaults to `active`.
4136
4733
  */
4137
4734
  async get(options = {}) {
4138
4735
  validateId(this.scopeId, "scope_id");
4139
- return await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_get", {
4736
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_get", {
4140
4737
  pathParams: { id: this.scopeId },
4141
- query: options.view === void 0 ? void 0 : { view: options.view }
4738
+ query: { view: options.view }
4142
4739
  });
4740
+ return data;
4143
4741
  }
4144
4742
  /**
4145
- * Replace this scope's subordinate scopes.
4743
+ * Replace draft subordinate supervision list.
4744
+ *
4745
+ * Writes the supplied subordinate id list into the draft variation. Replaces the previous list
4746
+ * fully — supply an empty array to clear all subordinates. Requires manage permission on the
4747
+ * supervisor; the change is not visible to runners until the scope is deployed.
4146
4748
  *
4147
- * @param request - Replacement supervision configuration.
4148
- * @returns The updated supervision configuration.
4749
+ * **Requires:** `scopes:write`
4750
+ *
4751
+ * @param request - Request body; see `SetSupervisionRequest`.
4149
4752
  */
4150
4753
  async set(request) {
4151
- return this.write("ScopeSupervisionController_set", request);
4754
+ validateId(this.scopeId, "scope_id");
4755
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_set", {
4756
+ pathParams: { id: this.scopeId },
4757
+ jsonBody: request
4758
+ });
4759
+ return data;
4152
4760
  }
4153
4761
  /**
4154
- * Replace subordinate scopes on the active (deployed) scope version.
4762
+ * Replace active subordinate supervision list.
4155
4763
  *
4156
- * @param request - Replacement supervision configuration.
4157
- * @returns The updated supervision configuration.
4764
+ * Writes directly into the active variation supervision set, bypassing the draft deploy cycle.
4765
+ * Requires `scopes:write` plus manage permission on the supervisor. Use to correct a live
4766
+ * supervision graph without going through the builder.
4767
+ *
4768
+ * **Requires:** `scopes:write`
4769
+ *
4770
+ * @param request - Request body; see `SetSupervisionRequest`.
4158
4771
  */
4159
4772
  async setActive(request) {
4160
- return this.write("ScopeSupervisionController_setActive", request);
4161
- }
4162
- async write(operation, request) {
4163
4773
  validateId(this.scopeId, "scope_id");
4164
- return await invokeWithRetry(this.config, this.http, operation, {
4774
+ const data = await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_setActive", {
4165
4775
  pathParams: { id: this.scopeId },
4166
4776
  jsonBody: request
4167
4777
  });
4778
+ return data;
4168
4779
  }
4169
4780
  };
4170
4781
 
4782
+ // src/management/scopes/supervision.ts
4783
+ var ScopeSupervisionResource = class extends ScopesSupervisionResourceBase {
4784
+ };
4785
+
4171
4786
  // src/management/scopes/skills.ts
4172
4787
  var MANAGEMENT_SCOPE_OPERATIONS = {
4173
4788
  list: "ScopesController_list",
@@ -4183,21 +4798,12 @@ var MANAGEMENT_SCOPE_OPERATIONS = {
4183
4798
  patchMcpConfig: "ScopesController_patchMcpConfig",
4184
4799
  getVariation: "ScopesController_getVariation"
4185
4800
  };
4186
- function scopesListParams(pageSize, pageToken, search, view, managerId) {
4187
- const extra = {};
4188
- if (search !== void 0) extra.search = search;
4189
- if (view !== void 0) extra.view = view;
4190
- if (managerId !== void 0) extra.managerId = managerId;
4191
- return aipListParams(pageSize, pageToken, extra);
4192
- }
4193
4801
  function parseScope(raw) {
4194
4802
  return raw;
4195
4803
  }
4196
- var ManagementScopesResource = class {
4197
- /** @internal */
4198
- constructor(http, config) {
4199
- this.http = http;
4200
- this.config = config;
4804
+ var ManagementScopesResource = class extends ScopesResourceBase {
4805
+ constructor() {
4806
+ super(...arguments);
4201
4807
  this.ops = MANAGEMENT_SCOPE_OPERATIONS;
4202
4808
  }
4203
4809
  /**
@@ -4237,67 +4843,13 @@ var ManagementScopesResource = class {
4237
4843
  return new ScopeSupervisionResource(this.http, this.config, scopeId);
4238
4844
  }
4239
4845
  /**
4240
- * List scopes in the organization.
4241
- *
4242
- * @param options.pageSize - Maximum items per page (default 25).
4243
- * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
4244
- * @param options.search - Case-insensitive substring filter on the scope name.
4245
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
4246
- * @param options.managerId - Return only scopes supervised by this manager scope id.
4247
- * @returns A page of scopes — use `.autoPagingIter()` for all pages.
4248
- * @example
4249
- * ```ts
4250
- * const mgmt = new ModusManagement()
4251
- * for await (const scope of (await mgmt.scopes.list()).autoPagingIter()) {
4252
- * console.log(scope.id, scope.name, scope.status)
4253
- * }
4254
- * ```
4255
- */
4256
- list(options = {}) {
4257
- const pageSize = options.pageSize ?? 25;
4258
- validatePageSize(pageSize);
4259
- return this.listPage(
4260
- pageSize,
4261
- options.pageToken,
4262
- options.search,
4263
- options.view,
4264
- options.managerId
4265
- );
4266
- }
4267
- async listPage(pageSize, pageToken, search, view, managerId) {
4268
- const data = asRecord(
4269
- await invokeWithRetry(this.config, this.http, this.ops.list, {
4270
- query: scopesListParams(pageSize, pageToken, search, view, managerId)
4271
- })
4272
- );
4273
- return buildAipPage(
4274
- data,
4275
- "scopes",
4276
- parseScope,
4277
- (token) => this.listPage(pageSize, token, search, view, managerId)
4278
- );
4279
- }
4280
- /**
4281
- * Retrieve a scope with full configuration.
4846
+ * Slack and Microsoft Teams interfaces for a scope.
4282
4847
  *
4283
4848
  * @param scopeId - Scope id.
4284
- * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
4285
- * @returns The scope.
4286
- * @example
4287
- * ```ts
4288
- * const mgmt = new ModusManagement()
4289
- * const scope = await mgmt.scopes.get('PLACEHOLDER_SCOPE_ID')
4290
- * console.log(scope.name, scope.status)
4291
- * ```
4849
+ * @returns An interfaces resource scoped to the scope.
4292
4850
  */
4293
- async get(scopeId, options = {}) {
4294
- validateId(scopeId, "scope_id");
4295
- const query = options.view !== void 0 ? { view: options.view } : void 0;
4296
- const data = await invokeWithRetry(this.config, this.http, this.ops.get, {
4297
- pathParams: { id: scopeId },
4298
- query
4299
- });
4300
- return parseScope(data);
4851
+ interfaces(scopeId) {
4852
+ return new ScopeInterfacesResource(this.http, this.config, scopeId);
4301
4853
  }
4302
4854
  /**
4303
4855
  * Create a new scope in the organization.
@@ -4307,6 +4859,7 @@ var ManagementScopesResource = class {
4307
4859
  * @param options.instructions - Optional system instructions.
4308
4860
  * @param options.model - Optional model id.
4309
4861
  * @param options.toolset - Optional tool selection for the scope.
4862
+ * @param options.includeOwnLearnings - Whether the scope reads what is taught while using it. Defaults to true.
4310
4863
  * @param options.guardrails - Runtime guardrail labels (for example `"no-pii"`). Omit to create with no guardrails.
4311
4864
  * @returns The created scope (draft).
4312
4865
  * @example
@@ -4326,6 +4879,7 @@ var ManagementScopesResource = class {
4326
4879
  model: options.model,
4327
4880
  connectionSet: options.connectionSet,
4328
4881
  contextSelections: options.contextSelections,
4882
+ includeOwnLearnings: options.includeOwnLearnings,
4329
4883
  interfaces: options.interfaces,
4330
4884
  accessConfig: accessConfigBodyForCreate(options.guardrails)
4331
4885
  });
@@ -4408,37 +4962,6 @@ var ManagementScopesResource = class {
4408
4962
  );
4409
4963
  return parseScope(data.scope);
4410
4964
  }
4411
- /**
4412
- * Delete a scope.
4413
- *
4414
- * @param scopeId - Scope id.
4415
- * @returns Resolves when the scope is deleted.
4416
- * @example
4417
- * ```ts
4418
- * const mgmt = new ModusManagement()
4419
- * await mgmt.scopes.delete('PLACEHOLDER_SCOPE_ID')
4420
- * ```
4421
- */
4422
- async delete(scopeId) {
4423
- validateId(scopeId, "scope_id");
4424
- await invokeWithRetry(this.config, this.http, this.ops.delete, {
4425
- pathParams: { id: scopeId }
4426
- });
4427
- }
4428
- /**
4429
- * Restore a previously deleted scope.
4430
- *
4431
- * @param scopeId - Scope id.
4432
- * @returns The restored scope.
4433
- */
4434
- async restore(scopeId) {
4435
- validateId(scopeId, "scope_id");
4436
- const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
4437
- pathParams: { id: scopeId },
4438
- jsonBody: {}
4439
- });
4440
- return parseScope(data);
4441
- }
4442
4965
  /**
4443
4966
  * Start transferring ownership of a scope to another organization member.
4444
4967
  *
@@ -4459,28 +4982,6 @@ var ManagementScopesResource = class {
4459
4982
  );
4460
4983
  return parseScope(data);
4461
4984
  }
4462
- /** Cancel a pending scope ownership transfer. */
4463
- async cancelOwnershipTransfer(scopeId) {
4464
- validateId(scopeId, "scope_id");
4465
- const data = await invokeWithRetry(
4466
- this.config,
4467
- this.http,
4468
- this.ops.cancelOwnershipTransfer,
4469
- { pathParams: { id: scopeId } }
4470
- );
4471
- return parseScope(data);
4472
- }
4473
- /** Accept a pending scope ownership transfer. */
4474
- async acceptOwnershipTransfer(scopeId) {
4475
- validateId(scopeId, "scope_id");
4476
- const data = await invokeWithRetry(
4477
- this.config,
4478
- this.http,
4479
- this.ops.acceptOwnershipTransfer,
4480
- { pathParams: { id: scopeId }, jsonBody: {} }
4481
- );
4482
- return parseScope(data);
4483
- }
4484
4985
  /**
4485
4986
  * Update MCP server configuration for a scope.
4486
4987
  *
@@ -4511,12 +5012,35 @@ var ManagementScopesResource = class {
4511
5012
  }
4512
5013
  };
4513
5014
 
4514
- // src/management/usage.ts
4515
- var ManagementUsageResource = class {
5015
+ // src/_generated/resources/management/usage.ts
5016
+ var UsageResourceBase = class {
5017
+ /** @internal */
4516
5018
  constructor(http, config) {
4517
5019
  this.http = http;
4518
5020
  this.config = config;
4519
5021
  }
5022
+ /**
5023
+ * List usage users.
5024
+ *
5025
+ * Returns the distinct acting-user emails that appear in your organization's LLM usage over the
5026
+ * `[since, until)` window. Feeds the usage page's user filter (includes non-Modus Slack/Teams
5027
+ * users). Scoped to your organization.
5028
+ *
5029
+ * **Requires:** `usage:read`
5030
+ *
5031
+ * @param options.since - ISO8601 start of the query window (inclusive).
5032
+ * @param options.until - ISO8601 end of the query window (exclusive).
5033
+ */
5034
+ async listUsers(options) {
5035
+ const data = await invokeWithRetry(this.config, this.http, "UsageController_listUsers", {
5036
+ query: { since: options.since, until: options.until }
5037
+ });
5038
+ return data;
5039
+ }
5040
+ };
5041
+
5042
+ // src/management/usage.ts
5043
+ var ManagementUsageResource = class extends UsageResourceBase {
4520
5044
  /**
4521
5045
  * List usage metrics for your organization over a time window.
4522
5046
  *
@@ -4540,42 +5064,27 @@ var ManagementUsageResource = class {
4540
5064
  const data = await invokeWithRetry(this.config, this.http, "UsageController_list", { query });
4541
5065
  return data;
4542
5066
  }
4543
- /**
4544
- * List distinct acting-user emails observed in a time window.
4545
- *
4546
- * @param options.since - Start of the window (ISO 8601, inclusive).
4547
- * @param options.until - End of the window (ISO 8601, exclusive).
4548
- * @returns User emails seen in usage during the window.
4549
- * @throws {UnprocessableError} When the request is rejected by the API.
4550
- * @throws {AuthenticationError} When the API key is invalid or missing.
4551
- */
4552
- async listUsers(options) {
4553
- const query = {
4554
- since: options.since,
4555
- until: options.until
4556
- };
4557
- const data = await invokeWithRetry(this.config, this.http, "UsageController_listUsers", {
4558
- query
4559
- });
4560
- return data;
4561
- }
4562
5067
  };
4563
5068
 
4564
- // src/management/tools.ts
4565
- function parseToolCatalogEntry(raw) {
4566
- return raw;
4567
- }
4568
- var ManagementToolsResource = class {
5069
+ // src/_generated/resources/management/tools.ts
5070
+ var ToolsResourceBase = class {
5071
+ /** @internal */
4569
5072
  constructor(http, config) {
4570
5073
  this.http = http;
4571
5074
  this.config = config;
4572
5075
  }
4573
5076
  /**
4574
- * List tool and integration surfaces a scope can select in its toolset.
5077
+ * List available tools.
4575
5078
  *
4576
- * @param options.pageSize - Maximum items per page (default 25).
4577
- * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
4578
- * @returns A page of tool catalog entries.
5079
+ * Returns a page of known tool/integration surfaces a scope can select in its toolset, with the
5080
+ * fixed actions for built-in tools.
5081
+ *
5082
+ * **Requires:** `scopes:read`
5083
+ *
5084
+ * @param options.pageSize - Items per page. Defaults to 25.
5085
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
5086
+ * for the first page.
5087
+ * @returns A page of tools.
4579
5088
  */
4580
5089
  list(options = {}) {
4581
5090
  const pageSize = options.pageSize ?? 25;
@@ -4588,10 +5097,19 @@ var ManagementToolsResource = class {
4588
5097
  query: aipListParams(pageSize, pageToken)
4589
5098
  })
4590
5099
  );
4591
- return buildAipPage(data, "tools", parseToolCatalogEntry, (token) => this.listPage(pageSize, token));
5100
+ return buildAipPage(
5101
+ data,
5102
+ "tools",
5103
+ (raw) => raw,
5104
+ (token) => this.listPage(pageSize, token)
5105
+ );
4592
5106
  }
4593
5107
  };
4594
5108
 
5109
+ // src/management/tools.ts
5110
+ var ManagementToolsResource = class extends ToolsResourceBase {
5111
+ };
5112
+
4595
5113
  // src/management/users.ts
4596
5114
  var ManagementUsersResource = class {
4597
5115
  constructor(http, config) {