@kici-dev/engine 0.1.27 → 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 (148) hide show
  1. package/dist/approval/types.d.ts +8 -1
  2. package/dist/approval/types.js +8 -1
  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 +8 -0
  7. package/dist/audit/activity.d.ts +12 -12
  8. package/dist/audit/retention-policy.js +16 -0
  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/context/index.d.ts +9 -1
  26. package/dist/context/index.js +9 -2
  27. package/dist/context/multi-context.d.ts +3 -3
  28. package/dist/context/scope-name.d.ts +29 -0
  29. package/dist/context/scope-name.js +49 -0
  30. package/dist/context/scope-resolver.d.ts +33 -0
  31. package/dist/context/scope-resolver.js +45 -15
  32. package/dist/context/types.d.ts +8 -5
  33. package/dist/dev-ops/operations.d.ts +8 -0
  34. package/dist/dev-ops/operations.js +36 -19
  35. package/dist/diagnostics/infra-alert.d.ts +71 -0
  36. package/dist/diagnostics/infra-alert.js +60 -0
  37. package/dist/env/environment-allowlist.d.ts +4 -4
  38. package/dist/fanout/materialize.d.ts +16 -0
  39. package/dist/fanout/materialize.js +32 -3
  40. package/dist/index.d.ts +15 -6
  41. package/dist/index.js +34 -19
  42. package/dist/inputs/descriptor.d.ts +9 -9
  43. package/dist/inventory.d.ts +4 -4
  44. package/dist/labels.d.ts +82 -2
  45. package/dist/labels.js +119 -1
  46. package/dist/matrix/expand.d.ts +49 -2
  47. package/dist/matrix/expand.js +102 -13
  48. package/dist/matrix/format.d.ts +6 -1
  49. package/dist/matrix/format.js +6 -1
  50. package/dist/mcp/held-run-resolve.d.ts +7 -10
  51. package/dist/mcp/held-run-resolve.js +33 -7
  52. package/dist/metrics/catalog-policy.js +4 -4
  53. package/dist/metrics/metric-catalog.generated.d.ts +954 -739
  54. package/dist/metrics/metric-catalog.generated.js +278 -20
  55. package/dist/metrics/metric-kind-compat.d.ts +26 -0
  56. package/dist/metrics/metric-kind-compat.js +33 -0
  57. package/dist/protocol/analytics-events.d.ts +6 -6
  58. package/dist/protocol/dashboard-api-errors.d.ts +1 -0
  59. package/dist/protocol/dashboard-api-errors.js +5 -1
  60. package/dist/protocol/dashboard-write-operations.d.ts +143 -86
  61. package/dist/protocol/dashboard-write-operations.js +91 -17
  62. package/dist/protocol/messages/access-log.d.ts +437 -392
  63. package/dist/protocol/messages/access-log.js +11 -2
  64. package/dist/protocol/messages/actor.d.ts +2 -2
  65. package/dist/protocol/messages/agent-dev-ops.d.ts +4 -2
  66. package/dist/protocol/messages/agent-dev-ops.js +2 -5
  67. package/dist/protocol/messages/agent-run-result.d.ts +72 -62
  68. package/dist/protocol/messages/auth.d.ts +35 -23
  69. package/dist/protocol/messages/browser.d.ts +81 -5
  70. package/dist/protocol/messages/browser.js +53 -2
  71. package/dist/protocol/messages/capabilities.d.ts +106 -31
  72. package/dist/protocol/messages/capabilities.js +94 -10
  73. package/dist/protocol/messages/common.d.ts +45 -2
  74. package/dist/protocol/messages/common.js +64 -3
  75. package/dist/protocol/messages/dashboard-sealed-write.d.ts +52 -0
  76. package/dist/protocol/messages/dashboard-sealed-write.js +57 -0
  77. package/dist/protocol/messages/dashboard.d.ts +1022 -498
  78. package/dist/protocol/messages/dashboard.js +198 -31
  79. package/dist/protocol/messages/deployment-identity.d.ts +37 -10
  80. package/dist/protocol/messages/deployment-identity.js +30 -3
  81. package/dist/protocol/messages/event-log.d.ts +5 -5
  82. package/dist/protocol/messages/execution-status.d.ts +189 -53
  83. package/dist/protocol/messages/execution-status.js +108 -40
  84. package/dist/protocol/messages/heartbeat-health.d.ts +83 -0
  85. package/dist/protocol/messages/heartbeat-health.js +87 -0
  86. package/dist/protocol/messages/log-stream.d.ts +18 -0
  87. package/dist/protocol/messages/log-stream.js +19 -0
  88. package/dist/protocol/messages/oidc-mint.d.ts +7 -0
  89. package/dist/protocol/messages/oidc-mint.js +7 -0
  90. package/dist/protocol/messages/orchestrator-agent.d.ts +264 -67
  91. package/dist/protocol/messages/orchestrator-agent.js +170 -5
  92. package/dist/protocol/messages/pat-kind.d.ts +1 -1
  93. package/dist/protocol/messages/peer.d.ts +122 -58
  94. package/dist/protocol/messages/peer.js +37 -2
  95. package/dist/protocol/messages/platform-orchestrator.d.ts +561 -217
  96. package/dist/protocol/messages/platform-orchestrator.js +131 -21
  97. package/dist/protocol/messages/run-events.d.ts +5 -5
  98. package/dist/protocol/messages/scaler-event.d.ts +3 -3
  99. package/dist/protocol/messages/source-registration.d.ts +56 -13
  100. package/dist/protocol/messages/source-registration.js +49 -6
  101. package/dist/protocol/source-origin.d.ts +1 -1
  102. package/dist/provenance/attestation-origin.d.ts +1 -1
  103. package/dist/provenance/schema.d.ts +11 -11
  104. package/dist/provenance/verify.js +2 -1
  105. package/dist/provider/changed-files-fetcher.d.ts +21 -2
  106. package/dist/provider/check-run-conclusion.d.ts +2 -2
  107. package/dist/provider/check-status-poster.d.ts +23 -0
  108. package/dist/provider/index.d.ts +2 -2
  109. package/dist/registration/registerable-trigger-type.d.ts +14 -13
  110. package/dist/registration/registerable-trigger-type.js +1 -0
  111. package/dist/sandbox/capabilities.d.ts +6 -0
  112. package/dist/sandbox/capabilities.js +57 -0
  113. package/dist/scaler/scaler-backend-type.d.ts +1 -1
  114. package/dist/status/presentation.d.ts +89 -0
  115. package/dist/status/presentation.js +163 -0
  116. package/dist/trigger/compiled-matchers.d.ts +13 -0
  117. package/dist/trigger/compiled-matchers.js +44 -0
  118. package/dist/trigger/event-buckets.d.ts +44 -0
  119. package/dist/trigger/event-buckets.js +93 -0
  120. package/dist/trigger/matcher.d.ts +7 -3
  121. package/dist/trigger/matcher.js +53 -15
  122. package/dist/trigger/schedule-key.d.ts +14 -0
  123. package/dist/trigger/schedule-key.js +21 -0
  124. package/dist/trigger/trigger-event-type.d.ts +1 -1
  125. package/dist/trigger/trigger-event-type.js +2 -0
  126. package/dist/trigger/types.d.ts +173 -43
  127. package/dist/trigger/types.js +82 -25
  128. package/dist/webhook/event-types.d.ts +56 -0
  129. package/dist/webhook/event-types.js +59 -0
  130. package/dist/ws/ws-like.d.ts +13 -0
  131. package/package.json +12 -4
  132. package/sbom.spdx.json +10 -10
  133. package/dist/environment/host-match.d.ts +0 -25
  134. package/dist/environment/index.d.ts +0 -6
  135. package/dist/environment/multi-env.d.ts +0 -30
  136. package/dist/environment/scope-resolver.d.ts +0 -46
  137. package/dist/environment/scope-template.d.ts +0 -18
  138. package/dist/environment/types.d.ts +0 -119
  139. package/dist/package-manager.d.ts +0 -20
  140. package/dist/protocol/messages/observe.d.ts +0 -76
  141. package/dist/protocol/messages/saas-orchestrator.d.ts +0 -2179
  142. package/dist/protocol/messages/test-run.d.ts +0 -59
  143. package/dist/state-machine/index.d.ts +0 -2
  144. package/dist/state-machine/index.js +0 -3
  145. package/dist/state-machine/machine.d.ts +0 -34
  146. package/dist/state-machine/machine.js +0 -103
  147. package/dist/state-machine/types.d.ts +0 -34
  148. package/dist/state-machine/types.js +0 -15
@@ -45,6 +45,14 @@ export interface DeveloperOperation {
45
45
  mcpAppropriate: boolean;
46
46
  /** MCP tool name when `entrypoints.mcp` is true; null otherwise. */
47
47
  mcpTool: string | null;
48
+ /**
49
+ * True when the op acts on a specific repository's resource and must honour
50
+ * the caller's repo glob patterns on EVERY entrypoint. Required on every row
51
+ * so a new op cannot compile without an explicit decision, and NOT derivable
52
+ * from `domain` — `workflows.list` is repo-scoped while `secrets.list`, whose
53
+ * rows are context-keyed with no repository to scope against, is not.
54
+ */
55
+ repoScoped: boolean;
48
56
  }
49
57
  /**
50
58
  * The workflow-developer core. Developer plane only — org-membership-scoped,
@@ -1,7 +1,7 @@
1
1
  import "../rolldown-runtime-ClRpJifh.js";
2
2
  //#region src/dev-ops/operations.ts
3
3
  /** Build a row, defaulting every unspecified entrypoint to false. */
4
- function op(id, domain, kind, ep, mcpAppropriate, mcpTool) {
4
+ function op(id, domain, kind, ep, mcpAppropriate, mcpTool, repoScoped) {
5
5
  return {
6
6
  id,
7
7
  domain,
@@ -14,7 +14,8 @@ function op(id, domain, kind, ep, mcpAppropriate, mcpTool) {
14
14
  ...ep
15
15
  },
16
16
  mcpAppropriate,
17
- mcpTool
17
+ mcpTool,
18
+ repoScoped
18
19
  };
19
20
  }
20
21
  /**
@@ -27,103 +28,119 @@ const DEVELOPER_OPERATIONS = [
27
28
  cli: true,
28
29
  mcp: true,
29
30
  ui: true
30
- }, true, "list_runs"),
31
+ }, true, "list_runs", true),
31
32
  op("runs.get", "runs", "read", {
32
33
  http: true,
33
34
  cli: true,
34
35
  mcp: true,
35
36
  ui: true
36
- }, true, "get_run"),
37
+ }, true, "get_run", true),
37
38
  op("runs.stepLogs", "runs", "read", {
38
39
  http: true,
39
40
  cli: true,
40
41
  mcp: true,
41
42
  ui: true
42
- }, true, "get_step_logs"),
43
+ }, true, "get_step_logs", true),
43
44
  op("runs.cancel", "runs", "write", {
44
45
  http: true,
45
46
  cli: true,
46
47
  mcp: true,
47
48
  ui: true
48
- }, true, "cancel_run"),
49
+ }, true, "cancel_run", true),
49
50
  op("runs.cancelByBranch", "runs", "write", {
50
51
  http: true,
51
52
  cli: true,
52
53
  mcp: true,
53
54
  ui: false
54
- }, true, "cancel_runs_by_branch"),
55
+ }, true, "cancel_runs_by_branch", true),
55
56
  op("runs.rerun", "runs", "write", {
56
57
  http: true,
57
58
  cli: true,
58
59
  mcp: true,
59
60
  ui: true
60
- }, true, "rerun_run"),
61
+ }, true, "rerun_run", true),
61
62
  op("workflows.list", "workflows", "read", {
62
63
  http: true,
63
64
  cli: true,
64
65
  mcp: true,
65
66
  ui: true
66
- }, true, "list_workflows"),
67
+ }, true, "list_workflows", true),
67
68
  op("workflows.trigger", "workflows", "write", {
68
69
  http: true,
69
70
  cli: false,
70
71
  mcp: true,
71
72
  ui: true
72
- }, true, "trigger_run"),
73
+ }, true, "trigger_run", true),
74
+ op("workflows.disable", "workflows", "write", {
75
+ http: true,
76
+ cli: false,
77
+ mcp: false,
78
+ ui: true
79
+ }, false, null, true),
80
+ op("workflows.delete", "workflows", "write", {
81
+ http: true,
82
+ cli: false,
83
+ mcp: false,
84
+ ui: true
85
+ }, false, null, true),
73
86
  op("secrets.list", "secrets", "read", {
74
87
  http: true,
75
88
  cli: true,
76
89
  mcp: true,
77
90
  ui: true
78
- }, true, "list_secrets"),
91
+ }, true, "list_secrets", false),
79
92
  op("secrets.set", "secrets", "write", {
80
93
  http: true,
81
94
  cli: false,
82
95
  mcp: false,
83
96
  ui: true
84
- }, false, null),
97
+ }, false, null, false),
85
98
  op("secrets.delete", "secrets", "write", {
86
99
  http: true,
87
100
  cli: false,
88
101
  mcp: false,
89
102
  ui: true
90
- }, false, null),
103
+ }, false, null, false),
91
104
  op("contexts.delete", "contexts", "write", {
92
105
  http: true,
93
106
  cli: false,
94
107
  mcp: false,
95
108
  ui: true
96
- }, false, null),
109
+ }, false, null, false),
110
+ op("held-runs.list", "held-runs", "read", {
111
+ http: true,
112
+ ui: true
113
+ }, false, null, true),
97
114
  op("held-runs.approve", "held-runs", "write", {
98
115
  http: true,
99
116
  cli: true,
100
117
  mcp: true,
101
118
  ui: true
102
- }, true, "approve_run"),
119
+ }, true, "approve_run", true),
103
120
  op("held-runs.reject", "held-runs", "write", {
104
121
  http: true,
105
122
  cli: true,
106
123
  mcp: true,
107
124
  ui: true
108
- }, true, "reject_run"),
125
+ }, true, "reject_run", true),
109
126
  op("diagnostics.get", "diagnostics", "read", {
110
127
  http: true,
111
128
  cli: true,
112
129
  mcp: true,
113
130
  ui: true
114
- }, true, "get_diagnostics"),
131
+ }, true, "get_diagnostics", false),
115
132
  op("orchestrators.list", "orchestrators", "read", {
116
133
  http: true,
117
134
  cli: true,
118
135
  mcp: true,
119
136
  ui: true
120
- }, true, "list_orchestrators"),
137
+ }, true, "list_orchestrators", false),
121
138
  op("orgs.list", "orgs", "read", {
122
139
  http: true,
123
140
  cli: true,
124
141
  mcp: true,
125
142
  ui: true
126
- }, true, "list_orgs")
143
+ }, true, "list_orgs", false)
127
144
  ];
128
145
  /** All ops a given entrypoint should expose. */
129
146
  function developerOpsForEntrypoint(ep) {
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Infrastructure alert vocabulary — the single definition of what a diagnostics
3
+ * infrastructure alert's `type` and `severity` can be.
4
+ *
5
+ * Lives beside the other shared vocabularies (`billing/plan-type.ts`,
6
+ * `context/held-run-status.ts`) rather than in the protocol module, so the
7
+ * Platform producer, the dashboard, and the `kici` CLI all name one enum
8
+ * instead of each carrying a copy. Pure Zod with no Node built-ins, so it is
9
+ * safe on the browser-facing engine barrel.
10
+ *
11
+ * This is the *known* vocabulary — the set the Platform mints alerts from and
12
+ * the set the read-side consumers colour their badges by. It is deliberately
13
+ * NOT the wire type of the response fields. The hosted Platform always runs the
14
+ * newest build, while a customer's `kici` CLI is pinned to whatever version
15
+ * they installed and hard-parses this response
16
+ * (`packages/compiler/src/remote/dashboard-client.ts`). A strict enum on the
17
+ * wire would not degrade one alert row — it would fail the whole
18
+ * `/diagnostics/infrastructure` parse and take `kici diagnostics` down with it
19
+ * the day a fifth alert type ships. So the response carries `z.string()` and
20
+ * the producer carries the enum: strict on write, permissive on read.
21
+ */
22
+ import { z } from 'zod';
23
+ /**
24
+ * Known infrastructure alert types, matching what the Platform mints from the
25
+ * state it computes about connected orchestrators.
26
+ */
27
+ export declare const InfraAlertType: z.ZodEnum<{
28
+ capacity: "capacity";
29
+ "label-gaps": "label-gaps";
30
+ "no-raft-leader": "no-raft-leader";
31
+ "zero-agents": "zero-agents";
32
+ }>;
33
+ export type InfraAlertType = z.infer<typeof InfraAlertType>;
34
+ /** Every known alert type, in declaration order. */
35
+ export declare const INFRA_ALERT_TYPES: readonly InfraAlertType[];
36
+ /** Known alert severities, in ascending urgency. */
37
+ export declare const InfraAlertSeverity: z.ZodEnum<{
38
+ critical: "critical";
39
+ warning: "warning";
40
+ }>;
41
+ export type InfraAlertSeverity = z.infer<typeof InfraAlertSeverity>;
42
+ /**
43
+ * An alert as the Platform mints it, with both fields narrowed to the known
44
+ * vocabulary.
45
+ *
46
+ * The producer annotates its accumulator with this type, which is what turns a
47
+ * misspelled or unranked alert type into a `pnpm typecheck` failure at the mint
48
+ * site rather than a string that validates on the wire and renders as an
49
+ * unrecognised row.
50
+ */
51
+ export interface MintedInfraAlert {
52
+ type: InfraAlertType;
53
+ message: string;
54
+ severity: InfraAlertSeverity;
55
+ }
56
+ /**
57
+ * Resolve an arbitrary severity string read off the wire to a known severity.
58
+ *
59
+ * An unrecognised value resolves to `critical`. A client older than the
60
+ * Platform cannot know whether a severity it has never seen is quieter or
61
+ * louder than `critical`, and on an operator surface the safe reading of "I
62
+ * don't know" is the conspicuous one. A plain `severity === 'critical'`
63
+ * comparison instead reads every unrecognised value as a yellow warning, so a
64
+ * `critcal` typo silently downgrades a critical alert.
65
+ *
66
+ * `safeParse` is a set membership test, so an attacker-supplied
67
+ * `constructor` / `toString` cannot walk the prototype chain the way a bare
68
+ * object index would.
69
+ */
70
+ export declare function normalizeInfraAlertSeverity(severity: string): InfraAlertSeverity;
71
+ //# sourceMappingURL=infra-alert.d.ts.map
@@ -0,0 +1,60 @@
1
+ import "../rolldown-runtime-ClRpJifh.js";
2
+ import { z } from "zod";
3
+ //#region src/diagnostics/infra-alert.ts
4
+ /**
5
+ * Infrastructure alert vocabulary — the single definition of what a diagnostics
6
+ * infrastructure alert's `type` and `severity` can be.
7
+ *
8
+ * Lives beside the other shared vocabularies (`billing/plan-type.ts`,
9
+ * `context/held-run-status.ts`) rather than in the protocol module, so the
10
+ * Platform producer, the dashboard, and the `kici` CLI all name one enum
11
+ * instead of each carrying a copy. Pure Zod with no Node built-ins, so it is
12
+ * safe on the browser-facing engine barrel.
13
+ *
14
+ * This is the *known* vocabulary — the set the Platform mints alerts from and
15
+ * the set the read-side consumers colour their badges by. It is deliberately
16
+ * NOT the wire type of the response fields. The hosted Platform always runs the
17
+ * newest build, while a customer's `kici` CLI is pinned to whatever version
18
+ * they installed and hard-parses this response
19
+ * (`packages/compiler/src/remote/dashboard-client.ts`). A strict enum on the
20
+ * wire would not degrade one alert row — it would fail the whole
21
+ * `/diagnostics/infrastructure` parse and take `kici diagnostics` down with it
22
+ * the day a fifth alert type ships. So the response carries `z.string()` and
23
+ * the producer carries the enum: strict on write, permissive on read.
24
+ */
25
+ /**
26
+ * Known infrastructure alert types, matching what the Platform mints from the
27
+ * state it computes about connected orchestrators.
28
+ */
29
+ const InfraAlertType = z.enum([
30
+ "zero-agents",
31
+ "capacity",
32
+ "label-gaps",
33
+ "no-raft-leader"
34
+ ]);
35
+ /** Every known alert type, in declaration order. */
36
+ const INFRA_ALERT_TYPES = InfraAlertType.options;
37
+ /** Known alert severities, in ascending urgency. */
38
+ const InfraAlertSeverity = z.enum(["warning", "critical"]);
39
+ /**
40
+ * Resolve an arbitrary severity string read off the wire to a known severity.
41
+ *
42
+ * An unrecognised value resolves to `critical`. A client older than the
43
+ * Platform cannot know whether a severity it has never seen is quieter or
44
+ * louder than `critical`, and on an operator surface the safe reading of "I
45
+ * don't know" is the conspicuous one. A plain `severity === 'critical'`
46
+ * comparison instead reads every unrecognised value as a yellow warning, so a
47
+ * `critcal` typo silently downgrades a critical alert.
48
+ *
49
+ * `safeParse` is a set membership test, so an attacker-supplied
50
+ * `constructor` / `toString` cannot walk the prototype chain the way a bare
51
+ * object index would.
52
+ */
53
+ function normalizeInfraAlertSeverity(severity) {
54
+ const parsed = InfraAlertSeverity.safeParse(severity);
55
+ return parsed.success ? parsed.data : InfraAlertSeverity.enum.critical;
56
+ }
57
+ //#endregion
58
+ export { INFRA_ALERT_TYPES, InfraAlertSeverity, InfraAlertType, normalizeInfraAlertSeverity };
59
+
60
+ //# sourceMappingURL=infra-alert.js.map
@@ -15,7 +15,7 @@
15
15
  * This is an explicit allowlist -- anything NOT listed here is stripped.
16
16
  * Adding new variables to the host process will NOT leak them downstream.
17
17
  */
18
- export declare const ALLOWED_SYSTEM_VARS: readonly ["PATH", "HOME", "USER", "SHELL", "LANG", "LC_ALL", "TERM", "TMPDIR", "NODE_PATH", "TZ", "PATHEXT", "SystemRoot", "windir", "COMSPEC", "TEMP", "TMP", "USERPROFILE", "LOCALAPPDATA", "APPDATA", "PROCESSOR_ARCHITECTURE", "NUMBER_OF_PROCESSORS"];
18
+ export declare const ALLOWED_SYSTEM_VARS: readonly ['PATH', 'HOME', 'USER', 'SHELL', 'LANG', 'LC_ALL', 'TERM', 'TMPDIR', 'NODE_PATH', 'TZ', 'PATHEXT', 'SystemRoot', 'windir', 'COMSPEC', 'TEMP', 'TMP', 'USERPROFILE', 'LOCALAPPDATA', 'APPDATA', 'PROCESSOR_ARCHITECTURE', 'NUMBER_OF_PROCESSORS'];
19
19
  /**
20
20
  * Default environment variables injected into every sandbox execution.
21
21
  *
@@ -31,7 +31,7 @@ export declare const SANDBOX_DEFAULT_VARS: Record<string, string>;
31
31
  * These are set explicitly by the scaler (not copied from orchestrator process.env)
32
32
  * to ensure the agent receives only the values it needs with correct content.
33
33
  */
34
- export declare const AGENT_REQUIRED_KICI_VARS: readonly ["KICI_ORCHESTRATOR_URL", "KICI_AGENT_ID", "KICI_LABELS", "KICI_MAX_CONCURRENT_JOBS", "KICI_SCALER_MANAGED", "KICI_EXECUTION_MODE", "KICI_PORT"];
34
+ export declare const AGENT_REQUIRED_KICI_VARS: readonly ['KICI_ORCHESTRATOR_URL', 'KICI_AGENT_ID', 'KICI_LABELS', 'KICI_MAX_CONCURRENT_JOBS', 'KICI_SCALER_MANAGED', 'KICI_EXECUTION_MODE', 'KICI_PORT'];
35
35
  /**
36
36
  * Prefix for operator-defined environment variables that should be forwarded
37
37
  * from the orchestrator process to spawned agent processes.
@@ -41,14 +41,14 @@ export declare const AGENT_REQUIRED_KICI_VARS: readonly ["KICI_ORCHESTRATOR_URL"
41
41
  * KICI_AGENT_ENV_HTTP_PROXY=http://proxy:3128
42
42
  * -> HTTP_PROXY=http://proxy:3128 in the agent process
43
43
  */
44
- export declare const KICI_AGENT_ENV_PREFIX: "KICI_AGENT_ENV_";
44
+ export declare const KICI_AGENT_ENV_PREFIX: 'KICI_AGENT_ENV_';
45
45
  /**
46
46
  * Non-`KICI_`-prefixed environment variables that are the agent's / orchestrator's
47
47
  * own infrastructure secrets. These are scrubbed from a trusted-env passthrough
48
48
  * in addition to the whole `KICI_*` namespace, so even a trusted fleet agent
49
49
  * never leaks its control-plane credentials into a workflow step.
50
50
  */
51
- export declare const TRUSTED_ENV_SCRUB_EXACT: readonly ["DATABASE_URL", "PLATFORM_TOKEN", "WEBHOOK_SECRET", "GITHUB_PRIVATE_KEY"];
51
+ export declare const TRUSTED_ENV_SCRUB_EXACT: readonly ['DATABASE_URL', 'PLATFORM_TOKEN', 'WEBHOOK_SECRET', 'GITHUB_PRIVATE_KEY'];
52
52
  /**
53
53
  * A variable that must NEVER reach a workflow step even under the trusted-env
54
54
  * profile. The agent's entire `KICI_*` namespace (its orchestrator URL, agent
@@ -2,6 +2,18 @@ import { type MatrixValues } from '../matrix/expand.js';
2
2
  import type { LockJob } from '../trigger/types.js';
3
3
  /** Hard cap on children per fanned job — mirrors the compiler's MAX_STATIC_MATRIX_JOBS. */
4
4
  export declare const MAX_FANOUT_JOBS = 256;
5
+ /**
6
+ * Hard ceiling on the raw combination product a matrix may materialize.
7
+ *
8
+ * Distinct from {@link MAX_FANOUT_JOBS} on purpose. `MAX_FANOUT_JOBS` bounds
9
+ * the FINAL children after include/exclude and is checked after expansion;
10
+ * this bounds what may be allocated in the first place, and is checked before.
11
+ * They cannot be collapsed into one check: excludes only ever reduce the count,
12
+ * so a matrix whose raw product is 300 but which excludes down to 200 is legal
13
+ * and must keep working. The ceiling is deliberately far above any realistic
14
+ * matrix — its only job is to turn an out-of-memory kill into a typed error.
15
+ */
16
+ export declare const MAX_MATRIX_MATERIALIZATION = 100000;
5
17
  /**
6
18
  * The kind of fan-out a materialized child belongs to. `matrix` children come
7
19
  * from a matrix expansion (one per combination); `host` children come from a
@@ -139,6 +151,10 @@ export declare function fanoutEnvelopeFields(mat: MaterializedJob): {
139
151
  * (produced by the agent eval flow). Mirrors the static-matrix branch of
140
152
  * {@link materializeFanout} but takes the already-resolved combinations and
141
153
  * enforces the same cap / zero-combination guards.
154
+ *
155
+ * Duplicate combinations are refused here rather than on the agent, so the
156
+ * failure surfaces beside the zero-combination and cap errors for the same
157
+ * path.
142
158
  */
143
159
  export declare function materializeResolvedMatrix(lockJob: LockJob, combos: readonly MatrixValues[]): FanoutResult;
144
160
  /**
@@ -1,10 +1,22 @@
1
1
  import "../rolldown-runtime-ClRpJifh.js";
2
- import { applyIncludeExclude, expandMatrix } from "../matrix/expand.js";
2
+ import { MatrixShapeError, applyIncludeExclude, expandMatrix, findDuplicateCombination, matrixCombinationCount } from "../matrix/expand.js";
3
3
  import { formatExpandedJobName } from "../matrix/format.js";
4
4
  //#region src/fanout/materialize.ts
5
5
  /** Hard cap on children per fanned job — mirrors the compiler's MAX_STATIC_MATRIX_JOBS. */
6
6
  const MAX_FANOUT_JOBS = 256;
7
7
  /**
8
+ * Hard ceiling on the raw combination product a matrix may materialize.
9
+ *
10
+ * Distinct from {@link MAX_FANOUT_JOBS} on purpose. `MAX_FANOUT_JOBS` bounds
11
+ * the FINAL children after include/exclude and is checked after expansion;
12
+ * this bounds what may be allocated in the first place, and is checked before.
13
+ * They cannot be collapsed into one check: excludes only ever reduce the count,
14
+ * so a matrix whose raw product is 300 but which excludes down to 200 is legal
15
+ * and must keep working. The ceiling is deliberately far above any realistic
16
+ * matrix — its only job is to turn an out-of-memory kill into a typed error.
17
+ */
18
+ const MAX_MATRIX_MATERIALIZATION = 1e5;
19
+ /**
8
20
  * The kind of fan-out a materialized child belongs to. `matrix` children come
9
21
  * from a matrix expansion (one per combination); `host` children come from a
10
22
  * `runsOnAll` fan-out (one pinned execution per roster host).
@@ -103,10 +115,16 @@ function fanoutEnvelopeFields(mat) {
103
115
  * (produced by the agent eval flow). Mirrors the static-matrix branch of
104
116
  * {@link materializeFanout} but takes the already-resolved combinations and
105
117
  * enforces the same cap / zero-combination guards.
118
+ *
119
+ * Duplicate combinations are refused here rather than on the agent, so the
120
+ * failure surfaces beside the zero-combination and cap errors for the same
121
+ * path.
106
122
  */
107
123
  function materializeResolvedMatrix(lockJob, combos) {
108
124
  if (combos.length === 0) throw new FanoutError(lockJob.name, `dynamic matrix for job '${lockJob.name}' resolved to zero combinations`);
109
125
  if (combos.length > 256) throw new FanoutError(lockJob.name, `dynamic matrix for job '${lockJob.name}' resolved to ${combos.length} combinations (max 256)`);
126
+ const duplicate = findDuplicateCombination(combos, (c) => formatExpandedJobName(lockJob.name, c));
127
+ if (duplicate) throw new FanoutError(lockJob.name, `dynamic matrix for job '${lockJob.name}' produced duplicate combination ${JSON.stringify(duplicate)} — two children would share the expanded name '${formatExpandedJobName(lockJob.name, duplicate)}'; de-duplicate the values your matrix function returns`);
110
128
  const jobs = [];
111
129
  for (const variantValues of combos) jobs.push({
112
130
  lockJob,
@@ -197,9 +215,20 @@ function materializeFanout(staticJobs) {
197
215
  }
198
216
  const values = matrix.values;
199
217
  if (!values) throw new FanoutError(lockJob.name, `static matrix for job '${lockJob.name}' has no values`);
200
- const combos = applyIncludeExclude(expandMatrix(values), lockJob.include, lockJob.exclude);
218
+ let expanded;
219
+ try {
220
+ const rawCount = matrixCombinationCount(values);
221
+ if (rawCount > 1e5) throw new FanoutError(lockJob.name, `matrix for job '${lockJob.name}' is too large to expand: ${rawCount} raw combinations (max ${MAX_MATRIX_MATERIALIZATION})`);
222
+ expanded = expandMatrix(values);
223
+ } catch (err) {
224
+ if (err instanceof MatrixShapeError) throw new FanoutError(lockJob.name, `job '${lockJob.name}': ${err.message}`);
225
+ throw err;
226
+ }
227
+ const combos = applyIncludeExclude(expanded, lockJob.include, lockJob.exclude);
201
228
  if (combos.length === 0) throw new FanoutError(lockJob.name, `matrix for job '${lockJob.name}' expands to zero combinations`);
202
229
  if (combos.length > 256) throw new FanoutError(lockJob.name, `matrix for job '${lockJob.name}' expands to ${combos.length} combinations (max 256)`);
230
+ const duplicate = findDuplicateCombination(combos, (c) => formatExpandedJobName(lockJob.name, c));
231
+ if (duplicate) throw new FanoutError(lockJob.name, `matrix for job '${lockJob.name}' produced duplicate combination ${JSON.stringify(duplicate)} — two children would share the expanded name '${formatExpandedJobName(lockJob.name, duplicate)}'; de-duplicate the matrix values`);
203
232
  const children = combos.map((variantValues) => ({
204
233
  lockJob,
205
234
  baseName: lockJob.name,
@@ -217,6 +246,6 @@ function materializeFanout(staticJobs) {
217
246
  };
218
247
  }
219
248
  //#endregion
220
- export { FanoutCause, FanoutError, MAX_FANOUT_JOBS, VariantKind, fanoutEnvelopeFields, hostEnvelopeFields, materializeFanout, materializeResolvedHosts, materializeResolvedMatrix, matrixEnvelopeFields };
249
+ export { FanoutCause, FanoutError, MAX_FANOUT_JOBS, MAX_MATRIX_MATERIALIZATION, VariantKind, fanoutEnvelopeFields, hostEnvelopeFields, materializeFanout, materializeResolvedHosts, materializeResolvedMatrix, matrixEnvelopeFields };
221
250
 
222
251
  //# sourceMappingURL=materialize.js.map
package/dist/index.d.ts CHANGED
@@ -4,7 +4,6 @@
4
4
  * Single source of truth for shared logic used across tiers:
5
5
  * - Protocol message schemas (Zod-based, direction-specific unions)
6
6
  * - Trigger matching engine (branch, path, event evaluation)
7
- * - Execution state machine (pure function transitions)
8
7
  * - Webhook signature verification (HMAC-SHA256)
9
8
  * - WebSocket close codes (unified across all tiers)
10
9
  */
@@ -19,10 +18,12 @@ export * from './mcp/held-run-resolve.js';
19
18
  export * from './mcp/fence.js';
20
19
  export * from './protocol/messages/auth.js';
21
20
  export * from './protocol/messages/capabilities.js';
22
- export { webhookRelaySchema, webhookRelayStartSchema, webhookRelayChunkSchema, webhookAckSchema, WebhookRelayResult, WEBHOOK_RELAY_MAX_BODY_BYTES, WEBHOOK_RELAY_CHUNK_SIZE, executionEventSchema, logChunkSchema, peerDiscoverSchema, peerUpdateSchema, cacheStatsSchema, orchMetricsSchema, platformToOrchestratorMessageSchema, orchestratorToPlatformMessageSchema, type WebhookRelay, type WebhookRelayStart, type WebhookRelayChunk, type WebhookAck, type LogChunk, type PeerDiscover, type PeerUpdate, type CacheStats, type OrchMetrics, trustPolicyUpdateSchema, type TrustPolicyUpdate, staleCheckrunCleanupSchema, type StaleCheckrunCleanup, type PlatformToOrchestratorMessage, type OrchestratorToPlatformMessage, } from './protocol/messages/platform-orchestrator.js';
21
+ export { webhookRelaySchema, webhookRelayStartSchema, webhookRelayChunkSchema, webhookAckSchema, WebhookRelayResult, WEBHOOK_RELAY_MAX_BODY_BYTES, WEBHOOK_RELAY_CHUNK_SIZE, executionEventSchema, logChunkSchema, orchLogChunkSchema, OrchLogPhase, peerDiscoverSchema, peerUpdateSchema, cacheStatsSchema, orchMetricsSchema, platformToOrchestratorMessageSchema, orchestratorToPlatformMessageSchema, collectDiscriminatorTypes, ORCH_TO_PLATFORM_RECOGNIZED_TYPES, PLATFORM_TO_ORCH_RECOGNIZED_TYPES, type WebhookRelay, type WebhookRelayStart, type WebhookRelayChunk, type WebhookAck, type LogChunk, type OrchLogChunk, type PeerDiscover, type PeerUpdate, type CacheStats, type OrchMetrics, DEFAULT_APPROVAL_EXPIRY_HOURS, trustPolicySchema, type TrustPolicy, trustPolicyUpdateSchema, type TrustPolicyUpdate, staleCheckrunCleanupSchema, type StaleCheckrunCleanup, platformCapabilitiesMessageSchema, type PlatformCapabilitiesMessage, type PlatformToOrchestratorMessage, type OrchestratorToPlatformMessage, } from './protocol/messages/platform-orchestrator.js';
23
22
  export * from './protocol/messages/execution-status.js';
23
+ export * from './status/presentation.js';
24
24
  export * from './protocol/messages/agent-run-result.js';
25
25
  export * from './protocol/messages/agent-dev-ops.js';
26
+ export * from './protocol/messages/heartbeat-health.js';
26
27
  export * from './dev-ops/operations.js';
27
28
  export * from './protocol/messages/deployment-identity.js';
28
29
  export * from './protocol/messages/scaler-event.js';
@@ -37,18 +38,22 @@ export * from './protocol/messages/dashboard.js';
37
38
  export * from './protocol/event-log-payload.js';
38
39
  export * from './protocol/messages/browser.js';
39
40
  export * from './protocol/messages/run-events.js';
40
- export { sourceRegistrationSchema, sourceRegistrationAckSchema, sourceDeregisterSchema, sourceDeregisterAckSchema, SourceSubtype, SourceProvider, type SourceRegistration, type SourceRegistrationAck, type SourceDeregister, type SourceDeregisterAck, } from './protocol/messages/source-registration.js';
41
+ export { sourceRegistrationSchema, sourceRegistrationAckSchema, sourceDeregisterSchema, sourceDeregisterAckSchema, SourceSubtype, SourceProvider, OrchestratorMode, PLATFORM_CONNECTED_MODES, RELAY_INGRESS_MODES, OWN_INGRESS_MODES, type SourceRegistration, type SourceRegistrationAck, type SourceDeregister, type SourceDeregisterAck, } from './protocol/messages/source-registration.js';
41
42
  export * from './protocol/messages/join.js';
42
43
  export * from './protocol/messages/peer.js';
44
+ export * from './protocol/messages/log-stream.js';
43
45
  export * from './protocol/messages/orchestrator-agent.js';
46
+ export * from './sandbox/capabilities.js';
44
47
  export * from './trigger/types.js';
45
48
  export * from './trigger/trigger-event-type.js';
46
49
  export * from './trigger/decision-trace.js';
47
50
  export * from './trigger/matcher.js';
51
+ export * from './trigger/event-buckets.js';
52
+ export { scheduleTriggerKey } from './trigger/schedule-key.js';
48
53
  export * from './inputs/index.js';
49
- export * from './state-machine/index.js';
50
54
  export * from './provider/index.js';
51
55
  export { githubWebhookPath, githubIngressPath } from './webhook/webhook-url-format.js';
56
+ export { PING_EVENT_TYPE, SUBSCRIBABLE_WEBHOOK_EVENT_TYPES, SubscribableWebhookEventType, WebhookEventType, } from './webhook/event-types.js';
52
57
  export type { WsLike } from './ws/ws-like.js';
53
58
  export * from './ws/close-codes.js';
54
59
  export { WsRateLimiter } from './ws/rate-limiter.js';
@@ -56,17 +61,21 @@ export type { RateLimiterConfig, RateLimitResult } from './ws/rate-limiter.js';
56
61
  export * from './env/environment-allowlist.js';
57
62
  export * from './secrets/index.js';
58
63
  export * from './context/index.js';
59
- export { deriveOsArchLabels, hostLabel, parseHostLabel, HOST_LABEL_PREFIX, agentTypeLabel, scalerLabel, mergeAutoLabels, normalizeRunsOn, KNOWN_ROLES, resolveRoleLabels, validateNoReservedLabels, scalerAgentLabels, isSelfReportedLabel, SELF_REPORTED_LABEL_PREFIXES, CAPABILITY_LABEL_PREFIX, capabilityLabel, SSH_TRANSPORT_CAPABILITY, INIT_LABEL, PRIVILEGED_ROOT_LABEL, } from './labels.js';
64
+ export { deriveOsArchLabels, derivePlatformTaints, PLATFORM_TAINT_LABELS, ScalerOs, ScalerArch, scalerPlatformSchema, platformToOsArchLabels, platformToTaints, nodePlatformToScalerOs, nodeArchToScalerArch, hostToScalerPlatform, hostLabel, parseHostLabel, HOST_LABEL_PREFIX, agentTypeLabel, scalerLabel, mergeAutoLabels, normalizeRunsOn, KNOWN_ROLES, resolveRoleLabels, validateNoReservedLabels, scalerAgentLabels, isSelfReportedLabel, SELF_REPORTED_LABEL_PREFIXES, CAPABILITY_LABEL_PREFIX, capabilityLabel, SSH_TRANSPORT_CAPABILITY, INIT_LABEL, PRIVILEGED_ROOT_LABEL, } from './labels.js';
60
65
  export type { NormalizedRunsOn } from './labels.js';
61
66
  export type { AgentRole } from './labels.js';
67
+ export type { ScalerPlatform } from './labels.js';
62
68
  export { LabelMatcher, matcherMatches, matcherSatisfiedBy, partitionMatchers, compileRegexMatcher, HostTargetValue, HostTargetSelector, hostSatisfiesTarget, } from './labels-match.js';
63
69
  export * from './inventory.js';
64
70
  export * from './scaler/scaler-backend-type.js';
65
71
  export * from './scaler/resource-types.js';
66
72
  export * from './registration/registerable-trigger-type.js';
67
73
  export * from './bundler/index.js';
68
- export { expandSingleDimension, expandMultiDimension, expandMatrix, applyIncludeExclude, type StaticMatrixArray, type StaticMatrixObject, type MatrixInclude, type MatrixExclude, type MatrixValues, } from './matrix/expand.js';
74
+ export { expandSingleDimension, expandMultiDimension, expandMatrix, applyIncludeExclude, normalizeMatrixInput, matrixCombinationCount, findDuplicateCombination, MatrixShapeError, type NormalizedMatrix, type StaticMatrixArray, type StaticMatrixObject, type MatrixInclude, type MatrixExclude, type MatrixValues, } from './matrix/expand.js';
69
75
  export { formatMatrixSuffix, formatExpandedJobName } from './matrix/format.js';
70
76
  export * from './fanout/materialize.js';
71
77
  export * from './check-mode.js';
78
+ export * from './artifacts/name.js';
79
+ export * from './billing/plan-type.js';
80
+ export * from './diagnostics/infra-alert.js';
72
81
  //# sourceMappingURL=index.d.ts.map