@agent-vm/gateway-control-contracts 0.0.109
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/LICENSE +21 -0
- package/dist/index.d.ts +3101 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +674 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;cAca,0BAAA,EAA0B,CAAA,CAAA,UAAA;AAAA,cAE1B,gCAAA,EAAgC,CAAA,CAAA,OAAA;;;;;;;;;;;;;;;;;cAkBhC,6BAAA,EAA6B,CAAA,CAAA,OAAA;;;;;;;;;;cAM7B,yCAAA,EAAyC,CAAA,CAAA,OAAA;;;;;;;;;;;;;;;;;;;;;cAsBzC,iCAAA,EAAiC,CAAA,CAAA,SAAA;;;;cAOjC,uCAAA,EAAuC,CAAA,CAAA,SAAA;;;;;;;;;;;;;cAIvC,0CAAA,EAA0C,CAAA,CAAA,SAAA;AAAA,cAE1C,uCAAA,EAAuC,CAAA,CAAA,SAAA;;;;;;;;;;;;cAevC,oCAAA,EAAoC,CAAA,CAAA,SAAA;;;cAMpC,+CAAA,EAA+C,CAAA,CAAA,UAAA;AAAA,cAE/C,sCAAA,EAAsC,CAAA,CAAA,SAAA;;;;cAOtC,+CAAA,EAA+C,CAAA,CAAA,SAAA;;;;;UAQ3C,4CAAA;EAAA,SACP,OAAA;EAAA,SACA,iBAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;EAAA,SACA,MAAA;AAAA;AAAA,iBAGM,4CAAA,CACf,KAAA,EAAO,4CAAA;AAAA,iBAcQ,qDAAA,CACf,KAAA,EAAO,4CAAA;AAAA,cAcK,gDAAA,EAAgD,CAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBhD,4CAAA,EAA4C,CAAA,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zC,sCAAA;AAAA,KAEI,yCAAA,GAA4C,CAAA,CAAE,KAAA,QAClD,+CAAA;AAAA,KAEI,0CAAA,GAA6C,CAAA,CAAE,KAAA,QACnD,gDAAA;AAAA,KAEI,sCAAA,GAAyC,CAAA,CAAE,KAAA,QAC/C,4CAAA;AAAA,KAEI,4BAAA,GAA+B,CAAA,CAAE,KAAA,QAAa,kCAAA;AAAA,KAC9C,2BAAA,GAA8B,CAAA,CAAE,KAAA,QAAa,iCAAA;AAAA,KAC7C,gCAAA,GAAmC,CAAA,CAAE,KAAA,QACzC,sCAAA;AAAA,KAEI,sCAAA,GAAyC,CAAA,CAAE,KAAA,QAC/C,4CAAA;AAAA,KAEI,8BAAA,GAAiC,CAAA,CAAE,KAAA,QAAa,oCAAA;AAAA,KAChD,kCAAA,GAAqC,CAAA,CAAE,KAAA,QAC3C,wCAAA;AAAA,KAEI,mCAAA,GAAsC,CAAA,CAAE,KAAA,QAC5C,yCAAA;AAAA,KAEI,8BAAA,GAAiC,CAAA,CAAE,KAAA,QAAa,oCAAA;AAAA,KAChD,gCAAA,GAAmC,CAAA,CAAE,KAAA,QACzC,sCAAA;AAAA,KAEI,kCAAA,GAAqC,CAAA,CAAE,KAAA,QAC3C,wCAAA;AAAA,KAEI,mDAAA,GAAsD,CAAA,CAAE,KAAA,QAC5D,yDAAA;AAAA,KAEI,kDAAA,GAAqD,CAAA,CAAE,KAAA,QAC3D,wDAAA;AAAA,KAEI,+BAAA,GAAkC,CAAA,CAAE,KAAA,QAAa,qCAAA;AAAA,iBAE7C,8BAAA,CAAA,GAAkC,QAAA,CAAS,MAAA;AAAA,iBAiB3C,oCAAA,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
import { ControlCorrelationSchema, ControlRpcErrorSchema, ControlRpcResultBaseSchema, ControlSessionStateSchema, KnownControlDomainSchema } from "@agent-vm/control-protocol-contracts";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
const GatewayControlDomainSchema = z.literal("gateway_control");
|
|
5
|
+
const GatewayControlRpcOperationSchema = z.enum([
|
|
6
|
+
"control_ping",
|
|
7
|
+
"caller_context_register",
|
|
8
|
+
"lease_create",
|
|
9
|
+
"lease_get",
|
|
10
|
+
"lease_peek",
|
|
11
|
+
"lease_renew",
|
|
12
|
+
"lease_release",
|
|
13
|
+
"lease_use_start",
|
|
14
|
+
"lease_use_heartbeat",
|
|
15
|
+
"lease_use_end",
|
|
16
|
+
"health_event",
|
|
17
|
+
"runtime_status",
|
|
18
|
+
"tool_portal_controller_host_action",
|
|
19
|
+
"operation_cancel",
|
|
20
|
+
"recovery_command"
|
|
21
|
+
]);
|
|
22
|
+
const GatewayControlRpcResultSchema = z.enum([
|
|
23
|
+
...ControlRpcResultBaseSchema.options,
|
|
24
|
+
"approval_required",
|
|
25
|
+
"approval_stale"
|
|
26
|
+
]);
|
|
27
|
+
const GatewayControlForbiddenPayloadFieldSchema = z.enum([
|
|
28
|
+
"adminToken",
|
|
29
|
+
"agentId",
|
|
30
|
+
"approvalProof",
|
|
31
|
+
"argv",
|
|
32
|
+
"controllerInstanceId",
|
|
33
|
+
"cwd",
|
|
34
|
+
"credentialProfileId",
|
|
35
|
+
"egressPolicy",
|
|
36
|
+
"env",
|
|
37
|
+
"executablePath",
|
|
38
|
+
"hostWorkMountDir",
|
|
39
|
+
"profileId",
|
|
40
|
+
"rawCredentialRef",
|
|
41
|
+
"retryPolicy",
|
|
42
|
+
"routeToken",
|
|
43
|
+
"sessionKey",
|
|
44
|
+
"sshIdentityPem",
|
|
45
|
+
"vmGenerationOverride",
|
|
46
|
+
"workMountDir"
|
|
47
|
+
]);
|
|
48
|
+
const GatewayControlCapabilityRefSchema = z.object({
|
|
49
|
+
name: z.string().min(1),
|
|
50
|
+
namespace: z.string().min(1)
|
|
51
|
+
}).strict();
|
|
52
|
+
const GatewayControlToolCallCorrelationSchema = ControlCorrelationSchema.extend({ capability: GatewayControlCapabilityRefSchema.optional() }).strict();
|
|
53
|
+
const GatewayControlTrustedCallerContextIdSchema = z.string().uuid();
|
|
54
|
+
const GatewayControlTrustedLeaseContextSchema = z.object({
|
|
55
|
+
agentId: z.string().min(1),
|
|
56
|
+
agentWorkspaceDir: z.string().min(1),
|
|
57
|
+
approvalScopeId: z.string().min(1).optional(),
|
|
58
|
+
callerContextId: GatewayControlTrustedCallerContextIdSchema,
|
|
59
|
+
custodyScopeId: z.string().min(1).optional(),
|
|
60
|
+
hostWorkMountDir: z.string().min(1),
|
|
61
|
+
profileId: z.string().min(1),
|
|
62
|
+
sessionKeyDigest: z.string().min(32),
|
|
63
|
+
workMountDir: z.string().min(1),
|
|
64
|
+
zoneId: z.string().min(1)
|
|
65
|
+
}).strict();
|
|
66
|
+
const GatewayControlCallerContextRefSchema = z.object({ callerContextId: GatewayControlTrustedCallerContextIdSchema }).strict();
|
|
67
|
+
const GatewayControlCallerContextProofAlgorithmSchema = z.literal("hmac-sha256");
|
|
68
|
+
const GatewayControlCallerContextProofSchema = z.object({
|
|
69
|
+
algorithm: GatewayControlCallerContextProofAlgorithmSchema,
|
|
70
|
+
digest: z.string().min(32)
|
|
71
|
+
}).strict();
|
|
72
|
+
const GatewayControlCallerContextAgentAuthoritySchema = z.object({
|
|
73
|
+
algorithm: GatewayControlCallerContextProofAlgorithmSchema,
|
|
74
|
+
digest: z.string().min(32),
|
|
75
|
+
keyId: z.string().min(1)
|
|
76
|
+
}).strict();
|
|
77
|
+
function buildGatewayControlCallerContextProofPayload(input) {
|
|
78
|
+
const purpose = input.purpose ?? "tool_vm_lease";
|
|
79
|
+
return [
|
|
80
|
+
"gateway-control-caller-context-v1",
|
|
81
|
+
input.zoneId,
|
|
82
|
+
input.agentId,
|
|
83
|
+
input.agentWorkspaceDir,
|
|
84
|
+
input.workMountDir,
|
|
85
|
+
input.sessionKey,
|
|
86
|
+
purpose
|
|
87
|
+
].join("\0");
|
|
88
|
+
}
|
|
89
|
+
function buildGatewayControlCallerContextAgentAuthorityPayload(input) {
|
|
90
|
+
const purpose = input.purpose ?? "tool_vm_lease";
|
|
91
|
+
return [
|
|
92
|
+
"gateway-control-agent-authority-v1",
|
|
93
|
+
input.zoneId,
|
|
94
|
+
input.agentId,
|
|
95
|
+
input.agentWorkspaceDir,
|
|
96
|
+
input.workMountDir,
|
|
97
|
+
input.sessionKey,
|
|
98
|
+
purpose
|
|
99
|
+
].join("\0");
|
|
100
|
+
}
|
|
101
|
+
const GatewayControlCallerContextRegisterPayloadSchema = z.object({
|
|
102
|
+
adapterEvidence: z.object({
|
|
103
|
+
agentAuthority: GatewayControlCallerContextAgentAuthoritySchema,
|
|
104
|
+
agentId: z.string().min(1),
|
|
105
|
+
agentWorkspaceDir: z.string().min(1),
|
|
106
|
+
proof: GatewayControlCallerContextProofSchema,
|
|
107
|
+
purpose: z.enum(["tool_vm_lease", "tool_portal_controller_host_action"]).optional(),
|
|
108
|
+
sessionKey: z.string().min(1),
|
|
109
|
+
workMountDir: z.string().min(1),
|
|
110
|
+
zoneId: z.string().min(1)
|
|
111
|
+
}).strict(),
|
|
112
|
+
correlation: GatewayControlToolCallCorrelationSchema.optional()
|
|
113
|
+
}).strict();
|
|
114
|
+
const GatewayControlLeaseCreateIntentPayloadSchema = z.object({
|
|
115
|
+
callerContext: GatewayControlCallerContextRefSchema,
|
|
116
|
+
correlation: GatewayControlToolCallCorrelationSchema.optional(),
|
|
117
|
+
gatewayWorkspaceDir: z.string().min(1).optional(),
|
|
118
|
+
idleTtlHintMs: z.number().int().positive().optional()
|
|
119
|
+
}).strict();
|
|
120
|
+
const GatewayControlLeaseIdPayloadSchema = z.object({
|
|
121
|
+
callerContext: GatewayControlCallerContextRefSchema,
|
|
122
|
+
leaseId: z.string().min(1)
|
|
123
|
+
}).strict();
|
|
124
|
+
const GatewayControlLeaseUseStartPayloadSchema = z.object({
|
|
125
|
+
callerContext: GatewayControlCallerContextRefSchema,
|
|
126
|
+
correlation: GatewayControlToolCallCorrelationSchema.optional(),
|
|
127
|
+
leaseId: z.string().min(1),
|
|
128
|
+
useId: z.string().uuid()
|
|
129
|
+
}).strict();
|
|
130
|
+
const GatewayControlLeaseUseHeartbeatPayloadSchema = z.object({
|
|
131
|
+
callerContext: GatewayControlCallerContextRefSchema,
|
|
132
|
+
leaseId: z.string().min(1),
|
|
133
|
+
observedAtMs: z.number().int().positive().optional(),
|
|
134
|
+
useId: z.string().uuid()
|
|
135
|
+
}).strict();
|
|
136
|
+
const GatewayControlLeaseUseEndPayloadSchema = z.object({
|
|
137
|
+
callerContext: GatewayControlCallerContextRefSchema,
|
|
138
|
+
leaseId: z.string().min(1),
|
|
139
|
+
reason: z.enum([
|
|
140
|
+
"completed",
|
|
141
|
+
"failed",
|
|
142
|
+
"cancelled",
|
|
143
|
+
"timed_out"
|
|
144
|
+
]),
|
|
145
|
+
useId: z.string().uuid()
|
|
146
|
+
}).strict();
|
|
147
|
+
const GatewayControlHealthEventResultSchema = z.enum([
|
|
148
|
+
"ok",
|
|
149
|
+
"failed",
|
|
150
|
+
"timeout",
|
|
151
|
+
"degraded"
|
|
152
|
+
]);
|
|
153
|
+
const GatewayControlProviderRuntimeHealthSchema = z.enum([
|
|
154
|
+
"healthy",
|
|
155
|
+
"transitioning",
|
|
156
|
+
"unhealthy_recoverable",
|
|
157
|
+
"unhealthy_unrecoverable"
|
|
158
|
+
]);
|
|
159
|
+
const GatewayControlControllerRequestHealthOperationSchema = z.enum([
|
|
160
|
+
"zone-git-push",
|
|
161
|
+
"lease-create",
|
|
162
|
+
"lease-get",
|
|
163
|
+
"lease-peek",
|
|
164
|
+
"lease-release",
|
|
165
|
+
"lease-use-start",
|
|
166
|
+
"lease-use-end"
|
|
167
|
+
]);
|
|
168
|
+
const GatewayControlSessionHealthOperationSchema = z.enum([
|
|
169
|
+
"control-session-hello",
|
|
170
|
+
"control-session-heartbeat",
|
|
171
|
+
"control-session-disconnect",
|
|
172
|
+
"control-session-reconnect"
|
|
173
|
+
]);
|
|
174
|
+
const GatewayControlToolVmSshHealthOperationSchema = z.enum([
|
|
175
|
+
"command",
|
|
176
|
+
"file-bridge",
|
|
177
|
+
"finalize",
|
|
178
|
+
"probe"
|
|
179
|
+
]);
|
|
180
|
+
const GatewayControlHealthEventBaseSchema = z.object({
|
|
181
|
+
correlation: ControlCorrelationSchema.optional(),
|
|
182
|
+
observedAtMs: z.number().int().positive(),
|
|
183
|
+
result: GatewayControlHealthEventResultSchema
|
|
184
|
+
}).strict();
|
|
185
|
+
const GatewayControlHealthEventPayloadSchema = z.discriminatedUnion("eventKind", [
|
|
186
|
+
GatewayControlHealthEventBaseSchema.extend({
|
|
187
|
+
channelProviderId: z.string().min(1),
|
|
188
|
+
eventKind: z.literal("agent-channel-provider-health"),
|
|
189
|
+
providerRuntimeHealth: GatewayControlProviderRuntimeHealthSchema,
|
|
190
|
+
safeDetails: z.record(z.string(), z.string()).optional()
|
|
191
|
+
}).strict(),
|
|
192
|
+
GatewayControlHealthEventBaseSchema.extend({
|
|
193
|
+
attempt: z.number().int().positive(),
|
|
194
|
+
elapsedMs: z.number().int().nonnegative(),
|
|
195
|
+
errorCode: z.string().min(1).optional(),
|
|
196
|
+
eventKind: z.literal("controller-request"),
|
|
197
|
+
maxAttempts: z.number().int().positive(),
|
|
198
|
+
operation: GatewayControlControllerRequestHealthOperationSchema,
|
|
199
|
+
statusCode: z.number().int().positive().optional()
|
|
200
|
+
}).strict(),
|
|
201
|
+
GatewayControlHealthEventBaseSchema.extend({
|
|
202
|
+
elapsedMs: z.number().int().nonnegative(),
|
|
203
|
+
eventKind: z.literal("gateway-control-session"),
|
|
204
|
+
operation: GatewayControlSessionHealthOperationSchema,
|
|
205
|
+
safeDetails: z.object({ peerId: z.string().min(1) }).catchall(z.string())
|
|
206
|
+
}).strict(),
|
|
207
|
+
GatewayControlHealthEventBaseSchema.extend({ eventKind: z.literal("gateway-plugin-health") }).strict(),
|
|
208
|
+
GatewayControlHealthEventBaseSchema.extend({
|
|
209
|
+
agentId: z.string().min(1),
|
|
210
|
+
elapsedMs: z.number().int().nonnegative(),
|
|
211
|
+
errorCode: z.string().min(1).optional(),
|
|
212
|
+
leaseId: z.string().min(1),
|
|
213
|
+
eventKind: z.literal("tool-vm-ssh"),
|
|
214
|
+
operation: GatewayControlToolVmSshHealthOperationSchema
|
|
215
|
+
}).strict()
|
|
216
|
+
]);
|
|
217
|
+
const GatewayControlRuntimeFindingSchema = z.object({
|
|
218
|
+
id: z.string().min(1),
|
|
219
|
+
ok: z.boolean(),
|
|
220
|
+
safeMessage: z.string().min(1).optional(),
|
|
221
|
+
severity: z.enum([
|
|
222
|
+
"info",
|
|
223
|
+
"warning",
|
|
224
|
+
"error"
|
|
225
|
+
]).optional()
|
|
226
|
+
}).strict();
|
|
227
|
+
const GatewayControlRuntimeStatusPayloadSchema = z.object({
|
|
228
|
+
findings: z.array(GatewayControlRuntimeFindingSchema),
|
|
229
|
+
observedAtMs: z.number().int().positive(),
|
|
230
|
+
providerRuntimeHealth: z.enum([
|
|
231
|
+
"healthy",
|
|
232
|
+
"transitioning",
|
|
233
|
+
"unhealthy_recoverable",
|
|
234
|
+
"unhealthy_unrecoverable"
|
|
235
|
+
]).optional(),
|
|
236
|
+
statusKind: z.string().min(1)
|
|
237
|
+
}).strict();
|
|
238
|
+
const GatewayControlToolPortalControllerHostActionPayloadSchema = z.object({
|
|
239
|
+
actionId: z.literal("zone_git_push"),
|
|
240
|
+
callerContext: GatewayControlCallerContextRefSchema,
|
|
241
|
+
correlation: GatewayControlToolCallCorrelationSchema,
|
|
242
|
+
expectedHead: z.string().min(1)
|
|
243
|
+
}).strict();
|
|
244
|
+
const GatewayControlZoneGitCommitSummarySchema = z.object({
|
|
245
|
+
sha: z.string().min(1),
|
|
246
|
+
subject: z.string()
|
|
247
|
+
}).strict();
|
|
248
|
+
const GatewayControlZoneGitPushResultSchema = z.object({
|
|
249
|
+
branch: z.string().min(1),
|
|
250
|
+
localHead: z.string().min(1),
|
|
251
|
+
pushedCommits: z.array(GatewayControlZoneGitCommitSummarySchema),
|
|
252
|
+
remoteHead: z.string().min(1)
|
|
253
|
+
}).strict();
|
|
254
|
+
const GatewayControlToolPortalControllerHostActionResultSchema = z.object({
|
|
255
|
+
actionId: z.literal("zone_git_push"),
|
|
256
|
+
result: GatewayControlZoneGitPushResultSchema
|
|
257
|
+
}).strict();
|
|
258
|
+
const GatewayControlActiveOperationIdSchema = z.string().uuid();
|
|
259
|
+
const GatewayInitiatedOperationCancelPayloadSchema = z.object({
|
|
260
|
+
activeOperationId: GatewayControlActiveOperationIdSchema,
|
|
261
|
+
initiatedBy: z.literal("gateway"),
|
|
262
|
+
reason: z.enum([
|
|
263
|
+
"caller_cancelled",
|
|
264
|
+
"gateway_shutdown",
|
|
265
|
+
"operation_failed"
|
|
266
|
+
])
|
|
267
|
+
}).strict();
|
|
268
|
+
const ControllerInitiatedGatewayOperationCancelPayloadSchema = z.object({
|
|
269
|
+
activeOperationId: GatewayControlActiveOperationIdSchema,
|
|
270
|
+
initiatedBy: z.literal("controller"),
|
|
271
|
+
reason: z.enum([
|
|
272
|
+
"controller_recovery",
|
|
273
|
+
"operator_cancelled",
|
|
274
|
+
"timeout"
|
|
275
|
+
])
|
|
276
|
+
}).strict();
|
|
277
|
+
const GatewayControlOperationCancelPayloadSchema = z.discriminatedUnion("initiatedBy", [GatewayInitiatedOperationCancelPayloadSchema, ControllerInitiatedGatewayOperationCancelPayloadSchema]);
|
|
278
|
+
const GatewayControlRecoveryCommandPayloadSchema = z.discriminatedUnion("action", [
|
|
279
|
+
z.object({ action: z.literal("refresh_runtime_status") }).strict(),
|
|
280
|
+
z.object({ action: z.literal("restart_control_service") }).strict(),
|
|
281
|
+
z.object({
|
|
282
|
+
action: z.literal("close_stale_session"),
|
|
283
|
+
targetSessionId: z.string().uuid()
|
|
284
|
+
}).strict()
|
|
285
|
+
]);
|
|
286
|
+
const GatewayControlPingPayloadSchema = z.object({}).strict();
|
|
287
|
+
const GatewayControlHeartbeatPayloadSchema = z.object({
|
|
288
|
+
elapsedMs: z.number().int().nonnegative().optional(),
|
|
289
|
+
observedAtMs: z.number().int().positive()
|
|
290
|
+
}).strict();
|
|
291
|
+
const GatewayControlRpcErrorSchema = ControlRpcErrorSchema;
|
|
292
|
+
const GatewayControlSessionStateSchema = ControlSessionStateSchema;
|
|
293
|
+
const GatewayControlToolVmSshAccessSchema = z.object({
|
|
294
|
+
host: z.string().min(1),
|
|
295
|
+
identityPem: z.string().min(1).optional(),
|
|
296
|
+
knownHostsLine: z.string().optional(),
|
|
297
|
+
port: z.number().int().positive(),
|
|
298
|
+
user: z.string().min(1)
|
|
299
|
+
}).strict();
|
|
300
|
+
const GatewayControlLeaseSnapshotSchema = z.object({
|
|
301
|
+
agentId: z.string().min(1),
|
|
302
|
+
activeUseId: z.string().uuid().optional(),
|
|
303
|
+
expiresAtMs: z.number().int().positive().optional(),
|
|
304
|
+
idleTtlMs: z.number().int().positive(),
|
|
305
|
+
leaseId: z.string().min(1),
|
|
306
|
+
ssh: GatewayControlToolVmSshAccessSchema.optional(),
|
|
307
|
+
state: z.enum([
|
|
308
|
+
"idle",
|
|
309
|
+
"active",
|
|
310
|
+
"expired",
|
|
311
|
+
"released"
|
|
312
|
+
]),
|
|
313
|
+
tcpSlot: z.number().int().nonnegative(),
|
|
314
|
+
transport: z.literal("ssh-sandbox"),
|
|
315
|
+
workdir: z.string().min(1),
|
|
316
|
+
zoneId: z.string().min(1)
|
|
317
|
+
}).strict();
|
|
318
|
+
const GatewayControlLeaseUseSnapshotSchema = z.object({
|
|
319
|
+
expiresAt: z.number().int().positive().optional(),
|
|
320
|
+
heartbeatAfterMs: z.number().int().positive().optional(),
|
|
321
|
+
leaseId: z.string().min(1),
|
|
322
|
+
state: z.enum([
|
|
323
|
+
"active",
|
|
324
|
+
"ended",
|
|
325
|
+
"expired"
|
|
326
|
+
]),
|
|
327
|
+
useId: z.string().uuid()
|
|
328
|
+
}).strict();
|
|
329
|
+
const GatewayControlLeaseRejectionReasonSchema = z.enum([
|
|
330
|
+
"absent",
|
|
331
|
+
"generation_stale",
|
|
332
|
+
"force_released",
|
|
333
|
+
"releasing",
|
|
334
|
+
"use_tombstoned",
|
|
335
|
+
"runtime_not_ready"
|
|
336
|
+
]);
|
|
337
|
+
const GatewayControlRpcDomainCorrelationSchema = ControlCorrelationSchema;
|
|
338
|
+
const GatewayControlRpcForbiddenResponseFieldsSchema = {
|
|
339
|
+
activeOperationId: z.never().optional(),
|
|
340
|
+
approvalRequired: z.never().optional(),
|
|
341
|
+
callerContext: z.never().optional(),
|
|
342
|
+
controllerHostAction: z.never().optional(),
|
|
343
|
+
error: z.never().optional(),
|
|
344
|
+
lease: z.never().optional(),
|
|
345
|
+
leaseRejectionReason: z.never().optional(),
|
|
346
|
+
leaseUse: z.never().optional()
|
|
347
|
+
};
|
|
348
|
+
const GatewayControlRpcResponseBasePayloadSchema = z.object({
|
|
349
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
350
|
+
responseToMessageId: z.string().uuid(),
|
|
351
|
+
result: GatewayControlRpcResultSchema
|
|
352
|
+
});
|
|
353
|
+
const GatewayControlRpcErrorResponseResultSchema = z.enum([
|
|
354
|
+
"failed",
|
|
355
|
+
"timeout",
|
|
356
|
+
"rejected",
|
|
357
|
+
"cancelled",
|
|
358
|
+
"stale_generation",
|
|
359
|
+
"approval_required",
|
|
360
|
+
"approval_stale"
|
|
361
|
+
]);
|
|
362
|
+
const GatewayControlRpcResponseCorrelationSchema = z.object({ responseToMessageId: z.string().uuid() }).strict();
|
|
363
|
+
const GatewayControlRpcBareResponsePayloadSchema = z.discriminatedUnion("result", [GatewayControlRpcResponseCorrelationSchema.extend({
|
|
364
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
365
|
+
result: z.literal("ok")
|
|
366
|
+
}).strict(), GatewayControlRpcResponseCorrelationSchema.extend({
|
|
367
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
368
|
+
error: GatewayControlRpcErrorSchema,
|
|
369
|
+
result: GatewayControlRpcErrorResponseResultSchema
|
|
370
|
+
}).strict()]);
|
|
371
|
+
const GatewayControlRpcCallerContextResponsePayloadSchema = z.discriminatedUnion("result", [GatewayControlRpcResponseCorrelationSchema.extend({
|
|
372
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
373
|
+
callerContext: GatewayControlCallerContextRefSchema,
|
|
374
|
+
result: z.literal("ok")
|
|
375
|
+
}).strict(), GatewayControlRpcResponseCorrelationSchema.extend({
|
|
376
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
377
|
+
error: GatewayControlRpcErrorSchema,
|
|
378
|
+
result: GatewayControlRpcErrorResponseResultSchema
|
|
379
|
+
}).strict()]);
|
|
380
|
+
const GatewayControlRpcLeaseResponsePayloadSchema = z.discriminatedUnion("result", [
|
|
381
|
+
GatewayControlRpcResponseCorrelationSchema.extend({
|
|
382
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
383
|
+
lease: GatewayControlLeaseSnapshotSchema,
|
|
384
|
+
result: z.literal("ok")
|
|
385
|
+
}).strict(),
|
|
386
|
+
GatewayControlRpcResponseCorrelationSchema.extend({
|
|
387
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
388
|
+
error: GatewayControlRpcErrorSchema.optional(),
|
|
389
|
+
leaseRejectionReason: GatewayControlLeaseRejectionReasonSchema,
|
|
390
|
+
result: z.literal("rejected")
|
|
391
|
+
}).strict(),
|
|
392
|
+
GatewayControlRpcResponseCorrelationSchema.extend({
|
|
393
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
394
|
+
error: GatewayControlRpcErrorSchema,
|
|
395
|
+
leaseRejectionReason: GatewayControlLeaseRejectionReasonSchema.optional(),
|
|
396
|
+
result: z.enum([
|
|
397
|
+
"failed",
|
|
398
|
+
"timeout",
|
|
399
|
+
"cancelled",
|
|
400
|
+
"stale_generation",
|
|
401
|
+
"approval_required",
|
|
402
|
+
"approval_stale"
|
|
403
|
+
])
|
|
404
|
+
}).strict()
|
|
405
|
+
]);
|
|
406
|
+
const GatewayControlRpcLeaseUseResponsePayloadSchema = z.discriminatedUnion("result", [
|
|
407
|
+
GatewayControlRpcResponseCorrelationSchema.extend({
|
|
408
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
409
|
+
leaseUse: GatewayControlLeaseUseSnapshotSchema,
|
|
410
|
+
result: z.literal("ok")
|
|
411
|
+
}).strict(),
|
|
412
|
+
GatewayControlRpcResponseCorrelationSchema.extend({
|
|
413
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
414
|
+
error: GatewayControlRpcErrorSchema.optional(),
|
|
415
|
+
leaseRejectionReason: GatewayControlLeaseRejectionReasonSchema,
|
|
416
|
+
result: z.literal("rejected")
|
|
417
|
+
}).strict(),
|
|
418
|
+
GatewayControlRpcResponseCorrelationSchema.extend({
|
|
419
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
420
|
+
error: GatewayControlRpcErrorSchema,
|
|
421
|
+
leaseRejectionReason: GatewayControlLeaseRejectionReasonSchema.optional(),
|
|
422
|
+
result: z.enum([
|
|
423
|
+
"failed",
|
|
424
|
+
"timeout",
|
|
425
|
+
"cancelled",
|
|
426
|
+
"stale_generation",
|
|
427
|
+
"approval_required",
|
|
428
|
+
"approval_stale"
|
|
429
|
+
])
|
|
430
|
+
}).strict()
|
|
431
|
+
]);
|
|
432
|
+
const GatewayControlRpcControllerHostActionResponsePayloadSchema = z.discriminatedUnion("result", [GatewayControlRpcResponseCorrelationSchema.extend({
|
|
433
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
434
|
+
controllerHostAction: GatewayControlToolPortalControllerHostActionResultSchema,
|
|
435
|
+
result: z.literal("ok")
|
|
436
|
+
}).strict(), GatewayControlRpcResponseCorrelationSchema.extend({
|
|
437
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
438
|
+
error: GatewayControlRpcErrorSchema,
|
|
439
|
+
result: GatewayControlRpcErrorResponseResultSchema
|
|
440
|
+
}).strict()]);
|
|
441
|
+
const GatewayControlRpcOperationCancelResponsePayloadSchema = z.discriminatedUnion("result", [GatewayControlRpcResponseCorrelationSchema.extend({
|
|
442
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
443
|
+
activeOperationId: GatewayControlActiveOperationIdSchema,
|
|
444
|
+
result: z.literal("ok")
|
|
445
|
+
}).strict(), GatewayControlRpcResponseCorrelationSchema.extend({
|
|
446
|
+
...GatewayControlRpcForbiddenResponseFieldsSchema,
|
|
447
|
+
activeOperationId: GatewayControlActiveOperationIdSchema.optional(),
|
|
448
|
+
error: GatewayControlRpcErrorSchema,
|
|
449
|
+
result: GatewayControlRpcErrorResponseResultSchema
|
|
450
|
+
}).strict()]);
|
|
451
|
+
const GatewayControlRpcResponsePayloadSchema = z.union([
|
|
452
|
+
GatewayControlRpcBareResponsePayloadSchema,
|
|
453
|
+
GatewayControlRpcCallerContextResponsePayloadSchema,
|
|
454
|
+
GatewayControlRpcLeaseResponsePayloadSchema,
|
|
455
|
+
GatewayControlRpcLeaseUseResponsePayloadSchema,
|
|
456
|
+
GatewayControlRpcControllerHostActionResponsePayloadSchema,
|
|
457
|
+
GatewayControlRpcOperationCancelResponsePayloadSchema
|
|
458
|
+
]);
|
|
459
|
+
const GatewayControlRpcControlPingCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
|
|
460
|
+
kind: z.literal("command_result"),
|
|
461
|
+
operation: z.literal("control_ping"),
|
|
462
|
+
payload: GatewayControlRpcBareResponsePayloadSchema
|
|
463
|
+
}).strict();
|
|
464
|
+
const GatewayControlRpcCallerContextRegisterCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
|
|
465
|
+
kind: z.literal("command_result"),
|
|
466
|
+
operation: z.literal("caller_context_register"),
|
|
467
|
+
payload: GatewayControlRpcCallerContextResponsePayloadSchema
|
|
468
|
+
}).strict();
|
|
469
|
+
const GatewayControlRpcLeaseCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
|
|
470
|
+
kind: z.literal("command_result"),
|
|
471
|
+
operation: z.enum([
|
|
472
|
+
"lease_create",
|
|
473
|
+
"lease_get",
|
|
474
|
+
"lease_peek",
|
|
475
|
+
"lease_renew",
|
|
476
|
+
"lease_release"
|
|
477
|
+
]),
|
|
478
|
+
payload: GatewayControlRpcLeaseResponsePayloadSchema
|
|
479
|
+
}).strict();
|
|
480
|
+
const GatewayControlRpcLeaseUseCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
|
|
481
|
+
kind: z.literal("command_result"),
|
|
482
|
+
operation: z.enum([
|
|
483
|
+
"lease_use_start",
|
|
484
|
+
"lease_use_heartbeat",
|
|
485
|
+
"lease_use_end"
|
|
486
|
+
]),
|
|
487
|
+
payload: GatewayControlRpcLeaseUseResponsePayloadSchema
|
|
488
|
+
}).strict();
|
|
489
|
+
const GatewayControlRpcControllerHostActionCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
|
|
490
|
+
kind: z.literal("command_result"),
|
|
491
|
+
operation: z.literal("tool_portal_controller_host_action"),
|
|
492
|
+
payload: GatewayControlRpcControllerHostActionResponsePayloadSchema
|
|
493
|
+
}).strict();
|
|
494
|
+
const GatewayControlRpcOperationCancelCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
|
|
495
|
+
kind: z.literal("command_result"),
|
|
496
|
+
operation: z.literal("operation_cancel"),
|
|
497
|
+
payload: GatewayControlRpcOperationCancelResponsePayloadSchema
|
|
498
|
+
}).strict();
|
|
499
|
+
const GatewayControlRpcRecoveryCommandResultMessageSchema = GatewayControlRpcDomainCorrelationSchema.extend({
|
|
500
|
+
kind: z.literal("command_result"),
|
|
501
|
+
operation: z.literal("recovery_command"),
|
|
502
|
+
payload: GatewayControlRpcBareResponsePayloadSchema
|
|
503
|
+
}).strict();
|
|
504
|
+
const GatewayControlHeartbeatMessageSchema = z.object({
|
|
505
|
+
kind: z.literal("heartbeat"),
|
|
506
|
+
operation: z.never().optional(),
|
|
507
|
+
payload: GatewayControlHeartbeatPayloadSchema
|
|
508
|
+
}).strict();
|
|
509
|
+
const GatewayControlRpcCommandResultMessageSchema = z.discriminatedUnion("operation", [
|
|
510
|
+
GatewayControlRpcControlPingCommandResultMessageSchema,
|
|
511
|
+
GatewayControlRpcCallerContextRegisterCommandResultMessageSchema,
|
|
512
|
+
GatewayControlRpcLeaseCommandResultMessageSchema,
|
|
513
|
+
GatewayControlRpcLeaseUseCommandResultMessageSchema,
|
|
514
|
+
GatewayControlRpcControllerHostActionCommandResultMessageSchema,
|
|
515
|
+
GatewayControlRpcOperationCancelCommandResultMessageSchema,
|
|
516
|
+
GatewayControlRpcRecoveryCommandResultMessageSchema
|
|
517
|
+
]);
|
|
518
|
+
const GatewayControlRpcCommandMessageSchema = z.discriminatedUnion("operation", [
|
|
519
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
520
|
+
kind: z.literal("command"),
|
|
521
|
+
operation: z.literal("control_ping"),
|
|
522
|
+
payload: GatewayControlPingPayloadSchema
|
|
523
|
+
}).strict(),
|
|
524
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
525
|
+
kind: z.literal("command"),
|
|
526
|
+
operation: z.literal("caller_context_register"),
|
|
527
|
+
payload: GatewayControlCallerContextRegisterPayloadSchema
|
|
528
|
+
}).strict(),
|
|
529
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
530
|
+
kind: z.literal("command"),
|
|
531
|
+
operation: z.literal("lease_create"),
|
|
532
|
+
payload: GatewayControlLeaseCreateIntentPayloadSchema
|
|
533
|
+
}).strict(),
|
|
534
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
535
|
+
kind: z.literal("command"),
|
|
536
|
+
operation: z.literal("lease_get"),
|
|
537
|
+
payload: GatewayControlLeaseIdPayloadSchema
|
|
538
|
+
}).strict(),
|
|
539
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
540
|
+
kind: z.literal("command"),
|
|
541
|
+
operation: z.literal("lease_peek"),
|
|
542
|
+
payload: GatewayControlLeaseIdPayloadSchema
|
|
543
|
+
}).strict(),
|
|
544
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
545
|
+
kind: z.literal("command"),
|
|
546
|
+
operation: z.literal("lease_renew"),
|
|
547
|
+
payload: GatewayControlLeaseIdPayloadSchema
|
|
548
|
+
}).strict(),
|
|
549
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
550
|
+
kind: z.literal("command"),
|
|
551
|
+
operation: z.literal("lease_release"),
|
|
552
|
+
payload: GatewayControlLeaseIdPayloadSchema
|
|
553
|
+
}).strict(),
|
|
554
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
555
|
+
kind: z.literal("command"),
|
|
556
|
+
operation: z.literal("lease_use_start"),
|
|
557
|
+
payload: GatewayControlLeaseUseStartPayloadSchema
|
|
558
|
+
}).strict(),
|
|
559
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
560
|
+
kind: z.literal("command"),
|
|
561
|
+
operation: z.literal("lease_use_heartbeat"),
|
|
562
|
+
payload: GatewayControlLeaseUseHeartbeatPayloadSchema
|
|
563
|
+
}).strict(),
|
|
564
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
565
|
+
kind: z.literal("command"),
|
|
566
|
+
operation: z.literal("lease_use_end"),
|
|
567
|
+
payload: GatewayControlLeaseUseEndPayloadSchema
|
|
568
|
+
}).strict(),
|
|
569
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
570
|
+
kind: z.literal("command"),
|
|
571
|
+
operation: z.literal("tool_portal_controller_host_action"),
|
|
572
|
+
payload: GatewayControlToolPortalControllerHostActionPayloadSchema
|
|
573
|
+
}).strict(),
|
|
574
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
575
|
+
kind: z.literal("command"),
|
|
576
|
+
operation: z.literal("operation_cancel"),
|
|
577
|
+
payload: GatewayControlOperationCancelPayloadSchema
|
|
578
|
+
}).strict(),
|
|
579
|
+
GatewayControlRpcDomainCorrelationSchema.extend({
|
|
580
|
+
kind: z.literal("command"),
|
|
581
|
+
operation: z.literal("recovery_command"),
|
|
582
|
+
payload: GatewayControlRecoveryCommandPayloadSchema
|
|
583
|
+
}).strict()
|
|
584
|
+
]);
|
|
585
|
+
const GatewayControlRpcEventMessageSchema = z.discriminatedUnion("operation", [GatewayControlRpcDomainCorrelationSchema.extend({
|
|
586
|
+
kind: z.literal("event"),
|
|
587
|
+
operation: z.literal("health_event"),
|
|
588
|
+
payload: GatewayControlHealthEventPayloadSchema
|
|
589
|
+
}).strict(), GatewayControlRpcDomainCorrelationSchema.extend({
|
|
590
|
+
kind: z.literal("event"),
|
|
591
|
+
operation: z.literal("runtime_status"),
|
|
592
|
+
payload: GatewayControlRuntimeStatusPayloadSchema
|
|
593
|
+
}).strict()]);
|
|
594
|
+
const GatewayControlEventOnlyOperationSchema = z.enum(["health_event", "runtime_status"]);
|
|
595
|
+
const GatewayControlRpcCommandResultOperationSchema = GatewayControlRpcOperationSchema.exclude(GatewayControlEventOnlyOperationSchema.options);
|
|
596
|
+
const GatewayControlRpcMessageSchema = z.union([
|
|
597
|
+
GatewayControlHeartbeatMessageSchema,
|
|
598
|
+
GatewayControlRpcCommandMessageSchema,
|
|
599
|
+
GatewayControlRpcEventMessageSchema,
|
|
600
|
+
GatewayControlRpcCommandResultMessageSchema
|
|
601
|
+
]);
|
|
602
|
+
const gatewayControlDeliveryPolicyByKind = { heartbeat: "critical_idempotent" };
|
|
603
|
+
const gatewayControlDeliveryPolicyByOperation = {
|
|
604
|
+
caller_context_register: "critical_idempotent",
|
|
605
|
+
control_ping: "acked_idempotent",
|
|
606
|
+
health_event: "append_only_observation",
|
|
607
|
+
lease_create: "critical_idempotent",
|
|
608
|
+
lease_get: "acked_idempotent",
|
|
609
|
+
lease_peek: "acked_idempotent",
|
|
610
|
+
lease_release: "acked_idempotent",
|
|
611
|
+
lease_renew: "single_use_critical",
|
|
612
|
+
lease_use_end: "acked_idempotent",
|
|
613
|
+
lease_use_heartbeat: "single_use_critical",
|
|
614
|
+
lease_use_start: "critical_idempotent",
|
|
615
|
+
operation_cancel: "acked_idempotent",
|
|
616
|
+
recovery_command: "critical_idempotent",
|
|
617
|
+
runtime_status: "latest_wins",
|
|
618
|
+
tool_portal_controller_host_action: "single_use_critical"
|
|
619
|
+
};
|
|
620
|
+
function deriveGatewayControlDeliveryPolicy(envelope) {
|
|
621
|
+
if (envelope.operation === "lease_create" && envelope.idempotencyKey === void 0) return "single_use_critical";
|
|
622
|
+
const parsedOperation = GatewayControlRpcOperationSchema.safeParse(envelope.operation);
|
|
623
|
+
if (parsedOperation.success) {
|
|
624
|
+
const operationPolicy = gatewayControlDeliveryPolicyByOperation[parsedOperation.data];
|
|
625
|
+
if (operationPolicy !== void 0) return operationPolicy;
|
|
626
|
+
}
|
|
627
|
+
const kindPolicy = envelope.kind === "heartbeat" ? gatewayControlDeliveryPolicyByKind.heartbeat : void 0;
|
|
628
|
+
if (kindPolicy !== void 0) return kindPolicy;
|
|
629
|
+
throw new Error(`no gateway control delivery policy for ${envelope.kind}:${envelope.operation ?? "<none>"}`);
|
|
630
|
+
}
|
|
631
|
+
function assertGatewayControlEnvelopeDeliveryPolicy(envelope) {
|
|
632
|
+
const derivedPolicy = deriveGatewayControlDeliveryPolicy(envelope);
|
|
633
|
+
if (envelope.deliveryPolicy !== derivedPolicy) throw new Error(`control delivery policy mismatch: ${envelope.deliveryPolicy} !== ${derivedPolicy}`);
|
|
634
|
+
}
|
|
635
|
+
const gatewayControlCommandExecutionTimeoutMsByOperation = {
|
|
636
|
+
caller_context_register: 5e3,
|
|
637
|
+
control_ping: 5e3,
|
|
638
|
+
health_event: 5e3,
|
|
639
|
+
lease_create: 18e4,
|
|
640
|
+
lease_get: 5e3,
|
|
641
|
+
lease_peek: 5e3,
|
|
642
|
+
lease_release: 5e3,
|
|
643
|
+
lease_renew: 1e4,
|
|
644
|
+
lease_use_end: 5e3,
|
|
645
|
+
lease_use_heartbeat: 5e3,
|
|
646
|
+
lease_use_start: 1e4,
|
|
647
|
+
operation_cancel: 5e3,
|
|
648
|
+
recovery_command: 1e4,
|
|
649
|
+
runtime_status: 5e3,
|
|
650
|
+
tool_portal_controller_host_action: 12e4
|
|
651
|
+
};
|
|
652
|
+
function buildGatewayControlJsonSchemas() {
|
|
653
|
+
return {
|
|
654
|
+
domain: z.toJSONSchema(GatewayControlDomainSchema, {
|
|
655
|
+
io: "input",
|
|
656
|
+
unrepresentable: "any"
|
|
657
|
+
}),
|
|
658
|
+
message: z.toJSONSchema(GatewayControlRpcMessageSchema, {
|
|
659
|
+
io: "input",
|
|
660
|
+
unrepresentable: "any"
|
|
661
|
+
}),
|
|
662
|
+
operation: z.toJSONSchema(GatewayControlRpcOperationSchema, {
|
|
663
|
+
io: "input",
|
|
664
|
+
unrepresentable: "any"
|
|
665
|
+
})
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
function assertGatewayControlDomainRegistered() {
|
|
669
|
+
return KnownControlDomainSchema.extract(["gateway_control"]).parse("gateway_control");
|
|
670
|
+
}
|
|
671
|
+
//#endregion
|
|
672
|
+
export { ControllerInitiatedGatewayOperationCancelPayloadSchema, GatewayControlActiveOperationIdSchema, GatewayControlCallerContextAgentAuthoritySchema, GatewayControlCallerContextProofAlgorithmSchema, GatewayControlCallerContextProofSchema, GatewayControlCallerContextRefSchema, GatewayControlCallerContextRegisterPayloadSchema, GatewayControlCapabilityRefSchema, GatewayControlControllerRequestHealthOperationSchema, GatewayControlDomainSchema, GatewayControlEventOnlyOperationSchema, GatewayControlForbiddenPayloadFieldSchema, GatewayControlHealthEventPayloadSchema, GatewayControlHealthEventResultSchema, GatewayControlHeartbeatPayloadSchema, GatewayControlLeaseCreateIntentPayloadSchema, GatewayControlLeaseIdPayloadSchema, GatewayControlLeaseRejectionReasonSchema, GatewayControlLeaseSnapshotSchema, 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, GatewayControlToolVmSshAccessSchema, GatewayControlToolVmSshHealthOperationSchema, GatewayControlTrustedCallerContextIdSchema, GatewayControlTrustedLeaseContextSchema, GatewayControlZoneGitCommitSummarySchema, GatewayControlZoneGitPushResultSchema, GatewayInitiatedOperationCancelPayloadSchema, assertGatewayControlDomainRegistered, assertGatewayControlEnvelopeDeliveryPolicy, buildGatewayControlCallerContextAgentAuthorityPayload, buildGatewayControlCallerContextProofPayload, buildGatewayControlJsonSchemas, deriveGatewayControlDeliveryPolicy, gatewayControlCommandExecutionTimeoutMsByOperation, gatewayControlDeliveryPolicyByKind, gatewayControlDeliveryPolicyByOperation };
|
|
673
|
+
|
|
674
|
+
//# sourceMappingURL=index.js.map
|