@getmodus/sdk 0.8.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/CHANGELOG.md +189 -0
- package/README.md +182 -14
- package/dist/{conversations-COA6NW8I.d.cts → _client-base-H5rt5EGy.d.cts} +3789 -972
- package/dist/{conversations-COA6NW8I.d.ts → _client-base-H5rt5EGy.d.ts} +3789 -972
- package/dist/{chunk-GFS7CNON.js → chunk-BMYCORZF.js} +656 -325
- package/dist/chunk-BMYCORZF.js.map +1 -0
- package/dist/chunk-NA3ZD35T.cjs +2666 -0
- package/dist/chunk-NA3ZD35T.cjs.map +1 -0
- package/dist/index.cjs +722 -2870
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +743 -497
- package/dist/index.d.ts +743 -497
- package/dist/index.js +601 -434
- package/dist/index.js.map +1 -1
- package/dist/management/index.cjs +1293 -3126
- package/dist/management/index.cjs.map +1 -1
- package/dist/management/index.d.cts +867 -436
- package/dist/management/index.d.ts +867 -436
- package/dist/management/index.js +1110 -680
- package/dist/management/index.js.map +1 -1
- package/package.json +15 -8
- package/dist/chunk-GFS7CNON.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as Agent, k as AgentType, l as
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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 =
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
readonly
|
|
257
|
+
interface ChatRequest {
|
|
258
|
+
readonly path: string;
|
|
259
|
+
readonly body: Record<string, unknown>;
|
|
179
260
|
readonly sessionId: string;
|
|
180
|
-
readonly
|
|
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
|
-
*
|
|
189
|
-
*
|
|
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
|
|
277
|
+
declare class ChatSession implements PromiseLike<ChatResult> {
|
|
192
278
|
private readonly http;
|
|
193
|
-
private readonly
|
|
194
|
-
private readonly
|
|
195
|
-
private
|
|
196
|
-
private
|
|
197
|
-
private
|
|
198
|
-
|
|
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
|
-
*
|
|
292
|
+
* The assistant's reply as text chunks, as they arrive. Sub-agent output is
|
|
293
|
+
* left out.
|
|
201
294
|
*
|
|
202
|
-
* @
|
|
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
|
|
297
|
+
* @throws {StreamTimeoutError} When the run times out.
|
|
206
298
|
*/
|
|
207
299
|
textStream(): AsyncGenerator<string>;
|
|
208
300
|
/**
|
|
209
|
-
*
|
|
301
|
+
* Every run event (tokens, approvals, `done`, …) as it arrives.
|
|
210
302
|
*
|
|
211
|
-
* @
|
|
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
|
|
305
|
+
* @throws {StreamTimeoutError} When the run times out.
|
|
215
306
|
*/
|
|
216
307
|
eventStream(): AsyncGenerator<RunEvent>;
|
|
217
|
-
private events;
|
|
218
308
|
/**
|
|
219
|
-
*
|
|
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
|
-
*
|
|
222
|
-
*
|
|
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
|
-
* @
|
|
225
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
233
|
-
type
|
|
234
|
-
|
|
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 -
|
|
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 -
|
|
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 -
|
|
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
|
|
521
|
+
* Resume a run paused at an approval or connect interrupt, and stream the continuation's events.
|
|
389
522
|
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
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
|
-
*
|
|
558
|
+
* Poll a run's buffered events once (the JSON transport, not SSE).
|
|
423
559
|
*
|
|
424
560
|
* @param runId - Run id.
|
|
425
|
-
* @returns
|
|
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<
|
|
564
|
+
events(runId: string): Promise<RunEventsPollResponse>;
|
|
428
565
|
/**
|
|
429
|
-
*
|
|
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
|
|
591
|
+
interrupt(runId: string, nextRun: FollowUpRunRequest, options?: {
|
|
592
|
+
lastSeenEventId?: string;
|
|
593
|
+
}): Promise<RunAdmission>;
|
|
434
594
|
/**
|
|
435
|
-
*
|
|
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<
|
|
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 {
|
|
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
|
|
633
|
+
* Reconnect to a run and stream its events.
|
|
462
634
|
*
|
|
463
635
|
* @param runId - Run id to follow.
|
|
464
|
-
* @param options.lastEventId -
|
|
465
|
-
*
|
|
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
|
-
*
|
|
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
|
*/
|
|
@@ -480,9 +654,15 @@ declare class WorkflowRunsResource {
|
|
|
480
654
|
}
|
|
481
655
|
|
|
482
656
|
type Connection = components['schemas']['ConnectionDto'];
|
|
657
|
+
type ConnectionSelection = components['schemas']['ConnectionSelectionDto'];
|
|
483
658
|
|
|
484
|
-
/** One
|
|
485
|
-
type ContextValueRow =
|
|
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
|
+
};
|
|
486
666
|
|
|
487
667
|
type SkillContextComposition = components['schemas']['ComposeSkillContextResponseDto'];
|
|
488
668
|
type ModusContextComposition = components['schemas']['ModusContextResponseDto'];
|
|
@@ -509,142 +689,408 @@ interface UploadIngestedDataOptions {
|
|
|
509
689
|
/** Location and identity of a newly stored ingested-data envelope. */
|
|
510
690
|
type IngestedDataUploadResult = components['schemas']['CreatedIngestedDataResponseDto'];
|
|
511
691
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
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 {
|
|
697
|
+
protected readonly http: HttpClient;
|
|
698
|
+
protected readonly config: ModusConfig;
|
|
515
699
|
/** @internal */
|
|
516
700
|
constructor(http: HttpClient, config: ModusConfig);
|
|
517
701
|
/**
|
|
518
|
-
*
|
|
702
|
+
* List scopes.
|
|
519
703
|
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
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`.
|
|
706
|
+
*
|
|
707
|
+
* **Requires:** `scopes:read`
|
|
708
|
+
*
|
|
709
|
+
* @param options.pageSize - Items per page. Defaults to 25.
|
|
710
|
+
* @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
|
|
711
|
+
* for the first page.
|
|
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.
|
|
718
|
+
*
|
|
719
|
+
* @example
|
|
720
|
+
* ```ts
|
|
721
|
+
* for await (const scope of (await client.scopes.list()).autoPagingIter()) {
|
|
722
|
+
* console.log(scope.id, scope.name, scope.status)
|
|
723
|
+
* }
|
|
724
|
+
* ```
|
|
523
725
|
*/
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
726
|
+
list(options?: {
|
|
727
|
+
pageSize?: number;
|
|
728
|
+
pageToken?: string;
|
|
729
|
+
search?: string;
|
|
730
|
+
view?: VariationView;
|
|
731
|
+
managerId?: number;
|
|
732
|
+
}): Promise<Page<Scope>>;
|
|
733
|
+
protected listPage(pageSize: number, pageToken: string | undefined, search?: string, view?: VariationView, managerId?: number): Promise<Page<Scope>>;
|
|
527
734
|
/**
|
|
528
|
-
*
|
|
735
|
+
* Get a scope.
|
|
529
736
|
*
|
|
530
|
-
*
|
|
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.
|
|
740
|
+
*
|
|
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
|
+
* ```
|
|
531
753
|
*/
|
|
532
|
-
|
|
533
|
-
|
|
754
|
+
get(scopeId: number | string, options?: {
|
|
755
|
+
view?: VariationView;
|
|
756
|
+
}): Promise<Scope>;
|
|
534
757
|
}
|
|
535
758
|
|
|
536
759
|
/**
|
|
537
|
-
* Read
|
|
760
|
+
* Read / chat with published scopes.
|
|
538
761
|
*
|
|
539
|
-
*
|
|
540
|
-
* -
|
|
541
|
-
* - {@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`.
|
|
542
764
|
*
|
|
543
765
|
* @example
|
|
544
766
|
* ```ts
|
|
545
|
-
*
|
|
546
|
-
* const
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
*
|
|
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)
|
|
550
772
|
* ```
|
|
551
773
|
*/
|
|
552
|
-
declare class
|
|
553
|
-
private readonly http;
|
|
554
|
-
private readonly config;
|
|
555
|
-
readonly runs: WorkflowRunsResource;
|
|
556
|
-
readonly workflowActions: AgentWorkflowActionsResource;
|
|
557
|
-
/** @internal */
|
|
558
|
-
constructor(http: HttpClient, config: ModusConfig);
|
|
774
|
+
declare class ScopesResource extends ScopesResourceBase {
|
|
559
775
|
/**
|
|
560
|
-
*
|
|
776
|
+
* Return the conversations sub-resource scoped to `scopeId`.
|
|
561
777
|
*
|
|
562
|
-
* @param
|
|
563
|
-
* @
|
|
564
|
-
* @param options.search - Case-insensitive substring filter on the workflow name.
|
|
565
|
-
* @param options.type - Workflow kind: `"task"` or `"workflow"`.
|
|
566
|
-
* @param options.view - Which saved version to return (`active` or `draft`).
|
|
567
|
-
* @param options.includeVariation - Include variation metadata when supported.
|
|
568
|
-
* @returns A page of workflows — use `.autoPagingIter()` for all pages.
|
|
778
|
+
* @param scopeId - Numeric scope id.
|
|
779
|
+
* @returns Conversations resource for the scope.
|
|
569
780
|
*
|
|
570
781
|
* @example
|
|
571
782
|
* ```ts
|
|
572
|
-
* for await (const
|
|
573
|
-
*
|
|
783
|
+
* for await (const row of (
|
|
784
|
+
* await client.scopes.conversations(scopeId).list({ pageSize: 10 })
|
|
785
|
+
* ).autoPagingIter()) {
|
|
786
|
+
* console.log(row.threadId, row.firstMessage)
|
|
574
787
|
* }
|
|
575
788
|
* ```
|
|
576
789
|
*/
|
|
577
|
-
|
|
578
|
-
pageSize?: number;
|
|
579
|
-
pageToken?: string;
|
|
580
|
-
search?: string;
|
|
581
|
-
type?: WorkflowType;
|
|
582
|
-
view?: VariationView;
|
|
583
|
-
includeVariation?: boolean;
|
|
584
|
-
}): Promise<Page<Workflow>>;
|
|
585
|
-
private listPage;
|
|
790
|
+
conversations(scopeId: number | string): ScopeConversationsResource;
|
|
586
791
|
/**
|
|
587
|
-
*
|
|
792
|
+
* Compose context this scope would use for an intent, without running chat.
|
|
588
793
|
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
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).
|
|
798
|
+
*
|
|
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.
|
|
594
803
|
*
|
|
595
804
|
* @example
|
|
596
805
|
* ```ts
|
|
597
|
-
* const
|
|
598
|
-
*
|
|
806
|
+
* const ctx = await client.scopes.getContext(scopeId, 'Which tables describe churn?', {
|
|
807
|
+
* limit: 5,
|
|
808
|
+
* })
|
|
809
|
+
* console.log(ctx.originalCount, ctx.sessionId)
|
|
599
810
|
* ```
|
|
600
811
|
*/
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
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;
|
|
605
842
|
}
|
|
606
843
|
|
|
607
|
-
/**
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
private readonly http;
|
|
612
|
-
private readonly config;
|
|
844
|
+
/** Generated base for the consumption `modus.conversations` resource. */
|
|
845
|
+
declare class ModusConversationsResourceBase {
|
|
846
|
+
protected readonly http: HttpClient;
|
|
847
|
+
protected readonly config: ModusConfig;
|
|
613
848
|
/** @internal */
|
|
614
849
|
constructor(http: HttpClient, config: ModusConfig);
|
|
615
850
|
/**
|
|
616
|
-
*
|
|
851
|
+
* Get a Modus conversation.
|
|
617
852
|
*
|
|
618
|
-
*
|
|
619
|
-
* @param options.pageToken - Opaque token from a previous page.
|
|
620
|
-
* @param options.type - Integration category; exact match filter.
|
|
621
|
-
* @returns A page of connections.
|
|
622
|
-
*/
|
|
623
|
-
list(options?: {
|
|
624
|
-
pageSize?: number;
|
|
625
|
-
pageToken?: string;
|
|
626
|
-
type?: string;
|
|
627
|
-
}): Promise<Page<Connection>>;
|
|
628
|
-
private listPage;
|
|
629
|
-
/**
|
|
630
|
-
* Find the first connection whose name matches (case-insensitive).
|
|
853
|
+
* Returns the full message history for a conversation thread.
|
|
631
854
|
*
|
|
632
|
-
*
|
|
855
|
+
* **Requires:** `scopes:read`
|
|
633
856
|
*
|
|
634
|
-
* @param
|
|
635
|
-
* @param options.type - Optional integration category filter.
|
|
636
|
-
* @param options.pageSize - Page size when scanning (default 25).
|
|
637
|
-
* @returns The matching connection, or `undefined` if none is found.
|
|
857
|
+
* @param threadId - Thread id from a conversation list or chat response.
|
|
638
858
|
*/
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
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?: {
|
|
642
882
|
pageSize?: number;
|
|
643
|
-
|
|
883
|
+
pageToken?: string;
|
|
884
|
+
kind?: ConversationKind;
|
|
885
|
+
source?: string;
|
|
886
|
+
sourceRef?: string;
|
|
887
|
+
}): Promise<Page<ConversationListItem>>;
|
|
888
|
+
private listPage;
|
|
644
889
|
}
|
|
645
890
|
|
|
646
|
-
|
|
647
|
-
|
|
891
|
+
/**
|
|
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
|
+
* ```
|
|
910
|
+
*/
|
|
911
|
+
declare class ModusResource {
|
|
912
|
+
private readonly http;
|
|
913
|
+
private readonly config;
|
|
914
|
+
readonly conversations: ModusConversationsResource;
|
|
915
|
+
constructor(http: HttpClient, config: ModusConfig);
|
|
916
|
+
/**
|
|
917
|
+
* Compose full-environment context for an intent without running chat.
|
|
918
|
+
*
|
|
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).
|
|
921
|
+
*
|
|
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
|
+
* ```
|
|
931
|
+
*/
|
|
932
|
+
getContext(message: string, options?: {
|
|
933
|
+
limit?: number;
|
|
934
|
+
}): Promise<ModusContextComposition>;
|
|
935
|
+
/**
|
|
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`.
|
|
945
|
+
*
|
|
946
|
+
* @example
|
|
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
|
+
* ```
|
|
958
|
+
*/
|
|
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);
|
|
968
|
+
/**
|
|
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.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* ```ts
|
|
990
|
+
* for await (const wf of (await client.workflows.list({ search: 'digest' })).autoPagingIter()) {
|
|
991
|
+
* console.log(wf.id, wf.name, wf.status)
|
|
992
|
+
* }
|
|
993
|
+
* ```
|
|
994
|
+
*/
|
|
995
|
+
list(options?: {
|
|
996
|
+
pageSize?: number;
|
|
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>>;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
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
|
+
}
|
|
648
1094
|
|
|
649
1095
|
/**
|
|
650
1096
|
* Read the org knowledge base (notes, metrics, saved queries, integration items).
|
|
@@ -750,7 +1196,7 @@ declare class ContextItemsResource {
|
|
|
750
1196
|
* contextType: 'note',
|
|
751
1197
|
* dataPath: ['finance', 'arr-definition'],
|
|
752
1198
|
* })
|
|
753
|
-
* if (found) console.log(found.uid, found.
|
|
1199
|
+
* if (found) console.log(found.uid, found.content)
|
|
754
1200
|
* ```
|
|
755
1201
|
*/
|
|
756
1202
|
lookup(options: {
|
|
@@ -759,14 +1205,19 @@ declare class ContextItemsResource {
|
|
|
759
1205
|
contentProjection?: JsonObjectInput | ContentProjection;
|
|
760
1206
|
}): Promise<ContextItemLookupRow | undefined>;
|
|
761
1207
|
/**
|
|
762
|
-
*
|
|
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`.
|
|
763
1214
|
*
|
|
764
1215
|
* @param uid - Item uid.
|
|
765
1216
|
* @param contextType - Context type of the item.
|
|
766
|
-
* @param contentKeyPath - Dot path to the
|
|
767
|
-
* @param options.pageSize - Maximum
|
|
768
|
-
* @param options.pageToken - Opaque token from a previous page.
|
|
769
|
-
* @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.
|
|
770
1221
|
*
|
|
771
1222
|
* @example
|
|
772
1223
|
* ```ts
|
|
@@ -777,7 +1228,7 @@ declare class ContextItemsResource {
|
|
|
777
1228
|
* 'enumValues',
|
|
778
1229
|
* { pageSize: 25 },
|
|
779
1230
|
* )
|
|
780
|
-
* for (const row of page.items) console.log(row)
|
|
1231
|
+
* for (const row of page.items) console.log(row.index, row.value)
|
|
781
1232
|
* ```
|
|
782
1233
|
*/
|
|
783
1234
|
listValues(uid: string, contextType: string, contentKeyPath: string, options?: {
|
|
@@ -785,13 +1236,13 @@ declare class ContextItemsResource {
|
|
|
785
1236
|
pageToken?: string;
|
|
786
1237
|
}): Promise<Page<ContextValueRow>>;
|
|
787
1238
|
/**
|
|
788
|
-
*
|
|
1239
|
+
* Page through an array field of a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.
|
|
789
1240
|
*
|
|
790
1241
|
* @param item - Context item (uses `item.uid` and `item.contextType`).
|
|
791
|
-
* @param contentKeyPath - Dot path to the
|
|
792
|
-
* @param options.pageSize - Maximum
|
|
793
|
-
* @param options.pageToken - Opaque token from a previous page.
|
|
794
|
-
* @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.
|
|
795
1246
|
*
|
|
796
1247
|
* @example
|
|
797
1248
|
* ```ts
|
|
@@ -823,321 +1274,84 @@ declare class ContextResource {
|
|
|
823
1274
|
constructor(http: HttpClient, config: ModusConfig);
|
|
824
1275
|
}
|
|
825
1276
|
|
|
826
|
-
/**
|
|
827
|
-
declare class
|
|
828
|
-
|
|
829
|
-
|
|
1277
|
+
/** Generated base for the consumption `connections` resource. */
|
|
1278
|
+
declare class ConnectionsResourceBase {
|
|
1279
|
+
protected readonly http: HttpClient;
|
|
1280
|
+
protected readonly config: ModusConfig;
|
|
830
1281
|
/** @internal */
|
|
831
1282
|
constructor(http: HttpClient, config: ModusConfig);
|
|
832
1283
|
/**
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
* Identity covers the complete organization, integration, request, and response
|
|
836
|
-
* content. A duplicate raises `ConflictError`, which means the identical payload
|
|
837
|
-
* is already stored and may be treated as a safe retry outcome.
|
|
1284
|
+
* List connections.
|
|
838
1285
|
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
*
|
|
842
|
-
* @returns The checksum of the stored envelope.
|
|
843
|
-
* @throws {ConflictError} When the complete payload is already stored.
|
|
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`.
|
|
844
1289
|
*
|
|
845
|
-
*
|
|
846
|
-
* ```ts
|
|
847
|
-
* const stored = await client.ingestedData.upload({
|
|
848
|
-
* integrationType: 'generic',
|
|
849
|
-
* request: { type: 'sql', query: 'SELECT id, total FROM orders' },
|
|
850
|
-
* response: { format: 'csv', content: 'id,total\n1,42.00\n' },
|
|
851
|
-
* })
|
|
852
|
-
* console.log(stored.checksum)
|
|
853
|
-
* ```
|
|
854
|
-
*/
|
|
855
|
-
upload(options: UploadIngestedDataOptions): Promise<IngestedDataUploadResult>;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
/** List and retrieve Modus / scope conversations. */
|
|
859
|
-
declare class ModusConversationsResource {
|
|
860
|
-
private readonly http;
|
|
861
|
-
private readonly config;
|
|
862
|
-
constructor(http: HttpClient, config: ModusConfig);
|
|
863
|
-
/**
|
|
864
|
-
* List conversations.
|
|
1290
|
+
* **Requires:** `context:read`
|
|
865
1291
|
*
|
|
866
|
-
* @param options.pageSize - Items per page
|
|
867
|
-
* @param options.pageToken - Opaque token from a previous
|
|
868
|
-
*
|
|
869
|
-
* @param options.
|
|
870
|
-
*
|
|
871
|
-
* omitted `kind` or `kind: "all"`; the API throws an `UnprocessableError` (422)
|
|
872
|
-
* if combined with `kind: "modus"` or `kind: "scopes"`.
|
|
873
|
-
* @param options.sourceRef - Narrow `source` to one instance of that surface — for
|
|
874
|
-
* `"dashboard_copilot"`, a dashboard id. Requires `source`; the API throws an
|
|
875
|
-
* `UnprocessableError` (422) if sent on its own. Conversations recorded before
|
|
876
|
-
* this filter shipped carry no instance key and never match it.
|
|
877
|
-
* @returns Page of conversation list items.
|
|
1292
|
+
* @param options.pageSize - Items per page. Defaults to 25.
|
|
1293
|
+
* @param options.pageToken - Opaque page token from a previous response's `nextPageToken`. Omit
|
|
1294
|
+
* for the first page.
|
|
1295
|
+
* @param options.type - Filter by effective integration category (case-sensitive exact match).
|
|
1296
|
+
* @returns A page of connections.
|
|
878
1297
|
*/
|
|
879
1298
|
list(options?: {
|
|
880
1299
|
pageSize?: number;
|
|
881
1300
|
pageToken?: string;
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
}): Promise<Page<ConversationListItem>>;
|
|
886
|
-
private listPage;
|
|
887
|
-
/**
|
|
888
|
-
* Retrieve a conversation thread with full message history.
|
|
889
|
-
*
|
|
890
|
-
* @param threadId - Conversation thread id.
|
|
891
|
-
* @returns Conversation with messages.
|
|
892
|
-
*/
|
|
893
|
-
get(threadId: string): Promise<Conversation>;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
/**
|
|
897
|
-
* Org-wide Modus assistant (full environment context and tools).
|
|
898
|
-
*
|
|
899
|
-
* Prefer `client.modus` over `client.scopes` when the question is not tied to one
|
|
900
|
-
* published scope. Construct with `new Modus()` (reads `MODUS_API_KEY`).
|
|
901
|
-
*
|
|
902
|
-
* - `chat` — one complete reply
|
|
903
|
-
* - `chatStream` — print tokens as they arrive (consume `textStream()`)
|
|
904
|
-
* - `getContext` — preview composed context without a chat turn
|
|
905
|
-
* - `conversations` — list/get prior Modus threads
|
|
906
|
-
*
|
|
907
|
-
* @example
|
|
908
|
-
* ```ts
|
|
909
|
-
* import { Modus } from '@getmodus/sdk'
|
|
910
|
-
* const client = new Modus()
|
|
911
|
-
* const result = await client.modus.chat('What tables describe revenue?', {
|
|
912
|
-
* model: 'claude-sonnet-5',
|
|
913
|
-
* })
|
|
914
|
-
* console.log(result.content, result.threadId)
|
|
915
|
-
* ```
|
|
916
|
-
*/
|
|
917
|
-
declare class ModusResource {
|
|
918
|
-
private readonly http;
|
|
919
|
-
private readonly config;
|
|
920
|
-
readonly conversations: ModusConversationsResource;
|
|
921
|
-
constructor(http: HttpClient, config: ModusConfig);
|
|
922
|
-
/**
|
|
923
|
-
* Compose full-environment context for an intent without running chat.
|
|
924
|
-
*
|
|
925
|
-
* @param message - Natural-language intent used to select context.
|
|
926
|
-
* @param options.limit - Maximum context items to return. Omit to return all selected items.
|
|
927
|
-
* @returns Composition metadata (counts / session id). Use `chat` for a reply.
|
|
928
|
-
*
|
|
929
|
-
* @example
|
|
930
|
-
* ```ts
|
|
931
|
-
* const ctx = await client.modus.getContext('What tables describe revenue?', { limit: 5 })
|
|
932
|
-
* console.log(ctx.originalCount, ctx.sessionId)
|
|
933
|
-
* ```
|
|
934
|
-
*/
|
|
935
|
-
getContext(message: string, options?: {
|
|
936
|
-
limit?: number;
|
|
937
|
-
}): Promise<ModusContextComposition>;
|
|
938
|
-
/**
|
|
939
|
-
* Send a message to Modus and wait for the complete reply.
|
|
940
|
-
*
|
|
941
|
-
* @param message - User message text.
|
|
942
|
-
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
943
|
-
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
944
|
-
* @returns Chat result: `content`, `threadId` (for follow-ups), `runId`.
|
|
945
|
-
*
|
|
946
|
-
* @example
|
|
947
|
-
* ```ts
|
|
948
|
-
* const result = await client.modus.chat('What tables describe revenue?', {
|
|
949
|
-
* model: 'claude-sonnet-5',
|
|
950
|
-
* })
|
|
951
|
-
* console.log(result.content, result.threadId)
|
|
952
|
-
* const follow = await client.modus.chat('Break that down by region.', {
|
|
953
|
-
* model: 'claude-sonnet-5',
|
|
954
|
-
* threadId: result.threadId,
|
|
955
|
-
* })
|
|
956
|
-
* ```
|
|
957
|
-
*/
|
|
958
|
-
chat(message: string, options: {
|
|
959
|
-
model: ChatModel;
|
|
960
|
-
threadId?: string;
|
|
961
|
-
}): Promise<ChatResult>;
|
|
962
|
-
/**
|
|
963
|
-
* Stream a Modus reply token by token (SSE).
|
|
964
|
-
*
|
|
965
|
-
* The request starts when you consume `textStream()` or `eventStream()`.
|
|
966
|
-
*
|
|
967
|
-
* @param message - User message text.
|
|
968
|
-
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
969
|
-
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
970
|
-
* @returns Chat stream — iterate `textStream()` for tokens.
|
|
971
|
-
*
|
|
972
|
-
* @example
|
|
973
|
-
* ```ts
|
|
974
|
-
* const stream = client.modus.chatStream('Summarize ARR in three bullets.', {
|
|
975
|
-
* model: 'claude-sonnet-5',
|
|
976
|
-
* })
|
|
977
|
-
* for await (const token of stream.textStream()) {
|
|
978
|
-
* process.stdout.write(token)
|
|
979
|
-
* }
|
|
980
|
-
* console.log(stream.getFinalResult().threadId)
|
|
981
|
-
* ```
|
|
982
|
-
*/
|
|
983
|
-
chatStream(message: string, options: {
|
|
984
|
-
model: ChatModel;
|
|
985
|
-
threadId?: string;
|
|
986
|
-
}): ChatStream;
|
|
1301
|
+
type?: string;
|
|
1302
|
+
}): Promise<Page<Connection>>;
|
|
1303
|
+
protected listPage(pageSize: number, pageToken: string | undefined, type?: string): Promise<Page<Connection>>;
|
|
987
1304
|
}
|
|
988
1305
|
|
|
989
1306
|
/**
|
|
990
|
-
* Read
|
|
991
|
-
*
|
|
992
|
-
* Call path: `client.scopes` after `new Modus(...)`. Prefer `client.modus` for
|
|
993
|
-
* the org-wide assistant. Create/deploy via `ModusManagement`.
|
|
994
|
-
*
|
|
995
|
-
* @example
|
|
996
|
-
* ```ts
|
|
997
|
-
* const scope = await client.scopes.get('revenue-analysis')
|
|
998
|
-
* const result = await client.scopes.chat(scope.id, 'What is our ARR trend?', {
|
|
999
|
-
* model: 'claude-sonnet-5',
|
|
1000
|
-
* })
|
|
1001
|
-
* console.log(result.content, result.threadId)
|
|
1002
|
-
* ```
|
|
1307
|
+
* Read access to integration connections.
|
|
1003
1308
|
*/
|
|
1004
|
-
declare class
|
|
1005
|
-
private readonly http;
|
|
1006
|
-
private readonly config;
|
|
1007
|
-
/** @internal */
|
|
1008
|
-
constructor(http: HttpClient, config: ModusConfig);
|
|
1309
|
+
declare class ConnectionsResource extends ConnectionsResourceBase {
|
|
1009
1310
|
/**
|
|
1010
|
-
*
|
|
1311
|
+
* Find the first connection whose name matches (case-insensitive).
|
|
1011
1312
|
*
|
|
1012
|
-
* @
|
|
1013
|
-
* @returns Conversations resource for the scope.
|
|
1313
|
+
* Pages through {@link ConnectionsResource.list} until a match is found.
|
|
1014
1314
|
*
|
|
1015
|
-
* @
|
|
1016
|
-
*
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
* ).autoPagingIter()) {
|
|
1020
|
-
* console.log(row.threadId, row.firstMessage)
|
|
1021
|
-
* }
|
|
1022
|
-
* ```
|
|
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.
|
|
1023
1319
|
*/
|
|
1024
|
-
|
|
1320
|
+
find(options: {
|
|
1321
|
+
name: string;
|
|
1322
|
+
type?: string;
|
|
1323
|
+
pageSize?: number;
|
|
1324
|
+
}): Promise<Connection | undefined>;
|
|
1025
1325
|
/**
|
|
1026
|
-
* List
|
|
1326
|
+
* List the selectable units on a connection (a repository, a schema, a project).
|
|
1027
1327
|
*
|
|
1028
|
-
* @param
|
|
1328
|
+
* @param connectionId - Connection id.
|
|
1329
|
+
* @param options.pageSize - Maximum items per page (default 25).
|
|
1029
1330
|
* @param options.pageToken - Opaque token from a previous page.
|
|
1030
|
-
* @
|
|
1031
|
-
* @param options.view - `"active"` (deployed) or `"draft"`.
|
|
1032
|
-
* @param options.managerId - Only scopes supervised by this manager scope id.
|
|
1033
|
-
* @returns Page of scopes — use `.autoPagingIter()` for all pages.
|
|
1034
|
-
*
|
|
1331
|
+
* @returns A page of selectable units — use {@link iterSelections} or `.autoPagingIter()` for every page.
|
|
1035
1332
|
* @example
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
* console.log(scope.id, scope.name, scope.status)
|
|
1333
|
+
* for await (const unit of client.connections.iterSelections('7a3f9d2c-1111-4000-a000-000000000abc')) {
|
|
1334
|
+
* console.log(unit.objectType, unit.path)
|
|
1039
1335
|
* }
|
|
1040
|
-
* ```
|
|
1041
1336
|
*/
|
|
1042
|
-
|
|
1337
|
+
listSelections(connectionId: string, options?: {
|
|
1043
1338
|
pageSize?: number;
|
|
1044
1339
|
pageToken?: string;
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
managerId?: number;
|
|
1048
|
-
}): Promise<Page<Scope>>;
|
|
1049
|
-
private listPage;
|
|
1050
|
-
/**
|
|
1051
|
-
* Retrieve a scope by ID or slug.
|
|
1052
|
-
*
|
|
1053
|
-
* @param scopeId - Scope numeric id or slug.
|
|
1054
|
-
* @param options.view - `"active"` (deployed) or `"draft"`.
|
|
1055
|
-
* @throws {NotFoundError} When no scope matches the id or slug.
|
|
1056
|
-
* @returns Scope (`id`, `name`, `status`, …).
|
|
1057
|
-
*
|
|
1058
|
-
* @example
|
|
1059
|
-
* ```ts
|
|
1060
|
-
* const scope = await client.scopes.get('revenue-analysis')
|
|
1061
|
-
* console.log(scope.name, scope.status)
|
|
1062
|
-
* ```
|
|
1063
|
-
*/
|
|
1064
|
-
get(scopeId: number | string, options?: {
|
|
1065
|
-
view?: VariationView;
|
|
1066
|
-
}): Promise<Scope>;
|
|
1067
|
-
/**
|
|
1068
|
-
* Compose context this scope would use for an intent, without running chat.
|
|
1069
|
-
*
|
|
1070
|
-
* @param scopeId - Scope numeric id or slug.
|
|
1071
|
-
* @param message - Natural-language intent used to select context.
|
|
1072
|
-
* @param options.limit - Maximum context items to return. Omit to return all selected items.
|
|
1073
|
-
* @returns Composition metadata. Use `chat` when you need an assistant reply.
|
|
1074
|
-
*
|
|
1075
|
-
* @example
|
|
1076
|
-
* ```ts
|
|
1077
|
-
* const ctx = await client.scopes.getContext(scopeId, 'Which tables describe churn?', {
|
|
1078
|
-
* limit: 5,
|
|
1079
|
-
* })
|
|
1080
|
-
* console.log(ctx.originalCount, ctx.sessionId)
|
|
1081
|
-
* ```
|
|
1082
|
-
*/
|
|
1083
|
-
getContext(scopeId: number | string, message: string, options?: {
|
|
1084
|
-
limit?: number;
|
|
1085
|
-
}): Promise<SkillContextComposition>;
|
|
1340
|
+
}): Promise<Page<ConnectionSelection>>;
|
|
1341
|
+
private listSelectionsPage;
|
|
1086
1342
|
/**
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
1089
|
-
* For the org-wide assistant use `client.modus.chat` instead.
|
|
1090
|
-
*
|
|
1091
|
-
* @param scopeId - Scope numeric id or slug (must be active for chat).
|
|
1092
|
-
* @param message - User message text.
|
|
1093
|
-
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1094
|
-
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1095
|
-
* @returns Chat result: `content`, `threadId`, `runId`.
|
|
1096
|
-
*
|
|
1097
|
-
* @example
|
|
1098
|
-
* ```ts
|
|
1099
|
-
* const result = await client.scopes.chat(scopeId, 'What is our ARR trend?', {
|
|
1100
|
-
* model: 'claude-sonnet-5',
|
|
1101
|
-
* })
|
|
1102
|
-
* console.log(result.content, result.threadId)
|
|
1103
|
-
* const follow = await client.scopes.chat(scopeId, 'Break that down by segment.', {
|
|
1104
|
-
* model: 'claude-sonnet-5',
|
|
1105
|
-
* threadId: result.threadId,
|
|
1106
|
-
* })
|
|
1107
|
-
* ```
|
|
1108
|
-
*/
|
|
1109
|
-
chat(scopeId: number | string, message: string, options: {
|
|
1110
|
-
model: ChatModel;
|
|
1111
|
-
threadId?: string;
|
|
1112
|
-
}): Promise<ChatResult>;
|
|
1113
|
-
/**
|
|
1114
|
-
* Stream a scope reply token by token (SSE).
|
|
1115
|
-
*
|
|
1116
|
-
* The request starts when you consume `textStream()` or `eventStream()`.
|
|
1117
|
-
*
|
|
1118
|
-
* @param scopeId - Scope numeric id or slug.
|
|
1119
|
-
* @param message - User message text.
|
|
1120
|
-
* @param options.model - Required model id (e.g. `"claude-sonnet-5"`).
|
|
1121
|
-
* @param options.threadId - Continue an existing conversation; omit to start new.
|
|
1122
|
-
* @param options.version - `"published"` or `"draft"`.
|
|
1123
|
-
* @returns Chat stream — iterate `textStream()` for tokens.
|
|
1343
|
+
* Yield every selectable unit on a connection, following pages.
|
|
1124
1344
|
*
|
|
1345
|
+
* @param connectionId - Connection id.
|
|
1346
|
+
* @param options.pageSize - Maximum items per page (default 25).
|
|
1125
1347
|
* @example
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1128
|
-
* model: 'claude-sonnet-5',
|
|
1129
|
-
* })
|
|
1130
|
-
* for await (const token of stream.textStream()) {
|
|
1131
|
-
* 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)
|
|
1132
1350
|
* }
|
|
1133
|
-
* console.log(stream.getFinalResult().threadId)
|
|
1134
|
-
* ```
|
|
1135
1351
|
*/
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
version?: string;
|
|
1140
|
-
}): ChatStream;
|
|
1352
|
+
iterSelections(connectionId: string, options?: {
|
|
1353
|
+
pageSize?: number;
|
|
1354
|
+
}): AsyncGenerator<ConnectionSelection>;
|
|
1141
1355
|
}
|
|
1142
1356
|
|
|
1143
1357
|
/**
|
|
@@ -1154,7 +1368,7 @@ declare class SuggestionsResource {
|
|
|
1154
1368
|
* @param options.pageSize - Maximum items per page (default 5, max 12).
|
|
1155
1369
|
* @param options.pageToken - Opaque token from a previous page.
|
|
1156
1370
|
* @param options.scopeId - Filter to a single scope.
|
|
1157
|
-
* @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.
|
|
1158
1372
|
* @returns A page of suggested questions.
|
|
1159
1373
|
*/
|
|
1160
1374
|
list(options?: {
|
|
@@ -1173,6 +1387,38 @@ declare class SuggestionsResource {
|
|
|
1173
1387
|
recordEvent(id: string, event: RecordSuggestionEventRequest): Promise<void>;
|
|
1174
1388
|
}
|
|
1175
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
|
+
|
|
1176
1422
|
/**
|
|
1177
1423
|
* Read / invoke client for Modus scopes, workflows, connections, and more.
|
|
1178
1424
|
*
|
|
@@ -1191,4 +1437,4 @@ declare class Modus extends ModusClientBase {
|
|
|
1191
1437
|
constructor(options?: ModusOptions);
|
|
1192
1438
|
}
|
|
1193
1439
|
|
|
1194
|
-
export { APIConnectionError, type AgentRun, type AgentRunCreateRequest, type AgentRunListItem, type AgentRunStream, type ApprovalScope, type AssistantContentResetEvent, AuthenticationError, type CancelRunRequest, type CancelledEvent, type ChatModel, type
|
|
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 };
|