export type GoalStatus = "active" | "paused" | "blocked" | "usage_limited" | "budget_limited" | "completed" | "cancelled"; export type RequirementStatus = "open" | "satisfied" | "blocked"; export type GoalEvidenceKind = "file" | "test" | "tool" | "user" | "finding" | "worker"; export declare const MAX_GOAL_OBJECTIVE_LENGTH = 4000; export declare const MAX_GOAL_EVENT_HISTORY = 128; /** One shared lifecycle classification for tools, runtime, persistence, and UI. */ export declare function isGoalExecutionActive(status: GoalStatus): boolean; export declare function isGoalResumableStatus(status: GoalStatus): boolean; export declare function isGoalTerminalStatus(status: GoalStatus): boolean; export declare function isGoalUnfinishedStatus(status: GoalStatus): boolean; export interface GoalState { goalId: string; userGoal: string; status: GoalStatus; /** Monotonic state revision used by compare-and-append persistence. Legacy snapshots start at 0. */ revision?: number; /** Monotonic meaningful-progress revision used by the continuation stall gate. */ progressRevision?: number; /** Optional owner-requested ceiling using the shared cache-discounted token-budget accounting. */ tokenBudget?: number; /** Budget-counted usage attributed to all goal-owned foreground execution. */ tokensUsed?: number; requirements: readonly Requirement[]; evidence: readonly GoalEvidenceRef[]; events: readonly GoalEvent[]; createdAt: string; updatedAt: string; lastProgressAt: string; stallTurns: number; blockedReason?: string; /** * Cumulative continuation turns submitted for this goal across EVERY `continueGoalLoop` * invocation for its lifetime (idle-driven auto-continues and manual continues alike) — * durable via goal-state persistence, so it survives process restarts and idle cycles. * Optional because snapshots persisted before this field existed carry no value; treat * `undefined` as `0` everywhere it is read. */ continuationTurnsUsed?: number; /** * Observed cumulative ACTIVE wall-clock milliseconds spent running continuation passes for this goal — * the sum of each individual pass's own await duration, NOT wall-clock time elapsed between * passes or during idle gaps. Same backward-compat/undefined-as-0 note as `continuationTurnsUsed`. */ continuationWallClockMs?: number; /** * Observed cumulative USD attributed to this goal's own foreground provider responses. Deliberately * excludes worker/subagent spend, which is reported separately. Same backward-compat note. */ continuationSpendUsd?: number; /** * Observed cumulative USD attributed to WORKER/SUBAGENT spend for this goal's lanes (in-process worker * usage via `addSpawnedUsage`, out-of-process tmux-worker usage via the advisory * `reportSpawnedUsage` claim) — the counterpart this goal's OWN model spend excludes (see * {@link continuationSpendUsd}). Populated by the runtime that sums lane spend by goalId; this * field is only the durable slot. Same backward-compat/undefined-as-0 note as the other * continuation accounting fields. This is advisory telemetry, not an implicit execution limit. */ continuationWorkerSpendUsd?: number; /** Durable acceptance override; avoids depending on an unbounded historical event scan. */ acceptanceOverride?: boolean; } export interface Requirement { id: string; text: string; status: RequirementStatus; evidenceIds: readonly string[]; blockedReason?: string; createdAt: string; updatedAt: string; /** * LaneId of a worker dispatched against this requirement (set by the `dispatch_worker` event). * Recording a binding never satisfies the requirement by itself -- the worker's own completion * later populates `"worker"`-kind evidence and prompts an explicit `satisfy_requirement` pass. */ boundLaneId?: string; /** * IDs of other requirements that must be satisfied before this requirement can be worked on. * Implementing this native graph tracking allows the orchestrator to automatically sequence subagent delegations. */ dependencies?: readonly string[]; /** * ISO timestamp of the moment `boundLaneId` was most recently bound to a REAL lane -- the clock * the never-hang wait-timeout (`evaluateGoalContinuation`'s `worker_wait_timeout` reasonCode) * reads to detect a worker that has hung past `maxWorkerWaitMs`. Stamped ONLY when a * `dispatch_worker` event carries a lane id; a declined dispatch (no lane) leaves this field * untouched, so no clock starts for a worker that never actually launched. */ boundAt?: string; } export interface GoalEvidenceRef { id: string; kind: GoalEvidenceKind; summary: string; uri?: string; /** * Whether `uri` was checked against session records ("tool" evidence, a toolCallId) or the * filesystem ("file" evidence, a path) at add_evidence time. `true`/`false` only when the * ref was checkable; `undefined` when the evidence kind carries no checkable ref (e.g. * "user"/"finding"/"test", or a "tool"/"file" entry with no `uri`). */ verified?: boolean; createdAt: string; } export type GoalEvent = { type: "edit_goal"; userGoal: string; tokenBudget?: number; now: string; } | { type: "add_requirement"; id: string; text: string; dependencies?: readonly string[]; now: string; } | { type: "satisfy_requirement"; id: string; evidenceIds: readonly string[]; now: string; } | { type: "block_requirement"; id: string; blockedReason: string; now: string; } | { type: "reopen_requirement"; id: string; now: string; } | { type: "dispatch_worker"; /** Requirement id the worker is bound to. */ id: string; /** Instructions the worker was (or will be) dispatched with. */ instructions: string; /** * LaneId returned by the tool-layer dispatch side effect. Undefined when that side effect * is unwired/stubbed -- the binding is then recorded with no lane target yet. */ laneId?: string; now: string; } | { type: "add_evidence"; id: string; kind: GoalEvidenceKind; summary: string; uri?: string; /** See {@link GoalEvidenceRef.verified}; computed by the tool layer before the event is applied. */ verified?: boolean; now: string; } | { type: "progress"; now: string; } | { type: "no_progress"; now: string; } | { type: "record_continuation_budget"; /** Turns submitted in this pass (currently always 1 — the loop calls once per submitted pass). */ turns: number; /** This pass's own active wall-clock duration, in milliseconds. */ wallClockMs: number; /** Budget-counted provider usage; cache reads use the shared lean-budget weight. */ tokens: number; /** Exact model spend attributed to the goal-owned execution. */ spendUsd: number; now: string; } | { type: "complete_goal"; acceptanceOverride?: boolean; now: string; } | { type: "complete_goal_manually"; now: string; } | { type: "block_goal"; reason: string; now: string; } | { type: "pause_goal"; now: string; } | { type: "resume_goal"; now: string; } | { type: "system_stop_goal"; status: "blocked" | "usage_limited" | "budget_limited"; reason: string; now: string; } | { type: "cancel_goal"; now: string; }; export declare function isGoalEvent(value: unknown): value is GoalEvent; export declare function isGoalState(value: unknown): value is GoalState; export declare function cloneGoalEventForStorage(event: GoalEvent): GoalEvent; export declare function cloneGoalStateForStorage(state: GoalState): GoalState; export declare function createGoalState(args: { goalId: string; userGoal: string; now: string; tokenBudget?: number; }): GoalState; export declare function applyGoalEvent(state: GoalState, event: GoalEvent): GoalState; export declare function shouldContinueGoalLoop(args: { state: GoalState; maxStallTurns: number; now: string; }): boolean; export declare function serializeGoalState(state: GoalState): string; export declare function parseGoalState(text: string): GoalState | undefined; //# sourceMappingURL=goal-state.d.ts.map