| 72 | } |
| 73 | |
| 74 | export interface ClaudeCodeProcess { |
| 75 | /** The underlying child process */ |
| 76 | proc: ChildProcess; |
| 77 | /** Send a user message via stdin (stream-json format) */ |
| 78 | sendMessage(content: string, sessionId?: string): void; |
| 79 | /** Kill the process */ |
| 80 | kill(): void; |
| 81 | /** Wait for the process to exit. Returns the exit code. */ |
| 82 | wait(): Promise<number>; |
| 83 | /** Register a handler for parsed JSONL events */ |
| 84 | onEvent(handler: (event: ClaudeEvent) => void): void; |
| 85 | /** Register a handler for the final result */ |
| 86 | onResult(handler: (result: string, isError: boolean) => void): void; |
| 87 | /** |
| 88 | * Register a handler invoked when Claude reports its session id (via the |
| 89 | * `system/init` event). Use this to persist the id and pass it back as |
| 90 | * `resumeSessionId` on the next spawn. |
| 91 | */ |
| 92 | onSessionId(handler: (sessionId: string) => void): void; |
| 93 | /** Register a handler for process exit */ |
| 94 | onExit(handler: (code: number) => void): void; |
| 95 | /** |
| 96 | * True iff Claude refused to resume the requested `resumeSessionId` |
| 97 | * (i.e. the session was not found locally). Callers can check this after |
| 98 | * exit and retry the spawn without `resumeSessionId` for cold-start |
| 99 | * recovery. |
| 100 | */ |
| 101 | resumeMissed(): boolean; |
| 102 | } |
| 103 | |
| 104 | export interface SpawnOptions { |
| 105 | model: ModelTier; |
no outgoing calls
no test coverage detected