@getmodus/sdk 0.2.3 → 0.4.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.
@@ -122,6 +122,19 @@ function resolveBaseUrl(baseUrl) {
122
122
  function resolveAgentHost(agentHost) {
123
123
  return agentHost ?? process.env[ENV_AGENT_HOST] ?? void 0;
124
124
  }
125
+ function isModusApiHostname(hostname) {
126
+ return hostname === "api.getmodus.com" || /^api\.[a-z0-9-]+\.getmodus\.com$/i.test(hostname);
127
+ }
128
+ function deriveAgentHostFromBaseUrl(baseUrl) {
129
+ try {
130
+ const url = new URL(baseUrl);
131
+ if (!isModusApiHostname(url.hostname)) return void 0;
132
+ url.hostname = `agent.${url.hostname.slice("api.".length)}`;
133
+ return url.origin;
134
+ } catch {
135
+ return void 0;
136
+ }
137
+ }
125
138
  function resolveOrganizationId(organizationId) {
126
139
  const raw = organizationId ?? process.env[ENV_ORGANIZATION_ID];
127
140
  if (raw === void 0) return void 0;
@@ -173,7 +186,7 @@ function createModusConfig(options = {}) {
173
186
  const baseUrl = normalizeBaseUrl(resolveBaseUrl(options.baseUrl) ?? DEFAULT_BASE_URL);
174
187
  const baseUrlOverrides = normalizeBaseUrls(options.baseUrls);
175
188
  const agentHost = normalizeBaseUrl(
176
- baseUrlOverrides["agent-service"] ?? resolveAgentHost(options.agentHost) ?? DEFAULT_AGENT_HOST
189
+ baseUrlOverrides["agent-service"] ?? resolveAgentHost(options.agentHost) ?? deriveAgentHostFromBaseUrl(baseUrl) ?? DEFAULT_AGENT_HOST
177
190
  );
178
191
  const organizationId = resolveOrganizationId(options.organizationId);
179
192
  return Object.freeze({
@@ -203,7 +216,7 @@ function formatConfigForLog(config) {
203
216
  }
204
217
 
205
218
  // src/_http.ts
206
- var USER_AGENT = `modus-typescript/${"0.2.3"} (node/${process.version}; ${process.platform})`;
219
+ var USER_AGENT = `modus-typescript/${"0.4.0"} (node/${process.version}; ${process.platform})`;
207
220
  function buildUrl(baseUrl, path, params) {
208
221
  const url = new URL(path.startsWith("/") ? path : `/${path}`, baseUrl);
209
222
  if (params) {
@@ -461,9 +474,20 @@ var Page = class {
461
474
  this.nextPageToken = normalizePageToken(nextPageToken);
462
475
  this.fetchPage = fetchPage;
463
476
  }
477
+ /**
478
+ * Whether another page of results is available.
479
+ *
480
+ * @returns `true` when {@link Page.nextPageToken} is set.
481
+ */
464
482
  hasNextPage() {
465
483
  return this.nextPageToken !== void 0;
466
484
  }
485
+ /**
486
+ * Fetch the next page using {@link Page.nextPageToken}.
487
+ *
488
+ * @returns The following page of results.
489
+ * @throws {Error} When there is no next page. Check {@link Page.hasNextPage} first.
490
+ */
467
491
  async getNextPage() {
468
492
  if (this.nextPageToken === void 0) {
469
493
  throw new Error(
@@ -472,6 +496,12 @@ var Page = class {
472
496
  }
473
497
  return this.fetchPage(this.nextPageToken);
474
498
  }
499
+ /**
500
+ * Async-iterate over all items across every page, fetching additional pages as needed.
501
+ *
502
+ * @returns An async generator yielding every item in the result set.
503
+ * @throws {ModusError} When a follow-up page request fails.
504
+ */
475
505
  async *autoPagingIter() {
476
506
  for (const item of this.items) yield item;
477
507
  let nextPageToken = this.nextPageToken;
@@ -481,6 +511,7 @@ var Page = class {
481
511
  nextPageToken = page.nextPageToken;
482
512
  }
483
513
  }
514
+ /** Iterate over the current page's items only. */
484
515
  [Symbol.iterator]() {
485
516
  return this.items[Symbol.iterator]();
486
517
  }
@@ -737,7 +768,7 @@ var OPERATIONS = {
737
768
  service: "modus-api",
738
769
  serverUrl: "https://api.getmodus.com",
739
770
  pathParams: [],
740
- queryParams: ["pageSize", "pageToken"],
771
+ queryParams: [],
741
772
  requestSchema: null,
742
773
  responseSchema: "ListMemberGroupsResponseDto"
743
774
  },
@@ -807,19 +838,9 @@ var OPERATIONS = {
807
838
  service: "modus-api",
808
839
  serverUrl: "https://api.getmodus.com",
809
840
  pathParams: [],
810
- queryParams: ["pageSize", "pageToken"],
811
- requestSchema: null,
812
- responseSchema: "ListOrgMembersResponseDto"
813
- },
814
- "OrganizationController_deleteOrganization": {
815
- method: "DELETE",
816
- path: "/api/v1/users/organization",
817
- service: "modus-api",
818
- serverUrl: "https://api.getmodus.com",
819
- pathParams: [],
820
841
  queryParams: [],
821
842
  requestSchema: null,
822
- responseSchema: null
843
+ responseSchema: "ListOrgMembersResponseDto"
823
844
  },
824
845
  "ResumeRunsController_create": {
825
846
  method: "POST",
@@ -1039,7 +1060,7 @@ var OPERATIONS = {
1039
1060
  pathParams: ["id"],
1040
1061
  queryParams: [],
1041
1062
  requestSchema: null,
1042
- responseSchema: "SkillDto"
1063
+ responseSchema: "ScopeDto"
1043
1064
  },
1044
1065
  "ScopesController_cancelOwnershipTransfer": {
1045
1066
  method: "DELETE",
@@ -1049,7 +1070,7 @@ var OPERATIONS = {
1049
1070
  pathParams: ["id"],
1050
1071
  queryParams: [],
1051
1072
  requestSchema: null,
1052
- responseSchema: "SkillDto"
1073
+ responseSchema: "ScopeDto"
1053
1074
  },
1054
1075
  "ScopesController_create": {
1055
1076
  method: "POST",
@@ -1059,7 +1080,7 @@ var OPERATIONS = {
1059
1080
  pathParams: [],
1060
1081
  queryParams: [],
1061
1082
  requestSchema: "CreateSkillDto",
1062
- responseSchema: "SkillDto"
1083
+ responseSchema: "ScopeDto"
1063
1084
  },
1064
1085
  "ScopesController_delete": {
1065
1086
  method: "DELETE",
@@ -1089,7 +1110,7 @@ var OPERATIONS = {
1089
1110
  pathParams: ["id"],
1090
1111
  queryParams: ["view"],
1091
1112
  requestSchema: null,
1092
- responseSchema: "SkillDto"
1113
+ responseSchema: "ScopeDto"
1093
1114
  },
1094
1115
  "ScopesController_getVariation": {
1095
1116
  method: "GET",
@@ -1099,7 +1120,7 @@ var OPERATIONS = {
1099
1120
  pathParams: ["id", "variationUid"],
1100
1121
  queryParams: [],
1101
1122
  requestSchema: null,
1102
- responseSchema: "SkillDto"
1123
+ responseSchema: "ScopeDto"
1103
1124
  },
1104
1125
  "ScopesController_list": {
1105
1126
  method: "GET",
@@ -1129,7 +1150,7 @@ var OPERATIONS = {
1129
1150
  pathParams: ["id"],
1130
1151
  queryParams: [],
1131
1152
  requestSchema: "TransferOwnershipDto",
1132
- responseSchema: "SkillDto"
1153
+ responseSchema: "ScopeDto"
1133
1154
  },
1134
1155
  "ScopesController_restore": {
1135
1156
  method: "POST",
@@ -1139,7 +1160,7 @@ var OPERATIONS = {
1139
1160
  pathParams: ["id"],
1140
1161
  queryParams: [],
1141
1162
  requestSchema: null,
1142
- responseSchema: "SkillDto"
1163
+ responseSchema: "ScopeDto"
1143
1164
  },
1144
1165
  "ScopesController_update": {
1145
1166
  method: "PATCH",
@@ -1149,7 +1170,7 @@ var OPERATIONS = {
1149
1170
  pathParams: ["id"],
1150
1171
  queryParams: ["updateMask"],
1151
1172
  requestSchema: "UpdateSkillDto",
1152
- responseSchema: "SkillDto"
1173
+ responseSchema: "ScopeDto"
1153
1174
  },
1154
1175
  "SuggestionsController_listApproved": {
1155
1176
  method: "GET",
@@ -1157,7 +1178,7 @@ var OPERATIONS = {
1157
1178
  service: "modus-api",
1158
1179
  serverUrl: "https://api.getmodus.com",
1159
1180
  pathParams: [],
1160
- queryParams: ["pageToken", "pageSize", "skill_id", "skill_ids"],
1181
+ queryParams: ["pageToken", "pageSize", "scopeId", "scopeIds"],
1161
1182
  requestSchema: null,
1162
1183
  responseSchema: "ListSuggestionQuestionsResponseDto"
1163
1184
  },
@@ -1171,16 +1192,36 @@ var OPERATIONS = {
1171
1192
  requestSchema: "RecordSuggestionEventDto",
1172
1193
  responseSchema: null
1173
1194
  },
1195
+ "ToolsController_list": {
1196
+ method: "GET",
1197
+ path: "/api/v1/tools",
1198
+ service: "modus-api",
1199
+ serverUrl: "https://api.getmodus.com",
1200
+ pathParams: [],
1201
+ queryParams: ["pageToken", "pageSize"],
1202
+ requestSchema: null,
1203
+ responseSchema: "ListToolsResponseDto"
1204
+ },
1174
1205
  "UsageController_list": {
1175
1206
  method: "GET",
1176
1207
  path: "/api/v1/usage",
1177
1208
  service: "modus-api",
1178
1209
  serverUrl: "https://api.getmodus.com",
1179
1210
  pathParams: [],
1180
- queryParams: ["since", "until", "rollup", "model", "group_by", "skill_id", "agent_id", "user_id", "interface"],
1211
+ queryParams: ["since", "until", "rollup", "model", "group_by", "skill_id", "agent_id", "user_id", "interface", "user_email"],
1181
1212
  requestSchema: null,
1182
1213
  responseSchema: "ListUsageResponseDto"
1183
1214
  },
1215
+ "UsageController_listUsers": {
1216
+ method: "GET",
1217
+ path: "/api/v1/usage/users",
1218
+ service: "modus-api",
1219
+ serverUrl: "https://api.getmodus.com",
1220
+ pathParams: [],
1221
+ queryParams: ["since", "until"],
1222
+ requestSchema: null,
1223
+ responseSchema: "ListUsageUsersResponseDto"
1224
+ },
1184
1225
  "WorkflowActionsController_cancel": {
1185
1226
  method: "POST",
1186
1227
  path: "/agent/v1/workflow-actions/{runId}/cancel",
@@ -1237,7 +1278,7 @@ var OPERATIONS = {
1237
1278
  service: "modus-api",
1238
1279
  serverUrl: "https://api.getmodus.com",
1239
1280
  pathParams: ["id"],
1240
- queryParams: ["pageSize", "pageToken"],
1281
+ queryParams: [],
1241
1282
  requestSchema: null,
1242
1283
  responseSchema: "ListAgentInterfacesResponseDto"
1243
1284
  },
@@ -1289,7 +1330,7 @@ var OPERATIONS = {
1289
1330
  pathParams: ["id"],
1290
1331
  queryParams: [],
1291
1332
  requestSchema: null,
1292
- responseSchema: "AgentDto"
1333
+ responseSchema: "WorkflowDto"
1293
1334
  },
1294
1335
  "WorkflowsController_cancelOwnershipTransfer": {
1295
1336
  method: "DELETE",
@@ -1299,7 +1340,7 @@ var OPERATIONS = {
1299
1340
  pathParams: ["id"],
1300
1341
  queryParams: [],
1301
1342
  requestSchema: null,
1302
- responseSchema: "AgentDto"
1343
+ responseSchema: "WorkflowDto"
1303
1344
  },
1304
1345
  "WorkflowsController_create": {
1305
1346
  method: "POST",
@@ -1309,7 +1350,7 @@ var OPERATIONS = {
1309
1350
  pathParams: [],
1310
1351
  queryParams: [],
1311
1352
  requestSchema: "CreateAgentDto",
1312
- responseSchema: "AgentDto"
1353
+ responseSchema: "WorkflowDto"
1313
1354
  },
1314
1355
  "WorkflowsController_delete": {
1315
1356
  method: "DELETE",
@@ -1339,7 +1380,7 @@ var OPERATIONS = {
1339
1380
  pathParams: ["id"],
1340
1381
  queryParams: ["view"],
1341
1382
  requestSchema: null,
1342
- responseSchema: "AgentDto"
1383
+ responseSchema: "WorkflowDto"
1343
1384
  },
1344
1385
  "WorkflowsController_list": {
1345
1386
  method: "GET",
@@ -1359,7 +1400,7 @@ var OPERATIONS = {
1359
1400
  pathParams: ["id"],
1360
1401
  queryParams: [],
1361
1402
  requestSchema: "TransferOwnershipDto",
1362
- responseSchema: "AgentDto"
1403
+ responseSchema: "WorkflowDto"
1363
1404
  },
1364
1405
  "WorkflowsController_restore": {
1365
1406
  method: "POST",
@@ -1369,7 +1410,7 @@ var OPERATIONS = {
1369
1410
  pathParams: ["id"],
1370
1411
  queryParams: [],
1371
1412
  requestSchema: null,
1372
- responseSchema: "AgentDto"
1413
+ responseSchema: "WorkflowDto"
1373
1414
  },
1374
1415
  "WorkflowsController_toggle": {
1375
1416
  method: "POST",
@@ -1379,7 +1420,7 @@ var OPERATIONS = {
1379
1420
  pathParams: ["id"],
1380
1421
  queryParams: [],
1381
1422
  requestSchema: "ToggleAgentDto",
1382
- responseSchema: "AgentDto"
1423
+ responseSchema: "WorkflowDto"
1383
1424
  },
1384
1425
  "WorkflowsController_update": {
1385
1426
  method: "PATCH",
@@ -1389,7 +1430,7 @@ var OPERATIONS = {
1389
1430
  pathParams: ["id"],
1390
1431
  queryParams: ["updateMask"],
1391
1432
  requestSchema: "UpdateAgentDto",
1392
- responseSchema: "AgentDto"
1433
+ responseSchema: "WorkflowDto"
1393
1434
  }
1394
1435
  };
1395
1436
 
@@ -1508,7 +1549,7 @@ var WRITE_BODY_ALLOWED_KEYS = {
1508
1549
  ScopesController_update: ["name", "description", "expectedOutput", "instructions", "toolset", "model", "connectionSet", "contextSelections", "interfaces", "accessConfig", "managerId", "evaluations", "supervisionSubordinateDescriptions"],
1509
1550
  ScopeSupervisionController_set: ["subordinateAgentIds"],
1510
1551
  ScopeSupervisionController_setActive: ["subordinateAgentIds"],
1511
- SuggestionsController_recordEvent: ["event_type", "source", "skill_id", "thread_id", "metadata"],
1552
+ SuggestionsController_recordEvent: ["eventType", "source", "skillId", "threadId", "metadata"],
1512
1553
  WorkflowActionsController_cancel: [],
1513
1554
  WorkflowActionsController_execute: ["organizationId", "sessionId", "fileThreadId", "workflowAction", "previousOutputs", "userTimezone", "runId", "automationId", "source"],
1514
1555
  WorkflowInterfacesController_add: ["type", "name", "config"],
@@ -1607,13 +1648,14 @@ async function accessConfigBodyForUpdate(guardrails, loadResource) {
1607
1648
  return accessConfigWireForUpdate(existing, guardrails);
1608
1649
  }
1609
1650
 
1610
- // src/management/agents/interfaces.ts
1651
+ // src/management/workflows/interfaces.ts
1611
1652
  var WorkflowInterfacesResource = class {
1612
1653
  constructor(http, config, workflowId) {
1613
1654
  this.http = http;
1614
1655
  this.config = config;
1615
1656
  this.workflowId = workflowId;
1616
1657
  }
1658
+ /** List interfaces attached to this workflow. */
1617
1659
  async list() {
1618
1660
  validateId(this.workflowId, "workflow_id");
1619
1661
  const data = await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_list", {
@@ -1621,6 +1663,12 @@ var WorkflowInterfacesResource = class {
1621
1663
  });
1622
1664
  return data.interfaces;
1623
1665
  }
1666
+ /**
1667
+ * Add an interface to this workflow.
1668
+ *
1669
+ * @param options - Interface configuration to attach.
1670
+ * @returns The created interface.
1671
+ */
1624
1672
  async create(options) {
1625
1673
  validateId(this.workflowId, "workflow_id");
1626
1674
  return await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_add", {
@@ -1628,6 +1676,14 @@ var WorkflowInterfacesResource = class {
1628
1676
  jsonBody: omitUndefined(options)
1629
1677
  });
1630
1678
  }
1679
+ /**
1680
+ * Update an interface attached to this workflow.
1681
+ *
1682
+ * @param interfaceId - Interface id.
1683
+ * @param options - Updated interface values.
1684
+ * @param updateMask - Optional comma-separated field names to update.
1685
+ * @returns The updated interface.
1686
+ */
1631
1687
  async update(interfaceId, options, updateMask) {
1632
1688
  validateId(this.workflowId, "workflow_id");
1633
1689
  validateId(interfaceId, "interface_id");
@@ -1637,6 +1693,11 @@ var WorkflowInterfacesResource = class {
1637
1693
  jsonBody: updateMask === void 0 ? omitUndefined(options) : options
1638
1694
  });
1639
1695
  }
1696
+ /**
1697
+ * Delete an interface from this workflow.
1698
+ *
1699
+ * @param interfaceId - Interface id.
1700
+ */
1640
1701
  async delete(interfaceId) {
1641
1702
  validateId(this.workflowId, "workflow_id");
1642
1703
  validateId(interfaceId, "interface_id");
@@ -1644,6 +1705,7 @@ var WorkflowInterfacesResource = class {
1644
1705
  pathParams: { id: this.workflowId, interfaceId }
1645
1706
  });
1646
1707
  }
1708
+ /** Delete every interface from this workflow. */
1647
1709
  async deleteAll() {
1648
1710
  validateId(this.workflowId, "workflow_id");
1649
1711
  await invokeWithRetry(this.config, this.http, "WorkflowInterfacesController_deleteAll", {
@@ -1652,7 +1714,7 @@ var WorkflowInterfacesResource = class {
1652
1714
  }
1653
1715
  };
1654
1716
 
1655
- // src/management/agents/agents.ts
1717
+ // src/management/workflows/agents.ts
1656
1718
  var MANAGEMENT_WORKFLOW_OPERATIONS = {
1657
1719
  list: "WorkflowsController_list",
1658
1720
  get: "WorkflowsController_get",
@@ -1683,6 +1745,17 @@ var ManagementWorkflowsResource = class {
1683
1745
  this.config = config;
1684
1746
  this.ops = MANAGEMENT_WORKFLOW_OPERATIONS;
1685
1747
  }
1748
+ /**
1749
+ * List workflows in the organization.
1750
+ *
1751
+ * @param options.pageSize - Maximum items per page (default 25).
1752
+ * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
1753
+ * @param options.search - Case-insensitive substring filter on the workflow name.
1754
+ * @param options.type - Filter by workflow type: `"task"` or `"workflow"`.
1755
+ * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
1756
+ * @param options.includeVariation - Include variation payload on each list row.
1757
+ * @returns A page of workflows.
1758
+ */
1686
1759
  list(options = {}) {
1687
1760
  const pageSize = options.pageSize ?? 25;
1688
1761
  validatePageSize(pageSize);
@@ -1703,11 +1776,18 @@ var ManagementWorkflowsResource = class {
1703
1776
  );
1704
1777
  return buildAipPage(
1705
1778
  data,
1706
- "agents",
1779
+ "workflows",
1707
1780
  parseWorkflow,
1708
1781
  (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
1709
1782
  );
1710
1783
  }
1784
+ /**
1785
+ * Retrieve a workflow with full configuration.
1786
+ *
1787
+ * @param workflowId - Workflow id.
1788
+ * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
1789
+ * @returns The workflow.
1790
+ */
1711
1791
  async get(workflowId, options = {}) {
1712
1792
  validateId(workflowId, "workflow_id");
1713
1793
  const query = options.view !== void 0 ? { view: options.view } : void 0;
@@ -1717,9 +1797,28 @@ var ManagementWorkflowsResource = class {
1717
1797
  });
1718
1798
  return parseWorkflow(data);
1719
1799
  }
1800
+ /**
1801
+ * Interfaces attached to a workflow.
1802
+ *
1803
+ * @param workflowId - Workflow id.
1804
+ * @returns An interfaces resource scoped to the workflow.
1805
+ */
1720
1806
  interfaces(workflowId) {
1721
1807
  return new WorkflowInterfacesResource(this.http, this.config, workflowId);
1722
1808
  }
1809
+ /**
1810
+ * Create a new workflow in the organization.
1811
+ *
1812
+ * @param options.name - Display name for the workflow.
1813
+ * @param options.type - `"task"` for single-step orchestration, or `"workflow"` for a multi-step graph.
1814
+ * @param options.trigger - Optional trigger configuration.
1815
+ * @param options.guardrails - Runtime guardrail labels (for example `"no-pii"`). Omit to create with no guardrails.
1816
+ * @returns The created workflow (draft).
1817
+ * @example
1818
+ * ```ts
1819
+ * const wf = await mgmt.workflows.create({ name: 'Daily report', type: WorkflowType.Task })
1820
+ * ```
1821
+ */
1723
1822
  async create(options) {
1724
1823
  const body = omitUndefined({
1725
1824
  name: options.name,
@@ -1735,6 +1834,17 @@ var ManagementWorkflowsResource = class {
1735
1834
  });
1736
1835
  return parseWorkflow(data);
1737
1836
  }
1837
+ /**
1838
+ * Update a workflow's configuration.
1839
+ *
1840
+ * Only the fields you pass are changed. To clear a field, name it in
1841
+ * `updateMask` and leave its argument unset.
1842
+ *
1843
+ * @param workflowId - Workflow id.
1844
+ * @param options.guardrails - Guardrail labels to set. Fetches the current workflow first to merge. Pass `[]` to clear all.
1845
+ * @param options.updateMask - Comma-separated field names to update or clear.
1846
+ * @returns The updated workflow.
1847
+ */
1738
1848
  async update(workflowId, options = {}) {
1739
1849
  validateId(workflowId, "workflow_id");
1740
1850
  const accessConfig = await accessConfigBodyForUpdate(
@@ -1762,6 +1872,17 @@ var ManagementWorkflowsResource = class {
1762
1872
  });
1763
1873
  return parseWorkflow(data);
1764
1874
  }
1875
+ /**
1876
+ * Publish the current draft of a workflow.
1877
+ *
1878
+ * @param workflowId - Workflow id.
1879
+ * @returns The published workflow.
1880
+ * @example
1881
+ * ```ts
1882
+ * await mgmt.workflows.update(workflowId, { description: 'Runs every morning' })
1883
+ * const published = await mgmt.workflows.deploy(workflowId)
1884
+ * ```
1885
+ */
1765
1886
  async deploy(workflowId) {
1766
1887
  validateId(workflowId, "workflow_id");
1767
1888
  const data = asRecord(
@@ -1770,8 +1891,15 @@ var ManagementWorkflowsResource = class {
1770
1891
  jsonBody: {}
1771
1892
  })
1772
1893
  );
1773
- return parseWorkflow(data.agent);
1774
- }
1894
+ return parseWorkflow(data.workflow);
1895
+ }
1896
+ /**
1897
+ * Enable or disable a workflow without deleting it.
1898
+ *
1899
+ * @param workflowId - Workflow id.
1900
+ * @param options.active - `true` to activate, `false` to deactivate.
1901
+ * @returns The updated workflow.
1902
+ */
1775
1903
  async toggle(workflowId, options) {
1776
1904
  validateId(workflowId, "workflow_id");
1777
1905
  const data = await invokeWithRetry(this.config, this.http, this.ops.toggle, {
@@ -1780,12 +1908,24 @@ var ManagementWorkflowsResource = class {
1780
1908
  });
1781
1909
  return parseWorkflow(data);
1782
1910
  }
1911
+ /**
1912
+ * Delete a workflow.
1913
+ *
1914
+ * @param workflowId - Workflow id.
1915
+ * @returns Resolves when the workflow is deleted.
1916
+ */
1783
1917
  async delete(workflowId) {
1784
1918
  validateId(workflowId, "workflow_id");
1785
1919
  await invokeWithRetry(this.config, this.http, this.ops.delete, {
1786
1920
  pathParams: { id: workflowId }
1787
1921
  });
1788
1922
  }
1923
+ /**
1924
+ * Restore a previously deleted workflow.
1925
+ *
1926
+ * @param workflowId - Workflow id.
1927
+ * @returns The restored workflow.
1928
+ */
1789
1929
  async restore(workflowId) {
1790
1930
  validateId(workflowId, "workflow_id");
1791
1931
  const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
@@ -1794,6 +1934,13 @@ var ManagementWorkflowsResource = class {
1794
1934
  });
1795
1935
  return parseWorkflow(data);
1796
1936
  }
1937
+ /**
1938
+ * Start transferring ownership of a workflow to another organization member.
1939
+ *
1940
+ * @param workflowId - Workflow id.
1941
+ * @param options.newOwnerUserId - User id of the proposed new owner.
1942
+ * @returns The workflow with a pending ownership transfer.
1943
+ */
1797
1944
  async requestOwnershipTransfer(workflowId, options) {
1798
1945
  validateId(workflowId, "workflow_id");
1799
1946
  const data = await invokeWithRetry(
@@ -1807,6 +1954,7 @@ var ManagementWorkflowsResource = class {
1807
1954
  );
1808
1955
  return parseWorkflow(data);
1809
1956
  }
1957
+ /** Cancel a pending workflow ownership transfer. */
1810
1958
  async cancelOwnershipTransfer(workflowId) {
1811
1959
  validateId(workflowId, "workflow_id");
1812
1960
  const data = await invokeWithRetry(
@@ -1817,6 +1965,7 @@ var ManagementWorkflowsResource = class {
1817
1965
  );
1818
1966
  return parseWorkflow(data);
1819
1967
  }
1968
+ /** Accept a pending workflow ownership transfer. */
1820
1969
  async acceptOwnershipTransfer(workflowId) {
1821
1970
  validateId(workflowId, "workflow_id");
1822
1971
  const data = await invokeWithRetry(
@@ -1839,16 +1988,37 @@ function parseContextItem(raw) {
1839
1988
  return raw;
1840
1989
  }
1841
1990
  function parseCreatedCustomContextItem(raw) {
1842
- return raw;
1991
+ const data = asRecord(raw);
1992
+ const contextItemId = data.contextItemId;
1993
+ if (typeof contextItemId !== "string" || !contextItemId) {
1994
+ throw new ValidationError(
1995
+ "Custom context create response missing non-empty string contextItemId"
1996
+ );
1997
+ }
1998
+ return {
1999
+ ...data,
2000
+ contextItemId,
2001
+ uid: contextItemId
2002
+ };
1843
2003
  }
1844
2004
  function parseDeletion(raw) {
1845
2005
  return raw;
1846
2006
  }
1847
2007
  var CustomContextItemsResource = class {
2008
+ /** @internal */
1848
2009
  constructor(http, config) {
1849
2010
  this.http = http;
1850
2011
  this.config = config;
1851
2012
  }
2013
+ /**
2014
+ * List custom context items.
2015
+ *
2016
+ * @param options.pageSize - Maximum items per page (default 25).
2017
+ * @param options.pageToken - Opaque token from a previous page.
2018
+ * @param options.searchQuery - Free-text search filter.
2019
+ * @param options.topics - Filter to items tagged with any of these topics.
2020
+ * @returns A page of custom context items.
2021
+ */
1852
2022
  list(options = {}) {
1853
2023
  const pageSize = options.pageSize ?? 25;
1854
2024
  validatePageSize(pageSize);
@@ -1870,6 +2040,13 @@ var CustomContextItemsResource = class {
1870
2040
  (token) => this.listPage(pageSize, token, options)
1871
2041
  );
1872
2042
  }
2043
+ /**
2044
+ * Retrieve a custom context item by uid.
2045
+ *
2046
+ * @param uid - Item uid.
2047
+ * @returns The custom context item.
2048
+ * @throws {NotFoundError} When no item matches the uid.
2049
+ */
1873
2050
  async get(uid) {
1874
2051
  return parseContextItem(
1875
2052
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_get", {
@@ -1877,6 +2054,26 @@ var CustomContextItemsResource = class {
1877
2054
  })
1878
2055
  );
1879
2056
  }
2057
+ /**
2058
+ * Create a custom context item.
2059
+ *
2060
+ * @param input.kind - Item kind (`source`, `collection`, `entity`, `field`, or `entity_samples`).
2061
+ * @param input.sourceId - Source identifier for the item hierarchy.
2062
+ * @param input.name - Display name when applicable.
2063
+ * @param input.content - Item payload.
2064
+ * @param input.idempotencyKey - Optional idempotency key for safe retries.
2065
+ * @returns Created item ids and hierarchy metadata.
2066
+ *
2067
+ * @example
2068
+ * ```ts
2069
+ * const created = await client.context.customItems.create({
2070
+ * kind: 'entity',
2071
+ * sourceId: 'my-source',
2072
+ * name: 'Q3 churn notes',
2073
+ * content: { summary: 'Key findings…' },
2074
+ * })
2075
+ * ```
2076
+ */
1880
2077
  async create(input) {
1881
2078
  return parseCreatedCustomContextItem(
1882
2079
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_create", {
@@ -1884,6 +2081,20 @@ var CustomContextItemsResource = class {
1884
2081
  })
1885
2082
  );
1886
2083
  }
2084
+ /**
2085
+ * Create multiple custom context items in one request.
2086
+ *
2087
+ * @param inputs - Items to create (same fields as {@link CustomContextItemsResource.create}).
2088
+ * @returns Created item metadata for each input.
2089
+ *
2090
+ * @example
2091
+ * ```ts
2092
+ * const created = await client.context.customItems.batchCreate([
2093
+ * { kind: 'field', sourceId: 'src', fieldName: 'region', dataType: 'string' },
2094
+ * { kind: 'field', sourceId: 'src', fieldName: 'amount', dataType: 'number' },
2095
+ * ])
2096
+ * ```
2097
+ */
1887
2098
  async batchCreate(inputs) {
1888
2099
  const data = asRecord(
1889
2100
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_batchCreate", {
@@ -1895,6 +2106,13 @@ var CustomContextItemsResource = class {
1895
2106
  const items = data.contextItems;
1896
2107
  return Array.isArray(items) ? items.map(parseCreatedCustomContextItem) : [];
1897
2108
  }
2109
+ /**
2110
+ * Update a custom context item.
2111
+ *
2112
+ * @param uid - Item uid.
2113
+ * @param input - Fields to change (kind and hierarchy ids cannot be changed).
2114
+ * @returns The updated item uid.
2115
+ */
1898
2116
  async update(uid, input) {
1899
2117
  return asRecord(
1900
2118
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_update", {
@@ -1903,6 +2121,12 @@ var CustomContextItemsResource = class {
1903
2121
  })
1904
2122
  );
1905
2123
  }
2124
+ /**
2125
+ * Delete a custom context item.
2126
+ *
2127
+ * @param uid - Item uid.
2128
+ * @returns Deletion confirmation with uid and context type.
2129
+ */
1906
2130
  async delete(uid) {
1907
2131
  return parseDeletion(
1908
2132
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_delete", {
@@ -2009,6 +2233,14 @@ var ManagementContextItemsResource = class {
2009
2233
  this.http = http;
2010
2234
  this.config = config;
2011
2235
  }
2236
+ /**
2237
+ * List context items in the knowledge base.
2238
+ *
2239
+ * @param options.pageSize - Items per page (default 25).
2240
+ * @param options.pageToken - Token from a previous page's `nextPageToken`.
2241
+ * @param options.contextType - Filter to one context type (for example `"note"`).
2242
+ * @returns A page of context items.
2243
+ */
2012
2244
  list(options = {}) {
2013
2245
  const pageSize = options.pageSize ?? 25;
2014
2246
  validatePageSize(pageSize);
@@ -2027,12 +2259,33 @@ var ManagementContextItemsResource = class {
2027
2259
  (token) => this.listPage(pageSize, token, contextType)
2028
2260
  );
2029
2261
  }
2262
+ /**
2263
+ * Retrieve one context item by uid.
2264
+ *
2265
+ * @param uid - Context item uid.
2266
+ * @returns The context item.
2267
+ */
2030
2268
  async get(uid) {
2031
2269
  const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_get", {
2032
2270
  pathParams: { uid }
2033
2271
  });
2034
2272
  return parseContextItem2(data);
2035
2273
  }
2274
+ /**
2275
+ * Update a context item.
2276
+ *
2277
+ * Only the fields you pass are changed. To clear a field, name it in
2278
+ * `updateMask` and leave its argument unset.
2279
+ *
2280
+ * @param uid - Context item uid.
2281
+ * @param options.content - Replacement type-specific content.
2282
+ * @param options.contextType - Item type (for example `"note"`). Required when `content` is supplied.
2283
+ * @param options.description - New description.
2284
+ * @param options.userFeedback - Feedback verdict: `"positive"`, `"neutral"`, or `"negative"`.
2285
+ * @param options.topics - Replacement topic tags. Pass `[]` to clear all tags.
2286
+ * @param options.updateMask - Comma-separated field names to update or clear.
2287
+ * @returns The updated context item.
2288
+ */
2036
2289
  async update(uid, options = {}) {
2037
2290
  const body = options.updateMask !== void 0 ? {
2038
2291
  content: options.content,
@@ -2054,6 +2307,12 @@ var ManagementContextItemsResource = class {
2054
2307
  });
2055
2308
  return this.get(uid);
2056
2309
  }
2310
+ /**
2311
+ * Delete a context item.
2312
+ *
2313
+ * @param uid - Context item uid.
2314
+ * @returns Deletion confirmation details.
2315
+ */
2057
2316
  async delete(uid) {
2058
2317
  const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_delete", {
2059
2318
  pathParams: { uid }
@@ -2064,24 +2323,51 @@ var ManagementContextItemsResource = class {
2064
2323
 
2065
2324
  // src/management/context/context.ts
2066
2325
  var ManagementContextResource = class {
2326
+ /** @internal */
2067
2327
  constructor(http, config) {
2068
2328
  this.http = http;
2069
2329
  this.config = config;
2070
2330
  this.items = new ManagementContextItemsResource(http, config);
2071
2331
  this.customItems = new CustomContextItemsResource(http, config);
2072
2332
  }
2073
- async create(operationId, payload) {
2074
- const data = await invokeWithRetry(this.config, this.http, operationId, {
2075
- jsonBody: payload
2076
- });
2077
- return withCreatedUid(data);
2078
- }
2333
+ /**
2334
+ * Add a free-form text note to the knowledge base.
2335
+ *
2336
+ * @param title - Note title.
2337
+ * @param content - Note body (markdown).
2338
+ * @returns The created context item.
2339
+ * @example
2340
+ * ```ts
2341
+ * const note = await mgmt.context.createNote('Runbook', '# Steps\n1. Check logs')
2342
+ * ```
2343
+ */
2079
2344
  createNote(title, content) {
2080
2345
  return this.create("ContextCreatorsController_createNote", omitUndefined({ title, content }));
2081
2346
  }
2347
+ /**
2348
+ * Update a note's title and markdown body.
2349
+ *
2350
+ * Preserves server-owned fields on the existing content blob. Pass `existing`
2351
+ * to skip a fetch when you already have the item from a list call.
2352
+ *
2353
+ * @param uid - Context item uid.
2354
+ * @param options.title - New title.
2355
+ * @param options.body - New markdown body.
2356
+ * @param options.existing - Optional cached item to avoid a GET.
2357
+ * @returns The updated context item.
2358
+ */
2082
2359
  updateNote(uid, options) {
2083
2360
  return resolveAndUpdateNote(this.items, uid, options);
2084
2361
  }
2362
+ /**
2363
+ * Save a SQL query to the knowledge base.
2364
+ *
2365
+ * @param name - Display name for the query.
2366
+ * @param options.connectionId - Connection the query runs against.
2367
+ * @param options.query - SQL text.
2368
+ * @param options.path - Optional hierarchy path segments.
2369
+ * @returns The created context item.
2370
+ */
2085
2371
  createSavedQuery(name, options) {
2086
2372
  return this.create(
2087
2373
  "ContextCreatorsController_createSavedQuery",
@@ -2094,9 +2380,27 @@ var ManagementContextResource = class {
2094
2380
  })
2095
2381
  );
2096
2382
  }
2383
+ /**
2384
+ * Update a saved query's name, SQL, and optional connection metadata.
2385
+ *
2386
+ * @param uid - Context item uid.
2387
+ * @param options.name - New display name.
2388
+ * @param options.query - New SQL text.
2389
+ * @param options.existing - Optional cached item to avoid a GET.
2390
+ * @returns The updated context item.
2391
+ */
2097
2392
  updateSavedQuery(uid, options) {
2098
2393
  return resolveAndUpdateSavedQuery(this.items, uid, options);
2099
2394
  }
2395
+ /**
2396
+ * Add a URL to the knowledge base.
2397
+ *
2398
+ * @param url - Link URL.
2399
+ * @param options.title - Optional display title.
2400
+ * @param options.isCrawl - When true, crawl linked pages into context.
2401
+ * @param options.pageLimit - Maximum pages to crawl when `isCrawl` is true.
2402
+ * @returns The created context item.
2403
+ */
2100
2404
  createLink(url, options = {}) {
2101
2405
  return this.create(
2102
2406
  "ContextCreatorsController_createLink",
@@ -2108,23 +2412,30 @@ var ManagementContextResource = class {
2108
2412
  })
2109
2413
  );
2110
2414
  }
2415
+ /**
2416
+ * Update link metadata on an existing item.
2417
+ *
2418
+ * Merges `title` and/or `url` into the stored content blob. Does not re-fetch or re-crawl the URL.
2419
+ *
2420
+ * @param uid - Context item uid.
2421
+ * @param options.title - New display title.
2422
+ * @param options.url - New URL.
2423
+ * @param options.existing - Optional cached item to avoid a GET.
2424
+ * @returns The updated context item.
2425
+ */
2111
2426
  updateLink(uid, options) {
2112
2427
  return resolveAndUpdateLink(this.items, uid, options);
2113
2428
  }
2114
- };
2115
-
2116
- // src/management/organization.ts
2117
- var ManagementOrganizationResource = class {
2118
- constructor(http, config) {
2119
- this.http = http;
2120
- this.config = config;
2121
- }
2122
- async delete() {
2123
- await invokeWithRetry(this.config, this.http, "OrganizationController_deleteOrganization");
2429
+ /** @internal */
2430
+ async create(operationId, payload) {
2431
+ const data = await invokeWithRetry(this.config, this.http, operationId, {
2432
+ jsonBody: payload
2433
+ });
2434
+ return withCreatedUid(data);
2124
2435
  }
2125
2436
  };
2126
2437
 
2127
- // src/resources/skills/conversations.ts
2438
+ // src/resources/scopes/conversations.ts
2128
2439
  function parseListItem(raw) {
2129
2440
  return raw;
2130
2441
  }
@@ -2137,6 +2448,13 @@ var ScopeConversationsResource = class {
2137
2448
  this.config = config;
2138
2449
  this.scopeId = scopeId;
2139
2450
  }
2451
+ /**
2452
+ * List conversation threads for this scope, newest first.
2453
+ *
2454
+ * @param options.pageSize - Items per page (default 25).
2455
+ * @param options.pageToken - Opaque token from a previous page.
2456
+ * @returns Page of conversation list items.
2457
+ */
2140
2458
  list(options = {}) {
2141
2459
  const pageSize = options.pageSize ?? 25;
2142
2460
  validatePageSize(pageSize);
@@ -2157,6 +2475,14 @@ var ScopeConversationsResource = class {
2157
2475
  (token) => this.listPage(pageSize, token)
2158
2476
  );
2159
2477
  }
2478
+ /**
2479
+ * Retrieve a thread with full message history.
2480
+ *
2481
+ * @param threadId - Conversation thread id.
2482
+ * @param options.messageLimit - Maximum messages to return (1–100).
2483
+ * @param options.beforeMessageIndex - Return messages before this index (requires messageLimit).
2484
+ * @returns Conversation with messages.
2485
+ */
2160
2486
  async get(threadId, options = {}) {
2161
2487
  validateId(this.scopeId, "scope_id");
2162
2488
  validateId(threadId, "thread_id");
@@ -2174,7 +2500,7 @@ var ScopeConversationsResource = class {
2174
2500
  }
2175
2501
  };
2176
2502
 
2177
- // src/management/skills/memories.ts
2503
+ // src/management/scopes/memories.ts
2178
2504
  function parseMemory(raw) {
2179
2505
  return raw;
2180
2506
  }
@@ -2184,6 +2510,14 @@ var ScopeMemoriesResource = class {
2184
2510
  this.config = config;
2185
2511
  this.scopeId = scopeId;
2186
2512
  }
2513
+ /**
2514
+ * List memories stored for this scope.
2515
+ *
2516
+ * @param options.pageSize - Items per page (default 25).
2517
+ * @param options.pageToken - Token from a previous page's `nextPageToken`.
2518
+ * @param options.userId - Optional end-user id when memories are scoped per user.
2519
+ * @returns A page of memories.
2520
+ */
2187
2521
  list(options = {}) {
2188
2522
  const pageSize = options.pageSize ?? 25;
2189
2523
  validatePageSize(pageSize);
@@ -2206,6 +2540,12 @@ var ScopeMemoriesResource = class {
2206
2540
  (token) => this.listPage(pageSize, token, userId)
2207
2541
  );
2208
2542
  }
2543
+ /**
2544
+ * Search this scope's memories by natural-language query.
2545
+ *
2546
+ * @param request - Query text and optional `userId` / `limit`.
2547
+ * @returns Matching memories and relevance scores.
2548
+ */
2209
2549
  async search(request) {
2210
2550
  validateId(this.scopeId, "scope_id");
2211
2551
  const data = await invokeWithRetry(this.config, this.http, "ScopeMemoriesController_search", {
@@ -2214,6 +2554,14 @@ var ScopeMemoriesResource = class {
2214
2554
  });
2215
2555
  return data;
2216
2556
  }
2557
+ /**
2558
+ * Update one memory. Requires manage permission on the scope.
2559
+ *
2560
+ * @param memoryId - Id from list or search.
2561
+ * @param update - Fields to change (`memory` and/or `metadata`).
2562
+ * @param options.updateMask - Optional comma-separated field names to update.
2563
+ * @returns The updated memory.
2564
+ */
2217
2565
  async update(memoryId, update, options = {}) {
2218
2566
  validateId(memoryId, "memory_id");
2219
2567
  validateId(this.scopeId, "scope_id");
@@ -2224,6 +2572,7 @@ var ScopeMemoriesResource = class {
2224
2572
  });
2225
2573
  return parseMemory(data);
2226
2574
  }
2575
+ /** Delete one memory (idempotent). */
2227
2576
  async delete(memoryId) {
2228
2577
  validateId(memoryId, "memory_id");
2229
2578
  validateId(this.scopeId, "scope_id");
@@ -2233,7 +2582,7 @@ var ScopeMemoriesResource = class {
2233
2582
  }
2234
2583
  };
2235
2584
 
2236
- // src/management/skills/evaluations.ts
2585
+ // src/management/scopes/evaluations.ts
2237
2586
  function parseConfig(raw) {
2238
2587
  return raw;
2239
2588
  }
@@ -2246,6 +2595,7 @@ var ScopeEvaluationsResource = class {
2246
2595
  this.config = config;
2247
2596
  this.scopeId = scopeId;
2248
2597
  }
2598
+ /** Get the evaluation configuration for this scope. */
2249
2599
  async getConfig() {
2250
2600
  validateId(this.scopeId, "scope_id");
2251
2601
  const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_getConfig", {
@@ -2253,6 +2603,12 @@ var ScopeEvaluationsResource = class {
2253
2603
  });
2254
2604
  return parseConfig(data);
2255
2605
  }
2606
+ /**
2607
+ * Update the evaluation configuration for this scope.
2608
+ *
2609
+ * @param update - Configuration fields to change.
2610
+ * @returns The updated evaluation configuration.
2611
+ */
2256
2612
  async updateConfig(update) {
2257
2613
  validateId(this.scopeId, "scope_id");
2258
2614
  const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_updateConfig", {
@@ -2261,6 +2617,11 @@ var ScopeEvaluationsResource = class {
2261
2617
  });
2262
2618
  return parseConfig(data);
2263
2619
  }
2620
+ /**
2621
+ * Trigger a manual evaluation run for this scope.
2622
+ *
2623
+ * @returns The triggered run id and status.
2624
+ */
2264
2625
  async triggerRun() {
2265
2626
  validateId(this.scopeId, "scope_id");
2266
2627
  const data = await invokeWithRetry(this.config, this.http, "EvaluationsController_triggerRun", {
@@ -2268,6 +2629,13 @@ var ScopeEvaluationsResource = class {
2268
2629
  });
2269
2630
  return data;
2270
2631
  }
2632
+ /**
2633
+ * List evaluation runs for this scope.
2634
+ *
2635
+ * @param options.pageSize - Items per page (default 25).
2636
+ * @param options.pageToken - Token from a previous page's `nextPageToken`.
2637
+ * @returns A page of evaluation runs.
2638
+ */
2271
2639
  listRuns(options = {}) {
2272
2640
  const pageSize = options.pageSize ?? 25;
2273
2641
  validatePageSize(pageSize);
@@ -2283,6 +2651,12 @@ var ScopeEvaluationsResource = class {
2283
2651
  );
2284
2652
  return buildAipPage(data, "runs", parseRun, (token) => this.listRunsPage(pageSize, token));
2285
2653
  }
2654
+ /**
2655
+ * Retrieve one evaluation run with full results.
2656
+ *
2657
+ * @param runId - Evaluation run id.
2658
+ * @returns The run and its result details.
2659
+ */
2286
2660
  async getRun(runId) {
2287
2661
  validateId(this.scopeId, "scope_id");
2288
2662
  validateId(runId, "run_id");
@@ -2293,13 +2667,19 @@ var ScopeEvaluationsResource = class {
2293
2667
  }
2294
2668
  };
2295
2669
 
2296
- // src/management/skills/supervision.ts
2670
+ // src/management/scopes/supervision.ts
2297
2671
  var ScopeSupervisionResource = class {
2298
2672
  constructor(http, config, scopeId) {
2299
2673
  this.http = http;
2300
2674
  this.config = config;
2301
2675
  this.scopeId = scopeId;
2302
2676
  }
2677
+ /**
2678
+ * Get this scope's supervision configuration.
2679
+ *
2680
+ * @param options.view - Optional scope variation to inspect.
2681
+ * @returns The supervision configuration.
2682
+ */
2303
2683
  async get(options = {}) {
2304
2684
  validateId(this.scopeId, "scope_id");
2305
2685
  return await invokeWithRetry(this.config, this.http, "ScopeSupervisionController_get", {
@@ -2307,9 +2687,21 @@ var ScopeSupervisionResource = class {
2307
2687
  query: options.view === void 0 ? void 0 : { view: options.view }
2308
2688
  });
2309
2689
  }
2690
+ /**
2691
+ * Replace this scope's subordinate scopes.
2692
+ *
2693
+ * @param request - Replacement supervision configuration.
2694
+ * @returns The updated supervision configuration.
2695
+ */
2310
2696
  async set(request) {
2311
2697
  return this.write("ScopeSupervisionController_set", request);
2312
2698
  }
2699
+ /**
2700
+ * Replace subordinate scopes on the active (deployed) scope version.
2701
+ *
2702
+ * @param request - Replacement supervision configuration.
2703
+ * @returns The updated supervision configuration.
2704
+ */
2313
2705
  async setActive(request) {
2314
2706
  return this.write("ScopeSupervisionController_setActive", request);
2315
2707
  }
@@ -2322,7 +2714,7 @@ var ScopeSupervisionResource = class {
2322
2714
  }
2323
2715
  };
2324
2716
 
2325
- // src/management/skills/skills.ts
2717
+ // src/management/scopes/skills.ts
2326
2718
  var MANAGEMENT_SCOPE_OPERATIONS = {
2327
2719
  list: "ScopesController_list",
2328
2720
  get: "ScopesController_get",
@@ -2348,23 +2740,58 @@ function parseScope(raw) {
2348
2740
  return raw;
2349
2741
  }
2350
2742
  var ManagementScopesResource = class {
2743
+ /** @internal */
2351
2744
  constructor(http, config) {
2352
2745
  this.http = http;
2353
2746
  this.config = config;
2354
2747
  this.ops = MANAGEMENT_SCOPE_OPERATIONS;
2355
2748
  }
2749
+ /**
2750
+ * Conversations for a scope.
2751
+ *
2752
+ * @param scopeId - Scope id.
2753
+ * @returns A conversations resource scoped to the scope.
2754
+ */
2356
2755
  conversations(scopeId) {
2357
2756
  return new ScopeConversationsResource(this.http, this.config, scopeId);
2358
2757
  }
2758
+ /**
2759
+ * Long-term memories for a scope.
2760
+ *
2761
+ * @param scopeId - Scope id.
2762
+ * @returns A memories resource scoped to the scope.
2763
+ */
2359
2764
  memories(scopeId) {
2360
2765
  return new ScopeMemoriesResource(this.http, this.config, scopeId);
2361
2766
  }
2767
+ /**
2768
+ * Evaluations for a scope.
2769
+ *
2770
+ * @param scopeId - Scope id.
2771
+ * @returns An evaluations resource scoped to the scope.
2772
+ */
2362
2773
  evaluations(scopeId) {
2363
2774
  return new ScopeEvaluationsResource(this.http, this.config, scopeId);
2364
2775
  }
2776
+ /**
2777
+ * Supervision (subordinate scopes) for a scope.
2778
+ *
2779
+ * @param scopeId - Scope id.
2780
+ * @returns A supervision resource scoped to the scope.
2781
+ */
2365
2782
  supervision(scopeId) {
2366
2783
  return new ScopeSupervisionResource(this.http, this.config, scopeId);
2367
2784
  }
2785
+ /**
2786
+ * List scopes in the organization.
2787
+ *
2788
+ * @param options.pageSize - Maximum items per page (default 25).
2789
+ * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
2790
+ * @param options.search - Case-insensitive substring filter on the scope name.
2791
+ * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
2792
+ * @param options.managerId - Return only scopes supervised by this manager scope id.
2793
+ * @returns A page of scopes.
2794
+ */
2368
2795
  list(options = {}) {
2369
2796
  const pageSize = options.pageSize ?? 25;
2370
2797
  validatePageSize(pageSize);
@@ -2384,11 +2811,18 @@ var ManagementScopesResource = class {
2384
2811
  );
2385
2812
  return buildAipPage(
2386
2813
  data,
2387
- "skills",
2814
+ "scopes",
2388
2815
  parseScope,
2389
2816
  (token) => this.listPage(pageSize, token, search, view, managerId)
2390
2817
  );
2391
2818
  }
2819
+ /**
2820
+ * Retrieve a scope with full configuration.
2821
+ *
2822
+ * @param scopeId - Scope id.
2823
+ * @param options.view - Variation view: `"active"` (deployed) or `"draft"`.
2824
+ * @returns The scope.
2825
+ */
2392
2826
  async get(scopeId, options = {}) {
2393
2827
  validateId(scopeId, "scope_id");
2394
2828
  const query = options.view !== void 0 ? { view: options.view } : void 0;
@@ -2398,6 +2832,21 @@ var ManagementScopesResource = class {
2398
2832
  });
2399
2833
  return parseScope(data);
2400
2834
  }
2835
+ /**
2836
+ * Create a new scope in the organization.
2837
+ *
2838
+ * @param options.name - Display name for the scope.
2839
+ * @param options.description - Optional description.
2840
+ * @param options.instructions - Optional system instructions.
2841
+ * @param options.model - Optional model id.
2842
+ * @param options.toolset - Optional tool selection for the scope.
2843
+ * @param options.guardrails - Runtime guardrail labels (for example `"no-pii"`). Omit to create with no guardrails.
2844
+ * @returns The created scope (draft).
2845
+ * @example
2846
+ * ```ts
2847
+ * const scope = await mgmt.scopes.create({ name: 'Support assistant', model: 'claude-sonnet-5' })
2848
+ * ```
2849
+ */
2401
2850
  async create(options) {
2402
2851
  const body = omitUndefined({
2403
2852
  name: options.name,
@@ -2416,6 +2865,17 @@ var ManagementScopesResource = class {
2416
2865
  });
2417
2866
  return parseScope(data);
2418
2867
  }
2868
+ /**
2869
+ * Update a scope's configuration.
2870
+ *
2871
+ * Only the fields you pass are changed. To clear a field, name it in
2872
+ * `updateMask` (comma-separated field names) and leave its argument unset.
2873
+ *
2874
+ * @param scopeId - Scope id.
2875
+ * @param options.guardrails - Guardrail labels to set. Fetches the current scope first to merge. Pass `[]` to clear all.
2876
+ * @param options.updateMask - Comma-separated field names to update or clear.
2877
+ * @returns The updated scope.
2878
+ */
2419
2879
  async update(scopeId, options = {}) {
2420
2880
  validateId(scopeId, "scope_id");
2421
2881
  const accessConfig = await accessConfigBodyForUpdate(
@@ -2449,6 +2909,17 @@ var ManagementScopesResource = class {
2449
2909
  });
2450
2910
  return parseScope(data);
2451
2911
  }
2912
+ /**
2913
+ * Publish the current draft of a scope.
2914
+ *
2915
+ * @param scopeId - Scope id.
2916
+ * @returns The published scope.
2917
+ * @example
2918
+ * ```ts
2919
+ * await mgmt.scopes.update(scopeId, { instructions: ['Be concise.'] })
2920
+ * const published = await mgmt.scopes.deploy(scopeId)
2921
+ * ```
2922
+ */
2452
2923
  async deploy(scopeId) {
2453
2924
  validateId(scopeId, "scope_id");
2454
2925
  const data = asRecord(
@@ -2457,14 +2928,26 @@ var ManagementScopesResource = class {
2457
2928
  jsonBody: {}
2458
2929
  })
2459
2930
  );
2460
- return parseScope(data.skill);
2461
- }
2931
+ return parseScope(data.scope);
2932
+ }
2933
+ /**
2934
+ * Delete a scope.
2935
+ *
2936
+ * @param scopeId - Scope id.
2937
+ * @returns Resolves when the scope is deleted.
2938
+ */
2462
2939
  async delete(scopeId) {
2463
2940
  validateId(scopeId, "scope_id");
2464
2941
  await invokeWithRetry(this.config, this.http, this.ops.delete, {
2465
2942
  pathParams: { id: scopeId }
2466
2943
  });
2467
2944
  }
2945
+ /**
2946
+ * Restore a previously deleted scope.
2947
+ *
2948
+ * @param scopeId - Scope id.
2949
+ * @returns The restored scope.
2950
+ */
2468
2951
  async restore(scopeId) {
2469
2952
  validateId(scopeId, "scope_id");
2470
2953
  const data = await invokeWithRetry(this.config, this.http, this.ops.restore, {
@@ -2473,6 +2956,13 @@ var ManagementScopesResource = class {
2473
2956
  });
2474
2957
  return parseScope(data);
2475
2958
  }
2959
+ /**
2960
+ * Start transferring ownership of a scope to another organization member.
2961
+ *
2962
+ * @param scopeId - Scope id.
2963
+ * @param options.newOwnerUserId - User id of the proposed new owner.
2964
+ * @returns The scope with a pending ownership transfer.
2965
+ */
2476
2966
  async requestOwnershipTransfer(scopeId, options) {
2477
2967
  validateId(scopeId, "scope_id");
2478
2968
  const data = await invokeWithRetry(
@@ -2486,6 +2976,7 @@ var ManagementScopesResource = class {
2486
2976
  );
2487
2977
  return parseScope(data);
2488
2978
  }
2979
+ /** Cancel a pending scope ownership transfer. */
2489
2980
  async cancelOwnershipTransfer(scopeId) {
2490
2981
  validateId(scopeId, "scope_id");
2491
2982
  const data = await invokeWithRetry(
@@ -2496,6 +2987,7 @@ var ManagementScopesResource = class {
2496
2987
  );
2497
2988
  return parseScope(data);
2498
2989
  }
2990
+ /** Accept a pending scope ownership transfer. */
2499
2991
  async acceptOwnershipTransfer(scopeId) {
2500
2992
  validateId(scopeId, "scope_id");
2501
2993
  const data = await invokeWithRetry(
@@ -2506,6 +2998,12 @@ var ManagementScopesResource = class {
2506
2998
  );
2507
2999
  return parseScope(data);
2508
3000
  }
3001
+ /**
3002
+ * Update MCP server configuration for a scope.
3003
+ *
3004
+ * @param scopeId - Scope id.
3005
+ * @param options.mcpConfig - MCP configuration object.
3006
+ */
2509
3007
  async patchMcpConfig(scopeId, options) {
2510
3008
  validateId(scopeId, "scope_id");
2511
3009
  await invokeWithRetry(this.config, this.http, this.ops.patchMcpConfig, {
@@ -2513,6 +3011,13 @@ var ManagementScopesResource = class {
2513
3011
  jsonBody: omitUndefined({ config: options.mcpConfig })
2514
3012
  });
2515
3013
  }
3014
+ /**
3015
+ * Retrieve a specific scope variation by uid.
3016
+ *
3017
+ * @param scopeId - Scope id.
3018
+ * @param options.variationUid - Variation uid.
3019
+ * @returns The scope variation.
3020
+ */
2516
3021
  async getVariation(scopeId, options) {
2517
3022
  validateId(scopeId, "scope_id");
2518
3023
  validateId(options.variationUid, "variation_uid");
@@ -2529,6 +3034,18 @@ var ManagementUsageResource = class {
2529
3034
  this.http = http;
2530
3035
  this.config = config;
2531
3036
  }
3037
+ /**
3038
+ * List usage metrics for your organization over a time window.
3039
+ *
3040
+ * @param options.since - Start of the window (ISO 8601, inclusive).
3041
+ * @param options.until - End of the window (ISO 8601, exclusive).
3042
+ * @param options.rollup - Bucket size for each row: `"hour"` or `"day"`.
3043
+ * @param options.model - Optional filter to a single model name.
3044
+ * @param options.userEmail - Optional filter to one or more acting-user emails.
3045
+ * @returns Usage report rows for the window.
3046
+ * @throws {UnprocessableError} When the request is rejected by the API.
3047
+ * @throws {AuthenticationError} When the API key is invalid or missing.
3048
+ */
2532
3049
  async list(options) {
2533
3050
  const query = {
2534
3051
  since: options.since,
@@ -2536,9 +3053,60 @@ var ManagementUsageResource = class {
2536
3053
  rollup: options.rollup
2537
3054
  };
2538
3055
  if (options.model !== void 0) query.model = options.model;
3056
+ if (options.userEmail !== void 0) query.user_email = [...options.userEmail];
2539
3057
  const data = await invokeWithRetry(this.config, this.http, "UsageController_list", { query });
2540
3058
  return data;
2541
3059
  }
3060
+ /**
3061
+ * List distinct acting-user emails observed in a time window.
3062
+ *
3063
+ * @param options.since - Start of the window (ISO 8601, inclusive).
3064
+ * @param options.until - End of the window (ISO 8601, exclusive).
3065
+ * @returns User emails seen in usage during the window.
3066
+ * @throws {UnprocessableError} When the request is rejected by the API.
3067
+ * @throws {AuthenticationError} When the API key is invalid or missing.
3068
+ */
3069
+ async listUsers(options) {
3070
+ const query = {
3071
+ since: options.since,
3072
+ until: options.until
3073
+ };
3074
+ const data = await invokeWithRetry(this.config, this.http, "UsageController_listUsers", {
3075
+ query
3076
+ });
3077
+ return data;
3078
+ }
3079
+ };
3080
+
3081
+ // src/management/tools.ts
3082
+ function parseToolCatalogEntry(raw) {
3083
+ return raw;
3084
+ }
3085
+ var ManagementToolsResource = class {
3086
+ constructor(http, config) {
3087
+ this.http = http;
3088
+ this.config = config;
3089
+ }
3090
+ /**
3091
+ * List tool and integration surfaces a scope can select in its toolset.
3092
+ *
3093
+ * @param options.pageSize - Maximum items per page (default 25).
3094
+ * @param options.pageToken - Token from a previous page's `nextPageToken`; omit for the first page.
3095
+ * @returns A page of tool catalog entries.
3096
+ */
3097
+ list(options = {}) {
3098
+ const pageSize = options.pageSize ?? 25;
3099
+ validatePageSize(pageSize);
3100
+ return this.listPage(pageSize, options.pageToken);
3101
+ }
3102
+ async listPage(pageSize, pageToken) {
3103
+ const data = asRecord(
3104
+ await invokeWithRetry(this.config, this.http, "ToolsController_list", {
3105
+ query: aipListParams(pageSize, pageToken)
3106
+ })
3107
+ );
3108
+ return buildAipPage(data, "tools", parseToolCatalogEntry, (token) => this.listPage(pageSize, token));
3109
+ }
2542
3110
  };
2543
3111
 
2544
3112
  // src/management/users.ts
@@ -2547,6 +3115,7 @@ var ManagementUsersResource = class {
2547
3115
  this.http = http;
2548
3116
  this.config = config;
2549
3117
  }
3118
+ /** List member groups in the organization. */
2550
3119
  async listMemberGroups() {
2551
3120
  const data = await invokeWithRetry(
2552
3121
  this.config,
@@ -2555,6 +3124,7 @@ var ManagementUsersResource = class {
2555
3124
  );
2556
3125
  return data.groups;
2557
3126
  }
3127
+ /** List organization members. */
2558
3128
  async listOrgMembers() {
2559
3129
  const data = await invokeWithRetry(
2560
3130
  this.config,
@@ -2573,7 +3143,7 @@ var ModusManagement = class extends ModusClientBase {
2573
3143
  this.workflows = new ManagementWorkflowsResource(this.http, this.config);
2574
3144
  this.context = new ManagementContextResource(this.http, this.config);
2575
3145
  this.usage = new ManagementUsageResource(this.http, this.config);
2576
- this.organization = new ManagementOrganizationResource(this.http, this.config);
3146
+ this.tools = new ManagementToolsResource(this.http, this.config);
2577
3147
  this.users = new ManagementUsersResource(this.http, this.config);
2578
3148
  }
2579
3149
  };