@getmodus/sdk 0.9.0 → 0.10.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,5 +1,5 @@
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 Conversation, f as ConversationKind, g as ConversationListItem, S as Scope, h as ScopeConversationsResource, i as ModusClientBase, j as ModusOptions } from './conversations-D7ffhHIh.cjs';
2
- export { A as Agent, k as AgentType, l as ContextItemAncestor, m as ContextItemDeletion, n as ContextItemMove, o as ContextType, p as Message, O as OPERATIONS, q as OperationId, r as OperationSpec, s as ScopeStatus, t as ScopeVariation, u as Skill, v as SkillStatus, w as SkillVariation, x as conversationScopeId, y as conversationSkillId, z as operations, B as paths } from './conversations-D7ffhHIh.cjs';
1
+ import { H as HttpClient, c as components, M as ModusConfig, P as Page, V as VariationView, S as Scope, a as ScopeConversationsResource, C as Conversation, b as ConversationKind, d as ConversationListItem, W as WorkflowType, e as Workflow, f as ContextItem, g as ContextItemLookupRow, h as CustomContextItemsResource, i as ModusClientBase, j as ModusOptions } from './_client-base-H5rt5EGy.cjs';
2
+ export { A as Agent, k as AgentType, l as ContextItemAccessUpdate, m as ContextItemAncestor, n as ContextItemDeletion, o as ContextItemMove, p as ContextType, q as CreateCustomContextItemInput, r as CreatedCustomContextItem, s as CustomAttributeInput, t as CustomContextItemDeletion, u as CustomContextItemKind, v as CustomContextItemRelationInput, w as Message, O as OPERATIONS, x as OperationId, y as OperationSpec, z as ScopeStatus, B as ScopeVariation, D as Skill, E as SkillStatus, F as SkillVariation, G as SupervisionView, U as UpdateContextItemAccessInput, I as UpdateCustomContextItemInput, J as conversationScopeId, K as conversationSkillId, L as operations, N as paths } from './_client-base-H5rt5EGy.cjs';
3
3
 
4
4
  /**
5
5
  * Base class for all Modus SDK errors.
@@ -9,16 +9,36 @@ export { A as Agent, k as AgentType, l as ContextItemAncestor, m as ContextItemD
9
9
  */
10
10
  declare class ModusError extends Error {
11
11
  readonly statusCode?: number;
12
+ /** The `requestId` of the error envelope (or the `x-request-id` header); quote it to support. */
12
13
  readonly requestId?: string;
14
+ /**
15
+ * The W3C trace id of the request that failed (from the `traceparent` the SDK sent). Quote
16
+ * it with `requestId`: it also names a request that never reached Modus, and every retry of it.
17
+ */
18
+ readonly traceId?: string;
13
19
  readonly responseHeaders?: Record<string, string>;
14
20
  readonly body?: string;
21
+ /** Machine-readable error code from the envelope, e.g. `NOT_FOUND`, `VALIDATION`. */
15
22
  readonly code?: string;
23
+ /** Structured detail from the envelope, e.g. `{ missing: ['scopes:write'] }` on a 403. */
24
+ readonly info?: Record<string, unknown>;
25
+ /**
26
+ * Whether the SDK's retry rule allows re-sending this call. True for a 429 whose
27
+ * `Retry-After` is absent or at most 60 s, and for a connection that never opened. For
28
+ * 408, 500, 502, 503, 504, a dropped connection or a timeout: true on GET, PUT, PATCH and
29
+ * DELETE and on POSTs that only read or set a state, false on any other POST, which may
30
+ * already have run. The SDK already retried a retryable error up to `maxRetries` times.
31
+ */
32
+ readonly retryable: boolean;
16
33
  constructor(message: string, options?: {
17
34
  statusCode?: number;
18
35
  requestId?: string;
36
+ traceId?: string;
19
37
  responseHeaders?: Record<string, string>;
20
38
  body?: string;
21
39
  code?: string;
40
+ info?: Record<string, unknown>;
41
+ retryable?: boolean;
22
42
  });
23
43
  }
24
44
  /**
@@ -26,7 +46,18 @@ declare class ModusError extends Error {
26
46
  * automatic retries are exhausted.
27
47
  */
28
48
  declare class APIConnectionError extends ModusError {
29
- constructor(message: string);
49
+ constructor(message: string, options?: {
50
+ retryable?: boolean;
51
+ traceId?: string;
52
+ });
53
+ }
54
+ /**
55
+ * The request was malformed (HTTP 400): a parameter or body field failed schema
56
+ * validation, an unknown property was sent, or an id was not a number. `message`
57
+ * names the field.
58
+ */
59
+ declare class BadRequestError extends ModusError {
60
+ constructor(message: string, options?: ConstructorParameters<typeof ModusError>[1]);
30
61
  }
31
62
  /**
32
63
  * The API key is missing, invalid, or expired (HTTP 401).
@@ -58,9 +89,12 @@ declare class ConflictError extends ModusError {
58
89
  constructor(message: string, options?: ConstructorParameters<typeof ModusError>[1]);
59
90
  }
60
91
  /**
61
- * Request validation failed (HTTP 422).
92
+ * The request was well-formed but failed a business rule (HTTP 422, `code: VALIDATION`),
93
+ * for example a toolset rule or a disallowed file type. Schema failures are
94
+ * {@link BadRequestError} (400) instead.
62
95
  *
63
- * Inspect `errors` when present for field-level details.
96
+ * `info` carries the rule detail when the server sends one (e.g. `info.violations`);
97
+ * `errors` is the whole parsed error envelope.
64
98
  */
65
99
  declare class UnprocessableError extends ModusError {
66
100
  readonly errors?: unknown;
@@ -71,7 +105,9 @@ declare class UnprocessableError extends ModusError {
71
105
  /**
72
106
  * Too many requests (HTTP 429).
73
107
  *
74
- * When present, `retryAfter` is the suggested wait in seconds.
108
+ * When present, `retryAfter` is the server's requested wait in whole seconds (from
109
+ * `retry-after-ms`, or `Retry-After` as seconds or an HTTP date). The SDK waits it out
110
+ * and retries when it is 60 s or less; a longer wait is thrown at once.
75
111
  */
76
112
  declare class RateLimitError extends ModusError {
77
113
  readonly retryAfter?: number;
@@ -99,20 +135,94 @@ declare class ValidationError extends ModusError {
99
135
  constructor(message: string);
100
136
  }
101
137
 
138
+ declare const CHAT_MODELS: readonly ["claude-sonnet-5", "claude-sonnet-5.5", "claude-sonnet-4.6", "claude-opus-4.8", "claude-opus-5.5", "claude-haiku-5.5", "gpt-5.2", "gpt-5.5", "gpt-5-mini", "gpt-5.6-luna", "gpt-6-luna", "gpt-oss-120b", "gpt-oss-20b", "qwen3-235b-a22b-2507", "qwen3-coder", "qwen3-32b", "deepseek-chat-v3.1", "deepseek-v4-pro", "deepseek-v4-flash-latest", "deepseek-v4.1-flash-1017", "minimax-m2.7", "llama-4-maverick", "llama-4-scout", "llama-3.3-70b-instruct", "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-3.8-flash", "grok-4.3-fast", "grok-4.3", "grok-4.7", "kimi-k3"];
139
+
140
+ /** Fields every run event carries. */
141
+ interface RunEventBase {
142
+ /**
143
+ * The SSE event id. Pass it as `lastEventId` to `runs.stream(runId, { lastEventId })`
144
+ * to resume after this event. Absent when the stream sent none.
145
+ */
146
+ readonly id?: string;
147
+ }
148
+ interface TokenEvent extends RunEventBase {
149
+ readonly type: 'token';
150
+ content: string;
151
+ /** Set when a sub-agent produced the token; absent for the assistant's own reply. */
152
+ subAgent?: string;
153
+ }
154
+ interface DoneEvent extends RunEventBase {
155
+ readonly type: 'done';
156
+ runId: string;
157
+ threadId: string;
158
+ /** The run's final answer. */
159
+ content?: string;
160
+ }
161
+ /**
162
+ * The run stopped for a human decision: a write tool needs approval (`toolId`,
163
+ * `toolName`, `title`, `description`, `args`) or a workflow approval node is
164
+ * waiting (`nodeId`, `prompt`, `options`).
165
+ */
166
+ interface ApprovalRequiredEvent extends RunEventBase {
167
+ readonly type: 'approval_required';
168
+ toolId?: string;
169
+ toolName?: string;
170
+ title?: string;
171
+ description?: string;
172
+ args?: Record<string, unknown>;
173
+ nodeId?: string;
174
+ prompt?: string;
175
+ options?: ReadonlyArray<{
176
+ id: string;
177
+ label: string;
178
+ }>;
179
+ }
180
+ interface ErrorEvent extends RunEventBase {
181
+ readonly type: 'error';
182
+ message: string;
183
+ /** The id to quote to support for this failure. */
184
+ requestId?: string;
185
+ }
186
+ interface CancelledEvent extends RunEventBase {
187
+ readonly type: 'cancelled';
188
+ }
189
+ interface StreamTimeoutEvent extends RunEventBase {
190
+ readonly type: 'stream_timeout';
191
+ }
192
+ interface AssistantContentResetEvent extends RunEventBase {
193
+ readonly type: 'assistant_content_reset';
194
+ content: string;
195
+ visibleContent?: string;
196
+ attempt: number;
197
+ reason: 'provider_stream_failed';
198
+ /** Set when the reset belongs to a sub-agent's timeline; absent for the assistant's own reply. */
199
+ subAgent?: Record<string, unknown>;
200
+ }
201
+ type ActiveConversationRunStatus = 'queued' | 'pending' | 'running';
202
+ interface ActiveConversationRun {
203
+ readonly runId: string;
204
+ readonly sessionId: string;
205
+ readonly status: ActiveConversationRunStatus;
206
+ readonly message?: string;
207
+ readonly createdAt: string;
208
+ readonly updatedAt: string;
209
+ }
210
+ type RunEvent = TokenEvent | DoneEvent | ErrorEvent | CancelledEvent | StreamTimeoutEvent | AssistantContentResetEvent | ApprovalRequiredEvent;
211
+
102
212
  /**
103
213
  * Canonical model id accepted by Modus chat APIs.
104
214
  *
105
- * Pass as `model` to `client.modus.chat(...)`, `client.scopes.chat(...)`,
106
- * and the matching stream methods. An unsupported value fails client-side
215
+ * Pass as `model` to `client.modus.chat(...)`, `client.scopes.chat(...)`
216
+ * or `client.workflows.chat(...)`. An unsupported value fails client-side
107
217
  * validation before the request is sent.
108
218
  *
109
219
  * Allowed values:
110
- * - `claude-sonnet-5`, `claude-sonnet-5.5`, `claude-sonnet-4.6`, `claude-opus-4.8`, `claude-opus-5.5`
220
+ * - `claude-sonnet-5`, `claude-sonnet-5.5`, `claude-sonnet-4.6`, `claude-opus-4.8`, `claude-opus-5.5`, `claude-haiku-5.5`
111
221
  * - `gpt-5.2`, `gpt-5.5`, `gpt-5-mini`, `gpt-5.6-luna`, `gpt-6-luna`, `gpt-oss-120b`, `gpt-oss-20b`
112
222
  * - `qwen3-235b-a22b-2507`, `qwen3-coder`, `qwen3-32b`
113
- * - `deepseek-chat-v3.1`, `deepseek-v4-pro`, `deepseek-v4-flash-latest`, `minimax-m2.7`
223
+ * - `deepseek-chat-v3.1`, `deepseek-v4-pro`, `deepseek-v4-flash-latest`, `deepseek-v4.1-flash-1017`, `minimax-m2.7`
114
224
  * - `llama-4-maverick`, `llama-4-scout`, `llama-3.3-70b-instruct`
115
- * - `gemini-3.1-pro-preview`, `gemini-3-flash-preview`
225
+ * - `gemini-3.1-pro-preview`, `gemini-3-flash-preview`, `gemini-3.8-flash`
116
226
  * - `grok-4.3-fast`, `grok-4.3`, `grok-4.7`, `kimi-k3`
117
227
  *
118
228
  * @example
@@ -122,19 +232,7 @@ declare class ValidationError extends ModusError {
122
232
  * })
123
233
  * ```
124
234
  */
125
- type ChatModel = components['schemas']['SkillChatRequestDto']['model'];
126
- /**
127
- * Chat request body (`message` + required `model`).
128
- *
129
- * Prefer `client.modus.chat(...)` / `client.scopes.chat(...)` — they take these
130
- * fields as method arguments so you rarely construct this type yourself.
131
- */
132
- interface ChatRequest {
133
- /** User message sent to the skill / Modus. */
134
- message: string;
135
- /** Canonical model id for this run (required). See {@link ChatModel}. */
136
- model: ChatModel;
137
- }
235
+ type ChatModel = (typeof CHAT_MODELS)[number];
138
236
  /**
139
237
  * Chat response: final assistant text plus `threadId` for follow-ups.
140
238
  */
@@ -145,99 +243,134 @@ interface ChatResult {
145
243
  threadId: string;
146
244
  /** Opaque run id for logging / correlation. */
147
245
  runId: string;
246
+ /** Set when the run stopped for a decision; continue with `ChatSession.resume`. */
247
+ approval?: ApprovalRequiredEvent;
148
248
  }
149
249
 
150
- interface TokenEvent {
151
- readonly type: 'token';
152
- content: string;
153
- }
154
- interface DoneEvent {
155
- readonly type: 'done';
156
- runId: string;
157
- threadId: string;
158
- }
159
- interface ErrorEvent {
160
- readonly type: 'error';
161
- message: string;
162
- }
163
- interface CancelledEvent {
164
- readonly type: 'cancelled';
165
- }
166
- interface StreamTimeoutEvent {
167
- readonly type: 'stream_timeout';
168
- }
169
- interface AssistantContentResetEvent {
170
- readonly type: 'assistant_content_reset';
171
- content: string;
172
- visibleContent?: string;
173
- attempt: number;
174
- reason: 'provider_stream_failed';
250
+ /** Options shared by every `chat()` method. */
251
+ interface ChatOptions {
252
+ /** Canonical model id for this run (required). See {@link ChatModel}. */
253
+ model: ChatModel;
254
+ /** Continue this conversation; omit to start a new one. */
255
+ threadId?: string;
175
256
  }
176
- type ActiveConversationRunStatus = 'queued' | 'pending' | 'running';
177
- interface ActiveConversationRun {
178
- readonly runId: string;
257
+ interface ChatRequest {
258
+ readonly path: string;
259
+ readonly body: Record<string, unknown>;
179
260
  readonly sessionId: string;
180
- readonly status: ActiveConversationRunStatus;
181
- readonly message?: string;
182
- readonly createdAt: string;
183
- readonly updatedAt: string;
261
+ readonly baseUrl: string;
184
262
  }
185
- type RunEvent = TokenEvent | DoneEvent | ErrorEvent | CancelledEvent | StreamTimeoutEvent | AssistantContentResetEvent;
186
-
187
263
  /**
188
- * Streaming chat session. Iterate {@link ChatStream.textStream} or
189
- * {@link ChatStream.eventStream}, then call {@link ChatStream.getFinalResult}.
264
+ * One chat turn, streamed live from the agent host.
265
+ *
266
+ * Iterate {@link ChatSession.textStream} for tokens as they arrive, or
267
+ * `await` the session for the final {@link ChatResult}. The request is sent
268
+ * once: iterating again, or awaiting after iterating, replays what arrived.
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * const chat = client.scopes.chat(scopeId, 'What is our ARR trend?', { model: 'claude-sonnet-5.5' })
273
+ * for await (const token of chat.textStream()) process.stdout.write(token)
274
+ * const { threadId } = await chat
275
+ * ```
190
276
  */
191
- declare class ChatStream {
277
+ declare class ChatSession implements PromiseLike<ChatResult> {
192
278
  private readonly http;
193
- private readonly path;
194
- private readonly body;
195
- private readonly baseUrl?;
196
- private final?;
197
- private readonly textParts;
198
- constructor(http: HttpClient, path: string, body: Record<string, unknown>, baseUrl?: string | undefined);
279
+ private readonly request;
280
+ private readonly received;
281
+ private live;
282
+ private finished;
283
+ private failure;
284
+ private final;
285
+ private approval;
286
+ /**
287
+ * @internal A session built with `failure` never sends; every read rejects
288
+ * with it, as the promise `chat()` used to return did.
289
+ */
290
+ constructor(http: HttpClient, request: ChatRequest | undefined, failure?: unknown);
199
291
  /**
200
- * Async iterable of assistant text token chunks as they arrive.
292
+ * The assistant's reply as text chunks, as they arrive. Sub-agent output is
293
+ * left out.
201
294
  *
202
- * @returns An async generator yielding partial text strings.
203
- * @throws {ModusError} When the stream emits an error event.
295
+ * @throws {ModusError} When the run reports an error.
204
296
  * @throws {RunCancelledError} When the run is cancelled.
205
- * @throws {StreamTimeoutError} When the stream times out.
297
+ * @throws {StreamTimeoutError} When the run times out.
206
298
  */
207
299
  textStream(): AsyncGenerator<string>;
208
300
  /**
209
- * Async iterable of structured run events (tokens, tool calls, done, and so on).
301
+ * Every run event (tokens, approvals, `done`, …) as it arrives.
210
302
  *
211
- * @returns An async generator yielding {@link RunEvent} objects.
212
- * @throws {ModusError} When the stream emits an error event.
303
+ * @throws {ModusError} When the run reports an error.
213
304
  * @throws {RunCancelledError} When the run is cancelled.
214
- * @throws {StreamTimeoutError} When the stream times out.
305
+ * @throws {StreamTimeoutError} When the run times out.
215
306
  */
216
307
  eventStream(): AsyncGenerator<RunEvent>;
217
- private events;
218
308
  /**
219
- * Final chat result after the stream completes.
309
+ * Waits for the run to finish and returns its final answer. `approval` is
310
+ * set when the run stopped for a decision; continue with {@link resume}.
311
+ *
312
+ * @throws {ModusError} When the run reports an error or ends without finishing.
313
+ */
314
+ result(): Promise<ChatResult>;
315
+ /** Resolve with the final {@link ChatResult}, so the session can be awaited. */
316
+ then<TResult1 = ChatResult, TResult2 = never>(onfulfilled?: ((value: ChatResult) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
317
+ /** Handle a failed run, as on the promise `chat()` used to return. */
318
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<ChatResult | TResult>;
319
+ /** Run `onfinally` once the run settles, as on the promise `chat()` used to return. */
320
+ finally(onfinally?: (() => void) | null): Promise<ChatResult>;
321
+ /**
322
+ * Approve or deny the action this run stopped for, continuing the same
323
+ * conversation.
220
324
  *
221
- * Call only after fully consuming {@link ChatStream.textStream} or
222
- * {@link ChatStream.eventStream}.
325
+ * @param input.decision - `approve` or `deny`.
326
+ * @returns A new session for the continued run.
327
+ * @throws {ModusError} When called before the run has finished.
223
328
  *
224
- * @returns The assembled assistant reply, thread id, and run id.
225
- * @throws {ModusError} When called before the stream finishes with a done event.
329
+ * @example
330
+ * ```ts
331
+ * const chat = client.modus.chat('Fix the typo in accounts', { model: 'claude-sonnet-5.5' })
332
+ * const first = await chat
333
+ * if (first.approval) {
334
+ * const done = await chat.resume({ decision: 'approve' })
335
+ * }
336
+ * ```
226
337
  */
227
- getFinalResult(): ChatResult;
338
+ resume(input: {
339
+ decision: 'approve' | 'deny';
340
+ }): ChatSession;
341
+ /**
342
+ * Stop reading the run and release its connection. Call it when you stop
343
+ * iterating before the run ends; a session that reached `done` has already
344
+ * let go. The run itself keeps going on the server.
345
+ */
346
+ close(): Promise<void>;
347
+ private replay;
348
+ private open;
228
349
  }
229
350
 
230
351
  type AgentRunListItem = components['schemas']['AutomationRunListItemDto'];
231
352
  type AgentRun = components['schemas']['GetAutomationRunResponseDto'];
232
- type AgentRunCreateRequest = components['schemas']['AgentRunDto'];
233
- type SkillRunCreateRequest = components['schemas']['SkillRunDto'];
234
- type ModusRunCreateRequest = components['schemas']['ModusRunDto'];
353
+ /** A new run's body: `sessionId` is optional, because the SDK starts a new conversation when it is omitted. */
354
+ type NewRunBody<T extends {
355
+ sessionId: string;
356
+ }> = Omit<T, 'sessionId'> & {
357
+ sessionId?: string;
358
+ };
359
+ type AgentRunCreateRequest = NewRunBody<components['schemas']['AgentRunDto']>;
360
+ type SkillRunCreateRequest = NewRunBody<components['schemas']['SkillRunDto']>;
361
+ type ModusRunCreateRequest = NewRunBody<components['schemas']['ModusRunDto']>;
235
362
  type ResumeRunRequest = components['schemas']['ResumeRunDto'];
236
363
  type CreateAgentRunRequest = AgentRunCreateRequest;
237
364
  type CancelRunRequest = components['schemas']['CancelRunDto'];
238
365
  type InterruptRunRequest = components['schemas']['InterruptRunDto'];
239
366
  type EditQueuedRunRequest = components['schemas']['EditQueuedRunDto'];
367
+ /** The turn `runs.interrupt` / `runs.editQueued` send as `nextRun`. */
368
+ type FollowUpRunRequest = components['schemas']['FollowUpRunDto'];
369
+ /** The run `runs.interrupt` / `runs.editQueued` admitted. */
370
+ type RunAdmission = components['schemas']['RunAdmissionResponseDto'];
240
371
  type WorkflowActionRequest = components['schemas']['WorkflowActionDto'];
372
+ /** One `runs.events()` poll: the buffered events after the cursor, the next cursor and the run status. */
373
+ type RunEventsPollResponse = components['schemas']['RunEventsPollResponseDto'];
241
374
  type RunStatus = 'running' | 'awaiting_human' | 'completed' | 'error' | 'cancelled' | 'all_executions' | (string & {});
242
375
  type RunTimeframe = 'last_hour' | 'last_day' | 'last_week' | (string & {});
243
376
  type ApprovalScope = 'mine' | 'all' | (string & {});
@@ -271,7 +404,7 @@ declare class WorkflowRunsResource {
271
404
  /**
272
405
  * List runs for a workflow.
273
406
  *
274
- * @param workflowId - Workflow id or slug.
407
+ * @param workflowId - Numeric workflow id.
275
408
  * @param options.pageSize - Maximum items per page (default 25, max 100).
276
409
  * @param options.pageToken - Opaque token from a previous page.
277
410
  * @param options.status - Filter by run status.
@@ -301,7 +434,7 @@ declare class WorkflowRunsResource {
301
434
  /**
302
435
  * Retrieve a workflow run by id.
303
436
  *
304
- * @param workflowId - Workflow id or slug the run belongs to.
437
+ * @param workflowId - Numeric workflow id the run belongs to.
305
438
  * @param runId - Run id (the list row's `workflowId` field, not the composite `id`).
306
439
  * @param options.temporalRunId - Optional internal execution id when disambiguating retries.
307
440
  * @returns Run details including status and output.
@@ -319,7 +452,7 @@ declare class WorkflowRunsResource {
319
452
  /**
320
453
  * Start a workflow run and stream run events.
321
454
  *
322
- * @param workflowId - Workflow id or slug to run.
455
+ * @param workflowId - Numeric workflow id to run.
323
456
  * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).
324
457
  * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
325
458
  * @returns A stream of run events (tokens, completion, errors, and related signals).
@@ -385,18 +518,21 @@ declare class WorkflowRunsResource {
385
518
  idempotencyKey?: string;
386
519
  }): AgentRunStream;
387
520
  /**
388
- * Resume an interrupted run and stream run events.
521
+ * Resume a run paused at an approval or connect interrupt, and stream the continuation's events.
389
522
  *
390
- * @param runId - Run id to resume.
391
- * @param body - Resume body (`message`, `sessionId`, and `decision`: `approve` / `deny` / `connected` / `cancelled`).
523
+ * The decision is the whole turn: send no `message` (a non-empty one is rejected).
524
+ *
525
+ * @param runId - Id of the interrupted run.
526
+ * @param body - `sessionId` (the run's conversation id, required) and `decision`
527
+ * (`approve` / `deny` / `connected` / `cancelled`); optional `approvalTarget`.
392
528
  * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
393
529
  * @returns A stream of run events.
530
+ * @throws {ValidationError} When `sessionId` is blank, before any request is sent.
394
531
  *
395
532
  * @example
396
533
  * ```ts
397
534
  * const stream = client.workflows.runs.resume(runId, {
398
535
  * decision: 'approve',
399
- * message: 'Looks good — continue.',
400
536
  * sessionId,
401
537
  * })
402
538
  * for await (const event of stream) {
@@ -419,24 +555,60 @@ declare class WorkflowRunsResource {
419
555
  */
420
556
  cancel(runId: string): Promise<void>;
421
557
  /**
422
- * Fetch stored run events for a run.
558
+ * Poll a run's buffered events once (the JSON transport, not SSE).
423
559
  *
424
560
  * @param runId - Run id.
425
- * @returns Run event history for replay or inspection.
561
+ * @returns The poll response: `events` (each with its stream `id` and `type`), `cursor`,
562
+ * `status` and `done`.
426
563
  */
427
- events(runId: string): Promise<unknown>;
564
+ events(runId: string): Promise<RunEventsPollResponse>;
428
565
  /**
429
- * Request a graceful stop for a running execution.
566
+ * Supersede a run's current turn with a follow-up turn.
567
+ *
568
+ * The run is cancelled and `nextRun` starts as a new run on the same conversation.
569
+ * On a run that has already finished nothing is cancelled, and `nextRun` simply
570
+ * starts a follow-up turn. `nextRun.runId` is pinned (a new uuid when you do not
571
+ * set one), so a retried request returns the same run instead of starting another.
430
572
  *
431
573
  * @param runId - Run id to interrupt.
574
+ * @param nextRun - The follow-up turn: `message` and `sessionId` (the run's conversation id).
575
+ * @param options.lastSeenEventId - Id of the last event you rendered, so the cancelled
576
+ * turn's saved output stops there.
577
+ * @returns The new run (`runId`, `status`); follow it with {@link stream}.
578
+ * @throws {ValidationError} When `nextRun.sessionId` is blank, before any request is sent.
579
+ *
580
+ * @example
581
+ * ```ts
582
+ * const { runId: nextRunId } = await client.workflows.runs.interrupt(runId, {
583
+ * message: 'Only count EMEA.',
584
+ * sessionId,
585
+ * })
586
+ * for await (const event of client.workflows.runs.stream(nextRunId)) {
587
+ * if (event.type === 'token') process.stdout.write(event.content)
588
+ * }
589
+ * ```
432
590
  */
433
- interrupt(runId: string): Promise<void>;
591
+ interrupt(runId: string, nextRun: FollowUpRunRequest, options?: {
592
+ lastSeenEventId?: string;
593
+ }): Promise<RunAdmission>;
434
594
  /**
435
- * Move a queued run back into an editable state before it starts.
595
+ * Replace the turn of a run that is still queued (not yet started).
436
596
  *
437
597
  * @param runId - Queued run id.
598
+ * @param nextRun - The replacement turn: `message` and `sessionId` (the run's conversation id).
599
+ * @returns The edited run (`runId`, `status`).
600
+ * @throws {ValidationError} When `nextRun.sessionId` is blank, before any request is sent.
601
+ * @throws {ConflictError} When the run has already started.
602
+ *
603
+ * @example
604
+ * ```ts
605
+ * await client.workflows.runs.editQueued(queuedRunId, {
606
+ * message: 'Summarize last week instead.',
607
+ * sessionId,
608
+ * })
609
+ * ```
438
610
  */
439
- editQueued(runId: string): Promise<void>;
611
+ editQueued(runId: string, nextRun: FollowUpRunRequest): Promise<RunAdmission>;
440
612
  /**
441
613
  * List active conversation runs across the organization.
442
614
  *
@@ -454,21 +626,23 @@ declare class WorkflowRunsResource {
454
626
  *
455
627
  * @param sessionIds - Up to 100 session ids.
456
628
  * @returns Active runs matching any of the given sessions.
457
- * @throws {Error} When more than 100 session ids are provided.
629
+ * @throws {ValidationError} When more than 100 session ids are provided.
458
630
  */
459
631
  activeBySession(sessionIds: readonly string[]): Promise<ActiveConversationRun[]>;
460
632
  /**
461
- * Reconnect to an in-progress run and stream run events.
633
+ * Reconnect to a run and stream its events.
462
634
  *
463
635
  * @param runId - Run id to follow.
464
- * @param options.lastEventId - Resume after this event id when catching up.
465
- * @returns A stream of run events from the current execution point.
636
+ * @param options.lastEventId - The `id` of the last event you handled; the stream resumes
637
+ * after it. Omit to replay the run from its first event.
638
+ * @returns A stream of run events.
466
639
  *
467
640
  * @example
468
641
  * ```ts
469
- * const stream = client.workflows.runs.stream(runId, { lastEventId: checkpoint })
470
- * for await (const event of stream) {
642
+ * let lastEventId: string | undefined
643
+ * for await (const event of client.workflows.runs.stream(runId, { lastEventId })) {
471
644
  * if (event.type === 'token') process.stdout.write(event.content)
645
+ * lastEventId = event.id // after handling it: reconnect with it if the connection drops
472
646
  * }
473
647
  * ```
474
648
  */
@@ -482,8 +656,13 @@ declare class WorkflowRunsResource {
482
656
  type Connection = components['schemas']['ConnectionDto'];
483
657
  type ConnectionSelection = components['schemas']['ConnectionSelectionDto'];
484
658
 
485
- /** One value entry from context item listValues (shape varies by context type). */
486
- type ContextValueRow = Record<string, unknown>;
659
+ /** One element of a context item's array field, from `listValues`. */
660
+ type ContextValueRow = {
661
+ /** Position of the element in the array (0-based). */
662
+ readonly index: number;
663
+ /** The element itself, as JSON of any type. */
664
+ readonly value: unknown;
665
+ };
487
666
 
488
667
  type SkillContextComposition = components['schemas']['ComposeSkillContextResponseDto'];
489
668
  type ModusContextComposition = components['schemas']['ModusContextResponseDto'];
@@ -510,35 +689,37 @@ interface UploadIngestedDataOptions {
510
689
  /** Location and identity of a newly stored ingested-data envelope. */
511
690
  type IngestedDataUploadResult = components['schemas']['CreatedIngestedDataResponseDto'];
512
691
 
513
- /** Generated base for the consumption `workflows` resource. */
514
- declare class WorkflowsResourceBase {
692
+ type JsonObjectInput = Record<string, unknown>;
693
+ type ContentProjection = components['schemas']['ContentProjectionDto'];
694
+
695
+ /** Generated base for the consumption `scopes` resource. */
696
+ declare class ScopesResourceBase {
515
697
  protected readonly http: HttpClient;
516
698
  protected readonly config: ModusConfig;
517
699
  /** @internal */
518
700
  constructor(http: HttpClient, config: ModusConfig);
519
701
  /**
520
- * List workflows.
702
+ * List scopes.
521
703
  *
522
- * Returns a paginated page of workflows the caller can at least `use`. Workflows the caller
523
- * cannot see are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
704
+ * Returns a paginated page of scopes the caller can at least `use`. Scopes the caller cannot see
705
+ * are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
524
706
  *
525
- * **Requires:** `workflows:read`
707
+ * **Requires:** `scopes:read`
526
708
  *
527
709
  * @param options.pageSize - Items per page. Defaults to 25.
528
710
  * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
529
711
  * for the first page.
530
- * @param options.search - Case-insensitive substring filter on workflow name.
531
- * @param options.type - Filter by workflow type.
532
- * @param options.view - Variation view. `active` reads deployed; `draft` reads the latest builder
533
- * snapshot.
534
- * @param options.includeVariation - Include the requested variation payload (`trigger`,
535
- * `workflowStructure`, `agentSelection`) on list rows.
536
- * @returns A page of workflows.
712
+ * @param options.search - Case-insensitive substring filter on scope name.
713
+ * @param options.view - Variation view. `active` reads the deployed version, or the latest draft
714
+ * when nothing is published. `draft` reads the latest builder snapshot. `published` reads only
715
+ * the published version, and only scopes you can use.
716
+ * @param options.managerId - Return only scopes supervised by this manager scope id.
717
+ * @returns A page of scopes.
537
718
  *
538
719
  * @example
539
720
  * ```ts
540
- * for await (const wf of (await client.workflows.list({ search: 'digest' })).autoPagingIter()) {
541
- * console.log(wf.id, wf.name, wf.status)
721
+ * for await (const scope of (await client.scopes.list()).autoPagingIter()) {
722
+ * console.log(scope.id, scope.name, scope.status)
542
723
  * }
543
724
  * ```
544
725
  */
@@ -546,161 +727,370 @@ declare class WorkflowsResourceBase {
546
727
  pageSize?: number;
547
728
  pageToken?: string;
548
729
  search?: string;
549
- type?: WorkflowType;
550
730
  view?: VariationView;
551
- includeVariation?: boolean;
552
- }): Promise<Page<Workflow>>;
553
- protected listPage(pageSize: number, pageToken: string | undefined, search?: string, type?: WorkflowType, view?: VariationView, includeVariation?: boolean): Promise<Page<Workflow>>;
554
- }
555
-
556
- declare class AgentWorkflowActionsResource {
557
- private readonly http;
558
- private readonly config;
559
- /** @internal */
560
- constructor(http: HttpClient, config: ModusConfig);
731
+ managerId?: number;
732
+ }): Promise<Page<Scope>>;
733
+ protected listPage(pageSize: number, pageToken: string | undefined, search?: string, view?: VariationView, managerId?: number): Promise<Page<Scope>>;
561
734
  /**
562
- * Execute a workflow action and stream run events.
735
+ * Get a scope.
563
736
  *
564
- * @param body - Action body (`organizationId`, `sessionId`, `workflowAction`, optional `previousOutputs`).
565
- * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
566
- * @returns A stream of run events for the action execution.
567
- */
568
- execute(body: WorkflowActionRequest, options?: {
569
- idempotencyKey?: string;
570
- }): AgentRunStream;
571
- /**
572
- * Cancel a workflow action run.
737
+ * Returns a scope. `view=active` (default) is the deployed version, or the latest draft when
738
+ * nothing is published. `view=draft` is the latest edits. `view=published` is only the published
739
+ * version, and only if you can use the scope. Returns 404 if you cannot access it.
573
740
  *
574
- * @param runId - Action run id to cancel.
741
+ * **Requires:** `scopes:read`
742
+ *
743
+ * @param scopeId - Numeric scope id.
744
+ * @param options.view - Which version to read. Defaults to `active`. `published` is only the
745
+ * published version, and only if you can use the scope.
746
+ *
747
+ * @example
748
+ * ```ts
749
+ * const [first] = (await client.scopes.list()).items
750
+ * const scope = await client.scopes.get(first.id)
751
+ * console.log(scope.name, scope.status)
752
+ * ```
575
753
  */
576
- cancel(runId: string): Promise<void>;
577
- private parseEvents;
754
+ get(scopeId: number | string, options?: {
755
+ view?: VariationView;
756
+ }): Promise<Scope>;
578
757
  }
579
758
 
580
759
  /**
581
- * Read and run access to Modus workflows.
760
+ * Read / chat with published scopes.
582
761
  *
583
- * - `list` / `get` — browse workflows (`view: 'active'` or `'draft'`)
584
- * - {@link WorkflowRunsResource runs} — start, monitor, and control workflow runs
585
- * - {@link AgentWorkflowActionsResource workflowActions} — execute workflow actions
762
+ * Call path: `client.scopes` after `new Modus(...)`. Prefer `client.modus` for
763
+ * the org-wide assistant. Create/deploy via `ModusManagement`.
586
764
  *
587
765
  * @example
588
766
  * ```ts
589
- * import { Modus } from '@getmodus/sdk'
590
- * const client = new Modus()
591
- * for await (const wf of (await client.workflows.list()).autoPagingIter()) {
592
- * console.log(wf.id, wf.name, wf.status)
593
- * }
767
+ * const [scope] = (await client.scopes.list()).items
768
+ * const result = await client.scopes.chat(scope.id, 'What is our ARR trend?', {
769
+ * model: 'claude-sonnet-5',
770
+ * })
771
+ * console.log(result.content, result.threadId)
594
772
  * ```
595
773
  */
596
- declare class WorkflowsResource extends WorkflowsResourceBase {
597
- readonly runs: WorkflowRunsResource;
598
- readonly workflowActions: AgentWorkflowActionsResource;
599
- /** @internal */
600
- constructor(http: HttpClient, config: ModusConfig);
774
+ declare class ScopesResource extends ScopesResourceBase {
601
775
  /**
602
- * Retrieve a workflow by ID or slug.
776
+ * Return the conversations sub-resource scoped to `scopeId`.
603
777
  *
604
- * @param workflowId - Numeric id or slug.
605
- * @param options.view - Which saved version to return (`active` or `draft`).
606
- * @param options.includeVariation - Include variation metadata when supported.
607
- * @returns The workflow (`id`, `name`, `status`, …).
608
- * @throws {NotFoundError} When no workflow matches the id or slug.
778
+ * @param scopeId - Numeric scope id.
779
+ * @returns Conversations resource for the scope.
609
780
  *
610
781
  * @example
611
782
  * ```ts
612
- * const wf = await client.workflows.get('weekly-digest')
613
- * console.log(wf.name, wf.status)
783
+ * for await (const row of (
784
+ * await client.scopes.conversations(scopeId).list({ pageSize: 10 })
785
+ * ).autoPagingIter()) {
786
+ * console.log(row.threadId, row.firstMessage)
787
+ * }
614
788
  * ```
615
789
  */
616
- get(workflowId: number | string, options?: {
617
- view?: VariationView;
618
- includeVariation?: boolean;
619
- }): Promise<Workflow>;
620
- }
621
-
622
- /** Generated base for the consumption `connections` resource. */
623
- declare class ConnectionsResourceBase {
624
- protected readonly http: HttpClient;
625
- protected readonly config: ModusConfig;
626
- /** @internal */
627
- constructor(http: HttpClient, config: ModusConfig);
790
+ conversations(scopeId: number | string): ScopeConversationsResource;
628
791
  /**
629
- * List connections.
792
+ * Compose context this scope would use for an intent, without running chat.
630
793
  *
631
- * Returns a paginated page of warehouse and SaaS integration connections the caller can `use`.
632
- * Connections the caller cannot access are filtered out. Use the returned `id` when creating
633
- * saved-query context items. Pagination uses an opaque token returned in `nextPageToken`.
794
+ * Large bodies are bounded inline previews. This REST method does not expose file references
795
+ * or a full-content fetch operation. Runs on the agent host, like `chat`, so a compose may take
796
+ * up to 90 seconds; keep `timeoutMs` above that. A compose still running at 90 seconds fails
797
+ * with `UPSTREAM_TIMEOUT` (504).
634
798
  *
635
- * **Requires:** `context:read`
799
+ * @param scopeId - Numeric scope id.
800
+ * @param message - Natural-language intent used to select context.
801
+ * @param options.limit - Maximum context items to return. Omit to return all selected items.
802
+ * @returns Composed context text plus selection counts, item UIDs, and correlation session id.
636
803
  *
637
- * @param options.pageSize - Items per page. Defaults to 25.
638
- * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
639
- * for the first page.
640
- * @param options.type - Filter by effective integration category (case-sensitive exact match).
641
- * @returns A page of connections.
804
+ * @example
805
+ * ```ts
806
+ * const ctx = await client.scopes.getContext(scopeId, 'Which tables describe churn?', {
807
+ * limit: 5,
808
+ * })
809
+ * console.log(ctx.originalCount, ctx.sessionId)
810
+ * ```
642
811
  */
643
- list(options?: {
812
+ getContext(scopeId: number | string, message: string, options?: {
813
+ limit?: number;
814
+ }): Promise<SkillContextComposition>;
815
+ /**
816
+ * Chat with a published scope. The reply streams live from the agent host:
817
+ * iterate `textStream()` for tokens, or `await` the result for the final
818
+ * answer. Pass the returned `threadId` back to continue the conversation.
819
+ *
820
+ * For the org-wide assistant use `client.modus.chat` instead.
821
+ *
822
+ * @param scopeId - Numeric scope id (must be active for chat).
823
+ * @param message - User message text.
824
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5.5"`).
825
+ * @param options.threadId - Continue an existing conversation; omit to start new.
826
+ * @returns A chat session — iterate it or `await` it for `content`, `threadId`, `runId`.
827
+ * @throws {ModusError} When no agent host is known for a custom `baseUrl`.
828
+ *
829
+ * @example
830
+ * ```ts
831
+ * const chat = client.scopes.chat(scopeId, 'What is our ARR trend?', { model: 'claude-sonnet-5.5' })
832
+ * for await (const token of chat.textStream()) process.stdout.write(token)
833
+ * const { threadId } = await chat
834
+ * const follow = await client.scopes.chat(scopeId, 'Break that down by segment.', {
835
+ * model: 'claude-sonnet-5.5',
836
+ * threadId,
837
+ * })
838
+ * console.log(follow.content)
839
+ * ```
840
+ */
841
+ chat(scopeId: number | string, message: string, options: ChatOptions): ChatSession;
842
+ }
843
+
844
+ /** Generated base for the consumption `modus.conversations` resource. */
845
+ declare class ModusConversationsResourceBase {
846
+ protected readonly http: HttpClient;
847
+ protected readonly config: ModusConfig;
848
+ /** @internal */
849
+ constructor(http: HttpClient, config: ModusConfig);
850
+ /**
851
+ * Get a Modus conversation.
852
+ *
853
+ * Returns the full message history for a conversation thread.
854
+ *
855
+ * **Requires:** `scopes:read`
856
+ *
857
+ * @param threadId - Thread id from a conversation list or chat response.
858
+ */
859
+ get(threadId: string): Promise<Conversation>;
860
+ }
861
+
862
+ /** List and retrieve Modus / scope conversations. */
863
+ declare class ModusConversationsResource extends ModusConversationsResourceBase {
864
+ constructor(http: HttpClient, config: ModusConfig);
865
+ /**
866
+ * List conversations.
867
+ *
868
+ * @param options.pageSize - Items per page (default 25).
869
+ * @param options.pageToken - Opaque token from a previous page.
870
+ * @param options.kind - `"modus"`, `"scopes"`, or `"all"`.
871
+ * @param options.source - Restrict to conversations started from this UI surface
872
+ * (e.g. `"context_chat"`, `"dashboard_copilot"`, `"slack"`). Only valid with an
873
+ * omitted `kind` or `kind: "all"`; the API throws an `UnprocessableError` (422)
874
+ * if combined with `kind: "modus"` or `kind: "scopes"`.
875
+ * @param options.sourceRef - Narrow `source` to one instance of that surface — for
876
+ * `"dashboard_copilot"`, a dashboard id. Requires `source`; the API throws an
877
+ * `UnprocessableError` (422) if sent on its own. Conversations recorded before
878
+ * this filter shipped carry no instance key and never match it.
879
+ * @returns Page of conversation list items.
880
+ */
881
+ list(options?: {
644
882
  pageSize?: number;
645
883
  pageToken?: string;
646
- type?: string;
647
- }): Promise<Page<Connection>>;
648
- protected listPage(pageSize: number, pageToken: string | undefined, type?: string): Promise<Page<Connection>>;
884
+ kind?: ConversationKind;
885
+ source?: string;
886
+ sourceRef?: string;
887
+ }): Promise<Page<ConversationListItem>>;
888
+ private listPage;
649
889
  }
650
890
 
651
891
  /**
652
- * Read access to integration connections.
892
+ * Org-wide Modus assistant (full environment context and tools).
893
+ *
894
+ * Prefer `client.modus` over `client.scopes` when the question is not tied to one
895
+ * published scope. Construct with `new Modus()` (reads `MODUS_API_KEY`).
896
+ *
897
+ * - `chat` — stream a reply live, or `await` it for the complete answer
898
+ * - `getContext` — preview composed context without a chat turn
899
+ * - `conversations` — list/get prior Modus threads
900
+ *
901
+ * @example
902
+ * ```ts
903
+ * import { Modus } from '@getmodus/sdk'
904
+ * const client = new Modus()
905
+ * const result = await client.modus.chat('What tables describe revenue?', {
906
+ * model: 'claude-sonnet-5',
907
+ * })
908
+ * console.log(result.content, result.threadId)
909
+ * ```
653
910
  */
654
- declare class ConnectionsResource extends ConnectionsResourceBase {
911
+ declare class ModusResource {
912
+ private readonly http;
913
+ private readonly config;
914
+ readonly conversations: ModusConversationsResource;
915
+ constructor(http: HttpClient, config: ModusConfig);
655
916
  /**
656
- * Find the first connection whose name matches (case-insensitive).
917
+ * Compose full-environment context for an intent without running chat.
657
918
  *
658
- * Pages through {@link ConnectionsResource.list} until a match is found.
919
+ * Runs on the agent host, like `chat`, so a compose may take up to 90 seconds; keep `timeoutMs`
920
+ * above that. A compose still running at 90 seconds fails with `UPSTREAM_TIMEOUT` (504).
659
921
  *
660
- * @param options.name - Connection name to search for.
661
- * @param options.type - Optional integration category filter.
662
- * @param options.pageSize - Page size when scanning (default 25).
663
- * @returns The matching connection, or `undefined` if none is found.
922
+ * @param message - Natural-language intent used to select context.
923
+ * @param options.limit - Maximum context items to return. Omit to return all selected items.
924
+ * @returns Composition metadata (counts / session id). Use `chat` for a reply.
925
+ *
926
+ * @example
927
+ * ```ts
928
+ * const ctx = await client.modus.getContext('What tables describe revenue?', { limit: 5 })
929
+ * console.log(ctx.originalCount, ctx.sessionId)
930
+ * ```
664
931
  */
665
- find(options: {
666
- name: string;
667
- type?: string;
668
- pageSize?: number;
669
- }): Promise<Connection | undefined>;
932
+ getContext(message: string, options?: {
933
+ limit?: number;
934
+ }): Promise<ModusContextComposition>;
670
935
  /**
671
- * List the selectable units on a connection (a repository, a schema, a project).
936
+ * Chat with Modus, the org-wide assistant. The reply streams live from the
937
+ * agent host: iterate `textStream()` for tokens, or `await` the result for
938
+ * the final answer. Pass the returned `threadId` back to continue.
939
+ *
940
+ * @param message - User message text.
941
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5.5"`).
942
+ * @param options.threadId - Continue an existing conversation; omit to start new.
943
+ * @returns A chat session — iterate it or `await` it for `content`, `threadId`, `runId`.
944
+ * @throws {ModusError} When no agent host is known for a custom `baseUrl`.
672
945
  *
673
- * @param connectionId - Connection id.
674
- * @param options.pageSize - Maximum items per page (default 25).
675
- * @param options.pageToken - Opaque token from a previous page.
676
- * @returns A page of selectable units — use {@link iterSelections} or `.autoPagingIter()` for every page.
677
946
  * @example
678
- * for await (const unit of client.connections.iterSelections('7a3f9d2c-1111-4000-a000-000000000abc')) {
679
- * console.log(unit.objectType, unit.path)
680
- * }
947
+ * ```ts
948
+ * const result = await client.modus.chat('What tables describe revenue?', {
949
+ * model: 'claude-sonnet-5.5',
950
+ * })
951
+ * console.log(result.content)
952
+ * const follow = client.modus.chat('Break that down by region.', {
953
+ * model: 'claude-sonnet-5.5',
954
+ * threadId: result.threadId,
955
+ * })
956
+ * for await (const token of follow.textStream()) process.stdout.write(token)
957
+ * ```
681
958
  */
682
- listSelections(connectionId: string, options?: {
683
- pageSize?: number;
684
- pageToken?: string;
685
- }): Promise<Page<ConnectionSelection>>;
686
- private listSelectionsPage;
959
+ chat(message: string, options: ChatOptions): ChatSession;
960
+ }
961
+
962
+ /** Generated base for the consumption `workflows` resource. */
963
+ declare class WorkflowsResourceBase {
964
+ protected readonly http: HttpClient;
965
+ protected readonly config: ModusConfig;
966
+ /** @internal */
967
+ constructor(http: HttpClient, config: ModusConfig);
687
968
  /**
688
- * Yield every selectable unit on a connection, following pages.
969
+ * List workflows.
970
+ *
971
+ * Returns a paginated page of workflows the caller can at least `use`. Workflows the caller
972
+ * cannot see are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
973
+ *
974
+ * **Requires:** `workflows:read`
975
+ *
976
+ * @param options.pageSize - Items per page. Defaults to 25.
977
+ * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
978
+ * for the first page.
979
+ * @param options.search - Case-insensitive substring filter on workflow name.
980
+ * @param options.type - Filter by workflow type.
981
+ * @param options.view - Variation view. `active` reads the deployed version. `draft` reads the
982
+ * latest builder snapshot. `published` reads only a published workflow of type workflow that
983
+ * you can use; tasks are excluded.
984
+ * @param options.includeVariation - Include the requested variation payload (`trigger`,
985
+ * `workflowStructure`, `agentSelection`) on list rows.
986
+ * @returns A page of workflows.
689
987
  *
690
- * @param connectionId - Connection id.
691
- * @param options.pageSize - Maximum items per page (default 25).
692
988
  * @example
693
- * for await (const unit of client.connections.iterSelections('7a3f9d2c-1111-4000-a000-000000000abc')) {
694
- * console.log(unit.objectType, unit.displayName)
989
+ * ```ts
990
+ * for await (const wf of (await client.workflows.list({ search: 'digest' })).autoPagingIter()) {
991
+ * console.log(wf.id, wf.name, wf.status)
695
992
  * }
993
+ * ```
696
994
  */
697
- iterSelections(connectionId: string, options?: {
995
+ list(options?: {
698
996
  pageSize?: number;
699
- }): AsyncGenerator<ConnectionSelection>;
997
+ pageToken?: string;
998
+ search?: string;
999
+ type?: WorkflowType;
1000
+ view?: VariationView;
1001
+ includeVariation?: boolean;
1002
+ }): Promise<Page<Workflow>>;
1003
+ protected listPage(pageSize: number, pageToken: string | undefined, search?: string, type?: WorkflowType, view?: VariationView, includeVariation?: boolean): Promise<Page<Workflow>>;
700
1004
  }
701
1005
 
702
- type JsonObjectInput = Record<string, unknown>;
703
- type ContentProjection = components['schemas']['ContentProjectionDto'];
1006
+ declare class AgentWorkflowActionsResource {
1007
+ private readonly http;
1008
+ private readonly config;
1009
+ /** @internal */
1010
+ constructor(http: HttpClient, config: ModusConfig);
1011
+ /**
1012
+ * Execute a workflow action and stream run events.
1013
+ *
1014
+ * @param body - Action body (`organizationId`, `sessionId`, `workflowAction`, optional `previousOutputs`).
1015
+ * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.
1016
+ * @returns A stream of run events for the action execution.
1017
+ */
1018
+ execute(body: WorkflowActionRequest, options?: {
1019
+ idempotencyKey?: string;
1020
+ }): AgentRunStream;
1021
+ /**
1022
+ * Cancel a workflow action run.
1023
+ *
1024
+ * @param runId - Action run id to cancel.
1025
+ */
1026
+ cancel(runId: string): Promise<void>;
1027
+ private parseEvents;
1028
+ }
1029
+
1030
+ /**
1031
+ * Read and run access to Modus workflows.
1032
+ *
1033
+ * - `list` / `get` — browse workflows (`view: 'active'`, `'draft'`, or `'published'`)
1034
+ * - `chat` — send a workflow a message and stream its reply
1035
+ * - {@link WorkflowRunsResource runs} — start, monitor, and control workflow runs
1036
+ * - {@link AgentWorkflowActionsResource workflowActions} — execute workflow actions
1037
+ *
1038
+ * @example
1039
+ * ```ts
1040
+ * import { Modus } from '@getmodus/sdk'
1041
+ * const client = new Modus()
1042
+ * for await (const wf of (await client.workflows.list()).autoPagingIter()) {
1043
+ * console.log(wf.id, wf.name, wf.status)
1044
+ * }
1045
+ * ```
1046
+ */
1047
+ declare class WorkflowsResource extends WorkflowsResourceBase {
1048
+ readonly runs: WorkflowRunsResource;
1049
+ readonly workflowActions: AgentWorkflowActionsResource;
1050
+ /** @internal */
1051
+ constructor(http: HttpClient, config: ModusConfig);
1052
+ /**
1053
+ * Retrieve a workflow by its numeric id.
1054
+ *
1055
+ * @param workflowId - Numeric workflow id.
1056
+ * @param options.view - Which saved version to return (`active` or `draft`).
1057
+ * @param options.includeVariation - Include variation metadata when supported.
1058
+ * @returns The workflow (`id`, `name`, `status`, …).
1059
+ * @throws {NotFoundError} When no workflow has this id.
1060
+ *
1061
+ * @example
1062
+ * ```ts
1063
+ * const [first] = (await client.workflows.list()).items
1064
+ * const wf = await client.workflows.get(first.id)
1065
+ * console.log(wf.name, wf.status)
1066
+ * ```
1067
+ */
1068
+ get(workflowId: number | string, options?: {
1069
+ view?: VariationView;
1070
+ includeVariation?: boolean;
1071
+ }): Promise<Workflow>;
1072
+ /**
1073
+ * Chat with a published workflow. Node output streams live from the agent
1074
+ * host: iterate `textStream()` for tokens, or `await` the result for the
1075
+ * workflow's final output.
1076
+ *
1077
+ * @param workflowId - Numeric workflow id.
1078
+ * @param message - User message text.
1079
+ * @param options.model - Required model id (e.g. `"claude-sonnet-5.5"`).
1080
+ * @param options.threadId - Continue an existing conversation; omit to start new.
1081
+ * @returns A chat session — iterate it or `await` it for `content`, `threadId`, `runId`.
1082
+ * @throws {ModusError} When no agent host is known for a custom `baseUrl`.
1083
+ *
1084
+ * @example
1085
+ * ```ts
1086
+ * const { content } = await client.workflows.chat(workflowId, 'Run this week\'s digest', {
1087
+ * model: 'claude-sonnet-5.5',
1088
+ * })
1089
+ * console.log(content)
1090
+ * ```
1091
+ */
1092
+ chat(workflowId: number | string, message: string, options: ChatOptions): ChatSession;
1093
+ }
704
1094
 
705
1095
  /**
706
1096
  * Read the org knowledge base (notes, metrics, saved queries, integration items).
@@ -806,7 +1196,7 @@ declare class ContextItemsResource {
806
1196
  * contextType: 'note',
807
1197
  * dataPath: ['finance', 'arr-definition'],
808
1198
  * })
809
- * if (found) console.log(found.uid, found.description ?? found.uid)
1199
+ * if (found) console.log(found.uid, found.content)
810
1200
  * ```
811
1201
  */
812
1202
  lookup(options: {
@@ -815,14 +1205,19 @@ declare class ContextItemsResource {
815
1205
  contentProjection?: JsonObjectInput | ContentProjection;
816
1206
  }): Promise<ContextItemLookupRow | undefined>;
817
1207
  /**
818
- * List values stored under a content key on a context item.
1208
+ * Page through the elements of an array field inside one context item's content.
1209
+ *
1210
+ * Each row is `{ index, value }`: the element's position in the array and the
1211
+ * element itself. A field that is not an array reads as one element; a missing
1212
+ * field as none. Rejects with a not-found error when the item does not exist,
1213
+ * you cannot read it, or its context type is not `contextType`.
819
1214
  *
820
1215
  * @param uid - Item uid.
821
1216
  * @param contextType - Context type of the item.
822
- * @param contentKeyPath - Dot path to the value field inside item content (e.g. `"enumValues"`).
823
- * @param options.pageSize - Maximum items per page (default 25).
824
- * @param options.pageToken - Opaque token from a previous page.
825
- * @returns A page of value rows.
1217
+ * @param contentKeyPath - Dot path to the array inside item content (e.g. `"enumValues"`).
1218
+ * @param options.pageSize - Maximum elements per page (default 25).
1219
+ * @param options.pageToken - Opaque token from a previous page of the same item.
1220
+ * @returns A page of `{ index, value }` rows.
826
1221
  *
827
1222
  * @example
828
1223
  * ```ts
@@ -833,7 +1228,7 @@ declare class ContextItemsResource {
833
1228
  * 'enumValues',
834
1229
  * { pageSize: 25 },
835
1230
  * )
836
- * for (const row of page.items) console.log(row)
1231
+ * for (const row of page.items) console.log(row.index, row.value)
837
1232
  * ```
838
1233
  */
839
1234
  listValues(uid: string, contextType: string, contentKeyPath: string, options?: {
@@ -841,13 +1236,13 @@ declare class ContextItemsResource {
841
1236
  pageToken?: string;
842
1237
  }): Promise<Page<ContextValueRow>>;
843
1238
  /**
844
- * List values for a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.
1239
+ * Page through an array field of a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.
845
1240
  *
846
1241
  * @param item - Context item (uses `item.uid` and `item.contextType`).
847
- * @param contentKeyPath - Dot path to the value field inside item content.
848
- * @param options.pageSize - Maximum items per page (default 25).
849
- * @param options.pageToken - Opaque token from a previous page.
850
- * @returns A page of value rows.
1242
+ * @param contentKeyPath - Dot path to the array inside item content.
1243
+ * @param options.pageSize - Maximum elements per page (default 25).
1244
+ * @param options.pageToken - Opaque token from a previous page of the same item.
1245
+ * @returns A page of `{ index, value }` rows.
851
1246
  *
852
1247
  * @example
853
1248
  * ```ts
@@ -879,347 +1274,84 @@ declare class ContextResource {
879
1274
  constructor(http: HttpClient, config: ModusConfig);
880
1275
  }
881
1276
 
882
- /** Store exact integration requests and responses as immutable ingested data. */
883
- declare class IngestedDataResource {
884
- private readonly http;
885
- private readonly config;
886
- /** @internal */
887
- constructor(http: HttpClient, config: ModusConfig);
888
- /**
889
- * Store a complete SQL or HTTP request and response exactly once.
890
- *
891
- * Identity covers the complete organization, integration, request, and response
892
- * content. A duplicate raises `ConflictError`, which means the identical payload
893
- * is already stored and may be treated as a safe retry outcome.
894
- *
895
- * @param options.integrationType - Canonical Modus integration identifier.
896
- * @param options.request - Exact SQL or HTTP request that produced the response.
897
- * @param options.response - Response format, optional source HTTP status, and exact string content. SQL requires CSV.
898
- * @returns The checksum of the stored envelope.
899
- * @throws {ConflictError} When the complete payload is already stored.
900
- *
901
- * @example
902
- * ```ts
903
- * const stored = await client.ingestedData.upload({
904
- * integrationType: 'generic',
905
- * request: { type: 'sql', query: 'SELECT id, total FROM orders' },
906
- * response: { format: 'csv', content: 'id,total\n1,42.00\n' },
907
- * })
908
- * console.log(stored.checksum)
909
- * ```
910
- */
911
- upload(options: UploadIngestedDataOptions): Promise<IngestedDataUploadResult>;
912
- }
913
-
914
- /** Generated base for the consumption `modus.conversations` resource. */
915
- declare class ModusConversationsResourceBase {
916
- protected readonly http: HttpClient;
917
- protected readonly config: ModusConfig;
918
- /** @internal */
919
- constructor(http: HttpClient, config: ModusConfig);
920
- /**
921
- * Get a Modus conversation.
922
- *
923
- * Returns the full message history for a conversation thread.
924
- *
925
- * **Requires:** `scopes:read`
926
- *
927
- * @param threadId - Thread id from a conversation list or chat response.
928
- */
929
- get(threadId: string): Promise<Conversation>;
930
- }
931
-
932
- /** List and retrieve Modus / scope conversations. */
933
- declare class ModusConversationsResource extends ModusConversationsResourceBase {
934
- constructor(http: HttpClient, config: ModusConfig);
935
- /**
936
- * List conversations.
937
- *
938
- * @param options.pageSize - Items per page (default 25).
939
- * @param options.pageToken - Opaque token from a previous page.
940
- * @param options.kind - `"modus"`, `"scopes"`, or `"all"`.
941
- * @param options.source - Restrict to conversations started from this UI surface
942
- * (e.g. `"context_chat"`, `"dashboard_copilot"`, `"slack"`). Only valid with an
943
- * omitted `kind` or `kind: "all"`; the API throws an `UnprocessableError` (422)
944
- * if combined with `kind: "modus"` or `kind: "scopes"`.
945
- * @param options.sourceRef - Narrow `source` to one instance of that surface — for
946
- * `"dashboard_copilot"`, a dashboard id. Requires `source`; the API throws an
947
- * `UnprocessableError` (422) if sent on its own. Conversations recorded before
948
- * this filter shipped carry no instance key and never match it.
949
- * @returns Page of conversation list items.
950
- */
951
- list(options?: {
952
- pageSize?: number;
953
- pageToken?: string;
954
- kind?: ConversationKind;
955
- source?: string;
956
- sourceRef?: string;
957
- }): Promise<Page<ConversationListItem>>;
958
- private listPage;
959
- }
960
-
961
- /**
962
- * Org-wide Modus assistant (full environment context and tools).
963
- *
964
- * Prefer `client.modus` over `client.scopes` when the question is not tied to one
965
- * published scope. Construct with `new Modus()` (reads `MODUS_API_KEY`).
966
- *
967
- * - `chat` — one complete reply
968
- * - `chatStream` — print tokens as they arrive (consume `textStream()`)
969
- * - `getContext` — preview composed context without a chat turn
970
- * - `conversations` — list/get prior Modus threads
971
- *
972
- * @example
973
- * ```ts
974
- * import { Modus } from '@getmodus/sdk'
975
- * const client = new Modus()
976
- * const result = await client.modus.chat('What tables describe revenue?', {
977
- * model: 'claude-sonnet-5',
978
- * })
979
- * console.log(result.content, result.threadId)
980
- * ```
981
- */
982
- declare class ModusResource {
983
- private readonly http;
984
- private readonly config;
985
- readonly conversations: ModusConversationsResource;
986
- constructor(http: HttpClient, config: ModusConfig);
987
- /**
988
- * Compose full-environment context for an intent without running chat.
989
- *
990
- * @param message - Natural-language intent used to select context.
991
- * @param options.limit - Maximum context items to return. Omit to return all selected items.
992
- * @returns Composition metadata (counts / session id). Use `chat` for a reply.
993
- *
994
- * @example
995
- * ```ts
996
- * const ctx = await client.modus.getContext('What tables describe revenue?', { limit: 5 })
997
- * console.log(ctx.originalCount, ctx.sessionId)
998
- * ```
999
- */
1000
- getContext(message: string, options?: {
1001
- limit?: number;
1002
- }): Promise<ModusContextComposition>;
1003
- /**
1004
- * Send a message to Modus and wait for the complete reply.
1005
- *
1006
- * @param message - User message text.
1007
- * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1008
- * @param options.threadId - Continue an existing conversation; omit to start new.
1009
- * @returns Chat result: `content`, `threadId` (for follow-ups), `runId`.
1010
- *
1011
- * @example
1012
- * ```ts
1013
- * const result = await client.modus.chat('What tables describe revenue?', {
1014
- * model: 'claude-sonnet-5',
1015
- * })
1016
- * console.log(result.content, result.threadId)
1017
- * const follow = await client.modus.chat('Break that down by region.', {
1018
- * model: 'claude-sonnet-5',
1019
- * threadId: result.threadId,
1020
- * })
1021
- * ```
1022
- */
1023
- chat(message: string, options: {
1024
- model: ChatModel;
1025
- threadId?: string;
1026
- }): Promise<ChatResult>;
1027
- /**
1028
- * Stream a Modus reply token by token (SSE).
1029
- *
1030
- * The request starts when you consume `textStream()` or `eventStream()`.
1031
- *
1032
- * @param message - User message text.
1033
- * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1034
- * @param options.threadId - Continue an existing conversation; omit to start new.
1035
- * @returns Chat stream — iterate `textStream()` for tokens.
1036
- *
1037
- * @example
1038
- * ```ts
1039
- * const stream = client.modus.chatStream('Summarize ARR in three bullets.', {
1040
- * model: 'claude-sonnet-5',
1041
- * })
1042
- * for await (const token of stream.textStream()) {
1043
- * process.stdout.write(token)
1044
- * }
1045
- * console.log(stream.getFinalResult().threadId)
1046
- * ```
1047
- */
1048
- chatStream(message: string, options: {
1049
- model: ChatModel;
1050
- threadId?: string;
1051
- }): ChatStream;
1052
- }
1053
-
1054
- /** Generated base for the consumption `scopes` resource. */
1055
- declare class ScopesResourceBase {
1277
+ /** Generated base for the consumption `connections` resource. */
1278
+ declare class ConnectionsResourceBase {
1056
1279
  protected readonly http: HttpClient;
1057
1280
  protected readonly config: ModusConfig;
1058
1281
  /** @internal */
1059
1282
  constructor(http: HttpClient, config: ModusConfig);
1060
1283
  /**
1061
- * List scopes.
1284
+ * List connections.
1062
1285
  *
1063
- * Returns a paginated page of scopes the caller can at least `use`. Scopes the caller cannot see
1064
- * are filtered out. Pagination uses an opaque token returned in `nextPageToken`.
1286
+ * Returns a paginated page of warehouse and SaaS integration connections the caller can `use`.
1287
+ * Connections the caller cannot access are filtered out. Use the returned `id` when creating
1288
+ * saved-query context items. Pagination uses an opaque token returned in `nextPageToken`.
1065
1289
  *
1066
- * **Requires:** `scopes:read`
1290
+ * **Requires:** `context:read`
1067
1291
  *
1068
1292
  * @param options.pageSize - Items per page. Defaults to 25.
1069
1293
  * @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
1070
1294
  * for the first page.
1071
- * @param options.search - Case-insensitive substring filter on scope name.
1072
- * @param options.view - Variation view. `active` reads deployed; `draft` reads the latest builder
1073
- * snapshot.
1074
- * @param options.managerId - Return only scopes supervised by this manager scope id.
1075
- * @returns A page of scopes.
1076
- *
1077
- * @example
1078
- * ```ts
1079
- * for await (const scope of (await client.scopes.list()).autoPagingIter()) {
1080
- * console.log(scope.id, scope.name, scope.status)
1081
- * }
1082
- * ```
1295
+ * @param options.type - Filter by effective integration category (case-sensitive exact match).
1296
+ * @returns A page of connections.
1083
1297
  */
1084
1298
  list(options?: {
1085
1299
  pageSize?: number;
1086
1300
  pageToken?: string;
1087
- search?: string;
1088
- view?: VariationView;
1089
- managerId?: number;
1090
- }): Promise<Page<Scope>>;
1091
- protected listPage(pageSize: number, pageToken: string | undefined, search?: string, view?: VariationView, managerId?: number): Promise<Page<Scope>>;
1092
- /**
1093
- * Get a scope.
1094
- *
1095
- * Returns a scope. `view=active` (default) returns the deployed version; `view=draft` returns the
1096
- * latest unpublished edits. Returns 404 if you cannot access the scope.
1097
- *
1098
- * **Requires:** `scopes:read`
1099
- *
1100
- * @param scopeId - Numeric scope id.
1101
- * @param options.view - Which variation snapshot to read. Defaults to `active`.
1102
- *
1103
- * @example
1104
- * ```ts
1105
- * const scope = await client.scopes.get('revenue-analysis')
1106
- * console.log(scope.name, scope.status)
1107
- * ```
1108
- */
1109
- get(scopeId: number | string, options?: {
1110
- view?: VariationView;
1111
- }): Promise<Scope>;
1301
+ type?: string;
1302
+ }): Promise<Page<Connection>>;
1303
+ protected listPage(pageSize: number, pageToken: string | undefined, type?: string): Promise<Page<Connection>>;
1112
1304
  }
1113
1305
 
1114
1306
  /**
1115
- * Read / chat with published scopes.
1116
- *
1117
- * Call path: `client.scopes` after `new Modus(...)`. Prefer `client.modus` for
1118
- * the org-wide assistant. Create/deploy via `ModusManagement`.
1119
- *
1120
- * @example
1121
- * ```ts
1122
- * const scope = await client.scopes.get('revenue-analysis')
1123
- * const result = await client.scopes.chat(scope.id, 'What is our ARR trend?', {
1124
- * model: 'claude-sonnet-5',
1125
- * })
1126
- * console.log(result.content, result.threadId)
1127
- * ```
1307
+ * Read access to integration connections.
1128
1308
  */
1129
- declare class ScopesResource extends ScopesResourceBase {
1130
- /**
1131
- * Return the conversations sub-resource scoped to `scopeId`.
1132
- *
1133
- * @param scopeId - Scope numeric id or slug.
1134
- * @returns Conversations resource for the scope.
1135
- *
1136
- * @example
1137
- * ```ts
1138
- * for await (const row of (
1139
- * await client.scopes.conversations(scopeId).list({ pageSize: 10 })
1140
- * ).autoPagingIter()) {
1141
- * console.log(row.threadId, row.firstMessage)
1142
- * }
1143
- * ```
1144
- */
1145
- conversations(scopeId: number | string): ScopeConversationsResource;
1309
+ declare class ConnectionsResource extends ConnectionsResourceBase {
1146
1310
  /**
1147
- * Compose context this scope would use for an intent, without running chat.
1148
- *
1149
- * Large bodies are bounded inline previews. This REST method does not expose file references
1150
- * or a full-content fetch operation.
1311
+ * Find the first connection whose name matches (case-insensitive).
1151
1312
  *
1152
- * @param scopeId - Scope numeric id or slug.
1153
- * @param message - Natural-language intent used to select context.
1154
- * @param options.limit - Maximum context items to return. Omit to return all selected items.
1155
- * @returns Composed context text plus selection counts, item UIDs, and correlation session id.
1313
+ * Pages through {@link ConnectionsResource.list} until a match is found.
1156
1314
  *
1157
- * @example
1158
- * ```ts
1159
- * const ctx = await client.scopes.getContext(scopeId, 'Which tables describe churn?', {
1160
- * limit: 5,
1161
- * })
1162
- * console.log(ctx.originalCount, ctx.sessionId)
1163
- * ```
1315
+ * @param options.name - Connection name to search for.
1316
+ * @param options.type - Optional integration category filter.
1317
+ * @param options.pageSize - Page size when scanning (default 25).
1318
+ * @returns The matching connection, or `undefined` if none is found.
1164
1319
  */
1165
- getContext(scopeId: number | string, message: string, options?: {
1166
- limit?: number;
1167
- }): Promise<SkillContextComposition>;
1320
+ find(options: {
1321
+ name: string;
1322
+ type?: string;
1323
+ pageSize?: number;
1324
+ }): Promise<Connection | undefined>;
1168
1325
  /**
1169
- * Send a message to a published scope and wait for the complete reply.
1170
- *
1171
- * For the org-wide assistant use `client.modus.chat` instead.
1172
- *
1173
- * @param scopeId - Scope numeric id or slug (must be active for chat).
1174
- * @param message - User message text.
1175
- * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1176
- * @param options.threadId - Continue an existing conversation; omit to start new.
1177
- * @returns Chat result: `content`, `threadId`, `runId`.
1326
+ * List the selectable units on a connection (a repository, a schema, a project).
1178
1327
  *
1328
+ * @param connectionId - Connection id.
1329
+ * @param options.pageSize - Maximum items per page (default 25).
1330
+ * @param options.pageToken - Opaque token from a previous page.
1331
+ * @returns A page of selectable units — use {@link iterSelections} or `.autoPagingIter()` for every page.
1179
1332
  * @example
1180
- * ```ts
1181
- * const result = await client.scopes.chat(scopeId, 'What is our ARR trend?', {
1182
- * model: 'claude-sonnet-5',
1183
- * })
1184
- * console.log(result.content, result.threadId)
1185
- * const follow = await client.scopes.chat(scopeId, 'Break that down by segment.', {
1186
- * model: 'claude-sonnet-5',
1187
- * threadId: result.threadId,
1188
- * })
1189
- * ```
1333
+ * for await (const unit of client.connections.iterSelections('7a3f9d2c-1111-4000-a000-000000000abc')) {
1334
+ * console.log(unit.objectType, unit.path)
1335
+ * }
1190
1336
  */
1191
- chat(scopeId: number | string, message: string, options: {
1192
- model: ChatModel;
1193
- threadId?: string;
1194
- }): Promise<ChatResult>;
1337
+ listSelections(connectionId: string, options?: {
1338
+ pageSize?: number;
1339
+ pageToken?: string;
1340
+ }): Promise<Page<ConnectionSelection>>;
1341
+ private listSelectionsPage;
1195
1342
  /**
1196
- * Stream a scope reply token by token (SSE).
1197
- *
1198
- * The request starts when you consume `textStream()` or `eventStream()`.
1199
- *
1200
- * @param scopeId - Scope numeric id or slug.
1201
- * @param message - User message text.
1202
- * @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
1203
- * @param options.threadId - Continue an existing conversation; omit to start new.
1204
- * @param options.version - `"published"` or `"draft"`.
1205
- * @returns Chat stream — iterate `textStream()` for tokens.
1343
+ * Yield every selectable unit on a connection, following pages.
1206
1344
  *
1345
+ * @param connectionId - Connection id.
1346
+ * @param options.pageSize - Maximum items per page (default 25).
1207
1347
  * @example
1208
- * ```ts
1209
- * const stream = client.scopes.chatStream(scopeId, 'Summarize in three bullets.', {
1210
- * model: 'claude-sonnet-5',
1211
- * })
1212
- * for await (const token of stream.textStream()) {
1213
- * process.stdout.write(token)
1348
+ * for await (const unit of client.connections.iterSelections('7a3f9d2c-1111-4000-a000-000000000abc')) {
1349
+ * console.log(unit.objectType, unit.displayName)
1214
1350
  * }
1215
- * console.log(stream.getFinalResult().threadId)
1216
- * ```
1217
1351
  */
1218
- chatStream(scopeId: number | string, message: string, options: {
1219
- model: ChatModel;
1220
- threadId?: string;
1221
- version?: string;
1222
- }): ChatStream;
1352
+ iterSelections(connectionId: string, options?: {
1353
+ pageSize?: number;
1354
+ }): AsyncGenerator<ConnectionSelection>;
1223
1355
  }
1224
1356
 
1225
1357
  /**
@@ -1236,7 +1368,7 @@ declare class SuggestionsResource {
1236
1368
  * @param options.pageSize - Maximum items per page (default 5, max 12).
1237
1369
  * @param options.pageToken - Opaque token from a previous page.
1238
1370
  * @param options.scopeId - Filter to a single scope.
1239
- * @param options.scopeIds - Filter to one or more scopes.
1371
+ * @param options.scopeIds - Filter to one or more scopes. An empty list throws; omit it for every scope.
1240
1372
  * @returns A page of suggested questions.
1241
1373
  */
1242
1374
  list(options?: {
@@ -1255,6 +1387,38 @@ declare class SuggestionsResource {
1255
1387
  recordEvent(id: string, event: RecordSuggestionEventRequest): Promise<void>;
1256
1388
  }
1257
1389
 
1390
+ /** Store exact integration requests and responses as immutable ingested data. */
1391
+ declare class IngestedDataResource {
1392
+ private readonly http;
1393
+ private readonly config;
1394
+ /** @internal */
1395
+ constructor(http: HttpClient, config: ModusConfig);
1396
+ /**
1397
+ * Store a complete SQL or HTTP request and response exactly once.
1398
+ *
1399
+ * Identity covers the complete organization, integration, request, and response
1400
+ * content. A duplicate raises `ConflictError`, which means the identical payload
1401
+ * is already stored and may be treated as a safe retry outcome.
1402
+ *
1403
+ * @param options.integrationType - Canonical Modus integration identifier.
1404
+ * @param options.request - Exact SQL or HTTP request that produced the response.
1405
+ * @param options.response - Response format, optional source HTTP status, and exact string content. SQL requires CSV.
1406
+ * @returns The checksum of the stored envelope.
1407
+ * @throws {ConflictError} When the complete payload is already stored.
1408
+ *
1409
+ * @example
1410
+ * ```ts
1411
+ * const stored = await client.ingestedData.upload({
1412
+ * integrationType: 'generic',
1413
+ * request: { type: 'sql', query: 'SELECT id, total FROM orders' },
1414
+ * response: { format: 'csv', content: 'id,total\n1,42.00\n' },
1415
+ * })
1416
+ * console.log(stored.checksum)
1417
+ * ```
1418
+ */
1419
+ upload(options: UploadIngestedDataOptions): Promise<IngestedDataUploadResult>;
1420
+ }
1421
+
1258
1422
  /**
1259
1423
  * Read / invoke client for Modus scopes, workflows, connections, and more.
1260
1424
  *
@@ -1273,4 +1437,4 @@ declare class Modus extends ModusClientBase {
1273
1437
  constructor(options?: ModusOptions);
1274
1438
  }
1275
1439
 
1276
- 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, type ConnectionSelection, ContextItem, ContextItemLookupRow, type ContextValueRow, Conversation, ConversationKind, ConversationListItem, type CreateAgentRunRequest, type DoneEvent, type EditQueuedRunRequest, type ErrorEvent, type HttpIngestedDataRequest, type IngestedDataRequest, type IngestedDataResponse, type IngestedDataResponseFormat, type IngestedDataUploadResult, 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, type SqlIngestedDataRequest, StreamTimeoutError, type StreamTimeoutEvent, type SuggestionEventSource, type SuggestionEventType, type SuggestionQuestion, type TokenEvent, UnprocessableError, type UploadIngestedDataOptions, ValidationError, VariationView, Workflow, type WorkflowActionRequest, WorkflowType, components };
1440
+ export { APIConnectionError, type ActiveConversationRun, type ActiveConversationRunStatus, type AgentRun, type AgentRunCreateRequest, type AgentRunListItem, type AgentRunStream, AgentWorkflowActionsResource, type ApprovalRequiredEvent, type ApprovalScope, type AssistantContentResetEvent, AuthenticationError, BadRequestError, type CancelRunRequest, type CancelledEvent, type ChatModel, type ChatOptions, type ChatResult, ChatSession, type ComposeSkillContextRequest, ConflictError, type Connection, type ConnectionSelection, ConnectionsResource, type ContentProjection, ContextItem, ContextItemLookupRow, ContextItemsResource, ContextResource, type ContextValueRow, Conversation, ConversationKind, ConversationListItem, type CreateAgentRunRequest, CustomContextItemsResource, type DoneEvent, type EditQueuedRunRequest, type ErrorEvent, type FollowUpRunRequest, type HttpIngestedDataRequest, type IngestedDataRequest, IngestedDataResource, type IngestedDataResponse, type IngestedDataResponseFormat, type IngestedDataUploadResult, InternalServerError, type InterruptRunRequest, type JsonObjectInput, Modus, ModusConfig, type ModusContextComposition, type ModusContextRequest, ModusConversationsResource, ModusError, ModusOptions, ModusResource, type ModusRunCreateRequest, NotFoundError, Page, PermissionDeniedError, RateLimitError, type RecordSuggestionEventRequest, type ResumeRunRequest, type RunAdmission, RunCancelledError, type RunEvent, type RunEventBase, type RunEventsPollResponse, type RunStatus, type RunTimeframe, Scope, ScopeConversationsResource, ScopesResource, type SkillContextComposition, type SkillRunCreateRequest, type SqlIngestedDataRequest, StreamTimeoutError, type StreamTimeoutEvent, type SuggestionEventSource, type SuggestionEventType, type SuggestionQuestion, SuggestionsResource, type TokenEvent, UnprocessableError, type UploadIngestedDataOptions, ValidationError, VariationView, Workflow, type WorkflowActionRequest, WorkflowRunsResource, WorkflowType, WorkflowsResource, components };