@camstack/addon-provider-homematic 1.2.202 → 1.2.203

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 (18) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/_stub.js +2 -2
  3. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-Co16X8r0.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_page-DjEdBUbH.mjs} +4 -4
  4. package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-B48ZmMNz.mjs +26 -0
  5. package/dist/addon-provider-homematic.css +1 -1
  6. package/dist/addon.js +2466 -1261
  7. package/dist/addon.mjs +2466 -1261
  8. package/dist/{hostInit-DNi48_tT.mjs → hostInit-C5XIF453.mjs} +3 -3
  9. package/dist/remoteEntry.js +1 -1
  10. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-CWpmn0LZ.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_provider_homematic_page__remoteEntry_js-BL0O2-to.mjs} +1 -1
  11. package/dist/widgets/_stub.js +1 -1
  12. package/dist/widgets/{_virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-D7OMUSRg.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_provider_homematic_widgets-Cq-Hf-_G.mjs} +2 -2
  13. package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-Cy-JR-hp.mjs +26 -0
  14. package/dist/widgets/{hostInit-BADUDAz-.mjs → hostInit-DzuijAl4.mjs} +2 -2
  15. package/dist/widgets/remoteEntry.js +1 -1
  16. package/package.json +3 -3
  17. package/dist/_virtual_mf___mfe_internal__addon_provider_homematic_page__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CSC-ziPZ.mjs +0 -26
  18. package/dist/widgets/_virtual_mf___mfe_internal__addon_provider_homematic_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DCfwscwZ.mjs +0 -26
package/dist/addon.mjs CHANGED
@@ -6085,7 +6085,7 @@ var ZodIssueCode = {
6085
6085
  var ZodFirstPartyTypeKind;
6086
6086
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
6087
6087
  //#endregion
6088
- //#region ../types/dist/sleep-BnR9qGOv.mjs
6088
+ //#region ../types/dist/sleep-C9EWTQr9.mjs
6089
6089
  /**
6090
6090
  * The audio chunk plane's byte format, and the ONE expansion from a coded
6091
6091
  * window to float samples (D455).
@@ -18797,6 +18797,118 @@ var CAP_VOCABULARY_BY_NAME = {
18797
18797
  },
18798
18798
  unit: "°C",
18799
18799
  icon: "thermometer"
18800
+ },
18801
+ {
18802
+ kind: "numeric",
18803
+ field: "feelsLike",
18804
+ quantity: {
18805
+ en: "the feels-like temperature",
18806
+ it: "la temperatura percepita"
18807
+ },
18808
+ label: {
18809
+ en: "Feels like",
18810
+ it: "Percepita"
18811
+ },
18812
+ unit: "°C",
18813
+ icon: "thermometer"
18814
+ },
18815
+ {
18816
+ kind: "numeric",
18817
+ field: "vpd",
18818
+ quantity: {
18819
+ en: "the vapour-pressure deficit",
18820
+ it: "il deficit di pressione di vapore"
18821
+ },
18822
+ label: {
18823
+ en: "VPD",
18824
+ it: "VPD"
18825
+ },
18826
+ unit: "kPa",
18827
+ icon: "gauge"
18828
+ },
18829
+ {
18830
+ kind: "numeric",
18831
+ field: "windGustMax",
18832
+ quantity: {
18833
+ en: "the highest gust today",
18834
+ it: "la raffica massima di oggi"
18835
+ },
18836
+ label: {
18837
+ en: "Max gust",
18838
+ it: "Raffica max"
18839
+ },
18840
+ unit: "m/s",
18841
+ icon: "wind"
18842
+ },
18843
+ {
18844
+ kind: "numeric",
18845
+ field: "windBearingAvg",
18846
+ quantity: {
18847
+ en: "the average wind bearing",
18848
+ it: "la direzione media del vento"
18849
+ },
18850
+ label: {
18851
+ en: "Avg bearing",
18852
+ it: "Direzione media"
18853
+ },
18854
+ unit: "°",
18855
+ icon: "wind"
18856
+ },
18857
+ {
18858
+ kind: "numeric",
18859
+ field: "rain24h",
18860
+ quantity: {
18861
+ en: "the rain in the last 24 hours",
18862
+ it: "la pioggia delle ultime 24 ore"
18863
+ },
18864
+ label: {
18865
+ en: "Rain 24 h",
18866
+ it: "Pioggia 24 h"
18867
+ },
18868
+ unit: "mm",
18869
+ icon: "droplets"
18870
+ },
18871
+ {
18872
+ kind: "numeric",
18873
+ field: "rainWeekly",
18874
+ quantity: {
18875
+ en: "the rain this week",
18876
+ it: "la pioggia di questa settimana"
18877
+ },
18878
+ label: {
18879
+ en: "Rain week",
18880
+ it: "Pioggia settimana"
18881
+ },
18882
+ unit: "mm",
18883
+ icon: "droplets"
18884
+ },
18885
+ {
18886
+ kind: "numeric",
18887
+ field: "rainMonthly",
18888
+ quantity: {
18889
+ en: "the rain this month",
18890
+ it: "la pioggia di questo mese"
18891
+ },
18892
+ label: {
18893
+ en: "Rain month",
18894
+ it: "Pioggia mese"
18895
+ },
18896
+ unit: "mm",
18897
+ icon: "droplets"
18898
+ },
18899
+ {
18900
+ kind: "numeric",
18901
+ field: "rainYearly",
18902
+ quantity: {
18903
+ en: "the rain this year",
18904
+ it: "la pioggia di quest’anno"
18905
+ },
18906
+ label: {
18907
+ en: "Rain year",
18908
+ it: "Pioggia anno"
18909
+ },
18910
+ unit: "mm",
18911
+ icon: "droplets"
18800
18912
  }
18801
18913
  ]
18802
18914
  },
@@ -19450,6 +19562,10 @@ var CAP_VOCABULARY_BY_NAME = {
19450
19562
  scope: "system",
19451
19563
  notOperatorFacing: "cluster administration — nodes, server package, metrics"
19452
19564
  },
19565
+ "tags": {
19566
+ scope: "system",
19567
+ notOperatorFacing: "tags are managed from the tag picker and the tags manager, not actuated"
19568
+ },
19453
19569
  "template": {
19454
19570
  scope: "system",
19455
19571
  notOperatorFacing: "operator-authored templates — edited in their own editor, never actuated"
@@ -19889,6 +20005,7 @@ var CAP_NAMES = Object.freeze([
19889
20005
  "stream-signals",
19890
20006
  "switch",
19891
20007
  "system",
20008
+ "tags",
19892
20009
  "tamper",
19893
20010
  "temperature-sensor",
19894
20011
  "template",
@@ -21959,6 +22076,38 @@ Object.freeze({
21959
22076
  {
21960
22077
  "path": "dewPoint",
21961
22078
  "valueType": "number"
22079
+ },
22080
+ {
22081
+ "path": "feelsLike",
22082
+ "valueType": "number"
22083
+ },
22084
+ {
22085
+ "path": "vpd",
22086
+ "valueType": "number"
22087
+ },
22088
+ {
22089
+ "path": "windGustMax",
22090
+ "valueType": "number"
22091
+ },
22092
+ {
22093
+ "path": "windBearingAvg",
22094
+ "valueType": "number"
22095
+ },
22096
+ {
22097
+ "path": "rain24h",
22098
+ "valueType": "number"
22099
+ },
22100
+ {
22101
+ "path": "rainWeekly",
22102
+ "valueType": "number"
22103
+ },
22104
+ {
22105
+ "path": "rainMonthly",
22106
+ "valueType": "number"
22107
+ },
22108
+ {
22109
+ "path": "rainYearly",
22110
+ "valueType": "number"
21962
22111
  }
21963
22112
  ],
21964
22113
  "zone-analytics": [
@@ -23637,6 +23786,384 @@ function tryConvertUnit(value, from, to) {
23637
23786
  return fromCanonical(toCanonical(value, fromSpec), toSpec);
23638
23787
  }
23639
23788
  //#endregion
23789
+ //#region ../types/dist/device-template-catalogue.mjs
23790
+ /**
23791
+ * The one catalogue of what a device template may name (D1021, D1029).
23792
+ *
23793
+ * Filters, the `range` global and the reserved names (`now`, `camera`, the
23794
+ * caller's recognition values) are listed here. The grammar's allow-list and
23795
+ * argument caps are derived from this module; nothing else keeps a second list.
23796
+ * The renderer imports this module through the
23797
+ * `@camstack/types/device-template-catalogue` subpath, never the types barrel
23798
+ * (D453), and sends the derived caps to the worker. The worker does not import it.
23799
+ */
23800
+ var DEVICE_TEMPLATE_CATALOGUE_KINDS = [
23801
+ "filter",
23802
+ "global",
23803
+ "variable"
23804
+ ];
23805
+ var DEVICE_TEMPLATE_CATALOGUE_CATEGORIES = [
23806
+ "number",
23807
+ "unit",
23808
+ "text",
23809
+ "state",
23810
+ "time",
23811
+ "fallback",
23812
+ "loop",
23813
+ "variable"
23814
+ ];
23815
+ var DEVICE_TEMPLATE_PARAM_TYPES = [
23816
+ "string",
23817
+ "number",
23818
+ "boolean"
23819
+ ];
23820
+ /**
23821
+ * Where the values a parameter takes come from, when a fixed set makes sense.
23822
+ * `units-of-field` is the units in the dimension of the piped field's unit;
23823
+ * `choices` is a named list (a time pattern); `range` is the numbers
23824
+ * `min…max` by `step`. An absent source means free input.
23825
+ */
23826
+ var deviceTemplateParamValuesSchemaValue = discriminatedUnion("kind", [
23827
+ object({ kind: literal("units-of-field") }),
23828
+ object({
23829
+ kind: literal("choices"),
23830
+ options: array(object({
23831
+ value: string(),
23832
+ labelKey: string().min(1)
23833
+ })).min(1)
23834
+ }),
23835
+ object({
23836
+ kind: literal("range"),
23837
+ min: number$1(),
23838
+ max: number$1(),
23839
+ step: number$1().positive()
23840
+ })
23841
+ ]);
23842
+ var deviceTemplateParamSchema = object({
23843
+ name: string().min(1),
23844
+ type: _enum(DEVICE_TEMPLATE_PARAM_TYPES),
23845
+ optional: boolean(),
23846
+ default: union([
23847
+ string(),
23848
+ number$1(),
23849
+ boolean()
23850
+ ]).optional(),
23851
+ values: deviceTemplateParamValuesSchemaValue.optional()
23852
+ });
23853
+ object({
23854
+ name: string().min(1),
23855
+ kind: _enum(DEVICE_TEMPLATE_CATALOGUE_KINDS),
23856
+ category: _enum(DEVICE_TEMPLATE_CATALOGUE_CATEGORIES),
23857
+ params: array(deviceTemplateParamSchema),
23858
+ descriptionKey: string().min(1),
23859
+ exampleKey: string().min(1)
23860
+ });
23861
+ function param(name, type, optional, fallback, values) {
23862
+ const base = fallback === void 0 ? {
23863
+ name,
23864
+ type,
23865
+ optional
23866
+ } : {
23867
+ name,
23868
+ type,
23869
+ optional,
23870
+ default: fallback
23871
+ };
23872
+ return values === void 0 ? base : {
23873
+ ...base,
23874
+ values
23875
+ };
23876
+ }
23877
+ function entry(name, kind, category, params) {
23878
+ return {
23879
+ name,
23880
+ kind,
23881
+ category,
23882
+ params: [...params],
23883
+ descriptionKey: `uiLibrary.deviceTemplateCatalogue.${name}.description`,
23884
+ exampleKey: `uiLibrary.deviceTemplateCatalogue.${name}.example`
23885
+ };
23886
+ }
23887
+ var DIGITS = param("digits", "number", true, 0, {
23888
+ kind: "range",
23889
+ min: 0,
23890
+ max: 4,
23891
+ step: 1
23892
+ });
23893
+ var UNITS_OF_FIELD = { kind: "units-of-field" };
23894
+ /** Named time patterns: the engine's tokens are `YYYY MM DD HH mm ss`. */
23895
+ var TIME_PATTERNS = [
23896
+ [
23897
+ "hm",
23898
+ "HH:mm",
23899
+ "Hours and minutes (14:05)",
23900
+ "Ore e minuti (14:05)"
23901
+ ],
23902
+ [
23903
+ "hms",
23904
+ "HH:mm:ss",
23905
+ "Hours, minutes, seconds (14:05:09)",
23906
+ "Ore, minuti, secondi (14:05:09)"
23907
+ ],
23908
+ [
23909
+ "dm",
23910
+ "DD/MM",
23911
+ "Day and month (31/12)",
23912
+ "Giorno e mese (31/12)"
23913
+ ],
23914
+ [
23915
+ "dmy",
23916
+ "DD/MM/YYYY",
23917
+ "Day, month, year (31/12/2026)",
23918
+ "Giorno, mese, anno (31/12/2026)"
23919
+ ],
23920
+ [
23921
+ "dmyhm",
23922
+ "DD/MM/YYYY HH:mm",
23923
+ "Date and time (31/12/2026 14:05)",
23924
+ "Data e ora (31/12/2026 14:05)"
23925
+ ],
23926
+ [
23927
+ "iso",
23928
+ "YYYY-MM-DD",
23929
+ "ISO date (2026-12-31)",
23930
+ "Data ISO (2026-12-31)"
23931
+ ],
23932
+ [
23933
+ "isohms",
23934
+ "YYYY-MM-DD HH:mm:ss",
23935
+ "ISO date and time (2026-12-31 14:05:09)",
23936
+ "Data e ora ISO (2026-12-31 14:05:09)"
23937
+ ]
23938
+ ];
23939
+ var TIME_PATTERN_KEY = (id) => `uiLibrary.deviceTemplateCatalogue.choice.time.${id}`;
23940
+ var TIME_PATTERN_VALUES = {
23941
+ kind: "choices",
23942
+ options: TIME_PATTERNS.map(([id, pattern]) => ({
23943
+ value: pattern,
23944
+ labelKey: TIME_PATTERN_KEY(id)
23945
+ }))
23946
+ };
23947
+ var FALLBACK_TEXT = param("fallback", "string", false);
23948
+ var FALSY = param("falsy", "boolean", true, false);
23949
+ /** Every name the engine allows, in the order operators meet them. */
23950
+ var DEVICE_TEMPLATE_CATALOGUE = [
23951
+ entry("unit", "filter", "unit", [param("symbol", "string", false, void 0, UNITS_OF_FIELD), param("from", "string", true, void 0, UNITS_OF_FIELD)]),
23952
+ entry("round", "filter", "number", [DIGITS]),
23953
+ entry("trunc", "filter", "number", [DIGITS]),
23954
+ entry("onoff", "filter", "state", []),
23955
+ entry("default", "filter", "fallback", [FALLBACK_TEXT, FALSY]),
23956
+ entry("since", "filter", "time", []),
23957
+ entry("ago", "filter", "time", []),
23958
+ entry("format", "filter", "text", [param("pattern", "string", false)]),
23959
+ entry("upper", "filter", "text", []),
23960
+ entry("lower", "filter", "text", []),
23961
+ entry("title", "filter", "text", []),
23962
+ entry("capitalize", "filter", "text", []),
23963
+ entry("trim", "filter", "text", []),
23964
+ entry("abs", "filter", "number", []),
23965
+ entry("int", "filter", "number", [param("fallback", "number", true, 0)]),
23966
+ entry("float", "filter", "number", [param("fallback", "number", true, 0)]),
23967
+ entry("length", "filter", "text", []),
23968
+ entry("d", "filter", "fallback", [FALLBACK_TEXT, FALSY]),
23969
+ entry("join", "filter", "text", [param("separator", "string", true, "")]),
23970
+ entry("replace", "filter", "text", [
23971
+ param("old", "string", false),
23972
+ param("new", "string", false),
23973
+ param("count", "number", true)
23974
+ ]),
23975
+ entry("first", "filter", "loop", []),
23976
+ entry("last", "filter", "loop", []),
23977
+ entry("sort", "filter", "loop", [param("reverse", "boolean", true, false), param("caseSensitive", "boolean", true, false)]),
23978
+ entry("reverse", "filter", "loop", []),
23979
+ entry("sum", "filter", "number", []),
23980
+ entry("string", "filter", "text", []),
23981
+ entry("list", "filter", "loop", []),
23982
+ entry("truncate", "filter", "text", [
23983
+ param("length", "number", false),
23984
+ param("killwords", "boolean", true, false),
23985
+ param("end", "string", true, "…")
23986
+ ]),
23987
+ entry("time", "filter", "time", [param("pattern", "string", false, void 0, TIME_PATTERN_VALUES)]),
23988
+ entry("range", "global", "loop", [
23989
+ param("stop", "number", false),
23990
+ param("start", "number", true, 0),
23991
+ param("step", "number", true, 1)
23992
+ ]),
23993
+ entry("now", "variable", "time", []),
23994
+ entry("camera", "variable", "variable", []),
23995
+ entry("loop", "variable", "loop", []),
23996
+ entry("lastPerson", "variable", "variable", []),
23997
+ entry("lastPlate", "variable", "variable", [])
23998
+ ];
23999
+ var COPY = {
24000
+ unit: {
24001
+ description: ["Converts a number from the field’s base unit and prints the symbol.", "Converte un numero dall’unità di base del campo e stampa il simbolo."],
24002
+ example: ["{{ garage.temperature | unit('°C') }}", "{{ garage.temperature | unit('°C') }}"]
24003
+ },
24004
+ round: {
24005
+ description: ["Rounds a number to the given decimals.", "Arrotonda un numero ai decimali indicati."],
24006
+ example: ["{{ garage.temperature | round(1) }}", "{{ garage.temperature | round(1) }}"]
24007
+ },
24008
+ trunc: {
24009
+ description: ["Cuts decimals toward zero, without rounding.", "Taglia i decimali verso zero, senza arrotondare."],
24010
+ example: ["{{ garage.temperature | trunc(1) }}", "{{ garage.temperature | trunc(1) }}"]
24011
+ },
24012
+ onoff: {
24013
+ description: ["Prints a boolean as ON or OFF.", "Stampa un sì/no come ON oppure OFF."],
24014
+ example: ["{{ garage.switch | onoff }}", "{{ garage.switch | onoff }}"]
24015
+ },
24016
+ default: {
24017
+ description: ["Replaces a missing value. The second argument also replaces a false or zero.", "Sostituisce un valore assente. Il secondo argomento sostituisce anche falso o zero."],
24018
+ example: ["{{ camera.lastPerson | default('') }}", "{{ camera.lastPerson | default('') }}"]
24019
+ },
24020
+ since: {
24021
+ description: ["How long ago a timestamp was, as “5 min”.", "Quanto tempo fa era un istante, come «5 min»."],
24022
+ example: ["{{ garage.updated | since }}", "{{ garage.updated | since }}"]
24023
+ },
24024
+ ago: {
24025
+ description: ["The same duration as since, followed by “ago”.", "La stessa durata di since, seguita da «ago»."],
24026
+ example: ["{{ garage.updated | ago }}", "{{ garage.updated | ago }}"]
24027
+ },
24028
+ format: {
24029
+ description: ["Prints one value with a single %s, %d or %.Nf placeholder.", "Stampa un valore con un solo segnaposto %s, %d o %.Nf."],
24030
+ example: ["{{ garage.temperature | format('%.1f') }}", "{{ garage.temperature | format('%.1f') }}"]
24031
+ },
24032
+ upper: {
24033
+ description: ["Uppercase text.", "Testo in maiuscolo."],
24034
+ example: ["{{ camera.lastPerson | upper }}", "{{ camera.lastPerson | upper }}"]
24035
+ },
24036
+ lower: {
24037
+ description: ["Lowercase text.", "Testo in minuscolo."],
24038
+ example: ["{{ camera.lastPlate | lower }}", "{{ camera.lastPlate | lower }}"]
24039
+ },
24040
+ title: {
24041
+ description: ["Capitalises each word.", "Mette la maiuscola a ogni parola."],
24042
+ example: ["{{ camera.lastPerson | title }}", "{{ camera.lastPerson | title }}"]
24043
+ },
24044
+ capitalize: {
24045
+ description: ["Capitalises the first letter.", "Mette la maiuscola alla prima lettera."],
24046
+ example: ["{{ camera.lastPerson | capitalize }}", "{{ camera.lastPerson | capitalize }}"]
24047
+ },
24048
+ trim: {
24049
+ description: ["Removes spaces at both ends.", "Toglie gli spazi alle estremità."],
24050
+ example: ["{{ camera.lastPerson | trim }}", "{{ camera.lastPerson | trim }}"]
24051
+ },
24052
+ abs: {
24053
+ description: ["The absolute value of a number.", "Il valore assoluto di un numero."],
24054
+ example: ["{{ garage.power | abs }}", "{{ garage.power | abs }}"]
24055
+ },
24056
+ int: {
24057
+ description: ["The whole part of a number.", "La parte intera di un numero."],
24058
+ example: ["{{ garage.temperature | int }}", "{{ garage.temperature | int }}"]
24059
+ },
24060
+ float: {
24061
+ description: ["Reads the value as a decimal number.", "Legge il valore come numero decimale."],
24062
+ example: ["{{ garage.temperature | float }}", "{{ garage.temperature | float }}"]
24063
+ },
24064
+ length: {
24065
+ description: ["How many characters or items.", "Quanti caratteri o elementi."],
24066
+ example: ["{{ camera.lastPerson | length }}", "{{ camera.lastPerson | length }}"]
24067
+ },
24068
+ d: {
24069
+ description: ["The short name of default.", "Il nome breve di default."],
24070
+ example: ["{{ camera.lastPerson | d('') }}", "{{ camera.lastPerson | d('') }}"]
24071
+ },
24072
+ join: {
24073
+ description: ["Joins a list with a separator.", "Unisce un elenco con un separatore."],
24074
+ example: ["{{ range(3) | join(', ') }}", "{{ range(3) | join(', ') }}"]
24075
+ },
24076
+ replace: {
24077
+ description: ["Replaces text, optionally only the first few times.", "Sostituisce del testo, volendo solo le prime volte."],
24078
+ example: ["{{ camera.lastPlate | replace(' ', '') }}", "{{ camera.lastPlate | replace(' ', '') }}"]
24079
+ },
24080
+ first: {
24081
+ description: ["The first item of a list.", "Il primo elemento di un elenco."],
24082
+ example: ["{{ range(3) | first }}", "{{ range(3) | first }}"]
24083
+ },
24084
+ last: {
24085
+ description: ["The last item of a list.", "L’ultimo elemento di un elenco."],
24086
+ example: ["{{ range(3) | last }}", "{{ range(3) | last }}"]
24087
+ },
24088
+ sort: {
24089
+ description: ["Sorts a list. The arguments reverse it or keep case.", "Ordina un elenco. Gli argomenti lo invertono o rispettano le maiuscole."],
24090
+ example: ["{{ range(3) | reverse | sort }}", "{{ range(3) | reverse | sort }}"]
24091
+ },
24092
+ reverse: {
24093
+ description: ["Reverses a list.", "Inverte un elenco."],
24094
+ example: ["{{ range(3) | reverse }}", "{{ range(3) | reverse }}"]
24095
+ },
24096
+ sum: {
24097
+ description: ["Adds the numbers in a list.", "Somma i numeri di un elenco."],
24098
+ example: ["{{ range(3) | sum }}", "{{ range(3) | sum }}"]
24099
+ },
24100
+ string: {
24101
+ description: ["Prints the value as text.", "Stampa il valore come testo."],
24102
+ example: ["{{ garage.temperature | string }}", "{{ garage.temperature | string }}"]
24103
+ },
24104
+ list: {
24105
+ description: ["Wraps the value in a list.", "Mette il valore in un elenco."],
24106
+ example: ["{{ garage.temperature | list }}", "{{ garage.temperature | list }}"]
24107
+ },
24108
+ truncate: {
24109
+ description: ["Shortens text to a length, with an ending.", "Accorcia il testo a una lunghezza, con una chiusura."],
24110
+ example: ["{{ camera.lastPerson | truncate(12) }}", "{{ camera.lastPerson | truncate(12) }}"]
24111
+ },
24112
+ time: {
24113
+ description: ["Prints a timestamp in the server’s time zone. Tokens: YYYY MM DD HH mm ss.", "Stampa un istante nel fuso del server. Segni: YYYY MM DD HH mm ss."],
24114
+ example: ["{{ now | time('HH:mm') }}", "{{ now | time('HH:mm') }}"]
24115
+ },
24116
+ range: {
24117
+ description: ["The integers up to stop, or from start to stop by step. At most 1000 items.", "Gli interi fino a stop, oppure da start a stop con step. Al massimo 1000 elementi."],
24118
+ example: ["{% for i in range(3) %}{{ i }}{% endfor %}", "{% for i in range(3) %}{{ i }}{% endfor %}"]
24119
+ },
24120
+ now: {
24121
+ description: ["The hub clock. A bare now prints ISO; time prints a pattern.", "L’orologio dell’hub. now da solo stampa ISO; time stampa un formato."],
24122
+ example: ["{{ now | time('HH:mm') }}", "{{ now | time('HH:mm') }}"]
24123
+ },
24124
+ camera: {
24125
+ description: ["The device this text is written for. It stays correct when the text is copied to another camera.", "Il dispositivo per cui è scritto il testo. Resta corretto se il testo viene copiato su un’altra telecamera."],
24126
+ example: ["{{ camera.temperature }}", "{{ camera.temperature }}"]
24127
+ },
24128
+ loop: {
24129
+ description: ["The for-loop counter (index, length) inside {% for %}.", "Il contatore del ciclo (index, length) dentro {% for %}."],
24130
+ example: ["{% for i in range(3) %}{{ loop.index }}{% endfor %}", "{% for i in range(3) %}{{ loop.index }}{% endfor %}"]
24131
+ },
24132
+ lastPerson: {
24133
+ description: ["The last person recognised on this camera, empty until there is one.", "L’ultima persona riconosciuta su questa telecamera, vuota finché non ce n’è una."],
24134
+ example: ["{{ camera.lastPerson }}", "{{ camera.lastPerson }}"]
24135
+ },
24136
+ lastPlate: {
24137
+ description: ["The last plate recognised on this camera, empty until there is one.", "L’ultima targa riconosciuta su questa telecamera, vuota finché non ce n’è una."],
24138
+ example: ["{{ camera.lastPlate }}", "{{ camera.lastPlate }}"]
24139
+ }
24140
+ };
24141
+ function buildText() {
24142
+ const out = {};
24143
+ for (const item of DEVICE_TEMPLATE_CATALOGUE) {
24144
+ const row = COPY[item.name];
24145
+ if (row === void 0) continue;
24146
+ out[item.descriptionKey] = {
24147
+ en: row.description[0],
24148
+ it: row.description[1]
24149
+ };
24150
+ out[item.exampleKey] = {
24151
+ en: row.example[0],
24152
+ it: row.example[1]
24153
+ };
24154
+ }
24155
+ for (const [id, , en, it] of TIME_PATTERNS) out[TIME_PATTERN_KEY(id)] = {
24156
+ en,
24157
+ it
24158
+ };
24159
+ return out;
24160
+ }
24161
+ buildText();
24162
+ /** Names a template may use after `|`. Order matches the catalogue. */
24163
+ function deviceTemplateFilterNames() {
24164
+ return DEVICE_TEMPLATE_CATALOGUE.filter((item) => item.kind === "filter").map((item) => item.name);
24165
+ }
24166
+ //#endregion
23640
24167
  //#region ../types/dist/index.mjs
23641
24168
  var SMTP_INBOUND_DEFAULT_PORT = 2525;
23642
24169
  var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
@@ -27375,967 +27902,6 @@ var LogChannelWindowSchema = object({
27375
27902
  /** `null` = every camera. A non-empty list narrows to those numeric ids. */
27376
27903
  deviceIds: array(number$1().int()).readonly().nullable()
27377
27904
  });
27378
- var ClipModelMetaSchema = object({
27379
- /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
27380
- textModelId: string().min(1),
27381
- /** Output dimension of BOTH towers. A vector of any other length is refused. */
27382
- embeddingDim: number$1().int().positive(),
27383
- /**
27384
- * The `vector-store` index this model's vectors live in. ONE feature space
27385
- * per index: two models share an index only when their vectors are ranked
27386
- * against each other, which for CLIP means never across families. Every
27387
- * model gets its own.
27388
- */
27389
- vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
27390
- /**
27391
- * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
27392
- * must be unique per tokenizer: every model's siblings land in ONE flat
27393
- * models directory, so two different tokenizers under the same name would
27394
- * silently overwrite each other (whichever model downloaded last wins, and
27395
- * the other one tokenises with the wrong vocabulary).
27396
- */
27397
- tokenizerFile: string().min(1),
27398
- /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
27399
- contextLength: number$1().int().positive(),
27400
- /** Id the tokenizer pads with. */
27401
- padId: number$1().int().nonnegative(),
27402
- /**
27403
- * The search cosine floor at `strictness: 'loose'` — calibrated per model,
27404
- * because cosine bands are a property of the model: 0.2 keeps 96% of matched
27405
- * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
27406
- */
27407
- searchMinScore: number$1().min(0).max(1)
27408
- });
27409
- var ClipSearchStrictnessSchema = _enum([
27410
- "loose",
27411
- "balanced",
27412
- "strict"
27413
- ]);
27414
- /** Steps whose effect a root label can BE. */
27415
- var LABEL_SUPPLY_STEP_IDS = [
27416
- "animal-classifier",
27417
- "vehicle-classifier",
27418
- "package-detection"
27419
- ];
27420
- /** Steps whose box a root detection can BE. */
27421
- var CROP_SUPPLY_STEP_IDS = ["plate-detection", "face-detection"];
27422
- /**
27423
- * Steps whose per-detection MASK a root detection can carry (D737). The live
27424
- * mask step is `segmentation` — a frame-plane refiner that runs its own model
27425
- * once per detection crop. (`instance-segmentation` is a dormant step id that
27426
- * no camera tree carries.)
27427
- */
27428
- var MASK_SUPPLY_STEP_IDS = ["segmentation"];
27429
- [
27430
- ...LABEL_SUPPLY_STEP_IDS,
27431
- ...CROP_SUPPLY_STEP_IDS,
27432
- ...MASK_SUPPLY_STEP_IDS
27433
- ];
27434
- /**
27435
- * Multi-file format payload.
27436
- *
27437
- * - Directory formats (`isDirectory: true`, e.g. `.mlpackage`): files
27438
- * relative to the directory root — the downloader fetches each from
27439
- * `{url}/{file}` into `{modelDir}/{file}`. If omitted, it probes the
27440
- * HuggingFace API (slower).
27441
- * - Single-file formats (no `isDirectory`, e.g. OpenVINO IR): sibling
27442
- * files fetched from the SAME remote directory as `url` and stored flat
27443
- * alongside the main file — e.g. `['camstack-yolov9t.bin']` for the IR
27444
- * weights next to `camstack-yolov9t.xml`.
27445
- */
27446
- var ModelFormatEntrySchema = object({
27447
- url: string(),
27448
- sizeMB: number$1(),
27449
- /** Whether this format is a directory bundle (e.g., .mlpackage) rather than a single file */
27450
- isDirectory: boolean().optional(),
27451
- /** Multi-file payload (directory members or sibling files). */
27452
- files: array(string()).readonly().optional(),
27453
- /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
27454
- runtimes: array(_enum(["python"])).readonly().optional(),
27455
- /**
27456
- * Content revision of the artefact, for one hosted OFF the CamStack mirror.
27457
- * A format on the mirror leaves it unset: its revision (the sha256 of its
27458
- * weight file) comes from the downloader's generated table, kept in step
27459
- * with the mirror by `scripts/check-hosted-model-revisions.ts` (D744). A
27460
- * node records the revision it downloaded next to the file
27461
- * (`<file>.revision`); a copy with no record or a different one is stale
27462
- * unless its weight file hashes to the revision, and a stale copy is
27463
- * downloaded again, the old one serving until the new one is complete. No
27464
- * revision at all ⇒ a file on disk is current, whatever it holds (D743).
27465
- */
27466
- revision: string().min(1).optional()
27467
- });
27468
- /**
27469
- * What a node holds for one (model, format) (D746). `current` is a complete
27470
- * copy at its catalog revision — exactly what `downloaded: true` means.
27471
- * `stale` is bytes on disk that are not (yet) proven current under D743/D744:
27472
- * no or a different revision record, or a missing sibling. `missing` is no
27473
- * copy. `downloaded` alone folds `stale` into "not downloaded", which hid
27474
- * reclaimable bytes and a copy about to be replaced.
27475
- */
27476
- var ModelOnDiskStateSchema = _enum([
27477
- "current",
27478
- "stale",
27479
- "missing"
27480
- ]);
27481
- /**
27482
- * The numeric precision of one format's BUILD (D746) — reported only when the
27483
- * build states it (file-name token, an INT8 variant, an EdgeTPU compile, a
27484
- * CamStack Core ML export). Absent means "not stated", never "fp32".
27485
- */
27486
- var ModelFormatPrecisionSchema = _enum([
27487
- "fp32",
27488
- "fp16",
27489
- "int8"
27490
- ]);
27491
- /**
27492
- * One format of one model as a node's `pipelineExecutor.getSchema` reports it.
27493
- * `onDisk` / `precision` are optional for version skew: a runner that predates
27494
- * them omits them, and a reader falls back to `downloaded`.
27495
- */
27496
- var PipelineModelFormatStatusSchema = object({
27497
- downloaded: boolean(),
27498
- sizeMB: number$1(),
27499
- onDisk: ModelOnDiskStateSchema.optional(),
27500
- precision: ModelFormatPrecisionSchema.optional()
27501
- });
27502
- /**
27503
- * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
27504
- * The downloader fetches from `url` and saves to `{modelsDir}/{filename}`.
27505
- */
27506
- var ModelExtraFileSchema = object({
27507
- url: string(),
27508
- filename: string(),
27509
- sizeMB: number$1()
27510
- });
27511
- /**
27512
- * Per-format payload map. Modelled as an explicit object (one optional key
27513
- * per `ModelFormat`) rather than `z.record(enum, …)` — zod v4's enum-keyed
27514
- * record requires every key, but a catalog entry only ships a subset of
27515
- * formats.
27516
- */
27517
- var ModelFormatsSchema = object({
27518
- onnx: ModelFormatEntrySchema.optional(),
27519
- coreml: ModelFormatEntrySchema.optional(),
27520
- openvino: ModelFormatEntrySchema.optional(),
27521
- tflite: ModelFormatEntrySchema.optional(),
27522
- pt: ModelFormatEntrySchema.optional(),
27523
- gguf: ModelFormatEntrySchema.optional()
27524
- });
27525
- /**
27526
- * Variant-selector grouping axes. Shared by the full `ModelCatalogEntry` and by
27527
- * the reduced `PipelineModelOption` returned in `pipeline.getSchema()` so the
27528
- * grouped Family→Tier→Variant picker renders identically in the config UI and
27529
- * in the pipeline/device steppers. The flat `id` stays the source of truth for
27530
- * resolution/download/persistence; this is a presentation overlay resolved back
27531
- * to an `id`.
27532
- */
27533
- var ModelVariantGroupSchema = object({
27534
- /** Top-level family, e.g. `yolo26` (later `d-fine`, `rf-detr`). */
27535
- family: string(),
27536
- /** Size within the family, e.g. `n` | `s` | `m` | `l`. */
27537
- tier: string(),
27538
- /** Quantization axis. Omit ⇒ the fp32 base build. */
27539
- precision: _enum(["fp32", "int8"]).optional(),
27540
- /**
27541
- * Training / latency-variant axis. Omit ⇒ the standard build. `test` marks
27542
- * an alternate training of the same family (plugin catalog `relu_test`); chip
27543
- * label is "Test".
27544
- */
27545
- optimization: _enum(["standard", "test"]).optional(),
27546
- /**
27547
- * Input-resolution axis (square input side, px). Omit ⇒ the family's native
27548
- * resolution (640 for yolo26). Reduced-input builds (320 / 256) are a big,
27549
- * cheap latency lever — especially on Apple ANE and the Intel N100 — at a
27550
- * small-object accuracy cost. Mirrors the model's `inputSize` but lifted onto
27551
- * the group so the selector can offer it as a variant axis.
27552
- */
27553
- resolution: number$1().int().positive().optional()
27554
- });
27555
- var ModelProviderIdSchema = _enum([
27556
- "camstack",
27557
- "frigate",
27558
- "scrypted",
27559
- "custom"
27560
- ]);
27561
- /**
27562
- * The licence of a model, as a record rather than a bare SPDX string: a
27563
- * permissive CODE licence routinely sits on top of restrictive WEIGHTS or
27564
- * DATA, and the obligations (attribution, modification notices, source offers)
27565
- * are per upstream. A persisted custom-model row written when this field was a
27566
- * string still parses — the string is lifted into `{ weights }`.
27567
- *
27568
- * Every machine licence surface (`THIRD_PARTY_MODELS.md`, the Hugging Face
27569
- * model table) is GENERATED from these records by
27570
- * `scripts/gen-model-licenses.ts` (D661). Operator-facing docs live in
27571
- * `camstack/docs` → `/docs/detection/models`.
27572
- */
27573
- var ModelLicenseSchema = preprocess((value) => typeof value === "string" ? { weights: value } : value, object({
27574
- /** SPDX id of the WEIGHTS' terms, a `LicenseRef-*` for non-SPDX terms, or `UNKNOWN`. */
27575
- weights: string().min(1),
27576
- /** SPDX id of the upstream code that defines / trained the network. */
27577
- code: string().min(1).optional(),
27578
- /** Training data whose terms add obligations (attribution, non-commercial). */
27579
- data: object({
27580
- name: string().min(1),
27581
- terms: string().min(1),
27582
- url: string().url().optional()
27583
- }).optional(),
27584
- /** The project the weights come from. Required on built-in entries (guard). */
27585
- upstream: object({
27586
- name: string().min(1),
27587
- url: string().url()
27588
- }).optional(),
27589
- /** Where the licence text governing the weights is published. */
27590
- url: string().url().optional(),
27591
- /** Attribution the licence REQUIRES, verbatim. */
27592
- attribution: string().min(1).optional(),
27593
- /** What CamStack changed. Required when `hosting` is `camstack-hf` (guard). */
27594
- modifications: string().min(1).optional(),
27595
- /** Who serves the file a node downloads. */
27596
- hosting: _enum([
27597
- "camstack-hf",
27598
- "third-party",
27599
- "built-in"
27600
- ]).optional(),
27601
- /** True when the weights or their data forbid commercial use. */
27602
- nonCommercial: boolean().optional()
27603
- }));
27604
- /**
27605
- * One step a ROOT detector can supply from its own output (D730) — see
27606
- * `ModelCatalogEntry.suppliesSteps`.
27607
- *
27608
- * - `label`: the root's raw class IS the step's answer. `labelToEffect` maps
27609
- * the root's label to the step's vocabulary; `uncovered` is the vocabulary
27610
- * the root cannot produce (shown as unavailable, never a blocker).
27611
- * - `crop`: the root draws the box the step would have found (`license_plate`
27612
- * for plate-detection, `face` for face-detection). The box becomes a detail
27613
- * child of the `parentMacro` detection that contains it — never a track.
27614
- * - `mask`: the root's decode emits an instance mask with every detection (a
27615
- * YOLO26-seg root, D737) — the `segmentation` step's result, carried on the
27616
- * detection in the shape that step produces. Derived from the model's
27617
- * postprocessor on read, never stored by an import.
27618
- */
27619
- var RootStepSupplySchema = discriminatedUnion("kind", [
27620
- object({
27621
- kind: literal("label"),
27622
- stepId: _enum(LABEL_SUPPLY_STEP_IDS),
27623
- labelToEffect: record$1(string(), string()),
27624
- uncovered: array(string()).readonly()
27625
- }),
27626
- object({
27627
- kind: literal("crop"),
27628
- stepId: _enum(CROP_SUPPLY_STEP_IDS),
27629
- rootLabels: array(string()).readonly(),
27630
- parentMacro: _enum(["vehicle", "person"]),
27631
- childClass: _enum(["plate", "face"]),
27632
- /**
27633
- * The root's smaller input side, stamped on read by `rootSuppliesOf` from
27634
- * the model entry — what a step's `minRootInputPx` gate judges. Never
27635
- * stored by an import.
27636
- */
27637
- rootInputPx: number$1().int().positive().optional()
27638
- }),
27639
- object({
27640
- kind: literal("mask"),
27641
- stepId: _enum(MASK_SUPPLY_STEP_IDS)
27642
- })
27643
- ]);
27644
- var ModelCatalogEntrySchema = object({
27645
- id: string(),
27646
- name: string(),
27647
- description: string(),
27648
- formats: ModelFormatsSchema,
27649
- inputSize: object({
27650
- width: number$1(),
27651
- height: number$1()
27652
- }),
27653
- /**
27654
- * Channel count of the model input tensor. Omit ⇒ 3 (RGB), the default for
27655
- * every detector / classifier / embedder. Set to 1 for a grayscale CTC text
27656
- * recognizer (EasyOCR VGG plate-OCR: input `[N,1,H,W]`) so the preprocess
27657
- * feeds a single-channel, EasyOCR-normalized tensor instead of the default
27658
- * 3-channel RGB one. Threaded through `PoolModelConfig.inputChannels` to the
27659
- * Python inference pool.
27660
- */
27661
- inputChannels: number$1().int().positive().optional(),
27662
- labels: array(LabelDefinitionSchema).readonly(),
27663
- inputLayout: _enum(["nchw", "nhwc"]).optional(),
27664
- /**
27665
- * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
27666
- * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
27667
- * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
27668
- * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
27669
- */
27670
- inputNormalization: _enum([
27671
- "zero-one",
27672
- "imagenet",
27673
- "none",
27674
- "scrfd"
27675
- ]).optional(),
27676
- /**
27677
- * The model already applies softmax IN-GRAPH — its raw output is a
27678
- * probability distribution, not logits. When set, the `softmax`
27679
- * postprocessor must NOT re-apply softmax: re-softmaxing an already-normalised
27680
- * probability vector collapses it toward uniform (top-1 score craters far
27681
- * below its true value, making every confidence gate meaningless). Absent ⇒
27682
- * the output is raw logits and the postprocessor applies softmax (the normal
27683
- * case). Set on the Google AIY Birds `bird-classifier` (softmax baked into the
27684
- * TF graph). Threaded to the Python pool via `PoolModelConfig.outputProbabilities`.
27685
- */
27686
- outputProbabilities: boolean().optional(),
27687
- preprocessMode: _enum(["letterbox", "resize"]).optional(),
27688
- /**
27689
- * Per-MODEL postprocessor override. Absent ⇒ the step's own
27690
- * `StepDefinition.postprocessor` applies (the normal case — every model in a
27691
- * step shares its decode). Set it when a step hosts models with DIFFERENT raw
27692
- * output layouts under one slot: e.g. object-detection is `'yolo'` by default,
27693
- * but a Coral SSD MobileNet build emits the `TFLite_Detection_PostProcess`
27694
- * 4-tensor layout and needs `'ssd'`. Threaded into `PoolModelConfig.postprocessor`
27695
- * by the engine factory (`modelEntry.postprocessor ?? def.postprocessor`).
27696
- */
27697
- postprocessor: custom().optional(),
27698
- /**
27699
- * Per-MODEL default confidence floor. Absent ⇒ the step's
27700
- * `StepDefinition.defaultConfidence` applies. A score is a property of one
27701
- * model's output scale, not of the step slot it sits in: YuNet's
27702
- * `sqrt(cls·obj)` is not SCRFD's score, and inheriting SCRFD's 0.5 filled the
27703
- * face gallery with wheels and hands (D662, amends D645). An operator's
27704
- * explicit value still wins over it. Resolved in ONE place —
27705
- * `addon-pipeline/.../registry/effective-confidence.ts`.
27706
- */
27707
- defaultConfidence: number$1().min(0).max(1).optional(),
27708
- /**
27709
- * Per-MODEL default of the per-class confidence floors (`minConfidence<Macro>`
27710
- * on a detector step), keyed by macro class: `{ person: 0.45 }`. A class
27711
- * absent here runs at the step slider's global default. The same row shape
27712
- * the floor measurement produces (`model-floors.json`: modelId → floors), so
27713
- * a measured table is copied in as-is. An operator override is bound to the
27714
- * model it was made for and does not survive a model change (D738). A custom
27715
- * / imported model may declare it; without it, the global defaults apply.
27716
- */
27717
- defaultClassFloors: record$1(string(), number$1().min(0).max(1)).optional(),
27718
- /**
27719
- * The inference precision this model's OpenVINO IR needs on an Intel GPU.
27720
- * Absent ⇒ the device default (f16 on a GPU). Set to `'f32'` for an FP32 IR
27721
- * that produces invalid output at f16 — measured 2026-10-07 for YOLO26
27722
- * base IRs (`yolo26s`: 0 true / 146 false positives; `yolo26m*`: NaN
27723
- * scores) on the Core Ultra iGPU and the N100. Threaded to the pool as
27724
- * `PoolModelConfig.gpuInferencePrecision`; the pool sets
27725
- * INFERENCE_PRECISION_HINT on a GPU only. Costs ~60% latency on the GPU.
27726
- */
27727
- gpuInferencePrecision: _enum(["f32", "f16"]).optional(),
27728
- /**
27729
- * ROOT detectors only: per supplied step (`animal-classifier`, …), the
27730
- * minimum DETECTION score from which this root's own fine label (species,
27731
- * vehicle type — D736 root supply) is taken (D741). Below it the detection
27732
- * keeps its macro class without the fine label. `1` = never take it from
27733
- * this root. Absent ⇒ no floor beyond the macro floor. The supplied step's
27734
- * `minConfidence` slider, bound to the ROOT model, overrides it.
27735
- */
27736
- suppliedLabelFloors: record$1(string(), number$1().min(0).max(1)).optional(),
27737
- /**
27738
- * When true, the executor produces a landmark-aligned crop (similarity warp
27739
- * onto the canonical template) before this step runs, instead of a plain
27740
- * axis-aligned bbox crop. Required for face-recognition embedders (ArcFace):
27741
- * their embeddings are only discriminative on an aligned input. The face
27742
- * detector that produced the parent detail must emit 5 landmarks.
27743
- */
27744
- faceAlignment: boolean().optional(),
27745
- /**
27746
- * Auxiliary files required at runtime (labels JSON, charset dict, etc.).
27747
- * Downloaded into the same modelsDir alongside the model file.
27748
- */
27749
- extraFiles: array(ModelExtraFileSchema).readonly().optional(),
27750
- /**
27751
- * LEGACY entry — retained in the catalog so a persisted operator selection
27752
- * still RESOLVES (and can be re-activated), but hidden from the selectable
27753
- * model list and excluded from the auto format-default pick. Set on the
27754
- * superseded / consolidated models (older lineages, redundant fp16 IRs) so
27755
- * the active lineup stays the coherent curated ladder without deleting a
27756
- * model anyone may still be pinned to. `resolveModelForFormat` keeps honoring
27757
- * an explicit legacy id that has a build for the node's format.
27758
- */
27759
- legacy: boolean().optional(),
27760
- /**
27761
- * Measured quality/latency metadata — populated from the benchmark addon on
27762
- * the real node classes. Absent = not yet measured (most entries today; the
27763
- * catalog historically carried only `sizeMB`, a poor cross-architecture
27764
- * speed proxy). `p95LatencyMs` is keyed by node class (e.g. `n100`, `mac`).
27765
- */
27766
- metrics: object({
27767
- map50: number$1().optional(),
27768
- p95LatencyMs: record$1(string(), number$1()).optional()
27769
- }).optional(),
27770
- /**
27771
- * The model's licence record — see {@link ModelLicenseSchema}. Optional in
27772
- * the schema (a custom model's author may state none); REQUIRED and complete
27773
- * on every built-in catalog entry (`scripts/check-catalog-licence.ts`).
27774
- */
27775
- license: ModelLicenseSchema.optional(),
27776
- /**
27777
- * Variant-selector grouping. The UI groups models by `family` + `tier` and
27778
- * offers `precision` / `optimization` as variant axes WITHIN a tier — so all
27779
- * of a family's sizes and quantizations collapse into one grouped picker
27780
- * instead of a flat list of `yolo26s`, `yolo26s-int8`, … Absent ⇒ ungrouped
27781
- * (legacy / custom models) — never shown in the grouped selector. The flat
27782
- * `id` stays the source of truth for resolution/download/persistence; grouping
27783
- * is a presentation overlay resolved back to an `id`.
27784
- */
27785
- group: ModelVariantGroupSchema.optional(),
27786
- /**
27787
- * Catalog source for the pipeline stepper's provider-first picker. Absent on
27788
- * built-in CamStack entries (treated as `camstack`) and on registry rows
27789
- * persisted before this field existed (`inferModelProvider` fills those).
27790
- */
27791
- provider: ModelProviderIdSchema.optional(),
27792
- /**
27793
- * Per-MODEL class map override. Absent ⇒ the step's `StepDefinition.classMap`
27794
- * applies (plus catalog / COCO public catalog). Set on a custom model whose raw
27795
- * labels already ARE the CamStack macros (plugin catalog identity map).
27796
- */
27797
- classMap: DetectionCatalogClassMapSchema.optional(),
27798
- /**
27799
- * The pipeline steps this ROOT detector can supply from its own output
27800
- * (D730): its labels name a step's effect (`deer` for `animal-classifier`)
27801
- * or draw a step's box (`license_plate` for `plate-detection`). Computed at
27802
- * import from THIS model's labelmap by `deriveRootSupplies`, never written
27803
- * by hand and never assumed per family; a row without it is derived on read
27804
- * (`rootSuppliesOf`). Whether a camera uses it is the step's own
27805
- * `useRootModel` flag (`resolveRootSupply`).
27806
- */
27807
- suppliesSteps: array(RootStepSupplySchema).readonly().optional(),
27808
- /**
27809
- * The model's CLIP feature-space contract (text encoder, dimension, vector
27810
- * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
27811
- * CLIP image encoder; its absence is what "not a CLIP model" means to the
27812
- * embedding encoder and the semantic-search store (D649).
27813
- */
27814
- clip: ClipModelMetaSchema.optional()
27815
- });
27816
- var ConvertTargetSchema = discriminatedUnion("format", [object({
27817
- format: literal("openvino"),
27818
- precisions: array(_enum(["fp16", "int8"])).min(1).readonly()
27819
- }), object({ format: literal("coreml") })]);
27820
- var ModelConvertMetadataSchema = object({
27821
- id: string().regex(/^[a-zA-Z0-9._-]+$/),
27822
- name: string(),
27823
- labels: array(LabelDefinitionSchema).readonly(),
27824
- inputSize: object({
27825
- width: number$1(),
27826
- height: number$1()
27827
- }),
27828
- inputLayout: _enum(["nchw", "nhwc"]).optional(),
27829
- inputNormalization: _enum([
27830
- "zero-one",
27831
- "imagenet",
27832
- "none",
27833
- "scrfd"
27834
- ]).optional(),
27835
- preprocessMode: _enum(["letterbox", "resize"]).optional(),
27836
- outputFormat: _enum([
27837
- "yolo",
27838
- "ssd",
27839
- "embedding",
27840
- "classification",
27841
- "ocr",
27842
- "segmentation"
27843
- ]),
27844
- faceAlignment: boolean().optional(),
27845
- classMap: DetectionCatalogClassMapSchema.optional()
27846
- });
27847
- var ConvertResultSchema = object({
27848
- entry: ModelCatalogEntrySchema,
27849
- artifacts: array(object({
27850
- format: _enum(MODEL_FORMATS),
27851
- precision: _enum(["fp16", "int8"]).optional(),
27852
- sizeMB: number$1(),
27853
- validated: boolean(),
27854
- files: array(string()).readonly()
27855
- })).readonly()
27856
- });
27857
- var ViewerFeatureIdSchema = _enum([
27858
- "face-assignment",
27859
- "plate-assignment",
27860
- "retrain",
27861
- "scenes"
27862
- ]);
27863
- /** Which devices a viewer reaches: `allow` minus `block`. */
27864
- var ViewerDeviceAllowSchema = union([literal("*"), array(number$1().int().nonnegative())]);
27865
- /**
27866
- * The viewer grant, stored as ONE row of a user's `scopes`. A principal that
27867
- * holds it is decided by the viewer rules ALONE — any other row it carries is
27868
- * ignored, so a viewer can never be widened by a leftover grant.
27869
- */
27870
- var ViewerTokenScopeSchema = object({
27871
- type: literal("viewer"),
27872
- allow: ViewerDeviceAllowSchema,
27873
- block: array(number$1().int().nonnegative()),
27874
- features: array(ViewerFeatureIdSchema)
27875
- });
27876
- /**
27877
- * Zod schemas for persisted record types.
27878
- *
27879
- * These schemas serve as the single source of truth for types that are
27880
- * stored in the settings-store backend and retrieved via tRPC. They
27881
- * replace the manual TypeScript interfaces with schema-derived types,
27882
- * enabling runtime validation when reading from the backend.
27883
- *
27884
- * Convention: each schema is named `<Type>Schema`, the inferred TS type
27885
- * keeps the original name for backward compatibility.
27886
- */
27887
- /**
27888
- * Auth model (v2 — 2026-05-12 caps-only):
27889
- *
27890
- * Two principals:
27891
- * - `isAdmin: true` — full bypass. Admin scope set is ignored.
27892
- * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
27893
- *
27894
- * No role enum. There used to be `viewer / agent / scoped` and earlier
27895
- * `super_admin` — collapsed onto the single boolean because every
27896
- * non-admin caller is governed by the same scope-check rules; the
27897
- * distinction was only ever used to route role-specific procedures
27898
- * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
27899
- * with `isAdmin: false` + an explicit scope list.
27900
- */
27901
- /** Per-method access flavour. Materialised on every cap method via codegen. */
27902
- var MethodAccessSchema = _enum([
27903
- "view",
27904
- "create",
27905
- "delete"
27906
- ]);
27907
- /**
27908
- * A single scope grant. Three forms — checked in matcher with OR
27909
- * semantics; the first match decides whether the call passes:
27910
- *
27911
- * - `category` — broadest. `target: 'device' | 'system'` selects every
27912
- * cap with the matching `scope` declaration. New caps inherit grants
27913
- * automatically — adding a device cap to the codebase makes it
27914
- * reachable to every user with `category:device [...]` without a
27915
- * re-grant. Use this for "family viewer" / "operator" tiers.
27916
- *
27917
- * - `addon` — every cap that ships inside a given addon id. Niche;
27918
- * useful when an integration needs to interact with one specific
27919
- * addon's surface regardless of how many caps it exports.
27920
- *
27921
- * - `capability` — the most precise form. Single cap name. Use for
27922
- * integration tokens where you want to grant `addons.installPackage`
27923
- * and nothing else.
27924
- *
27925
- * `access` is REQUIRED with min 1 element. `admin` bypass is the
27926
- * "give me everything" escape; there is no wildcard scope.
27927
- */
27928
- var AllowedProviderSchema = union([literal("*"), array(string())]);
27929
- var AllowedDevicesSchema = record$1(string(), union([literal("*"), array(string())]));
27930
- var CapScopeSchema = _enum(["device", "system"]);
27931
- /**
27932
- * DeviceSelector (scope model v3 — 2026-08-12).
27933
- *
27934
- * A `device` grant no longer carries a frozen list of deviceIds. It carries
27935
- * a SELECTOR the matcher resolves against the live fleet, so the grant can be
27936
- * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
27937
- * AFTER the grant was minted — no re-grant, no re-login.
27938
- *
27939
- * - `all` — every device in the deployment. The broad viewer/operator
27940
- * lever without a `category` grant (a `category` grant also covers device
27941
- * caps that carry no deviceId; `all` is specifically the device set).
27942
- * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
27943
- * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
27944
- * is NOT covered until the grant is edited.
27945
- * - `types` — every device of a `DeviceType` (e.g. every `camera`).
27946
- * DYNAMIC. A device that changes type, or a new device of the type,
27947
- * re-resolves on the next request.
27948
- * - `locations` — every device whose operator-assigned `location` label is
27949
- * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
27950
- * null/unset location matches NO `locations` selector.
27951
- */
27952
- var DeviceSelectorSchema = discriminatedUnion("kind", [
27953
- object({ kind: literal("all") }),
27954
- object({
27955
- kind: literal("ids"),
27956
- ids: array(number$1().int()).min(1)
27957
- }),
27958
- object({
27959
- kind: literal("types"),
27960
- types: array(_enum(DeviceType)).min(1)
27961
- }),
27962
- object({
27963
- kind: literal("locations"),
27964
- locations: array(string().min(1)).min(1)
27965
- })
27966
- ]);
27967
- var DeviceTokenScopeSchema = object({
27968
- type: literal("device"),
27969
- /** The device SET this grant covers — resolved against the live fleet. */
27970
- selector: DeviceSelectorSchema,
27971
- access: array(MethodAccessSchema).min(1),
27972
- /**
27973
- * Whether a grant on a PARENT device transparently covers its accessory
27974
- * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
27975
- * Direction is parent → children ONLY.
27976
- *
27977
- * Absent → the matcher DERIVES it from the access flavour: `view`
27978
- * inherits (a camera viewer sees the camera's accessories), `create` /
27979
- * `delete` do NOT (actuating/removing a child is an explicit act the
27980
- * operator must grant on the child, not inherit from the parent). Set it
27981
- * explicitly to override that default per grant.
27982
- */
27983
- includeLinked: boolean().optional()
27984
- });
27985
- /**
27986
- * v2 → v3 lazy migration. A pre-v3 `device` grant carried
27987
- * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
27988
- * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
27989
- * EVERY parse path — stored records AND the JWT-carried scope arrays
27990
- * normalised at the request boundary ({@link normalizeTokenScopes} in
27991
- * `device-selector.ts`). Chosen over a one-time DB migration because a
27992
- * migration cannot reach a JWT already in a client's hands; parse-time
27993
- * migration covers both without a flag day. No cast — the raw object is read
27994
- * through `Reflect.get` (its static type is `unknown`).
27995
- */
27996
- function migrateLegacyTokenScope(raw) {
27997
- if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
27998
- if (Reflect.get(raw, "type") !== "device") return raw;
27999
- if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
28000
- const targets = Reflect.get(raw, "targets");
28001
- if (!Array.isArray(targets)) return raw;
28002
- return {
28003
- type: "device",
28004
- selector: {
28005
- kind: "ids",
28006
- ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
28007
- },
28008
- access: Reflect.get(raw, "access")
28009
- };
28010
- }
28011
- /**
28012
- * A stored `types` selector may name a type D1033 retired (`thermostat`). The
28013
- * grant is read back through this same preprocess, so the retired name is
28014
- * rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
28015
- * stays a strict enum on the wire.
28016
- */
28017
- function canonicalSelectorTypes(raw) {
28018
- const selector = Reflect.get(raw, "selector");
28019
- if (selector === null || typeof selector !== "object") return raw;
28020
- if (Reflect.get(selector, "kind") !== "types") return raw;
28021
- const types = Reflect.get(selector, "types");
28022
- if (!Array.isArray(types)) return raw;
28023
- const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
28024
- return {
28025
- ...raw,
28026
- selector: {
28027
- ...selector,
28028
- types: canonical
28029
- }
28030
- };
28031
- }
28032
- var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
28033
- object({
28034
- type: literal("category"),
28035
- target: CapScopeSchema,
28036
- access: array(MethodAccessSchema).min(1)
28037
- }),
28038
- object({
28039
- type: literal("capability"),
28040
- target: string(),
28041
- access: array(MethodAccessSchema).min(1)
28042
- }),
28043
- object({
28044
- type: literal("addon"),
28045
- target: string(),
28046
- access: array(MethodAccessSchema).min(1)
28047
- }),
28048
- DeviceTokenScopeSchema
28049
- ]));
28050
- /**
28051
- * What a PERSON's grant set holds (D921): the capability rows above (legacy
28052
- * users, integration-style tokens) or the viewer row, which is decided by its
28053
- * own rules alone. Kept apart from {@link TokenScope} so every surface that
28054
- * edits capability rows (the scope picker, token minting) keeps its shape.
28055
- */
28056
- var UserScopeSchema = union([ViewerTokenScopeSchema, TokenScopeSchema]);
28057
- object({
28058
- id: string(),
28059
- username: string(),
28060
- passwordHash: string(),
28061
- /**
28062
- * Admin bypass. When true, the middleware skips the scope-access
28063
- * check entirely. There is no other axis of privilege; the legacy
28064
- * role enum collapsed onto this boolean in v2.
28065
- */
28066
- isAdmin: boolean().default(false),
28067
- allowedProviders: AllowedProviderSchema,
28068
- allowedDevices: AllowedDevicesSchema,
28069
- /**
28070
- * Scopes granted to this user. Admins bypass; their `scopes` is
28071
- * ignored. Non-admins without scopes are locked out of every
28072
- * protected call.
28073
- */
28074
- scopes: array(UserScopeSchema).default([]),
28075
- createdAt: number$1(),
28076
- updatedAt: number$1()
28077
- });
28078
- object({
28079
- id: string(),
28080
- userId: string(),
28081
- name: string(),
28082
- tokenHash: string(),
28083
- tokenPrefix: string(),
28084
- scopes: array(TokenScopeSchema),
28085
- expiresAt: number$1().nullish(),
28086
- lastUsedAt: number$1().nullish(),
28087
- createdAt: number$1()
28088
- });
28089
- /** What a share-view grant lets its holder see. */
28090
- var ShareViewGrantSchema = object({
28091
- kind: _enum(SHARE_VIEW_KINDS),
28092
- deviceIds: array(number$1().int().nonnegative()).min(1).max(64),
28093
- /** Talk-back, opt-in at mint time; absent means off. */
28094
- talk: boolean().optional()
28095
- });
28096
- var ShareViewScopeSchema = object({
28097
- type: literal("share-view"),
28098
- grant: ShareViewGrantSchema
28099
- });
28100
- var AddonRoutesScopeSchema = object({
28101
- type: literal("addon-routes"),
28102
- access: array(MethodAccessSchema).min(1)
28103
- });
28104
- var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
28105
- var CredentialScopeSchema = union([
28106
- literal("*"),
28107
- ShareViewScopeSchema,
28108
- AddonRoutesScopeSchema,
28109
- PreferencesSelfScopeSchema,
28110
- ViewerTokenScopeSchema,
28111
- TokenScopeSchema
28112
- ]);
28113
- object({
28114
- kind: literal("credential"),
28115
- sub: string().min(1),
28116
- jti: string().min(16),
28117
- scopes: array(CredentialScopeSchema).min(1)
28118
- });
28119
- var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
28120
- /** A namespace's value: a JSON object, opaque to the hub. */
28121
- var PreferenceValueSchema = record$1(string(), unknown());
28122
- var PreferenceDeviceIdSchema = string().min(1).max(64);
28123
- /** A stored row, as the owner reads it. */
28124
- var PreferenceRowSchema = object({
28125
- namespace: PreferenceNamespaceSchema,
28126
- value: PreferenceValueSchema,
28127
- /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
28128
- revision: number$1().int().positive(),
28129
- updatedAt: number$1().int(),
28130
- /** The client id the last writer sent; `null` when it sent none. */
28131
- updatedByDevice: PreferenceDeviceIdSchema.nullable()
28132
- });
28133
- object({
28134
- /** Absent: every namespace the caller holds. */
28135
- namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
28136
- object({ rows: array(PreferenceRowSchema) });
28137
- object({
28138
- namespace: PreferenceNamespaceSchema,
28139
- value: PreferenceValueSchema,
28140
- /**
28141
- * The revision the edit was based on. Absent: last write wins. `0`: the
28142
- * namespace must not exist yet. Any other value that is not the current
28143
- * revision answers `conflict` and writes nothing.
28144
- */
28145
- baseRevision: number$1().int().nonnegative().optional(),
28146
- deviceId: PreferenceDeviceIdSchema.optional()
28147
- });
28148
- discriminatedUnion("status", [object({
28149
- status: literal("saved"),
28150
- row: PreferenceRowSchema
28151
- }), object({
28152
- status: literal("conflict"),
28153
- current: PreferenceRowSchema.nullable()
28154
- })]);
28155
- object({ namespace: PreferenceNamespaceSchema });
28156
- object({
28157
- /** `false` when the namespace did not exist. */
28158
- deleted: boolean() });
28159
- object({
28160
- /** The revision the client holds per namespace; a namespace it does not list is new to it. */
28161
- revisionByNamespace: record$1(PreferenceNamespaceSchema, number$1().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
28162
- object({
28163
- /** Every row whose revision differs from the client's, and every row it did not list. */
28164
- rows: array(PreferenceRowSchema),
28165
- /** Namespaces the client listed that no longer exist. */
28166
- deleted: array(PreferenceNamespaceSchema)
28167
- });
28168
- _enum(["new-session", "step-up"]);
28169
- /** The languages the hub's app landing pages are written in (D858). */
28170
- var AppPageLangSchema = _enum(["en", "it"]);
28171
- /** How a native app starts one login method (D858), as `auth.listLoginMethods` reports it. */
28172
- var AppLoginPathSchema = discriminatedUnion("kind", [object({ kind: literal("native") }), object({
28173
- kind: literal("browser"),
28174
- startPath: string().startsWith("/")
28175
- })]);
28176
- /**
28177
- * Device certificates (D855) — the wire contract shared by the hub, the admin
28178
- * UI and the native viewer.
28179
- *
28180
- * A device (a phone) generates its OWN P-256 key pair in hardware (Secure
28181
- * Enclave / Android Keystore / a non-extractable WebCrypto key). The private
28182
- * key never travels. The hub signs the PUBLIC key into an X.509 leaf under a
28183
- * dedicated device CA; the device later proves possession of the key by
28184
- * signing a hub-issued nonce, and the hub answers with the same session a
28185
- * password login opens.
28186
- *
28187
- * Everything on the wire is a small string (a PEM, a base64url signature):
28188
- * D613 is about bulk bytes, and a certificate is ~600 bytes.
28189
- */
28190
- /** Signature algorithm of every device credential: ECDSA, curve P-256, SHA-256. */
28191
- var DEVICE_CERT_SIGNATURE = "ecdsa-p256-sha256";
28192
- /** First line of every signed message; a change of format bumps the version. */
28193
- var DEVICE_SIGNATURE_MESSAGE_VERSION = "camstack-device-cert-v1";
28194
- _enum([
28195
- "login",
28196
- "renew",
28197
- "revoke"
28198
- ]);
28199
- var DevicePlatformSchema = _enum([
28200
- "ios",
28201
- "android",
28202
- "web",
28203
- "other"
28204
- ]);
28205
- var Base64UrlSchema = string().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/);
28206
- var PemSchema = string().min(1).max(16384);
28207
- /**
28208
- * Why a device-certificate endpoint said no. Distinct from a transport / 5xx
28209
- * failure: those carry no reason and mean "try again", never "the credential is
28210
- * dead". The viewer switches on this exhaustively.
28211
- */
28212
- var DeviceRefusalReasonSchema = _enum([
28213
- "revoked",
28214
- "unknown-credential",
28215
- "expired",
28216
- "bad-signature",
28217
- "nonce-invalid",
28218
- "rate-limited",
28219
- "invalid-certificate",
28220
- "superseded",
28221
- "user-gone",
28222
- "unavailable",
28223
- "code-invalid",
28224
- "self-enrollment-disabled",
28225
- "step-up-required",
28226
- "bad-public-key"
28227
- ]);
28228
- var DeviceRefusalSchema = object({
28229
- ok: literal(false),
28230
- reason: DeviceRefusalReasonSchema,
28231
- definitive: boolean(),
28232
- retryAfterSeconds: number$1().optional()
28233
- });
28234
- object({
28235
- code: string().min(1).max(256),
28236
- /** SubjectPublicKeyInfo DER of the device's P-256 public key, base64url. */
28237
- publicKeySpki: Base64UrlSchema,
28238
- deviceName: string().min(1).max(80).optional(),
28239
- platform: DevicePlatformSchema
28240
- });
28241
- discriminatedUnion("ok", [object({
28242
- credentialId: string(),
28243
- certPem: PemSchema,
28244
- /** The device CA certificate the leaf chains to. */
28245
- chainPem: PemSchema,
28246
- notAfter: number$1(),
28247
- user: object({
28248
- id: string(),
28249
- username: string()
28250
- })
28251
- }).extend({ ok: literal(true) }), DeviceRefusalSchema]);
28252
- object({
28253
- /** The single-use step-up proof (`auth.deviceEnrollProofFrom…`). */
28254
- proof: string().min(1).max(512),
28255
- publicKeySpki: Base64UrlSchema,
28256
- deviceName: string().min(1).max(80),
28257
- platform: DevicePlatformSchema
28258
- });
28259
- object({
28260
- proof: string(),
28261
- expiresAt: number$1()
28262
- });
28263
- discriminatedUnion("ok", [object({
28264
- nonce: string(),
28265
- /** The origin to put in the signed message. The app compares it to the hub it dialled. */
28266
- origin: string(),
28267
- expiresAt: number$1(),
28268
- signature: literal(DEVICE_CERT_SIGNATURE)
28269
- }).extend({ ok: literal(true) }), DeviceRefusalSchema]);
28270
- object({
28271
- certPem: PemSchema,
28272
- nonce: string().min(1).max(256),
28273
- /** ECDSA P-256 SHA-256 over {@link buildDeviceSignatureMessage}; raw r||s or DER, base64url. */
28274
- signature: Base64UrlSchema
28275
- });
28276
- discriminatedUnion("ok", [object({
28277
- credentialId: string(),
28278
- certPem: PemSchema,
28279
- chainPem: PemSchema,
28280
- notAfter: number$1()
28281
- }).extend({ ok: literal(true) }), DeviceRefusalSchema]);
28282
- discriminatedUnion("ok", [object({
28283
- ok: literal(true),
28284
- credentialId: string(),
28285
- sessionsEnded: number$1().int()
28286
- }), DeviceRefusalSchema]);
28287
- var DeviceCredentialStatusSchema = _enum([
28288
- "active",
28289
- "expired",
28290
- "revoked"
28291
- ]);
28292
- var DeviceCredentialSchema = object({
28293
- id: string(),
28294
- userId: string(),
28295
- username: string().nullable(),
28296
- deviceName: string(),
28297
- platform: DevicePlatformSchema,
28298
- enrolledVia: _enum(["qr", "self"]),
28299
- /** SHA-256 of the leaf certificate DER, colon-hex. */
28300
- fingerprint: string(),
28301
- issuedAt: number$1(),
28302
- expiresAt: number$1(),
28303
- lastUsedAt: number$1().nullable(),
28304
- lastUsedFrom: string().nullable(),
28305
- revokedAt: number$1().nullable(),
28306
- /** `admin:<userId>` | `user:<userId>` | `device` | `user-deleted`. */
28307
- revokedBy: string().nullable(),
28308
- status: DeviceCredentialStatusSchema
28309
- });
28310
- var StartEnrollmentOutputSchema = object({
28311
- /** Shown once; only its hash is kept. */
28312
- code: string(),
28313
- expiresAt: number$1(),
28314
- /** `camstack://enroll?hub=…&code=…` — what the QR encodes. */
28315
- enrollUrl: string(),
28316
- /** The hub origin in the link, or `null` when the hub could not name one (the link then has no `hub`). */
28317
- hubOrigin: string().nullable(),
28318
- /** Every origin the apps may try (role `appConnections`). */
28319
- hubOrigins: array(string())
28320
- });
28321
- object({
28322
- kind: literal("device-certificate"),
28323
- id: literal("device-certificate"),
28324
- label: string(),
28325
- stage: literal("primary"),
28326
- /** tRPC paths under the hub's `auth` router, so a client names no literal. */
28327
- challengePath: literal("auth.getDeviceChallenge"),
28328
- revokePath: literal("auth.revokeOwnDeviceCertificate"),
28329
- enrollSelfPath: literal("auth.enrollSelf"),
28330
- loginPath: literal("auth.loginWithDeviceCertificate"),
28331
- renewPath: literal("auth.renewDeviceCertificate"),
28332
- signature: literal(DEVICE_CERT_SIGNATURE),
28333
- messageVersion: literal(DEVICE_SIGNATURE_MESSAGE_VERSION),
28334
- /** Which clients can execute it: a native app silently, a browser with a non-extractable WebCrypto key. */
28335
- clients: array(_enum(["native", "web"])),
28336
- /** The app executes it itself, silently (D858). */
28337
- app: AppLoginPathSchema.nullable()
28338
- });
28339
27905
  /** Lucide category ids, alphabetical. `ICON_META` indexes into this. */
28340
27906
  var ICON_CATEGORY_IDS = [
28341
27907
  "accessibility",
@@ -48149,84 +47715,1064 @@ var ICON_SYNONYMS = {
48149
47715
  ]
48150
47716
  };
48151
47717
  /**
48152
- * Spellings an operator may already have PERSISTED that no lucide package
48153
- * accepts any more, and the catalog key they draw. They resolve
48154
- * (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
48155
- * pre-catalog spelling of `gauge`.
47718
+ * Spellings an operator may already have PERSISTED that no lucide package
47719
+ * accepts any more, and the catalog key they draw. They resolve
47720
+ * (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
47721
+ * pre-catalog spelling of `gauge`.
47722
+ */
47723
+ var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
47724
+ /**
47725
+ * icon-catalog — THE icon vocabulary (D854).
47726
+ *
47727
+ * Every place that picks or stores an icon — a device's display override, a
47728
+ * location, a site zone, a viewer accessory, an `icon` settings field — names
47729
+ * it by a key of this catalog and nothing else. There is no curated subset and
47730
+ * no second list: the catalog is every lucide icon that both surfaces can draw
47731
+ * (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
47732
+ * intersection computed by `scripts/generate-icon-catalog.ts` into the
47733
+ * committed `icon-catalog.generated.ts`.
47734
+ *
47735
+ * Like the vocabularies it replaces, this module holds STRINGS only — no React,
47736
+ * no lucide import, no glyph. Each surface owns its glyph table (the web one
47737
+ * lives in `ui-library`, loaded lazily), and a test on each side pins that it
47738
+ * covers {@link ICON_KEYS}.
47739
+ *
47740
+ * ## What is persisted
47741
+ *
47742
+ * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
47743
+ * package still accepts (`home` for `house`) and this repo's own legacy ones
47744
+ * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
47745
+ * stale, but they are never OFFERED by search.
47746
+ *
47747
+ * ## Search
47748
+ *
47749
+ * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
47750
+ * the caller adds, and lucide's English tags — in that order of weight.
47751
+ */
47752
+ var KEY_SET$2 = new Set(ICON_KEYS);
47753
+ new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
47754
+ /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
47755
+ function isIconKey(value) {
47756
+ return typeof value === "string" && KEY_SET$2.has(value);
47757
+ }
47758
+ /**
47759
+ * Wire/storage schema for one icon key.
47760
+ *
47761
+ * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
47762
+ * into every cap router, type and API-reference row that carries an icon. The
47763
+ * check is membership in the catalog and the type is {@link IconKey}.
47764
+ */
47765
+ var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
47766
+ var ENTRIES = ICON_KEYS.map((key, index) => {
47767
+ const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
47768
+ const categories = categoryIndexes.flatMap((i) => {
47769
+ const id = ICON_CATEGORY_IDS[i];
47770
+ return id === void 0 ? [] : [id];
47771
+ });
47772
+ return {
47773
+ key,
47774
+ categories,
47775
+ primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
47776
+ tags,
47777
+ synonyms: ICON_SYNONYMS[key] ?? []
47778
+ };
47779
+ });
47780
+ new Map(ENTRIES.map((e) => [e.key, e]));
47781
+ /** Categories a picker offers first: the ones this product's icons mostly live in. */
47782
+ var LEADING_CATEGORIES = [
47783
+ "devices",
47784
+ "home",
47785
+ "security",
47786
+ "buildings",
47787
+ "connectivity",
47788
+ "multimedia",
47789
+ "nature",
47790
+ "weather",
47791
+ "transportation",
47792
+ "animals"
47793
+ ];
47794
+ var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
47795
+ [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
47796
+ /** One tag name: trimmed, 1..40 characters. */
47797
+ var TagNameSchema = string().trim().min(1).max(40);
47798
+ /** The `tags` field every owner record carries. Absent = no tags. */
47799
+ var TagsFieldSchema = array(TagNameSchema).max(20);
47800
+ var TagColorIdSchema = _enum([
47801
+ "tag-a",
47802
+ "tag-b",
47803
+ "tag-c",
47804
+ "tag-d",
47805
+ "tag-e",
47806
+ "tag-f",
47807
+ "tag-g",
47808
+ "tag-h"
47809
+ ]);
47810
+ object({
47811
+ name: TagNameSchema,
47812
+ color: TagColorIdSchema,
47813
+ icon: IconKeySchema
47814
+ });
47815
+ var ClipModelMetaSchema = object({
47816
+ /** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
47817
+ textModelId: string().min(1),
47818
+ /** Output dimension of BOTH towers. A vector of any other length is refused. */
47819
+ embeddingDim: number$1().int().positive(),
47820
+ /**
47821
+ * The `vector-store` index this model's vectors live in. ONE feature space
47822
+ * per index: two models share an index only when their vectors are ranked
47823
+ * against each other, which for CLIP means never across families. Every
47824
+ * model gets its own.
47825
+ */
47826
+ vectorIndex: string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
47827
+ /**
47828
+ * The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
47829
+ * must be unique per tokenizer: every model's siblings land in ONE flat
47830
+ * models directory, so two different tokenizers under the same name would
47831
+ * silently overwrite each other (whichever model downloaded last wins, and
47832
+ * the other one tokenises with the wrong vocabulary).
47833
+ */
47834
+ tokenizerFile: string().min(1),
47835
+ /** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
47836
+ contextLength: number$1().int().positive(),
47837
+ /** Id the tokenizer pads with. */
47838
+ padId: number$1().int().nonnegative(),
47839
+ /**
47840
+ * The search cosine floor at `strictness: 'loose'` — calibrated per model,
47841
+ * because cosine bands are a property of the model: 0.2 keeps 96% of matched
47842
+ * COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
47843
+ */
47844
+ searchMinScore: number$1().min(0).max(1)
47845
+ });
47846
+ var ClipSearchStrictnessSchema = _enum([
47847
+ "loose",
47848
+ "balanced",
47849
+ "strict"
47850
+ ]);
47851
+ /** Steps whose effect a root label can BE. */
47852
+ var LABEL_SUPPLY_STEP_IDS = [
47853
+ "animal-classifier",
47854
+ "vehicle-classifier",
47855
+ "package-detection"
47856
+ ];
47857
+ /** Steps whose box a root detection can BE. */
47858
+ var CROP_SUPPLY_STEP_IDS = ["plate-detection", "face-detection"];
47859
+ /**
47860
+ * Steps whose per-detection MASK a root detection can carry (D737). The live
47861
+ * mask step is `segmentation` — a frame-plane refiner that runs its own model
47862
+ * once per detection crop. (`instance-segmentation` is a dormant step id that
47863
+ * no camera tree carries.)
47864
+ */
47865
+ var MASK_SUPPLY_STEP_IDS = ["segmentation"];
47866
+ [
47867
+ ...LABEL_SUPPLY_STEP_IDS,
47868
+ ...CROP_SUPPLY_STEP_IDS,
47869
+ ...MASK_SUPPLY_STEP_IDS
47870
+ ];
47871
+ /**
47872
+ * Multi-file format payload.
47873
+ *
47874
+ * - Directory formats (`isDirectory: true`, e.g. `.mlpackage`): files
47875
+ * relative to the directory root — the downloader fetches each from
47876
+ * `{url}/{file}` into `{modelDir}/{file}`. If omitted, it probes the
47877
+ * HuggingFace API (slower).
47878
+ * - Single-file formats (no `isDirectory`, e.g. OpenVINO IR): sibling
47879
+ * files fetched from the SAME remote directory as `url` and stored flat
47880
+ * alongside the main file — e.g. `['camstack-yolov9t.bin']` for the IR
47881
+ * weights next to `camstack-yolov9t.xml`.
47882
+ */
47883
+ var ModelFormatEntrySchema = object({
47884
+ url: string(),
47885
+ sizeMB: number$1(),
47886
+ /** Whether this format is a directory bundle (e.g., .mlpackage) rather than a single file */
47887
+ isDirectory: boolean().optional(),
47888
+ /** Multi-file payload (directory members or sibling files). */
47889
+ files: array(string()).readonly().optional(),
47890
+ /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
47891
+ runtimes: array(_enum(["python"])).readonly().optional(),
47892
+ /**
47893
+ * Content revision of the artefact, for one hosted OFF the CamStack mirror.
47894
+ * A format on the mirror leaves it unset: its revision (the sha256 of its
47895
+ * weight file) comes from the downloader's generated table, kept in step
47896
+ * with the mirror by `scripts/check-hosted-model-revisions.ts` (D744). A
47897
+ * node records the revision it downloaded next to the file
47898
+ * (`<file>.revision`); a copy with no record or a different one is stale
47899
+ * unless its weight file hashes to the revision, and a stale copy is
47900
+ * downloaded again, the old one serving until the new one is complete. No
47901
+ * revision at all ⇒ a file on disk is current, whatever it holds (D743).
47902
+ */
47903
+ revision: string().min(1).optional()
47904
+ });
47905
+ /**
47906
+ * What a node holds for one (model, format) (D746). `current` is a complete
47907
+ * copy at its catalog revision — exactly what `downloaded: true` means.
47908
+ * `stale` is bytes on disk that are not (yet) proven current under D743/D744:
47909
+ * no or a different revision record, or a missing sibling. `missing` is no
47910
+ * copy. `downloaded` alone folds `stale` into "not downloaded", which hid
47911
+ * reclaimable bytes and a copy about to be replaced.
47912
+ */
47913
+ var ModelOnDiskStateSchema = _enum([
47914
+ "current",
47915
+ "stale",
47916
+ "missing"
47917
+ ]);
47918
+ /**
47919
+ * The numeric precision of one format's BUILD (D746) — reported only when the
47920
+ * build states it (file-name token, an INT8 variant, an EdgeTPU compile, a
47921
+ * CamStack Core ML export). Absent means "not stated", never "fp32".
47922
+ */
47923
+ var ModelFormatPrecisionSchema = _enum([
47924
+ "fp32",
47925
+ "fp16",
47926
+ "int8"
47927
+ ]);
47928
+ /**
47929
+ * One format of one model as a node's `pipelineExecutor.getSchema` reports it.
47930
+ * `onDisk` / `precision` are optional for version skew: a runner that predates
47931
+ * them omits them, and a reader falls back to `downloaded`.
47932
+ */
47933
+ var PipelineModelFormatStatusSchema = object({
47934
+ downloaded: boolean(),
47935
+ sizeMB: number$1(),
47936
+ onDisk: ModelOnDiskStateSchema.optional(),
47937
+ precision: ModelFormatPrecisionSchema.optional()
47938
+ });
47939
+ /**
47940
+ * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
47941
+ * The downloader fetches from `url` and saves to `{modelsDir}/{filename}`.
47942
+ */
47943
+ var ModelExtraFileSchema = object({
47944
+ url: string(),
47945
+ filename: string(),
47946
+ sizeMB: number$1()
47947
+ });
47948
+ /**
47949
+ * Per-format payload map. Modelled as an explicit object (one optional key
47950
+ * per `ModelFormat`) rather than `z.record(enum, …)` — zod v4's enum-keyed
47951
+ * record requires every key, but a catalog entry only ships a subset of
47952
+ * formats.
47953
+ */
47954
+ var ModelFormatsSchema = object({
47955
+ onnx: ModelFormatEntrySchema.optional(),
47956
+ coreml: ModelFormatEntrySchema.optional(),
47957
+ openvino: ModelFormatEntrySchema.optional(),
47958
+ tflite: ModelFormatEntrySchema.optional(),
47959
+ pt: ModelFormatEntrySchema.optional(),
47960
+ gguf: ModelFormatEntrySchema.optional()
47961
+ });
47962
+ /**
47963
+ * Variant-selector grouping axes. Shared by the full `ModelCatalogEntry` and by
47964
+ * the reduced `PipelineModelOption` returned in `pipeline.getSchema()` so the
47965
+ * grouped Family→Tier→Variant picker renders identically in the config UI and
47966
+ * in the pipeline/device steppers. The flat `id` stays the source of truth for
47967
+ * resolution/download/persistence; this is a presentation overlay resolved back
47968
+ * to an `id`.
47969
+ */
47970
+ var ModelVariantGroupSchema = object({
47971
+ /** Top-level family, e.g. `yolo26` (later `d-fine`, `rf-detr`). */
47972
+ family: string(),
47973
+ /** Size within the family, e.g. `n` | `s` | `m` | `l`. */
47974
+ tier: string(),
47975
+ /** Quantization axis. Omit ⇒ the fp32 base build. */
47976
+ precision: _enum(["fp32", "int8"]).optional(),
47977
+ /**
47978
+ * Training / latency-variant axis. Omit ⇒ the standard build. `test` marks
47979
+ * an alternate training of the same family (plugin catalog `relu_test`); chip
47980
+ * label is "Test".
47981
+ */
47982
+ optimization: _enum(["standard", "test"]).optional(),
47983
+ /**
47984
+ * Input-resolution axis (square input side, px). Omit ⇒ the family's native
47985
+ * resolution (640 for yolo26). Reduced-input builds (320 / 256) are a big,
47986
+ * cheap latency lever — especially on Apple ANE and the Intel N100 — at a
47987
+ * small-object accuracy cost. Mirrors the model's `inputSize` but lifted onto
47988
+ * the group so the selector can offer it as a variant axis.
47989
+ */
47990
+ resolution: number$1().int().positive().optional()
47991
+ });
47992
+ var ModelProviderIdSchema = _enum([
47993
+ "camstack",
47994
+ "frigate",
47995
+ "scrypted",
47996
+ "custom"
47997
+ ]);
47998
+ /**
47999
+ * The licence of a model, as a record rather than a bare SPDX string: a
48000
+ * permissive CODE licence routinely sits on top of restrictive WEIGHTS or
48001
+ * DATA, and the obligations (attribution, modification notices, source offers)
48002
+ * are per upstream. A persisted custom-model row written when this field was a
48003
+ * string still parses — the string is lifted into `{ weights }`.
48004
+ *
48005
+ * Every machine licence surface (`THIRD_PARTY_MODELS.md`, the Hugging Face
48006
+ * model table) is GENERATED from these records by
48007
+ * `scripts/gen-model-licenses.ts` (D661). Operator-facing docs live in
48008
+ * `camstack/docs` → `/docs/detection/models`.
48156
48009
  */
48157
- var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
48010
+ var ModelLicenseSchema = preprocess((value) => typeof value === "string" ? { weights: value } : value, object({
48011
+ /** SPDX id of the WEIGHTS' terms, a `LicenseRef-*` for non-SPDX terms, or `UNKNOWN`. */
48012
+ weights: string().min(1),
48013
+ /** SPDX id of the upstream code that defines / trained the network. */
48014
+ code: string().min(1).optional(),
48015
+ /** Training data whose terms add obligations (attribution, non-commercial). */
48016
+ data: object({
48017
+ name: string().min(1),
48018
+ terms: string().min(1),
48019
+ url: string().url().optional()
48020
+ }).optional(),
48021
+ /** The project the weights come from. Required on built-in entries (guard). */
48022
+ upstream: object({
48023
+ name: string().min(1),
48024
+ url: string().url()
48025
+ }).optional(),
48026
+ /** Where the licence text governing the weights is published. */
48027
+ url: string().url().optional(),
48028
+ /** Attribution the licence REQUIRES, verbatim. */
48029
+ attribution: string().min(1).optional(),
48030
+ /** What CamStack changed. Required when `hosting` is `camstack-hf` (guard). */
48031
+ modifications: string().min(1).optional(),
48032
+ /** Who serves the file a node downloads. */
48033
+ hosting: _enum([
48034
+ "camstack-hf",
48035
+ "third-party",
48036
+ "built-in"
48037
+ ]).optional(),
48038
+ /** True when the weights or their data forbid commercial use. */
48039
+ nonCommercial: boolean().optional()
48040
+ }));
48158
48041
  /**
48159
- * icon-catalog — THE icon vocabulary (D854).
48042
+ * One step a ROOT detector can supply from its own output (D730) — see
48043
+ * `ModelCatalogEntry.suppliesSteps`.
48160
48044
  *
48161
- * Every place that picks or stores an icon — a device's display override, a
48162
- * location, a site zone, a viewer accessory, an `icon` settings field — names
48163
- * it by a key of this catalog and nothing else. There is no curated subset and
48164
- * no second list: the catalog is every lucide icon that both surfaces can draw
48165
- * (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
48166
- * intersection computed by `scripts/generate-icon-catalog.ts` into the
48167
- * committed `icon-catalog.generated.ts`.
48045
+ * - `label`: the root's raw class IS the step's answer. `labelToEffect` maps
48046
+ * the root's label to the step's vocabulary; `uncovered` is the vocabulary
48047
+ * the root cannot produce (shown as unavailable, never a blocker).
48048
+ * - `crop`: the root draws the box the step would have found (`license_plate`
48049
+ * for plate-detection, `face` for face-detection). The box becomes a detail
48050
+ * child of the `parentMacro` detection that contains it — never a track.
48051
+ * - `mask`: the root's decode emits an instance mask with every detection (a
48052
+ * YOLO26-seg root, D737) — the `segmentation` step's result, carried on the
48053
+ * detection in the shape that step produces. Derived from the model's
48054
+ * postprocessor on read, never stored by an import.
48055
+ */
48056
+ var RootStepSupplySchema = discriminatedUnion("kind", [
48057
+ object({
48058
+ kind: literal("label"),
48059
+ stepId: _enum(LABEL_SUPPLY_STEP_IDS),
48060
+ labelToEffect: record$1(string(), string()),
48061
+ uncovered: array(string()).readonly()
48062
+ }),
48063
+ object({
48064
+ kind: literal("crop"),
48065
+ stepId: _enum(CROP_SUPPLY_STEP_IDS),
48066
+ rootLabels: array(string()).readonly(),
48067
+ parentMacro: _enum(["vehicle", "person"]),
48068
+ childClass: _enum(["plate", "face"]),
48069
+ /**
48070
+ * The root's smaller input side, stamped on read by `rootSuppliesOf` from
48071
+ * the model entry — what a step's `minRootInputPx` gate judges. Never
48072
+ * stored by an import.
48073
+ */
48074
+ rootInputPx: number$1().int().positive().optional()
48075
+ }),
48076
+ object({
48077
+ kind: literal("mask"),
48078
+ stepId: _enum(MASK_SUPPLY_STEP_IDS)
48079
+ })
48080
+ ]);
48081
+ var ModelCatalogEntrySchema = object({
48082
+ id: string(),
48083
+ name: string(),
48084
+ description: string(),
48085
+ formats: ModelFormatsSchema,
48086
+ inputSize: object({
48087
+ width: number$1(),
48088
+ height: number$1()
48089
+ }),
48090
+ /**
48091
+ * Channel count of the model input tensor. Omit ⇒ 3 (RGB), the default for
48092
+ * every detector / classifier / embedder. Set to 1 for a grayscale CTC text
48093
+ * recognizer (EasyOCR VGG plate-OCR: input `[N,1,H,W]`) so the preprocess
48094
+ * feeds a single-channel, EasyOCR-normalized tensor instead of the default
48095
+ * 3-channel RGB one. Threaded through `PoolModelConfig.inputChannels` to the
48096
+ * Python inference pool.
48097
+ */
48098
+ inputChannels: number$1().int().positive().optional(),
48099
+ labels: array(LabelDefinitionSchema).readonly(),
48100
+ inputLayout: _enum(["nchw", "nhwc"]).optional(),
48101
+ /**
48102
+ * `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
48103
+ * (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
48104
+ * plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
48105
+ * `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
48106
+ */
48107
+ inputNormalization: _enum([
48108
+ "zero-one",
48109
+ "imagenet",
48110
+ "none",
48111
+ "scrfd"
48112
+ ]).optional(),
48113
+ /**
48114
+ * The model already applies softmax IN-GRAPH — its raw output is a
48115
+ * probability distribution, not logits. When set, the `softmax`
48116
+ * postprocessor must NOT re-apply softmax: re-softmaxing an already-normalised
48117
+ * probability vector collapses it toward uniform (top-1 score craters far
48118
+ * below its true value, making every confidence gate meaningless). Absent ⇒
48119
+ * the output is raw logits and the postprocessor applies softmax (the normal
48120
+ * case). Set on the Google AIY Birds `bird-classifier` (softmax baked into the
48121
+ * TF graph). Threaded to the Python pool via `PoolModelConfig.outputProbabilities`.
48122
+ */
48123
+ outputProbabilities: boolean().optional(),
48124
+ preprocessMode: _enum(["letterbox", "resize"]).optional(),
48125
+ /**
48126
+ * Per-MODEL postprocessor override. Absent ⇒ the step's own
48127
+ * `StepDefinition.postprocessor` applies (the normal case — every model in a
48128
+ * step shares its decode). Set it when a step hosts models with DIFFERENT raw
48129
+ * output layouts under one slot: e.g. object-detection is `'yolo'` by default,
48130
+ * but a Coral SSD MobileNet build emits the `TFLite_Detection_PostProcess`
48131
+ * 4-tensor layout and needs `'ssd'`. Threaded into `PoolModelConfig.postprocessor`
48132
+ * by the engine factory (`modelEntry.postprocessor ?? def.postprocessor`).
48133
+ */
48134
+ postprocessor: custom().optional(),
48135
+ /**
48136
+ * Per-MODEL default confidence floor. Absent ⇒ the step's
48137
+ * `StepDefinition.defaultConfidence` applies. A score is a property of one
48138
+ * model's output scale, not of the step slot it sits in: YuNet's
48139
+ * `sqrt(cls·obj)` is not SCRFD's score, and inheriting SCRFD's 0.5 filled the
48140
+ * face gallery with wheels and hands (D662, amends D645). An operator's
48141
+ * explicit value still wins over it. Resolved in ONE place —
48142
+ * `addon-pipeline/.../registry/effective-confidence.ts`.
48143
+ */
48144
+ defaultConfidence: number$1().min(0).max(1).optional(),
48145
+ /**
48146
+ * Per-MODEL default of the per-class confidence floors (`minConfidence<Macro>`
48147
+ * on a detector step), keyed by macro class: `{ person: 0.45 }`. A class
48148
+ * absent here runs at the step slider's global default. The same row shape
48149
+ * the floor measurement produces (`model-floors.json`: modelId → floors), so
48150
+ * a measured table is copied in as-is. An operator override is bound to the
48151
+ * model it was made for and does not survive a model change (D738). A custom
48152
+ * / imported model may declare it; without it, the global defaults apply.
48153
+ */
48154
+ defaultClassFloors: record$1(string(), number$1().min(0).max(1)).optional(),
48155
+ /**
48156
+ * The inference precision this model's OpenVINO IR needs on an Intel GPU.
48157
+ * Absent ⇒ the device default (f16 on a GPU). Set to `'f32'` for an FP32 IR
48158
+ * that produces invalid output at f16 — measured 2026-10-07 for YOLO26
48159
+ * base IRs (`yolo26s`: 0 true / 146 false positives; `yolo26m*`: NaN
48160
+ * scores) on the Core Ultra iGPU and the N100. Threaded to the pool as
48161
+ * `PoolModelConfig.gpuInferencePrecision`; the pool sets
48162
+ * INFERENCE_PRECISION_HINT on a GPU only. Costs ~60% latency on the GPU.
48163
+ */
48164
+ gpuInferencePrecision: _enum(["f32", "f16"]).optional(),
48165
+ /**
48166
+ * ROOT detectors only: per supplied step (`animal-classifier`, …), the
48167
+ * minimum DETECTION score from which this root's own fine label (species,
48168
+ * vehicle type — D736 root supply) is taken (D741). Below it the detection
48169
+ * keeps its macro class without the fine label. `1` = never take it from
48170
+ * this root. Absent ⇒ no floor beyond the macro floor. The supplied step's
48171
+ * `minConfidence` slider, bound to the ROOT model, overrides it.
48172
+ */
48173
+ suppliedLabelFloors: record$1(string(), number$1().min(0).max(1)).optional(),
48174
+ /**
48175
+ * When true, the executor produces a landmark-aligned crop (similarity warp
48176
+ * onto the canonical template) before this step runs, instead of a plain
48177
+ * axis-aligned bbox crop. Required for face-recognition embedders (ArcFace):
48178
+ * their embeddings are only discriminative on an aligned input. The face
48179
+ * detector that produced the parent detail must emit 5 landmarks.
48180
+ */
48181
+ faceAlignment: boolean().optional(),
48182
+ /**
48183
+ * Auxiliary files required at runtime (labels JSON, charset dict, etc.).
48184
+ * Downloaded into the same modelsDir alongside the model file.
48185
+ */
48186
+ extraFiles: array(ModelExtraFileSchema).readonly().optional(),
48187
+ /**
48188
+ * LEGACY entry — retained in the catalog so a persisted operator selection
48189
+ * still RESOLVES (and can be re-activated), but hidden from the selectable
48190
+ * model list and excluded from the auto format-default pick. Set on the
48191
+ * superseded / consolidated models (older lineages, redundant fp16 IRs) so
48192
+ * the active lineup stays the coherent curated ladder without deleting a
48193
+ * model anyone may still be pinned to. `resolveModelForFormat` keeps honoring
48194
+ * an explicit legacy id that has a build for the node's format.
48195
+ */
48196
+ legacy: boolean().optional(),
48197
+ /**
48198
+ * Measured quality/latency metadata — populated from the benchmark addon on
48199
+ * the real node classes. Absent = not yet measured (most entries today; the
48200
+ * catalog historically carried only `sizeMB`, a poor cross-architecture
48201
+ * speed proxy). `p95LatencyMs` is keyed by node class (e.g. `n100`, `mac`).
48202
+ */
48203
+ metrics: object({
48204
+ map50: number$1().optional(),
48205
+ p95LatencyMs: record$1(string(), number$1()).optional()
48206
+ }).optional(),
48207
+ /**
48208
+ * The model's licence record — see {@link ModelLicenseSchema}. Optional in
48209
+ * the schema (a custom model's author may state none); REQUIRED and complete
48210
+ * on every built-in catalog entry (`scripts/check-catalog-licence.ts`).
48211
+ */
48212
+ license: ModelLicenseSchema.optional(),
48213
+ /**
48214
+ * Variant-selector grouping. The UI groups models by `family` + `tier` and
48215
+ * offers `precision` / `optimization` as variant axes WITHIN a tier — so all
48216
+ * of a family's sizes and quantizations collapse into one grouped picker
48217
+ * instead of a flat list of `yolo26s`, `yolo26s-int8`, … Absent ⇒ ungrouped
48218
+ * (legacy / custom models) — never shown in the grouped selector. The flat
48219
+ * `id` stays the source of truth for resolution/download/persistence; grouping
48220
+ * is a presentation overlay resolved back to an `id`.
48221
+ */
48222
+ group: ModelVariantGroupSchema.optional(),
48223
+ /**
48224
+ * Catalog source for the pipeline stepper's provider-first picker. Absent on
48225
+ * built-in CamStack entries (treated as `camstack`) and on registry rows
48226
+ * persisted before this field existed (`inferModelProvider` fills those).
48227
+ */
48228
+ provider: ModelProviderIdSchema.optional(),
48229
+ /**
48230
+ * Per-MODEL class map override. Absent ⇒ the step's `StepDefinition.classMap`
48231
+ * applies (plus catalog / COCO public catalog). Set on a custom model whose raw
48232
+ * labels already ARE the CamStack macros (plugin catalog identity map).
48233
+ */
48234
+ classMap: DetectionCatalogClassMapSchema.optional(),
48235
+ /**
48236
+ * The pipeline steps this ROOT detector can supply from its own output
48237
+ * (D730): its labels name a step's effect (`deer` for `animal-classifier`)
48238
+ * or draw a step's box (`license_plate` for `plate-detection`). Computed at
48239
+ * import from THIS model's labelmap by `deriveRootSupplies`, never written
48240
+ * by hand and never assumed per family; a row without it is derived on read
48241
+ * (`rootSuppliesOf`). Whether a camera uses it is the step's own
48242
+ * `useRootModel` flag (`resolveRootSupply`).
48243
+ */
48244
+ suppliesSteps: array(RootStepSupplySchema).readonly().optional(),
48245
+ /**
48246
+ * The model's CLIP feature-space contract (text encoder, dimension, vector
48247
+ * index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
48248
+ * CLIP image encoder; its absence is what "not a CLIP model" means to the
48249
+ * embedding encoder and the semantic-search store (D649).
48250
+ */
48251
+ clip: ClipModelMetaSchema.optional()
48252
+ });
48253
+ var ConvertTargetSchema = discriminatedUnion("format", [object({
48254
+ format: literal("openvino"),
48255
+ precisions: array(_enum(["fp16", "int8"])).min(1).readonly()
48256
+ }), object({ format: literal("coreml") })]);
48257
+ var ModelConvertMetadataSchema = object({
48258
+ id: string().regex(/^[a-zA-Z0-9._-]+$/),
48259
+ name: string(),
48260
+ labels: array(LabelDefinitionSchema).readonly(),
48261
+ inputSize: object({
48262
+ width: number$1(),
48263
+ height: number$1()
48264
+ }),
48265
+ inputLayout: _enum(["nchw", "nhwc"]).optional(),
48266
+ inputNormalization: _enum([
48267
+ "zero-one",
48268
+ "imagenet",
48269
+ "none",
48270
+ "scrfd"
48271
+ ]).optional(),
48272
+ preprocessMode: _enum(["letterbox", "resize"]).optional(),
48273
+ outputFormat: _enum([
48274
+ "yolo",
48275
+ "ssd",
48276
+ "embedding",
48277
+ "classification",
48278
+ "ocr",
48279
+ "segmentation"
48280
+ ]),
48281
+ faceAlignment: boolean().optional(),
48282
+ classMap: DetectionCatalogClassMapSchema.optional()
48283
+ });
48284
+ var ConvertResultSchema = object({
48285
+ entry: ModelCatalogEntrySchema,
48286
+ artifacts: array(object({
48287
+ format: _enum(MODEL_FORMATS),
48288
+ precision: _enum(["fp16", "int8"]).optional(),
48289
+ sizeMB: number$1(),
48290
+ validated: boolean(),
48291
+ files: array(string()).readonly()
48292
+ })).readonly()
48293
+ });
48294
+ var ViewerFeatureIdSchema = _enum([
48295
+ "face-assignment",
48296
+ "plate-assignment",
48297
+ "retrain",
48298
+ "scenes"
48299
+ ]);
48300
+ /** Which devices a viewer reaches: `allow` minus `block`. */
48301
+ var ViewerDeviceAllowSchema = union([literal("*"), array(number$1().int().nonnegative())]);
48302
+ /**
48303
+ * The viewer grant, stored as ONE row of a user's `scopes`. A principal that
48304
+ * holds it is decided by the viewer rules ALONE — any other row it carries is
48305
+ * ignored, so a viewer can never be widened by a leftover grant.
48306
+ */
48307
+ var ViewerTokenScopeSchema = object({
48308
+ type: literal("viewer"),
48309
+ allow: ViewerDeviceAllowSchema,
48310
+ block: array(number$1().int().nonnegative()),
48311
+ features: array(ViewerFeatureIdSchema)
48312
+ });
48313
+ /**
48314
+ * Zod schemas for persisted record types.
48168
48315
  *
48169
- * Like the vocabularies it replaces, this module holds STRINGS only — no React,
48170
- * no lucide import, no glyph. Each surface owns its glyph table (the web one
48171
- * lives in `ui-library`, loaded lazily), and a test on each side pins that it
48172
- * covers {@link ICON_KEYS}.
48316
+ * These schemas serve as the single source of truth for types that are
48317
+ * stored in the settings-store backend and retrieved via tRPC. They
48318
+ * replace the manual TypeScript interfaces with schema-derived types,
48319
+ * enabling runtime validation when reading from the backend.
48173
48320
  *
48174
- * ## What is persisted
48321
+ * Convention: each schema is named `<Type>Schema`, the inferred TS type
48322
+ * keeps the original name for backward compatibility.
48323
+ */
48324
+ /**
48325
+ * Auth model (v2 — 2026-05-12 caps-only):
48175
48326
  *
48176
- * The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
48177
- * package still accepts (`home` for `house`) and this repo's own legacy ones
48178
- * (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
48179
- * stale, but they are never OFFERED by search.
48327
+ * Two principals:
48328
+ * - `isAdmin: true` — full bypass. Admin scope set is ignored.
48329
+ * - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
48180
48330
  *
48181
- * ## Search
48331
+ * No role enum. There used to be `viewer / agent / scoped` and earlier
48332
+ * `super_admin` — collapsed onto the single boolean because every
48333
+ * non-admin caller is governed by the same scope-check rules; the
48334
+ * distinction was only ever used to route role-specific procedures
48335
+ * which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
48336
+ * with `isAdmin: false` + an explicit scope list.
48337
+ */
48338
+ /** Per-method access flavour. Materialised on every cap method via codegen. */
48339
+ var MethodAccessSchema = _enum([
48340
+ "view",
48341
+ "create",
48342
+ "delete"
48343
+ ]);
48344
+ /**
48345
+ * A single scope grant. Three forms — checked in matcher with OR
48346
+ * semantics; the first match decides whether the call passes:
48182
48347
  *
48183
- * Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
48184
- * the caller adds, and lucide's English tags — in that order of weight.
48348
+ * - `category` — broadest. `target: 'device' | 'system'` selects every
48349
+ * cap with the matching `scope` declaration. New caps inherit grants
48350
+ * automatically — adding a device cap to the codebase makes it
48351
+ * reachable to every user with `category:device [...]` without a
48352
+ * re-grant. Use this for "family viewer" / "operator" tiers.
48353
+ *
48354
+ * - `addon` — every cap that ships inside a given addon id. Niche;
48355
+ * useful when an integration needs to interact with one specific
48356
+ * addon's surface regardless of how many caps it exports.
48357
+ *
48358
+ * - `capability` — the most precise form. Single cap name. Use for
48359
+ * integration tokens where you want to grant `addons.installPackage`
48360
+ * and nothing else.
48361
+ *
48362
+ * `access` is REQUIRED with min 1 element. `admin` bypass is the
48363
+ * "give me everything" escape; there is no wildcard scope.
48185
48364
  */
48186
- var KEY_SET$2 = new Set(ICON_KEYS);
48187
- new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
48188
- /** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
48189
- function isIconKey(value) {
48190
- return typeof value === "string" && KEY_SET$2.has(value);
48191
- }
48365
+ var AllowedProviderSchema = union([literal("*"), array(string())]);
48366
+ var AllowedDevicesSchema = record$1(string(), union([literal("*"), array(string())]));
48367
+ var CapScopeSchema = _enum(["device", "system"]);
48192
48368
  /**
48193
- * Wire/storage schema for one icon key.
48369
+ * DeviceSelector (scope model v3 — 2026-08-12).
48194
48370
  *
48195
- * Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
48196
- * into every cap router, type and API-reference row that carries an icon. The
48197
- * check is membership in the catalog and the type is {@link IconKey}.
48371
+ * A `device` grant no longer carries a frozen list of deviceIds. It carries
48372
+ * a SELECTOR the matcher resolves against the live fleet, so the grant can be
48373
+ * DYNAMIC: a `types:['camera']` selector automatically covers a camera added
48374
+ * AFTER the grant was minted — no re-grant, no re-login.
48375
+ *
48376
+ * - `all` — every device in the deployment. The broad viewer/operator
48377
+ * lever without a `category` grant (a `category` grant also covers device
48378
+ * caps that carry no deviceId; `all` is specifically the device set).
48379
+ * - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
48380
+ * grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
48381
+ * is NOT covered until the grant is edited.
48382
+ * - `types` — every device of a `DeviceType` (e.g. every `camera`).
48383
+ * DYNAMIC. A device that changes type, or a new device of the type,
48384
+ * re-resolves on the next request.
48385
+ * - `locations` — every device whose operator-assigned `location` label is
48386
+ * in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
48387
+ * null/unset location matches NO `locations` selector.
48198
48388
  */
48199
- var IconKeySchema = custom(isIconKey, "Not an icon of the catalog");
48200
- var ENTRIES = ICON_KEYS.map((key, index) => {
48201
- const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
48202
- const categories = categoryIndexes.flatMap((i) => {
48203
- const id = ICON_CATEGORY_IDS[i];
48204
- return id === void 0 ? [] : [id];
48205
- });
48389
+ var DeviceSelectorSchema = discriminatedUnion("kind", [
48390
+ object({ kind: literal("all") }),
48391
+ object({
48392
+ kind: literal("ids"),
48393
+ ids: array(number$1().int()).min(1)
48394
+ }),
48395
+ object({
48396
+ kind: literal("types"),
48397
+ types: array(_enum(DeviceType)).min(1)
48398
+ }),
48399
+ object({
48400
+ kind: literal("locations"),
48401
+ locations: array(string().min(1)).min(1)
48402
+ })
48403
+ ]);
48404
+ var DeviceTokenScopeSchema = object({
48405
+ type: literal("device"),
48406
+ /** The device SET this grant covers — resolved against the live fleet. */
48407
+ selector: DeviceSelectorSchema,
48408
+ access: array(MethodAccessSchema).min(1),
48409
+ /**
48410
+ * Whether a grant on a PARENT device transparently covers its accessory
48411
+ * CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
48412
+ * Direction is parent → children ONLY.
48413
+ *
48414
+ * Absent → the matcher DERIVES it from the access flavour: `view`
48415
+ * inherits (a camera viewer sees the camera's accessories), `create` /
48416
+ * `delete` do NOT (actuating/removing a child is an explicit act the
48417
+ * operator must grant on the child, not inherit from the parent). Set it
48418
+ * explicitly to override that default per grant.
48419
+ */
48420
+ includeLinked: boolean().optional()
48421
+ });
48422
+ /**
48423
+ * v2 → v3 lazy migration. A pre-v3 `device` grant carried
48424
+ * `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
48425
+ * `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
48426
+ * EVERY parse path — stored records AND the JWT-carried scope arrays
48427
+ * normalised at the request boundary ({@link normalizeTokenScopes} in
48428
+ * `device-selector.ts`). Chosen over a one-time DB migration because a
48429
+ * migration cannot reach a JWT already in a client's hands; parse-time
48430
+ * migration covers both without a flag day. No cast — the raw object is read
48431
+ * through `Reflect.get` (its static type is `unknown`).
48432
+ */
48433
+ function migrateLegacyTokenScope(raw) {
48434
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
48435
+ if (Reflect.get(raw, "type") !== "device") return raw;
48436
+ if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
48437
+ const targets = Reflect.get(raw, "targets");
48438
+ if (!Array.isArray(targets)) return raw;
48206
48439
  return {
48207
- key,
48208
- categories,
48209
- primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
48210
- tags,
48211
- synonyms: ICON_SYNONYMS[key] ?? []
48440
+ type: "device",
48441
+ selector: {
48442
+ kind: "ids",
48443
+ ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
48444
+ },
48445
+ access: Reflect.get(raw, "access")
48446
+ };
48447
+ }
48448
+ /**
48449
+ * A stored `types` selector may name a type D1033 retired (`thermostat`). The
48450
+ * grant is read back through this same preprocess, so the retired name is
48451
+ * rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
48452
+ * stays a strict enum on the wire.
48453
+ */
48454
+ function canonicalSelectorTypes(raw) {
48455
+ const selector = Reflect.get(raw, "selector");
48456
+ if (selector === null || typeof selector !== "object") return raw;
48457
+ if (Reflect.get(selector, "kind") !== "types") return raw;
48458
+ const types = Reflect.get(selector, "types");
48459
+ if (!Array.isArray(types)) return raw;
48460
+ const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
48461
+ return {
48462
+ ...raw,
48463
+ selector: {
48464
+ ...selector,
48465
+ types: canonical
48466
+ }
48212
48467
  };
48468
+ }
48469
+ var TokenScopeSchema = preprocess(migrateLegacyTokenScope, discriminatedUnion("type", [
48470
+ object({
48471
+ type: literal("category"),
48472
+ target: CapScopeSchema,
48473
+ access: array(MethodAccessSchema).min(1)
48474
+ }),
48475
+ object({
48476
+ type: literal("capability"),
48477
+ target: string(),
48478
+ access: array(MethodAccessSchema).min(1)
48479
+ }),
48480
+ object({
48481
+ type: literal("addon"),
48482
+ target: string(),
48483
+ access: array(MethodAccessSchema).min(1)
48484
+ }),
48485
+ DeviceTokenScopeSchema
48486
+ ]));
48487
+ /**
48488
+ * What a PERSON's grant set holds (D921): the capability rows above (legacy
48489
+ * users, integration-style tokens) or the viewer row, which is decided by its
48490
+ * own rules alone. Kept apart from {@link TokenScope} so every surface that
48491
+ * edits capability rows (the scope picker, token minting) keeps its shape.
48492
+ */
48493
+ var UserScopeSchema = union([ViewerTokenScopeSchema, TokenScopeSchema]);
48494
+ object({
48495
+ id: string(),
48496
+ username: string(),
48497
+ passwordHash: string(),
48498
+ /**
48499
+ * Admin bypass. When true, the middleware skips the scope-access
48500
+ * check entirely. There is no other axis of privilege; the legacy
48501
+ * role enum collapsed onto this boolean in v2.
48502
+ */
48503
+ isAdmin: boolean().default(false),
48504
+ allowedProviders: AllowedProviderSchema,
48505
+ allowedDevices: AllowedDevicesSchema,
48506
+ /**
48507
+ * Scopes granted to this user. Admins bypass; their `scopes` is
48508
+ * ignored. Non-admins without scopes are locked out of every
48509
+ * protected call.
48510
+ */
48511
+ scopes: array(UserScopeSchema).default([]),
48512
+ createdAt: number$1(),
48513
+ updatedAt: number$1()
48514
+ });
48515
+ object({
48516
+ id: string(),
48517
+ userId: string(),
48518
+ name: string(),
48519
+ tokenHash: string(),
48520
+ tokenPrefix: string(),
48521
+ scopes: array(TokenScopeSchema),
48522
+ expiresAt: number$1().nullish(),
48523
+ lastUsedAt: number$1().nullish(),
48524
+ createdAt: number$1()
48525
+ });
48526
+ /** What a share-view grant lets its holder see. */
48527
+ var ShareViewGrantSchema = object({
48528
+ kind: _enum(SHARE_VIEW_KINDS),
48529
+ deviceIds: array(number$1().int().nonnegative()).min(1).max(64),
48530
+ /** Talk-back, opt-in at mint time; absent means off. */
48531
+ talk: boolean().optional()
48532
+ });
48533
+ var ShareViewScopeSchema = object({
48534
+ type: literal("share-view"),
48535
+ grant: ShareViewGrantSchema
48536
+ });
48537
+ var AddonRoutesScopeSchema = object({
48538
+ type: literal("addon-routes"),
48539
+ access: array(MethodAccessSchema).min(1)
48540
+ });
48541
+ var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
48542
+ var CredentialScopeSchema = union([
48543
+ literal("*"),
48544
+ ShareViewScopeSchema,
48545
+ AddonRoutesScopeSchema,
48546
+ PreferencesSelfScopeSchema,
48547
+ ViewerTokenScopeSchema,
48548
+ TokenScopeSchema
48549
+ ]);
48550
+ object({
48551
+ kind: literal("credential"),
48552
+ sub: string().min(1),
48553
+ jti: string().min(16),
48554
+ scopes: array(CredentialScopeSchema).min(1)
48555
+ });
48556
+ var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
48557
+ /** A namespace's value: a JSON object, opaque to the hub. */
48558
+ var PreferenceValueSchema = record$1(string(), unknown());
48559
+ var PreferenceDeviceIdSchema = string().min(1).max(64);
48560
+ /** A stored row, as the owner reads it. */
48561
+ var PreferenceRowSchema = object({
48562
+ namespace: PreferenceNamespaceSchema,
48563
+ value: PreferenceValueSchema,
48564
+ /** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
48565
+ revision: number$1().int().positive(),
48566
+ updatedAt: number$1().int(),
48567
+ /** The client id the last writer sent; `null` when it sent none. */
48568
+ updatedByDevice: PreferenceDeviceIdSchema.nullable()
48569
+ });
48570
+ object({
48571
+ /** Absent: every namespace the caller holds. */
48572
+ namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
48573
+ object({ rows: array(PreferenceRowSchema) });
48574
+ object({
48575
+ namespace: PreferenceNamespaceSchema,
48576
+ value: PreferenceValueSchema,
48577
+ /**
48578
+ * The revision the edit was based on. Absent: last write wins. `0`: the
48579
+ * namespace must not exist yet. Any other value that is not the current
48580
+ * revision answers `conflict` and writes nothing.
48581
+ */
48582
+ baseRevision: number$1().int().nonnegative().optional(),
48583
+ deviceId: PreferenceDeviceIdSchema.optional()
48584
+ });
48585
+ discriminatedUnion("status", [object({
48586
+ status: literal("saved"),
48587
+ row: PreferenceRowSchema
48588
+ }), object({
48589
+ status: literal("conflict"),
48590
+ current: PreferenceRowSchema.nullable()
48591
+ })]);
48592
+ object({ namespace: PreferenceNamespaceSchema });
48593
+ object({
48594
+ /** `false` when the namespace did not exist. */
48595
+ deleted: boolean() });
48596
+ object({
48597
+ /** The revision the client holds per namespace; a namespace it does not list is new to it. */
48598
+ revisionByNamespace: record$1(PreferenceNamespaceSchema, number$1().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
48599
+ object({
48600
+ /** Every row whose revision differs from the client's, and every row it did not list. */
48601
+ rows: array(PreferenceRowSchema),
48602
+ /** Namespaces the client listed that no longer exist. */
48603
+ deleted: array(PreferenceNamespaceSchema)
48604
+ });
48605
+ _enum(["new-session", "step-up"]);
48606
+ /** The languages the hub's app landing pages are written in (D858). */
48607
+ var AppPageLangSchema = _enum(["en", "it"]);
48608
+ /** How a native app starts one login method (D858), as `auth.listLoginMethods` reports it. */
48609
+ var AppLoginPathSchema = discriminatedUnion("kind", [object({ kind: literal("native") }), object({
48610
+ kind: literal("browser"),
48611
+ startPath: string().startsWith("/")
48612
+ })]);
48613
+ /**
48614
+ * Device certificates (D855) — the wire contract shared by the hub, the admin
48615
+ * UI and the native viewer.
48616
+ *
48617
+ * A device (a phone) generates its OWN P-256 key pair in hardware (Secure
48618
+ * Enclave / Android Keystore / a non-extractable WebCrypto key). The private
48619
+ * key never travels. The hub signs the PUBLIC key into an X.509 leaf under a
48620
+ * dedicated device CA; the device later proves possession of the key by
48621
+ * signing a hub-issued nonce, and the hub answers with the same session a
48622
+ * password login opens.
48623
+ *
48624
+ * Everything on the wire is a small string (a PEM, a base64url signature):
48625
+ * D613 is about bulk bytes, and a certificate is ~600 bytes.
48626
+ */
48627
+ /** Signature algorithm of every device credential: ECDSA, curve P-256, SHA-256. */
48628
+ var DEVICE_CERT_SIGNATURE = "ecdsa-p256-sha256";
48629
+ /** First line of every signed message; a change of format bumps the version. */
48630
+ var DEVICE_SIGNATURE_MESSAGE_VERSION = "camstack-device-cert-v1";
48631
+ _enum([
48632
+ "login",
48633
+ "renew",
48634
+ "revoke"
48635
+ ]);
48636
+ var DevicePlatformSchema = _enum([
48637
+ "ios",
48638
+ "android",
48639
+ "web",
48640
+ "other"
48641
+ ]);
48642
+ var Base64UrlSchema = string().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/);
48643
+ var PemSchema = string().min(1).max(16384);
48644
+ /**
48645
+ * Why a device-certificate endpoint said no. Distinct from a transport / 5xx
48646
+ * failure: those carry no reason and mean "try again", never "the credential is
48647
+ * dead". The viewer switches on this exhaustively.
48648
+ */
48649
+ var DeviceRefusalReasonSchema = _enum([
48650
+ "revoked",
48651
+ "unknown-credential",
48652
+ "expired",
48653
+ "bad-signature",
48654
+ "nonce-invalid",
48655
+ "rate-limited",
48656
+ "invalid-certificate",
48657
+ "superseded",
48658
+ "user-gone",
48659
+ "unavailable",
48660
+ "code-invalid",
48661
+ "self-enrollment-disabled",
48662
+ "step-up-required",
48663
+ "bad-public-key"
48664
+ ]);
48665
+ var DeviceRefusalSchema = object({
48666
+ ok: literal(false),
48667
+ reason: DeviceRefusalReasonSchema,
48668
+ definitive: boolean(),
48669
+ retryAfterSeconds: number$1().optional()
48670
+ });
48671
+ object({
48672
+ code: string().min(1).max(256),
48673
+ /** SubjectPublicKeyInfo DER of the device's P-256 public key, base64url. */
48674
+ publicKeySpki: Base64UrlSchema,
48675
+ deviceName: string().min(1).max(80).optional(),
48676
+ platform: DevicePlatformSchema
48677
+ });
48678
+ discriminatedUnion("ok", [object({
48679
+ credentialId: string(),
48680
+ certPem: PemSchema,
48681
+ /** The device CA certificate the leaf chains to. */
48682
+ chainPem: PemSchema,
48683
+ notAfter: number$1(),
48684
+ user: object({
48685
+ id: string(),
48686
+ username: string()
48687
+ })
48688
+ }).extend({ ok: literal(true) }), DeviceRefusalSchema]);
48689
+ object({
48690
+ /** The single-use step-up proof (`auth.deviceEnrollProofFrom…`). */
48691
+ proof: string().min(1).max(512),
48692
+ publicKeySpki: Base64UrlSchema,
48693
+ deviceName: string().min(1).max(80),
48694
+ platform: DevicePlatformSchema
48695
+ });
48696
+ object({
48697
+ proof: string(),
48698
+ expiresAt: number$1()
48699
+ });
48700
+ discriminatedUnion("ok", [object({
48701
+ nonce: string(),
48702
+ /** The origin to put in the signed message. The app compares it to the hub it dialled. */
48703
+ origin: string(),
48704
+ expiresAt: number$1(),
48705
+ signature: literal(DEVICE_CERT_SIGNATURE)
48706
+ }).extend({ ok: literal(true) }), DeviceRefusalSchema]);
48707
+ object({
48708
+ certPem: PemSchema,
48709
+ nonce: string().min(1).max(256),
48710
+ /** ECDSA P-256 SHA-256 over {@link buildDeviceSignatureMessage}; raw r||s or DER, base64url. */
48711
+ signature: Base64UrlSchema
48712
+ });
48713
+ discriminatedUnion("ok", [object({
48714
+ credentialId: string(),
48715
+ certPem: PemSchema,
48716
+ chainPem: PemSchema,
48717
+ notAfter: number$1()
48718
+ }).extend({ ok: literal(true) }), DeviceRefusalSchema]);
48719
+ discriminatedUnion("ok", [object({
48720
+ ok: literal(true),
48721
+ credentialId: string(),
48722
+ sessionsEnded: number$1().int()
48723
+ }), DeviceRefusalSchema]);
48724
+ var DeviceCredentialStatusSchema = _enum([
48725
+ "active",
48726
+ "expired",
48727
+ "revoked"
48728
+ ]);
48729
+ var DeviceCredentialSchema = object({
48730
+ id: string(),
48731
+ userId: string(),
48732
+ username: string().nullable(),
48733
+ deviceName: string(),
48734
+ platform: DevicePlatformSchema,
48735
+ enrolledVia: _enum(["qr", "self"]),
48736
+ /** SHA-256 of the leaf certificate DER, colon-hex. */
48737
+ fingerprint: string(),
48738
+ issuedAt: number$1(),
48739
+ expiresAt: number$1(),
48740
+ lastUsedAt: number$1().nullable(),
48741
+ lastUsedFrom: string().nullable(),
48742
+ revokedAt: number$1().nullable(),
48743
+ /** `admin:<userId>` | `user:<userId>` | `device` | `user-deleted`. */
48744
+ revokedBy: string().nullable(),
48745
+ status: DeviceCredentialStatusSchema
48746
+ });
48747
+ var StartEnrollmentOutputSchema = object({
48748
+ /** Shown once; only its hash is kept. */
48749
+ code: string(),
48750
+ expiresAt: number$1(),
48751
+ /** `camstack://enroll?hub=…&code=…` — what the QR encodes. */
48752
+ enrollUrl: string(),
48753
+ /** The hub origin in the link, or `null` when the hub could not name one (the link then has no `hub`). */
48754
+ hubOrigin: string().nullable(),
48755
+ /** Every origin the apps may try (role `appConnections`). */
48756
+ hubOrigins: array(string())
48757
+ });
48758
+ object({
48759
+ kind: literal("device-certificate"),
48760
+ id: literal("device-certificate"),
48761
+ label: string(),
48762
+ stage: literal("primary"),
48763
+ /** tRPC paths under the hub's `auth` router, so a client names no literal. */
48764
+ challengePath: literal("auth.getDeviceChallenge"),
48765
+ revokePath: literal("auth.revokeOwnDeviceCertificate"),
48766
+ enrollSelfPath: literal("auth.enrollSelf"),
48767
+ loginPath: literal("auth.loginWithDeviceCertificate"),
48768
+ renewPath: literal("auth.renewDeviceCertificate"),
48769
+ signature: literal(DEVICE_CERT_SIGNATURE),
48770
+ messageVersion: literal(DEVICE_SIGNATURE_MESSAGE_VERSION),
48771
+ /** Which clients can execute it: a native app silently, a browser with a non-extractable WebCrypto key. */
48772
+ clients: array(_enum(["native", "web"])),
48773
+ /** The app executes it itself, silently (D858). */
48774
+ app: AppLoginPathSchema.nullable()
48213
48775
  });
48214
- new Map(ENTRIES.map((e) => [e.key, e]));
48215
- /** Categories a picker offers first: the ones this product's icons mostly live in. */
48216
- var LEADING_CATEGORIES = [
48217
- "devices",
48218
- "home",
48219
- "security",
48220
- "buildings",
48221
- "connectivity",
48222
- "multimedia",
48223
- "nature",
48224
- "weather",
48225
- "transportation",
48226
- "animals"
48227
- ];
48228
- var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
48229
- [...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
48230
48776
  /**
48231
48777
  * One (location, icon) assignment as it travels.
48232
48778
  *
@@ -50010,7 +50556,9 @@ var SchedulerInputSchema = object({
50010
50556
  /** Higher wins when two holds want the same device in different states. */
50011
50557
  priority: number$1().int().min(0).max(100).default(0),
50012
50558
  maxLateMs: number$1().int().min(1e3).max(24 * 36e5).default(DEFAULT_MAX_LATE_MS),
50013
- profiles: array(SchedulerProfileSchema).max(20)
50559
+ profiles: array(SchedulerProfileSchema).max(20),
50560
+ /** Operator tags (D1054). Absent = no tags. */
50561
+ tags: TagsFieldSchema.optional()
50014
50562
  });
50015
50563
  var SchedulerSchema = SchedulerInputSchema.extend({
50016
50564
  id: string().min(1),
@@ -50539,6 +51087,8 @@ var ActionEntrySchema = object({
50539
51087
  * action (two rules, a button, an automation).
50540
51088
  */
50541
51089
  minDelaySec: ActionMinDelaySecSchema.optional(),
51090
+ /** Internal only: operator tags (D1054). Absent = no tags. */
51091
+ tags: TagsFieldSchema.optional(),
50542
51092
  status: ActionStatusSchema
50543
51093
  }).superRefine((entry, ctx) => {
50544
51094
  if (entry.source === "internal") {
@@ -50570,7 +51120,8 @@ var ActionInputSchema = object({
50570
51120
  name: string().min(1).max(120),
50571
51121
  steps: array(ActionStepSchema).min(1).max(50),
50572
51122
  variables: array(ActionVariableSchema).max(20).optional(),
50573
- minDelaySec: ActionMinDelaySecSchema.optional()
51123
+ minDelaySec: ActionMinDelaySecSchema.optional(),
51124
+ tags: TagsFieldSchema.optional()
50574
51125
  });
50575
51126
  /** Who started a run. Absent = the operator pressed it. */
50576
51127
  var ActionRunOriginSchema = object({
@@ -51834,11 +52385,13 @@ var airQualitySensorCapability = {
51834
52385
  deadband: 5
51835
52386
  },
51836
52387
  pm25: {
52388
+ group: "particulates",
51837
52389
  kind: "gauge",
51838
52390
  unit: "µg/m³",
51839
52391
  deadband: 1
51840
52392
  },
51841
52393
  pm10: {
52394
+ group: "particulates",
51842
52395
  kind: "gauge",
51843
52396
  unit: "µg/m³",
51844
52397
  deadband: 1
@@ -55804,33 +56357,41 @@ var climateControlCapability = {
55804
56357
  /**
55805
56358
  * History (D850): recorded series. Celsius by contract; setpoints keep every change (`minIntervalMs: 0`).
55806
56359
  */
55807
- history: { fields: {
55808
- currentTemp: {
55809
- kind: "gauge",
55810
- unit: "°C",
55811
- deadband: .1
55812
- },
55813
- currentHumidity: {
55814
- kind: "gauge",
55815
- unit: "%",
55816
- deadband: .5
55817
- },
55818
- target: {
55819
- kind: "gauge",
55820
- unit: "°C",
55821
- minIntervalMs: 0
55822
- },
55823
- targetHigh: {
55824
- kind: "gauge",
55825
- unit: "°C",
55826
- minIntervalMs: 0
55827
- },
55828
- targetLow: {
55829
- kind: "gauge",
55830
- unit: "°C",
55831
- minIntervalMs: 0
56360
+ history: {
56361
+ primary: "currentTemp",
56362
+ priority: 70,
56363
+ fields: {
56364
+ currentTemp: {
56365
+ group: "temperature",
56366
+ kind: "gauge",
56367
+ unit: "°C",
56368
+ deadband: .1
56369
+ },
56370
+ currentHumidity: {
56371
+ kind: "gauge",
56372
+ unit: "%",
56373
+ deadband: .5
56374
+ },
56375
+ target: {
56376
+ group: "temperature",
56377
+ kind: "gauge",
56378
+ unit: "°C",
56379
+ minIntervalMs: 0
56380
+ },
56381
+ targetHigh: {
56382
+ group: "target-range",
56383
+ kind: "gauge",
56384
+ unit: "°C",
56385
+ minIntervalMs: 0
56386
+ },
56387
+ targetLow: {
56388
+ group: "target-range",
56389
+ kind: "gauge",
56390
+ unit: "°C",
56391
+ minIntervalMs: 0
56392
+ }
55832
56393
  }
55833
- } },
56394
+ },
55834
56395
  vocabulary: {
55835
56396
  noun: t("Climate", "Clima"),
55836
56397
  order: 1070,
@@ -56548,13 +57109,14 @@ var connectivityCapability = {
56548
57109
  * its device tracks consumables registers it; the provider names each item
56549
57110
  * verbatim and says which `kind` it is.
56550
57111
  *
56551
- * The admin UI renders it as ONE collapsible section directly under the
56552
- * device page's hero card (`placement: 'hero'`), for every device bound to
56553
- * this cap — never drawn by a device type's hero card itself (D915).
57112
+ * The admin UI shows it in the device card's consumables chip and popover
57113
+ * (kind-aware level, remaining time, "Reset"), for every device bound to this
57114
+ * cap (D1023). It no longer has a section of its own under the hero card
57115
+ * (D915 on that point).
56554
57116
  *
56555
57117
  * Like `childLayout`, the cap is INERT until a provider sets items: no
56556
57118
  * provider populates it by guessing (no HA inference). The UI renders a
56557
- * "No consumables reported" placeholder when `items` is empty.
57119
+ * "No consumables reported" line when `items` is empty.
56558
57120
  */
56559
57121
  /**
56560
57122
  * What an item IS, which decides which direction is bad:
@@ -56641,7 +57203,7 @@ var ConsumablesStatusSchema = object({
56641
57203
  });
56642
57204
  /** Synthesize seed for a link-built status (no native provider).
56643
57205
  *
56644
- * ⚠ NO LIVE CALLER since 2026-08-08 (device-links deleted; see
57206
+ * ! NO LIVE CALLER since 2026-08-08 (device-links deleted; see
56645
57207
  * `CapabilityStatusSchema.empty`). The wiring guidance below was written for
56646
57208
  * exactly the case the operator is asking about again — a Dreame's HA
56647
57209
  * consumable-life sensors — so it is kept for that conversation, not because
@@ -56745,14 +57307,6 @@ var consumablesCapability = {
56745
57307
  deviceNative: true,
56746
57308
  mode: "singleton",
56747
57309
  deviceTypes: Object.values(DeviceType),
56748
- deviceConfig: { ui: {
56749
- kind: "widget",
56750
- widgetId: "host/consumables-panel",
56751
- tab: "consumables",
56752
- placement: "hero",
56753
- label: "Consumables",
56754
- order: 5
56755
- } },
56756
57310
  methods: {
56757
57311
  /** Mark a consumable as replaced — resets its remaining life. Only
56758
57312
  * meaningful when the item's `resettable` is true. */
@@ -58046,7 +58600,7 @@ var mediaPlayerCapability = {
58046
58600
  ]
58047
58601
  }
58048
58602
  };
58049
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Climate, DeviceType.Climate, DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Camera, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.PetFeeder, DeviceType.MediaPlayer;
58603
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Climate, DeviceType.EventEmitter, DeviceType.Climate, DeviceType.Climate, DeviceType.Camera, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.WeatherStation, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.PetFountain, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Gateway, DeviceType.HeatPump, DeviceType.EnergySystem, DeviceType.Camera, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Fan, DeviceType.Lock, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Gateway, DeviceType.Camera, DeviceType.Sensor, DeviceType.MediaPlayer, DeviceType.Vacuum, DeviceType.Generic, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.PetFountain, DeviceType.Fan, DeviceType.Humidifier, DeviceType.Climate, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.PetFeeder, DeviceType.MediaPlayer, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation, DeviceType.WeatherStation;
58050
58604
  var NUMBER = {
58051
58605
  kind: "fixed",
58052
58606
  result: ["number"]
@@ -58494,6 +59048,36 @@ function actuator(input) {
58494
59048
  }
58495
59049
  new Map(GROUP_TEMPLATES.map((template) => [template.id, template]));
58496
59050
  DeviceType.Camera;
59051
+ /**
59052
+ * The series a device card trends, per cap (`history.primary` + `history.priority`):
59053
+ * 6 caps. The card shows the primary of the enabled cap with the highest priority.
59054
+ */
59055
+ var HISTORY_PRIMARY = {
59056
+ "climate-control": {
59057
+ field: "currentTemp",
59058
+ priority: 70
59059
+ },
59060
+ "energy-system": {
59061
+ field: "house.powerW",
59062
+ priority: 50
59063
+ },
59064
+ "humidity-sensor": {
59065
+ field: "humidity",
59066
+ priority: 90
59067
+ },
59068
+ "power-meter": {
59069
+ field: "power",
59070
+ priority: 80
59071
+ },
59072
+ "temperature-sensor": {
59073
+ field: "temperature",
59074
+ priority: 100
59075
+ },
59076
+ "weather-station": {
59077
+ field: "temperature",
59078
+ priority: 60
59079
+ }
59080
+ };
58497
59081
  DeviceFeature.LightColorRgb, DeviceFeature.LightColorHsv, DeviceFeature.LightColorMired;
58498
59082
  var PowerSourceRefusalReasonSchema = _enum([
58499
59083
  "no-power-source",
@@ -58912,7 +59496,9 @@ var CoreBlockInputFieldsSchema = object({
58912
59496
  * from the compiled entry after a successful load; the editor may also set
58913
59497
  * it. Absent ⇒ `getBlockSettings` returns null until one is known.
58914
59498
  */
58915
- settingsSchema: CoreBlockSettingsSchemaBridge.optional()
59499
+ settingsSchema: CoreBlockSettingsSchemaBridge.optional(),
59500
+ /** Operator tags (D1054), kept on the record. Absent = no tags. */
59501
+ tags: TagsFieldSchema.optional()
58916
59502
  });
58917
59503
  /** Client-authored fields for create — requires `code` or `files[entry]`. */
58918
59504
  var CoreBlockInputSchema = CoreBlockInputFieldsSchema.superRefine((val, ctx) => {
@@ -58973,6 +59559,8 @@ var CoreBlockSchema = object({
58973
59559
  placement: CoreBlockPlacementSchema,
58974
59560
  integrationId: string().optional(),
58975
59561
  settingsSchema: CoreBlockSettingsSchemaBridge.optional(),
59562
+ /** Operator tags (D1054). Absent = no tags. */
59563
+ tags: TagsFieldSchema.optional(),
58976
59564
  id: string(),
58977
59565
  createdAt: number$1(),
58978
59566
  updatedAt: number$1(),
@@ -60222,6 +60810,7 @@ var DeviceTemplateThisDeviceSchema = object({
60222
60810
  deviceId: number$1().int(),
60223
60811
  values: record$1(string().min(1).max(64), DeviceTemplateValueSchema).optional()
60224
60812
  });
60813
+ deviceTemplateFilterNames();
60225
60814
  var DeviceTemplateRefusalSchema = object({
60226
60815
  reason: _enum([
60227
60816
  "too-long",
@@ -60843,6 +61432,8 @@ var DeviceInfoSchema = object({
60843
61432
  alias: DeviceAliasSchema.optional(),
60844
61433
  /** Operator-organisational location label. `null` when unset. */
60845
61434
  location: string().nullable(),
61435
+ /** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
61436
+ tags: TagsFieldSchema.optional(),
60846
61437
  /** Soft-disabled flag. */
60847
61438
  disabled: boolean(),
60848
61439
  parentDeviceId: number$1().nullable(),
@@ -60989,6 +61580,8 @@ var SavedDeviceRowSchema = object({
60989
61580
  name: string(),
60990
61581
  /** Operator-organisational location label. `null` when unset. */
60991
61582
  location: string().nullable(),
61583
+ /** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
61584
+ tags: TagsFieldSchema.optional(),
60992
61585
  /** Soft-disabled flag. */
60993
61586
  disabled: boolean(),
60994
61587
  parentDeviceId: number$1().nullable(),
@@ -61011,6 +61604,8 @@ var DeviceMetaSchema = object({
61011
61604
  * `DeviceMeta.userNamed`. */
61012
61605
  userNamed: boolean().optional(),
61013
61606
  location: string().nullable(),
61607
+ /** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
61608
+ tags: TagsFieldSchema.optional(),
61014
61609
  disabled: boolean(),
61015
61610
  parentDeviceId: number$1().nullable(),
61016
61611
  metadata: record$1(string(), unknown()).nullable().optional(),
@@ -61222,6 +61817,12 @@ method(object({
61222
61817
  }), _void(), {
61223
61818
  kind: "mutation",
61224
61819
  auth: "admin"
61820
+ }), method(object({
61821
+ deviceId: number$1(),
61822
+ tags: TagsFieldSchema
61823
+ }), _void(), {
61824
+ kind: "mutation",
61825
+ auth: "admin"
61225
61826
  }), method(object({
61226
61827
  deviceId: number$1(),
61227
61828
  type: _enum(DeviceType)
@@ -61307,6 +61908,7 @@ method(object({
61307
61908
  deviceId: number$1(),
61308
61909
  name: string().optional(),
61309
61910
  location: string().nullable().optional(),
61911
+ tags: TagsFieldSchema.optional(),
61310
61912
  type: _enum(DeviceType).optional(),
61311
61913
  integrationId: string().optional(),
61312
61914
  linkDeviceId: number$1().nullable().optional(),
@@ -63615,6 +64217,10 @@ method(object({
63615
64217
  * system did not report is `null`, never `0` (D393).
63616
64218
  *
63617
64219
  * Signs, all in watts:
64220
+ * - The branches are DISJOINT: `house` is the consumption EXCLUDING the heat pump
64221
+ * whenever `heatPump` is reported, so solar + grid import + storage discharge =
64222
+ * house + heatPump + grid export + storage charge. A provider whose meter totals
64223
+ * include the pump subtracts it; when it cannot, `house` is null (D393).
63618
64224
  * - `solar.powerW`, `house.powerW`, `heatPump.powerW` are magnitudes (≥ 0);
63619
64225
  * - `grid.powerW` is + importing, − exporting;
63620
64226
  * - `storage.powerW` is + charging, − discharging.
@@ -63704,91 +64310,100 @@ var energySystemCapability = {
63704
64310
  * have is null and records nothing. Day totals are not recorded: they are the
63705
64311
  * counters' difference over the day.
63706
64312
  */
63707
- history: { fields: {
63708
- "solar.powerW": {
63709
- kind: "gauge",
63710
- unit: "W",
63711
- deadband: 50,
63712
- displayName: "Solar power"
63713
- },
63714
- "solar.energyKwh": {
63715
- kind: "counter",
63716
- unit: "kWh",
63717
- displayName: "Solar energy"
63718
- },
63719
- "grid.powerW": {
63720
- kind: "gauge",
63721
- unit: "W",
63722
- deadband: 50,
63723
- displayName: "Grid power"
63724
- },
63725
- "grid.importKwh": {
63726
- kind: "counter",
63727
- unit: "kWh",
63728
- displayName: "Grid import"
63729
- },
63730
- "grid.exportKwh": {
63731
- kind: "counter",
63732
- unit: "kWh",
63733
- displayName: "Grid export"
63734
- },
63735
- "house.powerW": {
63736
- kind: "gauge",
63737
- unit: "W",
63738
- deadband: 50,
63739
- displayName: "House power"
63740
- },
63741
- "house.energyKwh": {
63742
- kind: "counter",
63743
- unit: "kWh",
63744
- displayName: "House energy"
63745
- },
63746
- "heatPump.powerW": {
63747
- kind: "gauge",
63748
- unit: "W",
63749
- deadband: 50,
63750
- displayName: "Heat pump power"
63751
- },
63752
- "heatPump.energyKwh": {
63753
- kind: "counter",
63754
- unit: "kWh",
63755
- displayName: "Heat pump energy"
63756
- },
63757
- "storage.stateOfChargePct": {
63758
- kind: "gauge",
63759
- unit: "%",
63760
- deadband: 1,
63761
- displayName: "Storage charge"
63762
- },
63763
- "storage.storedKwh": {
63764
- kind: "gauge",
63765
- unit: "kWh",
63766
- deadband: .05,
63767
- displayName: "Stored energy"
63768
- },
63769
- "storage.powerW": {
63770
- kind: "gauge",
63771
- unit: "W",
63772
- deadband: 50,
63773
- displayName: "Storage power"
63774
- },
63775
- "storage.chargedKwh": {
63776
- kind: "counter",
63777
- unit: "kWh",
63778
- displayName: "Storage charged"
63779
- },
63780
- "storage.dischargedKwh": {
63781
- kind: "counter",
63782
- unit: "kWh",
63783
- displayName: "Storage discharged"
63784
- },
63785
- "storage.healthPct": {
63786
- kind: "gauge",
63787
- unit: "%",
63788
- deadband: 1,
63789
- displayName: "Storage health"
64313
+ history: {
64314
+ primary: "house.powerW",
64315
+ priority: 50,
64316
+ fields: {
64317
+ "solar.powerW": {
64318
+ group: "power-flow",
64319
+ kind: "gauge",
64320
+ unit: "W",
64321
+ deadband: 50,
64322
+ displayName: "Solar power"
64323
+ },
64324
+ "solar.energyKwh": {
64325
+ kind: "counter",
64326
+ unit: "kWh",
64327
+ displayName: "Solar energy"
64328
+ },
64329
+ "grid.powerW": {
64330
+ group: "power-flow",
64331
+ kind: "gauge",
64332
+ unit: "W",
64333
+ deadband: 50,
64334
+ displayName: "Grid power"
64335
+ },
64336
+ "grid.importKwh": {
64337
+ kind: "counter",
64338
+ unit: "kWh",
64339
+ displayName: "Grid import"
64340
+ },
64341
+ "grid.exportKwh": {
64342
+ kind: "counter",
64343
+ unit: "kWh",
64344
+ displayName: "Grid export"
64345
+ },
64346
+ "house.powerW": {
64347
+ group: "power-flow",
64348
+ kind: "gauge",
64349
+ unit: "W",
64350
+ deadband: 50,
64351
+ displayName: "House power"
64352
+ },
64353
+ "house.energyKwh": {
64354
+ kind: "counter",
64355
+ unit: "kWh",
64356
+ displayName: "House energy"
64357
+ },
64358
+ "heatPump.powerW": {
64359
+ group: "power-flow",
64360
+ kind: "gauge",
64361
+ unit: "W",
64362
+ deadband: 50,
64363
+ displayName: "Heat pump power"
64364
+ },
64365
+ "heatPump.energyKwh": {
64366
+ kind: "counter",
64367
+ unit: "kWh",
64368
+ displayName: "Heat pump energy"
64369
+ },
64370
+ "storage.stateOfChargePct": {
64371
+ kind: "gauge",
64372
+ unit: "%",
64373
+ deadband: 1,
64374
+ displayName: "Storage charge"
64375
+ },
64376
+ "storage.storedKwh": {
64377
+ kind: "gauge",
64378
+ unit: "kWh",
64379
+ deadband: .05,
64380
+ displayName: "Stored energy"
64381
+ },
64382
+ "storage.powerW": {
64383
+ group: "power-flow",
64384
+ kind: "gauge",
64385
+ unit: "W",
64386
+ deadband: 50,
64387
+ displayName: "Storage power"
64388
+ },
64389
+ "storage.chargedKwh": {
64390
+ kind: "counter",
64391
+ unit: "kWh",
64392
+ displayName: "Storage charged"
64393
+ },
64394
+ "storage.dischargedKwh": {
64395
+ kind: "counter",
64396
+ unit: "kWh",
64397
+ displayName: "Storage discharged"
64398
+ },
64399
+ "storage.healthPct": {
64400
+ kind: "gauge",
64401
+ unit: "%",
64402
+ deadband: 1,
64403
+ displayName: "Storage health"
64404
+ }
63790
64405
  }
63791
- } },
64406
+ },
63792
64407
  volatileStateFields: ["lastFetchedAt"],
63793
64408
  vocabulary: {
63794
64409
  noun: t("Energy system", "Sistema energetico"),
@@ -63947,7 +64562,19 @@ var IdentitySampleInfoSchema = object({
63947
64562
  source: _enum(["detected", "photo"]),
63948
64563
  addedAt: number$1().int(),
63949
64564
  deviceId: number$1().int().optional(),
63950
- base64: string().optional()
64565
+ base64: string().optional(),
64566
+ /**
64567
+ * The sample's own crop, when it has one. The bytes stay on the event-media
64568
+ * plane — this list does not inline them.
64569
+ */
64570
+ mediaId: number$1().int().optional(),
64571
+ /**
64572
+ * The source face's key frame (or the photo the sample was cut from), when
64573
+ * the sample has no crop of its own. Draw {@link faceBbox} on it.
64574
+ */
64575
+ keyFrameMediaId: number$1().int().optional(),
64576
+ /** The face box on {@link keyFrameMediaId}, pixel space. */
64577
+ faceBbox: BoundingBoxSchema.optional()
63951
64578
  });
63952
64579
  /**
63953
64580
  * One enrolled sample, judged against the gallery it lives in.
@@ -64162,6 +64789,12 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
64162
64789
  }), _void(), {
64163
64790
  kind: "mutation",
64164
64791
  auth: "admin"
64792
+ }), method(object({
64793
+ sampleId: string().min(1),
64794
+ toIdentityId: string().min(1)
64795
+ }), _void(), {
64796
+ kind: "mutation",
64797
+ auth: "admin"
64165
64798
  }), method(object({
64166
64799
  /**
64167
64800
  * Restrict to ONE camera. Absent keeps the cluster-wide gallery view.
@@ -65818,12 +66451,14 @@ var heatPumpStatusCapability = {
65818
66451
  history: {
65819
66452
  fields: {
65820
66453
  "power.thermalW": {
66454
+ group: "power",
65821
66455
  kind: "gauge",
65822
66456
  unit: "W",
65823
66457
  deadband: 50,
65824
66458
  displayName: "Thermal power"
65825
66459
  },
65826
66460
  "power.electricalW": {
66461
+ group: "power",
65827
66462
  kind: "gauge",
65828
66463
  unit: "W",
65829
66464
  deadband: 50,
@@ -65836,12 +66471,14 @@ var heatPumpStatusCapability = {
65836
66471
  displayName: "Compressor"
65837
66472
  },
65838
66473
  "temperatures.supply": {
66474
+ group: "loop",
65839
66475
  kind: "gauge",
65840
66476
  unit: "°C",
65841
66477
  deadband: .5,
65842
66478
  displayName: "Supply"
65843
66479
  },
65844
66480
  "temperatures.return": {
66481
+ group: "loop",
65845
66482
  kind: "gauge",
65846
66483
  unit: "°C",
65847
66484
  deadband: .5,
@@ -66163,6 +66800,17 @@ var StateLookSchema = object({
66163
66800
  background: _enum(HERO_BACKGROUNDS),
66164
66801
  animation: HeroAnimationSchema
66165
66802
  });
66803
+ /**
66804
+ * Which history series a device card trends. Each cap declares its own
66805
+ * (`history.primary` + `history.priority`, projected into `HISTORY_PRIMARY`);
66806
+ * a device shows the primary of the ENABLED cap with the highest priority that
66807
+ * has data, falling back to the next.
66808
+ */
66809
+ /** The history series key of a cap's declared primary field; `null` when it declares none. */
66810
+ function primarySeriesKey(cap) {
66811
+ const primary = HISTORY_PRIMARY[cap];
66812
+ return primary === void 0 ? null : `cap:${cap}.${primary.field}`;
66813
+ }
66166
66814
  /** A string in both languages, as the cap vocabulary writes it (D920): no `t()` in the model. */
66167
66815
  var HeroTextSchema = object({
66168
66816
  en: string(),
@@ -66254,7 +66902,7 @@ function temperatureMeasurement(celsius, since) {
66254
66902
  tone: BAND_TONE[band],
66255
66903
  since,
66256
66904
  sinceKind: "updated",
66257
- historyKey: "cap:temperature-sensor.temperature"
66905
+ historyKey: primarySeriesKey("temperature-sensor")
66258
66906
  };
66259
66907
  }
66260
66908
  function humidityMeasurement(percent, since) {
@@ -66275,7 +66923,7 @@ function humidityMeasurement(percent, since) {
66275
66923
  tone: dry || humid ? "warning" : "info",
66276
66924
  since,
66277
66925
  sinceKind: "updated",
66278
- historyKey: "cap:humidity-sensor.humidity"
66926
+ historyKey: primarySeriesKey("humidity-sensor")
66279
66927
  };
66280
66928
  }
66281
66929
  function textMeasurement(text, since) {
@@ -66300,19 +66948,19 @@ var QUANTITY_FACE = {
66300
66948
  icon: "thermometer",
66301
66949
  unit: "°C",
66302
66950
  sinceKind: "updated",
66303
- historyKey: "cap:temperature-sensor.temperature"
66951
+ historyKey: primarySeriesKey("temperature-sensor")
66304
66952
  },
66305
66953
  humidity: {
66306
66954
  icon: "droplets",
66307
66955
  unit: "%",
66308
66956
  sinceKind: "updated",
66309
- historyKey: "cap:humidity-sensor.humidity"
66957
+ historyKey: primarySeriesKey("humidity-sensor")
66310
66958
  },
66311
66959
  power: {
66312
66960
  icon: "zap",
66313
66961
  unit: "W",
66314
66962
  sinceKind: "updated",
66315
- historyKey: "cap:power-meter.power"
66963
+ historyKey: primarySeriesKey("power-meter")
66316
66964
  },
66317
66965
  contact: {
66318
66966
  icon: null,
@@ -67077,11 +67725,15 @@ var humiditySensorCapability = {
67077
67725
  /**
67078
67726
  * History (D850): recorded series.
67079
67727
  */
67080
- history: { fields: { humidity: {
67081
- kind: "gauge",
67082
- unit: "%",
67083
- deadband: .5
67084
- } } },
67728
+ history: {
67729
+ primary: "humidity",
67730
+ priority: 90,
67731
+ fields: { humidity: {
67732
+ kind: "gauge",
67733
+ unit: "%",
67734
+ deadband: .5
67735
+ } }
67736
+ },
67085
67737
  /** Clock fields: written, but excluded from the compare that decides
67086
67738
  * whether persisting is worth a SQLite commit. */
67087
67739
  volatileStateFields: ["lastFetchedAt"],
@@ -81106,7 +81758,7 @@ var OsdSourceSchema = discriminatedUnion("kind", [
81106
81758
  object({ kind: literal("none") }),
81107
81759
  object({
81108
81760
  kind: literal("static"),
81109
- text: string().max(64)
81761
+ text: string().max(OSD_TEMPLATE_TEXT_MAX)
81110
81762
  }),
81111
81763
  object({
81112
81764
  kind: literal("template"),
@@ -82868,7 +83520,19 @@ var VehicleSampleInfoSchema = object({
82868
83520
  score: number$1(),
82869
83521
  addedAt: number$1().int(),
82870
83522
  deviceId: number$1().int().optional(),
82871
- base64: string().optional()
83523
+ base64: string().optional(),
83524
+ /**
83525
+ * The sample's own crop, when it has one. Prefer this over {@link base64}:
83526
+ * the bytes are on the event-media plane (`/m/<mediaId>`), never inlined.
83527
+ */
83528
+ mediaId: number$1().int().optional(),
83529
+ /**
83530
+ * The source plate's key frame, when the sample has no crop of its own.
83531
+ * Draw {@link plateBbox} on it. Absent when {@link mediaId} is set.
83532
+ */
83533
+ keyFrameMediaId: number$1().int().optional(),
83534
+ /** The plate box on {@link keyFrameMediaId}, pixel space. */
83535
+ plateBbox: BoundingBoxSchema.optional()
82872
83536
  });
82873
83537
  var PlateInfoSchema = object({
82874
83538
  plateId: string(),
@@ -82898,7 +83562,17 @@ var PlateInfoSchema = object({
82898
83562
  * and `searchPlates` inline the crop only when their `includeCrops` input is
82899
83563
  * left at its `true` default.
82900
83564
  */
82901
- cropUrl: string().optional()
83565
+ cropUrl: string().optional(),
83566
+ /**
83567
+ * Why {@link cropUrl} is absent. One of `no-frame-handle`,
83568
+ * `live-capture-missed`, `live-capture-threw`, `no-key-frame`,
83569
+ * `derive-not-wired`, `subject-moved`, `temporal-skew`, `key-frame-absent`,
83570
+ * `bad-frame-size`, `decode-empty`, `derive-threw`, `derive-returned-null`,
83571
+ * `put-failed`. A crossing vehicle whose live capture missed is
83572
+ * `subject-moved`: the key frame is a different instant, and the crop is
83573
+ * legitimately absent.
83574
+ */
83575
+ cropMissReason: string().optional()
82902
83576
  });
82903
83577
  /**
82904
83578
  * One gallery media row: what the crop is, how big it is, and WHERE its bytes
@@ -82998,6 +83672,12 @@ includeCrops: boolean().optional() }).optional(), array(VehicleSchema).readonly(
82998
83672
  }), _void(), {
82999
83673
  kind: "mutation",
83000
83674
  auth: "admin"
83675
+ }), method(object({
83676
+ sampleId: string().min(1),
83677
+ toVehicleId: string().min(1)
83678
+ }), _void(), {
83679
+ kind: "mutation",
83680
+ auth: "admin"
83001
83681
  }), method(object({
83002
83682
  plateId: string(),
83003
83683
  vehicleId: string()
@@ -83354,44 +84034,48 @@ var powerMeterCapability = {
83354
84034
  /**
83355
84035
  * History (D850): recorded series. Gauges are floored at 30 s; `energy` is the one monotonic meter (counter).
83356
84036
  */
83357
- history: { fields: {
83358
- power: {
83359
- kind: "gauge",
83360
- unit: "W",
83361
- deadband: 1,
83362
- minIntervalMs: 3e4
83363
- },
83364
- energy: {
83365
- kind: "counter",
83366
- unit: "kWh",
83367
- deadband: .01,
83368
- minIntervalMs: 6e4
83369
- },
83370
- voltage: {
83371
- kind: "gauge",
83372
- unit: "V",
83373
- deadband: 1,
83374
- minIntervalMs: 3e4
83375
- },
83376
- current: {
83377
- kind: "gauge",
83378
- unit: "A",
83379
- deadband: .05,
83380
- minIntervalMs: 3e4
83381
- },
83382
- apparentPower: {
83383
- kind: "gauge",
83384
- unit: "VA",
83385
- deadband: 1,
83386
- minIntervalMs: 3e4
83387
- },
83388
- powerFactor: {
83389
- kind: "gauge",
83390
- unit: "ratio",
83391
- deadband: .01,
83392
- minIntervalMs: 6e4
84037
+ history: {
84038
+ primary: "power",
84039
+ priority: 80,
84040
+ fields: {
84041
+ power: {
84042
+ kind: "gauge",
84043
+ unit: "W",
84044
+ deadband: 1,
84045
+ minIntervalMs: 3e4
84046
+ },
84047
+ energy: {
84048
+ kind: "counter",
84049
+ unit: "kWh",
84050
+ deadband: .01,
84051
+ minIntervalMs: 6e4
84052
+ },
84053
+ voltage: {
84054
+ kind: "gauge",
84055
+ unit: "V",
84056
+ deadband: 1,
84057
+ minIntervalMs: 3e4
84058
+ },
84059
+ current: {
84060
+ kind: "gauge",
84061
+ unit: "A",
84062
+ deadband: .05,
84063
+ minIntervalMs: 3e4
84064
+ },
84065
+ apparentPower: {
84066
+ kind: "gauge",
84067
+ unit: "VA",
84068
+ deadband: 1,
84069
+ minIntervalMs: 3e4
84070
+ },
84071
+ powerFactor: {
84072
+ kind: "gauge",
84073
+ unit: "ratio",
84074
+ deadband: .01,
84075
+ minIntervalMs: 6e4
84076
+ }
83393
84077
  }
83394
- } },
84078
+ },
83395
84079
  /** Clock fields: written, but excluded from the compare that decides
83396
84080
  * whether persisting is worth a SQLite commit. */
83397
84081
  volatileStateFields: ["lastFetchedAt"],
@@ -89330,18 +90014,22 @@ var streamParamsCapability = {
89330
90014
  */
89331
90015
  history: { fields: {
89332
90016
  "main.bitrate": {
90017
+ group: "bitrate",
89333
90018
  kind: "gauge",
89334
90019
  unit: "kbps"
89335
90020
  },
89336
90021
  "main.framerate": {
90022
+ group: "framerate",
89337
90023
  kind: "gauge",
89338
90024
  unit: "fps"
89339
90025
  },
89340
90026
  "sub.bitrate": {
90027
+ group: "bitrate",
89341
90028
  kind: "gauge",
89342
90029
  unit: "kbps"
89343
90030
  },
89344
90031
  "sub.framerate": {
90032
+ group: "framerate",
89345
90033
  kind: "gauge",
89346
90034
  unit: "fps"
89347
90035
  }
@@ -90288,6 +90976,50 @@ method(_void(), SystemInfoSchema), method(_void(), HealthStatusSchema), method(_
90288
90976
  auth: "admin"
90289
90977
  }), NOT_A_DEVICE.CLUSTER;
90290
90978
  /**
90979
+ * tags — the registry of tag STYLES and the one place that renames or removes a
90980
+ * tag everywhere (D1054). A tag itself lives in the `tags` array of the record it
90981
+ * labels (a core block, a scheduler, a template, an action, a device); only its
90982
+ * colour token and icon are registered here. Provided by the core-blocks builtin,
90983
+ * the one place that knows every owner kind; devices are reached through
90984
+ * `deviceManager` over `ctx.api`.
90985
+ *
90986
+ * Tags compare trimmed and case-insensitively. `list` is the union of styled tags
90987
+ * and tags in use; a tag with no style answers a colour derived from its name and
90988
+ * the default icon (`styled: false`).
90989
+ */
90990
+ var TagUsageCountsSchema = object({
90991
+ coreBlocks: number$1().int().nonnegative(),
90992
+ schedulers: number$1().int().nonnegative(),
90993
+ templates: number$1().int().nonnegative(),
90994
+ actions: number$1().int().nonnegative(),
90995
+ devices: number$1().int().nonnegative()
90996
+ });
90997
+ var TagEntrySchema = object({
90998
+ name: TagNameSchema,
90999
+ color: TagColorIdSchema,
91000
+ icon: IconKeySchema,
91001
+ /** `false` when the operator never chose a style: colour and icon are the derived defaults. */
91002
+ styled: boolean(),
91003
+ counts: TagUsageCountsSchema
91004
+ });
91005
+ method(object({}), array(TagEntrySchema), { auth: "protected" }), method(object({
91006
+ name: TagNameSchema,
91007
+ color: TagColorIdSchema,
91008
+ icon: IconKeySchema
91009
+ }), _void(), {
91010
+ kind: "mutation",
91011
+ auth: "admin"
91012
+ }), method(object({
91013
+ from: string(),
91014
+ to: string()
91015
+ }), object({ updated: TagUsageCountsSchema }), {
91016
+ kind: "mutation",
91017
+ auth: "admin"
91018
+ }), method(object({ name: string() }), object({ updated: TagUsageCountsSchema }), {
91019
+ kind: "mutation",
91020
+ auth: "admin"
91021
+ });
91022
+ /**
90291
91023
  * Tamper / case-open detection sensor. Drives Home Assistant
90292
91024
  * `binary_sensor` entries with `device_class: tamper`. Push-driven.
90293
91025
  */
@@ -90380,11 +91112,15 @@ var temperatureSensorCapability = {
90380
91112
  /**
90381
91113
  * History (D850): recorded series.
90382
91114
  */
90383
- history: { fields: { temperature: {
90384
- kind: "gauge",
90385
- unit: "°C",
90386
- deadband: .1
90387
- } } },
91115
+ history: {
91116
+ primary: "temperature",
91117
+ priority: 100,
91118
+ fields: { temperature: {
91119
+ kind: "gauge",
91120
+ unit: "°C",
91121
+ deadband: .1
91122
+ } }
91123
+ },
90388
91124
  /** Clock fields: written, but excluded from the compare that decides
90389
91125
  * whether persisting is worth a SQLite commit. */
90390
91126
  volatileStateFields: ["lastFetchedAt"],
@@ -90747,7 +91483,9 @@ var TemplateRecordSchema = object({
90747
91483
  createdAt: number$1(),
90748
91484
  updatedAt: number$1(),
90749
91485
  /** Shipped with CamStack (`builtin:` ids): listed beside the operator's, never updated or deleted. */
90750
- builtIn: literal(true).optional()
91486
+ builtIn: literal(true).optional(),
91487
+ /** Operator tags (D1054). Absent = no tags. */
91488
+ tags: TagsFieldSchema.optional()
90751
91489
  });
90752
91490
  var TemplateWriteResultSchema = discriminatedUnion("status", [object({
90753
91491
  status: literal("saved"),
@@ -90784,14 +91522,16 @@ var TemplateDeleteResultSchema = discriminatedUnion("status", [
90784
91522
  method(object({ kind: TemplateKindSchema.optional() }), array(TemplateRecordSchema), { auth: "protected" }), method(object({ id: string().min(1) }), TemplateRecordSchema.nullable(), { auth: "protected" }), method(object({
90785
91523
  kind: TemplateKindSchema,
90786
91524
  name: string().min(1).max(120),
90787
- payload: unknown()
91525
+ payload: unknown(),
91526
+ tags: TagsFieldSchema.optional()
90788
91527
  }), TemplateWriteResultSchema, {
90789
91528
  kind: "mutation",
90790
91529
  auth: "admin"
90791
91530
  }), method(object({
90792
91531
  id: string().min(1),
90793
91532
  name: string().min(1).max(120).optional(),
90794
- payload: unknown().optional()
91533
+ payload: unknown().optional(),
91534
+ tags: TagsFieldSchema.optional()
90795
91535
  }), TemplateWriteResultSchema, {
90796
91536
  kind: "mutation",
90797
91537
  auth: "admin"
@@ -92730,11 +93470,13 @@ var waterHeaterCapability = {
92730
93470
  */
92731
93471
  history: { fields: {
92732
93472
  currentTemp: {
93473
+ group: "temperature",
92733
93474
  kind: "gauge",
92734
93475
  unit: "°C",
92735
93476
  deadband: .5
92736
93477
  },
92737
93478
  targetTemp: {
93479
+ group: "temperature",
92738
93480
  kind: "gauge",
92739
93481
  unit: "°C",
92740
93482
  minIntervalMs: 0
@@ -92904,18 +93646,30 @@ var weatherCapability = {
92904
93646
  }
92905
93647
  };
92906
93648
  var WeatherStationStatusSchema = object({
92907
- temperature: number$1().nullable().meta(readingMeta("temperature", { precision: 1 })),
92908
- humidity: number$1().min(0).max(100).nullable().meta(readingMeta("humidity")),
92909
- pressure: number$1().nullable().meta(readingMeta("pressure")),
92910
- windSpeed: number$1().nullable().meta(readingMeta("speed")),
92911
- windGust: number$1().nullable().meta(readingMeta("speed")),
92912
- windBearing: number$1().nullable().meta(readingMeta("angle")),
92913
- rainRate: number$1().nullable().meta(readingMeta("precipitation-rate", { precision: 1 })),
92914
- rainDaily: number$1().nullable().meta(readingMeta("precipitation", { precision: 1 })),
92915
- rainEvent: number$1().nullable().meta(readingMeta("precipitation", { precision: 1 })),
92916
- uv: number$1().nullable().meta(readingMeta("index", { precision: 1 })),
92917
- solarRadiation: number$1().nullable().meta(readingMeta("irradiance")),
92918
- dewPoint: number$1().nullable().meta(readingMeta("temperature", { precision: 1 }))
93649
+ temperature: number$1().nullable().default(null).meta(readingMeta("temperature", { precision: 1 })),
93650
+ humidity: number$1().min(0).max(100).nullable().default(null).meta(readingMeta("humidity")),
93651
+ pressure: number$1().nullable().default(null).meta(readingMeta("pressure")),
93652
+ windSpeed: number$1().nullable().default(null).meta(readingMeta("speed")),
93653
+ windGust: number$1().nullable().default(null).meta(readingMeta("speed")),
93654
+ windBearing: number$1().nullable().default(null).meta(readingMeta("angle")),
93655
+ rainRate: number$1().nullable().default(null).meta(readingMeta("precipitation-rate", { precision: 1 })),
93656
+ rainDaily: number$1().nullable().default(null).meta(readingMeta("precipitation", { precision: 1 })),
93657
+ rainEvent: number$1().nullable().default(null).meta(readingMeta("precipitation", { precision: 1 })),
93658
+ uv: number$1().nullable().default(null).meta(readingMeta("index", { precision: 1 })),
93659
+ solarRadiation: number$1().nullable().default(null).meta(readingMeta("irradiance")),
93660
+ dewPoint: number$1().nullable().default(null).meta(readingMeta("temperature", { precision: 1 })),
93661
+ /** Apparent ("feels like") temperature. */
93662
+ feelsLike: number$1().nullable().default(null).meta(readingMeta("temperature", { precision: 1 })),
93663
+ /** Vapour-pressure deficit, stored in kPa (the unit stations and growers read it in). */
93664
+ vpd: number$1().nullable().default(null).meta(readingMeta("none", { precision: 2 })),
93665
+ /** Highest wind gust since local midnight. */
93666
+ windGustMax: number$1().nullable().default(null).meta(readingMeta("speed")),
93667
+ /** Wind bearing averaged over the station's own window. */
93668
+ windBearingAvg: number$1().nullable().default(null).meta(readingMeta("angle")),
93669
+ rain24h: number$1().nullable().default(null).meta(readingMeta("precipitation", { precision: 1 })),
93670
+ rainWeekly: number$1().nullable().default(null).meta(readingMeta("precipitation", { precision: 1 })),
93671
+ rainMonthly: number$1().nullable().default(null).meta(readingMeta("precipitation", { precision: 1 })),
93672
+ rainYearly: number$1().nullable().default(null).meta(readingMeta("precipitation", { precision: 1 }))
92919
93673
  }).extend({
92920
93674
  /** Ms epoch of the poll that produced this slice. 0 before the first one. */
92921
93675
  lastFetchedAt: number$1() });
@@ -92927,6 +93681,75 @@ var numeric = (field, quantity, label, unit, icon) => ({
92927
93681
  unit,
92928
93682
  icon
92929
93683
  });
93684
+ /** Every reading of the station with the unit a Customize source must carry ('' = dimensionless). */
93685
+ var STATION_FIELD_UNITS = {
93686
+ temperature: "°C",
93687
+ humidity: "%",
93688
+ pressure: "hPa",
93689
+ windSpeed: "m/s",
93690
+ windGust: "m/s",
93691
+ windBearing: "°",
93692
+ rainRate: "mm/h",
93693
+ rainDaily: "mm",
93694
+ rainEvent: "mm",
93695
+ uv: "",
93696
+ solarRadiation: "W/m²",
93697
+ dewPoint: "°C",
93698
+ feelsLike: "°C",
93699
+ vpd: "kPa",
93700
+ windGustMax: "m/s",
93701
+ windBearingAvg: "°",
93702
+ rain24h: "mm",
93703
+ rainWeekly: "mm",
93704
+ rainMonthly: "mm",
93705
+ rainYearly: "mm"
93706
+ };
93707
+ function isStationField(key) {
93708
+ return Object.prototype.hasOwnProperty.call(STATION_FIELD_UNITS, key);
93709
+ }
93710
+ var STATION_FIELDS = Object.keys(STATION_FIELD_UNITS).filter(isStationField);
93711
+ /**
93712
+ * One scalar target per reading, `apply: 'add'` and listed in `overridable` by its own id
93713
+ * (the running-state / climate-control mechanism, D984 / D990): a station that reports a
93714
+ * reading natively keeps it until the operator assigns another device to that ONE field,
93715
+ * and a device with no `weather-station` slice becomes one from the sources picked. On an
93716
+ * add, every other reading is absent from the claim and the schema defaults it to null
93717
+ * (a missing sensor is never 0, D393) — the fan-control precedent, never a cross-field companion
93718
+ * (the scalar merge treats a companion as owned by its target).
93719
+ */
93720
+ function stationTarget(field) {
93721
+ const unit = STATION_FIELD_UNITS[field];
93722
+ return {
93723
+ id: field,
93724
+ cardinality: "scalar",
93725
+ vocabulary: {
93726
+ cap: "weather-station",
93727
+ stateField: field
93728
+ },
93729
+ deviceTypes: [DeviceType.WeatherStation],
93730
+ apply: "add",
93731
+ path: field,
93732
+ sources: [{
93733
+ kind: "numeric",
93734
+ ...unit.length > 0 ? { requiredUnit: unit } : {},
93735
+ transforms: [{ kind: "identity" }]
93736
+ }],
93737
+ companions: [{
93738
+ kind: "clock",
93739
+ path: "lastFetchedAt",
93740
+ when: "add"
93741
+ }],
93742
+ sourceReport: { status: "assignment-status" }
93743
+ };
93744
+ }
93745
+ var weatherStationCustomize = {
93746
+ version: 1,
93747
+ overridable: STATION_FIELDS.map((field) => ({
93748
+ path: field,
93749
+ by: field
93750
+ })),
93751
+ targets: STATION_FIELDS.map(stationTarget)
93752
+ };
92930
93753
  var weatherStationCapability = {
92931
93754
  name: "weather-station",
92932
93755
  scope: "device",
@@ -92940,10 +93763,127 @@ var weatherStationCapability = {
92940
93763
  },
92941
93764
  runtimeState: WeatherStationStatusSchema,
92942
93765
  /**
92943
- * The sensor children already record each reading. The station slice is the
92944
- * live aggregate a template reads; it does not keep a second series.
93766
+ * History (D850): the station records its own readings. Rain totals that
93767
+ * reset (event, day, week, month, year) and the sliding 24 h total are
93768
+ * levels, so `gauge`; `counter` is for a monotonic meter only.
92945
93769
  */
92946
- history: "none",
93770
+ history: {
93771
+ primary: "temperature",
93772
+ priority: 60,
93773
+ fields: {
93774
+ temperature: {
93775
+ group: "temperature",
93776
+ kind: "gauge",
93777
+ unit: "°C",
93778
+ deadband: .1
93779
+ },
93780
+ humidity: {
93781
+ kind: "gauge",
93782
+ unit: "%",
93783
+ deadband: 1
93784
+ },
93785
+ pressure: {
93786
+ kind: "gauge",
93787
+ unit: "hPa",
93788
+ deadband: .2
93789
+ },
93790
+ windSpeed: {
93791
+ group: "wind-speed",
93792
+ kind: "gauge",
93793
+ unit: "m/s",
93794
+ deadband: .2
93795
+ },
93796
+ windGust: {
93797
+ group: "wind-speed",
93798
+ kind: "gauge",
93799
+ unit: "m/s",
93800
+ deadband: .2
93801
+ },
93802
+ windBearing: {
93803
+ group: "wind-bearing",
93804
+ kind: "gauge",
93805
+ unit: "°",
93806
+ deadband: 5
93807
+ },
93808
+ rainRate: {
93809
+ kind: "gauge",
93810
+ unit: "mm/h",
93811
+ deadband: .1
93812
+ },
93813
+ rainDaily: {
93814
+ kind: "gauge",
93815
+ unit: "mm",
93816
+ deadband: .1
93817
+ },
93818
+ rainEvent: {
93819
+ kind: "gauge",
93820
+ unit: "mm",
93821
+ deadband: .1
93822
+ },
93823
+ uv: {
93824
+ kind: "gauge",
93825
+ unit: "index",
93826
+ deadband: .1
93827
+ },
93828
+ solarRadiation: {
93829
+ kind: "gauge",
93830
+ unit: "W/m²",
93831
+ deadband: 5
93832
+ },
93833
+ dewPoint: {
93834
+ group: "temperature",
93835
+ kind: "gauge",
93836
+ unit: "°C",
93837
+ deadband: .1
93838
+ },
93839
+ feelsLike: {
93840
+ group: "temperature",
93841
+ kind: "gauge",
93842
+ unit: "°C",
93843
+ deadband: .1
93844
+ },
93845
+ vpd: {
93846
+ kind: "gauge",
93847
+ unit: "kPa",
93848
+ deadband: .05
93849
+ },
93850
+ windGustMax: {
93851
+ group: "wind-speed",
93852
+ kind: "gauge",
93853
+ unit: "m/s",
93854
+ deadband: .2
93855
+ },
93856
+ windBearingAvg: {
93857
+ group: "wind-bearing",
93858
+ kind: "gauge",
93859
+ unit: "°",
93860
+ deadband: 5
93861
+ },
93862
+ rain24h: {
93863
+ kind: "gauge",
93864
+ unit: "mm",
93865
+ deadband: .1
93866
+ },
93867
+ rainWeekly: {
93868
+ kind: "gauge",
93869
+ unit: "mm",
93870
+ deadband: .1
93871
+ },
93872
+ rainMonthly: {
93873
+ kind: "gauge",
93874
+ unit: "mm",
93875
+ deadband: .1
93876
+ },
93877
+ rainYearly: {
93878
+ kind: "gauge",
93879
+ unit: "mm",
93880
+ deadband: .1
93881
+ }
93882
+ }
93883
+ },
93884
+ customize: weatherStationCustomize,
93885
+ /** The poll clock is written but is no reason to commit a row. */
93886
+ volatileStateFields: ["lastFetchedAt"],
92947
93887
  /**
92948
93888
  * Runtime-state durability: **session** — a station reading is stale the
92949
93889
  * moment the hub is down; the provider re-reads on the next poll.
@@ -92964,7 +93904,15 @@ var weatherStationCapability = {
92964
93904
  numeric("rainEvent", t("the rain this event", "la pioggia di questo evento"), t("Rain event", "Evento di pioggia"), "mm", "droplets"),
92965
93905
  numeric("uv", t("the UV index", "l’indice UV"), t("UV", "UV"), "", "cloud-sun"),
92966
93906
  numeric("solarRadiation", t("the solar radiation", "la radiazione solare"), t("Solar", "Sole"), "W/m²", "cloud-sun"),
92967
- numeric("dewPoint", t("the dew point", "il punto di rugiada"), t("Dew point", "Punto di rugiada"), "°C", "thermometer")
93907
+ numeric("dewPoint", t("the dew point", "il punto di rugiada"), t("Dew point", "Punto di rugiada"), "°C", "thermometer"),
93908
+ numeric("feelsLike", t("the feels-like temperature", "la temperatura percepita"), t("Feels like", "Percepita"), "°C", "thermometer"),
93909
+ numeric("vpd", t("the vapour-pressure deficit", "il deficit di pressione di vapore"), t("VPD", "VPD"), "kPa", "gauge"),
93910
+ numeric("windGustMax", t("the highest gust today", "la raffica massima di oggi"), t("Max gust", "Raffica max"), "m/s", "wind"),
93911
+ numeric("windBearingAvg", t("the average wind bearing", "la direzione media del vento"), t("Avg bearing", "Direzione media"), "°", "wind"),
93912
+ numeric("rain24h", t("the rain in the last 24 hours", "la pioggia delle ultime 24 ore"), t("Rain 24 h", "Pioggia 24 h"), "mm", "droplets"),
93913
+ numeric("rainWeekly", t("the rain this week", "la pioggia di questa settimana"), t("Rain week", "Pioggia settimana"), "mm", "droplets"),
93914
+ numeric("rainMonthly", t("the rain this month", "la pioggia di questo mese"), t("Rain month", "Pioggia mese"), "mm", "droplets"),
93915
+ numeric("rainYearly", t("the rain this year", "la pioggia di quest’anno"), t("Rain year", "Pioggia anno"), "mm", "droplets")
92968
93916
  ]
92969
93917
  }
92970
93918
  };
@@ -92981,7 +93929,15 @@ var webrtcClientHintsSchema = object({
92981
93929
  /** navigator.connection.downlink — Mbps the browser estimates. */
92982
93930
  downlinkMbps: number$1().nonnegative().optional(),
92983
93931
  /** Hard tier override; takes precedence over scoring when registered. */
92984
- prefersTier: string().optional()
93932
+ prefersTier: string().optional(),
93933
+ /**
93934
+ * What the session is opened FOR. `clip` = the client opens it to play a
93935
+ * stored clip (`playClip` on the control channel): the server negotiates
93936
+ * without dialling the camera and attaches live only when the client
93937
+ * sends `goLive` — a sleeping battery camera is never woken to watch our
93938
+ * own footage (#566). Absent or `live` = today's live-first session.
93939
+ */
93940
+ intent: _enum(["live", "clip"]).optional()
92985
93941
  }).partial();
92986
93942
  /**
92987
93943
  * Discriminated target for a WebRTC session. The client sends this
@@ -101405,6 +102361,13 @@ Object.freeze({
101405
102361
  access: "create",
101406
102362
  role: "admin"
101407
102363
  },
102364
+ "deviceManager.setTags": {
102365
+ capName: "device-manager",
102366
+ capScope: "system",
102367
+ addonId: null,
102368
+ access: "create",
102369
+ role: "admin"
102370
+ },
101408
102371
  "deviceManager.setType": {
101409
102372
  capName: "device-manager",
101410
102373
  capScope: "system",
@@ -102035,6 +102998,13 @@ Object.freeze({
102035
102998
  access: "view",
102036
102999
  role: "feature:face-assignment"
102037
103000
  },
103001
+ "faceGallery.moveIdentitySample": {
103002
+ capName: "face-gallery",
103003
+ capScope: "system",
103004
+ addonId: null,
103005
+ access: "create",
103006
+ role: "feature:face-assignment"
103007
+ },
102038
103008
  "faceGallery.removeSample": {
102039
103009
  capName: "face-gallery",
102040
103010
  capScope: "system",
@@ -105955,6 +106925,13 @@ Object.freeze({
105955
106925
  access: "view",
105956
106926
  role: "feature:plate-assignment"
105957
106927
  },
106928
+ "plateGallery.moveVehicleSample": {
106929
+ capName: "plate-gallery",
106930
+ capScope: "system",
106931
+ addonId: null,
106932
+ access: "create",
106933
+ role: "feature:plate-assignment"
106934
+ },
105958
106935
  "plateGallery.removeVehicleSample": {
105959
106936
  capName: "plate-gallery",
105960
106937
  capScope: "system",
@@ -108104,6 +109081,34 @@ Object.freeze({
108104
109081
  access: "create",
108105
109082
  role: "admin"
108106
109083
  },
109084
+ "tags.list": {
109085
+ capName: "tags",
109086
+ capScope: "system",
109087
+ addonId: null,
109088
+ access: "view",
109089
+ role: "admin"
109090
+ },
109091
+ "tags.remove": {
109092
+ capName: "tags",
109093
+ capScope: "system",
109094
+ addonId: null,
109095
+ access: "delete",
109096
+ role: "admin"
109097
+ },
109098
+ "tags.rename": {
109099
+ capName: "tags",
109100
+ capScope: "system",
109101
+ addonId: null,
109102
+ access: "create",
109103
+ role: "admin"
109104
+ },
109105
+ "tags.setStyle": {
109106
+ capName: "tags",
109107
+ capScope: "system",
109108
+ addonId: null,
109109
+ access: "create",
109110
+ role: "admin"
109111
+ },
108107
109112
  "tamper.getStatus": {
108108
109113
  capName: "tamper",
108109
109114
  capScope: "device",
@@ -110061,6 +111066,11 @@ Object.freeze({
110061
111066
  form: "single",
110062
111067
  optional: false
110063
111068
  }],
111069
+ "deviceManager.setTags": [{
111070
+ name: "deviceId",
111071
+ form: "single",
111072
+ optional: false
111073
+ }],
110064
111074
  "deviceManager.setType": [{
110065
111075
  name: "deviceId",
110066
111076
  form: "single",
@@ -114456,6 +115466,146 @@ function channelNameLookup(devices) {
114456
115466
  };
114457
115467
  };
114458
115468
  }
115469
+ /**
115470
+ * Delays (ms) before re-running a call that failed because the CCU is not
115471
+ * ready yet ({@link isTransientCcuError}). The slot is held while waiting, so
115472
+ * a booting CCU slows the whole burst down instead of being polled harder.
115473
+ */
115474
+ var CCU_TRANSIENT_RETRY_DELAYS_MS = [
115475
+ 1e3,
115476
+ 3e3,
115477
+ 1e4
115478
+ ];
115479
+ /**
115480
+ * Error names the CCU library uses for "not ready, try again later". Matched
115481
+ * by name, not by class: `BackendUnavailableError` and `LoginBackoffError`
115482
+ * only exist in library versions after 0.9.0, and the code must work on both.
115483
+ */
115484
+ var TRANSIENT_CCU_ERROR_NAMES = new Set([
115485
+ "BackendUnavailableError",
115486
+ "LoginBackoffError",
115487
+ "NoConnectionError",
115488
+ "CircuitBreakerOpenError"
115489
+ ]);
115490
+ /** True for an error worth retrying later: the CCU is down, booting or backing off logins. */
115491
+ function isTransientCcuError(err) {
115492
+ return err instanceof Error && TRANSIENT_CCU_ERROR_NAMES.has(err.name);
115493
+ }
115494
+ /** Raised for a call still queued, or waiting out a backoff, when its integration's session is stopped. */
115495
+ var CcuCallLimiterDisposedError = class extends Error {
115496
+ constructor() {
115497
+ super("Homematic session stopped before the CCU call ran");
115498
+ this.name = "CcuCallLimiterDisposedError";
115499
+ }
115500
+ };
115501
+ /**
115502
+ * Bounded concurrency for the CCU calls of ONE integration, shared by every
115503
+ * device of that integration and by the CCU page. A call that fails with a
115504
+ * {@link isTransientCcuError transient} error is re-run on
115505
+ * {@link CCU_TRANSIENT_RETRY_DELAYS_MS}; any other error is the caller's.
115506
+ */
115507
+ var HmCcuCallLimiter = class {
115508
+ #concurrency;
115509
+ #retryDelaysMs;
115510
+ #queue = [];
115511
+ /** Backoff sleeps in progress; dispose cancels them so no call runs after it. */
115512
+ #sleeps = /* @__PURE__ */ new Set();
115513
+ #active = 0;
115514
+ #disposed = false;
115515
+ constructor(options = {}) {
115516
+ this.#concurrency = Math.max(1, options.concurrency ?? 2);
115517
+ this.#retryDelaysMs = options.retryDelaysMs ?? CCU_TRANSIENT_RETRY_DELAYS_MS;
115518
+ }
115519
+ /** Run `call` when a slot is free, retrying it while the CCU is not ready. */
115520
+ async run(call) {
115521
+ await this.#acquire();
115522
+ try {
115523
+ return await this.#withRetry(call);
115524
+ } finally {
115525
+ this.#release();
115526
+ }
115527
+ }
115528
+ /**
115529
+ * Stop retrying: reject every queued call and every call waiting out a
115530
+ * backoff. A call already on the wire finishes on its own.
115531
+ */
115532
+ dispose() {
115533
+ this.#disposed = true;
115534
+ for (const queued of this.#queue.splice(0)) queued.cancel(new CcuCallLimiterDisposedError());
115535
+ for (const sleep of [...this.#sleeps]) sleep.cancel(new CcuCallLimiterDisposedError());
115536
+ this.#sleeps.clear();
115537
+ }
115538
+ #acquire() {
115539
+ if (this.#disposed) return Promise.reject(new CcuCallLimiterDisposedError());
115540
+ if (this.#active < this.#concurrency) {
115541
+ this.#active += 1;
115542
+ return Promise.resolve();
115543
+ }
115544
+ return new Promise((resolve, reject) => {
115545
+ this.#queue.push({
115546
+ start: () => {
115547
+ this.#active += 1;
115548
+ resolve();
115549
+ },
115550
+ cancel: reject
115551
+ });
115552
+ });
115553
+ }
115554
+ #release() {
115555
+ this.#active -= 1;
115556
+ this.#queue.shift()?.start();
115557
+ }
115558
+ async #withRetry(call) {
115559
+ for (let attempt = 0;; attempt += 1) try {
115560
+ return await call();
115561
+ } catch (err) {
115562
+ const delay = this.#retryDelaysMs[attempt];
115563
+ if (this.#disposed || delay === void 0 || !isTransientCcuError(err)) throw err;
115564
+ await this.#sleep(delay);
115565
+ }
115566
+ }
115567
+ /** A backoff wait that {@link dispose} rejects with {@link CcuCallLimiterDisposedError}. */
115568
+ #sleep(delayMs) {
115569
+ return new Promise((resolve, reject) => {
115570
+ const sleep = {
115571
+ start: () => {
115572
+ this.#sleeps.delete(sleep);
115573
+ resolve();
115574
+ },
115575
+ cancel: (err) => {
115576
+ clearTimeout(timer);
115577
+ reject(err);
115578
+ }
115579
+ };
115580
+ const timer = setTimeout(sleep.start, delayMs);
115581
+ this.#sleeps.add(sleep);
115582
+ });
115583
+ }
115584
+ };
115585
+ /** True when a CCU call was dropped because its session stopped — not a read failure. */
115586
+ function isCcuCallDisposed(err) {
115587
+ return err instanceof CcuCallLimiterDisposedError;
115588
+ }
115589
+ /** One limiter per integration id, shared by its devices and the CCU page. */
115590
+ var limiters = /* @__PURE__ */ new Map();
115591
+ /** The CCU call limiter of one integration, created on first use. */
115592
+ function ccuCallLimiter(integrationId) {
115593
+ const existing = limiters.get(integrationId);
115594
+ if (existing !== void 0) return existing;
115595
+ const limiter = new HmCcuCallLimiter();
115596
+ limiters.set(integrationId, limiter);
115597
+ return limiter;
115598
+ }
115599
+ /** Dispose and forget one integration's limiter (its session was removed). */
115600
+ function disposeCcuCallLimiter(integrationId) {
115601
+ limiters.get(integrationId)?.dispose();
115602
+ limiters.delete(integrationId);
115603
+ }
115604
+ /** Dispose every limiter. Called when the facade registry shuts down. */
115605
+ function clearCcuCallLimiters() {
115606
+ for (const limiter of limiters.values()) limiter.dispose();
115607
+ limiters.clear();
115608
+ }
114459
115609
  //#endregion
114460
115610
  //#region src/ccu/ccu-button-events.ts
114461
115611
  /** The channels this key actuates: links where it is the SENDER. */
@@ -114493,9 +115643,11 @@ function deviceAddressOf$2(channelAddress) {
114493
115643
  */
114494
115644
  async function programChannelsOf(deps, integrationId, facade, device, deviceId) {
114495
115645
  try {
114496
- const program = await facade.getKeyEventProgram(keyEventProgramName(device));
115646
+ const name = keyEventProgramName(device);
115647
+ const program = await ccuCallLimiter(integrationId).run(() => facade.getKeyEventProgram(name));
114497
115648
  return new Set(program?.channelAddresses ?? []);
114498
115649
  } catch (err) {
115650
+ if (isCcuCallDisposed(err)) throw sessionStopped(deps, integrationId, device.address, deviceId);
114499
115651
  deps.logger.warn("Homematic key event program could not be read", {
114500
115652
  ...deviceId !== void 0 ? { tags: { deviceId } } : {},
114501
115653
  meta: {
@@ -114507,14 +115659,14 @@ async function programChannelsOf(deps, integrationId, facade, device, deviceId)
114507
115659
  return null;
114508
115660
  }
114509
115661
  }
114510
- async function keyChannelRow(deps, integrationId, facade, names, channel, programChannels) {
115662
+ async function keyChannelRow(deps, integrationId, facade, names, channel, deviceId, programChannels) {
114511
115663
  const row = {
114512
115664
  address: channel.address,
114513
115665
  index: channelIndexFromAddress(channel.address) ?? String(channel.index),
114514
115666
  name: hmName(channel.name)
114515
115667
  };
114516
115668
  try {
114517
- const state = await facade.getChannelLinkState(channel.address);
115669
+ const state = await ccuCallLimiter(integrationId).run(() => facade.getChannelLinkState(channel.address));
114518
115670
  if (programChannels === null) return {
114519
115671
  ...row,
114520
115672
  central: "unknown",
@@ -114527,11 +115679,15 @@ async function keyChannelRow(deps, integrationId, facade, names, channel, progra
114527
115679
  links: directLinksOfKey(channel.address, state.links, names)
114528
115680
  };
114529
115681
  } catch (err) {
114530
- deps.logger.warn("Homematic key channel link state could not be read", { meta: {
114531
- integrationId,
114532
- address: channel.address,
114533
- error: errorText(err)
114534
- } });
115682
+ if (isCcuCallDisposed(err)) throw sessionStopped(deps, integrationId, channel.address, deviceId);
115683
+ deps.logger.warn("Homematic key channel link state could not be read", {
115684
+ ...deviceId !== void 0 ? { tags: { deviceId } } : {},
115685
+ meta: {
115686
+ integrationId,
115687
+ address: channel.address,
115688
+ error: errorText(err)
115689
+ }
115690
+ });
114535
115691
  return {
114536
115692
  ...row,
114537
115693
  central: "unknown",
@@ -114539,6 +115695,20 @@ async function keyChannelRow(deps, integrationId, facade, names, channel, progra
114539
115695
  };
114540
115696
  }
114541
115697
  }
115698
+ /**
115699
+ * A dropped call is not a read failure: the session stopped under the request,
115700
+ * so the request fails as a whole instead of showing the keys as `unknown`.
115701
+ */
115702
+ function sessionStopped(deps, integrationId, address, deviceId) {
115703
+ deps.logger.debug("Homematic session stopped during a CCU page read", {
115704
+ ...deviceId !== void 0 ? { tags: { deviceId } } : {},
115705
+ meta: {
115706
+ integrationId,
115707
+ address
115708
+ }
115709
+ });
115710
+ return /* @__PURE__ */ new Error("Homematic session stopped before the CCU answered");
115711
+ }
114542
115712
  /** Key-channel central-link rows for adopted devices. */
114543
115713
  async function keyChannelsForDevice(deps, integrationId, device, adopted) {
114544
115714
  if (!adopted.has(device.address)) return [];
@@ -114547,8 +115717,9 @@ async function keyChannelsForDevice(deps, integrationId, device, adopted) {
114547
115717
  const facade = deps.facade(integrationId);
114548
115718
  if (facade === null) return [];
114549
115719
  const names = channelNameLookup(facade.devices());
114550
- const programChannels = isHmipDevice(device) ? await programChannelsOf(deps, integrationId, facade, device, (await deps.adoptedAddresses(integrationId)).get(device.address)) : void 0;
114551
- return Promise.all(keys.map((channel) => keyChannelRow(deps, integrationId, facade, names, channel, programChannels)));
115720
+ const deviceId = adopted.get(device.address);
115721
+ const programChannels = isHmipDevice(device) ? await programChannelsOf(deps, integrationId, facade, device, deviceId) : void 0;
115722
+ return Promise.all(keys.map((channel) => keyChannelRow(deps, integrationId, facade, names, channel, deviceId, programChannels)));
114552
115723
  }
114553
115724
  function withKeyChannels(row, keyChannels) {
114554
115725
  return {
@@ -141091,17 +142262,35 @@ function clearStoredKeyLinkStates() {
141091
142262
  * Read each key channel's central link from the CCU and publish that list.
141092
142263
  * `null` when the device has no key channel — the previous snapshot stays,
141093
142264
  * because an empty channel list is not evidence the buttons are gone.
141094
- * A failed read is published as `central: null` and `failed: true`.
142265
+ * A failed read is published as `central: null` and `failed: true`. A read
142266
+ * dropped because the session stopped is not a failure: nothing is published
142267
+ * and the result is `null`.
142268
+ *
142269
+ * Every CCU read goes through the integration's call limiter: a reconnect makes
142270
+ * every device call this at once, and a booting CCU must not see that burst.
141095
142271
  */
141096
142272
  async function publishKeyLinkStates(integrationId, read) {
141097
142273
  const keys = hmKeyChannels(read.device);
141098
142274
  if (keys.length === 0) return null;
141099
142275
  const names = channelNameLookup(read.facade.devices());
141100
- const coverage = await keyEventCoverage(read);
142276
+ try {
142277
+ return await readAndPublish(integrationId, read, keys, names);
142278
+ } catch (err) {
142279
+ if (!isCcuCallDisposed(err)) throw err;
142280
+ read.logger.debug("Homematic session stopped during the key link refresh, nothing published", {
142281
+ tags: { deviceId: read.deviceId },
142282
+ meta: { address: read.deviceAddress }
142283
+ });
142284
+ return null;
142285
+ }
142286
+ }
142287
+ async function readAndPublish(integrationId, read, keys, names) {
142288
+ const limiter = ccuCallLimiter(integrationId);
142289
+ const coverage = await keyEventCoverage(read, (name) => limiter.run(() => read.facade.getKeyEventProgram(name)));
141101
142290
  const states = [];
141102
142291
  let failed = false;
141103
142292
  for (const channel of keys) {
141104
- const one = await readKey(read, names, channel, coverage.get(channel.address) ?? null);
142293
+ const one = await readKey(read, names, channel, coverage.get(channel.address) ?? null, (address) => limiter.run(() => read.facade.getChannelLinkState(address)));
141105
142294
  if (one.failed) failed = true;
141106
142295
  states.push(one.state);
141107
142296
  }
@@ -141109,14 +142298,15 @@ async function publishKeyLinkStates(integrationId, read) {
141109
142298
  return { failed };
141110
142299
  }
141111
142300
  /** Channel address → program name, for keys the device's key-event program covers. */
141112
- async function keyEventCoverage(read) {
142301
+ async function keyEventCoverage(read, getKeyEventProgram) {
141113
142302
  if (!isHmipDevice(read.device)) return /* @__PURE__ */ new Map();
141114
142303
  const name = keyEventProgramName(read.device);
141115
142304
  try {
141116
- const program = await read.facade.getKeyEventProgram(name);
142305
+ const program = await getKeyEventProgram(name);
141117
142306
  if (program === null) return /* @__PURE__ */ new Map();
141118
142307
  return new Map(program.channelAddresses.map((address) => [address, name]));
141119
142308
  } catch (err) {
142309
+ if (isCcuCallDisposed(err)) throw err;
141120
142310
  read.logger.warn("Homematic key event program could not be read", {
141121
142311
  tags: { deviceId: read.deviceId },
141122
142312
  meta: {
@@ -141127,7 +142317,7 @@ async function keyEventCoverage(read) {
141127
142317
  return /* @__PURE__ */ new Map();
141128
142318
  }
141129
142319
  }
141130
- async function readKey(read, names, channel, programName) {
142320
+ async function readKey(read, names, channel, programName, getChannelLinkState) {
141131
142321
  const base = {
141132
142322
  address: channel.address,
141133
142323
  name: hmName(channel.name),
@@ -141135,7 +142325,7 @@ async function readKey(read, names, channel, programName) {
141135
142325
  programName
141136
142326
  };
141137
142327
  try {
141138
- const state = await read.facade.getChannelLinkState(channel.address);
142328
+ const state = await getChannelLinkState(channel.address);
141139
142329
  return {
141140
142330
  failed: false,
141141
142331
  state: {
@@ -141145,6 +142335,7 @@ async function readKey(read, names, channel, programName) {
141145
142335
  }
141146
142336
  };
141147
142337
  } catch (err) {
142338
+ if (isCcuCallDisposed(err)) throw err;
141148
142339
  read.logger.warn("Homematic key channel link state could not be read", {
141149
142340
  tags: { deviceId: read.deviceId },
141150
142341
  meta: {
@@ -141231,6 +142422,7 @@ var HmFacadeResolver = class {
141231
142422
  }
141232
142423
  /** Remove everything (called on full shutdown). */
141233
142424
  clear() {
142425
+ clearCcuCallLimiters();
141234
142426
  this.#facades.clear();
141235
142427
  this.#sessions.clear();
141236
142428
  this.#snapshotSubs.clear();
@@ -144812,8 +146004,9 @@ function isConnectionArg(arg) {
144812
146004
  //#region src/homematic-client-registry.ts
144813
146005
  /**
144814
146006
  * Delays (ms) between background retries after a failed `facade.start()` (e.g.
144815
- * CCU `ECONNREFUSED`). Six attempts ~ 2+5+10+20+30+60 s. Exported for specs
144816
- * that drive the schedule with fake timers.
146007
+ * CCU `ECONNREFUSED`): 2+5+10+20+30 s, then every 60 s for as long as the
146008
+ * integration exists. A CCU can take minutes to boot, and the integration must
146009
+ * come back on its own. Exported for specs that drive the schedule with fake timers.
144817
146010
  */
144818
146011
  var START_RETRY_DELAYS_MS = [
144819
146012
  2e3,
@@ -144823,6 +146016,8 @@ var START_RETRY_DELAYS_MS = [
144823
146016
  3e4,
144824
146017
  6e4
144825
146018
  ];
146019
+ /** The retry delay used if {@link START_RETRY_DELAYS_MS} were ever emptied. */
146020
+ var FALLBACK_RETRY_DELAY_MS = 6e4;
144826
146021
  /**
144827
146022
  * One live CCU session per enabled integration, each backed by an
144828
146023
  * {@link HmIntegrationManager}. The integration id IS the key: the connection
@@ -144830,8 +146025,9 @@ var START_RETRY_DELAYS_MS = [
144830
146025
  * its products) resolves its session through {@link homematicFacades}.
144831
146026
  *
144832
146027
  * `upsert` never throws: a CCU that is down at boot or on a settings change is
144833
- * retried on {@link START_RETRY_DELAYS_MS}, and the integration reconcile
144834
- * (which runs on every integration lifecycle event) retries it again.
146028
+ * retried on {@link START_RETRY_DELAYS_MS} until it answers or the integration
146029
+ * is removed, and the integration reconcile (which runs on every integration
146030
+ * lifecycle event) retries it too.
144835
146031
  */
144836
146032
  var HmClientRegistry = class {
144837
146033
  #logger;
@@ -144931,6 +146127,7 @@ var HmClientRegistry = class {
144931
146127
  if (entry === void 0) return;
144932
146128
  this.#entries.delete(integrationId);
144933
146129
  this.#facades.delete(integrationId);
146130
+ disposeCcuCallLimiter(integrationId);
144934
146131
  homematicFacades.set(integrationId, null);
144935
146132
  homematicFacades.setSession(integrationId, null);
144936
146133
  if (entry.manager !== null) try {
@@ -145012,6 +146209,10 @@ var HmClientRegistry = class {
145012
146209
  await this.#abandon(integrationId, manager);
145013
146210
  throw err;
145014
146211
  }
146212
+ if (this.#entries.get(integrationId)?.manager !== manager) {
146213
+ await this.#stopOrphan(integrationId, manager);
146214
+ return;
146215
+ }
145015
146216
  this.#clearRetry(integrationId);
145016
146217
  this.#logger.info("HmClientRegistry: session started", {
145017
146218
  tags: { integrationId },
@@ -145038,6 +146239,17 @@ var HmClientRegistry = class {
145038
146239
  }
145039
146240
  homematicFacades.emitSnapshot(integrationId);
145040
146241
  }
146242
+ async #stopOrphan(integrationId, manager) {
146243
+ this.#logger.info("HmClientRegistry: session started after its integration was removed, stopping it", { tags: { integrationId } });
146244
+ try {
146245
+ await manager.stop();
146246
+ } catch (err) {
146247
+ this.#logger.debug("HmClientRegistry: orphan stop failed", {
146248
+ tags: { integrationId },
146249
+ meta: { error: errMsg(err) }
146250
+ });
146251
+ }
146252
+ }
145041
146253
  #clearRetry(integrationId) {
145042
146254
  const pending = this.#retryTimers.get(integrationId);
145043
146255
  if (pending !== void 0) {
@@ -145046,20 +146258,13 @@ var HmClientRegistry = class {
145046
146258
  }
145047
146259
  }
145048
146260
  /**
145049
- * Schedule attempt `attemptIndex` of {@link START_RETRY_DELAYS_MS}. Stops
145050
- * quietly when the registry is shutting down; warns once when the schedule is
145051
- * exhausted (the next integration reconcile still retries).
146261
+ * Schedule attempt `attemptIndex`: the delay of {@link START_RETRY_DELAYS_MS}
146262
+ * at that index, the last delay past its end. Never gives up on its own; stops
146263
+ * quietly when the registry is shutting down or the integration was removed.
145052
146264
  */
145053
146265
  #scheduleRetry(integrationId, attemptIndex) {
145054
- if (this.#shuttingDown) return;
145055
- const delay = START_RETRY_DELAYS_MS[attemptIndex];
145056
- if (delay === void 0) {
145057
- this.#logger.warn("HmClientRegistry: start retries exhausted", {
145058
- tags: { integrationId },
145059
- meta: { attempts: START_RETRY_DELAYS_MS.length }
145060
- });
145061
- return;
145062
- }
146266
+ if (this.#shuttingDown || !this.#entries.has(integrationId)) return;
146267
+ const delay = START_RETRY_DELAYS_MS[Math.min(attemptIndex, START_RETRY_DELAYS_MS.length - 1)] ?? FALLBACK_RETRY_DELAY_MS;
145063
146268
  this.#clearRetry(integrationId);
145064
146269
  const timer = setTimeout(() => {
145065
146270
  this.#retryTimers.delete(integrationId);