Files
opencode-multi-model/src/types.ts
T

160 lines
4.4 KiB
TypeScript

/**
* Settings stored in ~/.config/opencode-multi-model/settings.json
*/
export interface MultiModelSettings {
lastModels: string[];
}
/**
* Options for launching a multi-model tmux session.
*/
export interface MultiModelOptions {
/** Name for the tmux session. */
sessionName: string;
/** List of model ids to launch. */
models: string[];
/** Binary name to use ('opencode' or 'kilo'). Defaults to 'opencode'. */
binaryName?: string;
/** Caller context: 'cli' shows shell commands, 'tool' shows tool instructions. */
mode: "cli" | "tool";
/** Save models to settings file on successful launch (CLI only). */
saveToSettings?: boolean;
}
/**
* Result returned after attempting to launch a multi-model session.
*/
export interface MultiModelResult {
/** Whether the launch succeeded. */
success: boolean;
/** The session name used. */
sessionName: string;
/** Window names created in the tmux session. */
windows?: string[];
/** Error message if the launch failed. */
error?: string;
/** Instructions for attaching and cleaning up the session. */
instructions?: string;
}
/**
* Options for closing a multi-model tmux session.
*/
export interface CloseSessionOptions {
/** Whether to create archive tags before deleting branches. */
createArchiveTags?: boolean;
/** Name of the tmux session to close. */
sessionName: string;
/** Whether to remove worktrees and delete branches. */
cleanupWorktrees?: boolean;
/** Skip confirmation prompts. */
force?: boolean;
/** Caller context: 'cli' shows shell commands, 'tool' shows tool instructions. */
mode: "cli" | "tool";
}
/**
* Result returned after attempting to close a multi-model session.
*/
export interface CloseSessionResult {
/** Console messages and instructions. */
instructions: string;
/** Whether the close succeeded. */
success: boolean;
/** The session name that was closed. */
sessionName: string;
/** Error message if the close failed. */
error?: string;
/** Whether cleanup was performed. */
cleanupPerformed?: boolean;
/** Worktree paths that were removed. */
worktreesRemoved?: string[];
/** Branch names that were deleted. */
branchesDeleted?: string[];
/** Archive tags that were created before branch deletion. */
tagsCreated?: string[];
}
/**
* Internal type for a window launch plan.
*/
export interface WindowLaunchPlan {
/** Full model id. */
model: string;
/** Unique tmux window name. */
windowName: string;
}
/**
* Options for cleaning up archive tags.
*/
export interface CleanupOptions {
/** Skip confirmation prompts. */
force?: boolean;
/**
* Remote name to push deletions to.
* - If string: use specified remote (error if doesn't exist)
* - If undefined: use first available remote from git remote -v
* - If false: only local cleanup (--no-remote flag)
*/
remote?: string | false;
/** Caller context: 'cli' shows shell commands, 'tool' shows tool instructions. */
mode: "cli" | "tool";
}
/**
* Result returned after attempting to cleanup archive tags.
*/
export interface CleanupResult {
/** Whether the cleanup succeeded. */
success: boolean;
/** Error message if the cleanup failed. */
error?: string;
/** Summary message for the user. */
instructions?: string;
/** Number of local tags deleted. */
localTagsDeleted: number;
/** Number of remote tags deleted. */
remoteTagsDeleted: number;
/** Names of tags that were deleted locally. */
localTagNames: string[];
/** Names of tags deleted from remote. */
remoteTagNames: string[];
/** Tags that failed remote deletion. */
remoteTagErrors: Array<{ tag: string; error: string }>;
/** Available remotes discovered. */
availableRemotes: string[];
}
/**
* Result of running a shell command.
*/
export interface CommandResult {
/** Whether the command exited with code 0. */
ok: boolean;
/** Captured stdout. */
stdout: string;
/** Captured stderr. */
stderr: string;
}
/**
* Options for running a shell command.
*/
export interface RunCommandOptions {
/** Caller context: 'cli' shows spinner, 'tool' does not. */
mode?: "cli" | "tool";
/** Message to display in the spinner while the command runs. */
spinnerMsg?: string;
}
/**
* Information about a git worktree.
*/
export interface WorktreeInfo {
/** Absolute path to the worktree. */
path: string;
/** Branch name associated with the worktree. */
branch: string;
}