@forgezero/agent 0.1.24 → 0.1.25
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/cli/agent-install.d.ts +1 -0
- package/dist/fz-agent.js +25 -8
- package/dist/fz.js +11 -2
- package/dist/guest-enrolment.d.ts +2 -0
- package/dist/guest-enrolment.js +1 -0
- package/dist/lifecycle-helper.d.ts +3 -3
- package/dist/lifecycle-helper.js +21 -7
- package/dist/migration-pull.d.ts +2 -0
- package/dist/provision.d.ts +2 -0
- package/dist/provision.js +9 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -70,6 +70,7 @@ export interface InstallOptions {
|
|
|
70
70
|
enrolTokenCredentialPath?: string;
|
|
71
71
|
enrolStatePath?: string;
|
|
72
72
|
nodeLabel?: string;
|
|
73
|
+
nodeHostname?: string;
|
|
73
74
|
}
|
|
74
75
|
export declare function planInstall(options: InstallOptions): ProvisionPlan;
|
|
75
76
|
/** Execute the same ordered plan the control plane executes over SSH. */
|
package/dist/fz-agent.js
CHANGED
|
@@ -1225,6 +1225,7 @@ async function enrolGuestIdentity(options) {
|
|
|
1225
1225
|
label: options.label,
|
|
1226
1226
|
gitDeployPublicKey: options.gitDeployPublicKey,
|
|
1227
1227
|
privateNetworkAttachment: options.privateNetworkAttachment,
|
|
1228
|
+
edgeHostname: options.edgeHostname?.trim() || undefined,
|
|
1228
1229
|
publicKeys: {
|
|
1229
1230
|
ed25519: options.keys.ed25519.publicKey,
|
|
1230
1231
|
mlDsa: options.keys.mlDsa.publicKey
|
|
@@ -2717,17 +2718,23 @@ function validateLifecycleProfile(profile) {
|
|
|
2717
2718
|
if (!Array.isArray(profile.apiUnits) || profile.apiUnits.length < 1 || profile.apiUnits.some((unit) => !unitPattern.test(unit))) {
|
|
2718
2719
|
throw new Error("lifecycle profile needs one or more valid API service units");
|
|
2719
2720
|
}
|
|
2720
|
-
|
|
2721
|
+
const databaseValues = [profile.databaseUnit, profile.databaseHealthUrl, profile.databasePorts];
|
|
2722
|
+
if (databaseValues.some((value) => value !== undefined) && databaseValues.some((value) => value === undefined)) {
|
|
2723
|
+
throw new Error("database lifecycle settings must be supplied together");
|
|
2724
|
+
}
|
|
2725
|
+
if (profile.databaseUnit && !unitPattern.test(profile.databaseUnit))
|
|
2721
2726
|
throw new Error("lifecycle profile database unit is invalid");
|
|
2722
2727
|
const apiUrl = new URL(profile.apiHealthUrl);
|
|
2723
2728
|
if (apiUrl.protocol !== "http:" || !["127.0.0.1", "[::1]", "::1", "localhost"].includes(apiUrl.hostname)) {
|
|
2724
2729
|
throw new Error("API health URL must be loopback HTTP");
|
|
2725
2730
|
}
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2731
|
+
if (profile.databaseHealthUrl) {
|
|
2732
|
+
const databaseUrl = new URL(profile.databaseHealthUrl);
|
|
2733
|
+
if (databaseUrl.protocol !== "http:" || !(["127.0.0.1", "[::1]", "::1", "localhost"].includes(databaseUrl.hostname) || privateIp(databaseUrl.hostname))) {
|
|
2734
|
+
throw new Error("database health URL must be loopback or private HTTP");
|
|
2735
|
+
}
|
|
2729
2736
|
}
|
|
2730
|
-
if (!Array.isArray(profile.databasePorts) || profile.databasePorts.length < 1 || profile.databasePorts.some((port) => !Number.isInteger(port) || port < 1 || port > 65535)) {
|
|
2737
|
+
if (profile.databasePorts && (!Array.isArray(profile.databasePorts) || profile.databasePorts.length < 1 || profile.databasePorts.some((port) => !Number.isInteger(port) || port < 1 || port > 65535))) {
|
|
2731
2738
|
throw new Error("lifecycle profile database ports are invalid");
|
|
2732
2739
|
}
|
|
2733
2740
|
}
|
|
@@ -2786,7 +2793,7 @@ async function executeLifecycleAction(profile, claim, exec = spawnLifecycleComma
|
|
|
2786
2793
|
throw new Error("WARP is not connected");
|
|
2787
2794
|
}
|
|
2788
2795
|
for (const address of claim.peerPrivateAddresses) {
|
|
2789
|
-
for (const port of profile.databasePorts)
|
|
2796
|
+
for (const port of profile.databasePorts ?? [])
|
|
2790
2797
|
await tcpProbe(address, port);
|
|
2791
2798
|
}
|
|
2792
2799
|
return {
|
|
@@ -2796,6 +2803,9 @@ async function executeLifecycleAction(profile, claim, exec = spawnLifecycleComma
|
|
|
2796
2803
|
};
|
|
2797
2804
|
}
|
|
2798
2805
|
case "database-member-ready": {
|
|
2806
|
+
if (!profile.databaseUnit || !profile.databaseHealthUrl) {
|
|
2807
|
+
throw new Error("this workload has no controller-managed database lifecycle");
|
|
2808
|
+
}
|
|
2799
2809
|
await requireSuccess(exec, ["/usr/bin/systemctl", "is-active", profile.databaseUnit], "database service check");
|
|
2800
2810
|
const response = await fetcher(profile.databaseHealthUrl, { signal: AbortSignal.timeout(5000) });
|
|
2801
2811
|
if (!response.ok && response.status !== 401)
|
|
@@ -2812,7 +2822,12 @@ async function executeLifecycleAction(profile, claim, exec = spawnLifecycleComma
|
|
|
2812
2822
|
await requireSuccess(exec, ["/usr/bin/systemctl", "stop", ...profile.apiUnits], "API drain");
|
|
2813
2823
|
return { sourceDrained: true };
|
|
2814
2824
|
case "source-stopped":
|
|
2815
|
-
await requireSuccess(exec, [
|
|
2825
|
+
await requireSuccess(exec, [
|
|
2826
|
+
"/usr/bin/systemctl",
|
|
2827
|
+
"stop",
|
|
2828
|
+
...profile.apiUnits,
|
|
2829
|
+
...profile.databaseUnit ? [profile.databaseUnit] : []
|
|
2830
|
+
], "source retirement");
|
|
2816
2831
|
return { sourceStopped: true };
|
|
2817
2832
|
default:
|
|
2818
2833
|
throw new Error("unknown lifecycle action");
|
|
@@ -2940,7 +2955,7 @@ function materializeWarpMdm(options) {
|
|
|
2940
2955
|
}
|
|
2941
2956
|
|
|
2942
2957
|
// src/version.ts
|
|
2943
|
-
var VERSION = "0.1.
|
|
2958
|
+
var VERSION = "0.1.25";
|
|
2944
2959
|
|
|
2945
2960
|
// src/index.ts
|
|
2946
2961
|
function loadOrCreateSeed(path) {
|
|
@@ -3083,6 +3098,7 @@ if (import.meta.main) {
|
|
|
3083
3098
|
nodeKey: nodeKey2,
|
|
3084
3099
|
keys: keys2,
|
|
3085
3100
|
label: process.env.FZ_NODE_LABEL,
|
|
3101
|
+
edgeHostname: process.env.FZ_NODE_HOSTNAME,
|
|
3086
3102
|
gitDeployPublicKey: process.env.FZ_GIT_PUBLIC_KEY_FILE ? readFileSync5(process.env.FZ_GIT_PUBLIC_KEY_FILE, "utf8").trim() : undefined,
|
|
3087
3103
|
privateNetworkAttachment: privateNetworkAttachmentFromEnvironment()
|
|
3088
3104
|
});
|
|
@@ -3302,6 +3318,7 @@ if (import.meta.main) {
|
|
|
3302
3318
|
nodeKey,
|
|
3303
3319
|
keys,
|
|
3304
3320
|
label: process.env.FZ_NODE_LABEL,
|
|
3321
|
+
edgeHostname: process.env.FZ_NODE_HOSTNAME,
|
|
3305
3322
|
gitDeployPublicKey: process.env.FZ_GIT_PUBLIC_KEY_FILE ? readFileSync5(process.env.FZ_GIT_PUBLIC_KEY_FILE, "utf8").trim() : undefined,
|
|
3306
3323
|
privateNetworkAttachment: privateNetworkAttachmentFromEnvironment()
|
|
3307
3324
|
});
|
package/dist/fz.js
CHANGED
|
@@ -163,6 +163,7 @@ var systemdPath = (value, label) => {
|
|
|
163
163
|
throw new Error(`invalid ${label} path`);
|
|
164
164
|
return value;
|
|
165
165
|
};
|
|
166
|
+
var validNodeHostname = (value) => !value || value.length <= 253 && value === value.toLowerCase() && value.split(".").length >= 3 && value.split(".").every((label) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label));
|
|
166
167
|
function warpConfigUnit(options) {
|
|
167
168
|
if (!options.warpOrganization || !/^[a-z0-9][a-z0-9-]{0,62}$/i.test(options.warpOrganization)) {
|
|
168
169
|
throw new Error("WARP organization is invalid");
|
|
@@ -252,10 +253,14 @@ function agentEnrolmentUnit(options) {
|
|
|
252
253
|
if (!options.apiUrl || !options.enrolTokenCredentialPath || !options.enrolStatePath) {
|
|
253
254
|
throw new Error("direct enrolment needs API, credential and state paths");
|
|
254
255
|
}
|
|
256
|
+
if (!validNodeHostname(options.nodeHostname))
|
|
257
|
+
throw new Error("node hostname is invalid");
|
|
255
258
|
const bin = options.binPath ?? "fz-agent";
|
|
256
259
|
const user = options.user ?? "forgezero";
|
|
257
260
|
const seedCredentialPath = options.seedCredentialPath ?? "/etc/forgezero/creds/agent-seed.cred";
|
|
258
261
|
const label = options.nodeLabel ? `Environment=FZ_NODE_LABEL=${options.nodeLabel}
|
|
262
|
+
` : "";
|
|
263
|
+
const hostname = options.nodeHostname ? `Environment=FZ_NODE_HOSTNAME=${options.nodeHostname}
|
|
259
264
|
` : "";
|
|
260
265
|
const gitPublicKey = options.gitPublicKeyPath ? `Environment=FZ_GIT_PUBLIC_KEY_FILE=${options.gitPublicKeyPath}
|
|
261
266
|
` : "";
|
|
@@ -287,7 +292,7 @@ Environment=FZ_SEED_CREDENTIAL=agent-seed
|
|
|
287
292
|
Environment=FZ_ENROL_TOKEN_CREDENTIAL=enrol-token
|
|
288
293
|
Environment=FZ_ENROL_STATE_FILE=${options.enrolStatePath}
|
|
289
294
|
Environment=FZ_API=${options.apiUrl}
|
|
290
|
-
${label}${gitPublicKey}${networkAttachment}ExecStart=${bin} enrol
|
|
295
|
+
${label}${hostname}${gitPublicKey}${networkAttachment}ExecStart=${bin} enrol
|
|
291
296
|
# A '+' fixed command runs as root solely to remove the host-bound one-time
|
|
292
297
|
# ciphertext. Tenant code and the agent never receive a privilege boundary.
|
|
293
298
|
ExecStartPost=+/usr/bin/rm -f ${options.enrolTokenCredentialPath}
|
|
@@ -346,6 +351,8 @@ WantedBy=multi-user.target
|
|
|
346
351
|
`;
|
|
347
352
|
}
|
|
348
353
|
function agentUnit(options) {
|
|
354
|
+
if (!validNodeHostname(options.nodeHostname))
|
|
355
|
+
throw new Error("node hostname is invalid");
|
|
349
356
|
const bin = options.binPath ?? "fz-agent";
|
|
350
357
|
const user = options.user ?? "forgezero";
|
|
351
358
|
const seedCredentialPath = options.seedCredentialPath ?? "/etc/forgezero/creds/agent-seed.cred";
|
|
@@ -403,6 +410,7 @@ function agentUnit(options) {
|
|
|
403
410
|
options.environment ? `FZ_ENVIRONMENT=${options.environment}` : null,
|
|
404
411
|
options.enrolStatePath ? `FZ_ENROL_STATE_FILE=${options.enrolStatePath}` : null,
|
|
405
412
|
options.nodeLabel ? `FZ_NODE_LABEL=${options.nodeLabel}` : null,
|
|
413
|
+
options.nodeHostname ? `FZ_NODE_HOSTNAME=${options.nodeHostname}` : null,
|
|
406
414
|
options.gitPublicKeyPath ? `FZ_GIT_PUBLIC_KEY_FILE=${options.gitPublicKeyPath}` : null,
|
|
407
415
|
options.repository ? `FZ_DEPLOY_REPO=${options.repository}` : null,
|
|
408
416
|
options.branch ? `FZ_DEPLOY_BRANCH=${options.branch}` : null,
|
|
@@ -966,7 +974,7 @@ async function resolveIdentity(selector, socketPath) {
|
|
|
966
974
|
}
|
|
967
975
|
|
|
968
976
|
// src/version.ts
|
|
969
|
-
var VERSION = "0.1.
|
|
977
|
+
var VERSION = "0.1.25";
|
|
970
978
|
|
|
971
979
|
// src/cli/index.ts
|
|
972
980
|
var DEFAULT_MODE = THRESHOLD_MODES[0].id;
|
|
@@ -1205,6 +1213,7 @@ async function cmdAgent(options, args) {
|
|
|
1205
1213
|
enrolTokenCredentialPath,
|
|
1206
1214
|
enrolStatePath,
|
|
1207
1215
|
nodeLabel: process.env.FZ_NODE_LABEL,
|
|
1216
|
+
nodeHostname: process.env.FZ_NODE_HOSTNAME,
|
|
1208
1217
|
deployRoot: process.env.FZ_DEPLOY_ROOT ?? "/opt/forgezero"
|
|
1209
1218
|
} : {},
|
|
1210
1219
|
binPath: process.env.FZ_AGENT_BIN ?? "/usr/local/lib/forgezero/agent/fz-agent",
|
|
@@ -30,6 +30,8 @@ export interface GuestEnrolmentOptions {
|
|
|
30
30
|
label?: string;
|
|
31
31
|
gitDeployPublicKey?: string;
|
|
32
32
|
privateNetworkAttachment?: GuestPrivateNetworkAttachment;
|
|
33
|
+
/** Stable API ingress identity; signed with the rest of the enrolment body. */
|
|
34
|
+
edgeHostname?: string;
|
|
33
35
|
fetch?: (input: URL, init: RequestInit) => Promise<Response>;
|
|
34
36
|
requestTimeoutMs?: number;
|
|
35
37
|
}
|
package/dist/guest-enrolment.js
CHANGED
|
@@ -135,6 +135,7 @@ async function enrolGuestIdentity(options) {
|
|
|
135
135
|
label: options.label,
|
|
136
136
|
gitDeployPublicKey: options.gitDeployPublicKey,
|
|
137
137
|
privateNetworkAttachment: options.privateNetworkAttachment,
|
|
138
|
+
edgeHostname: options.edgeHostname?.trim() || undefined,
|
|
138
139
|
publicKeys: {
|
|
139
140
|
ed25519: options.keys.ed25519.publicKey,
|
|
140
141
|
mlDsa: options.keys.mlDsa.publicKey
|
|
@@ -5,13 +5,13 @@ export interface LifecycleProfile {
|
|
|
5
5
|
/** Root-owned systemd units whose normal stop path performs application drain. */
|
|
6
6
|
apiUnits: readonly string[];
|
|
7
7
|
/** Root-owned database service stopped only at the final retirement stage. */
|
|
8
|
-
databaseUnit
|
|
8
|
+
databaseUnit?: string;
|
|
9
9
|
/** Loopback health endpoint for the API on this compute. */
|
|
10
10
|
apiHealthUrl: string;
|
|
11
11
|
/** Loopback health endpoint for the database member on this compute. */
|
|
12
|
-
databaseHealthUrl
|
|
12
|
+
databaseHealthUrl?: string;
|
|
13
13
|
/** Ports that must be reachable on every signed controller-provided private peer. */
|
|
14
|
-
databasePorts
|
|
14
|
+
databasePorts?: readonly number[];
|
|
15
15
|
}
|
|
16
16
|
export interface LifecycleCommandResult {
|
|
17
17
|
exitCode: number;
|
package/dist/lifecycle-helper.js
CHANGED
|
@@ -22,17 +22,23 @@ function validateLifecycleProfile(profile) {
|
|
|
22
22
|
if (!Array.isArray(profile.apiUnits) || profile.apiUnits.length < 1 || profile.apiUnits.some((unit) => !unitPattern.test(unit))) {
|
|
23
23
|
throw new Error("lifecycle profile needs one or more valid API service units");
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
const databaseValues = [profile.databaseUnit, profile.databaseHealthUrl, profile.databasePorts];
|
|
26
|
+
if (databaseValues.some((value) => value !== undefined) && databaseValues.some((value) => value === undefined)) {
|
|
27
|
+
throw new Error("database lifecycle settings must be supplied together");
|
|
28
|
+
}
|
|
29
|
+
if (profile.databaseUnit && !unitPattern.test(profile.databaseUnit))
|
|
26
30
|
throw new Error("lifecycle profile database unit is invalid");
|
|
27
31
|
const apiUrl = new URL(profile.apiHealthUrl);
|
|
28
32
|
if (apiUrl.protocol !== "http:" || !["127.0.0.1", "[::1]", "::1", "localhost"].includes(apiUrl.hostname)) {
|
|
29
33
|
throw new Error("API health URL must be loopback HTTP");
|
|
30
34
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
if (profile.databaseHealthUrl) {
|
|
36
|
+
const databaseUrl = new URL(profile.databaseHealthUrl);
|
|
37
|
+
if (databaseUrl.protocol !== "http:" || !(["127.0.0.1", "[::1]", "::1", "localhost"].includes(databaseUrl.hostname) || privateIp(databaseUrl.hostname))) {
|
|
38
|
+
throw new Error("database health URL must be loopback or private HTTP");
|
|
39
|
+
}
|
|
34
40
|
}
|
|
35
|
-
if (!Array.isArray(profile.databasePorts) || profile.databasePorts.length < 1 || profile.databasePorts.some((port) => !Number.isInteger(port) || port < 1 || port > 65535)) {
|
|
41
|
+
if (profile.databasePorts && (!Array.isArray(profile.databasePorts) || profile.databasePorts.length < 1 || profile.databasePorts.some((port) => !Number.isInteger(port) || port < 1 || port > 65535))) {
|
|
36
42
|
throw new Error("lifecycle profile database ports are invalid");
|
|
37
43
|
}
|
|
38
44
|
}
|
|
@@ -91,7 +97,7 @@ async function executeLifecycleAction(profile, claim, exec = spawnLifecycleComma
|
|
|
91
97
|
throw new Error("WARP is not connected");
|
|
92
98
|
}
|
|
93
99
|
for (const address of claim.peerPrivateAddresses) {
|
|
94
|
-
for (const port of profile.databasePorts)
|
|
100
|
+
for (const port of profile.databasePorts ?? [])
|
|
95
101
|
await tcpProbe(address, port);
|
|
96
102
|
}
|
|
97
103
|
return {
|
|
@@ -101,6 +107,9 @@ async function executeLifecycleAction(profile, claim, exec = spawnLifecycleComma
|
|
|
101
107
|
};
|
|
102
108
|
}
|
|
103
109
|
case "database-member-ready": {
|
|
110
|
+
if (!profile.databaseUnit || !profile.databaseHealthUrl) {
|
|
111
|
+
throw new Error("this workload has no controller-managed database lifecycle");
|
|
112
|
+
}
|
|
104
113
|
await requireSuccess(exec, ["/usr/bin/systemctl", "is-active", profile.databaseUnit], "database service check");
|
|
105
114
|
const response = await fetcher(profile.databaseHealthUrl, { signal: AbortSignal.timeout(5000) });
|
|
106
115
|
if (!response.ok && response.status !== 401)
|
|
@@ -117,7 +126,12 @@ async function executeLifecycleAction(profile, claim, exec = spawnLifecycleComma
|
|
|
117
126
|
await requireSuccess(exec, ["/usr/bin/systemctl", "stop", ...profile.apiUnits], "API drain");
|
|
118
127
|
return { sourceDrained: true };
|
|
119
128
|
case "source-stopped":
|
|
120
|
-
await requireSuccess(exec, [
|
|
129
|
+
await requireSuccess(exec, [
|
|
130
|
+
"/usr/bin/systemctl",
|
|
131
|
+
"stop",
|
|
132
|
+
...profile.apiUnits,
|
|
133
|
+
...profile.databaseUnit ? [profile.databaseUnit] : []
|
|
134
|
+
], "source retirement");
|
|
121
135
|
return { sourceStopped: true };
|
|
122
136
|
default:
|
|
123
137
|
throw new Error("unknown lifecycle action");
|
package/dist/migration-pull.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NodeKeyPair } from '@forgezero/runtime/identity';
|
|
2
2
|
export type MigrationNetwork = 'private-lan' | 'cloudflare-warp';
|
|
3
|
+
export type MigrationEvidenceProfile = 'forgezero-platform' | 'tenant-managed';
|
|
3
4
|
export type MigrationAction = 'network-ready' | 'database-member-ready' | 'api-ready' | 'source-drained' | 'source-stopped';
|
|
4
5
|
export interface MigrationEvidence {
|
|
5
6
|
targetAgentReady?: boolean;
|
|
@@ -14,6 +15,7 @@ export interface RemoteMigrationClaim {
|
|
|
14
15
|
migrationKey: string;
|
|
15
16
|
action: MigrationAction;
|
|
16
17
|
network: MigrationNetwork;
|
|
18
|
+
evidenceProfile?: MigrationEvidenceProfile;
|
|
17
19
|
claimToken: string;
|
|
18
20
|
claimExpiresAtTs: number;
|
|
19
21
|
attempt: number;
|
package/dist/provision.d.ts
CHANGED
|
@@ -119,6 +119,8 @@ export interface UnitOptions {
|
|
|
119
119
|
enrolTokenCredentialPath?: string;
|
|
120
120
|
enrolStatePath?: string;
|
|
121
121
|
nodeLabel?: string;
|
|
122
|
+
/** Stable API ingress identity bound by the signed one-time enrolment. */
|
|
123
|
+
nodeHostname?: string;
|
|
122
124
|
}
|
|
123
125
|
export declare const DEPLOYMENT_RUNNER_USER = "forgezero-runner";
|
|
124
126
|
export declare const DEPLOYMENT_GROUP = "forgezero-deploy";
|
package/dist/provision.js
CHANGED
|
@@ -55,6 +55,7 @@ var systemdPath = (value, label) => {
|
|
|
55
55
|
throw new Error(`invalid ${label} path`);
|
|
56
56
|
return value;
|
|
57
57
|
};
|
|
58
|
+
var validNodeHostname = (value) => !value || value.length <= 253 && value === value.toLowerCase() && value.split(".").length >= 3 && value.split(".").every((label) => /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label));
|
|
58
59
|
function warpConfigUnit(options) {
|
|
59
60
|
if (!options.warpOrganization || !/^[a-z0-9][a-z0-9-]{0,62}$/i.test(options.warpOrganization)) {
|
|
60
61
|
throw new Error("WARP organization is invalid");
|
|
@@ -144,10 +145,14 @@ function agentEnrolmentUnit(options) {
|
|
|
144
145
|
if (!options.apiUrl || !options.enrolTokenCredentialPath || !options.enrolStatePath) {
|
|
145
146
|
throw new Error("direct enrolment needs API, credential and state paths");
|
|
146
147
|
}
|
|
148
|
+
if (!validNodeHostname(options.nodeHostname))
|
|
149
|
+
throw new Error("node hostname is invalid");
|
|
147
150
|
const bin = options.binPath ?? "fz-agent";
|
|
148
151
|
const user = options.user ?? "forgezero";
|
|
149
152
|
const seedCredentialPath = options.seedCredentialPath ?? "/etc/forgezero/creds/agent-seed.cred";
|
|
150
153
|
const label = options.nodeLabel ? `Environment=FZ_NODE_LABEL=${options.nodeLabel}
|
|
154
|
+
` : "";
|
|
155
|
+
const hostname = options.nodeHostname ? `Environment=FZ_NODE_HOSTNAME=${options.nodeHostname}
|
|
151
156
|
` : "";
|
|
152
157
|
const gitPublicKey = options.gitPublicKeyPath ? `Environment=FZ_GIT_PUBLIC_KEY_FILE=${options.gitPublicKeyPath}
|
|
153
158
|
` : "";
|
|
@@ -179,7 +184,7 @@ Environment=FZ_SEED_CREDENTIAL=agent-seed
|
|
|
179
184
|
Environment=FZ_ENROL_TOKEN_CREDENTIAL=enrol-token
|
|
180
185
|
Environment=FZ_ENROL_STATE_FILE=${options.enrolStatePath}
|
|
181
186
|
Environment=FZ_API=${options.apiUrl}
|
|
182
|
-
${label}${gitPublicKey}${networkAttachment}ExecStart=${bin} enrol
|
|
187
|
+
${label}${hostname}${gitPublicKey}${networkAttachment}ExecStart=${bin} enrol
|
|
183
188
|
# A '+' fixed command runs as root solely to remove the host-bound one-time
|
|
184
189
|
# ciphertext. Tenant code and the agent never receive a privilege boundary.
|
|
185
190
|
ExecStartPost=+/usr/bin/rm -f ${options.enrolTokenCredentialPath}
|
|
@@ -238,6 +243,8 @@ WantedBy=multi-user.target
|
|
|
238
243
|
`;
|
|
239
244
|
}
|
|
240
245
|
function agentUnit(options) {
|
|
246
|
+
if (!validNodeHostname(options.nodeHostname))
|
|
247
|
+
throw new Error("node hostname is invalid");
|
|
241
248
|
const bin = options.binPath ?? "fz-agent";
|
|
242
249
|
const user = options.user ?? "forgezero";
|
|
243
250
|
const seedCredentialPath = options.seedCredentialPath ?? "/etc/forgezero/creds/agent-seed.cred";
|
|
@@ -295,6 +302,7 @@ function agentUnit(options) {
|
|
|
295
302
|
options.environment ? `FZ_ENVIRONMENT=${options.environment}` : null,
|
|
296
303
|
options.enrolStatePath ? `FZ_ENROL_STATE_FILE=${options.enrolStatePath}` : null,
|
|
297
304
|
options.nodeLabel ? `FZ_NODE_LABEL=${options.nodeLabel}` : null,
|
|
305
|
+
options.nodeHostname ? `FZ_NODE_HOSTNAME=${options.nodeHostname}` : null,
|
|
298
306
|
options.gitPublicKeyPath ? `FZ_GIT_PUBLIC_KEY_FILE=${options.gitPublicKeyPath}` : null,
|
|
299
307
|
options.repository ? `FZ_DEPLOY_REPO=${options.repository}` : null,
|
|
300
308
|
options.branch ? `FZ_DEPLOY_BRANCH=${options.branch}` : null,
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** One package version shared by both public binaries. Pinned to package.json by tests. */
|
|
2
|
-
export declare const VERSION = "0.1.
|
|
2
|
+
export declare const VERSION = "0.1.25";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"//": "Publishing happens from an operator's machine, not CI \u2014 CLAUDE.md records that the absence of CI is deliberate. npm's `provenance` attests a tarball was built by a recognised CI provider from a named commit, so it cannot be produced here: it was set, and the first publish failed with `Automatic provenance generation not supported for provider: null`. A setting that can never be satisfied is worse than none, because it reads as a guarantee nobody is getting. Restore it the day this publishes from CI, and not before.",
|
|
3
3
|
"name": "@forgezero/agent",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.25",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"check": "tsc --noEmit",
|