@kici-dev/orchestrator 0.15.0 → 0.17.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 (161) hide show
  1. package/dist/__test-helpers__/scratch-db.d.ts +16 -0
  2. package/dist/agent/registry.d.ts +1 -8
  3. package/dist/app-on-error.d.ts +1 -1
  4. package/dist/approvals/apply-decision.d.ts +12 -1
  5. package/dist/artifacts/artifact-store.d.ts +0 -2
  6. package/dist/audit/access-log.d.ts +1 -1
  7. package/dist/cache/source-cache.d.ts +1 -1
  8. package/dist/cache/user-cache.d.ts +0 -28
  9. package/dist/cli/api-client.d.ts +35 -1
  10. package/dist/cli/commands/access-log.d.ts +1 -1
  11. package/dist/cli/commands/api-key.d.ts +11 -4
  12. package/dist/cli/commands/cold-store-impl.d.ts +7 -84
  13. package/dist/cli/commands/db.d.ts +1 -0
  14. package/dist/cli/commands/orchestrator-service/status.d.ts +2 -0
  15. package/dist/cli/commands/org.d.ts +12 -0
  16. package/dist/cli/commands/scaler.d.ts +14 -0
  17. package/dist/cli/commands/secret.d.ts +1 -45
  18. package/dist/cli/commands/service-health.d.ts +21 -13
  19. package/dist/cli/commands/shared/cli-action.d.ts +17 -0
  20. package/dist/cli/commands/shared/db.d.ts +5 -5
  21. package/dist/cli/commands/shared/org-id.d.ts +5 -0
  22. package/dist/cli/commands/shared/service-verbs.d.ts +19 -0
  23. package/dist/cli/commands/shared/table.d.ts +3 -0
  24. package/dist/cli/commands/shared/unbound-context-warning.d.ts +2 -22
  25. package/dist/cli/commands/trust-policy.d.ts +7 -31
  26. package/dist/cli/kici-admin.d.ts +1 -1
  27. package/dist/cli.js +9865 -8203
  28. package/dist/cluster/coordinator.d.ts +2 -2
  29. package/dist/cluster/peer-client.d.ts +27 -1
  30. package/dist/cluster/peer-forget.d.ts +4 -9
  31. package/dist/cluster/peer-handler.d.ts +11 -1
  32. package/dist/cluster/peer-request-waiters.d.ts +26 -0
  33. package/dist/cluster/scaler-orphans-peer.d.ts +4 -9
  34. package/dist/cluster/scaler-reload-fanout.d.ts +29 -0
  35. package/dist/cluster/scaler-reload-peer.d.ts +16 -0
  36. package/dist/cluster/worker-cluster-settings.d.ts +1 -0
  37. package/dist/cold-store/load-access-log-range.d.ts +3 -3
  38. package/dist/cold-store/tables/access-log.d.ts +4 -12
  39. package/dist/cold-store/tables/event-log.d.ts +8 -19
  40. package/dist/cold-store/tables/execution-jobs.d.ts +7 -24
  41. package/dist/cold-store/tables/execution-runs.d.ts +6 -20
  42. package/dist/cold-store/tables/execution-steps.d.ts +8 -26
  43. package/dist/cold-store/tables/secret-audit-log.d.ts +4 -11
  44. package/dist/config/env-overlay.d.ts +3 -8
  45. package/dist/config/reload.d.ts +9 -2
  46. package/dist/config/schema.d.ts +2 -2
  47. package/dist/config/types.d.ts +2 -2
  48. package/dist/config.d.ts +13 -17
  49. package/dist/contexts/held-runs.d.ts +3 -6
  50. package/dist/dashboard/cursor.d.ts +12 -0
  51. package/dist/dashboard/handler.d.ts +5 -12
  52. package/dist/db/deferred-index-build.d.ts +42 -0
  53. package/dist/db/deferred-indexes.d.ts +3 -37
  54. package/dist/db/migrations/100_held_runs_hold_type_vocabulary.d.ts +3 -5
  55. package/dist/db/migrations/158_normalize_legacy_values.d.ts +4 -0
  56. package/dist/db/repos/org-ids-repo.d.ts +87 -0
  57. package/dist/db/schema-snapshot.generated.d.ts +3 -0
  58. package/dist/db/types.d.ts +5 -22
  59. package/dist/fault-injection-types.d.ts +0 -6
  60. package/dist/git/dispatch-git-auth.d.ts +6 -12
  61. package/dist/helpers/json.d.ts +3 -0
  62. package/dist/index.js +144 -140
  63. package/dist/metrics/prometheus.d.ts +0 -5
  64. package/dist/oidc/id-token-claims.d.ts +1 -1
  65. package/dist/oidc/resolve-signer.d.ts +2 -4
  66. package/dist/orchestrator-core.d.ts +10 -3
  67. package/dist/pipeline/global-eval-round.d.ts +2 -26
  68. package/dist/pipeline/install-secrets-resolver.d.ts +0 -3
  69. package/dist/pipeline/manual-schedule.d.ts +1 -7
  70. package/dist/pipeline/test-pipeline.d.ts +8 -7
  71. package/dist/provenance/dispatch-context.d.ts +5 -7
  72. package/dist/provenance/pending-attestations-repo.d.ts +1 -1
  73. package/dist/provenance/trust-root.d.ts +4 -5
  74. package/dist/provenance/verify-deferred-capture.d.ts +3 -3
  75. package/dist/provider-registry.d.ts +13 -40
  76. package/dist/providers/universal-git/ssh-auth.d.ts +0 -5
  77. package/dist/queue/terminalize-unroutable.d.ts +5 -0
  78. package/dist/reporting/check-run-reporter.d.ts +8 -21
  79. package/dist/reporting/check-run-summary.d.ts +2 -2
  80. package/dist/reporting/execution-tracker.d.ts +1 -1
  81. package/dist/reporting/log-chunk-sink.d.ts +1 -1
  82. package/dist/reporting/run-summary-fields.d.ts +25 -0
  83. package/dist/reporting/s3-log-storage.d.ts +2 -2
  84. package/dist/routes/admin-access-log.d.ts +2 -9
  85. package/dist/routes/admin-auth.d.ts +2 -0
  86. package/dist/routes/admin-backends.d.ts +2 -9
  87. package/dist/routes/admin-cluster-name.d.ts +2 -8
  88. package/dist/routes/admin-cluster-settings.d.ts +2 -8
  89. package/dist/routes/admin-config.d.ts +0 -3
  90. package/dist/routes/admin-contexts.d.ts +3 -11
  91. package/dist/routes/admin-db.d.ts +2 -9
  92. package/dist/routes/admin-env.d.ts +33 -0
  93. package/dist/routes/admin-event-dlq.d.ts +2 -9
  94. package/dist/routes/admin-event-inspect.d.ts +2 -9
  95. package/dist/routes/admin-event-log.d.ts +2 -9
  96. package/dist/routes/admin-events.d.ts +3 -13
  97. package/dist/routes/admin-held-runs.d.ts +2 -8
  98. package/dist/routes/admin-list-limit.d.ts +3 -0
  99. package/dist/routes/admin-maintenance.d.ts +2 -9
  100. package/dist/routes/admin-orchestrator-drain.d.ts +2 -9
  101. package/dist/routes/admin-org-settings.d.ts +2 -8
  102. package/dist/routes/admin-orgs.d.ts +27 -0
  103. package/dist/routes/admin-peer-forget.d.ts +2 -9
  104. package/dist/routes/admin-queue-execution.d.ts +3 -10
  105. package/dist/routes/admin-registrations.d.ts +3 -14
  106. package/dist/routes/admin-runs.d.ts +3 -14
  107. package/dist/routes/admin-scaler-orphans.d.ts +2 -9
  108. package/dist/routes/admin-scaler-reload.d.ts +41 -0
  109. package/dist/routes/admin-scheduled-jobs.d.ts +2 -9
  110. package/dist/routes/admin-signing-keys.d.ts +2 -9
  111. package/dist/routes/admin-sources.d.ts +2 -9
  112. package/dist/routes/admin-trust-policy.d.ts +2 -8
  113. package/dist/routes/admin.d.ts +15 -13
  114. package/dist/routes/caller-identity.d.ts +52 -0
  115. package/dist/routes/test-direct.d.ts +46 -0
  116. package/dist/routes/uploads.d.ts +12 -11
  117. package/dist/scaler/config.d.ts +12 -84
  118. package/dist/scaler/file-reload.d.ts +48 -0
  119. package/dist/scaler/manager.d.ts +47 -33
  120. package/dist/scaler/scaler-state-store.d.ts +5 -0
  121. package/dist/scaler/types.d.ts +1 -4
  122. package/dist/secrets/job-secret-gate.d.ts +2 -5
  123. package/dist/secrets/rbac.d.ts +5 -1
  124. package/dist/secrets/routing-key-scope.d.ts +1 -0
  125. package/dist/secrets/secret-resolver.d.ts +2 -4
  126. package/dist/secrets/token-manager.d.ts +1 -0
  127. package/dist/security/trust-policy-gate.d.ts +0 -4
  128. package/dist/server.d.ts +6 -17
  129. package/dist/server.js +9890 -10851
  130. package/dist/standalone.js +6928 -6576
  131. package/dist/storage/s3.d.ts +7 -7
  132. package/dist/storage/types.d.ts +4 -4
  133. package/dist/worker/reroute-dispatch.d.ts +1 -0
  134. package/dist/worker/reroute-spawn-control.d.ts +1 -3
  135. package/dist/worker-core.d.ts +9 -2
  136. package/dist/ws/agent-handler.d.ts +3 -3
  137. package/dist/ws/dashboard-access.d.ts +57 -0
  138. package/dist/ws/dashboard-backends-handler.d.ts +1 -6
  139. package/dist/ws/dashboard-context-handler.d.ts +10 -15
  140. package/dist/ws/dashboard-fleet-write-handler.d.ts +1 -6
  141. package/dist/ws/dashboard-global-workflows-handler.d.ts +1 -6
  142. package/dist/ws/dashboard-registrations-handler.d.ts +1 -7
  143. package/dist/ws/platform-client.d.ts +85 -330
  144. package/dist/ws/test-relay-handlers.d.ts +16 -9
  145. package/installer-image-digests.json +3 -3
  146. package/package.json +4 -4
  147. package/sbom.spdx.json +53 -53
  148. package/dist/cache/legacy-prefixes.d.ts +0 -19
  149. package/dist/cli/commands/agent-service/logs.d.ts +0 -14
  150. package/dist/cli/commands/agent-service/restart.d.ts +0 -12
  151. package/dist/cli/commands/agent-service/start.d.ts +0 -12
  152. package/dist/cli/commands/agent-service/stop.d.ts +0 -12
  153. package/dist/cli/commands/agent-service/uninstall.d.ts +0 -13
  154. package/dist/cli/commands/cache.d.ts +0 -51
  155. package/dist/cli/commands/orchestrator-service/logs.d.ts +0 -14
  156. package/dist/cli/commands/orchestrator-service/restart.d.ts +0 -12
  157. package/dist/cli/commands/orchestrator-service/start.d.ts +0 -12
  158. package/dist/cli/commands/orchestrator-service/stop.d.ts +0 -12
  159. package/dist/cli/commands/orchestrator-service/uninstall.d.ts +0 -13
  160. package/dist/git/inherited-secret.d.ts +0 -29
  161. package/dist/scaler/container-spawn.d.ts +0 -28
@@ -0,0 +1,16 @@
1
+ /** Throwaway PostgreSQL databases for DB-gated tests, dropped by `cleanup`. */
2
+ import pg from 'pg';
3
+ import { Kysely } from 'kysely';
4
+ export interface ScratchDb {
5
+ url: string;
6
+ pool: pg.Pool;
7
+ db: Kysely<any>;
8
+ }
9
+ /** Creates databases on `adminUrl`; `cleanup` drops every one of them. */
10
+ export declare function scratchDbFactory(adminUrl: string): {
11
+ freshDb: (tag: string) => Promise<ScratchDb>;
12
+ cleanup: () => Promise<void>;
13
+ };
14
+ /** The applied migration names, sorted. */
15
+ export declare function ledgerNames(db: Kysely<any>): Promise<string[]>;
16
+ //# sourceMappingURL=scratch-db.d.ts.map
@@ -9,7 +9,7 @@
9
9
  * No persistence needed -- agents re-register on reconnect.
10
10
  */
11
11
  import { type CanonicalLabel, type LabelMatcher } from '@kici-dev/engine';
12
- import type { AgentCapabilities, WsLike } from '@kici-dev/engine';
12
+ import type { WsLike } from '@kici-dev/engine';
13
13
  /**
14
14
  * The longest a busy rejection holds an agent out of routing when no evidence
15
15
  * of a free slot lifts the hold first: an `agent.status` capacity report, or a
@@ -108,11 +108,6 @@ export interface AgentEntry {
108
108
  registeredAt: number;
109
109
  /** Self-reported agent version (e.g. "0.0.1"). Null if not reported. */
110
110
  version: string | null;
111
- /**
112
- * Optional behaviours the agent advertised on `agent.register`. Null for an
113
- * agent that advertised none, which is read as supporting none.
114
- */
115
- capabilities: AgentCapabilities | null;
116
111
  /**
117
112
  * The `agent_tokens.id` row used to authenticate this connection, or
118
113
  * `null` when auth mode is `none`. Indexed by `tokenIdIndex` so a
@@ -180,8 +175,6 @@ interface AgentMetadata {
180
175
  * any operator-declared properties). Undefined ⇒ the agent reported none.
181
176
  */
182
177
  properties?: Record<string, string | number | boolean>;
183
- /** Optional behaviours the agent advertised on `agent.register`. */
184
- capabilities?: AgentCapabilities;
185
178
  }
186
179
  /**
187
180
  * Subset of `HostRosterStore` the registry reconciles into. Optional — when no
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Without one, Hono answers an unhandled throw with a bare, unstructured 500:
5
5
  * no JSON body, no route context, and nothing written to our own logs. Every
6
- * admin router already catches inside its handlers (routes/admin-errors.ts),
6
+ * admin sub-app answers its own errors through its own onError (routes/admin-env.ts),
7
7
  * and the auth path catches inside its middleware (routes/admin-auth.ts) -- this
8
8
  * covers whatever neither does.
9
9
  *
@@ -1,8 +1,19 @@
1
- import { ApprovalDecision } from '@kici-dev/engine';
1
+ import { AccessLogAction, ApprovalDecision } from '@kici-dev/engine';
2
2
  import type { HeldRun } from '../db/types.js';
3
3
  import { HoldOutcome } from '../pipeline/security-hold-check.js';
4
4
  import type { HeldRunStore, ReleaseSignal } from '../contexts/held-runs.js';
5
5
  import { type TeamMembershipLookup } from './approval-resolver.js';
6
+ /**
7
+ * The access-log action a held-run decision is audited under.
8
+ *
9
+ * A `kici run --approve-all` breakglass approval audits as
10
+ * `held_run.auto_approve`, so the trail shows "auto-approved by the dispatcher"
11
+ * apart from an interactive approve. The marker only renames the record:
12
+ * eligibility is enforced the same way for both. It never applies to a reject.
13
+ * Every approving surface takes its action from here, so the Platform-relayed
14
+ * and the direct admin-route approvals cannot audit the same act two ways.
15
+ */
16
+ export declare function heldRunDecisionAction(decision: ApprovalDecision, autoApprove: boolean): AccessLogAction;
6
17
  /** Whether a decision's post-commit consequence ran to completion. */
7
18
  export interface DecisionConsequenceResult {
8
19
  /** True when the whole consequence chain ran; false when a step of it threw. */
@@ -207,8 +207,6 @@ export declare class ArtifactStore {
207
207
  runId: string;
208
208
  name: string;
209
209
  }): Promise<ArtifactDownloadResult>;
210
- /** ISO string for a row's created_at (Date or already-string). */
211
- private createdAtIso;
212
210
  /** Load a run's non-expired artifact rows, newest first, given the org TTL. */
213
211
  private loadRunRows;
214
212
  /**
@@ -105,7 +105,7 @@ export declare class AccessLogWriter {
105
105
  * synthetic `__orchestrator__` tenant is scanned (matches the
106
106
  * NULL-org_id rows the orchestrator itself emits via
107
107
  * `cold-store-archive` / `cold-store-purge`). The CLI exposes this as
108
- * `kici-admin access-log show <id> --org-id <orgId>`.
108
+ * `kici-admin access-log show <id> --org <orgId>`.
109
109
  *
110
110
  * Best-effort contract: a cold-store error logs a warn line and
111
111
  * returns null, matching `loadAccessLogRange` and
@@ -32,7 +32,7 @@
32
32
  * defect this layout closes — so serving it would serve the bug. For a v6 lock
33
33
  * the fallback is unreachable anyway, since the schema bump moves every hash.
34
34
  * Old objects are orphaned. The cache TTL is enforced lazily on access, so
35
- * nothing here removes them; `kici-admin cache purge-legacy` does.
35
+ * nothing here removes them.
36
36
  */
37
37
  import type { CacheStorage } from '../storage/types.js';
38
38
  /**
@@ -24,26 +24,6 @@ export interface UserCacheOrgLimits {
24
24
  }
25
25
  /** Resolves the per-org cache limits for an org id (e.g. an `org_settings` read). */
26
26
  export type UserCacheOrgLimitsReader = (orgId: string) => Promise<UserCacheOrgLimits>;
27
- /**
28
- * Stem prefix of an in-flight upload, `.tmp-<uuid>.tar.gz`: the presigned PUT
29
- * target a save lands on before commit copies it to its final key. Shared with
30
- * the retired-layout classifier so both agree on what an upload looks like.
31
- */
32
- export declare const TEMP_UPLOAD_STEM = ".tmp-";
33
- /**
34
- * Sanitize a path segment so a key can never escape its org/repo/scope
35
- * namespace. Beyond stripping disallowed characters, a segment consisting
36
- * only of dots (`.`, `..`, …) is replaced wholesale: such a segment is a
37
- * dot-segment that HTTP/S3 path canonicalization collapses (`a/./b` → `a/b`,
38
- * `a/../b` → `b`), which both corrupts the namespace and breaks the SigV4
39
- * signature on a pre-signed PUT/GET. Repo identifiers like `.` (the internal
40
- * provider's repo id) hit exactly this case, so the all-dots guard keeps the
41
- * object key canonical and the namespace boundary intact.
42
- *
43
- * Exported so an operator tool that addresses an org's prefix from a raw org id
44
- * (`kici-admin cache purge-legacy --org`) lands on the segment the writer used.
45
- */
46
- export declare function sanitizeSegment(s: string): string;
47
27
  /** Identifies the org + repo + write scope a cache operation targets. */
48
28
  export interface UserCacheRef {
49
29
  org: string;
@@ -65,14 +45,6 @@ export interface UserCacheBeginSaveResult {
65
45
  uploadUrl?: string;
66
46
  tempKey?: string;
67
47
  }
68
- /**
69
- * The object key a committed save under `key` lands on for this ref. This is
70
- * the writer's own path — `beginSave` and `commitSave` address the entry
71
- * through it — so anything that must recognise a current-layout key (the
72
- * legacy-layout classifier tests) takes it from here rather than restating
73
- * the format.
74
- */
75
- export declare function userCacheEntryKey(ref: UserCacheRef, key: string): string;
76
48
  export declare class UserCache {
77
49
  private readonly storage;
78
50
  /** Cluster-wide default quota (the `KICI_USER_CACHE_QUOTA_BYTES` value). */
@@ -5,7 +5,7 @@
5
5
  * All methods are thin wrappers around fetch() that handle JSON serialization,
6
6
  * error formatting, and URL construction.
7
7
  */
8
- import type { PeerForgetOutcome, ScalerLiveVm, ScalerVmStopResult } from '@kici-dev/engine';
8
+ import type { PeerForgetOutcome, ScalerLiveVm, ScalerReloadAnswer, ScalerReloadInstanceResult, ScalerVmStopResult } from '@kici-dev/engine';
9
9
  /** `POST /api/v1/admin/peers/forget`: one result per coordinator, this one first. */
10
10
  export interface PeerForgetResponseBody {
11
11
  instanceId: string;
@@ -18,6 +18,11 @@ export interface PeerForgetResponseBody {
18
18
  acknowledgementRequired?: boolean;
19
19
  error?: string;
20
20
  }
21
+ /** The answer of `POST /api/v1/admin/scaler/reload`: one result per orchestrator, this one first. */
22
+ export interface ScalerReloadResponseBody {
23
+ scope: 'cluster' | 'single';
24
+ results: ScalerReloadInstanceResult[];
25
+ }
21
26
  /** The node a scaler orphans request answered for. */
22
27
  export interface ScalerOrphansNode {
23
28
  instanceId: string;
@@ -138,7 +143,11 @@ export declare function firstCauseMessage(err: unknown): string;
138
143
  * opening a connection.
139
144
  */
140
145
  export declare function isTransportFailure(err: unknown): boolean;
146
+ /** The admin API address kici-admin dials when neither --url nor KICI_ADMIN_URL is set. */
147
+ export declare const DEFAULT_ADMIN_URL = "http://localhost:4000";
141
148
  export declare function fetchAdminApi(url: string, init: RequestInit, baseUrl: string): Promise<Response>;
149
+ /** Build a `?a=1&b=2` query string, skipping undefined, null and empty-string values. */
150
+ export declare function toQuery(params: Record<string, string | number | boolean | undefined | null>): string;
142
151
  export declare class AdminApiClient {
143
152
  private readonly baseUrl;
144
153
  private readonly token;
@@ -409,6 +418,7 @@ export declare class AdminApiClient {
409
418
  success: boolean;
410
419
  version?: number;
411
420
  errors?: string[];
421
+ scaler?: ScalerReloadAnswer;
412
422
  }>;
413
423
  /** Flip the coordinator drain flag on ('drain') or off ('resume'). */
414
424
  drain(action: 'drain' | 'resume'): Promise<{
@@ -432,6 +442,22 @@ export declare class AdminApiClient {
432
442
  timeoutMs?: number;
433
443
  acknowledgeBackstop?: boolean;
434
444
  }): Promise<PeerForgetResponseBody>;
445
+ /**
446
+ * POST `body` and parse the answer whatever its status, for a route that
447
+ * reports per-instance results on a non-2xx status too. An unparseable body
448
+ * reads as `{}`.
449
+ */
450
+ private postForBody;
451
+ /**
452
+ * Reload the scaler config on this orchestrator and, unless `single`, on every
453
+ * peer it is connected to. A response where an instance refused its file or
454
+ * was not reached (422) is returned like a success, so the caller can show
455
+ * every instance; a 404 means the orchestrator predates the route.
456
+ */
457
+ scalerReload(body: {
458
+ single?: boolean;
459
+ timeoutMs?: number;
460
+ }): Promise<ScalerReloadResponseBody>;
435
461
  /** List the live Firecracker VMs on this coordinator, or on the `target` peer. */
436
462
  listScalerOrphans(opts?: {
437
463
  target?: string;
@@ -443,6 +469,10 @@ export declare class AdminApiClient {
443
469
  vmIds: string[];
444
470
  timeoutMs?: number;
445
471
  }): Promise<ScalerOrphansStopResponse>;
472
+ /**
473
+ * @deprecated No KiCI server serves `/api/v1/api-keys`; use `createToken`
474
+ * (`kici-admin token create`). Removed in v1.0.0.
475
+ */
446
476
  createApiKey(opts: {
447
477
  label?: string;
448
478
  routingKeys?: string[];
@@ -451,6 +481,10 @@ export declare class AdminApiClient {
451
481
  key: string;
452
482
  routingKeys: string[];
453
483
  }>;
484
+ /**
485
+ * @deprecated No KiCI server serves `/api/v1/api-keys`; use `createToken`
486
+ * with `routingKey` (`kici-admin token create --routing-key`). Removed in v1.0.0.
487
+ */
454
488
  addRoutingKeyPermission(keyId: string, pattern: string): Promise<{
455
489
  id: string;
456
490
  pattern: string;
@@ -10,7 +10,7 @@
10
10
  * access-log show Show a single entry by id
11
11
  *
12
12
  * Filter flags for `list`:
13
- * --org-id -> ?orgId=
13
+ * --org -> ?orgId=
14
14
  * --actor-type -> ?actorType=
15
15
  * --actor-id -> ?actorId=
16
16
  * --action -> ?action=
@@ -1,12 +1,19 @@
1
1
  /**
2
- * Platform API key management commands for kici-admin.
2
+ * `kici-admin api-key` — deprecated.
3
3
  *
4
- * These commands target the Platform admin API for managing API keys
5
- * and routing key permissions. Uses the same --url flag (point to Platform URL).
4
+ * The group targeted `/api/v1/api-keys`, which no KiCI server serves, so it
5
+ * never worked. Both subcommands stay registered until v1.0.0 and exit with a
6
+ * message that points at `kici-admin token create`, the per-person
7
+ * orchestrator token a developer passes to `kici connect`.
6
8
  *
7
9
  * api-key create, add-routing-key
8
10
  */
9
11
  import type { Command } from 'commander';
10
12
  import type { AdminApiClient } from '../api-client.js';
11
- export declare function registerApiKeyCommands(program: Command, getClient: () => AdminApiClient): void;
13
+ export declare const API_KEY_DEPRECATED_MESSAGE: string;
14
+ /**
15
+ * Register the deprecated `api-key` group. `getClient` is accepted for the
16
+ * registration signature every command group shares and is never called.
17
+ */
18
+ export declare function registerApiKeyCommands(program: Command, _getClient: () => AdminApiClient): void;
12
19
  //# sourceMappingURL=api-key.d.ts.map
@@ -1,101 +1,24 @@
1
- export declare function archiveNow(opts: {
2
- databaseUrl: string;
1
+ export declare const archiveNow: (opts: import("@kici-dev/shared").ColdStoreAdminStoreOpts & {
3
2
  table: string;
4
- instanceId?: string;
5
- }): Promise<void>;
6
- export declare function dryRunArchive(opts: {
7
- databaseUrl: string;
3
+ }) => Promise<void>, dryRunArchive: (opts: import("@kici-dev/shared").ColdStoreAdminStoreOpts & {
8
4
  table: string;
9
5
  tenant?: string;
10
6
  from?: string;
11
7
  to?: string;
12
- instanceId?: string;
13
- }): Promise<void>;
14
- export interface ChunkListing {
15
- chunkId: string;
16
- tenantId: string;
17
- partitionDate: string;
18
- dataKey: string | null;
19
- manifestKey: string | null;
20
- }
21
- export declare function listChunks(opts: {
22
- databaseUrl: string;
8
+ }) => Promise<void>, listChunks: (opts: import("@kici-dev/shared").ColdStoreAdminStoreOpts & {
23
9
  table: string;
24
10
  tenant?: string;
25
11
  missingData?: boolean;
26
12
  missingManifest?: boolean;
27
13
  from?: string;
28
14
  to?: string;
29
- instanceId?: string;
30
- }): Promise<void>;
31
- export declare function verifyChunk(opts: {
32
- databaseUrl: string;
33
- chunkId: string;
34
- table: string;
35
- tenant: string;
36
- partitionDate: string;
37
- instanceId?: string;
38
- }): Promise<'match' | 'mismatch'>;
39
- export declare function replayChunk(opts: {
40
- databaseUrl: string;
41
- chunkId: string;
42
- table: string;
43
- tenant: string;
44
- partitionDate: string;
45
- instanceId?: string;
46
- }): Promise<void>;
47
- /**
48
- * Promote a chunk's rows back into the orchestrator PG.
49
- * Mirrors the Platform-side `replayIntoPg`. Adapter must implement
50
- * `replayInsert` — currently only `execution_runs`.
51
- */
52
- export declare function replayIntoPg(opts: {
53
- databaseUrl: string;
54
- chunkId: string;
55
- table: string;
56
- tenant: string;
57
- partitionDate: string;
58
- instanceId?: string;
59
- }): Promise<void>;
60
- export declare function reconcile(opts: {
61
- databaseUrl: string;
15
+ }) => Promise<void>, verifyChunk: (opts: import("@kici-dev/shared").ColdStoreAdminChunkOpts) => Promise<"match" | "mismatch">, replayChunk: (opts: import("@kici-dev/shared").ColdStoreAdminChunkOpts) => Promise<void>, replayIntoPg: (opts: import("@kici-dev/shared").ColdStoreAdminChunkOpts) => Promise<void>, reconcile: (opts: import("@kici-dev/shared").ColdStoreAdminStoreOpts & {
62
16
  table: string;
63
17
  tenant?: string;
64
18
  confirmCleanup?: boolean;
65
- instanceId?: string;
66
- }): Promise<void>;
67
- /**
68
- * List chunks past their cold-retention horizon. Read-only;
69
- * no S3 or PG mutation. Emits one JSON line per row so the output is
70
- * easy to pipe through `jq` / `column -t` / etc.
71
- */
72
- export declare function listPurgeable(opts: {
73
- databaseUrl: string;
74
- table?: string;
75
- bucket?: string;
76
- limit?: number;
77
- instanceId?: string;
78
- }): Promise<void>;
79
- /**
80
- * Delete S3 objects + clean up PG bookkeeping for chunks
81
- * past their cold-retention horizon. Defaults to dry-run; pass
82
- * `--apply` to actually delete.
83
- */
84
- export declare function purgeNow(opts: {
85
- databaseUrl: string;
86
- table?: string;
87
- bucket?: string;
88
- limit?: number;
19
+ }) => Promise<void>, listPurgeable: (opts: import("@kici-dev/shared").ColdStoreAdminPurgeOpts) => Promise<void>, purgeNow: (opts: import("@kici-dev/shared").ColdStoreAdminPurgeOpts & {
89
20
  apply?: boolean;
90
- instanceId?: string;
91
- }): Promise<void>;
92
- export declare function peekChunk(opts: {
93
- databaseUrl: string;
94
- chunkId: string;
95
- table: string;
96
- tenant: string;
97
- partitionDate: string;
21
+ }) => Promise<void>, peekChunk: (opts: import("@kici-dev/shared").ColdStoreAdminChunkOpts & {
98
22
  limit: number;
99
- instanceId?: string;
100
- }): Promise<void>;
23
+ }) => Promise<void>;
101
24
  //# sourceMappingURL=cold-store-impl.d.ts.map
@@ -7,6 +7,7 @@
7
7
  * db create-role CREATE ROLE LOGIN [CREATEDB] (direct DB)
8
8
  * db create-readonly-user Read-only role + GRANT SELECT (direct DB)
9
9
  * db check-schema Compare bundled migrations vs live schema (direct DB)
10
+ * db schema-diff Compare the live schema with the release snapshot (direct DB)
10
11
  * db collation-check Check pg_database.datcollversion vs running libc (direct DB)
11
12
  * db reindex REINDEX DATABASE CONCURRENTLY (direct DB)
12
13
  * db refresh-collation-version ALTER DATABASE REFRESH COLLATION VERSION (direct DB)
@@ -4,6 +4,8 @@
4
4
  * Shows OS-level service status (state, PID, uptime) and queries the
5
5
  * running orchestrator's `/health` and `/ready` endpoints for its version,
6
6
  * build fingerprint, uptime and readiness (database reachable, boot finished).
7
+ * With an admin token (`--token` / KICI_ADMIN_TOKEN) it also asks the
8
+ * instance's admin API which org the Platform attached it to.
7
9
  *
8
10
  * Target resolution goes through resolveInstanceTarget — the same priority chain
9
11
  * every lifecycle command uses (--instance-dir > --name > CWD manifest >
@@ -0,0 +1,12 @@
1
+ /**
2
+ * `kici-admin org list` — every org id this orchestrator holds data for.
3
+ *
4
+ * Reads `GET /api/v1/admin/org-ids` by default. With `--database-url` (or
5
+ * KICI_DATABASE_URL) it runs the same query against the orchestrator database
6
+ * directly; that mode cannot see the live Platform connection, so it lists no
7
+ * `platform` source and says so.
8
+ */
9
+ import type { Command } from 'commander';
10
+ import type { AdminApiClient } from '../api-client.js';
11
+ export declare function registerOrgCommands(program: Command, getClient: () => AdminApiClient): void;
12
+ //# sourceMappingURL=org.d.ts.map
@@ -5,6 +5,9 @@
5
5
  * orchestrator does not track and, with --stop, stop
6
6
  * them. Goes through the admin HTTP API; `--target`
7
7
  * reaches a worker through the coordinator.
8
+ * scaler reload Re-read the scaler config on this orchestrator and
9
+ * every peer it is connected to (admin HTTP API);
10
+ * each one applies its file completely or not at all.
8
11
  * scaler reap-orphans Free leaked Firecracker/container resources WITHOUT a
9
12
  * running orchestrator (recovery for a wedged node whose
10
13
  * data disk is full).
@@ -49,6 +52,17 @@ export declare function formatAge(seconds: number): string;
49
52
  * @returns the process exit code
50
53
  */
51
54
  export declare function runScalerOrphans(client: OrphansClient, opts: ScalerOrphansOptions, io: ScalerOrphansIo): Promise<number>;
55
+ export interface ScalerReloadOptions {
56
+ single: boolean;
57
+ timeout: string;
58
+ json: boolean;
59
+ }
60
+ /**
61
+ * `scaler reload`: reload the scaler config and print one block per instance.
62
+ * Resolves the exit code: 1 when any instance refused its file or was not
63
+ * reached, else 0. A bad `--timeout` throws before any request.
64
+ */
65
+ export declare function runScalerReload(client: Pick<AdminApiClient, 'scalerReload'>, opts: ScalerReloadOptions, out: (line: string) => void): Promise<number>;
52
66
  export declare function registerScalerCommands(program: Command, getClient: () => AdminApiClient): void;
53
67
  export {};
54
68
  //# sourceMappingURL=scaler.d.ts.map
@@ -2,56 +2,12 @@
2
2
  * Secret management commands for kici-admin.
3
3
  *
4
4
  * Provides scoped secret operations:
5
- * secret scopes, list, set, delete, fix-prefixed-scopes
5
+ * secret scopes, list, set, delete
6
6
  * secret scope create|rename|delete
7
7
  *
8
8
  * Secret values are write-only -- there is no "get value" command.
9
9
  */
10
10
  import type { Command } from 'commander';
11
11
  import type { AdminApiClient } from '../api-client.js';
12
- /** One planned rename from a stored qualified scope to its bare path. */
13
- export interface PrefixedScopeRename {
14
- from: string;
15
- to: string;
16
- backendName: string;
17
- }
18
- /** One stored scope that cannot be repaired automatically. */
19
- export interface PrefixedScopeSkip {
20
- scope: string;
21
- reason: string;
22
- }
23
- /** Outcome of planning the repair of legacy qualifier-bearing scopes. */
24
- export interface PrefixedScopeFixPlan {
25
- renames: PrefixedScopeRename[];
26
- skips: PrefixedScopeSkip[];
27
- }
28
- /**
29
- * Plan the repair of scopes stored with a `<backend>:` qualifier still attached.
30
- *
31
- * Before backend-qualified routing landed on the HTTP admin plane, a scope
32
- * written as `pg:production` was stored verbatim, so the stored name carries a
33
- * qualifier the resolver now strips before it reaches the store. Such a row is
34
- * unreachable: every read addresses the bare `production`.
35
- *
36
- * Only a `pg:` qualifier is repaired. The scopes handed in come out of the PG
37
- * store, so a row named `vault:foo` is a PG row wearing another backend's
38
- * name: renaming it to `foo` would turn it into a genuine PG secret, moving it
39
- * across a backend boundary and past a `pgCustomerSecrets: false` setting that
40
- * exists to keep customer secrets out of PG. That is the same cross-backend
41
- * move the rename route refuses, so it is reported as a skip instead.
42
- *
43
- * An unregistered head is left alone entirely -- it is an ordinary (if
44
- * unusual) scope path, not a stale qualifier.
45
- *
46
- * A repair whose bare target already exists is SKIPPED, never merged: merging
47
- * two scopes would silently overwrite whichever key the two share, and there
48
- * is no way to tell which value the operator meant to keep.
49
- *
50
- * Pure -- no I/O, so the decision table is unit-testable without a database.
51
- *
52
- * @param scopes - Scope names as currently stored in the PG backend.
53
- * @param backendNames - Names of the registered secret backends.
54
- */
55
- export declare function planPrefixedScopeFixes(scopes: string[], backendNames: string[]): PrefixedScopeFixPlan;
56
12
  export declare function registerSecretCommands(program: Command, getClient: () => AdminApiClient): void;
57
13
  //# sourceMappingURL=secret.d.ts.map
@@ -30,6 +30,26 @@ export interface LocalEndpoint {
30
30
  export declare function readLocalEndpoint(envContent: string, defaultPort: number): LocalEndpoint;
31
31
  /** The URL of `pathname` on `endpoint`, with an IPv6 host bracketed. */
32
32
  export declare function localUrl(endpoint: LocalEndpoint, pathname: string): string;
33
+ /** What a local JSON request got: a body, a refusing status, or no answer at all. */
34
+ export type LocalJsonResult<T> = {
35
+ kind: 'ok';
36
+ status: number;
37
+ body: T;
38
+ } | {
39
+ kind: 'http-error';
40
+ status: number;
41
+ } | {
42
+ kind: 'no-answer';
43
+ };
44
+ /**
45
+ * GET a JSON body from a service on this host. `acceptStatuses` names the
46
+ * non-2xx codes whose body is still an answer; `headers` carries credentials.
47
+ */
48
+ export declare function requestLocalJson<T>(endpoint: LocalEndpoint, pathname: string, opts?: {
49
+ acceptStatuses?: readonly number[];
50
+ timeoutMs?: number;
51
+ headers?: Record<string, string>;
52
+ }): Promise<LocalJsonResult<T>>;
33
53
  /**
34
54
  * GET a JSON body from a service on this host. `acceptStatuses` names the
35
55
  * non-2xx codes whose body is still an answer: `/ready` returns its checks
@@ -39,22 +59,10 @@ export declare function fetchLocalJson<T>(endpoint: LocalEndpoint, pathname: str
39
59
  acceptStatuses?: readonly number[];
40
60
  timeoutMs?: number;
41
61
  }): 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
62
  /**
54
63
  * Rows for the build fingerprint and process uptime of a `/health` body. A
55
64
  * 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}).
65
+ * the fields it does report.
58
66
  */
59
67
  export declare function buildInfoRows(health: Partial<LivenessBase & BuildFingerprint & {
60
68
  buildDate: string;
@@ -0,0 +1,17 @@
1
+ /** Commander option flag and help text shared by every command that can bypass HTTP. */
2
+ export declare const DIRECT_DB_URL_FLAG = "--database-url <url>";
3
+ export declare const DIRECT_DB_URL_HELP = "Use direct DB access instead of HTTP (offline mode)";
4
+ /** `--database-url`, else `KICI_DATABASE_URL`, else null (null = use the HTTP admin API). */
5
+ export declare function resolveDirectDbUrl(explicit?: string): string | null;
6
+ /** Like {@link resolveDirectDbUrl} but required: throws when neither source is set. */
7
+ export declare function resolveDatabaseUrl(explicit?: string): string;
8
+ /** Parse an optional integer flag; throws naming the flag on a non-integer. */
9
+ export declare function parseIntOption(raw: string | undefined, label: string): number | undefined;
10
+ /**
11
+ * Wrap a Commander action so any thrown error prints `Error: <message>` to
12
+ * stderr and exits 1.
13
+ */
14
+ export declare function cliAction<A extends unknown[]>(fn: (...args: A) => Promise<void> | void): (...args: A) => Promise<void>;
15
+ /** Print `value` as one JSON line when `json` is set, otherwise hand it to `render`. */
16
+ export declare function printJsonOr<T>(json: boolean | undefined, value: T, render: (v: T) => void): void;
17
+ //# sourceMappingURL=cli-action.d.ts.map
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Shared database helper for CLI commands that need direct DB access.
3
3
  *
4
- * Provides a withDb() wrapper that creates a database connection from
5
- * KICI_DATABASE_URL, runs a callback, and ensures cleanup.
4
+ * Provides a withDb() wrapper that creates a database connection from the
5
+ * URL it is given (or KICI_DATABASE_URL when none is passed), runs a callback,
6
+ * and ensures cleanup.
6
7
  */
7
8
  import pg from 'pg';
8
9
  import { Kysely } from 'kysely';
9
10
  /**
10
11
  * Execute a callback with a database connection, then clean up.
11
12
  *
12
- * Reads the database URL from KICI_DATABASE_URL.
13
- * Creates a connection pool, runs the callback, and destroys the pool.
13
+ * Connects to `databaseUrl`, or to KICI_DATABASE_URL when none is passed.
14
14
  */
15
- export declare function withDb<T>(fn: (db: Kysely<any>, pool: pg.Pool) => Promise<T>): Promise<T>;
15
+ export declare function withDb<T>(fn: (db: Kysely<any>, pool: pg.Pool) => Promise<T>, databaseUrl?: string | undefined): Promise<T>;
16
16
  //# sourceMappingURL=db.d.ts.map
@@ -0,0 +1,5 @@
1
+ /** Where an operator finds an org id: appended to every org-id input's help. */
2
+ export declare const ORG_LIST_HINT = "kici-admin org list prints the org ids";
3
+ /** Help text of an org-id argument or `--org` option. */
4
+ export declare const ORG_ID_HELP = "Org id (kici-admin org list prints the org ids)";
5
+ //# sourceMappingURL=org-id.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The service lifecycle verbs shared by `kici-admin agent` and `kici-admin orchestrator`:
3
+ * `uninstall`, `start`, `stop`, `restart` and `logs`.
4
+ *
5
+ * Target resolution goes through resolveInstanceTarget — the priority chain every
6
+ * lifecycle command uses (--instance-dir > --name > CWD manifest > refusal with
7
+ * candidate list). `--name` has no default.
8
+ */
9
+ import type { Command } from 'commander';
10
+ export type ServiceComponent = 'agent' | 'orchestrator';
11
+ /**
12
+ * Register `uninstall`, `start`, `stop` and `restart` on a component's command group.
13
+ * Commander lists subcommands in registration order, so the caller places this
14
+ * between `install` and `status`.
15
+ */
16
+ export declare function registerServiceLifecycleVerbs(parent: Command, component: ServiceComponent): void;
17
+ /** Register `logs` on a component's command group (listed after `status`). */
18
+ export declare function registerServiceLogsVerb(parent: Command, component: ServiceComponent): void;
19
+ //# sourceMappingURL=service-verbs.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** Render a left-aligned, two-space-gapped text table with a dashed separator row. */
2
+ export declare function renderTable(headers: string[], rows: string[][]): string;
3
+ //# sourceMappingURL=table.d.ts.map