@camstack/types 1.2.357 → 1.2.359

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.
@@ -39,6 +39,13 @@ declare const CameraStepOverridePatchSchema: z.ZodObject<{
39
39
  modelId: z.ZodOptional<z.ZodString>;
40
40
  settings: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
41
41
  }, z.core.$strip>;
42
+ /** The three root-detector choices a camera has (D507: at most one root). */
43
+ export declare const CameraDetectionSourceSchema: z.ZodEnum<{
44
+ none: "none";
45
+ onboard: "onboard";
46
+ pipeline: "pipeline";
47
+ }>;
48
+ export type CameraDetectionSource = z.infer<typeof CameraDetectionSourceSchema>;
42
49
  /**
43
50
  * Pipeline placement record persisted by `addon-pipeline-orchestrator` via
44
51
  * the multi-level settings store. The orchestrator looks up these records
@@ -2318,6 +2325,48 @@ export declare const pipelineOrchestratorCapability: {
2318
2325
  }, z.core.$strip>, z.ZodObject<{
2319
2326
  success: z.ZodLiteral<true>;
2320
2327
  }, z.core.$strip>, "mutation">;
2328
+ /**
2329
+ * Where this camera's first-level detections come from: this node's own
2330
+ * root step (`pipeline`), the camera's onboard detector alone (`onboard`),
2331
+ * or no root detector (`none`). A camera runs at most one root detector
2332
+ * (D507), so there is no "both". Read from the camera's stored
2333
+ * `detectionSources` — the one authority; `explicit` is false while the
2334
+ * operator has never picked and the default stands.
2335
+ */
2336
+ readonly getCameraDetectionSource: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
2337
+ deviceId: z.ZodNumber;
2338
+ }, z.core.$strip>, z.ZodObject<{
2339
+ source: z.ZodEnum<{
2340
+ none: "none";
2341
+ onboard: "onboard";
2342
+ pipeline: "pipeline";
2343
+ }>;
2344
+ explicit: z.ZodBoolean;
2345
+ onboard: z.ZodObject<{
2346
+ available: z.ZodBoolean;
2347
+ geometry: z.ZodEnum<{
2348
+ boxed: "boxed";
2349
+ "flag-only": "flag-only";
2350
+ unknown: "unknown";
2351
+ "while-streaming": "while-streaming";
2352
+ }>;
2353
+ }, z.core.$strip>;
2354
+ }, z.core.$strip>, import("./capability-definition.js").CapabilityMethodKind>;
2355
+ /**
2356
+ * Pick where this camera's detections come from. Writes `detectionSources`
2357
+ * and arms (or disarms) the vendor's boxed sub-stream that the choice
2358
+ * drives. Refuses `onboard` on a camera with no onboard detector.
2359
+ */
2360
+ readonly setCameraDetectionSource: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
2361
+ deviceId: z.ZodNumber;
2362
+ source: z.ZodEnum<{
2363
+ none: "none";
2364
+ onboard: "onboard";
2365
+ pipeline: "pipeline";
2366
+ }>;
2367
+ }, z.core.$strip>, z.ZodObject<{
2368
+ success: z.ZodLiteral<true>;
2369
+ }, z.core.$strip>, "mutation">;
2321
2370
  /** Read every per-(node,device) override map for a device. Null when device has no overrides. */
2322
2371
  readonly getCameraStepOverrides: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
2323
2372
  deviceId: z.ZodNumber;
@@ -80,6 +80,43 @@ declare const BulkRecordSchema: z.ZodObject<{
80
80
  id: z.ZodOptional<z.ZodString>;
81
81
  data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
82
82
  }, z.core.$strip>;
83
+ /**
84
+ * One write inside a {@link settingsStoreCapability.methods.transact} call.
85
+ * Only the three that a "replace this set, bump that revision" write needs.
86
+ */
87
+ declare const TransactOpSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
88
+ op: z.ZodLiteral<"deleteWhere">;
89
+ collection: z.ZodString;
90
+ filter: z.ZodObject<{
91
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
92
+ whereIn: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown>>>;
93
+ whereBetween: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodTuple<[z.ZodUnknown, z.ZodUnknown], null>>>;
94
+ whereNot: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
95
+ whereNotIn: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown>>>;
96
+ }, z.core.$strip>;
97
+ }, z.core.$strip>, z.ZodObject<{
98
+ op: z.ZodLiteral<"insertMany">;
99
+ collection: z.ZodString;
100
+ records: z.ZodReadonly<z.ZodArray<z.ZodObject<{
101
+ id: z.ZodOptional<z.ZodString>;
102
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
103
+ }, z.core.$strip>>>;
104
+ }, z.core.$strip>, z.ZodObject<{
105
+ op: z.ZodLiteral<"update">;
106
+ collection: z.ZodString;
107
+ id: z.ZodString;
108
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
109
+ }, z.core.$strip>], "op">;
110
+ /**
111
+ * The precondition of a transaction: the row `key` of `collection` must hold
112
+ * `equals` in `column`, read INSIDE the transaction.
113
+ */
114
+ declare const TransactGuardSchema: z.ZodObject<{
115
+ collection: z.ZodString;
116
+ key: z.ZodString;
117
+ column: z.ZodString;
118
+ equals: z.ZodUnknown;
119
+ }, z.core.$strip>;
83
120
  /**
84
121
  * Column declaration for a structured (SQL-backed) collection.
85
122
  *
@@ -302,6 +339,60 @@ export declare const settingsStoreCapability: {
302
339
  }, z.core.$strip>, z.ZodObject<{
303
340
  inserted: z.ZodNumber;
304
341
  }, z.core.$strip>, "mutation">;
342
+ /**
343
+ * Several writes, ONE transaction, behind an optional precondition.
344
+ *
345
+ * The multi-collection twin of {@link insertMany}: a write that has to move
346
+ * a set of rows in one collection AND a revision in another cannot be
347
+ * expressed as separate calls without a window in which a reader (or a
348
+ * crash) sees half of it. The retrain annotation save replaces a frame's
349
+ * rows, its dismissed set and its revision this way.
350
+ *
351
+ * `guard`, when given, is read inside the transaction: if the row is
352
+ * missing or its column differs from `equals`, NOTHING is written and the
353
+ * answer is `{ applied: false, current }` with what was found — the
354
+ * compare-and-set a revisioned write needs, with no second reader able to
355
+ * slip between the check and the writes.
356
+ *
357
+ * **All or nothing**, like {@link insertMany}: a throw in any op rolls the
358
+ * whole call back. Ops run in the order given (delete before insert to
359
+ * replace a set). `namespace` applies to every collection named.
360
+ */
361
+ readonly transact: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
362
+ namespace: z.ZodOptional<z.ZodString>;
363
+ guard: z.ZodOptional<z.ZodObject<{
364
+ collection: z.ZodString;
365
+ key: z.ZodString;
366
+ column: z.ZodString;
367
+ equals: z.ZodUnknown;
368
+ }, z.core.$strip>>;
369
+ ops: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
370
+ op: z.ZodLiteral<"deleteWhere">;
371
+ collection: z.ZodString;
372
+ filter: z.ZodObject<{
373
+ where: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
374
+ whereIn: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown>>>;
375
+ whereBetween: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodTuple<[z.ZodUnknown, z.ZodUnknown], null>>>;
376
+ whereNot: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
377
+ whereNotIn: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown>>>;
378
+ }, z.core.$strip>;
379
+ }, z.core.$strip>, z.ZodObject<{
380
+ op: z.ZodLiteral<"insertMany">;
381
+ collection: z.ZodString;
382
+ records: z.ZodReadonly<z.ZodArray<z.ZodObject<{
383
+ id: z.ZodOptional<z.ZodString>;
384
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
385
+ }, z.core.$strip>>>;
386
+ }, z.core.$strip>, z.ZodObject<{
387
+ op: z.ZodLiteral<"update">;
388
+ collection: z.ZodString;
389
+ id: z.ZodString;
390
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
391
+ }, z.core.$strip>], "op">>>;
392
+ }, z.core.$strip>, z.ZodObject<{
393
+ applied: z.ZodBoolean;
394
+ current: z.ZodOptional<z.ZodUnknown>;
395
+ }, z.core.$strip>, "mutation">;
305
396
  /** Update an existing record by ID. */
306
397
  readonly update: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
307
398
  namespace: z.ZodOptional<z.ZodString>;
@@ -513,7 +604,7 @@ export type ISettingsStoreProvider = InferProvider<typeof settingsStoreCapabilit
513
604
  * Methods are accessed as `client.get.query(input)`, `client.set.mutate(input)`, etc.
514
605
  */
515
606
  export type SettingsStoreClient = import('../generated/addon-api.js').AddonApi['settingsStore'];
516
- export { AggregateFieldSchema, AggregateResultSchema, BulkRecordSchema, CollectionColumnSchema, CollectionIndexSchema, MutationFilterSchema, QueryFilterSchema, SettingsRecordSchema, };
607
+ export { AggregateFieldSchema, AggregateResultSchema, BulkRecordSchema, CollectionColumnSchema, CollectionIndexSchema, MutationFilterSchema, QueryFilterSchema, SettingsRecordSchema, TransactGuardSchema, TransactOpSchema, };
517
608
  export type BulkRecord = z.infer<typeof BulkRecordSchema>;
518
609
  export type AggregateField = z.infer<typeof AggregateFieldSchema>;
519
610
  export type AggregateResult = z.infer<typeof AggregateResultSchema>;
@@ -278,6 +278,17 @@ export declare const BrokerClientsSchema: z.ZodObject<{
278
278
  export type BrokerRtspClient = z.infer<typeof BrokerRtspClientSchema>;
279
279
  export type BrokerAudioClient = z.infer<typeof BrokerAudioClientSchema>;
280
280
  export type BrokerClients = z.infer<typeof BrokerClientsSchema>;
281
+ /**
282
+ * How many people are watching one camera LIVE right now — see
283
+ * `getLiveViewerCounts`. A camera with nobody watching is absent from the list
284
+ * (so `viewers` is always at least 1): the listing carries the cameras that
285
+ * have viewers, never a row of zeros.
286
+ */
287
+ export declare const LiveViewerCountSchema: z.ZodObject<{
288
+ deviceId: z.ZodNumber;
289
+ viewers: z.ZodNumber;
290
+ }, z.core.$strip>;
291
+ export type LiveViewerCount = z.infer<typeof LiveViewerCountSchema>;
281
292
  export declare const PlaceholderReasonSchema: z.ZodEnum<{
282
293
  disabled: "disabled";
283
294
  offline: "offline";
@@ -997,6 +1008,27 @@ export declare const streamBrokerCapability: {
997
1008
  pipeClients: z.ZodNumber;
998
1009
  encodedSubscribers: z.ZodNumber;
999
1010
  }, z.core.$strip>, import("./capability-definition.js").CapabilityMethodKind>;
1011
+ /**
1012
+ * People watching each camera LIVE right now, for every camera at once —
1013
+ * cheap enough to poll (a walk of the live session maps, no I/O).
1014
+ *
1015
+ * Counts EXTERNAL viewers only: WebRTC sessions of a viewer kind
1016
+ * (`webrtc-browser` / `-mobile` / `-whep`, `alexa`, `homekit`) that are on
1017
+ * the live edge, plus RTSP restream clients from outside that are playing.
1018
+ * The system's own consumers are never counted: the detection decoder, the
1019
+ * recorder, snapshots, the prebuffer hold, audio analysis, and the RTSP
1020
+ * dials an agent's derived broker makes. One WebRTC session or RTSP
1021
+ * connection is one viewer, so two tabs on one camera read 2.
1022
+ *
1023
+ * The count is read off the live session maps at call time, so a session
1024
+ * that ends — cleanly or by the peer vanishing — stops counting with no
1025
+ * counter to leak. It covers the sessions THIS provider serves; a node
1026
+ * with its own stream-broker is asked with a `nodeId` pin.
1027
+ */
1028
+ readonly getLiveViewerCounts: import("./capability-definition.js").CapabilityMethodSchema<z.ZodVoid, z.ZodReadonly<z.ZodArray<z.ZodObject<{
1029
+ deviceId: z.ZodNumber;
1030
+ viewers: z.ZodNumber;
1031
+ }, z.core.$strip>>>, import("./capability-definition.js").CapabilityMethodKind>;
1000
1032
  readonly killClient: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
1001
1033
  brokerId: z.ZodString;
1002
1034
  channel: z.ZodEnum<{
package/dist/client.d.ts CHANGED
@@ -14,4 +14,4 @@
14
14
  * value this entry does not export — a missing name here is `undefined` at
15
15
  * runtime, not a build error.
16
16
  */
17
- export { APPLE_SA_TO_MACRO, AUDIO_MACRO_LABELS, AlarmArmModeSchema, CLIP_BROKER_PACED_RATES, COCO_TO_MACRO, CamProfileSchema, DEFAULT_TIMELAPSE_PREVIEW_TEXT, DeviceType, EVENTFUL_CAP_NAMES, EVENT_KIND_BY_CAP, EVENT_TAXONOMY, MACRO_LABELS, NC_ALARM_DELAY_MAX_SEC, NC_ALARM_SENSORS_MAX, NC_ALARM_SYSTEM_EVENT_KINDS, NC_ALARM_TRIGGERED_MAX_SEC, NC_BATTERY_CONSUMABLE_SYSTEM_EVENT_KINDS, NC_CAMERA_SCOPE_CAP_NAME, NC_CONSUMABLE_LOW_PERCENT_DEFAULT, NC_CONSUMABLE_LOW_PERCENT_MAX, NC_GROUPING_DEFAULT_SEC, NC_GROUPING_MAX_SEC, NC_GROUPING_MIN_SEC, NC_RULE_EDITOR_SECTION_ORDER, NC_RULE_KIND_SPECS, NC_SENSOR_TRANSITION_UNSUPPORTED_REASON, NC_SYSTEM_EVENT_FAMILY_FILTERS, NC_SYSTEM_EVENT_KIND_GROUP_SPECS, NC_SYSTEM_EVENT_SUMMARY_FAMILIES, NC_TEMPLATE_HELD_BACK_SYSTEM_EVENT_KINDS, NC_TEMPLATE_VARS, NcAlarmConfigSchema, NcAlarmSensorsSchema, NcAlarmSettingsPatchSchema, NcHistoryEntrySchema, NcRuleLastRunsSchema, NodeDirectorySchema, RECORDING_EXPORT_MAX_READ_BYTES, SystemMirror, TIMELAPSE_DENSE_FLOOR_SEC, TimelapseRuleSchema, YAMNET_TO_MACRO, alarmDeviceBlocksArming, alarmDeviceSecureOnArm, alarmPatchLanded, conditionVisibleForKind, createSystemProxy, droppedConditionsForKind, isHeldBackTemplateVar, isSystemRuleKind, kindsForDiscriminator, knownValues, nodePickerItems, packagePickerItems, pickerForCondition, pickerForRuleClasses, resolveModeDelays, ruleDeviceCompatCapNames, ruleEditorSectionsForKind, ruleGroupingApplies, ruleKindOf, ruleKindSpec, ruleSeedForSection, sensorTransitionNeverFires, sensorTransitionOffered, stateLabel, systemEventDeliveryProblems, systemEventFilterAppliesToAnyKind, systemEventKindsOfFamily, systemFamilyOfKind, templateCarriesSummary, templateVarDeliveryApplies, templateVarKindApplies, templateVarSystemEventApplies, } from './index.js';
17
+ export { APPLE_SA_TO_MACRO, AUDIO_MACRO_LABELS, AlarmArmModeSchema, CLIP_BROKER_PACED_RATES, COCO_TO_MACRO, CamProfileSchema, DEFAULT_TIMELAPSE_PREVIEW_TEXT, DeviceType, EVENTFUL_CAP_NAMES, EVENT_KIND_BY_CAP, EVENT_TAXONOMY, MACRO_LABELS, NC_ALARM_DELAY_MAX_SEC, NC_ALARM_SENSORS_MAX, NC_ALARM_SYSTEM_EVENT_KINDS, NC_ALARM_TRIGGERED_MAX_SEC, NC_BATTERY_CONSUMABLE_SYSTEM_EVENT_KINDS, NC_CAMERA_SCOPE_CAP_NAME, NC_CONSUMABLE_LOW_PERCENT_DEFAULT, NC_CONSUMABLE_LOW_PERCENT_MAX, NC_GROUPING_DEFAULT_SEC, NC_GROUPING_MAX_SEC, NC_GROUPING_MIN_SEC, NC_RULE_EDITOR_SECTION_ORDER, NC_RULE_KIND_SPECS, NC_SENSOR_TRANSITION_UNSUPPORTED_REASON, NC_SYSTEM_EVENT_FAMILY_FILTERS, NC_SYSTEM_EVENT_KIND_GROUP_SPECS, NC_SYSTEM_EVENT_SUMMARY_FAMILIES, NC_TEMPLATE_HELD_BACK_SYSTEM_EVENT_KINDS, NC_TEMPLATE_VARS, NcAlarmConfigSchema, NcAlarmSensorsSchema, NcAlarmSettingsPatchSchema, NcHistoryEntrySchema, NcRuleLastRunsSchema, NodeDirectorySchema, RECORDING_EXPORT_MAX_READ_BYTES, RETRAIN_REVIEW_ADJUSTED_IOU, RETRAIN_REVIEW_MATCH_IOU, RETRAIN_REVIEW_STATUSES, RETRAIN_REVISION_CONFLICT, SystemMirror, TIMELAPSE_DENSE_FLOOR_SEC, TimelapseRuleSchema, YAMNET_TO_MACRO, alarmDeviceBlocksArming, alarmDeviceSecureOnArm, alarmPatchLanded, classifyRetrainReview, conditionVisibleForKind, createSystemProxy, droppedConditionsForKind, isHeldBackTemplateVar, isSystemRuleKind, kindsForDiscriminator, knownValues, nodePickerItems, packagePickerItems, pickerForCondition, pickerForRuleClasses, parseRetrainRevisionConflict, resolveModeDelays, retrainBoxIou, retrainRevisionConflictMessage, ruleDeviceCompatCapNames, ruleEditorSectionsForKind, ruleGroupingApplies, ruleKindOf, ruleKindSpec, ruleSeedForSection, sensorTransitionNeverFires, sensorTransitionOffered, stateLabel, summarizeReview, systemEventDeliveryProblems, systemEventFilterAppliesToAnyKind, systemEventKindsOfFamily, systemFamilyOfKind, templateCarriesSummary, templateVarDeliveryApplies, templateVarKindApplies, templateVarSystemEventApplies, } from './index.js';
package/dist/client.js CHANGED
@@ -100,6 +100,202 @@ var PeerBytesTicketSchema = zod.z.object({
100
100
  declaredBytes: zod.z.number().int().nonnegative().nullable()
101
101
  });
102
102
  //#endregion
103
+ //#region src/retrain-review.ts
104
+ /** Every status, in the order a summary lists them. */
105
+ var RETRAIN_REVIEW_STATUSES = [
106
+ "unchanged",
107
+ "adjusted",
108
+ "reclassified",
109
+ "added",
110
+ "removed",
111
+ "model-error"
112
+ ];
113
+ /**
114
+ * Two boxes overlapping at least this much are the same subject when a legacy
115
+ * row (no origin) is matched against a proposal. Deliberately loose: a legacy
116
+ * row is judged on evidence that is no longer exact.
117
+ */
118
+ var RETRAIN_REVIEW_MATCH_IOU = .5;
119
+ /**
120
+ * A kept box overlapping its origin at least this much is `unchanged`; below it
121
+ * the rectangle was moved or resized on purpose (`adjusted`). Not 1.0: the
122
+ * canvas rounds, and a box dragged by one pixel and dragged back is not an edit.
123
+ */
124
+ var RETRAIN_REVIEW_ADJUSTED_IOU = .95;
125
+ /** Two boxes this close on every edge are the same rectangle (an exact match). */
126
+ var EXACT_EDGE_EPSILON = 1e-6;
127
+ /** Intersection over union of two normalised rectangles. */
128
+ function retrainBoxIou(a, b) {
129
+ const inter = Math.max(0, Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x)) * Math.max(0, Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y));
130
+ const union = a.w * a.h + b.w * b.h - inter;
131
+ return union > 0 ? inter / union : 0;
132
+ }
133
+ function sameRect(a, b) {
134
+ return Math.abs(a.x - b.x) <= EXACT_EDGE_EPSILON && Math.abs(a.y - b.y) <= EXACT_EDGE_EPSILON && Math.abs(a.w - b.w) <= EXACT_EDGE_EPSILON && Math.abs(a.h - b.h) <= EXACT_EDGE_EPSILON;
135
+ }
136
+ function labelOf(value) {
137
+ return value?.trim() ?? "";
138
+ }
139
+ /** Kept box versus its baseline: class/label first, then geometry. */
140
+ function compareKept(saved, baseline, adjustedIou) {
141
+ const iou = retrainBoxIou(saved.bbox, baseline.bbox);
142
+ if (saved.macroClass !== baseline.macroClass || labelOf(saved.label) !== labelOf(baseline.label)) return {
143
+ status: "reclassified",
144
+ iou
145
+ };
146
+ return {
147
+ status: iou < adjustedIou ? "adjusted" : "unchanged",
148
+ iou
149
+ };
150
+ }
151
+ /**
152
+ * Pair legacy rows with proposals: exact rectangles first, then by descending
153
+ * overlap, one proposal per row. Greedy on a sorted list so the result does not
154
+ * depend on the order the rows were listed in.
155
+ */
156
+ function pairLegacy(saved, legacyIndexes, origins, matchIou) {
157
+ const candidates = [];
158
+ for (const savedIndex of legacyIndexes) {
159
+ const box = saved[savedIndex];
160
+ if (box === void 0) continue;
161
+ origins.forEach((origin, originIndex) => {
162
+ const exact = sameRect(box.bbox, origin.bbox);
163
+ const iou = exact ? 1 : retrainBoxIou(box.bbox, origin.bbox);
164
+ if (exact || iou >= matchIou) candidates.push({
165
+ savedIndex,
166
+ originIndex,
167
+ iou,
168
+ exact
169
+ });
170
+ });
171
+ }
172
+ candidates.sort((a, b) => Number(b.exact) - Number(a.exact) || b.iou - a.iou);
173
+ const pairs = /* @__PURE__ */ new Map();
174
+ const takenOrigins = /* @__PURE__ */ new Set();
175
+ for (const c of candidates) {
176
+ if (pairs.has(c.savedIndex) || takenOrigins.has(c.originIndex)) continue;
177
+ pairs.set(c.savedIndex, c.originIndex);
178
+ takenOrigins.add(c.originIndex);
179
+ }
180
+ return pairs;
181
+ }
182
+ /**
183
+ * Classify what the operator did on ONE frame.
184
+ *
185
+ * @param saved the frame's saved boxes.
186
+ * @param origins the proposals known now (the pipeline's boxes, re-derived) —
187
+ * consulted ONLY for rows that carry no origin snapshot.
188
+ * @param dismissed the proposals the operator deleted, with their snapshots.
189
+ */
190
+ function classifyRetrainReview(saved, origins, dismissed, opts = {}) {
191
+ const matchIou = opts.matchIou ?? .5;
192
+ const adjustedIou = opts.adjustedIou ?? .95;
193
+ const claimedRefs = /* @__PURE__ */ new Set();
194
+ const boxes = [];
195
+ const legacyIndexes = [];
196
+ saved.forEach((box, index) => {
197
+ if (box.origin === null) legacyIndexes.push(index);
198
+ else claimedRefs.add(box.origin.ref);
199
+ });
200
+ for (const entry of dismissed) claimedRefs.add(entry.ref);
201
+ const legacyPairs = pairLegacy(saved, legacyIndexes, origins, matchIou);
202
+ for (const originIndex of legacyPairs.values()) {
203
+ const origin = origins[originIndex];
204
+ if (origin !== void 0) claimedRefs.add(origin.ref);
205
+ }
206
+ saved.forEach((box, index) => {
207
+ const exactBaseline = box.origin;
208
+ const pairedOrigin = exactBaseline === null ? origins[legacyPairs.get(index) ?? -1] : void 0;
209
+ const baseline = exactBaseline ?? pairedOrigin ?? null;
210
+ const approximate = exactBaseline === null;
211
+ if (box.kind === "model_error") {
212
+ boxes.push({
213
+ ref: box.id,
214
+ savedId: box.id,
215
+ status: "model-error",
216
+ approximate: false,
217
+ ...baseline !== null ? {
218
+ origin: baseline,
219
+ iou: retrainBoxIou(box.bbox, baseline.bbox)
220
+ } : {}
221
+ });
222
+ return;
223
+ }
224
+ if (baseline === null || baseline.source === "operator") {
225
+ boxes.push({
226
+ ref: box.id,
227
+ savedId: box.id,
228
+ status: "added",
229
+ approximate: approximate && baseline === null,
230
+ ...baseline !== null ? { origin: baseline } : {}
231
+ });
232
+ return;
233
+ }
234
+ const verdict = compareKept(box, baseline, adjustedIou);
235
+ boxes.push({
236
+ ref: box.id,
237
+ savedId: box.id,
238
+ status: verdict.status,
239
+ approximate,
240
+ origin: baseline,
241
+ iou: verdict.iou
242
+ });
243
+ });
244
+ for (const entry of dismissed) boxes.push({
245
+ ref: entry.ref,
246
+ status: "removed",
247
+ approximate: false,
248
+ origin: entry.snapshot
249
+ });
250
+ if (opts.inferRemoved === true) for (const origin of origins) {
251
+ if (claimedRefs.has(origin.ref)) continue;
252
+ boxes.push({
253
+ ref: origin.ref,
254
+ status: "removed",
255
+ approximate: true,
256
+ origin
257
+ });
258
+ }
259
+ return {
260
+ boxes,
261
+ approximate: boxes.some((b) => b.approximate)
262
+ };
263
+ }
264
+ /** Counts per status, plus the totals a list row shows. */
265
+ function summarizeReview(review) {
266
+ const counts = {
267
+ unchanged: 0,
268
+ adjusted: 0,
269
+ reclassified: 0,
270
+ added: 0,
271
+ removed: 0,
272
+ "model-error": 0
273
+ };
274
+ for (const box of review.boxes) counts[box.status] += 1;
275
+ return {
276
+ counts,
277
+ total: review.boxes.length,
278
+ changed: review.boxes.length - counts.unchanged,
279
+ approximate: review.approximate
280
+ };
281
+ }
282
+ /** The prefix of the error a stale `expectedRevision` save is refused with. */
283
+ var RETRAIN_REVISION_CONFLICT = "retrain-revision-conflict";
284
+ /** The message a refused save carries — `parseRetrainRevisionConflict` reads it back. */
285
+ function retrainRevisionConflictMessage(frameId, conflict) {
286
+ return `${RETRAIN_REVISION_CONFLICT}: frame ${frameId} moved on — it is at revision ${String(conflict.currentRevision)}, the save expected ${String(conflict.expectedRevision)} (current=${String(conflict.currentRevision)} expected=${String(conflict.expectedRevision)})`;
287
+ }
288
+ /** The conflict an error message names, or `null` when it is some other error. */
289
+ function parseRetrainRevisionConflict(message) {
290
+ if (!message.includes("retrain-revision-conflict")) return null;
291
+ const match = /current=(\d+) expected=(\d+)/.exec(message);
292
+ if (match?.[1] === void 0 || match[2] === void 0) return null;
293
+ return {
294
+ currentRevision: Number(match[1]),
295
+ expectedRevision: Number(match[2])
296
+ };
297
+ }
298
+ //#endregion
103
299
  //#region src/capabilities/schemas/streaming-shared.ts
104
300
  /** Shared Zod schemas used across streaming capabilities. */
105
301
  var CamProfileSchema = zod.z.enum([
@@ -4735,7 +4931,14 @@ var TopologyNodeSchema = zod.z.object({
4735
4931
  * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
4736
4932
  * for offline rows and when the hub cannot tell.
4737
4933
  */
4738
- meshTransport: zod.z.enum(["tls", "clear"]).optional()
4934
+ meshTransport: zod.z.enum(["tls", "clear"]).optional(),
4935
+ /**
4936
+ * Whether the hub holds this online AGENT's capability registration (its
4937
+ * `registerNode` manifest). `false` = online in the mesh but not ready: the
4938
+ * hub dropped the registration on a disconnect only it saw and the agent has
4939
+ * not re-sent it. Absent for the hub and offline rows.
4940
+ */
4941
+ capabilitiesRegistered: zod.z.boolean().optional()
4739
4942
  });
4740
4943
  var CapUsageEdgeSchema = zod.z.object({
4741
4944
  callerAddonId: zod.z.string(),
@@ -5763,6 +5966,7 @@ function createDeviceProxy(api, binding, opts) {
5763
5966
  proposeRetrainAnnotations: (input) => dispatch("pipeline-analytics", "pipelineAnalytics", "proposeRetrainAnnotations", "mutation", input),
5764
5967
  listRetrainAnnotations: (input) => dispatch("pipeline-analytics", "pipelineAnalytics", "listRetrainAnnotations", "query", input),
5765
5968
  saveRetrainAnnotations: (input) => dispatch("pipeline-analytics", "pipelineAnalytics", "saveRetrainAnnotations", "mutation", input),
5969
+ backfillRetrainOrigins: (input) => dispatch("pipeline-analytics", "pipelineAnalytics", "backfillRetrainOrigins", "mutation", input),
5766
5970
  completeRetrainTrack: (input) => dispatch("pipeline-analytics", "pipelineAnalytics", "completeRetrainTrack", "mutation", input),
5767
5971
  restageRetrainTrack: (input) => dispatch("pipeline-analytics", "pipelineAnalytics", "restageRetrainTrack", "mutation", input),
5768
5972
  getRetrainExportUrl: (input) => dispatch("pipeline-analytics", "pipelineAnalytics", "getRetrainExportUrl", "query", input),
@@ -6046,6 +6250,8 @@ function createDeviceProxy(api, binding, opts) {
6046
6250
  getAudioAssignment: (input) => dispatchSystem("pipelineOrchestrator", "getAudioAssignment", "query", input),
6047
6251
  getCameraSettings: (input) => dispatchSystem("pipelineOrchestrator", "getCameraSettings", "query", input),
6048
6252
  setCameraStepToggle: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepToggle", "mutation", input),
6253
+ getCameraDetectionSource: (input) => dispatchSystem("pipelineOrchestrator", "getCameraDetectionSource", "query", input),
6254
+ setCameraDetectionSource: (input) => dispatchSystem("pipelineOrchestrator", "setCameraDetectionSource", "mutation", input),
6049
6255
  getCameraStepOverrides: (input) => dispatchSystem("pipelineOrchestrator", "getCameraStepOverrides", "query", input),
6050
6256
  setCameraStepOverride: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepOverride", "mutation", input),
6051
6257
  setCameraStepSettings: (input) => dispatchSystem("pipelineOrchestrator", "setCameraStepSettings", "mutation", input),
@@ -7568,6 +7774,7 @@ function createSystemProxy(api) {
7568
7774
  upsert: (input) => dispatch("settingsStore", "upsert", "mutation", input),
7569
7775
  insert: (input) => dispatch("settingsStore", "insert", "mutation", input),
7570
7776
  insertMany: (input) => dispatch("settingsStore", "insertMany", "mutation", input),
7777
+ transact: (input) => dispatch("settingsStore", "transact", "mutation", input),
7571
7778
  update: (input) => dispatch("settingsStore", "update", "mutation", input),
7572
7779
  delete: (input) => dispatch("settingsStore", "delete", "mutation", input),
7573
7780
  deleteWhere: (input) => dispatch("settingsStore", "deleteWhere", "mutation", input),
@@ -7622,6 +7829,7 @@ function createSystemProxy(api) {
7622
7829
  getBrokerStats: (input) => dispatch("streamBroker", "getBrokerStats", "query", input),
7623
7830
  probeStream: (input) => dispatch("streamBroker", "probeStream", "mutation", input),
7624
7831
  listClients: (input) => dispatch("streamBroker", "listClients", "query", input),
7832
+ getLiveViewerCounts: (input) => dispatch("streamBroker", "getLiveViewerCounts", "query", input),
7625
7833
  killClient: (input) => dispatch("streamBroker", "killClient", "mutation", input),
7626
7834
  getStreamUrl: (input) => dispatch("streamBroker", "getStreamUrl", "query", input),
7627
7835
  getStreamWithCodec: (input) => dispatch("streamBroker", "getStreamWithCodec", "mutation", input),
@@ -10632,6 +10840,10 @@ exports.NcHistoryEntrySchema = NcHistoryEntrySchema;
10632
10840
  exports.NcRuleLastRunsSchema = NcRuleLastRunsSchema;
10633
10841
  exports.NodeDirectorySchema = NodeDirectorySchema;
10634
10842
  exports.RECORDING_EXPORT_MAX_READ_BYTES = RECORDING_EXPORT_MAX_READ_BYTES;
10843
+ exports.RETRAIN_REVIEW_ADJUSTED_IOU = RETRAIN_REVIEW_ADJUSTED_IOU;
10844
+ exports.RETRAIN_REVIEW_MATCH_IOU = RETRAIN_REVIEW_MATCH_IOU;
10845
+ exports.RETRAIN_REVIEW_STATUSES = RETRAIN_REVIEW_STATUSES;
10846
+ exports.RETRAIN_REVISION_CONFLICT = RETRAIN_REVISION_CONFLICT;
10635
10847
  exports.SystemMirror = SystemMirror;
10636
10848
  exports.TIMELAPSE_DENSE_FLOOR_SEC = TIMELAPSE_DENSE_FLOOR_SEC;
10637
10849
  exports.TimelapseRuleSchema = TimelapseRuleSchema;
@@ -10639,6 +10851,7 @@ exports.YAMNET_TO_MACRO = YAMNET_TO_MACRO;
10639
10851
  exports.alarmDeviceBlocksArming = alarmDeviceBlocksArming;
10640
10852
  exports.alarmDeviceSecureOnArm = alarmDeviceSecureOnArm;
10641
10853
  exports.alarmPatchLanded = alarmPatchLanded;
10854
+ exports.classifyRetrainReview = classifyRetrainReview;
10642
10855
  exports.conditionVisibleForKind = conditionVisibleForKind;
10643
10856
  exports.createSystemProxy = createSystemProxy;
10644
10857
  exports.droppedConditionsForKind = droppedConditionsForKind;
@@ -10648,9 +10861,12 @@ exports.kindsForDiscriminator = kindsForDiscriminator;
10648
10861
  exports.knownValues = knownValues;
10649
10862
  exports.nodePickerItems = nodePickerItems;
10650
10863
  exports.packagePickerItems = packagePickerItems;
10864
+ exports.parseRetrainRevisionConflict = parseRetrainRevisionConflict;
10651
10865
  exports.pickerForCondition = pickerForCondition;
10652
10866
  exports.pickerForRuleClasses = pickerForRuleClasses;
10653
10867
  exports.resolveModeDelays = resolveModeDelays;
10868
+ exports.retrainBoxIou = retrainBoxIou;
10869
+ exports.retrainRevisionConflictMessage = retrainRevisionConflictMessage;
10654
10870
  exports.ruleDeviceCompatCapNames = ruleDeviceCompatCapNames;
10655
10871
  exports.ruleEditorSectionsForKind = ruleEditorSectionsForKind;
10656
10872
  exports.ruleGroupingApplies = ruleGroupingApplies;
@@ -10660,6 +10876,7 @@ exports.ruleSeedForSection = ruleSeedForSection;
10660
10876
  exports.sensorTransitionNeverFires = sensorTransitionNeverFires;
10661
10877
  exports.sensorTransitionOffered = sensorTransitionOffered;
10662
10878
  exports.stateLabel = stateLabel;
10879
+ exports.summarizeReview = summarizeReview;
10663
10880
  exports.systemEventDeliveryProblems = systemEventDeliveryProblems;
10664
10881
  exports.systemEventFilterAppliesToAnyKind = systemEventFilterAppliesToAnyKind;
10665
10882
  exports.systemEventKindsOfFamily = systemEventKindsOfFamily;