@camstack/addon-pipeline 1.2.70 → 1.2.72

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 (29) hide show
  1. package/dist/audio-analyzer/index.js +1 -1
  2. package/dist/audio-analyzer/index.mjs +1 -1
  3. package/dist/detection-pipeline/index.js +2 -2
  4. package/dist/detection-pipeline/index.mjs +2 -2
  5. package/dist/{dist-BPaa4_z6.mjs → dist-CNYUiN27.mjs} +158 -43
  6. package/dist/{dist-cR-pvD_z.js → dist-DwBdGpkx.js} +158 -43
  7. package/dist/{event-loop-stall-monitor-STRdnQWm.js → event-loop-stall-monitor-1o85rEbu.js} +1 -1
  8. package/dist/{event-loop-stall-monitor-B79REtL2.mjs → event-loop-stall-monitor-EvJwrf2f.mjs} +1 -1
  9. package/dist/motion-wasm/index.js +1 -1
  10. package/dist/motion-wasm/index.mjs +1 -1
  11. package/dist/pipeline-runner/index.js +95 -28
  12. package/dist/pipeline-runner/index.mjs +95 -28
  13. package/dist/recorder/index.js +365 -73
  14. package/dist/recorder/index.mjs +365 -73
  15. package/dist/session-decode/decode-worker-child.js +483 -52
  16. package/dist/session-decode/decode-worker-child.mjs +483 -52
  17. package/dist/stream-broker/_stub.js +660 -556
  18. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-B-HGBNad.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-BEBWZAKQ.mjs} +3 -3
  19. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DkUf57A0.mjs +26 -0
  20. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CExO0piw.mjs +26 -0
  21. package/dist/stream-broker/{hostInit-B12DHOv7.mjs → hostInit-aSIXKJAL.mjs} +3 -3
  22. package/dist/stream-broker/index.js +1 -1
  23. package/dist/stream-broker/index.mjs +1 -1
  24. package/dist/stream-broker/remoteEntry.js +1 -1
  25. package/dist/{worker-protocol-CBO8nwQj.mjs → worker-protocol-C_sGeitR.mjs} +26 -19
  26. package/dist/{worker-protocol-C7V1qIIA.js → worker-protocol-D0H-aG2_.js} +26 -19
  27. package/package.json +1 -1
  28. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D1CqbPrT.mjs +0 -26
  29. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-NjvjJWz-.mjs +0 -26
@@ -12056,7 +12056,14 @@ var cameraStreamsCapability = {
12056
12056
  low: string().optional()
12057
12057
  }),
12058
12058
  lastChangedAt: number()
12059
- })
12059
+ }),
12060
+ /**
12061
+ * Runtime-state durability: **session** — a restored `slotStatuses: streaming` for a camera that has been dark for two hours is a lie the UI renders as truth.
12062
+ *
12063
+ * See `RuntimeStateDurability`. Enforced by
12064
+ * `scripts/check-runtime-state-durability.ts`.
12065
+ */
12066
+ durability: "session"
12060
12067
  };
12061
12068
  /** Where a block runs. The operator chooses — a block driving a device on an
12062
12069
  * agent is the reason placement is not fixed to the hub. */
@@ -14431,7 +14438,23 @@ var NotificationActionSchema = object({
14431
14438
  * else — see `notification-center/action-token.ts` for what that does and
14432
14439
  * does not buy.
14433
14440
  */
14434
- destructive: boolean().optional()
14441
+ destructive: boolean().optional(),
14442
+ /**
14443
+ * How the tap should REACH the url.
14444
+ *
14445
+ * `navigate` (absent, and every button authored before this field) opens it:
14446
+ * the phone leaves the notification and shows whatever the callback returns.
14447
+ * That is right for a button whose answer the operator wants to read.
14448
+ *
14449
+ * `background` fires it as a POST and stays put. It exists for the buttons
14450
+ * whose whole point is not to interrupt — "silence this for 30 minutes" is
14451
+ * an answer to the notification, and being thrown into a browser tab to
14452
+ * confirm it costs more attention than the notification did. A backend that
14453
+ * cannot do a background call renders it as an ordinary link (the adapters
14454
+ * fall back rather than dropping the button), so this is a preference, never
14455
+ * a requirement.
14456
+ */
14457
+ mode: _enum(["navigate", "background"]).optional()
14435
14458
  });
14436
14459
  /**
14437
14460
  * The canonical notification. `body` is the only hard field (Apprise model).
@@ -15758,6 +15781,9 @@ var NcSystemEventConditionSchema = object({
15758
15781
  nodeIds: array(string().min(1)).min(1).optional(),
15759
15782
  packageNames: array(string().min(1)).min(1).optional()
15760
15783
  });
15784
+ /** Hard ceiling on a window (24h). A snooze that could not expire would be an
15785
+ * outage the operator asked for once and forgot. */
15786
+ var NC_SNOOZE_MAX_MINUTES = 1440;
15761
15787
  /** Weekly schedule — OR of windows; absence on the rule = always active. */
15762
15788
  var NcScheduleSchema = object({
15763
15789
  windows: array(object({
@@ -16134,15 +16160,15 @@ var NcConditionsSchema = object({
16134
16160
  * (an `immediate` rule naming an `audio-*` class, one notification per
16135
16161
  * classified sample) stays exactly as it was for rules that already use it.
16136
16162
  *
16137
- * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
16138
- * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
16139
- * (`camstack/src/data/notification-center.ts`, guarded by
16140
- * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
16163
+ * In {@link NC_CONDITION_CATALOG} since P2, and the ORDER it got there is the
16164
+ * rule rather than an accident: the viewer mirrors the descriptor enums BY
16165
+ * HAND (`camstack/src/data/notification-center.ts`, guarded by
16166
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor strips the
16141
16167
  * condition fields it does not know when a rule is saved from the phone.
16142
16168
  * Publishing an editor for a condition the app cannot round-trip is how an
16143
- * operator loses a rule's conditions by opening it — so the descriptor, the
16144
- * admin widget and the viewer mirror land together (P2 + P3), and only then
16145
- * does an audio rule become authorable.
16169
+ * operator loses a rule's conditions by opening it — so the viewer mirror
16170
+ * (P3, shipped) went FIRST, and the descriptor an editor renders from
16171
+ * follows here.
16146
16172
  */
16147
16173
  audio: NcAudioConditionSchema.optional()
16148
16174
  });
@@ -16378,6 +16404,30 @@ var NcRuleInputSchema = object({
16378
16404
  */
16379
16405
  snoozeAllowGlobal: boolean().optional(),
16380
16406
  /**
16407
+ * The snooze durations THIS rule's notification offers as buttons, in
16408
+ * minutes.
16409
+ *
16410
+ * Three states, and all three are distinct — which is exactly why this is
16411
+ * `.optional()` and never `.default()`. A Zod default does not run on the
16412
+ * addon cap path (three production failures in one day), so a schema default
16413
+ * would collapse the first two:
16414
+ *
16415
+ * | value | meaning |
16416
+ * | --- | --- |
16417
+ * | absent | the operator never said ⇒ {@link NC_DEFAULT_SNOOZE_MINUTES} |
16418
+ * | `[]` | **no snooze buttons on this rule** — the explicit override |
16419
+ * | a list | these choices, de-duplicated and sorted, at most four |
16420
+ *
16421
+ * `.max(4)` because the notifier's own action budget is small (ntfy allows
16422
+ * three buttons in total) and a rule that spent it all on snooze choices
16423
+ * would push its own tap-through actions off the notification.
16424
+ *
16425
+ * An empty list is NOT an alarm exemption: a rule the alarm is about, or
16426
+ * that arms the panel, is exempt automatically and cannot be silenced by a
16427
+ * window from anywhere (D133).
16428
+ */
16429
+ snoozeOptions: array(number().int().min(1).max(NC_SNOOZE_MAX_MINUTES)).max(4).optional(),
16430
+ /**
16381
16431
  * Devices this rule ACTUATES — arm the alarm, open a gate, turn on a light.
16382
16432
  *
16383
16433
  * This is what makes the rule set the alarm's trigger set without the alarm
@@ -16477,6 +16527,7 @@ var NcConditionDescriptorSchema = object({
16477
16527
  "device",
16478
16528
  "package",
16479
16529
  "occupancy",
16530
+ "audio",
16480
16531
  "system"
16481
16532
  ]),
16482
16533
  label: string(),
@@ -16495,6 +16546,7 @@ var NcConditionDescriptorSchema = object({
16495
16546
  "crossingSelect",
16496
16547
  "polygonDraw",
16497
16548
  "occupancy",
16549
+ "audio",
16498
16550
  "deviceState",
16499
16551
  "systemEvent"
16500
16552
  ]),
@@ -16646,7 +16698,20 @@ var NcSnoozeInputSchema = object({
16646
16698
  ruleId: string().optional(),
16647
16699
  /** Required when `scope: 'device'`. */
16648
16700
  deviceId: number().int().optional(),
16649
- durationMinutes: number().int().min(1).max(1440),
16701
+ /**
16702
+ * Narrow the window to these subject classes — "the cat, not the person".
16703
+ *
16704
+ * ORTHOGONAL to `scope`, deliberately, and absent means EVERY class: that is
16705
+ * what every window authored before this field meant, so no persisted row
16706
+ * changes meaning and no client has to learn anything to keep working.
16707
+ *
16708
+ * It is what makes the window's real key `(deviceId, classes[])` and lets it
16709
+ * cross rules (D133): the operator points at a camera and a kind of thing,
16710
+ * not at whichever of their four rules happened to produce the notification
16711
+ * they are dismissing.
16712
+ */
16713
+ classes: array(string().min(1)).min(1).optional(),
16714
+ durationMinutes: number().int().min(1).max(NC_SNOOZE_MAX_MINUTES),
16650
16715
  /**
16651
16716
  * Silence this for EVERY recipient, not just the caller. Permission is
16652
16717
  * checked server-side (the rule's `snoozeAllowGlobal`, or admin for the
@@ -16671,6 +16736,10 @@ var NcSnoozeSchema = object({
16671
16736
  scope: NcSnoozeScopeSchema,
16672
16737
  ruleId: string().optional(),
16673
16738
  deviceId: number().int().optional(),
16739
+ /** Subject classes this window covers. ABSENT = every class — see
16740
+ * {@link NcSnoozeInputSchema.shape.classes}. Lives in the JSON blob and has
16741
+ * no SQLite column: nothing queries a window by class. */
16742
+ classes: array(string().min(1)).min(1).optional(),
16674
16743
  startedAt: number(),
16675
16744
  /** Exclusive: at exactly this instant the snooze is over. Expiry is a
16676
16745
  * COMPARISON, not a job — no sweeper can leave the operator silenced. */
@@ -25860,13 +25929,24 @@ var recordingCapability = {
25860
25929
  /** Playback-speed multiplier for the render (1 = realtime). */
25861
25930
  var ExportSpeedSchema = number().min(.25).max(32);
25862
25931
  /**
25863
- * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
25932
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25933
+ *
25934
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25935
+ * derives these bounds from things that happened at a TIME (a track's
25936
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25937
+ * every segment present for the range, with each recording GAP removed. The
25938
+ * two agree only on a window that recorded without one interruption, and only
25939
+ * the render side knows the segments, so the translation lives there
25940
+ * (`export-dense-map.ts`, addon-pipeline).
25864
25941
  *
25865
- * Relative and not absolute epoch on purpose: the renderer's frame-select
25866
- * expression sees ffmpeg's `t`, which starts at 0 for the export's source
25867
- * playlist. Handing it absolute epochs would make every call site responsible
25868
- * for the same subtraction, and the one that forgot would emit a filter that
25869
- * selects nothing silently, as a uniform timelapse.
25942
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25943
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25944
+ * gap accumulated before it up to 6,607 s, well past EOF. Nothing matched,
25945
+ * the video was a uniform timelapse, and the log line reported the five ranges
25946
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25947
+ *
25948
+ * Relative and not absolute epoch, because an absolute epoch would make every
25949
+ * call site responsible for the same subtraction.
25870
25950
  */
25871
25951
  var ExportDenseRangeSchema = object({
25872
25952
  fromSec: number().nonnegative(),
@@ -32774,6 +32854,7 @@ Object.freeze({
32774
32854
  "network-access": "ingress",
32775
32855
  "smtp-provider": "email"
32776
32856
  });
32857
+ new Map(AUDIO_MACRO_LABELS.flatMap((macro) => macro.icon === void 0 ? [] : [[macro.id, macro.icon]]));
32777
32858
  new Set(["devices", "classes"]);
32778
32859
  /**
32779
32860
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
@@ -33152,10 +33233,11 @@ function slideInsideFrame(rect, frameWidth, frameHeight) {
33152
33233
  h
33153
33234
  };
33154
33235
  }
33155
- var NATIVE_LEASE_TTL_KEY = "nativeLeaseTtlMs";
33236
+ var NATIVE_LEASE_HOLD_KEY = "nativeLeaseHoldFrames";
33156
33237
  var NATIVE_LEASE_BUDGET_KEY = "nativeLeaseBudgetMb";
33157
33238
  var NATIVE_LEASE_ACTIVITY_KEY = "nativeLeaseActivityMs";
33158
33239
  var NATIVE_LEASE_ADMISSION_KEY = "nativeLeaseAdmission";
33240
+ var NATIVE_LEASE_TILE_BUDGET_KEY = "nativeTileBudgetMb";
33159
33241
  /**
33160
33242
  * WHICH delivered frames the decode worker retains a native copy of.
33161
33243
  *
@@ -33182,25 +33264,32 @@ var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33182
33264
  */
33183
33265
  var NativeLeaseSettingsSchema = object({
33184
33266
  /**
33185
- * How long a retained native frame is served before it counts as a miss.
33267
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33268
+ * detection result.
33269
+ *
33270
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33271
+ * a time window was never related to the event the pixels were waiting for.
33272
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33273
+ * — at which moment the runner cuts the subject tiles it actually wanted and
33274
+ * releases the frame. The bound exists only so a runner that stops answering
33275
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33186
33276
  *
33187
- * Must cover the FULL late-crop horizon: detection inference + the
33188
- * cross-process inference-result hop to hub post-analysis + tracking + the
33189
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33190
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33191
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33277
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
33278
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
33279
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
33280
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
33281
+ * `holdOverflow` on the metrics line is what says you need it.
33192
33282
  */
33193
- ttlMs: number().int().min(250).max(1e4),
33283
+ holdFrames: number().int().min(1).max(64),
33194
33284
  /**
33195
33285
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33196
33286
  *
33197
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33198
- * which one is actually binding before reasoning from that. At the shipped
33199
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33200
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33201
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33202
- * change that admits fewer frames buys retention WINDOW at constant RAM
33203
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
33287
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
33288
+ * is what decides how much is held, and the ceiling is the number above which
33289
+ * something is wrong. Before that it was the effective cap at 1024 MB with
33290
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
33291
+ * with the TTL expiring nothing, which is exactly the confusion the hold
33292
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33204
33293
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33205
33294
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33206
33295
  * to replace).
@@ -33226,22 +33315,45 @@ var NativeLeaseSettingsSchema = object({
33226
33315
  * there is the signal that some caller names frames outside the inference set
33227
33316
  * and that this must go back to `all`.
33228
33317
  */
33229
- admission: NativeLeaseAdmissionSchema
33318
+ admission: NativeLeaseAdmissionSchema,
33319
+ /**
33320
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
33321
+ * compressed native crops the worker cuts at the moment a frame's detection
33322
+ * result arrives, and keeps long after the frame itself is freed.
33323
+ *
33324
+ * This is the knob that replaced the old retention window, and it buys about
33325
+ * three orders of magnitude more of it: a tile is one subject at native
33326
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
33327
+ * the frame it was cut from. A frame on which nothing was detected costs
33328
+ * nothing at all, which is the real change — the old lease paid per FRAME and
33329
+ * was interrogated per SUBJECT.
33330
+ *
33331
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
33332
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
33333
+ * reproduce that.
33334
+ */
33335
+ tileBudgetMb: number().int().min(0).max(1024)
33230
33336
  });
33231
33337
  /**
33232
- * The values in force when the operator has set nothing — byte-for-byte the
33233
- * constants the decode worker shipped with as env-var defaults, so making these
33234
- * settings changed no behaviour on the day it landed.
33338
+ * The values in force when the operator has set nothing.
33339
+ *
33340
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
33341
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
33342
+ * in the same change that redefines it would make a regression and a retune
33343
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
33344
+ * live traffic.
33235
33345
  */
33236
33346
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33237
- ttlMs: 1200,
33347
+ holdFrames: 8,
33238
33348
  budgetMb: 1024,
33239
33349
  activityMs: 15e3,
33350
+ tileBudgetMb: 64,
33240
33351
  admission: "inferred"
33241
33352
  };
33242
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
33353
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33243
33354
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33244
33355
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
33356
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33245
33357
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33246
33358
  /**
33247
33359
  * Parse one knob, reporting `null` for absent, junk, out-of-bounds — AND for a
@@ -33251,7 +33363,7 @@ DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33251
33363
  * precedence being true and being a lie. `addon-settings.getGlobalSettings`
33252
33364
  * returns a HYDRATED payload, and `hydrateField` fills an unstored field with
33253
33365
  * the schema's own `default` (verified live on the hub: a cluster that has never
33254
- * opened the form still reports `nativeLeaseTtlMs = 1200`). A reader that took
33366
+ * opened the form still reports `nativeLeaseHoldFrames = 8`). A reader that took
33255
33367
  * that at face value would report all three knobs as "set" on every cluster on
33256
33368
  * the day this shipped, permanently retiring the `CAMSTACK_SESSION_NATIVE_LEASE_*`
33257
33369
  * emergency override that the precedence promises. There is no raw-store read on
@@ -33285,25 +33397,28 @@ function readAdmissionKnob(raw) {
33285
33397
  * {@link readKnob} for why the default counts as unset.
33286
33398
  */
33287
33399
  function readNativeLeaseOverride(config) {
33288
- const ttlMs = readKnob("ttlMs", config[NATIVE_LEASE_TTL_KEY]);
33400
+ const holdFrames = readKnob("holdFrames", config[NATIVE_LEASE_HOLD_KEY]);
33289
33401
  const budgetMb = readKnob("budgetMb", config[NATIVE_LEASE_BUDGET_KEY]);
33290
33402
  const activityMs = readKnob("activityMs", config[NATIVE_LEASE_ACTIVITY_KEY]);
33291
33403
  const admission = readAdmissionKnob(config[NATIVE_LEASE_ADMISSION_KEY]);
33404
+ const tileBudgetMb = readKnob("tileBudgetMb", config[NATIVE_LEASE_TILE_BUDGET_KEY]);
33292
33405
  return {
33293
- ...ttlMs === null ? {} : { ttlMs },
33406
+ ...holdFrames === null ? {} : { holdFrames },
33294
33407
  ...budgetMb === null ? {} : { budgetMb },
33295
33408
  ...activityMs === null ? {} : { activityMs },
33296
- ...admission === null ? {} : { admission }
33409
+ ...admission === null ? {} : { admission },
33410
+ ...tileBudgetMb === null ? {} : { tileBudgetMb }
33297
33411
  };
33298
33412
  }
33299
33413
  function isHydratedField(entry) {
33300
33414
  return typeof entry === "object" && entry !== null && "key" in entry;
33301
33415
  }
33302
33416
  var LEASE_KEYS = [
33303
- NATIVE_LEASE_TTL_KEY,
33417
+ NATIVE_LEASE_HOLD_KEY,
33304
33418
  NATIVE_LEASE_BUDGET_KEY,
33305
33419
  NATIVE_LEASE_ACTIVITY_KEY,
33306
- NATIVE_LEASE_ADMISSION_KEY
33420
+ NATIVE_LEASE_ADMISSION_KEY,
33421
+ NATIVE_LEASE_TILE_BUDGET_KEY
33307
33422
  ];
33308
33423
  /**
33309
33424
  * Extract the operator's lease overrides from an
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-cR-pvD_z.js");
1
+ const require_dist = require("./dist-DwBdGpkx.js");
2
2
  let node_perf_hooks = require("node:perf_hooks");
3
3
  //#region src/detection-pipeline/registry/model-catalogs.ts
4
4
  var HF_REPO = "camstack/camstack-models";
@@ -1,4 +1,4 @@
1
- import { a as COCO_TO_MACRO, i as COCO_80_LABELS, r as AUDIO_MACRO_LABELS, z as hfModelUrl } from "./dist-BPaa4_z6.mjs";
1
+ import { a as COCO_TO_MACRO, i as COCO_80_LABELS, r as AUDIO_MACRO_LABELS, z as hfModelUrl } from "./dist-CNYUiN27.mjs";
2
2
  import { PerformanceObserver } from "node:perf_hooks";
3
3
  //#region src/detection-pipeline/registry/model-catalogs.ts
4
4
  var HF_REPO = "camstack/camstack-models";
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_dist = require("../dist-cR-pvD_z.js");
5
+ const require_dist = require("../dist-DwBdGpkx.js");
6
6
  const require_lazy_sharp = require("../lazy-sharp-CcYuXtsa.js");
7
7
  let node_fs = require("node:fs");
8
8
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { H as motionDetectionCapability, R as evaluateZoneRules, ft as hydrateSchema, st as BaseAddon, ut as DeviceType } from "../dist-BPaa4_z6.mjs";
1
+ import { H as motionDetectionCapability, R as evaluateZoneRules, ft as hydrateSchema, st as BaseAddon, ut as DeviceType } from "../dist-CNYUiN27.mjs";
2
2
  import { t as getSharp } from "../lazy-sharp-B-mb8uWx.mjs";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { join } from "node:path";
@@ -3,9 +3,9 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../chunk-emK7D4bc.js");
6
- const require_dist = require("../dist-cR-pvD_z.js");
7
- const require_event_loop_stall_monitor = require("../event-loop-stall-monitor-STRdnQWm.js");
8
- const require_worker_protocol = require("../worker-protocol-C7V1qIIA.js");
6
+ const require_dist = require("../dist-DwBdGpkx.js");
7
+ const require_event_loop_stall_monitor = require("../event-loop-stall-monitor-1o85rEbu.js");
8
+ const require_worker_protocol = require("../worker-protocol-D0H-aG2_.js");
9
9
  const require_hub_hostname = require("../hub-hostname-DAJXlOgV.js");
10
10
  const require_lazy_sharp = require("../lazy-sharp-CcYuXtsa.js");
11
11
  const require_remote_restream = require("../remote-restream-BYbAsgUf.js");
@@ -17,28 +17,6 @@ let node_perf_hooks = require("node:perf_hooks");
17
17
  let node_os = require("node:os");
18
18
  node_os = require_chunk.__toESM(node_os);
19
19
  //#region src/session-decode/fork-decode-worker.ts
20
- /**
21
- * Real `fork` implementation for the session-decode coordinator — Epic C P1,
22
- * Task 4.
23
- *
24
- * Spawns the decode-worker child (`decode-worker-child.ts`, Task 2) as a
25
- * dedicated `child_process.fork` and adapts the returned `ChildProcess` to the
26
- * coordinator's minimal {@link ForkedChildLike} contract WITHOUT any cast —
27
- * an explicit forwarding wrapper, so a wider Node `ChildProcess` signature
28
- * never has to structurally satisfy the narrower interface.
29
- *
30
- * `serialization: 'advanced'` is MANDATORY: Node's default 'json' IPC
31
- * base64-serialises the `buffer` reply's `Uint8Array`, breaking the "raw
32
- * bytes, not base64" contract the coordinator + `worker-protocol.ts`'s
33
- * `value.bytes instanceof Uint8Array` guard both depend on. Advanced (V8
34
- * structured-clone) preserves the typed array on the wire.
35
- *
36
- * The child entry is resolved relative to THIS module's built location. Both
37
- * this module and `pipeline-runner/index.ts` bundle into the SAME entry
38
- * (`dist/pipeline-runner/index.js`, `manualChunks: () => null`), so
39
- * `import.meta.url` here is that file's URL and the sibling child lands at
40
- * `dist/session-decode/decode-worker-child.js` (its own vite build entry).
41
- */
42
20
  /** Absolute path to the built decode-worker child entry (a vite build entry). */
43
21
  var CHILD_ENTRY_PATH = (0, node_url.fileURLToPath)(new URL("../session-decode/decode-worker-child.js", require("url").pathToFileURL(__filename).href));
44
22
  /**
@@ -696,8 +674,24 @@ var SessionDecodeSession = class {
696
674
  });
697
675
  }
698
676
  /**
699
- * Prompt-release the worker's RAM native-frame lease for `frameId`. Fire and
700
- * forget (no reply): a lease also self-expires on its TTL, so a dropped
677
+ * The runner has this frame's detections: cut one native subject tile per box
678
+ * and END the hold on `frameId`. Fire and forget (no reply) so the encode can
679
+ * never delay the runner; a dropped message costs only the tiles.
680
+ *
681
+ * An EMPTY box list is still sent — it is how a frame that detected nothing
682
+ * releases its hold, and that is the common case.
683
+ */
684
+ cutTiles(frameId, bboxes) {
685
+ if (this.exited) return;
686
+ this.trySend({
687
+ kind: "cutTiles",
688
+ frameId,
689
+ bboxes
690
+ });
691
+ }
692
+ /**
693
+ * Prompt-release the worker's RAM native-frame hold for `frameId`. Fire and
694
+ * forget (no reply): the hold is also bounded by a frame count, so a dropped
701
695
  * release only defers reclaim. No-op once the worker has exited.
702
696
  */
703
697
  releaseLease(frameId) {
@@ -977,6 +971,7 @@ function buildFrameImage(session, reply) {
977
971
  return session.requestBuffer(reply.frameId, opts);
978
972
  },
979
973
  nativeCrop: (bbox, maxWidth) => session.requestNativeCrop(reply.frameId, bbox, maxWidth),
974
+ cutTiles: (bboxes) => session.cutTiles(reply.frameId, bboxes),
980
975
  releaseNativeLease: () => session.releaseLease(reply.frameId),
981
976
  markInferred: () => session.markInferred(reply.frameId),
982
977
  close: () => {
@@ -1117,6 +1112,7 @@ function startSessionDecodePump(deps) {
1117
1112
  const image = frame.image;
1118
1113
  const cropFn = image.nativeCrop;
1119
1114
  const nativeCrop = cropFn ? Object.assign((bbox, maxWidth) => cropFn(bbox, maxWidth), {
1115
+ cutTiles: (bboxes) => image.cutTiles?.(bboxes),
1120
1116
  release: () => image.releaseNativeLease?.(),
1121
1117
  markInferred: () => image.markInferred?.()
1122
1118
  }) : void 0;
@@ -2525,7 +2521,7 @@ var NATIVE_LEASE_OWNER_ADDON_ID = "pipeline-orchestrator";
2525
2521
  * old value.
2526
2522
  */
2527
2523
  function sameOverride(a, b) {
2528
- return a.ttlMs === b.ttlMs && a.budgetMb === b.budgetMb && a.activityMs === b.activityMs && a.admission === b.admission;
2524
+ return a.holdFrames === b.holdFrames && a.budgetMb === b.budgetMb && a.activityMs === b.activityMs && a.admission === b.admission && a.tileBudgetMb === b.tileBudgetMb;
2529
2525
  }
2530
2526
  /**
2531
2527
  * TTL-cached read of the cluster native-lease knobs.
@@ -3802,6 +3798,42 @@ async function runStatelessStep(deps, input) {
3802
3798
  details
3803
3799
  };
3804
3800
  }
3801
+ /**
3802
+ * Normalised boxes for the subjects worth a tile, highest confidence first,
3803
+ * capped.
3804
+ *
3805
+ * Returns an empty array for a frame with no usable detections — and the caller
3806
+ * still sends it: an empty `cutTiles` is how a frame that detected nothing ends
3807
+ * its hold, which is the majority of frames and the whole reason this design
3808
+ * costs less than the one it replaces.
3809
+ *
3810
+ * A degenerate or non-finite box is DROPPED rather than clamped: a zero-area
3811
+ * container serves nothing, and a NaN one would poison the worker's geometry.
3812
+ */
3813
+ function planTileCuts(detections, frame, maxSubjects = 4) {
3814
+ if (frame.width <= 0 || frame.height <= 0) return [];
3815
+ const ordered = [...detections.filter((d) => isUsable(d.bbox))].sort((a, b) => b.score - a.score);
3816
+ const out = [];
3817
+ for (const detection of ordered.slice(0, Math.max(0, maxSubjects))) {
3818
+ const { x, y, width, height } = detection.bbox;
3819
+ out.push({
3820
+ x: x / frame.width,
3821
+ y: y / frame.height,
3822
+ w: width / frame.width,
3823
+ h: height / frame.height
3824
+ });
3825
+ }
3826
+ return out;
3827
+ }
3828
+ function isUsable(bbox) {
3829
+ if (![
3830
+ bbox.x,
3831
+ bbox.y,
3832
+ bbox.width,
3833
+ bbox.height
3834
+ ].every((v) => Number.isFinite(v))) return false;
3835
+ return bbox.width > 0 && bbox.height > 0;
3836
+ }
3805
3837
  //#endregion
3806
3838
  //#region src/pipeline-runner/index.ts
3807
3839
  var DEFAULT_CONFIG = {
@@ -4290,6 +4322,7 @@ var PipelineRunnerAddon = class PipelineRunnerAddon extends require_dist.BaseAdd
4290
4322
  this.handleDetectionStreamChange(deviceId, action);
4291
4323
  });
4292
4324
  this.runner.onResult(async (deviceId, frame, result, _streamType, handle) => {
4325
+ this.cutSubjectTiles(deviceId, result, handle);
4293
4326
  this.emitInferenceResult(deviceId, frame, result, handle);
4294
4327
  const detectionCount = result.detections?.length ?? 0;
4295
4328
  this.runner?.noteDetectionResult(deviceId, detectionCount);
@@ -5111,6 +5144,40 @@ var PipelineRunnerAddon = class PipelineRunnerAddon extends require_dist.BaseAdd
5111
5144
  }, resolved.tier, input.encodeJpeg);
5112
5145
  }
5113
5146
  /**
5147
+ * Turn a finished frame into subject TILES and end its hold — the runner half
5148
+ * of R2 (`docs/design/2026-08-13-native-lease-two-tier-redesign.md`).
5149
+ *
5150
+ * Called from the result callback, which is the last instant at which the
5151
+ * frame's native pixels exist and its detections are known at the same time.
5152
+ * Every path through here ends the hold, including the one where there is
5153
+ * nothing to cut: a frame that detected nothing is the majority of frames and
5154
+ * releasing it promptly is most of the RAM this redesign gives back.
5155
+ *
5156
+ * Deliberately synchronous and unawaited. The worker replies to nothing, so
5157
+ * there is nothing to wait for, and a detection result must never be delayed
5158
+ * by an encode.
5159
+ */
5160
+ cutSubjectTiles(deviceId, result, handle) {
5161
+ if (!handle) return;
5162
+ const found = this.nativeCropRegistry.get(handle);
5163
+ if (!found) return;
5164
+ const boxes = planTileCuts(result.detections ?? [], {
5165
+ width: result.width,
5166
+ height: result.height
5167
+ });
5168
+ try {
5169
+ found.request.cutTiles(boxes);
5170
+ } catch (err) {
5171
+ this.ctx.logger.debug("subject tile cut could not be dispatched", {
5172
+ tags: { deviceId },
5173
+ meta: {
5174
+ subjects: boxes.length,
5175
+ error: err instanceof Error ? err.message : String(err)
5176
+ }
5177
+ });
5178
+ }
5179
+ }
5180
+ /**
5114
5181
  * The native-lease half of {@link getNativeCrop}, extracted so the DETAIL path
5115
5182
  * can keep the miss REASON the cap's `null` return has no room for. Both
5116
5183
  * callers share this one decision — a second copy of the tier arithmetic is