@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.
Files changed (58) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +65 -1
  3. package/dist/bindings.d.ts +186 -0
  4. package/dist/bindings.d.ts.map +1 -0
  5. package/dist/bindings.js +4 -0
  6. package/dist/bindings.js.map +1 -0
  7. package/dist/derivation.d.ts +123 -0
  8. package/dist/derivation.d.ts.map +1 -0
  9. package/dist/derivation.js +249 -0
  10. package/dist/derivation.js.map +1 -0
  11. package/dist/errors.d.ts +78 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +4 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/event-bus.d.ts +41 -0
  16. package/dist/event-bus.d.ts.map +1 -0
  17. package/dist/event-bus.js +13 -0
  18. package/dist/event-bus.js.map +1 -0
  19. package/dist/index.d.ts +11 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +13 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/inputs.d.ts +160 -0
  24. package/dist/inputs.d.ts.map +1 -0
  25. package/dist/inputs.js +4 -0
  26. package/dist/inputs.js.map +1 -0
  27. package/dist/runs.d.ts +73 -0
  28. package/dist/runs.d.ts.map +1 -0
  29. package/dist/runs.js +4 -0
  30. package/dist/runs.js.map +1 -0
  31. package/dist/schedulers/registry.d.ts +142 -0
  32. package/dist/schedulers/registry.d.ts.map +1 -0
  33. package/dist/schedulers/registry.js +4 -0
  34. package/dist/schedulers/registry.js.map +1 -0
  35. package/dist/schedulers/types.d.ts +99 -0
  36. package/dist/schedulers/types.d.ts.map +1 -0
  37. package/dist/schedulers/types.js +4 -0
  38. package/dist/schedulers/types.js.map +1 -0
  39. package/dist/types.d.ts +317 -0
  40. package/dist/types.d.ts.map +1 -0
  41. package/dist/types.js +6 -0
  42. package/dist/types.js.map +1 -0
  43. package/dist/versioning.d.ts +59 -0
  44. package/dist/versioning.d.ts.map +1 -0
  45. package/dist/versioning.js +89 -0
  46. package/dist/versioning.js.map +1 -0
  47. package/package.json +50 -4
  48. package/src/bindings.ts +244 -0
  49. package/src/derivation.ts +354 -0
  50. package/src/errors.ts +92 -0
  51. package/src/event-bus.ts +51 -0
  52. package/src/index.ts +13 -0
  53. package/src/inputs.ts +169 -0
  54. package/src/runs.ts +84 -0
  55. package/src/schedulers/registry.ts +197 -0
  56. package/src/schedulers/types.ts +112 -0
  57. package/src/types.ts +378 -0
  58. package/src/versioning.ts +110 -0
package/dist/runs.d.ts ADDED
@@ -0,0 +1,73 @@
1
+ import type { Cursor, NodeId, OrgId, ProjectId, RunId, TenantId, Timestamp } from '@kindgi/types';
2
+ import type { RunStatus } from './types.js';
3
+ /**
4
+ * Public run shape exposed by `RunBinding.getRun` / `.listRuns`.
5
+ * Matches the fields @kindgi/api's `/v1/runs` routes serialize to
6
+ * the wire.
7
+ */
8
+ export interface KernelRunRecord {
9
+ readonly runId: RunId;
10
+ readonly tenantId: TenantId;
11
+ readonly projectId: ProjectId;
12
+ readonly flowId: string;
13
+ readonly flowVersion: string;
14
+ readonly status: RunStatus;
15
+ readonly input: unknown;
16
+ /** The run's output once it completed — the value itself, not a storage envelope. */
17
+ readonly output?: unknown;
18
+ readonly failureMessage?: string | null;
19
+ readonly dryRun: boolean;
20
+ readonly createdAt: Timestamp;
21
+ readonly updatedAt: Timestamp;
22
+ readonly completedAt?: Timestamp | null;
23
+ /** Set on a child run: the parent run and the node that started it (`ParentRunRef`). */
24
+ readonly parentRunId?: RunId | null;
25
+ readonly parentNodeId?: NodeId | null;
26
+ readonly parentScope?: string | null;
27
+ }
28
+ /**
29
+ * Content-scope filter for `RunBinding.listRuns`. Present-with-value
30
+ * narrows to a specific project or org; absent = tenant-wide (admin
31
+ * default). An org scope includes the runs of every project in that
32
+ * org.
33
+ */
34
+ export type RunListScope = {
35
+ readonly kind: 'project';
36
+ readonly projectId: ProjectId;
37
+ } | {
38
+ readonly kind: 'org';
39
+ readonly orgId: OrgId;
40
+ };
41
+ /**
42
+ * Cursor position for `RunBinding.listRuns`. Sort key is
43
+ * `(createdAt desc, id desc)` — same discipline as every other
44
+ * kernel-facing list. Callers pass the opaque `Cursor` string
45
+ * decoded from the wire; the impl decodes it back to
46
+ * `{ createdAt, id }` internally.
47
+ */
48
+ export interface RunListCursor {
49
+ readonly createdAt: Timestamp;
50
+ readonly id: RunId;
51
+ }
52
+ export interface ListRunsInput {
53
+ readonly tenantId: TenantId;
54
+ readonly scope?: RunListScope;
55
+ readonly limit?: number;
56
+ readonly cursor?: RunListCursor;
57
+ /**
58
+ * Only the children of this run — optionally only those a given node
59
+ * (and loop scope) started.
60
+ */
61
+ readonly parent?: {
62
+ readonly runId: RunId;
63
+ readonly nodeId?: NodeId;
64
+ readonly scope?: string;
65
+ };
66
+ /** Only runs that are not a child of another run. */
67
+ readonly topLevelOnly?: boolean;
68
+ }
69
+ export interface ListRunsPage {
70
+ readonly data: readonly KernelRunRecord[];
71
+ readonly nextCursor?: Cursor;
72
+ }
73
+ //# sourceMappingURL=runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAElG,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,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IA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AAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;QACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,qDAAqD;IACrD,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B"}
package/dist/runs.js ADDED
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ export {};
4
+ //# sourceMappingURL=runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.js","sourceRoot":"","sources":["../src/runs.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC"}
@@ -0,0 +1,142 @@
1
+ import type { Cursor, Result, TenantId, TriggerId } from '@kindgi/types';
2
+ import type { CronTriggerConfig, EventTriggerConfig, WebhookTriggerConfig } from './types.js';
3
+ export interface TriggerRegistryBinding {
4
+ register(input: RegisterTriggerInput): Promise<Result<TriggerRecord, RegisterTriggerError>>;
5
+ update(input: UpdateTriggerInput): Promise<Result<TriggerRecord, UpdateTriggerError>>;
6
+ list(input: ListTriggersInput): Promise<TriggerListPage>;
7
+ get(input: GetTriggerInput): Promise<TriggerRecord | null>;
8
+ pause(input: TriggerLifecycleInput): Promise<Result<TriggerRecord, TriggerLifecycleError>>;
9
+ resume(input: TriggerLifecycleInput): Promise<Result<TriggerRecord, TriggerLifecycleError>>;
10
+ unregister(input: TriggerLifecycleInput): Promise<{
11
+ readonly triggerId: TriggerId;
12
+ readonly unregistered: boolean;
13
+ }>;
14
+ /**
15
+ * Webhook-receiver hot path. The receiver resolves the HMAC secret
16
+ * named by `hmacSecretName` from the tenant's secrets (`SecretBinding`
17
+ * in `@kindgi/api`) and verifies the request before spawning. Returns
18
+ * null when webhookId is unknown, the trigger is tombstoned, or
19
+ * `status !== 'active'`.
20
+ */
21
+ fetchActiveByWebhookId(input: {
22
+ readonly tenantId: TenantId;
23
+ readonly webhookId: string;
24
+ }): Promise<WebhookTriggerRecord | null>;
25
+ }
26
+ export type RegisterTriggerInput = RegisterCronTriggerInput | RegisterEventTriggerInput | RegisterWebhookTriggerInput;
27
+ export interface RegisterCronTriggerInput {
28
+ readonly kind: 'cron';
29
+ readonly tenantId: TenantId;
30
+ readonly flowId: string;
31
+ readonly flowVersion: string;
32
+ readonly config: CronTriggerConfig;
33
+ readonly label?: string;
34
+ }
35
+ export interface RegisterEventTriggerInput {
36
+ readonly kind: 'event';
37
+ readonly tenantId: TenantId;
38
+ readonly flowId: string;
39
+ readonly flowVersion: string;
40
+ readonly config: EventTriggerConfig;
41
+ readonly label?: string;
42
+ }
43
+ export interface RegisterWebhookTriggerInput {
44
+ readonly kind: 'webhook';
45
+ readonly tenantId: TenantId;
46
+ readonly flowId: string;
47
+ readonly flowVersion: string;
48
+ readonly config: WebhookTriggerConfig;
49
+ /** Caller-supplied (uuid). The routable id a webhook receiver looks the trigger up by. */
50
+ readonly webhookId: string;
51
+ /**
52
+ * Name of the HMAC secret in the tenant's secrets store. The caller
53
+ * writes the secret first (`POST /v1/secrets`); this row never holds it.
54
+ */
55
+ readonly hmacSecretName: string;
56
+ readonly label?: string;
57
+ }
58
+ export type UpdateTriggerInput = UpdateCronTriggerInput | UpdateEventTriggerInput | UpdateWebhookTriggerInput;
59
+ interface UpdateBase {
60
+ readonly tenantId: TenantId;
61
+ readonly triggerId: TriggerId;
62
+ /** `null` clears the label; omitted leaves it unchanged. */
63
+ readonly label?: string | null;
64
+ /** Pin the trigger to a different flow version. */
65
+ readonly flowVersion?: string;
66
+ }
67
+ export interface UpdateCronTriggerInput extends UpdateBase {
68
+ readonly kind: 'cron';
69
+ readonly config?: Partial<CronTriggerConfig>;
70
+ }
71
+ export interface UpdateEventTriggerInput extends UpdateBase {
72
+ readonly kind: 'event';
73
+ readonly config?: Partial<EventTriggerConfig>;
74
+ }
75
+ export interface UpdateWebhookTriggerInput extends UpdateBase {
76
+ readonly kind: 'webhook';
77
+ readonly config?: Partial<WebhookTriggerConfig>;
78
+ }
79
+ interface TriggerRecordBase {
80
+ readonly triggerId: TriggerId;
81
+ readonly tenantId: TenantId;
82
+ readonly flowId: string;
83
+ readonly flowVersion: string;
84
+ readonly status: 'active' | 'paused';
85
+ readonly label: string | null;
86
+ readonly lastFiredAt: string | null;
87
+ readonly createdAt: string;
88
+ readonly updatedAt: string;
89
+ }
90
+ export interface CronTriggerRecord extends TriggerRecordBase {
91
+ readonly kind: 'cron';
92
+ readonly config: CronTriggerConfig;
93
+ readonly nextFireAt: string | null;
94
+ }
95
+ export interface EventTriggerRecord extends TriggerRecordBase {
96
+ readonly kind: 'event';
97
+ readonly config: EventTriggerConfig;
98
+ }
99
+ export interface WebhookTriggerRecord extends TriggerRecordBase {
100
+ readonly kind: 'webhook';
101
+ readonly config: WebhookTriggerConfig;
102
+ readonly webhookId: string;
103
+ readonly hmacSecretName: string;
104
+ }
105
+ export type TriggerRecord = CronTriggerRecord | EventTriggerRecord | WebhookTriggerRecord;
106
+ export interface ListTriggersInput {
107
+ readonly tenantId: TenantId;
108
+ readonly kind?: TriggerKind;
109
+ readonly status?: 'active' | 'paused';
110
+ readonly limit?: number;
111
+ readonly cursor?: Cursor;
112
+ }
113
+ export interface TriggerListPage {
114
+ readonly data: readonly TriggerRecord[];
115
+ readonly nextCursor?: Cursor;
116
+ }
117
+ export interface GetTriggerInput {
118
+ readonly tenantId: TenantId;
119
+ readonly triggerId: TriggerId;
120
+ }
121
+ export interface TriggerLifecycleInput {
122
+ readonly tenantId: TenantId;
123
+ readonly triggerId: TriggerId;
124
+ }
125
+ export interface RegisterTriggerError {
126
+ readonly code: 'trigger-invalid-config' | 'trigger-webhook-id-conflict' | 'trigger-register-failed';
127
+ readonly message: string;
128
+ }
129
+ export interface UpdateTriggerError {
130
+ readonly code: 'trigger-not-found' | 'trigger-invalid-config' | 'trigger-update-failed';
131
+ readonly message: string;
132
+ readonly triggerId: TriggerId;
133
+ }
134
+ export interface TriggerLifecycleError {
135
+ readonly code: 'trigger-not-found' | 'trigger-already-in-state' | 'trigger-lifecycle-failed';
136
+ readonly message: string;
137
+ readonly triggerId: TriggerId;
138
+ }
139
+ export declare const TRIGGER_KINDS: readonly ["cron", "event", "webhook"];
140
+ export type TriggerKind = (typeof TRIGGER_KINDS)[number];
141
+ export {};
142
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +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;AAEzE,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,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAE3F,MAAM,CAAC,KAAK,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sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/schedulers/registry.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC;AAkMjC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,CAAU,CAAC"}
@@ -0,0 +1,99 @@
1
+ import type { EventId, Result, RunId, TenantId, TriggerId } from '@kindgi/types';
2
+ /**
3
+ * What the trigger runtime hands to a caller-supplied `RunFlowBinding`.
4
+ *
5
+ * The kernel doesn't own a flow registry — resolving `flowId + flowVersion`
6
+ * to a concrete `Flow + HandlerRegistry` is deployment-specific (packs
7
+ * register at boot, dev consumers pass in inline maps, etc.). The binding
8
+ * shape lets any of those wire in without the kernel choosing for them.
9
+ */
10
+ export interface TriggerFireContext {
11
+ readonly tenantId: TenantId;
12
+ readonly flowId: string;
13
+ readonly flowVersion: string;
14
+ /**
15
+ * Input to hand to `runGraph`. Shape is trigger-kind-specific:
16
+ * - cron: `config.input ?? {}` (the caller pre-shapes at register time).
17
+ * - event: the entire `Event` object — handler decides which fields
18
+ * it cares about.
19
+ * - webhook: parsed request body — the receiver route decides whether
20
+ * to JSON.parse or hand raw bytes to the binding.
21
+ */
22
+ readonly input: unknown;
23
+ readonly source: TriggerSource;
24
+ }
25
+ /** Discriminated origin of the run spawn, useful for provenance / audit. */
26
+ export type TriggerSource = {
27
+ readonly kind: 'cron';
28
+ readonly triggerId: TriggerId;
29
+ } | {
30
+ readonly kind: 'event';
31
+ readonly triggerId: TriggerId;
32
+ readonly eventId: EventId;
33
+ readonly eventKind: string;
34
+ } | {
35
+ readonly kind: 'webhook';
36
+ readonly triggerId: TriggerId;
37
+ readonly webhookId: string;
38
+ };
39
+ /**
40
+ * The caller-supplied hook that turns a trigger fire into a real run. The
41
+ * kernel calls this for every due tick, every matching event, every valid
42
+ * webhook receive. Deployments wire it to their own flow+handler lookup
43
+ * (packs manifest, in-process registry, etc.) and then call `runGraph`.
44
+ */
45
+ export type RunFlowBinding = (ctx: TriggerFireContext) => Promise<Result<{
46
+ readonly runId: RunId;
47
+ }, TriggerBindingError>>;
48
+ /** Errors the caller-supplied binding is allowed to surface. */
49
+ export interface TriggerBindingError {
50
+ readonly code: 'flow-not-found' | 'handler-missing' | 'run-spawn-failed';
51
+ readonly message: string;
52
+ readonly cause?: unknown;
53
+ }
54
+ /**
55
+ * Union of every error the trigger runtime primitives can return. The
56
+ * kind-specific shapes are declared below.
57
+ */
58
+ export type TriggerError = WebhookTriggerError | CronTriggerError | EventTriggerError;
59
+ export interface WebhookTriggerError {
60
+ readonly code: 'webhook-not-found' | 'webhook-signature-invalid' | 'webhook-inactive' | 'webhook-flow-not-found';
61
+ readonly message: string;
62
+ readonly webhookId: string;
63
+ }
64
+ export interface CronTriggerError {
65
+ readonly code: 'cron-config-invalid' | 'cron-flow-not-found';
66
+ readonly message: string;
67
+ readonly triggerId: TriggerId;
68
+ }
69
+ export interface EventTriggerError {
70
+ readonly code: 'event-config-invalid' | 'event-flow-not-found';
71
+ readonly message: string;
72
+ readonly triggerId: TriggerId;
73
+ }
74
+ /** Trigger-kind-specific config shapes, stored as each trigger's `config`. */
75
+ export interface CronTriggerConfig {
76
+ /** 5- or 6-field cron expression (croner-compatible). 6-field enables second precision. */
77
+ readonly cronExpression: string;
78
+ /** IANA timezone (e.g. 'UTC', 'America/New_York'). Defaults to 'UTC'. */
79
+ readonly timezone?: string;
80
+ /** Static input handed to the flow on every fire. Absent → `{}`. */
81
+ readonly input?: unknown;
82
+ }
83
+ export interface EventTriggerConfig {
84
+ /** Event type filter (matched against `event.type`). */
85
+ readonly eventKind: string;
86
+ /**
87
+ * Optional input override. When absent, the entire `Event` object is
88
+ * passed as the flow input.
89
+ */
90
+ readonly input?: unknown;
91
+ }
92
+ export interface WebhookTriggerConfig {
93
+ /**
94
+ * Optional input override. When absent, the parsed request body (as
95
+ * passed to `fireByWebhookId`) is used as the flow input.
96
+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AAED,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B"}
@@ -0,0 +1,4 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/schedulers/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,iCAAiC"}