Files
smartchat/ts/smartchat.interfaces.ts
jkunz dd04edb420 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)
2026-03-06 23:20:12 +00:00

53 lines
1.4 KiB
TypeScript

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;
}