@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/cli/t3/command.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { diagnoseT3 } from '../../t3/diagnostics';
|
|
2
|
-
import { deployment } from '../node-deployment';
|
|
3
|
-
import type { CommandOutcome } from '../contracts';
|
|
4
|
-
import type { Settings } from '../settings';
|
|
5
|
-
import { FleetUsageError } from '../../errors';
|
|
6
|
-
import { desired, nodeId, paths, type T3Options } from '../../t3/desired';
|
|
7
|
-
import { importT3, reconcileT3 } from '../../t3/reconcile';
|
|
8
|
-
|
|
9
|
-
export async function t3Command(
|
|
10
|
-
command: string,
|
|
11
|
-
options: T3Options,
|
|
12
|
-
settings: Settings
|
|
13
|
-
): Promise<CommandOutcome> {
|
|
14
|
-
const deployed = options.definition
|
|
15
|
-
? null
|
|
16
|
-
: await diagnoseT3('deployment', () => deployment(settings.workspace));
|
|
17
|
-
const workspace = deployed?.workspace ?? settings.workspace;
|
|
18
|
-
const target = paths(options, workspace);
|
|
19
|
-
if (command === 't3-reconcile' && options.import !== undefined)
|
|
20
|
-
return importCommand(target, options);
|
|
21
|
-
const instances = await diagnoseT3('definition', () =>
|
|
22
|
-
declared(command, target.definition, workspace, {
|
|
23
|
-
...options,
|
|
24
|
-
id: nodeId(options.id ?? deployed?.node),
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
const apply = shouldApply(command, options);
|
|
28
|
-
if (apply) requireSupportedPlatform(instances);
|
|
29
|
-
const data = await diagnoseT3('reconciliation', () =>
|
|
30
|
-
reconcileT3(target, instances, reconcileOptions(apply, options))
|
|
31
|
-
);
|
|
32
|
-
return {
|
|
33
|
-
exitCode: outcomeCode(command, data),
|
|
34
|
-
data: { command, ...data },
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function declared(
|
|
39
|
-
command: string,
|
|
40
|
-
definition: string,
|
|
41
|
-
workspace: string,
|
|
42
|
-
options: T3Options & { id: string }
|
|
43
|
-
): Promise<Record<string, unknown>> {
|
|
44
|
-
if (command === 't3-remove') return Promise.resolve({});
|
|
45
|
-
// An explicit definition is the complete instance set.
|
|
46
|
-
const roster =
|
|
47
|
-
options.roster ?? (options.definition ? async () => [] : undefined);
|
|
48
|
-
return desired(definition, workspace, options.id, roster);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function importCommand(
|
|
52
|
-
target: ReturnType<typeof paths>,
|
|
53
|
-
options: T3Options
|
|
54
|
-
): Promise<CommandOutcome> {
|
|
55
|
-
if (options.dryRun)
|
|
56
|
-
throw new FleetUsageError(
|
|
57
|
-
't3-reconcile --import adopts ownership and cannot be combined with --dry-run; inspect t3-reconcile --dry-run first.'
|
|
58
|
-
);
|
|
59
|
-
if (!options.import || !/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(options.import))
|
|
60
|
-
throw new FleetUsageError(
|
|
61
|
-
't3-reconcile --import expects an instance ID. Import authorizes management of that entire provider instance.'
|
|
62
|
-
);
|
|
63
|
-
return {
|
|
64
|
-
exitCode: 0,
|
|
65
|
-
data: { command: 't3-import', ...(await importT3(target, options.import)) },
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function reconcileOptions(apply: boolean, options: T3Options) {
|
|
70
|
-
return {
|
|
71
|
-
apply,
|
|
72
|
-
...(options.planHash ? { planHash: options.planHash } : {}),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function shouldApply(command: string, options: T3Options): boolean {
|
|
77
|
-
return ['t3-reconcile', 't3-remove'].includes(command) && !options.dryRun;
|
|
78
|
-
}
|
|
79
|
-
function outcomeCode(
|
|
80
|
-
command: string,
|
|
81
|
-
data: { ok: boolean; changed: boolean }
|
|
82
|
-
): number {
|
|
83
|
-
return !data.ok || (command === 't3' && data.changed) ? 1 : 0;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function requireSupportedPlatform(instances: Record<string, unknown>): void {
|
|
87
|
-
if (process.platform === 'win32' && Object.keys(instances).length)
|
|
88
|
-
throw new FleetUsageError(
|
|
89
|
-
'Managed Codex proxy execution requires macOS/Linux/WSL; native Windows settings were preserved.'
|
|
90
|
-
);
|
|
91
|
-
}
|
package/src/cli/t3/register.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Command } from 'commander';
|
|
2
|
-
import type { CommandOutcome } from '../contracts';
|
|
3
|
-
import { resolveSettings, type Settings } from '../settings';
|
|
4
|
-
import { commandNames } from '../names';
|
|
5
|
-
import { t3Command } from './command';
|
|
6
|
-
import type { T3Options } from '../../t3/desired';
|
|
7
|
-
|
|
8
|
-
export const T3_COMMANDS = [
|
|
9
|
-
['t3', 'Check managed T3 configuration for drift'],
|
|
10
|
-
[
|
|
11
|
-
't3-reconcile',
|
|
12
|
-
'Reconcile declared T3 provider instances; --dry-run plans, --import adopts',
|
|
13
|
-
],
|
|
14
|
-
[
|
|
15
|
-
't3-remove',
|
|
16
|
-
'Remove only provider instances recorded in personal ownership state',
|
|
17
|
-
],
|
|
18
|
-
] as const;
|
|
19
|
-
|
|
20
|
-
export function registerT3(
|
|
21
|
-
program: Command,
|
|
22
|
-
defaults: Settings,
|
|
23
|
-
complete: (outcome: CommandOutcome) => void
|
|
24
|
-
): void {
|
|
25
|
-
for (const [name, description] of T3_COMMANDS) {
|
|
26
|
-
const command = program
|
|
27
|
-
.command(commandNames(name).name)
|
|
28
|
-
.description(description)
|
|
29
|
-
.option('--id <name>', 'Node ID; defaults to hostname')
|
|
30
|
-
.option(
|
|
31
|
-
'--t3-home <path>',
|
|
32
|
-
'T3 base directory; defaults to T3CODE_HOME or ~/.t3'
|
|
33
|
-
)
|
|
34
|
-
.option(
|
|
35
|
-
'--definition <path>',
|
|
36
|
-
'Version 1 declarative T3 provider definition'
|
|
37
|
-
);
|
|
38
|
-
if (name !== 't3')
|
|
39
|
-
command
|
|
40
|
-
.option(
|
|
41
|
-
'--plan-hash <sha256>',
|
|
42
|
-
'Reject any changes since the reviewed plan'
|
|
43
|
-
)
|
|
44
|
-
.option('--dry-run', 'Preview without writing configuration or state');
|
|
45
|
-
if (name === 't3-reconcile')
|
|
46
|
-
command.option(
|
|
47
|
-
'--import <id>',
|
|
48
|
-
'Adopt an existing instance into personal ownership instead of reconciling'
|
|
49
|
-
);
|
|
50
|
-
command.action(async (_options, command: Command) => {
|
|
51
|
-
const options = command.optsWithGlobals<T3Options & Partial<Settings>>();
|
|
52
|
-
const settings = await resolveSettings({ ...defaults, ...options });
|
|
53
|
-
complete(await t3Command(name, options, settings));
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
package/src/configure.ts
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { join } from 'node:path';
|
|
2
|
-
import { mkdir, writeFile, rename, readFile } from 'node:fs/promises';
|
|
3
|
-
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import { record } from './config';
|
|
5
|
-
import type { Check, CommandResult, Runner } from './types';
|
|
6
|
-
|
|
7
|
-
export type ConfigurationRequest = {
|
|
8
|
-
revision: string;
|
|
9
|
-
tool: string;
|
|
10
|
-
profile: string;
|
|
11
|
-
node: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function validConfiguration(
|
|
15
|
-
value: unknown
|
|
16
|
-
): value is ConfigurationRequest {
|
|
17
|
-
return (
|
|
18
|
-
record(value) &&
|
|
19
|
-
typeof value['revision'] === 'string' &&
|
|
20
|
-
/^[a-f0-9]{40}$/.test(value['revision']) &&
|
|
21
|
-
['codex', 'claude', 'opencode', 'gemini', 'grok', 'antigravity'].includes(
|
|
22
|
-
String(value['tool'])
|
|
23
|
-
) &&
|
|
24
|
-
['direct', 'proxy'].includes(String(value['profile'])) &&
|
|
25
|
-
typeof value['node'] === 'string' &&
|
|
26
|
-
/^[a-z0-9][a-z0-9-]{0,62}$/.test(value['node'])
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** A pinned deployment worktree leaves the developer's branch and dirty files intact. */
|
|
31
|
-
export async function configureWorkspace(
|
|
32
|
-
root: string,
|
|
33
|
-
request: ConfigurationRequest,
|
|
34
|
-
run: Runner,
|
|
35
|
-
options: { additionalTools: string[]; bootstrappedDeployment: boolean } = {
|
|
36
|
-
additionalTools: [],
|
|
37
|
-
bootstrappedDeployment: false,
|
|
38
|
-
}
|
|
39
|
-
): Promise<Check[]> {
|
|
40
|
-
if (
|
|
41
|
-
options.additionalTools.some(
|
|
42
|
-
(tool) => !validConfiguration({ ...request, tool })
|
|
43
|
-
)
|
|
44
|
-
)
|
|
45
|
-
return failure('Invalid additional profile.');
|
|
46
|
-
if (!validConfiguration(request))
|
|
47
|
-
return failure('Invalid reviewed revision or configuration selection.');
|
|
48
|
-
const directory = deploymentDirectory(
|
|
49
|
-
root,
|
|
50
|
-
request.revision,
|
|
51
|
-
options.bootstrappedDeployment
|
|
52
|
-
);
|
|
53
|
-
const head = await run(
|
|
54
|
-
['git', 'rev-parse', '--verify', `${request.revision}^{commit}`],
|
|
55
|
-
{ cwd: root }
|
|
56
|
-
);
|
|
57
|
-
if (!head.ok || head.stdout.trim() !== request.revision)
|
|
58
|
-
return failure(
|
|
59
|
-
'Reviewed commit is unavailable locally. Fetch it explicitly and retry.'
|
|
60
|
-
);
|
|
61
|
-
const prepared = await prepareRevision(
|
|
62
|
-
root,
|
|
63
|
-
directory,
|
|
64
|
-
request.revision,
|
|
65
|
-
run
|
|
66
|
-
);
|
|
67
|
-
if (prepared.length) return prepared;
|
|
68
|
-
if (!options.bootstrappedDeployment) {
|
|
69
|
-
const setup = await setupRevision(directory, run);
|
|
70
|
-
if (setup.length) return setup;
|
|
71
|
-
}
|
|
72
|
-
const tools = [...new Set([request.tool, ...options.additionalTools])];
|
|
73
|
-
return recordProfiles(
|
|
74
|
-
root,
|
|
75
|
-
request,
|
|
76
|
-
tools,
|
|
77
|
-
await applyOwner(directory, request, tools, run)
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async function recordProfiles(
|
|
82
|
-
root: string,
|
|
83
|
-
request: ConfigurationRequest,
|
|
84
|
-
tools: string[],
|
|
85
|
-
applied: CommandResult
|
|
86
|
-
): Promise<Check[]> {
|
|
87
|
-
const single = tools.length === 1;
|
|
88
|
-
const lines = single ? [applied.stdout] : applied.stdout.trim().split('\n');
|
|
89
|
-
const checks: Check[] = [];
|
|
90
|
-
for (const [index, tool] of tools.entries()) {
|
|
91
|
-
const receipt = decodeReceipt(
|
|
92
|
-
lines[index] ?? '',
|
|
93
|
-
request.revision,
|
|
94
|
-
single ? undefined : tool
|
|
95
|
-
);
|
|
96
|
-
if (
|
|
97
|
-
!receipt ||
|
|
98
|
-
(index === tools.length - 1 &&
|
|
99
|
-
(!applied.ok || lines.length !== tools.length))
|
|
100
|
-
) {
|
|
101
|
-
checks.push(
|
|
102
|
-
...failure(
|
|
103
|
-
`Profile ${tool} was not verified. Receipts advanced for ${index} of ${tools.length} profiles; inspect agents preview before retrying.`
|
|
104
|
-
)
|
|
105
|
-
);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
await recordConfiguration(root, { ...request, tool }, receipt);
|
|
109
|
-
checks.push({
|
|
110
|
-
id: 'configuration:apply',
|
|
111
|
-
status: 'pass',
|
|
112
|
-
summary: `${tool} profile applied at revision ${request.revision}; configuration fingerprint ${receipt}.`,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return checks;
|
|
116
|
-
}
|
|
117
|
-
async function setupRevision(directory: string, run: Runner): Promise<Check[]> {
|
|
118
|
-
const setup = await run(
|
|
119
|
-
[
|
|
120
|
-
'mise',
|
|
121
|
-
'exec',
|
|
122
|
-
'--locked',
|
|
123
|
-
'bun',
|
|
124
|
-
'--',
|
|
125
|
-
'bun',
|
|
126
|
-
'bootstrap/setup.ts',
|
|
127
|
-
'--non-interactive',
|
|
128
|
-
],
|
|
129
|
-
{ cwd: directory, timeoutMs: 1_200_000 }
|
|
130
|
-
);
|
|
131
|
-
if (!setup.ok)
|
|
132
|
-
return failure(
|
|
133
|
-
'Existing setup owner failed. Partial tool/dependency installation is possible; no configuration receipt was advanced.'
|
|
134
|
-
);
|
|
135
|
-
return [];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function decodeReceipt(
|
|
139
|
-
output: string,
|
|
140
|
-
revision: string,
|
|
141
|
-
tool?: string
|
|
142
|
-
): string | null {
|
|
143
|
-
try {
|
|
144
|
-
const data: unknown = JSON.parse(output);
|
|
145
|
-
return record(data) &&
|
|
146
|
-
data['ok'] === true &&
|
|
147
|
-
(tool === undefined || data['tool'] === tool) &&
|
|
148
|
-
data['revision'] === revision &&
|
|
149
|
-
typeof data['fingerprint'] === 'string' &&
|
|
150
|
-
/^[a-f0-9]{64}$/.test(data['fingerprint'])
|
|
151
|
-
? data['fingerprint']
|
|
152
|
-
: null;
|
|
153
|
-
} catch {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function failure(summary: string): Check[] {
|
|
159
|
-
return [{ id: 'configuration:apply', status: 'fail', summary }];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async function prepareRevision(
|
|
163
|
-
root: string,
|
|
164
|
-
directory: string,
|
|
165
|
-
revision: string,
|
|
166
|
-
run: Runner
|
|
167
|
-
): Promise<Check[]> {
|
|
168
|
-
if (root === directory) return verifyRevision(directory, revision, run);
|
|
169
|
-
await mkdir(join(root, 'node_modules', '.fleet-revisions'), {
|
|
170
|
-
recursive: true,
|
|
171
|
-
});
|
|
172
|
-
const deployed = await run(['git', 'rev-parse', 'HEAD'], { cwd: directory });
|
|
173
|
-
if (!deployed.ok) {
|
|
174
|
-
const created = await run(
|
|
175
|
-
['git', 'worktree', 'add', '--detach', directory, revision],
|
|
176
|
-
{ cwd: root, timeoutMs: 30_000 }
|
|
177
|
-
);
|
|
178
|
-
if (!created.ok)
|
|
179
|
-
return failure(
|
|
180
|
-
'Cannot create pinned deployment worktree. Existing data was preserved.'
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
return verifyRevision(directory, revision, run);
|
|
184
|
-
}
|
|
185
|
-
async function verifyRevision(
|
|
186
|
-
directory: string,
|
|
187
|
-
revision: string,
|
|
188
|
-
run: Runner
|
|
189
|
-
): Promise<Check[]> {
|
|
190
|
-
const deployed = await run(['git', 'rev-parse', 'HEAD'], { cwd: directory });
|
|
191
|
-
const clean = await run(['git', 'status', '--porcelain'], { cwd: directory });
|
|
192
|
-
if (
|
|
193
|
-
!deployed.ok ||
|
|
194
|
-
deployed.stdout.trim() !== revision ||
|
|
195
|
-
!clean.ok ||
|
|
196
|
-
clean.stdout.trim()
|
|
197
|
-
)
|
|
198
|
-
return failure(
|
|
199
|
-
'Pinned deployment checkout differs or is dirty. Inspect it; fleet never resets it.'
|
|
200
|
-
);
|
|
201
|
-
const top = await run(['git', 'rev-parse', '--show-toplevel'], {
|
|
202
|
-
cwd: directory,
|
|
203
|
-
});
|
|
204
|
-
if (!top.ok || top.stdout.trim() !== directory)
|
|
205
|
-
return failure('Deployment path is not its own Git worktree.');
|
|
206
|
-
return [];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
async function recordConfiguration(
|
|
210
|
-
root: string,
|
|
211
|
-
request: ConfigurationRequest,
|
|
212
|
-
receipt: string
|
|
213
|
-
): Promise<void> {
|
|
214
|
-
const receipts = join(root, 'node_modules', '.fleet-configuration');
|
|
215
|
-
await mkdir(receipts, { recursive: true, mode: 0o700 });
|
|
216
|
-
const path = join(
|
|
217
|
-
receipts,
|
|
218
|
-
`${request.node}-${request.tool}-${request.profile}.json`
|
|
219
|
-
);
|
|
220
|
-
const contents =
|
|
221
|
-
JSON.stringify({ version: 1, ...request, fingerprint: receipt }) + '\n';
|
|
222
|
-
try {
|
|
223
|
-
if ((await readFile(path, 'utf8')) === contents) return;
|
|
224
|
-
} catch (error) {
|
|
225
|
-
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
|
|
226
|
-
}
|
|
227
|
-
const temp = `${path}.${randomUUID()}.tmp`;
|
|
228
|
-
await writeFile(temp, contents, { flag: 'wx', mode: 0o600 });
|
|
229
|
-
await rename(temp, path);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
async function applyOwner(
|
|
233
|
-
directory: string,
|
|
234
|
-
request: ConfigurationRequest,
|
|
235
|
-
tools: string[],
|
|
236
|
-
run: Runner
|
|
237
|
-
) {
|
|
238
|
-
return run(
|
|
239
|
-
[
|
|
240
|
-
'mise',
|
|
241
|
-
'exec',
|
|
242
|
-
'--locked',
|
|
243
|
-
'bun',
|
|
244
|
-
'--',
|
|
245
|
-
'bun',
|
|
246
|
-
'src/agents/cli.ts',
|
|
247
|
-
'--json',
|
|
248
|
-
'--yes',
|
|
249
|
-
'--non-interactive',
|
|
250
|
-
'agents',
|
|
251
|
-
'apply',
|
|
252
|
-
'--node',
|
|
253
|
-
request.node,
|
|
254
|
-
'--tool',
|
|
255
|
-
tools.join(','),
|
|
256
|
-
'--profile',
|
|
257
|
-
request.profile,
|
|
258
|
-
],
|
|
259
|
-
{ cwd: directory, timeoutMs: 120_000 * tools.length }
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function deploymentDirectory(
|
|
264
|
-
root: string,
|
|
265
|
-
revision: string,
|
|
266
|
-
bootstrapped: boolean
|
|
267
|
-
): string {
|
|
268
|
-
return bootstrapped
|
|
269
|
-
? root
|
|
270
|
-
: join(root, 'node_modules', '.fleet-revisions', revision);
|
|
271
|
-
}
|
package/src/github/copilot.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { Check, Runner } from '../types';
|
|
2
|
-
import { activeToken } from './sync';
|
|
3
|
-
|
|
4
|
-
/** The kinds of GitHub token Copilot CLI accepts: OAuth (`gho_`), GitHub App
|
|
5
|
-
* user (`ghu_`) and fine-grained personal (`github_pat_`) tokens. A classic
|
|
6
|
-
* personal token (`ghp_`) is refused by Copilot.
|
|
7
|
-
*/
|
|
8
|
-
const ACCEPTED = /^(gho_|ghu_|github_pat_)/;
|
|
9
|
-
const CLASSIC = /^ghp_/;
|
|
10
|
-
|
|
11
|
-
/** Copilot CLI signs in with the node's GitHub credential: with no token of
|
|
12
|
-
* its own in the environment and no `copilot login`, it uses the token gh
|
|
13
|
-
* holds. So the node's GitHub sign-in is Copilot's, and nothing is signed in
|
|
14
|
-
* per node by hand. Only the kind of the token is read, never the token.
|
|
15
|
-
*/
|
|
16
|
-
export async function copilotCheck(run: Runner): Promise<Check> {
|
|
17
|
-
const installed = await run(['copilot', '--version'], { timeoutMs: 15_000 });
|
|
18
|
-
if (!installed.ok)
|
|
19
|
-
return {
|
|
20
|
-
id: 'auth:copilot',
|
|
21
|
-
status: 'skip',
|
|
22
|
-
required: false,
|
|
23
|
-
summary: 'Copilot CLI is not installed in this process context.',
|
|
24
|
-
};
|
|
25
|
-
const token = await activeToken(run, 15_000);
|
|
26
|
-
if (token === null)
|
|
27
|
-
return {
|
|
28
|
-
id: 'auth:copilot',
|
|
29
|
-
status: 'fail',
|
|
30
|
-
summary:
|
|
31
|
-
'not-signed-in: this node holds no GitHub credential for Copilot CLI to use.',
|
|
32
|
-
remedy: {
|
|
33
|
-
action:
|
|
34
|
-
'Run converge: it signs the node in to GitHub from the stored credential, and Copilot CLI uses that sign-in. No copilot login is needed.',
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
if (CLASSIC.test(token) || !ACCEPTED.test(token))
|
|
38
|
-
return {
|
|
39
|
-
id: 'auth:copilot',
|
|
40
|
-
status: 'fail',
|
|
41
|
-
summary:
|
|
42
|
-
'COPILOT_TOKEN_UNSUPPORTED: the node’s GitHub token is of a kind Copilot CLI refuses (a classic personal access token).',
|
|
43
|
-
remedy: {
|
|
44
|
-
action:
|
|
45
|
-
'Store a fine-grained token with the Copilot Requests permission as github-token and run converge; every node and Copilot CLI then use it.',
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
return {
|
|
49
|
-
id: 'auth:copilot',
|
|
50
|
-
status: 'pass',
|
|
51
|
-
summary:
|
|
52
|
-
'Copilot CLI uses this node’s GitHub sign-in, whose token is of a kind Copilot accepts. Copilot entitlement of the account is not measured here; no prompt was made.',
|
|
53
|
-
};
|
|
54
|
-
}
|
package/src/t3/accounts.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
accountSlug as slug,
|
|
3
|
-
discoverAccounts,
|
|
4
|
-
type Account,
|
|
5
|
-
} from '../agents/accounts';
|
|
6
|
-
import { proxyKey } from '../agents/secrets';
|
|
7
|
-
|
|
8
|
-
export type Roster = () => Promise<Account[]>;
|
|
9
|
-
|
|
10
|
-
/** The accounts signed in on the CLI proxy, read with this node's own key.
|
|
11
|
-
* Throws when the proxy does not answer, so providers are never dropped
|
|
12
|
-
* because the roster was unreadable.
|
|
13
|
-
*/
|
|
14
|
-
export const proxyAccounts: Roster = async () =>
|
|
15
|
-
discoverAccounts(await proxyKey());
|
|
16
|
-
|
|
17
|
-
/** How T3 runs each tool for one account. The launcher pins every request to
|
|
18
|
-
* the account named by WS_AGENT_ACCOUNT; no credential is ever placed here.
|
|
19
|
-
*/
|
|
20
|
-
const TOOLS: Record<
|
|
21
|
-
string,
|
|
22
|
-
{ driver: string; label: string; config: Record<string, string> }
|
|
23
|
-
> = {
|
|
24
|
-
claude: {
|
|
25
|
-
driver: 'claudeAgent',
|
|
26
|
-
label: 'Claude',
|
|
27
|
-
config: {
|
|
28
|
-
binaryPath: '${workspace}/agents/claude-proxy',
|
|
29
|
-
homePath: '${agents}/${node}/claude/account-${account}',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
codex: {
|
|
33
|
-
driver: 'codex',
|
|
34
|
-
label: 'Codex',
|
|
35
|
-
config: {
|
|
36
|
-
binaryPath: '${workspace}/agents/codex-proxy.ts',
|
|
37
|
-
homePath: '${agents}/${node}/codex/account-${account}',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
antigravity: {
|
|
41
|
-
driver: 'antigravity',
|
|
42
|
-
label: 'AntiGravity',
|
|
43
|
-
config: {
|
|
44
|
-
binaryPath: '${workspace}/agents/bin/agy',
|
|
45
|
-
authMethod: 'gemini-api-key',
|
|
46
|
-
// T3 materializes its secret-store slot when it sees its redaction marker.
|
|
47
|
-
apiKey: '••••••',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/** The T3 instance of one account, and the T3 driver that runs its tool. */
|
|
53
|
-
export const accountInstanceId = (account: Account): string =>
|
|
54
|
-
`personal_${slug(account.prefix)}`.slice(0, 64);
|
|
55
|
-
export const accountDriver = (tool: string): string | undefined =>
|
|
56
|
-
TOOLS[tool]?.driver;
|
|
57
|
-
|
|
58
|
-
/** One `<Provider> <account email>` instance per signed-in account, identical
|
|
59
|
-
* on every machine because every machine reads the same proxy.
|
|
60
|
-
*/
|
|
61
|
-
export function accountInstances(
|
|
62
|
-
accounts: Account[],
|
|
63
|
-
variables: Record<string, string>
|
|
64
|
-
): Record<string, unknown> {
|
|
65
|
-
const instances: Record<string, unknown> = {};
|
|
66
|
-
for (const account of accounts) {
|
|
67
|
-
const tool = TOOLS[account.tool];
|
|
68
|
-
if (!tool) continue;
|
|
69
|
-
const values: Record<string, string> = {
|
|
70
|
-
...variables,
|
|
71
|
-
account: slug(account.email),
|
|
72
|
-
};
|
|
73
|
-
instances[accountInstanceId(account)] = {
|
|
74
|
-
driver: tool.driver,
|
|
75
|
-
displayName: `${tool.label} ${account.email}`,
|
|
76
|
-
enabled: true,
|
|
77
|
-
config: Object.fromEntries(
|
|
78
|
-
Object.entries(tool.config).map(([key, value]) => [
|
|
79
|
-
key,
|
|
80
|
-
value.replace(/\$\{(\w+)\}/g, (_, name: string) => values[name]!),
|
|
81
|
-
])
|
|
82
|
-
),
|
|
83
|
-
environment: [
|
|
84
|
-
{ name: 'WS_AGENT_NODE', value: variables['node'], sensitive: false },
|
|
85
|
-
{ name: 'WS_AGENT_ACCOUNT', value: account.email, sensitive: false },
|
|
86
|
-
],
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return instances;
|
|
90
|
-
}
|
package/src/t3/antigravity.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { Check, Runner } from '../types';
|
|
2
|
-
import { record } from '../config';
|
|
3
|
-
import { runCommand } from '../runner';
|
|
4
|
-
import { localRpc, missingT3Cli, type T3Transport } from './local-rpc';
|
|
5
|
-
|
|
6
|
-
/** An explicit model refresh opens a disposable ACP session using this
|
|
7
|
-
* instance's launcher, and publishes its sign-in status in T3 Settings. */
|
|
8
|
-
export async function refreshAntigravity(
|
|
9
|
-
id: string,
|
|
10
|
-
home?: string,
|
|
11
|
-
options: { run?: Runner; transport?: T3Transport } = {}
|
|
12
|
-
) {
|
|
13
|
-
const reply = await localRpc(
|
|
14
|
-
options.run ?? runCommand,
|
|
15
|
-
{
|
|
16
|
-
tag: 'server.refreshProviders',
|
|
17
|
-
payload: { instanceId: id, refreshModels: true, reloadSecrets: true },
|
|
18
|
-
},
|
|
19
|
-
[
|
|
20
|
-
'--scope',
|
|
21
|
-
'orchestration:read',
|
|
22
|
-
'--ttl',
|
|
23
|
-
'2m',
|
|
24
|
-
'--label',
|
|
25
|
-
'homelab provider check',
|
|
26
|
-
],
|
|
27
|
-
{
|
|
28
|
-
...(home ? { home } : {}),
|
|
29
|
-
...(options.transport ? { transport: options.transport } : {}),
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
if (reply === missingT3Cli) return missingT3Cli;
|
|
33
|
-
if (!record(reply) || reply['_tag'] !== 'Exit') return false;
|
|
34
|
-
const exit = reply['exit'];
|
|
35
|
-
if (!record(exit) || exit['_tag'] !== 'Success' || !record(exit['value']))
|
|
36
|
-
return false;
|
|
37
|
-
const providers = exit['value']['providers'];
|
|
38
|
-
return (
|
|
39
|
-
Array.isArray(providers) &&
|
|
40
|
-
providers.some(
|
|
41
|
-
(provider: unknown) =>
|
|
42
|
-
record(provider) &&
|
|
43
|
-
provider['instanceId'] === id &&
|
|
44
|
-
provider['enabled'] === true &&
|
|
45
|
-
provider['installed'] === true &&
|
|
46
|
-
provider['status'] === 'ready' &&
|
|
47
|
-
record(provider['auth']) &&
|
|
48
|
-
provider['auth']['status'] === 'authenticated'
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export async function checkedProviders(
|
|
54
|
-
instances: Record<string, unknown>,
|
|
55
|
-
home?: string,
|
|
56
|
-
refresh = refreshAntigravity
|
|
57
|
-
): Promise<Check> {
|
|
58
|
-
const managed = Object.entries(instances).filter(
|
|
59
|
-
([, instance]) => record(instance) && instance['driver'] === 'antigravity'
|
|
60
|
-
);
|
|
61
|
-
const failed: number[] = [];
|
|
62
|
-
for (const [index, [instanceId]] of managed.entries()) {
|
|
63
|
-
const result = await refresh(instanceId, home);
|
|
64
|
-
if (result === missingT3Cli)
|
|
65
|
-
return {
|
|
66
|
-
id: 't3:providers',
|
|
67
|
-
status: 'fail',
|
|
68
|
-
summary: 'T3_CLI_MISSING',
|
|
69
|
-
remedy: {
|
|
70
|
-
action:
|
|
71
|
-
'Restore the T3 CLI in the user installation or on the converge PATH, then rerun converge.',
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
if (!result) failed.push(index + 1);
|
|
75
|
-
}
|
|
76
|
-
if (failed.length)
|
|
77
|
-
return {
|
|
78
|
-
id: 't3:providers',
|
|
79
|
-
status: 'fail',
|
|
80
|
-
summary: `T3_ANTIGRAVITY_SESSION_UNVERIFIED: account positions ${failed.join(', ')} of ${managed.length}.`,
|
|
81
|
-
remedy: {
|
|
82
|
-
action:
|
|
83
|
-
'Open T3 Settings > Providers on this machine and refresh the affected Antigravity instances. Check their account-specific proxy sessions and rerun converge.',
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
return {
|
|
87
|
-
id: 't3:providers',
|
|
88
|
-
status: 'pass',
|
|
89
|
-
summary: managed.length
|
|
90
|
-
? `T3 reconciled its managed providers and authenticated all ${managed.length} Antigravity account sessions.`
|
|
91
|
-
: 'T3 on this machine offers exactly the managed provider instances every machine gets.',
|
|
92
|
-
};
|
|
93
|
-
}
|