@camstack/addon-pipeline 1.2.107 → 1.2.115

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 (35) hide show
  1. package/dist/{addon-utils-Vv2dCqA2.js → addon-utils-C0ht2KPO.js} +51 -15
  2. package/dist/{addon-utils-A2S9D7pu.mjs → addon-utils-CgBCF-mE.mjs} +50 -14
  3. package/dist/audio-analyzer/index.js +3 -3
  4. package/dist/audio-analyzer/index.mjs +3 -3
  5. package/dist/detection-pipeline/index.js +170 -31
  6. package/dist/detection-pipeline/index.mjs +169 -30
  7. package/dist/{dist-L-1LMGQs.js → dist-BqIbYW1A.js} +130 -17
  8. package/dist/{dist-CkXAzTZ2.mjs → dist-DGQkkWc6.mjs} +130 -17
  9. package/dist/{event-loop-stall-monitor-fHkfgmlw.mjs → event-loop-stall-monitor-D5jK5v4Z.mjs} +223 -2
  10. package/dist/{event-loop-stall-monitor-DwAho7HD.js → event-loop-stall-monitor-ylMGpz48.js} +234 -1
  11. package/dist/{lazy-sharp-DfbyQxET.js → lazy-sharp-cOsy7l_P.js} +1 -1
  12. package/dist/motion-wasm/index.js +2 -2
  13. package/dist/motion-wasm/index.mjs +1 -1
  14. package/dist/pipeline-runner/index.js +915 -107
  15. package/dist/pipeline-runner/index.mjs +914 -106
  16. package/dist/{process-memory-CgrbLo3l.js → process-memory-45juuHpN.js} +1 -1
  17. package/dist/{process-memory-DlSOzuHP.mjs → process-memory-BtT7WfbJ.mjs} +1 -1
  18. package/dist/recorder/index.js +187 -47
  19. package/dist/recorder/index.mjs +187 -47
  20. package/dist/session-decode/decode-worker-child.js +30 -10
  21. package/dist/session-decode/decode-worker-child.mjs +29 -9
  22. package/dist/stream-broker/_stub.js +2 -2
  23. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-BeL4_jgH.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-C_SFFNGT.mjs} +3 -3
  24. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-B1LDFHY9.mjs +26 -0
  25. package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CmHtm5CX.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BAMyzCWw.mjs} +1 -1
  26. package/dist/stream-broker/{hostInit-BK9nzKAG.mjs → hostInit-CG28NvlV.mjs} +3 -3
  27. package/dist/stream-broker/index.js +279 -198
  28. package/dist/stream-broker/index.mjs +279 -198
  29. package/dist/stream-broker/remoteEntry.js +1 -1
  30. package/dist/{worker-protocol-GGnzfWu3.js → worker-protocol-CIrqGbpG.js} +6 -3
  31. package/dist/{worker-protocol-bEipQT9l.mjs → worker-protocol-DyocTIx_.mjs} +6 -3
  32. package/package.json +1 -1
  33. package/python/inference_pool.py +4 -1
  34. package/python/test_inference_pool_preprocess.py +87 -16
  35. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DjndFc5V.mjs +0 -26
@@ -1,9 +1,9 @@
1
1
  import { n as __require } from "../chunk-DnnnRqeS.mjs";
2
- import { $ as pickClusterStepSettings, At as nodePin, D as YAMNET_TO_MACRO, Et as hydrateSchema, G as evaluateZoneRules, Gt as union, Ht as object, I as defaultDeviceFor$1, It as array, Kt as EventCategory, Pt as sleep, Q as pickClusterStepModels, Tt as createEvent, V as detectionPipelineCapability, W as enumerateInferenceDevices, Wt as string, X as overlayClusterStepSettings, c as DEFAULT_CLUSTER_STEP_MODELS, ct as resolvePoolMemoryPolicy, ht as errMsg, jt as parseJsonUnknown, l as DEFAULT_CLUSTER_STEP_SETTINGS, nt as pipelineExecutorCapability, ot as resolveClusterStepModelId, p as DEVICE_BACKEND_TO_FORMAT, pt as supportedRuntimes$1, t as APPLE_SA_TO_MACRO, ut as runtimeDevices$1, x as PoolMemoryWatchdog, xt as BaseAddon } from "../dist-CkXAzTZ2.mjs";
3
- import { a as getDefaultModelForFormat, c as getStepDefinition, i as ALL_STEPS, l as resolveModelForFormat, n as startEventLoopStallMonitor, o as getDefaultModelForFormatFromDef, r as ALL_PIPELINE_STEPS, s as getStep, u as landmarkPrecisionVerdict } from "../event-loop-stall-monitor-fHkfgmlw.mjs";
2
+ import { $ as pickClusterStepSettings, At as nodePin, D as YAMNET_TO_MACRO, Et as hydrateSchema, G as evaluateZoneRules, Gt as union, Ht as object, I as defaultDeviceFor$1, It as array, Kt as EventCategory, Pt as sleep, Q as pickClusterStepModels, Tt as createEvent, V as detectionPipelineCapability, W as enumerateInferenceDevices, Wt as string, X as overlayClusterStepSettings, c as DEFAULT_CLUSTER_STEP_MODELS, ct as resolvePoolMemoryPolicy, ht as errMsg, jt as parseJsonUnknown, l as DEFAULT_CLUSTER_STEP_SETTINGS, nt as pipelineExecutorCapability, ot as resolveClusterStepModelId, p as DEVICE_BACKEND_TO_FORMAT, pt as supportedRuntimes$1, t as APPLE_SA_TO_MACRO, ut as runtimeDevices$1, x as PoolMemoryWatchdog, xt as BaseAddon } from "../dist-DGQkkWc6.mjs";
3
+ import { a as ALL_PIPELINE_STEPS, c as getDefaultModelForFormatFromDef, d as resolveModelForFormat, f as landmarkPrecisionVerdict, l as getStep, n as startEventLoopStallMonitor, o as ALL_STEPS, r as localFrameRegistry, s as getDefaultModelForFormat, u as getStepDefinition } from "../event-loop-stall-monitor-D5jK5v4Z.mjs";
4
4
  import { t as getSharp } from "../lazy-sharp-6oymT_yf.mjs";
5
- import { n as pickNodePlatformArch, t as readProcessMemory } from "../process-memory-DlSOzuHP.mjs";
6
- import { a as ensureModel, o as isModelDownloaded, r as deleteModelFromDisk } from "../addon-utils-A2S9D7pu.mjs";
5
+ import { n as pickNodePlatformArch, t as readProcessMemory } from "../process-memory-BtT7WfbJ.mjs";
6
+ import { a as ensureModel, o as isModelDownloaded, r as deleteModelFromDisk } from "../addon-utils-CgBCF-mE.mjs";
7
7
  import sharp from "sharp";
8
8
  import { spawn } from "node:child_process";
9
9
  import * as path$1 from "node:path";
@@ -257,7 +257,13 @@ var OBJECT_DETECTION_STEP_ID = "object-detection";
257
257
  * `null` → the caller substitutes the step's own `defaultModelId` (`yolo26n`).
258
258
  * INTEL NPU + iGPU default to OUR YOLOv9 (int8 @320): yolo26 does NOT compile on
259
259
  * the Intel NPU (arch incompat → 0 frames), while yolov9 runs on it (~298 fps
260
- * measured). Apple ANE stays on yolo26 until the CoreML yolov9 build lands.
260
+ * measured). Apple ANE uses the CoreML yolov9 @320 build.
261
+ *
262
+ * Do **not** promote these ids to `yolov9m-640` / `*-640`. The controlled
263
+ * evaluation recovered 0/3 misses at the current 0.50 threshold and failed the
264
+ * false-positive and capacity gates — see
265
+ * `docs/benchmarks/pipeline-frame-model-eval.md`. 640 remains an explicit
266
+ * operator pick, not a hardware-aware default.
261
267
  */
262
268
  var MODEL_BY_CLASS = {
263
269
  "apple-ane": "yolov9m-320",
@@ -1367,7 +1373,7 @@ function macroOfMinConfidenceKey(key) {
1367
1373
  */
1368
1374
  function reachableMacros(def, entry) {
1369
1375
  if (entry.labels.length === 0) return void 0;
1370
- const map = def.classMap;
1376
+ const map = entry.classMap ?? def.classMap;
1371
1377
  if (!map) return new Set(entry.labels.map((l) => l.id));
1372
1378
  if (map.preserveOriginal) return void 0;
1373
1379
  const macros = /* @__PURE__ */ new Set();
@@ -1387,7 +1393,7 @@ function reachableMacros(def, entry) {
1387
1393
  */
1388
1394
  function collectClassMapDropWarning(def, entry) {
1389
1395
  if (entry.labels.length === 0) return null;
1390
- const map = def.classMap;
1396
+ const map = entry.classMap ?? def.classMap;
1391
1397
  if (!map || map.preserveOriginal) return null;
1392
1398
  const unmapped = entry.labels.filter((l) => map.mapping[l.id] === void 0).map((l) => l.id);
1393
1399
  if (unmapped.length === 0) return null;
@@ -4163,7 +4169,7 @@ function applyChildOutput(parent, childStep, output, stepLatencyMs, ctx) {
4163
4169
  switch (output.kind) {
4164
4170
  case "detections":
4165
4171
  if (childStep.definition.slot === "refiner") {
4166
- const classMap = childStep.definition.classMap?.mapping;
4172
+ const classMap = childStep.effectiveClassMap?.mapping;
4167
4173
  const parentMacro = parent.macroClass;
4168
4174
  const best = output.detections.filter((d) => {
4169
4175
  if (d.mask === void 0) return false;
@@ -4503,6 +4509,29 @@ function reprojectCropZoneDetections(output, cropOrigin) {
4503
4509
  }))
4504
4510
  };
4505
4511
  }
4512
+ function reprojectViewDetections(output, geometry) {
4513
+ const mapPoint = (x, y) => ({
4514
+ x: geometry.sourceCrop.left + x / geometry.scale.x,
4515
+ y: geometry.sourceCrop.top + y / geometry.scale.y
4516
+ });
4517
+ return {
4518
+ kind: "detections",
4519
+ detections: output.detections.map((det) => {
4520
+ const origin = mapPoint(det.bbox[0], det.bbox[1]);
4521
+ const end = mapPoint(det.bbox[2], det.bbox[3]);
4522
+ return {
4523
+ ...det,
4524
+ bbox: [
4525
+ origin.x,
4526
+ origin.y,
4527
+ end.x,
4528
+ end.y
4529
+ ],
4530
+ ...det.landmarks ? { landmarks: det.landmarks.map((landmark) => mapPoint(landmark.x, landmark.y)) } : {}
4531
+ };
4532
+ })
4533
+ };
4534
+ }
4506
4535
  var PipelineExecutor = class {
4507
4536
  opts;
4508
4537
  /** Bounds the full-frame-guard drop log: first example per (device,
@@ -4564,7 +4593,7 @@ var PipelineExecutor = class {
4564
4593
  *
4565
4594
  * @returns FrameResult + optional trace
4566
4595
  */
4567
- async run(tree, rootInput, fullFrameJpegProvider, imageWidth, imageHeight, deviceId, runOpts, nativeCropProvider, cropZoneBbox) {
4596
+ async run(tree, rootInput, fullFrameJpegProvider, imageWidth, imageHeight, deviceId, runOpts, nativeCropProvider, cropZoneBbox, rootInputViewProvider) {
4568
4597
  const startMs = Date.now();
4569
4598
  const verbosity = runOpts?.traceVerbosity ?? "off";
4570
4599
  const traceBuilder = new ExecutionTraceBuilder(verbosity, deviceId, imageWidth, imageHeight, this.opts.engineRuntime);
@@ -4612,18 +4641,20 @@ var PipelineExecutor = class {
4612
4641
  };
4613
4642
  for (const rootStep of tree.roots) {
4614
4643
  if (debug) console.log(`[executor] rootStep=${rootStep.stepId} settings=${JSON.stringify(rootStep.settings ?? {})}`);
4615
- const cropPrep = rootStep.definition.extractMode === "crop-zone" && cropZoneBbox !== void 0 ? await this.prepareCropZoneInput(cropZoneBbox, fullFrameJpegProvider, imageWidth, imageHeight, deviceId) : null;
4644
+ const rootCrop = rootStep.definition.extractMode === "crop-zone" ? cropZoneBbox : void 0;
4645
+ const rootView = rootInputViewProvider ? await rootInputViewProvider(rootStep, rootCrop) : null;
4646
+ const cropPrep = !rootView && rootCrop !== void 0 ? await this.prepareCropZoneInput(rootCrop, fullFrameJpegProvider, imageWidth, imageHeight, deviceId) : null;
4616
4647
  const rootStart = Date.now();
4617
- const rawRootOutput = await this.executeStep(rootStep, cropPrep?.input ?? withInferenceDeviceId(rootInput, deviceId), cropPrep?.width ?? imageWidth, cropPrep?.height ?? imageHeight, "full-frame", void 0, void 0, traceBuilder, stepTimings, poolAgg, rootShed);
4648
+ const rawRootOutput = await this.executeStep(rootStep, rootView?.input ?? cropPrep?.input ?? withInferenceDeviceId(rootInput, deviceId), rootView?.width ?? cropPrep?.width ?? imageWidth, rootView?.height ?? cropPrep?.height ?? imageHeight, "full-frame", void 0, void 0, traceBuilder, stepTimings, poolAgg, rootShed);
4618
4649
  const rootMs = Date.now() - rootStart;
4619
4650
  if (rawRootOutput === null) continue;
4620
- const rootOutput = cropPrep && rawRootOutput.kind === "detections" ? reprojectCropZoneDetections(rawRootOutput, cropPrep.origin) : rawRootOutput;
4651
+ const rootOutput = rootView && rawRootOutput.kind === "detections" ? reprojectViewDetections(rawRootOutput, rootView.geometry) : cropPrep && rawRootOutput.kind === "detections" ? reprojectCropZoneDetections(rawRootOutput, cropPrep.origin) : rawRootOutput;
4621
4652
  if (rootOutput.kind !== "detections") {
4622
4653
  if (isEnrichmentOutput(rootOutput)) {
4623
4654
  const mutable = this.synthesizeRootDetection(rootOutput, rootStep, idGen, rootMs, imageWidth, imageHeight);
4624
4655
  applyChildOutput(mutable, rootStep, rootOutput, rootMs, ctx);
4625
4656
  try {
4626
- await this.executeChildren(rootStep.children, mutable, fullFrameJpegProvider, imageWidth, imageHeight, traceBuilder, stepTimings, ctx, poolAgg, runOpts?.plane, deviceId, nativeCropProvider);
4657
+ await this.executeChildren(rootStep.children, mutable, rootView?.jpegProvider ?? fullFrameJpegProvider, imageWidth, imageHeight, traceBuilder, stepTimings, ctx, poolAgg, runOpts?.plane, deviceId, nativeCropProvider);
4627
4658
  } catch (err) {
4628
4659
  this.opts.logger?.warn("Pipeline child execution failed — keeping parent detection", {
4629
4660
  tags: { deviceId },
@@ -4641,12 +4672,12 @@ var PipelineExecutor = class {
4641
4672
  }
4642
4673
  for (const det of rootOutput.detections) {
4643
4674
  const mutable = toMutableRootDetection(det, rootStep, idGen, rootMs);
4644
- if (rootStep.definition.classMap) {
4645
- const mapped = rootStep.definition.classMap.mapping[det.class];
4675
+ if (rootStep.effectiveClassMap) {
4676
+ const mapped = rootStep.effectiveClassMap.mapping[det.class];
4646
4677
  if (mapped) {
4647
4678
  mutable.originalClass = det.class;
4648
4679
  mutable.macroClass = mapped;
4649
- } else if (!rootStep.definition.classMap.preserveOriginal) {
4680
+ } else if (!rootStep.effectiveClassMap.preserveOriginal) {
4650
4681
  (discarded ??= []).push({
4651
4682
  bbox: [
4652
4683
  mutable.bbox[0],
@@ -4728,7 +4759,7 @@ var PipelineExecutor = class {
4728
4759
  }
4729
4760
  });
4730
4761
  try {
4731
- await this.executeChildren(rootStep.children, mutable, fullFrameJpegProvider, imageWidth, imageHeight, traceBuilder, stepTimings, ctx, poolAgg, runOpts?.plane, deviceId, nativeCropProvider);
4762
+ await this.executeChildren(rootStep.children, mutable, rootView?.jpegProvider ?? fullFrameJpegProvider, imageWidth, imageHeight, traceBuilder, stepTimings, ctx, poolAgg, runOpts?.plane, deviceId, nativeCropProvider);
4732
4763
  } catch (err) {
4733
4764
  this.opts.logger?.warn("Pipeline child execution failed — keeping parent detection", {
4734
4765
  tags: { deviceId },
@@ -5148,6 +5179,59 @@ function capitalize(s) {
5148
5179
  return s.charAt(0).toUpperCase() + s.slice(1);
5149
5180
  }
5150
5181
  //#endregion
5182
+ //#region src/session-decode/frame-view-payload.ts
5183
+ var FRAME_VIEW_PAYLOAD_POLICY = "jpeg";
5184
+ //#endregion
5185
+ //#region src/detection-pipeline/root-frame-view.ts
5186
+ /** Resolve the pre-padding content requested from the decode worker for one root. */
5187
+ function resolveRootFrameViewSpec(model, source, crop, format = FRAME_VIEW_PAYLOAD_POLICY) {
5188
+ const sourceWidth = crop?.width ?? source.width;
5189
+ const sourceHeight = crop?.height ?? source.height;
5190
+ if (model.preprocessMode !== "letterbox") return {
5191
+ ...crop ? { crop } : {},
5192
+ content: {
5193
+ width: model.inputSize.width,
5194
+ height: model.inputSize.height
5195
+ },
5196
+ fit: "stretch",
5197
+ format
5198
+ };
5199
+ const scale = Math.min(model.inputSize.width / sourceWidth, model.inputSize.height / sourceHeight);
5200
+ return {
5201
+ ...crop ? { crop } : {},
5202
+ content: {
5203
+ width: Math.max(1, Math.round(sourceWidth * scale)),
5204
+ height: Math.max(1, Math.round(sourceHeight * scale))
5205
+ },
5206
+ fit: "contain",
5207
+ format
5208
+ };
5209
+ }
5210
+ //#endregion
5211
+ //#region src/detection-pipeline/frame-ref-view-provider.ts
5212
+ var LocalFrameRefMissError = class extends Error {
5213
+ reason;
5214
+ constructor(reason) {
5215
+ super(`local frameRef miss: ${reason}`);
5216
+ this.reason = reason;
5217
+ this.name = "LocalFrameRefMissError";
5218
+ }
5219
+ };
5220
+ /** Bind one registry lease for all heterogeneous roots of a pipeline invocation. */
5221
+ function createRootFrameViewResolver(registry, ref) {
5222
+ const lease = registry.acquire(ref);
5223
+ if (!lease) throw new LocalFrameRefMissError(ref.registryId === registry.registryId ? "stale-ref" : "foreign-registry");
5224
+ const resolve = async (root, crop) => {
5225
+ const model = root.definition.models.find((candidate) => candidate.id === root.modelId);
5226
+ if (!model) throw new Error(`frame view model not found: ${root.modelId}`);
5227
+ const spec = resolveRootFrameViewSpec(model, ref, crop);
5228
+ const result = await lease.resolve(spec);
5229
+ if (result.kind === "miss") throw new LocalFrameRefMissError(result.reason);
5230
+ return result;
5231
+ };
5232
+ return Object.assign(resolve, { release: (reason) => lease.release(reason) });
5233
+ }
5234
+ //#endregion
5151
5235
  //#region src/detection-pipeline/pipeline/native-crop-compose.ts
5152
5236
  /** Clamp `v` into `[lo, hi]`. */
5153
5237
  function clamp(v, lo, hi) {
@@ -5187,23 +5271,32 @@ function composeCropRoiToFrameNorm(roi, cropFrameSpace, frameWidth, frameHeight)
5187
5271
  //#endregion
5188
5272
  //#region src/detection-pipeline/pipeline/tree-builder.ts
5189
5273
  /**
5274
+ * Effective class map for `(definition, modelId)` without writing back to the
5275
+ * shared StepDefinition. Custom models missing from `definition.models` are
5276
+ * resolved through the optional registry callback.
5277
+ */
5278
+ function resolveEffectiveClassMap(definition, modelId, resolveModel) {
5279
+ return (definition.models.find((model) => model.id === modelId) ?? resolveModel?.(definition.id, modelId))?.classMap ?? definition.classMap;
5280
+ }
5281
+ /**
5190
5282
  * Build an executable tree from user config.
5191
5283
  *
5192
5284
  * @param steps - User-configured pipeline steps (from PipelineDefaultStep[])
5193
5285
  * @param getEngine - Function that returns an IInferenceEngine for a step ID.
5194
5286
  * Throws if step not loaded.
5195
5287
  */
5196
- function buildExecutableTree(steps, getEngine) {
5197
- return { roots: steps.filter((s) => s.enabled).filter((s) => s.slot !== "audio-classifier").map((s) => buildNode(s, getEngine)) };
5288
+ function buildExecutableTree(steps, getEngine, resolveModel) {
5289
+ return { roots: steps.filter((s) => s.enabled).filter((s) => s.slot !== "audio-classifier").map((s) => buildNode(s, getEngine, resolveModel)) };
5198
5290
  }
5199
- function buildNode(step, getEngine) {
5291
+ function buildNode(step, getEngine, resolveModel) {
5200
5292
  const definition = getStepDefinition(step.addonId);
5201
5293
  const engine = getEngine(step.addonId);
5202
- const children = (step.children ?? []).filter((c) => c.enabled).map((c) => buildNode(c, getEngine));
5294
+ const children = (step.children ?? []).filter((c) => c.enabled).map((c) => buildNode(c, getEngine, resolveModel));
5203
5295
  const mergedSettings = {
5204
5296
  ...collectSchemaDefaults(step.addonId),
5205
5297
  ...step.settings
5206
5298
  };
5299
+ const effectiveClassMap = resolveEffectiveClassMap(definition, step.modelId, resolveModel);
5207
5300
  return {
5208
5301
  stepId: step.addonId,
5209
5302
  definition,
@@ -5212,7 +5305,8 @@ function buildNode(step, getEngine) {
5212
5305
  inputClasses: definition.inputClasses ?? [],
5213
5306
  enabled: step.enabled,
5214
5307
  children,
5215
- ...Object.keys(mergedSettings).length > 0 ? { settings: mergedSettings } : {}
5308
+ ...Object.keys(mergedSettings).length > 0 ? { settings: mergedSettings } : {},
5309
+ ...effectiveClassMap !== void 0 ? { effectiveClassMap } : {}
5216
5310
  };
5217
5311
  }
5218
5312
  /**
@@ -7091,17 +7185,30 @@ var DetectionPipelineProvider = class DetectionPipelineProvider {
7091
7185
  let jpegProvider;
7092
7186
  const sources = [
7093
7187
  input.frame ? "frame" : null,
7188
+ input.frameRef ? "frameRef" : null,
7094
7189
  input.frameHandle ? "frameHandle" : null,
7095
7190
  input.image ? "image" : null,
7096
7191
  input.imageBase64 ? "imageBase64" : null,
7097
7192
  input.referenceImage ? "referenceImage" : null
7098
7193
  ].filter((s) => s !== null);
7099
- if (sources.length === 0) throw new Error("runPipeline requires exactly one of: frame, frameHandle, image, imageBase64, referenceImage");
7194
+ if (sources.length === 0) throw new Error("runPipeline requires exactly one of: frame, frameRef, frameHandle, image, imageBase64, referenceImage");
7100
7195
  if (sources.length > 1) throw new Error(`runPipeline received conflicting image sources: ${sources.join(", ")}`);
7101
7196
  if (input.frameHandle) return this.emptyFrameHandleResult(input);
7102
7197
  const runtimeFrame = input.frame ?? void 0;
7198
+ const runtimeFrameRef = input.frameRef;
7103
7199
  const decodeT0 = performance.now();
7104
- if (runtimeFrame) {
7200
+ if (runtimeFrameRef) {
7201
+ imageWidth = runtimeFrameRef.width;
7202
+ imageHeight = runtimeFrameRef.height;
7203
+ rootInput = {
7204
+ kind: "jpeg",
7205
+ data: Buffer.alloc(0)
7206
+ };
7207
+ jpegProvider = async () => {
7208
+ throw new Error("frameRef root view was requested before model resolution");
7209
+ };
7210
+ emit(`FrameRef: ${imageWidth}×${imageHeight} (${runtimeFrameRef.format})`);
7211
+ } else if (runtimeFrame) {
7105
7212
  const frame = runtimeFrame;
7106
7213
  imageWidth = frame.width;
7107
7214
  imageHeight = frame.height;
@@ -7301,9 +7408,9 @@ var DetectionPipelineProvider = class DetectionPipelineProvider {
7301
7408
  emit(`All models loaded`);
7302
7409
  }
7303
7410
  emit("Running inference...");
7304
- const tree = buildExecutableTree(benchmarkSteps, (stepId) => dispatchFactory.getEngine(stepId));
7411
+ const tree = buildExecutableTree(benchmarkSteps, (stepId) => dispatchFactory.getEngine(stepId), this.customModelResolver);
7305
7412
  setupMs = performance.now() - wallT0 - decodeMs;
7306
- const isRuntime = Boolean(runtimeFrame);
7413
+ const isRuntime = Boolean(runtimeFrame || runtimeFrameRef);
7307
7414
  const effectiveDeviceId = input.deviceId ?? 0;
7308
7415
  const deviceOverrides = effectiveDeviceId > 0 ? await this.readDeviceStore(effectiveDeviceId) : {};
7309
7416
  const effectiveTree = Object.keys(deviceOverrides).length > 0 ? applyDeviceOverridesToTree(tree, "object-detection", deviceOverrides) : tree;
@@ -7314,10 +7421,42 @@ var DetectionPipelineProvider = class DetectionPipelineProvider {
7314
7421
  const proxy = this.deviceProxies.get(effectiveDeviceId);
7315
7422
  if (proxy) cropZoneBbox = resolvePackageCropBbox(proxy.state.zones.value?.zones ?? [], proxy.state.zoneRules.value?.package ?? [], imageWidth, imageHeight) ?? void 0;
7316
7423
  }
7317
- const { result, trace } = await executor.run(effectiveTree, rootInput, jpegProvider, imageWidth, imageHeight, effectiveDeviceId, {
7318
- traceVerbosity: isRuntime ? this.eventBus ? "summary" : "off" : "full",
7319
- plane: input.plane
7320
- }, nativeCropProvider, cropZoneBbox);
7424
+ let frameViewResolver;
7425
+ let rootInputViewProvider;
7426
+ if (runtimeFrameRef) {
7427
+ frameViewResolver = createRootFrameViewResolver(localFrameRegistry, runtimeFrameRef);
7428
+ rootInputViewProvider = async (root, crop) => {
7429
+ const view = await frameViewResolver(root, crop ? {
7430
+ left: crop[0],
7431
+ top: crop[1],
7432
+ width: crop[2] - crop[0],
7433
+ height: crop[3] - crop[1]
7434
+ } : void 0);
7435
+ const data = Buffer.from(view.data.buffer, view.data.byteOffset, view.data.byteLength);
7436
+ return {
7437
+ input: {
7438
+ kind: "jpeg",
7439
+ data
7440
+ },
7441
+ jpegProvider: async () => data,
7442
+ width: view.width,
7443
+ height: view.height,
7444
+ geometry: view.geometry
7445
+ };
7446
+ };
7447
+ }
7448
+ let executionSucceeded = false;
7449
+ let execution;
7450
+ try {
7451
+ execution = await executor.run(effectiveTree, rootInput, jpegProvider, imageWidth, imageHeight, effectiveDeviceId, {
7452
+ traceVerbosity: isRuntime ? this.eventBus ? "summary" : "off" : "full",
7453
+ plane: input.plane
7454
+ }, nativeCropProvider, cropZoneBbox, rootInputViewProvider);
7455
+ executionSucceeded = true;
7456
+ } finally {
7457
+ frameViewResolver?.release(executionSucceeded ? "success" : "error");
7458
+ }
7459
+ const { result, trace } = execution;
7321
7460
  if (isRuntime) {
7322
7461
  if (trace && this.eventBus) this.eventBus.emit(createEvent(EventCategory.PipelineTrace, {
7323
7462
  type: "device",
@@ -9081,6 +9081,15 @@ var LabelDefinitionSchema = object({
9081
9081
  description: string().optional(),
9082
9082
  icon: string().optional()
9083
9083
  });
9084
+ var ClassMapDefinitionSchema = object({
9085
+ mapping: record(string(), _enum([
9086
+ "person",
9087
+ "vehicle",
9088
+ "animal",
9089
+ "package"
9090
+ ])),
9091
+ preserveOriginal: boolean()
9092
+ });
9084
9093
  var MODEL_FORMATS = [
9085
9094
  "onnx",
9086
9095
  "coreml",
@@ -9259,7 +9268,13 @@ var ModelCatalogEntrySchema = object({
9259
9268
  * `id` stays the source of truth for resolution/download/persistence; grouping
9260
9269
  * is a presentation overlay resolved back to an `id`.
9261
9270
  */
9262
- group: ModelVariantGroupSchema.optional()
9271
+ group: ModelVariantGroupSchema.optional(),
9272
+ /**
9273
+ * Per-MODEL class map override. Absent ⇒ the step's `StepDefinition.classMap`
9274
+ * applies (Frigate / COCO public catalog). Set on a custom model whose raw
9275
+ * labels already ARE the CamStack macros (Scrypted identity map).
9276
+ */
9277
+ classMap: ClassMapDefinitionSchema.optional()
9263
9278
  });
9264
9279
  var ConvertTargetSchema = discriminatedUnion("format", [object({
9265
9280
  format: literal("openvino"),
@@ -9288,7 +9303,8 @@ var ModelConvertMetadataSchema = object({
9288
9303
  "ocr",
9289
9304
  "segmentation"
9290
9305
  ]),
9291
- faceAlignment: boolean().optional()
9306
+ faceAlignment: boolean().optional(),
9307
+ classMap: ClassMapDefinitionSchema.optional()
9292
9308
  });
9293
9309
  var ConvertResultSchema = object({
9294
9310
  entry: ModelCatalogEntrySchema,
@@ -19072,6 +19088,33 @@ var NativeCropRefSchema = object({
19072
19088
  h: number()
19073
19089
  })
19074
19090
  });
19091
+ object({
19092
+ crop: object({
19093
+ left: number(),
19094
+ top: number(),
19095
+ width: number().positive(),
19096
+ height: number().positive()
19097
+ }).optional(),
19098
+ content: object({
19099
+ width: number().int().positive(),
19100
+ height: number().int().positive()
19101
+ }),
19102
+ fit: _enum(["stretch", "contain"]),
19103
+ format: _enum([
19104
+ "rgb",
19105
+ "gray",
19106
+ "jpeg"
19107
+ ])
19108
+ });
19109
+ var FrameRefSchema = object({
19110
+ registryId: string().min(1),
19111
+ id: string().min(1),
19112
+ width: number().int().positive(),
19113
+ height: number().int().positive(),
19114
+ format: _enum(["rgb", "gray"]),
19115
+ timestamp: number(),
19116
+ capturedAt: number().optional()
19117
+ });
19075
19118
  var ModelFormatSchema$1 = _enum([
19076
19119
  "onnx",
19077
19120
  "coreml",
@@ -19392,7 +19435,7 @@ var pipelineExecutorCapability = {
19392
19435
  * legacy call shape used by existing benchmark code; once all
19393
19436
  * callers pass it explicitly we make it required.
19394
19437
  *
19395
- * Exactly one of `frame`, `frameHandle`, `imageBase64`,
19438
+ * Exactly one of `frame`, `frameRef`, `frameHandle`, `imageBase64`,
19396
19439
  * `referenceImage` must be provided:
19397
19440
  * - `frame`: runtime dispatch path (runner → decoded broker frame).
19398
19441
  * Carries the raw buffer, dimensions, and format; the executor
@@ -19414,6 +19457,12 @@ var pipelineExecutorCapability = {
19414
19457
  steps: array(PipelineStepInputSchema).min(1),
19415
19458
  frame: FrameInputSchema.optional(),
19416
19459
  /**
19460
+ * Process-local lazy frame. Valid only when caller and provider resolve
19461
+ * in the same execution-group process; split/cross-node callers use
19462
+ * `frame`/`image` inline compatibility instead.
19463
+ */
19464
+ frameRef: FrameRefSchema.optional(),
19465
+ /**
19417
19466
  * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
19418
19467
  * the decoded pixels live in. One more member of the one-of
19419
19468
  * frame/frameHandle/image/imageBase64/referenceImage group.
@@ -19723,7 +19772,10 @@ var NativeCropResultSchema = object({
19723
19772
  * Which source served this crop, so a quality-sensitive consumer (the native
19724
19773
  * `keyFrame`) can reject a degraded fallback:
19725
19774
  * - `native` — cut from the decode worker's retained NATIVE surface (the
19726
- * quality path).
19775
+ * quality path). A subject-tile serve is also native-resolution and stays
19776
+ * `native` here: the public enum cannot name `tile` without a breaking cap
19777
+ * change. Runner telemetry distinguishes lease vs tile via `source` on the
19778
+ * internal crop result (`nativeHits` vs `tileHits`).
19727
19779
  * - `ram-fullframe` — the native surface MISSED but the request was full-frame,
19728
19780
  * so the ≤640 RAM `RetainedFrameStore` served it (honest lower-res; legit for
19729
19781
  * the blank-frame guard / 640-snapshot resolve, NOT for the clean keyFrame).
@@ -20214,12 +20266,41 @@ var RunnerLocalLoadSchema = object({
20214
20266
  * legacy `OrchestratorMetricsSchema` shape so existing dashboards keep
20215
20267
  * working unchanged when they switch to reading from the runner cap.
20216
20268
  */
20269
+ var FrameLazyCountersSchema = object({
20270
+ framesDecoded: number(),
20271
+ framesAdmitted: number(),
20272
+ framesDroppedPixelFree: number(),
20273
+ viewsMaterialized: number(),
20274
+ viewsSkipped: number(),
20275
+ workerToRunnerBytes: number(),
20276
+ runnerToPoolRawBytes: number(),
20277
+ runnerToPoolJpegBytes: number(),
20278
+ onDemandFullFrameRequests: number(),
20279
+ onDemandCropRequests: number(),
20280
+ nativeHits: number(),
20281
+ nativeMisses: number(),
20282
+ tileHits: number(),
20283
+ tileMisses: number(),
20284
+ fallbackHits: number(),
20285
+ fallbackMisses: number(),
20286
+ retainedWritesAvoided: number(),
20287
+ residentRefs: number(),
20288
+ residentBytes: number(),
20289
+ releases: number(),
20290
+ evictions: number(),
20291
+ staleMisses: number()
20292
+ });
20293
+ var FrameLazyMetricsSchema = object({
20294
+ node: FrameLazyCountersSchema,
20295
+ cameras: array(FrameLazyCountersSchema.extend({ deviceId: number() }))
20296
+ });
20217
20297
  var RunnerLocalMetricsSchema = object({
20218
20298
  nodeId: string(),
20219
20299
  activeCameras: number(),
20220
20300
  throttledCameras: number(),
20221
20301
  avgInferenceTimeMs: number(),
20222
- queueDepth: number()
20302
+ queueDepth: number(),
20303
+ frameLazy: FrameLazyMetricsSchema.optional()
20223
20304
  });
20224
20305
  /**
20225
20306
  * Pipeline Runner capability — runtime detection workhorse.
@@ -21676,6 +21757,9 @@ method(_void(), ProviderInfoSchema), method(object({ config: record(string(), un
21676
21757
  location: StorageLocationSchema,
21677
21758
  relativePath: string()
21678
21759
  }), _void(), { kind: "mutation" }), method(object({ location: StorageLocationSchema }), number().nullable()), method(BeginUploadInputSchema, BeginUploadResultSchema, { kind: "mutation" }), method(WriteChunkInputSchema, _void(), { kind: "mutation" }), method(FinalizeUploadInputSchema, _void(), { kind: "mutation" }), method(AbortUploadInputSchema, _void(), { kind: "mutation" }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, { kind: "mutation" }), method(ReadChunkInputSchema, _instanceof(Uint8Array)), method(EndDownloadInputSchema, _void(), { kind: "mutation" });
21760
+ /** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
21761
+ var ProfileSettingsSchemaBridge = unknown().nullable();
21762
+ var ProfileSettingsBagSchema = record(string(), unknown());
21679
21763
  /**
21680
21764
  * A live terminal session hosted by the provider addon. Output and input do
21681
21765
  * NOT flow through the capability — they use the addon data plane
@@ -21710,7 +21794,9 @@ var TerminalProfileInfoSchema = object({
21710
21794
  executable: string().optional(),
21711
21795
  args: array(string()).readonly().optional(),
21712
21796
  cwd: string().optional(),
21713
- environment: array(string()).readonly().optional()
21797
+ environment: array(string()).readonly().optional(),
21798
+ /** ConfigUISchema for instance knobs, or null when the profile has none. */
21799
+ settingsSchema: ProfileSettingsSchemaBridge.optional()
21714
21800
  });
21715
21801
  /**
21716
21802
  * A durable operator-created Terminal instance. Profiles are templates; only
@@ -21727,7 +21813,8 @@ var TerminalInstanceInfoSchema = object({
21727
21813
  executable: string(),
21728
21814
  args: array(string()).readonly(),
21729
21815
  cwd: string(),
21730
- environment: array(string()).readonly()
21816
+ environment: array(string()).readonly(),
21817
+ profileSettings: ProfileSettingsBagSchema
21731
21818
  });
21732
21819
  var TerminalLegacyCameraSchema = object({
21733
21820
  stableId: string(),
@@ -21761,7 +21848,8 @@ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }),
21761
21848
  executable: string().max(1024).optional(),
21762
21849
  args: array(string().max(2048)).max(64).optional(),
21763
21850
  cwd: string().max(1024).optional(),
21764
- environment: array(string().max(4096)).max(64).optional()
21851
+ environment: array(string().max(4096)).max(64).optional(),
21852
+ profileSettings: ProfileSettingsBagSchema.optional()
21765
21853
  }), TerminalInstanceInfoSchema, {
21766
21854
  kind: "mutation",
21767
21855
  auth: "admin"
@@ -21771,7 +21859,8 @@ method(_void(), array(TerminalProfileInfoSchema).readonly(), { auth: "admin" }),
21771
21859
  executable: string().max(1024).optional(),
21772
21860
  args: array(string().max(2048)).max(64).optional(),
21773
21861
  cwd: string().max(1024).optional(),
21774
- environment: array(string().max(4096)).max(64).optional()
21862
+ environment: array(string().max(4096)).max(64).optional(),
21863
+ profileSettings: ProfileSettingsBagSchema.optional()
21775
21864
  }), TerminalInstanceInfoSchema, {
21776
21865
  kind: "mutation",
21777
21866
  auth: "admin"
@@ -24726,10 +24815,10 @@ DeviceType.LawnMower, method(object({ deviceId: number().int().nonnegative() }),
24726
24815
  *
24727
24816
  * • The SDK (mobile / web client) consumes `getConnectionEndpoints()`
24728
24817
  * to receive an ordered list of candidate base URLs it should race
24729
- * on connect — LAN IPv4 first (lowest latency when on same network),
24730
- * then public hostname (if a tunnel is up), then IPv6. The SDK can
24731
- * race them with short timeouts and stick with the winner for the
24732
- * session.
24818
+ * on connect — LAN IPv4 and stable LAN IPv6 first (lowest latency
24819
+ * when on the same network), then public hostname (if a tunnel is
24820
+ * up). The SDK can race them with short timeouts and stick with the
24821
+ * winner for the session.
24733
24822
  *
24734
24823
  * Why hub-only: agents are not directly addressable by the operator's
24735
24824
  * clients — they reverse-connect to the hub. Exposing their interfaces
@@ -24884,6 +24973,17 @@ var NotificationEndpointSchema = object({
24884
24973
  /** What the ranking currently resolves to (null when nothing is reachable). */
24885
24974
  resolved: string().nullable()
24886
24975
  });
24976
+ /**
24977
+ * The URLs the SDK / viewer should race for API access. `baseUrls` empty =
24978
+ * AUTO (every LAN IPv4 + the public tunnel). `resolved` is what that choice
24979
+ * currently expands to, so the UI can show the effective set either way.
24980
+ */
24981
+ var ViewerEndpointsSchema = object({
24982
+ /** The operator's explicit race set, or empty for AUTO. */
24983
+ baseUrls: array(string()).readonly(),
24984
+ /** What the ranking currently resolves to (may be empty if nothing is up). */
24985
+ resolved: array(string()).readonly()
24986
+ });
24887
24987
  var AllowedAddressesSchema = object({
24888
24988
  /**
24889
24989
  * Allowlist of interface addresses operators have explicitly opted
@@ -24915,17 +25015,18 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
24915
25015
  */
24916
25016
  port: number().int().min(1).max(65535).optional(),
24917
25017
  /** Include `http(s)://127.0.0.1:<port>` as the lowest-priority
24918
- * candidate. Default `true`. */
25018
+ * candidate. Default `false` — loopback is not a client route. */
24919
25019
  includeLoopback: boolean().optional(),
24920
- /** Skip IPv6 entries. Some legacy clients can't parse them.
24921
- * Default `false`. */
25020
+ /** Skip IPv6 entries. Default `false` the palette includes stable
25021
+ * LAN IPv6 (ICE/WebRTC uses dual-stack regardless). Pass `true` to
25022
+ * hide them. The viewer HTTP/WS race is `getViewerEndpoints`. */
24922
25023
  ipv4Only: boolean().optional(),
24923
25024
  /** Scheme to emit for LAN/loopback URLs. Default `'http'`.
24924
25025
  * Pass `'https'` when the caller is itself loaded over HTTPS
24925
25026
  * to avoid mixed-content blocks in the browser. The public
24926
25027
  * tunnel always emits `https://` regardless. */
24927
25028
  scheme: _enum(["http", "https"]).optional()
24928
- }), GetConnectionEndpointsResultSchema), method(_void(), NotificationEndpointSchema), method(object({ baseUrl: string().nullable() }), NotificationEndpointSchema, { kind: "mutation" }), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" }), method(_void(), TlsStatusSchema), method(object({ reason: string().optional() }), TlsStatusSchema, {
25029
+ }), GetConnectionEndpointsResultSchema), method(_void(), NotificationEndpointSchema), method(object({ baseUrl: string().nullable() }), NotificationEndpointSchema, { kind: "mutation" }), method(_void(), ViewerEndpointsSchema), method(object({ baseUrls: array(string()).readonly() }), ViewerEndpointsSchema, { kind: "mutation" }), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" }), method(_void(), TlsStatusSchema), method(object({ reason: string().optional() }), TlsStatusSchema, {
24929
25030
  kind: "mutation",
24930
25031
  auth: "admin"
24931
25032
  }), method(object({
@@ -30909,6 +31010,12 @@ Object.freeze({
30909
31010
  addonId: null,
30910
31011
  access: "view"
30911
31012
  },
31013
+ "localNetwork.getViewerEndpoints": {
31014
+ capName: "local-network",
31015
+ capScope: "system",
31016
+ addonId: null,
31017
+ access: "view"
31018
+ },
30912
31019
  "localNetwork.list": {
30913
31020
  capName: "local-network",
30914
31021
  capScope: "system",
@@ -30945,6 +31052,12 @@ Object.freeze({
30945
31052
  addonId: null,
30946
31053
  access: "create"
30947
31054
  },
31055
+ "localNetwork.setViewerEndpoints": {
31056
+ capName: "local-network",
31057
+ capScope: "system",
31058
+ addonId: null,
31059
+ access: "create"
31060
+ },
30948
31061
  "localNetwork.uploadCertificate": {
30949
31062
  capName: "local-network",
30950
31063
  capScope: "system",