/** * Arial Server - Type definitions */ export type SpecStatus = "queued" | "running" | "pr_created" | "failed" | "cancelled"; /** Reference to previous work that this spec builds on */ export interface SpecReference { /** Type of reference */ type: "spec" | "pr" | "branch"; /** The reference value (spec ID, PR number, or branch name) */ value: string; } export interface Owner { name: string; email: string; } export interface Spec { id: string; repoId: string; title: string; content: string; owner: Owner; /** ID of the user who dispatched this spec (for GitHub API authentication) */ userId?: string; status: SpecStatus; branch?: string; worktreePath?: string; prNumber?: number; prUrl?: string; createdAt: string; startedAt?: string; completedAt?: string; duration?: number; error?: string; logs: string[]; /** References to previous specs/PRs this builds on */ extends?: SpecReference[]; /** Auto-generated summary of what this spec accomplished (populated after completion) */ summary?: string; } export interface SpecSummary { id: string; repoId: string; title: string; owner: Owner; status: SpecStatus; branch?: string; prNumber?: number; prUrl?: string; createdAt: string; startedAt?: string; completedAt?: string; duration?: number; error?: string; /** References to previous specs/PRs this builds on */ extends?: SpecReference[]; /** Auto-generated summary of what this spec accomplished */ summary?: string; } export interface QueueCounts { queued: number; running: number; pr_created: number; failed: number; cancelled: number; } export type ServerEvent = { type: "spec.queued"; spec: SpecSummary; position: number; } | { type: "spec.started"; spec: SpecSummary; } | { type: "spec.pr_created"; spec: SpecSummary; prUrl: string; } | { type: "spec.failed"; spec: SpecSummary; } | { type: "spec.cancelled"; spec: SpecSummary; } | { type: "spec.output"; specId: string; line: string; } | { type: "queue.updated"; counts: QueueCounts; }; export type ClientMessage = { type: "subscribe"; specId: string; } | { type: "unsubscribe"; specId: string; } | { type: "auth.subscribe"; deviceCode: string; } | { type: "auth.unsubscribe"; deviceCode: string; } | { type: "chat.send"; conversationId: string; content: string; requestId: string; } | { type: "chat.cancel"; requestId: string; }; export type AuthEvent = { type: "auth.complete"; deviceCode: string; accessToken: string; refreshToken: string; expiresIn: number; user: { id: string; username: string; avatarUrl: string; }; } | { type: "auth.error"; deviceCode: string; error: string; } | { type: "auth.expired"; deviceCode: string; }; export interface ChatGeneratedSpec { title: string; content: string; extends?: Array<{ type: "pr" | "branch" | "spec"; value: string; }>; } export interface ChatQuestion { id: string; text: string; options: Array<{ label: string; description?: string; }>; multiSelect: boolean; } export type ChatEvent = { type: "chat.text"; requestId: string; text: string; } | { type: "chat.spec"; requestId: string; spec: ChatGeneratedSpec; } | { type: "chat.question"; requestId: string; question: ChatQuestion; } | { type: "chat.done"; requestId: string; } | { type: "chat.error"; requestId: string; error: string; }; export interface DispatchRequest { repoId: string; /** Human-readable name for the spec (server generates unique ID from this) */ name: string; title: string; content: string; owner: Owner; /** Remote URL for auto-clone (optional, enables dynamic repo support) */ remoteUrl?: string; /** Base branch for the repo (optional, defaults to 'main') */ baseBranch?: string; /** References to previous specs/PRs this builds on */ extends?: SpecReference[]; } export interface DispatchResponse { ok: true; spec: { id: string; status: SpecStatus; position: number; createdAt: string; }; } export interface ErrorResponse { ok: false; error: string; } export type ApiResponse = T | ErrorResponse; /** * Per-repo status in API response */ export interface RepoStatusResponse { id: string; path: string; baseBranch: string; maxConcurrentAgents: number; activeAgents: number; status: "idle" | "running" | "merging"; github: { owner: string; repo: string; }; queue: QueueCounts; } /** * Server status API response */ export interface ServerStatus { status: "running"; globalMaxConcurrentAgents: number; globalActiveAgents: number; repos: RepoStatusResponse[]; } /** * Per-repo state */ export interface RepoState { status: "idle" | "running" | "merging"; activeAgents: number; buildQueue: string[]; mergeQueue: string[]; } /** * Server state (persisted) */ export interface ServerState { version: 2; specs: Record; repos: Record; updatedAt: string; } export type AdapterCapability = "file_read" | "file_write" | "file_search" | "bash_execute" | "web_search" | "web_fetch" | "code_analysis" | "git_operations"; export type AuthMode = "api_key" | "local_credentials"; export interface AdapterConfig { readonly id: string; readonly apiKey?: string | undefined; readonly authMode: AuthMode; readonly model?: string | undefined; readonly baseUrl?: string | undefined; readonly options?: Record; } export interface AgentCallbacks { onText?: (text: string) => void; onToolStart?: (toolName: string, toolUseId: string, input: unknown) => void; onToolEnd?: (toolName: string, toolUseId: string, success: boolean) => void; } export interface AgentRunOptions { prompt: string; cwd: string; systemPrompt?: string | undefined; abortController?: AbortController | undefined; maxTurns?: number | undefined; callbacks?: AgentCallbacks | undefined; } export interface ExecutionRunnerOptions extends AgentRunOptions { bypassPermissions?: boolean | undefined; /** Environment variables to pass to the agent process (defaults to filtered process.env) */ env?: Record | undefined; /** Enable sandbox mode to restrict agent to worktree */ sandbox?: boolean | undefined; } export interface AgentRunResult { success: boolean; output: string; error?: string | undefined; durationMs: number; metrics: AdapterMetrics; } export interface AdapterMetrics { adapterId: string; raw: Record; } export interface AgentRunner { start(): void; abort(): void; isRunning(): boolean; wait(): Promise; } export interface Adapter { readonly id: string; readonly name: string; readonly capabilities: readonly AdapterCapability[]; hasCapabilities(required: AdapterCapability[]): boolean; createExecutionRunner(options: ExecutionRunnerOptions): AgentRunner; runConflictAgent?(options: AgentRunOptions): Promise; } export type Result = { ok: true; value: T; } | { ok: false; error: E; }; export interface AdapterError { code: "MISSING_API_KEY" | "INVALID_CONFIG" | "CAPABILITY_NOT_SUPPORTED" | "ADAPTER_NOT_FOUND" | "INITIALIZATION_FAILED"; message: string; adapterId?: string; } export type AdapterFactory = (config: AdapterConfig) => Result; //# sourceMappingURL=types.d.ts.map