@rstreamlabs/tunnels 1.0.5 → 1.0.7

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,739 @@
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/tunnel.ts
40
+ import * as z2 from "zod";
41
+ var DEFAULT_PUBLISHED_PORT = 443;
42
+ var tunnelSchema = z2.object({
43
+ // common properties
44
+ client_id: z2.string(),
45
+ user_id: z2.string().optional(),
46
+ workspace_id: z2.string().optional(),
47
+ project_id: z2.string().optional(),
48
+ cluster_id: z2.string().optional(),
49
+ plan: z2.string().optional(),
50
+ provider: z2.string().optional(),
51
+ region: z2.string().optional(),
52
+ status: z2.enum(["online", "offline"]),
53
+ // tunnel properties
54
+ id: z2.string(),
55
+ creation_date: z2.union([z2.string().datetime(), z2.date()]).optional(),
56
+ name: z2.string().optional(),
57
+ type: z2.enum(["bytestream", "datagram"]).optional(),
58
+ publish: z2.boolean().optional(),
59
+ protocol: z2.enum(["tls", "dtls", "quic", "http"]).optional(),
60
+ labels: z2.record(z2.string(), z2.string()).optional(),
61
+ geo_ip: z2.array(z2.string()).optional(),
62
+ trusted_ips: z2.array(z2.string()).optional(),
63
+ host: z2.string().optional(),
64
+ hostname: z2.string().optional(),
65
+ port: z2.number().int().min(1).max(65535).optional(),
66
+ tls_mode: z2.enum(["passthrough", "terminated"]).optional(),
67
+ tls_alpns: z2.array(z2.string()).optional(),
68
+ tls_min_version: z2.string().optional(),
69
+ tls_ciphers: z2.array(z2.string()).optional(),
70
+ mtls: z2.boolean().optional(),
71
+ mtls_ca_cert_pem: z2.string().optional(),
72
+ http_version: z2.enum(["http/1.1", "h2", "h2c", "h3"]).optional(),
73
+ http_use_tls: z2.boolean().optional(),
74
+ upstream_tls: z2.boolean().optional(),
75
+ token_auth: z2.boolean().optional(),
76
+ rstream_auth: z2.boolean().optional(),
77
+ challenge_mode: z2.boolean().optional()
78
+ });
79
+ var tunnelFilterSchema = tunnelSchema.pick({
80
+ id: true,
81
+ name: true,
82
+ type: true,
83
+ status: true,
84
+ client_id: true,
85
+ user_id: true,
86
+ publish: true,
87
+ protocol: true,
88
+ hostname: true,
89
+ http_version: true,
90
+ labels: true
91
+ }).partial();
92
+ var listTunnelsParamsSchema = z2.object({
93
+ limit: z2.number().int().min(1).optional(),
94
+ filters: tunnelFilterSchema.optional()
95
+ });
96
+ var listTunnelsResponseSchema = z2.array(tunnelSchema);
97
+ function formatTunnelHost(tunnel) {
98
+ if (!tunnel.hostname) return tunnel.host;
99
+ if (!tunnel.port || tunnel.port === DEFAULT_PUBLISHED_PORT) {
100
+ return tunnel.hostname;
101
+ }
102
+ return `${tunnel.hostname}:${tunnel.port}`;
103
+ }
104
+
105
+ // src/stream.ts
106
+ import * as z3 from "zod";
107
+ var nonEmptyStringSchema = z3.string().min(1);
108
+ var isoDateTimeSchema = z3.string().datetime({ offset: true });
109
+ var ipAddressSchema = z3.string();
110
+ var intNonNegSchema = z3.number().int().nonnegative();
111
+ var numNonNegSchema = z3.number().nonnegative();
112
+ var geolocationSchema = z3.object({
113
+ country: z3.string().optional(),
114
+ region: z3.string().optional()
115
+ });
116
+ var streamTLSInfoSchema = z3.object({
117
+ version: z3.string().min(1).optional(),
118
+ cipher: z3.string().min(1).optional(),
119
+ protocol: z3.string().min(1).optional(),
120
+ curve: z3.string().min(1).optional(),
121
+ ech: z3.boolean().optional()
122
+ });
123
+ var streamEndpointSchema = z3.object({
124
+ ip: ipAddressSchema.optional(),
125
+ geolocation: geolocationSchema.optional(),
126
+ tls: streamTLSInfoSchema.optional()
127
+ });
128
+ var httpHeadersSchema = z3.record(
129
+ z3.string(),
130
+ z3.union([z3.string(), z3.array(z3.string())])
131
+ );
132
+ var httpProtocolSchema = z3.enum(["http/1.1", "h2", "h2c", "h3"]);
133
+ var httpRequestSchema = z3.object({
134
+ method: nonEmptyStringSchema,
135
+ scheme: z3.string().min(1).optional(),
136
+ host: nonEmptyStringSchema.optional(),
137
+ path: nonEmptyStringSchema.optional(),
138
+ query: z3.string().optional(),
139
+ url: nonEmptyStringSchema.optional(),
140
+ headers: httpHeadersSchema.optional(),
141
+ userAgent: z3.string().optional()
142
+ });
143
+ var httpResponseSchema = z3.object({
144
+ status: z3.number().int().min(100).max(999),
145
+ headers: httpHeadersSchema.optional()
146
+ });
147
+ var httpRequestStageSchema = z3.object({
148
+ protocol: httpProtocolSchema.optional(),
149
+ request: httpRequestSchema
150
+ });
151
+ var httpResponseStageSchema = z3.object({
152
+ protocol: httpProtocolSchema.optional(),
153
+ response: httpResponseSchema
154
+ });
155
+ var tokenSourceSchema = z3.enum([
156
+ "authorization",
157
+ "query",
158
+ "client",
159
+ "unknown"
160
+ ]);
161
+ var tokenTypeSchema = z3.enum(["auth", "pat", "app", "unknown"]);
162
+ var firewallRuleSchema = z3.discriminatedUnion("kind", [
163
+ z3.object({ kind: z3.literal("none") }),
164
+ z3.object({ kind: z3.literal("mtls") }),
165
+ z3.object({
166
+ kind: z3.literal("rstream_auth"),
167
+ source: z3.literal("rstream_auth")
168
+ }),
169
+ z3.object({
170
+ kind: z3.literal("token"),
171
+ source: tokenSourceSchema.optional(),
172
+ tokenType: tokenTypeSchema.optional()
173
+ })
174
+ ]);
175
+ var unauthorizedSourceSchema = z3.object({
176
+ source: tokenSourceSchema
177
+ });
178
+ var unauthorizedReasonSchema = (shape) => z3.object(shape).merge(unauthorizedSourceSchema);
179
+ var unauthorizedSchema = z3.discriminatedUnion("reason", [
180
+ unauthorizedReasonSchema({
181
+ reason: z3.literal("missing_token")
182
+ }),
183
+ unauthorizedReasonSchema({
184
+ reason: z3.literal("invalid_token")
185
+ }),
186
+ unauthorizedReasonSchema({
187
+ reason: z3.literal("expired_token")
188
+ }),
189
+ unauthorizedReasonSchema({
190
+ reason: z3.literal("invalid_secret")
191
+ }),
192
+ unauthorizedReasonSchema({
193
+ reason: z3.literal("user_mismatch")
194
+ }),
195
+ unauthorizedReasonSchema({
196
+ reason: z3.literal("insufficient_scope")
197
+ }),
198
+ unauthorizedReasonSchema({
199
+ reason: z3.literal("policy_denied"),
200
+ policy: z3.enum(["ip", "geo", "mtls", "challenge", "other"]),
201
+ value: z3.string().optional()
202
+ })
203
+ ]);
204
+ var failureSchema = z3.discriminatedUnion("kind", [
205
+ z3.object({
206
+ kind: z3.literal("timeout"),
207
+ timeoutMs: intNonNegSchema.optional(),
208
+ message: z3.string().optional()
209
+ }),
210
+ z3.object({
211
+ kind: z3.literal("unauthorized"),
212
+ why: unauthorizedSchema,
213
+ message: z3.string().optional()
214
+ }),
215
+ z3.object({
216
+ kind: z3.literal("not_found"),
217
+ resource: z3.enum(["tunnel", "client", "route"]),
218
+ message: z3.string().optional()
219
+ }),
220
+ z3.object({
221
+ kind: z3.literal("refused"),
222
+ reason: z3.enum(["capacity", "policy", "unsupported", "other"]),
223
+ message: z3.string().optional()
224
+ }),
225
+ z3.object({ kind: z3.literal("io"), message: z3.string().optional() }),
226
+ z3.object({ kind: z3.literal("internal"), message: z3.string().optional() })
227
+ ]);
228
+ var firewallSchema = z3.discriminatedUnion("decision", [
229
+ z3.object({ decision: z3.literal("allowed"), rule: firewallRuleSchema }),
230
+ z3.object({
231
+ decision: z3.literal("denied"),
232
+ rule: firewallRuleSchema,
233
+ failure: failureSchema
234
+ })
235
+ ]);
236
+ var routedTunnelSchema = z3.object({
237
+ tunnelId: nonEmptyStringSchema.optional(),
238
+ tunnelName: z3.string().optional(),
239
+ hostname: z3.string().optional(),
240
+ protocol: z3.string().optional(),
241
+ published: z3.boolean().optional(),
242
+ type: z3.string().optional(),
243
+ tlsMode: z3.string().optional(),
244
+ httpVersion: z3.string().optional(),
245
+ httpUseTls: z3.boolean().optional(),
246
+ upstreamTls: z3.boolean().optional(),
247
+ tokenAuth: z3.boolean().optional(),
248
+ mtls: z3.boolean().optional()
249
+ });
250
+ var routingSchema = z3.discriminatedUnion("decision", [
251
+ z3.object({ decision: z3.literal("routed"), tunnel: routedTunnelSchema }),
252
+ z3.object({ decision: z3.literal("not_routed"), failure: failureSchema })
253
+ ]);
254
+ var streamConnectedMetricsSchema = z3.object({
255
+ establish_ms: numNonNegSchema,
256
+ duration_ms: numNonNegSchema,
257
+ upstream_bytes: intNonNegSchema,
258
+ downstream_bytes: intNonNegSchema
259
+ });
260
+ var streamFailedMetricsSchema = z3.object({
261
+ time_to_fail_ms: numNonNegSchema.optional(),
262
+ establish_ms: numNonNegSchema.optional()
263
+ });
264
+ var terminationSchema = z3.object({
265
+ by: z3.enum(["downstream", "upstream", "server", "unknown"]),
266
+ reason: z3.enum(["closed", "reset", "timeout", "error", "unknown"]),
267
+ message: z3.string().optional()
268
+ });
269
+ var responseConnectedSchema = z3.object({
270
+ outcome: z3.literal("connected"),
271
+ established_at: isoDateTimeSchema,
272
+ upstream: streamEndpointSchema.optional(),
273
+ metrics: streamConnectedMetricsSchema,
274
+ termination: terminationSchema.optional(),
275
+ http: httpResponseStageSchema.optional()
276
+ });
277
+ var responseFailedSchema = z3.object({
278
+ outcome: z3.literal("failed"),
279
+ failure: failureSchema,
280
+ upstream: streamEndpointSchema.optional(),
281
+ metrics: streamFailedMetricsSchema.optional(),
282
+ termination: terminationSchema.optional(),
283
+ http: httpResponseStageSchema.optional()
284
+ });
285
+ var responseSchema = z3.discriminatedUnion("outcome", [
286
+ responseConnectedSchema,
287
+ responseFailedSchema
288
+ ]);
289
+ var streamSummarySchema = z3.object({
290
+ workspace_id: nonEmptyStringSchema.optional(),
291
+ project_id: nonEmptyStringSchema.optional(),
292
+ cluster_id: nonEmptyStringSchema.optional(),
293
+ user_id: nonEmptyStringSchema.optional(),
294
+ client_id: nonEmptyStringSchema.optional(),
295
+ tunnel_id: nonEmptyStringSchema.optional(),
296
+ stream_id: nonEmptyStringSchema,
297
+ created_at: isoDateTimeSchema,
298
+ terminated_at: isoDateTimeSchema,
299
+ request: z3.object({
300
+ downstream: streamEndpointSchema,
301
+ http: httpRequestStageSchema.optional()
302
+ }),
303
+ firewall: firewallSchema,
304
+ routing: routingSchema,
305
+ response: responseSchema
306
+ });
307
+
308
+ // src/event.ts
309
+ import * as z4 from "zod";
310
+ var isoDateTimeSchema2 = z4.string().datetime({ offset: true });
311
+ var initialStateSchema = z4.object({
312
+ snapshot_at: isoDateTimeSchema2,
313
+ clients: z4.array(clientSchema),
314
+ tunnels: z4.array(tunnelSchema)
315
+ });
316
+ var eventBaseSchema = z4.object({
317
+ id: z4.string().optional(),
318
+ created_at: isoDateTimeSchema2.optional(),
319
+ user_id: z4.string().optional(),
320
+ workspace_id: z4.string().optional(),
321
+ project_id: z4.string().optional(),
322
+ cluster_id: z4.string().optional()
323
+ });
324
+ var withEventBase = (shape) => z4.object(shape).merge(eventBaseSchema).passthrough();
325
+ var stateInitialEventSchema = withEventBase({
326
+ type: z4.literal("state.initial"),
327
+ object: initialStateSchema
328
+ });
329
+ var streamSummaryEventSchema = withEventBase({
330
+ type: z4.literal("stream.summary"),
331
+ object: streamSummarySchema
332
+ });
333
+ var commonEventsSchema = [
334
+ withEventBase({
335
+ type: z4.literal("client.created"),
336
+ object: clientSchema
337
+ }),
338
+ withEventBase({
339
+ type: z4.literal("client.updated"),
340
+ object: clientSchema
341
+ }),
342
+ withEventBase({
343
+ type: z4.literal("client.deleted"),
344
+ object: clientSchema
345
+ }),
346
+ withEventBase({
347
+ type: z4.literal("tunnel.created"),
348
+ object: tunnelSchema
349
+ }),
350
+ withEventBase({
351
+ type: z4.literal("tunnel.updated"),
352
+ object: tunnelSchema
353
+ }),
354
+ withEventBase({
355
+ type: z4.literal("tunnel.deleted"),
356
+ object: tunnelSchema
357
+ })
358
+ ];
359
+ var wsEventsSchema = z4.union([
360
+ stateInitialEventSchema,
361
+ ...commonEventsSchema
362
+ ]);
363
+ var webhookEventsSchema = z4.union([
364
+ ...commonEventsSchema,
365
+ streamSummaryEventSchema
366
+ ]);
367
+ var eventSchema = z4.union([wsEventsSchema, webhookEventsSchema]);
368
+
369
+ // src/openapi.ts
370
+ import * as z5 from "zod";
371
+ var jsonContentType = "application/json";
372
+ var openApiContentType = "application/vnd.oai.openapi+json;version=3.1";
373
+ function isRecord(value) {
374
+ return typeof value === "object" && value !== null && !Array.isArray(value);
375
+ }
376
+ function dropSchemaKeyword(value) {
377
+ if (!isRecord(value)) return value;
378
+ return Object.fromEntries(
379
+ Object.entries(value).filter(([key]) => key !== "$schema")
380
+ );
381
+ }
382
+ function jsonSchemaFor(schema) {
383
+ return dropSchemaKeyword(
384
+ z5.toJSONSchema(schema, {
385
+ unrepresentable: "any",
386
+ override: (ctx) => {
387
+ if (ctx.zodSchema instanceof z5.ZodDate) {
388
+ ctx.jsonSchema.type = "string";
389
+ ctx.jsonSchema.format = "date-time";
390
+ }
391
+ }
392
+ })
393
+ );
394
+ }
395
+ function jsonArrayResponse(description, itemSchemaRef) {
396
+ return {
397
+ description,
398
+ content: {
399
+ [jsonContentType]: {
400
+ schema: {
401
+ type: "array",
402
+ items: {
403
+ $ref: itemSchemaRef
404
+ }
405
+ }
406
+ }
407
+ }
408
+ };
409
+ }
410
+ function streamResponse(description) {
411
+ return {
412
+ description,
413
+ content: {
414
+ "text/event-stream": {
415
+ schema: {
416
+ type: "string"
417
+ }
418
+ }
419
+ }
420
+ };
421
+ }
422
+ function errorResponse(description) {
423
+ return {
424
+ description
425
+ };
426
+ }
427
+ function queryJsonParameter(name, description, schemaRef, examples) {
428
+ return {
429
+ name,
430
+ in: "query",
431
+ required: false,
432
+ description,
433
+ content: {
434
+ [jsonContentType]: {
435
+ schema: {
436
+ $ref: schemaRef
437
+ },
438
+ ...examples ? { examples } : {}
439
+ }
440
+ }
441
+ };
442
+ }
443
+ var readEngineStateRule = {
444
+ resource: ["engine.tunnels", "engine.streams"],
445
+ action: "read"
446
+ };
447
+ var readEngineStateRules = [readEngineStateRule];
448
+ var readEngineStreamsRules = [
449
+ {
450
+ resource: "engine.streams",
451
+ action: "read"
452
+ }
453
+ ];
454
+ var watchParamsSchema = z5.object({
455
+ clients: clientFilterSchema.optional(),
456
+ tunnels: tunnelFilterSchema.optional()
457
+ });
458
+ var enginePermissions = {
459
+ "tunnels.resources.read-only": {
460
+ name: "Discovery: Read-Only",
461
+ description: "Read active clients, active tunnels, and live state events.",
462
+ rules: [readEngineStateRule]
463
+ },
464
+ "tunnels.tunnels.create-delete": {
465
+ name: "Tunnels: Create and Delete",
466
+ description: "Create and close tunnels through the CLI, SDK, or engine control channel.",
467
+ rules: [
468
+ {
469
+ resource: "engine.tunnels",
470
+ action: ["create", "delete"]
471
+ }
472
+ ]
473
+ },
474
+ "tunnels.streams.create-delete": {
475
+ name: "Connections: Create and Delete",
476
+ description: "Open and close private tunnel streams and WebTTY connections.",
477
+ rules: [
478
+ {
479
+ resource: "engine.streams",
480
+ action: ["create", "delete"]
481
+ }
482
+ ]
483
+ }
484
+ };
485
+ var engineOpenApiDocument = {
486
+ openapi: "3.1.0",
487
+ info: {
488
+ title: "rstream Engine API",
489
+ version: "1.0.0",
490
+ description: "Operational data-plane 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."
491
+ },
492
+ servers: [
493
+ {
494
+ url: "https://{engine}",
495
+ description: "Project-scoped rstream engine endpoint.",
496
+ variables: {
497
+ engine: {
498
+ default: "project-endpoint.cluster-host:443",
499
+ description: "Use the engine value returned by project discovery or configured in RSTREAM_ENGINE."
500
+ }
501
+ }
502
+ }
503
+ ],
504
+ security: [
505
+ {
506
+ bearerAuth: []
507
+ }
508
+ ],
509
+ components: {
510
+ securitySchemes: {
511
+ bearerAuth: {
512
+ type: "http",
513
+ scheme: "bearer",
514
+ bearerFormat: "rstream token",
515
+ description: "Preferred authentication mechanism. Send an OAuth-issued rstream access token or compatible rstream credential in Authorization: Bearer <token>."
516
+ },
517
+ queryToken: {
518
+ type: "apiKey",
519
+ in: "query",
520
+ name: "rstream.token",
521
+ description: "Fallback authentication mechanism for transports where setting Authorization is impractical. Prefer bearerAuth whenever possible."
522
+ }
523
+ },
524
+ parameters: {
525
+ ListClientsParams: queryJsonParameter(
526
+ "params",
527
+ "JSON-encoded ListClientsParams object.",
528
+ "#/components/schemas/ListClientsParams",
529
+ {
530
+ filterByAgent: {
531
+ value: {
532
+ limit: 10,
533
+ filters: {
534
+ agent: "rstream",
535
+ channel: "stable"
536
+ }
537
+ }
538
+ }
539
+ }
540
+ ),
541
+ ListTunnelsParams: queryJsonParameter(
542
+ "params",
543
+ "JSON-encoded ListTunnelsParams object.",
544
+ "#/components/schemas/ListTunnelsParams",
545
+ {
546
+ filterByLabels: {
547
+ value: {
548
+ filters: {
549
+ labels: {
550
+ service: "ssh",
551
+ env: "prod"
552
+ }
553
+ }
554
+ }
555
+ }
556
+ }
557
+ ),
558
+ WatchParams: queryJsonParameter(
559
+ "params",
560
+ "JSON-encoded WatchParams object. The same shape is accepted by SSE and WebSocket transports.",
561
+ "#/components/schemas/WatchParams",
562
+ {
563
+ watchTaggedTunnels: {
564
+ value: {
565
+ clients: {
566
+ agent: "rstream"
567
+ },
568
+ tunnels: {
569
+ labels: {
570
+ service: "ssh"
571
+ }
572
+ }
573
+ }
574
+ }
575
+ }
576
+ )
577
+ },
578
+ responses: {
579
+ BadRequest: errorResponse("Request validation failed."),
580
+ Unauthorized: errorResponse("Authentication is required."),
581
+ Forbidden: errorResponse("The token is not authorized.")
582
+ },
583
+ schemas: {
584
+ Client: jsonSchemaFor(clientSchema),
585
+ Event: jsonSchemaFor(wsEventsSchema),
586
+ ListClientsParams: jsonSchemaFor(listClientsParamsSchema),
587
+ ListTunnelsParams: jsonSchemaFor(listTunnelsParamsSchema),
588
+ TunnelListItem: jsonSchemaFor(tunnelSchema),
589
+ WatchParams: jsonSchemaFor(watchParamsSchema)
590
+ }
591
+ },
592
+ "x-rstream-agent-authentication": {
593
+ oauth_authorization_server_metadata: "https://rstream.io/.well-known/oauth-authorization-server",
594
+ oauth_protected_resource_metadata: "https://rstream.io/.well-known/oauth-protected-resource",
595
+ 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."
596
+ },
597
+ "x-rstream-permissions": enginePermissions,
598
+ "x-rstream-use-case-permissions": {
599
+ "inspect-engine-state": ["tunnels.resources.read-only"],
600
+ "expose-service-from-cli": [
601
+ "tunnels.resources.read-only",
602
+ "tunnels.tunnels.create-delete"
603
+ ],
604
+ "connect-private-tunnel": [
605
+ "tunnels.resources.read-only",
606
+ "tunnels.streams.create-delete"
607
+ ],
608
+ "operate-webtty": [
609
+ "tunnels.resources.read-only",
610
+ "tunnels.tunnels.create-delete",
611
+ "tunnels.streams.create-delete"
612
+ ]
613
+ },
614
+ paths: {
615
+ "/api/openapi.json": {
616
+ get: {
617
+ tags: ["Discovery"],
618
+ summary: "Return this OpenAPI description.",
619
+ operationId: "get_engine_openapi",
620
+ security: [],
621
+ responses: {
622
+ "200": {
623
+ description: "OpenAPI document.",
624
+ content: {
625
+ [openApiContentType]: {
626
+ schema: {
627
+ type: "object"
628
+ }
629
+ }
630
+ }
631
+ }
632
+ }
633
+ }
634
+ },
635
+ "/api/clients": {
636
+ get: {
637
+ tags: ["Runtime inventory"],
638
+ summary: "List visible engine clients.",
639
+ operationId: "list_engine_clients",
640
+ parameters: [{ $ref: "#/components/parameters/ListClientsParams" }],
641
+ security: [{ bearerAuth: [] }, { queryToken: [] }],
642
+ responses: {
643
+ "200": jsonArrayResponse(
644
+ "Visible clients.",
645
+ "#/components/schemas/Client"
646
+ ),
647
+ "400": { $ref: "#/components/responses/BadRequest" },
648
+ "401": { $ref: "#/components/responses/Unauthorized" },
649
+ "403": { $ref: "#/components/responses/Forbidden" }
650
+ },
651
+ "x-rstream-required-rules": readEngineStreamsRules
652
+ }
653
+ },
654
+ "/api/tunnels": {
655
+ get: {
656
+ tags: ["Runtime inventory"],
657
+ summary: "List visible engine tunnels.",
658
+ operationId: "list_engine_tunnels",
659
+ parameters: [{ $ref: "#/components/parameters/ListTunnelsParams" }],
660
+ security: [{ bearerAuth: [] }, { queryToken: [] }],
661
+ responses: {
662
+ "200": jsonArrayResponse(
663
+ "Visible tunnels. Fine-grained list scopes may filter objects and project fields.",
664
+ "#/components/schemas/TunnelListItem"
665
+ ),
666
+ "400": { $ref: "#/components/responses/BadRequest" },
667
+ "401": { $ref: "#/components/responses/Unauthorized" },
668
+ "403": { $ref: "#/components/responses/Forbidden" }
669
+ },
670
+ "x-rstream-required-rules": readEngineStateRules,
671
+ "x-rstream-token-metadata-scope": "metadata.scopes.tunnels.list"
672
+ }
673
+ },
674
+ "/api/sse": {
675
+ get: {
676
+ tags: ["Runtime watch"],
677
+ summary: "Subscribe to visible engine state through Server-Sent Events.",
678
+ operationId: "watch_engine_events_sse",
679
+ parameters: [{ $ref: "#/components/parameters/WatchParams" }],
680
+ security: [{ bearerAuth: [] }, { queryToken: [] }],
681
+ responses: {
682
+ "200": streamResponse(
683
+ "SSE stream. Each event is emitted as a data line containing a JSON Event object."
684
+ ),
685
+ "400": { $ref: "#/components/responses/BadRequest" },
686
+ "401": { $ref: "#/components/responses/Unauthorized" },
687
+ "403": { $ref: "#/components/responses/Forbidden" }
688
+ },
689
+ "x-rstream-event-schema": "#/components/schemas/Event",
690
+ "x-rstream-required-rules": readEngineStateRules
691
+ }
692
+ },
693
+ "/api/websocket": {
694
+ get: {
695
+ tags: ["Runtime watch"],
696
+ summary: "Subscribe to visible engine state through a WebSocket upgrade.",
697
+ operationId: "watch_engine_events_websocket",
698
+ parameters: [{ $ref: "#/components/parameters/WatchParams" }],
699
+ security: [{ bearerAuth: [] }, { queryToken: [] }],
700
+ responses: {
701
+ "101": {
702
+ description: "WebSocket connection accepted. Frames contain JSON Event objects."
703
+ },
704
+ "400": { $ref: "#/components/responses/BadRequest" },
705
+ "401": { $ref: "#/components/responses/Unauthorized" },
706
+ "403": { $ref: "#/components/responses/Forbidden" }
707
+ },
708
+ "x-rstream-event-schema": "#/components/schemas/Event",
709
+ "x-rstream-required-rules": readEngineStateRules
710
+ }
711
+ }
712
+ }
713
+ };
714
+ var engineOpenApiJson = `${JSON.stringify(
715
+ engineOpenApiDocument,
716
+ null,
717
+ 2
718
+ )}
719
+ `;
720
+
721
+ export {
722
+ tunnelSchema,
723
+ tunnelFilterSchema,
724
+ listTunnelsParamsSchema,
725
+ listTunnelsResponseSchema,
726
+ formatTunnelHost,
727
+ clientSchema,
728
+ clientFilterSchema,
729
+ listClientsParamsSchema,
730
+ listClientsResponseSchema,
731
+ streamTLSInfoSchema,
732
+ streamEndpointSchema,
733
+ streamSummarySchema,
734
+ wsEventsSchema,
735
+ webhookEventsSchema,
736
+ eventSchema,
737
+ engineOpenApiDocument,
738
+ engineOpenApiJson
739
+ };