@kici-dev/orchestrator 0.0.0 → 0.1.1

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 (342) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -6
  3. package/dist/__test-helpers__/mock-db.d.ts +103 -0
  4. package/dist/__test-helpers__/mock-ws.d.ts +13 -0
  5. package/dist/agent/dispatcher.d.ts +231 -0
  6. package/dist/agent/ownership-tracker.d.ts +46 -0
  7. package/dist/agent/registry.d.ts +255 -0
  8. package/dist/agent/token-store.d.ts +96 -0
  9. package/dist/app.d.ts +234 -0
  10. package/dist/audit/access-log.d.ts +92 -0
  11. package/dist/audit/sampling-rate-limiter.d.ts +41 -0
  12. package/dist/cache/build-coordinator.d.ts +42 -0
  13. package/dist/cache/dep-cache.d.ts +51 -0
  14. package/dist/cache/index.d.ts +16 -0
  15. package/dist/cache/pending-builds.d.ts +14 -0
  16. package/dist/cache/pending-dynamics.d.ts +15 -0
  17. package/dist/cache/pending-inits.d.ts +19 -0
  18. package/dist/cache/pending-tracker.d.ts +65 -0
  19. package/dist/cache/source-cache.d.ts +30 -0
  20. package/dist/cli/api-client.d.ts +411 -0
  21. package/dist/cli/commands/access-log.d.ts +30 -0
  22. package/dist/cli/commands/agent-service/index.d.ts +15 -0
  23. package/dist/cli/commands/agent-service/install.d.ts +9 -0
  24. package/dist/cli/commands/agent-service/logs.d.ts +9 -0
  25. package/dist/cli/commands/agent-service/restart.d.ts +8 -0
  26. package/dist/cli/commands/agent-service/start.d.ts +8 -0
  27. package/dist/cli/commands/agent-service/status.d.ts +10 -0
  28. package/dist/cli/commands/agent-service/stop.d.ts +8 -0
  29. package/dist/cli/commands/agent-service/uninstall.d.ts +9 -0
  30. package/dist/cli/commands/agent-service/upgrade.d.ts +11 -0
  31. package/dist/cli/commands/agent.d.ts +10 -0
  32. package/dist/cli/commands/api-key.d.ts +12 -0
  33. package/dist/cli/commands/audit.d.ts +9 -0
  34. package/dist/cli/commands/backend.d.ts +17 -0
  35. package/dist/cli/commands/cold-store-impl.d.ts +101 -0
  36. package/dist/cli/commands/cold-store.d.ts +30 -0
  37. package/dist/cli/commands/config.d.ts +16 -0
  38. package/dist/cli/commands/db.d.ts +19 -0
  39. package/dist/cli/commands/debug-bundle.d.ts +16 -0
  40. package/dist/cli/commands/diagnose.d.ts +15 -0
  41. package/dist/cli/commands/environment.d.ts +24 -0
  42. package/dist/cli/commands/event-dlq.d.ts +19 -0
  43. package/dist/cli/commands/event-log.d.ts +27 -0
  44. package/dist/cli/commands/event.d.ts +4 -0
  45. package/dist/cli/commands/execution.d.ts +17 -0
  46. package/dist/cli/commands/inspect-bundle.d.ts +16 -0
  47. package/dist/cli/commands/maintenance.d.ts +4 -0
  48. package/dist/cli/commands/orchestrator-service/index.d.ts +12 -0
  49. package/dist/cli/commands/orchestrator-service/install.d.ts +10 -0
  50. package/dist/cli/commands/orchestrator-service/logs.d.ts +10 -0
  51. package/dist/cli/commands/orchestrator-service/restart.d.ts +8 -0
  52. package/dist/cli/commands/orchestrator-service/start.d.ts +8 -0
  53. package/dist/cli/commands/orchestrator-service/status.d.ts +10 -0
  54. package/dist/cli/commands/orchestrator-service/stop.d.ts +8 -0
  55. package/dist/cli/commands/orchestrator-service/uninstall.d.ts +9 -0
  56. package/dist/cli/commands/orchestrator-service/upgrade.d.ts +12 -0
  57. package/dist/cli/commands/org-settings.d.ts +17 -0
  58. package/dist/cli/commands/peer.d.ts +13 -0
  59. package/dist/cli/commands/queue.d.ts +16 -0
  60. package/dist/cli/commands/registration.d.ts +18 -0
  61. package/dist/cli/commands/rotate.d.ts +9 -0
  62. package/dist/cli/commands/runs.d.ts +34 -0
  63. package/dist/cli/commands/secret.d.ts +12 -0
  64. package/dist/cli/commands/shared/db.d.ts +16 -0
  65. package/dist/cli/commands/shared/versioned-upgrade.d.ts +38 -0
  66. package/dist/cli/commands/source.d.ts +24 -0
  67. package/dist/cli/commands/token.d.ts +10 -0
  68. package/dist/cli/commands/workflow.d.ts +31 -0
  69. package/dist/cli/join.d.ts +14 -0
  70. package/dist/cli/kici-admin.d.ts +13 -0
  71. package/dist/cli/lazy-deps/cache.d.ts +17 -0
  72. package/dist/cli/lazy-deps/downloader.d.ts +33 -0
  73. package/dist/cli/lazy-deps/registry.d.ts +43 -0
  74. package/dist/cli/service/compose.d.ts +25 -0
  75. package/dist/cli/service/index.d.ts +24 -0
  76. package/dist/cli/service/launchd.d.ts +34 -0
  77. package/dist/cli/service/platform-detect.d.ts +59 -0
  78. package/dist/cli/service/systemd.d.ts +41 -0
  79. package/dist/cli/service/types.d.ts +91 -0
  80. package/dist/cli/service/windows.d.ts +20 -0
  81. package/dist/cli/wizard/agent-wizard.d.ts +24 -0
  82. package/dist/cli/wizard/orchestrator-wizard.d.ts +38 -0
  83. package/dist/cli/wizard/prompts.d.ts +23 -0
  84. package/dist/cli.js +11435 -0
  85. package/dist/cluster/cluster-identity.d.ts +59 -0
  86. package/dist/cluster/coordinator.d.ts +204 -0
  87. package/dist/cluster/health-api.d.ts +30 -0
  88. package/dist/cluster/index.d.ts +24 -0
  89. package/dist/cluster/join-client.d.ts +75 -0
  90. package/dist/cluster/join-handler.d.ts +58 -0
  91. package/dist/cluster/join-token.d.ts +94 -0
  92. package/dist/cluster/orphan-recovery.d.ts +67 -0
  93. package/dist/cluster/peer-client.d.ts +190 -0
  94. package/dist/cluster/peer-credentials.d.ts +108 -0
  95. package/dist/cluster/peer-crypto.d.ts +57 -0
  96. package/dist/cluster/peer-handler.d.ts +97 -0
  97. package/dist/cluster/peer-registry.d.ts +186 -0
  98. package/dist/cluster/raft-state.d.ts +36 -0
  99. package/dist/cluster/raft.d.ts +140 -0
  100. package/dist/cold-store/load-access-log-range.d.ts +73 -0
  101. package/dist/cold-store/load-event-log-range.d.ts +62 -0
  102. package/dist/cold-store/load-secret-audit-log-range.d.ts +38 -0
  103. package/dist/cold-store/orchestrator-cold-store.d.ts +58 -0
  104. package/dist/cold-store/tables/access-log.d.ts +80 -0
  105. package/dist/cold-store/tables/event-log.d.ts +70 -0
  106. package/dist/cold-store/tables/execution-jobs.d.ts +63 -0
  107. package/dist/cold-store/tables/execution-runs.d.ts +81 -0
  108. package/dist/cold-store/tables/execution-steps.d.ts +65 -0
  109. package/dist/cold-store/tables/secret-audit-log.d.ts +77 -0
  110. package/dist/concurrency/dispatch-next-queued.d.ts +63 -0
  111. package/dist/concurrency/group-tracker.d.ts +51 -0
  112. package/dist/concurrency/index.d.ts +3 -0
  113. package/dist/concurrency/queue-manager.d.ts +68 -0
  114. package/dist/concurrency/waiters.d.ts +58 -0
  115. package/dist/config/encryption.d.ts +82 -0
  116. package/dist/config/env-overlay.d.ts +45 -0
  117. package/dist/config/index.d.ts +16 -0
  118. package/dist/config/loader.d.ts +26 -0
  119. package/dist/config/reload.d.ts +113 -0
  120. package/dist/config/resolver.d.ts +47 -0
  121. package/dist/config/schema.d.ts +210 -0
  122. package/dist/config/shared-store.d.ts +142 -0
  123. package/dist/config/types.d.ts +218 -0
  124. package/dist/config.d.ts +249 -0
  125. package/dist/cron/cron-scheduler.d.ts +78 -0
  126. package/dist/cron/cron-store.d.ts +38 -0
  127. package/dist/dashboard/handler.d.ts +243 -0
  128. package/dist/db/client.d.ts +13 -0
  129. package/dist/db/migration-provider.d.ts +9 -0
  130. package/dist/db/migrations/001_initial.d.ts +8 -0
  131. package/dist/db/migrations/002_config_versions_key_version.d.ts +16 -0
  132. package/dist/db/migrations/003_access_log.d.ts +26 -0
  133. package/dist/db/migrations/004_rename_bundle_to_source.d.ts +19 -0
  134. package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +19 -0
  135. package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +38 -0
  136. package/dist/db/migrations/007_audit_logs_archived_at.d.ts +42 -0
  137. package/dist/db/migrations/008_event_log_archived_at.d.ts +40 -0
  138. package/dist/db/migrations/009_access_log_trigram.d.ts +15 -0
  139. package/dist/db/migrations/010_cold_store_chunks.d.ts +34 -0
  140. package/dist/db/migrations/011_drop_source_secrets_notify.d.ts +21 -0
  141. package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +28 -0
  142. package/dist/db/migrations/013_execution_log_bytes.d.ts +21 -0
  143. package/dist/db/migrations/014_kici_events_lease_retry.d.ts +36 -0
  144. package/dist/db/migrations/015_org_settings_customer_scoped.d.ts +30 -0
  145. package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +15 -0
  146. package/dist/db/migrations/017_org_id_widen.d.ts +4 -0
  147. package/dist/db/migrations/018_org_id_prefix_backfill.d.ts +4 -0
  148. package/dist/db/migrator.d.ts +32 -0
  149. package/dist/db/types.d.ts +1266 -0
  150. package/dist/diagnostics/bundle-reader.d.ts +48 -0
  151. package/dist/diagnostics/bundle-writer.d.ts +57 -0
  152. package/dist/diagnostics/checks/agents.d.ts +10 -0
  153. package/dist/diagnostics/checks/certs.d.ts +9 -0
  154. package/dist/diagnostics/checks/config.d.ts +10 -0
  155. package/dist/diagnostics/checks/db.d.ts +9 -0
  156. package/dist/diagnostics/checks/disk.d.ts +9 -0
  157. package/dist/diagnostics/checks/index.d.ts +17 -0
  158. package/dist/diagnostics/checks/ws.d.ts +9 -0
  159. package/dist/diagnostics/index.d.ts +13 -0
  160. package/dist/diagnostics/runner.d.ts +23 -0
  161. package/dist/diagnostics/types.d.ts +38 -0
  162. package/dist/entry-helpers.d.ts +93 -0
  163. package/dist/environments/binding-store.d.ts +27 -0
  164. package/dist/environments/environment-store.d.ts +74 -0
  165. package/dist/environments/held-runs.d.ts +64 -0
  166. package/dist/environments/index.d.ts +10 -0
  167. package/dist/environments/protection/branch-gate.d.ts +5 -0
  168. package/dist/environments/protection/concurrency-gate.d.ts +7 -0
  169. package/dist/environments/protection/pipeline.d.ts +18 -0
  170. package/dist/environments/protection/reviewer-gate.d.ts +7 -0
  171. package/dist/environments/protection/trust-gate.d.ts +7 -0
  172. package/dist/environments/protection/wait-timer-gate.d.ts +7 -0
  173. package/dist/environments/variable-store.d.ts +39 -0
  174. package/dist/events/circuit-breaker.d.ts +33 -0
  175. package/dist/events/event-emitter.d.ts +55 -0
  176. package/dist/events/event-retry-scanner.d.ts +52 -0
  177. package/dist/events/event-router.d.ts +183 -0
  178. package/dist/events/event-store.d.ts +157 -0
  179. package/dist/events/trust-store.d.ts +54 -0
  180. package/dist/events/types.d.ts +61 -0
  181. package/dist/helpers/ip-extraction.d.ts +29 -0
  182. package/dist/helpers/rate-limiter.d.ts +23 -0
  183. package/dist/index.d.ts +7 -0
  184. package/dist/index.js +772 -0
  185. package/dist/lockfile-cache.d.ts +39 -0
  186. package/dist/metrics/agent-metrics-aggregator.d.ts +116 -0
  187. package/dist/metrics/metrics-reporter.d.ts +40 -0
  188. package/dist/metrics/prometheus.d.ts +261 -0
  189. package/dist/metrics/scheduled-jobs.d.ts +20 -0
  190. package/dist/orchestrator-core.d.ts +193 -0
  191. package/dist/pipeline/dispatch-matched-workflow.d.ts +102 -0
  192. package/dist/pipeline/inline-eval.d.ts +28 -0
  193. package/dist/pipeline/install-secrets-resolver.d.ts +73 -0
  194. package/dist/pipeline/manual-schedule.d.ts +21 -0
  195. package/dist/pipeline/needs-scheduler.d.ts +85 -0
  196. package/dist/pipeline/process-webhook.d.ts +38 -0
  197. package/dist/pipeline/processor.d.ts +326 -0
  198. package/dist/pipeline/rerun.d.ts +79 -0
  199. package/dist/pipeline/test-pipeline.d.ts +110 -0
  200. package/dist/provider-registry.d.ts +122 -0
  201. package/dist/providers/generic/index.d.ts +23 -0
  202. package/dist/providers/generic/normalizer.d.ts +112 -0
  203. package/dist/providers/generic/verification.d.ts +47 -0
  204. package/dist/providers/github/auth.d.ts +60 -0
  205. package/dist/providers/github/changed-files.d.ts +51 -0
  206. package/dist/providers/github/check-status-poster.d.ts +35 -0
  207. package/dist/providers/github/contributor-resolver.d.ts +30 -0
  208. package/dist/providers/github/index.d.ts +20 -0
  209. package/dist/providers/github/lock-file.d.ts +32 -0
  210. package/dist/providers/github/normalizer.d.ts +103 -0
  211. package/dist/providers/github/repo-url.d.ts +35 -0
  212. package/dist/providers/internal/index.d.ts +32 -0
  213. package/dist/providers/internal/lock-file-fetcher.d.ts +34 -0
  214. package/dist/providers/internal/normalizer.d.ts +89 -0
  215. package/dist/providers/internal/repo-url-builder.d.ts +42 -0
  216. package/dist/providers/universal-git/changed-files.d.ts +42 -0
  217. package/dist/providers/universal-git/clone-token.d.ts +83 -0
  218. package/dist/providers/universal-git/config.d.ts +192 -0
  219. package/dist/providers/universal-git/index.d.ts +55 -0
  220. package/dist/providers/universal-git/lock-file.d.ts +71 -0
  221. package/dist/providers/universal-git/normalizer.d.ts +90 -0
  222. package/dist/providers/universal-git/repo-url.d.ts +50 -0
  223. package/dist/providers/universal-git/ssh-auth.d.ts +94 -0
  224. package/dist/queue/bootstrap.d.ts +50 -0
  225. package/dist/queue/cleanup.d.ts +41 -0
  226. package/dist/queue/depth-refresher.d.ts +65 -0
  227. package/dist/queue/job-queue.d.ts +343 -0
  228. package/dist/queue/scheduled-job.d.ts +91 -0
  229. package/dist/registration/extractor.d.ts +44 -0
  230. package/dist/registration/registration-index.d.ts +162 -0
  231. package/dist/registration/registration-store.d.ts +111 -0
  232. package/dist/reporting/check-run-summary.d.ts +102 -0
  233. package/dist/reporting/commit-status.d.ts +382 -0
  234. package/dist/reporting/execution-tracker.d.ts +538 -0
  235. package/dist/reporting/fs-log-storage.d.ts +41 -0
  236. package/dist/reporting/log-pull-handler.d.ts +35 -0
  237. package/dist/reporting/log-storage.d.ts +70 -0
  238. package/dist/reporting/log-writer.d.ts +45 -0
  239. package/dist/reporting/s3-log-storage.d.ts +42 -0
  240. package/dist/reporting/step-log-buffer.d.ts +57 -0
  241. package/dist/routes/admin-access-log.d.ts +34 -0
  242. package/dist/routes/admin-backends.d.ts +28 -0
  243. package/dist/routes/admin-config.d.ts +57 -0
  244. package/dist/routes/admin-db.d.ts +20 -0
  245. package/dist/routes/admin-environments.d.ts +42 -0
  246. package/dist/routes/admin-errors.d.ts +4 -0
  247. package/dist/routes/admin-event-dlq.d.ts +39 -0
  248. package/dist/routes/admin-event-log.d.ts +42 -0
  249. package/dist/routes/admin-events.d.ts +46 -0
  250. package/dist/routes/admin-maintenance.d.ts +22 -0
  251. package/dist/routes/admin-org-settings.d.ts +29 -0
  252. package/dist/routes/admin-queue-execution.d.ts +27 -0
  253. package/dist/routes/admin-registrations.d.ts +37 -0
  254. package/dist/routes/admin-runs.d.ts +57 -0
  255. package/dist/routes/admin-scheduled-jobs.d.ts +36 -0
  256. package/dist/routes/admin-sources.d.ts +18 -0
  257. package/dist/routes/admin.d.ts +103 -0
  258. package/dist/routes/capabilities.d.ts +24 -0
  259. package/dist/routes/diagnostics.d.ts +16 -0
  260. package/dist/routes/health.d.ts +20 -0
  261. package/dist/routes/test-trigger.d.ts +41 -0
  262. package/dist/routes/uploads.d.ts +38 -0
  263. package/dist/routes/webhooks.d.ts +36 -0
  264. package/dist/scaler/bare-metal-backend.d.ts +107 -0
  265. package/dist/scaler/config.d.ts +303 -0
  266. package/dist/scaler/container-backend.d.ts +125 -0
  267. package/dist/scaler/file-tail.d.ts +23 -0
  268. package/dist/scaler/firecracker-api.d.ts +100 -0
  269. package/dist/scaler/firecracker-backend.d.ts +263 -0
  270. package/dist/scaler/index.d.ts +24 -0
  271. package/dist/scaler/ip-allocator.d.ts +177 -0
  272. package/dist/scaler/label-matcher.d.ts +73 -0
  273. package/dist/scaler/log-forwarder.d.ts +54 -0
  274. package/dist/scaler/machine-ledger.d.ts +160 -0
  275. package/dist/scaler/manager.d.ts +338 -0
  276. package/dist/scaler/nftables.d.ts +85 -0
  277. package/dist/scaler/types.d.ts +388 -0
  278. package/dist/scaler/warm-pool.d.ts +81 -0
  279. package/dist/secrets/audit-logger.d.ts +65 -0
  280. package/dist/secrets/backend-health.d.ts +60 -0
  281. package/dist/secrets/backend-registry.d.ts +68 -0
  282. package/dist/secrets/backend-sync.d.ts +40 -0
  283. package/dist/secrets/cleanup.d.ts +40 -0
  284. package/dist/secrets/config.d.ts +51 -0
  285. package/dist/secrets/crypto.d.ts +49 -0
  286. package/dist/secrets/ephemeral-keys.d.ts +49 -0
  287. package/dist/secrets/index.d.ts +17 -0
  288. package/dist/secrets/pg-secret-store.d.ts +105 -0
  289. package/dist/secrets/rbac.d.ts +47 -0
  290. package/dist/secrets/secret-output-store.d.ts +46 -0
  291. package/dist/secrets/secret-resolver.d.ts +137 -0
  292. package/dist/secrets/source-credentials.d.ts +61 -0
  293. package/dist/secrets/token-manager.d.ts +63 -0
  294. package/dist/secrets/vault-secret-store.d.ts +85 -0
  295. package/dist/security/comment-handler.d.ts +67 -0
  296. package/dist/security/contributor-cache.d.ts +75 -0
  297. package/dist/security/global-workflow-policy.d.ts +72 -0
  298. package/dist/security/lock-source.d.ts +34 -0
  299. package/dist/security/trust-resolver.d.ts +108 -0
  300. package/dist/security/workflow-diff.d.ts +26 -0
  301. package/dist/server.d.ts +17 -0
  302. package/dist/server.js +48055 -0
  303. package/dist/sources/index.d.ts +10 -0
  304. package/dist/sources/source-manager.d.ts +63 -0
  305. package/dist/sources/source-store.d.ts +79 -0
  306. package/dist/sources/source-validator.d.ts +16 -0
  307. package/dist/stale-detector/stale-run-detector.d.ts +109 -0
  308. package/dist/standalone.d.ts +20 -0
  309. package/dist/standalone.js +41546 -0
  310. package/dist/storage/blob-routes.d.ts +20 -0
  311. package/dist/storage/filesystem.d.ts +60 -0
  312. package/dist/storage/index.d.ts +20 -0
  313. package/dist/storage/s3.d.ts +68 -0
  314. package/dist/storage/sign-url.d.ts +45 -0
  315. package/dist/storage/types.d.ts +98 -0
  316. package/dist/webhook/dedup.d.ts +44 -0
  317. package/dist/webhook/event-log.d.ts +83 -0
  318. package/dist/webhook/generic-sources.d.ts +169 -0
  319. package/dist/webhook/handler.d.ts +23 -0
  320. package/dist/webhook/relay-buffer.d.ts +96 -0
  321. package/dist/webhook/verify-inbound.d.ts +78 -0
  322. package/dist/worker/in-memory-execution-tracker.d.ts +94 -0
  323. package/dist/worker/in-memory-job-queue.d.ts +74 -0
  324. package/dist/worker/static-agent-token-store.d.ts +58 -0
  325. package/dist/worker/worker-status.d.ts +36 -0
  326. package/dist/worker-core.d.ts +74 -0
  327. package/dist/ws/agent-api-registry.d.ts +49 -0
  328. package/dist/ws/agent-handler.d.ts +176 -0
  329. package/dist/ws/agent-heartbeat.d.ts +45 -0
  330. package/dist/ws/dashboard-backends-handler.d.ts +51 -0
  331. package/dist/ws/dashboard-diagnostics-handler.d.ts +56 -0
  332. package/dist/ws/dashboard-env-handler.d.ts +107 -0
  333. package/dist/ws/dashboard-global-workflows-handler.d.ts +72 -0
  334. package/dist/ws/dashboard-registrations-handler.d.ts +84 -0
  335. package/dist/ws/event-buffer.d.ts +16 -0
  336. package/dist/ws/observer-handler.d.ts +42 -0
  337. package/dist/ws/observer-registry.d.ts +88 -0
  338. package/dist/ws/platform-client.d.ts +270 -0
  339. package/dist/ws/server-options.d.ts +15 -0
  340. package/package.json +87 -6
  341. package/sbom.spdx.json +14370 -0
  342. package/index.js +0 -3
@@ -0,0 +1,96 @@
1
+ import { type Kysely } from 'kysely';
2
+ import type { Database, AgentTokenRow } from '../db/types.js';
3
+ /**
4
+ * Safe token row shape returned from list/validate (excludes token_hash).
5
+ */
6
+ export type SafeAgentTokenRow = Omit<AgentTokenRow, 'token_hash'>;
7
+ /**
8
+ * Manages agent authentication tokens.
9
+ *
10
+ * Tokens are kat_ + 64 hex chars (32 random bytes = 256 bits).
11
+ * Only the SHA-256 hash is stored; the plaintext is returned once at generation time.
12
+ */
13
+ export declare class AgentTokenStore {
14
+ private readonly db;
15
+ constructor(db: Kysely<Database>);
16
+ /**
17
+ * Create a static (long-lived) agent token.
18
+ *
19
+ * Static tokens have no expiry and are intended for manually-registered agents.
20
+ *
21
+ * @param opts.labels - Optional agent labels this token is authorized for.
22
+ * @param opts.createdBy - Optional creator identifier (e.g. "cli:admin").
23
+ * @returns The plaintext token (shown once) and the DB row ID.
24
+ */
25
+ createStatic(opts: {
26
+ labels?: string[];
27
+ createdBy?: string;
28
+ }): Promise<{
29
+ token: string;
30
+ id: string;
31
+ }>;
32
+ /**
33
+ * Create an ephemeral (short-lived) agent token.
34
+ *
35
+ * Ephemeral tokens are issued by the scaler for auto-provisioned agents
36
+ * and expire after the specified TTL.
37
+ *
38
+ * @param agentId - The agent ID this token is for (used as created_by).
39
+ * @param labels - Agent labels this token is authorized for.
40
+ * @param ttlMs - Time-to-live in milliseconds.
41
+ * @returns The plaintext token (shown once).
42
+ */
43
+ createEphemeral(agentId: string, labels: string[], ttlMs: number): Promise<string>;
44
+ /**
45
+ * Validate a plaintext token against stored hashes.
46
+ *
47
+ * Checks that the token exists, is not revoked, and has not expired.
48
+ * On success, fires a non-blocking update to last_seen_at.
49
+ *
50
+ * @param token - The plaintext token to validate.
51
+ * @returns The token row (without hash) if valid, null otherwise.
52
+ */
53
+ validate(token: string): Promise<SafeAgentTokenRow | null>;
54
+ /**
55
+ * Revoke a token by ID.
56
+ *
57
+ * Sets revoked_at to now. Returns true if the token was revoked,
58
+ * false if it was already revoked or not found.
59
+ *
60
+ * @param id - The token row ID to revoke.
61
+ * @returns True if the token was newly revoked.
62
+ */
63
+ revoke(id: string): Promise<boolean>;
64
+ /**
65
+ * List all non-revoked tokens (excludes token_hash for security).
66
+ *
67
+ * @param opts.agentType - Optional filter by agent type ('static' | 'ephemeral').
68
+ * @returns Array of token rows without the hash field.
69
+ */
70
+ list(opts?: {
71
+ agentType?: string;
72
+ }): Promise<SafeAgentTokenRow[]>;
73
+ /**
74
+ * Clean up expired ephemeral tokens.
75
+ *
76
+ * Deletes rows where `expires_at < now()` and `agent_type = 'ephemeral'`.
77
+ * Called periodically by the orchestrator (every 60s) to keep the
78
+ * table from growing without bound.
79
+ *
80
+ * Optional `onBeforeDelete` callback is invoked once with the list
81
+ * of expired token IDs **before** the DELETE runs. The orchestrator
82
+ * uses this to call `agentRegistry.disconnectByTokenId(id)` for
83
+ * each expired row, so any in-flight WS that survived the
84
+ * per-token kick timer (e.g. across a process restart that wiped
85
+ * the in-memory `tokenExpiryTimers` map) is still kicked. Closes
86
+ * the sister gap to the revocation finding.
87
+ *
88
+ * @param opts.onBeforeDelete - Optional sync/async callback invoked
89
+ * with expired token IDs before the DELETE.
90
+ * @returns Number of deleted rows.
91
+ */
92
+ cleanupExpired(opts?: {
93
+ onBeforeDelete?: (tokenIds: string[]) => void | Promise<void>;
94
+ }): Promise<number>;
95
+ }
96
+ //# sourceMappingURL=token-store.d.ts.map
package/dist/app.d.ts ADDED
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Hono application factory for the customer orchestrator.
3
+ *
4
+ * Creates the HTTP + WebSocket application with:
5
+ * - Agent WebSocket endpoint at /ws for agent connections
6
+ * - Webhook endpoint for direct webhook ingestion (Hybrid/Independent)
7
+ * - Source-tarball serve endpoint at /api/v1/cache/source/:hash
8
+ * - Health/readiness check endpoints
9
+ * - Prometheus metrics endpoint
10
+ * - Request ID and logging middleware
11
+ * - 25MB body size limit
12
+ *
13
+ * Pattern follows packages/platform/src/app.ts: returns { app, injectWebSocket }.
14
+ */
15
+ import type { Kysely } from 'kysely';
16
+ import type pg from 'pg';
17
+ import { type ColdStore } from '@kici-dev/shared';
18
+ import type { AppConfig } from './config.js';
19
+ import type { Database } from './db/types.js';
20
+ import type { AgentRegistry } from './agent/registry.js';
21
+ import type { Dispatcher } from './agent/dispatcher.js';
22
+ import type { RunCoordinator } from './cluster/coordinator.js';
23
+ import type { PeerRegistry } from './cluster/peer-registry.js';
24
+ import type { JobQueue } from './queue/job-queue.js';
25
+ import type { DedupCache } from './webhook/dedup.js';
26
+ import type { LockFileCache } from './lockfile-cache.js';
27
+ import type { PlatformClient } from './ws/platform-client.js';
28
+ import type { ScalerManager } from './scaler/manager.js';
29
+ import type { ProviderRegistry } from './provider-registry.js';
30
+ import type { SourceCache } from './cache/index.js';
31
+ import type { BuildCoordinator } from './cache/index.js';
32
+ import type { DepCache } from './cache/index.js';
33
+ import type { PendingBuildTracker } from './cache/index.js';
34
+ import type { PendingInitTracker } from './cache/index.js';
35
+ import type { PendingDynamicTracker } from './cache/index.js';
36
+ import type { CacheStorage } from './storage/types.js';
37
+ import { type CommitStatusReporter } from './reporting/commit-status.js';
38
+ import type { ExecutionTracker } from './reporting/execution-tracker.js';
39
+ import type { LogWriter } from './reporting/log-writer.js';
40
+ import type { LogStorage } from './reporting/log-storage.js';
41
+ import type { StepLogBuffer } from './reporting/step-log-buffer.js';
42
+ import type { SourceLocationData } from './reporting/check-run-summary.js';
43
+ import type { Hono as HonoType } from 'hono';
44
+ import type { PeerWsLike } from './cluster/peer-handler.js';
45
+ import type { PeerToPeerMessage } from '@kici-dev/engine';
46
+ import type { AgentTokenStore } from './agent/token-store.js';
47
+ import type { OwnershipTracker } from './agent/ownership-tracker.js';
48
+ import type { ObserverRegistry } from './ws/observer-registry.js';
49
+ import type { TokenManager } from './secrets/token-manager.js';
50
+ import type { SecretResolver } from './secrets/secret-resolver.js';
51
+ import { type AdminRouteDeps } from './routes/admin.js';
52
+ import type { RegistrationStore } from './registration/registration-store.js';
53
+ import type { RegistrationIndex } from './registration/registration-index.js';
54
+ import type { CronScheduler } from './cron/cron-scheduler.js';
55
+ import { type ConfigRouteDeps } from './routes/admin-config.js';
56
+ import type { ConcurrencyGroupTracker } from './concurrency/group-tracker.js';
57
+ import type { ConcurrencyQueueManager } from './concurrency/queue-manager.js';
58
+ import type { EventRouter } from './events/event-router.js';
59
+ import type { EventStore } from './events/event-store.js';
60
+ import type { EventEmitter } from './events/event-emitter.js';
61
+ import type { GlobalWorkflowPolicy } from './security/global-workflow-policy.js';
62
+ import type { EventLogWriter } from './webhook/event-log.js';
63
+ import type { AccessLogWriter } from './audit/access-log.js';
64
+ import type { GenericSourceManager } from './webhook/generic-sources.js';
65
+ import type { TrustStore } from './events/trust-store.js';
66
+ import type { EnvironmentStore } from './environments/environment-store.js';
67
+ import type { VariableStore } from './environments/variable-store.js';
68
+ import type { HeldRunStore } from './environments/held-runs.js';
69
+ import type { ContributorCache } from './security/contributor-cache.js';
70
+ import { AgentMetricsAggregator } from './metrics/agent-metrics-aggregator.js';
71
+ /**
72
+ * All dependencies needed to create the orchestrator Hono app.
73
+ */
74
+ export interface AppDependencies {
75
+ config: AppConfig;
76
+ db: Kysely<Database>;
77
+ pool: pg.Pool;
78
+ registry: AgentRegistry;
79
+ dispatcher: Dispatcher;
80
+ jobQueue: JobQueue;
81
+ dedup: DedupCache;
82
+ lockFileCache: LockFileCache;
83
+ providerRegistry: ProviderRegistry;
84
+ platformClient?: PlatformClient;
85
+ scalerManager?: ScalerManager;
86
+ /** Bundle cache for compiled workflow bundles. Optional — requires S3 storage. */
87
+ sourceCache?: SourceCache;
88
+ /** Build coordinator for deduplicating concurrent builds. Optional — requires bundle cache. */
89
+ buildCoordinator?: BuildCoordinator;
90
+ /** Dep cache for dependency tarballs. Optional — requires S3 storage. */
91
+ depCache?: DepCache;
92
+ /** Cache storage backend (S3) for metadata operations on upload completion. */
93
+ cacheStorage?: CacheStorage;
94
+ /**
95
+ * Filesystem cache backend handle. Only set when KICI_STORAGE_TYPE is
96
+ * `filesystem`. Drives the /api/v1/cache/blob/* HTTP route that serves and
97
+ * receives signed-URL blob traffic the filesystem backend mints.
98
+ */
99
+ fsCache?: {
100
+ basePath: string;
101
+ signingSecret: string;
102
+ ttlMs: number;
103
+ };
104
+ /** Pending build tracker for build-then-execute coordination. Optional — requires bundle cache. */
105
+ pendingBuilds?: PendingBuildTracker;
106
+ /** Pending init tracker for init-then-execute coordination. */
107
+ pendingInits?: PendingInitTracker;
108
+ /** Pending dynamic tracker for DynamicJobFn evaluation coordination. */
109
+ pendingDynamics?: PendingDynamicTracker;
110
+ /** Commit status reporter for setting pending/success/failure/error on commits. Optional. */
111
+ commitStatusReporter?: CommitStatusReporter;
112
+ /** Execution tracker for DB persistence of execution state. Optional — requires database. */
113
+ executionTracker?: ExecutionTracker;
114
+ /** Log writer for persisting agent log chunks. Optional — requires database. */
115
+ logWriter?: LogWriter;
116
+ /** Log storage backend for persisting webhook payloads and step logs. Optional — requires S3 storage. */
117
+ logStorage?: LogStorage;
118
+ /** Step log buffer for enriched check run summaries. Optional — requires execution tracker. */
119
+ stepLogBuffer?: StepLogBuffer;
120
+ /** Agent token store for validating agent auth tokens. Required when agentAuth='token'. */
121
+ tokenStore?: AgentTokenStore;
122
+ /** Job ownership tracker for validating agent messages. Optional — requires database. */
123
+ ownershipTracker?: OwnershipTracker;
124
+ /** Admin API route dependencies. Optional -- only mounted when secrets management is configured. */
125
+ adminDeps?: AdminRouteDeps;
126
+ /** Config admin API route dependencies. Optional -- mounted when config management is available. */
127
+ configRouteDeps?: ConfigRouteDeps;
128
+ /** Event router for internal event delivery. Optional -- if not set, event routing is inactive. */
129
+ eventRouter?: EventRouter;
130
+ /** Event store. Optional -- mounted when admin DLQ admin route should be available. */
131
+ eventStore?: EventStore;
132
+ /** Event emitter for system events (workflow/job complete). Optional -- if not set, system events are skipped. */
133
+ eventEmitter?: EventEmitter;
134
+ /** Generic webhook source manager. Optional -- if not set, generic webhooks are disabled. */
135
+ genericSourceManager?: GenericSourceManager;
136
+ /** Trust store for cross-repo event trust. Optional -- if not set, trust management admin routes are unavailable. */
137
+ trustStore?: TrustStore;
138
+ /** Observer registry for broadcasting status/log updates to CLI observers. Optional -- if not set, observer features are inactive. */
139
+ observerRegistry?: ObserverRegistry;
140
+ /** Token manager for authenticating test trigger and observer connections. Optional -- requires secrets subsystem. */
141
+ tokenManager?: TokenManager;
142
+ /** Secret resolver for test run secret context resolution. Optional -- if not set, test runs have no secret access. */
143
+ secretResolver?: SecretResolver;
144
+ /** Cron scheduler for refreshing last-fired cache after registration changes. Optional — requires database. */
145
+ cronScheduler?: CronScheduler;
146
+ /** Registration store for admin registration routes. Optional -- mounted when registration system is initialized. */
147
+ registrationStore?: RegistrationStore;
148
+ /** Registration index for admin registration routes. Optional -- mounted when registration system is initialized. */
149
+ registrationIndex?: RegistrationIndex;
150
+ /** Environment store for resolving environment configs. Optional -- if not set, environment resolution is inactive. */
151
+ environmentStore?: EnvironmentStore;
152
+ /** Variable store for resolving environment variables. Optional -- if not set, environment vars are not merged. */
153
+ variableStore?: VariableStore;
154
+ /** Held run store for persisting protection rule holds. Optional -- if not set, holds are not persisted. */
155
+ heldRunStore?: HeldRunStore;
156
+ /** Global workflow policy for org-level permission enforcement. Optional -- if not set, global workflows are dispatched without permission checks. */
157
+ globalWorkflowPolicy?: GlobalWorkflowPolicy;
158
+ /** Inbound webhook delivery log writer. Optional -- if not set, deliveries are not persisted to event_log. */
159
+ eventLogWriter?: EventLogWriter;
160
+ /** Cold-store handle (Phase E). Optional -- when present, admin event-log routes can serve archived rows. */
161
+ coldStore?: ColdStore | null;
162
+ /** Read + mutation attribution log writer. Optional -- if not set, access_log rows are not written. */
163
+ accessLogWriter?: AccessLogWriter;
164
+ /** In-memory concurrency group tracker. Optional -- if not set, concurrency is disabled. */
165
+ concurrencyTracker?: ConcurrencyGroupTracker;
166
+ /** DB-backed concurrency queue manager. Optional -- if not set, concurrency is disabled. */
167
+ concurrencyQueueManager?: ConcurrencyQueueManager;
168
+ /** Optional callback when agent sends encrypted secret outputs on job success. */
169
+ onSecretOutputs?: (runId: string, jobId: string, secretOutputs: Record<string, {
170
+ agentPublicKey: string;
171
+ encrypted: string;
172
+ }>) => Promise<void>;
173
+ /** Cluster health routes (Hono app). Always mounted (cluster always on). */
174
+ clusterHealthRoutes: HonoType;
175
+ /** Peer WS handler for incoming peer connections. Always mounted (cluster always on). */
176
+ peerHandler: {
177
+ handleConnection: (ws: PeerWsLike, remoteIp?: string) => void;
178
+ sendToPeer: (targetInstanceId: string, msg: PeerToPeerMessage) => boolean;
179
+ getConnectionCount: () => number;
180
+ };
181
+ /** Optional join handler for direct peer join requests. */
182
+ onJoinRequest?: (msg: import('@kici-dev/engine').JoinRequest) => Promise<import('@kici-dev/engine').JoinResponse>;
183
+ /** Optional callback when agent inventory changes (connect/disconnect). Triggers peer heartbeat broadcast. */
184
+ onAgentInventoryChanged?: () => void;
185
+ /** Run coordinator for multi-orch claim/reroute. Optional -- if not set, jobs dispatch locally. */
186
+ coordinator?: RunCoordinator;
187
+ /** Peer registry for aggregating infrastructure across cluster. Optional. */
188
+ peerRegistry?: PeerRegistry;
189
+ /** Contributor permission cache. Optional -- threaded through from server.ts
190
+ * so membership-related webhooks invalidate matching entries immediately
191
+ * (instead of waiting for the 15-minute TTL). */
192
+ contributorCache?: ContributorCache;
193
+ /**
194
+ * Shared aggregator for agent-pushed metrics. When omitted, app.ts
195
+ * constructs its own — kept optional so existing tests still work
196
+ * without touching every call site. Production wiring threads the
197
+ * subsystem-built instance through so the Platform-bound MetricsReporter
198
+ * can read the same store and Mimir gets agent metrics per-org.
199
+ */
200
+ agentMetricsAggregator?: AgentMetricsAggregator;
201
+ }
202
+ /**
203
+ * In-memory cache for step source locations extracted from lock files.
204
+ * Keyed by `workflowName:jobName`, stores source location arrays indexed by step index.
205
+ * Populated during webhook processing, used by CommitStatusReporter for annotations.
206
+ */
207
+ export declare class SourceLocationStore {
208
+ private readonly cache;
209
+ private key;
210
+ set(workflowName: string, jobName: string, locations: Array<SourceLocationData | undefined>): void;
211
+ get(workflowName: string, jobName: string): SourceLocationData[] | undefined;
212
+ }
213
+ /**
214
+ * Create Hono application with all routes and middleware.
215
+ *
216
+ * @param deps - Application dependencies (injected for testability)
217
+ * @returns Object with Hono app instance and injectWebSocket function
218
+ */
219
+ export declare function createApp(deps: AppDependencies): {
220
+ app: import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, import("hono/types").BlankSchema, string, string>;
221
+ injectWebSocket: (server: import("http").Server | import("http2").Http2Server | import("http2").Http2SecureServer) => void;
222
+ onSourceLocationsExtracted: (workflowName: string, jobName: string, locations: Array<{
223
+ file: string;
224
+ line: number;
225
+ column: number;
226
+ } | undefined>) => void;
227
+ /**
228
+ * Wake up the FIFO-next queued concurrency waiter for `(group, routingKey)`.
229
+ * Called by orchestrator-core when a slot is released (run completion,
230
+ * cancellation, supersession). No-op when concurrency is disabled.
231
+ */
232
+ tryDispatchNextQueued: ((group: string, routingKey: string) => Promise<void>) | undefined;
233
+ };
234
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1,92 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { type ColdStore } from '@kici-dev/shared';
3
+ import { type AccessLogAction, type AccessLogItem, type AccessLogOutcome, type AccessLogRateLimiter, type AccessLogSource, type AccessLogTargetType, type ActorPrincipal, type ActorType } from '@kici-dev/engine';
4
+ import type { Database } from '../db/types.js';
5
+ export interface AccessLogRecord {
6
+ orgId: string | null;
7
+ routingKey: string | null;
8
+ actor: ActorPrincipal;
9
+ action: AccessLogAction;
10
+ target: {
11
+ type: AccessLogTargetType;
12
+ id: string;
13
+ } | null;
14
+ requestId: string | null;
15
+ source: AccessLogSource;
16
+ outcome: AccessLogOutcome;
17
+ errorMessage?: string | null;
18
+ }
19
+ export interface AccessLogQueryFilter {
20
+ orgId?: string;
21
+ actorType?: ActorType;
22
+ actorId?: string;
23
+ action?: AccessLogAction;
24
+ source?: AccessLogSource;
25
+ outcome?: AccessLogOutcome;
26
+ targetType?: AccessLogTargetType;
27
+ targetId?: string;
28
+ fromTimestamp?: Date | string;
29
+ toTimestamp?: Date | string;
30
+ /** Full-text search over error_message (trigram-indexed). */
31
+ q?: string;
32
+ limit?: number;
33
+ cursor?: string;
34
+ }
35
+ export interface AccessLogQueryResult {
36
+ items: AccessLogItem[];
37
+ nextCursor: string | null;
38
+ }
39
+ /**
40
+ * Best-effort writer for the orchestrator `access_log` table. Records one
41
+ * row per read / orchestrator-admin mutation attributable to an
42
+ * ActorPrincipal. Callers get their actor from the incoming Platform proxy
43
+ * message (`msg.actor`) or from the admin HTTP auth chain.
44
+ *
45
+ * Failure mode: insert errors are logged and swallowed — a broken
46
+ * access_log table MUST NOT take down dashboard reads. Use `secret_audit_log`
47
+ * for the always-consistent secret mutation path; `access_log` is the
48
+ * read + broad-surface audit stream.
49
+ */
50
+ export declare class AccessLogWriter {
51
+ private readonly db;
52
+ private coldStore;
53
+ private readonly rateLimiter;
54
+ constructor(db: Kysely<Database>, coldStore?: ColdStore, rateLimiter?: AccessLogRateLimiter);
55
+ /**
56
+ * Late-binding setter for the cold-store handle. orchestrator-core
57
+ * builds AccessLogWriter before the cold-store singleton, then
58
+ * attaches it via this setter (mirrors AuditLogger.setColdStore).
59
+ */
60
+ setColdStore(coldStore: ColdStore | null): void;
61
+ record(entry: AccessLogRecord): Promise<void>;
62
+ /**
63
+ * Phase D: delegates to `loadAccessLogRange` so cold-store rows are
64
+ * merged transparently when pagination crosses the warm cutoff. The
65
+ * caller-visible `{items, nextCursor}` shape is preserved. NO
66
+ * --include-archived flag — access_log is "paginated/transparent"
67
+ * per design §7 row 11.
68
+ */
69
+ query(filter: AccessLogQueryFilter): Promise<AccessLogQueryResult>;
70
+ /**
71
+ * Detail lookup by row id. Hot first; on miss falls back to a single
72
+ * cold-store tenant scan filtering by `id`. Mirrors the
73
+ * `loadEventLogByDeliveryId` pattern in `load-event-log-range.ts` —
74
+ * cold-store is partitioned by `(tenant_id, day)` with no cross-tenant
75
+ * `id` index, so the caller MUST scope the cold scan to one tenant.
76
+ *
77
+ * `opts.orgId` supplies the tenant scope. When omitted, only the
78
+ * synthetic `__orchestrator__` tenant is scanned (matches the
79
+ * NULL-org_id rows the orchestrator itself emits via
80
+ * `cold-store-archive` / `cold-store-purge`). The CLI exposes this as
81
+ * `kici-admin access-log show <id> --org-id <orgId>`.
82
+ *
83
+ * Best-effort contract: a cold-store error logs a warn line and
84
+ * returns null, matching `loadAccessLogRange` and
85
+ * `loadEventLogByDeliveryId`. A transient S3 outage MUST NOT
86
+ * manufacture a misleading 404-vs-500 distinction at the HTTP layer.
87
+ */
88
+ getById(id: string, opts?: {
89
+ orgId?: string;
90
+ }): Promise<AccessLogItem | null>;
91
+ }
92
+ //# sourceMappingURL=access-log.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * In-memory rate limiter shared by AccessLogWriter and AuditLogger to enforce
3
+ * the per-action / per-actor caps defined in the engine's
4
+ * `POLICY_BY_ACTION` table (one row per minute per actor for diagnostics-class
5
+ * reads).
6
+ *
7
+ * Implementation: a single Map keyed by `${action}:${actorKey}` whose value
8
+ * is the last permit timestamp. The token bucket is implicit — a permit is
9
+ * granted iff `now - last >= floor(60_000 / perMinutePerActor)`. On each
10
+ * permit() call we lazily prune entries older than 5 minutes so memory
11
+ * stays bounded for long-lived orchestrators.
12
+ *
13
+ * Thread-safety: Node's single-threaded event loop guarantees the
14
+ * read-then-write below is atomic per call. No locking needed.
15
+ */
16
+ import type { AccessLogAction, AccessLogRateLimiter } from '@kici-dev/engine';
17
+ /**
18
+ * Implementation of `AccessLogRateLimiter` (engine interface). Constructed
19
+ * once per orchestrator process and injected into both
20
+ * `AccessLogWriter` and `AuditLogger`.
21
+ */
22
+ export declare class SamplingRateLimiter implements AccessLogRateLimiter {
23
+ private readonly buckets;
24
+ private readonly now;
25
+ private lastPruneAt;
26
+ /**
27
+ * @param now Time source override (test seam). Defaults to `Date.now`.
28
+ */
29
+ constructor(now?: () => number);
30
+ permit(action: AccessLogAction, actorKey: string, perMinute: number): boolean;
31
+ /**
32
+ * Drop entries older than PRUNE_TTL_MS. Called opportunistically from
33
+ * `permit()` so memory stays bounded without a background timer. With the
34
+ * 1-row/min/actor cap the map is naturally tiny (it grows by one entry
35
+ * per active actor and prunes after five minutes of silence).
36
+ */
37
+ private maybePrune;
38
+ /** Test-only: introspect the bucket size. */
39
+ size(): number;
40
+ }
41
+ //# sourceMappingURL=sampling-rate-limiter.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Build coordinator for coalescing concurrent build requests.
3
+ *
4
+ * Ensures only one build runs per content hash. Subsequent requests
5
+ * for the same hash coalesce on the same Promise, avoiding duplicate
6
+ * compilation work.
7
+ *
8
+ * On success: all waiters resolve.
9
+ * On failure: all waiters reject with the build error.
10
+ * On timeout: all waiters reject with a timeout error.
11
+ */
12
+ export declare class BuildCoordinator {
13
+ private readonly inFlight;
14
+ private readonly timeoutMs;
15
+ constructor(options?: {
16
+ timeoutMs?: number;
17
+ });
18
+ /**
19
+ * Ensure a build is running for the given content hash.
20
+ *
21
+ * If already in-flight, returns the existing promise (coalescing).
22
+ * If not, calls triggerBuild() and tracks the promise.
23
+ *
24
+ * @param contentHash - The content hash identifying the bundle to build
25
+ * @param triggerBuild - Async function that performs the actual build
26
+ */
27
+ ensureBuild(contentHash: string, triggerBuild: () => Promise<void>): Promise<void>;
28
+ /**
29
+ * Check if a build is currently in-flight for a content hash.
30
+ */
31
+ isBuilding(contentHash: string): boolean;
32
+ /**
33
+ * Get the number of in-flight builds (for metrics/debugging).
34
+ */
35
+ getInFlightCount(): number;
36
+ /**
37
+ * Run triggerBuild with a timeout. Rejects with a descriptive
38
+ * error if the build exceeds timeoutMs.
39
+ */
40
+ private runWithTimeout;
41
+ }
42
+ //# sourceMappingURL=build-coordinator.d.ts.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Dependency-specific cache layer wrapping CacheStorage.
3
+ *
4
+ * Stores and retrieves dependency tarballs keyed by lockfileHash + platform + arch.
5
+ * Shared CacheStorage backend with SourceCache (same S3 bucket).
6
+ * Refreshes TTL on reads (touch-on-read).
7
+ *
8
+ * Cache key format: deps/{platform}-{arch}/{lockfileHash}.tar.gz
9
+ */
10
+ import type { CacheStorage } from '../storage/types.js';
11
+ export declare class DepCache {
12
+ private readonly storage;
13
+ private readonly maxTarballBytes;
14
+ constructor(options: {
15
+ storage: CacheStorage;
16
+ maxTarballBytes?: number;
17
+ });
18
+ /** Check if a dep tarball exists in cache. */
19
+ has(lockfileHash: string, platform: string, arch: string): Promise<boolean>;
20
+ /**
21
+ * Get a pre-signed download URL for the dep tarball (for agent delivery).
22
+ * Refreshes TTL on hit.
23
+ */
24
+ getUrl(lockfileHash: string, platform: string, arch: string): Promise<string | null>;
25
+ /**
26
+ * Get a pre-signed download URL and the tarball content hash (if available).
27
+ * Returns null on cache miss. Hash may be undefined for old entries stored
28
+ * before integrity tracking was added.
29
+ */
30
+ getUrlAndHash(lockfileHash: string, platform: string, arch: string): Promise<{
31
+ url: string;
32
+ hash?: string;
33
+ } | null>;
34
+ /**
35
+ * Get a pre-signed upload URL for direct agent-to-S3 upload.
36
+ */
37
+ getUploadUrl(lockfileHash: string, platform: string, arch: string): Promise<string>;
38
+ /**
39
+ * Store a dep tarball in cache.
40
+ * Throws if tarball exceeds max size (per user decision).
41
+ */
42
+ store(lockfileHash: string, platform: string, arch: string, tarballData: Buffer): Promise<void>;
43
+ /**
44
+ * Compute SHA-256 hash of a tarball buffer.
45
+ * Used by build agents to compute the hash for depsHash protocol field.
46
+ */
47
+ static computeHash(data: Buffer): string;
48
+ /** Remove a dep tarball from cache. */
49
+ remove(lockfileHash: string, platform: string, arch: string): Promise<boolean>;
50
+ }
51
+ //# sourceMappingURL=dep-cache.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Cache module for customer-workflow source tarballs and dependency tarballs.
3
+ *
4
+ * SourceCache: content-hash-keyed storage for `.kici/` source tarballs
5
+ * (`source/{contentHash}.tar.gz`).
6
+ * BuildCoordinator: deduplicates concurrent build requests.
7
+ * DepCache: lockfileHash-keyed storage for dependency tarballs.
8
+ */
9
+ export { SourceCache } from './source-cache.js';
10
+ export { BuildCoordinator } from './build-coordinator.js';
11
+ export { DepCache } from './dep-cache.js';
12
+ export { PendingBuildTracker } from './pending-builds.js';
13
+ export { PendingInitTracker } from './pending-inits.js';
14
+ export type { InitResult } from './pending-inits.js';
15
+ export { PendingDynamicTracker } from './pending-dynamics.js';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Pending build tracker for coordinating build-then-execute pipeline.
3
+ *
4
+ * The orchestrator dispatches a build job and waits for the build agent to
5
+ * finish before retrieving cache URLs and dispatching execution jobs. The
6
+ * underlying tracker logic lives in `PendingTracker<void>`; this subclass
7
+ * just wires the build-specific logger prefix and disconnect error.
8
+ */
9
+ import { PendingTracker } from './pending-tracker.js';
10
+ export declare class PendingBuildTracker extends PendingTracker<void> {
11
+ constructor();
12
+ resolve(jobId: string): void;
13
+ }
14
+ //# sourceMappingURL=pending-builds.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Pending dynamic-eval tracker for coordinating DynamicJobFn evaluation pipeline.
3
+ *
4
+ * The orchestrator dispatches a dynamic eval job for runtime job generation and
5
+ * waits for the agent to evaluate the DynamicJobFn and return the generated
6
+ * `LockJob[]` array. The underlying tracker logic lives in
7
+ * `PendingTracker<LockJob[]>`; this subclass wires the dynamic-eval-specific
8
+ * logger prefix and disconnect error.
9
+ */
10
+ import type { LockJob } from '@kici-dev/engine';
11
+ import { PendingTracker } from './pending-tracker.js';
12
+ export declare class PendingDynamicTracker extends PendingTracker<LockJob[]> {
13
+ constructor();
14
+ }
15
+ //# sourceMappingURL=pending-dynamics.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Pending init tracker for coordinating init-then-execute pipeline.
3
+ *
4
+ * The orchestrator dispatches an init job for dynamic environment resolution
5
+ * and waits for the agent to return the resolved field values
6
+ * (environmentName, env, concurrencyGroup). The underlying tracker logic lives
7
+ * in `PendingTracker<InitResult>`; this subclass wires the init-specific
8
+ * logger prefix and disconnect error.
9
+ */
10
+ import { PendingTracker } from './pending-tracker.js';
11
+ export interface InitResult {
12
+ environmentName?: string;
13
+ env?: Record<string, string>;
14
+ concurrencyGroup?: string;
15
+ }
16
+ export declare class PendingInitTracker extends PendingTracker<InitResult> {
17
+ constructor();
18
+ }
19
+ //# sourceMappingURL=pending-inits.d.ts.map