feat: initial Lam Agent extension (#1)
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Shared domain types for Lam Agent.
|
||||
*
|
||||
* These are deliberately split into two families:
|
||||
*
|
||||
* - `ApiMessage` and friends mirror exactly what Ollama's `/api/chat` accepts.
|
||||
* - `Session`, `ChatTurn` and friends are Lam's own storage model.
|
||||
*
|
||||
* Keeping them separate matters because the storage model is derived from the
|
||||
* API model, not identical to it: the tool-calling messages that Ollama needs
|
||||
* mid-turn are not persisted, so a reloaded session replays cleanly as plain
|
||||
* user/assistant pairs.
|
||||
*/
|
||||
|
||||
export type ChatRole = "system" | "user" | "assistant" | "tool";
|
||||
|
||||
export interface ToolCall {
|
||||
function: {
|
||||
name: string;
|
||||
arguments: Record<string, unknown>;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ToolDefinition {
|
||||
type: "function";
|
||||
function: {
|
||||
name: string;
|
||||
description: string;
|
||||
parameters: Record<string, unknown>;
|
||||
};
|
||||
}
|
||||
|
||||
/** A message in the shape Ollama's `/api/chat` endpoint expects. */
|
||||
export interface ApiMessage {
|
||||
role: ChatRole;
|
||||
content: string;
|
||||
tool_calls?: ToolCall[];
|
||||
/** Only set on `role: "tool"` messages, naming the tool that produced this content. */
|
||||
tool_name?: string;
|
||||
}
|
||||
|
||||
/** What a tool actually returned during a turn, kept for display and debugging. */
|
||||
export interface ToolCallRecord {
|
||||
name: string;
|
||||
arguments: Record<string, unknown>;
|
||||
result: string;
|
||||
isError: boolean;
|
||||
}
|
||||
|
||||
/** One question and its answer. The unit the transcript is rendered from. */
|
||||
export interface ChatTurn {
|
||||
id: string;
|
||||
prompt: string;
|
||||
response: string;
|
||||
thinking: string;
|
||||
model: string;
|
||||
createdAt: number;
|
||||
/** Set when the turn failed, so a stored session can show what went wrong. */
|
||||
error?: string;
|
||||
toolCalls: ToolCallRecord[];
|
||||
}
|
||||
|
||||
export interface Session {
|
||||
id: string;
|
||||
title: string;
|
||||
model: string;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
turns: ChatTurn[];
|
||||
}
|
||||
|
||||
/** The lightweight record kept in the session index, so listing sessions never loads full transcripts. */
|
||||
export interface SessionSummary {
|
||||
id: string;
|
||||
title: string;
|
||||
model: string;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
turnCount: number;
|
||||
preview: string;
|
||||
}
|
||||
|
||||
/** A model as reported by `GET /api/tags`. */
|
||||
export interface ModelInfo {
|
||||
name: string;
|
||||
parameterSize?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user