import { ActivityDeltaEvent, ActivityMessage, ActivitySnapshotEvent, AgentCapabilities, BaseEvent, CustomEvent, Interrupt, Message, MessagesSnapshotEvent, Metadata, RawEvent, ReasoningEncryptedValueEvent, ReasoningEndEvent, ReasoningMessageContentEvent, ReasoningMessageEndEvent, ReasoningMessageStartEvent, ReasoningStartEvent, ResumeEntry, RunAgentInput, RunErrorEvent, RunFinishedEvent, RunFinishedOutcome, RunStartedEvent, State, StateDeltaEvent, StateSnapshotEvent, StepFinishedEvent, StepStartedEvent, SubagentErrorEvent, SubagentFinishedEvent, SubagentStartedEvent, TextMessageContentEvent, TextMessageEndEvent, TextMessageStartEvent, ToolCall, ToolCallArgsEvent, ToolCallEndEvent, ToolCallResultEvent, ToolCallStartEvent } from "@ag-ui/core"; import { Observable } from "rxjs"; export * from "@ag-ui/core"; //#region src/agent/types.d.ts /** Normalized debug configuration for the AG-UI agent. */ interface ResolvedAgentDebugConfig { enabled: boolean; events: boolean; lifecycle: boolean; verbose: boolean; } /** Debug input — boolean shorthand or granular config. */ type AgentDebugConfig = boolean | { events?: boolean; lifecycle?: boolean; verbose?: boolean; }; /** Resolves an AgentDebugConfig into a normalized ResolvedAgentDebugConfig. */ declare function resolveAgentDebugConfig(debug: AgentDebugConfig | undefined): ResolvedAgentDebugConfig; interface AgentConfig { agentId?: string; description?: string; threadId?: string; initialMessages?: Message[]; initialState?: State; debug?: AgentDebugConfig; } type HttpAgentFetchFn = (url: string, requestInit: RequestInit) => Promise; interface HttpAgentConfig extends AgentConfig { url: string; headers?: Record; fetch?: HttpAgentFetchFn; } interface RunAgentParameters extends Partial> { /** Per-interrupt responses addressing every open interrupt from the previous run. */ resume?: ResumeEntry[]; } //#endregion //#region src/debug-logger.d.ts /** Accepted input wherever a debug logger can be provided. */ type DebugLoggerInput = DebugLogger | boolean | null | undefined; /** * Resolves a DebugLoggerInput into a DebugLogger or undefined. * - `true` → creates a new DebugLogger with all logging enabled * - `DebugLogger` instance → returned as-is * - `false`, `null`, `undefined` → returns undefined */ declare function resolveDebugLogger(input: DebugLoggerInput): DebugLogger | undefined; /** * Centralized debug logger for the AG-UI event pipeline. * Handles verbose vs summary output based on config. */ declare class DebugLogger { private config; constructor(config: ResolvedAgentDebugConfig); /** * Log an event-level debug message. * Only logs when `config.events` is enabled. * In verbose mode, logs the full data; otherwise logs the summary. */ event(prefix: string, label: string, data: unknown, summary?: Record): void; /** * Log a lifecycle-level debug message. * Only logs when `config.lifecycle` is enabled. */ lifecycle(prefix: string, label: string, data?: Record): void; /** Whether event-level logging is enabled. */ get eventsEnabled(): boolean; /** Whether lifecycle-level logging is enabled. */ get lifecycleEnabled(): boolean; /** Whether any logging is enabled. */ get enabled(): boolean; } /** * Creates a DebugLogger if debug is enabled, otherwise returns undefined. * This allows consumers to pass it around cheaply when debug is off. */ declare function createDebugLogger(config: ResolvedAgentDebugConfig): DebugLogger | undefined; //#endregion //#region src/legacy/types.d.ts declare const LegacyRuntimeMetaEventName: { readonly LangGraphInterruptEvent: "LangGraphInterruptEvent"; readonly PredictState: "PredictState"; readonly Exit: "Exit"; }; type RuntimeMetaEventName = (typeof LegacyRuntimeMetaEventName)[keyof typeof LegacyRuntimeMetaEventName]; interface LegacyTextMessageStart { type: "TextMessageStart"; messageId: string; parentMessageId?: string; role?: string; } interface LegacyTextMessageContent { type: "TextMessageContent"; messageId: string; content: string; } interface LegacyTextMessageEnd { type: "TextMessageEnd"; messageId: string; } interface LegacyActionExecutionStart { type: "ActionExecutionStart"; actionExecutionId: string; actionName: string; parentMessageId?: string; } interface LegacyActionExecutionArgs { type: "ActionExecutionArgs"; actionExecutionId: string; args: string; } interface LegacyActionExecutionEnd { type: "ActionExecutionEnd"; actionExecutionId: string; } interface LegacyActionExecutionResult { type: "ActionExecutionResult"; actionName: string; actionExecutionId: string; result: string; } interface LegacyAgentStateMessage { type: "AgentStateMessage"; threadId: string; agentName: string; nodeName: string; runId: string; active: boolean; role: string; state: string; running: boolean; } interface LegacyMetaEvent { type: "MetaEvent"; name: RuntimeMetaEventName; value?: any; } interface LegacyRunError { type: "RunError"; message: string; code?: string; } type LegacyRuntimeProtocolEvent = LegacyTextMessageStart | LegacyTextMessageContent | LegacyTextMessageEnd | LegacyActionExecutionStart | LegacyActionExecutionArgs | LegacyActionExecutionEnd | LegacyActionExecutionResult | LegacyAgentStateMessage | LegacyMetaEvent | LegacyRunError; //#endregion //#region src/agent/subscriber.d.ts interface AgentStateMutation { messages?: Message[]; state?: State; stopPropagation?: boolean; } interface AgentSubscriberParams { messages: ReadonlyArray>; state: Readonly; agent: AbstractAgent; input: RunAgentInput; } type MaybePromise = T | Promise; interface AgentSubscriber { onRunInitialized?(params: AgentSubscriberParams): MaybePromise | void>; onRunFailed?(params: { error: Error; } & AgentSubscriberParams): MaybePromise | void>; onRunFinalized?(params: AgentSubscriberParams): MaybePromise | void>; onEvent?(params: { event: BaseEvent; } & AgentSubscriberParams): MaybePromise; onRunStartedEvent?(params: { event: RunStartedEvent; } & AgentSubscriberParams): MaybePromise; onRunFinishedEvent?(params: ({ event: RunFinishedEvent; outcome: "success"; result?: unknown; /** * Tool calls the run left for the application to answer, in order. * The producer's `outcome.pendingToolCallIds` when it named them; * otherwise derived from the stream: every tool call this run * started that received no TOOL_CALL_RESULT. */ pendingToolCallIds: string[]; } | { event: RunFinishedEvent; outcome: "interrupt"; interrupts: Interrupt[]; } | { event: RunFinishedEvent; outcome: "cancelled"; }) & AgentSubscriberParams): MaybePromise; onRunErrorEvent?(params: { event: RunErrorEvent; } & AgentSubscriberParams): MaybePromise; onStepStartedEvent?(params: { event: StepStartedEvent; } & AgentSubscriberParams): MaybePromise; onStepFinishedEvent?(params: { event: StepFinishedEvent; } & AgentSubscriberParams): MaybePromise; onSubagentStartedEvent?(params: { event: SubagentStartedEvent; } & AgentSubscriberParams): MaybePromise; onSubagentFinishedEvent?(params: { event: SubagentFinishedEvent; } & AgentSubscriberParams): MaybePromise; onSubagentErrorEvent?(params: { event: SubagentErrorEvent; } & AgentSubscriberParams): MaybePromise; onTextMessageStartEvent?(params: { event: TextMessageStartEvent; } & AgentSubscriberParams): MaybePromise; onTextMessageContentEvent?(params: { event: TextMessageContentEvent; textMessageBuffer: string; } & AgentSubscriberParams): MaybePromise; onTextMessageEndEvent?(params: { event: TextMessageEndEvent; textMessageBuffer: string; } & AgentSubscriberParams): MaybePromise; onToolCallStartEvent?(params: { event: ToolCallStartEvent; } & AgentSubscriberParams): MaybePromise; onToolCallArgsEvent?(params: { event: ToolCallArgsEvent; toolCallBuffer: string; toolCallName: string; partialToolCallArgs: Record; } & AgentSubscriberParams): MaybePromise; onToolCallEndEvent?(params: { event: ToolCallEndEvent; toolCallName: string; toolCallArgs: Record; } & AgentSubscriberParams): MaybePromise; onToolCallResultEvent?(params: { event: ToolCallResultEvent; } & AgentSubscriberParams): MaybePromise; onStateSnapshotEvent?(params: { event: StateSnapshotEvent; } & AgentSubscriberParams): MaybePromise; onStateDeltaEvent?(params: { event: StateDeltaEvent; } & AgentSubscriberParams): MaybePromise; onMessagesSnapshotEvent?(params: { event: MessagesSnapshotEvent; } & AgentSubscriberParams): MaybePromise; onActivitySnapshotEvent?(params: { event: ActivitySnapshotEvent; activityMessage?: ActivityMessage; existingMessage?: Message; } & AgentSubscriberParams): MaybePromise; onActivityDeltaEvent?(params: { event: ActivityDeltaEvent; activityMessage?: ActivityMessage; } & AgentSubscriberParams): MaybePromise; onRawEvent?(params: { event: RawEvent; } & AgentSubscriberParams): MaybePromise; onCustomEvent?(params: { event: CustomEvent; } & AgentSubscriberParams): MaybePromise; onReasoningStartEvent?(params: { event: ReasoningStartEvent; } & AgentSubscriberParams): MaybePromise; onReasoningMessageStartEvent?(params: { event: ReasoningMessageStartEvent; } & AgentSubscriberParams): MaybePromise; onReasoningMessageContentEvent?(params: { event: ReasoningMessageContentEvent; reasoningMessageBuffer: string; } & AgentSubscriberParams): MaybePromise; onReasoningMessageEndEvent?(params: { event: ReasoningMessageEndEvent; reasoningMessageBuffer: string; } & AgentSubscriberParams): MaybePromise; onReasoningEndEvent?(params: { event: ReasoningEndEvent; } & AgentSubscriberParams): MaybePromise; onReasoningEncryptedValueEvent?(params: { event: ReasoningEncryptedValueEvent; } & AgentSubscriberParams): MaybePromise; onMessagesChanged?(params: Omit & { input?: RunAgentInput; }): MaybePromise; onStateChanged?(params: Omit & { input?: RunAgentInput; }): MaybePromise; onNewMessage?(params: { message: Message; } & Omit & { input?: RunAgentInput; }): MaybePromise; onNewToolCall?(params: { toolCall: ToolCall; } & Omit & { input?: RunAgentInput; }): MaybePromise; } //#endregion //#region src/agent/http.d.ts interface RunHttpAgentConfig extends RunAgentParameters { abortController?: AbortController; } declare class HttpAgent extends AbstractAgent { url: string; headers: Record; fetch: HttpAgentFetchFn; abortController: AbortController; /** * Returns the fetch config for the http request. * Override this to customize the request. * * @returns The fetch config for the http request. */ protected requestInit(input: RunAgentInput): RequestInit; runAgent(parameters?: RunHttpAgentConfig, subscriber?: AgentSubscriber): Promise; abortRun(): void; constructor(config: HttpAgentConfig); run(input: RunAgentInput): Observable; clone(): HttpAgent; } //#endregion //#region src/middleware/middleware.d.ts type MiddlewareFunction = (input: RunAgentInput, next: AbstractAgent) => Observable; interface EventWithState { event: BaseEvent; messages: Message[]; state: any; } declare abstract class Middleware { abstract run(input: RunAgentInput, next: AbstractAgent): Observable; /** * Runs the next agent in the chain with automatic chunk transformation. */ protected runNext(input: RunAgentInput, next: AbstractAgent): Observable; /** * Runs the next agent and tracks state, providing current messages and state with each event. * The messages and state represent the state AFTER the event has been applied. */ protected runNextWithState(input: RunAgentInput, next: AbstractAgent): Observable; } declare class FunctionMiddleware extends Middleware { private fn; constructor(fn: MiddlewareFunction); run(input: RunAgentInput, next: AbstractAgent): Observable; } //#endregion //#region src/middleware/filter-tool-calls.d.ts type FilterToolCallsConfig = { allowedToolCalls: string[]; disallowedToolCalls?: never; } | { disallowedToolCalls: string[]; allowedToolCalls?: never; }; declare class FilterToolCallsMiddleware extends Middleware { private readonly allowedTools?; private readonly disallowedTools?; constructor(config: FilterToolCallsConfig); /** * One middleware instance serves every run, so the set of blocked IDs cannot live on it. * * A stalled run whose subscription is still open is the case that makes this concrete: with the * set on the instance, the next run starting wipes the IDs that were still filtering the stalled * run's events, and its `TOOL_CALL_ARGS`, `TOOL_CALL_END` and `TOOL_CALL_RESULT` start coming * through for a tool the caller disallowed. Clearing at the end of a run has the same problem * from the other direction. * * `defer` gives each subscription its own set, and `RUN_STARTED` resets it, which is what covers * two runs arriving down one subscription: `run()` is called once there, so anything keyed to the * call rather than to the event never fires for the second run. */ run(input: RunAgentInput, next: AbstractAgent): Observable; private shouldFilterTool; } //#endregion //#region src/middleware/backward-compatibility-0-0-39.d.ts /** * Middleware placeholder that maintains compatibility with AG-UI 0.0.39 flows. * Currently it simply forwards all events to the next middleware/agent. */ declare class BackwardCompatibility_0_0_39 extends Middleware { run(input: RunAgentInput, next: AbstractAgent): Observable; } //#endregion //#region src/middleware/backward-compatibility-0-0-45.d.ts /** * Middleware that maps deprecated THINKING events to the new REASONING events. * * This ensures backward compatibility for agents that still emit legacy THINKING * events (THINKING_START, THINKING_END, THINKING_TEXT_MESSAGE_START, etc.) * by transforming them into the corresponding REASONING events. * * Event mapping: * - THINKING_START → REASONING_START * - THINKING_TEXT_MESSAGE_START → REASONING_MESSAGE_START * - THINKING_TEXT_MESSAGE_CONTENT → REASONING_MESSAGE_CONTENT * - THINKING_TEXT_MESSAGE_END → REASONING_MESSAGE_END * - THINKING_END → REASONING_END * */ declare class BackwardCompatibility_0_0_45 extends Middleware { private currentReasoningId; private currentMessageId; private warnAboutTransformation; run(input: RunAgentInput, next: AbstractAgent): Observable; private transformEvent; } //#endregion //#region src/middleware/backward-compatibility-0-0-57.d.ts /** * Client middleware that removes subagent-support additions when the REMOTE AGENT is * pre-subagent (its `maxProtocolVersion` <= 0.0.57; the shim is auto-inserted by that gate). * The old party is the upstream agent, not the downstream consumer (the current client * supports subagents). * * - client → agent (the run input): strips `subagentRunId` from every top-level message so * a pre-subagent agent never receives attribution it doesn't understand. This is the * load-bearing half — the client's replayed message history can carry `subagentRunId`, * and this is what protects the old agent from it. * - agent → client (the event stream): defensive normalization. A genuinely pre-subagent * agent cannot emit `SUBAGENT_*` events or `subagentRunId`, and any `RUN_STARTED.input` * echo was already sanitized on the way in — so this path guards mixed/proxied * pipelines rather than doing load-bearing translation. It drops * SUBAGENT_STARTED/FINISHED/ERROR events and strips `subagentRunId` from every remaining * event, from MESSAGES_SNAPSHOT messages, and from RUN_STARTED `input` messages. * * Scope: this removes the protocol-level `subagentRunId` field and the SUBAGENT_* event * types only. It does NOT recurse into opaque application payloads (`RAW.event`, * `CUSTOM.value`, `STATE_SNAPSHOT.snapshot`, `STATE_DELTA.delta`, activity `content`, * etc.). Non-lifecycle events a subagent produced (TEXT_MESSAGE_*, TOOL_CALL_*, ...) are * kept with their `subagentRunId` stripped, so they flatten into the parent thread — the * intended downgrade, since subagent separation cannot be represented to a consumer with * no concept of it. * * The subagent feature is purely additive, so this shim is a pure removal in both * directions; there is no field/event to translate (unlike 0.0.45's THINKING->REASONING). * * Who this actually fires for: `maxProtocolVersion` defaults to this library's own * version, which sits above every era threshold, so the shim is installed only for an * agent subclass that OVERRIDES the ceiling to declare an older backend. As of this * writing exactly ONE integration in this repository does: * `integrations/community/spring-ai/typescript/src/index.ts`, pinned at 0.0.39. * * An earlier version of this note claimed six, naming llama-index, pydantic-ai, ag2, * agno and crew-ai alongside it. That census was wrong, and three of those integrations * now carry tests asserting the opposite -- llama-index's `multimodal-passthrough`, * and crew-ai's and agno's `no-content-flattening`, each of which fails if the agent * starts pinning a ceiling again. Do not trust this paragraph either: it is a snapshot * of code that lives outside this package and nothing keeps it honest. Re-check with * `grep -rn "maxProtocolVersion\|maxVersion" integrations` before relying on it. * * Where the shim IS installed, the client → agent strip carries the weight: those * backends predate subagents, so a replayed history or a stored thread written by a * newer client must not deliver them attribution they cannot interpret. The * agent → client strip is the defensive counterpart described above. */ declare class BackwardCompatibility_0_0_57 extends Middleware { private warnDroppedLifecycleEvent; run(input: RunAgentInput, next: AbstractAgent): Observable; } //#endregion //#region src/middleware/compatibility-boundary.d.ts /** * The always-on pre-1.0 compatibility boundary. * * With enforcement running AFTER middleware (PNI-205), anything nobody * translates is stripped with a warning. This middleware is the translator: * it upgrades every retired-but-understood inbound shape into its 1.0 * equivalent, so no data an old peer sends is lost. It is deliberately NOT * version-gated — a legacy-shaped event arriving is itself the proof the * peer is old, and on a modern stream every branch below is a no-op. * Outgoing legacy binary attachments are also upgraded before the transport * validates or sends them. Their shape identifies the conversion regardless * of the peer ceiling; actual downgrades remain version-gated separately. * * Inbound conversions, each warned with a pointer to the repo-root * DEPRECATIONS.md: * - THINKING_* events -> their REASONING_* equivalents. The version-gated * BackwardCompatibility_0_0_45 runs the same state machine and keeps its * 0.0.45 threshold, but it is not untouched: its synthesized * REASONING_MESSAGE_START now says `role: "reasoning"` where it used to say * "assistant", the same correction made here, because enforcement moved * behind the middleware chain and made the invalid role fatal. In practice * only this translation runs: THIS middleware is appended innermost, so it * sees every thinking event first and the shim always finds nothing to do * (see the corpus README's "A shim with no fixture"). * - Legacy binary content parts inside inbound messages (MESSAGES_SNAPSHOT, * RUN_STARTED input) -> the modern media parts. * - The whole optional nulls listed in OPTIONAL_NULLS -> absent, on the event * itself, in RUN_FINISHED's outcome and usage entries, and inside * RUN_STARTED.input and inbound messages. Required and nested data nulls * survive. * * The THINKING_* and binary conversions warn once per occurrence. An optional * null warns once per field and location per run: a producer that writes one * writes it on every event, and a warning per event would bury the stream. */ declare class CompatibilityBoundary extends Middleware { private currentReasoningId; private currentMessageId; private nullsNoticedThisRun; private readonly noticeNullOncePerRun; private warn; /** * A THINKING_* continuation names nothing: the id it belongs to lives in * this middleware's state, put there by the matching opener. When no opener * preceded it, there is no id to reuse and one is MINTED — which turns a * producer's "content with no start" into a REASONING_* event naming an id * nothing ever opened. Verification rejects that a few stages later, with a * message about an id no producer ever wrote, so the mint is announced here: * without this line the rejection is untraceable to its cause. */ private mintedContinuationId; /** * A conversion side effect the caller has to be told about in its own * sentence: something lost, or something invented. Separate from `warn`, * which only announces that a retired shape was translated — a reader who * saw only that would have no way to know the translation was not * information-preserving. */ private warnAside; run(input: RunAgentInput, next: AbstractAgent): Observable; private transformEvent; private upgradeInboundMessage; } //#endregion //#region src/agent/agent.d.ts interface RunAgentResult { result: any; newMessages: Message[]; } declare abstract class AbstractAgent { agentId?: string; description: string; threadId: string; messages: Message[]; state: State; private _debug; private _debugLogger; subscribers: AgentSubscriber[]; isRunning: boolean; /** Interrupts emitted by the most recent run that have not yet been resolved. * Populated when RUN_FINISHED arrives with outcome.type === "interrupt". * Cleared when a subsequent run completes successfully. */ pendingInterrupts: Interrupt[]; private middlewares; private activeRunDetach$?; private activeRunCompletionPromise?; /** Stops a legacy override that forwards to this.maxProtocolVersion. */ private resolvingPeerCeiling; private resolvePeerCeiling; get maxProtocolVersion(): string; /** * @deprecated Use {@link maxProtocolVersion}. Same value, honest name: this * is the ceiling the PEER speaks, not which protocol this SDK implements — * that is the generated PROTOCOL_VERSION constant. Registered in the client * package's DEPRECATIONS.md; removal no earlier than 2.0. */ get maxVersion(): string; get debug(): ResolvedAgentDebugConfig; set debug(value: AgentDebugConfig | ResolvedAgentDebugConfig); get debugLogger(): DebugLogger | undefined; set debugLogger(value: DebugLogger | boolean | undefined); /** * The peer ceiling as the constructor's version gates need it: a string * compareVersions can actually read. A subclass getter is the only writer, * and it can answer with something unusable — most often `undefined`, * because class fields initialise after `super()` returns — so the value is * judged here rather than deep inside the comparison. */ private resolvedCeilingDuringConstruction; constructor({ agentId, description, threadId, initialMessages, initialState, debug }?: AgentConfig); subscribe(subscriber: AgentSubscriber): { unsubscribe: () => void; }; abstract run(input: RunAgentInput): Observable; /** * Returns the agent's current capabilities. * Optional — subclasses implement this to advertise what they support. */ getCapabilities?(): Promise; use(...middlewares: (Middleware | MiddlewareFunction)[]): this; runAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise; protected connect(input: RunAgentInput): Observable; connectAgent(parameters?: RunAgentParameters, subscriber?: AgentSubscriber): Promise; abortRun(): void; detachActiveRun(): Promise; /** * Runs apply and processApplyEvents so that every event received before the * source errors is fully applied first. The error is held back as a * completion, then rethrown unchanged once both stages have drained. */ private applyBeforeSourceError; protected apply(input: RunAgentInput, events$: Observable, subscribers: AgentSubscriber[]): Observable; protected processApplyEvents(input: RunAgentInput, events$: Observable, subscribers: AgentSubscriber[]): Observable; protected prepareRunAgentInput(parameters?: RunAgentParameters): RunAgentInput; protected onInitialize(input: RunAgentInput, subscribers: AgentSubscriber[]): Promise; protected onError(input: RunAgentInput, error: Error, subscribers: AgentSubscriber[]): Observable; protected onFinalize(input: RunAgentInput, subscribers: AgentSubscriber[]): Promise; clone(): any; addMessage(message: Message): void; addMessages(messages: Message[]): void; setMessages(messages: Message[]): void; setState(state: State): void; legacy_to_be_removed_runAgentBridged(config?: RunAgentParameters): Observable; } //#endregion //#region src/apply/default.d.ts declare const defaultApplyEvents: (input: RunAgentInput, events$: Observable, agent: AbstractAgent, subscribers: AgentSubscriber[], debugLogger?: DebugLoggerInput) => Observable; //#endregion //#region src/verify/verify.d.ts declare const verifyEvents: (debugLogger?: DebugLoggerInput) => (source$: Observable) => Observable; //#endregion //#region src/run/http-request.d.ts declare enum HttpEventType { HEADERS = "headers", DATA = "data" } interface HttpDataEvent { type: HttpEventType.DATA; data?: Uint8Array; } interface HttpHeadersEvent { type: HttpEventType.HEADERS; status: number; headers: Headers; } type HttpEvent = HttpDataEvent | HttpHeadersEvent; declare const runHttpRequest: (fetchResponse: () => Promise) => Observable; //#endregion //#region src/transform/http.d.ts /** * Transforms HTTP events into BaseEvents using the appropriate format parser based on content type. */ declare const transformHttpEventStream: (source$: Observable, debugLogger?: DebugLoggerInput) => Observable; //#endregion //#region src/transform/sse.d.ts /** * Parses a stream of HTTP events into a stream of JSON objects using Server-Sent Events (SSE) format. * Strictly follows the SSE standard where: * - Events are separated by double newlines ('\n\n') * - Only 'data:' prefixed lines are processed * - Multi-line data events are supported and joined * - Non-data fields (event, id, retry) are ignored */ declare const parseSSEStream: (source$: Observable, debugLogger?: DebugLoggerInput) => Observable; //#endregion //#region src/transform/proto.d.ts declare const parseProtoStream: (source$: Observable, debugLogger?: DebugLoggerInput) => Observable; //#endregion //#region src/legacy/convert.d.ts declare const convertToLegacyEvents: (threadId: string, runId: string, agentName: string) => (events$: Observable) => Observable; //#endregion //#region src/utils.d.ts declare const structuredClone_: (obj: T) => T; /** * Generate a random UUID v4 * Cross-platform compatible (Node.js, browsers, React Native) */ declare function randomUUID(): string; //#endregion //#region src/compact/compact.d.ts /** * Compacts streaming events by consolidating multiple deltas into single events. * For text messages: multiple content deltas become one concatenated delta. * For tool calls: multiple args deltas become one concatenated delta. * For state: all STATE_SNAPSHOT and STATE_DELTA events within a run are compacted * into a single STATE_SNAPSHOT representing the final state. * Events between related streaming events are reordered to keep streaming events together. * * @param events - Array of events to compact * @returns Compacted array of events */ declare function compactEvents(events: BaseEvent[]): BaseEvent[]; //#endregion //#region src/chunks/transform.d.ts declare const transformChunks: (debugLogger?: DebugLoggerInput) => (events$: Observable) => Observable; //#endregion //#region src/interrupts/index.d.ts declare function getRunOutcome(event: RunFinishedEvent): RunFinishedOutcome | undefined; declare function isInterruptExpired(interrupt: Interrupt, now?: Date): boolean; type ResumeResponse = { status: "resolved"; payload?: unknown; metadata?: Metadata; } | { status: "cancelled"; metadata?: Metadata; }; declare function buildResumeArray(interrupts: Interrupt[], responses: Record): ResumeEntry[]; //#endregion //#region src/enforce/enforce.d.ts /** * An event whose `type` the protocol does not know. * * Between the transport and enforcement, the stream can carry these — that is * the point of running enforcement AFTER middleware, so a translator for a * deprecated event stays reachable once the event leaves the schema. A * middleware that wants to handle one deliberately checks with * {@link isRecognizedEvent}; whatever nothing handles is dropped, with a * warning, at the enforcement stage. The loose type never survives past * verification: subscribers and application code only ever see known events. */ type UnrecognizedEvent = { type: string; [key: string]: unknown; }; /** Narrows an event back to the known set at the enforcement boundary. */ declare function isRecognizedEvent(event: BaseEvent | UnrecognizedEvent): event is BaseEvent; /** * The enforcement stage: on each of the agent's three pipelines — streaming, * binary and in-memory alike — it sits after the middleware chain and before * THAT PIPELINE's chunk expansion, and guarantees that nothing unrecognised * survives to verification, subscribers or application code. * * Both halves of that placement need a qualifier. Chunk expansion also happens * INSIDE the chain, in `Middleware.runNext`, and that expansion is upstream of * this stage rather than downstream — which is why chunks/transform.ts must * carry through whatever it cannot vouch for instead of repairing or dropping * it. And "after the middleware chain" says nothing on `connect`, where there * is no chain to be after: this stage still runs, on events arriving straight * off the transport. * * - An event whose type nothing translated is dropped, with a warning. * - Unknown properties and unrecognised union members on a known event are * stripped, each with a warning naming its path. * - A malformed value on a field the protocol DOES describe stays fatal: * the generated validator throws, and the run errors. */ declare const enforceEvents: (debugLogger?: DebugLoggerInput) => (source$: Observable) => Observable; /** * The outgoing half of the same boundary: checked immediately before * transmission. Unknown properties are stripped with a warning; a malformed * known field is fatal before a byte leaves the process. */ declare function enforceOutgoingInput(input: RunAgentInput): RunAgentInput; //#endregion //#region src/activity-history.d.ts /** Package-owned convention. The protocol-reserved `ag-ui` namespace is untouched. */ declare const ACTIVITY_HISTORY_METADATA = "@ag-ui/client"; /** * Null owns all types; arrays own their types. Absent declarations use legacy * inference, while invalid declarations grant no omission-based deletion. */ declare function authoritativeActivityTypes(event: MessagesSnapshotEvent): string[] | null | undefined; /** * Add a projector scope, preserving full authority. Call on the incoming snapshot * before replacing its messages so inferred authority describes the original set. */ declare function withAuthoritativeActivityTypes(event: MessagesSnapshotEvent, activityTypes: readonly string[]): MessagesSnapshotEvent; //#endregion export { ACTIVITY_HISTORY_METADATA, AbstractAgent, AgentConfig, AgentDebugConfig, AgentStateMutation, AgentSubscriber, AgentSubscriberParams, BackwardCompatibility_0_0_39, BackwardCompatibility_0_0_45, BackwardCompatibility_0_0_57, CompatibilityBoundary, DebugLogger, DebugLoggerInput, FilterToolCallsMiddleware, FunctionMiddleware, HttpAgent, HttpAgentConfig, HttpAgentFetchFn, Middleware, type MiddlewareFunction, ResolvedAgentDebugConfig, RunAgentParameters, RunAgentResult, UnrecognizedEvent, authoritativeActivityTypes, buildResumeArray, compactEvents, convertToLegacyEvents, createDebugLogger, defaultApplyEvents, enforceEvents, enforceOutgoingInput, getRunOutcome, isInterruptExpired, isRecognizedEvent, parseProtoStream, parseSSEStream, randomUUID, resolveAgentDebugConfig, resolveDebugLogger, runHttpRequest, structuredClone_, transformChunks, transformHttpEventStream, verifyEvents, withAuthoritativeActivityTypes }; //# sourceMappingURL=index.d.ts.map