life
Version:
Life.js is the first fullstack framework to build agentic web applications. It is minimal, extensible, and typesafe. Well, everything you love.
1,204 lines (1,175 loc) • 174 kB
TypeScript
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 extends LifeErrorCode> = {
code: Code;
message?: string;
attributes?: LifeErrorAttributes;
retryAfterMs?: number;
isPublic?: boolean;
cause?: unknown;
};
type LifeErrorAttributes = Record<string, SerializableValue>;
/**
* @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<LifeErrorCode>);
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<Code extends LifeErrorCode = LifeErrorCode> = LifeErrorClass & {
code: Code;
};
/**
* Union of all LifeError types.
*/
type LifeErrorUnion<Code extends LifeErrorCode = LifeErrorCode> = Code extends LifeErrorCode ? LifeError<Code> : never;
/**
* Avoids repeating the same type signature for functions that can return a promise or not.
*/
type MaybePromise<T> = T | Promise<T>;
type ClassShape = {
prototype: object;
new (...arguments_: any[]): any;
};
type Prettify<T> = {
[K in keyof T]: T[K];
} & {};
type Any = any;
type IsAny<T> = 0 extends 1 & T ? true : false;
type IsNever<T> = [T] extends [never] ? true : false;
type IsFunction<T> = T extends (...args: Any) => Any ? true : false;
type IsInstance<T> = IsAny<T> extends true ? false : IsNever<T> extends true ? false : IsFunction<T> extends true ? false : T extends object ? true : false;
type IsClass<T> = T extends ClassShape ? (ClassShape extends T ? true : false) : false;
/**
* Override a property type in an object without creating nested type aliases.
*
* Unlike `Omit<T, K> & { [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<User, "age", string>; // { name: string; age: string }
*/
type Override<T extends object, K extends keyof T, V> = 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<T, K>` 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<User, "email">; // { name: string; age: number }
*/
type Without<T extends object, K extends keyof T> = Prettify<{
[I in keyof T as I extends K ? never : I]: T[I];
}>;
declare const __opaque: unique symbol;
type Opaque<T> = 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<D extends OperationData> = readonly [error: undefined, data: D];
type OperationFailure<_ extends OperationData = never> = readonly [
error: LifeErrorUnion,
data: undefined
];
type OperationResult<D extends OperationData> = OperationSuccess<D> | OperationFailure<D>;
type VoidIfNever<T> = [T] extends [never] ? void : T;
type IsOpFunction<T> = T extends (...args: Any) => MaybePromise<OperationResult<Any>> ? true : false;
type IsOpInstance<T> = {
[K in keyof T]: IsFunction<T[K]> extends true ? IsOpFunction<T[K]> : 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> = T & {
[__public]: [T];
};
declare const __public: unique symbol;
type IsAsserted<T> = T extends {
[__public]: Any;
} ? true : false;
type UnwrapAssert<T> = T extends {
[__public]: [infer U];
} ? U : never;
type FunctionToPublic<T> = T extends (...args: infer Args) => MaybePromise<OperationResult<infer Data>> ? Opaque<(...args: Args) => VoidIfNever<Data>> : T;
type InstanceToPublic<T> = IsInstance<T> extends true ? Prettify<{
[K in keyof T]: ToPublic<T[K]>;
} & (IsOpInstance<T> extends true ? Opaque<{
safe: {
[K in keyof T as IsOpFunction<T[K]> extends true ? K : never]: T[K];
};
}> : unknown)> : T;
type ClassToPublic<T> = IsClass<T> extends true ? Opaque<new (...args: Any) => InstanceToPublic<InstanceType<T extends ClassShape ? T : never>>> : T;
type ToPublic<T> = IsAsserted<T> extends true ? UnwrapAssert<T> : T extends z__default.ZodType ? T : IsClass<T> extends true ? ClassToPublic<T> : IsFunction<T> extends true ? FunctionToPublic<T> : IsInstance<T> extends true ? InstanceToPublic<T> : T;
declare const serializablePrimitivesSchema: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodNumber, z$1.ZodBoolean, z$1.ZodNull, z$1.ZodUndefined, z$1.ZodBigInt, z$1.ZodDate, z$1.ZodCustom<RegExp, RegExp>, z$1.ZodCustom<Error, Error>, z$1.ZodCustom<URL, URL>, z$1.ZodCustom<ArrayBuffer, ArrayBuffer>, z$1.ZodCustom<Int8Array<ArrayBuffer>, Int8Array<ArrayBuffer>>, z$1.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z$1.ZodCustom<Uint8ClampedArray<ArrayBuffer>, Uint8ClampedArray<ArrayBuffer>>, z$1.ZodCustom<Int16Array<ArrayBuffer>, Int16Array<ArrayBuffer>>, z$1.ZodCustom<Uint16Array<ArrayBuffer>, Uint16Array<ArrayBuffer>>, z$1.ZodCustom<Int32Array<ArrayBuffer>, Int32Array<ArrayBuffer>>, z$1.ZodCustom<Uint32Array<ArrayBuffer>, Uint32Array<ArrayBuffer>>, z$1.ZodCustom<Float32Array<ArrayBuffer>, Float32Array<ArrayBuffer>>, z$1.ZodCustom<Float64Array<ArrayBuffer>, Float64Array<ArrayBuffer>>, z$1.ZodCustom<BigInt64Array<ArrayBuffer>, BigInt64Array<ArrayBuffer>>, z$1.ZodCustom<BigUint64Array<ArrayBuffer>, BigUint64Array<ArrayBuffer>>]>;
type SerializablePrimitives = z$1.infer<typeof serializablePrimitivesSchema>;
type SerializableValue = SerializablePrimitives | SerializableValue[] | readonly SerializableValue[] | [SerializableValue, ...SerializableValue[]] | readonly [SerializableValue, ...SerializableValue[]] | Set<SerializableValue> | Map<SerializableValue, SerializableValue> | {
[key: string]: SerializableValue;
};
declare const storeConfigSchema: z$1.ZodUnion<readonly [z$1.ZodObject<{
schema: z$1.ZodCustom<z$1.ZodArray<z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>> | z$1.ZodRecord<z$1.ZodString, z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>>, z$1.ZodArray<z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>> | z$1.ZodRecord<z$1.ZodString, z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>>>;
type: z$1.ZodLiteral<"controlled">;
ttl: z$1.ZodOptional<z$1.ZodNumber>;
}, z$1.core.$strip>, z$1.ZodObject<{
schema: z$1.ZodCustom<z$1.ZodArray<z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>> | z$1.ZodRecord<z$1.ZodString, z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>>, z$1.ZodArray<z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>> | z$1.ZodRecord<z$1.ZodString, z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>>>;
type: z$1.ZodLiteral<"freeform">;
}, z$1.core.$strip>]>;
type StoreConfig<T extends "input" | "output"> = T extends "input" ? z$1.input<typeof storeConfigSchema> : z$1.output<typeof storeConfigSchema>;
type StoreRetrieve<Config extends StoreConfig<"output">> = () => z$1.infer<Config["schema"]> | Promise<z$1.infer<Config["schema"]>>;
interface StoreDefinition {
name: string;
config: StoreConfig<"output">;
retrieve?: () => unknown | Promise<unknown>;
}
declare class StoreDefinitionBuilder<const Definition extends StoreDefinition, Excluded extends string = never> {
_definition: Definition;
constructor(def: Definition);
config<Config extends StoreConfig<"input">>(config: Config): Omit<StoreDefinitionBuilder<Definition & {
config: Config;
}, "config" | Excluded | (Config["type"] extends "controlled" ? never : "retrieve")>, "config" | Excluded | (Config["type"] extends "controlled" ? never : "retrieve")>;
retrieve(retrieve: StoreRetrieve<Definition["config"]>): Omit<StoreDefinitionBuilder<Definition & {
retrieve: StoreRetrieve<Definition["config"]>;
}, Excluded | "retrieve">, Excluded | "retrieve">;
}
declare function defineStore<const Name extends string>(name: Name): StoreDefinitionBuilder<{
readonly name: Name;
readonly config: {
schema: z$1.ZodArray<z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>> | z$1.ZodRecord<z$1.ZodString, z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>>;
type: "controlled";
ttl?: number | undefined;
} | {
schema: z$1.ZodArray<z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>> | z$1.ZodRecord<z$1.ZodString, z$1.ZodType<SerializableValue, unknown, z$1.core.$ZodTypeInternals<SerializableValue, unknown>>>;
type: "freeform";
};
}, never>;
declare const agentToolRequestSchema: z$1.ZodObject<{
toolRequestId: z$1.ZodString;
toolName: z$1.ZodString;
toolInput: z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>;
}, z$1.core.$strip>;
type AgentToolRequest = z$1.output<typeof agentToolRequestSchema>;
declare const messageSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
role: z$1.ZodLiteral<"user">;
content: z$1.ZodPrefault<z$1.ZodString>;
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<z$1.ZodString>;
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<z$1.ZodString>;
toolsRequests: z$1.ZodPrefault<z$1.ZodArray<z$1.ZodObject<{
toolRequestId: z$1.ZodString;
toolName: z$1.ZodString;
toolInput: z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>;
}, 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<z$1.ZodRecord<z$1.ZodString, z$1.ZodAny>>;
toolError: z$1.ZodOptional<z$1.ZodString>;
id: z$1.ZodString;
createdAt: z$1.ZodNumber;
lastUpdated: z$1.ZodNumber;
}, z$1.core.$strip>], "role">;
type Message = z$1.output<typeof messageSchema>;
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.ZodEnum<{
blocking: "blocking";
"non-blocking": "non-blocking";
}>>;
}, z$1.core.$strip>;
type MemoryConfig<T extends "input" | "output"> = T extends "input" ? z$1.input<typeof memoryConfigSchema> : z$1.output<typeof memoryConfigSchema>;
interface MemoryDefinition {
name: string;
config: MemoryConfig<"output">;
output?: Message[] | ((params: {
messages: Message[];
}) => Message[] | Promise<Message[]>);
onHistoryChange?: (params: {
messages: Message[];
}) => void;
dependencies: MemoryDependenciesDefinition;
}
declare class MemoryDefinitionBuilder<const Definition extends MemoryDefinition, Excluded extends string = never> {
_definition: Definition;
constructor(def: Definition);
dependencies<Dependencies extends MemoryDependenciesDefinition>(dependencies: Dependencies): Omit<MemoryDefinitionBuilder<Definition & {
dependencies: Dependencies;
}, "dependencies" | Excluded>, "dependencies" | Excluded>;
config(config: MemoryConfig<"input">): Omit<MemoryDefinitionBuilder<Definition & {
config: {
behavior: "blocking" | "non-blocking";
};
}, "config" | Excluded>, "config" | Excluded>;
output(params: Message[] | ((params: {
messages: Message[];
}) => Message[] | Promise<Message[]>)): Omit<MemoryDefinitionBuilder<Definition & {
output: typeof params;
}, "output" | Excluded>, "output" | Excluded>;
onHistoryChange(params: (params: {
messages: Message[];
}) => void): Omit<MemoryDefinitionBuilder<Definition & {
onHistoryChange: typeof params;
}, Excluded | "onHistoryChange">, Excluded | "onHistoryChange">;
}
declare function defineMemory<const Name extends string>(name: Name): MemoryDefinitionBuilder<{
readonly name: Name;
readonly config: {
behavior: "blocking" | "non-blocking";
};
readonly dependencies: {
readonly stores: [];
readonly collections: [];
};
}, never>;
declare abstract class EOUBase<ConfigSchema extends z$1.ZodObject> {
protected config: z$1.infer<ConfigSchema>;
constructor(configSchema: ConfigSchema, config: Partial<z$1.infer<ConfigSchema>>);
abstract predict(messages: Message[]): Promise<number> | number;
}
declare const livekitEOUConfig: ZodObjectWithTelemetry<z$1.ZodObject<{
provider: z$1.ZodLiteral<"livekit">;
quantized: z$1.ZodPrefault<z$1.ZodBoolean>;
maxMessages: z$1.ZodPrefault<z$1.ZodNumber>;
maxTokens: z$1.ZodPrefault<z$1.ZodNumber>;
}, z$1.core.$strip>, "output">;
declare class LivekitEOU extends EOUBase<typeof livekitEOUConfig.schema> {
#private;
constructor(config: z$1.input<typeof livekitEOUConfig.schema>);
predict(messages: Message[]): Promise<number>;
}
declare const turnSenseEOUConfig: ZodObjectWithTelemetry<z$1.ZodObject<{
provider: z$1.ZodLiteral<"turnsense">;
quantized: z$1.ZodPrefault<z$1.ZodBoolean>;
maxMessages: z$1.ZodPrefault<z$1.ZodNumber>;
}, z$1.core.$strip>, "output">;
declare class TurnSenseEOU extends EOUBase<typeof turnSenseEOUConfig.schema> {
#private;
constructor(config: z$1.input<typeof turnSenseEOUConfig.schema>);
predict(messages: Message[]): Promise<number>;
}
declare const eouProviders: {
readonly turnsense: {
readonly class: typeof TurnSenseEOU;
readonly configSchema: z.ZodObject<{
provider: z.ZodLiteral<"turnsense">;
quantized: z.ZodPrefault<z.ZodBoolean>;
maxMessages: z.ZodPrefault<z.ZodNumber>;
}, zod_v4_core.$strip>;
};
readonly livekit: {
readonly class: typeof LivekitEOU;
readonly configSchema: z.ZodObject<{
provider: z.ZodLiteral<"livekit">;
quantized: z.ZodPrefault<z.ZodBoolean>;
maxMessages: z.ZodPrefault<z.ZodNumber>;
maxTokens: z.ZodPrefault<z.ZodNumber>;
}, 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<z__default.core.$ZodLooseShape, z__default.core.$strip>, z__default.ZodObject<z__default.core.$ZodLooseShape, z__default.core.$strip>>;
output: z__default.ZodCustom<z__default.ZodObject<z__default.core.$ZodLooseShape, z__default.core.$strip>, z__default.ZodObject<z__default.core.$ZodLooseShape, z__default.core.$strip>>;
}, z__default.core.$strip>;
run: z__default.ZodFunction<z__default.ZodTuple<readonly [z__default.ZodRecord<z__default.ZodString, z__default.ZodAny>], null>, z__default.ZodUnion<readonly [z__default.ZodObject<{
success: z__default.ZodBoolean;
output: z__default.ZodOptional<z__default.ZodRecord<z__default.ZodString, z__default.ZodAny>>;
error: z__default.ZodOptional<z__default.ZodString>;
}, z__default.core.$strip>, z__default.ZodPromise<z__default.ZodObject<{
success: z__default.ZodBoolean;
output: z__default.ZodOptional<z__default.ZodRecord<z__default.ZodString, z__default.ZodAny>>;
error: z__default.ZodOptional<z__default.ZodString>;
}, z__default.core.$strip>>]>>;
}, z__default.core.$strip>;
/**
* Represents a tool definition for an LLM.
*/
type LLMToolDefinition = z__default.infer<typeof llmToolSchema>;
type LLMGenerateMessageChunk = {
type: "content";
content: string;
} | {
type: "tools";
tools: AgentToolRequest[];
} | {
type: "end";
} | {
type: "error";
error: string;
};
interface LLMGenerateMessageJob {
id: string;
cancel: () => void;
stream: AsyncQueue<LLMGenerateMessageChunk>;
_abortController: AbortController;
}
type LLMGenerateObjectChunk<T extends z$1.ZodObject> = {
type: "content";
data: z$1.infer<T>;
} | {
type: "error";
error: string;
};
/**
* Base class for all LLMs providers.
*/
declare abstract class LLMBase<ConfigSchema extends z$1.ZodObject> {
config: z$1.infer<ConfigSchema>;
constructor(configSchema: ConfigSchema, config: Partial<z$1.infer<ConfigSchema>>);
protected createGenerateMessageJob(): LLMGenerateMessageJob;
abstract generateMessage(params: {
messages: Message[];
tools: LLMToolDefinition[];
}): Promise<LLMGenerateMessageJob>;
abstract generateObject<T extends z$1.ZodObject>(params: {
messages: Message[];
schema: T;
}): Promise<LLMGenerateObjectChunk<T>>;
}
declare const mistralLLMConfig: ZodObjectWithTelemetry<z$1.ZodObject<{
provider: z$1.ZodLiteral<"mistral">;
apiKey: z$1.ZodPrefault<z$1.ZodString>;
model: z$1.ZodPrefault<z$1.ZodEnum<{
"mistral-large-latest": "mistral-large-latest";
"mistral-large-2411": "mistral-large-2411";
"mistral-large-2407": "mistral-large-2407";
"mistral-small-latest": "mistral-small-latest";
"mistral-small-2501": "mistral-small-2501";
"mistral-small-2503": "mistral-small-2503";
"mistral-medium-latest": "mistral-medium-latest";
"mistral-medium-2505": "mistral-medium-2505";
"pixtral-large-latest": "pixtral-large-latest";
"pixtral-large-2411": "pixtral-large-2411";
"codestral-latest": "codestral-latest";
"codestral-2501": "codestral-2501";
"codestral-2405": "codestral-2405";
"ministral-3b-latest": "ministral-3b-latest";
"ministral-8b-latest": "ministral-8b-latest";
"open-mistral-7b": "open-mistral-7b";
"open-mixtral-8x7b": "open-mixtral-8x7b";
"open-mixtral-8x22b": "open-mixtral-8x22b";
}>>;
temperature: z$1.ZodPrefault<z$1.ZodNumber>;
}, z$1.core.$strip>, "output">;
declare class MistralLLM extends LLMBase<typeof mistralLLMConfig.schema> {
#private;
constructor(config: z$1.input<typeof mistralLLMConfig.schema>);
/**
* Generate a message with job management - returns jobId along with stream
*/
generateMessage(params: Parameters<typeof LLMBase.prototype.generateMessage>[0]): Promise<LLMGenerateMessageJob>;
generateObject<T extends z$1.ZodObject>(params: {
messages: Message[];
schema: T;
}): Promise<LLMGenerateObjectChunk<T>>;
}
declare const openAILLMConfig: ZodObjectWithTelemetry<z$1.ZodObject<{
provider: z$1.ZodLiteral<"openai">;
apiKey: z$1.ZodPrefault<z$1.ZodString>;
model: z$1.ZodPrefault<z$1.ZodEnum<{
"gpt-4o-mini": "gpt-4o-mini";
"gpt-4o": "gpt-4o";
"gpt-5": "gpt-5";
"gpt-5-nano": "gpt-5-nano";
}>>;
temperature: z$1.ZodPrefault<z$1.ZodNumber>;
}, z$1.core.$strip>, "output">;
declare class OpenAILLM extends LLMBase<typeof openAILLMConfig.schema> {
#private;
constructor(config: z$1.input<typeof openAILLMConfig.schema>);
/**
* Generate a message with job management - returns jobId along with stream
*/
generateMessage(params: Parameters<typeof LLMBase.prototype.generateMessage>[0]): Promise<LLMGenerateMessageJob>;
generateObject<T extends z$1.ZodObject>(params: {
messages: Message[];
schema: T;
}): Promise<LLMGenerateObjectChunk<T>>;
}
declare const xaiLLMConfig: ZodObjectWithTelemetry<z$1.ZodObject<{
provider: z$1.ZodLiteral<"xai">;
apiKey: z$1.ZodPrefault<z$1.ZodString>;
model: z$1.ZodPrefault<z$1.ZodEnum<{
"grok-3": "grok-3";
"grok-3-fast": "grok-3-fast";
"grok-3-mini": "grok-3-mini";
"grok-3-mini-fast": "grok-3-mini-fast";
"grok-2-1212": "grok-2-1212";
"grok-2-vision-1212": "grok-2-vision-1212";
"grok-beta": "grok-beta";
"grok-vision-beta": "grok-vision-beta";
}>>;
temperature: z$1.ZodPrefault<z$1.ZodNumber>;
}, z$1.core.$strip>, "output">;
declare class XaiLLM extends LLMBase<typeof xaiLLMConfig.schema> {
#private;
constructor(config: z$1.input<typeof xaiLLMConfig.schema>);
/**
* Generate a message with job management - returns jobId along with stream
*/
generateMessage(params: Parameters<typeof LLMBase.prototype.generateMessage>[0]): Promise<LLMGenerateMessageJob>;
generateObject<T extends z$1.ZodObject>(params: {
messages: Message[];
schema: T;
}): Promise<LLMGenerateObjectChunk<T>>;
}
declare const llmProviders: {
readonly mistral: {
readonly class: typeof MistralLLM;
readonly configSchema: ZodObjectWithTelemetry<z.ZodObject<{
provider: z.ZodLiteral<"mistral">;
apiKey: z.ZodPrefault<z.ZodString>;
model: z.ZodPrefault<z.ZodEnum<{
"mistral-large-latest": "mistral-large-latest";
"mistral-large-2411": "mistral-large-2411";
"mistral-large-2407": "mistral-large-2407";
"mistral-small-latest": "mistral-small-latest";
"mistral-small-2501": "mistral-small-2501";
"mistral-small-2503": "mistral-small-2503";
"mistral-medium-latest": "mistral-medium-latest";
"mistral-medium-2505": "mistral-medium-2505";
"pixtral-large-latest": "pixtral-large-latest";
"pixtral-large-2411": "pixtral-large-2411";
"codestral-latest": "codestral-latest";
"codestral-2501": "codestral-2501";
"codestral-2405": "codestral-2405";
"ministral-3b-latest": "ministral-3b-latest";
"ministral-8b-latest": "ministral-8b-latest";
"open-mistral-7b": "open-mistral-7b";
"open-mixtral-8x7b": "open-mixtral-8x7b";
"open-mixtral-8x22b": "open-mixtral-8x22b";
}>>;
temperature: z.ZodPrefault<z.ZodNumber>;
}, zod_v4_core.$strip>, "output">;
};
readonly openai: {
readonly class: typeof OpenAILLM;
readonly configSchema: ZodObjectWithTelemetry<z.ZodObject<{
provider: z.ZodLiteral<"openai">;
apiKey: z.ZodPrefault<z.ZodString>;
model: z.ZodPrefault<z.ZodEnum<{
"gpt-4o-mini": "gpt-4o-mini";
"gpt-4o": "gpt-4o";
"gpt-5": "gpt-5";
"gpt-5-nano": "gpt-5-nano";
}>>;
temperature: z.ZodPrefault<z.ZodNumber>;
}, zod_v4_core.$strip>, "output">;
};
readonly xai: {
readonly class: typeof XaiLLM;
readonly configSchema: ZodObjectWithTelemetry<z.ZodObject<{
provider: z.ZodLiteral<"xai">;
apiKey: z.ZodPrefault<z.ZodString>;
model: z.ZodPrefault<z.ZodEnum<{
"grok-3": "grok-3";
"grok-3-fast": "grok-3-fast";
"grok-3-mini": "grok-3-mini";
"grok-3-mini-fast": "grok-3-mini-fast";
"grok-2-1212": "grok-2-1212";
"grok-2-vision-1212": "grok-2-vision-1212";
"grok-beta": "grok-beta";
"grok-vision-beta": "grok-vision-beta";
}>>;
temperature: z.ZodPrefault<z.ZodNumber>;
}, 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<STTChunk>;
cancel: () => void;
inputVoice: (chunk: Int16Array) => void;
_abortController: AbortController;
};
/**
* Base class for all STT providers.
*/
declare abstract class STTBase<ConfigSchema extends z$1.ZodObject> {
protected config: z$1.infer<ConfigSchema>;
constructor(configSchema: ConfigSchema, config: Partial<z$1.infer<ConfigSchema>>);
protected createGenerateJob(): STTJob;
abstract generate(): Promise<STTJob>;
protected abstract onVoiceInput(job: STTJob, pcm: Int16Array): Promise<void>;
}
declare const deepgramSTTConfig: ZodObjectWithTelemetry<z$1.ZodObject<{
provider: z$1.ZodLiteral<"deepgram">;
apiKey: z$1.ZodPrefault<z$1.ZodString>;
model: z$1.ZodPrefault<z$1.ZodEnum<{
"nova-3": "nova-3";
"nova-2": "nova-2";
"nova-2-general": "nova-2-general";
"nova-2-meeting": "nova-2-meeting";
"nova-2-phonecall": "nova-2-phonecall";
"nova-2-voicemail": "nova-2-voicemail";
"nova-2-finance": "nova-2-finance";
"nova-2-conversationalai": "nova-2-conversationalai";
"nova-2-video": "nova-2-video";
"nova-2-medical": "nova-2-medical";
"nova-2-drivethru": "nova-2-drivethru";
"nova-2-automotive": "nova-2-automotive";
"nova-2-atc": "nova-2-atc";
nova: "nova";
"nova-general": "nova-general";
"nova-phonecall": "nova-phonecall";
enhanced: "enhanced";
"enhanced-general": "enhanced-general";
"enhanced-meeting": "enhanced-meeting";
"enhanced-phonecall": "enhanced-phonecall";
"enhanced-finance": "enhanced-finance";
base: "base";
"base-general": "base-general";
"base-meeting": "base-meeting";
"base-phonecall": "base-phonecall";
"base-voicemail": "base-voicemail";
"base-finance": "base-finance";
"base-conversationalai": "base-conversationalai";
"base-video": "base-video";
"whisper-tiny": "whisper-tiny";
"whisper-base": "whisper-base";
"whisper-small": "whisper-small";
"whisper-medium": "whisper-medium";
"whisper-large": "whisper-large";
}>>;
language: z$1.ZodPrefault<z$1.ZodString>;
}, z$1.core.$strip>, "output">;
declare class DeepgramSTT extends STTBase<typeof deepgramSTTConfig.schema> {
#private;
constructor(config: z$1.input<typeof deepgramSTTConfig.schema>);
generate(): Promise<STTJob>;
protected onVoiceInput(job: STTJob, pcm: Int16Array): Promise<void>;
}
declare const sttProviders: {
readonly deepgram: {
readonly class: typeof DeepgramSTT;
readonly configSchema: ZodObjectWithTelemetry<z.ZodObject<{
provider: z.ZodLiteral<"deepgram">;
apiKey: z.ZodPrefault<z.ZodString>;
model: z.ZodPrefault<z.ZodEnum<{
"nova-3": "nova-3";
"nova-2": "nova-2";
"nova-2-general": "nova-2-general";
"nova-2-meeting": "nova-2-meeting";
"nova-2-phonecall": "nova-2-phonecall";
"nova-2-voicemail": "nova-2-voicemail";
"nova-2-finance": "nova-2-finance";
"nova-2-conversationalai": "nova-2-conversationalai";
"nova-2-video": "nova-2-video";
"nova-2-medical": "nova-2-medical";
"nova-2-drivethru": "nova-2-drivethru";
"nova-2-automotive": "nova-2-automotive";
"nova-2-atc": "nova-2-atc";
nova: "nova";
"nova-general": "nova-general";
"nova-phonecall": "nova-phonecall";
enhanced: "enhanced";
"enhanced-general": "enhanced-general";
"enhanced-meeting": "enhanced-meeting";
"enhanced-phonecall": "enhanced-phonecall";
"enhanced-finance": "enhanced-finance";
base: "base";
"base-general": "base-general";
"base-meeting": "base-meeting";
"base-phonecall": "base-phonecall";
"base-voicemail": "base-voicemail";
"base-finance": "base-finance";
"base-conversationalai": "base-conversationalai";
"base-video": "base-video";
"whisper-tiny": "whisper-tiny";
"whisper-base": "whisper-base";
"whisper-small": "whisper-small";
"whisper-medium": "whisper-medium";
"whisper-large": "whisper-large";
}>>;
language: z.ZodPrefault<z.ZodString>;
}, 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<TTSChunk>;
cancel: () => void;
inputText: (text: string, isLast?: boolean) => Promise<void>;
_abortController: AbortController;
_receiveVoiceChunk: (chunk: TTSChunkInput) => Promise<void>;
}
/**
* Base class for all TTS providers.
*/
declare abstract class TTSBase<ConfigSchema extends z$1.ZodObject> {
#private;
config: z$1.infer<ConfigSchema>;
constructor(configSchema: ConfigSchema, config: Partial<z$1.infer<ConfigSchema>>);
protected createGenerateJob(): TTSJob;
abstract generate(): Promise<TTSJob>;
protected abstract onTextInput(job: TTSJob, text: string, isLast: boolean): Promise<void>;
}
declare const cartesiaTTSConfig: ZodObjectWithTelemetry<z$1.ZodObject<{
provider: z$1.ZodLiteral<"cartesia">;
apiKey: z$1.ZodPrefault<z$1.ZodString>;
model: z$1.ZodPrefault<z$1.ZodEnum<{
"sonic-2": "sonic-2";
"sonic-turbo": "sonic-turbo";
sonic: "sonic";
"sonic-3": "sonic-3";
}>>;
language: z$1.ZodPrefault<z$1.ZodEnum<{
pt: "pt";
en: "en";
fr: "fr";
de: "de";
es: "es";
zh: "zh";
ja: "ja";
hi: "hi";
it: "it";
ko: "ko";
nl: "nl";
pl: "pl";
ru: "ru";
sv: "sv";
tr: "tr";
}>>;
voiceId: z$1.ZodPrefault<z$1.ZodString>;
}, z$1.core.$strip>, "output">;
declare class CartesiaTTS extends TTSBase<typeof cartesiaTTSConfig.schema> {
#private;
constructor(config: z$1.input<typeof cartesiaTTSConfig.schema>);
generate(): Promise<TTSJob>;
protected onTextInput(job: TTSJob, text: string, isLast?: boolean): Promise<void>;
}
declare const ttsProviders: {
readonly cartesia: {
readonly class: typeof CartesiaTTS;
readonly configSchema: ZodObjectWithTelemetry<z.ZodObject<{
provider: z.ZodLiteral<"cartesia">;
apiKey: z.ZodPrefault<z.ZodString>;
model: z.ZodPrefault<z.ZodEnum<{
"sonic-2": "sonic-2";
"sonic-turbo": "sonic-turbo";
sonic: "sonic";
"sonic-3": "sonic-3";
}>>;
language: z.ZodPrefault<z.ZodEnum<{
pt: "pt";
en: "en";
fr: "fr";
de: "de";
es: "es";
zh: "zh";
ja: "ja";
hi: "hi";
it: "it";
ko: "ko";
nl: "nl";
pl: "pl";
ru: "ru";
sv: "sv";
tr: "tr";
}>>;
voiceId: z.ZodPrefault<z.ZodString>;
}, 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<VADChunk>;
inputVoice: (pcm: Int16Array) => void;
_abortController: AbortController;
};
declare abstract class VADBase<ConfigSchema extends z$1.ZodObject> {
protected config: z$1.infer<ConfigSchema>;
constructor(configSchema: ConfigSchema, config: Partial<z$1.infer<ConfigSchema>>);
protected createGenerateJob(): VADJob;
/**
* Create a new job to detect voice activity of an incomoing audio stream.
*/
abstract detect(): Promise<VADJob>;
protected abstract onVoiceInput(job: VADJob, pcm: Int16Array): Promise<void>;
}
declare const sileroVADConfig: ZodObjectWithTelemetry<z$1.ZodObject<{
provider: z$1.ZodLiteral<"silero">;
}, z$1.core.$strip>, "output">;
declare class SileroVAD extends VADBase<typeof sileroVADConfig.schema> {
#private;
constructor(config: z$1.input<typeof sileroVADConfig.schema>);
detect(): Promise<VADJob>;
protected onVoiceInput(job: VADJob, pcm: Int16Array): Promise<void>;
}
declare const vadProviders: {
readonly silero: {
readonly class: typeof SileroVAD;
readonly configSchema: ZodObjectWithTelemetry<z.ZodObject<{
provider: z.ZodLiteral<"silero">;
}, 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<void>;
/**
* 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<void>;
/**
* 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<T>(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<const PluginDef extends PluginDefinition> {
#private;
readonly def: PluginDef;
readonly agent: AgentServer;
readonly config: PluginConfig<PluginDef["config"], "output">;
context: PluginContext<PluginDef["context"], "output">;
readonly telemetry: TelemetryClient;
readonly queue: AsyncQueue<PluginEvent<PluginDef["events"], "output">>;
readonly eventsListeners: Map<string, PluginEventsListener>;
readonly contextListeners: Map<string, PluginContextListener>;
readonly streamHandlersQueues: AsyncQueue<PluginEvent<PluginDef["events"], "output">>[];
readonly externalInterceptHandlers: {
dependent: PluginServer<PluginDefinition>;
handler: PluginHandlerDefinition;
}[];
constructor({ agent, definition, config, context, }: {
agent: AgentServer;
definition: PluginDef;
config: PluginConfig<PluginDef["config"], "input">;
context: SerializableValue;
});
/**
* Produces an accessor object, exposing methods to interact safely with the plugin
* from a given source (plugin, handler, client).
*