@camstack/server 1.2.876 → 1.2.878
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.
- package/CHANGELOG.md +12 -0
- package/dist/api/trpc/generated-cap-mounts.js +2 -1
- package/dist/api/trpc/generated-cap-routers.js +308 -256
- package/package.json +10 -9
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/system/dist/builtins/alerts/alerts.addon.js +1 -1
- package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/system/dist/builtins/autotrack/index.js +1 -1
- package/system/dist/builtins/autotrack/index.mjs +1 -1
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
- package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
- package/system/dist/builtins/calendars/calendars.addon.js +1 -1
- package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
- package/system/dist/builtins/camera-grid/index.js +1 -1
- package/system/dist/builtins/camera-grid/index.mjs +1 -1
- package/system/dist/builtins/composer/composer.addon.js +4 -4
- package/system/dist/builtins/composer/composer.addon.mjs +4 -4
- package/system/dist/builtins/console-logging/index.js +1 -1
- package/system/dist/builtins/console-logging/index.mjs +1 -1
- package/system/dist/builtins/core-blocks/actions-store.d.ts +2 -0
- package/system/dist/builtins/core-blocks/core-block-store.d.ts +6 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +3 -0
- package/system/dist/builtins/core-blocks/core-blocks.addon.js +410 -9
- package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +410 -9
- package/system/dist/builtins/core-blocks/record-kinds.d.ts +11 -1
- package/system/dist/builtins/core-blocks/scheduler/scheduler-store.d.ts +6 -0
- package/system/dist/builtins/core-blocks/tags-service.d.ts +50 -0
- package/system/dist/builtins/core-blocks/tags-wiring.d.ts +16 -0
- package/system/dist/builtins/device-history/device-history.addon.js +2 -2
- package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
- package/system/dist/builtins/device-manager/device-manager.addon.js +59 -5
- package/system/dist/builtins/device-manager/device-manager.addon.mjs +59 -5
- package/system/dist/builtins/device-manager/device-meta-actions.d.ts +6 -0
- package/system/dist/builtins/device-manager/device-meta-types.d.ts +2 -0
- package/system/dist/builtins/device-manager/device-row-store.d.ts +1 -0
- package/system/dist/builtins/device-manager/device-template/template-grammar.d.ts +15 -1
- package/system/dist/builtins/device-manager/device-template/template-protocol.d.ts +8 -0
- package/system/dist/builtins/hub-forwarder/index.js +1 -1
- package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/system/dist/builtins/keychain/index.js +4 -4
- package/system/dist/builtins/keychain/index.mjs +4 -4
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
- package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
- package/system/dist/builtins/local-network/local-network.addon.js +3 -3
- package/system/dist/builtins/local-network/local-network.addon.mjs +3 -3
- package/system/dist/builtins/loki-logging/index.js +1 -1
- package/system/dist/builtins/loki-logging/index.mjs +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/system/dist/builtins/platform-probe/index.js +1 -1
- package/system/dist/builtins/platform-probe/index.mjs +1 -1
- package/system/dist/builtins/record-entries/index.js +1 -1
- package/system/dist/builtins/record-entries/index.mjs +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/snapshot/index.js +1 -1
- package/system/dist/builtins/snapshot/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/index.js +1 -1
- package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
- package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/system/dist/builtins/system-config/system-config.addon.js +3 -3
- package/system/dist/builtins/system-config/system-config.addon.mjs +3 -3
- package/system/dist/builtins/winston-logging/index.js +1 -1
- package/system/dist/builtins/winston-logging/index.mjs +1 -1
- package/system/dist/{capture-engine-DtuMWHR3.js → capture-engine-DAGmlBmJ.js} +1 -1
- package/system/dist/{capture-engine-Bao8AioF.mjs → capture-engine-vlouhBCY.mjs} +1 -1
- package/system/dist/{composition-sources-DPSSQaGb.js → composition-sources-Rm8xDXjA.js} +1 -1
- package/system/dist/{composition-sources-CCoQYZna.mjs → composition-sources-TeHa4THk.mjs} +1 -1
- package/system/dist/{constants-BQNuuICz.mjs → constants-Bq1Xl_Ku.mjs} +1 -1
- package/system/dist/{constants-wcqPhWGp.js → constants-DnUpXvIY.js} +1 -1
- package/system/dist/{device-ca-CDsYbRF8.js → device-ca-DMudhY-2.js} +1 -1
- package/system/dist/{device-ca-DvK5zoNx.mjs → device-ca-yHLgyutP.mjs} +1 -1
- package/system/dist/device-template-worker.js +26 -3
- package/system/dist/device-template-worker.mjs +26 -3
- package/system/dist/{dist-CdW0TjIj.js → dist-Bh5JIimH.js} +1704 -1178
- package/system/dist/{dist-DcH8pKL-.mjs → dist-DemZNuSJ.mjs} +1651 -1179
- package/system/dist/file-host-worker.js +1 -1
- package/system/dist/file-host-worker.mjs +1 -1
- package/system/dist/{hub-identity-DOyLUW_7.mjs → hub-identity-BxaJKDQk.mjs} +1 -1
- package/system/dist/{hub-identity-BRxxw7hh.js → hub-identity-YfGdAaBm.js} +1 -1
- package/system/dist/{hub-mdns-ciao-lO2BAONK.js → hub-mdns-ciao-BkWOmG6H.js} +2 -2
- package/system/dist/{hub-mdns-ciao-9IzOmoit.mjs → hub-mdns-ciao-aIsTpo0F.mjs} +2 -2
- package/system/dist/index.js +8 -8
- package/system/dist/index.mjs +8 -8
- package/system/dist/{legacy-integration-rows-door-DBL83TzQ.js → legacy-integration-rows-door-C9PZZiKH.js} +1 -1
- package/system/dist/{legacy-integration-rows-door-CTxk0fz7.mjs → legacy-integration-rows-door-DrfZZHWq.mjs} +1 -1
- package/system/dist/{rename-composition-block-DK9CVk1U.mjs → rename-composition-block-C2KFIOMP.mjs} +1 -1
- package/system/dist/{rename-composition-block-CKZqCPQF.js → rename-composition-block-Qp1dW4FP.js} +1 -1
- package/system/dist/{restore-archive-2OReGcRK.js → restore-archive-DGgj7aqA.js} +1 -1
- package/system/dist/{restore-archive-CruwV_-u.mjs → restore-archive-D_K6PqRk.mjs} +1 -1
- package/system/dist/{template-protocol-DRZ4cm95.js → template-protocol-D5ogm1rj.js} +8 -44
- package/system/dist/{template-protocol-D_6uVHKs.mjs → template-protocol-SgPDx3Hw.mjs} +8 -44
- package/system/dist/{wal-maintenance-DgFSFQH0.mjs → wal-maintenance-BuiSFfF2.mjs} +0 -0
- package/system/dist/{wal-maintenance-CN7sdJj-.js → wal-maintenance-DD8mfRDn.js} +0 -0
- package/system/package.json +4 -1
|
@@ -1274,7 +1274,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
1274
1274
|
*/
|
|
1275
1275
|
var COMPOSED_DEVICE_STABLE_ID_PREFIX = "composed-";
|
|
1276
1276
|
//#endregion
|
|
1277
|
-
//#region ../types/dist/sleep-
|
|
1277
|
+
//#region ../types/dist/sleep-C9EWTQr9.mjs
|
|
1278
1278
|
/**
|
|
1279
1279
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
1280
1280
|
* window to float samples (D455).
|
|
@@ -15580,6 +15580,10 @@ var CAP_VOCABULARY_BY_NAME = {
|
|
|
15580
15580
|
scope: "system",
|
|
15581
15581
|
notOperatorFacing: "cluster administration — nodes, server package, metrics"
|
|
15582
15582
|
},
|
|
15583
|
+
"tags": {
|
|
15584
|
+
scope: "system",
|
|
15585
|
+
notOperatorFacing: "tags are managed from the tag picker and the tags manager, not actuated"
|
|
15586
|
+
},
|
|
15583
15587
|
"template": {
|
|
15584
15588
|
scope: "system",
|
|
15585
15589
|
notOperatorFacing: "operator-authored templates — edited in their own editor, never actuated"
|
|
@@ -16323,6 +16327,7 @@ var CAP_NAMES = Object.freeze([
|
|
|
16323
16327
|
"stream-signals",
|
|
16324
16328
|
"switch",
|
|
16325
16329
|
"system",
|
|
16330
|
+
"tags",
|
|
16326
16331
|
"tamper",
|
|
16327
16332
|
"temperature-sensor",
|
|
16328
16333
|
"template",
|
|
@@ -21879,6 +21884,293 @@ function unitsForDimension(dimension) {
|
|
|
21879
21884
|
return out;
|
|
21880
21885
|
}
|
|
21881
21886
|
//#endregion
|
|
21887
|
+
//#region ../types/dist/device-template-catalogue.mjs
|
|
21888
|
+
/**
|
|
21889
|
+
* The one catalogue of what a device template may name (D1021, D1029).
|
|
21890
|
+
*
|
|
21891
|
+
* Filters, the `range` global and the reserved names (`now`, `camera`, the
|
|
21892
|
+
* caller's recognition values) are listed here. The grammar's allow-list and
|
|
21893
|
+
* argument caps are derived from this module; nothing else keeps a second list.
|
|
21894
|
+
* The renderer imports this module through the
|
|
21895
|
+
* `@camstack/types/device-template-catalogue` subpath, never the types barrel
|
|
21896
|
+
* (D453), and sends the derived caps to the worker. The worker does not import it.
|
|
21897
|
+
*/
|
|
21898
|
+
var DEVICE_TEMPLATE_CATALOGUE_KINDS = [
|
|
21899
|
+
"filter",
|
|
21900
|
+
"global",
|
|
21901
|
+
"variable"
|
|
21902
|
+
];
|
|
21903
|
+
var DEVICE_TEMPLATE_CATALOGUE_CATEGORIES = [
|
|
21904
|
+
"number",
|
|
21905
|
+
"unit",
|
|
21906
|
+
"text",
|
|
21907
|
+
"state",
|
|
21908
|
+
"time",
|
|
21909
|
+
"fallback",
|
|
21910
|
+
"loop",
|
|
21911
|
+
"variable"
|
|
21912
|
+
];
|
|
21913
|
+
var deviceTemplateParamSchema = zod.z.object({
|
|
21914
|
+
name: zod.z.string().min(1),
|
|
21915
|
+
type: zod.z.enum([
|
|
21916
|
+
"string",
|
|
21917
|
+
"number",
|
|
21918
|
+
"boolean"
|
|
21919
|
+
]),
|
|
21920
|
+
optional: zod.z.boolean(),
|
|
21921
|
+
default: zod.z.union([
|
|
21922
|
+
zod.z.string(),
|
|
21923
|
+
zod.z.number(),
|
|
21924
|
+
zod.z.boolean()
|
|
21925
|
+
]).optional()
|
|
21926
|
+
});
|
|
21927
|
+
zod.z.object({
|
|
21928
|
+
name: zod.z.string().min(1),
|
|
21929
|
+
kind: zod.z.enum(DEVICE_TEMPLATE_CATALOGUE_KINDS),
|
|
21930
|
+
category: zod.z.enum(DEVICE_TEMPLATE_CATALOGUE_CATEGORIES),
|
|
21931
|
+
params: zod.z.array(deviceTemplateParamSchema),
|
|
21932
|
+
descriptionKey: zod.z.string().min(1),
|
|
21933
|
+
exampleKey: zod.z.string().min(1)
|
|
21934
|
+
});
|
|
21935
|
+
function param(name, type, optional, fallback) {
|
|
21936
|
+
return fallback === void 0 ? {
|
|
21937
|
+
name,
|
|
21938
|
+
type,
|
|
21939
|
+
optional
|
|
21940
|
+
} : {
|
|
21941
|
+
name,
|
|
21942
|
+
type,
|
|
21943
|
+
optional,
|
|
21944
|
+
default: fallback
|
|
21945
|
+
};
|
|
21946
|
+
}
|
|
21947
|
+
function entry(name, kind, category, params) {
|
|
21948
|
+
return {
|
|
21949
|
+
name,
|
|
21950
|
+
kind,
|
|
21951
|
+
category,
|
|
21952
|
+
params: [...params],
|
|
21953
|
+
descriptionKey: `uiLibrary.deviceTemplateCatalogue.${name}.description`,
|
|
21954
|
+
exampleKey: `uiLibrary.deviceTemplateCatalogue.${name}.example`
|
|
21955
|
+
};
|
|
21956
|
+
}
|
|
21957
|
+
var DIGITS = param("digits", "number", true, 0);
|
|
21958
|
+
var FALLBACK_TEXT = param("fallback", "string", false);
|
|
21959
|
+
var FALSY = param("falsy", "boolean", true, false);
|
|
21960
|
+
/** Every name the engine allows, in the order operators meet them. */
|
|
21961
|
+
var DEVICE_TEMPLATE_CATALOGUE = [
|
|
21962
|
+
entry("unit", "filter", "unit", [param("symbol", "string", false), param("from", "string", true)]),
|
|
21963
|
+
entry("round", "filter", "number", [DIGITS]),
|
|
21964
|
+
entry("trunc", "filter", "number", [DIGITS]),
|
|
21965
|
+
entry("onoff", "filter", "state", []),
|
|
21966
|
+
entry("default", "filter", "fallback", [FALLBACK_TEXT, FALSY]),
|
|
21967
|
+
entry("since", "filter", "time", []),
|
|
21968
|
+
entry("ago", "filter", "time", []),
|
|
21969
|
+
entry("format", "filter", "text", [param("pattern", "string", false)]),
|
|
21970
|
+
entry("upper", "filter", "text", []),
|
|
21971
|
+
entry("lower", "filter", "text", []),
|
|
21972
|
+
entry("title", "filter", "text", []),
|
|
21973
|
+
entry("capitalize", "filter", "text", []),
|
|
21974
|
+
entry("trim", "filter", "text", []),
|
|
21975
|
+
entry("abs", "filter", "number", []),
|
|
21976
|
+
entry("int", "filter", "number", [param("fallback", "number", true, 0)]),
|
|
21977
|
+
entry("float", "filter", "number", [param("fallback", "number", true, 0)]),
|
|
21978
|
+
entry("length", "filter", "text", []),
|
|
21979
|
+
entry("d", "filter", "fallback", [FALLBACK_TEXT, FALSY]),
|
|
21980
|
+
entry("join", "filter", "text", [param("separator", "string", true, "")]),
|
|
21981
|
+
entry("replace", "filter", "text", [
|
|
21982
|
+
param("old", "string", false),
|
|
21983
|
+
param("new", "string", false),
|
|
21984
|
+
param("count", "number", true)
|
|
21985
|
+
]),
|
|
21986
|
+
entry("first", "filter", "loop", []),
|
|
21987
|
+
entry("last", "filter", "loop", []),
|
|
21988
|
+
entry("sort", "filter", "loop", [param("reverse", "boolean", true, false), param("caseSensitive", "boolean", true, false)]),
|
|
21989
|
+
entry("reverse", "filter", "loop", []),
|
|
21990
|
+
entry("sum", "filter", "number", []),
|
|
21991
|
+
entry("string", "filter", "text", []),
|
|
21992
|
+
entry("list", "filter", "loop", []),
|
|
21993
|
+
entry("truncate", "filter", "text", [
|
|
21994
|
+
param("length", "number", false),
|
|
21995
|
+
param("killwords", "boolean", true, false),
|
|
21996
|
+
param("end", "string", true, "…")
|
|
21997
|
+
]),
|
|
21998
|
+
entry("time", "filter", "time", [param("pattern", "string", false)]),
|
|
21999
|
+
entry("range", "global", "loop", [
|
|
22000
|
+
param("stop", "number", false),
|
|
22001
|
+
param("start", "number", true, 0),
|
|
22002
|
+
param("step", "number", true, 1)
|
|
22003
|
+
]),
|
|
22004
|
+
entry("now", "variable", "time", []),
|
|
22005
|
+
entry("camera", "variable", "variable", []),
|
|
22006
|
+
entry("loop", "variable", "loop", []),
|
|
22007
|
+
entry("lastPerson", "variable", "variable", []),
|
|
22008
|
+
entry("lastPlate", "variable", "variable", [])
|
|
22009
|
+
];
|
|
22010
|
+
var COPY = {
|
|
22011
|
+
unit: {
|
|
22012
|
+
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."],
|
|
22013
|
+
example: ["{{ garage.temperature | unit('°C') }}", "{{ garage.temperature | unit('°C') }}"]
|
|
22014
|
+
},
|
|
22015
|
+
round: {
|
|
22016
|
+
description: ["Rounds a number to the given decimals.", "Arrotonda un numero ai decimali indicati."],
|
|
22017
|
+
example: ["{{ garage.temperature | round(1) }}", "{{ garage.temperature | round(1) }}"]
|
|
22018
|
+
},
|
|
22019
|
+
trunc: {
|
|
22020
|
+
description: ["Cuts decimals toward zero, without rounding.", "Taglia i decimali verso zero, senza arrotondare."],
|
|
22021
|
+
example: ["{{ garage.temperature | trunc(1) }}", "{{ garage.temperature | trunc(1) }}"]
|
|
22022
|
+
},
|
|
22023
|
+
onoff: {
|
|
22024
|
+
description: ["Prints a boolean as ON or OFF.", "Stampa un sì/no come ON oppure OFF."],
|
|
22025
|
+
example: ["{{ garage.switch | onoff }}", "{{ garage.switch | onoff }}"]
|
|
22026
|
+
},
|
|
22027
|
+
default: {
|
|
22028
|
+
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."],
|
|
22029
|
+
example: ["{{ camera.lastPerson | default('') }}", "{{ camera.lastPerson | default('') }}"]
|
|
22030
|
+
},
|
|
22031
|
+
since: {
|
|
22032
|
+
description: ["How long ago a timestamp was, as “5 min”.", "Quanto tempo fa era un istante, come «5 min»."],
|
|
22033
|
+
example: ["{{ garage.updated | since }}", "{{ garage.updated | since }}"]
|
|
22034
|
+
},
|
|
22035
|
+
ago: {
|
|
22036
|
+
description: ["The same duration as since, followed by “ago”.", "La stessa durata di since, seguita da «ago»."],
|
|
22037
|
+
example: ["{{ garage.updated | ago }}", "{{ garage.updated | ago }}"]
|
|
22038
|
+
},
|
|
22039
|
+
format: {
|
|
22040
|
+
description: ["Prints one value with a single %s, %d or %.Nf placeholder.", "Stampa un valore con un solo segnaposto %s, %d o %.Nf."],
|
|
22041
|
+
example: ["{{ garage.temperature | format('%.1f') }}", "{{ garage.temperature | format('%.1f') }}"]
|
|
22042
|
+
},
|
|
22043
|
+
upper: {
|
|
22044
|
+
description: ["Uppercase text.", "Testo in maiuscolo."],
|
|
22045
|
+
example: ["{{ camera.lastPerson | upper }}", "{{ camera.lastPerson | upper }}"]
|
|
22046
|
+
},
|
|
22047
|
+
lower: {
|
|
22048
|
+
description: ["Lowercase text.", "Testo in minuscolo."],
|
|
22049
|
+
example: ["{{ camera.lastPlate | lower }}", "{{ camera.lastPlate | lower }}"]
|
|
22050
|
+
},
|
|
22051
|
+
title: {
|
|
22052
|
+
description: ["Capitalises each word.", "Mette la maiuscola a ogni parola."],
|
|
22053
|
+
example: ["{{ camera.lastPerson | title }}", "{{ camera.lastPerson | title }}"]
|
|
22054
|
+
},
|
|
22055
|
+
capitalize: {
|
|
22056
|
+
description: ["Capitalises the first letter.", "Mette la maiuscola alla prima lettera."],
|
|
22057
|
+
example: ["{{ camera.lastPerson | capitalize }}", "{{ camera.lastPerson | capitalize }}"]
|
|
22058
|
+
},
|
|
22059
|
+
trim: {
|
|
22060
|
+
description: ["Removes spaces at both ends.", "Toglie gli spazi alle estremità."],
|
|
22061
|
+
example: ["{{ camera.lastPerson | trim }}", "{{ camera.lastPerson | trim }}"]
|
|
22062
|
+
},
|
|
22063
|
+
abs: {
|
|
22064
|
+
description: ["The absolute value of a number.", "Il valore assoluto di un numero."],
|
|
22065
|
+
example: ["{{ garage.power | abs }}", "{{ garage.power | abs }}"]
|
|
22066
|
+
},
|
|
22067
|
+
int: {
|
|
22068
|
+
description: ["The whole part of a number.", "La parte intera di un numero."],
|
|
22069
|
+
example: ["{{ garage.temperature | int }}", "{{ garage.temperature | int }}"]
|
|
22070
|
+
},
|
|
22071
|
+
float: {
|
|
22072
|
+
description: ["Reads the value as a decimal number.", "Legge il valore come numero decimale."],
|
|
22073
|
+
example: ["{{ garage.temperature | float }}", "{{ garage.temperature | float }}"]
|
|
22074
|
+
},
|
|
22075
|
+
length: {
|
|
22076
|
+
description: ["How many characters or items.", "Quanti caratteri o elementi."],
|
|
22077
|
+
example: ["{{ camera.lastPerson | length }}", "{{ camera.lastPerson | length }}"]
|
|
22078
|
+
},
|
|
22079
|
+
d: {
|
|
22080
|
+
description: ["The short name of default.", "Il nome breve di default."],
|
|
22081
|
+
example: ["{{ camera.lastPerson | d('') }}", "{{ camera.lastPerson | d('') }}"]
|
|
22082
|
+
},
|
|
22083
|
+
join: {
|
|
22084
|
+
description: ["Joins a list with a separator.", "Unisce un elenco con un separatore."],
|
|
22085
|
+
example: ["{{ range(3) | join(', ') }}", "{{ range(3) | join(', ') }}"]
|
|
22086
|
+
},
|
|
22087
|
+
replace: {
|
|
22088
|
+
description: ["Replaces text, optionally only the first few times.", "Sostituisce del testo, volendo solo le prime volte."],
|
|
22089
|
+
example: ["{{ camera.lastPlate | replace(' ', '') }}", "{{ camera.lastPlate | replace(' ', '') }}"]
|
|
22090
|
+
},
|
|
22091
|
+
first: {
|
|
22092
|
+
description: ["The first item of a list.", "Il primo elemento di un elenco."],
|
|
22093
|
+
example: ["{{ range(3) | first }}", "{{ range(3) | first }}"]
|
|
22094
|
+
},
|
|
22095
|
+
last: {
|
|
22096
|
+
description: ["The last item of a list.", "L’ultimo elemento di un elenco."],
|
|
22097
|
+
example: ["{{ range(3) | last }}", "{{ range(3) | last }}"]
|
|
22098
|
+
},
|
|
22099
|
+
sort: {
|
|
22100
|
+
description: ["Sorts a list. The arguments reverse it or keep case.", "Ordina un elenco. Gli argomenti lo invertono o rispettano le maiuscole."],
|
|
22101
|
+
example: ["{{ range(3) | reverse | sort }}", "{{ range(3) | reverse | sort }}"]
|
|
22102
|
+
},
|
|
22103
|
+
reverse: {
|
|
22104
|
+
description: ["Reverses a list.", "Inverte un elenco."],
|
|
22105
|
+
example: ["{{ range(3) | reverse }}", "{{ range(3) | reverse }}"]
|
|
22106
|
+
},
|
|
22107
|
+
sum: {
|
|
22108
|
+
description: ["Adds the numbers in a list.", "Somma i numeri di un elenco."],
|
|
22109
|
+
example: ["{{ range(3) | sum }}", "{{ range(3) | sum }}"]
|
|
22110
|
+
},
|
|
22111
|
+
string: {
|
|
22112
|
+
description: ["Prints the value as text.", "Stampa il valore come testo."],
|
|
22113
|
+
example: ["{{ garage.temperature | string }}", "{{ garage.temperature | string }}"]
|
|
22114
|
+
},
|
|
22115
|
+
list: {
|
|
22116
|
+
description: ["Wraps the value in a list.", "Mette il valore in un elenco."],
|
|
22117
|
+
example: ["{{ garage.temperature | list }}", "{{ garage.temperature | list }}"]
|
|
22118
|
+
},
|
|
22119
|
+
truncate: {
|
|
22120
|
+
description: ["Shortens text to a length, with an ending.", "Accorcia il testo a una lunghezza, con una chiusura."],
|
|
22121
|
+
example: ["{{ camera.lastPerson | truncate(12) }}", "{{ camera.lastPerson | truncate(12) }}"]
|
|
22122
|
+
},
|
|
22123
|
+
time: {
|
|
22124
|
+
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."],
|
|
22125
|
+
example: ["{{ now | time('HH:mm') }}", "{{ now | time('HH:mm') }}"]
|
|
22126
|
+
},
|
|
22127
|
+
range: {
|
|
22128
|
+
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."],
|
|
22129
|
+
example: ["{% for i in range(3) %}{{ i }}{% endfor %}", "{% for i in range(3) %}{{ i }}{% endfor %}"]
|
|
22130
|
+
},
|
|
22131
|
+
now: {
|
|
22132
|
+
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."],
|
|
22133
|
+
example: ["{{ now | time('HH:mm') }}", "{{ now | time('HH:mm') }}"]
|
|
22134
|
+
},
|
|
22135
|
+
camera: {
|
|
22136
|
+
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."],
|
|
22137
|
+
example: ["{{ camera.temperature }}", "{{ camera.temperature }}"]
|
|
22138
|
+
},
|
|
22139
|
+
loop: {
|
|
22140
|
+
description: ["The for-loop counter (index, length) inside {% for %}.", "Il contatore del ciclo (index, length) dentro {% for %}."],
|
|
22141
|
+
example: ["{% for i in range(3) %}{{ loop.index }}{% endfor %}", "{% for i in range(3) %}{{ loop.index }}{% endfor %}"]
|
|
22142
|
+
},
|
|
22143
|
+
lastPerson: {
|
|
22144
|
+
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."],
|
|
22145
|
+
example: ["{{ camera.lastPerson }}", "{{ camera.lastPerson }}"]
|
|
22146
|
+
},
|
|
22147
|
+
lastPlate: {
|
|
22148
|
+
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."],
|
|
22149
|
+
example: ["{{ camera.lastPlate }}", "{{ camera.lastPlate }}"]
|
|
22150
|
+
}
|
|
22151
|
+
};
|
|
22152
|
+
function buildText() {
|
|
22153
|
+
const out = {};
|
|
22154
|
+
for (const item of DEVICE_TEMPLATE_CATALOGUE) {
|
|
22155
|
+
const row = COPY[item.name];
|
|
22156
|
+
if (row === void 0) continue;
|
|
22157
|
+
out[item.descriptionKey] = {
|
|
22158
|
+
en: row.description[0],
|
|
22159
|
+
it: row.description[1]
|
|
22160
|
+
};
|
|
22161
|
+
out[item.exampleKey] = {
|
|
22162
|
+
en: row.example[0],
|
|
22163
|
+
it: row.example[1]
|
|
22164
|
+
};
|
|
22165
|
+
}
|
|
22166
|
+
return out;
|
|
22167
|
+
}
|
|
22168
|
+
buildText();
|
|
22169
|
+
/** Names a template may use after `|`. Order matches the catalogue. */
|
|
22170
|
+
function deviceTemplateFilterNames() {
|
|
22171
|
+
return DEVICE_TEMPLATE_CATALOGUE.filter((item) => item.kind === "filter").map((item) => item.name);
|
|
22172
|
+
}
|
|
22173
|
+
//#endregion
|
|
21882
22174
|
//#region ../types/dist/index.mjs
|
|
21883
22175
|
var SMTP_INBOUND_DEFAULT_PORT = 2525;
|
|
21884
22176
|
var SMTP_INBOUND_DEFAULT_DOMAIN = "camstack.local";
|
|
@@ -26314,1074 +26606,6 @@ function reducePoints(points, bucketMs, origin) {
|
|
|
26314
26606
|
}
|
|
26315
26607
|
return [...buckets.values()].toSorted((a, b) => a.atMs - b.atMs);
|
|
26316
26608
|
}
|
|
26317
|
-
var ClipModelMetaSchema = zod.z.object({
|
|
26318
|
-
/** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
|
|
26319
|
-
textModelId: zod.z.string().min(1),
|
|
26320
|
-
/** Output dimension of BOTH towers. A vector of any other length is refused. */
|
|
26321
|
-
embeddingDim: zod.z.number().int().positive(),
|
|
26322
|
-
/**
|
|
26323
|
-
* The `vector-store` index this model's vectors live in. ONE feature space
|
|
26324
|
-
* per index: two models share an index only when their vectors are ranked
|
|
26325
|
-
* against each other, which for CLIP means never across families. Every
|
|
26326
|
-
* model gets its own.
|
|
26327
|
-
*/
|
|
26328
|
-
vectorIndex: zod.z.string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
|
|
26329
|
-
/**
|
|
26330
|
-
* The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
|
|
26331
|
-
* must be unique per tokenizer: every model's siblings land in ONE flat
|
|
26332
|
-
* models directory, so two different tokenizers under the same name would
|
|
26333
|
-
* silently overwrite each other (whichever model downloaded last wins, and
|
|
26334
|
-
* the other one tokenises with the wrong vocabulary).
|
|
26335
|
-
*/
|
|
26336
|
-
tokenizerFile: zod.z.string().min(1),
|
|
26337
|
-
/** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
|
|
26338
|
-
contextLength: zod.z.number().int().positive(),
|
|
26339
|
-
/** Id the tokenizer pads with. */
|
|
26340
|
-
padId: zod.z.number().int().nonnegative(),
|
|
26341
|
-
/**
|
|
26342
|
-
* The search cosine floor at `strictness: 'loose'` — calibrated per model,
|
|
26343
|
-
* because cosine bands are a property of the model: 0.2 keeps 96% of matched
|
|
26344
|
-
* COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
|
|
26345
|
-
*/
|
|
26346
|
-
searchMinScore: zod.z.number().min(0).max(1)
|
|
26347
|
-
});
|
|
26348
|
-
var ClipSearchStrictnessSchema = zod.z.enum([
|
|
26349
|
-
"loose",
|
|
26350
|
-
"balanced",
|
|
26351
|
-
"strict"
|
|
26352
|
-
]);
|
|
26353
|
-
/** Steps whose effect a root label can BE. */
|
|
26354
|
-
var LABEL_SUPPLY_STEP_IDS = [
|
|
26355
|
-
"animal-classifier",
|
|
26356
|
-
"vehicle-classifier",
|
|
26357
|
-
"package-detection"
|
|
26358
|
-
];
|
|
26359
|
-
/** Steps whose box a root detection can BE. */
|
|
26360
|
-
var CROP_SUPPLY_STEP_IDS = ["plate-detection", "face-detection"];
|
|
26361
|
-
/**
|
|
26362
|
-
* Steps whose per-detection MASK a root detection can carry (D737). The live
|
|
26363
|
-
* mask step is `segmentation` — a frame-plane refiner that runs its own model
|
|
26364
|
-
* once per detection crop. (`instance-segmentation` is a dormant step id that
|
|
26365
|
-
* no camera tree carries.)
|
|
26366
|
-
*/
|
|
26367
|
-
var MASK_SUPPLY_STEP_IDS = ["segmentation"];
|
|
26368
|
-
[
|
|
26369
|
-
...LABEL_SUPPLY_STEP_IDS,
|
|
26370
|
-
...CROP_SUPPLY_STEP_IDS,
|
|
26371
|
-
...MASK_SUPPLY_STEP_IDS
|
|
26372
|
-
];
|
|
26373
|
-
/**
|
|
26374
|
-
* Multi-file format payload.
|
|
26375
|
-
*
|
|
26376
|
-
* - Directory formats (`isDirectory: true`, e.g. `.mlpackage`): files
|
|
26377
|
-
* relative to the directory root — the downloader fetches each from
|
|
26378
|
-
* `{url}/{file}` into `{modelDir}/{file}`. If omitted, it probes the
|
|
26379
|
-
* HuggingFace API (slower).
|
|
26380
|
-
* - Single-file formats (no `isDirectory`, e.g. OpenVINO IR): sibling
|
|
26381
|
-
* files fetched from the SAME remote directory as `url` and stored flat
|
|
26382
|
-
* alongside the main file — e.g. `['camstack-yolov9t.bin']` for the IR
|
|
26383
|
-
* weights next to `camstack-yolov9t.xml`.
|
|
26384
|
-
*/
|
|
26385
|
-
var ModelFormatEntrySchema = zod.z.object({
|
|
26386
|
-
url: zod.z.string(),
|
|
26387
|
-
sizeMB: zod.z.number(),
|
|
26388
|
-
/** Whether this format is a directory bundle (e.g., .mlpackage) rather than a single file */
|
|
26389
|
-
isDirectory: zod.z.boolean().optional(),
|
|
26390
|
-
/** Multi-file payload (directory members or sibling files). */
|
|
26391
|
-
files: zod.z.array(zod.z.string()).readonly().optional(),
|
|
26392
|
-
/** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
|
|
26393
|
-
runtimes: zod.z.array(zod.z.enum(["python"])).readonly().optional(),
|
|
26394
|
-
/**
|
|
26395
|
-
* Content revision of the artefact, for one hosted OFF the CamStack mirror.
|
|
26396
|
-
* A format on the mirror leaves it unset: its revision (the sha256 of its
|
|
26397
|
-
* weight file) comes from the downloader's generated table, kept in step
|
|
26398
|
-
* with the mirror by `scripts/check-hosted-model-revisions.ts` (D744). A
|
|
26399
|
-
* node records the revision it downloaded next to the file
|
|
26400
|
-
* (`<file>.revision`); a copy with no record or a different one is stale
|
|
26401
|
-
* unless its weight file hashes to the revision, and a stale copy is
|
|
26402
|
-
* downloaded again, the old one serving until the new one is complete. No
|
|
26403
|
-
* revision at all ⇒ a file on disk is current, whatever it holds (D743).
|
|
26404
|
-
*/
|
|
26405
|
-
revision: zod.z.string().min(1).optional()
|
|
26406
|
-
});
|
|
26407
|
-
/**
|
|
26408
|
-
* What a node holds for one (model, format) (D746). `current` is a complete
|
|
26409
|
-
* copy at its catalog revision — exactly what `downloaded: true` means.
|
|
26410
|
-
* `stale` is bytes on disk that are not (yet) proven current under D743/D744:
|
|
26411
|
-
* no or a different revision record, or a missing sibling. `missing` is no
|
|
26412
|
-
* copy. `downloaded` alone folds `stale` into "not downloaded", which hid
|
|
26413
|
-
* reclaimable bytes and a copy about to be replaced.
|
|
26414
|
-
*/
|
|
26415
|
-
var ModelOnDiskStateSchema = zod.z.enum([
|
|
26416
|
-
"current",
|
|
26417
|
-
"stale",
|
|
26418
|
-
"missing"
|
|
26419
|
-
]);
|
|
26420
|
-
/**
|
|
26421
|
-
* The numeric precision of one format's BUILD (D746) — reported only when the
|
|
26422
|
-
* build states it (file-name token, an INT8 variant, an EdgeTPU compile, a
|
|
26423
|
-
* CamStack Core ML export). Absent means "not stated", never "fp32".
|
|
26424
|
-
*/
|
|
26425
|
-
var ModelFormatPrecisionSchema = zod.z.enum([
|
|
26426
|
-
"fp32",
|
|
26427
|
-
"fp16",
|
|
26428
|
-
"int8"
|
|
26429
|
-
]);
|
|
26430
|
-
/**
|
|
26431
|
-
* One format of one model as a node's `pipelineExecutor.getSchema` reports it.
|
|
26432
|
-
* `onDisk` / `precision` are optional for version skew: a runner that predates
|
|
26433
|
-
* them omits them, and a reader falls back to `downloaded`.
|
|
26434
|
-
*/
|
|
26435
|
-
var PipelineModelFormatStatusSchema = zod.z.object({
|
|
26436
|
-
downloaded: zod.z.boolean(),
|
|
26437
|
-
sizeMB: zod.z.number(),
|
|
26438
|
-
onDisk: ModelOnDiskStateSchema.optional(),
|
|
26439
|
-
precision: ModelFormatPrecisionSchema.optional()
|
|
26440
|
-
});
|
|
26441
|
-
/**
|
|
26442
|
-
* Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
|
|
26443
|
-
* The downloader fetches from `url` and saves to `{modelsDir}/{filename}`.
|
|
26444
|
-
*/
|
|
26445
|
-
var ModelExtraFileSchema = zod.z.object({
|
|
26446
|
-
url: zod.z.string(),
|
|
26447
|
-
filename: zod.z.string(),
|
|
26448
|
-
sizeMB: zod.z.number()
|
|
26449
|
-
});
|
|
26450
|
-
/**
|
|
26451
|
-
* Per-format payload map. Modelled as an explicit object (one optional key
|
|
26452
|
-
* per `ModelFormat`) rather than `z.record(enum, …)` — zod v4's enum-keyed
|
|
26453
|
-
* record requires every key, but a catalog entry only ships a subset of
|
|
26454
|
-
* formats.
|
|
26455
|
-
*/
|
|
26456
|
-
var ModelFormatsSchema = zod.z.object({
|
|
26457
|
-
onnx: ModelFormatEntrySchema.optional(),
|
|
26458
|
-
coreml: ModelFormatEntrySchema.optional(),
|
|
26459
|
-
openvino: ModelFormatEntrySchema.optional(),
|
|
26460
|
-
tflite: ModelFormatEntrySchema.optional(),
|
|
26461
|
-
pt: ModelFormatEntrySchema.optional(),
|
|
26462
|
-
gguf: ModelFormatEntrySchema.optional()
|
|
26463
|
-
});
|
|
26464
|
-
/**
|
|
26465
|
-
* Variant-selector grouping axes. Shared by the full `ModelCatalogEntry` and by
|
|
26466
|
-
* the reduced `PipelineModelOption` returned in `pipeline.getSchema()` so the
|
|
26467
|
-
* grouped Family→Tier→Variant picker renders identically in the config UI and
|
|
26468
|
-
* in the pipeline/device steppers. The flat `id` stays the source of truth for
|
|
26469
|
-
* resolution/download/persistence; this is a presentation overlay resolved back
|
|
26470
|
-
* to an `id`.
|
|
26471
|
-
*/
|
|
26472
|
-
var ModelVariantGroupSchema = zod.z.object({
|
|
26473
|
-
/** Top-level family, e.g. `yolo26` (later `d-fine`, `rf-detr`). */
|
|
26474
|
-
family: zod.z.string(),
|
|
26475
|
-
/** Size within the family, e.g. `n` | `s` | `m` | `l`. */
|
|
26476
|
-
tier: zod.z.string(),
|
|
26477
|
-
/** Quantization axis. Omit ⇒ the fp32 base build. */
|
|
26478
|
-
precision: zod.z.enum(["fp32", "int8"]).optional(),
|
|
26479
|
-
/**
|
|
26480
|
-
* Training / latency-variant axis. Omit ⇒ the standard build. `test` marks
|
|
26481
|
-
* an alternate training of the same family (plugin catalog `relu_test`); chip
|
|
26482
|
-
* label is "Test".
|
|
26483
|
-
*/
|
|
26484
|
-
optimization: zod.z.enum(["standard", "test"]).optional(),
|
|
26485
|
-
/**
|
|
26486
|
-
* Input-resolution axis (square input side, px). Omit ⇒ the family's native
|
|
26487
|
-
* resolution (640 for yolo26). Reduced-input builds (320 / 256) are a big,
|
|
26488
|
-
* cheap latency lever — especially on Apple ANE and the Intel N100 — at a
|
|
26489
|
-
* small-object accuracy cost. Mirrors the model's `inputSize` but lifted onto
|
|
26490
|
-
* the group so the selector can offer it as a variant axis.
|
|
26491
|
-
*/
|
|
26492
|
-
resolution: zod.z.number().int().positive().optional()
|
|
26493
|
-
});
|
|
26494
|
-
var ModelProviderIdSchema = zod.z.enum([
|
|
26495
|
-
"camstack",
|
|
26496
|
-
"frigate",
|
|
26497
|
-
"scrypted",
|
|
26498
|
-
"custom"
|
|
26499
|
-
]);
|
|
26500
|
-
var ModelLicenseRecordSchema = zod.z.object({
|
|
26501
|
-
/** SPDX id of the WEIGHTS' terms, a `LicenseRef-*` for non-SPDX terms, or `UNKNOWN`. */
|
|
26502
|
-
weights: zod.z.string().min(1),
|
|
26503
|
-
/** SPDX id of the upstream code that defines / trained the network. */
|
|
26504
|
-
code: zod.z.string().min(1).optional(),
|
|
26505
|
-
/** Training data whose terms add obligations (attribution, non-commercial). */
|
|
26506
|
-
data: zod.z.object({
|
|
26507
|
-
name: zod.z.string().min(1),
|
|
26508
|
-
terms: zod.z.string().min(1),
|
|
26509
|
-
url: zod.z.string().url().optional()
|
|
26510
|
-
}).optional(),
|
|
26511
|
-
/** The project the weights come from. Required on built-in entries (guard). */
|
|
26512
|
-
upstream: zod.z.object({
|
|
26513
|
-
name: zod.z.string().min(1),
|
|
26514
|
-
url: zod.z.string().url()
|
|
26515
|
-
}).optional(),
|
|
26516
|
-
/** Where the licence text governing the weights is published. */
|
|
26517
|
-
url: zod.z.string().url().optional(),
|
|
26518
|
-
/** Attribution the licence REQUIRES, verbatim. */
|
|
26519
|
-
attribution: zod.z.string().min(1).optional(),
|
|
26520
|
-
/** What CamStack changed. Required when `hosting` is `camstack-hf` (guard). */
|
|
26521
|
-
modifications: zod.z.string().min(1).optional(),
|
|
26522
|
-
/** Who serves the file a node downloads. */
|
|
26523
|
-
hosting: zod.z.enum([
|
|
26524
|
-
"camstack-hf",
|
|
26525
|
-
"third-party",
|
|
26526
|
-
"built-in"
|
|
26527
|
-
]).optional(),
|
|
26528
|
-
/** True when the weights or their data forbid commercial use. */
|
|
26529
|
-
nonCommercial: zod.z.boolean().optional()
|
|
26530
|
-
});
|
|
26531
|
-
/**
|
|
26532
|
-
* The licence of a model, as a record rather than a bare SPDX string: a
|
|
26533
|
-
* permissive CODE licence routinely sits on top of restrictive WEIGHTS or
|
|
26534
|
-
* DATA, and the obligations (attribution, modification notices, source offers)
|
|
26535
|
-
* are per upstream. A persisted custom-model row written when this field was a
|
|
26536
|
-
* string still parses — the string is lifted into `{ weights }`.
|
|
26537
|
-
*
|
|
26538
|
-
* Every machine licence surface (`THIRD_PARTY_MODELS.md`, the Hugging Face
|
|
26539
|
-
* model table) is GENERATED from these records by
|
|
26540
|
-
* `scripts/gen-model-licenses.ts` (D661). Operator-facing docs live in
|
|
26541
|
-
* `camstack/docs` → `/docs/detection/models`.
|
|
26542
|
-
*/
|
|
26543
|
-
var ModelLicenseSchema = zod.z.preprocess((value) => typeof value === "string" ? { weights: value } : value, ModelLicenseRecordSchema);
|
|
26544
|
-
/**
|
|
26545
|
-
* One step a ROOT detector can supply from its own output (D730) — see
|
|
26546
|
-
* `ModelCatalogEntry.suppliesSteps`.
|
|
26547
|
-
*
|
|
26548
|
-
* - `label`: the root's raw class IS the step's answer. `labelToEffect` maps
|
|
26549
|
-
* the root's label to the step's vocabulary; `uncovered` is the vocabulary
|
|
26550
|
-
* the root cannot produce (shown as unavailable, never a blocker).
|
|
26551
|
-
* - `crop`: the root draws the box the step would have found (`license_plate`
|
|
26552
|
-
* for plate-detection, `face` for face-detection). The box becomes a detail
|
|
26553
|
-
* child of the `parentMacro` detection that contains it — never a track.
|
|
26554
|
-
* - `mask`: the root's decode emits an instance mask with every detection (a
|
|
26555
|
-
* YOLO26-seg root, D737) — the `segmentation` step's result, carried on the
|
|
26556
|
-
* detection in the shape that step produces. Derived from the model's
|
|
26557
|
-
* postprocessor on read, never stored by an import.
|
|
26558
|
-
*/
|
|
26559
|
-
var RootStepSupplySchema = zod.z.discriminatedUnion("kind", [
|
|
26560
|
-
zod.z.object({
|
|
26561
|
-
kind: zod.z.literal("label"),
|
|
26562
|
-
stepId: zod.z.enum(LABEL_SUPPLY_STEP_IDS),
|
|
26563
|
-
labelToEffect: zod.z.record(zod.z.string(), zod.z.string()),
|
|
26564
|
-
uncovered: zod.z.array(zod.z.string()).readonly()
|
|
26565
|
-
}),
|
|
26566
|
-
zod.z.object({
|
|
26567
|
-
kind: zod.z.literal("crop"),
|
|
26568
|
-
stepId: zod.z.enum(CROP_SUPPLY_STEP_IDS),
|
|
26569
|
-
rootLabels: zod.z.array(zod.z.string()).readonly(),
|
|
26570
|
-
parentMacro: zod.z.enum(["vehicle", "person"]),
|
|
26571
|
-
childClass: zod.z.enum(["plate", "face"]),
|
|
26572
|
-
/**
|
|
26573
|
-
* The root's smaller input side, stamped on read by `rootSuppliesOf` from
|
|
26574
|
-
* the model entry — what a step's `minRootInputPx` gate judges. Never
|
|
26575
|
-
* stored by an import.
|
|
26576
|
-
*/
|
|
26577
|
-
rootInputPx: zod.z.number().int().positive().optional()
|
|
26578
|
-
}),
|
|
26579
|
-
zod.z.object({
|
|
26580
|
-
kind: zod.z.literal("mask"),
|
|
26581
|
-
stepId: zod.z.enum(MASK_SUPPLY_STEP_IDS)
|
|
26582
|
-
})
|
|
26583
|
-
]);
|
|
26584
|
-
var ModelCatalogEntrySchema = zod.z.object({
|
|
26585
|
-
id: zod.z.string(),
|
|
26586
|
-
name: zod.z.string(),
|
|
26587
|
-
description: zod.z.string(),
|
|
26588
|
-
formats: ModelFormatsSchema,
|
|
26589
|
-
inputSize: zod.z.object({
|
|
26590
|
-
width: zod.z.number(),
|
|
26591
|
-
height: zod.z.number()
|
|
26592
|
-
}),
|
|
26593
|
-
/**
|
|
26594
|
-
* Channel count of the model input tensor. Omit ⇒ 3 (RGB), the default for
|
|
26595
|
-
* every detector / classifier / embedder. Set to 1 for a grayscale CTC text
|
|
26596
|
-
* recognizer (EasyOCR VGG plate-OCR: input `[N,1,H,W]`) so the preprocess
|
|
26597
|
-
* feeds a single-channel, EasyOCR-normalized tensor instead of the default
|
|
26598
|
-
* 3-channel RGB one. Threaded through `PoolModelConfig.inputChannels` to the
|
|
26599
|
-
* Python inference pool.
|
|
26600
|
-
*/
|
|
26601
|
-
inputChannels: zod.z.number().int().positive().optional(),
|
|
26602
|
-
labels: zod.z.array(LabelDefinitionSchema).readonly(),
|
|
26603
|
-
inputLayout: zod.z.enum(["nchw", "nhwc"]).optional(),
|
|
26604
|
-
/**
|
|
26605
|
-
* `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
|
|
26606
|
-
* (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
|
|
26607
|
-
* plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
|
|
26608
|
-
* `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
|
|
26609
|
-
*/
|
|
26610
|
-
inputNormalization: zod.z.enum([
|
|
26611
|
-
"zero-one",
|
|
26612
|
-
"imagenet",
|
|
26613
|
-
"none",
|
|
26614
|
-
"scrfd"
|
|
26615
|
-
]).optional(),
|
|
26616
|
-
/**
|
|
26617
|
-
* The model already applies softmax IN-GRAPH — its raw output is a
|
|
26618
|
-
* probability distribution, not logits. When set, the `softmax`
|
|
26619
|
-
* postprocessor must NOT re-apply softmax: re-softmaxing an already-normalised
|
|
26620
|
-
* probability vector collapses it toward uniform (top-1 score craters far
|
|
26621
|
-
* below its true value, making every confidence gate meaningless). Absent ⇒
|
|
26622
|
-
* the output is raw logits and the postprocessor applies softmax (the normal
|
|
26623
|
-
* case). Set on the Google AIY Birds `bird-classifier` (softmax baked into the
|
|
26624
|
-
* TF graph). Threaded to the Python pool via `PoolModelConfig.outputProbabilities`.
|
|
26625
|
-
*/
|
|
26626
|
-
outputProbabilities: zod.z.boolean().optional(),
|
|
26627
|
-
preprocessMode: zod.z.enum(["letterbox", "resize"]).optional(),
|
|
26628
|
-
/**
|
|
26629
|
-
* Per-MODEL postprocessor override. Absent ⇒ the step's own
|
|
26630
|
-
* `StepDefinition.postprocessor` applies (the normal case — every model in a
|
|
26631
|
-
* step shares its decode). Set it when a step hosts models with DIFFERENT raw
|
|
26632
|
-
* output layouts under one slot: e.g. object-detection is `'yolo'` by default,
|
|
26633
|
-
* but a Coral SSD MobileNet build emits the `TFLite_Detection_PostProcess`
|
|
26634
|
-
* 4-tensor layout and needs `'ssd'`. Threaded into `PoolModelConfig.postprocessor`
|
|
26635
|
-
* by the engine factory (`modelEntry.postprocessor ?? def.postprocessor`).
|
|
26636
|
-
*/
|
|
26637
|
-
postprocessor: zod.z.custom().optional(),
|
|
26638
|
-
/**
|
|
26639
|
-
* Per-MODEL default confidence floor. Absent ⇒ the step's
|
|
26640
|
-
* `StepDefinition.defaultConfidence` applies. A score is a property of one
|
|
26641
|
-
* model's output scale, not of the step slot it sits in: YuNet's
|
|
26642
|
-
* `sqrt(cls·obj)` is not SCRFD's score, and inheriting SCRFD's 0.5 filled the
|
|
26643
|
-
* face gallery with wheels and hands (D662, amends D645). An operator's
|
|
26644
|
-
* explicit value still wins over it. Resolved in ONE place —
|
|
26645
|
-
* `addon-pipeline/.../registry/effective-confidence.ts`.
|
|
26646
|
-
*/
|
|
26647
|
-
defaultConfidence: zod.z.number().min(0).max(1).optional(),
|
|
26648
|
-
/**
|
|
26649
|
-
* Per-MODEL default of the per-class confidence floors (`minConfidence<Macro>`
|
|
26650
|
-
* on a detector step), keyed by macro class: `{ person: 0.45 }`. A class
|
|
26651
|
-
* absent here runs at the step slider's global default. The same row shape
|
|
26652
|
-
* the floor measurement produces (`model-floors.json`: modelId → floors), so
|
|
26653
|
-
* a measured table is copied in as-is. An operator override is bound to the
|
|
26654
|
-
* model it was made for and does not survive a model change (D738). A custom
|
|
26655
|
-
* / imported model may declare it; without it, the global defaults apply.
|
|
26656
|
-
*/
|
|
26657
|
-
defaultClassFloors: zod.z.record(zod.z.string(), zod.z.number().min(0).max(1)).optional(),
|
|
26658
|
-
/**
|
|
26659
|
-
* The inference precision this model's OpenVINO IR needs on an Intel GPU.
|
|
26660
|
-
* Absent ⇒ the device default (f16 on a GPU). Set to `'f32'` for an FP32 IR
|
|
26661
|
-
* that produces invalid output at f16 — measured 2026-10-07 for YOLO26
|
|
26662
|
-
* base IRs (`yolo26s`: 0 true / 146 false positives; `yolo26m*`: NaN
|
|
26663
|
-
* scores) on the Core Ultra iGPU and the N100. Threaded to the pool as
|
|
26664
|
-
* `PoolModelConfig.gpuInferencePrecision`; the pool sets
|
|
26665
|
-
* INFERENCE_PRECISION_HINT on a GPU only. Costs ~60% latency on the GPU.
|
|
26666
|
-
*/
|
|
26667
|
-
gpuInferencePrecision: zod.z.enum(["f32", "f16"]).optional(),
|
|
26668
|
-
/**
|
|
26669
|
-
* ROOT detectors only: per supplied step (`animal-classifier`, …), the
|
|
26670
|
-
* minimum DETECTION score from which this root's own fine label (species,
|
|
26671
|
-
* vehicle type — D736 root supply) is taken (D741). Below it the detection
|
|
26672
|
-
* keeps its macro class without the fine label. `1` = never take it from
|
|
26673
|
-
* this root. Absent ⇒ no floor beyond the macro floor. The supplied step's
|
|
26674
|
-
* `minConfidence` slider, bound to the ROOT model, overrides it.
|
|
26675
|
-
*/
|
|
26676
|
-
suppliedLabelFloors: zod.z.record(zod.z.string(), zod.z.number().min(0).max(1)).optional(),
|
|
26677
|
-
/**
|
|
26678
|
-
* When true, the executor produces a landmark-aligned crop (similarity warp
|
|
26679
|
-
* onto the canonical template) before this step runs, instead of a plain
|
|
26680
|
-
* axis-aligned bbox crop. Required for face-recognition embedders (ArcFace):
|
|
26681
|
-
* their embeddings are only discriminative on an aligned input. The face
|
|
26682
|
-
* detector that produced the parent detail must emit 5 landmarks.
|
|
26683
|
-
*/
|
|
26684
|
-
faceAlignment: zod.z.boolean().optional(),
|
|
26685
|
-
/**
|
|
26686
|
-
* Auxiliary files required at runtime (labels JSON, charset dict, etc.).
|
|
26687
|
-
* Downloaded into the same modelsDir alongside the model file.
|
|
26688
|
-
*/
|
|
26689
|
-
extraFiles: zod.z.array(ModelExtraFileSchema).readonly().optional(),
|
|
26690
|
-
/**
|
|
26691
|
-
* LEGACY entry — retained in the catalog so a persisted operator selection
|
|
26692
|
-
* still RESOLVES (and can be re-activated), but hidden from the selectable
|
|
26693
|
-
* model list and excluded from the auto format-default pick. Set on the
|
|
26694
|
-
* superseded / consolidated models (older lineages, redundant fp16 IRs) so
|
|
26695
|
-
* the active lineup stays the coherent curated ladder without deleting a
|
|
26696
|
-
* model anyone may still be pinned to. `resolveModelForFormat` keeps honoring
|
|
26697
|
-
* an explicit legacy id that has a build for the node's format.
|
|
26698
|
-
*/
|
|
26699
|
-
legacy: zod.z.boolean().optional(),
|
|
26700
|
-
/**
|
|
26701
|
-
* Measured quality/latency metadata — populated from the benchmark addon on
|
|
26702
|
-
* the real node classes. Absent = not yet measured (most entries today; the
|
|
26703
|
-
* catalog historically carried only `sizeMB`, a poor cross-architecture
|
|
26704
|
-
* speed proxy). `p95LatencyMs` is keyed by node class (e.g. `n100`, `mac`).
|
|
26705
|
-
*/
|
|
26706
|
-
metrics: zod.z.object({
|
|
26707
|
-
map50: zod.z.number().optional(),
|
|
26708
|
-
p95LatencyMs: zod.z.record(zod.z.string(), zod.z.number()).optional()
|
|
26709
|
-
}).optional(),
|
|
26710
|
-
/**
|
|
26711
|
-
* The model's licence record — see {@link ModelLicenseSchema}. Optional in
|
|
26712
|
-
* the schema (a custom model's author may state none); REQUIRED and complete
|
|
26713
|
-
* on every built-in catalog entry (`scripts/check-catalog-licence.ts`).
|
|
26714
|
-
*/
|
|
26715
|
-
license: ModelLicenseSchema.optional(),
|
|
26716
|
-
/**
|
|
26717
|
-
* Variant-selector grouping. The UI groups models by `family` + `tier` and
|
|
26718
|
-
* offers `precision` / `optimization` as variant axes WITHIN a tier — so all
|
|
26719
|
-
* of a family's sizes and quantizations collapse into one grouped picker
|
|
26720
|
-
* instead of a flat list of `yolo26s`, `yolo26s-int8`, … Absent ⇒ ungrouped
|
|
26721
|
-
* (legacy / custom models) — never shown in the grouped selector. The flat
|
|
26722
|
-
* `id` stays the source of truth for resolution/download/persistence; grouping
|
|
26723
|
-
* is a presentation overlay resolved back to an `id`.
|
|
26724
|
-
*/
|
|
26725
|
-
group: ModelVariantGroupSchema.optional(),
|
|
26726
|
-
/**
|
|
26727
|
-
* Catalog source for the pipeline stepper's provider-first picker. Absent on
|
|
26728
|
-
* built-in CamStack entries (treated as `camstack`) and on registry rows
|
|
26729
|
-
* persisted before this field existed (`inferModelProvider` fills those).
|
|
26730
|
-
*/
|
|
26731
|
-
provider: ModelProviderIdSchema.optional(),
|
|
26732
|
-
/**
|
|
26733
|
-
* Per-MODEL class map override. Absent ⇒ the step's `StepDefinition.classMap`
|
|
26734
|
-
* applies (plus catalog / COCO public catalog). Set on a custom model whose raw
|
|
26735
|
-
* labels already ARE the CamStack macros (plugin catalog identity map).
|
|
26736
|
-
*/
|
|
26737
|
-
classMap: DetectionCatalogClassMapSchema.optional(),
|
|
26738
|
-
/**
|
|
26739
|
-
* The pipeline steps this ROOT detector can supply from its own output
|
|
26740
|
-
* (D730): its labels name a step's effect (`deer` for `animal-classifier`)
|
|
26741
|
-
* or draw a step's box (`license_plate` for `plate-detection`). Computed at
|
|
26742
|
-
* import from THIS model's labelmap by `deriveRootSupplies`, never written
|
|
26743
|
-
* by hand and never assumed per family; a row without it is derived on read
|
|
26744
|
-
* (`rootSuppliesOf`). Whether a camera uses it is the step's own
|
|
26745
|
-
* `useRootModel` flag (`resolveRootSupply`).
|
|
26746
|
-
*/
|
|
26747
|
-
suppliesSteps: zod.z.array(RootStepSupplySchema).readonly().optional(),
|
|
26748
|
-
/**
|
|
26749
|
-
* The model's CLIP feature-space contract (text encoder, dimension, vector
|
|
26750
|
-
* index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
|
|
26751
|
-
* CLIP image encoder; its absence is what "not a CLIP model" means to the
|
|
26752
|
-
* embedding encoder and the semantic-search store (D649).
|
|
26753
|
-
*/
|
|
26754
|
-
clip: ClipModelMetaSchema.optional()
|
|
26755
|
-
});
|
|
26756
|
-
var ConvertTargetSchema = zod.z.discriminatedUnion("format", [zod.z.object({
|
|
26757
|
-
format: zod.z.literal("openvino"),
|
|
26758
|
-
precisions: zod.z.array(zod.z.enum(["fp16", "int8"])).min(1).readonly()
|
|
26759
|
-
}), zod.z.object({ format: zod.z.literal("coreml") })]);
|
|
26760
|
-
var ModelConvertMetadataSchema = zod.z.object({
|
|
26761
|
-
id: zod.z.string().regex(/^[a-zA-Z0-9._-]+$/),
|
|
26762
|
-
name: zod.z.string(),
|
|
26763
|
-
labels: zod.z.array(LabelDefinitionSchema).readonly(),
|
|
26764
|
-
inputSize: zod.z.object({
|
|
26765
|
-
width: zod.z.number(),
|
|
26766
|
-
height: zod.z.number()
|
|
26767
|
-
}),
|
|
26768
|
-
inputLayout: zod.z.enum(["nchw", "nhwc"]).optional(),
|
|
26769
|
-
inputNormalization: zod.z.enum([
|
|
26770
|
-
"zero-one",
|
|
26771
|
-
"imagenet",
|
|
26772
|
-
"none",
|
|
26773
|
-
"scrfd"
|
|
26774
|
-
]).optional(),
|
|
26775
|
-
preprocessMode: zod.z.enum(["letterbox", "resize"]).optional(),
|
|
26776
|
-
outputFormat: zod.z.enum([
|
|
26777
|
-
"yolo",
|
|
26778
|
-
"ssd",
|
|
26779
|
-
"embedding",
|
|
26780
|
-
"classification",
|
|
26781
|
-
"ocr",
|
|
26782
|
-
"segmentation"
|
|
26783
|
-
]),
|
|
26784
|
-
faceAlignment: zod.z.boolean().optional(),
|
|
26785
|
-
classMap: DetectionCatalogClassMapSchema.optional()
|
|
26786
|
-
});
|
|
26787
|
-
var ConvertArtifactSchema = zod.z.object({
|
|
26788
|
-
format: zod.z.enum(MODEL_FORMATS),
|
|
26789
|
-
precision: zod.z.enum(["fp16", "int8"]).optional(),
|
|
26790
|
-
sizeMB: zod.z.number(),
|
|
26791
|
-
validated: zod.z.boolean(),
|
|
26792
|
-
files: zod.z.array(zod.z.string()).readonly()
|
|
26793
|
-
});
|
|
26794
|
-
var ConvertResultSchema = zod.z.object({
|
|
26795
|
-
entry: ModelCatalogEntrySchema,
|
|
26796
|
-
artifacts: zod.z.array(ConvertArtifactSchema).readonly()
|
|
26797
|
-
});
|
|
26798
|
-
/**
|
|
26799
|
-
* True if the scope set grants `access` on device-scoped capabilities.
|
|
26800
|
-
* A `category:device` grant covers every device cap (the broad grant).
|
|
26801
|
-
*/
|
|
26802
|
-
function scopesAllowDeviceCap(scopes, access) {
|
|
26803
|
-
return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
|
|
26804
|
-
}
|
|
26805
|
-
/**
|
|
26806
|
-
* True if the scope set names this addon with at least `access`.
|
|
26807
|
-
*
|
|
26808
|
-
* Deliberately NOT satisfied by `category:device`: a grant over per-camera
|
|
26809
|
-
* capabilities says nothing about an addon's own HTTP surface, and conflating
|
|
26810
|
-
* the two is precisely the confusion that let an Alexa token drive Home
|
|
26811
|
-
* Assistant's command route.
|
|
26812
|
-
*/
|
|
26813
|
-
function scopesAllowAddon(scopes, addonId, access) {
|
|
26814
|
-
return scopes.some((s) => s.type === "addon" && s.target === addonId && s.access.includes(access));
|
|
26815
|
-
}
|
|
26816
|
-
var ViewerFeatureIdSchema = zod.z.enum([
|
|
26817
|
-
"face-assignment",
|
|
26818
|
-
"plate-assignment",
|
|
26819
|
-
"retrain",
|
|
26820
|
-
"scenes"
|
|
26821
|
-
]);
|
|
26822
|
-
/** Which devices a viewer reaches: `allow` minus `block`. */
|
|
26823
|
-
var ViewerDeviceAllowSchema = zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.number().int().nonnegative())]);
|
|
26824
|
-
/**
|
|
26825
|
-
* The viewer grant, stored as ONE row of a user's `scopes`. A principal that
|
|
26826
|
-
* holds it is decided by the viewer rules ALONE — any other row it carries is
|
|
26827
|
-
* ignored, so a viewer can never be widened by a leftover grant.
|
|
26828
|
-
*/
|
|
26829
|
-
var ViewerTokenScopeSchema = zod.z.object({
|
|
26830
|
-
type: zod.z.literal("viewer"),
|
|
26831
|
-
allow: ViewerDeviceAllowSchema,
|
|
26832
|
-
block: zod.z.array(zod.z.number().int().nonnegative()),
|
|
26833
|
-
features: zod.z.array(ViewerFeatureIdSchema)
|
|
26834
|
-
});
|
|
26835
|
-
/**
|
|
26836
|
-
* Zod schemas for persisted record types.
|
|
26837
|
-
*
|
|
26838
|
-
* These schemas serve as the single source of truth for types that are
|
|
26839
|
-
* stored in the settings-store backend and retrieved via tRPC. They
|
|
26840
|
-
* replace the manual TypeScript interfaces with schema-derived types,
|
|
26841
|
-
* enabling runtime validation when reading from the backend.
|
|
26842
|
-
*
|
|
26843
|
-
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
26844
|
-
* keeps the original name for backward compatibility.
|
|
26845
|
-
*/
|
|
26846
|
-
/**
|
|
26847
|
-
* Auth model (v2 — 2026-05-12 caps-only):
|
|
26848
|
-
*
|
|
26849
|
-
* Two principals:
|
|
26850
|
-
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
26851
|
-
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
26852
|
-
*
|
|
26853
|
-
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
26854
|
-
* `super_admin` — collapsed onto the single boolean because every
|
|
26855
|
-
* non-admin caller is governed by the same scope-check rules; the
|
|
26856
|
-
* distinction was only ever used to route role-specific procedures
|
|
26857
|
-
* which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
|
|
26858
|
-
* with `isAdmin: false` + an explicit scope list.
|
|
26859
|
-
*/
|
|
26860
|
-
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
26861
|
-
var MethodAccessSchema = zod.z.enum([
|
|
26862
|
-
"view",
|
|
26863
|
-
"create",
|
|
26864
|
-
"delete"
|
|
26865
|
-
]);
|
|
26866
|
-
/**
|
|
26867
|
-
* A single scope grant. Three forms — checked in matcher with OR
|
|
26868
|
-
* semantics; the first match decides whether the call passes:
|
|
26869
|
-
*
|
|
26870
|
-
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
26871
|
-
* cap with the matching `scope` declaration. New caps inherit grants
|
|
26872
|
-
* automatically — adding a device cap to the codebase makes it
|
|
26873
|
-
* reachable to every user with `category:device [...]` without a
|
|
26874
|
-
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
26875
|
-
*
|
|
26876
|
-
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
26877
|
-
* useful when an integration needs to interact with one specific
|
|
26878
|
-
* addon's surface regardless of how many caps it exports.
|
|
26879
|
-
*
|
|
26880
|
-
* - `capability` — the most precise form. Single cap name. Use for
|
|
26881
|
-
* integration tokens where you want to grant `addons.installPackage`
|
|
26882
|
-
* and nothing else.
|
|
26883
|
-
*
|
|
26884
|
-
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
26885
|
-
* "give me everything" escape; there is no wildcard scope.
|
|
26886
|
-
*/
|
|
26887
|
-
var AllowedProviderSchema = zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]);
|
|
26888
|
-
var AllowedDevicesSchema = zod.z.record(zod.z.string(), zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]));
|
|
26889
|
-
var CapScopeSchema = zod.z.enum(["device", "system"]);
|
|
26890
|
-
/**
|
|
26891
|
-
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
26892
|
-
*
|
|
26893
|
-
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
26894
|
-
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
26895
|
-
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
26896
|
-
* AFTER the grant was minted — no re-grant, no re-login.
|
|
26897
|
-
*
|
|
26898
|
-
* - `all` — every device in the deployment. The broad viewer/operator
|
|
26899
|
-
* lever without a `category` grant (a `category` grant also covers device
|
|
26900
|
-
* caps that carry no deviceId; `all` is specifically the device set).
|
|
26901
|
-
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
26902
|
-
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
26903
|
-
* is NOT covered until the grant is edited.
|
|
26904
|
-
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
26905
|
-
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
26906
|
-
* re-resolves on the next request.
|
|
26907
|
-
* - `locations` — every device whose operator-assigned `location` label is
|
|
26908
|
-
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
26909
|
-
* null/unset location matches NO `locations` selector.
|
|
26910
|
-
*/
|
|
26911
|
-
var DeviceSelectorSchema = zod.z.discriminatedUnion("kind", [
|
|
26912
|
-
zod.z.object({ kind: zod.z.literal("all") }),
|
|
26913
|
-
zod.z.object({
|
|
26914
|
-
kind: zod.z.literal("ids"),
|
|
26915
|
-
ids: zod.z.array(zod.z.number().int()).min(1)
|
|
26916
|
-
}),
|
|
26917
|
-
zod.z.object({
|
|
26918
|
-
kind: zod.z.literal("types"),
|
|
26919
|
-
types: zod.z.array(zod.z.enum(DeviceType)).min(1)
|
|
26920
|
-
}),
|
|
26921
|
-
zod.z.object({
|
|
26922
|
-
kind: zod.z.literal("locations"),
|
|
26923
|
-
locations: zod.z.array(zod.z.string().min(1)).min(1)
|
|
26924
|
-
})
|
|
26925
|
-
]);
|
|
26926
|
-
var DeviceTokenScopeSchema = zod.z.object({
|
|
26927
|
-
type: zod.z.literal("device"),
|
|
26928
|
-
/** The device SET this grant covers — resolved against the live fleet. */
|
|
26929
|
-
selector: DeviceSelectorSchema,
|
|
26930
|
-
access: zod.z.array(MethodAccessSchema).min(1),
|
|
26931
|
-
/**
|
|
26932
|
-
* Whether a grant on a PARENT device transparently covers its accessory
|
|
26933
|
-
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
26934
|
-
* Direction is parent → children ONLY.
|
|
26935
|
-
*
|
|
26936
|
-
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
26937
|
-
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
26938
|
-
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
26939
|
-
* operator must grant on the child, not inherit from the parent). Set it
|
|
26940
|
-
* explicitly to override that default per grant.
|
|
26941
|
-
*/
|
|
26942
|
-
includeLinked: zod.z.boolean().optional()
|
|
26943
|
-
});
|
|
26944
|
-
/**
|
|
26945
|
-
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
26946
|
-
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
26947
|
-
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
26948
|
-
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
26949
|
-
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
26950
|
-
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
26951
|
-
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
26952
|
-
* migration covers both without a flag day. No cast — the raw object is read
|
|
26953
|
-
* through `Reflect.get` (its static type is `unknown`).
|
|
26954
|
-
*/
|
|
26955
|
-
function migrateLegacyTokenScope(raw) {
|
|
26956
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
26957
|
-
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
26958
|
-
if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
|
|
26959
|
-
const targets = Reflect.get(raw, "targets");
|
|
26960
|
-
if (!Array.isArray(targets)) return raw;
|
|
26961
|
-
return {
|
|
26962
|
-
type: "device",
|
|
26963
|
-
selector: {
|
|
26964
|
-
kind: "ids",
|
|
26965
|
-
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
26966
|
-
},
|
|
26967
|
-
access: Reflect.get(raw, "access")
|
|
26968
|
-
};
|
|
26969
|
-
}
|
|
26970
|
-
/**
|
|
26971
|
-
* A stored `types` selector may name a type D1033 retired (`thermostat`). The
|
|
26972
|
-
* grant is read back through this same preprocess, so the retired name is
|
|
26973
|
-
* rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
|
|
26974
|
-
* stays a strict enum on the wire.
|
|
26975
|
-
*/
|
|
26976
|
-
function canonicalSelectorTypes(raw) {
|
|
26977
|
-
const selector = Reflect.get(raw, "selector");
|
|
26978
|
-
if (selector === null || typeof selector !== "object") return raw;
|
|
26979
|
-
if (Reflect.get(selector, "kind") !== "types") return raw;
|
|
26980
|
-
const types = Reflect.get(selector, "types");
|
|
26981
|
-
if (!Array.isArray(types)) return raw;
|
|
26982
|
-
const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
|
|
26983
|
-
return {
|
|
26984
|
-
...raw,
|
|
26985
|
-
selector: {
|
|
26986
|
-
...selector,
|
|
26987
|
-
types: canonical
|
|
26988
|
-
}
|
|
26989
|
-
};
|
|
26990
|
-
}
|
|
26991
|
-
var TokenScopeSchema = zod.z.preprocess(migrateLegacyTokenScope, zod.z.discriminatedUnion("type", [
|
|
26992
|
-
zod.z.object({
|
|
26993
|
-
type: zod.z.literal("category"),
|
|
26994
|
-
target: CapScopeSchema,
|
|
26995
|
-
access: zod.z.array(MethodAccessSchema).min(1)
|
|
26996
|
-
}),
|
|
26997
|
-
zod.z.object({
|
|
26998
|
-
type: zod.z.literal("capability"),
|
|
26999
|
-
target: zod.z.string(),
|
|
27000
|
-
access: zod.z.array(MethodAccessSchema).min(1)
|
|
27001
|
-
}),
|
|
27002
|
-
zod.z.object({
|
|
27003
|
-
type: zod.z.literal("addon"),
|
|
27004
|
-
target: zod.z.string(),
|
|
27005
|
-
access: zod.z.array(MethodAccessSchema).min(1)
|
|
27006
|
-
}),
|
|
27007
|
-
DeviceTokenScopeSchema
|
|
27008
|
-
]));
|
|
27009
|
-
/**
|
|
27010
|
-
* What a PERSON's grant set holds (D921): the capability rows above (legacy
|
|
27011
|
-
* users, integration-style tokens) or the viewer row, which is decided by its
|
|
27012
|
-
* own rules alone. Kept apart from {@link TokenScope} so every surface that
|
|
27013
|
-
* edits capability rows (the scope picker, token minting) keeps its shape.
|
|
27014
|
-
*/
|
|
27015
|
-
var UserScopeSchema = zod.z.union([ViewerTokenScopeSchema, TokenScopeSchema]);
|
|
27016
|
-
var UserRecordSchema = zod.z.object({
|
|
27017
|
-
id: zod.z.string(),
|
|
27018
|
-
username: zod.z.string(),
|
|
27019
|
-
passwordHash: zod.z.string(),
|
|
27020
|
-
/**
|
|
27021
|
-
* Admin bypass. When true, the middleware skips the scope-access
|
|
27022
|
-
* check entirely. There is no other axis of privilege; the legacy
|
|
27023
|
-
* role enum collapsed onto this boolean in v2.
|
|
27024
|
-
*/
|
|
27025
|
-
isAdmin: zod.z.boolean().default(false),
|
|
27026
|
-
allowedProviders: AllowedProviderSchema,
|
|
27027
|
-
allowedDevices: AllowedDevicesSchema,
|
|
27028
|
-
/**
|
|
27029
|
-
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
27030
|
-
* ignored. Non-admins without scopes are locked out of every
|
|
27031
|
-
* protected call.
|
|
27032
|
-
*/
|
|
27033
|
-
scopes: zod.z.array(UserScopeSchema).default([]),
|
|
27034
|
-
createdAt: zod.z.number(),
|
|
27035
|
-
updatedAt: zod.z.number()
|
|
27036
|
-
});
|
|
27037
|
-
var ScopedTokenSchema = zod.z.object({
|
|
27038
|
-
id: zod.z.string(),
|
|
27039
|
-
userId: zod.z.string(),
|
|
27040
|
-
name: zod.z.string(),
|
|
27041
|
-
tokenHash: zod.z.string(),
|
|
27042
|
-
tokenPrefix: zod.z.string(),
|
|
27043
|
-
scopes: zod.z.array(TokenScopeSchema),
|
|
27044
|
-
expiresAt: zod.z.number().nullish(),
|
|
27045
|
-
lastUsedAt: zod.z.number().nullish(),
|
|
27046
|
-
createdAt: zod.z.number()
|
|
27047
|
-
});
|
|
27048
|
-
/** What a share-view grant lets its holder see. */
|
|
27049
|
-
var ShareViewGrantSchema = zod.z.object({
|
|
27050
|
-
kind: zod.z.enum(SHARE_VIEW_KINDS),
|
|
27051
|
-
deviceIds: zod.z.array(zod.z.number().int().nonnegative()).min(1).max(64),
|
|
27052
|
-
/** Talk-back, opt-in at mint time; absent means off. */
|
|
27053
|
-
talk: zod.z.boolean().optional()
|
|
27054
|
-
});
|
|
27055
|
-
var ShareViewScopeSchema = zod.z.object({
|
|
27056
|
-
type: zod.z.literal("share-view"),
|
|
27057
|
-
grant: ShareViewGrantSchema
|
|
27058
|
-
});
|
|
27059
|
-
var AddonRoutesScopeSchema = zod.z.object({
|
|
27060
|
-
type: zod.z.literal("addon-routes"),
|
|
27061
|
-
access: zod.z.array(MethodAccessSchema).min(1)
|
|
27062
|
-
});
|
|
27063
|
-
var PreferencesSelfScopeSchema = zod.z.object({ type: zod.z.literal("preferences-self") });
|
|
27064
|
-
var CredentialScopeSchema = zod.z.union([
|
|
27065
|
-
zod.z.literal("*"),
|
|
27066
|
-
ShareViewScopeSchema,
|
|
27067
|
-
AddonRoutesScopeSchema,
|
|
27068
|
-
PreferencesSelfScopeSchema,
|
|
27069
|
-
ViewerTokenScopeSchema,
|
|
27070
|
-
TokenScopeSchema
|
|
27071
|
-
]);
|
|
27072
|
-
/**
|
|
27073
|
-
* The `kind` claim of a unified token. It names the TOKEN FAMILY (so every
|
|
27074
|
-
* older gate that classifies a hub JWT refuses it — `classifyBearerPrincipal`
|
|
27075
|
-
* treats any `kind` it does not know as not-a-credential), never what the
|
|
27076
|
-
* token may do: that is its `scopes`, and only its `scopes`.
|
|
27077
|
-
*/
|
|
27078
|
-
var CREDENTIAL_TOKEN_KIND = "credential";
|
|
27079
|
-
/**
|
|
27080
|
-
* The `aud` claim every minted token is signed with (D895). The hub's raw JWT
|
|
27081
|
-
* verify (`AuthManager.verifyToken`, used by every surface that wants a LOGIN
|
|
27082
|
-
* session — the OAuth consent page, the session cookie, health, backups)
|
|
27083
|
-
* refuses a token carrying it, so a minted token — a share link above all —
|
|
27084
|
-
* can never be replayed as a person's session. Only the credential verifier's
|
|
27085
|
-
* own door (`verifyCredentialToken`) accepts it.
|
|
27086
|
-
*/
|
|
27087
|
-
var CREDENTIAL_TOKEN_AUDIENCE = "camstack:credential";
|
|
27088
|
-
/** Does a verified JWT payload belong to the minted-token family? */
|
|
27089
|
-
function isCredentialTokenPayload(payload) {
|
|
27090
|
-
if (payload === null || typeof payload !== "object") return false;
|
|
27091
|
-
const kind = Reflect.get(payload, "kind");
|
|
27092
|
-
const aud = Reflect.get(payload, "aud");
|
|
27093
|
-
return kind === "credential" || aud === "camstack:credential" || Array.isArray(aud) && aud.includes("camstack:credential");
|
|
27094
|
-
}
|
|
27095
|
-
/**
|
|
27096
|
-
* The claims of a unified token (`auth.mintToken`). It carries no `exp`: its
|
|
27097
|
-
* row (looked up by `jti` on every verify, for revocation) holds the ONE
|
|
27098
|
-
* expiry, so a share link can be extended and a JWT clock can never disagree
|
|
27099
|
-
* with the row.
|
|
27100
|
-
*/
|
|
27101
|
-
var CredentialTokenClaimsSchema = zod.z.object({
|
|
27102
|
-
kind: zod.z.literal(CREDENTIAL_TOKEN_KIND),
|
|
27103
|
-
sub: zod.z.string().min(1),
|
|
27104
|
-
jti: zod.z.string().min(16),
|
|
27105
|
-
scopes: zod.z.array(CredentialScopeSchema).min(1)
|
|
27106
|
-
});
|
|
27107
|
-
/**
|
|
27108
|
-
* Per-user ACCOUNT preferences (D894): the hub-side half of the viewer's two
|
|
27109
|
-
* settings levels.
|
|
27110
|
-
*
|
|
27111
|
-
* - DEVICE settings never leave the phone.
|
|
27112
|
-
* - ACCOUNT settings live here: one row per `(user, namespace)`, private to
|
|
27113
|
-
* that user, synced across every device signed in as them, last write wins
|
|
27114
|
-
* unless the writer sends the revision it based its edit on.
|
|
27115
|
-
*
|
|
27116
|
-
* A setting lives in exactly ONE level; there are no overrides. The caller
|
|
27117
|
-
* never names a user: the hub stamps the principal's own id, admin included.
|
|
27118
|
-
*
|
|
27119
|
-
* The contract the client codes against is the `preferences.*` tRPC router
|
|
27120
|
-
* (`server/backend/src/api/core/preferences.router.ts`).
|
|
27121
|
-
*/
|
|
27122
|
-
/** `viewer.app`, `viewer.cameras`, `viewer.grids` … — lowercase, dot/dash separated. */
|
|
27123
|
-
var PREFERENCES_NAMESPACE_PATTERN = /^[a-z][a-z0-9.-]{0,63}$/;
|
|
27124
|
-
/** One row's value, measured as UTF-8 JSON. */
|
|
27125
|
-
var PREFERENCES_MAX_VALUE_BYTES = 256 * 1024;
|
|
27126
|
-
var PreferenceNamespaceSchema = zod.z.string().regex(PREFERENCES_NAMESPACE_PATTERN);
|
|
27127
|
-
/** A namespace's value: a JSON object, opaque to the hub. */
|
|
27128
|
-
var PreferenceValueSchema = zod.z.record(zod.z.string(), zod.z.unknown());
|
|
27129
|
-
var PreferenceDeviceIdSchema = zod.z.string().min(1).max(64);
|
|
27130
|
-
/** A stored row, as the owner reads it. */
|
|
27131
|
-
var PreferenceRowSchema = zod.z.object({
|
|
27132
|
-
namespace: PreferenceNamespaceSchema,
|
|
27133
|
-
value: PreferenceValueSchema,
|
|
27134
|
-
/** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
|
|
27135
|
-
revision: zod.z.number().int().positive(),
|
|
27136
|
-
updatedAt: zod.z.number().int(),
|
|
27137
|
-
/** The client id the last writer sent; `null` when it sent none. */
|
|
27138
|
-
updatedByDevice: PreferenceDeviceIdSchema.nullable()
|
|
27139
|
-
});
|
|
27140
|
-
zod.z.object({
|
|
27141
|
-
/** Absent: every namespace the caller holds. */
|
|
27142
|
-
namespaces: zod.z.array(PreferenceNamespaceSchema).max(32).optional() });
|
|
27143
|
-
zod.z.object({ rows: zod.z.array(PreferenceRowSchema) });
|
|
27144
|
-
zod.z.object({
|
|
27145
|
-
namespace: PreferenceNamespaceSchema,
|
|
27146
|
-
value: PreferenceValueSchema,
|
|
27147
|
-
/**
|
|
27148
|
-
* The revision the edit was based on. Absent: last write wins. `0`: the
|
|
27149
|
-
* namespace must not exist yet. Any other value that is not the current
|
|
27150
|
-
* revision answers `conflict` and writes nothing.
|
|
27151
|
-
*/
|
|
27152
|
-
baseRevision: zod.z.number().int().nonnegative().optional(),
|
|
27153
|
-
deviceId: PreferenceDeviceIdSchema.optional()
|
|
27154
|
-
});
|
|
27155
|
-
zod.z.discriminatedUnion("status", [zod.z.object({
|
|
27156
|
-
status: zod.z.literal("saved"),
|
|
27157
|
-
row: PreferenceRowSchema
|
|
27158
|
-
}), zod.z.object({
|
|
27159
|
-
status: zod.z.literal("conflict"),
|
|
27160
|
-
current: PreferenceRowSchema.nullable()
|
|
27161
|
-
})]);
|
|
27162
|
-
zod.z.object({ namespace: PreferenceNamespaceSchema });
|
|
27163
|
-
zod.z.object({
|
|
27164
|
-
/** `false` when the namespace did not exist. */
|
|
27165
|
-
deleted: zod.z.boolean() });
|
|
27166
|
-
zod.z.object({
|
|
27167
|
-
/** The revision the client holds per namespace; a namespace it does not list is new to it. */
|
|
27168
|
-
revisionByNamespace: zod.z.record(PreferenceNamespaceSchema, zod.z.number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
|
|
27169
|
-
zod.z.object({
|
|
27170
|
-
/** Every row whose revision differs from the client's, and every row it did not list. */
|
|
27171
|
-
rows: zod.z.array(PreferenceRowSchema),
|
|
27172
|
-
/** Namespaces the client listed that no longer exist. */
|
|
27173
|
-
deleted: zod.z.array(PreferenceNamespaceSchema)
|
|
27174
|
-
});
|
|
27175
|
-
zod.z.enum(["new-session", "step-up"]);
|
|
27176
|
-
/** The languages the hub's app landing pages are written in (D858). */
|
|
27177
|
-
var AppPageLangSchema = zod.z.enum(["en", "it"]);
|
|
27178
|
-
/** How a native app starts one login method (D858), as `auth.listLoginMethods` reports it. */
|
|
27179
|
-
var AppLoginPathSchema = zod.z.discriminatedUnion("kind", [zod.z.object({ kind: zod.z.literal("native") }), zod.z.object({
|
|
27180
|
-
kind: zod.z.literal("browser"),
|
|
27181
|
-
startPath: zod.z.string().startsWith("/")
|
|
27182
|
-
})]);
|
|
27183
|
-
/**
|
|
27184
|
-
* Device certificates (D855) — the wire contract shared by the hub, the admin
|
|
27185
|
-
* UI and the native viewer.
|
|
27186
|
-
*
|
|
27187
|
-
* A device (a phone) generates its OWN P-256 key pair in hardware (Secure
|
|
27188
|
-
* Enclave / Android Keystore / a non-extractable WebCrypto key). The private
|
|
27189
|
-
* key never travels. The hub signs the PUBLIC key into an X.509 leaf under a
|
|
27190
|
-
* dedicated device CA; the device later proves possession of the key by
|
|
27191
|
-
* signing a hub-issued nonce, and the hub answers with the same session a
|
|
27192
|
-
* password login opens.
|
|
27193
|
-
*
|
|
27194
|
-
* Everything on the wire is a small string (a PEM, a base64url signature):
|
|
27195
|
-
* D613 is about bulk bytes, and a certificate is ~600 bytes.
|
|
27196
|
-
*/
|
|
27197
|
-
/** Signature algorithm of every device credential: ECDSA, curve P-256, SHA-256. */
|
|
27198
|
-
var DEVICE_CERT_SIGNATURE = "ecdsa-p256-sha256";
|
|
27199
|
-
/** First line of every signed message; a change of format bumps the version. */
|
|
27200
|
-
var DEVICE_SIGNATURE_MESSAGE_VERSION = "camstack-device-cert-v1";
|
|
27201
|
-
zod.z.enum([
|
|
27202
|
-
"login",
|
|
27203
|
-
"renew",
|
|
27204
|
-
"revoke"
|
|
27205
|
-
]);
|
|
27206
|
-
/** One-shot enrollment code and login nonce lifetimes. */
|
|
27207
|
-
var DEVICE_ENROLLMENT_TTL_MS = 10 * 6e4;
|
|
27208
|
-
var DEVICE_NONCE_TTL_MS = 6e4;
|
|
27209
|
-
/** SAN URI prefixes of a device leaf. */
|
|
27210
|
-
var DEVICE_SAN_CREDENTIAL_PREFIX = "camstack:credential:";
|
|
27211
|
-
var DEVICE_SAN_USER_PREFIX = "camstack:user:";
|
|
27212
|
-
/**
|
|
27213
|
-
* The exact bytes a device signs (UTF-8, `\n` separators, no trailing newline):
|
|
27214
|
-
*
|
|
27215
|
-
* camstack-device-cert-v1
|
|
27216
|
-
* <login|renew>
|
|
27217
|
-
* <origin> the hub origin returned by `getDeviceChallenge`
|
|
27218
|
-
* <nonce>
|
|
27219
|
-
*
|
|
27220
|
-
* The origin is part of the message so a signature collected by a look-alike
|
|
27221
|
-
* hub is worthless on the real one; the hub additionally binds the nonce to
|
|
27222
|
-
* the origin it issued it for and refuses any other.
|
|
27223
|
-
*/
|
|
27224
|
-
function buildDeviceSignatureMessage(input) {
|
|
27225
|
-
return [
|
|
27226
|
-
DEVICE_SIGNATURE_MESSAGE_VERSION,
|
|
27227
|
-
input.purpose,
|
|
27228
|
-
input.origin,
|
|
27229
|
-
input.nonce
|
|
27230
|
-
].join("\n");
|
|
27231
|
-
}
|
|
27232
|
-
/** The deep link a QR carries: `camstack://enroll?hub=<origin>&code=<code>`. */
|
|
27233
|
-
function buildDeviceEnrollmentLink(input) {
|
|
27234
|
-
const query = new URLSearchParams();
|
|
27235
|
-
if (input.hub !== void 0) query.set("hub", input.hub);
|
|
27236
|
-
query.set("code", input.code);
|
|
27237
|
-
return `${input.scheme ?? "camstack"}://enroll?${query.toString()}`;
|
|
27238
|
-
}
|
|
27239
|
-
var DevicePlatformSchema = zod.z.enum([
|
|
27240
|
-
"ios",
|
|
27241
|
-
"android",
|
|
27242
|
-
"web",
|
|
27243
|
-
"other"
|
|
27244
|
-
]);
|
|
27245
|
-
var Base64UrlSchema = zod.z.string().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/);
|
|
27246
|
-
var PemSchema = zod.z.string().min(1).max(16384);
|
|
27247
|
-
/**
|
|
27248
|
-
* Why a device-certificate endpoint said no. Distinct from a transport / 5xx
|
|
27249
|
-
* failure: those carry no reason and mean "try again", never "the credential is
|
|
27250
|
-
* dead". The viewer switches on this exhaustively.
|
|
27251
|
-
*/
|
|
27252
|
-
var DeviceRefusalReasonSchema = zod.z.enum([
|
|
27253
|
-
"revoked",
|
|
27254
|
-
"unknown-credential",
|
|
27255
|
-
"expired",
|
|
27256
|
-
"bad-signature",
|
|
27257
|
-
"nonce-invalid",
|
|
27258
|
-
"rate-limited",
|
|
27259
|
-
"invalid-certificate",
|
|
27260
|
-
"superseded",
|
|
27261
|
-
"user-gone",
|
|
27262
|
-
"unavailable",
|
|
27263
|
-
"code-invalid",
|
|
27264
|
-
"self-enrollment-disabled",
|
|
27265
|
-
"step-up-required",
|
|
27266
|
-
"bad-public-key"
|
|
27267
|
-
]);
|
|
27268
|
-
var DeviceRefusalSchema = zod.z.object({
|
|
27269
|
-
ok: zod.z.literal(false),
|
|
27270
|
-
reason: DeviceRefusalReasonSchema,
|
|
27271
|
-
definitive: zod.z.boolean(),
|
|
27272
|
-
retryAfterSeconds: zod.z.number().optional()
|
|
27273
|
-
});
|
|
27274
|
-
zod.z.object({
|
|
27275
|
-
code: zod.z.string().min(1).max(256),
|
|
27276
|
-
/** SubjectPublicKeyInfo DER of the device's P-256 public key, base64url. */
|
|
27277
|
-
publicKeySpki: Base64UrlSchema,
|
|
27278
|
-
deviceName: zod.z.string().min(1).max(80).optional(),
|
|
27279
|
-
platform: DevicePlatformSchema
|
|
27280
|
-
});
|
|
27281
|
-
var CompleteEnrollmentOutputSchema = zod.z.object({
|
|
27282
|
-
credentialId: zod.z.string(),
|
|
27283
|
-
certPem: PemSchema,
|
|
27284
|
-
/** The device CA certificate the leaf chains to. */
|
|
27285
|
-
chainPem: PemSchema,
|
|
27286
|
-
notAfter: zod.z.number(),
|
|
27287
|
-
user: zod.z.object({
|
|
27288
|
-
id: zod.z.string(),
|
|
27289
|
-
username: zod.z.string()
|
|
27290
|
-
})
|
|
27291
|
-
});
|
|
27292
|
-
zod.z.discriminatedUnion("ok", [CompleteEnrollmentOutputSchema.extend({ ok: zod.z.literal(true) }), DeviceRefusalSchema]);
|
|
27293
|
-
zod.z.object({
|
|
27294
|
-
/** The single-use step-up proof (`auth.deviceEnrollProofFrom…`). */
|
|
27295
|
-
proof: zod.z.string().min(1).max(512),
|
|
27296
|
-
publicKeySpki: Base64UrlSchema,
|
|
27297
|
-
deviceName: zod.z.string().min(1).max(80),
|
|
27298
|
-
platform: DevicePlatformSchema
|
|
27299
|
-
});
|
|
27300
|
-
zod.z.object({
|
|
27301
|
-
proof: zod.z.string(),
|
|
27302
|
-
expiresAt: zod.z.number()
|
|
27303
|
-
});
|
|
27304
|
-
var DeviceChallengeSchema = zod.z.object({
|
|
27305
|
-
nonce: zod.z.string(),
|
|
27306
|
-
/** The origin to put in the signed message. The app compares it to the hub it dialled. */
|
|
27307
|
-
origin: zod.z.string(),
|
|
27308
|
-
expiresAt: zod.z.number(),
|
|
27309
|
-
signature: zod.z.literal(DEVICE_CERT_SIGNATURE)
|
|
27310
|
-
});
|
|
27311
|
-
zod.z.discriminatedUnion("ok", [DeviceChallengeSchema.extend({ ok: zod.z.literal(true) }), DeviceRefusalSchema]);
|
|
27312
|
-
zod.z.object({
|
|
27313
|
-
certPem: PemSchema,
|
|
27314
|
-
nonce: zod.z.string().min(1).max(256),
|
|
27315
|
-
/** ECDSA P-256 SHA-256 over {@link buildDeviceSignatureMessage}; raw r||s or DER, base64url. */
|
|
27316
|
-
signature: Base64UrlSchema
|
|
27317
|
-
});
|
|
27318
|
-
var RenewDeviceCertificateOutputSchema = zod.z.object({
|
|
27319
|
-
credentialId: zod.z.string(),
|
|
27320
|
-
certPem: PemSchema,
|
|
27321
|
-
chainPem: PemSchema,
|
|
27322
|
-
notAfter: zod.z.number()
|
|
27323
|
-
});
|
|
27324
|
-
zod.z.discriminatedUnion("ok", [RenewDeviceCertificateOutputSchema.extend({ ok: zod.z.literal(true) }), DeviceRefusalSchema]);
|
|
27325
|
-
zod.z.discriminatedUnion("ok", [zod.z.object({
|
|
27326
|
-
ok: zod.z.literal(true),
|
|
27327
|
-
credentialId: zod.z.string(),
|
|
27328
|
-
sessionsEnded: zod.z.number().int()
|
|
27329
|
-
}), DeviceRefusalSchema]);
|
|
27330
|
-
function formatDeviceRevoker(revoker) {
|
|
27331
|
-
return revoker.kind === "device" ? "device" : `${revoker.kind}:${revoker.userId}`;
|
|
27332
|
-
}
|
|
27333
|
-
var DeviceCredentialStatusSchema = zod.z.enum([
|
|
27334
|
-
"active",
|
|
27335
|
-
"expired",
|
|
27336
|
-
"revoked"
|
|
27337
|
-
]);
|
|
27338
|
-
var DeviceCredentialSchema = zod.z.object({
|
|
27339
|
-
id: zod.z.string(),
|
|
27340
|
-
userId: zod.z.string(),
|
|
27341
|
-
username: zod.z.string().nullable(),
|
|
27342
|
-
deviceName: zod.z.string(),
|
|
27343
|
-
platform: DevicePlatformSchema,
|
|
27344
|
-
enrolledVia: zod.z.enum(["qr", "self"]),
|
|
27345
|
-
/** SHA-256 of the leaf certificate DER, colon-hex. */
|
|
27346
|
-
fingerprint: zod.z.string(),
|
|
27347
|
-
issuedAt: zod.z.number(),
|
|
27348
|
-
expiresAt: zod.z.number(),
|
|
27349
|
-
lastUsedAt: zod.z.number().nullable(),
|
|
27350
|
-
lastUsedFrom: zod.z.string().nullable(),
|
|
27351
|
-
revokedAt: zod.z.number().nullable(),
|
|
27352
|
-
/** `admin:<userId>` | `user:<userId>` | `device` | `user-deleted`. */
|
|
27353
|
-
revokedBy: zod.z.string().nullable(),
|
|
27354
|
-
status: DeviceCredentialStatusSchema
|
|
27355
|
-
});
|
|
27356
|
-
var StartEnrollmentOutputSchema = zod.z.object({
|
|
27357
|
-
/** Shown once; only its hash is kept. */
|
|
27358
|
-
code: zod.z.string(),
|
|
27359
|
-
expiresAt: zod.z.number(),
|
|
27360
|
-
/** `camstack://enroll?hub=…&code=…` — what the QR encodes. */
|
|
27361
|
-
enrollUrl: zod.z.string(),
|
|
27362
|
-
/** The hub origin in the link, or `null` when the hub could not name one (the link then has no `hub`). */
|
|
27363
|
-
hubOrigin: zod.z.string().nullable(),
|
|
27364
|
-
/** Every origin the apps may try (role `appConnections`). */
|
|
27365
|
-
hubOrigins: zod.z.array(zod.z.string())
|
|
27366
|
-
});
|
|
27367
|
-
zod.z.object({
|
|
27368
|
-
kind: zod.z.literal("device-certificate"),
|
|
27369
|
-
id: zod.z.literal("device-certificate"),
|
|
27370
|
-
label: zod.z.string(),
|
|
27371
|
-
stage: zod.z.literal("primary"),
|
|
27372
|
-
/** tRPC paths under the hub's `auth` router, so a client names no literal. */
|
|
27373
|
-
challengePath: zod.z.literal("auth.getDeviceChallenge"),
|
|
27374
|
-
revokePath: zod.z.literal("auth.revokeOwnDeviceCertificate"),
|
|
27375
|
-
enrollSelfPath: zod.z.literal("auth.enrollSelf"),
|
|
27376
|
-
loginPath: zod.z.literal("auth.loginWithDeviceCertificate"),
|
|
27377
|
-
renewPath: zod.z.literal("auth.renewDeviceCertificate"),
|
|
27378
|
-
signature: zod.z.literal(DEVICE_CERT_SIGNATURE),
|
|
27379
|
-
messageVersion: zod.z.literal(DEVICE_SIGNATURE_MESSAGE_VERSION),
|
|
27380
|
-
/** Which clients can execute it: a native app silently, a browser with a non-extractable WebCrypto key. */
|
|
27381
|
-
clients: zod.z.array(zod.z.enum(["native", "web"])),
|
|
27382
|
-
/** The app executes it itself, silently (D858). */
|
|
27383
|
-
app: AppLoginPathSchema.nullable()
|
|
27384
|
-
});
|
|
27385
26609
|
/** Lucide category ids, alphabetical. `ICON_META` indexes into this. */
|
|
27386
26610
|
var ICON_CATEGORY_IDS = [
|
|
27387
26611
|
"accessibility",
|
|
@@ -47195,93 +46419,1229 @@ var ICON_SYNONYMS = {
|
|
|
47195
46419
|
]
|
|
47196
46420
|
};
|
|
47197
46421
|
/**
|
|
47198
|
-
* Spellings an operator may already have PERSISTED that no lucide package
|
|
47199
|
-
* accepts any more, and the catalog key they draw. They resolve
|
|
47200
|
-
* (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
|
|
47201
|
-
* pre-catalog spelling of `gauge`.
|
|
46422
|
+
* Spellings an operator may already have PERSISTED that no lucide package
|
|
46423
|
+
* accepts any more, and the catalog key they draw. They resolve
|
|
46424
|
+
* (`canonicalIconKey`) but are never offered. `gauge2` was this repo's own
|
|
46425
|
+
* pre-catalog spelling of `gauge`.
|
|
46426
|
+
*/
|
|
46427
|
+
var LEGACY_ICON_ALIASES = { gauge2: "gauge" };
|
|
46428
|
+
/**
|
|
46429
|
+
* icon-catalog — THE icon vocabulary (D854).
|
|
46430
|
+
*
|
|
46431
|
+
* Every place that picks or stores an icon — a device's display override, a
|
|
46432
|
+
* location, a site zone, a viewer accessory, an `icon` settings field — names
|
|
46433
|
+
* it by a key of this catalog and nothing else. There is no curated subset and
|
|
46434
|
+
* no second list: the catalog is every lucide icon that both surfaces can draw
|
|
46435
|
+
* (the admin UI's `lucide-react` and the viewer's `lucide-react-native`), the
|
|
46436
|
+
* intersection computed by `scripts/generate-icon-catalog.ts` into the
|
|
46437
|
+
* committed `icon-catalog.generated.ts`.
|
|
46438
|
+
*
|
|
46439
|
+
* Like the vocabularies it replaces, this module holds STRINGS only — no React,
|
|
46440
|
+
* no lucide import, no glyph. Each surface owns its glyph table (the web one
|
|
46441
|
+
* lives in `ui-library`, loaded lazily), and a test on each side pins that it
|
|
46442
|
+
* covers {@link ICON_KEYS}.
|
|
46443
|
+
*
|
|
46444
|
+
* ## What is persisted
|
|
46445
|
+
*
|
|
46446
|
+
* The canonical kebab-case lucide id ({@link IconKey}). Spellings that a lucide
|
|
46447
|
+
* package still accepts (`home` for `house`) and this repo's own legacy ones
|
|
46448
|
+
* (`gauge2`) RESOLVE ({@link canonicalIconKey}) so a stored value never goes
|
|
46449
|
+
* stale, but they are never OFFERED by search.
|
|
46450
|
+
*
|
|
46451
|
+
* ## Search
|
|
46452
|
+
*
|
|
46453
|
+
* Over the key, the Italian/English overlay in `icon-synonyms.ts`, any words
|
|
46454
|
+
* the caller adds, and lucide's English tags — in that order of weight.
|
|
46455
|
+
*/
|
|
46456
|
+
var KEY_SET$2 = new Set(ICON_KEYS);
|
|
46457
|
+
var ALIAS_TO_KEY = new Map([...Object.entries(ICON_ALIASES), ...Object.entries(LEGACY_ICON_ALIASES)]);
|
|
46458
|
+
/** Is this a canonical key of the catalog? (An alias is not — see {@link canonicalIconKey}.) */
|
|
46459
|
+
function isIconKey(value) {
|
|
46460
|
+
return typeof value === "string" && KEY_SET$2.has(value);
|
|
46461
|
+
}
|
|
46462
|
+
/**
|
|
46463
|
+
* A stored value as a catalog key: the key itself, the key a still-accepted or
|
|
46464
|
+
* legacy spelling stands for, or `undefined` — never a guess.
|
|
46465
|
+
*/
|
|
46466
|
+
function canonicalIconKey(value) {
|
|
46467
|
+
if (typeof value !== "string") return void 0;
|
|
46468
|
+
if (isIconKey(value)) return value;
|
|
46469
|
+
return ALIAS_TO_KEY.get(value);
|
|
46470
|
+
}
|
|
46471
|
+
/**
|
|
46472
|
+
* Wire/storage schema for one icon key.
|
|
46473
|
+
*
|
|
46474
|
+
* Deliberately NOT a `z.enum` of the catalog: ~1,700 literals would be inlined
|
|
46475
|
+
* into every cap router, type and API-reference row that carries an icon. The
|
|
46476
|
+
* check is membership in the catalog and the type is {@link IconKey}.
|
|
46477
|
+
*/
|
|
46478
|
+
var IconKeySchema = zod.z.custom(isIconKey, "Not an icon of the catalog");
|
|
46479
|
+
var ENTRIES = ICON_KEYS.map((key, index) => {
|
|
46480
|
+
const [categoryIndexes, tags] = ICON_META[index] ?? [[], []];
|
|
46481
|
+
const categories = categoryIndexes.flatMap((i) => {
|
|
46482
|
+
const id = ICON_CATEGORY_IDS[i];
|
|
46483
|
+
return id === void 0 ? [] : [id];
|
|
46484
|
+
});
|
|
46485
|
+
return {
|
|
46486
|
+
key,
|
|
46487
|
+
categories,
|
|
46488
|
+
primaryCategory: categories[0] ?? ICON_CATEGORY_IDS[0],
|
|
46489
|
+
tags,
|
|
46490
|
+
synonyms: ICON_SYNONYMS[key] ?? []
|
|
46491
|
+
};
|
|
46492
|
+
});
|
|
46493
|
+
new Map(ENTRIES.map((e) => [e.key, e]));
|
|
46494
|
+
/** Categories a picker offers first: the ones this product's icons mostly live in. */
|
|
46495
|
+
var LEADING_CATEGORIES = [
|
|
46496
|
+
"devices",
|
|
46497
|
+
"home",
|
|
46498
|
+
"security",
|
|
46499
|
+
"buildings",
|
|
46500
|
+
"connectivity",
|
|
46501
|
+
"multimedia",
|
|
46502
|
+
"nature",
|
|
46503
|
+
"weather",
|
|
46504
|
+
"transportation",
|
|
46505
|
+
"animals"
|
|
46506
|
+
];
|
|
46507
|
+
var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
|
|
46508
|
+
[...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
|
|
46509
|
+
/** One tag name: trimmed, 1..40 characters. */
|
|
46510
|
+
var TagNameSchema = zod.z.string().trim().min(1).max(40);
|
|
46511
|
+
/** The `tags` field every owner record carries. Absent = no tags. */
|
|
46512
|
+
var TagsFieldSchema = zod.z.array(TagNameSchema).max(20);
|
|
46513
|
+
/** Fixed tag palette ids (map to `--color-tag-*` theme tokens, never a hex). */
|
|
46514
|
+
var TAG_COLOR_IDS = [
|
|
46515
|
+
"tag-a",
|
|
46516
|
+
"tag-b",
|
|
46517
|
+
"tag-c",
|
|
46518
|
+
"tag-d",
|
|
46519
|
+
"tag-e",
|
|
46520
|
+
"tag-f",
|
|
46521
|
+
"tag-g",
|
|
46522
|
+
"tag-h"
|
|
46523
|
+
];
|
|
46524
|
+
var TagColorIdSchema = zod.z.enum(TAG_COLOR_IDS);
|
|
46525
|
+
var TagStyleSchema = zod.z.object({
|
|
46526
|
+
name: TagNameSchema,
|
|
46527
|
+
color: TagColorIdSchema,
|
|
46528
|
+
icon: IconKeySchema
|
|
46529
|
+
});
|
|
46530
|
+
/** The comparison key of a tag: trimmed and lower-cased. */
|
|
46531
|
+
function tagKey(name) {
|
|
46532
|
+
return name.trim().toLowerCase();
|
|
46533
|
+
}
|
|
46534
|
+
/** Two tag names are the same tag. */
|
|
46535
|
+
function sameTag(a, b) {
|
|
46536
|
+
return tagKey(a) === tagKey(b);
|
|
46537
|
+
}
|
|
46538
|
+
/** Stable FNV-1a hash of the tag key → one palette slot. */
|
|
46539
|
+
function hashTagKey(key) {
|
|
46540
|
+
let h = 2166136261;
|
|
46541
|
+
for (let i = 0; i < key.length; i++) {
|
|
46542
|
+
h ^= key.charCodeAt(i);
|
|
46543
|
+
h = Math.imul(h, 16777619);
|
|
46544
|
+
}
|
|
46545
|
+
return h >>> 0;
|
|
46546
|
+
}
|
|
46547
|
+
/** The colour a tag shows until the operator styles it (same name → same colour, case-insensitively). */
|
|
46548
|
+
function defaultTagColorId(name) {
|
|
46549
|
+
const id = TAG_COLOR_IDS[hashTagKey(tagKey(name)) % TAG_COLOR_IDS.length];
|
|
46550
|
+
if (id !== void 0) return id;
|
|
46551
|
+
return "tag-a";
|
|
46552
|
+
}
|
|
46553
|
+
/** Trim, drop empty, dedupe case-insensitively keeping the first spelling. */
|
|
46554
|
+
function normalizeTags(tags) {
|
|
46555
|
+
const seen = /* @__PURE__ */ new Set();
|
|
46556
|
+
const out = [];
|
|
46557
|
+
for (const raw of tags) {
|
|
46558
|
+
const name = raw.trim();
|
|
46559
|
+
if (name.length === 0) continue;
|
|
46560
|
+
const key = tagKey(name);
|
|
46561
|
+
if (seen.has(key)) continue;
|
|
46562
|
+
seen.add(key);
|
|
46563
|
+
out.push(name);
|
|
46564
|
+
}
|
|
46565
|
+
return out;
|
|
46566
|
+
}
|
|
46567
|
+
/** `tags` with every spelling of `from` replaced by `to` (deduped), or `null` when it did not carry `from`. */
|
|
46568
|
+
function renameInTags(tags, from, to) {
|
|
46569
|
+
if (!tags.some((t) => sameTag(t, from))) return null;
|
|
46570
|
+
return normalizeTags(tags.map((t) => sameTag(t, from) ? to : t));
|
|
46571
|
+
}
|
|
46572
|
+
/** `tags` without `name`, or `null` when it did not carry it. */
|
|
46573
|
+
function removeFromTags(tags, name) {
|
|
46574
|
+
if (!tags.some((t) => sameTag(t, name))) return null;
|
|
46575
|
+
return tags.filter((t) => !sameTag(t, name));
|
|
46576
|
+
}
|
|
46577
|
+
var ClipModelMetaSchema = zod.z.object({
|
|
46578
|
+
/** The paired text encoder's catalog id (the embedding-encoder's text catalog). */
|
|
46579
|
+
textModelId: zod.z.string().min(1),
|
|
46580
|
+
/** Output dimension of BOTH towers. A vector of any other length is refused. */
|
|
46581
|
+
embeddingDim: zod.z.number().int().positive(),
|
|
46582
|
+
/**
|
|
46583
|
+
* The `vector-store` index this model's vectors live in. ONE feature space
|
|
46584
|
+
* per index: two models share an index only when their vectors are ranked
|
|
46585
|
+
* against each other, which for CLIP means never across families. Every
|
|
46586
|
+
* model gets its own.
|
|
46587
|
+
*/
|
|
46588
|
+
vectorIndex: zod.z.string().regex(/^object-clip-[a-z0-9][a-z0-9-]*$/),
|
|
46589
|
+
/**
|
|
46590
|
+
* The text encoder's tokenizer, a declared SIBLING file of its onnx. The name
|
|
46591
|
+
* must be unique per tokenizer: every model's siblings land in ONE flat
|
|
46592
|
+
* models directory, so two different tokenizers under the same name would
|
|
46593
|
+
* silently overwrite each other (whichever model downloaded last wins, and
|
|
46594
|
+
* the other one tokenises with the wrong vocabulary).
|
|
46595
|
+
*/
|
|
46596
|
+
tokenizerFile: zod.z.string().min(1),
|
|
46597
|
+
/** Token window the text graph takes (SigLIP2: 64; CLIP BPE: 77). */
|
|
46598
|
+
contextLength: zod.z.number().int().positive(),
|
|
46599
|
+
/** Id the tokenizer pads with. */
|
|
46600
|
+
padId: zod.z.number().int().nonnegative(),
|
|
46601
|
+
/**
|
|
46602
|
+
* The search cosine floor at `strictness: 'loose'` — calibrated per model,
|
|
46603
|
+
* because cosine bands are a property of the model: 0.2 keeps 96% of matched
|
|
46604
|
+
* COCO caption-image pairs on MobileCLIP S1 and 2.7% on SigLIP2.
|
|
46605
|
+
*/
|
|
46606
|
+
searchMinScore: zod.z.number().min(0).max(1)
|
|
46607
|
+
});
|
|
46608
|
+
var ClipSearchStrictnessSchema = zod.z.enum([
|
|
46609
|
+
"loose",
|
|
46610
|
+
"balanced",
|
|
46611
|
+
"strict"
|
|
46612
|
+
]);
|
|
46613
|
+
/** Steps whose effect a root label can BE. */
|
|
46614
|
+
var LABEL_SUPPLY_STEP_IDS = [
|
|
46615
|
+
"animal-classifier",
|
|
46616
|
+
"vehicle-classifier",
|
|
46617
|
+
"package-detection"
|
|
46618
|
+
];
|
|
46619
|
+
/** Steps whose box a root detection can BE. */
|
|
46620
|
+
var CROP_SUPPLY_STEP_IDS = ["plate-detection", "face-detection"];
|
|
46621
|
+
/**
|
|
46622
|
+
* Steps whose per-detection MASK a root detection can carry (D737). The live
|
|
46623
|
+
* mask step is `segmentation` — a frame-plane refiner that runs its own model
|
|
46624
|
+
* once per detection crop. (`instance-segmentation` is a dormant step id that
|
|
46625
|
+
* no camera tree carries.)
|
|
46626
|
+
*/
|
|
46627
|
+
var MASK_SUPPLY_STEP_IDS = ["segmentation"];
|
|
46628
|
+
[
|
|
46629
|
+
...LABEL_SUPPLY_STEP_IDS,
|
|
46630
|
+
...CROP_SUPPLY_STEP_IDS,
|
|
46631
|
+
...MASK_SUPPLY_STEP_IDS
|
|
46632
|
+
];
|
|
46633
|
+
/**
|
|
46634
|
+
* Multi-file format payload.
|
|
46635
|
+
*
|
|
46636
|
+
* - Directory formats (`isDirectory: true`, e.g. `.mlpackage`): files
|
|
46637
|
+
* relative to the directory root — the downloader fetches each from
|
|
46638
|
+
* `{url}/{file}` into `{modelDir}/{file}`. If omitted, it probes the
|
|
46639
|
+
* HuggingFace API (slower).
|
|
46640
|
+
* - Single-file formats (no `isDirectory`, e.g. OpenVINO IR): sibling
|
|
46641
|
+
* files fetched from the SAME remote directory as `url` and stored flat
|
|
46642
|
+
* alongside the main file — e.g. `['camstack-yolov9t.bin']` for the IR
|
|
46643
|
+
* weights next to `camstack-yolov9t.xml`.
|
|
46644
|
+
*/
|
|
46645
|
+
var ModelFormatEntrySchema = zod.z.object({
|
|
46646
|
+
url: zod.z.string(),
|
|
46647
|
+
sizeMB: zod.z.number(),
|
|
46648
|
+
/** Whether this format is a directory bundle (e.g., .mlpackage) rather than a single file */
|
|
46649
|
+
isDirectory: zod.z.boolean().optional(),
|
|
46650
|
+
/** Multi-file payload (directory members or sibling files). */
|
|
46651
|
+
files: zod.z.array(zod.z.string()).readonly().optional(),
|
|
46652
|
+
/** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
|
|
46653
|
+
runtimes: zod.z.array(zod.z.enum(["python"])).readonly().optional(),
|
|
46654
|
+
/**
|
|
46655
|
+
* Content revision of the artefact, for one hosted OFF the CamStack mirror.
|
|
46656
|
+
* A format on the mirror leaves it unset: its revision (the sha256 of its
|
|
46657
|
+
* weight file) comes from the downloader's generated table, kept in step
|
|
46658
|
+
* with the mirror by `scripts/check-hosted-model-revisions.ts` (D744). A
|
|
46659
|
+
* node records the revision it downloaded next to the file
|
|
46660
|
+
* (`<file>.revision`); a copy with no record or a different one is stale
|
|
46661
|
+
* unless its weight file hashes to the revision, and a stale copy is
|
|
46662
|
+
* downloaded again, the old one serving until the new one is complete. No
|
|
46663
|
+
* revision at all ⇒ a file on disk is current, whatever it holds (D743).
|
|
46664
|
+
*/
|
|
46665
|
+
revision: zod.z.string().min(1).optional()
|
|
46666
|
+
});
|
|
46667
|
+
/**
|
|
46668
|
+
* What a node holds for one (model, format) (D746). `current` is a complete
|
|
46669
|
+
* copy at its catalog revision — exactly what `downloaded: true` means.
|
|
46670
|
+
* `stale` is bytes on disk that are not (yet) proven current under D743/D744:
|
|
46671
|
+
* no or a different revision record, or a missing sibling. `missing` is no
|
|
46672
|
+
* copy. `downloaded` alone folds `stale` into "not downloaded", which hid
|
|
46673
|
+
* reclaimable bytes and a copy about to be replaced.
|
|
46674
|
+
*/
|
|
46675
|
+
var ModelOnDiskStateSchema = zod.z.enum([
|
|
46676
|
+
"current",
|
|
46677
|
+
"stale",
|
|
46678
|
+
"missing"
|
|
46679
|
+
]);
|
|
46680
|
+
/**
|
|
46681
|
+
* The numeric precision of one format's BUILD (D746) — reported only when the
|
|
46682
|
+
* build states it (file-name token, an INT8 variant, an EdgeTPU compile, a
|
|
46683
|
+
* CamStack Core ML export). Absent means "not stated", never "fp32".
|
|
46684
|
+
*/
|
|
46685
|
+
var ModelFormatPrecisionSchema = zod.z.enum([
|
|
46686
|
+
"fp32",
|
|
46687
|
+
"fp16",
|
|
46688
|
+
"int8"
|
|
46689
|
+
]);
|
|
46690
|
+
/**
|
|
46691
|
+
* One format of one model as a node's `pipelineExecutor.getSchema` reports it.
|
|
46692
|
+
* `onDisk` / `precision` are optional for version skew: a runner that predates
|
|
46693
|
+
* them omits them, and a reader falls back to `downloaded`.
|
|
46694
|
+
*/
|
|
46695
|
+
var PipelineModelFormatStatusSchema = zod.z.object({
|
|
46696
|
+
downloaded: zod.z.boolean(),
|
|
46697
|
+
sizeMB: zod.z.number(),
|
|
46698
|
+
onDisk: ModelOnDiskStateSchema.optional(),
|
|
46699
|
+
precision: ModelFormatPrecisionSchema.optional()
|
|
46700
|
+
});
|
|
46701
|
+
/**
|
|
46702
|
+
* Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
|
|
46703
|
+
* The downloader fetches from `url` and saves to `{modelsDir}/{filename}`.
|
|
46704
|
+
*/
|
|
46705
|
+
var ModelExtraFileSchema = zod.z.object({
|
|
46706
|
+
url: zod.z.string(),
|
|
46707
|
+
filename: zod.z.string(),
|
|
46708
|
+
sizeMB: zod.z.number()
|
|
46709
|
+
});
|
|
46710
|
+
/**
|
|
46711
|
+
* Per-format payload map. Modelled as an explicit object (one optional key
|
|
46712
|
+
* per `ModelFormat`) rather than `z.record(enum, …)` — zod v4's enum-keyed
|
|
46713
|
+
* record requires every key, but a catalog entry only ships a subset of
|
|
46714
|
+
* formats.
|
|
46715
|
+
*/
|
|
46716
|
+
var ModelFormatsSchema = zod.z.object({
|
|
46717
|
+
onnx: ModelFormatEntrySchema.optional(),
|
|
46718
|
+
coreml: ModelFormatEntrySchema.optional(),
|
|
46719
|
+
openvino: ModelFormatEntrySchema.optional(),
|
|
46720
|
+
tflite: ModelFormatEntrySchema.optional(),
|
|
46721
|
+
pt: ModelFormatEntrySchema.optional(),
|
|
46722
|
+
gguf: ModelFormatEntrySchema.optional()
|
|
46723
|
+
});
|
|
46724
|
+
/**
|
|
46725
|
+
* Variant-selector grouping axes. Shared by the full `ModelCatalogEntry` and by
|
|
46726
|
+
* the reduced `PipelineModelOption` returned in `pipeline.getSchema()` so the
|
|
46727
|
+
* grouped Family→Tier→Variant picker renders identically in the config UI and
|
|
46728
|
+
* in the pipeline/device steppers. The flat `id` stays the source of truth for
|
|
46729
|
+
* resolution/download/persistence; this is a presentation overlay resolved back
|
|
46730
|
+
* to an `id`.
|
|
46731
|
+
*/
|
|
46732
|
+
var ModelVariantGroupSchema = zod.z.object({
|
|
46733
|
+
/** Top-level family, e.g. `yolo26` (later `d-fine`, `rf-detr`). */
|
|
46734
|
+
family: zod.z.string(),
|
|
46735
|
+
/** Size within the family, e.g. `n` | `s` | `m` | `l`. */
|
|
46736
|
+
tier: zod.z.string(),
|
|
46737
|
+
/** Quantization axis. Omit ⇒ the fp32 base build. */
|
|
46738
|
+
precision: zod.z.enum(["fp32", "int8"]).optional(),
|
|
46739
|
+
/**
|
|
46740
|
+
* Training / latency-variant axis. Omit ⇒ the standard build. `test` marks
|
|
46741
|
+
* an alternate training of the same family (plugin catalog `relu_test`); chip
|
|
46742
|
+
* label is "Test".
|
|
46743
|
+
*/
|
|
46744
|
+
optimization: zod.z.enum(["standard", "test"]).optional(),
|
|
46745
|
+
/**
|
|
46746
|
+
* Input-resolution axis (square input side, px). Omit ⇒ the family's native
|
|
46747
|
+
* resolution (640 for yolo26). Reduced-input builds (320 / 256) are a big,
|
|
46748
|
+
* cheap latency lever — especially on Apple ANE and the Intel N100 — at a
|
|
46749
|
+
* small-object accuracy cost. Mirrors the model's `inputSize` but lifted onto
|
|
46750
|
+
* the group so the selector can offer it as a variant axis.
|
|
46751
|
+
*/
|
|
46752
|
+
resolution: zod.z.number().int().positive().optional()
|
|
46753
|
+
});
|
|
46754
|
+
var ModelProviderIdSchema = zod.z.enum([
|
|
46755
|
+
"camstack",
|
|
46756
|
+
"frigate",
|
|
46757
|
+
"scrypted",
|
|
46758
|
+
"custom"
|
|
46759
|
+
]);
|
|
46760
|
+
var ModelLicenseRecordSchema = zod.z.object({
|
|
46761
|
+
/** SPDX id of the WEIGHTS' terms, a `LicenseRef-*` for non-SPDX terms, or `UNKNOWN`. */
|
|
46762
|
+
weights: zod.z.string().min(1),
|
|
46763
|
+
/** SPDX id of the upstream code that defines / trained the network. */
|
|
46764
|
+
code: zod.z.string().min(1).optional(),
|
|
46765
|
+
/** Training data whose terms add obligations (attribution, non-commercial). */
|
|
46766
|
+
data: zod.z.object({
|
|
46767
|
+
name: zod.z.string().min(1),
|
|
46768
|
+
terms: zod.z.string().min(1),
|
|
46769
|
+
url: zod.z.string().url().optional()
|
|
46770
|
+
}).optional(),
|
|
46771
|
+
/** The project the weights come from. Required on built-in entries (guard). */
|
|
46772
|
+
upstream: zod.z.object({
|
|
46773
|
+
name: zod.z.string().min(1),
|
|
46774
|
+
url: zod.z.string().url()
|
|
46775
|
+
}).optional(),
|
|
46776
|
+
/** Where the licence text governing the weights is published. */
|
|
46777
|
+
url: zod.z.string().url().optional(),
|
|
46778
|
+
/** Attribution the licence REQUIRES, verbatim. */
|
|
46779
|
+
attribution: zod.z.string().min(1).optional(),
|
|
46780
|
+
/** What CamStack changed. Required when `hosting` is `camstack-hf` (guard). */
|
|
46781
|
+
modifications: zod.z.string().min(1).optional(),
|
|
46782
|
+
/** Who serves the file a node downloads. */
|
|
46783
|
+
hosting: zod.z.enum([
|
|
46784
|
+
"camstack-hf",
|
|
46785
|
+
"third-party",
|
|
46786
|
+
"built-in"
|
|
46787
|
+
]).optional(),
|
|
46788
|
+
/** True when the weights or their data forbid commercial use. */
|
|
46789
|
+
nonCommercial: zod.z.boolean().optional()
|
|
46790
|
+
});
|
|
46791
|
+
/**
|
|
46792
|
+
* The licence of a model, as a record rather than a bare SPDX string: a
|
|
46793
|
+
* permissive CODE licence routinely sits on top of restrictive WEIGHTS or
|
|
46794
|
+
* DATA, and the obligations (attribution, modification notices, source offers)
|
|
46795
|
+
* are per upstream. A persisted custom-model row written when this field was a
|
|
46796
|
+
* string still parses — the string is lifted into `{ weights }`.
|
|
46797
|
+
*
|
|
46798
|
+
* Every machine licence surface (`THIRD_PARTY_MODELS.md`, the Hugging Face
|
|
46799
|
+
* model table) is GENERATED from these records by
|
|
46800
|
+
* `scripts/gen-model-licenses.ts` (D661). Operator-facing docs live in
|
|
46801
|
+
* `camstack/docs` → `/docs/detection/models`.
|
|
47202
46802
|
*/
|
|
47203
|
-
var
|
|
46803
|
+
var ModelLicenseSchema = zod.z.preprocess((value) => typeof value === "string" ? { weights: value } : value, ModelLicenseRecordSchema);
|
|
47204
46804
|
/**
|
|
47205
|
-
*
|
|
46805
|
+
* One step a ROOT detector can supply from its own output (D730) — see
|
|
46806
|
+
* `ModelCatalogEntry.suppliesSteps`.
|
|
47206
46807
|
*
|
|
47207
|
-
*
|
|
47208
|
-
*
|
|
47209
|
-
*
|
|
47210
|
-
*
|
|
47211
|
-
*
|
|
47212
|
-
*
|
|
47213
|
-
*
|
|
46808
|
+
* - `label`: the root's raw class IS the step's answer. `labelToEffect` maps
|
|
46809
|
+
* the root's label to the step's vocabulary; `uncovered` is the vocabulary
|
|
46810
|
+
* the root cannot produce (shown as unavailable, never a blocker).
|
|
46811
|
+
* - `crop`: the root draws the box the step would have found (`license_plate`
|
|
46812
|
+
* for plate-detection, `face` for face-detection). The box becomes a detail
|
|
46813
|
+
* child of the `parentMacro` detection that contains it — never a track.
|
|
46814
|
+
* - `mask`: the root's decode emits an instance mask with every detection (a
|
|
46815
|
+
* YOLO26-seg root, D737) — the `segmentation` step's result, carried on the
|
|
46816
|
+
* detection in the shape that step produces. Derived from the model's
|
|
46817
|
+
* postprocessor on read, never stored by an import.
|
|
46818
|
+
*/
|
|
46819
|
+
var RootStepSupplySchema = zod.z.discriminatedUnion("kind", [
|
|
46820
|
+
zod.z.object({
|
|
46821
|
+
kind: zod.z.literal("label"),
|
|
46822
|
+
stepId: zod.z.enum(LABEL_SUPPLY_STEP_IDS),
|
|
46823
|
+
labelToEffect: zod.z.record(zod.z.string(), zod.z.string()),
|
|
46824
|
+
uncovered: zod.z.array(zod.z.string()).readonly()
|
|
46825
|
+
}),
|
|
46826
|
+
zod.z.object({
|
|
46827
|
+
kind: zod.z.literal("crop"),
|
|
46828
|
+
stepId: zod.z.enum(CROP_SUPPLY_STEP_IDS),
|
|
46829
|
+
rootLabels: zod.z.array(zod.z.string()).readonly(),
|
|
46830
|
+
parentMacro: zod.z.enum(["vehicle", "person"]),
|
|
46831
|
+
childClass: zod.z.enum(["plate", "face"]),
|
|
46832
|
+
/**
|
|
46833
|
+
* The root's smaller input side, stamped on read by `rootSuppliesOf` from
|
|
46834
|
+
* the model entry — what a step's `minRootInputPx` gate judges. Never
|
|
46835
|
+
* stored by an import.
|
|
46836
|
+
*/
|
|
46837
|
+
rootInputPx: zod.z.number().int().positive().optional()
|
|
46838
|
+
}),
|
|
46839
|
+
zod.z.object({
|
|
46840
|
+
kind: zod.z.literal("mask"),
|
|
46841
|
+
stepId: zod.z.enum(MASK_SUPPLY_STEP_IDS)
|
|
46842
|
+
})
|
|
46843
|
+
]);
|
|
46844
|
+
var ModelCatalogEntrySchema = zod.z.object({
|
|
46845
|
+
id: zod.z.string(),
|
|
46846
|
+
name: zod.z.string(),
|
|
46847
|
+
description: zod.z.string(),
|
|
46848
|
+
formats: ModelFormatsSchema,
|
|
46849
|
+
inputSize: zod.z.object({
|
|
46850
|
+
width: zod.z.number(),
|
|
46851
|
+
height: zod.z.number()
|
|
46852
|
+
}),
|
|
46853
|
+
/**
|
|
46854
|
+
* Channel count of the model input tensor. Omit ⇒ 3 (RGB), the default for
|
|
46855
|
+
* every detector / classifier / embedder. Set to 1 for a grayscale CTC text
|
|
46856
|
+
* recognizer (EasyOCR VGG plate-OCR: input `[N,1,H,W]`) so the preprocess
|
|
46857
|
+
* feeds a single-channel, EasyOCR-normalized tensor instead of the default
|
|
46858
|
+
* 3-channel RGB one. Threaded through `PoolModelConfig.inputChannels` to the
|
|
46859
|
+
* Python inference pool.
|
|
46860
|
+
*/
|
|
46861
|
+
inputChannels: zod.z.number().int().positive().optional(),
|
|
46862
|
+
labels: zod.z.array(LabelDefinitionSchema).readonly(),
|
|
46863
|
+
inputLayout: zod.z.enum(["nchw", "nhwc"]).optional(),
|
|
46864
|
+
/**
|
|
46865
|
+
* `'scrfd'` applies InsightFace's SCRFD input contract, `(x - 127.5) / 128`
|
|
46866
|
+
* (upstream `insightface/model_zoo/scrfd.py`), instead of the historical
|
|
46867
|
+
* plain `/255`. Measured against COCO GT: 188 → 196 faces found on the
|
|
46868
|
+
* `scrfd-2.5g` catalog entry (2026-09-26 model-replacement spike, §2.4-2).
|
|
46869
|
+
*/
|
|
46870
|
+
inputNormalization: zod.z.enum([
|
|
46871
|
+
"zero-one",
|
|
46872
|
+
"imagenet",
|
|
46873
|
+
"none",
|
|
46874
|
+
"scrfd"
|
|
46875
|
+
]).optional(),
|
|
46876
|
+
/**
|
|
46877
|
+
* The model already applies softmax IN-GRAPH — its raw output is a
|
|
46878
|
+
* probability distribution, not logits. When set, the `softmax`
|
|
46879
|
+
* postprocessor must NOT re-apply softmax: re-softmaxing an already-normalised
|
|
46880
|
+
* probability vector collapses it toward uniform (top-1 score craters far
|
|
46881
|
+
* below its true value, making every confidence gate meaningless). Absent ⇒
|
|
46882
|
+
* the output is raw logits and the postprocessor applies softmax (the normal
|
|
46883
|
+
* case). Set on the Google AIY Birds `bird-classifier` (softmax baked into the
|
|
46884
|
+
* TF graph). Threaded to the Python pool via `PoolModelConfig.outputProbabilities`.
|
|
46885
|
+
*/
|
|
46886
|
+
outputProbabilities: zod.z.boolean().optional(),
|
|
46887
|
+
preprocessMode: zod.z.enum(["letterbox", "resize"]).optional(),
|
|
46888
|
+
/**
|
|
46889
|
+
* Per-MODEL postprocessor override. Absent ⇒ the step's own
|
|
46890
|
+
* `StepDefinition.postprocessor` applies (the normal case — every model in a
|
|
46891
|
+
* step shares its decode). Set it when a step hosts models with DIFFERENT raw
|
|
46892
|
+
* output layouts under one slot: e.g. object-detection is `'yolo'` by default,
|
|
46893
|
+
* but a Coral SSD MobileNet build emits the `TFLite_Detection_PostProcess`
|
|
46894
|
+
* 4-tensor layout and needs `'ssd'`. Threaded into `PoolModelConfig.postprocessor`
|
|
46895
|
+
* by the engine factory (`modelEntry.postprocessor ?? def.postprocessor`).
|
|
46896
|
+
*/
|
|
46897
|
+
postprocessor: zod.z.custom().optional(),
|
|
46898
|
+
/**
|
|
46899
|
+
* Per-MODEL default confidence floor. Absent ⇒ the step's
|
|
46900
|
+
* `StepDefinition.defaultConfidence` applies. A score is a property of one
|
|
46901
|
+
* model's output scale, not of the step slot it sits in: YuNet's
|
|
46902
|
+
* `sqrt(cls·obj)` is not SCRFD's score, and inheriting SCRFD's 0.5 filled the
|
|
46903
|
+
* face gallery with wheels and hands (D662, amends D645). An operator's
|
|
46904
|
+
* explicit value still wins over it. Resolved in ONE place —
|
|
46905
|
+
* `addon-pipeline/.../registry/effective-confidence.ts`.
|
|
46906
|
+
*/
|
|
46907
|
+
defaultConfidence: zod.z.number().min(0).max(1).optional(),
|
|
46908
|
+
/**
|
|
46909
|
+
* Per-MODEL default of the per-class confidence floors (`minConfidence<Macro>`
|
|
46910
|
+
* on a detector step), keyed by macro class: `{ person: 0.45 }`. A class
|
|
46911
|
+
* absent here runs at the step slider's global default. The same row shape
|
|
46912
|
+
* the floor measurement produces (`model-floors.json`: modelId → floors), so
|
|
46913
|
+
* a measured table is copied in as-is. An operator override is bound to the
|
|
46914
|
+
* model it was made for and does not survive a model change (D738). A custom
|
|
46915
|
+
* / imported model may declare it; without it, the global defaults apply.
|
|
46916
|
+
*/
|
|
46917
|
+
defaultClassFloors: zod.z.record(zod.z.string(), zod.z.number().min(0).max(1)).optional(),
|
|
46918
|
+
/**
|
|
46919
|
+
* The inference precision this model's OpenVINO IR needs on an Intel GPU.
|
|
46920
|
+
* Absent ⇒ the device default (f16 on a GPU). Set to `'f32'` for an FP32 IR
|
|
46921
|
+
* that produces invalid output at f16 — measured 2026-10-07 for YOLO26
|
|
46922
|
+
* base IRs (`yolo26s`: 0 true / 146 false positives; `yolo26m*`: NaN
|
|
46923
|
+
* scores) on the Core Ultra iGPU and the N100. Threaded to the pool as
|
|
46924
|
+
* `PoolModelConfig.gpuInferencePrecision`; the pool sets
|
|
46925
|
+
* INFERENCE_PRECISION_HINT on a GPU only. Costs ~60% latency on the GPU.
|
|
46926
|
+
*/
|
|
46927
|
+
gpuInferencePrecision: zod.z.enum(["f32", "f16"]).optional(),
|
|
46928
|
+
/**
|
|
46929
|
+
* ROOT detectors only: per supplied step (`animal-classifier`, …), the
|
|
46930
|
+
* minimum DETECTION score from which this root's own fine label (species,
|
|
46931
|
+
* vehicle type — D736 root supply) is taken (D741). Below it the detection
|
|
46932
|
+
* keeps its macro class without the fine label. `1` = never take it from
|
|
46933
|
+
* this root. Absent ⇒ no floor beyond the macro floor. The supplied step's
|
|
46934
|
+
* `minConfidence` slider, bound to the ROOT model, overrides it.
|
|
46935
|
+
*/
|
|
46936
|
+
suppliedLabelFloors: zod.z.record(zod.z.string(), zod.z.number().min(0).max(1)).optional(),
|
|
46937
|
+
/**
|
|
46938
|
+
* When true, the executor produces a landmark-aligned crop (similarity warp
|
|
46939
|
+
* onto the canonical template) before this step runs, instead of a plain
|
|
46940
|
+
* axis-aligned bbox crop. Required for face-recognition embedders (ArcFace):
|
|
46941
|
+
* their embeddings are only discriminative on an aligned input. The face
|
|
46942
|
+
* detector that produced the parent detail must emit 5 landmarks.
|
|
46943
|
+
*/
|
|
46944
|
+
faceAlignment: zod.z.boolean().optional(),
|
|
46945
|
+
/**
|
|
46946
|
+
* Auxiliary files required at runtime (labels JSON, charset dict, etc.).
|
|
46947
|
+
* Downloaded into the same modelsDir alongside the model file.
|
|
46948
|
+
*/
|
|
46949
|
+
extraFiles: zod.z.array(ModelExtraFileSchema).readonly().optional(),
|
|
46950
|
+
/**
|
|
46951
|
+
* LEGACY entry — retained in the catalog so a persisted operator selection
|
|
46952
|
+
* still RESOLVES (and can be re-activated), but hidden from the selectable
|
|
46953
|
+
* model list and excluded from the auto format-default pick. Set on the
|
|
46954
|
+
* superseded / consolidated models (older lineages, redundant fp16 IRs) so
|
|
46955
|
+
* the active lineup stays the coherent curated ladder without deleting a
|
|
46956
|
+
* model anyone may still be pinned to. `resolveModelForFormat` keeps honoring
|
|
46957
|
+
* an explicit legacy id that has a build for the node's format.
|
|
46958
|
+
*/
|
|
46959
|
+
legacy: zod.z.boolean().optional(),
|
|
46960
|
+
/**
|
|
46961
|
+
* Measured quality/latency metadata — populated from the benchmark addon on
|
|
46962
|
+
* the real node classes. Absent = not yet measured (most entries today; the
|
|
46963
|
+
* catalog historically carried only `sizeMB`, a poor cross-architecture
|
|
46964
|
+
* speed proxy). `p95LatencyMs` is keyed by node class (e.g. `n100`, `mac`).
|
|
46965
|
+
*/
|
|
46966
|
+
metrics: zod.z.object({
|
|
46967
|
+
map50: zod.z.number().optional(),
|
|
46968
|
+
p95LatencyMs: zod.z.record(zod.z.string(), zod.z.number()).optional()
|
|
46969
|
+
}).optional(),
|
|
46970
|
+
/**
|
|
46971
|
+
* The model's licence record — see {@link ModelLicenseSchema}. Optional in
|
|
46972
|
+
* the schema (a custom model's author may state none); REQUIRED and complete
|
|
46973
|
+
* on every built-in catalog entry (`scripts/check-catalog-licence.ts`).
|
|
46974
|
+
*/
|
|
46975
|
+
license: ModelLicenseSchema.optional(),
|
|
46976
|
+
/**
|
|
46977
|
+
* Variant-selector grouping. The UI groups models by `family` + `tier` and
|
|
46978
|
+
* offers `precision` / `optimization` as variant axes WITHIN a tier — so all
|
|
46979
|
+
* of a family's sizes and quantizations collapse into one grouped picker
|
|
46980
|
+
* instead of a flat list of `yolo26s`, `yolo26s-int8`, … Absent ⇒ ungrouped
|
|
46981
|
+
* (legacy / custom models) — never shown in the grouped selector. The flat
|
|
46982
|
+
* `id` stays the source of truth for resolution/download/persistence; grouping
|
|
46983
|
+
* is a presentation overlay resolved back to an `id`.
|
|
46984
|
+
*/
|
|
46985
|
+
group: ModelVariantGroupSchema.optional(),
|
|
46986
|
+
/**
|
|
46987
|
+
* Catalog source for the pipeline stepper's provider-first picker. Absent on
|
|
46988
|
+
* built-in CamStack entries (treated as `camstack`) and on registry rows
|
|
46989
|
+
* persisted before this field existed (`inferModelProvider` fills those).
|
|
46990
|
+
*/
|
|
46991
|
+
provider: ModelProviderIdSchema.optional(),
|
|
46992
|
+
/**
|
|
46993
|
+
* Per-MODEL class map override. Absent ⇒ the step's `StepDefinition.classMap`
|
|
46994
|
+
* applies (plus catalog / COCO public catalog). Set on a custom model whose raw
|
|
46995
|
+
* labels already ARE the CamStack macros (plugin catalog identity map).
|
|
46996
|
+
*/
|
|
46997
|
+
classMap: DetectionCatalogClassMapSchema.optional(),
|
|
46998
|
+
/**
|
|
46999
|
+
* The pipeline steps this ROOT detector can supply from its own output
|
|
47000
|
+
* (D730): its labels name a step's effect (`deer` for `animal-classifier`)
|
|
47001
|
+
* or draw a step's box (`license_plate` for `plate-detection`). Computed at
|
|
47002
|
+
* import from THIS model's labelmap by `deriveRootSupplies`, never written
|
|
47003
|
+
* by hand and never assumed per family; a row without it is derived on read
|
|
47004
|
+
* (`rootSuppliesOf`). Whether a camera uses it is the step's own
|
|
47005
|
+
* `useRootModel` flag (`resolveRootSupply`).
|
|
47006
|
+
*/
|
|
47007
|
+
suppliesSteps: zod.z.array(RootStepSupplySchema).readonly().optional(),
|
|
47008
|
+
/**
|
|
47009
|
+
* The model's CLIP feature-space contract (text encoder, dimension, vector
|
|
47010
|
+
* index, token window, search floor) — see `clip-model.ts`. Present ONLY on a
|
|
47011
|
+
* CLIP image encoder; its absence is what "not a CLIP model" means to the
|
|
47012
|
+
* embedding encoder and the semantic-search store (D649).
|
|
47013
|
+
*/
|
|
47014
|
+
clip: ClipModelMetaSchema.optional()
|
|
47015
|
+
});
|
|
47016
|
+
var ConvertTargetSchema = zod.z.discriminatedUnion("format", [zod.z.object({
|
|
47017
|
+
format: zod.z.literal("openvino"),
|
|
47018
|
+
precisions: zod.z.array(zod.z.enum(["fp16", "int8"])).min(1).readonly()
|
|
47019
|
+
}), zod.z.object({ format: zod.z.literal("coreml") })]);
|
|
47020
|
+
var ModelConvertMetadataSchema = zod.z.object({
|
|
47021
|
+
id: zod.z.string().regex(/^[a-zA-Z0-9._-]+$/),
|
|
47022
|
+
name: zod.z.string(),
|
|
47023
|
+
labels: zod.z.array(LabelDefinitionSchema).readonly(),
|
|
47024
|
+
inputSize: zod.z.object({
|
|
47025
|
+
width: zod.z.number(),
|
|
47026
|
+
height: zod.z.number()
|
|
47027
|
+
}),
|
|
47028
|
+
inputLayout: zod.z.enum(["nchw", "nhwc"]).optional(),
|
|
47029
|
+
inputNormalization: zod.z.enum([
|
|
47030
|
+
"zero-one",
|
|
47031
|
+
"imagenet",
|
|
47032
|
+
"none",
|
|
47033
|
+
"scrfd"
|
|
47034
|
+
]).optional(),
|
|
47035
|
+
preprocessMode: zod.z.enum(["letterbox", "resize"]).optional(),
|
|
47036
|
+
outputFormat: zod.z.enum([
|
|
47037
|
+
"yolo",
|
|
47038
|
+
"ssd",
|
|
47039
|
+
"embedding",
|
|
47040
|
+
"classification",
|
|
47041
|
+
"ocr",
|
|
47042
|
+
"segmentation"
|
|
47043
|
+
]),
|
|
47044
|
+
faceAlignment: zod.z.boolean().optional(),
|
|
47045
|
+
classMap: DetectionCatalogClassMapSchema.optional()
|
|
47046
|
+
});
|
|
47047
|
+
var ConvertArtifactSchema = zod.z.object({
|
|
47048
|
+
format: zod.z.enum(MODEL_FORMATS),
|
|
47049
|
+
precision: zod.z.enum(["fp16", "int8"]).optional(),
|
|
47050
|
+
sizeMB: zod.z.number(),
|
|
47051
|
+
validated: zod.z.boolean(),
|
|
47052
|
+
files: zod.z.array(zod.z.string()).readonly()
|
|
47053
|
+
});
|
|
47054
|
+
var ConvertResultSchema = zod.z.object({
|
|
47055
|
+
entry: ModelCatalogEntrySchema,
|
|
47056
|
+
artifacts: zod.z.array(ConvertArtifactSchema).readonly()
|
|
47057
|
+
});
|
|
47058
|
+
/**
|
|
47059
|
+
* True if the scope set grants `access` on device-scoped capabilities.
|
|
47060
|
+
* A `category:device` grant covers every device cap (the broad grant).
|
|
47061
|
+
*/
|
|
47062
|
+
function scopesAllowDeviceCap(scopes, access) {
|
|
47063
|
+
return scopes.some((s) => s.type === "category" && s.target === "device" && s.access.includes(access));
|
|
47064
|
+
}
|
|
47065
|
+
/**
|
|
47066
|
+
* True if the scope set names this addon with at least `access`.
|
|
47214
47067
|
*
|
|
47215
|
-
*
|
|
47216
|
-
*
|
|
47217
|
-
*
|
|
47218
|
-
*
|
|
47068
|
+
* Deliberately NOT satisfied by `category:device`: a grant over per-camera
|
|
47069
|
+
* capabilities says nothing about an addon's own HTTP surface, and conflating
|
|
47070
|
+
* the two is precisely the confusion that let an Alexa token drive Home
|
|
47071
|
+
* Assistant's command route.
|
|
47072
|
+
*/
|
|
47073
|
+
function scopesAllowAddon(scopes, addonId, access) {
|
|
47074
|
+
return scopes.some((s) => s.type === "addon" && s.target === addonId && s.access.includes(access));
|
|
47075
|
+
}
|
|
47076
|
+
var ViewerFeatureIdSchema = zod.z.enum([
|
|
47077
|
+
"face-assignment",
|
|
47078
|
+
"plate-assignment",
|
|
47079
|
+
"retrain",
|
|
47080
|
+
"scenes"
|
|
47081
|
+
]);
|
|
47082
|
+
/** Which devices a viewer reaches: `allow` minus `block`. */
|
|
47083
|
+
var ViewerDeviceAllowSchema = zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.number().int().nonnegative())]);
|
|
47084
|
+
/**
|
|
47085
|
+
* The viewer grant, stored as ONE row of a user's `scopes`. A principal that
|
|
47086
|
+
* holds it is decided by the viewer rules ALONE — any other row it carries is
|
|
47087
|
+
* ignored, so a viewer can never be widened by a leftover grant.
|
|
47088
|
+
*/
|
|
47089
|
+
var ViewerTokenScopeSchema = zod.z.object({
|
|
47090
|
+
type: zod.z.literal("viewer"),
|
|
47091
|
+
allow: ViewerDeviceAllowSchema,
|
|
47092
|
+
block: zod.z.array(zod.z.number().int().nonnegative()),
|
|
47093
|
+
features: zod.z.array(ViewerFeatureIdSchema)
|
|
47094
|
+
});
|
|
47095
|
+
/**
|
|
47096
|
+
* Zod schemas for persisted record types.
|
|
47219
47097
|
*
|
|
47220
|
-
*
|
|
47098
|
+
* These schemas serve as the single source of truth for types that are
|
|
47099
|
+
* stored in the settings-store backend and retrieved via tRPC. They
|
|
47100
|
+
* replace the manual TypeScript interfaces with schema-derived types,
|
|
47101
|
+
* enabling runtime validation when reading from the backend.
|
|
47221
47102
|
*
|
|
47222
|
-
*
|
|
47223
|
-
*
|
|
47224
|
-
|
|
47225
|
-
|
|
47103
|
+
* Convention: each schema is named `<Type>Schema`, the inferred TS type
|
|
47104
|
+
* keeps the original name for backward compatibility.
|
|
47105
|
+
*/
|
|
47106
|
+
/**
|
|
47107
|
+
* Auth model (v2 — 2026-05-12 caps-only):
|
|
47226
47108
|
*
|
|
47227
|
-
*
|
|
47109
|
+
* Two principals:
|
|
47110
|
+
* - `isAdmin: true` — full bypass. Admin scope set is ignored.
|
|
47111
|
+
* - `isAdmin: false` — every call gated by `scopes` (see TokenScope).
|
|
47228
47112
|
*
|
|
47229
|
-
*
|
|
47230
|
-
*
|
|
47113
|
+
* No role enum. There used to be `viewer / agent / scoped` and earlier
|
|
47114
|
+
* `super_admin` — collapsed onto the single boolean because every
|
|
47115
|
+
* non-admin caller is governed by the same scope-check rules; the
|
|
47116
|
+
* distinction was only ever used to route role-specific procedures
|
|
47117
|
+
* which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
|
|
47118
|
+
* with `isAdmin: false` + an explicit scope list.
|
|
47231
47119
|
*/
|
|
47232
|
-
|
|
47233
|
-
var
|
|
47234
|
-
|
|
47235
|
-
|
|
47236
|
-
|
|
47237
|
-
|
|
47120
|
+
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
47121
|
+
var MethodAccessSchema = zod.z.enum([
|
|
47122
|
+
"view",
|
|
47123
|
+
"create",
|
|
47124
|
+
"delete"
|
|
47125
|
+
]);
|
|
47238
47126
|
/**
|
|
47239
|
-
* A
|
|
47240
|
-
*
|
|
47127
|
+
* A single scope grant. Three forms — checked in matcher with OR
|
|
47128
|
+
* semantics; the first match decides whether the call passes:
|
|
47129
|
+
*
|
|
47130
|
+
* - `category` — broadest. `target: 'device' | 'system'` selects every
|
|
47131
|
+
* cap with the matching `scope` declaration. New caps inherit grants
|
|
47132
|
+
* automatically — adding a device cap to the codebase makes it
|
|
47133
|
+
* reachable to every user with `category:device [...]` without a
|
|
47134
|
+
* re-grant. Use this for "family viewer" / "operator" tiers.
|
|
47135
|
+
*
|
|
47136
|
+
* - `addon` — every cap that ships inside a given addon id. Niche;
|
|
47137
|
+
* useful when an integration needs to interact with one specific
|
|
47138
|
+
* addon's surface regardless of how many caps it exports.
|
|
47139
|
+
*
|
|
47140
|
+
* - `capability` — the most precise form. Single cap name. Use for
|
|
47141
|
+
* integration tokens where you want to grant `addons.installPackage`
|
|
47142
|
+
* and nothing else.
|
|
47143
|
+
*
|
|
47144
|
+
* `access` is REQUIRED with min 1 element. `admin` bypass is the
|
|
47145
|
+
* "give me everything" escape; there is no wildcard scope.
|
|
47241
47146
|
*/
|
|
47242
|
-
|
|
47243
|
-
|
|
47244
|
-
|
|
47245
|
-
return ALIAS_TO_KEY.get(value);
|
|
47246
|
-
}
|
|
47147
|
+
var AllowedProviderSchema = zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]);
|
|
47148
|
+
var AllowedDevicesSchema = zod.z.record(zod.z.string(), zod.z.union([zod.z.literal("*"), zod.z.array(zod.z.string())]));
|
|
47149
|
+
var CapScopeSchema = zod.z.enum(["device", "system"]);
|
|
47247
47150
|
/**
|
|
47248
|
-
*
|
|
47151
|
+
* DeviceSelector (scope model v3 — 2026-08-12).
|
|
47249
47152
|
*
|
|
47250
|
-
*
|
|
47251
|
-
*
|
|
47252
|
-
*
|
|
47153
|
+
* A `device` grant no longer carries a frozen list of deviceIds. It carries
|
|
47154
|
+
* a SELECTOR the matcher resolves against the live fleet, so the grant can be
|
|
47155
|
+
* DYNAMIC: a `types:['camera']` selector automatically covers a camera added
|
|
47156
|
+
* AFTER the grant was minted — no re-grant, no re-login.
|
|
47157
|
+
*
|
|
47158
|
+
* - `all` — every device in the deployment. The broad viewer/operator
|
|
47159
|
+
* lever without a `category` grant (a `category` grant also covers device
|
|
47160
|
+
* caps that carry no deviceId; `all` is specifically the device set).
|
|
47161
|
+
* - `ids` — an explicit deviceId list. This is what a v2 `device:[…]`
|
|
47162
|
+
* grant migrates to (see {@link TokenScopeSchema}); STATIC — a new camera
|
|
47163
|
+
* is NOT covered until the grant is edited.
|
|
47164
|
+
* - `types` — every device of a `DeviceType` (e.g. every `camera`).
|
|
47165
|
+
* DYNAMIC. A device that changes type, or a new device of the type,
|
|
47166
|
+
* re-resolves on the next request.
|
|
47167
|
+
* - `locations` — every device whose operator-assigned `location` label is
|
|
47168
|
+
* in the set (e.g. "Garden", "Front door"). DYNAMIC. A device with a
|
|
47169
|
+
* null/unset location matches NO `locations` selector.
|
|
47253
47170
|
*/
|
|
47254
|
-
var
|
|
47255
|
-
|
|
47256
|
-
|
|
47257
|
-
|
|
47258
|
-
|
|
47259
|
-
|
|
47260
|
-
|
|
47171
|
+
var DeviceSelectorSchema = zod.z.discriminatedUnion("kind", [
|
|
47172
|
+
zod.z.object({ kind: zod.z.literal("all") }),
|
|
47173
|
+
zod.z.object({
|
|
47174
|
+
kind: zod.z.literal("ids"),
|
|
47175
|
+
ids: zod.z.array(zod.z.number().int()).min(1)
|
|
47176
|
+
}),
|
|
47177
|
+
zod.z.object({
|
|
47178
|
+
kind: zod.z.literal("types"),
|
|
47179
|
+
types: zod.z.array(zod.z.enum(DeviceType)).min(1)
|
|
47180
|
+
}),
|
|
47181
|
+
zod.z.object({
|
|
47182
|
+
kind: zod.z.literal("locations"),
|
|
47183
|
+
locations: zod.z.array(zod.z.string().min(1)).min(1)
|
|
47184
|
+
})
|
|
47185
|
+
]);
|
|
47186
|
+
var DeviceTokenScopeSchema = zod.z.object({
|
|
47187
|
+
type: zod.z.literal("device"),
|
|
47188
|
+
/** The device SET this grant covers — resolved against the live fleet. */
|
|
47189
|
+
selector: DeviceSelectorSchema,
|
|
47190
|
+
access: zod.z.array(MethodAccessSchema).min(1),
|
|
47191
|
+
/**
|
|
47192
|
+
* Whether a grant on a PARENT device transparently covers its accessory
|
|
47193
|
+
* CHILDREN (siren / floodlight / PIR) via the persisted-parentage walk.
|
|
47194
|
+
* Direction is parent → children ONLY.
|
|
47195
|
+
*
|
|
47196
|
+
* Absent → the matcher DERIVES it from the access flavour: `view`
|
|
47197
|
+
* inherits (a camera viewer sees the camera's accessories), `create` /
|
|
47198
|
+
* `delete` do NOT (actuating/removing a child is an explicit act the
|
|
47199
|
+
* operator must grant on the child, not inherit from the parent). Set it
|
|
47200
|
+
* explicitly to override that default per grant.
|
|
47201
|
+
*/
|
|
47202
|
+
includeLinked: zod.z.boolean().optional()
|
|
47203
|
+
});
|
|
47204
|
+
/**
|
|
47205
|
+
* v2 → v3 lazy migration. A pre-v3 `device` grant carried
|
|
47206
|
+
* `targets: string[]` (stringified deviceIds); it rewrites to the equivalent
|
|
47207
|
+
* `selector: {kind:'ids', ids}`. Applied as a `preprocess` so it runs on
|
|
47208
|
+
* EVERY parse path — stored records AND the JWT-carried scope arrays
|
|
47209
|
+
* normalised at the request boundary ({@link normalizeTokenScopes} in
|
|
47210
|
+
* `device-selector.ts`). Chosen over a one-time DB migration because a
|
|
47211
|
+
* migration cannot reach a JWT already in a client's hands; parse-time
|
|
47212
|
+
* migration covers both without a flag day. No cast — the raw object is read
|
|
47213
|
+
* through `Reflect.get` (its static type is `unknown`).
|
|
47214
|
+
*/
|
|
47215
|
+
function migrateLegacyTokenScope(raw) {
|
|
47216
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
47217
|
+
if (Reflect.get(raw, "type") !== "device") return raw;
|
|
47218
|
+
if (Reflect.get(raw, "selector") !== void 0) return canonicalSelectorTypes(raw);
|
|
47219
|
+
const targets = Reflect.get(raw, "targets");
|
|
47220
|
+
if (!Array.isArray(targets)) return raw;
|
|
47261
47221
|
return {
|
|
47262
|
-
|
|
47263
|
-
|
|
47264
|
-
|
|
47265
|
-
|
|
47266
|
-
|
|
47222
|
+
type: "device",
|
|
47223
|
+
selector: {
|
|
47224
|
+
kind: "ids",
|
|
47225
|
+
ids: targets.map((t) => typeof t === "string" ? Number(t) : t).filter((n) => typeof n === "number" && Number.isInteger(n))
|
|
47226
|
+
},
|
|
47227
|
+
access: Reflect.get(raw, "access")
|
|
47228
|
+
};
|
|
47229
|
+
}
|
|
47230
|
+
/**
|
|
47231
|
+
* A stored `types` selector may name a type D1033 retired (`thermostat`). The
|
|
47232
|
+
* grant is read back through this same preprocess, so the retired name is
|
|
47233
|
+
* rewritten to its canonical type here and {@link DeviceSelectorSchema} itself
|
|
47234
|
+
* stays a strict enum on the wire.
|
|
47235
|
+
*/
|
|
47236
|
+
function canonicalSelectorTypes(raw) {
|
|
47237
|
+
const selector = Reflect.get(raw, "selector");
|
|
47238
|
+
if (selector === null || typeof selector !== "object") return raw;
|
|
47239
|
+
if (Reflect.get(selector, "kind") !== "types") return raw;
|
|
47240
|
+
const types = Reflect.get(selector, "types");
|
|
47241
|
+
if (!Array.isArray(types)) return raw;
|
|
47242
|
+
const canonical = types.map((t) => typeof t === "string" ? canonicalStoredDeviceType(t) : t);
|
|
47243
|
+
return {
|
|
47244
|
+
...raw,
|
|
47245
|
+
selector: {
|
|
47246
|
+
...selector,
|
|
47247
|
+
types: canonical
|
|
47248
|
+
}
|
|
47267
47249
|
};
|
|
47250
|
+
}
|
|
47251
|
+
var TokenScopeSchema = zod.z.preprocess(migrateLegacyTokenScope, zod.z.discriminatedUnion("type", [
|
|
47252
|
+
zod.z.object({
|
|
47253
|
+
type: zod.z.literal("category"),
|
|
47254
|
+
target: CapScopeSchema,
|
|
47255
|
+
access: zod.z.array(MethodAccessSchema).min(1)
|
|
47256
|
+
}),
|
|
47257
|
+
zod.z.object({
|
|
47258
|
+
type: zod.z.literal("capability"),
|
|
47259
|
+
target: zod.z.string(),
|
|
47260
|
+
access: zod.z.array(MethodAccessSchema).min(1)
|
|
47261
|
+
}),
|
|
47262
|
+
zod.z.object({
|
|
47263
|
+
type: zod.z.literal("addon"),
|
|
47264
|
+
target: zod.z.string(),
|
|
47265
|
+
access: zod.z.array(MethodAccessSchema).min(1)
|
|
47266
|
+
}),
|
|
47267
|
+
DeviceTokenScopeSchema
|
|
47268
|
+
]));
|
|
47269
|
+
/**
|
|
47270
|
+
* What a PERSON's grant set holds (D921): the capability rows above (legacy
|
|
47271
|
+
* users, integration-style tokens) or the viewer row, which is decided by its
|
|
47272
|
+
* own rules alone. Kept apart from {@link TokenScope} so every surface that
|
|
47273
|
+
* edits capability rows (the scope picker, token minting) keeps its shape.
|
|
47274
|
+
*/
|
|
47275
|
+
var UserScopeSchema = zod.z.union([ViewerTokenScopeSchema, TokenScopeSchema]);
|
|
47276
|
+
var UserRecordSchema = zod.z.object({
|
|
47277
|
+
id: zod.z.string(),
|
|
47278
|
+
username: zod.z.string(),
|
|
47279
|
+
passwordHash: zod.z.string(),
|
|
47280
|
+
/**
|
|
47281
|
+
* Admin bypass. When true, the middleware skips the scope-access
|
|
47282
|
+
* check entirely. There is no other axis of privilege; the legacy
|
|
47283
|
+
* role enum collapsed onto this boolean in v2.
|
|
47284
|
+
*/
|
|
47285
|
+
isAdmin: zod.z.boolean().default(false),
|
|
47286
|
+
allowedProviders: AllowedProviderSchema,
|
|
47287
|
+
allowedDevices: AllowedDevicesSchema,
|
|
47288
|
+
/**
|
|
47289
|
+
* Scopes granted to this user. Admins bypass; their `scopes` is
|
|
47290
|
+
* ignored. Non-admins without scopes are locked out of every
|
|
47291
|
+
* protected call.
|
|
47292
|
+
*/
|
|
47293
|
+
scopes: zod.z.array(UserScopeSchema).default([]),
|
|
47294
|
+
createdAt: zod.z.number(),
|
|
47295
|
+
updatedAt: zod.z.number()
|
|
47296
|
+
});
|
|
47297
|
+
var ScopedTokenSchema = zod.z.object({
|
|
47298
|
+
id: zod.z.string(),
|
|
47299
|
+
userId: zod.z.string(),
|
|
47300
|
+
name: zod.z.string(),
|
|
47301
|
+
tokenHash: zod.z.string(),
|
|
47302
|
+
tokenPrefix: zod.z.string(),
|
|
47303
|
+
scopes: zod.z.array(TokenScopeSchema),
|
|
47304
|
+
expiresAt: zod.z.number().nullish(),
|
|
47305
|
+
lastUsedAt: zod.z.number().nullish(),
|
|
47306
|
+
createdAt: zod.z.number()
|
|
47307
|
+
});
|
|
47308
|
+
/** What a share-view grant lets its holder see. */
|
|
47309
|
+
var ShareViewGrantSchema = zod.z.object({
|
|
47310
|
+
kind: zod.z.enum(SHARE_VIEW_KINDS),
|
|
47311
|
+
deviceIds: zod.z.array(zod.z.number().int().nonnegative()).min(1).max(64),
|
|
47312
|
+
/** Talk-back, opt-in at mint time; absent means off. */
|
|
47313
|
+
talk: zod.z.boolean().optional()
|
|
47314
|
+
});
|
|
47315
|
+
var ShareViewScopeSchema = zod.z.object({
|
|
47316
|
+
type: zod.z.literal("share-view"),
|
|
47317
|
+
grant: ShareViewGrantSchema
|
|
47318
|
+
});
|
|
47319
|
+
var AddonRoutesScopeSchema = zod.z.object({
|
|
47320
|
+
type: zod.z.literal("addon-routes"),
|
|
47321
|
+
access: zod.z.array(MethodAccessSchema).min(1)
|
|
47322
|
+
});
|
|
47323
|
+
var PreferencesSelfScopeSchema = zod.z.object({ type: zod.z.literal("preferences-self") });
|
|
47324
|
+
var CredentialScopeSchema = zod.z.union([
|
|
47325
|
+
zod.z.literal("*"),
|
|
47326
|
+
ShareViewScopeSchema,
|
|
47327
|
+
AddonRoutesScopeSchema,
|
|
47328
|
+
PreferencesSelfScopeSchema,
|
|
47329
|
+
ViewerTokenScopeSchema,
|
|
47330
|
+
TokenScopeSchema
|
|
47331
|
+
]);
|
|
47332
|
+
/**
|
|
47333
|
+
* The `kind` claim of a unified token. It names the TOKEN FAMILY (so every
|
|
47334
|
+
* older gate that classifies a hub JWT refuses it — `classifyBearerPrincipal`
|
|
47335
|
+
* treats any `kind` it does not know as not-a-credential), never what the
|
|
47336
|
+
* token may do: that is its `scopes`, and only its `scopes`.
|
|
47337
|
+
*/
|
|
47338
|
+
var CREDENTIAL_TOKEN_KIND = "credential";
|
|
47339
|
+
/**
|
|
47340
|
+
* The `aud` claim every minted token is signed with (D895). The hub's raw JWT
|
|
47341
|
+
* verify (`AuthManager.verifyToken`, used by every surface that wants a LOGIN
|
|
47342
|
+
* session — the OAuth consent page, the session cookie, health, backups)
|
|
47343
|
+
* refuses a token carrying it, so a minted token — a share link above all —
|
|
47344
|
+
* can never be replayed as a person's session. Only the credential verifier's
|
|
47345
|
+
* own door (`verifyCredentialToken`) accepts it.
|
|
47346
|
+
*/
|
|
47347
|
+
var CREDENTIAL_TOKEN_AUDIENCE = "camstack:credential";
|
|
47348
|
+
/** Does a verified JWT payload belong to the minted-token family? */
|
|
47349
|
+
function isCredentialTokenPayload(payload) {
|
|
47350
|
+
if (payload === null || typeof payload !== "object") return false;
|
|
47351
|
+
const kind = Reflect.get(payload, "kind");
|
|
47352
|
+
const aud = Reflect.get(payload, "aud");
|
|
47353
|
+
return kind === "credential" || aud === "camstack:credential" || Array.isArray(aud) && aud.includes("camstack:credential");
|
|
47354
|
+
}
|
|
47355
|
+
/**
|
|
47356
|
+
* The claims of a unified token (`auth.mintToken`). It carries no `exp`: its
|
|
47357
|
+
* row (looked up by `jti` on every verify, for revocation) holds the ONE
|
|
47358
|
+
* expiry, so a share link can be extended and a JWT clock can never disagree
|
|
47359
|
+
* with the row.
|
|
47360
|
+
*/
|
|
47361
|
+
var CredentialTokenClaimsSchema = zod.z.object({
|
|
47362
|
+
kind: zod.z.literal(CREDENTIAL_TOKEN_KIND),
|
|
47363
|
+
sub: zod.z.string().min(1),
|
|
47364
|
+
jti: zod.z.string().min(16),
|
|
47365
|
+
scopes: zod.z.array(CredentialScopeSchema).min(1)
|
|
47366
|
+
});
|
|
47367
|
+
/**
|
|
47368
|
+
* Per-user ACCOUNT preferences (D894): the hub-side half of the viewer's two
|
|
47369
|
+
* settings levels.
|
|
47370
|
+
*
|
|
47371
|
+
* - DEVICE settings never leave the phone.
|
|
47372
|
+
* - ACCOUNT settings live here: one row per `(user, namespace)`, private to
|
|
47373
|
+
* that user, synced across every device signed in as them, last write wins
|
|
47374
|
+
* unless the writer sends the revision it based its edit on.
|
|
47375
|
+
*
|
|
47376
|
+
* A setting lives in exactly ONE level; there are no overrides. The caller
|
|
47377
|
+
* never names a user: the hub stamps the principal's own id, admin included.
|
|
47378
|
+
*
|
|
47379
|
+
* The contract the client codes against is the `preferences.*` tRPC router
|
|
47380
|
+
* (`server/backend/src/api/core/preferences.router.ts`).
|
|
47381
|
+
*/
|
|
47382
|
+
/** `viewer.app`, `viewer.cameras`, `viewer.grids` … — lowercase, dot/dash separated. */
|
|
47383
|
+
var PREFERENCES_NAMESPACE_PATTERN = /^[a-z][a-z0-9.-]{0,63}$/;
|
|
47384
|
+
/** One row's value, measured as UTF-8 JSON. */
|
|
47385
|
+
var PREFERENCES_MAX_VALUE_BYTES = 256 * 1024;
|
|
47386
|
+
var PreferenceNamespaceSchema = zod.z.string().regex(PREFERENCES_NAMESPACE_PATTERN);
|
|
47387
|
+
/** A namespace's value: a JSON object, opaque to the hub. */
|
|
47388
|
+
var PreferenceValueSchema = zod.z.record(zod.z.string(), zod.z.unknown());
|
|
47389
|
+
var PreferenceDeviceIdSchema = zod.z.string().min(1).max(64);
|
|
47390
|
+
/** A stored row, as the owner reads it. */
|
|
47391
|
+
var PreferenceRowSchema = zod.z.object({
|
|
47392
|
+
namespace: PreferenceNamespaceSchema,
|
|
47393
|
+
value: PreferenceValueSchema,
|
|
47394
|
+
/** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
|
|
47395
|
+
revision: zod.z.number().int().positive(),
|
|
47396
|
+
updatedAt: zod.z.number().int(),
|
|
47397
|
+
/** The client id the last writer sent; `null` when it sent none. */
|
|
47398
|
+
updatedByDevice: PreferenceDeviceIdSchema.nullable()
|
|
47399
|
+
});
|
|
47400
|
+
zod.z.object({
|
|
47401
|
+
/** Absent: every namespace the caller holds. */
|
|
47402
|
+
namespaces: zod.z.array(PreferenceNamespaceSchema).max(32).optional() });
|
|
47403
|
+
zod.z.object({ rows: zod.z.array(PreferenceRowSchema) });
|
|
47404
|
+
zod.z.object({
|
|
47405
|
+
namespace: PreferenceNamespaceSchema,
|
|
47406
|
+
value: PreferenceValueSchema,
|
|
47407
|
+
/**
|
|
47408
|
+
* The revision the edit was based on. Absent: last write wins. `0`: the
|
|
47409
|
+
* namespace must not exist yet. Any other value that is not the current
|
|
47410
|
+
* revision answers `conflict` and writes nothing.
|
|
47411
|
+
*/
|
|
47412
|
+
baseRevision: zod.z.number().int().nonnegative().optional(),
|
|
47413
|
+
deviceId: PreferenceDeviceIdSchema.optional()
|
|
47414
|
+
});
|
|
47415
|
+
zod.z.discriminatedUnion("status", [zod.z.object({
|
|
47416
|
+
status: zod.z.literal("saved"),
|
|
47417
|
+
row: PreferenceRowSchema
|
|
47418
|
+
}), zod.z.object({
|
|
47419
|
+
status: zod.z.literal("conflict"),
|
|
47420
|
+
current: PreferenceRowSchema.nullable()
|
|
47421
|
+
})]);
|
|
47422
|
+
zod.z.object({ namespace: PreferenceNamespaceSchema });
|
|
47423
|
+
zod.z.object({
|
|
47424
|
+
/** `false` when the namespace did not exist. */
|
|
47425
|
+
deleted: zod.z.boolean() });
|
|
47426
|
+
zod.z.object({
|
|
47427
|
+
/** The revision the client holds per namespace; a namespace it does not list is new to it. */
|
|
47428
|
+
revisionByNamespace: zod.z.record(PreferenceNamespaceSchema, zod.z.number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
|
|
47429
|
+
zod.z.object({
|
|
47430
|
+
/** Every row whose revision differs from the client's, and every row it did not list. */
|
|
47431
|
+
rows: zod.z.array(PreferenceRowSchema),
|
|
47432
|
+
/** Namespaces the client listed that no longer exist. */
|
|
47433
|
+
deleted: zod.z.array(PreferenceNamespaceSchema)
|
|
47434
|
+
});
|
|
47435
|
+
zod.z.enum(["new-session", "step-up"]);
|
|
47436
|
+
/** The languages the hub's app landing pages are written in (D858). */
|
|
47437
|
+
var AppPageLangSchema = zod.z.enum(["en", "it"]);
|
|
47438
|
+
/** How a native app starts one login method (D858), as `auth.listLoginMethods` reports it. */
|
|
47439
|
+
var AppLoginPathSchema = zod.z.discriminatedUnion("kind", [zod.z.object({ kind: zod.z.literal("native") }), zod.z.object({
|
|
47440
|
+
kind: zod.z.literal("browser"),
|
|
47441
|
+
startPath: zod.z.string().startsWith("/")
|
|
47442
|
+
})]);
|
|
47443
|
+
/**
|
|
47444
|
+
* Device certificates (D855) — the wire contract shared by the hub, the admin
|
|
47445
|
+
* UI and the native viewer.
|
|
47446
|
+
*
|
|
47447
|
+
* A device (a phone) generates its OWN P-256 key pair in hardware (Secure
|
|
47448
|
+
* Enclave / Android Keystore / a non-extractable WebCrypto key). The private
|
|
47449
|
+
* key never travels. The hub signs the PUBLIC key into an X.509 leaf under a
|
|
47450
|
+
* dedicated device CA; the device later proves possession of the key by
|
|
47451
|
+
* signing a hub-issued nonce, and the hub answers with the same session a
|
|
47452
|
+
* password login opens.
|
|
47453
|
+
*
|
|
47454
|
+
* Everything on the wire is a small string (a PEM, a base64url signature):
|
|
47455
|
+
* D613 is about bulk bytes, and a certificate is ~600 bytes.
|
|
47456
|
+
*/
|
|
47457
|
+
/** Signature algorithm of every device credential: ECDSA, curve P-256, SHA-256. */
|
|
47458
|
+
var DEVICE_CERT_SIGNATURE = "ecdsa-p256-sha256";
|
|
47459
|
+
/** First line of every signed message; a change of format bumps the version. */
|
|
47460
|
+
var DEVICE_SIGNATURE_MESSAGE_VERSION = "camstack-device-cert-v1";
|
|
47461
|
+
zod.z.enum([
|
|
47462
|
+
"login",
|
|
47463
|
+
"renew",
|
|
47464
|
+
"revoke"
|
|
47465
|
+
]);
|
|
47466
|
+
/** One-shot enrollment code and login nonce lifetimes. */
|
|
47467
|
+
var DEVICE_ENROLLMENT_TTL_MS = 10 * 6e4;
|
|
47468
|
+
var DEVICE_NONCE_TTL_MS = 6e4;
|
|
47469
|
+
/** SAN URI prefixes of a device leaf. */
|
|
47470
|
+
var DEVICE_SAN_CREDENTIAL_PREFIX = "camstack:credential:";
|
|
47471
|
+
var DEVICE_SAN_USER_PREFIX = "camstack:user:";
|
|
47472
|
+
/**
|
|
47473
|
+
* The exact bytes a device signs (UTF-8, `\n` separators, no trailing newline):
|
|
47474
|
+
*
|
|
47475
|
+
* camstack-device-cert-v1
|
|
47476
|
+
* <login|renew>
|
|
47477
|
+
* <origin> the hub origin returned by `getDeviceChallenge`
|
|
47478
|
+
* <nonce>
|
|
47479
|
+
*
|
|
47480
|
+
* The origin is part of the message so a signature collected by a look-alike
|
|
47481
|
+
* hub is worthless on the real one; the hub additionally binds the nonce to
|
|
47482
|
+
* the origin it issued it for and refuses any other.
|
|
47483
|
+
*/
|
|
47484
|
+
function buildDeviceSignatureMessage(input) {
|
|
47485
|
+
return [
|
|
47486
|
+
DEVICE_SIGNATURE_MESSAGE_VERSION,
|
|
47487
|
+
input.purpose,
|
|
47488
|
+
input.origin,
|
|
47489
|
+
input.nonce
|
|
47490
|
+
].join("\n");
|
|
47491
|
+
}
|
|
47492
|
+
/** The deep link a QR carries: `camstack://enroll?hub=<origin>&code=<code>`. */
|
|
47493
|
+
function buildDeviceEnrollmentLink(input) {
|
|
47494
|
+
const query = new URLSearchParams();
|
|
47495
|
+
if (input.hub !== void 0) query.set("hub", input.hub);
|
|
47496
|
+
query.set("code", input.code);
|
|
47497
|
+
return `${input.scheme ?? "camstack"}://enroll?${query.toString()}`;
|
|
47498
|
+
}
|
|
47499
|
+
var DevicePlatformSchema = zod.z.enum([
|
|
47500
|
+
"ios",
|
|
47501
|
+
"android",
|
|
47502
|
+
"web",
|
|
47503
|
+
"other"
|
|
47504
|
+
]);
|
|
47505
|
+
var Base64UrlSchema = zod.z.string().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/);
|
|
47506
|
+
var PemSchema = zod.z.string().min(1).max(16384);
|
|
47507
|
+
/**
|
|
47508
|
+
* Why a device-certificate endpoint said no. Distinct from a transport / 5xx
|
|
47509
|
+
* failure: those carry no reason and mean "try again", never "the credential is
|
|
47510
|
+
* dead". The viewer switches on this exhaustively.
|
|
47511
|
+
*/
|
|
47512
|
+
var DeviceRefusalReasonSchema = zod.z.enum([
|
|
47513
|
+
"revoked",
|
|
47514
|
+
"unknown-credential",
|
|
47515
|
+
"expired",
|
|
47516
|
+
"bad-signature",
|
|
47517
|
+
"nonce-invalid",
|
|
47518
|
+
"rate-limited",
|
|
47519
|
+
"invalid-certificate",
|
|
47520
|
+
"superseded",
|
|
47521
|
+
"user-gone",
|
|
47522
|
+
"unavailable",
|
|
47523
|
+
"code-invalid",
|
|
47524
|
+
"self-enrollment-disabled",
|
|
47525
|
+
"step-up-required",
|
|
47526
|
+
"bad-public-key"
|
|
47527
|
+
]);
|
|
47528
|
+
var DeviceRefusalSchema = zod.z.object({
|
|
47529
|
+
ok: zod.z.literal(false),
|
|
47530
|
+
reason: DeviceRefusalReasonSchema,
|
|
47531
|
+
definitive: zod.z.boolean(),
|
|
47532
|
+
retryAfterSeconds: zod.z.number().optional()
|
|
47533
|
+
});
|
|
47534
|
+
zod.z.object({
|
|
47535
|
+
code: zod.z.string().min(1).max(256),
|
|
47536
|
+
/** SubjectPublicKeyInfo DER of the device's P-256 public key, base64url. */
|
|
47537
|
+
publicKeySpki: Base64UrlSchema,
|
|
47538
|
+
deviceName: zod.z.string().min(1).max(80).optional(),
|
|
47539
|
+
platform: DevicePlatformSchema
|
|
47540
|
+
});
|
|
47541
|
+
var CompleteEnrollmentOutputSchema = zod.z.object({
|
|
47542
|
+
credentialId: zod.z.string(),
|
|
47543
|
+
certPem: PemSchema,
|
|
47544
|
+
/** The device CA certificate the leaf chains to. */
|
|
47545
|
+
chainPem: PemSchema,
|
|
47546
|
+
notAfter: zod.z.number(),
|
|
47547
|
+
user: zod.z.object({
|
|
47548
|
+
id: zod.z.string(),
|
|
47549
|
+
username: zod.z.string()
|
|
47550
|
+
})
|
|
47551
|
+
});
|
|
47552
|
+
zod.z.discriminatedUnion("ok", [CompleteEnrollmentOutputSchema.extend({ ok: zod.z.literal(true) }), DeviceRefusalSchema]);
|
|
47553
|
+
zod.z.object({
|
|
47554
|
+
/** The single-use step-up proof (`auth.deviceEnrollProofFrom…`). */
|
|
47555
|
+
proof: zod.z.string().min(1).max(512),
|
|
47556
|
+
publicKeySpki: Base64UrlSchema,
|
|
47557
|
+
deviceName: zod.z.string().min(1).max(80),
|
|
47558
|
+
platform: DevicePlatformSchema
|
|
47559
|
+
});
|
|
47560
|
+
zod.z.object({
|
|
47561
|
+
proof: zod.z.string(),
|
|
47562
|
+
expiresAt: zod.z.number()
|
|
47563
|
+
});
|
|
47564
|
+
var DeviceChallengeSchema = zod.z.object({
|
|
47565
|
+
nonce: zod.z.string(),
|
|
47566
|
+
/** The origin to put in the signed message. The app compares it to the hub it dialled. */
|
|
47567
|
+
origin: zod.z.string(),
|
|
47568
|
+
expiresAt: zod.z.number(),
|
|
47569
|
+
signature: zod.z.literal(DEVICE_CERT_SIGNATURE)
|
|
47570
|
+
});
|
|
47571
|
+
zod.z.discriminatedUnion("ok", [DeviceChallengeSchema.extend({ ok: zod.z.literal(true) }), DeviceRefusalSchema]);
|
|
47572
|
+
zod.z.object({
|
|
47573
|
+
certPem: PemSchema,
|
|
47574
|
+
nonce: zod.z.string().min(1).max(256),
|
|
47575
|
+
/** ECDSA P-256 SHA-256 over {@link buildDeviceSignatureMessage}; raw r||s or DER, base64url. */
|
|
47576
|
+
signature: Base64UrlSchema
|
|
47577
|
+
});
|
|
47578
|
+
var RenewDeviceCertificateOutputSchema = zod.z.object({
|
|
47579
|
+
credentialId: zod.z.string(),
|
|
47580
|
+
certPem: PemSchema,
|
|
47581
|
+
chainPem: PemSchema,
|
|
47582
|
+
notAfter: zod.z.number()
|
|
47583
|
+
});
|
|
47584
|
+
zod.z.discriminatedUnion("ok", [RenewDeviceCertificateOutputSchema.extend({ ok: zod.z.literal(true) }), DeviceRefusalSchema]);
|
|
47585
|
+
zod.z.discriminatedUnion("ok", [zod.z.object({
|
|
47586
|
+
ok: zod.z.literal(true),
|
|
47587
|
+
credentialId: zod.z.string(),
|
|
47588
|
+
sessionsEnded: zod.z.number().int()
|
|
47589
|
+
}), DeviceRefusalSchema]);
|
|
47590
|
+
function formatDeviceRevoker(revoker) {
|
|
47591
|
+
return revoker.kind === "device" ? "device" : `${revoker.kind}:${revoker.userId}`;
|
|
47592
|
+
}
|
|
47593
|
+
var DeviceCredentialStatusSchema = zod.z.enum([
|
|
47594
|
+
"active",
|
|
47595
|
+
"expired",
|
|
47596
|
+
"revoked"
|
|
47597
|
+
]);
|
|
47598
|
+
var DeviceCredentialSchema = zod.z.object({
|
|
47599
|
+
id: zod.z.string(),
|
|
47600
|
+
userId: zod.z.string(),
|
|
47601
|
+
username: zod.z.string().nullable(),
|
|
47602
|
+
deviceName: zod.z.string(),
|
|
47603
|
+
platform: DevicePlatformSchema,
|
|
47604
|
+
enrolledVia: zod.z.enum(["qr", "self"]),
|
|
47605
|
+
/** SHA-256 of the leaf certificate DER, colon-hex. */
|
|
47606
|
+
fingerprint: zod.z.string(),
|
|
47607
|
+
issuedAt: zod.z.number(),
|
|
47608
|
+
expiresAt: zod.z.number(),
|
|
47609
|
+
lastUsedAt: zod.z.number().nullable(),
|
|
47610
|
+
lastUsedFrom: zod.z.string().nullable(),
|
|
47611
|
+
revokedAt: zod.z.number().nullable(),
|
|
47612
|
+
/** `admin:<userId>` | `user:<userId>` | `device` | `user-deleted`. */
|
|
47613
|
+
revokedBy: zod.z.string().nullable(),
|
|
47614
|
+
status: DeviceCredentialStatusSchema
|
|
47615
|
+
});
|
|
47616
|
+
var StartEnrollmentOutputSchema = zod.z.object({
|
|
47617
|
+
/** Shown once; only its hash is kept. */
|
|
47618
|
+
code: zod.z.string(),
|
|
47619
|
+
expiresAt: zod.z.number(),
|
|
47620
|
+
/** `camstack://enroll?hub=…&code=…` — what the QR encodes. */
|
|
47621
|
+
enrollUrl: zod.z.string(),
|
|
47622
|
+
/** The hub origin in the link, or `null` when the hub could not name one (the link then has no `hub`). */
|
|
47623
|
+
hubOrigin: zod.z.string().nullable(),
|
|
47624
|
+
/** Every origin the apps may try (role `appConnections`). */
|
|
47625
|
+
hubOrigins: zod.z.array(zod.z.string())
|
|
47626
|
+
});
|
|
47627
|
+
zod.z.object({
|
|
47628
|
+
kind: zod.z.literal("device-certificate"),
|
|
47629
|
+
id: zod.z.literal("device-certificate"),
|
|
47630
|
+
label: zod.z.string(),
|
|
47631
|
+
stage: zod.z.literal("primary"),
|
|
47632
|
+
/** tRPC paths under the hub's `auth` router, so a client names no literal. */
|
|
47633
|
+
challengePath: zod.z.literal("auth.getDeviceChallenge"),
|
|
47634
|
+
revokePath: zod.z.literal("auth.revokeOwnDeviceCertificate"),
|
|
47635
|
+
enrollSelfPath: zod.z.literal("auth.enrollSelf"),
|
|
47636
|
+
loginPath: zod.z.literal("auth.loginWithDeviceCertificate"),
|
|
47637
|
+
renewPath: zod.z.literal("auth.renewDeviceCertificate"),
|
|
47638
|
+
signature: zod.z.literal(DEVICE_CERT_SIGNATURE),
|
|
47639
|
+
messageVersion: zod.z.literal(DEVICE_SIGNATURE_MESSAGE_VERSION),
|
|
47640
|
+
/** Which clients can execute it: a native app silently, a browser with a non-extractable WebCrypto key. */
|
|
47641
|
+
clients: zod.z.array(zod.z.enum(["native", "web"])),
|
|
47642
|
+
/** The app executes it itself, silently (D858). */
|
|
47643
|
+
app: AppLoginPathSchema.nullable()
|
|
47268
47644
|
});
|
|
47269
|
-
new Map(ENTRIES.map((e) => [e.key, e]));
|
|
47270
|
-
/** Categories a picker offers first: the ones this product's icons mostly live in. */
|
|
47271
|
-
var LEADING_CATEGORIES = [
|
|
47272
|
-
"devices",
|
|
47273
|
-
"home",
|
|
47274
|
-
"security",
|
|
47275
|
-
"buildings",
|
|
47276
|
-
"connectivity",
|
|
47277
|
-
"multimedia",
|
|
47278
|
-
"nature",
|
|
47279
|
-
"weather",
|
|
47280
|
-
"transportation",
|
|
47281
|
-
"animals"
|
|
47282
|
-
];
|
|
47283
|
-
var PRIMARY_CATEGORIES = new Set(ENTRIES.map((e) => e.primaryCategory));
|
|
47284
|
-
[...LEADING_CATEGORIES, ...ICON_CATEGORY_IDS.filter((c) => !LEADING_CATEGORIES.includes(c))].filter((c) => PRIMARY_CATEGORIES.has(c));
|
|
47285
47645
|
/**
|
|
47286
47646
|
* One (location, icon) assignment as it travels.
|
|
47287
47647
|
*
|
|
@@ -49781,7 +50141,9 @@ var SchedulerInputSchema = zod.z.object({
|
|
|
49781
50141
|
/** Higher wins when two holds want the same device in different states. */
|
|
49782
50142
|
priority: zod.z.number().int().min(0).max(100).default(0),
|
|
49783
50143
|
maxLateMs: zod.z.number().int().min(1e3).max(24 * 36e5).default(DEFAULT_MAX_LATE_MS),
|
|
49784
|
-
profiles: zod.z.array(SchedulerProfileSchema).max(20)
|
|
50144
|
+
profiles: zod.z.array(SchedulerProfileSchema).max(20),
|
|
50145
|
+
/** Operator tags (D1054). Absent = no tags. */
|
|
50146
|
+
tags: TagsFieldSchema.optional()
|
|
49785
50147
|
});
|
|
49786
50148
|
var SchedulerSchema = SchedulerInputSchema.extend({
|
|
49787
50149
|
id: zod.z.string().min(1),
|
|
@@ -53302,6 +53664,8 @@ var ActionEntrySchema = zod.z.object({
|
|
|
53302
53664
|
* action (two rules, a button, an automation).
|
|
53303
53665
|
*/
|
|
53304
53666
|
minDelaySec: ActionMinDelaySecSchema.optional(),
|
|
53667
|
+
/** Internal only: operator tags (D1054). Absent = no tags. */
|
|
53668
|
+
tags: TagsFieldSchema.optional(),
|
|
53305
53669
|
status: ActionStatusSchema
|
|
53306
53670
|
}).superRefine((entry, ctx) => {
|
|
53307
53671
|
if (entry.source === "internal") {
|
|
@@ -53333,7 +53697,8 @@ var ActionInputSchema = zod.z.object({
|
|
|
53333
53697
|
name: zod.z.string().min(1).max(120),
|
|
53334
53698
|
steps: zod.z.array(ActionStepSchema).min(1).max(50),
|
|
53335
53699
|
variables: zod.z.array(ActionVariableSchema).max(20).optional(),
|
|
53336
|
-
minDelaySec: ActionMinDelaySecSchema.optional()
|
|
53700
|
+
minDelaySec: ActionMinDelaySecSchema.optional(),
|
|
53701
|
+
tags: TagsFieldSchema.optional()
|
|
53337
53702
|
});
|
|
53338
53703
|
/** Who started a run. Absent = the operator pressed it. */
|
|
53339
53704
|
var ActionRunOriginSchema = zod.z.object({
|
|
@@ -67705,7 +68070,9 @@ var CoreBlockInputFieldsSchema = zod.z.object({
|
|
|
67705
68070
|
* from the compiled entry after a successful load; the editor may also set
|
|
67706
68071
|
* it. Absent ⇒ `getBlockSettings` returns null until one is known.
|
|
67707
68072
|
*/
|
|
67708
|
-
settingsSchema: CoreBlockSettingsSchemaBridge.optional()
|
|
68073
|
+
settingsSchema: CoreBlockSettingsSchemaBridge.optional(),
|
|
68074
|
+
/** Operator tags (D1054), kept on the record. Absent = no tags. */
|
|
68075
|
+
tags: TagsFieldSchema.optional()
|
|
67709
68076
|
});
|
|
67710
68077
|
/** Client-authored fields for create — requires `code` or `files[entry]`. */
|
|
67711
68078
|
var CoreBlockInputSchema = CoreBlockInputFieldsSchema.superRefine((val, ctx) => {
|
|
@@ -67803,6 +68170,8 @@ var CoreBlockSchema = zod.z.object({
|
|
|
67803
68170
|
placement: CoreBlockPlacementSchema,
|
|
67804
68171
|
integrationId: zod.z.string().optional(),
|
|
67805
68172
|
settingsSchema: CoreBlockSettingsSchemaBridge.optional(),
|
|
68173
|
+
/** Operator tags (D1054). Absent = no tags. */
|
|
68174
|
+
tags: TagsFieldSchema.optional(),
|
|
67806
68175
|
id: zod.z.string(),
|
|
67807
68176
|
createdAt: zod.z.number(),
|
|
67808
68177
|
updatedAt: zod.z.number(),
|
|
@@ -69554,38 +69923,11 @@ var DeviceTemplateThisDeviceSchema = zod.z.object({
|
|
|
69554
69923
|
});
|
|
69555
69924
|
/** The synthetic slice `thisDevice.values` is exposed under. */
|
|
69556
69925
|
var DEVICE_TEMPLATE_VALUES_CAP = "values";
|
|
69557
|
-
/**
|
|
69558
|
-
|
|
69559
|
-
|
|
69560
|
-
|
|
69561
|
-
|
|
69562
|
-
"onoff",
|
|
69563
|
-
"default",
|
|
69564
|
-
"since",
|
|
69565
|
-
"ago",
|
|
69566
|
-
"format",
|
|
69567
|
-
"upper",
|
|
69568
|
-
"lower",
|
|
69569
|
-
"title",
|
|
69570
|
-
"capitalize",
|
|
69571
|
-
"trim",
|
|
69572
|
-
"abs",
|
|
69573
|
-
"int",
|
|
69574
|
-
"float",
|
|
69575
|
-
"length",
|
|
69576
|
-
"d",
|
|
69577
|
-
"join",
|
|
69578
|
-
"replace",
|
|
69579
|
-
"first",
|
|
69580
|
-
"last",
|
|
69581
|
-
"sort",
|
|
69582
|
-
"reverse",
|
|
69583
|
-
"sum",
|
|
69584
|
-
"string",
|
|
69585
|
-
"list",
|
|
69586
|
-
"truncate",
|
|
69587
|
-
"time"
|
|
69588
|
-
];
|
|
69926
|
+
/**
|
|
69927
|
+
* The filters a template may use, derived from the catalogue. Anything else
|
|
69928
|
+
* is refused at parse time.
|
|
69929
|
+
*/
|
|
69930
|
+
var DEVICE_TEMPLATE_FILTERS = deviceTemplateFilterNames();
|
|
69589
69931
|
var DeviceTemplateRefusalSchema = zod.z.object({
|
|
69590
69932
|
reason: zod.z.enum([
|
|
69591
69933
|
"too-long",
|
|
@@ -70289,6 +70631,8 @@ var DeviceInfoSchema = zod.z.object({
|
|
|
70289
70631
|
alias: DeviceAliasSchema.optional(),
|
|
70290
70632
|
/** Operator-organisational location label. `null` when unset. */
|
|
70291
70633
|
location: zod.z.string().nullable(),
|
|
70634
|
+
/** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
|
|
70635
|
+
tags: TagsFieldSchema.optional(),
|
|
70292
70636
|
/** Soft-disabled flag. */
|
|
70293
70637
|
disabled: zod.z.boolean(),
|
|
70294
70638
|
parentDeviceId: zod.z.number().nullable(),
|
|
@@ -70450,6 +70794,8 @@ var SavedDeviceRowSchema = zod.z.object({
|
|
|
70450
70794
|
name: zod.z.string(),
|
|
70451
70795
|
/** Operator-organisational location label. `null` when unset. */
|
|
70452
70796
|
location: zod.z.string().nullable(),
|
|
70797
|
+
/** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
|
|
70798
|
+
tags: TagsFieldSchema.optional(),
|
|
70453
70799
|
/** Soft-disabled flag. */
|
|
70454
70800
|
disabled: zod.z.boolean(),
|
|
70455
70801
|
parentDeviceId: zod.z.number().nullable(),
|
|
@@ -70472,6 +70818,8 @@ var DeviceMetaSchema = zod.z.object({
|
|
|
70472
70818
|
* `DeviceMeta.userNamed`. */
|
|
70473
70819
|
userNamed: zod.z.boolean().optional(),
|
|
70474
70820
|
location: zod.z.string().nullable(),
|
|
70821
|
+
/** Operator tags (D1054), kept on the device meta beside `location`. Absent = no tags. */
|
|
70822
|
+
tags: TagsFieldSchema.optional(),
|
|
70475
70823
|
disabled: zod.z.boolean(),
|
|
70476
70824
|
parentDeviceId: zod.z.number().nullable(),
|
|
70477
70825
|
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
|
|
@@ -70768,6 +71116,17 @@ var deviceManagerCapability = {
|
|
|
70768
71116
|
kind: "mutation",
|
|
70769
71117
|
auth: "admin"
|
|
70770
71118
|
}),
|
|
71119
|
+
/** Replace the operator tags of one device (D1054). The list is normalised
|
|
71120
|
+
* on write (trimmed, deduplicated case-insensitively); `[]` clears them.
|
|
71121
|
+
* Tags are not inherited: unlike `setLocation`, nothing cascades to
|
|
71122
|
+
* descendants. */
|
|
71123
|
+
setTags: method(zod.z.object({
|
|
71124
|
+
deviceId: zod.z.number(),
|
|
71125
|
+
tags: TagsFieldSchema
|
|
71126
|
+
}), zod.z.void(), {
|
|
71127
|
+
kind: "mutation",
|
|
71128
|
+
auth: "admin"
|
|
71129
|
+
}),
|
|
70771
71130
|
/** Update the device type. Writes the meta row, emits a
|
|
70772
71131
|
* `DeviceMetaChanged` event. Used by the kernel to apply
|
|
70773
71132
|
* `initialMeta.type` before device construction so the device
|
|
@@ -70924,6 +71283,7 @@ var deviceManagerCapability = {
|
|
|
70924
71283
|
deviceId: zod.z.number(),
|
|
70925
71284
|
name: zod.z.string().optional(),
|
|
70926
71285
|
location: zod.z.string().nullable().optional(),
|
|
71286
|
+
tags: TagsFieldSchema.optional(),
|
|
70927
71287
|
type: zod.z.enum(DeviceType).optional(),
|
|
70928
71288
|
integrationId: zod.z.string().optional(),
|
|
70929
71289
|
linkDeviceId: zod.z.number().nullable().optional(),
|
|
@@ -74112,6 +74472,10 @@ var embeddingEncoderCapability = {
|
|
|
74112
74472
|
* system did not report is `null`, never `0` (D393).
|
|
74113
74473
|
*
|
|
74114
74474
|
* Signs, all in watts:
|
|
74475
|
+
* - The branches are DISJOINT: `house` is the consumption EXCLUDING the heat pump
|
|
74476
|
+
* whenever `heatPump` is reported, so solar + grid import + storage discharge =
|
|
74477
|
+
* house + heatPump + grid export + storage charge. A provider whose meter totals
|
|
74478
|
+
* include the pump subtracts it; when it cannot, `house` is null (D393).
|
|
74115
74479
|
* - `solar.powerW`, `house.powerW`, `heatPump.powerW` are magnitudes (≥ 0);
|
|
74116
74480
|
* - `grid.powerW` is + importing, − exporting;
|
|
74117
74481
|
* - `storage.powerW` is + charging, − discharging.
|
|
@@ -95161,7 +95525,7 @@ var OsdSourceSchema = zod.z.discriminatedUnion("kind", [
|
|
|
95161
95525
|
zod.z.object({ kind: zod.z.literal("none") }),
|
|
95162
95526
|
zod.z.object({
|
|
95163
95527
|
kind: zod.z.literal("static"),
|
|
95164
|
-
text: zod.z.string().max(
|
|
95528
|
+
text: zod.z.string().max(OSD_TEMPLATE_TEXT_MAX)
|
|
95165
95529
|
}),
|
|
95166
95530
|
zod.z.object({
|
|
95167
95531
|
kind: zod.z.literal("template"),
|
|
@@ -106571,6 +106935,69 @@ var systemCapability = {
|
|
|
106571
106935
|
vocabulary: { notOperatorFacing: NOT_A_DEVICE.CLUSTER }
|
|
106572
106936
|
};
|
|
106573
106937
|
/**
|
|
106938
|
+
* tags — the registry of tag STYLES and the one place that renames or removes a
|
|
106939
|
+
* tag everywhere (D1054). A tag itself lives in the `tags` array of the record it
|
|
106940
|
+
* labels (a core block, a scheduler, a template, an action, a device); only its
|
|
106941
|
+
* colour token and icon are registered here. Provided by the core-blocks builtin,
|
|
106942
|
+
* the one place that knows every owner kind; devices are reached through
|
|
106943
|
+
* `deviceManager` over `ctx.api`.
|
|
106944
|
+
*
|
|
106945
|
+
* Tags compare trimmed and case-insensitively. `list` is the union of styled tags
|
|
106946
|
+
* and tags in use; a tag with no style answers a colour derived from its name and
|
|
106947
|
+
* the default icon (`styled: false`).
|
|
106948
|
+
*/
|
|
106949
|
+
var TagUsageCountsSchema = zod.z.object({
|
|
106950
|
+
coreBlocks: zod.z.number().int().nonnegative(),
|
|
106951
|
+
schedulers: zod.z.number().int().nonnegative(),
|
|
106952
|
+
templates: zod.z.number().int().nonnegative(),
|
|
106953
|
+
actions: zod.z.number().int().nonnegative(),
|
|
106954
|
+
devices: zod.z.number().int().nonnegative()
|
|
106955
|
+
});
|
|
106956
|
+
var TagEntrySchema = zod.z.object({
|
|
106957
|
+
name: TagNameSchema,
|
|
106958
|
+
color: TagColorIdSchema,
|
|
106959
|
+
icon: IconKeySchema,
|
|
106960
|
+
/** `false` when the operator never chose a style: colour and icon are the derived defaults. */
|
|
106961
|
+
styled: zod.z.boolean(),
|
|
106962
|
+
counts: TagUsageCountsSchema
|
|
106963
|
+
});
|
|
106964
|
+
var tagsCapability = {
|
|
106965
|
+
name: "tags",
|
|
106966
|
+
scope: "system",
|
|
106967
|
+
mode: "singleton",
|
|
106968
|
+
methods: {
|
|
106969
|
+
/** Every tag: styled or in use, with how many records of each kind carry it. */
|
|
106970
|
+
list: method(zod.z.object({}), zod.z.array(TagEntrySchema), { auth: "protected" }),
|
|
106971
|
+
/** Choose the colour and icon of a tag. The tag need not be in use. */
|
|
106972
|
+
setStyle: method(zod.z.object({
|
|
106973
|
+
name: TagNameSchema,
|
|
106974
|
+
color: TagColorIdSchema,
|
|
106975
|
+
icon: IconKeySchema
|
|
106976
|
+
}), zod.z.void(), {
|
|
106977
|
+
kind: "mutation",
|
|
106978
|
+
auth: "admin"
|
|
106979
|
+
}),
|
|
106980
|
+
/**
|
|
106981
|
+
* Rename a tag on EVERY owner in one call. When `to` already exists the two
|
|
106982
|
+
* merge and the TARGET's style wins (like `renameLocation`). An empty `to`
|
|
106983
|
+
* is refused before anything is written.
|
|
106984
|
+
*/
|
|
106985
|
+
rename: method(zod.z.object({
|
|
106986
|
+
from: zod.z.string(),
|
|
106987
|
+
to: zod.z.string()
|
|
106988
|
+
}), zod.z.object({ updated: TagUsageCountsSchema }), {
|
|
106989
|
+
kind: "mutation",
|
|
106990
|
+
auth: "admin"
|
|
106991
|
+
}),
|
|
106992
|
+
/** Drop a tag from every owner and delete its style. */
|
|
106993
|
+
remove: method(zod.z.object({ name: zod.z.string() }), zod.z.object({ updated: TagUsageCountsSchema }), {
|
|
106994
|
+
kind: "mutation",
|
|
106995
|
+
auth: "admin"
|
|
106996
|
+
})
|
|
106997
|
+
},
|
|
106998
|
+
vocabulary: { notOperatorFacing: "tags are managed from the tag picker and the tags manager, not actuated" }
|
|
106999
|
+
};
|
|
107000
|
+
/**
|
|
106574
107001
|
* Tamper / case-open detection sensor. Drives Home Assistant
|
|
106575
107002
|
* `binary_sensor` entries with `device_class: tamper`. Push-driven.
|
|
106576
107003
|
*/
|
|
@@ -107444,7 +107871,9 @@ var TemplateRecordSchema = zod.z.object({
|
|
|
107444
107871
|
createdAt: zod.z.number(),
|
|
107445
107872
|
updatedAt: zod.z.number(),
|
|
107446
107873
|
/** Shipped with CamStack (`builtin:` ids): listed beside the operator's, never updated or deleted. */
|
|
107447
|
-
builtIn: zod.z.literal(true).optional()
|
|
107874
|
+
builtIn: zod.z.literal(true).optional(),
|
|
107875
|
+
/** Operator tags (D1054). Absent = no tags. */
|
|
107876
|
+
tags: TagsFieldSchema.optional()
|
|
107448
107877
|
});
|
|
107449
107878
|
var TemplateWriteResultSchema = zod.z.discriminatedUnion("status", [zod.z.object({
|
|
107450
107879
|
status: zod.z.literal("saved"),
|
|
@@ -107488,7 +107917,8 @@ var templateCapability = {
|
|
|
107488
107917
|
create: method(zod.z.object({
|
|
107489
107918
|
kind: TemplateKindSchema,
|
|
107490
107919
|
name: zod.z.string().min(1).max(120),
|
|
107491
|
-
payload: zod.z.unknown()
|
|
107920
|
+
payload: zod.z.unknown(),
|
|
107921
|
+
tags: TagsFieldSchema.optional()
|
|
107492
107922
|
}), TemplateWriteResultSchema, {
|
|
107493
107923
|
kind: "mutation",
|
|
107494
107924
|
auth: "admin"
|
|
@@ -107496,7 +107926,8 @@ var templateCapability = {
|
|
|
107496
107926
|
update: method(zod.z.object({
|
|
107497
107927
|
id: zod.z.string().min(1),
|
|
107498
107928
|
name: zod.z.string().min(1).max(120).optional(),
|
|
107499
|
-
payload: zod.z.unknown().optional()
|
|
107929
|
+
payload: zod.z.unknown().optional(),
|
|
107930
|
+
tags: TagsFieldSchema.optional()
|
|
107500
107931
|
}), TemplateWriteResultSchema, {
|
|
107501
107932
|
kind: "mutation",
|
|
107502
107933
|
auth: "admin"
|
|
@@ -111400,6 +111831,7 @@ var ALL_CAPABILITY_DEFINITIONS = [
|
|
|
111400
111831
|
streamSignalsCapability,
|
|
111401
111832
|
switchCapability,
|
|
111402
111833
|
systemCapability,
|
|
111834
|
+
tagsCapability,
|
|
111403
111835
|
tamperCapability,
|
|
111404
111836
|
temperatureSensorCapability,
|
|
111405
111837
|
templateCapability,
|
|
@@ -122060,6 +122492,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
122060
122492
|
access: "create",
|
|
122061
122493
|
role: "admin"
|
|
122062
122494
|
},
|
|
122495
|
+
"deviceManager.setTags": {
|
|
122496
|
+
capName: "device-manager",
|
|
122497
|
+
capScope: "system",
|
|
122498
|
+
addonId: null,
|
|
122499
|
+
access: "create",
|
|
122500
|
+
role: "admin"
|
|
122501
|
+
},
|
|
122063
122502
|
"deviceManager.setType": {
|
|
122064
122503
|
capName: "device-manager",
|
|
122065
122504
|
capScope: "system",
|
|
@@ -128773,6 +129212,34 @@ var METHOD_ACCESS_MAP = Object.freeze({
|
|
|
128773
129212
|
access: "create",
|
|
128774
129213
|
role: "admin"
|
|
128775
129214
|
},
|
|
129215
|
+
"tags.list": {
|
|
129216
|
+
capName: "tags",
|
|
129217
|
+
capScope: "system",
|
|
129218
|
+
addonId: null,
|
|
129219
|
+
access: "view",
|
|
129220
|
+
role: "admin"
|
|
129221
|
+
},
|
|
129222
|
+
"tags.remove": {
|
|
129223
|
+
capName: "tags",
|
|
129224
|
+
capScope: "system",
|
|
129225
|
+
addonId: null,
|
|
129226
|
+
access: "delete",
|
|
129227
|
+
role: "admin"
|
|
129228
|
+
},
|
|
129229
|
+
"tags.rename": {
|
|
129230
|
+
capName: "tags",
|
|
129231
|
+
capScope: "system",
|
|
129232
|
+
addonId: null,
|
|
129233
|
+
access: "create",
|
|
129234
|
+
role: "admin"
|
|
129235
|
+
},
|
|
129236
|
+
"tags.setStyle": {
|
|
129237
|
+
capName: "tags",
|
|
129238
|
+
capScope: "system",
|
|
129239
|
+
addonId: null,
|
|
129240
|
+
access: "create",
|
|
129241
|
+
role: "admin"
|
|
129242
|
+
},
|
|
128776
129243
|
"tamper.getStatus": {
|
|
128777
129244
|
capName: "tamper",
|
|
128778
129245
|
capScope: "device",
|
|
@@ -130913,6 +131380,11 @@ Object.freeze({
|
|
|
130913
131380
|
form: "single",
|
|
130914
131381
|
optional: false
|
|
130915
131382
|
}],
|
|
131383
|
+
"deviceManager.setTags": [{
|
|
131384
|
+
name: "deviceId",
|
|
131385
|
+
form: "single",
|
|
131386
|
+
optional: false
|
|
131387
|
+
}],
|
|
130916
131388
|
"deviceManager.setType": [{
|
|
130917
131389
|
name: "deviceId",
|
|
130918
131390
|
form: "single",
|
|
@@ -136727,6 +137199,24 @@ Object.defineProperty(exports, "StoredRecordKindDeclarationSchema", {
|
|
|
136727
137199
|
return StoredRecordKindDeclarationSchema;
|
|
136728
137200
|
}
|
|
136729
137201
|
});
|
|
137202
|
+
Object.defineProperty(exports, "TagNameSchema", {
|
|
137203
|
+
enumerable: true,
|
|
137204
|
+
get: function() {
|
|
137205
|
+
return TagNameSchema;
|
|
137206
|
+
}
|
|
137207
|
+
});
|
|
137208
|
+
Object.defineProperty(exports, "TagStyleSchema", {
|
|
137209
|
+
enumerable: true,
|
|
137210
|
+
get: function() {
|
|
137211
|
+
return TagStyleSchema;
|
|
137212
|
+
}
|
|
137213
|
+
});
|
|
137214
|
+
Object.defineProperty(exports, "TagsFieldSchema", {
|
|
137215
|
+
enumerable: true,
|
|
137216
|
+
get: function() {
|
|
137217
|
+
return TagsFieldSchema;
|
|
137218
|
+
}
|
|
137219
|
+
});
|
|
136730
137220
|
Object.defineProperty(exports, "TemplateKindSchema", {
|
|
136731
137221
|
enumerable: true,
|
|
136732
137222
|
get: function() {
|
|
@@ -137297,6 +137787,12 @@ Object.defineProperty(exports, "decodeVectorBase64", {
|
|
|
137297
137787
|
return decodeVectorBase64;
|
|
137298
137788
|
}
|
|
137299
137789
|
});
|
|
137790
|
+
Object.defineProperty(exports, "defaultTagColorId", {
|
|
137791
|
+
enumerable: true,
|
|
137792
|
+
get: function() {
|
|
137793
|
+
return defaultTagColorId;
|
|
137794
|
+
}
|
|
137795
|
+
});
|
|
137300
137796
|
Object.defineProperty(exports, "defineAddonMigrations", {
|
|
137301
137797
|
enumerable: true,
|
|
137302
137798
|
get: function() {
|
|
@@ -138095,6 +138591,12 @@ Object.defineProperty(exports, "normalizeSecretOwner", {
|
|
|
138095
138591
|
return normalizeSecretOwner;
|
|
138096
138592
|
}
|
|
138097
138593
|
});
|
|
138594
|
+
Object.defineProperty(exports, "normalizeTags", {
|
|
138595
|
+
enumerable: true,
|
|
138596
|
+
get: function() {
|
|
138597
|
+
return normalizeTags;
|
|
138598
|
+
}
|
|
138599
|
+
});
|
|
138098
138600
|
Object.defineProperty(exports, "normalizeUnit", {
|
|
138099
138601
|
enumerable: true,
|
|
138100
138602
|
get: function() {
|
|
@@ -138353,6 +138855,18 @@ Object.defineProperty(exports, "remoteSourceSteps", {
|
|
|
138353
138855
|
return remoteSourceSteps;
|
|
138354
138856
|
}
|
|
138355
138857
|
});
|
|
138858
|
+
Object.defineProperty(exports, "removeFromTags", {
|
|
138859
|
+
enumerable: true,
|
|
138860
|
+
get: function() {
|
|
138861
|
+
return removeFromTags;
|
|
138862
|
+
}
|
|
138863
|
+
});
|
|
138864
|
+
Object.defineProperty(exports, "renameInTags", {
|
|
138865
|
+
enumerable: true,
|
|
138866
|
+
get: function() {
|
|
138867
|
+
return renameInTags;
|
|
138868
|
+
}
|
|
138869
|
+
});
|
|
138356
138870
|
Object.defineProperty(exports, "replaceRecipeLiteral", {
|
|
138357
138871
|
enumerable: true,
|
|
138358
138872
|
get: function() {
|
|
@@ -138695,6 +139209,18 @@ Object.defineProperty(exports, "switchStateOfMode", {
|
|
|
138695
139209
|
return switchStateOfMode;
|
|
138696
139210
|
}
|
|
138697
139211
|
});
|
|
139212
|
+
Object.defineProperty(exports, "tagKey", {
|
|
139213
|
+
enumerable: true,
|
|
139214
|
+
get: function() {
|
|
139215
|
+
return tagKey;
|
|
139216
|
+
}
|
|
139217
|
+
});
|
|
139218
|
+
Object.defineProperty(exports, "tagsCapability", {
|
|
139219
|
+
enumerable: true,
|
|
139220
|
+
get: function() {
|
|
139221
|
+
return tagsCapability;
|
|
139222
|
+
}
|
|
139223
|
+
});
|
|
138698
139224
|
Object.defineProperty(exports, "templateCapability", {
|
|
138699
139225
|
enumerable: true,
|
|
138700
139226
|
get: function() {
|