@eyepop.ai/eyepop 0.17.0 → 0.18.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/eyepop.index.d.mts +8 -1
- package/dist/eyepop.index.d.ts +8 -1
- package/dist/eyepop.index.js +119 -3
- package/dist/eyepop.index.js.map +1 -1
- package/dist/eyepop.index.mjs +119 -3
- 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
|
@@ -9792,6 +9792,7 @@ var Endpoint = class {
|
|
|
9792
9792
|
this._expire_token_time = null;
|
|
9793
9793
|
this._client = null;
|
|
9794
9794
|
this._state = "Idle" /* Idle */;
|
|
9795
|
+
this._pipeline = null;
|
|
9795
9796
|
this._stateChangeHandler = null;
|
|
9796
9797
|
this._ingressEventHandler = null;
|
|
9797
9798
|
this._ingressEventWs = null;
|
|
@@ -9821,6 +9822,40 @@ var Endpoint = class {
|
|
|
9821
9822
|
popName() {
|
|
9822
9823
|
return this._popName;
|
|
9823
9824
|
}
|
|
9825
|
+
popComp() {
|
|
9826
|
+
if (this._pipeline) {
|
|
9827
|
+
return this._pipeline.inferPipeline;
|
|
9828
|
+
} else {
|
|
9829
|
+
return null;
|
|
9830
|
+
}
|
|
9831
|
+
}
|
|
9832
|
+
async changePopComp(popComp) {
|
|
9833
|
+
if (!this._baseUrl || !this._client) {
|
|
9834
|
+
return Promise.reject("endpoint not connected, use connect() before changePopComp()");
|
|
9835
|
+
}
|
|
9836
|
+
const patch_url = `${this._baseUrl}/pipelines/${this._pipelineId}/inferencePipeline`;
|
|
9837
|
+
const headers = {
|
|
9838
|
+
"Authorization": await this.authorizationHeader(),
|
|
9839
|
+
"Content-Type": "application/json"
|
|
9840
|
+
};
|
|
9841
|
+
const body = {
|
|
9842
|
+
"pipeline": popComp
|
|
9843
|
+
};
|
|
9844
|
+
this._requestLogger.debug("before PATCH %s", patch_url);
|
|
9845
|
+
let response = await this._client.fetch(patch_url, {
|
|
9846
|
+
method: "PATCH",
|
|
9847
|
+
body: JSON.stringify(body),
|
|
9848
|
+
headers
|
|
9849
|
+
});
|
|
9850
|
+
if (response.status != 204) {
|
|
9851
|
+
const message = await response.text();
|
|
9852
|
+
return Promise.reject(`Unexpected status ${response.status}: ${message}`);
|
|
9853
|
+
}
|
|
9854
|
+
this._requestLogger.debug("after PATCH %s", patch_url);
|
|
9855
|
+
if (this._pipeline) {
|
|
9856
|
+
this._pipeline.inferPipeline = popComp;
|
|
9857
|
+
}
|
|
9858
|
+
}
|
|
9824
9859
|
popId() {
|
|
9825
9860
|
return this._options.popId || null;
|
|
9826
9861
|
}
|
|
@@ -10120,7 +10155,12 @@ var Endpoint = class {
|
|
|
10120
10155
|
if (!this._client) {
|
|
10121
10156
|
return Promise.reject("endpoint not initialized");
|
|
10122
10157
|
}
|
|
10123
|
-
|
|
10158
|
+
let config_url;
|
|
10159
|
+
if (this._options.popId == "transient" /* Transient */) {
|
|
10160
|
+
config_url = `${this.eyepopUrl()}/workers/config`;
|
|
10161
|
+
} else {
|
|
10162
|
+
config_url = `${this.eyepopUrl()}/pops/${this._options.popId}/config?auto_start=false`;
|
|
10163
|
+
}
|
|
10124
10164
|
const headers = {
|
|
10125
10165
|
"Authorization": await this.authorizationHeader()
|
|
10126
10166
|
};
|
|
@@ -10165,13 +10205,35 @@ var Endpoint = class {
|
|
|
10165
10205
|
}
|
|
10166
10206
|
const baseUrl = new URL(config.base_url, this.eyepopUrl());
|
|
10167
10207
|
this._baseUrl = baseUrl.toString();
|
|
10168
|
-
this.
|
|
10169
|
-
|
|
10208
|
+
if (this._options.popId == "transient" /* Transient */) {
|
|
10209
|
+
this._pipelineId = await this.startPopLessPipeline();
|
|
10210
|
+
this._popName = this._options.popId;
|
|
10211
|
+
} else {
|
|
10212
|
+
this._pipelineId = config.pipeline_id;
|
|
10213
|
+
this._popName = config.name;
|
|
10214
|
+
}
|
|
10170
10215
|
this._requestLogger.debug("after GET %s: %s / %s", config_url, this._baseUrl, this._pipelineId);
|
|
10171
10216
|
if (!this._pipelineId || !this._baseUrl) {
|
|
10172
10217
|
return Promise.reject(`Pop not started`);
|
|
10173
10218
|
}
|
|
10174
10219
|
this._baseUrl = this._baseUrl.replace(/\/+$/, "");
|
|
10220
|
+
if (this._baseUrl) {
|
|
10221
|
+
const get_url = `${this._baseUrl}/pipelines/${this._pipelineId}`;
|
|
10222
|
+
const headers2 = {
|
|
10223
|
+
"Authorization": await this.authorizationHeader()
|
|
10224
|
+
};
|
|
10225
|
+
this._requestLogger.debug("before GET %s", get_url);
|
|
10226
|
+
let response2 = await this._client.fetch(get_url, {
|
|
10227
|
+
method: "GET",
|
|
10228
|
+
headers: headers2
|
|
10229
|
+
});
|
|
10230
|
+
if (response2.status > 200) {
|
|
10231
|
+
const message = await response2.text();
|
|
10232
|
+
return Promise.reject(`Unexpected status ${response2.status}: ${message}`);
|
|
10233
|
+
}
|
|
10234
|
+
this._requestLogger.debug("after GET %s", get_url);
|
|
10235
|
+
this._pipeline = await response2.json();
|
|
10236
|
+
}
|
|
10175
10237
|
this.updateState();
|
|
10176
10238
|
return Promise.resolve(this);
|
|
10177
10239
|
}
|
|
@@ -10226,6 +10288,60 @@ var Endpoint = class {
|
|
|
10226
10288
|
this._logger.debug("using access token, valid for at least %d seconds", this._expire_token_time - now);
|
|
10227
10289
|
return this._token;
|
|
10228
10290
|
}
|
|
10291
|
+
async startPopLessPipeline() {
|
|
10292
|
+
if (this._client == null || this._baseUrl == null) {
|
|
10293
|
+
return Promise.reject("endpoint not initialized");
|
|
10294
|
+
}
|
|
10295
|
+
this.updateState("StartingPop" /* StartingPop */);
|
|
10296
|
+
let pipeline;
|
|
10297
|
+
if (this._pipeline) {
|
|
10298
|
+
pipeline = this._pipeline.inferPipeline;
|
|
10299
|
+
} else {
|
|
10300
|
+
pipeline = "identity";
|
|
10301
|
+
}
|
|
10302
|
+
const body = {
|
|
10303
|
+
"inferPipelineDef": {
|
|
10304
|
+
"pipeline": pipeline
|
|
10305
|
+
},
|
|
10306
|
+
"source": {
|
|
10307
|
+
"sourceType": "NONE"
|
|
10308
|
+
},
|
|
10309
|
+
"idleTimeoutSeconds": 30,
|
|
10310
|
+
"logging": ["out_meta"],
|
|
10311
|
+
"videoOutput": "no_output"
|
|
10312
|
+
};
|
|
10313
|
+
const post_url = `${this._baseUrl.replace(/\/+$/, "")}/pipelines`;
|
|
10314
|
+
let headers = {
|
|
10315
|
+
"Content-Type": "application/json",
|
|
10316
|
+
"Authorization": await this.authorizationHeader()
|
|
10317
|
+
};
|
|
10318
|
+
this._requestLogger.debug("before POST %s", post_url);
|
|
10319
|
+
let response = await this._client.fetch(post_url, {
|
|
10320
|
+
method: "POST",
|
|
10321
|
+
headers,
|
|
10322
|
+
body: JSON.stringify(body)
|
|
10323
|
+
});
|
|
10324
|
+
if (response.status == 401) {
|
|
10325
|
+
this._requestLogger.debug("after GET %s: 401, about to retry with fresh access token", post_url);
|
|
10326
|
+
this._token = null;
|
|
10327
|
+
headers = {
|
|
10328
|
+
"Content-Type": "application/json",
|
|
10329
|
+
"Authorization": await this.authorizationHeader()
|
|
10330
|
+
};
|
|
10331
|
+
response = await this._client.fetch(post_url, {
|
|
10332
|
+
method: "POST",
|
|
10333
|
+
headers,
|
|
10334
|
+
body: JSON.stringify(body)
|
|
10335
|
+
});
|
|
10336
|
+
}
|
|
10337
|
+
if (response.status != 200) {
|
|
10338
|
+
const message = await response.text();
|
|
10339
|
+
return Promise.reject(`Unexpected status ${response.status}: ${message}`);
|
|
10340
|
+
}
|
|
10341
|
+
this._requestLogger.debug("after POST %s", post_url);
|
|
10342
|
+
const pipelineId = (await response.json())["id"];
|
|
10343
|
+
return pipelineId;
|
|
10344
|
+
}
|
|
10229
10345
|
};
|
|
10230
10346
|
|
|
10231
10347
|
// index.ts
|