hashbrown

createChatRuntime

Creates a text chat runtime with optional shared agent state.

API

export declare function createChatRuntime<
  Tools extends  Chat.AnyTool ,
  State = unknown,
>(init: {
  debugName?: string;
  system: string;
  state?: State;
  messages?:  Chat.Message <string, Tools>[];
  tools?: Tools[];
  debounce?: number;
  retries?: number;
  transport?:  TransportOrFactory ;
  ui?: boolean;
  threadId?: string;
}):  ChatRuntime <string, Tools, State>;
createChatRuntime
ChatRuntime<string, Tools, State>
@paraminit:
{
    debugName?: string;
    system: string;
    state?: State;
    messages?: Chat.Message<string, Tools>[];
    tools?: Tools[];
    debounce?: number;
    retries?: number;
    transport?: TransportOrFactory;
    ui?: boolean;
    threadId?: string;
}

Runtime options. Initial state is JSON-validated, cloned, and frozen before the runtime is created.

@typeTools
Chat.AnyTool
@typeState
@returns
ChatRuntime<string, Tools, State>

API

export declare function createChatRuntime<
  Schema extends  s.SchemaOutput ,
  Tools extends  Chat.AnyTool ,
  Output extends  s.InferSchemaOutput <Schema> =
     s.InferSchemaOutput <Schema>,
  State = unknown,
>(init: {
  debugName?: string;
  system: string;
  state?: State;
  messages?:  Chat.Message <Output, Tools>[];
  tools?: Tools[];
  responseSchema: Schema;
  debounce?: number;
  retries?: number;
  transport?:  TransportOrFactory ;
  ui?: boolean;
  threadId?: string;
}):  ChatRuntime <Output, Tools, State>;
createChatRuntime
ChatRuntime<Output, Tools, State>
@paraminit:
{
    debugName?: string;
    system: string;
    state?: State;
    messages?: Chat.Message<Output, Tools>[];
    tools?: Tools[];
    responseSchema: Schema;
    debounce?: number;
    retries?: number;
    transport?: TransportOrFactory;
    ui?: boolean;
    threadId?: string;
}

Runtime options including the response schema. Initial state is JSON-validated, cloned, and frozen before creation.

@typeSchema
s.SchemaOutput
@typeTools
Chat.AnyTool
@typeOutput
s.InferSchemaOutput<Schema>
@typeState
@returns
ChatRuntime<Output, Tools, State>