@forgezero/agent 0.1.34 → 0.1.35

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.
@@ -0,0 +1,11 @@
1
+ import { type AttendedCloudflareBootstrapRequest, type CloudflareBootstrapEvidence, type CloudflareBootstrapPhaseRunner } from '../cloudflare-bootstrap';
2
+ export interface CloudflareBootstrapCommandDependencies {
3
+ run?: CloudflareBootstrapPhaseRunner;
4
+ write?: (text: string) => void;
5
+ }
6
+ /**
7
+ * Read reviewed non-secret coordinates and token-file paths for the attended
8
+ * operator phase. Raw token values and a persisted mode are not schema fields.
9
+ */
10
+ export declare function readCloudflareBootstrapCommandConfig(path: string, mode: 'plan' | 'apply'): AttendedCloudflareBootstrapRequest;
11
+ export declare function runCloudflareBootstrapCommand(configPath: string, apply: boolean, dependencies?: CloudflareBootstrapCommandDependencies): Promise<CloudflareBootstrapEvidence>;
@@ -0,0 +1,218 @@
1
+ import { type CloudflareAccessCredentials, type CloudflareAccountRuntimeToken, type CloudflareApiTokens } from './cloudflare-edge';
2
+ export interface CloudflareBootstrapNodeCoordinates {
3
+ nodeName: string;
4
+ hostname: string;
5
+ service: string;
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
+ }
18
+ export interface CloudflareBootstrapCoordinates {
19
+ accountId: string;
20
+ zoneId: string;
21
+ /** Legacy single-node coordinates; normalized into `nodes[0]`. */
22
+ hostname: string;
23
+ service: string;
24
+ 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;
37
+ nodes?: CloudflareBootstrapNodeCoordinates[];
38
+ privateNetwork?: CloudflarePrivateNetworkCoordinates;
39
+ }
40
+ export interface CloudflareBootstrapTokenFiles {
41
+ apiTokenFile?: string;
42
+ tunnelApiTokenFile?: string;
43
+ dnsApiTokenFile?: string;
44
+ kvApiTokenFile?: string;
45
+ accessApiTokenFile?: string;
46
+ workerApiTokenFile?: string;
47
+ }
48
+ interface CloudflareBootstrapResources {
49
+ tunnelId: string;
50
+ kvNamespaceId: string;
51
+ hostname: string;
52
+ service: string;
53
+ 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
+ };
87
+ }
88
+ export interface CloudflareBootstrapOutput {
89
+ format: 1;
90
+ kind: 'forgezero-cloudflare-bootstrap';
91
+ phase: 'edge-resources-provisioned' | 'runtime-tokens-created' | 'worker-deployed' | 'access-token-provisioned' | 'complete';
92
+ updatedAt: string;
93
+ coordinates: CloudflareBootstrapCoordinates;
94
+ resources: CloudflareBootstrapResources;
95
+ created?: {
96
+ tunnel: boolean;
97
+ kvNamespace: boolean;
98
+ serviceToken: boolean;
99
+ policy: boolean;
100
+ application: boolean;
101
+ privateNetwork: boolean;
102
+ workerDeployed: true;
103
+ nodes: Array<{
104
+ nodeName: string;
105
+ tunnel: boolean;
106
+ application: boolean;
107
+ }>;
108
+ };
109
+ }
110
+ export interface CloudflareBootstrapPlan {
111
+ format: 1;
112
+ kind: 'forgezero-cloudflare-bootstrap-plan';
113
+ mode: 'attended-token-file';
114
+ outputFile: string;
115
+ coordinates: CloudflareBootstrapCoordinates;
116
+ operations: readonly string[];
117
+ secrets: readonly string[];
118
+ }
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
+ export interface AttendedCloudflareBootstrapRequest {
126
+ mode: 'plan' | 'apply';
127
+ coordinates: CloudflareBootstrapCoordinates;
128
+ tokenFiles?: CloudflareBootstrapTokenFiles;
129
+ checkpointPath: string;
130
+ }
131
+ /** Secret-free evidence safe to embed in the platform bootstrap journal. */
132
+ export interface CloudflareBootstrapEvidence {
133
+ format: 1;
134
+ kind: 'forgezero-cloudflare-bootstrap-evidence';
135
+ phase: 'planned' | 'complete';
136
+ checkpointFile: string;
137
+ kvNamespaceId?: string;
138
+ workerScriptName: string;
139
+ publicDomains: readonly string[];
140
+ runtimeTokenIds?: {
141
+ kv?: string;
142
+ privateNetwork?: string;
143
+ };
144
+ nodes: ReadonlyArray<{
145
+ nodeName: string;
146
+ hostname: string;
147
+ tunnelId?: string;
148
+ applicationId?: string;
149
+ }>;
150
+ }
151
+ export interface CloudflareBootstrapDependencies {
152
+ fetcher?: typeof fetch;
153
+ workerRunner?: CloudflareWorkerCommandRunner;
154
+ }
155
+ export type CloudflareBootstrapPhaseRunner = (request: AttendedCloudflareBootstrapRequest) => Promise<CloudflareBootstrapEvidence>;
156
+ /** Read exactly one API token from a non-symlinked, owner-only regular file. */
157
+ export declare function readOwnerApiToken(path: string): Promise<string>;
158
+ export declare function readCloudflareBootstrapTokens(files: CloudflareBootstrapTokenFiles): Promise<CloudflareApiTokens>;
159
+ export declare function validateCloudflareBootstrapCoordinates(input: CloudflareBootstrapCoordinates): CloudflareBootstrapCoordinates;
160
+ export declare function planCloudflareBootstrap(input: CloudflareBootstrapCoordinates, outputPath: string): CloudflareBootstrapPlan;
161
+ export interface CloudflareWorkerCommand {
162
+ command: readonly string[];
163
+ cwd: string;
164
+ env: Readonly<Record<string, string>>;
165
+ }
166
+ export type CloudflareWorkerCommandRunner = (request: CloudflareWorkerCommand) => Promise<{
167
+ exitCode: number;
168
+ stdout: string;
169
+ stderr: string;
170
+ }>;
171
+ /** Deploy one Worker from an ephemeral config containing the runtime-created KV id. */
172
+ export declare function deployCloudflareWorker(coordinates: CloudflareBootstrapCoordinates, kvNamespaceId: string, apiToken: string, runner?: CloudflareWorkerCommandRunner): Promise<void>;
173
+ export interface CloudflareConnectorHandoff {
174
+ nodeName: string;
175
+ hostname: string;
176
+ service: string;
177
+ tunnelId: string;
178
+ connectorToken: string;
179
+ }
180
+ export interface CloudflareHostHandoff extends CloudflareConnectorHandoff {
181
+ accountId: string;
182
+ zoneId: string;
183
+ kvNamespaceId: string;
184
+ kvRuntimeToken: string;
185
+ privateNetworkRuntimeToken?: string;
186
+ warp?: {
187
+ organization: string;
188
+ clientId: string;
189
+ clientSecret: string;
190
+ virtualNetworkId: string;
191
+ deviceProfileId: string;
192
+ };
193
+ }
194
+ /**
195
+ * Select one node's connector credential directly from the completed fleet
196
+ * checkpoint. Host bootstrap can pipe this value into `systemd-creds` without
197
+ * creating another plaintext token file or accepting the whole JSON as a
198
+ * connector token.
199
+ */
200
+ export declare function readCloudflareConnectorHandoff(checkpointPath: string, nodeName: string): Promise<CloudflareConnectorHandoff>;
201
+ /** Complete secret-bearing handoff consumed once by root host bootstrap. */
202
+ export declare function readCloudflareHostHandoff(checkpointPath: string, nodeName: string): Promise<CloudflareHostHandoff>;
203
+ /** Atomically persist sensitive bootstrap material without making it runtime configuration. */
204
+ export declare function writeOwnerBootstrapOutput(path: string, output: CloudflareBootstrapOutput): Promise<void>;
205
+ /**
206
+ * Attended, resumable Cloudflare bootstrap. The output is checkpointed after
207
+ * every one-time secret is obtained, so a later API failure cannot orphan it.
208
+ */
209
+ export declare function applyCloudflareBootstrap(input: CloudflareBootstrapCoordinates, tokens: CloudflareApiTokens, outputPath: string, fetcher?: typeof fetch, workerRunner?: CloudflareWorkerCommandRunner): Promise<CloudflareBootstrapOutput>;
210
+ /**
211
+ * Run the attended Cloudflare phase for `fz bootstrap platform`.
212
+ *
213
+ * Plans are offline. Applies read management tokens only inside this function,
214
+ * persist one-time handoff values only in the owner-only checkpoint, and return
215
+ * a deliberately secret-free evidence record to the outer bootstrap journal.
216
+ */
217
+ export declare function runAttendedCloudflareBootstrap(request: AttendedCloudflareBootstrapRequest, dependencies?: CloudflareBootstrapDependencies): Promise<CloudflareBootstrapEvidence>;
218
+ export {};