import * as z from 'zod'; import z__default, { z as z$1 } from 'zod'; import * as zod_v4_core from 'zod/v4/core'; import { Z as ZodObjectWithTelemetry, A as AsyncQueue, T as TelemetryResource, c as TelemetryAttributes, e as TelemetryScopesDefinition, f as TelemetrySpan, g as TelemetryConsumer, h as TelemetrySpanHandle, i as TelemetrySignal, j as TelemetryLogHandle, b as ZodUnionWithTelemetry, a as agentServerConfig } from './config-n67P8tNt.js'; import { CamelCase } from 'type-fest'; declare const lifeErrorCodes: { /** * Used when the user sends or the server returns invalid data. */ readonly Validation: { readonly retriable: false; readonly defaultMessage: "Invalid data provided."; readonly httpEquivalent: 400; }; /** * Used when the user is not authorized to access a resource */ readonly Forbidden: { readonly retriable: false; readonly defaultMessage: "Not allowed to access this resource."; readonly httpEquivalent: 403; }; /** * Used when an operation took too long and timed out. */ readonly Timeout: { readonly retriable: true; readonly defaultMessage: "Operation timed out."; readonly httpEquivalent: 504; }; /** * Used when the user has exceeded the rate limit for a resource. */ readonly RateLimit: { readonly retriable: true; readonly defaultMessage: "Rate limit exceeded."; readonly httpEquivalent: 429; }; /** * Used when a resource was not found or missing. */ readonly NotFound: { readonly retriable: false; readonly defaultMessage: "Resource not found."; readonly httpEquivalent: 404; }; /** * Used when an operation is about to conflict with another. * E.g., a version mismatch, a unique constraint violation, etc. */ readonly Conflict: { readonly retriable: false; readonly defaultMessage: "Operation conflicted."; readonly httpEquivalent: 409; }; /** * Used when an upstream service or resource fails. * E.g., a database connection error, an OpenAI API downtime, etc. */ readonly Upstream: { readonly retriable: true; readonly defaultMessage: "Upstream error."; readonly httpEquivalent: 502; }; /** * Used when an unexpected error is thrown. */ readonly Unknown: { readonly retriable: false; readonly defaultMessage: "Unknown error."; readonly httpEquivalent: 500; }; /** * Used to obfuscate internal errors publicly. * Prevents leaking sensitive informations to public consumers. */ readonly Internal: { readonly retriable: true; readonly defaultMessage: "Internal error."; readonly httpEquivalent: 500; }; }; type LifeErrorCode = keyof typeof lifeErrorCodes; type LifeErrorParameters = { code: Code; message?: string; attributes?: LifeErrorAttributes; retryAfterMs?: number; isPublic?: boolean; cause?: unknown; }; type LifeErrorAttributes = Record; /** * @internal Use `lifeError()` instead. */ declare class LifeErrorClass extends Error { readonly name = "LifeError"; /** * The unique identifier of the error. */ readonly id: string; /** * The error code. * Can be one of: * - Validation * - Forbidden * - Timeout * - RateLimit * - NotFound * - Conflict * - Upstream * - Unknown * - Internal */ readonly code: LifeErrorCode; /** * Additional pieces of evidence attached to the error. */ readonly attributes: LifeErrorAttributes; /** * Used to indicate whether the operation that caused the error can be retried. */ readonly retriable: boolean; /** * The suggested time (in ms) to wait before retrying the operation that caused the error. * Check `.retriable` first to ensure the operation can be retried. */ readonly retryAfterMs?: number; /** * The HTTP status code equivalent to the error code. */ readonly httpEquivalent: number; /** * Used to indicate whether this error is public and can be safely sent to external clients. */ readonly isPublic: boolean; constructor({ code, message, attributes, retryAfterMs, cause, isPublic, }: LifeErrorParameters); toJSON(): { id: string; code: "Validation" | "Forbidden" | "Timeout" | "RateLimit" | "NotFound" | "Conflict" | "Upstream" | "Unknown" | "Internal"; message: string; retriable: boolean; attributes: LifeErrorAttributes; retryAfterMs: number | undefined; httpEquivalent: number; stack: string | undefined; cause: unknown; }; } /** * Error emitted by the Life.js framework. * Check attributes documentation for more information. */ type LifeError = LifeErrorClass & { code: Code; }; /** * Union of all LifeError types. */ type LifeErrorUnion = Code extends LifeErrorCode ? LifeError : never; /** * Avoids repeating the same type signature for functions that can return a promise or not. */ type MaybePromise = T | Promise; type ClassShape = { prototype: object; new (...arguments_: any[]): any; }; type Prettify = { [K in keyof T]: T[K]; } & {}; type Any = any; type IsAny = 0 extends 1 & T ? true : false; type IsNever = [T] extends [never] ? true : false; type IsFunction = T extends (...args: Any) => Any ? true : false; type IsInstance = IsAny extends true ? false : IsNever extends true ? false : IsFunction extends true ? false : T extends object ? true : false; type IsClass = T extends ClassShape ? (ClassShape extends T ? true : false) : false; /** * Override a property type in an object without creating nested type aliases. * * Unlike `Omit & { [K]: V }` which creates type alias references that nest * when chained, this produces an evaluated (expanded) type. This prevents type * instantiation depth issues common in builder patterns where types are repeatedly * transformed. * * @example * type User = { name: string; age: number }; * type UpdatedUser = Override; // { name: string; age: string } */ type Override = Prettify<{ [I in keyof T]: I extends K ? V : T[I]; }>; /** * Exclude specific properties from an object, producing an expanded type. * * Functionally similar to `Omit` but ensures the result is an evaluated type * rather than a type alias reference, preventing excessive type nesting in chained * transformations. * * @example * type User = { name: string; age: number; email: string }; * type PublicUser = Without; // { name: string; age: number } */ type Without = Prettify<{ [I in keyof T as I extends K ? never : I]: T[I]; }>; declare const __opaque: unique symbol; type Opaque = T & { [__opaque]?: never; }; /** * The 'operation' library (usually imported as 'op') is a minimal and type-safe * helper to enforce return type consistency across the entire codebase. * * * ## Why not using something like Effect.js or NeverThrow? * * While powerful, those libraries come with significant learning curves. We want * the Life.js codebase to remain accessible, so the community can easily engage, * learn, and contribute to it. Those libraries were incompatible with this goal. * * Also, we wanted the solution to be unnoticeable on the public API. The Life.js * SDKs shouldn't force developers to think differently about their program design. * Complex libraries like Effect.js or NeverThrow were again challenging with that * goal, this library solves that in ~100 LOC with the `toPublic()` helper. * * Still, 'operation' is not a perfect alternative to more complex libraries. * For example, it doesn't provide error-level type safety, yet it enforces errors * to be narrowed to LifeError (a 9 error codes surface), and strongly encourages * contributors to handle them properly. We found it being a good compromise. * * * ## Why 'error' comes first in the result tuple? * * We use `[error, data]` instead of `[data, error]` for two main reasons: * * 1. A function doesn't always return data, while it will always return a potential * error. When there is no data, with error first we can simply do: * ```ts * const [err] = op.attempt(...) * // instead of the more verbose * const [_, err] = op.attempt(...) * ``` * * 2. With error first, the developer explicitly acknowledges the potential error * before destructuring the data. If `data` was first, it would be easy to: * ```ts * const [data] = op.attempt(...) // <-- Easy to forget to destructure the error here! * if (data) { ... } * ``` */ type OperationData = unknown; type OperationSuccess = readonly [error: undefined, data: D]; type OperationFailure<_ extends OperationData = never> = readonly [ error: LifeErrorUnion, data: undefined ]; type OperationResult = OperationSuccess | OperationFailure; type VoidIfNever = [T] extends [never] ? void : T; type IsOpFunction = T extends (...args: Any) => MaybePromise> ? true : false; type IsOpInstance = { [K in keyof T]: IsFunction extends true ? IsOpFunction : false; } extends { [K in keyof T]: false; } ? false : true; /** * In some rare cases where a types produces another type itself containing generics, * Typescript won't be able to infer the precise branch and ToPublic will incorreclty * match the type and produce broken results. * This helper is used to assert that a type is already public and avoid the issue. */ type AssertPublic = T & { [__public]: [T]; }; declare const __public: unique symbol; type IsAsserted = T extends { [__public]: Any; } ? true : false; type UnwrapAssert = T extends { [__public]: [infer U]; } ? U : never; type FunctionToPublic = T extends (...args: infer Args) => MaybePromise> ? Opaque<(...args: Args) => VoidIfNever> : T; type InstanceToPublic = IsInstance extends true ? Prettify<{ [K in keyof T]: ToPublic; } & (IsOpInstance extends true ? Opaque<{ safe: { [K in keyof T as IsOpFunction extends true ? K : never]: T[K]; }; }> : unknown)> : T; type ClassToPublic = IsClass extends true ? Opaque InstanceToPublic>> : T; type ToPublic = IsAsserted extends true ? UnwrapAssert : T extends z__default.ZodType ? T : IsClass extends true ? ClassToPublic : IsFunction extends true ? FunctionToPublic : IsInstance extends true ? InstanceToPublic : T; declare const serializablePrimitivesSchema: z$1.ZodUnion, z$1.ZodCustom, z$1.ZodCustom, z$1.ZodCustom, z$1.ZodCustom, Int8Array>, z$1.ZodCustom, Uint8Array>, z$1.ZodCustom, Uint8ClampedArray>, z$1.ZodCustom, Int16Array>, z$1.ZodCustom, Uint16Array>, z$1.ZodCustom, Int32Array>, z$1.ZodCustom, Uint32Array>, z$1.ZodCustom, Float32Array>, z$1.ZodCustom, Float64Array>, z$1.ZodCustom, BigInt64Array>, z$1.ZodCustom, BigUint64Array>]>; type SerializablePrimitives = z$1.infer; type SerializableValue = SerializablePrimitives | SerializableValue[] | readonly SerializableValue[] | [SerializableValue, ...SerializableValue[]] | readonly [SerializableValue, ...SerializableValue[]] | Set | Map | { [key: string]: SerializableValue; }; declare const storeConfigSchema: z$1.ZodUnion>> | z$1.ZodRecord>>, z$1.ZodArray>> | z$1.ZodRecord>>>; type: z$1.ZodLiteral<"controlled">; ttl: z$1.ZodOptional; }, z$1.core.$strip>, z$1.ZodObject<{ schema: z$1.ZodCustom>> | z$1.ZodRecord>>, z$1.ZodArray>> | z$1.ZodRecord>>>; type: z$1.ZodLiteral<"freeform">; }, z$1.core.$strip>]>; type StoreConfig = T extends "input" ? z$1.input : z$1.output; type StoreRetrieve> = () => z$1.infer | Promise>; interface StoreDefinition { name: string; config: StoreConfig<"output">; retrieve?: () => unknown | Promise; } declare class StoreDefinitionBuilder { _definition: Definition; constructor(def: Definition); config>(config: Config): Omit, "config" | Excluded | (Config["type"] extends "controlled" ? never : "retrieve")>; retrieve(retrieve: StoreRetrieve): Omit; }, Excluded | "retrieve">, Excluded | "retrieve">; } declare function defineStore(name: Name): StoreDefinitionBuilder<{ readonly name: Name; readonly config: { schema: z$1.ZodArray>> | z$1.ZodRecord>>; type: "controlled"; ttl?: number | undefined; } | { schema: z$1.ZodArray>> | z$1.ZodRecord>>; type: "freeform"; }; }, never>; declare const agentToolRequestSchema: z$1.ZodObject<{ toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolInput: z$1.ZodRecord; }, z$1.core.$strip>; type AgentToolRequest = z$1.output; declare const messageSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ role: z$1.ZodLiteral<"user">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">; type Message = z$1.output; interface _MemoryDependenciesDefinition { stores: { name: string; }[]; collections: { name: string; }[]; } type MemoryDependenciesDefinition = _MemoryDependenciesDefinition | { _definition: _MemoryDependenciesDefinition; }; declare const memoryConfigSchema: z$1.ZodObject<{ behavior: z$1.ZodPrefault>; }, z$1.core.$strip>; type MemoryConfig = T extends "input" ? z$1.input : z$1.output; interface MemoryDefinition { name: string; config: MemoryConfig<"output">; output?: Message[] | ((params: { messages: Message[]; }) => Message[] | Promise); onHistoryChange?: (params: { messages: Message[]; }) => void; dependencies: MemoryDependenciesDefinition; } declare class MemoryDefinitionBuilder { _definition: Definition; constructor(def: Definition); dependencies(dependencies: Dependencies): Omit, "dependencies" | Excluded>; config(config: MemoryConfig<"input">): Omit, "config" | Excluded>; output(params: Message[] | ((params: { messages: Message[]; }) => Message[] | Promise)): Omit, "output" | Excluded>; onHistoryChange(params: (params: { messages: Message[]; }) => void): Omit, Excluded | "onHistoryChange">; } declare function defineMemory(name: Name): MemoryDefinitionBuilder<{ readonly name: Name; readonly config: { behavior: "blocking" | "non-blocking"; }; readonly dependencies: { readonly stores: []; readonly collections: []; }; }, never>; declare abstract class EOUBase { protected config: z$1.infer; constructor(configSchema: ConfigSchema, config: Partial>); abstract predict(messages: Message[]): Promise | number; } declare const livekitEOUConfig: ZodObjectWithTelemetry; quantized: z$1.ZodPrefault; maxMessages: z$1.ZodPrefault; maxTokens: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; declare class LivekitEOU extends EOUBase { #private; constructor(config: z$1.input); predict(messages: Message[]): Promise; } declare const turnSenseEOUConfig: ZodObjectWithTelemetry; quantized: z$1.ZodPrefault; maxMessages: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; declare class TurnSenseEOU extends EOUBase { #private; constructor(config: z$1.input); predict(messages: Message[]): Promise; } declare const eouProviders: { readonly turnsense: { readonly class: typeof TurnSenseEOU; readonly configSchema: z.ZodObject<{ provider: z.ZodLiteral<"turnsense">; quantized: z.ZodPrefault; maxMessages: z.ZodPrefault; }, zod_v4_core.$strip>; }; readonly livekit: { readonly class: typeof LivekitEOU; readonly configSchema: z.ZodObject<{ provider: z.ZodLiteral<"livekit">; quantized: z.ZodPrefault; maxMessages: z.ZodPrefault; maxTokens: z.ZodPrefault; }, zod_v4_core.$strip>; }; }; type EOUProvider = (typeof eouProviders)[keyof typeof eouProviders]["class"]; declare const llmToolSchema: z__default.ZodObject<{ name: z__default.ZodString; description: z__default.ZodString; schema: z__default.ZodObject<{ input: z__default.ZodCustom, z__default.ZodObject>; output: z__default.ZodCustom, z__default.ZodObject>; }, z__default.core.$strip>; run: z__default.ZodFunction], null>, z__default.ZodUnion>; error: z__default.ZodOptional; }, z__default.core.$strip>, z__default.ZodPromise>; error: z__default.ZodOptional; }, z__default.core.$strip>>]>>; }, z__default.core.$strip>; /** * Represents a tool definition for an LLM. */ type LLMToolDefinition = z__default.infer; type LLMGenerateMessageChunk = { type: "content"; content: string; } | { type: "tools"; tools: AgentToolRequest[]; } | { type: "end"; } | { type: "error"; error: string; }; interface LLMGenerateMessageJob { id: string; cancel: () => void; stream: AsyncQueue; _abortController: AbortController; } type LLMGenerateObjectChunk = { type: "content"; data: z$1.infer; } | { type: "error"; error: string; }; /** * Base class for all LLMs providers. */ declare abstract class LLMBase { config: z$1.infer; constructor(configSchema: ConfigSchema, config: Partial>); protected createGenerateMessageJob(): LLMGenerateMessageJob; abstract generateMessage(params: { messages: Message[]; tools: LLMToolDefinition[]; }): Promise; abstract generateObject(params: { messages: Message[]; schema: T; }): Promise>; } declare const mistralLLMConfig: ZodObjectWithTelemetry; apiKey: z$1.ZodPrefault; model: z$1.ZodPrefault>; temperature: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; declare class MistralLLM extends LLMBase { #private; constructor(config: z$1.input); /** * Generate a message with job management - returns jobId along with stream */ generateMessage(params: Parameters[0]): Promise; generateObject(params: { messages: Message[]; schema: T; }): Promise>; } declare const openAILLMConfig: ZodObjectWithTelemetry; apiKey: z$1.ZodPrefault; model: z$1.ZodPrefault>; temperature: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; declare class OpenAILLM extends LLMBase { #private; constructor(config: z$1.input); /** * Generate a message with job management - returns jobId along with stream */ generateMessage(params: Parameters[0]): Promise; generateObject(params: { messages: Message[]; schema: T; }): Promise>; } declare const xaiLLMConfig: ZodObjectWithTelemetry; apiKey: z$1.ZodPrefault; model: z$1.ZodPrefault>; temperature: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; declare class XaiLLM extends LLMBase { #private; constructor(config: z$1.input); /** * Generate a message with job management - returns jobId along with stream */ generateMessage(params: Parameters[0]): Promise; generateObject(params: { messages: Message[]; schema: T; }): Promise>; } declare const llmProviders: { readonly mistral: { readonly class: typeof MistralLLM; readonly configSchema: ZodObjectWithTelemetry; apiKey: z.ZodPrefault; model: z.ZodPrefault>; temperature: z.ZodPrefault; }, zod_v4_core.$strip>, "output">; }; readonly openai: { readonly class: typeof OpenAILLM; readonly configSchema: ZodObjectWithTelemetry; apiKey: z.ZodPrefault; model: z.ZodPrefault>; temperature: z.ZodPrefault; }, zod_v4_core.$strip>, "output">; }; readonly xai: { readonly class: typeof XaiLLM; readonly configSchema: ZodObjectWithTelemetry; apiKey: z.ZodPrefault; model: z.ZodPrefault>; temperature: z.ZodPrefault; }, zod_v4_core.$strip>, "output">; }; }; type LLMProvider = (typeof llmProviders)[keyof typeof llmProviders]["class"]; type STTChunk = { type: "content"; textChunk: string; } | { type: "end"; } | { type: "error"; error: string; }; type STTJob = { id: string; stream: AsyncQueue; cancel: () => void; inputVoice: (chunk: Int16Array) => void; _abortController: AbortController; }; /** * Base class for all STT providers. */ declare abstract class STTBase { protected config: z$1.infer; constructor(configSchema: ConfigSchema, config: Partial>); protected createGenerateJob(): STTJob; abstract generate(): Promise; protected abstract onVoiceInput(job: STTJob, pcm: Int16Array): Promise; } declare const deepgramSTTConfig: ZodObjectWithTelemetry; apiKey: z$1.ZodPrefault; model: z$1.ZodPrefault>; language: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; declare class DeepgramSTT extends STTBase { #private; constructor(config: z$1.input); generate(): Promise; protected onVoiceInput(job: STTJob, pcm: Int16Array): Promise; } declare const sttProviders: { readonly deepgram: { readonly class: typeof DeepgramSTT; readonly configSchema: ZodObjectWithTelemetry; apiKey: z.ZodPrefault; model: z.ZodPrefault>; language: z.ZodPrefault; }, zod_v4_core.$strip>, "output">; }; }; type STTProvider = (typeof sttProviders)[keyof typeof sttProviders]["class"]; type TTSChunk = { type: "content"; voiceChunk: Int16Array; textChunk: string; durationMs: number; } | { type: "end"; } | { type: "error"; error: string; }; type TTSChunkInput = { type: "content"; voiceChunk: Int16Array; } | { type: "end"; } | { type: "error"; error: string; }; interface TTSJob { id: string; stream: AsyncQueue; cancel: () => void; inputText: (text: string, isLast?: boolean) => Promise; _abortController: AbortController; _receiveVoiceChunk: (chunk: TTSChunkInput) => Promise; } /** * Base class for all TTS providers. */ declare abstract class TTSBase { #private; config: z$1.infer; constructor(configSchema: ConfigSchema, config: Partial>); protected createGenerateJob(): TTSJob; abstract generate(): Promise; protected abstract onTextInput(job: TTSJob, text: string, isLast: boolean): Promise; } declare const cartesiaTTSConfig: ZodObjectWithTelemetry; apiKey: z$1.ZodPrefault; model: z$1.ZodPrefault>; language: z$1.ZodPrefault>; voiceId: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; declare class CartesiaTTS extends TTSBase { #private; constructor(config: z$1.input); generate(): Promise; protected onTextInput(job: TTSJob, text: string, isLast?: boolean): Promise; } declare const ttsProviders: { readonly cartesia: { readonly class: typeof CartesiaTTS; readonly configSchema: ZodObjectWithTelemetry; apiKey: z.ZodPrefault; model: z.ZodPrefault>; language: z.ZodPrefault>; voiceId: z.ZodPrefault; }, zod_v4_core.$strip>, "output">; }; }; type TTSProvider = (typeof ttsProviders)[keyof typeof ttsProviders]["class"]; type VADChunk = { type: "result"; chunk: Int16Array; score: number; }; type VADJob = { id: string; cancel: () => void; stream: AsyncQueue; inputVoice: (pcm: Int16Array) => void; _abortController: AbortController; }; declare abstract class VADBase { protected config: z$1.infer; constructor(configSchema: ConfigSchema, config: Partial>); protected createGenerateJob(): VADJob; /** * Create a new job to detect voice activity of an incomoing audio stream. */ abstract detect(): Promise; protected abstract onVoiceInput(job: VADJob, pcm: Int16Array): Promise; } declare const sileroVADConfig: ZodObjectWithTelemetry; }, z$1.core.$strip>, "output">; declare class SileroVAD extends VADBase { #private; constructor(config: z$1.input); detect(): Promise; protected onVoiceInput(job: VADJob, pcm: Int16Array): Promise; } declare const vadProviders: { readonly silero: { readonly class: typeof SileroVAD; readonly configSchema: ZodObjectWithTelemetry; }, zod_v4_core.$strip>, "output">; }; }; type VADProvider = (typeof vadProviders)[keyof typeof vadProviders]["class"]; /** * The telemetry client provides a unified interface for logging, tracing, and metrics * collection across the Life.js codebase. The collected data is almost OTEL-compliant * and can be piped to any provider via consumers registering. * * @dev The program shouldn't fail or throw an error because of telemetry, so the * telemetry clients are not using the 'operation' library, they swallow and log any error. * * @todo Support auto-capture OTEL telemetry data from nested libraries. * @todo Properly parse and clean stack traces. Right now, we're using the raw stack trace string from the Error object. */ declare abstract class TelemetryClient { #private; readonly scope: string; readonly resource: TelemetryResource; clientAttributes: TelemetryAttributes; constructor(scopesDefinition: TelemetryScopesDefinition, scope: string); protected abstract getResource(): TelemetryResource; protected abstract getCurrentSpanData(): TelemetrySpan | undefined; protected abstract runWithSpanData(spanData: TelemetrySpan | undefined, fn: () => unknown): unknown; /** * Registers a callback consumer to receive telemetry data from all the clients. * @param consumer - The consumer to register * @returns A function that unregisters the consumer when called * @example * ```typescript * const unregister = telemetry.registerGlobalConsumer(myConsumer); * unregister(); // Later, to stop receiving events * ``` */ static registerGlobalConsumer(consumer: TelemetryConsumer): () => void; /** * Flushes any globally pending telemetry data, ensuring that all the consumers * of all the TelemetryClient instances have finished processing before returning * or until the timeout is reached. * @param timeoutMs - Maximum time to wait in milliseconds (default: 10000ms) * @returns A promise that resolves when flushing is complete or timeout is reached */ static flushAllConsumers(timeoutMs?: number): Promise; /** * Registers a callback consumer to receive telemetry data from this client. * @param consumer - The consumer to register * @returns A function that unregisters the consumer when called * @example * ```typescript * const unregister = telemetry.registerConsumer(myConsumer); * unregister(); // Later, to stop receiving events * ``` */ registerConsumer(consumer: TelemetryConsumer): () => void; /** * Flushes any pending telemetry data, ensuring that all consumers have finished * processing before returning or until the timeout is reached. * @param timeoutMs - Maximum time to wait in milliseconds (default: 10000ms) * @returns A promise that resolves when flushing is complete or timeout is reached */ flushConsumers(timeoutMs?: number): Promise; /** * Sets a client-level attribute that will be included in all telemetry data from this client. * @param key - The attribute key * @param value - The attribute value (must be serializable, else will be ignored) * @example * ```typescript * telemetry.setAttribute("modelId", "abc"); * telemetry.setAttribute("region", "us-west-2"); * ``` */ setAttribute(key: string, value: unknown): void; /** * Sets multiple client-level attributes that will be included in all telemetry data from this client. * @param attributes - The attributes to set * @example * ```typescript * telemetry.setAttributes({ modelId: "abc", region: "us-west-2" }); * ``` */ setAttributes(attributes: TelemetryAttributes): void; /** * Measure the duration and capture logs about an operation. * Automatically handles both sync and async functions, preserving their return types. * trace() calls can be nested and will produce nested spans. * @param name - The name of the operation being traced * @param fn - The function to execute within the span context (sync or async) * @param options - Optional attributes and parent span * @returns The result of the function (direct value for sync, Promise for async) * @example * ```typescript * // Sync function - no await needed * const hash = telemetry.trace("compute-hash", ({ log, setAttribute }) => { * log.info({ message: "Computing hash" }); * const result = computeHash(data); * setAttribute("algorithm", "sha256"); * return result; * }, { attributes: { dataSize: data.length } }); * * // Async function - await the result * const user = await telemetry.trace("fetch-user", async ({ log }) => { * log.info({ message: "Fetching user" }); * const response = await fetch(`/api/users/${id}`); * return response.json(); * }, { attributes: { userId: id } }); * * // Early end example: * telemetry.trace("process-item", ({ end }) => { * if (shouldSkip) { * end(); * return; * } * // ... process item * }); * ``` */ trace(name: string, fn: (params: TelemetrySpanHandle) => T, options?: { attributes?: TelemetryAttributes; parent?: TelemetrySpanHandle; }): T; /** * Get the ambient tracing span handle. * @returns The current tracing span parent (if any) */ getCurrentSpan(): TelemetrySpanHandle | undefined; /** * Send a telemetry signal to all consumers. * This a raw method, prefer using log.*(), counter(), updown(), histogram(), etc. * @param signal - The telemetry signal to send */ sendSignal(signal: TelemetrySignal, throwOnError?: boolean): void; /** * Unsafe version of sendSignal() bypassing all validation and checks. * Used internally to forward telemetry signals between processes. * @internal */ _unsafeSendSignal(signal: TelemetrySignal): void; /** * Creates a counter metric for tracking monotonically increasing values. * @param name - The name of the counter metric * @returns An object with methods to increment the counter * @example * ```typescript * const requestCounter = telemetry.counter("http_requests_total"); * requestCounter.increment({ method: "GET", status: "200" }); * requestCounter.add(5, { batch: "true" }); * ``` */ counter(name: string): { add: (n: number | bigint, attributes?: TelemetryAttributes) => void; increment: (attributes?: TelemetryAttributes) => void; }; /** * Creates an up/down counter metric for tracking values that can increase or decrease. * @param name - The name of the up/down counter metric * @returns An object with methods to modify the counter * @example * ```typescript * const connectionGauge = telemetry.updown("active_connections"); * connectionGauge.increment(); // New connection * connectionGauge.decrement(); // Connection closed * connectionGauge.add(10); // Bulk connections * ``` */ updown(name: string): { add: (n: number | bigint, attributes?: TelemetryAttributes) => void; remove: (n: number | bigint, attributes?: TelemetryAttributes) => void; increment: (attributes?: TelemetryAttributes) => void; decrement: (attributes?: TelemetryAttributes) => void; }; /** * Creates a histogram metric for recording value distributions over time. * @param name - The name of the histogram metric * @returns An object with a method to record values * @example * ```typescript * const latencyHistogram = telemetry.histogram("request_duration_ms"); * latencyHistogram.record(responseTime, { endpoint: "/api/users" }); * ``` */ histogram(name: string): { record: (value: number | bigint, attributes?: TelemetryAttributes) => void; }; /** * Log writer for recording events at different severity levels. * Logs are automatically associated with the current span context if one exists. * @example * ```typescript * telemetry.log.info({ message: "Server started", attributes: { port: 3000 } }); * telemetry.log.error({ error: new Error("Connection failed"), attributes: { host: "db.example.com" } }); * telemetry.log.warn({ message: "Deprecated API used", attributes: { endpoint: "/v1/users" } }); * ``` */ log: TelemetryLogHandle; } declare class PluginServer { #private; readonly def: PluginDef; readonly agent: AgentServer; readonly config: PluginConfig; context: PluginContext; readonly telemetry: TelemetryClient; readonly queue: AsyncQueue>; readonly eventsListeners: Map; readonly contextListeners: Map; readonly streamHandlersQueues: AsyncQueue>[]; readonly externalInterceptHandlers: { dependent: PluginServer; handler: PluginHandlerDefinition; }[]; constructor({ agent, definition, config, context, }: { agent: AgentServer; definition: PluginDef; config: PluginConfig; context: SerializableValue; }); /** * Produces an accessor object, exposing methods to interact safely with the plugin * from a given source (plugin, handler, client). * @param source - The source accessing the plugin. * @param handlerAccess - The access mode for the handler. * @returns An accessor object. */ getAccessor(source: Source, handlerAccess?: HandlerAccess): readonly [error: LifeErrorUnion, data: undefined] | readonly [error: undefined, data: PluginAccessor]; /** * Produces a map of dependencies' accessors, see `getAccessor()`. * @param source - The source accessing the dependencies. * @returns A map of dependencies' accessors. */ getDependenciesAccessors(source: Source): readonly [error: LifeErrorUnion, data: undefined] | readonly [error: undefined, data: PluginDependenciesAccessor]; start(): Promise; stop(): Promise; } type TransportEvent = { type: "audio-chunk"; chunk: Int16Array; }; declare abstract class TransportProviderClientBase { config: z$1.infer; listeners: Partial void)[]>>; constructor(configSchema: ConfigSchema, config: Partial>); on(type: EventType, callback: (data: Extract) => void): readonly [error: LifeErrorUnion, data: undefined] | readonly [error: undefined, data: () => void]; abstract joinRoom(roomName: string, token: string): Promise>; abstract leaveRoom(): Promise>; abstract streamText(topic: string): Promise, "desiredSize" | "closed" | "ready" | "abort" | "releaseLock">>>; abstract receiveStreamText(topic: string, callback: (iterator: AsyncIterable, participantId: string) => void | Promise, onError?: (error: LifeError) => void): OperationResult<() => void>; abstract enableMicrophone(): Promise>; abstract playAudio(): Promise>; abstract streamAudioChunk(chunk: Int16Array): Promise>; } type RPCProcedureSchema = { input?: z__default.ZodObject; output?: z__default.ZodObject; }; type RPCProcedure = { name: string; schema?: Schema; execute: (input: Schema["input"] extends z__default.ZodObject ? z__default.infer : undefined) => MaybePromise : void>>; }; declare abstract class TransportClientBase { #private; constructor({ provider, telemetry, obfuscateErrors, }: { provider: TransportProviderClientBase; obfuscateErrors?: boolean; telemetry?: TelemetryClient | null; }); sendText(topic: string, text: string): Promise; receiveText(topic: string, callback: (text: string, participantId: string) => MaybePromise, onError?: (error: LifeError) => void): readonly [error: LifeErrorUnion, data: undefined] | readonly [error: undefined, data: () => void]; sendObject(topic: string, obj: SerializableValue): Promise; receiveObject(topic: string, callback: (obj: unknown, participantId: string) => MaybePromise, onError?: (error: LifeError) => void): readonly [error: LifeErrorUnion, data: undefined] | readonly [error: undefined, data: () => void]; /** * Register a remote procedure. * @param procedure - The procedure to register */ register(procedure: RPCProcedure): void; /** * Call a remote procedure. * @param name - The name of the procedure to call * @param inputs - The parameters to pass to the procedure * @returns A promise that resolves to the response from the procedure */ call({ name, schema, input, timeoutMs, }: { name: string; schema?: Schema; timeoutMs?: number; } & (Schema["input"] extends z__default.ZodObject ? { input: z__default.infer; } : { input?: never; })): Promise : void>>; on: TransportProviderClientBase["on"]; joinRoom: TransportProviderClientBase["joinRoom"]; leaveRoom: TransportProviderClientBase["leaveRoom"]; streamText: TransportProviderClientBase["streamText"]; receiveStreamText: TransportProviderClientBase["receiveStreamText"]; enableMicrophone: TransportProviderClientBase["enableMicrophone"]; playAudio: TransportProviderClientBase["playAudio"]; streamAudioChunk: TransportProviderClientBase["streamAudioChunk"]; } declare const transportNodeConfig: ZodUnionWithTelemetry<"provider", readonly [ZodObjectWithTelemetry; serverUrl: z.ZodPrefault; apiKey: z.ZodPrefault; apiSecret: z.ZodPrefault; }, zod_v4_core.$strip>, "output">], z.ZodDiscriminatedUnion; serverUrl: z.ZodPrefault; apiKey: z.ZodPrefault; apiSecret: z.ZodPrefault; }, zod_v4_core.$strip>[], "provider">>; declare class TransportNodeClient extends TransportClientBase { constructor({ config, obfuscateErrors, telemetry, }: { config: z$1.output<(typeof transportNodeConfig)["schema"]>; obfuscateErrors?: boolean; telemetry?: TelemetryClient | null; }); } /** * Type representing a camelCase method name. * Used to enforce type safety when working with method names. */ type ToMethodName = CamelCase; declare class AgentBuilder { readonly def: AgentDef; constructor(definition: AgentDef); config(config: z$1.input): TypedAgentBuilder; scope(scope: AgentScopeDefinition): TypedAgentBuilder>, Excluded | "scope">; /** * Register plugins to extend the agent server features. * Defaults to `[generation, memories, stores, actions, percepts]` plugins if not specified. * * In case you want to register custom plugins and still keep the defaults you can do: * ```ts * import { defaults } from "life/client"; * * defineAgentClient("my-agent").plugins([...defaults.plugins, myCustomPlugin]); * ``` * * Or if you want only some of the defaults, you can do: * ```ts * import { defaults } from "life/client"; * * defineAgentClient("my-agent").plugins([defaults.plugins.generation, defaults.plugins.memories]); * ``` */ plugins(plugins: Plugins): TypedAgentBuilder, "pluginConfigs", { [K in Plugins[number] as K["def"]["name"]]: PluginConfig; }>, Excluded | "plugins">; static withPluginsMethods>(builder: Builder): Builder; } declare function defineAgent(name: Name): TypedAgentBuilder<{ readonly name: Name; readonly config: {}; readonly scope: { readonly schema: z$1.ZodObject<{ [x: string]: any; }, z$1.core.$strip>; readonly hasAccess: () => true; }; readonly plugins: ({ name: "generation"; dependencies: never[]; config: ZodObjectWithTelemetry; scoreOutThreshold: z$1.ZodPrefault; prePaddingChunks: z$1.ZodPrefault; postPaddingChunks: z$1.ZodPrefault; minVoiceInterruptionMs: z$1.ZodPrefault; }, z$1.core.$strip>>; endOfTurnDetection: z$1.ZodPrefault; minTimeoutMs: z$1.ZodPrefault; maxTimeoutMs: z$1.ZodPrefault; }, z$1.core.$strip>>; }, z$1.core.$strip>, "output">; context: ZodObjectWithTelemetry; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>>; status: z$1.ZodPrefault; thinking: z$1.ZodPrefault; speaking: z$1.ZodPrefault; }, z$1.core.$strip>>; voiceEnabled: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; events: [{ readonly name: "plugin.start"; readonly dataSchema: z$1.ZodObject<{ isRestart: z$1.ZodPrefault; restartCount: z$1.ZodPrefault; }, z$1.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z$1.ZodObject<{ error: z$1.ZodCustom; event: z$1.ZodObject<{ id: z$1.ZodString; name: z$1.ZodString; urgent: z$1.ZodPrefault; data: z$1.ZodPrefault; created: z$1.ZodObject<{ at: z$1.ZodNumber; by: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"handler">; plugin: z$1.ZodString; handler: z$1.ZodString; event: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"server">; name: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"client">; name: z$1.ZodString; }, z$1.core.$strip>], "type">; }, z$1.core.$strip>; edited: z$1.ZodDefault; reason: z$1.ZodString; dataBefore: z$1.ZodAny; dataAfter: z$1.ZodAny; }, z$1.core.$strip>>, z$1.ZodLiteral]>>; dropped: z$1.ZodPrefault; reason: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodLiteral]>>; contextChanges: z$1.ZodPrefault>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }] | [{ name: "messages.create"; dataSchema: z$1.ZodObject<{ message: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ role: z$1.ZodLiteral<"user">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; }, z$1.core.$strip>], "role">; }, z$1.core.$strip>; }, { name: "messages.update"; dataSchema: z$1.ZodObject<{ id: z$1.ZodString; role: z$1.ZodEnum<{ user: "user"; system: "system"; agent: "agent"; tool: "tool"; }>; message: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ role: z$1.ZodLiteral<"user">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; }, z$1.core.$strip>], "role">; }, z$1.core.$strip>; }, { name: "user.audio-chunk"; dataSchema: z$1.ZodObject<{ audioChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>; }, { name: "user.voice-start"; }, { name: "user.voice-chunk"; dataSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"voice">; voiceChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"padding">; voiceChunk: z$1.ZodCustom, Int16Array>; paddingSide: z$1.ZodEnum<{ pre: "pre"; post: "post"; }>; paddingIndex: z$1.ZodNumber; }, z$1.core.$strip>], "type">; }, { name: "user.voice-end"; }, { name: "user.text-chunk"; dataSchema: z$1.ZodObject<{ textChunk: z$1.ZodString; }, z$1.core.$strip>; }, { name: "user.interrupted"; }, { name: "agent.thinking-start"; }, { name: "agent.thinking-end"; }, { name: "agent.speaking-start"; }, { name: "agent.speaking-end"; }, { name: "agent.continue"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; }, z$1.core.$strip>; }, { name: "agent.decide"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; messages: z$1.ZodArray; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>; }, z$1.core.$strip>; }, { name: "agent.say"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; text: z$1.ZodString; }, z$1.core.$strip>; }, { name: "agent.interrupt"; dataSchema: z$1.ZodObject<{ reason: z$1.ZodString; author: z$1.ZodEnum<{ user: "user"; application: "application"; }>; force: z$1.ZodPrefault; }, z$1.core.$strip>; }, { name: "agent.resources-request"; }, { name: "agent.resources-response"; dataSchema: z$1.ZodObject<{ requestId: z$1.ZodString; resources: z$1.ZodObject<{ messages: z$1.ZodArray; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>; tools: z$1.ZodArray, z$1.ZodObject>; output: z$1.ZodCustom, z$1.ZodObject>; }, z$1.core.$strip>; run: z$1.ZodFunction], null>, z$1.ZodUnion>; error: z$1.ZodOptional; }, z$1.core.$strip>, z$1.ZodPromise>; error: z$1.ZodOptional; }, z$1.core.$strip>>]>>; }, z$1.core.$strip>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }, { name: "agent.tool-requests"; dataSchema: z$1.ZodObject<{ requests: z$1.ZodArray; }, z$1.core.$strip>>; }, z$1.core.$strip>; }, { name: "agent.interrupted"; dataSchema: z$1.ZodObject<{ reason: z$1.ZodString; forced: z$1.ZodBoolean; author: z$1.ZodEnum<{ user: "user"; application: "application"; }>; }, z$1.core.$strip>; }, { name: "agent.text-chunk"; dataSchema: z$1.ZodObject<{ textChunk: z$1.ZodString; }, z$1.core.$strip>; }, { name: "agent.voice-chunk"; dataSchema: z$1.ZodObject<{ voiceChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>; }]; handlers: [...never[], { name: "maintain-status"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "maintain-messages"; mode: "block"; state: never; onEvent: (params: unknown) => string | undefined; }, { name: "receive-user-audio"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "detect-user-voice"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "transcribe-user-voice"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "detect-end-of-turn"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "generate-agent-response"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "handle-resources-requests"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "handle-tools-requests"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "stream-outgoing-audio"; mode: "stream"; state: never; onEvent: (params: unknown) => void; }]; } | { name: "memories"; dependencies: { name: "generation"; config: ZodObjectWithTelemetry; scoreOutThreshold: z$1.ZodPrefault; prePaddingChunks: z$1.ZodPrefault; postPaddingChunks: z$1.ZodPrefault; minVoiceInterruptionMs: z$1.ZodPrefault; }, z$1.core.$strip>>; endOfTurnDetection: z$1.ZodPrefault; minTimeoutMs: z$1.ZodPrefault; maxTimeoutMs: z$1.ZodPrefault; }, z$1.core.$strip>>; }, z$1.core.$strip>, "output">; context: ZodObjectWithTelemetry; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>>; status: z$1.ZodPrefault; thinking: z$1.ZodPrefault; speaking: z$1.ZodPrefault; }, z$1.core.$strip>>; voiceEnabled: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; events: [{ readonly name: "plugin.start"; readonly dataSchema: z$1.ZodObject<{ isRestart: z$1.ZodPrefault; restartCount: z$1.ZodPrefault; }, z$1.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z$1.ZodObject<{ error: z$1.ZodCustom; event: z$1.ZodObject<{ id: z$1.ZodString; name: z$1.ZodString; urgent: z$1.ZodPrefault; data: z$1.ZodPrefault; created: z$1.ZodObject<{ at: z$1.ZodNumber; by: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"handler">; plugin: z$1.ZodString; handler: z$1.ZodString; event: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"server">; name: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"client">; name: z$1.ZodString; }, z$1.core.$strip>], "type">; }, z$1.core.$strip>; edited: z$1.ZodDefault; reason: z$1.ZodString; dataBefore: z$1.ZodAny; dataAfter: z$1.ZodAny; }, z$1.core.$strip>>, z$1.ZodLiteral]>>; dropped: z$1.ZodPrefault; reason: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodLiteral]>>; contextChanges: z$1.ZodPrefault>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }] | [{ name: "messages.create"; dataSchema: z$1.ZodObject<{ message: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ role: z$1.ZodLiteral<"user">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; }, z$1.core.$strip>], "role">; }, z$1.core.$strip>; }, { name: "messages.update"; dataSchema: z$1.ZodObject<{ id: z$1.ZodString; role: z$1.ZodEnum<{ user: "user"; system: "system"; agent: "agent"; tool: "tool"; }>; message: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ role: z$1.ZodLiteral<"user">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; }, z$1.core.$strip>], "role">; }, z$1.core.$strip>; }, { name: "user.audio-chunk"; dataSchema: z$1.ZodObject<{ audioChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>; }, { name: "user.voice-start"; }, { name: "user.voice-chunk"; dataSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"voice">; voiceChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"padding">; voiceChunk: z$1.ZodCustom, Int16Array>; paddingSide: z$1.ZodEnum<{ pre: "pre"; post: "post"; }>; paddingIndex: z$1.ZodNumber; }, z$1.core.$strip>], "type">; }, { name: "user.voice-end"; }, { name: "user.text-chunk"; dataSchema: z$1.ZodObject<{ textChunk: z$1.ZodString; }, z$1.core.$strip>; }, { name: "user.interrupted"; }, { name: "agent.thinking-start"; }, { name: "agent.thinking-end"; }, { name: "agent.speaking-start"; }, { name: "agent.speaking-end"; }, { name: "agent.continue"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; }, z$1.core.$strip>; }, { name: "agent.decide"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; messages: z$1.ZodArray; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>; }, z$1.core.$strip>; }, { name: "agent.say"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; text: z$1.ZodString; }, z$1.core.$strip>; }, { name: "agent.interrupt"; dataSchema: z$1.ZodObject<{ reason: z$1.ZodString; author: z$1.ZodEnum<{ user: "user"; application: "application"; }>; force: z$1.ZodPrefault; }, z$1.core.$strip>; }, { name: "agent.resources-request"; }, { name: "agent.resources-response"; dataSchema: z$1.ZodObject<{ requestId: z$1.ZodString; resources: z$1.ZodObject<{ messages: z$1.ZodArray; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>; tools: z$1.ZodArray, z$1.ZodObject>; output: z$1.ZodCustom, z$1.ZodObject>; }, z$1.core.$strip>; run: z$1.ZodFunction], null>, z$1.ZodUnion>; error: z$1.ZodOptional; }, z$1.core.$strip>, z$1.ZodPromise>; error: z$1.ZodOptional; }, z$1.core.$strip>>]>>; }, z$1.core.$strip>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }, { name: "agent.tool-requests"; dataSchema: z$1.ZodObject<{ requests: z$1.ZodArray; }, z$1.core.$strip>>; }, z$1.core.$strip>; }, { name: "agent.interrupted"; dataSchema: z$1.ZodObject<{ reason: z$1.ZodString; forced: z$1.ZodBoolean; author: z$1.ZodEnum<{ user: "user"; application: "application"; }>; }, z$1.core.$strip>; }, { name: "agent.text-chunk"; dataSchema: z$1.ZodObject<{ textChunk: z$1.ZodString; }, z$1.core.$strip>; }, { name: "agent.voice-chunk"; dataSchema: z$1.ZodObject<{ voiceChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>; }]; handlers: [...never[], { name: "maintain-status"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "maintain-messages"; mode: "block"; state: never; onEvent: (params: unknown) => string | undefined; }, { name: "receive-user-audio"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "detect-user-voice"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "transcribe-user-voice"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "detect-end-of-turn"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "generate-agent-response"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "handle-resources-requests"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "handle-tools-requests"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "stream-outgoing-audio"; mode: "stream"; state: never; onEvent: (params: unknown) => void; }]; }[]; config: ZodObjectWithTelemetry>>; }, z$1.core.$strip>, "output">; context: ZodObjectWithTelemetry; }[]; id: string; createdAt: number; lastUpdated: number; } | { role: "tool"; toolRequestId: string; toolName: string; toolSuccess: boolean; id: string; createdAt: number; lastUpdated: number; toolOutput?: Record | undefined; toolError?: string | undefined; })[]>, Map; }[]; id: string; createdAt: number; lastUpdated: number; } | { role: "tool"; toolRequestId: string; toolName: string; toolSuccess: boolean; id: string; createdAt: number; lastUpdated: number; toolOutput?: Record | undefined; toolError?: string | undefined; })[]>>>; memoriesLastTimestamp: z$1.ZodPrefault, Map>>; processedRequestsIds: z$1.ZodPrefault, Set>>; computedMemoriesCache: z$1.ZodPrefault, Map>>; }, z$1.core.$strip>, "output">; events: [{ readonly name: "plugin.start"; readonly dataSchema: z$1.ZodObject<{ isRestart: z$1.ZodPrefault; restartCount: z$1.ZodPrefault; }, z$1.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z$1.ZodObject<{ error: z$1.ZodCustom; event: z$1.ZodObject<{ id: z$1.ZodString; name: z$1.ZodString; urgent: z$1.ZodPrefault; data: z$1.ZodPrefault; created: z$1.ZodObject<{ at: z$1.ZodNumber; by: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"handler">; plugin: z$1.ZodString; handler: z$1.ZodString; event: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"server">; name: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"client">; name: z$1.ZodString; }, z$1.core.$strip>], "type">; }, z$1.core.$strip>; edited: z$1.ZodDefault; reason: z$1.ZodString; dataBefore: z$1.ZodAny; dataAfter: z$1.ZodAny; }, z$1.core.$strip>>, z$1.ZodLiteral]>>; dropped: z$1.ZodPrefault; reason: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodLiteral]>>; contextChanges: z$1.ZodPrefault>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }] | [{ name: "cache-build"; dataSchema: z$1.ZodObject<{ messagesHash: z$1.ZodString; memories: z$1.ZodArray; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>; }, z$1.core.$strip>; }, { name: "cache-memory"; dataSchema: z$1.ZodObject<{ name: z$1.ZodString; messages: z$1.ZodArray; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>; timestamp: z$1.ZodNumber; }, z$1.core.$strip>; }]; handlers: never[]; } | { name: "stores"; dependencies: { name: "generation"; config: ZodObjectWithTelemetry; scoreOutThreshold: z$1.ZodPrefault; prePaddingChunks: z$1.ZodPrefault; postPaddingChunks: z$1.ZodPrefault; minVoiceInterruptionMs: z$1.ZodPrefault; }, z$1.core.$strip>>; endOfTurnDetection: z$1.ZodPrefault; minTimeoutMs: z$1.ZodPrefault; maxTimeoutMs: z$1.ZodPrefault; }, z$1.core.$strip>>; }, z$1.core.$strip>, "output">; context: ZodObjectWithTelemetry; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>>; status: z$1.ZodPrefault; thinking: z$1.ZodPrefault; speaking: z$1.ZodPrefault; }, z$1.core.$strip>>; voiceEnabled: z$1.ZodPrefault; }, z$1.core.$strip>, "output">; events: [{ readonly name: "plugin.start"; readonly dataSchema: z$1.ZodObject<{ isRestart: z$1.ZodPrefault; restartCount: z$1.ZodPrefault; }, z$1.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z$1.ZodObject<{ error: z$1.ZodCustom; event: z$1.ZodObject<{ id: z$1.ZodString; name: z$1.ZodString; urgent: z$1.ZodPrefault; data: z$1.ZodPrefault; created: z$1.ZodObject<{ at: z$1.ZodNumber; by: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"handler">; plugin: z$1.ZodString; handler: z$1.ZodString; event: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"server">; name: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"client">; name: z$1.ZodString; }, z$1.core.$strip>], "type">; }, z$1.core.$strip>; edited: z$1.ZodDefault; reason: z$1.ZodString; dataBefore: z$1.ZodAny; dataAfter: z$1.ZodAny; }, z$1.core.$strip>>, z$1.ZodLiteral]>>; dropped: z$1.ZodPrefault; reason: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodLiteral]>>; contextChanges: z$1.ZodPrefault>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }] | [{ name: "messages.create"; dataSchema: z$1.ZodObject<{ message: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ role: z$1.ZodLiteral<"user">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; }, z$1.core.$strip>], "role">; }, z$1.core.$strip>; }, { name: "messages.update"; dataSchema: z$1.ZodObject<{ id: z$1.ZodString; role: z$1.ZodEnum<{ user: "user"; system: "system"; agent: "agent"; tool: "tool"; }>; message: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ role: z$1.ZodLiteral<"user">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; }, z$1.core.$strip>], "role">; }, z$1.core.$strip>; }, { name: "user.audio-chunk"; dataSchema: z$1.ZodObject<{ audioChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>; }, { name: "user.voice-start"; }, { name: "user.voice-chunk"; dataSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"voice">; voiceChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"padding">; voiceChunk: z$1.ZodCustom, Int16Array>; paddingSide: z$1.ZodEnum<{ pre: "pre"; post: "post"; }>; paddingIndex: z$1.ZodNumber; }, z$1.core.$strip>], "type">; }, { name: "user.voice-end"; }, { name: "user.text-chunk"; dataSchema: z$1.ZodObject<{ textChunk: z$1.ZodString; }, z$1.core.$strip>; }, { name: "user.interrupted"; }, { name: "agent.thinking-start"; }, { name: "agent.thinking-end"; }, { name: "agent.speaking-start"; }, { name: "agent.speaking-end"; }, { name: "agent.continue"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; }, z$1.core.$strip>; }, { name: "agent.decide"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; messages: z$1.ZodArray; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>; }, z$1.core.$strip>; }, { name: "agent.say"; dataSchema: z$1.ZodObject<{ interrupt: z$1.ZodPrefault, z$1.ZodLiteral]>>; preventInterruption: z$1.ZodPrefault; text: z$1.ZodString; }, z$1.core.$strip>; }, { name: "agent.interrupt"; dataSchema: z$1.ZodObject<{ reason: z$1.ZodString; author: z$1.ZodEnum<{ user: "user"; application: "application"; }>; force: z$1.ZodPrefault; }, z$1.core.$strip>; }, { name: "agent.resources-request"; }, { name: "agent.resources-response"; dataSchema: z$1.ZodObject<{ requestId: z$1.ZodString; resources: z$1.ZodObject<{ messages: z$1.ZodArray; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"system">; content: z$1.ZodPrefault; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"agent">; content: z$1.ZodPrefault; toolsRequests: z$1.ZodPrefault; }, z$1.core.$strip>>>; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>, z$1.ZodObject<{ role: z$1.ZodLiteral<"tool">; toolRequestId: z$1.ZodString; toolName: z$1.ZodString; toolSuccess: z$1.ZodBoolean; toolOutput: z$1.ZodOptional>; toolError: z$1.ZodOptional; id: z$1.ZodString; createdAt: z$1.ZodNumber; lastUpdated: z$1.ZodNumber; }, z$1.core.$strip>], "role">>; tools: z$1.ZodArray, z$1.ZodObject>; output: z$1.ZodCustom, z$1.ZodObject>; }, z$1.core.$strip>; run: z$1.ZodFunction], null>, z$1.ZodUnion>; error: z$1.ZodOptional; }, z$1.core.$strip>, z$1.ZodPromise>; error: z$1.ZodOptional; }, z$1.core.$strip>>]>>; }, z$1.core.$strip>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }, { name: "agent.tool-requests"; dataSchema: z$1.ZodObject<{ requests: z$1.ZodArray; }, z$1.core.$strip>>; }, z$1.core.$strip>; }, { name: "agent.interrupted"; dataSchema: z$1.ZodObject<{ reason: z$1.ZodString; forced: z$1.ZodBoolean; author: z$1.ZodEnum<{ user: "user"; application: "application"; }>; }, z$1.core.$strip>; }, { name: "agent.text-chunk"; dataSchema: z$1.ZodObject<{ textChunk: z$1.ZodString; }, z$1.core.$strip>; }, { name: "agent.voice-chunk"; dataSchema: z$1.ZodObject<{ voiceChunk: z$1.ZodCustom, Int16Array>; }, z$1.core.$strip>; }]; handlers: [...never[], { name: "maintain-status"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "maintain-messages"; mode: "block"; state: never; onEvent: (params: unknown) => string | undefined; }, { name: "receive-user-audio"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "detect-user-voice"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "transcribe-user-voice"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "detect-end-of-turn"; mode: "stream"; state: never; onEvent: (params: unknown) => Promise; }, { name: "generate-agent-response"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "handle-resources-requests"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "handle-tools-requests"; mode: "block"; state: never; onEvent: (params: unknown) => void; }, { name: "stream-outgoing-audio"; mode: "stream"; state: never; onEvent: (params: unknown) => void; }]; }[]; config: ZodObjectWithTelemetry>>; }, z$1.core.$strip>, "output">; context: ZodObjectWithTelemetry>; }, z$1.core.$strip>, "output">; events: [{ readonly name: "plugin.start"; readonly dataSchema: z$1.ZodObject<{ isRestart: z$1.ZodPrefault; restartCount: z$1.ZodPrefault; }, z$1.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z$1.ZodObject<{ error: z$1.ZodCustom; event: z$1.ZodObject<{ id: z$1.ZodString; name: z$1.ZodString; urgent: z$1.ZodPrefault; data: z$1.ZodPrefault; created: z$1.ZodObject<{ at: z$1.ZodNumber; by: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"handler">; plugin: z$1.ZodString; handler: z$1.ZodString; event: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"server">; name: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"client">; name: z$1.ZodString; }, z$1.core.$strip>], "type">; }, z$1.core.$strip>; edited: z$1.ZodDefault; reason: z$1.ZodString; dataBefore: z$1.ZodAny; dataAfter: z$1.ZodAny; }, z$1.core.$strip>>, z$1.ZodLiteral]>>; dropped: z$1.ZodPrefault; reason: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodLiteral]>>; contextChanges: z$1.ZodPrefault>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }] | [{ name: "update-store-data"; dataSchema: z$1.ZodObject<{ name: z$1.ZodString; data: z$1.ZodAny; }, z$1.core.$strip>; }, { name: "retrieve-store-data"; dataSchema: z$1.ZodObject<{ name: z$1.ZodString; }, z$1.core.$strip>; }]; handlers: never[]; })[]; readonly pluginConfigs: {}; }, never>; type AgentScopeDefinition = { schema: Schema; hasAccess: (params: { request: Request; scope: z__default.output; }) => boolean | Promise; }; type AgentScope = z__default.output; type AgentPluginsDefinition = PluginDefinition[]; type AgentDefinition = { name: string; config: z__default.input; plugins: AgentPluginsDefinition; pluginConfigs: Record; scope: AgentScopeDefinition; }; type TypedAgentBuilder = Omit & (Extract extends never ? unknown : { /** * TODO */ generation: AgentBuilderPluginMethod<"generation", AgentDef, Excluded>; }) & (Extract extends never ? unknown : { /** * TODO */ memories: AgentBuilderPluginMethod<"memories", AgentDef, Excluded>; }) & (Extract extends never ? unknown : { /** * TODO */ actions: AgentBuilderPluginMethod<"actions", AgentDef, Excluded>; }) & (Extract extends never ? unknown : { /** * TODO */ percepts: AgentBuilderPluginMethod<"percepts", AgentDef, Excluded>; }) & (Extract extends never ? unknown : { /** * TODO */ stores: AgentBuilderPluginMethod<"stores", AgentDef, Excluded>; }) & (Extract extends never ? unknown : { /** * TODO */ effects: AgentBuilderPluginMethod<"effects", AgentDef, Excluded>; }) & { [PluginDef in Exclude as ToMethodName]: AgentBuilderPluginMethod; }, Excluded>; type AgentBuilderPluginMethod = ["config"], "input">>(config: C) => PluginName extends string ? TypedAgentBuilder["config"], "output"> & C; }; }, Excluded | PluginName> : never; declare class AgentServer { #private; readonly def: AgentDefinition; readonly id: string; readonly sha: string; readonly config: z__default.output; readonly transport: TransportNodeClient; readonly storage: null; readonly models: { vad: InstanceType; stt: InstanceType; eou: InstanceType; llm: InstanceType; tts: InstanceType; }; readonly plugins: Record>; readonly scope: AgentScope; readonly isRestart: boolean; readonly telemetry: TelemetryClient; constructor({ id, sha, definition, scope, config, pluginsContexts, isRestart, }: { id: string; sha: string; definition: AgentDefinition; config: z__default.output; scope?: AgentScope; isRestart?: boolean; pluginsContexts?: Record; }); start(): Promise; stop(): Promise; } /** * Builder class for the plugin definition. * Do not use directly, use `definePlugin()` instead. */ declare class PluginBuilder { readonly def: PluginDef; constructor(definition: PluginDef); /** * ### `.dependencies()` * * Specify other plugins as required by this plugin. * * Their context, events, and config can then be accessed from `dependencies.*` inside handlers. * * @see TODO: Add docs link * * @example * ```ts * const plugin = definePlugin("my-plugin") * .dependencies([anotherPlugin]); * .addHandler({ * name: "handler-1", * mode: "block", * onEvent: ({ dependencies }) => { * if (dependencies.anotherPlugin.config.delayMs > 10) { // <-- Here * // ... * } * }, * }); * ``` *   * * --- * @param plugins - The dependencies definitions. * @returns TypedPluginBuilder */ dependencies(plugins: Plugins): TypedPluginBuilder; }>, Excluded | "dependencies">; /** * ### `.config()` * * Add a configuration that users can provide to tweak plugin's behavior. * * @see TODO: Add docs link * * @example * ```ts * const myPlugin = definePlugin("my-plugin") * .config({ schema: z.object({ enableVoice: z.boolean() }) }); * * const myAgent = defineAgent("my-agent") * .plugins([myPlugin]) * .myPlugin({ enableVoice: true }); // <-- Here * ``` *   * * --- * * The provided config can then be accessed from `plugin.config` inside handlers. * * @example * ```ts * const plugin = definePlugin("my-plugin") * .config({ schema: z.object({ enableVoice: z.boolean() }) }); * .addHandler({ * name: "handler-1", * mode: "block", * onEvent: ({ plugin }) => { * if (plugin.config.enableVoice) { // <-- Here * // ... * } * }, * }); * * ``` *   * * --- * @param config - The config definition. * @returns TypedPluginBuilder */ config(config: ZodObjectWithTelemetry): TypedPluginBuilder<{ [K in keyof { [I in keyof PluginDef]: I extends "config" ? ZodObjectWithTelemetry : PluginDef[I]; }]: { [I in keyof PluginDef]: I extends "config" ? ZodObjectWithTelemetry : PluginDef[I]; }[K]; }, "config" | Excluded | "$config">; /** * ### `.$config()` * * Define plugin config from the output of `definePluginConfig()`. * * @see TODO: Add docs link for `definePluginConfig()` * * --- * @param config - The config definition. * @returns TypedPluginBuilder */ $config(config: ConfigDef): TypedPluginBuilder, Excluded | "config" | "$config">; /** * ### `.context()` * * Add an in-memory object that handlers can read/write to share data without race conditions. * * Context is also exposed to dependent plugins and synced to the frontend via RPC. * * The context must be serializable, and thus cannot contain functions, instances, etc. * Use `state` property in handlers for non-serializable data instead. * * @see TODO: Add docs link * * @example * ```ts * const plugin = definePlugin("my-plugin") * .context(z.object({ name: z.string() })); * ``` *   * * --- * @param context - The context definition. */ context(context: ZodObjectWithTelemetry): TypedPluginBuilder<{ [K in keyof { [I in keyof PluginDef]: I extends "context" ? ZodObjectWithTelemetry : PluginDef[I]; }]: { [I in keyof PluginDef]: I extends "context" ? ZodObjectWithTelemetry : PluginDef[I]; }[K]; }, "context" | Excluded | "$context">; /** * ### `.$context()` * * Define plugin context from the output of `definePluginContext()`. * * @see TODO: Add docs link for `definePluginContext()` * * --- * @param context - The context definition. * @returns TypedPluginBuilder */ $context(context: ContextDef): TypedPluginBuilder, Excluded | "context" | "$context">; /** * ### `.events()` * * Add events that handlers can emit and observe to communicate with each other. * * Each plugin has a single event queue enforcing the order of execution, making * plugins more predictable and easier to write and maintain. * * @see TODO: Add docs link * * @example * ```ts * const plugin = definePlugin("my-plugin") * .events([{ name: "my-event" }]) * .addHandler({ * name: "handler-1", * mode: "block", * onEvent: ({ event, plugin }) => { * // Emit 'my-event' when the plugin starts * if (event.name === "plugin.start") { * plugin.events.emit({ name: "my-event" }); * } * }, * }) * .addHandler({ * name: "handler-2", * mode: "block", * onEvent: ({ event, plugin }) => { * // Listen to 'my-event' from handler-1 * if (event.name === "my-event") { * // Do something... * } * }, * }); * ``` *   * * --- * @param events - The events definition. * @returns TypedPluginBuilder */ events>(...events: EventsDef): TypedPluginBuilder<{ [K in keyof { [I in keyof PluginDef]: I extends "events" ? [{ readonly name: "plugin.start"; readonly dataSchema: z$1.ZodObject<{ isRestart: z$1.ZodPrefault; restartCount: z$1.ZodPrefault; }, z$1.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z$1.ZodObject<{ error: z$1.ZodCustom; event: z$1.ZodObject<{ id: z$1.ZodString; name: z$1.ZodString; urgent: z$1.ZodPrefault; data: z$1.ZodPrefault; created: z$1.ZodObject<{ at: z$1.ZodNumber; by: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"handler">; plugin: z$1.ZodString; handler: z$1.ZodString; event: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"server">; name: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"client">; name: z$1.ZodString; }, z$1.core.$strip>], "type">; }, z$1.core.$strip>; edited: z$1.ZodDefault; reason: z$1.ZodString; dataBefore: z$1.ZodAny; dataAfter: z$1.ZodAny; }, z$1.core.$strip>>, z$1.ZodLiteral]>>; dropped: z$1.ZodPrefault; reason: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodLiteral]>>; contextChanges: z$1.ZodPrefault>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }] | EventsDef : PluginDef[I]; }]: { [I in keyof PluginDef]: I extends "events" ? [{ readonly name: "plugin.start"; readonly dataSchema: z$1.ZodObject<{ isRestart: z$1.ZodPrefault; restartCount: z$1.ZodPrefault; }, z$1.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z$1.ZodObject<{ error: z$1.ZodCustom; event: z$1.ZodObject<{ id: z$1.ZodString; name: z$1.ZodString; urgent: z$1.ZodPrefault; data: z$1.ZodPrefault; created: z$1.ZodObject<{ at: z$1.ZodNumber; by: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"handler">; plugin: z$1.ZodString; handler: z$1.ZodString; event: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"server">; name: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"client">; name: z$1.ZodString; }, z$1.core.$strip>], "type">; }, z$1.core.$strip>; edited: z$1.ZodDefault; reason: z$1.ZodString; dataBefore: z$1.ZodAny; dataAfter: z$1.ZodAny; }, z$1.core.$strip>>, z$1.ZodLiteral]>>; dropped: z$1.ZodPrefault; reason: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodLiteral]>>; contextChanges: z$1.ZodPrefault>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }] | EventsDef : PluginDef[I]; }[K]; }, "events" | Excluded | "$events">; /** * ### `.$events()` * * Define plugin events from the output of `definePluginEvents()`. * * @see TODO: Add docs link for `definePluginEvents()` * * --- * @param events - The events definition. * @returns TypedPluginBuilder */ $events(events: EventsDef): TypedPluginBuilder, Excluded | "events" | "$events">; /** * ### `.addHandler()` * * Add a handler function to react to events from this plugin or dependent plugins. * * @see TODO: Add docs link * * @example * ```ts * const plugin = definePlugin("my-plugin") * .addHandler({ * name: "handler-1", * mode: "block", * onEvent: ({ event, plugin }) => { * // Do something... * }, * }); * ``` *   * * --- * * Handlers can return a value, which can be retrieved using the `events.waitForResult(eventId, handlerName)` method. * * @example * ```ts * const plugin = definePlugin("my-plugin") * .events([{ name: "my-event" }]) * .addHandler({ * name: "handler-1", * mode: "block", * onEvent: () => 123; * }) * .addHandler({ * name: "handler-2", * mode: "block", * onEvent: ({ event, plugin }) => { * if (event.name === "my-event") { * const eventId = plugin.events.emit({ name: "my-event" }); * const result = await plugin.events.waitForResult(eventId, "handler-1"); * // result: string (type-safe!) * } * }, * }) * ``` *   * * --- * @param handler - The handler definition. * @returns TypedPluginBuilder */ addHandler, StateDef extends PluginHandlerStateDefinition>(handler: Handler & { state?: StateDef; }): TypedPluginBuilder ReturnType; }]>, Excluded>; /** * ### `.removeHandler()` * * Remove a previously added handler from the plugin. * * @see TODO: Add docs link * * @example * ```ts * const plugin = definePlugin("my-plugin") * .addHandler({ * name: "handler-1", * mode: "block", * onEvent: ({ event, plugin }) => void 0, * }); * * const pluginWithoutHandler1 = plugin.removeHandler("handler-1"); * ``` *   * * --- * @param name - The name of the handler to remove. * @returns TypedPluginBuilder */ removeHandler(name: Name): TypedPluginBuilder>, Excluded>; } /** * ### `definePlugin()` * * Define a new Life.js plugin. * * @see TODO: Add docs link */ declare function definePlugin(name: Name): PluginBuilder<{ name: Name; dependencies: never[]; config: ZodObjectWithTelemetry, "output">; context: ZodObjectWithTelemetry, "output">; events: [{ readonly name: "plugin.start"; readonly dataSchema: z$1.ZodObject<{ isRestart: z$1.ZodPrefault; restartCount: z$1.ZodPrefault; }, z$1.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z$1.ZodObject<{ error: z$1.ZodCustom; event: z$1.ZodObject<{ id: z$1.ZodString; name: z$1.ZodString; urgent: z$1.ZodPrefault; data: z$1.ZodPrefault; created: z$1.ZodObject<{ at: z$1.ZodNumber; by: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{ type: z$1.ZodLiteral<"handler">; plugin: z$1.ZodString; handler: z$1.ZodString; event: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"server">; name: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodObject<{ type: z$1.ZodLiteral<"client">; name: z$1.ZodString; }, z$1.core.$strip>], "type">; }, z$1.core.$strip>; edited: z$1.ZodDefault; reason: z$1.ZodString; dataBefore: z$1.ZodAny; dataAfter: z$1.ZodAny; }, z$1.core.$strip>>, z$1.ZodLiteral]>>; dropped: z$1.ZodPrefault; reason: z$1.ZodString; }, z$1.core.$strip>, z$1.ZodLiteral]>>; contextChanges: z$1.ZodPrefault>>; }, z$1.core.$strip>; }, z$1.core.$strip>; }]; handlers: never[]; }, never>; type PluginDependenciesDefinition = Without[]; type PluginConfigDefinition = ZodObjectWithTelemetry; type PluginConfig = T extends "input" ? z__default.input : z__default.output; type PluginContextDefinition = ZodObjectWithTelemetry; type PluginContext = T extends "input" ? z__default.input : z__default.output; declare const eventSourceSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{ type: z__default.ZodLiteral<"handler">; plugin: z__default.ZodString; handler: z__default.ZodString; event: z__default.ZodString; }, z__default.core.$strip>, z__default.ZodObject<{ type: z__default.ZodLiteral<"server">; name: z__default.ZodString; }, z__default.core.$strip>, z__default.ZodObject<{ type: z__default.ZodLiteral<"client">; name: z__default.ZodString; }, z__default.core.$strip>], "type">; type PluginEventSource = z__default.infer; declare const pluginEventSchema: z__default.ZodObject<{ id: z__default.ZodString; name: z__default.ZodString; urgent: z__default.ZodPrefault; data: z__default.ZodPrefault; created: z__default.ZodObject<{ at: z__default.ZodNumber; by: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{ type: z__default.ZodLiteral<"handler">; plugin: z__default.ZodString; handler: z__default.ZodString; event: z__default.ZodString; }, z__default.core.$strip>, z__default.ZodObject<{ type: z__default.ZodLiteral<"server">; name: z__default.ZodString; }, z__default.core.$strip>, z__default.ZodObject<{ type: z__default.ZodLiteral<"client">; name: z__default.ZodString; }, z__default.core.$strip>], "type">; }, z__default.core.$strip>; edited: z__default.ZodDefault; reason: z__default.ZodString; dataBefore: z__default.ZodAny; dataAfter: z__default.ZodAny; }, z__default.core.$strip>>, z__default.ZodLiteral]>>; dropped: z__default.ZodPrefault; reason: z__default.ZodString; }, z__default.core.$strip>, z__default.ZodLiteral]>>; contextChanges: z__default.ZodPrefault>>; }, z__default.core.$strip>; type PluginEventDataSchema = z__default.ZodObject | z__default.ZodDiscriminatedUnion; type PluginEventDefinition = { name: Name; dataSchema?: PluginEventDataSchema; }; type PluginEventsDefinition = { [K in keyof Names]: PluginEventDefinition; }; type PluginEvent = { [K in keyof EventsDef]: Omit, "created" | "edited" | "dropped" | "id" | "contextChanges"> : z__default.output, "data" | "name"> & { name: EventsDef[K]["name"]; } & (EventsDef[K]["dataSchema"] extends PluginEventDataSchema ? T extends "input" ? { data: z__default.input; } : { data: z__default.output; } : T extends "input" ? unknown : { data: null; }); }[number]; declare const internalEventsDef: [{ readonly name: "plugin.start"; readonly dataSchema: z__default.ZodObject<{ isRestart: z__default.ZodPrefault; restartCount: z__default.ZodPrefault; }, z__default.core.$strip>; }, { readonly name: "plugin.stop"; }, { readonly name: "plugin.test"; }, { readonly name: "plugin.error"; readonly dataSchema: z__default.ZodObject<{ error: z__default.ZodCustom; event: z__default.ZodObject<{ id: z__default.ZodString; name: z__default.ZodString; urgent: z__default.ZodPrefault; data: z__default.ZodPrefault; created: z__default.ZodObject<{ at: z__default.ZodNumber; by: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{ type: z__default.ZodLiteral<"handler">; plugin: z__default.ZodString; handler: z__default.ZodString; event: z__default.ZodString; }, z__default.core.$strip>, z__default.ZodObject<{ type: z__default.ZodLiteral<"server">; name: z__default.ZodString; }, z__default.core.$strip>, z__default.ZodObject<{ type: z__default.ZodLiteral<"client">; name: z__default.ZodString; }, z__default.core.$strip>], "type">; }, z__default.core.$strip>; edited: z__default.ZodDefault; reason: z__default.ZodString; dataBefore: z__default.ZodAny; dataAfter: z__default.ZodAny; }, z__default.core.$strip>>, z__default.ZodLiteral]>>; dropped: z__default.ZodPrefault; reason: z__default.ZodString; }, z__default.core.$strip>, z__default.ZodLiteral]>>; contextChanges: z__default.ZodPrefault>>; }, z__default.core.$strip>; }, z__default.core.$strip>; }]; type PluginHandlerBlockFunction> = (params: { event: PluginEvent; state: PluginHandlerState; plugin: ToPublic>; agent: ToPublic; dependencies: ToPublic>; telemetry: TelemetrySpanHandle; }) => MaybePromise; type PluginHandlerStreamFunction> = (params: { event: PluginEvent; state: PluginHandlerState; plugin: ToPublic>; agent: ToPublic; dependencies: ToPublic>; telemetry: TelemetrySpanHandle; }) => MaybePromise; type PluginHandlerInterceptFunction> = (params: { event: PluginEvent; state: PluginHandlerState; next: (data: PluginEvent["data"], reason: string) => void; drop: (reason: string) => void; plugin: ToPublic>; dependency: ToPublic>; agent: ToPublic; telemetry: TelemetrySpanHandle; }) => MaybePromise; type PluginHandlerStateDefinition = Record | ((params: { config: PluginConfig; }) => Record); type PluginHandlerState> = StateDef extends (p: infer _) => Record ? ReturnType : StateDef; type PluginHandlerDefinition = Record> = { name: Name; state?: PluginHandlerStateDefinition; } & ({ mode: "block"; onEvent: PluginHandlerBlockFunction; } | { mode: "stream"; onEvent: PluginHandlerStreamFunction; } | { mode: "intercept"; onEvent: PluginHandlerInterceptFunction; }); type ExtractPluginContext = PluginContext; type PluginAccessor = (Source["type"] extends "client" ? unknown : { config: PluginConfig; }) & { context: { get(): OperationResult>; /** Subscribe to changes in the context. Returns a function to unsubscribe. */ onChange(selector: (context: ExtractPluginContext) => unknown, callback: (newContext: ExtractPluginContext, oldContext: ExtractPluginContext) => void): OperationResult<() => void>; } & (HandlerAccess extends "write" ? { /** Set a value in the context. */ set(valueOrUpdater: ExtractPluginContext | ((ctx: ExtractPluginContext) => ExtractPluginContext)): OperationResult; } : unknown); events: { emit: (event: Exclude, { name: (typeof internalEventsDef)[number]["name"]; }>) => Source["type"] extends "client" ? Promise> : OperationResult; /** * Wait for the return type of a specific handler when processing a given event. * Note that the intercept handlers don't return a result, and so are not supported by this method. * @param eventId * @param handlerName * @returns */ waitForProcessing: (eventId: string) => Promise>; waitForResult: ["name"]>(eventId: string, handlerName: HandlerName) => Promise["onEvent"]>>>; } & (Source["type"] extends "handler" ? unknown : { on: >(selector: Selector, callback: (event: PluginEventsSelection) => MaybePromise, includeDropped?: boolean) => OperationResult<() => void>; once: >(selector: Selector, callback: (event: PluginEventsSelection) => MaybePromise, includeDropped?: boolean) => OperationResult<() => void>; }); }; type PluginDependenciesAccessor = { [DependencyDef in DependenciesDef[number] as DependencyDef["name"]]: PluginAccessor; }; type PluginEventsSelector = "*" | EventsDef[number]["name"] | EventsDef[number]["name"][] | { include: EventsDef[number]["name"][] | "*"; exclude?: EventsDef[number]["name"][]; }; type PluginEventsSelection> = Selector extends "*" ? PluginEvent : Selector extends string ? Extract, { name: Selector; }> : Selector extends (infer S)[] ? S extends EventsDef[number]["name"] ? Extract, { name: S; }> : never : Selector extends { include: infer I; exclude?: infer E; } ? I extends "*" ? E extends string[] ? Extract, { name: Exclude; }> : PluginEvent : I extends string[] ? E extends string[] ? Extract, { name: Exclude; }> : Extract, { name: I[number]; }> : never : never; interface PluginDefinition { name: string; dependencies: PluginDependenciesDefinition; config: PluginConfigDefinition; context: PluginContextDefinition; events: PluginEventsDefinition; handlers: PluginHandlerDefinition[]; } type TypedPluginBuilder = Omit, Excluded>; type FilterHandlersByName = Handlers extends [{ name: infer N; }, ...infer Rest extends { name: string; }[]] ? N extends Name ? FilterHandlersByName : [Handlers[0], ...FilterHandlersByName] : []; type PluginEventsListener = { id: string; selector: PluginEventsSelector; callback: ((event: Any) => MaybePromise) | "remote"; includeDropped: boolean; }; type PluginContextListener = { id: string; selector: (context: Any) => Any; callback: (newContext: Any, oldContext: Any) => MaybePromise; }; export { type AgentDefinition as A, type ClassShape as C, type LifeErrorUnion as L, type MemoryDefinition as M, type OperationResult as O, type PluginEventsDefinition as P, type StoreDefinition as S, type ToPublic as T, type Without as W, type Any as a, type PluginEvent as b, type Message as c, type TypedPluginBuilder as d, defineAgent as e, defineMemory as f, defineStore as g, definePlugin as h, type PluginConfig as i, type PluginDefinition as j, TelemetryClient as k, TransportClientBase as l, type AgentScope as m, type ToMethodName as n, type Override as o, type Opaque as p, type PluginConfigDefinition as q, type AssertPublic as r, type PluginAccessor as s };