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
export type AgentState = "blocked" | "working" | "done";
export type BlockedKind = "permission" | "question";
export type StateRecord = {
state: AgentState;
cwd: string;
kind?: BlockedKind;
message?: string;
};
export const stateScript = (home: string) => `${home}/.dotfiles/ai/bin/,agent-state`;
export function recordArguments(record: StateRecord): string[] {
const args = ["record", "--app", "claude-code"];
if (record.kind !== undefined) args.push("--kind", record.kind);
args.push(record.state, record.cwd, record.message ?? "");
return args;
}
export function permissionRequest(tool: string | undefined, cwd: string): StateRecord {
return { state: "blocked", kind: "permission", cwd, message: tool ?? "" };
}
export function questionRequest(cwd: string): StateRecord {
return { state: "blocked", kind: "question", cwd };
}
export function working(cwd: string): StateRecord {
return { state: "working", cwd };
}
export function done(cwd: string): StateRecord {
return { state: "done", cwd, message: "turn finished" };
}
export function isPrimaryAgent(agentId: string | undefined): boolean {
return agentId === undefined || agentId === "";
}