@kici-dev/orchestrator 0.15.0 → 0.17.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 (161) 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/approvals/apply-decision.d.ts +12 -1
  5. package/dist/artifacts/artifact-store.d.ts +0 -2
  6. package/dist/audit/access-log.d.ts +1 -1
  7. package/dist/cache/source-cache.d.ts +1 -1
  8. package/dist/cache/user-cache.d.ts +0 -28
  9. package/dist/cli/api-client.d.ts +35 -1
  10. package/dist/cli/commands/access-log.d.ts +1 -1
  11. package/dist/cli/commands/api-key.d.ts +11 -4
  12. package/dist/cli/commands/cold-store-impl.d.ts +7 -84
  13. package/dist/cli/commands/db.d.ts +1 -0
  14. package/dist/cli/commands/orchestrator-service/status.d.ts +2 -0
  15. package/dist/cli/commands/org.d.ts +12 -0
  16. package/dist/cli/commands/scaler.d.ts +14 -0
  17. package/dist/cli/commands/secret.d.ts +1 -45
  18. package/dist/cli/commands/service-health.d.ts +21 -13
  19. package/dist/cli/commands/shared/cli-action.d.ts +17 -0
  20. package/dist/cli/commands/shared/db.d.ts +5 -5
  21. package/dist/cli/commands/shared/org-id.d.ts +5 -0
  22. package/dist/cli/commands/shared/service-verbs.d.ts +19 -0
  23. package/dist/cli/commands/shared/table.d.ts +3 -0
  24. package/dist/cli/commands/shared/unbound-context-warning.d.ts +2 -22
  25. package/dist/cli/commands/trust-policy.d.ts +7 -31
  26. package/dist/cli/kici-admin.d.ts +1 -1
  27. package/dist/cli.js +9865 -8203
  28. package/dist/cluster/coordinator.d.ts +2 -2
  29. package/dist/cluster/peer-client.d.ts +27 -1
  30. package/dist/cluster/peer-forget.d.ts +4 -9
  31. package/dist/cluster/peer-handler.d.ts +11 -1
  32. package/dist/cluster/peer-request-waiters.d.ts +26 -0
  33. package/dist/cluster/scaler-orphans-peer.d.ts +4 -9
  34. package/dist/cluster/scaler-reload-fanout.d.ts +29 -0
  35. package/dist/cluster/scaler-reload-peer.d.ts +16 -0
  36. package/dist/cluster/worker-cluster-settings.d.ts +1 -0
  37. package/dist/cold-store/load-access-log-range.d.ts +3 -3
  38. package/dist/cold-store/tables/access-log.d.ts +4 -12
  39. package/dist/cold-store/tables/event-log.d.ts +8 -19
  40. package/dist/cold-store/tables/execution-jobs.d.ts +7 -24
  41. package/dist/cold-store/tables/execution-runs.d.ts +6 -20
  42. package/dist/cold-store/tables/execution-steps.d.ts +8 -26
  43. package/dist/cold-store/tables/secret-audit-log.d.ts +4 -11
  44. package/dist/config/env-overlay.d.ts +3 -8
  45. package/dist/config/reload.d.ts +9 -2
  46. package/dist/config/schema.d.ts +2 -2
  47. package/dist/config/types.d.ts +2 -2
  48. package/dist/config.d.ts +13 -17
  49. package/dist/contexts/held-runs.d.ts +3 -6
  50. package/dist/dashboard/cursor.d.ts +12 -0
  51. package/dist/dashboard/handler.d.ts +5 -12
  52. package/dist/db/deferred-index-build.d.ts +42 -0
  53. package/dist/db/deferred-indexes.d.ts +3 -37
  54. package/dist/db/migrations/100_held_runs_hold_type_vocabulary.d.ts +3 -5
  55. package/dist/db/migrations/158_normalize_legacy_values.d.ts +4 -0
  56. package/dist/db/repos/org-ids-repo.d.ts +87 -0
  57. package/dist/db/schema-snapshot.generated.d.ts +3 -0
  58. package/dist/db/types.d.ts +5 -22
  59. package/dist/fault-injection-types.d.ts +0 -6
  60. package/dist/git/dispatch-git-auth.d.ts +6 -12
  61. package/dist/helpers/json.d.ts +3 -0
  62. package/dist/index.js +144 -140
  63. package/dist/metrics/prometheus.d.ts +0 -5
  64. package/dist/oidc/id-token-claims.d.ts +1 -1
  65. package/dist/oidc/resolve-signer.d.ts +2 -4
  66. package/dist/orchestrator-core.d.ts +10 -3
  67. package/dist/pipeline/global-eval-round.d.ts +2 -26
  68. package/dist/pipeline/install-secrets-resolver.d.ts +0 -3
  69. package/dist/pipeline/manual-schedule.d.ts +1 -7
  70. package/dist/pipeline/test-pipeline.d.ts +8 -7
  71. package/dist/provenance/dispatch-context.d.ts +5 -7
  72. package/dist/provenance/pending-attestations-repo.d.ts +1 -1
  73. package/dist/provenance/trust-root.d.ts +4 -5
  74. package/dist/provenance/verify-deferred-capture.d.ts +3 -3
  75. package/dist/provider-registry.d.ts +13 -40
  76. package/dist/providers/universal-git/ssh-auth.d.ts +0 -5
  77. package/dist/queue/terminalize-unroutable.d.ts +5 -0
  78. package/dist/reporting/check-run-reporter.d.ts +8 -21
  79. package/dist/reporting/check-run-summary.d.ts +2 -2
  80. package/dist/reporting/execution-tracker.d.ts +1 -1
  81. package/dist/reporting/log-chunk-sink.d.ts +1 -1
  82. package/dist/reporting/run-summary-fields.d.ts +25 -0
  83. package/dist/reporting/s3-log-storage.d.ts +2 -2
  84. package/dist/routes/admin-access-log.d.ts +2 -9
  85. package/dist/routes/admin-auth.d.ts +2 -0
  86. package/dist/routes/admin-backends.d.ts +2 -9
  87. package/dist/routes/admin-cluster-name.d.ts +2 -8
  88. package/dist/routes/admin-cluster-settings.d.ts +2 -8
  89. package/dist/routes/admin-config.d.ts +0 -3
  90. package/dist/routes/admin-contexts.d.ts +3 -11
  91. package/dist/routes/admin-db.d.ts +2 -9
  92. package/dist/routes/admin-env.d.ts +33 -0
  93. package/dist/routes/admin-event-dlq.d.ts +2 -9
  94. package/dist/routes/admin-event-inspect.d.ts +2 -9
  95. package/dist/routes/admin-event-log.d.ts +2 -9
  96. package/dist/routes/admin-events.d.ts +3 -13
  97. package/dist/routes/admin-held-runs.d.ts +2 -8
  98. package/dist/routes/admin-list-limit.d.ts +3 -0
  99. package/dist/routes/admin-maintenance.d.ts +2 -9
  100. package/dist/routes/admin-orchestrator-drain.d.ts +2 -9
  101. package/dist/routes/admin-org-settings.d.ts +2 -8
  102. package/dist/routes/admin-orgs.d.ts +27 -0
  103. package/dist/routes/admin-peer-forget.d.ts +2 -9
  104. package/dist/routes/admin-queue-execution.d.ts +3 -10
  105. package/dist/routes/admin-registrations.d.ts +3 -14
  106. package/dist/routes/admin-runs.d.ts +3 -14
  107. package/dist/routes/admin-scaler-orphans.d.ts +2 -9
  108. package/dist/routes/admin-scaler-reload.d.ts +41 -0
  109. package/dist/routes/admin-scheduled-jobs.d.ts +2 -9
  110. package/dist/routes/admin-signing-keys.d.ts +2 -9
  111. package/dist/routes/admin-sources.d.ts +2 -9
  112. package/dist/routes/admin-trust-policy.d.ts +2 -8
  113. package/dist/routes/admin.d.ts +15 -13
  114. package/dist/routes/caller-identity.d.ts +52 -0
  115. package/dist/routes/test-direct.d.ts +46 -0
  116. package/dist/routes/uploads.d.ts +12 -11
  117. package/dist/scaler/config.d.ts +12 -84
  118. package/dist/scaler/file-reload.d.ts +48 -0
  119. package/dist/scaler/manager.d.ts +47 -33
  120. package/dist/scaler/scaler-state-store.d.ts +5 -0
  121. package/dist/scaler/types.d.ts +1 -4
  122. package/dist/secrets/job-secret-gate.d.ts +2 -5
  123. package/dist/secrets/rbac.d.ts +5 -1
  124. package/dist/secrets/routing-key-scope.d.ts +1 -0
  125. package/dist/secrets/secret-resolver.d.ts +2 -4
  126. package/dist/secrets/token-manager.d.ts +1 -0
  127. package/dist/security/trust-policy-gate.d.ts +0 -4
  128. package/dist/server.d.ts +6 -17
  129. package/dist/server.js +9890 -10851
  130. package/dist/standalone.js +6928 -6576
  131. package/dist/storage/s3.d.ts +7 -7
  132. package/dist/storage/types.d.ts +4 -4
  133. package/dist/worker/reroute-dispatch.d.ts +1 -0
  134. package/dist/worker/reroute-spawn-control.d.ts +1 -3
  135. package/dist/worker-core.d.ts +9 -2
  136. package/dist/ws/agent-handler.d.ts +3 -3
  137. package/dist/ws/dashboard-access.d.ts +57 -0
  138. package/dist/ws/dashboard-backends-handler.d.ts +1 -6
  139. package/dist/ws/dashboard-context-handler.d.ts +10 -15
  140. package/dist/ws/dashboard-fleet-write-handler.d.ts +1 -6
  141. package/dist/ws/dashboard-global-workflows-handler.d.ts +1 -6
  142. package/dist/ws/dashboard-registrations-handler.d.ts +1 -7
  143. package/dist/ws/platform-client.d.ts +85 -330
  144. package/dist/ws/test-relay-handlers.d.ts +16 -9
  145. package/installer-image-digests.json +3 -3
  146. package/package.json +4 -4
  147. package/sbom.spdx.json +53 -53
  148. package/dist/cache/legacy-prefixes.d.ts +0 -19
  149. package/dist/cli/commands/agent-service/logs.d.ts +0 -14
  150. package/dist/cli/commands/agent-service/restart.d.ts +0 -12
  151. package/dist/cli/commands/agent-service/start.d.ts +0 -12
  152. package/dist/cli/commands/agent-service/stop.d.ts +0 -12
  153. package/dist/cli/commands/agent-service/uninstall.d.ts +0 -13
  154. package/dist/cli/commands/cache.d.ts +0 -51
  155. package/dist/cli/commands/orchestrator-service/logs.d.ts +0 -14
  156. package/dist/cli/commands/orchestrator-service/restart.d.ts +0 -12
  157. package/dist/cli/commands/orchestrator-service/start.d.ts +0 -12
  158. package/dist/cli/commands/orchestrator-service/stop.d.ts +0 -12
  159. package/dist/cli/commands/orchestrator-service/uninstall.d.ts +0 -13
  160. package/dist/git/inherited-secret.d.ts +0 -29
  161. package/dist/scaler/container-spawn.d.ts +0 -28
@@ -21,8 +21,9 @@ import { type ColdStore } from '@kici-dev/shared';
21
21
  import type { Kysely } from 'kysely';
22
22
  import type { Database } from '../db/types.js';
23
23
  import type { TokenManager } from '../secrets/token-manager.js';
24
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
24
+ import type { RbacEnforcer } from '../secrets/rbac.js';
25
25
  import type { LogStorage } from '../reporting/log-storage.js';
26
+ import { type AdminEnv } from './admin-env.js';
26
27
  export interface AdminEventLogRoutesDeps {
27
28
  db: Kysely<Database>;
28
29
  logStorage: LogStorage;
@@ -31,13 +32,5 @@ export interface AdminEventLogRoutesDeps {
31
32
  /** Optional cold-store for archived event_log rows. */
32
33
  coldStore?: ColdStore;
33
34
  }
34
- type AdminEnv = {
35
- Variables: {
36
- role: Role;
37
- userId: string;
38
- routingKey: string | null;
39
- };
40
- };
41
35
  export declare function createAdminEventLogRoutes(deps: AdminEventLogRoutesDeps): Hono<AdminEnv>;
42
- export {};
43
36
  //# sourceMappingURL=admin-event-log.d.ts.map
@@ -12,14 +12,12 @@ import type pg from 'pg';
12
12
  import type { GenericSourceManager } from '../webhook/generic-sources.js';
13
13
  import type { TrustStore } from '../events/trust-store.js';
14
14
  import type { TokenManager } from '../secrets/token-manager.js';
15
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
15
+ import type { RbacEnforcer } from '../secrets/rbac.js';
16
16
  import type { AppConfig } from '../config.js';
17
17
  import type { ProviderRegistry } from '../provider-registry.js';
18
18
  import type { SecretResolver } from '../secrets/secret-resolver.js';
19
19
  import type { ClusterSettingsReader } from '../cluster/cluster-settings-reader.js';
20
- /**
21
- * Dependencies for admin event routes.
22
- */
20
+ import { type AdminEnv } from './admin-env.js';
23
21
  interface AdminEventRouteDeps {
24
22
  sourceManager: GenericSourceManager;
25
23
  trustStore: TrustStore;
@@ -61,20 +59,12 @@ interface AdminEventRouteDeps {
61
59
  */
62
60
  pool?: pg.Pool;
63
61
  }
64
- /** Hono env type for admin event routes with context variables. */
65
- type AdminEventEnv = {
66
- Variables: {
67
- role: Role;
68
- userId: string;
69
- routingKey: string | null;
70
- };
71
- };
72
62
  /**
73
63
  * Create admin API routes for generic webhook sources and trust management.
74
64
  *
75
65
  * @param deps - Admin event route dependencies
76
66
  * @returns Hono app with admin event routes mounted at /api/v1/admin/*
77
67
  */
78
- export declare function createAdminEventRoutes(deps: AdminEventRouteDeps): Hono<AdminEventEnv>;
68
+ export declare function createAdminEventRoutes(deps: AdminEventRouteDeps): Hono<AdminEnv>;
79
69
  export {};
80
70
  //# sourceMappingURL=admin-events.d.ts.map
@@ -45,9 +45,10 @@ import { HeldRunStore, type ReleaseSignal } from '../contexts/held-runs.js';
45
45
  import type { TrustDirectoryStore } from '../security/trust-directory-store.js';
46
46
  import { adminActorSub, triggererSubjectFor } from '../approvals/triggerer-subject.js';
47
47
  import { type ResolveCheckStatusPoster } from '../pipeline/security-hold-check.js';
48
- import type { RbacEnforcer, Role } from '../secrets/rbac.js';
48
+ import type { RbacEnforcer } from '../secrets/rbac.js';
49
49
  import type { AccessLogWriter } from '../audit/access-log.js';
50
50
  import type { Database, HeldRun } from '../db/types.js';
51
+ import { type AdminEnv } from './admin-env.js';
51
52
  /**
52
53
  * Wording for the Platform-managed refusal, surfaced verbatim by the CLI.
53
54
  *
@@ -126,13 +127,6 @@ export interface HeldRunRouteDeps {
126
127
  accessLog: AccessLogWriter;
127
128
  release: HeldRunReleaseWiring;
128
129
  }
129
- type AdminEnv = {
130
- Variables: {
131
- role: Role;
132
- userId: string;
133
- routingKey: string | null;
134
- };
135
- };
136
130
  /**
137
131
  * The approval subject for a decision taken through an admin token.
138
132
  *
@@ -0,0 +1,3 @@
1
+ /** Page size from a `?limit=` query: a missing, non-numeric or non-positive value is 50; the cap is 200. */
2
+ export declare function clampLimit(raw: string | undefined): number;
3
+ //# sourceMappingURL=admin-list-limit.d.ts.map
@@ -14,17 +14,10 @@
14
14
  */
15
15
  import { Hono } from 'hono';
16
16
  import type { Kysely } from 'kysely';
17
- import type { Role } from '../secrets/rbac.js';
17
+ import { type AdminEnv } from './admin-env.js';
18
18
  interface MaintenanceRouteDeps {
19
19
  db: Kysely<any>;
20
20
  }
21
- type AdminMaintenanceEnv = {
22
- Variables: {
23
- role: Role;
24
- userId: string;
25
- routingKey: string | null;
26
- };
27
- };
28
- export declare function createMaintenanceRoutes(deps: MaintenanceRouteDeps): Hono<AdminMaintenanceEnv>;
21
+ export declare function createMaintenanceRoutes(deps: MaintenanceRouteDeps): Hono<AdminEnv>;
29
22
  export {};
30
23
  //# sourceMappingURL=admin-maintenance.d.ts.map
@@ -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
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Caller identity for orchestrator HTTP routes that act on behalf of the
3
+ * person or tool presenting a credential.
4
+ *
5
+ * Today the one credential is an admin token, resolved through the shared
6
+ * bearer-auth boundary (`resolveBearerAuth`), so the 401 / 503 semantics are
7
+ * identical to every admin route. The caller is a tagged union so a later
8
+ * credential kind (a signed command, for one) joins as another variant without
9
+ * touching the routes that consume it.
10
+ */
11
+ import type { Context } from 'hono';
12
+ import { type ActorPrincipal } from '@kici-dev/engine';
13
+ import { type BearerAuthDeps } from './admin-auth.js';
14
+ import type { Role } from '../secrets/rbac.js';
15
+ /** A caller authenticated by an admin token. */
16
+ export interface TokenCaller {
17
+ kind: 'token';
18
+ tokenId: string;
19
+ label: string;
20
+ /** The intended holder recorded at `token create --subject`, or null. */
21
+ subject: string | null;
22
+ role: Role;
23
+ /** The single routing key a scoped token is restricted to, or null. */
24
+ routingKeyScope: string | null;
25
+ }
26
+ export type CallerOutcome = {
27
+ ok: true;
28
+ caller: TokenCaller;
29
+ } | {
30
+ ok: false;
31
+ status: 401 | 403 | 503;
32
+ error: string;
33
+ };
34
+ /**
35
+ * Resolve the request's caller.
36
+ *
37
+ * @param c - The request context (the `Authorization` header is read).
38
+ * @param deps - The token validator and log scope, as for `resolveBearerAuth`.
39
+ * @param opts.requireUnscoped - Refuse a routing-key-scoped token with 403.
40
+ * Routes whose routing key the server chooses set it: a scoped token has no
41
+ * key of its own to compare there, so accepting it would widen its reach.
42
+ * @returns The caller, or the status and body to answer with.
43
+ */
44
+ export declare function resolveCaller(c: Context<any>, deps: BearerAuthDeps, opts: {
45
+ requireUnscoped: boolean;
46
+ }): Promise<CallerOutcome>;
47
+ /**
48
+ * The principal a caller's actions are attributed to: a `service_account`
49
+ * bearing the admin token id, the same shape the admin held-run routes use.
50
+ */
51
+ export declare function callerActor(caller: TokenCaller): ActorPrincipal;
52
+ //# sourceMappingURL=caller-identity.d.ts.map
@@ -0,0 +1,46 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { OrchestratorMode } from '@kici-dev/engine';
3
+ import type { Database } from '../db/types.js';
4
+ import type { RbacEnforcer } from '../secrets/rbac.js';
5
+ import { type TestRelayHandlerDeps } from '../ws/test-relay-handlers.js';
6
+ import type { AuthTokenValidator } from './admin-auth.js';
7
+ import { type TokenCaller } from './caller-identity.js';
8
+ type TestDirectEnv = {
9
+ Variables: {
10
+ caller: TokenCaller;
11
+ };
12
+ };
13
+ /** Answer for a Platform-connected orchestrator that has no org yet. */
14
+ export declare const NO_PLATFORM_ORG_MESSAGE = "This orchestrator has not received its organization from the KiCI Platform yet, so it cannot choose where to run the test. Retry when the orchestrator is connected.";
15
+ export interface TestDirectRouteDeps {
16
+ tokenManager: AuthTokenValidator;
17
+ rbac: RbacEnforcer;
18
+ mode: OrchestratorMode;
19
+ /** The org a connected orchestrator learned from the Platform; read per request. */
20
+ platformOrgId: () => string | null | undefined;
21
+ db: Kysely<Database>;
22
+ /** Builds the relay handlers' deps for one request (minus org, routing key and source). */
23
+ relayDeps: () => Omit<TestRelayHandlerDeps, 'orgId' | 'routingKey' | 'accessLogSource'>;
24
+ }
25
+ /**
26
+ * The org a direct test run belongs to: the default org on an independent
27
+ * orchestrator, the Platform-assigned org otherwise (null until it is known).
28
+ */
29
+ export declare function directOrgId(mode: OrchestratorMode, platformOrgId: string | null | undefined): string | null;
30
+ /**
31
+ * Build the route deps, or null when admin auth is not configured: without a
32
+ * token store there is no credential to authenticate a developer with.
33
+ */
34
+ export declare function testDirectRouteDeps(input: {
35
+ adminDeps?: {
36
+ tokenManager: AuthTokenValidator;
37
+ rbac: RbacEnforcer;
38
+ };
39
+ }, rest: Omit<TestDirectRouteDeps, 'tokenManager' | 'rbac'>): TestDirectRouteDeps | null;
40
+ /**
41
+ * Build the direct test-run router: the routes under `/api/v1/test`, each
42
+ * behind admin-token authentication that refuses a routing-key-scoped token.
43
+ */
44
+ export declare function createTestDirectRoutes(deps: TestDirectRouteDeps): import("hono").Hono<TestDirectEnv, import("hono/types").BlankSchema, "/">;
45
+ export {};
46
+ //# sourceMappingURL=test-direct.d.ts.map