stageflow 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/dist/agent/activity.d.ts +76 -0
  4. package/dist/agent/activity.js +89 -0
  5. package/dist/agent/activityObserver.d.ts +17 -0
  6. package/dist/agent/activityObserver.js +66 -0
  7. package/dist/agent/cursorExtension.d.ts +12 -0
  8. package/dist/agent/cursorExtension.js +88 -0
  9. package/dist/agent/cursorProvider.d.ts +14 -0
  10. package/dist/agent/cursorProvider.js +139 -0
  11. package/dist/agent/fakeAgent.d.ts +29 -0
  12. package/dist/agent/fakeAgent.js +295 -0
  13. package/dist/agent/oauthSessionManager.d.ts +33 -0
  14. package/dist/agent/oauthSessionManager.js +214 -0
  15. package/dist/agent/piAdapter.d.ts +128 -0
  16. package/dist/agent/piAdapter.js +967 -0
  17. package/dist/agent/port.d.ts +63 -0
  18. package/dist/agent/port.js +46 -0
  19. package/dist/agent/providerAuth.d.ts +101 -0
  20. package/dist/agent/providerAuth.js +282 -0
  21. package/dist/agent/providerSupport.d.ts +28 -0
  22. package/dist/agent/providerSupport.js +19 -0
  23. package/dist/cli/providersCommand.d.ts +11 -0
  24. package/dist/cli/providersCommand.js +275 -0
  25. package/dist/cli/terminalAuthInteraction.d.ts +8 -0
  26. package/dist/cli/terminalAuthInteraction.js +65 -0
  27. package/dist/cli/terminalSecret.d.ts +2 -0
  28. package/dist/cli/terminalSecret.js +67 -0
  29. package/dist/cli/validateCommand.d.ts +11 -0
  30. package/dist/cli/validateCommand.js +81 -0
  31. package/dist/cli/validateOutput.d.ts +8 -0
  32. package/dist/cli/validateOutput.js +75 -0
  33. package/dist/cli.d.ts +2 -0
  34. package/dist/cli.js +273 -0
  35. package/dist/config/createPipeline.d.ts +31 -0
  36. package/dist/config/createPipeline.js +255 -0
  37. package/dist/config/createStage.d.ts +25 -0
  38. package/dist/config/createStage.js +181 -0
  39. package/dist/config/listConfig.d.ts +33 -0
  40. package/dist/config/listConfig.js +195 -0
  41. package/dist/config/listExtensions.d.ts +26 -0
  42. package/dist/config/listExtensions.js +50 -0
  43. package/dist/config/listSkills.d.ts +29 -0
  44. package/dist/config/listSkills.js +55 -0
  45. package/dist/config/loadOutcome.d.ts +27 -0
  46. package/dist/config/loadOutcome.js +6 -0
  47. package/dist/config/loadPipeline.d.ts +25 -0
  48. package/dist/config/loadPipeline.js +196 -0
  49. package/dist/config/loadStage.d.ts +4 -0
  50. package/dist/config/loadStage.js +127 -0
  51. package/dist/config/loadTask.d.ts +7 -0
  52. package/dist/config/loadTask.js +69 -0
  53. package/dist/config/readYamlObject.d.ts +1 -0
  54. package/dist/config/readYamlObject.js +5 -0
  55. package/dist/config/resolvePipelineDag.d.ts +12 -0
  56. package/dist/config/resolvePipelineDag.js +282 -0
  57. package/dist/config/validateCatalog.d.ts +36 -0
  58. package/dist/config/validateCatalog.js +322 -0
  59. package/dist/envelope/check.d.ts +3 -0
  60. package/dist/envelope/check.js +52 -0
  61. package/dist/envelope/payloadSchema.d.ts +10 -0
  62. package/dist/envelope/payloadSchema.js +91 -0
  63. package/dist/hitl/qaTrail.d.ts +31 -0
  64. package/dist/hitl/qaTrail.js +65 -0
  65. package/dist/index.d.ts +13 -0
  66. package/dist/index.js +7 -0
  67. package/dist/mcp/projectRun.d.ts +37 -0
  68. package/dist/mcp/projectRun.js +57 -0
  69. package/dist/mcp/readArtifact.d.ts +2 -0
  70. package/dist/mcp/readArtifact.js +46 -0
  71. package/dist/mcp/server.d.ts +7 -0
  72. package/dist/mcp/server.js +26 -0
  73. package/dist/mcp/tools.d.ts +9 -0
  74. package/dist/mcp/tools.js +96 -0
  75. package/dist/package-meta.d.ts +1 -0
  76. package/dist/package-meta.js +1 -0
  77. package/dist/prompt/priorEnvelope.d.ts +2 -0
  78. package/dist/prompt/priorEnvelope.js +5 -0
  79. package/dist/runstore/catalog.d.ts +8 -0
  80. package/dist/runstore/catalog.js +16 -0
  81. package/dist/runstore/createStore.d.ts +15 -0
  82. package/dist/runstore/createStore.js +23 -0
  83. package/dist/runstore/disk/DiskRunStore.d.ts +30 -0
  84. package/dist/runstore/disk/DiskRunStore.js +238 -0
  85. package/dist/runstore/disk/catalogHelpers.d.ts +11 -0
  86. package/dist/runstore/disk/catalogHelpers.js +102 -0
  87. package/dist/runstore/layout.d.ts +22 -0
  88. package/dist/runstore/layout.js +58 -0
  89. package/dist/runstore/paths.d.ts +7 -0
  90. package/dist/runstore/paths.js +60 -0
  91. package/dist/runstore/pipelineDagSnapshot.d.ts +5 -0
  92. package/dist/runstore/pipelineDagSnapshot.js +43 -0
  93. package/dist/runstore/port.d.ts +146 -0
  94. package/dist/runstore/port.js +28 -0
  95. package/dist/runstore/runProjection.d.ts +6 -0
  96. package/dist/runstore/runProjection.js +102 -0
  97. package/dist/runstore/sqlite/SqliteRunStore.d.ts +48 -0
  98. package/dist/runstore/sqlite/SqliteRunStore.js +460 -0
  99. package/dist/runstore/sqlite/migrateFromDisk.d.ts +5 -0
  100. package/dist/runstore/sqlite/migrateFromDisk.js +108 -0
  101. package/dist/runstore/sqlite/schema.d.ts +1 -0
  102. package/dist/runstore/sqlite/schema.js +59 -0
  103. package/dist/runstore/stageExecution.d.ts +13 -0
  104. package/dist/runstore/stageExecution.js +22 -0
  105. package/dist/runstore/stageSnapshot.d.ts +2 -0
  106. package/dist/runstore/stageSnapshot.js +46 -0
  107. package/dist/runstore/syntheticStageSnapshot.d.ts +2 -0
  108. package/dist/runstore/syntheticStageSnapshot.js +10 -0
  109. package/dist/runstore/trackProjection.d.ts +7 -0
  110. package/dist/runstore/trackProjection.js +94 -0
  111. package/dist/runstore/workspaceLayout.d.ts +31 -0
  112. package/dist/runstore/workspaceLayout.js +172 -0
  113. package/dist/runtime/answerResume.d.ts +16 -0
  114. package/dist/runtime/answerResume.js +22 -0
  115. package/dist/runtime/credentialBinding.d.ts +16 -0
  116. package/dist/runtime/credentialBinding.js +80 -0
  117. package/dist/runtime/dagTraversal.d.ts +3 -0
  118. package/dist/runtime/dagTraversal.js +26 -0
  119. package/dist/runtime/envelopeRouting.d.ts +20 -0
  120. package/dist/runtime/envelopeRouting.js +59 -0
  121. package/dist/runtime/hitlSeams.d.ts +38 -0
  122. package/dist/runtime/hitlSeams.js +2 -0
  123. package/dist/runtime/pipelineRunner.d.ts +77 -0
  124. package/dist/runtime/pipelineRunner.js +141 -0
  125. package/dist/runtime/pipelineScheduler.d.ts +90 -0
  126. package/dist/runtime/pipelineScheduler.js +494 -0
  127. package/dist/runtime/pipelineValidationError.d.ts +6 -0
  128. package/dist/runtime/pipelineValidationError.js +8 -0
  129. package/dist/runtime/resumeReconstruct.d.ts +33 -0
  130. package/dist/runtime/resumeReconstruct.js +144 -0
  131. package/dist/runtime/runManager.d.ts +129 -0
  132. package/dist/runtime/runManager.js +818 -0
  133. package/dist/runtime/runRetryCoordinator.d.ts +85 -0
  134. package/dist/runtime/runRetryCoordinator.js +372 -0
  135. package/dist/runtime/settingsFile.d.ts +17 -0
  136. package/dist/runtime/settingsFile.js +88 -0
  137. package/dist/runtime/stageAttemptBootstrap.d.ts +40 -0
  138. package/dist/runtime/stageAttemptBootstrap.js +82 -0
  139. package/dist/runtime/stageAttemptContext.d.ts +11 -0
  140. package/dist/runtime/stageAttemptContext.js +26 -0
  141. package/dist/runtime/stageConcurrency.d.ts +10 -0
  142. package/dist/runtime/stageConcurrency.js +51 -0
  143. package/dist/runtime/stageHitl.d.ts +95 -0
  144. package/dist/runtime/stageHitl.js +198 -0
  145. package/dist/runtime/stageProcessLauncher.d.ts +45 -0
  146. package/dist/runtime/stageProcessLauncher.js +199 -0
  147. package/dist/runtime/stageRecovery.d.ts +10 -0
  148. package/dist/runtime/stageRecovery.js +43 -0
  149. package/dist/runtime/stageRoots.d.ts +22 -0
  150. package/dist/runtime/stageRoots.js +93 -0
  151. package/dist/runtime/stageRunner.d.ts +59 -0
  152. package/dist/runtime/stageRunner.js +221 -0
  153. package/dist/runtime/stageWorker.d.ts +6 -0
  154. package/dist/runtime/stageWorker.js +109 -0
  155. package/dist/runtime/stageWorkerProtocol.d.ts +27 -0
  156. package/dist/runtime/stageWorkerProtocol.js +16 -0
  157. package/dist/runtime/taskInput.d.ts +15 -0
  158. package/dist/runtime/taskInput.js +38 -0
  159. package/dist/server/http.d.ts +31 -0
  160. package/dist/server/http.js +561 -0
  161. package/dist/server/providerRoutes.d.ts +15 -0
  162. package/dist/server/providerRoutes.js +186 -0
  163. package/dist/tools/askOperator.d.ts +185 -0
  164. package/dist/tools/askOperator.js +409 -0
  165. package/dist/tools/emitStageEnvelope.d.ts +42 -0
  166. package/dist/tools/emitStageEnvelope.js +61 -0
  167. package/dist/tools/writeStageArtifact.d.ts +26 -0
  168. package/dist/tools/writeStageArtifact.js +103 -0
  169. package/dist/types/envelope.d.ts +12 -0
  170. package/dist/types/envelope.js +6 -0
  171. package/dist/types/pipeline.d.ts +25 -0
  172. package/dist/types/pipeline.js +1 -0
  173. package/dist/types/stage.d.ts +12 -0
  174. package/dist/types/stage.js +6 -0
  175. package/dist/types/task.d.ts +7 -0
  176. package/dist/types/task.js +1 -0
  177. package/dist/ui/assets/index-Cry0Tpfx.js +118 -0
  178. package/dist/ui/assets/index-DCsDopak.css +1 -0
  179. package/dist/ui/index.html +21 -0
  180. package/package.json +72 -0
@@ -0,0 +1,146 @@
1
+ import type { StageLogLine } from "../agent/activity.js";
2
+ import type { AskOperatorPrompt } from "../tools/askOperator.js";
3
+ import type { StageEnvelope } from "../types/envelope.js";
4
+ import type { ResolvedPipelineDag } from "../types/pipeline.js";
5
+ import type { StageGateKind } from "../types/stage.js";
6
+ export type RunStatus = "created" | "running" | "succeeded" | "failed";
7
+ export type RunPipelineDagSnapshot = ResolvedPipelineDag & {
8
+ stage_ids: string[];
9
+ gate_kinds?: Record<string, StageGateKind[]>;
10
+ };
11
+ export type StageReadiness = "blocked" | "ready" | "running" | "waiting" | "succeeded" | "failed" | "skipped";
12
+ export type PipelineTrackNode = {
13
+ stage_id: string;
14
+ status: StageSnapshot["status"];
15
+ readiness: StageReadiness;
16
+ layer: number;
17
+ layer_order: number;
18
+ blocked_by?: string[];
19
+ gate_kinds?: StageGateKind[];
20
+ attempt_count?: number;
21
+ };
22
+ export type PipelineTrackEdge = {
23
+ from: string;
24
+ to: string;
25
+ envelope_summary?: string;
26
+ };
27
+ export type PipelineTrackProjection = {
28
+ nodes: PipelineTrackNode[];
29
+ edges: PipelineTrackEdge[];
30
+ };
31
+ export type RunMeta = {
32
+ run_id: string;
33
+ pipeline_id: string;
34
+ created_at: string;
35
+ status?: RunStatus;
36
+ task_id?: string;
37
+ updated_at?: string;
38
+ checkout_root?: string;
39
+ pipeline_dag?: RunPipelineDagSnapshot;
40
+ };
41
+ export type CreatedRun = {
42
+ runId: string;
43
+ /** Opaque agent workspace path (artifacts live under this tree). */
44
+ workspaceDir: string;
45
+ };
46
+ /** Persisted stage log line (activity or lifecycle) with optional timestamp. */
47
+ export type StageLogEvent = StageLogLine & {
48
+ at?: string;
49
+ };
50
+ export type StageSnapshot = {
51
+ stage_id: string;
52
+ status: "pending" | "running" | "waiting_for_input" | "succeeded" | "failed";
53
+ events: StageLogEvent[];
54
+ envelope: StageEnvelope | null;
55
+ artifacts: string[];
56
+ last_at?: string;
57
+ pending_prompt?: AskOperatorPrompt;
58
+ attempt_count: number;
59
+ };
60
+ export type StageExecution = {
61
+ run_id: string;
62
+ stage_id: string;
63
+ attempt: number;
64
+ status: StageSnapshot["status"];
65
+ started_at?: string;
66
+ finished_at?: string;
67
+ envelope: StageEnvelope | null;
68
+ };
69
+ export type StageExecutionPatch = {
70
+ status?: StageSnapshot["status"];
71
+ started_at?: string;
72
+ finished_at?: string;
73
+ envelope?: StageEnvelope | null;
74
+ };
75
+ export type CompactStage = {
76
+ id: string;
77
+ status: StageSnapshot["status"];
78
+ attempt_count: number;
79
+ };
80
+ export type RunSummary = {
81
+ run_id: string;
82
+ pipeline_id: string;
83
+ task_id?: string;
84
+ status: RunStatus;
85
+ created_at: string;
86
+ updated_at?: string;
87
+ stages: CompactStage[];
88
+ /** Present when a stage is waiting_for_input (first such stage). */
89
+ waiting_stage_id?: string;
90
+ /** All stages waiting_for_input in declaration order; omitted when none. */
91
+ waiting_stage_ids?: string[];
92
+ /** Short prompt text for Today triage; omitted when not waiting. */
93
+ waiting_summary?: string;
94
+ waiting_kind?: AskOperatorPrompt["kind"];
95
+ waiting_prompt_id?: string;
96
+ waiting_artifacts?: string[];
97
+ waiting_questions?: string[];
98
+ failed_stage_id?: string;
99
+ failed_reason?: string;
100
+ };
101
+ export type RunDetail = Omit<RunSummary, "stages"> & {
102
+ task_yaml: string;
103
+ stages: StageSnapshot[];
104
+ pipeline_track: PipelineTrackProjection;
105
+ };
106
+ export type CreateRunInput = {
107
+ pipelineId: string;
108
+ taskYaml: string;
109
+ taskId?: string;
110
+ checkoutRoot?: string;
111
+ pipelineDag?: RunPipelineDagSnapshot;
112
+ };
113
+ /**
114
+ * Persistence port for pipeline run state.
115
+ * Call sites should prefer CreatedRun.workspaceDir from createRun over
116
+ * getWorkspaceDir; the latter returns the opaque run workspace root when a
117
+ * run id is all you have (catalog / rehydrate).
118
+ */
119
+ export interface RunStore {
120
+ createRun(input: CreateRunInput): Promise<CreatedRun>;
121
+ updateRunStatus(runId: string, status: RunStatus): Promise<void>;
122
+ readRunMeta(runId: string): Promise<RunMeta>;
123
+ readTaskYaml(runId: string): Promise<string>;
124
+ /** Opaque run workspace root for agents and artifact tools. */
125
+ getWorkspaceDir(runId: string): string;
126
+ ensureStageWorkspace(runId: string, stageId: string): Promise<void>;
127
+ ensureAttemptWorkspace(runId: string, stageId: string, attempt: number): Promise<void>;
128
+ createStageExecution(runId: string, stageId: string): Promise<StageExecution>;
129
+ listStageExecutions(runId: string, stageId: string): Promise<StageExecution[]>;
130
+ getLatestStageExecution(runId: string, stageId: string): Promise<StageExecution | null>;
131
+ countStageAttempts(runId: string, stageId: string): Promise<number>;
132
+ getStageExecution(runId: string, stageId: string, attempt: number): Promise<StageExecution>;
133
+ updateStageExecution(runId: string, stageId: string, attempt: number, patch: StageExecutionPatch): Promise<void>;
134
+ writeEnvelope(runId: string, stageId: string, envelope: StageEnvelope, options?: {
135
+ attempt?: number;
136
+ }): Promise<void>;
137
+ readEnvelope(runId: string, stageId: string): Promise<StageEnvelope>;
138
+ appendStageEvent(runId: string, stageId: string, event: StageLogLine, options?: {
139
+ attempt?: number;
140
+ }): Promise<void>;
141
+ listStageEvents(runId: string, stageId: string, attempt?: number): Promise<StageLogEvent[]>;
142
+ listRuns(): Promise<RunSummary[]>;
143
+ readRun(runId: string): Promise<RunDetail>;
144
+ }
145
+ export declare function stageStatusFromEvents(events: StageLogEvent[]): StageSnapshot["status"];
146
+ export declare function deriveStatusFromStages(stages: StageSnapshot[]): RunStatus;
@@ -0,0 +1,28 @@
1
+ export function stageStatusFromEvents(events) {
2
+ let status = "pending";
3
+ for (const ev of events) {
4
+ if (ev.event === "started" || ev.event === "resumed")
5
+ status = "running";
6
+ if (ev.event === "waiting_for_input")
7
+ status = "waiting_for_input";
8
+ if (ev.event === "succeeded")
9
+ status = "succeeded";
10
+ if (ev.event === "failed")
11
+ status = "failed";
12
+ }
13
+ return status;
14
+ }
15
+ export function deriveStatusFromStages(stages) {
16
+ if (stages.length === 0)
17
+ return "created";
18
+ if (stages.some((s) => s.status === "failed"))
19
+ return "failed";
20
+ if (stages.every((s) => s.status === "succeeded"))
21
+ return "succeeded";
22
+ if (stages.some((s) => s.status === "running" ||
23
+ s.status === "waiting_for_input" ||
24
+ s.status === "succeeded")) {
25
+ return "running";
26
+ }
27
+ return "created";
28
+ }
@@ -0,0 +1,6 @@
1
+ import type { RunDetail, RunMeta, RunPipelineDagSnapshot, RunSummary, StageSnapshot } from "./port.js";
2
+ export { syntheticPendingSnapshot } from "./syntheticStageSnapshot.js";
3
+ export declare function overlayPlannedStages(stageIds: string[], snapshots: StageSnapshot[]): StageSnapshot[];
4
+ export declare function orderStageSnapshots(stageIds: string[], snapshots: StageSnapshot[]): StageSnapshot[];
5
+ export declare function projectRunSummary(meta: RunMeta, stages: StageSnapshot[]): RunSummary;
6
+ export declare function projectRunDetail(meta: RunMeta, stages: StageSnapshot[], task_yaml: string, dagSnapshot?: RunPipelineDagSnapshot | null): RunDetail;
@@ -0,0 +1,102 @@
1
+ import { deriveStatusFromStages } from "./port.js";
2
+ import { linearCompatDagSnapshot } from "./pipelineDagSnapshot.js";
3
+ import { syntheticPendingSnapshot } from "./syntheticStageSnapshot.js";
4
+ import { buildPipelineTrack } from "./trackProjection.js";
5
+ export { syntheticPendingSnapshot } from "./syntheticStageSnapshot.js";
6
+ export function overlayPlannedStages(stageIds, snapshots) {
7
+ const byId = new Map(snapshots.map((s) => [s.stage_id, s]));
8
+ return stageIds.map((id) => byId.get(id) ?? syntheticPendingSnapshot(id));
9
+ }
10
+ export function orderStageSnapshots(stageIds, snapshots) {
11
+ return overlayPlannedStages(stageIds, snapshots);
12
+ }
13
+ function compactStages(stages) {
14
+ return stages.map((s) => ({
15
+ id: s.stage_id,
16
+ status: s.status,
17
+ attempt_count: s.attempt_count,
18
+ }));
19
+ }
20
+ function waitingSummaryFromPrompt(prompt) {
21
+ if (!prompt)
22
+ return "Waiting for input";
23
+ if (prompt.kind === "multi_question") {
24
+ const first = prompt.questions[0]?.message?.trim();
25
+ return first || "Waiting for input";
26
+ }
27
+ const message = prompt.message?.trim();
28
+ return message || "Waiting for input";
29
+ }
30
+ function waitingFieldsFromStages(stages) {
31
+ const waitingStages = stages.filter((s) => s.status === "waiting_for_input");
32
+ if (waitingStages.length === 0)
33
+ return {};
34
+ const waiting = waitingStages[0];
35
+ const prompt = waiting.pending_prompt;
36
+ const fields = {
37
+ waiting_stage_id: waiting.stage_id,
38
+ waiting_stage_ids: waitingStages.map((s) => s.stage_id),
39
+ waiting_summary: waitingSummaryFromPrompt(prompt),
40
+ };
41
+ if (prompt) {
42
+ fields.waiting_kind = prompt.kind;
43
+ fields.waiting_prompt_id = prompt.id;
44
+ if (prompt.kind === "artifact_backed") {
45
+ fields.waiting_artifacts = prompt.artifacts;
46
+ }
47
+ if (prompt.kind === "multi_question") {
48
+ fields.waiting_questions = prompt.questions.map((q) => q.message);
49
+ }
50
+ }
51
+ return fields;
52
+ }
53
+ function failedFieldsFromStages(stages) {
54
+ const failed = stages.find((s) => s.status === "failed");
55
+ if (!failed)
56
+ return {};
57
+ let failed_reason;
58
+ for (const ev of failed.events) {
59
+ if (ev.event === "failed")
60
+ failed_reason = ev.reason;
61
+ }
62
+ return {
63
+ failed_stage_id: failed.stage_id,
64
+ ...(failed_reason !== undefined ? { failed_reason } : {}),
65
+ };
66
+ }
67
+ function resolveListedStatus(stages, meta) {
68
+ const derived = deriveStatusFromStages(stages);
69
+ return stages.length > 0 ? derived : (meta.status ?? derived);
70
+ }
71
+ export function projectRunSummary(meta, stages) {
72
+ return {
73
+ run_id: meta.run_id,
74
+ pipeline_id: meta.pipeline_id,
75
+ task_id: meta.task_id,
76
+ status: resolveListedStatus(stages, meta),
77
+ created_at: meta.created_at,
78
+ updated_at: meta.updated_at,
79
+ stages: compactStages(stages),
80
+ ...waitingFieldsFromStages(stages),
81
+ ...failedFieldsFromStages(stages),
82
+ };
83
+ }
84
+ export function projectRunDetail(meta, stages, task_yaml, dagSnapshot) {
85
+ const ordered = dagSnapshot
86
+ ? overlayPlannedStages(dagSnapshot.stage_ids, stages)
87
+ : stages;
88
+ const summary = projectRunSummary(meta, ordered);
89
+ const snapshot = dagSnapshot ??
90
+ linearCompatDagSnapshot(ordered.map((s) => s.stage_id));
91
+ const pipeline_track = buildPipelineTrack({
92
+ dagSnapshot: snapshot,
93
+ stages: ordered,
94
+ runStatus: summary.status,
95
+ });
96
+ return {
97
+ ...summary,
98
+ task_yaml,
99
+ stages: ordered,
100
+ pipeline_track,
101
+ };
102
+ }
@@ -0,0 +1,48 @@
1
+ import type { StageEnvelope } from "../../types/envelope.js";
2
+ import type { StageLogLine } from "../../agent/activity.js";
3
+ import { type CreateRunInput, type CreatedRun, type RunDetail, type RunMeta, type RunStatus, type RunStore, type RunSummary, type StageExecution, type StageExecutionPatch, type StageLogEvent } from "../port.js";
4
+ export declare class SqliteRunStore implements RunStore {
5
+ private readonly storeRoot;
6
+ private readonly db;
7
+ private migratePromise;
8
+ constructor(storeRoot: string);
9
+ /** Await one-shot disk import before catalog reads (create paths also wait). */
10
+ ready(): Promise<void>;
11
+ getWorkspaceDir(runId: string): string;
12
+ createRun(input: CreateRunInput): Promise<CreatedRun>;
13
+ updateRunStatus(runId: string, status: RunStatus): Promise<void>;
14
+ readRunMeta(runId: string): Promise<RunMeta>;
15
+ readTaskYaml(runId: string): Promise<string>;
16
+ ensureStageWorkspace(runId: string, stageId: string): Promise<void>;
17
+ ensureAttemptWorkspace(runId: string, stageId: string, attempt: number): Promise<void>;
18
+ createStageExecution(runId: string, stageId: string): Promise<StageExecution>;
19
+ listStageExecutions(runId: string, stageId: string): Promise<StageExecution[]>;
20
+ getLatestStageExecution(runId: string, stageId: string): Promise<StageExecution | null>;
21
+ countStageAttempts(runId: string, stageId: string): Promise<number>;
22
+ getStageExecution(runId: string, stageId: string, attempt: number): Promise<StageExecution>;
23
+ updateStageExecution(runId: string, stageId: string, attempt: number, patch: StageExecutionPatch): Promise<void>;
24
+ writeEnvelope(runId: string, stageId: string, envelope: StageEnvelope, options?: {
25
+ attempt?: number;
26
+ }): Promise<void>;
27
+ readEnvelope(runId: string, stageId: string): Promise<StageEnvelope>;
28
+ private readEnvelopeFromDb;
29
+ appendStageEvent(runId: string, stageId: string, event: StageLogLine, options?: {
30
+ attempt?: number;
31
+ }): Promise<void>;
32
+ /**
33
+ * @remarks Intentional denormalization: mirrors lifecycle events into
34
+ * `stages.status` for legacy compatibility. This column is not the
35
+ * authoritative source for snapshot projection; status is event-derived
36
+ * in `buildStageSnapshotFromStore`.
37
+ */
38
+ private updateStageStatusDenorm;
39
+ listStageEvents(runId: string, stageId: string, attempt?: number): Promise<StageLogEvent[]>;
40
+ listRuns(): Promise<RunSummary[]>;
41
+ readRun(runId: string): Promise<RunDetail>;
42
+ private readPipelineDagSnapshotFromRow;
43
+ private runMetaFromRow;
44
+ private getRunRow;
45
+ private loadEvents;
46
+ private loadStageSnapshots;
47
+ }
48
+ export declare function openSqliteRunStore(storeRoot: string): SqliteRunStore;