@q9labsai/chalk-client 5.2.4 → 5.2.6

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/access/grant.d.ts +2 -1
  3. package/dist/access/manager.d.ts +1 -0
  4. package/dist/{chunk-AZONR3Q3.js → chunk-CJVLTSIO.js} +120 -8
  5. package/dist/{chunk-LDPC2JZB.js → chunk-I7Y4HR2P.js} +711 -194
  6. package/dist/{chunk-SYUGRHZ5.js → chunk-WFRTUBN6.js} +1 -1
  7. package/dist/{chunk-3ASKGMD3.js → chunk-YIDKETOX.js} +410 -232
  8. package/dist/client.d.ts +74 -2
  9. package/dist/connection/dependencies.d.ts +4 -1
  10. package/dist/connection/diagnostics.d.ts +4 -0
  11. package/dist/connection/episode-status.d.ts +7 -0
  12. package/dist/connection/index.d.ts +2 -0
  13. package/dist/connection/lifecycle.d.ts +2 -0
  14. package/dist/connection/production.d.ts +1 -1
  15. package/dist/effect.js +19 -3
  16. package/dist/generated/http-api.d.ts +73 -2
  17. package/dist/generated/schemas.d.ts +126 -4
  18. package/dist/index.js +4 -4
  19. package/dist/media/client.d.ts +4 -3
  20. package/dist/media/failure-diagnostics.d.ts +10 -0
  21. package/dist/media/index.js +1 -1
  22. package/dist/media/plane.d.ts +7 -2
  23. package/dist/media/types.d.ts +4 -2
  24. package/dist/public-invites/index.js +2 -2
  25. package/dist/server/access-refresh.d.cts +1 -1
  26. package/dist/server/access-refresh.d.ts +1 -1
  27. package/dist/server/index.cjs +15 -5
  28. package/dist/server/index.js +15 -5
  29. package/dist/server/types.d.cts +2 -1
  30. package/dist/server/types.d.ts +2 -1
  31. package/dist/space-client/media-projection-monitor.d.ts +26 -0
  32. package/dist/space-client/promise-facade.d.ts +5 -5
  33. package/dist/space-client/types.d.ts +4 -0
  34. package/dist/transport-diagnostics.d.ts +1 -1
  35. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.2.6
4
+
5
+ - Reuse microphone and camera senders after short browser capture interruptions, keeping capture disabled until a fresh user enable. Republish after long interruptions before trusting an expired provider track, and detach again if capture is interrupted during reattachment. Report interrupted owned capture as unavailable to other participants through the existing Sync pause command. Include a bounded replacement cause on the first SFU track request after a media connection is replaced.
6
+
3
7
  ## 5.2.0
4
8
 
5
9
  ### board-draw-policy
@@ -39,8 +39,9 @@ export type AccessGrant = {
39
39
  };
40
40
  export type AccessGrantProvider = () => ParsedAccessGrant | Promise<ParsedAccessGrant>;
41
41
  export declare class AccessGrantError extends TypeError {
42
+ readonly reason?: "connection_superseded" | undefined;
42
43
  readonly code: "access.invalid";
43
- constructor(message?: string);
44
+ constructor(message?: string, reason?: "connection_superseded" | undefined);
44
45
  }
45
46
  export declare function parseParsedAccessGrant(value: unknown): ParsedAccessGrant;
46
47
  export declare function parseAccessGrant(value: unknown): AccessGrant;
@@ -23,6 +23,7 @@ export type ConnectionAccessEffectService = {
23
23
  readonly subscribeAutomaticMediaReplacement: (listener: AutomaticMediaReplacementListener) => Effect.Effect<() => void>;
24
24
  readonly requiresRefresh: Effect.Effect<boolean>;
25
25
  readonly millisecondsUntilRefresh: Effect.Effect<number | null>;
26
+ readonly holdMediaBinding: (binding: string) => Effect.Effect<Effect.Effect<void>>;
26
27
  readonly clear: Effect.Effect<void>;
27
28
  };
28
29
  declare const ConnectionAccessService_base: Context.ServiceClass<ConnectionAccessService, "@chalk/client/ConnectionAccess", ConnectionAccessEffectService>;
@@ -295,17 +295,25 @@ var ConnectionReportRequestSchema = Schema.Struct({
295
295
  "sync_socket_close",
296
296
  "sync_heartbeat_gap",
297
297
  "media_state",
298
- "media_http_error"
298
+ "media_http_error",
299
+ "media_projection_mismatch"
299
300
  ]),
301
+ granted_audio: Schema.optional(Schema.Literals(["granted", "not_granted", "unknown"])),
302
+ granted_video: Schema.optional(Schema.Literals(["granted", "not_granted", "unknown"])),
300
303
  heartbeat_gap_ms: Schema.optional(Schema.NullOr(Schema.Number)),
301
304
  http_status: Schema.optional(Schema.NullOr(Schema.Number)),
305
+ media_error_kind: Schema.optional(Schema.Literals(["NotAllowedError", "NotReadableError", "NotFoundError", "OverconstrainedError", "AbortError", "SecurityError", "InvalidStateError", "OperationError", "NotSupportedError", "CloudflareSFUError", "network", "timeout", "unknown"])),
306
+ media_error_step: Schema.optional(Schema.Literals(["local_capture", "peer_connection", "access_refresh", "sfu_tracks", "sfu_close_tracks", "sfu_renegotiate", "sfu_publications"])),
302
307
  outcome: Schema.optional(Schema.Literals(["started", "succeeded", "failed", "cancelled"])),
303
308
  phase: Schema.optional(Schema.Literals(["idle", "connecting", "live", "recovering", "failed", "stopped", "new", "connected", "disconnected", "closed"])),
309
+ projection_state: Schema.optional(Schema.Literals(["on", "off"])),
310
+ publication_state: Schema.optional(Schema.Literals(["on", "off"])),
311
+ source: Schema.optional(Schema.Literals(["microphone", "camera"])),
304
312
  state: Schema.optional(Schema.Literals(["idle", "joining", "live", "reconnecting", "leaving", "left", "failed"])),
305
313
  step: Schema.optional(Schema.Literals(["join", "acquire_initial_media", "access_initialize", "create_media_client", "create_sync_client", "start_media", "start_sync", "wait_for_sync_live", "confirm_entered"]))
306
314
  })
307
315
  ).check(Schema.isMinLength(1), Schema.isMaxLength(64)),
308
- trigger: Schema.Literals(["join_failed", "connection_lost", "recovery_exhausted"]),
316
+ trigger: Schema.Literals(["join_failed", "connection_lost", "recovery_exhausted", "media_projection_mismatch"]),
309
317
  version: Schema.Literal(1)
310
318
  });
311
319
  var CreateAPIKeyRequestSchema = Schema.Struct({
@@ -475,6 +483,7 @@ var IntegrationActionIdSchema = Schema.String.check(Schema.isMinLength(1)).pipe(
475
483
  var IntegrationServiceIdSchema = Schema.String.check(Schema.isMinLength(1)).pipe(Schema.brand("IntegrationServiceId"));
476
484
  var IssueAccessGrantRequestSchema = Schema.Struct({
477
485
  current_media_token: Schema.optional(Schema.String.check(Schema.isMinLength(1))),
486
+ expected_media_connection_id: Schema.optional(Schema.NullOr(Schema.String.check(Schema.isMinLength(1)))),
478
487
  participant_generation: Schema.Number,
479
488
  replace_media_connection: Schema.Boolean
480
489
  });
@@ -493,6 +502,9 @@ var MembershipListSchema = Schema.Struct({
493
502
  memberships: Schema.Array(MembershipSchema),
494
503
  pagination: PaginationSchema
495
504
  });
505
+ var ParticipantEpisodeStatusSchema = Schema.Struct({
506
+ status: Schema.Literals(["active", "ending", "ended"])
507
+ });
496
508
  var ParticipantJoinCancellationSchema = Schema.Struct({
497
509
  cancelled: Schema.Boolean
498
510
  });
@@ -1097,7 +1109,25 @@ var AddCloudflareSFUTracksPathParamsSchema = Schema.Struct({
1097
1109
  tenant_id: TenantIdSchema
1098
1110
  });
1099
1111
  var AddCloudflareSFUTracksQueryParamsSchema = Schema.Struct({
1100
- allow_partial_remote_tracks: Schema.optional(Schema.Boolean)
1112
+ allow_partial_remote_tracks: Schema.optional(Schema.Boolean),
1113
+ replacement_cause: Schema.optional(
1114
+ Schema.Literals([
1115
+ "user_pause",
1116
+ "moderation_pause",
1117
+ "sync_recovery_loss",
1118
+ "discovery_absent",
1119
+ "capture_cleanup",
1120
+ "consent_revoked",
1121
+ "publish_failure",
1122
+ "enable_failure",
1123
+ "projection_mismatch",
1124
+ "forced_pause",
1125
+ "local_signaling_failure",
1126
+ "remote_signaling_failure",
1127
+ "dormant_connection",
1128
+ "access_refresh"
1129
+ ])
1130
+ )
1101
1131
  });
1102
1132
  var AddCloudflareSFUTracksRequestBodySchema = CloudflareSFUTracksRequestSchema;
1103
1133
  var AddCloudflareSFUTracksResponseSchema = CloudflareSFUTracksAPIResponseSchema;
@@ -1383,6 +1413,18 @@ var GetEpisodeAttendance429ResponseHeadersSchema = Schema.Struct({
1383
1413
  "X-RateLimit-Limit": RateLimitLimitHeaderSchema,
1384
1414
  "X-RateLimit-Remaining": RateLimitRemainingHeaderSchema
1385
1415
  });
1416
+ var GetParticipantEpisodeStatusPathParamsSchema = Schema.Struct({
1417
+ episode_id: EpisodeIdSchema,
1418
+ participant_id: ParticipantIdSchema,
1419
+ space_id: SpaceIdSchema,
1420
+ tenant_id: TenantIdSchema
1421
+ });
1422
+ var GetParticipantEpisodeStatusResponseSchema = ParticipantEpisodeStatusSchema;
1423
+ var GetParticipantEpisodeStatus429ResponseHeadersSchema = Schema.Struct({
1424
+ "Retry-After": RetryAfterHeaderSchema,
1425
+ "X-RateLimit-Limit": RateLimitLimitHeaderSchema,
1426
+ "X-RateLimit-Remaining": RateLimitRemainingHeaderSchema
1427
+ });
1386
1428
  var GetProblemReportAvailabilityPathParamsSchema = Schema.Struct({
1387
1429
  tenant_id: TenantIdSchema
1388
1430
  });
@@ -2889,6 +2931,25 @@ var ParticipantInvalidIdErrorSchema = ParticipantInvalidIdErrorWireSchema.pipe(
2889
2931
  encode: SchemaGetter.transform((error) => ({ error: error.error }))
2890
2932
  })
2891
2933
  );
2934
+ var ParticipantMediaReplacementPendingError = class extends Schema.TaggedErrorClass()("ParticipantMediaReplacementPendingError", {
2935
+ error: Schema.Struct({
2936
+ code: Schema.Literal("participant.media_replacement_pending"),
2937
+ message: Schema.String
2938
+ })
2939
+ }) {
2940
+ };
2941
+ var ParticipantMediaReplacementPendingErrorWireSchema = Schema.Struct({
2942
+ error: Schema.Struct({
2943
+ code: Schema.Literal("participant.media_replacement_pending"),
2944
+ message: Schema.String
2945
+ })
2946
+ });
2947
+ var ParticipantMediaReplacementPendingErrorSchema = ParticipantMediaReplacementPendingErrorWireSchema.pipe(
2948
+ Schema.decodeTo(ParticipantMediaReplacementPendingError, {
2949
+ decode: SchemaGetter.transform((wire) => ({ _tag: "ParticipantMediaReplacementPendingError", ...wire })),
2950
+ encode: SchemaGetter.transform((error) => ({ error: error.error }))
2951
+ })
2952
+ );
2892
2953
  var ParticipantNotActiveError = class extends Schema.TaggedErrorClass()("ParticipantNotActiveError", {
2893
2954
  error: Schema.Struct({
2894
2955
  code: Schema.Literal("participant.not_active"),
@@ -4490,6 +4551,18 @@ var GetEpisodeErrorSchema = Schema.Union([
4490
4551
  SpaceNotFoundErrorSchema,
4491
4552
  TenantInvalidIdErrorSchema
4492
4553
  ]);
4554
+ var GetParticipantEpisodeStatusErrorSchema = Schema.Union([
4555
+ AccessForbiddenErrorSchema,
4556
+ AccessUnauthenticatedErrorSchema,
4557
+ EpisodeInvalidIdErrorSchema,
4558
+ EpisodeNotFoundErrorSchema,
4559
+ ParticipantInvalidIdErrorSchema,
4560
+ RequestRateLimitedErrorSchema,
4561
+ ServiceInternalErrorSchema,
4562
+ ServiceUnavailableErrorSchema,
4563
+ SpaceInvalidIdErrorSchema,
4564
+ TenantInvalidIdErrorSchema
4565
+ ]);
4493
4566
  var GetProblemReportAvailabilityErrorSchema = TenantInvalidIdErrorSchema;
4494
4567
  var GetRecordingErrorSchema = Schema.Union([AccessForbiddenErrorSchema, AccessUnauthenticatedErrorSchema, RecordingInvalidIdErrorSchema, RecordingNotFoundErrorSchema, ServiceInternalErrorSchema, ServiceUnavailableErrorSchema, TenantInvalidIdErrorSchema]);
4495
4568
  var GetSpaceErrorSchema = Schema.Union([AccessForbiddenErrorSchema, AccessUnauthenticatedErrorSchema, ServiceInternalErrorSchema, ServiceUnavailableErrorSchema, SpaceInvalidIdErrorSchema, SpaceNotFoundErrorSchema, TenantInvalidIdErrorSchema]);
@@ -4621,6 +4694,7 @@ var IssueAccessGrantErrorSchema = Schema.Union([
4621
4694
  ParticipantConnectionSupersededErrorSchema,
4622
4695
  ParticipantGenerationMismatchErrorSchema,
4623
4696
  ParticipantInvalidIdErrorSchema,
4697
+ ParticipantMediaReplacementPendingErrorSchema,
4624
4698
  ParticipantNotFoundErrorSchema,
4625
4699
  RequestInvalidErrorSchema,
4626
4700
  RequestPayloadTooLargeErrorSchema,
@@ -5148,6 +5222,7 @@ var ChalkOperationPolicies = {
5148
5222
  findTenantByExternalID: { rateLimit: { limit: 300, policy: "v1.authenticated.read", windowSeconds: 60 } },
5149
5223
  getEpisode: { rateLimit: { limit: 300, policy: "v1.authenticated.read", windowSeconds: 60 } },
5150
5224
  getEpisodeAttendance: { rateLimit: { limit: 300, policy: "v1.authenticated.read", windowSeconds: 60 } },
5225
+ getParticipantEpisodeStatus: { rateLimit: { limit: 300, policy: "v1.authenticated.read", windowSeconds: 60 } },
5151
5226
  getSpacePublicInvite: { rateLimit: { limit: 300, policy: "v1.authenticated.read", windowSeconds: 60 } },
5152
5227
  getSpacePublicInviteArrival: { rateLimit: { limit: 300, policy: "v1.authenticated.read", windowSeconds: 60 } },
5153
5228
  getTenant: { rateLimit: { limit: 300, policy: "v1.authenticated.read", windowSeconds: 60 } },
@@ -5475,6 +5550,7 @@ var defaultGroup = HttpApiGroup.make("default").add(
5475
5550
  ParticipantNotFoundErrorSchema.pipe(HttpApiSchema.status(404)),
5476
5551
  ParticipantConnectionSupersededErrorSchema.pipe(HttpApiSchema.status(409)),
5477
5552
  ParticipantGenerationMismatchErrorSchema.pipe(HttpApiSchema.status(409)),
5553
+ ParticipantMediaReplacementPendingErrorSchema.pipe(HttpApiSchema.status(409)),
5478
5554
  RequestPayloadTooLargeErrorSchema.pipe(HttpApiSchema.status(413)),
5479
5555
  RequestRateLimitedErrorSchema.pipe(HttpApiSchema.status(429)),
5480
5556
  ServiceInternalErrorSchema.pipe(HttpApiSchema.status(500)),
@@ -5911,6 +5987,23 @@ var episodesGroup = HttpApiGroup.make("episodes").add(
5911
5987
  ServiceUnavailableErrorSchema.pipe(HttpApiSchema.status(503))
5912
5988
  ]
5913
5989
  })
5990
+ ).add(
5991
+ HttpApiEndpoint.get("getParticipantEpisodeStatus", "/v1/tenants/:tenant_id/spaces/:space_id/episodes/:episode_id/participants/:participant_id/episode-status", {
5992
+ params: GetParticipantEpisodeStatusPathParamsSchema,
5993
+ success: GetParticipantEpisodeStatusResponseSchema.pipe(HttpApiSchema.status(200)),
5994
+ error: [
5995
+ EpisodeInvalidIdErrorSchema.pipe(HttpApiSchema.status(400)),
5996
+ ParticipantInvalidIdErrorSchema.pipe(HttpApiSchema.status(400)),
5997
+ SpaceInvalidIdErrorSchema.pipe(HttpApiSchema.status(400)),
5998
+ TenantInvalidIdErrorSchema.pipe(HttpApiSchema.status(400)),
5999
+ AccessUnauthenticatedErrorSchema.pipe(HttpApiSchema.status(401)),
6000
+ AccessForbiddenErrorSchema.pipe(HttpApiSchema.status(403)),
6001
+ EpisodeNotFoundErrorSchema.pipe(HttpApiSchema.status(404)),
6002
+ RequestRateLimitedErrorSchema.pipe(HttpApiSchema.status(429)),
6003
+ ServiceInternalErrorSchema.pipe(HttpApiSchema.status(500)),
6004
+ ServiceUnavailableErrorSchema.pipe(HttpApiSchema.status(503))
6005
+ ]
6006
+ })
5914
6007
  ).add(
5915
6008
  HttpApiEndpoint.post("issueEpisodeParticipantSyncToken", "/v1/tenants/:tenant_id/spaces/:space_id/episodes/:episode_id/participants/:participant_id/sync-token", {
5916
6009
  params: IssueEpisodeParticipantSyncTokenPathParamsSchema,
@@ -6797,11 +6890,13 @@ function decodeBase64Url(value) {
6797
6890
  // src/access/grant.ts
6798
6891
  var accessGrantBrand = /* @__PURE__ */ Symbol("AccessGrant");
6799
6892
  var AccessGrantError = class extends TypeError {
6800
- code = "access.invalid";
6801
- constructor(message = "Access grant is invalid") {
6893
+ constructor(message = "Access grant is invalid", reason) {
6802
6894
  super(message);
6895
+ this.reason = reason;
6803
6896
  this.name = "AccessGrantError";
6804
6897
  }
6898
+ reason;
6899
+ code = "access.invalid";
6805
6900
  };
6806
6901
  var AccessUnavailableError = class extends Error {
6807
6902
  code = "access.unavailable";
@@ -6810,12 +6905,21 @@ var AccessUnavailableError = class extends Error {
6810
6905
  this.name = "AccessUnavailableError";
6811
6906
  }
6812
6907
  };
6813
- function requireSuccessfulResponse(response) {
6908
+ async function requireSuccessfulResponse(response) {
6814
6909
  if (response.ok) return;
6815
6910
  const status = response.status;
6816
6911
  if (status === 408 || status === 425 || status === 429 || status >= 500) throw new AccessUnavailableError(status);
6912
+ if (status === 409) {
6913
+ const body = await response.json().catch(() => null);
6914
+ const code = conflictResponseCode(body);
6915
+ if (code === "participant.media_replacement_pending") throw new AccessUnavailableError(status);
6916
+ if (code === "participant.connection_superseded") throw new AccessGrantError(void 0, "connection_superseded");
6917
+ }
6817
6918
  throw new AccessGrantError(`Access grant request failed with HTTP ${status}`);
6818
6919
  }
6920
+ function conflictResponseCode(body) {
6921
+ return typeof body === "object" && body !== null && "error" in body && typeof body.error === "object" && body.error !== null && "code" in body.error ? body.error.code : void 0;
6922
+ }
6819
6923
  function parseParsedAccessGrant(value) {
6820
6924
  if (!isRecord(value)) throw new AccessGrantError();
6821
6925
  const subject = parseSubject(value.subject);
@@ -6852,7 +6956,7 @@ function accessGrantFromParsed(value) {
6852
6956
  }
6853
6957
  async function requireParsedAccessGrant(value) {
6854
6958
  if (typeof Response !== "undefined" && value instanceof Response) {
6855
- requireSuccessfulResponse(value);
6959
+ await requireSuccessfulResponse(value);
6856
6960
  try {
6857
6961
  return parseParsedAccessGrant(await value.json());
6858
6962
  } catch (error) {
@@ -6864,7 +6968,7 @@ async function requireParsedAccessGrant(value) {
6864
6968
  }
6865
6969
  async function requireAccessGrant(value) {
6866
6970
  if (typeof Response !== "undefined" && value instanceof Response) {
6867
- requireSuccessfulResponse(value);
6971
+ await requireSuccessfulResponse(value);
6868
6972
  try {
6869
6973
  return parseAccessGrant(await value.json());
6870
6974
  } catch (error) {
@@ -7007,6 +7111,7 @@ export {
7007
7111
  MembershipIdSchema,
7008
7112
  MembershipSchema,
7009
7113
  MembershipListSchema,
7114
+ ParticipantEpisodeStatusSchema,
7010
7115
  ParticipantJoinCancellationSchema,
7011
7116
  ParticipantLifecycleSchema,
7012
7117
  ParticipantRemovalSchema,
@@ -7163,6 +7268,9 @@ export {
7163
7268
  GetEpisodeAttendancePathParamsSchema,
7164
7269
  GetEpisodeAttendanceResponseSchema,
7165
7270
  GetEpisodeAttendance429ResponseHeadersSchema,
7271
+ GetParticipantEpisodeStatusPathParamsSchema,
7272
+ GetParticipantEpisodeStatusResponseSchema,
7273
+ GetParticipantEpisodeStatus429ResponseHeadersSchema,
7166
7274
  GetProblemReportAvailabilityPathParamsSchema,
7167
7275
  GetProblemReportAvailabilityResponseSchema,
7168
7276
  GetRecordingPathParamsSchema,
@@ -7490,6 +7598,9 @@ export {
7490
7598
  ParticipantInvalidIdError,
7491
7599
  ParticipantInvalidIdErrorWireSchema,
7492
7600
  ParticipantInvalidIdErrorSchema,
7601
+ ParticipantMediaReplacementPendingError,
7602
+ ParticipantMediaReplacementPendingErrorWireSchema,
7603
+ ParticipantMediaReplacementPendingErrorSchema,
7493
7604
  ParticipantNotActiveError,
7494
7605
  ParticipantNotActiveErrorWireSchema,
7495
7606
  ParticipantNotActiveErrorSchema,
@@ -7711,6 +7822,7 @@ export {
7711
7822
  GetChatAttachmentDownloadErrorSchema,
7712
7823
  GetEpisodeAttendanceErrorSchema,
7713
7824
  GetEpisodeErrorSchema,
7825
+ GetParticipantEpisodeStatusErrorSchema,
7714
7826
  GetProblemReportAvailabilityErrorSchema,
7715
7827
  GetRecordingErrorSchema,
7716
7828
  GetSpaceErrorSchema,