cde75bd7fb
Use --resume <session_id> with claude -p so the web UI claude-code-pty provider maintains full conversation context across messages, identical to a long-running terminal Claude Code session. Changes: - Capture session_id from claude -p stream-json system event - Pass --resume on subsequent messages in same chat session - Thread session_id through ProviderConfig, ChatResult, WsResponse - Frontend stores sessionId per chat, clears on New Session - Unset CLAUDECODE env to allow nested spawning from server - Wait for clean process exit to ensure transcript flush to disk Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
69 lines
1.2 KiB
TypeScript
69 lines
1.2 KiB
TypeScript
export type Role = "system" | "user" | "assistant" | "tool";
|
|
|
|
export interface ToolCall {
|
|
id?: string;
|
|
type: string;
|
|
function: {
|
|
name: string;
|
|
arguments: string;
|
|
};
|
|
}
|
|
|
|
export interface Message {
|
|
role: Role;
|
|
content: string;
|
|
tool_calls?: ToolCall[];
|
|
tool_call_id?: string;
|
|
}
|
|
|
|
export interface ProviderConfig {
|
|
provider: string;
|
|
model: string;
|
|
base_url?: string;
|
|
enable_tools?: boolean;
|
|
session_id?: string;
|
|
}
|
|
|
|
export interface FileEntry {
|
|
name: string;
|
|
kind: "file" | "dir";
|
|
}
|
|
|
|
export interface SearchResult {
|
|
path: string;
|
|
matches: number;
|
|
}
|
|
|
|
export interface CommandOutput {
|
|
stdout: string;
|
|
stderr: string;
|
|
exit_code: number;
|
|
}
|
|
|
|
export type WsRequest =
|
|
| {
|
|
type: "chat";
|
|
messages: Message[];
|
|
config: ProviderConfig;
|
|
}
|
|
| {
|
|
type: "cancel";
|
|
};
|
|
|
|
export type WsResponse =
|
|
| { type: "token"; content: string }
|
|
| { type: "update"; messages: Message[] }
|
|
| { type: "session_id"; session_id: string }
|
|
| { type: "error"; message: string };
|
|
|
|
// Re-export API client types for convenience
|
|
export type {
|
|
Message as ApiMessage,
|
|
ProviderConfig as ApiProviderConfig,
|
|
FileEntry as ApiFileEntry,
|
|
SearchResult as ApiSearchResult,
|
|
CommandOutput as ApiCommandOutput,
|
|
WsRequest as ApiWsRequest,
|
|
WsResponse as ApiWsResponse,
|
|
};
|