@getmodus/sdk 0.3.0 → 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.
package/dist/index.cjs CHANGED
@@ -685,6 +685,16 @@ var OPERATIONS = {
685
685
  requestSchema: "RecordSuggestionEventDto",
686
686
  responseSchema: null
687
687
  },
688
+ "ToolsController_list": {
689
+ method: "GET",
690
+ path: "/api/v1/tools",
691
+ service: "modus-api",
692
+ serverUrl: "https://api.getmodus.com",
693
+ pathParams: [],
694
+ queryParams: ["pageToken", "pageSize"],
695
+ requestSchema: null,
696
+ responseSchema: "ListToolsResponseDto"
697
+ },
688
698
  "UsageController_list": {
689
699
  method: "GET",
690
700
  path: "/api/v1/usage",
@@ -1259,11 +1269,27 @@ var ChatStream = class {
1259
1269
  this.baseUrl = baseUrl;
1260
1270
  this.textParts = [];
1261
1271
  }
1272
+ /**
1273
+ * Async iterable of assistant text token chunks as they arrive.
1274
+ *
1275
+ * @returns An async generator yielding partial text strings.
1276
+ * @throws {ModusError} When the stream emits an error event.
1277
+ * @throws {RunCancelledError} When the run is cancelled.
1278
+ * @throws {StreamTimeoutError} When the stream times out.
1279
+ */
1262
1280
  async *textStream() {
1263
1281
  for await (const event of this.events(false)) {
1264
1282
  if (event.type === "token") yield event.content;
1265
1283
  }
1266
1284
  }
1285
+ /**
1286
+ * Async iterable of structured run events (tokens, tool calls, done, and so on).
1287
+ *
1288
+ * @returns An async generator yielding {@link RunEvent} objects.
1289
+ * @throws {ModusError} When the stream emits an error event.
1290
+ * @throws {RunCancelledError} When the run is cancelled.
1291
+ * @throws {StreamTimeoutError} When the stream times out.
1292
+ */
1267
1293
  async *eventStream() {
1268
1294
  yield* this.events(true);
1269
1295
  }
@@ -1292,6 +1318,15 @@ var ChatStream = class {
1292
1318
  }
1293
1319
  }
1294
1320
  }
1321
+ /**
1322
+ * Final chat result after the stream completes.
1323
+ *
1324
+ * Call only after fully consuming {@link ChatStream.textStream} or
1325
+ * {@link ChatStream.eventStream}.
1326
+ *
1327
+ * @returns The assembled assistant reply, thread id, and run id.
1328
+ * @throws {ModusError} When called before the stream finishes with a done event.
1329
+ */
1295
1330
  getFinalResult() {
1296
1331
  if (this.final === void 0) {
1297
1332
  throw new ModusError(
@@ -1351,9 +1386,20 @@ var Page = class {
1351
1386
  this.nextPageToken = normalizePageToken(nextPageToken);
1352
1387
  this.fetchPage = fetchPage;
1353
1388
  }
1389
+ /**
1390
+ * Whether another page of results is available.
1391
+ *
1392
+ * @returns `true` when {@link Page.nextPageToken} is set.
1393
+ */
1354
1394
  hasNextPage() {
1355
1395
  return this.nextPageToken !== void 0;
1356
1396
  }
1397
+ /**
1398
+ * Fetch the next page using {@link Page.nextPageToken}.
1399
+ *
1400
+ * @returns The following page of results.
1401
+ * @throws {Error} When there is no next page. Check {@link Page.hasNextPage} first.
1402
+ */
1357
1403
  async getNextPage() {
1358
1404
  if (this.nextPageToken === void 0) {
1359
1405
  throw new Error(
@@ -1362,6 +1408,12 @@ var Page = class {
1362
1408
  }
1363
1409
  return this.fetchPage(this.nextPageToken);
1364
1410
  }
1411
+ /**
1412
+ * Async-iterate over all items across every page, fetching additional pages as needed.
1413
+ *
1414
+ * @returns An async generator yielding every item in the result set.
1415
+ * @throws {ModusError} When a follow-up page request fails.
1416
+ */
1365
1417
  async *autoPagingIter() {
1366
1418
  for (const item of this.items) yield item;
1367
1419
  let nextPageToken = this.nextPageToken;
@@ -1371,6 +1423,7 @@ var Page = class {
1371
1423
  nextPageToken = page.nextPageToken;
1372
1424
  }
1373
1425
  }
1426
+ /** Iterate over the current page's items only. */
1374
1427
  [Symbol.iterator]() {
1375
1428
  return this.items[Symbol.iterator]();
1376
1429
  }
@@ -1452,6 +1505,19 @@ function resolveBaseUrl(baseUrl) {
1452
1505
  function resolveAgentHost(agentHost) {
1453
1506
  return agentHost ?? process.env[ENV_AGENT_HOST] ?? void 0;
1454
1507
  }
1508
+ function isModusApiHostname(hostname) {
1509
+ return hostname === "api.getmodus.com" || /^api\.[a-z0-9-]+\.getmodus\.com$/i.test(hostname);
1510
+ }
1511
+ function deriveAgentHostFromBaseUrl(baseUrl) {
1512
+ try {
1513
+ const url = new URL(baseUrl);
1514
+ if (!isModusApiHostname(url.hostname)) return void 0;
1515
+ url.hostname = `agent.${url.hostname.slice("api.".length)}`;
1516
+ return url.origin;
1517
+ } catch {
1518
+ return void 0;
1519
+ }
1520
+ }
1455
1521
  function resolveOrganizationId(organizationId) {
1456
1522
  const raw = organizationId ?? process.env[ENV_ORGANIZATION_ID];
1457
1523
  if (raw === void 0) return void 0;
@@ -1503,7 +1569,7 @@ function createModusConfig(options = {}) {
1503
1569
  const baseUrl = normalizeBaseUrl(resolveBaseUrl(options.baseUrl) ?? DEFAULT_BASE_URL);
1504
1570
  const baseUrlOverrides = normalizeBaseUrls(options.baseUrls);
1505
1571
  const agentHost = normalizeBaseUrl(
1506
- baseUrlOverrides["agent-service"] ?? resolveAgentHost(options.agentHost) ?? DEFAULT_AGENT_HOST
1572
+ baseUrlOverrides["agent-service"] ?? resolveAgentHost(options.agentHost) ?? deriveAgentHostFromBaseUrl(baseUrl) ?? DEFAULT_AGENT_HOST
1507
1573
  );
1508
1574
  const organizationId = resolveOrganizationId(options.organizationId);
1509
1575
  return Object.freeze({
@@ -1533,7 +1599,7 @@ function formatConfigForLog(config) {
1533
1599
  }
1534
1600
 
1535
1601
  // src/_http.ts
1536
- var USER_AGENT = `modus-typescript/${"0.3.0"} (node/${process.version}; ${process.platform})`;
1602
+ var USER_AGENT = `modus-typescript/${"0.4.0"} (node/${process.version}; ${process.platform})`;
1537
1603
  function buildUrl(baseUrl, path, params) {
1538
1604
  const url = new URL(path.startsWith("/") ? path : `/${path}`, baseUrl);
1539
1605
  if (params) {
@@ -1945,10 +2011,23 @@ function makeAgentRunStream(runId, events) {
1945
2011
  };
1946
2012
  }
1947
2013
  var WorkflowRunsResource = class {
2014
+ /** @internal */
1948
2015
  constructor(http, config) {
1949
2016
  this.http = http;
1950
2017
  this.config = config;
1951
2018
  }
2019
+ /**
2020
+ * List runs for a workflow.
2021
+ *
2022
+ * @param workflowId - Workflow id or slug.
2023
+ * @param options.pageSize - Maximum items per page (default 25, max 100).
2024
+ * @param options.pageToken - Opaque token from a previous page.
2025
+ * @param options.status - Filter by run status.
2026
+ * @param options.timeframe - Filter by recency (`last_hour`, `last_day`, or `last_week`).
2027
+ * @param options.approvalScope - Filter approval-related runs (`mine` or `all`).
2028
+ * @param options.search - Free-text search filter.
2029
+ * @returns A page of run summaries.
2030
+ */
1952
2031
  list(workflowId, options = {}) {
1953
2032
  validateId(workflowId, "workflow_id");
1954
2033
  const pageSize = options.pageSize ?? 25;
@@ -1983,6 +2062,15 @@ var WorkflowRunsResource = class {
1983
2062
  (token) => this.listPage(workflowId, pageSize, token, filters)
1984
2063
  );
1985
2064
  }
2065
+ /**
2066
+ * Retrieve a workflow run by id.
2067
+ *
2068
+ * @param workflowId - Workflow id or slug the run belongs to.
2069
+ * @param runId - Run id.
2070
+ * @param options.temporalRunId - Optional internal execution id when disambiguating retries.
2071
+ * @returns Run details including status and output.
2072
+ * @throws {NotFoundError} When the run does not exist.
2073
+ */
1986
2074
  async get(workflowId, runId, options = {}) {
1987
2075
  validateId(workflowId, "workflow_id");
1988
2076
  if (!runId.trim()) throw new Error("run_id must be a non-empty string");
@@ -1993,21 +2081,69 @@ var WorkflowRunsResource = class {
1993
2081
  });
1994
2082
  return parseRun(data);
1995
2083
  }
2084
+ /**
2085
+ * Start a workflow run and stream run events.
2086
+ *
2087
+ * @param workflowId - Workflow id or slug to run.
2088
+ * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
2089
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
2090
+ * @returns A stream of run events (tokens, completion, errors, and related signals).
2091
+ *
2092
+ * @example
2093
+ * ```ts
2094
+ * const stream = client.workflows.runs.create(workflowId, {
2095
+ * message: 'Summarize yesterday\'s sales',
2096
+ * sessionId: 'conv-abc',
2097
+ * })
2098
+ * for await (const event of stream) {
2099
+ * if (event.type === 'token') process.stdout.write(event.content)
2100
+ * if (event.type === 'done') break
2101
+ * }
2102
+ * ```
2103
+ */
1996
2104
  create(workflowId, body, options = {}) {
1997
2105
  validateId(workflowId, "workflow_id");
1998
2106
  return this.createRun("WorkflowRunsController_create", body, { id: workflowId }, options);
1999
2107
  }
2108
+ /**
2109
+ * Start a scope run and stream run events.
2110
+ *
2111
+ * @param scopeId - Scope id to run.
2112
+ * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
2113
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
2114
+ * @returns A stream of run events.
2115
+ */
2000
2116
  createScope(scopeId, body, options = {}) {
2001
2117
  validateId(scopeId, "scope_id");
2002
2118
  return this.createRun("ScopeRunsController_create", body, { id: scopeId }, options);
2003
2119
  }
2120
+ /**
2121
+ * Start a Modus assistant run and stream run events.
2122
+ *
2123
+ * @param body - Run body (`message`, optional `sessionId`, optional `subordinateSkillIds` to narrow context).
2124
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
2125
+ * @returns A stream of run events.
2126
+ */
2004
2127
  createModus(body, options = {}) {
2005
2128
  return this.createRun("ModusRunsController_create", body, {}, options);
2006
2129
  }
2130
+ /**
2131
+ * Resume an interrupted run and stream run events.
2132
+ *
2133
+ * @param runId - Run id to resume.
2134
+ * @param body - Resume body (`message`, `sessionId`, and `decision`: `approve` / `deny` / `connected` / `cancelled`).
2135
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
2136
+ * @returns A stream of run events.
2137
+ */
2007
2138
  resume(runId, body, options = {}) {
2008
2139
  validateId(runId, "run_id");
2009
2140
  return this.createRun("ResumeRunsController_create", body, { runId }, options);
2010
2141
  }
2142
+ /**
2143
+ * Cancel a run that is still in progress.
2144
+ *
2145
+ * @param runId - Run id to cancel.
2146
+ */
2011
2147
  async cancel(runId) {
2012
2148
  validateId(runId, "run_id");
2013
2149
  await invokeWithRetry(this.config, this.http, "RunLifecycleController_cancel", {
@@ -2015,12 +2151,23 @@ var WorkflowRunsResource = class {
2015
2151
  jsonBody: {}
2016
2152
  });
2017
2153
  }
2154
+ /**
2155
+ * Fetch stored run events for a run.
2156
+ *
2157
+ * @param runId - Run id.
2158
+ * @returns Run event history for replay or inspection.
2159
+ */
2018
2160
  async events(runId) {
2019
2161
  validateId(runId, "run_id");
2020
2162
  return invokeWithRetry(this.config, this.http, "RunLifecycleController_events", {
2021
2163
  pathParams: { runId }
2022
2164
  });
2023
2165
  }
2166
+ /**
2167
+ * Request a graceful stop for a running execution.
2168
+ *
2169
+ * @param runId - Run id to interrupt.
2170
+ */
2024
2171
  async interrupt(runId) {
2025
2172
  validateId(runId, "run_id");
2026
2173
  await invokeWithRetry(this.config, this.http, "RunLifecycleController_interrupt", {
@@ -2028,6 +2175,11 @@ var WorkflowRunsResource = class {
2028
2175
  jsonBody: {}
2029
2176
  });
2030
2177
  }
2178
+ /**
2179
+ * Move a queued run back into an editable state before it starts.
2180
+ *
2181
+ * @param runId - Queued run id.
2182
+ */
2031
2183
  async editQueued(runId) {
2032
2184
  validateId(runId, "run_id");
2033
2185
  await invokeWithRetry(this.config, this.http, "RunLifecycleController_editQueued", {
@@ -2035,6 +2187,13 @@ var WorkflowRunsResource = class {
2035
2187
  jsonBody: {}
2036
2188
  });
2037
2189
  }
2190
+ /**
2191
+ * List active conversation runs across the organization.
2192
+ *
2193
+ * @param options.pageSize - Maximum items per page (default 50, max 100).
2194
+ * @param options.pageToken - Opaque token from a previous page.
2195
+ * @returns A page of active runs with session and status metadata.
2196
+ */
2038
2197
  active(options = {}) {
2039
2198
  const pageSize = options.pageSize ?? 50;
2040
2199
  validatePageSize(pageSize, RUNS_MAX_PAGE_SIZE);
@@ -2048,6 +2207,13 @@ var WorkflowRunsResource = class {
2048
2207
  (token) => this.activePage(pageSize, token)
2049
2208
  );
2050
2209
  }
2210
+ /**
2211
+ * Look up active runs for specific conversation sessions.
2212
+ *
2213
+ * @param sessionIds - Up to 100 session ids.
2214
+ * @returns Active runs matching any of the given sessions.
2215
+ * @throws {Error} When more than 100 session ids are provided.
2216
+ */
2051
2217
  async activeBySession(sessionIds) {
2052
2218
  const uniqueSessionIds = [...new Set(sessionIds.map((id) => id.trim()).filter(Boolean))];
2053
2219
  if (uniqueSessionIds.length > 100) {
@@ -2059,6 +2225,21 @@ var WorkflowRunsResource = class {
2059
2225
  })
2060
2226
  );
2061
2227
  }
2228
+ /**
2229
+ * Reconnect to an in-progress run and stream run events.
2230
+ *
2231
+ * @param runId - Run id to follow.
2232
+ * @param options.lastEventId - Resume after this event id when catching up.
2233
+ * @returns A stream of run events from the current execution point.
2234
+ *
2235
+ * @example
2236
+ * ```ts
2237
+ * const stream = client.workflows.runs.stream(runId, { lastEventId: checkpoint })
2238
+ * for await (const event of stream) {
2239
+ * if (event.type === 'token') process.stdout.write(event.content)
2240
+ * }
2241
+ * ```
2242
+ */
2062
2243
  stream(runId, options = {}) {
2063
2244
  validateId(runId, "run_id");
2064
2245
  const op = getOperation("RunLifecycleController_stream");
@@ -2095,10 +2276,18 @@ function randomRunId2() {
2095
2276
  return (0, import_node_crypto3.randomUUID)();
2096
2277
  }
2097
2278
  var AgentWorkflowActionsResource = class {
2279
+ /** @internal */
2098
2280
  constructor(http, config) {
2099
2281
  this.http = http;
2100
2282
  this.config = config;
2101
2283
  }
2284
+ /**
2285
+ * Execute a workflow action and stream run events.
2286
+ *
2287
+ * @param body - Action body (`organizationId`, `sessionId`, `workflowAction`, optional `previousOutputs`).
2288
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
2289
+ * @returns A stream of run events for the action execution.
2290
+ */
2102
2291
  execute(body, options = {}) {
2103
2292
  const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId2();
2104
2293
  const op = getOperation("WorkflowActionsController_execute");
@@ -2109,6 +2298,11 @@ var AgentWorkflowActionsResource = class {
2109
2298
  });
2110
2299
  return makeAgentRunStream(runId, this.parseEvents(lines));
2111
2300
  }
2301
+ /**
2302
+ * Cancel a workflow action run.
2303
+ *
2304
+ * @param runId - Action run id to cancel.
2305
+ */
2112
2306
  async cancel(runId) {
2113
2307
  validateId(runId, "run_id");
2114
2308
  await invokeWithRetry(this.config, this.http, "WorkflowActionsController_cancel", {
@@ -2134,12 +2328,24 @@ function parseWorkflow(raw) {
2134
2328
  return raw;
2135
2329
  }
2136
2330
  var WorkflowsResource = class {
2331
+ /** @internal */
2137
2332
  constructor(http, config) {
2138
2333
  this.http = http;
2139
2334
  this.config = config;
2140
2335
  this.runs = new WorkflowRunsResource(http, config);
2141
2336
  this.workflowActions = new AgentWorkflowActionsResource(http, config);
2142
2337
  }
2338
+ /**
2339
+ * List workflows.
2340
+ *
2341
+ * @param options.pageSize - Maximum items per page (default 25).
2342
+ * @param options.pageToken - Opaque token from a previous page.
2343
+ * @param options.search - Free-text search filter.
2344
+ * @param options.type - Workflow kind: `"task"` or `"workflow"`.
2345
+ * @param options.view - Which saved version to return (`active` or `draft`).
2346
+ * @param options.includeVariation - Include variation metadata when supported.
2347
+ * @returns A page of workflows.
2348
+ */
2143
2349
  list(options = {}) {
2144
2350
  const pageSize = options.pageSize ?? 25;
2145
2351
  validatePageSize(pageSize);
@@ -2172,6 +2378,15 @@ var WorkflowsResource = class {
2172
2378
  (token) => this.listPage(pageSize, token, search, type, view, includeVariation)
2173
2379
  );
2174
2380
  }
2381
+ /**
2382
+ * Retrieve a workflow by ID or slug.
2383
+ *
2384
+ * @param workflowId - Numeric id or slug.
2385
+ * @param options.view - Which saved version to return (`active` or `draft`).
2386
+ * @param options.includeVariation - Include variation metadata when supported.
2387
+ * @returns The workflow.
2388
+ * @throws {NotFoundError} When no workflow matches the id or slug.
2389
+ */
2175
2390
  async get(workflowId, options = {}) {
2176
2391
  validateId(workflowId, "workflow_id");
2177
2392
  const query = {};
@@ -2197,10 +2412,19 @@ function parseConnection(raw) {
2197
2412
  return raw;
2198
2413
  }
2199
2414
  var ConnectionsResource = class {
2415
+ /** @internal */
2200
2416
  constructor(http, config) {
2201
2417
  this.http = http;
2202
2418
  this.config = config;
2203
2419
  }
2420
+ /**
2421
+ * List integration connections.
2422
+ *
2423
+ * @param options.pageSize - Maximum items per page (default 25).
2424
+ * @param options.pageToken - Opaque token from a previous page.
2425
+ * @param options.type - Integration category; exact match filter.
2426
+ * @returns A page of connections.
2427
+ */
2204
2428
  list(options = {}) {
2205
2429
  const pageSize = options.pageSize ?? 25;
2206
2430
  validatePageSize(pageSize);
@@ -2219,6 +2443,16 @@ var ConnectionsResource = class {
2219
2443
  (token) => this.listPage(pageSize, token, type)
2220
2444
  );
2221
2445
  }
2446
+ /**
2447
+ * Find the first connection whose name matches (case-insensitive).
2448
+ *
2449
+ * Pages through {@link ConnectionsResource.list} until a match is found.
2450
+ *
2451
+ * @param options.name - Connection name to search for.
2452
+ * @param options.type - Optional integration category filter.
2453
+ * @param options.pageSize - Page size when scanning (default 25).
2454
+ * @returns The matching connection, or `undefined` if none is found.
2455
+ */
2222
2456
  async find(options) {
2223
2457
  const pageSize = options.pageSize ?? 25;
2224
2458
  validatePageSize(pageSize);
@@ -2257,10 +2491,20 @@ function parseDeletion(raw) {
2257
2491
  return raw;
2258
2492
  }
2259
2493
  var CustomContextItemsResource = class {
2494
+ /** @internal */
2260
2495
  constructor(http, config) {
2261
2496
  this.http = http;
2262
2497
  this.config = config;
2263
2498
  }
2499
+ /**
2500
+ * List custom context items.
2501
+ *
2502
+ * @param options.pageSize - Maximum items per page (default 25).
2503
+ * @param options.pageToken - Opaque token from a previous page.
2504
+ * @param options.searchQuery - Free-text search filter.
2505
+ * @param options.topics - Filter to items tagged with any of these topics.
2506
+ * @returns A page of custom context items.
2507
+ */
2264
2508
  list(options = {}) {
2265
2509
  const pageSize = options.pageSize ?? 25;
2266
2510
  validatePageSize(pageSize);
@@ -2282,6 +2526,13 @@ var CustomContextItemsResource = class {
2282
2526
  (token) => this.listPage(pageSize, token, options)
2283
2527
  );
2284
2528
  }
2529
+ /**
2530
+ * Retrieve a custom context item by uid.
2531
+ *
2532
+ * @param uid - Item uid.
2533
+ * @returns The custom context item.
2534
+ * @throws {NotFoundError} When no item matches the uid.
2535
+ */
2285
2536
  async get(uid) {
2286
2537
  return parseContextItem(
2287
2538
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_get", {
@@ -2289,6 +2540,26 @@ var CustomContextItemsResource = class {
2289
2540
  })
2290
2541
  );
2291
2542
  }
2543
+ /**
2544
+ * Create a custom context item.
2545
+ *
2546
+ * @param input.kind - Item kind (`source`, `collection`, `entity`, `field`, or `entity_samples`).
2547
+ * @param input.sourceId - Source identifier for the item hierarchy.
2548
+ * @param input.name - Display name when applicable.
2549
+ * @param input.content - Item payload.
2550
+ * @param input.idempotencyKey - Optional idempotency key for safe retries.
2551
+ * @returns Created item ids and hierarchy metadata.
2552
+ *
2553
+ * @example
2554
+ * ```ts
2555
+ * const created = await client.context.customItems.create({
2556
+ * kind: 'entity',
2557
+ * sourceId: 'my-source',
2558
+ * name: 'Q3 churn notes',
2559
+ * content: { summary: 'Key findings…' },
2560
+ * })
2561
+ * ```
2562
+ */
2292
2563
  async create(input) {
2293
2564
  return parseCreatedCustomContextItem(
2294
2565
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_create", {
@@ -2296,6 +2567,20 @@ var CustomContextItemsResource = class {
2296
2567
  })
2297
2568
  );
2298
2569
  }
2570
+ /**
2571
+ * Create multiple custom context items in one request.
2572
+ *
2573
+ * @param inputs - Items to create (same fields as {@link CustomContextItemsResource.create}).
2574
+ * @returns Created item metadata for each input.
2575
+ *
2576
+ * @example
2577
+ * ```ts
2578
+ * const created = await client.context.customItems.batchCreate([
2579
+ * { kind: 'field', sourceId: 'src', fieldName: 'region', dataType: 'string' },
2580
+ * { kind: 'field', sourceId: 'src', fieldName: 'amount', dataType: 'number' },
2581
+ * ])
2582
+ * ```
2583
+ */
2299
2584
  async batchCreate(inputs) {
2300
2585
  const data = asRecord(
2301
2586
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_batchCreate", {
@@ -2307,6 +2592,13 @@ var CustomContextItemsResource = class {
2307
2592
  const items = data.contextItems;
2308
2593
  return Array.isArray(items) ? items.map(parseCreatedCustomContextItem) : [];
2309
2594
  }
2595
+ /**
2596
+ * Update a custom context item.
2597
+ *
2598
+ * @param uid - Item uid.
2599
+ * @param input - Fields to change (kind and hierarchy ids cannot be changed).
2600
+ * @returns The updated item uid.
2601
+ */
2310
2602
  async update(uid, input) {
2311
2603
  return asRecord(
2312
2604
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_update", {
@@ -2315,6 +2607,12 @@ var CustomContextItemsResource = class {
2315
2607
  })
2316
2608
  );
2317
2609
  }
2610
+ /**
2611
+ * Delete a custom context item.
2612
+ *
2613
+ * @param uid - Item uid.
2614
+ * @returns Deletion confirmation with uid and context type.
2615
+ */
2318
2616
  async delete(uid) {
2319
2617
  return parseDeletion(
2320
2618
  await invokeWithRetry(this.config, this.http, "CustomContextItemsController_delete", {
@@ -2342,10 +2640,19 @@ function parseLookupResponse(raw) {
2342
2640
  return item;
2343
2641
  }
2344
2642
  var ContextItemsResource = class {
2643
+ /** @internal */
2345
2644
  constructor(http, config) {
2346
2645
  this.http = http;
2347
2646
  this.config = config;
2348
2647
  }
2648
+ /**
2649
+ * List knowledge-base items.
2650
+ *
2651
+ * @param options.pageSize - Maximum items per page (default 25).
2652
+ * @param options.pageToken - Opaque token from a previous page.
2653
+ * @param options.contextType - Filter to a single context type.
2654
+ * @returns A page of context items.
2655
+ */
2349
2656
  list(options = {}) {
2350
2657
  const pageSize = options.pageSize ?? 25;
2351
2658
  validatePageSize(pageSize);
@@ -2364,12 +2671,27 @@ var ContextItemsResource = class {
2364
2671
  (token) => this.listPage(pageSize, token, contextType)
2365
2672
  );
2366
2673
  }
2674
+ /**
2675
+ * Retrieve a knowledge-base item by uid.
2676
+ *
2677
+ * @param uid - Item uid.
2678
+ * @returns The context item.
2679
+ * @throws {NotFoundError} When no item matches the uid.
2680
+ */
2367
2681
  async get(uid) {
2368
2682
  const data = await invokeWithRetry(this.config, this.http, "ContextItemsController_get", {
2369
2683
  pathParams: { uid }
2370
2684
  });
2371
2685
  return parseContextItem2(data);
2372
2686
  }
2687
+ /**
2688
+ * Look up a knowledge-base item by type and data path.
2689
+ *
2690
+ * @param options.contextType - Context type to match.
2691
+ * @param options.dataPath - Hierarchical path segments that identify the item.
2692
+ * @param options.contentProjection - Optional fields to include from item content.
2693
+ * @returns The matching row, or `undefined` when no item is found (404).
2694
+ */
2373
2695
  async lookup(options) {
2374
2696
  const body = omitUndefined({
2375
2697
  contextType: options.contextType,
@@ -2388,11 +2710,30 @@ var ContextItemsResource = class {
2388
2710
  throw error;
2389
2711
  }
2390
2712
  }
2713
+ /**
2714
+ * List values stored under a content key on a context item.
2715
+ *
2716
+ * @param uid - Item uid.
2717
+ * @param contextType - Context type of the item.
2718
+ * @param contentKeyPath - Dot path to the value field inside item content.
2719
+ * @param options.pageSize - Maximum items per page (default 25).
2720
+ * @param options.pageToken - Opaque token from a previous page.
2721
+ * @returns A page of value rows.
2722
+ */
2391
2723
  listValues(uid, contextType, contentKeyPath, options = {}) {
2392
2724
  const pageSize = options.pageSize ?? 25;
2393
2725
  validatePageSize(pageSize, DEFAULT_MAX_PAGE_SIZE);
2394
2726
  return this.listValuesPage(uid, contextType, contentKeyPath, pageSize, options.pageToken);
2395
2727
  }
2728
+ /**
2729
+ * List values for a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.
2730
+ *
2731
+ * @param item - Context item (uses `item.uid` and `item.contextType`).
2732
+ * @param contentKeyPath - Dot path to the value field inside item content.
2733
+ * @param options.pageSize - Maximum items per page (default 25).
2734
+ * @param options.pageToken - Opaque token from a previous page.
2735
+ * @returns A page of value rows.
2736
+ */
2396
2737
  listValuesFor(item, contentKeyPath, options = {}) {
2397
2738
  return this.listValues(item.uid, item.contextType, contentKeyPath, options);
2398
2739
  }
@@ -2417,6 +2758,7 @@ var ContextItemsResource = class {
2417
2758
 
2418
2759
  // src/resources/context/context.ts
2419
2760
  var ContextResource = class {
2761
+ /** @internal */
2420
2762
  constructor(http, config) {
2421
2763
  this.items = new ContextItemsResource(http, config);
2422
2764
  this.customItems = new CustomContextItemsResource(http, config);
@@ -2446,6 +2788,14 @@ var ModusConversationsResource = class {
2446
2788
  this.http = http;
2447
2789
  this.config = config;
2448
2790
  }
2791
+ /**
2792
+ * List conversations.
2793
+ *
2794
+ * @param options.pageSize - Items per page (default 25).
2795
+ * @param options.pageToken - Opaque token from a previous page.
2796
+ * @param options.kind - `"modus"`, `"scopes"`, or `"all"`.
2797
+ * @returns Page of conversation list items.
2798
+ */
2449
2799
  list(options = {}) {
2450
2800
  const pageSize = options.pageSize ?? 25;
2451
2801
  validatePageSize(pageSize);
@@ -2464,6 +2814,12 @@ var ModusConversationsResource = class {
2464
2814
  (token) => this.listPage(pageSize, token, kind)
2465
2815
  );
2466
2816
  }
2817
+ /**
2818
+ * Retrieve a conversation thread with full message history.
2819
+ *
2820
+ * @param threadId - Conversation thread id.
2821
+ * @returns Conversation with messages.
2822
+ */
2467
2823
  async get(threadId) {
2468
2824
  validateId(threadId, "thread_id");
2469
2825
  const data = await invokeWithRetry(this.config, this.http, "ModusConversationsController_get", {
@@ -2480,15 +2836,44 @@ var ModusResource = class {
2480
2836
  this.config = config;
2481
2837
  this.conversations = new ModusConversationsResource(http, config);
2482
2838
  }
2839
+ /**
2840
+ * Return composed full-environment context for an intent, without running chat.
2841
+ *
2842
+ * @param message - User intent or question to compose context for.
2843
+ * @param options.limit - Optional cap on structured fallback items.
2844
+ * @returns Composed Modus context.
2845
+ */
2483
2846
  async getContext(message, options = {}) {
2484
2847
  const data = await invokeWithRetry(this.config, this.http, "ModusContextController_compose", {
2485
2848
  jsonBody: omitUndefined({ message, limit: options.limit })
2486
2849
  });
2487
2850
  return data;
2488
2851
  }
2852
+ /**
2853
+ * Send a message to Modus (org-wide assistant) and get the complete reply.
2854
+ *
2855
+ * @param message - Message to send.
2856
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
2857
+ * @param options.threadId - Continue an existing conversation.
2858
+ * @returns Chat result with content and threadId.
2859
+ *
2860
+ * @example
2861
+ * ```ts
2862
+ * const result = await client.modus.chat('What tables describe revenue?', { model: 'claude-sonnet-5' })
2863
+ * console.log(result.content, result.threadId)
2864
+ * ```
2865
+ */
2489
2866
  chat(message, options) {
2490
2867
  return modusChatBuffered(this.http, message, options);
2491
2868
  }
2869
+ /**
2870
+ * Stream a Modus reply token by token.
2871
+ *
2872
+ * @param message - Message to send.
2873
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
2874
+ * @param options.threadId - Continue an existing conversation.
2875
+ * @returns Chat stream.
2876
+ */
2492
2877
  chatStream(message, options) {
2493
2878
  return modusChatStreamSession(this.http, this.config, message, options);
2494
2879
  }
@@ -2507,6 +2892,13 @@ var ScopeConversationsResource = class {
2507
2892
  this.config = config;
2508
2893
  this.scopeId = scopeId;
2509
2894
  }
2895
+ /**
2896
+ * List conversation threads for this scope, newest first.
2897
+ *
2898
+ * @param options.pageSize - Items per page (default 25).
2899
+ * @param options.pageToken - Opaque token from a previous page.
2900
+ * @returns Page of conversation list items.
2901
+ */
2510
2902
  list(options = {}) {
2511
2903
  const pageSize = options.pageSize ?? 25;
2512
2904
  validatePageSize(pageSize);
@@ -2527,6 +2919,14 @@ var ScopeConversationsResource = class {
2527
2919
  (token) => this.listPage(pageSize, token)
2528
2920
  );
2529
2921
  }
2922
+ /**
2923
+ * Retrieve a thread with full message history.
2924
+ *
2925
+ * @param threadId - Conversation thread id.
2926
+ * @param options.messageLimit - Maximum messages to return (1–100).
2927
+ * @param options.beforeMessageIndex - Return messages before this index (requires messageLimit).
2928
+ * @returns Conversation with messages.
2929
+ */
2530
2930
  async get(threadId, options = {}) {
2531
2931
  validateId(this.scopeId, "scope_id");
2532
2932
  validateId(threadId, "thread_id");
@@ -2556,13 +2956,30 @@ function parseScope(raw) {
2556
2956
  return raw;
2557
2957
  }
2558
2958
  var ScopesResource = class {
2959
+ /** @internal */
2559
2960
  constructor(http, config) {
2560
2961
  this.http = http;
2561
2962
  this.config = config;
2562
2963
  }
2964
+ /**
2965
+ * Return the conversations sub-resource scoped to `scopeId`.
2966
+ *
2967
+ * @param scopeId - Scope numeric id or slug.
2968
+ * @returns Conversations resource for the scope.
2969
+ */
2563
2970
  conversations(scopeId) {
2564
2971
  return new ScopeConversationsResource(this.http, this.config, scopeId);
2565
2972
  }
2973
+ /**
2974
+ * List scopes in the organisation.
2975
+ *
2976
+ * @param options.pageSize - Items per page (default 25).
2977
+ * @param options.pageToken - Opaque token from a previous page.
2978
+ * @param options.search - Case-insensitive substring filter on the scope name.
2979
+ * @param options.view - `"active"` (deployed) or `"draft"`.
2980
+ * @param options.managerId - Only scopes supervised by this manager scope id.
2981
+ * @returns Page of scopes.
2982
+ */
2566
2983
  list(options = {}) {
2567
2984
  const pageSize = options.pageSize ?? 25;
2568
2985
  validatePageSize(pageSize);
@@ -2587,6 +3004,14 @@ var ScopesResource = class {
2587
3004
  (token) => this.listPage(pageSize, token, search, view, managerId)
2588
3005
  );
2589
3006
  }
3007
+ /**
3008
+ * Retrieve a scope by ID or slug.
3009
+ *
3010
+ * @param scopeId - Scope numeric id or slug.
3011
+ * @param options.view - `"active"` (deployed) or `"draft"`.
3012
+ * @throws {NotFoundError} When no scope matches the id or slug.
3013
+ * @returns Scope.
3014
+ */
2590
3015
  async get(scopeId, options = {}) {
2591
3016
  validateId(scopeId, "scope_id");
2592
3017
  const query = options.view !== void 0 ? { view: options.view } : void 0;
@@ -2596,6 +3021,14 @@ var ScopesResource = class {
2596
3021
  });
2597
3022
  return parseScope(data);
2598
3023
  }
3024
+ /**
3025
+ * Return composed context Modus would use for a scope query, without running chat.
3026
+ *
3027
+ * @param scopeId - Scope numeric id or slug.
3028
+ * @param message - User intent or question to compose context for.
3029
+ * @param options.limit - Optional cap on structured fallback items.
3030
+ * @returns Composed scope context.
3031
+ */
2599
3032
  async getContext(scopeId, message, options = {}) {
2600
3033
  validateId(scopeId, "scope_id");
2601
3034
  const data = await invokeWithRetry(this.config, this.http, "ScopeContextController_compose", {
@@ -2604,9 +3037,34 @@ var ScopesResource = class {
2604
3037
  });
2605
3038
  return data;
2606
3039
  }
3040
+ /**
3041
+ * Send a message to a scope and get the complete reply.
3042
+ *
3043
+ * @param scopeId - Scope numeric id or slug.
3044
+ * @param message - Message to send.
3045
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
3046
+ * @param options.threadId - Continue an existing conversation.
3047
+ * @returns Chat result with content and threadId.
3048
+ *
3049
+ * @example
3050
+ * ```ts
3051
+ * const result = await client.scopes.chat(scopeId, 'Hello', { model: 'claude-sonnet-5' })
3052
+ * console.log(result.content, result.threadId)
3053
+ * ```
3054
+ */
2607
3055
  chat(scopeId, message, options) {
2608
3056
  return chatBuffered(this.http, "scopes", scopeId, message, options);
2609
3057
  }
3058
+ /**
3059
+ * Stream a scope reply token by token.
3060
+ *
3061
+ * @param scopeId - Scope numeric id or slug.
3062
+ * @param message - Message to send.
3063
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
3064
+ * @param options.threadId - Continue an existing conversation.
3065
+ * @param options.version - `"published"` or `"draft"`.
3066
+ * @returns Chat stream.
3067
+ */
2610
3068
  chatStream(scopeId, message, options) {
2611
3069
  return chatStreamSession(this.http, this.config, "scopes", scopeId, message, options);
2612
3070
  }
@@ -2627,10 +3085,20 @@ function suggestionListParams(options) {
2627
3085
  };
2628
3086
  }
2629
3087
  var SuggestionsResource = class {
3088
+ /** @internal */
2630
3089
  constructor(http, config) {
2631
3090
  this.http = http;
2632
3091
  this.config = config;
2633
3092
  }
3093
+ /**
3094
+ * List approved suggested questions.
3095
+ *
3096
+ * @param options.pageSize - Maximum items per page (default 5, max 12).
3097
+ * @param options.pageToken - Opaque token from a previous page.
3098
+ * @param options.scopeId - Filter to a single scope.
3099
+ * @param options.scopeIds - Filter to one or more scopes.
3100
+ * @returns A page of suggested questions.
3101
+ */
2634
3102
  list(options = {}) {
2635
3103
  const pageSize = options.pageSize ?? DEFAULT_SUGGESTIONS_PAGE_SIZE;
2636
3104
  validatePageSize(pageSize, MAX_SUGGESTIONS_PAGE_SIZE);
@@ -2649,6 +3117,12 @@ var SuggestionsResource = class {
2649
3117
  (token) => this.listPage(pageSize, token, scopeId, scopeIds)
2650
3118
  );
2651
3119
  }
3120
+ /**
3121
+ * Record that a suggested question was shown, clicked, dismissed, or submitted.
3122
+ *
3123
+ * @param id - Suggestion id.
3124
+ * @param event - Event details, including `eventType` (`shown`, `clicked`, `dismissed`, or `submitted`).
3125
+ */
2652
3126
  async recordEvent(id, event) {
2653
3127
  validateId(id, "id");
2654
3128
  await invokeWithRetry(this.config, this.http, "SuggestionsController_recordEvent", {