import { type RouteIndex, type BuildRoutesOpts } from "./agent-router.js"; /** * v0.6 ยง10.5 โ€” reload policy for fs-watcher events. * * The fs-watcher emits change events; this module decides what to do with * them based on `workspace.yaml.fs_watch.mode`: * * auto โ€” call `rebuildRoutes()` immediately + notify user. * prompt โ€” ask the user `๐Ÿ”„ N๊ฐœ SKILL ๋ณ€๊ฒฝ ๊ฐ์ง€ โ€” ์ ์šฉ? [y/N]` and wait * for `y`/`n`/timeout. Only `y` triggers rebuild. * manual โ€” emit a notice but do NOT rebuild. User must run * `solosquad agent reload`. * * Additional safety: when `gitOnly: true`, the policy refuses to apply * unless the workspace just had `origin/main` merged into the local branch. * The implementation compares the current HEAD to a tracking ref recorded * the last time the policy applied โ€” if HEAD advanced AND the most recent * commit's parent line includes the previously-tracked origin/main SHA, * we consider it a merge boundary. */ export type ReloadMode = "auto" | "prompt" | "manual"; export interface ReloadPolicyDecision { /** What the policy did: ran reload, deferred to user, or skipped. */ outcome: "auto" | "prompt" | "manual"; /** True iff `rebuildRoutes()` actually ran. */ reloaded: boolean; /** Caller can post this to PM channel. Empty when nothing to say. */ notice: string; /** When prompt mode fired, the question text we asked. */ prompt?: string; /** Set when reloaded โ€” the # of triggers after the rebuild. */ triggerCount?: number; } export interface ApplyReloadPolicyOpts { mode: ReloadMode; /** Absolute paths reported by `startSkillWatcher`. */ changes: string[]; /** * Only used in `prompt` mode. Caller drives the back-and-forth (ask the * user, await answer) and returns `true` for yes / `false` for no/timeout. * If omitted in prompt mode, the policy treats it as deferred (`reloaded: * false`, `outcome: "prompt"`) and the caller can prompt later. */ onConfirm?: (prompt: string) => Promise; /** When true, only apply when origin/main has just been merged. */ gitOnly?: boolean; /** * `git rev-parse`-style root used for the gitOnly check. Defaults to the * workspace from `buildOpts.workspace_root` or `process.cwd()`. Tests * inject a fixture path. */ gitRoot?: string; /** * Forwarded to `rebuildRoutes()` so the router scans the same tiers the * watcher did. The bot wires this from its known org slug. */ buildOpts?: BuildRoutesOpts; /** * Test hook โ€” replace the git probe. Returns whether we consider the * current HEAD a "just merged origin/main" state. */ gitProbe?: (root: string) => boolean; /** Test hook โ€” replace `rebuildRoutes()`. */ rebuild?: (opts: BuildRoutesOpts) => RouteIndex; } /** * Apply the configured reload policy. Pure with respect to the messenger โ€” * the caller posts `decision.notice` and (in prompt mode) drives the * `onConfirm` callback. */ export declare function applyReloadPolicy(opts: ApplyReloadPolicyOpts): Promise; export declare function triggerCount(idx: RouteIndex): number; /** * Convenience for callers that just want the "๐Ÿ”„ N๊ฐœ SKILL ๋ณ€๊ฒฝ" prefix * outside the policy decision flow. */ export declare function summarizeChanges(changes: string[]): string;