@kindgi/runtime 0.0.0-bootstrap.0 → 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.
- package/LICENSE +201 -0
- package/README.md +65 -1
- package/dist/bindings.d.ts +186 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +4 -0
- package/dist/bindings.js.map +1 -0
- package/dist/derivation.d.ts +123 -0
- package/dist/derivation.d.ts.map +1 -0
- package/dist/derivation.js +249 -0
- package/dist/derivation.js.map +1 -0
- package/dist/errors.d.ts +78 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -0
- package/dist/event-bus.d.ts +41 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-bus.js +13 -0
- package/dist/event-bus.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/inputs.d.ts +160 -0
- package/dist/inputs.d.ts.map +1 -0
- package/dist/inputs.js +4 -0
- package/dist/inputs.js.map +1 -0
- package/dist/runs.d.ts +73 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +4 -0
- package/dist/runs.js.map +1 -0
- package/dist/schedulers/registry.d.ts +142 -0
- package/dist/schedulers/registry.d.ts.map +1 -0
- package/dist/schedulers/registry.js +4 -0
- package/dist/schedulers/registry.js.map +1 -0
- package/dist/schedulers/types.d.ts +99 -0
- package/dist/schedulers/types.d.ts.map +1 -0
- package/dist/schedulers/types.js +4 -0
- package/dist/schedulers/types.js.map +1 -0
- package/dist/types.d.ts +317 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/versioning.d.ts +59 -0
- package/dist/versioning.d.ts.map +1 -0
- package/dist/versioning.js +89 -0
- package/dist/versioning.js.map +1 -0
- package/package.json +50 -4
- package/src/bindings.ts +244 -0
- package/src/derivation.ts +354 -0
- package/src/errors.ts +92 -0
- package/src/event-bus.ts +51 -0
- package/src/index.ts +13 -0
- package/src/inputs.ts +169 -0
- package/src/runs.ts +84 -0
- package/src/schedulers/registry.ts +197 -0
- package/src/schedulers/types.ts +112 -0
- package/src/types.ts +378 -0
- package/src/versioning.ts +110 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Kindgi Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
1
1
|
# @kindgi/runtime
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Kindgi™ runtime wire-vocabulary + binding interfaces.
|
|
4
|
+
|
|
5
|
+
The public shape of everything that flows across the Kindgi runtime
|
|
6
|
+
boundary: what a run looks like, what a journal entry looks like,
|
|
7
|
+
what triggers a run, and how a deployment plugs its runtime
|
|
8
|
+
implementation into `createApp`.
|
|
9
|
+
|
|
10
|
+
Types and pure derivation functions — no runtime state, and no
|
|
11
|
+
dependency on a runtime implementation.
|
|
12
|
+
|
|
13
|
+
## What lives here
|
|
14
|
+
|
|
15
|
+
### Wire vocabulary
|
|
16
|
+
- `RunStatus`, `RunResult`, `RunOptions`
|
|
17
|
+
- `JournalEntry`, `JournalKind`
|
|
18
|
+
- All fanout / subgraph / iteration / step payload types
|
|
19
|
+
- Kernel error shapes (`KernelError`, `RunNotFoundError`,
|
|
20
|
+
`HandlerMissingError`, `WaitpointError`, …)
|
|
21
|
+
- Versioning envelope + `wrap` / `unwrap` + `EnvelopeError` variants
|
|
22
|
+
- Event-bus channel + `KernelEventBusBinding`
|
|
23
|
+
- Derivation helpers (`deriveRunState`, `normalizeHandlerResult`,
|
|
24
|
+
`waitResolutionKey`) — pure functions over journal shape
|
|
25
|
+
|
|
26
|
+
### Run inputs and records
|
|
27
|
+
- `RunFlowInput`, `ResumeRunInput`, `StartRunParams`, `DeleteRunParams`
|
|
28
|
+
and their error shapes
|
|
29
|
+
- `FlowResolver` (sub-flow lookup), `HandlerResolver` (handlers for each
|
|
30
|
+
child flow), `ParentRunRef` (the parent node of a child run)
|
|
31
|
+
- `KernelRunRecord` (with `output` and the `parentRunId` /
|
|
32
|
+
`parentNodeId` / `parentScope` fields), `ListRunsInput` (content scope,
|
|
33
|
+
`parent`, `topLevelOnly`), `ListRunsPage`
|
|
34
|
+
|
|
35
|
+
### Trigger surface
|
|
36
|
+
- `CronTriggerRecord`, `EventTriggerRecord`, `WebhookTriggerRecord`
|
|
37
|
+
- All `Register*Input` / `Update*Input` variants + `Get`/`List` inputs
|
|
38
|
+
- `TriggerRegistryBinding` (the caller-plugged binding)
|
|
39
|
+
- `RunFlowBinding` (turns a trigger fire into a run), `TriggerFireContext`,
|
|
40
|
+
`TriggerSource`, trigger config and error shapes
|
|
41
|
+
- `TRIGGER_KINDS`, `TriggerKind`
|
|
42
|
+
|
|
43
|
+
### Binding interfaces (deployment-plug-in contract)
|
|
44
|
+
- `RunBinding` — `runGraph`, `resumeRun`, `cancelRun`, `cancelToken`,
|
|
45
|
+
`completeToken`, `readJournal`, `startRun`, `deleteRun`, `getRun`,
|
|
46
|
+
`listRuns`
|
|
47
|
+
- `SchedulerBinding` — scheduler lifecycle
|
|
48
|
+
- `WaitpointBinding` — waitpoint-timeout sleeper
|
|
49
|
+
- `RunRetentionBinding` — retention adapter
|
|
50
|
+
- `KernelBinding` — umbrella that groups all four plus
|
|
51
|
+
`TriggerRegistryBinding` + `KernelEventBusBinding`. What
|
|
52
|
+
`CreateAppInput.kernelBinding` accepts.
|
|
53
|
+
|
|
54
|
+
## What does NOT live here
|
|
55
|
+
|
|
56
|
+
- Pack-author authoring surface (`NodeHandler`, `NodeContext`,
|
|
57
|
+
`HandlerResult`, `HandlerRegistry`, `LoopContext`,
|
|
58
|
+
`WaitpointCancelledError`) — those are in **`@kindgi/handler`**.
|
|
59
|
+
- Concrete runtime functions — the Kindgi runtime implements them,
|
|
60
|
+
reached through the `KernelBinding` interface plugged into
|
|
61
|
+
`createApp`.
|
|
62
|
+
- Storage schema and migrations — implementation details of the Kindgi
|
|
63
|
+
runtime.
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
Apache License 2.0 — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { Result, RunId, TenantId } from '@kindgi/types';
|
|
2
|
+
import type { KernelError } from './errors.js';
|
|
3
|
+
import type { KernelEventBusBinding } from './event-bus.js';
|
|
4
|
+
import type { DeleteRunError, DeleteRunParams, ResumeRunInput, RunFlowInput, StartRunError, StartRunParams } from './inputs.js';
|
|
5
|
+
import type { KernelRunRecord, ListRunsInput, ListRunsPage } from './runs.js';
|
|
6
|
+
import type { TriggerRegistryBinding } from './schedulers/registry.js';
|
|
7
|
+
import type { JournalEntry, RunResult } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Run-lifecycle binding. Every enforcement site (@kindgi/api routes,
|
|
10
|
+
* @kindgi/agents invocation flow) that wants to start / resume /
|
|
11
|
+
* cancel / read a run goes through this contract. The implementation
|
|
12
|
+
* is supplied by the Kindgi runtime.
|
|
13
|
+
*/
|
|
14
|
+
export interface RunBinding {
|
|
15
|
+
/**
|
|
16
|
+
* Run a flow until it completes, fails, is cancelled or suspends.
|
|
17
|
+
* Starts a new run, or — when `input.runId` is set — runs the
|
|
18
|
+
* `pending` run `startRun` created.
|
|
19
|
+
*/
|
|
20
|
+
runGraph<TOutput = unknown>(input: RunFlowInput): Promise<Result<RunResult<TOutput>, KernelError>>;
|
|
21
|
+
/**
|
|
22
|
+
* Resume a suspended or interrupted run. The journal is the source
|
|
23
|
+
* of truth; every completed step is skipped and only outstanding
|
|
24
|
+
* work is dispatched. `flow` + `handlers` must match the flow the
|
|
25
|
+
* run was started with — versioned pinning refuses re-versioned
|
|
26
|
+
* flows with `flow-mismatch`.
|
|
27
|
+
*/
|
|
28
|
+
resumeRun<TOutput = unknown>(input: ResumeRunInput): Promise<Result<RunResult<TOutput>, KernelError>>;
|
|
29
|
+
/**
|
|
30
|
+
* Cancel an in-flight or suspended run. Journals `run.cancelled`;
|
|
31
|
+
* outstanding handlers observe `ctx.abortSignal`. Optional
|
|
32
|
+
* `eventBus` is used to publish the cancellation event alongside
|
|
33
|
+
* the journal write.
|
|
34
|
+
*/
|
|
35
|
+
cancelRun(tenantId: TenantId, runId: RunId, eventBus?: KernelEventBusBinding): Promise<Result<void, KernelError>>;
|
|
36
|
+
/**
|
|
37
|
+
* Cancel an outstanding waitpoint. The handler observing the token
|
|
38
|
+
* via `ctx.waitForToken(...)` throws `WaitpointCancelledError` on
|
|
39
|
+
* resume with the supplied `reason`. Journals `wait.cancelled`.
|
|
40
|
+
*/
|
|
41
|
+
cancelToken(tenantId: TenantId, runId: RunId, tokenId: string, reason: string, eventBus?: KernelEventBusBinding): Promise<Result<void, KernelError>>;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve an outstanding waitpoint with a value. The handler
|
|
44
|
+
* observing the token via `ctx.waitForToken(...)` returns the value
|
|
45
|
+
* on resume. Journals `wait.resumed`.
|
|
46
|
+
*/
|
|
47
|
+
completeToken(tenantId: TenantId, runId: RunId, tokenId: string, value: unknown, eventBus?: KernelEventBusBinding): Promise<Result<void, KernelError>>;
|
|
48
|
+
/**
|
|
49
|
+
* Read the full ordered journal for a run — every entry, in
|
|
50
|
+
* sequence order. The primitive routes + agents consume this for
|
|
51
|
+
* SSE tailing + replay reconstruction.
|
|
52
|
+
*/
|
|
53
|
+
readJournal(tenantId: TenantId, runId: RunId): Promise<Result<readonly JournalEntry[], KernelError>>;
|
|
54
|
+
/**
|
|
55
|
+
* Create a `pending` run without dispatching it. Used by callers
|
|
56
|
+
* that want to hand back a `runId` synchronously and start the
|
|
57
|
+
* run out-of-band (background workers, HTTP `POST /v1/runs` with
|
|
58
|
+
* `wait: false` answering `202`, subgraph child dispatch); the run
|
|
59
|
+
* is then executed with `runGraph({ ..., runId })`.
|
|
60
|
+
*/
|
|
61
|
+
startRun(params: StartRunParams): Promise<Result<{
|
|
62
|
+
readonly runId: RunId;
|
|
63
|
+
}, StartRunError>>;
|
|
64
|
+
/**
|
|
65
|
+
* Delete a run + its journal + waitpoints. Retention path;
|
|
66
|
+
* `not-found` returned for missing runs so the caller can be
|
|
67
|
+
* idempotent under concurrent deletes.
|
|
68
|
+
*/
|
|
69
|
+
deleteRun(params: DeleteRunParams): Promise<Result<void, DeleteRunError>>;
|
|
70
|
+
/**
|
|
71
|
+
* Fetch a single run by id, scoped to tenant. Returns null if
|
|
72
|
+
* the run doesn't exist or belongs to a different tenant. Callers
|
|
73
|
+
* do additional authz gating (per-project scope) at the route
|
|
74
|
+
* layer; this method is a straight tenant-scoped point-read.
|
|
75
|
+
*/
|
|
76
|
+
getRun(tenantId: TenantId, runId: RunId): Promise<KernelRunRecord | null>;
|
|
77
|
+
/**
|
|
78
|
+
* List runs in `(createdAt desc, id desc)` order, cursor-
|
|
79
|
+
* paginated. Filter by content scope: absent = tenant-wide,
|
|
80
|
+
* `{ kind: 'project' }` narrows to one project, `{ kind: 'org' }`
|
|
81
|
+
* includes every project in the org. `parent` narrows to a run's
|
|
82
|
+
* children; `topLevelOnly` excludes child runs.
|
|
83
|
+
*/
|
|
84
|
+
listRuns(input: ListRunsInput): Promise<ListRunsPage>;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Scheduler bootstrap binding. Deployments start/stop these long-
|
|
88
|
+
* lived processes at boot; the trigger CRUD flows through
|
|
89
|
+
* `TriggerRegistryBinding` separately.
|
|
90
|
+
*/
|
|
91
|
+
export interface SchedulerBinding {
|
|
92
|
+
/**
|
|
93
|
+
* Start the cron scheduler process. Returns a handle whose
|
|
94
|
+
* `stop()` cleanly shuts it down. Deployments call this once at
|
|
95
|
+
* boot and hold the handle for graceful-shutdown wiring.
|
|
96
|
+
*/
|
|
97
|
+
startCronScheduler(options: CronSchedulerOptions): CronSchedulerHandle;
|
|
98
|
+
/** Start the event-trigger scheduler process. */
|
|
99
|
+
startEventTriggerScheduler(options: EventTriggerSchedulerOptions): EventTriggerSchedulerHandle;
|
|
100
|
+
/**
|
|
101
|
+
* Fire a specific webhook trigger by its webhookId. Called by a
|
|
102
|
+
* webhook receiver AFTER it has verified the request's HMAC
|
|
103
|
+
* signature. The scheduler resolves the trigger, dispatches the
|
|
104
|
+
* flow, and journals the fire.
|
|
105
|
+
*/
|
|
106
|
+
fireByWebhookId(input: FireByWebhookIdInput): Promise<Result<{
|
|
107
|
+
readonly runId: RunId;
|
|
108
|
+
}, unknown>>;
|
|
109
|
+
/**
|
|
110
|
+
* Compute the initial `nextFireAt` for a cron config. Called at
|
|
111
|
+
* trigger register/update to precompute the first-fire timestamp
|
|
112
|
+
* in the same write.
|
|
113
|
+
*/
|
|
114
|
+
initialNextFireAt(config: {
|
|
115
|
+
readonly cronExpression: string;
|
|
116
|
+
readonly timezone?: string;
|
|
117
|
+
}, now?: Date): Date;
|
|
118
|
+
}
|
|
119
|
+
export interface CronSchedulerOptions {
|
|
120
|
+
readonly runFlowBinding: unknown;
|
|
121
|
+
readonly pollIntervalMs?: number;
|
|
122
|
+
readonly logger?: (msg: string, ctx?: Record<string, unknown>) => void;
|
|
123
|
+
}
|
|
124
|
+
export interface CronSchedulerHandle {
|
|
125
|
+
stop(): Promise<void>;
|
|
126
|
+
}
|
|
127
|
+
export interface EventTriggerSchedulerOptions {
|
|
128
|
+
readonly runFlowBinding: unknown;
|
|
129
|
+
readonly logger?: (msg: string, ctx?: Record<string, unknown>) => void;
|
|
130
|
+
}
|
|
131
|
+
export interface EventTriggerSchedulerHandle {
|
|
132
|
+
stop(): Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
export interface FireByWebhookIdInput {
|
|
135
|
+
readonly tenantId: TenantId;
|
|
136
|
+
readonly webhookId: string;
|
|
137
|
+
readonly runFlowBinding: unknown;
|
|
138
|
+
readonly requestBody: unknown;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Waitpoint-timeout sleeper binding. A long-lived process that finds
|
|
142
|
+
* waitpoints whose timeout has passed and cancels them with
|
|
143
|
+
* `reason: 'timeout'`. Deployments start this at boot alongside the
|
|
144
|
+
* schedulers.
|
|
145
|
+
*/
|
|
146
|
+
export interface WaitpointBinding {
|
|
147
|
+
startTimeoutSleeper(options: WaitpointTimeoutSleeperOptions): WaitpointTimeoutSleeperHandle;
|
|
148
|
+
}
|
|
149
|
+
export interface WaitpointTimeoutSleeperOptions {
|
|
150
|
+
readonly pollIntervalMs?: number;
|
|
151
|
+
readonly logger?: (msg: string, ctx?: Record<string, unknown>) => void;
|
|
152
|
+
}
|
|
153
|
+
export interface WaitpointTimeoutSleeperHandle {
|
|
154
|
+
stop(): Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Run retention binding. Deployments plug this in to have expired
|
|
158
|
+
* runs (per tenant retention policy) reaped on a schedule.
|
|
159
|
+
*/
|
|
160
|
+
export interface RunRetentionBinding {
|
|
161
|
+
createRetentionAdapter(options: RunRetentionOptions): RunRetentionAdapter;
|
|
162
|
+
}
|
|
163
|
+
export interface RunRetentionOptions {
|
|
164
|
+
readonly logger?: (msg: string, ctx?: Record<string, unknown>) => void;
|
|
165
|
+
}
|
|
166
|
+
export interface RunRetentionAdapter {
|
|
167
|
+
reapExpired(input: {
|
|
168
|
+
readonly tenantId: TenantId;
|
|
169
|
+
}): Promise<{
|
|
170
|
+
readonly deleted: number;
|
|
171
|
+
}>;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Umbrella that groups every kernel-runtime binding. What
|
|
175
|
+
* `CreateAppInput.kernelBinding` in `@kindgi/api` accepts. The Kindgi
|
|
176
|
+
* runtime supplies the implementation.
|
|
177
|
+
*/
|
|
178
|
+
export interface KernelBinding {
|
|
179
|
+
readonly run: RunBinding;
|
|
180
|
+
readonly scheduler: SchedulerBinding;
|
|
181
|
+
readonly waitpoint: WaitpointBinding;
|
|
182
|
+
readonly retention: RunRetentionBinding;
|
|
183
|
+
readonly triggers: TriggerRegistryBinding;
|
|
184
|
+
readonly eventBus?: KernelEventBusBinding;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,GAAG,OAAO,EACxB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;IAEpD;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,GAAG,OAAO,EACzB,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC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,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAC3C"}
|
package/dist/bindings.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { HandlerResult, LoopContext } from '@kindgi/handler';
|
|
2
|
+
import type { EdgeId, NodeId } from '@kindgi/types';
|
|
3
|
+
import type { JournalEntry } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Pure functions that project journal entries into the state shapes the
|
|
6
|
+
* scheduler + evaluator consume. The journal is the sole source of truth
|
|
7
|
+
* for run state — every derivation goes through here.
|
|
8
|
+
*/
|
|
9
|
+
export interface DerivedRunState {
|
|
10
|
+
readonly completedNodes: Set<NodeId>;
|
|
11
|
+
readonly inFlightNodes: Set<NodeId>;
|
|
12
|
+
readonly failedNodes: Set<NodeId>;
|
|
13
|
+
/**
|
|
14
|
+
* Nodes whose most recent state transition is `wait.suspended` with no
|
|
15
|
+
* matching `wait.resumed` yet. The executor treats these as "in-progress
|
|
16
|
+
* from the scheduler's POV" (merged with `inFlightNodes` when building
|
|
17
|
+
* `SchedulerState`) so they don't get re-dispatched while the wait is
|
|
18
|
+
* outstanding, and terminates the tick loop as `suspended` when every
|
|
19
|
+
* outstanding node is in this bucket.
|
|
20
|
+
*/
|
|
21
|
+
readonly suspendedNodes: Set<NodeId>;
|
|
22
|
+
/**
|
|
23
|
+
* Nodes whose most recent transition is `step.concurrency-deferred` with
|
|
24
|
+
* no subsequent `step.started` / `step.failed`. Recorded so the tick
|
|
25
|
+
* loop knows the ready-set entry is "waiting on a lease" — dispatch
|
|
26
|
+
* skips these until the lease releases, then re-attempts acquisition
|
|
27
|
+
* on the next tick. Not merged into `inFlightNodes` (they haven't run
|
|
28
|
+
* yet); a deferred-only run isn't `suspended` (which is a wait-token
|
|
29
|
+
* concept) — it's transiently blocked on a peer.
|
|
30
|
+
*/
|
|
31
|
+
readonly deferredNodes: Set<NodeId>;
|
|
32
|
+
readonly edgeDecisions: Map<EdgeId, boolean>;
|
|
33
|
+
readonly nodeOutputs: Map<NodeId, unknown>;
|
|
34
|
+
readonly state: Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Ordered log of step.failed messages, first-seen order. Used to build
|
|
37
|
+
* `run.failed`'s summary payload.
|
|
38
|
+
*/
|
|
39
|
+
readonly failureMessages: string[];
|
|
40
|
+
/**
|
|
41
|
+
* Resolved wait values, keyed by `${nodeId}::${tokenId}`. Populated from
|
|
42
|
+
* `wait.resumed` journal entries. Handlers re-invoked after resume read
|
|
43
|
+
* from this map inside `ctx.waitForToken()` to return the resolved value
|
|
44
|
+
* instead of suspending again.
|
|
45
|
+
*/
|
|
46
|
+
readonly waitResolutions: Map<string, unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* Cancelled wait reasons, keyed by `${nodeId}::${tokenId}`. Populated from
|
|
49
|
+
* `wait.cancelled` journal entries. Handlers re-invoked after cancel read
|
|
50
|
+
* from this map inside `ctx.waitForToken()` to throw a
|
|
51
|
+
* `WaitpointCancelledError` instead of returning a value.
|
|
52
|
+
*/
|
|
53
|
+
readonly waitCancellations: Map<string, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Attempt counter per node, derived by counting `step.retry-scheduled`
|
|
56
|
+
* journal entries for that node. `0` on the initial dispatch. After N
|
|
57
|
+
* retries the counter is `N`. Exposed for observability + the executor's
|
|
58
|
+
* retry decision path; not consulted by the scheduler otherwise.
|
|
59
|
+
*/
|
|
60
|
+
readonly nodeAttempts: Map<NodeId, number>;
|
|
61
|
+
/**
|
|
62
|
+
* Loop-body steps that completed, keyed by `bodyStepKey(nodeId,
|
|
63
|
+
* loopContext)`. A loop replays from iteration zero on resume; the loop
|
|
64
|
+
* executor hands a body step that already completed its journaled
|
|
65
|
+
* result instead of running it again, as the outer flow does for its
|
|
66
|
+
* own completed steps.
|
|
67
|
+
*/
|
|
68
|
+
readonly completedBodySteps: Map<string, CompletedBodyStep>;
|
|
69
|
+
}
|
|
70
|
+
/** What a loop-body step journaled when it completed. */
|
|
71
|
+
export interface CompletedBodyStep {
|
|
72
|
+
readonly output: unknown;
|
|
73
|
+
readonly stateDelta?: Readonly<Record<string, unknown>>;
|
|
74
|
+
}
|
|
75
|
+
/** Composite key for `waitResolutions` lookups. */
|
|
76
|
+
export declare function waitResolutionKey(nodeId: NodeId, tokenId: string): string;
|
|
77
|
+
/** A loop-body step's key in `completedBodySteps`: the node, at its iteration of every enclosing loop. */
|
|
78
|
+
export declare function bodyStepKey(nodeId: NodeId, loopContext: LoopContext): string;
|
|
79
|
+
/**
|
|
80
|
+
* Fold journal entries into the run state view the scheduler needs.
|
|
81
|
+
*
|
|
82
|
+
* Rules:
|
|
83
|
+
* - `step.started` puts the node into `inFlightNodes`.
|
|
84
|
+
* - `step.completed` removes it from `inFlightNodes`, adds to `completedNodes`,
|
|
85
|
+
* records its `output` in `nodeOutputs`, and shallow-merges any `stateDelta`
|
|
86
|
+
* into `state` (last-writer-wins by journal sequence).
|
|
87
|
+
* - `step.failed` removes it from `inFlightNodes`, adds to `failedNodes`, and
|
|
88
|
+
* records the failure message.
|
|
89
|
+
* - `edge.evaluated` records the decision keyed by edgeId.
|
|
90
|
+
* - `wait.suspended` moves the node from `inFlightNodes` to
|
|
91
|
+
* `suspendedNodes`; `wait.resumed` / `wait.cancelled` take it out of
|
|
92
|
+
* `suspendedNodes` and record the value / reason by
|
|
93
|
+
* `waitResolutionKey(nodeId, tokenId)`.
|
|
94
|
+
* - `step.retry-scheduled` clears the node's failed / in-flight markers
|
|
95
|
+
* and increments `nodeAttempts`.
|
|
96
|
+
* - `step.concurrency-deferred` adds the node to `deferredNodes`.
|
|
97
|
+
* - a `step.completed` with a `loopContext` (a loop-body step) is also
|
|
98
|
+
* recorded in `completedBodySteps`.
|
|
99
|
+
* - Every other kind is informational (run.started, run.completed, etc.).
|
|
100
|
+
*/
|
|
101
|
+
export declare function deriveRunState(journal: readonly JournalEntry[]): DerivedRunState;
|
|
102
|
+
/** The state of a run with no journal entries — `deriveRunState([])`. */
|
|
103
|
+
export declare function createRunState(): DerivedRunState;
|
|
104
|
+
/**
|
|
105
|
+
* Apply one journal entry to `state`, in place, by the rules of
|
|
106
|
+
* `deriveRunState` (which folds the journal with it). A runtime that
|
|
107
|
+
* keeps a run's state in memory reads the journal once, then applies each
|
|
108
|
+
* entry it writes, instead of reading the journal again.
|
|
109
|
+
*/
|
|
110
|
+
export declare function applyJournalEntry(state: DerivedRunState, entry: JournalEntry): void;
|
|
111
|
+
/**
|
|
112
|
+
* A copy of `state` that later `applyJournalEntry` calls on `state` don't
|
|
113
|
+
* change — what a step sees should be the run as it stood when the step
|
|
114
|
+
* was dispatched. Values (node outputs, state values) are shared, not
|
|
115
|
+
* copied; the journal never changes a value in place.
|
|
116
|
+
*/
|
|
117
|
+
export declare function cloneRunState(state: DerivedRunState): DerivedRunState;
|
|
118
|
+
/**
|
|
119
|
+
* Normalize a raw handler return into a HandlerResult shape. Bare values
|
|
120
|
+
* become `{ output: value }`; already-structured values pass through.
|
|
121
|
+
*/
|
|
122
|
+
export declare function normalizeHandlerResult(raw: unknown): HandlerResult;
|
|
123
|
+
//# sourceMappingURL=derivation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivation.d.ts","sourceRoot":"","sources":["../src/derivation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OA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