@kici-dev/orchestrator 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.d.ts CHANGED
@@ -34,7 +34,7 @@ import type { PendingBuildTracker } from './cache/index.js';
34
34
  import type { PendingInitTracker } from './cache/index.js';
35
35
  import type { PendingDynamicTracker } from './cache/index.js';
36
36
  import type { CacheStorage } from './storage/types.js';
37
- import { type CommitStatusReporter } from './reporting/commit-status.js';
37
+ import { type CheckRunReporter } from './reporting/check-run-reporter.js';
38
38
  import type { ExecutionTracker } from './reporting/execution-tracker.js';
39
39
  import type { LogWriter } from './reporting/log-writer.js';
40
40
  import type { LogStorage } from './reporting/log-storage.js';
@@ -108,7 +108,7 @@ export interface AppDependencies {
108
108
  /** Pending dynamic tracker for DynamicJobFn evaluation coordination. */
109
109
  pendingDynamics?: PendingDynamicTracker;
110
110
  /** Commit status reporter for setting pending/success/failure/error on commits. Optional. */
111
- commitStatusReporter?: CommitStatusReporter;
111
+ checkRunReporter?: CheckRunReporter;
112
112
  /** Execution tracker for DB persistence of execution state. Optional — requires database. */
113
113
  executionTracker?: ExecutionTracker;
114
114
  /** Log writer for persisting agent log chunks. Optional — requires database. */
@@ -123,6 +123,12 @@ export interface AppDependencies {
123
123
  ownershipTracker?: OwnershipTracker;
124
124
  /** Admin API route dependencies. Optional -- only mounted when secrets management is configured. */
125
125
  adminDeps?: AdminRouteDeps;
126
+ /**
127
+ * Resolves the public webhook URL for a newly added source (for
128
+ * `kici-admin source add` output). Built by the entry point where the
129
+ * Platform client + config are in scope; passed into the admin source routes.
130
+ */
131
+ resolveSourceWebhookUrl?: AdminRouteDeps['resolveSourceWebhookUrl'];
126
132
  /** Config admin API route dependencies. Optional -- mounted when config management is available. */
127
133
  configRouteDeps?: ConfigRouteDeps;
128
134
  /** Event router for internal event delivery. Optional -- if not set, event routing is inactive. */
@@ -202,7 +208,7 @@ export interface AppDependencies {
202
208
  /**
203
209
  * In-memory cache for step source locations extracted from lock files.
204
210
  * Keyed by `workflowName:jobName`, stores source location arrays indexed by step index.
205
- * Populated during webhook processing, used by CommitStatusReporter for annotations.
211
+ * Populated during webhook processing, used by CheckRunReporter for annotations.
206
212
  */
207
213
  export declare class SourceLocationStore {
208
214
  private readonly cache;
package/dist/cli.js CHANGED
@@ -4214,6 +4214,26 @@ createLogger({ prefix: "universal-git:clone-token" });
4214
4214
  * --stdin Read from stdin
4215
4215
  */
4216
4216
  /**
4217
+ * Short reason shown in `(unavailable — <reason>)` when no webhook URL could be
4218
+ * resolved for an added source.
4219
+ */
4220
+ function webhookNoteReason(note) {
4221
+ switch (note) {
4222
+ case "github-ingress-platform-only": return "this orchestrator runs in independent mode";
4223
+ case "platform-no-public-url": return "the Platform has no public webhook URL configured";
4224
+ case "platform-unavailable": return "could not reach the Platform";
4225
+ default: return "webhook URL could not be determined";
4226
+ }
4227
+ }
4228
+ /** Actionable next-step hint paired with {@link webhookNoteReason}. */
4229
+ function webhookNoteHint(note) {
4230
+ switch (note) {
4231
+ case "github-ingress-platform-only": return "GitHub App ingress is served by the KiCI Platform; find the URL in the dashboard under Sources.";
4232
+ case "platform-unavailable": return "Retry once the orchestrator reconnects, or find the URL in the dashboard under Sources.";
4233
+ default: return "Find the webhook URL in the dashboard under Sources.";
4234
+ }
4235
+ }
4236
+ /**
4217
4237
  * Resolve a secret value from various input modes.
4218
4238
  * Returns undefined if no input mode is specified.
4219
4239
  */
@@ -4357,7 +4377,16 @@ function registerSourceCommands(program, getClient) {
4357
4377
  webhookSecret: opts.webhookSecret
4358
4378
  });
4359
4379
  if (opts.json) console.log(JSON.stringify(result, null, 2));
4360
- else console.log(`Source added: ${result.routingKey} (${result.name})`);
4380
+ else {
4381
+ console.log(`Source added: ${result.routingKey} (${result.name})`);
4382
+ if (result.webhookUrl) {
4383
+ console.log(`Webhook URL: ${result.webhookUrl}`);
4384
+ console.log(` ↳ Paste this into your GitHub App's "Webhook URL" field.`);
4385
+ } else {
4386
+ console.log(`Webhook URL: (unavailable — ${webhookNoteReason(result.webhookNote)})`);
4387
+ console.log(` ↳ ${webhookNoteHint(result.webhookNote)}`);
4388
+ }
4389
+ }
4361
4390
  } catch (err) {
4362
4391
  console.error(`Error: ${toErrorMessage(err)}`);
4363
4392
  process.exit(1);
@@ -15,7 +15,7 @@ import type { PeerRegistry } from './peer-registry.js';
15
15
  import type { PeerClient } from './peer-client.js';
16
16
  import type { Dispatcher } from '../agent/dispatcher.js';
17
17
  import type { ExecutionTracker } from '../reporting/execution-tracker.js';
18
- import type { CommitStatusReporter } from '../reporting/commit-status.js';
18
+ import type { CheckRunReporter } from '../reporting/check-run-reporter.js';
19
19
  export interface RunContext {
20
20
  runId: string;
21
21
  deliveryId: string;
@@ -80,7 +80,7 @@ export interface RunCoordinatorDeps {
80
80
  peerRegistry: PeerRegistry;
81
81
  dispatcher: Dispatcher;
82
82
  executionTracker?: ExecutionTracker;
83
- commitStatusReporter?: CommitStatusReporter;
83
+ checkRunReporter?: CheckRunReporter;
84
84
  getPeerClient: (instanceId: string) => PeerClient | undefined;
85
85
  /** Fallback: send job.reroute via server-side (incoming) peer connection and wait for ACK. */
86
86
  sendAndWaitAckViaHandler?: (targetInstanceId: string, msg: JobReroute, timeoutMs: number) => Promise<boolean>;
@@ -95,7 +95,7 @@ export declare class RunCoordinator {
95
95
  private readonly peerRegistry;
96
96
  private readonly dispatcher;
97
97
  private readonly executionTracker?;
98
- private readonly commitStatusReporter?;
98
+ private readonly checkRunReporter?;
99
99
  private readonly getPeerClient;
100
100
  private readonly sendAndWaitAckViaHandler?;
101
101
  private readonly sendToPeerViaHandler?;
package/dist/config.d.ts CHANGED
@@ -27,6 +27,7 @@ declare const configSchema: z.ZodObject<{
27
27
  platformUrl: z.ZodOptional<z.ZodString>;
28
28
  platformToken: z.ZodOptional<z.ZodString>;
29
29
  dashboardUrl: z.ZodOptional<z.ZodString>;
30
+ webhookPublicUrl: z.ZodOptional<z.ZodString>;
30
31
  databaseUrl: z.ZodDefault<z.ZodString>;
31
32
  lockfileCacheMax: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
32
33
  lockfileCacheTtlMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
@@ -225,6 +226,7 @@ export declare const envDef: import("@kici-dev/shared/env").DefineEnvResult<{
225
226
  platformUrl?: string | undefined;
226
227
  platformToken?: string | undefined;
227
228
  dashboardUrl?: string | undefined;
229
+ webhookPublicUrl?: string | undefined;
228
230
  cacheStorageType?: "s3" | "filesystem" | undefined;
229
231
  cacheStoragePath?: string | undefined;
230
232
  cacheStorageS3Bucket?: string | undefined;
@@ -1294,7 +1294,7 @@ export type ColdStoreChunksUpdate = Updateable<ColdStoreChunksTable>;
1294
1294
  * Check-run tracking table (check_run_tracking).
1295
1295
  *
1296
1296
  * HA-safe persistence for the per-coord state previously held in
1297
- * `CommitStatusReporter`'s six in-memory `Map`s. Replacement coord on a
1297
+ * `CheckRunReporter`'s six in-memory `Map`s. Replacement coord on a
1298
1298
  * Raft leader switch reads this table to recover check-run IDs, build
1299
1299
  * creation state, step-progress entries, in-progress-sent timestamps, and
1300
1300
  * the run-id reverse index used for cleanup. A coord crash mid-check-run
@@ -27,7 +27,7 @@ import { ScalerManager } from './scaler/index.js';
27
27
  import type { ScalerConfig } from './scaler/index.js';
28
28
  import type { CacheStorage } from './storage/index.js';
29
29
  import { SourceCache, BuildCoordinator, DepCache, PendingBuildTracker, PendingInitTracker, PendingDynamicTracker } from './cache/index.js';
30
- import { CommitStatusReporter } from './reporting/commit-status.js';
30
+ import { CheckRunReporter } from './reporting/check-run-reporter.js';
31
31
  import { StepLogBuffer } from './reporting/step-log-buffer.js';
32
32
  import { type LogStorage } from './reporting/log-storage.js';
33
33
  import { ExecutionTracker, type ExecutionTrackerDeps } from './reporting/execution-tracker.js';
@@ -44,6 +44,7 @@ import { EventRouter } from './events/event-router.js';
44
44
  import { EventEmitter } from './events/event-emitter.js';
45
45
  import { TrustStore } from './events/trust-store.js';
46
46
  import { GenericSourceManager } from './webhook/generic-sources.js';
47
+ import { GenericSourcesChangeListener } from './webhook/generic-sources-listener.js';
47
48
  import { RegistrationStore } from './registration/registration-store.js';
48
49
  import { RegistrationIndex } from './registration/registration-index.js';
49
50
  import { CronScheduler } from './cron/cron-scheduler.js';
@@ -73,7 +74,7 @@ export interface OrchestratorSubsystems {
73
74
  pendingBuilds: PendingBuildTracker | undefined;
74
75
  pendingInits: PendingInitTracker;
75
76
  pendingDynamics: PendingDynamicTracker;
76
- commitStatusReporter: CommitStatusReporter;
77
+ checkRunReporter: CheckRunReporter;
77
78
  stepLogBuffer: StepLogBuffer;
78
79
  sourceLocationStore: SourceLocationStore;
79
80
  logStorage: LogStorage;
@@ -114,6 +115,12 @@ export interface OrchestratorSubsystems {
114
115
  localConfigVersion: number;
115
116
  sourceStore: SourceStore;
116
117
  sourceManager: SourceManager;
118
+ /**
119
+ * Generic-webhook-source hot-reload listener. Exposed so the platform-mode
120
+ * boot can wire its `onChange` to re-push the full source list to the
121
+ * Platform when a generic source is added/removed at runtime.
122
+ */
123
+ genericSourcesChangeListener: GenericSourcesChangeListener;
117
124
  /** Inbound webhook delivery log writer (event_log table + object-storage payloads). */
118
125
  eventLogWriter: EventLogWriter;
119
126
  /** Access log writer (read + mutation attribution for dashboard + admin). */
@@ -26,7 +26,7 @@ import type { DepCache } from '../cache/index.js';
26
26
  import type { PendingBuildTracker } from '../cache/index.js';
27
27
  import type { PendingInitTracker } from '../cache/pending-inits.js';
28
28
  import type { PendingDynamicTracker } from '../cache/pending-dynamics.js';
29
- import type { CommitStatusReporter } from '../reporting/commit-status.js';
29
+ import type { CheckRunReporter } from '../reporting/check-run-reporter.js';
30
30
  import type { ExecutionTracker } from '../reporting/execution-tracker.js';
31
31
  import type { AgentRegistry } from '../agent/registry.js';
32
32
  import type { RunCoordinator } from '../cluster/coordinator.js';
@@ -237,7 +237,7 @@ export interface ProcessingDeps {
237
237
  /** Pending dynamic tracker -- waits for agents to evaluate DynamicJobFn and return generated LockJob[]. */
238
238
  pendingDynamics?: PendingDynamicTracker;
239
239
  /** Commit status reporter for setting pending/success/failure/error on commits. Optional. */
240
- commitStatusReporter?: CommitStatusReporter;
240
+ checkRunReporter?: CheckRunReporter;
241
241
  /** Execution tracker for DB persistence. Optional -- if not set, execution tracking is skipped. */
242
242
  executionTracker?: ExecutionTracker;
243
243
  /** Agent registry for determining execution target platform/arch. Optional -- if not set, defaults to linux/x64. */
@@ -18,7 +18,7 @@ import type { Dispatcher } from '../agent/dispatcher.js';
18
18
  import type { ExecutionTracker } from '../reporting/execution-tracker.js';
19
19
  import type { JobQueue } from '../queue/job-queue.js';
20
20
  import type { PlatformClient } from '../ws/platform-client.js';
21
- import type { CommitStatusReporter } from '../reporting/commit-status.js';
21
+ import type { CheckRunReporter } from '../reporting/check-run-reporter.js';
22
22
  import type { RunCoordinator } from '../cluster/coordinator.js';
23
23
  import type { SecretResolver } from '../secrets/secret-resolver.js';
24
24
  import type { EventRouter } from '../events/event-router.js';
@@ -50,7 +50,7 @@ export interface RerunDeps {
50
50
  dispatcher: Dispatcher;
51
51
  jobQueue: JobQueue;
52
52
  platformClient: PlatformClient | null;
53
- commitStatusReporter: CommitStatusReporter | null;
53
+ checkRunReporter: CheckRunReporter | null;
54
54
  coordinator: RunCoordinator | null;
55
55
  secretResolver: SecretResolver | null;
56
56
  eventRouter: EventRouter | null;
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import type { LockFileCache } from '../lockfile-cache.js';
18
18
  import type { Dispatcher } from '../agent/dispatcher.js';
19
- import type { CommitStatusReporter } from '../reporting/commit-status.js';
19
+ import type { CheckRunReporter } from '../reporting/check-run-reporter.js';
20
20
  import type { ExecutionTracker } from '../reporting/execution-tracker.js';
21
21
  import type { AgentRegistry } from '../agent/registry.js';
22
22
  import type { ProviderRegistry } from '../provider-registry.js';
@@ -85,7 +85,7 @@ export interface TestPipelineDeps {
85
85
  lockFileCache: LockFileCache;
86
86
  dispatcher: Dispatcher;
87
87
  executionTracker?: ExecutionTracker;
88
- commitStatusReporter?: CommitStatusReporter;
88
+ checkRunReporter?: CheckRunReporter;
89
89
  sourceCache?: SourceCache;
90
90
  buildCoordinator?: BuildCoordinator;
91
91
  depCache?: DepCache;
@@ -12,7 +12,7 @@
12
12
  * Check run IDs are tracked in-memory after creation so that subsequent
13
13
  * updates (job complete, workflow complete) can reference them via checks.update().
14
14
  *
15
- * Enriched output (Phase 14):
15
+ * Enriched output:
16
16
  * - Live step progress with checklist-style updates (debounced at 5s)
17
17
  * - Failed check runs include step names, error messages, exit codes, and log context
18
18
  * - Check run annotations link failures to step source locations in workflow files (.kici/workflows/*.ts)
@@ -22,7 +22,7 @@
22
22
  * Note: The engine-level CheckStatusPoster interface (packages/engine/src/provider/check-status-poster.ts)
23
23
  * provides a provider-agnostic API for posting security-related check statuses (holds, approvals,
24
24
  * workflow modifications). The GitHub implementation is at packages/orchestrator/src/providers/github/check-status-poster.ts.
25
- * This CommitStatusReporter handles execution lifecycle checks (queued, in_progress, completed per job/workflow).
25
+ * This CheckRunReporter handles execution lifecycle checks (queued, in_progress, completed per job/workflow).
26
26
  * Future cleanup may unify both under CheckStatusPoster, but they serve different purposes today.
27
27
  */
28
28
  import { type GitHubAppConfig } from '../providers/github/auth.js';
@@ -32,9 +32,9 @@ import { type SourceLocationData } from './check-run-summary.js';
32
32
  import type { CheckRunTrackingStore } from './check-run-tracking-store.js';
33
33
  import { ExecutionJobStatus } from '@kici-dev/engine';
34
34
  /**
35
- * Dependencies for the CommitStatusReporter.
35
+ * Dependencies for the CheckRunReporter.
36
36
  */
37
- interface CommitStatusReporterDeps {
37
+ interface CheckRunReporterDeps {
38
38
  /**
39
39
  * Provider registry for per-routing-key credential lookup.
40
40
  * When provided, the reporter resolves GitHub App credentials by routing key
@@ -206,7 +206,7 @@ interface UpdateStepProgressOptions {
206
206
  * All public methods are fire-and-forget: they return void immediately
207
207
  * and log errors internally without propagating them.
208
208
  */
209
- export declare class CommitStatusReporter {
209
+ export declare class CheckRunReporter {
210
210
  private deps;
211
211
  /**
212
212
  * L1 cache: composite key → check run ID.
@@ -244,7 +244,7 @@ export declare class CommitStatusReporter {
244
244
  * still find every key for a runId at cleanup time.
245
245
  */
246
246
  private readonly runIdToKeys;
247
- constructor(deps: CommitStatusReporterDeps);
247
+ constructor(deps: CheckRunReporterDeps);
248
248
  /**
249
249
  * Update the provider registry used for per-routing-key credential lookup.
250
250
  * Called after config reload when the provider registry is rebuilt.
@@ -457,4 +457,4 @@ export declare class CommitStatusReporter {
457
457
  */
458
458
  export declare function buildJobFailureDescription(data: Record<string, unknown>): string;
459
459
  export {};
460
- //# sourceMappingURL=commit-status.d.ts.map
460
+ //# sourceMappingURL=check-run-reporter.d.ts.map
@@ -35,11 +35,11 @@ export interface CheckRunTrackingState {
35
35
  updatedAt?: Date;
36
36
  }
37
37
  /**
38
- * DB persistence for `CommitStatusReporter` check-run state.
38
+ * DB persistence for `CheckRunReporter` check-run state.
39
39
  *
40
40
  * Backed by the `check_run_tracking` table — one row per
41
41
  * `(provider, owner, repo, sha, check_name)`. Replaces six in-memory
42
- * `Map`s previously held inside `CommitStatusReporter`:
42
+ * `Map`s previously held inside `CheckRunReporter`:
43
43
  *
44
44
  * - `checkRunIds` → `check_run_id` column
45
45
  * - `pendingBuildCreations` → `build_creation_state` column
@@ -13,6 +13,21 @@ import type { SourceStore } from '../sources/source-store.js';
13
13
  import type { Role } from '../secrets/rbac.js';
14
14
  interface SourceRouteDeps {
15
15
  sourceStore: SourceStore;
16
+ /**
17
+ * Resolve the public webhook URL for a freshly added source so the CLI can
18
+ * print it. Platform/hybrid mode registers the source with the Platform and
19
+ * reads the URL from the `source.register.ack`; independent mode returns a
20
+ * null URL with an explanatory `webhookNote`. Omitted in deployments with no
21
+ * resolver wired (the route then returns `webhookUrl: null`).
22
+ */
23
+ resolveSourceWebhookUrl?: (params: {
24
+ routingKey: string;
25
+ provider: string;
26
+ sourceId: string;
27
+ }) => Promise<{
28
+ webhookUrl: string | null;
29
+ webhookNote?: string;
30
+ }>;
16
31
  }
17
32
  type AdminSourcesEnv = {
18
33
  Variables: {
@@ -63,6 +63,20 @@ export interface AdminRouteDeps {
63
63
  broadcastAgentTokenRevoke?: (tokenId: string) => void;
64
64
  /** Optional -- for source management endpoints. */
65
65
  sourceStore?: SourceStore;
66
+ /**
67
+ * Optional -- resolves the public webhook URL for a newly added source so
68
+ * `kici-admin source add` can print it. Wired in platform/hybrid mode to
69
+ * register-and-await the Platform ack; independent mode returns a null URL
70
+ * with a note.
71
+ */
72
+ resolveSourceWebhookUrl?: (params: {
73
+ routingKey: string;
74
+ provider: string;
75
+ sourceId: string;
76
+ }) => Promise<{
77
+ webhookUrl: string | null;
78
+ webhookNote?: string;
79
+ }>;
66
80
  /** Optional -- for DB migration endpoints. */
67
81
  db?: Kysely<any>;
68
82
  /** Optional -- for DB migration endpoints. */