import type { ActionInvocationListResponse, Agent, AgentListResponse, AgentMemory, AgentMemoryChange, AgentMemoryChangeListResponse, AgentMemoryEntry, AgentMemoryEntryListResponse, AgentTurn, AgentTurnListResponse, AgentTurnOperationPolicy, AgentTurnOutputSource, Artifact, ApplyBlueprintRequest, BlueprintApplyResult, BlueprintBindingListResponse, BlueprintDeleteResult, BillingUsageEvent, BillingUsageEventListResponse, ChannelContext, CreateAgentRequest, CreatePrincipalRequest, CreateRoleAssignmentRequest, CreateRoleRequest, Interaction, InteractionKind, InteractionListResponse, InvokeSessionSpec, MemoryKind, MemorySearchMode, OAuthReturnOrigins, PermissionCatalogResponse, Principal, PrincipalKind, PrincipalListResponse, RuntimeContextItem, SaveAgentMemoryEntryRequest, Session, SessionAttachmentResponse, SessionListResponse, SessionMessageListResponse, SessionNudge, SessionNudgeAck, SessionNudgeListResponse, SessionNudgeStatus, SessionStreamFrame, SessionTranscriptFrame, SessionTranscriptMessage, SessionTranscriptSnapshot, RespondToInteractionRequest, Role, RoleAssignment, RoleAssignmentListResponse, RoleListResponse, Skill, SkillAssignmentListResponse, SkillListResponse, SkillRequest, TurnAck, TurnOutputSpec, UpdatePrincipalRequest, UpdateRoleRequest } from "./api/index.js"; import { RateLimitError } from "./retry.js"; import { SessionTranscript, type TranscriptStreamEvent } from "./transcript.js"; export { RateLimitError } from "./retry.js"; export interface ClientOptions { apiKey: string; baseURL?: string; /** Fetch timeout in milliseconds. Defaults to 60_000. */ timeoutMs?: number; /** Number of retries for 429/503 responses. */ retry?: number; /** Optional structured transport logger. Headers, bodies, and message content are never included. */ logger?: (event: ClientLogEvent) => void; } export interface ClientLogEvent { type: "request" | "retry" | "stream"; event: string; method?: string; path?: string; status?: number; durationMs?: number; attempt?: number; waitSeconds?: number; frameType?: string; error?: string; } export interface CreateArtifactOptions { /** Display name or relative virtual path for the artifact. */ name: string; /** Artifact bytes. A Blob's existing MIME type is preserved unless mimeType is supplied. */ file: Blob | Uint8Array; /** Optional durable retry key for this one artifact. */ idempotencyKey?: string; mimeType?: string; metadata?: Record; signal?: AbortSignal; } /** Largest chunk the staged PDF upload accepts; every part but the last is exactly this size. */ export declare const SESSION_PDF_CHUNK_BYTES: number; /** Largest PDF the staged upload accepts. */ export declare const SESSION_PDF_MAX_BYTES: number; export interface UploadSessionPdfOptions { /** Session to bind the PDF to. */ sessionId: string; /** PDF bytes, up to 100 MiB. */ file: Blob | Uint8Array; /** Display filename recorded for the PDF. */ name: string; /** Retry key for the completing request, scoped to this session and caller. */ idempotencyKey?: string; /** Staging ID (a random v4 UUID). Generated when omitted; reuse it to resume a failed upload. */ uploadId?: string; signal?: AbortSignal; } export interface CompleteSessionPdfUploadOptions { sessionId: string; /** The v4 UUID the parts were staged under. */ uploadId: string; /** Display filename recorded for the PDF. */ name: string; /** Total bytes across all staged parts. */ sizeBytes: number; /** Number of staged parts, numbered from 0. */ partCount: number; /** Retry key scoped to this session and caller; an identical retry returns the original attachment. */ idempotencyKey?: string; signal?: AbortSignal; } export interface CreateSessionAttachmentOptions { /** Session to bind the attachment to. */ sessionId: string; /** Attachment bytes. A Blob's existing MIME type is preserved unless mimeType is supplied. */ file: Blob | Uint8Array; /** Display filename recorded for the attachment. */ name: string; /** * MIME hint only: Mobius detects and validates the media type from the * bytes and does not trust this declaration. */ mimeType?: string; /** Retry key scoped to this session and caller; an identical retry returns the original attachment. */ idempotencyKey?: string; signal?: AbortSignal; } export declare const DEFAULT_BASE_URL = "https://api.mobiusops.com"; export declare class AuthRevokedError extends Error { constructor(); } export declare class MobiusAPIError extends Error { /** * Adopt-mode create conflict code (409): the request names an identity * (agent name) that differs from the resource owning the * matched `external_ref`, or the match is soft-deleted — adopt never * resurrects or replaces a deleted resource. */ static readonly EXTERNAL_IDENTITY_CONFLICT = "external_identity_conflict"; readonly status: number; readonly code: string; readonly details?: Record; readonly requestId?: string; readonly retryAfter?: number; constructor(init: { status: number; code: string; message: string; details?: Record; requestId?: string; retryAfter?: number; }); } /** * Thrown when a streaming request (e.g. {@link Client.streamSessionTranscript}) * returns a non-OK HTTP status. `status` carries the response code so callers * of {@link Client.watchSessionTranscript} can branch on it — the watch loop * reconnects only on transient statuses (429/503) and surfaces every other * status by throwing this error. */ export declare class StreamHTTPError extends MobiusAPIError { constructor(status: number, message: string, init?: Partial>); } export declare class ConfigError extends Error { constructor(message: string); } export declare class LeaseLostError extends Error { readonly jobId: string; constructor(jobId: string); } export declare class PayloadTooLargeError extends Error { readonly jobId: string; constructor(jobId: string); } export declare class RateLimitedError extends RateLimitError { readonly jobId: string; constructor(jobId: string, retryAfter?: number); } export declare class WorkerInstanceConflictError extends Error { readonly workerInstanceId: string | undefined; constructor(workerInstanceId: string | undefined, message?: string); } /** Filters for the org-scoped billing usage evidence reader. */ export interface ListBillingUsageEventsOptions { /** Inclusive ISO-8601 lower bound. Selects chronological `(recorded_at, id)` ordering. */ recordedAfter?: string; periodStart?: string; counter?: string; sourceType?: string; sourceId?: string; jobId?: string; apiKeyId?: string; cursor?: string; limit?: number; } export interface InvokeAgentOptions { /** Agent identifier. Mutually exclusive with agentName. */ agentId?: string; /** Org-unique agent name. Mutually exclusive with agentId. */ agentName?: string; /** Ordered content blocks (text, images, …) for the caller's input message. Required. */ content: Record[]; /** * Ordered application-owned state snapshots for this turn. Send full, * deterministic values; Mobius records only first use, changes, and * post-compaction re-entry. */ context?: RuntimeContextItem[]; /** * Dedup key scoped to the resolved session. A repeat call with the same * key resolves the same session and returns the existing invocation * without restarting it or starting a second one — derive it from the * provider event id for Slack/Telegram webhook retries. The SDK retries * admission automatically unless `session.mode` is `new`, which cannot be * safely replayed with a session-scoped key. */ idempotencyKey?: string; /** Free-form caller metadata attached to the input message. */ inputMetadata?: Record; /** * How to resolve or create the session this invocation runs in. Omit to * use a single default session per agent in continue_or_create mode. Set * `session.thinking_effort` to override the agent's reasoning-effort * default for this session. */ session?: InvokeSessionSpec; /** * Policy for only this newly admitted turn. Its timeout takes precedence * over the stored agent timeout and is not saved on the session. */ operation?: AgentTurnOperationPolicy; /** * Structured-output contract for this turn. When set, Mobius exposes a * reserved submit tool for the schema, validates the submission * server-side, and fails the turn if it never produces a schema-valid * object. Read the validated value from {@link TurnTranscript.output}. */ output?: TurnOutputSpec; /** * Optional messaging provider/channel routing context (Slack, Telegram, * …) recorded on the started turn. */ channelContext?: ChannelContext; } export interface StartTurnOptions { /** Ordered content blocks (text, images, …) for the caller's input message. */ content: Record[]; /** Ordered application-owned state snapshots for this turn. */ context?: RuntimeContextItem[]; /** * Dedup key scoped to the existing session. A repeat returns the existing * invocation, writes no new input, and never restarts a terminal turn. */ idempotencyKey?: string; /** * Policy for only this newly admitted turn. Its timeout takes precedence * over the stored agent timeout and is not saved on the session. */ operation?: AgentTurnOperationPolicy; /** * Structured-output contract for this turn. See * {@link InvokeAgentOptions.output}; read the validated value from * {@link TurnTranscript.output}. */ output?: TurnOutputSpec; /** Free-form caller metadata attached to the input message. */ metadata?: Record; } /** * A single decoded frame from a session SSE stream. eventType is the * authoritative SSE `event:` name (e.g. "user.message", "turn.completed", * "tool.call") — {@link SessionStreamFrame} is a reference-only union that * cannot be shape-matched from data alone, so dispatch on eventType and cast * data to the corresponding payload type. */ export interface SessionStreamEvent { eventType: string; data: SessionStreamFrame; } export interface GetSessionTranscriptOptions { /** Opaque resume cursor from a prior snapshot or stream; omit for a bootstrap tail. */ cursor?: string; /** Opaque fixed-cut continuation (`next_page_token`) when draining an incremental cycle. */ pageToken?: string; /** Max messages per page. */ limit?: number; signal?: AbortSignal; } export interface StreamSessionTranscriptOptions { /** Opaque resume cursor; omit to hydrate from the live tail. */ cursor?: string; signal?: AbortSignal; } export interface WatchSessionTranscriptOptions { /** Opaque resume cursor for the first connection. Ignored if `transcript` carries one. */ cursor?: string; /** * Existing view to continue folding into (e.g. one bootstrapped from * getSessionTranscript pages). Omit to start fresh. */ transcript?: SessionTranscript; /** Delay before reconnecting after a dropped connection (not a clean `rotate`). Defaults to 1000. */ reconnectDelayMs?: number; /** Reopen after an idle close so turns started later are observed. Defaults to false. */ follow?: boolean; signal?: AbortSignal; } export interface ListAgentsOptions { /** Exact org-unique agent name. */ name?: string; principalId?: string; status?: string; limit?: number; } export interface CreateAgentOptions { /** * Makes the create safely retryable: when a live agent already carries * `externalRef`, it is returned unchanged (HTTP 200) instead of failing * with 409, and no fields are written. Requires `externalRef`. Adopt-mode * creates are retried on transient failures like idempotent requests, * because `external_ref` makes the create replay-safe server-side. * Conflicts that cannot be adopted fail with a {@link MobiusAPIError} * whose code is {@link MobiusAPIError.EXTERNAL_IDENTITY_CONFLICT}. */ adoptExisting?: boolean; /** * Client-owned durable identity key, unique within the org and * assign-once. Required with `adoptExisting`; optional otherwise. */ externalRef?: string; } export interface ListAgentMemoryEntriesOptions { /** Searches entry keys, kinds, summaries, and content. Omit to list. */ query?: string; /** * Ranks a non-blank query: keyword (the server default), semantic, or * hybrid. Semantic and hybrid surface a 503 * memory_semantic_search_unavailable {@link MobiusAPIError} when the index * is unavailable; the SDK never downgrades to keyword silently because that * would change result semantics — retry or fall back explicitly. */ searchMode?: MemorySearchMode; /** Filters to a single memory kind. */ kind?: MemoryKind; cursor?: string; limit?: number; } export interface ListAgentMemoryChangesOptions { /** * Opaque cursor returned as next_cursor by the previous page. Omit on the * first request to read retained changes oldest-first. */ after?: string; limit?: number; } /** * One bounded synchronization step of an agent's memory change feed, returned * by {@link Client.syncAgentMemory}. When reset is true the supplied cursor * predated retained history (HTTP 410) and entries carries a full current * snapshot to replace local state; otherwise changes carries every feed item * after the cursor. nextCursor is the new feed position to persist. */ export type MemorySyncResult = { reset: false; changes: AgentMemoryChange[]; nextCursor: string; } | { reset: true; entries: AgentMemoryEntry[]; nextCursor: string; }; export type TranscriptConnectionState = "open" | "reconnecting" | "ended"; export interface TranscriptUpdate { frame: SessionTranscriptFrame; cursor: string | null; transcript: SessionTranscript; connection: TranscriptConnectionState; reconnectCount: number; } export interface TranscriptDiagnostics { status: string; cursor: string | null; ready: boolean; reconnectCount: number; lastFrameType?: string; lastFrameAt?: string; connection: TranscriptConnectionState | "idle"; } /** @deprecated Use {@link TranscriptDiagnostics}. */ export type TurnDiagnostics = TranscriptDiagnostics; export interface ListSessionsOptions { agentId?: string; agentName?: string; sessionKey?: string; status?: string; scope?: string; provider?: string; integrationId?: string; since?: string; cursor?: string; limit?: number; } export interface ListSessionMessagesOptions { afterSequence?: number; beforeSequence?: number; order?: "asc" | "desc"; limit?: number; /** Set to context to return caller-supplied runtime context rows. */ include?: "context"; } export interface ListSessionTurnsOptions { ids?: string[]; order?: "asc" | "desc"; cursor?: string; limit?: number; } export interface NudgeSessionOptions { content: string; idempotencyKey?: string; metadata?: Record; wake?: boolean; } export interface ListSessionNudgesOptions { status?: SessionNudgeStatus[]; order?: "asc" | "desc"; cursor?: string; limit?: number; } export interface ListBlueprintBindingsOptions { namespace?: string; blueprintKey?: string; } export interface DeleteBlueprintOptions { namespace?: string; deleteRetained?: boolean; } export interface SetBlueprintProtectionOptions { namespace?: string; } export interface ListInteractionsOptions { status?: "pending" | "completed" | "expired" | "cancelled"; kind?: InteractionKind; sessionId?: string; targetUserId?: string; inbox?: boolean; cursor?: string; limit?: number; } export interface ListPrincipalsOptions { kind?: PrincipalKind; includeDisabled?: boolean; limit?: number; } export interface ListRoleAssignmentsOptions { principalId?: string; roleId?: string; } export interface ListRolesOptions { cursor?: string; limit?: number; } export interface ListActionInvocationsOptions { /** Filter to invocations from a specific job. */ jobId?: string; /** Filter to invocations executed in a specific environment. */ environmentId?: string; /** Filter to invocations of a specific action. */ actionName?: string; /** Filter to an immutable custom or organization Action ID. */ actionId?: string; /** * Filter by the scope that owned the selected definition: "platform", * "custom", or "organization". */ definitionScope?: "platform" | "custom" | "organization"; /** Filter to deliveries signed with a specific signing-secret version. */ secretVersion?: number; /** Filter to a signed delivery identity. */ deliveryId?: string; /** Filter to the request or dispatch correlation identity. */ correlationId?: string; /** Filter by terminal status (e.g. "success", "failed"). */ status?: string; cursor?: string; limit?: number; } export interface ListSkillsOptions { /** * Include read-only system skill templates. The server includes them by * default; pass false to omit them. */ includeSystem?: boolean; } export interface ImportSkillOptions { /** Override the skill name derived from the document. */ name?: string; } export declare class Client { private readonly baseURL; private readonly headers; private readonly timeoutMs; private readonly fetchFn; private readonly logger?; private readonly agentNameCache; constructor(opts: ClientOptions); /** * @internal Used by {@link Worker} to open its socket. * * Headers for the worker socket handshake: the API key and * `X-Mobius-Client: `. Only runtimes whose WebSocket can set * handshake headers, such as Node, can send them. */ workerSocketHeaders(clientHeader: string): Record; workerSocketURL(): string; /** Publish a private artifact using the client's org authorization. */ createArtifact(opts: CreateArtifactOptions): Promise; /** Read one page of exact, org-scoped billing usage evidence. */ listBillingUsageEvents(opts?: ListBillingUsageEventsOptions): Promise; /** * Drain every usage page for these filters in server order, yielding one * event at a time. Pass `recordedAfter` to select the durable oldest-first * incremental contract; a single call yields each matching event exactly * once. Deduplication is the caller's job only *across* calls: when you * advance `recordedAfter` and replay a bounded overlap, skip events whose * `id` you have already seen — this iterator does not remember events from * earlier calls. */ iterateBillingUsageEvents(opts: Omit): AsyncGenerator; applyBlueprint(input: ApplyBlueprintRequest): Promise; listBlueprintBindings(opts?: ListBlueprintBindingsOptions): Promise; setBlueprintProtection(blueprintKey: string, protectedResources: boolean, opts?: SetBlueprintProtectionOptions): Promise; deleteBlueprint(blueprintKey: string, opts?: DeleteBlueprintOptions): Promise; listInteractions(opts?: ListInteractionsOptions): Promise; listOrgPermissions(): Promise; listPrincipals(opts?: ListPrincipalsOptions): Promise; createPrincipal(input: CreatePrincipalRequest): Promise; getPrincipal(id: string): Promise; updatePrincipal(id: string, input: UpdatePrincipalRequest): Promise; deletePrincipal(id: string): Promise; listRoles(opts?: ListRolesOptions): Promise; createRole(input: CreateRoleRequest): Promise; getRole(id: string): Promise; updateRole(id: string, input: UpdateRoleRequest): Promise; deleteRole(id: string): Promise; listRoleAssignments(opts?: ListRoleAssignmentsOptions): Promise; createRoleAssignment(input: CreateRoleAssignmentRequest): Promise; deleteRoleAssignment(id: string): Promise; /** * Lists org-owned, organization-shared, and system skills. System * skill templates are included by default; pass includeSystem: false to * omit them. Organization skills are read-only through these mutation * routes. */ listSkills(opts?: ListSkillsOptions): Promise; /** Creates an org-owned skill. */ createSkill(input: SkillRequest): Promise; /** * Imports a Claude Code or Dive-style skill document into an org-owned * skill. The content string is sent verbatim, including any YAML * frontmatter; pass opts.name to override the document's own. */ importSkill(content: string, opts?: ImportSkillOptions): Promise; /** * Returns a single org-owned, organization-shared, or system skill by * ID. */ getSkill(skillId: string): Promise; /** * Replaces an org-owned skill. The server requires the full body — * including name and instructions — on every update; there is no partial * patch, so read-modify-write is the caller's responsibility. */ updateSkill(skillId: string, input: SkillRequest): Promise; /** * Deletes an org-owned skill. The skill is automatically detached from * any agents that reference it. */ deleteSkill(skillId: string): Promise; /** Returns the skills assigned to an agent in assignment order. */ listAgentSkillAssignments(agentId: string): Promise; /** * Replaces the agent's skill assignment set as a whole with skillIds, in * the given order. Pass an empty array to remove every assignment. */ replaceAgentSkillAssignments(agentId: string, skillIds: string[]): Promise; /** * Lists recent action invocation audit records from loops, agents, direct * invocations, and job-backed execution. Each entry carries definition * provenance (action_id, definition_scope) and, for signed HTTP * deliveries, the delivery identity (delivery_id, correlation_id, * secret_version). */ listActionInvocations(opts?: ListActionInvocationsOptions): Promise; listSessions(opts?: ListSessionsOptions): Promise; getSessionByKey(sessionKey: string, agent: { agentId?: string; agentName?: string; }): Promise; listAgents(opts?: ListAgentsOptions): Promise; getAgent(agentId: string): Promise; /** * Creates an agent, or — with `adoptExisting` — adopts the live agent * that already carries the same `externalRef`. On adopt the existing * agent is returned unchanged (HTTP 200) and mutable fields in `input` * are ignored, since no write happens. */ createAgent(input: CreateAgentRequest, opts?: CreateAgentOptions): Promise; /** * Returns the organization's allowlist of exact HTTPS origins an embedded * partner may name as an OAuth connect `return_url`. An empty list means * embedded return is disabled. Requires Admin or Owner membership. */ getOAuthReturnOrigins(): Promise; /** * Full-replaces the organization's OAuth return-origin allowlist. The * server normalizes each entry (lowercase host, default ports stripped) * and rejects invalid origins; no validation happens client-side. Pass an * empty array to disable embedded return. Requires Admin or Owner * membership. */ replaceOAuthReturnOrigins(origins: string[]): Promise; resolveAgent(name: string): Promise; /** Returns a summary of an agent's private memory. */ getAgentMemory(agentId: string): Promise; /** * Lists or searches an agent's memory entries. The response preserves * search_coverage so callers can see when semantic or hybrid results ranked * only a partially indexed subset. */ listAgentMemoryEntries(agentId: string, opts?: ListAgentMemoryEntriesOptions): Promise; /** Creates or updates the memory entry stored under key. */ saveAgentMemoryEntry(agentId: string, key: string, input: SaveAgentMemoryEntryRequest): Promise; /** Deletes the memory entry stored under key. */ deleteAgentMemoryEntry(agentId: string, key: string): Promise; /** * Returns one page of the content-free, append-only memory change feed. A * 410 {@link MobiusAPIError} means the cursor predates retained history; * recover with {@link syncAgentMemory} or by relisting entries. */ listAgentMemoryChanges(agentId: string, opts?: ListAgentMemoryChangesOptions): Promise; /** * Advances a memory change-feed consumer by one bounded synchronization * step: drains every change page after cursor and returns the new feed * position to persist. When the cursor has expired (HTTP 410) it recovers * explicitly — establishing a fresh feed position and returning a full * entry snapshot with reset set — instead of failing or silently replaying. * Omit cursor on first use. Polling cadence and retry policy stay with the * caller; this makes no timing decisions. */ syncAgentMemory(agentId: string, cursor?: string): Promise; private drainAgentMemoryChanges; private drainAgentMemoryEntries; getSession(sessionId: string): Promise; cancelSession(sessionId: string, opts?: { force?: boolean; }): Promise; /** * Attach one document or image to a session. * * Uploads the bytes into server-managed artifact storage and binds them * immutably to the session. The returned `content_block` is the canonical * block to append in a session message or turn input. */ createSessionAttachment(opts: CreateSessionAttachmentOptions): Promise; /** * Delete one artifact created through this session's attachments. * Deleting an artifact this session already deleted succeeds. */ deleteSessionAttachment(sessionId: string, artifactId: string): Promise; /** * Upload a PDF of up to 100 MiB through the staged chunk endpoints and * bind it to the session. PDFs over 30 MiB must take this path; smaller * ones may. Parts are 8 MiB and each is retried independently; the * completing request validates the whole file and returns the same * response as `createSessionAttachment`. */ uploadSessionPdf(opts: UploadSessionPdfOptions): Promise; /** * Stage one chunk of a large PDF. Low-level: prefer `uploadSessionPdf`. * Every part but the last must be exactly 8 MiB; part numbers run from 0. */ putSessionPdfUploadPart(sessionId: string, uploadId: string, partNumber: number, chunk: Blob | Uint8Array, opts?: { signal?: AbortSignal; }): Promise; /** * Validate the staged chunks as one PDF, commit it, and bind it to the * session. Low-level: prefer `uploadSessionPdf`. */ completeSessionPdfUpload(opts: CompleteSessionPdfUploadOptions): Promise; compactSession(sessionId: string): Promise; listSessionMessages(sessionId: string, opts?: ListSessionMessagesOptions): Promise; nudgeSession(sessionId: string, opts: NudgeSessionOptions): Promise; listNudges(sessionId: string, opts?: ListSessionNudgesOptions): Promise; getNudge(sessionId: string, nudgeId: string): Promise; cancelNudge(sessionId: string, nudgeId: string): Promise; /** Submit a response to an interaction observed on a session transcript. */ respondToInteraction(interactionId: string, input: RespondToInteractionRequest): Promise; listTurns(sessionId: string, opts?: ListSessionTurnsOptions): Promise; getTurn(sessionId: string, turnId: string): Promise; cancelTurn(sessionId: string, turnId: string): Promise; /** * Delete the session's last turn: its input, the agent's work, and its * reply leave the transcript. Only the last turn of an idle session can be * deleted (409 otherwise); repeat to walk further back. Deleting an * already-deleted turn succeeds. */ deleteSessionTurn(sessionId: string, turnId: string): Promise; /** Start a turn in an existing session and return its lazy transcript handle. */ startTurn(sessionId: string, opts: StartTurnOptions, streamOpts?: { signal?: AbortSignal; }): Promise; /** * Resolves (or creates) a session, appends opts.content as the caller's * input message, and starts an agent turn — collapsing the * create-or-resolve-session + start-turn sequence into one retryable * call. This is the entry point for a product backend (an embedded app, * a Slack handler, a Telegram bot) calling per inbound message. * * Resolves once the turn is accepted. The returned {@link TurnTranscript} * carries the turn's identity (`id`, `sessionId`, `status`) immediately and * its live transcript on demand: the stream is lazy, so `for await` the * handle to render the turn as it runs, or never iterate for * fire-and-forget. Use {@link Client.invokeAgentStream} instead to observe * the turn's activity inline on the same connection with v1 session-stream * framing. */ invokeAgent(opts: InvokeAgentOptions, streamOpts?: { signal?: AbortSignal; }): Promise; /** * Behaves like {@link Client.invokeAgent} but streams the turn's * activity inline on the same connection instead of waiting for a * TurnAck. The inline stream cannot be resumed; to follow the turn after * it drops, open `GET …/transcript/stream` from the turn's `resume_cursor`. */ invokeAgentStream(opts: InvokeAgentOptions, streamOpts?: { signal?: AbortSignal; }): AsyncGenerator; /** * Fetch a session transcript snapshot (session-stream v2). Without a cursor * this is a bootstrap tail (latest final page + all live rows and turns); * with a cursor it drains everything after it toward a fixed upper cut — * continue with the returned `next_page_token` until `has_more` is false. * Fold each page into a {@link SessionTranscript} with * `applySnapshot`; polling is the same protocol the stream accelerates. */ getSessionTranscript(sessionId: string, opts?: GetSessionTranscriptOptions): Promise; /** * Open one session-transcript SSE connection and yield each decoded frame * with its SSE `id:` (the resume cursor). This is the low-level primitive; * feed the events to a {@link SessionTranscript}'s `apply`, or use * {@link Client.watchSessionTranscript} for the managed connection loop * (reconnect on `rotate`, stop on `idle`). */ streamSessionTranscript(sessionId: string, opts?: StreamSessionTranscriptOptions): AsyncGenerator; /** * Drive a {@link SessionTranscript} across the full session-transcript * stream, yielding it after every applied frame. Owns the connection loop: * reconnects with the current cursor on `stream.end rotate` (and after a * dropped connection), and returns on `stream.end idle`. Reconnect is the * same code path as the first connect — the view keeps its rows and only * resets `ready`. On `idle` the caller can poll {@link * Client.getSessionTranscript} and reopen when `resume_cursor` moves. */ watchSessionTranscript(sessionId: string, opts?: WatchSessionTranscriptOptions): AsyncGenerator; /** Yield each observed transcript frame together with the accumulated view. */ watchSessionTranscriptUpdates(sessionId: string, opts?: WatchSessionTranscriptOptions): AsyncGenerator; private request; private requestHeaders; private log; private url; } /** * A started agent turn and its live transcript, returned by * {@link Client.invokeAgent}. The identity fields (`id`, `sessionId`, …) are * available immediately; the transcript stream is lazy — iteration opens it, * so a caller that never iterates pays for nothing beyond the invoke itself. * * `for await` the handle to render the turn as it streams; it yields after * every state change and completes once this turn reaches a terminal * `turn.upsert` (already applied — `status` reflects it), reconnecting through * stream rotations and dropped connections along the way. The full session * stream is consumed internally so the resume cursor stays valid when other * turns interleave; {@link messages} is scoped to this turn, and * {@link transcript} exposes the whole session view. * * ```ts * const turn = await client.invokeAgent({ agentName: "support", content }); * for await (const t of turn) render(t.messages()); * turn.status; // "completed" * ``` */ export declare class TurnTranscript implements AsyncIterable { #private; /** Turn id. */ readonly id: string; /** Id of the session this turn runs in. */ readonly sessionId: string; /** * Message sequence from the turn-start response. It is not a stream * cursor: to follow the turn yourself, open `GET …/transcript/stream` from * the response's `resume_cursor`. */ readonly afterSequence: number; /** True when a repeated idempotency key returned an existing turn without restarting it. */ readonly deduped: boolean; /** Full session view the stream folds into. */ readonly transcript: SessionTranscript; /** @internal Constructed by {@link Client.invokeAgent}. */ constructor(client: Client, ack: TurnAck, transcript: SessionTranscript, signal?: AbortSignal); /** * The turn's lifecycle status ("queued", "running", "completed", …). It is * live: each applied `turn.upsert` updates it. */ get status(): string; get errorType(): string | undefined; get errorMessage(): string | undefined; /** * The turn's validated structured output, present only on a completed turn * that declared an output contract (see {@link InvokeAgentOptions.output}). * `undefined` until the terminal `turn.upsert` frame is applied. Read this * instead of parsing the transcript messages. */ get output(): Record | undefined; /** * Where {@link output} came from: `"tool"` when the agent submitted it * through the reserved `mobius_submit_output` tool, or `"text"` when Mobius * accepted a schema-valid final message as a fallback. `undefined` when the * turn produced no structured output. */ get outputSource(): AgentTurnOutputSource | undefined; get error(): Error | undefined; /** This turn's rows, in render order. */ messages(): SessionTranscriptMessage[]; /** This turn's policy-light rendering projection. */ renderableMessages(): SessionTranscriptMessage[]; /** Last observed transport and turn facts; no backend state is inferred. */ diagnostics(): TranscriptDiagnostics; /** * Yield observed protocol frames while folding the full session. The * terminal update is exposed only after its incremental durable snapshot is * reconciled; snapshot failures reject iteration. */ updates(): AsyncGenerator; [Symbol.asyncIterator](): AsyncIterator; } //# sourceMappingURL=client.d.ts.map