dd04edb420
Three-layer architecture built on @push.rocks/smartagent: - ts/ — ChatSession wrapping runAgent() with conversation state management - ts_cli/ — ink-based terminal chat TUI (React.createElement, no JSX) - ts_web/ — Lit web components (smartchat-window, smartchat-message, smartchat-input)
35 lines
962 B
TypeScript
35 lines
962 B
TypeScript
import { React, h, render } from './plugins.js';
|
|
import type { LanguageModelV3, ToolSet } from './plugins.js';
|
|
import { ChatApp } from './components.chatapp.js';
|
|
|
|
export interface IStartChatOptions {
|
|
/** The language model to use */
|
|
model: LanguageModelV3;
|
|
/** System prompt for the agent */
|
|
system?: string;
|
|
/** Tools available to the agent */
|
|
tools?: ToolSet;
|
|
/** Maximum agentic steps per turn */
|
|
maxSteps?: number;
|
|
/** Display name for the model (shown in header/status) */
|
|
modelName?: string;
|
|
}
|
|
|
|
/**
|
|
* Start an interactive chat TUI in the terminal.
|
|
* Returns a promise that resolves when the user exits.
|
|
*/
|
|
export async function startChat(options: IStartChatOptions): Promise<void> {
|
|
const instance = render(
|
|
h(ChatApp, {
|
|
model: options.model,
|
|
system: options.system,
|
|
tools: options.tools,
|
|
maxSteps: options.maxSteps,
|
|
modelName: options.modelName,
|
|
}),
|
|
);
|
|
|
|
await instance.waitUntilExit();
|
|
}
|