Repository navigation
Expand file tree
/
Copy pathrunner.ts
More file actions
45 lines (40 loc) · 1.45 KB
/
Copy pathrunner.ts
File metadata and controls
45 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// The boundary between the daemon (Midhat) and the runner (Tahira).
// The daemon calls Runner methods. The runner yields RunnerEvents, the daemon stores and uploads them.
import type { AgentKind } from "./session.js";
export const RUNNER_EVENT_TYPES = [
"task.started",
"message",
"file.read",
"file.changed",
"command.started",
"command.finished",
"test.result",
"task.finished",
"task.failed",
"task.stopped",
] as const;
export type RunnerEventType = (typeof RUNNER_EVENT_TYPES)[number];
export interface RunnerEvent {
sessionId: string;
seq: number; // 1, 2, 3 … per session. Lets the phone catch up after a reconnect
type: RunnerEventType;
at: string; // ISO time
payload: Record<string, unknown>;
raw?: unknown; // the agent's original line, untouched
}
export interface StartOptions {
sessionId: string; // UUID from the server, reused as Claude's --session-id
repoPath: string;
prompt: string;
agent: Exclude<AgentKind, "codehands">;
model?: string;
budgetUsd?: number;
}
export interface Runner {
start(o: StartOptions): AsyncIterable<RunnerEvent>;
stop(sessionId: string): Promise<void>;
resume(sessionId: string, prompt?: string): AsyncIterable<RunnerEvent>;
diff(sessionId: string): Promise<{ patch: string; stat: string }>;
approve(sessionId: string, message: string): Promise<{ branch: string; commit: string }>;
reject(sessionId: string): Promise<void>;
}