@eyepop.ai/eyepop 3.14.6 → 3.15.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/README.md +133 -236
- package/dist/eyepop.index.d.mts +11 -8
- package/dist/eyepop.index.d.ts +11 -8
- package/dist/eyepop.index.js +76 -29
- package/dist/eyepop.index.js.map +1 -1
- package/dist/eyepop.index.mjs +75 -29
- package/dist/eyepop.index.mjs.map +1 -1
- package/dist/eyepop.min.js +1 -1
- package/package.json +1 -1
package/dist/eyepop.index.mjs
CHANGED
|
@@ -10517,8 +10517,10 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
10517
10517
|
}
|
|
10518
10518
|
async reconnect() {
|
|
10519
10519
|
if (this.options().popId == "transient" /* Transient */) {
|
|
10520
|
-
await this.
|
|
10520
|
+
await this.getComputeSession();
|
|
10521
10521
|
this._pipelineId = await this.startTransientPipeline();
|
|
10522
|
+
} else if (this.options().sessionUuid) {
|
|
10523
|
+
await this.getComputeSession();
|
|
10522
10524
|
} else {
|
|
10523
10525
|
await this.startWebApiSessionWithPopId();
|
|
10524
10526
|
}
|
|
@@ -10613,17 +10615,52 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
10613
10615
|
}
|
|
10614
10616
|
}
|
|
10615
10617
|
}
|
|
10616
|
-
async
|
|
10618
|
+
async getComputeSession() {
|
|
10617
10619
|
if (!this._client) {
|
|
10618
10620
|
throw new Error("endpoint not initialized");
|
|
10619
10621
|
}
|
|
10622
|
+
let session;
|
|
10623
|
+
let headers;
|
|
10624
|
+
const sessionUuid = this.options().sessionUuid;
|
|
10625
|
+
if (sessionUuid) {
|
|
10626
|
+
[session, headers] = await this.getPermanentComputeSession(this._client, sessionUuid);
|
|
10627
|
+
} else {
|
|
10628
|
+
[session, headers] = await this.getOnDemandComputeSession(this._client);
|
|
10629
|
+
}
|
|
10630
|
+
let isReady = false;
|
|
10631
|
+
const deadline = Date.now() + _WorkerEndpoint.WAIT_FOR_IS_READY;
|
|
10632
|
+
while (!isReady) {
|
|
10633
|
+
const health_url = `${session.session_endpoint}/health`;
|
|
10634
|
+
const response = await this._client.fetch(health_url, {
|
|
10635
|
+
headers
|
|
10636
|
+
});
|
|
10637
|
+
if (response.status < 300) {
|
|
10638
|
+
isReady = true;
|
|
10639
|
+
} else if (Date.now() > deadline) {
|
|
10640
|
+
throw new Error(`Created session ${session.session_uuid} did not become healthy after ${_WorkerEndpoint.WAIT_FOR_IS_READY / 1e3} seconds`);
|
|
10641
|
+
} else {
|
|
10642
|
+
this._logger.debug(`session ${session.session_uuid} health check status ${response.status}, wait and poll for update`);
|
|
10643
|
+
await sleep(_WorkerEndpoint.CHECK_FOR_IS_READY_INTERVAL);
|
|
10644
|
+
}
|
|
10645
|
+
}
|
|
10646
|
+
this._baseUrl = session.session_endpoint;
|
|
10647
|
+
this._pipeline = null;
|
|
10648
|
+
if (session.pipeline_uuid) {
|
|
10649
|
+
this._pipelineId = session.pipeline_uuid;
|
|
10650
|
+
} else if (session.pipelines) {
|
|
10651
|
+
this._pipelineId = session.pipelines[0].pipeline_id;
|
|
10652
|
+
} else {
|
|
10653
|
+
this._pipelineId = null;
|
|
10654
|
+
}
|
|
10655
|
+
}
|
|
10656
|
+
async getOnDemandComputeSession(httpClient) {
|
|
10620
10657
|
let session = null;
|
|
10621
10658
|
const sessionsUrl = `${this.eyepopUrl()}/v1/sessions`;
|
|
10622
10659
|
this._requestLogger.debug("fetching sessions from: %s", sessionsUrl);
|
|
10623
10660
|
const headers = {
|
|
10624
10661
|
Authorization: await this.authorizationHeader()
|
|
10625
10662
|
};
|
|
10626
|
-
let response = await
|
|
10663
|
+
let response = await httpClient.fetch(sessionsUrl, {
|
|
10627
10664
|
headers
|
|
10628
10665
|
});
|
|
10629
10666
|
let sessions;
|
|
@@ -10637,11 +10674,10 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
10637
10674
|
const response_content = await response.json();
|
|
10638
10675
|
sessions = response_content;
|
|
10639
10676
|
}
|
|
10640
|
-
console.log(sessions);
|
|
10641
10677
|
if (sessions.length > 0) {
|
|
10642
|
-
this._logger.debug(`User has ${sessions.length} sessions, inspecting for
|
|
10678
|
+
this._logger.debug(`User has ${sessions.length} sessions, inspecting for usable session`);
|
|
10643
10679
|
for (let s of sessions) {
|
|
10644
|
-
if (!_WorkerEndpoint.SESSION_DEAD.has(s.session_status)) {
|
|
10680
|
+
if (!_WorkerEndpoint.SESSION_DEAD.has(s.session_status) && !s.persistent) {
|
|
10645
10681
|
session = s;
|
|
10646
10682
|
this._logger.debug(`Use active session ${s.session_uuid} with pipeline ${s.pipeline_uuid}`);
|
|
10647
10683
|
break;
|
|
@@ -10650,7 +10686,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
10650
10686
|
}
|
|
10651
10687
|
if (!session) {
|
|
10652
10688
|
this._requestLogger.debug("creating a new session at: %s", sessionsUrl);
|
|
10653
|
-
response = await
|
|
10689
|
+
response = await httpClient.fetch(`${sessionsUrl}?wait=true`, {
|
|
10654
10690
|
headers,
|
|
10655
10691
|
method: "POST"
|
|
10656
10692
|
});
|
|
@@ -10669,29 +10705,30 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
|
|
|
10669
10705
|
if (!session) {
|
|
10670
10706
|
throw new Error("unexpected undefined session");
|
|
10671
10707
|
}
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
}
|
|
10687
|
-
}
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
this._pipelineId = session.pipeline_uuid;
|
|
10708
|
+
return [session, headers];
|
|
10709
|
+
}
|
|
10710
|
+
async getPermanentComputeSession(httpClient, sessionUuid) {
|
|
10711
|
+
let session = null;
|
|
10712
|
+
const sessionUrl = `${this.eyepopUrl()}/v1/sessions/${sessionUuid}`;
|
|
10713
|
+
this._requestLogger.debug("fetching session from: %s", sessionUrl);
|
|
10714
|
+
const headers = {
|
|
10715
|
+
Authorization: await this.authorizationHeader()
|
|
10716
|
+
};
|
|
10717
|
+
let response = await httpClient.fetch(sessionUrl, {
|
|
10718
|
+
headers
|
|
10719
|
+
});
|
|
10720
|
+
if (response.status == 404) {
|
|
10721
|
+
this.updateState("Error" /* Error */);
|
|
10722
|
+
throw new Error(`Unexpected status ${response.status} compute sessions ${sessionUuid} not found`);
|
|
10723
|
+
} else if (response.status != 200) {
|
|
10724
|
+
this.updateState("Error" /* Error */);
|
|
10725
|
+
const message = await response.text();
|
|
10726
|
+
throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
|
|
10692
10727
|
} else {
|
|
10693
|
-
|
|
10728
|
+
const response_content = await response.json();
|
|
10729
|
+
session = response_content;
|
|
10694
10730
|
}
|
|
10731
|
+
return [session, headers];
|
|
10695
10732
|
}
|
|
10696
10733
|
async startTransientPipeline() {
|
|
10697
10734
|
const client = this._client;
|
|
@@ -10997,6 +11034,11 @@ var TaskType = /* @__PURE__ */ ((TaskType2) => {
|
|
|
10997
11034
|
TaskType2["classification"] = "classification";
|
|
10998
11035
|
return TaskType2;
|
|
10999
11036
|
})(TaskType || {});
|
|
11037
|
+
var TaskMode = /* @__PURE__ */ ((TaskMode2) => {
|
|
11038
|
+
TaskMode2["image"] = "image";
|
|
11039
|
+
TaskMode2["video"] = "video";
|
|
11040
|
+
return TaskMode2;
|
|
11041
|
+
})(TaskMode || {});
|
|
11000
11042
|
var VlmAbilityStatus = /* @__PURE__ */ ((VlmAbilityStatus2) => {
|
|
11001
11043
|
VlmAbilityStatus2["in_progress"] = "in_progress";
|
|
11002
11044
|
VlmAbilityStatus2["draft"] = "draft";
|
|
@@ -12104,7 +12146,10 @@ var EyePop;
|
|
|
12104
12146
|
throw new Error("auth option or EYEPOP_API_KEY environment variable is required");
|
|
12105
12147
|
}
|
|
12106
12148
|
}
|
|
12107
|
-
if (opts.
|
|
12149
|
+
if (opts.sessionUuid === void 0) {
|
|
12150
|
+
opts.sessionUuid = readEnv("EYEPOP_SESSION_UUID");
|
|
12151
|
+
}
|
|
12152
|
+
if (opts.popId === void 0 && opts.sessionUuid === void 0) {
|
|
12108
12153
|
opts.popId = readEnv("EYEPOP_POP_ID") || "transient" /* Transient */;
|
|
12109
12154
|
}
|
|
12110
12155
|
if (opts.autoStart === void 0) {
|
|
@@ -12227,6 +12272,7 @@ export {
|
|
|
12227
12272
|
Semaphore,
|
|
12228
12273
|
SessionStatus,
|
|
12229
12274
|
Stream,
|
|
12275
|
+
TaskMode,
|
|
12230
12276
|
TaskType,
|
|
12231
12277
|
TranscodeMode,
|
|
12232
12278
|
TransientPopId,
|