@kici-dev/engine 0.1.3 → 0.1.6

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.
@@ -177,7 +177,21 @@ export declare const staleCheckrunCleanupSchema: z.ZodObject<{
177
177
  }, z.core.$strip>>;
178
178
  }, z.core.$strip>;
179
179
  export type StaleCheckrunCleanup = z.infer<typeof staleCheckrunCleanupSchema>;
180
- /** Periodic OTel metrics push from orchestrator to Platform for centralized observability. */
180
+ /**
181
+ * Periodic OTel metrics push from orchestrator to Platform for centralized observability.
182
+ *
183
+ * Schema bounds are the first line of defence against pollution of the
184
+ * Platform's monitoring system: a malformed or hostile push fails Zod
185
+ * parse at the WS edge and never reaches the aggregator or the Mimir
186
+ * relay. The content-level allow-list (catalog) is enforced one step
187
+ * deeper — see `packages/platform/src/ws/metrics-filter.ts`.
188
+ *
189
+ * Caps:
190
+ * - 2000 metric data points per push (one orch ships ~60 today)
191
+ * - 128-char metric name, 64-char label key, 256-char label value
192
+ * - 15 labels per series (KiCI metrics carry ~5 today)
193
+ * - 30 explicit histogram buckets (largest histogram has 9 boundaries)
194
+ */
181
195
  export declare const orchMetricsSchema: z.ZodObject<{
182
196
  type: z.ZodLiteral<"orch.metrics">;
183
197
  messageId: z.ZodString;
@@ -255,6 +269,50 @@ export declare const cacheStatsSchema: z.ZodObject<{
255
269
  hit: z.ZodBoolean;
256
270
  }, z.core.$strip>;
257
271
  export type CacheStats = z.infer<typeof cacheStatsSchema>;
272
+ /**
273
+ * Runtime broadcast of an updated dashboard-write policy. Carries the
274
+ * orch's full capabilities object (same shape as `orchCapabilitiesSchema`
275
+ * via `auth.request`) so Platform's per-org cache can be replaced
276
+ * wholesale rather than merged. Emitted by the orch whenever an
277
+ * operator flips a switch via `kici-admin org-settings dashboard-writes`;
278
+ * Platform receives it, updates its cache, and re-broadcasts the
279
+ * relevant subset to any connected dashboard SPA sessions.
280
+ */
281
+ export declare const orchCapabilitiesUpdateSchema: z.ZodObject<{
282
+ type: z.ZodLiteral<"orch.capabilities.update">;
283
+ capabilities: z.ZodObject<{
284
+ orchRole: z.ZodOptional<z.ZodEnum<{
285
+ coordinator: "coordinator";
286
+ worker: "worker";
287
+ }>>;
288
+ dashboardWrites: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
289
+ "secrets.set": "secrets.set";
290
+ "secrets.delete": "secrets.delete";
291
+ "secrets.scope.create": "secrets.scope.create";
292
+ "secrets.scope.rename": "secrets.scope.rename";
293
+ "secrets.scope.delete": "secrets.scope.delete";
294
+ "variables.set": "variables.set";
295
+ "variables.delete": "variables.delete";
296
+ "environments.create": "environments.create";
297
+ "environments.update": "environments.update";
298
+ "environments.delete": "environments.delete";
299
+ "environments.bindings.set": "environments.bindings.set";
300
+ "environments.source_overrides.set": "environments.source_overrides.set";
301
+ "environments.source_overrides.delete": "environments.source_overrides.delete";
302
+ "held_runs.approve": "held_runs.approve";
303
+ "held_runs.reject": "held_runs.reject";
304
+ "event_dlq.retry": "event_dlq.retry";
305
+ "event_dlq.discard": "event_dlq.discard";
306
+ "registration.disable": "registration.disable";
307
+ "registration.delete": "registration.delete";
308
+ "global_workflows.update": "global_workflows.update";
309
+ "backends.sync": "backends.sync";
310
+ "backends.sync_one": "backends.sync_one";
311
+ "backends.test": "backends.test";
312
+ }> & z.core.$partial, z.ZodBoolean>>;
313
+ }, z.core.$loose>;
314
+ }, z.core.$strip>;
315
+ export type OrchCapabilitiesUpdate = z.infer<typeof orchCapabilitiesUpdateSchema>;
258
316
  /** All messages that flow from Platform to Orchestrator.
259
317
  *
260
318
  * The single-frame `webhookRelaySchema` is intentionally NOT a member of this
@@ -321,7 +379,10 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
321
379
  }, z.core.$strip>, z.ZodObject<{
322
380
  type: z.ZodLiteral<"source.register.ack">;
323
381
  messageId: z.ZodString;
324
- accepted: z.ZodArray<z.ZodString>;
382
+ accepted: z.ZodArray<z.ZodObject<{
383
+ routingKey: z.ZodString;
384
+ webhookUrl: z.ZodNullable<z.ZodString>;
385
+ }, z.core.$strip>>;
325
386
  rejected: z.ZodArray<z.ZodObject<{
326
387
  routingKey: z.ZodString;
327
388
  reason: z.ZodString;
@@ -1424,6 +1485,98 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1424
1485
  orgId: z.ZodString;
1425
1486
  deliveryId: z.ZodString;
1426
1487
  routingKey: z.ZodOptional<z.ZodString>;
1488
+ }, z.core.$strip>, z.ZodObject<{
1489
+ type: z.ZodLiteral<"dashboard.event-dlq.list">;
1490
+ requestId: z.ZodString;
1491
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1492
+ type: z.ZodLiteral<"user">;
1493
+ sub: z.ZodString;
1494
+ }, z.core.$strip>, z.ZodObject<{
1495
+ type: z.ZodLiteral<"api_key">;
1496
+ keyId: z.ZodString;
1497
+ ownerSub: z.ZodString;
1498
+ }, z.core.$strip>, z.ZodObject<{
1499
+ type: z.ZodLiteral<"service_account">;
1500
+ id: z.ZodString;
1501
+ }, z.core.$strip>, z.ZodObject<{
1502
+ type: z.ZodLiteral<"platform_operator">;
1503
+ sub: z.ZodString;
1504
+ reason: z.ZodString;
1505
+ }, z.core.$strip>, z.ZodObject<{
1506
+ type: z.ZodLiteral<"system">;
1507
+ component: z.ZodString;
1508
+ }, z.core.$strip>], "type">;
1509
+ orgId: z.ZodString;
1510
+ limit: z.ZodOptional<z.ZodNumber>;
1511
+ before: z.ZodOptional<z.ZodString>;
1512
+ }, z.core.$strip>, z.ZodObject<{
1513
+ type: z.ZodLiteral<"dashboard.event-dlq.count">;
1514
+ requestId: z.ZodString;
1515
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1516
+ type: z.ZodLiteral<"user">;
1517
+ sub: z.ZodString;
1518
+ }, z.core.$strip>, z.ZodObject<{
1519
+ type: z.ZodLiteral<"api_key">;
1520
+ keyId: z.ZodString;
1521
+ ownerSub: z.ZodString;
1522
+ }, z.core.$strip>, z.ZodObject<{
1523
+ type: z.ZodLiteral<"service_account">;
1524
+ id: z.ZodString;
1525
+ }, z.core.$strip>, z.ZodObject<{
1526
+ type: z.ZodLiteral<"platform_operator">;
1527
+ sub: z.ZodString;
1528
+ reason: z.ZodString;
1529
+ }, z.core.$strip>, z.ZodObject<{
1530
+ type: z.ZodLiteral<"system">;
1531
+ component: z.ZodString;
1532
+ }, z.core.$strip>], "type">;
1533
+ orgId: z.ZodString;
1534
+ }, z.core.$strip>, z.ZodObject<{
1535
+ type: z.ZodLiteral<"dashboard.event-dlq.retry">;
1536
+ requestId: z.ZodString;
1537
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1538
+ type: z.ZodLiteral<"user">;
1539
+ sub: z.ZodString;
1540
+ }, z.core.$strip>, z.ZodObject<{
1541
+ type: z.ZodLiteral<"api_key">;
1542
+ keyId: z.ZodString;
1543
+ ownerSub: z.ZodString;
1544
+ }, z.core.$strip>, z.ZodObject<{
1545
+ type: z.ZodLiteral<"service_account">;
1546
+ id: z.ZodString;
1547
+ }, z.core.$strip>, z.ZodObject<{
1548
+ type: z.ZodLiteral<"platform_operator">;
1549
+ sub: z.ZodString;
1550
+ reason: z.ZodString;
1551
+ }, z.core.$strip>, z.ZodObject<{
1552
+ type: z.ZodLiteral<"system">;
1553
+ component: z.ZodString;
1554
+ }, z.core.$strip>], "type">;
1555
+ orgId: z.ZodString;
1556
+ eventId: z.ZodString;
1557
+ }, z.core.$strip>, z.ZodObject<{
1558
+ type: z.ZodLiteral<"dashboard.event-dlq.discard">;
1559
+ requestId: z.ZodString;
1560
+ actor: z.ZodDiscriminatedUnion<[z.ZodObject<{
1561
+ type: z.ZodLiteral<"user">;
1562
+ sub: z.ZodString;
1563
+ }, z.core.$strip>, z.ZodObject<{
1564
+ type: z.ZodLiteral<"api_key">;
1565
+ keyId: z.ZodString;
1566
+ ownerSub: z.ZodString;
1567
+ }, z.core.$strip>, z.ZodObject<{
1568
+ type: z.ZodLiteral<"service_account">;
1569
+ id: z.ZodString;
1570
+ }, z.core.$strip>, z.ZodObject<{
1571
+ type: z.ZodLiteral<"platform_operator">;
1572
+ sub: z.ZodString;
1573
+ reason: z.ZodString;
1574
+ }, z.core.$strip>, z.ZodObject<{
1575
+ type: z.ZodLiteral<"system">;
1576
+ component: z.ZodString;
1577
+ }, z.core.$strip>], "type">;
1578
+ orgId: z.ZodString;
1579
+ eventId: z.ZodString;
1427
1580
  }, z.core.$strip>, z.ZodObject<{
1428
1581
  type: z.ZodLiteral<"dashboard.global-workflows.get">;
1429
1582
  requestId: z.ZodString;
@@ -1510,6 +1663,11 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1510
1663
  }>>;
1511
1664
  actorId: z.ZodOptional<z.ZodString>;
1512
1665
  action: z.ZodOptional<z.ZodEnum<{
1666
+ "event_dlq.retry": "event_dlq.retry";
1667
+ "event_dlq.discard": "event_dlq.discard";
1668
+ "registration.disable": "registration.disable";
1669
+ "registration.delete": "registration.delete";
1670
+ "global_workflows.update": "global_workflows.update";
1513
1671
  "run.detail.read": "run.detail.read";
1514
1672
  "run.payload.read": "run.payload.read";
1515
1673
  "run.orch_logs.read": "run.orch_logs.read";
@@ -1546,8 +1704,6 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1546
1704
  "held_run.approve": "held_run.approve";
1547
1705
  "held_run.reject": "held_run.reject";
1548
1706
  "registration.list.read": "registration.list.read";
1549
- "registration.disable": "registration.disable";
1550
- "registration.delete": "registration.delete";
1551
1707
  "diagnostics.read": "diagnostics.read";
1552
1708
  "scaler.capacity.read": "scaler.capacity.read";
1553
1709
  "scaler.agents.read": "scaler.agents.read";
@@ -1557,12 +1713,12 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1557
1713
  "backend.sync.one": "backend.sync.one";
1558
1714
  "backend.test": "backend.test";
1559
1715
  "global_workflows.get.read": "global_workflows.get.read";
1560
- "global_workflows.update": "global_workflows.update";
1716
+ "org_settings.dashboard_write_policy.update": "org_settings.dashboard_write_policy.update";
1717
+ "cluster_name.update": "cluster_name.update";
1561
1718
  "access_log.list.read": "access_log.list.read";
1562
1719
  "event_dlq.list.read": "event_dlq.list.read";
1563
- "event_dlq.retry": "event_dlq.retry";
1564
- "event_dlq.discard": "event_dlq.discard";
1565
1720
  archive_chunk: "archive_chunk";
1721
+ purge_chunk: "purge_chunk";
1566
1722
  }>>;
1567
1723
  source: z.ZodOptional<z.ZodEnum<{
1568
1724
  platform_proxy: "platform_proxy";
@@ -1590,6 +1746,8 @@ export declare const platformToOrchestratorMessageSchema: z.ZodDiscriminatedUnio
1590
1746
  held_run: "held_run";
1591
1747
  access_log: "access_log";
1592
1748
  event_dlq: "event_dlq";
1749
+ org_settings: "org_settings";
1750
+ cluster_meta: "cluster_meta";
1593
1751
  }>>;
1594
1752
  targetId: z.ZodOptional<z.ZodString>;
1595
1753
  fromTimestamp: z.ZodOptional<z.ZodString>;
@@ -1751,6 +1909,39 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
1751
1909
  }, z.core.$strip>>;
1752
1910
  }, z.core.$strip>>;
1753
1911
  timestamp: z.ZodNumber;
1912
+ }, z.core.$strip>, z.ZodObject<{
1913
+ type: z.ZodLiteral<"orch.capabilities.update">;
1914
+ capabilities: z.ZodObject<{
1915
+ orchRole: z.ZodOptional<z.ZodEnum<{
1916
+ coordinator: "coordinator";
1917
+ worker: "worker";
1918
+ }>>;
1919
+ dashboardWrites: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
1920
+ "secrets.set": "secrets.set";
1921
+ "secrets.delete": "secrets.delete";
1922
+ "secrets.scope.create": "secrets.scope.create";
1923
+ "secrets.scope.rename": "secrets.scope.rename";
1924
+ "secrets.scope.delete": "secrets.scope.delete";
1925
+ "variables.set": "variables.set";
1926
+ "variables.delete": "variables.delete";
1927
+ "environments.create": "environments.create";
1928
+ "environments.update": "environments.update";
1929
+ "environments.delete": "environments.delete";
1930
+ "environments.bindings.set": "environments.bindings.set";
1931
+ "environments.source_overrides.set": "environments.source_overrides.set";
1932
+ "environments.source_overrides.delete": "environments.source_overrides.delete";
1933
+ "held_runs.approve": "held_runs.approve";
1934
+ "held_runs.reject": "held_runs.reject";
1935
+ "event_dlq.retry": "event_dlq.retry";
1936
+ "event_dlq.discard": "event_dlq.discard";
1937
+ "registration.disable": "registration.disable";
1938
+ "registration.delete": "registration.delete";
1939
+ "global_workflows.update": "global_workflows.update";
1940
+ "backends.sync": "backends.sync";
1941
+ "backends.sync_one": "backends.sync_one";
1942
+ "backends.test": "backends.test";
1943
+ }> & z.core.$partial, z.ZodBoolean>>;
1944
+ }, z.core.$loose>;
1754
1945
  }, z.core.$strip>, z.ZodObject<{
1755
1946
  type: z.ZodLiteral<"source.register">;
1756
1947
  messageId: z.ZodString;
@@ -1771,6 +1962,8 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
1771
1962
  }>;
1772
1963
  }, z.core.$strip>>;
1773
1964
  instanceId: z.ZodOptional<z.ZodString>;
1965
+ clusterName: z.ZodOptional<z.ZodString>;
1966
+ clusterId: z.ZodOptional<z.ZodString>;
1774
1967
  address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1775
1968
  version: z.ZodOptional<z.ZodString>;
1776
1969
  mode: z.ZodOptional<z.ZodEnum<{
@@ -1801,6 +1994,31 @@ export declare const orchestratorToPlatformMessageSchema: z.ZodDiscriminatedUnio
1801
1994
  coordinator: "coordinator";
1802
1995
  worker: "worker";
1803
1996
  }>>;
1997
+ dashboardWrites: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
1998
+ "secrets.set": "secrets.set";
1999
+ "secrets.delete": "secrets.delete";
2000
+ "secrets.scope.create": "secrets.scope.create";
2001
+ "secrets.scope.rename": "secrets.scope.rename";
2002
+ "secrets.scope.delete": "secrets.scope.delete";
2003
+ "variables.set": "variables.set";
2004
+ "variables.delete": "variables.delete";
2005
+ "environments.create": "environments.create";
2006
+ "environments.update": "environments.update";
2007
+ "environments.delete": "environments.delete";
2008
+ "environments.bindings.set": "environments.bindings.set";
2009
+ "environments.source_overrides.set": "environments.source_overrides.set";
2010
+ "environments.source_overrides.delete": "environments.source_overrides.delete";
2011
+ "held_runs.approve": "held_runs.approve";
2012
+ "held_runs.reject": "held_runs.reject";
2013
+ "event_dlq.retry": "event_dlq.retry";
2014
+ "event_dlq.discard": "event_dlq.discard";
2015
+ "registration.disable": "registration.disable";
2016
+ "registration.delete": "registration.delete";
2017
+ "global_workflows.update": "global_workflows.update";
2018
+ "backends.sync": "backends.sync";
2019
+ "backends.sync_one": "backends.sync_one";
2020
+ "backends.test": "backends.test";
2021
+ }> & z.core.$partial, z.ZodBoolean>>;
1804
2022
  }, z.core.$loose>>;
1805
2023
  }, z.core.$strip>, z.ZodObject<{
1806
2024
  type: z.ZodLiteral<"heartbeat">;
@@ -1,12 +1,13 @@
1
1
  import "../../chunk-gOLHoazu.js";
2
2
  import { heartbeatSchema } from "./common.js";
3
+ import { orchCapabilitiesSchema } from "./capabilities.js";
3
4
  import { authFailureSchema, authRequestSchema, authSuccessSchema } from "./auth.js";
4
5
  import { executionStatusSchema, jobStatusForwardSchema, stateReplaySchema, stepStatusForwardSchema } from "./execution-status.js";
5
6
  import { sourceDeregisterAckSchema, sourceDeregisterSchema, sourceRegistrationAckSchema, sourceRegistrationSchema } from "./source-registration.js";
6
7
  import { dashboardAccessLogListRequestSchema } from "./access-log.js";
7
8
  import { dashboardOrchLogsRequestSchema, jobContextMessageSchema, runEventMessageSchema } from "./run-events.js";
8
9
  import { globalWorkflowsGetRequestSchema, globalWorkflowsUpdateRequestSchema } from "./dashboard-global-workflows.js";
9
- import { backendGetRequestSchema, backendSyncRequestSchema, backendTestRequestSchema, backendsListRequestSchema, backendsSyncAllRequestSchema, dashboardDiagnosticsRequestSchema, dashboardEventLogDetailRequestSchema, dashboardEventLogListRequestSchema, dashboardEventLogPayloadStreamRequestSchema, dashboardPayloadRequestSchema, dashboardRunDetailRequestSchema, dashboardScalerAgentsRequestSchema, dashboardScalerCapacityRequestSchema, dashboardStepLogsRequestSchema, envBindingsListRequestSchema, envBindingsSetRequestSchema, envCreateRequestSchema, envDeleteRequestSchema, envGetRequestSchema, envHistoryRequestSchema, envListRequestSchema, envSecretDeleteRequestSchema, envSecretScopeCreateRequestSchema, envSecretScopeDeleteRequestSchema, envSecretScopeRenameRequestSchema, envSecretSetRequestSchema, envSecretsListRequestSchema, envSourceOverrideDeleteRequestSchema, envSourceOverrideSetRequestSchema, envSourceOverridesListRequestSchema, envUpdateRequestSchema, envVarDeleteRequestSchema, envVarSetRequestSchema, envVarsListRequestSchema, heldRunApproveRequestSchema, heldRunRejectRequestSchema, heldRunsListRequestSchema, manualScheduleRequestSchema, registrationDeleteRequestSchema, registrationDisableRequestSchema, registrationsListRequestSchema, runCancelRequestSchema, runRerunRequestSchema } from "./dashboard.js";
10
+ import { backendGetRequestSchema, backendSyncRequestSchema, backendTestRequestSchema, backendsListRequestSchema, backendsSyncAllRequestSchema, dashboardDiagnosticsRequestSchema, dashboardEventDlqCountRequestSchema, dashboardEventDlqDiscardRequestSchema, dashboardEventDlqListRequestSchema, dashboardEventDlqRetryRequestSchema, dashboardEventLogDetailRequestSchema, dashboardEventLogListRequestSchema, dashboardEventLogPayloadStreamRequestSchema, dashboardPayloadRequestSchema, dashboardRunDetailRequestSchema, dashboardScalerAgentsRequestSchema, dashboardScalerCapacityRequestSchema, dashboardStepLogsRequestSchema, envBindingsListRequestSchema, envBindingsSetRequestSchema, envCreateRequestSchema, envDeleteRequestSchema, envGetRequestSchema, envHistoryRequestSchema, envListRequestSchema, envSecretDeleteRequestSchema, envSecretScopeCreateRequestSchema, envSecretScopeDeleteRequestSchema, envSecretScopeRenameRequestSchema, envSecretSetRequestSchema, envSecretsListRequestSchema, envSourceOverrideDeleteRequestSchema, envSourceOverrideSetRequestSchema, envSourceOverridesListRequestSchema, envUpdateRequestSchema, envVarDeleteRequestSchema, envVarSetRequestSchema, envVarsListRequestSchema, heldRunApproveRequestSchema, heldRunRejectRequestSchema, heldRunsListRequestSchema, manualScheduleRequestSchema, registrationDeleteRequestSchema, registrationDisableRequestSchema, registrationsListRequestSchema, runCancelRequestSchema, runRerunRequestSchema } from "./dashboard.js";
10
11
  import { z } from "zod";
11
12
  //#region src/protocol/messages/platform-orchestrator.ts
12
13
  /** Trust policy update pushed from Platform to orchestrator when policy or identity links change. */
@@ -203,12 +204,26 @@ const staleCheckrunCleanupSchema = z.object({
203
204
  jobNames: z.array(z.string())
204
205
  }))
205
206
  });
206
- /** Periodic OTel metrics push from orchestrator to Platform for centralized observability. */
207
+ /**
208
+ * Periodic OTel metrics push from orchestrator to Platform for centralized observability.
209
+ *
210
+ * Schema bounds are the first line of defence against pollution of the
211
+ * Platform's monitoring system: a malformed or hostile push fails Zod
212
+ * parse at the WS edge and never reaches the aggregator or the Mimir
213
+ * relay. The content-level allow-list (catalog) is enforced one step
214
+ * deeper — see `packages/platform/src/ws/metrics-filter.ts`.
215
+ *
216
+ * Caps:
217
+ * - 2000 metric data points per push (one orch ships ~60 today)
218
+ * - 128-char metric name, 64-char label key, 256-char label value
219
+ * - 15 labels per series (KiCI metrics carry ~5 today)
220
+ * - 30 explicit histogram buckets (largest histogram has 9 boundaries)
221
+ */
207
222
  const orchMetricsSchema = z.object({
208
223
  type: z.literal("orch.metrics"),
209
- messageId: z.string(),
224
+ messageId: z.string().max(128),
210
225
  metrics: z.array(z.object({
211
- name: z.string(),
226
+ name: z.string().min(1).max(128),
212
227
  type: z.enum([
213
228
  "counter",
214
229
  "histogram",
@@ -216,14 +231,14 @@ const orchMetricsSchema = z.object({
216
231
  "upDownCounter"
217
232
  ]),
218
233
  value: z.number().optional(),
219
- labels: z.record(z.string(), z.string()).optional(),
234
+ labels: z.record(z.string().max(64), z.string().max(256)).refine((m) => Object.keys(m).length <= 15, { message: "metric carries more than 15 labels" }).optional(),
220
235
  buckets: z.array(z.object({
221
236
  le: z.number(),
222
237
  count: z.number()
223
- })).optional(),
238
+ })).max(30).optional(),
224
239
  count: z.number().optional(),
225
240
  sum: z.number().optional()
226
- })),
241
+ })).max(2e3),
227
242
  timestamp: z.number()
228
243
  });
229
244
  /**
@@ -279,6 +294,19 @@ const cacheStatsSchema = z.object({
279
294
  cacheType: z.enum(["source", "dep"]),
280
295
  hit: z.boolean()
281
296
  });
297
+ /**
298
+ * Runtime broadcast of an updated dashboard-write policy. Carries the
299
+ * orch's full capabilities object (same shape as `orchCapabilitiesSchema`
300
+ * via `auth.request`) so Platform's per-org cache can be replaced
301
+ * wholesale rather than merged. Emitted by the orch whenever an
302
+ * operator flips a switch via `kici-admin org-settings dashboard-writes`;
303
+ * Platform receives it, updates its cache, and re-broadcasts the
304
+ * relevant subset to any connected dashboard SPA sessions.
305
+ */
306
+ const orchCapabilitiesUpdateSchema = z.object({
307
+ type: z.literal("orch.capabilities.update"),
308
+ capabilities: orchCapabilitiesSchema
309
+ });
282
310
  /** All messages that flow from Platform to Orchestrator.
283
311
  *
284
312
  * The single-frame `webhookRelaySchema` is intentionally NOT a member of this
@@ -345,6 +373,10 @@ const platformToOrchestratorMessageSchema = z.discriminatedUnion("type", [
345
373
  dashboardEventLogListRequestSchema,
346
374
  dashboardEventLogDetailRequestSchema,
347
375
  dashboardEventLogPayloadStreamRequestSchema,
376
+ dashboardEventDlqListRequestSchema,
377
+ dashboardEventDlqCountRequestSchema,
378
+ dashboardEventDlqRetryRequestSchema,
379
+ dashboardEventDlqDiscardRequestSchema,
348
380
  globalWorkflowsGetRequestSchema,
349
381
  globalWorkflowsUpdateRequestSchema,
350
382
  dashboardAccessLogListRequestSchema
@@ -364,6 +396,7 @@ const orchestratorToPlatformMessageSchema = z.discriminatedUnion("type", [
364
396
  stepStatusForwardSchema,
365
397
  jobStatusForwardSchema,
366
398
  stateReplaySchema,
399
+ orchCapabilitiesUpdateSchema,
367
400
  sourceRegistrationSchema,
368
401
  sourceDeregisterSchema,
369
402
  cacheStatsSchema,
@@ -374,6 +407,6 @@ const orchestratorToPlatformMessageSchema = z.discriminatedUnion("type", [
374
407
  orchMetricsSchema
375
408
  ]);
376
409
  //#endregion
377
- export { WEBHOOK_RELAY_CHUNK_SIZE, WEBHOOK_RELAY_MAX_BODY_BYTES, WebhookRelayResult, cacheStatsSchema, executionEventSchema, logChunkSchema, orchMetricsSchema, orchestratorToPlatformMessageSchema, peerDiscoverSchema, peerUpdateSchema, platformToOrchestratorMessageSchema, staleCheckrunCleanupSchema, trustPolicyUpdateSchema, webhookAckSchema, webhookRelayChunkSchema, webhookRelaySchema, webhookRelayStartSchema };
410
+ export { WEBHOOK_RELAY_CHUNK_SIZE, WEBHOOK_RELAY_MAX_BODY_BYTES, WebhookRelayResult, cacheStatsSchema, executionEventSchema, logChunkSchema, orchCapabilitiesUpdateSchema, orchMetricsSchema, orchestratorToPlatformMessageSchema, peerDiscoverSchema, peerUpdateSchema, platformToOrchestratorMessageSchema, staleCheckrunCleanupSchema, trustPolicyUpdateSchema, webhookAckSchema, webhookRelayChunkSchema, webhookRelaySchema, webhookRelayStartSchema };
378
411
 
379
412
  //# sourceMappingURL=platform-orchestrator.js.map
@@ -57,6 +57,8 @@ export declare const sourceRegistrationSchema: z.ZodObject<{
57
57
  }>;
58
58
  }, z.core.$strip>>;
59
59
  instanceId: z.ZodOptional<z.ZodString>;
60
+ clusterName: z.ZodOptional<z.ZodString>;
61
+ clusterId: z.ZodOptional<z.ZodString>;
60
62
  address: z.ZodOptional<z.ZodNullable<z.ZodString>>;
61
63
  version: z.ZodOptional<z.ZodString>;
62
64
  mode: z.ZodOptional<z.ZodEnum<{
@@ -68,11 +70,27 @@ export declare const sourceRegistrationSchema: z.ZodObject<{
68
70
  s3LogAccess: z.ZodOptional<z.ZodBoolean>;
69
71
  queueTimeoutMs: z.ZodOptional<z.ZodNumber>;
70
72
  }, z.core.$strip>;
73
+ /**
74
+ * One accepted source in a {@link sourceRegistrationAckSchema}. Carries the
75
+ * public webhook URL the Platform computed for this routing key so the
76
+ * orchestrator (which only knows its org *alias*, never the canonical org id)
77
+ * can surface it to the operator — e.g. `kici-admin source add` printing the
78
+ * URL to paste into a GitHub App. `webhookUrl` is null when the Platform has
79
+ * no public webhook base configured (`config.webhookPublicUrl` unset).
80
+ */
81
+ export declare const acceptedSourceSchema: z.ZodObject<{
82
+ routingKey: z.ZodString;
83
+ webhookUrl: z.ZodNullable<z.ZodString>;
84
+ }, z.core.$strip>;
85
+ export type AcceptedSource = z.infer<typeof acceptedSourceSchema>;
71
86
  /** Platform acknowledgment of source registration. */
72
87
  export declare const sourceRegistrationAckSchema: z.ZodObject<{
73
88
  type: z.ZodLiteral<"source.register.ack">;
74
89
  messageId: z.ZodString;
75
- accepted: z.ZodArray<z.ZodString>;
90
+ accepted: z.ZodArray<z.ZodObject<{
91
+ routingKey: z.ZodString;
92
+ webhookUrl: z.ZodNullable<z.ZodString>;
93
+ }, z.core.$strip>>;
76
94
  rejected: z.ZodArray<z.ZodObject<{
77
95
  routingKey: z.ZodString;
78
96
  reason: z.ZodString;
@@ -57,6 +57,27 @@ const sourceRegistrationSchema = z.object({
57
57
  })),
58
58
  /** Orchestrator cluster instance ID for peer correlation. */
59
59
  instanceId: z.string().optional(),
60
+ /**
61
+ * Human-friendly cluster name resolved on orch boot (`cluster_meta.cluster_name`).
62
+ * Used by Platform to populate the per-orch dashboard URL segment
63
+ * (`/orgs/:cId/orchestrators/:clusterName/...`). Validation happens
64
+ * Platform-side via `clusterNameSchema`. Platform accepts N
65
+ * connected orchestrators per `(org_id, cluster_name)` — HA-cluster
66
+ * siblings share one cluster identity — and the dashboard listing
67
+ * dedupes by cluster name server-side.
68
+ */
69
+ clusterName: z.string().optional(),
70
+ /**
71
+ * Orchestrator DB identifier (UUID, seeded by orch migration 001 in
72
+ * `cluster_meta` key `'cluster_id'`). Lets Platform distinguish two
73
+ * different orchestrator clusters that accidentally share the same
74
+ * `clusterName` in one org: every coord in an HA cluster shares the
75
+ * same orch DB and therefore the same `clusterId`, while two unrelated
76
+ * clusters carry distinct UUIDs. Optional — older orchestrators that
77
+ * haven't been redeployed yet won't publish it, in which case Platform
78
+ * skips the cross-cluster collision warn for that connection.
79
+ */
80
+ clusterId: z.string().uuid().optional(),
60
81
  /** Reachable address for peer-to-peer connections (from KICI_CLUSTER_ADDRESS env var). */
61
82
  address: z.string().nullable().optional(),
62
83
  /** Orchestrator version (e.g. "0.0.1"). Optional for backward compatibility with older orchestrators. */
@@ -74,11 +95,23 @@ const sourceRegistrationSchema = z.object({
74
95
  /** Queue timeout in ms. Platform uses this (with margin) for safety-net GC of stale queued jobs. */
75
96
  queueTimeoutMs: z.number().optional()
76
97
  });
98
+ /**
99
+ * One accepted source in a {@link sourceRegistrationAckSchema}. Carries the
100
+ * public webhook URL the Platform computed for this routing key so the
101
+ * orchestrator (which only knows its org *alias*, never the canonical org id)
102
+ * can surface it to the operator — e.g. `kici-admin source add` printing the
103
+ * URL to paste into a GitHub App. `webhookUrl` is null when the Platform has
104
+ * no public webhook base configured (`config.webhookPublicUrl` unset).
105
+ */
106
+ const acceptedSourceSchema = z.object({
107
+ routingKey: z.string(),
108
+ webhookUrl: z.string().nullable()
109
+ });
77
110
  /** Platform acknowledgment of source registration. */
78
111
  const sourceRegistrationAckSchema = z.object({
79
112
  type: z.literal("source.register.ack"),
80
113
  messageId: z.string(),
81
- accepted: z.array(z.string()),
114
+ accepted: z.array(acceptedSourceSchema),
82
115
  rejected: z.array(z.object({
83
116
  routingKey: z.string(),
84
117
  reason: z.string()
@@ -104,6 +137,6 @@ const sourceDeregisterAckSchema = z.object({
104
137
  removed: z.array(z.string())
105
138
  });
106
139
  //#endregion
107
- export { SourceProvider, SourceSubtype, sourceDeregisterAckSchema, sourceDeregisterSchema, sourceRegistrationAckSchema, sourceRegistrationSchema };
140
+ export { SourceProvider, SourceSubtype, acceptedSourceSchema, sourceDeregisterAckSchema, sourceDeregisterSchema, sourceRegistrationAckSchema, sourceRegistrationSchema };
108
141
 
109
142
  //# sourceMappingURL=source-registration.js.map
@@ -25,6 +25,7 @@ import { z } from 'zod';
25
25
  * Access values: RegisterableTriggerType.enum.kici_event, etc.
26
26
  */
27
27
  export declare const RegisterableTriggerType: z.ZodEnum<{
28
+ dispatch: "dispatch";
28
29
  status: "status";
29
30
  generic_webhook: "generic_webhook";
30
31
  pr: "pr";
@@ -34,7 +35,6 @@ export declare const RegisterableTriggerType: z.ZodEnum<{
34
35
  review: "review";
35
36
  review_comment: "review_comment";
36
37
  release: "release";
37
- dispatch: "dispatch";
38
38
  create: "create";
39
39
  delete: "delete";
40
40
  workflow_run: "workflow_run";
@@ -23,6 +23,12 @@ export declare const WS_CLOSE_INTERNAL_ERROR = 4006;
23
23
  export declare const WS_CLOSE_AGENT_AUTH_FAILED = 4010;
24
24
  /** The connection was closed because the organization has reached its plan limit. */
25
25
  export declare const WS_CLOSE_PLAN_LIMIT = 4020;
26
+ /**
27
+ * The orchestrator's reported `cluster_name` collides with another
28
+ * already-connected orchestrator in the same org. Operator must rename
29
+ * via `kici-admin cluster-name set <name>` before reconnecting.
30
+ */
31
+ export declare const WS_CLOSE_CLUSTER_NAME_CONFLICT = 4011;
26
32
  /** The connection was closed because the requested run was not found. */
27
33
  export declare const WS_CLOSE_RUN_NOT_FOUND = 4030;
28
34
  //# sourceMappingURL=close-codes.d.ts.map
@@ -25,9 +25,15 @@ const WS_CLOSE_INTERNAL_ERROR = 4006;
25
25
  const WS_CLOSE_AGENT_AUTH_FAILED = 4010;
26
26
  /** The connection was closed because the organization has reached its plan limit. */
27
27
  const WS_CLOSE_PLAN_LIMIT = 4020;
28
+ /**
29
+ * The orchestrator's reported `cluster_name` collides with another
30
+ * already-connected orchestrator in the same org. Operator must rename
31
+ * via `kici-admin cluster-name set <name>` before reconnecting.
32
+ */
33
+ const WS_CLOSE_CLUSTER_NAME_CONFLICT = 4011;
28
34
  /** The connection was closed because the requested run was not found. */
29
35
  const WS_CLOSE_RUN_NOT_FOUND = 4030;
30
36
  //#endregion
31
- export { WS_CLOSE_AGENT_AUTH_FAILED, WS_CLOSE_AUTH_TIMEOUT, WS_CLOSE_GOING_AWAY, WS_CLOSE_HEARTBEAT_TIMEOUT, WS_CLOSE_INTERNAL_ERROR, WS_CLOSE_INVALID_MESSAGE, WS_CLOSE_PLAN_LIMIT, WS_CLOSE_PROTOCOL_ERROR, WS_CLOSE_RUN_NOT_FOUND, WS_CLOSE_UNAUTHORIZED };
37
+ export { WS_CLOSE_AGENT_AUTH_FAILED, WS_CLOSE_AUTH_TIMEOUT, WS_CLOSE_CLUSTER_NAME_CONFLICT, WS_CLOSE_GOING_AWAY, WS_CLOSE_HEARTBEAT_TIMEOUT, WS_CLOSE_INTERNAL_ERROR, WS_CLOSE_INVALID_MESSAGE, WS_CLOSE_PLAN_LIMIT, WS_CLOSE_PROTOCOL_ERROR, WS_CLOSE_RUN_NOT_FOUND, WS_CLOSE_UNAUTHORIZED };
32
38
 
33
39
  //# sourceMappingURL=close-codes.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kici-dev/engine",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
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
  "kici",
@@ -29,7 +29,6 @@
29
29
  "sbom.spdx.json"
30
30
  ],
31
31
  "publishConfig": {
32
- "registry": "https://registry.npmjs.org/",
33
32
  "access": "public"
34
33
  },
35
34
  "main": "dist/index.js",
@@ -51,9 +50,21 @@
51
50
  "import": "./dist/protocol/dashboard-global-workflows.js",
52
51
  "types": "./dist/protocol/dashboard-global-workflows.d.ts"
53
52
  },
53
+ "./protocol/dashboard-write-operations": {
54
+ "import": "./dist/protocol/dashboard-write-operations.js",
55
+ "types": "./dist/protocol/dashboard-write-operations.d.ts"
56
+ },
57
+ "./protocol/cluster-name": {
58
+ "import": "./dist/protocol/cluster-name.js",
59
+ "types": "./dist/protocol/cluster-name.d.ts"
60
+ },
54
61
  "./metrics/catalog": {
55
62
  "import": "./dist/metrics/metric-catalog.generated.js",
56
63
  "types": "./dist/metrics/metric-catalog.generated.d.ts"
64
+ },
65
+ "./metrics/catalog-policy": {
66
+ "import": "./dist/metrics/catalog-policy.js",
67
+ "types": "./dist/metrics/catalog-policy.d.ts"
57
68
  }
58
69
  },
59
70
  "dependencies": {
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.3",
6
- "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fengine/0.1.3/ce5e8341-060d-4cea-b030-6d643b9e3e4b",
5
+ "name": "@kici-dev/engine@0.1.6",
6
+ "documentNamespace": "https://kici.dev/sbom/%40kici-dev%2Fengine/0.1.6/b89e3174-b4cd-4b4c-9a07-e0b491f3e36e",
7
7
  "creationInfo": {
8
- "created": "2026-05-15T14:16:55Z",
8
+ "created": "2026-05-26T05:00:09Z",
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.3",
57
+ "versionInfo": "0.1.6",
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.3"
68
+ "referenceLocator": "pkg:npm/%40kici-dev/engine@0.1.6"
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.",