@rstreamlabs/tunnels 3.10.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -170,7 +170,7 @@ __export(index_exports, {
170
170
  attachWebTTYParticipantParamsSchema: () => attachWebTTYParticipantParamsSchema,
171
171
  buildWebhookHeaders: () => buildWebhookHeaders,
172
172
  clientFilterSchema: () => clientFilterSchema,
173
- clientSchema: () => clientSchema,
173
+ clientSchema: () => import_client2.clientSchema,
174
174
  createAPITURNCredentials: () => createAPITURNCredentials,
175
175
  createAPPTURNCredentials: () => createAPPTURNCredentials,
176
176
  createAuthTokenFromClientCredentials: () => createAuthTokenFromClientCredentials,
@@ -192,6 +192,8 @@ __export(index_exports, {
192
192
  listWebTTYKeyGrantDecryptMaterialParamsSchema: () => listWebTTYKeyGrantDecryptMaterialParamsSchema,
193
193
  listWebTTYSessionGroupsParamsSchema: () => listWebTTYSessionGroupsParamsSchema,
194
194
  listWebTTYSessionsParamsSchema: () => listWebTTYSessionsParamsSchema,
195
+ listedClientSchema: () => listedClientSchema,
196
+ listedTunnelSchema: () => listedTunnelSchema,
195
197
  normalizeEngineAddress: () => normalizeEngineAddress,
196
198
  parseWebTTYServers: () => parseWebTTYServers,
197
199
  projectLogEventsSchema: () => projectLogEventsSchema,
@@ -389,25 +391,10 @@ function normalizeOptionalString(value) {
389
391
 
390
392
  // src/client.ts
391
393
  var z = __toESM(require("zod"));
392
- var clientSchema = z.object({
393
- id: z.string(),
394
- status: z.enum(["online", "offline"]),
395
- user_id: z.string().optional(),
396
- workspace_id: z.string().optional(),
397
- project_id: z.string().optional(),
398
- cluster_id: z.string().optional(),
399
- plan: z.string().optional(),
400
- provider: z.string().optional(),
401
- region: z.string().optional(),
402
- agent: z.string().optional(),
403
- channel: z.string().optional(),
404
- version: z.string().optional(),
405
- os: z.string().optional(),
406
- arch: z.string().optional(),
407
- protocol_version: z.string().optional(),
408
- labels: z.record(z.string(), z.string()).optional()
409
- });
410
- var clientFilterSchema = clientSchema.pick({
394
+ var import_client = require("@rstreamlabs/rstream/client");
395
+ var import_client2 = require("@rstreamlabs/rstream/client");
396
+ var listedClientSchema = import_client.clientSchema.partial();
397
+ var clientFilterSchema = import_client.clientSchema.pick({
411
398
  id: true,
412
399
  status: true,
413
400
  user_id: true,
@@ -423,7 +410,7 @@ var listClientsParamsSchema = z.object({
423
410
  limit: z.number().int().min(1).optional(),
424
411
  filters: clientFilterSchema.optional()
425
412
  });
426
- var listClientsResponseSchema = z.array(clientSchema);
413
+ var listClientsResponseSchema = z.array(listedClientSchema);
427
414
 
428
415
  // src/clients-resource.ts
429
416
  function clientPathId(id) {
@@ -452,24 +439,55 @@ var RstreamClientsResource = class {
452
439
  method: "GET"
453
440
  }
454
441
  );
455
- return clientSchema.parse(response);
442
+ return import_client2.clientSchema.parse(response);
456
443
  }
457
444
  };
458
445
 
459
- // src/webtty-schemas.ts
446
+ // src/tunnel.ts
447
+ var import_tunnel = require("@rstreamlabs/rstream/tunnel");
460
448
  var z2 = __toESM(require("zod"));
461
- var webTTYTransportSchema = z2.enum([
449
+ var DEFAULT_PUBLISHED_PORT = 443;
450
+ var tunnelFilterSchema = import_tunnel.tunnelSchema.pick({
451
+ id: true,
452
+ name: true,
453
+ type: true,
454
+ status: true,
455
+ client_id: true,
456
+ user_id: true,
457
+ publish: true,
458
+ protocol: true,
459
+ hostname: true,
460
+ http_version: true,
461
+ labels: true
462
+ }).partial();
463
+ var listTunnelsParamsSchema = z2.object({
464
+ limit: z2.number().int().min(1).optional(),
465
+ filters: tunnelFilterSchema.optional()
466
+ });
467
+ var listedTunnelSchema = import_tunnel.tunnelSchema.partial();
468
+ var listTunnelsResponseSchema = z2.array(listedTunnelSchema);
469
+ function formatTunnelHost(tunnel) {
470
+ if (!tunnel.hostname) return tunnel.host;
471
+ if (!tunnel.port || tunnel.port === DEFAULT_PUBLISHED_PORT) {
472
+ return tunnel.hostname;
473
+ }
474
+ return `${tunnel.hostname}:${tunnel.port}`;
475
+ }
476
+
477
+ // src/webtty-schemas.ts
478
+ var z3 = __toESM(require("zod"));
479
+ var webTTYTransportSchema = z3.enum([
462
480
  "plain",
463
481
  "websocket",
464
482
  "webtransport"
465
483
  ]);
466
- var webTTYRecordingModeSchema = z2.enum(["recorded", "private"]);
467
- var webTTYEncryptionModeSchema = z2.enum(["managed", "e2e"]);
468
- var webTTYSessionModeSchema = z2.enum([
484
+ var webTTYRecordingModeSchema = z3.enum(["recorded", "private"]);
485
+ var webTTYEncryptionModeSchema = z3.enum(["managed", "e2e"]);
486
+ var webTTYSessionModeSchema = z3.enum([
469
487
  "interactive",
470
488
  "non-interactive"
471
489
  ]);
472
- var webTTYOriginSchema = z2.enum([
490
+ var webTTYOriginSchema = z3.enum([
473
491
  "human",
474
492
  "codex",
475
493
  "api",
@@ -477,259 +495,259 @@ var webTTYOriginSchema = z2.enum([
477
495
  "ci",
478
496
  "scheduled-job"
479
497
  ]);
480
- var webTTYParticipantRoleSchema = z2.enum(["controller", "spectator"]);
481
- var webTTYInitiatorKindSchema = z2.enum([
498
+ var webTTYParticipantRoleSchema = z3.enum(["controller", "spectator"]);
499
+ var webTTYInitiatorKindSchema = z3.enum([
482
500
  "user",
483
501
  "app",
484
502
  "agent",
485
503
  "service-account"
486
504
  ]);
487
- var webTTYContextMetadataSchema = z2.object({
505
+ var webTTYContextMetadataSchema = z3.object({
488
506
  origin: webTTYOriginSchema.optional(),
489
- origin_id: z2.string().optional(),
490
- purpose: z2.string().optional(),
507
+ origin_id: z3.string().optional(),
508
+ purpose: z3.string().optional(),
491
509
  initiator_kind: webTTYInitiatorKindSchema.optional(),
492
- agent_name: z2.string().optional(),
493
- agent_version: z2.string().optional(),
494
- request_id: z2.string().optional(),
495
- labels: z2.record(z2.string(), z2.string()).optional()
510
+ agent_name: z3.string().optional(),
511
+ agent_version: z3.string().optional(),
512
+ request_id: z3.string().optional(),
513
+ labels: z3.record(z3.string(), z3.string()).optional()
496
514
  }).passthrough();
497
515
 
498
516
  // src/stream.ts
499
- var z3 = __toESM(require("zod"));
500
- var nonEmptyStringSchema = z3.string().min(1);
501
- var isoDateTimeSchema = z3.string().datetime({ offset: true });
502
- var ipAddressSchema = z3.string();
503
- var intNonNegSchema = z3.number().int().nonnegative();
504
- var numNonNegSchema = z3.number().nonnegative();
505
- var geolocationSchema = z3.object({
506
- country: z3.string().optional(),
507
- region: z3.string().optional()
517
+ var z4 = __toESM(require("zod"));
518
+ var nonEmptyStringSchema = z4.string().min(1);
519
+ var isoDateTimeSchema = z4.string().datetime({ offset: true });
520
+ var ipAddressSchema = z4.string();
521
+ var intNonNegSchema = z4.number().int().nonnegative();
522
+ var numNonNegSchema = z4.number().nonnegative();
523
+ var geolocationSchema = z4.object({
524
+ country: z4.string().optional(),
525
+ region: z4.string().optional()
508
526
  });
509
- var streamTLSInfoSchema = z3.object({
510
- version: z3.string().min(1).optional(),
511
- cipher: z3.string().min(1).optional(),
512
- protocol: z3.string().min(1).optional(),
513
- curve: z3.string().min(1).optional(),
514
- ech: z3.boolean().optional()
527
+ var streamTLSInfoSchema = z4.object({
528
+ version: z4.string().min(1).optional(),
529
+ cipher: z4.string().min(1).optional(),
530
+ protocol: z4.string().min(1).optional(),
531
+ curve: z4.string().min(1).optional(),
532
+ ech: z4.boolean().optional()
515
533
  });
516
- var streamEndpointSchema = z3.object({
534
+ var streamEndpointSchema = z4.object({
517
535
  ip: ipAddressSchema.optional(),
518
536
  geolocation: geolocationSchema.optional(),
519
537
  tls: streamTLSInfoSchema.optional()
520
538
  });
521
- var httpHeadersSchema = z3.record(
522
- z3.string(),
523
- z3.union([z3.string(), z3.array(z3.string())])
539
+ var httpHeadersSchema = z4.record(
540
+ z4.string(),
541
+ z4.union([z4.string(), z4.array(z4.string())])
524
542
  );
525
- var httpProtocolSchema = z3.enum(["http/1.1", "h2", "h2c", "h3"]);
526
- var httpRequestSchema = z3.object({
543
+ var httpProtocolSchema = z4.enum(["http/1.1", "h2", "h2c", "h3"]);
544
+ var httpRequestSchema = z4.object({
527
545
  method: nonEmptyStringSchema,
528
- scheme: z3.string().min(1).optional(),
546
+ scheme: z4.string().min(1).optional(),
529
547
  host: nonEmptyStringSchema.optional(),
530
548
  path: nonEmptyStringSchema.optional(),
531
- query: z3.string().optional(),
549
+ query: z4.string().optional(),
532
550
  url: nonEmptyStringSchema.optional(),
533
551
  headers: httpHeadersSchema.optional(),
534
- userAgent: z3.string().optional()
552
+ userAgent: z4.string().optional()
535
553
  });
536
- var httpResponseSchema = z3.object({
537
- status: z3.number().int().min(100).max(999),
554
+ var httpResponseSchema = z4.object({
555
+ status: z4.number().int().min(100).max(999),
538
556
  headers: httpHeadersSchema.optional()
539
557
  });
540
- var httpRequestStageSchema = z3.object({
558
+ var httpRequestStageSchema = z4.object({
541
559
  protocol: httpProtocolSchema.optional(),
542
560
  request: httpRequestSchema
543
561
  });
544
- var httpResponseStageSchema = z3.object({
562
+ var httpResponseStageSchema = z4.object({
545
563
  protocol: httpProtocolSchema.optional(),
546
564
  response: httpResponseSchema
547
565
  });
548
- var streamEntrySchema = z3.object({
549
- kind: z3.enum([
566
+ var streamEntrySchema = z4.object({
567
+ kind: z4.enum([
550
568
  "published_tunnel",
551
569
  "private_rstream",
552
570
  "proxy_egress",
553
571
  "internal"
554
572
  ]),
555
- transport: z3.enum(["rstream", "tls", "quic", "dtls", "http", "tcp"]).optional()
573
+ transport: z4.enum(["rstream", "tls", "quic", "dtls", "http", "tcp"]).optional()
556
574
  });
557
- var tokenSourceSchema = z3.enum([
575
+ var tokenSourceSchema = z4.enum([
558
576
  "authorization",
559
577
  "query",
560
578
  "client",
561
579
  "unknown"
562
580
  ]);
563
- var tokenTypeSchema = z3.enum(["auth", "pat", "app", "unknown"]);
564
- var firewallRuleSchema = z3.discriminatedUnion("kind", [
565
- z3.object({ kind: z3.literal("none") }),
566
- z3.object({ kind: z3.literal("mtls") }),
567
- z3.object({
568
- kind: z3.literal("rstream_auth"),
569
- source: z3.literal("rstream_auth")
581
+ var tokenTypeSchema = z4.enum(["auth", "pat", "app", "unknown"]);
582
+ var firewallRuleSchema = z4.discriminatedUnion("kind", [
583
+ z4.object({ kind: z4.literal("none") }),
584
+ z4.object({ kind: z4.literal("mtls") }),
585
+ z4.object({
586
+ kind: z4.literal("rstream_auth"),
587
+ source: z4.literal("rstream_auth")
570
588
  }),
571
- z3.object({
572
- kind: z3.literal("rstream"),
573
- source: z3.literal("private_rstream").optional()
589
+ z4.object({
590
+ kind: z4.literal("rstream"),
591
+ source: z4.literal("private_rstream").optional()
574
592
  }),
575
- z3.object({
576
- kind: z3.literal("token"),
593
+ z4.object({
594
+ kind: z4.literal("token"),
577
595
  source: tokenSourceSchema.optional(),
578
596
  tokenType: tokenTypeSchema.optional()
579
597
  })
580
598
  ]);
581
- var unauthorizedSourceSchema = z3.object({
599
+ var unauthorizedSourceSchema = z4.object({
582
600
  source: tokenSourceSchema
583
601
  });
584
- var unauthorizedReasonSchema = (shape) => z3.object(shape).merge(unauthorizedSourceSchema);
585
- var unauthorizedSchema = z3.discriminatedUnion("reason", [
602
+ var unauthorizedReasonSchema = (shape) => z4.object(shape).merge(unauthorizedSourceSchema);
603
+ var unauthorizedSchema = z4.discriminatedUnion("reason", [
586
604
  unauthorizedReasonSchema({
587
- reason: z3.literal("missing_token")
605
+ reason: z4.literal("missing_token")
588
606
  }),
589
607
  unauthorizedReasonSchema({
590
- reason: z3.literal("invalid_token")
608
+ reason: z4.literal("invalid_token")
591
609
  }),
592
610
  unauthorizedReasonSchema({
593
- reason: z3.literal("expired_token")
611
+ reason: z4.literal("expired_token")
594
612
  }),
595
613
  unauthorizedReasonSchema({
596
- reason: z3.literal("invalid_secret")
614
+ reason: z4.literal("invalid_secret")
597
615
  }),
598
616
  unauthorizedReasonSchema({
599
- reason: z3.literal("user_mismatch")
617
+ reason: z4.literal("user_mismatch")
600
618
  }),
601
619
  unauthorizedReasonSchema({
602
- reason: z3.literal("insufficient_scope")
620
+ reason: z4.literal("insufficient_scope")
603
621
  }),
604
622
  unauthorizedReasonSchema({
605
- reason: z3.literal("policy_denied"),
606
- policy: z3.enum(["ip", "geo", "mtls", "challenge", "other"]),
607
- value: z3.string().optional()
623
+ reason: z4.literal("policy_denied"),
624
+ policy: z4.enum(["ip", "geo", "mtls", "challenge", "other"]),
625
+ value: z4.string().optional()
608
626
  })
609
627
  ]);
610
- var failureSchema = z3.discriminatedUnion("kind", [
611
- z3.object({
612
- kind: z3.literal("timeout"),
628
+ var failureSchema = z4.discriminatedUnion("kind", [
629
+ z4.object({
630
+ kind: z4.literal("timeout"),
613
631
  timeoutMs: intNonNegSchema.optional(),
614
- message: z3.string().optional()
632
+ message: z4.string().optional()
615
633
  }),
616
- z3.object({
617
- kind: z3.literal("unauthorized"),
634
+ z4.object({
635
+ kind: z4.literal("unauthorized"),
618
636
  why: unauthorizedSchema,
619
- message: z3.string().optional()
637
+ message: z4.string().optional()
620
638
  }),
621
- z3.object({
622
- kind: z3.literal("not_found"),
623
- resource: z3.enum(["tunnel", "client", "route"]),
624
- message: z3.string().optional()
639
+ z4.object({
640
+ kind: z4.literal("not_found"),
641
+ resource: z4.enum(["tunnel", "client", "route"]),
642
+ message: z4.string().optional()
625
643
  }),
626
- z3.object({
627
- kind: z3.literal("refused"),
628
- reason: z3.enum(["capacity", "policy", "unsupported", "other"]),
629
- message: z3.string().optional()
644
+ z4.object({
645
+ kind: z4.literal("refused"),
646
+ reason: z4.enum(["capacity", "policy", "unsupported", "other"]),
647
+ message: z4.string().optional()
630
648
  }),
631
- z3.object({ kind: z3.literal("io"), message: z3.string().optional() }),
632
- z3.object({ kind: z3.literal("internal"), message: z3.string().optional() })
649
+ z4.object({ kind: z4.literal("io"), message: z4.string().optional() }),
650
+ z4.object({ kind: z4.literal("internal"), message: z4.string().optional() })
633
651
  ]);
634
- var firewallSchema = z3.discriminatedUnion("decision", [
635
- z3.object({ decision: z3.literal("allowed"), rule: firewallRuleSchema }),
636
- z3.object({
637
- decision: z3.literal("denied"),
652
+ var firewallSchema = z4.discriminatedUnion("decision", [
653
+ z4.object({ decision: z4.literal("allowed"), rule: firewallRuleSchema }),
654
+ z4.object({
655
+ decision: z4.literal("denied"),
638
656
  rule: firewallRuleSchema,
639
657
  failure: failureSchema
640
658
  })
641
659
  ]);
642
- var routedTunnelSchema = z3.object({
660
+ var routedTunnelSchema = z4.object({
643
661
  tunnelId: nonEmptyStringSchema.optional(),
644
- tunnelName: z3.string().optional(),
645
- hostname: z3.string().optional(),
646
- protocol: z3.string().optional(),
647
- published: z3.boolean().optional(),
648
- type: z3.string().optional(),
649
- tlsMode: z3.string().optional(),
650
- httpVersion: z3.string().optional(),
651
- httpUseTls: z3.boolean().optional(),
652
- upstreamTls: z3.boolean().optional(),
653
- tokenAuth: z3.boolean().optional(),
654
- mtls_auth: z3.boolean().optional()
662
+ tunnelName: z4.string().optional(),
663
+ hostname: z4.string().optional(),
664
+ protocol: z4.string().optional(),
665
+ published: z4.boolean().optional(),
666
+ type: z4.string().optional(),
667
+ tlsMode: z4.string().optional(),
668
+ httpVersion: z4.string().optional(),
669
+ httpUseTls: z4.boolean().optional(),
670
+ upstreamTls: z4.boolean().optional(),
671
+ tokenAuth: z4.boolean().optional(),
672
+ mtls_auth: z4.boolean().optional()
655
673
  });
656
- var routingNodeSchema = z3.object({
674
+ var routingNodeSchema = z4.object({
657
675
  engineId: nonEmptyStringSchema,
658
676
  region: nonEmptyStringSchema,
659
677
  generation: nonEmptyStringSchema.optional()
660
678
  });
661
- var routingPathSchema = z3.object({
662
- mode: z3.enum(["direct", "cross_region"]),
663
- crossRegionRoutingAllowed: z3.boolean(),
679
+ var routingPathSchema = z4.object({
680
+ mode: z4.enum(["direct", "cross_region"]),
681
+ crossRegionRoutingAllowed: z4.boolean(),
664
682
  ingress: routingNodeSchema,
665
683
  owner: routingNodeSchema,
666
684
  anchor: routingNodeSchema
667
685
  });
668
- var routingSchema = z3.discriminatedUnion("decision", [
669
- z3.object({
670
- decision: z3.literal("routed"),
686
+ var routingSchema = z4.discriminatedUnion("decision", [
687
+ z4.object({
688
+ decision: z4.literal("routed"),
671
689
  tunnel: routedTunnelSchema,
672
690
  path: routingPathSchema.optional()
673
691
  }),
674
- z3.object({ decision: z3.literal("not_routed"), failure: failureSchema })
692
+ z4.object({ decision: z4.literal("not_routed"), failure: failureSchema })
675
693
  ]);
676
- var streamConnectedMetricsSchema = z3.object({
694
+ var streamConnectedMetricsSchema = z4.object({
677
695
  establish_ms: numNonNegSchema,
678
696
  duration_ms: numNonNegSchema,
679
697
  upstream_bytes: intNonNegSchema,
680
698
  downstream_bytes: intNonNegSchema
681
699
  });
682
- var streamFailedMetricsSchema = z3.object({
700
+ var streamFailedMetricsSchema = z4.object({
683
701
  time_to_fail_ms: numNonNegSchema.optional(),
684
702
  establish_ms: numNonNegSchema.optional()
685
703
  });
686
- var terminationSchema = z3.object({
687
- by: z3.enum(["downstream", "upstream", "server", "unknown"]),
688
- reason: z3.enum(["closed", "reset", "timeout", "error", "unknown"]),
689
- message: z3.string().optional()
704
+ var terminationSchema = z4.object({
705
+ by: z4.enum(["downstream", "upstream", "server", "unknown"]),
706
+ reason: z4.enum(["closed", "reset", "timeout", "error", "unknown"]),
707
+ message: z4.string().optional()
690
708
  });
691
- var responseConnectedSchema = z3.object({
692
- outcome: z3.literal("connected"),
709
+ var responseConnectedSchema = z4.object({
710
+ outcome: z4.literal("connected"),
693
711
  established_at: isoDateTimeSchema,
694
712
  upstream: streamEndpointSchema.optional(),
695
713
  metrics: streamConnectedMetricsSchema,
696
714
  termination: terminationSchema.optional(),
697
715
  http: httpResponseStageSchema.optional()
698
716
  });
699
- var responseFailedSchema = z3.object({
700
- outcome: z3.literal("failed"),
717
+ var responseFailedSchema = z4.object({
718
+ outcome: z4.literal("failed"),
701
719
  failure: failureSchema,
702
720
  upstream: streamEndpointSchema.optional(),
703
721
  metrics: streamFailedMetricsSchema.optional(),
704
722
  termination: terminationSchema.optional(),
705
723
  http: httpResponseStageSchema.optional()
706
724
  });
707
- var responseSchema = z3.discriminatedUnion("outcome", [
725
+ var responseSchema = z4.discriminatedUnion("outcome", [
708
726
  responseConnectedSchema,
709
727
  responseFailedSchema
710
728
  ]);
711
- var streamWebTTYMetadataSchema = z3.object({
729
+ var streamWebTTYMetadataSchema = z4.object({
712
730
  server_id: nonEmptyStringSchema.optional(),
713
731
  session_id: nonEmptyStringSchema.optional(),
714
732
  session_group_id: nonEmptyStringSchema.optional(),
715
733
  participant_id: nonEmptyStringSchema.optional(),
716
734
  participant_role: webTTYParticipantRoleSchema.optional(),
717
- controller: z3.boolean().optional(),
735
+ controller: z4.boolean().optional(),
718
736
  recording_mode: webTTYRecordingModeSchema.optional(),
719
737
  encryption_mode: webTTYEncryptionModeSchema.optional(),
720
- encryption_policy: z3.enum(["disabled", "explicit_key", "workspace_managed"]).optional(),
721
- e2e: z3.boolean().optional(),
722
- client_proof: z3.enum(["none", "required"]).optional(),
738
+ encryption_policy: z4.enum(["disabled", "explicit_key", "workspace_managed"]).optional(),
739
+ e2e: z4.boolean().optional(),
740
+ client_proof: z4.enum(["none", "required"]).optional(),
723
741
  session_mode: webTTYSessionModeSchema.optional(),
724
742
  downstream_transport: webTTYTransportSchema.optional(),
725
743
  upstream_transport: webTTYTransportSchema.optional(),
726
744
  origin: webTTYOriginSchema.optional(),
727
- origin_id: z3.string().optional(),
745
+ origin_id: z4.string().optional(),
728
746
  initiator_kind: webTTYInitiatorKindSchema.optional(),
729
- device_id: z3.string().optional(),
730
- browser_id: z3.string().optional()
747
+ device_id: z4.string().optional(),
748
+ browser_id: z4.string().optional()
731
749
  }).passthrough();
732
- var streamSummarySchema = z3.object({
750
+ var streamSummarySchema = z4.object({
733
751
  workspace_id: nonEmptyStringSchema.optional(),
734
752
  project_id: nonEmptyStringSchema.optional(),
735
753
  cluster_id: nonEmptyStringSchema.optional(),
@@ -739,7 +757,7 @@ var streamSummarySchema = z3.object({
739
757
  stream_id: nonEmptyStringSchema,
740
758
  created_at: isoDateTimeSchema,
741
759
  terminated_at: isoDateTimeSchema,
742
- request: z3.object({
760
+ request: z4.object({
743
761
  downstream: streamEndpointSchema,
744
762
  entry: streamEntrySchema.optional(),
745
763
  http: httpRequestStageSchema.optional()
@@ -766,34 +784,34 @@ function formatStreamAccessPath(entry) {
766
784
  }
767
785
 
768
786
  // src/webtty-resource.ts
769
- var z4 = __toESM(require("zod"));
770
- var isoDateTimeSchema2 = z4.string().datetime({ offset: true });
771
- var decimalCursorSchema = z4.string().regex(/^\d+$/);
772
- var webTTYSequenceCursorInputSchema = z4.union([
787
+ var z5 = __toESM(require("zod"));
788
+ var isoDateTimeSchema2 = z5.string().datetime({ offset: true });
789
+ var decimalCursorSchema = z5.string().regex(/^\d+$/);
790
+ var webTTYSequenceCursorInputSchema = z5.union([
773
791
  decimalCursorSchema,
774
- z4.number().int().nonnegative().safe().transform(String)
792
+ z5.number().int().nonnegative().safe().transform(String)
775
793
  ]);
776
- var webTTYSessionStatusSchema = z4.enum([
794
+ var webTTYSessionStatusSchema = z5.enum([
777
795
  "opening",
778
796
  "active",
779
797
  "closing",
780
798
  "closed",
781
799
  "errored"
782
800
  ]);
783
- var webTTYControlRequestStatusSchema = z4.enum([
801
+ var webTTYControlRequestStatusSchema = z5.enum([
784
802
  "pending",
785
803
  "granted",
786
804
  "refused",
787
805
  "revoked",
788
806
  "expired"
789
807
  ]);
790
- var webTTYEventDirectionSchema = z4.enum([
808
+ var webTTYEventDirectionSchema = z5.enum([
791
809
  "client_to_server",
792
810
  "server_to_client",
793
811
  "engine_internal"
794
812
  ]);
795
- var webTTYStreamTypeSchema = z4.enum(["stdin", "stdout", "stderr"]);
796
- var webTTYSessionEventTypeSchema = z4.enum([
813
+ var webTTYStreamTypeSchema = z5.enum(["stdin", "stdout", "stderr"]);
814
+ var webTTYSessionEventTypeSchema = z5.enum([
797
815
  "open",
798
816
  "ack",
799
817
  "data",
@@ -804,233 +822,233 @@ var webTTYSessionEventTypeSchema = z4.enum([
804
822
  "control",
805
823
  "recording_state"
806
824
  ]);
807
- var jsonRecordSchema = z4.record(z4.string(), z4.unknown());
825
+ var jsonRecordSchema = z5.record(z5.string(), z5.unknown());
808
826
  function rejectCryptoKeyEnvelopes(crypto3, ctx, path) {
809
827
  if (crypto3 === null || typeof crypto3 !== "object") {
810
828
  return;
811
829
  }
812
830
  if (Object.prototype.hasOwnProperty.call(crypto3, "key_envelopes")) {
813
831
  ctx.addIssue({
814
- code: z4.ZodIssueCode.custom,
832
+ code: z5.ZodIssueCode.custom,
815
833
  message: "key_envelopes are available only from the WebTTY decrypt-material endpoint.",
816
834
  path: [...path, "key_envelopes"]
817
835
  });
818
836
  }
819
837
  }
820
- var webTTYCapabilitiesSchema = z4.object({
821
- managed_protocol: z4.boolean(),
822
- store_configured: z4.boolean(),
823
- session_listing: z4.boolean(),
824
- recording: z4.boolean(),
825
- replay: z4.boolean(),
826
- live_attach: z4.boolean(),
827
- control_transfer: z4.boolean(),
828
- e2e: z4.boolean(),
829
- implemented_transports: z4.array(webTTYTransportSchema),
830
- recording_modes: z4.array(webTTYRecordingModeSchema),
831
- encryption_modes: z4.array(webTTYEncryptionModeSchema),
832
- required_permissions: z4.record(z4.string(), z4.array(z4.string()))
838
+ var webTTYCapabilitiesSchema = z5.object({
839
+ managed_protocol: z5.boolean(),
840
+ store_configured: z5.boolean(),
841
+ session_listing: z5.boolean(),
842
+ recording: z5.boolean(),
843
+ replay: z5.boolean(),
844
+ live_attach: z5.boolean(),
845
+ control_transfer: z5.boolean(),
846
+ e2e: z5.boolean(),
847
+ implemented_transports: z5.array(webTTYTransportSchema),
848
+ recording_modes: z5.array(webTTYRecordingModeSchema),
849
+ encryption_modes: z5.array(webTTYEncryptionModeSchema),
850
+ required_permissions: z5.record(z5.string(), z5.array(z5.string()))
833
851
  });
834
- var webTTYSessionLiveSchema = z4.object({
835
- available: z4.boolean(),
836
- attachable: z4.boolean(),
837
- participant_count: z4.number().int().nonnegative(),
838
- controller_participant_id: z4.string().optional(),
839
- has_upstream: z4.boolean()
852
+ var webTTYSessionLiveSchema = z5.object({
853
+ available: z5.boolean(),
854
+ attachable: z5.boolean(),
855
+ participant_count: z5.number().int().nonnegative(),
856
+ controller_participant_id: z5.string().optional(),
857
+ has_upstream: z5.boolean()
840
858
  });
841
- var webTTYParticipantLiveSchema = z4.object({
842
- connected: z4.boolean(),
843
- controller: z4.boolean()
859
+ var webTTYParticipantLiveSchema = z5.object({
860
+ connected: z5.boolean(),
861
+ controller: z5.boolean()
844
862
  });
845
- var webTTYSessionSchema = z4.object({
846
- id: z4.string(),
847
- workspace_id: z4.string().optional(),
848
- project_id: z4.string().optional(),
849
- cluster_id: z4.string().optional(),
850
- server_id: z4.string().optional(),
851
- tunnel_id: z4.string(),
852
- client_id: z4.string().optional(),
853
- initiator_user_id: z4.string().optional(),
854
- group_id: z4.string().optional(),
863
+ var webTTYSessionSchema = z5.object({
864
+ id: z5.string(),
865
+ workspace_id: z5.string().optional(),
866
+ project_id: z5.string().optional(),
867
+ cluster_id: z5.string().optional(),
868
+ server_id: z5.string().optional(),
869
+ tunnel_id: z5.string(),
870
+ client_id: z5.string().optional(),
871
+ initiator_user_id: z5.string().optional(),
872
+ group_id: z5.string().optional(),
855
873
  status: webTTYSessionStatusSchema,
856
874
  session_mode: webTTYSessionModeSchema,
857
875
  recording_mode: webTTYRecordingModeSchema,
858
876
  encryption_mode: webTTYEncryptionModeSchema,
859
877
  downstream_transport: webTTYTransportSchema.optional(),
860
878
  upstream_transport: webTTYTransportSchema.optional(),
861
- command_meta: z4.unknown().optional(),
879
+ command_meta: z5.unknown().optional(),
862
880
  context: webTTYContextMetadataSchema.optional(),
863
881
  started_at: isoDateTimeSchema2,
864
882
  ended_at: isoDateTimeSchema2.optional(),
865
- exit_code: z4.number().int().optional(),
866
- error_code: z4.string().optional(),
867
- error_message: z4.string().optional(),
883
+ exit_code: z5.number().int().optional(),
884
+ error_code: z5.string().optional(),
885
+ error_message: z5.string().optional(),
868
886
  live: webTTYSessionLiveSchema.optional()
869
887
  }).passthrough();
870
- var webTTYSessionGroupSchema = z4.object({
871
- id: z4.string(),
872
- workspace_id: z4.string().optional(),
873
- project_id: z4.string().optional(),
874
- initiator_user_id: z4.string().optional(),
888
+ var webTTYSessionGroupSchema = z5.object({
889
+ id: z5.string(),
890
+ workspace_id: z5.string().optional(),
891
+ project_id: z5.string().optional(),
892
+ initiator_user_id: z5.string().optional(),
875
893
  context: webTTYContextMetadataSchema.optional(),
876
894
  created_at: isoDateTimeSchema2,
877
895
  updated_at: isoDateTimeSchema2,
878
896
  closed_at: isoDateTimeSchema2.optional()
879
897
  }).passthrough();
880
- var webTTYParticipantSchema = z4.object({
881
- id: z4.string(),
882
- session_id: z4.string(),
883
- user_id: z4.string().optional(),
884
- device_id: z4.string().optional(),
885
- browser_id: z4.string().optional(),
898
+ var webTTYParticipantSchema = z5.object({
899
+ id: z5.string(),
900
+ session_id: z5.string(),
901
+ user_id: z5.string().optional(),
902
+ device_id: z5.string().optional(),
903
+ browser_id: z5.string().optional(),
886
904
  role: webTTYParticipantRoleSchema,
887
905
  attached_at: isoDateTimeSchema2,
888
906
  detached_at: isoDateTimeSchema2.optional(),
889
- controller: z4.boolean(),
890
- grant_state: z4.string().optional(),
891
- attach_grant: z4.string().optional(),
907
+ controller: z5.boolean(),
908
+ grant_state: z5.string().optional(),
909
+ attach_grant: z5.string().optional(),
892
910
  attach_grant_expires_at: isoDateTimeSchema2.optional(),
893
911
  live: webTTYParticipantLiveSchema.optional()
894
912
  }).passthrough();
895
- var webTTYCryptoMetadataSchema = z4.object({
896
- payload_suite: z4.string().optional(),
897
- payload_key_id: z4.string().optional(),
898
- nonce: z4.string().optional(),
899
- key_envelope_suite: z4.string().optional(),
900
- key_envelopes: z4.unknown().optional(),
901
- key_context: z4.unknown().optional(),
902
- key_context_raw: z4.string().optional()
913
+ var webTTYCryptoMetadataSchema = z5.object({
914
+ payload_suite: z5.string().optional(),
915
+ payload_key_id: z5.string().optional(),
916
+ nonce: z5.string().optional(),
917
+ key_envelope_suite: z5.string().optional(),
918
+ key_envelopes: z5.unknown().optional(),
919
+ key_context: z5.unknown().optional(),
920
+ key_context_raw: z5.string().optional()
903
921
  }).passthrough();
904
- var webTTYSessionEventSchema = z4.object({
905
- id: z4.string(),
906
- session_id: z4.string(),
922
+ var webTTYSessionEventSchema = z5.object({
923
+ id: z5.string(),
924
+ session_id: z5.string(),
907
925
  seq: decimalCursorSchema,
908
926
  created_at: isoDateTimeSchema2,
909
927
  type: webTTYSessionEventTypeSchema,
910
928
  direction: webTTYEventDirectionSchema.optional(),
911
929
  stream_type: webTTYStreamTypeSchema.optional(),
912
- participant_id: z4.string().optional(),
913
- payload_length: z4.number().int().nonnegative().optional(),
914
- payload_ciphertext: z4.string().optional(),
915
- payload_plaintext: z4.string().optional(),
930
+ participant_id: z5.string().optional(),
931
+ payload_length: z5.number().int().nonnegative().optional(),
932
+ payload_ciphertext: z5.string().optional(),
933
+ payload_plaintext: z5.string().optional(),
916
934
  crypto: webTTYCryptoMetadataSchema.optional(),
917
- prev_hash: z4.string().optional(),
918
- hash: z4.string().optional(),
919
- metadata: z4.unknown().optional()
935
+ prev_hash: z5.string().optional(),
936
+ hash: z5.string().optional(),
937
+ metadata: z5.unknown().optional()
920
938
  }).passthrough().superRefine((value, ctx) => {
921
939
  rejectCryptoKeyEnvelopes(value.crypto, ctx, ["crypto"]);
922
940
  });
923
941
  var webTTYKeyGrantBaseShape = {
924
- id: z4.string(),
925
- session_id: z4.string(),
926
- recipient_id: z4.string(),
927
- recipient_kind: z4.string(),
928
- granted_by: z4.string().optional(),
942
+ id: z5.string(),
943
+ session_id: z5.string(),
944
+ recipient_id: z5.string(),
945
+ recipient_kind: z5.string(),
946
+ granted_by: z5.string().optional(),
929
947
  crypto: webTTYCryptoMetadataSchema,
930
948
  created_at: isoDateTimeSchema2,
931
949
  revoked_at: isoDateTimeSchema2.optional()
932
950
  };
933
- var webTTYKeyGrantSchema = z4.object(webTTYKeyGrantBaseShape).passthrough().superRefine((value, ctx) => {
951
+ var webTTYKeyGrantSchema = z5.object(webTTYKeyGrantBaseShape).passthrough().superRefine((value, ctx) => {
934
952
  if (Object.prototype.hasOwnProperty.call(value, "wrapped_key")) {
935
953
  ctx.addIssue({
936
- code: z4.ZodIssueCode.custom,
954
+ code: z5.ZodIssueCode.custom,
937
955
  message: "wrapped_key is available only from the WebTTY decrypt-material endpoint.",
938
956
  path: ["wrapped_key"]
939
957
  });
940
958
  }
941
959
  rejectCryptoKeyEnvelopes(value.crypto, ctx, ["crypto"]);
942
960
  });
943
- var webTTYKeyGrantDecryptMaterialSchema = z4.object({
961
+ var webTTYKeyGrantDecryptMaterialSchema = z5.object({
944
962
  ...webTTYKeyGrantBaseShape,
945
- wrapped_key: z4.string().optional()
963
+ wrapped_key: z5.string().optional()
946
964
  }).passthrough();
947
- var webTTYControlRequestSchema = z4.object({
948
- id: z4.string(),
949
- session_id: z4.string(),
950
- requester_participant_id: z4.string(),
951
- requester_user_id: z4.string().optional(),
952
- approver_participant_id: z4.string().optional(),
953
- approver_user_id: z4.string().optional(),
965
+ var webTTYControlRequestSchema = z5.object({
966
+ id: z5.string(),
967
+ session_id: z5.string(),
968
+ requester_participant_id: z5.string(),
969
+ requester_user_id: z5.string().optional(),
970
+ approver_participant_id: z5.string().optional(),
971
+ approver_user_id: z5.string().optional(),
954
972
  status: webTTYControlRequestStatusSchema,
955
- reason: z4.string().optional(),
956
- metadata: z4.unknown().optional(),
973
+ reason: z5.string().optional(),
974
+ metadata: z5.unknown().optional(),
957
975
  created_at: isoDateTimeSchema2,
958
976
  updated_at: isoDateTimeSchema2,
959
977
  resolved_at: isoDateTimeSchema2.optional(),
960
978
  expires_at: isoDateTimeSchema2.optional()
961
979
  }).passthrough();
962
- var listWebTTYSessionsFiltersSchema = z4.object({
963
- server_id: z4.string().optional(),
964
- tunnel_id: z4.string().optional(),
965
- user_id: z4.string().optional(),
966
- group_id: z4.string().optional(),
980
+ var listWebTTYSessionsFiltersSchema = z5.object({
981
+ server_id: z5.string().optional(),
982
+ tunnel_id: z5.string().optional(),
983
+ user_id: z5.string().optional(),
984
+ group_id: z5.string().optional(),
967
985
  origin: webTTYOriginSchema.optional(),
968
986
  status: webTTYSessionStatusSchema.optional(),
969
987
  started_from: isoDateTimeSchema2.optional(),
970
988
  started_to: isoDateTimeSchema2.optional()
971
989
  });
972
- var listWebTTYSessionsParamsSchema = z4.object({
973
- limit: z4.number().int().min(1).optional(),
990
+ var listWebTTYSessionsParamsSchema = z5.object({
991
+ limit: z5.number().int().min(1).optional(),
974
992
  filters: listWebTTYSessionsFiltersSchema.optional()
975
993
  });
976
- var listWebTTYSessionGroupsFiltersSchema = z4.object({
977
- initiator_user_id: z4.string().optional(),
994
+ var listWebTTYSessionGroupsFiltersSchema = z5.object({
995
+ initiator_user_id: z5.string().optional(),
978
996
  origin: webTTYOriginSchema.optional(),
979
997
  created_from: isoDateTimeSchema2.optional(),
980
998
  created_to: isoDateTimeSchema2.optional()
981
999
  });
982
- var listWebTTYSessionGroupsParamsSchema = z4.object({
983
- limit: z4.number().int().min(1).optional(),
1000
+ var listWebTTYSessionGroupsParamsSchema = z5.object({
1001
+ limit: z5.number().int().min(1).optional(),
984
1002
  filters: listWebTTYSessionGroupsFiltersSchema.optional()
985
1003
  });
986
- var readWebTTYSessionEventsParamsSchema = z4.object({
1004
+ var readWebTTYSessionEventsParamsSchema = z5.object({
987
1005
  from_seq: webTTYSequenceCursorInputSchema.optional(),
988
- limit: z4.number().int().min(1).optional()
1006
+ limit: z5.number().int().min(1).optional()
989
1007
  });
990
- var listWebTTYKeyGrantDecryptMaterialParamsSchema = z4.object({
991
- recipient_id: z4.string().optional(),
992
- recipient_kind: z4.string().optional()
1008
+ var listWebTTYKeyGrantDecryptMaterialParamsSchema = z5.object({
1009
+ recipient_id: z5.string().optional(),
1010
+ recipient_kind: z5.string().optional()
993
1011
  });
994
- var listWebTTYControlRequestsFiltersSchema = z4.object({
1012
+ var listWebTTYControlRequestsFiltersSchema = z5.object({
995
1013
  status: webTTYControlRequestStatusSchema.optional(),
996
- requester_user_id: z4.string().optional()
1014
+ requester_user_id: z5.string().optional()
997
1015
  });
998
- var listWebTTYControlRequestsParamsSchema = z4.object({
999
- limit: z4.number().int().min(1).optional(),
1016
+ var listWebTTYControlRequestsParamsSchema = z5.object({
1017
+ limit: z5.number().int().min(1).optional(),
1000
1018
  filters: listWebTTYControlRequestsFiltersSchema.optional()
1001
1019
  });
1002
- var attachWebTTYParticipantParamsSchema = z4.object({
1003
- role: z4.literal("spectator").optional(),
1004
- device_id: z4.string().optional(),
1005
- browser_id: z4.string().optional(),
1020
+ var attachWebTTYParticipantParamsSchema = z5.object({
1021
+ role: z5.literal("spectator").optional(),
1022
+ device_id: z5.string().optional(),
1023
+ browser_id: z5.string().optional(),
1006
1024
  transport: webTTYTransportSchema.optional(),
1007
- grant_state: z4.string().optional(),
1025
+ grant_state: z5.string().optional(),
1008
1026
  metadata: jsonRecordSchema.optional()
1009
1027
  });
1010
- var detachWebTTYParticipantParamsSchema = z4.object({
1011
- reason: z4.string().optional(),
1028
+ var detachWebTTYParticipantParamsSchema = z5.object({
1029
+ reason: z5.string().optional(),
1012
1030
  metadata: jsonRecordSchema.optional()
1013
1031
  });
1014
- var createWebTTYControlRequestParamsSchema = z4.object({
1015
- participant_id: z4.string(),
1016
- reason: z4.string().optional(),
1032
+ var createWebTTYControlRequestParamsSchema = z5.object({
1033
+ participant_id: z5.string(),
1034
+ reason: z5.string().optional(),
1017
1035
  metadata: jsonRecordSchema.optional(),
1018
1036
  expires_at: isoDateTimeSchema2.optional()
1019
1037
  });
1020
- var resolveWebTTYControlRequestParamsSchema = z4.object({
1021
- action: z4.enum(["grant", "refuse", "revoke"]),
1022
- approver_participant_id: z4.string().optional(),
1023
- reason: z4.string().optional()
1038
+ var resolveWebTTYControlRequestParamsSchema = z5.object({
1039
+ action: z5.enum(["grant", "refuse", "revoke"]),
1040
+ approver_participant_id: z5.string().optional(),
1041
+ reason: z5.string().optional()
1024
1042
  });
1025
- var webTTYSessionListSchema = z4.array(webTTYSessionSchema);
1026
- var webTTYSessionGroupListSchema = z4.array(webTTYSessionGroupSchema);
1027
- var webTTYParticipantListSchema = z4.array(webTTYParticipantSchema);
1028
- var webTTYSessionEventListSchema = z4.array(webTTYSessionEventSchema);
1029
- var webTTYKeyGrantListSchema = z4.array(webTTYKeyGrantSchema);
1030
- var webTTYKeyGrantDecryptMaterialListSchema = z4.array(
1043
+ var webTTYSessionListSchema = z5.array(webTTYSessionSchema);
1044
+ var webTTYSessionGroupListSchema = z5.array(webTTYSessionGroupSchema);
1045
+ var webTTYParticipantListSchema = z5.array(webTTYParticipantSchema);
1046
+ var webTTYSessionEventListSchema = z5.array(webTTYSessionEventSchema);
1047
+ var webTTYKeyGrantListSchema = z5.array(webTTYKeyGrantSchema);
1048
+ var webTTYKeyGrantDecryptMaterialListSchema = z5.array(
1031
1049
  webTTYKeyGrantDecryptMaterialSchema
1032
1050
  );
1033
- var webTTYControlRequestListSchema = z4.array(webTTYControlRequestSchema);
1051
+ var webTTYControlRequestListSchema = z5.array(webTTYControlRequestSchema);
1034
1052
  function pathId(kind, value) {
1035
1053
  const normalized = value.trim();
1036
1054
  if (!normalized) {
@@ -1186,151 +1204,146 @@ var RstreamWebTTYResource = class {
1186
1204
  };
1187
1205
 
1188
1206
  // src/event.ts
1189
- var import_tunnel = require("@rstreamlabs/rstream/tunnel");
1190
- var z5 = __toESM(require("zod"));
1191
- var isoDateTimeSchema3 = z5.string().datetime({ offset: true });
1192
- var initialStateSchema = z5.object({
1207
+ var import_tunnel3 = require("@rstreamlabs/rstream/tunnel");
1208
+ var z6 = __toESM(require("zod"));
1209
+ var isoDateTimeSchema3 = z6.string().datetime({ offset: true });
1210
+ var initialStateSchema = z6.object({
1193
1211
  snapshot_at: isoDateTimeSchema3,
1194
- clients: z5.array(clientSchema),
1195
- tunnels: z5.array(import_tunnel.tunnelSchema)
1212
+ clients: z6.array(listedClientSchema),
1213
+ tunnels: z6.array(listedTunnelSchema)
1196
1214
  });
1197
- var eventBaseSchema = z5.object({
1198
- id: z5.string().optional(),
1215
+ var eventBaseSchema = z6.object({
1216
+ id: z6.string().optional(),
1199
1217
  created_at: isoDateTimeSchema3.optional(),
1200
- user_id: z5.string().optional(),
1201
- workspace_id: z5.string().optional(),
1202
- project_id: z5.string().optional(),
1203
- cluster_id: z5.string().optional()
1218
+ user_id: z6.string().optional(),
1219
+ workspace_id: z6.string().optional(),
1220
+ project_id: z6.string().optional(),
1221
+ cluster_id: z6.string().optional()
1204
1222
  });
1205
- var withEventBase = (shape) => z5.object(shape).merge(eventBaseSchema).passthrough();
1223
+ var withEventBase = (shape) => z6.object(shape).merge(eventBaseSchema).passthrough();
1206
1224
  var stateInitialEventSchema = withEventBase({
1207
- type: z5.literal("state.initial"),
1225
+ type: z6.literal("state.initial"),
1208
1226
  object: initialStateSchema
1209
1227
  });
1210
1228
  var streamSummaryEventSchema = withEventBase({
1211
- type: z5.literal("stream.summary"),
1229
+ type: z6.literal("stream.summary"),
1212
1230
  object: streamSummarySchema
1213
1231
  });
1232
+ var fullInventoryEventsSchema = [
1233
+ withEventBase({
1234
+ type: z6.literal("client.created"),
1235
+ object: import_client2.clientSchema
1236
+ }),
1237
+ withEventBase({
1238
+ type: z6.literal("client.updated"),
1239
+ object: import_client2.clientSchema
1240
+ }),
1241
+ withEventBase({
1242
+ type: z6.literal("client.deleted"),
1243
+ object: import_client2.clientSchema
1244
+ }),
1245
+ withEventBase({
1246
+ type: z6.literal("tunnel.created"),
1247
+ object: import_tunnel3.tunnelSchema
1248
+ }),
1249
+ withEventBase({
1250
+ type: z6.literal("tunnel.updated"),
1251
+ object: import_tunnel3.tunnelSchema
1252
+ }),
1253
+ withEventBase({
1254
+ type: z6.literal("tunnel.deleted"),
1255
+ object: import_tunnel3.tunnelSchema
1256
+ })
1257
+ ];
1214
1258
  var commonEventsSchema = [
1215
1259
  withEventBase({
1216
- type: z5.literal("client.created"),
1217
- object: clientSchema
1260
+ type: z6.literal("client.created"),
1261
+ object: listedClientSchema
1218
1262
  }),
1219
1263
  withEventBase({
1220
- type: z5.literal("client.updated"),
1221
- object: clientSchema
1264
+ type: z6.literal("client.updated"),
1265
+ object: listedClientSchema
1222
1266
  }),
1223
1267
  withEventBase({
1224
- type: z5.literal("client.deleted"),
1225
- object: clientSchema
1268
+ type: z6.literal("client.deleted"),
1269
+ object: listedClientSchema
1226
1270
  }),
1227
1271
  withEventBase({
1228
- type: z5.literal("tunnel.created"),
1229
- object: import_tunnel.tunnelSchema
1272
+ type: z6.literal("tunnel.created"),
1273
+ object: listedTunnelSchema
1230
1274
  }),
1231
1275
  withEventBase({
1232
- type: z5.literal("tunnel.updated"),
1233
- object: import_tunnel.tunnelSchema
1276
+ type: z6.literal("tunnel.updated"),
1277
+ object: listedTunnelSchema
1234
1278
  }),
1235
1279
  withEventBase({
1236
- type: z5.literal("tunnel.deleted"),
1237
- object: import_tunnel.tunnelSchema
1280
+ type: z6.literal("tunnel.deleted"),
1281
+ object: listedTunnelSchema
1238
1282
  })
1239
1283
  ];
1240
1284
  var webTTYEventsSchema = [
1241
1285
  withEventBase({
1242
- type: z5.literal("webtty.session.created"),
1286
+ type: z6.literal("webtty.session.created"),
1243
1287
  object: webTTYSessionSchema
1244
1288
  }),
1245
1289
  withEventBase({
1246
- type: z5.literal("webtty.session.updated"),
1247
- object: z5.union([webTTYSessionSchema, webTTYSessionGroupSchema])
1290
+ type: z6.literal("webtty.session.updated"),
1291
+ object: z6.union([webTTYSessionSchema, webTTYSessionGroupSchema])
1248
1292
  }),
1249
1293
  withEventBase({
1250
- type: z5.literal("webtty.session.ended"),
1294
+ type: z6.literal("webtty.session.ended"),
1251
1295
  object: webTTYSessionSchema
1252
1296
  }),
1253
1297
  withEventBase({
1254
- type: z5.literal("webtty.participant.joined"),
1298
+ type: z6.literal("webtty.participant.joined"),
1255
1299
  object: webTTYParticipantSchema
1256
1300
  }),
1257
1301
  withEventBase({
1258
- type: z5.literal("webtty.participant.updated"),
1302
+ type: z6.literal("webtty.participant.updated"),
1259
1303
  object: webTTYParticipantSchema
1260
1304
  }),
1261
1305
  withEventBase({
1262
- type: z5.literal("webtty.participant.left"),
1306
+ type: z6.literal("webtty.participant.left"),
1263
1307
  object: webTTYParticipantSchema
1264
1308
  }),
1265
1309
  withEventBase({
1266
- type: z5.literal("webtty.control.requested"),
1310
+ type: z6.literal("webtty.control.requested"),
1267
1311
  object: webTTYControlRequestSchema
1268
1312
  }),
1269
1313
  withEventBase({
1270
- type: z5.literal("webtty.control.granted"),
1314
+ type: z6.literal("webtty.control.granted"),
1271
1315
  object: webTTYControlRequestSchema
1272
1316
  }),
1273
1317
  withEventBase({
1274
- type: z5.literal("webtty.control.refused"),
1318
+ type: z6.literal("webtty.control.refused"),
1275
1319
  object: webTTYControlRequestSchema
1276
1320
  }),
1277
1321
  withEventBase({
1278
- type: z5.literal("webtty.control.revoked"),
1322
+ type: z6.literal("webtty.control.revoked"),
1279
1323
  object: webTTYControlRequestSchema
1280
1324
  })
1281
1325
  ];
1282
1326
  var webhookDeliverableEventsSchema = [
1283
- commonEventsSchema[0],
1284
- commonEventsSchema[2],
1285
- commonEventsSchema[3],
1286
- commonEventsSchema[5],
1327
+ fullInventoryEventsSchema[0],
1328
+ fullInventoryEventsSchema[2],
1329
+ fullInventoryEventsSchema[3],
1330
+ fullInventoryEventsSchema[5],
1287
1331
  ...webTTYEventsSchema
1288
1332
  ];
1289
- var wsEventsSchema = z5.union([
1333
+ var wsEventsSchema = z6.union([
1290
1334
  stateInitialEventSchema,
1291
1335
  ...commonEventsSchema,
1292
1336
  ...webTTYEventsSchema
1293
1337
  ]);
1294
- var webhookEventsSchema = z5.union(webhookDeliverableEventsSchema);
1338
+ var webhookEventsSchema = z6.union(webhookDeliverableEventsSchema);
1295
1339
  var projectLogEventsSchema = streamSummaryEventSchema;
1296
- var eventSchema = z5.union([
1340
+ var eventSchema = z6.union([
1297
1341
  wsEventsSchema,
1298
1342
  webhookEventsSchema,
1299
1343
  projectLogEventsSchema
1300
1344
  ]);
1301
1345
 
1302
- // src/tunnel.ts
1303
- var import_tunnel2 = require("@rstreamlabs/rstream/tunnel");
1304
- var z6 = __toESM(require("zod"));
1305
- var DEFAULT_PUBLISHED_PORT = 443;
1306
- var tunnelFilterSchema = import_tunnel2.tunnelSchema.pick({
1307
- id: true,
1308
- name: true,
1309
- type: true,
1310
- status: true,
1311
- client_id: true,
1312
- user_id: true,
1313
- publish: true,
1314
- protocol: true,
1315
- hostname: true,
1316
- http_version: true,
1317
- labels: true
1318
- }).partial();
1319
- var listTunnelsParamsSchema = z6.object({
1320
- limit: z6.number().int().min(1).optional(),
1321
- filters: tunnelFilterSchema.optional()
1322
- });
1323
- var listTunnelsResponseSchema = z6.array(import_tunnel2.tunnelSchema);
1324
- function formatTunnelHost(tunnel) {
1325
- if (!tunnel.hostname) return tunnel.host;
1326
- if (!tunnel.port || tunnel.port === DEFAULT_PUBLISHED_PORT) {
1327
- return tunnel.hostname;
1328
- }
1329
- return `${tunnel.hostname}:${tunnel.port}`;
1330
- }
1331
-
1332
1346
  // src/openapi.ts
1333
- var import_tunnel5 = require("@rstreamlabs/rstream/tunnel");
1334
1347
  var z7 = __toESM(require("zod"));
1335
1348
  var jsonContentType = "application/json";
1336
1349
  var openApiContentType = "application/vnd.oai.openapi+json;version=3.1";
@@ -1409,12 +1422,6 @@ var readEngineStateRule = {
1409
1422
  action: "read"
1410
1423
  };
1411
1424
  var readEngineStateRules = [readEngineStateRule];
1412
- var readEngineStreamsRules = [
1413
- {
1414
- resource: "engine.streams",
1415
- action: "read"
1416
- }
1417
- ];
1418
1425
  var watchParamsSchema = z7.object({
1419
1426
  clients: clientFilterSchema.optional(),
1420
1427
  tunnels: tunnelFilterSchema.optional()
@@ -1644,11 +1651,11 @@ var engineOpenApiDocument = {
1644
1651
  }
1645
1652
  }
1646
1653
  },
1647
- Client: jsonSchemaFor(clientSchema),
1654
+ Client: jsonSchemaFor(listedClientSchema),
1648
1655
  Event: jsonSchemaFor(wsEventsSchema),
1649
1656
  ListClientsParams: jsonSchemaFor(listClientsParamsSchema),
1650
1657
  ListTunnelsParams: jsonSchemaFor(listTunnelsParamsSchema),
1651
- TunnelListItem: jsonSchemaFor(import_tunnel5.tunnelSchema),
1658
+ TunnelListItem: jsonSchemaFor(listedTunnelSchema),
1652
1659
  WatchParams: jsonSchemaFor(watchParamsSchema)
1653
1660
  }
1654
1661
  },
@@ -1829,19 +1836,20 @@ var engineOpenApiDocument = {
1829
1836
  get: {
1830
1837
  tags: ["Runtime inventory"],
1831
1838
  summary: "List visible engine clients.",
1839
+ "x-rstream-token-scope": "resources.tunnels.scopes.clients.list",
1832
1840
  operationId: "list_engine_clients",
1833
1841
  parameters: [{ $ref: "#/components/parameters/ListClientsParams" }],
1834
1842
  security: [{ bearerAuth: [] }, { mutualTLS: [] }],
1835
1843
  responses: {
1836
1844
  "200": jsonArrayResponse(
1837
- "Visible clients.",
1845
+ "Visible clients. Fine-grained list scopes may filter objects and project fields.",
1838
1846
  "#/components/schemas/Client"
1839
1847
  ),
1840
1848
  "400": { $ref: "#/components/responses/BadRequest" },
1841
1849
  "401": { $ref: "#/components/responses/Unauthorized" },
1842
1850
  "403": { $ref: "#/components/responses/Forbidden" }
1843
1851
  },
1844
- "x-rstream-required-rules": readEngineStreamsRules
1852
+ "x-rstream-required-rules": readEngineStateRules
1845
1853
  }
1846
1854
  },
1847
1855
  "/api/tunnels": {
@@ -1861,7 +1869,7 @@ var engineOpenApiDocument = {
1861
1869
  "403": { $ref: "#/components/responses/Forbidden" }
1862
1870
  },
1863
1871
  "x-rstream-required-rules": readEngineStateRules,
1864
- "x-rstream-token-metadata-scope": "metadata.scopes.tunnels.list"
1872
+ "x-rstream-token-scope": "resources.tunnels.scopes.tunnels.list"
1865
1873
  }
1866
1874
  },
1867
1875
  "/api/sse": {
@@ -2167,7 +2175,7 @@ async function resolveManagedTunnelsProject(config) {
2167
2175
  }
2168
2176
 
2169
2177
  // src/tunnels-resource.ts
2170
- var import_tunnel7 = require("@rstreamlabs/rstream/tunnel");
2178
+ var import_tunnel8 = require("@rstreamlabs/rstream/tunnel");
2171
2179
  function tunnelPathId(id) {
2172
2180
  const normalized = id.trim();
2173
2181
  if (!normalized) {
@@ -2194,7 +2202,7 @@ var RstreamTunnelsResource = class {
2194
2202
  method: "GET"
2195
2203
  }
2196
2204
  );
2197
- return import_tunnel7.tunnelSchema.parse(response);
2205
+ return import_tunnel8.tunnelSchema.parse(response);
2198
2206
  }
2199
2207
  };
2200
2208
 
@@ -3526,7 +3534,7 @@ function validateWatchQueryToken(token) {
3526
3534
  }
3527
3535
  if (!hasWatchOnlyTunnelResources(parsed.data)) {
3528
3536
  throw new Error(
3529
- "Watch requires a fine-grained token limited to tunnel list resources for URL-based authentication."
3537
+ "Watch requires a fine-grained token limited to client or tunnel list resources for URL-based authentication."
3530
3538
  );
3531
3539
  }
3532
3540
  }
@@ -3542,38 +3550,38 @@ function hasWatchOnlyTunnelResources(token) {
3542
3550
  }
3543
3551
  function hasWatchOnlyTunnelResource(resource) {
3544
3552
  return watchResourceBranches(resource).every(
3545
- (branch) => branch.hasList && !branch.hasMutationOrConnect
3553
+ (branch) => (branch.clients || branch.tunnels) && !branch.create && !branch.connect
3546
3554
  );
3547
3555
  }
3548
3556
  function watchResourceBranches(resource) {
3549
3557
  if ("AND" in resource) {
3550
3558
  return resource.AND.reduce(
3551
- (branches, child) => combineWatchResourceBranches(branches, child),
3552
- [{ hasList: false, hasMutationOrConnect: false }]
3559
+ (branches, child) => branches.flatMap(
3560
+ (branch) => watchResourceBranches(child).map((other) => ({
3561
+ clients: branch.clients && other.clients,
3562
+ tunnels: branch.tunnels && other.tunnels,
3563
+ create: branch.create && other.create,
3564
+ connect: branch.connect && other.connect
3565
+ }))
3566
+ ),
3567
+ [{ clients: true, tunnels: true, create: true, connect: true }]
3553
3568
  );
3554
3569
  }
3555
- if ("OR" in resource) {
3556
- return resource.OR.flatMap(watchResourceBranches);
3557
- }
3558
- const tunnels = resource.scopes?.tunnels;
3559
- if (tunnels === void 0) {
3560
- return [{ hasList: false, hasMutationOrConnect: false }];
3570
+ if ("OR" in resource) return resource.OR.flatMap(watchResourceBranches);
3571
+ if (resource.scopes === void 0) {
3572
+ return [{ clients: true, tunnels: true, create: true, connect: true }];
3561
3573
  }
3574
+ const { clients, tunnels } = resource.scopes;
3575
+ const allows = (scope) => scope !== void 0 && scope !== false;
3562
3576
  return [
3563
3577
  {
3564
- hasList: tunnels.list !== void 0,
3565
- hasMutationOrConnect: tunnels.create !== void 0 || tunnels.connect !== void 0
3578
+ clients: clients === void 0 || allows(clients.list),
3579
+ tunnels: allows(tunnels?.list),
3580
+ create: allows(tunnels?.create),
3581
+ connect: allows(tunnels?.connect)
3566
3582
  }
3567
3583
  ];
3568
3584
  }
3569
- function combineWatchResourceBranches(branches, child) {
3570
- return branches.flatMap(
3571
- (branch) => watchResourceBranches(child).map((childBranch) => ({
3572
- hasList: branch.hasList || childBranch.hasList,
3573
- hasMutationOrConnect: branch.hasMutationOrConnect || childBranch.hasMutationOrConnect
3574
- }))
3575
- );
3576
- }
3577
3585
  function hasWatchOnlyPermissions(permissions) {
3578
3586
  if (!Array.isArray(permissions)) {
3579
3587
  return true;
@@ -3799,7 +3807,7 @@ function webTTYHasCapability(capabilities, capability) {
3799
3807
  return capabilities.includes(capability);
3800
3808
  }
3801
3809
  function parser(tunnel, includePrivate) {
3802
- if (tunnel.status !== "online") return null;
3810
+ if (!tunnel.id || tunnel.status !== "online") return null;
3803
3811
  if (tunnel.publish !== true && !includePrivate) return null;
3804
3812
  const managedProtocol = tunnel.protocol === "webtty";
3805
3813
  if (tunnel.protocol !== void 0 && tunnel.protocol !== "http" && !managedProtocol)
@@ -3957,6 +3965,8 @@ function resolveWebTTYBrowserEndpoint(server) {
3957
3965
  listWebTTYKeyGrantDecryptMaterialParamsSchema,
3958
3966
  listWebTTYSessionGroupsParamsSchema,
3959
3967
  listWebTTYSessionsParamsSchema,
3968
+ listedClientSchema,
3969
+ listedTunnelSchema,
3960
3970
  normalizeEngineAddress,
3961
3971
  parseWebTTYServers,
3962
3972
  projectLogEventsSchema,