UNPKG

life

Version:

Life.js is the first fullstack framework to build agentic web applications. It is minimal, extensible, and typesafe. Well, everything you love.

132 lines (126 loc) 3.84 kB
import { C as ClientBuild, f as AgentClientFromBuild, g as AgentClientParam, L as LifeClient } from '../create-COCmFmHD.js'; import { g as generationPluginClient } from '../client-CCd9dPl7.js'; import { FC, ReactNode } from 'react'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { T as ToPublic } from '../types-B6ejZKUB.js'; import 'zod'; import 'nanostores'; import 'LIFE_CLIENT_BUILD_PATH'; import '../config-n67P8tNt.js'; import 'zod/v4/core'; import 'type-fest'; interface UseAgentOptions { id?: string; } declare function useAgent<K extends keyof ClientBuild>(name: K, options?: UseAgentOptions): AgentClientFromBuild<K> | null; /** * ('generation' plugin) Reactively consume context.status. * * @param agent - AgentClient instance * @example * ```typescript * const status = useAgentStatus(agent); // { listening: boolean; thinking: boolean; speaking: boolean } | null * console.log(status); * console.log(status?.listening); * ``` */ declare const useAgentStatus: <Agent extends AgentClientParam<[typeof generationPluginClient]> | null>(agent: Agent) => { listening: boolean; thinking: boolean; speaking: boolean; } | null; declare const useAgentMessages: <Agent extends AgentClientParam<[typeof generationPluginClient]> | null>(agent: Agent) => ({ role: "user"; content: string; id: string; createdAt: number; lastUpdated: number; } | { role: "system"; content: string; id: string; createdAt: number; lastUpdated: number; } | { role: "agent"; content: string; toolsRequests: { toolRequestId: string; toolName: string; toolInput: Record<string, any>; }[]; id: string; createdAt: number; lastUpdated: number; } | { role: "tool"; toolRequestId: string; toolName: string; toolSuccess: boolean; id: string; createdAt: number; lastUpdated: number; toolOutput?: Record<string, any> | undefined; toolError?: string | undefined; })[]; interface RenderMarkdownComponents { parent: (args: { children: React.ReactNode; }) => React.ReactNode; heading: (args: { children: React.ReactNode; level: number; }) => React.ReactNode; paragraph: (args: { children: React.ReactNode; }) => React.ReactNode; bold: (args: { children: React.ReactNode; }) => React.ReactNode; italic: (args: { children: React.ReactNode; }) => React.ReactNode; strikethrough: (args: { children: React.ReactNode; }) => React.ReactNode; link: (args: { children: React.ReactNode; url: string; }) => React.ReactNode; image: (args: { children: React.ReactNode; url: string; alt?: string | null; }) => React.ReactNode; list: (args: { children: React.ReactNode; ordered: boolean; }) => React.ReactNode; listItem: (args: { children: React.ReactNode; }) => React.ReactNode; table: (args: { children: React.ReactNode; }) => React.ReactNode; tableRow: (args: { children: React.ReactNode; }) => React.ReactNode; tableCell: (args: { children: React.ReactNode; }) => React.ReactNode; } type MarkdownProps = { documentKey: string; children: string; components?: Partial<RenderMarkdownComponents>; throttleMs?: number; }; declare const Markdown: FC<MarkdownProps>; type PublicLifeClient = ToPublic<LifeClient>; interface LifeProviderProps { client: ToPublic<LifeClient>; children: ReactNode; } declare function LifeProvider({ client, children }: LifeProviderProps): react_jsx_runtime.JSX.Element; declare function useLifeClient(): PublicLifeClient; export { LifeProvider, Markdown, useAgent, useAgentMessages, useAgentStatus, useLifeClient };