import { BaseApi } from "../base-api"; import type { ApiRecordsV2, PagePagination } from "../types"; import type { ConversationId, ConversationResponse, CreateConversationRequest, CreateRunRequest, ListMessagesResponse, RunId, RunResponse } from "./types"; export * from "./types"; /** * @module AgentsApi * @description Agent Conversations: long-lived conversations with pinned system * prompt + defaults, asynchronous runs that may pause for caller-declared * tool outputs, and a versioned delta-cursor message stream. * * @see https://docs.narrative.io/reference/architecture/agent-conversations * * @extends BaseApi */ export declare class AgentsApi extends BaseApi { /** * Create an agent conversation. `system_prompt` and `defaults.{tools,mcp_servers}` * are pinned at creation; everything else in `defaults` is overridable per-run. */ createAgentConversation(request: CreateConversationRequest): Promise; /** * List the calling user's agent conversations, newest first by `created_at`. * Scoped to both `company_id` and `user_id` from the bearer token — peers in * the same company are not visible. Never 404s; empty state is `records: []`. */ listAgentConversations(options?: PagePagination): Promise>; /** * Read a conversation's metadata + current `version`. Always re-read this * immediately before starting a run — `version` is the compare-and-swap * token for `expected_version` and a stale value yields 409. */ getAgentConversation(conversationId: ConversationId): Promise; /** * Delta-read conversation messages with `sequence_no > since`. Use the * returned `current_version` as the next call's `since` for gap-free reads. */ listAgentConversationMessages(conversationId: ConversationId, options?: { since?: number; }): Promise; /** * Start a new run on the conversation. Returns immediately with * `status: "pending"` — poll {@link getAgentRun} until terminal. * * - Generate a fresh UUID for `client_op_id` per logical request (it's the * idempotency key; reusing one is only safe as a retry). * - Set `expected_version` to the value just read from * {@link getAgentConversation} — mismatches return 409. */ createAgentRun(conversationId: ConversationId, request: CreateRunRequest): Promise; /** * Read a run's current state. Terminal states: `completed`, * `requires_action`, `failed`. Stop polling on any of them. */ getAgentRun(runId: RunId): Promise; /** * Convenience: poll {@link getAgentRun} until terminal. Caller is responsible * for selecting a reasonable backoff; defaults to 1.5s fixed interval with a * 2-minute ceiling. * * Returns the terminal run. Throws on `failed` only if `throwOnFailed` is * true; otherwise the caller inspects `run.status === "failed"`. */ waitForAgentRun(runId: RunId, options?: { intervalMs?: number; timeoutMs?: number; signal?: AbortSignal; onTick?: (run: RunResponse) => void; throwOnFailed?: boolean; }): Promise; }