@rstreamlabs/tunnels 1.0.6 → 1.0.8

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