@eyepop.ai/eyepop 3.15.0 → 3.16.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.
@@ -9799,8 +9799,9 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9799
9799
  };
9800
9800
  } else {
9801
9801
  class NodeHttpClient {
9802
- constructor(agent, logger) {
9802
+ constructor(agent, fetchFn, logger) {
9803
9803
  this._agent = agent;
9804
+ this._fetch = fetchFn;
9804
9805
  this._logger = logger;
9805
9806
  }
9806
9807
  async fetch(input, init) {
@@ -9808,7 +9809,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9808
9809
  init.dispatcher = this._agent;
9809
9810
  const logLine = logLineFromRequest(input, init);
9810
9811
  this._logger.debug(`Node fetch() BEFORE ${logLine}`);
9811
- const response = await fetch(input, init);
9812
+ const response = await this._fetch(input, init);
9812
9813
  this._logger.debug(`AFTER ${logLine} -> ${response.status}`);
9813
9814
  return response;
9814
9815
  }
@@ -9828,7 +9829,7 @@ if ("document" in globalThis && "implementation" in globalThis.document) {
9828
9829
  pipelining: 0
9829
9830
  });
9830
9831
  logger.debug("Using node fetch with undici agent as http client");
9831
- return new NodeHttpClient(agent, logger);
9832
+ return new NodeHttpClient(agent, undici.fetch, logger);
9832
9833
  };
9833
9834
  }
9834
9835
 
@@ -10244,6 +10245,7 @@ var SessionStatus = /* @__PURE__ */ ((SessionStatus2) => {
10244
10245
  SessionStatus2["PIPELINE_OK"] = "pipeline_ok";
10245
10246
  SessionStatus2["PIPELINE_CHECKING"] = "pipeline_checking";
10246
10247
  SessionStatus2["PIPELINE_ERROR"] = "pipeline_error";
10248
+ SessionStatus2["UPGRADING"] = "upgrading";
10247
10249
  return SessionStatus2;
10248
10250
  })(SessionStatus || {});
10249
10251
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -10254,7 +10256,10 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10254
10256
  this._baseUrl = null;
10255
10257
  this._pipelineId = null;
10256
10258
  this._popName = null;
10259
+ this._sessionAccessToken = null;
10260
+ this._sessionAccessTokenValidUntil = null;
10257
10261
  this._pipeline = null;
10262
+ this._pipelineCreatePromise = null;
10258
10263
  }
10259
10264
  options() {
10260
10265
  return this._options;
@@ -10281,20 +10286,29 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10281
10286
  this._baseUrl = null;
10282
10287
  }
10283
10288
  async session() {
10284
- const session = await super.session();
10285
- if (this._baseUrl == null || this._pipelineId == null) {
10289
+ let session = null;
10290
+ if (this._baseUrl == null) {
10286
10291
  await this.reconnect();
10287
- if (this._baseUrl == null || this._pipelineId == null) {
10292
+ if (this._baseUrl == null) {
10288
10293
  return Promise.reject("endpoint not connected");
10289
10294
  }
10290
10295
  }
10296
+ if (this._sessionAccessToken) {
10297
+ session = {
10298
+ eyepopUrl: this.options().eyepopUrl,
10299
+ accessToken: this._sessionAccessToken,
10300
+ validUntil: this._sessionAccessTokenValidUntil || Number.MAX_VALUE
10301
+ };
10302
+ } else {
10303
+ session = await super.session();
10304
+ }
10291
10305
  return {
10292
10306
  eyepopUrl: session.eyepopUrl,
10293
10307
  accessToken: session.accessToken,
10294
10308
  validUntil: session.validUntil,
10295
10309
  popId: this.options().popId,
10296
10310
  baseUrl: this._baseUrl,
10297
- pipelineId: this._pipelineId,
10311
+ pipelineId: this._pipelineId || void 0,
10298
10312
  authenticationHeaders: () => this._authenticationHeaders(session)
10299
10313
  };
10300
10314
  }
@@ -10304,11 +10318,14 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10304
10318
  pop() {
10305
10319
  if (this._pipeline) {
10306
10320
  return this._pipeline.pop || null;
10307
- } else {
10308
- return null;
10309
10321
  }
10322
+ return this.options().pop || null;
10310
10323
  }
10311
10324
  async changePop(pop) {
10325
+ if (this.options().popId == "transient" /* Transient */) {
10326
+ await this.changeTransientPop(pop);
10327
+ return;
10328
+ }
10312
10329
  const client = this._client;
10313
10330
  const baseUrl = this._baseUrl;
10314
10331
  if (!baseUrl || !client) {
@@ -10331,6 +10348,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10331
10348
  const message = await response.text();
10332
10349
  throw new Error(`Unexpected status ${response.status}: ${message}`);
10333
10350
  }
10351
+ this.options().pop = pop;
10334
10352
  if (this._pipeline) {
10335
10353
  this._pipeline.pop = pop;
10336
10354
  } else {
@@ -10345,6 +10363,10 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10345
10363
  _authenticationHeaders(session) {
10346
10364
  return this._options.auth.isLocal !== void 0 ? {} : { Authorization: `Bearer ${session.accessToken}` };
10347
10365
  }
10366
+ /**
10367
+ * @deprecated Pop ids are only retained for backwards compatibility.
10368
+ * Configure transient sessions with `WorkerOptions.pop`.
10369
+ */
10348
10370
  popId() {
10349
10371
  return this.options().popId || null;
10350
10372
  }
@@ -10390,6 +10412,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10390
10412
  }
10391
10413
  }
10392
10414
  async uploadFile(source, params) {
10415
+ await this.ensureTransientPipelineStarted();
10393
10416
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10394
10417
  return Promise.reject("endpoint not connected, use connect()");
10395
10418
  }
@@ -10422,6 +10445,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10422
10445
  }
10423
10446
  }
10424
10447
  async uploadStream(source, params) {
10448
+ await this.ensureTransientPipelineStarted();
10425
10449
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10426
10450
  return Promise.reject("endpoint not connected, use connect()");
10427
10451
  }
@@ -10454,6 +10478,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10454
10478
  }
10455
10479
  }
10456
10480
  async uploadPath(source, params) {
10481
+ await this.ensureTransientPipelineStarted();
10457
10482
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10458
10483
  throw new Error("endpoint not connected, use connect()");
10459
10484
  }
@@ -10500,6 +10525,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10500
10525
  params
10501
10526
  );
10502
10527
  }
10528
+ await this.ensureTransientPipelineStarted();
10503
10529
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10504
10530
  throw new Error("endpoint not connected, use connect()");
10505
10531
  }
@@ -10529,6 +10555,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10529
10555
  }
10530
10556
  }
10531
10557
  async loadFromAssetUuid(source, params) {
10558
+ await this.ensureTransientPipelineStarted();
10532
10559
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10533
10560
  throw new Error("endpoint not connected, use connect()");
10534
10561
  }
@@ -10558,6 +10585,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10558
10585
  }
10559
10586
  }
10560
10587
  async loadMediaStream(source, params) {
10588
+ await this.ensureTransientPipelineStarted();
10561
10589
  if (!this._baseUrl || !this._pipelineId || !this._client || !this._limit) {
10562
10590
  throw new Error("endpoint not connected, use connect()");
10563
10591
  }
@@ -10600,7 +10628,9 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10600
10628
  async reconnect() {
10601
10629
  if (this.options().popId == "transient" /* Transient */) {
10602
10630
  await this.getComputeSession();
10603
- this._pipelineId = await this.startTransientPipeline();
10631
+ if (this.options().pop) {
10632
+ this.setTransientPipelinePop();
10633
+ }
10604
10634
  } else if (this.options().sessionUuid) {
10605
10635
  await this.getComputeSession();
10606
10636
  } else {
@@ -10697,29 +10727,65 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10697
10727
  }
10698
10728
  }
10699
10729
  }
10730
+ sessionReadyTimeoutMs() {
10731
+ const seconds = this.options().sessionReadyTimeoutSeconds;
10732
+ return typeof seconds == "number" && Number.isFinite(seconds) && seconds > 0 ? seconds * 1e3 : _WorkerEndpoint.WAIT_FOR_IS_READY;
10733
+ }
10734
+ sessionHealthReady(body, contentType) {
10735
+ if (contentType.includes("application/json")) {
10736
+ const health = JSON.parse(body);
10737
+ if (health && typeof health == "object") {
10738
+ if (health.message && !health.session_status) {
10739
+ return true;
10740
+ }
10741
+ return health.session_status == "running" /* RUNNING */;
10742
+ }
10743
+ }
10744
+ return contentType.includes("text/plain") && body.includes("I'm fine");
10745
+ }
10700
10746
  async getComputeSession() {
10701
10747
  if (!this._client) {
10702
10748
  throw new Error("endpoint not initialized");
10703
10749
  }
10704
10750
  let session;
10705
- let headers;
10706
10751
  const sessionUuid = this.options().sessionUuid;
10707
10752
  if (sessionUuid) {
10708
- [session, headers] = await this.getPermanentComputeSession(this._client, sessionUuid);
10753
+ session = await this.getPermanentComputeSession(this._client, sessionUuid);
10709
10754
  } else {
10710
- [session, headers] = await this.getOnDemandComputeSession(this._client);
10755
+ session = await this.getOnDemandComputeSession(this._client);
10711
10756
  }
10757
+ this.setComputeSessionAccessToken(session);
10758
+ const headers = {
10759
+ Authorization: await this.authorizationHeader()
10760
+ };
10712
10761
  let isReady = false;
10713
- const deadline = Date.now() + _WorkerEndpoint.WAIT_FOR_IS_READY;
10762
+ const readyTimeoutMs = this.sessionReadyTimeoutMs();
10763
+ const deadline = Date.now() + readyTimeoutMs;
10714
10764
  while (!isReady) {
10715
10765
  const health_url = `${session.session_endpoint}/health`;
10716
10766
  const response = await this._client.fetch(health_url, {
10717
- headers
10767
+ headers: {
10768
+ ...headers,
10769
+ Accept: "application/json"
10770
+ }
10718
10771
  });
10719
- if (response.status < 300) {
10720
- isReady = true;
10772
+ if (response.status == 200) {
10773
+ const contentType = response.headers.get("content-type") || "";
10774
+ const body = await response.text();
10775
+ try {
10776
+ isReady = this.sessionHealthReady(body, contentType);
10777
+ } catch (error) {
10778
+ this._logger.debug(`session ${session.session_uuid} health check returned invalid JSON, wait and poll for update`);
10779
+ }
10780
+ if (!isReady && Date.now() > deadline) {
10781
+ throw new Error(`Created session ${session.session_uuid} did not become healthy after ${readyTimeoutMs / 1e3} seconds`);
10782
+ }
10783
+ if (!isReady) {
10784
+ this._logger.debug(`session ${session.session_uuid} health check not ready, wait and poll for update`);
10785
+ await sleep(_WorkerEndpoint.CHECK_FOR_IS_READY_INTERVAL);
10786
+ }
10721
10787
  } else if (Date.now() > deadline) {
10722
- throw new Error(`Created session ${session.session_uuid} did not become healthy after ${_WorkerEndpoint.WAIT_FOR_IS_READY / 1e3} seconds`);
10788
+ throw new Error(`Created session ${session.session_uuid} did not become healthy after ${readyTimeoutMs / 1e3} seconds`);
10723
10789
  } else {
10724
10790
  this._logger.debug(`session ${session.session_uuid} health check status ${response.status}, wait and poll for update`);
10725
10791
  await sleep(_WorkerEndpoint.CHECK_FOR_IS_READY_INTERVAL);
@@ -10727,51 +10793,59 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10727
10793
  }
10728
10794
  this._baseUrl = session.session_endpoint;
10729
10795
  this._pipeline = null;
10730
- if (session.pipeline_uuid) {
10731
- this._pipelineId = session.pipeline_uuid;
10732
- } else if (session.pipelines) {
10733
- this._pipelineId = session.pipelines[0].pipeline_id;
10734
- } else {
10735
- this._pipelineId = null;
10796
+ this._pipelineId = this.pipelineIdFromSession(session);
10797
+ if (this.options().pop) {
10798
+ this.setTransientPipelinePop();
10736
10799
  }
10737
10800
  }
10738
10801
  async getOnDemandComputeSession(httpClient) {
10739
10802
  let session = null;
10740
10803
  const sessionsUrl = `${this.eyepopUrl()}/v1/sessions`;
10741
- this._requestLogger.debug("fetching sessions from: %s", sessionsUrl);
10742
10804
  const headers = {
10743
- Authorization: await this.authorizationHeader()
10805
+ Authorization: await this.computeAuthorizationHeader()
10744
10806
  };
10745
- let response = await httpClient.fetch(sessionsUrl, {
10746
- headers
10747
- });
10748
10807
  let sessions;
10749
- if (response.status == 404) {
10750
- sessions = [];
10751
- } else if (response.status != 200) {
10752
- this.updateState("Error" /* Error */);
10753
- const message = await response.text();
10754
- throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
10755
- } else {
10756
- const response_content = await response.json();
10757
- sessions = response_content;
10758
- }
10759
- if (sessions.length > 0) {
10760
- this._logger.debug(`User has ${sessions.length} sessions, inspecting for usable session`);
10761
- for (let s of sessions) {
10762
- if (!_WorkerEndpoint.SESSION_DEAD.has(s.session_status) && !s.persistent) {
10763
- session = s;
10764
- this._logger.debug(`Use active session ${s.session_uuid} with pipeline ${s.pipeline_uuid}`);
10765
- break;
10808
+ if (!this.options().pop) {
10809
+ this._requestLogger.debug("fetching sessions from: %s", sessionsUrl);
10810
+ const response = await httpClient.fetch(sessionsUrl, {
10811
+ headers
10812
+ });
10813
+ if (response.status == 404) {
10814
+ sessions = [];
10815
+ } else if (response.status != 200) {
10816
+ this.updateState("Error" /* Error */);
10817
+ const message = await response.text();
10818
+ throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
10819
+ } else {
10820
+ const response_content = await response.json();
10821
+ sessions = response_content;
10822
+ }
10823
+ if (sessions.length > 0) {
10824
+ this._logger.debug(`User has ${sessions.length} sessions, inspecting for usable session`);
10825
+ for (let s of sessions) {
10826
+ if (!_WorkerEndpoint.SESSION_DEAD.has(s.session_status) && !s.persistent) {
10827
+ session = s;
10828
+ this._logger.debug(`Use active session ${s.session_uuid} with pipeline ${this.pipelineIdFromSession(s)}`);
10829
+ break;
10830
+ }
10766
10831
  }
10767
10832
  }
10768
10833
  }
10769
10834
  if (!session) {
10770
10835
  this._requestLogger.debug("creating a new session at: %s", sessionsUrl);
10771
- response = await httpClient.fetch(`${sessionsUrl}?wait=true`, {
10772
- headers,
10836
+ const createBody = this.sessionCreateBody();
10837
+ const createHeaders = {
10838
+ ...headers,
10839
+ ...createBody ? { "Content-Type": "application/json" } : {}
10840
+ };
10841
+ const request = {
10842
+ headers: createHeaders,
10773
10843
  method: "POST"
10774
- });
10844
+ };
10845
+ if (createBody) {
10846
+ request.body = createBody;
10847
+ }
10848
+ const response = await httpClient.fetch(`${sessionsUrl}?wait=true`, request);
10775
10849
  if (response.status != 200) {
10776
10850
  this.updateState("Error" /* Error */);
10777
10851
  const message = await response.text();
@@ -10787,14 +10861,14 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10787
10861
  if (!session) {
10788
10862
  throw new Error("unexpected undefined session");
10789
10863
  }
10790
- return [session, headers];
10864
+ return session;
10791
10865
  }
10792
10866
  async getPermanentComputeSession(httpClient, sessionUuid) {
10793
10867
  let session = null;
10794
10868
  const sessionUrl = `${this.eyepopUrl()}/v1/sessions/${sessionUuid}`;
10795
10869
  this._requestLogger.debug("fetching session from: %s", sessionUrl);
10796
10870
  const headers = {
10797
- Authorization: await this.authorizationHeader()
10871
+ Authorization: await this.computeAuthorizationHeader()
10798
10872
  };
10799
10873
  let response = await httpClient.fetch(sessionUrl, {
10800
10874
  headers
@@ -10810,7 +10884,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10810
10884
  const response_content = await response.json();
10811
10885
  session = response_content;
10812
10886
  }
10813
- return [session, headers];
10887
+ return session;
10814
10888
  }
10815
10889
  async startTransientPipeline() {
10816
10890
  const client = this._client;
@@ -10819,12 +10893,12 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10819
10893
  throw new Error("endpoint not initialized");
10820
10894
  }
10821
10895
  let pop;
10822
- if (this._pipeline && this._pipeline.pop) {
10896
+ if (this.options().pop) {
10897
+ pop = this.options().pop;
10898
+ } else if (this._pipeline && this._pipeline.pop) {
10823
10899
  pop = this._pipeline.pop;
10824
10900
  } else {
10825
- pop = {
10826
- components: []
10827
- };
10901
+ throw new Error("Cannot start a transient pipeline without a pop");
10828
10902
  }
10829
10903
  const body = {
10830
10904
  pop,
@@ -10836,8 +10910,9 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10836
10910
  videoOutput: "no_output"
10837
10911
  };
10838
10912
  const post_url = `${baseUrl.replace(/\/+$/, "")}/pipelines`;
10839
- let response = await this.fetchWithRetry(async () => {
10913
+ const response = await this.fetchWithRetry(async () => {
10840
10914
  let headers = {
10915
+ Accept: "application/json",
10841
10916
  "Content-Type": "application/json",
10842
10917
  Authorization: await this.authorizationHeader()
10843
10918
  };
@@ -10849,11 +10924,138 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10849
10924
  });
10850
10925
  if (response.status != 200) {
10851
10926
  const message = await response.text();
10852
- throw new Error(`Unexpected status ${response.status}: ${message}`);
10927
+ throw new Error(`Unexpected status ${response.status} starting transient pipeline: ${message.slice(0, 300)}`);
10853
10928
  }
10854
10929
  const result = await response.json();
10855
10930
  return result["id"];
10856
10931
  }
10932
+ async ensureTransientPipelineStarted() {
10933
+ if (this.options().popId != "transient" /* Transient */ || this._pipelineId) {
10934
+ return;
10935
+ }
10936
+ if (!this.options().pop) {
10937
+ return;
10938
+ }
10939
+ if (!this._baseUrl) {
10940
+ await this.reconnect();
10941
+ }
10942
+ if (this._pipelineId) {
10943
+ return;
10944
+ }
10945
+ if (!this._pipelineCreatePromise) {
10946
+ this._pipelineCreatePromise = this.startTransientPipeline();
10947
+ }
10948
+ try {
10949
+ this._pipelineId = await this._pipelineCreatePromise;
10950
+ this.setTransientPipelinePop();
10951
+ } finally {
10952
+ this._pipelineCreatePromise = null;
10953
+ }
10954
+ }
10955
+ async changeTransientPop(pop) {
10956
+ if (!this._client) {
10957
+ throw new Error("endpoint not initialized");
10958
+ }
10959
+ const previousPop = this.options().pop;
10960
+ const previousPipeline = this._pipeline;
10961
+ if (this._pipelineId) {
10962
+ await this.deleteTransientPipeline(this._pipelineId);
10963
+ this._pipelineId = null;
10964
+ }
10965
+ this._pipeline = null;
10966
+ try {
10967
+ this.options().pop = pop;
10968
+ await this.ensureTransientPipelineStarted();
10969
+ } catch (error) {
10970
+ this.options().pop = previousPop;
10971
+ this._pipeline = previousPipeline;
10972
+ throw error;
10973
+ }
10974
+ if (!this._pipelineId) {
10975
+ throw new Error("Compute session did not provide a pipeline for the requested pop");
10976
+ }
10977
+ this.setTransientPipelinePop();
10978
+ }
10979
+ async deleteTransientPipeline(pipelineId) {
10980
+ if (!this._client || !this._baseUrl) {
10981
+ return;
10982
+ }
10983
+ const deleteUrl = `${this._baseUrl}/pipelines/${pipelineId}`;
10984
+ const headers = {
10985
+ Authorization: await this.authorizationHeader()
10986
+ };
10987
+ let response = await this._client.fetch(deleteUrl, {
10988
+ method: "DELETE",
10989
+ headers
10990
+ });
10991
+ if (response.status >= 300) {
10992
+ const message = await response.text();
10993
+ this._logger.info(`stopping pipeline failed, status ${response.status}: ${message}`);
10994
+ }
10995
+ }
10996
+ pipelineIdFromSession(session) {
10997
+ if (session.pipeline_uuid) {
10998
+ return session.pipeline_uuid;
10999
+ }
11000
+ const pipeline = session.pipelines?.[0];
11001
+ return pipeline?.id || pipeline?.pipeline_id || null;
11002
+ }
11003
+ async authorizationHeader() {
11004
+ if (this._sessionAccessToken) {
11005
+ return `Bearer ${this._sessionAccessToken}`;
11006
+ }
11007
+ return super.authorizationHeader();
11008
+ }
11009
+ async computeAuthorizationHeader() {
11010
+ if (this.options().auth.isLocal !== void 0) {
11011
+ return "Implicit";
11012
+ }
11013
+ if (this.options().auth.apiKey !== void 0) {
11014
+ return `Bearer ${this.options().auth.apiKey}`;
11015
+ }
11016
+ return super.authorizationHeader();
11017
+ }
11018
+ setComputeSessionAccessToken(session) {
11019
+ if (!session.access_token) {
11020
+ throw new Error(`Compute session ${session.session_uuid} did not provide an access token`);
11021
+ }
11022
+ this._sessionAccessToken = session.access_token;
11023
+ if (session.access_token_expires_at) {
11024
+ const expiresAt = Date.parse(session.access_token_expires_at);
11025
+ this._sessionAccessTokenValidUntil = Number.isNaN(expiresAt) ? null : expiresAt;
11026
+ } else if (session.access_token_expires_in) {
11027
+ this._sessionAccessTokenValidUntil = Date.now() + session.access_token_expires_in * 1e3;
11028
+ } else {
11029
+ this._sessionAccessTokenValidUntil = null;
11030
+ }
11031
+ }
11032
+ setTransientPipelinePop() {
11033
+ const pop = this.options().pop;
11034
+ if (pop && this._pipelineId) {
11035
+ this._pipeline = {
11036
+ id: this._pipelineId,
11037
+ state: "idle",
11038
+ startTime: (/* @__PURE__ */ new Date()).toString(),
11039
+ pop
11040
+ };
11041
+ }
11042
+ }
11043
+ sessionCreateBody() {
11044
+ const body = {};
11045
+ if (this.options().sessionName) {
11046
+ body.session_name = this.options().sessionName;
11047
+ }
11048
+ if (this.options().pipelineImage) {
11049
+ body.pipeline_image = this.options().pipelineImage;
11050
+ }
11051
+ if (this.options().pipelineVersion) {
11052
+ body.pipeline_version = this.options().pipelineVersion;
11053
+ }
11054
+ if (this.options().pop) {
11055
+ body.pop = this.options().pop;
11056
+ }
11057
+ return Object.keys(body).length > 0 ? JSON.stringify(body) : void 0;
11058
+ }
10857
11059
  };
10858
11060
  _WorkerEndpoint.SESSION_DEAD = /* @__PURE__ */ new Set(["error" /* ERROR */, "failed" /* FAILED */, "stopped" /* STOPPED */, "pipeline_error" /* PIPELINE_ERROR */, "unknown" /* UNKNOWN */]);
10859
11061
  _WorkerEndpoint.WAIT_FOR_IS_READY = 60 * 1e3;
@@ -12231,6 +12433,15 @@ var EyePop;
12231
12433
  if (opts.sessionUuid === void 0) {
12232
12434
  opts.sessionUuid = readEnv("EYEPOP_SESSION_UUID");
12233
12435
  }
12436
+ if (opts.sessionName === void 0) {
12437
+ opts.sessionName = readEnv("EYEPOP_SESSION_NAME");
12438
+ }
12439
+ if (opts.pipelineImage === void 0) {
12440
+ opts.pipelineImage = readEnv("EYEPOP_PIPELINE_IMAGE");
12441
+ }
12442
+ if (opts.pipelineVersion === void 0) {
12443
+ opts.pipelineVersion = readEnv("EYEPOP_PIPELINE_VERSION");
12444
+ }
12234
12445
  if (opts.popId === void 0 && opts.sessionUuid === void 0) {
12235
12446
  opts.popId = readEnv("EYEPOP_POP_ID") || "transient" /* Transient */;
12236
12447
  }