@camstack/addon-post-analysis 1.2.41 → 1.2.43
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/{dist-C09kySqI.js → dist-BIBeAcEY.js} +30 -5
- package/dist/{dist-CrCaHNC2.mjs → dist-D4eie2px.mjs} +30 -5
- package/dist/embedding-encoder/index.js +1 -1
- package/dist/embedding-encoder/index.mjs +1 -1
- package/dist/{node-DL2FM8_E.js → node-INtH-sDE.js} +1 -1
- package/dist/pipeline-analytics/_stub.js +1 -1
- package/dist/pipeline-analytics/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-Dt_25eeS.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-DX4bQCYL.mjs} +2 -2
- package/dist/pipeline-analytics/{_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DbdKLyhB.mjs → _virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-Da6ggNiB.mjs} +1 -1
- package/dist/pipeline-analytics/{hostInit-BfGl-Bnl.mjs → hostInit-BPLslJdB.mjs} +2 -2
- package/dist/pipeline-analytics/index.js +351 -84
- package/dist/pipeline-analytics/index.mjs +350 -83
- package/dist/pipeline-analytics/remoteEntry.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as unknown, A as kebabToCamel, B as DeviceType, C as cosineSimilarity, D as encodeVectorBase64, F as subKindsOf, G as _enum, H as hydrateSchema, I as videoclipsCapability, J as literal, K as array, L as zoneAnalyticsCapability, M as pipelineAnalyticsCapability, N as plateGalleryCapability, O as faceGalleryCapability, P as readDeviceStateFrom, Q as string, R as errMsg, S as buildEventKindDescriptor, T as defineCustomActions, U as isDeviceScopedCap, V as createEvent, W as nodePin, X as object, Y as number, Z as record, _ as TimelapseRuleInputSchema, a as MACRO_LABELS, b as alarmPanelCapability, c as NcConditionDescriptorSchema, d as NcRuleSchema, et as EventCategory, f as NcSnoozeInputSchema, g as OpsLogEntrySchema, h as NcTaxonomySchema, i as EVENT_PAD_MS, j as notificationRulesCapability, l as NcRuleInputSchema, m as NcSnoozeSuppressedSchema, n as DEFAULT_EVENT_COLOR, o as NC_CONDITION_CATALOG, p as NcSnoozeSchema, q as boolean, r as EVENT_KIND_BY_CAP, s as NC_TAXONOMY, t as BaseDevice, u as NcRulePatchSchema, v as TimelapseRuleSchema, w as customAction, x as audioMetricsCapability, y as addonWidgetsSourceCapability, z as BaseAddon } from "../dist-
|
|
1
|
+
import { $ as unknown, A as kebabToCamel, B as DeviceType, C as cosineSimilarity, D as encodeVectorBase64, F as subKindsOf, G as _enum, H as hydrateSchema, I as videoclipsCapability, J as literal, K as array, L as zoneAnalyticsCapability, M as pipelineAnalyticsCapability, N as plateGalleryCapability, O as faceGalleryCapability, P as readDeviceStateFrom, Q as string, R as errMsg, S as buildEventKindDescriptor, T as defineCustomActions, U as isDeviceScopedCap, V as createEvent, W as nodePin, X as object, Y as number, Z as record, _ as TimelapseRuleInputSchema, a as MACRO_LABELS, b as alarmPanelCapability, c as NcConditionDescriptorSchema, d as NcRuleSchema, et as EventCategory, f as NcSnoozeInputSchema, g as OpsLogEntrySchema, h as NcTaxonomySchema, i as EVENT_PAD_MS, j as notificationRulesCapability, l as NcRuleInputSchema, m as NcSnoozeSuppressedSchema, n as DEFAULT_EVENT_COLOR, o as NC_CONDITION_CATALOG, p as NcSnoozeSchema, q as boolean, r as EVENT_KIND_BY_CAP, s as NC_TAXONOMY, t as BaseDevice, u as NcRulePatchSchema, v as TimelapseRuleSchema, w as customAction, x as audioMetricsCapability, y as addonWidgetsSourceCapability, z as BaseAddon } from "../dist-D4eie2px.mjs";
|
|
2
2
|
import { promises } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
@@ -5815,6 +5815,76 @@ function makeNcActionHandlers(deps) {
|
|
|
5815
5815
|
};
|
|
5816
5816
|
}
|
|
5817
5817
|
//#endregion
|
|
5818
|
+
//#region src/pipeline-analytics/embedding-actions.ts
|
|
5819
|
+
/**
|
|
5820
|
+
* embedding-actions — operator buttons for the CLIP semantic-search index.
|
|
5821
|
+
*
|
|
5822
|
+
* These ride the generic `addons.custom` bridge rather than adding cap methods,
|
|
5823
|
+
* because the settings form already knows how to render an
|
|
5824
|
+
* `addon-action-button` and call it. The three operations they expose are the
|
|
5825
|
+
* ones an operator needs when the index and the world disagree:
|
|
5826
|
+
*
|
|
5827
|
+
* - **Rebuild** re-embeds tracks from their key frames. It is the only way to
|
|
5828
|
+
* change what a vector MEANS — crop margin, squaring, encoder model — since
|
|
5829
|
+
* mixing feature spaces in one index makes cosine scores incomparable.
|
|
5830
|
+
* - **Status** is what makes rebuild usable at all: a pass is ~1s per track,
|
|
5831
|
+
* 45 minutes for a fleet, so it runs detached and this is how progress is
|
|
5832
|
+
* seen.
|
|
5833
|
+
* - **Wipe** empties the index, for the clean slate before a policy change.
|
|
5834
|
+
*
|
|
5835
|
+
* Wipe is `danger` and carries a confirm prompt. It has already destroyed a
|
|
5836
|
+
* live index once when it was called casually — the button must not make that
|
|
5837
|
+
* easier than it needs to be.
|
|
5838
|
+
*/
|
|
5839
|
+
var RebuildInputSchema = object({
|
|
5840
|
+
/** Restrict to one camera; omit for the whole fleet. */
|
|
5841
|
+
deviceId: number().optional(),
|
|
5842
|
+
/**
|
|
5843
|
+
* Fraction added on EACH side of the detection box before cropping.
|
|
5844
|
+
* ~0.2 (a 1.4x window) gives CLIP the surroundings it is trained on; 0 is
|
|
5845
|
+
* the pixel-tight crop.
|
|
5846
|
+
*/
|
|
5847
|
+
cropMargin: number().min(0).max(4).optional(),
|
|
5848
|
+
/** Square the window so a tall subject is not squashed into CLIP's input. */
|
|
5849
|
+
square: boolean().optional(),
|
|
5850
|
+
/** Stop after this many tracks; the status reports whether more remain. */
|
|
5851
|
+
maxTracks: number().int().positive().optional()
|
|
5852
|
+
});
|
|
5853
|
+
var RebuildStartedSchema = object({
|
|
5854
|
+
started: boolean(),
|
|
5855
|
+
alreadyRunning: boolean()
|
|
5856
|
+
});
|
|
5857
|
+
var RebuildStatusSchema = object({
|
|
5858
|
+
running: boolean(),
|
|
5859
|
+
scanned: number(),
|
|
5860
|
+
rebuilt: number(),
|
|
5861
|
+
missingKeyFrame: number(),
|
|
5862
|
+
missingBbox: number(),
|
|
5863
|
+
failed: number(),
|
|
5864
|
+
complete: boolean().nullable(),
|
|
5865
|
+
startedAtMs: number().nullable(),
|
|
5866
|
+
finishedAtMs: number().nullable(),
|
|
5867
|
+
error: string().nullable(),
|
|
5868
|
+
/** Rows currently in the index — the number the operator is watching. */
|
|
5869
|
+
indexed: number()
|
|
5870
|
+
});
|
|
5871
|
+
var WipeResultSchema = object({ deleted: number() });
|
|
5872
|
+
/**
|
|
5873
|
+
* An input-less action still takes an OBJECT, never `z.void()`.
|
|
5874
|
+
*
|
|
5875
|
+
* The `addons.custom` envelope requires an `input` field — omitting it fails
|
|
5876
|
+
* envelope validation before the action is even looked up — and the settings
|
|
5877
|
+
* form's button always sends one. So `z.void()` makes an action that resolves
|
|
5878
|
+
* and can never be called: the bridge insists on `{}` and the schema rejects
|
|
5879
|
+
* it. Verified on the live hub, both directions.
|
|
5880
|
+
*/
|
|
5881
|
+
var NoInputSchema = object({});
|
|
5882
|
+
var embeddingActions = defineCustomActions({
|
|
5883
|
+
"embedding.rebuild": customAction(RebuildInputSchema, RebuildStartedSchema, { auth: "admin" }),
|
|
5884
|
+
"embedding.rebuildStatus": customAction(NoInputSchema, RebuildStatusSchema),
|
|
5885
|
+
"embedding.wipe": customAction(NoInputSchema, WipeResultSchema, { auth: "admin" })
|
|
5886
|
+
});
|
|
5887
|
+
//#endregion
|
|
5818
5888
|
//#region src/pipeline-analytics/pipeline/face-clustering.ts
|
|
5819
5889
|
/**
|
|
5820
5890
|
* face-clustering — pure greedy clustering of face embeddings by cosine
|
|
@@ -12041,57 +12111,84 @@ async function rebuildObjectEmbeddings(deps, options = {}) {
|
|
|
12041
12111
|
const margin = options.cropMargin ?? .2;
|
|
12042
12112
|
const square = options.square ?? true;
|
|
12043
12113
|
const maxTracks = options.maxTracks ?? Number.POSITIVE_INFINITY;
|
|
12044
|
-
const trackIds = await deps.listTrackIds();
|
|
12045
|
-
const considered = trackIds.slice(0, Number.isFinite(maxTracks) ? maxTracks : void 0);
|
|
12046
12114
|
let rebuilt = 0;
|
|
12047
12115
|
let missingKeyFrame = 0;
|
|
12048
12116
|
let missingBbox = 0;
|
|
12049
12117
|
let failed = 0;
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
if (
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
}
|
|
12060
|
-
if (source.bbox === null || source.bbox.w <= 0 || source.bbox.h <= 0) {
|
|
12061
|
-
missingBbox += 1;
|
|
12062
|
-
continue;
|
|
12063
|
-
}
|
|
12064
|
-
const meta = await sharp(source.keyFrame).metadata();
|
|
12065
|
-
if (meta.width === void 0 || meta.height === void 0) {
|
|
12066
|
-
failed += 1;
|
|
12067
|
-
continue;
|
|
12118
|
+
let scanned = 0;
|
|
12119
|
+
let cursor = null;
|
|
12120
|
+
let exhausted = false;
|
|
12121
|
+
let budgetExhausted = false;
|
|
12122
|
+
while (scanned < maxTracks) {
|
|
12123
|
+
const page = await deps.listTrackIdPage(cursor);
|
|
12124
|
+
if (page.trackIds.length === 0) {
|
|
12125
|
+
exhausted = true;
|
|
12126
|
+
break;
|
|
12068
12127
|
}
|
|
12069
|
-
const
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12128
|
+
const room = maxTracks - scanned;
|
|
12129
|
+
const batch = page.trackIds.slice(0, Number.isFinite(room) ? room : void 0);
|
|
12130
|
+
if (batch.length < page.trackIds.length) budgetExhausted = true;
|
|
12131
|
+
for (const trackId of batch) {
|
|
12132
|
+
scanned += 1;
|
|
12133
|
+
try {
|
|
12134
|
+
const source = await deps.loadSource(trackId);
|
|
12135
|
+
if (source === null) {
|
|
12136
|
+
missingKeyFrame += 1;
|
|
12137
|
+
continue;
|
|
12138
|
+
}
|
|
12139
|
+
if (source.keyFrame === null) {
|
|
12140
|
+
missingKeyFrame += 1;
|
|
12141
|
+
continue;
|
|
12142
|
+
}
|
|
12143
|
+
if (source.bbox === null || source.bbox.w <= 0 || source.bbox.h <= 0) {
|
|
12144
|
+
missingBbox += 1;
|
|
12145
|
+
continue;
|
|
12146
|
+
}
|
|
12147
|
+
const meta = await sharp(source.keyFrame).metadata();
|
|
12148
|
+
if (meta.width === void 0 || meta.height === void 0) {
|
|
12149
|
+
failed += 1;
|
|
12150
|
+
continue;
|
|
12151
|
+
}
|
|
12152
|
+
const window = cropWindow(source.bbox, meta.width, meta.height, {
|
|
12153
|
+
margin,
|
|
12154
|
+
square
|
|
12155
|
+
});
|
|
12156
|
+
const cut = await cropFromJpeg(source.keyFrame, window);
|
|
12157
|
+
if (cut === null) {
|
|
12158
|
+
failed += 1;
|
|
12159
|
+
continue;
|
|
12160
|
+
}
|
|
12161
|
+
const embedding = await deps.encode(cut.crop, cut.width, cut.height);
|
|
12162
|
+
if (embedding.length === 0) {
|
|
12163
|
+
failed += 1;
|
|
12164
|
+
continue;
|
|
12165
|
+
}
|
|
12166
|
+
await deps.store(source, embedding);
|
|
12167
|
+
rebuilt += 1;
|
|
12168
|
+
} catch (err) {
|
|
12169
|
+
failed += 1;
|
|
12170
|
+
deps.logger.warn("embedding rebuild failed for a track", { meta: {
|
|
12171
|
+
trackId,
|
|
12172
|
+
error: String(err)
|
|
12173
|
+
} });
|
|
12174
|
+
}
|
|
12175
|
+
if (scanned % 25 === 0) options.onProgress?.({
|
|
12176
|
+
scanned,
|
|
12177
|
+
rebuilt,
|
|
12178
|
+
missingKeyFrame,
|
|
12179
|
+
missingBbox,
|
|
12180
|
+
failed
|
|
12181
|
+
});
|
|
12077
12182
|
}
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
continue;
|
|
12183
|
+
if (page.nextCursor === null) {
|
|
12184
|
+
exhausted = true;
|
|
12185
|
+
break;
|
|
12082
12186
|
}
|
|
12083
|
-
|
|
12084
|
-
rebuilt += 1;
|
|
12085
|
-
} catch (err) {
|
|
12086
|
-
failed += 1;
|
|
12087
|
-
deps.logger.warn("embedding rebuild failed for a track", { meta: {
|
|
12088
|
-
trackId,
|
|
12089
|
-
error: String(err)
|
|
12090
|
-
} });
|
|
12187
|
+
cursor = page.nextCursor;
|
|
12091
12188
|
}
|
|
12092
|
-
const complete =
|
|
12189
|
+
const complete = exhausted && !budgetExhausted;
|
|
12093
12190
|
deps.logger.info("object embedding rebuild finished", { meta: {
|
|
12094
|
-
scanned
|
|
12191
|
+
scanned,
|
|
12095
12192
|
rebuilt,
|
|
12096
12193
|
missingKeyFrame,
|
|
12097
12194
|
missingBbox,
|
|
@@ -12101,7 +12198,7 @@ async function rebuildObjectEmbeddings(deps, options = {}) {
|
|
|
12101
12198
|
square
|
|
12102
12199
|
} });
|
|
12103
12200
|
return {
|
|
12104
|
-
scanned
|
|
12201
|
+
scanned,
|
|
12105
12202
|
rebuilt,
|
|
12106
12203
|
missingKeyFrame,
|
|
12107
12204
|
missingBbox,
|
|
@@ -17524,26 +17621,6 @@ var SyntheticSensorTrackMaterializer = class {
|
|
|
17524
17621
|
return track;
|
|
17525
17622
|
}
|
|
17526
17623
|
};
|
|
17527
|
-
var TRACK_RETENTION_DEFAULT_DAYS = object({ trackRetentionDays: number().min(0).default(7) }).parse({}).trackRetentionDays;
|
|
17528
|
-
/**
|
|
17529
|
-
* Sweep every device with persisted tracks: skip retention-disabled devices,
|
|
17530
|
-
* prune the rest at `now − retentionMs`. Per-device ISOLATED — one bad device
|
|
17531
|
-
* never aborts the sweep. Returns the total tracks pruned across devices.
|
|
17532
|
-
*/
|
|
17533
|
-
async function sweepTrackRetention(deps) {
|
|
17534
|
-
const devices = await deps.listDeviceIds();
|
|
17535
|
-
const nowMs = deps.now();
|
|
17536
|
-
let totalTracks = 0;
|
|
17537
|
-
for (const deviceId of devices) try {
|
|
17538
|
-
const cutoffMs = await deps.resolveCutoffMs(deviceId, nowMs);
|
|
17539
|
-
if (cutoffMs === null) continue;
|
|
17540
|
-
const counts = await deps.pruneTracksBefore(deviceId, cutoffMs);
|
|
17541
|
-
totalTracks += counts.tracks;
|
|
17542
|
-
} catch (err) {
|
|
17543
|
-
deps.onError?.(deviceId, err);
|
|
17544
|
-
}
|
|
17545
|
-
return totalTracks;
|
|
17546
|
-
}
|
|
17547
17624
|
var TrackingSettingsSchema = object({
|
|
17548
17625
|
/**
|
|
17549
17626
|
* How much of a detection's box must lie inside a zone (0-1 fraction of the
|
|
@@ -18339,6 +18416,26 @@ function buildDetectionSettingsSections() {
|
|
|
18339
18416
|
}
|
|
18340
18417
|
];
|
|
18341
18418
|
}
|
|
18419
|
+
var TRACK_RETENTION_DEFAULT_DAYS = object({ trackRetentionDays: number().min(0).default(7) }).parse({}).trackRetentionDays;
|
|
18420
|
+
/**
|
|
18421
|
+
* Sweep every device with persisted tracks: skip retention-disabled devices,
|
|
18422
|
+
* prune the rest at `now − retentionMs`. Per-device ISOLATED — one bad device
|
|
18423
|
+
* never aborts the sweep. Returns the total tracks pruned across devices.
|
|
18424
|
+
*/
|
|
18425
|
+
async function sweepTrackRetention(deps) {
|
|
18426
|
+
const devices = await deps.listDeviceIds();
|
|
18427
|
+
const nowMs = deps.now();
|
|
18428
|
+
let totalTracks = 0;
|
|
18429
|
+
for (const deviceId of devices) try {
|
|
18430
|
+
const cutoffMs = await deps.resolveCutoffMs(deviceId, nowMs);
|
|
18431
|
+
if (cutoffMs === null) continue;
|
|
18432
|
+
const counts = await deps.pruneTracksBefore(deviceId, cutoffMs);
|
|
18433
|
+
totalTracks += counts.tracks;
|
|
18434
|
+
} catch (err) {
|
|
18435
|
+
deps.onError?.(deviceId, err);
|
|
18436
|
+
}
|
|
18437
|
+
return totalTracks;
|
|
18438
|
+
}
|
|
18342
18439
|
/**
|
|
18343
18440
|
* Re-home the global analytics sections into the per-device `Analytics`
|
|
18344
18441
|
* top-tab. Every section defaults to the `Analytics` tab (so the
|
|
@@ -18449,6 +18546,59 @@ function buildGlobalSettingsSchema() {
|
|
|
18449
18546
|
default: true
|
|
18450
18547
|
}]
|
|
18451
18548
|
},
|
|
18549
|
+
{
|
|
18550
|
+
id: "embedding-index",
|
|
18551
|
+
title: "Semantic search index",
|
|
18552
|
+
description: "The CLIP vector index behind text search. Rebuild re-embeds stored tracks from their native key frames — the only way to change what a vector means, since a new crop margin or encoder model leaves two incomparable feature spaces in one index. Vectors live in the vector-store capability, alongside the events they are shown with.",
|
|
18553
|
+
columns: 1,
|
|
18554
|
+
fields: [
|
|
18555
|
+
{
|
|
18556
|
+
type: "number",
|
|
18557
|
+
key: "rebuildCropMargin",
|
|
18558
|
+
label: "Rebuild crop margin",
|
|
18559
|
+
description: "Fraction added on EACH side of the detection box when re-embedding. 0.2 gives a 1.4x window: CLIP is trained on natural images WITH surroundings, and a pixel-tight crop removes what it is strongest on. 0 reproduces the tight crop. Only affects Rebuild — it does not change live capture, and the thumbnail is never re-cropped.",
|
|
18560
|
+
default: .2,
|
|
18561
|
+
min: 0,
|
|
18562
|
+
max: 2,
|
|
18563
|
+
step: .1
|
|
18564
|
+
},
|
|
18565
|
+
{
|
|
18566
|
+
type: "addon-action-button",
|
|
18567
|
+
key: "rebuildEmbeddingsButton",
|
|
18568
|
+
label: "Rebuild index",
|
|
18569
|
+
description: "Re-embed every stored track from its key frame, using the margin above. Runs in the background — press Progress to watch it. Tracks whose key frame has aged out cannot be rebuilt and are reported as skipped.",
|
|
18570
|
+
addonId: "pipeline-analytics",
|
|
18571
|
+
action: "embedding.rebuild",
|
|
18572
|
+
buttonLabel: "Rebuild",
|
|
18573
|
+
variant: "primary",
|
|
18574
|
+
paramsFromForm: { cropMargin: "rebuildCropMargin" },
|
|
18575
|
+
paramsStatic: { square: true },
|
|
18576
|
+
successMessage: "Rebuild started — press Progress to follow it."
|
|
18577
|
+
},
|
|
18578
|
+
{
|
|
18579
|
+
type: "addon-action-button",
|
|
18580
|
+
key: "rebuildStatusButton",
|
|
18581
|
+
label: "Progress",
|
|
18582
|
+
description: "Rows currently indexed, plus the running pass: scanned, rebuilt, and what it had to skip.",
|
|
18583
|
+
addonId: "pipeline-analytics",
|
|
18584
|
+
action: "embedding.rebuildStatus",
|
|
18585
|
+
buttonLabel: "Check progress",
|
|
18586
|
+
successMessage: "Indexed {indexed} · scanned {scanned} · rebuilt {rebuilt} · no key frame {missingKeyFrame} · failed {failed}"
|
|
18587
|
+
},
|
|
18588
|
+
{
|
|
18589
|
+
type: "addon-action-button",
|
|
18590
|
+
key: "wipeEmbeddingsButton",
|
|
18591
|
+
label: "Empty the index",
|
|
18592
|
+
description: "Deletes every vector. Search returns nothing until a rebuild repopulates it, and only tracks still inside the retention window can be rebuilt — anything older is gone for good.",
|
|
18593
|
+
addonId: "pipeline-analytics",
|
|
18594
|
+
action: "embedding.wipe",
|
|
18595
|
+
buttonLabel: "Empty index",
|
|
18596
|
+
variant: "danger",
|
|
18597
|
+
confirmMessage: "Delete every semantic-search vector? Search stops working until a rebuild finishes, and vectors whose tracks have aged out cannot be recovered.",
|
|
18598
|
+
successMessage: "Removed {deleted} vectors."
|
|
18599
|
+
}
|
|
18600
|
+
]
|
|
18601
|
+
},
|
|
18452
18602
|
{
|
|
18453
18603
|
id: "tracking-core",
|
|
18454
18604
|
title: "Tracking",
|
|
@@ -22943,10 +23093,30 @@ var ENCODER_INFO_TTL_MS = 6e4;
|
|
|
22943
23093
|
var EMBEDDING_ORPHAN_SCAN_LIMIT = 2e4;
|
|
22944
23094
|
/** Dimension of the zero probe vector used to enumerate the index. */
|
|
22945
23095
|
var EMBEDDING_ORPHAN_PROBE_DIM = 512;
|
|
23096
|
+
/**
|
|
23097
|
+
* Tracks fetched per page while rebuilding.
|
|
23098
|
+
*
|
|
23099
|
+
* The page size is NOT the caller's `maxTracks`: that bounds the whole pass,
|
|
23100
|
+
* this bounds one round trip. Conflating them is what made the rebuild
|
|
23101
|
+
* re-embed the same newest N tracks on every call.
|
|
23102
|
+
*/
|
|
23103
|
+
var REBUILD_PAGE_SIZE = 200;
|
|
22946
23104
|
var PIPELINE_ANALYTICS_ADDON_ID = "pipeline-analytics";
|
|
22947
23105
|
/** Operator-visible name of the fixed integration. */
|
|
22948
23106
|
var NC_INTEGRATION_NAME = "Notification Center";
|
|
22949
23107
|
/**
|
|
23108
|
+
* The FULL action catalog for this addon.
|
|
23109
|
+
*
|
|
23110
|
+
* Must contain every action, not just the notification-center ones: the hub
|
|
23111
|
+
* harvests THIS named export, so an action registered only in what
|
|
23112
|
+
* `onInitialize` returns is invisible to the bridge and answers 404. That is
|
|
23113
|
+
* exactly what the embedding buttons did on their first deploy.
|
|
23114
|
+
*/
|
|
23115
|
+
var customActions = {
|
|
23116
|
+
...ncActions,
|
|
23117
|
+
...embeddingActions
|
|
23118
|
+
};
|
|
23119
|
+
/**
|
|
22950
23120
|
* Pipeline Analytics addon — subscribes to `PipelineInferenceResult` +
|
|
22951
23121
|
* `PipelineAudioInferenceResult` on the bus, refines raw detections
|
|
22952
23122
|
* into tracks + per-kind events + persisted media, and emits canonical
|
|
@@ -23130,6 +23300,8 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
|
|
|
23130
23300
|
plateStore = null;
|
|
23131
23301
|
plateRecognizer = null;
|
|
23132
23302
|
objectEmbeddingStore = null;
|
|
23303
|
+
/** Live state of the detached embedding rebuild — see `rebuildObjectEmbeddings`. */
|
|
23304
|
+
rebuildState = { running: false };
|
|
23133
23305
|
/** Cached active-encoder model id — see `resolveEncoderModelId`. */
|
|
23134
23306
|
encoderInfoCache = null;
|
|
23135
23307
|
/** Two-plane detail scheduler/dispatcher: per-track on-demand face/clip/
|
|
@@ -23604,8 +23776,14 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
|
|
|
23604
23776
|
return {
|
|
23605
23777
|
providers,
|
|
23606
23778
|
...isHub && ncHandlers !== void 0 ? {
|
|
23607
|
-
customActions:
|
|
23608
|
-
|
|
23779
|
+
customActions: {
|
|
23780
|
+
...ncActions,
|
|
23781
|
+
...embeddingActions
|
|
23782
|
+
},
|
|
23783
|
+
actionHandlers: {
|
|
23784
|
+
...ncHandlers,
|
|
23785
|
+
...this.buildEmbeddingActionHandlers()
|
|
23786
|
+
}
|
|
23609
23787
|
} : {}
|
|
23610
23788
|
};
|
|
23611
23789
|
}
|
|
@@ -26858,33 +27036,40 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
|
|
|
26858
27036
|
* widened after the fact.
|
|
26859
27037
|
*/
|
|
26860
27038
|
async rebuildObjectEmbeddings(input) {
|
|
27039
|
+
if (this.rebuildState.running) {
|
|
27040
|
+
this.ctx.logger.info("object embedding rebuild already running — request ignored");
|
|
27041
|
+
return {
|
|
27042
|
+
started: false,
|
|
27043
|
+
alreadyRunning: true
|
|
27044
|
+
};
|
|
27045
|
+
}
|
|
26861
27046
|
const store = this.objectEmbeddingStore;
|
|
26862
27047
|
const trackStore = this.trackStore;
|
|
26863
27048
|
const mediaStore = this.mediaStore;
|
|
26864
27049
|
const eventStore = this.eventStore;
|
|
26865
27050
|
const api = this.ctx.api;
|
|
26866
|
-
const empty = {
|
|
26867
|
-
scanned: 0,
|
|
26868
|
-
rebuilt: 0,
|
|
26869
|
-
missingKeyFrame: 0,
|
|
26870
|
-
missingBbox: 0,
|
|
26871
|
-
failed: 0,
|
|
26872
|
-
complete: true
|
|
26873
|
-
};
|
|
26874
27051
|
if (!store || !trackStore || !mediaStore || !eventStore || !api) {
|
|
26875
27052
|
this.ctx.logger.warn("rebuildObjectEmbeddings: analytics stores unavailable");
|
|
26876
|
-
return
|
|
27053
|
+
return {
|
|
27054
|
+
started: false,
|
|
27055
|
+
alreadyRunning: false
|
|
27056
|
+
};
|
|
26877
27057
|
}
|
|
26878
27058
|
const modelId = await this.resolveEncoderModelId(api) ?? "unknown";
|
|
26879
27059
|
const deviceIds = input.deviceId !== void 0 ? [input.deviceId] : await trackStore.listDeviceIds();
|
|
26880
|
-
|
|
26881
|
-
|
|
26882
|
-
|
|
27060
|
+
const deps = {
|
|
27061
|
+
listTrackIdPage: async (cursor) => {
|
|
27062
|
+
const page = await trackStore.queryRecent({
|
|
26883
27063
|
deviceIds,
|
|
26884
27064
|
...input.since !== void 0 ? { since: input.since } : {},
|
|
26885
27065
|
...input.until !== void 0 ? { until: input.until } : {},
|
|
26886
|
-
|
|
26887
|
-
|
|
27066
|
+
...cursor !== null ? { cursor } : {},
|
|
27067
|
+
limit: REBUILD_PAGE_SIZE
|
|
27068
|
+
});
|
|
27069
|
+
return {
|
|
27070
|
+
trackIds: page.tracks.map((t) => t.trackId),
|
|
27071
|
+
nextCursor: page.nextCursor
|
|
27072
|
+
};
|
|
26888
27073
|
},
|
|
26889
27074
|
loadSource: async (trackId) => {
|
|
26890
27075
|
const media = await mediaStore.listByOwner("track", trackId);
|
|
@@ -26930,11 +27115,93 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
|
|
|
26930
27115
|
info: (message, extras) => this.ctx.logger.info(message, extras),
|
|
26931
27116
|
warn: (message, extras) => this.ctx.logger.warn(message, extras)
|
|
26932
27117
|
}
|
|
26933
|
-
}
|
|
27118
|
+
};
|
|
27119
|
+
this.rebuildState = {
|
|
27120
|
+
running: true,
|
|
27121
|
+
startedAtMs: Date.now(),
|
|
27122
|
+
progress: {
|
|
27123
|
+
scanned: 0,
|
|
27124
|
+
rebuilt: 0,
|
|
27125
|
+
missingKeyFrame: 0,
|
|
27126
|
+
missingBbox: 0,
|
|
27127
|
+
failed: 0
|
|
27128
|
+
}
|
|
27129
|
+
};
|
|
27130
|
+
rebuildObjectEmbeddings(deps, {
|
|
26934
27131
|
...input.cropMargin !== void 0 ? { cropMargin: input.cropMargin } : {},
|
|
26935
27132
|
...input.square !== void 0 ? { square: input.square } : {},
|
|
26936
|
-
...input.maxTracks !== void 0 ? { maxTracks: input.maxTracks } : {}
|
|
27133
|
+
...input.maxTracks !== void 0 ? { maxTracks: input.maxTracks } : {},
|
|
27134
|
+
onProgress: (progress) => {
|
|
27135
|
+
if (this.rebuildState.running) this.rebuildState.progress = progress;
|
|
27136
|
+
this.ctx.logger.info("object embedding rebuild progress", { meta: { ...progress } });
|
|
27137
|
+
}
|
|
27138
|
+
}).then((outcome) => {
|
|
27139
|
+
this.rebuildState = {
|
|
27140
|
+
running: false,
|
|
27141
|
+
startedAtMs: this.rebuildState.startedAtMs ?? Date.now(),
|
|
27142
|
+
finishedAtMs: Date.now(),
|
|
27143
|
+
progress: outcome,
|
|
27144
|
+
complete: outcome.complete
|
|
27145
|
+
};
|
|
27146
|
+
}).catch((err) => {
|
|
27147
|
+
this.rebuildState = {
|
|
27148
|
+
running: false,
|
|
27149
|
+
startedAtMs: this.rebuildState.startedAtMs ?? Date.now(),
|
|
27150
|
+
finishedAtMs: Date.now(),
|
|
27151
|
+
error: String(err)
|
|
27152
|
+
};
|
|
27153
|
+
this.ctx.logger.warn("object embedding rebuild failed", { meta: { error: String(err) } });
|
|
26937
27154
|
});
|
|
27155
|
+
this.ctx.logger.info("object embedding rebuild started", { meta: {
|
|
27156
|
+
deviceId: input.deviceId ?? "all",
|
|
27157
|
+
cropMargin: input.cropMargin ?? "default",
|
|
27158
|
+
maxTracks: input.maxTracks ?? "unbounded"
|
|
27159
|
+
} });
|
|
27160
|
+
return {
|
|
27161
|
+
started: true,
|
|
27162
|
+
alreadyRunning: false
|
|
27163
|
+
};
|
|
27164
|
+
}
|
|
27165
|
+
/**
|
|
27166
|
+
* Handlers behind the embedding buttons in the settings form.
|
|
27167
|
+
*
|
|
27168
|
+
* They are thin wrappers over the cap methods on purpose: the button and the
|
|
27169
|
+
* API must not be able to drift into two behaviours.
|
|
27170
|
+
*/
|
|
27171
|
+
buildEmbeddingActionHandlers() {
|
|
27172
|
+
return {
|
|
27173
|
+
"embedding.rebuild": async (input) => this.rebuildObjectEmbeddings(input),
|
|
27174
|
+
"embedding.rebuildStatus": async () => {
|
|
27175
|
+
const status = await this.getObjectEmbeddingRebuildStatus();
|
|
27176
|
+
let indexed = 0;
|
|
27177
|
+
try {
|
|
27178
|
+
const api = this.ctx.api;
|
|
27179
|
+
if (api) indexed = (await api.vectorStore.stats.query({ index: OBJECT_CLIP_INDEX })).count;
|
|
27180
|
+
} catch {}
|
|
27181
|
+
return {
|
|
27182
|
+
...status,
|
|
27183
|
+
indexed
|
|
27184
|
+
};
|
|
27185
|
+
},
|
|
27186
|
+
"embedding.wipe": async () => this.wipeObjectEmbeddings()
|
|
27187
|
+
};
|
|
27188
|
+
}
|
|
27189
|
+
/** Progress of the detached rebuild — the only way to observe a long pass. */
|
|
27190
|
+
async getObjectEmbeddingRebuildStatus() {
|
|
27191
|
+
const state = this.rebuildState;
|
|
27192
|
+
const p = state.progress;
|
|
27193
|
+
return {
|
|
27194
|
+
running: state.running,
|
|
27195
|
+
scanned: p?.scanned ?? 0,
|
|
27196
|
+
rebuilt: p?.rebuilt ?? 0,
|
|
27197
|
+
missingKeyFrame: p?.missingKeyFrame ?? 0,
|
|
27198
|
+
missingBbox: p?.missingBbox ?? 0,
|
|
27199
|
+
failed: p?.failed ?? 0,
|
|
27200
|
+
complete: state.complete ?? null,
|
|
27201
|
+
startedAtMs: state.startedAtMs ?? null,
|
|
27202
|
+
finishedAtMs: state.finishedAtMs ?? null,
|
|
27203
|
+
error: state.error ?? null
|
|
27204
|
+
};
|
|
26938
27205
|
}
|
|
26939
27206
|
async searchObjectEvents(input) {
|
|
26940
27207
|
const store = this.objectEmbeddingStore;
|
|
@@ -27347,4 +27614,4 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
|
|
|
27347
27614
|
}
|
|
27348
27615
|
};
|
|
27349
27616
|
//#endregion
|
|
27350
|
-
export { DETECTION_PIPELINE_SECTION_IDS,
|
|
27617
|
+
export { DETECTION_PIPELINE_SECTION_IDS, customActions, PipelineAnalyticsAddon as default, ncActions, pickCleanMedia, retagDetectionSections, retagRetentionSection, stripGlobalOnlyFields, toAnalyticsDeviceSections };
|
|
@@ -30,7 +30,7 @@ async function d(e) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
async function f() {
|
|
33
|
-
return l ||= d(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-
|
|
33
|
+
return l ||= d(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-DX4bQCYL.mjs")).catch((e) => {
|
|
34
34
|
throw l = void 0, e;
|
|
35
35
|
}), l;
|
|
36
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-post-analysis",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.43",
|
|
4
4
|
"description": "Post-Analysis bundle — enrichment, embedding-encoder, pipeline-analytics. Multi-entry npm package shipping addons that consume pipeline output.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|