@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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-BFVY4_xY.js");
2
+ const require_sleep = require("./sleep-BBXNq778.js");
3
3
  const require_event_category = require("./event-category-T43rdQWR.js");
4
4
  const require_composition = require("./composition-DCYnv4I6.js");
5
5
  const require_node_color = require("./node-color.js");
@@ -1925,6 +1925,202 @@ function parseTrainingEventLine(line) {
1925
1925
  return parsed.success ? parsed.data : null;
1926
1926
  }
1927
1927
  //#endregion
1928
+ //#region src/retrain-review.ts
1929
+ /** Every status, in the order a summary lists them. */
1930
+ var RETRAIN_REVIEW_STATUSES = [
1931
+ "unchanged",
1932
+ "adjusted",
1933
+ "reclassified",
1934
+ "added",
1935
+ "removed",
1936
+ "model-error"
1937
+ ];
1938
+ /**
1939
+ * Two boxes overlapping at least this much are the same subject when a legacy
1940
+ * row (no origin) is matched against a proposal. Deliberately loose: a legacy
1941
+ * row is judged on evidence that is no longer exact.
1942
+ */
1943
+ var RETRAIN_REVIEW_MATCH_IOU = .5;
1944
+ /**
1945
+ * A kept box overlapping its origin at least this much is `unchanged`; below it
1946
+ * the rectangle was moved or resized on purpose (`adjusted`). Not 1.0: the
1947
+ * canvas rounds, and a box dragged by one pixel and dragged back is not an edit.
1948
+ */
1949
+ var RETRAIN_REVIEW_ADJUSTED_IOU = .95;
1950
+ /** Two boxes this close on every edge are the same rectangle (an exact match). */
1951
+ var EXACT_EDGE_EPSILON = 1e-6;
1952
+ /** Intersection over union of two normalised rectangles. */
1953
+ function retrainBoxIou(a, b) {
1954
+ 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));
1955
+ const union = a.w * a.h + b.w * b.h - inter;
1956
+ return union > 0 ? inter / union : 0;
1957
+ }
1958
+ function sameRect(a, b) {
1959
+ 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;
1960
+ }
1961
+ function labelOf(value) {
1962
+ return value?.trim() ?? "";
1963
+ }
1964
+ /** Kept box versus its baseline: class/label first, then geometry. */
1965
+ function compareKept(saved, baseline, adjustedIou) {
1966
+ const iou = retrainBoxIou(saved.bbox, baseline.bbox);
1967
+ if (saved.macroClass !== baseline.macroClass || labelOf(saved.label) !== labelOf(baseline.label)) return {
1968
+ status: "reclassified",
1969
+ iou
1970
+ };
1971
+ return {
1972
+ status: iou < adjustedIou ? "adjusted" : "unchanged",
1973
+ iou
1974
+ };
1975
+ }
1976
+ /**
1977
+ * Pair legacy rows with proposals: exact rectangles first, then by descending
1978
+ * overlap, one proposal per row. Greedy on a sorted list so the result does not
1979
+ * depend on the order the rows were listed in.
1980
+ */
1981
+ function pairLegacy(saved, legacyIndexes, origins, matchIou) {
1982
+ const candidates = [];
1983
+ for (const savedIndex of legacyIndexes) {
1984
+ const box = saved[savedIndex];
1985
+ if (box === void 0) continue;
1986
+ origins.forEach((origin, originIndex) => {
1987
+ const exact = sameRect(box.bbox, origin.bbox);
1988
+ const iou = exact ? 1 : retrainBoxIou(box.bbox, origin.bbox);
1989
+ if (exact || iou >= matchIou) candidates.push({
1990
+ savedIndex,
1991
+ originIndex,
1992
+ iou,
1993
+ exact
1994
+ });
1995
+ });
1996
+ }
1997
+ candidates.sort((a, b) => Number(b.exact) - Number(a.exact) || b.iou - a.iou);
1998
+ const pairs = /* @__PURE__ */ new Map();
1999
+ const takenOrigins = /* @__PURE__ */ new Set();
2000
+ for (const c of candidates) {
2001
+ if (pairs.has(c.savedIndex) || takenOrigins.has(c.originIndex)) continue;
2002
+ pairs.set(c.savedIndex, c.originIndex);
2003
+ takenOrigins.add(c.originIndex);
2004
+ }
2005
+ return pairs;
2006
+ }
2007
+ /**
2008
+ * Classify what the operator did on ONE frame.
2009
+ *
2010
+ * @param saved the frame's saved boxes.
2011
+ * @param origins the proposals known now (the pipeline's boxes, re-derived) —
2012
+ * consulted ONLY for rows that carry no origin snapshot.
2013
+ * @param dismissed the proposals the operator deleted, with their snapshots.
2014
+ */
2015
+ function classifyRetrainReview(saved, origins, dismissed, opts = {}) {
2016
+ const matchIou = opts.matchIou ?? .5;
2017
+ const adjustedIou = opts.adjustedIou ?? .95;
2018
+ const claimedRefs = /* @__PURE__ */ new Set();
2019
+ const boxes = [];
2020
+ const legacyIndexes = [];
2021
+ saved.forEach((box, index) => {
2022
+ if (box.origin === null) legacyIndexes.push(index);
2023
+ else claimedRefs.add(box.origin.ref);
2024
+ });
2025
+ for (const entry of dismissed) claimedRefs.add(entry.ref);
2026
+ const legacyPairs = pairLegacy(saved, legacyIndexes, origins, matchIou);
2027
+ for (const originIndex of legacyPairs.values()) {
2028
+ const origin = origins[originIndex];
2029
+ if (origin !== void 0) claimedRefs.add(origin.ref);
2030
+ }
2031
+ saved.forEach((box, index) => {
2032
+ const exactBaseline = box.origin;
2033
+ const pairedOrigin = exactBaseline === null ? origins[legacyPairs.get(index) ?? -1] : void 0;
2034
+ const baseline = exactBaseline ?? pairedOrigin ?? null;
2035
+ const approximate = exactBaseline === null;
2036
+ if (box.kind === "model_error") {
2037
+ boxes.push({
2038
+ ref: box.id,
2039
+ savedId: box.id,
2040
+ status: "model-error",
2041
+ approximate: false,
2042
+ ...baseline !== null ? {
2043
+ origin: baseline,
2044
+ iou: retrainBoxIou(box.bbox, baseline.bbox)
2045
+ } : {}
2046
+ });
2047
+ return;
2048
+ }
2049
+ if (baseline === null || baseline.source === "operator") {
2050
+ boxes.push({
2051
+ ref: box.id,
2052
+ savedId: box.id,
2053
+ status: "added",
2054
+ approximate: approximate && baseline === null,
2055
+ ...baseline !== null ? { origin: baseline } : {}
2056
+ });
2057
+ return;
2058
+ }
2059
+ const verdict = compareKept(box, baseline, adjustedIou);
2060
+ boxes.push({
2061
+ ref: box.id,
2062
+ savedId: box.id,
2063
+ status: verdict.status,
2064
+ approximate,
2065
+ origin: baseline,
2066
+ iou: verdict.iou
2067
+ });
2068
+ });
2069
+ for (const entry of dismissed) boxes.push({
2070
+ ref: entry.ref,
2071
+ status: "removed",
2072
+ approximate: false,
2073
+ origin: entry.snapshot
2074
+ });
2075
+ if (opts.inferRemoved === true) for (const origin of origins) {
2076
+ if (claimedRefs.has(origin.ref)) continue;
2077
+ boxes.push({
2078
+ ref: origin.ref,
2079
+ status: "removed",
2080
+ approximate: true,
2081
+ origin
2082
+ });
2083
+ }
2084
+ return {
2085
+ boxes,
2086
+ approximate: boxes.some((b) => b.approximate)
2087
+ };
2088
+ }
2089
+ /** Counts per status, plus the totals a list row shows. */
2090
+ function summarizeReview(review) {
2091
+ const counts = {
2092
+ unchanged: 0,
2093
+ adjusted: 0,
2094
+ reclassified: 0,
2095
+ added: 0,
2096
+ removed: 0,
2097
+ "model-error": 0
2098
+ };
2099
+ for (const box of review.boxes) counts[box.status] += 1;
2100
+ return {
2101
+ counts,
2102
+ total: review.boxes.length,
2103
+ changed: review.boxes.length - counts.unchanged,
2104
+ approximate: review.approximate
2105
+ };
2106
+ }
2107
+ /** The prefix of the error a stale `expectedRevision` save is refused with. */
2108
+ var RETRAIN_REVISION_CONFLICT = "retrain-revision-conflict";
2109
+ /** The message a refused save carries — `parseRetrainRevisionConflict` reads it back. */
2110
+ function retrainRevisionConflictMessage(frameId, conflict) {
2111
+ 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)})`;
2112
+ }
2113
+ /** The conflict an error message names, or `null` when it is some other error. */
2114
+ function parseRetrainRevisionConflict(message) {
2115
+ if (!message.includes("retrain-revision-conflict")) return null;
2116
+ const match = /current=(\d+) expected=(\d+)/.exec(message);
2117
+ if (match?.[1] === void 0 || match[2] === void 0) return null;
2118
+ return {
2119
+ currentRevision: Number(match[1]),
2120
+ expectedRevision: Number(match[2])
2121
+ };
2122
+ }
2123
+ //#endregion
1928
2124
  //#region src/interfaces/birth-decision-ledger.ts
1929
2125
  /**
1930
2126
  * Birth-decision ledger — one durable row per track-birth VERDICT (D409).
@@ -9260,6 +9456,16 @@ var BrokerClientsSchema = zod.z.object({
9260
9456
  /** Total encoded + raw-RTP callback subscriber count (sum of `encoded[].length`). */
9261
9457
  encodedSubscribers: zod.z.number()
9262
9458
  });
9459
+ /**
9460
+ * How many people are watching one camera LIVE right now — see
9461
+ * `getLiveViewerCounts`. A camera with nobody watching is absent from the list
9462
+ * (so `viewers` is always at least 1): the listing carries the cameras that
9463
+ * have viewers, never a row of zeros.
9464
+ */
9465
+ var LiveViewerCountSchema = zod.z.object({
9466
+ deviceId: zod.z.number().int().nonnegative(),
9467
+ viewers: zod.z.number().int().positive()
9468
+ });
9263
9469
  var PlaceholderReasonSchema = zod.z.enum([
9264
9470
  "reconnecting",
9265
9471
  "sleeping",
@@ -9743,6 +9949,24 @@ var streamBrokerCapability = {
9743
9949
  auth: "admin"
9744
9950
  }),
9745
9951
  listClients: require_sleep.method(zod.z.object({ brokerId: zod.z.string() }), BrokerClientsSchema),
9952
+ /**
9953
+ * People watching each camera LIVE right now, for every camera at once —
9954
+ * cheap enough to poll (a walk of the live session maps, no I/O).
9955
+ *
9956
+ * Counts EXTERNAL viewers only: WebRTC sessions of a viewer kind
9957
+ * (`webrtc-browser` / `-mobile` / `-whep`, `alexa`, `homekit`) that are on
9958
+ * the live edge, plus RTSP restream clients from outside that are playing.
9959
+ * The system's own consumers are never counted: the detection decoder, the
9960
+ * recorder, snapshots, the prebuffer hold, audio analysis, and the RTSP
9961
+ * dials an agent's derived broker makes. One WebRTC session or RTSP
9962
+ * connection is one viewer, so two tabs on one camera read 2.
9963
+ *
9964
+ * The count is read off the live session maps at call time, so a session
9965
+ * that ends — cleanly or by the peer vanishing — stops counting with no
9966
+ * counter to leak. It covers the sessions THIS provider serves; a node
9967
+ * with its own stream-broker is asked with a `nodeId` pin.
9968
+ */
9969
+ getLiveViewerCounts: require_sleep.method(zod.z.void(), zod.z.array(LiveViewerCountSchema).readonly()),
9746
9970
  killClient: require_sleep.method(zod.z.object({
9747
9971
  brokerId: zod.z.string(),
9748
9972
  channel: zod.z.enum(["rtsp", "audio"]),
@@ -12431,6 +12655,38 @@ var BulkRecordSchema = zod.z.object({
12431
12655
  data: zod.z.record(zod.z.string(), zod.z.unknown())
12432
12656
  });
12433
12657
  /**
12658
+ * One write inside a {@link settingsStoreCapability.methods.transact} call.
12659
+ * Only the three that a "replace this set, bump that revision" write needs.
12660
+ */
12661
+ var TransactOpSchema = zod.z.discriminatedUnion("op", [
12662
+ zod.z.object({
12663
+ op: zod.z.literal("deleteWhere"),
12664
+ collection: zod.z.string(),
12665
+ filter: MutationFilterSchema
12666
+ }),
12667
+ zod.z.object({
12668
+ op: zod.z.literal("insertMany"),
12669
+ collection: zod.z.string(),
12670
+ records: zod.z.array(BulkRecordSchema).readonly()
12671
+ }),
12672
+ zod.z.object({
12673
+ op: zod.z.literal("update"),
12674
+ collection: zod.z.string(),
12675
+ id: zod.z.string(),
12676
+ data: zod.z.record(zod.z.string(), zod.z.unknown())
12677
+ })
12678
+ ]);
12679
+ /**
12680
+ * The precondition of a transaction: the row `key` of `collection` must hold
12681
+ * `equals` in `column`, read INSIDE the transaction.
12682
+ */
12683
+ var TransactGuardSchema = zod.z.object({
12684
+ collection: zod.z.string(),
12685
+ key: zod.z.string(),
12686
+ column: zod.z.string(),
12687
+ equals: zod.z.unknown()
12688
+ });
12689
+ /**
12434
12690
  * Column declaration for a structured (SQL-backed) collection.
12435
12691
  *
12436
12692
  * Logical types — the backend translates each to the matching SQLite
@@ -12655,6 +12911,36 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
12655
12911
  kind: "mutation",
12656
12912
  auth: "admin"
12657
12913
  }),
12914
+ /**
12915
+ * Several writes, ONE transaction, behind an optional precondition.
12916
+ *
12917
+ * The multi-collection twin of {@link insertMany}: a write that has to move
12918
+ * a set of rows in one collection AND a revision in another cannot be
12919
+ * expressed as separate calls without a window in which a reader (or a
12920
+ * crash) sees half of it. The retrain annotation save replaces a frame's
12921
+ * rows, its dismissed set and its revision this way.
12922
+ *
12923
+ * `guard`, when given, is read inside the transaction: if the row is
12924
+ * missing or its column differs from `equals`, NOTHING is written and the
12925
+ * answer is `{ applied: false, current }` with what was found — the
12926
+ * compare-and-set a revisioned write needs, with no second reader able to
12927
+ * slip between the check and the writes.
12928
+ *
12929
+ * **All or nothing**, like {@link insertMany}: a throw in any op rolls the
12930
+ * whole call back. Ops run in the order given (delete before insert to
12931
+ * replace a set). `namespace` applies to every collection named.
12932
+ */
12933
+ transact: require_sleep.method(zod.z.object({
12934
+ namespace: zod.z.string().optional(),
12935
+ guard: TransactGuardSchema.optional(),
12936
+ ops: zod.z.array(TransactOpSchema).readonly()
12937
+ }), zod.z.object({
12938
+ applied: zod.z.boolean(),
12939
+ current: zod.z.unknown().optional()
12940
+ }), {
12941
+ kind: "mutation",
12942
+ auth: "admin"
12943
+ }),
12658
12944
  /** Update an existing record by ID. */
12659
12945
  update: require_sleep.method(zod.z.object({
12660
12946
  namespace: zod.z.string().optional(),
@@ -12941,6 +13227,18 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
12941
13227
  kind: "mutation",
12942
13228
  auth: "admin"
12943
13229
  }),
13230
+ /** Several writes in ONE transaction behind an optional guard; see the door. */
13231
+ transact: require_sleep.method(zod.z.object({
13232
+ namespace: zod.z.string().optional(),
13233
+ guard: TransactGuardSchema.optional(),
13234
+ ops: zod.z.array(TransactOpSchema).readonly()
13235
+ }), zod.z.object({
13236
+ applied: zod.z.boolean(),
13237
+ current: zod.z.unknown().optional()
13238
+ }), {
13239
+ kind: "mutation",
13240
+ auth: "admin"
13241
+ }),
12944
13242
  /** Update an existing record by ID. */
12945
13243
  update: require_sleep.method(zod.z.object({
12946
13244
  namespace: zod.z.string().optional(),
@@ -25636,6 +25934,56 @@ var RetrainBboxSchema = zod.z.object({
25636
25934
  h: zod.z.number()
25637
25935
  });
25638
25936
  /**
25937
+ * What a box LOOKED LIKE when it was offered, snapshotted at the moment the
25938
+ * operator accepted it. The saved row keeps only the final rectangle; this is
25939
+ * the other half of the pair, and the pair is what says whether the operator
25940
+ * accepted, nudged, relabelled or replaced a proposal (`retrain-review.ts`).
25941
+ *
25942
+ * `ref` names the proposal inside its frame: `pipeline:<trackId>` for a box the
25943
+ * live pipeline drew, `assist:<n>` for the n-th box of a detector or LLM run,
25944
+ * and anything unique for an operator-drawn box (`operator:<n>`). Re-derived
25945
+ * pipeline boxes carry the same ref every time, which is what lets a dismissal
25946
+ * stay dismissed.
25947
+ */
25948
+ var RetrainOriginSchema = zod.z.object({
25949
+ source: RetrainAnnotationSourceSchema,
25950
+ ref: zod.z.string().min(1),
25951
+ bbox: RetrainBboxSchema,
25952
+ macroClass: RetrainMacroClassSchema,
25953
+ label: zod.z.string().optional(),
25954
+ score: zod.z.number().optional(),
25955
+ modelId: zod.z.string().optional()
25956
+ });
25957
+ /**
25958
+ * A proposal the operator deleted. Durable on the frame, so a deleted pipeline
25959
+ * box does not come back as a draft every time the frame is reopened, and so
25960
+ * the deletion itself is a recorded fact rather than an absence.
25961
+ */
25962
+ var RetrainDismissedSchema = zod.z.object({
25963
+ ref: zod.z.string().min(1),
25964
+ snapshot: RetrainOriginSchema
25965
+ });
25966
+ /** What the operator did with a proposal (see `retrain-review.ts`). */
25967
+ var RetrainReviewStatusSchema = zod.z.enum(RETRAIN_REVIEW_STATUSES);
25968
+ var RetrainBoxReviewSchema = zod.z.object({
25969
+ ref: zod.z.string(),
25970
+ savedId: zod.z.string().optional(),
25971
+ status: RetrainReviewStatusSchema,
25972
+ /** The baseline was re-derived, not snapshotted (a pre-origin row). */
25973
+ approximate: zod.z.boolean(),
25974
+ origin: RetrainOriginSchema.optional(),
25975
+ iou: zod.z.number().optional()
25976
+ });
25977
+ var RetrainFrameReviewSchema = zod.z.object({
25978
+ boxes: zod.z.array(RetrainBoxReviewSchema).readonly(),
25979
+ summary: zod.z.object({
25980
+ counts: zod.z.record(RetrainReviewStatusSchema, zod.z.number().int()),
25981
+ total: zod.z.number().int(),
25982
+ changed: zod.z.number().int(),
25983
+ approximate: zod.z.boolean()
25984
+ })
25985
+ });
25986
+ /**
25639
25987
  * One annotated subject.
25640
25988
  *
25641
25989
  * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
@@ -25659,6 +26007,9 @@ var RetrainAnnotationSchema = zod.z.object({
25659
26007
  /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
25660
26008
  assistModelId: zod.z.string().optional(),
25661
26009
  assistScore: zod.z.number().optional(),
26010
+ /** The proposal this box started from, snapshotted at accept time. `null` on
26011
+ * a row saved before origins existed; absent on a draft nobody snapshotted. */
26012
+ origin: RetrainOriginSchema.nullable().optional(),
25662
26013
  exportedInBatch: zod.z.string().optional(),
25663
26014
  createdAt: zod.z.number()
25664
26015
  });
@@ -25751,7 +26102,19 @@ var RetrainFrameSchema = zod.z.object({
25751
26102
  * empty when nothing the track store holds can be placed on it. */
25752
26103
  pipelineBoxes: zod.z.array(RetrainPipelineBoxSchema).readonly().optional(),
25753
26104
  /** The named collections this frame belongs to. Present on list answers. */
25754
- collectionIds: zod.z.array(zod.z.string()).readonly().optional()
26105
+ collectionIds: zod.z.array(zod.z.string()).readonly().optional(),
26106
+ /** Bumped by every annotation save. A save that names a stale
26107
+ * `expectedRevision` is refused, so two surfaces cannot overwrite each other. */
26108
+ revision: zod.z.number().int().optional(),
26109
+ /** Proposals the operator deleted — never re-seeded as drafts. */
26110
+ dismissed: zod.z.array(RetrainDismissedSchema).readonly().optional(),
26111
+ /** What the operator did with the proposals, computed by the server. */
26112
+ review: RetrainFrameReviewSchema.optional(),
26113
+ /** The frame's pixels over the admin data plane (full size). Fetch with the
26114
+ * admin bearer token; relative to the hub root. */
26115
+ imageUrl: zod.z.string().optional(),
26116
+ /** The same, as a ~480 px thumbnail for grids. */
26117
+ thumbnailUrl: zod.z.string().optional()
25755
26118
  });
25756
26119
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
25757
26120
  var RetrainCopyRefusalSchema = zod.z.enum([
@@ -27347,6 +27710,11 @@ var pipelineAnalyticsCapability = {
27347
27710
  /**
27348
27711
  * The pixels of ONE copied frame, base64.
27349
27712
  *
27713
+ * @deprecated Use `RetrainFrame.imageUrl` / `thumbnailUrl` (the admin
27714
+ * `retrain-frame` data plane, D613). A base64 envelope holds the frame
27715
+ * whole in the producer AND the caller, and a grid of tiles paid that for
27716
+ * every tile. Kept for one release for callers that cannot fetch a URL.
27717
+ *
27350
27718
  * Through the cap rather than a data plane because it is genuinely one
27351
27719
  * frame at a time, on demand, at human speed — the shape D9/D18 permit
27352
27720
  * (what they forbid is frames crossing a boundary at frame RATE). The
@@ -27409,18 +27777,59 @@ var pipelineAnalyticsCapability = {
27409
27777
  * Refuses a macro class typed into `label` or `subLabel` — the tiers are
27410
27778
  * separate and the guard is at the WRITE, because a mixed taxonomy cannot
27411
27779
  * be un-mixed by reading it.
27780
+ *
27781
+ * ATOMIC and REVISIONED: the replaced rows, the frame's `dismissed` set and
27782
+ * its `revision` move in one transaction, guarded by the revision the
27783
+ * caller saw. A stale `expectedRevision` writes nothing and throws
27784
+ * `retrain-revision-conflict` (parse it with `parseRetrainRevisionConflict`);
27785
+ * the UI and an MCP agent no longer overwrite each other silently.
27412
27786
  */
27413
27787
  saveRetrainAnnotations: require_sleep.method(zod.z.object({
27414
27788
  deviceId: zod.z.number(),
27415
27789
  /** The frame's track, when it has one — checked against the frame. */
27416
27790
  trackId: zod.z.string().optional(),
27417
27791
  frameId: zod.z.string(),
27418
- annotations: zod.z.array(RetrainAnnotationDraftSchema)
27792
+ annotations: zod.z.array(RetrainAnnotationDraftSchema),
27793
+ /** The frame's `revision` the caller saw. A different current revision
27794
+ * refuses the save with a `retrain-revision-conflict` error
27795
+ * (`parseRetrainRevisionConflict`). Absent ⇒ last write wins. */
27796
+ expectedRevision: zod.z.number().int().optional(),
27797
+ /** The proposals the operator deleted. Absent ⇒ keep the frame's
27798
+ * current set; present ⇒ replace it (an empty array un-dismisses). */
27799
+ dismissed: zod.z.array(RetrainDismissedSchema).optional()
27419
27800
  }), zod.z.array(RetrainAnnotationSchema).readonly(), {
27420
27801
  kind: "mutation",
27421
27802
  auth: "admin"
27422
27803
  }),
27423
27804
  /**
27805
+ * Give annotations saved BEFORE origins existed the origin a caller
27806
+ * reconstructed for them (the MCP `track_review_backfill_origin` tool
27807
+ * matches each row to the pipeline box it equals).
27808
+ *
27809
+ * Writes `origin` and nothing else: ids, creation time and the export stamp
27810
+ * are untouched (a re-save through `saveRetrainAnnotations` would reset all
27811
+ * three). A row that already has an origin is SKIPPED — a snapshot taken at
27812
+ * accept time is evidence, a reconstruction is a guess. Atomic and
27813
+ * revision-guarded like the save; bumps the frame's `revision`.
27814
+ */
27815
+ backfillRetrainOrigins: require_sleep.method(zod.z.object({
27816
+ deviceId: zod.z.number(),
27817
+ trackId: zod.z.string().optional(),
27818
+ frameId: zod.z.string(),
27819
+ expectedRevision: zod.z.number().int().optional(),
27820
+ origins: zod.z.array(zod.z.object({
27821
+ annotationId: zod.z.string(),
27822
+ origin: RetrainOriginSchema
27823
+ })).min(1).max(500)
27824
+ }), zod.z.object({
27825
+ updated: zod.z.number().int(),
27826
+ skipped: zod.z.number().int(),
27827
+ revision: zod.z.number().int()
27828
+ }), {
27829
+ kind: "mutation",
27830
+ auth: "admin"
27831
+ }),
27832
+ /**
27424
27833
  * Finish with a track: `staging → trained`. **The only writer of that
27425
27834
  * state** — D81 shipped the column with it deliberately unreachable.
27426
27835
  *
@@ -30249,19 +30658,6 @@ var RunnerCameraDeviceUIFields = [
30249
30658
  label: MOTION_SOURCE_LABELS[value]
30250
30659
  })
30251
30660
  },
30252
- {
30253
- key: "detectionSources",
30254
- type: "multiselect",
30255
- label: "Detection Sources",
30256
- default: ["pipeline"],
30257
- options: [{
30258
- value: "pipeline",
30259
- label: "This node (ML root step on decoded frames)"
30260
- }, {
30261
- value: "onboard",
30262
- label: "Camera onboard AI (replaces the root step when picked alone)"
30263
- }]
30264
- },
30265
30661
  {
30266
30662
  key: "motionFps",
30267
30663
  type: "slider",
@@ -30952,6 +31348,12 @@ var CameraStepOverridePatchSchema = zod.z.object({
30952
31348
  settings: zod.z.record(zod.z.string(), zod.z.unknown()).readonly().optional()
30953
31349
  });
30954
31350
  var CameraStepSettingsSchema = zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.unknown()).readonly());
31351
+ /** The three root-detector choices a camera has (D507: at most one root). */
31352
+ var CameraDetectionSourceSchema = zod.z.enum([
31353
+ "pipeline",
31354
+ "onboard",
31355
+ "none"
31356
+ ]);
30955
31357
  var CameraPipelineSettingsSchema = zod.z.object({
30956
31358
  stepToggles: zod.z.record(zod.z.string(), zod.z.boolean()).optional(),
30957
31359
  stepSettings: CameraStepSettingsSchema.optional(),
@@ -31896,6 +32298,41 @@ var pipelineOrchestratorCapability = {
31896
32298
  kind: "mutation",
31897
32299
  auth: "admin"
31898
32300
  }),
32301
+ /**
32302
+ * Where this camera's first-level detections come from: this node's own
32303
+ * root step (`pipeline`), the camera's onboard detector alone (`onboard`),
32304
+ * or no root detector (`none`). A camera runs at most one root detector
32305
+ * (D507), so there is no "both". Read from the camera's stored
32306
+ * `detectionSources` — the one authority; `explicit` is false while the
32307
+ * operator has never picked and the default stands.
32308
+ */
32309
+ getCameraDetectionSource: require_sleep.method(zod.z.object({ deviceId: zod.z.number() }), zod.z.object({
32310
+ source: CameraDetectionSourceSchema,
32311
+ explicit: zod.z.boolean(),
32312
+ onboard: zod.z.object({
32313
+ /** The camera has an onboard detector this system can read. */
32314
+ available: zod.z.boolean(),
32315
+ /** What its detections carry — a camera with no box cannot be a root step. */
32316
+ geometry: zod.z.enum([
32317
+ "boxed",
32318
+ "while-streaming",
32319
+ "flag-only",
32320
+ "unknown"
32321
+ ])
32322
+ })
32323
+ })),
32324
+ /**
32325
+ * Pick where this camera's detections come from. Writes `detectionSources`
32326
+ * and arms (or disarms) the vendor's boxed sub-stream that the choice
32327
+ * drives. Refuses `onboard` on a camera with no onboard detector.
32328
+ */
32329
+ setCameraDetectionSource: require_sleep.method(zod.z.object({
32330
+ deviceId: zod.z.number(),
32331
+ source: CameraDetectionSourceSchema
32332
+ }), zod.z.object({ success: zod.z.literal(true) }), {
32333
+ kind: "mutation",
32334
+ auth: "admin"
32335
+ }),
31899
32336
  /** Read every per-(node,device) override map for a device. Null when device has no overrides. */
31900
32337
  getCameraStepOverrides: require_sleep.method(zod.z.object({ deviceId: zod.z.number() }), zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), CameraStepOverridePatchSchema))).nullable()),
31901
32338
  /**
@@ -42505,7 +42942,14 @@ var TopologyNodeSchema = zod.z.object({
42505
42942
  * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
42506
42943
  * for offline rows and when the hub cannot tell.
42507
42944
  */
42508
- meshTransport: zod.z.enum(["tls", "clear"]).optional()
42945
+ meshTransport: zod.z.enum(["tls", "clear"]).optional(),
42946
+ /**
42947
+ * Whether the hub holds this online AGENT's capability registration (its
42948
+ * `registerNode` manifest). `false` = online in the mesh but not ready: the
42949
+ * hub dropped the registration on a disconnect only it saw and the agent has
42950
+ * not re-sent it. Absent for the hub and offline rows.
42951
+ */
42952
+ capabilitiesRegistered: zod.z.boolean().optional()
42509
42953
  });
42510
42954
  var CapUsageEdgeSchema = zod.z.object({
42511
42955
  callerAddonId: zod.z.string(),
@@ -55570,6 +56014,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
55570
56014
  addonId: null,
55571
56015
  access: "create"
55572
56016
  },
56017
+ "dataStoreProvider.transact": {
56018
+ capName: "data-store-provider",
56019
+ capScope: "system",
56020
+ addonId: null,
56021
+ access: "create"
56022
+ },
55573
56023
  "dataStoreProvider.update": {
55574
56024
  capName: "data-store-provider",
55575
56025
  capScope: "system",
@@ -58414,6 +58864,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
58414
58864
  addonId: null,
58415
58865
  access: "create"
58416
58866
  },
58867
+ "pipelineAnalytics.backfillRetrainOrigins": {
58868
+ capName: "pipeline-analytics",
58869
+ capScope: "device",
58870
+ addonId: null,
58871
+ access: "create"
58872
+ },
58417
58873
  "pipelineAnalytics.cancelRelocateMedia": {
58418
58874
  capName: "pipeline-analytics",
58419
58875
  capScope: "device",
@@ -59194,6 +59650,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
59194
59650
  addonId: null,
59195
59651
  access: "view"
59196
59652
  },
59653
+ "pipelineOrchestrator.getCameraDetectionSource": {
59654
+ capName: "pipeline-orchestrator",
59655
+ capScope: "system",
59656
+ addonId: null,
59657
+ access: "view"
59658
+ },
59197
59659
  "pipelineOrchestrator.getCameraMetrics": {
59198
59660
  capName: "pipeline-orchestrator",
59199
59661
  capScope: "system",
@@ -59422,6 +59884,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
59422
59884
  addonId: null,
59423
59885
  access: "create"
59424
59886
  },
59887
+ "pipelineOrchestrator.setCameraDetectionSource": {
59888
+ capName: "pipeline-orchestrator",
59889
+ capScope: "system",
59890
+ addonId: null,
59891
+ access: "create"
59892
+ },
59425
59893
  "pipelineOrchestrator.setCameraPipelineForAgent": {
59426
59894
  capName: "pipeline-orchestrator",
59427
59895
  capScope: "system",
@@ -60394,6 +60862,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
60394
60862
  addonId: null,
60395
60863
  access: "create"
60396
60864
  },
60865
+ "settingsStore.transact": {
60866
+ capName: "settings-store",
60867
+ capScope: "system",
60868
+ addonId: null,
60869
+ access: "create"
60870
+ },
60397
60871
  "settingsStore.update": {
60398
60872
  capName: "settings-store",
60399
60873
  capScope: "system",
@@ -60874,6 +61348,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
60874
61348
  addonId: null,
60875
61349
  access: "view"
60876
61350
  },
61351
+ "streamBroker.getLiveViewerCounts": {
61352
+ capName: "stream-broker",
61353
+ capScope: "system",
61354
+ addonId: null,
61355
+ access: "view"
61356
+ },
60877
61357
  "streamBroker.getPreBufferInfo": {
60878
61358
  capName: "stream-broker",
60879
61359
  capScope: "system",
@@ -68124,6 +68604,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
68124
68604
  form: "single",
68125
68605
  optional: false
68126
68606
  }],
68607
+ "pipelineAnalytics.backfillRetrainOrigins": [{
68608
+ name: "deviceId",
68609
+ form: "single",
68610
+ optional: false
68611
+ }],
68127
68612
  "pipelineAnalytics.clearTrackRelation": [{
68128
68613
  name: "deviceId",
68129
68614
  form: "single",
@@ -68429,6 +68914,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
68429
68914
  form: "single",
68430
68915
  optional: false
68431
68916
  }],
68917
+ "pipelineOrchestrator.getCameraDetectionSource": [{
68918
+ name: "deviceId",
68919
+ form: "single",
68920
+ optional: false
68921
+ }],
68432
68922
  "pipelineOrchestrator.getCameraMetrics": [{
68433
68923
  name: "deviceId",
68434
68924
  form: "single",
@@ -68489,6 +68979,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
68489
68979
  form: "single",
68490
68980
  optional: false
68491
68981
  }],
68982
+ "pipelineOrchestrator.setCameraDetectionSource": [{
68983
+ name: "deviceId",
68984
+ form: "single",
68985
+ optional: false
68986
+ }],
68492
68987
  "pipelineOrchestrator.setCameraPipelineForAgent": [{
68493
68988
  name: "deviceId",
68494
68989
  form: "single",
@@ -69483,6 +69978,7 @@ var SYSTEM_SCOPE_DEVICE_METHODS = [
69483
69978
  "pipelineOrchestrator.assignAudio",
69484
69979
  "pipelineOrchestrator.assignPipeline",
69485
69980
  "pipelineOrchestrator.getAudioAssignment",
69981
+ "pipelineOrchestrator.getCameraDetectionSource",
69486
69982
  "pipelineOrchestrator.getCameraMetrics",
69487
69983
  "pipelineOrchestrator.getCameraSettings",
69488
69984
  "pipelineOrchestrator.getCameraStatus",
@@ -69495,6 +69991,7 @@ var SYSTEM_SCOPE_DEVICE_METHODS = [
69495
69991
  "pipelineOrchestrator.getPipelineDevicePin",
69496
69992
  "pipelineOrchestrator.requestOccupancyLook",
69497
69993
  "pipelineOrchestrator.resolvePipeline",
69994
+ "pipelineOrchestrator.setCameraDetectionSource",
69498
69995
  "pipelineOrchestrator.setCameraPipelineForAgent",
69499
69996
  "pipelineOrchestrator.setCameraSensors",
69500
69997
  "pipelineOrchestrator.setCameraStepOverride",
@@ -70622,6 +71119,7 @@ function createSystemProxy(api) {
70622
71119
  upsert: (input) => dispatch("settingsStore", "upsert", "mutation", input),
70623
71120
  insert: (input) => dispatch("settingsStore", "insert", "mutation", input),
70624
71121
  insertMany: (input) => dispatch("settingsStore", "insertMany", "mutation", input),
71122
+ transact: (input) => dispatch("settingsStore", "transact", "mutation", input),
70625
71123
  update: (input) => dispatch("settingsStore", "update", "mutation", input),
70626
71124
  delete: (input) => dispatch("settingsStore", "delete", "mutation", input),
70627
71125
  deleteWhere: (input) => dispatch("settingsStore", "deleteWhere", "mutation", input),
@@ -70676,6 +71174,7 @@ function createSystemProxy(api) {
70676
71174
  getBrokerStats: (input) => dispatch("streamBroker", "getBrokerStats", "query", input),
70677
71175
  probeStream: (input) => dispatch("streamBroker", "probeStream", "mutation", input),
70678
71176
  listClients: (input) => dispatch("streamBroker", "listClients", "query", input),
71177
+ getLiveViewerCounts: (input) => dispatch("streamBroker", "getLiveViewerCounts", "query", input),
70679
71178
  killClient: (input) => dispatch("streamBroker", "killClient", "mutation", input),
70680
71179
  getStreamUrl: (input) => dispatch("streamBroker", "getStreamUrl", "query", input),
70681
71180
  getStreamWithCodec: (input) => dispatch("streamBroker", "getStreamWithCodec", "mutation", input),
@@ -79453,6 +79952,7 @@ exports.CameraDecoderStatusSchema = CameraDecoderStatusSchema;
79453
79952
  exports.CameraDetectionPhaseSchema = CameraDetectionPhaseSchema;
79454
79953
  exports.CameraDetectionProvisioningSchema = CameraDetectionProvisioningSchema;
79455
79954
  exports.CameraDetectionProvisioningStateSchema = CameraDetectionProvisioningStateSchema;
79955
+ exports.CameraDetectionSourceSchema = CameraDetectionSourceSchema;
79456
79956
  exports.CameraDetectionStatusSchema = CameraDetectionStatusSchema;
79457
79957
  exports.CameraMetricsSchema = CameraMetricsSchema;
79458
79958
  exports.CameraMetricsWithDeviceIdSchema = CameraMetricsWithDeviceIdSchema;
@@ -79931,6 +80431,7 @@ exports.LinkedDevicesSlotValueSchema = LinkedDevicesSlotValueSchema;
79931
80431
  exports.ListNodeBenchmarkResultsInputSchema = ListNodeBenchmarkResultsInputSchema;
79932
80432
  exports.ListTrackRelationsInputSchema = ListTrackRelationsInputSchema;
79933
80433
  exports.ListTrackRelationsResultSchema = ListTrackRelationsResultSchema;
80434
+ exports.LiveViewerCountSchema = LiveViewerCountSchema;
79934
80435
  exports.LlmDefaultSchema = LlmDefaultSchema;
79935
80436
  exports.LlmDefaultSelectorSchema = LlmDefaultSelectorSchema;
79936
80437
  exports.LlmDownloadProgressSchema = LlmDownloadProgressSchema;
@@ -80478,6 +80979,10 @@ exports.REMOVED_MODEL_IDS = REMOVED_MODEL_IDS;
80478
80979
  exports.RESERVED_BINDING_NAMES = require_composition.RESERVED_BINDING_NAMES;
80479
80980
  exports.RESERVED_COLLECTION_SOURCES = RESERVED_COLLECTION_SOURCES;
80480
80981
  exports.RESTORED_CAP_NAMES = RESTORED_CAP_NAMES;
80982
+ exports.RETRAIN_REVIEW_ADJUSTED_IOU = RETRAIN_REVIEW_ADJUSTED_IOU;
80983
+ exports.RETRAIN_REVIEW_MATCH_IOU = RETRAIN_REVIEW_MATCH_IOU;
80984
+ exports.RETRAIN_REVIEW_STATUSES = RETRAIN_REVIEW_STATUSES;
80985
+ exports.RETRAIN_REVISION_CONFLICT = RETRAIN_REVISION_CONFLICT;
80481
80986
  exports.REVALIDATE_AFTER_MS = require_sleep.REVALIDATE_AFTER_MS;
80482
80987
  exports.ROOM_EXAMPLE_MOTION_SOURCES = ROOM_EXAMPLE_MOTION_SOURCES;
80483
80988
  exports.ROOM_EXAMPLE_TEMPERATURE_SOURCES = ROOM_EXAMPLE_TEMPERATURE_SOURCES;
@@ -80565,6 +81070,7 @@ exports.RetrainArchiveTargetSchema = RetrainArchiveTargetSchema;
80565
81070
  exports.RetrainAssistProfileSchema = RetrainAssistProfileSchema;
80566
81071
  exports.RetrainAssistResultSchema = RetrainAssistResultSchema;
80567
81072
  exports.RetrainAssistSubjectSchema = RetrainAssistSubjectSchema;
81073
+ exports.RetrainBoxReviewSchema = RetrainBoxReviewSchema;
80568
81074
  exports.RetrainCollectionCreateResultSchema = RetrainCollectionCreateResultSchema;
80569
81075
  exports.RetrainCollectionRenameResultSchema = RetrainCollectionRenameResultSchema;
80570
81076
  exports.RetrainCollectionSchema = RetrainCollectionSchema;
@@ -80577,11 +81083,13 @@ exports.RetrainCorpusPageSchema = RetrainCorpusPageSchema;
80577
81083
  exports.RetrainDatasetSelectionSchema = RetrainDatasetSelectionSchema;
80578
81084
  exports.RetrainDatasetStatsSchema = RetrainDatasetStatsSchema;
80579
81085
  exports.RetrainDatasetVersionSchema = RetrainDatasetVersionSchema;
81086
+ exports.RetrainDismissedSchema = RetrainDismissedSchema;
80580
81087
  exports.RetrainExportFilterSchema = RetrainExportFilterSchema;
80581
81088
  exports.RetrainExportLayoutSchema = RetrainExportLayoutSchema;
80582
81089
  exports.RetrainFrameCandidateSchema = RetrainFrameCandidateSchema;
80583
81090
  exports.RetrainFrameListSchema = RetrainFrameListSchema;
80584
81091
  exports.RetrainFrameOriginSchema = RetrainFrameOriginSchema;
81092
+ exports.RetrainFrameReviewSchema = RetrainFrameReviewSchema;
80585
81093
  exports.RetrainFrameSchema = RetrainFrameSchema;
80586
81094
  exports.RetrainFrameSelectionSchema = RetrainFrameSelectionSchema;
80587
81095
  exports.RetrainFrameWorkStateSchema = RetrainFrameWorkStateSchema;
@@ -80589,7 +81097,9 @@ exports.RetrainLlmAssistResultSchema = RetrainLlmAssistResultSchema;
80589
81097
  exports.RetrainLlmProposalSchema = RetrainLlmProposalSchema;
80590
81098
  exports.RetrainLlmReviewSchema = RetrainLlmReviewSchema;
80591
81099
  exports.RetrainMacroClassSchema = RetrainMacroClassSchema;
81100
+ exports.RetrainOriginSchema = RetrainOriginSchema;
80592
81101
  exports.RetrainPipelineBoxSchema = RetrainPipelineBoxSchema;
81102
+ exports.RetrainReviewStatusSchema = RetrainReviewStatusSchema;
80593
81103
  exports.RetrainStatusSchema = RetrainStatusSchema;
80594
81104
  exports.RetrainTrackSchema = RetrainTrackSchema;
80595
81105
  exports.RetrainTrainingCorpusResolveResultSchema = RetrainTrainingCorpusResolveResultSchema;
@@ -81030,6 +81540,7 @@ exports.checkRoleAddress = checkRoleAddress;
81030
81540
  exports.classifyBearerPrincipal = classifyBearerPrincipal;
81031
81541
  exports.classifyCamerasForBenchmark = classifyCamerasForBenchmark;
81032
81542
  exports.classifyInferenceHardware = classifyInferenceHardware;
81543
+ exports.classifyRetrainReview = classifyRetrainReview;
81033
81544
  exports.classifySecretWrite = require_sleep.classifySecretWrite;
81034
81545
  exports.classifyStream = classifyStream;
81035
81546
  exports.classifyStreams = classifyStreams;
@@ -81448,6 +81959,7 @@ exports.parseMediaOwnerKey = parseMediaOwnerKey;
81448
81959
  exports.parseOccupancyScope = parseOccupancyScope;
81449
81960
  exports.parseProcStatus = parseProcStatus;
81450
81961
  exports.parseProfileBrokerId = require_sleep.parseProfileBrokerId;
81962
+ exports.parseRetrainRevisionConflict = parseRetrainRevisionConflict;
81451
81963
  exports.parseRuleSection = parseRuleSection;
81452
81964
  exports.parseSecretRef = require_sleep.parseSecretRef;
81453
81965
  exports.parseSecretStatePath = require_sleep.parseSecretStatePath;
@@ -81564,6 +82076,8 @@ exports.resolveVariantModelId = resolveVariantModelId;
81564
82076
  exports.resolveViewableDeviceIds = resolveViewableDeviceIds;
81565
82077
  exports.resultCellKey = resultCellKey;
81566
82078
  exports.resultStandings = resultStandings;
82079
+ exports.retrainBoxIou = retrainBoxIou;
82080
+ exports.retrainRevisionConflictMessage = retrainRevisionConflictMessage;
81567
82081
  exports.roleSpec = roleSpec;
81568
82082
  exports.roomCompositionExample = roomCompositionExample;
81569
82083
  exports.rootSuppliesOf = rootSuppliesOf;
@@ -81645,6 +82159,7 @@ exports.strippedOfLegacyReadOnly = strippedOfLegacyReadOnly;
81645
82159
  exports.subKindsOf = subKindsOf;
81646
82160
  exports.summarisePrivacyAudio = summarisePrivacyAudio;
81647
82161
  exports.summarizeEffectiveScope = summarizeEffectiveScope;
82162
+ exports.summarizeReview = summarizeReview;
81648
82163
  exports.supplyFor = supplyFor;
81649
82164
  exports.supportedRuntimes = supportedRuntimes;
81650
82165
  exports.switchCapability = switchCapability;