@kici-dev/orchestrator 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/__test-helpers__/mock-db-query.d.ts +4 -5
  2. package/dist/agent/agent-version.d.ts +5 -5
  3. package/dist/agent/dispatcher.d.ts +26 -0
  4. package/dist/agent/registry.d.ts +7 -9
  5. package/dist/agent-packaging/node-runtime-members.d.ts +14 -0
  6. package/dist/app.d.ts +3 -3
  7. package/dist/approvals/apply-decision.d.ts +1 -1
  8. package/dist/audit/access-log.d.ts +2 -3
  9. package/dist/cli/api-client.d.ts +20 -1
  10. package/dist/cli/commands/access-log.d.ts +3 -3
  11. package/dist/cli/commands/agent-service/agent-env.d.ts +20 -0
  12. package/dist/cli/commands/agent-service/status.d.ts +3 -3
  13. package/dist/cli/commands/attestations.d.ts +10 -0
  14. package/dist/cli/commands/cold-store-impl.d.ts +3 -3
  15. package/dist/cli/commands/cold-store.d.ts +6 -3
  16. package/dist/cli/commands/context.d.ts +5 -3
  17. package/dist/cli/commands/dashboard-encryption-key.d.ts +18 -0
  18. package/dist/cli/commands/event-dlq.d.ts +5 -6
  19. package/dist/cli/commands/event-log.d.ts +2 -3
  20. package/dist/cli/commands/execution.d.ts +1 -3
  21. package/dist/cli/commands/orchestrator-service/status.d.ts +10 -3
  22. package/dist/cli/commands/queue.d.ts +1 -2
  23. package/dist/cli/commands/registration.d.ts +8 -4
  24. package/dist/cli/commands/runs.d.ts +2 -3
  25. package/dist/cli/commands/secret.d.ts +1 -0
  26. package/dist/cli/commands/service-health.d.ts +68 -0
  27. package/dist/cli/commands/shared/confirm.d.ts +19 -0
  28. package/dist/cli/commands/shared/env-file-mode.d.ts +3 -2
  29. package/dist/cli/commands/shared/upgrade-safety.d.ts +11 -5
  30. package/dist/cli/commands/shared/versioned-upgrade.d.ts +119 -7
  31. package/dist/cli/commands/workflow.d.ts +3 -4
  32. package/dist/cli/open-browser.d.ts +1 -1
  33. package/dist/cli/service/entrypoint.d.ts +18 -0
  34. package/dist/cli/service/image-digests.d.ts +10 -0
  35. package/dist/cli/service/index.d.ts +4 -2
  36. package/dist/cli/service/instance/manifest.d.ts +39 -0
  37. package/dist/cli/service/launchd.d.ts +45 -10
  38. package/dist/cli/service/shutdown-grace.d.ts +35 -0
  39. package/dist/cli/service/types.d.ts +9 -0
  40. package/dist/cli/service/windows-acl.d.ts +40 -0
  41. package/dist/cli/service/windows-env-file.d.ts +45 -0
  42. package/dist/cli/service/windows.d.ts +13 -0
  43. package/dist/cli.js +1869 -707
  44. package/dist/cluster/cluster-identity.d.ts +4 -4
  45. package/dist/cluster/join-token.d.ts +2 -2
  46. package/dist/cluster/leader-gated-scheduler.d.ts +7 -1
  47. package/dist/cluster/peer-credentials.d.ts +1 -1
  48. package/dist/cluster/raft-state.d.ts +6 -0
  49. package/dist/cluster/raft.d.ts +16 -2
  50. package/dist/cold-store/load-access-log-range.d.ts +3 -3
  51. package/dist/cold-store/load-event-log-range.d.ts +1 -1
  52. package/dist/cold-store/load-secret-audit-log-range.d.ts +2 -2
  53. package/dist/cold-store/orchestrator-cold-store.d.ts +9 -11
  54. package/dist/cold-store/tables/access-log.d.ts +2 -2
  55. package/dist/cold-store/tables/event-log.d.ts +4 -10
  56. package/dist/cold-store/tables/execution-jobs.d.ts +1 -1
  57. package/dist/cold-store/tables/execution-runs.d.ts +4 -4
  58. package/dist/cold-store/tables/execution-steps.d.ts +1 -1
  59. package/dist/cold-store/tables/secret-audit-log.d.ts +3 -3
  60. package/dist/config.d.ts +3 -1
  61. package/dist/contexts/held-runs.d.ts +2 -2
  62. package/dist/contexts/variable-store.d.ts +2 -0
  63. package/dist/dashboard/attestation-filters.d.ts +1 -1
  64. package/dist/dashboard/handler.d.ts +8 -8
  65. package/dist/db/deferred-indexes.d.ts +2 -2
  66. package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +2 -4
  67. package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +4 -4
  68. package/dist/db/migrations/007_audit_logs_archived_at.d.ts +6 -9
  69. package/dist/db/migrations/008_event_log_archived_at.d.ts +4 -6
  70. package/dist/db/migrations/010_cold_store_chunks.d.ts +2 -2
  71. package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +2 -4
  72. package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +2 -2
  73. package/dist/db/migrations/045_host_properties.d.ts +1 -1
  74. package/dist/db/migrations/046_join_token_consumed_by_instance.d.ts +1 -1
  75. package/dist/db/migrations/048_host_reboot_pending.d.ts +1 -1
  76. package/dist/db/migrations/049_held_runs_payload.d.ts +1 -1
  77. package/dist/db/migrations/050_sources_slug.d.ts +1 -1
  78. package/dist/db/migrations/051_binding_host_pattern.d.ts +1 -1
  79. package/dist/db/migrations/052_host_reach_metadata.d.ts +1 -1
  80. package/dist/db/migrations/053_agent_token_single_use.d.ts +1 -1
  81. package/dist/db/migrations/054_local_working_tree.d.ts +1 -1
  82. package/dist/db/migrations/055_agent_token_mandatory_labels.d.ts +1 -1
  83. package/dist/db/migrations/056_execution_jobs_environments.d.ts +1 -1
  84. package/dist/db/migrations/064_execution_jobs_skipped_environments.d.ts +1 -1
  85. package/dist/db/types.d.ts +12 -13
  86. package/dist/events/types.d.ts +1 -1
  87. package/dist/fault-injection-types.d.ts +2 -2
  88. package/dist/firecracker/host-network.d.ts +21 -3
  89. package/dist/firecracker/net-interfaces.d.ts +1 -1
  90. package/dist/helpers/run-detached.d.ts +12 -0
  91. package/dist/index.js +76 -14
  92. package/dist/oidc/db-signer.d.ts +1 -1
  93. package/dist/pipeline/global-eval-round.d.ts +2 -2
  94. package/dist/pipeline/processor.d.ts +2 -2
  95. package/dist/provenance/retrier-mint.d.ts +1 -1
  96. package/dist/provenance/trust-root.d.ts +3 -3
  97. package/dist/providers/universal-git/clone-token.d.ts +9 -13
  98. package/dist/providers/universal-git/index.d.ts +1 -2
  99. package/dist/providers/universal-git/normalizer.d.ts +2 -3
  100. package/dist/providers/universal-git/ssh-auth.d.ts +4 -4
  101. package/dist/queue/cleanup.d.ts +2 -2
  102. package/dist/queue/job-queue.d.ts +6 -6
  103. package/dist/queue/scheduled-job.d.ts +5 -7
  104. package/dist/registration/extractor.d.ts +1 -1
  105. package/dist/registration/registration-index.d.ts +1 -1
  106. package/dist/reporting/execution-tracker.d.ts +3 -3
  107. package/dist/routes/admin-access-log.d.ts +1 -1
  108. package/dist/routes/admin-auth.d.ts +2 -2
  109. package/dist/routes/admin-contexts.d.ts +6 -0
  110. package/dist/routes/admin-event-log.d.ts +2 -2
  111. package/dist/routes/admin-registrations.d.ts +2 -2
  112. package/dist/routes/admin-runs.d.ts +3 -3
  113. package/dist/routes/admin-scheduled-jobs.d.ts +2 -3
  114. package/dist/routes/health.d.ts +9 -0
  115. package/dist/scaler/container-backend.d.ts +1 -1
  116. package/dist/scaler/firecracker-backend.d.ts +15 -10
  117. package/dist/scaler/firecracker-extra-hosts.d.ts +20 -0
  118. package/dist/scaler/machine-ledger.d.ts +3 -4
  119. package/dist/scaler/scaler-state-store.d.ts +1 -1
  120. package/dist/scaler/types.d.ts +4 -1
  121. package/dist/secrets/audit-logger.d.ts +3 -3
  122. package/dist/security/reduced-privilege-note.d.ts +2 -3
  123. package/dist/security/trust-policy-store.d.ts +3 -3
  124. package/dist/server.d.ts +2 -1
  125. package/dist/server.js +2885 -2211
  126. package/dist/stale-detector/stale-run-detector.d.ts +1 -1
  127. package/dist/standalone.d.ts +1 -1
  128. package/dist/standalone.js +2254 -1629
  129. package/dist/storage/filesystem.d.ts +1 -1
  130. package/dist/storage/index.d.ts +1 -1
  131. package/dist/storage/sign-url.d.ts +2 -1
  132. package/dist/storage/types.d.ts +2 -2
  133. package/dist/ws/agent-handler.d.ts +34 -3
  134. package/dist/ws/agent-heartbeat.d.ts +2 -3
  135. package/dist/ws/dashboard-context-handler.d.ts +1 -1
  136. package/dist/ws/platform-client.d.ts +44 -32
  137. package/dist/ws/server-options.d.ts +1 -1
  138. package/dist/ws/test-relay-handlers.d.ts +1 -1
  139. package/installer-image-digests.json +3 -3
  140. package/package.json +4 -4
  141. package/sbom.spdx.json +53 -53
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * Predicate + projection evaluation for the shared `createMockDb` harness.
3
3
  *
4
- * Kept BYTE-IDENTICAL in two places —
5
- * `packages/orchestrator/src/__test-helpers__/mock-db-query.ts` and
6
- * `packages/platform/src/__test-helpers__/mock-db-query.ts`. Each package owns an
4
+ * Kept BYTE-IDENTICAL in the orchestrator and the Platform, which each carry a
5
+ * copy. Each package owns an
7
6
  * independent `createMockDb` builder and neither package may import the other, so
8
- * the evaluator is duplicated rather than shared. `mock-db-mirror.test.ts` in both
9
- * packages fails the moment the copies diverge.
7
+ * the evaluator is duplicated rather than shared. A drift test fails the moment
8
+ * the copies diverge.
10
9
  *
11
10
  * `createMockDb` used to return its configured rows verbatim, whatever the
12
11
  * query asked for: a `.where(...)` or a `.select([...])` was recorded on a spy
@@ -4,8 +4,8 @@
4
4
  * An agent reports its own package version in `agent.register`
5
5
  * (`agentRegisterSchema.version`), and the field is optional — an agent old
6
6
  * enough to omit it predates every feature this module gates on. The
7
- * orchestrator and the agent are deployed and upgraded independently
8
- * (`.claude/rules/compatibility.md`), so a feature the orchestrator ships is
7
+ * orchestrator and the agent are deployed and upgraded independently,
8
+ * so a feature the orchestrator ships is
9
9
  * routinely dispatched to a fleet that cannot run it, and the version is the
10
10
  * only fact the orchestrator has about what the fleet understands.
11
11
  */
@@ -16,9 +16,9 @@ type VersionBase = [number, number, number];
16
16
  * the string is not a version at all.
17
17
  *
18
18
  * The prerelease suffix is dropped rather than ordered because the suffixes in
19
- * play are build counters from the dev registry (`0.5.0-9159`), not semver
20
- * release candidates. Strict semver orders those BELOW `0.5.0`, which would
21
- * read every staging agent as too old for a feature it in fact carries.
19
+ * play are build counters (`0.5.0-9159`), not semver release candidates. Strict
20
+ * semver orders those BELOW `0.5.0`, which would read every agent on a
21
+ * prerelease build as too old for a feature it in fact carries.
22
22
  */
23
23
  export declare function parseVersionBase(version: string): VersionBase | null;
24
24
  /**
@@ -444,6 +444,32 @@ export declare class Dispatcher {
444
444
  private failRefusedDispatch;
445
445
  /** Free the slot and tracking a claim took on its agent; a claim for no agent took none. */
446
446
  private releaseClaimAccounting;
447
+ /**
448
+ * Release the slot and tracking `jobId` holds on `agentId`, if the job is
449
+ * still tracked there. Returns false when another path (a refusal, a
450
+ * put-back, a disconnect) already took it.
451
+ */
452
+ private releaseTrackedClaim;
453
+ /**
454
+ * Hand a job this coordinator just claimed from the queue to `agentId`,
455
+ * whose slot the claim took. A query that fails before the job is sent
456
+ * returns the claim ({@link returnUndeliveredClaim}) and rethrows, so the
457
+ * agent is not left holding a slot for a job it never received.
458
+ *
459
+ * @returns whether the job was sent.
460
+ */
461
+ private sendClaimedJob;
462
+ /**
463
+ * Put back a job a queue claim took but did not send: a query failed between
464
+ * the claim and the send. The agent's slot (and the job's tracking, once
465
+ * taken) is released so the agent takes work again, and the row returns to
466
+ * pending without spending a dispatch attempt, since no agent saw it. The
467
+ * next drain or the pending re-drive offers it again. A job a refusal or a
468
+ * disconnect already took is left to that path. If the put-back fails too,
469
+ * the row stays dispatched with no ack deadline and the stale-dispatch scan
470
+ * reaps it.
471
+ */
472
+ private returnUndeliveredClaim;
447
473
  /** Record that a job began executing on its agent. */
448
474
  markJobStarted(jobId: string): void;
449
475
  /**
@@ -117,7 +117,7 @@ export interface AgentEntry {
117
117
  * The `agent_tokens.id` row used to authenticate this connection, or
118
118
  * `null` when auth mode is `none`. Indexed by `tokenIdIndex` so a
119
119
  * synchronous revocation kick can enumerate every WS authenticated by
120
- * a given token. in the pentest catalog.
120
+ * a given token.
121
121
  */
122
122
  tokenId: string | null;
123
123
  hostname: string | null;
@@ -240,10 +240,9 @@ export declare class AgentRegistry {
240
240
  *
241
241
  * Idempotent: re-scheduling the same tokenId is a no-op as long as
242
242
  * a timer is still queued — a token's `expires_at` doesn't shift
243
- * across reconnects of the same agent. Closes the sister gap
244
- * to the revocation finding (`agent-token-revocation-stale-ws`,
245
- * fixed in `993bc3d9d`) where natural TTL expiration had no
246
- * propagation path to in-flight WS connections.
243
+ * across reconnects of the same agent. Revocation kicks a token's
244
+ * in-flight WS connections at once; these timers do the same when
245
+ * the token reaches its natural TTL.
247
246
  */
248
247
  private readonly tokenExpiryTimers;
249
248
  /**
@@ -317,10 +316,9 @@ export declare class AgentRegistry {
317
316
  * Caller is the agent WS handler at register-time, when the token's
318
317
  * `agent_tokens.expires_at` column is non-null. Static tokens have
319
318
  * `expires_at = null` and are skipped at the call site (they have
320
- * no TTL by design). Closes the sister gap to the revocation
321
- * finding (`agent-token-revocation-stale-ws`, fixed in `993bc3d9d`)
322
- * where natural TTL expiration had no propagation path to
323
- * in-flight WS connections.
319
+ * no TTL by design). Revocation kicks a token's in-flight WS
320
+ * connections at once; this timer does the same at the token's
321
+ * natural TTL.
324
322
  */
325
323
  scheduleExpiryKick(tokenId: string, expiresAt: Date): void;
326
324
  /**
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The members of an official Node.js Linux or macOS archive that a KiCI payload
3
+ * vendors, relative to the archive's `node-v<version>-<os>-<arch>/` directory:
4
+ * the `node` binary, the `npm` and `npx` launchers, and the bundled npm package.
5
+ * With them in place, the agent's `resolveNpm()` finds
6
+ * `<nodeDir>/../lib/node_modules/npm/bin/npm-cli.js` beside the vendored `node`,
7
+ * so the builder role needs no npm on the host.
8
+ *
9
+ * This module has no imports so that repository tooling can read the list:
10
+ * `scripts/lib/node-dist.mjs` (the standalone package builder) keeps its own
11
+ * copy, and its test pins the two lists equal.
12
+ */
13
+ export declare const NODE_RUNTIME_MEMBERS: readonly ['bin/node', 'bin/npm', 'bin/npx', 'lib/node_modules/npm'];
14
+ //# sourceMappingURL=node-runtime-members.d.ts.map
package/dist/app.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * - Request ID and logging middleware
11
11
  * - 25MB body size limit
12
12
  *
13
- * Pattern follows packages/platform/src/app.ts: returns { app, wss }.
13
+ * Same pattern as the Platform's app: returns { app, wss }.
14
14
  */
15
15
  import type { Kysely } from 'kysely';
16
16
  import type pg from 'pg';
@@ -197,7 +197,7 @@ export interface AppDependencies {
197
197
  */
198
198
  faultInjection?: import('./fault-injection-types.js').OrchestratorFaultInjection;
199
199
  /**
200
- * Orchestrator-owned provenance signing (Phase 1 root of trust). Present when
200
+ * Orchestrator-owned provenance signing (the root of trust). Present when
201
201
  * `KICI_ORCHESTRATOR_PROVENANCE_ISSUER` is configured: the orchestrator mints +
202
202
  * signs identity tokens locally with its own ES256 key, and serves its own
203
203
  * OIDC discovery + JWKS + native verify endpoint. `resolveOrchestratorSigner`
@@ -342,7 +342,7 @@ export interface AppDependencies {
342
342
  globalWorkflowPolicy?: GlobalWorkflowPolicy;
343
343
  /** Inbound webhook delivery log writer. Optional -- if not set, deliveries are not persisted to event_log. */
344
344
  eventLogWriter?: EventLogWriter;
345
- /** Cold-store handle (Phase E). Optional -- when present, admin event-log routes can serve archived rows. */
345
+ /** Cold-store handle. Optional -- when present, admin event-log routes can serve archived rows. */
346
346
  coldStore?: ColdStore | null;
347
347
  /** Read + mutation attribution log writer. Optional -- if not set, access_log rows are not written. */
348
348
  accessLogWriter?: AccessLogWriter;
@@ -50,7 +50,7 @@ export interface ApplyDecisionResult {
50
50
  export interface ApplyDecisionDeps {
51
51
  orgId: string;
52
52
  store: HeldRunStore;
53
- /** Team name → member user ids (from the Plan-1 trust-policy cache). */
53
+ /** Team name → member user ids (from the trust-policy cache). */
54
54
  teamMembershipLookup: TeamMembershipLookup;
55
55
  /** Whether the run triggerer may self-approve (org_settings.allow_self_approval). */
56
56
  allowSelfApproval: boolean;
@@ -88,11 +88,10 @@ export declare class AccessLogWriter {
88
88
  recordInTransaction(executor: Kysely<Database> | Transaction<Database>, entry: AccessLogRecord): Promise<void>;
89
89
  private insert;
90
90
  /**
91
- * Phase D: delegates to `loadAccessLogRange` so cold-store rows are
91
+ * Delegates to `loadAccessLogRange` so cold-store rows are
92
92
  * merged transparently when pagination crosses the warm cutoff. The
93
93
  * caller-visible `{items, nextCursor}` shape is preserved. NO
94
- * --include-archived flag — access_log is "paginated/transparent"
95
- * per design §7 row 11.
94
+ * --include-archived flag — access_log is "paginated/transparent".
96
95
  */
97
96
  query(filter: AccessLogQueryFilter): Promise<AccessLogQueryResult>;
98
97
  /**
@@ -158,6 +158,25 @@ export declare class AdminApiClient {
158
158
  }>;
159
159
  setSecret(orgId: string, scope: string, key: string, value: string): Promise<void>;
160
160
  deleteSecret(orgId: string, scope: string, key: string): Promise<void>;
161
+ /**
162
+ * Create an empty secret scope. A `<backend>:` qualifier selects the
163
+ * backend; an unqualified scope targets the PG backend. Creating a scope
164
+ * that already exists succeeds and changes nothing.
165
+ */
166
+ createScope(orgId: string, scope: string): Promise<{
167
+ created: boolean;
168
+ }>;
169
+ /**
170
+ * Rename a secret scope inside its backend. The route refuses a move between
171
+ * backends and a rename onto a scope that already exists.
172
+ */
173
+ renameScope(orgId: string, oldScope: string, newScope: string): Promise<{
174
+ renamed: boolean;
175
+ }>;
176
+ /** Delete a secret scope and every secret in it. */
177
+ deleteScope(orgId: string, scope: string): Promise<{
178
+ deleted: boolean;
179
+ }>;
161
180
  /**
162
181
  * Create (or upsert) a deployment context. `allowLocalExecution` lets
163
182
  * CLI-initiated / local runs resolve secrets through this context.
@@ -273,7 +292,7 @@ export declare class AdminApiClient {
273
292
  to?: string;
274
293
  limit?: number;
275
294
  offset?: number;
276
- /** Phase D opt-in for cold-store read-through. */
295
+ /** Opt-in cold-store read-through. */
277
296
  includeArchived?: boolean;
278
297
  }): Promise<any[]>;
279
298
  createToken(data: {
@@ -2,9 +2,9 @@
2
2
  * Access log commands for kici-admin.
3
3
  *
4
4
  * Operator-facing read access to the orchestrator's access_log table
5
- * (read + mutation attribution with ActorPrincipal). Dogfood replacement
6
- * for raw psql when an operator asks "who read this run's payload last
7
- * Tuesday" or "show me everything a platform_operator actor did".
5
+ * (read + mutation attribution with ActorPrincipal). Use it instead of raw
6
+ * psql when an operator asks "who read this run's payload last Tuesday" or
7
+ * "show me everything a platform_operator actor did".
8
8
  *
9
9
  * access-log list List access-log rows with filters (cursor-paginated)
10
10
  * access-log show Show a single entry by id
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The env file `kici-admin agent install` writes for a new agent. Each field
3
+ * lands in the variable the agent's config loader reads; that loader refuses
4
+ * any KICI_* variable it does not know, so a misspelt key here stops the agent
5
+ * at startup. `agent-env.test.ts` loads the rendered file through the agent's
6
+ * own loader to hold the two together.
7
+ */
8
+ export interface AgentEnvFields {
9
+ /** First line of the file, a `#` comment naming what wrote it. */
10
+ header: string;
11
+ orchestratorUrl?: string;
12
+ token?: string;
13
+ /** Routing labels, written comma-separated. */
14
+ labels?: string[];
15
+ /** The agent's HTTP port; omitted, the agent uses its default. */
16
+ port?: number;
17
+ }
18
+ /** Render the env file, one `KEY=value` line per field that was given. */
19
+ export declare function renderAgentEnvFile(fields: AgentEnvFields): string;
20
+ //# sourceMappingURL=agent-env.d.ts.map
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * `kici-admin agent status` command.
3
3
  *
4
- * Shows OS-level service status (state, PID, uptime) and queries
5
- * the running agent's health API for agent-specific info (labels,
6
- * orchestrator connection, current job).
4
+ * Shows OS-level service status (state, PID, uptime) and queries the
5
+ * running agent's `/health` endpoint for its ID, orchestrator connection,
6
+ * active job count, version, build fingerprint and uptime.
7
7
  *
8
8
  * Target resolution goes through resolveInstanceTarget — the same priority chain
9
9
  * every lifecycle command uses (--instance-dir > --name > CWD manifest >
@@ -1,3 +1,13 @@
1
+ /**
2
+ * `kici-admin attestations` — orchestrator-DB-direct provenance maintenance.
3
+ *
4
+ * attestations reverify [--all] Recompute stored verdicts (verify-at-ingest
5
+ * backfill). Default scope: pending /
6
+ * unverifiable rows; `--all` re-evaluates
7
+ * every row. Direct DB + object storage.
8
+ *
9
+ * Belongs to `kici-admin`: it works on the orchestrator's database.
10
+ */
1
11
  import type { Command } from 'commander';
2
12
  import type { AdminApiClient } from '../api-client.js';
3
13
  export declare function registerAttestationsCommands(program: Command, getClient: () => AdminApiClient): void;
@@ -45,7 +45,7 @@ export declare function replayChunk(opts: {
45
45
  instanceId?: string;
46
46
  }): Promise<void>;
47
47
  /**
48
- * Phase F — promote a chunk's rows BACK into the orchestrator PG.
48
+ * Promote a chunk's rows back into the orchestrator PG.
49
49
  * Mirrors the Platform-side `replayIntoPg`. Adapter must implement
50
50
  * `replayInsert` — currently only `execution_runs`.
51
51
  */
@@ -65,7 +65,7 @@ export declare function reconcile(opts: {
65
65
  instanceId?: string;
66
66
  }): Promise<void>;
67
67
  /**
68
- * Phase 2 — list chunks past their cold-retention horizon. Read-only;
68
+ * List chunks past their cold-retention horizon. Read-only;
69
69
  * no S3 or PG mutation. Emits one JSON line per row so the output is
70
70
  * easy to pipe through `jq` / `column -t` / etc.
71
71
  */
@@ -77,7 +77,7 @@ export declare function listPurgeable(opts: {
77
77
  instanceId?: string;
78
78
  }): Promise<void>;
79
79
  /**
80
- * Phase 2 — delete S3 objects + clean up PG bookkeeping for chunks
80
+ * Delete S3 objects + clean up PG bookkeeping for chunks
81
81
  * past their cold-retention horizon. Defaults to dry-run; pass
82
82
  * `--apply` to actually delete.
83
83
  */
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Cold-store commands for kici-admin (orchestrator side).
3
3
  *
4
- * Phase C: every subcommand has a real implementation that builds an
5
- * `OrchestratorColdStore` against the orchestrator Postgres + S3 and
6
- * delegates to the helpers in `cold-store-impl.ts`. Mirrors
4
+ * Every subcommand builds an `OrchestratorColdStore` against the
5
+ * orchestrator Postgres + S3 and delegates to the helpers in
6
+ * `cold-store-impl.ts`. Mirrors
7
7
  * `kici-platform-admin cold-store …` on the Platform side.
8
8
  *
9
9
  * cold-store archive-now <table> Run one cycle for a single adapter
@@ -11,7 +11,10 @@
11
11
  * cold-store list-chunks <table> List chunks for a table
12
12
  * cold-store verify-chunk <chunkId> Recompute contentHash for a chunk
13
13
  * cold-store replay-chunk <chunkId> Re-run UPDATE+DELETE for a stuck chunk
14
+ * cold-store replay-into-pg <chunkId> Promote a chunk's rows back into PG
14
15
  * cold-store reconcile <table> Rebuild orphaned manifests from data
16
+ * cold-store list-purgeable List chunks past cold retention
17
+ * cold-store purge-now Purge expired chunks (dry-run default)
15
18
  * cold-store peek-chunk <chunkId> Stream the first N rows of a chunk
16
19
  *
17
20
  * The CLI talks **directly** to the orchestrator Postgres (and the same
@@ -8,16 +8,18 @@
8
8
  * context show — show a single context with variables + bindings
9
9
  * context delete — delete a context (cascades bindings, variables, overrides; held-run history survives; pending held runs block with a clear error, resolved holds do not)
10
10
  * context create-template — create/update a context template + its seed variables
11
+ * context source-override list|set|delete — per-source variable overrides (HTTP only)
11
12
  *
12
- * Each command supports two modes (stage-4 pattern from `maintenance.ts`):
13
+ * Each command except `source-override` supports two modes, the same split
14
+ * `maintenance.ts` uses:
13
15
  *
14
16
  * HTTP mode (default): requires `--url` + `--token`, routes through the
15
17
  * orchestrator admin HTTP API at /api/v1/admin/contexts.
16
18
  *
17
19
  * Direct-DB mode: activated when `--database-url` is passed (or
18
20
  * KICI_DATABASE_URL / DATABASE_URL is set). Opens its own pool and runs the
19
- * SQL directly via *Direct helpers in @kici-dev/shared. Used by E2E
20
- * `globalSetup` helpers that need to seed envs before the orchestrator is up.
21
+ * SQL directly via *Direct helpers in @kici-dev/shared, so a setup script can
22
+ * seed contexts before the orchestrator is up.
21
23
  */
22
24
  import type { Command } from 'commander';
23
25
  import type { AdminApiClient } from '../api-client.js';
@@ -1,3 +1,21 @@
1
+ /**
2
+ * `kici-admin dashboard-encryption-key` — the orchestrator's X25519
3
+ * dashboard-encryption key: the trust root a browser seals a secret / variable
4
+ * value to under the `encrypted` dashboard-write posture, so the hosted control
5
+ * plane relays only opaque ciphertext.
6
+ *
7
+ * dashboard-encryption-key show Print the active kid, its public JWK, where
8
+ * the JWKS is published, and the Verified-tier
9
+ * URL (when that tier is opted into).
10
+ * dashboard-encryption-key list List every key on record (kid / status / created_at).
11
+ * dashboard-encryption-key rotate Mint a new active key; the prior active key
12
+ * is retired from the published JWKS, but its
13
+ * private half stays on record so envelopes
14
+ * already sealed to it still decrypt.
15
+ *
16
+ * The PRIVATE half is master-key wrapped (`KICI_SECRET_KEY`) in the orchestrator
17
+ * DB and is never exportable — recovery from a lost key is a routine rotation.
18
+ */
1
19
  import type { Command } from 'commander';
2
20
  export declare function registerDashboardEncryptionKeyCommands(program: Command): void;
3
21
  //# sourceMappingURL=dashboard-encryption-key.d.ts.map
@@ -6,12 +6,11 @@
6
6
  * event-dlq retry <id> — clear DLQ flag, schedule for retry, pg_notify
7
7
  * event-dlq discard <id> — permanently delete a DLQ event
8
8
  *
9
- * Operator dogfooding path for at-least-once event delivery (Phase 5 of the
10
- * event durability work). Customers should generally never see anything in
11
- * the DLQ — when something lands here it usually means a workflow handler is
12
- * consistently failing and should be fixed at its root cause. This CLI is the
13
- * triage surface: inspect last_error, retry once a fix is deployed, or discard
14
- * if the event is no longer relevant.
9
+ * Operator triage path for at-least-once event delivery. Customers should
10
+ * generally never see anything in the DLQ — when something lands here it
11
+ * usually means a workflow handler is consistently failing and should be fixed
12
+ * at its root cause. This CLI is the triage surface: inspect last_error, retry
13
+ * once a fix is deployed, or discard if the event is no longer relevant.
15
14
  */
16
15
  import type { Command } from 'commander';
17
16
  import type { AdminApiClient } from '../api-client.js';
@@ -2,9 +2,8 @@
2
2
  * Inbound webhook delivery log commands for kici-admin.
3
3
  *
4
4
  * Operator-facing read access to the orchestrator's event_log table via the
5
- * admin HTTP API. Dogfood replacement for raw psql / log-grep when an
6
- * operator asks "did delivery <id> arrive, and what did its payload look
7
- * like".
5
+ * admin HTTP API. Use it instead of raw psql / log-grep when an operator
6
+ * asks "did delivery <id> arrive, and what did its payload look like".
8
7
  *
9
8
  * event-log list List inbound deliveries with filters
10
9
  * event-log show Show a single delivery (optionally with payload)
@@ -7,9 +7,7 @@
7
7
  * READ-ONLY — mutations (purge-stale) live in `maintenance.ts` instead.
8
8
  * Dual-mode: HTTP (via AdminApiClient) or `--database-url` (direct DB).
9
9
  *
10
- * supersedes the original `cache list|show` framing: the real tables
11
- * the E2E call sites touch are execution_runs / execution_jobs, not
12
- * dedup_cache.
10
+ * The rows come from execution_runs / execution_jobs, not dedup_cache.
13
11
  */
14
12
  import type { Command } from 'commander';
15
13
  import type { AdminApiClient } from '../api-client.js';
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * `kici-admin orchestrator status` command.
3
3
  *
4
- * Shows OS-level service status (state, PID, uptime) and queries
5
- * the running orchestrator's health API for KiCI-specific info
6
- * (mode, DB connectivity, agents, jobs, scaler).
4
+ * Shows OS-level service status (state, PID, uptime) and queries the
5
+ * running orchestrator's `/health` and `/ready` endpoints for its version,
6
+ * build fingerprint, uptime and readiness (database reachable, boot finished).
7
7
  *
8
8
  * Target resolution goes through resolveInstanceTarget — the same priority chain
9
9
  * every lifecycle command uses (--instance-dir > --name > CWD manifest >
@@ -11,6 +11,13 @@
11
11
  */
12
12
  import type { Command } from 'commander';
13
13
  import { type ServicePlatform } from '../../service/index.js';
14
+ /**
15
+ * How long to wait for `/ready`. Its database check waits up to the pool's
16
+ * acquire timeout before it reports `database: false`, so the wait covers that
17
+ * timeout plus a margin. An acquire timeout of 0 lets the pool wait without
18
+ * limit; the default then bounds the wait.
19
+ */
20
+ export declare function readinessTimeoutMs(envContent: string): number;
14
21
  /**
15
22
  * The config files this install owns, for an operator who wants to inspect
16
23
  * them. Derived from the instance manifest and the env file on disk, not from
@@ -7,8 +7,7 @@
7
7
  * READ-ONLY — mutations live in `maintenance.ts` (queue clear) instead.
8
8
  * Dual-mode: HTTP (via AdminApiClient) or `--database-url` (direct DB).
9
9
  *
10
- * supersedes the original `cache list|show` framing — the E2E call
11
- * sites were actually querying dispatch_queue, not a dedup cache.
10
+ * The rows come from dispatch_queue, not a dedup cache.
12
11
  */
13
12
  import type { Command } from 'commander';
14
13
  import type { AdminApiClient } from '../api-client.js';
@@ -1,16 +1,20 @@
1
1
  /**
2
- * Workflow registration read CLI commands for kici-admin (5a #4).
2
+ * Workflow registration CLI commands for kici-admin.
3
3
  *
4
4
  * registration list [--org <id>] [--routing-key <k>] [--repo <ident>] [--limit <n>]
5
5
  * registration show <id>
6
+ * registration disable <id> | enable <id>
7
+ * registration delete <id> [--yes]
6
8
  *
7
9
  * A distinct namespace from `workflow list` — `workflow` is workflow-code,
8
10
  * `registration` is the registered-workflow-instance row in
9
- * workflow_registrations. Both coexist; the existing `workflow list` is
10
- * untouched by this plan.
11
+ * workflow_registrations. Both coexist.
11
12
  *
12
- * Dual-mode: HTTP (via AdminApiClient on the existing
13
+ * `list` and `show` are dual-mode: HTTP (via AdminApiClient on the
13
14
  * /api/v1/admin/registrations admin API) or `--database-url` (direct DB).
15
+ * `disable`, `enable` and `delete` are HTTP only: they are the operator path
16
+ * for the dashboard's registration writes, and the admin route bumps the
17
+ * registry version so every peer reloads.
14
18
  */
15
19
  import type { Command } from 'commander';
16
20
  import type { AdminApiClient } from '../api-client.js';
@@ -2,9 +2,8 @@
2
2
  * Execution run commands for kici-admin.
3
3
  *
4
4
  * Provides operator-facing read access to execution runs and their
5
- * sub-resources via the orchestrator's admin HTTP API. This is the
6
- * dogfooded replacement for hand-rolled curl commands when inspecting
7
- * run state.
5
+ * sub-resources via the orchestrator's admin HTTP API. Use it instead of
6
+ * hand-rolled curl commands when inspecting run state.
8
7
  *
9
8
  * runs list List execution runs (table or JSON)
10
9
  * runs show <runId> Show run detail with jobs and steps
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Provides scoped secret operations:
5
5
  * secret scopes, list, set, delete, fix-prefixed-scopes
6
+ * secret scope create|rename|delete
6
7
  *
7
8
  * Secret values are write-only -- there is no "get value" command.
8
9
  */
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Reads a locally installed KiCI service's health endpoints and formats what
3
+ * they report. `kici-admin orchestrator status` and `kici-admin agent status`
4
+ * both render through here, so the two sections agree on layout and on how a
5
+ * missing field is handled.
6
+ */
7
+ import { type BuildFingerprint, type LivenessBase } from '@kici-dev/shared';
8
+ /** A label and its value: one line of a status section. */
9
+ export type StatusRow = readonly [label: string, value: string];
10
+ /**
11
+ * Read the env file, or empty content when it is missing or unreadable. A file
12
+ * this account may not read is reported: the port and address the caller then
13
+ * falls back to may not be the ones the service uses. On Windows only
14
+ * LocalSystem and Administrators can read a service's env file.
15
+ */
16
+ export declare function readEnvContent(envFilePath: string, warn?: (line: string) => void): string;
17
+ /** Where a service installed on this host answers HTTP. */
18
+ export interface LocalEndpoint {
19
+ host: string;
20
+ port: number;
21
+ /** The prefix the service's routes are mounted under; empty when they sit at `/`. */
22
+ pathPrefix: string;
23
+ }
24
+ /**
25
+ * Where the service answers, read from its env file: `KICI_PORT` (or
26
+ * `defaultPort`), `KICI_HOST` and `KICI_BASE_PATH`. A service bound to every
27
+ * interface is reached on `localhost`; one bound to a single address is reached
28
+ * there. The agent reads none of the last two, so its env file never sets them.
29
+ */
30
+ export declare function readLocalEndpoint(envContent: string, defaultPort: number): LocalEndpoint;
31
+ /** The URL of `pathname` on `endpoint`, with an IPv6 host bracketed. */
32
+ export declare function localUrl(endpoint: LocalEndpoint, pathname: string): string;
33
+ /**
34
+ * GET a JSON body from a service on this host. `acceptStatuses` names the
35
+ * non-2xx codes whose body is still an answer: `/ready` returns its checks
36
+ * with a 503 when one fails. Returns null when nothing answers in time.
37
+ */
38
+ export declare function fetchLocalJson<T>(endpoint: LocalEndpoint, pathname: string, opts?: {
39
+ acceptStatuses?: readonly number[];
40
+ timeoutMs?: number;
41
+ }): Promise<T | null>;
42
+ /**
43
+ * A `/health` body with its deprecated `buildCommit` replaced by its version.
44
+ * A service older than this CLI reports a commit ID from KiCI's private
45
+ * repository there, which a reader cannot resolve; `--json` keeps the key, a
46
+ * string as before, and carries the release version in it. A body that reports
47
+ * no `buildCommit` comes back unchanged.
48
+ */
49
+ export declare function hideBuildCommit<T extends {
50
+ version?: string;
51
+ buildCommit?: string;
52
+ }>(health: T): T;
53
+ /**
54
+ * Rows for the build fingerprint and process uptime of a `/health` body. A
55
+ * field the body lacks is skipped, so a service older than this CLI renders
56
+ * the fields it does report. The version line never shows `buildCommit`
57
+ * (see {@link hideBuildCommit}).
58
+ */
59
+ export declare function buildInfoRows(health: Partial<LivenessBase & BuildFingerprint & {
60
+ buildDate: string;
61
+ }>): StatusRow[];
62
+ /**
63
+ * A status section: a blank separator line, the heading, then one line per
64
+ * row with each value starting at `valueColumn`. A body with no field this CLI
65
+ * recognises still gets a line saying so, so the heading never stands alone.
66
+ */
67
+ export declare function formatHealthSection(heading: string, rows: readonly StatusRow[], valueColumn: number): string[];
68
+ //# sourceMappingURL=service-health.d.ts.map
@@ -0,0 +1,19 @@
1
+ /** Message of the error raised when stdin ends before the operator answers. */
2
+ export declare const NO_CONFIRMATION_ANSWER: string;
3
+ /** The streams the prompt writes to and reads from. */
4
+ export interface ConfirmIo {
5
+ input: NodeJS.ReadableStream;
6
+ output: NodeJS.WritableStream;
7
+ }
8
+ /**
9
+ * Write `prompt` and read one line of answer.
10
+ *
11
+ * Resolves true when the line is `y` or `yes` (any case, surrounding spaces
12
+ * ignored) and false for any other line. Rejects with
13
+ * {@link NO_CONFIRMATION_ANSWER} when stdin ends before a line arrives, as it
14
+ * does for a script, a cron job or a `< /dev/null` redirect. Resolving false
15
+ * there would let a verb run without `--yes` exit 0 having done nothing, and
16
+ * the script that ran it would read that as success.
17
+ */
18
+ export declare function confirmPrompt(prompt: string, io?: ConfirmIo): Promise<boolean>;
19
+ //# sourceMappingURL=confirm.d.ts.map
@@ -9,8 +9,9 @@
9
9
  * `cluster/peer-credentials.ts`.
10
10
  *
11
11
  * The guarantee is POSIX-only. Node maps a mode onto Windows by toggling the
12
- * read-only attribute and changes no ACL, so a Windows install must restrict
13
- * the file itself.
12
+ * read-only attribute and changes no ACL, so a Windows install restricts the
13
+ * folder that holds the file instead (`restrictEnvFileAccess`,
14
+ * `cli/service/windows-acl.ts`).
14
15
  */
15
16
  export declare const ENV_FILE_MODE = 384;
16
17
  //# sourceMappingURL=env-file-mode.d.ts.map