@kici-dev/orchestrator 0.15.0 → 0.16.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 (146) hide show
  1. package/dist/__test-helpers__/scratch-db.d.ts +16 -0
  2. package/dist/agent/registry.d.ts +1 -8
  3. package/dist/app-on-error.d.ts +1 -1
  4. package/dist/artifacts/artifact-store.d.ts +0 -2
  5. package/dist/audit/access-log.d.ts +1 -1
  6. package/dist/cache/source-cache.d.ts +1 -1
  7. package/dist/cache/user-cache.d.ts +0 -28
  8. package/dist/cli/api-client.d.ts +27 -1
  9. package/dist/cli/commands/access-log.d.ts +1 -1
  10. package/dist/cli/commands/cold-store-impl.d.ts +7 -84
  11. package/dist/cli/commands/db.d.ts +1 -0
  12. package/dist/cli/commands/orchestrator-service/status.d.ts +2 -0
  13. package/dist/cli/commands/org.d.ts +12 -0
  14. package/dist/cli/commands/scaler.d.ts +14 -0
  15. package/dist/cli/commands/secret.d.ts +1 -45
  16. package/dist/cli/commands/service-health.d.ts +21 -13
  17. package/dist/cli/commands/shared/cli-action.d.ts +17 -0
  18. package/dist/cli/commands/shared/db.d.ts +5 -5
  19. package/dist/cli/commands/shared/org-id.d.ts +5 -0
  20. package/dist/cli/commands/shared/service-verbs.d.ts +19 -0
  21. package/dist/cli/commands/shared/table.d.ts +3 -0
  22. package/dist/cli/commands/shared/unbound-context-warning.d.ts +2 -22
  23. package/dist/cli/commands/trust-policy.d.ts +7 -31
  24. package/dist/cli/kici-admin.d.ts +1 -1
  25. package/dist/cli.js +9863 -8201
  26. package/dist/cluster/coordinator.d.ts +2 -2
  27. package/dist/cluster/peer-client.d.ts +27 -1
  28. package/dist/cluster/peer-forget.d.ts +4 -9
  29. package/dist/cluster/peer-handler.d.ts +11 -1
  30. package/dist/cluster/peer-request-waiters.d.ts +26 -0
  31. package/dist/cluster/scaler-orphans-peer.d.ts +4 -9
  32. package/dist/cluster/scaler-reload-fanout.d.ts +29 -0
  33. package/dist/cluster/scaler-reload-peer.d.ts +16 -0
  34. package/dist/cluster/worker-cluster-settings.d.ts +1 -0
  35. package/dist/cold-store/load-access-log-range.d.ts +3 -3
  36. package/dist/cold-store/tables/access-log.d.ts +4 -12
  37. package/dist/cold-store/tables/event-log.d.ts +8 -19
  38. package/dist/cold-store/tables/execution-jobs.d.ts +7 -24
  39. package/dist/cold-store/tables/execution-runs.d.ts +6 -20
  40. package/dist/cold-store/tables/execution-steps.d.ts +8 -26
  41. package/dist/cold-store/tables/secret-audit-log.d.ts +4 -11
  42. package/dist/config/env-overlay.d.ts +3 -8
  43. package/dist/config/reload.d.ts +9 -2
  44. package/dist/config/schema.d.ts +2 -2
  45. package/dist/config/types.d.ts +2 -2
  46. package/dist/config.d.ts +13 -17
  47. package/dist/contexts/held-runs.d.ts +3 -6
  48. package/dist/dashboard/cursor.d.ts +12 -0
  49. package/dist/dashboard/handler.d.ts +5 -12
  50. package/dist/db/deferred-index-build.d.ts +42 -0
  51. package/dist/db/deferred-indexes.d.ts +3 -37
  52. package/dist/db/migrations/100_held_runs_hold_type_vocabulary.d.ts +3 -5
  53. package/dist/db/migrations/158_normalize_legacy_values.d.ts +4 -0
  54. package/dist/db/repos/org-ids-repo.d.ts +87 -0
  55. package/dist/db/schema-snapshot.generated.d.ts +3 -0
  56. package/dist/db/types.d.ts +5 -22
  57. package/dist/fault-injection-types.d.ts +0 -6
  58. package/dist/git/dispatch-git-auth.d.ts +6 -12
  59. package/dist/helpers/json.d.ts +3 -0
  60. package/dist/index.js +133 -136
  61. package/dist/metrics/prometheus.d.ts +0 -5
  62. package/dist/oidc/id-token-claims.d.ts +1 -1
  63. package/dist/oidc/resolve-signer.d.ts +2 -4
  64. package/dist/orchestrator-core.d.ts +10 -3
  65. package/dist/pipeline/global-eval-round.d.ts +2 -26
  66. package/dist/pipeline/install-secrets-resolver.d.ts +0 -3
  67. package/dist/pipeline/manual-schedule.d.ts +1 -7
  68. package/dist/provenance/dispatch-context.d.ts +5 -7
  69. package/dist/provenance/pending-attestations-repo.d.ts +1 -1
  70. package/dist/provenance/trust-root.d.ts +4 -5
  71. package/dist/provenance/verify-deferred-capture.d.ts +3 -3
  72. package/dist/provider-registry.d.ts +13 -40
  73. package/dist/providers/universal-git/ssh-auth.d.ts +0 -5
  74. package/dist/reporting/check-run-reporter.d.ts +8 -21
  75. package/dist/reporting/check-run-summary.d.ts +2 -2
  76. package/dist/reporting/execution-tracker.d.ts +1 -1
  77. package/dist/reporting/log-chunk-sink.d.ts +1 -1
  78. package/dist/reporting/run-summary-fields.d.ts +25 -0
  79. package/dist/reporting/s3-log-storage.d.ts +2 -2
  80. package/dist/routes/admin-access-log.d.ts +2 -9
  81. package/dist/routes/admin-backends.d.ts +2 -9
  82. package/dist/routes/admin-cluster-name.d.ts +2 -8
  83. package/dist/routes/admin-cluster-settings.d.ts +2 -8
  84. package/dist/routes/admin-config.d.ts +0 -3
  85. package/dist/routes/admin-contexts.d.ts +3 -11
  86. package/dist/routes/admin-db.d.ts +2 -9
  87. package/dist/routes/admin-env.d.ts +33 -0
  88. package/dist/routes/admin-event-dlq.d.ts +2 -9
  89. package/dist/routes/admin-event-inspect.d.ts +2 -9
  90. package/dist/routes/admin-event-log.d.ts +2 -9
  91. package/dist/routes/admin-events.d.ts +3 -13
  92. package/dist/routes/admin-held-runs.d.ts +2 -8
  93. package/dist/routes/admin-list-limit.d.ts +3 -0
  94. package/dist/routes/admin-maintenance.d.ts +2 -9
  95. package/dist/routes/admin-orchestrator-drain.d.ts +2 -9
  96. package/dist/routes/admin-org-settings.d.ts +2 -8
  97. package/dist/routes/admin-orgs.d.ts +27 -0
  98. package/dist/routes/admin-peer-forget.d.ts +2 -9
  99. package/dist/routes/admin-queue-execution.d.ts +3 -10
  100. package/dist/routes/admin-registrations.d.ts +3 -14
  101. package/dist/routes/admin-runs.d.ts +3 -14
  102. package/dist/routes/admin-scaler-orphans.d.ts +2 -9
  103. package/dist/routes/admin-scaler-reload.d.ts +41 -0
  104. package/dist/routes/admin-scheduled-jobs.d.ts +2 -9
  105. package/dist/routes/admin-signing-keys.d.ts +2 -9
  106. package/dist/routes/admin-sources.d.ts +2 -9
  107. package/dist/routes/admin-trust-policy.d.ts +2 -8
  108. package/dist/routes/admin.d.ts +15 -13
  109. package/dist/scaler/config.d.ts +12 -84
  110. package/dist/scaler/file-reload.d.ts +48 -0
  111. package/dist/scaler/manager.d.ts +47 -33
  112. package/dist/scaler/scaler-state-store.d.ts +5 -0
  113. package/dist/scaler/types.d.ts +1 -4
  114. package/dist/secrets/job-secret-gate.d.ts +2 -5
  115. package/dist/secrets/secret-resolver.d.ts +2 -4
  116. package/dist/security/trust-policy-gate.d.ts +0 -4
  117. package/dist/server.d.ts +6 -17
  118. package/dist/server.js +6693 -8005
  119. package/dist/standalone.js +5826 -6555
  120. package/dist/worker/reroute-dispatch.d.ts +1 -0
  121. package/dist/worker/reroute-spawn-control.d.ts +1 -3
  122. package/dist/worker-core.d.ts +9 -2
  123. package/dist/ws/agent-handler.d.ts +3 -3
  124. package/dist/ws/dashboard-access.d.ts +57 -0
  125. package/dist/ws/dashboard-backends-handler.d.ts +1 -6
  126. package/dist/ws/dashboard-context-handler.d.ts +10 -15
  127. package/dist/ws/dashboard-fleet-write-handler.d.ts +1 -6
  128. package/dist/ws/dashboard-global-workflows-handler.d.ts +1 -6
  129. package/dist/ws/dashboard-registrations-handler.d.ts +1 -7
  130. package/dist/ws/platform-client.d.ts +85 -330
  131. package/installer-image-digests.json +3 -3
  132. package/package.json +4 -4
  133. package/sbom.spdx.json +53 -53
  134. package/dist/cache/legacy-prefixes.d.ts +0 -19
  135. package/dist/cli/commands/agent-service/logs.d.ts +0 -14
  136. package/dist/cli/commands/agent-service/restart.d.ts +0 -12
  137. package/dist/cli/commands/agent-service/start.d.ts +0 -12
  138. package/dist/cli/commands/agent-service/stop.d.ts +0 -12
  139. package/dist/cli/commands/agent-service/uninstall.d.ts +0 -13
  140. package/dist/cli/commands/cache.d.ts +0 -51
  141. package/dist/cli/commands/orchestrator-service/logs.d.ts +0 -14
  142. package/dist/cli/commands/orchestrator-service/restart.d.ts +0 -12
  143. package/dist/cli/commands/orchestrator-service/start.d.ts +0 -12
  144. package/dist/cli/commands/orchestrator-service/stop.d.ts +0 -12
  145. package/dist/cli/commands/orchestrator-service/uninstall.d.ts +0 -13
  146. package/dist/git/inherited-secret.d.ts +0 -29
@@ -14,22 +14,15 @@
14
14
  import { Hono } from 'hono';
15
15
  import { z } from 'zod';
16
16
  import type { DrainController } from '../drain/drain-controller.js';
17
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
17
+ import type { RbacEnforcer } from '../secrets/rbac.js';
18
+ import { type AdminEnv } from './admin-env.js';
18
19
  export declare const DrainActionSchema: z.ZodEnum<{
19
20
  drain: "drain";
20
21
  resume: "resume";
21
22
  }>;
22
23
  export type DrainAction = z.infer<typeof DrainActionSchema>;
23
- type AdminEnv = {
24
- Variables: {
25
- role: Role;
26
- userId: string;
27
- routingKey: string | null;
28
- };
29
- };
30
24
  export declare function createOrchestratorDrainRoutes(deps: {
31
25
  drainController: DrainController;
32
26
  rbac: RbacEnforcer;
33
27
  }): Hono<AdminEnv>;
34
- export {};
35
28
  //# sourceMappingURL=admin-orchestrator-drain.d.ts.map
@@ -14,8 +14,9 @@ import { type Kysely } from 'kysely';
14
14
  import { type OrchestratorMode } from '@kici-dev/engine';
15
15
  import { DashboardWriteOperation } from '@kici-dev/engine/protocol/dashboard-write-operations';
16
16
  import type { Database } from '../db/types.js';
17
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
17
+ import type { RbacEnforcer } from '../secrets/rbac.js';
18
18
  import type { AccessLogWriter } from '../audit/access-log.js';
19
+ import { type AdminEnv } from './admin-env.js';
19
20
  interface OrgSettingsRouteDeps {
20
21
  db: Kysely<Database>;
21
22
  rbac: RbacEnforcer;
@@ -40,13 +41,6 @@ interface OrgSettingsRouteDeps {
40
41
  */
41
42
  accessLog?: AccessLogWriter;
42
43
  }
43
- type AdminEnv = {
44
- Variables: {
45
- role: Role;
46
- userId: string;
47
- routingKey: string | null;
48
- };
49
- };
50
44
  export declare function createOrgSettingsRoutes(deps: OrgSettingsRouteDeps): Hono<AdminEnv>;
51
45
  export { DashboardWriteOperation };
52
46
  //# sourceMappingURL=admin-org-settings.d.ts.map
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Admin API route listing the org ids this orchestrator holds data for.
3
+ *
4
+ * GET /api/v1/admin/org-ids → `OrgListResponse`: every org id the configuration
5
+ * and anchor tables name, each with the data that names it, plus the live
6
+ * Platform attachment (`attached` / `pending` / `none`).
7
+ *
8
+ * Backs `kici-admin org list` and the `Org:` line of `kici-admin orchestrator
9
+ * status`. The listing spans every org, so the route requires an unscoped token
10
+ * and `secret.read`, like the other read-only inspection routes.
11
+ */
12
+ import { Hono } from 'hono';
13
+ import { type HeldOrg } from '../db/repos/org-ids-repo.js';
14
+ import type { RbacEnforcer } from '../secrets/rbac.js';
15
+ import { type AdminEnv } from './admin-env.js';
16
+ export interface AdminOrgRoutesDeps {
17
+ /** The org ids the database holds (`listHeldOrgIds` bound to the orchestrator DB). */
18
+ listOrgs: () => Promise<HeldOrg[]>;
19
+ rbac: RbacEnforcer;
20
+ /**
21
+ * The org the Platform named on `auth.success`; `undefined` before the first
22
+ * authentication. Absent when no Platform client runs (independent mode).
23
+ */
24
+ getPlatformOrgId?: () => string | undefined;
25
+ }
26
+ export declare function createAdminOrgRoutes(deps: AdminOrgRoutesDeps): Hono<AdminEnv>;
27
+ //# sourceMappingURL=admin-orgs.d.ts.map
@@ -16,14 +16,8 @@
16
16
  import { Hono } from 'hono';
17
17
  import type { AccessLogWriter } from '../audit/access-log.js';
18
18
  import { type PeerForgetResult } from '../cluster/peer-forget.js';
19
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
20
- type AdminEnv = {
21
- Variables: {
22
- role: Role;
23
- userId: string;
24
- routingKey: string | null;
25
- };
26
- };
19
+ import type { RbacEnforcer } from '../secrets/rbac.js';
20
+ import { type AdminEnv } from './admin-env.js';
27
21
  /** What the route needs from the coordinator it runs on. */
28
22
  export interface PeerForgetRouteDeps {
29
23
  /**
@@ -39,5 +33,4 @@ export declare function createPeerForgetRoutes(deps: {
39
33
  rbac: RbacEnforcer;
40
34
  accessLog?: AccessLogWriter;
41
35
  }): Hono<AdminEnv>;
42
- export {};
43
36
  //# sourceMappingURL=admin-peer-forget.d.ts.map
@@ -11,18 +11,11 @@
11
11
  */
12
12
  import { Hono } from 'hono';
13
13
  import { type Kysely } from 'kysely';
14
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
14
+ import type { RbacEnforcer } from '../secrets/rbac.js';
15
+ import { type AdminEnv } from './admin-env.js';
15
16
  export interface AdminQueueExecutionRoutesDeps {
16
17
  db: Kysely<any>;
17
18
  rbac: RbacEnforcer;
18
19
  }
19
- type AdminQEEnv = {
20
- Variables: {
21
- role: Role;
22
- userId: string;
23
- routingKey: string | null;
24
- };
25
- };
26
- export declare function createAdminQueueExecutionRoutes(deps: AdminQueueExecutionRoutesDeps): Hono<AdminQEEnv>;
27
- export {};
20
+ export declare function createAdminQueueExecutionRoutes(deps: AdminQueueExecutionRoutesDeps): Hono<AdminEnv>;
28
21
  //# sourceMappingURL=admin-queue-execution.d.ts.map
@@ -9,11 +9,9 @@ import { Hono } from 'hono';
9
9
  import type { RegistrationStore } from '../registration/registration-store.js';
10
10
  import type { RegistrationIndex } from '../registration/registration-index.js';
11
11
  import type { TokenManager } from '../secrets/token-manager.js';
12
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
12
+ import type { RbacEnforcer } from '../secrets/rbac.js';
13
13
  import type { ContextStore } from '../contexts/context-store.js';
14
- /**
15
- * Dependencies for admin registration routes.
16
- */
14
+ import { type AdminEnv } from './admin-env.js';
17
15
  export interface AdminRegistrationRoutesDeps {
18
16
  registrationStore: RegistrationStore;
19
17
  registrationIndex: RegistrationIndex;
@@ -27,20 +25,11 @@ export interface AdminRegistrationRoutesDeps {
27
25
  */
28
26
  contextStore?: Pick<ContextStore, 'matchContext'>;
29
27
  }
30
- /** Hono env type for admin registration routes with context variables. */
31
- type AdminRegEnv = {
32
- Variables: {
33
- role: Role;
34
- userId: string;
35
- routingKey: string | null;
36
- };
37
- };
38
28
  /**
39
29
  * Create admin API routes for workflow registration management.
40
30
  *
41
31
  * @param deps - Admin registration route dependencies
42
32
  * @returns Hono app with registration routes mounted at /api/v1/admin/registrations
43
33
  */
44
- export declare function createAdminRegistrationRoutes(deps: AdminRegistrationRoutesDeps): Hono<AdminRegEnv>;
45
- export {};
34
+ export declare function createAdminRegistrationRoutes(deps: AdminRegistrationRoutesDeps): Hono<AdminEnv>;
46
35
  //# sourceMappingURL=admin-registrations.d.ts.map
@@ -22,10 +22,11 @@ import { Hono } from 'hono';
22
22
  import type { Kysely } from 'kysely';
23
23
  import type { Database } from '../db/types.js';
24
24
  import type { TokenManager } from '../secrets/token-manager.js';
25
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
25
+ import type { RbacEnforcer } from '../secrets/rbac.js';
26
26
  import type { AuditLogger } from '../secrets/audit-logger.js';
27
27
  import type { ResolvedMasterKeys } from '../secrets/config.js';
28
28
  import type { LogStorage } from '../reporting/log-storage.js';
29
+ import { type AdminEnv } from './admin-env.js';
29
30
  /**
30
31
  * Statuses accepted by the `?status=` filter.
31
32
  *
@@ -35,9 +36,6 @@ import type { LogStorage } from '../reporting/log-storage.js';
35
36
  * an empty result into a rejected request.
36
37
  */
37
38
  export declare const RUN_STATUSES: ReadonlySet<string>;
38
- /**
39
- * Dependencies for admin run routes.
40
- */
41
39
  export interface AdminRunRoutesDeps {
42
40
  db: Kysely<Database>;
43
41
  tokenManager: TokenManager;
@@ -58,20 +56,11 @@ export interface AdminRunRoutesDeps {
58
56
  */
59
57
  logStorage?: LogStorage;
60
58
  }
61
- /** Hono env type for admin run routes with context variables. */
62
- type AdminRunEnv = {
63
- Variables: {
64
- role: Role;
65
- userId: string;
66
- routingKey: string | null;
67
- };
68
- };
69
59
  /**
70
60
  * Create admin API routes for execution run inspection.
71
61
  *
72
62
  * @param deps - Admin run route dependencies
73
63
  * @returns Hono app with run routes mounted at /api/v1/admin/runs
74
64
  */
75
- export declare function createAdminRunRoutes(deps: AdminRunRoutesDeps): Hono<AdminRunEnv>;
76
- export {};
65
+ export declare function createAdminRunRoutes(deps: AdminRunRoutesDeps): Hono<AdminEnv>;
77
66
  //# sourceMappingURL=admin-runs.d.ts.map
@@ -19,16 +19,10 @@
19
19
  import { Hono } from 'hono';
20
20
  import { type PeerScalerOrphansResponse } from '@kici-dev/engine';
21
21
  import type { AccessLogWriter } from '../audit/access-log.js';
22
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
22
+ import type { RbacEnforcer } from '../secrets/rbac.js';
23
23
  import { type ScalerOrphansAnswer, type ScalerOrphansRequest } from '../scaler/orphan-requests.js';
24
24
  import { ScalerOrphansForwardFailure } from '../cluster/scaler-orphans-peer.js';
25
- type AdminEnv = {
26
- Variables: {
27
- role: Role;
28
- userId: string;
29
- routingKey: string | null;
30
- };
31
- };
25
+ import { type AdminEnv } from './admin-env.js';
32
26
  /** What the routes need from the coordinator they run on. */
33
27
  export interface ScalerOrphansRouteDeps {
34
28
  /** This coordinator's instance id. */
@@ -60,5 +54,4 @@ export declare function createScalerOrphansRoutes(deps: {
60
54
  rbac: RbacEnforcer;
61
55
  accessLog?: AccessLogWriter;
62
56
  }): Hono<AdminEnv>;
63
- export {};
64
57
  //# sourceMappingURL=admin-scaler-orphans.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Reload the scaler config, behind `kici-admin scaler reload`.
3
+ *
4
+ * Mounted inside `createAdminRoutes` at `/api/v1/admin`, so the Bearer-token
5
+ * auth middleware has already resolved the caller's role. Needs an unscoped
6
+ * token and the `scaler.manage` permission (owner, admin).
7
+ *
8
+ * - `POST /api/v1/admin/scaler/reload { single?, timeoutMs? }` — re-read the
9
+ * scaler config on this orchestrator and, unless `single`, on every peer it
10
+ * is connected to. Each orchestrator applies its own file completely or not
11
+ * at all. Answers `{ scope, results }` with one result per instance, this
12
+ * one first: `200` when no instance refused its file or went unanswered,
13
+ * `422` otherwise.
14
+ *
15
+ * The route runs the scaler reload only: it does not reload the orchestrator
16
+ * config, so it never bumps the config version the peers follow, and a
17
+ * `single` reload stays on this orchestrator.
18
+ */
19
+ import { Hono } from 'hono';
20
+ import { type ScalerReloadInstanceResult } from '@kici-dev/engine';
21
+ import type { AccessLogWriter } from '../audit/access-log.js';
22
+ import type { RbacEnforcer } from '../secrets/rbac.js';
23
+ import { type AdminEnv } from './admin-env.js';
24
+ /** What the route needs from the orchestrator it runs on. */
25
+ export interface ScalerReloadRouteDeps {
26
+ /** This orchestrator's instance id, the audit row's target. */
27
+ instanceId: string;
28
+ /**
29
+ * Reload here and, unless `single`, on every connected peer, waiting
30
+ * `timeoutMs` for each peer. The first result is this orchestrator's.
31
+ */
32
+ reload: (single: boolean, timeoutMs: number) => Promise<ScalerReloadInstanceResult[]>;
33
+ }
34
+ /** How long the route waits for each peer by default. */
35
+ export declare const DEFAULT_SCALER_RELOAD_TIMEOUT_MS = 60000;
36
+ export declare function createScalerReloadRoutes(deps: {
37
+ scalerReload: ScalerReloadRouteDeps;
38
+ rbac: RbacEnforcer;
39
+ accessLog?: AccessLogWriter;
40
+ }): Hono<AdminEnv>;
41
+ //# sourceMappingURL=admin-scaler-reload.d.ts.map
@@ -18,19 +18,12 @@ import { Hono } from 'hono';
18
18
  import type { Kysely } from 'kysely';
19
19
  import type { Database } from '../db/types.js';
20
20
  import type { TokenManager } from '../secrets/token-manager.js';
21
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
21
+ import type { RbacEnforcer } from '../secrets/rbac.js';
22
+ import { type AdminEnv } from './admin-env.js';
22
23
  export interface AdminScheduledJobsRoutesDeps {
23
24
  db: Kysely<Database>;
24
25
  tokenManager: TokenManager;
25
26
  rbac: RbacEnforcer;
26
27
  }
27
- type AdminEnv = {
28
- Variables: {
29
- role: Role;
30
- userId: string;
31
- routingKey: string | null;
32
- };
33
- };
34
28
  export declare function createAdminScheduledJobsRoutes(deps: AdminScheduledJobsRoutesDeps): Hono<AdminEnv>;
35
- export {};
36
29
  //# sourceMappingURL=admin-scheduled-jobs.d.ts.map
@@ -16,18 +16,11 @@
16
16
  import { Hono } from 'hono';
17
17
  import type { Kysely } from 'kysely';
18
18
  import type { Database } from '../db/types.js';
19
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
19
+ import type { RbacEnforcer } from '../secrets/rbac.js';
20
+ import { type AdminEnv } from './admin-env.js';
20
21
  export interface AdminSigningKeyRoutesDeps {
21
22
  db: Kysely<Database>;
22
23
  rbac: RbacEnforcer;
23
24
  }
24
- type AdminEnv = {
25
- Variables: {
26
- role: Role;
27
- userId: string;
28
- routingKey: string | null;
29
- };
30
- };
31
25
  export declare function createAdminSigningKeyRoutes(deps: AdminSigningKeyRoutesDeps): Hono<AdminEnv>;
32
- export {};
33
26
  //# sourceMappingURL=admin-signing-keys.d.ts.map
@@ -11,9 +11,9 @@
11
11
  import { Hono } from 'hono';
12
12
  import type { SourceStore } from '../sources/source-store.js';
13
13
  import { type WebhookUrlResolution } from '../sources/webhook-url-resolvers.js';
14
- import type { Role } from '../secrets/rbac.js';
15
14
  import { type RedeliverWindowResult } from '../providers/github/deliveries.js';
16
15
  import { type FetchGithubAppIdentity, type FetchGithubAppInstallations } from '../github-app-name-refresher/github-app-name-refresher.js';
16
+ import { type AdminEnv } from './admin-env.js';
17
17
  interface SourceRouteDeps {
18
18
  sourceStore: SourceStore;
19
19
  /**
@@ -72,13 +72,6 @@ export type RedeliverDeliveries = (app: {
72
72
  until: Date;
73
73
  dryRun?: boolean;
74
74
  }) => Promise<RedeliverWindowResult>;
75
- type AdminSourcesEnv = {
76
- Variables: {
77
- role: Role;
78
- userId: string;
79
- routingKey: string | null;
80
- };
81
- };
82
- export declare function createSourceRoutes(deps: SourceRouteDeps): Hono<AdminSourcesEnv>;
75
+ export declare function createSourceRoutes(deps: SourceRouteDeps): Hono<AdminEnv>;
83
76
  export {};
84
77
  //# sourceMappingURL=admin-sources.d.ts.map
@@ -23,8 +23,9 @@ import { Hono } from 'hono';
23
23
  import type { OrchestratorMode } from '@kici-dev/engine';
24
24
  import type { TrustPolicyStore } from '../security/trust-policy-store.js';
25
25
  import type { TrustDirectoryStore } from '../security/trust-directory-store.js';
26
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
26
+ import type { RbacEnforcer } from '../secrets/rbac.js';
27
27
  import type { AccessLogWriter } from '../audit/access-log.js';
28
+ import { type AdminEnv } from './admin-env.js';
28
29
  /**
29
30
  * Wording for the Platform-managed refusal. Shared with the CLI through the
30
31
  * response body — the CLI surfaces this verbatim rather than inventing its own.
@@ -76,13 +77,6 @@ interface TrustPolicyRouteDeps {
76
77
  */
77
78
  accessLog: AccessLogWriter;
78
79
  }
79
- type AdminEnv = {
80
- Variables: {
81
- role: Role;
82
- userId: string;
83
- routingKey: string | null;
84
- };
85
- };
86
80
  export declare function createTrustPolicyRoutes(deps: TrustPolicyRouteDeps): Hono<AdminEnv>;
87
81
  export {};
88
82
  //# sourceMappingURL=admin-trust-policy.d.ts.map
@@ -10,7 +10,7 @@
10
10
  */
11
11
  import { Hono } from 'hono';
12
12
  import type { TokenManager } from '../secrets/token-manager.js';
13
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
13
+ import type { RbacEnforcer } from '../secrets/rbac.js';
14
14
  import type { PgSecretStore } from '../secrets/pg-secret-store.js';
15
15
  import type { AuditLogger } from '../secrets/audit-logger.js';
16
16
  import type { AgentTokenStore } from '../agent/token-store.js';
@@ -21,6 +21,7 @@ import { type HeldRunReleaseWiring } from './admin-held-runs.js';
21
21
  import { type ClusterSettingsPropagationSource } from './admin-cluster-settings.js';
22
22
  import { type ScalerOrphansRouteDeps } from './admin-scaler-orphans.js';
23
23
  import { type PeerForgetRouteDeps } from './admin-peer-forget.js';
24
+ import { type ScalerReloadRouteDeps } from './admin-scaler-reload.js';
24
25
  import type { DrainController } from '../drain/drain-controller.js';
25
26
  import type { SourceStore } from '../sources/source-store.js';
26
27
  import type { JoinTokenManager } from '../cluster/join-token.js';
@@ -31,9 +32,7 @@ import type { Kysely } from 'kysely';
31
32
  import type pg from 'pg';
32
33
  import type { AccessLogWriter } from '../audit/access-log.js';
33
34
  import type { WebhookUrlResolution } from '../sources/webhook-url-resolvers.js';
34
- /**
35
- * Dependencies for admin API routes.
36
- */
35
+ import { type AdminEnv } from './admin-env.js';
37
36
  export interface AdminRouteDeps {
38
37
  tokenManager: TokenManager;
39
38
  /**
@@ -55,6 +54,12 @@ export interface AdminRouteDeps {
55
54
  * an independent orchestrator and on a test admin, which have no connection.
56
55
  */
57
56
  platformConnected?: () => boolean;
57
+ /**
58
+ * The org the Platform named on `auth.success`, read per request; `undefined`
59
+ * before the first authentication. Backs the attachment `GET /org-ids` reports.
60
+ * Absent on an independent orchestrator and on a test admin.
61
+ */
62
+ getPlatformOrgId?: () => string | undefined;
58
63
  rbac: RbacEnforcer;
59
64
  secretStore: PgSecretStore;
60
65
  auditLogger: AuditLogger;
@@ -166,6 +171,12 @@ export interface AdminRouteDeps {
166
171
  * Bound by orchestrator-core once the cluster is up.
167
172
  */
168
173
  scalerOrphans?: ScalerOrphansRouteDeps;
174
+ /**
175
+ * Optional -- reload the scaler config here and on every connected peer.
176
+ * Backs `POST /api/v1/admin/scaler/reload` (`kici-admin scaler reload`).
177
+ * Bound by orchestrator-core once the cluster is up.
178
+ */
179
+ scalerReload?: ScalerReloadRouteDeps;
169
180
  /**
170
181
  * Optional -- forget a departed peer here and on every connected sibling
171
182
  * coordinator. Backs `POST /api/v1/admin/peers/forget` (`kici-admin peer
@@ -202,14 +213,6 @@ export interface AdminRouteDeps {
202
213
  */
203
214
  heldRunRelease?: HeldRunReleaseWiring;
204
215
  }
205
- /** Hono env type for admin routes with context variables. */
206
- type AdminEnv = {
207
- Variables: {
208
- role: Role;
209
- userId: string;
210
- routingKey: string | null;
211
- };
212
- };
213
216
  /**
214
217
  * Create admin API routes with Bearer token authentication and RBAC.
215
218
  *
@@ -217,5 +220,4 @@ type AdminEnv = {
217
220
  * @returns Hono app with admin routes mounted at /api/v1/admin/*
218
221
  */
219
222
  export declare function createAdminRoutes(deps: AdminRouteDeps): Hono<AdminEnv>;
220
- export {};
221
223
  //# sourceMappingURL=admin.d.ts.map
@@ -37,40 +37,16 @@ export declare const labelSetConfigSchema: z.ZodObject<{
37
37
  Never: "Never";
38
38
  }>>;
39
39
  binaryPath: z.ZodOptional<z.ZodString>;
40
- resources: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
40
+ resources: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
41
41
  requests: z.ZodOptional<z.ZodObject<{
42
- memory: z.ZodOptional<z.ZodString>;
43
42
  cpus: z.ZodOptional<z.ZodNumber>;
43
+ memory: z.ZodOptional<z.ZodString>;
44
44
  }, z.core.$strict>>;
45
45
  limits: z.ZodOptional<z.ZodObject<{
46
- memory: z.ZodOptional<z.ZodString>;
47
46
  cpus: z.ZodOptional<z.ZodNumber>;
47
+ memory: z.ZodOptional<z.ZodString>;
48
48
  }, z.core.$strict>>;
49
- }, z.core.$strict>, z.ZodObject<{
50
- memory: z.ZodOptional<z.ZodString>;
51
- cpus: z.ZodOptional<z.ZodNumber>;
52
- }, z.core.$strict>]>, z.ZodTransform<{
53
- requests?: {
54
- cpus?: number;
55
- memory?: string;
56
- };
57
- limits?: {
58
- cpus?: number;
59
- memory?: string;
60
- };
61
- }, {
62
- memory?: string | undefined;
63
- cpus?: number | undefined;
64
- } | {
65
- requests?: {
66
- memory?: string | undefined;
67
- cpus?: number | undefined;
68
- } | undefined;
69
- limits?: {
70
- memory?: string | undefined;
71
- cpus?: number | undefined;
72
- } | undefined;
73
- }>>>;
49
+ }, z.core.$strict>, unknown>>;
74
50
  volumes: z.ZodOptional<z.ZodArray<z.ZodString>>;
75
51
  containerSocket: z.ZodDefault<z.ZodBoolean>;
76
52
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -109,40 +85,16 @@ export declare const scalerFileSchema: z.ZodObject<{
109
85
  version: z.ZodLiteral<1>;
110
86
  globalMaxAgents: z.ZodDefault<z.ZodNumber>;
111
87
  defaults: z.ZodOptional<z.ZodObject<{
112
- resources: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
88
+ resources: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
113
89
  requests: z.ZodOptional<z.ZodObject<{
114
- memory: z.ZodOptional<z.ZodString>;
115
90
  cpus: z.ZodOptional<z.ZodNumber>;
91
+ memory: z.ZodOptional<z.ZodString>;
116
92
  }, z.core.$strict>>;
117
93
  limits: z.ZodOptional<z.ZodObject<{
118
- memory: z.ZodOptional<z.ZodString>;
119
94
  cpus: z.ZodOptional<z.ZodNumber>;
95
+ memory: z.ZodOptional<z.ZodString>;
120
96
  }, z.core.$strict>>;
121
- }, z.core.$strict>, z.ZodObject<{
122
- memory: z.ZodOptional<z.ZodString>;
123
- cpus: z.ZodOptional<z.ZodNumber>;
124
- }, z.core.$strict>]>, z.ZodTransform<{
125
- requests?: {
126
- cpus?: number;
127
- memory?: string;
128
- };
129
- limits?: {
130
- cpus?: number;
131
- memory?: string;
132
- };
133
- }, {
134
- memory?: string | undefined;
135
- cpus?: number | undefined;
136
- } | {
137
- requests?: {
138
- memory?: string | undefined;
139
- cpus?: number | undefined;
140
- } | undefined;
141
- limits?: {
142
- memory?: string | undefined;
143
- cpus?: number | undefined;
144
- } | undefined;
145
- }>>>;
97
+ }, z.core.$strict>, unknown>>;
146
98
  }, z.core.$strip>>;
147
99
  globalResourceCap: z.ZodOptional<z.ZodPipe<z.ZodObject<{
148
100
  maxCpu: z.ZodOptional<z.ZodNumber>;
@@ -186,40 +138,16 @@ export declare const scalerFileSchema: z.ZodObject<{
186
138
  Never: "Never";
187
139
  }>>;
188
140
  binaryPath: z.ZodOptional<z.ZodString>;
189
- resources: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodObject<{
141
+ resources: z.ZodOptional<z.ZodPreprocess<z.ZodObject<{
190
142
  requests: z.ZodOptional<z.ZodObject<{
191
- memory: z.ZodOptional<z.ZodString>;
192
143
  cpus: z.ZodOptional<z.ZodNumber>;
144
+ memory: z.ZodOptional<z.ZodString>;
193
145
  }, z.core.$strict>>;
194
146
  limits: z.ZodOptional<z.ZodObject<{
195
- memory: z.ZodOptional<z.ZodString>;
196
147
  cpus: z.ZodOptional<z.ZodNumber>;
148
+ memory: z.ZodOptional<z.ZodString>;
197
149
  }, z.core.$strict>>;
198
- }, z.core.$strict>, z.ZodObject<{
199
- memory: z.ZodOptional<z.ZodString>;
200
- cpus: z.ZodOptional<z.ZodNumber>;
201
- }, z.core.$strict>]>, z.ZodTransform<{
202
- requests?: {
203
- cpus?: number;
204
- memory?: string;
205
- };
206
- limits?: {
207
- cpus?: number;
208
- memory?: string;
209
- };
210
- }, {
211
- memory?: string | undefined;
212
- cpus?: number | undefined;
213
- } | {
214
- requests?: {
215
- memory?: string | undefined;
216
- cpus?: number | undefined;
217
- } | undefined;
218
- limits?: {
219
- memory?: string | undefined;
220
- cpus?: number | undefined;
221
- } | undefined;
222
- }>>>;
150
+ }, z.core.$strict>, unknown>>;
223
151
  volumes: z.ZodOptional<z.ZodArray<z.ZodString>>;
224
152
  containerSocket: z.ZodDefault<z.ZodBoolean>;
225
153
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The one scaler config reload: re-read the scaler file, hand it to the
3
+ * manager (which validates everything before it applies anything), and report
4
+ * what happened.
5
+ *
6
+ * `SIGHUP` (through `ConfigReloader`), the `POST /admin/scaler/reload` route
7
+ * and a peer's `peer.scaler.reload.request` all run this function, so each of
8
+ * them applies a file the same way.
9
+ */
10
+ import { type Logger } from '@kici-dev/shared';
11
+ import { type ScalerReloadAnswer } from '@kici-dev/engine';
12
+ import type { ScalerManager } from './manager.js';
13
+ import type { ScalerConfig } from './types.js';
14
+ export interface ScalerFileReloadDeps {
15
+ /** Null when the orchestrator runs without a scaler config. */
16
+ manager: Pick<ScalerManager, 'reload'> | null;
17
+ /** Re-reads the scaler config from disk; throws on a missing or invalid file. */
18
+ load: () => Promise<ScalerConfig>;
19
+ /** Runs after a reload applied (the dashboard diagnostics snapshot). */
20
+ onApplied?: (config: ScalerConfig) => void;
21
+ logger: Logger;
22
+ }
23
+ /**
24
+ * One orchestrator's scaler reload outcome: `applied` with its plan, `rejected`
25
+ * with its errors (nothing applied), or `not-configured`.
26
+ */
27
+ export type ScalerFileReloadResult = ScalerReloadAnswer;
28
+ /** Runs one scaler file reload; see `createScalerFileReload`. */
29
+ export type ScalerFileReload = () => Promise<ScalerFileReloadResult>;
30
+ /**
31
+ * Build the reload function. Calls run one after the other: a reload that
32
+ * arrives while another runs (a `SIGHUP` during an HTTP reload) waits, then
33
+ * reads the file again, and each caller gets the outcome of its own run.
34
+ */
35
+ export declare function createScalerFileReload(deps: ScalerFileReloadDeps): ScalerFileReload;
36
+ /** The part of `process` the signal listener needs, injectable for tests. */
37
+ export interface SignalSource {
38
+ on(signal: 'SIGHUP', listener: () => void): unknown;
39
+ off(signal: 'SIGHUP', listener: () => void): unknown;
40
+ }
41
+ /**
42
+ * Run `reload` on `SIGHUP`, debounced like the coordinator's `ConfigReloader`
43
+ * so a burst of signals reloads once. A Node.js process with no `SIGHUP`
44
+ * listener exits on the signal, so a host that reloads only its scaler config
45
+ * (a worker) installs this one. Returns the disposer that removes the listener.
46
+ */
47
+ export declare function installScalerReloadSignal(reload: ScalerFileReload, logger: Logger, signals?: SignalSource): () => void;
48
+ //# sourceMappingURL=file-reload.d.ts.map