@kici-dev/orchestrator 0.1.22 → 0.1.23

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.
@@ -3,6 +3,19 @@ import { type HostInventoryEntry, type InventorySelector, type LabelMatcher } fr
3
3
  import type { Database, HostRosterRow } from '../db/types.js';
4
4
  /** Typed host-vars bag carried by roster rows (`string | number | boolean`). */
5
5
  export type HostProperties = Record<string, string | number | boolean>;
6
+ /**
7
+ * Pre-agent reach metadata for a declared host — how to SSH to it for bootstrap
8
+ * bring-up before it has a KiCI agent. All fields nullable: a host with no reach
9
+ * metadata cannot be bootstrapped. `sshKeySecret` is a scoped-secret ref
10
+ * (`scope/key`) the orchestrator resolves server-side; the key never lives here.
11
+ */
12
+ export interface HostReach {
13
+ agentId: string;
14
+ address: string | null;
15
+ sshUser: string | null;
16
+ sshPort: number | null;
17
+ sshKeySecret: string | null;
18
+ }
6
19
  /**
7
20
  * Derived (read-time) status of a roster host. Never a stored mutable column:
8
21
  * status is computed from the shared `last_seen` + `connected_instance_id` so
@@ -96,13 +109,36 @@ export declare class HostRosterStore {
96
109
  markDisconnected(agentId: string, instanceId: string): Promise<void>;
97
110
  /** Coarse heartbeat stamp — same owner-guard as markDisconnected. */
98
111
  stampLastSeen(agentId: string, instanceId: string): Promise<void>;
99
- /** Operator pre-declare of a static host before its agent dials in. */
112
+ /**
113
+ * Operator pre-declare of a static host. A re-declare of an existing agent_id
114
+ * converges the operator-owned columns (labels, hostname, reach,
115
+ * host_properties) to the newly-declared values while preserving the
116
+ * agent-reported liveness/identity columns (connected_instance_id, last_seen,
117
+ * platform, arch, lifecycle_class, token_id, reboot_pending_until). The
118
+ * optional reach fields (`address`/`sshUser`/`sshPort`/`sshKeySecret`) carry
119
+ * how to SSH to the host for bootstrap bring-up. Each operator field is
120
+ * preserve-on-omit: an omitted field keeps the existing column value.
121
+ *
122
+ * Returns `{ created: true }` when the declare inserted a new row,
123
+ * `{ created: false }` when it converged an existing one.
124
+ */
100
125
  declareStatic(input: {
101
126
  agentId: string;
102
- labels: string[];
127
+ labels?: string[];
103
128
  hostname?: string;
104
129
  properties?: HostProperties;
105
- }): Promise<void>;
130
+ address?: string;
131
+ sshUser?: string;
132
+ sshPort?: number;
133
+ sshKeySecret?: string;
134
+ }): Promise<{
135
+ created: boolean;
136
+ }>;
137
+ /**
138
+ * Read a host's pre-agent reach metadata. Returns null when the host is not
139
+ * in the roster; a host declared without reach fields reads back with nulls.
140
+ */
141
+ getReach(agentId: string): Promise<HostReach | null>;
106
142
  get(agentId: string): Promise<HostRosterRow | null>;
107
143
  listAll(): Promise<HostRosterRow[]>;
108
144
  /**
@@ -41,6 +41,35 @@ export declare class AgentTokenStore {
41
41
  * @returns The plaintext token (shown once).
42
42
  */
43
43
  createEphemeral(agentId: string, labels: string[], ttlMs: number): Promise<string>;
44
+ /**
45
+ * Mint a single-use, short-TTL bootstrap token for an init-runner bring-up.
46
+ *
47
+ * The token is stored as `agent_type: 'ephemeral'` (so the existing expiry
48
+ * cleanup reaps it) and is bound to exactly the init-runner label set. It is
49
+ * single-use: `consumeBootstrapToken` sets `consumed_at` on first
50
+ * `agent.register`, and a second register is rejected. A leaked token is
51
+ * therefore inert after enrollment AND after its short TTL elapses.
52
+ *
53
+ * @param targetAgentId - The agent id the init-runner will register as.
54
+ * @param ttlMs - Time-to-live in milliseconds (short, ~10 min).
55
+ * @param labels - The init-runner labels the token authorizes.
56
+ * @returns The plaintext token (shown once) and the DB row ID.
57
+ */
58
+ mintBootstrapToken(opts: {
59
+ targetAgentId: string;
60
+ ttlMs: number;
61
+ labels: string[];
62
+ }): Promise<{
63
+ token: string;
64
+ id: string;
65
+ }>;
66
+ /**
67
+ * Consume a single-use bootstrap token by id. Sets `consumed_at` only when it
68
+ * is currently null, so the first register wins and any subsequent attempt
69
+ * with the same token returns false (already consumed). Returns true when
70
+ * this call performed the consumption.
71
+ */
72
+ consumeBootstrapToken(id: string): Promise<boolean>;
44
73
  /**
45
74
  * Validate a plaintext token against stored hashes.
46
75
  *