@camstack/addon-decoder-nodeav 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +1118 -413
  2. package/dist/index.mjs +1119 -402
  3. package/package.json +1 -2
package/dist/index.js CHANGED
@@ -2,9 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- let _camstack_shm_ring = require("@camstack/shm-ring");
6
5
  let node_crypto = require("node:crypto");
7
- let node_fs = require("node:fs");
8
6
  //#region ../../node_modules/zod/v4/core/core.js
9
7
  var _a$1;
10
8
  function $constructor(name, initializer, params) {
@@ -4293,6 +4291,14 @@ function object(shape, params) {
4293
4291
  ...normalizeParams(params)
4294
4292
  });
4295
4293
  }
4294
+ function looseObject(shape, params) {
4295
+ return new ZodObject({
4296
+ type: "object",
4297
+ shape,
4298
+ catchall: unknown(),
4299
+ ...normalizeParams(params)
4300
+ });
4301
+ }
4296
4302
  var ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
4297
4303
  $ZodUnion.init(inst, def);
4298
4304
  ZodType.init(inst, def);
@@ -4634,7 +4640,7 @@ function _instanceof(cls, params = {}) {
4634
4640
  return inst;
4635
4641
  }
4636
4642
  //#endregion
4637
- //#region ../types/dist/sleep-BC9Yqte7.mjs
4643
+ //#region ../types/dist/sleep-_sv7WKkq.mjs
4638
4644
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4639
4645
  EventCategory["SystemBoot"] = "system.boot";
4640
4646
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5044,10 +5050,51 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
5044
5050
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
5045
5051
  EventCategory["EnrichmentSceneStateChanged"] = "enrichment.scene.state-changed";
5046
5052
  EventCategory["EnrichmentActivitySummary"] = "enrichment.activity.summary";
5053
+ /**
5054
+ * Unified track-lifecycle event: ONE category carrying `phase:
5055
+ * 'start' | 'update' | 'end'` with a rich, typed
5056
+ * `PipelineAnalyticsTrackLifecyclePayload`. Supersedes the thin
5057
+ * `PipelineAnalyticsTrackStarted` / `PipelineAnalyticsTrackEnded`
5058
+ * pair — a consumer subscribes once and branches on `phase`.
5059
+ */
5060
+ EventCategory["PipelineAnalyticsTrackLifecycle"] = "pipeline-analytics.track-lifecycle";
5061
+ /**
5062
+ * @deprecated Superseded by {@link PipelineAnalyticsTrackLifecycle}
5063
+ * (`phase:'start'`). Kept as a soft alias — no known subscribers.
5064
+ */
5047
5065
  EventCategory["PipelineAnalyticsTrackStarted"] = "pipeline-analytics.track-started";
5066
+ /**
5067
+ * @deprecated Superseded by {@link PipelineAnalyticsTrackLifecycle}
5068
+ * (`phase:'end'`). Kept as a soft alias — no known subscribers.
5069
+ */
5048
5070
  EventCategory["PipelineAnalyticsTrackEnded"] = "pipeline-analytics.track-ended";
5049
5071
  EventCategory["PipelineAnalyticsDetectionEvent"] = "pipeline-analytics.detection-event";
5050
5072
  EventCategory["PipelineAnalyticsFrameTracked"] = "pipeline-analytics.frame-tracked";
5073
+ /**
5074
+ * Fired by `addon-post-analysis` when a parked (stationary) object appears
5075
+ * (a track was promoted to a stationary-registry entry) or departs (the
5076
+ * object moved / was removed). Telemetry (D8): lossy, drives a UI refresh of
5077
+ * the dedicated "Stationary" section — never the live event feed. Payload:
5078
+ * `{ deviceId, entryId, className, phase:'appeared'|'departed', timestamp }`.
5079
+ */
5080
+ EventCategory["PipelineAnalyticsStationaryChanged"] = "pipeline-analytics.stationary-changed";
5081
+ /**
5082
+ * Fired by `addon-post-analysis` whenever a gallery face row changes:
5083
+ * `kind:'buffered'` a new detected face was persisted, `'assigned'` /
5084
+ * `'unassigned'` its identity link changed, `'deleted'` the row was
5085
+ * removed. Telemetry semantics (D8): a lost event only delays a refresh,
5086
+ * never a correctness issue. Payload `PipelineAnalyticsFaceGalleryChangedPayload`.
5087
+ */
5088
+ EventCategory["PipelineAnalyticsFaceGalleryChanged"] = "pipeline-analytics.face-gallery-changed";
5089
+ /**
5090
+ * Fired by `addon-post-analysis` whenever a gallery plate row changes:
5091
+ * `kind:'buffered'` a new read was persisted (`PlateRecognizer.onTrackEnd`),
5092
+ * `'assigned'` / `'unassigned'` its vehicle link changed
5093
+ * (`PlateGalleryProvider`), `'deleted'` the row was removed. Telemetry
5094
+ * semantics (D8): a lost event only delays a refresh, never a correctness
5095
+ * issue. Payload `PipelineAnalyticsPlateGalleryChangedPayload`.
5096
+ */
5097
+ EventCategory["PipelineAnalyticsPlateGalleryChanged"] = "pipeline-analytics.plate-gallery-changed";
5051
5098
  EventCategory["FrigateLiveEvent"] = "frigate.live-event";
5052
5099
  EventCategory["CameraStreamsProfileSlotsChanged"] = "camera-streams.onProfileSlotsChanged";
5053
5100
  /**
@@ -6888,7 +6935,8 @@ var MODEL_FORMATS = [
6888
6935
  "coreml",
6889
6936
  "openvino",
6890
6937
  "tflite",
6891
- "pt"
6938
+ "pt",
6939
+ "gguf"
6892
6940
  ];
6893
6941
  /**
6894
6942
  * Multi-file format payload.
@@ -6932,7 +6980,8 @@ var ModelFormatsSchema = object({
6932
6980
  coreml: ModelFormatEntrySchema.optional(),
6933
6981
  openvino: ModelFormatEntrySchema.optional(),
6934
6982
  tflite: ModelFormatEntrySchema.optional(),
6935
- pt: ModelFormatEntrySchema.optional()
6983
+ pt: ModelFormatEntrySchema.optional(),
6984
+ gguf: ModelFormatEntrySchema.optional()
6936
6985
  });
6937
6986
  /**
6938
6987
  * Variant-selector grouping axes. Shared by the full `ModelCatalogEntry` and by
@@ -6973,6 +7022,15 @@ var ModelCatalogEntrySchema = object({
6973
7022
  width: number(),
6974
7023
  height: number()
6975
7024
  }),
7025
+ /**
7026
+ * Channel count of the model input tensor. Omit ⇒ 3 (RGB), the default for
7027
+ * every detector / classifier / embedder. Set to 1 for a grayscale CTC text
7028
+ * recognizer (EasyOCR VGG plate-OCR: input `[N,1,H,W]`) so the preprocess
7029
+ * feeds a single-channel, EasyOCR-normalized tensor instead of the default
7030
+ * 3-channel RGB one. Threaded through `PoolModelConfig.inputChannels` to the
7031
+ * Python inference pool.
7032
+ */
7033
+ inputChannels: number().int().positive().optional(),
6976
7034
  labels: array(LabelDefinitionSchema).readonly(),
6977
7035
  inputLayout: _enum(["nchw", "nhwc"]).optional(),
6978
7036
  inputNormalization: _enum([
@@ -6982,6 +7040,16 @@ var ModelCatalogEntrySchema = object({
6982
7040
  ]).optional(),
6983
7041
  preprocessMode: _enum(["letterbox", "resize"]).optional(),
6984
7042
  /**
7043
+ * Per-MODEL postprocessor override. Absent ⇒ the step's own
7044
+ * `StepDefinition.postprocessor` applies (the normal case — every model in a
7045
+ * step shares its decode). Set it when a step hosts models with DIFFERENT raw
7046
+ * output layouts under one slot: e.g. object-detection is `'yolo'` by default,
7047
+ * but a Coral SSD MobileNet build emits the `TFLite_Detection_PostProcess`
7048
+ * 4-tensor layout and needs `'ssd'`. Threaded into `PoolModelConfig.postprocessor`
7049
+ * by the engine factory (`modelEntry.postprocessor ?? def.postprocessor`).
7050
+ */
7051
+ postprocessor: custom().optional(),
7052
+ /**
6985
7053
  * When true, the executor produces a landmark-aligned crop (similarity warp
6986
7054
  * onto the canonical template) before this step runs, instead of a plain
6987
7055
  * axis-aligned bbox crop. Required for face-recognition embedders (ArcFace):
@@ -10427,7 +10495,8 @@ var ModelFormatSchema$1 = _enum([
10427
10495
  "coreml",
10428
10496
  "openvino",
10429
10497
  "tflite",
10430
- "pt"
10498
+ "pt",
10499
+ "gguf"
10431
10500
  ]);
10432
10501
  var PipelineSlotSchema = _enum([
10433
10502
  "detector",
@@ -10521,7 +10590,8 @@ var EngineProvisioningSchema = object({
10521
10590
  runtimeId: _enum([
10522
10591
  "onnx",
10523
10592
  "openvino",
10524
- "coreml"
10593
+ "coreml",
10594
+ "edgetpu"
10525
10595
  ]).nullable(),
10526
10596
  device: string().nullable(),
10527
10597
  state: _enum([
@@ -10682,7 +10752,15 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
10682
10752
  image: _instanceof(Uint8Array).optional(),
10683
10753
  referenceImage: string().optional(),
10684
10754
  deviceId: number().optional(),
10685
- sessionId: string().optional()
10755
+ sessionId: string().optional(),
10756
+ /**
10757
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
10758
+ * reference-image, and detail-subtree calls. 'frame' is the live
10759
+ * per-frame dispatch: ONLY root-plane steps run; crop children
10760
+ * (inputClasses ≠ null) are skipped and served per-track via
10761
+ * pipelineRunner.runDetailSubtree (two-plane design).
10762
+ */
10763
+ plane: _enum(["full", "frame"]).optional()
10686
10764
  }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
10687
10765
  engine: PipelineEngineChoiceSchema.optional(),
10688
10766
  steps: array(PipelineStepInputSchema).min(1),
@@ -10825,6 +10903,28 @@ var NativeCropResultSchema = object({
10825
10903
  width: number().int().positive(),
10826
10904
  height: number().int().positive()
10827
10905
  });
10906
+ /** Parent detection context passed to `runDetailSubtree` — the crop's
10907
+ * originating detection, in FRAME-space coordinates. Reuses
10908
+ * `NativeCropBboxSchema`'s `{x,y,w,h}` shape (same numeric fields; here
10909
+ * the coordinates are frame-space rather than getNativeCrop's
10910
+ * normalized [0,1] convention). */
10911
+ var DetailParentSchema = object({
10912
+ bbox: NativeCropBboxSchema,
10913
+ className: string()
10914
+ });
10915
+ /** One child-step result from `runDetailSubtree` — an embedding, label,
10916
+ * or refined detection produced by running the crop-subtree on a
10917
+ * single tracked detection. */
10918
+ var DetailResultSchema = object({
10919
+ stepId: string(),
10920
+ className: string(),
10921
+ score: number(),
10922
+ /** FRAME-space bbox (already mapped back from crop space). */
10923
+ bbox: NativeCropBboxSchema.optional(),
10924
+ embedding: string().optional(),
10925
+ label: string().optional(),
10926
+ alignedCropJpeg: string().optional()
10927
+ });
10828
10928
  /**
10829
10929
  * Per-camera tunable ranges + defaults. Single source of truth used
10830
10930
  * by both the Zod data schema (validation + default fallback) and
@@ -11085,7 +11185,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
11085
11185
  handle: FrameHandleSchema,
11086
11186
  bbox: NativeCropBboxSchema,
11087
11187
  maxWidth: number().int().positive().optional()
11088
- }), NativeCropResultSchema.nullable());
11188
+ }), NativeCropResultSchema.nullable()), method(object({
11189
+ deviceId: number(),
11190
+ frameHandle: FrameHandleSchema.optional(),
11191
+ cropJpeg: string().optional(),
11192
+ parent: DetailParentSchema,
11193
+ steps: array(string()).optional()
11194
+ }), object({ details: array(DetailResultSchema) }).nullable(), { kind: "mutation" });
11089
11195
  object({
11090
11196
  detected: boolean(),
11091
11197
  /** Ms epoch of the last detected-true observation. Null if never detected. */
@@ -11697,6 +11803,140 @@ DeviceType.Camera, method(object({ deviceId: number() }), PtzAutotrackStatusSche
11697
11803
  deviceId: number(),
11698
11804
  status: PtzAutotrackStatusSchema
11699
11805
  });
11806
+ /**
11807
+ * scene-monitor — device-scoped reference-region state cap. An operator marks
11808
+ * a rect ROI on a camera frame and names one or more states; the engine
11809
+ * (pipeline-analytics, designated post-processing node) reports which state is
11810
+ * active on an ongoing basis. Two operator-selectable check modes share every-
11811
+ * thing except the comparator: `similarity` (CLIP cosine at the same ROI coords
11812
+ * vs condition-tagged references) and `llm` (vision-LLM judgment over the crop).
11813
+ *
11814
+ * D14 device-config archetype (`deviceConfig.ui.kind:'widget'`) — the framework
11815
+ * derives the device-detail contribution; the provider carries NO hand-written
11816
+ * settings-contribution methods. `status.kind:'push'` — the engine pushes on
11817
+ * every hysteresis flip / availability change; consumers never poll.
11818
+ */
11819
+ /** Extensible condition tag. Seeded 'day' | 'night'; open by design so more can
11820
+ * be added without a wire break (matching falls back to any-condition refs). */
11821
+ var SceneConditionSchema = string();
11822
+ /** One captured reference — condition-tagged, model-version-gated. `embedding`
11823
+ * is `number[]` (Float32Array does NOT survive MsgPack/UDS). */
11824
+ var SceneReferenceSchema = object({
11825
+ embedding: array(number()),
11826
+ modelId: string(),
11827
+ condition: SceneConditionSchema,
11828
+ capturedAt: number(),
11829
+ thumbnailMediaId: string().optional()
11830
+ });
11831
+ var SceneMonitorStateSchema = object({
11832
+ id: string(),
11833
+ label: string(),
11834
+ references: array(SceneReferenceSchema),
11835
+ textPrompts: array(string()).optional(),
11836
+ referenceCount: number(),
11837
+ currentlyMatched: boolean()
11838
+ });
11839
+ /** Per-mode comparator params in a discriminated union so an `llm` scene never
11840
+ * carries similarity knobs and vice-versa. */
11841
+ var SceneCheckSchema = discriminatedUnion("mode", [object({
11842
+ mode: literal("similarity"),
11843
+ threshold: number().min(0).max(1),
11844
+ hysteresisCount: number().int().positive()
11845
+ }), object({
11846
+ mode: literal("llm"),
11847
+ prompt: string(),
11848
+ profileId: string().optional(),
11849
+ hysteresisCount: number().int().positive()
11850
+ })]);
11851
+ var SceneMonitorSchema = object({
11852
+ id: string(),
11853
+ label: string(),
11854
+ roi: MaskRectShapeSchema,
11855
+ enabled: boolean(),
11856
+ triggerMode: _enum([
11857
+ "periodic",
11858
+ "on-motion",
11859
+ "both"
11860
+ ]),
11861
+ checkIntervalSec: number().optional(),
11862
+ check: SceneCheckSchema,
11863
+ states: array(SceneMonitorStateSchema),
11864
+ currentStateId: string().nullable(),
11865
+ lastCheckedAt: number().nullable(),
11866
+ lastConfidence: number().nullable(),
11867
+ currentCondition: SceneConditionSchema.nullable(),
11868
+ availability: _enum(["ok", "unavailable"]),
11869
+ unavailableReason: string().nullable()
11870
+ });
11871
+ var SceneMonitorStatusSchema = object({
11872
+ monitors: array(SceneMonitorSchema),
11873
+ lastFetchedAt: number()
11874
+ });
11875
+ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSchema), method(object({
11876
+ deviceId: number(),
11877
+ label: string(),
11878
+ roi: MaskRectShapeSchema,
11879
+ check: SceneCheckSchema,
11880
+ triggerMode: _enum([
11881
+ "periodic",
11882
+ "on-motion",
11883
+ "both"
11884
+ ]).optional(),
11885
+ checkIntervalSec: number().optional()
11886
+ }), SceneMonitorSchema, {
11887
+ kind: "mutation",
11888
+ auth: "admin"
11889
+ }), method(object({
11890
+ deviceId: number(),
11891
+ monitorId: string(),
11892
+ patch: object({
11893
+ label: string().optional(),
11894
+ roi: MaskRectShapeSchema.optional(),
11895
+ enabled: boolean().optional(),
11896
+ triggerMode: _enum([
11897
+ "periodic",
11898
+ "on-motion",
11899
+ "both"
11900
+ ]).optional(),
11901
+ checkIntervalSec: number().optional(),
11902
+ check: SceneCheckSchema.optional()
11903
+ })
11904
+ }), _void(), {
11905
+ kind: "mutation",
11906
+ auth: "admin"
11907
+ }), method(object({
11908
+ deviceId: number(),
11909
+ monitorId: string()
11910
+ }), _void(), {
11911
+ kind: "mutation",
11912
+ auth: "admin"
11913
+ }), method(object({
11914
+ deviceId: number(),
11915
+ monitorId: string(),
11916
+ stateId: string().optional(),
11917
+ label: string().optional(),
11918
+ condition: SceneConditionSchema.optional()
11919
+ }), object({
11920
+ stateId: string(),
11921
+ referenceCount: number()
11922
+ }), {
11923
+ kind: "mutation",
11924
+ auth: "admin"
11925
+ }), method(object({
11926
+ deviceId: number(),
11927
+ monitorId: string(),
11928
+ stateId: string(),
11929
+ index: number()
11930
+ }), _void(), {
11931
+ kind: "mutation",
11932
+ auth: "admin"
11933
+ }), method(object({
11934
+ deviceId: number(),
11935
+ monitorId: string()
11936
+ }), _void(), {
11937
+ kind: "mutation",
11938
+ auth: "admin"
11939
+ });
11700
11940
  object({
11701
11941
  /** Whether the script is currently executing. */
11702
11942
  isRunning: boolean(),
@@ -12104,6 +12344,36 @@ var ZoneScopeBreakdownSchema = PerScopeBreakdownSchema.extend({
12104
12344
  * with the per-track detail panel and live overlay. */
12105
12345
  trackIds: array(string()).readonly()
12106
12346
  });
12347
+ /**
12348
+ * A parked ("stationary") object surfaced alongside occupancy — an object that
12349
+ * settled and stopped moving. It is NO LONGER a tracked object (the tracker was
12350
+ * told to forget it so it stops re-spawning tracks/events), but it IS still
12351
+ * physically present, so it keeps counting toward `frame` occupancy and is
12352
+ * listed here so the UI can show it in a dedicated "Stationary" section instead
12353
+ * of flooding the live event feed.
12354
+ */
12355
+ var StationaryObjectSchema = object({
12356
+ id: string(),
12357
+ className: string(),
12358
+ bbox: object({
12359
+ x: number(),
12360
+ y: number(),
12361
+ w: number(),
12362
+ h: number()
12363
+ }),
12364
+ frameWidth: number().int().nonnegative(),
12365
+ frameHeight: number().int().nonnegative(),
12366
+ /** When the source track was first seen. */
12367
+ firstSeenAt: number().int(),
12368
+ /** When the object was recognised as parked (promotion time). */
12369
+ becameStationaryAt: number().int(),
12370
+ /** Last frame a detection confirmed the object is still there. */
12371
+ lastConfirmedAt: number().int(),
12372
+ /** Enrichment label carried from the source track (identity / plate). */
12373
+ label: string().optional(),
12374
+ /** Native-resolution key-frame media key for the parked object's best image. */
12375
+ keyFrameMediaKey: string().optional()
12376
+ });
12107
12377
  var CameraOccupancySnapshotSchema = object({
12108
12378
  /** Frame timestamp of the inference result that produced this snapshot. */
12109
12379
  ts: number().int(),
@@ -12112,10 +12382,15 @@ var CameraOccupancySnapshotSchema = object({
12112
12382
  frameHeight: number().int().nonnegative(),
12113
12383
  /** Per-zone breakdown — one entry per defined zone (user + onboard). */
12114
12384
  zones: array(ZoneScopeBreakdownSchema).readonly(),
12115
- /** Frame-wide aggregate (everywhere, regardless of zone membership). */
12385
+ /** Frame-wide aggregate (everywhere, regardless of zone membership).
12386
+ * INCLUDES currently-confirmed stationary objects (they are still present). */
12116
12387
  frame: PerScopeBreakdownSchema,
12117
12388
  /** Detections that landed outside every zone. Empty when no zones defined. */
12118
- unzoned: PerScopeBreakdownSchema
12389
+ unzoned: PerScopeBreakdownSchema,
12390
+ /** Parked objects on this camera (additive — absent on legacy snapshots).
12391
+ * Surfaced separately so the UI shows them in a dedicated section rather
12392
+ * than as repeated tracks/events. */
12393
+ stationaryObjects: array(StationaryObjectSchema).readonly().optional()
12119
12394
  });
12120
12395
  /**
12121
12396
  * Time-series resolution. The history methods return one bucket per
@@ -12718,7 +12993,12 @@ var NotificationRuleConditionsSchema = object({
12718
12993
  clipDescription: object({
12719
12994
  text: string().min(1),
12720
12995
  minSimilarity: number().min(0).max(1)
12721
- }).optional()
12996
+ }).optional(),
12997
+ /** Match events whose recognized-entity label (face identity name or plate
12998
+ * vehicle name, propagated onto `event.data.label`) is one of these values.
12999
+ * Empty/absent → unaffected (back-compat). Enables "notify me when <named
13000
+ * vehicle/person> is seen". */
13001
+ labels: array(string()).readonly().optional()
12722
13002
  });
12723
13003
  var NotificationRuleTemplateSchema = object({
12724
13004
  title: string(),
@@ -13013,11 +13293,19 @@ method(object({
13013
13293
  * login page needs NO change.
13014
13294
  *
13015
13295
  * - `widget` — a Module-Federation widget the login page mounts (via
13016
- * `loadRemoteBundle`) for an in-page ceremony. Covers the passkey
13017
- * login ceremony, which must run `@simplewebauthn/browser` INSIDE the
13018
- * addon bundle. The referenced widget also declares `preAuth: true` in
13019
- * its `addon-widgets-source` catalog entry. `auth.listLoginMethods`
13020
- * stamps a public `bundleUrl` from `addonId` + `bundle`.
13296
+ * `loadRemoteBundle`) for an in-page ceremony. `auth.listLoginMethods`
13297
+ * stamps a public `bundleUrl` from `addonId` + `bundle`. Generic
13298
+ * mechanism kept for future use; no shipped addon uses it on the login
13299
+ * page (the passkey ceremony below runs natively in the shell instead).
13300
+ *
13301
+ * - `passkey` — a declarative WebAuthn ceremony the shell renders
13302
+ * natively (`@simplewebauthn/browser` lives in `addon-admin-ui`, not in
13303
+ * a remotely-loaded bundle). Carries the addon's effective `rpId` /
13304
+ * `origin` (from its `resolveRpID()` / `resolveOrigin()`) so the shell
13305
+ * can gate visibility (IP-literal origin, hostname/rpId mismatch) WITHOUT
13306
+ * fetching any remote code pre-auth. Contribution stays unconditional —
13307
+ * enrollment state is never leaked pre-auth; visibility is a shell
13308
+ * decision.
13021
13309
  *
13022
13310
  * Every contribution carries a `stage`:
13023
13311
  * - `primary` — shown on the first credentials screen (OIDC /
@@ -13031,30 +13319,45 @@ method(object({
13031
13319
  */
13032
13320
  /** When a login method renders in the two-phase login flow. */
13033
13321
  var LoginStageEnum = _enum(["primary", "second-factor"]);
13034
- /** One login-method contribution — redirect button OR pre-auth widget. */
13035
- var LoginMethodContributionSchema = discriminatedUnion("kind", [object({
13036
- kind: literal("redirect"),
13037
- /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13038
- id: string(),
13039
- /** Operator-facing button label. */
13040
- label: string(),
13041
- /** lucide-react icon name. */
13042
- icon: string().optional(),
13043
- /** Addon-owned HTTP route the button navigates to (GET). */
13044
- startUrl: string(),
13045
- stage: LoginStageEnum
13046
- }), object({
13047
- kind: literal("widget"),
13048
- /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13049
- id: string(),
13050
- /** Owning addon id drives the public bundle URL + the MF namespace. */
13051
- addonId: string(),
13052
- /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13053
- bundle: string(),
13054
- /** MF remote descriptor `{ remoteName, exposedModule, componentKey }`. */
13055
- remote: WidgetRemoteSchema,
13056
- stage: LoginStageEnum
13057
- })]);
13322
+ /** One login-method contribution — redirect button, pre-auth widget, or native passkey ceremony. */
13323
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [
13324
+ object({
13325
+ kind: literal("redirect"),
13326
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13327
+ id: string(),
13328
+ /** Operator-facing button label. */
13329
+ label: string(),
13330
+ /** lucide-react icon name. */
13331
+ icon: string().optional(),
13332
+ /** Addon-owned HTTP route the button navigates to (GET). */
13333
+ startUrl: string(),
13334
+ stage: LoginStageEnum
13335
+ }),
13336
+ object({
13337
+ kind: literal("widget"),
13338
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13339
+ id: string(),
13340
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
13341
+ addonId: string(),
13342
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13343
+ bundle: string(),
13344
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13345
+ remote: WidgetRemoteSchema,
13346
+ stage: LoginStageEnum
13347
+ }),
13348
+ object({
13349
+ kind: literal("passkey"),
13350
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-direct-login`). */
13351
+ id: string(),
13352
+ /** Operator-facing button label. */
13353
+ label: string(),
13354
+ stage: LoginStageEnum,
13355
+ /** Effective WebAuthn RP ID (`resolveRpID()`) — the shell gates visibility on it. */
13356
+ rpId: string(),
13357
+ /** Effective expected origin (`resolveOrigin()`), null when unconfigured. */
13358
+ origin: string().nullable()
13359
+ })
13360
+ ]);
13058
13361
  method(_void(), array(LoginMethodContributionSchema).readonly());
13059
13362
  /**
13060
13363
  * Orchestrator-side destination metadata. The orchestrator computes
@@ -14975,14 +15278,14 @@ var TargetKindCapsSchema = object({
14975
15278
  * the union is large and not meant for runtime validation here; the exported
14976
15279
  * `TargetKind` type re-tightens `configSchema` to `ConfigUISchema`.
14977
15280
  */
14978
- var ConfigSchemaPassthrough = unknown();
15281
+ var ConfigSchemaPassthrough$1 = unknown();
14979
15282
  var TargetKindSchema = object({
14980
15283
  kind: string(),
14981
15284
  label: string(),
14982
15285
  icon: string(),
14983
15286
  /** Stamped by each provider so the concat-fanned catalog stays routable. */
14984
15287
  addonId: string(),
14985
- configSchema: ConfigSchemaPassthrough,
15288
+ configSchema: ConfigSchemaPassthrough$1,
14986
15289
  supportsDiscovery: boolean(),
14987
15290
  caps: TargetKindCapsSchema
14988
15291
  });
@@ -15035,6 +15338,298 @@ method(object({}), array(TargetKindSchema)), method(object({}), array(TargetSche
15035
15338
  enabled: boolean()
15036
15339
  }), _void(), { kind: "mutation" });
15037
15340
  /**
15341
+ * Shared LLM generate contracts — imported by BOTH `llm.cap.ts` (consumer
15342
+ * surface) and `llm-runtime.cap.ts` (node-side managed executor) so the two
15343
+ * caps stay wire-compatible without a circular cap→cap import.
15344
+ *
15345
+ * Errors are a discriminated-union RESULT, never thrown: the shape survives
15346
+ * every transport tier structurally, and failed calls still write usage rows.
15347
+ * Token counts only in v1 — no costUsd (operator decision, 2026-07-15).
15348
+ */
15349
+ var LlmUsageSchema = object({
15350
+ inputTokens: number(),
15351
+ outputTokens: number()
15352
+ });
15353
+ var LlmErrorCodeSchema = _enum([
15354
+ "timeout",
15355
+ "rate-limited",
15356
+ "auth",
15357
+ "refusal",
15358
+ "bad-request",
15359
+ "unavailable",
15360
+ "no-profile",
15361
+ "budget-exceeded",
15362
+ "adapter-error"
15363
+ ]);
15364
+ var LlmGenerateResultSchema = discriminatedUnion("ok", [object({
15365
+ ok: literal(true),
15366
+ text: string(),
15367
+ model: string(),
15368
+ usage: LlmUsageSchema,
15369
+ truncated: boolean(),
15370
+ latencyMs: number()
15371
+ }), object({
15372
+ ok: literal(false),
15373
+ code: LlmErrorCodeSchema,
15374
+ message: string(),
15375
+ retryAfterMs: number().optional()
15376
+ })]);
15377
+ /**
15378
+ * `Uint8Array` is the sanctioned binary convention — superjson + the UDS
15379
+ * MsgPack channel round-trip typed arrays (embedding-encoder.cap.ts:29,
15380
+ * notification-output.cap.ts:27-31 precedents).
15381
+ */
15382
+ var LlmImageSchema = object({
15383
+ bytes: _instanceof(Uint8Array),
15384
+ mimeType: string()
15385
+ });
15386
+ var LlmGenerateBaseInputSchema = object({
15387
+ /** Collection routing (the notification-output posture). */
15388
+ addonId: string().optional(),
15389
+ /** Explicit profile; else the resolution chain (spec §3). */
15390
+ profileId: string().optional(),
15391
+ /** MANDATORY usage tag: 'ai-summary', 'notifier-rules', 'adhoc-ui', … */
15392
+ consumer: string(),
15393
+ system: string().optional(),
15394
+ /** v1: single-turn. `messages[]` is a v2 additive field. */
15395
+ prompt: string(),
15396
+ /** Structured output — adapter-mapped (response_format / forced tool / responseSchema). */
15397
+ jsonSchema: record(string(), unknown()).optional(),
15398
+ /** Per-call override of the profile default. */
15399
+ maxTokens: number().int().positive().optional(),
15400
+ temperature: number().optional()
15401
+ });
15402
+ /**
15403
+ * `llm-runtime` — node-side managed llama.cpp executor (spec §4). Registered
15404
+ * on EVERY node where `addon-ai` is installed; the hub `llm` provider reaches
15405
+ * a specific node's runtime with `nodePin(profile.runtime.nodeId)` — normal
15406
+ * cap routing, zero bespoke plumbing. `internal: true`: the operator reaches
15407
+ * this only through the `llm` cap's methods.
15408
+ *
15409
+ * One running llama-server child per node in v1 (models are RAM-heavy).
15410
+ * Resource ceiling = llama-server flags + idleStopMinutes ONLY (no RSS
15411
+ * watchdog — operator decision #3).
15412
+ */
15413
+ var ManagedModelRefSchema = discriminatedUnion("kind", [
15414
+ object({
15415
+ kind: literal("catalog"),
15416
+ catalogId: string()
15417
+ }),
15418
+ object({
15419
+ kind: literal("url"),
15420
+ url: string(),
15421
+ sha256: string().optional()
15422
+ }),
15423
+ object({
15424
+ kind: literal("path"),
15425
+ path: string()
15426
+ })
15427
+ ]);
15428
+ var ManagedRuntimeConfigSchema = object({
15429
+ /** WHERE the runtime lives — hub or any agent. */
15430
+ nodeId: string(),
15431
+ /** Closed for v1; 'ollama' is a v2 candidate. */
15432
+ engine: _enum(["llama-cpp"]),
15433
+ model: ManagedModelRefSchema,
15434
+ contextSize: number().int().default(4096),
15435
+ /** 0 = CPU-only. */
15436
+ gpuLayers: number().int().default(0),
15437
+ /** Default: cpus-2, clamped ≥1 (resolved node-side). */
15438
+ threads: number().int().optional(),
15439
+ /** Concurrent slots. */
15440
+ parallel: number().int().default(1),
15441
+ /** Else lazy: first generate boots it. */
15442
+ autoStart: boolean().default(false),
15443
+ /** 0 = never; frees RAM after quiet periods. */
15444
+ idleStopMinutes: number().int().default(30)
15445
+ });
15446
+ var LlmRuntimeStatusSchema = object({
15447
+ /** Status is ALWAYS node-qualified. */
15448
+ nodeId: string(),
15449
+ state: _enum([
15450
+ "stopped",
15451
+ "downloading",
15452
+ "starting",
15453
+ "ready",
15454
+ "crashed",
15455
+ "failed"
15456
+ ]),
15457
+ pid: number().optional(),
15458
+ port: number().optional(),
15459
+ modelPath: string().optional(),
15460
+ modelId: string().optional(),
15461
+ downloadProgress: number().min(0).max(1).optional(),
15462
+ lastError: string().optional(),
15463
+ crashesInWindow: number(),
15464
+ /** Child RSS (sampled best-effort). */
15465
+ memoryBytes: number().optional(),
15466
+ vramBytes: number().optional()
15467
+ });
15468
+ var LlmNodeModelSchema = object({
15469
+ file: string(),
15470
+ sizeBytes: number(),
15471
+ catalogId: string().optional(),
15472
+ installedAt: number().optional()
15473
+ });
15474
+ var LlmRuntimeDiskUsageSchema = object({
15475
+ nodeId: string(),
15476
+ modelsBytes: number(),
15477
+ freeBytes: number().optional()
15478
+ });
15479
+ method(LlmGenerateBaseInputSchema.extend({
15480
+ images: array(LlmImageSchema).optional(),
15481
+ runtime: ManagedRuntimeConfigSchema,
15482
+ /** The managed profile's timeout, threaded by the hub provider. */
15483
+ timeoutMs: number().int().positive().optional()
15484
+ }), LlmGenerateResultSchema, { kind: "mutation" }), method(object({ runtime: ManagedRuntimeConfigSchema }), LlmRuntimeStatusSchema, {
15485
+ kind: "mutation",
15486
+ auth: "admin"
15487
+ }), method(object({}), _void(), {
15488
+ kind: "mutation",
15489
+ auth: "admin"
15490
+ }), method(object({}), LlmRuntimeStatusSchema), method(object({ model: ManagedModelRefSchema }), _void(), {
15491
+ kind: "mutation",
15492
+ auth: "admin"
15493
+ }), method(object({ file: string() }), _void(), {
15494
+ kind: "mutation",
15495
+ auth: "admin"
15496
+ }), method(object({}), array(LlmNodeModelSchema)), method(object({}), LlmRuntimeDiskUsageSchema);
15497
+ /**
15498
+ * `llm` — consumer-facing LLM surface (spec §1-§3). Collection-mode: array
15499
+ * methods concat-fan across providers; single-row methods route to ONE
15500
+ * provider by the `addonId` in the call input (the notification-output
15501
+ * posture, notification-output.cap.ts:215-250). Provided by `addon-ai`
15502
+ * (hub-placed); the cap stays open for future providers.
15503
+ *
15504
+ * Profiles are ROWS (data), not addons: one row = one usable model endpoint.
15505
+ * `apiKey` is a password field — providers REDACT it on read and merge on
15506
+ * write; a stored key NEVER round-trips to a client.
15507
+ */
15508
+ var LlmProfileKindSchema = _enum([
15509
+ "openai-compatible",
15510
+ "openai",
15511
+ "anthropic",
15512
+ "google",
15513
+ "managed-local"
15514
+ ]);
15515
+ var LlmProfileSchema = object({
15516
+ id: string(),
15517
+ name: string(),
15518
+ kind: LlmProfileKindSchema,
15519
+ /** Stamped by the provider — keeps the fanned catalog routable. */
15520
+ addonId: string(),
15521
+ enabled: boolean(),
15522
+ /** Vendor model id, or the managed runtime's loaded model. */
15523
+ model: string(),
15524
+ /** Required for openai-compatible; override for cloud kinds. */
15525
+ baseUrl: string().optional(),
15526
+ /** ConfigUISchema type:'password' — never round-trips (spec §5). */
15527
+ apiKey: string().optional(),
15528
+ supportsVision: boolean(),
15529
+ temperature: number().min(0).max(2).optional(),
15530
+ maxTokens: number().int().positive().optional(),
15531
+ timeoutMs: number().int().positive().default(6e4),
15532
+ extraHeaders: record(string(), string()).optional(),
15533
+ /** kind === 'managed-local' only (spec §4). */
15534
+ runtime: ManagedRuntimeConfigSchema.optional()
15535
+ });
15536
+ /** ConfigUISchema tree passed through untyped on the wire (the
15537
+ * notification-output `ConfigSchemaPassthrough` precedent at
15538
+ * notification-output.cap.ts:151); the exported TS type re-tightens it. */
15539
+ var ConfigSchemaPassthrough = unknown();
15540
+ var LlmProfileKindDescriptorSchema = object({
15541
+ kind: LlmProfileKindSchema,
15542
+ label: string(),
15543
+ icon: string(),
15544
+ /** Stamped by each provider so the concat-fanned catalog stays routable. */
15545
+ addonId: string(),
15546
+ configSchema: ConfigSchemaPassthrough
15547
+ });
15548
+ var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
15549
+ var LlmDefaultSchema = object({
15550
+ selector: LlmDefaultSelectorSchema,
15551
+ profileId: string()
15552
+ });
15553
+ /** Server-side rollup row — getUsage never dumps raw call rows (spec §6). */
15554
+ var LlmUsageRollupSchema = object({
15555
+ day: string(),
15556
+ consumer: string(),
15557
+ profileId: string(),
15558
+ calls: number(),
15559
+ okCalls: number(),
15560
+ errorCalls: number(),
15561
+ inputTokens: number(),
15562
+ outputTokens: number(),
15563
+ avgLatencyMs: number()
15564
+ });
15565
+ /** LLM-facing view over the reused ModelCatalogEntry mechanism (spec §4.2). */
15566
+ var ManagedModelCatalogEntrySchema = object({
15567
+ id: string(),
15568
+ label: string(),
15569
+ family: string(),
15570
+ purpose: _enum(["text", "vision"]),
15571
+ url: string(),
15572
+ sha256: string(),
15573
+ sizeBytes: number(),
15574
+ quantization: string(),
15575
+ /** Load-time guidance shown in the picker. */
15576
+ minRamBytes: number(),
15577
+ contextSizeDefault: number().int(),
15578
+ /** Vision models: companion projector file. */
15579
+ mmprojUrl: string().optional()
15580
+ });
15581
+ var LlmRuntimeNodeSchema = object({
15582
+ nodeId: string(),
15583
+ reachable: boolean(),
15584
+ status: LlmRuntimeStatusSchema.optional(),
15585
+ disk: LlmRuntimeDiskUsageSchema.optional(),
15586
+ error: string().optional()
15587
+ });
15588
+ var GenerateVisionInputSchema = LlmGenerateBaseInputSchema.extend({ images: array(LlmImageSchema).min(1) });
15589
+ var ProfileRefInputSchema = object({
15590
+ addonId: string(),
15591
+ profileId: string()
15592
+ });
15593
+ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(GenerateVisionInputSchema, LlmGenerateResultSchema, { kind: "mutation" }), method(object({}), array(LlmProfileKindDescriptorSchema)), method(object({}), array(LlmProfileSchema)), method(object({ profile: LlmProfileSchema }), LlmProfileSchema, {
15594
+ kind: "mutation",
15595
+ auth: "admin"
15596
+ }), method(ProfileRefInputSchema, _void(), {
15597
+ kind: "mutation",
15598
+ auth: "admin"
15599
+ }), method(ProfileRefInputSchema, LlmGenerateResultSchema, {
15600
+ kind: "mutation",
15601
+ auth: "admin"
15602
+ }), method(ProfileRefInputSchema, array(string())), method(object({}), array(LlmDefaultSchema)), method(object({
15603
+ selector: LlmDefaultSelectorSchema,
15604
+ profileId: string().nullable()
15605
+ }), _void(), {
15606
+ kind: "mutation",
15607
+ auth: "admin"
15608
+ }), method(object({
15609
+ since: number().optional(),
15610
+ until: number().optional(),
15611
+ consumer: string().optional(),
15612
+ profileId: string().optional()
15613
+ }), array(LlmUsageRollupSchema)), method(object({}), array(ManagedModelCatalogEntrySchema)), method(object({}), array(LlmRuntimeNodeSchema)), method(object({ nodeId: string() }), array(LlmNodeModelSchema)), method(object({
15614
+ nodeId: string(),
15615
+ model: ManagedModelRefSchema
15616
+ }), _void(), {
15617
+ kind: "mutation",
15618
+ auth: "admin"
15619
+ }), method(object({
15620
+ nodeId: string(),
15621
+ file: string()
15622
+ }), _void(), {
15623
+ kind: "mutation",
15624
+ auth: "admin"
15625
+ }), method(ProfileRefInputSchema, LlmRuntimeStatusSchema), method(ProfileRefInputSchema, LlmRuntimeStatusSchema, {
15626
+ kind: "mutation",
15627
+ auth: "admin"
15628
+ }), method(ProfileRefInputSchema, _void(), {
15629
+ kind: "mutation",
15630
+ auth: "admin"
15631
+ });
15632
+ /**
15038
15633
  * Zod schemas for persisted record types.
15039
15634
  *
15040
15635
  * These schemas serve as the single source of truth for types that are
@@ -15236,6 +15831,22 @@ var TrackSnapshotSchema = object({
15236
15831
  /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
15237
15832
  mediaKey: string()
15238
15833
  });
15834
+ /**
15835
+ * One audio-classification label heard on the track's camera while the
15836
+ * track was alive, aggregated per label. An "episode" is one persisted
15837
+ * audio event (the confident-classification path: score ≥ the device's
15838
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
15839
+ * one 32 ms inference chunk, so counts stay human-scaled.
15840
+ */
15841
+ var TrackAudioLabelSchema = object({
15842
+ label: string(),
15843
+ /** Highest classification score observed across the label's episodes. */
15844
+ peakScore: number(),
15845
+ /** Number of coalesced audio-event episodes carrying this label. */
15846
+ count: number(),
15847
+ firstAt: number(),
15848
+ lastAt: number()
15849
+ });
15239
15850
  var TrackSchema = object({
15240
15851
  trackId: string(),
15241
15852
  deviceId: number(),
@@ -15250,6 +15861,10 @@ var TrackSchema = object({
15250
15861
  snapshots: array(TrackSnapshotSchema).readonly(),
15251
15862
  /** Deduplicated zones the track has entered at least once. */
15252
15863
  zonesVisited: array(string()).readonly(),
15864
+ /** Deduplicated set of detector classes observed for this track over its
15865
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
15866
+ * legacy rows written before class accumulation shipped. */
15867
+ classes: array(string()).readonly().optional(),
15253
15868
  /** Cumulative normalized distance travelled (0..1 units = full frame width). */
15254
15869
  totalDistance: number(),
15255
15870
  state: TrackStateSchema,
@@ -15263,7 +15878,11 @@ var TrackSchema = object({
15263
15878
  bestEventId: string().optional(),
15264
15879
  /** Tag of the importance sub-signal that dominated the score
15265
15880
  * (identity|dwell|proximity|class|confidence|travel|zone). */
15266
- importanceReason: string().optional()
15881
+ importanceReason: string().optional(),
15882
+ /** Audio-classification labels heard on the camera during the track's
15883
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
15884
+ * Absent on legacy rows / tracks with no confident audio. */
15885
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional()
15267
15886
  });
15268
15887
  var BaseEventFields = {
15269
15888
  id: string(),
@@ -15411,7 +16030,7 @@ var KeyEventSchema = object({
15411
16030
  /** Track lifetime in ms (lastSeen - firstSeen). */
15412
16031
  windowMs: number().optional()
15413
16032
  });
15414
- var TrackedDetectionSchema = object({
16033
+ object({
15415
16034
  trackId: string(),
15416
16035
  className: string(),
15417
16036
  confidence: number(),
@@ -15419,6 +16038,23 @@ var TrackedDetectionSchema = object({
15419
16038
  zones: array(string()).readonly(),
15420
16039
  state: TrackStateSchema
15421
16040
  });
16041
+ var OverlayDetectionSchema = looseObject({
16042
+ id: string(),
16043
+ kind: _enum(["first-level", "detail"]),
16044
+ macroClass: string(),
16045
+ score: number(),
16046
+ bbox: object({
16047
+ x: number(),
16048
+ y: number(),
16049
+ width: number(),
16050
+ height: number()
16051
+ }),
16052
+ labels: array(looseObject({
16053
+ label: string(),
16054
+ score: number()
16055
+ })).readonly(),
16056
+ parentId: string().optional()
16057
+ });
15422
16058
  var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
15423
16059
  var SearchObjectEventsInput = object({
15424
16060
  text: string(),
@@ -15429,6 +16065,20 @@ var SearchObjectEventsInput = object({
15429
16065
  limit: number().default(50),
15430
16066
  minScore: number().min(0).max(1).default(.2)
15431
16067
  });
16068
+ var TrackCascadeCountsSchema = object({
16069
+ /** Persisted track roots deleted (authoritative). */
16070
+ tracks: number().int(),
16071
+ /** Object events removed with their tracks (best-effort; see note above). */
16072
+ events: number().int(),
16073
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
16074
+ media: number().int(),
16075
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
16076
+ faces: number().int(),
16077
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
16078
+ plates: number().int(),
16079
+ /** Per-track CLIP search vectors removed (best-effort). */
16080
+ embeddings: number().int()
16081
+ });
15432
16082
  DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
15433
16083
  deviceId: number(),
15434
16084
  trackId: string()
@@ -15461,15 +16111,33 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
15461
16111
  kind: "mutation",
15462
16112
  auth: "admin"
15463
16113
  }), method(object({
15464
- eventId: string(),
15465
- kind: MediaFileKindEnum.optional()
15466
- }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
15467
16114
  deviceId: number(),
15468
- timestamp: number(),
15469
- frameWidth: number(),
15470
- frameHeight: number(),
15471
- detections: array(TrackedDetectionSchema).readonly()
15472
- }), object({
16115
+ cutoffMs: number()
16116
+ }), TrackCascadeCountsSchema, {
16117
+ kind: "mutation",
16118
+ auth: "admin"
16119
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
16120
+ kind: "mutation",
16121
+ auth: "admin"
16122
+ }), method(object({
16123
+ deviceId: number(),
16124
+ trackIds: array(string()).min(1)
16125
+ }), object({
16126
+ deleted: number().int(),
16127
+ failed: array(string()).readonly()
16128
+ }), {
16129
+ kind: "mutation",
16130
+ auth: "admin"
16131
+ }), method(object({
16132
+ eventId: string(),
16133
+ kind: MediaFileKindEnum.optional()
16134
+ }), array(MediaFileSchema).readonly()), method(object({ trackId: string() }), array(MediaFileSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), object({
16135
+ deviceId: number(),
16136
+ timestamp: number(),
16137
+ frameWidth: number(),
16138
+ frameHeight: number(),
16139
+ detections: array(OverlayDetectionSchema).readonly()
16140
+ }), object({
15473
16141
  deviceId: number(),
15474
16142
  trackId: string(),
15475
16143
  className: string()
@@ -18237,6 +18905,24 @@ DeviceType.Camera, method(object({
18237
18905
  deviceId: number(),
18238
18906
  status: OsdStatusSchema
18239
18907
  });
18908
+ var VehicleSchema = object({
18909
+ id: string(),
18910
+ name: string(),
18911
+ sampleCount: number().int().nonnegative(),
18912
+ coverMediaKey: string().optional(),
18913
+ /** Inline base64 of the cover sample's plate crop, resolved from `coverMediaKey`. */
18914
+ coverBase64: string().optional()
18915
+ });
18916
+ var VehicleSampleInfoSchema = object({
18917
+ id: string(),
18918
+ /** The plate text this sample enrolled (self-labeling — no embedding). */
18919
+ text: string(),
18920
+ /** OCR confidence of the enrolled read (0..1). */
18921
+ score: number(),
18922
+ addedAt: number().int(),
18923
+ deviceId: number().int().optional(),
18924
+ base64: string().optional()
18925
+ });
18240
18926
  var PlateInfoSchema = object({
18241
18927
  plateId: string(),
18242
18928
  deviceId: number().int(),
@@ -18248,6 +18934,16 @@ var PlateInfoSchema = object({
18248
18934
  score: number(),
18249
18935
  /** True when the text was manually corrected (exempt from retention). */
18250
18936
  corrected: boolean(),
18937
+ /** Recognized vehicle id when a matcher lookup named this read (SQL NULL → absent). */
18938
+ recognizedVehicleId: string().optional(),
18939
+ /** Resolved vehicle name for `recognizedVehicleId` (UI convenience). */
18940
+ vehicleName: string().optional(),
18941
+ /** True once the read was assigned to a vehicle (enrolled as a sample). */
18942
+ assigned: boolean(),
18943
+ /** keyFrame parity: the plate bbox (pixel space) on the native key frame. */
18944
+ plateBbox: BoundingBoxSchema.optional(),
18945
+ /** keyFrame parity: MediaStore key of the track's native-resolution key frame. */
18946
+ keyFrameMediaKey: string().optional(),
18251
18947
  base64: string().optional()
18252
18948
  });
18253
18949
  var MediaFileLiteSchema = object({
@@ -18287,6 +18983,48 @@ method(object({
18287
18983
  }), method(object({ plateId: string() }), _void(), {
18288
18984
  kind: "mutation",
18289
18985
  auth: "admin"
18986
+ }), method(_void(), array(VehicleSchema).readonly()), method(object({ name: string().min(1) }), VehicleSchema, {
18987
+ kind: "mutation",
18988
+ auth: "admin"
18989
+ }), method(object({
18990
+ id: string(),
18991
+ name: string().min(1)
18992
+ }), _void(), {
18993
+ kind: "mutation",
18994
+ auth: "admin"
18995
+ }), method(object({ id: string() }), _void(), {
18996
+ kind: "mutation",
18997
+ auth: "admin"
18998
+ }), method(object({ vehicleId: string() }), array(VehicleSampleInfoSchema).readonly()), method(object({
18999
+ vehicleId: string(),
19000
+ sampleId: string()
19001
+ }), _void(), {
19002
+ kind: "mutation",
19003
+ auth: "admin"
19004
+ }), method(object({
19005
+ plateId: string(),
19006
+ vehicleId: string()
19007
+ }), _void(), {
19008
+ kind: "mutation",
19009
+ auth: "admin"
19010
+ }), method(object({ plateId: string() }), _void(), {
19011
+ kind: "mutation",
19012
+ auth: "admin"
19013
+ }), method(object({
19014
+ plateIds: array(string()).min(1),
19015
+ vehicleId: string()
19016
+ }), object({
19017
+ assigned: number().int(),
19018
+ failed: array(string()).readonly()
19019
+ }), {
19020
+ kind: "mutation",
19021
+ auth: "admin"
19022
+ }), method(object({ plateIds: array(string()).min(1) }), object({
19023
+ unassigned: number().int(),
19024
+ failed: array(string()).readonly()
19025
+ }), {
19026
+ kind: "mutation",
19027
+ auth: "admin"
18290
19028
  });
18291
19029
  var ModelFormatSchema = _enum(MODEL_FORMATS);
18292
19030
  var HwAccelBackendInputSchema = _enum([
@@ -18365,6 +19103,10 @@ var GpuInfoSchema = object({
18365
19103
  memoryMB: number().optional()
18366
19104
  });
18367
19105
  var NpuInfoSchema = object({ type: _enum(["apple-ane", "intel-npu"]) });
19106
+ var CoralInfoSchema = object({
19107
+ type: literal("coral-edgetpu"),
19108
+ bus: string().optional()
19109
+ });
18368
19110
  var HardwareInfoSchema = object({
18369
19111
  platform: HardwarePlatformSchema,
18370
19112
  arch: HardwareArchSchema,
@@ -18373,7 +19115,8 @@ var HardwareInfoSchema = object({
18373
19115
  totalRAM_MB: number(),
18374
19116
  availableRAM_MB: number(),
18375
19117
  gpu: GpuInfoSchema.nullable(),
18376
- npu: NpuInfoSchema.nullable()
19118
+ npu: NpuInfoSchema.nullable(),
19119
+ coral: CoralInfoSchema.nullable().optional()
18377
19120
  });
18378
19121
  var PlatformScoreSchema = object({
18379
19122
  runtime: _enum(["node", "python"]),
@@ -20832,6 +21575,168 @@ Object.freeze({
20832
21575
  addonId: null,
20833
21576
  access: "create"
20834
21577
  },
21578
+ "llm.deleteModel": {
21579
+ capName: "llm",
21580
+ capScope: "system",
21581
+ addonId: null,
21582
+ access: "delete"
21583
+ },
21584
+ "llm.deleteProfile": {
21585
+ capName: "llm",
21586
+ capScope: "system",
21587
+ addonId: null,
21588
+ access: "delete"
21589
+ },
21590
+ "llm.generate": {
21591
+ capName: "llm",
21592
+ capScope: "system",
21593
+ addonId: null,
21594
+ access: "create"
21595
+ },
21596
+ "llm.generateVision": {
21597
+ capName: "llm",
21598
+ capScope: "system",
21599
+ addonId: null,
21600
+ access: "create"
21601
+ },
21602
+ "llm.getDefaults": {
21603
+ capName: "llm",
21604
+ capScope: "system",
21605
+ addonId: null,
21606
+ access: "view"
21607
+ },
21608
+ "llm.getRuntimeStatus": {
21609
+ capName: "llm",
21610
+ capScope: "system",
21611
+ addonId: null,
21612
+ access: "view"
21613
+ },
21614
+ "llm.getUsage": {
21615
+ capName: "llm",
21616
+ capScope: "system",
21617
+ addonId: null,
21618
+ access: "view"
21619
+ },
21620
+ "llm.installModel": {
21621
+ capName: "llm",
21622
+ capScope: "system",
21623
+ addonId: null,
21624
+ access: "create"
21625
+ },
21626
+ "llm.listModelCatalog": {
21627
+ capName: "llm",
21628
+ capScope: "system",
21629
+ addonId: null,
21630
+ access: "view"
21631
+ },
21632
+ "llm.listModels": {
21633
+ capName: "llm",
21634
+ capScope: "system",
21635
+ addonId: null,
21636
+ access: "view"
21637
+ },
21638
+ "llm.listNodeModels": {
21639
+ capName: "llm",
21640
+ capScope: "system",
21641
+ addonId: null,
21642
+ access: "view"
21643
+ },
21644
+ "llm.listProfileKinds": {
21645
+ capName: "llm",
21646
+ capScope: "system",
21647
+ addonId: null,
21648
+ access: "view"
21649
+ },
21650
+ "llm.listProfiles": {
21651
+ capName: "llm",
21652
+ capScope: "system",
21653
+ addonId: null,
21654
+ access: "view"
21655
+ },
21656
+ "llm.listRuntimeNodes": {
21657
+ capName: "llm",
21658
+ capScope: "system",
21659
+ addonId: null,
21660
+ access: "view"
21661
+ },
21662
+ "llm.setDefault": {
21663
+ capName: "llm",
21664
+ capScope: "system",
21665
+ addonId: null,
21666
+ access: "create"
21667
+ },
21668
+ "llm.startRuntime": {
21669
+ capName: "llm",
21670
+ capScope: "system",
21671
+ addonId: null,
21672
+ access: "create"
21673
+ },
21674
+ "llm.stopRuntime": {
21675
+ capName: "llm",
21676
+ capScope: "system",
21677
+ addonId: null,
21678
+ access: "create"
21679
+ },
21680
+ "llm.testProfile": {
21681
+ capName: "llm",
21682
+ capScope: "system",
21683
+ addonId: null,
21684
+ access: "create"
21685
+ },
21686
+ "llm.upsertProfile": {
21687
+ capName: "llm",
21688
+ capScope: "system",
21689
+ addonId: null,
21690
+ access: "create"
21691
+ },
21692
+ "llmRuntime.complete": {
21693
+ capName: "llm-runtime",
21694
+ capScope: "system",
21695
+ addonId: null,
21696
+ access: "create"
21697
+ },
21698
+ "llmRuntime.deleteModel": {
21699
+ capName: "llm-runtime",
21700
+ capScope: "system",
21701
+ addonId: null,
21702
+ access: "delete"
21703
+ },
21704
+ "llmRuntime.ensureStarted": {
21705
+ capName: "llm-runtime",
21706
+ capScope: "system",
21707
+ addonId: null,
21708
+ access: "create"
21709
+ },
21710
+ "llmRuntime.getDiskUsage": {
21711
+ capName: "llm-runtime",
21712
+ capScope: "system",
21713
+ addonId: null,
21714
+ access: "view"
21715
+ },
21716
+ "llmRuntime.installModel": {
21717
+ capName: "llm-runtime",
21718
+ capScope: "system",
21719
+ addonId: null,
21720
+ access: "create"
21721
+ },
21722
+ "llmRuntime.listLocalModels": {
21723
+ capName: "llm-runtime",
21724
+ capScope: "system",
21725
+ addonId: null,
21726
+ access: "view"
21727
+ },
21728
+ "llmRuntime.status": {
21729
+ capName: "llm-runtime",
21730
+ capScope: "system",
21731
+ addonId: null,
21732
+ access: "view"
21733
+ },
21734
+ "llmRuntime.stop": {
21735
+ capName: "llm-runtime",
21736
+ capScope: "system",
21737
+ addonId: null,
21738
+ access: "create"
21739
+ },
20835
21740
  "localNetwork.getAllowedAddresses": {
20836
21741
  capName: "local-network",
20837
21742
  capScope: "system",
@@ -21462,6 +22367,12 @@ Object.freeze({
21462
22367
  addonId: null,
21463
22368
  access: "delete"
21464
22369
  },
22370
+ "pipelineAnalytics.deleteTracks": {
22371
+ capName: "pipeline-analytics",
22372
+ capScope: "device",
22373
+ addonId: null,
22374
+ access: "delete"
22375
+ },
21465
22376
  "pipelineAnalytics.getActiveTracks": {
21466
22377
  capName: "pipeline-analytics",
21467
22378
  capScope: "device",
@@ -21528,12 +22439,24 @@ Object.freeze({
21528
22439
  addonId: null,
21529
22440
  access: "create"
21530
22441
  },
22442
+ "pipelineAnalytics.pruneTracksBefore": {
22443
+ capName: "pipeline-analytics",
22444
+ capScope: "device",
22445
+ addonId: null,
22446
+ access: "create"
22447
+ },
21531
22448
  "pipelineAnalytics.searchObjectEvents": {
21532
22449
  capName: "pipeline-analytics",
21533
22450
  capScope: "device",
21534
22451
  addonId: null,
21535
22452
  access: "view"
21536
22453
  },
22454
+ "pipelineAnalytics.wipeAllAnalytics": {
22455
+ capName: "pipeline-analytics",
22456
+ capScope: "device",
22457
+ addonId: null,
22458
+ access: "delete"
22459
+ },
21537
22460
  "pipelineExecutor.cacheFrameInPool": {
21538
22461
  capName: "pipeline-executor",
21539
22462
  capScope: "system",
@@ -22032,18 +22955,48 @@ Object.freeze({
22032
22955
  addonId: null,
22033
22956
  access: "create"
22034
22957
  },
22958
+ "pipelineRunner.runDetailSubtree": {
22959
+ capName: "pipeline-runner",
22960
+ capScope: "system",
22961
+ addonId: null,
22962
+ access: "create"
22963
+ },
22964
+ "plateGallery.assignPlate": {
22965
+ capName: "plate-gallery",
22966
+ capScope: "system",
22967
+ addonId: null,
22968
+ access: "create"
22969
+ },
22970
+ "plateGallery.assignPlates": {
22971
+ capName: "plate-gallery",
22972
+ capScope: "system",
22973
+ addonId: null,
22974
+ access: "create"
22975
+ },
22035
22976
  "plateGallery.correctPlateText": {
22036
22977
  capName: "plate-gallery",
22037
22978
  capScope: "system",
22038
22979
  addonId: null,
22039
22980
  access: "create"
22040
22981
  },
22982
+ "plateGallery.createVehicle": {
22983
+ capName: "plate-gallery",
22984
+ capScope: "system",
22985
+ addonId: null,
22986
+ access: "create"
22987
+ },
22041
22988
  "plateGallery.deletePlate": {
22042
22989
  capName: "plate-gallery",
22043
22990
  capScope: "system",
22044
22991
  addonId: null,
22045
22992
  access: "delete"
22046
22993
  },
22994
+ "plateGallery.deleteVehicle": {
22995
+ capName: "plate-gallery",
22996
+ capScope: "system",
22997
+ addonId: null,
22998
+ access: "delete"
22999
+ },
22047
23000
  "plateGallery.getPlateByTrack": {
22048
23001
  capName: "plate-gallery",
22049
23002
  capScope: "system",
@@ -22062,6 +23015,30 @@ Object.freeze({
22062
23015
  addonId: null,
22063
23016
  access: "view"
22064
23017
  },
23018
+ "plateGallery.listVehicles": {
23019
+ capName: "plate-gallery",
23020
+ capScope: "system",
23021
+ addonId: null,
23022
+ access: "view"
23023
+ },
23024
+ "plateGallery.listVehicleSamples": {
23025
+ capName: "plate-gallery",
23026
+ capScope: "system",
23027
+ addonId: null,
23028
+ access: "view"
23029
+ },
23030
+ "plateGallery.removeVehicleSample": {
23031
+ capName: "plate-gallery",
23032
+ capScope: "system",
23033
+ addonId: null,
23034
+ access: "delete"
23035
+ },
23036
+ "plateGallery.renameVehicle": {
23037
+ capName: "plate-gallery",
23038
+ capScope: "system",
23039
+ addonId: null,
23040
+ access: "create"
23041
+ },
22065
23042
  "plateGallery.searchPlates": {
22066
23043
  capName: "plate-gallery",
22067
23044
  capScope: "system",
@@ -22074,6 +23051,18 @@ Object.freeze({
22074
23051
  addonId: null,
22075
23052
  access: "view"
22076
23053
  },
23054
+ "plateGallery.unassignPlate": {
23055
+ capName: "plate-gallery",
23056
+ capScope: "system",
23057
+ addonId: null,
23058
+ access: "create"
23059
+ },
23060
+ "plateGallery.unassignPlates": {
23061
+ capName: "plate-gallery",
23062
+ capScope: "system",
23063
+ addonId: null,
23064
+ access: "create"
23065
+ },
22077
23066
  "platformProbe.getCapabilities": {
22078
23067
  capName: "platform-probe",
22079
23068
  capScope: "system",
@@ -22266,6 +23255,48 @@ Object.freeze({
22266
23255
  addonId: null,
22267
23256
  access: "create"
22268
23257
  },
23258
+ "sceneMonitor.captureReference": {
23259
+ capName: "scene-monitor",
23260
+ capScope: "device",
23261
+ addonId: null,
23262
+ access: "create"
23263
+ },
23264
+ "sceneMonitor.createScene": {
23265
+ capName: "scene-monitor",
23266
+ capScope: "device",
23267
+ addonId: null,
23268
+ access: "create"
23269
+ },
23270
+ "sceneMonitor.deleteReference": {
23271
+ capName: "scene-monitor",
23272
+ capScope: "device",
23273
+ addonId: null,
23274
+ access: "delete"
23275
+ },
23276
+ "sceneMonitor.deleteScene": {
23277
+ capName: "scene-monitor",
23278
+ capScope: "device",
23279
+ addonId: null,
23280
+ access: "delete"
23281
+ },
23282
+ "sceneMonitor.listScenes": {
23283
+ capName: "scene-monitor",
23284
+ capScope: "device",
23285
+ addonId: null,
23286
+ access: "view"
23287
+ },
23288
+ "sceneMonitor.recheckNow": {
23289
+ capName: "scene-monitor",
23290
+ capScope: "device",
23291
+ addonId: null,
23292
+ access: "create"
23293
+ },
23294
+ "sceneMonitor.updateScene": {
23295
+ capName: "scene-monitor",
23296
+ capScope: "device",
23297
+ addonId: null,
23298
+ access: "create"
23299
+ },
22269
23300
  "scriptRunner.run": {
22270
23301
  capName: "script-runner",
22271
23302
  capScope: "device",
@@ -23350,6 +24381,7 @@ Object.freeze({
23350
24381
  Object.freeze({
23351
24382
  "broker": "broker",
23352
24383
  "device-export": "device-export",
24384
+ "llm": "ai",
23353
24385
  "mesh-network": "mesh",
23354
24386
  "mqtt-broker": "broker",
23355
24387
  "network-access": "ingress",
@@ -23484,77 +24516,12 @@ function rankDecodeHwAccels(preferred, supportedMethods) {
23484
24516
  return candidates.sort((a, b) => decodeHwAccelRankIndex(a) - decodeHwAccelRankIndex(b));
23485
24517
  }
23486
24518
  //#endregion
23487
- //#region src/shm-orphan-purge.ts
23488
- /**
23489
- * Startup reclamation of orphaned shared-memory segments.
23490
- *
23491
- * A decoder writes frames into named `/dev/shm` segments and unlinks each one
23492
- * on graceful session teardown (`DecoderFrameRingSink.destroy`). When the
23493
- * decoder process dies *ungracefully* — SIGBUS, OOM-kill, or a SIGKILL during
23494
- * redeploy — that teardown never runs and the segment is orphaned: it stays in
23495
- * the tmpfs forever, since nothing else knows its name. Across many
23496
- * crashes/redeploys these accumulate until `/dev/shm` fills, at which point the
23497
- * next `mmap` write faults with an uncatchable SIGBUS and the decoder
23498
- * crash-loops into its circuit breaker (which is exactly the incident this
23499
- * guards against).
23500
- *
23501
- * The reclamation is safe *at process startup*: a freshly-booting decoder owns
23502
- * no live sessions, so every pre-existing segment with its prefix is by
23503
- * definition an orphan from a dead instance. `shm_unlink` only removes the
23504
- * name — any consumer still holding a mapping keeps reading valid memory until
23505
- * it closes (POSIX deferred reclaim + the ring seqlock), so unlinking is safe
23506
- * even if a stale reader is momentarily still attached.
23507
- *
23508
- * POSIX-only: segments surface as files under `/dev/shm` on Linux. On platforms
23509
- * without that directory (Windows, macOS) the scan finds nothing — no-op.
23510
- *
23511
- * NOTE: this lives inside the decoder addon (not `@camstack/shm-ring`) so it
23512
- * ships in the self-contained addon bundle via `camstack deploy`, reusing the
23513
- * already-deployed `unlinkSegment`; no host base-image rebuild required.
23514
- */
23515
- /** Default tmpfs directory where POSIX shared-memory segments appear on Linux. */
23516
- var DEFAULT_SHM_DIR = "/dev/shm";
23517
- /**
23518
- * Unlink every shared-memory segment whose name starts with `prefix`.
23519
- *
23520
- * Intended to run ONCE at decoder startup, before any session is created, to
23521
- * reclaim segments orphaned by a previously-crashed instance. A per-file unlink
23522
- * failure is swallowed so one stuck segment cannot block reclaiming the rest.
23523
- */
23524
- function purgeOrphanSegments(prefix, options = {}) {
23525
- const dir = options.dir ?? DEFAULT_SHM_DIR;
23526
- const unlink = options.unlink ?? _camstack_shm_ring.unlinkSegment;
23527
- let entries;
23528
- try {
23529
- entries = (0, node_fs.readdirSync)(dir);
23530
- } catch {
23531
- return {
23532
- scanned: 0,
23533
- removed: 0,
23534
- names: []
23535
- };
23536
- }
23537
- const names = [];
23538
- for (const name of entries) {
23539
- if (!name.startsWith(prefix)) continue;
23540
- try {
23541
- unlink(name);
23542
- names.push(name);
23543
- } catch {}
23544
- }
23545
- return {
23546
- scanned: entries.length,
23547
- removed: names.length,
23548
- names
23549
- };
23550
- }
23551
- //#endregion
23552
24519
  //#region src/shared/notifying-ring-buffer.ts
23553
24520
  /**
23554
24521
  * A {@link RingBuffer} that can notify a single blocked consumer the moment an
23555
- * item commits — the server side of the `pullFrames`/`pullHandles` long-poll.
24522
+ * item commits — the server side of the `pullFrames` long-poll.
23556
24523
  *
23557
- * The decoder's `onFrame`/`onFrameHandle` callback drives `push()`; a consumer
24524
+ * The decoder's `onFrame` callback drives `push()`; a consumer
23558
24525
  * that finds the ring momentarily empty calls {@link waitForItem} and is woken
23559
24526
  * on the very next `push()` (a real commit signal) rather than spinning at
23560
24527
  * ~1kHz on `setTimeout(…,1)`. If nothing commits it resolves after `waitMs`,
@@ -23892,19 +24859,7 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
23892
24859
  config;
23893
24860
  logger;
23894
24861
  frameCallbacks = /* @__PURE__ */ new Set();
23895
- handleCallbacks = /* @__PURE__ */ new Set();
23896
24862
  destroyed = false;
23897
- /**
23898
- * Frame delivery mode (see {@link DecoderFrameSink}). `'shm'` lazily
23899
- * constructs `frameRingSink` and routes every decoded frame through it.
23900
- */
23901
- frameSink;
23902
- /**
23903
- * The shared-memory ring writer for this stream. Created lazily on the
23904
- * first decoded frame in `'shm'` mode (the segment cannot be sized until
23905
- * the output geometry is known) and torn down in `destroy`.
23906
- */
23907
- frameRingSink = null;
23908
24863
  parser = null;
23909
24864
  codecCtx = null;
23910
24865
  scaler = null;
@@ -24025,8 +24980,6 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
24025
24980
  startTime = Date.now();
24026
24981
  hwaccelPref;
24027
24982
  hwaccelResolver;
24028
- /** Cluster node id stamped into every `FrameHandle` the `'shm'` sink emits. */
24029
- nodeId;
24030
24983
  /** The backend that actually initialised successfully — `'none'` = software fallback. */
24031
24984
  activeHwAccel = "none";
24032
24985
  hwDevice = null;
@@ -24058,35 +25011,6 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
24058
25011
  this.outputMode = NodeAvDecoderSession.resolveOutputMode(config.outputFormat);
24059
25012
  this.hwaccelPref = options?.hwaccel ?? "auto";
24060
25013
  this.hwaccelResolver = options?.hwaccelResolver ?? null;
24061
- this.frameSink = options?.frameSink ?? "callback";
24062
- this.nodeId = options?.nodeId ?? "local";
24063
- }
24064
- /**
24065
- * The shared-memory ring sink for this stream, or `null` before the first
24066
- * `'shm'`-mode frame lazily creates it. Exposed so the owning addon can
24067
- * surface ring stats via `decoder.getShmStats`.
24068
- */
24069
- get frameRingSinkOrNull() {
24070
- return this.frameRingSink;
24071
- }
24072
- /**
24073
- * Lazily build the shared-memory ring sink for this stream. The segment
24074
- * itself is still created lazily by the sink on its first `writeFrame`,
24075
- * once the decoded geometry is known.
24076
- */
24077
- ensureFrameRingSink() {
24078
- if (this.frameRingSink === null) {
24079
- const seedParts = [];
24080
- if (typeof this.config.deviceId === "number") seedParts.push(String(this.config.deviceId));
24081
- if (typeof this.config.tag === "string" && this.config.tag.length > 0) seedParts.push(this.config.tag);
24082
- const seed = seedParts.length > 0 ? seedParts.join(":") : "anon";
24083
- this.frameRingSink = new _camstack_shm_ring.DecoderFrameRingSink({
24084
- seed,
24085
- logger: this.logger,
24086
- nodeId: this.nodeId
24087
- });
24088
- }
24089
- return this.frameRingSink;
24090
25014
  }
24091
25015
  /**
24092
25016
  * Resolve the backend preference list and try each one against
@@ -24710,10 +25634,6 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
24710
25634
  }
24711
25635
  if (!this.dstFrame || !this.scaler) return;
24712
25636
  const decodeStart = performance.now();
24713
- if (this.frameSink === "shm" && this.outputMode !== "jpeg") {
24714
- this.scaleIntoRingSlot(frame, decodeStart);
24715
- return;
24716
- }
24717
25637
  try {
24718
25638
  this.dstFrame.makeWritable();
24719
25639
  this.scaler.scaleFrameSync(this.dstFrame, frame);
@@ -24758,100 +25678,6 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
24758
25678
  else this.emitRawFrame(rawBuf, "gray", decodeStart);
24759
25679
  }
24760
25680
  /**
24761
- * Scale a decoded frame **directly into a shared-memory ring slot** — the
24762
- * zero write-side copy path (Phase 5 / D9 Task 7c).
24763
- *
24764
- * `beginFrame` reserves the slot (its seqlock open / odd — readers skip it);
24765
- * `SoftwareScaleContext.scaleSync` (the low-level `sws_scale` mapping) writes
24766
- * the packed pixels straight into the slot buffer with `linesize = width ×
24767
- * bpp` — no linesize padding, so there is nothing to strip and nothing to
24768
- * memcpy; `commitFrame` writes the metadata, closes the seqlock and publishes
24769
- * the slot. The decoded source planes feed `scaleSync` as `srcSlice` +
24770
- * `srcStride` (`frame.data` / `frame.linesize`).
24771
- *
24772
- * Used only for raw output formats (rgb/bgr/gray). The jpeg path keeps the
24773
- * `dstFrame` + sharp encode route because sharp must consume an RGB buffer
24774
- * before the final (variable-length) jpeg bytes exist.
24775
- */
24776
- scaleIntoRingSlot(frame, decodeStart) {
24777
- if (!this.scaler) return;
24778
- const format = this.outputMode === "gray" ? "gray" : "rgb";
24779
- const channels = this.outputMode === "gray" ? 1 : 3;
24780
- const sink = this.ensureFrameRingSink();
24781
- const reserved = sink.beginFrame(this.outWidth, this.outHeight, format);
24782
- if (reserved === null) {
24783
- this.droppedFrames++;
24784
- return;
24785
- }
24786
- const srcPlanes = frame.data;
24787
- if (!srcPlanes || srcPlanes.length === 0) {
24788
- sink.abortFrame(reserved.slot);
24789
- this.droppedFrames++;
24790
- return;
24791
- }
24792
- const dstStride = this.outWidth * channels;
24793
- const needed = dstStride * this.outHeight;
24794
- if (reserved.buffer.length < needed) {
24795
- this.logger.warn("node-av: ring slot too small for scaled frame — dropping", { meta: {
24796
- needed,
24797
- slotBytes: reserved.buffer.length,
24798
- width: this.outWidth,
24799
- height: this.outHeight
24800
- } });
24801
- sink.abortFrame(reserved.slot);
24802
- this.droppedFrames++;
24803
- return;
24804
- }
24805
- try {
24806
- const srcStrides = Array.from(frame.linesize).slice(0, srcPlanes.length);
24807
- this.scaler.scaleSync(Array.from(srcPlanes), srcStrides, 0, frame.height, [reserved.buffer], [dstStride]);
24808
- } catch (err) {
24809
- this.logger.warn("node-av scale-into-slot error", { meta: { error: errMsg(err) } });
24810
- sink.abortFrame(reserved.slot);
24811
- this.droppedFrames++;
24812
- return;
24813
- }
24814
- const decodeMs = performance.now() - decodeStart;
24815
- this.totalDecodeTimeMs += decodeMs;
24816
- this.outputFrames++;
24817
- this.lastEmitTime = performance.now();
24818
- if (!this.firstFrameLogged) {
24819
- this.firstFrameLogged = true;
24820
- this.logger.info("node-av: scaled directly into shm ring slot", { meta: {
24821
- phase: "frame-debug",
24822
- width: this.outWidth,
24823
- height: this.outHeight,
24824
- dstStride,
24825
- format
24826
- } });
24827
- }
24828
- if (this.outputFrames === 1 || this.outputFrames % 500 === 0) this.logger.info("node-av frame emitted", { meta: {
24829
- frameNumber: this.outputFrames,
24830
- width: this.outWidth,
24831
- height: this.outHeight,
24832
- format,
24833
- decodeMs,
24834
- sink: "shm",
24835
- subs: this.handleCallbacks.size
24836
- } });
24837
- const handle = sink.commitFrame(reserved.slot, {
24838
- width: this.outWidth,
24839
- height: this.outHeight,
24840
- format,
24841
- pts: performance.now(),
24842
- byteLength: dstStride * this.outHeight
24843
- });
24844
- if (handle === null) {
24845
- this.droppedFrames++;
24846
- return;
24847
- }
24848
- const delivered = {
24849
- handle,
24850
- timestamp: Date.now()
24851
- };
24852
- for (const cb of this.handleCallbacks) cb(delivered);
24853
- }
24854
- /**
24855
25681
  * Extract packed pixel buffer from a decoded frame.
24856
25682
  * FFmpeg's av_frame_get_buffer() may pad each row to alignment (32/64 bytes).
24857
25683
  * Sharp and WASM consumers expect tightly-packed rows (stride = width * channels).
@@ -24910,13 +25736,8 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
24910
25736
  height: this.outHeight,
24911
25737
  format,
24912
25738
  decodeMs,
24913
- sink: this.frameSink,
24914
- subs: this.frameSink === "shm" ? this.handleCallbacks.size : this.frameCallbacks.size
25739
+ subs: this.frameCallbacks.size
24915
25740
  } });
24916
- if (this.frameSink === "shm") {
24917
- this.emitShmFrame(data, format);
24918
- return;
24919
- }
24920
25741
  const decodedFrame = {
24921
25742
  data,
24922
25743
  width: this.outWidth,
@@ -24926,47 +25747,12 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
24926
25747
  };
24927
25748
  for (const cb of this.frameCallbacks) cb(decodedFrame);
24928
25749
  }
24929
- /**
24930
- * Write a decoded frame into this stream's shared-memory ring and deliver
24931
- * the resulting `FrameHandle` to `onFrameHandle` subscribers. No pixel
24932
- * `Buffer` is handed to callbacks — consumers open the segment and read the
24933
- * pixels zero-copy via a `FrameRingReader`.
24934
- */
24935
- emitShmFrame(data, format) {
24936
- const handle = this.ensureFrameRingSink().writeFrame(data, {
24937
- width: this.outWidth,
24938
- height: this.outHeight,
24939
- format,
24940
- pts: performance.now(),
24941
- byteLength: data.byteLength
24942
- });
24943
- if (handle === null) {
24944
- this.droppedFrames++;
24945
- return;
24946
- }
24947
- const frame = {
24948
- handle,
24949
- timestamp: Date.now()
24950
- };
24951
- for (const cb of this.handleCallbacks) cb(frame);
24952
- }
24953
25750
  onFrame(callback) {
24954
25751
  this.frameCallbacks.add(callback);
24955
25752
  return () => {
24956
25753
  this.frameCallbacks.delete(callback);
24957
25754
  };
24958
25755
  }
24959
- /**
24960
- * Subscribe to shared-memory frame handles. Fires only when the session was
24961
- * created with `frameSink: 'shm'`; in the legacy `'callback'` mode no
24962
- * handles are produced and this subscription never fires.
24963
- */
24964
- onFrameHandle(callback) {
24965
- this.handleCallbacks.add(callback);
24966
- return () => {
24967
- this.handleCallbacks.delete(callback);
24968
- };
24969
- }
24970
25756
  updateConfig(update) {
24971
25757
  const prevFormat = this.config.outputFormat;
24972
25758
  this.config = {
@@ -25004,7 +25790,6 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
25004
25790
  if (this.destroyed) return;
25005
25791
  this.destroyed = true;
25006
25792
  this.frameCallbacks.clear();
25007
- this.handleCallbacks.clear();
25008
25793
  this.pullActive = false;
25009
25794
  if (this.pullRedialTimer) {
25010
25795
  clearTimeout(this.pullRedialTimer);
@@ -25020,8 +25805,6 @@ var NodeAvDecoderSession = class NodeAvDecoderSession {
25020
25805
  if (!this.pullHwContext.isDisposed) this.pullHwContext.dispose();
25021
25806
  this.pullHwContext = null;
25022
25807
  }
25023
- this.frameRingSink?.destroy();
25024
- this.frameRingSink = null;
25025
25808
  this.dstFrame?.[Symbol.dispose]?.();
25026
25809
  this.avFrame?.[Symbol.dispose]?.();
25027
25810
  this.avPacket?.[Symbol.dispose]?.();
@@ -25849,27 +26632,14 @@ var FRAME_BUFFER_CAPACITY = 32;
25849
26632
  var DecoderNodeAvAddon = class extends BaseAddon {
25850
26633
  /**
25851
26634
  * Sessions are stored as the concrete `NodeAvDecoderSession` (the only type
25852
- * this addon ever creates) so `getShmStats` can reach the per-session shm
25853
- * ring sink — `IDecoderSession` does not expose it.
26635
+ * this addon ever creates).
25854
26636
  */
25855
26637
  sessions = /* @__PURE__ */ new Map();
25856
- /** Pixel-frame buffers populated only for `frameSink: 'callback'` sessions. */
26638
+ /** Pixel-frame buffers drained by `pullFrames`. */
25857
26639
  frameBuffers = /* @__PURE__ */ new Map();
25858
- /** `FrameHandle` buffers — populated only for `frameSink: 'shm'` sessions. */
25859
- handleBuffers = /* @__PURE__ */ new Map();
25860
26640
  unsubscribers = /* @__PURE__ */ new Map();
25861
26641
  sessionMeta = /* @__PURE__ */ new Map();
25862
26642
  /**
25863
- * Per-shm-segment `FrameRingReader` cache backing `getFrame`. Opens each
25864
- * named segment once and reuses the reader for every later handle on it;
25865
- * built in `onInitialize` (it needs the scoped logger) and closed in
25866
- * `onShutdown`.
25867
- */
25868
- frameReaders = null;
25869
- /** Running `getFrame` hit/miss counters surfaced via `getShmStats`. */
25870
- getFrameHits = 0;
25871
- getFrameMisses = 0;
25872
- /**
25873
26643
  * node-av audio-codec provider — registered independently of the video
25874
26644
  * decoder backend gate whenever node-av loads on this node, so this single
25875
26645
  * addon provides both the `decoder` and `audio-codec` caps.
@@ -25934,12 +26704,6 @@ var DecoderNodeAvAddon = class extends BaseAddon {
25934
26704
  return registrations;
25935
26705
  }
25936
26706
  this.ctx.logger.info("node-av decoder addon initialized", { meta: { selectedBackend: backend } });
25937
- const purged = purgeOrphanSegments(_camstack_shm_ring.SEGMENT_NAME_PREFIX);
25938
- if (purged.removed > 0) this.ctx.logger.warn("node-av decoder: reclaimed orphaned shm segments at startup", { meta: {
25939
- removed: purged.removed,
25940
- scanned: purged.scanned
25941
- } });
25942
- this.frameReaders = new _camstack_shm_ring.FrameRingReaderCache(this.ctx.logger);
25943
26707
  if (!this.config.probedBestHwaccel) this.reprobeHwaccel().catch((err) => {
25944
26708
  this.ctx.logger.warn("nodeav: auto-reprobe hwaccel failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
25945
26709
  });
@@ -26006,11 +26770,11 @@ var DecoderNodeAvAddon = class extends BaseAddon {
26006
26770
  }
26007
26771
  /**
26008
26772
  * The cluster node id of this decoder — the Moleculer nodeID (`hub`,
26009
- * `dev-agent-0`, …), not the addon id. Stamped into session-owned
26010
- * `FrameHandle`s so a downstream consumer routes `getFrame` to the node
26011
- * that holds the shm ring. A hierarchical broker nodeID (`hub/...`) is
26012
- * collapsed to the cluster-visible parent; in-process boot is left as-is.
26013
- * Mirrors the resolution `PipelineRunnerAddon.onInitialize` performs.
26773
+ * `dev-agent-0`, …), not the addon id. Returned from `createSession` so the
26774
+ * caller can route session-scoped calls to the node that owns the session.
26775
+ * A hierarchical broker nodeID (`hub/...`) is collapsed to the
26776
+ * cluster-visible parent; in-process boot is left as-is. Mirrors the
26777
+ * resolution `PipelineRunnerAddon.onInitialize` performs.
26014
26778
  */
26015
26779
  resolveLocalNodeId() {
26016
26780
  const raw = this.ctx.kernel.localNodeId ?? this.ctx.id;
@@ -26019,15 +26783,12 @@ var DecoderNodeAvAddon = class extends BaseAddon {
26019
26783
  async createSession(config) {
26020
26784
  const sessionId = (0, node_crypto.randomUUID)();
26021
26785
  const hwaccel = await this.resolveHwAccelPref();
26022
- const { frameSink } = config;
26023
26786
  const nodeId = this.resolveLocalNodeId();
26024
26787
  const session = new NodeAvDecoderSession(config, this.ctx.logger, {
26025
26788
  hwaccel,
26026
- hwaccelResolver: this.ctx.kernel.hwaccel,
26027
- frameSink,
26028
- nodeId
26789
+ hwaccelResolver: this.ctx.kernel.hwaccel
26029
26790
  });
26030
- const unsub = frameSink === "shm" ? this.wireShmSink(sessionId, session) : this.wireCallbackSink(sessionId, session);
26791
+ const unsub = this.wireCallbackSink(sessionId, session);
26031
26792
  this.sessions.set(sessionId, session);
26032
26793
  this.unsubscribers.set(sessionId, unsub);
26033
26794
  this.sessionMeta.set(sessionId, {
@@ -26042,7 +26803,6 @@ var DecoderNodeAvAddon = class extends BaseAddon {
26042
26803
  sessionId,
26043
26804
  codec: config.codec,
26044
26805
  hwaccelPref: hwaccel,
26045
- frameSink,
26046
26806
  nodeId
26047
26807
  }
26048
26808
  });
@@ -26073,18 +26833,6 @@ var DecoderNodeAvAddon = class extends BaseAddon {
26073
26833
  ringBuffer.push(capFrame);
26074
26834
  });
26075
26835
  }
26076
- /**
26077
- * Subscribe a `'shm'` session's `FrameHandle`s into a per-session ring
26078
- * buffer drained by `pullHandles`. No pixel bytes cross the cap boundary
26079
- * — the broker opens the named segment and reads the pixels zero-copy.
26080
- */
26081
- wireShmSink(sessionId, session) {
26082
- const handleRing = new NotifyingRingBuffer(FRAME_BUFFER_CAPACITY);
26083
- this.handleBuffers.set(sessionId, handleRing);
26084
- return session.onFrameHandle((frame) => {
26085
- handleRing.push(frame.handle);
26086
- });
26087
- }
26088
26836
  async destroySession(input) {
26089
26837
  const { sessionId } = input;
26090
26838
  const session = this.sessions.get(sessionId);
@@ -26092,12 +26840,10 @@ var DecoderNodeAvAddon = class extends BaseAddon {
26092
26840
  const unsub = this.unsubscribers.get(sessionId);
26093
26841
  if (unsub) unsub();
26094
26842
  this.frameBuffers.get(sessionId)?.cancel();
26095
- this.handleBuffers.get(sessionId)?.cancel();
26096
26843
  const deviceId = this.sessionMeta.get(sessionId)?.deviceId;
26097
26844
  await session.destroy();
26098
26845
  this.sessions.delete(sessionId);
26099
26846
  this.frameBuffers.delete(sessionId);
26100
- this.handleBuffers.delete(sessionId);
26101
26847
  this.unsubscribers.delete(sessionId);
26102
26848
  this.sessionMeta.delete(sessionId);
26103
26849
  this.ctx.logger.info("node-av: destroyed session", {
@@ -26137,12 +26883,14 @@ var DecoderNodeAvAddon = class extends BaseAddon {
26137
26883
  if (ringBuffer.size === 0 && input.waitMs) await ringBuffer.waitForItem(input.waitMs);
26138
26884
  return ringBuffer.drain(input.maxCount);
26139
26885
  }
26140
- async pullHandles(input) {
26141
- if (!this.sessions.has(input.sessionId)) throw new Error(`decoder-nodeav: unknown sessionId ${input.sessionId}`);
26142
- const handleRing = this.handleBuffers.get(input.sessionId);
26143
- if (!handleRing) return [];
26144
- if (handleRing.size === 0 && input.waitMs) await handleRing.waitForItem(input.waitMs);
26145
- return handleRing.drain(input.maxCount);
26886
+ /**
26887
+ * DORMANT the shm `FrameHandle` frame plane is retired. Every session now
26888
+ * delivers pixels over the callback path drained by `pullFrames`, so no
26889
+ * handles are ever produced. Kept to satisfy the (still-defined) cap method;
26890
+ * always returns an empty list. Removal rides a later framework train.
26891
+ */
26892
+ async pullHandles() {
26893
+ return [];
26146
26894
  }
26147
26895
  async updateConfig(input) {
26148
26896
  const session = this.sessions.get(input.sessionId);
@@ -26155,50 +26903,22 @@ var DecoderNodeAvAddon = class extends BaseAddon {
26155
26903
  return session.getStats();
26156
26904
  }
26157
26905
  /**
26158
- * Read back the pixels a `FrameHandle` refers to from this node's shm ring
26159
- * (Phase 5 / D9 downstream access). Returns `null` when the slot was
26160
- * already recycled (latest-wins drop) or the segment could not be opened.
26161
- * The reader cache opens each named segment once and reuses the reader.
26162
- *
26163
- * The reader hands back a `Buffer` view over its **reusable scratch
26164
- * buffer**, only valid until the next `read` on the same reader; the
26165
- * cap caller may keep the frame across reads, so the pixels are copied
26166
- * into a fresh detached `ArrayBuffer` here. This matches the existing
26167
- * callback-path copy in `wireCallbackSink`.
26906
+ * DORMANT shm handle read-back is retired (the decoder no longer owns a
26907
+ * `/dev/shm` ring). Kept to satisfy the (still-defined) cap method; always
26908
+ * returns `null`. Full-frame retrieval by handle now flows through the
26909
+ * runner's RAM-backed `pipelineRunner.getNativeCrop`. Removal rides a later
26910
+ * framework train.
26168
26911
  */
26169
- async getFrame(input) {
26170
- const frame = this.frameReaders?.read(input.handle) ?? null;
26171
- if (!frame) {
26172
- this.getFrameMisses += 1;
26173
- return null;
26174
- }
26175
- this.getFrameHits += 1;
26176
- const arrayBuf = new ArrayBuffer(frame.data.byteLength);
26177
- new Uint8Array(arrayBuf).set(frame.data);
26178
- return {
26179
- data: new Uint8Array(arrayBuf),
26180
- width: frame.width,
26181
- height: frame.height,
26182
- format: frame.format,
26183
- timestamp: frame.timestamp
26184
- };
26912
+ async getFrame() {
26913
+ return null;
26185
26914
  }
26186
26915
  /**
26187
- * shm ring usage stats for a `frameSink: 'shm'` session — slot geometry,
26188
- * frames written, byte budget, plus this addon's running `getFrame`
26189
- * hit/miss counters. Returns `null` for an unknown session or one whose
26190
- * shm ring has not yet been armed by a first decoded frame.
26916
+ * DORMANT — no shm ring exists to report stats for. Kept to satisfy the
26917
+ * (still-defined) cap method; always returns `null`. Removal rides a later
26918
+ * framework train.
26191
26919
  */
26192
- async getShmStats(input) {
26193
- const stats = this.sessions.get(input.sessionId)?.frameRingSinkOrNull?.getShmStats() ?? null;
26194
- if (!stats) return null;
26195
- return {
26196
- sessionId: input.sessionId,
26197
- ...stats,
26198
- budgetMb: _camstack_shm_ring.RING_BUDGET_MB,
26199
- getFrameHits: this.getFrameHits,
26200
- getFrameMisses: this.getFrameMisses
26201
- };
26920
+ async getShmStats() {
26921
+ return null;
26202
26922
  }
26203
26923
  async onShutdown() {
26204
26924
  this.audioProvider?.stop();
@@ -26213,20 +26933,11 @@ var DecoderNodeAvAddon = class extends BaseAddon {
26213
26933
  await Promise.all(destroyPromises);
26214
26934
  this.sessions.clear();
26215
26935
  this.frameBuffers.clear();
26216
- this.handleBuffers.clear();
26217
26936
  this.unsubscribers.clear();
26218
26937
  this.sessionMeta.clear();
26219
- this.frameReaders?.close();
26220
- this.frameReaders = null;
26221
26938
  }
26222
26939
  };
26223
26940
  //#endregion
26224
- Object.defineProperty(exports, "DecoderFrameRingSink", {
26225
- enumerable: true,
26226
- get: function() {
26227
- return _camstack_shm_ring.DecoderFrameRingSink;
26228
- }
26229
- });
26230
26941
  exports.DecoderNodeAvAddon = DecoderNodeAvAddon;
26231
26942
  exports.NodeAvAudioCodecProvider = NodeAvAudioCodecProvider;
26232
26943
  exports.NodeAvAudioDecodeSession = NodeAvAudioDecodeSession;
@@ -26234,10 +26945,4 @@ exports.NodeAvAudioEncodeSession = NodeAvAudioEncodeSession;
26234
26945
  exports.NodeAvDecoderSession = NodeAvDecoderSession;
26235
26946
  exports.default = DecoderNodeAvAddon;
26236
26947
  exports.loadNodeAvRuntime = loadNodeAvRuntime;
26237
- Object.defineProperty(exports, "makeSegmentName", {
26238
- enumerable: true,
26239
- get: function() {
26240
- return _camstack_shm_ring.makeSegmentName;
26241
- }
26242
- });
26243
26948
  exports.peekNodeAvRuntime = peekNodeAvRuntime;