@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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,12 @@
1
- import { c as components, H as HttpClient, M as ModusConfig, P as Page, A as AgentType, V as VariationView, a as Agent, C as ContextItem, b as ContextItemLookupRow, d as CustomContextItemsResource, e as ConversationKind, f as ConversationListItem, g as Conversation, S as ScopeConversationsResource, h as Skill, i as ModusClientBase, j as ModusOptions } from './conversations-BP2sI3Q5.cjs';
2
- export { k as ContextType, l as Message, O as OPERATIONS, m as OperationId, n as OperationSpec, o as SkillStatus, p as SkillVariation, q as conversationSkillId, r as operations, s as paths } from './conversations-BP2sI3Q5.cjs';
1
+ import { c as components, H as HttpClient, M as ModusConfig, P as Page, W as WorkflowType, V as VariationView, a as Workflow, C as ContextItem, b as ContextItemLookupRow, d as CustomContextItemsResource, e as ConversationKind, f as ConversationListItem, g as Conversation, S as ScopeConversationsResource, h as Scope, i as ModusClientBase, j as ModusOptions } from './conversations-Cq6OVlpQ.cjs';
2
+ export { A as Agent, k as AgentType, l as ContextType, m as Message, O as OPERATIONS, n as OperationId, o as OperationSpec, p as ScopeStatus, q as ScopeVariation, r as Skill, s as SkillStatus, t as SkillVariation, u as conversationScopeId, v as conversationSkillId, w as operations, x as paths } from './conversations-Cq6OVlpQ.cjs';
3
3
 
4
+ /**
5
+ * Base class for all Modus SDK errors.
6
+ *
7
+ * HTTP failures map to subclasses by status code. Streaming run failures map
8
+ * from event types (`error`, `cancelled`, `stream_timeout`).
9
+ */
4
10
  declare class ModusError extends Error {
5
11
  readonly statusCode?: number;
6
12
  readonly requestId?: string;
@@ -15,49 +21,128 @@ declare class ModusError extends Error {
15
21
  code?: string;
16
22
  });
17
23
  }
24
+ /**
25
+ * Network-level failure (connection error, read timeout, etc.) after all
26
+ * automatic retries are exhausted.
27
+ */
18
28
  declare class APIConnectionError extends ModusError {
19
29
  constructor(message: string);
20
30
  }
31
+ /**
32
+ * The API key is missing, invalid, or expired (HTTP 401).
33
+ *
34
+ * Check that `MODUS_API_KEY` is set correctly, or pass `apiKey` explicitly.
35
+ * Create a token at app.getmodus.com → Settings → API Tokens.
36
+ */
21
37
  declare class AuthenticationError extends ModusError {
22
38
  constructor(message: string, options?: ConstructorParameters<typeof ModusError>[1]);
23
39
  }
40
+ /**
41
+ * The API key does not have permission for the requested operation (HTTP 403).
42
+ */
24
43
  declare class PermissionDeniedError extends ModusError {
25
44
  constructor(message: string, options?: ConstructorParameters<typeof ModusError>[1]);
26
45
  }
46
+ /** The requested resource does not exist (HTTP 404). */
27
47
  declare class NotFoundError extends ModusError {
28
48
  constructor(message: string, options?: ConstructorParameters<typeof ModusError>[1]);
29
49
  }
50
+ /**
51
+ * Idempotency conflict — a run with this ID already exists with a different
52
+ * body (HTTP 409). Use a new idempotency key or omit it to auto-generate.
53
+ */
30
54
  declare class ConflictError extends ModusError {
31
55
  constructor(message: string, options?: ConstructorParameters<typeof ModusError>[1]);
32
56
  }
57
+ /**
58
+ * Request validation failed (HTTP 422).
59
+ *
60
+ * Inspect `errors` when present for field-level details.
61
+ */
33
62
  declare class UnprocessableError extends ModusError {
34
63
  readonly errors?: unknown;
35
64
  constructor(message: string, options?: ConstructorParameters<typeof ModusError>[1] & {
36
65
  errors?: unknown;
37
66
  });
38
67
  }
68
+ /**
69
+ * Too many requests (HTTP 429).
70
+ *
71
+ * When present, `retryAfter` is the suggested wait in seconds.
72
+ */
39
73
  declare class RateLimitError extends ModusError {
40
74
  readonly retryAfter?: number;
41
75
  constructor(message: string, options?: ConstructorParameters<typeof ModusError>[1] & {
42
76
  retryAfter?: number;
43
77
  });
44
78
  }
79
+ /** Unexpected server failure (HTTP 5xx). */
45
80
  declare class InternalServerError extends ModusError {
46
81
  constructor(message: string, statusCode: number, options?: ConstructorParameters<typeof ModusError>[1]);
47
82
  }
83
+ /** The run was cancelled before it finished. */
48
84
  declare class RunCancelledError extends ModusError {
49
85
  constructor(message?: string);
50
86
  }
87
+ /** The streaming connection timed out before a final result arrived. */
51
88
  declare class StreamTimeoutError extends ModusError {
52
89
  constructor(message?: string);
53
90
  }
91
+ /**
92
+ * Client-side argument validation failed before a request was sent
93
+ * (for example an unsupported chat model id).
94
+ */
54
95
  declare class ValidationError extends ModusError {
55
96
  constructor(message: string);
56
97
  }
57
98
 
58
- type ChatResult = components['schemas']['SkillChatResponseDto'];
59
- type ChatRequest = components['schemas']['SkillChatRequestDto'];
60
- type ChatModel = ChatRequest['model'];
99
+ /**
100
+ * Canonical model id accepted by Modus chat APIs.
101
+ *
102
+ * Pass as `model` to `client.modus.chat(...)`, `client.scopes.chat(...)`,
103
+ * and the matching stream methods. An unsupported value fails client-side
104
+ * validation before the request is sent.
105
+ *
106
+ * Allowed values:
107
+ * - `claude-sonnet-5`, `claude-sonnet-4.6`, `claude-opus-4.8`
108
+ * - `gpt-5.2`, `gpt-5.5`, `gpt-5-mini`, `gpt-oss-120b`, `gpt-oss-20b`
109
+ * - `qwen3-235b-a22b-2507`, `qwen3-coder`, `qwen3-32b`
110
+ * - `deepseek-chat-v3.1`, `minimax-m2.7`
111
+ * - `llama-4-maverick`, `llama-4-scout`, `llama-3.3-70b-instruct`
112
+ * - `gemini-3.1-pro-preview`, `gemini-3-flash-preview`
113
+ * - `grok-4.3-fast`, `grok-4.3`
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * const result = await client.modus.chat('Summarize open tickets', {
118
+ * model: 'claude-sonnet-4.6',
119
+ * })
120
+ * ```
121
+ */
122
+ type ChatModel = components['schemas']['SkillChatRequestDto']['model'];
123
+ /**
124
+ * Chat request body (`message` + required `model`).
125
+ *
126
+ * Prefer `client.modus.chat(...)` / `client.scopes.chat(...)` — they take these
127
+ * fields as method arguments so you rarely construct this type yourself.
128
+ */
129
+ interface ChatRequest {
130
+ /** User message sent to the skill / Modus. */
131
+ message: string;
132
+ /** Canonical model id for this run (required). See {@link ChatModel}. */
133
+ model: ChatModel;
134
+ }
135
+ /**
136
+ * Chat response: final assistant text plus `threadId` for follow-ups.
137
+ */
138
+ interface ChatResult {
139
+ /** Final assistant text for the run. */
140
+ content: string;
141
+ /** Conversation thread id for follow-up messages. */
142
+ threadId: string;
143
+ /** Opaque run id for logging / correlation. */
144
+ runId: string;
145
+ }
61
146
 
62
147
  interface TokenEvent {
63
148
  readonly type: 'token';
@@ -96,6 +181,10 @@ interface ActiveConversationRun {
96
181
  }
97
182
  type RunEvent = TokenEvent | DoneEvent | ErrorEvent | CancelledEvent | StreamTimeoutEvent | AssistantContentResetEvent;
98
183
 
184
+ /**
185
+ * Streaming chat session. Iterate {@link ChatStream.textStream} or
186
+ * {@link ChatStream.eventStream}, then call {@link ChatStream.getFinalResult}.
187
+ */
99
188
  declare class ChatStream {
100
189
  private readonly http;
101
190
  private readonly path;
@@ -104,9 +193,34 @@ declare class ChatStream {
104
193
  private final?;
105
194
  private readonly textParts;
106
195
  constructor(http: HttpClient, path: string, body: Record<string, unknown>, baseUrl?: string | undefined);
196
+ /**
197
+ * Async iterable of assistant text token chunks as they arrive.
198
+ *
199
+ * @returns An async generator yielding partial text strings.
200
+ * @throws {ModusError} When the stream emits an error event.
201
+ * @throws {RunCancelledError} When the run is cancelled.
202
+ * @throws {StreamTimeoutError} When the stream times out.
203
+ */
107
204
  textStream(): AsyncGenerator<string>;
205
+ /**
206
+ * Async iterable of structured run events (tokens, tool calls, done, and so on).
207
+ *
208
+ * @returns An async generator yielding {@link RunEvent} objects.
209
+ * @throws {ModusError} When the stream emits an error event.
210
+ * @throws {RunCancelledError} When the run is cancelled.
211
+ * @throws {StreamTimeoutError} When the stream times out.
212
+ */
108
213
  eventStream(): AsyncGenerator<RunEvent>;
109
214
  private events;
215
+ /**
216
+ * Final chat result after the stream completes.
217
+ *
218
+ * Call only after fully consuming {@link ChatStream.textStream} or
219
+ * {@link ChatStream.eventStream}.
220
+ *
221
+ * @returns The assembled assistant reply, thread id, and run id.
222
+ * @throws {ModusError} When called before the stream finishes with a done event.
223
+ */
110
224
  getFinalResult(): ChatResult;
111
225
  }
112
226
 
@@ -132,7 +246,20 @@ interface AgentRunStream extends AsyncIterable<RunEvent> {
132
246
  declare class WorkflowRunsResource {
133
247
  private readonly http;
134
248
  private readonly config;
249
+ /** @internal */
135
250
  constructor(http: HttpClient, config: ModusConfig);
251
+ /**
252
+ * List runs for a workflow.
253
+ *
254
+ * @param workflowId - Workflow id or slug.
255
+ * @param options.pageSize - Maximum items per page (default 25, max 100).
256
+ * @param options.pageToken - Opaque token from a previous page.
257
+ * @param options.status - Filter by run status.
258
+ * @param options.timeframe - Filter by recency (`last_hour`, `last_day`, or `last_week`).
259
+ * @param options.approvalScope - Filter approval-related runs (`mine` or `all`).
260
+ * @param options.search - Free-text search filter.
261
+ * @returns A page of run summaries.
262
+ */
136
263
  list(workflowId: number | string, options?: {
137
264
  pageSize?: number;
138
265
  pageToken?: string;
@@ -142,31 +269,133 @@ declare class WorkflowRunsResource {
142
269
  search?: string;
143
270
  }): Promise<Page<AgentRunListItem>>;
144
271
  private listPage;
272
+ /**
273
+ * Retrieve a workflow run by id.
274
+ *
275
+ * @param workflowId - Workflow id or slug the run belongs to.
276
+ * @param runId - Run id.
277
+ * @param options.temporalRunId - Optional internal execution id when disambiguating retries.
278
+ * @returns Run details including status and output.
279
+ * @throws {NotFoundError} When the run does not exist.
280
+ */
145
281
  get(workflowId: number | string, runId: string, options?: {
146
282
  temporalRunId?: string;
147
283
  }): Promise<AgentRun>;
284
+ /**
285
+ * Start a workflow run and stream run events.
286
+ *
287
+ * @param workflowId - Workflow id or slug to run.
288
+ * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
289
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
290
+ * @returns A stream of run events (tokens, completion, errors, and related signals).
291
+ *
292
+ * @example
293
+ * ```ts
294
+ * const stream = client.workflows.runs.create(workflowId, {
295
+ * message: 'Summarize yesterday\'s sales',
296
+ * sessionId: 'conv-abc',
297
+ * })
298
+ * for await (const event of stream) {
299
+ * if (event.type === 'token') process.stdout.write(event.content)
300
+ * if (event.type === 'done') break
301
+ * }
302
+ * ```
303
+ */
148
304
  create(workflowId: number | string, body: CreateAgentRunRequest, options?: {
149
305
  idempotencyKey?: string;
150
306
  }): AgentRunStream;
307
+ /**
308
+ * Start a scope run and stream run events.
309
+ *
310
+ * @param scopeId - Scope id to run.
311
+ * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
312
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
313
+ * @returns A stream of run events.
314
+ */
151
315
  createScope(scopeId: number | string, body: SkillRunCreateRequest, options?: {
152
316
  idempotencyKey?: string;
153
317
  }): AgentRunStream;
318
+ /**
319
+ * Start a Modus assistant run and stream run events.
320
+ *
321
+ * @param body - Run body (`message`, optional `sessionId`, optional `subordinateSkillIds` to narrow context).
322
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
323
+ * @returns A stream of run events.
324
+ */
154
325
  createModus(body: ModusRunCreateRequest, options?: {
155
326
  idempotencyKey?: string;
156
327
  }): AgentRunStream;
328
+ /**
329
+ * Resume an interrupted run and stream run events.
330
+ *
331
+ * @param runId - Run id to resume.
332
+ * @param body - Resume body (`message`, `sessionId`, and `decision`: `approve` / `deny` / `connected` / `cancelled`).
333
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
334
+ * @returns A stream of run events.
335
+ */
157
336
  resume(runId: string, body: ResumeRunRequest, options?: {
158
337
  idempotencyKey?: string;
159
338
  }): AgentRunStream;
339
+ /**
340
+ * Cancel a run that is still in progress.
341
+ *
342
+ * @param runId - Run id to cancel.
343
+ */
160
344
  cancel(runId: string): Promise<void>;
345
+ /**
346
+ * Fetch stored run events for a run.
347
+ *
348
+ * @param runId - Run id.
349
+ * @returns Run event history for replay or inspection.
350
+ */
161
351
  events(runId: string): Promise<unknown>;
352
+ /**
353
+ * Request a graceful stop for a running execution.
354
+ *
355
+ * @param runId - Run id to interrupt.
356
+ */
162
357
  interrupt(runId: string): Promise<void>;
358
+ /**
359
+ * Move a queued run back into an editable state before it starts.
360
+ *
361
+ * @param runId - Queued run id.
362
+ */
163
363
  editQueued(runId: string): Promise<void>;
364
+ /**
365
+ * List active conversation runs across the organization.
366
+ *
367
+ * @param options.pageSize - Maximum items per page (default 50, max 100).
368
+ * @param options.pageToken - Opaque token from a previous page.
369
+ * @returns A page of active runs with session and status metadata.
370
+ */
164
371
  active(options?: {
165
372
  pageSize?: number;
166
373
  pageToken?: string;
167
374
  }): Promise<Page<ActiveConversationRun>>;
168
375
  private activePage;
376
+ /**
377
+ * Look up active runs for specific conversation sessions.
378
+ *
379
+ * @param sessionIds - Up to 100 session ids.
380
+ * @returns Active runs matching any of the given sessions.
381
+ * @throws {Error} When more than 100 session ids are provided.
382
+ */
169
383
  activeBySession(sessionIds: readonly string[]): Promise<ActiveConversationRun[]>;
384
+ /**
385
+ * Reconnect to an in-progress run and stream run events.
386
+ *
387
+ * @param runId - Run id to follow.
388
+ * @param options.lastEventId - Resume after this event id when catching up.
389
+ * @returns A stream of run events from the current execution point.
390
+ *
391
+ * @example
392
+ * ```ts
393
+ * const stream = client.workflows.runs.stream(runId, { lastEventId: checkpoint })
394
+ * for await (const event of stream) {
395
+ * if (event.type === 'token') process.stdout.write(event.content)
396
+ * }
397
+ * ```
398
+ */
170
399
  stream(runId: string, options?: {
171
400
  lastEventId?: string;
172
401
  }): AgentRunStream;
@@ -187,65 +416,113 @@ type ModusContextRequest = components['schemas']['ModusContextRequestDto'];
187
416
  type SuggestionQuestion = components['schemas']['SuggestionQuestionDto'];
188
417
  type SuggestionEventType = components['schemas']['SuggestionEventType'];
189
418
  type SuggestionEventSource = components['schemas']['SuggestionEventSource'];
190
- /** Wire format (snake_case) plus camelCase aliases for DX. */
191
- type RecordSuggestionEventRequest = components['schemas']['RecordSuggestionEventDto'] & {
192
- eventType?: components['schemas']['SuggestionEventType'];
193
- skillId?: number;
194
- threadId?: string;
195
- };
419
+ /** Request body for recording a suggestion event (camelCase, matches the wire). */
420
+ type RecordSuggestionEventRequest = components['schemas']['RecordSuggestionEventDto'];
196
421
 
197
422
  declare class AgentWorkflowActionsResource {
198
423
  private readonly http;
199
424
  private readonly config;
425
+ /** @internal */
200
426
  constructor(http: HttpClient, config: ModusConfig);
427
+ /**
428
+ * Execute a workflow action and stream run events.
429
+ *
430
+ * @param body - Action body (`organizationId`, `sessionId`, `workflowAction`, optional `previousOutputs`).
431
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
432
+ * @returns A stream of run events for the action execution.
433
+ */
201
434
  execute(body: WorkflowActionRequest, options?: {
202
435
  idempotencyKey?: string;
203
436
  }): AgentRunStream;
437
+ /**
438
+ * Cancel a workflow action run.
439
+ *
440
+ * @param runId - Action run id to cancel.
441
+ */
204
442
  cancel(runId: string): Promise<void>;
205
443
  private parseEvents;
206
444
  }
207
445
 
208
- /** Read / invoke access to Modus workflows (`/api/v1/workflows`). */
446
+ /**
447
+ * Read and run access to Modus workflows.
448
+ *
449
+ * - {@link WorkflowRunsResource runs} — start, monitor, and control workflow runs.
450
+ * - {@link AgentWorkflowActionsResource workflowActions} — execute workflow actions.
451
+ */
209
452
  declare class WorkflowsResource {
210
453
  private readonly http;
211
454
  private readonly config;
212
455
  readonly runs: WorkflowRunsResource;
213
456
  readonly workflowActions: AgentWorkflowActionsResource;
457
+ /** @internal */
214
458
  constructor(http: HttpClient, config: ModusConfig);
459
+ /**
460
+ * List workflows.
461
+ *
462
+ * @param options.pageSize - Maximum items per page (default 25).
463
+ * @param options.pageToken - Opaque token from a previous page.
464
+ * @param options.search - Free-text search filter.
465
+ * @param options.type - Workflow kind: `"task"` or `"workflow"`.
466
+ * @param options.view - Which saved version to return (`active` or `draft`).
467
+ * @param options.includeVariation - Include variation metadata when supported.
468
+ * @returns A page of workflows.
469
+ */
215
470
  list(options?: {
216
471
  pageSize?: number;
217
472
  pageToken?: string;
218
473
  search?: string;
219
- type?: AgentType;
474
+ type?: WorkflowType;
220
475
  view?: VariationView;
221
476
  includeVariation?: boolean;
222
- }): Promise<Page<Agent>>;
477
+ }): Promise<Page<Workflow>>;
223
478
  private listPage;
479
+ /**
480
+ * Retrieve a workflow by ID or slug.
481
+ *
482
+ * @param workflowId - Numeric id or slug.
483
+ * @param options.view - Which saved version to return (`active` or `draft`).
484
+ * @param options.includeVariation - Include variation metadata when supported.
485
+ * @returns The workflow.
486
+ * @throws {NotFoundError} When no workflow matches the id or slug.
487
+ */
224
488
  get(workflowId: number | string, options?: {
225
489
  view?: VariationView;
226
490
  includeVariation?: boolean;
227
- }): Promise<Agent>;
228
- chat(workflowId: number | string, message: string, options: {
229
- model: ChatModel;
230
- threadId?: string;
231
- }): Promise<ChatResult>;
232
- chatStream(workflowId: number | string, message: string, options: {
233
- model: ChatModel;
234
- threadId?: string;
235
- version?: string;
236
- }): ChatStream;
491
+ }): Promise<Workflow>;
237
492
  }
238
493
 
494
+ /**
495
+ * Read access to integration connections.
496
+ */
239
497
  declare class ConnectionsResource {
240
498
  private readonly http;
241
499
  private readonly config;
500
+ /** @internal */
242
501
  constructor(http: HttpClient, config: ModusConfig);
502
+ /**
503
+ * List integration connections.
504
+ *
505
+ * @param options.pageSize - Maximum items per page (default 25).
506
+ * @param options.pageToken - Opaque token from a previous page.
507
+ * @param options.type - Integration category; exact match filter.
508
+ * @returns A page of connections.
509
+ */
243
510
  list(options?: {
244
511
  pageSize?: number;
245
512
  pageToken?: string;
246
513
  type?: string;
247
514
  }): Promise<Page<Connection>>;
248
515
  private listPage;
516
+ /**
517
+ * Find the first connection whose name matches (case-insensitive).
518
+ *
519
+ * Pages through {@link ConnectionsResource.list} until a match is found.
520
+ *
521
+ * @param options.name - Connection name to search for.
522
+ * @param options.type - Optional integration category filter.
523
+ * @param options.pageSize - Page size when scanning (default 25).
524
+ * @returns The matching connection, or `undefined` if none is found.
525
+ */
249
526
  find(options: {
250
527
  name: string;
251
528
  type?: string;
@@ -256,26 +533,72 @@ declare class ConnectionsResource {
256
533
  type JsonObjectInput = Record<string, unknown>;
257
534
  type ContentProjection = components['schemas']['ContentProjectionDto'];
258
535
 
536
+ /**
537
+ * Read access to Modus knowledge-base items.
538
+ */
259
539
  declare class ContextItemsResource {
260
540
  private readonly http;
261
541
  private readonly config;
542
+ /** @internal */
262
543
  constructor(http: HttpClient, config: ModusConfig);
544
+ /**
545
+ * List knowledge-base items.
546
+ *
547
+ * @param options.pageSize - Maximum items per page (default 25).
548
+ * @param options.pageToken - Opaque token from a previous page.
549
+ * @param options.contextType - Filter to a single context type.
550
+ * @returns A page of context items.
551
+ */
263
552
  list(options?: {
264
553
  pageSize?: number;
265
554
  pageToken?: string;
266
555
  contextType?: string;
267
556
  }): Promise<Page<ContextItem>>;
268
557
  private listPage;
558
+ /**
559
+ * Retrieve a knowledge-base item by uid.
560
+ *
561
+ * @param uid - Item uid.
562
+ * @returns The context item.
563
+ * @throws {NotFoundError} When no item matches the uid.
564
+ */
269
565
  get(uid: string): Promise<ContextItem>;
566
+ /**
567
+ * Look up a knowledge-base item by type and data path.
568
+ *
569
+ * @param options.contextType - Context type to match.
570
+ * @param options.dataPath - Hierarchical path segments that identify the item.
571
+ * @param options.contentProjection - Optional fields to include from item content.
572
+ * @returns The matching row, or `undefined` when no item is found (404).
573
+ */
270
574
  lookup(options: {
271
575
  contextType: string;
272
576
  dataPath: string[];
273
577
  contentProjection?: JsonObjectInput | ContentProjection;
274
578
  }): Promise<ContextItemLookupRow | undefined>;
579
+ /**
580
+ * List values stored under a content key on a context item.
581
+ *
582
+ * @param uid - Item uid.
583
+ * @param contextType - Context type of the item.
584
+ * @param contentKeyPath - Dot path to the value field inside item content.
585
+ * @param options.pageSize - Maximum items per page (default 25).
586
+ * @param options.pageToken - Opaque token from a previous page.
587
+ * @returns A page of value rows.
588
+ */
275
589
  listValues(uid: string, contextType: string, contentKeyPath: string, options?: {
276
590
  pageSize?: number;
277
591
  pageToken?: string;
278
592
  }): Promise<Page<ContextValueRow>>;
593
+ /**
594
+ * List values for a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.
595
+ *
596
+ * @param item - Context item (uses `item.uid` and `item.contextType`).
597
+ * @param contentKeyPath - Dot path to the value field inside item content.
598
+ * @param options.pageSize - Maximum items per page (default 25).
599
+ * @param options.pageToken - Opaque token from a previous page.
600
+ * @returns A page of value rows.
601
+ */
279
602
  listValuesFor(item: ContextItem, contentKeyPath: string, options?: {
280
603
  pageSize?: number;
281
604
  pageToken?: string;
@@ -283,23 +606,46 @@ declare class ContextItemsResource {
283
606
  private listValuesPage;
284
607
  }
285
608
 
286
- /** Read access to the Modus knowledge base. */
609
+ /**
610
+ * Read access to the Modus knowledge base.
611
+ *
612
+ * - {@link ContextItemsResource items} — list and look up indexed knowledge-base items.
613
+ * - {@link CustomContextItemsResource customItems} — create and manage custom context items.
614
+ *
615
+ * Call path: `client.context` after `new Modus(...)`.
616
+ */
287
617
  declare class ContextResource {
288
618
  readonly items: ContextItemsResource;
289
619
  readonly customItems: CustomContextItemsResource;
620
+ /** @internal */
290
621
  constructor(http: HttpClient, config: ModusConfig);
291
622
  }
292
623
 
624
+ /** List and retrieve Modus / scope conversations. */
293
625
  declare class ModusConversationsResource {
294
626
  private readonly http;
295
627
  private readonly config;
296
628
  constructor(http: HttpClient, config: ModusConfig);
629
+ /**
630
+ * List conversations.
631
+ *
632
+ * @param options.pageSize - Items per page (default 25).
633
+ * @param options.pageToken - Opaque token from a previous page.
634
+ * @param options.kind - `"modus"`, `"scopes"`, or `"all"`.
635
+ * @returns Page of conversation list items.
636
+ */
297
637
  list(options?: {
298
638
  pageSize?: number;
299
639
  pageToken?: string;
300
640
  kind?: ConversationKind;
301
641
  }): Promise<Page<ConversationListItem>>;
302
642
  private listPage;
643
+ /**
644
+ * Retrieve a conversation thread with full message history.
645
+ *
646
+ * @param threadId - Conversation thread id.
647
+ * @returns Conversation with messages.
648
+ */
303
649
  get(threadId: string): Promise<Conversation>;
304
650
  }
305
651
 
@@ -309,43 +655,134 @@ declare class ModusResource {
309
655
  private readonly config;
310
656
  readonly conversations: ModusConversationsResource;
311
657
  constructor(http: HttpClient, config: ModusConfig);
658
+ /**
659
+ * Return composed full-environment context for an intent, without running chat.
660
+ *
661
+ * @param message - User intent or question to compose context for.
662
+ * @param options.limit - Optional cap on structured fallback items.
663
+ * @returns Composed Modus context.
664
+ */
312
665
  getContext(message: string, options?: {
313
666
  limit?: number;
314
667
  }): Promise<ModusContextComposition>;
668
+ /**
669
+ * Send a message to Modus (org-wide assistant) and get the complete reply.
670
+ *
671
+ * @param message - Message to send.
672
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
673
+ * @param options.threadId - Continue an existing conversation.
674
+ * @returns Chat result with content and threadId.
675
+ *
676
+ * @example
677
+ * ```ts
678
+ * const result = await client.modus.chat('What tables describe revenue?', { model: 'claude-sonnet-5' })
679
+ * console.log(result.content, result.threadId)
680
+ * ```
681
+ */
315
682
  chat(message: string, options: {
316
683
  model: ChatModel;
317
684
  threadId?: string;
318
685
  }): Promise<ChatResult>;
686
+ /**
687
+ * Stream a Modus reply token by token.
688
+ *
689
+ * @param message - Message to send.
690
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
691
+ * @param options.threadId - Continue an existing conversation.
692
+ * @returns Chat stream.
693
+ */
319
694
  chatStream(message: string, options: {
320
695
  model: ChatModel;
321
696
  threadId?: string;
322
697
  }): ChatStream;
323
698
  }
324
699
 
325
- /** Read / invoke access to Modus scopes (`/api/v1/scopes`). */
700
+ /**
701
+ * Read / chat with scopes.
702
+ *
703
+ * Call path: `client.scopes` after `new Modus(...)`.
704
+ */
326
705
  declare class ScopesResource {
327
706
  private readonly http;
328
707
  private readonly config;
708
+ /** @internal */
329
709
  constructor(http: HttpClient, config: ModusConfig);
710
+ /**
711
+ * Return the conversations sub-resource scoped to `scopeId`.
712
+ *
713
+ * @param scopeId - Scope numeric id or slug.
714
+ * @returns Conversations resource for the scope.
715
+ */
330
716
  conversations(scopeId: number | string): ScopeConversationsResource;
717
+ /**
718
+ * List scopes in the organisation.
719
+ *
720
+ * @param options.pageSize - Items per page (default 25).
721
+ * @param options.pageToken - Opaque token from a previous page.
722
+ * @param options.search - Case-insensitive substring filter on the scope name.
723
+ * @param options.view - `"active"` (deployed) or `"draft"`.
724
+ * @param options.managerId - Only scopes supervised by this manager scope id.
725
+ * @returns Page of scopes.
726
+ */
331
727
  list(options?: {
332
728
  pageSize?: number;
333
729
  pageToken?: string;
334
730
  search?: string;
335
731
  view?: VariationView;
336
732
  managerId?: number;
337
- }): Promise<Page<Skill>>;
733
+ }): Promise<Page<Scope>>;
338
734
  private listPage;
735
+ /**
736
+ * Retrieve a scope by ID or slug.
737
+ *
738
+ * @param scopeId - Scope numeric id or slug.
739
+ * @param options.view - `"active"` (deployed) or `"draft"`.
740
+ * @throws {NotFoundError} When no scope matches the id or slug.
741
+ * @returns Scope.
742
+ */
339
743
  get(scopeId: number | string, options?: {
340
744
  view?: VariationView;
341
- }): Promise<Skill>;
745
+ }): Promise<Scope>;
746
+ /**
747
+ * Return composed context Modus would use for a scope query, without running chat.
748
+ *
749
+ * @param scopeId - Scope numeric id or slug.
750
+ * @param message - User intent or question to compose context for.
751
+ * @param options.limit - Optional cap on structured fallback items.
752
+ * @returns Composed scope context.
753
+ */
342
754
  getContext(scopeId: number | string, message: string, options?: {
343
755
  limit?: number;
344
756
  }): Promise<SkillContextComposition>;
757
+ /**
758
+ * Send a message to a scope and get the complete reply.
759
+ *
760
+ * @param scopeId - Scope numeric id or slug.
761
+ * @param message - Message to send.
762
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
763
+ * @param options.threadId - Continue an existing conversation.
764
+ * @returns Chat result with content and threadId.
765
+ *
766
+ * @example
767
+ * ```ts
768
+ * const result = await client.scopes.chat(scopeId, 'Hello', { model: 'claude-sonnet-5' })
769
+ * console.log(result.content, result.threadId)
770
+ * ```
771
+ */
345
772
  chat(scopeId: number | string, message: string, options: {
346
773
  model: ChatModel;
347
774
  threadId?: string;
348
775
  }): Promise<ChatResult>;
776
+ /**
777
+ * Stream a scope reply token by token.
778
+ *
779
+ * @param scopeId - Scope numeric id or slug.
780
+ * @param message - Message to send.
781
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
782
+ * @param options.threadId - Continue an existing conversation.
783
+ * @param options.version - `"published"` or `"draft"`.
784
+ * @returns Chat stream.
785
+ */
349
786
  chatStream(scopeId: number | string, message: string, options: {
350
787
  model: ChatModel;
351
788
  threadId?: string;
@@ -353,21 +790,46 @@ declare class ScopesResource {
353
790
  }): ChatStream;
354
791
  }
355
792
 
793
+ /**
794
+ * List suggested questions and record suggestion events.
795
+ */
356
796
  declare class SuggestionsResource {
357
797
  private readonly http;
358
798
  private readonly config;
799
+ /** @internal */
359
800
  constructor(http: HttpClient, config: ModusConfig);
801
+ /**
802
+ * List approved suggested questions.
803
+ *
804
+ * @param options.pageSize - Maximum items per page (default 5, max 12).
805
+ * @param options.pageToken - Opaque token from a previous page.
806
+ * @param options.scopeId - Filter to a single scope.
807
+ * @param options.scopeIds - Filter to one or more scopes.
808
+ * @returns A page of suggested questions.
809
+ */
360
810
  list(options?: {
361
811
  pageSize?: number;
362
812
  pageToken?: string;
363
- skillId?: number;
364
- skillIds?: readonly number[];
813
+ scopeId?: number;
814
+ scopeIds?: readonly number[];
365
815
  }): Promise<Page<SuggestionQuestion>>;
366
816
  private listPage;
817
+ /**
818
+ * Record that a suggested question was shown, clicked, dismissed, or submitted.
819
+ *
820
+ * @param id - Suggestion id.
821
+ * @param event - Event details, including `eventType` (`shown`, `clicked`, `dismissed`, or `submitted`).
822
+ */
367
823
  recordEvent(id: string, event: RecordSuggestionEventRequest): Promise<void>;
368
824
  }
369
825
 
370
- /** Read / invoke client for Modus scopes, workflows, connections, and more. */
826
+ /**
827
+ * Read / invoke client for Modus scopes, workflows, connections, and more.
828
+ *
829
+ * Call path: `const client = new Modus(...)` then `client.scopes`, `client.context`, …
830
+ *
831
+ * @param options - Client configuration (`apiKey`, `baseUrl`, `timeoutMs`, `maxRetries`).
832
+ */
371
833
  declare class Modus extends ModusClientBase {
372
834
  readonly scopes: ScopesResource;
373
835
  readonly modus: ModusResource;
@@ -378,4 +840,4 @@ declare class Modus extends ModusClientBase {
378
840
  constructor(options?: ModusOptions);
379
841
  }
380
842
 
381
- export { APIConnectionError, Agent, type AgentRun, type AgentRunCreateRequest, type AgentRunListItem, type AgentRunStream, AgentType, type ApprovalScope, type AssistantContentResetEvent, AuthenticationError, type CancelRunRequest, type CancelledEvent, type ChatModel, type ChatRequest, type ChatResult, ChatStream, type ComposeSkillContextRequest, ConflictError, type Connection, ContextItem, ContextItemLookupRow, type ContextValueRow, Conversation, ConversationKind, ConversationListItem, type CreateAgentRunRequest, type DoneEvent, type EditQueuedRunRequest, type ErrorEvent, InternalServerError, type InterruptRunRequest, Modus, type ModusContextComposition, type ModusContextRequest, ModusError, ModusOptions, type ModusRunCreateRequest, NotFoundError, Page, PermissionDeniedError, RateLimitError, type RecordSuggestionEventRequest, type ResumeRunRequest, RunCancelledError, type RunEvent, type RunStatus, type RunTimeframe, Skill, type SkillContextComposition, type SkillRunCreateRequest, StreamTimeoutError, type StreamTimeoutEvent, type SuggestionEventSource, type SuggestionEventType, type SuggestionQuestion, type TokenEvent, UnprocessableError, ValidationError, VariationView, type WorkflowActionRequest, components };
843
+ export { APIConnectionError, type AgentRun, type AgentRunCreateRequest, type AgentRunListItem, type AgentRunStream, type ApprovalScope, type AssistantContentResetEvent, AuthenticationError, type CancelRunRequest, type CancelledEvent, type ChatModel, type ChatRequest, type ChatResult, ChatStream, type ComposeSkillContextRequest, ConflictError, type Connection, ContextItem, ContextItemLookupRow, type ContextValueRow, Conversation, ConversationKind, ConversationListItem, type CreateAgentRunRequest, type DoneEvent, type EditQueuedRunRequest, type ErrorEvent, InternalServerError, type InterruptRunRequest, Modus, type ModusContextComposition, type ModusContextRequest, ModusError, ModusOptions, type ModusRunCreateRequest, NotFoundError, Page, PermissionDeniedError, RateLimitError, type RecordSuggestionEventRequest, type ResumeRunRequest, RunCancelledError, type RunEvent, type RunStatus, type RunTimeframe, Scope, type SkillContextComposition, type SkillRunCreateRequest, StreamTimeoutError, type StreamTimeoutEvent, type SuggestionEventSource, type SuggestionEventType, type SuggestionQuestion, type TokenEvent, UnprocessableError, ValidationError, VariationView, Workflow, type WorkflowActionRequest, WorkflowType, components };