/** * @file Spawn advisor — composes tier + route + billing + profile into ONE call * so callers stop hand-wiring the AI stack layer by layer. Given a * `TaskClass` and a probed `RouteContext` (plus an optional * `BillingContext`), `adviseSpawn` resolves the capability tier * (`taskClassToTier`), orders the usable cross-engine candidates * (billing-aware via `orderCandidates` when billing is supplied, the static * availability order via `usableTierCandidates` otherwise), and picks the * LEAST-capable `AI_PROFILE` lockdown tier the task class needs. Pure — no * I/O, no spawn: the caller still probes availability/billing once * (`billing-context.mts`) and hands the resulting `RouteContext` / * `BillingContext` in, then calls `spawnAiAgent` / `spawnTierWithFallback` * with the advice. Modeled on the "advisor" pattern from Copilot-style CLIs: * one entry point a skill consults instead of importing four modules and * reimplementing the same composition at every call site. */ import { AI_PROFILE } from './profiles.js'; import type { AiProfile } from './profiles.js'; import type { BillingContext, RoutingEnv, TaskClass } from './route-heuristic.js'; import type { RouteContext, TierCandidate } from './route.js'; import type { AiTier } from './tier.js'; /** * The LEAST-capable `AI_PROFILE` lockdown tier each task class needs — a * floor, not a ceiling. A caller may run a task at a MORE capable tier (that * is what `isOverProfileFloor` in `enforce.mts` flags as over-permissioned), * but never a less capable one and still expect the work to land. * * - `plan` → `read` — planning inspects and proposes; it never mutates a repo, so * the research-only tier (Read/Grep/Glob/WebFetch/WebSearch, no * Edit/Write/Bash) is sufficient. * - `grunt` → `read` — classify / summarize / single-token rewrites are * read-and-report; the caller applies the rewrite, the agent does not. * - `code` → `create` — control-flow / caller-chain edits and feature work author * AND create files such as a new test or a split module, but do not need Bash * to do the job. * - `agentic` → `full` — long autonomous tool-use loops that land their own work * need the whole ladder: author, self-verify, and commit. */ export declare const PROFILE_FLOOR: Readonly>; export interface AdviseSpawnOptions { readonly billing?: BillingContext | undefined; readonly demoteThreshold?: number | undefined; readonly env?: RoutingEnv | undefined; readonly profileFloor?: keyof typeof AI_PROFILE | undefined; readonly route: RouteContext; readonly taskClass: TaskClass; } /** * A complete, ready-to-spawn plan: which tier, which lockdown profile floor * (and its concrete `AiProfile`), the ordered candidate list to walk, and a * human-readable `reason` a caller can log alongside the spawn. */ export interface SpawnAdvice { readonly candidates: TierCandidate[]; readonly profile: AiProfile; readonly profileFloor: keyof typeof AI_PROFILE; readonly reason: string; readonly tier: AiTier; } /** * Advise a complete spawn plan for one unit of work. Resolves the tier from * the task class, orders the usable candidates (billing-aware when `billing` * is supplied), and picks the profile floor (`options.profileFloor` override, * else `PROFILE_FLOOR[taskClass]`). Never throws and never probes anything — * an empty `route`/`billing` simply yields advice with an empty * `candidates` list and a `reason` that says so, so a caller can surface "no * usable AI engine" without a try/catch. */ export declare function adviseSpawn(options: AdviseSpawnOptions): SpawnAdvice;