@camstack/addon-post-analysis 1.1.3 → 1.1.5

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.
Files changed (20) hide show
  1. package/dist/{dist-BUE-vLMt.mjs → dist-BpGP9ago.mjs} +57 -12
  2. package/dist/{dist-BY1NQ5oi.js → dist-n-zJ0Uox.js} +62 -11
  3. package/dist/embedding-encoder/index.js +273 -97
  4. package/dist/embedding-encoder/index.mjs +271 -95
  5. package/dist/enrichment-engine/index.js +2 -2
  6. package/dist/enrichment-engine/index.mjs +1 -1
  7. package/dist/pipeline-analytics/_stub.js +1 -1
  8. package/dist/pipeline-analytics/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-D5LAGg5T.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-DgAlWohT.mjs} +3 -3
  9. package/dist/pipeline-analytics/{_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BFIbMkkd.mjs → _virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DBkzwlqD.mjs} +1 -1
  10. package/dist/pipeline-analytics/{hostInit-D8QpRf30.mjs → hostInit-D51b7QGW.mjs} +3 -3
  11. package/dist/pipeline-analytics/index.js +316 -2
  12. package/dist/pipeline-analytics/index.mjs +315 -1
  13. package/dist/pipeline-analytics/remoteEntry.js +1 -1
  14. package/dist/{resolve-frame-B2Do-e7z.js → resolve-frame-DB2NdMu2.js} +1 -1
  15. package/package.json +2 -1
  16. package/python/raw_tensor_inference.py +73 -0
  17. package/python/requirements-embedding.txt +8 -0
  18. package/python/tensor_frames.py +70 -0
  19. package/python/test_text_encoder.py +48 -0
  20. package/python/text_encoder_inference.py +76 -0
@@ -4627,7 +4627,7 @@ function _instanceof(cls, params = {}) {
4627
4627
  return inst;
4628
4628
  }
4629
4629
  //#endregion
4630
- //#region ../types/dist/sleep-BV7rLc6Y.mjs
4630
+ //#region ../types/dist/sleep-NOH4yRwj.mjs
4631
4631
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4632
4632
  EventCategory["SystemBoot"] = "system.boot";
4633
4633
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5742,15 +5742,24 @@ var BaseAddon = class {
5742
5742
  } catch {}
5743
5743
  }
5744
5744
  /**
5745
- * Resolve the shared models directory path via the storage capability.
5746
- * Falls back to `camstack-data/models` if storage is unavailable.
5747
- * Used by inference addons (detection-pipeline, audio-classifier, embedding-encoder).
5745
+ * Resolve the shared, node-local models directory: `<nodeDataDir>/models`.
5746
+ *
5747
+ * This is the SINGLE centralized models-dir resolver for every inference addon
5748
+ * (detection-pipeline, audio-analyzer, embedding-encoder, model-studio). It is
5749
+ * anchored at the node's own writable data root (`ctx.nodeDataDir`, i.e.
5750
+ * `CAMSTACK_DATA` ?? the kernel boot dir) — never the hub-singleton `storage`
5751
+ * cap, which returns the hub's `/data/models` to every node and breaks any node
5752
+ * whose real data dir differs (e.g. the macOS electron agent).
5753
+ *
5754
+ * `node:path`/`node:fs` are imported dynamically so the `@camstack/types` root
5755
+ * barrel (re-exported into browser bundles) stays free of node builtins.
5748
5756
  */
5749
5757
  async resolveModelsDir() {
5750
- return this.ctx.api.storage.resolve.query({
5751
- location: "models",
5752
- relativePath: ""
5753
- }).catch(() => "camstack-data/models");
5758
+ const { join } = await import("node:path");
5759
+ const { promises: fsp } = await import("node:fs");
5760
+ const dir = join(this.ctx.nodeDataDir, "models");
5761
+ await fsp.mkdir(dir, { recursive: true });
5762
+ return dir;
5754
5763
  }
5755
5764
  /**
5756
5765
  * Access the runtime capability registry for in-process provider lookups.
@@ -7125,6 +7134,9 @@ var EncodeProfileSchema = object({
7125
7134
  */
7126
7135
  outputArgs: array(string()).optional()
7127
7136
  });
7137
+ function hfModelUrl(repo, path) {
7138
+ return `https://huggingface.co/${repo}/resolve/main/${path}`;
7139
+ }
7128
7140
  /** Cosine similarity between two embedding vectors */
7129
7141
  function cosineSimilarity(a, b) {
7130
7142
  if (a.length !== b.length) return 0;
@@ -12761,7 +12773,8 @@ method(object({
12761
12773
  sessionId: string().optional()
12762
12774
  }), ConvertResultSchema, {
12763
12775
  kind: "mutation",
12764
- auth: "admin"
12776
+ auth: "admin",
12777
+ timeoutMs: 6e5
12765
12778
  });
12766
12779
  var AddonHttpRouteSchema = object({
12767
12780
  method: _enum([
@@ -14317,7 +14330,14 @@ var NotificationRuleConditionsSchema = object({
14317
14330
  /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
14318
14331
  * carrying a matching `data.eventType` string pass this condition. Rules without this field are
14319
14332
  * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
14320
- eventTypeTokens: array(string()).readonly().optional()
14333
+ eventTypeTokens: array(string()).readonly().optional(),
14334
+ /** Match detections whose CLIP image embedding is semantically similar to this free-text
14335
+ * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
14336
+ * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
14337
+ clipDescription: object({
14338
+ text: string().min(1),
14339
+ minSimilarity: number().min(0).max(1)
14340
+ }).optional()
14321
14341
  });
14322
14342
  var NotificationRuleTemplateSchema = object({
14323
14343
  title: string(),
@@ -14559,6 +14579,16 @@ var TrackedDetectionSchema = object({
14559
14579
  zones: array(string()).readonly(),
14560
14580
  state: TrackStateSchema
14561
14581
  });
14582
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
14583
+ var SearchObjectEventsInput = object({
14584
+ text: string(),
14585
+ deviceId: number().optional(),
14586
+ since: number().optional(),
14587
+ until: number().optional(),
14588
+ classFilter: string().optional(),
14589
+ limit: number().default(50),
14590
+ minScore: number().min(0).max(1).default(.2)
14591
+ });
14562
14592
  var pipelineAnalyticsCapability = {
14563
14593
  name: "pipeline-analytics",
14564
14594
  scope: "device",
@@ -14625,7 +14655,16 @@ var pipelineAnalyticsCapability = {
14625
14655
  eventId: string(),
14626
14656
  kind: MediaFileKindEnum.optional()
14627
14657
  }), array(MediaFileSchema).readonly()),
14628
- getTrackMedia: method(object({ trackId: string() }), array(MediaFileSchema).readonly())
14658
+ getTrackMedia: method(object({ trackId: string() }), array(MediaFileSchema).readonly()),
14659
+ /**
14660
+ * Search object events by text query using CLIP cosine similarity.
14661
+ * Encodes `text` via the `embedding-encoder` cap, queries the
14662
+ * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
14663
+ * embeddings by cosine similarity, and joins winners to their
14664
+ * ObjectEvents by trackId. Returns up to `limit` events scored ≥
14665
+ * `minScore`, sorted descending by score.
14666
+ */
14667
+ searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly())
14629
14668
  },
14630
14669
  events: {
14631
14670
  /**
@@ -19342,6 +19381,12 @@ Object.freeze({
19342
19381
  addonId: null,
19343
19382
  access: "create"
19344
19383
  },
19384
+ "pipelineAnalytics.searchObjectEvents": {
19385
+ capName: "pipeline-analytics",
19386
+ capScope: "device",
19387
+ addonId: null,
19388
+ access: "view"
19389
+ },
19345
19390
  "pipelineExecutor.cacheFrameInPool": {
19346
19391
  capName: "pipeline-executor",
19347
19392
  capScope: "system",
@@ -21226,4 +21271,4 @@ object({
21226
21271
  schemaVersion: literal(1)
21227
21272
  });
21228
21273
  //#endregion
21229
- export { tuple as C, string as S, _enum as _, faceGalleryCapability as a, number as b, videoclipsCapability as c, BaseAddon as d, DeviceType as f, hydrateSchema as g, createEvent as h, embeddingEncoderCapability as i, zoneAnalyticsCapability as l, asJsonObject as m, audioMetricsCapability as n, pipelineAnalyticsCapability as o, EventCategory as p, cosineSimilarity as r, plateGalleryCapability as s, addonWidgetsSourceCapability as t, errMsg as u, array as v, object as x, boolean as y };
21274
+ export { string as C, object as S, hydrateSchema as _, faceGalleryCapability as a, boolean as b, plateGalleryCapability as c, errMsg as d, BaseAddon as f, createEvent as g, asJsonObject as h, embeddingEncoderCapability as i, videoclipsCapability as l, EventCategory as m, audioMetricsCapability as n, hfModelUrl as o, DeviceType as p, cosineSimilarity as r, pipelineAnalyticsCapability as s, addonWidgetsSourceCapability as t, zoneAnalyticsCapability as u, _enum as v, tuple as w, number as x, array as y };
@@ -4649,7 +4649,7 @@ function _instanceof(cls, params = {}) {
4649
4649
  return inst;
4650
4650
  }
4651
4651
  //#endregion
4652
- //#region ../types/dist/sleep-BV7rLc6Y.mjs
4652
+ //#region ../types/dist/sleep-NOH4yRwj.mjs
4653
4653
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4654
4654
  EventCategory["SystemBoot"] = "system.boot";
4655
4655
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5764,15 +5764,24 @@ var BaseAddon = class {
5764
5764
  } catch {}
5765
5765
  }
5766
5766
  /**
5767
- * Resolve the shared models directory path via the storage capability.
5768
- * Falls back to `camstack-data/models` if storage is unavailable.
5769
- * Used by inference addons (detection-pipeline, audio-classifier, embedding-encoder).
5767
+ * Resolve the shared, node-local models directory: `<nodeDataDir>/models`.
5768
+ *
5769
+ * This is the SINGLE centralized models-dir resolver for every inference addon
5770
+ * (detection-pipeline, audio-analyzer, embedding-encoder, model-studio). It is
5771
+ * anchored at the node's own writable data root (`ctx.nodeDataDir`, i.e.
5772
+ * `CAMSTACK_DATA` ?? the kernel boot dir) — never the hub-singleton `storage`
5773
+ * cap, which returns the hub's `/data/models` to every node and breaks any node
5774
+ * whose real data dir differs (e.g. the macOS electron agent).
5775
+ *
5776
+ * `node:path`/`node:fs` are imported dynamically so the `@camstack/types` root
5777
+ * barrel (re-exported into browser bundles) stays free of node builtins.
5770
5778
  */
5771
5779
  async resolveModelsDir() {
5772
- return this.ctx.api.storage.resolve.query({
5773
- location: "models",
5774
- relativePath: ""
5775
- }).catch(() => "camstack-data/models");
5780
+ const { join } = await import("node:path");
5781
+ const { promises: fsp } = await import("node:fs");
5782
+ const dir = join(this.ctx.nodeDataDir, "models");
5783
+ await fsp.mkdir(dir, { recursive: true });
5784
+ return dir;
5776
5785
  }
5777
5786
  /**
5778
5787
  * Access the runtime capability registry for in-process provider lookups.
@@ -7147,6 +7156,9 @@ var EncodeProfileSchema = object({
7147
7156
  */
7148
7157
  outputArgs: array(string()).optional()
7149
7158
  });
7159
+ function hfModelUrl(repo, path) {
7160
+ return `https://huggingface.co/${repo}/resolve/main/${path}`;
7161
+ }
7150
7162
  /** Cosine similarity between two embedding vectors */
7151
7163
  function cosineSimilarity(a, b) {
7152
7164
  if (a.length !== b.length) return 0;
@@ -12783,7 +12795,8 @@ method(object({
12783
12795
  sessionId: string().optional()
12784
12796
  }), ConvertResultSchema, {
12785
12797
  kind: "mutation",
12786
- auth: "admin"
12798
+ auth: "admin",
12799
+ timeoutMs: 6e5
12787
12800
  });
12788
12801
  var AddonHttpRouteSchema = object({
12789
12802
  method: _enum([
@@ -14339,7 +14352,14 @@ var NotificationRuleConditionsSchema = object({
14339
14352
  /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
14340
14353
  * carrying a matching `data.eventType` string pass this condition. Rules without this field are
14341
14354
  * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
14342
- eventTypeTokens: array(string()).readonly().optional()
14355
+ eventTypeTokens: array(string()).readonly().optional(),
14356
+ /** Match detections whose CLIP image embedding is semantically similar to this free-text
14357
+ * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
14358
+ * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
14359
+ clipDescription: object({
14360
+ text: string().min(1),
14361
+ minSimilarity: number().min(0).max(1)
14362
+ }).optional()
14343
14363
  });
14344
14364
  var NotificationRuleTemplateSchema = object({
14345
14365
  title: string(),
@@ -14581,6 +14601,16 @@ var TrackedDetectionSchema = object({
14581
14601
  zones: array(string()).readonly(),
14582
14602
  state: TrackStateSchema
14583
14603
  });
14604
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
14605
+ var SearchObjectEventsInput = object({
14606
+ text: string(),
14607
+ deviceId: number().optional(),
14608
+ since: number().optional(),
14609
+ until: number().optional(),
14610
+ classFilter: string().optional(),
14611
+ limit: number().default(50),
14612
+ minScore: number().min(0).max(1).default(.2)
14613
+ });
14584
14614
  var pipelineAnalyticsCapability = {
14585
14615
  name: "pipeline-analytics",
14586
14616
  scope: "device",
@@ -14647,7 +14677,16 @@ var pipelineAnalyticsCapability = {
14647
14677
  eventId: string(),
14648
14678
  kind: MediaFileKindEnum.optional()
14649
14679
  }), array(MediaFileSchema).readonly()),
14650
- getTrackMedia: method(object({ trackId: string() }), array(MediaFileSchema).readonly())
14680
+ getTrackMedia: method(object({ trackId: string() }), array(MediaFileSchema).readonly()),
14681
+ /**
14682
+ * Search object events by text query using CLIP cosine similarity.
14683
+ * Encodes `text` via the `embedding-encoder` cap, queries the
14684
+ * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
14685
+ * embeddings by cosine similarity, and joins winners to their
14686
+ * ObjectEvents by trackId. Returns up to `limit` events scored ≥
14687
+ * `minScore`, sorted descending by score.
14688
+ */
14689
+ searchObjectEvents: method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly())
14651
14690
  },
14652
14691
  events: {
14653
14692
  /**
@@ -19364,6 +19403,12 @@ Object.freeze({
19364
19403
  addonId: null,
19365
19404
  access: "create"
19366
19405
  },
19406
+ "pipelineAnalytics.searchObjectEvents": {
19407
+ capName: "pipeline-analytics",
19408
+ capScope: "device",
19409
+ addonId: null,
19410
+ access: "view"
19411
+ },
19367
19412
  "pipelineExecutor.cacheFrameInPool": {
19368
19413
  capName: "pipeline-executor",
19369
19414
  capScope: "system",
@@ -21338,6 +21383,12 @@ Object.defineProperty(exports, "faceGalleryCapability", {
21338
21383
  return faceGalleryCapability;
21339
21384
  }
21340
21385
  });
21386
+ Object.defineProperty(exports, "hfModelUrl", {
21387
+ enumerable: true,
21388
+ get: function() {
21389
+ return hfModelUrl;
21390
+ }
21391
+ });
21341
21392
  Object.defineProperty(exports, "hydrateSchema", {
21342
21393
  enumerable: true,
21343
21394
  get: function() {