@freedome/client 1.0.0 → 1.2.0

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.cjs CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ApiCaller: () => ApiCaller,
24
+ AssistantRepository: () => AssistantRepository,
24
25
  AudioReactiveRepository: () => AudioReactiveRepository,
25
26
  AudioRepository: () => AudioRepository,
26
27
  BackoffPolicy: () => BackoffPolicy,
@@ -34,11 +35,11 @@ __export(index_exports, {
34
35
  ContentRepository: () => ContentRepository,
35
36
  Credentials: () => Credentials,
36
37
  DEFAULT_OFFLINE_POLICY: () => DEFAULT_OFFLINE_POLICY,
37
- DomeTopics: () => import_protocol21.DomeTopics,
38
+ DomeTopics: () => import_protocol22.DomeTopics,
38
39
  Emitter: () => Emitter,
39
40
  EngineRepository: () => EngineRepository,
40
41
  EventHub: () => EventHub,
41
- EventKinds: () => import_protocol21.EventKinds,
42
+ EventKinds: () => import_protocol22.EventKinds,
42
43
  FREEDOME_CLIENT_VERSION: () => FREEDOME_CLIENT_VERSION,
43
44
  FetchTransport: () => FetchTransport,
44
45
  ForbiddenError: () => ForbiddenError,
@@ -62,7 +63,7 @@ __export(index_exports, {
62
63
  NetworkError: () => NetworkError,
63
64
  NotFoundError: () => NotFoundError,
64
65
  OfflineError: () => OfflineError,
65
- Operations: () => import_protocol21.Operations,
66
+ Operations: () => import_protocol22.Operations,
66
67
  OscRepository: () => OscRepository,
67
68
  PACKAGE_NAME: () => PACKAGE_NAME,
68
69
  PairingLink: () => PairingLink,
@@ -70,10 +71,12 @@ __export(index_exports, {
70
71
  PlayTargets: () => PlayTargets,
71
72
  PlaybackRepository: () => PlaybackRepository,
72
73
  PlayerHandle: () => PlayerHandle,
74
+ ProtocolVersions: () => import_protocol22.ProtocolVersions,
73
75
  QueuedForReplayError: () => QueuedForReplayError,
74
76
  RateLimitedError: () => RateLimitedError,
75
77
  RepositoryContext: () => RepositoryContext,
76
78
  RequestTimeoutError: () => RequestTimeoutError,
79
+ SemVer: () => import_protocol22.SemVer,
77
80
  ServerError: () => ServerError,
78
81
  Sha256: () => Sha256,
79
82
  ShowParts: () => ShowParts,
@@ -434,6 +437,9 @@ var ApiCaller = class _ApiCaller {
434
437
  "patchAudioZone",
435
438
  "startAudioSession",
436
439
  "stopAudioSession",
440
+ "pauseAudioSession",
441
+ "resumeAudioSession",
442
+ "startAudioDeviceSweep",
437
443
  "setSourcePosition"
438
444
  ]);
439
445
  async call(op, o = {}) {
@@ -667,7 +673,7 @@ var BackoffPolicy = class {
667
673
  };
668
674
 
669
675
  // src/client.ts
670
- var import_protocol19 = require("@freedome/protocol");
676
+ var import_protocol20 = require("@freedome/protocol");
671
677
 
672
678
  // src/context.ts
673
679
  var import_protocol3 = require("@freedome/protocol");
@@ -709,7 +715,7 @@ function nextValue(e, pred = () => true, timeoutMs = 5e3) {
709
715
 
710
716
  // src/context.ts
711
717
  var RepositoryContext = class {
712
- constructor(api, hub, cache, outbox, offline, isOffline, cacheScope, realtimeUp, positionHz, onEngineHealth, logger) {
718
+ constructor(api, hub, cache, outbox, offline, isOffline, cacheScope, realtimeUp, positionHz, onEngineHealth, logger, contractVersion = () => void 0) {
713
719
  this.api = api;
714
720
  this.hub = hub;
715
721
  this.cache = cache;
@@ -721,6 +727,7 @@ var RepositoryContext = class {
721
727
  this.positionHz = positionHz;
722
728
  this.onEngineHealth = onEngineHealth;
723
729
  this.logger = logger;
730
+ this.contractVersion = contractVersion;
724
731
  }
725
732
  api;
726
733
  hub;
@@ -733,7 +740,21 @@ var RepositoryContext = class {
733
740
  positionHz;
734
741
  onEngineHealth;
735
742
  logger;
743
+ contractVersion;
736
744
  outboxOutcomes = new Emitter();
745
+ /** Whether the server reports a contract of at least [version]. False while it is not known. */
746
+ contractAtLeast(version) {
747
+ const v = this.contractVersion();
748
+ return v !== void 0 && v.compareTo(version) >= 0;
749
+ }
750
+ /**
751
+ * Whether the server reports a contract older than [version]. False while it is not known: the call is then sent,
752
+ * and the server's answer decides.
753
+ */
754
+ contractBelow(version) {
755
+ const v = this.contractVersion();
756
+ return v !== void 0 && v.compareTo(version) < 0;
757
+ }
737
758
  log(level, message, error) {
738
759
  this.logger?.({ level, message, ...error === void 0 ? {} : { error } });
739
760
  }
@@ -1900,6 +1921,21 @@ var AudioRepository = class _AudioRepository {
1900
1921
  get v() {
1901
1922
  return { venueId: this.venueId };
1902
1923
  }
1924
+ /**
1925
+ * Whether the server has the audio additions of contract 1.1.0: [pauseSession], [resumeSession], [startDeviceSweep],
1926
+ * `roleZones` of [startSession] and the `multi` block of the generator. False against a 1.0 server and while its
1927
+ * contract version is not known.
1928
+ */
1929
+ get supportsAudioControl() {
1930
+ return this.c.contractAtLeast(import_protocol9.ProtocolVersions.audioControl);
1931
+ }
1932
+ /** @internal A 1.0 server would answer 404 or 422: says why instead. Sent as it is when the version is not known. */
1933
+ requireAudioControl(what) {
1934
+ if (this.c.contractBelow(import_protocol9.ProtocolVersions.audioControl))
1935
+ throw new UnsupportedCapabilityError(
1936
+ `${what} needs contract ${import_protocol9.ProtocolVersions.audioControl.toString()}; the server reports ${String(this.c.contractVersion())}`
1937
+ );
1938
+ }
1903
1939
  /** The same repository for another venue. */
1904
1940
  venue(id) {
1905
1941
  if (id === this.venueId) return this;
@@ -2081,6 +2117,20 @@ var AudioRepository = class _AudioRepository {
2081
2117
  body: patch
2082
2118
  });
2083
2119
  }
2120
+ /**
2121
+ * Resonance sweep of one resonator channel of [deviceId] (scope `audio:calibrate`): answers a calibration job of kind
2122
+ * `audio-device-sweep`. Follow it with `client.calibration.progress`; progress is elapsed time, not measurement, and
2123
+ * the job's `sweep` member holds `peaks`, and with `modelHz` also `partials` and `warnings`, once it has succeeded.
2124
+ * There is nothing to apply. 409 while a session uses the device, another sweep runs or the device is in emergency
2125
+ * stop; 422 without such a resonator channel. Needs [supportsAudioControl].
2126
+ */
2127
+ async startDeviceSweep(deviceId, sweep = {}) {
2128
+ this.requireAudioControl("startDeviceSweep");
2129
+ return this.c.api.json(import_protocol9.Operations.startAudioDeviceSweep, {
2130
+ params: { ...this.v, deviceId },
2131
+ body: sweep
2132
+ });
2133
+ }
2084
2134
  /** Ping / tone / self-test / strike of a device. */
2085
2135
  testDevice(deviceId, test = { kind: "ping" }) {
2086
2136
  return this.c.api.json(import_protocol9.Operations.testAudioDevice, {
@@ -2139,10 +2189,12 @@ var AudioRepository = class _AudioRepository {
2139
2189
  }
2140
2190
  // ---- sessions ----
2141
2191
  /** Runs an installed preset (live control). */
2142
- startSession(s) {
2192
+ async startSession(s) {
2193
+ if (s.roleZones !== void 0) this.requireAudioControl("roleZones");
2143
2194
  const body = { presetId: s.presetId };
2144
2195
  if (s.gainDb !== void 0) body.gainDb = s.gainDb;
2145
2196
  if (s.targets !== void 0) body.targets = s.targets;
2197
+ if (s.roleZones !== void 0) body.roleZones = s.roleZones;
2146
2198
  if (s.at !== void 0) body.at = s.at instanceof Date ? (0, import_protocol9.rfc3339Millis)(s.at) : s.at;
2147
2199
  if (s.loop !== void 0) body.loop = s.loop;
2148
2200
  return this.c.api.json(import_protocol9.Operations.startAudioSession, {
@@ -2176,6 +2228,29 @@ var AudioRepository = class _AudioRepository {
2176
2228
  }
2177
2229
  );
2178
2230
  }
2231
+ /**
2232
+ * Pauses a session (live control, scope `audio:control`): every engine holds its position, `audioSession.state`
2233
+ * follows. A paused session answers as it is; 409 for one that is starting or has ended. Needs
2234
+ * [supportsAudioControl].
2235
+ */
2236
+ async pauseSession(sessionId) {
2237
+ this.requireAudioControl("pauseSession");
2238
+ return this.c.api.json(import_protocol9.Operations.pauseAudioSession, {
2239
+ params: { ...this.v, sessionId },
2240
+ preferRealtime: true
2241
+ });
2242
+ }
2243
+ /**
2244
+ * Resumes a paused session from its position (live control, scope `audio:control`). A running session answers as it
2245
+ * is; 409 for one that is starting or has ended. Needs [supportsAudioControl].
2246
+ */
2247
+ async resumeSession(sessionId) {
2248
+ this.requireAudioControl("resumeSession");
2249
+ return this.c.api.json(import_protocol9.Operations.resumeAudioSession, {
2250
+ params: { ...this.v, sessionId },
2251
+ preferRealtime: true
2252
+ });
2253
+ }
2179
2254
  /** Stops a session (live control). */
2180
2255
  async stopSession(sessionId) {
2181
2256
  await this.c.api.call(import_protocol9.Operations.stopAudioSession, {
@@ -2254,8 +2329,12 @@ var GeneratorSession = class {
2254
2329
  this.push(s);
2255
2330
  return s;
2256
2331
  }
2257
- /** Starts the generator or replaces its settings (live control, scope `audio:control`). */
2332
+ /**
2333
+ * Starts the generator or replaces its settings (live control, scope `audio:control`). The `multi` block needs
2334
+ * [AudioRepository.supportsAudioControl].
2335
+ */
2258
2336
  async start(settings) {
2337
+ if (settings.multi !== void 0) this.r.requireAudioControl("generator multi");
2259
2338
  const s = await this.r.ctx.api.json(import_protocol9.Operations.setGenerator, {
2260
2339
  params: this.v,
2261
2340
  body: settings,
@@ -2264,6 +2343,17 @@ var GeneratorSession = class {
2264
2343
  this.push(s);
2265
2344
  return s;
2266
2345
  }
2346
+ /**
2347
+ * Plays a MULTI programme: `signal: multi` with the block [multi], the same object a phone gives to `setParams`
2348
+ * (contract 1.1.0, `docs/audio-control.md`).
2349
+ */
2350
+ startMulti(multi, o = {}) {
2351
+ return this.start({
2352
+ ...o,
2353
+ signal: "multi",
2354
+ multi: { ...multi, compatJava: multi.compatJava ?? false }
2355
+ });
2356
+ }
2267
2357
  /** Stops the generator (live control). */
2268
2358
  async stop() {
2269
2359
  await this.r.ctx.api.call(import_protocol9.Operations.stopGenerator, { params: this.v, preferRealtime: true });
@@ -2407,28 +2497,54 @@ var CalibrationRepository = class {
2407
2497
  }
2408
2498
  };
2409
2499
 
2410
- // src/repositories/clients.ts
2500
+ // src/repositories/assistant.ts
2411
2501
  var import_protocol11 = require("@freedome/protocol");
2502
+ var AssistantRepository = class {
2503
+ constructor(c) {
2504
+ this.c = c;
2505
+ }
2506
+ c;
2507
+ /** Newest first, with codes for a person. */
2508
+ confirmations() {
2509
+ return readAllPages(this.c.api, import_protocol11.Operations.listAssistantConfirmations);
2510
+ }
2511
+ refuse(confirmationId) {
2512
+ return this.c.api.json(import_protocol11.Operations.refuseAssistantConfirmation, { params: { confirmationId } });
2513
+ }
2514
+ link() {
2515
+ return this.c.api.json(import_protocol11.Operations.getAssistantLink);
2516
+ }
2517
+ /** Approves the code the assistant showed. Lasts 8 hours, with the scopes of the person signed in here. */
2518
+ approve(code) {
2519
+ return this.c.api.json(import_protocol11.Operations.approveAssistantLink, { body: { code } });
2520
+ }
2521
+ async end(sessionId) {
2522
+ await this.c.api.call(import_protocol11.Operations.endAssistantLink, { params: { sessionId } });
2523
+ }
2524
+ };
2525
+
2526
+ // src/repositories/clients.ts
2527
+ var import_protocol12 = require("@freedome/protocol");
2412
2528
  var ClientsRepository = class {
2413
2529
  constructor(c) {
2414
2530
  this.c = c;
2415
2531
  }
2416
2532
  c;
2417
2533
  register(registration) {
2418
- return this.c.api.json(import_protocol11.Operations.registerClient, { body: registration });
2534
+ return this.c.api.json(import_protocol12.Operations.registerClient, { body: registration });
2419
2535
  }
2420
2536
  list() {
2421
- return readAllPages(this.c.api, import_protocol11.Operations.listClients);
2537
+ return readAllPages(this.c.api, import_protocol12.Operations.listClients);
2422
2538
  }
2423
2539
  async telemetry(clientId, batch) {
2424
- await this.c.api.call(import_protocol11.Operations.postClientTelemetry, { params: { clientId }, body: batch });
2540
+ await this.c.api.call(import_protocol12.Operations.postClientTelemetry, { params: { clientId }, body: batch });
2425
2541
  }
2426
2542
  async unregister(clientId) {
2427
- await this.c.api.call(import_protocol11.Operations.unregisterClient, { params: { clientId } });
2543
+ await this.c.api.call(import_protocol12.Operations.unregisterClient, { params: { clientId } });
2428
2544
  }
2429
2545
  /** Commands the dome sends to this device (`clients/{id}/commands`). */
2430
2546
  commands(clientId, fn) {
2431
- return this.c.hub.on([import_protocol11.DomeTopics.clientCommands(clientId)], (e) => {
2547
+ return this.c.hub.on([import_protocol12.DomeTopics.clientCommands(clientId)], (e) => {
2432
2548
  const r = e.resource ?? {};
2433
2549
  if (typeof r.command === "string") fn(r.command, r.args);
2434
2550
  });
@@ -2436,10 +2552,10 @@ var ClientsRepository = class {
2436
2552
  };
2437
2553
 
2438
2554
  // src/repositories/content.ts
2439
- var import_protocol13 = require("@freedome/protocol");
2555
+ var import_protocol14 = require("@freedome/protocol");
2440
2556
 
2441
2557
  // src/repositories/upload.ts
2442
- var import_protocol12 = require("@freedome/protocol");
2558
+ var import_protocol13 = require("@freedome/protocol");
2443
2559
 
2444
2560
  // src/sha256.ts
2445
2561
  var K = new Uint32Array([
@@ -2721,7 +2837,7 @@ var UploadTask = class {
2721
2837
  const id = this.uploadIdValue;
2722
2838
  if (id) {
2723
2839
  try {
2724
- await this.c.api.call(import_protocol12.Operations.deleteUpload, {
2840
+ await this.c.api.call(import_protocol13.Operations.deleteUpload, {
2725
2841
  params: { uploadId: id },
2726
2842
  headers: { "tus-resumable": "1.0.0" }
2727
2843
  });
@@ -2782,7 +2898,7 @@ var UploadTask = class {
2782
2898
  }
2783
2899
  const api = this.c.api;
2784
2900
  if (!this.uploadIdValue) {
2785
- const res = await api.call(import_protocol12.Operations.createUpload, {
2901
+ const res = await api.call(import_protocol13.Operations.createUpload, {
2786
2902
  headers: {
2787
2903
  "tus-resumable": "1.0.0",
2788
2904
  "upload-length": String(total),
@@ -2810,7 +2926,7 @@ var UploadTask = class {
2810
2926
  const chunk = await this.source.read(this.offset, end);
2811
2927
  let res;
2812
2928
  try {
2813
- res = await api.call(import_protocol12.Operations.appendUpload, {
2929
+ res = await api.call(import_protocol13.Operations.appendUpload, {
2814
2930
  params: { uploadId: this.uploadIdValue },
2815
2931
  bytes: chunk,
2816
2932
  contentType: "application/offset+octet-stream",
@@ -2838,7 +2954,7 @@ var UploadTask = class {
2838
2954
  uploadId: this.uploadIdValue,
2839
2955
  name: this.o.asset?.name ?? this.source.name
2840
2956
  };
2841
- asset = await api.json(import_protocol12.Operations.createAsset, { body: req });
2957
+ asset = await api.json(import_protocol13.Operations.createAsset, { body: req });
2842
2958
  }
2843
2959
  this.set("done");
2844
2960
  if (!this.finished) {
@@ -2852,7 +2968,7 @@ var UploadTask = class {
2852
2968
  this.progress.close();
2853
2969
  }
2854
2970
  async headOffset() {
2855
- const res = await this.c.api.call(import_protocol12.Operations.getUploadOffset, {
2971
+ const res = await this.c.api.call(import_protocol13.Operations.getUploadOffset, {
2856
2972
  params: { uploadId: this.uploadIdValue },
2857
2973
  headers: { "tus-resumable": "1.0.0" }
2858
2974
  });
@@ -2886,7 +3002,7 @@ var ContentRepository = class {
2886
3002
  /** One page of assets (first pages cache-backed). */
2887
3003
  list(query = {}, cursor) {
2888
3004
  const q = { type: query.type, tag: query.tag, q: query.q, status: query.status };
2889
- const read = () => readPage(this.c.api, import_protocol13.Operations.listAssets, {
3005
+ const read = () => readPage(this.c.api, import_protocol14.Operations.listAssets, {
2890
3006
  query: q,
2891
3007
  cursor,
2892
3008
  limit: query.limit
@@ -2903,7 +3019,26 @@ var ContentRepository = class {
2903
3019
  );
2904
3020
  }
2905
3021
  get(assetId) {
2906
- return this.c.api.json(import_protocol13.Operations.getAsset, { params: { assetId } });
3022
+ return this.c.api.json(import_protocol14.Operations.getAsset, { params: { assetId } });
3023
+ }
3024
+ /**
3025
+ * The first asset whose `name` equals `name` exactly (case-sensitive), or `null` when there is none.
3026
+ *
3027
+ * Asks the server with `q` = `name` (a case-insensitive substring match), keeps exact matches only and reads more
3028
+ * pages while needed; `type` / `tag` / `status` narrow it as in `list`. Several assets with the name: the first in
3029
+ * the server's order wins. Offline, the first page comes from the cache as in `list`. Added in 1.2.0.
3030
+ */
3031
+ async findAssetByName(name, filter = {}) {
3032
+ if (!name) throw new RangeError("findAssetByName: empty name");
3033
+ const query = { ...filter, q: name, limit: 100 };
3034
+ let cursor;
3035
+ do {
3036
+ const page = await this.list(query, cursor);
3037
+ const hit = page.items.find((a) => a.name === name);
3038
+ if (hit) return hit;
3039
+ cursor = page.nextCursor ?? void 0;
3040
+ } while (cursor);
3041
+ return null;
2907
3042
  }
2908
3043
  /** Starts a resumable upload creating an asset (await `task.done`). */
2909
3044
  upload(source, o = {}) {
@@ -2942,7 +3077,7 @@ var ContentRepository = class {
2942
3077
  /** Uploads [source] and runs an import job; returns the finished job (rejects when it failed). */
2943
3078
  async importFile(source, format, o = {}) {
2944
3079
  const up = await this.uploadFor("import", source).done;
2945
- const job = await this.c.api.json(import_protocol13.Operations.startImport, {
3080
+ const job = await this.c.api.json(import_protocol14.Operations.startImport, {
2946
3081
  body: {
2947
3082
  uploadId: up.uploadId,
2948
3083
  format,
@@ -2978,13 +3113,13 @@ var ContentRepository = class {
2978
3113
  if (Date.now() > deadline)
2979
3114
  throw new RequestTimeoutError(`job ${j.id} not finished in time`, o.timeoutMs);
2980
3115
  await new Promise((r) => setTimeout(r, o.pollMs ?? 500));
2981
- j = await this.c.api.json(import_protocol13.Operations.getJob, { params: { jobId: j.id } });
3116
+ j = await this.c.api.json(import_protocol14.Operations.getJob, { params: { jobId: j.id } });
2982
3117
  }
2983
3118
  }
2984
3119
  /** Merge-patches an asset (ETag read first when not given). */
2985
3120
  async patch(assetId, patch, ifMatch) {
2986
3121
  const etag = ifMatch ?? `"r${(await this.get(assetId)).revision}"`;
2987
- return this.c.api.json(import_protocol13.Operations.patchAsset, {
3122
+ return this.c.api.json(import_protocol14.Operations.patchAsset, {
2988
3123
  params: { assetId },
2989
3124
  body: patch,
2990
3125
  headers: { "if-match": etag }
@@ -2993,23 +3128,23 @@ var ContentRepository = class {
2993
3128
  /** Deletes an asset (409 while referenced unless [force]). */
2994
3129
  async delete(assetId, o = {}) {
2995
3130
  const etag = o.ifMatch ?? `"r${(await this.get(assetId)).revision}"`;
2996
- await this.c.api.call(import_protocol13.Operations.deleteAsset, {
3131
+ await this.c.api.call(import_protocol14.Operations.deleteAsset, {
2997
3132
  params: { assetId },
2998
3133
  query: o.force ? { force: "true" } : {},
2999
3134
  headers: { "if-match": etag }
3000
3135
  });
3001
3136
  }
3002
3137
  async thumbnail(assetId, size) {
3003
- return (await this.c.api.call(import_protocol13.Operations.getAssetThumbnail, {
3138
+ return (await this.c.api.call(import_protocol14.Operations.getAssetThumbnail, {
3004
3139
  params: { assetId },
3005
3140
  query: { size: size?.toString() }
3006
3141
  })).body;
3007
3142
  }
3008
3143
  async download(assetId) {
3009
- return (await this.c.api.call(import_protocol13.Operations.downloadAsset, { params: { assetId }, timeoutMs: 18e5 })).body;
3144
+ return (await this.c.api.call(import_protocol14.Operations.downloadAsset, { params: { assetId }, timeoutMs: 18e5 })).body;
3010
3145
  }
3011
3146
  storage() {
3012
- return this.c.api.json(import_protocol13.Operations.getStorageStats);
3147
+ return this.c.api.json(import_protocol14.Operations.getStorageStats);
3013
3148
  }
3014
3149
  /** Changes of the content store. */
3015
3150
  changes(fn) {
@@ -3024,59 +3159,59 @@ var ContentRepository = class {
3024
3159
  });
3025
3160
  }
3026
3161
  listShows(o = {}) {
3027
- return readPage(this.c.api, import_protocol13.Operations.listShows, {
3162
+ return readPage(this.c.api, import_protocol14.Operations.listShows, {
3028
3163
  query: { q: o.q },
3029
3164
  cursor: o.cursor,
3030
3165
  limit: o.limit
3031
3166
  });
3032
3167
  }
3033
3168
  async getShow(showId) {
3034
- const res = await this.c.api.call(import_protocol13.Operations.getShow, { params: { showId } });
3169
+ const res = await this.c.api.call(import_protocol14.Operations.getShow, { params: { showId } });
3035
3170
  return {
3036
- value: ApiCaller.decodeBody(import_protocol13.Operations.getShow, res),
3171
+ value: ApiCaller.decodeBody(import_protocol14.Operations.getShow, res),
3037
3172
  etag: res.headers.etag
3038
3173
  };
3039
3174
  }
3040
3175
  async createShow(body) {
3041
- const res = await this.c.api.call(import_protocol13.Operations.createShow, { body });
3176
+ const res = await this.c.api.call(import_protocol14.Operations.createShow, { body });
3042
3177
  return {
3043
- value: ApiCaller.decodeBody(import_protocol13.Operations.createShow, res),
3178
+ value: ApiCaller.decodeBody(import_protocol14.Operations.createShow, res),
3044
3179
  etag: res.headers.etag
3045
3180
  };
3046
3181
  }
3047
3182
  /** Replaces a show (`ifMatch`; without: create with If-None-Match: *). Queued in the outbox while offline. */
3048
3183
  async saveShow(showId, body, ifMatch) {
3049
- const res = await this.c.idempotentWrite(import_protocol13.Operations.putShow, {
3184
+ const res = await this.c.idempotentWrite(import_protocol14.Operations.putShow, {
3050
3185
  params: { showId },
3051
3186
  body,
3052
3187
  headers: ifMatch ? { "if-match": ifMatch } : { "if-none-match": "*" }
3053
3188
  });
3054
3189
  return {
3055
- value: ApiCaller.decodeBody(import_protocol13.Operations.putShow, res),
3190
+ value: ApiCaller.decodeBody(import_protocol14.Operations.putShow, res),
3056
3191
  etag: res.headers.etag
3057
3192
  };
3058
3193
  }
3059
3194
  async patchShow(showId, patch, ifMatch) {
3060
3195
  const etag = ifMatch ?? (await this.getShow(showId)).etag;
3061
- const res = await this.c.api.call(import_protocol13.Operations.patchShow, {
3196
+ const res = await this.c.api.call(import_protocol14.Operations.patchShow, {
3062
3197
  params: { showId },
3063
3198
  body: patch,
3064
3199
  headers: { "if-match": etag }
3065
3200
  });
3066
3201
  return {
3067
- value: ApiCaller.decodeBody(import_protocol13.Operations.patchShow, res),
3202
+ value: ApiCaller.decodeBody(import_protocol14.Operations.patchShow, res),
3068
3203
  etag: res.headers.etag
3069
3204
  };
3070
3205
  }
3071
3206
  async deleteShow(showId, ifMatch) {
3072
- await this.c.api.call(import_protocol13.Operations.deleteShow, {
3207
+ await this.c.api.call(import_protocol14.Operations.deleteShow, {
3073
3208
  params: { showId },
3074
3209
  headers: { "if-match": ifMatch }
3075
3210
  });
3076
3211
  }
3077
3212
  /** Exports a show as `.dome` bytes. */
3078
3213
  async exportShow(showId, embedAssets = false) {
3079
- return (await this.c.api.call(import_protocol13.Operations.exportShow, {
3214
+ return (await this.c.api.call(import_protocol14.Operations.exportShow, {
3080
3215
  params: { showId },
3081
3216
  query: embedAssets ? { embedAssets: "true" } : {},
3082
3217
  timeoutMs: 18e5
@@ -3084,7 +3219,7 @@ var ContentRepository = class {
3084
3219
  }
3085
3220
  /** tus capabilities. */
3086
3221
  async uploadCapabilities() {
3087
- const res = await this.c.api.call(import_protocol13.Operations.getUploadCapabilities);
3222
+ const res = await this.c.api.call(import_protocol14.Operations.getUploadCapabilities);
3088
3223
  const list = (h) => (res.headers[h] ?? "").split(",").map((x) => x.trim()).filter(Boolean);
3089
3224
  const max = Number.parseInt(res.headers["tus-max-size"] ?? "", 10);
3090
3225
  return {
@@ -3095,11 +3230,11 @@ var ContentRepository = class {
3095
3230
  };
3096
3231
  }
3097
3232
  uploadStatus(uploadId) {
3098
- return this.c.api.json(import_protocol13.Operations.getUpload, { params: { uploadId } });
3233
+ return this.c.api.json(import_protocol14.Operations.getUpload, { params: { uploadId } });
3099
3234
  }
3100
3235
  /** Watch hook used by apps showing one asset. */
3101
3236
  watchAsset(assetId, fn) {
3102
- return this.c.watchResource(import_protocol13.DomeTopics.asset(assetId), () => this.get(assetId), { next: fn });
3237
+ return this.c.watchResource(import_protocol14.DomeTopics.asset(assetId), () => this.get(assetId), { next: fn });
3103
3238
  }
3104
3239
  };
3105
3240
  var ShowParts = class {
@@ -3108,29 +3243,29 @@ var ShowParts = class {
3108
3243
  }
3109
3244
  c;
3110
3245
  async etag(showId, ifMatch) {
3111
- return ifMatch ?? (await this.c.api.call(import_protocol13.Operations.getShow, { params: { showId } })).headers.etag;
3246
+ return ifMatch ?? (await this.c.api.call(import_protocol14.Operations.getShow, { params: { showId } })).headers.etag;
3112
3247
  }
3113
3248
  get(part, showId, itemId) {
3114
- return this.c.api.json(import_protocol13.Operations[`get${part}`], { params: { showId, itemId } });
3249
+ return this.c.api.json(import_protocol14.Operations[`get${part}`], { params: { showId, itemId } });
3115
3250
  }
3116
3251
  async put(part, showId, item, ifMatch) {
3117
- return this.c.api.json(import_protocol13.Operations[`put${part}`], {
3252
+ return this.c.api.json(import_protocol14.Operations[`put${part}`], {
3118
3253
  params: { showId, itemId: item.id },
3119
3254
  body: item,
3120
3255
  headers: { "if-match": await this.etag(showId, ifMatch) }
3121
3256
  });
3122
3257
  }
3123
3258
  async delete(part, showId, itemId, ifMatch) {
3124
- await this.c.api.call(import_protocol13.Operations[`delete${part}`], {
3259
+ await this.c.api.call(import_protocol14.Operations[`delete${part}`], {
3125
3260
  params: { showId, itemId },
3126
3261
  headers: { "if-match": await this.etag(showId, ifMatch) }
3127
3262
  });
3128
3263
  }
3129
3264
  matrix(showId) {
3130
- return this.c.api.json(import_protocol13.Operations.getMatrix, { params: { showId } });
3265
+ return this.c.api.json(import_protocol14.Operations.getMatrix, { params: { showId } });
3131
3266
  }
3132
3267
  async putMatrix(showId, matrix, ifMatch) {
3133
- return this.c.api.json(import_protocol13.Operations.putMatrix, {
3268
+ return this.c.api.json(import_protocol14.Operations.putMatrix, {
3134
3269
  params: { showId },
3135
3270
  body: matrix,
3136
3271
  headers: { "if-match": await this.etag(showId, ifMatch) }
@@ -3139,7 +3274,7 @@ var ShowParts = class {
3139
3274
  };
3140
3275
 
3141
3276
  // src/repositories/engine.ts
3142
- var import_protocol14 = require("@freedome/protocol");
3277
+ var import_protocol15 = require("@freedome/protocol");
3143
3278
  var EngineRepository = class {
3144
3279
  constructor(c) {
3145
3280
  this.c = c;
@@ -3147,23 +3282,23 @@ var EngineRepository = class {
3147
3282
  c;
3148
3283
  /** Every engine (visual, audio, …; `name@node` on multi-node installations). */
3149
3284
  engines() {
3150
- return readAllPages(this.c.api, import_protocol14.Operations.listEngines);
3285
+ return readAllPages(this.c.api, import_protocol15.Operations.listEngines);
3151
3286
  }
3152
3287
  /** Displays of a venue. */
3153
3288
  outputs(venueId = "default") {
3154
- return readAllPages(this.c.api, import_protocol14.Operations.listDisplays, {
3289
+ return readAllPages(this.c.api, import_protocol15.Operations.listDisplays, {
3155
3290
  params: { venueId }
3156
3291
  });
3157
3292
  }
3158
3293
  /** One display. */
3159
3294
  display(displayId, venueId = "default") {
3160
- return this.c.api.json(import_protocol14.Operations.getDisplay, {
3295
+ return this.c.api.json(import_protocol15.Operations.getDisplay, {
3161
3296
  params: { venueId, displayId }
3162
3297
  });
3163
3298
  }
3164
3299
  /** Shows a test pattern on a display. */
3165
3300
  showTestPattern(displayId, pattern, venueId = "default") {
3166
- return this.c.api.json(import_protocol14.Operations.setTestPattern, {
3301
+ return this.c.api.json(import_protocol15.Operations.setTestPattern, {
3167
3302
  params: { venueId, displayId },
3168
3303
  body: pattern,
3169
3304
  preferRealtime: true
@@ -3179,28 +3314,28 @@ var EngineRepository = class {
3179
3314
  }
3180
3315
  /** Flashes the id overlay. */
3181
3316
  async identify(displayId, durationMs, venueId = "default") {
3182
- await this.c.api.call(import_protocol14.Operations.identifyDisplay, {
3317
+ await this.c.api.call(import_protocol15.Operations.identifyDisplay, {
3183
3318
  params: { venueId, displayId },
3184
3319
  body: durationMs === void 0 ? {} : { durationS: durationMs / 1e3 }
3185
3320
  });
3186
3321
  }
3187
3322
  /** Power / shutter (what `state.capabilities` lists). */
3188
3323
  setPower(displayId, request, venueId = "default") {
3189
- return this.c.api.json(import_protocol14.Operations.setDisplayPower, {
3324
+ return this.c.api.json(import_protocol15.Operations.setDisplayPower, {
3190
3325
  params: { venueId, displayId },
3191
3326
  body: request
3192
3327
  });
3193
3328
  }
3194
3329
  /** Status of engine [name]. */
3195
3330
  async engineStatus(name = "visual") {
3196
- const s = await this.c.api.json(import_protocol14.Operations.getEngine, { params: { name } });
3331
+ const s = await this.c.api.json(import_protocol15.Operations.getEngine, { params: { name } });
3197
3332
  if (name === "visual") this.c.onEngineHealth?.(String(s.status));
3198
3333
  return s;
3199
3334
  }
3200
3335
  /** Watches an engine (feeds the `degraded` state for the visual engine). */
3201
3336
  status(obs, name = "visual", intervalMs = 2e3) {
3202
3337
  return this.c.watchResource(
3203
- import_protocol14.DomeTopics.engine(name),
3338
+ import_protocol15.DomeTopics.engine(name),
3204
3339
  () => this.engineStatus(name),
3205
3340
  {
3206
3341
  next: (s) => {
@@ -3210,13 +3345,13 @@ var EngineRepository = class {
3210
3345
  },
3211
3346
  ...obs.error ? { error: obs.error } : {}
3212
3347
  },
3213
- { intervalMs, kinds: /* @__PURE__ */ new Set([import_protocol14.EventKinds.engineStatus]) }
3348
+ { intervalMs, kinds: /* @__PURE__ */ new Set([import_protocol15.EventKinds.engineStatus]) }
3214
3349
  );
3215
3350
  }
3216
3351
  };
3217
3352
 
3218
3353
  // src/repositories/gateways.ts
3219
- var import_protocol15 = require("@freedome/protocol");
3354
+ var import_protocol16 = require("@freedome/protocol");
3220
3355
  var GatewaysRepository = class {
3221
3356
  constructor(c) {
3222
3357
  this.c = c;
@@ -3224,13 +3359,13 @@ var GatewaysRepository = class {
3224
3359
  c;
3225
3360
  /** Every gateway. */
3226
3361
  list() {
3227
- return readAllPages(this.c.api, import_protocol15.Operations.listGateways, {});
3362
+ return readAllPages(this.c.api, import_protocol16.Operations.listGateways, {});
3228
3363
  }
3229
3364
  /** One gateway with its ETag. */
3230
3365
  async get(gatewayId) {
3231
- const res = await this.c.api.call(import_protocol15.Operations.getGateway, { params: { gatewayId } });
3366
+ const res = await this.c.api.call(import_protocol16.Operations.getGateway, { params: { gatewayId } });
3232
3367
  return {
3233
- value: ApiCaller.decodeBody(import_protocol15.Operations.getGateway, res),
3368
+ value: ApiCaller.decodeBody(import_protocol16.Operations.getGateway, res),
3234
3369
  etag: res.headers.etag
3235
3370
  };
3236
3371
  }
@@ -3240,24 +3375,24 @@ var GatewaysRepository = class {
3240
3375
  */
3241
3376
  async patch(gatewayId, patch, o = {}) {
3242
3377
  const etag = o.ifMatch ?? (await this.get(gatewayId)).etag;
3243
- const res = await this.c.api.call(import_protocol15.Operations.patchGateway, {
3378
+ const res = await this.c.api.call(import_protocol16.Operations.patchGateway, {
3244
3379
  params: { gatewayId },
3245
3380
  body: patch,
3246
3381
  headers: { "if-match": etag }
3247
3382
  });
3248
3383
  return {
3249
- value: ApiCaller.decodeBody(import_protocol15.Operations.patchGateway, res),
3384
+ value: ApiCaller.decodeBody(import_protocol16.Operations.patchGateway, res),
3250
3385
  etag: res.headers.etag
3251
3386
  };
3252
3387
  }
3253
3388
  /** Runs the gateway's connectivity test. */
3254
3389
  test(gatewayId) {
3255
- return this.c.api.json(import_protocol15.Operations.testGateway, { params: { gatewayId } });
3390
+ return this.c.api.json(import_protocol16.Operations.testGateway, { params: { gatewayId } });
3256
3391
  }
3257
3392
  };
3258
3393
 
3259
3394
  // src/repositories/osc.ts
3260
- var import_protocol16 = require("@freedome/protocol");
3395
+ var import_protocol17 = require("@freedome/protocol");
3261
3396
  function oscArg(a) {
3262
3397
  if (a !== null && typeof a === "object" && "type" in a && !(a instanceof Uint8Array) && !(a instanceof Date))
3263
3398
  return a;
@@ -3284,12 +3419,12 @@ var OscRepository = class {
3284
3419
  async send(address, args, target) {
3285
3420
  if (!address.startsWith("/")) throw new TypeError("OSC address must start with /");
3286
3421
  const body = { target, address, args: args.map(oscArg) };
3287
- await this.c.api.call(import_protocol16.Operations.sendOsc, { body, preferRealtime: true });
3422
+ await this.c.api.call(import_protocol17.Operations.sendOsc, { body, preferRealtime: true });
3288
3423
  }
3289
3424
  /** OSC traffic of gateways (`gateway.message` events). */
3290
3425
  messages(fn, gatewayId = "+") {
3291
3426
  return this.c.hub.on(
3292
- [gatewayId === "+" ? "gateways/+" : import_protocol16.DomeTopics.gateway(gatewayId)],
3427
+ [gatewayId === "+" ? "gateways/+" : import_protocol17.DomeTopics.gateway(gatewayId)],
3293
3428
  (e) => {
3294
3429
  const r = e.resource ?? e.data;
3295
3430
  if (typeof r?.address === "string")
@@ -3300,7 +3435,7 @@ var OscRepository = class {
3300
3435
  };
3301
3436
 
3302
3437
  // src/repositories/playback.ts
3303
- var import_protocol17 = require("@freedome/protocol");
3438
+ var import_protocol18 = require("@freedome/protocol");
3304
3439
  var PlayTargets = {
3305
3440
  show: (showId, o = {}) => ({
3306
3441
  kind: "show",
@@ -3388,13 +3523,13 @@ var PlayerHandle = class {
3388
3523
  watch(fn) {
3389
3524
  const off = this.states.on(fn);
3390
3525
  if (this.listeners++ === 0) {
3391
- const topic = import_protocol17.DomeTopics.player(this.playerId, this.venueId);
3526
+ const topic = import_protocol18.DomeTopics.player(this.playerId, this.venueId);
3392
3527
  this.offEvents = this.c.hub.on([topic], (e) => {
3393
- if (e.kind === import_protocol17.EventKinds.playerState || e.kind === import_protocol17.EventKinds.playerError) {
3528
+ if (e.kind === import_protocol18.EventKinds.playerState || e.kind === import_protocol18.EventKinds.playerError) {
3394
3529
  if (e.resource && typeof e.resource === "object")
3395
3530
  this.push({ state: e.resource });
3396
- } else if (e.kind === import_protocol17.EventKinds.playerPosition && e.patch && this.last) {
3397
- this.push({ state: (0, import_protocol17.jsonMergePatch)(this.last.state, e.patch) });
3531
+ } else if (e.kind === import_protocol18.EventKinds.playerPosition && e.patch && this.last) {
3532
+ this.push({ state: (0, import_protocol18.jsonMergePatch)(this.last.state, e.patch) });
3398
3533
  }
3399
3534
  });
3400
3535
  this.offSnapshot = this.c.hub.onSnapshot(topic, async () => {
@@ -3422,7 +3557,7 @@ var PlayerHandle = class {
3422
3557
  const snap = await this.c.cachedRead(
3423
3558
  `players/${this.venueId}/${this.playerId}`,
3424
3559
  async () => {
3425
- const s = await this.c.api.json(import_protocol17.Operations.getPlayer, { params: this.params });
3560
+ const s = await this.c.api.json(import_protocol18.Operations.getPlayer, { params: this.params });
3426
3561
  return [{ state: s }, s];
3427
3562
  },
3428
3563
  (json, asOf) => ({ state: json, stale: true, asOf })
@@ -3454,7 +3589,7 @@ var PlayerHandle = class {
3454
3589
  /** Plays [target] (optionally from [positionMs], at server time [at] for multi-node sync). */
3455
3590
  async play(target, o = {}) {
3456
3591
  if (target.kind === "app") {
3457
- await this.c.api.call(import_protocol17.Operations.publishAppPayload, {
3592
+ await this.c.api.call(import_protocol18.Operations.publishAppPayload, {
3458
3593
  params: { app: target.app },
3459
3594
  body: target.payload,
3460
3595
  preferRealtime: true
@@ -3472,40 +3607,40 @@ var PlayerHandle = class {
3472
3607
  if (target.itemIndex !== void 0) req.itemIndex = target.itemIndex;
3473
3608
  } else if (target.kind === "asset") req.assetId = target.assetId;
3474
3609
  if (o.positionMs !== void 0) req.position = o.positionMs / 1e3;
3475
- if (o.at) req.at = (0, import_protocol17.rfc3339Millis)(o.at);
3476
- return this.command(import_protocol17.Operations.play, req);
3610
+ if (o.at) req.at = (0, import_protocol18.rfc3339Millis)(o.at);
3611
+ return this.command(import_protocol18.Operations.play, req);
3477
3612
  }
3478
3613
  pause() {
3479
- return this.command(import_protocol17.Operations.pause);
3614
+ return this.command(import_protocol18.Operations.pause);
3480
3615
  }
3481
3616
  resume() {
3482
- return this.command(import_protocol17.Operations.resume);
3617
+ return this.command(import_protocol18.Operations.resume);
3483
3618
  }
3484
3619
  stop() {
3485
- return this.command(import_protocol17.Operations.stop);
3620
+ return this.command(import_protocol18.Operations.stop);
3486
3621
  }
3487
3622
  next() {
3488
- return this.command(import_protocol17.Operations.next);
3623
+ return this.command(import_protocol18.Operations.next);
3489
3624
  }
3490
3625
  previous() {
3491
- return this.command(import_protocol17.Operations.previous);
3626
+ return this.command(import_protocol18.Operations.previous);
3492
3627
  }
3493
3628
  /** Seeks (coalesced while scrubbing). */
3494
3629
  seek(positionMs) {
3495
3630
  return this.fader(
3496
3631
  "seek",
3497
3632
  { position: positionMs / 1e3 },
3498
- (b) => this.command(import_protocol17.Operations.seek, b)
3633
+ (b) => this.command(import_protocol18.Operations.seek, b)
3499
3634
  );
3500
3635
  }
3501
3636
  seekToMarker(marker) {
3502
- return this.command(import_protocol17.Operations.seek, { marker });
3637
+ return this.command(import_protocol18.Operations.seek, { marker });
3503
3638
  }
3504
3639
  patch(body) {
3505
3640
  return this.fader(
3506
3641
  `patch:${Object.keys(body).join(",")}`,
3507
3642
  body,
3508
- (b) => this.command(import_protocol17.Operations.patchPlayer, b)
3643
+ (b) => this.command(import_protocol18.Operations.patchPlayer, b)
3509
3644
  );
3510
3645
  }
3511
3646
  /** Player volume 0..1 (fader). */
@@ -3555,7 +3690,7 @@ var PlaybackRepository = class {
3555
3690
  return this.main.watch(fn);
3556
3691
  }
3557
3692
  list(venueId = "default") {
3558
- return readAllPages(this.c.api, import_protocol17.Operations.listPlayers, { params: { venueId } });
3693
+ return readAllPages(this.c.api, import_protocol18.Operations.listPlayers, { params: { venueId } });
3559
3694
  }
3560
3695
  play(target, o = {}) {
3561
3696
  return this.main.play(target, o);
@@ -3580,7 +3715,7 @@ var PlaybackRepository = class {
3580
3715
  }
3581
3716
  /** Fires cue [cueId] of the active show (or of [showId]). */
3582
3717
  async cue(cueId, o = {}) {
3583
- await this.c.api.call(import_protocol17.Operations.fireCue, {
3718
+ await this.c.api.call(import_protocol18.Operations.fireCue, {
3584
3719
  params: { venueId: o.venueId ?? "default", cueId },
3585
3720
  body: o.showId ? { showId: o.showId } : {},
3586
3721
  preferRealtime: true
@@ -3588,21 +3723,21 @@ var PlaybackRepository = class {
3588
3723
  }
3589
3724
  /** Loads a show onto the venue. */
3590
3725
  async setActiveShow(showId, o = {}) {
3591
- await this.c.api.call(import_protocol17.Operations.setActiveShow, {
3726
+ await this.c.api.call(import_protocol18.Operations.setActiveShow, {
3592
3727
  params: { venueId: o.venueId ?? "default" },
3593
3728
  body: { showId, autoplay: o.autoplay ?? false }
3594
3729
  });
3595
3730
  }
3596
3731
  activeShow(venueId = "default") {
3597
- return this.c.api.json(import_protocol17.Operations.getActiveShow, { params: { venueId } });
3732
+ return this.c.api.json(import_protocol18.Operations.getActiveShow, { params: { venueId } });
3598
3733
  }
3599
3734
  parameters(venueId = "default") {
3600
- return readAllPages(this.c.api, import_protocol17.Operations.listParameters, {
3735
+ return readAllPages(this.c.api, import_protocol18.Operations.listParameters, {
3601
3736
  params: { venueId }
3602
3737
  });
3603
3738
  }
3604
3739
  parameter(path, venueId = "default") {
3605
- return this.c.api.json(import_protocol17.Operations.getParameter, { params: { venueId, path } });
3740
+ return this.c.api.json(import_protocol18.Operations.getParameter, { params: { venueId, path } });
3606
3741
  }
3607
3742
  /** Sets a parameter (fader; coalesced). */
3608
3743
  async setParameter(path, value, venueId = "default") {
@@ -3610,7 +3745,7 @@ var PlaybackRepository = class {
3610
3745
  let f = this.outputFaders.get(k);
3611
3746
  if (!f) {
3612
3747
  f = new Fader(async (b) => {
3613
- await this.c.api.call(import_protocol17.Operations.setParameter, {
3748
+ await this.c.api.call(import_protocol18.Operations.setParameter, {
3614
3749
  params: { venueId, path },
3615
3750
  body: b,
3616
3751
  preferRealtime: true
@@ -3623,14 +3758,14 @@ var PlaybackRepository = class {
3623
3758
  }
3624
3759
  /** Removes every payload an app published. */
3625
3760
  async clearAppPayloads(app) {
3626
- await this.c.api.call(import_protocol17.Operations.clearAppPayloads, { params: { app }, preferRealtime: true });
3761
+ await this.c.api.call(import_protocol18.Operations.clearAppPayloads, { params: { app }, preferRealtime: true });
3627
3762
  }
3628
3763
  /** Master output of a venue. */
3629
3764
  readOutput(venueId = "default") {
3630
3765
  return this.c.cachedRead(
3631
3766
  `output/${venueId}`,
3632
3767
  async () => {
3633
- const o = await this.c.api.json(import_protocol17.Operations.getOutput, { params: { venueId } });
3768
+ const o = await this.c.api.json(import_protocol18.Operations.getOutput, { params: { venueId } });
3634
3769
  return [o, o];
3635
3770
  },
3636
3771
  (json) => json
@@ -3639,9 +3774,9 @@ var PlaybackRepository = class {
3639
3774
  /** Follows the master output (`output.changed` events / patches). */
3640
3775
  watchOutput(fn, venueId = "default") {
3641
3776
  let last;
3642
- const off = this.c.hub.on([import_protocol17.DomeTopics.output(venueId)], (e) => {
3777
+ const off = this.c.hub.on([import_protocol18.DomeTopics.output(venueId)], (e) => {
3643
3778
  if (e.resource && typeof e.resource === "object") last = e.resource;
3644
- else if (e.patch && last) last = (0, import_protocol17.jsonMergePatch)(last, e.patch);
3779
+ else if (e.patch && last) last = (0, import_protocol18.jsonMergePatch)(last, e.patch);
3645
3780
  else return;
3646
3781
  fn(last);
3647
3782
  });
@@ -3659,7 +3794,7 @@ var PlaybackRepository = class {
3659
3794
  let f = this.outputFaders.get(k);
3660
3795
  if (!f) {
3661
3796
  f = new Fader(
3662
- (b) => this.c.api.json(import_protocol17.Operations.patchOutput, {
3797
+ (b) => this.c.api.json(import_protocol18.Operations.patchOutput, {
3663
3798
  params: { venueId },
3664
3799
  body: b,
3665
3800
  preferRealtime: true
@@ -3690,7 +3825,7 @@ var PlaybackRepository = class {
3690
3825
  };
3691
3826
 
3692
3827
  // src/repositories/venues.ts
3693
- var import_protocol18 = require("@freedome/protocol");
3828
+ var import_protocol19 = require("@freedome/protocol");
3694
3829
  var CALIBRATION_FILE_TYPES = {
3695
3830
  warp: "application/vnd.nativemind.freedome.fdmesh",
3696
3831
  blend: "image/png",
@@ -3709,7 +3844,7 @@ var VenuesRepository = class {
3709
3844
  return this.c.cachedRead(
3710
3845
  "venues",
3711
3846
  async () => {
3712
- const l = await readAllPages(this.api, import_protocol18.Operations.listVenues);
3847
+ const l = await readAllPages(this.api, import_protocol19.Operations.listVenues);
3713
3848
  return [{ value: l, etag: void 0 }, l];
3714
3849
  },
3715
3850
  (json, asOf) => ({ value: json, etag: void 0, stale: true, asOf })
@@ -3717,8 +3852,8 @@ var VenuesRepository = class {
3717
3852
  }
3718
3853
  /** One venue with its ETag (`default` = the active venue). */
3719
3854
  async get(venueId = "default") {
3720
- const res = await this.api.call(import_protocol18.Operations.getVenue, { params: { venueId } });
3721
- return { value: ApiCaller.decodeBody(import_protocol18.Operations.getVenue, res), etag: res.headers.etag };
3855
+ const res = await this.api.call(import_protocol19.Operations.getVenue, { params: { venueId } });
3856
+ return { value: ApiCaller.decodeBody(import_protocol19.Operations.getVenue, res), etag: res.headers.etag };
3722
3857
  }
3723
3858
  /** The venue the server runs now. */
3724
3859
  async current() {
@@ -3726,22 +3861,22 @@ var VenuesRepository = class {
3726
3861
  }
3727
3862
  /** Creates a venue (`POST /venues`; id = `meta.id`). */
3728
3863
  async create(body) {
3729
- const res = await this.api.call(import_protocol18.Operations.createVenue, { body });
3864
+ const res = await this.api.call(import_protocol19.Operations.createVenue, { body });
3730
3865
  return {
3731
- value: ApiCaller.decodeBody(import_protocol18.Operations.createVenue, res),
3866
+ value: ApiCaller.decodeBody(import_protocol19.Operations.createVenue, res),
3732
3867
  etag: res.headers.etag
3733
3868
  };
3734
3869
  }
3735
3870
  /** Replaces a venue (`ifMatch` = ETag; without it: create with If-None-Match: *). 409 / 412 → ConflictError with `latest`. */
3736
3871
  async save(venueId, body, ifMatch) {
3737
3872
  try {
3738
- const res = await this.api.call(import_protocol18.Operations.putVenue, {
3873
+ const res = await this.api.call(import_protocol19.Operations.putVenue, {
3739
3874
  params: { venueId },
3740
3875
  body,
3741
3876
  headers: ifMatch ? { "if-match": ifMatch } : { "if-none-match": "*" }
3742
3877
  });
3743
3878
  return {
3744
- value: ApiCaller.decodeBody(import_protocol18.Operations.putVenue, res),
3879
+ value: ApiCaller.decodeBody(import_protocol19.Operations.putVenue, res),
3745
3880
  etag: res.headers.etag
3746
3881
  };
3747
3882
  } catch (e) {
@@ -3762,31 +3897,31 @@ var VenuesRepository = class {
3762
3897
  /** Merge-patches a venue (reads the ETag when not given). */
3763
3898
  async patch(venueId, patch, ifMatch) {
3764
3899
  const etag = ifMatch ?? (await this.get(venueId)).etag;
3765
- const res = await this.api.call(import_protocol18.Operations.patchVenue, {
3900
+ const res = await this.api.call(import_protocol19.Operations.patchVenue, {
3766
3901
  params: { venueId },
3767
3902
  body: patch,
3768
3903
  headers: { "if-match": etag }
3769
3904
  });
3770
3905
  return {
3771
- value: ApiCaller.decodeBody(import_protocol18.Operations.patchVenue, res),
3906
+ value: ApiCaller.decodeBody(import_protocol19.Operations.patchVenue, res),
3772
3907
  etag: res.headers.etag
3773
3908
  };
3774
3909
  }
3775
3910
  /** Watches a venue (events, resync re-read, polling while realtime is down). */
3776
3911
  watch(venueId, obs, intervalMs = 5e3) {
3777
3912
  return this.c.watchResource(
3778
- import_protocol18.DomeTopics.venue(venueId),
3913
+ import_protocol19.DomeTopics.venue(venueId),
3779
3914
  async () => (await this.get(venueId)).value,
3780
3915
  obs,
3781
3916
  {
3782
3917
  intervalMs,
3783
- kinds: /* @__PURE__ */ new Set([import_protocol18.EventKinds.venueUpdated])
3918
+ kinds: /* @__PURE__ */ new Set([import_protocol19.EventKinds.venueUpdated])
3784
3919
  }
3785
3920
  );
3786
3921
  }
3787
3922
  /** Exports the venue as `.dome` bytes. */
3788
3923
  async export(venueId = "default") {
3789
- const res = await this.api.call(import_protocol18.Operations.exportVenue, {
3924
+ const res = await this.api.call(import_protocol19.Operations.exportVenue, {
3790
3925
  params: { venueId },
3791
3926
  headers: { accept: "application/vnd.nativemind.freedome.dome+zip, application/problem+json" },
3792
3927
  timeoutMs: 3e5
@@ -3795,15 +3930,15 @@ var VenuesRepository = class {
3795
3930
  }
3796
3931
  /** Calibration block with the venue ETag. */
3797
3932
  async calibration(venueId = "default") {
3798
- const res = await this.api.call(import_protocol18.Operations.getCalibration, { params: { venueId } });
3933
+ const res = await this.api.call(import_protocol19.Operations.getCalibration, { params: { venueId } });
3799
3934
  return {
3800
- value: ApiCaller.decodeBody(import_protocol18.Operations.getCalibration, res),
3935
+ value: ApiCaller.decodeBody(import_protocol19.Operations.getCalibration, res),
3801
3936
  etag: res.headers.etag
3802
3937
  };
3803
3938
  }
3804
3939
  /** Bytes of a calibration sidecar. */
3805
3940
  async calibrationFile(venueId, displayId, file) {
3806
- return (await this.api.call(import_protocol18.Operations.getCalibrationFile, {
3941
+ return (await this.api.call(import_protocol19.Operations.getCalibrationFile, {
3807
3942
  params: { venueId, displayId, file },
3808
3943
  headers: { accept: "*/*" }
3809
3944
  })).body;
@@ -3811,21 +3946,21 @@ var VenuesRepository = class {
3811
3946
  /** Uploads a calibration sidecar (If-Match = venue ETag, read when not given). */
3812
3947
  async putCalibrationFile(venueId, displayId, file, bytes, ifMatch) {
3813
3948
  const etag = ifMatch ?? (await this.calibration(venueId)).etag;
3814
- const res = await this.api.call(import_protocol18.Operations.putCalibrationFile, {
3949
+ const res = await this.api.call(import_protocol19.Operations.putCalibrationFile, {
3815
3950
  params: { venueId, displayId, file },
3816
3951
  bytes,
3817
3952
  contentType: CALIBRATION_FILE_TYPES[file],
3818
3953
  headers: { "if-match": etag }
3819
3954
  });
3820
3955
  return {
3821
- value: ApiCaller.decodeBody(import_protocol18.Operations.putCalibrationFile, res),
3956
+ value: ApiCaller.decodeBody(import_protocol19.Operations.putCalibrationFile, res),
3822
3957
  etag: res.headers.etag
3823
3958
  };
3824
3959
  }
3825
3960
  };
3826
3961
 
3827
3962
  // src/client.ts
3828
- var FREEDOME_CLIENT_VERSION = "1.0.0-rc.1";
3963
+ var FREEDOME_CLIENT_VERSION = "1.2.0";
3829
3964
  function defaultTransports() {
3830
3965
  return { rest: (e) => new FetchTransport(e), sockets: webSocketConnector() };
3831
3966
  }
@@ -3842,6 +3977,7 @@ var FreedomeClient = class {
3842
3977
  playback;
3843
3978
  content;
3844
3979
  osc;
3980
+ assistant;
3845
3981
  clients;
3846
3982
  audio;
3847
3983
  audioReactive;
@@ -3919,7 +4055,8 @@ var FreedomeClient = class {
3919
4055
  () => this.channel !== void 0,
3920
4056
  this.options.positionHz,
3921
4057
  (s) => this.onEngineHealth(s),
3922
- init.logger
4058
+ init.logger,
4059
+ () => this.contractVersion
3923
4060
  );
3924
4061
  this.graphql = new GraphqlClient(this.api);
3925
4062
  this.venues = new VenuesRepository(this.ctx);
@@ -3928,6 +4065,7 @@ var FreedomeClient = class {
3928
4065
  this.playback = new PlaybackRepository(this.ctx);
3929
4066
  this.content = new ContentRepository(this.ctx);
3930
4067
  this.osc = new OscRepository(this.ctx);
4068
+ this.assistant = new AssistantRepository(this.ctx);
3931
4069
  this.clients = new ClientsRepository(this.ctx);
3932
4070
  this.audio = new AudioRepository(this.ctx);
3933
4071
  this.audioReactive = new AudioReactiveRepository(this.ctx);
@@ -3942,6 +4080,15 @@ var FreedomeClient = class {
3942
4080
  get server() {
3943
4081
  return this.serverInfo;
3944
4082
  }
4083
+ /**
4084
+ * Contract version the server reports (`contractVersion` of `GET /info`); undefined before [open], or when the server
4085
+ * reports none or an unreadable one. This is how an app tells what a server offers: a 1.0 server has no audio control
4086
+ * (`ProtocolVersions.audioControl`, `AudioRepository.supportsAudioControl`).
4087
+ */
4088
+ get contractVersion() {
4089
+ const v = this.serverInfo?.contractVersion;
4090
+ return typeof v === "string" ? import_protocol20.SemVer.tryParse(v) ?? void 0 : void 0;
4091
+ }
3945
4092
  get state() {
3946
4093
  return this.stateValue;
3947
4094
  }
@@ -4024,7 +4171,7 @@ var FreedomeClient = class {
4024
4171
  this.set("negotiating");
4025
4172
  let info;
4026
4173
  try {
4027
- info = await this.api.json(import_protocol19.Operations.getInfo, { authenticated: false });
4174
+ info = await this.api.json(import_protocol20.Operations.getInfo, { authenticated: false });
4028
4175
  } catch (e) {
4029
4176
  if (e instanceof NetworkError) {
4030
4177
  this.set("offline", "server not reachable");
@@ -4038,17 +4185,17 @@ var FreedomeClient = class {
4038
4185
  throw new IncompatibleServerError(
4039
4186
  `no Freedome API v1 at ${this.endpointValue.apiBase} (${e.message})`,
4040
4187
  [],
4041
- import_protocol19.ProtocolVersions.apiMajors
4188
+ import_protocol20.ProtocolVersions.apiMajors
4042
4189
  );
4043
4190
  }
4044
4191
  const versions = (info.apiVersions ?? []).map(String);
4045
4192
  const majors = versions.map((v) => Number.parseInt(v.replace(/^v/, ""), 10));
4046
- if (!majors.some((m) => import_protocol19.ProtocolVersions.apiMajors.includes(m))) {
4193
+ if (!majors.some((m) => import_protocol20.ProtocolVersions.apiMajors.includes(m))) {
4047
4194
  this.set("incompatible");
4048
4195
  throw new IncompatibleServerError(
4049
- `server speaks ${versions.join(", ")}, this client v${import_protocol19.ProtocolVersions.apiMajors.join(", v")}`,
4196
+ `server speaks ${versions.join(", ")}, this client v${import_protocol20.ProtocolVersions.apiMajors.join(", v")}`,
4050
4197
  versions,
4051
- import_protocol19.ProtocolVersions.apiMajors
4198
+ import_protocol20.ProtocolVersions.apiMajors
4052
4199
  );
4053
4200
  }
4054
4201
  this.serverInfo = info;
@@ -4067,12 +4214,12 @@ var FreedomeClient = class {
4067
4214
  return;
4068
4215
  case "apiKey":
4069
4216
  this.api.authorization = `Bearer ${c.key}`;
4070
- this.setSession(sessionFromPrincipal(await this.api.json(import_protocol19.Operations.getMe)));
4217
+ this.setSession(sessionFromPrincipal(await this.api.json(import_protocol20.Operations.getMe)));
4071
4218
  return;
4072
4219
  case "password": {
4073
4220
  const stored = await this.tokenStore.read(key);
4074
4221
  if (stored && await this.tryStored(stored)) return;
4075
- const t = await this.api.json(import_protocol19.Operations.createSession, {
4222
+ const t = await this.api.json(import_protocol20.Operations.createSession, {
4076
4223
  body: { username: c.username, password: c.password, client },
4077
4224
  authenticated: false
4078
4225
  });
@@ -4088,7 +4235,7 @@ var FreedomeClient = class {
4088
4235
  case "cloud": {
4089
4236
  const stored = await this.tokenStore.read(key);
4090
4237
  if (stored && await this.tryStored(stored)) return;
4091
- const t = await this.api.json(import_protocol19.Operations.exchangeCloudToken, {
4238
+ const t = await this.api.json(import_protocol20.Operations.exchangeCloudToken, {
4092
4239
  body: { subjectToken: await c.token(), client },
4093
4240
  authenticated: false
4094
4241
  });
@@ -4100,7 +4247,7 @@ var FreedomeClient = class {
4100
4247
  async tryStored(t) {
4101
4248
  this.api.authorization = `Bearer ${t.accessToken}`;
4102
4249
  try {
4103
- this.setSession(sessionFromPrincipal(await this.api.json(import_protocol19.Operations.getMe)));
4250
+ this.setSession(sessionFromPrincipal(await this.api.json(import_protocol20.Operations.getMe)));
4104
4251
  return true;
4105
4252
  } catch (e) {
4106
4253
  if (!(e instanceof UnauthorizedError)) throw e;
@@ -4115,7 +4262,7 @@ var FreedomeClient = class {
4115
4262
  this.setSession(sessionFromTokens(t, user ?? this.sessionValue.user));
4116
4263
  }
4117
4264
  async pair(p) {
4118
- let pairing = await this.api.json(import_protocol19.Operations.createPairing, {
4265
+ let pairing = await this.api.json(import_protocol20.Operations.createPairing, {
4119
4266
  body: {
4120
4267
  app: p.app,
4121
4268
  deviceName: p.deviceName,
@@ -4138,7 +4285,7 @@ var FreedomeClient = class {
4138
4285
  while (!["approved", "denied", "expired", "revoked"].includes(pr().status)) {
4139
4286
  if (Date.now() > deadline) throw new UnauthorizedError("pairing was not approved in time");
4140
4287
  await new Promise((r) => setTimeout(r, this.options.pairingPollIntervalMs));
4141
- pairing = await this.api.json(import_protocol19.Operations.getPairing, {
4288
+ pairing = await this.api.json(import_protocol20.Operations.getPairing, {
4142
4289
  params: { pairingId: pr().pairingId },
4143
4290
  authenticated: false
4144
4291
  });
@@ -4156,7 +4303,7 @@ var FreedomeClient = class {
4156
4303
  const rt = stored?.refreshToken;
4157
4304
  if (!rt) return await this.reauthenticate();
4158
4305
  try {
4159
- const t = await this.api.json(import_protocol19.Operations.refreshSession, {
4306
+ const t = await this.api.json(import_protocol20.Operations.refreshSession, {
4160
4307
  body: { refreshToken: rt },
4161
4308
  authenticated: false
4162
4309
  });
@@ -4194,7 +4341,7 @@ var FreedomeClient = class {
4194
4341
  async logout() {
4195
4342
  if (this.api.authorization && this.credentials.kind !== "apiKey") {
4196
4343
  try {
4197
- await this.api.call(import_protocol19.Operations.deleteSession);
4344
+ await this.api.call(import_protocol20.Operations.deleteSession);
4198
4345
  } catch (e) {
4199
4346
  this.log("warning", "logout", e);
4200
4347
  }
@@ -4230,7 +4377,7 @@ var FreedomeClient = class {
4230
4377
  );
4231
4378
  return GraphqlWsChannel.open(s2, hello, { ...o, ...log });
4232
4379
  }
4233
- const s = await sockets(this.endpointValue, "/api/v1/ws", [import_protocol19.WS_SUBPROTOCOL], o.timeoutMs);
4380
+ const s = await sockets(this.endpointValue, "/api/v1/ws", [import_protocol20.WS_SUBPROTOCOL], o.timeoutMs);
4234
4381
  return WsChannel.open(s, hello, { ...o, ...log });
4235
4382
  };
4236
4383
  }
@@ -4325,9 +4472,9 @@ var FreedomeClient = class {
4325
4472
  async replayOutbox() {
4326
4473
  if (!this.outbox) return;
4327
4474
  await this.ctx.replayOutbox(async (e) => {
4328
- const op = import_protocol19.Operations[e.operationId];
4475
+ const op = import_protocol20.Operations[e.operationId];
4329
4476
  if (!op || op.method !== "PUT" && op.method !== "PATCH") return void 0;
4330
- const get = Object.values(import_protocol19.Operations).find(
4477
+ const get = Object.values(import_protocol20.Operations).find(
4331
4478
  (o) => o.method === "GET" && o.path === op.path
4332
4479
  );
4333
4480
  if (!get) return void 0;
@@ -4348,7 +4495,7 @@ var FreedomeClient = class {
4348
4495
  async seedSeq(filters) {
4349
4496
  if (this.hub.lastSeq !== void 0) return;
4350
4497
  try {
4351
- const page = await this.api.json(import_protocol19.Operations.listEvents, {
4498
+ const page = await this.api.json(import_protocol20.Operations.listEvents, {
4352
4499
  query: { topics: filters.join(","), limit: "1" }
4353
4500
  });
4354
4501
  if (typeof page.lastSeq === "number") this.hub.seed(page.lastSeq);
@@ -4467,7 +4614,7 @@ var FreedomeClient = class {
4467
4614
  };
4468
4615
 
4469
4616
  // src/discovery.ts
4470
- var import_protocol20 = require("@freedome/protocol");
4617
+ var import_protocol21 = require("@freedome/protocol");
4471
4618
 
4472
4619
  // src/endpoint.ts
4473
4620
  var FreedomeEndpoint = class _FreedomeEndpoint {
@@ -4595,8 +4742,8 @@ async function probe(endpoint, timeoutMs = 2e3) {
4595
4742
  try {
4596
4743
  const res = await t.send(
4597
4744
  {
4598
- method: import_protocol20.Operations.getInfo.method,
4599
- path: import_protocol20.Operations.getInfo.path,
4745
+ method: import_protocol21.Operations.getInfo.method,
4746
+ path: import_protocol21.Operations.getInfo.path,
4600
4747
  headers: { accept: "application/json" }
4601
4748
  },
4602
4749
  timeoutMs
@@ -4658,11 +4805,12 @@ var CompositeDiscovery = class {
4658
4805
  };
4659
4806
 
4660
4807
  // src/index.ts
4661
- var import_protocol21 = require("@freedome/protocol");
4808
+ var import_protocol22 = require("@freedome/protocol");
4662
4809
  var PACKAGE_NAME = "@freedome/client";
4663
4810
  // Annotate the CommonJS export names for ESM import in node:
4664
4811
  0 && (module.exports = {
4665
4812
  ApiCaller,
4813
+ AssistantRepository,
4666
4814
  AudioReactiveRepository,
4667
4815
  AudioRepository,
4668
4816
  BackoffPolicy,
@@ -4712,10 +4860,12 @@ var PACKAGE_NAME = "@freedome/client";
4712
4860
  PlayTargets,
4713
4861
  PlaybackRepository,
4714
4862
  PlayerHandle,
4863
+ ProtocolVersions,
4715
4864
  QueuedForReplayError,
4716
4865
  RateLimitedError,
4717
4866
  RepositoryContext,
4718
4867
  RequestTimeoutError,
4868
+ SemVer,
4719
4869
  ServerError,
4720
4870
  Sha256,
4721
4871
  ShowParts,