import { type BotConfig } from '../../bot-registry.js'; import { type BirthResult, type GrillState, type RunChatBinding } from './grill-state.js'; import { type RunArchitectInput, type RunArchitectResult } from './architect.js'; import { type PublishRunEnvelopeResult, type V3AdHocRunEnvelope } from './run-envelope.js'; import { type BotSnapshot } from './contract.js'; export declare function hostNew(opts: { goal: string; baseDir?: string; runId?: string; now?: Date; chatBinding?: RunChatBinding; }): BirthResult; /** * Resolve the grill command's *current-turn* caller into a chat binding. * Static worker env is intentionally not an authority: BOTMUX_OWNER_OPEN_ID is * the session owner and BOTMUX_TURN_ID/root values go stale in a long-lived * CLI. In-session commands must join the fresh process-tree marker to the * durable session record; detached/stale calls fail closed. * * A genuine standalone/dev invocation (no session claim or marker) keeps the * old minimal env binding for card experiments, but never claims an owner. */ export declare function chatBindingFromEnv(env?: NodeJS.ProcessEnv, startPid?: number): RunChatBinding | undefined; /** * Authorize a non-`new` host mutation against the principal captured when the * grill was born. A workflow started in chat is owned by that exact * (app, chat, caller) tuple; a later message from the session's static owner or * from another participant must not be able to finalize/approve it merely by * knowing the run id. * * Unbound standalone/dev runs remain operable from a standalone CLI. Legacy * bindings without an authenticated owner are also dev-only: an in-session * caller cannot upgrade them into an owned authorization implicitly. */ export declare function assertWorkflowHostCaller(runDir: string, current: RunChatBinding | undefined): void; export interface SpecFinalizeOutcome { ok: boolean; state?: GrillState; /** Present on failure — the parse/validate problems that BLOCK handoff. */ problems?: string[]; } /** Parse + validate spec.md → write spec.json → status=spec_ready. On a * SpecValidationError, returns {ok:false, problems} and leaves status untouched * (grill stays grilling and relays the problems to the user). */ export declare function hostSpecFinalize(runDir: string, now?: Date): SpecFinalizeOutcome; /** gate-1: spec_ready → spec_approved. Rejects unless status is spec_ready. */ export declare function hostApproveSpec(runDir: string, now?: Date): GrillState; export interface ArchitectDeps { runArchitect: (input: RunArchitectInput) => Promise; /** Throws on an invalid dag (dag.ts loadDag). */ loadDag: (path: string) => unknown; botSnapshot: BotSnapshot; resolveLarkAppSecret: (larkAppId: string) => string | undefined | Promise; timeoutMs?: number; cancelSignal?: AbortSignal; } export interface ArchitectOutcome { ok: boolean; state: GrillState; problems?: string[]; } /** * spec_approved → architect_running → runArchitect → host loadDag/validateDag. * Encodes codex's three assertions: * 1. rejects unless status=spec_approved (don't skip gate-1); * 2. runArchitect-fail OR validateDag-fail → retreat to spec_approved with the * problems recorded in grill.state.json (so grill can fix the spec) — NOT * dag_ready; * 3. on success → dag_ready records dagPath/notesPath/architectManifestPath so * approve-dag and the dashboard never re-guess paths. */ export declare function hostArchitect(runDir: string, deps: ArchitectDeps, now?: Date): Promise; /** gate-2: dag_ready → dag_approved. Returns the recorded dagPath for the * runner. A dag_approved retry is accepted only with its valid ad-hoc envelope. */ export declare function hostApproveDag(runDir: string, now?: Date): { state: GrillState; dagPath: string; }; export interface AdHocRunAuthorizationResult { dagPath: string; envelope: V3AdHocRunEnvelope; publication: PublishRunEnvelopeResult; } /** * Materialize Gate-2's immutable execution artifacts and publish `run.json`. * This must run BEFORE the grill transitions to `dag_approved`: if the process * crashes between the two writes, retrying approval verifies/reuses the * existing envelope and then finishes the conversation-state transition. */ export declare function authorizeAdHocRun(runDir: string, bots: BotConfig[], now?: Date): AdHocRunAuthorizationResult; /** * 改稿·改需求:把任一 grilling 之后的阶段退回 `grilling`,并清掉已失效的 * architect 产物(dagPath/notesPath/architectManifestPath)+ problems,让用户 * 重新 grill / 改 spec.md 再 finalize。改需求意味着已编排的 DAG 作废,所以这里 * 必须把那些指针清空,否则后续 approve-dag / dashboard 会拿到过期的 dag * (codex review 2026-06-02). 从 `grilling`(无可退)和 `dag_approved`(已交 * runtime)拒绝。 */ export declare function hostReviseSpec(runDir: string, now?: Date): GrillState; /** * 改稿·只改流程:需求没变、只是 DAG 编得不满意时,从 `dag_ready` 退回 * `spec_approved` 并清掉 stale 的 dag 产物,使 `architect` 在同一份已批准 spec * 上重编一张,不必重新 grill。 */ export declare function hostReviseDag(runDir: string, now?: Date): GrillState; export declare class HostGuardError extends Error { constructor(message: string); } /** * `botmux workflow ` host-controller subcommands. Dispatched from * `cmdWorkflow` for the v3-specific verbs (new/spec-finalize/approve-spec/ * architect/approve-dag); v0.2 verbs (run/create/validate/…) stay in workflow.ts. */ export interface WorkflowHostCommandDeps { loadBots?: () => BotConfig[]; /** Test/dev seam; production resolves fresh current-turn provenance. */ resolveChatBinding?: () => RunChatBinding | undefined; } export declare function cmdWorkflowHost(sub: string, rest: string[], deps?: WorkflowHostCommandDeps): Promise; /** True when `sub` is a v3 host-controller verb (so cmdWorkflow routes here). */ export declare function isHostSub(sub: string): boolean; /** Resolve real bot/secret deps and run the architect step. */ export declare function resolveArchitectBotSnapshot(runDir: string, bots: BotConfig[], explicitSelector?: string, workingDirOverride?: string): BotSnapshot; //# sourceMappingURL=host.d.ts.map