feat(initial): scaffold @push.rocks/smartchat with core, CLI, and web layers
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)
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import type { LanguageModelV3, ModelMessage, ToolSet, IAgentRunResult } from './plugins.js';
|
||||
|
||||
/**
|
||||
* Options for creating a ChatSession.
|
||||
*/
|
||||
export interface IChatSessionOptions {
|
||||
/** 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callbacks for real-time streaming events during a turn.
|
||||
*/
|
||||
export interface IChatCallbacks {
|
||||
/** Called for each streamed text token */
|
||||
onToken?: (delta: string) => void;
|
||||
/** Called when a tool call starts */
|
||||
onToolCall?: (name: string, input: unknown) => void;
|
||||
/** Called when a tool call completes */
|
||||
onToolResult?: (name: string, result: string) => void;
|
||||
/** Called when a turn completes */
|
||||
onTurnComplete?: (result: IAgentRunResult) => void;
|
||||
/** Called on error */
|
||||
onError?: (error: Error) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Events emitted during chat.
|
||||
*/
|
||||
export type TChatEvent =
|
||||
| { type: 'token'; delta: string }
|
||||
| { type: 'tool_call_start'; name: string; input: unknown }
|
||||
| { type: 'tool_call_end'; name: string; result: string }
|
||||
| { type: 'turn_start' }
|
||||
| { type: 'turn_complete'; result: IAgentRunResult }
|
||||
| { type: 'error'; error: Error };
|
||||
|
||||
/**
|
||||
* Usage stats accumulated across all turns.
|
||||
*/
|
||||
export interface IChatUsage {
|
||||
inputTokens: number;
|
||||
outputTokens: number;
|
||||
totalTokens: number;
|
||||
turns: number;
|
||||
}
|
||||
Reference in New Issue
Block a user