condukt 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 (233) hide show
  1. package/dist/bridge/bridge.d.ts +34 -0
  2. package/dist/bridge/bridge.d.ts.map +1 -0
  3. package/dist/bridge/bridge.js +365 -0
  4. package/dist/bridge/bridge.js.map +1 -0
  5. package/dist/bridge/index.d.ts +3 -0
  6. package/dist/bridge/index.d.ts.map +1 -0
  7. package/dist/bridge/index.js +6 -0
  8. package/dist/bridge/index.js.map +1 -0
  9. package/dist/runtimes/copilot/copilot-adapter.d.ts +28 -0
  10. package/dist/runtimes/copilot/copilot-adapter.d.ts.map +1 -0
  11. package/dist/runtimes/copilot/copilot-adapter.js +50 -0
  12. package/dist/runtimes/copilot/copilot-adapter.js.map +1 -0
  13. package/dist/runtimes/copilot/copilot-backend.d.ts +49 -0
  14. package/dist/runtimes/copilot/copilot-backend.d.ts.map +1 -0
  15. package/dist/runtimes/copilot/copilot-backend.js +13 -0
  16. package/dist/runtimes/copilot/copilot-backend.js.map +1 -0
  17. package/dist/runtimes/copilot/index.d.ts +5 -0
  18. package/dist/runtimes/copilot/index.d.ts.map +1 -0
  19. package/dist/runtimes/copilot/index.js +11 -0
  20. package/dist/runtimes/copilot/index.js.map +1 -0
  21. package/dist/runtimes/copilot/process-killer.d.ts +13 -0
  22. package/dist/runtimes/copilot/process-killer.d.ts.map +1 -0
  23. package/dist/runtimes/copilot/process-killer.js +77 -0
  24. package/dist/runtimes/copilot/process-killer.js.map +1 -0
  25. package/dist/runtimes/copilot/subprocess-backend.d.ts +26 -0
  26. package/dist/runtimes/copilot/subprocess-backend.d.ts.map +1 -0
  27. package/dist/runtimes/copilot/subprocess-backend.js +308 -0
  28. package/dist/runtimes/copilot/subprocess-backend.js.map +1 -0
  29. package/dist/runtimes/mock/index.d.ts +3 -0
  30. package/dist/runtimes/mock/index.d.ts.map +1 -0
  31. package/dist/runtimes/mock/index.js +6 -0
  32. package/dist/runtimes/mock/index.js.map +1 -0
  33. package/dist/runtimes/mock/mock-runtime.d.ts +43 -0
  34. package/dist/runtimes/mock/mock-runtime.d.ts.map +1 -0
  35. package/dist/runtimes/mock/mock-runtime.js +153 -0
  36. package/dist/runtimes/mock/mock-runtime.js.map +1 -0
  37. package/dist/src/agent.d.ts +35 -0
  38. package/dist/src/agent.d.ts.map +1 -0
  39. package/dist/src/agent.js +257 -0
  40. package/dist/src/agent.js.map +1 -0
  41. package/dist/src/events.d.ts +153 -0
  42. package/dist/src/events.d.ts.map +1 -0
  43. package/dist/src/events.js +11 -0
  44. package/dist/src/events.js.map +1 -0
  45. package/dist/src/index.d.ts +8 -0
  46. package/dist/src/index.d.ts.map +1 -0
  47. package/dist/src/index.js +24 -0
  48. package/dist/src/index.js.map +1 -0
  49. package/dist/src/nodes.d.ts +63 -0
  50. package/dist/src/nodes.d.ts.map +1 -0
  51. package/dist/src/nodes.js +120 -0
  52. package/dist/src/nodes.js.map +1 -0
  53. package/dist/src/scheduler.d.ts +11 -0
  54. package/dist/src/scheduler.d.ts.map +1 -0
  55. package/dist/src/scheduler.js +478 -0
  56. package/dist/src/scheduler.js.map +1 -0
  57. package/dist/src/types.d.ts +201 -0
  58. package/dist/src/types.d.ts.map +1 -0
  59. package/dist/src/types.js +38 -0
  60. package/dist/src/types.js.map +1 -0
  61. package/dist/src/verify.d.ts +51 -0
  62. package/dist/src/verify.d.ts.map +1 -0
  63. package/dist/src/verify.js +126 -0
  64. package/dist/src/verify.js.map +1 -0
  65. package/dist/state/index.d.ts +5 -0
  66. package/dist/state/index.d.ts.map +1 -0
  67. package/dist/state/index.js +14 -0
  68. package/dist/state/index.js.map +1 -0
  69. package/dist/state/reducer.d.ts +11 -0
  70. package/dist/state/reducer.d.ts.map +1 -0
  71. package/dist/state/reducer.js +223 -0
  72. package/dist/state/reducer.js.map +1 -0
  73. package/dist/state/state-runtime.d.ts +30 -0
  74. package/dist/state/state-runtime.d.ts.map +1 -0
  75. package/dist/state/state-runtime.js +131 -0
  76. package/dist/state/state-runtime.js.map +1 -0
  77. package/dist/state/storage-memory.d.ts +24 -0
  78. package/dist/state/storage-memory.d.ts.map +1 -0
  79. package/dist/state/storage-memory.js +91 -0
  80. package/dist/state/storage-memory.js.map +1 -0
  81. package/dist/state/storage.d.ts +29 -0
  82. package/dist/state/storage.d.ts.map +1 -0
  83. package/dist/state/storage.js +175 -0
  84. package/dist/state/storage.js.map +1 -0
  85. package/dist/theme/index.d.ts +128 -0
  86. package/dist/theme/index.d.ts.map +1 -0
  87. package/dist/theme/index.js +59 -0
  88. package/dist/theme/index.js.map +1 -0
  89. package/dist/ui/ansi.d.ts +9 -0
  90. package/dist/ui/ansi.d.ts.map +1 -0
  91. package/dist/ui/ansi.js +78 -0
  92. package/dist/ui/ansi.js.map +1 -0
  93. package/dist/ui/components/FlowEdge.d.ts +5 -0
  94. package/dist/ui/components/FlowEdge.d.ts.map +1 -0
  95. package/dist/ui/components/FlowEdge.js +33 -0
  96. package/dist/ui/components/FlowEdge.js.map +1 -0
  97. package/dist/ui/components/FlowGraph.d.ts +10 -0
  98. package/dist/ui/components/FlowGraph.d.ts.map +1 -0
  99. package/dist/ui/components/FlowGraph.js +124 -0
  100. package/dist/ui/components/FlowGraph.js.map +1 -0
  101. package/dist/ui/components/FlowStatusBar.d.ts +7 -0
  102. package/dist/ui/components/FlowStatusBar.d.ts.map +1 -0
  103. package/dist/ui/components/FlowStatusBar.js +27 -0
  104. package/dist/ui/components/FlowStatusBar.js.map +1 -0
  105. package/dist/ui/components/MiniPipeline.d.ts +10 -0
  106. package/dist/ui/components/MiniPipeline.d.ts.map +1 -0
  107. package/dist/ui/components/MiniPipeline.js +155 -0
  108. package/dist/ui/components/MiniPipeline.js.map +1 -0
  109. package/dist/ui/components/NodeCard.d.ts +5 -0
  110. package/dist/ui/components/NodeCard.d.ts.map +1 -0
  111. package/dist/ui/components/NodeCard.js +39 -0
  112. package/dist/ui/components/NodeCard.js.map +1 -0
  113. package/dist/ui/components/NodeDetailPanel.d.ts +10 -0
  114. package/dist/ui/components/NodeDetailPanel.d.ts.map +1 -0
  115. package/dist/ui/components/NodeDetailPanel.js +38 -0
  116. package/dist/ui/components/NodeDetailPanel.js.map +1 -0
  117. package/dist/ui/components/node-panel/Controls.d.ts +16 -0
  118. package/dist/ui/components/node-panel/Controls.d.ts.map +1 -0
  119. package/dist/ui/components/node-panel/Controls.js +28 -0
  120. package/dist/ui/components/node-panel/Controls.js.map +1 -0
  121. package/dist/ui/components/node-panel/ErrorBar.d.ts +6 -0
  122. package/dist/ui/components/node-panel/ErrorBar.d.ts.map +1 -0
  123. package/dist/ui/components/node-panel/ErrorBar.js +14 -0
  124. package/dist/ui/components/node-panel/ErrorBar.js.map +1 -0
  125. package/dist/ui/components/node-panel/Gate.d.ts +13 -0
  126. package/dist/ui/components/node-panel/Gate.d.ts.map +1 -0
  127. package/dist/ui/components/node-panel/Gate.js +40 -0
  128. package/dist/ui/components/node-panel/Gate.js.map +1 -0
  129. package/dist/ui/components/node-panel/Header.d.ts +10 -0
  130. package/dist/ui/components/node-panel/Header.d.ts.map +1 -0
  131. package/dist/ui/components/node-panel/Header.js +19 -0
  132. package/dist/ui/components/node-panel/Header.js.map +1 -0
  133. package/dist/ui/components/node-panel/Info.d.ts +7 -0
  134. package/dist/ui/components/node-panel/Info.d.ts.map +1 -0
  135. package/dist/ui/components/node-panel/Info.js +23 -0
  136. package/dist/ui/components/node-panel/Info.js.map +1 -0
  137. package/dist/ui/components/node-panel/Output.d.ts +27 -0
  138. package/dist/ui/components/node-panel/Output.d.ts.map +1 -0
  139. package/dist/ui/components/node-panel/Output.js +66 -0
  140. package/dist/ui/components/node-panel/Output.js.map +1 -0
  141. package/dist/ui/components/node-panel/index.d.ts +47 -0
  142. package/dist/ui/components/node-panel/index.d.ts.map +1 -0
  143. package/dist/ui/components/node-panel/index.js +54 -0
  144. package/dist/ui/components/node-panel/index.js.map +1 -0
  145. package/dist/ui/components/node-panel/types.d.ts +23 -0
  146. package/dist/ui/components/node-panel/types.d.ts.map +1 -0
  147. package/dist/ui/components/node-panel/types.js +24 -0
  148. package/dist/ui/components/node-panel/types.js.map +1 -0
  149. package/dist/ui/core/components/Badge.d.ts +6 -0
  150. package/dist/ui/core/components/Badge.d.ts.map +1 -0
  151. package/dist/ui/core/components/Badge.js +11 -0
  152. package/dist/ui/core/components/Badge.js.map +1 -0
  153. package/dist/ui/core/components/Button.d.ts +9 -0
  154. package/dist/ui/core/components/Button.d.ts.map +1 -0
  155. package/dist/ui/core/components/Button.js +18 -0
  156. package/dist/ui/core/components/Button.js.map +1 -0
  157. package/dist/ui/core/components/ConfirmDialog.d.ts +11 -0
  158. package/dist/ui/core/components/ConfirmDialog.d.ts.map +1 -0
  159. package/dist/ui/core/components/ConfirmDialog.js +23 -0
  160. package/dist/ui/core/components/ConfirmDialog.js.map +1 -0
  161. package/dist/ui/core/components/ExecutionCard.d.ts +12 -0
  162. package/dist/ui/core/components/ExecutionCard.d.ts.map +1 -0
  163. package/dist/ui/core/components/ExecutionCard.js +15 -0
  164. package/dist/ui/core/components/ExecutionCard.js.map +1 -0
  165. package/dist/ui/core/components/NodeListItem.d.ts +10 -0
  166. package/dist/ui/core/components/NodeListItem.d.ts.map +1 -0
  167. package/dist/ui/core/components/NodeListItem.js +27 -0
  168. package/dist/ui/core/components/NodeListItem.js.map +1 -0
  169. package/dist/ui/core/components/PageHeader.d.ts +10 -0
  170. package/dist/ui/core/components/PageHeader.d.ts.map +1 -0
  171. package/dist/ui/core/components/PageHeader.js +9 -0
  172. package/dist/ui/core/components/PageHeader.js.map +1 -0
  173. package/dist/ui/core/components/SectionLabel.d.ts +6 -0
  174. package/dist/ui/core/components/SectionLabel.d.ts.map +1 -0
  175. package/dist/ui/core/components/SectionLabel.js +9 -0
  176. package/dist/ui/core/components/SectionLabel.js.map +1 -0
  177. package/dist/ui/core/components/Skeleton.d.ts +7 -0
  178. package/dist/ui/core/components/Skeleton.d.ts.map +1 -0
  179. package/dist/ui/core/components/Skeleton.js +26 -0
  180. package/dist/ui/core/components/Skeleton.js.map +1 -0
  181. package/dist/ui/core/components/Stat.d.ts +8 -0
  182. package/dist/ui/core/components/Stat.d.ts.map +1 -0
  183. package/dist/ui/core/components/Stat.js +9 -0
  184. package/dist/ui/core/components/Stat.js.map +1 -0
  185. package/dist/ui/core/components/Toast.d.ts +7 -0
  186. package/dist/ui/core/components/Toast.d.ts.map +1 -0
  187. package/dist/ui/core/components/Toast.js +28 -0
  188. package/dist/ui/core/components/Toast.js.map +1 -0
  189. package/dist/ui/core/components/__tests__/primitives.test.d.ts +2 -0
  190. package/dist/ui/core/components/__tests__/primitives.test.d.ts.map +1 -0
  191. package/dist/ui/core/components/__tests__/primitives.test.js +3 -0
  192. package/dist/ui/core/components/__tests__/primitives.test.js.map +1 -0
  193. package/dist/ui/core/components/index.d.ts +21 -0
  194. package/dist/ui/core/components/index.d.ts.map +1 -0
  195. package/dist/ui/core/components/index.js +24 -0
  196. package/dist/ui/core/components/index.js.map +1 -0
  197. package/dist/ui/core/index.d.ts +17 -0
  198. package/dist/ui/core/index.d.ts.map +1 -0
  199. package/dist/ui/core/index.js +56 -0
  200. package/dist/ui/core/index.js.map +1 -0
  201. package/dist/ui/core/utils.d.ts +6 -0
  202. package/dist/ui/core/utils.d.ts.map +1 -0
  203. package/dist/ui/core/utils.js +32 -0
  204. package/dist/ui/core/utils.js.map +1 -0
  205. package/dist/ui/graph/index.d.ts +4 -0
  206. package/dist/ui/graph/index.d.ts.map +1 -0
  207. package/dist/ui/graph/index.js +11 -0
  208. package/dist/ui/graph/index.js.map +1 -0
  209. package/dist/ui/hooks/useAutoSelectNode.d.ts +3 -0
  210. package/dist/ui/hooks/useAutoSelectNode.d.ts.map +1 -0
  211. package/dist/ui/hooks/useAutoSelectNode.js +36 -0
  212. package/dist/ui/hooks/useAutoSelectNode.js.map +1 -0
  213. package/dist/ui/hooks/useFlowExecution.d.ts +32 -0
  214. package/dist/ui/hooks/useFlowExecution.d.ts.map +1 -0
  215. package/dist/ui/hooks/useFlowExecution.js +113 -0
  216. package/dist/ui/hooks/useFlowExecution.js.map +1 -0
  217. package/dist/ui/hooks/useNodeNavigation.d.ts +3 -0
  218. package/dist/ui/hooks/useNodeNavigation.d.ts.map +1 -0
  219. package/dist/ui/hooks/useNodeNavigation.js +38 -0
  220. package/dist/ui/hooks/useNodeNavigation.js.map +1 -0
  221. package/dist/ui/hooks/useNodeOutput.d.ts +21 -0
  222. package/dist/ui/hooks/useNodeOutput.d.ts.map +1 -0
  223. package/dist/ui/hooks/useNodeOutput.js +75 -0
  224. package/dist/ui/hooks/useNodeOutput.js.map +1 -0
  225. package/dist/ui/index.d.ts +16 -0
  226. package/dist/ui/index.d.ts.map +1 -0
  227. package/dist/ui/index.js +37 -0
  228. package/dist/ui/index.js.map +1 -0
  229. package/dist/ui/utils.d.ts +3 -0
  230. package/dist/ui/utils.d.ts.map +1 -0
  231. package/dist/ui/utils.js +9 -0
  232. package/dist/ui/utils.js.map +1 -0
  233. package/package.json +87 -0
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Flow framework type system — generic, zero domain imports.
3
+ *
4
+ * Three primitives: agent(), deterministic(), gate()
5
+ * One combinator: verify()
6
+ * One composition: FlowGraph + run()
7
+ */
8
+ import type { ExecutionEvent, OutputEvent } from './events';
9
+ declare const __brand: unique symbol;
10
+ type Brand<T, B extends string> = T & {
11
+ readonly [__brand]: B;
12
+ };
13
+ /** Branded execution identifier. Create: `'my-id' as ExecutionId` */
14
+ export type ExecutionId = Brand<string, 'ExecutionId'>;
15
+ /**
16
+ * The fundamental callable unit.
17
+ * Receives NodeInput (composition data) + ExecutionContext (runtime services).
18
+ * Returns a routing action + optional artifact.
19
+ */
20
+ export type NodeFn = (input: NodeInput, ctx: ExecutionContext) => Promise<NodeOutput>;
21
+ /** What every node receives — composition-defined, framework-opaque. */
22
+ export interface NodeInput {
23
+ readonly dir: string;
24
+ readonly params: Readonly<Record<string, unknown>>;
25
+ readonly artifactPaths: Readonly<Record<string, string>>;
26
+ readonly retryContext?: RetryContext;
27
+ }
28
+ /** What every node returns — the scheduler handles event emission from this. */
29
+ export interface NodeOutput {
30
+ readonly action: string;
31
+ readonly artifact?: string;
32
+ readonly metadata?: Record<string, unknown>;
33
+ }
34
+ /** Populated on retry: prior output + check feedback + user override. */
35
+ export interface RetryContext {
36
+ readonly priorOutput: string | null;
37
+ readonly feedback: string;
38
+ readonly override?: string;
39
+ }
40
+ /** Runtime services injected by the scheduler — not shared mutable state. */
41
+ export interface ExecutionContext {
42
+ readonly executionId: string;
43
+ readonly nodeId: string;
44
+ readonly runtime: AgentRuntime;
45
+ readonly emitOutput: (event: OutputEvent) => void;
46
+ readonly signal: AbortSignal;
47
+ }
48
+ /** A complete flow graph: nodes + edges + start. */
49
+ export interface FlowGraph {
50
+ readonly nodes: Readonly<Record<string, NodeEntry>>;
51
+ readonly edges: Readonly<Record<string, Readonly<Record<string, string>>>>;
52
+ readonly start: readonly string[];
53
+ }
54
+ /** A node in the flow graph. */
55
+ export interface NodeEntry {
56
+ readonly fn: NodeFn;
57
+ readonly displayName: string;
58
+ readonly nodeType: 'agent' | 'deterministic' | 'gate' | 'verify';
59
+ readonly output?: string;
60
+ readonly reads?: readonly string[];
61
+ readonly model?: string;
62
+ readonly timeout?: number;
63
+ }
64
+ export interface RunOptions {
65
+ readonly executionId: string;
66
+ readonly dir: string;
67
+ readonly params: Readonly<Record<string, unknown>>;
68
+ readonly runtime: AgentRuntime;
69
+ readonly emitState: (event: ExecutionEvent) => Promise<void>;
70
+ readonly emitOutput: (event: OutputEvent) => void;
71
+ readonly signal: AbortSignal;
72
+ readonly resumeFrom?: ResumeState;
73
+ /** PARITY-1: RetryContext for specific nodes (nodeId → RetryContext). */
74
+ readonly retryContexts?: Readonly<Record<string, RetryContext>>;
75
+ }
76
+ export interface RunResult {
77
+ readonly completed: boolean;
78
+ readonly durationMs: number;
79
+ }
80
+ export interface ResumeState {
81
+ readonly completedNodes: Map<string, {
82
+ action: string;
83
+ finishedAt: number;
84
+ }>;
85
+ readonly firedEdges: Map<string, Set<string>>;
86
+ readonly nodeStatuses: Map<string, string>;
87
+ }
88
+ export interface AgentRuntime {
89
+ createSession(config: SessionConfig): Promise<AgentSession>;
90
+ isAvailable(): Promise<boolean>;
91
+ readonly name: string;
92
+ }
93
+ export interface SessionConfig {
94
+ readonly model: string;
95
+ readonly cwd: string;
96
+ readonly addDirs: readonly string[];
97
+ readonly timeout: number;
98
+ readonly heartbeatTimeout: number;
99
+ }
100
+ export interface AgentSession {
101
+ readonly pid: number | null;
102
+ send(prompt: string): void;
103
+ on(event: 'text', handler: (text: string) => void): void;
104
+ on(event: 'tool_start', handler: (tool: string, input: string) => void): void;
105
+ on(event: 'tool_complete', handler: (tool: string, output: string) => void): void;
106
+ on(event: 'idle', handler: () => void): void;
107
+ on(event: 'error', handler: (err: Error) => void): void;
108
+ abort(): Promise<void>;
109
+ }
110
+ export type PromptOutput = string | {
111
+ system: string;
112
+ user: string;
113
+ };
114
+ export interface ToolRef {
115
+ readonly id: string;
116
+ readonly displayName: string;
117
+ }
118
+ export interface AgentConfig {
119
+ readonly objective: string;
120
+ readonly tools: readonly ToolRef[];
121
+ readonly output?: string;
122
+ readonly reads?: readonly string[];
123
+ readonly model?: string;
124
+ readonly isolation?: boolean;
125
+ readonly timeout?: number;
126
+ readonly heartbeatTimeout?: number;
127
+ /** Override session cwd. Default: input.dir. Use for running in repo dir while artifacts go to input.dir. */
128
+ readonly cwdResolver?: (input: NodeInput) => string;
129
+ readonly setup?: (input: NodeInput) => void | Promise<void>;
130
+ readonly teardown?: (input: NodeInput) => void | Promise<void>;
131
+ readonly promptBuilder: (input: NodeInput) => PromptOutput;
132
+ readonly actionParser?: (artifactContent: string) => string;
133
+ readonly completionIndicators?: readonly string[];
134
+ }
135
+ export interface ExecutionProjection {
136
+ readonly id: string;
137
+ readonly flowId: string;
138
+ readonly status: 'pending' | 'running' | 'completed' | 'failed' | 'stopped' | 'crashed';
139
+ readonly params: Record<string, unknown>;
140
+ readonly graph: {
141
+ readonly nodes: ReadonlyArray<ProjectionNode>;
142
+ readonly edges: ReadonlyArray<ProjectionEdge>;
143
+ readonly activeNodes: readonly string[];
144
+ readonly completedPath: readonly string[];
145
+ };
146
+ readonly totalCost: number;
147
+ readonly startedAt?: number;
148
+ readonly finishedAt?: number;
149
+ readonly metadata: Record<string, unknown>;
150
+ }
151
+ export interface ProjectionNode {
152
+ readonly id: string;
153
+ readonly displayName: string;
154
+ readonly nodeType: string;
155
+ readonly model?: string;
156
+ readonly status: string;
157
+ readonly action?: string;
158
+ readonly startedAt?: number;
159
+ readonly finishedAt?: number;
160
+ readonly elapsedMs?: number;
161
+ readonly attempt: number;
162
+ readonly error?: string;
163
+ readonly output?: string;
164
+ readonly gateData?: Record<string, unknown>;
165
+ }
166
+ export interface ProjectionEdge {
167
+ readonly source: string;
168
+ readonly action: string;
169
+ readonly target: string;
170
+ readonly state: 'default' | 'taken' | 'not_taken';
171
+ }
172
+ export interface OutputPage {
173
+ readonly lines: readonly string[];
174
+ readonly offset: number;
175
+ readonly total: number;
176
+ readonly hasMore: boolean;
177
+ }
178
+ export interface StorageEngine {
179
+ appendEvent(execId: string, event: ExecutionEvent): void;
180
+ readEvents(execId: string): ExecutionEvent[];
181
+ writeProjection(execId: string, projection: ExecutionProjection): void;
182
+ readProjection(execId: string): ExecutionProjection | null;
183
+ writeArtifact(execId: string, nodeId: string, name: string, content: string): void;
184
+ readArtifact(execId: string, nodeId: string, name: string): string | null;
185
+ appendOutput(execId: string, nodeId: string, line: string): void;
186
+ readOutput(execId: string, nodeId: string, offset?: number, limit?: number): OutputPage;
187
+ closeOutput(execId: string, nodeId: string): void;
188
+ delete(execId: string): boolean;
189
+ listExecutionIds(): string[];
190
+ }
191
+ /** Type-safe params access: `getParams<MyParams>(projection)` (CR2) */
192
+ export declare function getParams<T>(projection: ExecutionProjection): T;
193
+ export declare class FlowAbortedError extends Error {
194
+ constructor(reason?: string);
195
+ }
196
+ export declare class FlowValidationError extends Error {
197
+ readonly issues: readonly string[];
198
+ constructor(issues: readonly string[]);
199
+ }
200
+ export {};
201
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAM5D,OAAO,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,CAAC;AACrC,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAEhE,qEAAqE;AACrE,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAMvD;;;;GAIG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtF,wEAAwE;AACxE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;CACtC;AAED,gFAAgF;AAChF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,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E,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACxF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,gBAAgB,IAAI,MAAM,EAAE,CAAC;CAC9B;AAMD,uEAAuE;AACvE,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,EAAE,mBAAmB,GAAG,CAAC,CAE/D;AAMD,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,MAAM,GAAE,MAAuB;CAI5C;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE;gBAAzB,MAAM,EAAE,SAAS,MAAM,EAAE;CAI/C"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * Flow framework type system — generic, zero domain imports.
4
+ *
5
+ * Three primitives: agent(), deterministic(), gate()
6
+ * One combinator: verify()
7
+ * One composition: FlowGraph + run()
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.FlowValidationError = exports.FlowAbortedError = void 0;
11
+ exports.getParams = getParams;
12
+ // ---------------------------------------------------------------------------
13
+ // Utilities
14
+ // ---------------------------------------------------------------------------
15
+ /** Type-safe params access: `getParams<MyParams>(projection)` (CR2) */
16
+ function getParams(projection) {
17
+ return projection.params;
18
+ }
19
+ // ---------------------------------------------------------------------------
20
+ // Errors
21
+ // ---------------------------------------------------------------------------
22
+ class FlowAbortedError extends Error {
23
+ constructor(reason = 'Flow aborted') {
24
+ super(reason);
25
+ this.name = 'FlowAbortedError';
26
+ }
27
+ }
28
+ exports.FlowAbortedError = FlowAbortedError;
29
+ class FlowValidationError extends Error {
30
+ issues;
31
+ constructor(issues) {
32
+ super(`Flow validation failed:\n${issues.map(i => ` - ${i}`).join('\n')}`);
33
+ this.issues = issues;
34
+ this.name = 'FlowValidationError';
35
+ }
36
+ }
37
+ exports.FlowValidationError = FlowValidationError;
38
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AA8OH,8BAEC;AAPD,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,uEAAuE;AACvE,SAAgB,SAAS,CAAI,UAA+B;IAC1D,OAAO,UAAU,CAAC,MAAW,CAAC;AAChC,CAAC;AAED,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAY,SAAiB,cAAc;QACzC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AALD,4CAKC;AAED,MAAa,mBAAoB,SAAQ,KAAK;IACvB;IAArB,YAAqB,MAAyB;QAC5C,KAAK,CAAC,4BAA4B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QADzD,WAAM,GAAN,MAAM,CAAmB;QAE5C,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Verify combinator — wraps a producer NodeFn with a check loop.
3
+ *
4
+ * On each iteration:
5
+ * 1. Call the producer to generate output
6
+ * 2. Run all checks against the output
7
+ * 3. If all pass → return the producer's output
8
+ * 4. If any fail → build feedback, inject RetryContext, retry
9
+ * 5. If max iterations reached → return { action: 'fail' }
10
+ *
11
+ * The verify combinator is itself a NodeFn. From the scheduler's perspective,
12
+ * it's one node that may take multiple internal iterations.
13
+ */
14
+ import type { NodeFn } from './types';
15
+ export interface VerifyCheck {
16
+ readonly name: string;
17
+ readonly fn: (dir: string, artifactContent: string | undefined) => Promise<CheckResult>;
18
+ }
19
+ export interface CheckResult {
20
+ readonly passed: boolean;
21
+ readonly feedback: string;
22
+ }
23
+ export interface VerifyConfig {
24
+ readonly checks: readonly VerifyCheck[];
25
+ readonly maxIterations?: number;
26
+ }
27
+ /**
28
+ * Creates a VerifyCheck from a predicate function.
29
+ *
30
+ * @param name - Display name for the check
31
+ * @param predicate - Function that examines artifact content and returns true/false
32
+ * @param failureMessage - Message to include in feedback when check fails
33
+ */
34
+ export declare function property(name: string, predicate: (content: string) => boolean, failureMessage: string): VerifyCheck;
35
+ /**
36
+ * Wraps a producer NodeFn with iterative verification.
37
+ *
38
+ * The returned NodeFn:
39
+ * 1. Calls the producer (which may be an agent, deterministic, etc.)
40
+ * 2. Runs all checks against the producer's output
41
+ * 3. If all checks pass → returns the producer's NodeOutput
42
+ * 4. If any check fails → injects RetryContext with feedback, calls producer again
43
+ * 5. After maxIterations failures → returns { action: 'fail' }
44
+ *
45
+ * Each iteration emits metadata events with check results for observability.
46
+ *
47
+ * @param producer - The NodeFn to wrap (e.g., an agent node)
48
+ * @param config - Checks to run and max iterations
49
+ */
50
+ export declare function verify(producer: NodeFn, config: VerifyConfig): NodeFn;
51
+ //# sourceMappingURL=verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,MAAM,EAIP,MAAM,SAAS,CAAC;AAMjB,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CACzF;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAMD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,EACvC,cAAc,EAAE,MAAM,GACrB,WAAW,CAcb;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GACnB,MAAM,CA4ER"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ /**
3
+ * Verify combinator — wraps a producer NodeFn with a check loop.
4
+ *
5
+ * On each iteration:
6
+ * 1. Call the producer to generate output
7
+ * 2. Run all checks against the output
8
+ * 3. If all pass → return the producer's output
9
+ * 4. If any fail → build feedback, inject RetryContext, retry
10
+ * 5. If max iterations reached → return { action: 'fail' }
11
+ *
12
+ * The verify combinator is itself a NodeFn. From the scheduler's perspective,
13
+ * it's one node that may take multiple internal iterations.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.property = property;
17
+ exports.verify = verify;
18
+ // ---------------------------------------------------------------------------
19
+ // property() — convenience factory for common check patterns
20
+ // ---------------------------------------------------------------------------
21
+ /**
22
+ * Creates a VerifyCheck from a predicate function.
23
+ *
24
+ * @param name - Display name for the check
25
+ * @param predicate - Function that examines artifact content and returns true/false
26
+ * @param failureMessage - Message to include in feedback when check fails
27
+ */
28
+ function property(name, predicate, failureMessage) {
29
+ return {
30
+ name,
31
+ fn: async (_dir, artifactContent) => {
32
+ if (artifactContent == null || artifactContent.trim() === '') {
33
+ return { passed: false, feedback: `${name}: No artifact content to verify` };
34
+ }
35
+ const passed = predicate(artifactContent);
36
+ return {
37
+ passed,
38
+ feedback: passed ? `${name}: passed` : `${name}: ${failureMessage}`,
39
+ };
40
+ },
41
+ };
42
+ }
43
+ // ---------------------------------------------------------------------------
44
+ // verify() — the combinator
45
+ // ---------------------------------------------------------------------------
46
+ /**
47
+ * Wraps a producer NodeFn with iterative verification.
48
+ *
49
+ * The returned NodeFn:
50
+ * 1. Calls the producer (which may be an agent, deterministic, etc.)
51
+ * 2. Runs all checks against the producer's output
52
+ * 3. If all checks pass → returns the producer's NodeOutput
53
+ * 4. If any check fails → injects RetryContext with feedback, calls producer again
54
+ * 5. After maxIterations failures → returns { action: 'fail' }
55
+ *
56
+ * Each iteration emits metadata events with check results for observability.
57
+ *
58
+ * @param producer - The NodeFn to wrap (e.g., an agent node)
59
+ * @param config - Checks to run and max iterations
60
+ */
61
+ function verify(producer, config) {
62
+ const maxIterations = config.maxIterations ?? 3;
63
+ return async (input, ctx) => {
64
+ let currentInput = input;
65
+ for (let iteration = 1; iteration <= maxIterations; iteration++) {
66
+ // Run the producer
67
+ const output = await producer(currentInput, ctx);
68
+ // Run all checks
69
+ const checkResults = await Promise.all(config.checks.map(async (check) => {
70
+ try {
71
+ return await check.fn(input.dir, output.artifact);
72
+ }
73
+ catch (err) {
74
+ return {
75
+ passed: false,
76
+ feedback: `${check.name}: check error — ${err instanceof Error ? err.message : String(err)}`,
77
+ };
78
+ }
79
+ }));
80
+ const allPassed = checkResults.every((r) => r.passed);
81
+ // Emit check results as metadata for observability
82
+ const metadataOutput = {
83
+ action: output.action,
84
+ artifact: output.artifact,
85
+ metadata: {
86
+ ...(output.metadata ?? {}),
87
+ _verifyIteration: iteration,
88
+ _verifyMaxIterations: maxIterations,
89
+ _verifyChecks: checkResults.map((r, i) => ({
90
+ name: config.checks[i].name,
91
+ passed: r.passed,
92
+ feedback: r.feedback,
93
+ })),
94
+ },
95
+ };
96
+ if (allPassed) {
97
+ return metadataOutput;
98
+ }
99
+ // Last iteration — fail
100
+ if (iteration === maxIterations) {
101
+ return {
102
+ action: 'fail',
103
+ artifact: output.artifact,
104
+ metadata: metadataOutput.metadata,
105
+ };
106
+ }
107
+ // Build feedback for retry
108
+ const failedChecks = checkResults
109
+ .filter((r) => !r.passed)
110
+ .map((r) => r.feedback);
111
+ const feedbackStr = `Verification failed (attempt ${iteration}/${maxIterations}):\n${failedChecks.map((f) => ` - ${f}`).join('\n')}`;
112
+ // Retry with RetryContext
113
+ currentInput = {
114
+ ...input,
115
+ retryContext: {
116
+ priorOutput: output.artifact ?? null,
117
+ feedback: feedbackStr,
118
+ override: currentInput.retryContext?.override,
119
+ },
120
+ };
121
+ }
122
+ // Should not reach here, but TypeScript needs it
123
+ return { action: 'fail' };
124
+ };
125
+ }
126
+ //# sourceMappingURL=verify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/verify.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;AAuCH,4BAkBC;AAqBD,wBA+EC;AAjID,8EAA8E;AAC9E,6DAA6D;AAC7D,8EAA8E;AAE9E;;;;;;GAMG;AACH,SAAgB,QAAQ,CACtB,IAAY,EACZ,SAAuC,EACvC,cAAsB;IAEtB,OAAO;QACL,IAAI;QACJ,EAAE,EAAE,KAAK,EAAE,IAAY,EAAE,eAAmC,EAAwB,EAAE;YACpF,IAAI,eAAe,IAAI,IAAI,IAAI,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;gBAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,iCAAiC,EAAE,CAAC;YAC/E,CAAC;YACD,MAAM,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;YAC1C,OAAO;gBACL,MAAM;gBACN,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,cAAc,EAAE;aACpE,CAAC;QACJ,CAAC;KACF,CA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Y,CAAC,YAAY,EAAE,QAAQ;iBAC9C;aACF,CAAC;QACJ,CAAC;QAED,iDAAiD;QACjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { reduce, createEmptyProjection, replayEvents } from './reducer';
2
+ export { FileStorage } from './storage';
3
+ export { MemoryStorage } from './storage-memory';
4
+ export { StateRuntime } from './state-runtime';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StateRuntime = exports.MemoryStorage = exports.FileStorage = exports.replayEvents = exports.createEmptyProjection = exports.reduce = void 0;
4
+ var reducer_1 = require("./reducer");
5
+ Object.defineProperty(exports, "reduce", { enumerable: true, get: function () { return reducer_1.reduce; } });
6
+ Object.defineProperty(exports, "createEmptyProjection", { enumerable: true, get: function () { return reducer_1.createEmptyProjection; } });
7
+ Object.defineProperty(exports, "replayEvents", { enumerable: true, get: function () { return reducer_1.replayEvents; } });
8
+ var storage_1 = require("./storage");
9
+ Object.defineProperty(exports, "FileStorage", { enumerable: true, get: function () { return storage_1.FileStorage; } });
10
+ var storage_memory_1 = require("./storage-memory");
11
+ Object.defineProperty(exports, "MemoryStorage", { enumerable: true, get: function () { return storage_memory_1.MemoryStorage; } });
12
+ var state_runtime_1 = require("./state-runtime");
13
+ Object.defineProperty(exports, "StateRuntime", { enumerable: true, get: function () { return state_runtime_1.StateRuntime; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../state/index.ts"],"names":[],"mappings":";;;AAAA,qCAAwE;AAA/D,iGAAA,MAAM,OAAA;AAAE,gHAAA,qBAAqB,OAAA;AAAE,uGAAA,YAAY,OAAA;AACpD,qCAAwC;AAA/B,sGAAA,WAAW,OAAA;AACpB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Pure projection reducer — folds ExecutionEvents into ExecutionProjection.
3
+ *
4
+ * Zero I/O. Exhaustive switch with `never` default. All updates are immutable.
5
+ */
6
+ import type { ExecutionProjection } from '../src/types';
7
+ import type { ExecutionEvent } from '../src/events';
8
+ export declare function createEmptyProjection(id: string, flowId?: string): ExecutionProjection;
9
+ export declare function reduce(state: ExecutionProjection, event: ExecutionEvent): ExecutionProjection;
10
+ export declare function replayEvents(id: string, events: readonly ExecutionEvent[]): ExecutionProjection;
11
+ //# sourceMappingURL=reducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../state/reducer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,mBAAmB,EAGpB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAMpD,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAetF;AA+CD,wBAAgB,MAAM,CACpB,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,cAAc,GACpB,mBAAmB,CA2KrB;AAMD,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,SAAS,cAAc,EAAE,GAChC,mBAAmB,CAKrB"}