@camstack/addon-post-analysis 1.2.1 → 1.2.2

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.
@@ -11146,7 +11146,8 @@ var PipelineStepInputSchema = lazy(() => object({
11146
11146
  modelId: string().optional(),
11147
11147
  enabled: boolean().default(true),
11148
11148
  children: array(PipelineStepInputSchema).optional(),
11149
- settings: record(string(), unknown()).optional()
11149
+ settings: record(string(), unknown()).optional(),
11150
+ jumpDeviceKey: string().optional()
11150
11151
  }));
11151
11152
  var ModelSubstitutionSchema = object({
11152
11153
  addonId: string(),
@@ -11452,8 +11453,24 @@ var NativeCropBboxSchema = object({
11452
11453
  });
11453
11454
  /** Result of a best-effort native-resolution crop (`getNativeCrop`). */
11454
11455
  var NativeCropResultSchema = object({
11455
- /** Packed rgb (24-bit) pixels of the crop. */
11456
- bytes: _instanceof(Uint8Array),
11456
+ /**
11457
+ * Packed rgb (24-bit) pixels of the crop. Present on the DEFAULT (raw) path —
11458
+ * same-node (in-process / UDS) callers get zero-copy RGB and encode locally.
11459
+ * OMITTED when the caller requested `encodeJpeg` (the cross-node compressed
11460
+ * path below), where shipping raw RGB is both an invariant violation and, for
11461
+ * a native full frame (~26 MB at 4K), larger than Moleculer's 10 MB
11462
+ * `maxPacketSize` → the packet is dropped and the call 60s-times-out. That is
11463
+ * the cross-node native-media miss: `bytes` is replaced by `jpeg`.
11464
+ */
11465
+ bytes: _instanceof(Uint8Array).optional(),
11466
+ /**
11467
+ * Base64 JPEG of the crop — the COMPRESSED cross-node payload. The OWNING node
11468
+ * (which holds the native surface) encodes it in-process, so a native 4K frame
11469
+ * ships as ~0.5–2 MB (well under `maxPacketSize`) and NO raw pixels ever cross
11470
+ * a process boundary (CLAUDE.md invariant #21). Present ONLY when the request
11471
+ * set `encodeJpeg: true`; `bytes` is then absent.
11472
+ */
11473
+ jpeg: string().optional(),
11457
11474
  width: number().int().positive(),
11458
11475
  height: number().int().positive(),
11459
11476
  /**
@@ -11599,6 +11616,20 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
11599
11616
  hubHostnameOverride: string().optional()
11600
11617
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
11601
11618
  /**
11619
+ * One ENABLED inference device on the runner's node, as the step-tree
11620
+ * device-jump resolver sees it (phase 1). The orchestrator populates this
11621
+ * roster on the attach payload whenever the camera is elected onto a specific
11622
+ * `deviceKey` and the node has ≥2 enabled devices — it is the candidate set the
11623
+ * runner auto-jumps an enrichment step to when the elected device's format
11624
+ * cannot run that step's model. `weight`/`maxSessions` mirror the balancer's
11625
+ * per-device knobs so the auto choice is weighted-least-loaded.
11626
+ */
11627
+ var RunnerInferenceDeviceSchema = object({
11628
+ deviceKey: string(),
11629
+ weight: number().positive().default(1),
11630
+ maxSessions: number().int().positive().nullable().default(null)
11631
+ });
11632
+ /**
11602
11633
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
11603
11634
  * specific runner instance via `attachCamera`. Carries everything the
11604
11635
  * runner needs to subscribe to the local broker and execute inference.
@@ -11716,7 +11747,16 @@ var RunnerCameraConfigSchema = object({
11716
11747
  * omitted ⇒ the runner's default device. The engine itself stays node-local —
11717
11748
  * this only selects WHICH device pool of that node runs the session.
11718
11749
  */
11719
- deviceKey: string().optional()
11750
+ deviceKey: string().optional(),
11751
+ /**
11752
+ * Step-tree device-jump roster (phase 1): the node's ENABLED inference
11753
+ * devices, populated by the orchestrator ONLY when `deviceKey` is set and the
11754
+ * node has ≥2 enabled devices. The runner uses it to AUTO-jump an enrichment
11755
+ * step whose model has no build for the elected device's format onto another
11756
+ * enabled device of the SAME node (weighted-least-loaded). Absent/single-entry
11757
+ * ⇒ no jump possible; the step runs on `deviceKey`.
11758
+ */
11759
+ inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11720
11760
  });
11721
11761
  motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
11722
11762
  /**
@@ -11772,7 +11812,18 @@ var RunnerLocalMetricsSchema = object({
11772
11812
  method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mutation" }), method(object({ deviceId: number() }), object({ success: literal(true) }), { kind: "mutation" }), method(ReportMotionInputSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), RunnerLocalLoadSchema), method(_void(), RunnerLocalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(_void(), array(CameraMetricsWithDeviceIdSchema).readonly()), method(_void(), array(number()).readonly()), method(object({
11773
11813
  handle: FrameHandleSchema,
11774
11814
  bbox: NativeCropBboxSchema,
11775
- maxWidth: number().int().positive().optional()
11815
+ maxWidth: number().int().positive().optional(),
11816
+ /**
11817
+ * When `true`, the runner encodes the resolved crop to JPEG ON THE
11818
+ * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
11819
+ * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
11820
+ * agent) so the compressed payload fits Moleculer's `maxPacketSize` and
11821
+ * no raw pixels cross the process boundary. Same-node callers omit it
11822
+ * and keep the zero-copy raw `bytes` path. Additive + optional: a
11823
+ * pre-encode runner (version skew) ignores it and returns `bytes`, so
11824
+ * the caller falls back to encoding locally.
11825
+ */
11826
+ encodeJpeg: boolean().optional()
11776
11827
  }), NativeCropResultSchema.nullable()), method(object({
11777
11828
  deviceId: number(),
11778
11829
  frameHandle: FrameHandleSchema.optional(),
@@ -17147,7 +17198,16 @@ var PipelineTemplateSchema = object({
17147
17198
  });
17148
17199
  var DeviceStepConfigSchema = object({
17149
17200
  modelId: string().optional(),
17150
- settings: record(string(), unknown()).optional()
17201
+ settings: record(string(), unknown()).optional(),
17202
+ /**
17203
+ * Step-tree device jump (same-node, phase 1) — OPTIONAL manual override.
17204
+ * When set, this step runs on the named enabled device of the SAME node
17205
+ * (`<backend>:<device>`) instead of the camera's elected device, bypassing
17206
+ * the runtime AUTO-jump. The orchestrator rejects a `jumpDeviceKey` pointing
17207
+ * at a disabled/absent device on that node at save time. Absent ⇒ the runner
17208
+ * auto-jumps only when the effective device's format cannot run the step.
17209
+ */
17210
+ jumpDeviceKey: string().optional()
17151
17211
  });
17152
17212
  var AgentPipelineSettingsSchema = object({
17153
17213
  maxCameras: number().int().nonnegative().nullable().default(null),
@@ -11168,7 +11168,8 @@ var PipelineStepInputSchema = lazy(() => object({
11168
11168
  modelId: string().optional(),
11169
11169
  enabled: boolean().default(true),
11170
11170
  children: array(PipelineStepInputSchema).optional(),
11171
- settings: record(string(), unknown()).optional()
11171
+ settings: record(string(), unknown()).optional(),
11172
+ jumpDeviceKey: string().optional()
11172
11173
  }));
11173
11174
  var ModelSubstitutionSchema = object({
11174
11175
  addonId: string(),
@@ -11474,8 +11475,24 @@ var NativeCropBboxSchema = object({
11474
11475
  });
11475
11476
  /** Result of a best-effort native-resolution crop (`getNativeCrop`). */
11476
11477
  var NativeCropResultSchema = object({
11477
- /** Packed rgb (24-bit) pixels of the crop. */
11478
- bytes: _instanceof(Uint8Array),
11478
+ /**
11479
+ * Packed rgb (24-bit) pixels of the crop. Present on the DEFAULT (raw) path —
11480
+ * same-node (in-process / UDS) callers get zero-copy RGB and encode locally.
11481
+ * OMITTED when the caller requested `encodeJpeg` (the cross-node compressed
11482
+ * path below), where shipping raw RGB is both an invariant violation and, for
11483
+ * a native full frame (~26 MB at 4K), larger than Moleculer's 10 MB
11484
+ * `maxPacketSize` → the packet is dropped and the call 60s-times-out. That is
11485
+ * the cross-node native-media miss: `bytes` is replaced by `jpeg`.
11486
+ */
11487
+ bytes: _instanceof(Uint8Array).optional(),
11488
+ /**
11489
+ * Base64 JPEG of the crop — the COMPRESSED cross-node payload. The OWNING node
11490
+ * (which holds the native surface) encodes it in-process, so a native 4K frame
11491
+ * ships as ~0.5–2 MB (well under `maxPacketSize`) and NO raw pixels ever cross
11492
+ * a process boundary (CLAUDE.md invariant #21). Present ONLY when the request
11493
+ * set `encodeJpeg: true`; `bytes` is then absent.
11494
+ */
11495
+ jpeg: string().optional(),
11479
11496
  width: number().int().positive(),
11480
11497
  height: number().int().positive(),
11481
11498
  /**
@@ -11621,6 +11638,20 @@ var RunnerFrameSourceSchema = discriminatedUnion("kind", [object({ kind: literal
11621
11638
  hubHostnameOverride: string().optional()
11622
11639
  })]).describe("Per-camera frame-source mode for the runner (P2c)");
11623
11640
  /**
11641
+ * One ENABLED inference device on the runner's node, as the step-tree
11642
+ * device-jump resolver sees it (phase 1). The orchestrator populates this
11643
+ * roster on the attach payload whenever the camera is elected onto a specific
11644
+ * `deviceKey` and the node has ≥2 enabled devices — it is the candidate set the
11645
+ * runner auto-jumps an enrichment step to when the elected device's format
11646
+ * cannot run that step's model. `weight`/`maxSessions` mirror the balancer's
11647
+ * per-device knobs so the auto choice is weighted-least-loaded.
11648
+ */
11649
+ var RunnerInferenceDeviceSchema = object({
11650
+ deviceKey: string(),
11651
+ weight: number().positive().default(1),
11652
+ maxSessions: number().int().positive().nullable().default(null)
11653
+ });
11654
+ /**
11624
11655
  * Camera assignment payload sent by `addon-pipeline-orchestrator` to a
11625
11656
  * specific runner instance via `attachCamera`. Carries everything the
11626
11657
  * runner needs to subscribe to the local broker and execute inference.
@@ -11738,7 +11769,16 @@ var RunnerCameraConfigSchema = object({
11738
11769
  * omitted ⇒ the runner's default device. The engine itself stays node-local —
11739
11770
  * this only selects WHICH device pool of that node runs the session.
11740
11771
  */
11741
- deviceKey: string().optional()
11772
+ deviceKey: string().optional(),
11773
+ /**
11774
+ * Step-tree device-jump roster (phase 1): the node's ENABLED inference
11775
+ * devices, populated by the orchestrator ONLY when `deviceKey` is set and the
11776
+ * node has ≥2 enabled devices. The runner uses it to AUTO-jump an enrichment
11777
+ * step whose model has no build for the elected device's format onto another
11778
+ * enabled device of the SAME node (weighted-least-loaded). Absent/single-entry
11779
+ * ⇒ no jump possible; the step runs on `deviceKey`.
11780
+ */
11781
+ inferenceDevices: array(RunnerInferenceDeviceSchema).readonly().optional()
11742
11782
  });
11743
11783
  motionFpsField.min, motionFpsField.max, motionFpsField.step, motionFpsField.default, detectionFpsField.min, detectionFpsField.max, detectionFpsField.step, detectionFpsField.default, motionCooldownMsField.min, motionCooldownMsField.max, motionCooldownMsField.step, motionCooldownMsField.default, occupancyRecheckSecField.min, occupancyRecheckSecField.max, occupancyRecheckSecField.step, occupancyRecheckSecField.default, occupancyRecheckFramesField.min, occupancyRecheckFramesField.max, occupancyRecheckFramesField.step, occupancyRecheckFramesField.default;
11744
11784
  /**
@@ -11794,7 +11834,18 @@ var RunnerLocalMetricsSchema = object({
11794
11834
  method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mutation" }), method(object({ deviceId: number() }), object({ success: literal(true) }), { kind: "mutation" }), method(ReportMotionInputSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), RunnerLocalLoadSchema), method(_void(), RunnerLocalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(_void(), array(CameraMetricsWithDeviceIdSchema).readonly()), method(_void(), array(number()).readonly()), method(object({
11795
11835
  handle: FrameHandleSchema,
11796
11836
  bbox: NativeCropBboxSchema,
11797
- maxWidth: number().int().positive().optional()
11837
+ maxWidth: number().int().positive().optional(),
11838
+ /**
11839
+ * When `true`, the runner encodes the resolved crop to JPEG ON THE
11840
+ * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
11841
+ * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
11842
+ * agent) so the compressed payload fits Moleculer's `maxPacketSize` and
11843
+ * no raw pixels cross the process boundary. Same-node callers omit it
11844
+ * and keep the zero-copy raw `bytes` path. Additive + optional: a
11845
+ * pre-encode runner (version skew) ignores it and returns `bytes`, so
11846
+ * the caller falls back to encoding locally.
11847
+ */
11848
+ encodeJpeg: boolean().optional()
11798
11849
  }), NativeCropResultSchema.nullable()), method(object({
11799
11850
  deviceId: number(),
11800
11851
  frameHandle: FrameHandleSchema.optional(),
@@ -17169,7 +17220,16 @@ var PipelineTemplateSchema = object({
17169
17220
  });
17170
17221
  var DeviceStepConfigSchema = object({
17171
17222
  modelId: string().optional(),
17172
- settings: record(string(), unknown()).optional()
17223
+ settings: record(string(), unknown()).optional(),
17224
+ /**
17225
+ * Step-tree device jump (same-node, phase 1) — OPTIONAL manual override.
17226
+ * When set, this step runs on the named enabled device of the SAME node
17227
+ * (`<backend>:<device>`) instead of the camera's elected device, bypassing
17228
+ * the runtime AUTO-jump. The orchestrator rejects a `jumpDeviceKey` pointing
17229
+ * at a disabled/absent device on that node at save time. Absent ⇒ the runner
17230
+ * auto-jumps only when the effective device's format cannot run the step.
17231
+ */
17232
+ jumpDeviceKey: string().optional()
17173
17233
  });
17174
17234
  var AgentPipelineSettingsSchema = object({
17175
17235
  maxCameras: number().int().nonnegative().nullable().default(null),
@@ -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-DMg7kQfI.js");
5
+ const require_dist = require("../dist-DSP-cVM0.js");
6
6
  let node_fs = require("node:fs");
7
7
  let node_fs$1 = require_dist.__toESM(node_fs, 1);
8
8
  node_fs = require_dist.__toESM(node_fs);
@@ -1,4 +1,4 @@
1
- import { b as BaseAddon, f as hfModelUrl, u as embeddingEncoderCapability } from "../dist-D4KAS857.mjs";
1
+ import { b as BaseAddon, f as hfModelUrl, u as embeddingEncoderCapability } from "../dist-Bu9eXObI.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import * as fs from "node:fs";
4
4
  import * as path$1 from "node:path";
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-DMg7kQfI.js");
1
+ const require_dist = require("./dist-DSP-cVM0.js");
2
2
  let node_fs = require("node:fs");
3
3
  node_fs = require_dist.__toESM(node_fs, 1);
4
4
  let node_path = require("node:path");
@@ -3,7 +3,7 @@ import "./dist-CYZr2fwk.mjs";
3
3
  var e = {
4
4
  "@camstack/sdk": {
5
5
  name: "@camstack/sdk",
6
- version: "1.2.1",
6
+ version: "1.2.2",
7
7
  scope: ["default"],
8
8
  loaded: !1,
9
9
  from: "addon_pipeline_analytics_widgets",
@@ -18,7 +18,7 @@ var e = {
18
18
  },
19
19
  "@camstack/types": {
20
20
  name: "@camstack/types",
21
- version: "1.2.1",
21
+ version: "1.2.2",
22
22
  scope: ["default"],
23
23
  loaded: !1,
24
24
  from: "addon_pipeline_analytics_widgets",
@@ -33,7 +33,7 @@ var e = {
33
33
  },
34
34
  "@camstack/ui-library": {
35
35
  name: "@camstack/ui-library",
36
- version: "1.2.1",
36
+ version: "1.2.2",
37
37
  scope: ["default"],
38
38
  loaded: !1,
39
39
  from: "addon_pipeline_analytics_widgets",
@@ -36,7 +36,7 @@ async function r() {
36
36
  }
37
37
  },
38
38
  "@camstack/types": {
39
- version: "1.2.1",
39
+ version: "1.2.2",
40
40
  scope: "default",
41
41
  shareConfig: {
42
42
  singleton: !0,
@@ -45,7 +45,7 @@ async function r() {
45
45
  }
46
46
  },
47
47
  "@camstack/sdk": {
48
- version: "1.2.1",
48
+ version: "1.2.2",
49
49
  scope: "default",
50
50
  shareConfig: {
51
51
  singleton: !0,
@@ -81,7 +81,7 @@ async function r() {
81
81
  }
82
82
  },
83
83
  "@camstack/ui-library": {
84
- version: "1.2.1",
84
+ version: "1.2.2",
85
85
  scope: "default",
86
86
  shareConfig: {
87
87
  singleton: !0,
@@ -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-DMg7kQfI.js");
5
+ const require_dist = require("../dist-DSP-cVM0.js");
6
6
  let node_crypto = require("node:crypto");
7
7
  let sharp = require("sharp");
8
8
  sharp = require_dist.__toESM(sharp);
@@ -11608,6 +11608,21 @@ async function encodeRgbCropToJpeg(bytes, width, height) {
11608
11608
  channels: 3
11609
11609
  } }).jpeg({ quality: 90 }).toBuffer();
11610
11610
  }
11611
+ /**
11612
+ * Decode a base64 JPEG (the COMPRESSED cross-node crop the owning runner
11613
+ * returns) back into raw RGB (24-bit) pixels, so every downstream consumer
11614
+ * keeps its existing RGB contract regardless of whether the crop was fetched
11615
+ * same-node (raw) or cross-node (JPEG). The decode happens IN-PROCESS on the
11616
+ * post-processing node — no raw pixels ever cross a process boundary.
11617
+ */
11618
+ async function decodeJpegToRgb(base64Jpeg) {
11619
+ const { data, info } = await (0, sharp.default)(Buffer.from(base64Jpeg, "base64")).raw().toBuffer({ resolveWithObject: true });
11620
+ return {
11621
+ bytes: data,
11622
+ width: info.width,
11623
+ height: info.height
11624
+ };
11625
+ }
11611
11626
  //#endregion
11612
11627
  //#region src/pipeline-analytics/pipeline/event-child-crops.ts
11613
11628
  /**
@@ -12401,7 +12416,7 @@ var PipelineAnalyticsAddon = class extends require_dist.BaseAddon {
12401
12416
  let storage = this.ctx.kernel.storage;
12402
12417
  const mediaRoot = process.env.CAMSTACK_MEDIA_ROOT?.trim();
12403
12418
  if (mediaRoot) {
12404
- const { FilesystemStorageProvider } = await Promise.resolve().then(() => require("../node--uX7wh6R.js"));
12419
+ const { FilesystemStorageProvider } = await Promise.resolve().then(() => require("../node-DtSEvIXU.js"));
12405
12420
  storage = new FilesystemStorageProvider(mediaRoot);
12406
12421
  logger.info("pipeline-analytics: event media rooted at CAMSTACK_MEDIA_ROOT", { meta: { mediaRoot } });
12407
12422
  }
@@ -12548,6 +12563,23 @@ var PipelineAnalyticsAddon = class extends require_dist.BaseAddon {
12548
12563
  } });
12549
12564
  }
12550
12565
  const pipelineRunnerApi = api.pipelineRunner;
12566
+ const isRemoteHandle = (handle) => handle.nodeId !== ownNodeId;
12567
+ const cropReplyToRgb = async (reply) => {
12568
+ if (reply.jpeg !== void 0) {
12569
+ const rgb = await decodeJpegToRgb(reply.jpeg);
12570
+ return {
12571
+ bytes: Buffer.from(rgb.bytes),
12572
+ width: rgb.width,
12573
+ height: rgb.height
12574
+ };
12575
+ }
12576
+ if (reply.bytes !== void 0) return {
12577
+ bytes: Buffer.from(reply.bytes),
12578
+ width: reply.width,
12579
+ height: reply.height
12580
+ };
12581
+ return null;
12582
+ };
12551
12583
  const getRemoteFrame = async (handle) => {
12552
12584
  if (!pipelineRunnerApi?.getNativeCrop) return null;
12553
12585
  const full = await pipelineRunnerApi.getNativeCrop.query({
@@ -12558,13 +12590,16 @@ var PipelineAnalyticsAddon = class extends require_dist.BaseAddon {
12558
12590
  w: 1,
12559
12591
  h: 1
12560
12592
  },
12561
- maxWidth: handle.width
12593
+ maxWidth: handle.width,
12594
+ encodeJpeg: isRemoteHandle(handle)
12562
12595
  }, require_dist.nodePin(handle.nodeId));
12563
12596
  if (!full || full.width <= 0 || full.height <= 0) return null;
12597
+ const rgb = await cropReplyToRgb(full);
12598
+ if (!rgb) return null;
12564
12599
  return {
12565
- data: Buffer.from(full.bytes),
12566
- width: full.width,
12567
- height: full.height,
12600
+ data: rgb.bytes,
12601
+ width: rgb.width,
12602
+ height: rgb.height,
12568
12603
  format: "rgb",
12569
12604
  timestamp: 0
12570
12605
  };
@@ -12579,15 +12614,18 @@ var PipelineAnalyticsAddon = class extends require_dist.BaseAddon {
12579
12614
  w: 1,
12580
12615
  h: 1
12581
12616
  },
12582
- maxWidth
12617
+ maxWidth,
12618
+ encodeJpeg: isRemoteHandle(handle)
12583
12619
  }, require_dist.nodePin(handle.nodeId));
12584
12620
  if (!full || full.width <= 0 || full.height <= 0) return null;
12621
+ const rgb = await cropReplyToRgb(full);
12622
+ if (!rgb) return null;
12585
12623
  const tier = full.tier === "ram-fullframe" ? "ram-fullframe" : "native";
12586
12624
  return {
12587
12625
  frame: {
12588
- data: Buffer.from(full.bytes),
12589
- width: full.width,
12590
- height: full.height,
12626
+ data: rgb.bytes,
12627
+ width: rgb.width,
12628
+ height: rgb.height,
12591
12629
  format: "rgb",
12592
12630
  timestamp: 0
12593
12631
  },
@@ -12618,14 +12656,11 @@ var PipelineAnalyticsAddon = class extends require_dist.BaseAddon {
12618
12656
  const native = await pipelineRunnerApi.getNativeCrop.query({
12619
12657
  handle: frameHandle,
12620
12658
  bbox: paddedNorm,
12621
- ...maxWidth !== void 0 ? { maxWidth } : {}
12659
+ ...maxWidth !== void 0 ? { maxWidth } : {},
12660
+ encodeJpeg: isRemoteHandle(frameHandle)
12622
12661
  }, require_dist.nodePin(frameHandle.nodeId));
12623
12662
  if (!native || native.width <= 0 || native.height <= 0) return null;
12624
- return {
12625
- bytes: Buffer.from(native.bytes),
12626
- width: native.width,
12627
- height: native.height
12628
- };
12663
+ return await cropReplyToRgb(native);
12629
12664
  } catch (err) {
12630
12665
  cropMetricLogger.debug("native crop request failed — falling back", { meta: { error: require_dist.errMsg(err) } });
12631
12666
  return null;
@@ -1,4 +1,4 @@
1
- import { C as hydrateSchema, D as object, E as number, O as string, S as createEvent, T as boolean, _ as videoclipsCapability, a as OpsLogEntrySchema, b as BaseAddon, c as buildEventKindDescriptor, d as faceGalleryCapability, g as subKindsOf, h as plateGalleryCapability, i as MACRO_LABELS, k as EventCategory, l as cosineSimilarity, m as pipelineAnalyticsCapability, n as EVENT_KIND_BY_CAP, o as addonWidgetsSourceCapability, p as nodePin, r as EVENT_PAD_MS, s as audioMetricsCapability, t as DEFAULT_EVENT_COLOR, v as zoneAnalyticsCapability, w as array, x as DeviceType, y as errMsg } from "../dist-D4KAS857.mjs";
1
+ import { C as hydrateSchema, D as object, E as number, O as string, S as createEvent, T as boolean, _ as videoclipsCapability, a as OpsLogEntrySchema, b as BaseAddon, c as buildEventKindDescriptor, d as faceGalleryCapability, g as subKindsOf, h as plateGalleryCapability, i as MACRO_LABELS, k as EventCategory, l as cosineSimilarity, m as pipelineAnalyticsCapability, n as EVENT_KIND_BY_CAP, o as addonWidgetsSourceCapability, p as nodePin, r as EVENT_PAD_MS, s as audioMetricsCapability, t as DEFAULT_EVENT_COLOR, v as zoneAnalyticsCapability, w as array, x as DeviceType, y as errMsg } from "../dist-Bu9eXObI.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import sharp from "sharp";
4
4
  //#region src/pipeline-analytics/videoclips-provider.ts
@@ -11603,6 +11603,21 @@ async function encodeRgbCropToJpeg(bytes, width, height) {
11603
11603
  channels: 3
11604
11604
  } }).jpeg({ quality: 90 }).toBuffer();
11605
11605
  }
11606
+ /**
11607
+ * Decode a base64 JPEG (the COMPRESSED cross-node crop the owning runner
11608
+ * returns) back into raw RGB (24-bit) pixels, so every downstream consumer
11609
+ * keeps its existing RGB contract regardless of whether the crop was fetched
11610
+ * same-node (raw) or cross-node (JPEG). The decode happens IN-PROCESS on the
11611
+ * post-processing node — no raw pixels ever cross a process boundary.
11612
+ */
11613
+ async function decodeJpegToRgb(base64Jpeg) {
11614
+ const { data, info } = await sharp(Buffer.from(base64Jpeg, "base64")).raw().toBuffer({ resolveWithObject: true });
11615
+ return {
11616
+ bytes: data,
11617
+ width: info.width,
11618
+ height: info.height
11619
+ };
11620
+ }
11606
11621
  //#endregion
11607
11622
  //#region src/pipeline-analytics/pipeline/event-child-crops.ts
11608
11623
  /**
@@ -12543,6 +12558,23 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
12543
12558
  } });
12544
12559
  }
12545
12560
  const pipelineRunnerApi = api.pipelineRunner;
12561
+ const isRemoteHandle = (handle) => handle.nodeId !== ownNodeId;
12562
+ const cropReplyToRgb = async (reply) => {
12563
+ if (reply.jpeg !== void 0) {
12564
+ const rgb = await decodeJpegToRgb(reply.jpeg);
12565
+ return {
12566
+ bytes: Buffer.from(rgb.bytes),
12567
+ width: rgb.width,
12568
+ height: rgb.height
12569
+ };
12570
+ }
12571
+ if (reply.bytes !== void 0) return {
12572
+ bytes: Buffer.from(reply.bytes),
12573
+ width: reply.width,
12574
+ height: reply.height
12575
+ };
12576
+ return null;
12577
+ };
12546
12578
  const getRemoteFrame = async (handle) => {
12547
12579
  if (!pipelineRunnerApi?.getNativeCrop) return null;
12548
12580
  const full = await pipelineRunnerApi.getNativeCrop.query({
@@ -12553,13 +12585,16 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
12553
12585
  w: 1,
12554
12586
  h: 1
12555
12587
  },
12556
- maxWidth: handle.width
12588
+ maxWidth: handle.width,
12589
+ encodeJpeg: isRemoteHandle(handle)
12557
12590
  }, nodePin(handle.nodeId));
12558
12591
  if (!full || full.width <= 0 || full.height <= 0) return null;
12592
+ const rgb = await cropReplyToRgb(full);
12593
+ if (!rgb) return null;
12559
12594
  return {
12560
- data: Buffer.from(full.bytes),
12561
- width: full.width,
12562
- height: full.height,
12595
+ data: rgb.bytes,
12596
+ width: rgb.width,
12597
+ height: rgb.height,
12563
12598
  format: "rgb",
12564
12599
  timestamp: 0
12565
12600
  };
@@ -12574,15 +12609,18 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
12574
12609
  w: 1,
12575
12610
  h: 1
12576
12611
  },
12577
- maxWidth
12612
+ maxWidth,
12613
+ encodeJpeg: isRemoteHandle(handle)
12578
12614
  }, nodePin(handle.nodeId));
12579
12615
  if (!full || full.width <= 0 || full.height <= 0) return null;
12616
+ const rgb = await cropReplyToRgb(full);
12617
+ if (!rgb) return null;
12580
12618
  const tier = full.tier === "ram-fullframe" ? "ram-fullframe" : "native";
12581
12619
  return {
12582
12620
  frame: {
12583
- data: Buffer.from(full.bytes),
12584
- width: full.width,
12585
- height: full.height,
12621
+ data: rgb.bytes,
12622
+ width: rgb.width,
12623
+ height: rgb.height,
12586
12624
  format: "rgb",
12587
12625
  timestamp: 0
12588
12626
  },
@@ -12613,14 +12651,11 @@ var PipelineAnalyticsAddon = class extends BaseAddon {
12613
12651
  const native = await pipelineRunnerApi.getNativeCrop.query({
12614
12652
  handle: frameHandle,
12615
12653
  bbox: paddedNorm,
12616
- ...maxWidth !== void 0 ? { maxWidth } : {}
12654
+ ...maxWidth !== void 0 ? { maxWidth } : {},
12655
+ encodeJpeg: isRemoteHandle(frameHandle)
12617
12656
  }, nodePin(frameHandle.nodeId));
12618
12657
  if (!native || native.width <= 0 || native.height <= 0) return null;
12619
- return {
12620
- bytes: Buffer.from(native.bytes),
12621
- width: native.width,
12622
- height: native.height
12623
- };
12658
+ return await cropReplyToRgb(native);
12624
12659
  } catch (err) {
12625
12660
  cropMetricLogger.debug("native crop request failed — falling back", { meta: { error: errMsg(err) } });
12626
12661
  return null;
@@ -30,7 +30,7 @@ async function d(e) {
30
30
  }
31
31
  }
32
32
  async function f() {
33
- return l ||= d(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-ddQyIsuX.mjs")).catch((e) => {
33
+ return l ||= d(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-2w2j7Rm4.mjs")).catch((e) => {
34
34
  throw l = void 0, e;
35
35
  }), l;
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-post-analysis",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "CamStack Post-Analysis bundle — enrichment, embedding-encoder, pipeline-analytics. Multi-entry npm package shipping addons that consume pipeline output.",
5
5
  "keywords": [
6
6
  "camstack",