@rstreamlabs/tunnels 3.10.2 → 4.0.3

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