@forgezero/agent 0.1.39 → 0.1.40

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.
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env bun
2
- import { type AgentIdentity } from '@forgezero/runtime/ssh-agent';
3
2
  /**
4
3
  * What every CLI request carries.
5
4
  *
@@ -9,7 +8,6 @@ import { type AgentIdentity } from '@forgezero/runtime/ssh-agent';
9
8
  * notice. A header nobody can see is a header nobody maintains.
10
9
  */
11
10
  export declare function requestHeaders(apiBase: string, cookie: string | null): Record<string, string>;
12
- export declare function useCustodyIdentity(identity: AgentIdentity, socketPath?: string): void;
13
11
  export declare function safeApiPath(value: string): string;
14
12
  export declare function targetCoordinate(value: string): {
15
13
  computeReference: string;
@@ -1,19 +1,9 @@
1
- import { type CloudflareAccessCredentials, type CloudflareAccountRuntimeToken, type CloudflareApiTokens } from './cloudflare-edge';
1
+ import { type CloudflareApiTokens } from './cloudflare-edge';
2
2
  export interface CloudflareBootstrapNodeCoordinates {
3
3
  nodeName: string;
4
4
  hostname: string;
5
5
  service: string;
6
6
  tunnelName: string;
7
- applicationName: string;
8
- /** Present only on DB nodes that publish an exact private host route. */
9
- privateAddress?: string;
10
- }
11
- export interface CloudflarePrivateNetworkCoordinates {
12
- warpOrganization: string;
13
- virtualNetworkName: string;
14
- deviceProfileName: string;
15
- enrollmentApplicationName: string;
16
- deviceProfilePrecedence?: number;
17
7
  }
18
8
  export interface CloudflareBootstrapCoordinates {
19
9
  accountId: string;
@@ -22,88 +12,49 @@ export interface CloudflareBootstrapCoordinates {
22
12
  hostname: string;
23
13
  service: string;
24
14
  tunnelName: string;
25
- kvNamespaceTitle: string;
26
- workerScriptName: string;
27
- serviceTokenName: string;
28
- policyName: string;
29
- applicationName: string;
30
- workerDirectory: string;
31
- workerMain: string;
32
- workerCompatibilityDate: string;
33
- publicDomains: string[];
34
- createRuntimeTokens: boolean;
35
- createPrivateNetworkRuntimeToken: boolean;
36
- runtimeTokenNamePrefix: string;
15
+ /** Existing namespace bound to the separately deployed Worker. */
16
+ kvNamespaceId: string;
37
17
  nodes?: CloudflareBootstrapNodeCoordinates[];
38
- privateNetwork?: CloudflarePrivateNetworkCoordinates;
39
18
  }
40
19
  export interface CloudflareBootstrapTokenFiles {
20
+ /** One owner-supplied token with Tunnel Write, DNS Write and KV Write. */
41
21
  apiTokenFile?: string;
22
+ /** Recommended bootstrap token: Tunnel Write + DNS Write. */
23
+ managementApiTokenFile?: string;
24
+ /** Recommended normal-runtime token: Workers KV Storage Write. */
25
+ runtimeApiTokenFile?: string;
26
+ /** Optional split management/runtime tokens. */
42
27
  tunnelApiTokenFile?: string;
43
28
  dnsApiTokenFile?: string;
44
29
  kvApiTokenFile?: string;
45
- accessApiTokenFile?: string;
46
- workerApiTokenFile?: string;
30
+ }
31
+ interface CloudflareBootstrapNodeResource extends CloudflareBootstrapNodeCoordinates {
32
+ tunnelId: string;
33
+ connectorToken: string;
47
34
  }
48
35
  interface CloudflareBootstrapResources {
36
+ /** First-node compatibility fields. */
49
37
  tunnelId: string;
50
38
  kvNamespaceId: string;
51
39
  hostname: string;
52
40
  service: string;
53
41
  connectorToken: string;
54
- access?: CloudflareAccessCredentials & {
55
- policyId?: string;
56
- applicationId?: string;
57
- };
58
- nodes: Array<{
59
- nodeName: string;
60
- hostname: string;
61
- service: string;
62
- tunnelName: string;
63
- tunnelId: string;
64
- connectorToken: string;
65
- applicationId?: string;
66
- }>;
67
- worker?: {
68
- scriptName: string;
69
- publicDomains: string[];
70
- deployed: true;
71
- };
72
- runtimeTokens?: {
73
- kv: CloudflareAccountRuntimeToken;
74
- privateNetwork?: CloudflareAccountRuntimeToken;
75
- };
76
- privateNetwork?: {
77
- warpOrganization: string;
78
- virtualNetworkId: string;
79
- deviceProfileId: string;
80
- enrollmentApplicationId: string;
81
- routes: Array<{
82
- nodeName: string;
83
- routeId: string;
84
- privateAddress: string;
85
- }>;
86
- };
42
+ /** Owner-supplied Workers KV Storage Write token, sealed into each host handoff. */
43
+ kvRuntimeToken: string;
44
+ nodes: CloudflareBootstrapNodeResource[];
87
45
  }
88
46
  export interface CloudflareBootstrapOutput {
89
47
  format: 1;
90
48
  kind: 'forgezero-cloudflare-bootstrap';
91
- phase: 'edge-resources-provisioned' | 'runtime-tokens-created' | 'worker-deployed' | 'access-token-provisioned' | 'complete';
49
+ phase: 'edge-resources-provisioned' | 'complete';
92
50
  updatedAt: string;
93
51
  coordinates: CloudflareBootstrapCoordinates;
94
52
  resources: CloudflareBootstrapResources;
95
53
  created?: {
96
54
  tunnel: boolean;
97
- kvNamespace: boolean;
98
- serviceToken: boolean;
99
- policy: boolean;
100
- application: boolean;
101
- privateNetwork: boolean;
102
- workerDeployed: true;
103
55
  nodes: Array<{
104
56
  nodeName: string;
105
57
  tunnel: boolean;
106
- application: boolean;
107
58
  }>;
108
59
  };
109
60
  }
@@ -116,12 +67,6 @@ export interface CloudflareBootstrapPlan {
116
67
  operations: readonly string[];
117
68
  secrets: readonly string[];
118
69
  }
119
- /**
120
- * The published `fz bootstrap platform` boundary. It deliberately accepts
121
- * token *paths*, never token values, so a caller cannot accidentally put the
122
- * Cloudflare management credential into a platform manifest, runtime config,
123
- * child argv, or evidence journal.
124
- */
125
70
  export interface AttendedCloudflareBootstrapRequest {
126
71
  mode: 'plan' | 'apply';
127
72
  coordinates: CloudflareBootstrapCoordinates;
@@ -135,22 +80,13 @@ export interface CloudflareBootstrapEvidence {
135
80
  phase: 'planned' | 'complete';
136
81
  checkpointFile: string;
137
82
  kvNamespaceId?: string;
138
- workerScriptName: string;
139
- publicDomains: readonly string[];
140
- runtimeTokenIds?: {
141
- kv?: string;
142
- privateNetwork?: string;
143
- };
144
83
  nodes: ReadonlyArray<{
145
84
  nodeName: string;
146
85
  hostname: string;
147
- /** Owner-only, node-specific input for `fz bootstrap platform`. */
148
86
  handoffFile?: string;
149
87
  tunnelId?: string;
150
- applicationId?: string;
151
88
  }>;
152
89
  }
153
- /** Secret-free proof that the already-provisioned edge reaches live APIs. */
154
90
  export interface CloudflareBootstrapAcceptanceEvidence {
155
91
  format: 1;
156
92
  kind: 'forgezero-cloudflare-bootstrap-acceptance';
@@ -161,14 +97,9 @@ export interface CloudflareBootstrapAcceptanceEvidence {
161
97
  hostname: string;
162
98
  status: number;
163
99
  }>;
164
- publicDomains: ReadonlyArray<{
165
- hostname: string;
166
- status: number;
167
- }>;
168
100
  }
169
101
  export interface CloudflareBootstrapDependencies {
170
102
  fetcher?: typeof fetch;
171
- workerRunner?: CloudflareWorkerCommandRunner;
172
103
  }
173
104
  export type CloudflareBootstrapPhaseRunner = (request: AttendedCloudflareBootstrapRequest) => Promise<CloudflareBootstrapEvidence>;
174
105
  /** Read exactly one API token from a non-symlinked, owner-only regular file. */
@@ -176,18 +107,6 @@ export declare function readOwnerApiToken(path: string): Promise<string>;
176
107
  export declare function readCloudflareBootstrapTokens(files: CloudflareBootstrapTokenFiles): Promise<CloudflareApiTokens>;
177
108
  export declare function validateCloudflareBootstrapCoordinates(input: CloudflareBootstrapCoordinates): CloudflareBootstrapCoordinates;
178
109
  export declare function planCloudflareBootstrap(input: CloudflareBootstrapCoordinates, outputPath: string): CloudflareBootstrapPlan;
179
- export interface CloudflareWorkerCommand {
180
- command: readonly string[];
181
- cwd: string;
182
- env: Readonly<Record<string, string>>;
183
- }
184
- export type CloudflareWorkerCommandRunner = (request: CloudflareWorkerCommand) => Promise<{
185
- exitCode: number;
186
- stdout: string;
187
- stderr: string;
188
- }>;
189
- /** Deploy one Worker from an ephemeral config containing the runtime-created KV id. */
190
- export declare function deployCloudflareWorker(coordinates: CloudflareBootstrapCoordinates, kvNamespaceId: string, apiToken: string, runner?: CloudflareWorkerCommandRunner): Promise<void>;
191
110
  export interface CloudflareConnectorHandoff {
192
111
  nodeName: string;
193
112
  hostname: string;
@@ -200,6 +119,7 @@ export interface CloudflareHostHandoff extends CloudflareConnectorHandoff {
200
119
  zoneId: string;
201
120
  kvNamespaceId: string;
202
121
  kvRuntimeToken: string;
122
+ /** Backward-compatible private-network coordinates; not produced by this public-hostname bootstrap. */
203
123
  privateNetworkRuntimeToken?: string;
204
124
  warp?: {
205
125
  organization: string;
@@ -209,39 +129,12 @@ export interface CloudflareHostHandoff extends CloudflareConnectorHandoff {
209
129
  deviceProfileId: string;
210
130
  };
211
131
  }
212
- /** Deterministic private output path; safe to include in secret-free evidence. */
213
132
  export declare function cloudflareHostHandoffPath(checkpointPath: string, nodeName: string): string;
214
- /**
215
- * Select one node's connector credential directly from the completed fleet
216
- * checkpoint. Host bootstrap can pipe this value into `systemd-creds` without
217
- * creating another plaintext token file or accepting the whole JSON as a
218
- * connector token.
219
- */
220
133
  export declare function readCloudflareConnectorHandoff(checkpointPath: string, nodeName: string): Promise<CloudflareConnectorHandoff>;
221
- /** Complete secret-bearing handoff consumed once by root host bootstrap. */
222
134
  export declare function readCloudflareHostHandoff(handoffPath: string, nodeName: string): Promise<CloudflareHostHandoff>;
223
135
  export declare function writeOwnerBootstrapOutput(path: string, output: CloudflareBootstrapOutput): Promise<void>;
224
- /**
225
- * Attended, resumable Cloudflare bootstrap. The output is checkpointed after
226
- * every one-time secret is obtained, so a later API failure cannot orphan it.
227
- */
228
- export declare function applyCloudflareBootstrap(input: CloudflareBootstrapCoordinates, tokens: CloudflareApiTokens, outputPath: string, fetcher?: typeof fetch, workerRunner?: CloudflareWorkerCommandRunner): Promise<CloudflareBootstrapOutput>;
229
- /**
230
- * Run the attended Cloudflare phase for `fz bootstrap platform`.
231
- *
232
- * Plans are offline. Applies read management tokens only inside this function,
233
- * persist one-time handoff values only in the owner-only checkpoint, and return
234
- * a deliberately secret-free evidence record to the outer bootstrap journal.
235
- */
136
+ /** Attended, resumable Tunnel/DNS/KV handoff bootstrap. */
137
+ export declare function applyCloudflareBootstrap(input: CloudflareBootstrapCoordinates, tokens: CloudflareApiTokens, outputPath: string, fetcher?: typeof fetch): Promise<CloudflareBootstrapOutput>;
236
138
  export declare function runAttendedCloudflareBootstrap(request: AttendedCloudflareBootstrapRequest, dependencies?: CloudflareBootstrapDependencies): Promise<CloudflareBootstrapEvidence>;
237
- /**
238
- * Prove the post-bootstrap data path from an operator machine.
239
- *
240
- * This deliberately reads only the completed owner checkpoint. The Access
241
- * service credential is used in request headers for each origin and is never
242
- * returned, logged, copied to a host, or accepted on argv. Public Worker
243
- * domains are then checked without privileged headers, proving the same route
244
- * a client uses after KV heartbeats are active.
245
- */
246
139
  export declare function verifyCloudflareBootstrapAcceptance(checkpointPath: string, fetcher?: typeof fetch): Promise<CloudflareBootstrapAcceptanceEvidence>;
247
140
  export {};