@kici-dev/engine 0.1.26 → 0.2.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 (157) hide show
  1. package/dist/approval/types.d.ts +11 -4
  2. package/dist/approval/types.js +11 -4
  3. package/dist/artifacts/name.d.ts +60 -0
  4. package/dist/artifacts/name.js +71 -0
  5. package/dist/audit/access-log-policy.d.ts +1 -1
  6. package/dist/audit/access-log-policy.js +20 -11
  7. package/dist/audit/activity.d.ts +12 -12
  8. package/dist/audit/retention-policy.js +40 -22
  9. package/dist/billing/plan-type.d.ts +53 -0
  10. package/dist/billing/plan-type.js +70 -0
  11. package/dist/bundler/rolldown-config.d.ts +3 -3
  12. package/dist/check-mode.d.ts +1 -1
  13. package/dist/context/concurrency-strategy.d.ts +34 -0
  14. package/dist/context/concurrency-strategy.js +35 -0
  15. package/dist/context/held-run-job-id.d.ts +45 -0
  16. package/dist/context/held-run-job-id.js +56 -0
  17. package/dist/context/held-run-status.d.ts +33 -0
  18. package/dist/context/held-run-status.js +37 -0
  19. package/dist/context/hold-expiry.d.ts +20 -0
  20. package/dist/context/hold-expiry.js +25 -0
  21. package/dist/context/hold-reason.d.ts +33 -0
  22. package/dist/context/hold-reason.js +23 -0
  23. package/dist/context/hold-type.d.ts +40 -0
  24. package/dist/context/hold-type.js +61 -0
  25. package/dist/{environment → context}/host-match.js +1 -1
  26. package/dist/context/index.d.ts +14 -0
  27. package/dist/context/index.js +12 -0
  28. package/dist/context/multi-context.d.ts +30 -0
  29. package/dist/context/multi-context.js +38 -0
  30. package/dist/context/scope-name.d.ts +29 -0
  31. package/dist/context/scope-name.js +49 -0
  32. package/dist/context/scope-resolver.d.ts +79 -0
  33. package/dist/{environment → context}/scope-resolver.js +47 -17
  34. package/dist/{environment → context}/scope-template.js +1 -1
  35. package/dist/{environment → context}/types.d.ts +25 -22
  36. package/dist/{environment → context}/types.js +3 -3
  37. package/dist/dev-ops/operations.d.ts +9 -1
  38. package/dist/dev-ops/operations.js +37 -20
  39. package/dist/diagnostics/infra-alert.d.ts +71 -0
  40. package/dist/diagnostics/infra-alert.js +60 -0
  41. package/dist/env/environment-allowlist.d.ts +26 -3
  42. package/dist/env/environment-allowlist.js +35 -1
  43. package/dist/fanout/materialize.d.ts +16 -0
  44. package/dist/fanout/materialize.js +34 -5
  45. package/dist/index.d.ts +16 -7
  46. package/dist/index.js +38 -23
  47. package/dist/inputs/descriptor.d.ts +9 -9
  48. package/dist/inventory.d.ts +4 -4
  49. package/dist/labels.d.ts +82 -2
  50. package/dist/labels.js +119 -1
  51. package/dist/matrix/expand.d.ts +49 -2
  52. package/dist/matrix/expand.js +102 -13
  53. package/dist/matrix/format.d.ts +6 -1
  54. package/dist/matrix/format.js +6 -1
  55. package/dist/mcp/held-run-resolve.d.ts +7 -10
  56. package/dist/mcp/held-run-resolve.js +33 -7
  57. package/dist/metrics/catalog-policy.js +4 -4
  58. package/dist/metrics/metric-catalog.generated.d.ts +954 -734
  59. package/dist/metrics/metric-catalog.generated.js +296 -32
  60. package/dist/metrics/metric-kind-compat.d.ts +26 -0
  61. package/dist/metrics/metric-kind-compat.js +33 -0
  62. package/dist/protocol/analytics-events.d.ts +6 -6
  63. package/dist/protocol/dashboard-api-errors.d.ts +13 -0
  64. package/dist/protocol/dashboard-api-errors.js +17 -0
  65. package/dist/protocol/dashboard-write-operations.d.ts +143 -86
  66. package/dist/protocol/dashboard-write-operations.js +143 -69
  67. package/dist/protocol/messages/access-log.d.ts +438 -388
  68. package/dist/protocol/messages/access-log.js +24 -14
  69. package/dist/protocol/messages/actor.d.ts +2 -2
  70. package/dist/protocol/messages/agent-dev-ops.d.ts +4 -2
  71. package/dist/protocol/messages/agent-dev-ops.js +2 -5
  72. package/dist/protocol/messages/agent-run-result.d.ts +74 -64
  73. package/dist/protocol/messages/agent-run-result.js +1 -1
  74. package/dist/protocol/messages/auth.d.ts +35 -23
  75. package/dist/protocol/messages/browser.d.ts +81 -5
  76. package/dist/protocol/messages/browser.js +53 -2
  77. package/dist/protocol/messages/capabilities.d.ts +106 -31
  78. package/dist/protocol/messages/capabilities.js +94 -10
  79. package/dist/protocol/messages/common.d.ts +45 -2
  80. package/dist/protocol/messages/common.js +64 -3
  81. package/dist/protocol/messages/dashboard-sealed-write.d.ts +52 -0
  82. package/dist/protocol/messages/dashboard-sealed-write.js +57 -0
  83. package/dist/protocol/messages/dashboard.d.ts +1232 -706
  84. package/dist/protocol/messages/dashboard.js +387 -220
  85. package/dist/protocol/messages/deployment-identity.d.ts +37 -10
  86. package/dist/protocol/messages/deployment-identity.js +30 -3
  87. package/dist/protocol/messages/event-log.d.ts +5 -5
  88. package/dist/protocol/messages/execution-status.d.ts +198 -62
  89. package/dist/protocol/messages/execution-status.js +114 -46
  90. package/dist/protocol/messages/heartbeat-health.d.ts +83 -0
  91. package/dist/protocol/messages/heartbeat-health.js +87 -0
  92. package/dist/protocol/messages/log-stream.d.ts +18 -0
  93. package/dist/protocol/messages/log-stream.js +19 -0
  94. package/dist/protocol/messages/oidc-mint.d.ts +7 -0
  95. package/dist/protocol/messages/oidc-mint.js +7 -0
  96. package/dist/protocol/messages/orchestrator-agent.d.ts +264 -67
  97. package/dist/protocol/messages/orchestrator-agent.js +170 -5
  98. package/dist/protocol/messages/pat-kind.d.ts +1 -1
  99. package/dist/protocol/messages/peer.d.ts +122 -58
  100. package/dist/protocol/messages/peer.js +37 -2
  101. package/dist/protocol/messages/platform-orchestrator.d.ts +603 -258
  102. package/dist/protocol/messages/platform-orchestrator.js +131 -21
  103. package/dist/protocol/messages/run-events.d.ts +5 -5
  104. package/dist/protocol/messages/scaler-event.d.ts +3 -3
  105. package/dist/protocol/messages/source-registration.d.ts +56 -13
  106. package/dist/protocol/messages/source-registration.js +49 -6
  107. package/dist/protocol/session-policy.d.ts +20 -0
  108. package/dist/protocol/session-policy.js +25 -0
  109. package/dist/protocol/source-origin.d.ts +1 -1
  110. package/dist/provenance/attestation-origin.d.ts +1 -1
  111. package/dist/provenance/schema.d.ts +11 -11
  112. package/dist/provenance/verify.js +2 -1
  113. package/dist/provider/changed-files-fetcher.d.ts +21 -2
  114. package/dist/provider/check-run-conclusion.d.ts +2 -2
  115. package/dist/provider/check-status-poster.d.ts +23 -0
  116. package/dist/provider/index.d.ts +2 -2
  117. package/dist/registration/registerable-trigger-type.d.ts +14 -13
  118. package/dist/registration/registerable-trigger-type.js +1 -0
  119. package/dist/sandbox/capabilities.d.ts +6 -0
  120. package/dist/sandbox/capabilities.js +57 -0
  121. package/dist/scaler/scaler-backend-type.d.ts +1 -1
  122. package/dist/status/presentation.d.ts +89 -0
  123. package/dist/status/presentation.js +163 -0
  124. package/dist/trigger/compiled-matchers.d.ts +13 -0
  125. package/dist/trigger/compiled-matchers.js +44 -0
  126. package/dist/trigger/event-buckets.d.ts +44 -0
  127. package/dist/trigger/event-buckets.js +93 -0
  128. package/dist/trigger/matcher.d.ts +7 -3
  129. package/dist/trigger/matcher.js +53 -15
  130. package/dist/trigger/schedule-key.d.ts +14 -0
  131. package/dist/trigger/schedule-key.js +21 -0
  132. package/dist/trigger/trigger-event-type.d.ts +1 -1
  133. package/dist/trigger/trigger-event-type.js +2 -0
  134. package/dist/trigger/types.d.ts +178 -47
  135. package/dist/trigger/types.js +82 -24
  136. package/dist/webhook/event-types.d.ts +56 -0
  137. package/dist/webhook/event-types.js +59 -0
  138. package/dist/ws/ws-like.d.ts +13 -0
  139. package/package.json +26 -10
  140. package/sbom.spdx.json +10 -10
  141. package/dist/environment/index.d.ts +0 -6
  142. package/dist/environment/index.js +0 -5
  143. package/dist/environment/multi-env.d.ts +0 -30
  144. package/dist/environment/multi-env.js +0 -38
  145. package/dist/environment/scope-resolver.d.ts +0 -46
  146. package/dist/package-manager.d.ts +0 -20
  147. package/dist/protocol/messages/observe.d.ts +0 -76
  148. package/dist/protocol/messages/saas-orchestrator.d.ts +0 -2179
  149. package/dist/protocol/messages/test-run.d.ts +0 -59
  150. package/dist/state-machine/index.d.ts +0 -2
  151. package/dist/state-machine/index.js +0 -3
  152. package/dist/state-machine/machine.d.ts +0 -34
  153. package/dist/state-machine/machine.js +0 -103
  154. package/dist/state-machine/types.d.ts +0 -34
  155. package/dist/state-machine/types.js +0 -15
  156. /package/dist/{environment → context}/host-match.d.ts +0 -0
  157. /package/dist/{environment → context}/scope-template.d.ts +0 -0
@@ -1,32 +1,62 @@
1
1
  import "../rolldown-runtime-ClRpJifh.js";
2
2
  import { ExecutionJobStatus, TERMINAL_JOB_STATES } from "../protocol/messages/execution-status.js";
3
+ import { isFailureStatus } from "../status/presentation.js";
3
4
  import { z } from "zod";
4
5
  //#region src/trigger/types.ts
5
6
  /**
6
7
  * Lock file types for the trigger matching engine.
7
8
  * Single source of truth -- replaces local copies in @kici-dev/compiler and @kici-dev/orchestrator.
8
- * Schema version 4: adds 4 internal event routing trigger types (kici_event, workflow_complete,
9
+ *
10
+ * Bump-history convention: every entry is annotated `additive` (older readers
11
+ * tolerate the new lock because unknown fields are ignored) or `BREAKING` (an
12
+ * older reader would mis-parse the lock). Every `BREAKING` bump moves
13
+ * `BREAKING_FLOOR` (below) to that version in the SAME commit.
14
+ *
15
+ * Schema version 4 (additive): adds 4 internal event routing trigger types (kici_event, workflow_complete,
9
16
  * job_complete, generic_webhook).
10
- * Schema version 6: replaces job-level contexts with environment/env/concurrencyGroup.
11
- * Schema version 8: adds runsOn polymorphic type (string | string[] | selector) and excludeLabels.
12
- * Schema version 9: adds repos/notRepos repo pattern fields to git-event triggers for global workflow matching.
13
- * Schema version 10: removes notRepos/notPaths fields, negative patterns use ! prefix in repos/paths arrays.
14
- * Schema version 11: adds LockInlineValue type for pure function inline evaluation.
15
- * Schema version 14: adds declarative cache specs to LockJob and LockStep.
16
- * Schema version 15: adds per-job init config(s) to LockJob.
17
- * Schema version 16: adds normalized approval config to LockWorkflow/LockJob/LockStep.
18
- * Schema version 17: widens LockJob.init to typed presets ('mise' / { mise }) and 'auto' detection.
19
- * Schema version 18: adds LockJob.runsOnAll host fan-out predicate + onUnreachable policy.
20
- * Schema version 19: adds LockJob.maxParallel/failFast fan-out concurrency (rolling waves).
21
- * Schema version 20: runsOn/runsOnAll/excludeLabels carry LabelMatcher (exact|regex) for glob+regex selectors.
22
- * Schema version 23: adds LockDispatchTrigger.inputs (typed dispatch inputs descriptors).
23
- * Schema version 24: adds LockJob.runsOnPick (deterministic single-host selection).
24
- * Schema version 25: adds LockStep.retry (step retry policy data subset; retryIf is execution-only).
25
- * Schema version 26: adds LockJob.includeUninitialized (runsOnAll fans out to declared-but-un-agented hosts, bringing up a temporary init-runner per fresh box).
26
- * Schema version 27: adds LockScheduleTrigger.inputs (defaults-only schedule dispatch inputs).
17
+ * Schema version 6 (BREAKING): replaces job-level contexts with environment/env/concurrencyGroup.
18
+ * Schema version 8 (additive): adds runsOn polymorphic type (string | string[] | selector) and excludeLabels.
19
+ * Schema version 9 (additive): adds repos/notRepos repo pattern fields to git-event triggers for global workflow matching.
20
+ * Schema version 10 (BREAKING): removes notRepos/notPaths fields, negative patterns use ! prefix in repos/paths arrays.
21
+ * Schema version 11 (additive): adds LockInlineValue type for pure function inline evaluation.
22
+ * Schema version 14 (additive): adds declarative cache specs to LockJob and LockStep.
23
+ * Schema version 15 (additive): adds per-job init config(s) to LockJob.
24
+ * Schema version 16 (additive): adds normalized approval config to LockWorkflow/LockJob/LockStep.
25
+ * Schema version 17 (additive): widens LockJob.init to typed presets ('mise' / { mise }) and 'auto' detection.
26
+ * Schema version 18 (additive): adds LockJob.runsOnAll host fan-out predicate + onUnreachable policy.
27
+ * Schema version 19 (additive): adds LockJob.maxParallel/failFast fan-out concurrency (rolling waves).
28
+ * Schema version 20 (BREAKING): runsOn/runsOnAll/excludeLabels carry LabelMatcher (exact|regex) for glob+regex selectors.
29
+ * Schema version 23 (additive): adds LockDispatchTrigger.inputs (typed dispatch inputs descriptors).
30
+ * Schema version 24 (additive): adds LockJob.runsOnPick (deterministic single-host selection).
31
+ * Schema version 25 (additive): adds LockStep.retry (step retry policy data subset; retryIf is execution-only).
32
+ * Schema version 26 (additive): adds LockJob.includeUninitialized (runsOnAll fans out to declared-but-un-agented hosts, bringing up a temporary init-runner per fresh box).
33
+ * Schema version 27 (additive): adds LockScheduleTrigger.inputs (defaults-only schedule dispatch inputs).
34
+ * Schema version 30 (BREAKING): renames job-level `environments` to `contexts`.
35
+ * Schema version 31 (additive): adds the workflows_failed_batch lock trigger.
36
+ * Schema version 32 (additive): adds LockJob.sandbox (per-job escape-hatch request).
37
+ */
38
+ /**
39
+ * Schema version the compiler emits into every lock file. Incremented on ANY
40
+ * schema change (additive or breaking); the bump-history comment above records
41
+ * which. See `BREAKING_FLOOR` for the compatibility-window semantics.
27
42
  */
28
- /** Schema version - increment on breaking changes */
29
- const SCHEMA_VERSION = 29;
43
+ const SCHEMA_VERSION = 32;
44
+ /**
45
+ * Oldest lock schema version this codebase can still read correctly — the lower
46
+ * bound of the acceptance window.
47
+ *
48
+ * A lock at `schemaVersion >= BREAKING_FLOOR` parses correctly here even if it
49
+ * is newer than `SCHEMA_VERSION` (additive bumps add fields this reader ignores).
50
+ * A lock below the floor was produced by an SDK whose breaking change this
51
+ * reader predates and must be rejected (it would mis-parse silently otherwise).
52
+ *
53
+ * Bump rule: move this to the current `SCHEMA_VERSION` ONLY in the commit that
54
+ * lands a `BREAKING` schema change (see the bump-history convention above). It
55
+ * currently sits at 30 because v30 (`environments`→`contexts`) was the most
56
+ * recent breaking bump; v31 and v32 were additive, so a v30 lock still reads
57
+ * correctly.
58
+ */
59
+ const BREAKING_FLOOR = 30;
30
60
  /** Type guard distinguishing a parallel group from an ordinary lock step. */
31
61
  function isLockParallelStep(entry) {
32
62
  return entry.kind === "parallel";
@@ -58,17 +88,22 @@ const WHEN_TO_RUN_ON = {
58
88
  "on-success": [ExecutionJobStatus.enum.success],
59
89
  always: [...TERMINAL_JOB_STATES],
60
90
  "on-skip": [ExecutionJobStatus.enum.success, ExecutionJobStatus.enum.skipped],
61
- "on-failure": [ExecutionJobStatus.enum.failed, ExecutionJobStatus.enum.timed_out_stale]
91
+ "on-failure": [...TERMINAL_JOB_STATES].filter(isFailureStatus)
62
92
  };
63
93
  /**
64
94
  * Resolve the author-facing `when` (keyword sugar | raw status-set | unset) to
65
95
  * the normalized status-set. An unset `when` defaults to success-only — the
66
96
  * downstream runs only when the upstream succeeded.
97
+ *
98
+ * Always a fresh array. The keyword arm used to hand back the shared
99
+ * `WHEN_TO_RUN_ON` entry itself, so every lock-file edge compiled from the same
100
+ * keyword aliased one array and any caller that sorted or mutated its result
101
+ * silently reordered the keyword's expansion for every other edge.
67
102
  */
68
103
  function resolveWhenToRunOn(when) {
69
104
  if (when === void 0) return [ExecutionJobStatus.enum.success];
70
- if (Array.isArray(when)) return when;
71
- return WHEN_TO_RUN_ON[when];
105
+ if (Array.isArray(when)) return [...when];
106
+ return [...WHEN_TO_RUN_ON[when]];
72
107
  }
73
108
  /**
74
109
  * Needs entry carrying the normalized run-on status-set.
@@ -111,6 +146,12 @@ const OnUnreachableMode = z.enum([
111
146
  * - `any`: pick any available agent (load spread).
112
147
  */
113
148
  const RunsOnPick = z.enum(["deterministic", "any"]);
149
+ /** Container network posture: 'default' (bridge), 'none' (loopback-only), 'host' (host netns; gated). */
150
+ const SANDBOX_NETWORK_MODES = [
151
+ "default",
152
+ "none",
153
+ "host"
154
+ ];
114
155
  /** Type guard for static jobs */
115
156
  function isLockStaticJob(job) {
116
157
  return job._type === "static";
@@ -119,7 +160,24 @@ function isLockStaticJob(job) {
119
160
  function isLockDynamicJobFn(job) {
120
161
  return job._type === "dynamic";
121
162
  }
163
+ /**
164
+ * Availability of the changed-files list for path-filter evaluation.
165
+ *
166
+ * Distinguishes three states that a bare `string[]` collapses into one:
167
+ * - `skipped` — no trigger has path patterns, so the fetch never ran. Path
168
+ * filters are not evaluated (today's no-fetch fast path).
169
+ * - `fetched` — the fetch succeeded and the list is authoritative; an empty
170
+ * list genuinely means "no files changed" and does NOT match a path filter.
171
+ * - `unavailable` — the diff could not be determined (a provider capability
172
+ * gap such as universal-git PR events, or upstream degradation). Path
173
+ * filters match conservatively so a real change is never silently dropped.
174
+ */
175
+ const changedFilesStatusSchema = z.enum([
176
+ "fetched",
177
+ "unavailable",
178
+ "skipped"
179
+ ]);
122
180
  //#endregion
123
- export { NeedsEntrySchema, NeedsGroupEntrySchema, NeedsRunOn, NeedsWhen, OnUnreachableMode, RunsOnPick, SCHEMA_VERSION, isLockDynamicJobFn, isLockInlineValue, isLockParallelStep, isLockStaticJob, resolveWhenToRunOn };
181
+ export { BREAKING_FLOOR, NeedsEntrySchema, NeedsGroupEntrySchema, NeedsRunOn, NeedsWhen, OnUnreachableMode, RunsOnPick, SANDBOX_NETWORK_MODES, SCHEMA_VERSION, changedFilesStatusSchema, isLockDynamicJobFn, isLockInlineValue, isLockParallelStep, isLockStaticJob, resolveWhenToRunOn };
124
182
 
125
183
  //# sourceMappingURL=types.js.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Shared outbound-webhook event-type vocabulary — the single source of truth for
3
+ * the event types a customer can subscribe an endpoint to, consumed by the
4
+ * Platform route validator and the dashboard endpoint-create checkbox list.
5
+ *
6
+ * Pure Zod (browser-safe): the engine barrel re-exports this module and the
7
+ * dashboard imports the barrel, so no Node built-in may appear here.
8
+ *
9
+ * `docs/user/dashboard/settings.md` § Webhooks lists the subscribable types in
10
+ * prose — adding a type here means updating that list in the same change.
11
+ */
12
+ import { z } from 'zod';
13
+ /**
14
+ * The connectivity-check event the test-endpoint button sends. It is not
15
+ * subscribable, and a failed ping never counts toward an endpoint's
16
+ * consecutive-failure budget — a customer probing a not-yet-live receiver must
17
+ * not be able to auto-disable their own endpoint.
18
+ */
19
+ export declare const PING_EVENT_TYPE = "ping";
20
+ /** Zod enum for the subscribable set — usable directly as a route schema. */
21
+ export declare const SubscribableWebhookEventType: z.ZodEnum<{
22
+ "job.completed": "job.completed";
23
+ "job.failed": "job.failed";
24
+ "job.started": "job.started";
25
+ "run.completed": "run.completed";
26
+ "run.failed": "run.failed";
27
+ "run.started": "run.started";
28
+ }>;
29
+ export type SubscribableWebhookEventType = z.infer<typeof SubscribableWebhookEventType>;
30
+ /**
31
+ * All outbound webhook event types (the Stripe-style envelope `type`, also sent
32
+ * as the X-KiCI-Event header): the subscribable set plus the ping, which is
33
+ * emitted only by the test-endpoint button and is never subscribable.
34
+ */
35
+ export declare const WebhookEventType: z.ZodEnum<{
36
+ "job.completed": "job.completed";
37
+ "job.failed": "job.failed";
38
+ "job.started": "job.started";
39
+ ping: "ping";
40
+ "run.completed": "run.completed";
41
+ "run.failed": "run.failed";
42
+ "run.started": "run.started";
43
+ }>;
44
+ export type WebhookEventType = z.infer<typeof WebhookEventType>;
45
+ /**
46
+ * Readonly value tuple for iteration (UI checkbox list, tests) — the accepted
47
+ * set of `SubscribableWebhookEventType`, in declaration order.
48
+ *
49
+ * A frozen copy, not `SubscribableWebhookEventType.options`: Zod hands back the
50
+ * validator's own internal array from that getter, so re-exporting it would let
51
+ * any consumer `push` / `sort` the shared vocabulary out from under every other
52
+ * module in the process. `event-types.test.ts` asserts the copy still matches
53
+ * the validator's options.
54
+ */
55
+ export declare const SUBSCRIBABLE_WEBHOOK_EVENT_TYPES: readonly ("job.completed" | "job.failed" | "job.started" | "run.completed" | "run.failed" | "run.started")[];
56
+ //# sourceMappingURL=event-types.d.ts.map
@@ -0,0 +1,59 @@
1
+ import "../rolldown-runtime-ClRpJifh.js";
2
+ import { z } from "zod";
3
+ //#region src/webhook/event-types.ts
4
+ /**
5
+ * Shared outbound-webhook event-type vocabulary — the single source of truth for
6
+ * the event types a customer can subscribe an endpoint to, consumed by the
7
+ * Platform route validator and the dashboard endpoint-create checkbox list.
8
+ *
9
+ * Pure Zod (browser-safe): the engine barrel re-exports this module and the
10
+ * dashboard imports the barrel, so no Node built-in may appear here.
11
+ *
12
+ * `docs/user/dashboard/settings.md` § Webhooks lists the subscribable types in
13
+ * prose — adding a type here means updating that list in the same change.
14
+ */
15
+ /**
16
+ * Subscribable webhook event types — the run/job lifecycle events a customer can
17
+ * wire an endpoint to. Written once here; the full `WebhookEventType` enum
18
+ * derives from these plus the non-subscribable ping. Module-private on purpose:
19
+ * `SUBSCRIBABLE_WEBHOOK_EVENT_TYPES` is the one public name for this list, so
20
+ * consumers cannot pick between two spellings of the same vocabulary.
21
+ */
22
+ const SUBSCRIBABLE_EVENT_VALUES = [
23
+ "run.started",
24
+ "run.completed",
25
+ "run.failed",
26
+ "job.started",
27
+ "job.completed",
28
+ "job.failed"
29
+ ];
30
+ /**
31
+ * The connectivity-check event the test-endpoint button sends. It is not
32
+ * subscribable, and a failed ping never counts toward an endpoint's
33
+ * consecutive-failure budget — a customer probing a not-yet-live receiver must
34
+ * not be able to auto-disable their own endpoint.
35
+ */
36
+ const PING_EVENT_TYPE = "ping";
37
+ /** Zod enum for the subscribable set — usable directly as a route schema. */
38
+ const SubscribableWebhookEventType = z.enum(SUBSCRIBABLE_EVENT_VALUES);
39
+ /**
40
+ * All outbound webhook event types (the Stripe-style envelope `type`, also sent
41
+ * as the X-KiCI-Event header): the subscribable set plus the ping, which is
42
+ * emitted only by the test-endpoint button and is never subscribable.
43
+ */
44
+ const WebhookEventType = z.enum([...SUBSCRIBABLE_EVENT_VALUES, PING_EVENT_TYPE]);
45
+ /**
46
+ * Readonly value tuple for iteration (UI checkbox list, tests) — the accepted
47
+ * set of `SubscribableWebhookEventType`, in declaration order.
48
+ *
49
+ * A frozen copy, not `SubscribableWebhookEventType.options`: Zod hands back the
50
+ * validator's own internal array from that getter, so re-exporting it would let
51
+ * any consumer `push` / `sort` the shared vocabulary out from under every other
52
+ * module in the process. `event-types.test.ts` asserts the copy still matches
53
+ * the validator's options.
54
+ */
55
+ const SUBSCRIBABLE_WEBHOOK_EVENT_TYPES = Object.freeze([...SUBSCRIBABLE_EVENT_VALUES]);
56
+ //#endregion
57
+ export { PING_EVENT_TYPE, SUBSCRIBABLE_WEBHOOK_EVENT_TYPES, SubscribableWebhookEventType, WebhookEventType };
58
+
59
+ //# sourceMappingURL=event-types.js.map
@@ -8,5 +8,18 @@ export interface WsLike {
8
8
  send(data: string | ArrayBuffer): void;
9
9
  close(code?: number, reason?: string): void;
10
10
  readyState: number;
11
+ /**
12
+ * Bytes queued in the socket's send buffer, when the transport exposes it.
13
+ * The `ws` library socket does; used by the browser fan-out to terminate a
14
+ * slow consumer past a watermark instead of buffering unboundedly in heap.
15
+ * Optional so mock sockets and non-`ws` transports need not provide it.
16
+ */
17
+ bufferedAmount?: number;
18
+ /**
19
+ * Force-close the underlying socket immediately, when the transport exposes
20
+ * it (the `ws` library socket does). Optional for the same reason as
21
+ * `bufferedAmount`.
22
+ */
23
+ terminate?(): void;
11
24
  }
12
25
  //# sourceMappingURL=ws-like.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kici-dev/engine",
3
- "version": "0.1.26",
3
+ "version": "0.2.0",
4
4
  "description": "Shared business logic for the KiCI CI/CD stack: protocol, triggers, state machine, and provider interfaces used by the Platform relay, orchestrator, and compiler.",
5
5
  "keywords": [
6
6
  "ci",
@@ -53,13 +53,13 @@
53
53
  "import": "./dist/labels/compile.js",
54
54
  "types": "./dist/labels/compile.d.ts"
55
55
  },
56
- "./environment/host-match": {
57
- "import": "./dist/environment/host-match.js",
58
- "types": "./dist/environment/host-match.d.ts"
56
+ "./context/host-match": {
57
+ "import": "./dist/context/host-match.js",
58
+ "types": "./dist/context/host-match.d.ts"
59
59
  },
60
- "./environment/scope-template": {
61
- "import": "./dist/environment/scope-template.js",
62
- "types": "./dist/environment/scope-template.d.ts"
60
+ "./context/scope-template": {
61
+ "import": "./dist/context/scope-template.js",
62
+ "types": "./dist/context/scope-template.d.ts"
63
63
  },
64
64
  "./protocol/dashboard-global-workflows": {
65
65
  "import": "./dist/protocol/dashboard-global-workflows.js",
@@ -69,6 +69,14 @@
69
69
  "import": "./dist/protocol/dashboard-write-operations.js",
70
70
  "types": "./dist/protocol/dashboard-write-operations.d.ts"
71
71
  },
72
+ "./protocol/dashboard-api-errors": {
73
+ "import": "./dist/protocol/dashboard-api-errors.js",
74
+ "types": "./dist/protocol/dashboard-api-errors.d.ts"
75
+ },
76
+ "./protocol/session-policy": {
77
+ "import": "./dist/protocol/session-policy.js",
78
+ "types": "./dist/protocol/session-policy.d.ts"
79
+ },
72
80
  "./protocol/analytics-events": {
73
81
  "import": "./dist/protocol/analytics-events.js",
74
82
  "types": "./dist/protocol/analytics-events.d.ts"
@@ -81,6 +89,10 @@
81
89
  "import": "./dist/protocol/messages/oidc-token-relay.js",
82
90
  "types": "./dist/protocol/messages/oidc-token-relay.d.ts"
83
91
  },
92
+ "./protocol/messages/dashboard-sealed-write": {
93
+ "import": "./dist/protocol/messages/dashboard-sealed-write.js",
94
+ "types": "./dist/protocol/messages/dashboard-sealed-write.d.ts"
95
+ },
84
96
  "./protocol/messages/oidc-mint": {
85
97
  "import": "./dist/protocol/messages/oidc-mint.js",
86
98
  "types": "./dist/protocol/messages/oidc-mint.d.ts"
@@ -112,12 +124,16 @@
112
124
  "./metrics/catalog-policy": {
113
125
  "import": "./dist/metrics/catalog-policy.js",
114
126
  "types": "./dist/metrics/catalog-policy.d.ts"
127
+ },
128
+ "./metrics/metric-kind-compat": {
129
+ "import": "./dist/metrics/metric-kind-compat.js",
130
+ "types": "./dist/metrics/metric-kind-compat.d.ts"
115
131
  }
116
132
  },
117
133
  "dependencies": {
118
134
  "jose": "^6.1.0",
119
135
  "jsonpath-plus": "^10.4.0",
120
- "picomatch": "^4.0.4",
136
+ "picomatch": "^4.0.5",
121
137
  "safe-regex": "^2.1.1",
122
138
  "zod": "^4.4.3"
123
139
  },
@@ -126,8 +142,8 @@
126
142
  "@types/safe-regex": "^1.1.6"
127
143
  },
128
144
  "scripts": {
129
- "build": "node ../../scripts/build-ts.mjs && tsc --emitDeclarationOnly",
130
- "typecheck": "tsc --noEmit",
145
+ "build": "node ../../scripts/build-ts.mjs && tsgo --emitDeclarationOnly",
146
+ "typecheck": "tsgo --noEmit",
131
147
  "test": "vitest run"
132
148
  }
133
149
  }
package/sbom.spdx.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "spdxVersion": "SPDX-2.3",
3
3
  "dataLicense": "CC0-1.0",
4
4
  "SPDXID": "SPDXRef-DOCUMENT",
5
- "name": "@kici-dev/engine@0.1.26",
6
- "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fengine/0.1.26/aac1dbb3-c6f9-48b3-8675-85b4ba20c113",
5
+ "name": "@kici-dev/engine@0.2.0",
6
+ "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fengine/0.2.0/542cdb3d-4979-42ab-ac13-1e4b9c793893",
7
7
  "creationInfo": {
8
- "created": "2026-07-06T04:29:39Z",
8
+ "created": "2026-08-08T04:27:05Z",
9
9
  "creators": [
10
10
  "Tool: kici-sbom-generator"
11
11
  ]
@@ -54,7 +54,7 @@
54
54
  {
55
55
  "SPDXID": "SPDXRef-RootPackage",
56
56
  "name": "@kici-dev/engine",
57
- "versionInfo": "0.1.26",
57
+ "versionInfo": "0.2.0",
58
58
  "downloadLocation": "NOASSERTION",
59
59
  "filesAnalyzed": false,
60
60
  "licenseConcluded": "NOASSERTION",
@@ -65,7 +65,7 @@
65
65
  {
66
66
  "referenceCategory": "PACKAGE-MANAGER",
67
67
  "referenceType": "purl",
68
- "referenceLocator": "pkg:npm/%40kici-dev/engine@0.1.26"
68
+ "referenceLocator": "pkg:npm/%40kici-dev/engine@0.2.0"
69
69
  }
70
70
  ],
71
71
  "description": "Shared business logic for the KiCI CI/CD stack: protocol, triggers, state machine, and provider interfaces used by the Platform relay, orchestrator, and compiler.",
@@ -132,10 +132,10 @@
132
132
  "homepage": "https://github.com/s3u/JSONPath"
133
133
  },
134
134
  {
135
- "SPDXID": "SPDXRef-Package-picomatch-4.0.4",
135
+ "SPDXID": "SPDXRef-Package-picomatch-4.0.5",
136
136
  "name": "picomatch",
137
- "versionInfo": "4.0.4",
138
- "downloadLocation": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
137
+ "versionInfo": "4.0.5",
138
+ "downloadLocation": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
139
139
  "filesAnalyzed": false,
140
140
  "licenseConcluded": "NOASSERTION",
141
141
  "licenseDeclared": "MIT",
@@ -145,7 +145,7 @@
145
145
  {
146
146
  "referenceCategory": "PACKAGE-MANAGER",
147
147
  "referenceType": "purl",
148
- "referenceLocator": "pkg:npm/picomatch@4.0.4"
148
+ "referenceLocator": "pkg:npm/picomatch@4.0.5"
149
149
  }
150
150
  ],
151
151
  "description": "Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.",
@@ -240,7 +240,7 @@
240
240
  },
241
241
  {
242
242
  "spdxElementId": "SPDXRef-RootPackage",
243
- "relatedSpdxElement": "SPDXRef-Package-picomatch-4.0.4",
243
+ "relatedSpdxElement": "SPDXRef-Package-picomatch-4.0.5",
244
244
  "relationshipType": "DEPENDS_ON"
245
245
  },
246
246
  {
@@ -1,6 +0,0 @@
1
- export type { Environment, EnvironmentBinding, EnvironmentVariable, EnvironmentSourceOverride, ScopedSecret, HeldRun, ProtectionGateResult, TrustTier, } from './types.js';
2
- export { TrustTierSchema } from './types.js';
3
- export { resolveSecretsForEnvironment, matchScopePattern, stripScopePrefix, } from './scope-resolver.js';
4
- export type { HostFacts } from './host-match.js';
5
- export { mergeOrderedMaps, EnvGateRejectReason } from './multi-env.js';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +0,0 @@
1
- import "../rolldown-runtime-ClRpJifh.js";
2
- import { TrustTierSchema } from "./types.js";
3
- import { matchScopePattern, resolveSecretsForEnvironment, stripScopePrefix } from "./scope-resolver.js";
4
- import { EnvGateRejectReason, mergeOrderedMaps } from "./multi-env.js";
5
- export { EnvGateRejectReason, TrustTierSchema, matchScopePattern, mergeOrderedMaps, resolveSecretsForEnvironment, stripScopePrefix };
@@ -1,30 +0,0 @@
1
- /**
2
- * Multi-environment merge helpers shared across the orchestrator dispatch path.
3
- *
4
- * A job may bind several deployment environments in order; their resolved
5
- * secrets/variables are folded last-wins (a later environment's key overrides an
6
- * earlier one) and their protection gates combine all-must-pass. This module is
7
- * browser-safe (pure functions + a Zod enum, no Node built-ins) so it can be
8
- * exported from the engine environment barrel.
9
- */
10
- import { z } from 'zod';
11
- /**
12
- * Reason a single bound environment rejects a run under all-must-pass
13
- * aggregation. Used to name which environment and which rule blocked dispatch.
14
- */
15
- export declare const EnvGateRejectReason: z.ZodEnum<{
16
- branch_restricted: "branch_restricted";
17
- trigger_filtered: "trigger_filtered";
18
- repo_unmatched: "repo_unmatched";
19
- trust_too_low: "trust_too_low";
20
- env_disabled: "env_disabled";
21
- env_not_found: "env_not_found";
22
- }>;
23
- export type EnvGateRejectReason = z.infer<typeof EnvGateRejectReason>;
24
- /**
25
- * Fold an ordered list of per-environment resolved maps into one. Later entries
26
- * override earlier keys (last-wins), matching the documented merge order for
27
- * `environments: [...]`.
28
- */
29
- export declare function mergeOrderedMaps(maps: ReadonlyArray<Record<string, string>>): Record<string, string>;
30
- //# sourceMappingURL=multi-env.d.ts.map
@@ -1,38 +0,0 @@
1
- import "../rolldown-runtime-ClRpJifh.js";
2
- import { z } from "zod";
3
- //#region src/environment/multi-env.ts
4
- /**
5
- * Multi-environment merge helpers shared across the orchestrator dispatch path.
6
- *
7
- * A job may bind several deployment environments in order; their resolved
8
- * secrets/variables are folded last-wins (a later environment's key overrides an
9
- * earlier one) and their protection gates combine all-must-pass. This module is
10
- * browser-safe (pure functions + a Zod enum, no Node built-ins) so it can be
11
- * exported from the engine environment barrel.
12
- */
13
- /**
14
- * Reason a single bound environment rejects a run under all-must-pass
15
- * aggregation. Used to name which environment and which rule blocked dispatch.
16
- */
17
- const EnvGateRejectReason = z.enum([
18
- "branch_restricted",
19
- "trigger_filtered",
20
- "repo_unmatched",
21
- "trust_too_low",
22
- "env_disabled",
23
- "env_not_found"
24
- ]);
25
- /**
26
- * Fold an ordered list of per-environment resolved maps into one. Later entries
27
- * override earlier keys (last-wins), matching the documented merge order for
28
- * `environments: [...]`.
29
- */
30
- function mergeOrderedMaps(maps) {
31
- const out = {};
32
- for (const m of maps) Object.assign(out, m);
33
- return out;
34
- }
35
- //#endregion
36
- export { EnvGateRejectReason, mergeOrderedMaps };
37
-
38
- //# sourceMappingURL=multi-env.js.map
@@ -1,46 +0,0 @@
1
- import type { EnvironmentBinding, ScopedSecret } from './types.js';
2
- import { type HostFacts } from './host-match.js';
3
- export type { HostFacts } from './host-match.js';
4
- /**
5
- * Check whether a scope string matches a pattern.
6
- *
7
- * Supports exact match and glob patterns (via picomatch).
8
- * Scope paths use '/' as separator (e.g., 'aws/prod/db').
9
- *
10
- * For prefixed scopes (e.g., 'pg:aws/prod'), the pattern may be prefixed too
11
- * (e.g., 'pg:**'). In this case, the backend prefix must match exactly and
12
- * the path portion is matched separately against the glob. This is needed
13
- * because picomatch's '**' requires '/' separators — 'pg:**' wouldn't match
14
- * 'pg:aws/prod' without splitting on the colon.
15
- */
16
- export declare function matchScopePattern(scope: string, pattern: string): boolean;
17
- /**
18
- * Strip the backend prefix from a scope string.
19
- * Prefixed scopes have the form "backendName:path" (e.g., "pg:aws/prod").
20
- * Returns the path after the first colon, or the full scope if no prefix.
21
- */
22
- export declare function stripScopePrefix(scope: string): string;
23
- /**
24
- * Resolve secrets for an environment by matching bindings against scoped secrets.
25
- *
26
- * Takes already-filtered bindings (for the target environment). For each binding,
27
- * finds secrets whose (substituted) scope matches the binding's scopePattern via
28
- * picomatch. When multiple scopes provide the same key, precedence is the tuple
29
- * `(host specificity, scope depth)` — a per-host binding (exact host) overrides a
30
- * fleet-wide one, then longest scope path wins. Scope depth is computed AFTER
31
- * stripping the backend prefix.
32
- *
33
- * When `hostFacts` is supplied (a fan-out child's identity), each binding is
34
- * gated by its `host_pattern` and its `scope_pattern` is templated per-child
35
- * (`${agentId}`/`${host}`/`${label:NAME}`). When omitted, only fleet-wide
36
- * (`'**'`/NULL) non-templated bindings contribute — preserving the workflow-level
37
- * (no-host) behaviour.
38
- *
39
- * @param bindings - Bindings already filtered for the target environment
40
- * @param allSecrets - All scoped secrets in the org
41
- * @param decryptFn - Pure decryption function (keeps this module crypto-free)
42
- * @param hostFacts - Optional fan-out child identity for per-host resolution
43
- * @returns Flat record of decrypted secret key-value pairs
44
- */
45
- export declare function resolveSecretsForEnvironment(bindings: EnvironmentBinding[], allSecrets: ScopedSecret[], decryptFn: (s: ScopedSecret) => string, hostFacts?: HostFacts): Record<string, string>;
46
- //# sourceMappingURL=scope-resolver.d.ts.map
@@ -1,20 +0,0 @@
1
- /**
2
- * Package-manager wire identity for protocol schemas and the lock-file type.
3
- *
4
- * Engine has no internal `@kici-dev/*` dependencies (it is a leaf imported by
5
- * the browser dashboard), so it owns the wire enum for the package manager
6
- * rather than importing the detection enum from `@kici-dev/shared`. The three
7
- * values are identical to `@kici-dev/shared`'s `PackageManager` enum; a
8
- * compile-time assignability test in a package that imports both guards
9
- * against drift.
10
- */
11
- import { z } from 'zod';
12
- /** Wire schema for the package manager that resolves `.kici/` dependencies. */
13
- export declare const packageManagerSchema: z.ZodEnum<{
14
- npm: "npm";
15
- pnpm: "pnpm";
16
- yarn: "yarn";
17
- }>;
18
- /** `'npm' | 'pnpm' | 'yarn'` — the package-manager identity on the wire. */
19
- export type PackageManagerId = z.infer<typeof packageManagerSchema>;
20
- //# sourceMappingURL=package-manager.d.ts.map