@camstack/addon-provider-hikvision 1.2.40 → 1.2.42
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/addon.js +425 -40
- package/dist/addon.mjs +425 -40
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -7463,6 +7463,111 @@ var CameraSwitchGroupSchema = object({
|
|
|
7463
7463
|
fetchedAt: number()
|
|
7464
7464
|
});
|
|
7465
7465
|
/**
|
|
7466
|
+
* Per-component log CHANNELS — the gate a hot path consults, and the registry
|
|
7467
|
+
* an addon declares its channels in.
|
|
7468
|
+
*
|
|
7469
|
+
* ## Two axes, deliberately separated
|
|
7470
|
+
*
|
|
7471
|
+
* - **DECLARATION** — which channels exist. Only the addon knows:
|
|
7472
|
+
* `stream-broker` knows webrtc/ICE/RTP, `provider-reolink` knows
|
|
7473
|
+
* baichuan/handshake. A hand-wired central list rots at the first addition,
|
|
7474
|
+
* and rots silently. So a channel is declared where it is consulted, and the
|
|
7475
|
+
* `log-channels` capability enumerates the declarations.
|
|
7476
|
+
* - **VALUE** — at which level, for which scope, until when. That stays ONE
|
|
7477
|
+
* thing: the logging settings document on the `system` cap. Two authorities
|
|
7478
|
+
* over the values is the exact defect
|
|
7479
|
+
* `docs/design/plans/2026-08-26-logging-per-componente.md` was written to
|
|
7480
|
+
* remove; re-introducing it from the cure side would be grotesque.
|
|
7481
|
+
*
|
|
7482
|
+
* Nothing in this file reads a clock, an env var or a store. The registry is
|
|
7483
|
+
* a MIRROR: it is moved only by {@link LogChannelRegistry.apply}, called off
|
|
7484
|
+
* the hot path with a value somebody actually read, and by
|
|
7485
|
+
* {@link LogChannelRegistry.tick}, called on a timer. A store read that fails
|
|
7486
|
+
* never reaches here, so it can neither disarm an armed channel nor arm a
|
|
7487
|
+
* disarmed one (D49).
|
|
7488
|
+
*
|
|
7489
|
+
* ## The canonical call shape
|
|
7490
|
+
*
|
|
7491
|
+
* ```ts
|
|
7492
|
+
* if (CH_RTP.on && CH_RTP.wants(deviceId)) {
|
|
7493
|
+
* CH_RTP.log(logger, 'rtp subscriber added', { tags: { deviceId }, meta: { ssrc } })
|
|
7494
|
+
* }
|
|
7495
|
+
* ```
|
|
7496
|
+
*
|
|
7497
|
+
* `on` is a plain boolean FIELD — never a getter — and it is the FIRST thing
|
|
7498
|
+
* read. Disarmed, a call site costs one load and one branch, and the `extras`
|
|
7499
|
+
* object literal is never constructed because it lives inside the branch. It
|
|
7500
|
+
* is the same shape already proven in production at `stream-broker.ts:1650`,
|
|
7501
|
+
* and the same discipline `LoggingGate.allowsDestination` uses for the
|
|
7502
|
+
* destination floor (measured at 1.93 ns/call when off).
|
|
7503
|
+
*
|
|
7504
|
+
* ## Why a channel emits at `info`
|
|
7505
|
+
*
|
|
7506
|
+
* `loki-logging.addon.ts` pins the destination default at `info` and
|
|
7507
|
+
* `loki-destination.ts` drops everything below it, so a line emitted at
|
|
7508
|
+
* `debug` never reaches Loki and the hub's in-memory ring only holds ~35
|
|
7509
|
+
* minutes. A diagnostic that cannot be read an hour later is worse than no
|
|
7510
|
+
* diagnostic, because it looks done. {@link LogChannelGate.log} therefore
|
|
7511
|
+
* emits at the channel's declared level, whose schema floor is `info`.
|
|
7512
|
+
*/
|
|
7513
|
+
/**
|
|
7514
|
+
* The level a channel writes at once armed.
|
|
7515
|
+
*
|
|
7516
|
+
* `debug` is absent ON PURPOSE and not by omission: below `info` the line does
|
|
7517
|
+
* not leave the process for Loki, and the whole point of arming a channel is
|
|
7518
|
+
* to read it later.
|
|
7519
|
+
*/
|
|
7520
|
+
var LogChannelLevelSchema = _enum([
|
|
7521
|
+
"info",
|
|
7522
|
+
"warn",
|
|
7523
|
+
"error"
|
|
7524
|
+
]);
|
|
7525
|
+
/**
|
|
7526
|
+
* What an addon declares about one channel. No value, no state — a
|
|
7527
|
+
* declaration is inert.
|
|
7528
|
+
*/
|
|
7529
|
+
var LogChannelDescriptorSchema = object({
|
|
7530
|
+
/**
|
|
7531
|
+
* Dotted `area.thing`, unique across the workspace. `area` is conventionally
|
|
7532
|
+
* the addon's short name so an operator reading a channel list can tell who
|
|
7533
|
+
* owns it without a second lookup.
|
|
7534
|
+
*/
|
|
7535
|
+
name: string().min(3).regex(/^[a-z0-9-]+(\.[a-z0-9-]+)+$/, "a channel name is dotted lower-kebab, e.g. area.thing"),
|
|
7536
|
+
/** One sentence: what the operator will SEE after arming it. */
|
|
7537
|
+
description: string().min(1),
|
|
7538
|
+
/** The level its lines are emitted at. Never below `info`. */
|
|
7539
|
+
defaultLevel: LogChannelLevelSchema,
|
|
7540
|
+
/**
|
|
7541
|
+
* Whether this channel can be narrowed to a camera.
|
|
7542
|
+
*
|
|
7543
|
+
* `true` is a PROMISE with two halves, and both must hold: the gate is
|
|
7544
|
+
* consulted with the numeric device id, AND every line the channel admits
|
|
7545
|
+
* carries `tags: { deviceId }` with that same numeric id. The second half is
|
|
7546
|
+
* what makes `| json | deviceId="617"` work in Loki — `loki-payload.ts`
|
|
7547
|
+
* keeps `deviceId` out of the stream labels for cardinality, so the tag in
|
|
7548
|
+
* the body is the only way to filter.
|
|
7549
|
+
*
|
|
7550
|
+
* A channel whose lines carry the device only in `meta` (or not at all) is
|
|
7551
|
+
* declared `false`. Declaring it `true` anyway would be a lie the UI repeats:
|
|
7552
|
+
* the operator narrows to one camera, sees nothing, and concludes the code
|
|
7553
|
+
* path was never taken.
|
|
7554
|
+
*/
|
|
7555
|
+
perDevice: boolean()
|
|
7556
|
+
});
|
|
7557
|
+
/**
|
|
7558
|
+
* An armed window over one channel, as the document hands it to a mirror.
|
|
7559
|
+
*
|
|
7560
|
+
* A window is a DEADLINE, never a flag (ADR-0244): a channel somebody forgot
|
|
7561
|
+
* expires by itself, which is the one failure a boolean cannot avoid.
|
|
7562
|
+
*/
|
|
7563
|
+
var LogChannelWindowSchema = object({
|
|
7564
|
+
channel: string().min(1),
|
|
7565
|
+
/** Epoch ms the window closes at. */
|
|
7566
|
+
armedUntilMs: number(),
|
|
7567
|
+
/** `null` = every camera. A non-empty list narrows to those numeric ids. */
|
|
7568
|
+
deviceIds: array(number().int()).readonly().nullable()
|
|
7569
|
+
});
|
|
7570
|
+
/**
|
|
7466
7571
|
* Ops-log — the durable, append-only operations audit shared by the
|
|
7467
7572
|
* recordings and events management surfaces.
|
|
7468
7573
|
*
|
|
@@ -11270,6 +11375,35 @@ var MutationFilterSchema = object({
|
|
|
11270
11375
|
whereBetween: record(string(), tuple([unknown(), unknown()])).optional(),
|
|
11271
11376
|
whereNot: record(string(), unknown()).optional()
|
|
11272
11377
|
});
|
|
11378
|
+
/**
|
|
11379
|
+
* One scalar an {@link settingsStoreCapability.methods.aggregate} call asks for.
|
|
11380
|
+
*
|
|
11381
|
+
* `as` names the slot in the result, so the SAME column may be asked twice with
|
|
11382
|
+
* two operations (`MIN(startMs)` and `MAX(startMs)` in one round trip) — which
|
|
11383
|
+
* a `Record<column, op>` shape could not express.
|
|
11384
|
+
*/
|
|
11385
|
+
var AggregateFieldSchema = object({
|
|
11386
|
+
/** Result key. */
|
|
11387
|
+
as: string().min(1),
|
|
11388
|
+
/** Column to aggregate. Must be a real column of a declared collection. */
|
|
11389
|
+
field: string().min(1),
|
|
11390
|
+
op: _enum([
|
|
11391
|
+
"sum",
|
|
11392
|
+
"min",
|
|
11393
|
+
"max"
|
|
11394
|
+
])
|
|
11395
|
+
});
|
|
11396
|
+
/**
|
|
11397
|
+
* `COUNT(*)` plus one number per requested field.
|
|
11398
|
+
*
|
|
11399
|
+
* `null` means NO ROW MATCHED, never zero: a `SUM` over an empty set and a sum
|
|
11400
|
+
* that really is 0 are different facts, and an accounting caller that renders
|
|
11401
|
+
* "0 bytes, oldest = 0" for "nothing here" reports a lie about a disk.
|
|
11402
|
+
*/
|
|
11403
|
+
var AggregateResultSchema = object({
|
|
11404
|
+
count: number().int(),
|
|
11405
|
+
values: record(string(), number().nullable())
|
|
11406
|
+
});
|
|
11273
11407
|
/** A single stored record: `{ id, data }`. */
|
|
11274
11408
|
var SettingsRecordSchema = object({
|
|
11275
11409
|
id: string(),
|
|
@@ -11354,6 +11488,11 @@ method(object({
|
|
|
11354
11488
|
collection: string(),
|
|
11355
11489
|
filter: QueryFilterSchema.optional()
|
|
11356
11490
|
}), number()), method(object({
|
|
11491
|
+
namespace: string().optional(),
|
|
11492
|
+
collection: string(),
|
|
11493
|
+
fields: array(AggregateFieldSchema).readonly(),
|
|
11494
|
+
filter: QueryFilterSchema.optional()
|
|
11495
|
+
}), AggregateResultSchema), method(object({
|
|
11357
11496
|
namespace: string().optional(),
|
|
11358
11497
|
collection: string(),
|
|
11359
11498
|
field: string(),
|
|
@@ -11470,6 +11609,11 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
|
|
|
11470
11609
|
collection: string(),
|
|
11471
11610
|
filter: QueryFilterSchema.optional()
|
|
11472
11611
|
}), number(), { auth: "admin" }), method(object({
|
|
11612
|
+
namespace: string().optional(),
|
|
11613
|
+
collection: string(),
|
|
11614
|
+
fields: array(AggregateFieldSchema).readonly(),
|
|
11615
|
+
filter: QueryFilterSchema.optional()
|
|
11616
|
+
}), AggregateResultSchema, { auth: "admin" }), method(object({
|
|
11473
11617
|
namespace: string().optional(),
|
|
11474
11618
|
collection: string(),
|
|
11475
11619
|
field: string(),
|
|
@@ -12193,24 +12337,6 @@ var deviceProviderCapability = {
|
|
|
12193
12337
|
})
|
|
12194
12338
|
}
|
|
12195
12339
|
};
|
|
12196
|
-
/**
|
|
12197
|
-
* Device Manager capability — hub-side singleton that unifies device persistence,
|
|
12198
|
-
* live registry access, and all management operations into a single tRPC surface.
|
|
12199
|
-
*
|
|
12200
|
-
* Replaces:
|
|
12201
|
-
* - `device-persistence` capability (persistence methods absorbed here)
|
|
12202
|
-
* - `device-management.router.ts` (deleted in Phase 2)
|
|
12203
|
-
* - `device-ops.router.ts` (compat layer — deleted; device-provider ops absorbed here)
|
|
12204
|
-
*
|
|
12205
|
-
* All device provider addons (rtsp, onvif, frigate, …) are hub-local: they may
|
|
12206
|
-
* fork into separate processes but never run on remote cluster agents. Therefore:
|
|
12207
|
-
* - No nodeId routing needed — this is a pure hub singleton.
|
|
12208
|
-
* - The hub's DeviceRegistry is the single source of truth for all live devices.
|
|
12209
|
-
* - No shadow registry or cross-node aggregation required.
|
|
12210
|
-
*
|
|
12211
|
-
* Forked workers register devices back to the hub via `ctx.devices`
|
|
12212
|
-
* (DeviceManagerApi → ctx.api.deviceManager.registerDevice), same as today.
|
|
12213
|
-
*/
|
|
12214
12340
|
/** One child-placement directive on a container's `childLayout`. Structurally
|
|
12215
12341
|
* identical to `ChildLayoutEntry` in `device-management.ts` — the cap wire
|
|
12216
12342
|
* shape for the same field. The child is identified by its re-sync-stable
|
|
@@ -12579,7 +12705,7 @@ method(object({
|
|
|
12579
12705
|
* it answers today and the caller filters as it already does.
|
|
12580
12706
|
*/
|
|
12581
12707
|
deviceIds: array(number()).optional()
|
|
12582
|
-
}), array(DeviceInfoSchema)), method(object({ deviceId: number() }), DeviceInfoSchema.nullable()), method(object({ parentDeviceId: number() }), array(DeviceInfoSchema)), method(object({ deviceId: number() }), object({
|
|
12708
|
+
}), 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({
|
|
12583
12709
|
mode: LinkedDevicesModeSchema,
|
|
12584
12710
|
devices: array(LinkedDeviceSchema)
|
|
12585
12711
|
})), 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({
|
|
@@ -13303,6 +13429,59 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
|
|
|
13303
13429
|
kind: "mutation",
|
|
13304
13430
|
auth: "admin"
|
|
13305
13431
|
});
|
|
13432
|
+
/**
|
|
13433
|
+
* `log-channels` — the capability an addon DECLARES its diagnostic channels
|
|
13434
|
+
* through. It stores nothing.
|
|
13435
|
+
*
|
|
13436
|
+
* ## Why a capability at all, and why this shape
|
|
13437
|
+
*
|
|
13438
|
+
* Which channels exist is knowledge only the addon has: `stream-broker` knows
|
|
13439
|
+
* webrtc/ICE/RTP, `provider-reolink` knows baichuan/handshake. A central list
|
|
13440
|
+
* maintained by hand rots at the first addition and rots INVISIBLY — nothing
|
|
13441
|
+
* fails, an operator just never sees the channel somebody added. So the list
|
|
13442
|
+
* is assembled from declarations at runtime.
|
|
13443
|
+
*
|
|
13444
|
+
* The shape is copied from `log-destination.cap.ts`, which already does
|
|
13445
|
+
* exactly this job: `mode: 'collection'`, `internal: true`,
|
|
13446
|
+
* `mount: { kind: 'skip' }` — no tRPC route, no generated hooks — while
|
|
13447
|
+
* `addons.listCapabilityProviders` still enumerates it, and the hub's
|
|
13448
|
+
* `CapabilityRegistry` still holds an RPC proxy per provider so a forked
|
|
13449
|
+
* runner's declarations reach hub-main over the transport that already exists.
|
|
13450
|
+
* No new UDS message, no second registry.
|
|
13451
|
+
*
|
|
13452
|
+
* ## What it deliberately does NOT own
|
|
13453
|
+
*
|
|
13454
|
+
* The VALUES — which channel is armed, for which cameras, until when — live in
|
|
13455
|
+
* ONE place: the logging settings document on the `system` cap
|
|
13456
|
+
* (`getLoggingSettings` / `setLoggingSettings`). Two authorities over the same
|
|
13457
|
+
* value is the defect the plan behind this work exists to remove, and
|
|
13458
|
+
* `setRequestCensus` was retired (D245) rather than allowed to be a second
|
|
13459
|
+
* one. {@link logChannelsCapability} therefore has no getter for a level, no
|
|
13460
|
+
* setter for a window and no persistence of any kind.
|
|
13461
|
+
*
|
|
13462
|
+
* ## Why `apply` is here even so
|
|
13463
|
+
*
|
|
13464
|
+
* The gate lives in the addon's PROCESS; the document lives in hub-main. Some
|
|
13465
|
+
* seam has to carry the value from the authority to the mirror, and a channel
|
|
13466
|
+
* that cannot be reached is precisely the dead knob this whole slice exists to
|
|
13467
|
+
* make impossible (D62 — `audioThresholdDbfs`, the HA entities with no source).
|
|
13468
|
+
* `apply` is that seam and nothing more: it writes an in-memory mirror, it
|
|
13469
|
+
* persists nothing, it is never the source of a value, and it is called only
|
|
13470
|
+
* with a set the hub actually read (D49 — a read that fails does not call it
|
|
13471
|
+
* at all, so no channel is silently disarmed by a bad read).
|
|
13472
|
+
*/
|
|
13473
|
+
/** What `apply` reports back — enough to log, not enough to be a second state. */
|
|
13474
|
+
var LogChannelApplyResultSchema = object({
|
|
13475
|
+
/** How many declared channels are armed in this process after the call. */
|
|
13476
|
+
armed: number().int().min(0),
|
|
13477
|
+
/**
|
|
13478
|
+
* Names the document armed that this process does not declare. Reported
|
|
13479
|
+
* rather than swallowed: a name here is either a typo or an addon that has
|
|
13480
|
+
* not booted, and both deserve a line instead of silence.
|
|
13481
|
+
*/
|
|
13482
|
+
unknown: array(string()).readonly()
|
|
13483
|
+
});
|
|
13484
|
+
method(_void(), array(LogChannelDescriptorSchema).readonly()), method(object({ windows: array(LogChannelWindowSchema).readonly() }), LogChannelApplyResultSchema, { kind: "mutation" });
|
|
13306
13485
|
var LogLevelSchema = _enum([
|
|
13307
13486
|
"debug",
|
|
13308
13487
|
"info",
|
|
@@ -29182,10 +29361,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
|
|
|
29182
29361
|
* The layers of the level hierarchy, general → specific. The most specific
|
|
29183
29362
|
* layer that carries an explicit value wins.
|
|
29184
29363
|
*
|
|
29185
|
-
* `component`
|
|
29186
|
-
*
|
|
29187
|
-
*
|
|
29188
|
-
*
|
|
29364
|
+
* `component` became RESOLVABLE on 2026-08-27: a component is a declared log
|
|
29365
|
+
* CHANNEL (`stream-broker.webrtc`, `provider-reolink.baichuan`), named by
|
|
29366
|
+
* `scopeComponent`. It was declared-but-dark in the first slice precisely so
|
|
29367
|
+
* that turning it on would not force every consumer of this document to widen
|
|
29368
|
+
* a `levelSource` enum — which is what has now not happened.
|
|
29189
29369
|
*/
|
|
29190
29370
|
var LoggingScopeKindSchema = _enum([
|
|
29191
29371
|
"cluster",
|
|
@@ -29212,6 +29392,14 @@ var LoggingLevelLayerSchema = object({
|
|
|
29212
29392
|
scope: LoggingScopeKindSchema,
|
|
29213
29393
|
/** The node this layer speaks for; `null` on the cluster layer. */
|
|
29214
29394
|
nodeId: string().nullable(),
|
|
29395
|
+
/**
|
|
29396
|
+
* The declared channel this layer speaks for; `null` on every layer but
|
|
29397
|
+
* `component`. Never folded into `nodeId`: a component level is CLUSTER-WIDE
|
|
29398
|
+
* by design — the convention this repo settled on is one orchestrator-wide
|
|
29399
|
+
* setting, never per node (D52) — so a component layer that carried a node
|
|
29400
|
+
* would invite a per-node copy of a value that has no per-node meaning.
|
|
29401
|
+
*/
|
|
29402
|
+
component: string().nullable(),
|
|
29215
29403
|
/** Explicitly set here, or `null` when this layer inherits. */
|
|
29216
29404
|
level: LogLevelSchema$1.nullable()
|
|
29217
29405
|
});
|
|
@@ -29253,6 +29441,49 @@ var DiagnosticWindowPatchSchema = object({
|
|
|
29253
29441
|
reportEveryMs: number().int().positive().optional()
|
|
29254
29442
|
});
|
|
29255
29443
|
/**
|
|
29444
|
+
* A channel ARMED, as the document reports it.
|
|
29445
|
+
*
|
|
29446
|
+
* `armMs` is not echoed back: what an operator needs to see is the deadline
|
|
29447
|
+
* and the time left, because a diagnostic left running is itself an incident
|
|
29448
|
+
* and "armed for 10 minutes" said an hour ago is not an answer.
|
|
29449
|
+
*/
|
|
29450
|
+
var LogChannelWindowStateSchema = object({
|
|
29451
|
+
channel: string(),
|
|
29452
|
+
armed: boolean(),
|
|
29453
|
+
/** Epoch ms the window closes at. 0 when disarmed. */
|
|
29454
|
+
armedUntilMs: number(),
|
|
29455
|
+
/** Ms left before it expires on its own. 0 when disarmed. */
|
|
29456
|
+
remainingMs: number(),
|
|
29457
|
+
/**
|
|
29458
|
+
* The cameras it is narrowed to, or `null` for every camera.
|
|
29459
|
+
*
|
|
29460
|
+
* A channel declared `perDevice: false` can only ever report `null` here:
|
|
29461
|
+
* its lines do not carry `tags: { deviceId }`, so narrowing them would
|
|
29462
|
+
* produce a filter that silently matches nothing. The server REFUSES such a
|
|
29463
|
+
* patch rather than quietly widening it — ignoring the request would teach
|
|
29464
|
+
* the operator that per-camera filtering works on that channel when it does
|
|
29465
|
+
* not.
|
|
29466
|
+
*/
|
|
29467
|
+
deviceIds: array(number().int()).readonly().nullable()
|
|
29468
|
+
});
|
|
29469
|
+
/**
|
|
29470
|
+
* `armMs: 0` DISARMS. Same grammar as {@link DiagnosticWindowPatchSchema}, and
|
|
29471
|
+
* for the same reason: a channel is a window with a deadline, never a switch.
|
|
29472
|
+
*/
|
|
29473
|
+
var LogChannelWindowPatchSchema = object({
|
|
29474
|
+
channel: string().min(1),
|
|
29475
|
+
armMs: number().int().min(0),
|
|
29476
|
+
/**
|
|
29477
|
+
* Narrow to these numeric device ids. Absent or `null` = every camera.
|
|
29478
|
+
*
|
|
29479
|
+
* Numeric because the repo's own rule makes it possible: every log line
|
|
29480
|
+
* about a device carries `tags: { deviceId }` with the numeric id. That rule
|
|
29481
|
+
* was paid for with a 22% thumbnail gap and a 3-hour media blackout both
|
|
29482
|
+
* diagnosed by hand, and this is the first thing that collects on it.
|
|
29483
|
+
*/
|
|
29484
|
+
deviceIds: array(number().int()).readonly().nullable().optional()
|
|
29485
|
+
});
|
|
29486
|
+
/**
|
|
29256
29487
|
* A PATCH, and patches MERGE.
|
|
29257
29488
|
*
|
|
29258
29489
|
* A field absent from the patch is left exactly as it was — arming a
|
|
@@ -29271,7 +29502,14 @@ var LoggingSettingsPatchSchema = object({
|
|
|
29271
29502
|
* Only the diagnostics NAMED here change. An armed window that is not listed
|
|
29272
29503
|
* keeps running — a patch is never a full replacement.
|
|
29273
29504
|
*/
|
|
29274
|
-
diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional()
|
|
29505
|
+
diagnostics: array(DiagnosticWindowPatchSchema).readonly().optional(),
|
|
29506
|
+
/**
|
|
29507
|
+
* Only the channels NAMED here change. An armed channel that is not listed
|
|
29508
|
+
* keeps running — same rule as `diagnostics`, because a patch that silently
|
|
29509
|
+
* disarmed the channels it did not mention would make the Levels page and
|
|
29510
|
+
* the Diagnostics page fight over the same value.
|
|
29511
|
+
*/
|
|
29512
|
+
channels: array(LogChannelWindowPatchSchema).readonly().optional()
|
|
29275
29513
|
});
|
|
29276
29514
|
/**
|
|
29277
29515
|
* Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
|
|
@@ -29284,9 +29522,22 @@ var LoggingSettingsPatchSchema = object({
|
|
|
29284
29522
|
* authority over the whole hierarchy and answers for every layer, so the
|
|
29285
29523
|
* layer selector needs a name the transport does not already own.
|
|
29286
29524
|
*/
|
|
29287
|
-
var GetLoggingSettingsInputSchema = object({
|
|
29525
|
+
var GetLoggingSettingsInputSchema = object({
|
|
29526
|
+
scopeNodeId: string().optional(),
|
|
29527
|
+
/**
|
|
29528
|
+
* The declared CHANNEL this document is addressed at, when the caller wants
|
|
29529
|
+
* the `component` layer. Absent = the node/cluster hierarchy only.
|
|
29530
|
+
*
|
|
29531
|
+
* Naming it separately rather than overloading `scopeNodeId` keeps the two
|
|
29532
|
+
* axes from collapsing: a component level is cluster-wide, a node level is
|
|
29533
|
+
* not, and one selector for both would make "which of these two did I just
|
|
29534
|
+
* set" unanswerable — the exact ambiguity `explicit` exists to remove.
|
|
29535
|
+
*/
|
|
29536
|
+
scopeComponent: string().optional()
|
|
29537
|
+
});
|
|
29288
29538
|
var SetLoggingSettingsInputSchema = object({
|
|
29289
29539
|
scopeNodeId: string().optional(),
|
|
29540
|
+
scopeComponent: string().optional(),
|
|
29290
29541
|
patch: LoggingSettingsPatchSchema
|
|
29291
29542
|
});
|
|
29292
29543
|
/**
|
|
@@ -29301,9 +29552,20 @@ var SetLoggingSettingsInputSchema = object({
|
|
|
29301
29552
|
var LoggingSettingsStateSchema = object({
|
|
29302
29553
|
/** The layer this document was read at. `null` = the cluster layer. */
|
|
29303
29554
|
scopeNodeId: string().nullable(),
|
|
29555
|
+
/** The channel this document was read at. `null` = no component layer. */
|
|
29556
|
+
scopeComponent: string().nullable(),
|
|
29304
29557
|
effective: LoggingEffectiveSchema,
|
|
29305
29558
|
explicit: LoggingExplicitSchema,
|
|
29306
29559
|
activeWindows: array(DiagnosticWindowSchema).readonly(),
|
|
29560
|
+
/**
|
|
29561
|
+
* Every channel the cluster's addons DECLARE, gathered from the
|
|
29562
|
+
* `log-channels` providers. Not stored anywhere: assembled per read, so a
|
|
29563
|
+
* channel added by a redeployed addon appears without anybody editing a
|
|
29564
|
+
* list, and a channel whose addon is gone stops being offered.
|
|
29565
|
+
*/
|
|
29566
|
+
channels: array(LogChannelDescriptorSchema).readonly(),
|
|
29567
|
+
/** The channels ARMED right now, each with its deadline. */
|
|
29568
|
+
activeChannels: array(LogChannelWindowStateSchema).readonly(),
|
|
29307
29569
|
persisted: boolean()
|
|
29308
29570
|
});
|
|
29309
29571
|
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(), {
|
|
@@ -32521,6 +32783,12 @@ Object.freeze({
|
|
|
32521
32783
|
addonId: null,
|
|
32522
32784
|
access: "view"
|
|
32523
32785
|
},
|
|
32786
|
+
"dataStoreProvider.aggregate": {
|
|
32787
|
+
capName: "data-store-provider",
|
|
32788
|
+
capScope: "system",
|
|
32789
|
+
addonId: null,
|
|
32790
|
+
access: "view"
|
|
32791
|
+
},
|
|
32524
32792
|
"dataStoreProvider.count": {
|
|
32525
32793
|
capName: "data-store-provider",
|
|
32526
32794
|
capScope: "system",
|
|
@@ -32935,6 +33203,12 @@ Object.freeze({
|
|
|
32935
33203
|
addonId: null,
|
|
32936
33204
|
access: "view"
|
|
32937
33205
|
},
|
|
33206
|
+
"deviceManager.getChildrenBatch": {
|
|
33207
|
+
capName: "device-manager",
|
|
33208
|
+
capScope: "system",
|
|
33209
|
+
addonId: null,
|
|
33210
|
+
access: "view"
|
|
33211
|
+
},
|
|
32938
33212
|
"deviceManager.getConfigSchema": {
|
|
32939
33213
|
capName: "device-manager",
|
|
32940
33214
|
capScope: "system",
|
|
@@ -33985,6 +34259,18 @@ Object.freeze({
|
|
|
33985
34259
|
addonId: null,
|
|
33986
34260
|
access: "create"
|
|
33987
34261
|
},
|
|
34262
|
+
"logChannels.apply": {
|
|
34263
|
+
capName: "log-channels",
|
|
34264
|
+
capScope: "system",
|
|
34265
|
+
addonId: null,
|
|
34266
|
+
access: "create"
|
|
34267
|
+
},
|
|
34268
|
+
"logChannels.list": {
|
|
34269
|
+
capName: "log-channels",
|
|
34270
|
+
capScope: "system",
|
|
34271
|
+
addonId: null,
|
|
34272
|
+
access: "view"
|
|
34273
|
+
},
|
|
33988
34274
|
"logDestination.query": {
|
|
33989
34275
|
capName: "log-destination",
|
|
33990
34276
|
capScope: "system",
|
|
@@ -36139,6 +36425,12 @@ Object.freeze({
|
|
|
36139
36425
|
addonId: null,
|
|
36140
36426
|
access: "create"
|
|
36141
36427
|
},
|
|
36428
|
+
"settingsStore.aggregate": {
|
|
36429
|
+
capName: "settings-store",
|
|
36430
|
+
capScope: "system",
|
|
36431
|
+
addonId: null,
|
|
36432
|
+
access: "view"
|
|
36433
|
+
},
|
|
36142
36434
|
"settingsStore.count": {
|
|
36143
36435
|
capName: "settings-store",
|
|
36144
36436
|
capScope: "system",
|
|
@@ -37718,6 +38010,11 @@ Object.freeze({
|
|
|
37718
38010
|
form: "single",
|
|
37719
38011
|
optional: false
|
|
37720
38012
|
}],
|
|
38013
|
+
"deviceManager.getChildrenBatch": [{
|
|
38014
|
+
name: "parentDeviceIds",
|
|
38015
|
+
form: "array",
|
|
38016
|
+
optional: false
|
|
38017
|
+
}],
|
|
37721
38018
|
"deviceManager.getConfigSchema": [{
|
|
37722
38019
|
name: "deviceId",
|
|
37723
38020
|
form: "single",
|
|
@@ -40184,6 +40481,38 @@ function createAccessoryDevice(kind, ctx, parent) {
|
|
|
40184
40481
|
default: throw new Error(`Hikvision provider does not implement accessory kind "${String(kind)}"`);
|
|
40185
40482
|
}
|
|
40186
40483
|
}
|
|
40484
|
+
function createAlarmTypeTally(deps) {
|
|
40485
|
+
const intervalMs = deps.intervalMs ?? 3e5;
|
|
40486
|
+
const lastLoggedAt = /* @__PURE__ */ new Map();
|
|
40487
|
+
const suppressed = /* @__PURE__ */ new Map();
|
|
40488
|
+
const note = (type, state, reason) => {
|
|
40489
|
+
const logger = deps.logger;
|
|
40490
|
+
if (!logger) return;
|
|
40491
|
+
const key = `${type}/${state ?? "none"}`;
|
|
40492
|
+
const now = Date.now();
|
|
40493
|
+
const last = lastLoggedAt.get(key);
|
|
40494
|
+
if (last !== void 0 && now - last < intervalMs) {
|
|
40495
|
+
suppressed.set(key, (suppressed.get(key) ?? 0) + 1);
|
|
40496
|
+
return;
|
|
40497
|
+
}
|
|
40498
|
+
const count = (suppressed.get(key) ?? 0) + 1;
|
|
40499
|
+
suppressed.set(key, 0);
|
|
40500
|
+
lastLoggedAt.set(key, now);
|
|
40501
|
+
const extras = {
|
|
40502
|
+
...deps.deviceId === null ? {} : { tags: { deviceId: deps.deviceId } },
|
|
40503
|
+
meta: {
|
|
40504
|
+
type,
|
|
40505
|
+
state,
|
|
40506
|
+
count,
|
|
40507
|
+
...last === void 0 ? { first: true } : { windowMs: now - last },
|
|
40508
|
+
...reason === void 0 ? {} : { reason }
|
|
40509
|
+
}
|
|
40510
|
+
};
|
|
40511
|
+
if (deps.level === "debug") logger.debug(deps.message, extras);
|
|
40512
|
+
else logger.info(deps.message, extras);
|
|
40513
|
+
};
|
|
40514
|
+
return { note };
|
|
40515
|
+
}
|
|
40187
40516
|
//#endregion
|
|
40188
40517
|
//#region src/hikvision-channel-fps.ts
|
|
40189
40518
|
/**
|
|
@@ -40269,6 +40598,24 @@ function buildAuthHeader(input) {
|
|
|
40269
40598
|
return `Digest ${parts.join(", ")}`;
|
|
40270
40599
|
}
|
|
40271
40600
|
//#endregion
|
|
40601
|
+
//#region src/hikvision-alarm-ignore.ts
|
|
40602
|
+
var IGNORED_ALARMS = new Map([["videoloss", {
|
|
40603
|
+
states: ["inactive"],
|
|
40604
|
+
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."
|
|
40605
|
+
}]]);
|
|
40606
|
+
/**
|
|
40607
|
+
* The reason this `(type, state)` is deliberately not acted on, or `null` when
|
|
40608
|
+
* the event must be delivered.
|
|
40609
|
+
*
|
|
40610
|
+
* Both arguments are expected lowercased, matching `eventType` / `eventState`
|
|
40611
|
+
* as normalised by the alert parser.
|
|
40612
|
+
*/
|
|
40613
|
+
function hikvisionIgnoredAlarmReason(type, state) {
|
|
40614
|
+
const policy = IGNORED_ALARMS.get(type);
|
|
40615
|
+
if (!policy) return null;
|
|
40616
|
+
return policy.states.includes(state) ? policy.reason : null;
|
|
40617
|
+
}
|
|
40618
|
+
//#endregion
|
|
40272
40619
|
//#region src/hikvision-snapshot-channel.ts
|
|
40273
40620
|
/**
|
|
40274
40621
|
* Hikvision encodes a channel id as `{cameraNumber}{streamSlot}`; slot `1` is
|
|
@@ -42355,6 +42702,13 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
|
|
|
42355
42702
|
const retainBytes = options.retainBytes ?? 65536;
|
|
42356
42703
|
const unparsedWarnBytes = options.unparsedWarnBytes ?? 32768;
|
|
42357
42704
|
const diagnostics = createAlarmDiagnostics(options.logger ?? null, options.deviceId ?? null, options.diagnosticIntervalMs ?? 6e4);
|
|
42705
|
+
const ignoredTally = createAlarmTypeTally({
|
|
42706
|
+
logger: options.logger ?? null,
|
|
42707
|
+
deviceId: options.deviceId ?? null,
|
|
42708
|
+
message: "hikvision alarm stream: ignored alarm type (declared policy)",
|
|
42709
|
+
level: "debug",
|
|
42710
|
+
...options.ignoredTallyIntervalMs === void 0 ? {} : { intervalMs: options.ignoredTallyIntervalMs }
|
|
42711
|
+
});
|
|
42358
42712
|
const reader = stream.getReader();
|
|
42359
42713
|
let activeBoundary = declaredBoundary;
|
|
42360
42714
|
let activeDashBoundary = `--${activeBoundary}`;
|
|
@@ -42397,8 +42751,8 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
|
|
|
42397
42751
|
});
|
|
42398
42752
|
return;
|
|
42399
42753
|
}
|
|
42400
|
-
const
|
|
42401
|
-
if (!
|
|
42754
|
+
const peeked = peekAlertTypeState(bodyText);
|
|
42755
|
+
if (!peeked) {
|
|
42402
42756
|
diagnostics.report("alert-xml-without-event-type", "hikvision alarm stream: alert part dropped — no <eventType> tag", {
|
|
42403
42757
|
contentType,
|
|
42404
42758
|
bytes: block.byteLength,
|
|
@@ -42406,7 +42760,12 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
|
|
|
42406
42760
|
});
|
|
42407
42761
|
return;
|
|
42408
42762
|
}
|
|
42409
|
-
|
|
42763
|
+
const ignoredReason = hikvisionIgnoredAlarmReason(peeked.type, peeked.state);
|
|
42764
|
+
if (ignoredReason !== null) {
|
|
42765
|
+
ignoredTally.note(peeked.type, peeked.state, ignoredReason);
|
|
42766
|
+
return;
|
|
42767
|
+
}
|
|
42768
|
+
handlers.onEvent(parseAlertXml(bodyText, peeked));
|
|
42410
42769
|
};
|
|
42411
42770
|
let idleTimer = null;
|
|
42412
42771
|
const armIdle = () => {
|
|
@@ -42591,10 +42950,22 @@ function isHikvisionMotionAlarmType(type) {
|
|
|
42591
42950
|
function isHikvisionSmartAlarmType(type) {
|
|
42592
42951
|
return type !== "vmd" && type !== "motiondetection" && isHikvisionMotionAlarmType(type);
|
|
42593
42952
|
}
|
|
42594
|
-
function
|
|
42953
|
+
function peekAlertTypeState(xml) {
|
|
42595
42954
|
const type = extractTag(xml, "eventType");
|
|
42596
42955
|
if (!type) return null;
|
|
42597
42956
|
const state = extractTag(xml, "eventState");
|
|
42957
|
+
return {
|
|
42958
|
+
type: type.toLowerCase(),
|
|
42959
|
+
state: state?.toLowerCase() ?? null
|
|
42960
|
+
};
|
|
42961
|
+
}
|
|
42962
|
+
/**
|
|
42963
|
+
* Build the full event. Takes the already-peeked `(type, state)` so the two
|
|
42964
|
+
* tags are extracted exactly once, and so this function has no failure mode
|
|
42965
|
+
* left: `peekAlertTypeState` returning non-null IS the precondition, and the
|
|
42966
|
+
* caller has already reported the only way it can fail.
|
|
42967
|
+
*/
|
|
42968
|
+
function parseAlertXml(xml, peeked) {
|
|
42598
42969
|
const channelId = extractTag(xml, "dynChannelID") ?? extractTag(xml, "channelID");
|
|
42599
42970
|
const description = extractTag(xml, "eventDescription") ?? extractTag(xml, "description");
|
|
42600
42971
|
const aiClass = extractTag(xml, "targetType") ?? extractTag(xml, "className");
|
|
@@ -42606,8 +42977,8 @@ function parseAlertXml(xml) {
|
|
|
42606
42977
|
})();
|
|
42607
42978
|
return {
|
|
42608
42979
|
observedAt: Date.now(),
|
|
42609
|
-
type: type
|
|
42610
|
-
state: state
|
|
42980
|
+
type: peeked.type,
|
|
42981
|
+
state: peeked.state,
|
|
42611
42982
|
channelId,
|
|
42612
42983
|
aiClass,
|
|
42613
42984
|
description,
|
|
@@ -44135,6 +44506,25 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
|
|
|
44135
44506
|
alarmReconnectAttempts = 0;
|
|
44136
44507
|
/** Pending alarm-reconnect timer. */
|
|
44137
44508
|
alarmReconnectTimer = null;
|
|
44509
|
+
/**
|
|
44510
|
+
* Counting reporter for alarm types the camera receives but does not model.
|
|
44511
|
+
*
|
|
44512
|
+
* Built lazily so it can capture `this.id` / `this.ctx.logger` — every line
|
|
44513
|
+
* it emits carries the numeric `deviceId`. It keeps the historical message
|
|
44514
|
+
* text (`hikvision: unhandled alarm event`) so existing Loki queries keep
|
|
44515
|
+
* working; what changed is that the line now carries `meta.count` and arrives
|
|
44516
|
+
* once per window instead of once per event.
|
|
44517
|
+
*/
|
|
44518
|
+
unhandledAlarmsTally = null;
|
|
44519
|
+
get unhandledAlarms() {
|
|
44520
|
+
this.unhandledAlarmsTally ??= createAlarmTypeTally({
|
|
44521
|
+
logger: this.ctx.logger,
|
|
44522
|
+
deviceId: this.id,
|
|
44523
|
+
message: "hikvision: unhandled alarm event",
|
|
44524
|
+
level: "info"
|
|
44525
|
+
});
|
|
44526
|
+
return this.unhandledAlarmsTally;
|
|
44527
|
+
}
|
|
44138
44528
|
/** Hysteresis: drop motion-active back to inactive after this many ms with
|
|
44139
44529
|
* no fresh `VMD` event. Hikvision fires VMD every ~1s while motion is
|
|
44140
44530
|
* active; missing 2 ticks signals the burst is over. */
|
|
@@ -46360,22 +46750,17 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
|
|
|
46360
46750
|
return;
|
|
46361
46751
|
}
|
|
46362
46752
|
if (ev.type === "videoloss") {
|
|
46363
|
-
this.ctx.logger.
|
|
46753
|
+
this.ctx.logger.warn("hikvision: camera reports video signal loss", {
|
|
46364
46754
|
tags: { deviceId: this.id },
|
|
46365
46755
|
meta: {
|
|
46366
46756
|
type: ev.type,
|
|
46367
|
-
state: ev.state
|
|
46757
|
+
state: ev.state,
|
|
46758
|
+
camStreamId
|
|
46368
46759
|
}
|
|
46369
46760
|
});
|
|
46370
46761
|
return;
|
|
46371
46762
|
}
|
|
46372
|
-
this.
|
|
46373
|
-
tags: { deviceId: this.id },
|
|
46374
|
-
meta: {
|
|
46375
|
-
type: ev.type,
|
|
46376
|
-
state: ev.state
|
|
46377
|
-
}
|
|
46378
|
-
});
|
|
46763
|
+
this.unhandledAlarms.note(ev.type, ev.state);
|
|
46379
46764
|
}
|
|
46380
46765
|
resolveAlarmCamStreamId(channelId) {
|
|
46381
46766
|
if (!channelId) return "native:main";
|
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",
|
|
@@ -29183,10 +29362,11 @@ var DiagnosticIdSchema = _enum(["request-census"]);
|
|
|
29183
29362
|
* The layers of the level hierarchy, general → specific. The most specific
|
|
29184
29363
|
* layer that carries an explicit value wins.
|
|
29185
29364
|
*
|
|
29186
|
-
* `component`
|
|
29187
|
-
*
|
|
29188
|
-
*
|
|
29189
|
-
*
|
|
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.
|
|
29190
29370
|
*/
|
|
29191
29371
|
var LoggingScopeKindSchema = _enum([
|
|
29192
29372
|
"cluster",
|
|
@@ -29213,6 +29393,14 @@ var LoggingLevelLayerSchema = object({
|
|
|
29213
29393
|
scope: LoggingScopeKindSchema,
|
|
29214
29394
|
/** The node this layer speaks for; `null` on the cluster layer. */
|
|
29215
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(),
|
|
29216
29404
|
/** Explicitly set here, or `null` when this layer inherits. */
|
|
29217
29405
|
level: LogLevelSchema$1.nullable()
|
|
29218
29406
|
});
|
|
@@ -29254,6 +29442,49 @@ var DiagnosticWindowPatchSchema = object({
|
|
|
29254
29442
|
reportEveryMs: number().int().positive().optional()
|
|
29255
29443
|
});
|
|
29256
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
|
+
/**
|
|
29257
29488
|
* A PATCH, and patches MERGE.
|
|
29258
29489
|
*
|
|
29259
29490
|
* A field absent from the patch is left exactly as it was — arming a
|
|
@@ -29272,7 +29503,14 @@ var LoggingSettingsPatchSchema = object({
|
|
|
29272
29503
|
* Only the diagnostics NAMED here change. An armed window that is not listed
|
|
29273
29504
|
* keeps running — a patch is never a full replacement.
|
|
29274
29505
|
*/
|
|
29275
|
-
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()
|
|
29276
29514
|
});
|
|
29277
29515
|
/**
|
|
29278
29516
|
* Which LAYER of the hierarchy is addressed. Absent = the cluster layer.
|
|
@@ -29285,9 +29523,22 @@ var LoggingSettingsPatchSchema = object({
|
|
|
29285
29523
|
* authority over the whole hierarchy and answers for every layer, so the
|
|
29286
29524
|
* layer selector needs a name the transport does not already own.
|
|
29287
29525
|
*/
|
|
29288
|
-
var GetLoggingSettingsInputSchema = object({
|
|
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
|
+
});
|
|
29289
29539
|
var SetLoggingSettingsInputSchema = object({
|
|
29290
29540
|
scopeNodeId: string().optional(),
|
|
29541
|
+
scopeComponent: string().optional(),
|
|
29291
29542
|
patch: LoggingSettingsPatchSchema
|
|
29292
29543
|
});
|
|
29293
29544
|
/**
|
|
@@ -29302,9 +29553,20 @@ var SetLoggingSettingsInputSchema = object({
|
|
|
29302
29553
|
var LoggingSettingsStateSchema = object({
|
|
29303
29554
|
/** The layer this document was read at. `null` = the cluster layer. */
|
|
29304
29555
|
scopeNodeId: string().nullable(),
|
|
29556
|
+
/** The channel this document was read at. `null` = no component layer. */
|
|
29557
|
+
scopeComponent: string().nullable(),
|
|
29305
29558
|
effective: LoggingEffectiveSchema,
|
|
29306
29559
|
explicit: LoggingExplicitSchema,
|
|
29307
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(),
|
|
29308
29570
|
persisted: boolean()
|
|
29309
29571
|
});
|
|
29310
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(), {
|
|
@@ -32522,6 +32784,12 @@ Object.freeze({
|
|
|
32522
32784
|
addonId: null,
|
|
32523
32785
|
access: "view"
|
|
32524
32786
|
},
|
|
32787
|
+
"dataStoreProvider.aggregate": {
|
|
32788
|
+
capName: "data-store-provider",
|
|
32789
|
+
capScope: "system",
|
|
32790
|
+
addonId: null,
|
|
32791
|
+
access: "view"
|
|
32792
|
+
},
|
|
32525
32793
|
"dataStoreProvider.count": {
|
|
32526
32794
|
capName: "data-store-provider",
|
|
32527
32795
|
capScope: "system",
|
|
@@ -32936,6 +33204,12 @@ Object.freeze({
|
|
|
32936
33204
|
addonId: null,
|
|
32937
33205
|
access: "view"
|
|
32938
33206
|
},
|
|
33207
|
+
"deviceManager.getChildrenBatch": {
|
|
33208
|
+
capName: "device-manager",
|
|
33209
|
+
capScope: "system",
|
|
33210
|
+
addonId: null,
|
|
33211
|
+
access: "view"
|
|
33212
|
+
},
|
|
32939
33213
|
"deviceManager.getConfigSchema": {
|
|
32940
33214
|
capName: "device-manager",
|
|
32941
33215
|
capScope: "system",
|
|
@@ -33986,6 +34260,18 @@ Object.freeze({
|
|
|
33986
34260
|
addonId: null,
|
|
33987
34261
|
access: "create"
|
|
33988
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
|
+
},
|
|
33989
34275
|
"logDestination.query": {
|
|
33990
34276
|
capName: "log-destination",
|
|
33991
34277
|
capScope: "system",
|
|
@@ -36140,6 +36426,12 @@ Object.freeze({
|
|
|
36140
36426
|
addonId: null,
|
|
36141
36427
|
access: "create"
|
|
36142
36428
|
},
|
|
36429
|
+
"settingsStore.aggregate": {
|
|
36430
|
+
capName: "settings-store",
|
|
36431
|
+
capScope: "system",
|
|
36432
|
+
addonId: null,
|
|
36433
|
+
access: "view"
|
|
36434
|
+
},
|
|
36143
36435
|
"settingsStore.count": {
|
|
36144
36436
|
capName: "settings-store",
|
|
36145
36437
|
capScope: "system",
|
|
@@ -37719,6 +38011,11 @@ Object.freeze({
|
|
|
37719
38011
|
form: "single",
|
|
37720
38012
|
optional: false
|
|
37721
38013
|
}],
|
|
38014
|
+
"deviceManager.getChildrenBatch": [{
|
|
38015
|
+
name: "parentDeviceIds",
|
|
38016
|
+
form: "array",
|
|
38017
|
+
optional: false
|
|
38018
|
+
}],
|
|
37722
38019
|
"deviceManager.getConfigSchema": [{
|
|
37723
38020
|
name: "deviceId",
|
|
37724
38021
|
form: "single",
|
|
@@ -40185,6 +40482,38 @@ function createAccessoryDevice(kind, ctx, parent) {
|
|
|
40185
40482
|
default: throw new Error(`Hikvision provider does not implement accessory kind "${String(kind)}"`);
|
|
40186
40483
|
}
|
|
40187
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
|
+
}
|
|
40188
40517
|
//#endregion
|
|
40189
40518
|
//#region src/hikvision-channel-fps.ts
|
|
40190
40519
|
/**
|
|
@@ -40270,6 +40599,24 @@ function buildAuthHeader(input) {
|
|
|
40270
40599
|
return `Digest ${parts.join(", ")}`;
|
|
40271
40600
|
}
|
|
40272
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
|
|
40273
40620
|
//#region src/hikvision-snapshot-channel.ts
|
|
40274
40621
|
/**
|
|
40275
40622
|
* Hikvision encodes a channel id as `{cameraNumber}{streamSlot}`; slot `1` is
|
|
@@ -42356,6 +42703,13 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
|
|
|
42356
42703
|
const retainBytes = options.retainBytes ?? 65536;
|
|
42357
42704
|
const unparsedWarnBytes = options.unparsedWarnBytes ?? 32768;
|
|
42358
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
|
+
});
|
|
42359
42713
|
const reader = stream.getReader();
|
|
42360
42714
|
let activeBoundary = declaredBoundary;
|
|
42361
42715
|
let activeDashBoundary = `--${activeBoundary}`;
|
|
@@ -42398,8 +42752,8 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
|
|
|
42398
42752
|
});
|
|
42399
42753
|
return;
|
|
42400
42754
|
}
|
|
42401
|
-
const
|
|
42402
|
-
if (!
|
|
42755
|
+
const peeked = peekAlertTypeState(bodyText);
|
|
42756
|
+
if (!peeked) {
|
|
42403
42757
|
diagnostics.report("alert-xml-without-event-type", "hikvision alarm stream: alert part dropped — no <eventType> tag", {
|
|
42404
42758
|
contentType,
|
|
42405
42759
|
bytes: block.byteLength,
|
|
@@ -42407,7 +42761,12 @@ async function pumpAlarmStream(stream, declaredBoundary, handlers, options) {
|
|
|
42407
42761
|
});
|
|
42408
42762
|
return;
|
|
42409
42763
|
}
|
|
42410
|
-
|
|
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));
|
|
42411
42770
|
};
|
|
42412
42771
|
let idleTimer = null;
|
|
42413
42772
|
const armIdle = () => {
|
|
@@ -42592,10 +42951,22 @@ function isHikvisionMotionAlarmType(type) {
|
|
|
42592
42951
|
function isHikvisionSmartAlarmType(type) {
|
|
42593
42952
|
return type !== "vmd" && type !== "motiondetection" && isHikvisionMotionAlarmType(type);
|
|
42594
42953
|
}
|
|
42595
|
-
function
|
|
42954
|
+
function peekAlertTypeState(xml) {
|
|
42596
42955
|
const type = extractTag(xml, "eventType");
|
|
42597
42956
|
if (!type) return null;
|
|
42598
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) {
|
|
42599
42970
|
const channelId = extractTag(xml, "dynChannelID") ?? extractTag(xml, "channelID");
|
|
42600
42971
|
const description = extractTag(xml, "eventDescription") ?? extractTag(xml, "description");
|
|
42601
42972
|
const aiClass = extractTag(xml, "targetType") ?? extractTag(xml, "className");
|
|
@@ -42607,8 +42978,8 @@ function parseAlertXml(xml) {
|
|
|
42607
42978
|
})();
|
|
42608
42979
|
return {
|
|
42609
42980
|
observedAt: Date.now(),
|
|
42610
|
-
type: type
|
|
42611
|
-
state: state
|
|
42981
|
+
type: peeked.type,
|
|
42982
|
+
state: peeked.state,
|
|
42612
42983
|
channelId,
|
|
42613
42984
|
aiClass,
|
|
42614
42985
|
description,
|
|
@@ -44136,6 +44507,25 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
|
|
|
44136
44507
|
alarmReconnectAttempts = 0;
|
|
44137
44508
|
/** Pending alarm-reconnect timer. */
|
|
44138
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
|
+
}
|
|
44139
44529
|
/** Hysteresis: drop motion-active back to inactive after this many ms with
|
|
44140
44530
|
* no fresh `VMD` event. Hikvision fires VMD every ~1s while motion is
|
|
44141
44531
|
* active; missing 2 ticks signals the burst is over. */
|
|
@@ -46361,22 +46751,17 @@ var HikvisionCamera = class HikvisionCamera extends BaseDevice {
|
|
|
46361
46751
|
return;
|
|
46362
46752
|
}
|
|
46363
46753
|
if (ev.type === "videoloss") {
|
|
46364
|
-
this.ctx.logger.
|
|
46754
|
+
this.ctx.logger.warn("hikvision: camera reports video signal loss", {
|
|
46365
46755
|
tags: { deviceId: this.id },
|
|
46366
46756
|
meta: {
|
|
46367
46757
|
type: ev.type,
|
|
46368
|
-
state: ev.state
|
|
46758
|
+
state: ev.state,
|
|
46759
|
+
camStreamId
|
|
46369
46760
|
}
|
|
46370
46761
|
});
|
|
46371
46762
|
return;
|
|
46372
46763
|
}
|
|
46373
|
-
this.
|
|
46374
|
-
tags: { deviceId: this.id },
|
|
46375
|
-
meta: {
|
|
46376
|
-
type: ev.type,
|
|
46377
|
-
state: ev.state
|
|
46378
|
-
}
|
|
46379
|
-
});
|
|
46764
|
+
this.unhandledAlarms.note(ev.type, ev.state);
|
|
46380
46765
|
}
|
|
46381
46766
|
resolveAlarmCamStreamId(channelId) {
|
|
46382
46767
|
if (!channelId) return "native:main";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-hikvision",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.42",
|
|
4
4
|
"description": "Hikvision camera device provider addon for CamStack — ISAPI over HTTP(S) with digest auth (snapshot, alarm stream, RTSP discovery)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|