/** * User-level settings for pi-dynamic-workflows. * * Stored separately from Pi's own settings.json so extension preferences remain * stable without depending on host-internal config shape. */ import { type ContextPrimitives } from "./context-mode.js"; export interface WorkflowSettings { keywordTriggerEnabled?: boolean; defaultAgentTimeoutMs?: number | null; /** * Default hard timeout for a run, in milliseconds. When unset (undefined) * the runtime constant still applies. Set to null to disable the run-wide * timeout explicitly. Positive finite numbers are retained; invalid / * zero / negative / non-numeric values are dropped. Normalized exactly like * `defaultAgentTimeoutMs`. */ defaultWorkflowTimeoutMs?: number | null; /** Default max concurrent agents per run. Clamped to the runtime maximum. */ defaultConcurrency?: number; /** Default retry attempts after recoverable agent failures. */ defaultAgentRetries?: number; /** Default hard per-agent provider input/context token cap. */ defaultAgentMaxContextTokens?: number | null; /** Default reserve subtracted from model context windows for occupancy warnings. */ defaultAgentContextReserveTokens?: number | null; /** Bottom task-panel display mode: "detailed" (default — per-phase/per-agent tree with status, tokens, model, and each finished agent's result preview) | "compact" (one line per run). */ progressPanelMode?: "compact" | "detailed"; /** Max agents shown per phase in detailed progress mode (default 8). */ progressPanelMaxAgents?: number; /** * Whether each subagent gets a persisted NDJSON transcript under * `//subagents/`. Default true (matches Claude Code, which * writes `agent-.jsonl` per subagent so failed runs are debuggable). * Set false to keep subagent sessions in-memory only. */ persistSubagentTranscripts?: boolean; /** * herdr TUI status bridge: "auto" (default — mirror live workflow status into * the host herdr pane's cell when running inside herdr; a no-op otherwise) or * "off" (never report). The `PI_WORKFLOWS_HERDR=0` env var also disables it. * See docs/herdr-integration.md. */ herdrStatus?: "auto" | "off"; /** * herdr pane-spawn: "off" (default — do not spawn a real pi per run) or * "auto" (enable pane-spawn for isolated runs only when inside herdr, * i.e. HERDR_PANE_ID present). Opt-in because a real pi per run multiplies * VM memory. See docs/herdr-integration.md §4. */ herdrPaneSpawn?: "off" | "auto"; /** * Maximum concurrent herdr-pane-spawned runs (VM memory cap). * Default 4. Must be a positive integer; invalid values fall back to default. * See docs/herdr-integration.md §6. */ herdrMaxPanes?: number; /** * Project-defined context modes, merged OVER the built-ins (focused|isolated| * scoped|legacy) for `--mode ` and agentType frontmatter. Each name maps * to the full inheritance primitive set. Built-in names are reserved and * silently ignored. Entries missing or mistyping any field are dropped (the * feature stays opt-in and the built-ins remain available regardless). */ contextModes?: Record; } export interface WorkflowSettingsStore { load(): WorkflowSettings; save(settings: WorkflowSettings): void; } export interface WorkflowSettingsOptions { /** Explicit settings path, primarily for tests and migrations. */ settingsPath?: string; /** Project cwd whose project-level settings should override global settings. */ cwd?: string; /** Explicit project settings path, primarily for tests. */ projectSettingsPath?: string; /** Save destination when using saveWorkflowSettings with cwd. Default: global. */ scope?: "global" | "project"; } /** Path to the user-level workflow settings JSON file (~/.pi/workflows/settings.json). */ export declare function getWorkflowSettingsPath(): string; /** Path to this project's optional workflow settings override. */ export declare function getWorkflowProjectSettingsPath(cwd: string): string; /** Load settings from disk. Missing, corrupt, or invalid files resolve to {}. */ export declare function loadWorkflowSettings(settingsPathOrOptions?: string | WorkflowSettingsOptions): WorkflowSettings; /** Merge known settings into the user-level settings file. */ export declare function saveWorkflowSettings(settings: WorkflowSettings, settingsPathOrOptions?: string | WorkflowSettingsOptions): void; /** Save a global preference and update an existing project override if one is present. */ export declare function saveWorkflowSettingsForCwd(settings: WorkflowSettings, cwd: string): void;