@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
@@ -18791,6 +18791,12 @@ var CameraStatusSchema = object({
18791
18791
  /** Unix timestamp (ms) when this snapshot was composed server-side. */
18792
18792
  fetchedAt: number()
18793
18793
  });
18794
+ var InferenceDeviceExclusionReasonSchema = _enum([
18795
+ "disabled",
18796
+ "unavailable",
18797
+ "cannot-host-camera-root",
18798
+ "accelerator-preferred"
18799
+ ]);
18794
18800
  var NodeInferenceDeviceSchema = object({
18795
18801
  /** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
18796
18802
  key: string(),
@@ -18821,7 +18827,17 @@ var NodeInferenceDeviceSchema = object({
18821
18827
  * available per format; this is the stored selection that becomes the
18822
18828
  * default for EVERY camera landing on this accelerator.
18823
18829
  */
18824
- steps: record(string(), DeviceStepConfigSchema).optional()
18830
+ steps: record(string(), DeviceStepConfigSchema).optional(),
18831
+ /**
18832
+ * `null` when the device IS a camera-root candidate on this node; otherwise
18833
+ * the reason the dispatcher drops it. Computed by the SAME
18834
+ * `resolveInferenceDeviceEligibility` the dispatcher runs, so this view can
18835
+ * never disagree with the election — deriving it in the UI from
18836
+ * `enabled`/`available` would silently miss `cannot-host-camera-root` (needs
18837
+ * the node's model catalog) and `accelerator-preferred` (needs the node-wide
18838
+ * "an accelerator is serving" predicate).
18839
+ */
18840
+ exclusion: InferenceDeviceExclusionReasonSchema.nullable()
18825
18841
  });
18826
18842
  var NodeInferenceDevicesSchema = object({
18827
18843
  nodeId: string(),
@@ -22579,7 +22595,12 @@ var ListResultSchema = object({
22579
22595
  probedAt: number()
22580
22596
  });
22581
22597
  var PreferredSchema = LocalInterfaceSchema.nullable();
22582
- var GetConnectionEndpointsResultSchema = object({ endpoints: array(object({
22598
+ /**
22599
+ * Candidate base URL for the SDK to race on connect. Order matters —
22600
+ * the SDK should attempt these top-to-bottom with a short per-candidate
22601
+ * timeout (e.g. 1500ms) and cache the winner for the session.
22602
+ */
22603
+ var ConnectionEndpointSchema = object({
22583
22604
  /** Operator-facing label (e.g. "LAN — en0", "Public tunnel"). */
22584
22605
  label: string(),
22585
22606
  /** Fully-formed base URL with scheme + host + port. */
@@ -22622,7 +22643,42 @@ var GetConnectionEndpointsResultSchema = object({ endpoints: array(object({
22622
22643
  * ordering between polls.
22623
22644
  */
22624
22645
  priority: number()
22625
- })).readonly() });
22646
+ });
22647
+ /**
22648
+ * Where the advertised local port came from. Ordered most → least
22649
+ * authoritative, and the whole point of returning it: a client must be able to
22650
+ * tell a FACT about the hub's socket from an echo of its own guess.
22651
+ */
22652
+ var LocalPortSourceEnum = _enum([
22653
+ "server-config",
22654
+ "server-env",
22655
+ "caller-hint",
22656
+ "default"
22657
+ ]);
22658
+ /** The port every LAN/loopback `baseUrl` in the same result was built with. */
22659
+ var AdvertisedLocalPortSchema = object({
22660
+ port: number().int().min(1).max(65535),
22661
+ source: LocalPortSourceEnum
22662
+ });
22663
+ var GetConnectionEndpointsResultSchema = object({
22664
+ endpoints: array(ConnectionEndpointSchema).readonly(),
22665
+ /**
22666
+ * The port the hub built the LAN/loopback URLs with, and where that number
22667
+ * came from.
22668
+ *
22669
+ * Returned rather than merely applied, because "the URL is right" and "the
22670
+ * client can KNOW the URL is right" are different properties. A client that
22671
+ * only sees a corrected URL cannot distinguish a hub that fixed the port from
22672
+ * a hub that echoed the port the client sent, so it cannot decide whether to
22673
+ * race the candidate or discard it. With `source` it can: anything but
22674
+ * `caller-hint` is the hub's own socket.
22675
+ *
22676
+ * Absent on hubs predating this field — a client that finds it missing is
22677
+ * talking to an echoing hub and must degrade exactly as it does for
22678
+ * `caller-hint`.
22679
+ */
22680
+ localPort: AdvertisedLocalPortSchema
22681
+ });
22626
22682
  /**
22627
22683
  * The chosen outbound endpoint for notification artifacts. `baseUrl: null` =
22628
22684
  * AUTO (resolved from the candidate ranking at send time); `resolved` reports
@@ -22643,8 +22699,13 @@ var AllowedAddressesSchema = object({
22643
22699
  */
22644
22700
  addresses: array(string()).readonly() });
22645
22701
  method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(object({
22646
- /** Local hub HTTP port to use in base URLs. */
22647
- port: number().int().min(1).max(65535),
22702
+ /**
22703
+ * LEGACY HINT — do not send from new code. Kept optional so clients
22704
+ * written against the echoing contract keep working; the hub uses it
22705
+ * only when it cannot read its own port, and says so via
22706
+ * `localPort.source === 'caller-hint'`.
22707
+ */
22708
+ port: number().int().min(1).max(65535).optional(),
22648
22709
  /** Include `http(s)://127.0.0.1:<port>` as the lowest-priority
22649
22710
  * candidate. Default `true`. */
22650
22711
  includeLoopback: boolean().optional(),
@@ -34144,6 +34205,383 @@ function removeCustomModel(list, modelId) {
34144
34205
  removed: next.length !== list.length
34145
34206
  };
34146
34207
  }
34208
+ var FRIGATE_PUBLIC_CATALOG = [{
34209
+ id: "frigate-mobiledet-edgetpu",
34210
+ label: "Frigate default — SSDLite MobileDet (EdgeTPU)",
34211
+ format: "tflite",
34212
+ url: "https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite",
34213
+ sizeMB: 5.4,
34214
+ inputSize: 320,
34215
+ postprocessor: "ssd",
34216
+ labels: [
34217
+ "person",
34218
+ "bicycle",
34219
+ "car",
34220
+ "motorcycle",
34221
+ "airplane",
34222
+ "bus",
34223
+ "train",
34224
+ "car",
34225
+ "boat",
34226
+ "traffic light",
34227
+ "fire hydrant",
34228
+ "street sign",
34229
+ "stop sign",
34230
+ "parking meter",
34231
+ "bench",
34232
+ "bird",
34233
+ "cat",
34234
+ "dog",
34235
+ "horse",
34236
+ "sheep",
34237
+ "cow",
34238
+ "elephant",
34239
+ "bear",
34240
+ "zebra",
34241
+ "giraffe",
34242
+ "hat",
34243
+ "backpack",
34244
+ "umbrella",
34245
+ "shoe",
34246
+ "eye glasses",
34247
+ "handbag",
34248
+ "tie",
34249
+ "suitcase",
34250
+ "frisbee",
34251
+ "skis",
34252
+ "snowboard",
34253
+ "sports ball",
34254
+ "kite",
34255
+ "baseball bat",
34256
+ "baseball glove",
34257
+ "skateboard",
34258
+ "surfboard",
34259
+ "tennis racket",
34260
+ "bottle",
34261
+ "plate",
34262
+ "wine glass",
34263
+ "cup",
34264
+ "fork",
34265
+ "knife",
34266
+ "spoon",
34267
+ "bowl",
34268
+ "banana",
34269
+ "apple",
34270
+ "sandwich",
34271
+ "orange",
34272
+ "broccoli",
34273
+ "carrot",
34274
+ "hot dog",
34275
+ "pizza",
34276
+ "donut",
34277
+ "cake",
34278
+ "chair",
34279
+ "couch",
34280
+ "potted plant",
34281
+ "bed",
34282
+ "mirror",
34283
+ "dining table",
34284
+ "window",
34285
+ "desk",
34286
+ "toilet",
34287
+ "door",
34288
+ "tv",
34289
+ "laptop",
34290
+ "mouse",
34291
+ "remote",
34292
+ "keyboard",
34293
+ "cell phone",
34294
+ "microwave",
34295
+ "oven",
34296
+ "toaster",
34297
+ "sink",
34298
+ "refrigerator",
34299
+ "blender",
34300
+ "book",
34301
+ "clock",
34302
+ "vase",
34303
+ "scissors",
34304
+ "teddy bear",
34305
+ "hair drier",
34306
+ "toothbrush",
34307
+ "hair brush"
34308
+ ],
34309
+ 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."
34310
+ }];
34311
+ /**
34312
+ * Build the registrable descriptor for a curated catalog entry. The URL is
34313
+ * the PUBLIC one — any node downloads it on demand; no Distribute needed.
34314
+ */
34315
+ function buildFrigateCatalogDescriptor(catalogId, overrides) {
34316
+ const cat = FRIGATE_PUBLIC_CATALOG.find((e) => e.id === catalogId);
34317
+ if (!cat) throw new Error(`Unknown Frigate catalog id "${catalogId}" — available: ${FRIGATE_PUBLIC_CATALOG.map((e) => e.id).join(", ")}`);
34318
+ return {
34319
+ stepId: "object-detection",
34320
+ entry: {
34321
+ id: overrides?.modelId?.trim() || cat.id,
34322
+ name: overrides?.name?.trim() || cat.label,
34323
+ description: `${cat.notes} Imported from the Frigate public catalog via Model Studio.`,
34324
+ formats: { [cat.format]: {
34325
+ url: cat.url,
34326
+ sizeMB: cat.sizeMB,
34327
+ runtimes: ["python"]
34328
+ } },
34329
+ inputSize: {
34330
+ width: cat.inputSize,
34331
+ height: cat.inputSize
34332
+ },
34333
+ labels: cat.labels.map((name) => ({
34334
+ id: name,
34335
+ name
34336
+ })),
34337
+ preprocessMode: "letterbox",
34338
+ ...cat.postprocessor !== void 0 ? { postprocessor: cat.postprocessor } : {}
34339
+ }
34340
+ };
34341
+ }
34342
+ //#endregion
34343
+ //#region src/frigate/plus-conversion.ts
34344
+ /** Converted formats ADD to the imported entry; identity fields (decode,
34345
+ * labels, description, preprocess) stay the import's. */
34346
+ function mergeConvertedFormats(base, converted) {
34347
+ return {
34348
+ ...base,
34349
+ formats: {
34350
+ ...base.formats,
34351
+ ...converted.formats
34352
+ }
34353
+ };
34354
+ }
34355
+ function targetOf(format) {
34356
+ return format === "openvino" ? {
34357
+ format,
34358
+ precisions: ["fp16"]
34359
+ } : { format };
34360
+ }
34361
+ /**
34362
+ * Convert the imported ONNX for each requested engine, one target at a time,
34363
+ * merging every success into the registered entry. Returns one outcome per
34364
+ * requested format — the caller surfaces them verbatim.
34365
+ */
34366
+ async function runPlusConversions(deps, args) {
34367
+ const outcomes = [];
34368
+ let current = args.entry;
34369
+ for (const format of args.targetFormats) {
34370
+ const targets = [targetOf(format)];
34371
+ try {
34372
+ const ranked = await deps.recommend({ targets });
34373
+ const best = ranked.find((r) => r.supported);
34374
+ if (!best) {
34375
+ const reason = ranked[0]?.reason ?? "no node can satisfy this target";
34376
+ outcomes.push({
34377
+ format,
34378
+ ok: false,
34379
+ error: reason
34380
+ });
34381
+ continue;
34382
+ }
34383
+ const sourceUrl = await deps.freshSourceUrl();
34384
+ const result = await deps.convert({
34385
+ sourceUrl,
34386
+ metadata: {
34387
+ id: current.id,
34388
+ name: current.name,
34389
+ labels: current.labels,
34390
+ inputSize: current.inputSize,
34391
+ preprocessMode: current.preprocessMode ?? "letterbox",
34392
+ outputFormat: "yolo"
34393
+ },
34394
+ targets
34395
+ }, best.nodeId);
34396
+ if (result.artifacts.length === 0) {
34397
+ outcomes.push({
34398
+ format,
34399
+ ok: false,
34400
+ nodeId: best.nodeId,
34401
+ error: "no validated artifacts"
34402
+ });
34403
+ continue;
34404
+ }
34405
+ current = mergeConvertedFormats(current, result.entry);
34406
+ await deps.upsertEntry(current);
34407
+ await deps.markAvailable(best.nodeId, current.id, result.artifacts);
34408
+ outcomes.push({
34409
+ format,
34410
+ ok: true,
34411
+ nodeId: best.nodeId
34412
+ });
34413
+ } catch (err) {
34414
+ outcomes.push({
34415
+ format,
34416
+ ok: false,
34417
+ error: err instanceof Error ? err.message : "conversion failed"
34418
+ });
34419
+ }
34420
+ }
34421
+ return outcomes;
34422
+ }
34423
+ //#endregion
34424
+ //#region src/frigate/frigate-plus.ts
34425
+ var PLUS_API_HOST = "https://api.frigate.video";
34426
+ 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}$/;
34427
+ function isValidPlusApiKey(key) {
34428
+ return PLUS_KEY_RE.test(key);
34429
+ }
34430
+ function isRecord(value) {
34431
+ return typeof value === "object" && value !== null && !Array.isArray(value);
34432
+ }
34433
+ /** Exchange the API key for an access token. The key never appears in errors. */
34434
+ async function fetchPlusAccessToken(fetchFn, apiKey) {
34435
+ 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");
34436
+ const [user, pass] = apiKey.split(":");
34437
+ const basic = Buffer.from(`${user}:${pass}`).toString("base64");
34438
+ const res = await fetchFn(`${PLUS_API_HOST}/v1/auth/token`, { headers: { authorization: `Basic ${basic}` } });
34439
+ if (!res.ok) throw new Error(`Frigate+ authentication failed (HTTP ${res.status}) — check the API key in the Model Studio addon settings`);
34440
+ const body = await res.json();
34441
+ const token = isRecord(body) && typeof body.accessToken === "string" ? body.accessToken : null;
34442
+ if (token === null) throw new Error("Frigate+ auth response carried no accessToken");
34443
+ return token;
34444
+ }
34445
+ async function plusGet(fetchFn, token, path) {
34446
+ const res = await fetchFn(`${PLUS_API_HOST}/v1/${path}`, { headers: { authorization: `Bearer ${token}` } });
34447
+ if (!res.ok) throw new Error(`Frigate+ request "${path}" failed (HTTP ${res.status}): ${await res.text()}`);
34448
+ return res.json();
34449
+ }
34450
+ /**
34451
+ * `verifiedCounts` has THREE real shapes and none may break the parse:
34452
+ * -1 → base model ("not applicable") ⇒ 0
34453
+ * { "11": 199 } → legacy custom (flat label→count)
34454
+ * { camera: { label: n, … }, … } → recent custom (per camera)
34455
+ */
34456
+ function verifiedImageCount(raw) {
34457
+ if (typeof raw === "number") return raw > 0 ? raw : 0;
34458
+ if (!isRecord(raw)) return 0;
34459
+ let total = 0;
34460
+ for (const value of Object.values(raw)) if (typeof value === "number") total += value > 0 ? value : 0;
34461
+ else if (isRecord(value)) {
34462
+ for (const inner of Object.values(value)) if (typeof inner === "number" && inner > 0) total += inner;
34463
+ }
34464
+ return total;
34465
+ }
34466
+ function toModelSummary(m) {
34467
+ if (typeof m.id !== "string") return null;
34468
+ return {
34469
+ id: m.id,
34470
+ name: typeof m.name === "string" ? m.name : m.id,
34471
+ type: typeof m.type === "string" ? m.type : "unknown",
34472
+ isBaseModel: m.isBaseModel === true,
34473
+ baseModel: typeof m.baseModel === "string" ? m.baseModel : "",
34474
+ supportedDetectors: Array.isArray(m.supportedDetectors) ? m.supportedDetectors.filter((d) => typeof d === "string") : [],
34475
+ trainDate: typeof m.trainDate === "string" ? m.trainDate : "",
34476
+ ...typeof m.hailoDevice === "string" ? { hailoDevice: m.hailoDevice } : {},
34477
+ verifiedImages: verifiedImageCount(m.verifiedCounts),
34478
+ ...typeof m.width === "number" ? { width: m.width } : {},
34479
+ ...typeof m.height === "number" ? { height: m.height } : {}
34480
+ };
34481
+ }
34482
+ /** Parse a raw `/v1/model/list` body (`{list:[…]}`, or a bare array). */
34483
+ function toPlusModelSummaries(raw) {
34484
+ return (Array.isArray(raw) ? raw : isRecord(raw) && Array.isArray(raw.list) ? raw.list : []).filter(isRecord).map(toModelSummary).filter((m) => m !== null);
34485
+ }
34486
+ /**
34487
+ * EVERYTHING the account has access to — base AND custom models. The real
34488
+ * response wraps the array: `{ "list": [...] }` (a bare array is tolerated
34489
+ * for forward compatibility).
34490
+ */
34491
+ async function listPlusModels(fetchFn, apiKey) {
34492
+ return toPlusModelSummaries(await plusGet(fetchFn, await fetchPlusAccessToken(fetchFn, apiKey), "model/list"));
34493
+ }
34494
+ function toModelInfo(raw, modelId) {
34495
+ if (!isRecord(raw)) throw new Error("Frigate+ model info: unexpected response shape");
34496
+ const labelMap = {};
34497
+ if (isRecord(raw.labelMap)) {
34498
+ for (const [k, v] of Object.entries(raw.labelMap)) if (typeof v === "string") labelMap[k] = v;
34499
+ }
34500
+ return {
34501
+ id: typeof raw.id === "string" ? raw.id : modelId,
34502
+ type: typeof raw.type === "string" ? raw.type : "unknown",
34503
+ width: typeof raw.width === "number" ? raw.width : 320,
34504
+ height: typeof raw.height === "number" ? raw.height : 320,
34505
+ labelMap
34506
+ };
34507
+ }
34508
+ /** Resolve one model's metadata + presigned artifact URL. */
34509
+ async function requestPlusModelDownload(fetchFn, apiKey, plusModelId) {
34510
+ const token = await fetchPlusAccessToken(fetchFn, apiKey);
34511
+ const info = toModelInfo(await plusGet(fetchFn, token, `model/${plusModelId}`), plusModelId);
34512
+ const signed = await plusGet(fetchFn, token, `model/${plusModelId}/signed_url`);
34513
+ const url = isRecord(signed) && typeof signed.url === "string" ? signed.url : null;
34514
+ if (url === null) throw new Error("Frigate+ signed_url response carried no url");
34515
+ return {
34516
+ info,
34517
+ downloadUrl: url
34518
+ };
34519
+ }
34520
+ /** Frigate+ model type → our format + decode. Mirrors the Frigate presets. */
34521
+ var PLUS_TYPE_MAP = {
34522
+ mobiledet: {
34523
+ format: "tflite",
34524
+ postprocessor: "ssd",
34525
+ extension: ".tflite"
34526
+ },
34527
+ yolonas: {
34528
+ format: "onnx",
34529
+ postprocessor: "yolonas",
34530
+ extension: ".onnx"
34531
+ },
34532
+ yolov9: {
34533
+ format: "onnx",
34534
+ extension: ".onnx"
34535
+ }
34536
+ };
34537
+ function plusTypeTraits(type) {
34538
+ return PLUS_TYPE_MAP[type] ?? {
34539
+ format: "onnx",
34540
+ extension: ".onnx"
34541
+ };
34542
+ }
34543
+ /** Ordered labels from the API's `index → label` map; holes keep alignment. */
34544
+ function orderedLabels(labelMap) {
34545
+ const indices = Object.keys(labelMap).map((k) => Number.parseInt(k, 10)).filter((n) => Number.isInteger(n) && n >= 0);
34546
+ if (indices.length === 0) return [];
34547
+ const max = Math.max(...indices);
34548
+ const out = [];
34549
+ for (let i = 0; i <= max; i++) out.push(labelMap[String(i)] ?? `unknown-${i}`);
34550
+ return out;
34551
+ }
34552
+ /**
34553
+ * Build the registrable descriptor for a downloaded Frigate+ model. The
34554
+ * artifact is hub-local (landed by the server-side download), so the URL uses
34555
+ * the `camstack-local://` convention (D208) — other nodes get it via
34556
+ * Distribute.
34557
+ */
34558
+ function plusInfoToDescriptor(info, opts) {
34559
+ const traits = plusTypeTraits(info.type);
34560
+ const labels = orderedLabels(info.labelMap);
34561
+ return {
34562
+ stepId: "object-detection",
34563
+ entry: {
34564
+ id: opts.modelId,
34565
+ name: opts.name,
34566
+ description: `Frigate+ personal model (${info.type}) — imported via Model Studio`,
34567
+ formats: { [traits.format]: {
34568
+ url: `camstack-local://${opts.modelId}/${opts.filename}`,
34569
+ sizeMB: opts.sizeMB,
34570
+ runtimes: ["python"]
34571
+ } },
34572
+ inputSize: {
34573
+ width: info.width,
34574
+ height: info.height
34575
+ },
34576
+ labels: labels.map((name) => ({
34577
+ id: name,
34578
+ name
34579
+ })),
34580
+ preprocessMode: "letterbox",
34581
+ ...traits.postprocessor !== void 0 ? { postprocessor: traits.postprocessor } : {}
34582
+ }
34583
+ };
34584
+ }
34147
34585
  var MODEL_UPLOAD_ALLOWED_EXTENSIONS = [".onnx", ".tflite"];
34148
34586
  var FILENAME_RE = /^[a-zA-Z0-9._-]+$/;
34149
34587
  /**
@@ -34285,6 +34723,78 @@ var modelStudioActions = defineCustomActions({
34285
34723
  }), { kind: "mutation" }),
34286
34724
  abortModelUpload: customAction(object({ uploadId: string() }), object({ ok: literal(true) }), { kind: "mutation" }),
34287
34725
  /**
34726
+ * Curated PUBLIC Frigate model catalog (D214 addendum) — models Frigate
34727
+ * uses/references that are downloadable without credentials, with verified
34728
+ * metadata so the operator types nothing. Import downloads SERVER-SIDE into
34729
+ * the hub's modelsDir and registers the descriptor with the public URL
34730
+ * (other nodes download on demand — no Distribute needed).
34731
+ */
34732
+ listFrigateCatalog: customAction(_void(), array(object({
34733
+ id: string(),
34734
+ label: string(),
34735
+ format: _enum(MODEL_FORMATS),
34736
+ sizeMB: number(),
34737
+ inputSize: number(),
34738
+ notes: string()
34739
+ })).readonly()),
34740
+ importFrigateCatalogModel: customAction(object({
34741
+ catalogId: string(),
34742
+ modelId: string().optional(),
34743
+ name: string().optional()
34744
+ }), object({
34745
+ ok: literal(true),
34746
+ modelId: string(),
34747
+ bytes: number()
34748
+ }), { kind: "mutation" }),
34749
+ /**
34750
+ * Frigate+ personal models. The API key lives in the addon's SETTINGS
34751
+ * (password field) and never leaves the hub: list / test / import all run
34752
+ * server-side against api.frigate.video. Status deliberately reveals only
34753
+ * booleans — never the key.
34754
+ */
34755
+ /**
34756
+ * Nodes whose engine can actually LOAD a tflite artifact (the pool's only
34757
+ * tflite runtime binds the Coral EdgeTPU delegate — no Coral, no tflite).
34758
+ * The UI gates tflite imports on this instead of letting them fail at load.
34759
+ */
34760
+ tfliteSupport: customAction(_void(), object({ nodes: array(string()).readonly() })),
34761
+ frigatePlusStatus: customAction(_void(), object({
34762
+ configured: boolean(),
34763
+ keyFormatValid: boolean()
34764
+ })),
34765
+ frigatePlusTest: customAction(_void(), object({
34766
+ ok: boolean(),
34767
+ error: string().optional()
34768
+ }), { kind: "mutation" }),
34769
+ frigatePlusListModels: customAction(_void(), array(object({
34770
+ id: string(),
34771
+ name: string(),
34772
+ type: string(),
34773
+ isBaseModel: boolean(),
34774
+ baseModel: string(),
34775
+ supportedDetectors: array(string()).readonly(),
34776
+ trainDate: string(),
34777
+ hailoDevice: string().optional(),
34778
+ verifiedImages: number(),
34779
+ width: number().optional(),
34780
+ height: number().optional()
34781
+ })).readonly()),
34782
+ importFrigatePlusModel: customAction(object({
34783
+ plusModelId: string(),
34784
+ modelId: string(),
34785
+ name: string().optional()
34786
+ }), object({
34787
+ ok: literal(true),
34788
+ modelId: string(),
34789
+ bytes: number(),
34790
+ conversions: array(object({
34791
+ format: _enum(["openvino", "coreml"]),
34792
+ ok: boolean(),
34793
+ nodeId: string().optional(),
34794
+ error: string().optional()
34795
+ })).readonly()
34796
+ }), { kind: "mutation" }),
34797
+ /**
34288
34798
  * Rank nodes for model conversion based on hardware capabilities.
34289
34799
  * CoreML targets require darwin; OpenVINO targets require an OpenVINO-capable node.
34290
34800
  */
@@ -34367,18 +34877,9 @@ function spawnRunConvert(jobPath, pythonPath, onProgress, _sessionId) {
34367
34877
  });
34368
34878
  });
34369
34879
  }
34370
- /**
34371
- * Model Studio provides the `custom-model-registry` collection cap (hub only)
34372
- * and the `model-convert` singleton cap (any node).
34373
- *
34374
- * P1 maintained the durable list of custom detection models and exposed them
34375
- * so the detection pipeline can offer them in its model picker.
34376
- *
34377
- * P3 adds the `model-convert` provider on EVERY node so agents can run
34378
- * local Python conversion without routing through the hub.
34379
- * The `custom-model-registry` cap and all customActions are hub-only.
34380
- */
34381
- var ModelStudioAddon = class extends BaseAddon {
34880
+ /** Global-fetch adapter for the injected Frigate+ client seam. */
34881
+ var plusFetch = async (url, init) => fetch(url, init);
34882
+ var ModelStudioAddon = class ModelStudioAddon extends BaseAddon {
34382
34883
  id = "model-studio";
34383
34884
  modelsState = null;
34384
34885
  availabilityState = null;
@@ -34400,7 +34901,21 @@ var ModelStudioAddon = class extends BaseAddon {
34400
34901
  section: "detection"
34401
34902
  }];
34402
34903
  constructor() {
34403
- super({});
34904
+ super({ frigatePlusApiKey: "" });
34905
+ }
34906
+ globalSettingsSchema() {
34907
+ return this.schema({ sections: [{
34908
+ id: "frigate-plus",
34909
+ title: "Frigate+",
34910
+ 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.",
34911
+ fields: [{
34912
+ type: "password",
34913
+ key: "frigatePlusApiKey",
34914
+ label: "Frigate+ API key",
34915
+ description: "Shape: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:40-hex-chars",
34916
+ showToggle: true
34917
+ }]
34918
+ }] });
34404
34919
  }
34405
34920
  makeConvertDeps() {
34406
34921
  return {
@@ -34487,6 +35002,45 @@ var ModelStudioAddon = class extends BaseAddon {
34487
35002
  listCustomModels: async () => this.listCustomModels(),
34488
35003
  distributeModel: async (input) => this.distributeModel(input),
34489
35004
  listAvailability: async () => this.availability_.get(),
35005
+ listFrigateCatalog: async () => FRIGATE_PUBLIC_CATALOG.map((c) => ({
35006
+ id: c.id,
35007
+ label: c.label,
35008
+ format: c.format,
35009
+ sizeMB: c.sizeMB,
35010
+ inputSize: c.inputSize,
35011
+ notes: c.notes
35012
+ })),
35013
+ importFrigateCatalogModel: async (input) => this.importFrigateCatalogModel(input),
35014
+ tfliteSupport: async () => {
35015
+ const api = this.ctx.api;
35016
+ if (!api) return { nodes: [] };
35017
+ const nodes = await this.recommendDeps().listNodes();
35018
+ const supported = [];
35019
+ for (const nId of nodes) try {
35020
+ if ((await api.platformProbe.getCapabilities.query({ nodeId: nId })).scores.some((sc) => sc.format === "tflite" && sc.available)) supported.push(nId);
35021
+ } catch {}
35022
+ return { nodes: supported };
35023
+ },
35024
+ frigatePlusStatus: async () => {
35025
+ const key = this.config.frigatePlusApiKey ?? "";
35026
+ return {
35027
+ configured: key.length > 0,
35028
+ keyFormatValid: isValidPlusApiKey(key)
35029
+ };
35030
+ },
35031
+ frigatePlusTest: async () => {
35032
+ try {
35033
+ await fetchPlusAccessToken(plusFetch, this.config.frigatePlusApiKey ?? "");
35034
+ return { ok: true };
35035
+ } catch (err) {
35036
+ return {
35037
+ ok: false,
35038
+ error: err instanceof Error ? err.message : "auth failed"
35039
+ };
35040
+ }
35041
+ },
35042
+ frigatePlusListModels: async () => listPlusModels(plusFetch, this.config.frigatePlusApiKey ?? ""),
35043
+ importFrigatePlusModel: async (input) => this.importFrigatePlusModel(input),
34490
35044
  recommendConvertNode: async (input) => {
34491
35045
  const api = this.ctx.api;
34492
35046
  if (!api) throw new Error("recommendConvertNode: ctx.api unavailable");
@@ -34616,6 +35170,170 @@ var ModelStudioAddon = class extends BaseAddon {
34616
35170
  bytes: res.bytes
34617
35171
  };
34618
35172
  }
35173
+ /** listNodes/hardwareOf deps for `recommendConvertNode` — shared by the
35174
+ * convert actions and the Frigate+ auto-conversion. */
35175
+ recommendDeps() {
35176
+ const api = this.ctx.api;
35177
+ if (!api) throw new Error("model-studio: ctx.api unavailable");
35178
+ return {
35179
+ listNodes: async () => {
35180
+ return (await api.addons.listCapabilityProviders.query({ capName: "model-convert" })).map((p) => {
35181
+ const atIdx = p.addonId.indexOf("@");
35182
+ return atIdx !== -1 ? p.addonId.slice(atIdx + 1) : "hub";
35183
+ });
35184
+ },
35185
+ hardwareOf: async (nId) => {
35186
+ const hw = await api.platformProbe.getHardware.query({ nodeId: nId });
35187
+ const caps = await api.platformProbe.getCapabilities.query({ nodeId: nId });
35188
+ return {
35189
+ platform: hw.platform,
35190
+ gpu: hw.gpu ?? void 0,
35191
+ npu: hw.npu ?? void 0,
35192
+ openvino: caps.scores.some((s) => s.format === "openvino" && s.available)
35193
+ };
35194
+ }
35195
+ };
35196
+ }
35197
+ /** sha256 of a file on disk (streamed). */
35198
+ static async fileSha256(filePath) {
35199
+ const hash = crypto$1.createHash("sha256");
35200
+ await new Promise((resolve, reject) => {
35201
+ fs.createReadStream(filePath).on("data", (chunk) => hash.update(chunk)).on("end", () => resolve()).on("error", reject);
35202
+ });
35203
+ return hash.digest("hex");
35204
+ }
35205
+ /**
35206
+ * Import a curated PUBLIC Frigate catalog model: download SERVER-SIDE into
35207
+ * the hub's modelsDir (size-verified against the curated declaration),
35208
+ * register the descriptor with the PUBLIC url (nodes download on demand),
35209
+ * and record hub availability.
35210
+ */
35211
+ async importFrigateCatalogModel(input) {
35212
+ const cat = FRIGATE_PUBLIC_CATALOG.find((c) => c.id === input.catalogId);
35213
+ if (!cat) throw new Error(`importFrigateCatalogModel: unknown catalog id "${input.catalogId}"`);
35214
+ const descriptor = buildFrigateCatalogDescriptor(input.catalogId, {
35215
+ ...input.modelId !== void 0 ? { modelId: input.modelId } : {},
35216
+ ...input.name !== void 0 ? { name: input.name } : {}
35217
+ });
35218
+ const modelsDir = await this.resolveModelsDir();
35219
+ const filename = cat.url.split("/").at(-1) ?? `${descriptor.entry.id}.${cat.format}`;
35220
+ const destPath = path.join(modelsDir, filename);
35221
+ await downloadFile(cat.url, destPath);
35222
+ const bytes = (await fs.promises.stat(destPath)).size;
35223
+ const declaredBytes = cat.sizeMB * 1e6;
35224
+ if (bytes < declaredBytes * .5 || bytes > declaredBytes * 2) {
35225
+ await fs.promises.rm(destPath, { force: true });
35226
+ throw new Error(`importFrigateCatalogModel: downloaded ${bytes} bytes but the catalog declares ~${Math.round(declaredBytes)} — refusing to register a suspicious artifact`);
35227
+ }
35228
+ const sha256 = await ModelStudioAddon.fileSha256(destPath);
35229
+ await this.registerCustomModel(descriptor);
35230
+ await this.availability_.update((prev) => upsertAvailability(prev, descriptor.entry.id, "hub", {
35231
+ format: cat.format,
35232
+ sha256,
35233
+ bytes,
35234
+ at: Date.now()
35235
+ }));
35236
+ this.ctx.logger.info("Imported Frigate catalog model", { meta: {
35237
+ catalogId: input.catalogId,
35238
+ modelId: descriptor.entry.id,
35239
+ bytes,
35240
+ sha256
35241
+ } });
35242
+ return {
35243
+ ok: true,
35244
+ modelId: descriptor.entry.id,
35245
+ bytes
35246
+ };
35247
+ }
35248
+ /**
35249
+ * Import one of the operator's personal Frigate+ models: resolve metadata +
35250
+ * presigned URL with the SECRET key (server-side only), download into the
35251
+ * hub's modelsDir, and register with the model-type-derived characteristics
35252
+ * (format, decode, input size, labelmap — nothing hand-typed). The artifact
35253
+ * is hub-local: other nodes get it via Models → Distribute.
35254
+ */
35255
+ async importFrigatePlusModel(input) {
35256
+ if (!/^[a-zA-Z0-9._-]+$/.test(input.modelId)) throw new Error(`importFrigatePlusModel: model id "${input.modelId}" is invalid`);
35257
+ const key = this.config.frigatePlusApiKey ?? "";
35258
+ const { info, downloadUrl } = await requestPlusModelDownload(plusFetch, key, input.plusModelId);
35259
+ const traits = plusTypeTraits(info.type);
35260
+ const filename = `${input.modelId}${traits.extension}`;
35261
+ const modelsDir = await this.resolveModelsDir();
35262
+ const destPath = path.join(modelsDir, filename);
35263
+ await downloadFile(downloadUrl, destPath);
35264
+ const bytes = (await fs.promises.stat(destPath)).size;
35265
+ if (bytes < 1e4) {
35266
+ await fs.promises.rm(destPath, { force: true });
35267
+ throw new Error(`importFrigatePlusModel: downloaded only ${bytes} bytes — the signed URL likely expired or the response was an error page`);
35268
+ }
35269
+ const sha256 = await ModelStudioAddon.fileSha256(destPath);
35270
+ const descriptor = plusInfoToDescriptor(info, {
35271
+ modelId: input.modelId,
35272
+ name: input.name?.trim() || `Frigate+ ${info.type} (${input.plusModelId.slice(0, 8)})`,
35273
+ filename,
35274
+ sizeMB: Number((bytes / 1e6).toFixed(1))
35275
+ });
35276
+ await this.registerCustomModel(descriptor);
35277
+ await this.availability_.update((prev) => upsertAvailability(prev, input.modelId, "hub", {
35278
+ format: traits.format,
35279
+ sha256,
35280
+ bytes,
35281
+ at: Date.now()
35282
+ }));
35283
+ this.ctx.logger.info("Imported Frigate+ model", { meta: {
35284
+ plusModelId: input.plusModelId,
35285
+ modelId: input.modelId,
35286
+ type: info.type,
35287
+ bytes
35288
+ } });
35289
+ let conversions = [];
35290
+ if (traits.format === "onnx") {
35291
+ const api = this.ctx.api;
35292
+ if (api) {
35293
+ conversions = await runPlusConversions({
35294
+ recommend: (i) => recommendConvertNode(i, this.recommendDeps()),
35295
+ convert: (convertInput, nId) => api.modelConvert.convert.mutate(convertInput, nodePin(nId)),
35296
+ freshSourceUrl: async () => (await requestPlusModelDownload(plusFetch, key, input.plusModelId)).downloadUrl,
35297
+ upsertEntry: async (entry) => {
35298
+ await this.state_.update((prev) => upsertCustomModel(prev, {
35299
+ stepId: descriptor.stepId,
35300
+ entry
35301
+ }));
35302
+ },
35303
+ markAvailable: async (nId, mId, artifacts) => {
35304
+ await this.availability_.update((prev) => {
35305
+ const seen = /* @__PURE__ */ new Set();
35306
+ let next = prev;
35307
+ for (const artifact of artifacts) {
35308
+ if (seen.has(artifact.format)) continue;
35309
+ seen.add(artifact.format);
35310
+ next = upsertAvailability(next, mId, nId, {
35311
+ format: artifact.format,
35312
+ sha256: "",
35313
+ bytes: Math.round(artifact.sizeMB * 1e6),
35314
+ at: Date.now()
35315
+ });
35316
+ }
35317
+ return next;
35318
+ });
35319
+ }
35320
+ }, {
35321
+ entry: descriptor.entry,
35322
+ targetFormats: ["openvino", "coreml"]
35323
+ });
35324
+ this.ctx.logger.info("Frigate+ import — engine conversions", { meta: {
35325
+ modelId: input.modelId,
35326
+ outcomes: conversions.map((o) => ({ ...o }))
35327
+ } });
35328
+ }
35329
+ }
35330
+ return {
35331
+ ok: true,
35332
+ modelId: input.modelId,
35333
+ bytes,
35334
+ conversions
35335
+ };
35336
+ }
34619
35337
  async registerCustomModel(input) {
34620
35338
  if (!input.stepId.trim()) throw new Error("registerCustomModel: stepId is required");
34621
35339
  if (!input.entry.id.trim()) throw new Error("registerCustomModel: entry.id is required");