@camstack/types 1.2.112 → 1.2.113

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
@@ -1436,6 +1436,76 @@ var OPS_LOG_RING_DEFAULT_MAX = 500;
1436
1436
  /** Default page size for a `listOpsLog` query when the caller omits `limit`. */
1437
1437
  var OPS_LOG_DEFAULT_LIMIT = 200;
1438
1438
  //#endregion
1439
+ //#region src/types/labels.ts
1440
+ var LabelDefinitionSchema = zod.z.object({
1441
+ id: zod.z.string(),
1442
+ name: zod.z.string(),
1443
+ category: zod.z.string().optional(),
1444
+ description: zod.z.string().optional(),
1445
+ icon: zod.z.string().optional()
1446
+ });
1447
+ /** Detection-macro targets a catalog `classMap` may resolve to. */
1448
+ var CLASS_MAP_MACRO_TARGETS = [
1449
+ "person",
1450
+ "vehicle",
1451
+ "animal",
1452
+ "package"
1453
+ ];
1454
+ /**
1455
+ * Le macro classi di PRIMO LIVELLO: quelle che un object detector emette e che
1456
+ * un operatore può selezionare.
1457
+ *
1458
+ * Sono le tre offerte dallo step `object-detection`
1459
+ * (`addon-pipeline/src/detection-pipeline/registry/step-definitions.ts`,
1460
+ * `enabledMacroClasses`). `package` sta in {@link CLASS_MAP_MACRO_TARGETS} e in
1461
+ * `MACRO_LABELS` — è una macro vera — ma NON qui: appartiene allo step
1462
+ * `package-detection`, la cui abilitazione è guidata dalle zone, e offrire la
1463
+ * stessa parola due volte ha già fatto accendere a un operatore il proxy COCO
1464
+ * (suitcase/backpack/handbag) lasciando spento il detector dedicato.
1465
+ *
1466
+ * UNA lista. Prima di oggi le stesse tre erano scritte a mano nell'offerta
1467
+ * dello step e una seconda volta come union `FirstLevelMacro`
1468
+ * (`types/detection.ts`); una terza copia per il trigger di registrazione
1469
+ * (`RecordingTriggers.objectClasses`) avrebbe reso invisibile la divergenza
1470
+ * successiva.
1471
+ */
1472
+ var FIRST_LEVEL_MACRO_CLASSES = [
1473
+ "person",
1474
+ "vehicle",
1475
+ "animal"
1476
+ ];
1477
+ /**
1478
+ * True quando `value` è una macro di primo livello. Type guard, non cast: un
1479
+ * `className` che arriva dal bus è una stringa qualunque finché non passa di
1480
+ * qui.
1481
+ */
1482
+ function isFirstLevelMacroClass(value) {
1483
+ return FIRST_LEVEL_MACRO_CLASSES.some((macro) => macro === value);
1484
+ }
1485
+ /**
1486
+ * Wire schema for a per-model CATALOG classMap override
1487
+ * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
1488
+ * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
1489
+ * detection pipeline executor actually routes.
1490
+ *
1491
+ * This is deliberately a DIFFERENT, narrower shape than the general-purpose
1492
+ * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
1493
+ * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
1494
+ * enum) — the two used to share the name `ClassMapDefinition`/
1495
+ * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
1496
+ * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
1497
+ * are not: it is two different concepts colliding on a name. Keep this type
1498
+ * under its own name rather than reusing `ClassMapDefinition` — reusing it
1499
+ * would either narrow every `ClassMapDefinition` consumer to the four
1500
+ * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
1501
+ * schema exists for (see the "rejects a classMap whose target is not a
1502
+ * detection macro" test in `model-catalog-schema.test.ts`).
1503
+ */
1504
+ var DetectionCatalogClassMapSchema = zod.z.object({
1505
+ mapping: zod.z.record(zod.z.string(), zod.z.enum(CLASS_MAP_MACRO_TARGETS)),
1506
+ preserveOriginal: zod.z.boolean()
1507
+ });
1508
+ //#endregion
1439
1509
  //#region src/interfaces/recording-config.ts
1440
1510
  /**
1441
1511
  * THE canonical event-clip pad: the time window a single-timestamp analytics
@@ -1478,10 +1548,64 @@ var RecordingStorageModeSchema = zod.z.enum([
1478
1548
  "events",
1479
1549
  "continuous"
1480
1550
  ]);
1551
+ /**
1552
+ * Le macro classi che possono aprire una finestra di registrazione — le stesse
1553
+ * tre offerte dallo step `object-detection`, da UNA lista
1554
+ * ({@link FIRST_LEVEL_MACRO_CLASSES}).
1555
+ */
1556
+ var RecordingObjectTriggerClassSchema = zod.z.enum(FIRST_LEVEL_MACRO_CLASSES);
1557
+ /**
1558
+ * True quando `values` non ripete un elemento.
1559
+ *
1560
+ * Un duplicato non è innocuo: ogni voce di `objectClasses` / `sensorDeviceIds`
1561
+ * diventa una SORGENTE in `bandTriggerSources`, e la stessa sorgente due volte
1562
+ * conterebbe due volte le sue finestre in `segmentMissedByMs`.
1563
+ */
1564
+ var noDuplicates = (values) => new Set(values).size === values.length;
1565
+ /**
1566
+ * Quanti device sorgente una singola banda può ascoltare.
1567
+ *
1568
+ * Non è un gusto: ogni sorgente è una CHIAVE nel `TriggerState` del recorder, e
1569
+ * il limite per chiave (`MAX_TRIGGER_WINDOWS = 32`) senza un limite sulle
1570
+ * chiavi lascerebbe crescere la mappa con l'inventario dell'operatore. 16
1571
+ * sensori su UNA camera è già oltre qualunque installazione osservata.
1572
+ */
1573
+ var MAX_SENSOR_TRIGGER_DEVICES = 16;
1481
1574
  /** Which detectors trigger an `events`-mode band. */
1482
1575
  var RecordingTriggersSchema = zod.z.object({
1483
1576
  motion: zod.z.boolean().optional(),
1484
- audioThresholdDbfs: zod.z.number().optional()
1577
+ audioThresholdDbfs: zod.z.number().optional(),
1578
+ /**
1579
+ * Le macro classi la cui detection apre una finestra. ASSENTE = la sorgente
1580
+ * non è ascoltata; un array VUOTO è rifiutato, perché "banda events, trigger
1581
+ * object acceso, nessuna classe" è la stessa forma "abilitata e non registra
1582
+ * nulla, per sempre" contro cui è scritto `eventsBandCanEverDemand`.
1583
+ *
1584
+ * Il segnale letto è GIÀ FILTRATO: solo detection `source: 'pipeline'`, cioè
1585
+ * quelle che hanno attraversato `enabledMacroClasses`, i
1586
+ * `minConfidence<Macro>` e il full-frame guard. L'AI a bordo camera
1587
+ * (`source: 'onboard'`) non attraversa nessuno di quei gate e NON apre
1588
+ * finestre — vedi `recorder/object-trigger.ts`.
1589
+ */
1590
+ objectClasses: zod.z.array(RecordingObjectTriggerClassSchema).min(1).refine(noDuplicates, { message: "objectClasses must not repeat a class" }).optional(),
1591
+ /**
1592
+ * I device LINKED il cui FRONTE ALTO apre una finestra. Assente = la sorgente
1593
+ * non è ascoltata; un array vuoto è rifiutato per la stessa ragione di
1594
+ * `objectClasses`.
1595
+ *
1596
+ * Sono id di device SORGENTE, non camere: la banda li nomina, quindi il
1597
+ * percorso caldo (`DeviceStateChanged`, a ritmo di bus su tutta la flotta)
1598
+ * non fa RPC. L'OFFERTA da cui l'operatore li sceglie è un'altra domanda, e
1599
+ * si risolve con `deviceManager.getLinkedDevices` + `getBindingsBatch` per
1600
+ * device (D12) — mai un elenco globale di cap.
1601
+ *
1602
+ * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
1603
+ * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
1604
+ * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
1605
+ * il livello: un contatto trovato già aperto al riavvio del runner non fa
1606
+ * registrare.
1607
+ */
1608
+ sensorDeviceIds: zod.z.array(zod.z.number().int().positive()).min(1).max(16).refine(noDuplicates, { message: "sensorDeviceIds must not repeat a device" }).optional()
1485
1609
  });
1486
1610
  /**
1487
1611
  * Mode of a single recording band — the recorder per-band vocabulary.
@@ -2271,45 +2395,6 @@ function pickClosestResolution(entries, target) {
2271
2395
  return bestAbove?.entry ?? bestBelow?.entry;
2272
2396
  }
2273
2397
  //#endregion
2274
- //#region src/types/labels.ts
2275
- var LabelDefinitionSchema = zod.z.object({
2276
- id: zod.z.string(),
2277
- name: zod.z.string(),
2278
- category: zod.z.string().optional(),
2279
- description: zod.z.string().optional(),
2280
- icon: zod.z.string().optional()
2281
- });
2282
- /** Detection-macro targets a catalog `classMap` may resolve to. */
2283
- var CLASS_MAP_MACRO_TARGETS = [
2284
- "person",
2285
- "vehicle",
2286
- "animal",
2287
- "package"
2288
- ];
2289
- /**
2290
- * Wire schema for a per-model CATALOG classMap override
2291
- * (`ModelCatalogEntry.classMap` / `ModelConvertMetadata.classMap`) —
2292
- * restricted to {@link CLASS_MAP_MACRO_TARGETS}, the only macros the
2293
- * detection pipeline executor actually routes.
2294
- *
2295
- * This is deliberately a DIFFERENT, narrower shape than the general-purpose
2296
- * `ClassMapDefinition` interface above (e.g. `IDetectionAddon.getClassMap()`
2297
- * and the audio `YAMNET_TO_MACRO` catalog both use macro targets outside this
2298
- * enum) — the two used to share the name `ClassMapDefinition`/
2299
- * `ClassMapDefinitionSchema`, which made the schema-type-twin guard
2300
- * (`scripts/check-schema-type-twins.ts`) flag them as a duplicated shape. They
2301
- * are not: it is two different concepts colliding on a name. Keep this type
2302
- * under its own name rather than reusing `ClassMapDefinition` — reusing it
2303
- * would either narrow every `ClassMapDefinition` consumer to the four
2304
- * detection macros (breaking `YAMNET_TO_MACRO`) or drop the validation this
2305
- * schema exists for (see the "rejects a classMap whose target is not a
2306
- * detection macro" test in `model-catalog-schema.test.ts`).
2307
- */
2308
- var DetectionCatalogClassMapSchema = zod.z.object({
2309
- mapping: zod.z.record(zod.z.string(), zod.z.enum(CLASS_MAP_MACRO_TARGETS)),
2310
- preserveOriginal: zod.z.boolean()
2311
- });
2312
- //#endregion
2313
2398
  //#region src/types/model-variant-groups.ts
2314
2399
  var FORMAT_KEYS = [
2315
2400
  "onnx",
@@ -21651,7 +21736,7 @@ var lifecycleJobSchema = zod.z.object({
21651
21736
  * `useAddonsOnAddonLogs`, etc. flow through the same codegen pipeline
21652
21737
  * as every other cap.
21653
21738
  */
21654
- var LogLevelSchema$1 = zod.z.enum([
21739
+ var LogLevelSchema$2 = zod.z.enum([
21655
21740
  "debug",
21656
21741
  "info",
21657
21742
  "warn",
@@ -21878,7 +21963,7 @@ var addonsCapability = {
21878
21963
  getLogs: require_sleep.method(zod.z.object({
21879
21964
  addonId: zod.z.string(),
21880
21965
  limit: zod.z.number().min(1).max(500).default(100),
21881
- level: LogLevelSchema$1.optional()
21966
+ level: LogLevelSchema$2.optional()
21882
21967
  }), zod.z.array(LogQueryEntrySchema)),
21883
21968
  listPackages: require_sleep.method(zod.z.void(), zod.z.array(InstalledPackageSchema).readonly()),
21884
21969
  installPackage: require_sleep.method(zod.z.object({
@@ -22116,7 +22201,7 @@ var addonsCapability = {
22116
22201
  }),
22117
22202
  onAddonLogs: require_sleep.method(zod.z.object({
22118
22203
  addonId: zod.z.string(),
22119
- level: LogLevelSchema$1.optional()
22204
+ level: LogLevelSchema$2.optional()
22120
22205
  }), LogStreamEntrySchema, { kind: "subscription" })
22121
22206
  },
22122
22207
  /** BIG PLAN 2: declarative mount hint — read by `@camstack/system` `buildCapRouters`. */
@@ -24062,6 +24147,35 @@ var FaceFilterEnum = zod.z.enum([
24062
24147
  "identified",
24063
24148
  "all"
24064
24149
  ]);
24150
+ /**
24151
+ * What a `listRecentFaces` page is ORDERED BY.
24152
+ *
24153
+ * - `timestamp` — when the face was seen. The historical (and default) order.
24154
+ * - `suggestionConfidence` — {@link FaceInfo.suggestedMatchScore}, the peak
24155
+ * cosine of the face's SUGGESTED identity. This is the "review by certainty"
24156
+ * order: it puts the suggestions an operator can confirm with one tap at the
24157
+ * top, and it is the reason this enum exists — a client that ranked a capped
24158
+ * page client-side was ranking the newest N, never the most certain N.
24159
+ *
24160
+ * A row with NO suggestion (`suggestedMatchScore` absent — a legacy row, an
24161
+ * auto-assigned face, or a face below the suggestion band) has no certainty to
24162
+ * compare. Under `suggestionConfidence` it sorts **LAST, in BOTH directions**
24163
+ * — flipping the direction reorders the rows that HAVE a certainty and never
24164
+ * floods the page with the ones that do not. `addon-post-analysis`'s
24165
+ * `store/face-sort.ts` is the single implementation, tiebreaks newest-first
24166
+ * then by faceId, and is what makes this a total order instead of the
24167
+ * backend's NULL-collation accident.
24168
+ */
24169
+ var FaceSortFieldEnum = zod.z.enum(["timestamp", "suggestionConfidence"]);
24170
+ var FaceSortDirectionEnum = zod.z.enum(["asc", "desc"]);
24171
+ /** One suggested group of look-alike UNASSIGNED faces. Ids only — an embedding
24172
+ * never leaves the server. */
24173
+ var FaceClusterSchema = zod.z.object({
24174
+ faceIds: zod.z.array(zod.z.string()).readonly(),
24175
+ representativeFaceId: zod.z.string(),
24176
+ size: zod.z.number().int(),
24177
+ cohesion: zod.z.number()
24178
+ });
24065
24179
  var MediaFileLiteSchema$1 = zod.z.object({
24066
24180
  key: zod.z.string(),
24067
24181
  kind: zod.z.string(),
@@ -24119,24 +24233,72 @@ includeCrops: zod.z.boolean().optional() }).optional(), zod.z.array(IdentitySche
24119
24233
  auth: "admin"
24120
24234
  }),
24121
24235
  listRecentFaces: require_sleep.method(zod.z.object({
24122
- /** Restrict to one camera. Absent keeps the cluster-wide gallery view. */
24236
+ /**
24237
+ * Restrict to ONE camera. Absent keeps the cluster-wide gallery view.
24238
+ *
24239
+ * The legacy single-camera form, kept verbatim for every caller that
24240
+ * already sends it. A caller that wants a SET sends {@link deviceIds}
24241
+ * instead — never both: `deviceIds` is the authority whenever it is
24242
+ * present, and this field is then ignored rather than unioned, so
24243
+ * there is exactly one answer to "which cameras did I ask for".
24244
+ */
24123
24245
  deviceId: zod.z.number().int().optional(),
24246
+ /**
24247
+ * Restrict to a SET of cameras — the review UI's camera filter, which
24248
+ * until now had to fetch the cluster-wide page and drop rows in the
24249
+ * client (so the `limit` it asked for was spent on cameras it was
24250
+ * about to discard).
24251
+ *
24252
+ * An **empty array reads NOTHING** — `[]` is an empty page, never
24253
+ * "every camera". A request for no devices is a request, not an
24254
+ * omission; same contract as `deviceManager.listFleet` and
24255
+ * `pipelineAnalytics.listRecentTracks`.
24256
+ *
24257
+ * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
24258
+ */
24259
+ deviceIds: zod.z.array(zod.z.number().int()).optional(),
24124
24260
  limit: zod.z.number().int().positive().optional(),
24125
24261
  filter: FaceFilterEnum.optional(),
24126
24262
  /**
24127
- * Inline the base64 crop on every row. Default `true` — the existing
24128
- * behaviour, kept so no caller breaks.
24263
+ * Window lower bound on {@link FaceInfo.timestamp}, INCLUSIVE.
24264
+ * Absent means no lower bound.
24265
+ */
24266
+ since: zod.z.number().int().optional(),
24267
+ /**
24268
+ * Window upper bound on {@link FaceInfo.timestamp}, INCLUSIVE.
24269
+ * Absent means no upper bound.
24270
+ */
24271
+ until: zod.z.number().int().optional(),
24272
+ /**
24273
+ * Order the page by time or by suggestion certainty. Default
24274
+ * `'timestamp'` — the historical order, unchanged for every caller
24275
+ * that does not ask.
24129
24276
  *
24130
- * Set `false` once the caller renders {@link FaceInfo.cropUrl}: that
24131
- * drops ~2.87 MiB per 500-row page to a few KiB of metadata and lets
24132
- * the browser cache the images.
24277
+ * See {@link FaceSortFieldEnum} for what a row with no suggestion
24278
+ * does under `'suggestionConfidence'`.
24133
24279
  *
24134
- * **This is an INPUT field, so it does not reach the addon until the
24135
- * next train.** The hub router validates cap inputs against its own
24136
- * compiled Zod, which strips a key it does not know verified today
24137
- * on the OUTPUT side, where an additive field DOES arrive immediately
24138
- * (`Track.hasFace`). Until the train ships, sending `false` is
24139
- * harmless and simply keeps the crops inline.
24280
+ * Cost note: `'timestamp'` is served by the `(deviceId, timestamp)`
24281
+ * index and stops reading as soon as `limit` rows have PASSED the
24282
+ * filter. `'suggestionConfidence'` cannot stop earlythe most
24283
+ * certain row may be the oldest so it walks the window. Narrow it
24284
+ * with {@link since} / {@link until}.
24285
+ */
24286
+ sortBy: FaceSortFieldEnum.optional(),
24287
+ /** Sort direction for {@link sortBy}. Default `'desc'`. */
24288
+ sortDirection: FaceSortDirectionEnum.optional(),
24289
+ /**
24290
+ * Inline the base64 crop on every row.
24291
+ *
24292
+ * Default `false` since the 2026-08-25 inversion — see
24293
+ * `include-crops-default.ts`, which is the ONE place that resolves
24294
+ * this for every gallery, and which records why the inline shape had
24295
+ * to become the one you ASK for (60 457 ms → UDS timeout at 500 rows).
24296
+ * The doc here used to still say `true`; it was wrong, and a leftover
24297
+ * that describes the old design reads as permission to rely on it.
24298
+ *
24299
+ * Nothing loses its image: the row carries {@link FaceInfo.cropUrl},
24300
+ * which the browser fetches off the `event-media` plane in parallel,
24301
+ * cached and ETagged.
24140
24302
  */
24141
24303
  includeCrops: zod.z.boolean().optional()
24142
24304
  }).optional(), zod.z.array(FaceInfoSchema).readonly()),
@@ -24185,13 +24347,39 @@ includeCrops: zod.z.boolean().optional() }).optional(), zod.z.array(IdentitySche
24185
24347
  suggestFaceClusters: require_sleep.method(zod.z.object({
24186
24348
  threshold: zod.z.number().min(0).max(1).optional(),
24187
24349
  minClusterSize: zod.z.number().int().min(2).optional(),
24188
- limit: zod.z.number().int().positive().optional()
24189
- }).optional(), zod.z.array(zod.z.object({
24190
- faceIds: zod.z.array(zod.z.string()).readonly(),
24191
- representativeFaceId: zod.z.string(),
24192
- size: zod.z.number().int(),
24193
- cohesion: zod.z.number()
24194
- })).readonly())
24350
+ /**
24351
+ * Cap on the number of CLUSTERS returned. Renamed from `limit`,
24352
+ * which read as though it bounded the work — it never did.
24353
+ *
24354
+ * Wins over {@link limit} when both are sent.
24355
+ */
24356
+ maxClusters: zod.z.number().int().positive().optional(),
24357
+ /**
24358
+ * @deprecated Ambiguous name for {@link maxClusters} — it cuts the
24359
+ * RESULT, not the scan. Kept so existing callers keep working; send
24360
+ * `maxClusters` (and, if you care about cost, {@link maxFacesScanned}).
24361
+ */
24362
+ limit: zod.z.number().int().positive().optional(),
24363
+ /**
24364
+ * Cap on the number of unassigned faces READ AND CLUSTERED — the
24365
+ * POOL, not the result.
24366
+ *
24367
+ * This is the knob {@link maxClusters} was mistaken for. Clustering
24368
+ * used to read every unassigned face on the hub no matter what the
24369
+ * caller asked for, because the only bound cut the finished clusters
24370
+ * afterwards; a UI showing a window of 100 paid for a scan of the
24371
+ * whole corpus, on an addon whose disk is under contention.
24372
+ *
24373
+ * The pool is the NEWEST matching faces first — the same order the
24374
+ * gallery shows — so a bound here shortens the horizon, it does not
24375
+ * sample it randomly.
24376
+ *
24377
+ * Default: 1 000 (`FACE_SWEEP_PAGE`, exactly one store page). Chosen
24378
+ * so the live corpus — 372 face rows — is unaffected while the
24379
+ * unbounded scan can never come back as the table grows.
24380
+ */
24381
+ maxFacesScanned: zod.z.number().int().positive().optional()
24382
+ }).optional(), zod.z.array(FaceClusterSchema).readonly())
24195
24383
  }
24196
24384
  };
24197
24385
  //#endregion
@@ -30257,6 +30445,213 @@ var SetSiteLocationInputSchema = zod.z.object({
30257
30445
  latitude: zod.z.number().min(-90).max(90),
30258
30446
  longitude: zod.z.number().min(-180).max(180)
30259
30447
  }).nullable();
30448
+ /**
30449
+ * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
30450
+ * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
30451
+ * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
30452
+ * already prints - never a token, never an `Authorization` header.
30453
+ */
30454
+ var RequestCensusGroupSchema = zod.z.object({
30455
+ procedure: zod.z.string(),
30456
+ userAgent: zod.z.string(),
30457
+ ip: zod.z.string(),
30458
+ principal: zod.z.string(),
30459
+ calls: zod.z.number(),
30460
+ perMin: zod.z.number()
30461
+ });
30462
+ /**
30463
+ * A procedure's TOTAL over the window, across every caller.
30464
+ *
30465
+ * This block, not the group list, is what answers "did these calls arrive over
30466
+ * HTTP at all". A total far BELOW what a store-side census counted over the
30467
+ * same window excludes the HTTP plane, which is a result, not a failure.
30468
+ */
30469
+ var RequestCensusProcedureSchema = zod.z.object({
30470
+ procedure: zod.z.string(),
30471
+ calls: zod.z.number(),
30472
+ perMin: zod.z.number()
30473
+ });
30474
+ /** What one armed window measured. Mirrors `HttpRequestCensus.snapshot()`. */
30475
+ var RequestCensusSnapshotSchema = zod.z.object({
30476
+ armed: zod.z.boolean(),
30477
+ /** How long the current - or just-closed - window collected, in ms. */
30478
+ elapsedMs: zod.z.number(),
30479
+ /** The window actually armed, after the server clamped the request. */
30480
+ windowMs: zod.z.number(),
30481
+ /** Epoch ms the window closes at. 0 when disarmed. */
30482
+ armedUntilMs: zod.z.number(),
30483
+ httpRequests: zod.z.number(),
30484
+ batchedRequests: zod.z.number(),
30485
+ /**
30486
+ * Procedure invocations. Higher than `httpRequests` whenever tRPC batching
30487
+ * is in play (`?batch=1` carries several procedures in one request); this is
30488
+ * the number comparable with a store-side call count.
30489
+ */
30490
+ procedureCalls: zod.z.number(),
30491
+ /**
30492
+ * tRPC WebSocket connections opened during the window. NOT calls - the WS
30493
+ * transport resolves one context per connection - but the number that says
30494
+ * whether a plane this census cannot see was busy while HTTP was quiet.
30495
+ */
30496
+ wsConnections: zod.z.number(),
30497
+ distinctGroups: zod.z.number(),
30498
+ /** Calls counted in the totals whose group attribution was shed at the
30499
+ * cardinality bound. */
30500
+ unattributedCalls: zod.z.number(),
30501
+ procedures: zod.z.array(RequestCensusProcedureSchema).readonly(),
30502
+ groups: zod.z.array(RequestCensusGroupSchema).readonly()
30503
+ });
30504
+ /**
30505
+ * The census as an operator sees it.
30506
+ *
30507
+ * `persisted` is the honest answer to "will this survive the restart I am
30508
+ * about to do": the arm deadline is written to `system-settings` so a window
30509
+ * armed now can measure the NEXT boot, and a write that failed must not look
30510
+ * like one that succeeded.
30511
+ */
30512
+ var RequestCensusStatusSchema = RequestCensusSnapshotSchema.extend({ persisted: zod.z.boolean() });
30513
+ /** Severity vocabulary. Mirrors `LogLevel` in `interfaces/logging.ts`. */
30514
+ var LogLevelSchema$1 = zod.z.enum([
30515
+ "debug",
30516
+ "info",
30517
+ "warn",
30518
+ "error"
30519
+ ]);
30520
+ /**
30521
+ * The diagnostics that can be ARMED for a window. Exactly one today.
30522
+ *
30523
+ * A diagnostic is anything whose cost is only worth paying while a question is
30524
+ * open. It never persists as a boolean: see {@link DiagnosticWindowSchema}.
30525
+ */
30526
+ var DiagnosticIdSchema = zod.z.enum(["request-census"]);
30527
+ /**
30528
+ * The layers of the level hierarchy, general → specific. The most specific
30529
+ * layer that carries an explicit value wins.
30530
+ *
30531
+ * `component` is DECLARED and not yet resolvable: the per-component channels
30532
+ * are a later slice of the same plan, and a `levelSource` enum that has to
30533
+ * grow later would force every consumer of this document to change with it.
30534
+ * Nothing returns `component` today.
30535
+ */
30536
+ var LoggingScopeKindSchema = zod.z.enum([
30537
+ "cluster",
30538
+ "node",
30539
+ "component"
30540
+ ]);
30541
+ /** Where an effective level came from. `default` = nothing is set anywhere. */
30542
+ var LoggingLevelSourceSchema = zod.z.enum([
30543
+ "default",
30544
+ "cluster",
30545
+ "node",
30546
+ "component"
30547
+ ]);
30548
+ /**
30549
+ * One layer of the hierarchy as it actually STANDS.
30550
+ *
30551
+ * `level: null` is the whole reason this array is returned: it is the
30552
+ * difference between "this node is at `info` because I decided it" and
30553
+ * "...because it inherits". An operator who clears an override believing they
30554
+ * are clearing an inherited value has been handed the same defect as the two
30555
+ * contradicting knobs this document exists to remove, moved one floor up.
30556
+ */
30557
+ var LoggingLevelLayerSchema = zod.z.object({
30558
+ scope: LoggingScopeKindSchema,
30559
+ /** The node this layer speaks for; `null` on the cluster layer. */
30560
+ nodeId: zod.z.string().nullable(),
30561
+ /** Explicitly set here, or `null` when this layer inherits. */
30562
+ level: LogLevelSchema$1.nullable()
30563
+ });
30564
+ /** What a line is judged against, and WHICH layer decided it. */
30565
+ var LoggingEffectiveSchema = zod.z.object({
30566
+ level: LogLevelSchema$1,
30567
+ levelSource: LoggingLevelSourceSchema
30568
+ });
30569
+ /** Every layer, general → specific. Never collapsed into the effective value. */
30570
+ var LoggingExplicitSchema = zod.z.object({ layers: zod.z.array(LoggingLevelLayerSchema).readonly() });
30571
+ /**
30572
+ * An armed diagnostic, with its DEADLINE.
30573
+ *
30574
+ * The shape of ADR-0244: what is stored is a deadline and never a flag, so a
30575
+ * diagnostic somebody forgot expires by itself, and a boot-window measurement
30576
+ * survives the restart it exists to measure. `remainingMs` is 0 whenever
30577
+ * `armed` is false — a window is never reported as slightly expired.
30578
+ */
30579
+ var DiagnosticWindowSchema = zod.z.object({
30580
+ id: DiagnosticIdSchema,
30581
+ armed: zod.z.boolean(),
30582
+ /** Epoch ms the window closes at. 0 when disarmed. */
30583
+ armedUntilMs: zod.z.number(),
30584
+ /** Ms left before it expires on its own. 0 when disarmed. */
30585
+ remainingMs: zod.z.number(),
30586
+ /** Whether the stored deadline is the one the live diagnostic is running —
30587
+ * i.e. whether this window would survive a restart. */
30588
+ persisted: zod.z.boolean()
30589
+ });
30590
+ /**
30591
+ * `armMs: 0` DISARMS. Any positive value arms for that long, clamped by the
30592
+ * server — there is no maximum here on purpose: a bound repeated in a schema
30593
+ * is a second knob that disagrees with the first the day one of them moves.
30594
+ */
30595
+ var DiagnosticWindowPatchSchema = zod.z.object({
30596
+ id: DiagnosticIdSchema,
30597
+ armMs: zod.z.number().int().min(0),
30598
+ /** Cadence of the diagnostic's aggregated report line. Clamped by the server. */
30599
+ reportEveryMs: zod.z.number().int().positive().optional()
30600
+ });
30601
+ /**
30602
+ * A PATCH, and patches MERGE.
30603
+ *
30604
+ * A field absent from the patch is left exactly as it was — arming a
30605
+ * diagnostic never resets a level, and setting a level never disarms a window.
30606
+ * The provider must not reconstruct the document as `{ ...snapshot, ...patch }`:
30607
+ * `setAll` already merges, and rebuilding the object is how an absent field
30608
+ * turns into an erased one.
30609
+ */
30610
+ var LoggingSettingsPatchSchema = zod.z.object({
30611
+ /**
30612
+ * Absent leaves the level untouched. `null` CLEARS the explicit value at the
30613
+ * addressed scope so it inherits again. A value sets it.
30614
+ */
30615
+ level: LogLevelSchema$1.nullable().optional(),
30616
+ /**
30617
+ * Only the diagnostics NAMED here change. An armed window that is not listed
30618
+ * keeps running — a patch is never a full replacement.
30619
+ */
30620
+ diagnostics: zod.z.array(DiagnosticWindowPatchSchema).readonly().optional()
30621
+ });
30622
+ /**
30623
+ * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
30624
+ *
30625
+ * Deliberately NOT called `nodeId`: that key is reserved on every cap method
30626
+ * input — the generated router strips it and uses it to resolve the PROVIDER
30627
+ * on that node (`resolveProvider(cap, nodeId, …)`). A document about
30628
+ * `agent-1` addressed as `nodeId` would be forwarded to agent-1 and answered
30629
+ * by an agent that holds no cluster document at all. The hub is the single
30630
+ * authority over the whole hierarchy and answers for every layer, so the
30631
+ * layer selector needs a name the transport does not already own.
30632
+ */
30633
+ var GetLoggingSettingsInputSchema = zod.z.object({ scopeNodeId: zod.z.string().optional() });
30634
+ var SetLoggingSettingsInputSchema = zod.z.object({
30635
+ scopeNodeId: zod.z.string().optional(),
30636
+ patch: LoggingSettingsPatchSchema
30637
+ });
30638
+ /**
30639
+ * The whole document, as read and as returned after every write.
30640
+ *
30641
+ * `persisted: false` means the settings store could not be read or written.
30642
+ * The in-memory mirror still governs behaviour and is unchanged by the
30643
+ * failure — a read that fails neither switches a level nor disarms a window
30644
+ * (D49) — but the operator is told that what they are looking at would not
30645
+ * survive a restart.
30646
+ */
30647
+ var LoggingSettingsStateSchema = zod.z.object({
30648
+ /** The layer this document was read at. `null` = the cluster layer. */
30649
+ scopeNodeId: zod.z.string().nullable(),
30650
+ effective: LoggingEffectiveSchema,
30651
+ explicit: LoggingExplicitSchema,
30652
+ activeWindows: zod.z.array(DiagnosticWindowSchema).readonly(),
30653
+ persisted: zod.z.boolean()
30654
+ });
30260
30655
  var systemCapability = {
30261
30656
  name: "system",
30262
30657
  scope: "system",
@@ -30300,6 +30695,38 @@ var systemCapability = {
30300
30695
  detectSiteLocation: require_sleep.method(zod.z.void(), SiteLocationStatusSchema, {
30301
30696
  kind: "mutation",
30302
30697
  auth: "admin"
30698
+ }),
30699
+ /**
30700
+ * Read the HTTP request census - which caller, from which address, with
30701
+ * which user-agent, invoked which tRPC procedure, and how often.
30702
+ *
30703
+ * Reading NEVER re-arms: re-arming clears the counts, which would throw
30704
+ * away exactly the numbers being asked for. A closed window may be read as
30705
+ * many times as the operator likes and always describes the same window.
30706
+ *
30707
+ * Admin-only: the rows carry source addresses and principal names.
30708
+ */
30709
+ getRequestCensus: require_sleep.method(zod.z.void(), RequestCensusStatusSchema, { auth: "admin" }),
30710
+ /**
30711
+ * The logging settings document — levels and armed diagnostics — resolved
30712
+ * for `nodeId`, or for the cluster when `nodeId` is absent.
30713
+ *
30714
+ * Returns BOTH `effective` and `explicit`. See
30715
+ * {@link LoggingLevelLayerSchema} for why collapsing them is the defect.
30716
+ */
30717
+ getLoggingSettings: require_sleep.method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }),
30718
+ /**
30719
+ * Write the logging settings document. The ONLY write authority over log
30720
+ * levels and diagnostic windows — arming the request census went through
30721
+ * `system.setRequestCensus` until 2026-08-27 and no longer does, because
30722
+ * two writes that disagree about the same window is exactly the defect
30723
+ * this document exists to remove (D245).
30724
+ *
30725
+ * The patch MERGES: see {@link LoggingSettingsPatchSchema}.
30726
+ */
30727
+ setLoggingSettings: require_sleep.method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30728
+ kind: "mutation",
30729
+ auth: "admin"
30303
30730
  })
30304
30731
  },
30305
30732
  /** BIG PLAN 2: declarative mount hint — read by `@camstack/system` `buildCapRouters`. */
@@ -31494,6 +31921,172 @@ function stateVocabularyFor(runtimeState, alarmStates = []) {
31494
31921
  return [];
31495
31922
  }
31496
31923
  //#endregion
31924
+ //#region src/catalogs/sensor-active-state.ts
31925
+ /**
31926
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
31927
+ * valutatore puro del suo FRONTE.
31928
+ *
31929
+ * Viveva dentro il builtin virtual-doorbell
31930
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
31931
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
31932
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
31933
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
31934
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
31935
+ * SPOSTA qui e il doorbell la ri-esporta.
31936
+ *
31937
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
31938
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
31939
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
31940
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
31941
+ */
31942
+ /**
31943
+ * Known binary / switch source caps → the boolean slice field whose
31944
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
31945
+ * Sensors whose "active" reading is not a plain boolean (presence's string
31946
+ * state, connectivity's connected flag) are deliberately excluded — a
31947
+ * reconnect is not a doorbell press, and it is not a recording either.
31948
+ */
31949
+ var SOURCE_CAP_ACTIVE_FIELD = {
31950
+ contact: "entryOpen",
31951
+ binary: "on",
31952
+ switch: "on",
31953
+ motion: "detected",
31954
+ flood: "flooded",
31955
+ gas: "detected",
31956
+ smoke: "detected",
31957
+ "carbon-monoxide": "detected",
31958
+ vibration: "detected",
31959
+ tamper: "tampered"
31960
+ };
31961
+ /**
31962
+ * The same caps → the slice field carrying the ms-epoch timestamp of the
31963
+ * last transition. Every source cap MUST appear here (guarded by a spec):
31964
+ * without a transition timestamp the evaluator cannot tell a genuine rise
31965
+ * from a boot-time hydration when the FIRST slice it ever sees is already
31966
+ * active, and errs towards silence — swallowing the rise.
31967
+ *
31968
+ * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
31969
+ * provider derives them from `state.last_changed`, so they survive our own
31970
+ * restarts and correctly read as "hours ago" for a state that has been
31971
+ * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
31972
+ */
31973
+ var SOURCE_CAP_CHANGED_AT_FIELD = {
31974
+ contact: "lastChangedAt",
31975
+ binary: "lastChangedAt",
31976
+ switch: "lastChangedAt",
31977
+ motion: "lastDetectedAt",
31978
+ flood: "lastChangedAt",
31979
+ gas: "lastChangedAt",
31980
+ smoke: "lastChangedAt",
31981
+ "carbon-monoxide": "lastChangedAt",
31982
+ vibration: "lastChangedAt",
31983
+ tamper: "lastChangedAt"
31984
+ };
31985
+ /** Cap names whose presence in a device's bindings qualify it as a source. */
31986
+ var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
31987
+ /**
31988
+ * Device `type` values (from `DeviceType`) that can host a binary/switch
31989
+ * source cap. Used by the camera's `device-multiselect` picker as the
31990
+ * CLIENT-SIDE filter, alongside `SOURCE_CAPS`.
31991
+ *
31992
+ * Why types and not caps alone: the shared picker filters
31993
+ * `deviceManager.listAll` rows client-side, and those rows carry only the
31994
+ * device's advertised `features` — NOT its registered cap list. On the live
31995
+ * cluster binary sensors and switches advertise EMPTY features (features
31996
+ * mirror only a handful of caps like `motion-trigger`), so a caps-only
31997
+ * filter matched against `features` would list nothing (the very bug this
31998
+ * replaced, which relied on the now-empty `getAllBindings`). Matching by
31999
+ * `type` is the reliable client-side signal; the union with `SOURCE_CAPS`
32000
+ * still captures any device that DOES advertise a source-cap feature.
32001
+ * `sensor` covers contact/motion/flood/gas/smoke/CO/vibration/tamper,
32002
+ * `switch` covers switches, `control` covers generic binary actuators.
32003
+ */
32004
+ var SOURCE_DEVICE_TYPES = [
32005
+ "sensor",
32006
+ "switch",
32007
+ "control"
32008
+ ];
32009
+ /** True when a cap is a recognised binary/switch source. */
32010
+ function isSourceCap(capName) {
32011
+ return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
32012
+ }
32013
+ /** Extract the "active" boolean a source cap's slice carries, or null when
32014
+ * the cap is unknown or the field is missing / non-boolean. */
32015
+ function sliceActiveValue(capName, slice) {
32016
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
32017
+ if (field === void 0) return null;
32018
+ const raw = slice[field];
32019
+ return typeof raw === "boolean" ? raw : null;
32020
+ }
32021
+ /** Ms-epoch transition timestamp a source cap's slice carries, or null when
32022
+ * it is absent, non-numeric or the zero "never observed" sentinel. */
32023
+ function sliceChangedAt(capName, slice) {
32024
+ const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
32025
+ if (field === void 0) return null;
32026
+ const raw = slice[field];
32027
+ if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
32028
+ return raw;
32029
+ }
32030
+ /**
32031
+ * How recent a source's own transition timestamp must be for a FIRST
32032
+ * sighting that is already active to count as a genuine rise rather than a
32033
+ * hydration of long-standing state.
32034
+ */
32035
+ var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
32036
+ /**
32037
+ * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
32038
+ * porta `prior`, `nowMs` e il proprio `startedAtMs`.
32039
+ *
32040
+ * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
32041
+ * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
32042
+ * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
32043
+ * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
32044
+ * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
32045
+ * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
32046
+ * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
32047
+ * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
32048
+ */
32049
+ function evaluateSensorEdge(input) {
32050
+ const value = sliceActiveValue(input.capName, input.slice);
32051
+ if (value === null) return {
32052
+ edge: "none",
32053
+ value: null,
32054
+ reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
32055
+ };
32056
+ if (input.prior === void 0) {
32057
+ if (!value) return {
32058
+ edge: "none",
32059
+ value,
32060
+ reason: "baseline-seeded-inactive"
32061
+ };
32062
+ const changedAt = sliceChangedAt(input.capName, input.slice);
32063
+ const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
32064
+ if (changedAt === null || changedAt < floor) return {
32065
+ edge: "none",
32066
+ value,
32067
+ reason: "baseline-seeded-stale-active"
32068
+ };
32069
+ return {
32070
+ edge: "rising",
32071
+ value: true
32072
+ };
32073
+ }
32074
+ if (input.prior === value) return {
32075
+ edge: "none",
32076
+ value,
32077
+ reason: "no-change"
32078
+ };
32079
+ if (!value) return {
32080
+ edge: "none",
32081
+ value,
32082
+ reason: "falling-edge"
32083
+ };
32084
+ return {
32085
+ edge: "rising",
32086
+ value: true
32087
+ };
32088
+ }
32089
+ //#endregion
31497
32090
  //#region src/constants.ts
31498
32091
  var HF_REPO = "camstack/camstack-models";
31499
32092
  var HF_BASE_URL = `https://huggingface.co/${HF_REPO}/resolve/main`;
@@ -32655,6 +33248,47 @@ var BaseDeviceProvider = class extends require_sleep.BaseAddon {
32655
33248
  }
32656
33249
  };
32657
33250
  //#endregion
33251
+ //#region src/device/battery-presence.ts
33252
+ /**
33253
+ * Default silence budget before a sleeping battery camera is called gone.
33254
+ *
33255
+ * Sized off the mechanism that produces contact, not off taste: a battery cam
33256
+ * on this deployment surfaces a firmware push (battery level, sleep/wake, or a
33257
+ * motion email) on the order of hours even with no visitors, and the snapshot
33258
+ * wrapper's own battery window is 1 hour. Six hours is therefore several
33259
+ * missed opportunities, not one — so a single quiet night does not raise a
33260
+ * fault, and a genuinely flat camera is named well inside a day.
33261
+ */
33262
+ var BATTERY_UNREACHABLE_AFTER_MS = 360 * 6e4;
33263
+ /**
33264
+ * THE derivation. One crop rectangle, one presence verdict — see D52 for why
33265
+ * this repo insists a derived value has exactly one implementation.
33266
+ *
33267
+ * `undefined` status ⇒ `sleeping`. A device with no slice has made no claim,
33268
+ * and the caller decides separately whether it is even battery-operated
33269
+ * (`DeviceFeature.BatteryOperated`); this function never answers that
33270
+ * question, only what a battery device is doing.
33271
+ */
33272
+ function deriveBatteryPresence(input) {
33273
+ const status = input.status;
33274
+ if (!status) return "sleeping";
33275
+ if (status.sleeping !== true) return "awake";
33276
+ const lastContactAt = status.lastContactAt;
33277
+ if (typeof lastContactAt !== "number" || lastContactAt <= 0) return "sleeping";
33278
+ const budget = input.unreachableAfterMs ?? 216e5;
33279
+ return input.nowMs - lastContactAt > budget ? "unreachable" : "sleeping";
33280
+ }
33281
+ /**
33282
+ * Is this presence a FAULT the operator should be told about?
33283
+ *
33284
+ * Exists so no surface has to re-decide it — the whole point of the third
33285
+ * state is that `sleeping` stops being rendered as breakage, and a caller that
33286
+ * writes `presence !== 'awake'` has silently undone that.
33287
+ */
33288
+ function isBatteryPresenceFault(presence) {
33289
+ return presence === "unreachable";
33290
+ }
33291
+ //#endregion
32658
33292
  //#region src/device/declared-device.ts
32659
33293
  /** Marker written to a declared integration's `info`. */
32660
33294
  var DECLARED_INTEGRATION_FIXED_KEY = "fixed";
@@ -33121,47 +33755,6 @@ function resolveDeviceProfile(features) {
33121
33755
  return null;
33122
33756
  }
33123
33757
  //#endregion
33124
- //#region src/device/battery-presence.ts
33125
- /**
33126
- * Default silence budget before a sleeping battery camera is called gone.
33127
- *
33128
- * Sized off the mechanism that produces contact, not off taste: a battery cam
33129
- * on this deployment surfaces a firmware push (battery level, sleep/wake, or a
33130
- * motion email) on the order of hours even with no visitors, and the snapshot
33131
- * wrapper's own battery window is 1 hour. Six hours is therefore several
33132
- * missed opportunities, not one — so a single quiet night does not raise a
33133
- * fault, and a genuinely flat camera is named well inside a day.
33134
- */
33135
- var BATTERY_UNREACHABLE_AFTER_MS = 360 * 6e4;
33136
- /**
33137
- * THE derivation. One crop rectangle, one presence verdict — see D52 for why
33138
- * this repo insists a derived value has exactly one implementation.
33139
- *
33140
- * `undefined` status ⇒ `sleeping`. A device with no slice has made no claim,
33141
- * and the caller decides separately whether it is even battery-operated
33142
- * (`DeviceFeature.BatteryOperated`); this function never answers that
33143
- * question, only what a battery device is doing.
33144
- */
33145
- function deriveBatteryPresence(input) {
33146
- const status = input.status;
33147
- if (!status) return "sleeping";
33148
- if (status.sleeping !== true) return "awake";
33149
- const lastContactAt = status.lastContactAt;
33150
- if (typeof lastContactAt !== "number" || lastContactAt <= 0) return "sleeping";
33151
- const budget = input.unreachableAfterMs ?? 216e5;
33152
- return input.nowMs - lastContactAt > budget ? "unreachable" : "sleeping";
33153
- }
33154
- /**
33155
- * Is this presence a FAULT the operator should be told about?
33156
- *
33157
- * Exists so no surface has to re-decide it — the whole point of the third
33158
- * state is that `sleeping` stops being rendered as breakage, and a caller that
33159
- * writes `presence !== 'awake'` has silently undone that.
33160
- */
33161
- function isBatteryPresenceFault(presence) {
33162
- return presence === "unreachable";
33163
- }
33164
- //#endregion
33165
33758
  //#region src/device/path-util.ts
33166
33759
  /** Returns true when `x` is a non-null, non-array plain object. */
33167
33760
  function isRecord(x) {
@@ -40445,6 +41038,18 @@ var METHOD_ACCESS_MAP = Object.freeze({
40445
41038
  addonId: null,
40446
41039
  access: "create"
40447
41040
  },
41041
+ "system.getLoggingSettings": {
41042
+ capName: "system",
41043
+ capScope: "system",
41044
+ addonId: null,
41045
+ access: "view"
41046
+ },
41047
+ "system.getRequestCensus": {
41048
+ capName: "system",
41049
+ capScope: "system",
41050
+ addonId: null,
41051
+ access: "view"
41052
+ },
40448
41053
  "system.getRetentionConfig": {
40449
41054
  capName: "system",
40450
41055
  capScope: "system",
@@ -40475,6 +41080,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
40475
41080
  addonId: null,
40476
41081
  access: "view"
40477
41082
  },
41083
+ "system.setLoggingSettings": {
41084
+ capName: "system",
41085
+ capScope: "system",
41086
+ addonId: null,
41087
+ access: "create"
41088
+ },
40478
41089
  "system.setRetentionConfig": {
40479
41090
  capName: "system",
40480
41091
  capScope: "system",
@@ -41887,6 +42498,10 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
41887
42498
  name: "deviceId",
41888
42499
  form: "single",
41889
42500
  optional: true
42501
+ }, {
42502
+ name: "deviceIds",
42503
+ form: "array",
42504
+ optional: true
41890
42505
  }],
41891
42506
  "fanControl.setDirection": [{
41892
42507
  name: "deviceId",
@@ -44204,7 +44819,10 @@ function createSystemProxy(api) {
44204
44819
  forceRetentionCleanup: (input) => dispatch("system", "forceRetentionCleanup", "mutation", input),
44205
44820
  getSiteLocation: (input) => dispatch("system", "getSiteLocation", "query", input),
44206
44821
  setSiteLocation: (input) => dispatch("system", "setSiteLocation", "mutation", input),
44207
- detectSiteLocation: (input) => dispatch("system", "detectSiteLocation", "mutation", input)
44822
+ detectSiteLocation: (input) => dispatch("system", "detectSiteLocation", "mutation", input),
44823
+ getRequestCensus: (input) => dispatch("system", "getRequestCensus", "query", input),
44824
+ getLoggingSettings: (input) => dispatch("system", "getLoggingSettings", "query", input),
44825
+ setLoggingSettings: (input) => dispatch("system", "setLoggingSettings", "mutation", input)
44208
44826
  },
44209
44827
  terminalSession: {
44210
44828
  listProfiles: (input) => dispatch("terminalSession", "listProfiles", "query", input),
@@ -46067,6 +46685,7 @@ var NATIVE_LEASE_BUDGET_KEY = "nativeLeaseBudgetMb";
46067
46685
  var NATIVE_LEASE_ACTIVITY_KEY = "nativeLeaseActivityMs";
46068
46686
  var NATIVE_LEASE_ADMISSION_KEY = "nativeLeaseAdmission";
46069
46687
  var NATIVE_LEASE_TILE_BUDGET_KEY = "nativeTileBudgetMb";
46688
+ var NATIVE_LEASE_SCENE_BUDGET_KEY = "nativeSceneBudgetMb";
46070
46689
  /**
46071
46690
  * WHICH delivered frames the decode worker retains a native copy of.
46072
46691
  *
@@ -46161,7 +46780,38 @@ var NativeLeaseSettingsSchema = zod.z.object({
46161
46780
  * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
46162
46781
  * reproduce that.
46163
46782
  */
46164
- tileBudgetMb: zod.z.number().int().min(0).max(1024)
46783
+ tileBudgetMb: zod.z.number().int().min(0).max(1024),
46784
+ /**
46785
+ * RAM ceiling per decode worker, in MB, for the SCENE TILES — one
46786
+ * JPEG-encoded copy of the WHOLE native frame, cut in the same instant as the
46787
+ * subject tiles, on frames that detected something.
46788
+ *
46789
+ * It exists because a subject tile cannot answer a FULL-FRAME request:
46790
+ * containment is strict by design, so the native `keyFrame`, the detail
46791
+ * plane's `frameJpeg` rung and the display-crop fallback had no rung at all
46792
+ * below the hold. Measured on the live cluster: 23.3% of key-frame captures
46793
+ * missed, 95.7% of them with `worker-lease-gone` — the raster released one
46794
+ * frame-time after delivery, with the request only p50 367 ms behind it.
46795
+ *
46796
+ * Sizing, and why this is a budget and not a duration: a scene tile is
46797
+ * ~1.5-2.5 MB at 4K (against ~23.75 MB for the raster it was cut from and
46798
+ * ~60-120 KB for a subject tile), and it is cut ~0.4 times a second per busy
46799
+ * camera — only detection-bearing frames get one. 48 MB is therefore ~20-30
46800
+ * frames, i.e. the store's 30 s TTL binds at the steady state and the budget
46801
+ * binds only through a detection burst, where it still covers well past the
46802
+ * measured p90 ask age of 4.3 s. Holding the RASTERS for the same window
46803
+ * would be ~498 MB per camera and ~6 GB at peak concurrency — the OOM this
46804
+ * whole shape exists to avoid.
46805
+ *
46806
+ * A SEPARATE ceiling from `tileBudgetMb` on purpose: a scene tile is ~20× a
46807
+ * subject tile, so one shared budget would let a busy camera's key frames
46808
+ * evict the face/plate tiles the recognisers depend on. Two budgets make that
46809
+ * impossible rather than unlikely. `0` DISABLES scene tiles and restores the
46810
+ * pre-existing behaviour, where a late full-frame request had nothing but the
46811
+ * ≤640 RAM raster — which the `keyFrame` gate rejects, so in practice it had
46812
+ * nothing.
46813
+ */
46814
+ sceneBudgetMb: zod.z.number().int().min(0).max(1024)
46165
46815
  });
46166
46816
  /**
46167
46817
  * The values in force when the operator has set nothing.
@@ -46177,6 +46827,7 @@ var DEFAULT_NATIVE_LEASE_SETTINGS = {
46177
46827
  budgetMb: 1024,
46178
46828
  activityMs: 15e3,
46179
46829
  tileBudgetMb: 64,
46830
+ sceneBudgetMb: 48,
46180
46831
  admission: "inferred"
46181
46832
  };
46182
46833
  /** Slider bounds for the operator-facing knobs (orchestrator settings UI). */
@@ -46204,6 +46855,12 @@ var NATIVE_LEASE_TILE_BUDGET_FIELD = {
46204
46855
  step: 16,
46205
46856
  default: DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb
46206
46857
  };
46858
+ var NATIVE_LEASE_SCENE_BUDGET_FIELD = {
46859
+ min: 0,
46860
+ max: 1024,
46861
+ step: 16,
46862
+ default: DEFAULT_NATIVE_LEASE_SETTINGS.sceneBudgetMb
46863
+ };
46207
46864
  /** Select options for the admission knob (orchestrator settings UI). */
46208
46865
  var NATIVE_LEASE_ADMISSION_FIELD = {
46209
46866
  options: [{
@@ -46262,12 +46919,14 @@ function readNativeLeaseOverride(config) {
46262
46919
  const activityMs = readKnob("activityMs", config[NATIVE_LEASE_ACTIVITY_KEY]);
46263
46920
  const admission = readAdmissionKnob(config[NATIVE_LEASE_ADMISSION_KEY]);
46264
46921
  const tileBudgetMb = readKnob("tileBudgetMb", config[NATIVE_LEASE_TILE_BUDGET_KEY]);
46922
+ const sceneBudgetMb = readKnob("sceneBudgetMb", config[NATIVE_LEASE_SCENE_BUDGET_KEY]);
46265
46923
  return {
46266
46924
  ...holdFrames === null ? {} : { holdFrames },
46267
46925
  ...budgetMb === null ? {} : { budgetMb },
46268
46926
  ...activityMs === null ? {} : { activityMs },
46269
46927
  ...admission === null ? {} : { admission },
46270
- ...tileBudgetMb === null ? {} : { tileBudgetMb }
46928
+ ...tileBudgetMb === null ? {} : { tileBudgetMb },
46929
+ ...sceneBudgetMb === null ? {} : { sceneBudgetMb }
46271
46930
  };
46272
46931
  }
46273
46932
  function isHydratedField(entry) {
@@ -46278,7 +46937,8 @@ var LEASE_KEYS = [
46278
46937
  NATIVE_LEASE_BUDGET_KEY,
46279
46938
  NATIVE_LEASE_ACTIVITY_KEY,
46280
46939
  NATIVE_LEASE_ADMISSION_KEY,
46281
- NATIVE_LEASE_TILE_BUDGET_KEY
46940
+ NATIVE_LEASE_TILE_BUDGET_KEY,
46941
+ NATIVE_LEASE_SCENE_BUDGET_KEY
46282
46942
  ];
46283
46943
  /**
46284
46944
  * Extract the operator's lease overrides from an
@@ -48370,6 +49030,7 @@ exports.DEFAULT_DETAIL_CROP_CONVENTION = DEFAULT_DETAIL_CROP_CONVENTION;
48370
49030
  exports.DEFAULT_EVENTS_BAND_BUFFER_SEC = DEFAULT_EVENTS_BAND_BUFFER_SEC;
48371
49031
  exports.DEFAULT_EVENT_COLOR = DEFAULT_EVENT_COLOR;
48372
49032
  exports.DEFAULT_FEATURES = DEFAULT_FEATURES;
49033
+ exports.DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = DEFAULT_FIRST_SIGHTING_FRESHNESS_MS;
48373
49034
  exports.DEFAULT_MIN_LANDMARK_FACE_SIZE_PX = DEFAULT_MIN_LANDMARK_FACE_SIZE_PX;
48374
49035
  exports.DEFAULT_NATIVE_LEASE_SETTINGS = DEFAULT_NATIVE_LEASE_SETTINGS;
48375
49036
  exports.DEFAULT_POOL_MEMORY_POLICY = DEFAULT_POOL_MEMORY_POLICY;
@@ -48420,6 +49081,9 @@ exports.DeviceRuntimeState = DeviceRuntimeState;
48420
49081
  exports.DeviceSelectorSchema = DeviceSelectorSchema;
48421
49082
  exports.DeviceStatusSchema = DeviceStatusSchema;
48422
49083
  exports.DeviceType = require_sleep.DeviceType;
49084
+ exports.DiagnosticIdSchema = DiagnosticIdSchema;
49085
+ exports.DiagnosticWindowPatchSchema = DiagnosticWindowPatchSchema;
49086
+ exports.DiagnosticWindowSchema = DiagnosticWindowSchema;
48423
49087
  exports.DiscoveredChildDeviceSchema = DiscoveredChildDeviceSchema;
48424
49088
  exports.DiscoveredChildStatusSchema = DiscoveredChildStatusSchema;
48425
49089
  exports.DiscoveredDeviceSchema = DiscoveredDeviceSchema;
@@ -48484,6 +49148,7 @@ exports.ExpressionGlobalBindingSchema = ExpressionGlobalBindingSchema;
48484
49148
  exports.ExpressionLiteralBindingSchema = ExpressionLiteralBindingSchema;
48485
49149
  exports.ExpressionParseError = ExpressionParseError;
48486
49150
  exports.ExpressionSourceSchema = ExpressionSourceSchema;
49151
+ exports.FIRST_LEVEL_MACRO_CLASSES = FIRST_LEVEL_MACRO_CLASSES;
48487
49152
  exports.FULL_IMAGE_BBOX = FULL_IMAGE_BBOX;
48488
49153
  exports.FanControlStatusSchema = FanControlStatusSchema;
48489
49154
  exports.FanDirectionSchema = FanDirectionSchema;
@@ -48497,6 +49162,7 @@ exports.FrameInputSchema = FrameInputSchema;
48497
49162
  exports.FrameLazyCountersSchema = FrameLazyCountersSchema;
48498
49163
  exports.FrameLazyMetricsSchema = FrameLazyMetricsSchema;
48499
49164
  exports.GasStatusSchema = GasStatusSchema;
49165
+ exports.GetLoggingSettingsInputSchema = GetLoggingSettingsInputSchema;
48500
49166
  exports.GetStreamWithCodecInputSchema = GetStreamWithCodecInputSchema;
48501
49167
  exports.GlobalMetricsSchema = GlobalMetricsSchema;
48502
49168
  exports.HAP_AUDIO_BASE = HAP_AUDIO_BASE;
@@ -48568,6 +49234,13 @@ exports.LockStateSchema = LockStateSchema;
48568
49234
  exports.LogEntrySchema = LogEntrySchema;
48569
49235
  exports.LogLevelSchema = LogLevelSchema;
48570
49236
  exports.LogStreamEntrySchema = LogStreamEntrySchema;
49237
+ exports.LoggingEffectiveSchema = LoggingEffectiveSchema;
49238
+ exports.LoggingExplicitSchema = LoggingExplicitSchema;
49239
+ exports.LoggingLevelLayerSchema = LoggingLevelLayerSchema;
49240
+ exports.LoggingLevelSourceSchema = LoggingLevelSourceSchema;
49241
+ exports.LoggingScopeKindSchema = LoggingScopeKindSchema;
49242
+ exports.LoggingSettingsPatchSchema = LoggingSettingsPatchSchema;
49243
+ exports.LoggingSettingsStateSchema = LoggingSettingsStateSchema;
48571
49244
  exports.LoginMethodContributionSchema = LoginMethodContributionSchema;
48572
49245
  exports.LoginStageEnum = LoginStageEnum;
48573
49246
  exports.MACRO_LABELS = MACRO_LABELS;
@@ -48580,6 +49253,7 @@ exports.MAX_EXPRESSION_BINDINGS = MAX_EXPRESSION_BINDINGS;
48580
49253
  exports.MAX_EXPRESSION_CALL_ARGS = MAX_EXPRESSION_CALL_ARGS;
48581
49254
  exports.MAX_EXPRESSION_EVAL_STEPS = MAX_EXPRESSION_EVAL_STEPS;
48582
49255
  exports.MAX_EXPRESSION_SOURCE_LENGTH = MAX_EXPRESSION_SOURCE_LENGTH;
49256
+ exports.MAX_SENSOR_TRIGGER_DEVICES = MAX_SENSOR_TRIGGER_DEVICES;
48583
49257
  exports.METHOD_ACCESS_MAP = METHOD_ACCESS_MAP;
48584
49258
  exports.METHOD_DEVICE_SELECTORS = METHOD_DEVICE_SELECTORS;
48585
49259
  exports.MODEL_FORMATS = MODEL_FORMATS;
@@ -48640,6 +49314,8 @@ exports.NATIVE_LEASE_BUDGET_FIELD = NATIVE_LEASE_BUDGET_FIELD;
48640
49314
  exports.NATIVE_LEASE_BUDGET_KEY = NATIVE_LEASE_BUDGET_KEY;
48641
49315
  exports.NATIVE_LEASE_HOLD_FIELD = NATIVE_LEASE_HOLD_FIELD;
48642
49316
  exports.NATIVE_LEASE_HOLD_KEY = NATIVE_LEASE_HOLD_KEY;
49317
+ exports.NATIVE_LEASE_SCENE_BUDGET_FIELD = NATIVE_LEASE_SCENE_BUDGET_FIELD;
49318
+ exports.NATIVE_LEASE_SCENE_BUDGET_KEY = NATIVE_LEASE_SCENE_BUDGET_KEY;
48643
49319
  exports.NATIVE_LEASE_SECTION_ID = NATIVE_LEASE_SECTION_ID;
48644
49320
  exports.NATIVE_LEASE_TILE_BUDGET_FIELD = NATIVE_LEASE_TILE_BUDGET_FIELD;
48645
49321
  exports.NATIVE_LEASE_TILE_BUDGET_KEY = NATIVE_LEASE_TILE_BUDGET_KEY;
@@ -48846,6 +49522,7 @@ exports.RecordingDaysSchema = RecordingDaysSchema;
48846
49522
  exports.RecordingDeviceUsageSchema = RecordingDeviceUsageSchema;
48847
49523
  exports.RecordingLocationUsageSchema = RecordingLocationUsageSchema;
48848
49524
  exports.RecordingManifestSchema = RecordingManifestSchema;
49525
+ exports.RecordingObjectTriggerClassSchema = RecordingObjectTriggerClassSchema;
48849
49526
  exports.RecordingRangeSchema = RecordingRangeSchema;
48850
49527
  exports.RecordingRebalanceInputSchema = RecordingRebalanceInputSchema;
48851
49528
  exports.RecordingRebalanceMoveSchema = RecordingRebalanceMoveSchema;
@@ -48866,6 +49543,10 @@ exports.RelocateJobStateSchema = RelocateJobStateSchema;
48866
49543
  exports.RelocateMediaInputSchema = RelocateMediaInputSchema;
48867
49544
  exports.RenderedAsSchema = RenderedAsSchema;
48868
49545
  exports.ReportMotionInputSchema = ReportMotionInputSchema;
49546
+ exports.RequestCensusGroupSchema = RequestCensusGroupSchema;
49547
+ exports.RequestCensusProcedureSchema = RequestCensusProcedureSchema;
49548
+ exports.RequestCensusSnapshotSchema = RequestCensusSnapshotSchema;
49549
+ exports.RequestCensusStatusSchema = RequestCensusStatusSchema;
48869
49550
  exports.RetrainAnnotationDraftSchema = RetrainAnnotationDraftSchema;
48870
49551
  exports.RetrainAnnotationKindSchema = RetrainAnnotationKindSchema;
48871
49552
  exports.RetrainAnnotationSchema = RetrainAnnotationSchema;
@@ -48903,6 +49584,10 @@ exports.SCENE_RESET_RECAPTURES = SCENE_RESET_RECAPTURES;
48903
49584
  exports.SCOPE_PRESETS = SCOPE_PRESETS;
48904
49585
  exports.SENSOR_FEATURES = SENSOR_FEATURES;
48905
49586
  exports.SENSOR_MAP = SENSOR_MAP;
49587
+ exports.SOURCE_CAPS = SOURCE_CAPS;
49588
+ exports.SOURCE_CAP_ACTIVE_FIELD = SOURCE_CAP_ACTIVE_FIELD;
49589
+ exports.SOURCE_CAP_CHANGED_AT_FIELD = SOURCE_CAP_CHANGED_AT_FIELD;
49590
+ exports.SOURCE_DEVICE_TYPES = SOURCE_DEVICE_TYPES;
48906
49591
  exports.SOURCE_INFO_METADATA_KEY = SOURCE_INFO_METADATA_KEY;
48907
49592
  exports.STREAM_PROFILE_META = STREAM_PROFILE_META;
48908
49593
  exports.STREAM_QUALITY_LABELS = STREAM_QUALITY_LABELS;
@@ -48934,6 +49619,7 @@ exports.ServerRollbackInfoSchema = ServerRollbackInfoSchema;
48934
49619
  exports.ServerUpdateActionResultSchema = ServerUpdateActionResultSchema;
48935
49620
  exports.ServerUpdateCheckResultSchema = ServerUpdateCheckResultSchema;
48936
49621
  exports.ServerUpdateStateSchema = ServerUpdateStateSchema;
49622
+ exports.SetLoggingSettingsInputSchema = SetLoggingSettingsInputSchema;
48937
49623
  exports.SetSiteLocationInputSchema = SetSiteLocationInputSchema;
48938
49624
  exports.SettingsPatchSchema = SettingsPatchSchema;
48939
49625
  exports.SettingsRecordSchema = SettingsRecordSchema;
@@ -49239,6 +49925,7 @@ exports.errMsg = require_err_msg.errMsg;
49239
49925
  exports.evaluateAst = evaluateAst;
49240
49926
  exports.evaluateExpressionSource = evaluateExpressionSource;
49241
49927
  exports.evaluatePoolMemory = evaluatePoolMemory;
49928
+ exports.evaluateSensorEdge = evaluateSensorEdge;
49242
49929
  exports.evaluateZoneRules = evaluateZoneRules;
49243
49930
  exports.event = require_sleep.event;
49244
49931
  exports.eventEmitterCapability = eventEmitterCapability;
@@ -49286,6 +49973,7 @@ exports.isDetectionMacroClass = isDetectionMacroClass;
49286
49973
  exports.isDeviceConfigCap = require_sleep.isDeviceConfigCap;
49287
49974
  exports.isDeviceScopedCap = require_sleep.isDeviceScopedCap;
49288
49975
  exports.isEvent = require_sleep.isEvent;
49976
+ exports.isFirstLevelMacroClass = isFirstLevelMacroClass;
49289
49977
  exports.isIsolatedBuiltin = isIsolatedBuiltin;
49290
49978
  exports.isNode = isNode;
49291
49979
  exports.isObjectInput = isObjectInput;
@@ -49294,6 +49982,7 @@ exports.isRestoredCap = isRestoredCap;
49294
49982
  exports.isSameAddonId = isSameAddonId;
49295
49983
  exports.isScheduleActive = isScheduleActive;
49296
49984
  exports.isSoftwareDecode = require_canonical_hash.isSoftwareDecode;
49985
+ exports.isSourceCap = isSourceCap;
49297
49986
  exports.isSystemDelivery = isSystemDelivery;
49298
49987
  exports.isVoidInput = isVoidInput;
49299
49988
  exports.jobKindSchema = jobKindSchema;
@@ -49447,6 +50136,8 @@ exports.setByPath = setByPath;
49447
50136
  exports.settingsStoreCapability = settingsStoreCapability;
49448
50137
  exports.sleep = require_sleep.sleep;
49449
50138
  exports.sleepCancellable = require_sleep.sleepCancellable;
50139
+ exports.sliceActiveValue = sliceActiveValue;
50140
+ exports.sliceChangedAt = sliceChangedAt;
49450
50141
  exports.smokeCapability = smokeCapability;
49451
50142
  exports.smtpProviderCapability = smtpProviderCapability;
49452
50143
  exports.snapshotCapability = snapshotCapability;