@camstack/addon-pipeline 1.2.7 → 1.2.8

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 (41) hide show
  1. package/dist/audio-analyzer/index.js +3 -3
  2. package/dist/audio-analyzer/index.mjs +2 -3
  3. package/dist/{chunk-D6vf50IK.js → chunk-emK7D4bc.js} +7 -0
  4. package/dist/detection-pipeline/index.js +104 -8
  5. package/dist/detection-pipeline/index.mjs +103 -8
  6. package/dist/{dist-CAT3VF7A.js → dist-DNjy_sr4.js} +1239 -1058
  7. package/dist/{dist-BwyGTnMu.mjs → dist-owmpaeIY.mjs} +867 -680
  8. package/dist/fmp4-keyframes-BzTPoPVn.js +6676 -0
  9. package/dist/fmp4-keyframes-qOgJBjMO.mjs +6669 -0
  10. package/dist/{sheet-geometry-DcpuGTCm.mjs → hub-hostname-DAJXlOgV.js} +6 -39
  11. package/dist/{sheet-geometry-BR-ip0CP.js → hub-hostname-cCknRYKj.mjs} +1 -56
  12. package/dist/{model-download-service-Cp9f4dk6-CwUb5v3Y.mjs → model-download-service-Cp9f4dk6-WO-foD7W.mjs} +26 -1
  13. package/dist/{model-download-service-Cp9f4dk6-Dv-oFwjN.js → model-download-service-Cp9f4dk6-fsdDExML.js} +1 -1
  14. package/dist/motion-wasm/index.js +1 -1
  15. package/dist/motion-wasm/index.mjs +1 -1
  16. package/dist/pipeline-runner/index.js +40 -126
  17. package/dist/pipeline-runner/index.mjs +38 -124
  18. package/dist/recorder/index.js +695 -974
  19. package/dist/recorder/index.mjs +694 -972
  20. package/dist/session-decode/decode-worker-child.js +9 -5
  21. package/dist/session-decode/decode-worker-child.mjs +8 -4
  22. package/dist/{step-definitions-BPEExRug.js → step-definitions-C2bNlww3.js} +1 -1
  23. package/dist/{step-definitions-DN1obXS7.mjs → step-definitions-CkvctwuS.mjs} +1 -1
  24. package/dist/stream-broker/_stub.js +2 -2
  25. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-BtN6sZcL.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-XdI0RgvI.mjs} +2 -2
  26. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DSfbOjdi.mjs +26 -0
  27. package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BdxY9zld.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js--zEZtV2N.mjs} +1 -1
  28. package/dist/stream-broker/{hostInit-BIZvt2bk.mjs → hostInit-DsMIdlwP.mjs} +2 -2
  29. package/dist/stream-broker/index.js +646 -10
  30. package/dist/stream-broker/index.mjs +645 -10
  31. package/dist/stream-broker/remoteEntry.js +1 -1
  32. package/embed-dist/assets/{MaskShapeCanvas-DI4BY7W2-3uL2OmvC.js → MaskShapeCanvas-DI4BY7W2-CftzR7Pj.js} +1 -1
  33. package/embed-dist/assets/{MotionZonesSettings-NcxxQN8r-JkIkJTeI.js → MotionZonesSettings-NcxxQN8r-DPgVIdEn.js} +1 -1
  34. package/embed-dist/assets/{PrivacyMaskSettings-APgPLF7p-AKGABxQk.js → PrivacyMaskSettings-APgPLF7p-D0HqiXHW.js} +1 -1
  35. package/embed-dist/assets/{index-DfcKIHhA.js → index-DRtbV_en.js} +17 -15
  36. package/embed-dist/index.html +1 -1
  37. package/package.json +1 -1
  38. package/python/postprocessors/ctc.py +14 -5
  39. package/python/postprocessors/test_ctc.py +35 -0
  40. package/dist/chunk-BdkLduGY.mjs +0 -5
  41. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D34ivtL2.mjs +0 -26
@@ -1,4 +1,4 @@
1
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
1
+ //#region ../types/dist/event-category-BLcNejAE.mjs
2
2
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
3
3
  EventCategory["SystemBoot"] = "system.boot";
4
4
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -148,9 +148,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
148
148
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
149
149
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
150
150
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
151
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
152
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
153
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
154
151
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
155
152
  * progress bar the client reconciles via `recordingExport.getExport`. */
156
153
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -7451,47 +7448,6 @@ var ScrubThumbnailPresetSchema = _enum([
7451
7448
  "max"
7452
7449
  ]);
7453
7450
  /**
7454
- * Preset → tile geometry + JPEG quality. Every step is 16:9; the graduated
7455
- * ladder trades sheet size (and remote fetch cost) for scrub crispness.
7456
- * `standard` matches the shipped `sheet-geometry`/`sheet-composer` defaults
7457
- * (480×270 q72), so an unset config is byte-identical to today. The map is
7458
- * strictly monotone in resolution AND quality across the ordered steps.
7459
- */
7460
- var SCRUB_THUMBNAIL_PRESETS = {
7461
- minimal: {
7462
- tileWidth: 240,
7463
- tileHeight: 135,
7464
- quality: 55
7465
- },
7466
- low: {
7467
- tileWidth: 320,
7468
- tileHeight: 180,
7469
- quality: 60
7470
- },
7471
- standard: {
7472
- tileWidth: 480,
7473
- tileHeight: 270,
7474
- quality: 72
7475
- },
7476
- high: {
7477
- tileWidth: 640,
7478
- tileHeight: 360,
7479
- quality: 80
7480
- },
7481
- max: {
7482
- tileWidth: 960,
7483
- tileHeight: 540,
7484
- quality: 85
7485
- }
7486
- };
7487
- /**
7488
- * Resolve the geometry for a recording config's scrub-thumbnail preset,
7489
- * defaulting to `standard` when unset. Pure — no I/O.
7490
- */
7491
- function resolveScrubThumbnailGeometry(preset) {
7492
- return SCRUB_THUMBNAIL_PRESETS[preset ?? "standard"];
7493
- }
7494
- /**
7495
7451
  * The full per-camera recording intent — the wire shape of a RecordingTarget.
7496
7452
  *
7497
7453
  * `mode` is the authoritative storage choice; `schedule`/`triggers`/`pre`/`post`
@@ -8807,6 +8763,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8807
8763
  /** The complete taxonomy dictionary, keyed by kind. */
8808
8764
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8809
8765
  /**
8766
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8767
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8768
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8769
+ * taxonomy surface (timeline, filters, event page).
8770
+ *
8771
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8772
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8773
+ * for the `classes` / `classesExclude` conditions.
8774
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8775
+ * the same class picker, grouped under an Audio header.
8776
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8777
+ * lock / …) for the `sensorKinds` device-event condition.
8778
+ *
8779
+ * Each entry carries `parentKind` so the client can group video subs under
8780
+ * their macro and sensor/control kinds under their category. This surface is
8781
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8782
+ * method, no codegen — so it ships train-free with an addon deploy.
8783
+ */
8784
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8785
+ var NcTaxonomyEntrySchema = object({
8786
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8787
+ kind: string(),
8788
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8789
+ label: string(),
8790
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8791
+ parentKind: string().nullable()
8792
+ });
8793
+ object({
8794
+ videoClasses: array(NcTaxonomyEntrySchema),
8795
+ audioKinds: array(NcTaxonomyEntrySchema),
8796
+ labels: array(NcTaxonomyEntrySchema)
8797
+ });
8798
+ function toEntry(kind, label, parentKind) {
8799
+ return {
8800
+ kind,
8801
+ label,
8802
+ parentKind
8803
+ };
8804
+ }
8805
+ /**
8806
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8807
+ * (macros before their subs), which the client relies on for stable grouping.
8808
+ */
8809
+ function buildNcTaxonomy() {
8810
+ const all = Object.values(EVENT_TAXONOMY);
8811
+ return {
8812
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8813
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8814
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8815
+ };
8816
+ }
8817
+ Object.freeze(buildNcTaxonomy());
8818
+ /**
8810
8819
  * Error types for the safe expression engine. Two distinct classes so callers
8811
8820
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8812
8821
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -14685,94 +14694,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
14685
14694
  bundleUrl: string()
14686
14695
  });
14687
14696
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
14688
- var NotificationRuleConditionsSchema = object({
14689
- deviceIds: array(number()).readonly().optional(),
14690
- classNames: array(string()).readonly().optional(),
14691
- zoneIds: array(string()).readonly().optional(),
14692
- minConfidence: number().optional(),
14693
- source: _enum([
14694
- "pipeline",
14695
- "onboard",
14696
- "any"
14697
- ]).optional(),
14698
- schedule: object({
14699
- days: array(number()).readonly(),
14700
- startHour: number(),
14701
- endHour: number()
14702
- }).optional(),
14703
- cooldownSeconds: number().optional(),
14704
- minDwellSeconds: number().optional(),
14705
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
14706
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
14707
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
14708
- eventTypeTokens: array(string()).readonly().optional(),
14709
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
14710
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
14711
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
14712
- clipDescription: object({
14713
- text: string().min(1),
14714
- minSimilarity: number().min(0).max(1)
14715
- }).optional(),
14716
- /** Match events whose recognized-entity label (face identity name or plate
14717
- * vehicle name, propagated onto `event.data.label`) is one of these values.
14718
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
14719
- * vehicle/person> is seen". */
14720
- labels: array(string()).readonly().optional()
14721
- });
14722
- var NotificationRuleTemplateSchema = object({
14723
- title: string(),
14724
- body: string(),
14725
- imageMode: _enum([
14726
- "crop",
14727
- "annotated",
14728
- "full",
14729
- "none"
14730
- ])
14731
- });
14732
- var NotificationRuleSchema = object({
14733
- id: string(),
14734
- name: string(),
14735
- enabled: boolean(),
14736
- eventTypes: array(string()).readonly(),
14737
- conditions: NotificationRuleConditionsSchema,
14738
- outputs: array(string()).readonly(),
14739
- template: NotificationRuleTemplateSchema.optional(),
14740
- priority: _enum([
14741
- "low",
14742
- "normal",
14743
- "high",
14744
- "critical"
14745
- ])
14746
- });
14747
- var NotificationTestResultSchema = object({
14748
- ruleId: string(),
14749
- eventId: string(),
14750
- timestamp: number(),
14751
- wouldFire: boolean(),
14752
- reason: string().optional()
14753
- });
14754
- var NotificationHistoryEntrySchema = object({
14755
- id: string(),
14756
- ruleId: string(),
14757
- ruleName: string(),
14758
- eventId: string(),
14759
- timestamp: number(),
14760
- outputs: array(string()).readonly(),
14761
- success: boolean(),
14762
- error: string().optional(),
14763
- deviceId: number().optional()
14764
- });
14765
- var NotificationHistoryFilterSchema = object({
14766
- ruleId: string().optional(),
14767
- deviceId: number().optional(),
14768
- from: number().optional(),
14769
- to: number().optional(),
14770
- limit: number().optional()
14771
- });
14772
- method(_void(), object({ rules: array(NotificationRuleSchema).readonly() })), method(object({ rule: NotificationRuleSchema }), object({ success: literal(true) }), { kind: "mutation" }), method(object({ ruleId: string() }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
14773
- ruleId: string(),
14774
- lookbackMinutes: number()
14775
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
14776
14697
  /**
14777
14698
  * Alerts capability — collection-based internal alert system.
14778
14699
  *
@@ -15044,89 +14965,6 @@ method(object({
15044
14965
  password: string()
15045
14966
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
15046
14967
  /**
15047
- * `login-method` — collection cap through which auth addons contribute
15048
- * their pre-auth login surfaces to the login page. This is the SINGLE,
15049
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
15050
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15051
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15052
- * procedure aggregates them for the unauthenticated login page.
15053
- *
15054
- * A contribution is a discriminated union on `kind`:
15055
- *
15056
- * - `redirect` — a declarative button. The login page renders a generic
15057
- * button that navigates to `startUrl` (an addon-owned HTTP route).
15058
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
15059
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
15060
- * login page needs NO change.
15061
- *
15062
- * - `widget` — a Module-Federation widget the login page mounts (via
15063
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
15064
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
15065
- * mechanism kept for future use; no shipped addon uses it on the login
15066
- * page (the passkey ceremony below runs natively in the shell instead).
15067
- *
15068
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
15069
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
15070
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
15071
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
15072
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
15073
- * fetching any remote code pre-auth. Contribution stays unconditional —
15074
- * enrollment state is never leaked pre-auth; visibility is a shell
15075
- * decision.
15076
- *
15077
- * Every contribution carries a `stage`:
15078
- * - `primary` — shown on the first credentials screen (OIDC /
15079
- * magic-link buttons; a future usernameless passkey).
15080
- * - `second-factor` — shown AFTER the password leg, gated on the
15081
- * returned `factors` (passkey-as-2FA today).
15082
- *
15083
- * `mount: skip` — the cap is read server-side by the core auth router
15084
- * (`registry.getCollection('login-method')`), never mounted as its own
15085
- * tRPC router.
15086
- */
15087
- /** When a login method renders in the two-phase login flow. */
15088
- var LoginStageEnum = _enum(["primary", "second-factor"]);
15089
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
15090
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
15091
- object({
15092
- kind: literal("redirect"),
15093
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
15094
- id: string(),
15095
- /** Operator-facing button label. */
15096
- label: string(),
15097
- /** lucide-react icon name. */
15098
- icon: string().optional(),
15099
- /** Addon-owned HTTP route the button navigates to (GET). */
15100
- startUrl: string(),
15101
- stage: LoginStageEnum
15102
- }),
15103
- object({
15104
- kind: literal("widget"),
15105
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
15106
- id: string(),
15107
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
15108
- addonId: string(),
15109
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
15110
- bundle: string(),
15111
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
15112
- remote: WidgetRemoteSchema,
15113
- stage: LoginStageEnum
15114
- }),
15115
- object({
15116
- kind: literal("passkey"),
15117
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
15118
- id: string(),
15119
- /** Operator-facing button label. */
15120
- label: string(),
15121
- stage: LoginStageEnum,
15122
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
15123
- rpId: string(),
15124
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
15125
- origin: string().nullable()
15126
- })
15127
- ]);
15128
- method(_void(), array(LoginMethodContributionSchema).readonly());
15129
- /**
15130
14968
  * Orchestrator-side destination metadata. The orchestrator computes
15131
14969
  * `id = <addonId>:<subId>` from its provider lookup so consumers
15132
14970
  * (admin UI, restore flow) see one canonical key.
@@ -15500,7 +15338,8 @@ function customAction(input, output, options) {
15500
15338
  output,
15501
15339
  kind: options?.kind ?? "query",
15502
15340
  auth: options?.auth ?? "protected",
15503
- scope: options?.scope ?? { kind: "system" }
15341
+ scope: options?.scope ?? { kind: "system" },
15342
+ ...options?.caller ? { caller: "required" } : {}
15504
15343
  };
15505
15344
  }
15506
15345
  /**
@@ -16522,55 +16361,430 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
16522
16361
  kind: "mutation",
16523
16362
  auth: "admin"
16524
16363
  });
16525
- var LogLevelSchema = _enum([
16526
- "debug",
16527
- "info",
16528
- "warn",
16529
- "error"
16364
+ /**
16365
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
16366
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
16367
+ * caps stay wire-compatible without a circular cap→cap import.
16368
+ *
16369
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
16370
+ * every transport tier structurally, and failed calls still write usage rows.
16371
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16372
+ */
16373
+ var LlmUsageSchema = object({
16374
+ inputTokens: number(),
16375
+ outputTokens: number()
16376
+ });
16377
+ var LlmErrorCodeSchema = _enum([
16378
+ "timeout",
16379
+ "rate-limited",
16380
+ "auth",
16381
+ "refusal",
16382
+ "bad-request",
16383
+ "unavailable",
16384
+ "no-profile",
16385
+ "budget-exceeded",
16386
+ "adapter-error"
16530
16387
  ]);
16531
- var LogEntrySchema = object({
16532
- timestamp: date(),
16533
- level: LogLevelSchema,
16534
- scope: array(string()),
16388
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16389
+ ok: literal(true),
16390
+ text: string(),
16391
+ model: string(),
16392
+ usage: LlmUsageSchema,
16393
+ truncated: boolean(),
16394
+ latencyMs: number()
16395
+ }), object({
16396
+ ok: literal(false),
16397
+ code: LlmErrorCodeSchema,
16535
16398
  message: string(),
16536
- meta: record(string(), unknown()).optional(),
16537
- tags: record(string(), string()).optional()
16538
- });
16539
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16540
- scope: array(string()).optional(),
16541
- level: LogLevelSchema.optional(),
16542
- since: date().optional(),
16543
- until: date().optional(),
16544
- limit: number().optional(),
16545
- tags: record(string(), string()).optional()
16546
- }), array(LogEntrySchema).readonly());
16547
- var CpuBreakdownSchema = object({
16548
- total: number(),
16549
- user: number(),
16550
- system: number(),
16551
- irq: number(),
16552
- nice: number(),
16553
- loadAvg: tuple([
16554
- number(),
16555
- number(),
16556
- number()
16557
- ]),
16558
- cores: number()
16559
- });
16560
- var MemoryInfoSchema = object({
16561
- percent: number(),
16562
- totalBytes: number(),
16563
- usedBytes: number(),
16564
- availableBytes: number(),
16565
- swapUsedBytes: number(),
16566
- swapTotalBytes: number()
16399
+ retryAfterMs: number().optional()
16400
+ })]);
16401
+ /**
16402
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
16403
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
16404
+ * notification-output.cap.ts:27-31 precedents).
16405
+ */
16406
+ var LlmImageSchema = object({
16407
+ bytes: _instanceof(Uint8Array),
16408
+ mimeType: string()
16567
16409
  });
16568
- var DiskIoSnapshotSchema = object({
16569
- readBytes: number(),
16570
- writeBytes: number(),
16571
- readOps: number(),
16572
- writeOps: number(),
16573
- timestampMs: number()
16410
+ var LlmGenerateBaseInputSchema = object({
16411
+ /** Collection routing (the notification-output posture). */
16412
+ addonId: string().optional(),
16413
+ /** Explicit profile; else the resolution chain (spec §3). */
16414
+ profileId: string().optional(),
16415
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
16416
+ consumer: string(),
16417
+ system: string().optional(),
16418
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
16419
+ prompt: string(),
16420
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
16421
+ jsonSchema: record(string(), unknown()).optional(),
16422
+ /** Per-call override of the profile default. */
16423
+ maxTokens: number().int().positive().optional(),
16424
+ temperature: number().optional()
16425
+ });
16426
+ /**
16427
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
16428
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
16429
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
16430
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
16431
+ * this only through the `llm` cap's methods.
16432
+ *
16433
+ * One running llama-server child per node in v1 (models are RAM-heavy).
16434
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
16435
+ * watchdog — operator decision #3).
16436
+ */
16437
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
16438
+ object({
16439
+ kind: literal("catalog"),
16440
+ catalogId: string()
16441
+ }),
16442
+ object({
16443
+ kind: literal("url"),
16444
+ url: string(),
16445
+ sha256: string().optional()
16446
+ }),
16447
+ object({
16448
+ kind: literal("path"),
16449
+ path: string()
16450
+ })
16451
+ ]);
16452
+ var ManagedRuntimeConfigSchema = object({
16453
+ /** WHERE the runtime lives — hub or any agent. */
16454
+ nodeId: string(),
16455
+ /** Closed for v1; 'ollama' is a v2 candidate. */
16456
+ engine: _enum(["llama-cpp"]),
16457
+ model: ManagedModelRefSchema,
16458
+ contextSize: number().int().default(4096),
16459
+ /** 0 = CPU-only. */
16460
+ gpuLayers: number().int().default(0),
16461
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16462
+ threads: number().int().optional(),
16463
+ /** Concurrent slots. */
16464
+ parallel: number().int().default(1),
16465
+ /** Else lazy: first generate boots it. */
16466
+ autoStart: boolean().default(false),
16467
+ /** 0 = never; frees RAM after quiet periods. */
16468
+ idleStopMinutes: number().int().default(30)
16469
+ });
16470
+ var LlmRuntimeStatusSchema = object({
16471
+ /** Status is ALWAYS node-qualified. */
16472
+ nodeId: string(),
16473
+ state: _enum([
16474
+ "stopped",
16475
+ "downloading",
16476
+ "starting",
16477
+ "ready",
16478
+ "crashed",
16479
+ "failed"
16480
+ ]),
16481
+ pid: number().optional(),
16482
+ port: number().optional(),
16483
+ modelPath: string().optional(),
16484
+ modelId: string().optional(),
16485
+ downloadProgress: number().min(0).max(1).optional(),
16486
+ lastError: string().optional(),
16487
+ crashesInWindow: number(),
16488
+ /** Child RSS (sampled best-effort). */
16489
+ memoryBytes: number().optional(),
16490
+ vramBytes: number().optional()
16491
+ });
16492
+ var LlmNodeModelSchema = object({
16493
+ file: string(),
16494
+ sizeBytes: number(),
16495
+ catalogId: string().optional(),
16496
+ installedAt: number().optional()
16497
+ });
16498
+ var LlmRuntimeDiskUsageSchema = object({
16499
+ nodeId: string(),
16500
+ modelsBytes: number(),
16501
+ freeBytes: number().optional()
16502
+ });
16503
+ method(LlmGenerateBaseInputSchema.extend({
16504
+ images: array(LlmImageSchema).optional(),
16505
+ runtime: ManagedRuntimeConfigSchema,
16506
+ /** The managed profile's timeout, threaded by the hub provider. */
16507
+ timeoutMs: number().int().positive().optional()
16508
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
16509
+ kind: "mutation",
16510
+ auth: "admin"
16511
+ }), method(object({}), _void(), {
16512
+ kind: "mutation",
16513
+ auth: "admin"
16514
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
16515
+ kind: "mutation",
16516
+ auth: "admin"
16517
+ }), method(object({ file: string() }), _void(), {
16518
+ kind: "mutation",
16519
+ auth: "admin"
16520
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16521
+ /**
16522
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16523
+ * methods concat-fan across providers; single-row methods route to ONE
16524
+ * provider by the `addonId` in the call input (the notification-output
16525
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16526
+ * (hub-placed); the cap stays open for future providers.
16527
+ *
16528
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16529
+ * `apiKey` is a password field — providers REDACT it on read and merge on
16530
+ * write; a stored key NEVER round-trips to a client.
16531
+ */
16532
+ var LlmProfileKindSchema = _enum([
16533
+ "openai-compatible",
16534
+ "openai",
16535
+ "anthropic",
16536
+ "google",
16537
+ "managed-local"
16538
+ ]);
16539
+ var LlmProfileSchema = object({
16540
+ id: string(),
16541
+ name: string(),
16542
+ kind: LlmProfileKindSchema,
16543
+ /** Stamped by the provider — keeps the fanned catalog routable. */
16544
+ addonId: string(),
16545
+ enabled: boolean(),
16546
+ /** Vendor model id, or the managed runtime's loaded model. */
16547
+ model: string(),
16548
+ /** Required for openai-compatible; override for cloud kinds. */
16549
+ baseUrl: string().optional(),
16550
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16551
+ apiKey: string().optional(),
16552
+ supportsVision: boolean(),
16553
+ temperature: number().min(0).max(2).optional(),
16554
+ maxTokens: number().int().positive().optional(),
16555
+ timeoutMs: number().int().positive().default(6e4),
16556
+ extraHeaders: record(string(), string()).optional(),
16557
+ /** kind === 'managed-local' only (spec §4). */
16558
+ runtime: ManagedRuntimeConfigSchema.optional()
16559
+ });
16560
+ /** ConfigUISchema tree passed through untyped on the wire (the
16561
+ * notification-output `ConfigSchemaPassthrough` precedent at
16562
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16563
+ var ConfigSchemaPassthrough$1 = unknown();
16564
+ var LlmProfileKindDescriptorSchema = object({
16565
+ kind: LlmProfileKindSchema,
16566
+ label: string(),
16567
+ icon: string(),
16568
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
16569
+ addonId: string(),
16570
+ configSchema: ConfigSchemaPassthrough$1
16571
+ });
16572
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16573
+ var LlmDefaultSchema = object({
16574
+ selector: LlmDefaultSelectorSchema,
16575
+ profileId: string()
16576
+ });
16577
+ /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16578
+ var LlmUsageRollupSchema = object({
16579
+ day: string(),
16580
+ consumer: string(),
16581
+ profileId: string(),
16582
+ calls: number(),
16583
+ okCalls: number(),
16584
+ errorCalls: number(),
16585
+ inputTokens: number(),
16586
+ outputTokens: number(),
16587
+ avgLatencyMs: number()
16588
+ });
16589
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16590
+ var ManagedModelCatalogEntrySchema = object({
16591
+ id: string(),
16592
+ label: string(),
16593
+ family: string(),
16594
+ purpose: _enum(["text", "vision"]),
16595
+ url: string(),
16596
+ sha256: string(),
16597
+ sizeBytes: number(),
16598
+ quantization: string(),
16599
+ /** Load-time guidance shown in the picker. */
16600
+ minRamBytes: number(),
16601
+ contextSizeDefault: number().int(),
16602
+ /** Vision models: companion projector file. */
16603
+ mmprojUrl: string().optional()
16604
+ });
16605
+ var LlmRuntimeNodeSchema = object({
16606
+ nodeId: string(),
16607
+ reachable: boolean(),
16608
+ status: LlmRuntimeStatusSchema.optional(),
16609
+ disk: LlmRuntimeDiskUsageSchema.optional(),
16610
+ error: string().optional()
16611
+ });
16612
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16613
+ var ProfileRefInputSchema = object({
16614
+ addonId: string(),
16615
+ profileId: string()
16616
+ });
16617
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16618
+ kind: "mutation",
16619
+ auth: "admin"
16620
+ }), method(ProfileRefInputSchema, _void(), {
16621
+ kind: "mutation",
16622
+ auth: "admin"
16623
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16624
+ kind: "mutation",
16625
+ auth: "admin"
16626
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16627
+ selector: LlmDefaultSelectorSchema,
16628
+ profileId: string().nullable()
16629
+ }), _void(), {
16630
+ kind: "mutation",
16631
+ auth: "admin"
16632
+ }), method(object({
16633
+ since: number().optional(),
16634
+ until: number().optional(),
16635
+ consumer: string().optional(),
16636
+ profileId: string().optional()
16637
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16638
+ nodeId: string(),
16639
+ model: ManagedModelRefSchema
16640
+ }), _void(), {
16641
+ kind: "mutation",
16642
+ auth: "admin"
16643
+ }), method(object({
16644
+ nodeId: string(),
16645
+ file: string()
16646
+ }), _void(), {
16647
+ kind: "mutation",
16648
+ auth: "admin"
16649
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16650
+ kind: "mutation",
16651
+ auth: "admin"
16652
+ }), method(ProfileRefInputSchema, _void(), {
16653
+ kind: "mutation",
16654
+ auth: "admin"
16655
+ });
16656
+ var LogLevelSchema = _enum([
16657
+ "debug",
16658
+ "info",
16659
+ "warn",
16660
+ "error"
16661
+ ]);
16662
+ var LogEntrySchema = object({
16663
+ timestamp: date(),
16664
+ level: LogLevelSchema,
16665
+ scope: array(string()),
16666
+ message: string(),
16667
+ meta: record(string(), unknown()).optional(),
16668
+ tags: record(string(), string()).optional()
16669
+ });
16670
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
16671
+ scope: array(string()).optional(),
16672
+ level: LogLevelSchema.optional(),
16673
+ since: date().optional(),
16674
+ until: date().optional(),
16675
+ limit: number().optional(),
16676
+ tags: record(string(), string()).optional()
16677
+ }), array(LogEntrySchema).readonly());
16678
+ /**
16679
+ * `login-method` — collection cap through which auth addons contribute
16680
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
16681
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
16682
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
16683
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
16684
+ * procedure aggregates them for the unauthenticated login page.
16685
+ *
16686
+ * A contribution is a discriminated union on `kind`:
16687
+ *
16688
+ * - `redirect` — a declarative button. The login page renders a generic
16689
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
16690
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
16691
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
16692
+ * login page needs NO change.
16693
+ *
16694
+ * - `widget` — a Module-Federation widget the login page mounts (via
16695
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
16696
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
16697
+ * mechanism kept for future use; no shipped addon uses it on the login
16698
+ * page (the passkey ceremony below runs natively in the shell instead).
16699
+ *
16700
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
16701
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
16702
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
16703
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
16704
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
16705
+ * fetching any remote code pre-auth. Contribution stays unconditional —
16706
+ * enrollment state is never leaked pre-auth; visibility is a shell
16707
+ * decision.
16708
+ *
16709
+ * Every contribution carries a `stage`:
16710
+ * - `primary` — shown on the first credentials screen (OIDC /
16711
+ * magic-link buttons; a future usernameless passkey).
16712
+ * - `second-factor` — shown AFTER the password leg, gated on the
16713
+ * returned `factors` (passkey-as-2FA today).
16714
+ *
16715
+ * `mount: skip` — the cap is read server-side by the core auth router
16716
+ * (`registry.getCollection('login-method')`), never mounted as its own
16717
+ * tRPC router.
16718
+ */
16719
+ /** When a login method renders in the two-phase login flow. */
16720
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
16721
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
16722
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
16723
+ object({
16724
+ kind: literal("redirect"),
16725
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
16726
+ id: string(),
16727
+ /** Operator-facing button label. */
16728
+ label: string(),
16729
+ /** lucide-react icon name. */
16730
+ icon: string().optional(),
16731
+ /** Addon-owned HTTP route the button navigates to (GET). */
16732
+ startUrl: string(),
16733
+ stage: LoginStageEnum
16734
+ }),
16735
+ object({
16736
+ kind: literal("widget"),
16737
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
16738
+ id: string(),
16739
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
16740
+ addonId: string(),
16741
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
16742
+ bundle: string(),
16743
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
16744
+ remote: WidgetRemoteSchema,
16745
+ stage: LoginStageEnum
16746
+ }),
16747
+ object({
16748
+ kind: literal("passkey"),
16749
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
16750
+ id: string(),
16751
+ /** Operator-facing button label. */
16752
+ label: string(),
16753
+ stage: LoginStageEnum,
16754
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
16755
+ rpId: string(),
16756
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
16757
+ origin: string().nullable()
16758
+ })
16759
+ ]);
16760
+ method(_void(), array(LoginMethodContributionSchema).readonly());
16761
+ var CpuBreakdownSchema = object({
16762
+ total: number(),
16763
+ user: number(),
16764
+ system: number(),
16765
+ irq: number(),
16766
+ nice: number(),
16767
+ loadAvg: tuple([
16768
+ number(),
16769
+ number(),
16770
+ number()
16771
+ ]),
16772
+ cores: number()
16773
+ });
16774
+ var MemoryInfoSchema = object({
16775
+ percent: number(),
16776
+ totalBytes: number(),
16777
+ usedBytes: number(),
16778
+ availableBytes: number(),
16779
+ swapUsedBytes: number(),
16780
+ swapTotalBytes: number()
16781
+ });
16782
+ var DiskIoSnapshotSchema = object({
16783
+ readBytes: number(),
16784
+ writeBytes: number(),
16785
+ readOps: number(),
16786
+ writeOps: number(),
16787
+ timestampMs: number()
16574
16788
  });
16575
16789
  var NetworkIoSnapshotSchema = object({
16576
16790
  rxBytes: number(),
@@ -17016,14 +17230,14 @@ var TargetKindCapsSchema = object({
17016
17230
  * the union is large and not meant for runtime validation here; the exported
17017
17231
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
17018
17232
  */
17019
- var ConfigSchemaPassthrough$1 = unknown();
17233
+ var ConfigSchemaPassthrough = unknown();
17020
17234
  var TargetKindSchema = object({
17021
17235
  kind: string(),
17022
17236
  label: string(),
17023
17237
  icon: string(),
17024
17238
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
17025
17239
  addonId: string(),
17026
- configSchema: ConfigSchemaPassthrough$1,
17240
+ configSchema: ConfigSchemaPassthrough,
17027
17241
  supportsDiscovery: boolean(),
17028
17242
  caps: TargetKindCapsSchema
17029
17243
  });
@@ -17105,8 +17319,27 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
17105
17319
  * `z.infer` exports; no duplicate interfaces (the advanced-notifier
17106
17320
  * schema/interface drift is explicitly not repeated).
17107
17321
  */
17108
- /** D-3: the urgency of a rule — which persistence moment evaluates it. */
17109
- var NcDeliverySchema = _enum(["immediate", "track-end"]);
17322
+ /**
17323
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
17324
+ * The value maps 1:1 onto the evaluated record kind:
17325
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
17326
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
17327
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
17328
+ * change of a LINKED device, one row per linked camera)
17329
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
17330
+ * delivery / pick-up)
17331
+ *
17332
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
17333
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
17334
+ * this one field keeps the schema additive — a rule still declares exactly
17335
+ * one trigger.
17336
+ */
17337
+ var NcDeliverySchema = _enum([
17338
+ "immediate",
17339
+ "track-end",
17340
+ "device-event",
17341
+ "package-event"
17342
+ ]);
17110
17343
  /** Weekly schedule — OR of windows; absence on the rule = always active. */
17111
17344
  var NcScheduleSchema = object({
17112
17345
  windows: array(object({
@@ -17126,6 +17359,33 @@ var NcPlateMatcherSchema = object({
17126
17359
  /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
17127
17360
  maxDistance: number().int().min(0).max(3).default(1)
17128
17361
  });
17362
+ /**
17363
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
17364
+ * occupancy edge for a device — optionally narrowed to a single admin
17365
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
17366
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
17367
+ * - `became-free` — count crossed ≥ `count` → below it
17368
+ * - `>=` / `<=` — count is at/over or at/under `count`
17369
+ * `sustainSeconds` requires the condition hold continuously that long
17370
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
17371
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
17372
+ * the condition never matches. Confirmed edge-state survives addon restarts
17373
+ * (declared SQLite collection, reseeded on boot).
17374
+ */
17375
+ var NcOccupancyConditionSchema = object({
17376
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
17377
+ zoneId: string().optional(),
17378
+ /** Object class to count; absent = any class. */
17379
+ className: string().optional(),
17380
+ op: _enum([
17381
+ "became-occupied",
17382
+ "became-free",
17383
+ ">=",
17384
+ "<="
17385
+ ]).default("became-occupied"),
17386
+ count: number().int().min(0).default(1),
17387
+ sustainSeconds: number().int().min(0).max(3600).default(15)
17388
+ });
17129
17389
  /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
17130
17390
  var NcZoneConditionSchema = object({
17131
17391
  ids: array(string().min(1)).min(1),
@@ -17161,7 +17421,104 @@ var NcConditionsSchema = object({
17161
17421
  */
17162
17422
  identities: array(string().min(1)).optional(),
17163
17423
  /** Fuzzy plate matcher against the record's `label` (plate text). */
17164
- plates: NcPlateMatcherSchema.optional()
17424
+ plates: NcPlateMatcherSchema.optional(),
17425
+ /**
17426
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
17427
+ * Same P1 boundary: matched against the record's collapsed `label` (the
17428
+ * identity display name). A record with NO label passes (nothing to
17429
+ * exclude), unlike the include variant which fails on an absent label.
17430
+ */
17431
+ identitiesExclude: array(string().min(1)).optional(),
17432
+ /**
17433
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
17434
+ * TRACK-END only: importance is scored at track close, so it does not exist
17435
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
17436
+ * close the value is threaded via the close-time info (the `Track` clone is
17437
+ * captured before the DB row is updated, so it would otherwise read stale).
17438
+ * Fails when the record carries no importance (never guess quality — the
17439
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
17440
+ */
17441
+ minImportance: number().min(0).max(1).optional(),
17442
+ /**
17443
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
17444
+ * TRACK-END only: an `immediate` / object-event subject has no closed
17445
+ * lifespan, so a dwell condition never matches immediate delivery
17446
+ * (documented choice — the object-event record carries no `firstSeen`,
17447
+ * so dwell cannot be computed from what the subject actually carries).
17448
+ */
17449
+ minDwellSeconds: number().min(0).optional(),
17450
+ /**
17451
+ * Detection provenance filter. `any` (default / absent) matches every
17452
+ * source; otherwise the subject's source must equal it. Legacy records
17453
+ * with no stamped source are treated as `pipeline`. The union spans both
17454
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
17455
+ * tracks carry `sensor`.
17456
+ */
17457
+ source: _enum([
17458
+ "pipeline",
17459
+ "onboard",
17460
+ "sensor",
17461
+ "any"
17462
+ ]).optional(),
17463
+ /**
17464
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
17465
+ * detector `minConfidence` (that gates the object-detection score; this
17466
+ * gates the recognition/OCR match score). Fails when the subject carries
17467
+ * no label-match confidence (never guess). TRACK-END only: the confidence
17468
+ * lives on the recognition result and reaches the subject at track close.
17469
+ *
17470
+ * What it measures precisely (plumbed at track close — the closer threads
17471
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
17472
+ * `importance`): the BEST recognition match confidence observed for the
17473
+ * label the track carries at close — for a face, the peak cosine similarity
17474
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
17475
+ * for a plate, the peak OCR read score of the best-held plate
17476
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
17477
+ * one track the higher of the two is used. A track that ended with no
17478
+ * confident identity/plate match carries no value, so the condition fails
17479
+ * closed for it (an un-recognized subject).
17480
+ */
17481
+ minLabelConfidence: number().min(0).max(1).optional(),
17482
+ /**
17483
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
17484
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
17485
+ * against the token carried on the device-event subject (extracted from the
17486
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
17487
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
17488
+ * eventType, so gate those with {@link sensorKinds} instead.
17489
+ */
17490
+ eventTypeTokens: array(string().min(1)).optional(),
17491
+ /**
17492
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
17493
+ * `contact`, `button`, `device-event`) — matched against the persisted
17494
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
17495
+ */
17496
+ sensorKinds: array(string().min(1)).optional(),
17497
+ /**
17498
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
17499
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
17500
+ * when the subject's phase does not match (a subject always carries a phase
17501
+ * on the package-event trigger).
17502
+ */
17503
+ packagePhase: _enum([
17504
+ "delivered",
17505
+ "picked-up",
17506
+ "both"
17507
+ ]).optional(),
17508
+ /**
17509
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
17510
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
17511
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
17512
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
17513
+ */
17514
+ customZones: array(MaskPolygonShapeSchema).optional(),
17515
+ /**
17516
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
17517
+ * (optionally zone/class-scoped) occupancy count crosses the configured
17518
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
17519
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
17520
+ */
17521
+ occupancy: NcOccupancyConditionSchema.optional()
17165
17522
  });
17166
17523
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
17167
17524
  var NcRuleTargetSchema = object({
@@ -17175,12 +17532,21 @@ var NcRuleTargetSchema = object({
17175
17532
  params: record(string(), unknown()).optional()
17176
17533
  });
17177
17534
  /**
17178
- * Media attachment policy (P1 still-image subset). `best` = the best
17179
- * AVAILABLE media at dispatch time (D-3); `best-matching` (track-end
17180
- * condition-best) is deferred operator open point.
17535
+ * Media attachment policy (P1 still-image subset).
17536
+ * - `best` — the best AVAILABLE subject image at dispatch time (D-3).
17537
+ * - `best-matching` the media that explains WHY the rule fired: a rule
17538
+ * matched on identities attaches the subject's `faceCrop`, one matched on
17539
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
17540
+ * (or when the specific crop is missing) degrades to `best`, then
17541
+ * `keyFrame`, then no attachment — never delaying the send. The matched
17542
+ * condition summary is frozen on the outbox row at enqueue (like the rule
17543
+ * name), so the choice never drifts from the record that fired it.
17544
+ * - `keyFrame` — the clean scene frame (no subject box).
17545
+ * - `none` — no attachment.
17181
17546
  */
17182
17547
  var NcMediaPolicySchema = object({ attach: _enum([
17183
17548
  "best",
17549
+ "best-matching",
17184
17550
  "keyFrame",
17185
17551
  "none"
17186
17552
  ]).default("best") });
@@ -17209,21 +17575,46 @@ var NcRuleInputSchema = object({
17209
17575
  body: string().max(2e3).optional()
17210
17576
  }).optional(),
17211
17577
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
17212
- priority: number().int().min(1).max(5).default(3)
17578
+ priority: number().int().min(1).max(5).default(3),
17579
+ /**
17580
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
17581
+ * behaviour, visible to all, read-only in the viewer). Present = personal
17582
+ * rule owned by this userId. Server-stamped; never trusted from a client.
17583
+ */
17584
+ ownerUserId: string().optional()
17213
17585
  });
17214
- /** Partial patch for `updateRule` — any subset of the input fields. */
17215
- var NcRulePatchSchema = NcRuleInputSchema.partial();
17586
+ /**
17587
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
17588
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
17589
+ * NOT a client-authored input field (it lives on the persisted rule, not the
17590
+ * input), so it is added here explicitly to let the store's per-target opt-out
17591
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
17592
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
17593
+ * `updateRule` patch.
17594
+ */
17595
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
17216
17596
  /** A persisted rule. */
17217
17597
  var NcRuleSchema = NcRuleInputSchema.extend({
17218
17598
  id: string(),
17219
17599
  /** userId of the admin who created the rule (server-stamped caller). */
17220
17600
  createdBy: string(),
17221
17601
  createdAt: number(),
17222
- updatedAt: number()
17602
+ updatedAt: number(),
17603
+ /**
17604
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
17605
+ * send time. Only a target's OWNER may add/remove its id (server-checked
17606
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
17607
+ */
17608
+ disabledTargetIds: array(string()).default([])
17223
17609
  });
17224
17610
  var NcTestResultSchema = object({
17225
17611
  recordId: string(),
17226
- recordKind: _enum(["object-event", "track"]),
17612
+ recordKind: _enum([
17613
+ "object-event",
17614
+ "track",
17615
+ "device-event",
17616
+ "package-event"
17617
+ ]),
17227
17618
  deviceId: number(),
17228
17619
  timestamp: number(),
17229
17620
  wouldFire: boolean(),
@@ -17241,7 +17632,10 @@ var NcConditionDescriptorSchema = object({
17241
17632
  "zones",
17242
17633
  "quality",
17243
17634
  "label",
17244
- "schedule"
17635
+ "schedule",
17636
+ "device",
17637
+ "package",
17638
+ "occupancy"
17245
17639
  ]),
17246
17640
  label: string(),
17247
17641
  /** Editor widget the UI renders — never hardcode per-condition forms. */
@@ -17249,10 +17643,15 @@ var NcConditionDescriptorSchema = object({
17249
17643
  "deviceIdList",
17250
17644
  "stringList",
17251
17645
  "number01",
17646
+ "number",
17647
+ "sourceSelect",
17252
17648
  "zoneSelection",
17253
17649
  "zoneIdList",
17254
17650
  "schedule",
17255
- "plateMatcher"
17651
+ "plateMatcher",
17652
+ "packagePhase",
17653
+ "polygonDraw",
17654
+ "occupancy"
17256
17655
  ]),
17257
17656
  operator: _enum([
17258
17657
  "in",
@@ -17268,325 +17667,116 @@ var NcConditionDescriptorSchema = object({
17268
17667
  phase: string(),
17269
17668
  description: string().optional()
17270
17669
  });
17271
- method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), method(object({ ruleId: string() }), object({ rule: NcRuleSchema.nullable() }), { auth: "admin" }), method(object({ rule: NcRuleInputSchema }), object({ rule: NcRuleSchema }), {
17272
- kind: "mutation",
17273
- auth: "admin",
17274
- caller: "required"
17275
- }), method(object({
17276
- ruleId: string(),
17277
- patch: NcRulePatchSchema
17278
- }), object({ rule: NcRuleSchema }), {
17279
- kind: "mutation",
17280
- auth: "admin",
17281
- caller: "required"
17282
- }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
17283
- kind: "mutation",
17284
- auth: "admin"
17285
- }), method(object({
17286
- ruleId: string(),
17287
- enabled: boolean()
17288
- }), object({ success: literal(true) }), {
17289
- kind: "mutation",
17290
- auth: "admin"
17291
- }), method(object({
17292
- rule: NcRuleInputSchema,
17293
- lookbackMinutes: number().int().min(1).max(1440).default(60)
17294
- }), object({ results: array(NcTestResultSchema) }), {
17295
- kind: "mutation",
17296
- auth: "admin"
17297
- }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) }));
17298
- /**
17299
- * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
17300
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
17301
- * caps stay wire-compatible without a circular cap→cap import.
17302
- *
17303
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
17304
- * every transport tier structurally, and failed calls still write usage rows.
17305
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
17306
- */
17307
- var LlmUsageSchema = object({
17308
- inputTokens: number(),
17309
- outputTokens: number()
17310
- });
17311
- var LlmErrorCodeSchema = _enum([
17312
- "timeout",
17313
- "rate-limited",
17314
- "auth",
17315
- "refusal",
17316
- "bad-request",
17317
- "unavailable",
17318
- "no-profile",
17319
- "budget-exceeded",
17320
- "adapter-error"
17321
- ]);
17322
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
17323
- ok: literal(true),
17324
- text: string(),
17325
- model: string(),
17326
- usage: LlmUsageSchema,
17327
- truncated: boolean(),
17328
- latencyMs: number()
17329
- }), object({
17330
- ok: literal(false),
17331
- code: LlmErrorCodeSchema,
17332
- message: string(),
17333
- retryAfterMs: number().optional()
17334
- })]);
17335
- /**
17336
- * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
17337
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
17338
- * notification-output.cap.ts:27-31 precedents).
17339
- */
17340
- var LlmImageSchema = object({
17341
- bytes: _instanceof(Uint8Array),
17342
- mimeType: string()
17343
- });
17344
- var LlmGenerateBaseInputSchema = object({
17345
- /** Collection routing (the notification-output posture). */
17346
- addonId: string().optional(),
17347
- /** Explicit profile; else the resolution chain (spec §3). */
17348
- profileId: string().optional(),
17349
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
17350
- consumer: string(),
17351
- system: string().optional(),
17352
- /** v1: single-turn. `messages[]` is a v2 additive field. */
17353
- prompt: string(),
17354
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
17355
- jsonSchema: record(string(), unknown()).optional(),
17356
- /** Per-call override of the profile default. */
17357
- maxTokens: number().int().positive().optional(),
17358
- temperature: number().optional()
17359
- });
17360
17670
  /**
17361
- * `llm-runtime` node-side managed llama.cpp executor (spec §4). Registered
17362
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
17363
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` normal
17364
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
17365
- * this only through the `llm` cap's methods.
17671
+ * The delivery lifecycle status of a history row — a straight read of the
17672
+ * durable outbox row's own status (single source of truth):
17673
+ * - `pending` enqueued, in-flight or retrying with backoff
17674
+ * - `sent` — delivered (terminal)
17675
+ * - `dead` — dead-lettered after exhausting retries / a permanent
17676
+ * backend rejection / a deleted target (terminal; carries
17677
+ * the failure `error`)
17366
17678
  *
17367
- * One running llama-server child per node in v1 (models are RAM-heavy).
17368
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
17369
- * watchdog — operator decision #3).
17679
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states those ride the P2
17680
+ * user dimension (quiet hours / snooze) and are additive when they land.
17370
17681
  */
17371
- var ManagedModelRefSchema = discriminatedUnion("kind", [
17372
- object({
17373
- kind: literal("catalog"),
17374
- catalogId: string()
17375
- }),
17376
- object({
17377
- kind: literal("url"),
17378
- url: string(),
17379
- sha256: string().optional()
17380
- }),
17381
- object({
17382
- kind: literal("path"),
17383
- path: string()
17384
- })
17682
+ var NcHistoryStatusSchema = _enum([
17683
+ "pending",
17684
+ "sent",
17685
+ "dead"
17385
17686
  ]);
17386
- var ManagedRuntimeConfigSchema = object({
17387
- /** WHERE the runtime lives — hub or any agent. */
17388
- nodeId: string(),
17389
- /** Closed for v1; 'ollama' is a v2 candidate. */
17390
- engine: _enum(["llama-cpp"]),
17391
- model: ManagedModelRefSchema,
17392
- contextSize: number().int().default(4096),
17393
- /** 0 = CPU-only. */
17394
- gpuLayers: number().int().default(0),
17395
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
17396
- threads: number().int().optional(),
17397
- /** Concurrent slots. */
17398
- parallel: number().int().default(1),
17399
- /** Else lazy: first generate boots it. */
17400
- autoStart: boolean().default(false),
17401
- /** 0 = never; frees RAM after quiet periods. */
17402
- idleStopMinutes: number().int().default(30)
17403
- });
17404
- var LlmRuntimeStatusSchema = object({
17405
- /** Status is ALWAYS node-qualified. */
17406
- nodeId: string(),
17407
- state: _enum([
17408
- "stopped",
17409
- "downloading",
17410
- "starting",
17411
- "ready",
17412
- "crashed",
17413
- "failed"
17414
- ]),
17415
- pid: number().optional(),
17416
- port: number().optional(),
17417
- modelPath: string().optional(),
17418
- modelId: string().optional(),
17419
- downloadProgress: number().min(0).max(1).optional(),
17420
- lastError: string().optional(),
17421
- crashesInWindow: number(),
17422
- /** Child RSS (sampled best-effort). */
17423
- memoryBytes: number().optional(),
17424
- vramBytes: number().optional()
17425
- });
17426
- var LlmNodeModelSchema = object({
17427
- file: string(),
17428
- sizeBytes: number(),
17429
- catalogId: string().optional(),
17430
- installedAt: number().optional()
17431
- });
17432
- var LlmRuntimeDiskUsageSchema = object({
17433
- nodeId: string(),
17434
- modelsBytes: number(),
17435
- freeBytes: number().optional()
17436
- });
17437
- method(LlmGenerateBaseInputSchema.extend({
17438
- images: array(LlmImageSchema).optional(),
17439
- runtime: ManagedRuntimeConfigSchema,
17440
- /** The managed profile's timeout, threaded by the hub provider. */
17441
- timeoutMs: number().int().positive().optional()
17442
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
17443
- kind: "mutation",
17444
- auth: "admin"
17445
- }), method(object({}), _void(), {
17446
- kind: "mutation",
17447
- auth: "admin"
17448
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
17449
- kind: "mutation",
17450
- auth: "admin"
17451
- }), method(object({ file: string() }), _void(), {
17452
- kind: "mutation",
17453
- auth: "admin"
17454
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
17455
- /**
17456
- * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
17457
- * methods concat-fan across providers; single-row methods route to ONE
17458
- * provider by the `addonId` in the call input (the notification-output
17459
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
17460
- * (hub-placed); the cap stays open for future providers.
17461
- *
17462
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
17463
- * `apiKey` is a password field — providers REDACT it on read and merge on
17464
- * write; a stored key NEVER round-trips to a client.
17465
- */
17466
- var LlmProfileKindSchema = _enum([
17467
- "openai-compatible",
17468
- "openai",
17469
- "anthropic",
17470
- "google",
17471
- "managed-local"
17687
+ /** The evaluated record kind a history row descends from (one per trigger). */
17688
+ var NcHistoryRecordKindSchema = _enum([
17689
+ "object-event",
17690
+ "track-end",
17691
+ "device-event",
17692
+ "package-event"
17472
17693
  ]);
17473
- var LlmProfileSchema = object({
17474
- id: string(),
17475
- name: string(),
17476
- kind: LlmProfileKindSchema,
17477
- /** Stamped by the provider — keeps the fanned catalog routable. */
17478
- addonId: string(),
17479
- enabled: boolean(),
17480
- /** Vendor model id, or the managed runtime's loaded model. */
17481
- model: string(),
17482
- /** Required for openai-compatible; override for cloud kinds. */
17483
- baseUrl: string().optional(),
17484
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
17485
- apiKey: string().optional(),
17486
- supportsVision: boolean(),
17487
- temperature: number().min(0).max(2).optional(),
17488
- maxTokens: number().int().positive().optional(),
17489
- timeoutMs: number().int().positive().default(6e4),
17490
- extraHeaders: record(string(), string()).optional(),
17491
- /** kind === 'managed-local' only (spec §4). */
17492
- runtime: ManagedRuntimeConfigSchema.optional()
17493
- });
17494
- /** ConfigUISchema tree passed through untyped on the wire (the
17495
- * notification-output `ConfigSchemaPassthrough` precedent at
17496
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
17497
- var ConfigSchemaPassthrough = unknown();
17498
- var LlmProfileKindDescriptorSchema = object({
17499
- kind: LlmProfileKindSchema,
17500
- label: string(),
17501
- icon: string(),
17502
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
17503
- addonId: string(),
17504
- configSchema: ConfigSchemaPassthrough
17505
- });
17506
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
17507
- var LlmDefaultSchema = object({
17508
- selector: LlmDefaultSelectorSchema,
17509
- profileId: string()
17510
- });
17511
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
17512
- var LlmUsageRollupSchema = object({
17513
- day: string(),
17514
- consumer: string(),
17515
- profileId: string(),
17516
- calls: number(),
17517
- okCalls: number(),
17518
- errorCalls: number(),
17519
- inputTokens: number(),
17520
- outputTokens: number(),
17521
- avgLatencyMs: number()
17694
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
17695
+ var NcHistorySubjectSchema = object({
17696
+ className: string(),
17697
+ label: string().optional(),
17698
+ confidence: number().optional(),
17699
+ zones: array(string()),
17700
+ timestamp: number()
17522
17701
  });
17523
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
17524
- var ManagedModelCatalogEntrySchema = object({
17702
+ /**
17703
+ * One delivery-history row. This is a read-only VIEW over the durable
17704
+ * outbox row (single source of truth — the same row the drain loop drives;
17705
+ * NO second write path, so history can never drift from delivery state).
17706
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
17707
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
17708
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
17709
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
17710
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
17711
+ * P1 (admin scope only).
17712
+ */
17713
+ var NcHistoryEntrySchema = object({
17714
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
17525
17715
  id: string(),
17526
- label: string(),
17527
- family: string(),
17528
- purpose: _enum(["text", "vision"]),
17529
- url: string(),
17530
- sha256: string(),
17531
- sizeBytes: number(),
17532
- quantization: string(),
17533
- /** Load-time guidance shown in the picker. */
17534
- minRamBytes: number(),
17535
- contextSizeDefault: number().int(),
17536
- /** Vision models: companion projector file. */
17537
- mmprojUrl: string().optional()
17538
- });
17539
- var LlmRuntimeNodeSchema = object({
17540
- nodeId: string(),
17541
- reachable: boolean(),
17542
- status: LlmRuntimeStatusSchema.optional(),
17543
- disk: LlmRuntimeDiskUsageSchema.optional(),
17544
- error: string().optional()
17716
+ ruleId: string(),
17717
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
17718
+ ruleName: string(),
17719
+ /** The rule urgency/trigger that produced this delivery. */
17720
+ delivery: NcDeliverySchema,
17721
+ targetId: string(),
17722
+ deviceId: number(),
17723
+ recordKind: NcHistoryRecordKindSchema,
17724
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
17725
+ recordId: string(),
17726
+ /** Present for track-scoped deliveries (object-event / track-end). */
17727
+ trackId: string().optional(),
17728
+ status: NcHistoryStatusSchema,
17729
+ /** Delivery attempts made so far. */
17730
+ attempts: number().int(),
17731
+ /** Fire time (outbox enqueue). */
17732
+ createdAt: number(),
17733
+ /** Last transition time (terminal for sent / dead). */
17734
+ updatedAt: number(),
17735
+ /** Failure detail — present on a `dead` row. */
17736
+ error: string().optional(),
17737
+ subject: NcHistorySubjectSchema
17545
17738
  });
17546
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
17547
- var ProfileRefInputSchema = object({
17548
- addonId: string(),
17549
- profileId: string()
17739
+ /**
17740
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
17741
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
17742
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
17743
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
17744
+ */
17745
+ var NcHistoryFilterSchema = object({
17746
+ ruleId: string().optional(),
17747
+ deviceId: number().optional(),
17748
+ status: NcHistoryStatusSchema.optional(),
17749
+ since: number().optional(),
17750
+ until: number().optional(),
17751
+ limit: number().int().min(1).max(500).default(100)
17550
17752
  });
17551
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
17552
- kind: "mutation",
17553
- auth: "admin"
17554
- }), method(ProfileRefInputSchema, _void(), {
17753
+ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), method(object({ ruleId: string() }), object({ rule: NcRuleSchema.nullable() }), { auth: "admin" }), method(object({ rule: NcRuleInputSchema }), object({ rule: NcRuleSchema }), {
17555
17754
  kind: "mutation",
17556
- auth: "admin"
17557
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
17755
+ auth: "admin",
17756
+ caller: "required"
17757
+ }), method(object({
17758
+ ruleId: string(),
17759
+ patch: NcRulePatchSchema
17760
+ }), object({ rule: NcRuleSchema }), {
17558
17761
  kind: "mutation",
17559
- auth: "admin"
17560
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
17561
- selector: LlmDefaultSelectorSchema,
17562
- profileId: string().nullable()
17563
- }), _void(), {
17762
+ auth: "admin",
17763
+ caller: "required"
17764
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
17564
17765
  kind: "mutation",
17565
17766
  auth: "admin"
17566
17767
  }), method(object({
17567
- since: number().optional(),
17568
- until: number().optional(),
17569
- consumer: string().optional(),
17570
- profileId: string().optional()
17571
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
17572
- nodeId: string(),
17573
- model: ManagedModelRefSchema
17574
- }), _void(), {
17768
+ ruleId: string(),
17769
+ enabled: boolean()
17770
+ }), object({ success: literal(true) }), {
17575
17771
  kind: "mutation",
17576
17772
  auth: "admin"
17577
17773
  }), method(object({
17578
- nodeId: string(),
17579
- file: string()
17580
- }), _void(), {
17581
- kind: "mutation",
17582
- auth: "admin"
17583
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
17584
- kind: "mutation",
17585
- auth: "admin"
17586
- }), method(ProfileRefInputSchema, _void(), {
17774
+ rule: NcRuleInputSchema,
17775
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
17776
+ }), object({ results: array(NcTestResultSchema) }), {
17587
17777
  kind: "mutation",
17588
17778
  auth: "admin"
17589
- });
17779
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
17590
17780
  /**
17591
17781
  * Zod schemas for persisted record types.
17592
17782
  *
@@ -18296,76 +18486,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18296
18486
  eventId: string(),
18297
18487
  timestamp: number()
18298
18488
  });
18299
- /**
18300
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
18301
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
18302
- * caps into per-camera event-kind descriptors.
18303
- *
18304
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
18305
- * is NOT duplicated here — every entry is derived from the single
18306
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18307
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18308
- * control cap means adding one line here (and a taxonomy entry); the anti-
18309
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18310
- * eventful cap is missing.
18311
- */
18312
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18313
- var LEGACY_ICON = {
18314
- motion: "motion",
18315
- audio: "audio",
18316
- person: "person",
18317
- vehicle: "vehicle",
18318
- animal: "animal",
18319
- package: "package",
18320
- door: "door",
18321
- pir: "pir",
18322
- smoke: "smoke",
18323
- water: "water",
18324
- button: "button",
18325
- generic: "generic",
18326
- gas: "smoke",
18327
- vibration: "generic",
18328
- tamper: "generic",
18329
- presence: "person",
18330
- lock: "generic",
18331
- siren: "generic",
18332
- switch: "generic",
18333
- doorbell: "button"
18334
- };
18335
- function legacyIcon(iconId) {
18336
- return LEGACY_ICON[iconId] ?? "generic";
18337
- }
18338
- /**
18339
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18340
- * The anti-drift guard cross-checks this against the eventful caps declared
18341
- * in `packages/types/src/capabilities/*.cap.ts`.
18342
- */
18343
- var CAP_TO_KIND = {
18344
- contact: "contact",
18345
- motion: "motion-sensor",
18346
- smoke: "smoke",
18347
- flood: "flood",
18348
- gas: "gas",
18349
- "carbon-monoxide": "carbon-monoxide",
18350
- vibration: "vibration",
18351
- tamper: "tamper",
18352
- presence: "presence",
18353
- "enum-sensor": "enum-sensor",
18354
- "event-emitter": "device-event",
18355
- "lock-control": "lock",
18356
- switch: "switch",
18357
- button: "button",
18358
- doorbell: "doorbell"
18359
- };
18360
- function buildDescriptor(capName, kind) {
18361
- const t = EVENT_TAXONOMY[kind];
18362
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18363
- return {
18364
- ...t,
18365
- icon: legacyIcon(t.iconId)
18366
- };
18367
- }
18368
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18369
18489
  var CameraPipelineConfigSchema = object({
18370
18490
  engine: PipelineEngineChoiceSchema.optional(),
18371
18491
  steps: array(PipelineStepInputSchema).readonly(),
@@ -18851,6 +18971,76 @@ method(object({
18851
18971
  auth: "admin"
18852
18972
  });
18853
18973
  /**
18974
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
18975
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
18976
+ * caps into per-camera event-kind descriptors.
18977
+ *
18978
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
18979
+ * is NOT duplicated here — every entry is derived from the single
18980
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18981
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18982
+ * control cap means adding one line here (and a taxonomy entry); the anti-
18983
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18984
+ * eventful cap is missing.
18985
+ */
18986
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18987
+ var LEGACY_ICON = {
18988
+ motion: "motion",
18989
+ audio: "audio",
18990
+ person: "person",
18991
+ vehicle: "vehicle",
18992
+ animal: "animal",
18993
+ package: "package",
18994
+ door: "door",
18995
+ pir: "pir",
18996
+ smoke: "smoke",
18997
+ water: "water",
18998
+ button: "button",
18999
+ generic: "generic",
19000
+ gas: "smoke",
19001
+ vibration: "generic",
19002
+ tamper: "generic",
19003
+ presence: "person",
19004
+ lock: "generic",
19005
+ siren: "generic",
19006
+ switch: "generic",
19007
+ doorbell: "button"
19008
+ };
19009
+ function legacyIcon(iconId) {
19010
+ return LEGACY_ICON[iconId] ?? "generic";
19011
+ }
19012
+ /**
19013
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
19014
+ * The anti-drift guard cross-checks this against the eventful caps declared
19015
+ * in `packages/types/src/capabilities/*.cap.ts`.
19016
+ */
19017
+ var CAP_TO_KIND = {
19018
+ contact: "contact",
19019
+ motion: "motion-sensor",
19020
+ smoke: "smoke",
19021
+ flood: "flood",
19022
+ gas: "gas",
19023
+ "carbon-monoxide": "carbon-monoxide",
19024
+ vibration: "vibration",
19025
+ tamper: "tamper",
19026
+ presence: "presence",
19027
+ "enum-sensor": "enum-sensor",
19028
+ "event-emitter": "device-event",
19029
+ "lock-control": "lock",
19030
+ switch: "switch",
19031
+ button: "button",
19032
+ doorbell: "doorbell"
19033
+ };
19034
+ function buildDescriptor(capName, kind) {
19035
+ const t = EVENT_TAXONOMY[kind];
19036
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
19037
+ return {
19038
+ ...t,
19039
+ icon: legacyIcon(t.iconId)
19040
+ };
19041
+ }
19042
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
19043
+ /**
18854
19044
  * server-management — per-NODE singleton capability for a node's ROOT
18855
19045
  * package lifecycle (runtime-updatable node packages).
18856
19046
  *
@@ -20400,7 +20590,28 @@ var FaceInfoSchema = object({
20400
20590
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
20401
20591
  * track produced no key frame (e.g. native/onboard source) — the UI falls
20402
20592
  * back to the inline `base64` face crop. */
20403
- keyFrameMediaKey: string().optional()
20593
+ keyFrameMediaKey: string().optional(),
20594
+ /** Winning identity-match cosine (0..1) for this face's track, when an
20595
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
20596
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
20597
+ * faces that were never auto-recognized. */
20598
+ bestMatchScore: number().optional(),
20599
+ /** Native-scale face short side (px) at recognition time, when the runner
20600
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
20601
+ * legacy rows / runners that reported no native measure. */
20602
+ nativeFaceShortSidePx: number().optional(),
20603
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
20604
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
20605
+ * but blocked only by the recognition size floor). Mutually exclusive with
20606
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
20607
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
20608
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
20609
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
20610
+ suggestedIdentityId: string().optional(),
20611
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
20612
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
20613
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
20614
+ suggestedMatchScore: number().optional()
20404
20615
  });
20405
20616
  var FaceFilterEnum = _enum([
20406
20617
  "unassigned",
@@ -22506,36 +22717,6 @@ Object.freeze({
22506
22717
  addonId: null,
22507
22718
  access: "view"
22508
22719
  },
22509
- "advancedNotifier.deleteRule": {
22510
- capName: "advanced-notifier",
22511
- capScope: "system",
22512
- addonId: null,
22513
- access: "delete"
22514
- },
22515
- "advancedNotifier.getHistory": {
22516
- capName: "advanced-notifier",
22517
- capScope: "system",
22518
- addonId: null,
22519
- access: "view"
22520
- },
22521
- "advancedNotifier.getRules": {
22522
- capName: "advanced-notifier",
22523
- capScope: "system",
22524
- addonId: null,
22525
- access: "view"
22526
- },
22527
- "advancedNotifier.testRule": {
22528
- capName: "advanced-notifier",
22529
- capScope: "system",
22530
- addonId: null,
22531
- access: "create"
22532
- },
22533
- "advancedNotifier.upsertRule": {
22534
- capName: "advanced-notifier",
22535
- capScope: "system",
22536
- addonId: null,
22537
- access: "create"
22538
- },
22539
22720
  "alarmPanel.arm": {
22540
22721
  capName: "alarm-panel",
22541
22722
  capScope: "device",
@@ -24858,6 +25039,12 @@ Object.freeze({
24858
25039
  addonId: null,
24859
25040
  access: "view"
24860
25041
  },
25042
+ "notificationRules.getHistory": {
25043
+ capName: "notification-rules",
25044
+ capScope: "system",
25045
+ addonId: null,
25046
+ access: "view"
25047
+ },
24861
25048
  "notificationRules.getRule": {
24862
25049
  capName: "notification-rules",
24863
25050
  capScope: "system",
@@ -27416,4 +27603,4 @@ function enumerateInferenceDevices(hw) {
27416
27603
  return out;
27417
27604
  }
27418
27605
  //#endregion
27419
- export { parseProfileBrokerId as $, motionDetectionCapability as A, supportedRuntimes as B, detectionPipelineCapability as C, mapAudioLabelToMacro as D, hfModelUrl as E, recordingExportCapability as F, DeviceFeature as G, errMsg as H, resolveScrubThumbnailGeometry as I, hydrateSchema as J, DeviceType as K, runtimeDevices as L, pipelineExecutorCapability as M, pipelineRunnerCapability as N, maskUrlCredentials as O, recordingCapability as P, parseJsonUnknown as Q, storageEvictableCapability as R, defineCustomActions as S, evaluateZoneRules as T, BaseAddon as U, webrtcSessionCapability as V, CAM_PROFILE_ORDER as W, makeProfileBrokerId as X, isEvent as Y, makeSourceBrokerId as Z, audioAnalysisCapability as _, COCO_TO_MACRO as a, discriminatedUnion as at, customAction as b, EVENT_PAD_MS as c, number as ct, HF_BASE_URL as d, string as dt, selectAssignedProfileSlots as et, OpsLogEntrySchema as f, union as ft, addonWidgetsSourceCapability as g, YAMNET_TO_MACRO as h, COCO_80_LABELS as i, boolean as it, nodePin as j, migrateConfigToBands as k, EncodeProfileSchema as l, object as lt, RingBuffer as m, AUDIO_BACKEND_CHOICES as n, _enum as nt, DEFAULT_AUDIO_ANALYZER_CONFIG as o, lazy as ot, RecordingConfigSchema as p, EventCategory as pt, createEvent as q, AUDIO_MACRO_LABELS as r, array as rt, DEVICE_BACKEND_TO_FORMAT as s, literal as st, APPLE_SA_TO_MACRO as t, sleep as tt, ExportRecordSchema as u, record as ut, audioAnalyzerCapability as v, enumerateInferenceDevices as w, defaultDeviceFor as x, cameraStreamsCapability as y, streamBrokerCapability as z };
27606
+ export { selectAssignedProfileSlots as $, motionDetectionCapability as A, webrtcSessionCapability as B, detectionPipelineCapability as C, mapAudioLabelToMacro as D, hfModelUrl as E, recordingExportCapability as F, DeviceType as G, BaseAddon as H, runtimeDevices as I, isEvent as J, createEvent as K, storageEvictableCapability as L, pipelineExecutorCapability as M, pipelineRunnerCapability as N, maskUrlCredentials as O, recordingCapability as P, parseProfileBrokerId as Q, streamBrokerCapability as R, defineCustomActions as S, evaluateZoneRules as T, CAM_PROFILE_ORDER as U, errMsg as V, DeviceFeature as W, makeSourceBrokerId as X, makeProfileBrokerId as Y, parseJsonUnknown as Z, audioAnalysisCapability as _, COCO_TO_MACRO as a, lazy as at, customAction as b, EVENT_PAD_MS as c, object as ct, HF_BASE_URL as d, union as dt, sleep as et, OpsLogEntrySchema as f, EventCategory as ft, addonWidgetsSourceCapability as g, YAMNET_TO_MACRO as h, COCO_80_LABELS as i, discriminatedUnion as it, nodePin as j, migrateConfigToBands as k, EncodeProfileSchema as l, record as lt, RingBuffer as m, AUDIO_BACKEND_CHOICES as n, array as nt, DEFAULT_AUDIO_ANALYZER_CONFIG as o, literal as ot, RecordingConfigSchema as p, hydrateSchema as q, AUDIO_MACRO_LABELS as r, boolean as rt, DEVICE_BACKEND_TO_FORMAT as s, number as st, APPLE_SA_TO_MACRO as t, _enum as tt, ExportRecordSchema as u, string as ut, audioAnalyzerCapability as v, enumerateInferenceDevices as w, defaultDeviceFor as x, cameraStreamsCapability as y, supportedRuntimes as z };