-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprotocol.ts
More file actions
68 lines (67 loc) · 1.64 KB
/
Copy pathprotocol.ts
File metadata and controls
68 lines (67 loc) · 1.64 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type { NativeContext } from "./native-state.js";
import { z } from "zod";
export const requestSchema = z.object({
id: z.string().uuid(),
harness: z.enum(["claude", "codex", "pi"]),
prompt: z.string().min(1).max(64_000),
});
export const stopSchema = z.object({
type: z.literal("stop"),
requestId: z.string().uuid(),
});
export type Request = z.infer<typeof requestSchema>;
export type Turn = Request & {
status: "completed" | "failed" | "stopped";
text: string;
};
export type Output =
| {
type: "lifecycle";
phase: "suspending" | "resumed";
bootId: string;
turns: number;
workspaceRestored?: boolean;
}
| {
type: "native";
requestId: string;
harness: Request["harness"];
id: string;
resumed: boolean;
restored: boolean;
}
| {
type: "started";
requestId: string;
harness: Request["harness"];
attempt?: number;
}
| {
type: "event";
requestId: string;
harness: Request["harness"];
event: unknown;
}
| {
type: "result";
requestId: string;
harness: Request["harness"];
status: Turn["status"];
text: string;
}
| { type: "committed"; requestId: string; commitKey: string }
| { type: "text"; requestId: string; text: string; replace?: boolean }
| {
type: "tool";
requestId: string;
harness: Request["harness"];
name: string;
}
| { type: "retrying"; requestId: string; attempt: number };
export type Harness = (
prompt: string,
emit: (event: unknown) => void,
signal: AbortSignal,
workspace: string,
native?: NativeContext,
) => Promise<string>;