@osolmaz/pi-workflows 0.15.3 → 0.16.1

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 (207) hide show
  1. package/README.md +24 -8
  2. package/dist/channels/adapter-entry.d.ts +3 -0
  3. package/dist/channels/adapter-entry.js +203 -0
  4. package/dist/channels/adapter-entry.js.map +1 -0
  5. package/dist/channels/config.d.ts +43 -0
  6. package/dist/channels/config.js +234 -0
  7. package/dist/channels/config.js.map +1 -0
  8. package/dist/channels/protocol.d.ts +94 -0
  9. package/dist/channels/protocol.js +219 -0
  10. package/dist/channels/protocol.js.map +1 -0
  11. package/dist/channels/telegram.d.ts +46 -0
  12. package/dist/channels/telegram.js +285 -0
  13. package/dist/channels/telegram.js.map +1 -0
  14. package/dist/client/activity.d.ts +2 -0
  15. package/dist/client/activity.js +6 -0
  16. package/dist/client/activity.js.map +1 -0
  17. package/dist/client/client.d.ts +102 -0
  18. package/dist/client/client.js +737 -0
  19. package/dist/client/client.js.map +1 -0
  20. package/dist/client/index.d.ts +3 -0
  21. package/dist/client/index.js +3 -0
  22. package/dist/client/index.js.map +1 -0
  23. package/dist/client/materialize.d.ts +7 -0
  24. package/dist/client/materialize.js +177 -0
  25. package/dist/client/materialize.js.map +1 -0
  26. package/dist/client/protocol.d.ts +60 -0
  27. package/dist/client/protocol.js +275 -0
  28. package/dist/client/protocol.js.map +1 -0
  29. package/dist/client/resolver.d.ts +23 -0
  30. package/dist/client/resolver.js +2 -0
  31. package/dist/client/resolver.js.map +1 -0
  32. package/dist/client/view.d.ts +144 -0
  33. package/dist/client/view.js +3 -0
  34. package/dist/client/view.js.map +1 -0
  35. package/dist/controllers/index.d.ts +1 -1
  36. package/dist/controllers/index.js.map +1 -1
  37. package/dist/controllers/sqlite.d.ts +47 -157
  38. package/dist/controllers/sqlite.js +230 -406
  39. package/dist/controllers/sqlite.js.map +1 -1
  40. package/dist/extension/index.d.ts +23 -1
  41. package/dist/extension/index.js +734 -555
  42. package/dist/extension/index.js.map +1 -1
  43. package/dist/extension/recorder.d.ts +95 -0
  44. package/dist/extension/recorder.js +530 -0
  45. package/dist/extension/recorder.js.map +1 -0
  46. package/dist/extension/remote-recorder-store.d.ts +25 -0
  47. package/dist/extension/remote-recorder-store.js +81 -0
  48. package/dist/extension/remote-recorder-store.js.map +1 -0
  49. package/dist/extension/session-events.d.ts +134 -0
  50. package/dist/extension/session-events.js +60 -0
  51. package/dist/extension/session-events.js.map +1 -0
  52. package/dist/extension/session-view.d.ts +9 -2
  53. package/dist/extension/session-view.js +117 -51
  54. package/dist/extension/session-view.js.map +1 -1
  55. package/dist/extension/step-message.d.ts +6 -4
  56. package/dist/extension/step-message.js +12 -6
  57. package/dist/extension/step-message.js.map +1 -1
  58. package/dist/extension/widget.d.ts +3 -2
  59. package/dist/extension/widget.js +41 -24
  60. package/dist/extension/widget.js.map +1 -1
  61. package/dist/extension/workflow-message-coordinator.d.ts +27 -0
  62. package/dist/extension/workflow-message-coordinator.js +294 -0
  63. package/dist/extension/workflow-message-coordinator.js.map +1 -0
  64. package/dist/host/channel-effects.d.ts +72 -0
  65. package/dist/host/channel-effects.js +271 -0
  66. package/dist/host/channel-effects.js.map +1 -0
  67. package/dist/host/channel-supervisor.d.ts +21 -0
  68. package/dist/host/channel-supervisor.js +54 -0
  69. package/dist/host/channel-supervisor.js.map +1 -0
  70. package/dist/host/child-worker-supervisor.js +1 -1
  71. package/dist/host/child-worker-supervisor.js.map +1 -1
  72. package/dist/host/resolver-entry.d.ts +2 -23
  73. package/dist/host/resolver-entry.js +1 -1
  74. package/dist/host/resolver-entry.js.map +1 -1
  75. package/dist/host/runner.d.ts +54 -8
  76. package/dist/host/runner.js +1997 -305
  77. package/dist/host/runner.js.map +1 -1
  78. package/dist/host/state.d.ts +25 -19
  79. package/dist/host/state.js +303 -89
  80. package/dist/host/state.js.map +1 -1
  81. package/dist/host/view.d.ts +83 -0
  82. package/dist/host/view.js +975 -0
  83. package/dist/host/view.js.map +1 -0
  84. package/dist/host/worker-protocol.js +1 -1
  85. package/dist/host/worker-protocol.js.map +1 -1
  86. package/dist/state/database.d.ts +1 -0
  87. package/dist/state/database.js +15 -0
  88. package/dist/state/database.js.map +1 -1
  89. package/dist/state/prune.d.ts +3 -1
  90. package/dist/state/prune.js +9 -33
  91. package/dist/state/prune.js.map +1 -1
  92. package/dist/state/schema.js +88 -98
  93. package/dist/state/schema.js.map +1 -1
  94. package/dist/state/workflow-messages.d.ts +96 -0
  95. package/dist/state/workflow-messages.js +335 -0
  96. package/dist/state/workflow-messages.js.map +1 -0
  97. package/dist/viewer/backup.d.ts +2 -0
  98. package/dist/viewer/backup.js +28 -0
  99. package/dist/viewer/backup.js.map +1 -0
  100. package/dist/viewer/cli.d.ts +4 -0
  101. package/dist/viewer/cli.js +150 -170
  102. package/dist/viewer/cli.js.map +1 -1
  103. package/dist/viewer/render.js +1 -1
  104. package/dist/viewer/render.js.map +1 -1
  105. package/dist/viewer/tui.d.ts +5 -7
  106. package/dist/viewer/tui.js +245 -108
  107. package/dist/viewer/tui.js.map +1 -1
  108. package/dist/workflows/human-decision.d.ts +2 -0
  109. package/dist/workflows/human-decision.js +8 -2
  110. package/dist/workflows/human-decision.js.map +1 -1
  111. package/dist/workflows/index.d.ts +1 -1
  112. package/dist/workflows/index.js.map +1 -1
  113. package/dist/workflows/settings.d.ts +1 -8
  114. package/dist/workflows/settings.js.map +1 -1
  115. package/dist/workflows/store.d.ts +67 -20
  116. package/dist/workflows/store.js +451 -378
  117. package/dist/workflows/store.js.map +1 -1
  118. package/dist/workflows/tool-input.d.ts +21 -0
  119. package/dist/workflows/tool-input.js +23 -1
  120. package/dist/workflows/tool-input.js.map +1 -1
  121. package/dist/workflows/types.d.ts +5 -5
  122. package/dist/workflows/workflow-message-content.d.ts +38 -0
  123. package/dist/workflows/workflow-message-content.js +157 -0
  124. package/dist/workflows/workflow-message-content.js.map +1 -0
  125. package/docs/2026-08-18-herdr-piw-plan.md +2 -1
  126. package/docs/2026-08-20-durable-workflow-launch-plan.md +1 -1
  127. package/docs/2026-08-25-workflow-follow-ups.md +26 -50
  128. package/docs/2026-08-30-out-of-process-workflow-host-plan.md +3 -3
  129. package/docs/2026-09-01-restore-session-delivery-controls-plan.md +4 -0
  130. package/docs/2026-09-01-unified-workflow-client-plan.md +385 -0
  131. package/docs/2026-09-02-installed-live-e2e-plan.md +239 -0
  132. package/docs/2026-09-02-unify-workflow-messages-plan.md +562 -0
  133. package/docs/DEFERRED_TURNS.md +66 -294
  134. package/docs/HUMAN_DECISIONS.md +29 -30
  135. package/docs/HUMAN_DECISION_PRESENTATIONS.md +4 -11
  136. package/docs/SQLITE_STATE.md +31 -25
  137. package/docs/WORKFLOW_HOST.md +155 -77
  138. package/docs/WORKFLOW_STEP_MESSAGES.md +166 -75
  139. package/docs/development.md +2 -1
  140. package/docs/live-replay-protocol.md +74 -132
  141. package/docs/tui-viewer.md +12 -14
  142. package/docs/workflows.md +78 -28
  143. package/herdr-plugin.toml +1 -1
  144. package/package.json +9 -3
  145. package/plugins/herdr/viewer.mjs +14 -5
  146. package/protocol/client.v1.schema.json +137 -0
  147. package/protocol/fixtures/client-v1.json +23 -0
  148. package/src/channels/adapter-entry.ts +220 -0
  149. package/src/channels/config.ts +296 -0
  150. package/src/channels/protocol.ts +333 -0
  151. package/src/channels/telegram.ts +335 -0
  152. package/src/client/activity.ts +6 -0
  153. package/src/client/client.ts +939 -0
  154. package/src/client/index.ts +25 -0
  155. package/src/client/materialize.ts +228 -0
  156. package/src/client/protocol.ts +333 -0
  157. package/src/client/resolver.ts +26 -0
  158. package/src/client/view.ts +163 -0
  159. package/src/controllers/index.ts +0 -1
  160. package/src/controllers/sqlite.ts +339 -808
  161. package/src/extension/index.ts +853 -665
  162. package/src/extension/recorder.ts +687 -0
  163. package/src/extension/remote-recorder-store.ts +126 -0
  164. package/src/extension/session-events.ts +119 -0
  165. package/src/extension/session-view.ts +157 -51
  166. package/src/extension/step-message.ts +19 -9
  167. package/src/extension/widget.ts +53 -25
  168. package/src/extension/workflow-message-coordinator.ts +334 -0
  169. package/src/host/channel-effects.ts +465 -0
  170. package/src/host/channel-supervisor.ts +73 -0
  171. package/src/host/child-worker-supervisor.ts +1 -1
  172. package/src/host/resolver-entry.ts +11 -26
  173. package/src/host/runner.ts +2639 -450
  174. package/src/host/state.ts +404 -137
  175. package/src/host/view.ts +1212 -0
  176. package/src/host/worker-protocol.ts +1 -1
  177. package/src/state/database.ts +13 -0
  178. package/src/state/prune.ts +14 -42
  179. package/src/state/schema.ts +88 -98
  180. package/src/state/workflow-messages.ts +548 -0
  181. package/src/viewer/backup.ts +29 -0
  182. package/src/viewer/cli.ts +171 -185
  183. package/src/viewer/render.ts +1 -5
  184. package/src/viewer/tui.ts +261 -124
  185. package/src/workflows/human-decision.ts +18 -2
  186. package/src/workflows/index.ts +0 -1
  187. package/src/workflows/settings.ts +1 -20
  188. package/src/workflows/store.ts +650 -511
  189. package/src/workflows/tool-input.ts +36 -1
  190. package/src/workflows/types.ts +5 -5
  191. package/src/workflows/workflow-message-content.ts +197 -0
  192. package/dist/extension/decision-channels.d.ts +0 -134
  193. package/dist/extension/decision-channels.js +0 -1307
  194. package/dist/extension/decision-channels.js.map +0 -1
  195. package/dist/host/client.d.ts +0 -48
  196. package/dist/host/client.js +0 -216
  197. package/dist/host/client.js.map +0 -1
  198. package/dist/host/protocol.d.ts +0 -38
  199. package/dist/host/protocol.js +0 -156
  200. package/dist/host/protocol.js.map +0 -1
  201. package/dist/viewer/watch.d.ts +0 -6
  202. package/dist/viewer/watch.js +0 -46
  203. package/dist/viewer/watch.js.map +0 -1
  204. package/src/extension/decision-channels.ts +0 -1826
  205. package/src/host/client.ts +0 -293
  206. package/src/host/protocol.ts +0 -196
  207. package/src/viewer/watch.ts +0 -51
@@ -0,0 +1,23 @@
1
+ import type { JsonValue } from "../state/json.js";
2
+ export type ResolvedWorkflowLaunch = {
3
+ schema: "pi-workflows.resolved-launch.v1";
4
+ workflowName: string;
5
+ workflowSourceRef: string;
6
+ workflowSource: JsonValue;
7
+ definitionDigest: string;
8
+ definitionSnapshot: JsonValue;
9
+ };
10
+ export type ResolvedControllerInitialization = {
11
+ schema: "pi-workflows.resolved-controller-initialization.v1";
12
+ controllerName: string;
13
+ controllerPath: string;
14
+ sourceHash: string;
15
+ initialStatus: JsonValue;
16
+ };
17
+ export type ResolvedSettingsChange = {
18
+ schema: "pi-workflows.resolved-settings-change.v1";
19
+ definitionDigest: string;
20
+ patch: JsonValue;
21
+ settings: JsonValue;
22
+ paths: JsonValue;
23
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/client/resolver.ts"],"names":[],"mappings":""}
@@ -0,0 +1,144 @@
1
+ import type { JsonValue } from "../state/json.js";
2
+ import type { WorkflowMessage, WorkflowTurn } from "../state/workflow-messages.js";
3
+ export declare const RUN_VIEW_SCHEMA: "pi-workflows.run-view.v1";
4
+ export declare const SESSION_VIEW_SCHEMA: "pi-workflows.session-view.v1";
5
+ export type WorkflowDisplayStatus = "queued" | "running" | "waiting" | "paused" | "completed" | "failed" | "timed_out" | "cancelled" | "ambiguous";
6
+ export type WorkflowDisplay = {
7
+ status: WorkflowDisplayStatus;
8
+ activity: "supervised_worker" | "origin_turn" | null;
9
+ controls: Array<"pause" | "resume" | "cancel" | "answer" | "review">;
10
+ reason: string | null;
11
+ reasonContent?: JsonValue;
12
+ };
13
+ export type WorkflowRunQueueView = {
14
+ runId: string;
15
+ workflowName: string;
16
+ workflowSourceRef: string;
17
+ initialized: boolean;
18
+ definitionDigest: string;
19
+ status: "queued" | "starting" | "running" | "parked" | "done" | "failed" | "cancelled";
20
+ originSessionId: string | null;
21
+ executionMode: "interactive" | "headless";
22
+ parentRunId: string | null;
23
+ rootRunId: string;
24
+ lineageKind: "continuation" | "restart" | null;
25
+ restartNumber: number;
26
+ parentTerminalFingerprint: string | null;
27
+ errorCode: string | null;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ startedAt: string | null;
31
+ finishedAt: string | null;
32
+ };
33
+ export type WorkflowRunView = {
34
+ schema: typeof RUN_VIEW_SCHEMA;
35
+ runId: string;
36
+ revision: number;
37
+ display: WorkflowDisplay;
38
+ manifest: JsonValue;
39
+ state: JsonValue;
40
+ workflow: JsonValue;
41
+ queue: WorkflowRunQueueView;
42
+ updates: JsonValue[];
43
+ graphSteps: JsonValue[];
44
+ graphStepStart: number;
45
+ graphStepTotal: number;
46
+ takenTransitions: string[];
47
+ graphHistory: JsonValue;
48
+ takenTransitionStart: number;
49
+ takenTransitionTotal: number;
50
+ graphCursor: number;
51
+ stepStart: number;
52
+ stepTotal: number;
53
+ tracePage: JsonValue;
54
+ session: JsonValue;
55
+ settingsScopes: JsonValue[];
56
+ settingsStart: number;
57
+ settingsTotal: number;
58
+ followUpQueue: JsonValue;
59
+ followUpStart: number;
60
+ followUpTotal: number;
61
+ updateStart: number;
62
+ updateTotal: number;
63
+ live: boolean;
64
+ possiblyInterrupted: boolean;
65
+ };
66
+ export type WorkflowRunListPage = {
67
+ schema: "pi-workflows.run-list-page.v1";
68
+ revision: string;
69
+ start: number;
70
+ total: number;
71
+ items: WorkflowRunSummary[];
72
+ };
73
+ export type WorkflowRunSummary = {
74
+ runId: string;
75
+ workflowName: string;
76
+ originSessionId: string | null;
77
+ createdAt: string;
78
+ updatedAt: string;
79
+ display: WorkflowDisplay;
80
+ manifest: JsonValue;
81
+ live: boolean;
82
+ possiblyInterrupted: boolean;
83
+ };
84
+ export type ClientInteractiveRequest = {
85
+ requestId: string;
86
+ runId: string;
87
+ attemptId: string;
88
+ targetSessionId: string;
89
+ kind: "agent" | "assistant" | "decision";
90
+ contract: JsonValue;
91
+ revision: number;
92
+ status: "pending" | "settled" | "cancelled";
93
+ unproductiveTurnEnds: number;
94
+ acceptedSubmissionId: string | null;
95
+ createdAt: string;
96
+ updatedAt: string;
97
+ settledAt: string | null;
98
+ consumedAt: string | null;
99
+ };
100
+ export type WorkflowSessionView = {
101
+ schema: typeof SESSION_VIEW_SCHEMA;
102
+ sessionId: string;
103
+ run: WorkflowRunView | null;
104
+ pendingInteractions: JsonValue[];
105
+ pendingInteractionStart: number;
106
+ pendingInteractionTotal: number;
107
+ workflowMessages: WorkflowMessage[];
108
+ workflowMessageStart: number;
109
+ workflowMessageTotal: number;
110
+ workflowMessageWindowComplete: boolean;
111
+ nextWorkflowMessageId: string | null;
112
+ openWorkflowMessageId: string | null;
113
+ openWorkflowTurn: WorkflowTurn | null;
114
+ coordinatorEpoch: string | null;
115
+ coordinatorActive: boolean;
116
+ branchReportRequired: boolean;
117
+ };
118
+ export type WorkflowBranchReport = {
119
+ targetSessionId: string;
120
+ coordinatorEpoch: string;
121
+ entries: Array<{
122
+ workflowMessageId: string;
123
+ piSessionEntryId: string;
124
+ }>;
125
+ isIdle: boolean;
126
+ hasPendingMessages: boolean;
127
+ };
128
+ export type WorkflowTurnReport = {
129
+ state: "started";
130
+ workflowMessageId: string;
131
+ workflowTurnId: string;
132
+ runId: string;
133
+ targetSessionId: string;
134
+ coordinatorEpoch: string;
135
+ } | {
136
+ state: "ended";
137
+ workflowMessageId: string;
138
+ workflowTurnId: string;
139
+ runId: string;
140
+ targetSessionId: string;
141
+ coordinatorEpoch: string;
142
+ stopReason: "completed" | "aborted" | "error" | "lost";
143
+ responseSessionEntryId: string | null;
144
+ };
@@ -0,0 +1,3 @@
1
+ export const RUN_VIEW_SCHEMA = "pi-workflows.run-view.v1";
2
+ export const SESSION_VIEW_SCHEMA = "pi-workflows.session-view.v1";
3
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/client/view.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,eAAe,GAAG,0BAAmC,CAAC;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,8BAAuC,CAAC"}
@@ -5,7 +5,7 @@ export { ControllerEffectService } from "./effects.js";
5
5
  export { canonicalJson, jsonFingerprint } from "./json.js";
6
6
  export { ControllerManager, type ControllerManagerOptions } from "./manager.js";
7
7
  export { createResultHelpers, requeue, requeueAfter, settled } from "./results.js";
8
- export { SqliteControllerStore, type RunEventRecord, type WorkflowNotificationRecord, type WorkflowRunClaimOptions, type WorkflowRunPreparationResult, type WorkflowRunQueueRecord, type WorkflowRunReservationOptions, } from "./sqlite.js";
8
+ export { SqliteControllerStore, type RunEventRecord, type WorkflowRunClaimOptions, type WorkflowRunPreparationResult, type WorkflowRunQueueRecord, type WorkflowRunReservationOptions, } from "./sqlite.js";
9
9
  export { type ControllerStore, type EffectReservation, type QueueItem, type QueueRequeueOptions, type WorkflowRecordUpdate, type WorkflowReservation, } from "./store.js";
10
10
  export { controllerFileStem, controllerSearchDirs, discoverControllers, loadControllerFile, loadDiscoveredControllers, type DiscoveredController, } from "./loader.js";
11
11
  export { ControllerWorkflowCoordinator, type ControllerWorkflowControlRequest, type ControllerWorkflowScheduler, type WorkflowSchedulerRequest, type WorkflowSchedulerResult, } from "./workflows.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controllers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAiC,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EACL,qBAAqB,GAOtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAON,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,6BAA6B,GAK9B,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controllers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAiC,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EACL,qBAAqB,GAMtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAON,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,6BAA6B,GAK9B,MAAM,gBAAgB,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { StateDatabase } from "../state/database.js";
2
2
  import type { ControllerStore, EffectReservation, QueueItem, QueueRequeueOptions, WorkflowRecordUpdate, WorkflowReservation } from "./store.js";
3
3
  import type { ChildWorkflowRecord, ControllerEvent, ControllerQueueClaim, ControllerResource, ControllerResourceRef, ControllerResourceStatus, EffectRecord, JsonObject } from "./types.js";
4
- declare const TURN_INTENT_FACTS_SCHEMA = "pi-workflows.deferred-turn-facts.v1";
5
4
  export type WorkflowRunLaunchStatus = "queued" | "starting" | "running" | "parked" | "done" | "failed" | "cancelled";
6
5
  export type WorkflowRunReservationOptions = {
7
6
  runId: string;
@@ -16,12 +15,39 @@ export type WorkflowRunReservationOptions = {
16
15
  originSessionId: string;
17
16
  executionMode?: "interactive" | "headless";
18
17
  parentRunId?: string;
18
+ lineageKind?: "continuation" | "restart";
19
+ restartNumber?: number;
20
+ parentTerminalFingerprint?: string;
19
21
  now?: string;
20
22
  };
21
23
  export type WorkflowRunClaimOptions = WorkflowRunReservationOptions & {
22
24
  claimToken: string;
23
25
  leaseMs: number;
24
26
  };
27
+ export type WorkflowRunQueueViewRecord = {
28
+ runId: string;
29
+ workflowName: string;
30
+ workflowSourceRef: string;
31
+ workflowSource: unknown;
32
+ initialized: boolean;
33
+ definitionDigest: string;
34
+ runStateStatus: string;
35
+ paused: boolean;
36
+ status: WorkflowRunLaunchStatus;
37
+ originSessionId: string | null;
38
+ executionMode: "interactive" | "headless";
39
+ parentRunId: string | null;
40
+ rootRunId: string;
41
+ lineageKind: "continuation" | "restart" | null;
42
+ restartNumber: number;
43
+ parentTerminalFingerprint: string | null;
44
+ errorCode: string | null;
45
+ errorMessage: string | null;
46
+ createdAt: string;
47
+ updatedAt: string;
48
+ startedAt: string | null;
49
+ finishedAt: string | null;
50
+ };
25
51
  export type WorkflowRunQueueRecord = {
26
52
  runId: string;
27
53
  workflowName: string;
@@ -40,6 +66,10 @@ export type WorkflowRunQueueRecord = {
40
66
  originSessionId: string | null;
41
67
  executionMode: "interactive" | "headless";
42
68
  parentRunId: string | null;
69
+ rootRunId: string;
70
+ lineageKind: "continuation" | "restart" | null;
71
+ restartNumber: number;
72
+ parentTerminalFingerprint: string | null;
43
73
  errorCode: string | null;
44
74
  errorMessage: string | null;
45
75
  createdAt: string;
@@ -56,49 +86,6 @@ export type WorkflowRunPreparationResult = {
56
86
  state: "adopted";
57
87
  run: WorkflowRunQueueRecord;
58
88
  };
59
- export type WorkflowNotificationRecord = {
60
- notificationId: string;
61
- runId: string;
62
- nodeId: string;
63
- attemptId: string;
64
- notificationIndex: number;
65
- targetSessionId: string;
66
- kind: "progress" | "final";
67
- content: string;
68
- createdAt: string;
69
- deliveryClaimExpiresAt: string | null;
70
- deliveredAt: string | null;
71
- };
72
- export type WorkflowTurnIntentCause = "agentCancelled" | "timedOut" | "failed" | "launchFailed" | "controllerInterrupted" | "claimLost" | "terminal" | "cancelled";
73
- export type WorkflowTurnIntentResolution = "workflowPrompt" | "presentation" | "fallback";
74
- export type WorkflowTurnIntentFacts = JsonObject & {
75
- schema: typeof TURN_INTENT_FACTS_SCHEMA;
76
- workflowName: string;
77
- runId: string;
78
- observedState: string;
79
- cause: WorkflowTurnIntentCause;
80
- nodeId: string | null;
81
- attemptId: string | null;
82
- reason: string | null;
83
- handoff: boolean;
84
- };
85
- export type WorkflowTurnIntentRecord = {
86
- intentId: string;
87
- sourceEventId: string;
88
- runId: string;
89
- workflowRef: string;
90
- targetSessionId: string;
91
- cause: WorkflowTurnIntentCause;
92
- nodeId: string | null;
93
- attemptId: string | null;
94
- fallbackFacts: WorkflowTurnIntentFacts;
95
- requestedAt: string;
96
- eligibleAt: string | null;
97
- resolvedAt: string | null;
98
- resolution: WorkflowTurnIntentResolution | null;
99
- resolutionMessageId: string | null;
100
- deliveryClaimExpiresAt: string | null;
101
- };
102
89
  export type RunEventRecord = {
103
90
  seq: number;
104
91
  recordedAt: string;
@@ -212,6 +199,19 @@ export declare class SqliteControllerStore implements ControllerStore {
212
199
  prepareOrAdoptWorkflowRun(options: WorkflowRunClaimOptions): WorkflowRunPreparationResult;
213
200
  enqueueWorkflowRun(options: WorkflowRunClaimOptions): WorkflowRunQueueRecord;
214
201
  getWorkflowRun(runId: string): WorkflowRunQueueRecord | undefined;
202
+ getWorkflowRunView(runId: string): WorkflowRunQueueViewRecord | undefined;
203
+ workflowRunListRevision(): {
204
+ total: number;
205
+ revision: string;
206
+ };
207
+ listWorkflowRunViews(options: {
208
+ offset: number;
209
+ limit: number;
210
+ }): {
211
+ total: number;
212
+ revision: string;
213
+ runs: WorkflowRunQueueViewRecord[];
214
+ };
215
215
  workflowRunProjectPath(runId: string): string | undefined;
216
216
  listWorkflowRuns(options?: {
217
217
  statuses?: WorkflowRunLaunchStatus[];
@@ -219,6 +219,7 @@ export declare class SqliteControllerStore implements ControllerStore {
219
219
  limit?: number;
220
220
  }): WorkflowRunQueueRecord[];
221
221
  findSessionReservation(sessionId: string): WorkflowRunQueueRecord | undefined;
222
+ findSessionReservationView(sessionId: string): WorkflowRunQueueViewRecord | undefined;
222
223
  claimWorkflowRun(options: {
223
224
  runId: string;
224
225
  runnerId: string;
@@ -244,6 +245,7 @@ export declare class SqliteControllerStore implements ControllerStore {
244
245
  }): WorkflowRunQueueRecord | undefined;
245
246
  beginWorkflowRunInteractionTimeout(options: {
246
247
  runId: string;
248
+ targetSessionId: string;
247
249
  claimToken: string;
248
250
  now?: string;
249
251
  }): boolean;
@@ -348,102 +350,6 @@ export declare class SqliteControllerStore implements ControllerStore {
348
350
  listRunEventsAfter(seq: number, options?: {
349
351
  limit?: number;
350
352
  }): RunEventRecord[];
351
- ensureWorkflowTurnIntent(options: {
352
- intentId: string;
353
- sourceEventId: string;
354
- runId: string;
355
- workflowRef: string;
356
- targetSessionId: string;
357
- cause: WorkflowTurnIntentCause;
358
- nodeId?: string | null;
359
- attemptId?: string | null;
360
- fallbackFacts: WorkflowTurnIntentFacts;
361
- eligible: boolean;
362
- requestedAt?: string;
363
- }): WorkflowTurnIntentRecord;
364
- getWorkflowTurnIntent(intentId: string): WorkflowTurnIntentRecord | undefined;
365
- findPendingWorkflowTurnIntent(options: {
366
- runId: string;
367
- targetSessionId: string;
368
- }): WorkflowTurnIntentRecord | undefined;
369
- isWorkflowTurnIntentClaimLive(options: {
370
- intentId: string;
371
- targetSessionId: string;
372
- claimToken: string;
373
- now?: string;
374
- }): boolean;
375
- claimWorkflowTurnIntent(options: {
376
- intentId: string;
377
- targetSessionId: string;
378
- claimToken: string;
379
- leaseMs: number;
380
- now?: string;
381
- }): WorkflowTurnIntentRecord | undefined;
382
- claimEligibleWorkflowTurnIntents(options: {
383
- targetSessionId: string;
384
- claimToken: string;
385
- leaseMs: number;
386
- now?: string;
387
- limit?: number;
388
- }): WorkflowTurnIntentRecord[];
389
- makeWorkflowTurnIntentEligible(options: {
390
- intentId: string;
391
- fallbackFacts: WorkflowTurnIntentFacts;
392
- eligibleAt?: string;
393
- now?: string;
394
- }): boolean;
395
- resolveWorkflowTurnIntent(options: {
396
- intentId: string;
397
- targetSessionId: string;
398
- claimToken: string;
399
- resolution: WorkflowTurnIntentResolution;
400
- messageId?: string;
401
- now?: string;
402
- }): boolean;
403
- releaseWorkflowTurnIntentClaim(options: {
404
- intentId: string;
405
- targetSessionId: string;
406
- claimToken: string;
407
- }): boolean;
408
- listWorkflowTurnIntents(options?: {
409
- runId?: string;
410
- targetSessionId?: string;
411
- unresolvedOnly?: boolean;
412
- limit?: number;
413
- }): WorkflowTurnIntentRecord[];
414
- enqueueWorkflowNotification(options: {
415
- runId: string;
416
- nodeId: string;
417
- attemptId: string;
418
- notificationIndex: number;
419
- targetSessionId: string;
420
- kind: "progress" | "final";
421
- content: string;
422
- now?: string;
423
- }): WorkflowNotificationRecord;
424
- listPendingWorkflowNotifications(options: {
425
- targetSessionId: string;
426
- limit?: number;
427
- }): WorkflowNotificationRecord[];
428
- claimPendingWorkflowNotifications(options: {
429
- targetSessionId: string;
430
- claimToken: string;
431
- leaseMs: number;
432
- now?: string;
433
- limit?: number;
434
- }): WorkflowNotificationRecord[];
435
- isWorkflowNotificationClaimLive(options: {
436
- notificationId: string;
437
- targetSessionId: string;
438
- claimToken: string;
439
- now?: string;
440
- }): boolean;
441
- markWorkflowNotificationDelivered(options: {
442
- notificationId: string;
443
- targetSessionId: string;
444
- claimToken: string;
445
- now?: string;
446
- }): boolean;
447
353
  settleRunEffect(runId: string, effectType: "run.park_queue" | "run.settle_queue"): void;
448
354
  setWorkflowRunOriginSession(runId: string, originSessionId: string): boolean;
449
355
  private ensureProject;
@@ -478,6 +384,7 @@ export declare class SqliteControllerStore implements ControllerStore {
478
384
  private requireWorkflowRunRow;
479
385
  private requireWorkflowRun;
480
386
  private assertWorkflowRunPreparationCompatible;
387
+ private workflowRunViewRows;
481
388
  private mapWorkflowRun;
482
389
  private claimRun;
483
390
  private claimRunInTransaction;
@@ -485,22 +392,5 @@ export declare class SqliteControllerStore implements ControllerStore {
485
392
  private releaseRunClaim;
486
393
  private terminalRun;
487
394
  private cancelWorkflowRunDependents;
488
- private turnIntent;
489
- private requireTurnIntent;
490
- private turnIntentRow;
491
- private turnIntentBySource;
492
- private mapTurnIntent;
493
- private claimEffectForTurn;
494
- private claimEffect;
495
- private verifyEffectToken;
496
- private releaseEffectLease;
497
- private completeEffect;
498
- private insertEffectResource;
499
- private notification;
500
- private requireNotification;
501
- private notificationRows;
502
- private notificationRowById;
503
- private mapNotification;
504
395
  private assertWritable;
505
396
  }
506
- export {};