@eyepop.ai/eyepop 3.9.0 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9016,9 +9016,9 @@ var WebrtcBase = class _WebrtcBase {
9016
9016
  const sections = answer.split("m=");
9017
9017
  for (let i = 0; i < sections.length; i++) {
9018
9018
  const section = sections[i];
9019
- if (section.startsWith("video")) {
9019
+ if (section && section.startsWith("video")) {
9020
9020
  sections[i] = WebrtcWhip.setVideoBitrate(WebrtcWhip.setCodec(section, videoCodec), videoBitrate);
9021
- } else if (section.startsWith("audio")) {
9021
+ } else if (section && section.startsWith("audio")) {
9022
9022
  sections[i] = WebrtcWhip.setAudioBitrate(WebrtcWhip.setCodec(section, audioCodec), audioBitrate, audioVoice);
9023
9023
  }
9024
9024
  }
@@ -9057,7 +9057,11 @@ var WebrtcBase = class _WebrtcBase {
9057
9057
  static setVideoBitrate(section, bitrate) {
9058
9058
  let lines = section.split("\r\n");
9059
9059
  for (let i = 0; i < lines.length; i++) {
9060
- if (lines[i].startsWith("c=")) {
9060
+ const line = lines[i];
9061
+ if (!line) {
9062
+ continue;
9063
+ }
9064
+ if (line.startsWith("c=")) {
9061
9065
  lines = [...lines.slice(0, i + 1), "b=TIAS:" + (bitrate * 1024).toString(), ...lines.slice(i + 1)];
9062
9066
  break;
9063
9067
  }
@@ -9068,8 +9072,12 @@ var WebrtcBase = class _WebrtcBase {
9068
9072
  let opusPayloadFormat = "";
9069
9073
  let lines = section.split("\r\n");
9070
9074
  for (let i = 0; i < lines.length; i++) {
9071
- if (lines[i].startsWith("a=rtpmap:") && lines[i].toLowerCase().includes("opus/")) {
9072
- opusPayloadFormat = lines[i].slice("a=rtpmap:".length).split(" ")[0];
9075
+ const line = lines[i];
9076
+ if (!line) {
9077
+ continue;
9078
+ }
9079
+ if (line.startsWith("a=rtpmap:") && line.toLowerCase().includes("opus/")) {
9080
+ opusPayloadFormat = line.slice("a=rtpmap:".length).split(" ")[0] || "";
9073
9081
  break;
9074
9082
  }
9075
9083
  }
@@ -9077,7 +9085,11 @@ var WebrtcBase = class _WebrtcBase {
9077
9085
  return section;
9078
9086
  }
9079
9087
  for (let i = 0; i < lines.length; i++) {
9080
- if (lines[i].startsWith("a=fmtp:" + opusPayloadFormat + " ")) {
9088
+ const line = lines[i];
9089
+ if (!line) {
9090
+ continue;
9091
+ }
9092
+ if (line.startsWith("a=fmtp:" + opusPayloadFormat + " ")) {
9081
9093
  if (voice) {
9082
9094
  lines[i] = "a=fmtp:" + opusPayloadFormat + " minptime=10;useinbandfec=1;maxaveragebitrate=" + ((bitrate ?? 0) * 1024).toString();
9083
9095
  } else {
@@ -9581,7 +9593,7 @@ var LoadMediaStreamJob = class extends AbstractJob {
9581
9593
  true,
9582
9594
  this._requestLogger
9583
9595
  );
9584
- whip.start().then((value) => {
9596
+ whip.start().then((_) => {
9585
9597
  this._requestLogger.debug("direct whip for ingressId=%s successful", whip.ingressId());
9586
9598
  }).catch((reason) => {
9587
9599
  this._controller.abort(reason);
@@ -9612,7 +9624,7 @@ var LoadMediaStreamJob = class extends AbstractJob {
9612
9624
  // shims/local_file.ts
9613
9625
  var resolvePath;
9614
9626
  if ("document" in globalThis && "implementation" in globalThis.document) {
9615
- resolvePath = async (source, logger) => {
9627
+ resolvePath = async (_source, _logger) => {
9616
9628
  throw new DOMException("resolving a path to a file is not supported in browser");
9617
9629
  };
9618
9630
  } else {
@@ -9634,7 +9646,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9634
9646
  yield chunk;
9635
9647
  }
9636
9648
  }
9637
- resolvePath = async (source, logger) => {
9649
+ resolvePath = async (source, _) => {
9638
9650
  const mime = require_mime_types();
9639
9651
  const filehandle = __require("fs/promises");
9640
9652
  const fd = await filehandle.open(source.path, "r");
@@ -9763,7 +9775,7 @@ var Semaphore = class {
9763
9775
  this.permits -= 1;
9764
9776
  return Promise.resolve(true);
9765
9777
  }
9766
- let resolver = (b) => void 0;
9778
+ let resolver = (_) => void 0;
9767
9779
  const promise = new Promise((r) => {
9768
9780
  resolver = r;
9769
9781
  });
@@ -9893,7 +9905,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9893
9905
  return session;
9894
9906
  };
9895
9907
  } else {
9896
- authenticateBrowserSession = (auth0, options) => {
9908
+ authenticateBrowserSession = (_auth0, _options) => {
9897
9909
  return Promise.reject("auth0 login not supported server-side");
9898
9910
  };
9899
9911
  }
@@ -9927,6 +9939,14 @@ var Endpoint = class {
9927
9939
  eyepopUrl() {
9928
9940
  if (this._options.eyepopUrl) {
9929
9941
  return this._options.eyepopUrl.replace(/\/+$/, "");
9942
+ } else {
9943
+ return "https://compute.eyepop.ai";
9944
+ }
9945
+ }
9946
+ // TODO: deprecated Web API endpoint needed for POP_ID support
9947
+ eyepopWebApiUrl() {
9948
+ if (this._options.eyepopUrl) {
9949
+ return this._options.eyepopUrl.replace(/\/+$/, "").replace(/compute\./, "web-api.");
9930
9950
  } else {
9931
9951
  return "https://api.eyepop.ai";
9932
9952
  }
@@ -9974,10 +9994,10 @@ var Endpoint = class {
9974
9994
  this._token = this._options.auth.session.accessToken;
9975
9995
  this._expire_token_time = this._options.auth.session.validUntil / 1e3;
9976
9996
  } else if (this._options.auth.oAuth2 !== void 0) {
9977
- } else if (this._options.auth.secretKey !== void 0) {
9997
+ } else if (this._options.auth.apiKey !== void 0) {
9978
9998
  } else if (this._options.auth.isLocal !== void 0) {
9979
9999
  } else {
9980
- return Promise.reject("option secretKey or environment variable EYEPOP_SECRET_KEY is required");
10000
+ return Promise.reject("option apiKey or environment variable EYEPOP_API_KEY is required");
9981
10001
  }
9982
10002
  if (this._options.platformSupport?.createHttpClient !== void 0) {
9983
10003
  this._client = await this._options.platformSupport.createHttpClient(this._requestLogger);
@@ -10009,7 +10029,7 @@ var Endpoint = class {
10009
10029
  validUntil: this._expire_token_time * 1e3
10010
10030
  };
10011
10031
  }
10012
- statusHandler401(statusCode) {
10032
+ statusHandler401(_statusCode) {
10013
10033
  this._token = null;
10014
10034
  this._expire_token_time = null;
10015
10035
  }
@@ -10072,15 +10092,12 @@ var Endpoint = class {
10072
10092
  const session = await authenticateBrowserSession(this._options.auth.oAuth2, this._options);
10073
10093
  this._token = session.accessToken;
10074
10094
  this._expire_token_time = session.validUntil / 1e3;
10075
- } else if (this._options.auth.secretKey !== void 0 && this._options.eyepopUrl) {
10076
- const secretKeyAuth = this._options.auth;
10077
- const body = { secret_key: secretKeyAuth.secretKey };
10078
- const headers = { "Content-Type": "application/json" };
10079
- const post_url = `${this.eyepopUrl()}/authentication/token`;
10095
+ } else if (this._options.auth.apiKey !== void 0 && this._options.eyepopUrl) {
10096
+ const headers = { "Authorization": `Bearer ${this._options.auth.apiKey}` };
10097
+ const post_url = `${this.eyepopUrl()}/v1/auth/authenticate`;
10080
10098
  const response = await this._client.fetch(post_url, {
10081
10099
  method: "POST",
10082
- headers,
10083
- body: JSON.stringify(body)
10100
+ headers
10084
10101
  });
10085
10102
  if (response.status != 200) {
10086
10103
  const message = await response.text();
@@ -10109,7 +10126,21 @@ var TransientPopId = /* @__PURE__ */ ((TransientPopId2) => {
10109
10126
  })(TransientPopId || {});
10110
10127
 
10111
10128
  // worker/worker_endpoint.ts
10112
- var WorkerEndpoint = class extends Endpoint {
10129
+ var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
10130
+ SessionStatus2["UNKNOWN"] = "unknown";
10131
+ SessionStatus2["PENDING"] = "pending";
10132
+ SessionStatus2["RUNNING"] = "running";
10133
+ SessionStatus2["STOPPED"] = "stopped";
10134
+ SessionStatus2["FAILED"] = "failed";
10135
+ SessionStatus2["ERROR"] = "error";
10136
+ SessionStatus2["PIPELINE_CREATING"] = "pipeline_creating";
10137
+ SessionStatus2["PIPELINE_OK"] = "pipeline_ok";
10138
+ SessionStatus2["PIPELINE_CHECKING"] = "pipeline_checking";
10139
+ SessionStatus2["PIPELINE_ERROR"] = "pipeline_error";
10140
+ return SessionStatus2;
10141
+ })(SessionStatus || {});
10142
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
10143
+ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10113
10144
  constructor(options) {
10114
10145
  super(options);
10115
10146
  this.setStatusRetryHandlers(/* @__PURE__ */ new Map([[404, (statusCode) => this.statusHandler404(statusCode)]]));
@@ -10138,7 +10169,7 @@ var WorkerEndpoint = class extends Endpoint {
10138
10169
  }
10139
10170
  return super.disconnect(wait);
10140
10171
  }
10141
- statusHandler404(statusCode) {
10172
+ statusHandler404(_) {
10142
10173
  this._pipelineId = null;
10143
10174
  this._baseUrl = null;
10144
10175
  }
@@ -10191,10 +10222,17 @@ var WorkerEndpoint = class extends Endpoint {
10191
10222
  });
10192
10223
  if (response.status != 204) {
10193
10224
  const message = await response.text();
10194
- return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10225
+ throw new Error(`Unexpected status ${response.status}: ${message}`);
10195
10226
  }
10196
10227
  if (this._pipeline) {
10197
10228
  this._pipeline.pop = pop;
10229
+ } else {
10230
+ this._pipeline = {
10231
+ id: this._pipelineId || "unknown",
10232
+ state: "idle",
10233
+ startTime: (/* @__PURE__ */ new Date()).toString(),
10234
+ pop
10235
+ };
10198
10236
  }
10199
10237
  }
10200
10238
  _authenticationHeaders(session) {
@@ -10414,11 +10452,11 @@ var WorkerEndpoint = class extends Endpoint {
10414
10452
  throw e;
10415
10453
  }
10416
10454
  }
10417
- jobDone(job) {
10455
+ jobDone(_) {
10418
10456
  this._limit?.release();
10419
10457
  this.updateState();
10420
10458
  }
10421
- jobStatus(job, statusCode) {
10459
+ jobStatus(_, statusCode) {
10422
10460
  if (statusCode == 404) {
10423
10461
  this.statusHandler404(statusCode);
10424
10462
  } else if (statusCode == 401) {
@@ -10426,15 +10464,20 @@ var WorkerEndpoint = class extends Endpoint {
10426
10464
  }
10427
10465
  }
10428
10466
  async reconnect() {
10429
- if (!this._client) {
10430
- return Promise.reject("endpoint not initialized");
10431
- }
10432
- let config_url;
10433
10467
  if (this.options().popId == "transient" /* Transient */) {
10434
- config_url = `${this.eyepopUrl()}/workers/config`;
10468
+ await this.startComputeSession();
10469
+ this._pipelineId = await this.startTransientPipeline();
10435
10470
  } else {
10436
- config_url = `${this.eyepopUrl()}/pops/${this.options().popId}/config?auto_start=false`;
10471
+ await this.startWebApiSessionWithPopId();
10437
10472
  }
10473
+ this.updateState();
10474
+ return Promise.resolve(this);
10475
+ }
10476
+ async startWebApiSessionWithPopId() {
10477
+ if (!this._client) {
10478
+ throw new Error("endpoint not initialized");
10479
+ }
10480
+ const config_url = `${this.eyepopWebApiUrl()}/pops/${this.options().popId}/config?auto_start=false`;
10438
10481
  const headers = {
10439
10482
  Authorization: await this.authorizationHeader()
10440
10483
  };
@@ -10458,11 +10501,11 @@ var WorkerEndpoint = class extends Endpoint {
10458
10501
  } else {
10459
10502
  this.updateState("Error" /* Error */, message);
10460
10503
  }
10461
- return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10504
+ throw new Error(`Unexpected status ${response.status}: ${message}`);
10462
10505
  }
10463
10506
  let config = await response.json();
10464
10507
  if (!config.base_url && this.options().autoStart) {
10465
- const auto_start_config_url = `${this.eyepopUrl()}/pops/${this.options().popId}/config?auto_start=true`;
10508
+ const auto_start_config_url = `${this.eyepopWebApiUrl()}/pops/${this.options().popId}/config?auto_start=true`;
10466
10509
  this._requestLogger.debug("pop was not running, trying to autostart with: %s", auto_start_config_url);
10467
10510
  const headers2 = {
10468
10511
  Authorization: await this.authorizationHeader()
@@ -10473,7 +10516,7 @@ var WorkerEndpoint = class extends Endpoint {
10473
10516
  if (response.status != 200) {
10474
10517
  this.updateState("Error" /* Error */);
10475
10518
  const message = await response.text();
10476
- return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10519
+ throw new Error(`Unexpected status ${response.status}: ${message}`);
10477
10520
  }
10478
10521
  config = await response.json();
10479
10522
  }
@@ -10481,17 +10524,11 @@ var WorkerEndpoint = class extends Endpoint {
10481
10524
  this._baseUrl = baseUrl.toString();
10482
10525
  if (this._baseUrl) {
10483
10526
  this._baseUrl = this._baseUrl.replace(/\/+$/, "");
10484
- if (this.options().popId == "transient" /* Transient */) {
10485
- this._pipelineId = await this.startTransientPipeline();
10486
- this._popName = this.options().popId || null;
10487
- } else {
10488
- this._pipelineId = config.pipeline_id;
10489
- this._popName = config.name;
10490
- }
10527
+ this._pipelineId = config.pipeline_id;
10528
+ this._popName = config.name;
10491
10529
  if (!this._pipelineId || !this._baseUrl) {
10492
- return Promise.reject(`Pop not started`);
10530
+ throw new Error("Pop not started");
10493
10531
  }
10494
- this._baseUrl = this._baseUrl.replace(/\/+$/, "");
10495
10532
  const get_url = `${this._baseUrl}/pipelines/${this._pipelineId}`;
10496
10533
  const headers2 = {
10497
10534
  Authorization: await this.authorizationHeader()
@@ -10502,7 +10539,7 @@ var WorkerEndpoint = class extends Endpoint {
10502
10539
  });
10503
10540
  if (response2.status > 200) {
10504
10541
  const message = await response2.text();
10505
- return Promise.reject(`Unexpected status ${response2.status}: ${message}`);
10542
+ throw new Error(`Unexpected status ${response2.status}: ${message}`);
10506
10543
  }
10507
10544
  this._pipeline = await response2.json();
10508
10545
  if (this.options().stopJobs) {
@@ -10519,18 +10556,95 @@ var WorkerEndpoint = class extends Endpoint {
10519
10556
  });
10520
10557
  if (response3.status >= 300) {
10521
10558
  const message = await response3.text();
10522
- return Promise.reject(`Unexpected status ${response3.status}: ${message}`);
10559
+ throw new Error(`Unexpected status ${response3.status}: ${message}`);
10523
10560
  }
10524
10561
  }
10525
10562
  }
10526
- this.updateState();
10527
- return Promise.resolve(this);
10563
+ }
10564
+ async startComputeSession() {
10565
+ if (!this._client) {
10566
+ throw new Error("endpoint not initialized");
10567
+ }
10568
+ let session = null;
10569
+ const sessionsUrl = `${this.eyepopUrl()}/v1/sessions`;
10570
+ this._requestLogger.debug("fetching sessions from: %s", sessionsUrl);
10571
+ const headers = {
10572
+ Authorization: await this.authorizationHeader()
10573
+ };
10574
+ let response = await this._client.fetch(sessionsUrl, {
10575
+ headers
10576
+ });
10577
+ let sessions;
10578
+ if (response.status == 404) {
10579
+ sessions = [];
10580
+ } else if (response.status != 200) {
10581
+ this.updateState("Error" /* Error */);
10582
+ const message = await response.text();
10583
+ throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
10584
+ } else {
10585
+ const response_content = await response.json();
10586
+ sessions = response_content;
10587
+ }
10588
+ if (sessions.length > 0) {
10589
+ this._logger.debug(`User has ${sessions.length} sessions, inspecting for active session`);
10590
+ for (let s of sessions) {
10591
+ if (!_WorkerEndpoint.SESSION_DEAD.has(s.session_status)) {
10592
+ session = s;
10593
+ this._logger.debug(`Use active session ${s.session_uuid} with pipeline ${s.pipeline_uuid}`);
10594
+ break;
10595
+ }
10596
+ }
10597
+ }
10598
+ if (!session) {
10599
+ this._requestLogger.debug("creating a new session at: %s", sessionsUrl);
10600
+ response = await this._client.fetch(sessionsUrl, {
10601
+ headers,
10602
+ method: "POST"
10603
+ });
10604
+ if (response.status != 200) {
10605
+ this.updateState("Error" /* Error */);
10606
+ const message = await response.text();
10607
+ throw new Error(`Unexpected status ${response.status} creating a compute session: ${message}`);
10608
+ } else {
10609
+ sessions = await response.json();
10610
+ }
10611
+ if (sessions.length == 0) {
10612
+ throw new Error("Unexpected, no compute session after attempt to create one");
10613
+ }
10614
+ session = sessions[0] || null;
10615
+ }
10616
+ if (!session) {
10617
+ throw new Error("unexpected undefined session");
10618
+ }
10619
+ let isReady = false;
10620
+ const deadline = Date.now() + _WorkerEndpoint.WAIT_FOR_IS_READY;
10621
+ while (!isReady) {
10622
+ const health_url = `${session.session_endpoint}/health`;
10623
+ response = await this._client.fetch(health_url, {
10624
+ headers
10625
+ });
10626
+ if (response.status < 300) {
10627
+ isReady = true;
10628
+ } else if (Date.now() > deadline) {
10629
+ throw new Error(`Created session ${session.session_uuid} did not become healthy after ${_WorkerEndpoint.WAIT_FOR_IS_READY / 1e3} seconds`);
10630
+ } else {
10631
+ this._logger.debug(`session ${session.session_uuid} health check status ${response.status}, wait and poll for update`);
10632
+ await sleep(_WorkerEndpoint.CHECK_FOR_IS_READY_INTERVAL);
10633
+ }
10634
+ }
10635
+ this._baseUrl = session.session_endpoint;
10636
+ this._pipeline = null;
10637
+ if (session.pipeline_uuid) {
10638
+ this._pipelineId = session.pipeline_uuid;
10639
+ } else {
10640
+ this._pipelineId = null;
10641
+ }
10528
10642
  }
10529
10643
  async startTransientPipeline() {
10530
10644
  const client = this._client;
10531
10645
  const baseUrl = this._baseUrl;
10532
10646
  if (client == null || baseUrl == null) {
10533
- return Promise.reject("endpoint not initialized");
10647
+ throw new Error("endpoint not initialized");
10534
10648
  }
10535
10649
  let pop;
10536
10650
  if (this._pipeline && this._pipeline.pop) {
@@ -10563,12 +10677,22 @@ var WorkerEndpoint = class extends Endpoint {
10563
10677
  });
10564
10678
  if (response.status != 200) {
10565
10679
  const message = await response.text();
10566
- return Promise.reject(`Unexpected status ${response.status}: ${message}`);
10680
+ throw new Error(`Unexpected status ${response.status}: ${message}`);
10567
10681
  }
10568
10682
  const result = await response.json();
10569
10683
  return result["id"];
10570
10684
  }
10571
10685
  };
10686
+ _WorkerEndpoint.SESSION_DEAD = /* @__PURE__ */ new Set([
10687
+ "error" /* ERROR */,
10688
+ "failed" /* FAILED */,
10689
+ "stopped" /* STOPPED */,
10690
+ "pipeline_error" /* PIPELINE_ERROR */,
10691
+ "unknown" /* UNKNOWN */
10692
+ ]);
10693
+ _WorkerEndpoint.WAIT_FOR_IS_READY = 60 * 1e3;
10694
+ _WorkerEndpoint.CHECK_FOR_IS_READY_INTERVAL = 250;
10695
+ var WorkerEndpoint = _WorkerEndpoint;
10572
10696
 
10573
10697
  // shims/websockets.ts
10574
10698
  var createWebSocket;
@@ -11004,7 +11128,7 @@ var DataEndpoint = class extends Endpoint {
11004
11128
  return Promise.reject("endpoint not initialized");
11005
11129
  }
11006
11130
  const accountUuidQuery = this._accountId ? `?account_uuid=${this._accountId}` : "";
11007
- const config_url = `${this.eyepopUrl()}/configs${accountUuidQuery}`;
11131
+ const config_url = `${this.eyepopUrl()}/v1/configs${accountUuidQuery}`;
11008
11132
  let headers = {
11009
11133
  Authorization: await this.authorizationHeader()
11010
11134
  };
@@ -11582,7 +11706,7 @@ var DataEndpoint = class extends Endpoint {
11582
11706
  throw e;
11583
11707
  }
11584
11708
  }
11585
- jobDone(job) {
11709
+ jobDone(_job) {
11586
11710
  this._limit?.release();
11587
11711
  }
11588
11712
  async dispatchChangeEvent(change_event) {
@@ -11602,6 +11726,7 @@ var DataEndpoint = class extends Endpoint {
11602
11726
  for (let handler of this._account_event_handlers) {
11603
11727
  await handler(change_event);
11604
11728
  }
11729
+ break;
11605
11730
  // dataset event types
11606
11731
  case "asset_added" /* asset_added */:
11607
11732
  case "asset_removed" /* asset_removed */:
@@ -11699,6 +11824,23 @@ var DataEndpoint = class extends Endpoint {
11699
11824
  method: "DELETE"
11700
11825
  });
11701
11826
  }
11827
+ async listVlmAbilityEvaluations(vlm_ability_uuid) {
11828
+ return this.request(`/vlm_abilities/${vlm_ability_uuid}/evaluations`, {
11829
+ method: "GET"
11830
+ });
11831
+ }
11832
+ async getVlmAbilityEvaluation(vlm_ability_uuid, source) {
11833
+ return this.request(`/vlm_abilities/${vlm_ability_uuid}/evaluations/${source}`, {
11834
+ method: "GET"
11835
+ });
11836
+ }
11837
+ async startVlmAbilityEvaluation(vlm_ability_uuid, evaluate_request) {
11838
+ return this.request(`/vlm_abilities/${vlm_ability_uuid}/evaluations`, {
11839
+ method: "POST",
11840
+ body: JSON.stringify(evaluate_request),
11841
+ headers: { "Content-Type": "application/json" }
11842
+ });
11843
+ }
11702
11844
  };
11703
11845
 
11704
11846
  // worker/webrtc_whep.ts
@@ -11763,7 +11905,7 @@ var WebrtcWhep = class extends WebrtcBase {
11763
11905
  return new Promise(async (resolve, reject) => {
11764
11906
  pc.ontrack = (evt) => {
11765
11907
  this._requestLogger.debug(`new track: ${evt.track.kind}`);
11766
- this._stream = evt.streams[0];
11908
+ this._stream = evt.streams[0] || null;
11767
11909
  resolve(this);
11768
11910
  };
11769
11911
  pc.oniceconnectionstatechange = () => {
@@ -11799,21 +11941,24 @@ var stringToBooleanSafe = (str) => {
11799
11941
  };
11800
11942
  var EyePop;
11801
11943
  ((EyePop2) => {
11802
- const envSecretKey = readEnv("EYEPOP_SECRET_KEY");
11803
- const defaultAuth = envSecretKey ? {
11804
- secretKey: envSecretKey
11944
+ const envApiKey = readEnv("EYEPOP_API_KEY");
11945
+ const defaultAuth = envApiKey ? {
11946
+ apiKey: envApiKey
11805
11947
  } : void 0;
11806
11948
  EyePop2.endpoint = workerEndpoint;
11807
11949
  function workerEndpoint(opts = {}) {
11808
11950
  if (opts.isLocalMode === void 0) {
11809
11951
  opts.isLocalMode = stringToBooleanSafe(readEnv("EYEPOP_LOCAL_MODE"));
11810
11952
  }
11811
- _fill_default_options(opts, opts.isLocalMode ? "http://127.0.0.1:8080" : void 0);
11953
+ if (opts.isLocalMode) {
11954
+ opts.eyepopUrl = "http://127.0.0.1:8080";
11955
+ }
11956
+ _fill_default_options(opts);
11812
11957
  if (opts.auth === void 0) {
11813
11958
  if (opts.isLocalMode) {
11814
11959
  opts.auth = { isLocal: true };
11815
11960
  } else {
11816
- throw new Error("auth option or EYEPOP_SECRET_KEY environment variable is required");
11961
+ throw new Error("auth option or EYEPOP_API_KEY environment variable is required");
11817
11962
  }
11818
11963
  }
11819
11964
  if (opts.popId === void 0) {
@@ -11840,7 +11985,7 @@ var EyePop;
11840
11985
  function dataEndpoint(opts = {}) {
11841
11986
  _fill_default_options(opts);
11842
11987
  if (opts.auth === void 0) {
11843
- throw new Error("auth option or EYEPOP_SECRET_KEY environment variable is required");
11988
+ throw new Error("auth option or EYEPOP_API_KEY environment variable is required");
11844
11989
  }
11845
11990
  if (opts.accountId === void 0) {
11846
11991
  opts.accountId = readEnv("EYEPOP_ACCOUNT_ID");
@@ -11855,20 +12000,23 @@ var EyePop;
11855
12000
  return new DataEndpoint(opts);
11856
12001
  }
11857
12002
  EyePop2.dataEndpoint = dataEndpoint;
11858
- function _fill_default_options(opts, default_eyepop_url = "https://api.eyepop.ai") {
11859
- if (opts.auth === void 0) {
12003
+ function _fill_default_options(opts) {
12004
+ if (!opts.auth) {
11860
12005
  opts.auth = defaultAuth;
11861
12006
  }
11862
- if (opts.eyepopUrl === void 0) {
11863
- opts.eyepopUrl = readEnv("EYEPOP_URL") || default_eyepop_url;
12007
+ if (!opts.eyepopUrl && opts.auth && opts.auth.session && opts.auth.session.eyepopUrl) {
12008
+ opts.eyepopUrl = opts.auth.session.eyepopUrl;
11864
12009
  }
11865
- if (opts.jobQueueLength === void 0) {
11866
- opts.jobQueueLength = 1024;
12010
+ if (!opts.eyepopUrl) {
12011
+ opts.eyepopUrl = readEnv("EYEPOP_URL");
11867
12012
  }
11868
- if (opts.auth !== void 0) {
12013
+ if (!opts.eyepopUrl) {
12014
+ opts.eyepopUrl = "https://compute.eyepop.ai";
12015
+ }
12016
+ if (opts.auth) {
11869
12017
  if (opts.auth.oAuth2 !== void 0) {
11870
12018
  if (typeof opts.auth.oAuth2 === "boolean") {
11871
- if (opts.eyepopUrl.startsWith("https://web-api.staging.eyepop.xyz")) {
12019
+ if (opts.eyepopUrl && opts.eyepopUrl.match(/https:(.*).staging.eyepop.xyz/i)) {
11872
12020
  opts.auth = {
11873
12021
  oAuth2: {
11874
12022
  domain: "dev-eyepop.us.auth0.com",
@@ -11889,11 +12037,9 @@ var EyePop;
11889
12037
  }
11890
12038
  }
11891
12039
  }
11892
- if (opts.auth.session !== void 0) {
11893
- if (opts.auth.session.eyepopUrl) {
11894
- opts.eyepopUrl = opts.auth.session.eyepopUrl;
11895
- }
11896
- }
12040
+ }
12041
+ if (!opts.jobQueueLength) {
12042
+ opts.jobQueueLength = 128;
11897
12043
  }
11898
12044
  }
11899
12045
  })(EyePop || (EyePop = {}));
@@ -11934,6 +12080,7 @@ export {
11934
12080
  PopComponentType,
11935
12081
  PredictionVersion,
11936
12082
  Semaphore,
12083
+ SessionStatus,
11937
12084
  Stream,
11938
12085
  TranscodeMode,
11939
12086
  TransientPopId,