@kindgi/runtime 0.1.4 → 0.1.5-rc.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/dist/bindings.d.ts +2 -0
- package/dist/bindings.d.ts.map +1 -1
- package/dist/errors.d.ts +11 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/inputs.d.ts +42 -9
- package/dist/inputs.d.ts.map +1 -1
- package/dist/runs.d.ts +17 -2
- package/dist/runs.d.ts.map +1 -1
- package/dist/schedulers/registry.d.ts +137 -8
- package/dist/schedulers/registry.d.ts.map +1 -1
- package/dist/schedulers/registry.js +5 -0
- package/dist/schedulers/registry.js.map +1 -1
- package/package.json +5 -5
- package/src/bindings.ts +10 -1
- package/src/errors.ts +13 -1
- package/src/inputs.ts +47 -8
- package/src/runs.ts +17 -1
- package/src/schedulers/registry.ts +155 -8
package/dist/bindings.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface RunBinding {
|
|
|
60
60
|
*/
|
|
61
61
|
startRun(params: StartRunParams): Promise<Result<{
|
|
62
62
|
readonly runId: RunId;
|
|
63
|
+
/** Set when `params.idempotencyKey` named a run that already exists: nothing new started. */
|
|
64
|
+
readonly existing?: true;
|
|
63
65
|
}, StartRunError>>;
|
|
64
66
|
/**
|
|
65
67
|
* Delete a run + its journal + waitpoints. Retention path;
|
package/dist/bindings.d.ts.map
CHANGED
|
@@ -1 +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,a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AAgB,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/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type KernelError = RunNotFoundError | FlowMismatchError | RunAlreadyTerminalError | NodeExecutionError | JournalError | WaitpointError | HandlerMissingError | StuckRunError | RunLeaseLostError;
|
|
1
|
+
export type KernelError = RunNotFoundError | FlowMismatchError | RunAlreadyTerminalError | NodeExecutionError | JournalError | WaitpointError | HandlerMissingError | StuckRunError | RunLeaseLostError | RunExecutingError;
|
|
2
2
|
export interface RunNotFoundError {
|
|
3
3
|
readonly code: 'run-not-found';
|
|
4
4
|
readonly message: string;
|
|
@@ -75,4 +75,14 @@ export interface RunLeaseLostError {
|
|
|
75
75
|
readonly message: string;
|
|
76
76
|
readonly runId: string;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* The run is executing (an executor holds its lease), and the caller asked
|
|
80
|
+
* to end it only if it isn't: an erasure cancels a person's waiting turn,
|
|
81
|
+
* never one under a live executor, and tries again later.
|
|
82
|
+
*/
|
|
83
|
+
export interface RunExecutingError {
|
|
84
|
+
readonly code: 'run-executing';
|
|
85
|
+
readonly message: string;
|
|
86
|
+
readonly runId: string;
|
|
87
|
+
}
|
|
78
88
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,WAAW,GACnB,gBAAgB,GAChB,iBAAiB,GACjB,uBAAuB,GACvB,kBAAkB,GAClB,YAAY,GACZ,cAAc,GACd,mBAAmB,GACnB,aA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IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB"}
|
package/dist/inputs.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Principal } from '@kindgi/authz';
|
|
2
2
|
import type { Flow, FlowVersionOverrides } from '@kindgi/flow';
|
|
3
3
|
import type { HandlerRegistry } from '@kindgi/handler';
|
|
4
|
-
import type { AgentVersionVia, ConversationId, LiveScope, NodeId, ProjectId, Result, RunId, ScopeSegment, TenantId } from '@kindgi/types';
|
|
4
|
+
import type { AgentVersionVia, ConversationId, LiveScope, NodeId, ProjectId, Result, RunId, ScopeSegment, TenantId, Timestamp, TriggerId } from '@kindgi/types';
|
|
5
5
|
import type { HandlerMissingError } from './errors.js';
|
|
6
6
|
import type { KernelEventBusBinding } from './event-bus.js';
|
|
7
7
|
import type { RunOptions } from './types.js';
|
|
@@ -57,6 +57,24 @@ export interface RunReplayRef {
|
|
|
57
57
|
readonly of: RunId;
|
|
58
58
|
readonly evalRunId: string;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Marks a run a trigger started: the trigger, the fire that started it,
|
|
62
|
+
* and for a schedule the occurrence it ran for.
|
|
63
|
+
*/
|
|
64
|
+
export interface RunTriggerRef {
|
|
65
|
+
readonly triggerId: TriggerId;
|
|
66
|
+
readonly kind: 'schedule' | 'event' | 'webhook';
|
|
67
|
+
readonly fireId: string;
|
|
68
|
+
/** A schedule's fire: the occurrence it ran for. */
|
|
69
|
+
readonly scheduledFor?: Timestamp;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The idempotency key of a run start: a start with a key a run of the
|
|
73
|
+
* tenant already has starts nothing and answers that run (`existing`), so
|
|
74
|
+
* a retried or re-driven start never runs twice. A trigger's fire uses
|
|
75
|
+
* `fire:<fireId>`. Keys are opaque, at most 255 characters.
|
|
76
|
+
*/
|
|
77
|
+
export type RunIdempotencyKey = string;
|
|
60
78
|
/**
|
|
61
79
|
* Binds the handlers for a flow the runtime is about to run or resume —
|
|
62
80
|
* the root flow and every child flow a subgraph node starts. Lets a
|
|
@@ -103,6 +121,14 @@ export interface RunFlowInput {
|
|
|
103
121
|
readonly agent?: RunAgentRef;
|
|
104
122
|
/** Set when an eval run is replaying a past run; see `RunReplayRef`. */
|
|
105
123
|
readonly replay?: RunReplayRef;
|
|
124
|
+
/**
|
|
125
|
+
* Set when the run doesn't exist yet (no `runId`): start it at most once
|
|
126
|
+
* per key; see `RunIdempotencyKey`. A key a run already has runs nothing
|
|
127
|
+
* and answers that run's current state.
|
|
128
|
+
*/
|
|
129
|
+
readonly idempotencyKey?: RunIdempotencyKey;
|
|
130
|
+
/** Set when a trigger started the run; see `RunTriggerRef`. */
|
|
131
|
+
readonly trigger?: RunTriggerRef;
|
|
106
132
|
/**
|
|
107
133
|
* The W3C trace id of the request that started the run (32 lowercase
|
|
108
134
|
* hex), kept on the run so its later turns and resumes can name the
|
|
@@ -137,9 +163,15 @@ export interface RunFlowInput {
|
|
|
137
163
|
*/
|
|
138
164
|
readonly eventBus?: KernelEventBusBinding;
|
|
139
165
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
166
|
+
* The Principal on whose authority this run executes: who started it
|
|
167
|
+
* (a caller, a schedule's creator, a service identity). Stored with
|
|
168
|
+
* the run, so every resume (an approval, a timeout, a child waking its
|
|
169
|
+
* flow, a run recovered after a crash) acts for the same principal.
|
|
170
|
+
* Only the start stores it: a pending run (`StartRunParams`) keeps the
|
|
171
|
+
* one it was started with, none included, whoever adopts it.
|
|
172
|
+
* When set together with `authz`, every `ctx.authorize` / `can` /
|
|
173
|
+
* `check` inside handlers is decided against it; on its own it only
|
|
174
|
+
* informs (e.g. whose own memory an agent turn may read).
|
|
143
175
|
*/
|
|
144
176
|
readonly principal?: Principal;
|
|
145
177
|
/**
|
|
@@ -168,11 +200,6 @@ export interface ResumeRunInput {
|
|
|
168
200
|
readonly handlerResolver?: HandlerResolver;
|
|
169
201
|
/** Same shape + semantics as `RunFlowInput.eventBus`. */
|
|
170
202
|
readonly eventBus?: KernelEventBusBinding;
|
|
171
|
-
/**
|
|
172
|
-
* Authorization — carried through on resume so the resumed run
|
|
173
|
-
* keeps enforcing per-tool + per-subgraph checks.
|
|
174
|
-
*/
|
|
175
|
-
readonly principal?: Principal;
|
|
176
203
|
readonly authz?: {
|
|
177
204
|
readonly fgaApiUrl: string;
|
|
178
205
|
};
|
|
@@ -190,12 +217,18 @@ export interface StartRunParams {
|
|
|
190
217
|
readonly agent?: RunAgentRef;
|
|
191
218
|
/** Set when an eval run is replaying a past run; see `RunReplayRef`. */
|
|
192
219
|
readonly replay?: RunReplayRef;
|
|
220
|
+
/** Start it at most once per key; see `RunIdempotencyKey`. */
|
|
221
|
+
readonly idempotencyKey?: RunIdempotencyKey;
|
|
222
|
+
/** Set when a trigger started the run; see `RunTriggerRef`. */
|
|
223
|
+
readonly trigger?: RunTriggerRef;
|
|
193
224
|
/** The trace id of the request that started the run; see `RunFlowInput.traceId`. */
|
|
194
225
|
readonly traceId?: string;
|
|
195
226
|
/** The versions the run swaps in over its flow version's pins; see `RunFlowInput.versions`. */
|
|
196
227
|
readonly versions?: FlowVersionOverrides;
|
|
197
228
|
/** The run's segment path; see `RunFlowInput.segments`. */
|
|
198
229
|
readonly segments?: readonly ScopeSegment[];
|
|
230
|
+
/** Who starts the run; stored with it, see `RunFlowInput.principal`. */
|
|
231
|
+
readonly principal?: Principal;
|
|
199
232
|
}
|
|
200
233
|
export type StartRunError = {
|
|
201
234
|
readonly code: 'insert-failed';
|
package/dist/inputs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,MAAM,EACN,SAAS,EACT,MAAM,EACN,KAAK,EACL,YAAY,EACZ,QAAQ,EACT,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,KAAK,EAAE;QAChB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,MA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M,CAAC;CAC3B,CAAC"}
|
package/dist/runs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FlowVersionOverrides } from '@kindgi/flow';
|
|
2
|
-
import type { Cursor, NodeId, OrgId, ProjectId, RunId, ScopeSegment, TenantId, Timestamp } from '@kindgi/types';
|
|
3
|
-
import type { RunAgentRef } from './inputs.js';
|
|
2
|
+
import type { Cursor, NodeId, OrgId, ProjectId, RunId, ScopeSegment, TenantId, Timestamp, TriggerId } from '@kindgi/types';
|
|
3
|
+
import type { RunAgentRef, RunTriggerRef } from './inputs.js';
|
|
4
4
|
import type { RunStatus } from './types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Public run shape exposed by `RunBinding.getRun` / `.listRuns`.
|
|
@@ -45,6 +45,13 @@ export interface KernelRunRecord {
|
|
|
45
45
|
* when it is a flow run. Absent when it was started without one.
|
|
46
46
|
*/
|
|
47
47
|
readonly segments?: readonly ScopeSegment[];
|
|
48
|
+
/** Set on a run a trigger started (`RunTriggerRef`). */
|
|
49
|
+
readonly trigger?: RunTriggerRef;
|
|
50
|
+
/**
|
|
51
|
+
* When an erasure cleared the run's content (its input, output, failure
|
|
52
|
+
* message and journal payloads). Absent on every other run.
|
|
53
|
+
*/
|
|
54
|
+
readonly contentErasedAt?: Timestamp;
|
|
48
55
|
/**
|
|
49
56
|
* The W3C trace id of the request that started the run
|
|
50
57
|
* (`RunFlowInput.traceId`). Absent for a run no request started, and on
|
|
@@ -73,6 +80,12 @@ export type RunListScope = {
|
|
|
73
80
|
* `{ createdAt, id }` internally.
|
|
74
81
|
*/
|
|
75
82
|
export interface RunListCursor {
|
|
83
|
+
/**
|
|
84
|
+
* The last run's `createdAt`, as the binding's `nextCursor` carries it:
|
|
85
|
+
* as stored (Postgres keeps microseconds). A binding compares it as given,
|
|
86
|
+
* never through a JS `Date`, which keeps milliseconds and would skip the
|
|
87
|
+
* runs created earlier in the same millisecond.
|
|
88
|
+
*/
|
|
76
89
|
readonly createdAt: Timestamp;
|
|
77
90
|
readonly id: RunId;
|
|
78
91
|
}
|
|
@@ -98,6 +111,8 @@ export interface ListRunsInput {
|
|
|
98
111
|
readonly replays?: 'exclude' | 'include' | 'only';
|
|
99
112
|
/** Only the replays of this eval run. */
|
|
100
113
|
readonly evalRunId?: string;
|
|
114
|
+
/** Only the runs this trigger started (`RunTriggerRef.triggerId`). */
|
|
115
|
+
readonly triggerId?: TriggerId;
|
|
101
116
|
}
|
|
102
117
|
export interface ListRunsPage {
|
|
103
118
|
readonly data: readonly KernelRunRecord[];
|
package/dist/runs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,SAAS,EACT,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACV,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,SAAS,EACT,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,SAAS,EACV,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CA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;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Cursor, Result, TenantId, TriggerId } from '@kindgi/types';
|
|
1
|
+
import type { Cursor, LiveScope, ProjectId, Result, TenantId, TriggerId } from '@kindgi/types';
|
|
2
2
|
import type { CronTriggerConfig, EventTriggerConfig, WebhookTriggerConfig } from './types.js';
|
|
3
3
|
export interface TriggerRegistryBinding {
|
|
4
4
|
register(input: RegisterTriggerInput): Promise<Result<TriggerRecord, RegisterTriggerError>>;
|
|
@@ -22,14 +22,123 @@ export interface TriggerRegistryBinding {
|
|
|
22
22
|
readonly tenantId: TenantId;
|
|
23
23
|
readonly webhookId: string;
|
|
24
24
|
}): Promise<WebhookTriggerRecord | null>;
|
|
25
|
+
/**
|
|
26
|
+
* A trigger's fire history, newest first. Optional: without it, the
|
|
27
|
+
* route answers `501`.
|
|
28
|
+
*/
|
|
29
|
+
listFires?(input: ListTriggerFiresInput): Promise<TriggerFirePage>;
|
|
30
|
+
/**
|
|
31
|
+
* Fire a schedule now, outside its schedule (`run-now`): one fire, recorded
|
|
32
|
+
* in its history with `manual: true`, starting one run as the schedule's
|
|
33
|
+
* owner. Optional: without it, the route answers `501`.
|
|
34
|
+
*/
|
|
35
|
+
fireNow?(input: TriggerLifecycleInput): Promise<Result<TriggerFire, TriggerLifecycleError>>;
|
|
36
|
+
/**
|
|
37
|
+
* Make `owner` the principal a schedule's runs act as (an admin re-owns
|
|
38
|
+
* a schedule whose owner left). Optional: without it, the route answers
|
|
39
|
+
* `501`.
|
|
40
|
+
*/
|
|
41
|
+
setOwner?(input: TriggerLifecycleInput & {
|
|
42
|
+
readonly owner: TriggerOwner;
|
|
43
|
+
}): Promise<Result<TriggerRecord, TriggerLifecycleError>>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What a schedule runs: a flow at an exact version, or an agent. An agent
|
|
47
|
+
* that names no version runs its live version for the schedule's project,
|
|
48
|
+
* as a run that names none does. `improve` starts an improvement pass on
|
|
49
|
+
* an agent for a live scope when enough new trusted "no" judgments have
|
|
50
|
+
* come in (its input says how many, and the pass's options); otherwise
|
|
51
|
+
* its fire is `skipped`.
|
|
52
|
+
*/
|
|
53
|
+
export type TriggerTarget = {
|
|
54
|
+
readonly kind: 'flow';
|
|
55
|
+
readonly flowId: string;
|
|
56
|
+
readonly flowVersion: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: 'agent';
|
|
59
|
+
readonly agentId: string;
|
|
60
|
+
readonly agentVersion?: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: 'improve';
|
|
63
|
+
readonly agentId: string;
|
|
64
|
+
readonly scope: LiveScope;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The principal a trigger's runs act as: whoever registered it, until an
|
|
68
|
+
* admin re-owns it. Checked again at every fire.
|
|
69
|
+
*/
|
|
70
|
+
export interface TriggerOwner {
|
|
71
|
+
readonly kind: 'user' | 'service';
|
|
72
|
+
readonly id: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* What a schedule does after a gap (the runtime was down, or the schedule
|
|
76
|
+
* was overdue past `startingDeadlineSeconds`): `latest` fires once, for
|
|
77
|
+
* the latest missed occurrence, recording how many it missed; `skip` drops
|
|
78
|
+
* the missed occurrences. Never every missed occurrence.
|
|
79
|
+
*/
|
|
80
|
+
export type ScheduleCatchUp = 'latest' | 'skip';
|
|
81
|
+
/** When an occurrence comes while the schedule's previous run is still running. */
|
|
82
|
+
export type ScheduleOverlap = 'skip' | 'allow';
|
|
83
|
+
export declare const SCHEDULE_DEFAULTS: {
|
|
84
|
+
readonly catchUp: "latest";
|
|
85
|
+
readonly overlap: "skip";
|
|
86
|
+
readonly startingDeadlineSeconds: 600;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* One fire of a trigger: an occurrence of a schedule (or a `run-now`), and
|
|
90
|
+
* what came of it. `pending` while its run is being started.
|
|
91
|
+
*/
|
|
92
|
+
export interface TriggerFire {
|
|
93
|
+
readonly fireId: string;
|
|
94
|
+
readonly triggerId: TriggerId;
|
|
95
|
+
readonly kind: 'schedule' | 'event' | 'webhook';
|
|
96
|
+
/** A schedule's fire: the occurrence it is for. */
|
|
97
|
+
readonly scheduledFor?: string;
|
|
98
|
+
readonly firedAt: string;
|
|
99
|
+
/**
|
|
100
|
+
* `skipped-erasure`: the person the fire acts for is being erased (the
|
|
101
|
+
* run start answered `erasure-in-progress`). Skipped fires never count
|
|
102
|
+
* toward the auto-pause; refused and failed ones do.
|
|
103
|
+
* `skipped`: what the target waits for wasn't there (an `improve`
|
|
104
|
+
* schedule's threshold, or its monthly cap), as `detail` says.
|
|
105
|
+
*/
|
|
106
|
+
readonly outcome: 'pending' | 'started' | 'skipped-overlap' | 'skipped-erasure' | 'skipped' | 'refused' | 'failed';
|
|
107
|
+
/** The run it started, when it started one. */
|
|
108
|
+
readonly runId?: string;
|
|
109
|
+
/** The improvement pass it started, for an `improve` schedule. */
|
|
110
|
+
readonly passId?: string;
|
|
111
|
+
/** Why it was refused, skipped or failed. */
|
|
112
|
+
readonly detail?: string;
|
|
113
|
+
/** Occurrences this fire stood in for after a gap (`catchUp: 'latest'`). */
|
|
114
|
+
readonly missedCount?: number;
|
|
115
|
+
/** A `run-now` fire, outside the schedule. */
|
|
116
|
+
readonly manual?: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface ListTriggerFiresInput {
|
|
119
|
+
readonly tenantId: TenantId;
|
|
120
|
+
readonly triggerId: TriggerId;
|
|
121
|
+
readonly limit?: number;
|
|
122
|
+
readonly cursor?: Cursor;
|
|
123
|
+
}
|
|
124
|
+
export interface TriggerFirePage {
|
|
125
|
+
readonly data: readonly TriggerFire[];
|
|
126
|
+
readonly nextCursor?: Cursor;
|
|
25
127
|
}
|
|
26
128
|
export type RegisterTriggerInput = RegisterCronTriggerInput | RegisterEventTriggerInput | RegisterWebhookTriggerInput;
|
|
27
129
|
export interface RegisterCronTriggerInput {
|
|
28
130
|
readonly kind: 'cron';
|
|
29
131
|
readonly tenantId: TenantId;
|
|
30
|
-
readonly
|
|
31
|
-
|
|
132
|
+
readonly target: TriggerTarget;
|
|
133
|
+
/** The schedule's project; absent → the tenant's default project. */
|
|
134
|
+
readonly projectId?: ProjectId;
|
|
135
|
+
/** Who its runs act as: the principal registering it. */
|
|
136
|
+
readonly owner: TriggerOwner;
|
|
32
137
|
readonly config: CronTriggerConfig;
|
|
138
|
+
readonly catchUp?: ScheduleCatchUp;
|
|
139
|
+
readonly overlap?: ScheduleOverlap;
|
|
140
|
+
/** How late a fire may start and still count as on time; past it, `catchUp` applies. */
|
|
141
|
+
readonly startingDeadlineSeconds?: number;
|
|
33
142
|
readonly label?: string;
|
|
34
143
|
}
|
|
35
144
|
export interface RegisterEventTriggerInput {
|
|
@@ -64,9 +173,14 @@ interface UpdateBase {
|
|
|
64
173
|
/** Pin the trigger to a different flow version. */
|
|
65
174
|
readonly flowVersion?: string;
|
|
66
175
|
}
|
|
67
|
-
export interface UpdateCronTriggerInput extends UpdateBase {
|
|
176
|
+
export interface UpdateCronTriggerInput extends Omit<UpdateBase, 'flowVersion'> {
|
|
68
177
|
readonly kind: 'cron';
|
|
69
178
|
readonly config?: Partial<CronTriggerConfig>;
|
|
179
|
+
/** Run something else: another flow version, another agent version. */
|
|
180
|
+
readonly target?: TriggerTarget;
|
|
181
|
+
readonly catchUp?: ScheduleCatchUp;
|
|
182
|
+
readonly overlap?: ScheduleOverlap;
|
|
183
|
+
readonly startingDeadlineSeconds?: number;
|
|
70
184
|
}
|
|
71
185
|
export interface UpdateEventTriggerInput extends UpdateBase {
|
|
72
186
|
readonly kind: 'event';
|
|
@@ -79,24 +193,37 @@ export interface UpdateWebhookTriggerInput extends UpdateBase {
|
|
|
79
193
|
interface TriggerRecordBase {
|
|
80
194
|
readonly triggerId: TriggerId;
|
|
81
195
|
readonly tenantId: TenantId;
|
|
82
|
-
readonly flowId: string;
|
|
83
|
-
readonly flowVersion: string;
|
|
84
196
|
readonly status: 'active' | 'paused';
|
|
85
197
|
readonly label: string | null;
|
|
86
198
|
readonly lastFiredAt: string | null;
|
|
87
199
|
readonly createdAt: string;
|
|
88
200
|
readonly updatedAt: string;
|
|
89
201
|
}
|
|
202
|
+
/** An event trigger or an inbound webhook starts a flow at an exact version. */
|
|
203
|
+
interface FlowTriggerRecordBase extends TriggerRecordBase {
|
|
204
|
+
readonly flowId: string;
|
|
205
|
+
readonly flowVersion: string;
|
|
206
|
+
}
|
|
90
207
|
export interface CronTriggerRecord extends TriggerRecordBase {
|
|
91
208
|
readonly kind: 'cron';
|
|
209
|
+
readonly target: TriggerTarget;
|
|
210
|
+
readonly projectId: ProjectId;
|
|
211
|
+
readonly owner: TriggerOwner;
|
|
92
212
|
readonly config: CronTriggerConfig;
|
|
213
|
+
readonly catchUp: ScheduleCatchUp;
|
|
214
|
+
readonly overlap: ScheduleOverlap;
|
|
215
|
+
readonly startingDeadlineSeconds: number;
|
|
93
216
|
readonly nextFireAt: string | null;
|
|
217
|
+
/** Why the runtime paused it (repeated refused or failed fires; skipped ones never count), when it did. */
|
|
218
|
+
readonly statusReason?: string;
|
|
219
|
+
/** The next occurrences, when the read asked for them (`GetTriggerInput.upcoming`). */
|
|
220
|
+
readonly upcoming?: readonly string[];
|
|
94
221
|
}
|
|
95
|
-
export interface EventTriggerRecord extends
|
|
222
|
+
export interface EventTriggerRecord extends FlowTriggerRecordBase {
|
|
96
223
|
readonly kind: 'event';
|
|
97
224
|
readonly config: EventTriggerConfig;
|
|
98
225
|
}
|
|
99
|
-
export interface WebhookTriggerRecord extends
|
|
226
|
+
export interface WebhookTriggerRecord extends FlowTriggerRecordBase {
|
|
100
227
|
readonly kind: 'webhook';
|
|
101
228
|
readonly config: WebhookTriggerConfig;
|
|
102
229
|
readonly webhookId: string;
|
|
@@ -117,6 +244,8 @@ export interface TriggerListPage {
|
|
|
117
244
|
export interface GetTriggerInput {
|
|
118
245
|
readonly tenantId: TenantId;
|
|
119
246
|
readonly triggerId: TriggerId;
|
|
247
|
+
/** A schedule: include its next N occurrences (`CronTriggerRecord.upcoming`), at most 20. */
|
|
248
|
+
readonly upcoming?: number;
|
|
120
249
|
}
|
|
121
250
|
export interface TriggerLifecycleInput {
|
|
122
251
|
readonly tenantId: TenantId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/schedulers/registry.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/schedulers/registry.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/F,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE9F,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAE5F,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEtF,IAAI,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEzD,GAAG,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;IAE3D,KAAK,CAAC,KAAK,EAAE,qBAAqB,GAAG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CAAC;IAC9B,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAID,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EACT,wBAAwB,GACxB,6BAA6B,GAC7B,yBAAyB,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,wBAAwB,GAAG,uBAAuB,CAAC;IACxF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;IAC7F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED,eAAO,MAAM,aAAa,uCAAwC,CAAC;AACnE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
export const SCHEDULE_DEFAULTS = {
|
|
4
|
+
catchUp: 'latest',
|
|
5
|
+
overlap: 'skip',
|
|
6
|
+
startingDeadlineSeconds: 600,
|
|
7
|
+
};
|
|
3
8
|
export const TRIGGER_KINDS = ['cron', 'event', 'webhook'];
|
|
4
9
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/schedulers/registry.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/schedulers/registry.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAiGjC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,MAAM;IACf,uBAAuB,EAAE,GAAG;CAK7B,CAAC;AA4OF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kindgi/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5-rc.0",
|
|
4
4
|
"description": "Kindgi™ runtime wire-vocabulary + binding interfaces. Public shape covering: RunStatus / RunResult / RunOptions / JournalEntry / JournalKind and all fanout/subgraph/iteration/step payload types; all kernel error shapes (KernelError, RunNotFoundError, HandlerMissingError, WaitpointError, etc.); run inputs and records (RunFlowInput / ResumeRunInput / StartRunParams, FlowResolver, HandlerResolver, ParentRunRef, KernelRunRecord, ListRunsInput); trigger schemas (Cron/Event/Webhook records + inputs + errors, plus TriggerRegistryBinding + RunFlowBinding + TRIGGER_KINDS); versioning envelope + wrap/unwrap; event-bus channel + KernelEventBusBinding; and the binding interfaces (RunBinding, SchedulerBinding, WaitpointBinding, RunRetentionBinding, umbrella KernelBinding) that deployments plug into `createApp`. Types + pure derivation functions — no runtime state, no dependency on a runtime implementation. The Kindgi runtime implements the bindings.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@kindgi/authz": "0.1.
|
|
32
|
-
"@kindgi/flow": "0.1.
|
|
33
|
-
"@kindgi/handler": "0.1.
|
|
34
|
-
"@kindgi/types": "0.1.
|
|
31
|
+
"@kindgi/authz": "0.1.5-rc.0",
|
|
32
|
+
"@kindgi/flow": "0.1.5-rc.0",
|
|
33
|
+
"@kindgi/handler": "0.1.5-rc.0",
|
|
34
|
+
"@kindgi/types": "0.1.5-rc.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=22.12.0"
|
package/src/bindings.ts
CHANGED
|
@@ -106,7 +106,16 @@ export interface RunBinding {
|
|
|
106
106
|
* `wait: false` answering `202`, subgraph child dispatch); the run
|
|
107
107
|
* is then executed with `runGraph({ ..., runId })`.
|
|
108
108
|
*/
|
|
109
|
-
startRun(params: StartRunParams): Promise<
|
|
109
|
+
startRun(params: StartRunParams): Promise<
|
|
110
|
+
Result<
|
|
111
|
+
{
|
|
112
|
+
readonly runId: RunId;
|
|
113
|
+
/** Set when `params.idempotencyKey` named a run that already exists: nothing new started. */
|
|
114
|
+
readonly existing?: true;
|
|
115
|
+
},
|
|
116
|
+
StartRunError
|
|
117
|
+
>
|
|
118
|
+
>;
|
|
110
119
|
|
|
111
120
|
/**
|
|
112
121
|
* Delete a run + its journal + waitpoints. Retention path;
|
package/src/errors.ts
CHANGED
|
@@ -10,7 +10,8 @@ export type KernelError =
|
|
|
10
10
|
| WaitpointError
|
|
11
11
|
| HandlerMissingError
|
|
12
12
|
| StuckRunError
|
|
13
|
-
| RunLeaseLostError
|
|
13
|
+
| RunLeaseLostError
|
|
14
|
+
| RunExecutingError;
|
|
14
15
|
|
|
15
16
|
export interface RunNotFoundError {
|
|
16
17
|
readonly code: 'run-not-found';
|
|
@@ -90,3 +91,14 @@ export interface RunLeaseLostError {
|
|
|
90
91
|
readonly message: string;
|
|
91
92
|
readonly runId: string;
|
|
92
93
|
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The run is executing (an executor holds its lease), and the caller asked
|
|
97
|
+
* to end it only if it isn't: an erasure cancels a person's waiting turn,
|
|
98
|
+
* never one under a live executor, and tries again later.
|
|
99
|
+
*/
|
|
100
|
+
export interface RunExecutingError {
|
|
101
|
+
readonly code: 'run-executing';
|
|
102
|
+
readonly message: string;
|
|
103
|
+
readonly runId: string;
|
|
104
|
+
}
|
package/src/inputs.ts
CHANGED
|
@@ -14,6 +14,8 @@ import type {
|
|
|
14
14
|
RunId,
|
|
15
15
|
ScopeSegment,
|
|
16
16
|
TenantId,
|
|
17
|
+
Timestamp,
|
|
18
|
+
TriggerId,
|
|
17
19
|
} from '@kindgi/types';
|
|
18
20
|
|
|
19
21
|
import type { HandlerMissingError } from './errors.js';
|
|
@@ -76,6 +78,26 @@ export interface RunReplayRef {
|
|
|
76
78
|
readonly evalRunId: string;
|
|
77
79
|
}
|
|
78
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Marks a run a trigger started: the trigger, the fire that started it,
|
|
83
|
+
* and for a schedule the occurrence it ran for.
|
|
84
|
+
*/
|
|
85
|
+
export interface RunTriggerRef {
|
|
86
|
+
readonly triggerId: TriggerId;
|
|
87
|
+
readonly kind: 'schedule' | 'event' | 'webhook';
|
|
88
|
+
readonly fireId: string;
|
|
89
|
+
/** A schedule's fire: the occurrence it ran for. */
|
|
90
|
+
readonly scheduledFor?: Timestamp;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The idempotency key of a run start: a start with a key a run of the
|
|
95
|
+
* tenant already has starts nothing and answers that run (`existing`), so
|
|
96
|
+
* a retried or re-driven start never runs twice. A trigger's fire uses
|
|
97
|
+
* `fire:<fireId>`. Keys are opaque, at most 255 characters.
|
|
98
|
+
*/
|
|
99
|
+
export type RunIdempotencyKey = string;
|
|
100
|
+
|
|
79
101
|
/**
|
|
80
102
|
* Binds the handlers for a flow the runtime is about to run or resume —
|
|
81
103
|
* the root flow and every child flow a subgraph node starts. Lets a
|
|
@@ -123,6 +145,14 @@ export interface RunFlowInput {
|
|
|
123
145
|
readonly agent?: RunAgentRef;
|
|
124
146
|
/** Set when an eval run is replaying a past run; see `RunReplayRef`. */
|
|
125
147
|
readonly replay?: RunReplayRef;
|
|
148
|
+
/**
|
|
149
|
+
* Set when the run doesn't exist yet (no `runId`): start it at most once
|
|
150
|
+
* per key; see `RunIdempotencyKey`. A key a run already has runs nothing
|
|
151
|
+
* and answers that run's current state.
|
|
152
|
+
*/
|
|
153
|
+
readonly idempotencyKey?: RunIdempotencyKey;
|
|
154
|
+
/** Set when a trigger started the run; see `RunTriggerRef`. */
|
|
155
|
+
readonly trigger?: RunTriggerRef;
|
|
126
156
|
/**
|
|
127
157
|
* The W3C trace id of the request that started the run (32 lowercase
|
|
128
158
|
* hex), kept on the run so its later turns and resumes can name the
|
|
@@ -157,9 +187,15 @@ export interface RunFlowInput {
|
|
|
157
187
|
*/
|
|
158
188
|
readonly eventBus?: KernelEventBusBinding;
|
|
159
189
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
190
|
+
* The Principal on whose authority this run executes: who started it
|
|
191
|
+
* (a caller, a schedule's creator, a service identity). Stored with
|
|
192
|
+
* the run, so every resume (an approval, a timeout, a child waking its
|
|
193
|
+
* flow, a run recovered after a crash) acts for the same principal.
|
|
194
|
+
* Only the start stores it: a pending run (`StartRunParams`) keeps the
|
|
195
|
+
* one it was started with, none included, whoever adopts it.
|
|
196
|
+
* When set together with `authz`, every `ctx.authorize` / `can` /
|
|
197
|
+
* `check` inside handlers is decided against it; on its own it only
|
|
198
|
+
* informs (e.g. whose own memory an agent turn may read).
|
|
163
199
|
*/
|
|
164
200
|
readonly principal?: Principal;
|
|
165
201
|
/**
|
|
@@ -189,11 +225,8 @@ export interface ResumeRunInput {
|
|
|
189
225
|
readonly handlerResolver?: HandlerResolver;
|
|
190
226
|
/** Same shape + semantics as `RunFlowInput.eventBus`. */
|
|
191
227
|
readonly eventBus?: KernelEventBusBinding;
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
* keeps enforcing per-tool + per-subgraph checks.
|
|
195
|
-
*/
|
|
196
|
-
readonly principal?: Principal;
|
|
228
|
+
// No principal: a resumed run acts for the one stored when it started
|
|
229
|
+
// (`RunFlowInput.principal`); a resume can't drop or change it.
|
|
197
230
|
readonly authz?: {
|
|
198
231
|
readonly fgaApiUrl: string;
|
|
199
232
|
};
|
|
@@ -212,12 +245,18 @@ export interface StartRunParams {
|
|
|
212
245
|
readonly agent?: RunAgentRef;
|
|
213
246
|
/** Set when an eval run is replaying a past run; see `RunReplayRef`. */
|
|
214
247
|
readonly replay?: RunReplayRef;
|
|
248
|
+
/** Start it at most once per key; see `RunIdempotencyKey`. */
|
|
249
|
+
readonly idempotencyKey?: RunIdempotencyKey;
|
|
250
|
+
/** Set when a trigger started the run; see `RunTriggerRef`. */
|
|
251
|
+
readonly trigger?: RunTriggerRef;
|
|
215
252
|
/** The trace id of the request that started the run; see `RunFlowInput.traceId`. */
|
|
216
253
|
readonly traceId?: string;
|
|
217
254
|
/** The versions the run swaps in over its flow version's pins; see `RunFlowInput.versions`. */
|
|
218
255
|
readonly versions?: FlowVersionOverrides;
|
|
219
256
|
/** The run's segment path; see `RunFlowInput.segments`. */
|
|
220
257
|
readonly segments?: readonly ScopeSegment[];
|
|
258
|
+
/** Who starts the run; stored with it, see `RunFlowInput.principal`. */
|
|
259
|
+
readonly principal?: Principal;
|
|
221
260
|
}
|
|
222
261
|
|
|
223
262
|
export type StartRunError = { readonly code: 'insert-failed'; readonly message: string };
|
package/src/runs.ts
CHANGED
|
@@ -18,9 +18,10 @@ import type {
|
|
|
18
18
|
ScopeSegment,
|
|
19
19
|
TenantId,
|
|
20
20
|
Timestamp,
|
|
21
|
+
TriggerId,
|
|
21
22
|
} from '@kindgi/types';
|
|
22
23
|
|
|
23
|
-
import type { RunAgentRef } from './inputs.js';
|
|
24
|
+
import type { RunAgentRef, RunTriggerRef } from './inputs.js';
|
|
24
25
|
import type { RunStatus } from './types.js';
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -66,6 +67,13 @@ export interface KernelRunRecord {
|
|
|
66
67
|
* when it is a flow run. Absent when it was started without one.
|
|
67
68
|
*/
|
|
68
69
|
readonly segments?: readonly ScopeSegment[];
|
|
70
|
+
/** Set on a run a trigger started (`RunTriggerRef`). */
|
|
71
|
+
readonly trigger?: RunTriggerRef;
|
|
72
|
+
/**
|
|
73
|
+
* When an erasure cleared the run's content (its input, output, failure
|
|
74
|
+
* message and journal payloads). Absent on every other run.
|
|
75
|
+
*/
|
|
76
|
+
readonly contentErasedAt?: Timestamp;
|
|
69
77
|
/**
|
|
70
78
|
* The W3C trace id of the request that started the run
|
|
71
79
|
* (`RunFlowInput.traceId`). Absent for a run no request started, and on
|
|
@@ -92,6 +100,12 @@ export type RunListScope =
|
|
|
92
100
|
* `{ createdAt, id }` internally.
|
|
93
101
|
*/
|
|
94
102
|
export interface RunListCursor {
|
|
103
|
+
/**
|
|
104
|
+
* The last run's `createdAt`, as the binding's `nextCursor` carries it:
|
|
105
|
+
* as stored (Postgres keeps microseconds). A binding compares it as given,
|
|
106
|
+
* never through a JS `Date`, which keeps milliseconds and would skip the
|
|
107
|
+
* runs created earlier in the same millisecond.
|
|
108
|
+
*/
|
|
95
109
|
readonly createdAt: Timestamp;
|
|
96
110
|
readonly id: RunId;
|
|
97
111
|
}
|
|
@@ -118,6 +132,8 @@ export interface ListRunsInput {
|
|
|
118
132
|
readonly replays?: 'exclude' | 'include' | 'only';
|
|
119
133
|
/** Only the replays of this eval run. */
|
|
120
134
|
readonly evalRunId?: string;
|
|
135
|
+
/** Only the runs this trigger started (`RunTriggerRef.triggerId`). */
|
|
136
|
+
readonly triggerId?: TriggerId;
|
|
121
137
|
}
|
|
122
138
|
|
|
123
139
|
export interface ListRunsPage {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// input variants, record shapes, error shapes, TRIGGER_KINDS constant.
|
|
6
6
|
// The implementation is supplied by the Kindgi runtime.
|
|
7
7
|
|
|
8
|
-
import type { Cursor, Result, TenantId, TriggerId } from '@kindgi/types';
|
|
8
|
+
import type { Cursor, LiveScope, ProjectId, Result, TenantId, TriggerId } from '@kindgi/types';
|
|
9
9
|
|
|
10
10
|
import type { CronTriggerConfig, EventTriggerConfig, WebhookTriggerConfig } from './types.js';
|
|
11
11
|
|
|
@@ -37,6 +37,125 @@ export interface TriggerRegistryBinding {
|
|
|
37
37
|
readonly tenantId: TenantId;
|
|
38
38
|
readonly webhookId: string;
|
|
39
39
|
}): Promise<WebhookTriggerRecord | null>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A trigger's fire history, newest first. Optional: without it, the
|
|
43
|
+
* route answers `501`.
|
|
44
|
+
*/
|
|
45
|
+
listFires?(input: ListTriggerFiresInput): Promise<TriggerFirePage>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Fire a schedule now, outside its schedule (`run-now`): one fire, recorded
|
|
49
|
+
* in its history with `manual: true`, starting one run as the schedule's
|
|
50
|
+
* owner. Optional: without it, the route answers `501`.
|
|
51
|
+
*/
|
|
52
|
+
fireNow?(input: TriggerLifecycleInput): Promise<Result<TriggerFire, TriggerLifecycleError>>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Make `owner` the principal a schedule's runs act as (an admin re-owns
|
|
56
|
+
* a schedule whose owner left). Optional: without it, the route answers
|
|
57
|
+
* `501`.
|
|
58
|
+
*/
|
|
59
|
+
setOwner?(
|
|
60
|
+
input: TriggerLifecycleInput & { readonly owner: TriggerOwner },
|
|
61
|
+
): Promise<Result<TriggerRecord, TriggerLifecycleError>>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// ---------- schedules: what they run, who as, and when ----------
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* What a schedule runs: a flow at an exact version, or an agent. An agent
|
|
68
|
+
* that names no version runs its live version for the schedule's project,
|
|
69
|
+
* as a run that names none does. `improve` starts an improvement pass on
|
|
70
|
+
* an agent for a live scope when enough new trusted "no" judgments have
|
|
71
|
+
* come in (its input says how many, and the pass's options); otherwise
|
|
72
|
+
* its fire is `skipped`.
|
|
73
|
+
*/
|
|
74
|
+
export type TriggerTarget =
|
|
75
|
+
| { readonly kind: 'flow'; readonly flowId: string; readonly flowVersion: string }
|
|
76
|
+
| { readonly kind: 'agent'; readonly agentId: string; readonly agentVersion?: string }
|
|
77
|
+
| { readonly kind: 'improve'; readonly agentId: string; readonly scope: LiveScope };
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The principal a trigger's runs act as: whoever registered it, until an
|
|
81
|
+
* admin re-owns it. Checked again at every fire.
|
|
82
|
+
*/
|
|
83
|
+
export interface TriggerOwner {
|
|
84
|
+
readonly kind: 'user' | 'service';
|
|
85
|
+
readonly id: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* What a schedule does after a gap (the runtime was down, or the schedule
|
|
90
|
+
* was overdue past `startingDeadlineSeconds`): `latest` fires once, for
|
|
91
|
+
* the latest missed occurrence, recording how many it missed; `skip` drops
|
|
92
|
+
* the missed occurrences. Never every missed occurrence.
|
|
93
|
+
*/
|
|
94
|
+
export type ScheduleCatchUp = 'latest' | 'skip';
|
|
95
|
+
|
|
96
|
+
/** When an occurrence comes while the schedule's previous run is still running. */
|
|
97
|
+
export type ScheduleOverlap = 'skip' | 'allow';
|
|
98
|
+
|
|
99
|
+
export const SCHEDULE_DEFAULTS = {
|
|
100
|
+
catchUp: 'latest',
|
|
101
|
+
overlap: 'skip',
|
|
102
|
+
startingDeadlineSeconds: 600,
|
|
103
|
+
} as const satisfies {
|
|
104
|
+
readonly catchUp: ScheduleCatchUp;
|
|
105
|
+
readonly overlap: ScheduleOverlap;
|
|
106
|
+
readonly startingDeadlineSeconds: number;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// ---------- fires ----------
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* One fire of a trigger: an occurrence of a schedule (or a `run-now`), and
|
|
113
|
+
* what came of it. `pending` while its run is being started.
|
|
114
|
+
*/
|
|
115
|
+
export interface TriggerFire {
|
|
116
|
+
readonly fireId: string;
|
|
117
|
+
readonly triggerId: TriggerId;
|
|
118
|
+
readonly kind: 'schedule' | 'event' | 'webhook';
|
|
119
|
+
/** A schedule's fire: the occurrence it is for. */
|
|
120
|
+
readonly scheduledFor?: string;
|
|
121
|
+
readonly firedAt: string;
|
|
122
|
+
/**
|
|
123
|
+
* `skipped-erasure`: the person the fire acts for is being erased (the
|
|
124
|
+
* run start answered `erasure-in-progress`). Skipped fires never count
|
|
125
|
+
* toward the auto-pause; refused and failed ones do.
|
|
126
|
+
* `skipped`: what the target waits for wasn't there (an `improve`
|
|
127
|
+
* schedule's threshold, or its monthly cap), as `detail` says.
|
|
128
|
+
*/
|
|
129
|
+
readonly outcome:
|
|
130
|
+
| 'pending'
|
|
131
|
+
| 'started'
|
|
132
|
+
| 'skipped-overlap'
|
|
133
|
+
| 'skipped-erasure'
|
|
134
|
+
| 'skipped'
|
|
135
|
+
| 'refused'
|
|
136
|
+
| 'failed';
|
|
137
|
+
/** The run it started, when it started one. */
|
|
138
|
+
readonly runId?: string;
|
|
139
|
+
/** The improvement pass it started, for an `improve` schedule. */
|
|
140
|
+
readonly passId?: string;
|
|
141
|
+
/** Why it was refused, skipped or failed. */
|
|
142
|
+
readonly detail?: string;
|
|
143
|
+
/** Occurrences this fire stood in for after a gap (`catchUp: 'latest'`). */
|
|
144
|
+
readonly missedCount?: number;
|
|
145
|
+
/** A `run-now` fire, outside the schedule. */
|
|
146
|
+
readonly manual?: boolean;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface ListTriggerFiresInput {
|
|
150
|
+
readonly tenantId: TenantId;
|
|
151
|
+
readonly triggerId: TriggerId;
|
|
152
|
+
readonly limit?: number;
|
|
153
|
+
readonly cursor?: Cursor;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface TriggerFirePage {
|
|
157
|
+
readonly data: readonly TriggerFire[];
|
|
158
|
+
readonly nextCursor?: Cursor;
|
|
40
159
|
}
|
|
41
160
|
|
|
42
161
|
// ---------- register (discriminated on kind) ----------
|
|
@@ -49,9 +168,16 @@ export type RegisterTriggerInput =
|
|
|
49
168
|
export interface RegisterCronTriggerInput {
|
|
50
169
|
readonly kind: 'cron';
|
|
51
170
|
readonly tenantId: TenantId;
|
|
52
|
-
readonly
|
|
53
|
-
|
|
171
|
+
readonly target: TriggerTarget;
|
|
172
|
+
/** The schedule's project; absent → the tenant's default project. */
|
|
173
|
+
readonly projectId?: ProjectId;
|
|
174
|
+
/** Who its runs act as: the principal registering it. */
|
|
175
|
+
readonly owner: TriggerOwner;
|
|
54
176
|
readonly config: CronTriggerConfig;
|
|
177
|
+
readonly catchUp?: ScheduleCatchUp;
|
|
178
|
+
readonly overlap?: ScheduleOverlap;
|
|
179
|
+
/** How late a fire may start and still count as on time; past it, `catchUp` applies. */
|
|
180
|
+
readonly startingDeadlineSeconds?: number;
|
|
55
181
|
readonly label?: string;
|
|
56
182
|
}
|
|
57
183
|
|
|
@@ -96,9 +222,14 @@ interface UpdateBase {
|
|
|
96
222
|
readonly flowVersion?: string;
|
|
97
223
|
}
|
|
98
224
|
|
|
99
|
-
export interface UpdateCronTriggerInput extends UpdateBase {
|
|
225
|
+
export interface UpdateCronTriggerInput extends Omit<UpdateBase, 'flowVersion'> {
|
|
100
226
|
readonly kind: 'cron';
|
|
101
227
|
readonly config?: Partial<CronTriggerConfig>;
|
|
228
|
+
/** Run something else: another flow version, another agent version. */
|
|
229
|
+
readonly target?: TriggerTarget;
|
|
230
|
+
readonly catchUp?: ScheduleCatchUp;
|
|
231
|
+
readonly overlap?: ScheduleOverlap;
|
|
232
|
+
readonly startingDeadlineSeconds?: number;
|
|
102
233
|
}
|
|
103
234
|
|
|
104
235
|
export interface UpdateEventTriggerInput extends UpdateBase {
|
|
@@ -117,8 +248,6 @@ export interface UpdateWebhookTriggerInput extends UpdateBase {
|
|
|
117
248
|
interface TriggerRecordBase {
|
|
118
249
|
readonly triggerId: TriggerId;
|
|
119
250
|
readonly tenantId: TenantId;
|
|
120
|
-
readonly flowId: string;
|
|
121
|
-
readonly flowVersion: string;
|
|
122
251
|
readonly status: 'active' | 'paused';
|
|
123
252
|
readonly label: string | null;
|
|
124
253
|
readonly lastFiredAt: string | null;
|
|
@@ -126,18 +255,34 @@ interface TriggerRecordBase {
|
|
|
126
255
|
readonly updatedAt: string;
|
|
127
256
|
}
|
|
128
257
|
|
|
258
|
+
/** An event trigger or an inbound webhook starts a flow at an exact version. */
|
|
259
|
+
interface FlowTriggerRecordBase extends TriggerRecordBase {
|
|
260
|
+
readonly flowId: string;
|
|
261
|
+
readonly flowVersion: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
129
264
|
export interface CronTriggerRecord extends TriggerRecordBase {
|
|
130
265
|
readonly kind: 'cron';
|
|
266
|
+
readonly target: TriggerTarget;
|
|
267
|
+
readonly projectId: ProjectId;
|
|
268
|
+
readonly owner: TriggerOwner;
|
|
131
269
|
readonly config: CronTriggerConfig;
|
|
270
|
+
readonly catchUp: ScheduleCatchUp;
|
|
271
|
+
readonly overlap: ScheduleOverlap;
|
|
272
|
+
readonly startingDeadlineSeconds: number;
|
|
132
273
|
readonly nextFireAt: string | null;
|
|
274
|
+
/** Why the runtime paused it (repeated refused or failed fires; skipped ones never count), when it did. */
|
|
275
|
+
readonly statusReason?: string;
|
|
276
|
+
/** The next occurrences, when the read asked for them (`GetTriggerInput.upcoming`). */
|
|
277
|
+
readonly upcoming?: readonly string[];
|
|
133
278
|
}
|
|
134
279
|
|
|
135
|
-
export interface EventTriggerRecord extends
|
|
280
|
+
export interface EventTriggerRecord extends FlowTriggerRecordBase {
|
|
136
281
|
readonly kind: 'event';
|
|
137
282
|
readonly config: EventTriggerConfig;
|
|
138
283
|
}
|
|
139
284
|
|
|
140
|
-
export interface WebhookTriggerRecord extends
|
|
285
|
+
export interface WebhookTriggerRecord extends FlowTriggerRecordBase {
|
|
141
286
|
readonly kind: 'webhook';
|
|
142
287
|
readonly config: WebhookTriggerConfig;
|
|
143
288
|
readonly webhookId: string;
|
|
@@ -164,6 +309,8 @@ export interface TriggerListPage {
|
|
|
164
309
|
export interface GetTriggerInput {
|
|
165
310
|
readonly tenantId: TenantId;
|
|
166
311
|
readonly triggerId: TriggerId;
|
|
312
|
+
/** A schedule: include its next N occurrences (`CronTriggerRecord.upcoming`), at most 20. */
|
|
313
|
+
readonly upcoming?: number;
|
|
167
314
|
}
|
|
168
315
|
|
|
169
316
|
export interface TriggerLifecycleInput {
|