@eyepop.ai/eyepop 3.14.7 → 3.15.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.
@@ -60,24 +60,35 @@ interface Prediction extends StreamTime {
60
60
  */
61
61
  source_height: number;
62
62
  source_id?: string;
63
+ source_url?: string;
64
+ source_type?: string;
65
+ system_timestamp?: number;
63
66
  objects?: Array<PredictedObject>;
64
67
  classes?: Array<PredictedClass>;
65
68
  texts?: Array<PredictedText>;
66
69
  meshs?: Array<PredictedMesh>;
67
70
  keyPoints?: Array<PredictedKeyPoints>;
71
+ embeddings?: Array<PredictedEmbedding>;
72
+ motions?: Array<PredictedMotion>;
68
73
  }
69
74
  interface PredictedClass {
70
75
  id?: number;
71
- confidence: number;
76
+ confidence?: number;
72
77
  classLabel: string;
73
78
  category?: string;
74
79
  }
75
80
  interface PredictedText {
76
81
  id?: number;
77
- confidence: number;
82
+ confidence?: number;
78
83
  text: string;
79
84
  category?: string;
80
85
  }
86
+ interface PredictedEmbedding {
87
+ x?: number;
88
+ y?: number;
89
+ embedding: Array<number>;
90
+ category?: string;
91
+ }
81
92
  interface Contour {
82
93
  points: Array<Point2d>;
83
94
  cutouts: Array<Array<Point2d>>;
@@ -89,41 +100,45 @@ interface Mask {
89
100
  stride: number;
90
101
  }
91
102
  interface PredictedObject extends PredictedClass {
92
- trackId: number | undefined;
103
+ trackId?: number;
93
104
  x: number;
94
105
  y: number;
95
106
  width: number;
96
107
  height: number;
97
108
  orientation?: number;
98
- outline: Array<Point2d> | undefined;
99
- contours: Array<Contour> | undefined;
100
- mask: Mask | undefined;
101
- objects: Array<PredictedObject> | undefined;
102
- classes: Array<PredictedClass> | undefined;
103
- texts: Array<PredictedText> | undefined;
104
- meshs: Array<PredictedMesh> | undefined;
105
- keyPoints: Array<PredictedKeyPoints> | undefined;
109
+ outline?: Array<Point2d>;
110
+ contours?: Array<Contour>;
111
+ mask?: Mask;
112
+ objects?: Array<PredictedObject>;
113
+ classes?: Array<PredictedClass>;
114
+ texts?: Array<PredictedText>;
115
+ meshs?: Array<PredictedMesh>;
116
+ keyPoints?: Array<PredictedKeyPoints>;
106
117
  }
107
118
  interface Point2d {
108
119
  x: number;
109
120
  y: number;
110
121
  }
111
122
  interface PredictedMesh {
112
- category: string;
113
- id: number;
114
- confidence: number;
123
+ category?: string;
124
+ id?: number;
125
+ confidence?: number;
115
126
  points: Array<Point3d>;
116
127
  }
117
128
  interface Point3d extends Point2d {
118
- z: number | undefined;
129
+ z?: number;
119
130
  }
120
131
  interface PredictedKeyPoints {
121
- category: string;
122
- type: string;
132
+ category?: string;
133
+ type?: string;
123
134
  points: Array<PredictedKeyPoint>;
124
135
  }
125
- interface PredictedKeyPoint extends Point3d, PredictedClass {
126
- visible: boolean | undefined;
136
+ interface PredictedKeyPoint extends Point3d {
137
+ id?: number;
138
+ confidence?: number;
139
+ classLabel?: string;
140
+ category?: string;
141
+ visible?: boolean;
127
142
  }
128
143
  interface PredictedMotion {
129
144
  begin_timestamp: number;
@@ -941,11 +956,6 @@ interface PlatformSupport {
941
956
  }
942
957
  interface Options {
943
958
  auth?: Authentication | undefined;
944
- /**
945
- * Override the default base URL for the API, e.g., "https://api.eyepop.ai/"
946
- *
947
- * Defaults to process.env['EYEPOP_URL'].
948
- */
949
959
  eyepopUrl?: string | undefined;
950
960
  jobQueueLength?: number;
951
961
  logger?: Logger | undefined;
@@ -1063,9 +1073,10 @@ declare enum TransientPopId {
1063
1073
  }
1064
1074
  interface WorkerOptions extends Options {
1065
1075
  /**
1066
- * TODO: deprecated, defaults to process.env['EYEPOP_POP_ID'].
1076
+ * TODO: deprecated, support for pop id will be removed in 3.16
1067
1077
  */
1068
1078
  popId?: string | TransientPopId | undefined;
1079
+ sessionUuid?: string | undefined;
1069
1080
  autoStart?: boolean;
1070
1081
  stopJobs?: boolean;
1071
1082
  isLocalMode?: boolean;
@@ -1130,7 +1141,9 @@ declare class WorkerEndpoint extends Endpoint<WorkerEndpoint> {
1130
1141
  private static SESSION_DEAD;
1131
1142
  private static WAIT_FOR_IS_READY;
1132
1143
  private static CHECK_FOR_IS_READY_INTERVAL;
1133
- private startComputeSession;
1144
+ private getComputeSession;
1145
+ private getOnDemandComputeSession;
1146
+ private getPermanentComputeSession;
1134
1147
  private startTransientPipeline;
1135
1148
  }
1136
1149
 
@@ -1405,4 +1418,4 @@ declare namespace EyePop {
1405
1418
  function dataEndpoint(opts?: DataOptions): DataEndpoint;
1406
1419
  }
1407
1420
 
1408
- export { type AbilityAliasEntry, AbstractJob, type AliasResolution, type Annotation, AnnotationInclusionMode, AnnotationType, type ApiKeyAuth, type Area, AreaType, ArtifactType, type Asset, type AssetImport, AssetInclusionMode, AssetStatus, AssetUrlType, type AssetUuidSource, type Auth0Options, type Authentication, type AutoAnnotate, type AutoAnnotateParams, type AutoAnnotatePrompt, AutoAnnotateStatus, AutoAnnotateTask, type AutoPromptConfig, type AutoTask, type BaseArea, type BaseComponent, type BaseTask, type Box, type ChangeEvent, ChangeType, type ClassificationTask, type ComponentFinderComponent, type ComponentParams, type Contour, type ContourArea, type ContourFinderComponent, ContourType, type CreateWorkflow, type CreateWorkflowConfig, DEFAULT_PREDICTION_VERSION, DataApiType, DataEndpoint, type DataOptions, type DataSession, type Dataset, type DatasetAutoAnnotate, type DatasetAutoAnnotateCreate, type DatasetAutoAnnotateUpdate, type DatasetCreate, type DatasetHeroAssetUpdate, type DatasetParent, type DatasetUpdate, type DatasetVersion, type DatasetVersionAssetStats, type DownloadResponse, Endpoint, EndpointState, type EvaluateConfig, type EvaluateFilter, type EvaluateRequest, type EvaluateResponse, type EvaluateRunInfo, EvaluationStatus, ExportedBy, EyePop, EyepopLineDecoder, type FileSource, type ForwardComponent, ForwardOperatorType, type HttpClient, type InferRequest, type InferRunInfo, type InferRuntimeConfig, type InferenceComponent, InferenceType, type ListWorkFlowItem, type ListWorkFlowItemMetadata, type ListWorkflowItemMetadataLabels, LoadFromAssetUuidJob, LoadFromJob, LoadMediaStreamJob, type LocalAuth, type Mask, type MediaStreamSource, type Model, type ModelCreate, type ModelExport, ModelExportStatus, ModelFormat, type ModelMetrics, ModelPrecisionType, type ModelSample, ModelStatus, ModelTask, type ModelTrainingProgress, ModelTrainingStage, ModelType, type ModelUpdate, type MotionDetectConfig, MotionModel, type OAuth2Auth, type OnChangeEvent, type Options, type PathSource, type PlatformSupport, type Point2d, type Point3d, type Pop, type PopComponent, PopComponentType, type PopCrop, type PopForward, type PopForwardOperator, type PredictedClass, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedMotion, type PredictedObject, type PredictedText, type Prediction, PredictionVersion, type ProcessParams, type ProcessRequest, type QcAiHubExportParams, type RectangleArea, type ResultStream, type Roi, Semaphore, type Session, type SessionAuth, SessionStatus, type Source, Stream, type StreamEvent, type StreamSource, type StreamTime, TaskMode, TaskType, type TimeSpan, type TrackingComponent, TranscodeMode, type TransformInto, TransientPopId, UploadJob, type UrlSource, UserReview, VideoMode, type VlmAbility, type VlmAbilityCreate, type VlmAbilityGroup, type VlmAbilityGroupCreate, type VlmAbilityGroupUpdate, VlmAbilityStatus, type VlmAbilityUpdate, WebrtcBase, WebrtcWhep, WebrtcWhip, WorkerEndpoint, type WorkerOptions, type WorkerSession, type Workflow, WorkflowPhase, EyePop as default, getBaseUrl, readableStreamFromString };
1421
+ export { type AbilityAliasEntry, AbstractJob, type AliasResolution, type Annotation, AnnotationInclusionMode, AnnotationType, type ApiKeyAuth, type Area, AreaType, ArtifactType, type Asset, type AssetImport, AssetInclusionMode, AssetStatus, AssetUrlType, type AssetUuidSource, type Auth0Options, type Authentication, type AutoAnnotate, type AutoAnnotateParams, type AutoAnnotatePrompt, AutoAnnotateStatus, AutoAnnotateTask, type AutoPromptConfig, type AutoTask, type BaseArea, type BaseComponent, type BaseTask, type Box, type ChangeEvent, ChangeType, type ClassificationTask, type ComponentFinderComponent, type ComponentParams, type Contour, type ContourArea, type ContourFinderComponent, ContourType, type CreateWorkflow, type CreateWorkflowConfig, DEFAULT_PREDICTION_VERSION, DataApiType, DataEndpoint, type DataOptions, type DataSession, type Dataset, type DatasetAutoAnnotate, type DatasetAutoAnnotateCreate, type DatasetAutoAnnotateUpdate, type DatasetCreate, type DatasetHeroAssetUpdate, type DatasetParent, type DatasetUpdate, type DatasetVersion, type DatasetVersionAssetStats, type DownloadResponse, Endpoint, EndpointState, type EvaluateConfig, type EvaluateFilter, type EvaluateRequest, type EvaluateResponse, type EvaluateRunInfo, EvaluationStatus, ExportedBy, EyePop, EyepopLineDecoder, type FileSource, type ForwardComponent, ForwardOperatorType, type HttpClient, type InferRequest, type InferRunInfo, type InferRuntimeConfig, type InferenceComponent, InferenceType, type ListWorkFlowItem, type ListWorkFlowItemMetadata, type ListWorkflowItemMetadataLabels, LoadFromAssetUuidJob, LoadFromJob, LoadMediaStreamJob, type LocalAuth, type Mask, type MediaStreamSource, type Model, type ModelCreate, type ModelExport, ModelExportStatus, ModelFormat, type ModelMetrics, ModelPrecisionType, type ModelSample, ModelStatus, ModelTask, type ModelTrainingProgress, ModelTrainingStage, ModelType, type ModelUpdate, type MotionDetectConfig, MotionModel, type OAuth2Auth, type OnChangeEvent, type Options, type PathSource, type PlatformSupport, type Point2d, type Point3d, type Pop, type PopComponent, PopComponentType, type PopCrop, type PopForward, type PopForwardOperator, type PredictedClass, type PredictedEmbedding, type PredictedKeyPoint, type PredictedKeyPoints, type PredictedMesh, type PredictedMotion, type PredictedObject, type PredictedText, type Prediction, PredictionVersion, type ProcessParams, type ProcessRequest, type QcAiHubExportParams, type RectangleArea, type ResultStream, type Roi, Semaphore, type Session, type SessionAuth, SessionStatus, type Source, Stream, type StreamEvent, type StreamSource, type StreamTime, TaskMode, TaskType, type TimeSpan, type TrackingComponent, TranscodeMode, type TransformInto, TransientPopId, UploadJob, type UrlSource, UserReview, VideoMode, type VlmAbility, type VlmAbilityCreate, type VlmAbilityGroup, type VlmAbilityGroupCreate, type VlmAbilityGroupUpdate, VlmAbilityStatus, type VlmAbilityUpdate, WebrtcBase, WebrtcWhep, WebrtcWhip, WorkerEndpoint, type WorkerOptions, type WorkerSession, type Workflow, WorkflowPhase, EyePop as default, getBaseUrl, readableStreamFromString };
@@ -10599,8 +10599,10 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10599
10599
  }
10600
10600
  async reconnect() {
10601
10601
  if (this.options().popId == "transient" /* Transient */) {
10602
- await this.startComputeSession();
10602
+ await this.getComputeSession();
10603
10603
  this._pipelineId = await this.startTransientPipeline();
10604
+ } else if (this.options().sessionUuid) {
10605
+ await this.getComputeSession();
10604
10606
  } else {
10605
10607
  await this.startWebApiSessionWithPopId();
10606
10608
  }
@@ -10695,17 +10697,52 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10695
10697
  }
10696
10698
  }
10697
10699
  }
10698
- async startComputeSession() {
10700
+ async getComputeSession() {
10699
10701
  if (!this._client) {
10700
10702
  throw new Error("endpoint not initialized");
10701
10703
  }
10704
+ let session;
10705
+ let headers;
10706
+ const sessionUuid = this.options().sessionUuid;
10707
+ if (sessionUuid) {
10708
+ [session, headers] = await this.getPermanentComputeSession(this._client, sessionUuid);
10709
+ } else {
10710
+ [session, headers] = await this.getOnDemandComputeSession(this._client);
10711
+ }
10712
+ let isReady = false;
10713
+ const deadline = Date.now() + _WorkerEndpoint.WAIT_FOR_IS_READY;
10714
+ while (!isReady) {
10715
+ const health_url = `${session.session_endpoint}/health`;
10716
+ const response = await this._client.fetch(health_url, {
10717
+ headers
10718
+ });
10719
+ if (response.status < 300) {
10720
+ isReady = true;
10721
+ } 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`);
10723
+ } else {
10724
+ this._logger.debug(`session ${session.session_uuid} health check status ${response.status}, wait and poll for update`);
10725
+ await sleep(_WorkerEndpoint.CHECK_FOR_IS_READY_INTERVAL);
10726
+ }
10727
+ }
10728
+ this._baseUrl = session.session_endpoint;
10729
+ 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;
10736
+ }
10737
+ }
10738
+ async getOnDemandComputeSession(httpClient) {
10702
10739
  let session = null;
10703
10740
  const sessionsUrl = `${this.eyepopUrl()}/v1/sessions`;
10704
10741
  this._requestLogger.debug("fetching sessions from: %s", sessionsUrl);
10705
10742
  const headers = {
10706
10743
  Authorization: await this.authorizationHeader()
10707
10744
  };
10708
- let response = await this._client.fetch(sessionsUrl, {
10745
+ let response = await httpClient.fetch(sessionsUrl, {
10709
10746
  headers
10710
10747
  });
10711
10748
  let sessions;
@@ -10719,11 +10756,10 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10719
10756
  const response_content = await response.json();
10720
10757
  sessions = response_content;
10721
10758
  }
10722
- console.log(sessions);
10723
10759
  if (sessions.length > 0) {
10724
- this._logger.debug(`User has ${sessions.length} sessions, inspecting for active session`);
10760
+ this._logger.debug(`User has ${sessions.length} sessions, inspecting for usable session`);
10725
10761
  for (let s of sessions) {
10726
- if (!_WorkerEndpoint.SESSION_DEAD.has(s.session_status)) {
10762
+ if (!_WorkerEndpoint.SESSION_DEAD.has(s.session_status) && !s.persistent) {
10727
10763
  session = s;
10728
10764
  this._logger.debug(`Use active session ${s.session_uuid} with pipeline ${s.pipeline_uuid}`);
10729
10765
  break;
@@ -10732,7 +10768,7 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10732
10768
  }
10733
10769
  if (!session) {
10734
10770
  this._requestLogger.debug("creating a new session at: %s", sessionsUrl);
10735
- response = await this._client.fetch(`${sessionsUrl}?wait=true`, {
10771
+ response = await httpClient.fetch(`${sessionsUrl}?wait=true`, {
10736
10772
  headers,
10737
10773
  method: "POST"
10738
10774
  });
@@ -10751,29 +10787,30 @@ var _WorkerEndpoint = class _WorkerEndpoint extends Endpoint {
10751
10787
  if (!session) {
10752
10788
  throw new Error("unexpected undefined session");
10753
10789
  }
10754
- let isReady = false;
10755
- const deadline = Date.now() + _WorkerEndpoint.WAIT_FOR_IS_READY;
10756
- while (!isReady) {
10757
- const health_url = `${session.session_endpoint}/health`;
10758
- response = await this._client.fetch(health_url, {
10759
- headers
10760
- });
10761
- if (response.status < 300) {
10762
- isReady = true;
10763
- } else if (Date.now() > deadline) {
10764
- throw new Error(`Created session ${session.session_uuid} did not become healthy after ${_WorkerEndpoint.WAIT_FOR_IS_READY / 1e3} seconds`);
10765
- } else {
10766
- this._logger.debug(`session ${session.session_uuid} health check status ${response.status}, wait and poll for update`);
10767
- await sleep(_WorkerEndpoint.CHECK_FOR_IS_READY_INTERVAL);
10768
- }
10769
- }
10770
- this._baseUrl = session.session_endpoint;
10771
- this._pipeline = null;
10772
- if (session.pipeline_uuid) {
10773
- this._pipelineId = session.pipeline_uuid;
10790
+ return [session, headers];
10791
+ }
10792
+ async getPermanentComputeSession(httpClient, sessionUuid) {
10793
+ let session = null;
10794
+ const sessionUrl = `${this.eyepopUrl()}/v1/sessions/${sessionUuid}`;
10795
+ this._requestLogger.debug("fetching session from: %s", sessionUrl);
10796
+ const headers = {
10797
+ Authorization: await this.authorizationHeader()
10798
+ };
10799
+ let response = await httpClient.fetch(sessionUrl, {
10800
+ headers
10801
+ });
10802
+ if (response.status == 404) {
10803
+ this.updateState("Error" /* Error */);
10804
+ throw new Error(`Unexpected status ${response.status} compute sessions ${sessionUuid} not found`);
10805
+ } else if (response.status != 200) {
10806
+ this.updateState("Error" /* Error */);
10807
+ const message = await response.text();
10808
+ throw new Error(`Unexpected status ${response.status} fetching compute sessions: ${message}`);
10774
10809
  } else {
10775
- this._pipelineId = null;
10810
+ const response_content = await response.json();
10811
+ session = response_content;
10776
10812
  }
10813
+ return [session, headers];
10777
10814
  }
10778
10815
  async startTransientPipeline() {
10779
10816
  const client = this._client;
@@ -12191,7 +12228,10 @@ var EyePop;
12191
12228
  throw new Error("auth option or EYEPOP_API_KEY environment variable is required");
12192
12229
  }
12193
12230
  }
12194
- if (opts.popId === void 0) {
12231
+ if (opts.sessionUuid === void 0) {
12232
+ opts.sessionUuid = readEnv("EYEPOP_SESSION_UUID");
12233
+ }
12234
+ if (opts.popId === void 0 && opts.sessionUuid === void 0) {
12195
12235
  opts.popId = readEnv("EYEPOP_POP_ID") || "transient" /* Transient */;
12196
12236
  }
12197
12237
  if (opts.autoStart === void 0) {