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