@camstack/addon-model-studio 1.1.32 → 1.1.33

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 (19) hide show
  1. package/dist/{MotionZonesSettings-sZkppmGH.mjs → MotionZonesSettings-W4fQr3y3.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-C4IQ_tob.mjs → PrivacyMaskSettings-CtKzQjYD.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-Dv55kWSO.mjs → SceneMonitorEditor-CM3z_N4Q.mjs} +3 -3
  4. package/dist/_stub.js +3757 -3212
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-Cg1VXUiH.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-B0we2PiB.mjs} +4 -4
  6. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Boi8PUUw.mjs +26 -0
  7. package/dist/addon-model-studio.css +1 -1
  8. package/dist/{hostInit-DXmPMLUp.mjs → hostInit-B-Vb5-CN.mjs} +3 -3
  9. package/dist/model-studio.addon.js +736 -18
  10. package/dist/model-studio.addon.mjs +736 -18
  11. package/dist/{player-overlays-CS5IM4vB.mjs → player-overlays-CNkUzVZI.mjs} +1 -1
  12. package/dist/remoteEntry.js +1 -1
  13. package/dist/{responsive-CWtuZhDz.mjs → responsive-D-JIMJTX.mjs} +1 -1
  14. package/dist/{square-OXaWZ-Np.mjs → square-CBwtzgNH.mjs} +1 -1
  15. package/dist/{trash-2-BtfCrPnQ.mjs → trash-2-CiJaurwE.mjs} +1 -1
  16. package/dist/{use-device-snapshot-Bx87WhSL.mjs → use-device-snapshot-DpcJhtJX.mjs} +1 -1
  17. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-CnPUM5JZ.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-vDbogekh.mjs} +1 -1
  18. package/package.json +1 -1
  19. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Do4Kqwhj.mjs +0 -26
@@ -18814,6 +18814,12 @@ var CameraStatusSchema = object({
18814
18814
  /** Unix timestamp (ms) when this snapshot was composed server-side. */
18815
18815
  fetchedAt: number()
18816
18816
  });
18817
+ var InferenceDeviceExclusionReasonSchema = _enum([
18818
+ "disabled",
18819
+ "unavailable",
18820
+ "cannot-host-camera-root",
18821
+ "accelerator-preferred"
18822
+ ]);
18817
18823
  var NodeInferenceDeviceSchema = object({
18818
18824
  /** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
18819
18825
  key: string(),
@@ -18844,7 +18850,17 @@ var NodeInferenceDeviceSchema = object({
18844
18850
  * available per format; this is the stored selection that becomes the
18845
18851
  * default for EVERY camera landing on this accelerator.
18846
18852
  */
18847
- steps: record(string(), DeviceStepConfigSchema).optional()
18853
+ steps: record(string(), DeviceStepConfigSchema).optional(),
18854
+ /**
18855
+ * `null` when the device IS a camera-root candidate on this node; otherwise
18856
+ * the reason the dispatcher drops it. Computed by the SAME
18857
+ * `resolveInferenceDeviceEligibility` the dispatcher runs, so this view can
18858
+ * never disagree with the election — deriving it in the UI from
18859
+ * `enabled`/`available` would silently miss `cannot-host-camera-root` (needs
18860
+ * the node's model catalog) and `accelerator-preferred` (needs the node-wide
18861
+ * "an accelerator is serving" predicate).
18862
+ */
18863
+ exclusion: InferenceDeviceExclusionReasonSchema.nullable()
18848
18864
  });
18849
18865
  var NodeInferenceDevicesSchema = object({
18850
18866
  nodeId: string(),
@@ -22602,7 +22618,12 @@ var ListResultSchema = object({
22602
22618
  probedAt: number()
22603
22619
  });
22604
22620
  var PreferredSchema = LocalInterfaceSchema.nullable();
22605
- var GetConnectionEndpointsResultSchema = object({ endpoints: array(object({
22621
+ /**
22622
+ * Candidate base URL for the SDK to race on connect. Order matters —
22623
+ * the SDK should attempt these top-to-bottom with a short per-candidate
22624
+ * timeout (e.g. 1500ms) and cache the winner for the session.
22625
+ */
22626
+ var ConnectionEndpointSchema = object({
22606
22627
  /** Operator-facing label (e.g. "LAN — en0", "Public tunnel"). */
22607
22628
  label: string(),
22608
22629
  /** Fully-formed base URL with scheme + host + port. */
@@ -22645,7 +22666,42 @@ var GetConnectionEndpointsResultSchema = object({ endpoints: array(object({
22645
22666
  * ordering between polls.
22646
22667
  */
22647
22668
  priority: number()
22648
- })).readonly() });
22669
+ });
22670
+ /**
22671
+ * Where the advertised local port came from. Ordered most → least
22672
+ * authoritative, and the whole point of returning it: a client must be able to
22673
+ * tell a FACT about the hub's socket from an echo of its own guess.
22674
+ */
22675
+ var LocalPortSourceEnum = _enum([
22676
+ "server-config",
22677
+ "server-env",
22678
+ "caller-hint",
22679
+ "default"
22680
+ ]);
22681
+ /** The port every LAN/loopback `baseUrl` in the same result was built with. */
22682
+ var AdvertisedLocalPortSchema = object({
22683
+ port: number().int().min(1).max(65535),
22684
+ source: LocalPortSourceEnum
22685
+ });
22686
+ var GetConnectionEndpointsResultSchema = object({
22687
+ endpoints: array(ConnectionEndpointSchema).readonly(),
22688
+ /**
22689
+ * The port the hub built the LAN/loopback URLs with, and where that number
22690
+ * came from.
22691
+ *
22692
+ * Returned rather than merely applied, because "the URL is right" and "the
22693
+ * client can KNOW the URL is right" are different properties. A client that
22694
+ * only sees a corrected URL cannot distinguish a hub that fixed the port from
22695
+ * a hub that echoed the port the client sent, so it cannot decide whether to
22696
+ * race the candidate or discard it. With `source` it can: anything but
22697
+ * `caller-hint` is the hub's own socket.
22698
+ *
22699
+ * Absent on hubs predating this field — a client that finds it missing is
22700
+ * talking to an echoing hub and must degrade exactly as it does for
22701
+ * `caller-hint`.
22702
+ */
22703
+ localPort: AdvertisedLocalPortSchema
22704
+ });
22649
22705
  /**
22650
22706
  * The chosen outbound endpoint for notification artifacts. `baseUrl: null` =
22651
22707
  * AUTO (resolved from the candidate ranking at send time); `resolved` reports
@@ -22666,8 +22722,13 @@ var AllowedAddressesSchema = object({
22666
22722
  */
22667
22723
  addresses: array(string()).readonly() });
22668
22724
  method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
22669
- /** Local hub HTTP port to use in base URLs. */
22670
- port: number().int().min(1).max(65535),
22725
+ /**
22726
+ * LEGACY HINT — do not send from new code. Kept optional so clients
22727
+ * written against the echoing contract keep working; the hub uses it
22728
+ * only when it cannot read its own port, and says so via
22729
+ * `localPort.source === 'caller-hint'`.
22730
+ */
22731
+ port: number().int().min(1).max(65535).optional(),
22671
22732
  /** Include `http(s)://127.0.0.1:<port>` as the lowest-priority
22672
22733
  * candidate. Default `true`. */
22673
22734
  includeLoopback: boolean().optional(),
@@ -34167,6 +34228,383 @@ function removeCustomModel(list, modelId) {
34167
34228
  removed: next.length !== list.length
34168
34229
  };
34169
34230
  }
34231
+ var FRIGATE_PUBLIC_CATALOG = [{
34232
+ id: "frigate-mobiledet-edgetpu",
34233
+ label: "Frigate default — SSDLite MobileDet (EdgeTPU)",
34234
+ format: "tflite",
34235
+ url: "https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite",
34236
+ sizeMB: 5.4,
34237
+ inputSize: 320,
34238
+ postprocessor: "ssd",
34239
+ labels: [
34240
+ "person",
34241
+ "bicycle",
34242
+ "car",
34243
+ "motorcycle",
34244
+ "airplane",
34245
+ "bus",
34246
+ "train",
34247
+ "car",
34248
+ "boat",
34249
+ "traffic light",
34250
+ "fire hydrant",
34251
+ "street sign",
34252
+ "stop sign",
34253
+ "parking meter",
34254
+ "bench",
34255
+ "bird",
34256
+ "cat",
34257
+ "dog",
34258
+ "horse",
34259
+ "sheep",
34260
+ "cow",
34261
+ "elephant",
34262
+ "bear",
34263
+ "zebra",
34264
+ "giraffe",
34265
+ "hat",
34266
+ "backpack",
34267
+ "umbrella",
34268
+ "shoe",
34269
+ "eye glasses",
34270
+ "handbag",
34271
+ "tie",
34272
+ "suitcase",
34273
+ "frisbee",
34274
+ "skis",
34275
+ "snowboard",
34276
+ "sports ball",
34277
+ "kite",
34278
+ "baseball bat",
34279
+ "baseball glove",
34280
+ "skateboard",
34281
+ "surfboard",
34282
+ "tennis racket",
34283
+ "bottle",
34284
+ "plate",
34285
+ "wine glass",
34286
+ "cup",
34287
+ "fork",
34288
+ "knife",
34289
+ "spoon",
34290
+ "bowl",
34291
+ "banana",
34292
+ "apple",
34293
+ "sandwich",
34294
+ "orange",
34295
+ "broccoli",
34296
+ "carrot",
34297
+ "hot dog",
34298
+ "pizza",
34299
+ "donut",
34300
+ "cake",
34301
+ "chair",
34302
+ "couch",
34303
+ "potted plant",
34304
+ "bed",
34305
+ "mirror",
34306
+ "dining table",
34307
+ "window",
34308
+ "desk",
34309
+ "toilet",
34310
+ "door",
34311
+ "tv",
34312
+ "laptop",
34313
+ "mouse",
34314
+ "remote",
34315
+ "keyboard",
34316
+ "cell phone",
34317
+ "microwave",
34318
+ "oven",
34319
+ "toaster",
34320
+ "sink",
34321
+ "refrigerator",
34322
+ "blender",
34323
+ "book",
34324
+ "clock",
34325
+ "vase",
34326
+ "scissors",
34327
+ "teddy bear",
34328
+ "hair drier",
34329
+ "toothbrush",
34330
+ "hair brush"
34331
+ ],
34332
+ notes: "Frigate's default detection model (the one a stock Frigate + Coral install runs). EdgeTPU-compiled full-integer TFLite, 320×320, TFLite_Detection_PostProcess output → ssd decode. Requires a Coral (tflite format) node."
34333
+ }];
34334
+ /**
34335
+ * Build the registrable descriptor for a curated catalog entry. The URL is
34336
+ * the PUBLIC one — any node downloads it on demand; no Distribute needed.
34337
+ */
34338
+ function buildFrigateCatalogDescriptor(catalogId, overrides) {
34339
+ const cat = FRIGATE_PUBLIC_CATALOG.find((e) => e.id === catalogId);
34340
+ if (!cat) throw new Error(`Unknown Frigate catalog id "${catalogId}" — available: ${FRIGATE_PUBLIC_CATALOG.map((e) => e.id).join(", ")}`);
34341
+ return {
34342
+ stepId: "object-detection",
34343
+ entry: {
34344
+ id: overrides?.modelId?.trim() || cat.id,
34345
+ name: overrides?.name?.trim() || cat.label,
34346
+ description: `${cat.notes} Imported from the Frigate public catalog via Model Studio.`,
34347
+ formats: { [cat.format]: {
34348
+ url: cat.url,
34349
+ sizeMB: cat.sizeMB,
34350
+ runtimes: ["python"]
34351
+ } },
34352
+ inputSize: {
34353
+ width: cat.inputSize,
34354
+ height: cat.inputSize
34355
+ },
34356
+ labels: cat.labels.map((name) => ({
34357
+ id: name,
34358
+ name
34359
+ })),
34360
+ preprocessMode: "letterbox",
34361
+ ...cat.postprocessor !== void 0 ? { postprocessor: cat.postprocessor } : {}
34362
+ }
34363
+ };
34364
+ }
34365
+ //#endregion
34366
+ //#region src/frigate/plus-conversion.ts
34367
+ /** Converted formats ADD to the imported entry; identity fields (decode,
34368
+ * labels, description, preprocess) stay the import's. */
34369
+ function mergeConvertedFormats(base, converted) {
34370
+ return {
34371
+ ...base,
34372
+ formats: {
34373
+ ...base.formats,
34374
+ ...converted.formats
34375
+ }
34376
+ };
34377
+ }
34378
+ function targetOf(format) {
34379
+ return format === "openvino" ? {
34380
+ format,
34381
+ precisions: ["fp16"]
34382
+ } : { format };
34383
+ }
34384
+ /**
34385
+ * Convert the imported ONNX for each requested engine, one target at a time,
34386
+ * merging every success into the registered entry. Returns one outcome per
34387
+ * requested format — the caller surfaces them verbatim.
34388
+ */
34389
+ async function runPlusConversions(deps, args) {
34390
+ const outcomes = [];
34391
+ let current = args.entry;
34392
+ for (const format of args.targetFormats) {
34393
+ const targets = [targetOf(format)];
34394
+ try {
34395
+ const ranked = await deps.recommend({ targets });
34396
+ const best = ranked.find((r) => r.supported);
34397
+ if (!best) {
34398
+ const reason = ranked[0]?.reason ?? "no node can satisfy this target";
34399
+ outcomes.push({
34400
+ format,
34401
+ ok: false,
34402
+ error: reason
34403
+ });
34404
+ continue;
34405
+ }
34406
+ const sourceUrl = await deps.freshSourceUrl();
34407
+ const result = await deps.convert({
34408
+ sourceUrl,
34409
+ metadata: {
34410
+ id: current.id,
34411
+ name: current.name,
34412
+ labels: current.labels,
34413
+ inputSize: current.inputSize,
34414
+ preprocessMode: current.preprocessMode ?? "letterbox",
34415
+ outputFormat: "yolo"
34416
+ },
34417
+ targets
34418
+ }, best.nodeId);
34419
+ if (result.artifacts.length === 0) {
34420
+ outcomes.push({
34421
+ format,
34422
+ ok: false,
34423
+ nodeId: best.nodeId,
34424
+ error: "no validated artifacts"
34425
+ });
34426
+ continue;
34427
+ }
34428
+ current = mergeConvertedFormats(current, result.entry);
34429
+ await deps.upsertEntry(current);
34430
+ await deps.markAvailable(best.nodeId, current.id, result.artifacts);
34431
+ outcomes.push({
34432
+ format,
34433
+ ok: true,
34434
+ nodeId: best.nodeId
34435
+ });
34436
+ } catch (err) {
34437
+ outcomes.push({
34438
+ format,
34439
+ ok: false,
34440
+ error: err instanceof Error ? err.message : "conversion failed"
34441
+ });
34442
+ }
34443
+ }
34444
+ return outcomes;
34445
+ }
34446
+ //#endregion
34447
+ //#region src/frigate/frigate-plus.ts
34448
+ var PLUS_API_HOST = "https://api.frigate.video";
34449
+ var PLUS_KEY_RE = /^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}:[a-z0-9]{40}$/;
34450
+ function isValidPlusApiKey(key) {
34451
+ return PLUS_KEY_RE.test(key);
34452
+ }
34453
+ function isRecord(value) {
34454
+ return typeof value === "object" && value !== null && !Array.isArray(value);
34455
+ }
34456
+ /** Exchange the API key for an access token. The key never appears in errors. */
34457
+ async function fetchPlusAccessToken(fetchFn, apiKey) {
34458
+ if (!isValidPlusApiKey(apiKey)) throw new Error("Frigate+ API key is malformed — expected the \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:40-hex\" shape shown in your Frigate+ account settings");
34459
+ const [user, pass] = apiKey.split(":");
34460
+ const basic = Buffer.from(`${user}:${pass}`).toString("base64");
34461
+ const res = await fetchFn(`${PLUS_API_HOST}/v1/auth/token`, { headers: { authorization: `Basic ${basic}` } });
34462
+ if (!res.ok) throw new Error(`Frigate+ authentication failed (HTTP ${res.status}) — check the API key in the Model Studio addon settings`);
34463
+ const body = await res.json();
34464
+ const token = isRecord(body) && typeof body.accessToken === "string" ? body.accessToken : null;
34465
+ if (token === null) throw new Error("Frigate+ auth response carried no accessToken");
34466
+ return token;
34467
+ }
34468
+ async function plusGet(fetchFn, token, path) {
34469
+ const res = await fetchFn(`${PLUS_API_HOST}/v1/${path}`, { headers: { authorization: `Bearer ${token}` } });
34470
+ if (!res.ok) throw new Error(`Frigate+ request "${path}" failed (HTTP ${res.status}): ${await res.text()}`);
34471
+ return res.json();
34472
+ }
34473
+ /**
34474
+ * `verifiedCounts` has THREE real shapes and none may break the parse:
34475
+ * -1 → base model ("not applicable") ⇒ 0
34476
+ * { "11": 199 } → legacy custom (flat label→count)
34477
+ * { camera: { label: n, … }, … } → recent custom (per camera)
34478
+ */
34479
+ function verifiedImageCount(raw) {
34480
+ if (typeof raw === "number") return raw > 0 ? raw : 0;
34481
+ if (!isRecord(raw)) return 0;
34482
+ let total = 0;
34483
+ for (const value of Object.values(raw)) if (typeof value === "number") total += value > 0 ? value : 0;
34484
+ else if (isRecord(value)) {
34485
+ for (const inner of Object.values(value)) if (typeof inner === "number" && inner > 0) total += inner;
34486
+ }
34487
+ return total;
34488
+ }
34489
+ function toModelSummary(m) {
34490
+ if (typeof m.id !== "string") return null;
34491
+ return {
34492
+ id: m.id,
34493
+ name: typeof m.name === "string" ? m.name : m.id,
34494
+ type: typeof m.type === "string" ? m.type : "unknown",
34495
+ isBaseModel: m.isBaseModel === true,
34496
+ baseModel: typeof m.baseModel === "string" ? m.baseModel : "",
34497
+ supportedDetectors: Array.isArray(m.supportedDetectors) ? m.supportedDetectors.filter((d) => typeof d === "string") : [],
34498
+ trainDate: typeof m.trainDate === "string" ? m.trainDate : "",
34499
+ ...typeof m.hailoDevice === "string" ? { hailoDevice: m.hailoDevice } : {},
34500
+ verifiedImages: verifiedImageCount(m.verifiedCounts),
34501
+ ...typeof m.width === "number" ? { width: m.width } : {},
34502
+ ...typeof m.height === "number" ? { height: m.height } : {}
34503
+ };
34504
+ }
34505
+ /** Parse a raw `/v1/model/list` body (`{list:[…]}`, or a bare array). */
34506
+ function toPlusModelSummaries(raw) {
34507
+ return (Array.isArray(raw) ? raw : isRecord(raw) && Array.isArray(raw.list) ? raw.list : []).filter(isRecord).map(toModelSummary).filter((m) => m !== null);
34508
+ }
34509
+ /**
34510
+ * EVERYTHING the account has access to — base AND custom models. The real
34511
+ * response wraps the array: `{ "list": [...] }` (a bare array is tolerated
34512
+ * for forward compatibility).
34513
+ */
34514
+ async function listPlusModels(fetchFn, apiKey) {
34515
+ return toPlusModelSummaries(await plusGet(fetchFn, await fetchPlusAccessToken(fetchFn, apiKey), "model/list"));
34516
+ }
34517
+ function toModelInfo(raw, modelId) {
34518
+ if (!isRecord(raw)) throw new Error("Frigate+ model info: unexpected response shape");
34519
+ const labelMap = {};
34520
+ if (isRecord(raw.labelMap)) {
34521
+ for (const [k, v] of Object.entries(raw.labelMap)) if (typeof v === "string") labelMap[k] = v;
34522
+ }
34523
+ return {
34524
+ id: typeof raw.id === "string" ? raw.id : modelId,
34525
+ type: typeof raw.type === "string" ? raw.type : "unknown",
34526
+ width: typeof raw.width === "number" ? raw.width : 320,
34527
+ height: typeof raw.height === "number" ? raw.height : 320,
34528
+ labelMap
34529
+ };
34530
+ }
34531
+ /** Resolve one model's metadata + presigned artifact URL. */
34532
+ async function requestPlusModelDownload(fetchFn, apiKey, plusModelId) {
34533
+ const token = await fetchPlusAccessToken(fetchFn, apiKey);
34534
+ const info = toModelInfo(await plusGet(fetchFn, token, `model/${plusModelId}`), plusModelId);
34535
+ const signed = await plusGet(fetchFn, token, `model/${plusModelId}/signed_url`);
34536
+ const url = isRecord(signed) && typeof signed.url === "string" ? signed.url : null;
34537
+ if (url === null) throw new Error("Frigate+ signed_url response carried no url");
34538
+ return {
34539
+ info,
34540
+ downloadUrl: url
34541
+ };
34542
+ }
34543
+ /** Frigate+ model type → our format + decode. Mirrors the Frigate presets. */
34544
+ var PLUS_TYPE_MAP = {
34545
+ mobiledet: {
34546
+ format: "tflite",
34547
+ postprocessor: "ssd",
34548
+ extension: ".tflite"
34549
+ },
34550
+ yolonas: {
34551
+ format: "onnx",
34552
+ postprocessor: "yolonas",
34553
+ extension: ".onnx"
34554
+ },
34555
+ yolov9: {
34556
+ format: "onnx",
34557
+ extension: ".onnx"
34558
+ }
34559
+ };
34560
+ function plusTypeTraits(type) {
34561
+ return PLUS_TYPE_MAP[type] ?? {
34562
+ format: "onnx",
34563
+ extension: ".onnx"
34564
+ };
34565
+ }
34566
+ /** Ordered labels from the API's `index → label` map; holes keep alignment. */
34567
+ function orderedLabels(labelMap) {
34568
+ const indices = Object.keys(labelMap).map((k) => Number.parseInt(k, 10)).filter((n) => Number.isInteger(n) && n >= 0);
34569
+ if (indices.length === 0) return [];
34570
+ const max = Math.max(...indices);
34571
+ const out = [];
34572
+ for (let i = 0; i <= max; i++) out.push(labelMap[String(i)] ?? `unknown-${i}`);
34573
+ return out;
34574
+ }
34575
+ /**
34576
+ * Build the registrable descriptor for a downloaded Frigate+ model. The
34577
+ * artifact is hub-local (landed by the server-side download), so the URL uses
34578
+ * the `camstack-local://` convention (D208) — other nodes get it via
34579
+ * Distribute.
34580
+ */
34581
+ function plusInfoToDescriptor(info, opts) {
34582
+ const traits = plusTypeTraits(info.type);
34583
+ const labels = orderedLabels(info.labelMap);
34584
+ return {
34585
+ stepId: "object-detection",
34586
+ entry: {
34587
+ id: opts.modelId,
34588
+ name: opts.name,
34589
+ description: `Frigate+ personal model (${info.type}) — imported via Model Studio`,
34590
+ formats: { [traits.format]: {
34591
+ url: `camstack-local://${opts.modelId}/${opts.filename}`,
34592
+ sizeMB: opts.sizeMB,
34593
+ runtimes: ["python"]
34594
+ } },
34595
+ inputSize: {
34596
+ width: info.width,
34597
+ height: info.height
34598
+ },
34599
+ labels: labels.map((name) => ({
34600
+ id: name,
34601
+ name
34602
+ })),
34603
+ preprocessMode: "letterbox",
34604
+ ...traits.postprocessor !== void 0 ? { postprocessor: traits.postprocessor } : {}
34605
+ }
34606
+ };
34607
+ }
34170
34608
  var MODEL_UPLOAD_ALLOWED_EXTENSIONS = [".onnx", ".tflite"];
34171
34609
  var FILENAME_RE = /^[a-zA-Z0-9._-]+$/;
34172
34610
  /**
@@ -34308,6 +34746,78 @@ var modelStudioActions = defineCustomActions({
34308
34746
  }), { kind: "mutation" }),
34309
34747
  abortModelUpload: customAction(object({ uploadId: string() }), object({ ok: literal(true) }), { kind: "mutation" }),
34310
34748
  /**
34749
+ * Curated PUBLIC Frigate model catalog (D214 addendum) — models Frigate
34750
+ * uses/references that are downloadable without credentials, with verified
34751
+ * metadata so the operator types nothing. Import downloads SERVER-SIDE into
34752
+ * the hub's modelsDir and registers the descriptor with the public URL
34753
+ * (other nodes download on demand — no Distribute needed).
34754
+ */
34755
+ listFrigateCatalog: customAction(_void(), array(object({
34756
+ id: string(),
34757
+ label: string(),
34758
+ format: _enum(MODEL_FORMATS),
34759
+ sizeMB: number(),
34760
+ inputSize: number(),
34761
+ notes: string()
34762
+ })).readonly()),
34763
+ importFrigateCatalogModel: customAction(object({
34764
+ catalogId: string(),
34765
+ modelId: string().optional(),
34766
+ name: string().optional()
34767
+ }), object({
34768
+ ok: literal(true),
34769
+ modelId: string(),
34770
+ bytes: number()
34771
+ }), { kind: "mutation" }),
34772
+ /**
34773
+ * Frigate+ personal models. The API key lives in the addon's SETTINGS
34774
+ * (password field) and never leaves the hub: list / test / import all run
34775
+ * server-side against api.frigate.video. Status deliberately reveals only
34776
+ * booleans — never the key.
34777
+ */
34778
+ /**
34779
+ * Nodes whose engine can actually LOAD a tflite artifact (the pool's only
34780
+ * tflite runtime binds the Coral EdgeTPU delegate — no Coral, no tflite).
34781
+ * The UI gates tflite imports on this instead of letting them fail at load.
34782
+ */
34783
+ tfliteSupport: customAction(_void(), object({ nodes: array(string()).readonly() })),
34784
+ frigatePlusStatus: customAction(_void(), object({
34785
+ configured: boolean(),
34786
+ keyFormatValid: boolean()
34787
+ })),
34788
+ frigatePlusTest: customAction(_void(), object({
34789
+ ok: boolean(),
34790
+ error: string().optional()
34791
+ }), { kind: "mutation" }),
34792
+ frigatePlusListModels: customAction(_void(), array(object({
34793
+ id: string(),
34794
+ name: string(),
34795
+ type: string(),
34796
+ isBaseModel: boolean(),
34797
+ baseModel: string(),
34798
+ supportedDetectors: array(string()).readonly(),
34799
+ trainDate: string(),
34800
+ hailoDevice: string().optional(),
34801
+ verifiedImages: number(),
34802
+ width: number().optional(),
34803
+ height: number().optional()
34804
+ })).readonly()),
34805
+ importFrigatePlusModel: customAction(object({
34806
+ plusModelId: string(),
34807
+ modelId: string(),
34808
+ name: string().optional()
34809
+ }), object({
34810
+ ok: literal(true),
34811
+ modelId: string(),
34812
+ bytes: number(),
34813
+ conversions: array(object({
34814
+ format: _enum(["openvino", "coreml"]),
34815
+ ok: boolean(),
34816
+ nodeId: string().optional(),
34817
+ error: string().optional()
34818
+ })).readonly()
34819
+ }), { kind: "mutation" }),
34820
+ /**
34311
34821
  * Rank nodes for model conversion based on hardware capabilities.
34312
34822
  * CoreML targets require darwin; OpenVINO targets require an OpenVINO-capable node.
34313
34823
  */
@@ -34390,18 +34900,9 @@ function spawnRunConvert(jobPath, pythonPath, onProgress, _sessionId) {
34390
34900
  });
34391
34901
  });
34392
34902
  }
34393
- /**
34394
- * Model Studio provides the `custom-model-registry` collection cap (hub only)
34395
- * and the `model-convert` singleton cap (any node).
34396
- *
34397
- * P1 maintained the durable list of custom detection models and exposed them
34398
- * so the detection pipeline can offer them in its model picker.
34399
- *
34400
- * P3 adds the `model-convert` provider on EVERY node so agents can run
34401
- * local Python conversion without routing through the hub.
34402
- * The `custom-model-registry` cap and all customActions are hub-only.
34403
- */
34404
- var ModelStudioAddon = class extends BaseAddon {
34903
+ /** Global-fetch adapter for the injected Frigate+ client seam. */
34904
+ var plusFetch = async (url, init) => fetch(url, init);
34905
+ var ModelStudioAddon = class ModelStudioAddon extends BaseAddon {
34405
34906
  id = "model-studio";
34406
34907
  modelsState = null;
34407
34908
  availabilityState = null;
@@ -34423,7 +34924,21 @@ var ModelStudioAddon = class extends BaseAddon {
34423
34924
  section: "detection"
34424
34925
  }];
34425
34926
  constructor() {
34426
- super({});
34927
+ super({ frigatePlusApiKey: "" });
34928
+ }
34929
+ globalSettingsSchema() {
34930
+ return this.schema({ sections: [{
34931
+ id: "frigate-plus",
34932
+ title: "Frigate+",
34933
+ description: "Credentials for importing your personal Frigate+ models. Create an API key in your Frigate+ account (https://plus.frigate.video → Settings → API keys; see docs.frigate.video/integrations/plus). The key is used only server-side against api.frigate.video and is never sent to the browser.",
34934
+ fields: [{
34935
+ type: "password",
34936
+ key: "frigatePlusApiKey",
34937
+ label: "Frigate+ API key",
34938
+ description: "Shape: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:40-hex-chars",
34939
+ showToggle: true
34940
+ }]
34941
+ }] });
34427
34942
  }
34428
34943
  makeConvertDeps() {
34429
34944
  return {
@@ -34510,6 +35025,45 @@ var ModelStudioAddon = class extends BaseAddon {
34510
35025
  listCustomModels: async () => this.listCustomModels(),
34511
35026
  distributeModel: async (input) => this.distributeModel(input),
34512
35027
  listAvailability: async () => this.availability_.get(),
35028
+ listFrigateCatalog: async () => FRIGATE_PUBLIC_CATALOG.map((c) => ({
35029
+ id: c.id,
35030
+ label: c.label,
35031
+ format: c.format,
35032
+ sizeMB: c.sizeMB,
35033
+ inputSize: c.inputSize,
35034
+ notes: c.notes
35035
+ })),
35036
+ importFrigateCatalogModel: async (input) => this.importFrigateCatalogModel(input),
35037
+ tfliteSupport: async () => {
35038
+ const api = this.ctx.api;
35039
+ if (!api) return { nodes: [] };
35040
+ const nodes = await this.recommendDeps().listNodes();
35041
+ const supported = [];
35042
+ for (const nId of nodes) try {
35043
+ if ((await api.platformProbe.getCapabilities.query({ nodeId: nId })).scores.some((sc) => sc.format === "tflite" && sc.available)) supported.push(nId);
35044
+ } catch {}
35045
+ return { nodes: supported };
35046
+ },
35047
+ frigatePlusStatus: async () => {
35048
+ const key = this.config.frigatePlusApiKey ?? "";
35049
+ return {
35050
+ configured: key.length > 0,
35051
+ keyFormatValid: isValidPlusApiKey(key)
35052
+ };
35053
+ },
35054
+ frigatePlusTest: async () => {
35055
+ try {
35056
+ await fetchPlusAccessToken(plusFetch, this.config.frigatePlusApiKey ?? "");
35057
+ return { ok: true };
35058
+ } catch (err) {
35059
+ return {
35060
+ ok: false,
35061
+ error: err instanceof Error ? err.message : "auth failed"
35062
+ };
35063
+ }
35064
+ },
35065
+ frigatePlusListModels: async () => listPlusModels(plusFetch, this.config.frigatePlusApiKey ?? ""),
35066
+ importFrigatePlusModel: async (input) => this.importFrigatePlusModel(input),
34513
35067
  recommendConvertNode: async (input) => {
34514
35068
  const api = this.ctx.api;
34515
35069
  if (!api) throw new Error("recommendConvertNode: ctx.api unavailable");
@@ -34639,6 +35193,170 @@ var ModelStudioAddon = class extends BaseAddon {
34639
35193
  bytes: res.bytes
34640
35194
  };
34641
35195
  }
35196
+ /** listNodes/hardwareOf deps for `recommendConvertNode` — shared by the
35197
+ * convert actions and the Frigate+ auto-conversion. */
35198
+ recommendDeps() {
35199
+ const api = this.ctx.api;
35200
+ if (!api) throw new Error("model-studio: ctx.api unavailable");
35201
+ return {
35202
+ listNodes: async () => {
35203
+ return (await api.addons.listCapabilityProviders.query({ capName: "model-convert" })).map((p) => {
35204
+ const atIdx = p.addonId.indexOf("@");
35205
+ return atIdx !== -1 ? p.addonId.slice(atIdx + 1) : "hub";
35206
+ });
35207
+ },
35208
+ hardwareOf: async (nId) => {
35209
+ const hw = await api.platformProbe.getHardware.query({ nodeId: nId });
35210
+ const caps = await api.platformProbe.getCapabilities.query({ nodeId: nId });
35211
+ return {
35212
+ platform: hw.platform,
35213
+ gpu: hw.gpu ?? void 0,
35214
+ npu: hw.npu ?? void 0,
35215
+ openvino: caps.scores.some((s) => s.format === "openvino" && s.available)
35216
+ };
35217
+ }
35218
+ };
35219
+ }
35220
+ /** sha256 of a file on disk (streamed). */
35221
+ static async fileSha256(filePath) {
35222
+ const hash = node_crypto.default.createHash("sha256");
35223
+ await new Promise((resolve, reject) => {
35224
+ node_fs.default.createReadStream(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve()).on("error", reject);
35225
+ });
35226
+ return hash.digest("hex");
35227
+ }
35228
+ /**
35229
+ * Import a curated PUBLIC Frigate catalog model: download SERVER-SIDE into
35230
+ * the hub's modelsDir (size-verified against the curated declaration),
35231
+ * register the descriptor with the PUBLIC url (nodes download on demand),
35232
+ * and record hub availability.
35233
+ */
35234
+ async importFrigateCatalogModel(input) {
35235
+ const cat = FRIGATE_PUBLIC_CATALOG.find((c) => c.id === input.catalogId);
35236
+ if (!cat) throw new Error(`importFrigateCatalogModel: unknown catalog id "${input.catalogId}"`);
35237
+ const descriptor = buildFrigateCatalogDescriptor(input.catalogId, {
35238
+ ...input.modelId !== void 0 ? { modelId: input.modelId } : {},
35239
+ ...input.name !== void 0 ? { name: input.name } : {}
35240
+ });
35241
+ const modelsDir = await this.resolveModelsDir();
35242
+ const filename = cat.url.split("/").at(-1) ?? `${descriptor.entry.id}.${cat.format}`;
35243
+ const destPath = node_path.default.join(modelsDir, filename);
35244
+ await downloadFile(cat.url, destPath);
35245
+ const bytes = (await node_fs.default.promises.stat(destPath)).size;
35246
+ const declaredBytes = cat.sizeMB * 1e6;
35247
+ if (bytes < declaredBytes * .5 || bytes > declaredBytes * 2) {
35248
+ await node_fs.default.promises.rm(destPath, { force: true });
35249
+ throw new Error(`importFrigateCatalogModel: downloaded ${bytes} bytes but the catalog declares ~${Math.round(declaredBytes)} — refusing to register a suspicious artifact`);
35250
+ }
35251
+ const sha256 = await ModelStudioAddon.fileSha256(destPath);
35252
+ await this.registerCustomModel(descriptor);
35253
+ await this.availability_.update((prev) => upsertAvailability(prev, descriptor.entry.id, "hub", {
35254
+ format: cat.format,
35255
+ sha256,
35256
+ bytes,
35257
+ at: Date.now()
35258
+ }));
35259
+ this.ctx.logger.info("Imported Frigate catalog model", { meta: {
35260
+ catalogId: input.catalogId,
35261
+ modelId: descriptor.entry.id,
35262
+ bytes,
35263
+ sha256
35264
+ } });
35265
+ return {
35266
+ ok: true,
35267
+ modelId: descriptor.entry.id,
35268
+ bytes
35269
+ };
35270
+ }
35271
+ /**
35272
+ * Import one of the operator's personal Frigate+ models: resolve metadata +
35273
+ * presigned URL with the SECRET key (server-side only), download into the
35274
+ * hub's modelsDir, and register with the model-type-derived characteristics
35275
+ * (format, decode, input size, labelmap — nothing hand-typed). The artifact
35276
+ * is hub-local: other nodes get it via Models → Distribute.
35277
+ */
35278
+ async importFrigatePlusModel(input) {
35279
+ if (!/^[a-zA-Z0-9._-]+$/.test(input.modelId)) throw new Error(`importFrigatePlusModel: model id "${input.modelId}" is invalid`);
35280
+ const key = this.config.frigatePlusApiKey ?? "";
35281
+ const { info, downloadUrl } = await requestPlusModelDownload(plusFetch, key, input.plusModelId);
35282
+ const traits = plusTypeTraits(info.type);
35283
+ const filename = `${input.modelId}${traits.extension}`;
35284
+ const modelsDir = await this.resolveModelsDir();
35285
+ const destPath = node_path.default.join(modelsDir, filename);
35286
+ await downloadFile(downloadUrl, destPath);
35287
+ const bytes = (await node_fs.default.promises.stat(destPath)).size;
35288
+ if (bytes < 1e4) {
35289
+ await node_fs.default.promises.rm(destPath, { force: true });
35290
+ throw new Error(`importFrigatePlusModel: downloaded only ${bytes} bytes — the signed URL likely expired or the response was an error page`);
35291
+ }
35292
+ const sha256 = await ModelStudioAddon.fileSha256(destPath);
35293
+ const descriptor = plusInfoToDescriptor(info, {
35294
+ modelId: input.modelId,
35295
+ name: input.name?.trim() || `Frigate+ ${info.type} (${input.plusModelId.slice(0, 8)})`,
35296
+ filename,
35297
+ sizeMB: Number((bytes / 1e6).toFixed(1))
35298
+ });
35299
+ await this.registerCustomModel(descriptor);
35300
+ await this.availability_.update((prev) => upsertAvailability(prev, input.modelId, "hub", {
35301
+ format: traits.format,
35302
+ sha256,
35303
+ bytes,
35304
+ at: Date.now()
35305
+ }));
35306
+ this.ctx.logger.info("Imported Frigate+ model", { meta: {
35307
+ plusModelId: input.plusModelId,
35308
+ modelId: input.modelId,
35309
+ type: info.type,
35310
+ bytes
35311
+ } });
35312
+ let conversions = [];
35313
+ if (traits.format === "onnx") {
35314
+ const api = this.ctx.api;
35315
+ if (api) {
35316
+ conversions = await runPlusConversions({
35317
+ recommend: (i) => recommendConvertNode(i, this.recommendDeps()),
35318
+ convert: (convertInput, nId) => api.modelConvert.convert.mutate(convertInput, nodePin(nId)),
35319
+ freshSourceUrl: async () => (await requestPlusModelDownload(plusFetch, key, input.plusModelId)).downloadUrl,
35320
+ upsertEntry: async (entry) => {
35321
+ await this.state_.update((prev) => upsertCustomModel(prev, {
35322
+ stepId: descriptor.stepId,
35323
+ entry
35324
+ }));
35325
+ },
35326
+ markAvailable: async (nId, mId, artifacts) => {
35327
+ await this.availability_.update((prev) => {
35328
+ const seen = /* @__PURE__ */ new Set();
35329
+ let next = prev;
35330
+ for (const artifact of artifacts) {
35331
+ if (seen.has(artifact.format)) continue;
35332
+ seen.add(artifact.format);
35333
+ next = upsertAvailability(next, mId, nId, {
35334
+ format: artifact.format,
35335
+ sha256: "",
35336
+ bytes: Math.round(artifact.sizeMB * 1e6),
35337
+ at: Date.now()
35338
+ });
35339
+ }
35340
+ return next;
35341
+ });
35342
+ }
35343
+ }, {
35344
+ entry: descriptor.entry,
35345
+ targetFormats: ["openvino", "coreml"]
35346
+ });
35347
+ this.ctx.logger.info("Frigate+ import — engine conversions", { meta: {
35348
+ modelId: input.modelId,
35349
+ outcomes: conversions.map((o) => ({ ...o }))
35350
+ } });
35351
+ }
35352
+ }
35353
+ return {
35354
+ ok: true,
35355
+ modelId: input.modelId,
35356
+ bytes,
35357
+ conversions
35358
+ };
35359
+ }
34642
35360
  async registerCustomModel(input) {
34643
35361
  if (!input.stepId.trim()) throw new Error("registerCustomModel: stepId is required");
34644
35362
  if (!input.entry.id.trim()) throw new Error("registerCustomModel: entry.id is required");