@rstreamlabs/tunnels 3.2.1 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1330 @@
1
+ // src/client.ts
2
+ import * as z from "zod";
3
+ var clientSchema = z.object({
4
+ id: z.string(),
5
+ status: z.enum(["online", "offline"]),
6
+ user_id: z.string().optional(),
7
+ workspace_id: z.string().optional(),
8
+ project_id: z.string().optional(),
9
+ cluster_id: z.string().optional(),
10
+ plan: z.string().optional(),
11
+ provider: z.string().optional(),
12
+ region: z.string().optional(),
13
+ agent: z.string().optional(),
14
+ channel: z.string().optional(),
15
+ version: z.string().optional(),
16
+ os: z.string().optional(),
17
+ arch: z.string().optional(),
18
+ protocol_version: z.string().optional(),
19
+ labels: z.record(z.string(), z.string()).optional()
20
+ });
21
+ var clientFilterSchema = clientSchema.pick({
22
+ id: true,
23
+ status: true,
24
+ user_id: true,
25
+ agent: true,
26
+ channel: true,
27
+ version: true,
28
+ os: true,
29
+ arch: true,
30
+ protocol_version: true,
31
+ labels: true
32
+ }).partial();
33
+ var listClientsParamsSchema = z.object({
34
+ limit: z.number().int().min(1).optional(),
35
+ filters: clientFilterSchema.optional()
36
+ });
37
+ var listClientsResponseSchema = z.array(clientSchema);
38
+
39
+ // src/webtty-schemas.ts
40
+ import * as z2 from "zod";
41
+ var webTTYTransportSchema = z2.enum([
42
+ "plain",
43
+ "websocket",
44
+ "webtransport"
45
+ ]);
46
+ var webTTYRecordingModeSchema = z2.enum(["recorded", "private"]);
47
+ var webTTYEncryptionModeSchema = z2.enum(["managed", "e2e"]);
48
+ var webTTYSessionModeSchema = z2.enum([
49
+ "interactive",
50
+ "non-interactive"
51
+ ]);
52
+ var webTTYOriginSchema = z2.enum([
53
+ "human",
54
+ "codex",
55
+ "api",
56
+ "automation",
57
+ "ci",
58
+ "scheduled-job"
59
+ ]);
60
+ var webTTYParticipantRoleSchema = z2.enum(["controller", "spectator"]);
61
+ var webTTYInitiatorKindSchema = z2.enum([
62
+ "user",
63
+ "app",
64
+ "agent",
65
+ "service-account"
66
+ ]);
67
+ var webTTYContextMetadataSchema = z2.object({
68
+ origin: webTTYOriginSchema.optional(),
69
+ origin_id: z2.string().optional(),
70
+ purpose: z2.string().optional(),
71
+ initiator_kind: webTTYInitiatorKindSchema.optional(),
72
+ agent_name: z2.string().optional(),
73
+ agent_version: z2.string().optional(),
74
+ request_id: z2.string().optional(),
75
+ labels: z2.record(z2.string(), z2.string()).optional()
76
+ }).passthrough();
77
+
78
+ // src/stream.ts
79
+ import * as z3 from "zod";
80
+ var nonEmptyStringSchema = z3.string().min(1);
81
+ var isoDateTimeSchema = z3.string().datetime({ offset: true });
82
+ var ipAddressSchema = z3.string();
83
+ var intNonNegSchema = z3.number().int().nonnegative();
84
+ var numNonNegSchema = z3.number().nonnegative();
85
+ var geolocationSchema = z3.object({
86
+ country: z3.string().optional(),
87
+ region: z3.string().optional()
88
+ });
89
+ var streamTLSInfoSchema = z3.object({
90
+ version: z3.string().min(1).optional(),
91
+ cipher: z3.string().min(1).optional(),
92
+ protocol: z3.string().min(1).optional(),
93
+ curve: z3.string().min(1).optional(),
94
+ ech: z3.boolean().optional()
95
+ });
96
+ var streamEndpointSchema = z3.object({
97
+ ip: ipAddressSchema.optional(),
98
+ geolocation: geolocationSchema.optional(),
99
+ tls: streamTLSInfoSchema.optional()
100
+ });
101
+ var httpHeadersSchema = z3.record(
102
+ z3.string(),
103
+ z3.union([z3.string(), z3.array(z3.string())])
104
+ );
105
+ var httpProtocolSchema = z3.enum(["http/1.1", "h2", "h2c", "h3"]);
106
+ var httpRequestSchema = z3.object({
107
+ method: nonEmptyStringSchema,
108
+ scheme: z3.string().min(1).optional(),
109
+ host: nonEmptyStringSchema.optional(),
110
+ path: nonEmptyStringSchema.optional(),
111
+ query: z3.string().optional(),
112
+ url: nonEmptyStringSchema.optional(),
113
+ headers: httpHeadersSchema.optional(),
114
+ userAgent: z3.string().optional()
115
+ });
116
+ var httpResponseSchema = z3.object({
117
+ status: z3.number().int().min(100).max(999),
118
+ headers: httpHeadersSchema.optional()
119
+ });
120
+ var httpRequestStageSchema = z3.object({
121
+ protocol: httpProtocolSchema.optional(),
122
+ request: httpRequestSchema
123
+ });
124
+ var httpResponseStageSchema = z3.object({
125
+ protocol: httpProtocolSchema.optional(),
126
+ response: httpResponseSchema
127
+ });
128
+ var streamEntrySchema = z3.object({
129
+ kind: z3.enum([
130
+ "published_tunnel",
131
+ "private_rstream",
132
+ "proxy_egress",
133
+ "internal"
134
+ ]),
135
+ transport: z3.enum(["rstream", "tls", "quic", "dtls", "http", "tcp"]).optional()
136
+ });
137
+ var tokenSourceSchema = z3.enum([
138
+ "authorization",
139
+ "query",
140
+ "client",
141
+ "unknown"
142
+ ]);
143
+ var tokenTypeSchema = z3.enum(["auth", "pat", "app", "unknown"]);
144
+ var firewallRuleSchema = z3.discriminatedUnion("kind", [
145
+ z3.object({ kind: z3.literal("none") }),
146
+ z3.object({ kind: z3.literal("mtls") }),
147
+ z3.object({
148
+ kind: z3.literal("rstream_auth"),
149
+ source: z3.literal("rstream_auth")
150
+ }),
151
+ z3.object({
152
+ kind: z3.literal("rstream"),
153
+ source: z3.literal("private_rstream").optional()
154
+ }),
155
+ z3.object({
156
+ kind: z3.literal("token"),
157
+ source: tokenSourceSchema.optional(),
158
+ tokenType: tokenTypeSchema.optional()
159
+ })
160
+ ]);
161
+ var unauthorizedSourceSchema = z3.object({
162
+ source: tokenSourceSchema
163
+ });
164
+ var unauthorizedReasonSchema = (shape) => z3.object(shape).merge(unauthorizedSourceSchema);
165
+ var unauthorizedSchema = z3.discriminatedUnion("reason", [
166
+ unauthorizedReasonSchema({
167
+ reason: z3.literal("missing_token")
168
+ }),
169
+ unauthorizedReasonSchema({
170
+ reason: z3.literal("invalid_token")
171
+ }),
172
+ unauthorizedReasonSchema({
173
+ reason: z3.literal("expired_token")
174
+ }),
175
+ unauthorizedReasonSchema({
176
+ reason: z3.literal("invalid_secret")
177
+ }),
178
+ unauthorizedReasonSchema({
179
+ reason: z3.literal("user_mismatch")
180
+ }),
181
+ unauthorizedReasonSchema({
182
+ reason: z3.literal("insufficient_scope")
183
+ }),
184
+ unauthorizedReasonSchema({
185
+ reason: z3.literal("policy_denied"),
186
+ policy: z3.enum(["ip", "geo", "mtls", "challenge", "other"]),
187
+ value: z3.string().optional()
188
+ })
189
+ ]);
190
+ var failureSchema = z3.discriminatedUnion("kind", [
191
+ z3.object({
192
+ kind: z3.literal("timeout"),
193
+ timeoutMs: intNonNegSchema.optional(),
194
+ message: z3.string().optional()
195
+ }),
196
+ z3.object({
197
+ kind: z3.literal("unauthorized"),
198
+ why: unauthorizedSchema,
199
+ message: z3.string().optional()
200
+ }),
201
+ z3.object({
202
+ kind: z3.literal("not_found"),
203
+ resource: z3.enum(["tunnel", "client", "route"]),
204
+ message: z3.string().optional()
205
+ }),
206
+ z3.object({
207
+ kind: z3.literal("refused"),
208
+ reason: z3.enum(["capacity", "policy", "unsupported", "other"]),
209
+ message: z3.string().optional()
210
+ }),
211
+ z3.object({ kind: z3.literal("io"), message: z3.string().optional() }),
212
+ z3.object({ kind: z3.literal("internal"), message: z3.string().optional() })
213
+ ]);
214
+ var firewallSchema = z3.discriminatedUnion("decision", [
215
+ z3.object({ decision: z3.literal("allowed"), rule: firewallRuleSchema }),
216
+ z3.object({
217
+ decision: z3.literal("denied"),
218
+ rule: firewallRuleSchema,
219
+ failure: failureSchema
220
+ })
221
+ ]);
222
+ var routedTunnelSchema = z3.object({
223
+ tunnelId: nonEmptyStringSchema.optional(),
224
+ tunnelName: z3.string().optional(),
225
+ hostname: z3.string().optional(),
226
+ protocol: z3.string().optional(),
227
+ published: z3.boolean().optional(),
228
+ type: z3.string().optional(),
229
+ tlsMode: z3.string().optional(),
230
+ httpVersion: z3.string().optional(),
231
+ httpUseTls: z3.boolean().optional(),
232
+ upstreamTls: z3.boolean().optional(),
233
+ tokenAuth: z3.boolean().optional(),
234
+ mtls_auth: z3.boolean().optional()
235
+ });
236
+ var routingSchema = z3.discriminatedUnion("decision", [
237
+ z3.object({ decision: z3.literal("routed"), tunnel: routedTunnelSchema }),
238
+ z3.object({ decision: z3.literal("not_routed"), failure: failureSchema })
239
+ ]);
240
+ var streamConnectedMetricsSchema = z3.object({
241
+ establish_ms: numNonNegSchema,
242
+ duration_ms: numNonNegSchema,
243
+ upstream_bytes: intNonNegSchema,
244
+ downstream_bytes: intNonNegSchema
245
+ });
246
+ var streamFailedMetricsSchema = z3.object({
247
+ time_to_fail_ms: numNonNegSchema.optional(),
248
+ establish_ms: numNonNegSchema.optional()
249
+ });
250
+ var terminationSchema = z3.object({
251
+ by: z3.enum(["downstream", "upstream", "server", "unknown"]),
252
+ reason: z3.enum(["closed", "reset", "timeout", "error", "unknown"]),
253
+ message: z3.string().optional()
254
+ });
255
+ var responseConnectedSchema = z3.object({
256
+ outcome: z3.literal("connected"),
257
+ established_at: isoDateTimeSchema,
258
+ upstream: streamEndpointSchema.optional(),
259
+ metrics: streamConnectedMetricsSchema,
260
+ termination: terminationSchema.optional(),
261
+ http: httpResponseStageSchema.optional()
262
+ });
263
+ var responseFailedSchema = z3.object({
264
+ outcome: z3.literal("failed"),
265
+ failure: failureSchema,
266
+ upstream: streamEndpointSchema.optional(),
267
+ metrics: streamFailedMetricsSchema.optional(),
268
+ termination: terminationSchema.optional(),
269
+ http: httpResponseStageSchema.optional()
270
+ });
271
+ var responseSchema = z3.discriminatedUnion("outcome", [
272
+ responseConnectedSchema,
273
+ responseFailedSchema
274
+ ]);
275
+ var streamWebTTYMetadataSchema = z3.object({
276
+ server_id: nonEmptyStringSchema.optional(),
277
+ session_id: nonEmptyStringSchema.optional(),
278
+ session_group_id: nonEmptyStringSchema.optional(),
279
+ participant_id: nonEmptyStringSchema.optional(),
280
+ participant_role: webTTYParticipantRoleSchema.optional(),
281
+ controller: z3.boolean().optional(),
282
+ recording_mode: webTTYRecordingModeSchema.optional(),
283
+ encryption_mode: webTTYEncryptionModeSchema.optional(),
284
+ encryption_policy: z3.enum(["disabled", "explicit_key", "workspace_managed"]).optional(),
285
+ e2e: z3.boolean().optional(),
286
+ client_proof: z3.enum(["none", "required"]).optional(),
287
+ session_mode: webTTYSessionModeSchema.optional(),
288
+ downstream_transport: webTTYTransportSchema.optional(),
289
+ upstream_transport: webTTYTransportSchema.optional(),
290
+ origin: webTTYOriginSchema.optional(),
291
+ origin_id: z3.string().optional(),
292
+ initiator_kind: webTTYInitiatorKindSchema.optional(),
293
+ device_id: z3.string().optional(),
294
+ browser_id: z3.string().optional()
295
+ }).passthrough();
296
+ var streamSummarySchema = z3.object({
297
+ workspace_id: nonEmptyStringSchema.optional(),
298
+ project_id: nonEmptyStringSchema.optional(),
299
+ cluster_id: nonEmptyStringSchema.optional(),
300
+ user_id: nonEmptyStringSchema.optional(),
301
+ client_id: nonEmptyStringSchema.optional(),
302
+ tunnel_id: nonEmptyStringSchema.optional(),
303
+ stream_id: nonEmptyStringSchema,
304
+ created_at: isoDateTimeSchema,
305
+ terminated_at: isoDateTimeSchema,
306
+ request: z3.object({
307
+ downstream: streamEndpointSchema,
308
+ entry: streamEntrySchema.optional(),
309
+ http: httpRequestStageSchema.optional()
310
+ }),
311
+ firewall: firewallSchema,
312
+ routing: routingSchema,
313
+ webtty: streamWebTTYMetadataSchema.optional(),
314
+ response: responseSchema
315
+ });
316
+ function formatStreamAccessPath(entry) {
317
+ if (!entry) return void 0;
318
+ switch (entry.kind) {
319
+ case "published_tunnel":
320
+ return "Public URL";
321
+ case "private_rstream":
322
+ return "Private rstream dial";
323
+ case "proxy_egress":
324
+ return "Proxy egress";
325
+ case "internal":
326
+ return "Internal";
327
+ default:
328
+ return void 0;
329
+ }
330
+ }
331
+
332
+ // src/webtty-resource.ts
333
+ import * as z4 from "zod";
334
+ var isoDateTimeSchema2 = z4.string().datetime({ offset: true });
335
+ var decimalCursorSchema = z4.string().regex(/^\d+$/);
336
+ var webTTYSequenceCursorInputSchema = z4.union([
337
+ decimalCursorSchema,
338
+ z4.number().int().nonnegative().safe().transform(String)
339
+ ]);
340
+ var webTTYSessionStatusSchema = z4.enum([
341
+ "opening",
342
+ "active",
343
+ "closing",
344
+ "closed",
345
+ "errored"
346
+ ]);
347
+ var webTTYControlRequestStatusSchema = z4.enum([
348
+ "pending",
349
+ "granted",
350
+ "refused",
351
+ "revoked",
352
+ "expired"
353
+ ]);
354
+ var webTTYEventDirectionSchema = z4.enum([
355
+ "client_to_server",
356
+ "server_to_client",
357
+ "engine_internal"
358
+ ]);
359
+ var webTTYStreamTypeSchema = z4.enum(["stdin", "stdout", "stderr"]);
360
+ var webTTYSessionEventTypeSchema = z4.enum([
361
+ "open",
362
+ "ack",
363
+ "data",
364
+ "resize",
365
+ "close",
366
+ "error",
367
+ "participant",
368
+ "control",
369
+ "recording_state"
370
+ ]);
371
+ var jsonRecordSchema = z4.record(z4.string(), z4.unknown());
372
+ function rejectCryptoKeyEnvelopes(crypto, ctx, path) {
373
+ if (crypto === null || typeof crypto !== "object") {
374
+ return;
375
+ }
376
+ if (Object.prototype.hasOwnProperty.call(crypto, "key_envelopes")) {
377
+ ctx.addIssue({
378
+ code: z4.ZodIssueCode.custom,
379
+ message: "key_envelopes are available only from the WebTTY decrypt-material endpoint.",
380
+ path: [...path, "key_envelopes"]
381
+ });
382
+ }
383
+ }
384
+ var webTTYCapabilitiesSchema = z4.object({
385
+ managed_protocol: z4.boolean(),
386
+ store_configured: z4.boolean(),
387
+ session_listing: z4.boolean(),
388
+ recording: z4.boolean(),
389
+ replay: z4.boolean(),
390
+ live_attach: z4.boolean(),
391
+ control_transfer: z4.boolean(),
392
+ e2e: z4.boolean(),
393
+ implemented_transports: z4.array(webTTYTransportSchema),
394
+ recording_modes: z4.array(webTTYRecordingModeSchema),
395
+ encryption_modes: z4.array(webTTYEncryptionModeSchema),
396
+ required_permissions: z4.record(z4.string(), z4.array(z4.string()))
397
+ });
398
+ var webTTYSessionLiveSchema = z4.object({
399
+ available: z4.boolean(),
400
+ attachable: z4.boolean(),
401
+ participant_count: z4.number().int().nonnegative(),
402
+ controller_participant_id: z4.string().optional(),
403
+ has_upstream: z4.boolean()
404
+ });
405
+ var webTTYParticipantLiveSchema = z4.object({
406
+ connected: z4.boolean(),
407
+ controller: z4.boolean()
408
+ });
409
+ var webTTYSessionSchema = z4.object({
410
+ id: z4.string(),
411
+ workspace_id: z4.string().optional(),
412
+ project_id: z4.string().optional(),
413
+ cluster_id: z4.string().optional(),
414
+ server_id: z4.string().optional(),
415
+ tunnel_id: z4.string(),
416
+ client_id: z4.string().optional(),
417
+ initiator_user_id: z4.string().optional(),
418
+ group_id: z4.string().optional(),
419
+ status: webTTYSessionStatusSchema,
420
+ session_mode: webTTYSessionModeSchema,
421
+ recording_mode: webTTYRecordingModeSchema,
422
+ encryption_mode: webTTYEncryptionModeSchema,
423
+ downstream_transport: webTTYTransportSchema.optional(),
424
+ upstream_transport: webTTYTransportSchema.optional(),
425
+ command_meta: z4.unknown().optional(),
426
+ context: webTTYContextMetadataSchema.optional(),
427
+ started_at: isoDateTimeSchema2,
428
+ ended_at: isoDateTimeSchema2.optional(),
429
+ exit_code: z4.number().int().optional(),
430
+ error_code: z4.string().optional(),
431
+ error_message: z4.string().optional(),
432
+ live: webTTYSessionLiveSchema.optional()
433
+ }).passthrough();
434
+ var webTTYSessionGroupSchema = z4.object({
435
+ id: z4.string(),
436
+ workspace_id: z4.string().optional(),
437
+ project_id: z4.string().optional(),
438
+ initiator_user_id: z4.string().optional(),
439
+ context: webTTYContextMetadataSchema.optional(),
440
+ created_at: isoDateTimeSchema2,
441
+ updated_at: isoDateTimeSchema2,
442
+ closed_at: isoDateTimeSchema2.optional()
443
+ }).passthrough();
444
+ var webTTYParticipantSchema = z4.object({
445
+ id: z4.string(),
446
+ session_id: z4.string(),
447
+ user_id: z4.string().optional(),
448
+ device_id: z4.string().optional(),
449
+ browser_id: z4.string().optional(),
450
+ role: webTTYParticipantRoleSchema,
451
+ attached_at: isoDateTimeSchema2,
452
+ detached_at: isoDateTimeSchema2.optional(),
453
+ controller: z4.boolean(),
454
+ grant_state: z4.string().optional(),
455
+ attach_grant: z4.string().optional(),
456
+ attach_grant_expires_at: isoDateTimeSchema2.optional(),
457
+ live: webTTYParticipantLiveSchema.optional()
458
+ }).passthrough();
459
+ var webTTYCryptoMetadataSchema = z4.object({
460
+ payload_suite: z4.string().optional(),
461
+ payload_key_id: z4.string().optional(),
462
+ nonce: z4.string().optional(),
463
+ key_envelope_suite: z4.string().optional(),
464
+ key_envelopes: z4.unknown().optional(),
465
+ key_context: z4.unknown().optional(),
466
+ key_context_raw: z4.string().optional()
467
+ }).passthrough();
468
+ var webTTYSessionEventSchema = z4.object({
469
+ id: z4.string(),
470
+ session_id: z4.string(),
471
+ seq: decimalCursorSchema,
472
+ created_at: isoDateTimeSchema2,
473
+ type: webTTYSessionEventTypeSchema,
474
+ direction: webTTYEventDirectionSchema.optional(),
475
+ stream_type: webTTYStreamTypeSchema.optional(),
476
+ participant_id: z4.string().optional(),
477
+ payload_length: z4.number().int().nonnegative().optional(),
478
+ payload_ciphertext: z4.string().optional(),
479
+ payload_plaintext: z4.string().optional(),
480
+ crypto: webTTYCryptoMetadataSchema.optional(),
481
+ prev_hash: z4.string().optional(),
482
+ hash: z4.string().optional(),
483
+ metadata: z4.unknown().optional()
484
+ }).passthrough().superRefine((value, ctx) => {
485
+ rejectCryptoKeyEnvelopes(value.crypto, ctx, ["crypto"]);
486
+ });
487
+ var webTTYKeyGrantBaseShape = {
488
+ id: z4.string(),
489
+ session_id: z4.string(),
490
+ recipient_id: z4.string(),
491
+ recipient_kind: z4.string(),
492
+ granted_by: z4.string().optional(),
493
+ crypto: webTTYCryptoMetadataSchema,
494
+ created_at: isoDateTimeSchema2,
495
+ revoked_at: isoDateTimeSchema2.optional()
496
+ };
497
+ var webTTYKeyGrantSchema = z4.object(webTTYKeyGrantBaseShape).passthrough().superRefine((value, ctx) => {
498
+ if (Object.prototype.hasOwnProperty.call(value, "wrapped_key")) {
499
+ ctx.addIssue({
500
+ code: z4.ZodIssueCode.custom,
501
+ message: "wrapped_key is available only from the WebTTY decrypt-material endpoint.",
502
+ path: ["wrapped_key"]
503
+ });
504
+ }
505
+ rejectCryptoKeyEnvelopes(value.crypto, ctx, ["crypto"]);
506
+ });
507
+ var webTTYKeyGrantDecryptMaterialSchema = z4.object({
508
+ ...webTTYKeyGrantBaseShape,
509
+ wrapped_key: z4.string().optional()
510
+ }).passthrough();
511
+ var webTTYControlRequestSchema = z4.object({
512
+ id: z4.string(),
513
+ session_id: z4.string(),
514
+ requester_participant_id: z4.string(),
515
+ requester_user_id: z4.string().optional(),
516
+ approver_participant_id: z4.string().optional(),
517
+ approver_user_id: z4.string().optional(),
518
+ status: webTTYControlRequestStatusSchema,
519
+ reason: z4.string().optional(),
520
+ metadata: z4.unknown().optional(),
521
+ created_at: isoDateTimeSchema2,
522
+ updated_at: isoDateTimeSchema2,
523
+ resolved_at: isoDateTimeSchema2.optional(),
524
+ expires_at: isoDateTimeSchema2.optional()
525
+ }).passthrough();
526
+ var listWebTTYSessionsFiltersSchema = z4.object({
527
+ server_id: z4.string().optional(),
528
+ tunnel_id: z4.string().optional(),
529
+ user_id: z4.string().optional(),
530
+ group_id: z4.string().optional(),
531
+ origin: webTTYOriginSchema.optional(),
532
+ status: webTTYSessionStatusSchema.optional(),
533
+ started_from: isoDateTimeSchema2.optional(),
534
+ started_to: isoDateTimeSchema2.optional()
535
+ });
536
+ var listWebTTYSessionsParamsSchema = z4.object({
537
+ limit: z4.number().int().min(1).optional(),
538
+ filters: listWebTTYSessionsFiltersSchema.optional()
539
+ });
540
+ var listWebTTYSessionGroupsFiltersSchema = z4.object({
541
+ initiator_user_id: z4.string().optional(),
542
+ origin: webTTYOriginSchema.optional(),
543
+ created_from: isoDateTimeSchema2.optional(),
544
+ created_to: isoDateTimeSchema2.optional()
545
+ });
546
+ var listWebTTYSessionGroupsParamsSchema = z4.object({
547
+ limit: z4.number().int().min(1).optional(),
548
+ filters: listWebTTYSessionGroupsFiltersSchema.optional()
549
+ });
550
+ var readWebTTYSessionEventsParamsSchema = z4.object({
551
+ from_seq: webTTYSequenceCursorInputSchema.optional(),
552
+ limit: z4.number().int().min(1).optional()
553
+ });
554
+ var listWebTTYKeyGrantDecryptMaterialParamsSchema = z4.object({
555
+ recipient_id: z4.string().optional(),
556
+ recipient_kind: z4.string().optional()
557
+ });
558
+ var listWebTTYControlRequestsFiltersSchema = z4.object({
559
+ status: webTTYControlRequestStatusSchema.optional(),
560
+ requester_user_id: z4.string().optional()
561
+ });
562
+ var listWebTTYControlRequestsParamsSchema = z4.object({
563
+ limit: z4.number().int().min(1).optional(),
564
+ filters: listWebTTYControlRequestsFiltersSchema.optional()
565
+ });
566
+ var attachWebTTYParticipantParamsSchema = z4.object({
567
+ role: z4.literal("spectator").optional(),
568
+ device_id: z4.string().optional(),
569
+ browser_id: z4.string().optional(),
570
+ transport: webTTYTransportSchema.optional(),
571
+ grant_state: z4.string().optional(),
572
+ metadata: jsonRecordSchema.optional()
573
+ });
574
+ var detachWebTTYParticipantParamsSchema = z4.object({
575
+ reason: z4.string().optional(),
576
+ metadata: jsonRecordSchema.optional()
577
+ });
578
+ var createWebTTYControlRequestParamsSchema = z4.object({
579
+ participant_id: z4.string(),
580
+ reason: z4.string().optional(),
581
+ metadata: jsonRecordSchema.optional(),
582
+ expires_at: isoDateTimeSchema2.optional()
583
+ });
584
+ var resolveWebTTYControlRequestParamsSchema = z4.object({
585
+ action: z4.enum(["grant", "refuse", "revoke"]),
586
+ approver_participant_id: z4.string().optional(),
587
+ reason: z4.string().optional()
588
+ });
589
+ var webTTYSessionListSchema = z4.array(webTTYSessionSchema);
590
+ var webTTYSessionGroupListSchema = z4.array(webTTYSessionGroupSchema);
591
+ var webTTYParticipantListSchema = z4.array(webTTYParticipantSchema);
592
+ var webTTYSessionEventListSchema = z4.array(webTTYSessionEventSchema);
593
+ var webTTYKeyGrantListSchema = z4.array(webTTYKeyGrantSchema);
594
+ var webTTYKeyGrantDecryptMaterialListSchema = z4.array(
595
+ webTTYKeyGrantDecryptMaterialSchema
596
+ );
597
+ var webTTYControlRequestListSchema = z4.array(webTTYControlRequestSchema);
598
+ function pathId(kind, value) {
599
+ const normalized = value.trim();
600
+ if (!normalized) {
601
+ throw new Error(`${kind} is required.`);
602
+ }
603
+ return encodeURIComponent(normalized);
604
+ }
605
+ function pathWithParams(path, params) {
606
+ if (params === void 0) {
607
+ return path;
608
+ }
609
+ return `${path}?params=${encodeURIComponent(JSON.stringify(params))}`;
610
+ }
611
+ var RstreamWebTTYResource = class {
612
+ client;
613
+ constructor(client) {
614
+ this.client = client;
615
+ }
616
+ async capabilities() {
617
+ const response = await this.client.request(
618
+ "/webtty/capabilities",
619
+ {
620
+ method: "GET"
621
+ }
622
+ );
623
+ return webTTYCapabilitiesSchema.parse(response);
624
+ }
625
+ async listGroups(params) {
626
+ const parsed = params === void 0 ? void 0 : listWebTTYSessionGroupsParamsSchema.parse(params);
627
+ const response = await this.client.request(
628
+ pathWithParams("/webtty/groups", parsed),
629
+ { method: "GET" }
630
+ );
631
+ return webTTYSessionGroupListSchema.parse(response);
632
+ }
633
+ async getGroup(groupId) {
634
+ const response = await this.client.request(
635
+ `/webtty/groups/${pathId("Session group ID", groupId)}`,
636
+ { method: "GET" }
637
+ );
638
+ return webTTYSessionGroupSchema.parse(response);
639
+ }
640
+ async listSessions(params) {
641
+ const parsed = params === void 0 ? void 0 : listWebTTYSessionsParamsSchema.parse(params);
642
+ const response = await this.client.request(
643
+ pathWithParams("/webtty/sessions", parsed),
644
+ { method: "GET" }
645
+ );
646
+ return webTTYSessionListSchema.parse(response);
647
+ }
648
+ async getSession(sessionId) {
649
+ const response = await this.client.request(
650
+ `/webtty/sessions/${pathId("Session ID", sessionId)}`,
651
+ { method: "GET" }
652
+ );
653
+ return webTTYSessionSchema.parse(response);
654
+ }
655
+ async listParticipants(sessionId) {
656
+ const response = await this.client.request(
657
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/participants`,
658
+ { method: "GET" }
659
+ );
660
+ return webTTYParticipantListSchema.parse(response);
661
+ }
662
+ async attachParticipant(sessionId, params = {}) {
663
+ const response = await this.client.request(
664
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/participants`,
665
+ {
666
+ body: JSON.stringify(attachWebTTYParticipantParamsSchema.parse(params)),
667
+ headers: { "Content-Type": "application/json" },
668
+ method: "POST"
669
+ }
670
+ );
671
+ return webTTYParticipantSchema.parse(response);
672
+ }
673
+ async detachParticipant(sessionId, participantId, params = {}) {
674
+ const response = await this.client.request(
675
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/participants/${pathId("Participant ID", participantId)}`,
676
+ {
677
+ body: JSON.stringify(detachWebTTYParticipantParamsSchema.parse(params)),
678
+ headers: { "Content-Type": "application/json" },
679
+ method: "POST"
680
+ }
681
+ );
682
+ return webTTYParticipantSchema.parse(response);
683
+ }
684
+ async readEvents(sessionId, params) {
685
+ const parsed = params === void 0 ? void 0 : readWebTTYSessionEventsParamsSchema.parse(params);
686
+ const response = await this.client.request(
687
+ pathWithParams(
688
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/events`,
689
+ parsed
690
+ ),
691
+ { method: "GET" }
692
+ );
693
+ return webTTYSessionEventListSchema.parse(response);
694
+ }
695
+ async listKeyGrants(sessionId) {
696
+ const response = await this.client.request(
697
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/key-grants`,
698
+ { method: "GET" }
699
+ );
700
+ return webTTYKeyGrantListSchema.parse(response);
701
+ }
702
+ async listKeyGrantDecryptMaterial(sessionId, params) {
703
+ const parsed = params === void 0 ? void 0 : listWebTTYKeyGrantDecryptMaterialParamsSchema.parse(params);
704
+ const response = await this.client.request(
705
+ pathWithParams(
706
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/key-grants/decrypt-material`,
707
+ parsed
708
+ ),
709
+ { method: "GET" }
710
+ );
711
+ return webTTYKeyGrantDecryptMaterialListSchema.parse(response);
712
+ }
713
+ async listControlRequests(sessionId, params) {
714
+ const parsed = params === void 0 ? void 0 : listWebTTYControlRequestsParamsSchema.parse(params);
715
+ const response = await this.client.request(
716
+ pathWithParams(
717
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/control-requests`,
718
+ parsed
719
+ ),
720
+ { method: "GET" }
721
+ );
722
+ return webTTYControlRequestListSchema.parse(response);
723
+ }
724
+ async createControlRequest(sessionId, params) {
725
+ const response = await this.client.request(
726
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/control-requests`,
727
+ {
728
+ body: JSON.stringify(
729
+ createWebTTYControlRequestParamsSchema.parse(params)
730
+ ),
731
+ headers: { "Content-Type": "application/json" },
732
+ method: "POST"
733
+ }
734
+ );
735
+ return webTTYControlRequestSchema.parse(response);
736
+ }
737
+ async resolveControlRequest(sessionId, requestId, params) {
738
+ const response = await this.client.request(
739
+ `/webtty/sessions/${pathId("Session ID", sessionId)}/control-requests/${pathId("Control request ID", requestId)}`,
740
+ {
741
+ body: JSON.stringify(
742
+ resolveWebTTYControlRequestParamsSchema.parse(params)
743
+ ),
744
+ headers: { "Content-Type": "application/json" },
745
+ method: "POST"
746
+ }
747
+ );
748
+ return webTTYControlRequestSchema.parse(response);
749
+ }
750
+ };
751
+
752
+ // src/event.ts
753
+ import { tunnelSchema } from "@rstreamlabs/rstream/tunnel";
754
+ import * as z5 from "zod";
755
+ var isoDateTimeSchema3 = z5.string().datetime({ offset: true });
756
+ var initialStateSchema = z5.object({
757
+ snapshot_at: isoDateTimeSchema3,
758
+ clients: z5.array(clientSchema),
759
+ tunnels: z5.array(tunnelSchema)
760
+ });
761
+ var eventBaseSchema = z5.object({
762
+ id: z5.string().optional(),
763
+ created_at: isoDateTimeSchema3.optional(),
764
+ user_id: z5.string().optional(),
765
+ workspace_id: z5.string().optional(),
766
+ project_id: z5.string().optional(),
767
+ cluster_id: z5.string().optional()
768
+ });
769
+ var withEventBase = (shape) => z5.object(shape).merge(eventBaseSchema).passthrough();
770
+ var stateInitialEventSchema = withEventBase({
771
+ type: z5.literal("state.initial"),
772
+ object: initialStateSchema
773
+ });
774
+ var streamSummaryEventSchema = withEventBase({
775
+ type: z5.literal("stream.summary"),
776
+ object: streamSummarySchema
777
+ });
778
+ var commonEventsSchema = [
779
+ withEventBase({
780
+ type: z5.literal("client.created"),
781
+ object: clientSchema
782
+ }),
783
+ withEventBase({
784
+ type: z5.literal("client.updated"),
785
+ object: clientSchema
786
+ }),
787
+ withEventBase({
788
+ type: z5.literal("client.deleted"),
789
+ object: clientSchema
790
+ }),
791
+ withEventBase({
792
+ type: z5.literal("tunnel.created"),
793
+ object: tunnelSchema
794
+ }),
795
+ withEventBase({
796
+ type: z5.literal("tunnel.updated"),
797
+ object: tunnelSchema
798
+ }),
799
+ withEventBase({
800
+ type: z5.literal("tunnel.deleted"),
801
+ object: tunnelSchema
802
+ })
803
+ ];
804
+ var webTTYEventsSchema = [
805
+ withEventBase({
806
+ type: z5.literal("webtty.session.created"),
807
+ object: webTTYSessionSchema
808
+ }),
809
+ withEventBase({
810
+ type: z5.literal("webtty.session.updated"),
811
+ object: z5.union([webTTYSessionSchema, webTTYSessionGroupSchema])
812
+ }),
813
+ withEventBase({
814
+ type: z5.literal("webtty.session.ended"),
815
+ object: webTTYSessionSchema
816
+ }),
817
+ withEventBase({
818
+ type: z5.literal("webtty.participant.joined"),
819
+ object: webTTYParticipantSchema
820
+ }),
821
+ withEventBase({
822
+ type: z5.literal("webtty.participant.updated"),
823
+ object: webTTYParticipantSchema
824
+ }),
825
+ withEventBase({
826
+ type: z5.literal("webtty.participant.left"),
827
+ object: webTTYParticipantSchema
828
+ }),
829
+ withEventBase({
830
+ type: z5.literal("webtty.control.requested"),
831
+ object: webTTYControlRequestSchema
832
+ }),
833
+ withEventBase({
834
+ type: z5.literal("webtty.control.granted"),
835
+ object: webTTYControlRequestSchema
836
+ }),
837
+ withEventBase({
838
+ type: z5.literal("webtty.control.refused"),
839
+ object: webTTYControlRequestSchema
840
+ }),
841
+ withEventBase({
842
+ type: z5.literal("webtty.control.revoked"),
843
+ object: webTTYControlRequestSchema
844
+ })
845
+ ];
846
+ var webhookDeliverableEventsSchema = [
847
+ commonEventsSchema[0],
848
+ commonEventsSchema[2],
849
+ commonEventsSchema[3],
850
+ commonEventsSchema[5],
851
+ ...webTTYEventsSchema
852
+ ];
853
+ var wsEventsSchema = z5.union([
854
+ stateInitialEventSchema,
855
+ ...commonEventsSchema,
856
+ ...webTTYEventsSchema
857
+ ]);
858
+ var webhookEventsSchema = z5.union(webhookDeliverableEventsSchema);
859
+ var projectLogEventsSchema = streamSummaryEventSchema;
860
+ var eventSchema = z5.union([
861
+ wsEventsSchema,
862
+ webhookEventsSchema,
863
+ projectLogEventsSchema
864
+ ]);
865
+
866
+ // src/tunnel.ts
867
+ import { tunnelSchema as tunnelSchema2 } from "@rstreamlabs/rstream/tunnel";
868
+ import * as z6 from "zod";
869
+ var DEFAULT_PUBLISHED_PORT = 443;
870
+ var tunnelFilterSchema = tunnelSchema2.pick({
871
+ id: true,
872
+ name: true,
873
+ type: true,
874
+ status: true,
875
+ client_id: true,
876
+ user_id: true,
877
+ publish: true,
878
+ protocol: true,
879
+ hostname: true,
880
+ http_version: true,
881
+ labels: true
882
+ }).partial();
883
+ var listTunnelsParamsSchema = z6.object({
884
+ limit: z6.number().int().min(1).optional(),
885
+ filters: tunnelFilterSchema.optional()
886
+ });
887
+ var listTunnelsResponseSchema = z6.array(tunnelSchema2);
888
+ function formatTunnelHost(tunnel) {
889
+ if (!tunnel.hostname) return tunnel.host;
890
+ if (!tunnel.port || tunnel.port === DEFAULT_PUBLISHED_PORT) {
891
+ return tunnel.hostname;
892
+ }
893
+ return `${tunnel.hostname}:${tunnel.port}`;
894
+ }
895
+
896
+ // src/openapi.ts
897
+ import { tunnelSchema as tunnelSchema3 } from "@rstreamlabs/rstream/tunnel";
898
+ import * as z7 from "zod";
899
+ var jsonContentType = "application/json";
900
+ var openApiContentType = "application/vnd.oai.openapi+json;version=3.1";
901
+ function isRecord(value) {
902
+ return typeof value === "object" && value !== null && !Array.isArray(value);
903
+ }
904
+ function dropSchemaKeyword(value) {
905
+ if (!isRecord(value)) return value;
906
+ return Object.fromEntries(
907
+ Object.entries(value).filter(([key]) => key !== "$schema")
908
+ );
909
+ }
910
+ function jsonSchemaFor(schema) {
911
+ return dropSchemaKeyword(
912
+ z7.toJSONSchema(schema, {
913
+ unrepresentable: "any",
914
+ override: (ctx) => {
915
+ if (ctx.zodSchema instanceof z7.ZodDate) {
916
+ ctx.jsonSchema.type = "string";
917
+ ctx.jsonSchema.format = "date-time";
918
+ }
919
+ }
920
+ })
921
+ );
922
+ }
923
+ function jsonArrayResponse(description, itemSchemaRef) {
924
+ return {
925
+ description,
926
+ content: {
927
+ [jsonContentType]: {
928
+ schema: {
929
+ type: "array",
930
+ items: {
931
+ $ref: itemSchemaRef
932
+ }
933
+ }
934
+ }
935
+ }
936
+ };
937
+ }
938
+ function streamResponse(description) {
939
+ return {
940
+ description,
941
+ content: {
942
+ "text/event-stream": {
943
+ schema: {
944
+ type: "string"
945
+ }
946
+ }
947
+ }
948
+ };
949
+ }
950
+ function errorResponse(description) {
951
+ return {
952
+ description
953
+ };
954
+ }
955
+ function queryJsonParameter(name, description, schemaRef, examples) {
956
+ return {
957
+ name,
958
+ in: "query",
959
+ required: false,
960
+ description,
961
+ content: {
962
+ [jsonContentType]: {
963
+ schema: {
964
+ $ref: schemaRef
965
+ },
966
+ ...examples ? { examples } : {}
967
+ }
968
+ }
969
+ };
970
+ }
971
+ var readEngineStateRule = {
972
+ resource: ["engine.tunnels", "engine.streams"],
973
+ action: "read"
974
+ };
975
+ var readEngineStateRules = [readEngineStateRule];
976
+ var readEngineStreamsRules = [
977
+ {
978
+ resource: "engine.streams",
979
+ action: "read"
980
+ }
981
+ ];
982
+ var watchParamsSchema = z7.object({
983
+ clients: clientFilterSchema.optional(),
984
+ tunnels: tunnelFilterSchema.optional()
985
+ });
986
+ var enginePermissions = {
987
+ "tunnels.resources.read-only": {
988
+ name: "Discovery: Read-Only",
989
+ description: "Read active clients, active tunnels, and live state events.",
990
+ rules: [readEngineStateRule]
991
+ },
992
+ "tunnels.tunnels.create-delete": {
993
+ name: "Tunnels: Create and Delete",
994
+ description: "Create and close tunnels through the CLI, SDK, or engine control channel.",
995
+ rules: [
996
+ {
997
+ resource: "engine.tunnels",
998
+ action: ["create", "delete"]
999
+ }
1000
+ ]
1001
+ },
1002
+ "tunnels.streams.create-delete": {
1003
+ name: "Connections: Create and Delete",
1004
+ description: "Open and close private tunnel streams and WebTTY connections.",
1005
+ rules: [
1006
+ {
1007
+ resource: "engine.streams",
1008
+ action: ["create", "delete"]
1009
+ }
1010
+ ]
1011
+ },
1012
+ "webtty.sessions.read-only": {
1013
+ name: "WebTTY Sessions: Read-Only",
1014
+ description: "List managed WebTTY sessions, participants, replay state, and join as a spectator.",
1015
+ rules: [
1016
+ {
1017
+ resource: "engine.webtty.sessions",
1018
+ action: "read"
1019
+ }
1020
+ ]
1021
+ },
1022
+ "webtty.sessions.read-write": {
1023
+ name: "WebTTY Sessions: Read and Write",
1024
+ description: "Create managed WebTTY sessions and coordinate control requests for active sessions.",
1025
+ rules: [
1026
+ {
1027
+ resource: "engine.webtty.sessions",
1028
+ action: ["read", "write"]
1029
+ }
1030
+ ]
1031
+ },
1032
+ "webtty.logs.read-only": {
1033
+ name: "WebTTY Session Logs: Read-Only",
1034
+ description: "Read managed WebTTY session logs. End-to-end encrypted content still requires trusted local key material.",
1035
+ rules: [
1036
+ {
1037
+ resource: "engine.webtty.sessions",
1038
+ action: "read"
1039
+ },
1040
+ {
1041
+ resource: "engine.webtty.logs",
1042
+ action: "read"
1043
+ }
1044
+ ]
1045
+ }
1046
+ };
1047
+ var engineOpenApiDocument = {
1048
+ openapi: "3.1.0",
1049
+ info: {
1050
+ title: "rstream Engine API",
1051
+ version: "1.0.0",
1052
+ description: "Operational Engine API exposed by rstream engine. This surface is scoped to the authenticated engine or project endpoint and covers live clients, live tunnels, and state-change streams."
1053
+ },
1054
+ servers: [
1055
+ {
1056
+ url: "https://{engine}",
1057
+ description: "Project-scoped rstream engine endpoint.",
1058
+ variables: {
1059
+ engine: {
1060
+ default: "project-endpoint.cluster-host:443",
1061
+ description: "Use the engine value returned by project discovery or configured in RSTREAM_ENGINE."
1062
+ }
1063
+ }
1064
+ }
1065
+ ],
1066
+ security: [
1067
+ {
1068
+ bearerAuth: []
1069
+ }
1070
+ ],
1071
+ components: {
1072
+ securitySchemes: {
1073
+ bearerAuth: {
1074
+ type: "http",
1075
+ scheme: "bearer",
1076
+ bearerFormat: "rstream token",
1077
+ description: "Preferred authentication mechanism. Send an OAuth-issued rstream access token or compatible rstream credential in Authorization: Bearer <token>."
1078
+ }
1079
+ },
1080
+ parameters: {
1081
+ ListClientsParams: queryJsonParameter(
1082
+ "params",
1083
+ "JSON-encoded ListClientsParams object.",
1084
+ "#/components/schemas/ListClientsParams",
1085
+ {
1086
+ filterByAgent: {
1087
+ value: {
1088
+ limit: 10,
1089
+ filters: {
1090
+ agent: "rstream",
1091
+ channel: "stable"
1092
+ }
1093
+ }
1094
+ }
1095
+ }
1096
+ ),
1097
+ ListTunnelsParams: queryJsonParameter(
1098
+ "params",
1099
+ "JSON-encoded ListTunnelsParams object.",
1100
+ "#/components/schemas/ListTunnelsParams",
1101
+ {
1102
+ filterByLabels: {
1103
+ value: {
1104
+ filters: {
1105
+ labels: {
1106
+ service: "ssh",
1107
+ env: "prod"
1108
+ }
1109
+ }
1110
+ }
1111
+ }
1112
+ }
1113
+ ),
1114
+ WatchParams: queryJsonParameter(
1115
+ "params",
1116
+ "JSON-encoded WatchParams object. The same shape is accepted by SSE and WebSocket transports.",
1117
+ "#/components/schemas/WatchParams",
1118
+ {
1119
+ watchTaggedTunnels: {
1120
+ value: {
1121
+ clients: {
1122
+ agent: "rstream"
1123
+ },
1124
+ tunnels: {
1125
+ labels: {
1126
+ service: "ssh"
1127
+ }
1128
+ }
1129
+ }
1130
+ }
1131
+ }
1132
+ )
1133
+ },
1134
+ responses: {
1135
+ BadRequest: errorResponse("Request validation failed."),
1136
+ Unauthorized: errorResponse("Authentication is required."),
1137
+ Forbidden: errorResponse("The token is not authorized.")
1138
+ },
1139
+ schemas: {
1140
+ Client: jsonSchemaFor(clientSchema),
1141
+ Event: jsonSchemaFor(wsEventsSchema),
1142
+ ListClientsParams: jsonSchemaFor(listClientsParamsSchema),
1143
+ ListTunnelsParams: jsonSchemaFor(listTunnelsParamsSchema),
1144
+ TunnelListItem: jsonSchemaFor(tunnelSchema3),
1145
+ WatchParams: jsonSchemaFor(watchParamsSchema)
1146
+ }
1147
+ },
1148
+ "x-rstream-agent-authentication": {
1149
+ oauth_authorization_server_metadata: "https://rstream.io/.well-known/oauth-authorization-server",
1150
+ oauth_protected_resource_metadata: "https://rstream.io/.well-known/oauth-protected-resource",
1151
+ scope_selection: "Use x-rstream-required-rules to understand backend authorization checks. Choose OAuth scopes from x-rstream-permissions or use the task bundles in x-rstream-use-case-permissions."
1152
+ },
1153
+ "x-rstream-permissions": enginePermissions,
1154
+ "x-rstream-use-case-permissions": {
1155
+ "inspect-engine-state": ["tunnels.resources.read-only"],
1156
+ "expose-service-from-cli": [
1157
+ "tunnels.resources.read-only",
1158
+ "tunnels.tunnels.create-delete"
1159
+ ],
1160
+ "connect-private-tunnel": [
1161
+ "tunnels.resources.read-only",
1162
+ "tunnels.streams.create-delete"
1163
+ ],
1164
+ "run-tunnel-webtty": [
1165
+ "tunnels.resources.read-only",
1166
+ "tunnels.tunnels.create-delete",
1167
+ "tunnels.streams.create-delete"
1168
+ ],
1169
+ "join-managed-webtty": ["webtty.sessions.read-only"],
1170
+ "control-managed-webtty": ["webtty.sessions.read-write"],
1171
+ "read-managed-webtty-recordings": ["webtty.logs.read-only"]
1172
+ },
1173
+ paths: {
1174
+ "/api/openapi.json": {
1175
+ get: {
1176
+ tags: ["Discovery"],
1177
+ summary: "Return this OpenAPI description.",
1178
+ operationId: "get_engine_openapi",
1179
+ security: [],
1180
+ responses: {
1181
+ "200": {
1182
+ description: "OpenAPI document.",
1183
+ content: {
1184
+ [openApiContentType]: {
1185
+ schema: {
1186
+ type: "object"
1187
+ }
1188
+ }
1189
+ }
1190
+ }
1191
+ }
1192
+ }
1193
+ },
1194
+ "/api/clients": {
1195
+ get: {
1196
+ tags: ["Runtime inventory"],
1197
+ summary: "List visible engine clients.",
1198
+ operationId: "list_engine_clients",
1199
+ parameters: [{ $ref: "#/components/parameters/ListClientsParams" }],
1200
+ security: [{ bearerAuth: [] }],
1201
+ responses: {
1202
+ "200": jsonArrayResponse(
1203
+ "Visible clients.",
1204
+ "#/components/schemas/Client"
1205
+ ),
1206
+ "400": { $ref: "#/components/responses/BadRequest" },
1207
+ "401": { $ref: "#/components/responses/Unauthorized" },
1208
+ "403": { $ref: "#/components/responses/Forbidden" }
1209
+ },
1210
+ "x-rstream-required-rules": readEngineStreamsRules
1211
+ }
1212
+ },
1213
+ "/api/tunnels": {
1214
+ get: {
1215
+ tags: ["Runtime inventory"],
1216
+ summary: "List visible engine tunnels.",
1217
+ operationId: "list_engine_tunnels",
1218
+ parameters: [{ $ref: "#/components/parameters/ListTunnelsParams" }],
1219
+ security: [{ bearerAuth: [] }],
1220
+ responses: {
1221
+ "200": jsonArrayResponse(
1222
+ "Visible tunnels. Fine-grained list scopes may filter objects and project fields.",
1223
+ "#/components/schemas/TunnelListItem"
1224
+ ),
1225
+ "400": { $ref: "#/components/responses/BadRequest" },
1226
+ "401": { $ref: "#/components/responses/Unauthorized" },
1227
+ "403": { $ref: "#/components/responses/Forbidden" }
1228
+ },
1229
+ "x-rstream-required-rules": readEngineStateRules,
1230
+ "x-rstream-token-metadata-scope": "metadata.scopes.tunnels.list"
1231
+ }
1232
+ },
1233
+ "/api/sse": {
1234
+ get: {
1235
+ tags: ["Runtime watch"],
1236
+ summary: "Subscribe to visible engine state through Server-Sent Events.",
1237
+ operationId: "watch_engine_events_sse",
1238
+ parameters: [{ $ref: "#/components/parameters/WatchParams" }],
1239
+ security: [{ bearerAuth: [] }],
1240
+ responses: {
1241
+ "200": streamResponse(
1242
+ "SSE stream. Each event is emitted as a data line containing a JSON Event object."
1243
+ ),
1244
+ "400": { $ref: "#/components/responses/BadRequest" },
1245
+ "401": { $ref: "#/components/responses/Unauthorized" },
1246
+ "403": { $ref: "#/components/responses/Forbidden" }
1247
+ },
1248
+ "x-rstream-event-schema": "#/components/schemas/Event",
1249
+ "x-rstream-required-rules": readEngineStateRules
1250
+ }
1251
+ },
1252
+ "/api/websocket": {
1253
+ get: {
1254
+ tags: ["Runtime watch"],
1255
+ summary: "Subscribe to visible engine state through a WebSocket upgrade.",
1256
+ operationId: "watch_engine_events_websocket",
1257
+ parameters: [{ $ref: "#/components/parameters/WatchParams" }],
1258
+ security: [{ bearerAuth: [] }],
1259
+ responses: {
1260
+ "101": {
1261
+ description: "WebSocket connection accepted. Frames contain JSON Event objects."
1262
+ },
1263
+ "400": { $ref: "#/components/responses/BadRequest" },
1264
+ "401": { $ref: "#/components/responses/Unauthorized" },
1265
+ "403": { $ref: "#/components/responses/Forbidden" }
1266
+ },
1267
+ "x-rstream-event-schema": "#/components/schemas/Event",
1268
+ "x-rstream-required-rules": readEngineStateRules
1269
+ }
1270
+ }
1271
+ }
1272
+ };
1273
+ var engineOpenApiJson = `${JSON.stringify(
1274
+ engineOpenApiDocument,
1275
+ null,
1276
+ 2
1277
+ )}
1278
+ `;
1279
+
1280
+ export {
1281
+ clientSchema,
1282
+ clientFilterSchema,
1283
+ listClientsParamsSchema,
1284
+ listClientsResponseSchema,
1285
+ webTTYTransportSchema,
1286
+ webTTYRecordingModeSchema,
1287
+ webTTYEncryptionModeSchema,
1288
+ webTTYSessionModeSchema,
1289
+ webTTYOriginSchema,
1290
+ webTTYParticipantRoleSchema,
1291
+ webTTYContextMetadataSchema,
1292
+ streamTLSInfoSchema,
1293
+ streamEndpointSchema,
1294
+ streamEntrySchema,
1295
+ streamWebTTYMetadataSchema,
1296
+ streamSummarySchema,
1297
+ formatStreamAccessPath,
1298
+ webTTYCapabilitiesSchema,
1299
+ webTTYSessionLiveSchema,
1300
+ webTTYParticipantLiveSchema,
1301
+ webTTYSessionSchema,
1302
+ webTTYSessionGroupSchema,
1303
+ webTTYParticipantSchema,
1304
+ webTTYCryptoMetadataSchema,
1305
+ webTTYSessionEventSchema,
1306
+ webTTYKeyGrantSchema,
1307
+ webTTYKeyGrantDecryptMaterialSchema,
1308
+ webTTYControlRequestSchema,
1309
+ listWebTTYSessionsParamsSchema,
1310
+ listWebTTYSessionGroupsParamsSchema,
1311
+ readWebTTYSessionEventsParamsSchema,
1312
+ listWebTTYKeyGrantDecryptMaterialParamsSchema,
1313
+ listWebTTYControlRequestsParamsSchema,
1314
+ attachWebTTYParticipantParamsSchema,
1315
+ detachWebTTYParticipantParamsSchema,
1316
+ createWebTTYControlRequestParamsSchema,
1317
+ resolveWebTTYControlRequestParamsSchema,
1318
+ RstreamWebTTYResource,
1319
+ streamSummaryEventSchema,
1320
+ wsEventsSchema,
1321
+ webhookEventsSchema,
1322
+ projectLogEventsSchema,
1323
+ eventSchema,
1324
+ tunnelFilterSchema,
1325
+ listTunnelsParamsSchema,
1326
+ listTunnelsResponseSchema,
1327
+ formatTunnelHost,
1328
+ engineOpenApiDocument,
1329
+ engineOpenApiJson
1330
+ };