@camstack/addon-provider-hikvision 1.2.39 → 1.2.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +512 -45
  2. package/dist/addon.mjs +512 -45
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7464,6 +7464,111 @@ var CameraSwitchGroupSchema = object({
7464
7464
  fetchedAt: number()
7465
7465
  });
7466
7466
  /**
7467
+ * Per-component log CHANNELS — the gate a hot path consults, and the registry
7468
+ * an addon declares its channels in.
7469
+ *
7470
+ * ## Two axes, deliberately separated
7471
+ *
7472
+ * - **DECLARATION** — which channels exist. Only the addon knows:
7473
+ * `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
7474
+ * baichuan/handshake. A hand-wired central list rots at the first addition,
7475
+ * and rots silently. So a channel is declared where it is consulted, and the
7476
+ * `log-channels` capability enumerates the declarations.
7477
+ * - **VALUE** — at which level, for which scope, until when. That stays ONE
7478
+ * thing: the logging settings document on the `system` cap. Two authorities
7479
+ * over the values is the exact defect
7480
+ * `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
7481
+ * remove; re-introducing it from the cure side would be grotesque.
7482
+ *
7483
+ * Nothing in this file reads a clock, an env var or a store. The registry is
7484
+ * a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
7485
+ * the hot path with a value somebody actually read, and by
7486
+ * {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
7487
+ * never reaches here, so it can neither disarm an armed channel nor arm a
7488
+ * disarmed one (D49).
7489
+ *
7490
+ * ## The canonical call shape
7491
+ *
7492
+ * ```ts
7493
+ * if (CH_RTP.on && CH_RTP.wants(deviceId)) {
7494
+ * CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
7495
+ * }
7496
+ * ```
7497
+ *
7498
+ * `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
7499
+ * read. Disarmed, a call site costs one load and one branch, and the `extras`
7500
+ * object literal is never constructed because it lives inside the branch. It
7501
+ * is the same shape already proven in production at `stream-broker.ts:1650`,
7502
+ * and the same discipline `LoggingGate.allowsDestination` uses for the
7503
+ * destination floor (measured at 1.93 ns/call when off).
7504
+ *
7505
+ * ## Why a channel emits at `info`
7506
+ *
7507
+ * `loki-logging.addon.ts` pins the destination default at `info` and
7508
+ * `loki-destination.ts` drops everything below it, so a line emitted at
7509
+ * `debug` never reaches Loki and the hub's in-memory ring only holds ~35
7510
+ * minutes. A diagnostic that cannot be read an hour later is worse than no
7511
+ * diagnostic, because it looks done. {@link LogChannelGate.log} therefore
7512
+ * emits at the channel's declared level, whose schema floor is `info`.
7513
+ */
7514
+ /**
7515
+ * The level a channel writes at once armed.
7516
+ *
7517
+ * `debug` is absent ON PURPOSE and not by omission: below `info` the line does
7518
+ * not leave the process for Loki, and the whole point of arming a channel is
7519
+ * to read it later.
7520
+ */
7521
+ var LogChannelLevelSchema = _enum([
7522
+ "info",
7523
+ "warn",
7524
+ "error"
7525
+ ]);
7526
+ /**
7527
+ * What an addon declares about one channel. No value, no state — a
7528
+ * declaration is inert.
7529
+ */
7530
+ var LogChannelDescriptorSchema = object({
7531
+ /**
7532
+ * Dotted `area.thing`, unique across the workspace. `area` is conventionally
7533
+ * the addon's short name so an operator reading a channel list can tell who
7534
+ * owns it without a second lookup.
7535
+ */
7536
+ name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
7537
+ /** One sentence: what the operator will SEE after arming it. */
7538
+ description: string().min(1),
7539
+ /** The level its lines are emitted at. Never below `info`. */
7540
+ defaultLevel: LogChannelLevelSchema,
7541
+ /**
7542
+ * Whether this channel can be narrowed to a camera.
7543
+ *
7544
+ * `true` is a PROMISE with two halves, and both must hold: the gate is
7545
+ * consulted with the numeric device id, AND every line the channel admits
7546
+ * carries `tags: { deviceId }` with that same numeric id. The second half is
7547
+ * what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
7548
+ * keeps `deviceId` out of the stream labels for cardinality, so the tag in
7549
+ * the body is the only way to filter.
7550
+ *
7551
+ * A channel whose lines carry the device only in `meta` (or not at all) is
7552
+ * declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
7553
+ * the operator narrows to one camera, sees nothing, and concludes the code
7554
+ * path was never taken.
7555
+ */
7556
+ perDevice: boolean()
7557
+ });
7558
+ /**
7559
+ * An armed window over one channel, as the document hands it to a mirror.
7560
+ *
7561
+ * A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
7562
+ * expires by itself, which is the one failure a boolean cannot avoid.
7563
+ */
7564
+ var LogChannelWindowSchema = object({
7565
+ channel: string().min(1),
7566
+ /** Epoch ms the window closes at. */
7567
+ armedUntilMs: number(),
7568
+ /** `null` = every camera. A non-empty list narrows to those numeric ids. */
7569
+ deviceIds: array(number().int()).readonly().nullable()
7570
+ });
7571
+ /**
7467
7572
  * Ops-log — the durable, append-only operations audit shared by the
7468
7573
  * recordings and events management surfaces.
7469
7574
  *
@@ -11271,6 +11376,35 @@ var MutationFilterSchema = object({
11271
11376
  whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
11272
11377
  whereNot: record(string(), unknown()).optional()
11273
11378
  });
11379
+ /**
11380
+ * One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
11381
+ *
11382
+ * `as` names the slot in the result, so the SAME column may be asked twice with
11383
+ * two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
11384
+ * a `Record<column, op>` shape could not express.
11385
+ */
11386
+ var AggregateFieldSchema = object({
11387
+ /** Result key. */
11388
+ as: string().min(1),
11389
+ /** Column to aggregate. Must be a real column of a declared collection. */
11390
+ field: string().min(1),
11391
+ op: _enum([
11392
+ "sum",
11393
+ "min",
11394
+ "max"
11395
+ ])
11396
+ });
11397
+ /**
11398
+ * `COUNT(*)` plus one number per requested field.
11399
+ *
11400
+ * `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
11401
+ * that really is 0 are different facts, and an accounting caller that renders
11402
+ * "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
11403
+ */
11404
+ var AggregateResultSchema = object({
11405
+ count: number().int(),
11406
+ values: record(string(), number().nullable())
11407
+ });
11274
11408
  /** A single stored record: `{ id, data }`. */
11275
11409
  var SettingsRecordSchema = object({
11276
11410
  id: string(),
@@ -11355,6 +11489,11 @@ method(object({
11355
11489
  collection: string(),
11356
11490
  filter: QueryFilterSchema.optional()
11357
11491
  }), number()), method(object({
11492
+ namespace: string().optional(),
11493
+ collection: string(),
11494
+ fields: array(AggregateFieldSchema).readonly(),
11495
+ filter: QueryFilterSchema.optional()
11496
+ }), AggregateResultSchema), method(object({
11358
11497
  namespace: string().optional(),
11359
11498
  collection: string(),
11360
11499
  field: string(),
@@ -11471,6 +11610,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
11471
11610
  collection: string(),
11472
11611
  filter: QueryFilterSchema.optional()
11473
11612
  }), number(), { auth: "admin" }), method(object({
11613
+ namespace: string().optional(),
11614
+ collection: string(),
11615
+ fields: array(AggregateFieldSchema).readonly(),
11616
+ filter: QueryFilterSchema.optional()
11617
+ }), AggregateResultSchema, { auth: "admin" }), method(object({
11474
11618
  namespace: string().optional(),
11475
11619
  collection: string(),
11476
11620
  field: string(),
@@ -12194,24 +12338,6 @@ var deviceProviderCapability = {
12194
12338
  })
12195
12339
  }
12196
12340
  };
12197
- /**
12198
- * Device Manager capability — hub-side singleton that unifies device persistence,
12199
- * live registry access, and all management operations into a single tRPC surface.
12200
- *
12201
- * Replaces:
12202
- * - `device-persistence` capability (persistence methods absorbed here)
12203
- * - `device-management.router.ts` (deleted in Phase 2)
12204
- * - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
12205
- *
12206
- * All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
12207
- * fork into separate processes but never run on remote cluster agents. Therefore:
12208
- * - No nodeId routing needed — this is a pure hub singleton.
12209
- * - The hub's DeviceRegistry is the single source of truth for all live devices.
12210
- * - No shadow registry or cross-node aggregation required.
12211
- *
12212
- * Forked workers register devices back to the hub via `ctx.devices`
12213
- * (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
12214
- */
12215
12341
  /** One child-placement directive on a container's `childLayout`. Structurally
12216
12342
  * identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
12217
12343
  * shape for the same field. The child is identified by its re-sync-stable
@@ -12580,7 +12706,7 @@ method(object({
12580
12706
  * it answers today and the caller filters as it already does.
12581
12707
  */
12582
12708
  deviceIds: array(number()).optional()
12583
- }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
12709
+ }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ parentDeviceIds: array(number()).max(256) }), record(string(), array(DeviceInfoSchema))), method(object({ deviceId: number() }), object({
12584
12710
  mode: LinkedDevicesModeSchema,
12585
12711
  devices: array(LinkedDeviceSchema)
12586
12712
  })), method(object({ deviceIds: array(number()) }), array(LinkedDevicesForDeviceSchema)), method(object({ deviceId: number() }), array(StreamSourceEntrySchema$1)), method(object({ deviceId: number() }), array(ConfigEntrySchema)), method(object({ deviceId: number() }), ConfigUISchemaOutput), method(object({
@@ -13304,6 +13430,59 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13304
13430
  kind: "mutation",
13305
13431
  auth: "admin"
13306
13432
  });
13433
+ /**
13434
+ * `log-channels` — the capability an addon DECLARES its diagnostic channels
13435
+ * through. It stores nothing.
13436
+ *
13437
+ * ## Why a capability at all, and why this shape
13438
+ *
13439
+ * Which channels exist is knowledge only the addon has: `stream-broker` knows
13440
+ * webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
13441
+ * maintained by hand rots at the first addition and rots INVISIBLY — nothing
13442
+ * fails, an operator just never sees the channel somebody added. So the list
13443
+ * is assembled from declarations at runtime.
13444
+ *
13445
+ * The shape is copied from `log-destination.cap.ts`, which already does
13446
+ * exactly this job: `mode: 'collection'`, `internal: true`,
13447
+ * `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
13448
+ * `addons.listCapabilityProviders` still enumerates it, and the hub's
13449
+ * `CapabilityRegistry` still holds an RPC proxy per provider so a forked
13450
+ * runner's declarations reach hub-main over the transport that already exists.
13451
+ * No new UDS message, no second registry.
13452
+ *
13453
+ * ## What it deliberately does NOT own
13454
+ *
13455
+ * The VALUES — which channel is armed, for which cameras, until when — live in
13456
+ * ONE place: the logging settings document on the `system` cap
13457
+ * (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
13458
+ * value is the defect the plan behind this work exists to remove, and
13459
+ * `setRequestCensus` was retired (D245) rather than allowed to be a second
13460
+ * one. {@link logChannelsCapability} therefore has no getter for a level, no
13461
+ * setter for a window and no persistence of any kind.
13462
+ *
13463
+ * ## Why `apply` is here even so
13464
+ *
13465
+ * The gate lives in the addon's PROCESS; the document lives in hub-main. Some
13466
+ * seam has to carry the value from the authority to the mirror, and a channel
13467
+ * that cannot be reached is precisely the dead knob this whole slice exists to
13468
+ * make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
13469
+ * `apply` is that seam and nothing more: it writes an in-memory mirror, it
13470
+ * persists nothing, it is never the source of a value, and it is called only
13471
+ * with a set the hub actually read (D49 — a read that fails does not call it
13472
+ * at all, so no channel is silently disarmed by a bad read).
13473
+ */
13474
+ /** What `apply` reports back — enough to log, not enough to be a second state. */
13475
+ var LogChannelApplyResultSchema = object({
13476
+ /** How many declared channels are armed in this process after the call. */
13477
+ armed: number().int().min(0),
13478
+ /**
13479
+ * Names the document armed that this process does not declare. Reported
13480
+ * rather than swallowed: a name here is either a typo or an addon that has
13481
+ * not booted, and both deserve a line instead of silence.
13482
+ */
13483
+ unknown: array(string()).readonly()
13484
+ });
13485
+ method(_void(), array(LogChannelDescriptorSchema).readonly()), method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" });
13307
13486
  var LogLevelSchema = _enum([
13308
13487
  "debug",
13309
13488
  "info",
@@ -29021,17 +29200,60 @@ var SetSiteLocationInputSchema = object({
29021
29200
  longitude: number().min(-180).max(180)
29022
29201
  }).nullable();
29023
29202
  /**
29024
- * One `(procedure, user-agent, ip, principal)` tuple of the HTTP request
29203
+ * The TRANSPORT a call arrived on.
29204
+ *
29205
+ * Every counted call carries exactly one of these, and `unknown` is a PLANE
29206
+ * rather than a gap: a plane that cannot attribute a call declares it here, so
29207
+ * the call lands in a named bucket instead of vanishing. `planes` summing to
29208
+ * `procedureCalls` is what makes "the sum of the planes explains the total"
29209
+ * checkable rather than asserted.
29210
+ *
29211
+ * - `http` — the Fastify tRPC plugin (`/trpc/*`), one context per request.
29212
+ * - `ws` — `applyWSSHandler`, counted per OPERATION rather than per
29213
+ * connection; the viewer talks to the hub over `wsLink`
29214
+ * exclusively, so this is the plane the HTTP census could not see.
29215
+ * - `mesh` — the in-process `$core-caps` bridge (`createCaller`), which
29216
+ * never touches a socket and therefore never touched a census.
29217
+ * - `unknown` — counted, plane undecidable. No hook produces it today, and
29218
+ * that is exactly what its `0` asserts: every plane the hub has can name
29219
+ * itself. It is an output bucket, never a knob — a call that arrives on a
29220
+ * plane nobody instrumented lands here instead of vanishing from the total.
29221
+ */
29222
+ var TransportPlaneSchema = _enum([
29223
+ "http",
29224
+ "ws",
29225
+ "mesh",
29226
+ "unknown"
29227
+ ]);
29228
+ /**
29229
+ * Calls per plane. Every key is always present, `0` included — an absent plane
29230
+ * reads as "not instrumented", which is the one thing this census must never
29231
+ * make an operator wonder about.
29232
+ */
29233
+ var TransportPlaneCountsSchema = object({
29234
+ http: number(),
29235
+ ws: number(),
29236
+ mesh: number(),
29237
+ unknown: number()
29238
+ });
29239
+ /**
29240
+ * One `(plane, procedure, user-agent, ip, principal)` tuple of the transport
29025
29241
  * census. `principal` is the DERIVED identity (`apocaliss92 (admin)`,
29026
29242
  * `scoped:1a2b3c4d (scoped-token)`, `anonymous`) that the tRPC error log
29027
29243
  * already prints - never a token, never an `Authorization` header.
29244
+ *
29245
+ * `subscriptions` is counted APART from `calls`: a subscription is opened once
29246
+ * and lives for hours, so folding it into a call count makes one long-lived
29247
+ * stream look like a storm.
29028
29248
  */
29029
29249
  var RequestCensusGroupSchema = object({
29250
+ plane: TransportPlaneSchema,
29030
29251
  procedure: string(),
29031
29252
  userAgent: string(),
29032
29253
  ip: string(),
29033
29254
  principal: string(),
29034
29255
  calls: number(),
29256
+ subscriptions: number(),
29035
29257
  perMin: number()
29036
29258
  });
29037
29259
  /**
@@ -29044,6 +29266,14 @@ var RequestCensusGroupSchema = object({
29044
29266
  var RequestCensusProcedureSchema = object({
29045
29267
  procedure: string(),
29046
29268
  calls: number(),
29269
+ /**
29270
+ * The same total, split by transport. THIS is the row that answers the
29271
+ * question the census exists for: one look at `deviceManager.listAll` says
29272
+ * which plane carried the 4 960, without joining two log lines by eye.
29273
+ */
29274
+ planes: TransportPlaneCountsSchema,
29275
+ /** Subscription STARTS on this procedure. Never folded into `calls`. */
29276
+ subscriptions: number(),
29047
29277
  perMin: number()
29048
29278
  });
29049
29279
  /**
@@ -29071,14 +29301,45 @@ var RequestCensusStatusSchema = object({
29071
29301
  */
29072
29302
  procedureCalls: number(),
29073
29303
  /**
29304
+ * `procedureCalls` split by transport. The four keys sum to
29305
+ * `procedureCalls` by construction - {@link RequestCensusSnapshotSchema}'s
29306
+ * `planesExplainTotal` is that identity, checked rather than assumed.
29307
+ */
29308
+ planes: TransportPlaneCountsSchema,
29309
+ /**
29310
+ * True iff `planes` sums to `procedureCalls`. False means a call was counted
29311
+ * on no plane at all - which is a RESULT (a plane is missing from the
29312
+ * instrument), not a failure, and it has to be visible to be read as one.
29313
+ */
29314
+ planesExplainTotal: boolean(),
29315
+ /**
29074
29316
  * tRPC WebSocket connections opened during the window. NOT calls - the WS
29075
- * transport resolves one context per connection - but the number that says
29076
- * whether a plane this census cannot see was busy while HTTP was quiet.
29317
+ * adapter resolves one context per connection - kept because a plane's call
29318
+ * count of zero against 37 open connections says something different from a
29319
+ * plane with no connections at all.
29077
29320
  */
29078
29321
  wsConnections: number(),
29322
+ /**
29323
+ * Client frames the WS plane looked at. `wsMessages` far above
29324
+ * `planes.ws + subscriptions` means most traffic is not operations
29325
+ * (keepalives, connection params) - which is itself an answer.
29326
+ */
29327
+ wsMessages: number(),
29328
+ /**
29329
+ * Subscription STARTS across every plane, excluded from `procedureCalls` on
29330
+ * purpose: one live-events stream opened at boot and held for six hours is
29331
+ * one subscription, and counting it as a call would let a quiet plane
29332
+ * masquerade as the storm.
29333
+ */
29334
+ subscriptions: number(),
29335
+ /** `subscription.stop` frames. Starts minus stops is what is still open. */
29336
+ subscriptionStops: number(),
29079
29337
  distinctGroups: number(),
29080
- /** Calls counted in the totals whose group attribution was shed at the
29081
- * cardinality bound. */
29338
+ /**
29339
+ * Operations counted in the totals whose CALLER attribution was shed at the
29340
+ * cardinality bound. Unrelated to the `unknown` PLANE: these calls know
29341
+ * which transport they arrived on, they just lost their group row.
29342
+ */
29082
29343
  unattributedCalls: number(),
29083
29344
  procedures: array(RequestCensusProcedureSchema).readonly(),
29084
29345
  groups: array(RequestCensusGroupSchema).readonly()
@@ -29101,10 +29362,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
29101
29362
  * The layers of the level hierarchy, general → specific. The most specific
29102
29363
  * layer that carries an explicit value wins.
29103
29364
  *
29104
- * `component` is DECLARED and not yet resolvable: the per-component channels
29105
- * are a later slice of the same plan, and a `levelSource` enum that has to
29106
- * grow later would force every consumer of this document to change with it.
29107
- * Nothing returns `component` today.
29365
+ * `component` became RESOLVABLE on 2026-08-27: a component is a declared log
29366
+ * CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
29367
+ * `scopeComponent`. It was declared-but-dark in the first slice precisely so
29368
+ * that turning it on would not force every consumer of this document to widen
29369
+ * a `levelSource` enum — which is what has now not happened.
29108
29370
  */
29109
29371
  var LoggingScopeKindSchema = _enum([
29110
29372
  "cluster",
@@ -29131,6 +29393,14 @@ var LoggingLevelLayerSchema = object({
29131
29393
  scope: LoggingScopeKindSchema,
29132
29394
  /** The node this layer speaks for; `null` on the cluster layer. */
29133
29395
  nodeId: string().nullable(),
29396
+ /**
29397
+ * The declared channel this layer speaks for; `null` on every layer but
29398
+ * `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
29399
+ * by design — the convention this repo settled on is one orchestrator-wide
29400
+ * setting, never per node (D52) — so a component layer that carried a node
29401
+ * would invite a per-node copy of a value that has no per-node meaning.
29402
+ */
29403
+ component: string().nullable(),
29134
29404
  /** Explicitly set here, or `null` when this layer inherits. */
29135
29405
  level: LogLevelSchema$1.nullable()
29136
29406
  });
@@ -29172,6 +29442,49 @@ var DiagnosticWindowPatchSchema = object({
29172
29442
  reportEveryMs: number().int().positive().optional()
29173
29443
  });
29174
29444
  /**
29445
+ * A channel ARMED, as the document reports it.
29446
+ *
29447
+ * `armMs` is not echoed back: what an operator needs to see is the deadline
29448
+ * and the time left, because a diagnostic left running is itself an incident
29449
+ * and "armed for 10 minutes" said an hour ago is not an answer.
29450
+ */
29451
+ var LogChannelWindowStateSchema = object({
29452
+ channel: string(),
29453
+ armed: boolean(),
29454
+ /** Epoch ms the window closes at. 0 when disarmed. */
29455
+ armedUntilMs: number(),
29456
+ /** Ms left before it expires on its own. 0 when disarmed. */
29457
+ remainingMs: number(),
29458
+ /**
29459
+ * The cameras it is narrowed to, or `null` for every camera.
29460
+ *
29461
+ * A channel declared `perDevice: false` can only ever report `null` here:
29462
+ * its lines do not carry `tags: { deviceId }`, so narrowing them would
29463
+ * produce a filter that silently matches nothing. The server REFUSES such a
29464
+ * patch rather than quietly widening it — ignoring the request would teach
29465
+ * the operator that per-camera filtering works on that channel when it does
29466
+ * not.
29467
+ */
29468
+ deviceIds: array(number().int()).readonly().nullable()
29469
+ });
29470
+ /**
29471
+ * `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
29472
+ * for the same reason: a channel is a window with a deadline, never a switch.
29473
+ */
29474
+ var LogChannelWindowPatchSchema = object({
29475
+ channel: string().min(1),
29476
+ armMs: number().int().min(0),
29477
+ /**
29478
+ * Narrow to these numeric device ids. Absent or `null` = every camera.
29479
+ *
29480
+ * Numeric because the repo's own rule makes it possible: every log line
29481
+ * about a device carries `tags: { deviceId }` with the numeric id. That rule
29482
+ * was paid for with a 22% thumbnail gap and a 3-hour media blackout both
29483
+ * diagnosed by hand, and this is the first thing that collects on it.
29484
+ */
29485
+ deviceIds: array(number().int()).readonly().nullable().optional()
29486
+ });
29487
+ /**
29175
29488
  * A PATCH, and patches MERGE.
29176
29489
  *
29177
29490
  * A field absent from the patch is left exactly as it was — arming a
@@ -29190,7 +29503,14 @@ var LoggingSettingsPatchSchema = object({
29190
29503
  * Only the diagnostics NAMED here change. An armed window that is not listed
29191
29504
  * keeps running — a patch is never a full replacement.
29192
29505
  */
29193
- diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
29506
+ diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
29507
+ /**
29508
+ * Only the channels NAMED here change. An armed channel that is not listed
29509
+ * keeps running — same rule as `diagnostics`, because a patch that silently
29510
+ * disarmed the channels it did not mention would make the Levels page and
29511
+ * the Diagnostics page fight over the same value.
29512
+ */
29513
+ channels: array(LogChannelWindowPatchSchema).readonly().optional()
29194
29514
  });
29195
29515
  /**
29196
29516
  * Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
@@ -29203,9 +29523,22 @@ var LoggingSettingsPatchSchema = object({
29203
29523
  * authority over the whole hierarchy and answers for every layer, so the
29204
29524
  * layer selector needs a name the transport does not already own.
29205
29525
  */
29206
- var GetLoggingSettingsInputSchema = object({ scopeNodeId: string().optional() });
29526
+ var GetLoggingSettingsInputSchema = object({
29527
+ scopeNodeId: string().optional(),
29528
+ /**
29529
+ * The declared CHANNEL this document is addressed at, when the caller wants
29530
+ * the `component` layer. Absent = the node/cluster hierarchy only.
29531
+ *
29532
+ * Naming it separately rather than overloading `scopeNodeId` keeps the two
29533
+ * axes from collapsing: a component level is cluster-wide, a node level is
29534
+ * not, and one selector for both would make "which of these two did I just
29535
+ * set" unanswerable — the exact ambiguity `explicit` exists to remove.
29536
+ */
29537
+ scopeComponent: string().optional()
29538
+ });
29207
29539
  var SetLoggingSettingsInputSchema = object({
29208
29540
  scopeNodeId: string().optional(),
29541
+ scopeComponent: string().optional(),
29209
29542
  patch: LoggingSettingsPatchSchema
29210
29543
  });
29211
29544
  /**
@@ -29220,9 +29553,20 @@ var SetLoggingSettingsInputSchema = object({
29220
29553
  var LoggingSettingsStateSchema = object({
29221
29554
  /** The layer this document was read at. `null` = the cluster layer. */
29222
29555
  scopeNodeId: string().nullable(),
29556
+ /** The channel this document was read at. `null` = no component layer. */
29557
+ scopeComponent: string().nullable(),
29223
29558
  effective: LoggingEffectiveSchema,
29224
29559
  explicit: LoggingExplicitSchema,
29225
29560
  activeWindows: array(DiagnosticWindowSchema).readonly(),
29561
+ /**
29562
+ * Every channel the cluster's addons DECLARE, gathered from the
29563
+ * `log-channels` providers. Not stored anywhere: assembled per read, so a
29564
+ * channel added by a redeployed addon appears without anybody editing a
29565
+ * list, and a channel whose addon is gone stops being offered.
29566
+ */
29567
+ channels: array(LogChannelDescriptorSchema).readonly(),
29568
+ /** The channels ARMED right now, each with its deadline. */
29569
+ activeChannels: array(LogChannelWindowStateSchema).readonly(),
29226
29570
  persisted: boolean()
29227
29571
  });
29228
29572
  method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), method(_void(), FeatureManifestSchema), method(_void(), array(NetworkAddressSchema).readonly()), method(_void(), unknown().nullable(), { auth: "admin" }), method(record(string(), unknown()), _null(), {
@@ -32440,6 +32784,12 @@ Object.freeze({
32440
32784
  addonId: null,
32441
32785
  access: "view"
32442
32786
  },
32787
+ "dataStoreProvider.aggregate": {
32788
+ capName: "data-store-provider",
32789
+ capScope: "system",
32790
+ addonId: null,
32791
+ access: "view"
32792
+ },
32443
32793
  "dataStoreProvider.count": {
32444
32794
  capName: "data-store-provider",
32445
32795
  capScope: "system",
@@ -32854,6 +33204,12 @@ Object.freeze({
32854
33204
  addonId: null,
32855
33205
  access: "view"
32856
33206
  },
33207
+ "deviceManager.getChildrenBatch": {
33208
+ capName: "device-manager",
33209
+ capScope: "system",
33210
+ addonId: null,
33211
+ access: "view"
33212
+ },
32857
33213
  "deviceManager.getConfigSchema": {
32858
33214
  capName: "device-manager",
32859
33215
  capScope: "system",
@@ -33904,6 +34260,18 @@ Object.freeze({
33904
34260
  addonId: null,
33905
34261
  access: "create"
33906
34262
  },
34263
+ "logChannels.apply": {
34264
+ capName: "log-channels",
34265
+ capScope: "system",
34266
+ addonId: null,
34267
+ access: "create"
34268
+ },
34269
+ "logChannels.list": {
34270
+ capName: "log-channels",
34271
+ capScope: "system",
34272
+ addonId: null,
34273
+ access: "view"
34274
+ },
33907
34275
  "logDestination.query": {
33908
34276
  capName: "log-destination",
33909
34277
  capScope: "system",
@@ -36058,6 +36426,12 @@ Object.freeze({
36058
36426
  addonId: null,
36059
36427
  access: "create"
36060
36428
  },
36429
+ "settingsStore.aggregate": {
36430
+ capName: "settings-store",
36431
+ capScope: "system",
36432
+ addonId: null,
36433
+ access: "view"
36434
+ },
36061
36435
  "settingsStore.count": {
36062
36436
  capName: "settings-store",
36063
36437
  capScope: "system",
@@ -37637,6 +38011,11 @@ Object.freeze({
37637
38011
  form: "single",
37638
38012
  optional: false
37639
38013
  }],
38014
+ "deviceManager.getChildrenBatch": [{
38015
+ name: "parentDeviceIds",
38016
+ form: "array",
38017
+ optional: false
38018
+ }],
37640
38019
  "deviceManager.getConfigSchema": [{
37641
38020
  name: "deviceId",
37642
38021
  form: "single",
@@ -40103,6 +40482,38 @@ function createAccessoryDevice(kind, ctx, parent) {
40103
40482
  default: throw new Error(`Hikvision provider does not implement accessory kind "${String(kind)}"`);
40104
40483
  }
40105
40484
  }
40485
+ function createAlarmTypeTally(deps) {
40486
+ const intervalMs = deps.intervalMs ?? 3e5;
40487
+ const lastLoggedAt = /* @__PURE__ */ new Map();
40488
+ const suppressed = /* @__PURE__ */ new Map();
40489
+ const note = (type, state, reason) => {
40490
+ const logger = deps.logger;
40491
+ if (!logger) return;
40492
+ const key = `${type}/${state ?? "none"}`;
40493
+ const now = Date.now();
40494
+ const last = lastLoggedAt.get(key);
40495
+ if (last !== void 0 && now - last < intervalMs) {
40496
+ suppressed.set(key, (suppressed.get(key) ?? 0) + 1);
40497
+ return;
40498
+ }
40499
+ const count = (suppressed.get(key) ?? 0) + 1;
40500
+ suppressed.set(key, 0);
40501
+ lastLoggedAt.set(key, now);
40502
+ const extras = {
40503
+ ...deps.deviceId === null ? {} : { tags: { deviceId: deps.deviceId } },
40504
+ meta: {
40505
+ type,
40506
+ state,
40507
+ count,
40508
+ ...last === void 0 ? { first: true } : { windowMs: now - last },
40509
+ ...reason === void 0 ? {} : { reason }
40510
+ }
40511
+ };
40512
+ if (deps.level === "debug") logger.debug(deps.message, extras);
40513
+ else logger.info(deps.message, extras);
40514
+ };
40515
+ return { note };
40516
+ }
40106
40517
  //#endregion
40107
40518
  //#region src/hikvision-channel-fps.ts
40108
40519
  /**
@@ -40188,6 +40599,24 @@ function buildAuthHeader(input) {
40188
40599
  return `Digest ${parts.join(", ")}`;
40189
40600
  }
40190
40601
  //#endregion
40602
+ //#region src/hikvision-alarm-ignore.ts
40603
+ var IGNORED_ALARMS = new Map([["videoloss", {
40604
+ states: ["inactive"],
40605
+ reason: "alertStream keep-alive: \"no video loss\" repeated every ~5s by firmware whether or not anything happened. It carries no edge and no state we do not already hold — the stream being alive is already tracked by the idle watchdog, and camera liveness by markOnline(). Measured at 83 200 events / 12 h (116/min) across the fleet, all byte-identical."
40606
+ }]]);
40607
+ /**
40608
+ * The reason this `(type, state)` is deliberately not acted on, or `null` when
40609
+ * the event must be delivered.
40610
+ *
40611
+ * Both arguments are expected lowercased, matching `eventType` / `eventState`
40612
+ * as normalised by the alert parser.
40613
+ */
40614
+ function hikvisionIgnoredAlarmReason(type, state) {
40615
+ const policy = IGNORED_ALARMS.get(type);
40616
+ if (!policy) return null;
40617
+ return policy.states.includes(state) ? policy.reason : null;
40618
+ }
40619
+ //#endregion
40191
40620
  //#region src/hikvision-snapshot-channel.ts
40192
40621
  /**
40193
40622
  * Hikvision encodes a channel id as `{cameraNumber}{streamSlot}`; slot `1` is
@@ -42274,6 +42703,13 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
42274
42703
  const retainBytes = options.retainBytes ?? 65536;
42275
42704
  const unparsedWarnBytes = options.unparsedWarnBytes ?? 32768;
42276
42705
  const diagnostics = createAlarmDiagnostics(options.logger ?? null, options.deviceId ?? null, options.diagnosticIntervalMs ?? 6e4);
42706
+ const ignoredTally = createAlarmTypeTally({
42707
+ logger: options.logger ?? null,
42708
+ deviceId: options.deviceId ?? null,
42709
+ message: "hikvision alarm stream: ignored alarm type (declared policy)",
42710
+ level: "debug",
42711
+ ...options.ignoredTallyIntervalMs === void 0 ? {} : { intervalMs: options.ignoredTallyIntervalMs }
42712
+ });
42277
42713
  const reader = stream.getReader();
42278
42714
  let activeBoundary = declaredBoundary;
42279
42715
  let activeDashBoundary = `--${activeBoundary}`;
@@ -42316,8 +42752,8 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
42316
42752
  });
42317
42753
  return;
42318
42754
  }
42319
- const ev = parseAlertXml(bodyText);
42320
- if (!ev) {
42755
+ const peeked = peekAlertTypeState(bodyText);
42756
+ if (!peeked) {
42321
42757
  diagnostics.report("alert-xml-without-event-type", "hikvision alarm stream: alert part dropped — no <eventType> tag", {
42322
42758
  contentType,
42323
42759
  bytes: block.byteLength,
@@ -42325,7 +42761,12 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
42325
42761
  });
42326
42762
  return;
42327
42763
  }
42328
- handlers.onEvent(ev);
42764
+ const ignoredReason = hikvisionIgnoredAlarmReason(peeked.type, peeked.state);
42765
+ if (ignoredReason !== null) {
42766
+ ignoredTally.note(peeked.type, peeked.state, ignoredReason);
42767
+ return;
42768
+ }
42769
+ handlers.onEvent(parseAlertXml(bodyText, peeked));
42329
42770
  };
42330
42771
  let idleTimer = null;
42331
42772
  const armIdle = () => {
@@ -42510,10 +42951,22 @@ function isHikvisionMotionAlarmType(type) {
42510
42951
  function isHikvisionSmartAlarmType(type) {
42511
42952
  return type !== "vmd" && type !== "motiondetection" && isHikvisionMotionAlarmType(type);
42512
42953
  }
42513
- function parseAlertXml(xml) {
42954
+ function peekAlertTypeState(xml) {
42514
42955
  const type = extractTag(xml, "eventType");
42515
42956
  if (!type) return null;
42516
42957
  const state = extractTag(xml, "eventState");
42958
+ return {
42959
+ type: type.toLowerCase(),
42960
+ state: state?.toLowerCase() ?? null
42961
+ };
42962
+ }
42963
+ /**
42964
+ * Build the full event. Takes the already-peeked `(type, state)` so the two
42965
+ * tags are extracted exactly once, and so this function has no failure mode
42966
+ * left: `peekAlertTypeState` returning non-null IS the precondition, and the
42967
+ * caller has already reported the only way it can fail.
42968
+ */
42969
+ function parseAlertXml(xml, peeked) {
42517
42970
  const channelId = extractTag(xml, "dynChannelID") ?? extractTag(xml, "channelID");
42518
42971
  const description = extractTag(xml, "eventDescription") ?? extractTag(xml, "description");
42519
42972
  const aiClass = extractTag(xml, "targetType") ?? extractTag(xml, "className");
@@ -42525,8 +42978,8 @@ function parseAlertXml(xml) {
42525
42978
  })();
42526
42979
  return {
42527
42980
  observedAt: Date.now(),
42528
- type: type.toLowerCase(),
42529
- state: state?.toLowerCase() ?? null,
42981
+ type: peeked.type,
42982
+ state: peeked.state,
42530
42983
  channelId,
42531
42984
  aiClass,
42532
42985
  description,
@@ -44054,6 +44507,25 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
44054
44507
  alarmReconnectAttempts = 0;
44055
44508
  /** Pending alarm-reconnect timer. */
44056
44509
  alarmReconnectTimer = null;
44510
+ /**
44511
+ * Counting reporter for alarm types the camera receives but does not model.
44512
+ *
44513
+ * Built lazily so it can capture `this.id` / `this.ctx.logger` — every line
44514
+ * it emits carries the numeric `deviceId`. It keeps the historical message
44515
+ * text (`hikvision: unhandled alarm event`) so existing Loki queries keep
44516
+ * working; what changed is that the line now carries `meta.count` and arrives
44517
+ * once per window instead of once per event.
44518
+ */
44519
+ unhandledAlarmsTally = null;
44520
+ get unhandledAlarms() {
44521
+ this.unhandledAlarmsTally ??= createAlarmTypeTally({
44522
+ logger: this.ctx.logger,
44523
+ deviceId: this.id,
44524
+ message: "hikvision: unhandled alarm event",
44525
+ level: "info"
44526
+ });
44527
+ return this.unhandledAlarmsTally;
44528
+ }
44057
44529
  /** Hysteresis: drop motion-active back to inactive after this many ms with
44058
44530
  * no fresh `VMD` event. Hikvision fires VMD every ~1s while motion is
44059
44531
  * active; missing 2 ticks signals the burst is over. */
@@ -46279,22 +46751,17 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
46279
46751
  return;
46280
46752
  }
46281
46753
  if (ev.type === "videoloss") {
46282
- this.ctx.logger.debug("hikvision: unhandled alarm event", {
46754
+ this.ctx.logger.warn("hikvision: camera reports video signal loss", {
46283
46755
  tags: { deviceId: this.id },
46284
46756
  meta: {
46285
46757
  type: ev.type,
46286
- state: ev.state
46758
+ state: ev.state,
46759
+ camStreamId
46287
46760
  }
46288
46761
  });
46289
46762
  return;
46290
46763
  }
46291
- this.ctx.logger.info("hikvision: unhandled alarm event", {
46292
- tags: { deviceId: this.id },
46293
- meta: {
46294
- type: ev.type,
46295
- state: ev.state
46296
- }
46297
- });
46764
+ this.unhandledAlarms.note(ev.type, ev.state);
46298
46765
  }
46299
46766
  resolveAlarmCamStreamId(channelId) {
46300
46767
  if (!channelId) return "native:main";