@forgezero/agent 0.1.40 → 0.1.42

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.
Files changed (64) hide show
  1. package/README.md +573 -424
  2. package/dist/agent-heartbeat.js +6 -3
  3. package/dist/agent-update-helper.js +5 -2
  4. package/dist/agent-update.js +5 -2
  5. package/dist/bootstrap.d.ts +17 -8
  6. package/dist/bootstrap.js +1504 -512
  7. package/dist/cli/agent-install.d.ts +6 -5
  8. package/dist/cli/cloudflare-bootstrap.d.ts +12 -1
  9. package/dist/cli/maintenance.d.ts +23 -0
  10. package/dist/cli/run.d.ts +3 -1
  11. package/dist/cli/session-store.d.ts +5 -0
  12. package/dist/cloudflare-bootstrap.d.ts +73 -35
  13. package/dist/cloudflare-bootstrap.js +587 -90
  14. package/dist/cloudflare-edge.d.ts +64 -12
  15. package/dist/cloudflare-edge.js +103 -8
  16. package/dist/community-rehearsal-host.d.ts +51 -0
  17. package/dist/community-rehearsal-host.js +272 -0
  18. package/dist/credential-schema.d.ts +54 -0
  19. package/dist/credential-schema.js +47 -0
  20. package/dist/definition.d.ts +31 -5
  21. package/dist/definition.js +271 -44
  22. package/dist/deploy-file.js +294 -68
  23. package/dist/deployment-runner.js +18 -5
  24. package/dist/deployment.d.ts +13 -1
  25. package/dist/fz-agent.js +9162 -7564
  26. package/dist/fz-git-ssh.js +122 -0
  27. package/dist/fz.js +5679 -5077
  28. package/dist/git-ssh.d.ts +5 -0
  29. package/dist/guest-enrolment.d.ts +2 -0
  30. package/dist/guest-enrolment.js +1 -0
  31. package/dist/host-maintenance.d.ts +39 -0
  32. package/dist/host-maintenance.js +135 -0
  33. package/dist/index.d.ts +4 -2
  34. package/dist/mesh-connector.d.ts +16 -0
  35. package/dist/mesh-connector.js +46 -0
  36. package/dist/metal-bootstrap.js +145 -7
  37. package/dist/metal-helper-socket.js +61 -31
  38. package/dist/metal-provision.d.ts +2 -2
  39. package/dist/metal-provision.js +62 -32
  40. package/dist/operator-bootstrap.d.ts +90 -0
  41. package/dist/operator-bootstrap.js +5704 -0
  42. package/dist/otel-collector.d.ts +18 -0
  43. package/dist/pipeline.d.ts +3 -2
  44. package/dist/pipeline.js +1 -1
  45. package/dist/platform-bootstrap-runtime.d.ts +39 -21
  46. package/dist/platform-bootstrap-runtime.js +182 -59
  47. package/dist/platform-fleet-verification.d.ts +19 -0
  48. package/dist/platform-fleet-verification.js +3873 -0
  49. package/dist/platform-genesis-config.d.ts +7 -0
  50. package/dist/platform-genesis.d.ts +17 -0
  51. package/dist/provision.d.ts +76 -3
  52. package/dist/provision.js +1061 -229
  53. package/dist/recovery-host.d.ts +7 -0
  54. package/dist/recovery-host.js +124 -0
  55. package/dist/service-supervisor.d.ts +42 -0
  56. package/dist/software-helper.d.ts +4 -0
  57. package/dist/software-helper.js +865 -63
  58. package/dist/software.d.ts +14 -3
  59. package/dist/software.js +163 -37
  60. package/dist/ssh-bootstrap.d.ts +97 -0
  61. package/dist/supervised-app.d.ts +2 -0
  62. package/dist/version.d.ts +1 -1
  63. package/package.json +175 -164
  64. package/schema/{deploy-v2.json → deploy-v3.json} +53 -6
@@ -1,4 +1,4 @@
1
- import { type Capabilities, type ProvisionPlan } from '../provision';
1
+ import { type Capabilities, type CapabilityOperation, type ProvisionOperation, type ProvisionPlan } from '../provision';
2
2
  /**
3
3
  * `fz agent install` — run the provision plan on THIS machine.
4
4
  *
@@ -26,12 +26,11 @@ export declare function parseTcpPorts(value: string | undefined): readonly numbe
26
26
  * SSH come from the same test, so a box that reports `attested` to an operator
27
27
  * cannot report `enrolled` to the platform.
28
28
  */
29
- export declare function readCapabilities(run: (command: string) => Promise<{
29
+ export declare function readCapabilities(run: (operation: CapabilityOperation) => Promise<{
30
30
  stdout: string;
31
31
  exitCode: number;
32
32
  }>): Promise<Capabilities>;
33
- /** Run a command locally. The SSH executor is the platform's half. */
34
- export declare function localRunner(command: string): Promise<{
33
+ export declare function localRunner(operation: CapabilityOperation | ProvisionOperation): Promise<{
35
34
  stdout: string;
36
35
  exitCode: number;
37
36
  }>;
@@ -58,6 +57,8 @@ export interface InstallOptions {
58
57
  pullMigrations?: boolean;
59
58
  pullBootstrap?: boolean;
60
59
  bootstrapSshCredentialPath?: string;
60
+ bootstrapSshSourcePath?: string;
61
+ bootstrapSshPublicKeyPath?: string;
61
62
  bootstrapTargetTelemetryEndpoint?: string;
62
63
  lifecycleProfilePath?: string;
63
64
  lifecycleHelperSocketPath?: string;
@@ -83,7 +84,7 @@ export interface InstallOptions {
83
84
  }
84
85
  export declare function planInstall(options: InstallOptions): ProvisionPlan;
85
86
  /** Execute the same ordered plan the control plane executes over SSH. */
86
- export declare function applyPlan(plan: ProvisionPlan, run: (command: string) => Promise<{
87
+ export declare function applyPlan(plan: ProvisionPlan, run: (operation: CapabilityOperation | ProvisionOperation) => Promise<{
87
88
  stdout: string;
88
89
  exitCode: number;
89
90
  }>): Promise<readonly {
@@ -1,8 +1,14 @@
1
- import { verifyCloudflareBootstrapAcceptance, type AttendedCloudflareBootstrapRequest, type CloudflareBootstrapEvidence, type CloudflareBootstrapAcceptanceEvidence, type CloudflareBootstrapPhaseRunner } from '../cloudflare-bootstrap';
1
+ import { finalizeCloudflareBootstrapAcceptance, verifyCloudflareBootstrapAcceptance, type AttendedCloudflareBootstrapRequest, type CloudflareBootstrapEvidence, type CloudflareBootstrapAcceptanceEvidence, type CloudflareBootstrapFinalizeRequest, type CloudflareBootstrapPhaseRunner } from '../cloudflare-bootstrap';
2
2
  export interface CloudflareBootstrapCommandDependencies {
3
3
  run?: CloudflareBootstrapPhaseRunner;
4
4
  write?: (text: string) => void;
5
5
  }
6
+ export interface CloudflareBootstrapFinalizeConfig {
7
+ format: 1;
8
+ kind: 'forgezero-cloudflare-bootstrap-finalize';
9
+ checkpointPath: string;
10
+ acceptancePath: string;
11
+ }
6
12
  /**
7
13
  * Read reviewed non-secret coordinates and token-file paths for the attended
8
14
  * operator phase. Raw token values and a persisted mode are not schema fields.
@@ -13,3 +19,8 @@ export declare function runCloudflareBootstrapVerificationCommand(checkpointPath
13
19
  verify?: typeof verifyCloudflareBootstrapAcceptance;
14
20
  write?: (text: string) => void;
15
21
  }): Promise<CloudflareBootstrapAcceptanceEvidence>;
22
+ export declare function readCloudflareBootstrapFinalizeConfig(path: string): CloudflareBootstrapFinalizeRequest;
23
+ export declare function runCloudflareBootstrapFinalizeCommand(configPath: string, dependencies?: {
24
+ finalize?: typeof finalizeCloudflareBootstrapAcceptance;
25
+ write?: (text: string) => void;
26
+ }): Promise<CloudflareBootstrapAcceptanceEvidence>;
@@ -0,0 +1,23 @@
1
+ export type RepositoryOperation = 'dev-reset' | 'db-backup' | 'db-recover' | 'db-inspect-recovery-target' | 'db-verify-recovery-cluster' | 'db-consolidate' | 'rehearse-recovery' | 'rehearse-transactions' | 'community-cluster-api' | 'platform-fleet' | 'platform-recovery';
2
+ /**
3
+ * Global fz options must not disappear before a maintenance parser sees them.
4
+ * Only --root selects the reviewed checkout; --apply/--json are deliberately
5
+ * reinserted for the operation. Every other recognized global option is an
6
+ * error instead of a silently ignored mutation bypass such as --force.
7
+ */
8
+ export declare function unsupportedRepositoryCliOption(argv: readonly string[]): string | undefined;
9
+ export interface ResolvedRepositoryOperation {
10
+ operation: RepositoryOperation;
11
+ root: string;
12
+ cwd: string;
13
+ entrypoint: string;
14
+ }
15
+ /**
16
+ * Resolve only reviewed repository-owned operations.
17
+ *
18
+ * This is deliberately a closed table, not `fz exec <path>`. The published
19
+ * Agent can launch maintenance from a checkout, but a typo or untrusted value
20
+ * cannot turn that facility into arbitrary script execution.
21
+ */
22
+ export declare function resolveRepositoryOperation(operation: RepositoryOperation, requestedRoot: string): ResolvedRepositoryOperation;
23
+ export declare function runRepositoryOperation(operation: RepositoryOperation, requestedRoot: string, args?: readonly string[]): Promise<number>;
package/dist/cli/run.d.ts CHANGED
@@ -89,4 +89,6 @@ export declare function exitCodeFor(status: {
89
89
  * forwarded signals, propagated status — and none of it is provable against a
90
90
  * mock.
91
91
  */
92
- export declare function spawnWith(command: readonly string[], env: Record<string, string>, report?: (line: string) => void): Promise<number>;
92
+ export declare function spawnWith(command: readonly string[], env: Record<string, string>, report?: (line: string) => void, options?: {
93
+ cwd?: string;
94
+ }): Promise<number>;
@@ -3,7 +3,12 @@ export interface CliSession {
3
3
  api: string;
4
4
  /** Browser application origin that approved this session and fresh actions. */
5
5
  app?: string;
6
+ /** Internal URL selector. `platform` or the tenant slug; never presented as identity. */
6
7
  realm: string;
8
+ /** Stable database/crypto identity returned by the API. */
9
+ realmId?: string;
10
+ /** Human-readable routing coordinate, when this is a tenant session. */
11
+ tenantSlug?: string;
7
12
  cookie: string;
8
13
  createdAtTs: number;
9
14
  lastUsedAtTs: number;
@@ -1,46 +1,64 @@
1
- import { type CloudflareApiTokens } from './cloudflare-edge';
1
+ export interface CloudflareMeshCoordinates {
2
+ /** Unique account-scoped Mesh/WARP Connector name. */
3
+ connectorName: string;
4
+ /** Exact private CIDRs reachable behind this metal/compute. */
5
+ routes: string[];
6
+ /** Mesh replicas sharing one connector may be active/passive. */
7
+ highAvailability?: boolean;
8
+ }
2
9
  export interface CloudflareBootstrapNodeCoordinates {
3
10
  nodeName: string;
4
11
  hostname: string;
5
12
  service: string;
6
13
  tunnelName: string;
14
+ /** Optional bidirectional private networking, independent of public ingress. */
15
+ mesh?: CloudflareMeshCoordinates;
16
+ }
17
+ export interface CloudflareRealtimeCoordinates {
18
+ /** Existing Worker script deployed independently through Cloudflare Git integration. */
19
+ workerScriptName: string;
20
+ /** Stable public HTTPS Worker origin used by API publishers and WebSocket clients. */
21
+ endpoint: string;
22
+ /** Signed producer identity emitted by this platform API fleet. */
23
+ producer: string;
7
24
  }
8
25
  export interface CloudflareBootstrapCoordinates {
9
26
  accountId: string;
10
27
  zoneId: string;
11
- /** Legacy single-node coordinates; normalized into `nodes[0]`. */
12
- hostname: string;
13
- service: string;
14
- tunnelName: string;
15
28
  /** Existing namespace bound to the separately deployed Worker. */
16
29
  kvNamespaceId: string;
17
- nodes?: CloudflareBootstrapNodeCoordinates[];
30
+ /** Existing dedicated Mesh device profile whose include list ForgeZero owns. */
31
+ meshDevicePolicyId?: string;
32
+ /** Optional existing Worker/DO realtime boundary. No Worker source is deployed here. */
33
+ realtime?: CloudflareRealtimeCoordinates;
34
+ nodes: CloudflareBootstrapNodeCoordinates[];
18
35
  }
19
36
  export interface CloudflareBootstrapTokenFiles {
20
- /** One owner-supplied token with Tunnel Write, DNS Write and KV Write. */
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. */
27
- tunnelApiTokenFile?: string;
28
- dnsApiTokenFile?: string;
29
- kvApiTokenFile?: string;
37
+ /** CF_TUNNEL_TOKEN: Tunnel, DNS, Mesh connector/network and device-profile writes. */
38
+ tunnelTokenFile: string;
39
+ /** Exact-account Workers KV Storage Write plus existing-Worker Scripts Write. */
40
+ apiTokenFile: string;
41
+ }
42
+ export interface CloudflareBootstrapTokens {
43
+ tunnelToken: string;
44
+ apiToken: string;
30
45
  }
31
46
  interface CloudflareBootstrapNodeResource extends CloudflareBootstrapNodeCoordinates {
32
47
  tunnelId: string;
33
48
  connectorToken: string;
49
+ mesh?: CloudflareMeshCoordinates & {
50
+ connectorId: string;
51
+ connectorToken: string;
52
+ };
34
53
  }
35
54
  interface CloudflareBootstrapResources {
36
- /** First-node compatibility fields. */
37
- tunnelId: string;
38
55
  kvNamespaceId: string;
39
- hostname: string;
40
- service: string;
41
- connectorToken: string;
42
- /** Owner-supplied Workers KV Storage Write token, sealed into each host handoff. */
43
- kvRuntimeToken: string;
56
+ /** Owner-supplied CF_API_TOKEN, sealed into each host handoff. */
57
+ apiToken: string;
58
+ realtime?: {
59
+ publishSecret: string;
60
+ ticketSecret: string;
61
+ };
44
62
  nodes: CloudflareBootstrapNodeResource[];
45
63
  }
46
64
  export interface CloudflareBootstrapOutput {
@@ -51,10 +69,10 @@ export interface CloudflareBootstrapOutput {
51
69
  coordinates: CloudflareBootstrapCoordinates;
52
70
  resources: CloudflareBootstrapResources;
53
71
  created?: {
54
- tunnel: boolean;
55
72
  nodes: Array<{
56
73
  nodeName: string;
57
74
  tunnel: boolean;
75
+ mesh: boolean;
58
76
  }>;
59
77
  };
60
78
  }
@@ -98,13 +116,21 @@ export interface CloudflareBootstrapAcceptanceEvidence {
98
116
  status: number;
99
117
  }>;
100
118
  }
119
+ export interface CloudflareBootstrapAcceptedNode {
120
+ nodeName: string;
121
+ hostname: string;
122
+ }
123
+ export interface CloudflareBootstrapFinalizeRequest {
124
+ checkpointPath: string;
125
+ acceptancePath: string;
126
+ }
101
127
  export interface CloudflareBootstrapDependencies {
102
128
  fetcher?: typeof fetch;
103
129
  }
104
130
  export type CloudflareBootstrapPhaseRunner = (request: AttendedCloudflareBootstrapRequest) => Promise<CloudflareBootstrapEvidence>;
105
131
  /** Read exactly one API token from a non-symlinked, owner-only regular file. */
106
132
  export declare function readOwnerApiToken(path: string): Promise<string>;
107
- export declare function readCloudflareBootstrapTokens(files: CloudflareBootstrapTokenFiles): Promise<CloudflareApiTokens>;
133
+ export declare function readCloudflareBootstrapTokens(files: CloudflareBootstrapTokenFiles): Promise<CloudflareBootstrapTokens>;
108
134
  export declare function validateCloudflareBootstrapCoordinates(input: CloudflareBootstrapCoordinates): CloudflareBootstrapCoordinates;
109
135
  export declare function planCloudflareBootstrap(input: CloudflareBootstrapCoordinates, outputPath: string): CloudflareBootstrapPlan;
110
136
  export interface CloudflareConnectorHandoff {
@@ -113,20 +139,21 @@ export interface CloudflareConnectorHandoff {
113
139
  service: string;
114
140
  tunnelId: string;
115
141
  connectorToken: string;
142
+ mesh?: {
143
+ connectorId: string;
144
+ connectorToken: string;
145
+ routes: readonly string[];
146
+ };
116
147
  }
117
148
  export interface CloudflareHostHandoff extends CloudflareConnectorHandoff {
118
149
  accountId: string;
119
150
  zoneId: string;
120
151
  kvNamespaceId: string;
121
- kvRuntimeToken: string;
122
- /** Backward-compatible private-network coordinates; not produced by this public-hostname bootstrap. */
123
- privateNetworkRuntimeToken?: string;
124
- warp?: {
125
- organization: string;
126
- clientId: string;
127
- clientSecret: string;
128
- virtualNetworkId: string;
129
- deviceProfileId: string;
152
+ /** CF_API_TOKEN: Workers KV Storage Write plus existing-Worker Scripts Write. */
153
+ apiToken: string;
154
+ realtime?: CloudflareRealtimeCoordinates & {
155
+ publishSecret: string;
156
+ ticketSecret: string;
130
157
  };
131
158
  }
132
159
  export declare function cloudflareHostHandoffPath(checkpointPath: string, nodeName: string): string;
@@ -134,7 +161,18 @@ export declare function readCloudflareConnectorHandoff(checkpointPath: string, n
134
161
  export declare function readCloudflareHostHandoff(handoffPath: string, nodeName: string): Promise<CloudflareHostHandoff>;
135
162
  export declare function writeOwnerBootstrapOutput(path: string, output: CloudflareBootstrapOutput): Promise<void>;
136
163
  /** Attended, resumable Tunnel/DNS/KV handoff bootstrap. */
137
- export declare function applyCloudflareBootstrap(input: CloudflareBootstrapCoordinates, tokens: CloudflareApiTokens, outputPath: string, fetcher?: typeof fetch): Promise<CloudflareBootstrapOutput>;
164
+ export declare function applyCloudflareBootstrap(input: CloudflareBootstrapCoordinates, tokens: CloudflareBootstrapTokens, outputPath: string, fetcher?: typeof fetch): Promise<CloudflareBootstrapOutput>;
138
165
  export declare function runAttendedCloudflareBootstrap(request: AttendedCloudflareBootstrapRequest, dependencies?: CloudflareBootstrapDependencies): Promise<CloudflareBootstrapEvidence>;
139
166
  export declare function verifyCloudflareBootstrapAcceptance(checkpointPath: string, fetcher?: typeof fetch): Promise<CloudflareBootstrapAcceptanceEvidence>;
167
+ /**
168
+ * Read finalized, secret-free Cloudflare acceptance after the capability-bearing
169
+ * checkpoint has been removed. This is the durable input consumed by the fleet
170
+ * rehearsal; it never attempts to reopen the deleted handoff.
171
+ */
172
+ export declare function readCloudflareBootstrapAcceptanceEvidence(acceptancePath: string, expectedNodes?: readonly CloudflareBootstrapAcceptedNode[]): Promise<CloudflareBootstrapAcceptanceEvidence>;
173
+ /**
174
+ * Prove every public node, persist secret-free acceptance evidence, then remove
175
+ * the resumable checkpoint and node handoffs that contain runtime capabilities.
176
+ */
177
+ export declare function finalizeCloudflareBootstrapAcceptance(request: CloudflareBootstrapFinalizeRequest, fetcher?: typeof fetch): Promise<CloudflareBootstrapAcceptanceEvidence>;
140
178
  export {};