import { C as ChatConfig, a as ChatController, S as StreamChunk, T as TokenUsage, O as Observer, A as AgentEvent, b as StreamSource, c as SkillDefinition } from './chat-DcKAcuLr.cjs'; export { d as AdapterCapabilities, e as AdapterContext, f as AdapterFactory, g as AdapterRequest, h as ChatReturn, i as ChatState, E as EditOptions, j as StreamStatus, k as StreamToolCallPayload, U as UseStreamOptions, l as UseStreamReturn } from './chat-DcKAcuLr.cjs'; import { M as Message, a as MemoryRecord, T as ToolDefinition, b as MessageRole, c as MessageStatus, d as ToolExecutionContext, e as ToolCall, f as MaybePromise, A as ArgsValidator, g as ToolAuthorizer } from './message-CyXbT7Zj.cjs'; export { h as ArgsValidationError, i as ArgsValidationResult, j as AudioPart, C as ContentPart, D as DataRegion, k as DefineToolConfig, F as FilePart, I as ImagePart, l as InferSchemaType, P as PartKind, m as TextPart, n as ToolAuthorizationContext, o as ToolAuthorizationDecision, p as ToolAuthorizationPhase, q as ToolCallHandlerContext, r as ToolCallStatus, V as VideoPart, s as audioPart, t as defineTool, u as filePart, v as filterParts, w as imagePart, x as normalizeContent, y as partsToText, z as textPart, B as videoPart } from './message-CyXbT7Zj.cjs'; import { C as ChatMemory, R as RetrievedDocument, a as Retriever } from './memory-mFMVJZXL.cjs'; export { E as EmbedFn, b as RetrieverRequest, V as VectorDocument, c as VectorFilter, d as VectorFilterCompound, e as VectorFilterOperator, f as VectorFilterPredicate, g as VectorFilterPrimitive, h as VectorMemory, i as VectorSearchOptions } from './memory-mFMVJZXL.cjs'; import { T as TokenCounter } from './token-counter-DMjeHRQY.cjs'; export { a as TokenCountResult, b as TokenCounterOptions } from './token-counter-DMjeHRQY.cjs'; import 'json-schema'; interface EvalTestCase { input: string; expected: string | ((result: string) => boolean); metadata?: Record; } interface EvalResult { totalCases: number; passed: number; failed: number; accuracy: number; results: Array<{ input: string; output: string; passed: boolean; latencyMs: number; tokenUsage?: { prompt: number; completion: number; }; error?: string; }>; } interface EvalSuite { name: string; cases: EvalTestCase[]; } declare function createChatController(initial: ChatConfig): ChatController; declare class AgentsKitError extends Error { readonly code: string; readonly hint: string | undefined; readonly docsUrl: string | undefined; readonly cause: unknown; constructor(options: { code: string; message: string; hint?: string; docsUrl?: string; cause?: unknown; }); toString(): string; } declare class AdapterError extends AgentsKitError { constructor(options: { code: string; message: string; hint?: string; docsUrl?: string; cause?: unknown; }); } declare class ToolError extends AgentsKitError { constructor(options: { code: string; message: string; hint?: string; docsUrl?: string; cause?: unknown; }); } declare class MemoryError extends AgentsKitError { constructor(options: { code: string; message: string; hint?: string; docsUrl?: string; cause?: unknown; }); } declare class ConfigError extends AgentsKitError { constructor(options: { code: string; message: string; hint?: string; docsUrl?: string; cause?: unknown; }); } declare class RuntimeError extends AgentsKitError { constructor(options: { code: string; message: string; hint?: string; docsUrl?: string; cause?: unknown; }); } declare class SandboxError extends AgentsKitError { constructor(options: { code: string; message: string; hint?: string; docsUrl?: string; cause?: unknown; }); } declare class SkillError extends AgentsKitError { constructor(options: { code: string; message: string; hint?: string; docsUrl?: string; cause?: unknown; }); } declare const ErrorCodes: { readonly AK_ADAPTER_MISSING: "AK_ADAPTER_MISSING"; readonly AK_ADAPTER_STREAM_FAILED: "AK_ADAPTER_STREAM_FAILED"; readonly AK_TOOL_NOT_FOUND: "AK_TOOL_NOT_FOUND"; readonly AK_TOOL_EXEC_FAILED: "AK_TOOL_EXEC_FAILED"; readonly AK_TOOL_PEER_MISSING: "AK_TOOL_PEER_MISSING"; readonly AK_TOOL_INVALID_INPUT: "AK_TOOL_INVALID_INPUT"; readonly AK_TOOL_QUOTA_EXCEEDED: "AK_TOOL_QUOTA_EXCEEDED"; readonly AK_TOOL_FORBIDDEN: "AK_TOOL_FORBIDDEN"; readonly AK_MEMORY_LOAD_FAILED: "AK_MEMORY_LOAD_FAILED"; readonly AK_MEMORY_SAVE_FAILED: "AK_MEMORY_SAVE_FAILED"; readonly AK_MEMORY_DESERIALIZE_FAILED: "AK_MEMORY_DESERIALIZE_FAILED"; readonly AK_MEMORY_PEER_MISSING: "AK_MEMORY_PEER_MISSING"; readonly AK_MEMORY_REMOTE_HTTP: "AK_MEMORY_REMOTE_HTTP"; readonly AK_CONFIG_INVALID: "AK_CONFIG_INVALID"; readonly AK_RUNTIME_INVALID_INPUT: "AK_RUNTIME_INVALID_INPUT"; readonly AK_RUNTIME_STEP_FAILED: "AK_RUNTIME_STEP_FAILED"; readonly AK_RUNTIME_DELEGATE_FAILED: "AK_RUNTIME_DELEGATE_FAILED"; readonly AK_SANDBOX_DENIED: "AK_SANDBOX_DENIED"; readonly AK_SANDBOX_INVALID_TOOL: "AK_SANDBOX_INVALID_TOOL"; readonly AK_SANDBOX_PEER_MISSING: "AK_SANDBOX_PEER_MISSING"; readonly AK_SANDBOX_BACKEND_FAILED: "AK_SANDBOX_BACKEND_FAILED"; readonly AK_SKILL_INVALID: "AK_SKILL_INVALID"; readonly AK_SKILL_DUPLICATE: "AK_SKILL_DUPLICATE"; }; declare function serializeMessages(messages: Message[]): MemoryRecord; declare function deserializeMessages(record: MemoryRecord | null | undefined): Message[]; declare function createInMemoryMemory(initialMessages?: Message[]): ChatMemory; declare function createLocalStorageMemory(key: string): ChatMemory; interface StaticRetrieverConfig { documents: RetrievedDocument[]; limit?: number; } declare function createStaticRetriever(config: StaticRetrieverConfig): Retriever; declare function formatRetrievedDocuments(documents: RetrievedDocument[]): string; declare function generateId(prefix: string): string; declare function createEventEmitter(): { addObserver(observer: Observer): () => void; emit(event: AgentEvent): void; }; declare function buildMessage(params: { role: MessageRole; content: string; status?: MessageStatus; metadata?: Record; toolCallId?: string; }): Message; declare function executeToolCall(tool: ToolDefinition, args: Record, context: ToolExecutionContext, onPartialResult?: (accumulated: string) => void): Promise; declare function safeParseArgs(args: string): Record; declare function createToolLifecycle(tools: Map): { init(tool: ToolDefinition): Promise; disposeAll(): Promise; }; interface ConsumeStreamHandlers { onText?: (accumulated: string) => void; onReasoning?: (accumulated: string) => void; onToolCall?: (chunk: StreamChunk) => Promise | void; onToolResult?: (content: string) => void; onUsage?: (usage: TokenUsage) => void; onError?: (error: Error) => void; onDone: (accumulatedText: string) => void; } declare function consumeStream(source: StreamSource, handlers: ConsumeStreamHandlers): Promise; type BudgetStrategy = 'drop-oldest' | 'sliding-window' | 'summarize'; interface CompileBudgetInput { /** Hard upper bound (model context limit - reserveForOutput). */ budget: number; messages: Message[]; systemPrompt?: string; tools?: ToolDefinition[]; /** Token counter. Defaults to `approximateCounter` (chars/4 heuristic). */ counter?: TokenCounter; /** Trimming strategy. Default 'drop-oldest'. */ strategy?: BudgetStrategy; /** Required when strategy === 'summarize'. */ summarizer?: (dropped: Message[]) => Message | Promise; /** Tokens reserved for the model's output. Subtracted from budget. */ reserveForOutput?: number; /** * Minimum number of recent messages to keep regardless of strategy. * Protects against dropping the turn that actually matters. Default 1. */ keepRecent?: number; } interface CompileBudgetResult { messages: Message[]; systemPrompt?: string; tokens: { system: number; messages: number; tools: number; total: number; budget: number; }; dropped: Message[]; fits: boolean; strategy: BudgetStrategy; } /** * Zero-dependency approximate token counter. Rule of thumb: ~4 chars * per token. Good enough for budget planning; swap for a real * tokenizer (tiktoken etc.) via the `counter` option in prod. */ declare const approximateCounter: TokenCounter; /** * Take a declared `budget` and a set of messages/system/tools, then * return a trimmed request guaranteed to fit under `budget`. Three * strategies: * - 'drop-oldest': remove oldest messages until it fits * - 'sliding-window': keep only the most recent N messages * - 'summarize': fold dropped messages into a single summary message */ declare function compileBudget(input: CompileBudgetInput): Promise; interface ProgressiveFieldEvent { /** Top-level field name whose value just finished being streamed. */ field: string; /** Parsed value (string / number / boolean / array / object / null). */ value: unknown; /** Raw JSON text for that field. */ raw: string; /** Byte offset in the accumulated buffer where this field ended. */ offset: number; } interface ProgressiveArgParser { /** Append a new chunk of JSON text. Emits `onField` for each top-level field that completes. */ push: (chunk: string) => ProgressiveFieldEvent[]; /** Mark the stream finished — validates the object closed cleanly. Returns any final events. */ end: () => ProgressiveFieldEvent[]; /** All events seen so far, in order. */ readonly events: ReadonlyArray; /** Current parsed partial object (fields completed so far). */ readonly value: Record; /** Accumulated raw buffer. */ readonly buffer: string; } /** * Stream-parse a JSON object where top-level field values arrive * incrementally. Fires an event as soon as each top-level field has a * syntactically complete value, enabling "progressive" tool execution * — the tool can begin work on the first field before the LLM has * finished emitting the rest. * * Only works at the top level of a JSON object — nested structures * are parsed atomically when their enclosing top-level field closes. * That matches the common tool-args shape: a flat `{ query, limit, ...}` * object where the expensive operation depends on one key. */ declare function createProgressiveArgParser(): ProgressiveArgParser; interface ProgressiveExecOptions { /** Start executing after these fields have been received. Default: first field. */ triggerFields?: string[]; /** Called for each field event, including those after execution starts. */ onField?: (event: ProgressiveFieldEvent) => void; } interface ProgressiveExecResult { fields: ProgressiveFieldEvent[]; finalArgs: Record; /** Resolves with the tool's return value. */ execution: Promise; } /** * Run a tool "progressively": feed argument-text chunks as they * stream, and kick off `tool.execute` as soon as the trigger fields * have arrived. Additional field events keep landing in the same * `onField` callback so the tool can adapt. * * The tool's `args` parameter reflects whichever fields had arrived * by the trigger point — callers that need the complete object should * wait for `finalArgs`. */ declare function executeToolProgressively>(tool: ToolDefinition, chunks: AsyncIterable, context: Omit & { messages: Message[]; callId: string; }, options?: ProgressiveExecOptions): ProgressiveExecResult; interface VirtualizedMemoryOptions { /** Maximum number of recent messages to keep "hot" (always loaded). Default 50. */ maxActive?: number; /** * Optional retriever used to surface relevant "cold" messages on * each `load()`. Given the hot window, returns up to `maxRetrieved` * older messages to splice back in (in chronological order). */ retriever?: (input: { hot: Message[]; cold: Message[]; maxRetrieved: number; }) => Message[] | Promise; /** Maximum retrieved cold messages per load. Default 10. */ maxRetrieved?: number; } /** * Wrap any `ChatMemory` implementation with a fixed active window. * Older messages (cold) are preserved on disk / in the backing store * but omitted from `load()` unless a `retriever` surfaces them. * * Key guarantees: * - Backing store always holds the full conversation. No data loss. * - `load()` returns at most `maxActive + maxRetrieved` messages. * - `save()` merges the caller's messages with any cold tail the * caller did not see, so callers that load -> mutate -> save do not * accidentally truncate history. */ declare function createVirtualizedMemory(backing: ChatMemory, options?: VirtualizedMemoryOptions): ChatMemory & { /** Total messages in the backing store (hot + cold). */ size: () => Promise; /** Read the full (cold + hot) message list, bypassing virtualization. */ loadAll: () => Promise; }; declare function buildToolMap(...sources: Array): Map; interface ActivateSkillsResult { systemPrompt: string | undefined; skillTools: ToolDefinition[]; } declare function activateSkills(skills: SkillDefinition[], prompt?: string): Promise; interface ToolExecResult { status: 'complete' | 'error' | 'skipped'; result?: string; error?: string; durationMs: number; } interface ExecuteSafeToolOptions { tool: ToolDefinition | undefined; toolCall: ToolCall; context: ToolExecutionContext; emitter: ReturnType; lifecycle: ReturnType; onPartial?: (result: string) => void; onConfirm?: (toolCall: ToolCall) => MaybePromise; /** Opt-in arg validation against `tool.schema` (ADR-0008). */ validate?: ArgsValidator; authorize?: ToolAuthorizer; } declare function executeSafeTool(options: ExecuteSafeToolOptions): Promise; export { type ActivateSkillsResult, AdapterError, AgentEvent, AgentsKitError, ArgsValidator, type BudgetStrategy, ChatConfig, ChatController, ChatMemory, type CompileBudgetInput, type CompileBudgetResult, ConfigError, type ConsumeStreamHandlers, ErrorCodes, type EvalResult, type EvalSuite, type EvalTestCase, type ExecuteSafeToolOptions, MaybePromise, MemoryError, MemoryRecord, Message, MessageRole, MessageStatus, Observer, type ProgressiveArgParser, type ProgressiveExecOptions, type ProgressiveExecResult, type ProgressiveFieldEvent, RetrievedDocument, Retriever, RuntimeError, SandboxError, SkillDefinition, SkillError, StreamChunk, StreamSource, TokenCounter, TokenUsage, ToolAuthorizer, ToolCall, ToolDefinition, ToolError, type ToolExecResult, ToolExecutionContext, type VirtualizedMemoryOptions, activateSkills, approximateCounter, buildMessage, buildToolMap, compileBudget, consumeStream, createChatController, createEventEmitter, createInMemoryMemory, createLocalStorageMemory, createProgressiveArgParser, createStaticRetriever, createToolLifecycle, createVirtualizedMemory, deserializeMessages, executeSafeTool, executeToolCall, executeToolProgressively, formatRetrievedDocuments, generateId, safeParseArgs, serializeMessages };