@kici-dev/orchestrator 0.1.16 → 0.1.17

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 (58) hide show
  1. package/dist/agent/dispatcher.d.ts +18 -1
  2. package/dist/approvals/apply-decision.d.ts +11 -1
  3. package/dist/cache/pending-inits.d.ts +5 -0
  4. package/dist/cli/api-client.d.ts +11 -0
  5. package/dist/cli/commands/local-hook.d.ts +15 -0
  6. package/dist/cli/commands/local-trigger.d.ts +24 -0
  7. package/dist/cli/commands/remote-source.d.ts +17 -0
  8. package/dist/cli/commands/shared/versioned-upgrade.d.ts +14 -0
  9. package/dist/cli/kici-admin.d.ts +13 -0
  10. package/dist/cli.js +726 -177
  11. package/dist/config.d.ts +0 -4
  12. package/dist/dashboard/handler.d.ts +26 -2
  13. package/dist/dashboard/needs-edges.d.ts +13 -0
  14. package/dist/db/migrations/035_pending_workflow_contexts.d.ts +11 -0
  15. package/dist/db/migrations/036_attestations.d.ts +15 -0
  16. package/dist/db/migrations/037_generic_sources_provider_type_local.d.ts +19 -0
  17. package/dist/db/migrations/038_remote_sources.d.ts +14 -0
  18. package/dist/db/types.d.ts +83 -10
  19. package/dist/diagnostics/fleet-collector.d.ts +1 -1
  20. package/dist/entry-helpers.d.ts +7 -29
  21. package/dist/environments/held-runs.d.ts +24 -0
  22. package/dist/index.js +1 -0
  23. package/dist/metrics/prometheus.d.ts +4 -2
  24. package/dist/orchestrator-core.d.ts +48 -0
  25. package/dist/pipeline/dispatch-matched-workflow.d.ts +18 -1
  26. package/dist/pipeline/install-secrets-resolver.d.ts +32 -5
  27. package/dist/pipeline/needs-scheduler.d.ts +12 -10
  28. package/dist/pipeline/pending-workflow-context.d.ts +44 -0
  29. package/dist/pipeline/processor.d.ts +6 -4
  30. package/dist/pipeline/remote-source-store.d.ts +21 -0
  31. package/dist/pipeline/resume-workflow.d.ts +26 -0
  32. package/dist/providers/local/index.d.ts +33 -0
  33. package/dist/providers/local/local-source-config.d.ts +17 -0
  34. package/dist/providers/{internal → local}/lock-file-fetcher.d.ts +6 -6
  35. package/dist/providers/{internal → local}/normalizer.d.ts +28 -28
  36. package/dist/providers/{internal → local}/repo-url-builder.d.ts +6 -6
  37. package/dist/reporting/execution-tracker.d.ts +33 -0
  38. package/dist/routes/admin-events.d.ts +3 -4
  39. package/dist/routes/uploads.d.ts +36 -26
  40. package/dist/server.js +27910 -26483
  41. package/dist/sources/build-platform-sources.d.ts +4 -2
  42. package/dist/stale-detector/stale-run-detector.d.ts +14 -1
  43. package/dist/standalone.js +15708 -15619
  44. package/dist/webhook/generic-sources-listener.d.ts +4 -0
  45. package/dist/webhook/generic-sources.d.ts +37 -11
  46. package/dist/webhook/register-source-bundle.d.ts +14 -4
  47. package/dist/ws/agent-handler.d.ts +17 -0
  48. package/dist/ws/dashboard-dispatch-guard.d.ts +21 -0
  49. package/dist/ws/dashboard-env-handler.d.ts +13 -1
  50. package/dist/ws/oidc-token-relay.d.ts +59 -0
  51. package/dist/ws/platform-client.d.ts +30 -1
  52. package/dist/ws/test-relay-handlers.d.ts +112 -0
  53. package/installer-image-digests.json +3 -3
  54. package/package.json +4 -4
  55. package/sbom.spdx.json +98 -48
  56. package/dist/providers/internal/index.d.ts +0 -32
  57. package/dist/routes/test-trigger.d.ts +0 -41
  58. package/dist/ws/observer-handler.d.ts +0 -42
@@ -55,6 +55,13 @@ export declare class Dispatcher {
55
55
  private readonly agentJobs;
56
56
  /** Reverse map: jobId -> agentId, for cancel-run lookups. */
57
57
  private readonly jobToAgent;
58
+ /**
59
+ * jobId -> runId for currently-tracked jobs. Populated alongside
60
+ * `jobToAgent`/`agentJobs` at dispatch time and cleared with them, so the
61
+ * provenance token relay can resolve a job's runId from the dispatcher's own
62
+ * state (`resolveOwnedJob`) rather than trusting an agent-asserted value.
63
+ */
64
+ private readonly jobRunIds;
58
65
  /**
59
66
  * Grace window for recently completed jobs.
60
67
  * Allows late messages (log.chunk, step.status) to be accepted for a short
@@ -296,7 +303,7 @@ export declare class Dispatcher {
296
303
  * reconnecting agent reporting the job in-flight means it had started,
297
304
  * so mark it started for disconnect triage.
298
305
  */
299
- restoreJobForAgent(agentId: string, jobId: string): void;
306
+ restoreJobForAgent(agentId: string, jobId: string, runId?: string): void;
300
307
  /**
301
308
  * Start a recovery timer for a job found in 'dispatched' state on startup.
302
309
  * Called by server.ts/standalone.ts to create recovery timers for jobs
@@ -349,6 +356,16 @@ export declare class Dispatcher {
349
356
  /** Remove expired entries from the completedJobs grace window map. */
350
357
  private cleanupExpiredGraceEntries;
351
358
  private trackJobForAgent;
359
+ /**
360
+ * Verify `agentId` currently owns `jobId`; if so, return the job's runId from
361
+ * the dispatcher's own tracking. Used by the provenance token relay so the
362
+ * orchestrator binds a minted token to a job the agent actually owns — the
363
+ * agent never asserts a runId. Returns `undefined` when the agent does not
364
+ * own the job (or the runId is no longer tracked).
365
+ */
366
+ resolveOwnedJob(agentId: string, jobId: string): {
367
+ runId: string;
368
+ } | undefined;
352
369
  /**
353
370
  * Cancel a queued job (mark as failed in the dispatch queue).
354
371
  * Used by the coordinator to clean up local fallback entries when a peer
@@ -40,15 +40,25 @@ export interface ApplyDecisionDeps {
40
40
  allowSelfApproval: boolean;
41
41
  /** Resolve the Keycloak sub of the user who triggered a run (for the self-approval gate). */
42
42
  resolveTriggererSub: (runId: string) => Promise<string | undefined>;
43
- /** Called when a job/workflow hold is released — re-dispatch the element. */
43
+ /** Called when a job hold is released — re-dispatch the element. */
44
44
  onJobRelease: (signal: ReleaseSignal) => Promise<void>;
45
45
  /** Called when a step hold is released — notify the waiting agent (approved). */
46
46
  onStepRelease?: (signal: ReleaseSignal) => Promise<void>;
47
+ /**
48
+ * Called when a workflow-scoped hold is released (install gate approved) —
49
+ * rebuild the dispatch context and resume the workflow from the install gate.
50
+ */
51
+ onWorkflowRelease?: (signal: ReleaseSignal) => Promise<void>;
47
52
  /**
48
53
  * Called when a step-scoped hold is rejected — notify the waiting agent so it
49
54
  * fails the step instead of blocking until expiry. Carries the holdId.
50
55
  */
51
56
  onStepReject?: (heldRunId: string, reason?: string) => Promise<void> | void;
57
+ /**
58
+ * Called when a workflow-scoped hold is rejected (install gate rejected) —
59
+ * cancel the run and drop the pending workflow context. Carries the runId.
60
+ */
61
+ onWorkflowReject?: (runId: string) => Promise<void>;
52
62
  }
53
63
  /** Apply a single approve/reject decision to a hold. */
54
64
  export declare function applyDecision(deps: ApplyDecisionDeps, args: {
@@ -12,6 +12,11 @@ export interface InitResult {
12
12
  environmentName?: string;
13
13
  env?: Record<string, string>;
14
14
  concurrencyGroup?: string;
15
+ /**
16
+ * Resolved matrix combinations when the target job's matrix is a dynamic
17
+ * function. The dispatch path re-materializes these into N execution jobs.
18
+ */
19
+ matrixValues?: Array<Record<string, string | undefined>>;
15
20
  }
16
21
  export declare class PendingInitTracker extends PendingTracker<InitResult> {
17
22
  constructor();
@@ -25,6 +25,14 @@ export interface FleetTopologyResponse {
25
25
  * avoid a cross-package import in the CLI wire type.
26
26
  */
27
27
  export type GenericSourceGitConfigPayload = Record<string, unknown>;
28
+ /**
29
+ * Wire shape for a local filesystem source's config (`{ repoBasePath, cloneUrlBase? }`).
30
+ * Matches `LocalSourceConfigSchema` in `providers/local/local-source-config.ts`.
31
+ */
32
+ export interface GenericSourceLocalConfigPayload {
33
+ repoBasePath: string;
34
+ cloneUrlBase?: string;
35
+ }
28
36
  /**
29
37
  * Response shape for generic webhook sources from the admin API.
30
38
  */
@@ -134,6 +142,7 @@ export declare class AdminApiClient {
134
142
  rateLimitRpm?: number;
135
143
  providerType?: string;
136
144
  gitConfig?: GenericSourceGitConfigPayload;
145
+ localConfig?: GenericSourceLocalConfigPayload;
137
146
  }): Promise<{
138
147
  source: GenericSourceResponse;
139
148
  }>;
@@ -159,6 +168,8 @@ export declare class AdminApiClient {
159
168
  providerType?: string;
160
169
  /** `null` clears the config; omit to leave unchanged. */
161
170
  gitConfig?: GenericSourceGitConfigPayload | null;
171
+ /** `null` clears the config; omit to leave unchanged. */
172
+ localConfig?: GenericSourceLocalConfigPayload | null;
162
173
  }): Promise<{
163
174
  source: GenericSourceResponse;
164
175
  }>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Render the post-receive hook script. For each pushed ref the hook calls
3
+ * `kici-admin source trigger-local <id> --ref <ref> --sha <new> --base-url <url>`,
4
+ * so a push to any branch dispatches a run for that ref.
5
+ */
6
+ export declare function renderPostReceiveHook(opts: {
7
+ sourceId: string;
8
+ baseUrl: string;
9
+ }): string;
10
+ /**
11
+ * Write the rendered hook into the repo's `.git/hooks/post-receive` and make it
12
+ * executable. Throws when the path is not a git repo (no `.git/hooks` dir).
13
+ */
14
+ export declare function installPostReceiveHook(repoPath: string, script: string): string;
15
+ //# sourceMappingURL=local-hook.d.ts.map
@@ -0,0 +1,24 @@
1
+ export interface LocalTriggerInput {
2
+ orgId: string;
3
+ sourceId: string;
4
+ repoFullName: string;
5
+ event: 'push' | 'pull_request';
6
+ ref: string;
7
+ sha: string;
8
+ defaultBranch: string;
9
+ }
10
+ export interface LocalTriggerRequest {
11
+ path: string;
12
+ headers: Record<string, string>;
13
+ body: string;
14
+ }
15
+ /** Build the GitHub-shaped webhook request the local provider normalizer expects. */
16
+ export declare function buildLocalTriggerRequest(input: LocalTriggerInput): LocalTriggerRequest;
17
+ /** Read HEAD ref + sha from a local git repo (used when the operator omits --ref/--sha). */
18
+ export declare function readRepoHead(repoPath: string): {
19
+ ref: string;
20
+ sha: string;
21
+ };
22
+ /** POST the trigger request to the orchestrator base URL. Returns the HTTP status. */
23
+ export declare function sendLocalTrigger(baseUrl: string, req: LocalTriggerRequest): Promise<number>;
24
+ //# sourceMappingURL=local-trigger.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Remote-source inspection command for kici-admin.
3
+ *
4
+ * Subcommand namespace: `kici-admin remote-source show`.
5
+ *
6
+ * The remote-source anchor (`remote_sources` table) maps the deterministic
7
+ * routing key `remote:<orgId>` to the orchestrator's canonical org id so a
8
+ * Platform-relayed `kici run remote` resolves the real tenant. It is
9
+ * auto-provisioned on Platform auth; this command lets an operator inspect or
10
+ * confirm the row when debugging org-anchor issues on a hidden orchestrator.
11
+ *
12
+ * Reads the orchestrator DB directly (on-host operator inspection), so it stays
13
+ * usable even when Platform is unreachable.
14
+ */
15
+ import type { Command } from 'commander';
16
+ export declare function registerRemoteSourceCommands(program: Command): void;
17
+ //# sourceMappingURL=remote-source.d.ts.map
@@ -85,6 +85,20 @@ export declare function getInstallBase(platform: ServicePlatform, name: string):
85
85
  * 5. Update symlink (Unix) or service registration (Windows)
86
86
  * 6. Start service
87
87
  */
88
+ /**
89
+ * Resolve the target version for an npm-source upgrade (no --from/--url).
90
+ *
91
+ * The npm-source flow assumes the operator already ran
92
+ * `npm install -g @kici-dev/<pkg>@<version>`, which overwrites the global
93
+ * package in place. The running `kici-admin` binary is therefore the new
94
+ * version, and `running` is its self-reported version. We default the target
95
+ * to it, or validate an explicitly-passed --version matches — a mismatch means
96
+ * the npm install did not actually update the global binary.
97
+ */
98
+ export declare function resolveNpmSourceVersion(opts: {
99
+ requested: string | undefined;
100
+ running: string;
101
+ }): string;
88
102
  export declare function performVersionedUpgrade(component: UpgradeComponent, opts: VersionedUpgradeOptions): Promise<void>;
89
103
  export {};
90
104
  //# sourceMappingURL=versioned-upgrade.d.ts.map
@@ -19,4 +19,17 @@ import { Command } from 'commander';
19
19
  export declare function buildProgram(): Command;
20
20
  /** Build the program and parse argv — the bin-shim entry point. */
21
21
  export declare function runCli(argv?: string[]): void;
22
+ /**
23
+ * Canonicalize a path through any symlinks, falling back to a plain `resolve`
24
+ * when the target does not exist on disk. The entry-point guard compares the
25
+ * invoked script path against this module's own path; both sides must be fully
26
+ * canonicalized or a symlinked invocation path silently fails the match. The
27
+ * canonical example is the light-package launcher running
28
+ * `node /tmp/.../kici-admin.cjs` on macOS, where `/tmp` is a symlink to
29
+ * `/private/tmp`: `process.argv[1]` keeps the `/tmp` form while the bundle's
30
+ * `import.meta.url` resolves to the real `/private/tmp` path, so an
31
+ * un-canonicalized comparison is always false and the CLI exits 0 without
32
+ * running any command.
33
+ */
34
+ export declare function canonicalize(p: string): string;
22
35
  //# sourceMappingURL=kici-admin.d.ts.map