@camstack/addon-notifiers 1.2.4 → 1.2.6

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { brotliCompressSync, deflateSync, gzipSync } from "node:zlib";
2
- //#region ../types/dist/event-category-D4HJq7Mw.mjs
2
+ //#region ../types/dist/event-category-BLcNejAE.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -149,9 +149,6 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
149
149
  EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
150
150
  EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
151
151
  EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
152
- /** Runner-sampled scrub thumbnail (~1/5 s/camera). Telemetry (D8): a lost
153
- * thumb is a scrub gap the recorder's keyframe backfill covers. */
154
- EventCategory["RecordingThumbSampled"] = "recording.thumb-sampled";
155
152
  /** Export render progress (0–100). Telemetry (D8): a lost tick is a stale
156
153
  * progress bar the client reconciles via `recordingExport.getExport`. */
157
154
  EventCategory["RecordingExportProgress"] = "recording.export.progress";
@@ -6816,7 +6813,6 @@ object({ deviceId: number() }), object({ deviceId: number() }), object({
6816
6813
  patch: record(string(), unknown())
6817
6814
  }), object({ success: literal(true) });
6818
6815
  object({ deviceId: number() }), unknown().nullable();
6819
- /** Shorthand to define a method schema */
6820
6816
  function method(input, output, options) {
6821
6817
  return {
6822
6818
  input,
@@ -6824,6 +6820,7 @@ function method(input, output, options) {
6824
6820
  kind: options?.kind ?? "query",
6825
6821
  auth: options?.auth ?? "protected",
6826
6822
  ...options?.access !== void 0 ? { access: options.access } : {},
6823
+ ...options?.caller !== void 0 ? { caller: options.caller } : {},
6827
6824
  timeoutMs: options?.timeoutMs
6828
6825
  };
6829
6826
  }
@@ -8294,6 +8291,59 @@ for (const l of AUDIO_MACRO_LABELS) {
8294
8291
  /** The complete taxonomy dictionary, keyed by kind. */
8295
8292
  var EVENT_TAXONOMY = Object.freeze(Object.fromEntries(entries));
8296
8293
  /**
8294
+ * Notification-Center taxonomy — the fixed vocabulary the NC rule editor
8295
+ * offers as pickers instead of free text. Derived (never hand-listed) from the
8296
+ * single `EVENT_TAXONOMY` dictionary so it stays in lockstep with every other
8297
+ * taxonomy surface (timeline, filters, event page).
8298
+ *
8299
+ * Three buckets, mapped onto the rule editor's `stringList` conditions:
8300
+ * - `videoClasses` → detection classes (person / vehicle / animal + subs)
8301
+ * for the `classes` / `classesExclude` conditions.
8302
+ * - `audioKinds` → audio-analyzer sub kinds (`audio-scream`, …) shown in
8303
+ * the same class picker, grouped under an Audio header.
8304
+ * - `labels` → sensor + control taxonomy kinds (doorbell / contact /
8305
+ * lock / …) for the `sensorKinds` device-event condition.
8306
+ *
8307
+ * Each entry carries `parentKind` so the client can group video subs under
8308
+ * their macro and sensor/control kinds under their category. This surface is
8309
+ * served ADDITIVELY on the `nc.getConditionCatalog` bridge response — no cap
8310
+ * method, no codegen — so it ships train-free with an addon deploy.
8311
+ */
8312
+ /** One selectable taxonomy value: a stable kind id + display label + parent. */
8313
+ var NcTaxonomyEntrySchema = object({
8314
+ /** Stable kind id (e.g. 'person', 'car', 'audio-scream', 'doorbell'). */
8315
+ kind: string(),
8316
+ /** English fallback label (the UI translates via the event-kind i18n key). */
8317
+ label: string(),
8318
+ /** Macro/category parent for grouping ('car' → 'vehicle'); null for a top. */
8319
+ parentKind: string().nullable()
8320
+ });
8321
+ object({
8322
+ videoClasses: array(NcTaxonomyEntrySchema),
8323
+ audioKinds: array(NcTaxonomyEntrySchema),
8324
+ labels: array(NcTaxonomyEntrySchema)
8325
+ });
8326
+ function toEntry(kind, label, parentKind) {
8327
+ return {
8328
+ kind,
8329
+ label,
8330
+ parentKind
8331
+ };
8332
+ }
8333
+ /**
8334
+ * Build the NC taxonomy from `EVENT_TAXONOMY`. Insertion order is preserved
8335
+ * (macros before their subs), which the client relies on for stable grouping.
8336
+ */
8337
+ function buildNcTaxonomy() {
8338
+ const all = Object.values(EVENT_TAXONOMY);
8339
+ return {
8340
+ videoClasses: all.filter((e) => e.category === "detection").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8341
+ audioKinds: all.filter((e) => e.category === "audio" && e.level === "sub").map((e) => toEntry(e.kind, e.label, e.parentKind)),
8342
+ labels: all.filter((e) => e.category === "sensor" || e.category === "control").map((e) => toEntry(e.kind, e.label, e.parentKind))
8343
+ };
8344
+ }
8345
+ Object.freeze(buildNcTaxonomy());
8346
+ /**
8297
8347
  * Error types for the safe expression engine. Two distinct classes so callers
8298
8348
  * can tell a compile-time (grammar) failure from a runtime (evaluation)
8299
8349
  * failure — both are non-fatal to the host: read paths degrade to "skip link".
@@ -11195,6 +11245,22 @@ var CameraMetricsSchema = object({
11195
11245
  ])
11196
11246
  });
11197
11247
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
11248
+ /**
11249
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
11250
+ * within the frame, so the executor can re-cut a leaf child ROI at native
11251
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
11252
+ */
11253
+ var NativeCropRefSchema = object({
11254
+ /** Handle keying the retained native surface (node-pinned to its owner). */
11255
+ handle: FrameHandleSchema,
11256
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
11257
+ cropFrameSpace: object({
11258
+ x: number(),
11259
+ y: number(),
11260
+ w: number(),
11261
+ h: number()
11262
+ })
11263
+ });
11198
11264
  var ModelFormatSchema$1 = _enum([
11199
11265
  "onnx",
11200
11266
  "coreml",
@@ -11470,7 +11536,22 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11470
11536
  * Omitted ⇒ the runner's default device (current single-engine
11471
11537
  * behaviour). Selects WHICH device pool of the node runs the call.
11472
11538
  */
11473
- deviceKey: string().optional()
11539
+ deviceKey: string().optional(),
11540
+ /**
11541
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
11542
+ * when the parent crop was resolved from the frame's retained NATIVE
11543
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
11544
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
11545
+ * resolution from that surface — the SAME quality path faces already
11546
+ * had — instead of the downscaled parent tile. `handle` keys the native
11547
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
11548
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
11549
+ * the executor's crop-normalized child ROI back into frame-normalized
11550
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
11551
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
11552
+ * (today's behaviour on the fallback path).
11553
+ */
11554
+ nativeCropRef: NativeCropRefSchema.optional()
11474
11555
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
11475
11556
  engine: PipelineEngineChoiceSchema.optional(),
11476
11557
  steps: array(PipelineStepInputSchema).min(1),
@@ -11686,7 +11767,11 @@ var DetailResultSchema = object({
11686
11767
  bbox: NativeCropBboxSchema.optional(),
11687
11768
  embedding: string().optional(),
11688
11769
  label: string().optional(),
11689
- alignedCropJpeg: string().optional()
11770
+ alignedCropJpeg: string().optional(),
11771
+ /** Face short side (px) measured on the NATIVE crop surface. The `bbox`
11772
+ * above is detection-frame px (≈6× smaller on a 4K camera) — min-face-size
11773
+ * consumers MUST prefer this when present (2026-07-22 native-gate fix). */
11774
+ nativeFaceShortSidePx: number().optional()
11690
11775
  });
11691
11776
  /**
11692
11777
  * Per-camera tunable ranges + defaults. Single source of truth used
@@ -11700,6 +11785,12 @@ var motionCooldownMsField = {
11700
11785
  default: 3e4,
11701
11786
  step: 500
11702
11787
  };
11788
+ var maxSessionHoldMsField = {
11789
+ min: 0,
11790
+ max: 6e5,
11791
+ default: 12e4,
11792
+ step: 5e3
11793
+ };
11703
11794
  var motionFpsField = {
11704
11795
  min: 1,
11705
11796
  max: 30,
@@ -11847,6 +11938,19 @@ var RunnerCameraConfigSchema = object({
11847
11938
  "on-motion"
11848
11939
  ]).default("always-on"),
11849
11940
  motionCooldownMs: number().min(motionCooldownMsField.min).default(motionCooldownMsField.default),
11941
+ /**
11942
+ * Orchestrator-side on-motion session-hold cap (ms). While an on-motion
11943
+ * detection session is active and ≥1 confirmed non-stationary track is
11944
+ * still live, the orchestrator keeps the session open past
11945
+ * `motionCooldownMs` (a slowly-moving subject can stop re-triggering the
11946
+ * camera's VMD yet is still being tracked frame-to-frame) — up to this many
11947
+ * ms since the session opened, after which it closes regardless. `0`
11948
+ * disables the hold (legacy cooldown-only teardown). Not consumed by the
11949
+ * runner itself — carried here so it shares the per-camera device-settings
11950
+ * surface with `motionCooldownMs`; the orchestrator reads it off the
11951
+ * resolved `CameraDetectionConfig`.
11952
+ */
11953
+ maxSessionHoldMs: number().min(maxSessionHoldMsField.min).max(maxSessionHoldMsField.max).optional(),
11850
11954
  motionFps: number().min(motionFpsField.min).max(motionFpsField.max).default(motionFpsField.default),
11851
11955
  detectionFps: number().min(detectionFpsField.min).max(detectionFpsField.max).default(detectionFpsField.default),
11852
11956
  motionStreamId: string(),
@@ -11936,7 +12040,7 @@ var RunnerCameraConfigSchema = object({
11936
12040
  */
11937
12041
  inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11938
12042
  });
11939
- motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
12043
+ motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, maxSessionHoldMsField.min, maxSessionHoldMsField.max, maxSessionHoldMsField.step, maxSessionHoldMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
11940
12044
  /**
11941
12045
  * Runtime load summary returned by `getLocalLoad`. Used by the orchestrator's
11942
12046
  * load-balancing levels (L2 capacity-based, L3 hardware-aware) to decide
@@ -13809,94 +13913,6 @@ var EnrichedWidgetMetadataSchema = WidgetMetadataSchema.extend({
13809
13913
  bundleUrl: string()
13810
13914
  });
13811
13915
  method(_void(), array(EnrichedWidgetMetadataSchema).readonly());
13812
- var NotificationRuleConditionsSchema = object({
13813
- deviceIds: array(number()).readonly().optional(),
13814
- classNames: array(string()).readonly().optional(),
13815
- zoneIds: array(string()).readonly().optional(),
13816
- minConfidence: number().optional(),
13817
- source: _enum([
13818
- "pipeline",
13819
- "onboard",
13820
- "any"
13821
- ]).optional(),
13822
- schedule: object({
13823
- days: array(number()).readonly(),
13824
- startHour: number(),
13825
- endHour: number()
13826
- }).optional(),
13827
- cooldownSeconds: number().optional(),
13828
- minDwellSeconds: number().optional(),
13829
- /** Match against `event.data.eventType` token (e.g. `'press_long'`). When non-empty, only events
13830
- * carrying a matching `data.eventType` string pass this condition. Rules without this field are
13831
- * unaffected (back-compat). Distinct from `rule.eventTypes` which holds EventCategory strings. */
13832
- eventTypeTokens: array(string()).readonly().optional(),
13833
- /** Match detections whose CLIP image embedding is semantically similar to this free-text
13834
- * description. Requires the embedding-encoder cap to have pre-warmed the text vector.
13835
- * `minSimilarity` is the cosine similarity threshold in [0, 1]. */
13836
- clipDescription: object({
13837
- text: string().min(1),
13838
- minSimilarity: number().min(0).max(1)
13839
- }).optional(),
13840
- /** Match events whose recognized-entity label (face identity name or plate
13841
- * vehicle name, propagated onto `event.data.label`) is one of these values.
13842
- * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13843
- * vehicle/person> is seen". */
13844
- labels: array(string()).readonly().optional()
13845
- });
13846
- var NotificationRuleTemplateSchema = object({
13847
- title: string(),
13848
- body: string(),
13849
- imageMode: _enum([
13850
- "crop",
13851
- "annotated",
13852
- "full",
13853
- "none"
13854
- ])
13855
- });
13856
- var NotificationRuleSchema = object({
13857
- id: string(),
13858
- name: string(),
13859
- enabled: boolean(),
13860
- eventTypes: array(string()).readonly(),
13861
- conditions: NotificationRuleConditionsSchema,
13862
- outputs: array(string()).readonly(),
13863
- template: NotificationRuleTemplateSchema.optional(),
13864
- priority: _enum([
13865
- "low",
13866
- "normal",
13867
- "high",
13868
- "critical"
13869
- ])
13870
- });
13871
- var NotificationTestResultSchema = object({
13872
- ruleId: string(),
13873
- eventId: string(),
13874
- timestamp: number(),
13875
- wouldFire: boolean(),
13876
- reason: string().optional()
13877
- });
13878
- var NotificationHistoryEntrySchema = object({
13879
- id: string(),
13880
- ruleId: string(),
13881
- ruleName: string(),
13882
- eventId: string(),
13883
- timestamp: number(),
13884
- outputs: array(string()).readonly(),
13885
- success: boolean(),
13886
- error: string().optional(),
13887
- deviceId: number().optional()
13888
- });
13889
- var NotificationHistoryFilterSchema = object({
13890
- ruleId: string().optional(),
13891
- deviceId: number().optional(),
13892
- from: number().optional(),
13893
- to: number().optional(),
13894
- limit: number().optional()
13895
- });
13896
- 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({
13897
- ruleId: string(),
13898
- lookbackMinutes: number()
13899
- }), object({ results: array(NotificationTestResultSchema).readonly() }), { kind: "mutation" }), method(object({ filter: NotificationHistoryFilterSchema.optional() }), object({ entries: array(NotificationHistoryEntrySchema).readonly() }));
13900
13916
  /**
13901
13917
  * Alerts capability — collection-based internal alert system.
13902
13918
  *
@@ -14083,89 +14099,6 @@ method(object({
14083
14099
  password: string()
14084
14100
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
14085
14101
  /**
14086
- * `login-method` — collection cap through which auth addons contribute
14087
- * their pre-auth login surfaces to the login page. This is the SINGLE,
14088
- * generic mechanism that supersedes the dead `auth.listProviders` reader:
14089
- * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
14090
- * `login-method` provider and the PUBLIC `auth.listLoginMethods`
14091
- * procedure aggregates them for the unauthenticated login page.
14092
- *
14093
- * A contribution is a discriminated union on `kind`:
14094
- *
14095
- * - `redirect` — a declarative button. The login page renders a generic
14096
- * button that navigates to `startUrl` (an addon-owned HTTP route).
14097
- * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
14098
- * ZERO shell-side JS. A future SSO addon plugs in the same way — the
14099
- * login page needs NO change.
14100
- *
14101
- * - `widget` — a Module-Federation widget the login page mounts (via
14102
- * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
14103
- * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
14104
- * mechanism kept for future use; no shipped addon uses it on the login
14105
- * page (the passkey ceremony below runs natively in the shell instead).
14106
- *
14107
- * - `passkey` — a declarative WebAuthn ceremony the shell renders
14108
- * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
14109
- * a remotely-loaded bundle). Carries the addon's effective `rpId` /
14110
- * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
14111
- * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
14112
- * fetching any remote code pre-auth. Contribution stays unconditional —
14113
- * enrollment state is never leaked pre-auth; visibility is a shell
14114
- * decision.
14115
- *
14116
- * Every contribution carries a `stage`:
14117
- * - `primary` — shown on the first credentials screen (OIDC /
14118
- * magic-link buttons; a future usernameless passkey).
14119
- * - `second-factor` — shown AFTER the password leg, gated on the
14120
- * returned `factors` (passkey-as-2FA today).
14121
- *
14122
- * `mount: skip` — the cap is read server-side by the core auth router
14123
- * (`registry.getCollection('login-method')`), never mounted as its own
14124
- * tRPC router.
14125
- */
14126
- /** When a login method renders in the two-phase login flow. */
14127
- var LoginStageEnum = _enum(["primary", "second-factor"]);
14128
- /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
14129
- var LoginMethodContributionSchema = discriminatedUnion("kind", [
14130
- object({
14131
- kind: literal("redirect"),
14132
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
14133
- id: string(),
14134
- /** Operator-facing button label. */
14135
- label: string(),
14136
- /** lucide-react icon name. */
14137
- icon: string().optional(),
14138
- /** Addon-owned HTTP route the button navigates to (GET). */
14139
- startUrl: string(),
14140
- stage: LoginStageEnum
14141
- }),
14142
- object({
14143
- kind: literal("widget"),
14144
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
14145
- id: string(),
14146
- /** Owning addon id — drives the public bundle URL + the MF namespace. */
14147
- addonId: string(),
14148
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
14149
- bundle: string(),
14150
- /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
14151
- remote: WidgetRemoteSchema,
14152
- stage: LoginStageEnum
14153
- }),
14154
- object({
14155
- kind: literal("passkey"),
14156
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
14157
- id: string(),
14158
- /** Operator-facing button label. */
14159
- label: string(),
14160
- stage: LoginStageEnum,
14161
- /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
14162
- rpId: string(),
14163
- /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
14164
- origin: string().nullable()
14165
- })
14166
- ]);
14167
- method(_void(), array(LoginMethodContributionSchema).readonly());
14168
- /**
14169
14102
  * Orchestrator-side destination metadata. The orchestrator computes
14170
14103
  * `id = <addonId>:<subId>` from its provider lookup so consumers
14171
14104
  * (admin UI, restore flow) see one canonical key.
@@ -14522,6 +14455,28 @@ method(ListInputSchema, array(BrokerInfoSchema$1)), method(GetInputSchema, Broke
14522
14455
  }), method(GetStateInputSchema, unknown().nullable()), method(_void(), RegistryStatusSchema);
14523
14456
  DeviceType.Camera;
14524
14457
  /**
14458
+ * Identity — preserves literal types for downstream inference.
14459
+ *
14460
+ * The constraint is `Record<string, unknown>` (not `CustomActionsSpec`) so
14461
+ * TypeScript does not widen each entry's literal `kind`/`auth` fields to
14462
+ * the broader unions declared on `CustomActionSpec`'s default generics.
14463
+ * Shape validity is enforced separately by the `customAction(...)` helper
14464
+ * whose return type is already a `CustomActionSpec<...>`.
14465
+ */
14466
+ function defineCustomActions(spec) {
14467
+ return spec;
14468
+ }
14469
+ function customAction(input, output, options) {
14470
+ return {
14471
+ input,
14472
+ output,
14473
+ kind: options?.kind ?? "query",
14474
+ auth: options?.auth ?? "protected",
14475
+ scope: options?.scope ?? { kind: "system" },
14476
+ ...options?.caller ? { caller: "required" } : {}
14477
+ };
14478
+ }
14479
+ /**
14525
14480
  * `custom-model-registry` — collection cap exposing operator-registered
14526
14481
  * custom detection models. Each provider (today: `addon-model-studio`)
14527
14482
  * contributes a list of `CustomModelDescriptor`s; the hub auto-concatenates
@@ -15509,229 +15464,604 @@ method(_void(), array(string()).readonly(), { auth: "admin" }), method(object({
15509
15464
  kind: "mutation",
15510
15465
  auth: "admin"
15511
15466
  });
15512
- var LogLevelSchema = _enum([
15513
- "debug",
15514
- "info",
15515
- "warn",
15516
- "error"
15467
+ /**
15468
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15469
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15470
+ * caps stay wire-compatible without a circular cap→cap import.
15471
+ *
15472
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15473
+ * every transport tier structurally, and failed calls still write usage rows.
15474
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15475
+ */
15476
+ var LlmUsageSchema = object({
15477
+ inputTokens: number(),
15478
+ outputTokens: number()
15479
+ });
15480
+ var LlmErrorCodeSchema = _enum([
15481
+ "timeout",
15482
+ "rate-limited",
15483
+ "auth",
15484
+ "refusal",
15485
+ "bad-request",
15486
+ "unavailable",
15487
+ "no-profile",
15488
+ "budget-exceeded",
15489
+ "adapter-error"
15517
15490
  ]);
15518
- var LogEntrySchema = object({
15519
- timestamp: date(),
15520
- level: LogLevelSchema,
15521
- scope: array(string()),
15491
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15492
+ ok: literal(true),
15493
+ text: string(),
15494
+ model: string(),
15495
+ usage: LlmUsageSchema,
15496
+ truncated: boolean(),
15497
+ latencyMs: number()
15498
+ }), object({
15499
+ ok: literal(false),
15500
+ code: LlmErrorCodeSchema,
15522
15501
  message: string(),
15523
- meta: record(string(), unknown()).optional(),
15524
- tags: record(string(), string()).optional()
15525
- });
15526
- method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15527
- scope: array(string()).optional(),
15528
- level: LogLevelSchema.optional(),
15529
- since: date().optional(),
15530
- until: date().optional(),
15531
- limit: number().optional(),
15532
- tags: record(string(), string()).optional()
15533
- }), array(LogEntrySchema).readonly());
15534
- var CpuBreakdownSchema = object({
15535
- total: number(),
15536
- user: number(),
15537
- system: number(),
15538
- irq: number(),
15539
- nice: number(),
15540
- loadAvg: tuple([
15541
- number(),
15542
- number(),
15543
- number()
15544
- ]),
15545
- cores: number()
15546
- });
15547
- var MemoryInfoSchema = object({
15548
- percent: number(),
15549
- totalBytes: number(),
15550
- usedBytes: number(),
15551
- availableBytes: number(),
15552
- swapUsedBytes: number(),
15553
- swapTotalBytes: number()
15502
+ retryAfterMs: number().optional()
15503
+ })]);
15504
+ /**
15505
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15506
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15507
+ * notification-output.cap.ts:27-31 precedents).
15508
+ */
15509
+ var LlmImageSchema = object({
15510
+ bytes: _instanceof(Uint8Array),
15511
+ mimeType: string()
15554
15512
  });
15555
- var DiskIoSnapshotSchema = object({
15556
- readBytes: number(),
15557
- writeBytes: number(),
15558
- readOps: number(),
15559
- writeOps: number(),
15560
- timestampMs: number()
15561
- });
15562
- var NetworkIoSnapshotSchema = object({
15563
- rxBytes: number(),
15564
- txBytes: number(),
15565
- rxPackets: number(),
15566
- txPackets: number(),
15567
- rxErrors: number(),
15568
- txErrors: number(),
15569
- timestampMs: number()
15570
- });
15571
- var MetricsGpuInfoSchema = object({
15572
- utilization: number(),
15573
- model: string(),
15574
- memoryUsedBytes: number(),
15575
- memoryTotalBytes: number(),
15576
- temperature: number().nullable()
15577
- });
15578
- var ProcessResourceInfoSchema = object({
15579
- openFds: number(),
15580
- threadCount: number(),
15581
- activeHandles: number(),
15582
- activeRequests: number()
15583
- });
15584
- var PressureAvgsSchema = object({
15585
- avg10: number(),
15586
- avg60: number(),
15587
- avg300: number()
15588
- });
15589
- var PressureInfoSchema = object({
15590
- some: PressureAvgsSchema,
15591
- full: PressureAvgsSchema.nullable()
15513
+ var LlmGenerateBaseInputSchema = object({
15514
+ /** Collection routing (the notification-output posture). */
15515
+ addonId: string().optional(),
15516
+ /** Explicit profile; else the resolution chain (spec §3). */
15517
+ profileId: string().optional(),
15518
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15519
+ consumer: string(),
15520
+ system: string().optional(),
15521
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15522
+ prompt: string(),
15523
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15524
+ jsonSchema: record(string(), unknown()).optional(),
15525
+ /** Per-call override of the profile default. */
15526
+ maxTokens: number().int().positive().optional(),
15527
+ temperature: number().optional()
15592
15528
  });
15593
- var SystemResourceSnapshotSchema = object({
15594
- cpu: CpuBreakdownSchema,
15595
- memory: MemoryInfoSchema,
15596
- gpu: MetricsGpuInfoSchema.nullable(),
15597
- network: NetworkIoSnapshotSchema,
15598
- disk: DiskIoSnapshotSchema,
15599
- pressure: object({
15600
- cpu: PressureInfoSchema.nullable(),
15601
- memory: PressureInfoSchema.nullable(),
15602
- io: PressureInfoSchema.nullable()
15529
+ /**
15530
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15531
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15532
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15533
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15534
+ * this only through the `llm` cap's methods.
15535
+ *
15536
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15537
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15538
+ * watchdog — operator decision #3).
15539
+ */
15540
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15541
+ object({
15542
+ kind: literal("catalog"),
15543
+ catalogId: string()
15603
15544
  }),
15604
- process: ProcessResourceInfoSchema,
15605
- cpuTemperature: number().nullable(),
15606
- timestampMs: number()
15607
- });
15608
- var DiskSpaceInfoSchema = object({
15609
- path: string(),
15610
- totalBytes: number(),
15611
- usedBytes: number(),
15612
- availableBytes: number(),
15613
- percent: number()
15614
- });
15615
- var PidResourceStatsSchema = object({
15616
- pid: number(),
15617
- cpu: number(),
15618
- memory: number(),
15619
- /**
15620
- * Private (anonymous) resident bytes — the per-process V8 heap + native
15621
- * allocations NOT shared with other processes (Linux RssAnon). This is the
15622
- * "real" per-runner cost; summing it across runners is meaningful, unlike
15623
- * `memory` (RSS), which double-counts the shared mmap'd framework code.
15624
- * Undefined where /proc is unavailable (e.g. macOS).
15625
- */
15626
- privateBytes: number().optional(),
15627
- /**
15628
- * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15629
- * code shared copy-on-write across runners. Undefined on macOS.
15630
- */
15631
- sharedBytes: number().optional()
15545
+ object({
15546
+ kind: literal("url"),
15547
+ url: string(),
15548
+ sha256: string().optional()
15549
+ }),
15550
+ object({
15551
+ kind: literal("path"),
15552
+ path: string()
15553
+ })
15554
+ ]);
15555
+ var ManagedRuntimeConfigSchema = object({
15556
+ /** WHERE the runtime lives — hub or any agent. */
15557
+ nodeId: string(),
15558
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15559
+ engine: _enum(["llama-cpp"]),
15560
+ model: ManagedModelRefSchema,
15561
+ contextSize: number().int().default(4096),
15562
+ /** 0 = CPU-only. */
15563
+ gpuLayers: number().int().default(0),
15564
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15565
+ threads: number().int().optional(),
15566
+ /** Concurrent slots. */
15567
+ parallel: number().int().default(1),
15568
+ /** Else lazy: first generate boots it. */
15569
+ autoStart: boolean().default(false),
15570
+ /** 0 = never; frees RAM after quiet periods. */
15571
+ idleStopMinutes: number().int().default(30)
15632
15572
  });
15633
- var AddonInstanceSchema = object({
15634
- addonId: string(),
15573
+ var LlmRuntimeStatusSchema = object({
15574
+ /** Status is ALWAYS node-qualified. */
15635
15575
  nodeId: string(),
15636
- role: _enum(["hub", "worker"]),
15637
- pid: number(),
15638
15576
  state: _enum([
15639
- "starting",
15640
- "running",
15641
- "stopping",
15642
15577
  "stopped",
15643
- "crashed"
15644
- ]),
15645
- uptimeSec: number()
15646
- });
15647
- var NodeProcessSchema = object({
15648
- pid: number(),
15649
- ppid: number(),
15650
- pgid: number(),
15651
- classification: _enum([
15652
- "root",
15653
- "managed",
15654
- "system",
15655
- "ghost"
15578
+ "downloading",
15579
+ "starting",
15580
+ "ready",
15581
+ "crashed",
15582
+ "failed"
15656
15583
  ]),
15657
- /** `$process` addon binding when `managed`, else null. */
15658
- addonId: string().nullable(),
15659
- /** Kernel-reported nodeId when the process is a known agent/worker. */
15660
- nodeId: string().nullable(),
15661
- /** Truncated command line. */
15662
- command: string(),
15663
- cpuPercent: number(),
15664
- memoryRssBytes: number(),
15665
- /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15666
- uptimeSec: number(),
15667
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15668
- orphaned: boolean()
15669
- });
15670
- var KillProcessInputSchema = object({
15671
- pid: number(),
15672
- /** Force = SIGKILL. Default is SIGTERM. */
15673
- force: boolean().optional()
15674
- });
15675
- var KillProcessResultSchema = object({
15676
- success: boolean(),
15677
- reason: string().optional(),
15678
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
15679
- });
15680
- var DumpHeapSnapshotInputSchema = object({
15681
- /** The addon whose runner should dump a heap snapshot. */
15682
- addonId: string() });
15683
- var DumpHeapSnapshotResultSchema = object({
15684
- success: boolean(),
15685
- /** Path of the written .heapsnapshot inside the runner's container/host. */
15686
- path: string().optional(),
15687
- /** Process pid that was signalled. */
15688
15584
  pid: number().optional(),
15689
- reason: string().optional()
15585
+ port: number().optional(),
15586
+ modelPath: string().optional(),
15587
+ modelId: string().optional(),
15588
+ downloadProgress: number().min(0).max(1).optional(),
15589
+ lastError: string().optional(),
15590
+ crashesInWindow: number(),
15591
+ /** Child RSS (sampled best-effort). */
15592
+ memoryBytes: number().optional(),
15593
+ vramBytes: number().optional()
15690
15594
  });
15691
- var SystemMetricsSchema = object({
15692
- cpuPercent: number(),
15693
- memoryPercent: number(),
15694
- memoryUsedMB: number(),
15695
- memoryTotalMB: number(),
15696
- diskPercent: number().optional(),
15697
- temperature: number().optional(),
15698
- gpuPercent: number().optional(),
15699
- gpuMemoryPercent: number().optional()
15595
+ var LlmNodeModelSchema = object({
15596
+ file: string(),
15597
+ sizeBytes: number(),
15598
+ catalogId: string().optional(),
15599
+ installedAt: number().optional()
15700
15600
  });
15701
- method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
15601
+ var LlmRuntimeDiskUsageSchema = object({
15602
+ nodeId: string(),
15603
+ modelsBytes: number(),
15604
+ freeBytes: number().optional()
15605
+ });
15606
+ method(LlmGenerateBaseInputSchema.extend({
15607
+ images: array(LlmImageSchema).optional(),
15608
+ runtime: ManagedRuntimeConfigSchema,
15609
+ /** The managed profile's timeout, threaded by the hub provider. */
15610
+ timeoutMs: number().int().positive().optional()
15611
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15702
15612
  kind: "mutation",
15703
15613
  auth: "admin"
15704
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
15614
+ }), method(object({}), _void(), {
15705
15615
  kind: "mutation",
15706
15616
  auth: "admin"
15707
- });
15708
- method(object({
15709
- sourceUrl: string(),
15710
- metadata: ModelConvertMetadataSchema,
15711
- targets: array(ConvertTargetSchema).min(1).readonly(),
15712
- calibrationRef: string().optional(),
15713
- sessionId: string().optional()
15714
- }), ConvertResultSchema, {
15617
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15715
15618
  kind: "mutation",
15716
- auth: "admin",
15717
- timeoutMs: 6e5
15718
- });
15719
- method(object({
15720
- nodeId: string(),
15721
- modelId: string(),
15722
- format: _enum(MODEL_FORMATS),
15723
- entry: ModelCatalogEntrySchema
15724
- }), object({
15725
- ok: boolean(),
15726
- /** sha256 of the staged tarball (empty for a hub-local no-op). */
15727
- sha256: string(),
15728
- bytes: number(),
15729
- /** The target node's modelsDir the artifact landed in. */
15730
- path: string()
15731
- }), {
15619
+ auth: "admin"
15620
+ }), method(object({ file: string() }), _void(), {
15732
15621
  kind: "mutation",
15733
15622
  auth: "admin"
15734
- });
15623
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15624
+ /**
15625
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15626
+ * methods concat-fan across providers; single-row methods route to ONE
15627
+ * provider by the `addonId` in the call input (the notification-output
15628
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15629
+ * (hub-placed); the cap stays open for future providers.
15630
+ *
15631
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15632
+ * `apiKey` is a password field — providers REDACT it on read and merge on
15633
+ * write; a stored key NEVER round-trips to a client.
15634
+ */
15635
+ var LlmProfileKindSchema = _enum([
15636
+ "openai-compatible",
15637
+ "openai",
15638
+ "anthropic",
15639
+ "google",
15640
+ "managed-local"
15641
+ ]);
15642
+ var LlmProfileSchema = object({
15643
+ id: string(),
15644
+ name: string(),
15645
+ kind: LlmProfileKindSchema,
15646
+ /** Stamped by the provider — keeps the fanned catalog routable. */
15647
+ addonId: string(),
15648
+ enabled: boolean(),
15649
+ /** Vendor model id, or the managed runtime's loaded model. */
15650
+ model: string(),
15651
+ /** Required for openai-compatible; override for cloud kinds. */
15652
+ baseUrl: string().optional(),
15653
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15654
+ apiKey: string().optional(),
15655
+ supportsVision: boolean(),
15656
+ temperature: number().min(0).max(2).optional(),
15657
+ maxTokens: number().int().positive().optional(),
15658
+ timeoutMs: number().int().positive().default(6e4),
15659
+ extraHeaders: record(string(), string()).optional(),
15660
+ /** kind === 'managed-local' only (spec §4). */
15661
+ runtime: ManagedRuntimeConfigSchema.optional()
15662
+ });
15663
+ /** ConfigUISchema tree passed through untyped on the wire (the
15664
+ * notification-output `ConfigSchemaPassthrough` precedent at
15665
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15666
+ var ConfigSchemaPassthrough$1 = unknown();
15667
+ var LlmProfileKindDescriptorSchema = object({
15668
+ kind: LlmProfileKindSchema,
15669
+ label: string(),
15670
+ icon: string(),
15671
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
15672
+ addonId: string(),
15673
+ configSchema: ConfigSchemaPassthrough$1
15674
+ });
15675
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15676
+ var LlmDefaultSchema = object({
15677
+ selector: LlmDefaultSelectorSchema,
15678
+ profileId: string()
15679
+ });
15680
+ /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15681
+ var LlmUsageRollupSchema = object({
15682
+ day: string(),
15683
+ consumer: string(),
15684
+ profileId: string(),
15685
+ calls: number(),
15686
+ okCalls: number(),
15687
+ errorCalls: number(),
15688
+ inputTokens: number(),
15689
+ outputTokens: number(),
15690
+ avgLatencyMs: number()
15691
+ });
15692
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15693
+ var ManagedModelCatalogEntrySchema = object({
15694
+ id: string(),
15695
+ label: string(),
15696
+ family: string(),
15697
+ purpose: _enum(["text", "vision"]),
15698
+ url: string(),
15699
+ sha256: string(),
15700
+ sizeBytes: number(),
15701
+ quantization: string(),
15702
+ /** Load-time guidance shown in the picker. */
15703
+ minRamBytes: number(),
15704
+ contextSizeDefault: number().int(),
15705
+ /** Vision models: companion projector file. */
15706
+ mmprojUrl: string().optional()
15707
+ });
15708
+ var LlmRuntimeNodeSchema = object({
15709
+ nodeId: string(),
15710
+ reachable: boolean(),
15711
+ status: LlmRuntimeStatusSchema.optional(),
15712
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15713
+ error: string().optional()
15714
+ });
15715
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15716
+ var ProfileRefInputSchema = object({
15717
+ addonId: string(),
15718
+ profileId: string()
15719
+ });
15720
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
15721
+ kind: "mutation",
15722
+ auth: "admin"
15723
+ }), method(ProfileRefInputSchema, _void(), {
15724
+ kind: "mutation",
15725
+ auth: "admin"
15726
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
15727
+ kind: "mutation",
15728
+ auth: "admin"
15729
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
15730
+ selector: LlmDefaultSelectorSchema,
15731
+ profileId: string().nullable()
15732
+ }), _void(), {
15733
+ kind: "mutation",
15734
+ auth: "admin"
15735
+ }), method(object({
15736
+ since: number().optional(),
15737
+ until: number().optional(),
15738
+ consumer: string().optional(),
15739
+ profileId: string().optional()
15740
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
15741
+ nodeId: string(),
15742
+ model: ManagedModelRefSchema
15743
+ }), _void(), {
15744
+ kind: "mutation",
15745
+ auth: "admin"
15746
+ }), method(object({
15747
+ nodeId: string(),
15748
+ file: string()
15749
+ }), _void(), {
15750
+ kind: "mutation",
15751
+ auth: "admin"
15752
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
15753
+ kind: "mutation",
15754
+ auth: "admin"
15755
+ }), method(ProfileRefInputSchema, _void(), {
15756
+ kind: "mutation",
15757
+ auth: "admin"
15758
+ });
15759
+ var LogLevelSchema = _enum([
15760
+ "debug",
15761
+ "info",
15762
+ "warn",
15763
+ "error"
15764
+ ]);
15765
+ var LogEntrySchema = object({
15766
+ timestamp: date(),
15767
+ level: LogLevelSchema,
15768
+ scope: array(string()),
15769
+ message: string(),
15770
+ meta: record(string(), unknown()).optional(),
15771
+ tags: record(string(), string()).optional()
15772
+ });
15773
+ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
15774
+ scope: array(string()).optional(),
15775
+ level: LogLevelSchema.optional(),
15776
+ since: date().optional(),
15777
+ until: date().optional(),
15778
+ limit: number().optional(),
15779
+ tags: record(string(), string()).optional()
15780
+ }), array(LogEntrySchema).readonly());
15781
+ /**
15782
+ * `login-method` — collection cap through which auth addons contribute
15783
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
15784
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
15785
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15786
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15787
+ * procedure aggregates them for the unauthenticated login page.
15788
+ *
15789
+ * A contribution is a discriminated union on `kind`:
15790
+ *
15791
+ * - `redirect` — a declarative button. The login page renders a generic
15792
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
15793
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
15794
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
15795
+ * login page needs NO change.
15796
+ *
15797
+ * - `widget` — a Module-Federation widget the login page mounts (via
15798
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
15799
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
15800
+ * mechanism kept for future use; no shipped addon uses it on the login
15801
+ * page (the passkey ceremony below runs natively in the shell instead).
15802
+ *
15803
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
15804
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
15805
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
15806
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
15807
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
15808
+ * fetching any remote code pre-auth. Contribution stays unconditional —
15809
+ * enrollment state is never leaked pre-auth; visibility is a shell
15810
+ * decision.
15811
+ *
15812
+ * Every contribution carries a `stage`:
15813
+ * - `primary` — shown on the first credentials screen (OIDC /
15814
+ * magic-link buttons; a future usernameless passkey).
15815
+ * - `second-factor` — shown AFTER the password leg, gated on the
15816
+ * returned `factors` (passkey-as-2FA today).
15817
+ *
15818
+ * `mount: skip` — the cap is read server-side by the core auth router
15819
+ * (`registry.getCollection('login-method')`), never mounted as its own
15820
+ * tRPC router.
15821
+ */
15822
+ /** When a login method renders in the two-phase login flow. */
15823
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
15824
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
15825
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
15826
+ object({
15827
+ kind: literal("redirect"),
15828
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
15829
+ id: string(),
15830
+ /** Operator-facing button label. */
15831
+ label: string(),
15832
+ /** lucide-react icon name. */
15833
+ icon: string().optional(),
15834
+ /** Addon-owned HTTP route the button navigates to (GET). */
15835
+ startUrl: string(),
15836
+ stage: LoginStageEnum
15837
+ }),
15838
+ object({
15839
+ kind: literal("widget"),
15840
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
15841
+ id: string(),
15842
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
15843
+ addonId: string(),
15844
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
15845
+ bundle: string(),
15846
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
15847
+ remote: WidgetRemoteSchema,
15848
+ stage: LoginStageEnum
15849
+ }),
15850
+ object({
15851
+ kind: literal("passkey"),
15852
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
15853
+ id: string(),
15854
+ /** Operator-facing button label. */
15855
+ label: string(),
15856
+ stage: LoginStageEnum,
15857
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
15858
+ rpId: string(),
15859
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
15860
+ origin: string().nullable()
15861
+ })
15862
+ ]);
15863
+ method(_void(), array(LoginMethodContributionSchema).readonly());
15864
+ var CpuBreakdownSchema = object({
15865
+ total: number(),
15866
+ user: number(),
15867
+ system: number(),
15868
+ irq: number(),
15869
+ nice: number(),
15870
+ loadAvg: tuple([
15871
+ number(),
15872
+ number(),
15873
+ number()
15874
+ ]),
15875
+ cores: number()
15876
+ });
15877
+ var MemoryInfoSchema = object({
15878
+ percent: number(),
15879
+ totalBytes: number(),
15880
+ usedBytes: number(),
15881
+ availableBytes: number(),
15882
+ swapUsedBytes: number(),
15883
+ swapTotalBytes: number()
15884
+ });
15885
+ var DiskIoSnapshotSchema = object({
15886
+ readBytes: number(),
15887
+ writeBytes: number(),
15888
+ readOps: number(),
15889
+ writeOps: number(),
15890
+ timestampMs: number()
15891
+ });
15892
+ var NetworkIoSnapshotSchema = object({
15893
+ rxBytes: number(),
15894
+ txBytes: number(),
15895
+ rxPackets: number(),
15896
+ txPackets: number(),
15897
+ rxErrors: number(),
15898
+ txErrors: number(),
15899
+ timestampMs: number()
15900
+ });
15901
+ var MetricsGpuInfoSchema = object({
15902
+ utilization: number(),
15903
+ model: string(),
15904
+ memoryUsedBytes: number(),
15905
+ memoryTotalBytes: number(),
15906
+ temperature: number().nullable()
15907
+ });
15908
+ var ProcessResourceInfoSchema = object({
15909
+ openFds: number(),
15910
+ threadCount: number(),
15911
+ activeHandles: number(),
15912
+ activeRequests: number()
15913
+ });
15914
+ var PressureAvgsSchema = object({
15915
+ avg10: number(),
15916
+ avg60: number(),
15917
+ avg300: number()
15918
+ });
15919
+ var PressureInfoSchema = object({
15920
+ some: PressureAvgsSchema,
15921
+ full: PressureAvgsSchema.nullable()
15922
+ });
15923
+ var SystemResourceSnapshotSchema = object({
15924
+ cpu: CpuBreakdownSchema,
15925
+ memory: MemoryInfoSchema,
15926
+ gpu: MetricsGpuInfoSchema.nullable(),
15927
+ network: NetworkIoSnapshotSchema,
15928
+ disk: DiskIoSnapshotSchema,
15929
+ pressure: object({
15930
+ cpu: PressureInfoSchema.nullable(),
15931
+ memory: PressureInfoSchema.nullable(),
15932
+ io: PressureInfoSchema.nullable()
15933
+ }),
15934
+ process: ProcessResourceInfoSchema,
15935
+ cpuTemperature: number().nullable(),
15936
+ timestampMs: number()
15937
+ });
15938
+ var DiskSpaceInfoSchema = object({
15939
+ path: string(),
15940
+ totalBytes: number(),
15941
+ usedBytes: number(),
15942
+ availableBytes: number(),
15943
+ percent: number()
15944
+ });
15945
+ var PidResourceStatsSchema = object({
15946
+ pid: number(),
15947
+ cpu: number(),
15948
+ memory: number(),
15949
+ /**
15950
+ * Private (anonymous) resident bytes — the per-process V8 heap + native
15951
+ * allocations NOT shared with other processes (Linux RssAnon). This is the
15952
+ * "real" per-runner cost; summing it across runners is meaningful, unlike
15953
+ * `memory` (RSS), which double-counts the shared mmap'd framework code.
15954
+ * Undefined where /proc is unavailable (e.g. macOS).
15955
+ */
15956
+ privateBytes: number().optional(),
15957
+ /**
15958
+ * Shared file-backed resident bytes (Linux RssFile) — mmap'd framework/lib
15959
+ * code shared copy-on-write across runners. Undefined on macOS.
15960
+ */
15961
+ sharedBytes: number().optional()
15962
+ });
15963
+ var AddonInstanceSchema = object({
15964
+ addonId: string(),
15965
+ nodeId: string(),
15966
+ role: _enum(["hub", "worker"]),
15967
+ pid: number(),
15968
+ state: _enum([
15969
+ "starting",
15970
+ "running",
15971
+ "stopping",
15972
+ "stopped",
15973
+ "crashed"
15974
+ ]),
15975
+ uptimeSec: number()
15976
+ });
15977
+ var NodeProcessSchema = object({
15978
+ pid: number(),
15979
+ ppid: number(),
15980
+ pgid: number(),
15981
+ classification: _enum([
15982
+ "root",
15983
+ "managed",
15984
+ "system",
15985
+ "ghost"
15986
+ ]),
15987
+ /** `$process` addon binding when `managed`, else null. */
15988
+ addonId: string().nullable(),
15989
+ /** Kernel-reported nodeId when the process is a known agent/worker. */
15990
+ nodeId: string().nullable(),
15991
+ /** Truncated command line. */
15992
+ command: string(),
15993
+ cpuPercent: number(),
15994
+ memoryRssBytes: number(),
15995
+ /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
15996
+ uptimeSec: number(),
15997
+ /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
15998
+ orphaned: boolean()
15999
+ });
16000
+ var KillProcessInputSchema = object({
16001
+ pid: number(),
16002
+ /** Force = SIGKILL. Default is SIGTERM. */
16003
+ force: boolean().optional()
16004
+ });
16005
+ var KillProcessResultSchema = object({
16006
+ success: boolean(),
16007
+ reason: string().optional(),
16008
+ signal: _enum(["SIGTERM", "SIGKILL"]).optional()
16009
+ });
16010
+ var DumpHeapSnapshotInputSchema = object({
16011
+ /** The addon whose runner should dump a heap snapshot. */
16012
+ addonId: string() });
16013
+ var DumpHeapSnapshotResultSchema = object({
16014
+ success: boolean(),
16015
+ /** Path of the written .heapsnapshot inside the runner's container/host. */
16016
+ path: string().optional(),
16017
+ /** Process pid that was signalled. */
16018
+ pid: number().optional(),
16019
+ reason: string().optional()
16020
+ });
16021
+ var SystemMetricsSchema = object({
16022
+ cpuPercent: number(),
16023
+ memoryPercent: number(),
16024
+ memoryUsedMB: number(),
16025
+ memoryTotalMB: number(),
16026
+ diskPercent: number().optional(),
16027
+ temperature: number().optional(),
16028
+ gpuPercent: number().optional(),
16029
+ gpuMemoryPercent: number().optional()
16030
+ });
16031
+ method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
16032
+ kind: "mutation",
16033
+ auth: "admin"
16034
+ }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
16035
+ kind: "mutation",
16036
+ auth: "admin"
16037
+ });
16038
+ method(object({
16039
+ sourceUrl: string(),
16040
+ metadata: ModelConvertMetadataSchema,
16041
+ targets: array(ConvertTargetSchema).min(1).readonly(),
16042
+ calibrationRef: string().optional(),
16043
+ sessionId: string().optional()
16044
+ }), ConvertResultSchema, {
16045
+ kind: "mutation",
16046
+ auth: "admin",
16047
+ timeoutMs: 6e5
16048
+ });
16049
+ method(object({
16050
+ nodeId: string(),
16051
+ modelId: string(),
16052
+ format: _enum(MODEL_FORMATS),
16053
+ entry: ModelCatalogEntrySchema
16054
+ }), object({
16055
+ ok: boolean(),
16056
+ /** sha256 of the staged tarball (empty for a hub-local no-op). */
16057
+ sha256: string(),
16058
+ bytes: number(),
16059
+ /** The target node's modelsDir the artifact landed in. */
16060
+ path: string()
16061
+ }), {
16062
+ kind: "mutation",
16063
+ auth: "admin"
16064
+ });
15735
16065
  /**
15736
16066
  * `mqtt-broker` — broker-registry cap.
15737
16067
  *
@@ -16003,14 +16333,14 @@ var TargetKindCapsSchema = object({
16003
16333
  * the union is large and not meant for runtime validation here; the exported
16004
16334
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
16005
16335
  */
16006
- var ConfigSchemaPassthrough$1 = unknown();
16336
+ var ConfigSchemaPassthrough = unknown();
16007
16337
  var TargetKindSchema = object({
16008
16338
  kind: string(),
16009
16339
  label: string(),
16010
16340
  icon: string(),
16011
16341
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
16012
16342
  addonId: string(),
16013
- configSchema: ConfigSchemaPassthrough$1,
16343
+ configSchema: ConfigSchemaPassthrough,
16014
16344
  supportsDiscovery: boolean(),
16015
16345
  caps: TargetKindCapsSchema
16016
16346
  });
@@ -16077,297 +16407,493 @@ var notificationOutputCapability = {
16077
16407
  }
16078
16408
  };
16079
16409
  /**
16080
- * Shared LLM generate contracts imported by BOTH `llm.cap.ts` (consumer
16081
- * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
16082
- * caps stay wire-compatible without a circular cap→cap import.
16410
+ * notification-rules the Notification Center rule surface (P1 core).
16083
16411
  *
16084
- * Errors are a discriminated-union RESULT, never thrown: the shape survives
16085
- * every transport tier structurally, and failed calls still write usage rows.
16086
- * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
16412
+ * Spec: `docs/superpowers/specs/2026-07-22-notification-center-requirements.md`
16413
+ * (operator decisions D-1/D-2/D-3 are binding):
16414
+ *
16415
+ * - D-2: rule EVALUATION lives in `addon-post-analysis` (the
16416
+ * `notification-center` module), hooked on the durable persistence
16417
+ * moments (object-event insert, TrackCloser.closeExpired) with a
16418
+ * persisted outbox + retry — never the lossy telemetry bus (D8).
16419
+ * - D-3: urgency belongs to the RULE. `delivery: 'immediate'` fires on the
16420
+ * FIRST persisted detection matching the conditions (per-track dedup,
16421
+ * `maxPerTrack` fixed at 1 — see {@link NC_MAX_PER_TRACK_IMMEDIATE});
16422
+ * `delivery: 'track-end'` evaluates the finalized track record at close.
16423
+ * - DISPATCH stays behind `notification-output` (rules reference targets
16424
+ * by id; per-backend params are a passthrough blob capped by the
16425
+ * target kind's own caps/degrade engine).
16426
+ *
16427
+ * P1 scope: admin-authored rules only (`createdBy` stamped from the
16428
+ * server-injected caller identity — the first `caller: 'required'`
16429
+ * adopter). The P1 condition subset is: devices, classes(+exclude),
16430
+ * minConfidence, admin zones (any/all + exclude), weekly schedule
16431
+ * windows, and the optional label/identity/plate matchers. User rules,
16432
+ * private zones, per-recipient fan-out and the wider condition table are
16433
+ * P2+ (see spec §7).
16434
+ *
16435
+ * All schemas here are the single source of truth — `NcRule` etc. are
16436
+ * `z.infer` exports; no duplicate interfaces (the advanced-notifier
16437
+ * schema/interface drift is explicitly not repeated).
16087
16438
  */
16088
- var LlmUsageSchema = object({
16089
- inputTokens: number(),
16090
- outputTokens: number()
16091
- });
16092
- var LlmErrorCodeSchema = _enum([
16093
- "timeout",
16094
- "rate-limited",
16095
- "auth",
16096
- "refusal",
16097
- "bad-request",
16098
- "unavailable",
16099
- "no-profile",
16100
- "budget-exceeded",
16101
- "adapter-error"
16439
+ /**
16440
+ * D-3: the trigger/urgency of a rule — which persistence moment evaluates it.
16441
+ * The value maps 1:1 onto the evaluated record kind:
16442
+ * - `immediate` ↔ object-event persist (lowest-latency detection burst)
16443
+ * - `track-end` ↔ TrackCloser.closeExpired (finalized track record)
16444
+ * - `device-event` ↔ SensorEventStore insert (doorbell press / sensor state
16445
+ * change of a LINKED device, one row per linked camera)
16446
+ * - `package-event` ↔ PackageDropDetector object-event insert (a `package`
16447
+ * delivery / pick-up)
16448
+ *
16449
+ * `immediate`/`track-end` carry the D-3 urgency semantics; `device-event`/
16450
+ * `package-event` are pure trigger kinds (no urgency dimension). Extending
16451
+ * this one field keeps the schema additive — a rule still declares exactly
16452
+ * one trigger.
16453
+ */
16454
+ var NcDeliverySchema = _enum([
16455
+ "immediate",
16456
+ "track-end",
16457
+ "device-event",
16458
+ "package-event"
16102
16459
  ]);
16103
- var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
16104
- ok: literal(true),
16105
- text: string(),
16106
- model: string(),
16107
- usage: LlmUsageSchema,
16108
- truncated: boolean(),
16109
- latencyMs: number()
16110
- }), object({
16111
- ok: literal(false),
16112
- code: LlmErrorCodeSchema,
16113
- message: string(),
16114
- retryAfterMs: number().optional()
16115
- })]);
16460
+ /** Weekly schedule — OR of windows; absence on the rule = always active. */
16461
+ var NcScheduleSchema = object({
16462
+ windows: array(object({
16463
+ /** Days of week the window STARTS on (0 = Sunday … 6 = Saturday). */
16464
+ days: array(number().int().min(0).max(6)).min(1),
16465
+ startMinute: number().int().min(0).max(1439),
16466
+ endMinute: number().int().min(0).max(1439)
16467
+ })).min(1),
16468
+ /** IANA timezone; default = hub host timezone. */
16469
+ timezone: string().optional(),
16470
+ /** Active OUTSIDE the windows (e.g. "only outside business hours"). */
16471
+ invert: boolean().optional()
16472
+ });
16473
+ /** Fuzzy plate matcher — OCR noise makes exact match useless (spec row 12/13). */
16474
+ var NcPlateMatcherSchema = object({
16475
+ values: array(string().min(1)).min(1),
16476
+ /** Max Levenshtein distance after normalization (uppercase alphanumeric). */
16477
+ maxDistance: number().int().min(0).max(3).default(1)
16478
+ });
16116
16479
  /**
16117
- * `Uint8Array` is the sanctioned binary convention superjson + the UDS
16118
- * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
16119
- * notification-output.cap.ts:27-31 precedents).
16480
+ * Occupancy condition (DEVICE-EVENT trigger). Fires on a ZoneAnalytics
16481
+ * occupancy edge for a device — optionally narrowed to a single admin
16482
+ * `zoneId` and/or object `className`. `op` selects the edge/threshold:
16483
+ * - `became-occupied` (default) — count crossed 0 → ≥ `count`
16484
+ * - `became-free` — count crossed ≥ `count` → below it
16485
+ * - `>=` / `<=` — count is at/over or at/under `count`
16486
+ * `sustainSeconds` requires the condition hold continuously that long
16487
+ * before firing (debounces flicker; 0 = fire on the first matching edge).
16488
+ * Fail-closed: no ZoneAnalytics snapshot / missing zone / null snapshot ⇒
16489
+ * the condition never matches. Confirmed edge-state survives addon restarts
16490
+ * (declared SQLite collection, reseeded on boot).
16120
16491
  */
16121
- var LlmImageSchema = object({
16122
- bytes: _instanceof(Uint8Array),
16123
- mimeType: string()
16492
+ var NcOccupancyConditionSchema = object({
16493
+ /** Admin zone id to scope the count to; absent = whole-frame occupancy. */
16494
+ zoneId: string().optional(),
16495
+ /** Object class to count; absent = any class. */
16496
+ className: string().optional(),
16497
+ op: _enum([
16498
+ "became-occupied",
16499
+ "became-free",
16500
+ ">=",
16501
+ "<="
16502
+ ]).default("became-occupied"),
16503
+ count: number().int().min(0).default(1),
16504
+ sustainSeconds: number().int().min(0).max(3600).default(15)
16505
+ });
16506
+ /** Admin-zone membership condition (zone IDs as stamped by the ZoneEngine). */
16507
+ var NcZoneConditionSchema = object({
16508
+ ids: array(string().min(1)).min(1),
16509
+ /** Quantifier over `ids` — at least one / every one visited. */
16510
+ match: _enum(["any", "all"]).default("any")
16124
16511
  });
16125
- var LlmGenerateBaseInputSchema = object({
16126
- /** Collection routing (the notification-output posture). */
16127
- addonId: string().optional(),
16128
- /** Explicit profile; else the resolution chain (spec §3). */
16129
- profileId: string().optional(),
16130
- /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', */
16131
- consumer: string(),
16132
- system: string().optional(),
16133
- /** v1: single-turn. `messages[]` is a v2 additive field. */
16134
- prompt: string(),
16135
- /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
16136
- jsonSchema: record(string(), unknown()).optional(),
16137
- /** Per-call override of the profile default. */
16138
- maxTokens: number().int().positive().optional(),
16139
- temperature: number().optional()
16512
+ /**
16513
+ * The P1 condition set a flat AND of groups; absent group = pass;
16514
+ * membership lists are OR within the list (spec §2.3).
16515
+ */
16516
+ var NcConditionsSchema = object({
16517
+ /** Device scope absent = all devices. */
16518
+ devices: array(number()).optional(),
16519
+ /** Detector class names (any overlap with the record's class set). */
16520
+ classes: array(string().min(1)).optional(),
16521
+ /** Veto classes — any overlap fails the rule. */
16522
+ classesExclude: array(string().min(1)).optional(),
16523
+ /** Minimum detection confidence 0–1 (fails when the record has none). */
16524
+ minConfidence: number().min(0).max(1).optional(),
16525
+ /** Admin zone membership over event `zones` / track `zonesVisited`. */
16526
+ zones: NcZoneConditionSchema.optional(),
16527
+ /** Veto zones — any hit fails the rule. */
16528
+ zonesExclude: array(string().min(1)).optional(),
16529
+ /**
16530
+ * Exact (case-insensitive) match on the record's collapsed `label`
16531
+ * (identity name / plate text / subclass).
16532
+ */
16533
+ labelEquals: array(string().min(1)).optional(),
16534
+ /**
16535
+ * Identity matcher. P1 boundary: matched against the record's collapsed
16536
+ * `label` (the identity display name propagated by the face pipeline) —
16537
+ * identity-ID matching rides in P2 when identity ids reach the record.
16538
+ */
16539
+ identities: array(string().min(1)).optional(),
16540
+ /** Fuzzy plate matcher against the record's `label` (plate text). */
16541
+ plates: NcPlateMatcherSchema.optional(),
16542
+ /**
16543
+ * Identity EXCLUDE — mirror of {@link identities} with `notIn` semantics.
16544
+ * Same P1 boundary: matched against the record's collapsed `label` (the
16545
+ * identity display name). A record with NO label passes (nothing to
16546
+ * exclude), unlike the include variant which fails on an absent label.
16547
+ */
16548
+ identitiesExclude: array(string().min(1)).optional(),
16549
+ /**
16550
+ * Minimum server-computed key-event importance in [0,1] (`Track.importance`).
16551
+ * TRACK-END only: importance is scored at track close, so it does not exist
16552
+ * at immediate / object-event evaluation time (see catalog `appliesTo`). At
16553
+ * close the value is threaded via the close-time info (the `Track` clone is
16554
+ * captured before the DB row is updated, so it would otherwise read stale).
16555
+ * Fails when the record carries no importance (never guess quality — the
16556
+ * `minConfidence` precedent). MVP cut: a single scalar threshold.
16557
+ */
16558
+ minImportance: number().min(0).max(1).optional(),
16559
+ /**
16560
+ * Minimum track dwell in SECONDS — `(lastSeen − firstSeen) / 1000`.
16561
+ * TRACK-END only: an `immediate` / object-event subject has no closed
16562
+ * lifespan, so a dwell condition never matches immediate delivery
16563
+ * (documented choice — the object-event record carries no `firstSeen`,
16564
+ * so dwell cannot be computed from what the subject actually carries).
16565
+ */
16566
+ minDwellSeconds: number().min(0).optional(),
16567
+ /**
16568
+ * Detection provenance filter. `any` (default / absent) matches every
16569
+ * source; otherwise the subject's source must equal it. Legacy records
16570
+ * with no stamped source are treated as `pipeline`. The union spans both
16571
+ * record kinds — object events carry `pipeline` | `onboard`, synthetic
16572
+ * tracks carry `sensor`.
16573
+ */
16574
+ source: _enum([
16575
+ "pipeline",
16576
+ "onboard",
16577
+ "sensor",
16578
+ "any"
16579
+ ]).optional(),
16580
+ /**
16581
+ * Minimum identity / plate MATCH confidence in [0,1] — DISTINCT from the
16582
+ * detector `minConfidence` (that gates the object-detection score; this
16583
+ * gates the recognition/OCR match score). Fails when the subject carries
16584
+ * no label-match confidence (never guess). TRACK-END only: the confidence
16585
+ * lives on the recognition result and reaches the subject at track close.
16586
+ *
16587
+ * What it measures precisely (plumbed at track close — the closer threads
16588
+ * the value into `NcTrackClosedInfo.labelConfidence`, the same seam as
16589
+ * `importance`): the BEST recognition match confidence observed for the
16590
+ * label the track carries at close — for a face, the peak cosine similarity
16591
+ * of the ASSIGNED identity (`FaceMatch.score`, reset on an identity switch);
16592
+ * for a plate, the peak OCR read score of the best-held plate
16593
+ * (`plateText.confidence`). When BOTH a face and a plate were recognized on
16594
+ * one track the higher of the two is used. A track that ended with no
16595
+ * confident identity/plate match carries no value, so the condition fails
16596
+ * closed for it (an un-recognized subject).
16597
+ */
16598
+ minLabelConfidence: number().min(0).max(1).optional(),
16599
+ /**
16600
+ * DEVICE-EVENT only. Raw device event-type tokens (`EventFire.eventType`,
16601
+ * e.g. a doorbell `press` / `press_long`) — matched case-insensitively
16602
+ * against the token carried on the device-event subject (extracted from the
16603
+ * event-emitter runtime slice's `lastEvent.eventType`). Fails when the
16604
+ * subject carries no token. Doorbell-pulse / passive-sensor kinds emit no
16605
+ * eventType, so gate those with {@link sensorKinds} instead.
16606
+ */
16607
+ eventTypeTokens: array(string().min(1)).optional(),
16608
+ /**
16609
+ * DEVICE-EVENT only. Sensor/control taxonomy kinds (e.g. `doorbell`,
16610
+ * `contact`, `button`, `device-event`) — matched against the persisted
16611
+ * `SensorEvent.kind` (see `sensor-event-kinds.ts`). Membership is OR.
16612
+ */
16613
+ sensorKinds: array(string().min(1)).optional(),
16614
+ /**
16615
+ * PACKAGE-EVENT only. Which package phase fires the rule — `delivered`
16616
+ * (a parked parcel appeared), `picked-up` (it departed), or `both`. Fails
16617
+ * when the subject's phase does not match (a subject always carries a phase
16618
+ * on the package-event trigger).
16619
+ */
16620
+ packagePhase: _enum([
16621
+ "delivered",
16622
+ "picked-up",
16623
+ "both"
16624
+ ]).optional(),
16625
+ /**
16626
+ * PERSONAL-RULE custom zones (viewer-drawn). Inline normalized polygons
16627
+ * (MaskShape vocabulary). A record passes when its bbox overlaps ANY
16628
+ * listed polygon (ZoneEngine membership semantics). Evaluated only when
16629
+ * the subject carries a bbox; absent bbox ⇒ the condition FAILS.
16630
+ */
16631
+ customZones: array(MaskPolygonShapeSchema).optional(),
16632
+ /**
16633
+ * DEVICE-EVENT only. ZoneAnalytics occupancy edge — fires when a device's
16634
+ * (optionally zone/class-scoped) occupancy count crosses the configured
16635
+ * threshold and holds for `sustainSeconds`. Fail-closed on missing
16636
+ * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
16637
+ */
16638
+ occupancy: NcOccupancyConditionSchema.optional()
16639
+ });
16640
+ /** One delivery target: a `notification-output` Target ref + passthrough params. */
16641
+ var NcRuleTargetSchema = object({
16642
+ /** `notification-output` Target id. */
16643
+ targetId: string().min(1),
16644
+ /**
16645
+ * Per-backend passthrough. Recognized keys are mapped onto the canonical
16646
+ * Notification (`priority`, `level`, `sound`, `clickUrl`, `ttl`); the
16647
+ * degrade engine drops what the backend can't render.
16648
+ */
16649
+ params: record(string(), unknown()).optional()
16140
16650
  });
16141
16651
  /**
16142
- * `llm-runtime` node-side managed llama.cpp executor (spec §4). Registered
16143
- * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
16144
- * a specific node's runtime with `nodePin(profile.runtime.nodeId)` normal
16145
- * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
16146
- * this only through the `llm` cap's methods.
16147
- *
16148
- * One running llama-server child per node in v1 (models are RAM-heavy).
16149
- * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
16150
- * watchdog operator decision #3).
16652
+ * Media attachment policy (P1 still-image subset).
16653
+ * - `best` the best AVAILABLE subject image at dispatch time (D-3).
16654
+ * - `best-matching` the media that explains WHY the rule fired: a rule
16655
+ * matched on identities attaches the subject's `faceCrop`, one matched on
16656
+ * plates attaches the `plateCrop`; a rule with no identity/plate condition
16657
+ * (or when the specific crop is missing) degrades to `best`, then
16658
+ * `keyFrame`, then no attachment never delaying the send. The matched
16659
+ * condition summary is frozen on the outbox row at enqueue (like the rule
16660
+ * name), so the choice never drifts from the record that fired it.
16661
+ * - `keyFrame` — the clean scene frame (no subject box).
16662
+ * - `none` — no attachment.
16151
16663
  */
16152
- var ManagedModelRefSchema = discriminatedUnion("kind", [
16153
- object({
16154
- kind: literal("catalog"),
16155
- catalogId: string()
16156
- }),
16157
- object({
16158
- kind: literal("url"),
16159
- url: string(),
16160
- sha256: string().optional()
16664
+ var NcMediaPolicySchema = object({ attach: _enum([
16665
+ "best",
16666
+ "best-matching",
16667
+ "keyFrame",
16668
+ "none"
16669
+ ]).default("best") });
16670
+ /** Throttle — cooldown survives restarts (rebuilt from the outbox on boot). */
16671
+ var NcThrottleSchema = object({
16672
+ cooldownSec: number().int().min(0).max(86400).default(60),
16673
+ /** `rule` = one shared cooldown; `rule-device` = per-camera cooldown. */
16674
+ scope: _enum(["rule", "rule-device"]).default("rule-device")
16675
+ });
16676
+ /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
16677
+ var NcRuleInputSchema = object({
16678
+ name: string().min(1).max(200),
16679
+ enabled: boolean().default(true),
16680
+ delivery: NcDeliverySchema,
16681
+ conditions: NcConditionsSchema.default({}),
16682
+ schedule: NcScheduleSchema.optional(),
16683
+ targets: array(NcRuleTargetSchema).min(1),
16684
+ media: NcMediaPolicySchema.default({ attach: "best" }),
16685
+ throttle: NcThrottleSchema.default({
16686
+ cooldownSec: 60,
16687
+ scope: "rule-device"
16161
16688
  }),
16162
- object({
16163
- kind: literal("path"),
16164
- path: string()
16165
- })
16166
- ]);
16167
- var ManagedRuntimeConfigSchema = object({
16168
- /** WHERE the runtime lives — hub or any agent. */
16169
- nodeId: string(),
16170
- /** Closed for v1; 'ollama' is a v2 candidate. */
16171
- engine: _enum(["llama-cpp"]),
16172
- model: ManagedModelRefSchema,
16173
- contextSize: number().int().default(4096),
16174
- /** 0 = CPU-only. */
16175
- gpuLayers: number().int().default(0),
16176
- /** Default: cpus-2, clamped ≥1 (resolved node-side). */
16177
- threads: number().int().optional(),
16178
- /** Concurrent slots. */
16179
- parallel: number().int().default(1),
16180
- /** Else lazy: first generate boots it. */
16181
- autoStart: boolean().default(false),
16182
- /** 0 = never; frees RAM after quiet periods. */
16183
- idleStopMinutes: number().int().default(30)
16689
+ /** `{{var}}` templating over camera/class/label/zones/confidence/time. */
16690
+ template: object({
16691
+ title: string().max(500).optional(),
16692
+ body: string().max(2e3).optional()
16693
+ }).optional(),
16694
+ /** Canonical notification priority ordinal (1..5); per-target overridable. */
16695
+ priority: number().int().min(1).max(5).default(3),
16696
+ /**
16697
+ * Ownership/visibility key. Absent = admin/global rule (unchanged legacy
16698
+ * behaviour, visible to all, read-only in the viewer). Present = personal
16699
+ * rule owned by this userId. Server-stamped; never trusted from a client.
16700
+ */
16701
+ ownerUserId: string().optional()
16184
16702
  });
16185
- var LlmRuntimeStatusSchema = object({
16186
- /** Status is ALWAYS node-qualified. */
16187
- nodeId: string(),
16188
- state: _enum([
16189
- "stopped",
16190
- "downloading",
16191
- "starting",
16192
- "ready",
16193
- "crashed",
16194
- "failed"
16703
+ /**
16704
+ * Partial patch for `updateRule` — any subset of the input fields, plus the
16705
+ * persisted-only {@link NcRuleSchema} `disabledTargetIds` set. The latter is
16706
+ * NOT a client-authored input field (it lives on the persisted rule, not the
16707
+ * input), so it is added here explicitly to let the store's per-target opt-out
16708
+ * toggle round-trip through the shared `update` path. Viewer opt-out mutations
16709
+ * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
16710
+ * `updateRule` patch.
16711
+ */
16712
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
16713
+ /** A persisted rule. */
16714
+ var NcRuleSchema = NcRuleInputSchema.extend({
16715
+ id: string(),
16716
+ /** userId of the admin who created the rule (server-stamped caller). */
16717
+ createdBy: string(),
16718
+ createdAt: number(),
16719
+ updatedAt: number(),
16720
+ /**
16721
+ * Per-target opt-out set. A targetId here is suppressed for THIS rule at
16722
+ * send time. Only a target's OWNER may add/remove its id (server-checked
16723
+ * in `nc.setRuleTargetEnabled`). Defaults to empty.
16724
+ */
16725
+ disabledTargetIds: array(string()).default([])
16726
+ });
16727
+ var NcTestResultSchema = object({
16728
+ recordId: string(),
16729
+ recordKind: _enum([
16730
+ "object-event",
16731
+ "track",
16732
+ "device-event",
16733
+ "package-event"
16195
16734
  ]),
16196
- pid: number().optional(),
16197
- port: number().optional(),
16198
- modelPath: string().optional(),
16199
- modelId: string().optional(),
16200
- downloadProgress: number().min(0).max(1).optional(),
16201
- lastError: string().optional(),
16202
- crashesInWindow: number(),
16203
- /** Child RSS (sampled best-effort). */
16204
- memoryBytes: number().optional(),
16205
- vramBytes: number().optional()
16206
- });
16207
- var LlmNodeModelSchema = object({
16208
- file: string(),
16209
- sizeBytes: number(),
16210
- catalogId: string().optional(),
16211
- installedAt: number().optional()
16735
+ deviceId: number(),
16736
+ timestamp: number(),
16737
+ wouldFire: boolean(),
16738
+ /** Condition id that failed (first failing group), when `wouldFire` is false. */
16739
+ failedCondition: string().optional(),
16740
+ className: string().optional(),
16741
+ label: string().optional()
16212
16742
  });
16213
- var LlmRuntimeDiskUsageSchema = object({
16214
- nodeId: string(),
16215
- modelsBytes: number(),
16216
- freeBytes: number().optional()
16743
+ var NcConditionDescriptorSchema = object({
16744
+ /** Field id inside `NcConditions` (or `'schedule'` for the rule-level group). */
16745
+ id: string(),
16746
+ group: _enum([
16747
+ "scope",
16748
+ "class",
16749
+ "zones",
16750
+ "quality",
16751
+ "label",
16752
+ "schedule",
16753
+ "device",
16754
+ "package",
16755
+ "occupancy"
16756
+ ]),
16757
+ label: string(),
16758
+ /** Editor widget the UI renders — never hardcode per-condition forms. */
16759
+ valueType: _enum([
16760
+ "deviceIdList",
16761
+ "stringList",
16762
+ "number01",
16763
+ "number",
16764
+ "sourceSelect",
16765
+ "zoneSelection",
16766
+ "zoneIdList",
16767
+ "schedule",
16768
+ "plateMatcher",
16769
+ "packagePhase",
16770
+ "polygonDraw",
16771
+ "occupancy"
16772
+ ]),
16773
+ operator: _enum([
16774
+ "in",
16775
+ "notIn",
16776
+ "anyOf",
16777
+ "allOf",
16778
+ "gte",
16779
+ "fuzzyIn",
16780
+ "withinSchedule"
16781
+ ]),
16782
+ /** Which delivery kinds the condition applies to. */
16783
+ appliesTo: array(NcDeliverySchema),
16784
+ phase: string(),
16785
+ description: string().optional()
16217
16786
  });
16218
- method(LlmGenerateBaseInputSchema.extend({
16219
- images: array(LlmImageSchema).optional(),
16220
- runtime: ManagedRuntimeConfigSchema,
16221
- /** The managed profile's timeout, threaded by the hub provider. */
16222
- timeoutMs: number().int().positive().optional()
16223
- }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
16224
- kind: "mutation",
16225
- auth: "admin"
16226
- }), method(object({}), _void(), {
16227
- kind: "mutation",
16228
- auth: "admin"
16229
- }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
16230
- kind: "mutation",
16231
- auth: "admin"
16232
- }), method(object({ file: string() }), _void(), {
16233
- kind: "mutation",
16234
- auth: "admin"
16235
- }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
16236
16787
  /**
16237
- * `llm` consumer-facing LLM surface (spec §1-§3). Collection-mode: array
16238
- * methods concat-fan across providers; single-row methods route to ONE
16239
- * provider by the `addonId` in the call input (the notification-output
16240
- * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
16241
- * (hub-placed); the cap stays open for future providers.
16788
+ * The delivery lifecycle status of a history row — a straight read of the
16789
+ * durable outbox row's own status (single source of truth):
16790
+ * - `pending` enqueued, in-flight or retrying with backoff
16791
+ * - `sent` — delivered (terminal)
16792
+ * - `dead` — dead-lettered after exhausting retries / a permanent
16793
+ * backend rejection / a deleted target (terminal; carries
16794
+ * the failure `error`)
16242
16795
  *
16243
- * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
16244
- * `apiKey` is a password field providers REDACT it on read and merge on
16245
- * write; a stored key NEVER round-trips to a client.
16796
+ * P1 has no `suppressed-quiet-hours` / `snoozed` states those ride the P2
16797
+ * user dimension (quiet hours / snooze) and are additive when they land.
16246
16798
  */
16247
- var LlmProfileKindSchema = _enum([
16248
- "openai-compatible",
16249
- "openai",
16250
- "anthropic",
16251
- "google",
16252
- "managed-local"
16799
+ var NcHistoryStatusSchema = _enum([
16800
+ "pending",
16801
+ "sent",
16802
+ "dead"
16253
16803
  ]);
16254
- var LlmProfileSchema = object({
16255
- id: string(),
16256
- name: string(),
16257
- kind: LlmProfileKindSchema,
16258
- /** Stamped by the provider — keeps the fanned catalog routable. */
16259
- addonId: string(),
16260
- enabled: boolean(),
16261
- /** Vendor model id, or the managed runtime's loaded model. */
16262
- model: string(),
16263
- /** Required for openai-compatible; override for cloud kinds. */
16264
- baseUrl: string().optional(),
16265
- /** ConfigUISchema type:'password' — never round-trips (spec §5). */
16266
- apiKey: string().optional(),
16267
- supportsVision: boolean(),
16268
- temperature: number().min(0).max(2).optional(),
16269
- maxTokens: number().int().positive().optional(),
16270
- timeoutMs: number().int().positive().default(6e4),
16271
- extraHeaders: record(string(), string()).optional(),
16272
- /** kind === 'managed-local' only (spec §4). */
16273
- runtime: ManagedRuntimeConfigSchema.optional()
16274
- });
16275
- /** ConfigUISchema tree passed through untyped on the wire (the
16276
- * notification-output `ConfigSchemaPassthrough` precedent at
16277
- * notification-output.cap.ts:151); the exported TS type re-tightens it. */
16278
- var ConfigSchemaPassthrough = unknown();
16279
- var LlmProfileKindDescriptorSchema = object({
16280
- kind: LlmProfileKindSchema,
16281
- label: string(),
16282
- icon: string(),
16283
- /** Stamped by each provider so the concat-fanned catalog stays routable. */
16284
- addonId: string(),
16285
- configSchema: ConfigSchemaPassthrough
16286
- });
16287
- var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
16288
- var LlmDefaultSchema = object({
16289
- selector: LlmDefaultSelectorSchema,
16290
- profileId: string()
16291
- });
16292
- /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
16293
- var LlmUsageRollupSchema = object({
16294
- day: string(),
16295
- consumer: string(),
16296
- profileId: string(),
16297
- calls: number(),
16298
- okCalls: number(),
16299
- errorCalls: number(),
16300
- inputTokens: number(),
16301
- outputTokens: number(),
16302
- avgLatencyMs: number()
16804
+ /** The evaluated record kind a history row descends from (one per trigger). */
16805
+ var NcHistoryRecordKindSchema = _enum([
16806
+ "object-event",
16807
+ "track-end",
16808
+ "device-event",
16809
+ "package-event"
16810
+ ]);
16811
+ /** Subject summary frozen on the row at fire time (survives rule/record edits). */
16812
+ var NcHistorySubjectSchema = object({
16813
+ className: string(),
16814
+ label: string().optional(),
16815
+ confidence: number().optional(),
16816
+ zones: array(string()),
16817
+ timestamp: number()
16303
16818
  });
16304
- /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
16305
- var ManagedModelCatalogEntrySchema = object({
16819
+ /**
16820
+ * One delivery-history row. This is a read-only VIEW over the durable
16821
+ * outbox row (single source of truth — the same row the drain loop drives;
16822
+ * NO second write path, so history can never drift from delivery state).
16823
+ * The §3.2 fields map directly: `ruleId`/`targetId`/`deviceId` are columns,
16824
+ * `eventRef` is `recordKind`+`recordId`, `timestamps` are `createdAt`
16825
+ * (fire) / `updatedAt` (last transition), `status` + `error` are the
16826
+ * lifecycle. `ruleName` + `subject` are the intent snapshot frozen at
16827
+ * enqueue. `userId?` (per-recipient history) is P2 — no user dimension in
16828
+ * P1 (admin scope only).
16829
+ */
16830
+ var NcHistoryEntrySchema = object({
16831
+ /** Outbox row id — the stable dedup id `ruleId:dedupRef:targetId`. */
16306
16832
  id: string(),
16307
- label: string(),
16308
- family: string(),
16309
- purpose: _enum(["text", "vision"]),
16310
- url: string(),
16311
- sha256: string(),
16312
- sizeBytes: number(),
16313
- quantization: string(),
16314
- /** Load-time guidance shown in the picker. */
16315
- minRamBytes: number(),
16316
- contextSizeDefault: number().int(),
16317
- /** Vision models: companion projector file. */
16318
- mmprojUrl: string().optional()
16319
- });
16320
- var LlmRuntimeNodeSchema = object({
16321
- nodeId: string(),
16322
- reachable: boolean(),
16323
- status: LlmRuntimeStatusSchema.optional(),
16324
- disk: LlmRuntimeDiskUsageSchema.optional(),
16325
- error: string().optional()
16326
- });
16327
- var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
16328
- var ProfileRefInputSchema = object({
16329
- addonId: string(),
16330
- profileId: string()
16833
+ ruleId: string(),
16834
+ /** Rule name frozen at fire time (outlives a later rename / delete). */
16835
+ ruleName: string(),
16836
+ /** The rule urgency/trigger that produced this delivery. */
16837
+ delivery: NcDeliverySchema,
16838
+ targetId: string(),
16839
+ deviceId: number(),
16840
+ recordKind: NcHistoryRecordKindSchema,
16841
+ /** Event / track ref of the evaluated record (§3.2 `eventRef`). */
16842
+ recordId: string(),
16843
+ /** Present for track-scoped deliveries (object-event / track-end). */
16844
+ trackId: string().optional(),
16845
+ status: NcHistoryStatusSchema,
16846
+ /** Delivery attempts made so far. */
16847
+ attempts: number().int(),
16848
+ /** Fire time (outbox enqueue). */
16849
+ createdAt: number(),
16850
+ /** Last transition time (terminal for sent / dead). */
16851
+ updatedAt: number(),
16852
+ /** Failure detail — present on a `dead` row. */
16853
+ error: string().optional(),
16854
+ subject: NcHistorySubjectSchema
16331
16855
  });
16332
- method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
16333
- kind: "mutation",
16334
- auth: "admin"
16335
- }), method(ProfileRefInputSchema, _void(), {
16336
- kind: "mutation",
16337
- auth: "admin"
16338
- }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
16339
- kind: "mutation",
16340
- auth: "admin"
16341
- }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
16342
- selector: LlmDefaultSelectorSchema,
16343
- profileId: string().nullable()
16344
- }), _void(), {
16345
- kind: "mutation",
16346
- auth: "admin"
16347
- }), method(object({
16856
+ /**
16857
+ * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
16858
+ * AND; absent = unbounded on that axis. `since`/`until` bound the fire time
16859
+ * (`createdAt`, epoch ms, inclusive). `limit` is clamped to
16860
+ * {@link NC_HISTORY_LIMIT_MAX}. `userId` (per-recipient filtering) is P2.
16861
+ */
16862
+ var NcHistoryFilterSchema = object({
16863
+ ruleId: string().optional(),
16864
+ deviceId: number().optional(),
16865
+ status: NcHistoryStatusSchema.optional(),
16348
16866
  since: number().optional(),
16349
- until: number().optional(),
16350
- consumer: string().optional(),
16351
- profileId: string().optional()
16352
- }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
16353
- nodeId: string(),
16354
- model: ManagedModelRefSchema
16355
- }), _void(), {
16867
+ until: number().optional(),
16868
+ limit: number().int().min(1).max(500).default(100)
16869
+ });
16870
+ 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 }), {
16356
16871
  kind: "mutation",
16357
- auth: "admin"
16872
+ auth: "admin",
16873
+ caller: "required"
16358
16874
  }), method(object({
16359
- nodeId: string(),
16360
- file: string()
16361
- }), _void(), {
16875
+ ruleId: string(),
16876
+ patch: NcRulePatchSchema
16877
+ }), object({ rule: NcRuleSchema }), {
16878
+ kind: "mutation",
16879
+ auth: "admin",
16880
+ caller: "required"
16881
+ }), method(object({ ruleId: string() }), object({ success: literal(true) }), {
16362
16882
  kind: "mutation",
16363
16883
  auth: "admin"
16364
- }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
16884
+ }), method(object({
16885
+ ruleId: string(),
16886
+ enabled: boolean()
16887
+ }), object({ success: literal(true) }), {
16365
16888
  kind: "mutation",
16366
16889
  auth: "admin"
16367
- }), method(ProfileRefInputSchema, _void(), {
16890
+ }), method(object({
16891
+ rule: NcRuleInputSchema,
16892
+ lookbackMinutes: number().int().min(1).max(1440).default(60)
16893
+ }), object({ results: array(NcTestResultSchema) }), {
16368
16894
  kind: "mutation",
16369
16895
  auth: "admin"
16370
- });
16896
+ }), method(object({}), object({ catalog: array(NcConditionDescriptorSchema) })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" });
16371
16897
  /**
16372
16898
  * Zod schemas for persisted record types.
16373
16899
  *
@@ -17053,7 +17579,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17053
17579
  }), method(object({
17054
17580
  eventId: string(),
17055
17581
  kind: MediaFileKindEnum.optional()
17056
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17582
+ }), array(MediaFileSchema).readonly()), method(object({
17583
+ trackId: string(),
17584
+ kinds: array(MediaFileKindEnum).optional()
17585
+ }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
17057
17586
  deviceId: number(),
17058
17587
  timestamp: number(),
17059
17588
  frameWidth: number(),
@@ -17074,76 +17603,6 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
17074
17603
  eventId: string(),
17075
17604
  timestamp: number()
17076
17605
  });
17077
- /**
17078
- * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
17079
- * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
17080
- * caps into per-camera event-kind descriptors.
17081
- *
17082
- * The descriptor DATA (color / iconId / labelKey / parentKind / category)
17083
- * is NOT duplicated here — every entry is derived from the single
17084
- * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
17085
- * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
17086
- * control cap means adding one line here (and a taxonomy entry); the anti-
17087
- * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
17088
- * eventful cap is missing.
17089
- */
17090
- /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
17091
- var LEGACY_ICON = {
17092
- motion: "motion",
17093
- audio: "audio",
17094
- person: "person",
17095
- vehicle: "vehicle",
17096
- animal: "animal",
17097
- package: "package",
17098
- door: "door",
17099
- pir: "pir",
17100
- smoke: "smoke",
17101
- water: "water",
17102
- button: "button",
17103
- generic: "generic",
17104
- gas: "smoke",
17105
- vibration: "generic",
17106
- tamper: "generic",
17107
- presence: "person",
17108
- lock: "generic",
17109
- siren: "generic",
17110
- switch: "generic",
17111
- doorbell: "button"
17112
- };
17113
- function legacyIcon(iconId) {
17114
- return LEGACY_ICON[iconId] ?? "generic";
17115
- }
17116
- /**
17117
- * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
17118
- * The anti-drift guard cross-checks this against the eventful caps declared
17119
- * in `packages/types/src/capabilities/*.cap.ts`.
17120
- */
17121
- var CAP_TO_KIND = {
17122
- contact: "contact",
17123
- motion: "motion-sensor",
17124
- smoke: "smoke",
17125
- flood: "flood",
17126
- gas: "gas",
17127
- "carbon-monoxide": "carbon-monoxide",
17128
- vibration: "vibration",
17129
- tamper: "tamper",
17130
- presence: "presence",
17131
- "enum-sensor": "enum-sensor",
17132
- "event-emitter": "device-event",
17133
- "lock-control": "lock",
17134
- switch: "switch",
17135
- button: "button",
17136
- doorbell: "doorbell"
17137
- };
17138
- function buildDescriptor(capName, kind) {
17139
- const t = EVENT_TAXONOMY[kind];
17140
- if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
17141
- return {
17142
- ...t,
17143
- icon: legacyIcon(t.iconId)
17144
- };
17145
- }
17146
- Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
17147
17606
  var CameraPipelineConfigSchema = object({
17148
17607
  engine: PipelineEngineChoiceSchema.optional(),
17149
17608
  steps: array(PipelineStepInputSchema).readonly(),
@@ -17629,6 +18088,76 @@ method(object({
17629
18088
  auth: "admin"
17630
18089
  });
17631
18090
  /**
18091
+ * Cap → event-kind mapping for the SENSOR / CONTROL cap families — the table
18092
+ * `pipeline-analytics.listEventKinds` uses to turn a linked device's bound
18093
+ * caps into per-camera event-kind descriptors.
18094
+ *
18095
+ * The descriptor DATA (color / iconId / labelKey / parentKind / category)
18096
+ * is NOT duplicated here — every entry is derived from the single
18097
+ * `EVENT_TAXONOMY` dictionary (`catalogs/event-taxonomy.ts`). This file owns
18098
+ * ONLY the cap-name → taxonomy-kind mapping. Adding a new eventful sensor /
18099
+ * control cap means adding one line here (and a taxonomy entry); the anti-
18100
+ * drift guard `scripts/check-event-kind-coverage.ts` fails the build if an
18101
+ * eventful cap is missing.
18102
+ */
18103
+ /** Map a taxonomy `iconId` onto the legacy closed `EventKindIcon` enum. */
18104
+ var LEGACY_ICON = {
18105
+ motion: "motion",
18106
+ audio: "audio",
18107
+ person: "person",
18108
+ vehicle: "vehicle",
18109
+ animal: "animal",
18110
+ package: "package",
18111
+ door: "door",
18112
+ pir: "pir",
18113
+ smoke: "smoke",
18114
+ water: "water",
18115
+ button: "button",
18116
+ generic: "generic",
18117
+ gas: "smoke",
18118
+ vibration: "generic",
18119
+ tamper: "generic",
18120
+ presence: "person",
18121
+ lock: "generic",
18122
+ siren: "generic",
18123
+ switch: "generic",
18124
+ doorbell: "button"
18125
+ };
18126
+ function legacyIcon(iconId) {
18127
+ return LEGACY_ICON[iconId] ?? "generic";
18128
+ }
18129
+ /**
18130
+ * Cap name → taxonomy kind id. Covers EVERY eventful sensor / control cap.
18131
+ * The anti-drift guard cross-checks this against the eventful caps declared
18132
+ * in `packages/types/src/capabilities/*.cap.ts`.
18133
+ */
18134
+ var CAP_TO_KIND = {
18135
+ contact: "contact",
18136
+ motion: "motion-sensor",
18137
+ smoke: "smoke",
18138
+ flood: "flood",
18139
+ gas: "gas",
18140
+ "carbon-monoxide": "carbon-monoxide",
18141
+ vibration: "vibration",
18142
+ tamper: "tamper",
18143
+ presence: "presence",
18144
+ "enum-sensor": "enum-sensor",
18145
+ "event-emitter": "device-event",
18146
+ "lock-control": "lock",
18147
+ switch: "switch",
18148
+ button: "button",
18149
+ doorbell: "doorbell"
18150
+ };
18151
+ function buildDescriptor(capName, kind) {
18152
+ const t = EVENT_TAXONOMY[kind];
18153
+ if (t === void 0) throw new Error(`EVENT_KIND_BY_CAP: cap '${capName}' maps to unknown taxonomy kind '${kind}'`);
18154
+ return {
18155
+ ...t,
18156
+ icon: legacyIcon(t.iconId)
18157
+ };
18158
+ }
18159
+ Object.freeze(Object.fromEntries(Object.entries(CAP_TO_KIND).map(([capName, kind]) => [capName, buildDescriptor(capName, kind)])));
18160
+ /**
17632
18161
  * server-management — per-NODE singleton capability for a node's ROOT
17633
18162
  * package lifecycle (runtime-updatable node packages).
17634
18163
  *
@@ -19083,7 +19612,28 @@ var FaceInfoSchema = object({
19083
19612
  * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`). Absent when the
19084
19613
  * track produced no key frame (e.g. native/onboard source) — the UI falls
19085
19614
  * back to the inline `base64` face crop. */
19086
- keyFrameMediaKey: string().optional()
19615
+ keyFrameMediaKey: string().optional(),
19616
+ /** Winning identity-match cosine (0..1) for this face's track, when an
19617
+ * identity was auto-confirmed. Lets the UI surface WHY a face was assigned
19618
+ * (confidence badge / low-confidence audit). Absent on legacy rows and on
19619
+ * faces that were never auto-recognized. */
19620
+ bestMatchScore: number().optional(),
19621
+ /** Native-scale face short side (px) at recognition time, when the runner
19622
+ * measured it. Lets the UI flag low-resolution auto-assignments. Absent on
19623
+ * legacy rows / runners that reported no native measure. */
19624
+ nativeFaceShortSidePx: number().optional(),
19625
+ /** SUGGESTED identity for this face — a plausible-but-not-confident match that
19626
+ * MISSED auto-assignment (cosine in the suggestion band, or above threshold
19627
+ * but blocked only by the recognition size floor). Mutually exclusive with
19628
+ * `recognizedIdentityId` (a suggestion is NEVER an assignment): the face stays
19629
+ * UNASSIGNED and everything else keeps treating it as unrecognized — the UI
19630
+ * merely offers a one-tap "is this <name>?" confirm. Absent on legacy rows and
19631
+ * on faces that were auto-assigned or below the suggestion band. (2026-07-24) */
19632
+ suggestedIdentityId: string().optional(),
19633
+ /** Peak identity-match cosine (0..1) for `suggestedIdentityId`, captured at the
19634
+ * same moment as `bestMatchScore` (track peak, at close). Lets the UI rank /
19635
+ * badge suggestion confidence. Present iff `suggestedIdentityId` is. (2026-07-24) */
19636
+ suggestedMatchScore: number().optional()
19087
19637
  });
19088
19638
  var FaceFilterEnum = _enum([
19089
19639
  "unassigned",
@@ -21126,36 +21676,6 @@ Object.freeze({
21126
21676
  addonId: null,
21127
21677
  access: "view"
21128
21678
  },
21129
- "advancedNotifier.deleteRule": {
21130
- capName: "advanced-notifier",
21131
- capScope: "system",
21132
- addonId: null,
21133
- access: "delete"
21134
- },
21135
- "advancedNotifier.getHistory": {
21136
- capName: "advanced-notifier",
21137
- capScope: "system",
21138
- addonId: null,
21139
- access: "view"
21140
- },
21141
- "advancedNotifier.getRules": {
21142
- capName: "advanced-notifier",
21143
- capScope: "system",
21144
- addonId: null,
21145
- access: "view"
21146
- },
21147
- "advancedNotifier.testRule": {
21148
- capName: "advanced-notifier",
21149
- capScope: "system",
21150
- addonId: null,
21151
- access: "create"
21152
- },
21153
- "advancedNotifier.upsertRule": {
21154
- capName: "advanced-notifier",
21155
- capScope: "system",
21156
- addonId: null,
21157
- access: "create"
21158
- },
21159
21679
  "alarmPanel.arm": {
21160
21680
  capName: "alarm-panel",
21161
21681
  capScope: "device",
@@ -23460,6 +23980,60 @@ Object.freeze({
23460
23980
  addonId: null,
23461
23981
  access: "create"
23462
23982
  },
23983
+ "notificationRules.createRule": {
23984
+ capName: "notification-rules",
23985
+ capScope: "system",
23986
+ addonId: null,
23987
+ access: "create"
23988
+ },
23989
+ "notificationRules.deleteRule": {
23990
+ capName: "notification-rules",
23991
+ capScope: "system",
23992
+ addonId: null,
23993
+ access: "delete"
23994
+ },
23995
+ "notificationRules.getConditionCatalog": {
23996
+ capName: "notification-rules",
23997
+ capScope: "system",
23998
+ addonId: null,
23999
+ access: "view"
24000
+ },
24001
+ "notificationRules.getHistory": {
24002
+ capName: "notification-rules",
24003
+ capScope: "system",
24004
+ addonId: null,
24005
+ access: "view"
24006
+ },
24007
+ "notificationRules.getRule": {
24008
+ capName: "notification-rules",
24009
+ capScope: "system",
24010
+ addonId: null,
24011
+ access: "view"
24012
+ },
24013
+ "notificationRules.listRules": {
24014
+ capName: "notification-rules",
24015
+ capScope: "system",
24016
+ addonId: null,
24017
+ access: "view"
24018
+ },
24019
+ "notificationRules.setRuleEnabled": {
24020
+ capName: "notification-rules",
24021
+ capScope: "system",
24022
+ addonId: null,
24023
+ access: "create"
24024
+ },
24025
+ "notificationRules.testRule": {
24026
+ capName: "notification-rules",
24027
+ capScope: "system",
24028
+ addonId: null,
24029
+ access: "create"
24030
+ },
24031
+ "notificationRules.updateRule": {
24032
+ capName: "notification-rules",
24033
+ capScope: "system",
24034
+ addonId: null,
24035
+ access: "create"
24036
+ },
23463
24037
  "notifier.cancel": {
23464
24038
  capName: "notifier",
23465
24039
  capScope: "device",
@@ -25810,6 +26384,152 @@ function createIconRouteProvider() {
25810
26384
  return buildAddonRouteProvider(NOTIFIERS_ROUTE_ID, Object.keys(NOTIFIER_ICONS).map(iconRoute));
25811
26385
  }
25812
26386
  //#endregion
26387
+ //#region src/nc-target-actions.ts
26388
+ /**
26389
+ * nc-target-actions — the `notifiers` target-bridge action catalog.
26390
+ *
26391
+ * The Notification Center viewer NEVER adds a cap method: every target
26392
+ * read/write rides the generic `addons.custom` bridge (`{ addonId, action,
26393
+ * input }`) with a per-action `nc.*` name, and THIS module enforces the
26394
+ * per-action auth + ownership server-side (spec C1/C2). The addon id is
26395
+ * `'notifiers'`.
26396
+ *
26397
+ * Ownership model (spec §2 / §5 — server-derived, never client-trusted):
26398
+ * - A PERSONAL target carries its owner INSIDE the open `config.ownerUserId`
26399
+ * blob (train-free, additive — no `notification-output` schema change). This
26400
+ * matches the A6 rule-bridge's target-ownership check verbatim
26401
+ * (`target.config['ownerUserId']`).
26402
+ * - `ownerUserId` absent = a legacy admin/global target (owned by no viewer
26403
+ * user); the viewer never sees or mutates those through this bridge.
26404
+ * - `nc.listMyTargets` returns ONLY the caller's own targets.
26405
+ * - `nc.upsertMyTarget` STAMPS `config.ownerUserId` from the caller (stripping
26406
+ * any client-supplied value) and, on edit, requires the existing row to be
26407
+ * caller-owned. A client-suggested id that collides with a FOREIGN target is
26408
+ * minted fresh so a viewer can never edit or clobber another user's row.
26409
+ * - `nc.deleteMyTarget` / `nc.setMyTargetEnabled` / `nc.testMyTarget` operate
26410
+ * ONLY on caller-owned targets.
26411
+ *
26412
+ * FAIL-CLOSED: an absent forwarded caller (UDS version-skew can still deliver
26413
+ * `undefined`) is rejected before any ownership decision — never treated as
26414
+ * admin/global.
26415
+ *
26416
+ * Secret redaction (on read) + secret merge (on write) is the underlying
26417
+ * `notification-output` provider's concern (`provider.ts` / `secrets.ts`): this
26418
+ * bridge wraps that provider, so `nc.listMyTargets` returns already-redacted
26419
+ * rows and `nc.upsertMyTarget` inherits the stored-secret merge (the viewer's
26420
+ * blank-seed round-trip). `config.ownerUserId` is NOT a password field, so it
26421
+ * survives redaction and remains the ownership key on read.
26422
+ */
26423
+ /**
26424
+ * The action catalog — the tRPC contract Group B (the viewer client) consumes
26425
+ * against `addonId: 'notifiers'`. Every entry that depends on the caller
26426
+ * identity is declared `caller: 'required'` so the dispatcher forwards the
26427
+ * server-derived `{ userId, isAdmin }` as the handler's second argument.
26428
+ */
26429
+ var ncTargetActions = defineCustomActions({
26430
+ "nc.listMyTargets": customAction(object({}), object({ targets: array(TargetSchema) }), { caller: "required" }),
26431
+ "nc.listTargetKinds": customAction(object({}), object({ kinds: array(TargetKindSchema) })),
26432
+ "nc.upsertMyTarget": customAction(object({ target: TargetSchema }), object({ target: TargetSchema }), {
26433
+ kind: "mutation",
26434
+ caller: "required"
26435
+ }),
26436
+ "nc.deleteMyTarget": customAction(object({ targetId: string() }), object({ success: literal(true) }), {
26437
+ kind: "mutation",
26438
+ caller: "required"
26439
+ }),
26440
+ "nc.setMyTargetEnabled": customAction(object({
26441
+ targetId: string(),
26442
+ enabled: boolean()
26443
+ }), object({ success: literal(true) }), {
26444
+ kind: "mutation",
26445
+ caller: "required"
26446
+ }),
26447
+ "nc.testMyTarget": customAction(object({ targetId: string() }), object({
26448
+ success: boolean(),
26449
+ error: string().optional()
26450
+ }), {
26451
+ kind: "mutation",
26452
+ caller: "required"
26453
+ })
26454
+ });
26455
+ /** The open-blob ownership key — matches the A6 rule-bridge check verbatim. */
26456
+ var OWNER_KEY = "ownerUserId";
26457
+ var ownerOf = (target) => target.config[OWNER_KEY];
26458
+ /** Fail-closed caller resolution — an absent forwarded caller is NEVER admin. */
26459
+ function requireCaller(caller) {
26460
+ if (!caller || typeof caller.userId !== "string" || caller.userId.length === 0) throw new Error("forbidden: authenticated caller required");
26461
+ return caller;
26462
+ }
26463
+ /** Mint a fresh, collision-resistant target id (kind-prefixed for readability). */
26464
+ function mintTargetId(kind) {
26465
+ const rand = Math.random().toString(36).slice(2, 10);
26466
+ return `${kind}-${Date.now()}-${rand}`;
26467
+ }
26468
+ function makeNcTargetHandlers(deps) {
26469
+ /** A caller-owned target — must exist AND carry the caller's ownerUserId. */
26470
+ const assertOwns = async (targetId, userId) => {
26471
+ const target = (await deps.provider.listTargets({})).find((t) => t.id === targetId);
26472
+ if (!target || ownerOf(target) !== userId) throw new Error(`forbidden: target not owned: ${targetId}`);
26473
+ return target;
26474
+ };
26475
+ return {
26476
+ "nc.listMyTargets": async (_input, caller) => {
26477
+ const c = requireCaller(caller);
26478
+ return { targets: (await deps.provider.listTargets({})).filter((t) => ownerOf(t) === c.userId) };
26479
+ },
26480
+ "nc.listTargetKinds": async () => ({ kinds: await deps.provider.listTargetKinds({}) }),
26481
+ "nc.upsertMyTarget": async (input, caller) => {
26482
+ const c = requireCaller(caller);
26483
+ const all = await deps.provider.listTargets({});
26484
+ const suggestedId = input.target.id;
26485
+ const existing = suggestedId.length > 0 ? all.find((t) => t.id === suggestedId) : void 0;
26486
+ const id = existing !== void 0 ? ownerOf(existing) === c.userId ? suggestedId : mintTargetId(input.target.kind) : suggestedId.length > 0 ? suggestedId : mintTargetId(input.target.kind);
26487
+ const stamped = {
26488
+ ...input.target,
26489
+ id,
26490
+ config: {
26491
+ ...input.target.config,
26492
+ [OWNER_KEY]: c.userId
26493
+ }
26494
+ };
26495
+ const saved = await deps.provider.upsertTarget({ target: stamped });
26496
+ deps.logger.info("nc target upserted", { meta: {
26497
+ targetId: saved.id,
26498
+ owner: c.userId
26499
+ } });
26500
+ return { target: saved };
26501
+ },
26502
+ "nc.deleteMyTarget": async (input, caller) => {
26503
+ const c = requireCaller(caller);
26504
+ await assertOwns(input.targetId, c.userId);
26505
+ await deps.provider.deleteTarget({ targetId: input.targetId });
26506
+ deps.logger.info("nc target deleted", { meta: {
26507
+ targetId: input.targetId,
26508
+ owner: c.userId
26509
+ } });
26510
+ return { success: true };
26511
+ },
26512
+ "nc.setMyTargetEnabled": async (input, caller) => {
26513
+ const c = requireCaller(caller);
26514
+ await assertOwns(input.targetId, c.userId);
26515
+ await deps.provider.setTargetEnabled({
26516
+ targetId: input.targetId,
26517
+ enabled: input.enabled
26518
+ });
26519
+ return { success: true };
26520
+ },
26521
+ "nc.testMyTarget": async (input, caller) => {
26522
+ const c = requireCaller(caller);
26523
+ await assertOwns(input.targetId, c.userId);
26524
+ const res = await deps.provider.testTarget({ targetId: input.targetId });
26525
+ return {
26526
+ success: res.success,
26527
+ ...res.error !== void 0 ? { error: res.error } : {}
26528
+ };
26529
+ }
26530
+ };
26531
+ }
26532
+ //#endregion
25813
26533
  //#region src/adapters/discord.ts
25814
26534
  /** Discord message `content` hard limit. */
25815
26535
  var CONTENT_MAX_LEN = 2e3;
@@ -28534,18 +29254,26 @@ var NotifiersAddon = class extends BaseAddon {
28534
29254
  iconUrlFor
28535
29255
  });
28536
29256
  const iconRouteProvider = createIconRouteProvider();
29257
+ const ncHandlers = makeNcTargetHandlers({
29258
+ provider,
29259
+ logger: this.ctx.logger.child("nc-target-actions")
29260
+ });
28537
29261
  this.ctx.logger.info("NotifiersAddon initialized", { meta: { adapterCount: ADAPTERS.length } });
28538
- return [{
28539
- capability: notificationOutputCapability,
28540
- provider
28541
- }, {
28542
- capability: addonRoutesCapability,
28543
- provider: iconRouteProvider
28544
- }];
29262
+ return {
29263
+ providers: [{
29264
+ capability: notificationOutputCapability,
29265
+ provider
29266
+ }, {
29267
+ capability: addonRoutesCapability,
29268
+ provider: iconRouteProvider
29269
+ }],
29270
+ customActions: ncTargetActions,
29271
+ actionHandlers: ncHandlers
29272
+ };
28545
29273
  }
28546
29274
  async onShutdown() {
28547
29275
  this.ctx.logger.info("NotifiersAddon shut down");
28548
29276
  }
28549
29277
  };
28550
29278
  //#endregion
28551
- export { NotifiersAddon, NotifiersAddon as default, NOTIFIERS_ADDON_ID as a, mergeSecrets as c, DEFAULT_MAX_ATTACHMENT_BYTES as d, DEFAULT_OUTPUT_TIMEOUT_MS as f, sendHttpPlan as h, createMemorySettingsStorePort as i, passwordFieldKeys as l, fetchWithTimeout as m, TargetStore as n, createNotificationOutputProvider as o, fetchAttachmentBytes as p, createApiSettingsStorePort as r, REDACTED_MARKER as s, TARGETS_COLLECTION as t, redactForRead as u };
29279
+ export { NotifiersAddon, NotifiersAddon as default, ncTargetActions as _, NOTIFIERS_ADDON_ID as a, mergeSecrets as c, DEFAULT_MAX_ATTACHMENT_BYTES as d, DEFAULT_OUTPUT_TIMEOUT_MS as f, makeNcTargetHandlers as g, sendHttpPlan as h, createMemorySettingsStorePort as i, passwordFieldKeys as l, fetchWithTimeout as m, TargetStore as n, createNotificationOutputProvider as o, fetchAttachmentBytes as p, createApiSettingsStorePort as r, REDACTED_MARKER as s, TARGETS_COLLECTION as t, redactForRead as u };