@agent-vm/gateway-lifecycle 0.0.115

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,1121 @@
1
+ import { MediatedSecretSpec, SecretResolver } from "@agent-vm/secret-management";
2
+ import { ManagedVmGitReadOnlySshEgress, ManagedVmMount } from "@agent-vm/managed-vm";
3
+
4
+ //#region src/gateway-runtime-contract.d.ts
5
+ declare const gatewayTypeValues: readonly ["openclaw", "hermes", "worker"];
6
+ type GatewayType = (typeof gatewayTypeValues)[number];
7
+ declare function buildGatewaySessionLabel(projectNamespace: string, zoneId: string): string;
8
+ declare function buildToolSessionLabel(projectNamespace: string, zoneId: string, tcpSlot: number): string;
9
+ //#endregion
10
+ //#region src/audience.d.ts
11
+ declare const vmAudienceValues: readonly ["gateway", "tool-vm", "both"];
12
+ type VmAudience = (typeof vmAudienceValues)[number];
13
+ type RuntimeVmAudience = Exclude<VmAudience, 'both'>;
14
+ interface EgressHostConfig {
15
+ readonly host: string;
16
+ readonly audience: VmAudience;
17
+ }
18
+ declare const controllerVmHost = "controller.vm.host";
19
+ declare function targetsAudience(configAudience: VmAudience, runtimeAudience: RuntimeVmAudience): boolean;
20
+ declare function egressHostsForAudience(egressHosts: readonly EgressHostConfig[], runtimeAudience: RuntimeVmAudience): readonly string[];
21
+ declare function gatewayVmAllowedHosts(egressHosts: readonly EgressHostConfig[]): readonly string[];
22
+ declare function workerVmAllowedHosts(egressHosts: readonly EgressHostConfig[]): readonly string[];
23
+ //#endregion
24
+ //#region src/gateway-control-private-environment.d.ts
25
+ declare const GATEWAY_CONTROL_CALLER_CONTEXT_PROOF_KEY_ENV = "AGENT_VM_GATEWAY_CONTROL_CALLER_CONTEXT_PROOF_KEY";
26
+ declare const GATEWAY_CONTROL_CALLER_CONTEXT_AGENT_AUTHORITY_KEYS_ENV = "AGENT_VM_GATEWAY_CONTROL_CALLER_CONTEXT_AGENT_AUTHORITY_KEYS";
27
+ declare const GATEWAY_CONTROL_PRIVATE_ENVIRONMENT_NAMES: readonly ["AGENT_VM_GATEWAY_CONTROL_CALLER_CONTEXT_AGENT_AUTHORITY_KEYS", "AGENT_VM_GATEWAY_CONTROL_CALLER_CONTEXT_PROOF_KEY"];
28
+ type GatewayControlPrivateEnvironmentName = (typeof GATEWAY_CONTROL_PRIVATE_ENVIRONMENT_NAMES)[number];
29
+ //#endregion
30
+ //#region src/gateway-process-spec.d.ts
31
+ type GatewayHealthCheck = {
32
+ readonly type: 'http';
33
+ readonly port: number;
34
+ readonly path: string;
35
+ } | {
36
+ readonly type: 'command';
37
+ readonly command: string;
38
+ };
39
+ /**
40
+ * Everything about the process running inside the VM.
41
+ * Retained by the running gateway handle for logs, health, restart.
42
+ */
43
+ interface GatewayProcessSpec {
44
+ readonly bootstrapCommand: string;
45
+ readonly startCommand: string;
46
+ readonly healthCheck: GatewayHealthCheck;
47
+ readonly serviceHealthCheck?: GatewayHealthCheck | undefined;
48
+ readonly guestListenPort: number;
49
+ readonly logPath: string;
50
+ }
51
+ //#endregion
52
+ //#region src/websocket-upgrade-policy.d.ts
53
+ interface WebSocketUpgradeConfig {
54
+ readonly audience: VmAudience;
55
+ readonly scheme: 'ws' | 'wss';
56
+ readonly host: string;
57
+ readonly port?: number | undefined;
58
+ readonly path?: string | undefined;
59
+ }
60
+ interface CreateWebSocketUpgradeRequestGuardOptions {
61
+ readonly rules: readonly WebSocketUpgradeConfig[];
62
+ readonly runtimeAudience: RuntimeVmAudience;
63
+ }
64
+ declare function websocketUpgradesForAudience(rules: readonly WebSocketUpgradeConfig[] | undefined, runtimeAudience: RuntimeVmAudience): readonly WebSocketUpgradeConfig[];
65
+ declare function createWebSocketUpgradeRequestGuard(options: CreateWebSocketUpgradeRequestGuardOptions): (request: Request) => Promise<Response | void>;
66
+ //#endregion
67
+ //#region src/gateway-vm-spec.d.ts
68
+ /**
69
+ * Guest workload requirements produced by a gateway lifecycle.
70
+ *
71
+ * Image selection, resources, VM construction, and backend translation remain
72
+ * controller/composition responsibilities.
73
+ */
74
+ interface GatewayVmRequirements {
75
+ readonly environment: Record<string, string>;
76
+ readonly mounts: Record<string, ManagedVmMount>;
77
+ readonly mediatedSecrets: Record<string, MediatedSecretSpec>;
78
+ readonly tcpHosts: Record<string, string>;
79
+ readonly sshEgress?: ManagedVmGitReadOnlySshEgress;
80
+ readonly allowedHosts: readonly string[];
81
+ readonly websocketUpgrades?: readonly WebSocketUpgradeConfig[];
82
+ readonly rootfsMode: 'readonly' | 'memory' | 'cow';
83
+ readonly runtimeRootfsSize?: string;
84
+ readonly sessionLabel: string;
85
+ }
86
+ //#endregion
87
+ //#region src/managed-gateway-boot-contract.d.ts
88
+ type ManagedFrameworkKind = 'openclaw' | 'hermes';
89
+ type ManagedFrameworkBootEntry = 'openclaw-gateway' | 'hermes-gateway';
90
+ interface ManagedGatewayLogIdentity {
91
+ readonly guestPath: string;
92
+ readonly serviceName: string;
93
+ }
94
+ interface ManagedToolPortalReadinessMetadata {
95
+ readonly evidencePath: string;
96
+ readonly kind: 'tool-portal-evidence';
97
+ readonly socketPath: string;
98
+ }
99
+ interface ManagedFrameworkReadinessMetadata {
100
+ readonly guestPort: number;
101
+ readonly kind: 'framework-http';
102
+ readonly path: string;
103
+ }
104
+ interface ManagedFrameworkIngressMetadata {
105
+ readonly guestPort: number;
106
+ readonly kind: 'framework-http';
107
+ }
108
+ interface ManagedToolPortalServiceBootMetadata {
109
+ readonly bootEntry: 'agent-vm-gateway-runtime';
110
+ readonly configurationInputPath: string;
111
+ readonly environmentInputPath: string;
112
+ readonly logIdentity: ManagedGatewayLogIdentity;
113
+ readonly readiness: ManagedToolPortalReadinessMetadata;
114
+ readonly role: 'tool-portal-service';
115
+ }
116
+ interface ManagedFrameworkServiceBootMetadataBase {
117
+ readonly configurationInputPath: string;
118
+ readonly environmentInputPath: string;
119
+ readonly ingress: ManagedFrameworkIngressMetadata;
120
+ readonly logIdentity: ManagedGatewayLogIdentity;
121
+ readonly readiness: ManagedFrameworkReadinessMetadata;
122
+ readonly role: 'framework-service';
123
+ }
124
+ interface ManagedOpenClawServiceBootMetadata extends ManagedFrameworkServiceBootMetadataBase {
125
+ readonly bootEntry: 'openclaw-gateway';
126
+ readonly framework: 'openclaw';
127
+ }
128
+ interface ManagedHermesServiceBootMetadata extends ManagedFrameworkServiceBootMetadataBase {
129
+ readonly bootEntry: 'hermes-gateway';
130
+ readonly framework: 'hermes';
131
+ }
132
+ type ManagedFrameworkServiceBootMetadata = ManagedOpenClawServiceBootMetadata | ManagedHermesServiceBootMetadata;
133
+ /**
134
+ * Exact image-owned startup contract for a managed Gateway VM.
135
+ *
136
+ * This contract intentionally contains no executable, argv, shell command,
137
+ * callback, process handle, or resolved environment value. The image build
138
+ * maps each closed `bootEntry` discriminator to code-owned process startup.
139
+ */
140
+ interface ManagedGatewayBootContract {
141
+ readonly contractVersion: 1;
142
+ readonly frameworkService: ManagedFrameworkServiceBootMetadata;
143
+ readonly kind: 'managed-gateway-exact-two-role';
144
+ readonly toolPortalService: ManagedToolPortalServiceBootMetadata;
145
+ }
146
+ /**
147
+ * Parses untrusted or serialized boot metadata into the exact V1 contract.
148
+ * Unknown fields are rejected at every level and a fresh deeply frozen value
149
+ * is returned so callers cannot retain mutation authority after validation.
150
+ */
151
+ declare function parseManagedGatewayBootContract(value: unknown): ManagedGatewayBootContract;
152
+ //#endregion
153
+ //#region src/gateway-lifecycle.d.ts
154
+ /**
155
+ * Describes how to run interactive auth for a gateway type.
156
+ * Static property — available without a running VM.
157
+ */
158
+ interface GatewayAuthConfig {
159
+ /**
160
+ * Shell command to list available auth providers inside the VM.
161
+ * Should output one provider name per line to stdout.
162
+ */
163
+ readonly listProvidersCommand: string;
164
+ /**
165
+ * Build the shell command for interactive auth login.
166
+ * The CLI passes this as the SSH remote command with -t (TTY).
167
+ */
168
+ readonly buildLoginCommand: (provider: string, options?: {
169
+ readonly deviceCode?: boolean;
170
+ readonly agentId?: string;
171
+ readonly profileId?: string;
172
+ }) => string;
173
+ /**
174
+ * Build the shell command for listing provider auth profiles for one agent.
175
+ * The CLI uses this after login to verify requested profile IDs exist.
176
+ */
177
+ readonly buildProfileListCommand: (provider: string, options: {
178
+ readonly agentId: string;
179
+ }) => string;
180
+ }
181
+ interface GatewayAuthProfilesRef {
182
+ readonly source: '1password' | 'config' | 'environment';
183
+ }
184
+ interface OnePasswordGatewayAuthProfilesRef extends GatewayAuthProfilesRef {
185
+ readonly source: '1password';
186
+ readonly ref: string;
187
+ }
188
+ interface EnvironmentGatewayAuthProfilesRef extends GatewayAuthProfilesRef {
189
+ readonly source: 'environment';
190
+ readonly envVar: string;
191
+ }
192
+ interface ConfigGatewayAuthProfilesRef extends GatewayAuthProfilesRef {
193
+ readonly source: 'config';
194
+ readonly value: string;
195
+ }
196
+ type GatewaySshSecretEnvMode = 'always' | 'explicit' | 'never';
197
+ interface GatewaySshConfig {
198
+ readonly secretEnv: GatewaySshSecretEnvMode;
199
+ }
200
+ interface GatewayIngressConfig {
201
+ readonly upstreamHeaderTimeoutMs?: number;
202
+ readonly upstreamResponseTimeoutMs?: number;
203
+ }
204
+ interface OpenClawGatewayControlAuthConfig {
205
+ readonly mode: 'token';
206
+ readonly secret: string;
207
+ }
208
+ interface OpenClawAuthLoginProviderConfig {
209
+ readonly profileIds: readonly string[];
210
+ }
211
+ interface OpenClawAuthLoginConfig {
212
+ readonly defaultAgent?: string;
213
+ readonly providers: Readonly<Record<string, OpenClawAuthLoginProviderConfig>>;
214
+ }
215
+ interface GatewayZoneBaseGatewayConfig {
216
+ readonly type: GatewayType;
217
+ readonly memory: string;
218
+ readonly cpus: number;
219
+ readonly port: number;
220
+ readonly ingress?: GatewayIngressConfig;
221
+ readonly config: string;
222
+ readonly stateDir: string;
223
+ readonly runtimeRootfsSize?: string;
224
+ readonly ssh: GatewaySshConfig;
225
+ }
226
+ interface OpenClawGatewayZoneGatewayConfig extends GatewayZoneBaseGatewayConfig {
227
+ readonly type: 'openclaw';
228
+ readonly controlAuth: OpenClawGatewayControlAuthConfig;
229
+ readonly zoneFilesDir: string;
230
+ readonly authProfilesRef?: ConfigGatewayAuthProfilesRef | OnePasswordGatewayAuthProfilesRef | EnvironmentGatewayAuthProfilesRef | undefined;
231
+ readonly authProfilesByAgent?: Readonly<Record<string, ConfigGatewayAuthProfilesRef | OnePasswordGatewayAuthProfilesRef | EnvironmentGatewayAuthProfilesRef>>;
232
+ readonly authLogin?: OpenClawAuthLoginConfig;
233
+ readonly rawEnvSecrets?: readonly string[];
234
+ }
235
+ interface HermesGatewayZoneGatewayConfig extends GatewayZoneBaseGatewayConfig {
236
+ readonly type: 'hermes';
237
+ readonly zoneFilesDir: string;
238
+ readonly profilesByAgent: Readonly<Record<string, string>>;
239
+ }
240
+ interface WorkerGatewayZoneGatewayConfig extends GatewayZoneBaseGatewayConfig {
241
+ readonly type: 'worker';
242
+ }
243
+ type GatewayZoneGatewayConfig = OpenClawGatewayZoneGatewayConfig | HermesGatewayZoneGatewayConfig | WorkerGatewayZoneGatewayConfig;
244
+ interface OnePasswordSecretSourceConfig {
245
+ readonly source: '1password';
246
+ readonly ref: string;
247
+ }
248
+ interface EnvironmentSecretSourceConfig {
249
+ readonly source: 'environment';
250
+ readonly envVar: string;
251
+ }
252
+ interface ConfigSecretSourceConfig {
253
+ readonly source: 'config';
254
+ readonly value: string;
255
+ }
256
+ type SecretSourceConfig = OnePasswordSecretSourceConfig | EnvironmentSecretSourceConfig | ConfigSecretSourceConfig;
257
+ type EnvInjectedGatewaySecretConfig = SecretSourceConfig & {
258
+ readonly audience: 'gateway';
259
+ readonly injection: 'env';
260
+ };
261
+ type HttpMediatedGatewaySecretConfig = SecretSourceConfig & {
262
+ readonly audience: VmAudience;
263
+ readonly injection: 'http-mediation';
264
+ readonly hosts: readonly string[];
265
+ };
266
+ type GatewaySecretConfig = EnvInjectedGatewaySecretConfig | HttpMediatedGatewaySecretConfig;
267
+ declare const gatewayToolPortalTelemetryServiceName: "agent-vm-tool-portal";
268
+ declare const gatewayFrameworkTelemetryServiceNames: Readonly<{
269
+ hermes: "agent-vm-hermes";
270
+ openclaw: "agent-vm-openclaw";
271
+ }>;
272
+ declare const gatewayTelemetrySourcePolicy: Readonly<{
273
+ admitBaggage: false;
274
+ captureContent: false;
275
+ }>;
276
+ declare const gatewayTelemetryAdmissionLimits: Readonly<{
277
+ maxExportBatchRecords: 64;
278
+ maxQueuedRecordsPerSignal: 256;
279
+ maxRecordBytes: 65536;
280
+ }>;
281
+ type GatewayTelemetrySourcePolicy = typeof gatewayTelemetrySourcePolicy;
282
+ type GatewayTelemetryAdmissionLimits = typeof gatewayTelemetryAdmissionLimits;
283
+ interface GatewayTelemetrySignalPolicy {
284
+ readonly traces: boolean;
285
+ readonly metrics: boolean;
286
+ readonly logs: boolean;
287
+ readonly sampleRate: number;
288
+ readonly flushIntervalMs: number;
289
+ }
290
+ interface GatewayTelemetryProducerSafetyContract {
291
+ readonly admissionLimits: GatewayTelemetryAdmissionLimits;
292
+ readonly sourcePolicy: GatewayTelemetrySourcePolicy;
293
+ }
294
+ interface GatewayFrameworkTelemetryProducerConfig extends GatewayTelemetrySignalPolicy, GatewayTelemetryProducerSafetyContract {
295
+ readonly serviceName: (typeof gatewayFrameworkTelemetryServiceNames)[keyof typeof gatewayFrameworkTelemetryServiceNames];
296
+ }
297
+ interface GatewayToolPortalTelemetryProducerConfig extends GatewayTelemetrySignalPolicy, GatewayTelemetryProducerSafetyContract {
298
+ readonly serviceName: typeof gatewayToolPortalTelemetryServiceName;
299
+ }
300
+ declare function createGatewayTelemetryProducerSafetyContract(): GatewayTelemetryProducerSafetyContract;
301
+ interface GatewayZoneObservabilityConfig {
302
+ readonly mode: 'collector';
303
+ readonly collector: {
304
+ readonly host: string;
305
+ readonly grpcPort: number;
306
+ readonly httpPort: number;
307
+ readonly targetHost: string;
308
+ readonly targetGrpcPort: number;
309
+ readonly targetHttpPort: number;
310
+ };
311
+ readonly framework: GatewayFrameworkTelemetryProducerConfig;
312
+ readonly openclaw?: {
313
+ readonly diagnosticsFlags: readonly string[];
314
+ };
315
+ readonly toolPortal: GatewayToolPortalTelemetryProducerConfig;
316
+ }
317
+ /**
318
+ * Zone config as the lifecycle sees it.
319
+ * Decoupled from SystemConfig — the controller maps into this shape.
320
+ */
321
+ interface GatewayZoneConfig {
322
+ readonly id: string;
323
+ readonly agents?: readonly GatewayZoneAgentConfig[];
324
+ readonly gateway: GatewayZoneGatewayConfig;
325
+ readonly toolPortal?: GatewayZoneMcpPortalConfig;
326
+ readonly runtimeMcpServers?: Readonly<Record<string, GatewayZoneMcpServerConfig>>;
327
+ readonly runtimeMediatedSecrets?: Readonly<Record<string, MediatedSecretSpec>>;
328
+ readonly runtimeEnvironment?: Readonly<Record<string, string>>;
329
+ readonly runtimePrivateEnvironment?: Readonly<Partial<Record<GatewayControlPrivateEnvironmentName, string>>>;
330
+ readonly runtimePluginConfigs?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
331
+ readonly gitReadAllowlistRepos?: readonly string[];
332
+ readonly observability?: GatewayZoneObservabilityConfig;
333
+ readonly secrets: Readonly<Record<string, GatewaySecretConfig>>;
334
+ readonly egressHosts: readonly EgressHostConfig[];
335
+ readonly websocketUpgrades?: readonly WebSocketUpgradeConfig[];
336
+ readonly defaultToolVmProfile?: string;
337
+ }
338
+ interface GatewayZoneAgentConfig {
339
+ readonly id: string;
340
+ readonly toolVmProfile?: string | undefined;
341
+ }
342
+ interface GatewayZoneMcpPortalConfig {
343
+ readonly configDir: string;
344
+ }
345
+ interface GatewayZoneMcpServerConfig {
346
+ readonly headers?: Readonly<Record<string, string>>;
347
+ readonly transport: 'streamable-http';
348
+ readonly url: string;
349
+ }
350
+ interface BuildGatewayVmRequirementsOptions {
351
+ readonly controllerPort: number;
352
+ readonly gatewayCacheDir: string;
353
+ readonly projectNamespace: string;
354
+ readonly resolvedSecrets: Record<string, string>;
355
+ readonly runtimeDir: string;
356
+ readonly tcpPool: {
357
+ readonly basePort: number;
358
+ readonly size: number;
359
+ };
360
+ readonly zone: GatewayZoneConfig;
361
+ }
362
+ interface GatewayLifecycleBase {
363
+ /**
364
+ * How to run interactive auth for this gateway type.
365
+ * Absent means the gateway type does not support interactive auth.
366
+ */
367
+ readonly authConfig?: GatewayAuthConfig | undefined;
368
+ /**
369
+ * Build backend-neutral guest workload requirements.
370
+ * Pure data assembly — no side effects or controller authority.
371
+ */
372
+ buildVmRequirements(options: BuildGatewayVmRequirementsOptions): GatewayVmRequirements;
373
+ /**
374
+ * Optional hook to prepare host-side state before the VM boots.
375
+ * Example: writing auth-profiles.json from 1Password.
376
+ */
377
+ prepareHostState?(zone: GatewayZoneConfig, secretResolver: SecretResolver): Promise<void>;
378
+ /**
379
+ * Optional hook to resolve host-state secret dependencies without writing
380
+ * host state. Protected restarts use this before closing a live gateway so
381
+ * secret-resolution failures do not strand the zone without a VM.
382
+ */
383
+ preflightHostState?(zone: GatewayZoneConfig, secretResolver: SecretResolver): Promise<void>;
384
+ }
385
+ interface BuildManagedFrameworkServiceBootInputsOptions {
386
+ readonly resolvedSecrets: Record<string, string>;
387
+ readonly zone: GatewayZoneConfig;
388
+ }
389
+ /**
390
+ * Sensitive framework-service inputs that the controller materializes into
391
+ * the protected, immutable Managed Gateway boot-input directory.
392
+ *
393
+ * This contract intentionally contains no executable, argv, callback,
394
+ * process handle, or controller authority.
395
+ */
396
+ interface ManagedFrameworkServiceBootInputsBase {
397
+ readonly configuration: unknown;
398
+ readonly environment: Readonly<Record<string, string>>;
399
+ }
400
+ interface ManagedFrameworkServiceConfigurationOnlyBootInputs extends ManagedFrameworkServiceBootInputsBase {
401
+ readonly kind: 'configuration-only';
402
+ }
403
+ interface ManagedHermesFrameworkServiceBootInputs extends ManagedFrameworkServiceBootInputsBase {
404
+ readonly kind: 'hermes-managed-scope';
405
+ readonly managedConfigurationSource: string;
406
+ }
407
+ type ManagedFrameworkServiceBootInputs = ManagedFrameworkServiceConfigurationOnlyBootInputs | ManagedHermesFrameworkServiceBootInputs;
408
+ interface ManagedGatewayLifecycle extends GatewayLifecycleBase {
409
+ readonly executionModel: 'managed-gateway';
410
+ /** Build the selected framework half of the exact managed boot contract. */
411
+ buildFrameworkServiceBootMetadata(zone: GatewayZoneConfig): ManagedFrameworkServiceBootMetadata;
412
+ /** Build service-scoped config and environment for protected materialization. */
413
+ buildFrameworkServiceBootInputs(options: BuildManagedFrameworkServiceBootInputsOptions): Promise<ManagedFrameworkServiceBootInputs>;
414
+ }
415
+ interface DirectProcessGatewayLifecycle extends GatewayLifecycleBase {
416
+ readonly executionModel: 'direct-process';
417
+ /**
418
+ * Build the direct-process spec retained only by standalone Worker.
419
+ * Pure data assembly — no side effects.
420
+ */
421
+ buildProcessSpec(zone: GatewayZoneConfig, resolvedSecrets: Record<string, string>): GatewayProcessSpec;
422
+ }
423
+ type GatewayLifecycle = ManagedGatewayLifecycle | DirectProcessGatewayLifecycle;
424
+ //#endregion
425
+ //#region src/health/controller-request-policy.d.ts
426
+ declare const gatewayInternalControllerRequestOperations: readonly ["workspace-git-push", "lease-create", "lease-get", "lease-peek", "lease-renew", "lease-release", "lease-use-start", "lease-heartbeat", "lease-use-end"];
427
+ type GatewayInternalControllerRequestOperation = (typeof gatewayInternalControllerRequestOperations)[number];
428
+ type ControllerRequestPolicyOperation = GatewayInternalControllerRequestOperation;
429
+ declare const dedicatedControllerRequestHealthEventOperations: readonly ["lease-heartbeat", "lease-renew"];
430
+ type DedicatedControllerRequestHealthEventOperation = (typeof dedicatedControllerRequestHealthEventOperations)[number];
431
+ type GenericControllerRequestEventOperation = Exclude<ControllerRequestPolicyOperation, DedicatedControllerRequestHealthEventOperation>;
432
+ declare const genericControllerRequestEventOperations: GenericControllerRequestEventOperation[];
433
+ declare const externalControllerRoutes: readonly ["GET /controller-status", "GET /zones/:zoneId/status", "GET /zones/:zoneId/health", "GET /zones/:zoneId/logs", "POST /zones/:zoneId/credentials/refresh", "POST /zones/:zoneId/destroy", "POST /zones/:zoneId/upgrade", "GET /zones/:zoneId/tasks/:taskId", "POST /zones/:zoneId/worker-tasks", "POST /zones/:zoneId/tasks/:taskId/close", "POST /zones/:zoneId/enable-ssh", "POST /zones/:zoneId/execute-command", "POST /stop-controller"];
434
+ type ExternalControllerRoute = (typeof externalControllerRoutes)[number];
435
+ type ControllerRequestPolicyIdempotency = 'read' | 'safe-mutation' | 'unsafe-mutation';
436
+ interface ControllerRequestPolicyBase {
437
+ readonly idempotency: ControllerRequestPolicyIdempotency;
438
+ readonly timeoutMs: number;
439
+ }
440
+ type ControllerRequestPolicy = (ControllerRequestPolicyBase & {
441
+ readonly maxAttempts: 1;
442
+ readonly retryBaseDelayMs: 0;
443
+ readonly retryEnabled: false;
444
+ readonly retryStatuses: readonly [];
445
+ }) | (ControllerRequestPolicyBase & {
446
+ readonly maxAttempts: number;
447
+ readonly retryBaseDelayMs: number;
448
+ readonly retryEnabled: true;
449
+ readonly retryStatuses: readonly [number, ...number[]];
450
+ });
451
+ type ControllerRequestPolicyTransportErrorCode = 'controller-request-failed' | 'controller-request-timeout';
452
+ declare class ControllerRequestPolicyTransportError extends Error {
453
+ readonly code: ControllerRequestPolicyTransportErrorCode;
454
+ readonly operation: ControllerRequestPolicyOperation;
455
+ constructor(options: {
456
+ readonly cause: unknown;
457
+ readonly code: ControllerRequestPolicyTransportErrorCode;
458
+ readonly operation: ControllerRequestPolicyOperation;
459
+ });
460
+ }
461
+ declare function drainControllerResponseBody(response: Response): Promise<void>;
462
+ declare const controllerRequestPolicies: {
463
+ 'workspace-git-push': {
464
+ idempotency: "unsafe-mutation";
465
+ maxAttempts: 1;
466
+ retryBaseDelayMs: 0;
467
+ retryEnabled: false;
468
+ retryStatuses: [];
469
+ timeoutMs: number;
470
+ };
471
+ 'lease-create': {
472
+ idempotency: "unsafe-mutation";
473
+ maxAttempts: 1;
474
+ retryBaseDelayMs: 0;
475
+ retryEnabled: false;
476
+ retryStatuses: [];
477
+ timeoutMs: number;
478
+ };
479
+ 'lease-get': {
480
+ idempotency: "read";
481
+ maxAttempts: number;
482
+ retryBaseDelayMs: number;
483
+ retryEnabled: true;
484
+ retryStatuses: [number, number];
485
+ timeoutMs: number;
486
+ };
487
+ 'lease-peek': {
488
+ idempotency: "read";
489
+ maxAttempts: number;
490
+ retryBaseDelayMs: number;
491
+ retryEnabled: true;
492
+ retryStatuses: [number, number];
493
+ timeoutMs: number;
494
+ };
495
+ 'lease-renew': {
496
+ idempotency: "safe-mutation";
497
+ maxAttempts: number;
498
+ retryBaseDelayMs: number;
499
+ retryEnabled: true;
500
+ retryStatuses: [number, number, number];
501
+ timeoutMs: number;
502
+ };
503
+ 'lease-release': {
504
+ idempotency: "safe-mutation";
505
+ maxAttempts: number;
506
+ retryBaseDelayMs: number;
507
+ retryEnabled: true;
508
+ retryStatuses: [number, number];
509
+ timeoutMs: number;
510
+ };
511
+ 'lease-use-start': {
512
+ idempotency: "safe-mutation";
513
+ maxAttempts: number;
514
+ retryBaseDelayMs: number;
515
+ retryEnabled: true;
516
+ retryStatuses: [number, number, number];
517
+ timeoutMs: number;
518
+ };
519
+ 'lease-heartbeat': {
520
+ idempotency: "safe-mutation";
521
+ maxAttempts: number;
522
+ retryBaseDelayMs: number;
523
+ retryEnabled: true;
524
+ retryStatuses: [number, number, number];
525
+ timeoutMs: number;
526
+ };
527
+ 'lease-use-end': {
528
+ idempotency: "safe-mutation";
529
+ maxAttempts: number;
530
+ retryBaseDelayMs: number;
531
+ retryEnabled: true;
532
+ retryStatuses: [number, number];
533
+ timeoutMs: number;
534
+ };
535
+ };
536
+ //#endregion
537
+ //#region src/health/agent-vm-health.d.ts
538
+ declare const agentVmHealthEventKinds: readonly ["gateway-service-health", "gateway-control-session", "controller-request", "lease-renew", "lease-heartbeat", "caller-context-rejection", "tool-vm-ssh", "gateway-plugin-health", "agent-channel-provider-health", "gateway-recovery", "gateway-recovery-suspended"];
539
+ type AgentVmHealthEventKind = (typeof agentVmHealthEventKinds)[number];
540
+ declare const agentVmHealthResultKinds: readonly ["ok", "failed", "timeout", "stale"];
541
+ type AgentVmHealthResultKind = (typeof agentVmHealthResultKinds)[number];
542
+ interface AgentVmHealthEventBase {
543
+ readonly causationId?: string | undefined;
544
+ readonly correlationId?: string | undefined;
545
+ readonly observedAtMs: number;
546
+ readonly requestId?: string | undefined;
547
+ readonly result: AgentVmHealthResultKind;
548
+ readonly runId?: string | undefined;
549
+ readonly sessionKeyDigest?: string | undefined;
550
+ readonly toolCallId?: string | undefined;
551
+ readonly traceId?: string | undefined;
552
+ readonly zoneId: string;
553
+ }
554
+ type ToolVmSshHealthOperation = 'command' | 'file-bridge' | 'finalize' | 'probe';
555
+ declare const toolVmLeaseLifecycleEventRoles: readonly ["plugin_observation", "controller_final"];
556
+ type ToolVmLeaseLifecycleEventRole = (typeof toolVmLeaseLifecycleEventRoles)[number];
557
+ declare const toolVmLeaseLifecycleTransitions: readonly ["current_to_stale", "current_to_retired", "deprecated_to_reacquired", "deprecated_to_retired", "stale_to_reacquired", "stale_to_retired", "retired_rejected"];
558
+ type ToolVmLeaseLifecycleTransition = (typeof toolVmLeaseLifecycleTransitions)[number];
559
+ declare const toolVmLeaseReacquiredLifecycleTransitions: readonly ["deprecated_to_reacquired", "stale_to_reacquired"];
560
+ type ToolVmLeaseReacquiredLifecycleTransition = (typeof toolVmLeaseReacquiredLifecycleTransitions)[number];
561
+ type ToolVmLeaseNonReacquiredLifecycleTransition = Exclude<ToolVmLeaseLifecycleTransition, ToolVmLeaseReacquiredLifecycleTransition>;
562
+ declare const toolVmLeaseCallerContextStates: readonly ["ok", "absent", "stale", "session_mismatch", "not_applicable"];
563
+ type ToolVmLeaseCallerContextState = (typeof toolVmLeaseCallerContextStates)[number];
564
+ declare const toolVmLeaseRejectionReasons: readonly ["caller_context_absent", "caller_context_session_mismatch", "caller_context_stale", "lease_absent", "lease_authority_absent", "lease_force_released", "lease_generation_stale", "lease_reacquire_required", "lease_releasing", "lease_retired", "lease_use_tombstoned", "ownership_denied", "runtime_not_ready"];
565
+ type ToolVmLeaseRejectionReason = (typeof toolVmLeaseRejectionReasons)[number];
566
+ interface ToolVmLeaseLifecycleEvidenceBase {
567
+ readonly activeUseId?: string | undefined;
568
+ readonly callerContextState?: ToolVmLeaseCallerContextState | undefined;
569
+ readonly leaseRejectionReason?: ToolVmLeaseRejectionReason | undefined;
570
+ readonly lifecycleEventRole: ToolVmLeaseLifecycleEventRole;
571
+ readonly oldLeaseId: string;
572
+ readonly transitionId: string;
573
+ }
574
+ type ToolVmLeaseLifecycleEvidence = (ToolVmLeaseLifecycleEvidenceBase & {
575
+ readonly lifecycleTransition: ToolVmLeaseReacquiredLifecycleTransition;
576
+ readonly replacementLeaseId: string;
577
+ }) | (ToolVmLeaseLifecycleEvidenceBase & {
578
+ readonly lifecycleTransition: ToolVmLeaseNonReacquiredLifecycleTransition;
579
+ readonly replacementLeaseId?: undefined;
580
+ });
581
+ interface ToolVmLeaseLifecycleAbsentEvidence {
582
+ readonly activeUseId?: undefined;
583
+ readonly callerContextState?: undefined;
584
+ readonly leaseRejectionReason?: undefined;
585
+ readonly lifecycleEventRole?: undefined;
586
+ readonly lifecycleTransition?: undefined;
587
+ readonly oldLeaseId?: undefined;
588
+ readonly replacementLeaseId?: undefined;
589
+ readonly transitionId?: undefined;
590
+ }
591
+ declare const agentChannelProviderHealthKinds: readonly ["healthy", "transitioning", "unhealthy-recoverable", "unhealthy-unrecoverable"];
592
+ type AgentChannelProviderHealthKind = (typeof agentChannelProviderHealthKinds)[number];
593
+ declare const agentChannelProviderHealthDetailKeys: readonly ["closeCode", "providerType", "reconnectAttempt", "reconnecting", "sleepResumeSuspected", "statusCode"];
594
+ type AgentChannelProviderHealthDetailKey = (typeof agentChannelProviderHealthDetailKeys)[number];
595
+ type AgentChannelProviderHealthDetails = Readonly<Partial<Record<AgentChannelProviderHealthDetailKey, boolean | number | string>>>;
596
+ declare const gatewayRecoveryHealthReasons: readonly ["agent-channel-provider-unhealthy", "gateway-control-session-unhealthy", "gateway-service-unhealthy"];
597
+ type GatewayRecoveryHealthReason = (typeof gatewayRecoveryHealthReasons)[number];
598
+ type GatewayRecoveryVmAction = 'gateway-vm-cold-start' | 'gateway-vm-restart';
599
+ type GatewayRecoveryEventAction = GatewayRecoveryVmAction | 'observe-only' | 'operator-required';
600
+ type GatewayRecoveryTimeoutErrorCode = 'recovery-callback-unconfigured' | 'recovery-timeout';
601
+ declare const gatewayControlSessionHealthOperations: readonly ["control-session-hello", "control-session-heartbeat", "control-session-disconnect", "control-session-reconnect"];
602
+ type GatewayControlSessionHealthOperation = (typeof gatewayControlSessionHealthOperations)[number];
603
+ type AgentVmHealthEvent = (AgentVmHealthEventBase & {
604
+ readonly kind: 'caller-context-rejection';
605
+ readonly operation: 'lease_create' | 'lease_get' | 'lease_peek' | 'lease_reacquire' | 'lease_release' | 'lease_renew' | 'lease_use_end' | 'lease_use_heartbeat' | 'lease_use_start';
606
+ readonly reason: 'caller_context_absent' | 'caller_context_session_mismatch' | 'caller_context_stale';
607
+ readonly result: 'failed';
608
+ }) | (AgentVmHealthEventBase & {
609
+ readonly kind: 'gateway-service-health';
610
+ readonly path: string;
611
+ readonly port: number;
612
+ readonly statusCode?: number | undefined;
613
+ }) | (AgentVmHealthEventBase & {
614
+ readonly bootId?: string | undefined;
615
+ readonly connectionId?: string | undefined;
616
+ readonly domain: 'gateway_control';
617
+ readonly elapsedMs: number;
618
+ readonly kind: 'gateway-control-session';
619
+ readonly operation: GatewayControlSessionHealthOperation;
620
+ readonly peerId: string;
621
+ readonly sessionId?: string | undefined;
622
+ }) | (AgentVmHealthEventBase & {
623
+ readonly attempt: number;
624
+ readonly elapsedMs: number;
625
+ readonly errorCode?: string | undefined;
626
+ readonly kind: 'controller-request';
627
+ readonly maxAttempts: number;
628
+ readonly operation: GenericControllerRequestEventOperation;
629
+ readonly statusCode?: number | undefined;
630
+ }) | (AgentVmHealthEventBase & {
631
+ readonly agentId: string;
632
+ readonly elapsedMs: number;
633
+ readonly errorCode?: string | undefined;
634
+ readonly kind: 'lease-renew';
635
+ readonly leaseId: string;
636
+ }) | (AgentVmHealthEventBase & {
637
+ readonly agentId: string;
638
+ readonly elapsedMs: number;
639
+ readonly errorCode?: string | undefined;
640
+ readonly kind: 'lease-heartbeat';
641
+ readonly leaseId: string;
642
+ readonly useId: string;
643
+ }) | (AgentVmHealthEventBase & {
644
+ readonly agentId: string;
645
+ readonly elapsedMs: number;
646
+ readonly errorCode?: string | undefined;
647
+ readonly kind: 'tool-vm-ssh';
648
+ readonly leaseId: string;
649
+ readonly operation: ToolVmSshHealthOperation;
650
+ } & (ToolVmLeaseLifecycleAbsentEvidence | ToolVmLeaseLifecycleEvidence)) | (AgentVmHealthEventBase & {
651
+ readonly gatewayService: GatewayType;
652
+ readonly kind: 'gateway-plugin-health';
653
+ readonly state: 'starting' | 'ready' | 'stopping' | 'failed';
654
+ }) | (AgentVmHealthEventBase & {
655
+ readonly channelProviderId: string;
656
+ readonly details?: AgentChannelProviderHealthDetails | undefined;
657
+ readonly health: AgentChannelProviderHealthKind;
658
+ readonly kind: 'agent-channel-provider-health';
659
+ readonly transitionStartedAtMs?: number | undefined;
660
+ readonly unhealthySinceMs?: number | undefined;
661
+ }) | (AgentVmHealthEventBase & {
662
+ readonly action: 'gateway-vm-restart';
663
+ readonly consecutiveFailures: number;
664
+ readonly cooldownMs: number;
665
+ readonly elapsedMs: number;
666
+ readonly kind: 'gateway-recovery';
667
+ readonly leaseReleaseFailureCount: number;
668
+ readonly newBootedAt: string;
669
+ readonly newHostPid: number;
670
+ readonly newVmId: string;
671
+ readonly oldBootedAt: string;
672
+ readonly oldHostPid: number;
673
+ readonly oldVmId: string;
674
+ readonly operationId?: string | undefined;
675
+ readonly reason: GatewayRecoveryHealthReason;
676
+ readonly result: 'ok';
677
+ }) | (AgentVmHealthEventBase & {
678
+ readonly action: 'gateway-vm-cold-start';
679
+ readonly consecutiveFailures: number;
680
+ readonly cooldownMs: number;
681
+ readonly elapsedMs: number;
682
+ readonly kind: 'gateway-recovery';
683
+ readonly leaseReleaseFailureCount: number;
684
+ readonly newBootedAt: string;
685
+ readonly newHostPid: number;
686
+ readonly newVmId: string;
687
+ readonly oldBootedAt?: undefined;
688
+ readonly oldHostPid?: undefined;
689
+ readonly oldVmId?: undefined;
690
+ readonly operationId?: string | undefined;
691
+ readonly reason: GatewayRecoveryHealthReason;
692
+ readonly result: 'ok';
693
+ }) | (AgentVmHealthEventBase & {
694
+ readonly action: 'gateway-vm-restart';
695
+ readonly consecutiveFailures: number;
696
+ readonly cooldownMs: number;
697
+ readonly elapsedMs: number;
698
+ readonly errorCode: string;
699
+ readonly kind: 'gateway-recovery';
700
+ readonly leaseReleaseFailureCount?: number | undefined;
701
+ readonly oldBootedAt?: string | undefined;
702
+ readonly oldHostPid?: number | undefined;
703
+ readonly oldVmId: string;
704
+ readonly operationId?: string | undefined;
705
+ readonly reason: GatewayRecoveryHealthReason;
706
+ readonly result: 'failed';
707
+ }) | (AgentVmHealthEventBase & {
708
+ readonly action: 'gateway-vm-restart';
709
+ readonly consecutiveFailures: number;
710
+ readonly cooldownMs: number;
711
+ readonly elapsedMs: number;
712
+ readonly errorCode: GatewayRecoveryTimeoutErrorCode;
713
+ readonly kind: 'gateway-recovery';
714
+ readonly leaseReleaseFailureCount?: number | undefined;
715
+ readonly oldBootedAt?: string | undefined;
716
+ readonly oldHostPid?: number | undefined;
717
+ readonly oldVmId?: string | undefined;
718
+ readonly operationId?: string | undefined;
719
+ readonly reason: GatewayRecoveryHealthReason;
720
+ readonly result: 'failed';
721
+ }) | (AgentVmHealthEventBase & {
722
+ readonly action: 'gateway-vm-cold-start' | 'observe-only' | 'operator-required';
723
+ readonly consecutiveFailures: number;
724
+ readonly cooldownMs: number;
725
+ readonly elapsedMs: number;
726
+ readonly errorCode: string;
727
+ readonly kind: 'gateway-recovery';
728
+ readonly leaseReleaseFailureCount?: number | undefined;
729
+ readonly oldBootedAt?: undefined;
730
+ readonly oldHostPid?: undefined;
731
+ readonly oldVmId?: undefined;
732
+ readonly operationId?: string | undefined;
733
+ readonly reason: GatewayRecoveryHealthReason;
734
+ readonly result: 'failed';
735
+ }) | (AgentVmHealthEventBase & {
736
+ readonly action: GatewayRecoveryEventAction;
737
+ readonly consecutiveFailedRecoveries: number;
738
+ readonly consecutiveFailures: number;
739
+ readonly cooldownMs: number;
740
+ readonly errorCode: 'max-failed-recoveries';
741
+ readonly failedRecoveryResetMs: number;
742
+ readonly kind: 'gateway-recovery-suspended';
743
+ readonly operationId?: string | undefined;
744
+ readonly reason: GatewayRecoveryHealthReason;
745
+ readonly result: 'failed';
746
+ });
747
+ declare const zoneHealthStateKinds: readonly ["unknown", "ok", "stale", "failed"];
748
+ type ZoneHealthStateKind = (typeof zoneHealthStateKinds)[number];
749
+ declare const zoneHealthIssueKinds: readonly ["gateway-service-unhealthy", "gateway-control-session-unhealthy", "controller-request-failing", "lease-heartbeat-failing", "lease-renew-failing", "tool-vm-ssh-failing", "gateway-plugin-unhealthy", "agent-channel-provider-unhealthy", "gateway-recovery-failed", "gateway-recovery-suspended", "health-event-stale"];
750
+ type ZoneHealthIssueKind = (typeof zoneHealthIssueKinds)[number];
751
+ interface ZoneHealthIssue {
752
+ readonly kind: ZoneHealthIssueKind;
753
+ readonly latestEvent: AgentVmHealthEvent;
754
+ readonly message: string;
755
+ readonly sinceMs: number;
756
+ }
757
+ type ZoneHealthSnapshot = {
758
+ readonly kind: 'unknown';
759
+ readonly reason: 'no-events';
760
+ readonly zoneId: string;
761
+ } | {
762
+ readonly kind: 'ok';
763
+ readonly latestEvents: readonly AgentVmHealthEvent[];
764
+ readonly zoneId: string;
765
+ } | {
766
+ readonly issues: readonly ZoneHealthIssue[];
767
+ readonly kind: 'stale' | 'failed';
768
+ readonly latestEvents: readonly AgentVmHealthEvent[];
769
+ readonly zoneId: string;
770
+ };
771
+ interface DeriveZoneHealthSnapshotOptions {
772
+ readonly nowMs: number;
773
+ readonly staleAfterMs: number;
774
+ readonly zoneId: string;
775
+ }
776
+ declare function isAgentVmHealthEvent(value: unknown): value is AgentVmHealthEvent;
777
+ declare function healthEventBucketKey(event: AgentVmHealthEvent): string;
778
+ declare function deriveZoneHealthSnapshot(events: readonly AgentVmHealthEvent[], options: DeriveZoneHealthSnapshotOptions): ZoneHealthSnapshot;
779
+ //#endregion
780
+ //#region src/git-read-allowlist.d.ts
781
+ interface NormalizedGitSshReadAllowlistEntry {
782
+ readonly host: string;
783
+ readonly repoPath: string;
784
+ }
785
+ interface NormalizedGitSshReadAllowlist {
786
+ readonly allowedHosts: readonly string[];
787
+ readonly allowedRepos: readonly string[];
788
+ }
789
+ declare function normalizeGitRepoForSshReadAllowlist(repoUrl: string): NormalizedGitSshReadAllowlistEntry | undefined;
790
+ declare function normalizeGitReposForSshReadAllowlist(repoUrls: readonly string[] | undefined): NormalizedGitSshReadAllowlist;
791
+ declare function normalizeGitHubRepoForSshReadAllowlist(repoUrl: string): string | undefined;
792
+ declare function normalizeGitHubReposForSshReadAllowlist(repoUrls: readonly string[] | undefined): readonly string[];
793
+ //#endregion
794
+ //#region src/force-ipv4-egress.d.ts
795
+ /**
796
+ * Canonical NODE_OPTIONS value for forcing IPv4-preference egress
797
+ * in agent-vm VMs.
798
+ *
799
+ * Background: the managed VM synthetic DNS path (when tcpHosts is enabled)
800
+ * returns a per-host IPv4 (reverse-lookable) and a single shared
801
+ * IPv4-mapped IPv6 (::ffff:198.18.0.1, NOT reverse-lookable). Node
802
+ * 20+'s fetch (via undici, autoSelectFamily: true) races both
803
+ * families; when the IPv6 race wins (~5-20% under sequential load),
804
+ * the VM egress router cannot route it and the request fails with a non-JSON
805
+ * 400 (HTTP) or 403 (TLS). The two flags below stop the race:
806
+ *
807
+ * --dns-result-order=ipv4first changes dns.lookup() so
808
+ * IPv4 addresses are listed
809
+ * before IPv6.
810
+ *
811
+ * --no-network-family-autoselection disables Node's Happy
812
+ * Eyeballs entirely. This is
813
+ * the load-bearing flag —
814
+ * --dns-result-order alone
815
+ * doesn't prevent Node from
816
+ * racing both families if
817
+ * IPv4 is slow.
818
+ *
819
+ * Composition: NODE_OPTIONS is whitespace-separated. To add more
820
+ * flags downstream, append rather than replace. Example:
821
+ *
822
+ * NODE_OPTIONS: `${FORCE_IPV4_EGRESS_NODE_OPTIONS} --inspect`
823
+ *
824
+ * Reference: see `shravan-claw@0ddf5f2:docs/wip/debugging/
825
+ * 2026-05-21-lease-keepalive-400-and-discord-403-ipv6-race.md`
826
+ * for the full root-cause analysis. Node-side flag references:
827
+ * https://github.com/nodejs/node/issues/54359 (autoSelectFamily
828
+ * revert recommendation by the Node core team).
829
+ */
830
+ declare const FORCE_IPV4_EGRESS_NODE_OPTIONS = "--dns-result-order=ipv4first --no-network-family-autoselection";
831
+ /**
832
+ * Compose the forced IPv4-preference flags with a user-provided
833
+ * NODE_OPTIONS value (if any).
834
+ *
835
+ * Use this at every site where NODE_OPTIONS is set into a VM env
836
+ * block AFTER a spread of user-controlled secrets, to guarantee
837
+ * the forced flags are always present in the final value even if
838
+ * a zone secret happens to provide its own NODE_OPTIONS.
839
+ *
840
+ * Forced flags come FIRST so they are unambiguously applied.
841
+ * User-provided flags are appended verbatim except for duplicate
842
+ * forced IPv4-preference flags. Node treats NODE_OPTIONS as a
843
+ * whitespace-separated list and all flags apply.
844
+ *
845
+ * Returns just the forced flags if the user value is undefined,
846
+ * empty, or whitespace-only.
847
+ *
848
+ * Examples:
849
+ *
850
+ * composeNodeOptions(undefined)
851
+ * ──► '--dns-result-order=ipv4first --no-network-family-autoselection'
852
+ *
853
+ * composeNodeOptions('')
854
+ * ──► '--dns-result-order=ipv4first --no-network-family-autoselection'
855
+ *
856
+ * composeNodeOptions('--inspect=0.0.0.0:9229')
857
+ * ──► '--dns-result-order=ipv4first --no-network-family-autoselection
858
+ * --inspect=0.0.0.0:9229'
859
+ */
860
+ declare function composeNodeOptions(userValue: string | undefined): string;
861
+ //#endregion
862
+ //#region src/split-resolved-gateway-secrets.d.ts
863
+ interface SplitResolvedSecretsResult {
864
+ readonly environmentSecrets: Record<string, string>;
865
+ readonly mediatedSecrets: Record<string, MediatedSecretSpec>;
866
+ }
867
+ interface MergeRuntimeGatewaySecretsOptions {
868
+ readonly logPrefix?: string;
869
+ readonly runtimeEnvironment?: Readonly<Record<string, string>> | undefined;
870
+ readonly runtimeMediatedSecrets?: Readonly<Record<string, MediatedSecretSpec>> | undefined;
871
+ }
872
+ type SecretInjectionConfig = GatewaySecretConfig;
873
+ interface SplitResolvedSecretsOptions {
874
+ readonly audience: RuntimeVmAudience;
875
+ readonly logPrefix?: string;
876
+ }
877
+ declare function splitResolvedSecretsByInjection(secretConfigs: Readonly<Record<string, SecretInjectionConfig>>, resolvedSecrets: Record<string, string>, options: SplitResolvedSecretsOptions): SplitResolvedSecretsResult;
878
+ type SplitResolvedGatewaySecretsResult = SplitResolvedSecretsResult;
879
+ declare function splitResolvedGatewaySecrets(zone: GatewayZoneConfig, resolvedSecrets: Record<string, string>): SplitResolvedGatewaySecretsResult;
880
+ declare function mergeRuntimeGatewaySecrets(baseSecrets: SplitResolvedSecretsResult, options?: MergeRuntimeGatewaySecretsOptions): SplitResolvedSecretsResult;
881
+ //#endregion
882
+ //#region src/tool-vm-active-use.d.ts
883
+ type ToolVmActiveUseOutcome = 'abandoned' | 'cancelled' | 'completed' | 'failed' | 'timed-out';
884
+ interface ToolVmActiveUseCorrelation {
885
+ readonly messageId?: string | undefined;
886
+ readonly requestId?: string | undefined;
887
+ readonly runId?: string | undefined;
888
+ readonly sessionKeyDigest?: string | undefined;
889
+ readonly toolCallId?: string | undefined;
890
+ readonly traceId?: string | undefined;
891
+ }
892
+ type ToolVmSshOperationPhase = 'completed' | 'failed' | 'probe-succeeded' | 'running' | 'starting';
893
+ type ToolVmSshFailureKind = 'active-use-refreshable-failure' | 'ssh-command-failed' | 'ssh-command-timed-out' | 'ssh-probe-failed';
894
+ interface ToolVmSshFailureReport {
895
+ readonly kind: ToolVmSshFailureKind;
896
+ readonly message: string;
897
+ }
898
+ interface ToolVmSshOperationReport {
899
+ readonly failure?: ToolVmSshFailureReport | undefined;
900
+ readonly probeSucceeded?: boolean | undefined;
901
+ }
902
+ interface ToolVmActiveUseOperationReport {
903
+ readonly observedAtMs: number;
904
+ readonly phase: ToolVmSshOperationPhase;
905
+ readonly ssh?: ToolVmSshOperationReport | undefined;
906
+ }
907
+ interface StartToolVmActiveUseRequest {
908
+ readonly correlation?: ToolVmActiveUseCorrelation | undefined;
909
+ readonly report?: ToolVmActiveUseOperationReport | undefined;
910
+ readonly useId: string;
911
+ }
912
+ interface StartToolVmActiveUseResponse {
913
+ readonly expiresAt: number;
914
+ readonly heartbeatAfterMs: number;
915
+ readonly useId: string;
916
+ }
917
+ interface HeartbeatToolVmActiveUseResponse {
918
+ readonly expiresAt: number;
919
+ readonly heartbeatAfterMs: number;
920
+ }
921
+ interface HeartbeatToolVmActiveUseRequest {
922
+ readonly report?: ToolVmActiveUseOperationReport | undefined;
923
+ }
924
+ interface EndToolVmActiveUseRequest {
925
+ readonly outcome: ToolVmActiveUseOutcome;
926
+ readonly report?: ToolVmActiveUseOperationReport | undefined;
927
+ }
928
+ interface ToolVmActiveUseHandle {
929
+ readonly signal: AbortSignal;
930
+ readonly useId: string;
931
+ dispose(outcome?: ToolVmActiveUseOutcome): Promise<void>;
932
+ end(outcome?: ToolVmActiveUseOutcome): Promise<void>;
933
+ report(report: ToolVmActiveUseOperationReport): void;
934
+ }
935
+ interface CreateToolVmActiveUseHandleOptions {
936
+ readonly correlation?: ToolVmActiveUseCorrelation | undefined;
937
+ readonly endActiveUse: (useId: string, request: EndToolVmActiveUseRequest) => Promise<void>;
938
+ readonly heartbeatActiveUse: (useId: string, request: HeartbeatToolVmActiveUseRequest) => Promise<HeartbeatToolVmActiveUseResponse>;
939
+ readonly heartbeatJitterRatio?: number | undefined;
940
+ readonly isEndErrorTolerable?: (error: unknown) => boolean;
941
+ readonly isHeartbeatErrorRefreshable?: (error: unknown) => boolean;
942
+ readonly logEndFailure?: (error: unknown) => void;
943
+ readonly logHeartbeatFailure?: (error: unknown) => void;
944
+ readonly maxHeartbeatDurationMs?: number | undefined;
945
+ readonly nowImpl?: (() => number) | undefined;
946
+ readonly onRefreshableHeartbeatFailure?: (error: unknown) => Promise<void>;
947
+ readonly randomImpl?: (() => number) | undefined;
948
+ readonly startActiveUse: (request: StartToolVmActiveUseRequest) => Promise<StartToolVmActiveUseResponse>;
949
+ readonly setTimeoutImpl?: typeof setTimeout | undefined;
950
+ readonly clearTimeoutImpl?: typeof clearTimeout | undefined;
951
+ }
952
+ declare function createToolVmActiveUseId(): string;
953
+ declare function isToolVmActiveUseId(value: string): boolean;
954
+ declare function normalizeToolVmActiveUseCorrelation(correlation: unknown): ToolVmActiveUseCorrelation | undefined;
955
+ declare function createToolVmActiveUseHandle(options: CreateToolVmActiveUseHandleOptions): Promise<ToolVmActiveUseHandle>;
956
+ //#endregion
957
+ //#region src/runtime-paths/runtime-path-mapping.d.ts
958
+ declare const TOOL_VM_SCRATCH_GUEST_ROOT = "/scratch";
959
+ declare const OPENCLAW_STATE_VM_ROOT = "/home/openclaw/.openclaw/state";
960
+ declare const OPENCLAW_STATE_SANDBOXES_VM_ROOT = "/home/openclaw/.openclaw/state/sandboxes";
961
+ type RuntimePathNamespace = 'controller-host' | 'openclaw-gateway' | 'tool-vm-guest';
962
+ type RuntimePathPurpose = 'executionCwd' | 'leaseMount';
963
+ interface RuntimePathCapabilities {
964
+ readonly executionCwd: boolean;
965
+ readonly leaseMount: boolean;
966
+ }
967
+ type RuntimePathBacking = {
968
+ readonly kind: 'host-realfs';
969
+ readonly durability: 'durable' | 'runtime' | 'cache';
970
+ readonly backup: 'included' | 'excluded';
971
+ } | {
972
+ readonly kind: 'guest-rootfs-cow';
973
+ readonly durability: 'vm-lifetime';
974
+ };
975
+ type RuntimePathLocations = Partial<Record<RuntimePathNamespace, string>>;
976
+ type RuntimePathHostRealfsLocations = {
977
+ readonly 'controller-host': string;
978
+ readonly 'openclaw-gateway'?: string;
979
+ readonly 'tool-vm-guest'?: string;
980
+ } | {
981
+ readonly 'controller-host'?: string;
982
+ readonly 'openclaw-gateway': string;
983
+ readonly 'tool-vm-guest'?: string;
984
+ };
985
+ interface RuntimePathGuestRootfsCowLocations {
986
+ readonly 'controller-host'?: never;
987
+ readonly 'openclaw-gateway'?: never;
988
+ readonly 'tool-vm-guest': string;
989
+ }
990
+ type RuntimePathGuidanceVisibility = Partial<Record<RuntimePathNamespace, boolean>>;
991
+ interface RuntimePathRootMappingBase {
992
+ readonly capabilities: RuntimePathCapabilities;
993
+ readonly guidanceLabel: string;
994
+ readonly id: string;
995
+ /**
996
+ * False for broad roots like /zone where mounting the root would expose
997
+ * unrelated children; callers must request an explicit child path.
998
+ */
999
+ readonly rootPathAllowed: boolean;
1000
+ readonly showInGuidance?: RuntimePathGuidanceVisibility;
1001
+ }
1002
+ type RuntimePathRootMapping = (RuntimePathRootMappingBase & {
1003
+ readonly backing: Extract<RuntimePathBacking, {
1004
+ readonly kind: 'host-realfs';
1005
+ }>;
1006
+ readonly locations: RuntimePathHostRealfsLocations;
1007
+ }) | (RuntimePathRootMappingBase & {
1008
+ readonly backing: Extract<RuntimePathBacking, {
1009
+ readonly kind: 'guest-rootfs-cow';
1010
+ }>;
1011
+ readonly capabilities: RuntimePathCapabilities & {
1012
+ readonly leaseMount: false;
1013
+ };
1014
+ readonly locations: RuntimePathGuestRootfsCowLocations;
1015
+ });
1016
+ interface RuntimePathMapping {
1017
+ readonly id: string;
1018
+ readonly roots: readonly RuntimePathRootMapping[];
1019
+ }
1020
+ interface TranslateRuntimePathInput {
1021
+ readonly inputPath: string;
1022
+ readonly mapping: RuntimePathMapping;
1023
+ readonly purpose: RuntimePathPurpose;
1024
+ readonly sourceNamespace?: RuntimePathNamespace;
1025
+ readonly targetNamespace: RuntimePathNamespace;
1026
+ }
1027
+ interface RuntimePathTranslation {
1028
+ readonly backing: RuntimePathBacking;
1029
+ readonly capabilities: RuntimePathCapabilities;
1030
+ readonly inputNamespace: RuntimePathNamespace;
1031
+ readonly inputPath: string;
1032
+ readonly mappingId: string;
1033
+ readonly outputNamespace: RuntimePathNamespace;
1034
+ readonly outputPath: string;
1035
+ readonly relativePath: string;
1036
+ readonly rootId: string;
1037
+ }
1038
+ type RuntimePathTranslationErrorCode = 'path-not-absolute' | 'path-parent-traversal' | 'invalid-runtime-root' | 'unknown-runtime-path' | 'purpose-not-allowed' | 'root-path-not-allowed' | 'target-namespace-not-available';
1039
+ interface RuntimePathTranslationError {
1040
+ readonly allowedPathForms: readonly string[];
1041
+ readonly code: RuntimePathTranslationErrorCode;
1042
+ readonly inputPath: string;
1043
+ readonly mappingId: string;
1044
+ readonly message: string;
1045
+ readonly purpose: RuntimePathPurpose;
1046
+ readonly retryGuidance: string;
1047
+ }
1048
+ type TranslateRuntimePathResult = {
1049
+ readonly ok: true;
1050
+ readonly value: RuntimePathTranslation;
1051
+ } | {
1052
+ readonly ok: false;
1053
+ readonly error: RuntimePathTranslationError;
1054
+ };
1055
+ declare function translateRuntimePath(input: TranslateRuntimePathInput): TranslateRuntimePathResult;
1056
+ //#endregion
1057
+ //#region src/tool-vm-lease-id.d.ts
1058
+ declare const toolVmLeaseIdBrand: unique symbol;
1059
+ type ToolVmLeaseId = string & {
1060
+ readonly [toolVmLeaseIdBrand]: true;
1061
+ };
1062
+ declare function createToolVmLeaseId(): ToolVmLeaseId;
1063
+ declare function isToolVmLeaseId(value: unknown): value is ToolVmLeaseId;
1064
+ declare function parseToolVmLeaseId(value: unknown): ToolVmLeaseId;
1065
+ //#endregion
1066
+ //#region src/vm-capability-lease.d.ts
1067
+ /**
1068
+ * Small host-issued capability envelope shared by VM-backed transports. The
1069
+ * transport tag keeps SSH Tool VM leases distinct from future host-side
1070
+ * VM RPC or bridge capabilities without inventing a transport object.
1071
+ */
1072
+ interface VmCapabilityLease<TTransport extends string> {
1073
+ readonly leaseId: string;
1074
+ readonly transport: TTransport;
1075
+ }
1076
+ interface VmSshEndpoint {
1077
+ readonly host: string;
1078
+ readonly identityPem: string;
1079
+ readonly knownHostsLine: string;
1080
+ readonly port: number;
1081
+ readonly user: string;
1082
+ }
1083
+ interface VmSshPublicEndpoint {
1084
+ readonly host: string;
1085
+ readonly port: number;
1086
+ readonly user: string;
1087
+ }
1088
+ interface VmSshLease<TTransport extends string> extends VmCapabilityLease<TTransport> {
1089
+ readonly ssh: VmSshEndpoint;
1090
+ }
1091
+ declare function isVmCapabilityLease<TTransport extends string>(value: unknown, transport: TTransport): value is VmCapabilityLease<TTransport>;
1092
+ declare function isVmSshEndpoint(value: unknown): value is VmSshEndpoint;
1093
+ declare function isVmSshPublicEndpoint(value: unknown): value is VmSshPublicEndpoint;
1094
+ //#endregion
1095
+ //#region src/tool-vm-lease.d.ts
1096
+ declare const defaultToolVmLeaseAuthorityTombstoneTtlMs: number;
1097
+ declare const TOOL_VM_WORK_GUEST_ROOT = "/work";
1098
+ interface ToolVmSshLease extends VmSshLease<'ssh-sandbox'> {
1099
+ readonly agentId: string;
1100
+ readonly idleTtlMs: number;
1101
+ readonly leaseId: ToolVmLeaseId;
1102
+ readonly tcpSlot: number;
1103
+ readonly workdir: string;
1104
+ }
1105
+ interface ToolVmLeasePeek extends VmCapabilityLease<'ssh-sandbox'> {
1106
+ readonly agentId: string;
1107
+ readonly createdAt: number;
1108
+ readonly idleTtlMs: number;
1109
+ readonly lastUsedAt: number;
1110
+ readonly leaseId: ToolVmLeaseId;
1111
+ readonly profileId: string;
1112
+ readonly ssh: VmSshPublicEndpoint;
1113
+ readonly tcpSlot: number;
1114
+ readonly workdir: string;
1115
+ readonly zoneId: string;
1116
+ }
1117
+ declare function isToolVmSshLease(value: unknown): value is ToolVmSshLease;
1118
+ declare function isToolVmLeasePeek(value: unknown): value is ToolVmLeasePeek;
1119
+ //#endregion
1120
+ export { type AgentChannelProviderHealthDetails, type AgentChannelProviderHealthKind, type AgentVmHealthEvent, type AgentVmHealthEventBase, type AgentVmHealthEventKind, type AgentVmHealthResultKind, type BuildGatewayVmRequirementsOptions, type BuildManagedFrameworkServiceBootInputsOptions, type ControllerRequestPolicy, type ControllerRequestPolicyOperation, ControllerRequestPolicyTransportError, type ControllerRequestPolicyTransportErrorCode, type CreateToolVmActiveUseHandleOptions, type DeriveZoneHealthSnapshotOptions, type DirectProcessGatewayLifecycle, type EgressHostConfig, type EndToolVmActiveUseRequest, type EnvInjectedGatewaySecretConfig, type ExternalControllerRoute, FORCE_IPV4_EGRESS_NODE_OPTIONS, GATEWAY_CONTROL_CALLER_CONTEXT_AGENT_AUTHORITY_KEYS_ENV, GATEWAY_CONTROL_CALLER_CONTEXT_PROOF_KEY_ENV, GATEWAY_CONTROL_PRIVATE_ENVIRONMENT_NAMES, type GatewayAuthConfig, type GatewayControlPrivateEnvironmentName, type GatewayControlSessionHealthOperation, type GatewayFrameworkTelemetryProducerConfig, type GatewayHealthCheck, type GatewayIngressConfig, type GatewayLifecycle, type GatewayLifecycleBase, type GatewayProcessSpec, type GatewayRecoveryEventAction, type GatewayRecoveryHealthReason, type GatewayRecoveryTimeoutErrorCode, type GatewayRecoveryVmAction, type GatewaySecretConfig, type GatewayTelemetryAdmissionLimits, type GatewayTelemetryProducerSafetyContract, type GatewayTelemetrySignalPolicy, type GatewayTelemetrySourcePolicy, type GatewayToolPortalTelemetryProducerConfig, type GatewayType, type GatewayVmRequirements, type GatewayZoneAgentConfig, type GatewayZoneConfig, type GatewayZoneMcpPortalConfig, type GatewayZoneObservabilityConfig, type GenericControllerRequestEventOperation, type HeartbeatToolVmActiveUseRequest, type HeartbeatToolVmActiveUseResponse, type HttpMediatedGatewaySecretConfig, type ManagedFrameworkBootEntry, type ManagedFrameworkIngressMetadata, type ManagedFrameworkKind, type ManagedFrameworkReadinessMetadata, type ManagedFrameworkServiceBootInputs, type ManagedFrameworkServiceBootMetadata, type ManagedGatewayBootContract, type ManagedGatewayLifecycle, type ManagedGatewayLogIdentity, type ManagedHermesServiceBootMetadata, type ManagedOpenClawServiceBootMetadata, type ManagedToolPortalReadinessMetadata, type ManagedToolPortalServiceBootMetadata, type NormalizedGitSshReadAllowlist, type NormalizedGitSshReadAllowlistEntry, OPENCLAW_STATE_SANDBOXES_VM_ROOT, OPENCLAW_STATE_VM_ROOT, type RuntimePathBacking, type RuntimePathCapabilities, type RuntimePathGuidanceVisibility, type RuntimePathLocations, type RuntimePathMapping, type RuntimePathNamespace, type RuntimePathPurpose, type RuntimePathRootMapping, type RuntimePathTranslation, type RuntimePathTranslationError, type RuntimePathTranslationErrorCode, type RuntimeVmAudience, type SecretInjectionConfig, type SplitResolvedGatewaySecretsResult, type SplitResolvedSecretsResult, type StartToolVmActiveUseRequest, type StartToolVmActiveUseResponse, TOOL_VM_SCRATCH_GUEST_ROOT, TOOL_VM_WORK_GUEST_ROOT, type ToolVmActiveUseCorrelation, type ToolVmActiveUseHandle, type ToolVmActiveUseOperationReport, type ToolVmActiveUseOutcome, type ToolVmLeaseId, type ToolVmLeasePeek, type ToolVmSshFailureKind, type ToolVmSshFailureReport, type ToolVmSshHealthOperation, type ToolVmSshLease, type ToolVmSshOperationPhase, type ToolVmSshOperationReport, type TranslateRuntimePathInput, type TranslateRuntimePathResult, type VmAudience, type VmCapabilityLease, type VmSshEndpoint, type VmSshLease, type VmSshPublicEndpoint, type WebSocketUpgradeConfig, type ZoneHealthIssue, type ZoneHealthIssueKind, type ZoneHealthSnapshot, type ZoneHealthStateKind, agentVmHealthEventKinds, agentVmHealthResultKinds, buildGatewaySessionLabel, buildToolSessionLabel, composeNodeOptions, controllerRequestPolicies, controllerVmHost, createGatewayTelemetryProducerSafetyContract, createToolVmActiveUseHandle, createToolVmActiveUseId, createToolVmLeaseId, createWebSocketUpgradeRequestGuard, defaultToolVmLeaseAuthorityTombstoneTtlMs, deriveZoneHealthSnapshot, drainControllerResponseBody, egressHostsForAudience, externalControllerRoutes, gatewayControlSessionHealthOperations, gatewayFrameworkTelemetryServiceNames, gatewayRecoveryHealthReasons, gatewayTelemetryAdmissionLimits, gatewayTelemetrySourcePolicy, gatewayToolPortalTelemetryServiceName, gatewayTypeValues, gatewayVmAllowedHosts, genericControllerRequestEventOperations, healthEventBucketKey, isAgentVmHealthEvent, isToolVmActiveUseId, isToolVmLeaseId, isToolVmLeasePeek, isToolVmSshLease, isVmCapabilityLease, isVmSshEndpoint, isVmSshPublicEndpoint, mergeRuntimeGatewaySecrets, normalizeGitHubRepoForSshReadAllowlist, normalizeGitHubReposForSshReadAllowlist, normalizeGitRepoForSshReadAllowlist, normalizeGitReposForSshReadAllowlist, normalizeToolVmActiveUseCorrelation, parseManagedGatewayBootContract, parseToolVmLeaseId, splitResolvedGatewaySecrets, splitResolvedSecretsByInjection, targetsAudience, translateRuntimePath, vmAudienceValues, websocketUpgradesForAudience, workerVmAllowedHosts, zoneHealthIssueKinds, zoneHealthStateKinds };
1121
+ //# sourceMappingURL=index.d.ts.map