- add shared provider checkpoint diff query options and keys - refactor `ChatView` and `DiffPanel` to fetch diffs via React Query - persist selected-turn checkpoint diffs back into thread state for reuse
144 lines
5.1 KiB
TypeScript
144 lines
5.1 KiB
TypeScript
import type { AgentConfig, AgentExit, OutputChunk } from "./agent";
|
|
import type {
|
|
GitCheckoutInput,
|
|
GitCreateBranchInput,
|
|
GitCreateWorktreeInput,
|
|
GitCreateWorktreeResult,
|
|
GitInitInput,
|
|
GitListBranchesInput,
|
|
GitListBranchesResult,
|
|
GitPullInput,
|
|
GitPullResult,
|
|
GitRemoveWorktreeInput,
|
|
GitRunStackedActionInput,
|
|
GitRunStackedActionResult,
|
|
GitStatusInput,
|
|
GitStatusResult,
|
|
} from "./git";
|
|
import type {
|
|
ProviderEvent,
|
|
ProviderGetCheckpointDiffInput,
|
|
ProviderGetCheckpointDiffResult,
|
|
ProviderInterruptTurnInput,
|
|
ProviderListCheckpointsInput,
|
|
ProviderListCheckpointsResult,
|
|
ProviderRevertToCheckpointInput,
|
|
ProviderRevertToCheckpointResult,
|
|
ProviderRespondToRequestInput,
|
|
ProviderSendTurnInput,
|
|
ProviderSession,
|
|
ProviderSessionStartInput,
|
|
ProviderStopSessionInput,
|
|
ProviderTurnStartResult,
|
|
} from "./provider";
|
|
import type {
|
|
ProjectAddInput,
|
|
ProjectAddResult,
|
|
ProjectListResult,
|
|
ProjectSearchEntriesInput,
|
|
ProjectSearchEntriesResult,
|
|
ProjectRemoveInput,
|
|
ProjectUpdateScriptsInput,
|
|
ProjectUpdateScriptsResult,
|
|
} from "./project";
|
|
import type { ServerConfig } from "./server";
|
|
import type {
|
|
TerminalClearInput,
|
|
TerminalCloseInput,
|
|
TerminalEvent,
|
|
TerminalOpenInput,
|
|
TerminalResizeInput,
|
|
TerminalSessionSnapshot,
|
|
TerminalWriteInput,
|
|
} from "./terminal";
|
|
import type { NewTodoInput, Todo } from "./todo";
|
|
import type { ServerUpsertKeybindingInput, ServerUpsertKeybindingResult } from "./server";
|
|
|
|
export const EDITORS = [
|
|
{ id: "cursor", label: "Cursor", command: "cursor" },
|
|
{ id: "file-manager", label: "File Manager", command: null },
|
|
] as const;
|
|
|
|
export type EditorId = (typeof EDITORS)[number]["id"];
|
|
|
|
export interface NativeApi {
|
|
todos: {
|
|
list: () => Promise<Todo[]>;
|
|
add: (input: NewTodoInput) => Promise<Todo[]>;
|
|
toggle: (id: string) => Promise<Todo[]>;
|
|
remove: (id: string) => Promise<Todo[]>;
|
|
};
|
|
dialogs: {
|
|
pickFolder: () => Promise<string | null>;
|
|
confirm: (message: string) => Promise<boolean>;
|
|
};
|
|
terminal: {
|
|
open: (input: TerminalOpenInput) => Promise<TerminalSessionSnapshot>;
|
|
write: (input: TerminalWriteInput) => Promise<void>;
|
|
resize: (input: TerminalResizeInput) => Promise<void>;
|
|
clear: (input: TerminalClearInput) => Promise<void>;
|
|
restart: (input: TerminalOpenInput) => Promise<TerminalSessionSnapshot>;
|
|
close: (input: TerminalCloseInput) => Promise<void>;
|
|
onEvent: (callback: (event: TerminalEvent) => void) => () => void;
|
|
};
|
|
agent: {
|
|
spawn: (config: AgentConfig) => Promise<string>;
|
|
kill: (sessionId: string) => Promise<void>;
|
|
write: (sessionId: string, data: string) => Promise<void>;
|
|
onOutput: (callback: (chunk: OutputChunk) => void) => () => void;
|
|
onExit: (callback: (exit: AgentExit) => void) => () => void;
|
|
};
|
|
providers: {
|
|
startSession: (input: ProviderSessionStartInput) => Promise<ProviderSession>;
|
|
sendTurn: (input: ProviderSendTurnInput) => Promise<ProviderTurnStartResult>;
|
|
interruptTurn: (input: ProviderInterruptTurnInput) => Promise<void>;
|
|
respondToRequest: (input: ProviderRespondToRequestInput) => Promise<void>;
|
|
stopSession: (input: ProviderStopSessionInput) => Promise<void>;
|
|
listSessions: () => Promise<ProviderSession[]>;
|
|
listCheckpoints: (
|
|
input: ProviderListCheckpointsInput,
|
|
) => Promise<ProviderListCheckpointsResult>;
|
|
getCheckpointDiff: (
|
|
input: ProviderGetCheckpointDiffInput,
|
|
) => Promise<ProviderGetCheckpointDiffResult>;
|
|
revertToCheckpoint: (
|
|
input: ProviderRevertToCheckpointInput,
|
|
) => Promise<ProviderRevertToCheckpointResult>;
|
|
onEvent: (callback: (event: ProviderEvent) => void) => () => void;
|
|
};
|
|
projects: {
|
|
list: () => Promise<ProjectListResult>;
|
|
add: (input: ProjectAddInput) => Promise<ProjectAddResult>;
|
|
remove: (input: ProjectRemoveInput) => Promise<void>;
|
|
searchEntries: (input: ProjectSearchEntriesInput) => Promise<ProjectSearchEntriesResult>;
|
|
updateScripts: (input: ProjectUpdateScriptsInput) => Promise<ProjectUpdateScriptsResult>;
|
|
};
|
|
shell: {
|
|
openInEditor: (cwd: string, editor: EditorId) => Promise<void>;
|
|
openExternal: (url: string) => Promise<void>;
|
|
};
|
|
git: {
|
|
// Existing branch/worktree API
|
|
listBranches: (input: GitListBranchesInput) => Promise<GitListBranchesResult>;
|
|
createWorktree: (input: GitCreateWorktreeInput) => Promise<GitCreateWorktreeResult>;
|
|
removeWorktree: (input: GitRemoveWorktreeInput) => Promise<void>;
|
|
createBranch: (input: GitCreateBranchInput) => Promise<void>;
|
|
checkout: (input: GitCheckoutInput) => Promise<void>;
|
|
init: (input: GitInitInput) => Promise<void>;
|
|
// Stacked action API
|
|
pull: (input: GitPullInput) => Promise<GitPullResult>;
|
|
status: (input: GitStatusInput) => Promise<GitStatusResult>;
|
|
runStackedAction: (input: GitRunStackedActionInput) => Promise<GitRunStackedActionResult>;
|
|
};
|
|
contextMenu: {
|
|
show: <T extends string>(
|
|
items: readonly { id: T; label: string }[],
|
|
position?: { x: number; y: number },
|
|
) => Promise<T | null>;
|
|
};
|
|
server: {
|
|
getConfig: () => Promise<ServerConfig>;
|
|
upsertKeybinding: (input: ServerUpsertKeybindingInput) => Promise<ServerUpsertKeybindingResult>;
|
|
};
|
|
}
|