@crvouga/homelab 0.23.13 → 0.24.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 (177) hide show
  1. package/.mise/locks/npm-vercel/{68.0.0 → 68.2.0}/aube-lock.yaml +73 -297
  2. package/.mise/locks/npm-vercel/{68.0.0 → 68.2.0}/package.json +1 -1
  3. package/.mise/locks/npm-wrangler/{4.169.0 → 4.170.0}/aube-lock.yaml +42 -42
  4. package/.mise/locks/npm-wrangler/{4.169.0 → 4.170.0}/package.json +1 -1
  5. package/README.md +54 -76
  6. package/ansible/ubuntu/agent-tool.py +106 -1
  7. package/ansible/ubuntu/heavy.py +142 -0
  8. package/ansible/ubuntu/idle-reboot.py +125 -0
  9. package/ansible/ubuntu/policy.json +58 -3
  10. package/ansible/ubuntu/t3-desktop.yml +7 -0
  11. package/ansible/ubuntu/t3-hang-snapshot.sh +75 -0
  12. package/ansible/ubuntu/t3-headless.yml +7 -0
  13. package/ansible/ubuntu/t3-health.sh +71 -3
  14. package/ansible/ubuntu/t3-policy.yml +14 -5
  15. package/ansible/ubuntu/tasks/packages.yml +2 -0
  16. package/ansible/ubuntu/tasks/recovery.yml +16 -2
  17. package/ansible/ubuntu/tasks/resources.yml +25 -2
  18. package/ansible/ubuntu/tasks/unattended-upgrades.yml +24 -6
  19. package/ansible/ubuntu/tasks/updates.yml +59 -0
  20. package/ansible/ubuntu/wip-guard.py +141 -14
  21. package/bootstrap/doctor.ts +0 -4
  22. package/bootstrap/project-action.sh +4 -5
  23. package/bootstrap/shell-path.ts +17 -19
  24. package/cliproxy/README.md +5 -6
  25. package/cliproxy/config.template.yaml +1 -15
  26. package/cliproxy/docs/health-workflow.example.yml +6 -6
  27. package/cliproxy/docs/model-health.md +8 -8
  28. package/cliproxy/scripts/accounts.py +3 -4
  29. package/cliproxy/scripts/fleet_sync.py +2 -13
  30. package/cliproxy/scripts/ops +3 -21
  31. package/docs/authentication.md +21 -26
  32. package/docs/convergence.md +28 -32
  33. package/docs/declared.md +30 -31
  34. package/docs/durability.md +9 -0
  35. package/docs/github.md +0 -9
  36. package/docs/machine-setup.md +16 -17
  37. package/docs/manager-recovery.md +0 -2
  38. package/docs/operations.md +12 -11
  39. package/docs/releasing.md +18 -21
  40. package/docs/runbooks.md +22 -78
  41. package/docs/support-matrix.md +1 -1
  42. package/docs/ubuntu-sync.md +71 -65
  43. package/docs/worker-contract.md +112 -15
  44. package/examples/fleet.json +0 -1
  45. package/llms.txt +0 -2
  46. package/mise.lock +206 -780
  47. package/mise.toml +12 -27
  48. package/package.json +5 -6
  49. package/schema/check-ids.json +41 -482
  50. package/schema/fleet.schema.json +6 -57
  51. package/schema/roster.schema.json +0 -2
  52. package/src/agent-session-limit.ts +2 -7
  53. package/src/auth-checks.ts +1 -3
  54. package/src/check-owners.ts +0 -13
  55. package/src/check-registry.ts +13 -72
  56. package/src/cli/agent-guide.ts +3 -16
  57. package/src/cli/command-index.ts +0 -12
  58. package/src/cli/fleet-sync-manager.ts +4 -146
  59. package/src/cli/fleet-sync-output.ts +1 -4
  60. package/src/cli/fleet-sync-plan.ts +1 -24
  61. package/src/cli/fleet-sync-remote.ts +2 -1
  62. package/src/cli/fleet-sync-vault.ts +1 -2
  63. package/src/cli/fleet-sync.ts +8 -44
  64. package/src/cli/fleet.ts +1 -2
  65. package/src/cli/program.ts +3 -14
  66. package/src/cli/register-fleet.ts +1 -55
  67. package/src/cli/registry.ts +1 -43
  68. package/src/config.ts +0 -2
  69. package/src/definition.ts +8 -83
  70. package/src/fleet-config.ts +1 -1
  71. package/src/ide/definition.ts +2 -29
  72. package/src/ide/super.ts +4 -35
  73. package/src/ide/t3.ts +9 -38
  74. package/src/manager-sync.ts +1 -1
  75. package/src/node-converge-linux.ts +4 -47
  76. package/src/node-converge-shared.ts +1 -22
  77. package/src/{agents/toolchain.ts → pinned-path.ts} +0 -17
  78. package/src/platform/agent-oom-check.ts +104 -0
  79. package/src/platform/t3-policy.ts +23 -36
  80. package/src/platform/t3-service.ts +117 -0
  81. package/src/platform/wip-guard-check.ts +65 -0
  82. package/src/remote-entry.ts +2 -41
  83. package/src/repair-catalog.ts +0 -30
  84. package/src/schedule-check.ts +17 -4
  85. package/src/service-auth.ts +0 -50
  86. package/src/state/litestream.ts +1 -1
  87. package/src/t3/retire-providers.ts +79 -0
  88. package/src/t3/version.ts +1 -1
  89. package/src/transport.ts +2 -6
  90. package/src/types.ts +0 -2
  91. package/src/version-parity.ts +0 -8
  92. package/src/worker-access-checks.ts +0 -75
  93. package/src/worker-host-checks.ts +78 -1
  94. package/src/worker-policy.ts +0 -2
  95. package/src/worker-readiness.ts +2 -0
  96. package/src/worker-sizing.ts +25 -0
  97. package/.mise/locks/azure-cli/2.93.0~a837e014/pyproject.toml +0 -5
  98. package/.mise/locks/azure-cli/2.93.0~a837e014/uv.lock +0 -2841
  99. package/.mise/locks/gemini/0.71.1~84aac8e6/aube-lock.yaml +0 -124
  100. package/.mise/locks/gemini/0.71.1~84aac8e6/package.json +0 -12
  101. package/agents/antigravity-proxy.ts +0 -3
  102. package/agents/audit.md +0 -88
  103. package/agents/bin/agy +0 -10
  104. package/agents/bin/antigravity +0 -10
  105. package/agents/bin/claude +0 -10
  106. package/agents/bin/codex +0 -10
  107. package/agents/bin/grok +0 -10
  108. package/agents/bin/opencode +0 -10
  109. package/agents/claude-proxy +0 -5
  110. package/agents/claude-proxy.ts +0 -3
  111. package/agents/codex-proxy.ts +0 -3
  112. package/agents/grok-proxy.ts +0 -3
  113. package/agents/managed-proxy.ts +0 -109
  114. package/agents/opencode-proxy.ts +0 -3
  115. package/agents/registry.json +0 -209
  116. package/agents/registry.schema.json +0 -149
  117. package/agents/setup.md +0 -158
  118. package/agents/t3.json +0 -40
  119. package/ansible/agents/agents.yml +0 -135
  120. package/ansible/agents/commands.yml +0 -32
  121. package/ansible/agents/receipts.yml +0 -19
  122. package/ansible/agents/templates/antigravity.settings.json.j2 +0 -3
  123. package/ansible/agents/templates/claude.settings.json.j2 +0 -3
  124. package/ansible/agents/templates/codex.config.toml.j2 +0 -11
  125. package/ansible/agents/templates/gemini.settings.json.j2 +0 -14
  126. package/ansible/agents/templates/grok.config.toml.j2 +0 -25
  127. package/ansible/agents/templates/opencode.json.j2 +0 -24
  128. package/ansible/agents/templates/receipt.json.j2 +0 -10
  129. package/ansible/t3/provider-keys.yml +0 -24
  130. package/docs/accounts.md +0 -256
  131. package/src/accounts/checks.ts +0 -226
  132. package/src/accounts/context.ts +0 -77
  133. package/src/accounts/propagate.ts +0 -62
  134. package/src/accounts/roster.ts +0 -112
  135. package/src/accounts/selection.ts +0 -67
  136. package/src/accounts/sessions.ts +0 -354
  137. package/src/agents/account-relay.ts +0 -279
  138. package/src/agents/accounts.ts +0 -94
  139. package/src/agents/admission.ts +0 -65
  140. package/src/agents/audit.ts +0 -77
  141. package/src/agents/cli.ts +0 -13
  142. package/src/agents/command.ts +0 -257
  143. package/src/agents/commands.ts +0 -127
  144. package/src/agents/converge.ts +0 -339
  145. package/src/agents/doctor.ts +0 -107
  146. package/src/agents/errors.ts +0 -2
  147. package/src/agents/files.ts +0 -43
  148. package/src/agents/fleet-verify.ts +0 -195
  149. package/src/agents/launch.ts +0 -361
  150. package/src/agents/native-verify.ts +0 -738
  151. package/src/agents/provider-errors.ts +0 -57
  152. package/src/agents/registry.ts +0 -61
  153. package/src/agents/render.ts +0 -121
  154. package/src/agents/round-trip.ts +0 -192
  155. package/src/agents/secrets.ts +0 -48
  156. package/src/agents/verify-cache.ts +0 -164
  157. package/src/agents/verify.ts +0 -129
  158. package/src/cli/fleet-accounts.ts +0 -294
  159. package/src/cli/fleet-sync-accounts.ts +0 -62
  160. package/src/cli/node-deployment.ts +0 -34
  161. package/src/cli/node-sync.ts +0 -121
  162. package/src/cli/node-t3.ts +0 -35
  163. package/src/cli/t3/command.ts +0 -91
  164. package/src/cli/t3/register.ts +0 -56
  165. package/src/configure.ts +0 -271
  166. package/src/github/copilot.ts +0 -54
  167. package/src/t3/accounts.ts +0 -90
  168. package/src/t3/antigravity.ts +0 -93
  169. package/src/t3/desired.ts +0 -174
  170. package/src/t3/diagnostics.ts +0 -42
  171. package/src/t3/models.ts +0 -354
  172. package/src/t3/names-check.ts +0 -53
  173. package/src/t3/names.ts +0 -155
  174. package/src/t3/plan.ts +0 -106
  175. package/src/t3/provider-keys.ts +0 -49
  176. package/src/t3/providers.ts +0 -102
  177. package/src/t3/reconcile.ts +0 -133
@@ -1,129 +0,0 @@
1
- import {
2
- ProviderVerificationError,
3
- providerHttpFailure,
4
- } from './provider-errors';
5
- import { registry, type Selection } from './registry';
6
- import { proxyKey } from './secrets';
7
- import { VERIFY_OUTPUT_TOKENS } from './round-trip';
8
-
9
- export async function verifyProvider(
10
- selection: Selection,
11
- smoke: boolean,
12
- credential?: string
13
- ) {
14
- if (selection.profile !== 'proxy')
15
- return {
16
- static: 'pass',
17
- reachability: 'unverified',
18
- authenticatedModels: 'unverified',
19
- inference: 'unverified',
20
- streaming: 'unverified',
21
- toolCalls: 'unverified',
22
- t3EndToEnd: 'unverified',
23
- };
24
- const key = credential ?? (await proxyKey());
25
- const headers = {
26
- Authorization: `Bearer ${key}`,
27
- 'Content-Type': 'application/json',
28
- };
29
- const response = await fetch(registry.proxy.endpoint + '/v1/models', {
30
- headers,
31
- redirect: 'error',
32
- signal: AbortSignal.timeout(15_000),
33
- });
34
- if (!response.ok) throw providerHttpFailure(response.status);
35
- const data = (await response.json()) as { data?: Array<{ id: string }> };
36
- if (!data.data?.some((model) => model.id === selection.model))
37
- throw new ProviderVerificationError(
38
- 'PROVIDER_MODEL_UNAVAILABLE',
39
- 'Approved model is unavailable; review registry model selection.'
40
- );
41
- let inference = 'unverified';
42
- if (smoke) {
43
- const { path, body } = inferenceRequest(selection);
44
- const result = await fetch(registry.proxy.endpoint + path, {
45
- method: 'POST',
46
- headers: {
47
- ...headers,
48
- 'anthropic-version': '2023-06-01',
49
- 'x-goog-api-key': key,
50
- },
51
- body: JSON.stringify(body),
52
- redirect: 'error',
53
- signal: AbortSignal.timeout(30_000),
54
- });
55
- if (!result.ok) throw providerHttpFailure(result.status);
56
- await validateOutput(result, selection.tool);
57
- inference = 'pass';
58
- }
59
- return {
60
- static: 'pass',
61
- reachability: 'pass',
62
- authenticatedModels: 'pass',
63
- inference,
64
- streaming: 'unverified',
65
- toolCalls: 'unverified',
66
- t3EndToEnd: 'unverified',
67
- };
68
- }
69
-
70
- async function validateOutput(
71
- result: Response,
72
- tool: Selection['tool']
73
- ): Promise<void> {
74
- const payload = (await result.json()) as {
75
- content?: unknown[];
76
- output?: unknown[];
77
- error?: unknown;
78
- candidates?: unknown[];
79
- };
80
- const output =
81
- tool === 'gemini' || tool === 'antigravity'
82
- ? payload.candidates
83
- : tool === 'claude'
84
- ? payload.content
85
- : payload.output;
86
- if (payload.error || !Array.isArray(output) || output.length === 0)
87
- throw new ProviderVerificationError(
88
- 'PROVIDER_OUTPUT_UNVERIFIED',
89
- 'Inference returned no output; inspect the provider locally.'
90
- );
91
- }
92
-
93
- /** Exact pinned clients use different wire protocols; model discovery is not inference.
94
- * Output uses the same ceiling as the round trip: reasoning models (Muse) spend
95
- * dozens of tokens before any text, so a tiny cap returns an empty output.
96
- */
97
- export function inferenceRequest(
98
- selection: Pick<Selection, 'tool' | 'model'>
99
- ): {
100
- path: string;
101
- body: object;
102
- } {
103
- // Antigravity's CLI speaks the same Gemini generateContent protocol.
104
- if (selection.tool === 'gemini' || selection.tool === 'antigravity')
105
- return {
106
- path: `/v1beta/models/${encodeURIComponent(selection.model)}:generateContent`,
107
- body: {
108
- contents: [{ role: 'user', parts: [{ text: 'Reply OK.' }] }],
109
- generationConfig: { maxOutputTokens: VERIFY_OUTPUT_TOKENS },
110
- },
111
- };
112
- if (selection.tool === 'claude')
113
- return {
114
- path: '/v1/messages',
115
- body: {
116
- model: selection.model,
117
- max_tokens: VERIFY_OUTPUT_TOKENS,
118
- messages: [{ role: 'user', content: 'Reply OK.' }],
119
- },
120
- };
121
- return {
122
- path: '/v1/responses',
123
- body: {
124
- model: selection.model,
125
- max_output_tokens: VERIFY_OUTPUT_TOKENS,
126
- input: 'Reply OK.',
127
- },
128
- };
129
- }
@@ -1,294 +0,0 @@
1
- import { rm } from 'node:fs/promises';
2
- import { homedir } from 'node:os';
3
- import { join } from 'node:path';
4
- import { FleetUsageError } from '../errors';
5
- import { fleet } from '../fleet-config';
6
- import { runCommand } from '../runner';
7
- import { blocking, type Check, type Runner } from '../types';
8
- import {
9
- nativeLoginCheck,
10
- nativeLogins,
11
- providerAccountChecks,
12
- rosterCurrentCheck,
13
- } from '../accounts/checks';
14
- import { exposedVersion, t3Settings } from '../accounts/context';
15
- import { parseRoster, type ProxyRoster } from '../accounts/roster';
16
- import { exposedInstances } from '../accounts/sessions';
17
- import { forwardSourceOperation, ownerCheckout } from './source-operations';
18
- import type { CommandOutcome } from './contracts';
19
- import type { Settings } from './settings';
20
- import { fleetSync } from './fleet-sync';
21
-
22
- export interface FleetAccountsOptions {
23
- authPlan?: boolean;
24
- diff?: boolean;
25
- add?: boolean;
26
- relogin?: boolean;
27
- remove?: boolean;
28
- removeNativeLogins?: boolean;
29
- yes?: boolean;
30
- }
31
-
32
- export interface AccountsDependencies {
33
- run?: Runner;
34
- /** Runs a proxy command attached to the terminal (a sign-in). */
35
- operate?: (args: string[]) => Promise<number>;
36
- /** `converge --only accounts`. */
37
- propagate?: () => Promise<CommandOutcome>;
38
- home?: string;
39
- settingsFile?: string;
40
- }
41
-
42
- const PROVIDER = /^[a-z][a-z0-9-]{0,31}$/;
43
-
44
- /** `homelab accounts`: the provider account roster the proxy holds,
45
- * each account's state, and the account checks. `--add`, `--relogin` and
46
- * `--remove` change one account on the proxy and propagate the result to
47
- * every node at once.
48
- */
49
- export async function fleetAccounts(
50
- options: FleetAccountsOptions,
51
- args: string[],
52
- settings: Settings,
53
- dependencies: AccountsDependencies = {}
54
- ): Promise<CommandOutcome> {
55
- if (options.authPlan) return authPlan(options, args, settings, dependencies);
56
- const home = dependencies.home ?? homedir();
57
- if (options.removeNativeLogins)
58
- return removeNativeLogins(Boolean(options.yes), home);
59
- const change = lifecycle(options, args);
60
- const changed = change
61
- ? await applyChange(change, settings, dependencies)
62
- : undefined;
63
- if (changed && !changed.data) return failedChange();
64
- return report(options, settings, dependencies, { change, changed });
65
- }
66
-
67
- async function authPlan(
68
- options: FleetAccountsOptions,
69
- args: string[],
70
- settings: Settings,
71
- dependencies: AccountsDependencies
72
- ): Promise<CommandOutcome> {
73
- if (
74
- args.length ||
75
- options.add ||
76
- options.relogin ||
77
- options.remove ||
78
- options.removeNativeLogins ||
79
- options.diff ||
80
- options.yes
81
- )
82
- throw new FleetUsageError('Run --auth-plan on its own.');
83
- const roster = await readRoster(
84
- dependencies.run ?? runCommand,
85
- settings.workspace
86
- );
87
- return {
88
- exitCode: roster.managementApi ? 0 : 1,
89
- data: {
90
- version: 1,
91
- command: 'accounts',
92
- ok: roster.managementApi,
93
- managementApi: roster.managementApi,
94
- signIns: roster.accounts
95
- .filter((account) => account.state === 'needs-login')
96
- .map(({ provider, index }) => ({ provider, index })),
97
- ...(!roster.managementApi && {
98
- summary:
99
- 'The proxy management API is unavailable. The sign-in plan may be incomplete.',
100
- }),
101
- },
102
- };
103
- }
104
-
105
- async function report(
106
- options: FleetAccountsOptions,
107
- settings: Settings,
108
- dependencies: AccountsDependencies,
109
- {
110
- change,
111
- changed,
112
- }: { change: string[] | null; changed: CommandOutcome | undefined }
113
- ): Promise<CommandOutcome> {
114
- const home = dependencies.home ?? homedir();
115
- const roster = await readRoster(
116
- dependencies.run ?? runCommand,
117
- settings.workspace
118
- );
119
- const checks: Check[] = providerAccountChecks(
120
- roster,
121
- fleet.services.proxy.accounts?.minimumUsable
122
- );
123
- if (options.diff)
124
- checks.push(...(await thisMachine(roster, home, dependencies)));
125
- const ok = !checks.some(blocking) && !changed?.exitCode;
126
- return {
127
- exitCode: ok ? 0 : 1,
128
- data: {
129
- version: 1,
130
- command: 'accounts',
131
- ok,
132
- ...listing(roster),
133
- checks,
134
- ...(change && {
135
- changed: change.slice(0, 2),
136
- propagation: changed?.data,
137
- }),
138
- },
139
- };
140
- }
141
-
142
- /** The roster as listed: no routing prefix, no file. */
143
- function listing(roster: ProxyRoster) {
144
- return {
145
- rosterVersion: roster.rosterVersion,
146
- managementApi: roster.managementApi,
147
- accounts: roster.accounts.map(
148
- ({ provider, index, label, state, until, cooldowns }) => ({
149
- provider,
150
- index,
151
- label,
152
- state,
153
- until,
154
- cooldowns,
155
- })
156
- ),
157
- };
158
- }
159
-
160
- /** Runs the change on the proxy, then propagates it to every node. A change
161
- * the proxy did not complete answers with no data: nothing was propagated.
162
- */
163
- async function applyChange(
164
- change: string[],
165
- settings: Settings,
166
- dependencies: AccountsDependencies
167
- ): Promise<CommandOutcome> {
168
- const operate =
169
- dependencies.operate ??
170
- ((forwarded: string[]) =>
171
- forwardSourceOperation(['proxy', ...forwarded], settings));
172
- if ((await operate(change)) !== 0) return { exitCode: 1, data: null };
173
- return (
174
- dependencies.propagate ??
175
- (() => fleetSync({ only: 'accounts', json: true }, settings))
176
- )();
177
- }
178
-
179
- function failedChange(): CommandOutcome {
180
- return {
181
- exitCode: 1,
182
- data: {
183
- version: 1,
184
- command: 'accounts',
185
- ok: false,
186
- error: 'ACCOUNT_CHANGE_FAILED',
187
- summary:
188
- 'The proxy did not complete the change; an interrupted sign-in leaves no credential behind. Nothing was propagated.',
189
- },
190
- };
191
- }
192
-
193
- /** `--diff`: what this machine offers against the roster. */
194
- async function thisMachine(
195
- roster: ProxyRoster,
196
- home: string,
197
- dependencies: AccountsDependencies
198
- ): Promise<Check[]> {
199
- const exposed = await exposedInstances(
200
- dependencies.settingsFile ?? t3Settings()
201
- );
202
- return [
203
- rosterCurrentCheck(roster.rosterVersion, exposedVersion(exposed)),
204
- nativeLoginCheck(nativeLogins(home)),
205
- ];
206
- }
207
-
208
- /** The proxy command a lifecycle flag stands for, or null for a listing. */
209
- function lifecycle(
210
- options: FleetAccountsOptions,
211
- [provider, index]: string[]
212
- ): string[] | null {
213
- const chosen = (['add', 'relogin', 'remove'] as const).filter(
214
- (flag) => options[flag]
215
- );
216
- if (chosen.length === 0) return null;
217
- if (chosen.length > 1)
218
- throw new FleetUsageError('Choose one of --add, --relogin and --remove.');
219
- const flag = chosen[0]!;
220
- if (!provider || !PROVIDER.test(provider))
221
- throw new FleetUsageError(
222
- `--${flag} needs a provider, such as claude or codex.`
223
- );
224
- if (flag === 'add') return ['add-account', provider];
225
- if (!index || !/^[1-9][0-9]{0,3}$/.test(index))
226
- throw new FleetUsageError(
227
- `--${flag} needs the account's index, as homelab accounts lists it.`
228
- );
229
- return [flag === 'relogin' ? 'relogin' : 'remove-account', provider, index];
230
- }
231
-
232
- /** The roster as the proxy on this manager reports it. */
233
- async function readRoster(
234
- run: Runner,
235
- workspace: string
236
- ): Promise<ProxyRoster> {
237
- const checkout = ownerCheckout(workspace);
238
- if (!checkout)
239
- throw new FleetUsageError(
240
- 'The account roster is kept by the proxy on the manager. Run homelab accounts there, after a first converge.'
241
- );
242
- const result = await run(
243
- [
244
- 'python3',
245
- '-B',
246
- join(checkout, 'cliproxy/scripts/cli.py'),
247
- 'accounts',
248
- '--json',
249
- ],
250
- { cwd: checkout, timeoutMs: 60_000 }
251
- );
252
- try {
253
- if (!result.ok) throw new Error();
254
- return parseRoster(result.stdout);
255
- } catch {
256
- throw new FleetUsageError(
257
- 'The proxy did not report its accounts. Check it with homelab proxy status.'
258
- );
259
- }
260
- }
261
-
262
- /** Opt-in: deletes the provider logins agent CLIs keep outside the proxy. */
263
- async function removeNativeLogins(
264
- yes: boolean,
265
- home: string
266
- ): Promise<CommandOutcome> {
267
- const found = nativeLogins(home);
268
- if (!yes)
269
- return {
270
- exitCode: found.length ? 1 : 0,
271
- data: {
272
- version: 1,
273
- command: 'accounts',
274
- ok: found.length === 0,
275
- applied: false,
276
- checks: [nativeLoginCheck(found)],
277
- next: found.length
278
- ? 'Add --yes to remove these logins from this machine.'
279
- : undefined,
280
- },
281
- };
282
- for (const login of found) await rm(login.path, { force: true });
283
- return {
284
- exitCode: 0,
285
- data: {
286
- version: 1,
287
- command: 'accounts',
288
- ok: true,
289
- applied: true,
290
- removed: [...new Set(found.map((login) => login.cli))].sort(),
291
- checks: [nativeLoginCheck(nativeLogins(home))],
292
- },
293
- };
294
- }
@@ -1,62 +0,0 @@
1
- import { enrolledRoster } from '../enrolled-roster';
2
- import { selectNodes } from '../config';
3
- import { fleet as definition } from '../fleet-config';
4
- import { bundleProbe } from '../transport';
5
- import { machineProviders } from '../t3/providers';
6
- import { accountModels } from '../t3/models';
7
- import { accountContext, nodeAccountChecks } from '../accounts/context';
8
- import { propagateAccounts } from '../accounts/propagate';
9
- import { loadRoster } from './roster';
10
- import { ownerCheckout } from './source-operations';
11
- import type { Check, FleetNode, Runner } from '../types';
12
- import type { FleetSyncOptions } from './fleet-sync';
13
- import type { Settings } from './settings';
14
- import type { CommandOutcome } from './contracts';
15
-
16
- /** `converge --only accounts` on the manager. */
17
- export async function syncAccounts(
18
- options: FleetSyncOptions,
19
- settings: Settings,
20
- { revision, run }: { revision: string; run: Runner }
21
- ): Promise<CommandOutcome> {
22
- let nodes: FleetNode[] = [];
23
- try {
24
- nodes = selectNodes(
25
- enrolledRoster(definition, await loadRoster(settings.config)),
26
- options.node ?? []
27
- );
28
- } catch {
29
- // No enrolled worker yet: the manager alone.
30
- }
31
- return propagateAccounts({
32
- nodes,
33
- revision,
34
- source: await bundleProbe(),
35
- manager: () => managerAccounts(settings.workspace),
36
- run,
37
- });
38
- }
39
-
40
- /** The manager's own account instances and the models each shows, from the
41
- * checkout it runs.
42
- */
43
- export async function managerAccounts(workspace: string): Promise<Check[]> {
44
- const checkout = ownerCheckout(workspace);
45
- if (!checkout)
46
- return [
47
- {
48
- id: 't3:providers',
49
- status: 'fail',
50
- summary: 'No revision is applied on the manager yet.',
51
- remedy: {
52
- action: 'Run a full converge first.',
53
- command: 'homelab converge',
54
- },
55
- },
56
- ];
57
- return [
58
- await machineProviders(definition.manager.id, checkout, true),
59
- await accountModels(),
60
- ...(await nodeAccountChecks(await accountContext())),
61
- ];
62
- }
@@ -1,34 +0,0 @@
1
- import { join } from 'node:path';
2
- import { read, object, write } from '../t3/files';
3
- import { FleetUsageError } from '../errors';
4
-
5
- export async function deployment(root: string) {
6
- const raw = await read(join(root, 'node_modules/.personal-node.json'));
7
- if (raw === null) return null;
8
- const data = object(raw);
9
- if (
10
- data['version'] !== 1 ||
11
- typeof data['revision'] !== 'string' ||
12
- !/^[a-f0-9]{40}$/.test(data['revision']) ||
13
- typeof data['node'] !== 'string' ||
14
- !/^[a-z0-9][a-z0-9-]{0,62}$/.test(data['node'])
15
- )
16
- throw new FleetUsageError(
17
- 'Invalid local node receipt. Restore it before reconciling.'
18
- );
19
- return {
20
- workspace: join(root, 'node_modules/.fleet-revisions', data['revision']),
21
- node: data['node'],
22
- revision: data['revision'],
23
- };
24
- }
25
-
26
- export async function recordDeployment(
27
- root: string,
28
- node: string,
29
- revision: string
30
- ) {
31
- const path = join(root, 'node_modules/.personal-node.json');
32
- const content = JSON.stringify({ version: 1, node, revision }) + '\n';
33
- if ((await read(path)) !== content) await write(path, content);
34
- }
@@ -1,121 +0,0 @@
1
- import { join } from 'node:path';
2
- import { configureWorkspace } from '../configure';
3
- import { runCommand } from '../runner';
4
- import { FleetUsageError } from '../errors';
5
- import { packageInfo } from '../package-info';
6
- import type { Runner } from '../types';
7
- import type { Settings } from './settings';
8
- import type { CommandOutcome } from './contracts';
9
- import { syncT3 } from './node-t3';
10
- import { nodeId, type T3Options } from '../t3/desired';
11
- import { recordDeployment } from './node-deployment';
12
-
13
- export interface NodeSyncOptions extends T3Options {
14
- revision?: string;
15
- }
16
-
17
- /** One local convergence: locked tools, public launcher, profiles, then T3. */
18
- export async function syncNode(
19
- options: NodeSyncOptions,
20
- settings: Settings,
21
- run: Runner = runCommand
22
- ): Promise<CommandOutcome> {
23
- if (process.platform === 'win32' && !options.dryRun)
24
- throw new FleetUsageError(
25
- 'Codex proxy node sync requires macOS/Linux/WSL. Use homelab commands for native Windows configuration.'
26
- );
27
- const node = nodeId(options.id);
28
- // An installed package is not a checkout, and the Git repository around it
29
- // is the operator's own project: its HEAD is not a homelab revision.
30
- if (packageInfo().revision)
31
- throw new FleetUsageError(
32
- 'converge-local works on a checkout of homelab. Run converge instead: it converges this machine from a checkout it owns.'
33
- );
34
- const head = await run(['git', 'rev-parse', '--verify', 'HEAD'], {
35
- cwd: settings.workspace,
36
- });
37
- const revision = options.revision ?? head.stdout.trim();
38
- if (!head.ok || !/^[a-f0-9]{40}$/.test(revision))
39
- throw new FleetUsageError(
40
- 'An existing personal checkout is required; set --workspace PATH.'
41
- );
42
- const request = { node, revision, tool: 'codex', profile: 'proxy' };
43
- if (options.dryRun)
44
- return {
45
- exitCode: 0,
46
- data: {
47
- version: 1,
48
- command: 'converge-local',
49
- ok: true,
50
- applied: false,
51
- ...request,
52
- steps: [
53
- 'Reconcile locked tools',
54
- 'Install personal and retire owned ws launcher',
55
- 'Upsert Codex proxy profile',
56
- 'Reconcile declared T3 instances and remove stale owned entries',
57
- ],
58
- },
59
- };
60
- const checks = await configureWorkspace(settings.workspace, request, run);
61
- if (checks.some((check) => check.status !== 'pass'))
62
- return {
63
- exitCode: 1,
64
- data: { version: 1, command: 'converge-local', ok: false, checks },
65
- };
66
- return finishSync(options, settings, { request, checks }, run);
67
- }
68
-
69
- async function finishSync(
70
- options: NodeSyncOptions,
71
- settings: Settings,
72
- input: {
73
- request: { node: string; revision: string; tool: string; profile: string };
74
- checks: Awaited<ReturnType<typeof configureWorkspace>>;
75
- },
76
- run: Runner
77
- ): Promise<CommandOutcome> {
78
- const { request, checks } = input;
79
- const { node, revision } = request;
80
- const workspace = join(
81
- settings.workspace,
82
- 'node_modules/.fleet-revisions',
83
- revision
84
- );
85
- const installed = await run(['sh', 'bootstrap/install-launcher.sh'], {
86
- cwd: workspace,
87
- timeoutMs: 30_000,
88
- });
89
- if (!installed.ok)
90
- return {
91
- exitCode: 1,
92
- data: {
93
- version: 1,
94
- ok: false,
95
- checks,
96
- error:
97
- 'Launcher installation failed; profile changes may already have applied.',
98
- },
99
- };
100
- const t3 = await syncT3({ ...options, id: node }, { ...settings, workspace });
101
- if (t3.exitCode !== 0) return t3;
102
- await recordDeployment(settings.workspace, node, revision);
103
- return {
104
- exitCode: 0,
105
- data: {
106
- version: 1,
107
- command: 'converge-local',
108
- ok: true,
109
- applied: true,
110
- ...request,
111
- checks,
112
- t3: t3.data,
113
- readiness: {
114
- authentication: 'unverified',
115
- inference: 'unverified',
116
- pairing: 'unverified',
117
- },
118
- next: 'Use homelab t3 for configuration drift and homelab check for machine health.',
119
- },
120
- };
121
- }
@@ -1,35 +0,0 @@
1
- import { T3DiagnosticError } from '../t3/diagnostics';
2
- import { FleetUsageError } from '../errors';
3
- import type { Settings } from './settings';
4
- import type { CommandOutcome } from './contracts';
5
- import { t3Command } from './t3/command';
6
- import type { T3Options } from '../t3/desired';
7
-
8
- export async function syncT3(
9
- options: T3Options,
10
- settings: Settings
11
- ): Promise<CommandOutcome> {
12
- try {
13
- return await t3Command('t3-reconcile', options, settings);
14
- } catch (error) {
15
- return {
16
- exitCode: 1,
17
- data: {
18
- version: 1,
19
- command: 'converge-local',
20
- ok: false,
21
- applied: true,
22
- stage: 't3',
23
- ...(error instanceof T3DiagnosticError
24
- ? { checks: [error.check] }
25
- : {}),
26
- error:
27
- error instanceof FleetUsageError
28
- ? error.message
29
- : 'T3 reconciliation failed; inspect local configuration and ownership state.',
30
- progress:
31
- 'Tools, launcher and profile steps completed. Node receipt was not advanced. Fix the T3 conflict and repeat converge-local.',
32
- },
33
- };
34
- }
35
- }