@agent-vm/gateway-control-contracts 0.0.113 → 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.
package/dist/index.js CHANGED
@@ -1,9 +1,1433 @@
1
- import { ControlCorrelationSchema, ControlRpcErrorSchema, ControlRpcResultBaseSchema, ControlSessionStateSchema, KnownControlDomainSchema } from "@agent-vm/control-protocol-contracts";
1
+ import { GatewayRuntimeFrameworkIdentitySchema, GatewayRuntimeFrameworkKindSchema, GatewayRuntimeTrustedInvocationContextSchema, GatewayRuntimeTrustedInvocationCorrelationSchema, GatewayRuntimeTrustedInvocationPrincipalSchema, GatewayRuntimeTrustedInvocationPrincipalSchema as GatewayRuntimeTrustedInvocationPrincipalSchema$1, GatewayRuntimeTrustedInvocationRequesterSchema, GatewayStablePrincipalDigestSchema, ManagedAgentProjectionSchema, ManagedAgentProjectionSchema as ManagedAgentProjectionSchema$1 } from "@agent-vm/agent-portal-sdk/contracts";
2
+ import { CONTROL_PROTOCOL_VERSION, ControlCorrelationSchema, ControlRpcErrorSchema, ControlRpcResultBaseSchema, ControlSessionStateSchema, KnownControlDomainSchema } from "@agent-vm/control-protocol-contracts";
2
3
  import { z } from "zod/v4";
4
+ import { Buffer } from "node:buffer";
5
+ import { createHash } from "node:crypto";
6
+ import { jsonObjectSchema, mcpConfigSchema, toolPortalBackendKindSchema, toolPortalConfigSchema } from "@agent-vm/config-contracts";
7
+ //#region src/gateway-control-principal.ts
8
+ function lengthPrefixedUtf8(value) {
9
+ return `${Buffer.byteLength(value, "utf8")}:${value}`;
10
+ }
11
+ function canonicalStablePrincipalMaterial(principal) {
12
+ const frameworkIdentityValue = principal.frameworkIdentity.kind === "openclaw" ? principal.frameworkIdentity.agentId : principal.frameworkIdentity.profileName;
13
+ return [
14
+ principal.agentId,
15
+ principal.frameworkIdentity.kind,
16
+ frameworkIdentityValue,
17
+ principal.toolPortalProfileId,
18
+ principal.profileAssignmentRevision
19
+ ].map(lengthPrefixedUtf8).join("");
20
+ }
21
+ function deriveGatewayControlStablePrincipal(options) {
22
+ return GatewayStablePrincipalDigestSchema.parse(createHash("sha256").update("agent-vm-gateway-stable-principal-v4", "utf8").update("\0").update(canonicalStablePrincipalMaterial(options.principal), "utf8").digest("hex"));
23
+ }
24
+ //#endregion
25
+ //#region src/gateway-runtime-portal-context.ts
26
+ const GatewayRuntimePortalSurfaceClassSchema = z.enum(["mcp", "protected_uds"]);
27
+ const GatewayRuntimePortalSemanticSnapshotSchema = z.object({
28
+ activeRevision: z.string().min(1),
29
+ agentProjections: z.record(z.string().min(1), ManagedAgentProjectionSchema$1),
30
+ bindingRevision: z.string().min(1),
31
+ catalogRevision: z.string().min(1),
32
+ desiredRevision: z.string().min(1),
33
+ profilePolicyRevision: z.string().min(1),
34
+ projectionCohortDigest: z.string().regex(/^projection-cohort:[a-f0-9]{64}$/u),
35
+ providerRevision: z.string().min(1),
36
+ schemaRevision: z.string().min(1),
37
+ schemaVersion: z.literal(1),
38
+ surfaceEligibilityByProfile: z.record(z.string().min(1), z.record(z.string().min(1), z.array(GatewayRuntimePortalSurfaceClassSchema).min(1)))
39
+ }).strict();
40
+ //#endregion
41
+ //#region src/gateway-runtime-approval.ts
42
+ const GATEWAY_RUNTIME_APPROVAL_AUDIENCE = "agent-vm-controller-approval";
43
+ const GatewayRuntimeApprovalFingerprintSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/u);
44
+ function canonicalApprovalJson(value) {
45
+ if (value === null || typeof value === "boolean" || typeof value === "string") return JSON.stringify(value);
46
+ if (typeof value === "number") {
47
+ if (!Number.isFinite(value)) throw new TypeError("Approval fingerprint values must be finite.");
48
+ return JSON.stringify(value);
49
+ }
50
+ if (Array.isArray(value)) return `[${value.map((item) => canonicalApprovalJson(item)).join(",")}]`;
51
+ if (typeof value === "object") return `{${Object.entries(value).filter(([, fieldValue]) => fieldValue !== void 0).toSorted(([leftName], [rightName]) => leftName.localeCompare(rightName)).map(([fieldName, fieldValue]) => `${JSON.stringify(fieldName)}:${canonicalApprovalJson(fieldValue)}`).join(",")}}`;
52
+ throw new TypeError("Approval fingerprint values must be JSON-compatible.");
53
+ }
54
+ const GatewayRuntimeApprovalAuthorityContextSchema = z.object({
55
+ controllerEpoch: z.string().min(1),
56
+ frameworkEpoch: z.string().min(1),
57
+ gatewayEpoch: z.string().min(1),
58
+ runtimeEpoch: z.string().min(1),
59
+ zoneId: z.string().min(1)
60
+ }).strict();
61
+ const GatewayRuntimeApprovalSemanticRevisionCohortSchema = z.object({
62
+ activeRevision: z.string().min(1),
63
+ bindingRevision: z.string().min(1),
64
+ catalogRevision: z.string().min(1),
65
+ profilePolicyRevision: z.string().min(1),
66
+ providerRevision: z.string().min(1),
67
+ schemaRevision: z.string().min(1)
68
+ }).strict();
69
+ const GatewayRuntimeApprovalCallSchema = z.object({
70
+ arguments: jsonObjectSchema,
71
+ id: z.string().min(1),
72
+ name: z.string().min(1),
73
+ namespace: z.string().min(1)
74
+ }).strict();
75
+ const GatewayRuntimeApprovalChallengeIntentSchema = z.object({
76
+ backendKind: toolPortalBackendKindSchema,
77
+ call: GatewayRuntimeApprovalCallSchema,
78
+ operationId: z.string().uuid(),
79
+ semanticRevisions: GatewayRuntimeApprovalSemanticRevisionCohortSchema,
80
+ surfaceClass: GatewayRuntimePortalSurfaceClassSchema,
81
+ trustedContext: GatewayRuntimeTrustedInvocationContextSchema
82
+ }).strict();
83
+ const GatewayRuntimeApprovalChallengeSchema = z.object({
84
+ approvalId: z.string().uuid(),
85
+ createdAt: z.string().datetime(),
86
+ expiresAt: z.string().datetime(),
87
+ fingerprint: GatewayRuntimeApprovalFingerprintSchema,
88
+ intent: GatewayRuntimeApprovalChallengeIntentSchema
89
+ }).strict();
90
+ const approvalDispatchAuthorityShape = {
91
+ approvalId: z.string().uuid(),
92
+ authorityContext: GatewayRuntimeApprovalAuthorityContextSchema,
93
+ expiresAt: z.string().datetime(),
94
+ fingerprint: GatewayRuntimeApprovalFingerprintSchema,
95
+ operationId: z.string().uuid(),
96
+ stablePrincipal: GatewayStablePrincipalDigestSchema
97
+ };
98
+ const GatewayRuntimeMcpProviderDispatchReservationSchema = z.object({
99
+ ...approvalDispatchAuthorityShape,
100
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.mcp_provider),
101
+ reservationId: z.string().uuid()
102
+ }).strict();
103
+ const GatewayRuntimeControllerHostActionDispatchReservationSchema = z.object({
104
+ ...approvalDispatchAuthorityShape,
105
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.controller_host_action),
106
+ reservationId: z.string().uuid()
107
+ }).strict();
108
+ const GatewayRuntimeToolVmRunnerDispatchReservationSchema = z.object({
109
+ ...approvalDispatchAuthorityShape,
110
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.tool_vm_runner),
111
+ reservationId: z.string().uuid()
112
+ }).strict();
113
+ const GatewayRuntimeApprovalDispatchReservationSchema = z.discriminatedUnion("backendKind", [
114
+ GatewayRuntimeMcpProviderDispatchReservationSchema,
115
+ GatewayRuntimeControllerHostActionDispatchReservationSchema,
116
+ GatewayRuntimeToolVmRunnerDispatchReservationSchema
117
+ ]);
118
+ const GatewayRuntimeGatewayDispatchReservationSchema = z.discriminatedUnion("backendKind", [GatewayRuntimeMcpProviderDispatchReservationSchema, GatewayRuntimeToolVmRunnerDispatchReservationSchema]);
119
+ const GatewayRuntimeMcpProviderDispatchGrantSchema = z.object({
120
+ ...approvalDispatchAuthorityShape,
121
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.mcp_provider),
122
+ grantId: z.string().uuid()
123
+ }).strict();
124
+ const GatewayRuntimeToolVmRunnerDispatchGrantSchema = z.object({
125
+ ...approvalDispatchAuthorityShape,
126
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.tool_vm_runner),
127
+ grantId: z.string().uuid()
128
+ }).strict();
129
+ const GatewayRuntimeApprovalDispatchGrantSchema = z.discriminatedUnion("backendKind", [GatewayRuntimeMcpProviderDispatchGrantSchema, GatewayRuntimeToolVmRunnerDispatchGrantSchema]);
130
+ const directDispatchAuthorityShape = {
131
+ fingerprint: GatewayRuntimeApprovalFingerprintSchema,
132
+ kind: z.literal("without-approval"),
133
+ operationId: z.string().uuid()
134
+ };
135
+ const GatewayRuntimeMcpProviderDirectDispatchAuthoritySchema = z.object({
136
+ ...directDispatchAuthorityShape,
137
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.mcp_provider)
138
+ }).strict();
139
+ const GatewayRuntimeToolVmRunnerDirectDispatchAuthoritySchema = z.object({
140
+ ...directDispatchAuthorityShape,
141
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.tool_vm_runner)
142
+ }).strict();
143
+ const GatewayRuntimeControllerHostActionDirectDispatchAuthoritySchema = z.object({
144
+ ...directDispatchAuthorityShape,
145
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.controller_host_action)
146
+ }).strict();
147
+ const GatewayRuntimeMcpProviderApprovalGrantDispatchAuthoritySchema = z.object({
148
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.mcp_provider),
149
+ grant: GatewayRuntimeMcpProviderDispatchGrantSchema,
150
+ kind: z.literal("approval-grant")
151
+ }).strict();
152
+ const GatewayRuntimeToolVmRunnerApprovalGrantDispatchAuthoritySchema = z.object({
153
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.tool_vm_runner),
154
+ grant: GatewayRuntimeToolVmRunnerDispatchGrantSchema,
155
+ kind: z.literal("approval-grant")
156
+ }).strict();
157
+ const GatewayRuntimeControllerHostActionApprovalReservationDispatchAuthoritySchema = z.object({
158
+ backendKind: z.literal(toolPortalBackendKindSchema.enum.controller_host_action),
159
+ kind: z.literal("controller-approval-reservation"),
160
+ reservation: GatewayRuntimeControllerHostActionDispatchReservationSchema
161
+ }).strict();
162
+ const GatewayRuntimeToolPortalDispatchAuthoritySchema = z.union([
163
+ GatewayRuntimeMcpProviderDirectDispatchAuthoritySchema,
164
+ GatewayRuntimeToolVmRunnerDirectDispatchAuthoritySchema,
165
+ GatewayRuntimeControllerHostActionDirectDispatchAuthoritySchema,
166
+ GatewayRuntimeMcpProviderApprovalGrantDispatchAuthoritySchema,
167
+ GatewayRuntimeToolVmRunnerApprovalGrantDispatchAuthoritySchema,
168
+ GatewayRuntimeControllerHostActionApprovalReservationDispatchAuthoritySchema
169
+ ]);
170
+ const GatewayRuntimeApprovalNotDispatchedReasonSchema = z.enum([
171
+ "consumed-without-dispatch",
172
+ "denied",
173
+ "expired",
174
+ "revoked",
175
+ "stale-authority",
176
+ "stale-fingerprint"
177
+ ]);
178
+ const GatewayRuntimeApprovalAmbiguousReasonSchema = z.literal("dispatch-armed");
179
+ const GatewayRuntimeApprovalAdmissionResultSchema = z.discriminatedUnion("kind", [
180
+ z.object({
181
+ challenge: GatewayRuntimeApprovalChallengeSchema,
182
+ kind: z.literal("approval-required")
183
+ }).strict(),
184
+ z.object({
185
+ kind: z.literal("dispatch-reserved"),
186
+ reservation: GatewayRuntimeApprovalDispatchReservationSchema
187
+ }).strict(),
188
+ z.object({
189
+ kind: z.literal("not-dispatched"),
190
+ operationId: z.string().uuid(),
191
+ reason: GatewayRuntimeApprovalNotDispatchedReasonSchema
192
+ }).strict(),
193
+ z.object({
194
+ kind: z.literal("ambiguous"),
195
+ operationId: z.string().uuid(),
196
+ reason: GatewayRuntimeApprovalAmbiguousReasonSchema
197
+ }).strict()
198
+ ]);
199
+ const GatewayRuntimeApprovalArmDispatchCommandSchema = z.object({ reservation: GatewayRuntimeGatewayDispatchReservationSchema }).strict();
200
+ const GatewayRuntimeApprovalArmDispatchResultSchema = z.discriminatedUnion("kind", [
201
+ z.object({
202
+ grant: GatewayRuntimeApprovalDispatchGrantSchema,
203
+ kind: z.literal("dispatch-armed")
204
+ }).strict(),
205
+ z.object({
206
+ kind: z.literal("not-dispatched"),
207
+ operationId: z.string().uuid(),
208
+ reason: GatewayRuntimeApprovalNotDispatchedReasonSchema
209
+ }).strict(),
210
+ z.object({
211
+ kind: z.literal("ambiguous"),
212
+ operationId: z.string().uuid(),
213
+ reason: GatewayRuntimeApprovalAmbiguousReasonSchema
214
+ }).strict()
215
+ ]);
216
+ const GatewayRuntimeApprovalDecisionCommandSchema = z.object({
217
+ approvalId: z.string().uuid(),
218
+ decision: z.enum(["approve", "deny"])
219
+ }).strict();
220
+ const GatewayRuntimeApprovalRevokeCommandSchema = z.object({ approvalId: z.string().uuid() }).strict();
221
+ function deriveGatewayRuntimeApprovalFingerprint(props) {
222
+ return `sha256:${createHash("sha256").update(canonicalApprovalJson(props), "utf8").digest("hex")}`;
223
+ }
224
+ function deriveGatewayRuntimeApprovalId(fingerprint) {
225
+ const hexadecimal = fingerprint.slice(7, 39).split("");
226
+ hexadecimal[12] = "5";
227
+ hexadecimal[16] = (Number.parseInt(hexadecimal[16] ?? "0", 16) & 3 | 8).toString(16);
228
+ const value = hexadecimal.join("");
229
+ return `${value.slice(0, 8)}-${value.slice(8, 12)}-${value.slice(12, 16)}-${value.slice(16, 20)}-${value.slice(20)}`;
230
+ }
231
+ //#endregion
232
+ //#region src/gateway-runtime-readiness-snapshot.ts
233
+ const GATEWAY_RUNTIME_READINESS_SNAPSHOT_VERSION = 1;
234
+ const GATEWAY_RUNTIME_ATTACHMENT_SNAPSHOT_VERSION = 1;
235
+ const BoundedIdentitySchema = z.string().min(1).max(256);
236
+ const PositiveSafeIntegerSchema = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
237
+ const NonNegativeSafeIntegerSchema = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
238
+ const GatewayRuntimeManagedPluginClientKindSchema = z.enum(["openclaw-managed-plugin", "hermes-managed-plugin"]);
239
+ const GatewayRuntimeExpectedAttachmentIdentitySchema = z.object({
240
+ attachmentGeneration: PositiveSafeIntegerSchema,
241
+ clientKind: GatewayRuntimeManagedPluginClientKindSchema,
242
+ configuredAgentIds: z.array(BoundedIdentitySchema).min(1).max(128).readonly(),
243
+ frameworkEpoch: BoundedIdentitySchema,
244
+ gatewayEpoch: BoundedIdentitySchema,
245
+ protocolVersion: PositiveSafeIntegerSchema,
246
+ projectionCohortDigest: z.string().regex(/^projection-cohort:[a-f0-9]{64}$/u),
247
+ runtimeEpoch: BoundedIdentitySchema,
248
+ schemaVersion: PositiveSafeIntegerSchema
249
+ }).strict().superRefine((identity, context) => {
250
+ if (new Set(identity.configuredAgentIds).size !== identity.configuredAgentIds.length) context.addIssue({
251
+ code: "custom",
252
+ message: "Gateway runtime configured agent ids must be unique.",
253
+ path: ["configuredAgentIds"]
254
+ });
255
+ }).readonly();
256
+ const GatewayRuntimeAttachmentSnapshotSchema = z.object({
257
+ connectionId: z.string().uuid().optional(),
258
+ expected: GatewayRuntimeExpectedAttachmentIdentitySchema,
259
+ observationSequence: NonNegativeSafeIntegerSchema,
260
+ snapshotVersion: z.literal(1),
261
+ status: z.enum([
262
+ "awaiting-attachment",
263
+ "attached",
264
+ "attachment-lost",
265
+ "retired"
266
+ ])
267
+ }).strict().superRefine((snapshot, context) => {
268
+ const requiresConnectionIdentity = snapshot.status === "attached" || snapshot.status === "attachment-lost";
269
+ if (requiresConnectionIdentity && snapshot.connectionId === void 0) context.addIssue({
270
+ code: "custom",
271
+ message: "Accepted and lost attachment snapshots require a connection identity.",
272
+ path: ["connectionId"]
273
+ });
274
+ if (!requiresConnectionIdentity && snapshot.connectionId !== void 0) context.addIssue({
275
+ code: "custom",
276
+ message: "Awaiting and retired attachment snapshots cannot claim a connection identity.",
277
+ path: ["connectionId"]
278
+ });
279
+ }).readonly();
280
+ const GatewayRuntimeUdsPublicationSnapshotSchema = z.object({
281
+ identity: z.literal("managed-plugin-private-uds"),
282
+ protocolVersion: PositiveSafeIntegerSchema,
283
+ schemaVersion: PositiveSafeIntegerSchema,
284
+ socketPath: z.string().min(1).max(256).startsWith("/"),
285
+ status: z.enum(["published", "retired"])
286
+ }).strict().readonly();
287
+ const GatewayRuntimeRequiredBackendKindSchema = z.enum([
288
+ "controller_host_action",
289
+ "mcp_provider",
290
+ "tool_vm_runner"
291
+ ]);
292
+ const GatewayRuntimeRequiredBackendsReadinessSchema = z.object({
293
+ readyBackendKinds: z.array(GatewayRuntimeRequiredBackendKindSchema).max(3).readonly(),
294
+ revision: BoundedIdentitySchema,
295
+ status: z.literal("ready")
296
+ }).strict().superRefine((readiness, context) => {
297
+ if (new Set(readiness.readyBackendKinds).size !== readiness.readyBackendKinds.length) context.addIssue({
298
+ code: "custom",
299
+ message: "Gateway runtime ready backend kinds must be unique.",
300
+ path: ["readyBackendKinds"]
301
+ });
302
+ }).readonly();
303
+ const GatewayRuntimeFatalEvidenceSchema = z.object({
304
+ failureCode: BoundedIdentitySchema,
305
+ kind: z.literal("fatal"),
306
+ observedGatewayEpoch: BoundedIdentitySchema,
307
+ processEpoch: BoundedIdentitySchema,
308
+ role: z.enum(["framework-service", "tool-portal-service"]),
309
+ schemaVersion: z.literal(1),
310
+ serviceId: BoundedIdentitySchema
311
+ }).strict().readonly();
312
+ /**
313
+ * Role-local Tool Portal evidence. The controller must join this with framework,
314
+ * backend, ingress, and control-session evidence before admitting the Gateway.
315
+ */
316
+ const GatewayRuntimeReadinessSnapshotSchema = z.object({
317
+ controlEndpoint: z.object({
318
+ identity: z.object({
319
+ bootId: BoundedIdentitySchema,
320
+ controllerEpoch: BoundedIdentitySchema,
321
+ generationId: BoundedIdentitySchema,
322
+ peerId: BoundedIdentitySchema,
323
+ processEpoch: BoundedIdentitySchema,
324
+ zoneId: BoundedIdentitySchema
325
+ }).strict().readonly(),
326
+ listener: z.object({
327
+ host: z.string().min(1).max(253),
328
+ port: z.number().int().min(1).max(65535),
329
+ readyPath: z.string().min(1).max(256).startsWith("/"),
330
+ socketPath: z.string().min(1).max(256).startsWith("/")
331
+ }).strict().readonly()
332
+ }).strict().readonly(),
333
+ kind: z.literal("tool-portal-role-readiness"),
334
+ providerRevision: BoundedIdentitySchema,
335
+ requiredBackends: GatewayRuntimeRequiredBackendsReadinessSchema,
336
+ semanticRevision: BoundedIdentitySchema,
337
+ serviceIdentity: z.object({
338
+ processEpoch: BoundedIdentitySchema,
339
+ role: z.literal("tool-portal"),
340
+ serviceId: BoundedIdentitySchema
341
+ }).strict().readonly(),
342
+ snapshotVersion: z.literal(1),
343
+ uds: z.object({
344
+ attachment: GatewayRuntimeAttachmentSnapshotSchema,
345
+ publication: GatewayRuntimeUdsPublicationSnapshotSchema
346
+ }).strict().readonly()
347
+ }).strict().superRefine((snapshot, context) => {
348
+ if (snapshot.controlEndpoint.identity.processEpoch !== snapshot.serviceIdentity.processEpoch) context.addIssue({
349
+ code: "custom",
350
+ message: "Gateway runtime service and control endpoint process epochs must match.",
351
+ path: [
352
+ "controlEndpoint",
353
+ "identity",
354
+ "processEpoch"
355
+ ]
356
+ });
357
+ if (snapshot.uds.publication.status === "retired" && snapshot.uds.attachment.status !== "retired") context.addIssue({
358
+ code: "custom",
359
+ message: "A retired UDS publication requires a retired attachment lifecycle.",
360
+ path: [
361
+ "uds",
362
+ "attachment",
363
+ "status"
364
+ ]
365
+ });
366
+ }).readonly();
367
+ function freezeExpectedAttachmentIdentity(identity) {
368
+ return Object.freeze({
369
+ ...identity,
370
+ configuredAgentIds: Object.freeze([...identity.configuredAgentIds].toSorted())
371
+ });
372
+ }
373
+ function createGatewayRuntimeAttachmentSnapshot(input) {
374
+ const parsed = GatewayRuntimeAttachmentSnapshotSchema.parse(input);
375
+ return Object.freeze({
376
+ ...parsed,
377
+ expected: freezeExpectedAttachmentIdentity(parsed.expected)
378
+ });
379
+ }
380
+ function createGatewayRuntimeReadinessSnapshot(input) {
381
+ const parsed = GatewayRuntimeReadinessSnapshotSchema.parse(input);
382
+ const attachment = createGatewayRuntimeAttachmentSnapshot(parsed.uds.attachment);
383
+ return Object.freeze({
384
+ ...parsed,
385
+ controlEndpoint: Object.freeze({
386
+ identity: Object.freeze({ ...parsed.controlEndpoint.identity }),
387
+ listener: Object.freeze({ ...parsed.controlEndpoint.listener })
388
+ }),
389
+ serviceIdentity: Object.freeze({ ...parsed.serviceIdentity }),
390
+ requiredBackends: Object.freeze({
391
+ ...parsed.requiredBackends,
392
+ readyBackendKinds: Object.freeze([...parsed.requiredBackends.readyBackendKinds].toSorted())
393
+ }),
394
+ uds: Object.freeze({
395
+ attachment,
396
+ publication: Object.freeze({ ...parsed.uds.publication })
397
+ })
398
+ });
399
+ }
400
+ //#endregion
401
+ //#region src/gateway-control-admission.ts
402
+ const GATEWAY_CONTROL_ADMISSION_LIMITS = {
403
+ authority: {
404
+ maxBytes: 1572864,
405
+ maxMessages: 96
406
+ },
407
+ diagnostic: {
408
+ maxBytes: 1048576,
409
+ maxMessages: 64
410
+ },
411
+ liveness: {
412
+ maxBytes: 1048576,
413
+ maxMessages: 64
414
+ },
415
+ maxFrameBytes: 65536,
416
+ perPrincipalAuthority: {
417
+ maxBytes: 131072,
418
+ maxMessages: 8
419
+ },
420
+ safety: {
421
+ maxBytes: 524288,
422
+ maxMessages: 32
423
+ }
424
+ };
425
+ const GATEWAY_CONTROL_PROCESS_ADMISSION_LIMITS = {
426
+ maxActiveSessions: 32,
427
+ maxNonSafetyBytes: 33554432,
428
+ maxNonSafetyMessages: 2048
429
+ };
430
+ function dequeueFirstCoalescedMessage(messages) {
431
+ const first = messages.entries().next().value;
432
+ if (first === void 0) return;
433
+ messages.delete(first[0]);
434
+ return first[1];
435
+ }
436
+ const serviceCycle = [
437
+ "safety",
438
+ "safety",
439
+ "safety",
440
+ "safety",
441
+ "safety",
442
+ "safety",
443
+ "safety",
444
+ "safety",
445
+ "authority",
446
+ "authority",
447
+ "authority",
448
+ "authority",
449
+ "liveness",
450
+ "liveness",
451
+ "diagnostic"
452
+ ];
453
+ function canReserve(accounting, byteLength, limits) {
454
+ return accounting.byteCount + byteLength <= limits.maxBytes && accounting.messageCount + 1 <= limits.maxMessages;
455
+ }
456
+ function release(accounting, byteLength) {
457
+ accounting.byteCount -= byteLength;
458
+ accounting.messageCount -= 1;
459
+ }
460
+ function requirePositiveLimit(name, value) {
461
+ if (!Number.isSafeInteger(value) || value <= 0) throw new RangeError(`${name} must be a positive safe integer.`);
462
+ }
463
+ function validateMessage(message) {
464
+ if (message.id.length === 0 || !Number.isSafeInteger(message.byteLength) || message.byteLength <= 0) return {
465
+ reason: "invalid_message",
466
+ status: "fence"
467
+ };
468
+ if (message.byteLength > GATEWAY_CONTROL_ADMISSION_LIMITS.maxFrameBytes) return {
469
+ reason: "frame_too_large",
470
+ status: "fence"
471
+ };
472
+ if (message.messageClass === "authority" && (message.stablePrincipal === void 0 || message.stablePrincipal.length === 0)) return {
473
+ reason: "invalid_message",
474
+ status: "fence"
475
+ };
476
+ if ((message.messageClass === "diagnostic" || message.messageClass === "liveness") && (message.coalesceKey === void 0 || message.coalesceKey.length === 0)) return {
477
+ reason: "invalid_message",
478
+ status: "fence"
479
+ };
480
+ }
481
+ function isGatewayControlProcessAdmissionMessage(message) {
482
+ return "zoneId" in message && typeof message.zoneId === "string";
483
+ }
484
+ function gatewayControlProcessCoalescingKey(message) {
485
+ return message.messageClass === "liveness" || message.messageClass === "diagnostic" ? `${message.messageClass}\u0000${message.coalesceKey ?? ""}` : void 0;
486
+ }
487
+ function createGatewayControlAdmissionScheduler() {
488
+ const safety = [];
489
+ const safetyAccounting = {
490
+ byteCount: 0,
491
+ messageCount: 0
492
+ };
493
+ const authorityByPrincipal = /* @__PURE__ */ new Map();
494
+ const authorityPrincipalOrder = [];
495
+ const authorityAccounting = {
496
+ byteCount: 0,
497
+ messageCount: 0
498
+ };
499
+ const livenessByKey = /* @__PURE__ */ new Map();
500
+ const livenessAccounting = {
501
+ byteCount: 0,
502
+ messageCount: 0
503
+ };
504
+ const diagnosticByKey = /* @__PURE__ */ new Map();
505
+ const diagnosticAccounting = {
506
+ byteCount: 0,
507
+ messageCount: 0
508
+ };
509
+ const inFlightMessages = /* @__PURE__ */ new Map();
510
+ let serviceCursor = 0;
511
+ let authorityPrincipalCursor = 0;
512
+ let coalescedMessages = 0;
513
+ let droppedMessages = 0;
514
+ let fencedMessages = 0;
515
+ let refusedMessages = 0;
516
+ let shedMessages = 0;
517
+ const dequeueAuthority = () => {
518
+ if (authorityPrincipalOrder.length === 0) return;
519
+ for (let offset = 0; offset < authorityPrincipalOrder.length; offset += 1) {
520
+ const index = (authorityPrincipalCursor + offset) % authorityPrincipalOrder.length;
521
+ const principal = authorityPrincipalOrder[index];
522
+ if (principal === void 0) continue;
523
+ const queue = authorityByPrincipal.get(principal);
524
+ const message = queue?.messages.shift();
525
+ if (queue === void 0 || message === void 0) continue;
526
+ authorityPrincipalCursor = (index + 1) % authorityPrincipalOrder.length;
527
+ return message;
528
+ }
529
+ };
530
+ const dequeueClass = (messageClass) => {
531
+ switch (messageClass) {
532
+ case "safety": return safety.shift();
533
+ case "authority": return dequeueAuthority();
534
+ case "liveness": return dequeueFirstCoalescedMessage(livenessByKey);
535
+ case "diagnostic": return dequeueFirstCoalescedMessage(diagnosticByKey);
536
+ }
537
+ throw new Error("unsupported gateway control admission class");
538
+ };
539
+ return {
540
+ cancelQueued() {
541
+ const cancelled = [];
542
+ for (const message of safety.splice(0)) {
543
+ release(safetyAccounting, message.byteLength);
544
+ cancelled.push(message);
545
+ }
546
+ for (const [principal, queue] of authorityByPrincipal) {
547
+ for (const message of queue.messages.splice(0)) {
548
+ release(queue, message.byteLength);
549
+ release(authorityAccounting, message.byteLength);
550
+ cancelled.push(message);
551
+ }
552
+ if (queue.messageCount === 0) authorityByPrincipal.delete(principal);
553
+ }
554
+ for (let index = authorityPrincipalOrder.length - 1; index >= 0; index -= 1) if (!authorityByPrincipal.has(authorityPrincipalOrder[index] ?? "")) authorityPrincipalOrder.splice(index, 1);
555
+ authorityPrincipalCursor = authorityPrincipalOrder.length === 0 ? 0 : Math.min(authorityPrincipalCursor, authorityPrincipalOrder.length - 1);
556
+ for (const message of livenessByKey.values()) {
557
+ release(livenessAccounting, message.byteLength);
558
+ cancelled.push(message);
559
+ }
560
+ livenessByKey.clear();
561
+ for (const message of diagnosticByKey.values()) {
562
+ release(diagnosticAccounting, message.byteLength);
563
+ cancelled.push(message);
564
+ }
565
+ diagnosticByKey.clear();
566
+ return cancelled;
567
+ },
568
+ complete(completionToken) {
569
+ const message = inFlightMessages.get(completionToken);
570
+ if (message === void 0 || !inFlightMessages.delete(completionToken)) throw new Error("gateway control admission message is not in flight");
571
+ switch (message.messageClass) {
572
+ case "safety":
573
+ release(safetyAccounting, message.byteLength);
574
+ return;
575
+ case "authority": {
576
+ const principal = message.stablePrincipal ?? "";
577
+ const queue = authorityByPrincipal.get(principal);
578
+ if (queue === void 0) throw new Error("gateway control authority principal is not admitted");
579
+ release(queue, message.byteLength);
580
+ release(authorityAccounting, message.byteLength);
581
+ if (queue.messageCount === 0) {
582
+ authorityByPrincipal.delete(principal);
583
+ const index = authorityPrincipalOrder.indexOf(principal);
584
+ if (index >= 0) {
585
+ authorityPrincipalOrder.splice(index, 1);
586
+ authorityPrincipalCursor = authorityPrincipalOrder.length === 0 ? 0 : Math.min(authorityPrincipalCursor, authorityPrincipalOrder.length - 1);
587
+ }
588
+ }
589
+ return;
590
+ }
591
+ case "liveness":
592
+ release(livenessAccounting, message.byteLength);
593
+ return;
594
+ case "diagnostic":
595
+ release(diagnosticAccounting, message.byteLength);
596
+ return;
597
+ }
598
+ },
599
+ enqueue(message) {
600
+ const invalid = validateMessage(message);
601
+ if (invalid !== void 0) {
602
+ fencedMessages += 1;
603
+ return invalid;
604
+ }
605
+ switch (message.messageClass) {
606
+ case "safety":
607
+ if (!canReserve(safetyAccounting, message.byteLength, GATEWAY_CONTROL_ADMISSION_LIMITS.safety)) {
608
+ fencedMessages += 1;
609
+ return {
610
+ reason: "safety_capacity",
611
+ status: "fence"
612
+ };
613
+ }
614
+ safety.push(message);
615
+ safetyAccounting.byteCount += message.byteLength;
616
+ safetyAccounting.messageCount += 1;
617
+ return { status: "admitted" };
618
+ case "authority": {
619
+ const principal = message.stablePrincipal ?? "";
620
+ const queue = authorityByPrincipal.get(principal) ?? {
621
+ byteCount: 0,
622
+ messageCount: 0,
623
+ messages: []
624
+ };
625
+ if (!canReserve(queue, message.byteLength, GATEWAY_CONTROL_ADMISSION_LIMITS.perPrincipalAuthority)) {
626
+ refusedMessages += 1;
627
+ return {
628
+ reason: "principal_capacity",
629
+ status: "refused"
630
+ };
631
+ }
632
+ if (!canReserve(authorityAccounting, message.byteLength, GATEWAY_CONTROL_ADMISSION_LIMITS.authority)) {
633
+ fencedMessages += 1;
634
+ return {
635
+ reason: "authority_capacity",
636
+ status: "fence"
637
+ };
638
+ }
639
+ if (!authorityByPrincipal.has(principal)) {
640
+ authorityByPrincipal.set(principal, queue);
641
+ authorityPrincipalOrder.push(principal);
642
+ }
643
+ queue.messages.push(message);
644
+ queue.byteCount += message.byteLength;
645
+ queue.messageCount += 1;
646
+ authorityAccounting.byteCount += message.byteLength;
647
+ authorityAccounting.messageCount += 1;
648
+ return { status: "admitted" };
649
+ }
650
+ case "liveness":
651
+ case "diagnostic": {
652
+ const isLiveness = message.messageClass === "liveness";
653
+ const messages = isLiveness ? livenessByKey : diagnosticByKey;
654
+ const accounting = isLiveness ? livenessAccounting : diagnosticAccounting;
655
+ const limits = isLiveness ? GATEWAY_CONTROL_ADMISSION_LIMITS.liveness : GATEWAY_CONTROL_ADMISSION_LIMITS.diagnostic;
656
+ const key = message.coalesceKey ?? "";
657
+ const prior = messages.get(key);
658
+ const nextBytes = accounting.byteCount - (prior?.byteLength ?? 0) + message.byteLength;
659
+ const nextMessages = accounting.messageCount + (prior === void 0 ? 1 : 0);
660
+ if (nextBytes > limits.maxBytes || nextMessages > limits.maxMessages) {
661
+ if (isLiveness) {
662
+ shedMessages += 1;
663
+ return {
664
+ reason: "liveness_capacity",
665
+ status: "shed"
666
+ };
667
+ }
668
+ droppedMessages += 1;
669
+ return {
670
+ reason: "diagnostic_capacity",
671
+ status: "dropped"
672
+ };
673
+ }
674
+ messages.set(key, message);
675
+ accounting.byteCount = nextBytes;
676
+ accounting.messageCount = nextMessages;
677
+ if (prior !== void 0) coalescedMessages += 1;
678
+ return prior === void 0 ? { status: "admitted" } : {
679
+ replacedMessage: prior,
680
+ status: "replaced"
681
+ };
682
+ }
683
+ }
684
+ throw new Error("unsupported gateway control admission class");
685
+ },
686
+ dequeue(options = {}) {
687
+ for (let offset = 0; offset < serviceCycle.length; offset += 1) {
688
+ const index = (serviceCursor + offset) % serviceCycle.length;
689
+ const messageClass = serviceCycle[index];
690
+ if (messageClass === void 0) continue;
691
+ if (options.allowedMessageClasses !== void 0 && !options.allowedMessageClasses.includes(messageClass)) continue;
692
+ const message = dequeueClass(messageClass);
693
+ if (message !== void 0) {
694
+ serviceCursor = (index + 1) % serviceCycle.length;
695
+ const completionToken = Object.freeze({ completionTokenId: Symbol("gateway-control-admission-completion") });
696
+ inFlightMessages.set(completionToken, message);
697
+ return {
698
+ completionToken,
699
+ message
700
+ };
701
+ }
702
+ }
703
+ },
704
+ diagnostics() {
705
+ return {
706
+ authorityBytes: authorityAccounting.byteCount,
707
+ authorityMessages: authorityAccounting.messageCount,
708
+ diagnosticBytes: diagnosticAccounting.byteCount,
709
+ diagnosticMessages: diagnosticAccounting.messageCount,
710
+ livenessBytes: livenessAccounting.byteCount,
711
+ livenessMessages: livenessAccounting.messageCount,
712
+ safetyBytes: safetyAccounting.byteCount,
713
+ safetyMessages: safetyAccounting.messageCount,
714
+ coalescedMessages,
715
+ droppedMessages,
716
+ fencedMessages,
717
+ refusedMessages,
718
+ shedMessages
719
+ };
720
+ }
721
+ };
722
+ }
723
+ function createGatewayControlProcessAdmission(options = {}) {
724
+ const maxActiveSessions = options.maxActiveSessions ?? GATEWAY_CONTROL_PROCESS_ADMISSION_LIMITS.maxActiveSessions;
725
+ const maxNonSafetyBytes = options.maxNonSafetyBytes ?? GATEWAY_CONTROL_PROCESS_ADMISSION_LIMITS.maxNonSafetyBytes;
726
+ const maxNonSafetyMessages = options.maxNonSafetyMessages ?? GATEWAY_CONTROL_PROCESS_ADMISSION_LIMITS.maxNonSafetyMessages;
727
+ const schedulersByZone = /* @__PURE__ */ new Map();
728
+ const queuedCoalescibleMessagesByZone = /* @__PURE__ */ new Map();
729
+ const inFlightMessages = /* @__PURE__ */ new Map();
730
+ const zoneOrder = [];
731
+ let zoneCursor = 0;
732
+ let nonSafetyBytes = 0;
733
+ let nonSafetyMessages = 0;
734
+ requirePositiveLimit("maxActiveSessions", maxActiveSessions);
735
+ requirePositiveLimit("maxNonSafetyBytes", maxNonSafetyBytes);
736
+ requirePositiveLimit("maxNonSafetyMessages", maxNonSafetyMessages);
737
+ return {
738
+ complete(completionToken) {
739
+ const message = inFlightMessages.get(completionToken);
740
+ if (message === void 0 || !inFlightMessages.delete(completionToken)) throw new Error("gateway control process admission message is not in flight");
741
+ const scheduler = schedulersByZone.get(message.zoneId);
742
+ if (scheduler === void 0) throw new Error("gateway control process admission zone is not registered");
743
+ scheduler.complete(completionToken);
744
+ if (message.messageClass !== "safety") {
745
+ nonSafetyMessages -= 1;
746
+ nonSafetyBytes -= message.byteLength;
747
+ }
748
+ },
749
+ registerZone(zoneId) {
750
+ if (zoneId.length === 0) return { status: "capacity_refused" };
751
+ if (schedulersByZone.has(zoneId)) return { status: "admitted" };
752
+ if (schedulersByZone.size >= maxActiveSessions) return { status: "capacity_refused" };
753
+ schedulersByZone.set(zoneId, createGatewayControlAdmissionScheduler());
754
+ queuedCoalescibleMessagesByZone.set(zoneId, /* @__PURE__ */ new Map());
755
+ zoneOrder.push(zoneId);
756
+ return { status: "admitted" };
757
+ },
758
+ unregisterZone(zoneId) {
759
+ const scheduler = schedulersByZone.get(zoneId);
760
+ if (scheduler === void 0) return;
761
+ for (;;) {
762
+ const work = scheduler.dequeue();
763
+ if (work === void 0) break;
764
+ const { completionToken, message } = work;
765
+ if (message.messageClass !== "safety") {
766
+ nonSafetyBytes -= message.byteLength;
767
+ nonSafetyMessages -= 1;
768
+ }
769
+ scheduler.complete(completionToken);
770
+ }
771
+ for (const [completionToken, message] of inFlightMessages) {
772
+ if (message.zoneId !== zoneId) continue;
773
+ inFlightMessages.delete(completionToken);
774
+ scheduler.complete(completionToken);
775
+ if (message.messageClass !== "safety") {
776
+ nonSafetyBytes -= message.byteLength;
777
+ nonSafetyMessages -= 1;
778
+ }
779
+ }
780
+ schedulersByZone.delete(zoneId);
781
+ queuedCoalescibleMessagesByZone.delete(zoneId);
782
+ const index = zoneOrder.indexOf(zoneId);
783
+ if (index >= 0) {
784
+ zoneOrder.splice(index, 1);
785
+ zoneCursor = zoneOrder.length === 0 ? 0 : Math.min(zoneCursor, zoneOrder.length - 1);
786
+ }
787
+ },
788
+ enqueue(message) {
789
+ const scheduler = schedulersByZone.get(message.zoneId);
790
+ if (scheduler === void 0) return {
791
+ reason: "global_capacity",
792
+ status: "refused"
793
+ };
794
+ const coalescingKey = gatewayControlProcessCoalescingKey(message);
795
+ const priorCoalescibleMessage = coalescingKey === void 0 ? void 0 : queuedCoalescibleMessagesByZone.get(message.zoneId)?.get(coalescingKey);
796
+ const nonSafetyMessageDelta = priorCoalescibleMessage === void 0 ? 1 : 0;
797
+ const nonSafetyByteDelta = message.byteLength - (priorCoalescibleMessage?.byteLength ?? 0);
798
+ if (message.messageClass !== "safety" && (nonSafetyMessages + nonSafetyMessageDelta > maxNonSafetyMessages || nonSafetyBytes + nonSafetyByteDelta > maxNonSafetyBytes)) return message.messageClass === "authority" ? {
799
+ reason: "global_capacity",
800
+ status: "refused"
801
+ } : message.messageClass === "liveness" ? {
802
+ reason: "global_capacity",
803
+ status: "shed"
804
+ } : {
805
+ reason: "global_capacity",
806
+ status: "dropped"
807
+ };
808
+ const before = scheduler.diagnostics();
809
+ const result = scheduler.enqueue(message);
810
+ if (message.messageClass !== "safety" && (result.status === "admitted" || result.status === "replaced")) {
811
+ const after = scheduler.diagnostics();
812
+ const beforeMessages = before.authorityMessages + before.livenessMessages + before.diagnosticMessages;
813
+ const afterMessages = after.authorityMessages + after.livenessMessages + after.diagnosticMessages;
814
+ const beforeBytes = before.authorityBytes + before.livenessBytes + before.diagnosticBytes;
815
+ const afterBytes = after.authorityBytes + after.livenessBytes + after.diagnosticBytes;
816
+ nonSafetyMessages += afterMessages - beforeMessages;
817
+ nonSafetyBytes += afterBytes - beforeBytes;
818
+ if (coalescingKey !== void 0) queuedCoalescibleMessagesByZone.get(message.zoneId)?.set(coalescingKey, message);
819
+ }
820
+ return result;
821
+ },
822
+ dequeue() {
823
+ if (zoneOrder.length === 0) return;
824
+ for (let offset = 0; offset < zoneOrder.length; offset += 1) {
825
+ const index = (zoneCursor + offset) % zoneOrder.length;
826
+ const zoneId = zoneOrder[index];
827
+ const work = (zoneId === void 0 ? void 0 : schedulersByZone.get(zoneId))?.dequeue();
828
+ if (zoneId === void 0 || work === void 0) continue;
829
+ const { completionToken, message } = work;
830
+ if (!isGatewayControlProcessAdmissionMessage(message) || message.zoneId !== zoneId) throw new Error("gateway control process admission message lost its zone identity");
831
+ const coalescingKey = gatewayControlProcessCoalescingKey(message);
832
+ if (coalescingKey !== void 0) {
833
+ const queuedMessages = queuedCoalescibleMessagesByZone.get(zoneId);
834
+ if (queuedMessages?.get(coalescingKey) === message) queuedMessages.delete(coalescingKey);
835
+ }
836
+ zoneCursor = (index + 1) % zoneOrder.length;
837
+ inFlightMessages.set(completionToken, message);
838
+ return {
839
+ completionToken,
840
+ message
841
+ };
842
+ }
843
+ },
844
+ diagnostics() {
845
+ return {
846
+ activeSessions: schedulersByZone.size,
847
+ nonSafetyBytes,
848
+ nonSafetyMessages
849
+ };
850
+ }
851
+ };
852
+ }
853
+ //#endregion
854
+ //#region src/gateway-control-admission-executor.ts
855
+ const GATEWAY_CONTROL_ADMISSION_EXECUTION_LIMITS = {
856
+ authority: 4,
857
+ diagnostic: 1,
858
+ liveness: 2,
859
+ safety: 8
860
+ };
861
+ const GATEWAY_CONTROL_ADMISSION_CLASSES = [
862
+ "authority",
863
+ "diagnostic",
864
+ "liveness",
865
+ "safety"
866
+ ];
867
+ function executionMessage(request, work) {
868
+ return {
869
+ byteLength: request.byteLength,
870
+ ...request.coalesceKey === void 0 ? {} : { coalesceKey: request.coalesceKey },
871
+ id: request.id,
872
+ messageClass: request.messageClass,
873
+ payload: work,
874
+ ...request.stablePrincipal === void 0 ? {} : { stablePrincipal: request.stablePrincipal }
875
+ };
876
+ }
877
+ function createGatewayControlAdmissionExecutor(options = {}) {
878
+ const scheduler = createGatewayControlAdmissionScheduler();
879
+ const scheduleImmediate = options.scheduleImmediate ?? ((callback) => setImmediate(callback));
880
+ const executionLimits = {
881
+ ...GATEWAY_CONTROL_ADMISSION_EXECUTION_LIMITS,
882
+ ...options.executionLimits
883
+ };
884
+ const activeByClass = {
885
+ authority: 0,
886
+ diagnostic: 0,
887
+ liveness: 0,
888
+ safety: 0
889
+ };
890
+ let pumpScheduled = false;
891
+ let admissionGeneration = 0;
892
+ let closedReason;
893
+ const activeWork = /* @__PURE__ */ new Set();
894
+ for (const messageClass of GATEWAY_CONTROL_ADMISSION_CLASSES) {
895
+ const limit = executionLimits[messageClass];
896
+ if (!Number.isSafeInteger(limit) || limit <= 0) throw new RangeError(`${messageClass} execution limit must be a positive safe integer.`);
897
+ }
898
+ const schedulePump = () => {
899
+ if (pumpScheduled || closedReason !== void 0) return;
900
+ pumpScheduled = true;
901
+ scheduleImmediate(() => {
902
+ pumpScheduled = false;
903
+ pump();
904
+ });
905
+ };
906
+ const pump = () => {
907
+ if (closedReason !== void 0) return;
908
+ for (;;) {
909
+ const allowedMessageClasses = GATEWAY_CONTROL_ADMISSION_CLASSES.filter((messageClass) => activeByClass[messageClass] < executionLimits[messageClass]);
910
+ if (allowedMessageClasses.length === 0) return;
911
+ const admittedWork = scheduler.dequeue({ allowedMessageClasses });
912
+ if (admittedWork === void 0) return;
913
+ const { completionToken, message } = admittedWork;
914
+ const messageClass = message.messageClass;
915
+ const work = message.payload;
916
+ activeByClass[messageClass] += 1;
917
+ activeWork.add(work);
918
+ (async () => {
919
+ let executionError;
920
+ try {
921
+ await work.execute();
922
+ } catch (error) {
923
+ executionError = error;
924
+ } finally {
925
+ scheduler.complete(completionToken);
926
+ activeByClass[messageClass] -= 1;
927
+ activeWork.delete(work);
928
+ schedulePump();
929
+ }
930
+ if (work.settled || work.admissionGeneration !== admissionGeneration) return;
931
+ work.settled = true;
932
+ if (executionError === void 0) {
933
+ work.resolve({ status: "executed" });
934
+ return;
935
+ }
936
+ work.reject(executionError);
937
+ })();
938
+ }
939
+ };
940
+ return {
941
+ close: (reason) => {
942
+ if (closedReason !== void 0) return;
943
+ closedReason = reason;
944
+ admissionGeneration += 1;
945
+ for (const message of scheduler.cancelQueued()) {
946
+ const work = message.payload;
947
+ if (!work.settled) {
948
+ work.settled = true;
949
+ work.onCancel?.(reason);
950
+ work.resolve({
951
+ reason,
952
+ status: "closed"
953
+ });
954
+ }
955
+ }
956
+ for (const work of activeWork) if (!work.settled) {
957
+ work.settled = true;
958
+ work.onCancel?.(reason);
959
+ work.resolve({
960
+ reason,
961
+ status: "closed"
962
+ });
963
+ }
964
+ },
965
+ diagnostics: () => ({
966
+ activeByClass: { ...activeByClass },
967
+ scheduler: scheduler.diagnostics()
968
+ }),
969
+ submit: (request) => {
970
+ if (closedReason !== void 0) {
971
+ const closed = {
972
+ reason: closedReason,
973
+ status: "closed"
974
+ };
975
+ return {
976
+ admission: closed,
977
+ completion: Promise.resolve(closed)
978
+ };
979
+ }
980
+ let resolveCompletion;
981
+ let rejectCompletion;
982
+ const completion = new Promise((resolve, reject) => {
983
+ resolveCompletion = resolve;
984
+ rejectCompletion = reject;
985
+ });
986
+ const work = {
987
+ admissionGeneration,
988
+ execute: request.execute,
989
+ ...request.onCancel === void 0 ? {} : { onCancel: request.onCancel },
990
+ payload: request.payload,
991
+ reject: rejectCompletion,
992
+ resolve: resolveCompletion,
993
+ settled: false
994
+ };
995
+ const result = scheduler.enqueue(executionMessage(request, work));
996
+ switch (result.status) {
997
+ case "admitted":
998
+ schedulePump();
999
+ return {
1000
+ admission: { status: "admitted" },
1001
+ completion
1002
+ };
1003
+ case "replaced":
1004
+ if (!result.replacedMessage.payload.settled) {
1005
+ result.replacedMessage.payload.settled = true;
1006
+ result.replacedMessage.payload.onCancel?.("replaced");
1007
+ result.replacedMessage.payload.resolve({ status: "replaced" });
1008
+ }
1009
+ schedulePump();
1010
+ return {
1011
+ admission: { status: "replaced" },
1012
+ completion
1013
+ };
1014
+ case "dropped":
1015
+ case "fence":
1016
+ case "refused":
1017
+ case "shed":
1018
+ resolveCompletion(result);
1019
+ return {
1020
+ admission: result,
1021
+ completion
1022
+ };
1023
+ }
1024
+ throw new Error("unsupported gateway control admission result");
1025
+ }
1026
+ };
1027
+ }
1028
+ //#endregion
1029
+ //#region src/gateway-control-admission-classification.ts
1030
+ function authorityClassification(stablePrincipal) {
1031
+ return stablePrincipal === void 0 || stablePrincipal.length === 0 ? {
1032
+ reason: "stable_principal_required",
1033
+ status: "refused"
1034
+ } : {
1035
+ authoritySchedulingKey: stablePrincipal,
1036
+ messageClass: "authority",
1037
+ stablePrincipal,
1038
+ status: "classified"
1039
+ };
1040
+ }
1041
+ function diagnosticCoalesceKey(payload) {
1042
+ return JSON.stringify([
1043
+ payload.eventKind,
1044
+ "leaseId" in payload ? payload.leaseId : void 0,
1045
+ "transitionId" in payload ? payload.transitionId : void 0,
1046
+ "operation" in payload ? payload.operation : void 0,
1047
+ "channelProviderId" in payload ? payload.channelProviderId : void 0
1048
+ ]);
1049
+ }
1050
+ function classifyGatewayControlAdmission(options) {
1051
+ const message = options.message;
1052
+ if (message.kind === "command_result") return options.matchedPendingResult === true ? {
1053
+ messageClass: "safety",
1054
+ status: "classified"
1055
+ } : {
1056
+ reason: "forged_command_result",
1057
+ status: "fence"
1058
+ };
1059
+ if (message.kind === "heartbeat") return {
1060
+ coalesceKey: `${options.direction}:control-heartbeat`,
1061
+ messageClass: "liveness",
1062
+ status: "classified"
1063
+ };
1064
+ if (message.kind === "event") {
1065
+ if (options.direction !== "gateway_to_controller") return {
1066
+ reason: "direction_violation",
1067
+ status: "fence"
1068
+ };
1069
+ switch (message.operation) {
1070
+ case "gateway_runtime_readiness": return {
1071
+ coalesceKey: "gateway-runtime-readiness",
1072
+ messageClass: "liveness",
1073
+ status: "classified"
1074
+ };
1075
+ case "runtime_status": return {
1076
+ coalesceKey: `runtime-status:${message.payload.statusKind}`,
1077
+ messageClass: "liveness",
1078
+ status: "classified"
1079
+ };
1080
+ case "health_event": return {
1081
+ coalesceKey: diagnosticCoalesceKey(message.payload),
1082
+ messageClass: "diagnostic",
1083
+ status: "classified"
1084
+ };
1085
+ }
1086
+ }
1087
+ if (message.operation === "control_ping") return {
1088
+ coalesceKey: `${options.direction}:control-ping`,
1089
+ messageClass: "liveness",
1090
+ status: "classified"
1091
+ };
1092
+ if (options.direction === "controller_to_gateway") switch (message.operation) {
1093
+ case "tool_vm_binding_publish": {
1094
+ if (message.kind !== "command") return {
1095
+ reason: "direction_violation",
1096
+ status: "fence"
1097
+ };
1098
+ const stablePrincipal = message.payload.binding.stablePrincipal;
1099
+ return {
1100
+ authoritySchedulingKey: stablePrincipal,
1101
+ coalesceKey: `tool-vm-binding:${stablePrincipal}`,
1102
+ messageClass: "authority",
1103
+ stablePrincipal,
1104
+ status: "classified"
1105
+ };
1106
+ }
1107
+ case "operation_cancel": return options.controllerSafetyOperation === true && message.payload.initiatedBy === "controller" ? {
1108
+ messageClass: "safety",
1109
+ status: "classified"
1110
+ } : {
1111
+ reason: "direction_violation",
1112
+ status: "fence"
1113
+ };
1114
+ case "recovery_command": return options.controllerSafetyOperation === true ? {
1115
+ messageClass: "safety",
1116
+ status: "classified"
1117
+ } : {
1118
+ reason: "direction_violation",
1119
+ status: "fence"
1120
+ };
1121
+ case "caller_context_register":
1122
+ case "lease_create":
1123
+ case "lease_get":
1124
+ case "lease_peek":
1125
+ case "lease_reacquire":
1126
+ case "lease_release":
1127
+ case "lease_renew":
1128
+ case "lease_use_start":
1129
+ case "lease_use_heartbeat":
1130
+ case "lease_use_end":
1131
+ case "tool_portal_controller_host_action":
1132
+ case "tool_portal_admission_reserve":
1133
+ case "tool_portal_dispatch_arm":
1134
+ case "tool_vm_binding_request": return {
1135
+ reason: "direction_violation",
1136
+ status: "fence"
1137
+ };
1138
+ }
1139
+ switch (message.operation) {
1140
+ case "caller_context_register": return authorityClassification(options.stablePrincipal);
1141
+ case "lease_renew": return options.stablePrincipal === void 0 ? {
1142
+ reason: "stable_principal_required",
1143
+ status: "refused"
1144
+ } : {
1145
+ coalesceKey: `${options.stablePrincipal}:lease:${message.payload.leaseId}`,
1146
+ messageClass: "liveness",
1147
+ status: "classified"
1148
+ };
1149
+ case "lease_use_heartbeat": return options.stablePrincipal === void 0 ? {
1150
+ reason: "stable_principal_required",
1151
+ status: "refused"
1152
+ } : {
1153
+ coalesceKey: `${options.stablePrincipal}:lease:${message.payload.leaseId}:use:${message.payload.useId}`,
1154
+ messageClass: "liveness",
1155
+ status: "classified"
1156
+ };
1157
+ case "operation_cancel": return message.payload.initiatedBy === "gateway" ? {
1158
+ reason: "unproven_gateway_cancel",
1159
+ status: "refused"
1160
+ } : {
1161
+ reason: "direction_violation",
1162
+ status: "fence"
1163
+ };
1164
+ case "recovery_command": return {
1165
+ reason: "direction_violation",
1166
+ status: "fence"
1167
+ };
1168
+ case "tool_vm_binding_publish": return {
1169
+ reason: "direction_violation",
1170
+ status: "fence"
1171
+ };
1172
+ case "lease_create":
1173
+ case "lease_get":
1174
+ case "lease_peek":
1175
+ case "lease_reacquire":
1176
+ case "lease_release":
1177
+ case "lease_use_start":
1178
+ case "lease_use_end":
1179
+ case "tool_portal_controller_host_action":
1180
+ case "tool_portal_admission_reserve":
1181
+ case "tool_portal_dispatch_arm":
1182
+ case "tool_vm_binding_request": return authorityClassification(options.stablePrincipal);
1183
+ }
1184
+ return {
1185
+ reason: "direction_violation",
1186
+ status: "fence"
1187
+ };
1188
+ }
1189
+ //#endregion
1190
+ //#region src/gateway-runtime-control-endpoint.ts
1191
+ const GATEWAY_RUNTIME_TOOL_PORTAL_CONTROL_LISTEN_HOST = "127.0.0.1";
1192
+ const GATEWAY_RUNTIME_TOOL_PORTAL_CONTROL_GUEST_PORT = 18790;
1193
+ const GatewayRuntimeToolPortalProductionControlEndpointSchema = z.object({
1194
+ host: z.literal(GATEWAY_RUNTIME_TOOL_PORTAL_CONTROL_LISTEN_HOST),
1195
+ port: z.literal(GATEWAY_RUNTIME_TOOL_PORTAL_CONTROL_GUEST_PORT)
1196
+ }).strict().readonly();
1197
+ const GATEWAY_RUNTIME_TOOL_PORTAL_PRODUCTION_CONTROL_ENDPOINT = GatewayRuntimeToolPortalProductionControlEndpointSchema.parse({
1198
+ host: GATEWAY_RUNTIME_TOOL_PORTAL_CONTROL_LISTEN_HOST,
1199
+ port: GATEWAY_RUNTIME_TOOL_PORTAL_CONTROL_GUEST_PORT
1200
+ });
1201
+ //#endregion
1202
+ //#region src/gateway-runtime-portal-admission.ts
1203
+ const GATEWAY_RUNTIME_PORTAL_ADMISSION_FILE_NAME = "gateway-runtime-portal-admission.json";
1204
+ const GatewayRuntimeManagedToolPortalConfigSchema = toolPortalConfigSchema.transform((config, context) => {
1205
+ if (config.mode !== "managed") {
1206
+ context.addIssue({
1207
+ code: "custom",
1208
+ message: "Gateway runtime admission requires managed Tool Portal configuration.",
1209
+ path: ["mode"]
1210
+ });
1211
+ return z.NEVER;
1212
+ }
1213
+ return config;
1214
+ });
1215
+ const GatewayRuntimePortalAdmissionMaterialSchema = z.object({
1216
+ effectiveMcpConfig: mcpConfigSchema,
1217
+ effectiveToolPortalConfig: GatewayRuntimeManagedToolPortalConfigSchema,
1218
+ semanticSnapshot: GatewayRuntimePortalSemanticSnapshotSchema
1219
+ }).strict();
1220
+ //#endregion
1221
+ //#region src/gateway-runtime-portal-semantic-revision.ts
1222
+ function sortedStrings(values) {
1223
+ return [...values].toSorted();
1224
+ }
1225
+ function normalizedToolSelector(selector) {
1226
+ return {
1227
+ allow: selector.allow === "*" ? "*" : sortedStrings(selector.allow),
1228
+ deny: sortedStrings(selector.deny)
1229
+ };
1230
+ }
1231
+ function normalizedMcpProviders(providers) {
1232
+ return Object.fromEntries(Object.entries(providers).map(([providerId, provider]) => {
1233
+ const secretPolicies = Object.fromEntries(Object.entries(provider.secretPolicies).map(([secretName, policy]) => [secretName, {
1234
+ hosts: sortedStrings(policy.hosts),
1235
+ injection: policy.injection
1236
+ }]));
1237
+ const transport = provider.transport.kind === "stdio" ? {
1238
+ args: provider.transport.args,
1239
+ command: provider.transport.command,
1240
+ ...provider.transport.connectionTimeoutMs === void 0 ? {} : { connectionTimeoutMs: provider.transport.connectionTimeoutMs },
1241
+ ...provider.transport.cwd === void 0 ? {} : { cwd: provider.transport.cwd },
1242
+ env: provider.transport.env,
1243
+ kind: provider.transport.kind,
1244
+ ...provider.transport.networkAccess === void 0 ? {} : { networkAccess: provider.transport.networkAccess },
1245
+ requiredEgressHosts: sortedStrings(provider.transport.requiredEgressHosts)
1246
+ } : {
1247
+ ...provider.transport.connectionTimeoutMs === void 0 ? {} : { connectionTimeoutMs: provider.transport.connectionTimeoutMs },
1248
+ headers: provider.transport.headers,
1249
+ kind: provider.transport.kind,
1250
+ requiredEgressHosts: sortedStrings(provider.transport.requiredEgressHosts),
1251
+ url: provider.transport.url
1252
+ };
1253
+ return [providerId, {
1254
+ discovery: provider.discovery,
1255
+ kind: provider.kind,
1256
+ namespace: provider.namespace,
1257
+ secretPolicies,
1258
+ transport
1259
+ }];
1260
+ }));
1261
+ }
1262
+ function normalizedSurfaceEligibility(surfaceEligibilityByProfile) {
1263
+ return Object.fromEntries(Object.entries(surfaceEligibilityByProfile).map(([profileId, capabilities]) => [profileId, Object.fromEntries(Object.entries(capabilities).map(([capabilityId, surfaceClasses]) => [capabilityId, sortedStrings(surfaceClasses)]))]));
1264
+ }
1265
+ function normalizedCatalogInputs(props) {
1266
+ return {
1267
+ profiles: Object.fromEntries(Object.entries(props.toolPortalConfig.profiles).map(([profileId, profile]) => [profileId, Object.fromEntries(Object.entries(profile.namespaces).map(([namespaceId, namespacePolicy]) => [namespaceId, {
1268
+ ...namespacePolicy.backend.kind === "tool_vm_runner" ? { operations: Object.fromEntries(Object.entries(namespacePolicy.backend.operations).map(([operationName, operation]) => [operationName, {
1269
+ description: operation.description,
1270
+ kind: operation.kind
1271
+ }])) } : {},
1272
+ tools: normalizedToolSelector(namespacePolicy.tools)
1273
+ }]))])),
1274
+ providers: normalizedMcpProviders(props.mcpConfig.providers)
1275
+ };
1276
+ }
1277
+ function normalizedProfilePolicyInputs(props) {
1278
+ return {
1279
+ profiles: Object.fromEntries(Object.entries(props.toolPortalConfig.profiles).map(([profileId, profile]) => [profileId, Object.fromEntries(Object.entries(profile.namespaces).map(([namespaceId, namespacePolicy]) => [namespaceId, {
1280
+ calls: {
1281
+ requiresApproval: normalizedToolSelector(namespacePolicy.calls.requiresApproval),
1282
+ withoutApproval: normalizedToolSelector(namespacePolicy.calls.withoutApproval)
1283
+ },
1284
+ tools: normalizedToolSelector(namespacePolicy.tools)
1285
+ }]))])),
1286
+ surfaceEligibilityByProfile: normalizedSurfaceEligibility(props.surfaceEligibilityByProfile)
1287
+ };
1288
+ }
1289
+ function normalizedBindingInputs(config) {
1290
+ return Object.fromEntries(Object.entries(config.profiles).map(([profileId, profile]) => [profileId, Object.fromEntries(Object.entries(profile.namespaces).map(([namespaceId, namespacePolicy]) => [namespaceId, namespacePolicy.backend.kind === "tool_vm_runner" ? {
1291
+ kind: namespacePolicy.backend.kind,
1292
+ operations: Object.fromEntries(Object.entries(namespacePolicy.backend.operations).map(([operationName, operation]) => [operationName, operation.kind === "command.fixed" ? {
1293
+ executable: operation.executable,
1294
+ kind: operation.kind,
1295
+ mandatoryArgvPrefix: operation.mandatoryArgvPrefix,
1296
+ workingDirectory: operation.workingDirectory
1297
+ } : operation.kind === "process.start" ? {
1298
+ executable: operation.executable,
1299
+ kind: operation.kind,
1300
+ mandatoryArgvPrefix: operation.mandatoryArgvPrefix,
1301
+ maxRuntimeMs: operation.maxRuntimeMs,
1302
+ retainOutputBytes: operation.retainOutputBytes,
1303
+ workingDirectory: operation.workingDirectory
1304
+ } : operation.kind === "process.wait" ? {
1305
+ kind: operation.kind,
1306
+ timeoutMs: operation.timeoutMs
1307
+ } : { kind: operation.kind }])),
1308
+ profile: namespacePolicy.backend.profile
1309
+ } : { kind: namespacePolicy.backend.kind }]))]));
1310
+ }
1311
+ function canonicalJson(value) {
1312
+ return JSON.stringify(value, (_key, nestedValue) => {
1313
+ if (typeof nestedValue !== "object" || nestedValue === null || Array.isArray(nestedValue)) return nestedValue;
1314
+ return Object.fromEntries(Object.entries(nestedValue).toSorted(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)));
1315
+ });
1316
+ }
1317
+ function revision(domain, material) {
1318
+ return `${domain}:${createHash("sha256").update(`${domain}\0`, "utf8").update(canonicalJson(material), "utf8").digest("hex")}`;
1319
+ }
1320
+ function frameworkIdentityKey(identity) {
1321
+ return identity.kind === "openclaw" ? `openclaw:${identity.agentId}` : `hermes:${identity.profileName}`;
1322
+ }
1323
+ function assertExactManagedAgentProjectionInputs(props) {
1324
+ const projectionAgentIds = props.agentProjections.map((projection) => projection.agentId);
1325
+ if (new Set(projectionAgentIds).size !== projectionAgentIds.length) throw new Error("Managed Agent Projection agent ids must be unique.");
1326
+ const configuredAgentIds = sortedStrings(Object.keys(props.configuredAgents));
1327
+ const sortedProjectionAgentIds = sortedStrings(projectionAgentIds);
1328
+ if (configuredAgentIds.length !== sortedProjectionAgentIds.length || configuredAgentIds.some((agentId, index) => agentId !== sortedProjectionAgentIds[index])) throw new Error("Managed Agent Projection agent ids must exactly match configured Tool Portal agent ids.");
1329
+ if (new Set(props.agentProjections.map((projection) => projection.frameworkIdentity.kind)).size !== 1) throw new Error("Managed Agent Projections must share one framework kind.");
1330
+ const frameworkIdentityKeys = props.agentProjections.map((projection) => frameworkIdentityKey(projection.frameworkIdentity));
1331
+ if (new Set(frameworkIdentityKeys).size !== frameworkIdentityKeys.length) throw new Error("Managed Agent Projection framework identities must be unique.");
1332
+ for (const projection of props.agentProjections) {
1333
+ if (projection.frameworkIdentity.kind === "openclaw" && projection.frameworkIdentity.agentId !== projection.agentId) throw new Error(`OpenClaw projection identity must match agent '${projection.agentId}'.`);
1334
+ if (props.configuredAgents[projection.agentId]?.profile !== projection.toolPortalProfileId) throw new Error(`Managed Agent Projection Tool Portal profile does not match for agent '${projection.agentId}'.`);
1335
+ }
1336
+ }
1337
+ function deriveManagedAgentProjection(input) {
1338
+ return ManagedAgentProjectionSchema.parse({
1339
+ ...input,
1340
+ profileAssignmentRevision: revision("profile-assignment", input)
1341
+ });
1342
+ }
1343
+ function deriveManagedAgentProjectionCohortDigest(agentProjections) {
1344
+ return revision("projection-cohort", { agentProjections: [...agentProjections].toSorted((leftProjection, rightProjection) => leftProjection.agentId.localeCompare(rightProjection.agentId)) });
1345
+ }
1346
+ function deriveGatewayRuntimePortalSemanticSnapshot(props) {
1347
+ assertExactManagedAgentProjectionInputs({
1348
+ agentProjections: props.agentProjections,
1349
+ configuredAgents: props.toolPortalConfig.agents
1350
+ });
1351
+ const projections = props.agentProjections.map((projection) => deriveManagedAgentProjection(projection)).toSorted((leftProjection, rightProjection) => leftProjection.agentId.localeCompare(rightProjection.agentId));
1352
+ const agentProjections = Object.fromEntries(projections.map((projection) => [projection.agentId, projection]));
1353
+ const projectionCohortDigest = deriveManagedAgentProjectionCohortDigest(projections);
1354
+ const providerRevision = revision("provider", normalizedMcpProviders(props.mcpConfig.providers));
1355
+ const catalogRevision = revision("catalog", normalizedCatalogInputs({
1356
+ mcpConfig: props.mcpConfig,
1357
+ toolPortalConfig: props.toolPortalConfig
1358
+ }));
1359
+ const profilePolicyRevision = revision("profile-policy", normalizedProfilePolicyInputs({
1360
+ surfaceEligibilityByProfile: props.surfaceEligibilityByProfile,
1361
+ toolPortalConfig: props.toolPortalConfig
1362
+ }));
1363
+ const bindingRevision = revision("binding", normalizedBindingInputs(props.toolPortalConfig));
1364
+ const schemaRevision = revision("schema", {
1365
+ mcpConfigSchemaVersion: props.mcpConfig.schemaVersion,
1366
+ toolPortalConfigSchemaVersion: props.toolPortalConfig.schemaVersion
1367
+ });
1368
+ const desiredRevision = revision("portal-admission", {
1369
+ agentProjections,
1370
+ bindingRevision,
1371
+ catalogRevision,
1372
+ profilePolicyRevision,
1373
+ projectionCohortDigest,
1374
+ providerRevision,
1375
+ schemaRevision,
1376
+ surfaceEligibilityByProfile: normalizedSurfaceEligibility(props.surfaceEligibilityByProfile)
1377
+ });
1378
+ return GatewayRuntimePortalSemanticSnapshotSchema.parse({
1379
+ activeRevision: desiredRevision,
1380
+ agentProjections,
1381
+ bindingRevision,
1382
+ catalogRevision,
1383
+ desiredRevision,
1384
+ profilePolicyRevision,
1385
+ projectionCohortDigest,
1386
+ providerRevision,
1387
+ schemaRevision,
1388
+ schemaVersion: 1,
1389
+ surfaceEligibilityByProfile: normalizedSurfaceEligibility(props.surfaceEligibilityByProfile)
1390
+ });
1391
+ }
1392
+ function assertGatewayRuntimePortalSemanticSnapshotMatchesInputs(props) {
1393
+ if (canonicalJson(deriveGatewayRuntimePortalSemanticSnapshot({
1394
+ agentProjections: Object.values(props.semanticSnapshot.agentProjections).map((projection) => ({
1395
+ agentId: projection.agentId,
1396
+ frameworkIdentity: projection.frameworkIdentity,
1397
+ toolPortalProfileId: projection.toolPortalProfileId
1398
+ })),
1399
+ mcpConfig: props.mcpConfig,
1400
+ surfaceEligibilityByProfile: props.semanticSnapshot.surfaceEligibilityByProfile,
1401
+ toolPortalConfig: props.toolPortalConfig
1402
+ })) !== canonicalJson(props.semanticSnapshot)) throw new Error("Gateway runtime semantic snapshot does not match the protected Tool Portal and MCP inputs.");
1403
+ }
1404
+ //#endregion
3
1405
  //#region src/index.ts
4
1406
  const GatewayControlDomainSchema = z.literal("gateway_control");
1407
+ const GatewayControlHelloSchema = z.object({
1408
+ attachmentGeneration: z.number().int().positive(),
1409
+ controllerEpoch: z.string().min(1),
1410
+ domain: GatewayControlDomainSchema,
1411
+ gatewayEpoch: z.string().min(1),
1412
+ peerId: z.string().min(1),
1413
+ processEpoch: z.string().min(1),
1414
+ protocolVersion: z.literal(CONTROL_PROTOCOL_VERSION)
1415
+ }).strict();
1416
+ const GatewayControlHelloResponseSchema = z.object({
1417
+ attachmentGeneration: z.number().int().positive(),
1418
+ connectionId: z.string().uuid(),
1419
+ controllerEpoch: z.string().min(1),
1420
+ outcome: z.enum([
1421
+ "accepted",
1422
+ "rejected",
1423
+ "generation_mismatch",
1424
+ "stale_attachment"
1425
+ ]),
1426
+ sessionId: z.string().uuid()
1427
+ }).strict();
5
1428
  const GatewayControlRpcOperationSchema = z.enum([
6
1429
  "control_ping",
1430
+ "gateway_runtime_readiness",
7
1431
  "caller_context_register",
8
1432
  "lease_create",
9
1433
  "lease_get",
@@ -16,7 +1440,11 @@ const GatewayControlRpcOperationSchema = z.enum([
16
1440
  "lease_use_end",
17
1441
  "health_event",
18
1442
  "runtime_status",
1443
+ "tool_vm_binding_publish",
1444
+ "tool_vm_binding_request",
19
1445
  "tool_portal_controller_host_action",
1446
+ "tool_portal_admission_reserve",
1447
+ "tool_portal_dispatch_arm",
20
1448
  "operation_cancel",
21
1449
  "recovery_command"
22
1450
  ]);
@@ -52,19 +1480,8 @@ const GatewayControlCapabilityRefSchema = z.object({
52
1480
  }).strict();
53
1481
  const GatewayControlToolCallCorrelationSchema = ControlCorrelationSchema.extend({ capability: GatewayControlCapabilityRefSchema.optional() }).strict();
54
1482
  const GatewayControlTrustedCallerContextIdSchema = z.string().uuid();
55
- const GatewayControlTrustedLeaseContextSchema = z.object({
56
- agentId: z.string().min(1),
57
- agentWorkspaceDir: z.string().min(1),
58
- approvalScopeId: z.string().min(1).optional(),
59
- callerContextId: GatewayControlTrustedCallerContextIdSchema,
60
- custodyScopeId: z.string().min(1).optional(),
61
- hostWorkMountDir: z.string().min(1),
62
- profileId: z.string().min(1),
63
- sessionKeyDigest: z.string().min(32),
64
- workMountDir: z.string().min(1),
65
- zoneId: z.string().min(1)
66
- }).strict();
67
1483
  const GatewayControlCallerContextRefSchema = z.object({ callerContextId: GatewayControlTrustedCallerContextIdSchema }).strict();
1484
+ const GatewayControlRegisteredCallerContextRefSchema = GatewayControlCallerContextRefSchema.extend({ admissionPrincipal: GatewayStablePrincipalDigestSchema }).strict();
68
1485
  const GatewayControlCallerContextProofAlgorithmSchema = z.literal("hmac-sha256");
69
1486
  const GatewayControlCallerContextProofSchema = z.object({
70
1487
  algorithm: GatewayControlCallerContextProofAlgorithmSchema,
@@ -78,36 +1495,27 @@ const GatewayControlCallerContextAgentAuthoritySchema = z.object({
78
1495
  function buildGatewayControlCallerContextProofPayload(input) {
79
1496
  const purpose = input.purpose ?? "tool_vm_lease";
80
1497
  return [
81
- "gateway-control-caller-context-v1",
1498
+ "gateway-control-caller-context-v4",
82
1499
  input.zoneId,
83
- input.agentId,
84
- input.agentWorkspaceDir,
85
- input.workMountDir,
86
- input.sessionKey,
1500
+ deriveGatewayControlStablePrincipal({ principal: input.principal }),
87
1501
  purpose
88
1502
  ].join("\0");
89
1503
  }
90
1504
  function buildGatewayControlCallerContextAgentAuthorityPayload(input) {
91
1505
  const purpose = input.purpose ?? "tool_vm_lease";
92
1506
  return [
93
- "gateway-control-agent-authority-v1",
1507
+ "gateway-control-agent-authority-v4",
94
1508
  input.zoneId,
95
- input.agentId,
96
- input.agentWorkspaceDir,
97
- input.workMountDir,
98
- input.sessionKey,
1509
+ deriveGatewayControlStablePrincipal({ principal: input.principal }),
99
1510
  purpose
100
1511
  ].join("\0");
101
1512
  }
102
1513
  const GatewayControlCallerContextRegisterPayloadSchema = z.object({
103
1514
  adapterEvidence: z.object({
104
1515
  agentAuthority: GatewayControlCallerContextAgentAuthoritySchema,
105
- agentId: z.string().min(1),
106
- agentWorkspaceDir: z.string().min(1),
1516
+ principal: GatewayRuntimeTrustedInvocationPrincipalSchema$1,
107
1517
  proof: GatewayControlCallerContextProofSchema,
108
1518
  purpose: z.enum(["tool_vm_lease", "tool_portal_controller_host_action"]).optional(),
109
- sessionKey: z.string().min(1),
110
- workMountDir: z.string().min(1),
111
1519
  zoneId: z.string().min(1)
112
1520
  }).strict(),
113
1521
  correlation: GatewayControlToolCallCorrelationSchema.optional()
@@ -115,7 +1523,11 @@ const GatewayControlCallerContextRegisterPayloadSchema = z.object({
115
1523
  const GatewayControlLeaseCreateIntentPayloadSchema = z.object({
116
1524
  callerContext: GatewayControlCallerContextRefSchema,
117
1525
  correlation: GatewayControlToolCallCorrelationSchema.optional(),
118
- gatewayWorkspaceDir: z.string().min(1).optional(),
1526
+ idleTtlHintMs: z.number().int().positive().optional()
1527
+ }).strict();
1528
+ const GatewayControlToolVmBindingRequestPayloadSchema = z.object({
1529
+ callerContext: GatewayControlCallerContextRefSchema,
1530
+ correlation: GatewayControlToolCallCorrelationSchema.optional(),
119
1531
  idleTtlHintMs: z.number().int().positive().optional()
120
1532
  }).strict();
121
1533
  const GatewayControlLeaseIdPayloadSchema = z.object({
@@ -230,7 +1642,7 @@ const GatewayControlToolVmLeaseCallerContextStateSchema = z.enum([
230
1642
  "not_applicable"
231
1643
  ]);
232
1644
  const GatewayControlControllerRequestHealthOperationSchema = z.enum([
233
- "zone-git-push",
1645
+ "workspace-git-push",
234
1646
  "lease-create",
235
1647
  "lease-get",
236
1648
  "lease-peek",
@@ -333,41 +1745,44 @@ const GatewayControlRuntimeStatusPayloadSchema = z.object({
333
1745
  ]).optional(),
334
1746
  statusKind: z.string().min(1)
335
1747
  }).strict();
336
- const GatewayControlZoneGitPushControllerHostActionPayloadSchema = z.object({
337
- actionId: z.literal("zone_git_push"),
1748
+ const GatewayControlGitObjectIdSchema = z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u, "expected an exact lowercase SHA-1 or SHA-256 object id");
1749
+ const GatewayControlWorkspaceGitPushControllerHostActionPayloadSchema = z.object({
1750
+ actionId: z.literal("workspace_git_push"),
1751
+ approvalReservation: GatewayRuntimeControllerHostActionDispatchReservationSchema.optional(),
338
1752
  callerContext: GatewayControlCallerContextRefSchema,
339
1753
  correlation: GatewayControlToolCallCorrelationSchema,
340
- expectedHead: z.string().min(1)
1754
+ expectedHead: GatewayControlGitObjectIdSchema
341
1755
  }).strict();
342
1756
  const GatewayControlControllerHostProbePayloadSchema = z.object({
343
1757
  actionId: z.literal("controller_host_probe"),
1758
+ approvalReservation: GatewayRuntimeControllerHostActionDispatchReservationSchema.optional(),
344
1759
  callerContext: GatewayControlCallerContextRefSchema,
345
1760
  correlation: GatewayControlToolCallCorrelationSchema
346
1761
  }).strict();
347
- const GatewayControlToolPortalControllerHostActionPayloadSchema = z.discriminatedUnion("actionId", [GatewayControlZoneGitPushControllerHostActionPayloadSchema, GatewayControlControllerHostProbePayloadSchema]);
348
- const GatewayControlZoneGitCommitSummarySchema = z.object({
349
- sha: z.string().min(1),
1762
+ const GatewayControlToolPortalControllerHostActionPayloadSchema = z.discriminatedUnion("actionId", [GatewayControlWorkspaceGitPushControllerHostActionPayloadSchema, GatewayControlControllerHostProbePayloadSchema]);
1763
+ const GatewayControlWorkspaceGitCommitSummarySchema = z.object({
1764
+ sha: GatewayControlGitObjectIdSchema,
350
1765
  subject: z.string()
351
1766
  }).strict();
352
- const GatewayControlZoneGitPushResultSchema = z.object({
1767
+ const GatewayControlWorkspaceGitPushResultSchema = z.object({
353
1768
  branch: z.string().min(1),
354
- localHead: z.string().min(1),
355
- pushedCommits: z.array(GatewayControlZoneGitCommitSummarySchema),
356
- remoteHead: z.string().min(1)
1769
+ localHead: GatewayControlGitObjectIdSchema,
1770
+ pushedCommits: z.array(GatewayControlWorkspaceGitCommitSummarySchema),
1771
+ remoteHead: GatewayControlGitObjectIdSchema
357
1772
  }).strict();
358
1773
  const GatewayControlControllerHostProbeResultSchema = z.object({
359
1774
  entryNames: z.array(z.string().min(1)).max(64),
360
1775
  probeKind: z.literal("controller_cache_dir_listing")
361
1776
  }).strict();
362
- const GatewayControlZoneGitPushControllerHostActionResultSchema = z.object({
363
- actionId: z.literal("zone_git_push"),
364
- result: GatewayControlZoneGitPushResultSchema
1777
+ const GatewayControlWorkspaceGitPushControllerHostActionResultSchema = z.object({
1778
+ actionId: z.literal("workspace_git_push"),
1779
+ result: GatewayControlWorkspaceGitPushResultSchema
365
1780
  }).strict();
366
1781
  const GatewayControlControllerHostProbeActionResultSchema = z.object({
367
1782
  actionId: z.literal("controller_host_probe"),
368
1783
  result: GatewayControlControllerHostProbeResultSchema
369
1784
  }).strict();
370
- const GatewayControlToolPortalControllerHostActionResultSchema = z.discriminatedUnion("actionId", [GatewayControlZoneGitPushControllerHostActionResultSchema, GatewayControlControllerHostProbeActionResultSchema]);
1785
+ const GatewayControlToolPortalControllerHostActionResultSchema = z.discriminatedUnion("actionId", [GatewayControlWorkspaceGitPushControllerHostActionResultSchema, GatewayControlControllerHostProbeActionResultSchema]);
371
1786
  const GatewayControlActiveOperationIdSchema = z.string().uuid();
372
1787
  const GatewayInitiatedOperationCancelPayloadSchema = z.object({
373
1788
  activeOperationId: GatewayControlActiveOperationIdSchema,
@@ -397,6 +1812,8 @@ const GatewayControlRecoveryCommandPayloadSchema = z.discriminatedUnion("action"
397
1812
  }).strict()
398
1813
  ]);
399
1814
  const GatewayControlPingPayloadSchema = z.object({}).strict();
1815
+ const GatewayControlToolPortalAdmissionReservePayloadSchema = z.object({ intent: GatewayRuntimeApprovalChallengeIntentSchema }).strict();
1816
+ const GatewayControlToolPortalDispatchArmPayloadSchema = z.object({ reservation: GatewayRuntimeGatewayDispatchReservationSchema }).strict();
400
1817
  const GatewayControlHeartbeatPayloadSchema = z.object({
401
1818
  elapsedMs: z.number().int().nonnegative().optional(),
402
1819
  observedAtMs: z.number().int().positive()
@@ -405,12 +1822,69 @@ const GatewayControlRpcErrorSchema = ControlRpcErrorSchema;
405
1822
  const GatewayControlSessionStateSchema = ControlSessionStateSchema;
406
1823
  const GatewayControlToolVmSshAccessSchema = z.object({
407
1824
  host: z.string().min(1),
408
- identityPem: z.string().min(1).optional(),
409
- knownHostsLine: z.string().optional(),
410
1825
  port: z.number().int().positive(),
411
1826
  user: z.string().min(1)
412
1827
  }).strict();
413
- const GatewayControlLeaseSnapshotSchema = z.object({
1828
+ const GatewayControlPrivateToolVmSshAccessSchema = GatewayControlToolVmSshAccessSchema.extend({
1829
+ identityPem: z.string().min(1),
1830
+ knownHostsLine: z.string().min(1)
1831
+ }).strict();
1832
+ const GatewayControlToolVmBindingPublicationAuthoritySchema = z.object({
1833
+ attachmentGeneration: z.number().int().positive(),
1834
+ connectionId: z.string().uuid(),
1835
+ controllerEpoch: z.string().min(1),
1836
+ gatewayEpoch: z.string().min(1),
1837
+ processEpoch: z.string().min(1),
1838
+ sessionId: z.string().uuid(),
1839
+ zoneId: z.string().min(1)
1840
+ }).strict();
1841
+ const GatewayControlToolVmBindingAccessGrantSchema = z.object({
1842
+ agentId: z.string().min(1),
1843
+ idleTtlMs: z.number().int().positive(),
1844
+ leafGeneration: z.string().min(1),
1845
+ leaseId: z.string().min(1),
1846
+ profileAssignmentRevision: z.string().min(1),
1847
+ ssh: GatewayControlPrivateToolVmSshAccessSchema,
1848
+ sshBindingId: z.string().min(1),
1849
+ stablePrincipal: GatewayStablePrincipalDigestSchema,
1850
+ tcpSlot: z.number().int().nonnegative(),
1851
+ transport: z.literal("ssh-sandbox"),
1852
+ workdir: z.string().min(1),
1853
+ zoneId: z.string().min(1)
1854
+ }).strict();
1855
+ const GatewayControlToolVmBindingIdentitySchema = GatewayControlToolVmBindingAccessGrantSchema.pick({
1856
+ agentId: true,
1857
+ leafGeneration: true,
1858
+ leaseId: true,
1859
+ profileAssignmentRevision: true,
1860
+ sshBindingId: true,
1861
+ stablePrincipal: true,
1862
+ zoneId: true
1863
+ }).strict();
1864
+ const GatewayControlToolVmBindingPublicationSchema = z.discriminatedUnion("kind", [z.object({
1865
+ authority: GatewayControlToolVmBindingPublicationAuthoritySchema,
1866
+ binding: GatewayControlToolVmBindingAccessGrantSchema,
1867
+ kind: z.literal("current"),
1868
+ observedAtMs: z.number().int().positive()
1869
+ }).strict(), z.object({
1870
+ authority: GatewayControlToolVmBindingPublicationAuthoritySchema,
1871
+ binding: GatewayControlToolVmBindingIdentitySchema,
1872
+ kind: z.literal("retired"),
1873
+ observedAtMs: z.number().int().positive(),
1874
+ reason: z.enum([
1875
+ "dead",
1876
+ "expired",
1877
+ "released",
1878
+ "replaced",
1879
+ "session_retired"
1880
+ ])
1881
+ }).strict()]);
1882
+ const GatewayControlToolVmBindingRequestResultSchema = z.object({
1883
+ agentId: z.string().min(1),
1884
+ stablePrincipal: GatewayStablePrincipalDigestSchema,
1885
+ status: z.literal("publication_pending")
1886
+ }).strict();
1887
+ const GatewayControlLeaseSnapshotBaseSchema = z.object({
414
1888
  agentId: z.string().min(1),
415
1889
  activeUseId: z.string().uuid().optional(),
416
1890
  expiresAtMs: z.number().int().positive().optional(),
@@ -428,6 +1902,13 @@ const GatewayControlLeaseSnapshotSchema = z.object({
428
1902
  workdir: z.string().min(1),
429
1903
  zoneId: z.string().min(1)
430
1904
  }).strict();
1905
+ const GatewayControlPublicLeaseSnapshotSchema = GatewayControlLeaseSnapshotBaseSchema;
1906
+ const GatewayControlPrivateLeaseSnapshotSchema = GatewayControlLeaseSnapshotBaseSchema.extend({
1907
+ leafGeneration: z.string().min(1),
1908
+ ssh: GatewayControlPrivateToolVmSshAccessSchema,
1909
+ sshBindingId: z.string().min(1)
1910
+ }).strict();
1911
+ const GatewayControlLeaseSnapshotSchema = z.union([GatewayControlPrivateLeaseSnapshotSchema, GatewayControlPublicLeaseSnapshotSchema]);
431
1912
  const GatewayControlLeaseUseSnapshotSchema = z.object({
432
1913
  expiresAt: z.number().int().positive().optional(),
433
1914
  heartbeatAfterMs: z.number().int().positive().optional(),
@@ -442,8 +1923,11 @@ const GatewayControlLeaseUseSnapshotSchema = z.object({
442
1923
  const GatewayControlRpcDomainCorrelationSchema = ControlCorrelationSchema;
443
1924
  const GatewayControlRpcForbiddenResponseFieldsSchema = {
444
1925
  activeOperationId: z.never().optional(),
1926
+ approvalAdmission: z.never().optional(),
1927
+ approvalDispatch: z.never().optional(),
445
1928
  approvalRequired: z.never().optional(),
446
1929
  callerContext: z.never().optional(),
1930
+ bindingRequest: z.never().optional(),
447
1931
  controllerHostAction: z.never().optional(),
448
1932
  error: z.never().optional(),
449
1933
  lease: z.never().optional(),
@@ -475,39 +1959,60 @@ const GatewayControlRpcBareResponsePayloadSchema = z.discriminatedUnion("result"
475
1959
  }).strict()]);
476
1960
  const GatewayControlRpcCallerContextResponsePayloadSchema = z.discriminatedUnion("result", [GatewayControlRpcResponseCorrelationSchema.extend({
477
1961
  ...GatewayControlRpcForbiddenResponseFieldsSchema,
478
- callerContext: GatewayControlCallerContextRefSchema,
1962
+ callerContext: GatewayControlRegisteredCallerContextRefSchema,
479
1963
  result: z.literal("ok")
480
1964
  }).strict(), GatewayControlRpcResponseCorrelationSchema.extend({
481
1965
  ...GatewayControlRpcForbiddenResponseFieldsSchema,
482
1966
  error: GatewayControlRpcErrorSchema,
483
1967
  result: GatewayControlRpcErrorResponseResultSchema
484
1968
  }).strict()]);
485
- const GatewayControlRpcLeaseResponsePayloadSchema = z.discriminatedUnion("result", [
1969
+ const GatewayControlRpcToolVmBindingRequestResponsePayloadSchema = z.discriminatedUnion("result", [GatewayControlRpcResponseCorrelationSchema.extend({
1970
+ ...GatewayControlRpcForbiddenResponseFieldsSchema,
1971
+ bindingRequest: GatewayControlToolVmBindingRequestResultSchema,
1972
+ result: z.literal("ok")
1973
+ }).strict(), GatewayControlRpcResponseCorrelationSchema.extend({
1974
+ ...GatewayControlRpcForbiddenResponseFieldsSchema,
1975
+ error: GatewayControlRpcErrorSchema,
1976
+ result: GatewayControlRpcErrorResponseResultSchema
1977
+ }).strict()]);
1978
+ const GatewayControlRpcLeaseRejectedResponsePayloadSchema = GatewayControlRpcResponseCorrelationSchema.extend({
1979
+ ...GatewayControlRpcForbiddenResponseFieldsSchema,
1980
+ error: GatewayControlRpcErrorSchema.optional(),
1981
+ leaseRejectionReason: GatewayControlLeaseRejectionReasonSchema,
1982
+ result: z.literal("rejected")
1983
+ }).strict();
1984
+ const GatewayControlRpcLeaseFailedResponsePayloadSchema = GatewayControlRpcResponseCorrelationSchema.extend({
1985
+ ...GatewayControlRpcForbiddenResponseFieldsSchema,
1986
+ error: GatewayControlRpcErrorSchema,
1987
+ leaseRejectionReason: GatewayControlLeaseRejectionReasonSchema.optional(),
1988
+ result: z.enum([
1989
+ "failed",
1990
+ "timeout",
1991
+ "cancelled",
1992
+ "stale_generation",
1993
+ "approval_required",
1994
+ "approval_stale"
1995
+ ])
1996
+ }).strict();
1997
+ const GatewayControlRpcPrivateLeaseResponsePayloadSchema = z.discriminatedUnion("result", [
486
1998
  GatewayControlRpcResponseCorrelationSchema.extend({
487
1999
  ...GatewayControlRpcForbiddenResponseFieldsSchema,
488
- lease: GatewayControlLeaseSnapshotSchema,
2000
+ lease: GatewayControlPrivateLeaseSnapshotSchema,
489
2001
  result: z.literal("ok")
490
2002
  }).strict(),
2003
+ GatewayControlRpcLeaseRejectedResponsePayloadSchema,
2004
+ GatewayControlRpcLeaseFailedResponsePayloadSchema
2005
+ ]);
2006
+ const GatewayControlRpcPublicLeaseResponsePayloadSchema = z.discriminatedUnion("result", [
491
2007
  GatewayControlRpcResponseCorrelationSchema.extend({
492
2008
  ...GatewayControlRpcForbiddenResponseFieldsSchema,
493
- error: GatewayControlRpcErrorSchema.optional(),
494
- leaseRejectionReason: GatewayControlLeaseRejectionReasonSchema,
495
- result: z.literal("rejected")
2009
+ lease: GatewayControlPublicLeaseSnapshotSchema,
2010
+ result: z.literal("ok")
496
2011
  }).strict(),
497
- GatewayControlRpcResponseCorrelationSchema.extend({
498
- ...GatewayControlRpcForbiddenResponseFieldsSchema,
499
- error: GatewayControlRpcErrorSchema,
500
- leaseRejectionReason: GatewayControlLeaseRejectionReasonSchema.optional(),
501
- result: z.enum([
502
- "failed",
503
- "timeout",
504
- "cancelled",
505
- "stale_generation",
506
- "approval_required",
507
- "approval_stale"
508
- ])
509
- }).strict()
2012
+ GatewayControlRpcLeaseRejectedResponsePayloadSchema,
2013
+ GatewayControlRpcLeaseFailedResponsePayloadSchema
510
2014
  ]);
2015
+ const GatewayControlRpcLeaseResponsePayloadSchema = z.union([GatewayControlRpcPrivateLeaseResponsePayloadSchema, GatewayControlRpcPublicLeaseResponsePayloadSchema]);
511
2016
  const GatewayControlRpcLeaseUseResponsePayloadSchema = z.discriminatedUnion("result", [
512
2017
  GatewayControlRpcResponseCorrelationSchema.extend({
513
2018
  ...GatewayControlRpcForbiddenResponseFieldsSchema,
@@ -553,13 +2058,34 @@ const GatewayControlRpcOperationCancelResponsePayloadSchema = z.discriminatedUni
553
2058
  error: GatewayControlRpcErrorSchema,
554
2059
  result: GatewayControlRpcErrorResponseResultSchema
555
2060
  }).strict()]);
2061
+ const GatewayControlRpcApprovalAdmissionResponsePayloadSchema = z.discriminatedUnion("result", [GatewayControlRpcResponseCorrelationSchema.extend({
2062
+ ...GatewayControlRpcForbiddenResponseFieldsSchema,
2063
+ approvalAdmission: GatewayRuntimeApprovalAdmissionResultSchema,
2064
+ result: z.literal("ok")
2065
+ }).strict(), GatewayControlRpcResponseCorrelationSchema.extend({
2066
+ ...GatewayControlRpcForbiddenResponseFieldsSchema,
2067
+ error: GatewayControlRpcErrorSchema,
2068
+ result: GatewayControlRpcErrorResponseResultSchema
2069
+ }).strict()]);
2070
+ const GatewayControlRpcApprovalDispatchResponsePayloadSchema = z.discriminatedUnion("result", [GatewayControlRpcResponseCorrelationSchema.extend({
2071
+ ...GatewayControlRpcForbiddenResponseFieldsSchema,
2072
+ approvalDispatch: GatewayRuntimeApprovalArmDispatchResultSchema,
2073
+ result: z.literal("ok")
2074
+ }).strict(), GatewayControlRpcResponseCorrelationSchema.extend({
2075
+ ...GatewayControlRpcForbiddenResponseFieldsSchema,
2076
+ error: GatewayControlRpcErrorSchema,
2077
+ result: GatewayControlRpcErrorResponseResultSchema
2078
+ }).strict()]);
556
2079
  const GatewayControlRpcResponsePayloadSchema = z.union([
557
2080
  GatewayControlRpcBareResponsePayloadSchema,
558
2081
  GatewayControlRpcCallerContextResponsePayloadSchema,
2082
+ GatewayControlRpcToolVmBindingRequestResponsePayloadSchema,
559
2083
  GatewayControlRpcLeaseResponsePayloadSchema,
560
2084
  GatewayControlRpcLeaseUseResponsePayloadSchema,
561
2085
  GatewayControlRpcControllerHostActionResponsePayloadSchema,
562
- GatewayControlRpcOperationCancelResponsePayloadSchema
2086
+ GatewayControlRpcOperationCancelResponsePayloadSchema,
2087
+ GatewayControlRpcApprovalAdmissionResponsePayloadSchema,
2088
+ GatewayControlRpcApprovalDispatchResponsePayloadSchema
563
2089
  ]);
564
2090
  const GatewayControlRpcControlPingCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
565
2091
  kind: z.literal("command_result"),
@@ -571,17 +2097,20 @@ const GatewayControlRpcCallerContextRegisterCommandResultMessageSchema = Gateway
571
2097
  operation: z.literal("caller_context_register"),
572
2098
  payload: GatewayControlRpcCallerContextResponsePayloadSchema
573
2099
  }).strict();
574
- const GatewayControlRpcLeaseCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
2100
+ const GatewayControlRpcPrivateLeaseCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
575
2101
  kind: z.literal("command_result"),
576
2102
  operation: z.enum([
577
2103
  "lease_create",
578
2104
  "lease_get",
579
- "lease_peek",
580
2105
  "lease_reacquire",
581
- "lease_renew",
582
- "lease_release"
2106
+ "lease_renew"
583
2107
  ]),
584
- payload: GatewayControlRpcLeaseResponsePayloadSchema
2108
+ payload: GatewayControlRpcPrivateLeaseResponsePayloadSchema
2109
+ }).strict();
2110
+ const GatewayControlRpcPublicLeaseCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
2111
+ kind: z.literal("command_result"),
2112
+ operation: z.enum(["lease_peek", "lease_release"]),
2113
+ payload: GatewayControlRpcPublicLeaseResponsePayloadSchema
585
2114
  }).strict();
586
2115
  const GatewayControlRpcLeaseUseCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
587
2116
  kind: z.literal("command_result"),
@@ -607,6 +2136,26 @@ const GatewayControlRpcRecoveryCommandResultMessageSchema = GatewayControlRpcDom
607
2136
  operation: z.literal("recovery_command"),
608
2137
  payload: GatewayControlRpcBareResponsePayloadSchema
609
2138
  }).strict();
2139
+ const GatewayControlRpcApprovalAdmissionCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
2140
+ kind: z.literal("command_result"),
2141
+ operation: z.literal("tool_portal_admission_reserve"),
2142
+ payload: GatewayControlRpcApprovalAdmissionResponsePayloadSchema
2143
+ }).strict();
2144
+ const GatewayControlRpcApprovalDispatchCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
2145
+ kind: z.literal("command_result"),
2146
+ operation: z.literal("tool_portal_dispatch_arm"),
2147
+ payload: GatewayControlRpcApprovalDispatchResponsePayloadSchema
2148
+ }).strict();
2149
+ const GatewayControlRpcToolVmBindingRequestCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
2150
+ kind: z.literal("command_result"),
2151
+ operation: z.literal("tool_vm_binding_request"),
2152
+ payload: GatewayControlRpcToolVmBindingRequestResponsePayloadSchema
2153
+ }).strict();
2154
+ const GatewayControlRpcToolVmBindingPublishCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
2155
+ kind: z.literal("command_result"),
2156
+ operation: z.literal("tool_vm_binding_publish"),
2157
+ payload: GatewayControlRpcBareResponsePayloadSchema
2158
+ }).strict();
610
2159
  const GatewayControlHeartbeatMessageSchema = z.object({
611
2160
  kind: z.literal("heartbeat"),
612
2161
  operation: z.never().optional(),
@@ -615,13 +2164,28 @@ const GatewayControlHeartbeatMessageSchema = z.object({
615
2164
  const GatewayControlRpcCommandResultMessageSchema = z.discriminatedUnion("operation", [
616
2165
  GatewayControlRpcControlPingCommandResultMessageSchema,
617
2166
  GatewayControlRpcCallerContextRegisterCommandResultMessageSchema,
618
- GatewayControlRpcLeaseCommandResultMessageSchema,
2167
+ GatewayControlRpcPrivateLeaseCommandResultMessageSchema,
2168
+ GatewayControlRpcPublicLeaseCommandResultMessageSchema,
619
2169
  GatewayControlRpcLeaseUseCommandResultMessageSchema,
620
2170
  GatewayControlRpcControllerHostActionCommandResultMessageSchema,
621
2171
  GatewayControlRpcOperationCancelCommandResultMessageSchema,
622
- GatewayControlRpcRecoveryCommandResultMessageSchema
2172
+ GatewayControlRpcRecoveryCommandResultMessageSchema,
2173
+ GatewayControlRpcApprovalAdmissionCommandResultMessageSchema,
2174
+ GatewayControlRpcApprovalDispatchCommandResultMessageSchema,
2175
+ GatewayControlRpcToolVmBindingRequestCommandResultMessageSchema,
2176
+ GatewayControlRpcToolVmBindingPublishCommandResultMessageSchema
623
2177
  ]);
624
2178
  const GatewayControlRpcCommandMessageSchema = z.discriminatedUnion("operation", [
2179
+ GatewayControlRpcDomainCorrelationSchema.extend({
2180
+ kind: z.literal("command"),
2181
+ operation: z.literal("tool_vm_binding_request"),
2182
+ payload: GatewayControlToolVmBindingRequestPayloadSchema
2183
+ }).strict(),
2184
+ GatewayControlRpcDomainCorrelationSchema.extend({
2185
+ kind: z.literal("command"),
2186
+ operation: z.literal("tool_vm_binding_publish"),
2187
+ payload: GatewayControlToolVmBindingPublicationSchema
2188
+ }).strict(),
625
2189
  GatewayControlRpcDomainCorrelationSchema.extend({
626
2190
  kind: z.literal("command"),
627
2191
  operation: z.literal("control_ping"),
@@ -682,6 +2246,16 @@ const GatewayControlRpcCommandMessageSchema = z.discriminatedUnion("operation",
682
2246
  operation: z.literal("tool_portal_controller_host_action"),
683
2247
  payload: GatewayControlToolPortalControllerHostActionPayloadSchema
684
2248
  }).strict(),
2249
+ GatewayControlRpcDomainCorrelationSchema.extend({
2250
+ kind: z.literal("command"),
2251
+ operation: z.literal("tool_portal_admission_reserve"),
2252
+ payload: GatewayControlToolPortalAdmissionReservePayloadSchema
2253
+ }).strict(),
2254
+ GatewayControlRpcDomainCorrelationSchema.extend({
2255
+ kind: z.literal("command"),
2256
+ operation: z.literal("tool_portal_dispatch_arm"),
2257
+ payload: GatewayControlToolPortalDispatchArmPayloadSchema
2258
+ }).strict(),
685
2259
  GatewayControlRpcDomainCorrelationSchema.extend({
686
2260
  kind: z.literal("command"),
687
2261
  operation: z.literal("operation_cancel"),
@@ -693,16 +2267,28 @@ const GatewayControlRpcCommandMessageSchema = z.discriminatedUnion("operation",
693
2267
  payload: GatewayControlRecoveryCommandPayloadSchema
694
2268
  }).strict()
695
2269
  ]);
696
- const GatewayControlRpcEventMessageSchema = z.discriminatedUnion("operation", [GatewayControlRpcDomainCorrelationSchema.extend({
697
- kind: z.literal("event"),
698
- operation: z.literal("health_event"),
699
- payload: GatewayControlHealthEventPayloadSchema
700
- }).strict(), GatewayControlRpcDomainCorrelationSchema.extend({
701
- kind: z.literal("event"),
702
- operation: z.literal("runtime_status"),
703
- payload: GatewayControlRuntimeStatusPayloadSchema
704
- }).strict()]);
705
- const GatewayControlEventOnlyOperationSchema = z.enum(["health_event", "runtime_status"]);
2270
+ const GatewayControlRpcEventMessageSchema = z.discriminatedUnion("operation", [
2271
+ GatewayControlRpcDomainCorrelationSchema.extend({
2272
+ kind: z.literal("event"),
2273
+ operation: z.literal("gateway_runtime_readiness"),
2274
+ payload: GatewayRuntimeReadinessSnapshotSchema
2275
+ }).strict(),
2276
+ GatewayControlRpcDomainCorrelationSchema.extend({
2277
+ kind: z.literal("event"),
2278
+ operation: z.literal("health_event"),
2279
+ payload: GatewayControlHealthEventPayloadSchema
2280
+ }).strict(),
2281
+ GatewayControlRpcDomainCorrelationSchema.extend({
2282
+ kind: z.literal("event"),
2283
+ operation: z.literal("runtime_status"),
2284
+ payload: GatewayControlRuntimeStatusPayloadSchema
2285
+ }).strict()
2286
+ ]);
2287
+ const GatewayControlEventOnlyOperationSchema = z.enum([
2288
+ "gateway_runtime_readiness",
2289
+ "health_event",
2290
+ "runtime_status"
2291
+ ]);
706
2292
  const GatewayControlRpcCommandResultOperationSchema = GatewayControlRpcOperationSchema.exclude(GatewayControlEventOnlyOperationSchema.options);
707
2293
  const GatewayControlRpcMessageSchema = z.union([
708
2294
  GatewayControlHeartbeatMessageSchema,
@@ -714,6 +2300,7 @@ const gatewayControlDeliveryPolicyByKind = { heartbeat: "critical_idempotent" };
714
2300
  const gatewayControlDeliveryPolicyByOperation = {
715
2301
  caller_context_register: "critical_idempotent",
716
2302
  control_ping: "acked_idempotent",
2303
+ gateway_runtime_readiness: "latest_wins",
717
2304
  health_event: "append_only_observation",
718
2305
  lease_create: "critical_idempotent",
719
2306
  lease_get: "acked_idempotent",
@@ -727,7 +2314,11 @@ const gatewayControlDeliveryPolicyByOperation = {
727
2314
  operation_cancel: "acked_idempotent",
728
2315
  recovery_command: "critical_idempotent",
729
2316
  runtime_status: "latest_wins",
730
- tool_portal_controller_host_action: "single_use_critical"
2317
+ tool_vm_binding_publish: "critical_idempotent",
2318
+ tool_vm_binding_request: "critical_idempotent",
2319
+ tool_portal_controller_host_action: "single_use_critical",
2320
+ tool_portal_admission_reserve: "single_use_critical",
2321
+ tool_portal_dispatch_arm: "single_use_critical"
731
2322
  };
732
2323
  function deriveGatewayControlDeliveryPolicy(envelope) {
733
2324
  if (envelope.operation === "lease_create" && envelope.idempotencyKey === void 0) return "single_use_critical";
@@ -747,6 +2338,7 @@ function assertGatewayControlEnvelopeDeliveryPolicy(envelope) {
747
2338
  const gatewayControlCommandExecutionTimeoutMsByOperation = {
748
2339
  caller_context_register: 5e3,
749
2340
  control_ping: 5e3,
2341
+ gateway_runtime_readiness: 5e3,
750
2342
  health_event: 5e3,
751
2343
  lease_create: 18e4,
752
2344
  lease_get: 5e3,
@@ -760,7 +2352,11 @@ const gatewayControlCommandExecutionTimeoutMsByOperation = {
760
2352
  operation_cancel: 5e3,
761
2353
  recovery_command: 1e4,
762
2354
  runtime_status: 5e3,
763
- tool_portal_controller_host_action: 12e4
2355
+ tool_vm_binding_publish: 1e4,
2356
+ tool_vm_binding_request: 18e4,
2357
+ tool_portal_controller_host_action: 12e4,
2358
+ tool_portal_admission_reserve: 1e4,
2359
+ tool_portal_dispatch_arm: 1e4
764
2360
  };
765
2361
  function buildGatewayControlJsonSchemas() {
766
2362
  return {
@@ -768,6 +2364,14 @@ function buildGatewayControlJsonSchemas() {
768
2364
  io: "input",
769
2365
  unrepresentable: "any"
770
2366
  }),
2367
+ hello: z.toJSONSchema(GatewayControlHelloSchema, {
2368
+ io: "input",
2369
+ unrepresentable: "any"
2370
+ }),
2371
+ helloResponse: z.toJSONSchema(GatewayControlHelloResponseSchema, {
2372
+ io: "input",
2373
+ unrepresentable: "any"
2374
+ }),
771
2375
  message: z.toJSONSchema(GatewayControlRpcMessageSchema, {
772
2376
  io: "input",
773
2377
  unrepresentable: "any"
@@ -782,6 +2386,6 @@ function assertGatewayControlDomainRegistered() {
782
2386
  return KnownControlDomainSchema.extract(["gateway_control"]).parse("gateway_control");
783
2387
  }
784
2388
  //#endregion
785
- export { ControllerInitiatedGatewayOperationCancelPayloadSchema, GatewayControlActiveOperationIdSchema, GatewayControlCallerContextAgentAuthoritySchema, GatewayControlCallerContextProofAlgorithmSchema, GatewayControlCallerContextProofSchema, GatewayControlCallerContextRefSchema, GatewayControlCallerContextRegisterPayloadSchema, GatewayControlCapabilityRefSchema, GatewayControlControllerHostProbeActionResultSchema, GatewayControlControllerHostProbePayloadSchema, GatewayControlControllerHostProbeResultSchema, GatewayControlControllerRequestHealthOperationSchema, GatewayControlDomainSchema, GatewayControlEventOnlyOperationSchema, GatewayControlForbiddenPayloadFieldSchema, GatewayControlHealthEventPayloadSchema, GatewayControlHealthEventResultSchema, GatewayControlHeartbeatPayloadSchema, GatewayControlLeaseCreateIntentPayloadSchema, GatewayControlLeaseIdPayloadSchema, GatewayControlLeaseReacquireIntentPayloadSchema, GatewayControlLeaseRejectionReasonSchema, GatewayControlLeaseSnapshotSchema, GatewayControlLeaseStaleEvidenceSchema, GatewayControlLeaseUseEndPayloadSchema, GatewayControlLeaseUseHeartbeatPayloadSchema, GatewayControlLeaseUseSnapshotSchema, GatewayControlLeaseUseStartPayloadSchema, GatewayControlOperationCancelPayloadSchema, GatewayControlPingPayloadSchema, GatewayControlProviderRuntimeHealthSchema, GatewayControlRecoveryCommandPayloadSchema, GatewayControlRpcBareResponsePayloadSchema, GatewayControlRpcCallerContextResponsePayloadSchema, GatewayControlRpcCommandMessageSchema, GatewayControlRpcCommandResultMessageSchema, GatewayControlRpcCommandResultOperationSchema, GatewayControlRpcControllerHostActionResponsePayloadSchema, GatewayControlRpcDomainCorrelationSchema, GatewayControlRpcErrorSchema, GatewayControlRpcEventMessageSchema, GatewayControlRpcLeaseResponsePayloadSchema, GatewayControlRpcLeaseUseResponsePayloadSchema, GatewayControlRpcMessageSchema, GatewayControlRpcOperationCancelResponsePayloadSchema, GatewayControlRpcOperationSchema, GatewayControlRpcResponseBasePayloadSchema, GatewayControlRpcResponsePayloadSchema, GatewayControlRpcResultSchema, GatewayControlRuntimeFindingSchema, GatewayControlRuntimeStatusPayloadSchema, GatewayControlSessionHealthOperationSchema, GatewayControlSessionStateSchema, GatewayControlToolCallCorrelationSchema, GatewayControlToolPortalControllerHostActionPayloadSchema, GatewayControlToolPortalControllerHostActionResultSchema, GatewayControlToolVmLeaseCallerContextStateSchema, GatewayControlToolVmLeaseLifecycleEventRoleSchema, GatewayControlToolVmLeaseLifecycleTransitionSchema, GatewayControlToolVmSshAccessSchema, GatewayControlToolVmSshHealthOperationSchema, GatewayControlTrustedCallerContextIdSchema, GatewayControlTrustedLeaseContextSchema, GatewayControlZoneGitCommitSummarySchema, GatewayControlZoneGitPushControllerHostActionPayloadSchema, GatewayControlZoneGitPushControllerHostActionResultSchema, GatewayControlZoneGitPushResultSchema, GatewayInitiatedOperationCancelPayloadSchema, assertGatewayControlDomainRegistered, assertGatewayControlEnvelopeDeliveryPolicy, buildGatewayControlCallerContextAgentAuthorityPayload, buildGatewayControlCallerContextProofPayload, buildGatewayControlJsonSchemas, deriveGatewayControlDeliveryPolicy, gatewayControlCommandExecutionTimeoutMsByOperation, gatewayControlDeliveryPolicyByKind, gatewayControlDeliveryPolicyByOperation };
2389
+ export { ControllerInitiatedGatewayOperationCancelPayloadSchema, GATEWAY_CONTROL_ADMISSION_EXECUTION_LIMITS, GATEWAY_CONTROL_ADMISSION_LIMITS, GATEWAY_CONTROL_PROCESS_ADMISSION_LIMITS, GATEWAY_RUNTIME_APPROVAL_AUDIENCE, GATEWAY_RUNTIME_ATTACHMENT_SNAPSHOT_VERSION, GATEWAY_RUNTIME_PORTAL_ADMISSION_FILE_NAME, GATEWAY_RUNTIME_READINESS_SNAPSHOT_VERSION, GATEWAY_RUNTIME_TOOL_PORTAL_CONTROL_GUEST_PORT, GATEWAY_RUNTIME_TOOL_PORTAL_CONTROL_LISTEN_HOST, GATEWAY_RUNTIME_TOOL_PORTAL_PRODUCTION_CONTROL_ENDPOINT, GatewayControlActiveOperationIdSchema, GatewayControlCallerContextAgentAuthoritySchema, GatewayControlCallerContextProofAlgorithmSchema, GatewayControlCallerContextProofSchema, GatewayControlCallerContextRefSchema, GatewayControlCallerContextRegisterPayloadSchema, GatewayControlCapabilityRefSchema, GatewayControlControllerHostProbeActionResultSchema, GatewayControlControllerHostProbePayloadSchema, GatewayControlControllerHostProbeResultSchema, GatewayControlControllerRequestHealthOperationSchema, GatewayControlDomainSchema, GatewayControlEventOnlyOperationSchema, GatewayControlForbiddenPayloadFieldSchema, GatewayControlHealthEventPayloadSchema, GatewayControlHealthEventResultSchema, GatewayControlHeartbeatPayloadSchema, GatewayControlHelloResponseSchema, GatewayControlHelloSchema, GatewayControlLeaseCreateIntentPayloadSchema, GatewayControlLeaseIdPayloadSchema, GatewayControlLeaseReacquireIntentPayloadSchema, GatewayControlLeaseRejectionReasonSchema, GatewayControlLeaseSnapshotSchema, GatewayControlLeaseStaleEvidenceSchema, GatewayControlLeaseUseEndPayloadSchema, GatewayControlLeaseUseHeartbeatPayloadSchema, GatewayControlLeaseUseSnapshotSchema, GatewayControlLeaseUseStartPayloadSchema, GatewayControlOperationCancelPayloadSchema, GatewayControlPingPayloadSchema, GatewayControlPrivateLeaseSnapshotSchema, GatewayControlPrivateToolVmSshAccessSchema, GatewayControlProviderRuntimeHealthSchema, GatewayControlPublicLeaseSnapshotSchema, GatewayControlRecoveryCommandPayloadSchema, GatewayControlRegisteredCallerContextRefSchema, GatewayControlRpcApprovalAdmissionResponsePayloadSchema, GatewayControlRpcApprovalDispatchResponsePayloadSchema, GatewayControlRpcBareResponsePayloadSchema, GatewayControlRpcCallerContextResponsePayloadSchema, GatewayControlRpcCommandMessageSchema, GatewayControlRpcCommandResultMessageSchema, GatewayControlRpcCommandResultOperationSchema, GatewayControlRpcControllerHostActionResponsePayloadSchema, GatewayControlRpcDomainCorrelationSchema, GatewayControlRpcErrorSchema, GatewayControlRpcEventMessageSchema, GatewayControlRpcLeaseResponsePayloadSchema, GatewayControlRpcLeaseUseResponsePayloadSchema, GatewayControlRpcMessageSchema, GatewayControlRpcOperationCancelResponsePayloadSchema, GatewayControlRpcOperationSchema, GatewayControlRpcPrivateLeaseResponsePayloadSchema, GatewayControlRpcPublicLeaseResponsePayloadSchema, GatewayControlRpcResponseBasePayloadSchema, GatewayControlRpcResponsePayloadSchema, GatewayControlRpcResultSchema, GatewayControlRpcToolVmBindingRequestResponsePayloadSchema, GatewayControlRuntimeFindingSchema, GatewayControlRuntimeStatusPayloadSchema, GatewayControlSessionHealthOperationSchema, GatewayControlSessionStateSchema, GatewayControlToolCallCorrelationSchema, GatewayControlToolPortalAdmissionReservePayloadSchema, GatewayControlToolPortalControllerHostActionPayloadSchema, GatewayControlToolPortalControllerHostActionResultSchema, GatewayControlToolPortalDispatchArmPayloadSchema, GatewayControlToolVmBindingAccessGrantSchema, GatewayControlToolVmBindingIdentitySchema, GatewayControlToolVmBindingPublicationAuthoritySchema, GatewayControlToolVmBindingPublicationSchema, GatewayControlToolVmBindingRequestPayloadSchema, GatewayControlToolVmBindingRequestResultSchema, GatewayControlToolVmLeaseCallerContextStateSchema, GatewayControlToolVmLeaseLifecycleEventRoleSchema, GatewayControlToolVmLeaseLifecycleTransitionSchema, GatewayControlToolVmSshAccessSchema, GatewayControlToolVmSshHealthOperationSchema, GatewayControlTrustedCallerContextIdSchema, GatewayControlWorkspaceGitCommitSummarySchema, GatewayControlWorkspaceGitPushControllerHostActionPayloadSchema, GatewayControlWorkspaceGitPushControllerHostActionResultSchema, GatewayControlWorkspaceGitPushResultSchema, GatewayInitiatedOperationCancelPayloadSchema, GatewayRuntimeApprovalAdmissionResultSchema, GatewayRuntimeApprovalAmbiguousReasonSchema, GatewayRuntimeApprovalArmDispatchCommandSchema, GatewayRuntimeApprovalArmDispatchResultSchema, GatewayRuntimeApprovalAuthorityContextSchema, GatewayRuntimeApprovalCallSchema, GatewayRuntimeApprovalChallengeIntentSchema, GatewayRuntimeApprovalChallengeSchema, GatewayRuntimeApprovalDecisionCommandSchema, GatewayRuntimeApprovalDispatchGrantSchema, GatewayRuntimeApprovalDispatchReservationSchema, GatewayRuntimeApprovalFingerprintSchema, GatewayRuntimeApprovalNotDispatchedReasonSchema, GatewayRuntimeApprovalRevokeCommandSchema, GatewayRuntimeApprovalSemanticRevisionCohortSchema, GatewayRuntimeAttachmentSnapshotSchema, GatewayRuntimeControllerHostActionApprovalReservationDispatchAuthoritySchema, GatewayRuntimeControllerHostActionDirectDispatchAuthoritySchema, GatewayRuntimeControllerHostActionDispatchReservationSchema, GatewayRuntimeExpectedAttachmentIdentitySchema, GatewayRuntimeFatalEvidenceSchema, GatewayRuntimeFrameworkIdentitySchema, GatewayRuntimeFrameworkKindSchema, GatewayRuntimeGatewayDispatchReservationSchema, GatewayRuntimeManagedPluginClientKindSchema, GatewayRuntimeMcpProviderApprovalGrantDispatchAuthoritySchema, GatewayRuntimeMcpProviderDirectDispatchAuthoritySchema, GatewayRuntimeMcpProviderDispatchGrantSchema, GatewayRuntimeMcpProviderDispatchReservationSchema, GatewayRuntimePortalAdmissionMaterialSchema, GatewayRuntimePortalSemanticSnapshotSchema, GatewayRuntimePortalSurfaceClassSchema, GatewayRuntimeReadinessSnapshotSchema, GatewayRuntimeRequiredBackendKindSchema, GatewayRuntimeRequiredBackendsReadinessSchema, GatewayRuntimeToolPortalDispatchAuthoritySchema, GatewayRuntimeToolPortalProductionControlEndpointSchema, GatewayRuntimeToolVmRunnerApprovalGrantDispatchAuthoritySchema, GatewayRuntimeToolVmRunnerDirectDispatchAuthoritySchema, GatewayRuntimeToolVmRunnerDispatchGrantSchema, GatewayRuntimeToolVmRunnerDispatchReservationSchema, GatewayRuntimeTrustedInvocationContextSchema, GatewayRuntimeTrustedInvocationCorrelationSchema, GatewayRuntimeTrustedInvocationPrincipalSchema, GatewayRuntimeTrustedInvocationRequesterSchema, GatewayRuntimeUdsPublicationSnapshotSchema, ManagedAgentProjectionSchema, assertGatewayControlDomainRegistered, assertGatewayControlEnvelopeDeliveryPolicy, assertGatewayRuntimePortalSemanticSnapshotMatchesInputs, buildGatewayControlCallerContextAgentAuthorityPayload, buildGatewayControlCallerContextProofPayload, buildGatewayControlJsonSchemas, classifyGatewayControlAdmission, createGatewayControlAdmissionExecutor, createGatewayControlAdmissionScheduler, createGatewayControlProcessAdmission, createGatewayRuntimeAttachmentSnapshot, createGatewayRuntimeReadinessSnapshot, deriveGatewayControlDeliveryPolicy, deriveGatewayControlStablePrincipal, deriveGatewayRuntimeApprovalFingerprint, deriveGatewayRuntimeApprovalId, deriveGatewayRuntimePortalSemanticSnapshot, deriveManagedAgentProjection, gatewayControlCommandExecutionTimeoutMsByOperation, gatewayControlDeliveryPolicyByKind, gatewayControlDeliveryPolicyByOperation };
786
2390
 
787
2391
  //# sourceMappingURL=index.js.map