import { type GuardedWriteResult } from "../gjc-runtime/state-writer"; import { CANONICAL_GJC_WORKFLOW_SKILLS, type CanonicalGjcWorkflowSkill } from "./canonical-skills"; import type { WorkflowStateReceipt } from "./workflow-state-contract"; export declare const SKILL_ACTIVE_STATE_FILE = "skill-active-state.json"; export { CANONICAL_GJC_WORKFLOW_SKILLS, type CanonicalGjcWorkflowSkill }; export type WorkflowHudSeverity = "info" | "warning" | "blocked" | "error" | "success"; export interface WorkflowHudChip { label: string; value?: string; priority?: number; severity?: WorkflowHudSeverity; } export interface WorkflowHudSummary { version: 1; summary?: string; chips?: WorkflowHudChip[]; details?: WorkflowHudChip[]; severity?: WorkflowHudSeverity; updated_at?: string; } export type { WorkflowStateReceipt } from "./workflow-state-contract"; export interface ActiveSubskillToolReference { extensionId: string; expectedDigest: string; } export interface ActiveSubskillEntry { plugin: string; subskillName: string; parent: string; bindsTo: string; phase: string; activationArg: string; /** Registry identity required for persisted v2 activation. */ scope?: "user" | "project"; extensionId?: string; expectedDigest?: string; toolRefs?: ActiveSubskillToolReference[]; /** Legacy paths are accepted only in transient in-memory values; persisted readers reject them. */ filePath?: string; toolPaths?: string[]; } export interface SkillActiveEntry { skill: string; phase?: string; active?: boolean; activated_at?: string; updated_at?: string; session_id?: string; thread_id?: string; turn_id?: string; hud?: WorkflowHudSummary; stale?: boolean; receipt?: WorkflowStateReceipt; handoff_from?: string; handoff_to?: string; handoff_at?: string; active_subskills?: ActiveSubskillEntry[]; source_state_revision?: number; } export interface SkillActiveState { version?: number; active?: boolean; skill?: string; keyword?: string; phase?: string; activated_at?: string; updated_at?: string; source?: string; session_id?: string; thread_id?: string; turn_id?: string; initialized_mode?: CanonicalGjcWorkflowSkill; initialized_state_path?: string; active_skills?: SkillActiveEntry[]; active_subskills?: ActiveSubskillEntry[]; [key: string]: unknown; } export interface SkillActiveStatePaths { rootPath: string; sessionPath: string; } export interface SyncSkillActiveStateOptions { cwd: string; skill: string; active: boolean; phase?: string; sessionId?: string; threadId?: string; turnId?: string; nowIso?: string; source?: string; hud?: WorkflowHudSummary; receipt?: WorkflowStateReceipt; handoff_from?: string; handoff_to?: string; handoff_at?: string; active_subskills?: ActiveSubskillEntry[]; sourceRevision?: number; /** Internal seed path: retain the authoritative entry receipt if snapshot rebuilding fails. */ bestEffortSnapshot?: boolean; } export declare function normalizeWorkflowHudSummary(raw: unknown): WorkflowHudSummary | undefined; export declare function isCanonicalGjcWorkflowSkill(skill: string): skill is CanonicalGjcWorkflowSkill; /** * Continuation inertness for compaction auto-continue, derived from each * workflow's manifest contract: manifest-terminal and explicitly inert phases * are inert; unknown skills or phases unknown to the skill's manifest are * conservatively inert so a synthetic continuation never wakes an unrecognized * workflow. Generic Ultragoal `blocked` remains continuation-active because its * blocker may be autonomously resolvable; verified human pauses are represented * by the inline goal's `paused` status instead. */ export declare function isWorkflowContinuationInert(skill: string, phase: string): boolean; export declare function listActiveSkills(raw: unknown): SkillActiveEntry[]; export declare function normalizeSkillActiveState(raw: unknown): SkillActiveState | null; export declare function getSkillActiveStatePaths(cwd: string, sessionId?: string): SkillActiveStatePaths; export declare function upstreamPlanningPipelineSkills(skill: string): string[]; export declare function collapsePlanningPipeline(entries: readonly SkillActiveEntry[]): SkillActiveEntry[]; export type VisibleSkillActiveStateCacheTier = "security" | "hud"; export interface ReadVisibleSkillActiveStateOptions { tier?: VisibleSkillActiveStateCacheTier; /** Bypass all signature/TTL caches for authorization decisions. */ bypassCache?: boolean; } interface ActiveStateStatSignature { path: string; mtimeMs: number; size: number; } interface ActiveStateSignature { sessionPath: ActiveStateStatSignature | null; activeDir: ActiveStateStatSignature | null; activeEntries: ActiveStateStatSignature[]; ralplanModeState: ActiveStateStatSignature | null; } export declare function computeActiveStateSignature(cwd: string, sessionId: string): Promise; export declare function invalidateVisibleSkillActiveStateCache(cwd?: string, sessionId?: string): void; export declare function readVisibleSkillActiveState(cwd: string, sessionId?: string, opts?: ReadVisibleSkillActiveStateOptions): Promise; export declare function syncSkillActiveState(options: SyncSkillActiveStateOptions): Promise; export interface ApplyHandoffOptions { cwd: string; caller: SyncSkillActiveStateOptions; callee: SyncSkillActiveStateOptions; /** Shared timestamp; falls back to new Date().toISOString(). */ nowIso?: string; /** When true, read errors other than ENOENT propagate. */ strict?: boolean; } /** * Atomically apply a workflow-skill handoff to the session-scoped active state. */ export declare function applyHandoffToActiveState(options: ApplyHandoffOptions): Promise;