@kici-dev/orchestrator 0.0.0 → 0.1.2
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.
- package/LICENSE +661 -0
- package/README.md +1 -6
- package/dist/__test-helpers__/mock-db.d.ts +103 -0
- package/dist/__test-helpers__/mock-ws.d.ts +13 -0
- package/dist/agent/dispatcher.d.ts +231 -0
- package/dist/agent/ownership-tracker.d.ts +46 -0
- package/dist/agent/registry.d.ts +255 -0
- package/dist/agent/token-store.d.ts +96 -0
- package/dist/app.d.ts +234 -0
- package/dist/audit/access-log.d.ts +92 -0
- package/dist/audit/sampling-rate-limiter.d.ts +41 -0
- package/dist/cache/build-coordinator.d.ts +42 -0
- package/dist/cache/dep-cache.d.ts +51 -0
- package/dist/cache/index.d.ts +16 -0
- package/dist/cache/pending-builds.d.ts +14 -0
- package/dist/cache/pending-dynamics.d.ts +15 -0
- package/dist/cache/pending-inits.d.ts +19 -0
- package/dist/cache/pending-tracker.d.ts +65 -0
- package/dist/cache/source-cache.d.ts +30 -0
- package/dist/cli/api-client.d.ts +411 -0
- package/dist/cli/commands/access-log.d.ts +30 -0
- package/dist/cli/commands/agent-service/index.d.ts +15 -0
- package/dist/cli/commands/agent-service/install.d.ts +9 -0
- package/dist/cli/commands/agent-service/logs.d.ts +9 -0
- package/dist/cli/commands/agent-service/restart.d.ts +8 -0
- package/dist/cli/commands/agent-service/start.d.ts +8 -0
- package/dist/cli/commands/agent-service/status.d.ts +10 -0
- package/dist/cli/commands/agent-service/stop.d.ts +8 -0
- package/dist/cli/commands/agent-service/uninstall.d.ts +9 -0
- package/dist/cli/commands/agent-service/upgrade.d.ts +11 -0
- package/dist/cli/commands/agent.d.ts +10 -0
- package/dist/cli/commands/api-key.d.ts +12 -0
- package/dist/cli/commands/audit.d.ts +9 -0
- package/dist/cli/commands/backend.d.ts +17 -0
- package/dist/cli/commands/cold-store-impl.d.ts +101 -0
- package/dist/cli/commands/cold-store.d.ts +30 -0
- package/dist/cli/commands/config.d.ts +16 -0
- package/dist/cli/commands/db.d.ts +19 -0
- package/dist/cli/commands/debug-bundle.d.ts +16 -0
- package/dist/cli/commands/diagnose.d.ts +15 -0
- package/dist/cli/commands/environment.d.ts +24 -0
- package/dist/cli/commands/event-dlq.d.ts +19 -0
- package/dist/cli/commands/event-log.d.ts +27 -0
- package/dist/cli/commands/event.d.ts +4 -0
- package/dist/cli/commands/execution.d.ts +17 -0
- package/dist/cli/commands/inspect-bundle.d.ts +16 -0
- package/dist/cli/commands/maintenance.d.ts +4 -0
- package/dist/cli/commands/orchestrator-service/index.d.ts +12 -0
- package/dist/cli/commands/orchestrator-service/install.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/logs.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/restart.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/start.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/status.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/stop.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/uninstall.d.ts +9 -0
- package/dist/cli/commands/orchestrator-service/upgrade.d.ts +12 -0
- package/dist/cli/commands/org-settings.d.ts +17 -0
- package/dist/cli/commands/peer.d.ts +13 -0
- package/dist/cli/commands/queue.d.ts +16 -0
- package/dist/cli/commands/registration.d.ts +18 -0
- package/dist/cli/commands/rotate.d.ts +9 -0
- package/dist/cli/commands/runs.d.ts +34 -0
- package/dist/cli/commands/secret.d.ts +12 -0
- package/dist/cli/commands/shared/db.d.ts +16 -0
- package/dist/cli/commands/shared/versioned-upgrade.d.ts +38 -0
- package/dist/cli/commands/source.d.ts +24 -0
- package/dist/cli/commands/token.d.ts +10 -0
- package/dist/cli/commands/workflow.d.ts +31 -0
- package/dist/cli/join.d.ts +14 -0
- package/dist/cli/kici-admin.d.ts +13 -0
- package/dist/cli/lazy-deps/cache.d.ts +17 -0
- package/dist/cli/lazy-deps/downloader.d.ts +33 -0
- package/dist/cli/lazy-deps/registry.d.ts +43 -0
- package/dist/cli/service/compose.d.ts +25 -0
- package/dist/cli/service/index.d.ts +24 -0
- package/dist/cli/service/launchd.d.ts +34 -0
- package/dist/cli/service/platform-detect.d.ts +59 -0
- package/dist/cli/service/systemd.d.ts +41 -0
- package/dist/cli/service/types.d.ts +91 -0
- package/dist/cli/service/windows.d.ts +20 -0
- package/dist/cli/wizard/agent-wizard.d.ts +24 -0
- package/dist/cli/wizard/orchestrator-wizard.d.ts +38 -0
- package/dist/cli/wizard/prompts.d.ts +23 -0
- package/dist/cli.js +11435 -0
- package/dist/cluster/cluster-identity.d.ts +59 -0
- package/dist/cluster/coordinator.d.ts +204 -0
- package/dist/cluster/health-api.d.ts +30 -0
- package/dist/cluster/index.d.ts +24 -0
- package/dist/cluster/join-client.d.ts +75 -0
- package/dist/cluster/join-handler.d.ts +58 -0
- package/dist/cluster/join-token.d.ts +94 -0
- package/dist/cluster/orphan-recovery.d.ts +67 -0
- package/dist/cluster/peer-client.d.ts +190 -0
- package/dist/cluster/peer-credentials.d.ts +108 -0
- package/dist/cluster/peer-crypto.d.ts +57 -0
- package/dist/cluster/peer-handler.d.ts +97 -0
- package/dist/cluster/peer-registry.d.ts +186 -0
- package/dist/cluster/raft-state.d.ts +36 -0
- package/dist/cluster/raft.d.ts +140 -0
- package/dist/cold-store/load-access-log-range.d.ts +73 -0
- package/dist/cold-store/load-event-log-range.d.ts +62 -0
- package/dist/cold-store/load-secret-audit-log-range.d.ts +38 -0
- package/dist/cold-store/orchestrator-cold-store.d.ts +58 -0
- package/dist/cold-store/tables/access-log.d.ts +80 -0
- package/dist/cold-store/tables/event-log.d.ts +70 -0
- package/dist/cold-store/tables/execution-jobs.d.ts +63 -0
- package/dist/cold-store/tables/execution-runs.d.ts +81 -0
- package/dist/cold-store/tables/execution-steps.d.ts +65 -0
- package/dist/cold-store/tables/secret-audit-log.d.ts +77 -0
- package/dist/concurrency/dispatch-next-queued.d.ts +63 -0
- package/dist/concurrency/group-tracker.d.ts +51 -0
- package/dist/concurrency/index.d.ts +3 -0
- package/dist/concurrency/queue-manager.d.ts +68 -0
- package/dist/concurrency/waiters.d.ts +58 -0
- package/dist/config/encryption.d.ts +82 -0
- package/dist/config/env-overlay.d.ts +45 -0
- package/dist/config/index.d.ts +16 -0
- package/dist/config/loader.d.ts +26 -0
- package/dist/config/reload.d.ts +113 -0
- package/dist/config/resolver.d.ts +47 -0
- package/dist/config/schema.d.ts +210 -0
- package/dist/config/shared-store.d.ts +142 -0
- package/dist/config/types.d.ts +218 -0
- package/dist/config.d.ts +249 -0
- package/dist/cron/cron-scheduler.d.ts +78 -0
- package/dist/cron/cron-store.d.ts +38 -0
- package/dist/dashboard/handler.d.ts +243 -0
- package/dist/db/client.d.ts +13 -0
- package/dist/db/migration-provider.d.ts +9 -0
- package/dist/db/migrations/001_initial.d.ts +8 -0
- package/dist/db/migrations/002_config_versions_key_version.d.ts +16 -0
- package/dist/db/migrations/003_access_log.d.ts +26 -0
- package/dist/db/migrations/004_rename_bundle_to_source.d.ts +19 -0
- package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +19 -0
- package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +38 -0
- package/dist/db/migrations/007_audit_logs_archived_at.d.ts +42 -0
- package/dist/db/migrations/008_event_log_archived_at.d.ts +40 -0
- package/dist/db/migrations/009_access_log_trigram.d.ts +15 -0
- package/dist/db/migrations/010_cold_store_chunks.d.ts +34 -0
- package/dist/db/migrations/011_drop_source_secrets_notify.d.ts +21 -0
- package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +28 -0
- package/dist/db/migrations/013_execution_log_bytes.d.ts +21 -0
- package/dist/db/migrations/014_kici_events_lease_retry.d.ts +36 -0
- package/dist/db/migrations/015_org_settings_customer_scoped.d.ts +30 -0
- package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +15 -0
- package/dist/db/migrations/017_org_id_widen.d.ts +4 -0
- package/dist/db/migrations/018_org_id_prefix_backfill.d.ts +4 -0
- package/dist/db/migrator.d.ts +32 -0
- package/dist/db/types.d.ts +1266 -0
- package/dist/diagnostics/bundle-reader.d.ts +48 -0
- package/dist/diagnostics/bundle-writer.d.ts +57 -0
- package/dist/diagnostics/checks/agents.d.ts +10 -0
- package/dist/diagnostics/checks/certs.d.ts +9 -0
- package/dist/diagnostics/checks/config.d.ts +10 -0
- package/dist/diagnostics/checks/db.d.ts +9 -0
- package/dist/diagnostics/checks/disk.d.ts +9 -0
- package/dist/diagnostics/checks/index.d.ts +17 -0
- package/dist/diagnostics/checks/ws.d.ts +9 -0
- package/dist/diagnostics/index.d.ts +13 -0
- package/dist/diagnostics/runner.d.ts +23 -0
- package/dist/diagnostics/types.d.ts +38 -0
- package/dist/entry-helpers.d.ts +93 -0
- package/dist/environments/binding-store.d.ts +27 -0
- package/dist/environments/environment-store.d.ts +74 -0
- package/dist/environments/held-runs.d.ts +64 -0
- package/dist/environments/index.d.ts +10 -0
- package/dist/environments/protection/branch-gate.d.ts +5 -0
- package/dist/environments/protection/concurrency-gate.d.ts +7 -0
- package/dist/environments/protection/pipeline.d.ts +18 -0
- package/dist/environments/protection/reviewer-gate.d.ts +7 -0
- package/dist/environments/protection/trust-gate.d.ts +7 -0
- package/dist/environments/protection/wait-timer-gate.d.ts +7 -0
- package/dist/environments/variable-store.d.ts +39 -0
- package/dist/events/circuit-breaker.d.ts +33 -0
- package/dist/events/event-emitter.d.ts +55 -0
- package/dist/events/event-retry-scanner.d.ts +52 -0
- package/dist/events/event-router.d.ts +183 -0
- package/dist/events/event-store.d.ts +157 -0
- package/dist/events/trust-store.d.ts +54 -0
- package/dist/events/types.d.ts +61 -0
- package/dist/helpers/ip-extraction.d.ts +29 -0
- package/dist/helpers/rate-limiter.d.ts +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +772 -0
- package/dist/lockfile-cache.d.ts +39 -0
- package/dist/metrics/agent-metrics-aggregator.d.ts +116 -0
- package/dist/metrics/metrics-reporter.d.ts +40 -0
- package/dist/metrics/prometheus.d.ts +261 -0
- package/dist/metrics/scheduled-jobs.d.ts +20 -0
- package/dist/orchestrator-core.d.ts +193 -0
- package/dist/pipeline/dispatch-matched-workflow.d.ts +102 -0
- package/dist/pipeline/inline-eval.d.ts +28 -0
- package/dist/pipeline/install-secrets-resolver.d.ts +73 -0
- package/dist/pipeline/manual-schedule.d.ts +21 -0
- package/dist/pipeline/needs-scheduler.d.ts +85 -0
- package/dist/pipeline/process-webhook.d.ts +38 -0
- package/dist/pipeline/processor.d.ts +326 -0
- package/dist/pipeline/rerun.d.ts +79 -0
- package/dist/pipeline/test-pipeline.d.ts +110 -0
- package/dist/provider-registry.d.ts +122 -0
- package/dist/providers/generic/index.d.ts +23 -0
- package/dist/providers/generic/normalizer.d.ts +112 -0
- package/dist/providers/generic/verification.d.ts +47 -0
- package/dist/providers/github/auth.d.ts +60 -0
- package/dist/providers/github/changed-files.d.ts +51 -0
- package/dist/providers/github/check-status-poster.d.ts +35 -0
- package/dist/providers/github/contributor-resolver.d.ts +30 -0
- package/dist/providers/github/index.d.ts +20 -0
- package/dist/providers/github/lock-file.d.ts +32 -0
- package/dist/providers/github/normalizer.d.ts +103 -0
- package/dist/providers/github/repo-url.d.ts +35 -0
- package/dist/providers/internal/index.d.ts +32 -0
- package/dist/providers/internal/lock-file-fetcher.d.ts +34 -0
- package/dist/providers/internal/normalizer.d.ts +89 -0
- package/dist/providers/internal/repo-url-builder.d.ts +42 -0
- package/dist/providers/universal-git/changed-files.d.ts +42 -0
- package/dist/providers/universal-git/clone-token.d.ts +83 -0
- package/dist/providers/universal-git/config.d.ts +192 -0
- package/dist/providers/universal-git/index.d.ts +55 -0
- package/dist/providers/universal-git/lock-file.d.ts +71 -0
- package/dist/providers/universal-git/normalizer.d.ts +90 -0
- package/dist/providers/universal-git/repo-url.d.ts +50 -0
- package/dist/providers/universal-git/ssh-auth.d.ts +94 -0
- package/dist/queue/bootstrap.d.ts +50 -0
- package/dist/queue/cleanup.d.ts +41 -0
- package/dist/queue/depth-refresher.d.ts +65 -0
- package/dist/queue/job-queue.d.ts +343 -0
- package/dist/queue/scheduled-job.d.ts +91 -0
- package/dist/registration/extractor.d.ts +44 -0
- package/dist/registration/registration-index.d.ts +162 -0
- package/dist/registration/registration-store.d.ts +111 -0
- package/dist/reporting/check-run-summary.d.ts +102 -0
- package/dist/reporting/commit-status.d.ts +382 -0
- package/dist/reporting/execution-tracker.d.ts +538 -0
- package/dist/reporting/fs-log-storage.d.ts +41 -0
- package/dist/reporting/log-pull-handler.d.ts +35 -0
- package/dist/reporting/log-storage.d.ts +70 -0
- package/dist/reporting/log-writer.d.ts +45 -0
- package/dist/reporting/s3-log-storage.d.ts +42 -0
- package/dist/reporting/step-log-buffer.d.ts +57 -0
- package/dist/routes/admin-access-log.d.ts +34 -0
- package/dist/routes/admin-backends.d.ts +28 -0
- package/dist/routes/admin-config.d.ts +57 -0
- package/dist/routes/admin-db.d.ts +20 -0
- package/dist/routes/admin-environments.d.ts +42 -0
- package/dist/routes/admin-errors.d.ts +4 -0
- package/dist/routes/admin-event-dlq.d.ts +39 -0
- package/dist/routes/admin-event-log.d.ts +42 -0
- package/dist/routes/admin-events.d.ts +46 -0
- package/dist/routes/admin-maintenance.d.ts +22 -0
- package/dist/routes/admin-org-settings.d.ts +29 -0
- package/dist/routes/admin-queue-execution.d.ts +27 -0
- package/dist/routes/admin-registrations.d.ts +37 -0
- package/dist/routes/admin-runs.d.ts +57 -0
- package/dist/routes/admin-scheduled-jobs.d.ts +36 -0
- package/dist/routes/admin-sources.d.ts +18 -0
- package/dist/routes/admin.d.ts +103 -0
- package/dist/routes/capabilities.d.ts +24 -0
- package/dist/routes/diagnostics.d.ts +16 -0
- package/dist/routes/health.d.ts +20 -0
- package/dist/routes/test-trigger.d.ts +41 -0
- package/dist/routes/uploads.d.ts +38 -0
- package/dist/routes/webhooks.d.ts +36 -0
- package/dist/scaler/bare-metal-backend.d.ts +107 -0
- package/dist/scaler/config.d.ts +303 -0
- package/dist/scaler/container-backend.d.ts +125 -0
- package/dist/scaler/file-tail.d.ts +23 -0
- package/dist/scaler/firecracker-api.d.ts +100 -0
- package/dist/scaler/firecracker-backend.d.ts +263 -0
- package/dist/scaler/index.d.ts +24 -0
- package/dist/scaler/ip-allocator.d.ts +177 -0
- package/dist/scaler/label-matcher.d.ts +73 -0
- package/dist/scaler/log-forwarder.d.ts +54 -0
- package/dist/scaler/machine-ledger.d.ts +160 -0
- package/dist/scaler/manager.d.ts +338 -0
- package/dist/scaler/nftables.d.ts +85 -0
- package/dist/scaler/types.d.ts +388 -0
- package/dist/scaler/warm-pool.d.ts +81 -0
- package/dist/secrets/audit-logger.d.ts +65 -0
- package/dist/secrets/backend-health.d.ts +60 -0
- package/dist/secrets/backend-registry.d.ts +68 -0
- package/dist/secrets/backend-sync.d.ts +40 -0
- package/dist/secrets/cleanup.d.ts +40 -0
- package/dist/secrets/config.d.ts +51 -0
- package/dist/secrets/crypto.d.ts +49 -0
- package/dist/secrets/ephemeral-keys.d.ts +49 -0
- package/dist/secrets/index.d.ts +17 -0
- package/dist/secrets/pg-secret-store.d.ts +105 -0
- package/dist/secrets/rbac.d.ts +47 -0
- package/dist/secrets/secret-output-store.d.ts +46 -0
- package/dist/secrets/secret-resolver.d.ts +137 -0
- package/dist/secrets/source-credentials.d.ts +61 -0
- package/dist/secrets/token-manager.d.ts +63 -0
- package/dist/secrets/vault-secret-store.d.ts +85 -0
- package/dist/security/comment-handler.d.ts +67 -0
- package/dist/security/contributor-cache.d.ts +75 -0
- package/dist/security/global-workflow-policy.d.ts +72 -0
- package/dist/security/lock-source.d.ts +34 -0
- package/dist/security/trust-resolver.d.ts +108 -0
- package/dist/security/workflow-diff.d.ts +26 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.js +48055 -0
- package/dist/sources/index.d.ts +10 -0
- package/dist/sources/source-manager.d.ts +63 -0
- package/dist/sources/source-store.d.ts +79 -0
- package/dist/sources/source-validator.d.ts +16 -0
- package/dist/stale-detector/stale-run-detector.d.ts +109 -0
- package/dist/standalone.d.ts +20 -0
- package/dist/standalone.js +41546 -0
- package/dist/storage/blob-routes.d.ts +20 -0
- package/dist/storage/filesystem.d.ts +60 -0
- package/dist/storage/index.d.ts +20 -0
- package/dist/storage/s3.d.ts +68 -0
- package/dist/storage/sign-url.d.ts +45 -0
- package/dist/storage/types.d.ts +98 -0
- package/dist/webhook/dedup.d.ts +44 -0
- package/dist/webhook/event-log.d.ts +83 -0
- package/dist/webhook/generic-sources.d.ts +169 -0
- package/dist/webhook/handler.d.ts +23 -0
- package/dist/webhook/relay-buffer.d.ts +96 -0
- package/dist/webhook/verify-inbound.d.ts +78 -0
- package/dist/worker/in-memory-execution-tracker.d.ts +94 -0
- package/dist/worker/in-memory-job-queue.d.ts +74 -0
- package/dist/worker/static-agent-token-store.d.ts +58 -0
- package/dist/worker/worker-status.d.ts +36 -0
- package/dist/worker-core.d.ts +74 -0
- package/dist/ws/agent-api-registry.d.ts +49 -0
- package/dist/ws/agent-handler.d.ts +176 -0
- package/dist/ws/agent-heartbeat.d.ts +45 -0
- package/dist/ws/dashboard-backends-handler.d.ts +51 -0
- package/dist/ws/dashboard-diagnostics-handler.d.ts +56 -0
- package/dist/ws/dashboard-env-handler.d.ts +107 -0
- package/dist/ws/dashboard-global-workflows-handler.d.ts +72 -0
- package/dist/ws/dashboard-registrations-handler.d.ts +84 -0
- package/dist/ws/event-buffer.d.ts +16 -0
- package/dist/ws/observer-handler.d.ts +42 -0
- package/dist/ws/observer-registry.d.ts +88 -0
- package/dist/ws/platform-client.d.ts +270 -0
- package/dist/ws/server-options.d.ts +15 -0
- package/package.json +87 -7
- package/sbom.spdx.json +14370 -0
- package/index.js +0 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source management module for the orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Provides CRUD operations (SourceStore), LISTEN/NOTIFY hot reload (SourceManager),
|
|
5
|
+
* and credential validation (validateGitHubSource) for webhook sources.
|
|
6
|
+
*/
|
|
7
|
+
export { SourceStore, type AddSourceParams, type SourceWithSecrets } from './source-store.js';
|
|
8
|
+
export { SourceManager, type SourceManagerOptions } from './source-manager.js';
|
|
9
|
+
export { validateGitHubSource, type ValidationResult } from './source-validator.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source manager with LISTEN/NOTIFY hot reload.
|
|
3
|
+
*
|
|
4
|
+
* Subscribes to PostgreSQL LISTEN/NOTIFY on the `sources_change` channel
|
|
5
|
+
* to detect source configuration changes. When a change is detected,
|
|
6
|
+
* reloads sources from the database, rebuilds the ProviderRegistry,
|
|
7
|
+
* and notifies the caller of added/removed sources via a callback.
|
|
8
|
+
*
|
|
9
|
+
* Debounces rapid changes to avoid excessive reloads.
|
|
10
|
+
*/
|
|
11
|
+
import type pg from 'pg';
|
|
12
|
+
import { ProviderRegistry } from '../provider-registry.js';
|
|
13
|
+
import type { ProviderSource } from '../entry-helpers.js';
|
|
14
|
+
import type { SourceStore } from './source-store.js';
|
|
15
|
+
/**
|
|
16
|
+
* Options for creating a SourceManager.
|
|
17
|
+
*/
|
|
18
|
+
export interface SourceManagerOptions {
|
|
19
|
+
/** Raw pg pool for LISTEN/NOTIFY subscriber. */
|
|
20
|
+
pool: pg.Pool;
|
|
21
|
+
/** SourceStore for reading sources and secrets. */
|
|
22
|
+
sourceStore: SourceStore;
|
|
23
|
+
/** Callback invoked when source diff is detected (for Platform registration). */
|
|
24
|
+
onSourcesChanged: (diff: {
|
|
25
|
+
added: ProviderSource[];
|
|
26
|
+
removed: ProviderSource[];
|
|
27
|
+
}) => void;
|
|
28
|
+
/** Debounce interval in ms for coalescing rapid changes. Default: 200. */
|
|
29
|
+
debounceMs?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Manages webhook sources from the database with hot reload support.
|
|
33
|
+
*
|
|
34
|
+
* On start, loads all sources, builds a ProviderRegistry, and subscribes
|
|
35
|
+
* to LISTEN sources_change. On each NOTIFY, debounces and reloads,
|
|
36
|
+
* rebuilding the registry and computing the diff for Platform registration.
|
|
37
|
+
*/
|
|
38
|
+
export declare class SourceManager {
|
|
39
|
+
private readonly opts;
|
|
40
|
+
private client;
|
|
41
|
+
private registry;
|
|
42
|
+
private currentSources;
|
|
43
|
+
private debounceTimer;
|
|
44
|
+
private readonly debounceMs;
|
|
45
|
+
constructor(opts: SourceManagerOptions);
|
|
46
|
+
/** Get current ProviderRegistry (rebuilt on each reload). */
|
|
47
|
+
getRegistry(): ProviderRegistry;
|
|
48
|
+
/** Get current sources for Platform registration. */
|
|
49
|
+
getSources(): ProviderSource[];
|
|
50
|
+
/** Initial load + subscribe to changes. */
|
|
51
|
+
start(): Promise<ProviderRegistry>;
|
|
52
|
+
/** Stop listening and release the dedicated pg client. */
|
|
53
|
+
stop(): Promise<void>;
|
|
54
|
+
private scheduleReload;
|
|
55
|
+
/** Reload sources from DB and rebuild the ProviderRegistry. */
|
|
56
|
+
reload(): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Build a ProviderBundle for a source with decrypted secrets.
|
|
59
|
+
* Currently only supports GitHub; throws for unknown providers.
|
|
60
|
+
*/
|
|
61
|
+
private buildBundle;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=source-manager.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source store for orchestrator webhook source management.
|
|
3
|
+
*
|
|
4
|
+
* Provides CRUD operations for the sources table with secret storage
|
|
5
|
+
* via PgSecretStore. Secrets (private keys, webhook secrets) are stored
|
|
6
|
+
* separately from the source config to leverage the existing encryption
|
|
7
|
+
* infrastructure.
|
|
8
|
+
*/
|
|
9
|
+
import { type Kysely } from 'kysely';
|
|
10
|
+
import type { Database, Source } from '../db/types.js';
|
|
11
|
+
import type { PgSecretStore } from '../secrets/pg-secret-store.js';
|
|
12
|
+
/**
|
|
13
|
+
* Parameters for adding a new source.
|
|
14
|
+
*/
|
|
15
|
+
export interface AddSourceParams {
|
|
16
|
+
/** Provider type (e.g. 'github') */
|
|
17
|
+
provider: string;
|
|
18
|
+
/** Human-readable source name */
|
|
19
|
+
name: string;
|
|
20
|
+
/** App ID for the provider (used to build routing key) */
|
|
21
|
+
appId: string;
|
|
22
|
+
/** Private key (PEM format for GitHub Apps) */
|
|
23
|
+
privateKey: string;
|
|
24
|
+
/** Webhook secret for signature verification */
|
|
25
|
+
webhookSecret?: string;
|
|
26
|
+
/** Extra non-sensitive config */
|
|
27
|
+
config?: Record<string, unknown>;
|
|
28
|
+
/** Customer/org identifier for secret and environment scoping */
|
|
29
|
+
customerId?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A source with its decrypted secrets.
|
|
33
|
+
*/
|
|
34
|
+
export interface SourceWithSecrets extends Source {
|
|
35
|
+
privateKey: string;
|
|
36
|
+
webhookSecret?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* CRUD store for webhook sources backed by PostgreSQL.
|
|
40
|
+
* Sensitive credentials are stored in PgSecretStore under `__source__/<id>`.
|
|
41
|
+
*/
|
|
42
|
+
export declare class SourceStore {
|
|
43
|
+
private readonly db;
|
|
44
|
+
private readonly secretStore;
|
|
45
|
+
constructor(db: Kysely<Database>, secretStore: PgSecretStore);
|
|
46
|
+
/**
|
|
47
|
+
* Add a new source. Stores config in sources table, secrets in PgSecretStore.
|
|
48
|
+
* Routing key is computed as `<provider>:<appId>`.
|
|
49
|
+
*/
|
|
50
|
+
addSource(params: AddSourceParams): Promise<Source>;
|
|
51
|
+
/**
|
|
52
|
+
* List all sources (no secrets exposed).
|
|
53
|
+
*/
|
|
54
|
+
listSources(): Promise<Source[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Get a single source by routing key, or null if not found.
|
|
57
|
+
*/
|
|
58
|
+
getSource(routingKey: string): Promise<Source | null>;
|
|
59
|
+
/**
|
|
60
|
+
* Get a source with its decrypted secrets.
|
|
61
|
+
*/
|
|
62
|
+
getSourceWithSecrets(routingKey: string): Promise<SourceWithSecrets | null>;
|
|
63
|
+
/**
|
|
64
|
+
* Update a source's name/config and optionally rotate secrets.
|
|
65
|
+
*/
|
|
66
|
+
updateSource(routingKey: string, updates: {
|
|
67
|
+
name?: string;
|
|
68
|
+
privateKey?: string;
|
|
69
|
+
webhookSecret?: string;
|
|
70
|
+
config?: Record<string, unknown>;
|
|
71
|
+
/** New customer/org identifier (used for secret + environment scoping). */
|
|
72
|
+
customerId?: string;
|
|
73
|
+
}): Promise<Source>;
|
|
74
|
+
/**
|
|
75
|
+
* Remove a source and its associated secrets.
|
|
76
|
+
*/
|
|
77
|
+
removeSource(routingKey: string): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=source-store.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of a source credential validation.
|
|
3
|
+
*/
|
|
4
|
+
export interface ValidationResult {
|
|
5
|
+
valid: boolean;
|
|
6
|
+
appName?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validate GitHub App credentials by calling the GitHub API.
|
|
11
|
+
*
|
|
12
|
+
* Creates a JWT from the appId + privateKey and calls GET /app
|
|
13
|
+
* to verify the credentials are valid and retrieve the app name.
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateGitHubSource(appId: string, privateKey: string): Promise<ValidationResult>;
|
|
16
|
+
//# sourceMappingURL=source-validator.d.ts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StaleRunDetector: periodic DB scanner for stale execution jobs.
|
|
3
|
+
*
|
|
4
|
+
* Detects jobs that have stopped sending heartbeats (agent died, network partition,
|
|
5
|
+
* container killed, etc.) and marks them as timed_out_stale. Also detects stale
|
|
6
|
+
* dispatch_queue entries that were dispatched but never acknowledged.
|
|
7
|
+
*
|
|
8
|
+
* Key behaviors:
|
|
9
|
+
* - Immediate startup scan for crash recovery (finds stale jobs from before restart)
|
|
10
|
+
* - Periodic scans at configurable interval (default 60s)
|
|
11
|
+
* - Uses timed_out_stale as distinct DB status (not just 'failed')
|
|
12
|
+
* - Optimistic concurrency: WHERE status='running' prevents race with agent completion
|
|
13
|
+
* - Does NOT call executionTracker.onJobStatus() to avoid redundant DB writes
|
|
14
|
+
* - Updates in-memory state and calls completeRunIfAllJobsTerminal for run completion
|
|
15
|
+
* - Force-terminates stale agents via scaler manager
|
|
16
|
+
* - Updates GitHub check runs with timed_out conclusion
|
|
17
|
+
*/
|
|
18
|
+
import { type Kysely } from 'kysely';
|
|
19
|
+
import type { Database } from '../db/types.js';
|
|
20
|
+
import type { ExecutionTracker } from '../reporting/execution-tracker.js';
|
|
21
|
+
import type { CommitStatusReporter } from '../reporting/commit-status.js';
|
|
22
|
+
import type { ScalerManager } from '../scaler/manager.js';
|
|
23
|
+
import type { Dispatcher } from '../agent/dispatcher.js';
|
|
24
|
+
import type { AgentRegistry } from '../agent/registry.js';
|
|
25
|
+
import type { HeldRunStore } from '../environments/held-runs.js';
|
|
26
|
+
export interface StaleRunDetectorDeps {
|
|
27
|
+
db: Kysely<Database>;
|
|
28
|
+
executionTracker: ExecutionTracker;
|
|
29
|
+
commitStatusReporter?: CommitStatusReporter;
|
|
30
|
+
scalerManager?: ScalerManager;
|
|
31
|
+
dispatcher: Dispatcher;
|
|
32
|
+
registry: AgentRegistry;
|
|
33
|
+
/** Threshold in ms after which a job is considered stale. Default: heartbeatIntervalMs * multiplier */
|
|
34
|
+
staleThresholdMs: number;
|
|
35
|
+
/** How often to scan for stale jobs in ms. Default: 60_000 */
|
|
36
|
+
scanIntervalMs: number;
|
|
37
|
+
/** Held run store for expiring overdue held runs. Optional -- if not set, held run cleanup is skipped. */
|
|
38
|
+
heldRunStore?: HeldRunStore;
|
|
39
|
+
}
|
|
40
|
+
export declare class StaleRunDetector {
|
|
41
|
+
private readonly db;
|
|
42
|
+
private readonly executionTracker;
|
|
43
|
+
private readonly commitStatusReporter?;
|
|
44
|
+
private readonly scalerManager?;
|
|
45
|
+
private readonly dispatcher;
|
|
46
|
+
private readonly registry;
|
|
47
|
+
private readonly staleThresholdMs;
|
|
48
|
+
private readonly scanIntervalMs;
|
|
49
|
+
private readonly heldRunStore?;
|
|
50
|
+
private interval;
|
|
51
|
+
constructor(deps: StaleRunDetectorDeps);
|
|
52
|
+
/**
|
|
53
|
+
* Clean up orphaned jobs left in 'recovering' state from a previous orchestrator instance.
|
|
54
|
+
*
|
|
55
|
+
* Recovery timers are in-memory (Dispatcher) and lost on restart. Any jobs still
|
|
56
|
+
* in 'recovering' state after a restart have no timer and no path to completion,
|
|
57
|
+
* so they must be failed immediately.
|
|
58
|
+
*
|
|
59
|
+
* Call this during startup, before the first periodic scan.
|
|
60
|
+
*/
|
|
61
|
+
cleanupOrphanedRecoveryJobs(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Start the stale run detector.
|
|
64
|
+
* Runs an immediate scan for crash recovery, then starts periodic scans.
|
|
65
|
+
*/
|
|
66
|
+
start(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Stop the stale run detector.
|
|
69
|
+
*/
|
|
70
|
+
stop(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Run a single stale detection scan.
|
|
73
|
+
*
|
|
74
|
+
* Three sub-scans:
|
|
75
|
+
* A. Running jobs with old heartbeat (last_heartbeat_at < threshold)
|
|
76
|
+
* B. Running jobs with NULL heartbeat (created_at < threshold, pre-heartbeat jobs)
|
|
77
|
+
* C. Dispatched queue entries that were never acknowledged
|
|
78
|
+
*
|
|
79
|
+
* After all sub-scans, checks run completion for affected runs.
|
|
80
|
+
*
|
|
81
|
+
* Note: jobs in 'recovering' state are NOT scanned -- they have their own
|
|
82
|
+
* per-job recovery timers managed by the Dispatcher (see Phase 15).
|
|
83
|
+
* All sub-scans filter on status='running' or status='dispatched',
|
|
84
|
+
* so recovering jobs are naturally excluded.
|
|
85
|
+
*/
|
|
86
|
+
scan(): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Sub-scan A: Find running jobs with stale heartbeats.
|
|
89
|
+
*/
|
|
90
|
+
private scanStaleRunningJobs;
|
|
91
|
+
/**
|
|
92
|
+
* Sub-scan B: Find running jobs with NULL heartbeat and old created_at.
|
|
93
|
+
* These are jobs that started before the heartbeat system existed or where
|
|
94
|
+
* the initial heartbeat was never set.
|
|
95
|
+
*/
|
|
96
|
+
private scanStaleRunningJobsNullHeartbeat;
|
|
97
|
+
/**
|
|
98
|
+
* Sub-scan C: Find dispatched entries that were never acknowledged.
|
|
99
|
+
* Only checks 'dispatched' status (job sent to agent but agent never started it).
|
|
100
|
+
* 'queued' jobs are legitimately waiting for agents and handled by queue timeout instead.
|
|
101
|
+
*/
|
|
102
|
+
private scanStaleDispatchedJobs;
|
|
103
|
+
/**
|
|
104
|
+
* Mark a single running job as timed_out_stale.
|
|
105
|
+
* Shared by sub-scans A and B.
|
|
106
|
+
*/
|
|
107
|
+
private markJobStale;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=stale-run-detector.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Independent mode entry point for the customer orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Operates in 'independent' mode:
|
|
5
|
+
* - Receives webhooks ONLY via direct HTTP endpoints
|
|
6
|
+
* - No Platform WS relay connection
|
|
7
|
+
* - No event buffer (nothing to buffer for)
|
|
8
|
+
*
|
|
9
|
+
* Same as server.ts but WITHOUT PlatformClient.
|
|
10
|
+
* Webhooks arrive only via the per-source generic webhook endpoints at
|
|
11
|
+
* /webhook/:orgId/generic/:sourceId, registered with `kici-admin source add`.
|
|
12
|
+
*
|
|
13
|
+
* Startup sequence:
|
|
14
|
+
* config -> DB -> provider registry -> dispatcher -> app -> HTTP -> heartbeat
|
|
15
|
+
*
|
|
16
|
+
* Graceful shutdown:
|
|
17
|
+
* agent WS -> heartbeat -> HTTP -> DB
|
|
18
|
+
*/
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=standalone.d.ts.map
|