@getmodus/sdk 0.7.0 → 0.8.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.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/_agent_run_request.ts","../src/_streaming.ts","../src/_chat.ts","../src/types/workflows.ts","../src/types/conversations.ts","../src/resources/workflows/runs.ts","../src/resources/workflows/workflow-actions.ts","../src/resources/workflows.ts","../src/resources/connections.ts","../src/resources/context/items.ts","../src/resources/context/context.ts","../src/resources/ingested-data.ts","../src/resources/modus/conversations.ts","../src/resources/modus/modus.ts","../src/resources/scopes.ts","../src/resources/suggestions.ts","../src/index.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto'\n\n/** Mint or reuse a non-empty sessionId for agent-host runs. */\nexport function resolveAgentRunSessionId(sessionId?: string | null): string {\n if (typeof sessionId === 'string' && sessionId.trim()) return sessionId.trim()\n return randomUUID()\n}\n","import type {\n AssistantContentResetEvent,\n CancelledEvent,\n DoneEvent,\n ErrorEvent,\n RunEvent,\n StreamTimeoutEvent,\n TokenEvent,\n} from './types/runs.js'\n\nconst SILENTLY_IGNORED = new Set([\n 'heartbeat',\n 'ws_chunk',\n 'unknown',\n 'tool_start',\n 'tool_end',\n 'tool_chunk',\n 'agent_thinking',\n 'warning',\n 'selected_final_content',\n])\n\nfunction parseLine(line: string): Record<string, unknown> | undefined {\n if (!line.startsWith('data:')) return undefined\n const raw = line.slice(5).trimStart()\n if (!raw || raw === '[DONE]') return undefined\n try {\n const data = JSON.parse(raw) as unknown\n if (data && typeof data === 'object' && !Array.isArray(data)) {\n return data as Record<string, unknown>\n }\n } catch {\n return undefined\n }\n return undefined\n}\n\nfunction isAsyncIterable<T>(value: Iterable<T> | AsyncIterable<T>): value is AsyncIterable<T> {\n return Symbol.asyncIterator in Object(value)\n}\n\nfunction* parseData(data: Record<string, unknown>): Generator<RunEvent> {\n const eventType = typeof data.type === 'string' ? data.type : 'unknown'\n\n if (eventType === 'token') {\n const event: TokenEvent = {\n type: 'token',\n content: typeof data.content === 'string' ? data.content : '',\n }\n yield event\n } else if (eventType === 'done') {\n const event: DoneEvent = {\n type: 'done',\n runId: typeof data.runId === 'string' ? data.runId : '',\n threadId: typeof data.threadId === 'string' ? data.threadId : '',\n }\n yield event\n } else if (eventType === 'error') {\n const msg =\n data.error ?? data.message ?? data.content ?? 'Unknown run error'\n const event: ErrorEvent = { type: 'error', message: String(msg) }\n yield event\n } else if (eventType === 'cancelled') {\n const event: CancelledEvent = { type: 'cancelled' }\n yield event\n } else if (eventType === 'stream_timeout') {\n const event: StreamTimeoutEvent = { type: 'stream_timeout' }\n yield event\n } else if (eventType === 'assistant_content_reset') {\n if (typeof data.content !== 'string') return\n const event: AssistantContentResetEvent = {\n type: 'assistant_content_reset',\n content: data.content,\n ...(typeof data.visibleContent === 'string'\n ? { visibleContent: data.visibleContent }\n : {}),\n attempt: typeof data.attempt === 'number' ? data.attempt : 1,\n reason: 'provider_stream_failed',\n }\n yield event\n } else if (!SILENTLY_IGNORED.has(eventType)) {\n // Unknown future event types ignored for forward compatibility.\n return\n }\n}\n\nfunction* parseSyncSseLines(lines: Iterable<string>): Generator<RunEvent> {\n for (const line of lines) {\n const data = parseLine(line)\n if (data !== undefined) yield* parseData(data)\n }\n}\n\nasync function* parseAsyncSseLines(lines: AsyncIterable<string>): AsyncGenerator<RunEvent> {\n for await (const line of lines) {\n const data = parseLine(line)\n if (data !== undefined) yield* parseData(data)\n }\n}\n\n/** Convert raw SSE lines into typed run events (forward-compatible). */\nexport function parseSseStream(lines: Iterable<string>): Generator<RunEvent>\nexport function parseSseStream(lines: AsyncIterable<string>): AsyncGenerator<RunEvent>\nexport function parseSseStream(\n lines: Iterable<string> | AsyncIterable<string>,\n): Generator<RunEvent> | AsyncGenerator<RunEvent> {\n return isAsyncIterable(lines) ? parseAsyncSseLines(lines) : parseSyncSseLines(lines)\n}\n","import {\n ModusError,\n RunCancelledError,\n StreamTimeoutError,\n} from './_exceptions.js'\nimport type { ModusConfig } from './_config.js'\nimport { resolveAgentRunSessionId } from './_agent_run_request.js'\nimport type { HttpClient } from './_http.js'\nimport { parseSseStream } from './_streaming.js'\nimport { validateChatModel, validateId } from './_validation.js'\nimport type { ChatModel, ChatResult } from './types/chat.js'\nimport type { RunEvent } from './types/runs.js'\n\nfunction effectiveThreadId(threadId?: string): string | undefined {\n if (threadId === undefined) return undefined\n if (!threadId.trim()) return undefined\n return threadId\n}\n\nfunction resolveSessionId(threadId?: string): string {\n return resolveAgentRunSessionId(effectiveThreadId(threadId))\n}\n\nfunction chatPath(\n resource: string,\n resourceId: number | string,\n options: { threadId?: string },\n): string {\n const safeId = encodeURIComponent(String(resourceId))\n const tid = effectiveThreadId(options.threadId)\n if (tid !== undefined) {\n const safeTid = encodeURIComponent(tid)\n return `/api/v1/${resource}/${safeId}/conversations/${safeTid}/chat`\n }\n return `/api/v1/${resource}/${safeId}/chat`\n}\n\nfunction modusChatPath(options: { threadId?: string }): string {\n const tid = effectiveThreadId(options.threadId)\n if (tid !== undefined) {\n validateId(tid, 'thread_id')\n return `/api/v1/modus/conversations/${encodeURIComponent(tid)}/chat`\n }\n return `/api/v1/modus/chat`\n}\n\nfunction agentHostRunsPath(\n resource: 'modus' | 'scopes' | 'workflows',\n resourceId?: number | string,\n): string {\n if (resource === 'modus') return '/agent/v1/modus/runs'\n const safeId = encodeURIComponent(String(resourceId))\n return `/agent/v1/${resource}/${safeId}/runs`\n}\n\nfunction chatBody(message: string, model: ChatModel): Record<string, string> {\n return { message, model }\n}\n\nfunction agentRunsBody(\n message: string,\n model: ChatModel,\n options: { sessionId: string; organizationId?: string; version?: string },\n): Record<string, unknown> {\n const body: Record<string, unknown> = {\n message,\n config: { model },\n sessionId: options.sessionId,\n }\n if (options.organizationId !== undefined) {\n body.organizationId = options.organizationId\n }\n if (options.version !== undefined) {\n body.version = options.version\n }\n return body\n}\n\nfunction raiseForEvent(event: RunEvent): RunEvent {\n if (event.type === 'error') throw new ModusError(event.message)\n if (event.type === 'cancelled') throw new RunCancelledError()\n if (event.type === 'stream_timeout') throw new StreamTimeoutError()\n return event\n}\n\n/**\n * Streaming chat session. Iterate {@link ChatStream.textStream} or\n * {@link ChatStream.eventStream}, then call {@link ChatStream.getFinalResult}.\n */\nexport class ChatStream {\n private final?: ChatResult\n private readonly textParts: string[] = []\n\n constructor(\n private readonly http: HttpClient,\n private readonly path: string,\n private readonly body: Record<string, unknown>,\n private readonly baseUrl?: string,\n ) {}\n\n /**\n * Async iterable of assistant text token chunks as they arrive.\n *\n * @returns An async generator yielding partial text strings.\n * @throws {ModusError} When the stream emits an error event.\n * @throws {RunCancelledError} When the run is cancelled.\n * @throws {StreamTimeoutError} When the stream times out.\n */\n async *textStream(): AsyncGenerator<string> {\n for await (const event of this.events(false)) {\n if (event.type === 'token') yield event.content\n }\n }\n\n /**\n * Async iterable of structured run events (tokens, tool calls, done, and so on).\n *\n * @returns An async generator yielding {@link RunEvent} objects.\n * @throws {ModusError} When the stream emits an error event.\n * @throws {RunCancelledError} When the run is cancelled.\n * @throws {StreamTimeoutError} When the stream times out.\n */\n async *eventStream(): AsyncGenerator<RunEvent> {\n yield* this.events(true)\n }\n\n private async *events(supportsReset: boolean): AsyncGenerator<RunEvent> {\n const body = supportsReset\n ? { ...this.body, streamProtocolVersion: 2 }\n : this.body\n for await (const line of this.http.streamPost(this.path, body, {\n baseUrl: this.baseUrl,\n })) {\n for (const event of parseSseStream([line])) {\n const normalized = raiseForEvent(event)\n if (normalized.type === 'token') this.textParts.push(normalized.content)\n if (normalized.type === 'assistant_content_reset') {\n this.textParts.length = 0\n this.textParts.push(normalized.content)\n }\n if (normalized.type === 'done') {\n this.final = {\n content: this.textParts.join(''),\n threadId: normalized.threadId,\n runId: normalized.runId,\n }\n yield normalized\n return\n }\n yield normalized\n }\n }\n }\n\n /**\n * Final chat result after the stream completes.\n *\n * Call only after fully consuming {@link ChatStream.textStream} or\n * {@link ChatStream.eventStream}.\n *\n * @returns The assembled assistant reply, thread id, and run id.\n * @throws {ModusError} When called before the stream finishes with a done event.\n */\n getFinalResult(): ChatResult {\n if (this.final === undefined) {\n throw new ModusError(\n 'Stream ended without a done event; call getFinalResult() only after consuming textStream() or eventStream().',\n )\n }\n return this.final\n }\n}\n\nexport async function chatBuffered(\n http: HttpClient,\n resource: string,\n resourceId: number | string,\n message: string,\n options: { model: ChatModel; threadId?: string },\n): Promise<ChatResult> {\n validateId(resourceId, `${resource}_id`)\n validateChatModel(options.model)\n const path = chatPath(resource, resourceId, {\n threadId: options.threadId,\n })\n const data = await http.post(path, chatBody(message, options.model))\n return data as ChatResult\n}\n\nexport function chatStreamSession(\n http: HttpClient,\n config: ModusConfig,\n resource: 'scopes' | 'workflows',\n resourceId: number | string,\n message: string,\n options: { model: ChatModel; threadId?: string; version?: string },\n): ChatStream {\n validateId(resourceId, `${resource}_id`)\n validateChatModel(options.model)\n const path = agentHostRunsPath(resource, resourceId)\n return new ChatStream(\n http,\n path,\n agentRunsBody(message, options.model, {\n sessionId: resolveSessionId(options.threadId),\n organizationId: config.organizationId,\n version: options.version,\n }),\n config.agentHost,\n )\n}\n\nexport async function modusChatBuffered(\n http: HttpClient,\n message: string,\n options: { model: ChatModel; threadId?: string },\n): Promise<ChatResult> {\n validateChatModel(options.model)\n const path = modusChatPath({ threadId: options.threadId })\n const data = await http.post(path, chatBody(message, options.model))\n return data as ChatResult\n}\n\nexport function modusChatStreamSession(\n http: HttpClient,\n config: ModusConfig,\n message: string,\n options: { model: ChatModel; threadId?: string },\n): ChatStream {\n validateChatModel(options.model)\n return new ChatStream(\n http,\n agentHostRunsPath('modus'),\n agentRunsBody(message, options.model, {\n sessionId: resolveSessionId(options.threadId),\n organizationId: config.organizationId,\n }),\n config.agentHost,\n )\n}\n","import type { components } from '../_generated/v1.js'\n\n/** Canonical public type for a Modus workflow (OpenAPI `WorkflowDto`). */\nexport type Workflow = components['schemas']['WorkflowDto']\n\n/** Runtime + type for workflow kinds (use `WorkflowType.task`, not only as a type). */\nexport const WorkflowType = {\n task: 'task',\n workflow: 'workflow',\n} as const\n\nexport type WorkflowType = (typeof WorkflowType)[keyof typeof WorkflowType]\n\n/** @deprecated Use `Workflow` instead. */\nexport type Agent = Workflow\n/** @deprecated Use `WorkflowType` instead. */\nexport type AgentType = WorkflowType\n/** @deprecated Use `WorkflowType` instead. */\nexport const AgentType = WorkflowType\n","import type { components } from '../_generated/v1.js'\n\nexport type Conversation = components['schemas']['ConversationDto']\nexport type ConversationListItem = components['schemas']['ConversationListItemDto']\nexport type Message = components['schemas']['ConversationMessageDto']\nexport type ConversationKind = 'all' | 'modus' | 'scopes'\n\n/** Scope id for a list item, or undefined for direct Modus chats (scopeId 0). */\nexport function conversationScopeId(item: ConversationListItem): number | undefined {\n return item.scopeId === 0 ? undefined : item.scopeId\n}\n\n/**\n * @deprecated Use `conversationScopeId` instead.\n * Preserves the legacy `0` sentinel for direct Modus chats (unlike\n * `conversationScopeId`, which returns `undefined` for id `0`).\n */\nexport function conversationSkillId(item: ConversationListItem): number | undefined {\n return item.scopeId\n}\n","import { randomUUID } from 'node:crypto'\nimport type { ModusConfig } from '../../_config.js'\nimport { resolveAgentRunSessionId } from '../../_agent_run_request.js'\nimport { ModusError } from '../../_exceptions.js'\nimport type { OperationId } from '../../_generated/operations.js'\nimport {\n formatOperationPath,\n getOperation,\n operationBaseUrl,\n} from '../../_openapi-invoke.js'\nimport type { HttpClient } from '../../_http.js'\nimport { Page, normalizePageToken } from '../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { parseSseStream } from '../../_streaming.js'\nimport { validateId, validatePageSize } from '../../_validation.js'\nimport type {\n AgentRun,\n AgentRunListItem,\n AgentRunCreateRequest,\n ApprovalScope,\n CreateAgentRunRequest,\n ModusRunCreateRequest,\n ResumeRunRequest,\n RunStatus,\n RunTimeframe,\n SkillRunCreateRequest,\n} from '../../types/agent-runs.js'\nimport type { ActiveConversationRun, RunEvent } from '../../types/runs.js'\n\nconst RUNS_MAX_PAGE_SIZE = 100\n\nfunction runsListParams(\n pageSize: number,\n pageToken: string | undefined,\n status?: RunStatus,\n timeframe?: RunTimeframe,\n approvalScope?: ApprovalScope,\n search?: string,\n): Record<string, string | number | boolean | undefined | null> {\n const params: Record<string, string | number | boolean | undefined | null> = { pageSize }\n const token = normalizePageToken(pageToken)\n if (token !== undefined) params.pageToken = token\n if (status !== undefined) params.status = status\n if (timeframe !== undefined) params.timeframe = timeframe\n if (approvalScope !== undefined) params.approvalScope = approvalScope\n if (search !== undefined) params.search = search\n return params\n}\n\nfunction activeRunsParams(\n pageSize: number,\n pageToken: string | undefined,\n): Record<string, string | number> {\n const params: Record<string, string | number> = { pageSize }\n const token = normalizePageToken(pageToken)\n if (token !== undefined) params.pageToken = token\n return params\n}\n\nfunction parseRun(raw: unknown): AgentRun {\n return raw as AgentRun\n}\n\nfunction parseActiveRunsArray(raw: unknown): ActiveConversationRun[] {\n const data = asRecord(raw)\n const runs = data.runs\n if (!Array.isArray(runs)) {\n throw new ModusError(\n `Unexpected active runs response shape: runs must be a list, got ${typeof runs}.`,\n )\n }\n return runs as ActiveConversationRun[]\n}\n\nfunction parseActiveRunsPage(\n raw: unknown,\n fetchPage: (token: string) => Promise<Page<ActiveConversationRun>>,\n): Page<ActiveConversationRun> {\n const data = asRecord(raw)\n const runs = data.runs\n if (!Array.isArray(runs)) {\n throw new ModusError(\n `Unexpected active runs response shape: runs must be a list, got ${typeof runs}.`,\n )\n }\n return new Page(\n runs as ActiveConversationRun[],\n normalizePageToken(\n typeof data.nextPageToken === 'string' ? data.nextPageToken : undefined,\n ),\n fetchPage,\n )\n}\n\nfunction randomRunId(): string {\n return randomUUID()\n}\n\nfunction sessionIdFromBody(body: { sessionId?: string }): string {\n return resolveAgentRunSessionId(body.sessionId)\n}\n\nexport interface AgentRunStream extends AsyncIterable<RunEvent> {\n readonly runId: string\n readonly events: AsyncIterable<RunEvent>\n}\n\nexport function makeAgentRunStream(runId: string, events: AsyncIterable<RunEvent>): AgentRunStream {\n return {\n runId,\n events,\n [Symbol.asyncIterator]() {\n return events[Symbol.asyncIterator]()\n },\n }\n}\n\n/**\n * Start, inspect, and control workflow runs.\n *\n * Typical path: `create` (or `createScope` / `createModus`) → stream events →\n * `list` / `get` history → `cancel` or `resume` when needed.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.create(workflowId, {\n * message: \"Summarize yesterday's sales\",\n * config: { model: 'claude-sonnet-5' },\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\nexport class WorkflowRunsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List runs for a workflow.\n *\n * @param workflowId - Workflow id or slug.\n * @param options.pageSize - Maximum items per page (default 25, max 100).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.status - Filter by run status.\n * @param options.timeframe - Filter by recency (`last_hour`, `last_day`, or `last_week`).\n * @param options.approvalScope - Filter approval-related runs (`mine` or `all`).\n * @param options.search - Free-text search filter.\n * @returns A page of run summaries — use `.autoPagingIter()` for all pages.\n *\n * @example\n * ```ts\n * for await (const run of (\n * await client.workflows.runs.list(workflowId, { status: 'completed' })\n * ).autoPagingIter()) {\n * console.log(run.workflowId, run.status, run.startedAt)\n * }\n * ```\n */\n list(\n workflowId: number | string,\n options: {\n pageSize?: number\n pageToken?: string\n status?: RunStatus\n timeframe?: RunTimeframe\n approvalScope?: ApprovalScope\n search?: string\n } = {},\n ): Promise<Page<AgentRunListItem>> {\n validateId(workflowId, 'workflow_id')\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize, RUNS_MAX_PAGE_SIZE)\n return this.listPage(workflowId, pageSize, options.pageToken, options)\n }\n\n private async listPage(\n workflowId: number | string,\n pageSize: number,\n pageToken: string | undefined,\n filters: {\n status?: RunStatus\n timeframe?: RunTimeframe\n approvalScope?: ApprovalScope\n search?: string\n },\n ): Promise<Page<AgentRunListItem>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'WorkflowRunsController_list', {\n pathParams: { id: workflowId },\n query: runsListParams(\n pageSize,\n pageToken,\n filters.status,\n filters.timeframe,\n filters.approvalScope,\n filters.search,\n ),\n }),\n )\n const runs = data.runs\n if (!Array.isArray(runs)) {\n throw new ModusError(\n `Unexpected list response shape: runs must be a list, got ${typeof runs}.`,\n )\n }\n return new Page(\n runs as AgentRunListItem[],\n normalizePageToken(\n typeof data.nextPageToken === 'string' ? data.nextPageToken : undefined,\n ),\n (token: string) => this.listPage(workflowId, pageSize, token, filters),\n )\n }\n\n /**\n * Retrieve a workflow run by id.\n *\n * @param workflowId - Workflow id or slug the run belongs to.\n * @param runId - Run id (the list row's `workflowId` field, not the composite `id`).\n * @param options.temporalRunId - Optional internal execution id when disambiguating retries.\n * @returns Run details including status and output.\n * @throws {NotFoundError} When the run does not exist.\n *\n * @example\n * ```ts\n * const run = await client.workflows.runs.get(workflowId, runId)\n * console.log(run.status)\n * ```\n */\n async get(\n workflowId: number | string,\n runId: string,\n options: { temporalRunId?: string } = {},\n ): Promise<AgentRun> {\n validateId(workflowId, 'workflow_id')\n if (!runId.trim()) throw new Error('run_id must be a non-empty string')\n const query =\n options.temporalRunId !== undefined\n ? { temporalRunId: options.temporalRunId }\n : undefined\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowRunsController_get', {\n pathParams: { id: workflowId, runId },\n query,\n })\n return parseRun(data)\n }\n\n /**\n * Start a workflow run and stream run events.\n *\n * @param workflowId - Workflow id or slug to run.\n * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events (tokens, completion, errors, and related signals).\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.create(workflowId, {\n * message: \"Summarize yesterday's sales\",\n * config: { model: 'claude-sonnet-5' },\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * if (event.type === 'done') break\n * }\n * ```\n */\n create(\n workflowId: number | string,\n body: CreateAgentRunRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n validateId(workflowId, 'workflow_id')\n return this.createRun('WorkflowRunsController_create', body, { id: workflowId }, options)\n }\n\n /**\n * Start a scope run and stream run events.\n *\n * Same event stream shape as {@link create}, but targets a published scope.\n *\n * @param scopeId - Scope id to run.\n * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.createScope(scopeId, {\n * message: 'What is our ARR trend?',\n * config: { model: 'claude-sonnet-5' },\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\n createScope(\n scopeId: number | string,\n body: SkillRunCreateRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n validateId(scopeId, 'scope_id')\n return this.createRun('ScopeRunsController_create', body, { id: scopeId }, options)\n }\n\n /**\n * Start a Modus org-assistant run and stream run events.\n *\n * @param body - Run body (`message`, optional `sessionId`, optional `subordinateSkillIds` to narrow context).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.createModus({\n * message: 'Summarize ARR in three bullets.',\n * config: { model: 'claude-sonnet-5' },\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\n createModus(\n body: ModusRunCreateRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n return this.createRun('ModusRunsController_create', body, {}, options)\n }\n\n /**\n * Resume an interrupted run and stream run events.\n *\n * @param runId - Run id to resume.\n * @param body - Resume body (`message`, `sessionId`, and `decision`: `approve` / `deny` / `connected` / `cancelled`).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.resume(runId, {\n * decision: 'approve',\n * message: 'Looks good — continue.',\n * sessionId,\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\n resume(\n runId: string,\n body: ResumeRunRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n validateId(runId, 'run_id')\n return this.createRun('ResumeRunsController_create', body, { runId }, options)\n }\n\n /**\n * Cancel a run that is still in progress.\n *\n * @param runId - Run id to cancel.\n *\n * @example\n * ```ts\n * await client.workflows.runs.cancel(runId)\n * ```\n */\n async cancel(runId: string): Promise<void> {\n validateId(runId, 'run_id')\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_cancel', {\n pathParams: { runId },\n jsonBody: {},\n })\n }\n\n /**\n * Fetch stored run events for a run.\n *\n * @param runId - Run id.\n * @returns Run event history for replay or inspection.\n */\n async events(runId: string): Promise<unknown> {\n validateId(runId, 'run_id')\n return invokeWithRetry(this.config, this.http, 'RunLifecycleController_events', {\n pathParams: { runId },\n })\n }\n\n /**\n * Request a graceful stop for a running execution.\n *\n * @param runId - Run id to interrupt.\n */\n async interrupt(runId: string): Promise<void> {\n validateId(runId, 'run_id')\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_interrupt', {\n pathParams: { runId },\n jsonBody: {},\n })\n }\n\n /**\n * Move a queued run back into an editable state before it starts.\n *\n * @param runId - Queued run id.\n */\n async editQueued(runId: string): Promise<void> {\n validateId(runId, 'run_id')\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_editQueued', {\n pathParams: { runId },\n jsonBody: {},\n })\n }\n\n /**\n * List active conversation runs across the organization.\n *\n * @param options.pageSize - Maximum items per page (default 50, max 100).\n * @param options.pageToken - Opaque token from a previous page.\n * @returns A page of active runs with session and status metadata.\n */\n active(options: {\n pageSize?: number\n pageToken?: string\n } = {}): Promise<Page<ActiveConversationRun>> {\n const pageSize = options.pageSize ?? 50\n validatePageSize(pageSize, RUNS_MAX_PAGE_SIZE)\n return this.activePage(pageSize, options.pageToken)\n }\n\n private async activePage(\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<ActiveConversationRun>> {\n return parseActiveRunsPage(\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_active', {\n query: activeRunsParams(pageSize, pageToken),\n }),\n (token: string) => this.activePage(pageSize, token),\n )\n }\n\n /**\n * Look up active runs for specific conversation sessions.\n *\n * @param sessionIds - Up to 100 session ids.\n * @returns Active runs matching any of the given sessions.\n * @throws {Error} When more than 100 session ids are provided.\n */\n async activeBySession(sessionIds: readonly string[]): Promise<ActiveConversationRun[]> {\n const uniqueSessionIds = [...new Set(sessionIds.map((id) => id.trim()).filter(Boolean))]\n if (uniqueSessionIds.length > 100) {\n throw new Error('sessionIds must contain at most 100 ids')\n }\n return parseActiveRunsArray(\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_activeBySession', {\n jsonBody: { sessionIds: uniqueSessionIds },\n }),\n )\n }\n\n /**\n * Reconnect to an in-progress run and stream run events.\n *\n * @param runId - Run id to follow.\n * @param options.lastEventId - Resume after this event id when catching up.\n * @returns A stream of run events from the current execution point.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.stream(runId, { lastEventId: checkpoint })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\n stream(runId: string, options: { lastEventId?: string } = {}): AgentRunStream {\n validateId(runId, 'run_id')\n const op = getOperation('RunLifecycleController_stream')\n const path = formatOperationPath('RunLifecycleController_stream', { runId })\n const lines = this.http.streamGet(path, undefined, {\n baseUrl: operationBaseUrl(this.http, op),\n headers: options.lastEventId ? { 'Last-Event-ID': options.lastEventId } : undefined,\n })\n return makeAgentRunStream(runId, this.parseEvents(lines))\n }\n\n private createRun(\n operationId: OperationId,\n body: AgentRunCreateRequest | SkillRunCreateRequest | ModusRunCreateRequest | ResumeRunRequest,\n pathParams: Record<string, unknown>,\n options: { idempotencyKey?: string },\n ): AgentRunStream {\n const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId()\n const sessionId = sessionIdFromBody(body as { sessionId?: string })\n const op = getOperation(operationId)\n const path = formatOperationPath(operationId, pathParams)\n const lines = this.http.streamPost(path, {\n ...body,\n sessionId,\n streamProtocolVersion: 2,\n }, {\n baseUrl: operationBaseUrl(this.http, op),\n headers: { 'Idempotency-Key': runId },\n })\n return makeAgentRunStream(runId, this.parseEvents(lines))\n }\n\n private async *parseEvents(lines: AsyncIterable<string>): AsyncGenerator<RunEvent> {\n yield* parseSseStream(lines)\n }\n}\n","import { randomUUID } from 'node:crypto'\nimport type { ModusConfig } from '../../_config.js'\nimport {\n formatOperationPath,\n getOperation,\n operationBaseUrl,\n} from '../../_openapi-invoke.js'\nimport type { HttpClient } from '../../_http.js'\nimport { invokeWithRetry } from '../../_request.js'\nimport { parseSseStream } from '../../_streaming.js'\nimport { validateId } from '../../_validation.js'\nimport type { WorkflowActionRequest } from '../../types/agent-runs.js'\nimport type { RunEvent } from '../../types/runs.js'\nimport { makeAgentRunStream, type AgentRunStream } from './runs.js'\n\nfunction randomRunId(): string {\n return randomUUID()\n}\n\nexport class AgentWorkflowActionsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * Execute a workflow action and stream run events.\n *\n * @param body - Action body (`organizationId`, `sessionId`, `workflowAction`, optional `previousOutputs`).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events for the action execution.\n */\n execute(\n body: WorkflowActionRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId()\n const op = getOperation('WorkflowActionsController_execute')\n const path = formatOperationPath('WorkflowActionsController_execute')\n const lines = this.http.streamPost(path, body, {\n baseUrl: operationBaseUrl(this.http, op),\n headers: { 'Idempotency-Key': runId },\n })\n return makeAgentRunStream(runId, this.parseEvents(lines))\n }\n\n /**\n * Cancel a workflow action run.\n *\n * @param runId - Action run id to cancel.\n */\n async cancel(runId: string): Promise<void> {\n validateId(runId, 'run_id')\n await invokeWithRetry(this.config, this.http, 'WorkflowActionsController_cancel', {\n pathParams: { runId },\n jsonBody: {},\n })\n }\n\n private async *parseEvents(lines: AsyncIterable<string>): AsyncGenerator<RunEvent> {\n yield* parseSseStream(lines)\n }\n}\n","import type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../_request.js'\nimport { validateId, validatePageSize } from '../_validation.js'\nimport type { Workflow, WorkflowType } from '../types/workflows.js'\nimport type { VariationView } from '../types/views.js'\nimport { WorkflowRunsResource } from './workflows/runs.js'\nimport { AgentWorkflowActionsResource } from './workflows/workflow-actions.js'\n\nfunction workflowsListParams(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n type?: WorkflowType,\n view?: VariationView,\n includeVariation?: boolean,\n): Record<string, string | number | boolean | undefined | null> {\n const extra: Record<string, string | number | boolean | undefined | null> = {}\n if (search !== undefined) extra.search = search\n if (type !== undefined) extra.type = type\n if (view !== undefined) extra.view = view\n if (includeVariation !== undefined) extra.includeVariation = includeVariation\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >\n}\n\nfunction parseWorkflow(raw: unknown): Workflow {\n return raw as Workflow\n}\n\n/**\n * Read and run access to Modus workflows.\n *\n * - `list` / `get` — browse workflows (`view: 'active'` or `'draft'`)\n * - {@link WorkflowRunsResource runs} — start, monitor, and control workflow runs\n * - {@link AgentWorkflowActionsResource workflowActions} — execute workflow actions\n *\n * @example\n * ```ts\n * import { Modus } from '@getmodus/sdk'\n * const client = new Modus()\n * for await (const wf of (await client.workflows.list()).autoPagingIter()) {\n * console.log(wf.id, wf.name, wf.status)\n * }\n * ```\n */\nexport class WorkflowsResource {\n readonly runs: WorkflowRunsResource\n readonly workflowActions: AgentWorkflowActionsResource\n\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {\n this.runs = new WorkflowRunsResource(http, config)\n this.workflowActions = new AgentWorkflowActionsResource(http, config)\n }\n\n /**\n * List workflows in the organisation.\n *\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.search - Case-insensitive substring filter on the workflow name.\n * @param options.type - Workflow kind: `\"task\"` or `\"workflow\"`.\n * @param options.view - Which saved version to return (`active` or `draft`).\n * @param options.includeVariation - Include variation metadata when supported.\n * @returns A page of workflows — use `.autoPagingIter()` for all pages.\n *\n * @example\n * ```ts\n * for await (const wf of (await client.workflows.list({ search: 'digest' })).autoPagingIter()) {\n * console.log(wf.id, wf.name, wf.status)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n search?: string\n type?: WorkflowType\n view?: VariationView\n includeVariation?: boolean\n } = {}): Promise<Page<Workflow>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(\n pageSize,\n options.pageToken,\n options.search,\n options.type,\n options.view,\n options.includeVariation,\n )\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n type?: WorkflowType,\n view?: VariationView,\n includeVariation?: boolean,\n ): Promise<Page<Workflow>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'WorkflowsController_list', {\n query: workflowsListParams(\n pageSize,\n pageToken,\n search,\n type,\n view,\n includeVariation,\n ),\n }),\n )\n // List responses require the canonical `workflows` key (dual `agents` envelope removed).\n return buildAipPage(\n data,\n 'workflows',\n parseWorkflow,\n (token) => this.listPage(pageSize, token, search, type, view, includeVariation),\n )\n }\n\n /**\n * Retrieve a workflow by ID or slug.\n *\n * @param workflowId - Numeric id or slug.\n * @param options.view - Which saved version to return (`active` or `draft`).\n * @param options.includeVariation - Include variation metadata when supported.\n * @returns The workflow (`id`, `name`, `status`, …).\n * @throws {NotFoundError} When no workflow matches the id or slug.\n *\n * @example\n * ```ts\n * const wf = await client.workflows.get('weekly-digest')\n * console.log(wf.name, wf.status)\n * ```\n */\n async get(\n workflowId: number | string,\n options: { view?: VariationView; includeVariation?: boolean } = {},\n ): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const query: Record<string, string | boolean> = {}\n if (options.view !== undefined) query.view = options.view\n if (options.includeVariation !== undefined) {\n query.includeVariation = options.includeVariation\n }\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowsController_get', {\n pathParams: { id: workflowId },\n query: Object.keys(query).length > 0 ? query : undefined,\n })\n return parseWorkflow(data)\n }\n}\n","import type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../_request.js'\nimport { validatePageSize } from '../_validation.js'\nimport type { Connection } from '../types/connections.js'\n\nfunction connectionsListParams(\n pageSize: number,\n pageToken: string | undefined,\n type?: string,\n): Record<string, string | number | boolean | undefined | null> {\n const extra: Record<string, string | number | boolean | undefined | null> = {}\n if (type !== undefined) extra.type = type\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >\n}\n\nfunction parseConnection(raw: unknown): Connection {\n return raw as Connection\n}\n\n/**\n * Read access to integration connections.\n */\nexport class ConnectionsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List integration connections.\n *\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.type - Integration category; exact match filter.\n * @returns A page of connections.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n type?: string\n } = {}): Promise<Page<Connection>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.type)\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n type?: string,\n ): Promise<Page<Connection>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ConnectionsController_list', {\n query: connectionsListParams(pageSize, pageToken, type),\n }),\n )\n return buildAipPage(data, 'connections', parseConnection, (token) =>\n this.listPage(pageSize, token, type),\n )\n }\n\n /**\n * Find the first connection whose name matches (case-insensitive).\n *\n * Pages through {@link ConnectionsResource.list} until a match is found.\n *\n * @param options.name - Connection name to search for.\n * @param options.type - Optional integration category filter.\n * @param options.pageSize - Page size when scanning (default 25).\n * @returns The matching connection, or `undefined` if none is found.\n */\n async find(options: {\n name: string\n type?: string\n pageSize?: number\n }): Promise<Connection | undefined> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n const target = options.name.trim().toLowerCase()\n let token: string | undefined\n do {\n const page = await this.listPage(pageSize, token, options.type)\n const match = page.items.find((c) => c.name?.toLowerCase() === target)\n if (match) return match\n if (!page.hasNextPage()) break\n token = page.nextPageToken\n } while (token !== undefined)\n return undefined\n }\n}\n","import type { ModusConfig } from '../../_config.js'\nimport { NotFoundError } from '../../_exceptions.js'\nimport type { HttpClient } from '../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../_pagination.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { DEFAULT_MAX_PAGE_SIZE, validatePageSize } from '../../_validation.js'\nimport type { ContextItem, ContextItemLookupRow } from '../../types/context.js'\nimport type { ContextValueRow } from '../../types/context-values.js'\nimport type { ContentProjection, JsonObjectInput } from '../../types/json-blob.js'\n\nfunction contextListParams(\n pageSize: number,\n pageToken: string | undefined,\n contextType?: string,\n): Record<string, string | number | boolean | readonly string[] | undefined | null> {\n const extra: Record<string, string | readonly string[]> = {}\n if (contextType !== undefined) extra.contextTypes = [contextType]\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | readonly string[] | undefined | null\n >\n}\n\nfunction parseContextItem(raw: unknown): ContextItem {\n return raw as ContextItem\n}\n\nfunction parseContextValueRow(raw: unknown): ContextValueRow {\n return raw as ContextValueRow\n}\n\nfunction parseLookupResponse(raw: Record<string, unknown>): ContextItemLookupRow | undefined {\n const item = raw.item\n if (item === null || item === undefined) return undefined\n return item as ContextItemLookupRow\n}\n\n/**\n * Read the org knowledge base (notes, metrics, saved queries, integration items).\n *\n * Use `client.context.items` after `new Modus()`. Prefer `list` / `get` /\n * `lookup` for discovery; use `listValues` when a field holds a large array\n * inside `content`.\n *\n * @example\n * ```ts\n * import { Modus } from '@getmodus/sdk'\n * const client = new Modus()\n * for await (const item of (await client.context.items.list({ pageSize: 25 })).autoPagingIter()) {\n * console.log(item.contextType, item.description ?? item.uid)\n * }\n * ```\n */\nexport class ContextItemsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List knowledge-base items.\n *\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.contextType - Filter to a single context type (e.g. `\"note\"`).\n * @returns A page of context items — use `.autoPagingIter()` for all pages.\n *\n * @example\n * ```ts\n * const notes = await client.context.items.list({ contextType: 'note', pageSize: 50 })\n * for (const item of notes.items) {\n * console.log(item.description ?? item.uid, item.uid)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n contextType?: string\n } = {}): Promise<Page<ContextItem>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.contextType)\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n contextType?: string,\n ): Promise<Page<ContextItem>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_list', {\n query: contextListParams(pageSize, pageToken, contextType),\n }),\n )\n return buildAipPage(data, 'contextItems', parseContextItem, (token) =>\n this.listPage(pageSize, token, contextType),\n )\n }\n\n /**\n * Retrieve a knowledge-base item by uid.\n *\n * @param uid - Item uid.\n * @returns The context item (`uid`, `contextType`, `content`, …).\n * @throws {NotFoundError} When no item matches the uid.\n *\n * @example\n * ```ts\n * const item = await client.context.items.get(uid)\n * console.log(item.contextType, item.description ?? item.uid)\n * ```\n */\n async get(uid: string): Promise<ContextItem> {\n const data = await invokeWithRetry(this.config, this.http, 'ContextItemsController_get', {\n pathParams: { uid },\n })\n return parseContextItem(data)\n }\n\n /**\n * Look up a knowledge-base item by type and data path.\n *\n * @param options.contextType - Context type to match (e.g. `\"note\"`).\n * @param options.dataPath - Hierarchical path segments that identify the item.\n * @param options.contentProjection - Optional fields to include from item content.\n * @returns The matching row, or `undefined` when no item is found (404).\n *\n * @example\n * ```ts\n * const found = await client.context.items.lookup({\n * contextType: 'note',\n * dataPath: ['finance', 'arr-definition'],\n * })\n * if (found) console.log(found.uid, found.description ?? found.uid)\n * ```\n */\n async lookup(options: {\n contextType: string\n dataPath: string[]\n contentProjection?: JsonObjectInput | ContentProjection\n }): Promise<ContextItemLookupRow | undefined> {\n const body = omitUndefined({\n contextType: options.contextType,\n dataPath: options.dataPath,\n contentProjection: options.contentProjection,\n })\n try {\n const raw = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_lookup', {\n jsonBody: body,\n }),\n )\n return parseLookupResponse(raw)\n } catch (error) {\n if (error instanceof NotFoundError) return undefined\n throw error\n }\n }\n\n /**\n * List values stored under a content key on a context item.\n *\n * @param uid - Item uid.\n * @param contextType - Context type of the item.\n * @param contentKeyPath - Dot path to the value field inside item content (e.g. `\"enumValues\"`).\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @returns A page of value rows.\n *\n * @example\n * ```ts\n * // Replace PLACEHOLDER_UID with a real uid whose content has enumValues.\n * const page = await client.context.items.listValues(\n * 'PLACEHOLDER_UID',\n * 'table_column',\n * 'enumValues',\n * { pageSize: 25 },\n * )\n * for (const row of page.items) console.log(row)\n * ```\n */\n listValues(\n uid: string,\n contextType: string,\n contentKeyPath: string,\n options: { pageSize?: number; pageToken?: string } = {},\n ): Promise<Page<ContextValueRow>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize, DEFAULT_MAX_PAGE_SIZE)\n return this.listValuesPage(uid, contextType, contentKeyPath, pageSize, options.pageToken)\n }\n\n /**\n * List values for a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.\n *\n * @param item - Context item (uses `item.uid` and `item.contextType`).\n * @param contentKeyPath - Dot path to the value field inside item content.\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @returns A page of value rows.\n *\n * @example\n * ```ts\n * // Replace PLACEHOLDER_UID with a real uid that has enumValues in content.\n * const item = await client.context.items.get('PLACEHOLDER_UID')\n * const page = await client.context.items.listValuesFor(item, 'enumValues')\n * for (const row of page.items) console.log(row)\n * ```\n */\n listValuesFor(\n item: ContextItem,\n contentKeyPath: string,\n options: { pageSize?: number; pageToken?: string } = {},\n ): Promise<Page<ContextValueRow>> {\n return this.listValues(item.uid, item.contextType, contentKeyPath, options)\n }\n\n private async listValuesPage(\n uid: string,\n contextType: string,\n contentKeyPath: string,\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<ContextValueRow>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_listValues', {\n pathParams: { uid },\n query: aipListParams(pageSize, pageToken, {\n contextType,\n contentKeyPath,\n }) as Record<string, string | number | boolean | undefined | null>,\n }),\n )\n return buildAipPage(data, 'values', parseContextValueRow, (token) =>\n this.listValuesPage(uid, contextType, contentKeyPath, pageSize, token),\n )\n }\n}\n","import type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { CustomContextItemsResource } from './custom-items.js'\nimport { ContextItemsResource } from './items.js'\n\n/**\n * Read access to the Modus knowledge base.\n *\n * - {@link ContextItemsResource items} — list and look up indexed knowledge-base items.\n * - {@link CustomContextItemsResource customItems} — create and manage custom context items.\n *\n * Call path: `client.context` after `new Modus(...)`.\n */\nexport class ContextResource {\n readonly items: ContextItemsResource\n readonly customItems: CustomContextItemsResource\n\n /** @internal */\n constructor(http: HttpClient, config: ModusConfig) {\n this.items = new ContextItemsResource(http, config)\n this.customItems = new CustomContextItemsResource(http, config)\n }\n}\n","import type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { invokeWithRetry } from '../_request.js'\nimport type {\n IngestedDataUploadResult,\n UploadIngestedDataOptions,\n} from '../types/ingested-data.js'\n\n/** Store exact integration requests and responses as immutable ingested data. */\nexport class IngestedDataResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * Store a complete SQL or HTTP request and response exactly once.\n *\n * Identity covers the complete organization, integration, request, and response\n * content. A duplicate raises `ConflictError`, which means the identical payload\n * is already stored and may be treated as a safe retry outcome.\n *\n * @param options.integrationType - Canonical Modus integration identifier.\n * @param options.request - Exact SQL or HTTP request that produced the response.\n * @param options.response - Response format, optional source HTTP status, and exact string content. SQL requires CSV.\n * @returns The checksum of the stored envelope.\n * @throws {ConflictError} When the complete payload is already stored.\n *\n * @example\n * ```ts\n * const stored = await client.ingestedData.upload({\n * integrationType: 'generic',\n * request: { type: 'sql', query: 'SELECT id, total FROM orders' },\n * response: { format: 'csv', content: 'id,total\\n1,42.00\\n' },\n * })\n * console.log(stored.checksum)\n * ```\n */\n async upload(options: UploadIngestedDataOptions): Promise<IngestedDataUploadResult> {\n const data = await invokeWithRetry(this.config, this.http, 'IngestedDataController_upload', {\n jsonBody: {\n integration_type: options.integrationType,\n request: options.request,\n response: options.response,\n },\n })\n return data as IngestedDataUploadResult\n }\n}\n","import type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { validateId, validatePageSize } from '../../_validation.js'\nimport type {\n Conversation,\n ConversationKind,\n ConversationListItem,\n} from '../../types/conversations.js'\n\nconst ALLOWED_KINDS = new Set<ConversationKind>(['all', 'modus', 'scopes'])\n\nfunction listParams(\n pageSize: number,\n pageToken: string | undefined,\n kind?: ConversationKind,\n source?: string,\n sourceRef?: string,\n): Record<string, string | number | boolean | undefined | null> {\n if (kind !== undefined && !ALLOWED_KINDS.has(kind)) {\n throw new Error(\n `kind must be one of ${[...ALLOWED_KINDS].sort().join(', ')}, got ${JSON.stringify(kind)}`,\n )\n }\n const extra: Record<string, string> = {}\n if (kind !== undefined) extra.kind = kind\n if (source !== undefined) extra.source = source\n if (sourceRef !== undefined) extra.sourceRef = sourceRef\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >\n}\n\nfunction parseListItem(raw: unknown): ConversationListItem {\n return raw as ConversationListItem\n}\n\nfunction parseConversation(raw: unknown): Conversation {\n return raw as Conversation\n}\n\n/** List and retrieve Modus / scope conversations. */\nexport class ModusConversationsResource {\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List conversations.\n *\n * @param options.pageSize - Items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.kind - `\"modus\"`, `\"scopes\"`, or `\"all\"`.\n * @param options.source - Restrict to conversations started from this UI surface\n * (e.g. `\"context_chat\"`, `\"dashboard_copilot\"`, `\"slack\"`). Only valid with an\n * omitted `kind` or `kind: \"all\"`; the API throws an `UnprocessableError` (422)\n * if combined with `kind: \"modus\"` or `kind: \"scopes\"`.\n * @param options.sourceRef - Narrow `source` to one instance of that surface — for\n * `\"dashboard_copilot\"`, a dashboard id. Requires `source`; the API throws an\n * `UnprocessableError` (422) if sent on its own. Conversations recorded before\n * this filter shipped carry no instance key and never match it.\n * @returns Page of conversation list items.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n kind?: ConversationKind\n source?: string\n sourceRef?: string\n } = {}): Promise<Page<ConversationListItem>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.kind, options.source, options.sourceRef)\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n kind?: ConversationKind,\n source?: string,\n sourceRef?: string,\n ): Promise<Page<ConversationListItem>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ModusConversationsController_list', {\n query: listParams(pageSize, pageToken, kind, source, sourceRef),\n }),\n )\n return buildAipPage(data, 'conversations', parseListItem, (token) =>\n this.listPage(pageSize, token, kind, source, sourceRef),\n )\n }\n\n /**\n * Retrieve a conversation thread with full message history.\n *\n * @param threadId - Conversation thread id.\n * @returns Conversation with messages.\n */\n async get(threadId: string): Promise<Conversation> {\n validateId(threadId, 'thread_id')\n const data = await invokeWithRetry(this.config, this.http, 'ModusConversationsController_get', {\n pathParams: { threadId },\n })\n return parseConversation(data)\n }\n}\n","import { modusChatBuffered, modusChatStreamSession, type ChatStream } from '../../_chat.js'\nimport type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport type { ChatModel, ChatResult } from '../../types/chat.js'\nimport type { ModusContextComposition } from '../../types/context-compose.js'\n\nimport { ModusConversationsResource } from './conversations.js'\n\n/**\n * Org-wide Modus assistant (full environment context and tools).\n *\n * Prefer `client.modus` over `client.scopes` when the question is not tied to one\n * published scope. Construct with `new Modus()` (reads `MODUS_API_KEY`).\n *\n * - `chat` — one complete reply\n * - `chatStream` — print tokens as they arrive (consume `textStream()`)\n * - `getContext` — preview composed context without a chat turn\n * - `conversations` — list/get prior Modus threads\n *\n * @example\n * ```ts\n * import { Modus } from '@getmodus/sdk'\n * const client = new Modus()\n * const result = await client.modus.chat('What tables describe revenue?', {\n * model: 'claude-sonnet-5',\n * })\n * console.log(result.content, result.threadId)\n * ```\n */\nexport class ModusResource {\n readonly conversations: ModusConversationsResource\n\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {\n this.conversations = new ModusConversationsResource(http, config)\n }\n\n /**\n * Compose full-environment context for an intent without running chat.\n *\n * @param message - Natural-language intent used to select context.\n * @param options.limit - Maximum context items to return. Omit to return all selected items.\n * @returns Composition metadata (counts / session id). Use `chat` for a reply.\n *\n * @example\n * ```ts\n * const ctx = await client.modus.getContext('What tables describe revenue?', { limit: 5 })\n * console.log(ctx.originalCount, ctx.sessionId)\n * ```\n */\n async getContext(\n message: string,\n options: { limit?: number } = {},\n ): Promise<ModusContextComposition> {\n const data = await invokeWithRetry(this.config, this.http, 'ModusContextController_compose', {\n jsonBody: omitUndefined({ message, limit: options.limit }),\n })\n return data as ModusContextComposition\n }\n\n /**\n * Send a message to Modus and wait for the complete reply.\n *\n * @param message - User message text.\n * @param options.model - Required model id (e.g. `\"claude-sonnet-5\"`).\n * @param options.threadId - Continue an existing conversation; omit to start new.\n * @returns Chat result: `content`, `threadId` (for follow-ups), `runId`.\n *\n * @example\n * ```ts\n * const result = await client.modus.chat('What tables describe revenue?', {\n * model: 'claude-sonnet-5',\n * })\n * console.log(result.content, result.threadId)\n * const follow = await client.modus.chat('Break that down by region.', {\n * model: 'claude-sonnet-5',\n * threadId: result.threadId,\n * })\n * ```\n */\n chat(message: string, options: { model: ChatModel; threadId?: string }): Promise<ChatResult> {\n return modusChatBuffered(this.http, message, options)\n }\n\n /**\n * Stream a Modus reply token by token (SSE).\n *\n * The request starts when you consume `textStream()` or `eventStream()`.\n *\n * @param message - User message text.\n * @param options.model - Required model id (e.g. `\"claude-sonnet-5\"`).\n * @param options.threadId - Continue an existing conversation; omit to start new.\n * @returns Chat stream — iterate `textStream()` for tokens.\n *\n * @example\n * ```ts\n * const stream = client.modus.chatStream('Summarize ARR in three bullets.', {\n * model: 'claude-sonnet-5',\n * })\n * for await (const token of stream.textStream()) {\n * process.stdout.write(token)\n * }\n * console.log(stream.getFinalResult().threadId)\n * ```\n */\n chatStream(message: string, options: { model: ChatModel; threadId?: string }): ChatStream {\n return modusChatStreamSession(this.http, this.config, message, options)\n }\n}\n","import { chatBuffered, chatStreamSession, type ChatStream } from '../_chat.js'\nimport type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../_pagination.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../_request.js'\nimport { validateId, validatePageSize } from '../_validation.js'\nimport type { ChatModel, ChatResult } from '../types/chat.js'\nimport type { SkillContextComposition } from '../types/context-compose.js'\nimport type { Scope } from '../types/scopes.js'\nimport type { VariationView } from '../types/views.js'\nimport { ScopeConversationsResource } from './scopes/conversations.js'\n\nfunction scopesListParams(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n view?: VariationView,\n managerId?: number,\n): Record<string, string | number | boolean | undefined | null> {\n const extra: Record<string, string | number | boolean | undefined | null> = {}\n if (search !== undefined) extra.search = search\n if (view !== undefined) extra.view = view\n if (managerId !== undefined) extra.managerId = managerId\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >\n}\n\nfunction parseScope(raw: unknown): Scope {\n return raw as Scope\n}\n\n/**\n * Read / chat with published scopes.\n *\n * Call path: `client.scopes` after `new Modus(...)`. Prefer `client.modus` for\n * the org-wide assistant. Create/deploy via `ModusManagement`.\n *\n * @example\n * ```ts\n * const scope = await client.scopes.get('revenue-analysis')\n * const result = await client.scopes.chat(scope.id, 'What is our ARR trend?', {\n * model: 'claude-sonnet-5',\n * })\n * console.log(result.content, result.threadId)\n * ```\n */\nexport class ScopesResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * Return the conversations sub-resource scoped to `scopeId`.\n *\n * @param scopeId - Scope numeric id or slug.\n * @returns Conversations resource for the scope.\n *\n * @example\n * ```ts\n * for await (const row of (\n * await client.scopes.conversations(scopeId).list({ pageSize: 10 })\n * ).autoPagingIter()) {\n * console.log(row.threadId, row.firstMessage)\n * }\n * ```\n */\n conversations(scopeId: number | string): ScopeConversationsResource {\n return new ScopeConversationsResource(this.http, this.config, scopeId)\n }\n\n /**\n * List scopes in the organisation.\n *\n * @param options.pageSize - Items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.search - Case-insensitive substring filter on the scope name.\n * @param options.view - `\"active\"` (deployed) or `\"draft\"`.\n * @param options.managerId - Only scopes supervised by this manager scope id.\n * @returns Page of scopes — use `.autoPagingIter()` for all pages.\n *\n * @example\n * ```ts\n * for await (const scope of (await client.scopes.list()).autoPagingIter()) {\n * console.log(scope.id, scope.name, scope.status)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n search?: string\n view?: VariationView\n managerId?: number\n } = {}): Promise<Page<Scope>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(\n pageSize,\n options.pageToken,\n options.search,\n options.view,\n options.managerId,\n )\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n view?: VariationView,\n managerId?: number,\n ): Promise<Page<Scope>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ScopesController_list', {\n query: scopesListParams(pageSize, pageToken, search, view, managerId),\n }),\n )\n // List responses require the canonical `scopes` key (dual `skills` envelope removed).\n return buildAipPage(\n data,\n 'scopes',\n parseScope,\n (token) => this.listPage(pageSize, token, search, view, managerId),\n )\n }\n\n /**\n * Retrieve a scope by ID or slug.\n *\n * @param scopeId - Scope numeric id or slug.\n * @param options.view - `\"active\"` (deployed) or `\"draft\"`.\n * @throws {NotFoundError} When no scope matches the id or slug.\n * @returns Scope (`id`, `name`, `status`, …).\n *\n * @example\n * ```ts\n * const scope = await client.scopes.get('revenue-analysis')\n * console.log(scope.name, scope.status)\n * ```\n */\n async get(\n scopeId: number | string,\n options: { view?: VariationView } = {},\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const query = options.view !== undefined ? { view: options.view } : undefined\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_get', {\n pathParams: { id: scopeId },\n query,\n })\n return parseScope(data)\n }\n\n /**\n * Compose context this scope would use for an intent, without running chat.\n *\n * @param scopeId - Scope numeric id or slug.\n * @param message - Natural-language intent used to select context.\n * @param options.limit - Maximum context items to return. Omit to return all selected items.\n * @returns Composition metadata. Use `chat` when you need an assistant reply.\n *\n * @example\n * ```ts\n * const ctx = await client.scopes.getContext(scopeId, 'Which tables describe churn?', {\n * limit: 5,\n * })\n * console.log(ctx.originalCount, ctx.sessionId)\n * ```\n */\n async getContext(\n scopeId: number | string,\n message: string,\n options: { limit?: number } = {},\n ): Promise<SkillContextComposition> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeContextController_compose', {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined({ message, limit: options.limit }),\n })\n return data as SkillContextComposition\n }\n\n /**\n * Send a message to a published scope and wait for the complete reply.\n *\n * For the org-wide assistant use `client.modus.chat` instead.\n *\n * @param scopeId - Scope numeric id or slug (must be active for chat).\n * @param message - User message text.\n * @param options.model - Required model id (e.g. `\"claude-sonnet-5\"`).\n * @param options.threadId - Continue an existing conversation; omit to start new.\n * @returns Chat result: `content`, `threadId`, `runId`.\n *\n * @example\n * ```ts\n * const result = await client.scopes.chat(scopeId, 'What is our ARR trend?', {\n * model: 'claude-sonnet-5',\n * })\n * console.log(result.content, result.threadId)\n * const follow = await client.scopes.chat(scopeId, 'Break that down by segment.', {\n * model: 'claude-sonnet-5',\n * threadId: result.threadId,\n * })\n * ```\n */\n chat(\n scopeId: number | string,\n message: string,\n options: { model: ChatModel; threadId?: string },\n ): Promise<ChatResult> {\n return chatBuffered(this.http, 'scopes', scopeId, message, options)\n }\n\n /**\n * Stream a scope reply token by token (SSE).\n *\n * The request starts when you consume `textStream()` or `eventStream()`.\n *\n * @param scopeId - Scope numeric id or slug.\n * @param message - User message text.\n * @param options.model - Required model id (e.g. `\"claude-sonnet-5\"`).\n * @param options.threadId - Continue an existing conversation; omit to start new.\n * @param options.version - `\"published\"` or `\"draft\"`.\n * @returns Chat stream — iterate `textStream()` for tokens.\n *\n * @example\n * ```ts\n * const stream = client.scopes.chatStream(scopeId, 'Summarize in three bullets.', {\n * model: 'claude-sonnet-5',\n * })\n * for await (const token of stream.textStream()) {\n * process.stdout.write(token)\n * }\n * console.log(stream.getFinalResult().threadId)\n * ```\n */\n chatStream(\n scopeId: number | string,\n message: string,\n options: { model: ChatModel; threadId?: string; version?: string },\n ): ChatStream {\n return chatStreamSession(this.http, this.config, 'scopes', scopeId, message, options)\n }\n}\n","import type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { buildAipPage, type Page } from '../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../_request.js'\nimport { validateId, validatePageSize } from '../_validation.js'\nimport {\n type RecordSuggestionEventRequest,\n type SuggestionQuestion,\n} from '../types/suggestions.js'\n\nconst DEFAULT_SUGGESTIONS_PAGE_SIZE = 5\nconst MAX_SUGGESTIONS_PAGE_SIZE = 12\n\nfunction parseSuggestion(raw: unknown): SuggestionQuestion {\n return raw as SuggestionQuestion\n}\n\nfunction suggestionListParams(options: {\n pageSize: number\n pageToken?: string\n scopeId?: number\n scopeIds?: readonly number[]\n}): Record<string, string | number | undefined> {\n return {\n pageSize: options.pageSize,\n pageToken: options.pageToken,\n scopeId: options.scopeId,\n scopeIds: options.scopeIds?.join(','),\n }\n}\n\n/**\n * List suggested questions and record suggestion events.\n */\nexport class SuggestionsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List approved suggested questions.\n *\n * @param options.pageSize - Maximum items per page (default 5, max 12).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.scopeId - Filter to a single scope.\n * @param options.scopeIds - Filter to one or more scopes.\n * @returns A page of suggested questions.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n scopeId?: number\n scopeIds?: readonly number[]\n } = {}): Promise<Page<SuggestionQuestion>> {\n const pageSize = options.pageSize ?? DEFAULT_SUGGESTIONS_PAGE_SIZE\n validatePageSize(pageSize, MAX_SUGGESTIONS_PAGE_SIZE)\n return this.listPage(pageSize, options.pageToken, options.scopeId, options.scopeIds)\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n scopeId: number | undefined,\n scopeIds: readonly number[] | undefined,\n ): Promise<Page<SuggestionQuestion>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'SuggestionsController_listApproved', {\n query: suggestionListParams({ pageSize, pageToken, scopeId, scopeIds }),\n }),\n )\n return buildAipPage(data, 'suggestions', parseSuggestion, (token) =>\n this.listPage(pageSize, token, scopeId, scopeIds),\n )\n }\n\n /**\n * Record that a suggested question was shown, clicked, dismissed, or submitted.\n *\n * @param id - Suggestion id.\n * @param event - Event details, including `eventType` (`shown`, `clicked`, `dismissed`, or `submitted`).\n */\n async recordEvent(id: string, event: RecordSuggestionEventRequest): Promise<void> {\n validateId(id, 'id')\n await invokeWithRetry(this.config, this.http, 'SuggestionsController_recordEvent', {\n pathParams: { id },\n jsonBody: event,\n })\n }\n}\n","/**\n * @getmodus/sdk — official TypeScript client for Modus.\n */\n\nexport type { components, paths, operations } from './_generated/v1.js'\nexport type { OperationId, OperationSpec } from './_generated/operations.js'\nexport { OPERATIONS } from './_generated/operations.js'\n\nexport {\n APIConnectionError,\n AuthenticationError,\n ConflictError,\n InternalServerError,\n ModusError,\n NotFoundError,\n PermissionDeniedError,\n RateLimitError,\n RunCancelledError,\n StreamTimeoutError,\n UnprocessableError,\n ValidationError,\n} from './_exceptions.js'\n\nexport { ChatStream } from './_chat.js'\nexport { Page } from './_pagination.js'\nexport type {\n AssistantContentResetEvent,\n CancelledEvent,\n DoneEvent,\n ErrorEvent,\n RunEvent,\n StreamTimeoutEvent,\n TokenEvent,\n} from './types/runs.js'\nexport type { ChatModel, ChatRequest, ChatResult } from './types/chat.js'\nexport type { ModusOptions } from './_config.js'\nexport type { Scope, ScopeStatus, ScopeVariation, Skill, SkillStatus, SkillVariation } from './types/scopes.js'\nexport type { Workflow, Agent } from './types/workflows.js'\nexport { AgentType, WorkflowType } from './types/workflows.js'\nexport type {\n AgentRun,\n AgentRunCreateRequest,\n AgentRunListItem,\n ApprovalScope,\n CancelRunRequest,\n CreateAgentRunRequest,\n EditQueuedRunRequest,\n InterruptRunRequest,\n ModusRunCreateRequest,\n ResumeRunRequest,\n RunStatus,\n RunTimeframe,\n SkillRunCreateRequest,\n WorkflowActionRequest,\n} from './types/agent-runs.js'\nexport type { AgentRunStream } from './resources/workflows/runs.js'\nexport type {\n Conversation,\n ConversationKind,\n ConversationListItem,\n Message,\n} from './types/conversations.js'\nexport { conversationScopeId, conversationSkillId } from './types/conversations.js'\nexport type { Connection } from './types/connections.js'\nexport type { VariationView } from './types/views.js'\nexport type {\n ContextItem,\n ContextItemLookupRow,\n ContextType,\n} from './types/context.js'\nexport type { ContextValueRow } from './types/context-values.js'\nexport type {\n ComposeSkillContextRequest,\n ModusContextComposition,\n ModusContextRequest,\n SkillContextComposition,\n} from './types/context-compose.js'\nexport type {\n RecordSuggestionEventRequest,\n SuggestionEventSource,\n SuggestionEventType,\n SuggestionQuestion,\n} from './types/suggestions.js'\nexport type {\n HttpIngestedDataRequest,\n IngestedDataRequest,\n IngestedDataResponse,\n IngestedDataResponseFormat,\n IngestedDataUploadResult,\n SqlIngestedDataRequest,\n UploadIngestedDataOptions,\n} from './types/ingested-data.js'\n\nimport { ModusClientBase } from './_client-base.js'\nimport { WorkflowsResource } from './resources/workflows.js'\nimport { ConnectionsResource } from './resources/connections.js'\nimport { ContextResource } from './resources/context/context.js'\nimport { IngestedDataResource } from './resources/ingested-data.js'\nimport { ModusResource } from './resources/modus/modus.js'\nimport { ScopesResource } from './resources/scopes.js'\nimport { SuggestionsResource } from './resources/suggestions.js'\n\n/**\n * Read / invoke client for Modus scopes, workflows, connections, and more.\n *\n * Call path: `const client = new Modus(...)` then `client.scopes`, `client.context`, …\n *\n * @param options - Client configuration (`apiKey`, `baseUrl`, `timeoutMs`, `maxRetries`).\n */\nexport class Modus extends ModusClientBase {\n readonly scopes: ScopesResource\n readonly modus: ModusResource\n readonly workflows: WorkflowsResource\n readonly context: ContextResource\n readonly connections: ConnectionsResource\n readonly suggestions: SuggestionsResource\n readonly ingestedData: IngestedDataResource\n\n constructor(options: import('./_config.js').ModusOptions = {}) {\n super(options)\n this.scopes = new ScopesResource(this.http, this.config)\n this.modus = new ModusResource(this.http, this.config)\n this.workflows = new WorkflowsResource(this.http, this.config)\n this.context = new ContextResource(this.http, this.config)\n this.connections = new ConnectionsResource(this.http, this.config)\n this.suggestions = new SuggestionsResource(this.http, this.config)\n this.ingestedData = new IngestedDataResource(this.http, this.config)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAGpB,SAAS,yBAAyB,WAAmC;AAC1E,MAAI,OAAO,cAAc,YAAY,UAAU,KAAK,EAAG,QAAO,UAAU,KAAK;AAC7E,SAAO,WAAW;AACpB;;;ACIA,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,UAAU,MAAmD;AACpE,MAAI,CAAC,KAAK,WAAW,OAAO,EAAG,QAAO;AACtC,QAAM,MAAM,KAAK,MAAM,CAAC,EAAE,UAAU;AACpC,MAAI,CAAC,OAAO,QAAQ,SAAU,QAAO;AACrC,MAAI;AACF,UAAM,OAAO,KAAK,MAAM,GAAG;AAC3B,QAAI,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,GAAG;AAC5D,aAAO;AAAA,IACT;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEA,SAAS,gBAAmB,OAAkE;AAC5F,SAAO,OAAO,iBAAiB,OAAO,KAAK;AAC7C;AAEA,UAAU,UAAU,MAAoD;AACtE,QAAM,YAAY,OAAO,KAAK,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AAK,MAAM,KAAK,MAAM;AACrD,SAAK,YAAY,IAAI,kBAAkB,KAAK,MAAM,KAAK,MAAM;AAC7D,SAAK,UAAU,IAAI,gBAAgB,KAAK,MAAM,KAAK,MAAM;AACzD,SAAK,cAAc,IAAI,oBAAoB,KAAK,MAAM,KAAK,MAAM;AACjE,SAAK,cAAc,IAAI,oBAAoB,KAAK,MAAM,KAAK,MAAM;AACjE,SAAK,eAAe,IAAI,qBAAqB,KAAK,MAAM,KAAK,MAAM;AAAA,EACrE;AACF;","names":["randomUUID","randomUUID","randomUUID","randomRunId","randomUUID"]}
1
+ {"version":3,"sources":["../src/_agent_run_request.ts","../src/_streaming.ts","../src/_chat.ts","../src/types/workflows.ts","../src/types/conversations.ts","../src/resources/workflows/runs.ts","../src/resources/workflows/workflow-actions.ts","../src/resources/workflows.ts","../src/resources/connections.ts","../src/resources/context/items.ts","../src/resources/context/context.ts","../src/resources/ingested-data.ts","../src/resources/modus/conversations.ts","../src/resources/modus/modus.ts","../src/resources/scopes.ts","../src/resources/suggestions.ts","../src/index.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto'\n\n/** Mint or reuse a non-empty sessionId for agent-host runs. */\nexport function resolveAgentRunSessionId(sessionId?: string | null): string {\n if (typeof sessionId === 'string' && sessionId.trim()) return sessionId.trim()\n return randomUUID()\n}\n","import type {\n AssistantContentResetEvent,\n CancelledEvent,\n DoneEvent,\n ErrorEvent,\n RunEvent,\n StreamTimeoutEvent,\n TokenEvent,\n} from './types/runs.js'\n\nconst SILENTLY_IGNORED = new Set([\n 'heartbeat',\n 'ws_chunk',\n 'unknown',\n 'tool_start',\n 'tool_end',\n 'tool_chunk',\n 'agent_thinking',\n 'warning',\n 'selected_final_content',\n])\n\nfunction parseLine(line: string): Record<string, unknown> | undefined {\n if (!line.startsWith('data:')) return undefined\n const raw = line.slice(5).trimStart()\n if (!raw || raw === '[DONE]') return undefined\n try {\n const data = JSON.parse(raw) as unknown\n if (data && typeof data === 'object' && !Array.isArray(data)) {\n return data as Record<string, unknown>\n }\n } catch {\n return undefined\n }\n return undefined\n}\n\nfunction isAsyncIterable<T>(value: Iterable<T> | AsyncIterable<T>): value is AsyncIterable<T> {\n return Symbol.asyncIterator in Object(value)\n}\n\nfunction* parseData(data: Record<string, unknown>): Generator<RunEvent> {\n const eventType = typeof data.type === 'string' ? data.type : 'unknown'\n\n if (eventType === 'token') {\n const event: TokenEvent = {\n type: 'token',\n content: typeof data.content === 'string' ? data.content : '',\n }\n yield event\n } else if (eventType === 'done') {\n const event: DoneEvent = {\n type: 'done',\n runId: typeof data.runId === 'string' ? data.runId : '',\n threadId: typeof data.threadId === 'string' ? data.threadId : '',\n }\n yield event\n } else if (eventType === 'error') {\n const msg =\n data.error ?? data.message ?? data.content ?? 'Unknown run error'\n const event: ErrorEvent = { type: 'error', message: String(msg) }\n yield event\n } else if (eventType === 'cancelled') {\n const event: CancelledEvent = { type: 'cancelled' }\n yield event\n } else if (eventType === 'stream_timeout') {\n const event: StreamTimeoutEvent = { type: 'stream_timeout' }\n yield event\n } else if (eventType === 'assistant_content_reset') {\n if (typeof data.content !== 'string') return\n const event: AssistantContentResetEvent = {\n type: 'assistant_content_reset',\n content: data.content,\n ...(typeof data.visibleContent === 'string'\n ? { visibleContent: data.visibleContent }\n : {}),\n attempt: typeof data.attempt === 'number' ? data.attempt : 1,\n reason: 'provider_stream_failed',\n }\n yield event\n } else if (!SILENTLY_IGNORED.has(eventType)) {\n // Unknown future event types ignored for forward compatibility.\n return\n }\n}\n\nfunction* parseSyncSseLines(lines: Iterable<string>): Generator<RunEvent> {\n for (const line of lines) {\n const data = parseLine(line)\n if (data !== undefined) yield* parseData(data)\n }\n}\n\nasync function* parseAsyncSseLines(lines: AsyncIterable<string>): AsyncGenerator<RunEvent> {\n for await (const line of lines) {\n const data = parseLine(line)\n if (data !== undefined) yield* parseData(data)\n }\n}\n\n/** Convert raw SSE lines into typed run events (forward-compatible). */\nexport function parseSseStream(lines: Iterable<string>): Generator<RunEvent>\nexport function parseSseStream(lines: AsyncIterable<string>): AsyncGenerator<RunEvent>\nexport function parseSseStream(\n lines: Iterable<string> | AsyncIterable<string>,\n): Generator<RunEvent> | AsyncGenerator<RunEvent> {\n return isAsyncIterable(lines) ? parseAsyncSseLines(lines) : parseSyncSseLines(lines)\n}\n","import {\n ModusError,\n RunCancelledError,\n StreamTimeoutError,\n} from './_exceptions.js'\nimport type { ModusConfig } from './_config.js'\nimport { resolveAgentRunSessionId } from './_agent_run_request.js'\nimport type { HttpClient } from './_http.js'\nimport { parseSseStream } from './_streaming.js'\nimport { validateChatModel, validateId } from './_validation.js'\nimport type { ChatModel, ChatResult } from './types/chat.js'\nimport type { RunEvent } from './types/runs.js'\n\nfunction effectiveThreadId(threadId?: string): string | undefined {\n if (threadId === undefined) return undefined\n if (!threadId.trim()) return undefined\n return threadId\n}\n\nfunction resolveSessionId(threadId?: string): string {\n return resolveAgentRunSessionId(effectiveThreadId(threadId))\n}\n\nfunction chatPath(\n resource: string,\n resourceId: number | string,\n options: { threadId?: string },\n): string {\n const safeId = encodeURIComponent(String(resourceId))\n const tid = effectiveThreadId(options.threadId)\n if (tid !== undefined) {\n const safeTid = encodeURIComponent(tid)\n return `/api/v1/${resource}/${safeId}/conversations/${safeTid}/chat`\n }\n return `/api/v1/${resource}/${safeId}/chat`\n}\n\nfunction modusChatPath(options: { threadId?: string }): string {\n const tid = effectiveThreadId(options.threadId)\n if (tid !== undefined) {\n validateId(tid, 'thread_id')\n return `/api/v1/modus/conversations/${encodeURIComponent(tid)}/chat`\n }\n return `/api/v1/modus/chat`\n}\n\nfunction agentHostRunsPath(\n resource: 'modus' | 'scopes' | 'workflows',\n resourceId?: number | string,\n): string {\n if (resource === 'modus') return '/agent/v1/modus/runs'\n const safeId = encodeURIComponent(String(resourceId))\n return `/agent/v1/${resource}/${safeId}/runs`\n}\n\nfunction chatBody(message: string, model: ChatModel): Record<string, string> {\n return { message, model }\n}\n\nfunction agentRunsBody(\n message: string,\n model: ChatModel,\n options: { sessionId: string; organizationId?: string; version?: string },\n): Record<string, unknown> {\n const body: Record<string, unknown> = {\n message,\n config: { model },\n sessionId: options.sessionId,\n }\n if (options.organizationId !== undefined) {\n body.organizationId = options.organizationId\n }\n if (options.version !== undefined) {\n body.version = options.version\n }\n return body\n}\n\nfunction raiseForEvent(event: RunEvent): RunEvent {\n if (event.type === 'error') throw new ModusError(event.message)\n if (event.type === 'cancelled') throw new RunCancelledError()\n if (event.type === 'stream_timeout') throw new StreamTimeoutError()\n return event\n}\n\n/**\n * Streaming chat session. Iterate {@link ChatStream.textStream} or\n * {@link ChatStream.eventStream}, then call {@link ChatStream.getFinalResult}.\n */\nexport class ChatStream {\n private final?: ChatResult\n private readonly textParts: string[] = []\n\n constructor(\n private readonly http: HttpClient,\n private readonly path: string,\n private readonly body: Record<string, unknown>,\n private readonly baseUrl?: string,\n ) {}\n\n /**\n * Async iterable of assistant text token chunks as they arrive.\n *\n * @returns An async generator yielding partial text strings.\n * @throws {ModusError} When the stream emits an error event.\n * @throws {RunCancelledError} When the run is cancelled.\n * @throws {StreamTimeoutError} When the stream times out.\n */\n async *textStream(): AsyncGenerator<string> {\n for await (const event of this.events(false)) {\n if (event.type === 'token') yield event.content\n }\n }\n\n /**\n * Async iterable of structured run events (tokens, tool calls, done, and so on).\n *\n * @returns An async generator yielding {@link RunEvent} objects.\n * @throws {ModusError} When the stream emits an error event.\n * @throws {RunCancelledError} When the run is cancelled.\n * @throws {StreamTimeoutError} When the stream times out.\n */\n async *eventStream(): AsyncGenerator<RunEvent> {\n yield* this.events(true)\n }\n\n private async *events(supportsReset: boolean): AsyncGenerator<RunEvent> {\n const body = supportsReset\n ? { ...this.body, streamProtocolVersion: 2 }\n : this.body\n for await (const line of this.http.streamPost(this.path, body, {\n baseUrl: this.baseUrl,\n })) {\n for (const event of parseSseStream([line])) {\n const normalized = raiseForEvent(event)\n if (normalized.type === 'token') this.textParts.push(normalized.content)\n if (normalized.type === 'assistant_content_reset') {\n this.textParts.length = 0\n this.textParts.push(normalized.content)\n }\n if (normalized.type === 'done') {\n this.final = {\n content: this.textParts.join(''),\n threadId: normalized.threadId,\n runId: normalized.runId,\n }\n yield normalized\n return\n }\n yield normalized\n }\n }\n }\n\n /**\n * Final chat result after the stream completes.\n *\n * Call only after fully consuming {@link ChatStream.textStream} or\n * {@link ChatStream.eventStream}.\n *\n * @returns The assembled assistant reply, thread id, and run id.\n * @throws {ModusError} When called before the stream finishes with a done event.\n */\n getFinalResult(): ChatResult {\n if (this.final === undefined) {\n throw new ModusError(\n 'Stream ended without a done event; call getFinalResult() only after consuming textStream() or eventStream().',\n )\n }\n return this.final\n }\n}\n\nexport async function chatBuffered(\n http: HttpClient,\n resource: string,\n resourceId: number | string,\n message: string,\n options: { model: ChatModel; threadId?: string },\n): Promise<ChatResult> {\n validateId(resourceId, `${resource}_id`)\n validateChatModel(options.model)\n const path = chatPath(resource, resourceId, {\n threadId: options.threadId,\n })\n const data = await http.post(path, chatBody(message, options.model))\n return data as ChatResult\n}\n\nexport function chatStreamSession(\n http: HttpClient,\n config: ModusConfig,\n resource: 'scopes' | 'workflows',\n resourceId: number | string,\n message: string,\n options: { model: ChatModel; threadId?: string; version?: string },\n): ChatStream {\n validateId(resourceId, `${resource}_id`)\n validateChatModel(options.model)\n const path = agentHostRunsPath(resource, resourceId)\n return new ChatStream(\n http,\n path,\n agentRunsBody(message, options.model, {\n sessionId: resolveSessionId(options.threadId),\n organizationId: config.organizationId,\n version: options.version,\n }),\n config.agentHost,\n )\n}\n\nexport async function modusChatBuffered(\n http: HttpClient,\n message: string,\n options: { model: ChatModel; threadId?: string },\n): Promise<ChatResult> {\n validateChatModel(options.model)\n const path = modusChatPath({ threadId: options.threadId })\n const data = await http.post(path, chatBody(message, options.model))\n return data as ChatResult\n}\n\nexport function modusChatStreamSession(\n http: HttpClient,\n config: ModusConfig,\n message: string,\n options: { model: ChatModel; threadId?: string },\n): ChatStream {\n validateChatModel(options.model)\n return new ChatStream(\n http,\n agentHostRunsPath('modus'),\n agentRunsBody(message, options.model, {\n sessionId: resolveSessionId(options.threadId),\n organizationId: config.organizationId,\n }),\n config.agentHost,\n )\n}\n","import type { components } from '../_generated/v1.js'\n\n/** Canonical public type for a Modus workflow (OpenAPI `WorkflowDto`). */\nexport type Workflow = components['schemas']['WorkflowDto']\n\n/** Runtime + type for workflow kinds (use `WorkflowType.task`, not only as a type). */\nexport const WorkflowType = {\n task: 'task',\n workflow: 'workflow',\n} as const\n\nexport type WorkflowType = (typeof WorkflowType)[keyof typeof WorkflowType]\n\n/** @deprecated Use `Workflow` instead. */\nexport type Agent = Workflow\n/** @deprecated Use `WorkflowType` instead. */\nexport type AgentType = WorkflowType\n/** @deprecated Use `WorkflowType` instead. */\nexport const AgentType = WorkflowType\n","import type { components } from '../_generated/v1.js'\n\nexport type Conversation = components['schemas']['ConversationDto']\nexport type ConversationListItem = components['schemas']['ConversationListItemDto']\nexport type Message = components['schemas']['ConversationMessageDto']\nexport type ConversationKind = 'all' | 'modus' | 'scopes'\n\n/** Scope id for a list item, or undefined for direct Modus chats (scopeId 0). */\nexport function conversationScopeId(item: ConversationListItem): number | undefined {\n return item.scopeId === 0 ? undefined : item.scopeId\n}\n\n/**\n * @deprecated Use `conversationScopeId` instead.\n * Preserves the legacy `0` sentinel for direct Modus chats (unlike\n * `conversationScopeId`, which returns `undefined` for id `0`).\n */\nexport function conversationSkillId(item: ConversationListItem): number | undefined {\n return item.scopeId\n}\n","import { randomUUID } from 'node:crypto'\nimport type { ModusConfig } from '../../_config.js'\nimport { resolveAgentRunSessionId } from '../../_agent_run_request.js'\nimport { ModusError } from '../../_exceptions.js'\nimport type { OperationId } from '../../_generated/operations.js'\nimport {\n formatOperationPath,\n getOperation,\n operationBaseUrl,\n} from '../../_openapi-invoke.js'\nimport type { HttpClient } from '../../_http.js'\nimport { Page, normalizePageToken } from '../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { parseSseStream } from '../../_streaming.js'\nimport { validateId, validatePageSize } from '../../_validation.js'\nimport type {\n AgentRun,\n AgentRunListItem,\n AgentRunCreateRequest,\n ApprovalScope,\n CreateAgentRunRequest,\n ModusRunCreateRequest,\n ResumeRunRequest,\n RunStatus,\n RunTimeframe,\n SkillRunCreateRequest,\n} from '../../types/agent-runs.js'\nimport type { ActiveConversationRun, RunEvent } from '../../types/runs.js'\n\nconst RUNS_MAX_PAGE_SIZE = 100\n\nfunction runsListParams(\n pageSize: number,\n pageToken: string | undefined,\n status?: RunStatus,\n timeframe?: RunTimeframe,\n approvalScope?: ApprovalScope,\n search?: string,\n): Record<string, string | number | boolean | undefined | null> {\n const params: Record<string, string | number | boolean | undefined | null> = { pageSize }\n const token = normalizePageToken(pageToken)\n if (token !== undefined) params.pageToken = token\n if (status !== undefined) params.status = status\n if (timeframe !== undefined) params.timeframe = timeframe\n if (approvalScope !== undefined) params.approvalScope = approvalScope\n if (search !== undefined) params.search = search\n return params\n}\n\nfunction activeRunsParams(\n pageSize: number,\n pageToken: string | undefined,\n): Record<string, string | number> {\n const params: Record<string, string | number> = { pageSize }\n const token = normalizePageToken(pageToken)\n if (token !== undefined) params.pageToken = token\n return params\n}\n\nfunction parseRun(raw: unknown): AgentRun {\n return raw as AgentRun\n}\n\nfunction parseActiveRunsArray(raw: unknown): ActiveConversationRun[] {\n const data = asRecord(raw)\n const runs = data.runs\n if (!Array.isArray(runs)) {\n throw new ModusError(\n `Unexpected active runs response shape: runs must be a list, got ${typeof runs}.`,\n )\n }\n return runs as ActiveConversationRun[]\n}\n\nfunction parseActiveRunsPage(\n raw: unknown,\n fetchPage: (token: string) => Promise<Page<ActiveConversationRun>>,\n): Page<ActiveConversationRun> {\n const data = asRecord(raw)\n const runs = data.runs\n if (!Array.isArray(runs)) {\n throw new ModusError(\n `Unexpected active runs response shape: runs must be a list, got ${typeof runs}.`,\n )\n }\n return new Page(\n runs as ActiveConversationRun[],\n normalizePageToken(\n typeof data.nextPageToken === 'string' ? data.nextPageToken : undefined,\n ),\n fetchPage,\n )\n}\n\nfunction randomRunId(): string {\n return randomUUID()\n}\n\nfunction sessionIdFromBody(body: { sessionId?: string }): string {\n return resolveAgentRunSessionId(body.sessionId)\n}\n\nexport interface AgentRunStream extends AsyncIterable<RunEvent> {\n readonly runId: string\n readonly events: AsyncIterable<RunEvent>\n}\n\nexport function makeAgentRunStream(runId: string, events: AsyncIterable<RunEvent>): AgentRunStream {\n return {\n runId,\n events,\n [Symbol.asyncIterator]() {\n return events[Symbol.asyncIterator]()\n },\n }\n}\n\n/**\n * Start, inspect, and control workflow runs.\n *\n * Typical path: `create` (or `createScope` / `createModus`) → stream events →\n * `list` / `get` history → `cancel` or `resume` when needed.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.create(workflowId, {\n * message: \"Summarize yesterday's sales\",\n * config: { model: 'claude-sonnet-5' },\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\nexport class WorkflowRunsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List runs for a workflow.\n *\n * @param workflowId - Workflow id or slug.\n * @param options.pageSize - Maximum items per page (default 25, max 100).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.status - Filter by run status.\n * @param options.timeframe - Filter by recency (`last_hour`, `last_day`, or `last_week`).\n * @param options.approvalScope - Filter approval-related runs (`mine` or `all`).\n * @param options.search - Free-text search filter.\n * @returns A page of run summaries — use `.autoPagingIter()` for all pages.\n *\n * @example\n * ```ts\n * for await (const run of (\n * await client.workflows.runs.list(workflowId, { status: 'completed' })\n * ).autoPagingIter()) {\n * console.log(run.workflowId, run.status, run.startedAt)\n * }\n * ```\n */\n list(\n workflowId: number | string,\n options: {\n pageSize?: number\n pageToken?: string\n status?: RunStatus\n timeframe?: RunTimeframe\n approvalScope?: ApprovalScope\n search?: string\n } = {},\n ): Promise<Page<AgentRunListItem>> {\n validateId(workflowId, 'workflow_id')\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize, RUNS_MAX_PAGE_SIZE)\n return this.listPage(workflowId, pageSize, options.pageToken, options)\n }\n\n private async listPage(\n workflowId: number | string,\n pageSize: number,\n pageToken: string | undefined,\n filters: {\n status?: RunStatus\n timeframe?: RunTimeframe\n approvalScope?: ApprovalScope\n search?: string\n },\n ): Promise<Page<AgentRunListItem>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'WorkflowRunsController_list', {\n pathParams: { id: workflowId },\n query: runsListParams(\n pageSize,\n pageToken,\n filters.status,\n filters.timeframe,\n filters.approvalScope,\n filters.search,\n ),\n }),\n )\n const runs = data.runs\n if (!Array.isArray(runs)) {\n throw new ModusError(\n `Unexpected list response shape: runs must be a list, got ${typeof runs}.`,\n )\n }\n return new Page(\n runs as AgentRunListItem[],\n normalizePageToken(\n typeof data.nextPageToken === 'string' ? data.nextPageToken : undefined,\n ),\n (token: string) => this.listPage(workflowId, pageSize, token, filters),\n )\n }\n\n /**\n * Retrieve a workflow run by id.\n *\n * @param workflowId - Workflow id or slug the run belongs to.\n * @param runId - Run id (the list row's `workflowId` field, not the composite `id`).\n * @param options.temporalRunId - Optional internal execution id when disambiguating retries.\n * @returns Run details including status and output.\n * @throws {NotFoundError} When the run does not exist.\n *\n * @example\n * ```ts\n * const run = await client.workflows.runs.get(workflowId, runId)\n * console.log(run.status)\n * ```\n */\n async get(\n workflowId: number | string,\n runId: string,\n options: { temporalRunId?: string } = {},\n ): Promise<AgentRun> {\n validateId(workflowId, 'workflow_id')\n if (!runId.trim()) throw new Error('run_id must be a non-empty string')\n const query =\n options.temporalRunId !== undefined\n ? { temporalRunId: options.temporalRunId }\n : undefined\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowRunsController_get', {\n pathParams: { id: workflowId, runId },\n query,\n })\n return parseRun(data)\n }\n\n /**\n * Start a workflow run and stream run events.\n *\n * @param workflowId - Workflow id or slug to run.\n * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events (tokens, completion, errors, and related signals).\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.create(workflowId, {\n * message: \"Summarize yesterday's sales\",\n * config: { model: 'claude-sonnet-5' },\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * if (event.type === 'done') break\n * }\n * ```\n */\n create(\n workflowId: number | string,\n body: CreateAgentRunRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n validateId(workflowId, 'workflow_id')\n return this.createRun('WorkflowRunsController_create', body, { id: workflowId }, options)\n }\n\n /**\n * Start a scope run and stream run events.\n *\n * Same event stream shape as {@link create}, but targets a published scope.\n *\n * @param scopeId - Scope id to run.\n * @param body - Run body (`message`, optional `sessionId`, optional `version` as `published` or `draft`).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.createScope(scopeId, {\n * message: 'What is our ARR trend?',\n * config: { model: 'claude-sonnet-5' },\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\n createScope(\n scopeId: number | string,\n body: SkillRunCreateRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n validateId(scopeId, 'scope_id')\n return this.createRun('ScopeRunsController_create', body, { id: scopeId }, options)\n }\n\n /**\n * Start a Modus org-assistant run and stream run events.\n *\n * @param body - Run body (`message`, optional `sessionId`, optional `subordinateSkillIds` to narrow context).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.createModus({\n * message: 'Summarize ARR in three bullets.',\n * config: { model: 'claude-sonnet-5' },\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\n createModus(\n body: ModusRunCreateRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n return this.createRun('ModusRunsController_create', body, {}, options)\n }\n\n /**\n * Resume an interrupted run and stream run events.\n *\n * @param runId - Run id to resume.\n * @param body - Resume body (`message`, `sessionId`, and `decision`: `approve` / `deny` / `connected` / `cancelled`).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.resume(runId, {\n * decision: 'approve',\n * message: 'Looks good — continue.',\n * sessionId,\n * })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\n resume(\n runId: string,\n body: ResumeRunRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n validateId(runId, 'run_id')\n return this.createRun('ResumeRunsController_create', body, { runId }, options)\n }\n\n /**\n * Cancel a run that is still in progress.\n *\n * @param runId - Run id to cancel.\n *\n * @example\n * ```ts\n * await client.workflows.runs.cancel(runId)\n * ```\n */\n async cancel(runId: string): Promise<void> {\n validateId(runId, 'run_id')\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_cancel', {\n pathParams: { runId },\n jsonBody: {},\n })\n }\n\n /**\n * Fetch stored run events for a run.\n *\n * @param runId - Run id.\n * @returns Run event history for replay or inspection.\n */\n async events(runId: string): Promise<unknown> {\n validateId(runId, 'run_id')\n return invokeWithRetry(this.config, this.http, 'RunLifecycleController_events', {\n pathParams: { runId },\n })\n }\n\n /**\n * Request a graceful stop for a running execution.\n *\n * @param runId - Run id to interrupt.\n */\n async interrupt(runId: string): Promise<void> {\n validateId(runId, 'run_id')\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_interrupt', {\n pathParams: { runId },\n jsonBody: {},\n })\n }\n\n /**\n * Move a queued run back into an editable state before it starts.\n *\n * @param runId - Queued run id.\n */\n async editQueued(runId: string): Promise<void> {\n validateId(runId, 'run_id')\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_editQueued', {\n pathParams: { runId },\n jsonBody: {},\n })\n }\n\n /**\n * List active conversation runs across the organization.\n *\n * @param options.pageSize - Maximum items per page (default 50, max 100).\n * @param options.pageToken - Opaque token from a previous page.\n * @returns A page of active runs with session and status metadata.\n */\n active(options: {\n pageSize?: number\n pageToken?: string\n } = {}): Promise<Page<ActiveConversationRun>> {\n const pageSize = options.pageSize ?? 50\n validatePageSize(pageSize, RUNS_MAX_PAGE_SIZE)\n return this.activePage(pageSize, options.pageToken)\n }\n\n private async activePage(\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<ActiveConversationRun>> {\n return parseActiveRunsPage(\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_active', {\n query: activeRunsParams(pageSize, pageToken),\n }),\n (token: string) => this.activePage(pageSize, token),\n )\n }\n\n /**\n * Look up active runs for specific conversation sessions.\n *\n * @param sessionIds - Up to 100 session ids.\n * @returns Active runs matching any of the given sessions.\n * @throws {Error} When more than 100 session ids are provided.\n */\n async activeBySession(sessionIds: readonly string[]): Promise<ActiveConversationRun[]> {\n const uniqueSessionIds = [...new Set(sessionIds.map((id) => id.trim()).filter(Boolean))]\n if (uniqueSessionIds.length > 100) {\n throw new Error('sessionIds must contain at most 100 ids')\n }\n return parseActiveRunsArray(\n await invokeWithRetry(this.config, this.http, 'RunLifecycleController_activeBySession', {\n jsonBody: { sessionIds: uniqueSessionIds },\n }),\n )\n }\n\n /**\n * Reconnect to an in-progress run and stream run events.\n *\n * @param runId - Run id to follow.\n * @param options.lastEventId - Resume after this event id when catching up.\n * @returns A stream of run events from the current execution point.\n *\n * @example\n * ```ts\n * const stream = client.workflows.runs.stream(runId, { lastEventId: checkpoint })\n * for await (const event of stream) {\n * if (event.type === 'token') process.stdout.write(event.content)\n * }\n * ```\n */\n stream(runId: string, options: { lastEventId?: string } = {}): AgentRunStream {\n validateId(runId, 'run_id')\n const op = getOperation('RunLifecycleController_stream')\n const path = formatOperationPath('RunLifecycleController_stream', { runId })\n const lines = this.http.streamGet(path, undefined, {\n baseUrl: operationBaseUrl(this.http, op),\n headers: options.lastEventId ? { 'Last-Event-ID': options.lastEventId } : undefined,\n })\n return makeAgentRunStream(runId, this.parseEvents(lines))\n }\n\n private createRun(\n operationId: OperationId,\n body: AgentRunCreateRequest | SkillRunCreateRequest | ModusRunCreateRequest | ResumeRunRequest,\n pathParams: Record<string, unknown>,\n options: { idempotencyKey?: string },\n ): AgentRunStream {\n const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId()\n const sessionId = sessionIdFromBody(body as { sessionId?: string })\n const op = getOperation(operationId)\n const path = formatOperationPath(operationId, pathParams)\n const lines = this.http.streamPost(path, {\n ...body,\n sessionId,\n streamProtocolVersion: 2,\n }, {\n baseUrl: operationBaseUrl(this.http, op),\n headers: { 'Idempotency-Key': runId },\n })\n return makeAgentRunStream(runId, this.parseEvents(lines))\n }\n\n private async *parseEvents(lines: AsyncIterable<string>): AsyncGenerator<RunEvent> {\n yield* parseSseStream(lines)\n }\n}\n","import { randomUUID } from 'node:crypto'\nimport type { ModusConfig } from '../../_config.js'\nimport {\n formatOperationPath,\n getOperation,\n operationBaseUrl,\n} from '../../_openapi-invoke.js'\nimport type { HttpClient } from '../../_http.js'\nimport { invokeWithRetry } from '../../_request.js'\nimport { parseSseStream } from '../../_streaming.js'\nimport { validateId } from '../../_validation.js'\nimport type { WorkflowActionRequest } from '../../types/agent-runs.js'\nimport type { RunEvent } from '../../types/runs.js'\nimport { makeAgentRunStream, type AgentRunStream } from './runs.js'\n\nfunction randomRunId(): string {\n return randomUUID()\n}\n\nexport class AgentWorkflowActionsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * Execute a workflow action and stream run events.\n *\n * @param body - Action body (`organizationId`, `sessionId`, `workflowAction`, optional `previousOutputs`).\n * @param options.idempotencyKey - Client-supplied idempotency key; defaults to `body.runId` or a new uuid.\n * @returns A stream of run events for the action execution.\n */\n execute(\n body: WorkflowActionRequest,\n options: { idempotencyKey?: string } = {},\n ): AgentRunStream {\n const runId = options.idempotencyKey?.trim() || body.runId?.trim() || randomRunId()\n const op = getOperation('WorkflowActionsController_execute')\n const path = formatOperationPath('WorkflowActionsController_execute')\n const lines = this.http.streamPost(path, body, {\n baseUrl: operationBaseUrl(this.http, op),\n headers: { 'Idempotency-Key': runId },\n })\n return makeAgentRunStream(runId, this.parseEvents(lines))\n }\n\n /**\n * Cancel a workflow action run.\n *\n * @param runId - Action run id to cancel.\n */\n async cancel(runId: string): Promise<void> {\n validateId(runId, 'run_id')\n await invokeWithRetry(this.config, this.http, 'WorkflowActionsController_cancel', {\n pathParams: { runId },\n jsonBody: {},\n })\n }\n\n private async *parseEvents(lines: AsyncIterable<string>): AsyncGenerator<RunEvent> {\n yield* parseSseStream(lines)\n }\n}\n","import type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../_request.js'\nimport { validateId, validatePageSize } from '../_validation.js'\nimport type { Workflow, WorkflowType } from '../types/workflows.js'\nimport type { VariationView } from '../types/views.js'\nimport { WorkflowRunsResource } from './workflows/runs.js'\nimport { AgentWorkflowActionsResource } from './workflows/workflow-actions.js'\n\nfunction workflowsListParams(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n type?: WorkflowType,\n view?: VariationView,\n includeVariation?: boolean,\n): Record<string, string | number | boolean | undefined | null> {\n const extra: Record<string, string | number | boolean | undefined | null> = {}\n if (search !== undefined) extra.search = search\n if (type !== undefined) extra.type = type\n if (view !== undefined) extra.view = view\n if (includeVariation !== undefined) extra.includeVariation = includeVariation\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >\n}\n\nfunction parseWorkflow(raw: unknown): Workflow {\n return raw as Workflow\n}\n\n/**\n * Read and run access to Modus workflows.\n *\n * - `list` / `get` — browse workflows (`view: 'active'` or `'draft'`)\n * - {@link WorkflowRunsResource runs} — start, monitor, and control workflow runs\n * - {@link AgentWorkflowActionsResource workflowActions} — execute workflow actions\n *\n * @example\n * ```ts\n * import { Modus } from '@getmodus/sdk'\n * const client = new Modus()\n * for await (const wf of (await client.workflows.list()).autoPagingIter()) {\n * console.log(wf.id, wf.name, wf.status)\n * }\n * ```\n */\nexport class WorkflowsResource {\n readonly runs: WorkflowRunsResource\n readonly workflowActions: AgentWorkflowActionsResource\n\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {\n this.runs = new WorkflowRunsResource(http, config)\n this.workflowActions = new AgentWorkflowActionsResource(http, config)\n }\n\n /**\n * List workflows in the organisation.\n *\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.search - Case-insensitive substring filter on the workflow name.\n * @param options.type - Workflow kind: `\"task\"` or `\"workflow\"`.\n * @param options.view - Which saved version to return (`active` or `draft`).\n * @param options.includeVariation - Include variation metadata when supported.\n * @returns A page of workflows — use `.autoPagingIter()` for all pages.\n *\n * @example\n * ```ts\n * for await (const wf of (await client.workflows.list({ search: 'digest' })).autoPagingIter()) {\n * console.log(wf.id, wf.name, wf.status)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n search?: string\n type?: WorkflowType\n view?: VariationView\n includeVariation?: boolean\n } = {}): Promise<Page<Workflow>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(\n pageSize,\n options.pageToken,\n options.search,\n options.type,\n options.view,\n options.includeVariation,\n )\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n type?: WorkflowType,\n view?: VariationView,\n includeVariation?: boolean,\n ): Promise<Page<Workflow>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'WorkflowsController_list', {\n query: workflowsListParams(\n pageSize,\n pageToken,\n search,\n type,\n view,\n includeVariation,\n ),\n }),\n )\n // List responses require the canonical `workflows` key (dual `agents` envelope removed).\n return buildAipPage(\n data,\n 'workflows',\n parseWorkflow,\n (token) => this.listPage(pageSize, token, search, type, view, includeVariation),\n )\n }\n\n /**\n * Retrieve a workflow by ID or slug.\n *\n * @param workflowId - Numeric id or slug.\n * @param options.view - Which saved version to return (`active` or `draft`).\n * @param options.includeVariation - Include variation metadata when supported.\n * @returns The workflow (`id`, `name`, `status`, …).\n * @throws {NotFoundError} When no workflow matches the id or slug.\n *\n * @example\n * ```ts\n * const wf = await client.workflows.get('weekly-digest')\n * console.log(wf.name, wf.status)\n * ```\n */\n async get(\n workflowId: number | string,\n options: { view?: VariationView; includeVariation?: boolean } = {},\n ): Promise<Workflow> {\n validateId(workflowId, 'workflow_id')\n const query: Record<string, string | boolean> = {}\n if (options.view !== undefined) query.view = options.view\n if (options.includeVariation !== undefined) {\n query.includeVariation = options.includeVariation\n }\n const data = await invokeWithRetry(this.config, this.http, 'WorkflowsController_get', {\n pathParams: { id: workflowId },\n query: Object.keys(query).length > 0 ? query : undefined,\n })\n return parseWorkflow(data)\n }\n}\n","import type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../_request.js'\nimport { validatePageSize } from '../_validation.js'\nimport type { Connection } from '../types/connections.js'\n\nfunction connectionsListParams(\n pageSize: number,\n pageToken: string | undefined,\n type?: string,\n): Record<string, string | number | boolean | undefined | null> {\n const extra: Record<string, string | number | boolean | undefined | null> = {}\n if (type !== undefined) extra.type = type\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >\n}\n\nfunction parseConnection(raw: unknown): Connection {\n return raw as Connection\n}\n\n/**\n * Read access to integration connections.\n */\nexport class ConnectionsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List integration connections.\n *\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.type - Integration category; exact match filter.\n * @returns A page of connections.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n type?: string\n } = {}): Promise<Page<Connection>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.type)\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n type?: string,\n ): Promise<Page<Connection>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ConnectionsController_list', {\n query: connectionsListParams(pageSize, pageToken, type),\n }),\n )\n return buildAipPage(data, 'connections', parseConnection, (token) =>\n this.listPage(pageSize, token, type),\n )\n }\n\n /**\n * Find the first connection whose name matches (case-insensitive).\n *\n * Pages through {@link ConnectionsResource.list} until a match is found.\n *\n * @param options.name - Connection name to search for.\n * @param options.type - Optional integration category filter.\n * @param options.pageSize - Page size when scanning (default 25).\n * @returns The matching connection, or `undefined` if none is found.\n */\n async find(options: {\n name: string\n type?: string\n pageSize?: number\n }): Promise<Connection | undefined> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n const target = options.name.trim().toLowerCase()\n let token: string | undefined\n do {\n const page = await this.listPage(pageSize, token, options.type)\n const match = page.items.find((c) => c.name?.toLowerCase() === target)\n if (match) return match\n if (!page.hasNextPage()) break\n token = page.nextPageToken\n } while (token !== undefined)\n return undefined\n }\n}\n","import type { ModusConfig } from '../../_config.js'\nimport { NotFoundError } from '../../_exceptions.js'\nimport type { HttpClient } from '../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../_pagination.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../../_request.js'\nimport { DEFAULT_MAX_PAGE_SIZE, validatePageSize } from '../../_validation.js'\nimport type { ContextItem, ContextItemLookupRow } from '../../types/context.js'\nimport type { ContextValueRow } from '../../types/context-values.js'\nimport type { ContentProjection, JsonObjectInput } from '../../types/json-blob.js'\n\nfunction contextListParams(\n pageSize: number,\n pageToken: string | undefined,\n filters: ListContextItemsFilters = {},\n): Record<string, string | number | boolean | readonly string[] | undefined | null> {\n const extra: Record<string, string | readonly string[]> = {}\n if (filters.contextType !== undefined) extra.contextTypes = [filters.contextType]\n if (filters.parentUids !== undefined) {\n extra.parentUids = filters.parentUids.length === 0 ? '' : [...filters.parentUids]\n }\n if (filters.ancestorUids !== undefined) {\n extra.ancestorUids = filters.ancestorUids.length === 0 ? '' : [...filters.ancestorUids]\n }\n if (filters.connectionIds !== undefined) {\n extra.connectionIds = filters.connectionIds.length === 0 ? '' : [...filters.connectionIds]\n }\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | readonly string[] | undefined | null\n >\n}\n\ntype ListContextItemsFilters = {\n contextType?: string\n parentUids?: readonly string[]\n ancestorUids?: readonly string[]\n connectionIds?: readonly string[]\n}\n\nfunction parseContextItem(raw: unknown): ContextItem {\n return raw as ContextItem\n}\n\nfunction parseContextValueRow(raw: unknown): ContextValueRow {\n return raw as ContextValueRow\n}\n\nfunction parseLookupResponse(raw: Record<string, unknown>): ContextItemLookupRow | undefined {\n const item = raw.item\n if (item === null || item === undefined) return undefined\n return item as ContextItemLookupRow\n}\n\n/**\n * Read the org knowledge base (notes, metrics, saved queries, integration items).\n *\n * Use `client.context.items` after `new Modus()`. Prefer `list` / `get` /\n * `lookup` for discovery; use `listValues` when a field holds a large array\n * inside `content`.\n *\n * @example\n * ```ts\n * import { Modus } from '@getmodus/sdk'\n * const client = new Modus()\n * for await (const item of (await client.context.items.list({ pageSize: 25 })).autoPagingIter()) {\n * console.log(item.contextType, item.description ?? item.uid)\n * }\n * ```\n */\nexport class ContextItemsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List knowledge-base items.\n *\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.contextType - Filter to a single context type (e.g. `\"note\"`).\n * @param options.parentUids - Exact ordered native ancestry chain for direct\n * children. Omit to leave parent unrestricted; pass `[]` for the known-empty\n * root. Native UIDs are exact tokens (including whitespace); do not use the\n * hashed context-item `uid`. For a folder's children, send that item's\n * `ancestry` UIDs plus its last `dataPath` token.\n * @param options.ancestorUids - Ordered UID ancestry prefix for strict\n * descendants. Omit to leave unrestricted; pass `[]` for every item with\n * non-null ancestry.\n * @param options.connectionIds - Restrict to these connection ids. Omit to\n * leave unfiltered; pass `[]` to match none. The Files root is\n * `connectionIds: ['files']` with `parentUids: []`.\n * @returns A page of context items — use `.autoPagingIter()` for all pages.\n *\n * @example\n * ```ts\n * const notes = await client.context.items.list({ contextType: 'note', pageSize: 50 })\n * for (const item of notes.items) {\n * console.log(item.description ?? item.uid, item.uid)\n * }\n * ```\n *\n * @example\n * ```ts\n * const rootFolders = await client.context.items.list({\n * connectionIds: ['files'],\n * contextType: 'file_folder_metadata',\n * parentUids: [],\n * })\n * const folder = rootFolders.items[0]\n * const nativeUid = folder?.dataPath?.at(-1)\n * // Known ancestry only — never treat null/omitted ancestry as a root chain.\n * if (folder?.ancestry != null && nativeUid !== undefined) {\n * const filesInFolder = await client.context.items.list({\n * connectionIds: ['files'],\n * contextType: 'file_upload',\n * parentUids: [...folder.ancestry.map((a) => a.uid), nativeUid],\n * })\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n contextType?: string\n parentUids?: readonly string[]\n ancestorUids?: readonly string[]\n connectionIds?: readonly string[]\n } = {}): Promise<Page<ContextItem>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, {\n contextType: options.contextType,\n parentUids: options.parentUids,\n ancestorUids: options.ancestorUids,\n connectionIds: options.connectionIds,\n })\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n filters: ListContextItemsFilters,\n ): Promise<Page<ContextItem>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_list', {\n query: contextListParams(pageSize, pageToken, filters),\n }),\n )\n return buildAipPage(data, 'contextItems', parseContextItem, (token) =>\n this.listPage(pageSize, token, filters),\n )\n }\n\n /**\n * Retrieve a knowledge-base item by uid.\n *\n * @param uid - Item uid.\n * @returns The context item (`uid`, `contextType`, `content`, …).\n * @throws {NotFoundError} When no item matches the uid.\n *\n * @example\n * ```ts\n * const item = await client.context.items.get(uid)\n * console.log(item.contextType, item.description ?? item.uid)\n * ```\n */\n async get(uid: string): Promise<ContextItem> {\n const data = await invokeWithRetry(this.config, this.http, 'ContextItemsController_get', {\n pathParams: { uid },\n })\n return parseContextItem(data)\n }\n\n /**\n * Look up a knowledge-base item by type and data path.\n *\n * @param options.contextType - Context type to match (e.g. `\"note\"`).\n * @param options.dataPath - Hierarchical path segments that identify the item.\n * @param options.contentProjection - Optional fields to include from item content.\n * @returns The matching row, or `undefined` when no item is found (404).\n *\n * @example\n * ```ts\n * const found = await client.context.items.lookup({\n * contextType: 'note',\n * dataPath: ['finance', 'arr-definition'],\n * })\n * if (found) console.log(found.uid, found.description ?? found.uid)\n * ```\n */\n async lookup(options: {\n contextType: string\n dataPath: string[]\n contentProjection?: JsonObjectInput | ContentProjection\n }): Promise<ContextItemLookupRow | undefined> {\n const body = omitUndefined({\n contextType: options.contextType,\n dataPath: options.dataPath,\n contentProjection: options.contentProjection,\n })\n try {\n const raw = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_lookup', {\n jsonBody: body,\n }),\n )\n return parseLookupResponse(raw)\n } catch (error) {\n if (error instanceof NotFoundError) return undefined\n throw error\n }\n }\n\n /**\n * List values stored under a content key on a context item.\n *\n * @param uid - Item uid.\n * @param contextType - Context type of the item.\n * @param contentKeyPath - Dot path to the value field inside item content (e.g. `\"enumValues\"`).\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @returns A page of value rows.\n *\n * @example\n * ```ts\n * // Replace PLACEHOLDER_UID with a real uid whose content has enumValues.\n * const page = await client.context.items.listValues(\n * 'PLACEHOLDER_UID',\n * 'table_column',\n * 'enumValues',\n * { pageSize: 25 },\n * )\n * for (const row of page.items) console.log(row)\n * ```\n */\n listValues(\n uid: string,\n contextType: string,\n contentKeyPath: string,\n options: { pageSize?: number; pageToken?: string } = {},\n ): Promise<Page<ContextValueRow>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize, DEFAULT_MAX_PAGE_SIZE)\n return this.listValuesPage(uid, contextType, contentKeyPath, pageSize, options.pageToken)\n }\n\n /**\n * List values for a context item already loaded via {@link ContextItemsResource.list} or {@link ContextItemsResource.get}.\n *\n * @param item - Context item (uses `item.uid` and `item.contextType`).\n * @param contentKeyPath - Dot path to the value field inside item content.\n * @param options.pageSize - Maximum items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @returns A page of value rows.\n *\n * @example\n * ```ts\n * // Replace PLACEHOLDER_UID with a real uid that has enumValues in content.\n * const item = await client.context.items.get('PLACEHOLDER_UID')\n * const page = await client.context.items.listValuesFor(item, 'enumValues')\n * for (const row of page.items) console.log(row)\n * ```\n */\n listValuesFor(\n item: ContextItem,\n contentKeyPath: string,\n options: { pageSize?: number; pageToken?: string } = {},\n ): Promise<Page<ContextValueRow>> {\n return this.listValues(item.uid, item.contextType, contentKeyPath, options)\n }\n\n private async listValuesPage(\n uid: string,\n contextType: string,\n contentKeyPath: string,\n pageSize: number,\n pageToken: string | undefined,\n ): Promise<Page<ContextValueRow>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ContextItemsController_listValues', {\n pathParams: { uid },\n query: aipListParams(pageSize, pageToken, {\n contextType,\n contentKeyPath,\n }) as Record<string, string | number | boolean | undefined | null>,\n }),\n )\n return buildAipPage(data, 'values', parseContextValueRow, (token) =>\n this.listValuesPage(uid, contextType, contentKeyPath, pageSize, token),\n )\n }\n}\n","import type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { CustomContextItemsResource } from './custom-items.js'\nimport { ContextItemsResource } from './items.js'\n\n/**\n * Read access to the Modus knowledge base.\n *\n * - {@link ContextItemsResource items} — list and look up indexed knowledge-base items.\n * - {@link CustomContextItemsResource customItems} — create and manage custom context items.\n *\n * Call path: `client.context` after `new Modus(...)`.\n */\nexport class ContextResource {\n readonly items: ContextItemsResource\n readonly customItems: CustomContextItemsResource\n\n /** @internal */\n constructor(http: HttpClient, config: ModusConfig) {\n this.items = new ContextItemsResource(http, config)\n this.customItems = new CustomContextItemsResource(http, config)\n }\n}\n","import type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { invokeWithRetry } from '../_request.js'\nimport type {\n IngestedDataUploadResult,\n UploadIngestedDataOptions,\n} from '../types/ingested-data.js'\n\n/** Store exact integration requests and responses as immutable ingested data. */\nexport class IngestedDataResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * Store a complete SQL or HTTP request and response exactly once.\n *\n * Identity covers the complete organization, integration, request, and response\n * content. A duplicate raises `ConflictError`, which means the identical payload\n * is already stored and may be treated as a safe retry outcome.\n *\n * @param options.integrationType - Canonical Modus integration identifier.\n * @param options.request - Exact SQL or HTTP request that produced the response.\n * @param options.response - Response format, optional source HTTP status, and exact string content. SQL requires CSV.\n * @returns The checksum of the stored envelope.\n * @throws {ConflictError} When the complete payload is already stored.\n *\n * @example\n * ```ts\n * const stored = await client.ingestedData.upload({\n * integrationType: 'generic',\n * request: { type: 'sql', query: 'SELECT id, total FROM orders' },\n * response: { format: 'csv', content: 'id,total\\n1,42.00\\n' },\n * })\n * console.log(stored.checksum)\n * ```\n */\n async upload(options: UploadIngestedDataOptions): Promise<IngestedDataUploadResult> {\n const data = await invokeWithRetry(this.config, this.http, 'IngestedDataController_upload', {\n jsonBody: {\n integration_type: options.integrationType,\n request: options.request,\n response: options.response,\n },\n })\n return data as IngestedDataUploadResult\n }\n}\n","import type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../../_request.js'\nimport { validateId, validatePageSize } from '../../_validation.js'\nimport type {\n Conversation,\n ConversationKind,\n ConversationListItem,\n} from '../../types/conversations.js'\n\nconst ALLOWED_KINDS = new Set<ConversationKind>(['all', 'modus', 'scopes'])\n\nfunction listParams(\n pageSize: number,\n pageToken: string | undefined,\n kind?: ConversationKind,\n source?: string,\n sourceRef?: string,\n): Record<string, string | number | boolean | undefined | null> {\n if (kind !== undefined && !ALLOWED_KINDS.has(kind)) {\n throw new Error(\n `kind must be one of ${[...ALLOWED_KINDS].sort().join(', ')}, got ${JSON.stringify(kind)}`,\n )\n }\n const extra: Record<string, string> = {}\n if (kind !== undefined) extra.kind = kind\n if (source !== undefined) extra.source = source\n if (sourceRef !== undefined) extra.sourceRef = sourceRef\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >\n}\n\nfunction parseListItem(raw: unknown): ConversationListItem {\n return raw as ConversationListItem\n}\n\nfunction parseConversation(raw: unknown): Conversation {\n return raw as Conversation\n}\n\n/** List and retrieve Modus / scope conversations. */\nexport class ModusConversationsResource {\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List conversations.\n *\n * @param options.pageSize - Items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.kind - `\"modus\"`, `\"scopes\"`, or `\"all\"`.\n * @param options.source - Restrict to conversations started from this UI surface\n * (e.g. `\"context_chat\"`, `\"dashboard_copilot\"`, `\"slack\"`). Only valid with an\n * omitted `kind` or `kind: \"all\"`; the API throws an `UnprocessableError` (422)\n * if combined with `kind: \"modus\"` or `kind: \"scopes\"`.\n * @param options.sourceRef - Narrow `source` to one instance of that surface — for\n * `\"dashboard_copilot\"`, a dashboard id. Requires `source`; the API throws an\n * `UnprocessableError` (422) if sent on its own. Conversations recorded before\n * this filter shipped carry no instance key and never match it.\n * @returns Page of conversation list items.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n kind?: ConversationKind\n source?: string\n sourceRef?: string\n } = {}): Promise<Page<ConversationListItem>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(pageSize, options.pageToken, options.kind, options.source, options.sourceRef)\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n kind?: ConversationKind,\n source?: string,\n sourceRef?: string,\n ): Promise<Page<ConversationListItem>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ModusConversationsController_list', {\n query: listParams(pageSize, pageToken, kind, source, sourceRef),\n }),\n )\n return buildAipPage(data, 'conversations', parseListItem, (token) =>\n this.listPage(pageSize, token, kind, source, sourceRef),\n )\n }\n\n /**\n * Retrieve a conversation thread with full message history.\n *\n * @param threadId - Conversation thread id.\n * @returns Conversation with messages.\n */\n async get(threadId: string): Promise<Conversation> {\n validateId(threadId, 'thread_id')\n const data = await invokeWithRetry(this.config, this.http, 'ModusConversationsController_get', {\n pathParams: { threadId },\n })\n return parseConversation(data)\n }\n}\n","import { modusChatBuffered, modusChatStreamSession, type ChatStream } from '../../_chat.js'\nimport type { ModusConfig } from '../../_config.js'\nimport type { HttpClient } from '../../_http.js'\nimport { invokeWithRetry, omitUndefined } from '../../_request.js'\nimport type { ChatModel, ChatResult } from '../../types/chat.js'\nimport type { ModusContextComposition } from '../../types/context-compose.js'\n\nimport { ModusConversationsResource } from './conversations.js'\n\n/**\n * Org-wide Modus assistant (full environment context and tools).\n *\n * Prefer `client.modus` over `client.scopes` when the question is not tied to one\n * published scope. Construct with `new Modus()` (reads `MODUS_API_KEY`).\n *\n * - `chat` — one complete reply\n * - `chatStream` — print tokens as they arrive (consume `textStream()`)\n * - `getContext` — preview composed context without a chat turn\n * - `conversations` — list/get prior Modus threads\n *\n * @example\n * ```ts\n * import { Modus } from '@getmodus/sdk'\n * const client = new Modus()\n * const result = await client.modus.chat('What tables describe revenue?', {\n * model: 'claude-sonnet-5',\n * })\n * console.log(result.content, result.threadId)\n * ```\n */\nexport class ModusResource {\n readonly conversations: ModusConversationsResource\n\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {\n this.conversations = new ModusConversationsResource(http, config)\n }\n\n /**\n * Compose full-environment context for an intent without running chat.\n *\n * @param message - Natural-language intent used to select context.\n * @param options.limit - Maximum context items to return. Omit to return all selected items.\n * @returns Composition metadata (counts / session id). Use `chat` for a reply.\n *\n * @example\n * ```ts\n * const ctx = await client.modus.getContext('What tables describe revenue?', { limit: 5 })\n * console.log(ctx.originalCount, ctx.sessionId)\n * ```\n */\n async getContext(\n message: string,\n options: { limit?: number } = {},\n ): Promise<ModusContextComposition> {\n const data = await invokeWithRetry(this.config, this.http, 'ModusContextController_compose', {\n jsonBody: omitUndefined({ message, limit: options.limit }),\n })\n return data as ModusContextComposition\n }\n\n /**\n * Send a message to Modus and wait for the complete reply.\n *\n * @param message - User message text.\n * @param options.model - Required model id (e.g. `\"claude-sonnet-5\"`).\n * @param options.threadId - Continue an existing conversation; omit to start new.\n * @returns Chat result: `content`, `threadId` (for follow-ups), `runId`.\n *\n * @example\n * ```ts\n * const result = await client.modus.chat('What tables describe revenue?', {\n * model: 'claude-sonnet-5',\n * })\n * console.log(result.content, result.threadId)\n * const follow = await client.modus.chat('Break that down by region.', {\n * model: 'claude-sonnet-5',\n * threadId: result.threadId,\n * })\n * ```\n */\n chat(message: string, options: { model: ChatModel; threadId?: string }): Promise<ChatResult> {\n return modusChatBuffered(this.http, message, options)\n }\n\n /**\n * Stream a Modus reply token by token (SSE).\n *\n * The request starts when you consume `textStream()` or `eventStream()`.\n *\n * @param message - User message text.\n * @param options.model - Required model id (e.g. `\"claude-sonnet-5\"`).\n * @param options.threadId - Continue an existing conversation; omit to start new.\n * @returns Chat stream — iterate `textStream()` for tokens.\n *\n * @example\n * ```ts\n * const stream = client.modus.chatStream('Summarize ARR in three bullets.', {\n * model: 'claude-sonnet-5',\n * })\n * for await (const token of stream.textStream()) {\n * process.stdout.write(token)\n * }\n * console.log(stream.getFinalResult().threadId)\n * ```\n */\n chatStream(message: string, options: { model: ChatModel; threadId?: string }): ChatStream {\n return modusChatStreamSession(this.http, this.config, message, options)\n }\n}\n","import { chatBuffered, chatStreamSession, type ChatStream } from '../_chat.js'\nimport type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { aipListParams, buildAipPage, type Page } from '../_pagination.js'\nimport { asRecord, invokeWithRetry, omitUndefined } from '../_request.js'\nimport { validateId, validatePageSize } from '../_validation.js'\nimport type { ChatModel, ChatResult } from '../types/chat.js'\nimport type { SkillContextComposition } from '../types/context-compose.js'\nimport type { Scope } from '../types/scopes.js'\nimport type { VariationView } from '../types/views.js'\nimport { ScopeConversationsResource } from './scopes/conversations.js'\n\nfunction scopesListParams(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n view?: VariationView,\n managerId?: number,\n): Record<string, string | number | boolean | undefined | null> {\n const extra: Record<string, string | number | boolean | undefined | null> = {}\n if (search !== undefined) extra.search = search\n if (view !== undefined) extra.view = view\n if (managerId !== undefined) extra.managerId = managerId\n return aipListParams(pageSize, pageToken, extra) as Record<\n string,\n string | number | boolean | undefined | null\n >\n}\n\nfunction parseScope(raw: unknown): Scope {\n return raw as Scope\n}\n\n/**\n * Read / chat with published scopes.\n *\n * Call path: `client.scopes` after `new Modus(...)`. Prefer `client.modus` for\n * the org-wide assistant. Create/deploy via `ModusManagement`.\n *\n * @example\n * ```ts\n * const scope = await client.scopes.get('revenue-analysis')\n * const result = await client.scopes.chat(scope.id, 'What is our ARR trend?', {\n * model: 'claude-sonnet-5',\n * })\n * console.log(result.content, result.threadId)\n * ```\n */\nexport class ScopesResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * Return the conversations sub-resource scoped to `scopeId`.\n *\n * @param scopeId - Scope numeric id or slug.\n * @returns Conversations resource for the scope.\n *\n * @example\n * ```ts\n * for await (const row of (\n * await client.scopes.conversations(scopeId).list({ pageSize: 10 })\n * ).autoPagingIter()) {\n * console.log(row.threadId, row.firstMessage)\n * }\n * ```\n */\n conversations(scopeId: number | string): ScopeConversationsResource {\n return new ScopeConversationsResource(this.http, this.config, scopeId)\n }\n\n /**\n * List scopes in the organisation.\n *\n * @param options.pageSize - Items per page (default 25).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.search - Case-insensitive substring filter on the scope name.\n * @param options.view - `\"active\"` (deployed) or `\"draft\"`.\n * @param options.managerId - Only scopes supervised by this manager scope id.\n * @returns Page of scopes — use `.autoPagingIter()` for all pages.\n *\n * @example\n * ```ts\n * for await (const scope of (await client.scopes.list()).autoPagingIter()) {\n * console.log(scope.id, scope.name, scope.status)\n * }\n * ```\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n search?: string\n view?: VariationView\n managerId?: number\n } = {}): Promise<Page<Scope>> {\n const pageSize = options.pageSize ?? 25\n validatePageSize(pageSize)\n return this.listPage(\n pageSize,\n options.pageToken,\n options.search,\n options.view,\n options.managerId,\n )\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n search?: string,\n view?: VariationView,\n managerId?: number,\n ): Promise<Page<Scope>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'ScopesController_list', {\n query: scopesListParams(pageSize, pageToken, search, view, managerId),\n }),\n )\n // List responses require the canonical `scopes` key (dual `skills` envelope removed).\n return buildAipPage(\n data,\n 'scopes',\n parseScope,\n (token) => this.listPage(pageSize, token, search, view, managerId),\n )\n }\n\n /**\n * Retrieve a scope by ID or slug.\n *\n * @param scopeId - Scope numeric id or slug.\n * @param options.view - `\"active\"` (deployed) or `\"draft\"`.\n * @throws {NotFoundError} When no scope matches the id or slug.\n * @returns Scope (`id`, `name`, `status`, …).\n *\n * @example\n * ```ts\n * const scope = await client.scopes.get('revenue-analysis')\n * console.log(scope.name, scope.status)\n * ```\n */\n async get(\n scopeId: number | string,\n options: { view?: VariationView } = {},\n ): Promise<Scope> {\n validateId(scopeId, 'scope_id')\n const query = options.view !== undefined ? { view: options.view } : undefined\n const data = await invokeWithRetry(this.config, this.http, 'ScopesController_get', {\n pathParams: { id: scopeId },\n query,\n })\n return parseScope(data)\n }\n\n /**\n * Compose context this scope would use for an intent, without running chat.\n *\n * @param scopeId - Scope numeric id or slug.\n * @param message - Natural-language intent used to select context.\n * @param options.limit - Maximum context items to return. Omit to return all selected items.\n * @returns Composition metadata. Use `chat` when you need an assistant reply.\n *\n * @example\n * ```ts\n * const ctx = await client.scopes.getContext(scopeId, 'Which tables describe churn?', {\n * limit: 5,\n * })\n * console.log(ctx.originalCount, ctx.sessionId)\n * ```\n */\n async getContext(\n scopeId: number | string,\n message: string,\n options: { limit?: number } = {},\n ): Promise<SkillContextComposition> {\n validateId(scopeId, 'scope_id')\n const data = await invokeWithRetry(this.config, this.http, 'ScopeContextController_compose', {\n pathParams: { id: scopeId },\n jsonBody: omitUndefined({ message, limit: options.limit }),\n })\n return data as SkillContextComposition\n }\n\n /**\n * Send a message to a published scope and wait for the complete reply.\n *\n * For the org-wide assistant use `client.modus.chat` instead.\n *\n * @param scopeId - Scope numeric id or slug (must be active for chat).\n * @param message - User message text.\n * @param options.model - Required model id (e.g. `\"claude-sonnet-5\"`).\n * @param options.threadId - Continue an existing conversation; omit to start new.\n * @returns Chat result: `content`, `threadId`, `runId`.\n *\n * @example\n * ```ts\n * const result = await client.scopes.chat(scopeId, 'What is our ARR trend?', {\n * model: 'claude-sonnet-5',\n * })\n * console.log(result.content, result.threadId)\n * const follow = await client.scopes.chat(scopeId, 'Break that down by segment.', {\n * model: 'claude-sonnet-5',\n * threadId: result.threadId,\n * })\n * ```\n */\n chat(\n scopeId: number | string,\n message: string,\n options: { model: ChatModel; threadId?: string },\n ): Promise<ChatResult> {\n return chatBuffered(this.http, 'scopes', scopeId, message, options)\n }\n\n /**\n * Stream a scope reply token by token (SSE).\n *\n * The request starts when you consume `textStream()` or `eventStream()`.\n *\n * @param scopeId - Scope numeric id or slug.\n * @param message - User message text.\n * @param options.model - Required model id (e.g. `\"claude-sonnet-5\"`).\n * @param options.threadId - Continue an existing conversation; omit to start new.\n * @param options.version - `\"published\"` or `\"draft\"`.\n * @returns Chat stream — iterate `textStream()` for tokens.\n *\n * @example\n * ```ts\n * const stream = client.scopes.chatStream(scopeId, 'Summarize in three bullets.', {\n * model: 'claude-sonnet-5',\n * })\n * for await (const token of stream.textStream()) {\n * process.stdout.write(token)\n * }\n * console.log(stream.getFinalResult().threadId)\n * ```\n */\n chatStream(\n scopeId: number | string,\n message: string,\n options: { model: ChatModel; threadId?: string; version?: string },\n ): ChatStream {\n return chatStreamSession(this.http, this.config, 'scopes', scopeId, message, options)\n }\n}\n","import type { ModusConfig } from '../_config.js'\nimport type { HttpClient } from '../_http.js'\nimport { buildAipPage, type Page } from '../_pagination.js'\nimport { asRecord, invokeWithRetry } from '../_request.js'\nimport { validateId, validatePageSize } from '../_validation.js'\nimport {\n type RecordSuggestionEventRequest,\n type SuggestionQuestion,\n} from '../types/suggestions.js'\n\nconst DEFAULT_SUGGESTIONS_PAGE_SIZE = 5\nconst MAX_SUGGESTIONS_PAGE_SIZE = 12\n\nfunction parseSuggestion(raw: unknown): SuggestionQuestion {\n return raw as SuggestionQuestion\n}\n\nfunction suggestionListParams(options: {\n pageSize: number\n pageToken?: string\n scopeId?: number\n scopeIds?: readonly number[]\n}): Record<string, string | number | undefined> {\n return {\n pageSize: options.pageSize,\n pageToken: options.pageToken,\n scopeId: options.scopeId,\n scopeIds: options.scopeIds?.join(','),\n }\n}\n\n/**\n * List suggested questions and record suggestion events.\n */\nexport class SuggestionsResource {\n /** @internal */\n constructor(\n private readonly http: HttpClient,\n private readonly config: ModusConfig,\n ) {}\n\n /**\n * List approved suggested questions.\n *\n * @param options.pageSize - Maximum items per page (default 5, max 12).\n * @param options.pageToken - Opaque token from a previous page.\n * @param options.scopeId - Filter to a single scope.\n * @param options.scopeIds - Filter to one or more scopes.\n * @returns A page of suggested questions.\n */\n list(options: {\n pageSize?: number\n pageToken?: string\n scopeId?: number\n scopeIds?: readonly number[]\n } = {}): Promise<Page<SuggestionQuestion>> {\n const pageSize = options.pageSize ?? DEFAULT_SUGGESTIONS_PAGE_SIZE\n validatePageSize(pageSize, MAX_SUGGESTIONS_PAGE_SIZE)\n return this.listPage(pageSize, options.pageToken, options.scopeId, options.scopeIds)\n }\n\n private async listPage(\n pageSize: number,\n pageToken: string | undefined,\n scopeId: number | undefined,\n scopeIds: readonly number[] | undefined,\n ): Promise<Page<SuggestionQuestion>> {\n const data = asRecord(\n await invokeWithRetry(this.config, this.http, 'SuggestionsController_listApproved', {\n query: suggestionListParams({ pageSize, pageToken, scopeId, scopeIds }),\n }),\n )\n return buildAipPage(data, 'suggestions', parseSuggestion, (token) =>\n this.listPage(pageSize, token, scopeId, scopeIds),\n )\n }\n\n /**\n * Record that a suggested question was shown, clicked, dismissed, or submitted.\n *\n * @param id - Suggestion id.\n * @param event - Event details, including `eventType` (`shown`, `clicked`, `dismissed`, or `submitted`).\n */\n async recordEvent(id: string, event: RecordSuggestionEventRequest): Promise<void> {\n validateId(id, 'id')\n await invokeWithRetry(this.config, this.http, 'SuggestionsController_recordEvent', {\n pathParams: { id },\n jsonBody: event,\n })\n }\n}\n","/**\n * @getmodus/sdk — official TypeScript client for Modus.\n */\n\nexport type { components, paths, operations } from './_generated/v1.js'\nexport type { OperationId, OperationSpec } from './_generated/operations.js'\nexport { OPERATIONS } from './_generated/operations.js'\n\nexport {\n APIConnectionError,\n AuthenticationError,\n ConflictError,\n InternalServerError,\n ModusError,\n NotFoundError,\n PermissionDeniedError,\n RateLimitError,\n RunCancelledError,\n StreamTimeoutError,\n UnprocessableError,\n ValidationError,\n} from './_exceptions.js'\n\nexport { ChatStream } from './_chat.js'\nexport { Page } from './_pagination.js'\nexport type {\n AssistantContentResetEvent,\n CancelledEvent,\n DoneEvent,\n ErrorEvent,\n RunEvent,\n StreamTimeoutEvent,\n TokenEvent,\n} from './types/runs.js'\nexport type { ChatModel, ChatRequest, ChatResult } from './types/chat.js'\nexport type { ModusOptions } from './_config.js'\nexport type { Scope, ScopeStatus, ScopeVariation, Skill, SkillStatus, SkillVariation } from './types/scopes.js'\nexport type { Workflow, Agent } from './types/workflows.js'\nexport { AgentType, WorkflowType } from './types/workflows.js'\nexport type {\n AgentRun,\n AgentRunCreateRequest,\n AgentRunListItem,\n ApprovalScope,\n CancelRunRequest,\n CreateAgentRunRequest,\n EditQueuedRunRequest,\n InterruptRunRequest,\n ModusRunCreateRequest,\n ResumeRunRequest,\n RunStatus,\n RunTimeframe,\n SkillRunCreateRequest,\n WorkflowActionRequest,\n} from './types/agent-runs.js'\nexport type { AgentRunStream } from './resources/workflows/runs.js'\nexport type {\n Conversation,\n ConversationKind,\n ConversationListItem,\n Message,\n} from './types/conversations.js'\nexport { conversationScopeId, conversationSkillId } from './types/conversations.js'\nexport type { Connection } from './types/connections.js'\nexport type { VariationView } from './types/views.js'\nexport type {\n ContextItem,\n ContextItemAncestor,\n ContextItemDeletion,\n ContextItemLookupRow,\n ContextItemMove,\n ContextType,\n} from './types/context.js'\nexport type { ContextValueRow } from './types/context-values.js'\nexport type {\n ComposeSkillContextRequest,\n ModusContextComposition,\n ModusContextRequest,\n SkillContextComposition,\n} from './types/context-compose.js'\nexport type {\n RecordSuggestionEventRequest,\n SuggestionEventSource,\n SuggestionEventType,\n SuggestionQuestion,\n} from './types/suggestions.js'\nexport type {\n HttpIngestedDataRequest,\n IngestedDataRequest,\n IngestedDataResponse,\n IngestedDataResponseFormat,\n IngestedDataUploadResult,\n SqlIngestedDataRequest,\n UploadIngestedDataOptions,\n} from './types/ingested-data.js'\n\nimport { ModusClientBase } from './_client-base.js'\nimport { WorkflowsResource } from './resources/workflows.js'\nimport { ConnectionsResource } from './resources/connections.js'\nimport { ContextResource } from './resources/context/context.js'\nimport { IngestedDataResource } from './resources/ingested-data.js'\nimport { ModusResource } from './resources/modus/modus.js'\nimport { ScopesResource } from './resources/scopes.js'\nimport { SuggestionsResource } from './resources/suggestions.js'\n\n/**\n * Read / invoke client for Modus scopes, workflows, connections, and more.\n *\n * Call path: `const client = new Modus(...)` then `client.scopes`, `client.context`, …\n *\n * @param options - Client configuration (`apiKey`, `baseUrl`, `timeoutMs`, `maxRetries`).\n */\nexport class Modus extends ModusClientBase {\n readonly scopes: ScopesResource\n readonly modus: ModusResource\n readonly workflows: WorkflowsResource\n readonly context: ContextResource\n readonly connections: ConnectionsResource\n readonly suggestions: SuggestionsResource\n readonly ingestedData: IngestedDataResource\n\n constructor(options: import('./_config.js').ModusOptions = {}) {\n super(options)\n this.scopes = new ScopesResource(this.http, this.config)\n this.modus = new ModusResource(this.http, this.config)\n this.workflows = new WorkflowsResource(this.http, this.config)\n this.context = new ContextResource(this.http, this.config)\n this.connections = new ConnectionsResource(this.http, this.config)\n this.suggestions = new SuggestionsResource(this.http, this.config)\n this.ingestedData = new IngestedDataResource(this.http, this.config)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAGpB,SAAS,yBAAyB,WAAmC;AAC1E,MAAI,OAAO,cAAc,YAAY,UAAU,KAAK,EAAG,QAAO,UAAU,KAAK;AAC7E,SAAO,WAAW;AACpB;;;ACIA,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,UAAU,MAAmD;AACpE,MAAI,CAAC,KAAK,WAAW,OAAO,EAAG,QAAO;AACtC,QAAM,MAAM,KAAK,MAAM,CAAC,EAAE,UAAU;AACpC,MAAI,CAAC,OAAO,QAAQ,SAAU,QAAO;AACrC,MAAI;AACF,UAAM,OAAO,KAAK,MAAM,GAAG;AAC3B,QAAI,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI,GAAG;AAC5D,aAAO;AAAA,IACT;AAAA,EACF,QA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