@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.
- package/.mise/locks/npm-vercel/{68.0.0 → 68.2.0}/aube-lock.yaml +73 -297
- package/.mise/locks/npm-vercel/{68.0.0 → 68.2.0}/package.json +1 -1
- package/.mise/locks/npm-wrangler/{4.169.0 → 4.170.0}/aube-lock.yaml +42 -42
- package/.mise/locks/npm-wrangler/{4.169.0 → 4.170.0}/package.json +1 -1
- package/README.md +54 -76
- package/ansible/ubuntu/agent-tool.py +106 -1
- package/ansible/ubuntu/heavy.py +142 -0
- package/ansible/ubuntu/idle-reboot.py +125 -0
- package/ansible/ubuntu/policy.json +58 -3
- package/ansible/ubuntu/t3-desktop.yml +7 -0
- package/ansible/ubuntu/t3-hang-snapshot.sh +75 -0
- package/ansible/ubuntu/t3-headless.yml +7 -0
- package/ansible/ubuntu/t3-health.sh +71 -3
- package/ansible/ubuntu/t3-policy.yml +14 -5
- package/ansible/ubuntu/tasks/packages.yml +2 -0
- package/ansible/ubuntu/tasks/recovery.yml +16 -2
- package/ansible/ubuntu/tasks/resources.yml +25 -2
- package/ansible/ubuntu/tasks/unattended-upgrades.yml +24 -6
- package/ansible/ubuntu/tasks/updates.yml +59 -0
- package/ansible/ubuntu/wip-guard.py +141 -14
- package/bootstrap/doctor.ts +0 -4
- package/bootstrap/project-action.sh +4 -5
- package/bootstrap/shell-path.ts +17 -19
- package/cliproxy/README.md +5 -6
- package/cliproxy/config.template.yaml +1 -15
- package/cliproxy/docs/health-workflow.example.yml +6 -6
- package/cliproxy/docs/model-health.md +8 -8
- package/cliproxy/scripts/accounts.py +3 -4
- package/cliproxy/scripts/fleet_sync.py +2 -13
- package/cliproxy/scripts/ops +3 -21
- package/docs/authentication.md +21 -26
- package/docs/convergence.md +28 -32
- package/docs/declared.md +30 -31
- package/docs/durability.md +9 -0
- package/docs/github.md +0 -9
- package/docs/machine-setup.md +16 -17
- package/docs/manager-recovery.md +0 -2
- package/docs/operations.md +12 -11
- package/docs/releasing.md +18 -21
- package/docs/runbooks.md +22 -78
- package/docs/support-matrix.md +1 -1
- package/docs/ubuntu-sync.md +71 -65
- package/docs/worker-contract.md +112 -15
- package/examples/fleet.json +0 -1
- package/llms.txt +0 -2
- package/mise.lock +206 -780
- package/mise.toml +12 -27
- package/package.json +5 -6
- package/schema/check-ids.json +41 -482
- package/schema/fleet.schema.json +6 -57
- package/schema/roster.schema.json +0 -2
- package/src/agent-session-limit.ts +2 -7
- package/src/auth-checks.ts +1 -3
- package/src/check-owners.ts +0 -13
- package/src/check-registry.ts +13 -72
- package/src/cli/agent-guide.ts +3 -16
- package/src/cli/command-index.ts +0 -12
- package/src/cli/fleet-sync-manager.ts +4 -146
- package/src/cli/fleet-sync-output.ts +1 -4
- package/src/cli/fleet-sync-plan.ts +1 -24
- package/src/cli/fleet-sync-remote.ts +2 -1
- package/src/cli/fleet-sync-vault.ts +1 -2
- package/src/cli/fleet-sync.ts +8 -44
- package/src/cli/fleet.ts +1 -2
- package/src/cli/program.ts +3 -14
- package/src/cli/register-fleet.ts +1 -55
- package/src/cli/registry.ts +1 -43
- package/src/config.ts +0 -2
- package/src/definition.ts +8 -83
- package/src/fleet-config.ts +1 -1
- package/src/ide/definition.ts +2 -29
- package/src/ide/super.ts +4 -35
- package/src/ide/t3.ts +9 -38
- package/src/manager-sync.ts +1 -1
- package/src/node-converge-linux.ts +4 -47
- package/src/node-converge-shared.ts +1 -22
- package/src/{agents/toolchain.ts → pinned-path.ts} +0 -17
- package/src/platform/agent-oom-check.ts +104 -0
- package/src/platform/t3-policy.ts +23 -36
- package/src/platform/t3-service.ts +117 -0
- package/src/platform/wip-guard-check.ts +65 -0
- package/src/remote-entry.ts +2 -41
- package/src/repair-catalog.ts +0 -30
- package/src/schedule-check.ts +17 -4
- package/src/service-auth.ts +0 -50
- package/src/state/litestream.ts +1 -1
- package/src/t3/retire-providers.ts +79 -0
- package/src/t3/version.ts +1 -1
- package/src/transport.ts +2 -6
- package/src/types.ts +0 -2
- package/src/version-parity.ts +0 -8
- package/src/worker-access-checks.ts +0 -75
- package/src/worker-host-checks.ts +78 -1
- package/src/worker-policy.ts +0 -2
- package/src/worker-readiness.ts +2 -0
- package/src/worker-sizing.ts +25 -0
- package/.mise/locks/azure-cli/2.93.0~a837e014/pyproject.toml +0 -5
- package/.mise/locks/azure-cli/2.93.0~a837e014/uv.lock +0 -2841
- package/.mise/locks/gemini/0.71.1~84aac8e6/aube-lock.yaml +0 -124
- package/.mise/locks/gemini/0.71.1~84aac8e6/package.json +0 -12
- package/agents/antigravity-proxy.ts +0 -3
- package/agents/audit.md +0 -88
- package/agents/bin/agy +0 -10
- package/agents/bin/antigravity +0 -10
- package/agents/bin/claude +0 -10
- package/agents/bin/codex +0 -10
- package/agents/bin/grok +0 -10
- package/agents/bin/opencode +0 -10
- package/agents/claude-proxy +0 -5
- package/agents/claude-proxy.ts +0 -3
- package/agents/codex-proxy.ts +0 -3
- package/agents/grok-proxy.ts +0 -3
- package/agents/managed-proxy.ts +0 -109
- package/agents/opencode-proxy.ts +0 -3
- package/agents/registry.json +0 -209
- package/agents/registry.schema.json +0 -149
- package/agents/setup.md +0 -158
- package/agents/t3.json +0 -40
- package/ansible/agents/agents.yml +0 -135
- package/ansible/agents/commands.yml +0 -32
- package/ansible/agents/receipts.yml +0 -19
- package/ansible/agents/templates/antigravity.settings.json.j2 +0 -3
- package/ansible/agents/templates/claude.settings.json.j2 +0 -3
- package/ansible/agents/templates/codex.config.toml.j2 +0 -11
- package/ansible/agents/templates/gemini.settings.json.j2 +0 -14
- package/ansible/agents/templates/grok.config.toml.j2 +0 -25
- package/ansible/agents/templates/opencode.json.j2 +0 -24
- package/ansible/agents/templates/receipt.json.j2 +0 -10
- package/ansible/t3/provider-keys.yml +0 -24
- package/docs/accounts.md +0 -256
- package/src/accounts/checks.ts +0 -226
- package/src/accounts/context.ts +0 -77
- package/src/accounts/propagate.ts +0 -62
- package/src/accounts/roster.ts +0 -112
- package/src/accounts/selection.ts +0 -67
- package/src/accounts/sessions.ts +0 -354
- package/src/agents/account-relay.ts +0 -279
- package/src/agents/accounts.ts +0 -94
- package/src/agents/admission.ts +0 -65
- package/src/agents/audit.ts +0 -77
- package/src/agents/cli.ts +0 -13
- package/src/agents/command.ts +0 -257
- package/src/agents/commands.ts +0 -127
- package/src/agents/converge.ts +0 -339
- package/src/agents/doctor.ts +0 -107
- package/src/agents/errors.ts +0 -2
- package/src/agents/files.ts +0 -43
- package/src/agents/fleet-verify.ts +0 -195
- package/src/agents/launch.ts +0 -361
- package/src/agents/native-verify.ts +0 -738
- package/src/agents/provider-errors.ts +0 -57
- package/src/agents/registry.ts +0 -61
- package/src/agents/render.ts +0 -121
- package/src/agents/round-trip.ts +0 -192
- package/src/agents/secrets.ts +0 -48
- package/src/agents/verify-cache.ts +0 -164
- package/src/agents/verify.ts +0 -129
- package/src/cli/fleet-accounts.ts +0 -294
- package/src/cli/fleet-sync-accounts.ts +0 -62
- package/src/cli/node-deployment.ts +0 -34
- package/src/cli/node-sync.ts +0 -121
- package/src/cli/node-t3.ts +0 -35
- package/src/cli/t3/command.ts +0 -91
- package/src/cli/t3/register.ts +0 -56
- package/src/configure.ts +0 -271
- package/src/github/copilot.ts +0 -54
- package/src/t3/accounts.ts +0 -90
- package/src/t3/antigravity.ts +0 -93
- package/src/t3/desired.ts +0 -174
- package/src/t3/diagnostics.ts +0 -42
- package/src/t3/models.ts +0 -354
- package/src/t3/names-check.ts +0 -53
- package/src/t3/names.ts +0 -155
- package/src/t3/plan.ts +0 -106
- package/src/t3/provider-keys.ts +0 -49
- package/src/t3/providers.ts +0 -102
- package/src/t3/reconcile.ts +0 -133
package/src/agents/command.ts
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console -- this command's contract is JSON on stdout. */
|
|
2
|
-
import { auditMachine } from './audit';
|
|
3
|
-
import { AgentConfigurationError } from './errors';
|
|
4
|
-
import type { Command } from 'commander';
|
|
5
|
-
import { join } from 'node:path';
|
|
6
|
-
import { homedir } from 'node:os';
|
|
7
|
-
import { currentPlatform } from '../platform';
|
|
8
|
-
import { registry, select } from './registry';
|
|
9
|
-
import { agentRoot } from './render';
|
|
10
|
-
import {
|
|
11
|
-
convergeAgents,
|
|
12
|
-
plan,
|
|
13
|
-
publicPlan,
|
|
14
|
-
refreshProfileBatch,
|
|
15
|
-
} from './converge';
|
|
16
|
-
import { launchProfile } from './launch';
|
|
17
|
-
import { verifyProvider } from './verify';
|
|
18
|
-
|
|
19
|
-
/** The global flags of the CLI that hosts these commands. */
|
|
20
|
-
type GlobalOpts = { json?: boolean | undefined; yes?: boolean | undefined };
|
|
21
|
-
|
|
22
|
-
/** The monorepo checkout that contains this package. */
|
|
23
|
-
const workspaceRoot = (): string => join(import.meta.dir, '../..');
|
|
24
|
-
|
|
25
|
-
async function revision(requireClean: boolean): Promise<string> {
|
|
26
|
-
if (requireClean) await requireCleanSources();
|
|
27
|
-
const child = Bun.spawn(['git', 'rev-parse', 'HEAD'], {
|
|
28
|
-
cwd: workspaceRoot(),
|
|
29
|
-
stdout: 'pipe',
|
|
30
|
-
stderr: 'ignore',
|
|
31
|
-
});
|
|
32
|
-
const value = (await new Response(child.stdout).text()).trim();
|
|
33
|
-
if ((await child.exited) || !/^[a-f0-9]{40}$/.test(value))
|
|
34
|
-
throw new AgentConfigurationError('Cannot resolve checkout revision.');
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type AgentOptions = {
|
|
39
|
-
node: string;
|
|
40
|
-
tool: string;
|
|
41
|
-
profile: string;
|
|
42
|
-
adopt?: boolean;
|
|
43
|
-
smoke?: boolean;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export function registerAgents(
|
|
47
|
-
program: Command,
|
|
48
|
-
globals: () => GlobalOpts
|
|
49
|
-
): void {
|
|
50
|
-
const agents = program
|
|
51
|
-
.command('agents')
|
|
52
|
-
.description('[ws] Versioned agent/provider profiles');
|
|
53
|
-
agents
|
|
54
|
-
.command('inventory')
|
|
55
|
-
.action(() => console.log(JSON.stringify(registry, null, 2)));
|
|
56
|
-
agents
|
|
57
|
-
.command('audit')
|
|
58
|
-
.action(async () =>
|
|
59
|
-
console.log(
|
|
60
|
-
JSON.stringify(await auditMachine(currentPlatform()), null, 2)
|
|
61
|
-
)
|
|
62
|
-
);
|
|
63
|
-
registerT3Plan(agents);
|
|
64
|
-
for (const action of ['preview', 'apply', 'status', 'verify', 'run']) {
|
|
65
|
-
agents
|
|
66
|
-
.command(action)
|
|
67
|
-
.argument('[args...]')
|
|
68
|
-
.requiredOption('--node <id>', 'Explicit fleet node ID')
|
|
69
|
-
.option(
|
|
70
|
-
'--tool <tool>',
|
|
71
|
-
'codex|claude|opencode|gemini|grok|antigravity; apply takes several, separated by commas',
|
|
72
|
-
'codex'
|
|
73
|
-
)
|
|
74
|
-
.option('--profile <profile>', 'direct|proxy', 'direct')
|
|
75
|
-
.option(
|
|
76
|
-
'--adopt',
|
|
77
|
-
'Back up and replace conflicting dedicated profile files'
|
|
78
|
-
)
|
|
79
|
-
.option(
|
|
80
|
-
'--smoke',
|
|
81
|
-
'Spend tokens: one request, 16 output tokens, 30 second deadline'
|
|
82
|
-
)
|
|
83
|
-
.action(async (args: string[], options: AgentOptions) => {
|
|
84
|
-
// `apply --tool a,b` applies each tool in turn in this one process
|
|
85
|
-
// and stops at the first that fails, which its line names.
|
|
86
|
-
const tools =
|
|
87
|
-
action === 'apply' ? options.tool.split(',') : [options.tool];
|
|
88
|
-
let reviewed: Promise<string> | undefined;
|
|
89
|
-
const selectedRevision = () =>
|
|
90
|
-
(reviewed ??= revision(['apply', 'run', 'verify'].includes(action)));
|
|
91
|
-
if (
|
|
92
|
-
tools.length > 1 &&
|
|
93
|
-
globals().yes &&
|
|
94
|
-
(await refreshBatch(options, tools, selectedRevision))
|
|
95
|
-
)
|
|
96
|
-
return;
|
|
97
|
-
for (const tool of tools) {
|
|
98
|
-
try {
|
|
99
|
-
await execute(
|
|
100
|
-
action,
|
|
101
|
-
args,
|
|
102
|
-
{ ...options, tool, revision: await selectedRevision() },
|
|
103
|
-
globals()
|
|
104
|
-
);
|
|
105
|
-
} catch (error) {
|
|
106
|
-
console.log(
|
|
107
|
-
JSON.stringify({
|
|
108
|
-
ok: false,
|
|
109
|
-
...(tools.length > 1 ? { tool } : {}),
|
|
110
|
-
error:
|
|
111
|
-
error instanceof AgentConfigurationError
|
|
112
|
-
? error.message
|
|
113
|
-
: 'Agent operation failed. Check node/tool/profile, review conflicts with preview, authenticate this node to Vault for proxy, and check approved model availability. No raw error or response is retained.',
|
|
114
|
-
})
|
|
115
|
-
);
|
|
116
|
-
process.exitCode = 1;
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async function refreshBatch(
|
|
125
|
-
options: AgentOptions,
|
|
126
|
-
tools: string[],
|
|
127
|
-
selectedRevision: () => Promise<string>
|
|
128
|
-
): Promise<boolean> {
|
|
129
|
-
try {
|
|
130
|
-
const revision = await selectedRevision();
|
|
131
|
-
const root = agentRoot(homedir(), currentPlatform().name);
|
|
132
|
-
const results = await refreshProfileBatch(
|
|
133
|
-
tools.map((tool) => ({
|
|
134
|
-
root,
|
|
135
|
-
revision,
|
|
136
|
-
selection: select(options.node, tool, options.profile),
|
|
137
|
-
}))
|
|
138
|
-
);
|
|
139
|
-
if (!results) return false;
|
|
140
|
-
for (const [index, result] of results.entries())
|
|
141
|
-
console.log(JSON.stringify({ ok: true, tool: tools[index], ...result }));
|
|
142
|
-
return true;
|
|
143
|
-
} catch {
|
|
144
|
-
// Recheck under the lock one profile at a time for per-tool evidence.
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
async function execute(
|
|
150
|
-
action: string,
|
|
151
|
-
args: string[],
|
|
152
|
-
options: AgentOptions & { revision: string },
|
|
153
|
-
global: GlobalOpts
|
|
154
|
-
) {
|
|
155
|
-
const selection = select(options.node, options.tool, options.profile);
|
|
156
|
-
const root = agentRoot(homedir(), currentPlatform().name);
|
|
157
|
-
const context = {
|
|
158
|
-
root,
|
|
159
|
-
selection,
|
|
160
|
-
revision: options.revision,
|
|
161
|
-
};
|
|
162
|
-
if (action === 'apply') {
|
|
163
|
-
if (!global.yes) throw new AgentConfigurationError('Apply requires --yes.');
|
|
164
|
-
console.log(
|
|
165
|
-
JSON.stringify({
|
|
166
|
-
ok: true,
|
|
167
|
-
tool: selection.tool,
|
|
168
|
-
...(await convergeAgents(context, options.adopt)),
|
|
169
|
-
})
|
|
170
|
-
);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
const result = await plan(context);
|
|
174
|
-
const clean =
|
|
175
|
-
result.files.every((file) => file.state === 'unchanged') &&
|
|
176
|
-
result.previous?.fingerprint === result.fingerprint;
|
|
177
|
-
if (['run', 'verify'].includes(action)) {
|
|
178
|
-
if (!clean)
|
|
179
|
-
throw new AgentConfigurationError(
|
|
180
|
-
'Apply the reviewed configuration first.'
|
|
181
|
-
);
|
|
182
|
-
await runOrVerify(action, root, selection, {
|
|
183
|
-
args,
|
|
184
|
-
smoke: options.smoke === true,
|
|
185
|
-
});
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
console.log(
|
|
189
|
-
JSON.stringify({
|
|
190
|
-
ok: action === 'preview' || clean,
|
|
191
|
-
...publicPlan(result, context.revision),
|
|
192
|
-
})
|
|
193
|
-
);
|
|
194
|
-
if (action === 'status' && !clean) process.exitCode = 1;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
async function runOrVerify(
|
|
198
|
-
action: string,
|
|
199
|
-
root: string,
|
|
200
|
-
selection: ReturnType<typeof select>,
|
|
201
|
-
input: { args: string[]; smoke: boolean }
|
|
202
|
-
) {
|
|
203
|
-
if (action === 'run') {
|
|
204
|
-
process.exitCode = await launchProfile(root, selection, input.args);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
console.log(
|
|
208
|
-
JSON.stringify({
|
|
209
|
-
ok: true,
|
|
210
|
-
...(await verifyProvider(selection, input.smoke)),
|
|
211
|
-
})
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function registerT3Plan(agents: Command): void {
|
|
216
|
-
agents
|
|
217
|
-
.command('t3-plan')
|
|
218
|
-
.requiredOption('--node <id>', 'Fleet node ID')
|
|
219
|
-
.action((options: { node: string }) => {
|
|
220
|
-
const selection = select(options.node, 'codex', 'proxy');
|
|
221
|
-
const root = agentRoot(homedir(), currentPlatform().name);
|
|
222
|
-
console.log(
|
|
223
|
-
JSON.stringify(
|
|
224
|
-
{
|
|
225
|
-
applied: false,
|
|
226
|
-
instance: 'personal_codex_proxy',
|
|
227
|
-
driver: 'codex',
|
|
228
|
-
config: {
|
|
229
|
-
binaryPath: join(workspaceRoot(), 'agents/codex-proxy.ts'),
|
|
230
|
-
homePath: join(root, selection.node, 'codex', 'proxy'),
|
|
231
|
-
},
|
|
232
|
-
environment: [{ name: 'WS_AGENT_NODE', value: selection.node }],
|
|
233
|
-
instruction:
|
|
234
|
-
'Use these explicitly owned fields in a new T3 Codex provider instance. Preserve all other settings and secret references. Native Windows executable launch has not been validated.',
|
|
235
|
-
},
|
|
236
|
-
null,
|
|
237
|
-
2
|
|
238
|
-
)
|
|
239
|
-
);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
async function requireCleanSources(): Promise<void> {
|
|
244
|
-
const child = Bun.spawn(
|
|
245
|
-
['git', 'status', '--porcelain', '--', 'agents', 'src/agents'],
|
|
246
|
-
{
|
|
247
|
-
cwd: workspaceRoot(),
|
|
248
|
-
stdout: 'pipe',
|
|
249
|
-
stderr: 'ignore',
|
|
250
|
-
}
|
|
251
|
-
);
|
|
252
|
-
const output = await new Response(child.stdout).text();
|
|
253
|
-
if ((await child.exited) || output.trim())
|
|
254
|
-
throw new AgentConfigurationError(
|
|
255
|
-
'Fleet agent sources are dirty. Commit/review configuration before applying or launching a managed profile. Local work was preserved.'
|
|
256
|
-
);
|
|
257
|
-
}
|
package/src/agents/commands.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { readdirSync } from 'node:fs';
|
|
2
|
-
import { lstat, readlink } from 'node:fs/promises';
|
|
3
|
-
import { homedir } from 'node:os';
|
|
4
|
-
import { dirname, join, relative } from 'node:path';
|
|
5
|
-
import { agentCommands } from '../../bootstrap/shell-path';
|
|
6
|
-
import { PACKAGE_ROOT } from '../package-info';
|
|
7
|
-
import { runAnsible } from '../platform/ansible';
|
|
8
|
-
import { stablePath } from '../platform/t3-policy';
|
|
9
|
-
import type { Check, CommandResult, Runner } from '../types';
|
|
10
|
-
|
|
11
|
-
/** The agent commands of a worker. On a worker `claude`, `codex` and the
|
|
12
|
-
* others are the fleet's launchers (`agents/bin`), which sign in through the
|
|
13
|
-
* CLI proxy: the proxy holds the provider accounts, and a worker holds none.
|
|
14
|
-
* So whatever starts an agent by its name there, a person in a terminal or
|
|
15
|
-
* an app over SSH, uses the proxy's accounts.
|
|
16
|
-
*
|
|
17
|
-
* One link does it: `agent-commands`, beside the applied revision, points at
|
|
18
|
-
* that revision's `agents/bin` through `current`, so it follows every sync
|
|
19
|
-
* and rollback without being written again. Every shell has it first on its
|
|
20
|
-
* PATH (bootstrap/shell-path.ts). The manager gets no link: its shells keep
|
|
21
|
-
* the pinned CLIs. The link is made by a play (ansible/agents/commands.yml);
|
|
22
|
-
* this decides whether it is played and measures the result.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/** Runs the commands play with the link and its target. */
|
|
26
|
-
export type CommandsPlay = (variables: {
|
|
27
|
-
agent_commands_link: string;
|
|
28
|
-
agent_commands_target: string;
|
|
29
|
-
}) => Promise<CommandResult>;
|
|
30
|
-
|
|
31
|
-
/** `scratch` is where the variables file is kept while the play runs (the
|
|
32
|
-
* fleet's private run directory by default).
|
|
33
|
-
*/
|
|
34
|
-
export function commandsPlay(run: Runner, scratch?: string): CommandsPlay {
|
|
35
|
-
const directory = join(PACKAGE_ROOT, 'ansible', 'agents');
|
|
36
|
-
return (variables) =>
|
|
37
|
-
runAnsible(
|
|
38
|
-
run,
|
|
39
|
-
join(directory, 'commands.yml'),
|
|
40
|
-
{
|
|
41
|
-
cwd: directory,
|
|
42
|
-
input: JSON.stringify(variables),
|
|
43
|
-
timeoutMs: 90_000,
|
|
44
|
-
},
|
|
45
|
-
scratch
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Where the link is and what it holds, for the checkout this run applies:
|
|
50
|
-
* nothing for a checkout the fleet does not own.
|
|
51
|
-
*/
|
|
52
|
-
function link(
|
|
53
|
-
root: string,
|
|
54
|
-
home: string
|
|
55
|
-
): { path: string; target: string } | null {
|
|
56
|
-
const current = stablePath(root);
|
|
57
|
-
const path = agentCommands(home);
|
|
58
|
-
return current !== root && dirname(current) === dirname(path)
|
|
59
|
-
? { path, target: join(relative(dirname(path), current), 'agents', 'bin') }
|
|
60
|
-
: null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** `agent:commands`: the worker's agent commands are the fleet's launchers. */
|
|
64
|
-
export async function linkAgentCommands(
|
|
65
|
-
root: string,
|
|
66
|
-
play: CommandsPlay,
|
|
67
|
-
home = homedir()
|
|
68
|
-
): Promise<Check> {
|
|
69
|
-
const id = 'agent:commands';
|
|
70
|
-
const wanted = link(root, home);
|
|
71
|
-
if (!wanted)
|
|
72
|
-
return {
|
|
73
|
-
id,
|
|
74
|
-
status: 'skip',
|
|
75
|
-
summary:
|
|
76
|
-
'Not a checkout converge owns: the agent commands of this machine are left as they are.',
|
|
77
|
-
};
|
|
78
|
-
const held = () => readlink(wanted.path).catch(() => null);
|
|
79
|
-
if ((await held()) !== wanted.target) {
|
|
80
|
-
const found = await lstat(wanted.path).catch(() => null);
|
|
81
|
-
if (found && !found.isSymbolicLink())
|
|
82
|
-
return {
|
|
83
|
-
id,
|
|
84
|
-
status: 'fail',
|
|
85
|
-
summary: 'AGENT_COMMANDS_CONFLICT',
|
|
86
|
-
remedy: {
|
|
87
|
-
action: `${wanted.path} is not the link converge makes. Move it away on this worker, then run converge.`,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
const played = await play({
|
|
91
|
-
agent_commands_link: wanted.path,
|
|
92
|
-
agent_commands_target: wanted.target,
|
|
93
|
-
});
|
|
94
|
-
if (!played.ok || (await held()) !== wanted.target)
|
|
95
|
-
return {
|
|
96
|
-
id,
|
|
97
|
-
status: 'fail',
|
|
98
|
-
summary: 'AGENT_COMMANDS_NOT_LINKED',
|
|
99
|
-
remedy: {
|
|
100
|
-
action:
|
|
101
|
-
'The agent commands play (ansible/agents/commands.yml) did not make the link on this worker; its output is not reported. Run converge again.',
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
id,
|
|
107
|
-
status: 'pass',
|
|
108
|
-
summary:
|
|
109
|
-
"This worker's agent commands are the fleet's launchers, through the CLI proxy.",
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** The node a launcher runs as when nothing names it: the one whose agent
|
|
114
|
-
* profiles this machine holds. T3 names the node itself; a command started
|
|
115
|
-
* from a shell cannot. More than one, or none, is no answer.
|
|
116
|
-
*/
|
|
117
|
-
export function renderedNode(root: string): string {
|
|
118
|
-
let nodes: string[];
|
|
119
|
-
try {
|
|
120
|
-
nodes = readdirSync(root, { withFileTypes: true })
|
|
121
|
-
.filter((entry) => entry.isDirectory() && entry.name !== 'backups')
|
|
122
|
-
.map((entry) => entry.name);
|
|
123
|
-
} catch {
|
|
124
|
-
return '';
|
|
125
|
-
}
|
|
126
|
-
return nodes.length === 1 ? nodes[0]! : '';
|
|
127
|
-
}
|