/** * Messages and runs: what the user sends, and the work the agent does in response. * * One message shape carries the whole conversation — history, send acceptances, * and events all speak it. */ import { type Static } from "@sinclair/typebox"; import { type Cuid2, type EventCursor, type MessageMode, type Timestamp } from "./common.js"; import type { UsageBreakdown } from "./usage.js"; /** One read the exploration performed: a listing, a file read, or a search. */ export declare const explorationOperationSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ kind: import("@sinclair/typebox").TLiteral<"list">; target: import("@sinclair/typebox").TString; }>, import("@sinclair/typebox").TObject<{ kind: import("@sinclair/typebox").TLiteral<"read">; name: import("@sinclair/typebox").TString; }>, import("@sinclair/typebox").TObject<{ command: import("@sinclair/typebox").TString; kind: import("@sinclair/typebox").TLiteral<"search">; path: import("@sinclair/typebox").TOptional; query: import("@sinclair/typebox").TOptional; }>]>; /** One read the exploration performed: a listing, a file read, or a search. */ export type ExplorationOperation = Static; /** Reading around the codebase: listings, file reads, and searches. */ export declare const explorationPresentationSchema: import("@sinclair/typebox").TObject<{ operations: import("@sinclair/typebox").TArray; target: import("@sinclair/typebox").TString; }>, import("@sinclair/typebox").TObject<{ kind: import("@sinclair/typebox").TLiteral<"read">; name: import("@sinclair/typebox").TString; }>, import("@sinclair/typebox").TObject<{ command: import("@sinclair/typebox").TString; kind: import("@sinclair/typebox").TLiteral<"search">; path: import("@sinclair/typebox").TOptional; query: import("@sinclair/typebox").TOptional; }>]>>; type: import("@sinclair/typebox").TLiteral<"exploration">; }>; /** Reading around the codebase: listings, file reads, and searches. */ export type ExplorationPresentation = Static; /** A shell command; `output` arrives on completion. */ export declare const execCommandPresentationSchema: import("@sinclair/typebox").TObject<{ command: import("@sinclair/typebox").TString; output: import("@sinclair/typebox").TOptional>; /** Set when the command kept running and became a background terminal. */ terminalId: import("@sinclair/typebox").TOptional>; type: import("@sinclair/typebox").TLiteral<"exec_command">; }>; /** A shell command; `output` arrives on completion. */ export type ExecCommandPresentation = Static; /** Input typed into an existing background terminal. */ export declare const backgroundTerminalInteractionPresentationSchema: import("@sinclair/typebox").TObject<{ /** What the terminal is running. */ command: import("@sinclair/typebox").TString; /** What was typed into it. */ input: import("@sinclair/typebox").TString; terminalId: import("@sinclair/typebox").TString; type: import("@sinclair/typebox").TLiteral<"background_terminal_interaction">; }>; /** Input typed into an existing background terminal. */ export type BackgroundTerminalInteractionPresentation = Static; /** One line of a hunk. */ export declare const fileDiffLineSchema: import("@sinclair/typebox").TObject<{ kind: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"context">, import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"delete">]>; text: import("@sinclair/typebox").TString; }>; /** One line of a hunk. */ export type FileDiffLine = Static; /** A contiguous run of diff lines, numbered against both sides. */ export declare const fileDiffHunkSchema: import("@sinclair/typebox").TObject<{ lines: import("@sinclair/typebox").TArray, import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"delete">]>; text: import("@sinclair/typebox").TString; }>>; newStart: import("@sinclair/typebox").TInteger; oldStart: import("@sinclair/typebox").TInteger; }>; /** A contiguous run of diff lines, numbered against both sides. */ export type FileDiffHunk = Static; /** One file's changes inside a diff presentation. */ export declare const fileDiffSchema: import("@sinclair/typebox").TObject<{ added: import("@sinclair/typebox").TInteger; deleted: import("@sinclair/typebox").TInteger; hunks: import("@sinclair/typebox").TArray, import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"delete">]>; text: import("@sinclair/typebox").TString; }>>; newStart: import("@sinclair/typebox").TInteger; oldStart: import("@sinclair/typebox").TInteger; }>>; kind: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"delete">, import("@sinclair/typebox").TLiteral<"update">]>; /** For syntax highlighting, when the daemon could name the language. */ language: import("@sinclair/typebox").TOptional; /** How many lines this file's hunks left out. */ omittedLines: import("@sinclair/typebox").TOptional; path: import("@sinclair/typebox").TString; }>; /** One file's changes inside a diff presentation. */ export type FileDiff = Static; /** File changes, one or many files per call. */ export declare const fileDiffPresentationSchema: import("@sinclair/typebox").TObject<{ files: import("@sinclair/typebox").TArray, import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"delete">]>; text: import("@sinclair/typebox").TString; }>>; newStart: import("@sinclair/typebox").TInteger; oldStart: import("@sinclair/typebox").TInteger; }>>; kind: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"delete">, import("@sinclair/typebox").TLiteral<"update">]>; /** For syntax highlighting, when the daemon could name the language. */ language: import("@sinclair/typebox").TOptional; /** How many lines this file's hunks left out. */ omittedLines: import("@sinclair/typebox").TOptional; path: import("@sinclair/typebox").TString; }>>; /** How many files the call changed but the presentation left out. */ omittedFiles: import("@sinclair/typebox").TOptional; type: import("@sinclair/typebox").TLiteral<"file_diff">; }>; /** File changes, one or many files per call. */ export type FileDiffPresentation = Static; /** One source a search drew from. */ export declare const searchSourceSchema: import("@sinclair/typebox").TObject<{ title: import("@sinclair/typebox").TString; url: import("@sinclair/typebox").TString; }>; /** One source a search drew from. */ export type SearchSource = Static; /** A web or X search; `sources` arrives on completion. */ export declare const searchPresentationSchema: import("@sinclair/typebox").TObject<{ query: import("@sinclair/typebox").TString; sources: import("@sinclair/typebox").TOptional>>; target: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"web">, import("@sinclair/typebox").TLiteral<"x">]>; type: import("@sinclair/typebox").TLiteral<"search">; }>; /** A web or X search; `sources` arrives on completion. */ export type SearchPresentation = Static; /** The exact model/provider pair resolved by the sub-agent creation path. */ export declare const agentSpawnModelSchema: import("@sinclair/typebox").TObject<{ modelId: import("@sinclair/typebox").TString; providerId: import("@sinclair/typebox").TString; /** Human-readable catalog name, captured before creation and retained in history. */ name: import("@sinclair/typebox").TString; }>; /** The exact model/provider pair resolved by the sub-agent creation path. */ export type AgentSpawnModel = Static; /** Sub-agent creation; the enclosing tool status owns its lifecycle. */ export declare const agentSpawnPresentationSchema: import("@sinclair/typebox").TObject<{ type: import("@sinclair/typebox").TLiteral<"agent_spawn">; /** Absent until the creation path has resolved and validated the complete identity. */ model: import("@sinclair/typebox").TOptional>; /** The child identity, supplied only after creation and initial-task delivery succeed. */ agentId: import("@sinclair/typebox").TOptional; }>; /** Sub-agent creation; the enclosing tool status owns its lifecycle. */ export type AgentSpawnPresentation = Static; /** Every display-ready tool-call presentation the client understands. */ export declare const toolPresentationSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ operations: import("@sinclair/typebox").TArray; target: import("@sinclair/typebox").TString; }>, import("@sinclair/typebox").TObject<{ kind: import("@sinclair/typebox").TLiteral<"read">; name: import("@sinclair/typebox").TString; }>, import("@sinclair/typebox").TObject<{ command: import("@sinclair/typebox").TString; kind: import("@sinclair/typebox").TLiteral<"search">; path: import("@sinclair/typebox").TOptional; query: import("@sinclair/typebox").TOptional; }>]>>; type: import("@sinclair/typebox").TLiteral<"exploration">; }>, import("@sinclair/typebox").TObject<{ command: import("@sinclair/typebox").TString; output: import("@sinclair/typebox").TOptional>; /** Set when the command kept running and became a background terminal. */ terminalId: import("@sinclair/typebox").TOptional>; type: import("@sinclair/typebox").TLiteral<"exec_command">; }>, import("@sinclair/typebox").TObject<{ /** What the terminal is running. */ command: import("@sinclair/typebox").TString; /** What was typed into it. */ input: import("@sinclair/typebox").TString; terminalId: import("@sinclair/typebox").TString; type: import("@sinclair/typebox").TLiteral<"background_terminal_interaction">; }>, import("@sinclair/typebox").TObject<{ files: import("@sinclair/typebox").TArray, import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"delete">]>; text: import("@sinclair/typebox").TString; }>>; newStart: import("@sinclair/typebox").TInteger; oldStart: import("@sinclair/typebox").TInteger; }>>; kind: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"add">, import("@sinclair/typebox").TLiteral<"delete">, import("@sinclair/typebox").TLiteral<"update">]>; /** For syntax highlighting, when the daemon could name the language. */ language: import("@sinclair/typebox").TOptional; /** How many lines this file's hunks left out. */ omittedLines: import("@sinclair/typebox").TOptional; path: import("@sinclair/typebox").TString; }>>; /** How many files the call changed but the presentation left out. */ omittedFiles: import("@sinclair/typebox").TOptional; type: import("@sinclair/typebox").TLiteral<"file_diff">; }>, import("@sinclair/typebox").TObject<{ query: import("@sinclair/typebox").TString; sources: import("@sinclair/typebox").TOptional>>; target: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"web">, import("@sinclair/typebox").TLiteral<"x">]>; type: import("@sinclair/typebox").TLiteral<"search">; }>, import("@sinclair/typebox").TObject<{ type: import("@sinclair/typebox").TLiteral<"agent_spawn">; /** Absent until the creation path has resolved and validated the complete identity. */ model: import("@sinclair/typebox").TOptional>; /** The child identity, supplied only after creation and initial-task delivery succeed. */ agentId: import("@sinclair/typebox").TOptional; }>]>; /** Every display-ready tool-call presentation the client understands. */ export type ToolPresentation = Static; /** Stable provenance carried with a message without exposing internal module metadata. */ export declare const messageMetadataSchema: import("@sinclair/typebox").TObject<{ /** The provider that produced this message, when it came from inference. */ providerId: import("@sinclair/typebox").TOptional; /** The model that produced this message, when it came from inference. */ modelId: import("@sinclair/typebox").TOptional; /** The agent that sent this system-generated message, when one identified itself. */ senderAgentId: import("@sinclair/typebox").TOptional; /** The authenticated team member's local Happy user ID, captured at submission. */ userId: import("@sinclair/typebox").TOptional; }>; export type MessageMetadata = Static; /** One JSON value inside opaque client-owned message metadata. */ export declare const clientMetadataValueSchema: import("@sinclair/typebox").TRecursive, import("@sinclair/typebox").TRecord]>>; /** One JSON value inside opaque client-owned message metadata. */ export type ClientMetadataValue = Static; /** Freeform JSON supplied by a client and durably attached to one user message. */ export declare const clientMetadataSchema: import("@sinclair/typebox").TRecord, import("@sinclair/typebox").TRecord]>>>; /** Freeform JSON supplied by a client and durably attached to one user message. */ export type ClientMetadata = Static; /** An explicit request in a user message for Agent Base to execute one tool before inference. */ export declare const toolCallRequestBlockSchema: import("@sinclair/typebox").TObject<{ arguments: import("@sinclair/typebox").TOptional, import("@sinclair/typebox").TRecord]>>>>; name: import("@sinclair/typebox").TString; type: import("@sinclair/typebox").TLiteral<"tool_call_request">; }>; /** An explicit request in a user message for Agent Base to execute one tool before inference. */ export type ToolCallRequestBlock = Static; /** What is in a message, in order. */ export type MessageBlock = TextBlock | ImageBlock | ToolCallRequestBlock | ReasoningBlock | ToolCallBlock | CompactionBlock; /** Plain text. */ export interface TextBlock { type: "text"; text: string; } /** An image travelling inline with the message. */ export interface ImageBlock { type: "image"; mimeType: string; /** Base64 image bytes, travelling inline. */ data: string; } /** The model's thinking summary, when the provider surfaces one. */ export interface ReasoningBlock { type: "reasoning"; text: string; } /** Risk assigned by the automatic permission reviewer. */ export type ToolPermissionRisk = "low" | "medium" | "high" | "critical"; /** How strongly the conversation authorized an automatically reviewed action. */ export type ToolPermissionUserAuthorization = "unknown" | "low" | "medium" | "high"; /** The bounded result of reviewing one tool call. */ export type ToolPermissionReview = { outcome: "allowed"; reason: string; risk: ToolPermissionRisk; userAuthorization: ToolPermissionUserAuthorization; } | { outcome: "denied"; reason: string; risk: ToolPermissionRisk; userAuthorization: ToolPermissionUserAuthorization; } | { outcome: "unproven"; kind: "timed_out" | "unavailable"; reason: string; }; interface ToolCallBlockBase { type: "tool_call"; /** Happy Agent Base's stable CUID2 identity for this invocation. */ id: string; name: string; status: "running" | "completed" | "failed"; /** Raw tool arguments; absent under `omitToolData`. */ arguments?: Record; /** Raw tool result; absent under `omitToolData` and until the call finishes. */ result?: Record; /** A typed rendering of what the call did, when the daemon produced one. */ presentation?: ToolPresentation; } /** A tool call that did not cross the automatic-review boundary. */ export interface UnreviewedToolCallBlock extends ToolCallBlockBase { elevated?: never; review?: never; } /** A reviewed tool call, including whether its eventual execution used temporary Full access. */ export interface ReviewedToolCallBlock extends ToolCallBlockBase { elevated: boolean; review: ToolPermissionReview; } /** One tool invocation. Review metadata is present as one complete, discriminated pair. */ export type ToolCallBlock = UnreviewedToolCallBlock | ReviewedToolCallBlock; /** What requested a context compaction. */ export declare const compactionTriggerSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"manual">, import("@sinclair/typebox").TLiteral<"automatic">]>; export type CompactionTrigger = Static; /** A compaction that has started but has not settled. */ export declare const runningCompactionBlockSchema: import("@sinclair/typebox").TObject<{ completedAt: import("@sinclair/typebox").TNull; failureReason: import("@sinclair/typebox").TNull; startedAt: import("@sinclair/typebox").TInteger; status: import("@sinclair/typebox").TLiteral<"running">; tokensAfter: import("@sinclair/typebox").TNull; tokensBefore: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>; trigger: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"manual">, import("@sinclair/typebox").TLiteral<"automatic">]>; type: import("@sinclair/typebox").TLiteral<"compaction">; }>; export type RunningCompactionBlock = Static; /** A successfully replaced context, optionally measured by a later inference. */ export declare const completedCompactionBlockSchema: import("@sinclair/typebox").TObject<{ completedAt: import("@sinclair/typebox").TInteger; failureReason: import("@sinclair/typebox").TNull; startedAt: import("@sinclair/typebox").TInteger; status: import("@sinclair/typebox").TLiteral<"completed">; tokensAfter: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>; tokensBefore: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>; trigger: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"manual">, import("@sinclair/typebox").TLiteral<"automatic">]>; type: import("@sinclair/typebox").TLiteral<"compaction">; }>; export type CompletedCompactionBlock = Static; /** A provider failure, cancellation, or interrupted compaction. */ export declare const failedCompactionBlockSchema: import("@sinclair/typebox").TObject<{ completedAt: import("@sinclair/typebox").TInteger; failureReason: import("@sinclair/typebox").TString; startedAt: import("@sinclair/typebox").TInteger; status: import("@sinclair/typebox").TLiteral<"failed">; tokensAfter: import("@sinclair/typebox").TNull; tokensBefore: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>; trigger: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"manual">, import("@sinclair/typebox").TLiteral<"automatic">]>; type: import("@sinclair/typebox").TLiteral<"compaction">; }>; export type FailedCompactionBlock = Static; /** One typed context-compaction lifecycle inside a durable service message. */ export declare const compactionBlockSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{ completedAt: import("@sinclair/typebox").TNull; failureReason: import("@sinclair/typebox").TNull; startedAt: import("@sinclair/typebox").TInteger; status: import("@sinclair/typebox").TLiteral<"running">; tokensAfter: import("@sinclair/typebox").TNull; tokensBefore: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>; trigger: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"manual">, import("@sinclair/typebox").TLiteral<"automatic">]>; type: import("@sinclair/typebox").TLiteral<"compaction">; }>, import("@sinclair/typebox").TObject<{ completedAt: import("@sinclair/typebox").TInteger; failureReason: import("@sinclair/typebox").TNull; startedAt: import("@sinclair/typebox").TInteger; status: import("@sinclair/typebox").TLiteral<"completed">; tokensAfter: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>; tokensBefore: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>; trigger: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"manual">, import("@sinclair/typebox").TLiteral<"automatic">]>; type: import("@sinclair/typebox").TLiteral<"compaction">; }>, import("@sinclair/typebox").TObject<{ completedAt: import("@sinclair/typebox").TInteger; failureReason: import("@sinclair/typebox").TString; startedAt: import("@sinclair/typebox").TInteger; status: import("@sinclair/typebox").TLiteral<"failed">; tokensAfter: import("@sinclair/typebox").TNull; tokensBefore: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>; trigger: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"manual">, import("@sinclair/typebox").TLiteral<"automatic">]>; type: import("@sinclair/typebox").TLiteral<"compaction">; }>]>; export type CompactionBlock = Static; /** Whether a message waits behind the current run or interrupts it. */ export type MessageDelivery = "queue" | "steer"; /** A message, whoever produced it. */ export type Message = UserMessage | AgentMessage | SystemMessage | ServiceMessage; /** Sent by a person. */ export interface UserMessage { id: Cuid2; role: "user"; createdAt: Timestamp; content: MessageBlock[]; metadata: MessageMetadata; /** Opaque client-owned JSON, when the sender supplied it. */ clientMetadata?: ClientMetadata; /** Opaque request profile; a change resets the model's private conversation context. */ profile?: string | null; /** `"pending"` until inference takes the message up. */ status: "pending" | "accepted"; delivery: MessageDelivery; mode: MessageMode; /** `null` while pending; assigned at acceptance and the handle for abort. */ runId: Cuid2 | null; } /** Produced by the model: its text, reasoning, and tool calls. */ export interface AgentMessage { id: Cuid2; role: "agent"; createdAt: Timestamp; content: MessageBlock[]; metadata: MessageMetadata; } /** Content the daemon injected into the model's context, when worth showing. */ export interface SystemMessage { id: Cuid2; role: "system"; createdAt: Timestamp; content: MessageBlock[]; metadata: MessageMetadata; } /** Operational records the model never saw: compaction, aborts, housekeeping. */ export interface ServiceMessage { id: Cuid2; role: "service"; createdAt: Timestamp; content: MessageBlock[]; metadata: MessageMetadata; } /** The exact durable message shape used for one compaction attempt. */ export interface CompactionMessage extends Omit { content: [CompactionBlock]; } /** The run's outcome. */ export type RunStatus = "running" | "completed" | "aborted" | "failed"; /** Why a run ended; status is the outcome, reason is the cause. */ export type RunReason = "completed" | "steering" | "abort" | "error"; /** The work an agent did in response to a message. */ export interface Run { id: Cuid2; status: RunStatus; reason: RunReason | null; startedAt: Timestamp; endedAt: Timestamp | null; usage: UsageBreakdown; costUsd: number | null; } /** One whole history group, with its messages oldest first. */ export interface HistoryRun extends Run { /** Oldest first. */ messages: Message[]; } /** `POST /v0/agents/:agentId/send` */ export interface SendMessageRequest { /** Optional client-chosen identity. Reusing it returns the existing message. */ id?: Cuid2; /** The message text. Required. */ text: string; /** Opaque JSON to persist and return with this user message. */ clientMetadata?: ClientMetadata; /** Optional rich blocks accompanying the text; image bytes travel inline. */ content?: MessageBlock[]; /** Defaults to `"queue"`. On an idle agent the two are identical. */ delivery?: MessageDelivery; /** Opaque context profile. Omitted and `null` both select the default profile. */ profile?: string | null; /** The model selection and permission mode this message runs with. */ mode: MessageMode; } /** `POST /v0/agents/:agentId/send` */ export interface SendMessageResponse { message: UserMessage; /** The event cursor at send; streaming from it replays everything this causes. */ cursor: EventCursor; } /** `GET /v0/agents/:agentId/messages` query parameters. */ export interface MessageHistoryQuery { /** A run ID; return runs older than it. Cannot be combined with `after`. */ before?: Cuid2; /** A message ID; return the messages that came after it. */ after?: Cuid2; /** * A lower bound counted in messages, not an upper one: a page always * contains whole runs and may overflow well past it. */ limit?: number; /** Drop raw data for presented calls, except `agent_spawn` keeps older-client fallback. */ omitToolData?: boolean; } /** `GET /v0/agents/:agentId/messages` */ export declare const messageHistoryResponseSchema: import("@sinclair/typebox").TObject<{ /** The event cursor captured before the history read. */ cursor: import("@sinclair/typebox").TString; hasMore: import("@sinclair/typebox").TBoolean; /** Oldest first, whole runs only. */ runs: import("@sinclair/typebox").TArray>; }>; /** `GET /v0/agents/:agentId/messages` */ export type MessageHistoryResponse = Static; export {}; //# sourceMappingURL=messages.d.ts.map