import type http from "node:http"; import type { AgentSession } from "@kenkaiiii/gg-engine/internal/core/agent-session.js"; import type { ChatAgentId } from "../chat-agents/index.js"; import type { ChildProcess } from "node:child_process"; import type { RunOutcome } from "@kenkaiiii/gg-engine/internal/core/session-manager.js"; import type { HfPullState, WorkspaceMode } from "@kenkaiiii/gg-protocol"; import type { FixAllRunner } from "./fix-all-runner.js"; export interface SseClient { id: number; res: http.ServerResponse; } export type { WorkspaceMode }; /** Unknown or missing modes fall back to the coding agent. */ export declare function parseWorkspaceMode(value: unknown): WorkspaceMode; export interface SessionContext { id: string; mode: WorkspaceMode; chatAgent: ChatAgentId; cwd: string; sessionPath?: string; session: AgentSession; clients: Set; broadcast: (type: string, data: unknown) => void; /** Handle one HTTP request for this session. Owns its own 404 fallthrough. */ handle: (req: http.IncomingMessage, res: http.ServerResponse, url: string, method: string) => void; dispose: () => Promise; /** Synchronously stop this context's background commands (all its sessions). */ stopBackgroundProcesses: () => void; /** Working right now: a run in progress, or a worker still on a task. */ isBusy: () => boolean; /** How the latest run ended; null before any run, or while one is in progress. */ lastRunOutcome: () => RunOutcome | null; /** * Holds state only in memory that closing it would lose: a plan awaiting * review, plan mode, an accepted plan in progress, Ken replying, an open * question, or `!` output waiting for the next message. */ holdsState: () => boolean; /** Waiting on the user: a plan to review or an open question. */ awaitsUser: () => boolean; /** * The folder this window reads git state from (a Goal window: its project * folder, not the goal folder). Absent for contexts without git state. */ gitDir?: () => string; /** The project it belongs to when it works in a GG-made worktree of it, else null. */ ggWorktreeOf?: () => string | null; /** Its Fix all runner (code windows on a project), or null. */ fixAll?: () => FixAllRunner | null; } /** The sidecar's running `ollama pull`: the wire state plus its process. */ export interface HfPullJob extends HfPullState { child: ChildProcess | null; }