@codemation/core 0.0.19 → 0.2.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 (81) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/EngineRuntimeRegistration.types-0sgV2XL2.d.ts +42 -0
  3. package/dist/EngineWorkflowRunnerService-Dx7bJsJR.d.cts +73 -0
  4. package/dist/InMemoryRunDataFactory-qIYQEar7.d.cts +94 -0
  5. package/dist/{InMemoryLiveWorkflowRepository-DxoualoC.d.ts → RunIntentService-BCvGdOSY.d.ts} +438 -9
  6. package/dist/{RunIntentService-C1nu_YwM.js → RunIntentService-BFA48UpH.js} +252 -67
  7. package/dist/RunIntentService-BFA48UpH.js.map +1 -0
  8. package/dist/{InMemoryLiveWorkflowRepository-orY1VsWG.d.cts → RunIntentService-CV8izV8t.d.cts} +214 -7
  9. package/dist/{RunIntentService-ZkjpY7MS.cjs → RunIntentService-DcxXf_AM.cjs} +262 -65
  10. package/dist/RunIntentService-DcxXf_AM.cjs.map +1 -0
  11. package/dist/bootstrap/index.cjs +14 -1135
  12. package/dist/bootstrap/index.d.cts +7 -60
  13. package/dist/bootstrap/index.d.ts +4 -40
  14. package/dist/bootstrap/index.js +3 -1122
  15. package/dist/bootstrap-D67Sf2BF.js +1136 -0
  16. package/dist/bootstrap-D67Sf2BF.js.map +1 -0
  17. package/dist/bootstrap-DoQHAEQJ.cjs +1203 -0
  18. package/dist/bootstrap-DoQHAEQJ.cjs.map +1 -0
  19. package/dist/{index-BIewO9-9.d.ts → index-CueSzHsf.d.ts} +37 -260
  20. package/dist/index.cjs +99 -223
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +201 -6
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +93 -218
  25. package/dist/index.js.map +1 -1
  26. package/dist/testing.cjs +329 -3
  27. package/dist/testing.cjs.map +1 -1
  28. package/dist/testing.d.cts +181 -4
  29. package/dist/testing.d.ts +181 -3
  30. package/dist/testing.js +319 -2
  31. package/dist/testing.js.map +1 -1
  32. package/dist/workflowActivationPolicy-B8HzTk3o.js +201 -0
  33. package/dist/workflowActivationPolicy-B8HzTk3o.js.map +1 -0
  34. package/dist/workflowActivationPolicy-BzyzXLa_.cjs +231 -0
  35. package/dist/workflowActivationPolicy-BzyzXLa_.cjs.map +1 -0
  36. package/package.json +1 -1
  37. package/src/ai/AgentConnectionNodeCollector.ts +99 -0
  38. package/src/ai/AgentToolFactory.ts +38 -2
  39. package/src/ai/AiHost.ts +1 -1
  40. package/src/authoring/defineNode.types.ts +6 -0
  41. package/src/browser.ts +11 -0
  42. package/src/contracts/executionPersistenceContracts.ts +186 -0
  43. package/src/contracts/index.ts +1 -0
  44. package/src/contracts/runFinishedAtFactory.ts +5 -2
  45. package/src/contracts/runTypes.ts +10 -0
  46. package/src/contracts/runtimeTypes.ts +6 -2
  47. package/src/contracts/workflowTypes.ts +3 -2
  48. package/src/events/EventPublishingWorkflowExecutionRepository.ts +5 -0
  49. package/src/execution/ActivationEnqueueService.ts +8 -8
  50. package/src/execution/PersistedRunStateTerminalBuilder.ts +3 -0
  51. package/src/index.ts +6 -0
  52. package/src/orchestration/NodeExecutionRequestHandlerService.ts +11 -6
  53. package/src/orchestration/RunContinuationService.ts +94 -24
  54. package/src/runStorage/InMemoryWorkflowExecutionRepository.ts +14 -1
  55. package/src/scheduler/DefaultDrivingScheduler.ts +21 -11
  56. package/src/scheduler/InlineDrivingScheduler.ts +17 -21
  57. package/src/testing/CapturingScheduler.ts +15 -0
  58. package/src/testing/EngineTestKitRunIdFactory.ts +24 -0
  59. package/src/testing/InMemoryTriggerSetupStateRepository.ts +21 -0
  60. package/src/testing/PrefixedSequentialIdGenerator.ts +17 -0
  61. package/src/testing/RegistrarEngineTestKit.types.ts +76 -0
  62. package/src/testing/RegistrarEngineTestKitFactory.ts +154 -0
  63. package/src/testing/SubWorkflowRunnerTestNode.ts +83 -0
  64. package/src/testing/WorkflowTestHarnessManualTrigger.ts +39 -0
  65. package/src/testing/WorkflowTestKit.types.ts +9 -0
  66. package/src/testing/WorkflowTestKitBuilder.ts +77 -0
  67. package/src/testing/WorkflowTestKitNodeRegistrationContextFactory.ts +17 -0
  68. package/src/testing/WorkflowTestKitRunNodeWorkflowFactory.ts +26 -0
  69. package/src/testing.ts +19 -0
  70. package/src/types/index.ts +1 -0
  71. package/src/workflow/definition/ConnectionNodeIdFactory.ts +28 -0
  72. package/dist/InMemoryLiveWorkflowRepository-BTzHpQ6e.cjs +0 -151
  73. package/dist/InMemoryLiveWorkflowRepository-BTzHpQ6e.cjs.map +0 -1
  74. package/dist/InMemoryLiveWorkflowRepository-BoLNnVLg.js +0 -139
  75. package/dist/InMemoryLiveWorkflowRepository-BoLNnVLg.js.map +0 -1
  76. package/dist/RunIntentService-C1nu_YwM.js.map +0 -1
  77. package/dist/RunIntentService-DjbxzBBP.d.cts +0 -288
  78. package/dist/RunIntentService-ZkjpY7MS.cjs.map +0 -1
  79. package/dist/WorkflowSnapshotCodec-DSEzKyt3.d.cts +0 -22
  80. package/dist/bootstrap/index.cjs.map +0 -1
  81. package/dist/bootstrap/index.js.map +0 -1
@@ -1,288 +0,0 @@
1
- import { $n as RunCurrentState, B as NodeActivationId, Br as RetryPolicySpec, Bt as BinaryStorageWriteResult, Cn as WorkflowSnapshotResolver, D as BinaryAttachment, Dn as WebhookInvocationMatch, Ft as BinaryBody, Gt as ExecutionContext, Hn as NodeInputsByPort, In as CurrentStateExecutionRequest, It as BinaryStorage, Kt as ExecutionContextFactory, Lt as BinaryStorageReadResult, On as WebhookTriggerMatcher, P as Items, Rt as BinaryStorageStatResult, Wt as ExecutionBinaryService, X as NodeOutputs, Xn as PersistedWorkflowTokenRegistryLike, Xt as NodeActivationContinuation, at as RunDataSnapshot, fr as WorkflowExecutionRepository, ht as WorkflowDefinition, in as NodeExecutionRequestHandler, ir as RunResult, it as RunDataFactory, kn as WebhookTriggerResolution, lr as WebhookRunResult, nn as NodeExecutionContext, on as NodeExecutionStatePublisher, ot as RunId, q as NodeId, qt as LiveWorkflowRepository, rn as NodeExecutionRequest, sr as RunStopCondition, tn as NodeBinaryAttachmentService, tr as RunExecutionOptions, tt as ParentExecutionRef, v as CredentialSessionService, wn as HttpMethod, xt as WorkflowId, yn as WorkflowRepository, z as MutableRunData } from "./InMemoryLiveWorkflowRepository-orY1VsWG.cjs";
2
-
3
- //#region src/orchestration/Engine.d.ts
4
- interface EngineTriggerRuntime {
5
- startTriggers(): Promise<void>;
6
- stop(): Promise<void>;
7
- syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void>;
8
- createTriggerTestItems(args: {
9
- workflow: WorkflowDefinition;
10
- nodeId: NodeId;
11
- }): Promise<Items | undefined>;
12
- }
13
- interface EngineRunStartService {
14
- runWorkflow(wf: WorkflowDefinition, startAt: NodeId, items: Items, parent?: ParentExecutionRef, executionOptions?: RunExecutionOptions, persistedStateOverrides?: Readonly<{
15
- workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
16
- mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"];
17
- }>): Promise<RunResult>;
18
- runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult>;
19
- }
20
- interface EngineRunContinuationService {
21
- markNodeRunning(args: {
22
- runId: RunId;
23
- activationId: NodeActivationId;
24
- nodeId: NodeId;
25
- inputsByPort: NodeInputsByPort;
26
- }): Promise<void>;
27
- resumeFromNodeResult(args: {
28
- runId: RunId;
29
- activationId: NodeActivationId;
30
- nodeId: NodeId;
31
- outputs: NodeOutputs;
32
- }): Promise<RunResult>;
33
- resumeFromNodeError(args: {
34
- runId: RunId;
35
- activationId: NodeActivationId;
36
- nodeId: NodeId;
37
- error: Error;
38
- }): Promise<RunResult>;
39
- resumeFromStepResult(args: {
40
- runId: RunId;
41
- activationId: NodeActivationId;
42
- nodeId: NodeId;
43
- outputs: NodeOutputs;
44
- }): Promise<RunResult>;
45
- resumeFromStepError(args: {
46
- runId: RunId;
47
- activationId: NodeActivationId;
48
- nodeId: NodeId;
49
- error: Error;
50
- }): Promise<RunResult>;
51
- waitForCompletion(runId: RunId): Promise<Extract<RunResult, {
52
- status: "completed" | "failed";
53
- }>>;
54
- waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult>;
55
- }
56
- interface EngineNodeExecutionRequestHandler {
57
- handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
58
- }
59
- interface EngineFacadeDeps {
60
- liveWorkflowRepository: LiveWorkflowRepository;
61
- tokenRegistry: PersistedWorkflowTokenRegistryLike;
62
- webhookTriggerMatcher: WebhookTriggerMatcher;
63
- workflowSnapshotResolver: WorkflowSnapshotResolver;
64
- triggerRuntime: EngineTriggerRuntime;
65
- runStartService: EngineRunStartService;
66
- runContinuationService: EngineRunContinuationService;
67
- nodeExecutionRequestHandler: EngineNodeExecutionRequestHandler;
68
- }
69
- /**
70
- * Runtime facade for orchestration, continuation, triggers, and webhook routing.
71
- * Prefer {@link import("../intents/RunIntentService").RunIntentService} for host/HTTP invocation boundaries.
72
- * The class token is exported from `@codemation/core/bootstrap` (not the main `@codemation/core` barrel).
73
- */
74
- declare class Engine implements NodeActivationContinuation, NodeExecutionRequestHandler {
75
- private readonly deps;
76
- constructor(deps: EngineFacadeDeps);
77
- loadWorkflows(workflows: ReadonlyArray<WorkflowDefinition>): void;
78
- getTokenRegistry(): EngineFacadeDeps["tokenRegistry"];
79
- resolveWorkflowSnapshot(args: {
80
- workflowId: WorkflowId;
81
- workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
82
- }): WorkflowDefinition | undefined;
83
- startTriggers(): Promise<void>;
84
- syncWorkflowTriggersForActivation(workflowId: WorkflowId): Promise<void>;
85
- start(workflows: WorkflowDefinition[]): Promise<void>;
86
- stop(): Promise<void>;
87
- resolveWebhookTrigger(args: {
88
- endpointPath: string;
89
- method: HttpMethod;
90
- }): WebhookTriggerResolution;
91
- createTriggerTestItems(args: {
92
- workflow: WorkflowDefinition;
93
- nodeId: NodeId;
94
- }): Promise<Items | undefined>;
95
- runWorkflow(wf: WorkflowDefinition, startAt: NodeId, items: Items, parent?: ParentExecutionRef, executionOptions?: RunExecutionOptions, persistedStateOverrides?: Readonly<{
96
- workflowSnapshot?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["workflowSnapshot"];
97
- mutableState?: NonNullable<Awaited<ReturnType<WorkflowExecutionRepository["load"]>>>["mutableState"];
98
- }>): Promise<RunResult>;
99
- runWorkflowFromState(request: CurrentStateExecutionRequest): Promise<RunResult>;
100
- markNodeRunning(args: {
101
- runId: RunId;
102
- activationId: NodeActivationId;
103
- nodeId: NodeId;
104
- inputsByPort: NodeInputsByPort;
105
- }): Promise<void>;
106
- resumeFromNodeResult(args: {
107
- runId: RunId;
108
- activationId: NodeActivationId;
109
- nodeId: NodeId;
110
- outputs: NodeOutputs;
111
- }): Promise<RunResult>;
112
- resumeFromNodeError(args: {
113
- runId: RunId;
114
- activationId: NodeActivationId;
115
- nodeId: NodeId;
116
- error: Error;
117
- }): Promise<RunResult>;
118
- resumeFromStepResult(args: {
119
- runId: RunId;
120
- activationId: NodeActivationId;
121
- nodeId: NodeId;
122
- outputs: NodeOutputs;
123
- }): Promise<RunResult>;
124
- resumeFromStepError(args: {
125
- runId: RunId;
126
- activationId: NodeActivationId;
127
- nodeId: NodeId;
128
- error: Error;
129
- }): Promise<RunResult>;
130
- waitForCompletion(runId: RunId): Promise<Extract<RunResult, {
131
- status: "completed" | "failed";
132
- }>>;
133
- waitForWebhookResponse(runId: RunId): Promise<WebhookRunResult>;
134
- handleNodeExecutionRequest(request: NodeExecutionRequest): Promise<void>;
135
- }
136
- //#endregion
137
- //#region src/execution/CredentialResolverFactory.d.ts
138
- declare class CredentialResolverFactory {
139
- private readonly credentialSessions;
140
- constructor(credentialSessions: CredentialSessionService);
141
- create(workflowId: WorkflowId, nodeId: NodeId, config?: NodeExecutionContext["config"]): NodeExecutionContext["getCredential"];
142
- }
143
- //#endregion
144
- //#region src/execution/asyncSleeper.types.d.ts
145
- interface AsyncSleeper {
146
- sleep(ms: number): Promise<void>;
147
- }
148
- //#endregion
149
- //#region src/execution/DefaultAsyncSleeper.d.ts
150
- declare class DefaultAsyncSleeper implements AsyncSleeper {
151
- sleep(ms: number): Promise<void>;
152
- }
153
- //#endregion
154
- //#region src/execution/DefaultExecutionContextFactory.d.ts
155
- declare class DefaultExecutionContextFactory implements ExecutionContextFactory {
156
- private readonly binaryStorage;
157
- private readonly currentDate;
158
- constructor(binaryStorage?: BinaryStorage, currentDate?: () => Date);
159
- create(args: {
160
- runId: RunId;
161
- workflowId: WorkflowId;
162
- parent?: ParentExecutionRef;
163
- subworkflowDepth: number;
164
- engineMaxNodeActivations: number;
165
- engineMaxSubworkflowDepth: number;
166
- data: RunDataSnapshot;
167
- nodeState?: NodeExecutionStatePublisher;
168
- getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
169
- }): ExecutionContext;
170
- }
171
- //#endregion
172
- //#region src/execution/InProcessRetryRunner.d.ts
173
- declare class InProcessRetryRunner {
174
- private readonly sleeper;
175
- constructor(sleeper: AsyncSleeper);
176
- run<T>(policy: RetryPolicySpec | undefined, work: () => Promise<T>): Promise<T>;
177
- private static delayAfterFailureMs;
178
- private static normalizePolicy;
179
- private static assertPositiveInt;
180
- private static assertNonNegativeFinite;
181
- private static assertMultiplier;
182
- }
183
- //#endregion
184
- //#region src/binaries/UnavailableBinaryStorage.d.ts
185
- declare class UnavailableBinaryStorage implements BinaryStorage {
186
- readonly driverName = "unavailable";
187
- write(): Promise<never>;
188
- openReadStream(): Promise<undefined>;
189
- stat(): Promise<{
190
- exists: false;
191
- }>;
192
- delete(): Promise<void>;
193
- }
194
- //#endregion
195
- //#region src/binaries/DefaultExecutionBinaryServiceFactory.d.ts
196
- declare class DefaultExecutionBinaryService implements ExecutionBinaryService {
197
- private readonly storage;
198
- private readonly workflowId;
199
- private readonly runId;
200
- private readonly now;
201
- constructor(storage: BinaryStorage, workflowId: WorkflowId, runId: RunId, now: () => Date);
202
- forNode(args: {
203
- nodeId: NodeId;
204
- activationId: NodeActivationId;
205
- }): NodeBinaryAttachmentService;
206
- openReadStream(attachment: BinaryAttachment): Promise<BinaryStorageReadResult | undefined>;
207
- }
208
- //#endregion
209
- //#region src/runStorage/InMemoryBinaryStorageRegistry.d.ts
210
- declare class InMemoryBinaryStorage implements BinaryStorage {
211
- readonly driverName = "memory";
212
- private readonly values;
213
- write(args: {
214
- storageKey: string;
215
- body: BinaryBody;
216
- }): Promise<BinaryStorageWriteResult>;
217
- openReadStream(storageKey: string): Promise<BinaryStorageReadResult | undefined>;
218
- stat(storageKey: string): Promise<BinaryStorageStatResult>;
219
- delete(storageKey: string): Promise<void>;
220
- }
221
- //#endregion
222
- //#region src/runStorage/InMemoryRunDataFactory.d.ts
223
- declare class InMemoryRunDataFactory implements RunDataFactory {
224
- create(initial?: Record<NodeId, NodeOutputs>): MutableRunData;
225
- }
226
- //#endregion
227
- //#region src/runtime/RunIntentService.d.ts
228
- type StartWorkflowIntent = {
229
- workflow: WorkflowDefinition;
230
- startAt?: string;
231
- items: Items;
232
- synthesizeTriggerItems?: boolean;
233
- parent?: CurrentStateExecutionRequest["parent"];
234
- executionOptions?: RunExecutionOptions;
235
- workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
236
- mutableState?: CurrentStateExecutionRequest["mutableState"];
237
- currentState?: RunCurrentState;
238
- stopCondition?: RunStopCondition;
239
- reset?: CurrentStateExecutionRequest["reset"];
240
- };
241
- type RerunFromNodeIntent = {
242
- workflow: WorkflowDefinition;
243
- nodeId: NodeId;
244
- currentState: RunCurrentState;
245
- items?: Items;
246
- synthesizeTriggerItems?: boolean;
247
- parent?: CurrentStateExecutionRequest["parent"];
248
- executionOptions?: RunExecutionOptions;
249
- workflowSnapshot?: CurrentStateExecutionRequest["workflowSnapshot"];
250
- mutableState?: CurrentStateExecutionRequest["mutableState"];
251
- };
252
- type MatchedWebhookRunIntent = {
253
- endpointPath: string;
254
- method: HttpMethod;
255
- requestItem: Items[number];
256
- };
257
- type WebhookMatchRunIntent = {
258
- match: WebhookInvocationMatch;
259
- requestItem: Items[number];
260
- };
261
- declare class RunIntentService {
262
- private readonly engine;
263
- private readonly workflowRepository;
264
- constructor(engine: Engine, workflowRepository: WorkflowRepository);
265
- startWorkflow(args: StartWorkflowIntent): Promise<RunResult>;
266
- rerunFromNode(args: RerunFromNodeIntent): Promise<RunResult>;
267
- private resolveStartWorkflowItems;
268
- private resolveRerunItems;
269
- private resolveStartWorkflowTriggerNodeId;
270
- private resolveRerunTriggerNodeId;
271
- private firstTriggerNodeId;
272
- private isTriggerNode;
273
- private hasNonEmptyItems;
274
- resolveWebhookTrigger(args: {
275
- endpointPath: string;
276
- method: HttpMethod;
277
- }): WebhookTriggerResolution;
278
- runMatchedWebhook(args: MatchedWebhookRunIntent): Promise<WebhookRunResult>;
279
- runWebhookMatch(args: WebhookMatchRunIntent): Promise<WebhookRunResult>;
280
- /**
281
- * Webhook-triggered runs always force inline execution first.
282
- * This is the highest-precedence scheduler override: it wins over node hints and container defaults.
283
- */
284
- private createWebhookExecutionOptions;
285
- }
286
- //#endregion
287
- export { UnavailableBinaryStorage as a, DefaultAsyncSleeper as c, Engine as d, DefaultExecutionBinaryService as i, AsyncSleeper as l, InMemoryRunDataFactory as n, InProcessRetryRunner as o, InMemoryBinaryStorage as r, DefaultExecutionContextFactory as s, RunIntentService as t, CredentialResolverFactory as u };
288
- //# sourceMappingURL=RunIntentService-DjbxzBBP.d.cts.map