@osolmaz/pi-workflows 0.16.4 → 0.16.6

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 (173) hide show
  1. package/README.md +5 -5
  2. package/dist/builtins/autoimplement.workflow.d.ts +5 -1
  3. package/dist/builtins/autoimplement.workflow.js +29 -10
  4. package/dist/builtins/autoimplement.workflow.js.map +1 -1
  5. package/dist/client/client.js +3 -1
  6. package/dist/client/client.js.map +1 -1
  7. package/dist/client/protocol.d.ts +1 -1
  8. package/dist/client/protocol.js +18 -1
  9. package/dist/client/protocol.js.map +1 -1
  10. package/dist/client/view.d.ts +7 -5
  11. package/dist/extension/index.d.ts +2 -1
  12. package/dist/extension/index.js +115 -165
  13. package/dist/extension/index.js.map +1 -1
  14. package/dist/extension/recorder.d.ts +1 -1
  15. package/dist/extension/recorder.js +2 -2
  16. package/dist/extension/recorder.js.map +1 -1
  17. package/dist/extension/step-message.d.ts +1 -1
  18. package/dist/extension/step-message.js +4 -4
  19. package/dist/extension/step-message.js.map +1 -1
  20. package/dist/extension/workflow-message-coordinator.d.ts +12 -1
  21. package/dist/extension/workflow-message-coordinator.js +65 -54
  22. package/dist/extension/workflow-message-coordinator.js.map +1 -1
  23. package/dist/resource-managers/index.d.ts +1 -2
  24. package/dist/resource-managers/index.js +1 -2
  25. package/dist/resource-managers/index.js.map +1 -1
  26. package/dist/resource-managers/sqlite.d.ts +2 -295
  27. package/dist/resource-managers/sqlite.js +71 -1528
  28. package/dist/resource-managers/sqlite.js.map +1 -1
  29. package/dist/resource-managers/types.d.ts +2 -7
  30. package/dist/server/resource-runner-entry.js +2 -6
  31. package/dist/server/resource-runner-entry.js.map +1 -1
  32. package/dist/server/rpc-bridge.js +1 -1
  33. package/dist/server/rpc-bridge.js.map +1 -1
  34. package/dist/server/rpc-executor.js +2 -4
  35. package/dist/server/rpc-executor.js.map +1 -1
  36. package/dist/server/server-entry.js +3 -0
  37. package/dist/server/server-entry.js.map +1 -1
  38. package/dist/server/server.d.ts +22 -8
  39. package/dist/server/server.js +498 -543
  40. package/dist/server/server.js.map +1 -1
  41. package/dist/server/state.d.ts +16 -29
  42. package/dist/server/state.js +105 -319
  43. package/dist/server/state.js.map +1 -1
  44. package/dist/server/view.d.ts +4 -5
  45. package/dist/server/view.js +51 -51
  46. package/dist/server/view.js.map +1 -1
  47. package/dist/server/workflow-runner-entry.d.ts +1 -1
  48. package/dist/server/workflow-runner-entry.js +1 -49
  49. package/dist/server/workflow-runner-entry.js.map +1 -1
  50. package/dist/server/workflow-runner-protocol.d.ts +2 -7
  51. package/dist/server/workflow-runner-protocol.js +5 -10
  52. package/dist/server/workflow-runner-protocol.js.map +1 -1
  53. package/dist/server/workflow-runner-store.d.ts +5 -6
  54. package/dist/server/workflow-runner-store.js +7 -14
  55. package/dist/server/workflow-runner-store.js.map +1 -1
  56. package/dist/state/attempt-time.d.ts +21 -0
  57. package/dist/state/attempt-time.js +95 -0
  58. package/dist/state/attempt-time.js.map +1 -0
  59. package/dist/state/json.d.ts +2 -1
  60. package/dist/state/json.js.map +1 -1
  61. package/dist/state/project-store.d.ts +39 -0
  62. package/dist/state/project-store.js +154 -0
  63. package/dist/state/project-store.js.map +1 -0
  64. package/dist/state/prune.d.ts +28 -0
  65. package/dist/state/prune.js +278 -83
  66. package/dist/state/prune.js.map +1 -1
  67. package/dist/state/schema.js +23 -23
  68. package/dist/state/workflow-messages.d.ts +1 -1
  69. package/dist/state/workflow-messages.js +3 -1
  70. package/dist/state/workflow-messages.js.map +1 -1
  71. package/dist/viewer/backup.js +5 -0
  72. package/dist/viewer/backup.js.map +1 -1
  73. package/dist/workflows/diagnostics.d.ts +8 -0
  74. package/dist/workflows/diagnostics.js +61 -0
  75. package/dist/workflows/diagnostics.js.map +1 -0
  76. package/dist/workflows/engine.d.ts +2 -15
  77. package/dist/workflows/engine.js +125 -245
  78. package/dist/workflows/engine.js.map +1 -1
  79. package/dist/workflows/human-decision.d.ts +3 -7
  80. package/dist/workflows/human-decision.js +2 -56
  81. package/dist/workflows/human-decision.js.map +1 -1
  82. package/dist/workflows/index.d.ts +2 -1
  83. package/dist/workflows/index.js +1 -0
  84. package/dist/workflows/index.js.map +1 -1
  85. package/dist/workflows/queue.d.ts +267 -0
  86. package/dist/workflows/queue.js +1248 -0
  87. package/dist/workflows/queue.js.map +1 -0
  88. package/dist/workflows/requests.d.ts +47 -0
  89. package/dist/workflows/requests.js +158 -0
  90. package/dist/workflows/requests.js.map +1 -0
  91. package/dist/workflows/schema.js +2 -4
  92. package/dist/workflows/schema.js.map +1 -1
  93. package/dist/workflows/store.d.ts +11 -16
  94. package/dist/workflows/store.js +174 -169
  95. package/dist/workflows/store.js.map +1 -1
  96. package/dist/workflows/tool-input.d.ts +6 -9
  97. package/dist/workflows/tool-input.js +15 -12
  98. package/dist/workflows/tool-input.js.map +1 -1
  99. package/dist/workflows/transitions.d.ts +38 -0
  100. package/dist/workflows/transitions.js +276 -0
  101. package/dist/workflows/transitions.js.map +1 -0
  102. package/dist/workflows/types.d.ts +9 -42
  103. package/dist/workflows/workflow-message-content.d.ts +7 -1
  104. package/dist/workflows/workflow-message-content.js +22 -4
  105. package/dist/workflows/workflow-message-content.js.map +1 -1
  106. package/docs/2026-08-25-workflow-follow-ups.md +5 -5
  107. package/docs/2026-09-02-unify-workflow-messages-plan.md +2 -0
  108. package/docs/2026-09-04-workflow-run-state-plan.md +2 -0
  109. package/docs/2026-09-06-durable-execution-plan.md +176 -0
  110. package/docs/DEFERRED_TURNS.md +84 -105
  111. package/docs/HUMAN_DECISIONS.md +17 -19
  112. package/docs/HUMAN_DECISION_PRESENTATIONS.md +1 -1
  113. package/docs/SQLITE_STATE.md +87 -30
  114. package/docs/WORKFLOW_SERVER.md +50 -11
  115. package/docs/WORKFLOW_STEP_MESSAGES.md +72 -54
  116. package/docs/plans/2026-08-04-controller-runtime-plan.md +2 -0
  117. package/docs/plans/2026-08-21-deferred-turn-intents-plan.md +2 -0
  118. package/docs/plans/2026-08-27-workflow-terminal-restart-plan.md +2 -0
  119. package/docs/plans/2026-09-04-automatic-state-retention-plan.md +283 -0
  120. package/docs/workflows.md +109 -44
  121. package/examples/workflows/autoresearch.workflow.ts +0 -2
  122. package/examples/workflows/branch.workflow.ts +0 -4
  123. package/examples/workflows/echo.workflow.ts +0 -2
  124. package/examples/workflows/live-settings.workflow.ts +0 -2
  125. package/examples/workflows/two-turn.workflow.ts +0 -2
  126. package/herdr-plugin.toml +1 -1
  127. package/package.json +1 -1
  128. package/protocol/fixtures/client-v1.json +1 -1
  129. package/skills/pi-workflows/SKILL.md +8 -7
  130. package/src/builtins/autoimplement.workflow.ts +31 -10
  131. package/src/client/client.ts +3 -1
  132. package/src/client/protocol.ts +21 -1
  133. package/src/client/view.ts +9 -5
  134. package/src/extension/index.ts +117 -189
  135. package/src/extension/recorder.ts +2 -2
  136. package/src/extension/step-message.ts +4 -4
  137. package/src/extension/workflow-message-coordinator.ts +78 -50
  138. package/src/resource-managers/index.ts +1 -9
  139. package/src/resource-managers/sqlite.ts +330 -2655
  140. package/src/resource-managers/types.ts +2 -3
  141. package/src/server/resource-runner-entry.ts +2 -7
  142. package/src/server/rpc-bridge.ts +1 -1
  143. package/src/server/rpc-executor.ts +4 -9
  144. package/src/server/server-entry.ts +3 -0
  145. package/src/server/server.ts +568 -644
  146. package/src/server/state.ts +122 -466
  147. package/src/server/view.ts +56 -60
  148. package/src/server/workflow-runner-entry.ts +2 -55
  149. package/src/server/workflow-runner-protocol.ts +5 -15
  150. package/src/server/workflow-runner-store.ts +12 -27
  151. package/src/state/attempt-time.ts +122 -0
  152. package/src/state/json.ts +2 -1
  153. package/src/state/project-store.ts +218 -0
  154. package/src/state/prune.ts +408 -95
  155. package/src/state/schema.ts +23 -23
  156. package/src/state/workflow-messages.ts +4 -2
  157. package/src/viewer/backup.ts +7 -0
  158. package/src/workflows/diagnostics.ts +78 -0
  159. package/src/workflows/engine.ts +133 -291
  160. package/src/workflows/human-decision.ts +3 -81
  161. package/src/workflows/index.ts +8 -2
  162. package/src/workflows/queue.ts +2091 -0
  163. package/src/workflows/requests.ts +283 -0
  164. package/src/workflows/schema.ts +2 -6
  165. package/src/workflows/store.ts +223 -231
  166. package/src/workflows/tool-input.ts +20 -12
  167. package/src/workflows/transitions.ts +330 -0
  168. package/src/workflows/types.ts +9 -46
  169. package/src/workflows/workflow-message-content.ts +28 -4
  170. package/dist/resource-managers/runtime.d.ts +0 -59
  171. package/dist/resource-managers/runtime.js +0 -423
  172. package/dist/resource-managers/runtime.js.map +0 -1
  173. package/src/resource-managers/runtime.ts +0 -576
@@ -1,3 +1,4 @@
1
+ export { WorkflowRunQueueStore, type RunEventRecord, type WorkflowRunPreparationResult, type WorkflowRunQueueRecord, type WorkflowRunQueueViewRecord, type WorkflowRunReservationOptions, } from "./queue.js";
1
2
  export { agent, assistantMessage, action, checkpoint, compute, defineWorkflow, defineWorkflowRegistry, idempotentEffect, includeWorkflow, includedResult, manualEffect, isWorkflowDefinition, notify, shell, } from "./definition.js";
2
3
  export { decision, decisionEdge, type DecisionDefinition } from "./decision.js";
3
4
  export { MAX_PRESENTATION_BLOCKS, MAX_PRESENTATION_CODE_UNITS, MAX_PRESENTATION_ITEMS, MAX_PRESENTATION_STRING_CODE_UNITS, MAX_PRESENTATION_TRANSPORT_PARTS, decisionDocumentSegments, decisionPresentationDigest, decisionPresentationFingerprint, digestCanonical, humanDecisionChannelRequest, normalizeDecisionPresentation, valueDecisionPresentation, validateHumanDecisionRequestIntegrity, type DecisionDocumentSegment, } from "./decision-presentation.js";
@@ -16,4 +17,4 @@ export { estimateProgress, formatProgressLine, formatProgressReport, formatRemai
16
17
  export { MAX_CURRENT_UPDATES, MAX_UPDATE_DATA_BYTES, UPDATE_RATE_BURST, UPDATE_RATE_PER_SECOND, updateProjection, validateProgressData, validateWorkflowUpdate, } from "./updates.js";
17
18
  export { sanitizeText, stripAnsi } from "./text.js";
18
19
  export { DEFINITION_SNAPSHOT_SCHEMA, RUN_STATE_SCHEMA, SESSION_BINDING_SCHEMA, WorkflowRunStore, createDefinitionSnapshot, createRunId, listWorkflowRuns, readLastTraceEvent, readWorkflowRun, workflowStateDatabasePath, type LoadedWorkflowRun, type ReadWorkflowRunOptions, type RunWriteAuthority, } from "./store.js";
19
- export type { AcceptedHumanDecision, DefaultedHumanDecision, ResolvedHumanDecision, AgentNodeDefinition, AgentExpectedOutput, AgentStepCompletion, AgentStepContract, AssistantAgentNodeDefinition, AssistantMessageOutput, AssistantMessageReceipt, AgentStepExecutor, AgentStepPresentation, AgentStepRequest, AgentStepSubmission, ActionNodeDefinition, CheckpointNodeDefinition, ConversationRange, ComputeNodeDefinition, FunctionActionNodeDefinition, DecisionPresentation, DecisionPresentationBlock, DecisionPresentationBullets, DecisionPresentationFields, DecisionPresentationParagraph, DecisionPresentationPreformatted, DecisionPresentationSection, HumanDecisionAnswerSource, HumanDecisionAudience, HumanDecisionCancellationRecord, HumanDecisionChannelRequest, HumanDecisionChoice, HumanDecisionChoiceMap, HumanDecisionContinuationRecord, HumanDecisionDeliveryRecord, HumanDecisionNodeContract, HumanDecisionPrompt, HumanDecisionReceipt, HumanDecisionRequest, HumanDecisionResponse, HumanDecisionSettlementRecord, HumanDecisionSubmission, HumanDecisionTextInput, HumanDecisionTimeout, HumanDecisionTimeoutPolicy, MaybePromise, NotifyNodeDefinition, ShellActionExecution, ShellActionNodeDefinition, SubmittedAgentNodeDefinition, ShellActionResult, WorkflowActionContext, WorkflowActionReceipt, WorkflowCompositionSnapshot, WorkflowDefinition, WorkflowDefinitionSnapshot, WorkflowEdge, WorkflowExitDefinition, WorkflowExitMap, WorkflowExitOutputs, WorkflowIncludeDefinition, WorkflowIncludedResult, WorkflowInputOf, WorkflowSettingsOf, WorkflowMountedSource, WorkflowMountSnapshot, WorkflowValueParser, WorkflowEngineOptions, WorkflowNodeCommon, WorkflowNodeContext, WorkflowNodeDefinition, WorkflowNodeOutcome, WorkflowNodeResult, WorkflowNodeSnapshot, WorkflowNotificationReceipt, WorkflowNotificationRequest, WorkflowNotificationSink, WorkflowPresentationContext, WorkflowProgressData, WorkflowProgressStatus, WorkflowRunResult, WorkflowRunState, WorkflowRunStatus, WorkflowSource, WorkflowSessionBinding, WorkflowSessionEntryRecord, WorkflowSettingsSnapshot, WorkflowStepRecord, WorkflowTraceEvent, WorkflowTraceEventDraft, WorkflowUpdateInput, WorkflowUpdateReceipt, WorkflowUpdateRecord, ShellActionUpdates, ShellUpdateLine, } from "./types.js";
20
+ export type { AcceptedHumanDecision, DefaultedHumanDecision, ResolvedHumanDecision, AgentNodeDefinition, AgentExpectedOutput, AgentStepCompletion, AgentStepContract, AssistantAgentNodeDefinition, AssistantMessageOutput, AssistantMessageReceipt, AgentStepExecutor, AgentStepPresentation, AgentStepRequest, AgentStepSubmission, ActionNodeDefinition, CheckpointNodeDefinition, ConversationRange, ComputeNodeDefinition, FunctionActionNodeDefinition, DecisionPresentation, DecisionPresentationBlock, DecisionPresentationBullets, DecisionPresentationFields, DecisionPresentationParagraph, DecisionPresentationPreformatted, DecisionPresentationSection, HumanDecisionAnswerSource, HumanDecisionAudience, HumanDecisionCancellationRecord, HumanDecisionChannelRequest, HumanDecisionChoice, HumanDecisionChoiceMap, HumanDecisionDeliveryRecord, HumanDecisionNodeContract, HumanDecisionPrompt, HumanDecisionReceipt, HumanDecisionRequest, HumanDecisionResponse, HumanDecisionSettlementRecord, HumanDecisionSubmission, HumanDecisionTextInput, HumanDecisionTimeout, HumanDecisionTimeoutPolicy, MaybePromise, NotifyNodeDefinition, ShellActionExecution, ShellActionNodeDefinition, SubmittedAgentNodeDefinition, ShellActionResult, WorkflowActionContext, WorkflowActionReceipt, WorkflowCompositionSnapshot, WorkflowDefinition, WorkflowDefinitionSnapshot, WorkflowEdge, WorkflowExitDefinition, WorkflowExitMap, WorkflowExitOutputs, WorkflowIncludeDefinition, WorkflowIncludedResult, WorkflowInputOf, WorkflowSettingsOf, WorkflowMountedSource, WorkflowMountSnapshot, WorkflowValueParser, WorkflowEngineOptions, WorkflowNodeCommon, WorkflowNodeContext, WorkflowNodeDefinition, WorkflowNodeOutcome, WorkflowNodeResult, WorkflowNodeSnapshot, WorkflowNotificationReceipt, WorkflowNotificationRequest, WorkflowNotificationSink, WorkflowProgressData, WorkflowProgressStatus, WorkflowRunResult, WorkflowRunState, WorkflowRunStatus, WorkflowSource, WorkflowSessionBinding, WorkflowSessionEntryRecord, WorkflowSettingsSnapshot, WorkflowStepRecord, WorkflowTraceEvent, WorkflowTraceEventDraft, WorkflowUpdateInput, WorkflowUpdateReceipt, WorkflowUpdateRecord, ShellActionUpdates, ShellUpdateLine, } from "./types.js";
@@ -1,3 +1,4 @@
1
+ export { WorkflowRunQueueStore, } from "./queue.js";
1
2
  export { agent, assistantMessage, action, checkpoint, compute, defineWorkflow, defineWorkflowRegistry, idempotentEffect, includeWorkflow, includedResult, manualEffect, isWorkflowDefinition, notify, shell, } from "./definition.js";
2
3
  export { decision, decisionEdge } from "./decision.js";
3
4
  export { MAX_PRESENTATION_BLOCKS, MAX_PRESENTATION_CODE_UNITS, MAX_PRESENTATION_ITEMS, MAX_PRESENTATION_STRING_CODE_UNITS, MAX_PRESENTATION_TRANSPORT_PARTS, decisionDocumentSegments, decisionPresentationDigest, decisionPresentationFingerprint, digestCanonical, humanDecisionChannelRequest, normalizeDecisionPresentation, valueDecisionPresentation, validateHumanDecisionRequestIntegrity, } from "./decision-presentation.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,OAAO,EACP,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAA2B,MAAM,eAAe,CAAC;AAChF,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AAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EACL,2BAA2B,EAC3B,6BAA6B,EAC7B,uBAAuB,EACvB,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,EACf,2BAA2B,GAO5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,GAK1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,GAI1B,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAMtB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,EACL,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,OAAO,EACP,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAA2B,MAAM,eAAe,CAAC;AAChF,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,kCAAkC,EAClC,gCAAgC,EAChC,wBAAwB,EACxB,0BAA0B,EAC1B,+BAA+B,E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EACvB,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,EACf,2BAA2B,GAO5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,GAK1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,0BAA0B,EAC1B,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,GAI1B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,267 @@
1
+ import { type JsonObject } from "../state/json.js";
2
+ import { ProjectStore } from "../state/project-store.js";
3
+ export type WorkflowRunLaunchStatus = "queued" | "starting" | "running" | "parked" | "done" | "failed" | "cancelled";
4
+ export type WorkflowRunReservationOptions = {
5
+ runId: string;
6
+ workflowName: string;
7
+ workflowSourceRef: string;
8
+ workflowSource: unknown;
9
+ definitionDigest: string;
10
+ definitionSnapshot: unknown;
11
+ input: unknown;
12
+ launchOptions?: unknown;
13
+ originSessionId: string;
14
+ executionMode?: "interactive" | "headless";
15
+ parentRunId?: string;
16
+ lineageKind?: "restart";
17
+ restartNumber?: number;
18
+ parentRunRevision?: number;
19
+ now?: string;
20
+ };
21
+ export type WorkflowRunQueueViewRecord = {
22
+ runId: string;
23
+ workflowName: string;
24
+ workflowSourceRef: string;
25
+ workflowSource: unknown;
26
+ initialized: boolean;
27
+ definitionDigest: string;
28
+ runStateStatus: string;
29
+ paused: boolean;
30
+ status: WorkflowRunLaunchStatus;
31
+ originSessionId: string | null;
32
+ executionMode: "interactive" | "headless";
33
+ parentRunId: string | null;
34
+ rootRunId: string;
35
+ lineageKind: "restart" | null;
36
+ restartNumber: number;
37
+ parentRunRevision: number | null;
38
+ errorCode: string | null;
39
+ errorMessage: string | null;
40
+ createdAt: string;
41
+ updatedAt: string;
42
+ startedAt: string | null;
43
+ finishedAt: string | null;
44
+ };
45
+ export type WorkflowRunQueueRecord = {
46
+ runId: string;
47
+ workflowName: string;
48
+ workflowSourceRef: string;
49
+ workflowSource: unknown;
50
+ initialized: boolean;
51
+ definitionDigest: string;
52
+ input: unknown;
53
+ launchOptions: unknown;
54
+ status: WorkflowRunLaunchStatus;
55
+ runnerId: string | null;
56
+ claimToken: string | null;
57
+ claimGeneration: number | null;
58
+ claimExpiresAt: string | null;
59
+ originSessionId: string | null;
60
+ executionMode: "interactive" | "headless";
61
+ parentRunId: string | null;
62
+ rootRunId: string;
63
+ lineageKind: "restart" | null;
64
+ restartNumber: number;
65
+ parentRunRevision: number | null;
66
+ errorCode: string | null;
67
+ errorMessage: string | null;
68
+ createdAt: string;
69
+ updatedAt: string;
70
+ startedAt: string | null;
71
+ finishedAt: string | null;
72
+ };
73
+ export type WorkflowRunPreparationResult = {
74
+ state: "reserved";
75
+ run: WorkflowRunQueueRecord;
76
+ } | {
77
+ state: "adopted";
78
+ run: WorkflowRunQueueRecord;
79
+ };
80
+ export type RunEventRecord = {
81
+ seq: number;
82
+ recordedAt: string;
83
+ runId: string;
84
+ workflowRef: string;
85
+ type: string;
86
+ runnerId: string | null;
87
+ payload: JsonObject;
88
+ };
89
+ export declare class WorkflowRunQueueStore extends ProjectStore {
90
+ private readonly workflowMessages;
91
+ reserveWorkflowRun(options: WorkflowRunReservationOptions): WorkflowRunQueueRecord;
92
+ private reserveWorkflowRunInTransaction;
93
+ reserveOrAdoptWorkflowRun(options: WorkflowRunReservationOptions): WorkflowRunPreparationResult;
94
+ getWorkflowRun(runId: string): WorkflowRunQueueRecord | undefined;
95
+ getWorkflowRunView(runId: string): WorkflowRunQueueViewRecord | undefined;
96
+ workflowRunListRevision(): {
97
+ total: number;
98
+ revision: string;
99
+ };
100
+ listWorkflowRunViews(options: {
101
+ offset: number;
102
+ limit: number;
103
+ }): {
104
+ total: number;
105
+ revision: string;
106
+ runs: WorkflowRunQueueViewRecord[];
107
+ };
108
+ workflowRunProjectPath(runId: string): string | undefined;
109
+ listWorkflowRuns(options?: {
110
+ statuses?: WorkflowRunLaunchStatus[];
111
+ excludeRunIds?: string[];
112
+ limit?: number;
113
+ }): WorkflowRunQueueRecord[];
114
+ findSessionReservation(sessionId: string): WorkflowRunQueueRecord | undefined;
115
+ findSessionReservationView(sessionId: string): WorkflowRunQueueViewRecord | undefined;
116
+ claimWorkflowRun(options: {
117
+ runId: string;
118
+ runnerId: string;
119
+ claimToken: string;
120
+ leaseMs: number;
121
+ now?: string;
122
+ }): WorkflowRunQueueRecord | undefined;
123
+ /** Schedule a runner that validates one pending interactive submission. */
124
+ claimWorkflowRunForInteractionValidation(options: {
125
+ runId: string;
126
+ runnerId: string;
127
+ claimToken: string;
128
+ leaseMs: number;
129
+ now?: string;
130
+ }): WorkflowRunQueueRecord | undefined;
131
+ /** Take a short server claim without scheduling a parked interactive run. */
132
+ claimWorkflowRunForControl(options: {
133
+ runId: string;
134
+ runnerId: string;
135
+ claimToken: string;
136
+ leaseMs: number;
137
+ now?: string;
138
+ }): WorkflowRunQueueRecord | undefined;
139
+ beginWorkflowRunInteractionTimeout(options: {
140
+ runId: string;
141
+ targetSessionId: string;
142
+ claimToken: string;
143
+ now?: string;
144
+ }): boolean;
145
+ markWorkflowRunRunning(options: {
146
+ runId: string;
147
+ claimToken: string;
148
+ now?: string;
149
+ }): boolean;
150
+ claimNextWorkflowRun(options: {
151
+ runnerId: string;
152
+ claimToken: string;
153
+ leaseMs: number;
154
+ now?: string;
155
+ excludeRunIds?: string[];
156
+ }): WorkflowRunQueueRecord | undefined;
157
+ renewWorkflowRunClaim(options: {
158
+ runId: string;
159
+ claimToken: string;
160
+ leaseMs: number;
161
+ now?: string;
162
+ }): boolean;
163
+ verifyWorkflowRunClaim(options: {
164
+ runId: string;
165
+ claimToken: string;
166
+ now?: string;
167
+ }): boolean;
168
+ workflowRunAuthority(runId: string, claimToken: string): {
169
+ actor: {
170
+ type: "session" | "host";
171
+ id: string;
172
+ };
173
+ ownerType: "session" | "host";
174
+ ownerId: string;
175
+ token: string;
176
+ generation: number;
177
+ leaseMs: number;
178
+ } | undefined;
179
+ parkWorkflowRun(options: {
180
+ runId: string;
181
+ claimToken: string;
182
+ now?: string;
183
+ }): boolean;
184
+ parkWorkflowRunForRunnerNoProgress(options: {
185
+ runId: string;
186
+ claimToken: string;
187
+ detail: string;
188
+ now?: string;
189
+ }): boolean;
190
+ pauseParkedWorkflowRun(options: {
191
+ runId: string;
192
+ now?: string;
193
+ }): boolean;
194
+ resumePausedInteraction(options: {
195
+ runId: string;
196
+ now?: string;
197
+ }): boolean;
198
+ requestWorkflowRunResume(options: {
199
+ runId: string;
200
+ now?: string;
201
+ }): boolean;
202
+ isWorkflowRunPaused(runId: string): boolean;
203
+ parkWorkflowRunForSourceChange(options: {
204
+ runId: string;
205
+ claimToken: string;
206
+ detail: string;
207
+ now?: string;
208
+ }): boolean;
209
+ parkWorkflowRunForAmbiguousEffect(options: {
210
+ runId: string;
211
+ claimToken: string;
212
+ now?: string;
213
+ }): boolean;
214
+ failWorkflowRun(options: {
215
+ runId: string;
216
+ claimToken?: string;
217
+ errorCode: string;
218
+ errorMessage: string;
219
+ now?: string;
220
+ }): boolean;
221
+ cancelWorkflowRun(options: {
222
+ runId: string;
223
+ claimToken?: string;
224
+ now?: string;
225
+ }): boolean;
226
+ /** Cancel a nonterminal run only when its claim is absent or expired. */
227
+ cancelStaleWorkflowRun(options: {
228
+ runId: string;
229
+ controlId?: string;
230
+ claimToken?: string;
231
+ now?: string;
232
+ }): boolean;
233
+ deleteWorkflowRun(options: {
234
+ runId: string;
235
+ claimToken: string;
236
+ }): boolean;
237
+ completeWorkflowRun(options: {
238
+ runId: string;
239
+ claimToken: string;
240
+ now?: string;
241
+ }): boolean;
242
+ recordRunEvent(options: {
243
+ runId: string;
244
+ workflowRef: string;
245
+ type: string;
246
+ payload?: JsonObject;
247
+ runnerId?: string;
248
+ now?: string;
249
+ }): RunEventRecord;
250
+ listRunEventsAfter(seq: number, options?: {
251
+ limit?: number;
252
+ }): RunEventRecord[];
253
+ settleRunEffect(runId: string, effectType: "run.park_queue" | "run.settle_queue"): void;
254
+ private workflowRunRow;
255
+ private requireWorkflowRunRow;
256
+ private requireWorkflowRun;
257
+ private assertWorkflowRunPreparationCompatible;
258
+ private workflowRunViewRows;
259
+ private mapWorkflowRun;
260
+ private claimRun;
261
+ private claimRunInTransaction;
262
+ private updateClaimedRunStatus;
263
+ private releaseRunClaim;
264
+ private terminalRun;
265
+ private settleWorkflowRunMessages;
266
+ private cancelWorkflowRunDependents;
267
+ }