/** * Canonical phase identifiers used by both `meta-orchestrate.md` and * `meta-fix-bug.md` (the latter adds `triage`). When a subagent is * dispatched, its phase tag MUST be one of these values — that lets the * phase-ownership guard compare the caller's phase against the tool's * named `--phase` argument. */ export type PhaseRole = "triage" | "plan" | "plan-fix" | "review-plan" | "implement" | "review-code" | "validate" | "approve" | "writeback" | "commit" | "finalize"; /** * Caller context of the current handler invocation. Discriminated union: * orchestrator (default) or subagent + phase. Subagent context is set * exclusively by `asSubagent(phase, fn)` — the single setter point in * the per-phase orchestrator dispatch loop. */ export type CallerContext = { kind: "orchestrator"; } | { kind: "subagent"; phase: PhaseRole; }; /** * Singleton that tracks the caller context for the current handler turn. * * Usage: * - Read with `CallerContextStore.get()` — used by `assertAudience()` * and `assertPhaseOwnership()`. * - Set with `CallerContextStore.set(...)` — used by orchestrator * handlers when RAII scoping is not viable (avoid where possible). * - Use `CallerContextStore.asSubagent(phase, fn)` / * `asOrchestrator(fn)` for RAII-style scoping. The async overload * accepts an `async () => Promise` and awaits before restoring * prior context. */ export declare const CallerContextStore: { /** Get the current caller context. Defaults to `{ kind: "orchestrator" }`. */ get(): CallerContext; /** Set the current caller context. */ set(ctx: CallerContext): void; /** * Execute fn with context set to `{ kind: "subagent", phase }`; restore * prior context on return or throw. Supports sync and async fn — the * return type is preserved so `await` works at the call site. */ asSubagent(phase: PhaseRole, fn: () => T): T; /** * Execute fn with context set to `{ kind: "orchestrator" }`; restore prior * context on return or throw. */ asOrchestrator(fn: () => T): T; };