@consiliency/agent-board-cli 1.27.1 → 1.29.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.
package/dist/setup.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import type { Command } from "commander";
2
- import { type DeviceAuthorizationPrompt, type EnrollmentIntent, type EnrollmentOutcome } from "@consiliency/agent-board-client";
2
+ import { type DeviceAuthorizationPrompt, type EnrollmentIntent, type EnrollmentOutcome, type IdentityHarness, type ListHarnessProcessesOptions, type ParsedInviteInput } from "@consiliency/agent-board-client";
3
+ import type { SetupAllOptions } from "./setup_all.js";
3
4
  import { type BakedAssets } from "./assets.js";
4
5
  import { type DoctorOptions, type DoctorReport } from "./doctor.js";
5
- import { type DepsOutcome, type KeyStorageContext, type KeyStorageSelection } from "./setup_storage.js";
6
- import { type ChildRunner, type WriterContext } from "./setup_writers.js";
6
+ import { type IdentityDeployment } from "./identity_writer.js";
7
+ import { type DepsOutcome, type KeyStorageContext, type KeyStorageSelection, type PreparedKeyStorage } from "./setup_storage.js";
8
+ import { type ChildRunner, type SetupScope, type WriterContext } from "./setup_writers.js";
7
9
  export declare const SETUP_STEPS: readonly ["preflight", "deps", "key", "enroll", "identity", "board", "harness", "doctor"];
8
10
  export type SetupStepName = (typeof SETUP_STEPS)[number];
9
11
  export type SetupStatus = "done" | "already" | "skipped" | "failed" | "undetermined";
@@ -17,11 +19,24 @@ export interface SetupReport {
17
19
  exit: 0 | 1 | 2;
18
20
  /** Human text: per-step fixes and the next steps. Never part of `--json`'s stdout. */
19
21
  notes: string[];
22
+ /**
23
+ * IF-0-ONBOARD-3: this harness's processes that started before setup installed or upgraded its
24
+ * registration, found by executable. Empty when the harness step installed nothing.
25
+ */
26
+ staleSessions: StaleSession[];
27
+ }
28
+ export interface StaleSession {
29
+ pid: number;
30
+ /** ISO time the process started. */
31
+ startedAt: string;
32
+ cwd: string | null;
20
33
  }
21
34
  export interface SetupOptions {
22
35
  harness: string;
23
36
  slug?: string;
24
37
  invite?: boolean;
38
+ /** IF-0-ONBOARD-2: a file holding the invite (a bare code, or the whole invite message). */
39
+ inviteFile?: string;
25
40
  allowUnsealedKey?: boolean;
26
41
  agentSocket?: string;
27
42
  scope?: string;
@@ -61,7 +76,10 @@ export interface SetupDeps {
61
76
  sudoPath?: string;
62
77
  hostname?: () => string;
63
78
  bakedAssets?: () => BakedAssets;
79
+ /** A whole selector, scan included; its answer is final (the pre-ONBOARD seam). */
64
80
  selectKeyStorage?: (ctx: KeyStorageContext) => Promise<KeyStorageSelection>;
81
+ /** The key step's preparation (no scan); default `prepareKeyStorage`. */
82
+ prepareKeyStorage?: (ctx: KeyStorageContext) => Promise<PreparedKeyStorage>;
65
83
  /** Seams passed through to the storage selector (probeKeychain, run, keyslotDir, …). */
66
84
  storage?: Partial<KeyStorageContext>;
67
85
  enroll?: SetupEnroller;
@@ -71,6 +89,8 @@ export interface SetupDeps {
71
89
  doctorOptions?: Partial<DoctorOptions>;
72
90
  /** Seams passed through to the harness writer (fs, claudeManagedDir). */
73
91
  writer?: Partial<Pick<WriterContext, "fs" | "claudeManagedDir">>;
92
+ /** Seams passed through to the stale-session listing (`/proc` or `ps` readers, uid, platform). */
93
+ processes?: Omit<ListHarnessProcessesOptions, "startedBefore">;
74
94
  }
75
95
  export declare const DEFAULT_SUDO = "/usr/bin/sudo";
76
96
  export declare const SECRET_SERVICE_NAME = "org.freedesktop.secrets";
@@ -90,7 +110,22 @@ export declare const KEYCHAIN_INSTALL_ARGV: ReadonlyArray<{
90
110
  }>;
91
111
  /** `<short hostname>-<harness>`, lowercased to `[a-z0-9-]`. */
92
112
  export declare function defaultSlug(host: string, harness: string): string;
93
- export declare function pendingMarkerPath(harness: string, env: NodeJS.ProcessEnv): string;
113
+ type IdentityState = {
114
+ kind: "present";
115
+ values: Record<string, string>;
116
+ } | {
117
+ kind: "absent";
118
+ } | {
119
+ kind: "unreadable";
120
+ reason: string;
121
+ };
122
+ declare class Run {
123
+ readonly steps: SetupStep[];
124
+ readonly notes: string[];
125
+ readonly staleSessions: StaleSession[];
126
+ record(step: SetupStep["step"], status: SetupStatus, reason: string, fix?: string): SetupStep;
127
+ report(): SetupReport;
128
+ }
94
129
  interface DepsContext {
95
130
  env: NodeJS.ProcessEnv;
96
131
  platform: NodeJS.Platform;
@@ -105,6 +140,74 @@ interface DepsContext {
105
140
  export declare function depsStep(ctx: DepsContext): Promise<DepsOutcome & {
106
141
  fix?: string;
107
142
  }>;
143
+ /**
144
+ * IF-0-ONBOARD-2: the invite, read ONCE and parsed by the shared parser. `--invite-file` and a
145
+ * piped stdin may hold the whole invite message; a terminal takes one hidden line that must be a
146
+ * bare code. The code never reaches argv, a log or any message: a refusal names only its reason.
147
+ */
148
+ export declare function readSetupInvite(input: {
149
+ invite?: boolean;
150
+ inviteFile?: string;
151
+ }, deps: Pick<SetupDeps, "interactive" | "prompt" | "readStdin">): Promise<{
152
+ invite: ParsedInviteInput | null;
153
+ } | {
154
+ reason: string;
155
+ fix: string;
156
+ }>;
157
+ /** IF-0-ONBOARD-2 "Board": reported, never checked (setup has no target board). Never the code. */
158
+ export declare function inviteBoardNote(invite: ParsedInviteInput): string;
159
+ /**
160
+ * A pair past preflight, deps and its key PREPARATION (ONBOARD SL-4): what the rest of setup
161
+ * needs, plus the prepared storage, which is scanned before `finishSetupPair` may use it.
162
+ * `prepared` is null when the identity already exists (no key is chosen).
163
+ */
164
+ export interface SetupPair {
165
+ readonly harness: IdentityHarness;
166
+ readonly slug: string;
167
+ readonly prepared: PreparedKeyStorage | null;
168
+ /** @internal */
169
+ readonly state: PairState;
170
+ }
171
+ interface PairState {
172
+ out: Run;
173
+ options: SetupOptions;
174
+ deps: SetupDeps;
175
+ env: NodeJS.ProcessEnv;
176
+ cwd: string;
177
+ scope: SetupScope;
178
+ assets: BakedAssets;
179
+ identity: IdentityState;
180
+ deployment: IdentityDeployment | null;
181
+ invite: ParsedInviteInput | null;
182
+ identityPath: string;
183
+ markerPath: string;
184
+ }
185
+ export type SetupPairStart = {
186
+ kind: "stopped";
187
+ report: SetupReport;
188
+ } | {
189
+ kind: "started";
190
+ pair: SetupPair;
191
+ };
192
+ /** The storage context the key step's scan reads (env, runner, budgets, notices). */
193
+ export declare function setupStorageContext(deps: SetupDeps): Pick<KeyStorageContext, "env" | "run" | "statusBudgets" | "notify">;
194
+ /**
195
+ * Preflight, deps and the key PREPARATION for one harness. `preset.invite` is an invite the caller
196
+ * already read and parsed (`setup --all` reads it once for every pair); without it, the invite is
197
+ * read here.
198
+ */
199
+ export declare function startSetupPair(options: SetupOptions, deps?: SetupDeps, preset?: {
200
+ invite: ParsedInviteInput | null;
201
+ }): Promise<SetupPairStart>;
202
+ /**
203
+ * The rest of one pair, from its FINAL key storage (`finalizeKeyStorage`'s answer for this pair;
204
+ * null for a pair whose identity exists): enroll, identity, board, harness, doctor.
205
+ */
206
+ export declare function finishSetupPair(pair: SetupPair, selection: KeyStorageSelection | null): Promise<SetupReport>;
207
+ /**
208
+ * One harness: start, the key step's one scan (prepare → measure → finalize, as `setup --all` does
209
+ * over every pair), then the rest.
210
+ */
108
211
  export declare function runSetup(options: SetupOptions, deps?: SetupDeps): Promise<SetupReport>;
109
212
  export type SetupRunner = (options: SetupOptions) => Promise<SetupReport>;
110
213
  interface SetupIo {
@@ -112,5 +215,9 @@ interface SetupIo {
112
215
  writeStderr(message: string): void;
113
216
  }
114
217
  export declare function formatSetupReport(report: SetupReport): string;
115
- export declare function addSetupCommand(program: Command, io: SetupIo, setup: SetupRunner): void;
218
+ /** `setup --all`: runs, prints (the table, or `--json` on stdout with notes on stderr), returns the exit. */
219
+ export type SetupAllCommand = (options: SetupAllOptions, output: {
220
+ json: boolean;
221
+ }) => Promise<0 | 1 | 2>;
222
+ export declare function addSetupCommand(program: Command, io: SetupIo, setup: SetupRunner, setupAll?: SetupAllCommand): void;
116
223
  export {};