import { type BackgroundToolTaskRef } from "../background-tool-task-controller.ts"; import { type GoalEvidenceKind, type GoalState } from "./goal-state.ts"; /** * Agent-facing goal ledger actions. * * This is the producer half of the goal continuation pipeline: the agent records * what it is trying to achieve and how far it has gotten, and those records become * the {@link GoalState} snapshots that the runtime continuation consumer reads. * * Each action maps onto either {@link createGoalState} or a single * {@link GoalEvent}, so the durable state model stays the single source of truth. */ export type GoalAction = { action: "start"; goalId: string; userGoal: string; tokenBudget?: number; } | { action: "add_requirement"; requirementId: string; text: string; dependencies?: readonly string[]; } | { action: "satisfy_requirement"; requirementId: string; evidenceIds?: readonly string[]; } | { action: "block_requirement"; requirementId: string; reason: string; } | { action: "reopen_requirement"; requirementId: string; } | { action: "dispatch_worker"; requirementId: string; instructions: string; /** * LaneId returned by the tool layer's dispatch side effect (calling the real worker/tmux * dispatch). Computed by the tool layer -- which has session/runtime access -- and merged * onto the action before it reaches this pure reducer, exactly like `add_evidence`'s * `verified` field. Undefined when the dispatch side effect is unwired/stubbed. */ laneId?: string; } | { action: "add_evidence"; evidenceId: string; kind: GoalEvidenceKind; summary: string; uri?: string; /** * Whether `uri` was checked against session records/the filesystem. Computed by the * tool layer (which has session/filesystem access); `applyGoalAction` stays pure and * only carries this value through into the recorded {@link GoalEvidenceRef}. */ verified?: boolean; } | { action: "progress"; } | { action: "no_progress"; } | { action: "complete"; } | { action: "increment"; } | { action: "block_goal"; reason: string; }; export type GoalActionName = GoalAction["action"]; export interface GoalActionSuccess { ok: true; state: GoalState; } export interface GoalActionFailure { ok: false; error: string; } export type GoalActionResult = GoalActionSuccess | GoalActionFailure; export interface ApplyGoalActionOptions { /** * Gate agent-facing 'complete' on every satisfied requirement being backed by * verified-ref evidence (kind 'tool'/'file' with `verified === true`) or kind 'user' * evidence. Defaults to `true` (on) when omitted — the conservative default. Manual * completion ({@link completeGoalManually}) is never subject to this gate. */ requireVerifiedEvidenceForCompletion?: boolean; /** * Open (non-terminal) task_steps on this branch. Agent-facing complete refuses while any remain. */ openTaskSteps?: readonly OpenTaskStepRef[]; /** Live background tool_task records used to gate goal-owned work and re-check tool evidence. */ backgroundToolTasks?: readonly BackgroundToolTaskRef[]; /** Active ICM pipeline run; agent complete refuses while any active run remains. */ activePipeline?: { runId: string; pipelineName: string; goalId?: string; status: string; }; /** Queued/running worker lanes owned by this goal or bound to one of its requirements. */ activeGoalLaneIds?: readonly string[]; } /** * Apply one agent-facing goal action to the current ledger state. * * Pure: takes the current state (or `undefined` when no goal exists yet) and the * action, and returns either the next state or a validation error. Performs no * I/O and never mutates its inputs. */ export declare function applyGoalAction(current: GoalState | undefined, action: GoalAction, now: string, options?: ApplyGoalActionOptions): GoalActionResult; /** * Complete a goal on explicit user authority, even when requirements remain open or * blocked. Agent-facing `complete` stays evidence-gated; this path is reserved for * direct user lifecycle controls. */ export declare function completeGoalManually(current: GoalState | undefined, now: string): GoalActionResult; /** Render a compact human-readable summary of the ledger after an action. */ export declare function summarizeGoalState(state: GoalState, options?: { action?: GoalAction; openTaskSteps?: readonly OpenTaskStepRef[]; }): string; /** * Read-only goal⇄task cross-visibility (bounded slice — no shared state machine). * * `goal-tool-core` never reads or mutates task state itself (it stays pure); callers that DO * have access to the branch-scoped open task steps (e.g. via `buildGoalRuntimeSnapshot`) may * pass them through here to surface a nudge in the tool response when an open task_steps step is * explicitly linked to, or conservatively appears to reference, a requirement the agent just * satisfied or completed. Task state is never written from goal code — this only reads an * already-resolved, caller-supplied summary. */ export interface OpenTaskStepRef { id: string; content: string; requirementIds?: readonly string[]; evidence?: readonly string[]; pipelineRunId?: string; pipelineStageId?: string; } /** * Nudge lines for open task steps that reference any of `requirementIds` (deduped per * requirement, one line naming every referencing step). Empty when there is nothing to say. */ export declare function findRequirementCrossReferenceNudges(state: GoalState, requirementIds: readonly string[], openTaskSteps: readonly OpenTaskStepRef[]): string[]; /** * After 'satisfy_requirement' or 'complete', nudge lines for linked open task steps. Returns `[]` * for every other action, or when * `openTaskSteps` was not supplied (the default -- backward compatible, no behavior change for * callers that do not pass task-step context). */ export declare function buildGoalTaskCrossVisibilityNudges(action: GoalAction, state: GoalState, openTaskSteps: readonly OpenTaskStepRef[] | undefined): string[]; //# sourceMappingURL=goal-tool-core.d.ts.map