@getmodus/sdk 0.3.0 → 0.5.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.3.0"} (node/${process.version}; ${process.platform})`;
219
+ var USER_AGENT = `modus-typescript/${"0.5.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
  }
@@ -1161,6 +1192,16 @@ var OPERATIONS = {
1161
1192
  requestSchema: "RecordSuggestionEventDto",
1162
1193
  responseSchema: null
1163
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
+ },
1164
1205
  "UsageController_list": {
1165
1206
  method: "GET",
1166
1207
  path: "/api/v1/usage",
@@ -1614,6 +1655,7 @@ var WorkflowInterfacesResource = class {
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", {
@@ -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);
@@ -1708,6 +1781,13 @@ var ManagementWorkflowsResource = class {
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(
@@ -1772,6 +1893,13 @@ var ManagementWorkflowsResource = class {
1772
1893
  );
1773
1894
  return parseWorkflow(data.workflow);
1774
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(
@@ -1856,10 +2005,20 @@ function parseDeletion(raw) {
1856
2005
  return raw;
1857
2006
  }
1858
2007
  var CustomContextItemsResource = class {
2008
+ /** @internal */
1859
2009
  constructor(http, config) {
1860
2010
  this.http = http;
1861
2011
  this.config = config;
1862
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
+ */
1863
2022
  list(options = {}) {
1864
2023
  const pageSize = options.pageSize ?? 25;
1865
2024
  validatePageSize(pageSize);
@@ -1881,6 +2040,13 @@ var CustomContextItemsResource = class {
1881
2040
  (token) => this.listPage(pageSize, token, options)
1882
2041
  );
1883
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
+ */
1884
2050
  async get(uid) {
1885
2051
  return parseContextItem(
1886
2052
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_get", {
@@ -1888,6 +2054,26 @@ var CustomContextItemsResource = class {
1888
2054
  })
1889
2055
  );
1890
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
+ */
1891
2077
  async create(input) {
1892
2078
  return parseCreatedCustomContextItem(
1893
2079
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_create", {
@@ -1895,6 +2081,20 @@ var CustomContextItemsResource = class {
1895
2081
  })
1896
2082
  );
1897
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
+ */
1898
2098
  async batchCreate(inputs) {
1899
2099
  const data = asRecord(
1900
2100
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_batchCreate", {
@@ -1906,6 +2106,13 @@ var CustomContextItemsResource = class {
1906
2106
  const items = data.contextItems;
1907
2107
  return Array.isArray(items) ? items.map(parseCreatedCustomContextItem) : [];
1908
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
+ */
1909
2116
  async update(uid, input) {
1910
2117
  return asRecord(
1911
2118
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_update", {
@@ -1914,6 +2121,12 @@ var CustomContextItemsResource = class {
1914
2121
  })
1915
2122
  );
1916
2123
  }
2124
+ /**
2125
+ * Delete a custom context item.
2126
+ *
2127
+ * @param uid - Item uid.
2128
+ * @returns Deletion confirmation with uid and context type.
2129
+ */
1917
2130
  async delete(uid) {
1918
2131
  return parseDeletion(
1919
2132
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_delete", {
@@ -2020,6 +2233,14 @@ var ManagementContextItemsResource = class {
2020
2233
  this.http = http;
2021
2234
  this.config = config;
2022
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
+ */
2023
2244
  list(options = {}) {
2024
2245
  const pageSize = options.pageSize ?? 25;
2025
2246
  validatePageSize(pageSize);
@@ -2038,12 +2259,33 @@ var ManagementContextItemsResource = class {
2038
2259
  (token) => this.listPage(pageSize, token, contextType)
2039
2260
  );
2040
2261
  }
2262
+ /**
2263
+ * Retrieve one context item by uid.
2264
+ *
2265
+ * @param uid - Context item uid.
2266
+ * @returns The context item.
2267
+ */
2041
2268
  async get(uid) {
2042
2269
  const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_get", {
2043
2270
  pathParams: { uid }
2044
2271
  });
2045
2272
  return parseContextItem2(data);
2046
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
+ */
2047
2289
  async update(uid, options = {}) {
2048
2290
  const body = options.updateMask !== void 0 ? {
2049
2291
  content: options.content,
@@ -2065,6 +2307,12 @@ var ManagementContextItemsResource = class {
2065
2307
  });
2066
2308
  return this.get(uid);
2067
2309
  }
2310
+ /**
2311
+ * Delete a context item.
2312
+ *
2313
+ * @param uid - Context item uid.
2314
+ * @returns Deletion confirmation details.
2315
+ */
2068
2316
  async delete(uid) {
2069
2317
  const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_delete", {
2070
2318
  pathParams: { uid }
@@ -2075,24 +2323,51 @@ var ManagementContextItemsResource = class {
2075
2323
 
2076
2324
  // src/management/context/context.ts
2077
2325
  var ManagementContextResource = class {
2326
+ /** @internal */
2078
2327
  constructor(http, config) {
2079
2328
  this.http = http;
2080
2329
  this.config = config;
2081
2330
  this.items = new ManagementContextItemsResource(http, config);
2082
2331
  this.customItems = new CustomContextItemsResource(http, config);
2083
2332
  }
2084
- async create(operationId, payload) {
2085
- const data = await invokeWithRetry(this.config, this.http, operationId, {
2086
- jsonBody: payload
2087
- });
2088
- return withCreatedUid(data);
2089
- }
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
+ */
2090
2344
  createNote(title, content) {
2091
2345
  return this.create("ContextCreatorsController_createNote", omitUndefined({ title, content }));
2092
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
+ */
2093
2359
  updateNote(uid, options) {
2094
2360
  return resolveAndUpdateNote(this.items, uid, options);
2095
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
+ */
2096
2371
  createSavedQuery(name, options) {
2097
2372
  return this.create(
2098
2373
  "ContextCreatorsController_createSavedQuery",
@@ -2105,9 +2380,27 @@ var ManagementContextResource = class {
2105
2380
  })
2106
2381
  );
2107
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
+ */
2108
2392
  updateSavedQuery(uid, options) {
2109
2393
  return resolveAndUpdateSavedQuery(this.items, uid, options);
2110
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
+ */
2111
2404
  createLink(url, options = {}) {
2112
2405
  return this.create(
2113
2406
  "ContextCreatorsController_createLink",
@@ -2119,9 +2412,27 @@ var ManagementContextResource = class {
2119
2412
  })
2120
2413
  );
2121
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
+ */
2122
2426
  updateLink(uid, options) {
2123
2427
  return resolveAndUpdateLink(this.items, uid, options);
2124
2428
  }
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);
2435
+ }
2125
2436
  };
2126
2437
 
2127
2438
  // src/resources/scopes/conversations.ts
@@ -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");
@@ -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");
@@ -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");
@@ -2300,6 +2674,12 @@ var ScopeSupervisionResource = class {
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
  }
@@ -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);
@@ -2389,6 +2816,13 @@ var ManagementScopesResource = class {
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(
@@ -2459,12 +2930,24 @@ var ManagementScopesResource = class {
2459
2930
  );
2460
2931
  return parseScope(data.scope);
2461
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,
@@ -2540,6 +3057,15 @@ var ManagementUsageResource = class {
2540
3057
  const data = await invokeWithRetry(this.config, this.http, "UsageController_list", { query });
2541
3058
  return data;
2542
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
+ */
2543
3069
  async listUsers(options) {
2544
3070
  const query = {
2545
3071
  since: options.since,
@@ -2552,12 +3078,44 @@ var ManagementUsageResource = class {
2552
3078
  }
2553
3079
  };
2554
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
+ }
3110
+ };
3111
+
2555
3112
  // src/management/users.ts
2556
3113
  var ManagementUsersResource = class {
2557
3114
  constructor(http, config) {
2558
3115
  this.http = http;
2559
3116
  this.config = config;
2560
3117
  }
3118
+ /** List member groups in the organization. */
2561
3119
  async listMemberGroups() {
2562
3120
  const data = await invokeWithRetry(
2563
3121
  this.config,
@@ -2566,6 +3124,7 @@ var ManagementUsersResource = class {
2566
3124
  );
2567
3125
  return data.groups;
2568
3126
  }
3127
+ /** List organization members. */
2569
3128
  async listOrgMembers() {
2570
3129
  const data = await invokeWithRetry(
2571
3130
  this.config,
@@ -2584,6 +3143,7 @@ var ModusManagement = class extends ModusClientBase {
2584
3143
  this.workflows = new ManagementWorkflowsResource(this.http, this.config);
2585
3144
  this.context = new ManagementContextResource(this.http, this.config);
2586
3145
  this.usage = new ManagementUsageResource(this.http, this.config);
3146
+ this.tools = new ManagementToolsResource(this.http, this.config);
2587
3147
  this.users = new ManagementUsersResource(this.http, this.config);
2588
3148
  }
2589
3149
  };