@camstack/addon-export-hap 1.2.154 → 1.2.156
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/dist/hap-export.addon.js +3552 -162
- package/dist/hap-export.addon.mjs +3552 -162
- package/package.json +1 -1
package/dist/hap-export.addon.js
CHANGED
|
@@ -48,7 +48,7 @@ node_fs_promises = __toESM(node_fs_promises, 1);
|
|
|
48
48
|
let node_events = require("node:events");
|
|
49
49
|
let node_dgram = require("node:dgram");
|
|
50
50
|
let node_os = require("node:os");
|
|
51
|
-
//#region ../types/dist/event-category-
|
|
51
|
+
//#region ../types/dist/event-category-DaIZi00R.mjs
|
|
52
52
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
53
53
|
EventCategory["SystemBoot"] = "system.boot";
|
|
54
54
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -127,6 +127,13 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
127
127
|
*/
|
|
128
128
|
EventCategory["AddonLoadFailed"] = "addon.load-failed";
|
|
129
129
|
/**
|
|
130
|
+
* A keychain value was stored or removed (D787). Carries the ref, its
|
|
131
|
+
* owner and the new version — NEVER the value. A process holding the ref
|
|
132
|
+
* drops its cached copy and the owning `BaseAddon` re-resolves its config.
|
|
133
|
+
* Telemetry (D8): a process that misses it still revalidates by version.
|
|
134
|
+
*/
|
|
135
|
+
EventCategory["KeychainChanged"] = "keychain.changed";
|
|
136
|
+
/**
|
|
130
137
|
* Addon recovered from a previous failure. Emitted when an addon
|
|
131
138
|
* transitions from `failed` back to `healthy` (typically via the
|
|
132
139
|
* monitor's auto-retry loop, or after manual `addons.retryLoad`).
|
|
@@ -5419,7 +5426,7 @@ var ZodIssueCode = {
|
|
|
5419
5426
|
var ZodFirstPartyTypeKind;
|
|
5420
5427
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5421
5428
|
//#endregion
|
|
5422
|
-
//#region ../types/dist/sleep-
|
|
5429
|
+
//#region ../types/dist/sleep-r3RWkGVx.mjs
|
|
5423
5430
|
/**
|
|
5424
5431
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5425
5432
|
* window to float samples (D455).
|
|
@@ -5498,6 +5505,97 @@ function buildAlawTable() {
|
|
|
5498
5505
|
}
|
|
5499
5506
|
buildUlawTable();
|
|
5500
5507
|
buildAlawTable();
|
|
5508
|
+
/** Is this field's stored value a credential? */
|
|
5509
|
+
function isSecretConfigField(field) {
|
|
5510
|
+
if (field.type === "password") return true;
|
|
5511
|
+
return "secret" in field && field.secret === true;
|
|
5512
|
+
}
|
|
5513
|
+
/**
|
|
5514
|
+
* Is this field's value stored in the KEYCHAIN (D787)? Every secret field is,
|
|
5515
|
+
* by its TYPE, unless it opts out with `storage: 'inline'` — never by its name.
|
|
5516
|
+
*/
|
|
5517
|
+
function isKeychainStoredField(field) {
|
|
5518
|
+
if (!isSecretConfigField(field)) return false;
|
|
5519
|
+
if (field.type === "textarea" && field.isJson === true) return false;
|
|
5520
|
+
return !("storage" in field && field.storage === "inline");
|
|
5521
|
+
}
|
|
5522
|
+
/**
|
|
5523
|
+
* What a settings blob holds where a secret used to be.
|
|
5524
|
+
*
|
|
5525
|
+
* A keychain-stored field never holds its value. It holds a self-describing
|
|
5526
|
+
* MARKER, `{"$secret":"secret://…","v":1}` — an object, never a string, so no
|
|
5527
|
+
* code can mistake it for a credential and no form can send it to a camera as
|
|
5528
|
+
* a password. The empty state is `null` / absent, never `''`.
|
|
5529
|
+
*
|
|
5530
|
+
* The same shapes travel to and from the admin UI:
|
|
5531
|
+
*
|
|
5532
|
+
* - read: `hydrateSchema` hands a secret field a {@link SecretFieldView}
|
|
5533
|
+
* (`{ $secret, v, set: true }`) or `null` — the browser learns whether a
|
|
5534
|
+
* value is set, never the value.
|
|
5535
|
+
* - write: an untouched field submits the view back unchanged (KEEP); a typed
|
|
5536
|
+
* value is a plain non-empty string (CHANGE); the Clear button submits
|
|
5537
|
+
* {@link SECRET_CLEAR} (CLEAR). `''`, `null` and the legacy redaction tokens
|
|
5538
|
+
* are KEEP — an empty string is what a defaults-fallback pushes back, and
|
|
5539
|
+
* treating it as "clear" is how a save destroyed a stored credential before.
|
|
5540
|
+
*
|
|
5541
|
+
* Pure and browser-safe.
|
|
5542
|
+
*/
|
|
5543
|
+
var SECRET_CLEAR = { $secretClear: true };
|
|
5544
|
+
/** The `'***'` token D634 redaction writes for non-admins. */
|
|
5545
|
+
var LEGACY_DEVICE_REDACTION = "***";
|
|
5546
|
+
function isRecord$2(value) {
|
|
5547
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5548
|
+
}
|
|
5549
|
+
function makeSecretMarker(ref) {
|
|
5550
|
+
return {
|
|
5551
|
+
$secret: ref,
|
|
5552
|
+
v: 1
|
|
5553
|
+
};
|
|
5554
|
+
}
|
|
5555
|
+
/** A stored marker: an object whose `$secret` is a non-empty string. */
|
|
5556
|
+
function isSecretMarker(value) {
|
|
5557
|
+
if (!isRecord$2(value)) return false;
|
|
5558
|
+
const ref = value["$secret"];
|
|
5559
|
+
return typeof ref === "string" && ref.length > 0;
|
|
5560
|
+
}
|
|
5561
|
+
function isSecretClear(value) {
|
|
5562
|
+
return isRecord$2(value) && value["$secretClear"] === true;
|
|
5563
|
+
}
|
|
5564
|
+
/**
|
|
5565
|
+
* The UI view of a stored secret field value: a marker becomes "set", inline
|
|
5566
|
+
* plaintext becomes "set (inline)", nothing becomes `null`. A value never
|
|
5567
|
+
* survives this function.
|
|
5568
|
+
*/
|
|
5569
|
+
function toSecretFieldView(stored) {
|
|
5570
|
+
if (isSecretMarker(stored)) return {
|
|
5571
|
+
$secret: stored.$secret,
|
|
5572
|
+
v: 1,
|
|
5573
|
+
set: true
|
|
5574
|
+
};
|
|
5575
|
+
if (typeof stored === "string" && stored.length > 0) return {
|
|
5576
|
+
$secret: null,
|
|
5577
|
+
v: 1,
|
|
5578
|
+
set: true,
|
|
5579
|
+
inline: true
|
|
5580
|
+
};
|
|
5581
|
+
return null;
|
|
5582
|
+
}
|
|
5583
|
+
/**
|
|
5584
|
+
* Classify an incoming value for a secret path. Only a non-empty string that is
|
|
5585
|
+
* not a redaction token sets a value; only {@link SECRET_CLEAR} clears.
|
|
5586
|
+
* Everything else — a marker (ours or anyone's), a UI view, `''`, `null`,
|
|
5587
|
+
* `undefined`, a redaction token, a non-string — keeps what is stored.
|
|
5588
|
+
*/
|
|
5589
|
+
function classifySecretWrite(incoming) {
|
|
5590
|
+
if (isSecretClear(incoming)) return { kind: "clear" };
|
|
5591
|
+
if (typeof incoming !== "string") return { kind: "keep" };
|
|
5592
|
+
if (incoming.length === 0) return { kind: "keep" };
|
|
5593
|
+
if (incoming === "__camstack_redacted__" || incoming === LEGACY_DEVICE_REDACTION) return { kind: "keep" };
|
|
5594
|
+
return {
|
|
5595
|
+
kind: "set",
|
|
5596
|
+
value: incoming
|
|
5597
|
+
};
|
|
5598
|
+
}
|
|
5501
5599
|
Object.fromEntries([
|
|
5502
5600
|
{
|
|
5503
5601
|
id: "overview",
|
|
@@ -5669,33 +5767,19 @@ Object.fromEntries([
|
|
|
5669
5767
|
function isValuelessField(field) {
|
|
5670
5768
|
return field.type === "separator" || field.type === "info" || field.type === "qr-code" || field.type === "button" || field.type === "object-array" || field.type === "widget" || field.type === "addon-action-button" || field.type === "device-action-button";
|
|
5671
5769
|
}
|
|
5672
|
-
|
|
5673
|
-
* Merge a `ConfigUISchema` with a raw `values` record into a
|
|
5674
|
-
* `ConfigUISchemaWithValues`. Used by every `get*Settings` backend endpoint
|
|
5675
|
-
* before returning to the admin UI. Groups are walked recursively.
|
|
5676
|
-
*
|
|
5677
|
-
* For each leaf field:
|
|
5678
|
-
* - structural fields (`separator`, `info`, `button`) pass through unchanged
|
|
5679
|
-
* - other fields get `value = values[key] ?? field.default ?? null`
|
|
5680
|
-
*
|
|
5681
|
-
* Unknown keys in `values` (keys not declared in the schema) are silently
|
|
5682
|
-
* ignored — they don't contribute to the output. Missing keys fall back to
|
|
5683
|
-
* the schema default or `null`. This mirrors the old backend behaviour where
|
|
5684
|
-
* `FormBuilder` rendered `values[key] ?? field.default`.
|
|
5685
|
-
*/
|
|
5686
|
-
function hydrateSchema(schema, values) {
|
|
5770
|
+
function hydrateSchema(schema, values, options = {}) {
|
|
5687
5771
|
return {
|
|
5688
5772
|
...schema.tabs ? { tabs: [...schema.tabs] } : {},
|
|
5689
5773
|
sections: schema.sections.map((section) => ({
|
|
5690
5774
|
...section,
|
|
5691
|
-
fields: section.fields.map((field) => hydrateField(field, values))
|
|
5775
|
+
fields: section.fields.map((field) => hydrateField(field, values, options))
|
|
5692
5776
|
}))
|
|
5693
5777
|
};
|
|
5694
5778
|
}
|
|
5695
|
-
function hydrateField(field, values) {
|
|
5779
|
+
function hydrateField(field, values, options) {
|
|
5696
5780
|
if (isValuelessField(field)) return field;
|
|
5697
5781
|
if (field.type === "group") {
|
|
5698
|
-
const hydratedChildren = field.fields.map((child) => hydrateField(child, values));
|
|
5782
|
+
const hydratedChildren = field.fields.map((child) => hydrateField(child, values, options));
|
|
5699
5783
|
return {
|
|
5700
5784
|
...field,
|
|
5701
5785
|
fields: hydratedChildren
|
|
@@ -5704,7 +5788,7 @@ function hydrateField(field, values) {
|
|
|
5704
5788
|
if (field.type === "sub-tabs") {
|
|
5705
5789
|
const hydratedTabs = field.tabs.map((tab) => ({
|
|
5706
5790
|
...tab,
|
|
5707
|
-
fields: tab.fields.map((child) => hydrateField(child, values))
|
|
5791
|
+
fields: tab.fields.map((child) => hydrateField(child, values, options))
|
|
5708
5792
|
}));
|
|
5709
5793
|
return {
|
|
5710
5794
|
...field,
|
|
@@ -5714,6 +5798,33 @@ function hydrateField(field, values) {
|
|
|
5714
5798
|
const key = field.key;
|
|
5715
5799
|
const storedValue = Object.prototype.hasOwnProperty.call(values, key) ? values[key] : void 0;
|
|
5716
5800
|
const defaultValue = field.default;
|
|
5801
|
+
const asView = (v) => isSecretMarker(v) || options.inlineSecretsAsViews === true && v !== void 0;
|
|
5802
|
+
if (isKeychainStoredField(field) && asView(storedValue)) return {
|
|
5803
|
+
...field,
|
|
5804
|
+
value: toSecretFieldView(storedValue)
|
|
5805
|
+
};
|
|
5806
|
+
if (isKeychainStoredField(field) && options.inlineSecretsAsViews === true) return {
|
|
5807
|
+
...field,
|
|
5808
|
+
value: null
|
|
5809
|
+
};
|
|
5810
|
+
if (field.type === "editable-array" && Array.isArray(storedValue)) {
|
|
5811
|
+
const secretItemKeys = field.itemFields.filter((item) => "key" in item && isKeychainStoredField(item)).map((item) => "key" in item ? item.key : "");
|
|
5812
|
+
if (secretItemKeys.length > 0) {
|
|
5813
|
+
const rows = storedValue.map((row) => {
|
|
5814
|
+
if (row === null || typeof row !== "object" || Array.isArray(row)) return row;
|
|
5815
|
+
const out = { ...row };
|
|
5816
|
+
for (const k of secretItemKeys) {
|
|
5817
|
+
const v = Reflect.get(row, k);
|
|
5818
|
+
if (asView(v)) out[k] = toSecretFieldView(v);
|
|
5819
|
+
}
|
|
5820
|
+
return out;
|
|
5821
|
+
});
|
|
5822
|
+
return {
|
|
5823
|
+
...field,
|
|
5824
|
+
value: rows
|
|
5825
|
+
};
|
|
5826
|
+
}
|
|
5827
|
+
}
|
|
5717
5828
|
if (field.multiple) {
|
|
5718
5829
|
const stored = Array.isArray(storedValue) ? storedValue : storedValue !== void 0 && storedValue !== null ? [storedValue] : [];
|
|
5719
5830
|
const itemFallback = field.multiple.itemDefault !== void 0 ? field.multiple.itemDefault : defaultValue !== void 0 ? defaultValue : typeOf(field) === "string" ? "" : null;
|
|
@@ -5956,6 +6067,778 @@ function projectStore(store, perNodeKeys, nodeId) {
|
|
|
5956
6067
|
}
|
|
5957
6068
|
return out;
|
|
5958
6069
|
}
|
|
6070
|
+
var GLOBAL_SCOPE = { kind: "global" };
|
|
6071
|
+
/** The scope every addon-wide (not per-node, not per-device) setting lives in. */
|
|
6072
|
+
function globalSecretScope() {
|
|
6073
|
+
return GLOBAL_SCOPE;
|
|
6074
|
+
}
|
|
6075
|
+
function encodeSegment(value) {
|
|
6076
|
+
return encodeURIComponent(value);
|
|
6077
|
+
}
|
|
6078
|
+
function decodeSegment(value) {
|
|
6079
|
+
try {
|
|
6080
|
+
return decodeURIComponent(value);
|
|
6081
|
+
} catch {
|
|
6082
|
+
return null;
|
|
6083
|
+
}
|
|
6084
|
+
}
|
|
6085
|
+
/**
|
|
6086
|
+
* The field path of a value inside an array item, addressed by the item's id:
|
|
6087
|
+
* `arrayItemFieldPath('providers', 'authentik', 'clientSecret')` →
|
|
6088
|
+
* `providers[authentik].clientSecret`.
|
|
6089
|
+
*/
|
|
6090
|
+
function arrayItemFieldPath(arrayKey, itemId, fieldKey) {
|
|
6091
|
+
return `${arrayKey}[${encodeSegment(itemId)}].${fieldKey}`;
|
|
6092
|
+
}
|
|
6093
|
+
function parseScope(segments) {
|
|
6094
|
+
switch (segments[0]) {
|
|
6095
|
+
case "global": return {
|
|
6096
|
+
scope: GLOBAL_SCOPE,
|
|
6097
|
+
used: 1
|
|
6098
|
+
};
|
|
6099
|
+
case "node": {
|
|
6100
|
+
const nodeId = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
|
|
6101
|
+
return nodeId === null || nodeId.length === 0 ? null : {
|
|
6102
|
+
scope: {
|
|
6103
|
+
kind: "node",
|
|
6104
|
+
nodeId
|
|
6105
|
+
},
|
|
6106
|
+
used: 2
|
|
6107
|
+
};
|
|
6108
|
+
}
|
|
6109
|
+
case "device": {
|
|
6110
|
+
const raw = segments[1];
|
|
6111
|
+
if (raw === void 0 || !/^\d+$/.test(raw)) return null;
|
|
6112
|
+
return {
|
|
6113
|
+
scope: {
|
|
6114
|
+
kind: "device",
|
|
6115
|
+
deviceId: Number(raw)
|
|
6116
|
+
},
|
|
6117
|
+
used: 2
|
|
6118
|
+
};
|
|
6119
|
+
}
|
|
6120
|
+
case "integration": {
|
|
6121
|
+
const id = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
|
|
6122
|
+
return id === null || id.length === 0 ? null : {
|
|
6123
|
+
scope: {
|
|
6124
|
+
kind: "integration",
|
|
6125
|
+
integrationId: id
|
|
6126
|
+
},
|
|
6127
|
+
used: 2
|
|
6128
|
+
};
|
|
6129
|
+
}
|
|
6130
|
+
case "row": {
|
|
6131
|
+
const collection = segments[1] !== void 0 ? decodeSegment(segments[1]) : null;
|
|
6132
|
+
const rowId = segments[2] !== void 0 ? decodeSegment(segments[2]) : null;
|
|
6133
|
+
if (collection === null || rowId === null || collection.length === 0 || rowId.length === 0) return null;
|
|
6134
|
+
return {
|
|
6135
|
+
scope: {
|
|
6136
|
+
kind: "row",
|
|
6137
|
+
collection,
|
|
6138
|
+
rowId
|
|
6139
|
+
},
|
|
6140
|
+
used: 3
|
|
6141
|
+
};
|
|
6142
|
+
}
|
|
6143
|
+
default: return null;
|
|
6144
|
+
}
|
|
6145
|
+
}
|
|
6146
|
+
/** Take a ref apart; `null` when it is not a well-formed ref. */
|
|
6147
|
+
function parseSecretRef(ref) {
|
|
6148
|
+
if (!ref.startsWith("secret://")) return null;
|
|
6149
|
+
const segments = ref.slice(9).split("/");
|
|
6150
|
+
const owner = segments[0] !== void 0 ? decodeSegment(segments[0]) : null;
|
|
6151
|
+
if (owner === null || owner.length === 0) return null;
|
|
6152
|
+
const parsed = parseScope(segments.slice(1));
|
|
6153
|
+
if (parsed === null) return null;
|
|
6154
|
+
const fieldPath = segments.slice(1 + parsed.used).join("/");
|
|
6155
|
+
if (fieldPath.length === 0) return null;
|
|
6156
|
+
return {
|
|
6157
|
+
owner,
|
|
6158
|
+
scope: parsed.scope,
|
|
6159
|
+
fieldPath
|
|
6160
|
+
};
|
|
6161
|
+
}
|
|
6162
|
+
/** A write to a secret path could not be stored in the keychain, so it was refused. */
|
|
6163
|
+
var KeychainWriteRefusedError = class extends Error {
|
|
6164
|
+
fieldPath;
|
|
6165
|
+
constructor(fieldPath, cause) {
|
|
6166
|
+
super(`secret "${fieldPath}" was not saved: the keychain could not store it (${cause instanceof Error ? cause.message : String(cause)}). Nothing was written.`);
|
|
6167
|
+
this.fieldPath = fieldPath;
|
|
6168
|
+
this.name = "KeychainWriteRefusedError";
|
|
6169
|
+
}
|
|
6170
|
+
};
|
|
6171
|
+
var KEEP = { kind: "keep" };
|
|
6172
|
+
function isRecord$1$1(value) {
|
|
6173
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6174
|
+
}
|
|
6175
|
+
function defaultMintId() {
|
|
6176
|
+
return globalThis.crypto.randomUUID();
|
|
6177
|
+
}
|
|
6178
|
+
/** Every marker ref anywhere under `value`. */
|
|
6179
|
+
function collectSecretMarkerRefs(value, out = []) {
|
|
6180
|
+
if (isSecretMarker(value)) {
|
|
6181
|
+
out.push(value.$secret);
|
|
6182
|
+
return out;
|
|
6183
|
+
}
|
|
6184
|
+
if (Array.isArray(value)) for (const item of value) collectSecretMarkerRefs(item, out);
|
|
6185
|
+
else if (isRecord$1$1(value)) for (const child of Object.values(value)) collectSecretMarkerRefs(child, out);
|
|
6186
|
+
return out;
|
|
6187
|
+
}
|
|
6188
|
+
async function storedValueEquals(secrets, marker, candidate) {
|
|
6189
|
+
const resolved = (await secrets.resolve([marker.$secret]))[marker.$secret];
|
|
6190
|
+
return resolved?.kind === "value" && resolved.value === candidate;
|
|
6191
|
+
}
|
|
6192
|
+
async function writeLeaf(ctx, incoming, stored, fieldPath) {
|
|
6193
|
+
const intent = classifySecretWrite(incoming);
|
|
6194
|
+
const ref = ctx.secrets.ref(ctx.scope, fieldPath);
|
|
6195
|
+
const storedIsOurs = isSecretMarker(stored) && stored.$secret === ref;
|
|
6196
|
+
if (intent.kind === "keep") return KEEP;
|
|
6197
|
+
if (intent.kind === "set" && !ctx.operatorWrite && typeof stored === "string" && stored === intent.value) return KEEP;
|
|
6198
|
+
if (intent.kind === "clear") {
|
|
6199
|
+
if (storedIsOurs) ctx.deletes.push(ref);
|
|
6200
|
+
return {
|
|
6201
|
+
kind: "value",
|
|
6202
|
+
value: null
|
|
6203
|
+
};
|
|
6204
|
+
}
|
|
6205
|
+
if (storedIsOurs && await storedValueEquals(ctx.secrets, stored, intent.value)) return {
|
|
6206
|
+
kind: "value",
|
|
6207
|
+
value: stored
|
|
6208
|
+
};
|
|
6209
|
+
try {
|
|
6210
|
+
await ctx.secrets.put(ref, intent.value);
|
|
6211
|
+
} catch (err) {
|
|
6212
|
+
throw new KeychainWriteRefusedError(fieldPath, err);
|
|
6213
|
+
}
|
|
6214
|
+
return {
|
|
6215
|
+
kind: "value",
|
|
6216
|
+
value: makeSecretMarker(ref)
|
|
6217
|
+
};
|
|
6218
|
+
}
|
|
6219
|
+
/** Apply a member result onto `out`: KEEP restores the stored member, or removes it. */
|
|
6220
|
+
function applyMember(out, key, result, storedParent) {
|
|
6221
|
+
if (result.kind === "value") {
|
|
6222
|
+
out[key] = result.value;
|
|
6223
|
+
return;
|
|
6224
|
+
}
|
|
6225
|
+
if (Object.prototype.hasOwnProperty.call(storedParent, key)) out[key] = storedParent[key];
|
|
6226
|
+
else delete out[key];
|
|
6227
|
+
}
|
|
6228
|
+
async function writeMembers(ctx, children, incoming, stored, pathOf) {
|
|
6229
|
+
const out = { ...incoming };
|
|
6230
|
+
for (const [member, node] of children) applyMember(out, member, await writeNode(ctx, node, incoming[member], stored[member], pathOf(member)), stored);
|
|
6231
|
+
return out;
|
|
6232
|
+
}
|
|
6233
|
+
function rowId(row, idKey) {
|
|
6234
|
+
const raw = row[idKey];
|
|
6235
|
+
if (typeof raw === "string" && raw.length > 0) return raw;
|
|
6236
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
6237
|
+
return null;
|
|
6238
|
+
}
|
|
6239
|
+
async function writeArray(ctx, node, incoming, stored, fieldPath) {
|
|
6240
|
+
const storedRows = Array.isArray(stored) ? stored.filter(isRecord$1$1) : [];
|
|
6241
|
+
if (!Array.isArray(incoming)) {
|
|
6242
|
+
ctx.deletes.push(...collectSecretMarkerRefs(storedRows));
|
|
6243
|
+
return {
|
|
6244
|
+
kind: "value",
|
|
6245
|
+
value: incoming
|
|
6246
|
+
};
|
|
6247
|
+
}
|
|
6248
|
+
const storedById = /* @__PURE__ */ new Map();
|
|
6249
|
+
for (const row of storedRows) {
|
|
6250
|
+
const id = rowId(row, node.idKey);
|
|
6251
|
+
if (id !== null) storedById.set(id, row);
|
|
6252
|
+
}
|
|
6253
|
+
const kept = /* @__PURE__ */ new Set();
|
|
6254
|
+
const rows = [];
|
|
6255
|
+
for (const row of incoming) {
|
|
6256
|
+
if (!isRecord$1$1(row)) {
|
|
6257
|
+
rows.push(row);
|
|
6258
|
+
continue;
|
|
6259
|
+
}
|
|
6260
|
+
const id = rowId(row, node.idKey) ?? ctx.mintId();
|
|
6261
|
+
kept.add(id);
|
|
6262
|
+
const withId = {
|
|
6263
|
+
...row,
|
|
6264
|
+
[node.idKey]: row[node.idKey] ?? id
|
|
6265
|
+
};
|
|
6266
|
+
if (rowId(withId, node.idKey) === null) withId[node.idKey] = id;
|
|
6267
|
+
const storedRow = storedById.get(id) ?? {};
|
|
6268
|
+
rows.push(await writeMembers(ctx, node.item, withId, storedRow, (member) => arrayItemFieldPath(fieldPath, id, member)));
|
|
6269
|
+
}
|
|
6270
|
+
for (const [id, row] of storedById) if (!kept.has(id)) ctx.deletes.push(...collectSecretMarkerRefs(row));
|
|
6271
|
+
return {
|
|
6272
|
+
kind: "value",
|
|
6273
|
+
value: rows
|
|
6274
|
+
};
|
|
6275
|
+
}
|
|
6276
|
+
async function writeNode(ctx, node, incoming, stored, fieldPath) {
|
|
6277
|
+
switch (node.kind) {
|
|
6278
|
+
case "leaf": return writeLeaf(ctx, incoming, stored, fieldPath);
|
|
6279
|
+
case "array": return writeArray(ctx, node, incoming, stored, fieldPath);
|
|
6280
|
+
case "object": {
|
|
6281
|
+
if (!isRecord$1$1(incoming)) {
|
|
6282
|
+
if (incoming === void 0) return KEEP;
|
|
6283
|
+
ctx.deletes.push(...collectSecretMarkerRefs(stored));
|
|
6284
|
+
return {
|
|
6285
|
+
kind: "value",
|
|
6286
|
+
value: incoming
|
|
6287
|
+
};
|
|
6288
|
+
}
|
|
6289
|
+
const storedObj = isRecord$1$1(stored) ? stored : {};
|
|
6290
|
+
return {
|
|
6291
|
+
kind: "value",
|
|
6292
|
+
value: await writeMembers(ctx, node.children, incoming, storedObj, (m) => `${fieldPath}.${m}`)
|
|
6293
|
+
};
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
}
|
|
6297
|
+
/** Split a perNode-scoped key (`key@nodeId`). */
|
|
6298
|
+
function splitNodeKey(key) {
|
|
6299
|
+
const at = key.indexOf("@");
|
|
6300
|
+
return at <= 0 ? {
|
|
6301
|
+
base: key,
|
|
6302
|
+
nodeId: null
|
|
6303
|
+
} : {
|
|
6304
|
+
base: key.slice(0, at),
|
|
6305
|
+
nodeId: key.slice(at + 1)
|
|
6306
|
+
};
|
|
6307
|
+
}
|
|
6308
|
+
/** Rewrite a settings patch so no secret value reaches the blob. See the file doc. */
|
|
6309
|
+
async function transformSecretWrite(input) {
|
|
6310
|
+
const deletes = [];
|
|
6311
|
+
const base = {
|
|
6312
|
+
secrets: input.secrets,
|
|
6313
|
+
mintId: input.mintId ?? defaultMintId,
|
|
6314
|
+
deletes,
|
|
6315
|
+
operatorWrite: input.operatorWrite === true
|
|
6316
|
+
};
|
|
6317
|
+
const out = {};
|
|
6318
|
+
for (const [key, incoming] of Object.entries(input.patch)) {
|
|
6319
|
+
const { base: baseKey, nodeId } = splitNodeKey(key);
|
|
6320
|
+
const node = input.tree.get(baseKey);
|
|
6321
|
+
if (node === void 0) {
|
|
6322
|
+
out[key] = incoming;
|
|
6323
|
+
continue;
|
|
6324
|
+
}
|
|
6325
|
+
const scope = nodeId !== null && nodeId.length > 0 ? {
|
|
6326
|
+
kind: "node",
|
|
6327
|
+
nodeId
|
|
6328
|
+
} : input.scope ?? globalSecretScope();
|
|
6329
|
+
const result = await writeNode({
|
|
6330
|
+
...base,
|
|
6331
|
+
scope
|
|
6332
|
+
}, node, incoming, input.stored[key], baseKey);
|
|
6333
|
+
if (result.kind === "value") out[key] = result.value;
|
|
6334
|
+
}
|
|
6335
|
+
return {
|
|
6336
|
+
patch: out,
|
|
6337
|
+
afterWrite: async () => {
|
|
6338
|
+
if (deletes.length === 0) return { orphaned: [] };
|
|
6339
|
+
try {
|
|
6340
|
+
await input.secrets.delete([...new Set(deletes)]);
|
|
6341
|
+
return { orphaned: [] };
|
|
6342
|
+
} catch {
|
|
6343
|
+
return { orphaned: [...new Set(deletes)] };
|
|
6344
|
+
}
|
|
6345
|
+
}
|
|
6346
|
+
};
|
|
6347
|
+
}
|
|
6348
|
+
/** Is `ref` one of `owner`'s refs? */
|
|
6349
|
+
function isSecretRefOwnedBy(ref, owner) {
|
|
6350
|
+
return parseSecretRef(ref)?.owner === owner;
|
|
6351
|
+
}
|
|
6352
|
+
/**
|
|
6353
|
+
* Replace every marker in `value` with its keychain value. Returns the SAME
|
|
6354
|
+
* reference when there is no marker (no allocation, no keychain call).
|
|
6355
|
+
*/
|
|
6356
|
+
async function resolveSecretMarkers(value, secrets, options = {}) {
|
|
6357
|
+
const keepMarker = options.unresolved === "keep-marker";
|
|
6358
|
+
const owner = options.ownedBy;
|
|
6359
|
+
const inScope = (ref) => owner === void 0 || isSecretRefOwnedBy(ref, owner);
|
|
6360
|
+
const refs = collectSecretMarkerRefs(value).filter(inScope);
|
|
6361
|
+
if (refs.length === 0) return {
|
|
6362
|
+
value,
|
|
6363
|
+
unresolved: []
|
|
6364
|
+
};
|
|
6365
|
+
const answers = await secrets.resolve(refs);
|
|
6366
|
+
const unresolved = [];
|
|
6367
|
+
for (const ref of new Set(refs)) {
|
|
6368
|
+
const answer = answers[ref];
|
|
6369
|
+
if (answer === void 0) unresolved.push({
|
|
6370
|
+
ref,
|
|
6371
|
+
reason: "not-initialized"
|
|
6372
|
+
});
|
|
6373
|
+
else if (answer.kind === "unavailable") unresolved.push({
|
|
6374
|
+
ref,
|
|
6375
|
+
reason: answer.reason
|
|
6376
|
+
});
|
|
6377
|
+
else if (answer.kind === "missing" || answer.kind === "forbidden") unresolved.push({
|
|
6378
|
+
ref,
|
|
6379
|
+
reason: answer.kind
|
|
6380
|
+
});
|
|
6381
|
+
}
|
|
6382
|
+
const substitute = (v) => {
|
|
6383
|
+
if (isSecretMarker(v)) {
|
|
6384
|
+
if (!inScope(v.$secret)) return {
|
|
6385
|
+
keep: true,
|
|
6386
|
+
value: v
|
|
6387
|
+
};
|
|
6388
|
+
const answer = answers[v.$secret];
|
|
6389
|
+
if (answer?.kind === "value") return {
|
|
6390
|
+
keep: true,
|
|
6391
|
+
value: answer.value
|
|
6392
|
+
};
|
|
6393
|
+
return keepMarker ? {
|
|
6394
|
+
keep: true,
|
|
6395
|
+
value: v
|
|
6396
|
+
} : {
|
|
6397
|
+
keep: false,
|
|
6398
|
+
value: void 0
|
|
6399
|
+
};
|
|
6400
|
+
}
|
|
6401
|
+
if (Array.isArray(v)) {
|
|
6402
|
+
const items = [];
|
|
6403
|
+
for (const item of v) {
|
|
6404
|
+
const s = substitute(item);
|
|
6405
|
+
if (s.keep) items.push(s.value);
|
|
6406
|
+
}
|
|
6407
|
+
return {
|
|
6408
|
+
keep: true,
|
|
6409
|
+
value: items
|
|
6410
|
+
};
|
|
6411
|
+
}
|
|
6412
|
+
if (isRecord$1$1(v)) {
|
|
6413
|
+
const out = {};
|
|
6414
|
+
for (const [k, child] of Object.entries(v)) {
|
|
6415
|
+
const s = substitute(child);
|
|
6416
|
+
if (s.keep) out[k] = s.value;
|
|
6417
|
+
}
|
|
6418
|
+
return {
|
|
6419
|
+
keep: true,
|
|
6420
|
+
value: out
|
|
6421
|
+
};
|
|
6422
|
+
}
|
|
6423
|
+
return {
|
|
6424
|
+
keep: true,
|
|
6425
|
+
value: v
|
|
6426
|
+
};
|
|
6427
|
+
};
|
|
6428
|
+
return {
|
|
6429
|
+
value: substitute(value).value,
|
|
6430
|
+
unresolved
|
|
6431
|
+
};
|
|
6432
|
+
}
|
|
6433
|
+
/** An addon tried to replace a stored secret it could not read. Nothing was written. */
|
|
6434
|
+
var SecretOverwriteRefusedError = class extends Error {
|
|
6435
|
+
ref;
|
|
6436
|
+
reason;
|
|
6437
|
+
constructor(ref, reason) {
|
|
6438
|
+
super(`secret ${ref} was not replaced: its stored value cannot be read right now (${reason}), and an addon may not overwrite a secret it cannot see. Nothing was written.`);
|
|
6439
|
+
this.ref = ref;
|
|
6440
|
+
this.reason = reason;
|
|
6441
|
+
this.name = "SecretOverwriteRefusedError";
|
|
6442
|
+
}
|
|
6443
|
+
};
|
|
6444
|
+
function isRecord$3(value) {
|
|
6445
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6446
|
+
}
|
|
6447
|
+
function resolvedValue(pass, marker) {
|
|
6448
|
+
const answer = pass.answers[marker.$secret];
|
|
6449
|
+
return answer?.kind === "value" ? answer.value : null;
|
|
6450
|
+
}
|
|
6451
|
+
async function atMarker(pass, incoming, stored) {
|
|
6452
|
+
if (incoming === null) return stored;
|
|
6453
|
+
if (typeof incoming !== "string") return incoming;
|
|
6454
|
+
if (incoming === resolvedValue(pass, stored)) return stored;
|
|
6455
|
+
const intent = classifySecretWrite(incoming);
|
|
6456
|
+
if (intent.kind !== "set") return stored;
|
|
6457
|
+
const ref = stored.$secret;
|
|
6458
|
+
if (!isSecretRefOwnedBy(ref, pass.secrets.owner)) return incoming;
|
|
6459
|
+
const answer = pass.answers[ref];
|
|
6460
|
+
if ((answer === void 0 || answer.kind === "unavailable" || answer.kind === "forbidden") && !pass.operatorWrite) throw new SecretOverwriteRefusedError(ref, answer === void 0 ? "not-initialized" : answer.kind === "unavailable" ? answer.reason : answer.kind);
|
|
6461
|
+
try {
|
|
6462
|
+
await pass.secrets.put(ref, intent.value);
|
|
6463
|
+
} catch (err) {
|
|
6464
|
+
throw new KeychainWriteRefusedError(ref, err);
|
|
6465
|
+
}
|
|
6466
|
+
pass.changedRefs.push(ref);
|
|
6467
|
+
return stored;
|
|
6468
|
+
}
|
|
6469
|
+
function inArray(pass, incoming, stored) {
|
|
6470
|
+
return incoming.map((item, index) => {
|
|
6471
|
+
const twin = stored[index];
|
|
6472
|
+
if (isSecretMarker(twin)) return typeof item === "string" && item === resolvedValue(pass, twin) ? twin : item;
|
|
6473
|
+
if (isRecord$3(item) && isRecord$3(twin)) return inArrayRow(pass, item, twin);
|
|
6474
|
+
if (Array.isArray(item) && Array.isArray(twin)) return inArray(pass, item, twin);
|
|
6475
|
+
return item;
|
|
6476
|
+
});
|
|
6477
|
+
}
|
|
6478
|
+
function inArrayRow(pass, incoming, stored) {
|
|
6479
|
+
const out = { ...incoming };
|
|
6480
|
+
for (const [key, value] of Object.entries(incoming)) {
|
|
6481
|
+
const twin = stored[key];
|
|
6482
|
+
if (isSecretMarker(twin)) {
|
|
6483
|
+
if (typeof value === "string" && value === resolvedValue(pass, twin)) out[key] = twin;
|
|
6484
|
+
} else if (isRecord$3(value) && isRecord$3(twin)) out[key] = inArrayRow(pass, value, twin);
|
|
6485
|
+
else if (Array.isArray(value) && Array.isArray(twin)) out[key] = inArray(pass, value, twin);
|
|
6486
|
+
}
|
|
6487
|
+
return out;
|
|
6488
|
+
}
|
|
6489
|
+
async function walk(pass, incoming, stored) {
|
|
6490
|
+
if (isSecretMarker(stored)) return atMarker(pass, incoming, stored);
|
|
6491
|
+
if (Array.isArray(incoming) && Array.isArray(stored)) return inArray(pass, incoming, stored);
|
|
6492
|
+
if (!isRecord$3(incoming) || !isRecord$3(stored)) return incoming;
|
|
6493
|
+
const out = { ...incoming };
|
|
6494
|
+
for (const [key, value] of Object.entries(incoming)) out[key] = await walk(pass, value, stored[key]);
|
|
6495
|
+
return out;
|
|
6496
|
+
}
|
|
6497
|
+
/** Restore markers a write-back carries as values. See the file doc. */
|
|
6498
|
+
async function restoreUnchangedSecrets(input) {
|
|
6499
|
+
const refs = [];
|
|
6500
|
+
for (const key of Object.keys(input.patch)) collectSecretMarkerRefs(input.stored[key], refs);
|
|
6501
|
+
const owned = refs.filter((ref) => isSecretRefOwnedBy(ref, input.secrets.owner));
|
|
6502
|
+
if (owned.length === 0) return {
|
|
6503
|
+
patch: input.patch,
|
|
6504
|
+
changedRefs: []
|
|
6505
|
+
};
|
|
6506
|
+
const pass = {
|
|
6507
|
+
secrets: input.secrets,
|
|
6508
|
+
answers: await input.secrets.resolve([...new Set(owned)]),
|
|
6509
|
+
operatorWrite: input.operatorWrite,
|
|
6510
|
+
changedRefs: []
|
|
6511
|
+
};
|
|
6512
|
+
const out = {};
|
|
6513
|
+
for (const [key, value] of Object.entries(input.patch)) out[key] = await walk(pass, value, input.stored[key]);
|
|
6514
|
+
return {
|
|
6515
|
+
patch: out,
|
|
6516
|
+
changedRefs: pass.changedRefs
|
|
6517
|
+
};
|
|
6518
|
+
}
|
|
6519
|
+
/** Structural equality over JSON-shaped values (key order does not matter). */
|
|
6520
|
+
function isJsonEqual(a, b) {
|
|
6521
|
+
if (Object.is(a, b)) return true;
|
|
6522
|
+
if (Array.isArray(a)) return Array.isArray(b) && a.length === b.length && a.every((v, i) => isJsonEqual(v, b[i]));
|
|
6523
|
+
if (isRecord$3(a) && isRecord$3(b)) {
|
|
6524
|
+
const keys = Object.keys(a);
|
|
6525
|
+
if (keys.length !== Object.keys(b).length) return false;
|
|
6526
|
+
return keys.every((k) => Object.prototype.hasOwnProperty.call(b, k) && isJsonEqual(a[k], b[k]));
|
|
6527
|
+
}
|
|
6528
|
+
return false;
|
|
6529
|
+
}
|
|
6530
|
+
/** The patch without the keys whose value already equals the stored one. */
|
|
6531
|
+
function dropUnchangedKeys(patch, stored) {
|
|
6532
|
+
const out = {};
|
|
6533
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
6534
|
+
if (Object.prototype.hasOwnProperty.call(stored, key) && isJsonEqual(value, stored[key])) continue;
|
|
6535
|
+
out[key] = value;
|
|
6536
|
+
}
|
|
6537
|
+
return out;
|
|
6538
|
+
}
|
|
6539
|
+
/** The top-level keys of a blob that hold at least one of `owner`'s markers. */
|
|
6540
|
+
function markerKeysOf(blob, owner) {
|
|
6541
|
+
const keys = /* @__PURE__ */ new Set();
|
|
6542
|
+
for (const [key, value] of Object.entries(blob)) if (collectSecretMarkerRefs(value).some((ref) => isSecretRefOwnedBy(ref, owner))) keys.add(key);
|
|
6543
|
+
return keys;
|
|
6544
|
+
}
|
|
6545
|
+
function nodeFromStored(value, owner) {
|
|
6546
|
+
if (isSecretMarker(value)) return isSecretRefOwnedBy(value.$secret, owner) ? { kind: "leaf" } : null;
|
|
6547
|
+
if (!isRecord$3(value)) return null;
|
|
6548
|
+
const children = /* @__PURE__ */ new Map();
|
|
6549
|
+
for (const [key, child] of Object.entries(value)) {
|
|
6550
|
+
const node = nodeFromStored(child, owner);
|
|
6551
|
+
if (node !== null) children.set(key, node);
|
|
6552
|
+
}
|
|
6553
|
+
return children.size > 0 ? {
|
|
6554
|
+
kind: "object",
|
|
6555
|
+
children
|
|
6556
|
+
} : null;
|
|
6557
|
+
}
|
|
6558
|
+
/**
|
|
6559
|
+
* The declared secret tree, widened by every place the STORED blob holds a
|
|
6560
|
+
* marker under one of `keys` — so a marker the schema no longer declares (or
|
|
6561
|
+
* never declared: Wyze before b4906cec6) still gets the save path's
|
|
6562
|
+
* KEEP / SET / CLEAR semantics instead of being overwritten by whatever the
|
|
6563
|
+
* addon writes. Markers inside arrays are not added: a row has no id field to
|
|
6564
|
+
* match by unless the schema declares one. Only `owner`'s markers count: a
|
|
6565
|
+
* builtin that keeps another addon's marker (device-manager) never takes it
|
|
6566
|
+
* over.
|
|
6567
|
+
*/
|
|
6568
|
+
function widenTreeWithStoredMarkers(declared, stored, keys, owner) {
|
|
6569
|
+
const added = /* @__PURE__ */ new Map();
|
|
6570
|
+
for (const key of keys) {
|
|
6571
|
+
const at = key.indexOf("@");
|
|
6572
|
+
const base = at > 0 ? key.slice(0, at) : key;
|
|
6573
|
+
if (declared.has(base) || added.has(base)) continue;
|
|
6574
|
+
const node = nodeFromStored(stored[key], owner);
|
|
6575
|
+
if (node !== null) added.set(base, node);
|
|
6576
|
+
}
|
|
6577
|
+
return added.size === 0 ? declared : new Map([...declared, ...added]);
|
|
6578
|
+
}
|
|
6579
|
+
/** The blob as stored now; a failed read REFUSES the write instead of guessing. */
|
|
6580
|
+
async function readStoredAddonBlob(raw) {
|
|
6581
|
+
const threeWay = raw.readAddonStoreResult;
|
|
6582
|
+
if (threeWay === void 0) return raw.readAddonStore();
|
|
6583
|
+
const result = await threeWay.call(raw);
|
|
6584
|
+
if (result.kind === "failed") throw new Error(`settings write refused: the stored blob could not be read (${result.error})`);
|
|
6585
|
+
return result.kind === "missing" ? {} : result.value;
|
|
6586
|
+
}
|
|
6587
|
+
function touchesTree(tree, patch) {
|
|
6588
|
+
if (tree.size === 0) return false;
|
|
6589
|
+
for (const key of Object.keys(patch)) {
|
|
6590
|
+
const at = key.indexOf("@");
|
|
6591
|
+
if (tree.has(at > 0 ? key.slice(0, at) : key)) return true;
|
|
6592
|
+
}
|
|
6593
|
+
return false;
|
|
6594
|
+
}
|
|
6595
|
+
/**
|
|
6596
|
+
* Which top-level keys of each store held markers when last seen. `undefined`
|
|
6597
|
+
* for a store not seen yet: its first write reads it, to be safe.
|
|
6598
|
+
*/
|
|
6599
|
+
var MarkerKeyIndex = class {
|
|
6600
|
+
owner;
|
|
6601
|
+
byStore = /* @__PURE__ */ new Map();
|
|
6602
|
+
constructor(owner) {
|
|
6603
|
+
this.owner = owner;
|
|
6604
|
+
}
|
|
6605
|
+
seen(store, blob) {
|
|
6606
|
+
this.byStore.set(store, markerKeysOf(blob, this.owner));
|
|
6607
|
+
}
|
|
6608
|
+
wrote(store, patch) {
|
|
6609
|
+
const keys = this.byStore.get(store);
|
|
6610
|
+
if (keys === void 0) return;
|
|
6611
|
+
const now = markerKeysOf(patch, this.owner);
|
|
6612
|
+
for (const key of Object.keys(patch)) if (now.has(key)) keys.add(key);
|
|
6613
|
+
else keys.delete(key);
|
|
6614
|
+
}
|
|
6615
|
+
mayHoldMarkers(store, patch) {
|
|
6616
|
+
const keys = this.byStore.get(store);
|
|
6617
|
+
if (keys === void 0) return true;
|
|
6618
|
+
return Object.keys(patch).some((key) => keys.has(key));
|
|
6619
|
+
}
|
|
6620
|
+
};
|
|
6621
|
+
function createHandle(raw, opts) {
|
|
6622
|
+
const chains = /* @__PURE__ */ new Map();
|
|
6623
|
+
const serialize = (key, fn) => {
|
|
6624
|
+
const next = (chains.get(key) ?? Promise.resolve()).then(fn, fn);
|
|
6625
|
+
const tail = next.catch(() => void 0);
|
|
6626
|
+
chains.set(key, tail);
|
|
6627
|
+
tail.then(() => {
|
|
6628
|
+
if (chains.get(key) === tail) chains.delete(key);
|
|
6629
|
+
});
|
|
6630
|
+
return next;
|
|
6631
|
+
};
|
|
6632
|
+
const index = new MarkerKeyIndex(opts.secrets.owner);
|
|
6633
|
+
const resolveRead = async (store, blob) => {
|
|
6634
|
+
index.seen(store, blob);
|
|
6635
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, opts.secrets, {
|
|
6636
|
+
unresolved: "keep-marker",
|
|
6637
|
+
ownedBy: opts.secrets.owner
|
|
6638
|
+
});
|
|
6639
|
+
if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
|
|
6640
|
+
return value;
|
|
6641
|
+
};
|
|
6642
|
+
const write = async (store, declared, scope, patch, readStored, rawWrite) => {
|
|
6643
|
+
if (!touchesTree(declared, patch) && !index.mayHoldMarkers(store, patch)) {
|
|
6644
|
+
await rawWrite(patch);
|
|
6645
|
+
index.wrote(store, patch);
|
|
6646
|
+
return { changed: true };
|
|
6647
|
+
}
|
|
6648
|
+
return serialize(store, async () => {
|
|
6649
|
+
const stored = await readStored();
|
|
6650
|
+
index.seen(store, stored);
|
|
6651
|
+
const operatorWrite = opts.isOperatorWrite?.() === true;
|
|
6652
|
+
const restored = await restoreUnchangedSecrets({
|
|
6653
|
+
patch,
|
|
6654
|
+
stored,
|
|
6655
|
+
secrets: opts.secrets,
|
|
6656
|
+
operatorWrite
|
|
6657
|
+
});
|
|
6658
|
+
const result = await transformSecretWrite({
|
|
6659
|
+
tree: widenTreeWithStoredMarkers(declared, stored, Object.keys(restored.patch), opts.secrets.owner),
|
|
6660
|
+
secrets: opts.secrets,
|
|
6661
|
+
patch: restored.patch,
|
|
6662
|
+
stored,
|
|
6663
|
+
...scope !== void 0 ? { scope } : {},
|
|
6664
|
+
operatorWrite
|
|
6665
|
+
});
|
|
6666
|
+
const effective = dropUnchangedKeys(result.patch, stored);
|
|
6667
|
+
const wroteBlob = Object.keys(effective).length > 0;
|
|
6668
|
+
if (wroteBlob) {
|
|
6669
|
+
await rawWrite(effective);
|
|
6670
|
+
index.wrote(store, effective);
|
|
6671
|
+
}
|
|
6672
|
+
const { orphaned } = await result.afterWrite();
|
|
6673
|
+
if (orphaned.length > 0) opts.onOrphaned(orphaned);
|
|
6674
|
+
return { changed: wroteBlob || restored.changedRefs.length > 0 };
|
|
6675
|
+
});
|
|
6676
|
+
};
|
|
6677
|
+
const writeAddon = (patch) => write("addon", opts.addonTree(), void 0, patch, () => readStoredAddonBlob(raw), (p) => raw.writeAddonStore(p));
|
|
6678
|
+
const readAddonStoreResult = raw.readAddonStoreResult;
|
|
6679
|
+
const readAddonStoreKeyResult = raw.readAddonStoreKeyResult;
|
|
6680
|
+
const readDeviceStoreBatch = raw.readDeviceStoreBatch;
|
|
6681
|
+
const overrides = {
|
|
6682
|
+
readAddonStore: async () => resolveRead("addon", await raw.readAddonStore()),
|
|
6683
|
+
...readAddonStoreResult !== void 0 ? { readAddonStoreResult: async () => {
|
|
6684
|
+
const result = await readAddonStoreResult.call(raw);
|
|
6685
|
+
return result.kind === "value" ? {
|
|
6686
|
+
kind: "value",
|
|
6687
|
+
value: await resolveRead("addon", result.value)
|
|
6688
|
+
} : result;
|
|
6689
|
+
} } : {},
|
|
6690
|
+
...readAddonStoreKeyResult !== void 0 ? { readAddonStoreKeyResult: async (key) => {
|
|
6691
|
+
const result = await readAddonStoreKeyResult.call(raw, key);
|
|
6692
|
+
if (result.kind !== "present") return result;
|
|
6693
|
+
const { value, unresolved } = await resolveSecretMarkers({ [key]: result.value }, opts.secrets, {
|
|
6694
|
+
unresolved: "keep-marker",
|
|
6695
|
+
ownedBy: opts.secrets.owner
|
|
6696
|
+
});
|
|
6697
|
+
if (unresolved.length > 0) opts.onUnresolved?.(unresolved);
|
|
6698
|
+
return {
|
|
6699
|
+
kind: "present",
|
|
6700
|
+
value: value[key]
|
|
6701
|
+
};
|
|
6702
|
+
} } : {},
|
|
6703
|
+
readDeviceStore: async (deviceId) => resolveRead(`device:${deviceId}`, await raw.readDeviceStore(deviceId)),
|
|
6704
|
+
...readDeviceStoreBatch !== void 0 ? { readDeviceStoreBatch: async (deviceIds) => {
|
|
6705
|
+
const rows = await readDeviceStoreBatch.call(raw, deviceIds);
|
|
6706
|
+
const out = /* @__PURE__ */ new Map();
|
|
6707
|
+
for (const [deviceId, blob] of rows) out.set(deviceId, await resolveRead(`device:${deviceId}`, blob));
|
|
6708
|
+
return out;
|
|
6709
|
+
} } : {},
|
|
6710
|
+
writeAddonStore: async (patch) => {
|
|
6711
|
+
await writeAddon(patch);
|
|
6712
|
+
},
|
|
6713
|
+
writeDeviceStore: async (deviceId, patch) => {
|
|
6714
|
+
await write(`device:${deviceId}`, opts.deviceTree(), {
|
|
6715
|
+
kind: "device",
|
|
6716
|
+
deviceId
|
|
6717
|
+
}, patch, () => raw.readDeviceStore(deviceId), (p) => raw.writeDeviceStore(deviceId, p));
|
|
6718
|
+
}
|
|
6719
|
+
};
|
|
6720
|
+
return {
|
|
6721
|
+
settings: new Proxy(raw, { get(target, prop, receiver) {
|
|
6722
|
+
if (typeof prop === "string" && Object.prototype.hasOwnProperty.call(overrides, prop)) return Reflect.get(overrides, prop);
|
|
6723
|
+
const value = Reflect.get(target, prop, receiver);
|
|
6724
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
6725
|
+
} }),
|
|
6726
|
+
raw: {
|
|
6727
|
+
readAddonStore: async () => {
|
|
6728
|
+
const blob = await raw.readAddonStore();
|
|
6729
|
+
index.seen("addon", blob);
|
|
6730
|
+
return blob;
|
|
6731
|
+
},
|
|
6732
|
+
readDeviceStore: async (deviceId) => {
|
|
6733
|
+
const blob = await raw.readDeviceStore(deviceId);
|
|
6734
|
+
index.seen(`device:${deviceId}`, blob);
|
|
6735
|
+
return blob;
|
|
6736
|
+
}
|
|
6737
|
+
},
|
|
6738
|
+
writeAddonStore: writeAddon
|
|
6739
|
+
};
|
|
6740
|
+
}
|
|
6741
|
+
/** The context the addon sees, plus the private raw view and write outcome. */
|
|
6742
|
+
function createSecretAwareContext(context, opts) {
|
|
6743
|
+
const raw = context.settings;
|
|
6744
|
+
if (raw === void 0) return {
|
|
6745
|
+
context,
|
|
6746
|
+
handle: null
|
|
6747
|
+
};
|
|
6748
|
+
const handle = createHandle(raw, opts);
|
|
6749
|
+
return {
|
|
6750
|
+
context: new Proxy(context, { get(target, prop, receiver) {
|
|
6751
|
+
if (prop === "settings") return handle.settings;
|
|
6752
|
+
return Reflect.get(target, prop, receiver);
|
|
6753
|
+
} }),
|
|
6754
|
+
handle
|
|
6755
|
+
};
|
|
6756
|
+
}
|
|
6757
|
+
var LEAF = { kind: "leaf" };
|
|
6758
|
+
var DEFAULT_ITEM_ID_KEY = "id";
|
|
6759
|
+
function collectFields(fields, out) {
|
|
6760
|
+
for (const field of fields) {
|
|
6761
|
+
if (field.type === "group") {
|
|
6762
|
+
collectFields(field.fields, out);
|
|
6763
|
+
continue;
|
|
6764
|
+
}
|
|
6765
|
+
if (field.type === "sub-tabs") {
|
|
6766
|
+
for (const tab of field.tabs) collectFields(tab.fields, out);
|
|
6767
|
+
continue;
|
|
6768
|
+
}
|
|
6769
|
+
if (field.type === "editable-array") {
|
|
6770
|
+
const item = /* @__PURE__ */ new Map();
|
|
6771
|
+
for (const itemField of field.itemFields) if ("key" in itemField && isKeychainStoredField(itemField)) item.set(itemField.key, LEAF);
|
|
6772
|
+
if (item.size > 0) out.set(field.key, {
|
|
6773
|
+
kind: "array",
|
|
6774
|
+
idKey: field.itemIdKey ?? DEFAULT_ITEM_ID_KEY,
|
|
6775
|
+
item
|
|
6776
|
+
});
|
|
6777
|
+
continue;
|
|
6778
|
+
}
|
|
6779
|
+
if (!("key" in field) || typeof field.key !== "string") continue;
|
|
6780
|
+
if (isKeychainStoredField(field)) out.set(field.key, LEAF);
|
|
6781
|
+
}
|
|
6782
|
+
}
|
|
6783
|
+
/** The secret tree a settings schema declares. */
|
|
6784
|
+
function secretTreeFromSchema(schema) {
|
|
6785
|
+
const out = /* @__PURE__ */ new Map();
|
|
6786
|
+
if (schema === null) return out;
|
|
6787
|
+
for (const section of schema.sections) collectFields(section.fields, out);
|
|
6788
|
+
return out;
|
|
6789
|
+
}
|
|
6790
|
+
/** Parse `a.b[id].c` into segments; throws on a malformed path (a declaration bug). */
|
|
6791
|
+
function parseSecretStatePath(path) {
|
|
6792
|
+
const segments = [];
|
|
6793
|
+
for (const raw of path.split(".")) {
|
|
6794
|
+
const m = /^([^[\]]+)(?:\[([^[\]]+)\])?$/.exec(raw);
|
|
6795
|
+
if (m === null || m[1] === void 0) throw new Error(`secretStatePaths: malformed path "${path}"`);
|
|
6796
|
+
segments.push(m[2] !== void 0 ? {
|
|
6797
|
+
key: m[1],
|
|
6798
|
+
idKey: m[2]
|
|
6799
|
+
} : { key: m[1] });
|
|
6800
|
+
}
|
|
6801
|
+
if (segments.length === 0) throw new Error(`secretStatePaths: empty path`);
|
|
6802
|
+
if (segments[segments.length - 1]?.idKey !== void 0) throw new Error(`secretStatePaths: "${path}" ends on an array — name the member that is secret`);
|
|
6803
|
+
return segments;
|
|
6804
|
+
}
|
|
6805
|
+
function insert(into, segments) {
|
|
6806
|
+
const [head, ...rest] = segments;
|
|
6807
|
+
if (head === void 0) return;
|
|
6808
|
+
if (rest.length === 0) {
|
|
6809
|
+
into.set(head.key, LEAF);
|
|
6810
|
+
return;
|
|
6811
|
+
}
|
|
6812
|
+
const existing = into.get(head.key);
|
|
6813
|
+
if (head.idKey !== void 0) {
|
|
6814
|
+
const item = new Map(existing?.kind === "array" ? existing.item : []);
|
|
6815
|
+
insert(item, rest);
|
|
6816
|
+
into.set(head.key, {
|
|
6817
|
+
kind: "array",
|
|
6818
|
+
idKey: head.idKey,
|
|
6819
|
+
item
|
|
6820
|
+
});
|
|
6821
|
+
return;
|
|
6822
|
+
}
|
|
6823
|
+
const children = new Map(existing?.kind === "object" ? existing.children : []);
|
|
6824
|
+
insert(children, rest);
|
|
6825
|
+
into.set(head.key, {
|
|
6826
|
+
kind: "object",
|
|
6827
|
+
children
|
|
6828
|
+
});
|
|
6829
|
+
}
|
|
6830
|
+
/** Add hidden-state paths (`secretStatePaths`) to a schema-derived tree. */
|
|
6831
|
+
function mergeSecretStatePaths(tree, paths) {
|
|
6832
|
+
if (paths.length === 0) return tree;
|
|
6833
|
+
const out = new Map(tree);
|
|
6834
|
+
for (const path of paths) insert(out, parseSecretStatePath(path));
|
|
6835
|
+
return out;
|
|
6836
|
+
}
|
|
6837
|
+
/** First retry of a secret the keychain could not serve; doubles to {@link SECRET_RETRY_MAX_MS}. */
|
|
6838
|
+
var SECRET_RETRY_FIRST_MS = 5e3;
|
|
6839
|
+
var SECRET_RETRY_MAX_MS = 5 * 6e4;
|
|
6840
|
+
/** Coalesces a burst of `keychain.changed` events into one re-resolve. */
|
|
6841
|
+
var SECRET_CHANGE_DEBOUNCE_MS = 250;
|
|
5959
6842
|
/**
|
|
5960
6843
|
* Base class for CamStack addons. Eliminates settings boilerplate:
|
|
5961
6844
|
*
|
|
@@ -6025,6 +6908,33 @@ var BaseAddon = class {
|
|
|
6025
6908
|
settingsStoreReady = false;
|
|
6026
6909
|
/** Default config values. Provided via constructor. */
|
|
6027
6910
|
defaults;
|
|
6911
|
+
/**
|
|
6912
|
+
* Hidden-state paths that hold secrets (D787) — values the addon writes
|
|
6913
|
+
* itself (`updateGlobalSettings`, `state()`) that no form field declares.
|
|
6914
|
+
* Stored in the keychain exactly like a `password` field. Syntax:
|
|
6915
|
+
* `'snapshotSigningKey'`, `'identity.pincode'`, `'tokens[userId].accessToken'`
|
|
6916
|
+
* (`key[<id field>]` addresses array items by id, never by index).
|
|
6917
|
+
*/
|
|
6918
|
+
secretStatePaths = [];
|
|
6919
|
+
_addonSecretTree = null;
|
|
6920
|
+
_deviceSecretTree = null;
|
|
6921
|
+
/** Refs the last resolved config pointed at — a change to one re-resolves. */
|
|
6922
|
+
_configSecretRefs = /* @__PURE__ */ new Set();
|
|
6923
|
+
_unresolvedSecrets = [];
|
|
6924
|
+
_secretRetryTimer = null;
|
|
6925
|
+
_secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
6926
|
+
_secretChangeTimer = null;
|
|
6927
|
+
_secretChangeUnsub = null;
|
|
6928
|
+
/** >0 while an OPERATOR's settings write is being applied. */
|
|
6929
|
+
_operatorWriteDepth = 0;
|
|
6930
|
+
/**
|
|
6931
|
+
* The keychain-aware settings handle (D798). Its `raw` view is the ONLY way
|
|
6932
|
+
* to the marker-bearing blobs and stays private to this class: the form
|
|
6933
|
+
* hydrate and config resolution need markers, addon code never does.
|
|
6934
|
+
*/
|
|
6935
|
+
_secretSettings = null;
|
|
6936
|
+
/** Refs an addon-facing read could not resolve — each is logged once per process. */
|
|
6937
|
+
_loggedUnresolvedReads = /* @__PURE__ */ new Set();
|
|
6028
6938
|
constructor(defaults) {
|
|
6029
6939
|
this.defaults = defaults;
|
|
6030
6940
|
this._config = { ...defaults };
|
|
@@ -6060,8 +6970,26 @@ var BaseAddon = class {
|
|
|
6060
6970
|
return this._config;
|
|
6061
6971
|
}
|
|
6062
6972
|
async initialize(context) {
|
|
6063
|
-
|
|
6973
|
+
const secrets = context.secrets;
|
|
6974
|
+
if (secrets !== void 0) {
|
|
6975
|
+
const { context: wrapped, handle } = createSecretAwareContext(context, {
|
|
6976
|
+
secrets,
|
|
6977
|
+
addonTree: () => this.addonSecretTree(),
|
|
6978
|
+
deviceTree: () => this.deviceSecretTree(),
|
|
6979
|
+
onOrphaned: (refs) => context.logger.warn("keychain refs dropped by a settings write could not be deleted", { meta: { refs: [...refs] } }),
|
|
6980
|
+
isOperatorWrite: () => this._operatorWriteDepth > 0,
|
|
6981
|
+
onUnresolved: (unresolved) => this.logUnresolvedRead(unresolved)
|
|
6982
|
+
});
|
|
6983
|
+
this._ctx = wrapped;
|
|
6984
|
+
this._secretSettings = handle;
|
|
6985
|
+
} else {
|
|
6986
|
+
this._ctx = context;
|
|
6987
|
+
this._secretSettings = null;
|
|
6988
|
+
}
|
|
6064
6989
|
await this.resolveConfig();
|
|
6990
|
+
if (secrets !== void 0) this._secretChangeUnsub = secrets.onChange((ref) => {
|
|
6991
|
+
if (this._configSecretRefs.has(ref)) this.scheduleSecretReresolve(SECRET_CHANGE_DEBOUNCE_MS);
|
|
6992
|
+
});
|
|
6065
6993
|
const result = await this.onInitialize();
|
|
6066
6994
|
this.emitLifecycle(EventCategory.AddonStarted);
|
|
6067
6995
|
const normalized = normalizeAddonInitResult(result);
|
|
@@ -6094,6 +7022,12 @@ var BaseAddon = class {
|
|
|
6094
7022
|
*/
|
|
6095
7023
|
async onHubReachable() {}
|
|
6096
7024
|
async shutdown() {
|
|
7025
|
+
this._secretChangeUnsub?.();
|
|
7026
|
+
this._secretChangeUnsub = null;
|
|
7027
|
+
if (this._secretRetryTimer !== null) clearTimeout(this._secretRetryTimer);
|
|
7028
|
+
if (this._secretChangeTimer !== null) clearTimeout(this._secretChangeTimer);
|
|
7029
|
+
this._secretRetryTimer = null;
|
|
7030
|
+
this._secretChangeTimer = null;
|
|
6097
7031
|
this.emitLifecycle(EventCategory.AddonStopped);
|
|
6098
7032
|
if (this.autoEmitReadiness) this.emitReadinessForProviders("down");
|
|
6099
7033
|
await this.onShutdown();
|
|
@@ -6168,11 +7102,8 @@ var BaseAddon = class {
|
|
|
6168
7102
|
async getGlobalSettings(overlay, cap, nodeId) {
|
|
6169
7103
|
const schema = this.globalSettingsSchema(cap);
|
|
6170
7104
|
if (!schema) return { sections: [] };
|
|
6171
|
-
const projected = await this.
|
|
6172
|
-
return hydrateSchema(schema, overlay ? {
|
|
6173
|
-
...projected,
|
|
6174
|
-
...overlay
|
|
6175
|
-
} : projected);
|
|
7105
|
+
const projected = await this.readRawProjectedStore(nodeId, cap);
|
|
7106
|
+
return hydrateSchema(schema, overlay ? await this.overlayKeepingMarkers(projected, overlay) : projected, { inlineSecretsAsViews: true });
|
|
6176
7107
|
}
|
|
6177
7108
|
/**
|
|
6178
7109
|
* The integration-level view of this addon's settings: exactly the sections
|
|
@@ -6217,11 +7148,11 @@ var BaseAddon = class {
|
|
|
6217
7148
|
});
|
|
6218
7149
|
}
|
|
6219
7150
|
if (sections.length === 0) return null;
|
|
6220
|
-
const projected = await this.
|
|
7151
|
+
const projected = await this.readRawProjectedStore(nodeId);
|
|
6221
7152
|
return hydrateSchema({
|
|
6222
7153
|
...schema,
|
|
6223
7154
|
sections
|
|
6224
|
-
}, projected);
|
|
7155
|
+
}, projected, { inlineSecretsAsViews: true });
|
|
6225
7156
|
}
|
|
6226
7157
|
/**
|
|
6227
7158
|
* The raw addon store PROJECTED onto the target node's bare per-node keys:
|
|
@@ -6234,12 +7165,50 @@ var BaseAddon = class {
|
|
|
6234
7165
|
* the store for custom option logic (option narrowing, value snapping) to
|
|
6235
7166
|
* read it per-node — never `ctx.settings.readAddonStore()` directly.
|
|
6236
7167
|
* `nodeId` omitted ⇒ the local node (node-blind injection from ctx).
|
|
7168
|
+
*
|
|
7169
|
+
* Keychain values come back RESOLVED (D798): a secret reads as its value,
|
|
7170
|
+
* never as a `{ $secret }` marker. One the keychain cannot serve right now
|
|
7171
|
+
* stays a marker — "stored, unavailable" (`isSecretMarker()` is true, and it
|
|
7172
|
+
* is listed in {@link unresolvedSecrets}) — never `''` and never absent, so
|
|
7173
|
+
* it cannot be mistaken for "nothing stored, mint a new one". Writing the
|
|
7174
|
+
* resolved blob back is a no-op for every unchanged secret.
|
|
6237
7175
|
*/
|
|
6238
7176
|
async resolveGlobalStore(nodeId, cap) {
|
|
6239
7177
|
const raw = await this._ctx?.settings?.readAddonStore() ?? {};
|
|
7178
|
+
return this.projectForNode(raw, nodeId, cap);
|
|
7179
|
+
}
|
|
7180
|
+
projectForNode(store, nodeId, cap) {
|
|
6240
7181
|
const keys = this.perNodeKeys(cap);
|
|
6241
7182
|
const node = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6242
|
-
return keys.size > 0 ? projectStore(
|
|
7183
|
+
return keys.size > 0 ? projectStore(store, keys, node) : store;
|
|
7184
|
+
}
|
|
7185
|
+
/** The PROJECTED store with its markers — the form hydrate only (D798). */
|
|
7186
|
+
async readRawProjectedStore(nodeId, cap) {
|
|
7187
|
+
const raw = await this.rawSettings()?.readAddonStore() ?? {};
|
|
7188
|
+
return this.projectForNode(raw, nodeId, cap);
|
|
7189
|
+
}
|
|
7190
|
+
/**
|
|
7191
|
+
* `{ ...stored, ...overlay }`, except that an overlay member equal to the
|
|
7192
|
+
* RESOLVED stored one keeps the stored (marker-bearing) member — so a form
|
|
7193
|
+
* hydrated from a resolved overlay still shows a secret as "set", never as
|
|
7194
|
+
* its value.
|
|
7195
|
+
*/
|
|
7196
|
+
async overlayKeepingMarkers(stored, overlay) {
|
|
7197
|
+
const secrets = this._ctx?.secrets;
|
|
7198
|
+
const merged = {
|
|
7199
|
+
...stored,
|
|
7200
|
+
...overlay
|
|
7201
|
+
};
|
|
7202
|
+
if (secrets === void 0 || collectSecretMarkerRefs(stored).length === 0) return merged;
|
|
7203
|
+
const { value: resolved } = await resolveSecretMarkers(stored, secrets, {
|
|
7204
|
+
unresolved: "keep-marker",
|
|
7205
|
+
ownedBy: secrets.owner
|
|
7206
|
+
});
|
|
7207
|
+
for (const key of Object.keys(overlay)) {
|
|
7208
|
+
if (collectSecretMarkerRefs(stored[key]).length === 0) continue;
|
|
7209
|
+
if (isJsonEqual(overlay[key], resolved[key])) merged[key] = stored[key];
|
|
7210
|
+
}
|
|
7211
|
+
return merged;
|
|
6243
7212
|
}
|
|
6244
7213
|
/**
|
|
6245
7214
|
* Whether ONE global key of this addon's store was written, read three-way
|
|
@@ -6275,18 +7244,58 @@ var BaseAddon = class {
|
|
|
6275
7244
|
value: result.value[key]
|
|
6276
7245
|
};
|
|
6277
7246
|
}
|
|
7247
|
+
/**
|
|
7248
|
+
* The OPERATOR's write — a settings form or an admin API call, dispatched by
|
|
7249
|
+
* the kernel. Identical to {@link updateGlobalSettings}, except that a secret
|
|
7250
|
+
* the operator sends is stored as sent even when it equals a pre-keychain
|
|
7251
|
+
* inline value: the operator re-entering a password is a change, an addon
|
|
7252
|
+
* writing back what it read is not (D787).
|
|
7253
|
+
*/
|
|
7254
|
+
async updateGlobalSettingsAsOperator(patch, nodeId) {
|
|
7255
|
+
this._operatorWriteDepth++;
|
|
7256
|
+
try {
|
|
7257
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7258
|
+
} finally {
|
|
7259
|
+
this._operatorWriteDepth--;
|
|
7260
|
+
}
|
|
7261
|
+
}
|
|
6278
7262
|
async updateGlobalSettings(patch, nodeId) {
|
|
7263
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7264
|
+
}
|
|
7265
|
+
/**
|
|
7266
|
+
* REMOVE stored secrets — their keychain values and their markers (D787).
|
|
7267
|
+
*
|
|
7268
|
+
* Writing `''` to a secret field KEEPS what is stored (an empty string is
|
|
7269
|
+
* what a defaults fallback writes back, and it must never destroy a
|
|
7270
|
+
* credential), so code that means "forget this token" says so here. Without
|
|
7271
|
+
* a keychain (an older kernel) it writes `''`, as such code always did.
|
|
7272
|
+
*/
|
|
7273
|
+
async clearSecrets(keys, nodeId) {
|
|
7274
|
+
const tree = this.addonSecretTree();
|
|
7275
|
+
const keychain = this._ctx?.secrets !== void 0;
|
|
7276
|
+
const stored = keychain ? await this.readAddonStoreWithRetry() : {};
|
|
7277
|
+
const patch = {};
|
|
7278
|
+
for (const key of keys) {
|
|
7279
|
+
const keychainStored = tree.has(key) || collectSecretMarkerRefs(stored[key]).length > 0;
|
|
7280
|
+
patch[key] = keychain && keychainStored ? SECRET_CLEAR : "";
|
|
7281
|
+
}
|
|
7282
|
+
await this.applyGlobalPatch(patch, nodeId);
|
|
7283
|
+
}
|
|
7284
|
+
async applyGlobalPatch(barePatch, nodeId) {
|
|
6279
7285
|
const keys = this.perNodeKeys();
|
|
6280
7286
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6281
7287
|
const target = normalizeNodeId(nodeId ?? this._ctx?.kernel?.localNodeId);
|
|
6282
|
-
const barePatch = patch;
|
|
6283
7288
|
const scoped = keys.size > 0 ? scopePatch(barePatch, keys, target) : barePatch;
|
|
6284
|
-
|
|
7289
|
+
const handle = this._secretSettings;
|
|
7290
|
+
if (handle !== null) {
|
|
7291
|
+
const { changed } = await handle.writeAddonStore(scoped);
|
|
7292
|
+
if (!changed) return;
|
|
7293
|
+
} else await this._ctx?.settings?.writeAddonStore(scoped);
|
|
6285
7294
|
if (target !== localNode) return;
|
|
6286
7295
|
await this.resolveConfig();
|
|
6287
7296
|
await this.onConfigChanged();
|
|
6288
7297
|
this.emitLifecycle(EventCategory.AddonUpdated, { level: "global" });
|
|
6289
|
-
this.maybeAutoRestart(
|
|
7298
|
+
this.maybeAutoRestart(Object.keys(barePatch), this.globalSettingsSchema());
|
|
6290
7299
|
}
|
|
6291
7300
|
/**
|
|
6292
7301
|
* The set of field keys the global settings schema declares `perNode: true`
|
|
@@ -6311,7 +7320,7 @@ var BaseAddon = class {
|
|
|
6311
7320
|
* time to return its response before the addon is torn down and
|
|
6312
7321
|
* re-initialised by `AddonRegistryService.restartAddon`.
|
|
6313
7322
|
*/
|
|
6314
|
-
maybeAutoRestart(
|
|
7323
|
+
maybeAutoRestart(patchKeys, schema) {
|
|
6315
7324
|
if (!schema) return;
|
|
6316
7325
|
const restartKeys = /* @__PURE__ */ new Set();
|
|
6317
7326
|
for (const section of schema.sections) for (const field of section.fields) {
|
|
@@ -6319,13 +7328,13 @@ var BaseAddon = class {
|
|
|
6319
7328
|
if (field.requiresRestart) restartKeys.add(field.key);
|
|
6320
7329
|
}
|
|
6321
7330
|
if (restartKeys.size === 0) return;
|
|
6322
|
-
if (!
|
|
7331
|
+
if (!patchKeys.some((k) => restartKeys.has(k))) return;
|
|
6323
7332
|
const ctx = this._ctx;
|
|
6324
7333
|
if (!ctx) return;
|
|
6325
7334
|
const addonId = ctx.id;
|
|
6326
7335
|
setImmediate(() => {
|
|
6327
7336
|
ctx.api.addons?.restartAddon?.mutate({ addonId }).then(() => {
|
|
6328
|
-
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields:
|
|
7337
|
+
ctx.logger.info("addon auto-restart triggered by restart-required setting change", { meta: { changedFields: patchKeys.filter((k) => restartKeys.has(k)) } });
|
|
6329
7338
|
}).catch((err) => {
|
|
6330
7339
|
ctx.logger.error("addon auto-restart failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
6331
7340
|
});
|
|
@@ -6334,7 +7343,7 @@ var BaseAddon = class {
|
|
|
6334
7343
|
async getDeviceSettings(deviceId) {
|
|
6335
7344
|
const schema = this.deviceSettingsSchema();
|
|
6336
7345
|
if (!schema) return { sections: [] };
|
|
6337
|
-
return hydrateSchema(schema, await this.
|
|
7346
|
+
return hydrateSchema(schema, await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, { inlineSecretsAsViews: true });
|
|
6338
7347
|
}
|
|
6339
7348
|
async updateDeviceSettings(deviceId, patch) {
|
|
6340
7349
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
@@ -6464,7 +7473,7 @@ var BaseAddon = class {
|
|
|
6464
7473
|
* selection at boot (absent scoped key ⇒ the constructor default wins).
|
|
6465
7474
|
*/
|
|
6466
7475
|
async resolveConfig() {
|
|
6467
|
-
const stored = await this.readAddonStoreWithRetry();
|
|
7476
|
+
const stored = await this.resolveStoredSecrets(await this.readAddonStoreWithRetry());
|
|
6468
7477
|
const perNode = this.perNodeKeys();
|
|
6469
7478
|
const localNode = normalizeNodeId(this._ctx?.kernel?.localNodeId);
|
|
6470
7479
|
const resolved = { ...this.defaults };
|
|
@@ -6489,7 +7498,7 @@ var BaseAddon = class {
|
|
|
6489
7498
|
key,
|
|
6490
7499
|
schema,
|
|
6491
7500
|
fallback,
|
|
6492
|
-
read: () => this.readAddonStoreWithRetry(),
|
|
7501
|
+
read: async () => this.resolveStoredSecrets(await this.readAddonStoreWithRetry()),
|
|
6493
7502
|
write: async (patch) => {
|
|
6494
7503
|
await this._ctx?.settings?.writeAddonStore(patch);
|
|
6495
7504
|
},
|
|
@@ -6506,7 +7515,7 @@ var BaseAddon = class {
|
|
|
6506
7515
|
key,
|
|
6507
7516
|
schema,
|
|
6508
7517
|
fallback,
|
|
6509
|
-
read: async () => await this.
|
|
7518
|
+
read: async () => this.resolveStoredSecrets(await this.rawSettings()?.readDeviceStore(deviceId) ?? {}, false),
|
|
6510
7519
|
write: async (patch) => {
|
|
6511
7520
|
await this._ctx?.settings?.writeDeviceStore(deviceId, patch);
|
|
6512
7521
|
},
|
|
@@ -6518,6 +7527,87 @@ var BaseAddon = class {
|
|
|
6518
7527
|
} })
|
|
6519
7528
|
});
|
|
6520
7529
|
}
|
|
7530
|
+
/** The addon store's secret tree: schema fields by TYPE, plus `secretStatePaths`. */
|
|
7531
|
+
addonSecretTree() {
|
|
7532
|
+
this._addonSecretTree ??= mergeSecretStatePaths(secretTreeFromSchema(this.globalSettingsSchema()), this.secretStatePaths);
|
|
7533
|
+
return this._addonSecretTree;
|
|
7534
|
+
}
|
|
7535
|
+
deviceSecretTree() {
|
|
7536
|
+
this._deviceSecretTree ??= secretTreeFromSchema(this.deviceSettingsSchema());
|
|
7537
|
+
return this._deviceSecretTree;
|
|
7538
|
+
}
|
|
7539
|
+
/**
|
|
7540
|
+
* Secrets of this addon's stored config that could not be resolved on the
|
|
7541
|
+
* last read, with why. Non-empty means the addon is running WITHOUT them —
|
|
7542
|
+
* an addon whose function needs one should report itself degraded rather
|
|
7543
|
+
* than start on an empty credential.
|
|
7544
|
+
*/
|
|
7545
|
+
get unresolvedSecrets() {
|
|
7546
|
+
return this._unresolvedSecrets;
|
|
7547
|
+
}
|
|
7548
|
+
/**
|
|
7549
|
+
* Substitute every keychain marker in a stored blob with its value. With no
|
|
7550
|
+
* keychain (no `ctx.secrets`) or no marker, the blob comes back unchanged.
|
|
7551
|
+
* An unresolvable value is LEFT OUT (never `''`), logged by ref — never by
|
|
7552
|
+
* value — and, when the cause can pass, retried with backoff. Nothing is
|
|
7553
|
+
* ever written back from here.
|
|
7554
|
+
*/
|
|
7555
|
+
async resolveStoredSecrets(blob, trackForConfig = true) {
|
|
7556
|
+
const secrets = this._ctx?.secrets;
|
|
7557
|
+
if (secrets === void 0) return blob;
|
|
7558
|
+
const refs = collectSecretMarkerRefs(blob);
|
|
7559
|
+
if (trackForConfig) this._configSecretRefs = new Set(refs);
|
|
7560
|
+
if (refs.length === 0) {
|
|
7561
|
+
if (trackForConfig) this._unresolvedSecrets = [];
|
|
7562
|
+
return blob;
|
|
7563
|
+
}
|
|
7564
|
+
const { value, unresolved } = await resolveSecretMarkers(blob, secrets);
|
|
7565
|
+
if (trackForConfig) {
|
|
7566
|
+
this._unresolvedSecrets = unresolved;
|
|
7567
|
+
if (unresolved.length > 0) {
|
|
7568
|
+
this._ctx?.logger?.error?.("secret unavailable — running without it, will retry", { meta: { secrets: unresolved.map((u) => ({
|
|
7569
|
+
ref: u.ref,
|
|
7570
|
+
reason: u.reason
|
|
7571
|
+
})) } });
|
|
7572
|
+
if (unresolved.some((u) => u.reason !== "missing" && u.reason !== "forbidden")) {
|
|
7573
|
+
this.scheduleSecretReresolve(this._secretRetryDelayMs);
|
|
7574
|
+
this._secretRetryDelayMs = Math.min(this._secretRetryDelayMs * 2, SECRET_RETRY_MAX_MS);
|
|
7575
|
+
}
|
|
7576
|
+
} else this._secretRetryDelayMs = SECRET_RETRY_FIRST_MS;
|
|
7577
|
+
}
|
|
7578
|
+
return value;
|
|
7579
|
+
}
|
|
7580
|
+
/**
|
|
7581
|
+
* The marker-bearing settings reads (D798) — private on purpose. Without a
|
|
7582
|
+
* keychain the context's own view is already raw.
|
|
7583
|
+
*/
|
|
7584
|
+
rawSettings() {
|
|
7585
|
+
return this._secretSettings?.raw ?? this._ctx?.settings;
|
|
7586
|
+
}
|
|
7587
|
+
/** An addon-facing read met markers it could not resolve: say so once per ref. */
|
|
7588
|
+
logUnresolvedRead(unresolved) {
|
|
7589
|
+
const fresh = unresolved.filter((u) => !this._loggedUnresolvedReads.has(u.ref));
|
|
7590
|
+
if (fresh.length === 0) return;
|
|
7591
|
+
for (const u of fresh) this._loggedUnresolvedReads.add(u.ref);
|
|
7592
|
+
this._ctx?.logger?.warn?.("settings read: a stored secret is unavailable — it reads as its marker, not as a value", { meta: { secrets: fresh.map((u) => ({
|
|
7593
|
+
ref: u.ref,
|
|
7594
|
+
reason: u.reason
|
|
7595
|
+
})) } });
|
|
7596
|
+
}
|
|
7597
|
+
/** Re-resolve the config (a keychain-only change, or a retry) and apply it. */
|
|
7598
|
+
scheduleSecretReresolve(delayMs) {
|
|
7599
|
+
const timerOf = delayMs === SECRET_CHANGE_DEBOUNCE_MS ? "_secretChangeTimer" : "_secretRetryTimer";
|
|
7600
|
+
if (this[timerOf] !== null) return;
|
|
7601
|
+
const timer = setTimeout(() => {
|
|
7602
|
+
this[timerOf] = null;
|
|
7603
|
+
if (this._ctx === null) return;
|
|
7604
|
+
this.resolveConfig().then(() => this.onConfigChanged()).catch((err) => {
|
|
7605
|
+
this._ctx?.logger?.error?.("re-resolving secrets failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
|
|
7606
|
+
});
|
|
7607
|
+
}, delayMs);
|
|
7608
|
+
timer.unref?.();
|
|
7609
|
+
this[timerOf] = timer;
|
|
7610
|
+
}
|
|
6521
7611
|
/**
|
|
6522
7612
|
* Wrap `ctx.settings.readAddonStore()` with a short retry budget so a
|
|
6523
7613
|
* transient settings-store outage (mid-restart of sqlite-settings, tsx-watch
|
|
@@ -6530,7 +7620,7 @@ var BaseAddon = class {
|
|
|
6530
7620
|
* `{}` (defaults) — the addon's first successful patch will rehydrate.
|
|
6531
7621
|
*/
|
|
6532
7622
|
async readAddonStoreWithRetry() {
|
|
6533
|
-
const settings = this.
|
|
7623
|
+
const settings = this.rawSettings();
|
|
6534
7624
|
if (!settings) return {};
|
|
6535
7625
|
const delaysMs = [
|
|
6536
7626
|
150,
|
|
@@ -9490,6 +10580,278 @@ var CameraSwitchGroupSchema = object({
|
|
|
9490
10580
|
fetchedAt: number()
|
|
9491
10581
|
});
|
|
9492
10582
|
/**
|
|
10583
|
+
* The trainer contract — what the hub hands the cloud trainer and what it
|
|
10584
|
+
* gets back (cloud training, D805+).
|
|
10585
|
+
*
|
|
10586
|
+
* The trainer (`hf/camstack-trainer`, published as the Hugging Face repo
|
|
10587
|
+
* `camstack/camstack-trainer`) is a separate AGPL program the hub never
|
|
10588
|
+
* imports: `job.json` goes in, files come out, and progress is `CAMSTACK_EVENT`
|
|
10589
|
+
* lines on stdout. These schemas are the hub's half of that boundary; the
|
|
10590
|
+
* trainer's pydantic models (and the JSON Schemas generated from them under
|
|
10591
|
+
* `hf/camstack-trainer/schemas/`) are the other half. A change here is a
|
|
10592
|
+
* change there, in the same piece of work.
|
|
10593
|
+
*
|
|
10594
|
+
* No `.default()` anywhere: defaults do not run on the addon cap path, so the
|
|
10595
|
+
* orchestrator fills every field of a job spec explicitly.
|
|
10596
|
+
*/
|
|
10597
|
+
var TRAINING_JOB_SCHEMA = "camstack.training/v1";
|
|
10598
|
+
var TRAINING_RESULT_SCHEMA = "camstack.training-result/v1";
|
|
10599
|
+
/** What the trainer can export. Edge TPU is a later, separate image. */
|
|
10600
|
+
var TrainingExportSchema = _enum([
|
|
10601
|
+
"onnx",
|
|
10602
|
+
"openvino-fp16",
|
|
10603
|
+
"openvino-int8",
|
|
10604
|
+
"coreml-fp16"
|
|
10605
|
+
]);
|
|
10606
|
+
var FloorsSchema = record(string(), number().min(0).max(1));
|
|
10607
|
+
object({
|
|
10608
|
+
schema: literal(TRAINING_JOB_SCHEMA),
|
|
10609
|
+
jobKey: string().uuid(),
|
|
10610
|
+
target: object({
|
|
10611
|
+
kind: literal("detector"),
|
|
10612
|
+
step: literal("object-detection")
|
|
10613
|
+
}),
|
|
10614
|
+
base: object({
|
|
10615
|
+
modelId: string().min(1),
|
|
10616
|
+
/** Ultralytics weights id, e.g. `yolov9m.pt`. */
|
|
10617
|
+
weights: string().min(1),
|
|
10618
|
+
imgsz: number().int().positive()
|
|
10619
|
+
}),
|
|
10620
|
+
baseline: object({
|
|
10621
|
+
modelId: string().min(1),
|
|
10622
|
+
/** The baseline ONNX the holdout comparison runs; public mirror URL. */
|
|
10623
|
+
onnxUrl: string().url(),
|
|
10624
|
+
imgsz: number().int().positive(),
|
|
10625
|
+
floors: FloorsSchema
|
|
10626
|
+
}),
|
|
10627
|
+
dataset: object({
|
|
10628
|
+
versionId: string().min(1),
|
|
10629
|
+
annotationHash: string(),
|
|
10630
|
+
/** sha256 of the uploaded archive; the trainer refuses a mismatch (exit 65). */
|
|
10631
|
+
sha256: string().regex(/^[0-9a-f]{64}$/)
|
|
10632
|
+
}),
|
|
10633
|
+
split: object({
|
|
10634
|
+
holdoutCameras: array(number().int()),
|
|
10635
|
+
/** When no camera is held out: the last N days of every camera. */
|
|
10636
|
+
holdoutLastDays: number().int().nonnegative(),
|
|
10637
|
+
valFraction: number().min(0).max(.5),
|
|
10638
|
+
seed: number().int()
|
|
10639
|
+
}),
|
|
10640
|
+
hyper: object({
|
|
10641
|
+
epochs: number().int().positive(),
|
|
10642
|
+
batch: number().int().positive(),
|
|
10643
|
+
lr0: number().positive(),
|
|
10644
|
+
/** Layers frozen from the start of the backbone; 0 = none. */
|
|
10645
|
+
freeze: number().int().nonnegative(),
|
|
10646
|
+
patience: number().int().nonnegative(),
|
|
10647
|
+
seed: number().int()
|
|
10648
|
+
}),
|
|
10649
|
+
replay: object({
|
|
10650
|
+
source: literal("coco2017"),
|
|
10651
|
+
count: number().int().nonnegative()
|
|
10652
|
+
}),
|
|
10653
|
+
exports: array(TrainingExportSchema).min(1),
|
|
10654
|
+
calibration: object({ maxFrames: number().int().positive() }),
|
|
10655
|
+
floors: object({
|
|
10656
|
+
minSupport: number().int().positive(),
|
|
10657
|
+
clamp: number().min(0).max(1)
|
|
10658
|
+
}),
|
|
10659
|
+
int8Gate: object({ maxMap50Drop: number().min(0).max(1) }),
|
|
10660
|
+
catalog: object({
|
|
10661
|
+
id: string().regex(/^[a-z0-9][a-z0-9-]{2,80}$/),
|
|
10662
|
+
name: string().min(1).max(160)
|
|
10663
|
+
})
|
|
10664
|
+
});
|
|
10665
|
+
/** One regular file of the bundle. An mlpackage contributes one row per member. */
|
|
10666
|
+
var TrainingResultFileSchema = object({
|
|
10667
|
+
path: string().min(1),
|
|
10668
|
+
bytes: number().int().nonnegative(),
|
|
10669
|
+
sha256: string().regex(/^[0-9a-f]{64}$/),
|
|
10670
|
+
format: _enum([
|
|
10671
|
+
"onnx",
|
|
10672
|
+
"openvino",
|
|
10673
|
+
"coreml",
|
|
10674
|
+
"pt"
|
|
10675
|
+
]),
|
|
10676
|
+
variant: _enum(["base", "int8"])
|
|
10677
|
+
});
|
|
10678
|
+
var DraftFormatSchema = object({
|
|
10679
|
+
/** RELATIVE path inside the bundle; the hub rewrites it to `camstack-local://`. */
|
|
10680
|
+
url: string().min(1),
|
|
10681
|
+
sizeMB: number().nonnegative(),
|
|
10682
|
+
isDirectory: boolean().optional(),
|
|
10683
|
+
files: array(string()).optional(),
|
|
10684
|
+
runtimes: array(literal("python")).optional(),
|
|
10685
|
+
revision: string().min(1)
|
|
10686
|
+
});
|
|
10687
|
+
/** The trainer's half of a catalog entry; the hub completes it (labels, licence, group). */
|
|
10688
|
+
var TrainingCatalogDraftSchema = object({
|
|
10689
|
+
id: string().min(1),
|
|
10690
|
+
name: string().min(1),
|
|
10691
|
+
description: string(),
|
|
10692
|
+
labels: array(unknown()),
|
|
10693
|
+
inputSize: object({
|
|
10694
|
+
width: number().int().positive(),
|
|
10695
|
+
height: number().int().positive()
|
|
10696
|
+
}),
|
|
10697
|
+
preprocessMode: literal("letterbox"),
|
|
10698
|
+
defaultClassFloors: FloorsSchema,
|
|
10699
|
+
formats: object({
|
|
10700
|
+
onnx: DraftFormatSchema.optional(),
|
|
10701
|
+
openvino: DraftFormatSchema.optional(),
|
|
10702
|
+
coreml: DraftFormatSchema.optional()
|
|
10703
|
+
})
|
|
10704
|
+
});
|
|
10705
|
+
/** One class of one model's holdout report (the eval harness's summary). */
|
|
10706
|
+
var TrainingEvalClassSchema = object({
|
|
10707
|
+
positives: number().int(),
|
|
10708
|
+
floor: number().nullable(),
|
|
10709
|
+
tp: number().int(),
|
|
10710
|
+
fp: number().int(),
|
|
10711
|
+
fn: number().int(),
|
|
10712
|
+
precision: number().nullable(),
|
|
10713
|
+
recall: number().nullable(),
|
|
10714
|
+
ap50: number().nullable(),
|
|
10715
|
+
recallByCamera: record(string(), number().nullable()).optional(),
|
|
10716
|
+
recallByLight: record(string(), number().nullable()).optional(),
|
|
10717
|
+
fpByCamera: record(string(), number()).optional(),
|
|
10718
|
+
smallFound: number().int().optional(),
|
|
10719
|
+
smallTotal: number().int().optional()
|
|
10720
|
+
}).passthrough();
|
|
10721
|
+
var TrainingEvalReportSchema = object({
|
|
10722
|
+
frames: number().int(),
|
|
10723
|
+
classes: record(string(), TrainingEvalClassSchema)
|
|
10724
|
+
}).passthrough();
|
|
10725
|
+
/**
|
|
10726
|
+
* A succeeded result carries every block; a failed one carries the error and
|
|
10727
|
+
* whatever was known by then — the other blocks are ABSENT, not null. The
|
|
10728
|
+
* orchestrator checks the blocks it needs before it trusts a success.
|
|
10729
|
+
*/
|
|
10730
|
+
var TrainingResultSchema = object({
|
|
10731
|
+
schema: literal(TRAINING_RESULT_SCHEMA),
|
|
10732
|
+
jobKey: string(),
|
|
10733
|
+
status: _enum(["succeeded", "failed"]),
|
|
10734
|
+
error: object({
|
|
10735
|
+
stage: string(),
|
|
10736
|
+
code: string(),
|
|
10737
|
+
message: string()
|
|
10738
|
+
}).nullable(),
|
|
10739
|
+
trainer: object({
|
|
10740
|
+
version: string(),
|
|
10741
|
+
revision: string()
|
|
10742
|
+
}),
|
|
10743
|
+
toolchain: record(string(), string().nullable()),
|
|
10744
|
+
dataset: object({
|
|
10745
|
+
versionId: string(),
|
|
10746
|
+
annotationHash: string(),
|
|
10747
|
+
sha256: string(),
|
|
10748
|
+
frames: object({
|
|
10749
|
+
train: number().int(),
|
|
10750
|
+
val: number().int(),
|
|
10751
|
+
holdout: number().int()
|
|
10752
|
+
}),
|
|
10753
|
+
holdoutCameras: array(number().int()),
|
|
10754
|
+
replayImages: number().int()
|
|
10755
|
+
}).optional(),
|
|
10756
|
+
training: object({
|
|
10757
|
+
epochsRun: number().int(),
|
|
10758
|
+
bestEpoch: number().int(),
|
|
10759
|
+
bestMap50: number(),
|
|
10760
|
+
bestMap50_95: number(),
|
|
10761
|
+
seconds: number()
|
|
10762
|
+
}).optional(),
|
|
10763
|
+
evaluation: object({
|
|
10764
|
+
holdoutFrames: number().int(),
|
|
10765
|
+
baseline: TrainingEvalReportSchema.nullable(),
|
|
10766
|
+
candidate: TrainingEvalReportSchema.nullable(),
|
|
10767
|
+
candidateInt8: TrainingEvalReportSchema.nullable(),
|
|
10768
|
+
recallDeltaByCamera: record(string(), record(string(), number())).nullable(),
|
|
10769
|
+
map50: record(string(), number().nullable())
|
|
10770
|
+
}).optional(),
|
|
10771
|
+
floors: object({
|
|
10772
|
+
baseline: FloorsSchema,
|
|
10773
|
+
candidate: FloorsSchema,
|
|
10774
|
+
candidateInt8: FloorsSchema.nullable(),
|
|
10775
|
+
notes: array(string())
|
|
10776
|
+
}).optional(),
|
|
10777
|
+
int8: object({
|
|
10778
|
+
kept: boolean(),
|
|
10779
|
+
map50Fp16: number().nullable(),
|
|
10780
|
+
map50Int8: number().nullable(),
|
|
10781
|
+
reason: string().nullable()
|
|
10782
|
+
}).optional(),
|
|
10783
|
+
exportsDropped: array(object({
|
|
10784
|
+
export: string(),
|
|
10785
|
+
reason: string()
|
|
10786
|
+
})).optional(),
|
|
10787
|
+
files: array(TrainingResultFileSchema).optional(),
|
|
10788
|
+
bundle: object({
|
|
10789
|
+
path: literal("bundle.tar"),
|
|
10790
|
+
bytes: number().int().nonnegative(),
|
|
10791
|
+
sha256: string().regex(/^[0-9a-f]{64}$/)
|
|
10792
|
+
}).nullable().optional(),
|
|
10793
|
+
catalogDraft: object({
|
|
10794
|
+
base: TrainingCatalogDraftSchema,
|
|
10795
|
+
int8: TrainingCatalogDraftSchema.nullable()
|
|
10796
|
+
}).nullable().optional(),
|
|
10797
|
+
licence: string()
|
|
10798
|
+
});
|
|
10799
|
+
var TrainingStageSchema = _enum([
|
|
10800
|
+
"prepare",
|
|
10801
|
+
"replay",
|
|
10802
|
+
"train",
|
|
10803
|
+
"eval",
|
|
10804
|
+
"export",
|
|
10805
|
+
"package"
|
|
10806
|
+
]);
|
|
10807
|
+
var EventBase = {
|
|
10808
|
+
v: literal(1),
|
|
10809
|
+
ts: number()
|
|
10810
|
+
};
|
|
10811
|
+
discriminatedUnion("type", [
|
|
10812
|
+
object({
|
|
10813
|
+
...EventBase,
|
|
10814
|
+
type: literal("stage"),
|
|
10815
|
+
stage: TrainingStageSchema
|
|
10816
|
+
}),
|
|
10817
|
+
object({
|
|
10818
|
+
...EventBase,
|
|
10819
|
+
type: literal("epoch"),
|
|
10820
|
+
epoch: number().int(),
|
|
10821
|
+
epochs: number().int(),
|
|
10822
|
+
boxLoss: number().nullable().optional(),
|
|
10823
|
+
map50: number().nullable().optional(),
|
|
10824
|
+
map50_95: number().nullable().optional(),
|
|
10825
|
+
etaSec: number().nullable().optional()
|
|
10826
|
+
}),
|
|
10827
|
+
object({
|
|
10828
|
+
...EventBase,
|
|
10829
|
+
type: literal("metric"),
|
|
10830
|
+
name: string(),
|
|
10831
|
+
value: number()
|
|
10832
|
+
}),
|
|
10833
|
+
object({
|
|
10834
|
+
...EventBase,
|
|
10835
|
+
type: literal("artifact"),
|
|
10836
|
+
path: string(),
|
|
10837
|
+
bytes: number(),
|
|
10838
|
+
sha256: string()
|
|
10839
|
+
}),
|
|
10840
|
+
object({
|
|
10841
|
+
...EventBase,
|
|
10842
|
+
type: literal("done"),
|
|
10843
|
+
status: _enum(["succeeded", "failed"]),
|
|
10844
|
+
resultSha256: string().nullable().optional()
|
|
10845
|
+
}),
|
|
10846
|
+
object({
|
|
10847
|
+
...EventBase,
|
|
10848
|
+
type: literal("error"),
|
|
10849
|
+
stage: string(),
|
|
10850
|
+
code: string(),
|
|
10851
|
+
message: string()
|
|
10852
|
+
})
|
|
10853
|
+
]);
|
|
10854
|
+
/**
|
|
9493
10855
|
* What the gate decided about a birth, from the CALLER's point of view.
|
|
9494
10856
|
*
|
|
9495
10857
|
* Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
|
|
@@ -11971,7 +13333,9 @@ var AddonHttpRouteSchema = object({
|
|
|
11971
13333
|
"authenticated",
|
|
11972
13334
|
"admin"
|
|
11973
13335
|
]).optional(),
|
|
11974
|
-
description: string().optional()
|
|
13336
|
+
description: string().optional(),
|
|
13337
|
+
/** The hub limits this route per client address before the handler runs. */
|
|
13338
|
+
rateLimit: _enum(["auth"]).optional()
|
|
11975
13339
|
});
|
|
11976
13340
|
/**
|
|
11977
13341
|
* Cross-process route invocation envelope. The hub captures the
|
|
@@ -12676,6 +14040,37 @@ var BackupDestinationInfoSchema = object({
|
|
|
12676
14040
|
lastError: string().optional()
|
|
12677
14041
|
});
|
|
12678
14042
|
/**
|
|
14043
|
+
* How an archive is encrypted (operator decision 2026-10-09): to a backup
|
|
14044
|
+
* PUBLIC key the hub holds, so only the operator's secret key opens it.
|
|
14045
|
+
* Absent on a plain `.tar.gz` — every archive made before encryption, or
|
|
14046
|
+
* with it off — which restores without a key.
|
|
14047
|
+
*/
|
|
14048
|
+
var BackupArchiveEncryptionSchema = object({
|
|
14049
|
+
/** `x25519-hkdf-aes256gcm-stream-v1`. */
|
|
14050
|
+
scheme: string(),
|
|
14051
|
+
/** 16 hex — the backup key whose secret restores this archive. */
|
|
14052
|
+
keyId: string()
|
|
14053
|
+
});
|
|
14054
|
+
/**
|
|
14055
|
+
* The backup encryption setting. The hub keeps PUBLIC keys only: the active
|
|
14056
|
+
* one new archives are encrypted to, and the retired ones older archives
|
|
14057
|
+
* still need. The secret key is shown once, at `setupEncryption`.
|
|
14058
|
+
*/
|
|
14059
|
+
var BackupEncryptionStatusSchema = object({
|
|
14060
|
+
enabled: boolean(),
|
|
14061
|
+
active: object({
|
|
14062
|
+
keyId: string(),
|
|
14063
|
+
publicKey: string(),
|
|
14064
|
+
createdAt: number()
|
|
14065
|
+
}).nullable(),
|
|
14066
|
+
/** Every key ever set up, newest first. */
|
|
14067
|
+
keys: array(object({
|
|
14068
|
+
keyId: string(),
|
|
14069
|
+
createdAt: number(),
|
|
14070
|
+
retiredAt: number().nullable()
|
|
14071
|
+
})).readonly()
|
|
14072
|
+
});
|
|
14073
|
+
/**
|
|
12679
14074
|
* Per-archive entry returned by `backup.listArchives({ destinationId })`.
|
|
12680
14075
|
* Same shape the destination drill-in renders. Sourced from the per-
|
|
12681
14076
|
* location `manifests.json` (no per-archive tarball read required).
|
|
@@ -12687,7 +14082,9 @@ var BackupArchiveEntrySchema = object({
|
|
|
12687
14082
|
sizeBytes: number(),
|
|
12688
14083
|
label: string().optional(),
|
|
12689
14084
|
/** Top-level locations included in the archive (db, addons, tls, …). */
|
|
12690
|
-
locations: array(string()).readonly()
|
|
14085
|
+
locations: array(string()).readonly(),
|
|
14086
|
+
/** Present when the archive is encrypted; restore then needs that key. */
|
|
14087
|
+
encryption: BackupArchiveEncryptionSchema.optional()
|
|
12691
14088
|
});
|
|
12692
14089
|
var BackupEntrySchema = object({
|
|
12693
14090
|
id: string(),
|
|
@@ -12696,7 +14093,8 @@ var BackupEntrySchema = object({
|
|
|
12696
14093
|
label: string().optional(),
|
|
12697
14094
|
createdAt: number(),
|
|
12698
14095
|
sizeBytes: number(),
|
|
12699
|
-
locations: array(string()).optional()
|
|
14096
|
+
locations: array(string()).optional(),
|
|
14097
|
+
encryption: BackupArchiveEncryptionSchema.optional()
|
|
12700
14098
|
});
|
|
12701
14099
|
var ArchiveEntrySchema = object({
|
|
12702
14100
|
path: string(),
|
|
@@ -12885,10 +14283,40 @@ method(_void(), array(BackupDestinationInfoSchema).readonly(), { auth: "admin" }
|
|
|
12885
14283
|
* this list and skips entries whose path doesn't start with
|
|
12886
14284
|
* any of them.
|
|
12887
14285
|
*/
|
|
12888
|
-
locations: array(string()).optional()
|
|
14286
|
+
locations: array(string()).optional(),
|
|
14287
|
+
/**
|
|
14288
|
+
* The backup SECRET key, for an encrypted archive (ignored for a plain
|
|
14289
|
+
* one). The archive is decrypted into the hub's private staging
|
|
14290
|
+
* before the restart; the key is not stored. A wrong or missing key
|
|
14291
|
+
* is refused before the archive is downloaded.
|
|
14292
|
+
*/
|
|
14293
|
+
backupSecretKey: string().optional()
|
|
12889
14294
|
}), _void(), {
|
|
12890
14295
|
kind: "mutation",
|
|
12891
14296
|
auth: "admin"
|
|
14297
|
+
}), method(_void(), BackupEncryptionStatusSchema, { auth: "admin" }), method(object({}), object({
|
|
14298
|
+
keyId: string(),
|
|
14299
|
+
secretKey: string(),
|
|
14300
|
+
publicKey: string(),
|
|
14301
|
+
createdAt: number(),
|
|
14302
|
+
replacedKeyId: string().nullable()
|
|
14303
|
+
}), {
|
|
14304
|
+
kind: "mutation",
|
|
14305
|
+
auth: "admin"
|
|
14306
|
+
}), method(object({}), object({ disabledKeyId: string().nullable() }), {
|
|
14307
|
+
kind: "mutation",
|
|
14308
|
+
auth: "admin"
|
|
14309
|
+
}), method(object({ backupSecretKey: string() }), object({
|
|
14310
|
+
valid: boolean(),
|
|
14311
|
+
keyId: string().nullable(),
|
|
14312
|
+
/** The hub knows this key (active or retired). */
|
|
14313
|
+
known: boolean(),
|
|
14314
|
+
/** It is the key new archives are encrypted to. */
|
|
14315
|
+
active: boolean(),
|
|
14316
|
+
error: string().optional()
|
|
14317
|
+
}), {
|
|
14318
|
+
kind: "mutation",
|
|
14319
|
+
auth: "admin"
|
|
12892
14320
|
}), method(object({
|
|
12893
14321
|
destinationId: string(),
|
|
12894
14322
|
backupId: string()
|
|
@@ -14512,7 +15940,60 @@ var CustomModelDescriptorSchema = object({
|
|
|
14512
15940
|
stepId: string(),
|
|
14513
15941
|
entry: ModelCatalogEntrySchema
|
|
14514
15942
|
});
|
|
14515
|
-
|
|
15943
|
+
/** One regular file of an imported bundle, as the producer measured it. */
|
|
15944
|
+
var ModelBundleFileSchema = object({
|
|
15945
|
+
/** Relative path inside the bundle tar; an mlpackage member is `<x>.mlpackage/<member>`. */
|
|
15946
|
+
path: string().min(1),
|
|
15947
|
+
bytes: number().int().nonnegative(),
|
|
15948
|
+
sha256: string().regex(/^[0-9a-f]{64}$/)
|
|
15949
|
+
});
|
|
15950
|
+
var ImportModelBundleInputSchema = object({
|
|
15951
|
+
/** The registry provider that keeps the model (Model Studio). */
|
|
15952
|
+
addonId: string(),
|
|
15953
|
+
stepId: string().min(1),
|
|
15954
|
+
/**
|
|
15955
|
+
* The catalog rows to register, complete, every format URL already
|
|
15956
|
+
* `camstack-local://<modelId>/<file>` naming a file of the bundle. One
|
|
15957
|
+
* bundle may carry several rows (a base and its INT8 variant).
|
|
15958
|
+
*/
|
|
15959
|
+
entries: array(ModelCatalogEntrySchema).min(1).max(4),
|
|
15960
|
+
/** The bundle tar, offered by the producer over `ctx.peerBytes` (same host). */
|
|
15961
|
+
bundle: object({
|
|
15962
|
+
ticket: PeerBytesTicketSchema,
|
|
15963
|
+
bytes: number().int().positive(),
|
|
15964
|
+
sha256: string().regex(/^[0-9a-f]{64}$/)
|
|
15965
|
+
}),
|
|
15966
|
+
/** Every file the tar must hold; anything missing, extra or different is refused. */
|
|
15967
|
+
files: array(ModelBundleFileSchema).min(1).max(64),
|
|
15968
|
+
/** Convert missing engine formats and push the model to every agent afterwards. */
|
|
15969
|
+
distribute: boolean()
|
|
15970
|
+
});
|
|
15971
|
+
var ImportModelBundleResultSchema = discriminatedUnion("kind", [object({
|
|
15972
|
+
kind: literal("imported"),
|
|
15973
|
+
modelIds: array(string()).readonly(),
|
|
15974
|
+
distributed: array(object({
|
|
15975
|
+
modelId: string(),
|
|
15976
|
+
nodeId: string(),
|
|
15977
|
+
format: _enum(MODEL_FORMATS),
|
|
15978
|
+
ok: boolean(),
|
|
15979
|
+
error: string().optional()
|
|
15980
|
+
})).readonly()
|
|
15981
|
+
}), object({
|
|
15982
|
+
kind: literal("refused"),
|
|
15983
|
+
reason: _enum([
|
|
15984
|
+
"transfer-failed",
|
|
15985
|
+
"checksum-mismatch",
|
|
15986
|
+
"bundle-mismatch",
|
|
15987
|
+
"invalid-entry",
|
|
15988
|
+
"id-taken"
|
|
15989
|
+
]),
|
|
15990
|
+
detail: string()
|
|
15991
|
+
})]);
|
|
15992
|
+
method(_void(), array(CustomModelDescriptorSchema).readonly(), { auth: "admin" }), method(ImportModelBundleInputSchema, ImportModelBundleResultSchema, {
|
|
15993
|
+
kind: "mutation",
|
|
15994
|
+
auth: "admin",
|
|
15995
|
+
timeoutMs: 30 * 6e4
|
|
15996
|
+
});
|
|
14516
15997
|
/**
|
|
14517
15998
|
* Query filter for settings-store collections.
|
|
14518
15999
|
*/
|
|
@@ -14896,6 +16377,253 @@ id: union([string(), number()]) }), {
|
|
|
14896
16377
|
auth: "admin"
|
|
14897
16378
|
});
|
|
14898
16379
|
/**
|
|
16380
|
+
* `keychain` — the hub's encrypted store of secret values (D787).
|
|
16381
|
+
*
|
|
16382
|
+
* Settings blobs never hold a secret: they hold a marker
|
|
16383
|
+
* `{"$secret":"secret://<owner>/<scope>/<fieldPath>","v":1}` and the value
|
|
16384
|
+
* lives here, AES-256-GCM under a data key that a master key wraps. This cap
|
|
16385
|
+
* is the OWNER's door to its own values: every method is owner-checked
|
|
16386
|
+
* against the CALLER, never against anything the caller claims.
|
|
16387
|
+
*
|
|
16388
|
+
* Who the caller is: the transport stamps `callerAddonId` into the args of a
|
|
16389
|
+
* call that crossed a process (the parent `LocalChildRegistry` from the UDS
|
|
16390
|
+
* connection, the agent from its child's connection carried in
|
|
16391
|
+
* `$hub-cap-fwd`'s envelope). A stamp always overwrites; a wire call with no
|
|
16392
|
+
* stamp has its claim stripped. Only a hub in-process caller may state its own
|
|
16393
|
+
* identity — `ctx.secrets` does that with the addon id closed over. This is
|
|
16394
|
+
* identity against BUGS and misrouting, not against a malicious addon (every
|
|
16395
|
+
* runner is the same OS user): see the threat model in
|
|
16396
|
+
* `docs/design/2026-10-08-secrets-keychain.md`.
|
|
16397
|
+
*
|
|
16398
|
+
* `callerAddonId` is deliberately NOT in any input schema: the tRPC router
|
|
16399
|
+
* parses the input, so a session can never supply it, and the internal mount
|
|
16400
|
+
* floors every method to admin anyway (D240).
|
|
16401
|
+
*
|
|
16402
|
+
* Internal: addons reach it through `ctx.secrets`, never directly.
|
|
16403
|
+
*/
|
|
16404
|
+
/** Why a value cannot be served right now. Never folded into "missing". */
|
|
16405
|
+
var KeychainUnavailableReasonSchema = _enum([
|
|
16406
|
+
"key-missing",
|
|
16407
|
+
"wrong-key",
|
|
16408
|
+
"key-file-unreadable",
|
|
16409
|
+
"store-unavailable",
|
|
16410
|
+
"not-initialized",
|
|
16411
|
+
"decrypt-failed"
|
|
16412
|
+
]);
|
|
16413
|
+
var KeychainStateSchema = discriminatedUnion("state", [object({ state: literal("ready") }), object({
|
|
16414
|
+
state: literal("locked"),
|
|
16415
|
+
reason: KeychainUnavailableReasonSchema
|
|
16416
|
+
})]);
|
|
16417
|
+
var KeychainResolveEntrySchema = discriminatedUnion("kind", [
|
|
16418
|
+
object({
|
|
16419
|
+
kind: literal("value"),
|
|
16420
|
+
value: string(),
|
|
16421
|
+
version: number().int()
|
|
16422
|
+
}),
|
|
16423
|
+
object({ kind: literal("missing") }),
|
|
16424
|
+
object({
|
|
16425
|
+
kind: literal("unavailable"),
|
|
16426
|
+
reason: KeychainUnavailableReasonSchema
|
|
16427
|
+
}),
|
|
16428
|
+
object({ kind: literal("forbidden") })
|
|
16429
|
+
]);
|
|
16430
|
+
var KeychainResolveResultSchema = record(string(), KeychainResolveEntrySchema);
|
|
16431
|
+
/** Metadata of one stored value — never the value. */
|
|
16432
|
+
var KeychainSecretMetaSchema = object({
|
|
16433
|
+
ref: string(),
|
|
16434
|
+
owner: string(),
|
|
16435
|
+
/** Formatted scope (`global`, `node/<id>`, `device/<id>`, …). */
|
|
16436
|
+
scope: string(),
|
|
16437
|
+
fieldPath: string(),
|
|
16438
|
+
version: number().int(),
|
|
16439
|
+
createdAt: number(),
|
|
16440
|
+
updatedAt: number(),
|
|
16441
|
+
/** `addon:<id>` | `user:<id>` | `system`. */
|
|
16442
|
+
updatedBy: string(),
|
|
16443
|
+
/** Coarse — written at most once an hour per ref. `null` = never read. */
|
|
16444
|
+
lastReadAt: number().nullable()
|
|
16445
|
+
});
|
|
16446
|
+
var RefListSchema = array(string().min(1)).max(512);
|
|
16447
|
+
method(object({
|
|
16448
|
+
ref: string().min(1),
|
|
16449
|
+
value: string().min(1)
|
|
16450
|
+
}), object({
|
|
16451
|
+
ref: string(),
|
|
16452
|
+
version: number().int()
|
|
16453
|
+
}), {
|
|
16454
|
+
kind: "mutation",
|
|
16455
|
+
auth: "admin"
|
|
16456
|
+
}), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
|
|
16457
|
+
kind: "mutation",
|
|
16458
|
+
auth: "admin"
|
|
16459
|
+
}), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
|
|
16460
|
+
var KeychainKeySourceSchema = object({
|
|
16461
|
+
kind: _enum([
|
|
16462
|
+
"config-file",
|
|
16463
|
+
"previous-config-file",
|
|
16464
|
+
"platform",
|
|
16465
|
+
"default-file"
|
|
16466
|
+
]),
|
|
16467
|
+
/** File sources only — a path is not a secret. */
|
|
16468
|
+
path: string().optional(),
|
|
16469
|
+
/**
|
|
16470
|
+
* True when a whole-volume backup of the data directory carries this key
|
|
16471
|
+
* next to the database it protects (the default file). The page warns.
|
|
16472
|
+
*/
|
|
16473
|
+
sharesBackupWithDatabase: boolean()
|
|
16474
|
+
});
|
|
16475
|
+
/**
|
|
16476
|
+
* One keychain reset, as the Secrets page reports it until the operator
|
|
16477
|
+
* acknowledges it. Never a value: refs, counts and table names only.
|
|
16478
|
+
*/
|
|
16479
|
+
var KeychainResetRecordSchema = object({
|
|
16480
|
+
id: string(),
|
|
16481
|
+
at: number(),
|
|
16482
|
+
/** `user:<id>` or {@link KEYCHAIN_RESET_TRIGGER_ACTOR}. */
|
|
16483
|
+
actor: string(),
|
|
16484
|
+
/** Why the keychain was locked when it was reset; `null` when it was not locked. */
|
|
16485
|
+
lockedReason: string().nullable(),
|
|
16486
|
+
/** Values moved into the archive table (ciphertext under the lost key). */
|
|
16487
|
+
archived: number().int(),
|
|
16488
|
+
/** `keychain:secrets-orphaned-<ts>`, or `null` when nothing was stored. */
|
|
16489
|
+
archivedCollection: string().nullable(),
|
|
16490
|
+
/**
|
|
16491
|
+
* `keychain:keys-orphaned-<ts>`: the wrapped data keys of the archive, kept
|
|
16492
|
+
* so the archive can still be opened if the lost master key turns up.
|
|
16493
|
+
*/
|
|
16494
|
+
archivedKeysCollection: string().nullable(),
|
|
16495
|
+
/**
|
|
16496
|
+
* `system-settings` keys whose marker the reset cleared — the cluster
|
|
16497
|
+
* secret's: a marker left pointing at an archived value would refuse every
|
|
16498
|
+
* agent forever (D797).
|
|
16499
|
+
*/
|
|
16500
|
+
clearedSettingsKeys: array(string()).readonly(),
|
|
16501
|
+
/** When an operator dismissed the notice on the Secrets page; `null` until then. */
|
|
16502
|
+
acknowledgedAt: number().nullable()
|
|
16503
|
+
});
|
|
16504
|
+
var KeychainStatusSchema = object({
|
|
16505
|
+
keychain: KeychainStateSchema,
|
|
16506
|
+
/** The source of the master key in use; `null` while locked. */
|
|
16507
|
+
keySource: KeychainKeySourceSchema.nullable(),
|
|
16508
|
+
/** The source configured to be primary — differs from `keySource` while a rotation is pending. */
|
|
16509
|
+
configuredSource: KeychainKeySourceSchema,
|
|
16510
|
+
/** Short fingerprint of the master key in use (`HMAC(KEK, label)`, 16 hex). */
|
|
16511
|
+
fingerprint: string().nullable(),
|
|
16512
|
+
activeKeyId: string().nullable(),
|
|
16513
|
+
/**
|
|
16514
|
+
* The keychain unlocked with a NON-primary source: the configured primary
|
|
16515
|
+
* key is not the one that wraps the data key yet. `rotateMasterKey` moves it.
|
|
16516
|
+
*/
|
|
16517
|
+
rotationPending: boolean(),
|
|
16518
|
+
/** Wrapped copies of the data key under a previous master key, kept until purged. */
|
|
16519
|
+
retiredWraps: number().int(),
|
|
16520
|
+
recoveryKeyDownloadedAt: number().nullable(),
|
|
16521
|
+
secretCount: number().int(),
|
|
16522
|
+
/** The most recent reset, acknowledged or not; `null` when the keychain was never reset. */
|
|
16523
|
+
lastReset: KeychainResetRecordSchema.nullable()
|
|
16524
|
+
});
|
|
16525
|
+
/**
|
|
16526
|
+
* Whether a stored value is still pointed at by its owner's settings.
|
|
16527
|
+
* `unknown` is a first-class answer: a scope whose blob could not be read is
|
|
16528
|
+
* never reported as an orphan (and never deleted as one).
|
|
16529
|
+
*/
|
|
16530
|
+
var KeychainSecretUsageSchema = _enum([
|
|
16531
|
+
"in-use",
|
|
16532
|
+
"orphan",
|
|
16533
|
+
"unknown"
|
|
16534
|
+
]);
|
|
16535
|
+
var KeychainAdminSecretSchema = KeychainSecretMetaSchema.extend({ usage: KeychainSecretUsageSchema });
|
|
16536
|
+
var KeychainAuditActionSchema = _enum([
|
|
16537
|
+
"put",
|
|
16538
|
+
"delete",
|
|
16539
|
+
"reveal",
|
|
16540
|
+
"rotate-master-key",
|
|
16541
|
+
"purge-retired-keys",
|
|
16542
|
+
"download-recovery-key",
|
|
16543
|
+
"delete-orphans",
|
|
16544
|
+
"reset",
|
|
16545
|
+
"acknowledge-reset",
|
|
16546
|
+
"initialize"
|
|
16547
|
+
]);
|
|
16548
|
+
var KeychainAuditEntrySchema = object({
|
|
16549
|
+
id: string(),
|
|
16550
|
+
at: number(),
|
|
16551
|
+
action: KeychainAuditActionSchema,
|
|
16552
|
+
/** `addon:<id>` | `user:<id>` | `system` | `trigger-file`. */
|
|
16553
|
+
actor: string(),
|
|
16554
|
+
ref: string().nullable(),
|
|
16555
|
+
detail: string().nullable()
|
|
16556
|
+
});
|
|
16557
|
+
var KEYCHAIN_RESET_CONFIRMATION = "RESET KEYCHAIN";
|
|
16558
|
+
/**
|
|
16559
|
+
* Secrets the HUB itself holds (owner `system`) that no settings form shows:
|
|
16560
|
+
* `jwt-signing-key` — the session signing key (D797). It is always "in use",
|
|
16561
|
+
* never an orphan; it is generated on a fresh hub and replaced only through
|
|
16562
|
+
* {@link keychainAdminCapability.methods.setSystemSecret}.
|
|
16563
|
+
*/
|
|
16564
|
+
var SystemHeldSecretNameSchema = _enum(["jwt-signing-key"]);
|
|
16565
|
+
method(object({}), KeychainStatusSchema, { auth: "admin" }), method(object({}), array(KeychainAdminSecretSchema).readonly(), { auth: "admin" }), method(object({ limit: number().int().min(1).max(500).optional() }), array(KeychainAuditEntrySchema).readonly(), { auth: "admin" }), method(object({ ref: string().min(1) }), object({
|
|
16566
|
+
value: string(),
|
|
16567
|
+
version: number().int()
|
|
16568
|
+
}), {
|
|
16569
|
+
kind: "mutation",
|
|
16570
|
+
auth: "admin",
|
|
16571
|
+
caller: "required"
|
|
16572
|
+
}), method(object({
|
|
16573
|
+
name: SystemHeldSecretNameSchema,
|
|
16574
|
+
value: string().min(16)
|
|
16575
|
+
}), object({
|
|
16576
|
+
ref: string(),
|
|
16577
|
+
version: number().int()
|
|
16578
|
+
}), {
|
|
16579
|
+
kind: "mutation",
|
|
16580
|
+
auth: "admin",
|
|
16581
|
+
caller: "required"
|
|
16582
|
+
}), method(object({ refs: array(string().min(1)).max(1e3) }), object({
|
|
16583
|
+
deleted: array(string()).readonly(),
|
|
16584
|
+
kept: array(object({
|
|
16585
|
+
ref: string(),
|
|
16586
|
+
usage: KeychainSecretUsageSchema
|
|
16587
|
+
})).readonly()
|
|
16588
|
+
}), {
|
|
16589
|
+
kind: "mutation",
|
|
16590
|
+
auth: "admin",
|
|
16591
|
+
caller: "required"
|
|
16592
|
+
}), method(object({}), object({
|
|
16593
|
+
fingerprint: string(),
|
|
16594
|
+
keySource: KeychainKeySourceSchema
|
|
16595
|
+
}), {
|
|
16596
|
+
kind: "mutation",
|
|
16597
|
+
auth: "admin",
|
|
16598
|
+
caller: "required"
|
|
16599
|
+
}), method(object({}), object({ purged: number().int() }), {
|
|
16600
|
+
kind: "mutation",
|
|
16601
|
+
auth: "admin",
|
|
16602
|
+
caller: "required"
|
|
16603
|
+
}), method(object({}), object({
|
|
16604
|
+
key: string(),
|
|
16605
|
+
fingerprint: string(),
|
|
16606
|
+
keySource: KeychainKeySourceSchema
|
|
16607
|
+
}), {
|
|
16608
|
+
kind: "mutation",
|
|
16609
|
+
auth: "admin",
|
|
16610
|
+
caller: "required"
|
|
16611
|
+
}), method(object({ confirm: literal(KEYCHAIN_RESET_CONFIRMATION) }), object({
|
|
16612
|
+
archivedCollection: string().nullable(),
|
|
16613
|
+
archived: number().int()
|
|
16614
|
+
}), {
|
|
16615
|
+
kind: "mutation",
|
|
16616
|
+
auth: "admin",
|
|
16617
|
+
caller: "required"
|
|
16618
|
+
}), method(object({}), object({
|
|
16619
|
+
reset: KeychainResetRecordSchema.nullable(),
|
|
16620
|
+
pendingReentry: array(KeychainSecretMetaSchema).readonly()
|
|
16621
|
+
}), { auth: "admin" }), method(object({}), object({ acknowledged: boolean() }), {
|
|
16622
|
+
kind: "mutation",
|
|
16623
|
+
auth: "admin",
|
|
16624
|
+
caller: "required"
|
|
16625
|
+
});
|
|
16626
|
+
/**
|
|
14899
16627
|
* Stable UI option list for the `hwaccel` setting. Decoder addons
|
|
14900
16628
|
* reuse this for `globalSettingsSchema()` so the dropdown is
|
|
14901
16629
|
* identical everywhere. Order: auto → off → common backends by
|
|
@@ -16013,7 +17741,11 @@ var DeviceRegisterPayloadSchema = object({
|
|
|
16013
17741
|
var DeviceRemovePayloadSchema = object({ deviceId: number() });
|
|
16014
17742
|
var DevicePersistConfigPayloadSchema = object({
|
|
16015
17743
|
deviceId: number(),
|
|
16016
|
-
data: record(string(), unknown())
|
|
17744
|
+
data: record(string(), unknown()),
|
|
17745
|
+
/** The paths the device's schema declares secret (D783), when the caller
|
|
17746
|
+
* knows them — those values are kept in the keychain, not the blob (D787).
|
|
17747
|
+
* Absent: the paths the device last reported at `registerDevice` apply. */
|
|
17748
|
+
secretConfigPaths: array(string()).optional()
|
|
16017
17749
|
});
|
|
16018
17750
|
/** What a migration actually did, per switch. `unreachable` is a first-class
|
|
16019
17751
|
* answer: a camera that could not be asked is not a camera that was silenced. */
|
|
@@ -17616,7 +19348,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
|
|
|
17616
19348
|
* `login-method` — collection cap through which auth addons contribute
|
|
17617
19349
|
* their pre-auth login surfaces to the login page. This is the SINGLE,
|
|
17618
19350
|
* generic mechanism that supersedes the dead `auth.listProviders` reader:
|
|
17619
|
-
* every auth addon (OIDC,
|
|
19351
|
+
* every auth addon (OIDC, WebAuthn/passkey) registers a
|
|
17620
19352
|
* `login-method` provider and the PUBLIC `auth.listLoginMethods`
|
|
17621
19353
|
* procedure aggregates them for the unauthenticated login page.
|
|
17622
19354
|
*
|
|
@@ -17624,8 +19356,7 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
|
|
|
17624
19356
|
*
|
|
17625
19357
|
* - `redirect` — a declarative button. The login page renders a generic
|
|
17626
19358
|
* button that navigates to `startUrl` (an addon-owned HTTP route).
|
|
17627
|
-
* Covers OIDC (`/addon/auth-oidc/<id>/start`)
|
|
17628
|
-
* ZERO shell-side JS. A future SSO addon plugs in the same way — the
|
|
19359
|
+
* Covers OIDC (`/addon/auth-oidc/<id>/start`) with ZERO shell-side JS. A future SSO addon plugs in the same way — the
|
|
17629
19360
|
* login page needs NO change.
|
|
17630
19361
|
*
|
|
17631
19362
|
* - `widget` — a Module-Federation widget the login page mounts (via
|
|
@@ -17644,8 +19375,8 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
|
|
|
17644
19375
|
* decision.
|
|
17645
19376
|
*
|
|
17646
19377
|
* Every contribution carries a `stage`:
|
|
17647
|
-
* - `primary` — shown on the first credentials screen (OIDC
|
|
17648
|
-
*
|
|
19378
|
+
* - `primary` — shown on the first credentials screen (OIDC
|
|
19379
|
+
* buttons; a usernameless passkey).
|
|
17649
19380
|
* - `second-factor` — shown AFTER the password leg, gated on the
|
|
17650
19381
|
* returned `factors` (passkey-as-2FA today).
|
|
17651
19382
|
*
|
|
@@ -17672,7 +19403,7 @@ var LoginMethodContributionSchema = discriminatedUnion("kind", [
|
|
|
17672
19403
|
* The provider names an external identity a signed-in user can link to
|
|
17673
19404
|
* their own account (D782): `auth.listLinkableProviders` /
|
|
17674
19405
|
* `beginExternalLink` offer exactly the redirect methods that set this,
|
|
17675
|
-
* whatever their id. Absent / false — a login button only
|
|
19406
|
+
* whatever their id. Absent / false — a login button only.
|
|
17676
19407
|
*/
|
|
17677
19408
|
linkable: boolean().optional()
|
|
17678
19409
|
}),
|
|
@@ -21489,8 +23220,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
|
|
|
21489
23220
|
* `super_admin` — collapsed onto the single boolean because every
|
|
21490
23221
|
* non-admin caller is governed by the same scope-check rules; the
|
|
21491
23222
|
* distinction was only ever used to route role-specific procedures
|
|
21492
|
-
* which we no longer have.
|
|
21493
|
-
* `createServiceToken`; CLI / webhook integrations are `cst_*` tokens
|
|
23223
|
+
* which we no longer have. CLI / webhook integrations are `cst_*` tokens
|
|
21494
23224
|
* with `isAdmin: false` + an explicit scope list.
|
|
21495
23225
|
*/
|
|
21496
23226
|
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
@@ -22992,8 +24722,23 @@ var RetrainMacroClassSchema = _enum([
|
|
|
22992
24722
|
]);
|
|
22993
24723
|
/** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
|
|
22994
24724
|
var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
|
|
22995
|
-
/**
|
|
22996
|
-
|
|
24725
|
+
/**
|
|
24726
|
+
* Where a box came from. A machine-sourced box is a DRAFT on the page until
|
|
24727
|
+
* the operator confirms it; once saved it keeps its source as provenance.
|
|
24728
|
+
*
|
|
24729
|
+
* - `operator` — drawn by hand.
|
|
24730
|
+
* - `assist` — proposed by a detector run on the copy (the camera's own
|
|
24731
|
+
* model, or a larger teacher model).
|
|
24732
|
+
* - `pipeline` — the box the live pipeline actually drew on that frame, read
|
|
24733
|
+
* back from the track store (never a re-run).
|
|
24734
|
+
* - `llm` — proposed by a vision-capable LLM profile.
|
|
24735
|
+
*/
|
|
24736
|
+
var RetrainAnnotationSourceSchema = _enum([
|
|
24737
|
+
"operator",
|
|
24738
|
+
"assist",
|
|
24739
|
+
"pipeline",
|
|
24740
|
+
"llm"
|
|
24741
|
+
]);
|
|
22997
24742
|
/** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
|
|
22998
24743
|
var RetrainBboxSchema = object({
|
|
22999
24744
|
x: number(),
|
|
@@ -23011,7 +24756,8 @@ var RetrainBboxSchema = object({
|
|
|
23011
24756
|
*/
|
|
23012
24757
|
var RetrainAnnotationSchema = object({
|
|
23013
24758
|
id: string(),
|
|
23014
|
-
|
|
24759
|
+
/** The frame's track. Absent on a recording still, which has none. */
|
|
24760
|
+
trackId: string().optional(),
|
|
23015
24761
|
deviceId: number(),
|
|
23016
24762
|
/** The COPY in retrain storage — never the source track's media key. */
|
|
23017
24763
|
mediaKey: string(),
|
|
@@ -23060,13 +24806,47 @@ var RetrainFrameCandidateSchema = object({
|
|
|
23060
24806
|
* fail, whatever became of the original. */
|
|
23061
24807
|
copied: boolean()
|
|
23062
24808
|
});
|
|
24809
|
+
/**
|
|
24810
|
+
* One box the live pipeline drew on a copied frame — what a correction starts
|
|
24811
|
+
* from. Derived when the frame is listed, from the track store: the subject
|
|
24812
|
+
* box recorded on the source media row when there is one, else the track
|
|
24813
|
+
* position nearest the frame's capture time. Never stored as an annotation
|
|
24814
|
+
* until the operator confirms it.
|
|
24815
|
+
*/
|
|
24816
|
+
var RetrainPipelineBoxSchema = object({
|
|
24817
|
+
/** Normalised `[0,1]` against the full frame. */
|
|
24818
|
+
bbox: RetrainBboxSchema,
|
|
24819
|
+
macroClass: RetrainMacroClassSchema,
|
|
24820
|
+
label: string().optional(),
|
|
24821
|
+
subLabel: string().optional(),
|
|
24822
|
+
/** The detection score of the position used, when it was recorded. */
|
|
24823
|
+
score: number().optional(),
|
|
24824
|
+
/** The root model that produced the track, when it was recorded. */
|
|
24825
|
+
modelId: string().optional(),
|
|
24826
|
+
trackId: string(),
|
|
24827
|
+
/** `subject-box`: recorded on this very frame. `position`: the track's
|
|
24828
|
+
* position nearest the capture time, `deltaMs` away. */
|
|
24829
|
+
basis: _enum(["subject-box", "position"]),
|
|
24830
|
+
deltaMs: number()
|
|
24831
|
+
});
|
|
24832
|
+
/**
|
|
24833
|
+
* Where a retrain frame came from: a TRACK's stored media (copy-on-select),
|
|
24834
|
+
* or the RECORDING at an instant — the frame a model saw nothing in has no
|
|
24835
|
+
* track at all.
|
|
24836
|
+
*/
|
|
24837
|
+
var RetrainFrameOriginSchema = _enum(["track", "recording"]);
|
|
23063
24838
|
/** A frame the dataset OWNS: bytes copied at selection time. */
|
|
23064
24839
|
var RetrainFrameSchema = object({
|
|
23065
24840
|
frameId: string(),
|
|
23066
24841
|
deviceId: number(),
|
|
23067
|
-
|
|
23068
|
-
/**
|
|
23069
|
-
|
|
24842
|
+
origin: RetrainFrameOriginSchema,
|
|
24843
|
+
/** The track it was copied from. Absent on a recording still. */
|
|
24844
|
+
trackId: string().optional(),
|
|
24845
|
+
/** Provenance only. It may already point at nothing — that is expected.
|
|
24846
|
+
* Absent on a recording still. */
|
|
24847
|
+
sourceMediaId: number().int().optional(),
|
|
24848
|
+
/** A recording still: the playhead instant it was taken at. */
|
|
24849
|
+
epochMs: number().optional(),
|
|
23070
24850
|
sourceKind: MediaFileKindEnum,
|
|
23071
24851
|
sizeBytes: number().int(),
|
|
23072
24852
|
width: number().int(),
|
|
@@ -23077,7 +24857,12 @@ var RetrainFrameSchema = object({
|
|
|
23077
24857
|
/** The operator's "every subject in this frame is boxed". Detector
|
|
23078
24858
|
* evaluation keeps only complete frames: an unboxed subject would count as
|
|
23079
24859
|
* a false positive. */
|
|
23080
|
-
complete: boolean()
|
|
24860
|
+
complete: boolean(),
|
|
24861
|
+
/** The boxes the pipeline drew on this frame. Present on list answers;
|
|
24862
|
+
* empty when nothing the track store holds can be placed on it. */
|
|
24863
|
+
pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
|
|
24864
|
+
/** The named collections this frame belongs to. Present on list answers. */
|
|
24865
|
+
collectionIds: array(string()).readonly().optional()
|
|
23081
24866
|
});
|
|
23082
24867
|
/** Why a copy-on-select could not be honoured — named, never a silent skip. */
|
|
23083
24868
|
var RetrainCopyRefusalSchema = _enum([
|
|
@@ -23108,6 +24893,11 @@ var RetrainFrameListSchema = object({
|
|
|
23108
24893
|
var RetrainExportFilterSchema = object({
|
|
23109
24894
|
deviceIds: array(number()).optional(),
|
|
23110
24895
|
frameIds: array(string()).max(2e4).optional(),
|
|
24896
|
+
/** Only frames in at least one of these named collections. */
|
|
24897
|
+
collectionIds: array(string()).max(200).optional(),
|
|
24898
|
+
/** Exactly the frames of this dataset version (and its completeOnly). An
|
|
24899
|
+
* unknown id selects nothing. */
|
|
24900
|
+
datasetVersionId: string().optional(),
|
|
23111
24901
|
batchId: string().optional(),
|
|
23112
24902
|
/** Only frames the operator marked complete (all subjects boxed). */
|
|
23113
24903
|
completeOnly: boolean().optional()
|
|
@@ -23172,6 +24962,170 @@ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
|
|
|
23172
24962
|
reason: string(),
|
|
23173
24963
|
detail: string().optional()
|
|
23174
24964
|
})]);
|
|
24965
|
+
/** A named set over the retrain corpus — membership only, it owns no pixels. */
|
|
24966
|
+
var RetrainCollectionSchema = object({
|
|
24967
|
+
id: string(),
|
|
24968
|
+
name: string(),
|
|
24969
|
+
createdAt: number(),
|
|
24970
|
+
frameCount: number().int()
|
|
24971
|
+
});
|
|
24972
|
+
var RetrainCollectionCreateResultSchema = discriminatedUnion("kind", [object({
|
|
24973
|
+
kind: literal("created"),
|
|
24974
|
+
collection: RetrainCollectionSchema
|
|
24975
|
+
}), object({
|
|
24976
|
+
kind: literal("refused"),
|
|
24977
|
+
reason: _enum(["empty-name", "duplicate-name"])
|
|
24978
|
+
})]);
|
|
24979
|
+
var RetrainCollectionRenameResultSchema = discriminatedUnion("kind", [object({
|
|
24980
|
+
kind: literal("renamed"),
|
|
24981
|
+
collection: RetrainCollectionSchema
|
|
24982
|
+
}), object({
|
|
24983
|
+
kind: literal("refused"),
|
|
24984
|
+
reason: _enum([
|
|
24985
|
+
"empty-name",
|
|
24986
|
+
"duplicate-name",
|
|
24987
|
+
"unknown-collection"
|
|
24988
|
+
])
|
|
24989
|
+
})]);
|
|
24990
|
+
/**
|
|
24991
|
+
* The outcome of adding the frame at a recording instant. Every refusal is
|
|
24992
|
+
* named: `still-unavailable` (not recording, a gap, or an undecodable frame —
|
|
24993
|
+
* `detail` says which), `still-busy` (the recorder is at its decode bound; try
|
|
24994
|
+
* again), `unreadable-image`, `write-failed`, `unknown-collection`.
|
|
24995
|
+
*/
|
|
24996
|
+
var AddRetrainFrameFromRecordingResultSchema = discriminatedUnion("kind", [object({
|
|
24997
|
+
kind: literal("added"),
|
|
24998
|
+
collectionId: string(),
|
|
24999
|
+
frame: RetrainFrameSchema,
|
|
25000
|
+
/** The moment was already in the dataset; nothing was decoded. */
|
|
25001
|
+
reused: boolean()
|
|
25002
|
+
}), object({
|
|
25003
|
+
kind: literal("refused"),
|
|
25004
|
+
reason: _enum([
|
|
25005
|
+
"unknown-collection",
|
|
25006
|
+
"still-unavailable",
|
|
25007
|
+
"still-busy",
|
|
25008
|
+
"unreadable-image",
|
|
25009
|
+
"write-failed"
|
|
25010
|
+
]),
|
|
25011
|
+
detail: string().optional()
|
|
25012
|
+
})]);
|
|
25013
|
+
/** A vision LLM profile the AI assist may use, and where it sends the frame. */
|
|
25014
|
+
var RetrainAssistProfileSchema = object({
|
|
25015
|
+
id: string(),
|
|
25016
|
+
name: string(),
|
|
25017
|
+
model: string(),
|
|
25018
|
+
kind: string(),
|
|
25019
|
+
/** `true` when the frame would leave the house (a cloud vendor, or an
|
|
25020
|
+
* endpoint that is not on the local network). The page confirms each such
|
|
25021
|
+
* run, and the provider refuses one without `allowCloud`. */
|
|
25022
|
+
leavesHouse: boolean()
|
|
25023
|
+
});
|
|
25024
|
+
/** A box the AI assist proposed: a draft, plus the model's own reason. */
|
|
25025
|
+
var RetrainLlmProposalSchema = RetrainAnnotationDraftSchema.extend({ reason: string() });
|
|
25026
|
+
/** What the AI assist said about a box that was already on the canvas. */
|
|
25027
|
+
var RetrainLlmReviewSchema = object({
|
|
25028
|
+
/** The `ref` the page sent the box under. */
|
|
25029
|
+
ref: string(),
|
|
25030
|
+
verdict: _enum([
|
|
25031
|
+
"confirmed",
|
|
25032
|
+
"wrong-class",
|
|
25033
|
+
"not-an-object",
|
|
25034
|
+
"uncertain"
|
|
25035
|
+
]),
|
|
25036
|
+
suggestedClass: RetrainMacroClassSchema.optional(),
|
|
25037
|
+
reason: string()
|
|
25038
|
+
});
|
|
25039
|
+
/**
|
|
25040
|
+
* The AI assist's answer. `proposed` carries drafts (`source: 'llm'`, the
|
|
25041
|
+
* model and its confidence) and reviews; items the model got wrong (a box off
|
|
25042
|
+
* the frame, an unasked class, an unknown ref) are dropped and counted in
|
|
25043
|
+
* `rejected`. A whole answer that is not the schema is `malformed-answer`.
|
|
25044
|
+
*/
|
|
25045
|
+
var RetrainLlmAssistResultSchema = discriminatedUnion("kind", [object({
|
|
25046
|
+
kind: literal("proposed"),
|
|
25047
|
+
profileId: string(),
|
|
25048
|
+
model: string(),
|
|
25049
|
+
/** The frame was sent outside the house for this answer. */
|
|
25050
|
+
leftHouse: boolean(),
|
|
25051
|
+
proposals: array(RetrainLlmProposalSchema).readonly(),
|
|
25052
|
+
reviews: array(RetrainLlmReviewSchema).readonly(),
|
|
25053
|
+
rejected: number().int()
|
|
25054
|
+
}), object({
|
|
25055
|
+
kind: literal("refused"),
|
|
25056
|
+
reason: _enum([
|
|
25057
|
+
"unknown-frame",
|
|
25058
|
+
"unreadable-frame",
|
|
25059
|
+
"unknown-profile",
|
|
25060
|
+
"profile-disabled",
|
|
25061
|
+
"no-vision",
|
|
25062
|
+
"cloud-not-confirmed",
|
|
25063
|
+
"llm-error",
|
|
25064
|
+
"malformed-answer"
|
|
25065
|
+
]),
|
|
25066
|
+
detail: string().optional()
|
|
25067
|
+
})]);
|
|
25068
|
+
/** What a dataset version is cut from. Every field narrows. */
|
|
25069
|
+
var RetrainDatasetSelectionSchema = object({
|
|
25070
|
+
deviceIds: array(number()).readonly().optional(),
|
|
25071
|
+
collectionIds: array(string()).max(200).readonly().optional(),
|
|
25072
|
+
frameIds: array(string()).max(2e4).readonly().optional()
|
|
25073
|
+
});
|
|
25074
|
+
/** The counts a dataset is judged by. */
|
|
25075
|
+
var RetrainDatasetStatsSchema = object({
|
|
25076
|
+
frames: number().int(),
|
|
25077
|
+
completeFrames: number().int(),
|
|
25078
|
+
/** `completeFrames / frames`, 0..1. */
|
|
25079
|
+
completeness: number(),
|
|
25080
|
+
/** Boxes to learn (model errors excluded). */
|
|
25081
|
+
subjects: number().int(),
|
|
25082
|
+
modelErrors: number().int(),
|
|
25083
|
+
/** Complete frames with no subject. */
|
|
25084
|
+
hardNegatives: number().int(),
|
|
25085
|
+
/** Subjects per class × camera × day/night. */
|
|
25086
|
+
cells: array(object({
|
|
25087
|
+
macroClass: string(),
|
|
25088
|
+
deviceId: number(),
|
|
25089
|
+
lighting: _enum([
|
|
25090
|
+
"day",
|
|
25091
|
+
"night",
|
|
25092
|
+
"unknown"
|
|
25093
|
+
]),
|
|
25094
|
+
subjects: number().int(),
|
|
25095
|
+
frames: number().int()
|
|
25096
|
+
})).readonly(),
|
|
25097
|
+
cameras: array(object({
|
|
25098
|
+
deviceId: number(),
|
|
25099
|
+
frames: number().int(),
|
|
25100
|
+
completeFrames: number().int()
|
|
25101
|
+
})).readonly()
|
|
25102
|
+
});
|
|
25103
|
+
/** An immutable dataset version, without its frame list. */
|
|
25104
|
+
var RetrainDatasetVersionSchema = object({
|
|
25105
|
+
id: string(),
|
|
25106
|
+
name: string(),
|
|
25107
|
+
createdAt: number(),
|
|
25108
|
+
selection: RetrainDatasetSelectionSchema,
|
|
25109
|
+
layout: RetrainExportLayoutSchema,
|
|
25110
|
+
completeOnly: boolean(),
|
|
25111
|
+
frameCount: number().int(),
|
|
25112
|
+
/** sha256 of what the frames taught when the version was frozen. */
|
|
25113
|
+
annotationHash: string(),
|
|
25114
|
+
/** The export manifest schema the version was cut under. */
|
|
25115
|
+
manifestSchema: string(),
|
|
25116
|
+
stats: RetrainDatasetStatsSchema
|
|
25117
|
+
});
|
|
25118
|
+
var CreateRetrainDatasetVersionResultSchema = discriminatedUnion("kind", [object({
|
|
25119
|
+
kind: literal("created"),
|
|
25120
|
+
version: RetrainDatasetVersionSchema
|
|
25121
|
+
}), object({
|
|
25122
|
+
kind: literal("refused"),
|
|
25123
|
+
reason: _enum([
|
|
25124
|
+
"empty-name",
|
|
25125
|
+
"duplicate-name",
|
|
25126
|
+
"no-frames"
|
|
25127
|
+
])
|
|
25128
|
+
})]);
|
|
23175
25129
|
/** The outcome of a lifecycle move owned by the retrain page. */
|
|
23176
25130
|
var RetrainTransitionResultSchema = object({
|
|
23177
25131
|
trackId: string(),
|
|
@@ -23889,7 +25843,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23889
25843
|
auth: "admin"
|
|
23890
25844
|
}), method(object({
|
|
23891
25845
|
deviceId: number(),
|
|
23892
|
-
trackId: string(),
|
|
25846
|
+
trackId: string().optional(),
|
|
23893
25847
|
frameId: string()
|
|
23894
25848
|
}), object({
|
|
23895
25849
|
removed: boolean(),
|
|
@@ -23906,7 +25860,8 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23906
25860
|
auth: "admin"
|
|
23907
25861
|
}), method(object({
|
|
23908
25862
|
deviceId: number(),
|
|
23909
|
-
|
|
25863
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25864
|
+
trackId: string().optional(),
|
|
23910
25865
|
frameId: string(),
|
|
23911
25866
|
subject: RetrainAssistSubjectSchema,
|
|
23912
25867
|
/** Which node runs it. Absent ⇒ wherever an unowned call lands. */
|
|
@@ -23914,12 +25869,16 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23914
25869
|
}), RetrainAssistResultSchema, {
|
|
23915
25870
|
kind: "mutation",
|
|
23916
25871
|
auth: "admin"
|
|
23917
|
-
}), method(object({
|
|
25872
|
+
}), method(object({
|
|
25873
|
+
trackId: string().optional(),
|
|
25874
|
+
frameIds: array(string()).max(2e3).optional()
|
|
25875
|
+
}), array(RetrainAnnotationSchema).readonly(), {
|
|
23918
25876
|
kind: "query",
|
|
23919
25877
|
auth: "admin"
|
|
23920
25878
|
}), method(object({
|
|
23921
25879
|
deviceId: number(),
|
|
23922
|
-
|
|
25880
|
+
/** The frame's track, when it has one — checked against the frame. */
|
|
25881
|
+
trackId: string().optional(),
|
|
23923
25882
|
frameId: string(),
|
|
23924
25883
|
annotations: array(RetrainAnnotationDraftSchema)
|
|
23925
25884
|
}), array(RetrainAnnotationSchema).readonly(), {
|
|
@@ -23942,7 +25901,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23942
25901
|
auth: "admin"
|
|
23943
25902
|
}), method(object({
|
|
23944
25903
|
deviceId: number(),
|
|
23945
|
-
trackId: string(),
|
|
25904
|
+
trackId: string().optional(),
|
|
23946
25905
|
frameId: string(),
|
|
23947
25906
|
complete: boolean()
|
|
23948
25907
|
}), RetrainFrameSchema, {
|
|
@@ -23956,6 +25915,115 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
23956
25915
|
kind: "mutation",
|
|
23957
25916
|
auth: "admin",
|
|
23958
25917
|
timeoutMs: 60 * 6e4
|
|
25918
|
+
}), method(object({
|
|
25919
|
+
filter: RetrainExportFilterSchema,
|
|
25920
|
+
layout: RetrainExportLayoutSchema
|
|
25921
|
+
}), object({
|
|
25922
|
+
ticket: PeerBytesTicketSchema,
|
|
25923
|
+
frames: number().int(),
|
|
25924
|
+
annotations: number().int()
|
|
25925
|
+
}), {
|
|
25926
|
+
kind: "mutation",
|
|
25927
|
+
auth: "admin",
|
|
25928
|
+
timeoutMs: 12e4
|
|
25929
|
+
}), method(object({
|
|
25930
|
+
selection: RetrainDatasetSelectionSchema,
|
|
25931
|
+
completeOnly: boolean().optional()
|
|
25932
|
+
}), RetrainDatasetStatsSchema, {
|
|
25933
|
+
kind: "query",
|
|
25934
|
+
auth: "admin"
|
|
25935
|
+
}), method(object({
|
|
25936
|
+
name: string().max(120),
|
|
25937
|
+
selection: RetrainDatasetSelectionSchema,
|
|
25938
|
+
layout: RetrainExportLayoutSchema,
|
|
25939
|
+
completeOnly: boolean()
|
|
25940
|
+
}), CreateRetrainDatasetVersionResultSchema, {
|
|
25941
|
+
kind: "mutation",
|
|
25942
|
+
auth: "admin",
|
|
25943
|
+
timeoutMs: 12e4
|
|
25944
|
+
}), method(object({}), array(RetrainDatasetVersionSchema).readonly(), {
|
|
25945
|
+
kind: "query",
|
|
25946
|
+
auth: "admin"
|
|
25947
|
+
}), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
25948
|
+
kind: "mutation",
|
|
25949
|
+
auth: "admin"
|
|
25950
|
+
}), method(object({ id: string() }), object({
|
|
25951
|
+
found: boolean(),
|
|
25952
|
+
annotationHash: string(),
|
|
25953
|
+
matches: boolean(),
|
|
25954
|
+
missingFrames: number().int()
|
|
25955
|
+
}), {
|
|
25956
|
+
kind: "query",
|
|
25957
|
+
auth: "admin",
|
|
25958
|
+
timeoutMs: 12e4
|
|
25959
|
+
}), method(object({}), array(RetrainAssistProfileSchema).readonly(), {
|
|
25960
|
+
kind: "query",
|
|
25961
|
+
auth: "admin"
|
|
25962
|
+
}), method(object({
|
|
25963
|
+
deviceId: number(),
|
|
25964
|
+
trackId: string().optional(),
|
|
25965
|
+
frameId: string(),
|
|
25966
|
+
profileId: string(),
|
|
25967
|
+
classes: array(RetrainMacroClassSchema).min(1),
|
|
25968
|
+
boxes: array(object({
|
|
25969
|
+
ref: string(),
|
|
25970
|
+
bbox: RetrainBboxSchema,
|
|
25971
|
+
macroClass: RetrainMacroClassSchema,
|
|
25972
|
+
label: string().optional()
|
|
25973
|
+
})).max(50),
|
|
25974
|
+
allowCloud: boolean()
|
|
25975
|
+
}), RetrainLlmAssistResultSchema, {
|
|
25976
|
+
kind: "mutation",
|
|
25977
|
+
auth: "admin",
|
|
25978
|
+
timeoutMs: 18e4
|
|
25979
|
+
}), method(object({ name: string().max(120) }), RetrainCollectionCreateResultSchema, {
|
|
25980
|
+
kind: "mutation",
|
|
25981
|
+
auth: "admin"
|
|
25982
|
+
}), method(object({}), array(RetrainCollectionSchema).readonly(), {
|
|
25983
|
+
kind: "query",
|
|
25984
|
+
auth: "admin"
|
|
25985
|
+
}), method(object({
|
|
25986
|
+
id: string(),
|
|
25987
|
+
name: string().max(120)
|
|
25988
|
+
}), RetrainCollectionRenameResultSchema, {
|
|
25989
|
+
kind: "mutation",
|
|
25990
|
+
auth: "admin"
|
|
25991
|
+
}), method(object({ id: string() }), object({
|
|
25992
|
+
deleted: boolean(),
|
|
25993
|
+
removedFrames: number().int()
|
|
25994
|
+
}), {
|
|
25995
|
+
kind: "mutation",
|
|
25996
|
+
auth: "admin"
|
|
25997
|
+
}), method(object({
|
|
25998
|
+
collectionId: string(),
|
|
25999
|
+
deviceId: number(),
|
|
26000
|
+
epochMs: number()
|
|
26001
|
+
}), AddRetrainFrameFromRecordingResultSchema, {
|
|
26002
|
+
kind: "mutation",
|
|
26003
|
+
auth: "admin",
|
|
26004
|
+
timeoutMs: 6e4
|
|
26005
|
+
}), method(object({
|
|
26006
|
+
collectionId: string(),
|
|
26007
|
+
frameIds: array(string()).min(1).max(500)
|
|
26008
|
+
}), object({
|
|
26009
|
+
added: number().int(),
|
|
26010
|
+
alreadyMember: number().int(),
|
|
26011
|
+
unknownFrameIds: array(string()).readonly()
|
|
26012
|
+
}), {
|
|
26013
|
+
kind: "mutation",
|
|
26014
|
+
auth: "admin"
|
|
26015
|
+
}), method(object({
|
|
26016
|
+
collectionId: string(),
|
|
26017
|
+
frameId: string()
|
|
26018
|
+
}), object({
|
|
26019
|
+
removed: boolean(),
|
|
26020
|
+
deletedFrame: boolean()
|
|
26021
|
+
}), {
|
|
26022
|
+
kind: "mutation",
|
|
26023
|
+
auth: "admin"
|
|
26024
|
+
}), method(object({ collectionId: string() }), array(RetrainFrameSchema).readonly(), {
|
|
26025
|
+
kind: "query",
|
|
26026
|
+
auth: "admin"
|
|
23959
26027
|
}), method(object({
|
|
23960
26028
|
/** Which of the three event tables owns the row. */
|
|
23961
26029
|
ownerType: EventOwnerTypeSchema,
|
|
@@ -24579,13 +26647,31 @@ var RecommendationReasonSchema = discriminatedUnion("kind", [
|
|
|
24579
26647
|
object({
|
|
24580
26648
|
kind: literal("no-family-build"),
|
|
24581
26649
|
format: ModelFormatSchema$1
|
|
26650
|
+
}),
|
|
26651
|
+
object({
|
|
26652
|
+
kind: literal("kept-custom-pin"),
|
|
26653
|
+
modelId: string(),
|
|
26654
|
+
deviceKey: string()
|
|
24582
26655
|
})
|
|
24583
26656
|
]);
|
|
26657
|
+
/** Why a device is left exactly as it is, whatever the plan would pick (D786). */
|
|
26658
|
+
var KeptReasonSchema = _enum(["custom-pin"]);
|
|
26659
|
+
/**
|
|
26660
|
+
* Where a choice's latency came from (D791): this node's own benchmark
|
|
26661
|
+
* result, or the hardware-class table. Measured on the node beats the table.
|
|
26662
|
+
*/
|
|
26663
|
+
var LatencySourceSchema = discriminatedUnion("kind", [object({ kind: literal("table") }), object({
|
|
26664
|
+
kind: literal("node-benchmark"),
|
|
26665
|
+
resultId: string(),
|
|
26666
|
+
measuredAtMs: number()
|
|
26667
|
+
})]);
|
|
24584
26668
|
var DeviceModelChoiceSchema = object({
|
|
24585
26669
|
modelId: string(),
|
|
24586
26670
|
p50Ms: number(),
|
|
24587
26671
|
fps: number(),
|
|
24588
26672
|
measured: boolean(),
|
|
26673
|
+
/** Absent on a plan from before D791 — read as the table. */
|
|
26674
|
+
source: LatencySourceSchema.optional(),
|
|
24589
26675
|
/** Parallel sessions at the camera rate with the headroom kept free: ⌊fps × (1 − headroom) / camera fps⌋. */
|
|
24590
26676
|
capacitySessions: number(),
|
|
24591
26677
|
personRecall: number()
|
|
@@ -24596,6 +26682,8 @@ var DeviceRecommendationSchema = object({
|
|
|
24596
26682
|
enabled: boolean(),
|
|
24597
26683
|
available: boolean(),
|
|
24598
26684
|
chosen: DeviceModelChoiceSchema.nullable(),
|
|
26685
|
+
/** Present when the device is kept as is: Apply writes nothing on it. */
|
|
26686
|
+
kept: KeptReasonSchema.optional(),
|
|
24599
26687
|
reasons: array(RecommendationReasonSchema).readonly()
|
|
24600
26688
|
});
|
|
24601
26689
|
var NodeRecommendationSchema = object({
|
|
@@ -24649,6 +26737,17 @@ var AutoTuneWarningSchema = discriminatedUnion("kind", [
|
|
|
24649
26737
|
kind: literal("coral-enabled"),
|
|
24650
26738
|
nodeId: string(),
|
|
24651
26739
|
deviceKey: string()
|
|
26740
|
+
}),
|
|
26741
|
+
object({
|
|
26742
|
+
kind: literal("custom-pin-kept"),
|
|
26743
|
+
nodeId: string(),
|
|
26744
|
+
deviceKey: string().nullable(),
|
|
26745
|
+
deviceId: number().nullable(),
|
|
26746
|
+
modelId: string()
|
|
26747
|
+
}),
|
|
26748
|
+
object({
|
|
26749
|
+
kind: literal("custom-registry-unreadable"),
|
|
26750
|
+
error: string()
|
|
24652
26751
|
})
|
|
24653
26752
|
]);
|
|
24654
26753
|
var AutoTuneOptionsSchema = object({
|
|
@@ -24827,13 +26926,14 @@ var SuggestSharesResultSchema = object({
|
|
|
24827
26926
|
nodes: array(SuggestedNodeShareSchema).readonly()
|
|
24828
26927
|
});
|
|
24829
26928
|
/**
|
|
24830
|
-
* Where the node and device shares come from (D750, D755).
|
|
24831
|
-
* - `
|
|
24832
|
-
*
|
|
24833
|
-
*
|
|
24834
|
-
*
|
|
24835
|
-
*
|
|
24836
|
-
*
|
|
26929
|
+
* Where the node and device shares come from (D750, D755, D791).
|
|
26930
|
+
* - `benchmark` (default since D791) — each node's capacity as its own node
|
|
26931
|
+
* benchmark measured it; a node without fresh results is sized from
|
|
26932
|
+
* `hardware` and says so. Measured on the node beats the table.
|
|
26933
|
+
* - `hardware` — computed from each node's static capacity only (its
|
|
26934
|
+
* accelerators at their Auto tune models, from the latency table).
|
|
26935
|
+
* Both are recomputed whenever a node or device joins, leaves, is switched
|
|
26936
|
+
* on or off, changes model, or a benchmark result is written. No load input.
|
|
24837
26937
|
* - `manual` — the operator's stored sliders.
|
|
24838
26938
|
* Either way a node or device that cannot take sessions gives its share to
|
|
24839
26939
|
* the others in proportion; the stored values are never rewritten for that.
|
|
@@ -24882,6 +26982,362 @@ var EffectiveSharesSchema = object({
|
|
|
24882
26982
|
nodeWeights: record(string(), number()),
|
|
24883
26983
|
deviceWeights: record(string(), record(string(), number()))
|
|
24884
26984
|
});
|
|
26985
|
+
/**
|
|
26986
|
+
* Wire shapes of the node benchmark (D791): the operator's plan, the
|
|
26987
|
+
* preflight the confirmation shows, the run the orchestrator owns, what the
|
|
26988
|
+
* measuring runner reports, and the result rows Auto tune and the automatic
|
|
26989
|
+
* shares read.
|
|
26990
|
+
*
|
|
26991
|
+
* ONE node at a time, owned by the pipeline orchestrator. While a run is
|
|
26992
|
+
* active the cluster is in BENCHMARK MODE for that node: it is not a
|
|
26993
|
+
* detection candidate, camera pins naming it are ignored so its sessions move
|
|
26994
|
+
* elsewhere, and both come back when the mode ends — after a crash or a hub
|
|
26995
|
+
* restart too (a persisted manifest, reconciled against the registry).
|
|
26996
|
+
*
|
|
26997
|
+
* Two measurements, both on the node, driven by its own runner (frames never
|
|
26998
|
+
* cross a process at frame rate, D9):
|
|
26999
|
+
* - `device` — one accelerator × one candidate detector, root only, open
|
|
27000
|
+
* loop: how many streams at the camera rate it carries inside the frame
|
|
27001
|
+
* interval;
|
|
27002
|
+
* - `pipeline` — the chosen detector plus the operator's detail steps
|
|
27003
|
+
* (faces, plates, classifiers, CLIP…), on varied frames from the bench
|
|
27004
|
+
* clip: how many parallel sessions the node carries before latency, drops,
|
|
27005
|
+
* CPU, RAM or the event loop give out.
|
|
27006
|
+
*/
|
|
27007
|
+
/** Defaults and bounds, one place. */
|
|
27008
|
+
var NODE_BENCHMARK_DEFAULTS = {
|
|
27009
|
+
fpsPerStream: 10,
|
|
27010
|
+
budgetMinutes: 45,
|
|
27011
|
+
minBudgetMinutes: 10,
|
|
27012
|
+
maxBudgetMinutes: 120,
|
|
27013
|
+
/** A result older than this no longer beats the table. */
|
|
27014
|
+
staleAfterDays: 30,
|
|
27015
|
+
/** Warm-in per ramp step (not accounted). */
|
|
27016
|
+
settleSec: 5,
|
|
27017
|
+
/** Accounted window per ramp step. */
|
|
27018
|
+
measureSec: 20,
|
|
27019
|
+
/** Longest the drain may take before the run is refused. */
|
|
27020
|
+
drainTimeoutSec: 120,
|
|
27021
|
+
/** Candidate models per device in one run. */
|
|
27022
|
+
maxModelsPerDevice: 6
|
|
27023
|
+
};
|
|
27024
|
+
/** The two measurements a run can make. */
|
|
27025
|
+
var NodeBenchmarkPhaseSchema = _enum(["device", "pipeline"]);
|
|
27026
|
+
var NodeBenchmarkDevicePlanSchema = object({
|
|
27027
|
+
/** `<backend>:<device>` — `openvino:npu`, `coreml:all`, `cpu`. */
|
|
27028
|
+
deviceKey: string().min(1),
|
|
27029
|
+
/**
|
|
27030
|
+
* Root detector candidates for the `device` measurement, in the order
|
|
27031
|
+
* measured. The FIRST is the one the `pipeline` measurement runs.
|
|
27032
|
+
*/
|
|
27033
|
+
modelIds: array(string().min(1)).min(1).max(NODE_BENCHMARK_DEFAULTS.maxModelsPerDevice)
|
|
27034
|
+
});
|
|
27035
|
+
/** What the operator confirmed. */
|
|
27036
|
+
var NodeBenchmarkPlanSchema = object({
|
|
27037
|
+
nodeId: string().min(1),
|
|
27038
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
27039
|
+
/** Which measurements run. At least one. */
|
|
27040
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1).default(["device", "pipeline"]),
|
|
27041
|
+
/**
|
|
27042
|
+
* Detail steps (catalog step ids under the root: faces, plates,
|
|
27043
|
+
* classifiers, CLIP…) the `pipeline` measurement enables. The root
|
|
27044
|
+
* detector always runs.
|
|
27045
|
+
*/
|
|
27046
|
+
steps: array(string().min(1)).default([]),
|
|
27047
|
+
/** Offered rate of one stream / session. */
|
|
27048
|
+
fpsPerStream: number().int().min(1).max(30).default(NODE_BENCHMARK_DEFAULTS.fpsPerStream),
|
|
27049
|
+
/** Hard deadline: the mode ends and the cluster is restored when it passes. */
|
|
27050
|
+
budgetMinutes: number().int().min(NODE_BENCHMARK_DEFAULTS.minBudgetMinutes).max(NODE_BENCHMARK_DEFAULTS.maxBudgetMinutes).default(NODE_BENCHMARK_DEFAULTS.budgetMinutes),
|
|
27051
|
+
/** Keep the models the run downloaded (default: delete what was not installed before). */
|
|
27052
|
+
keepDownloadedModels: boolean().default(false),
|
|
27053
|
+
/** Start although the other nodes' capacity does not cover the sessions running now. */
|
|
27054
|
+
acceptInsufficientHeadroom: boolean().default(false)
|
|
27055
|
+
});
|
|
27056
|
+
var NodeBenchmarkRefusalSchema = object({
|
|
27057
|
+
kind: _enum([
|
|
27058
|
+
"benchmark-active",
|
|
27059
|
+
"node-offline",
|
|
27060
|
+
"unknown-device",
|
|
27061
|
+
"no-phase",
|
|
27062
|
+
"insufficient-headroom"
|
|
27063
|
+
]),
|
|
27064
|
+
detail: string(),
|
|
27065
|
+
overridable: boolean()
|
|
27066
|
+
});
|
|
27067
|
+
/** A camera whose detection leaves the node for the run. */
|
|
27068
|
+
var NodeBenchmarkMovingCameraSchema = object({
|
|
27069
|
+
deviceId: number(),
|
|
27070
|
+
/** Placed on the node now (a standing attach or a running session). */
|
|
27071
|
+
placedOnNode: boolean(),
|
|
27072
|
+
/** A node pin naming this node, ignored for the run. */
|
|
27073
|
+
pinnedToNode: boolean()
|
|
27074
|
+
});
|
|
27075
|
+
/** A camera that cannot leave: no other node can obtain its frames. */
|
|
27076
|
+
var NodeBenchmarkStayingCameraSchema = object({
|
|
27077
|
+
deviceId: number(),
|
|
27078
|
+
reason: literal("only-frame-source")
|
|
27079
|
+
});
|
|
27080
|
+
var NodeBenchmarkPreflightSchema = object({
|
|
27081
|
+
nodeId: string(),
|
|
27082
|
+
online: boolean(),
|
|
27083
|
+
moving: array(NodeBenchmarkMovingCameraSchema).readonly(),
|
|
27084
|
+
/** Keep running on the node during the run; the result is flagged contaminated. */
|
|
27085
|
+
staying: array(NodeBenchmarkStayingCameraSchema).readonly(),
|
|
27086
|
+
estimatedDurationMs: number(),
|
|
27087
|
+
/** The run ends and the cluster is restored at the latest after this long. */
|
|
27088
|
+
budgetMs: number(),
|
|
27089
|
+
phases: array(NodeBenchmarkPhaseSchema).readonly(),
|
|
27090
|
+
steps: array(string()).readonly(),
|
|
27091
|
+
devices: array(NodeBenchmarkDevicePlanSchema).readonly(),
|
|
27092
|
+
/** Parallel sessions the cluster runs now, and what the other nodes can carry. */
|
|
27093
|
+
headroom: object({
|
|
27094
|
+
sessionsNow: number(),
|
|
27095
|
+
otherNodesCapacitySessions: number().nullable()
|
|
27096
|
+
}),
|
|
27097
|
+
refusals: array(NodeBenchmarkRefusalSchema).readonly(),
|
|
27098
|
+
canStart: boolean()
|
|
27099
|
+
});
|
|
27100
|
+
/** Where the measuring runner is. */
|
|
27101
|
+
var NodeBenchProgressSchema = object({
|
|
27102
|
+
phase: _enum([
|
|
27103
|
+
"preparing",
|
|
27104
|
+
"device",
|
|
27105
|
+
"pipeline",
|
|
27106
|
+
"cleanup"
|
|
27107
|
+
]),
|
|
27108
|
+
deviceKey: string().nullable(),
|
|
27109
|
+
modelId: string().nullable(),
|
|
27110
|
+
/** Streams (device) or sessions (pipeline) of the step running now. */
|
|
27111
|
+
load: number().nullable(),
|
|
27112
|
+
cellsDone: number(),
|
|
27113
|
+
cellsTotal: number(),
|
|
27114
|
+
message: string()
|
|
27115
|
+
});
|
|
27116
|
+
/** What limited a ramp. `none` = the ramp ran out of steps still passing. */
|
|
27117
|
+
var NodeBenchLimitSchema = _enum([
|
|
27118
|
+
"p95",
|
|
27119
|
+
"drops",
|
|
27120
|
+
"errors",
|
|
27121
|
+
"stall",
|
|
27122
|
+
"cpu",
|
|
27123
|
+
"ram",
|
|
27124
|
+
"none"
|
|
27125
|
+
]);
|
|
27126
|
+
var NodeBenchRampStepSchema = object({
|
|
27127
|
+
load: number(),
|
|
27128
|
+
pass: boolean(),
|
|
27129
|
+
p95Ms: number(),
|
|
27130
|
+
dropRatio: number(),
|
|
27131
|
+
/** Completed frames per second over the accounted window. */
|
|
27132
|
+
fps: number(),
|
|
27133
|
+
cpuPct: number().nullable(),
|
|
27134
|
+
ramFreePct: number().nullable(),
|
|
27135
|
+
failReasons: array(string()).readonly()
|
|
27136
|
+
});
|
|
27137
|
+
var NodeBenchCellSchema = discriminatedUnion("phase", [object({
|
|
27138
|
+
phase: literal("device"),
|
|
27139
|
+
deviceKey: string(),
|
|
27140
|
+
modelId: string(),
|
|
27141
|
+
/** Single-stream latency (the K = 1 step). */
|
|
27142
|
+
p50Ms: number(),
|
|
27143
|
+
p95Ms: number(),
|
|
27144
|
+
p99Ms: number(),
|
|
27145
|
+
/** Frames per second sustained at the last passing step. */
|
|
27146
|
+
fps: number(),
|
|
27147
|
+
/** Streams at the camera rate the device carried inside the frame interval; 0 = not even one. */
|
|
27148
|
+
kMax: number(),
|
|
27149
|
+
limitedBy: NodeBenchLimitSchema,
|
|
27150
|
+
/** First call (model load + warm-up). */
|
|
27151
|
+
warmupMs: number(),
|
|
27152
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
27153
|
+
}), object({
|
|
27154
|
+
phase: literal("pipeline"),
|
|
27155
|
+
deviceKey: string(),
|
|
27156
|
+
modelId: string(),
|
|
27157
|
+
steps: array(string()).readonly(),
|
|
27158
|
+
/** Parallel sessions at the camera rate the node carried; 0 = not even one. */
|
|
27159
|
+
maxSessions: number(),
|
|
27160
|
+
limitedBy: NodeBenchLimitSchema,
|
|
27161
|
+
/** Detail steps that produced at least one result on the clip — a step that never fired measured nothing. */
|
|
27162
|
+
stepsFired: array(string()).readonly(),
|
|
27163
|
+
warmupMs: number(),
|
|
27164
|
+
ramp: array(NodeBenchRampStepSchema).readonly()
|
|
27165
|
+
})]);
|
|
27166
|
+
/**
|
|
27167
|
+
* What a result was measured ON. A result whose fingerprint no longer matches
|
|
27168
|
+
* the node no longer beats the table.
|
|
27169
|
+
*/
|
|
27170
|
+
var NodeBenchFingerprintSchema = object({
|
|
27171
|
+
pipelineVersion: string().nullable(),
|
|
27172
|
+
cpuModel: string().nullable(),
|
|
27173
|
+
ramGb: number().nullable(),
|
|
27174
|
+
os: string().nullable(),
|
|
27175
|
+
/** Per device: the pool the cells ran on (runtime + tuning). */
|
|
27176
|
+
pools: record(string(), object({
|
|
27177
|
+
runtime: string(),
|
|
27178
|
+
numWorkers: number(),
|
|
27179
|
+
concurrency: number(),
|
|
27180
|
+
batchMode: string()
|
|
27181
|
+
})).default({})
|
|
27182
|
+
});
|
|
27183
|
+
/** The frames the run used. */
|
|
27184
|
+
var NodeBenchClipSchema = object({
|
|
27185
|
+
/** `camstack-bench-v1` or `reference-images` (the fallback when the clip is not reachable). */
|
|
27186
|
+
id: string(),
|
|
27187
|
+
revision: string().nullable(),
|
|
27188
|
+
frames: number(),
|
|
27189
|
+
width: number(),
|
|
27190
|
+
height: number()
|
|
27191
|
+
});
|
|
27192
|
+
var NodeBenchRunnerInputSchema = object({
|
|
27193
|
+
runId: string().min(1),
|
|
27194
|
+
devices: array(NodeBenchmarkDevicePlanSchema).min(1),
|
|
27195
|
+
phases: array(NodeBenchmarkPhaseSchema).min(1),
|
|
27196
|
+
/** The full detail step tree root for the `pipeline` measurement is built on the node from these ids. */
|
|
27197
|
+
steps: array(string()).default([]),
|
|
27198
|
+
fpsPerStream: number().int().min(1).max(30),
|
|
27199
|
+
/** The runner stops on its own past this instant, whatever the hub does. */
|
|
27200
|
+
deadlineAtMs: number(),
|
|
27201
|
+
settleSec: number().min(0).max(60).default(NODE_BENCHMARK_DEFAULTS.settleSec),
|
|
27202
|
+
measureSec: number().min(2).max(300).default(NODE_BENCHMARK_DEFAULTS.measureSec),
|
|
27203
|
+
keepDownloadedModels: boolean().default(false)
|
|
27204
|
+
});
|
|
27205
|
+
var NodeBenchRunnerStateSchema = _enum([
|
|
27206
|
+
"running",
|
|
27207
|
+
"done",
|
|
27208
|
+
"failed",
|
|
27209
|
+
"aborted"
|
|
27210
|
+
]);
|
|
27211
|
+
var NodeBenchRunnerStatusSchema = object({
|
|
27212
|
+
runId: string(),
|
|
27213
|
+
nodeId: string(),
|
|
27214
|
+
state: NodeBenchRunnerStateSchema,
|
|
27215
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
27216
|
+
/** Every finished cell so far — a run stopped half way keeps what it measured. */
|
|
27217
|
+
cells: array(NodeBenchCellSchema).readonly(),
|
|
27218
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
27219
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
27220
|
+
/** Cameras seen running on the node during the run (they share its pools). */
|
|
27221
|
+
activeCameraIds: array(number()).readonly(),
|
|
27222
|
+
/** Models the run downloaded and then deleted (not installed before). */
|
|
27223
|
+
deletedModels: array(string()).readonly(),
|
|
27224
|
+
error: string().nullable(),
|
|
27225
|
+
startedAtMs: number(),
|
|
27226
|
+
finishedAtMs: number().nullable()
|
|
27227
|
+
});
|
|
27228
|
+
var NodeBenchmarkStateSchema = _enum([
|
|
27229
|
+
"draining",
|
|
27230
|
+
"measuring",
|
|
27231
|
+
"restoring",
|
|
27232
|
+
"done",
|
|
27233
|
+
"failed",
|
|
27234
|
+
"aborted"
|
|
27235
|
+
]);
|
|
27236
|
+
/** Why a run ended. */
|
|
27237
|
+
var NodeBenchmarkEndReasonSchema = _enum([
|
|
27238
|
+
"completed",
|
|
27239
|
+
"operator-abort",
|
|
27240
|
+
"deadline",
|
|
27241
|
+
"node-lost",
|
|
27242
|
+
"runner-lost",
|
|
27243
|
+
"hub-restart",
|
|
27244
|
+
"drain-timeout",
|
|
27245
|
+
"failed"
|
|
27246
|
+
]);
|
|
27247
|
+
var NodeBenchmarkRunSchema = object({
|
|
27248
|
+
runId: string(),
|
|
27249
|
+
nodeId: string(),
|
|
27250
|
+
state: NodeBenchmarkStateSchema,
|
|
27251
|
+
plan: NodeBenchmarkPlanSchema,
|
|
27252
|
+
startedAtMs: number(),
|
|
27253
|
+
deadlineAtMs: number(),
|
|
27254
|
+
finishedAtMs: number().nullable(),
|
|
27255
|
+
endReason: NodeBenchmarkEndReasonSchema.nullable(),
|
|
27256
|
+
error: string().nullable(),
|
|
27257
|
+
/** Cameras moved off the node for the run. */
|
|
27258
|
+
moved: array(number()).readonly(),
|
|
27259
|
+
/** Cameras that stayed (their only frame source is the node). */
|
|
27260
|
+
staying: array(number()).readonly(),
|
|
27261
|
+
/** Something else ran on the node's pools during the run. */
|
|
27262
|
+
contaminated: boolean(),
|
|
27263
|
+
progress: NodeBenchProgressSchema.nullable(),
|
|
27264
|
+
resultIds: array(string()).readonly()
|
|
27265
|
+
});
|
|
27266
|
+
/** `getNodeBenchmarkStatus`: the active run (or the last one), and whether benchmark mode is on. */
|
|
27267
|
+
var NodeBenchmarkStatusSchema = object({
|
|
27268
|
+
/** The node the cluster is in benchmark mode for; null = none. */
|
|
27269
|
+
modeNodeId: string().nullable(),
|
|
27270
|
+
run: NodeBenchmarkRunSchema.nullable()
|
|
27271
|
+
});
|
|
27272
|
+
/**
|
|
27273
|
+
* One stored measurement — the only authority Auto tune and the automatic
|
|
27274
|
+
* shares read measured capacity from. Written by the orchestrator when a run
|
|
27275
|
+
* ends, never by anyone else.
|
|
27276
|
+
*/
|
|
27277
|
+
var NodeBenchmarkResultSchema = object({
|
|
27278
|
+
id: string(),
|
|
27279
|
+
runId: string(),
|
|
27280
|
+
nodeId: string(),
|
|
27281
|
+
cell: NodeBenchCellSchema,
|
|
27282
|
+
fpsPerStream: number(),
|
|
27283
|
+
fingerprint: NodeBenchFingerprintSchema.nullable(),
|
|
27284
|
+
clip: NodeBenchClipSchema.nullable(),
|
|
27285
|
+
/** Other work shared the node's pools (a camera that could not move, or the hub's own duties). */
|
|
27286
|
+
contaminated: boolean(),
|
|
27287
|
+
stayingCameras: array(number()).readonly(),
|
|
27288
|
+
/** The run ended early; the cell itself completed. */
|
|
27289
|
+
partialRun: boolean(),
|
|
27290
|
+
measuredAtMs: number()
|
|
27291
|
+
});
|
|
27292
|
+
var ListNodeBenchmarkResultsInputSchema = object({
|
|
27293
|
+
nodeId: string().optional(),
|
|
27294
|
+
deviceKey: string().optional()
|
|
27295
|
+
});
|
|
27296
|
+
/** A result with its standing today: does it still beat the table? */
|
|
27297
|
+
var NodeBenchmarkResultViewSchema = NodeBenchmarkResultSchema.extend({
|
|
27298
|
+
/** `fresh` beats the table; `stale` falls back to it; `superseded` = a newer row covers the same cell. */
|
|
27299
|
+
standing: _enum([
|
|
27300
|
+
"fresh",
|
|
27301
|
+
"stale",
|
|
27302
|
+
"superseded"
|
|
27303
|
+
]),
|
|
27304
|
+
staleWhy: _enum([
|
|
27305
|
+
"age",
|
|
27306
|
+
"runtime",
|
|
27307
|
+
"pool-tuning"
|
|
27308
|
+
]).nullable()
|
|
27309
|
+
});
|
|
27310
|
+
object({
|
|
27311
|
+
runId: string(),
|
|
27312
|
+
nodeId: string(),
|
|
27313
|
+
startedAtMs: number(),
|
|
27314
|
+
deadlineAtMs: number(),
|
|
27315
|
+
plan: NodeBenchmarkPlanSchema,
|
|
27316
|
+
moved: array(number()).readonly(),
|
|
27317
|
+
staying: array(number()).readonly()
|
|
27318
|
+
});
|
|
27319
|
+
/** Candidate detectors per device, for the plan editor. */
|
|
27320
|
+
var NodeBenchmarkCandidatesSchema = object({
|
|
27321
|
+
nodeId: string(),
|
|
27322
|
+
reachable: boolean(),
|
|
27323
|
+
devices: array(object({
|
|
27324
|
+
deviceKey: string(),
|
|
27325
|
+
enabled: boolean(),
|
|
27326
|
+
available: boolean(),
|
|
27327
|
+
/** Ordered: what Auto tune would pick first, then the rest of the family by accuracy. */
|
|
27328
|
+
suggested: array(string()).readonly(),
|
|
27329
|
+
/** Every root detector the device has a build for. */
|
|
27330
|
+
all: array(string()).readonly(),
|
|
27331
|
+
/** The model the device runs now, when pinned. */
|
|
27332
|
+
currentModelId: string().nullable()
|
|
27333
|
+
})).readonly(),
|
|
27334
|
+
/** Detail steps the node's catalog offers under the root (for the `pipeline` measurement). */
|
|
27335
|
+
steps: array(object({
|
|
27336
|
+
id: string(),
|
|
27337
|
+
name: string(),
|
|
27338
|
+
slot: string()
|
|
27339
|
+
})).readonly()
|
|
27340
|
+
});
|
|
24885
27341
|
object({
|
|
24886
27342
|
activeCameras: number(),
|
|
24887
27343
|
throttledCameras: number(),
|
|
@@ -25970,7 +28426,16 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
|
|
|
25970
28426
|
}), ParkedTrackFrameSchema.nullable()), method(object({
|
|
25971
28427
|
deviceId: number(),
|
|
25972
28428
|
trackId: string()
|
|
25973
|
-
}), object({ released: number().int().nonnegative() }), { kind: "mutation" })
|
|
28429
|
+
}), object({ released: number().int().nonnegative() }), { kind: "mutation" }), method(NodeBenchRunnerInputSchema, object({
|
|
28430
|
+
accepted: literal(true),
|
|
28431
|
+
runId: string()
|
|
28432
|
+
}), {
|
|
28433
|
+
kind: "mutation",
|
|
28434
|
+
auth: "admin"
|
|
28435
|
+
}), method(object({ runId: string() }), NodeBenchRunnerStatusSchema.nullable(), { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
28436
|
+
kind: "mutation",
|
|
28437
|
+
auth: "admin"
|
|
28438
|
+
});
|
|
25974
28439
|
var CameraPipelineConfigSchema = object({
|
|
25975
28440
|
engine: PipelineEngineChoiceSchema.optional(),
|
|
25976
28441
|
steps: array(PipelineStepInputSchema).readonly(),
|
|
@@ -26609,6 +29074,21 @@ method(object({
|
|
|
26609
29074
|
}), method(PlacementStatsInputSchema, PlacementStatsSchema, { auth: "admin" }), method(SuggestSharesInputSchema, SuggestSharesResultSchema, { auth: "admin" }), method(_void(), EffectiveSharesSchema, { auth: "admin" }), method(SetShareSourceInputSchema, object({ success: literal(true) }), {
|
|
26610
29075
|
kind: "mutation",
|
|
26611
29076
|
auth: "admin"
|
|
29077
|
+
}), method(NodeBenchmarkPlanSchema, NodeBenchmarkPreflightSchema, { auth: "admin" }), method(NodeBenchmarkPlanSchema, discriminatedUnion("kind", [object({
|
|
29078
|
+
kind: literal("started"),
|
|
29079
|
+
runId: string()
|
|
29080
|
+
}), object({
|
|
29081
|
+
kind: literal("refused"),
|
|
29082
|
+
preflight: NodeBenchmarkPreflightSchema
|
|
29083
|
+
})]), {
|
|
29084
|
+
kind: "mutation",
|
|
29085
|
+
auth: "admin"
|
|
29086
|
+
}), method(_void(), NodeBenchmarkStatusSchema, { auth: "admin" }), method(object({ runId: string() }), object({ aborted: boolean() }), {
|
|
29087
|
+
kind: "mutation",
|
|
29088
|
+
auth: "admin"
|
|
29089
|
+
}), method(object({ nodeId: string() }), NodeBenchmarkCandidatesSchema, { auth: "admin" }), method(ListNodeBenchmarkResultsInputSchema, array(NodeBenchmarkResultViewSchema).readonly(), { auth: "admin" }), method(object({ id: string() }), object({ deleted: boolean() }), {
|
|
29090
|
+
kind: "mutation",
|
|
29091
|
+
auth: "admin"
|
|
26612
29092
|
}), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
|
|
26613
29093
|
deviceId: number(),
|
|
26614
29094
|
addonId: string(),
|
|
@@ -27014,8 +29494,8 @@ version: string().optional() }), ServerUpdateActionResultSchema, {
|
|
|
27014
29494
|
* `smtp-provider` — pluggable email delivery surface.
|
|
27015
29495
|
*
|
|
27016
29496
|
* Collection cap: a deployment may install multiple SMTP relays (e.g.
|
|
27017
|
-
* one for transactional / one for notifications). Consumers (
|
|
27018
|
-
*
|
|
29497
|
+
* one for transactional / one for notifications). Consumers (notifier
|
|
29498
|
+
* addons, …) walk the collection and pick the first
|
|
27019
29499
|
* ready provider OR target a specific addonId.
|
|
27020
29500
|
*
|
|
27021
29501
|
* The shape stays small on purpose — `sendEmail` is enough for the
|
|
@@ -27194,7 +29674,7 @@ targets: array(object({
|
|
|
27194
29674
|
})));
|
|
27195
29675
|
/**
|
|
27196
29676
|
* `sso-bridge` — internal hub-only cap that lets SSO-style auth
|
|
27197
|
-
* providers (OIDC, SAML,
|
|
29677
|
+
* providers (OIDC, SAML, …) mint an HMAC-signed token
|
|
27198
29678
|
* carrying the post-callback claims before redirecting back to
|
|
27199
29679
|
* `/api/auth/sso/finish`.
|
|
27200
29680
|
*
|
|
@@ -27257,7 +29737,14 @@ var SsoBridgeClaimsSchema = object({
|
|
|
27257
29737
|
* Verified `iss` of the id_token behind an OIDC login bridge (D782). A
|
|
27258
29738
|
* subject is unique only per issuer, so a link is bound to it.
|
|
27259
29739
|
*/
|
|
27260
|
-
issuer: string().optional()
|
|
29740
|
+
issuer: string().optional(),
|
|
29741
|
+
/**
|
|
29742
|
+
* SHA-256 (hex) of the `camstack_sso_state` cookie the IdP `/start` set in
|
|
29743
|
+
* the browser that began this sign-in. `/api/auth/sso/finish` requires the
|
|
29744
|
+
* request to present the matching cookie — a login bridge is useless in
|
|
29745
|
+
* any other browser.
|
|
29746
|
+
*/
|
|
29747
|
+
browserBinding: string().optional()
|
|
27261
29748
|
});
|
|
27262
29749
|
method(object({
|
|
27263
29750
|
claims: SsoBridgeClaimsSchema,
|
|
@@ -31919,6 +34406,9 @@ var CreateIntegrationInputSchema = object({
|
|
|
31919
34406
|
enabled: boolean().optional(),
|
|
31920
34407
|
info: record(string(), unknown()).optional(),
|
|
31921
34408
|
settings: record(string(), unknown()).optional(),
|
|
34409
|
+
/** Keys of `settings` the form's schema declares secret (by type) — kept in
|
|
34410
|
+
* the keychain, not the table (D787). */
|
|
34411
|
+
secretKeys: array(string()).optional(),
|
|
31922
34412
|
skipRestart: boolean().optional()
|
|
31923
34413
|
});
|
|
31924
34414
|
var UpdateIntegrationInputSchema = object({
|
|
@@ -31942,7 +34432,9 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
|
|
|
31942
34432
|
auth: "admin"
|
|
31943
34433
|
}), method(object({ id: string() }), record(string(), unknown()), { auth: "admin" }), method(object({
|
|
31944
34434
|
id: string(),
|
|
31945
|
-
settings: record(string(), unknown())
|
|
34435
|
+
settings: record(string(), unknown()),
|
|
34436
|
+
/** Keys the form's schema declares secret (by type) — keychain-stored (D787). */
|
|
34437
|
+
secretKeys: array(string()).optional()
|
|
31946
34438
|
}), object({ success: boolean() }), {
|
|
31947
34439
|
kind: "mutation",
|
|
31948
34440
|
auth: "admin"
|
|
@@ -37426,16 +39918,6 @@ var ApiKeySummarySchema = object({
|
|
|
37426
39918
|
createdAt: number(),
|
|
37427
39919
|
lastUsedAt: number().optional()
|
|
37428
39920
|
});
|
|
37429
|
-
var CreateApiKeyInputSchema = object({
|
|
37430
|
-
label: string(),
|
|
37431
|
-
isAdmin: boolean().default(false),
|
|
37432
|
-
allowedProviders: union([array(string()), literal("*")]).optional(),
|
|
37433
|
-
allowedDevices: record(string(), union([array(string()), literal("*")])).optional()
|
|
37434
|
-
});
|
|
37435
|
-
var CreateApiKeyResultSchema = object({
|
|
37436
|
-
token: string(),
|
|
37437
|
-
record: ApiKeySummarySchema
|
|
37438
|
-
});
|
|
37439
39921
|
var ScopedTokenSummarySchema = object({
|
|
37440
39922
|
id: string(),
|
|
37441
39923
|
userId: string(),
|
|
@@ -37534,17 +40016,10 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
37534
40016
|
}), UserSummarySchema.extend({ passwordHash: string() }).nullable(), {
|
|
37535
40017
|
kind: "mutation",
|
|
37536
40018
|
access: "view"
|
|
37537
|
-
}), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(
|
|
37538
|
-
kind: "mutation",
|
|
37539
|
-
auth: "admin",
|
|
37540
|
-
access: "create"
|
|
37541
|
-
}), method(object({ id: string() }), object({ success: literal(true) }), {
|
|
40019
|
+
}), method(_void(), array(ApiKeySummarySchema), { auth: "admin" }), method(object({ id: string() }), object({ success: literal(true) }), {
|
|
37542
40020
|
kind: "mutation",
|
|
37543
40021
|
auth: "admin",
|
|
37544
40022
|
access: "delete"
|
|
37545
|
-
}), method(object({ token: string() }), ApiKeySummarySchema.nullable(), {
|
|
37546
|
-
kind: "mutation",
|
|
37547
|
-
access: "view"
|
|
37548
40023
|
}), method(CreateScopedTokenInputSchema, CreateScopedTokenResultSchema, {
|
|
37549
40024
|
kind: "mutation",
|
|
37550
40025
|
auth: "admin",
|
|
@@ -37618,15 +40093,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
37618
40093
|
}).nullable(), { access: "view" }), method(object({ userId: string() }), array(ExternalIdentitySchema), { auth: "admin" }), method(ExternalIdentityKeySchema, object({
|
|
37619
40094
|
userId: string(),
|
|
37620
40095
|
issuer: string()
|
|
37621
|
-
}).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({
|
|
37622
|
-
userId: string(),
|
|
37623
|
-
issuer: string().min(1),
|
|
37624
|
-
label: string().optional()
|
|
37625
|
-
}), object({ success: literal(true) }), {
|
|
37626
|
-
kind: "mutation",
|
|
37627
|
-
auth: "admin",
|
|
37628
|
-
access: "create"
|
|
37629
|
-
}), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
|
|
40096
|
+
}).nullable(), { auth: "admin" }), method(ExternalIdentityKeySchema.extend({ userId: string() }), object({ success: boolean() }), {
|
|
37630
40097
|
kind: "mutation",
|
|
37631
40098
|
auth: "admin",
|
|
37632
40099
|
access: "delete"
|
|
@@ -38021,6 +40488,451 @@ DeviceType.Camera, method(object({
|
|
|
38021
40488
|
detection: array(ZoneRuleSchema).readonly(),
|
|
38022
40489
|
package: array(ZoneRuleSchema).readonly()
|
|
38023
40490
|
});
|
|
40491
|
+
/**
|
|
40492
|
+
* `training-provider` — ONE cloud that can run the CamStack trainer.
|
|
40493
|
+
*
|
|
40494
|
+
* A thin, mockable translation layer: it knows how to run a container with a
|
|
40495
|
+
* GPU, move a dataset in, read the job's stdout and hand artefacts back. It
|
|
40496
|
+
* knows nothing about datasets, splits, floors, cost policy or Model Studio —
|
|
40497
|
+
* those are the `training` orchestrator's (D805). Every rule written there
|
|
40498
|
+
* once is what makes a second provider (RunPod, a local NVIDIA node) a new
|
|
40499
|
+
* manifest entry and nothing else.
|
|
40500
|
+
*
|
|
40501
|
+
* Collection, routed by the `addonId` in every single-row input (the `llm` /
|
|
40502
|
+
* `notification-output` posture); `describe` concat-fans across providers.
|
|
40503
|
+
* Every method is `admin`: these spend money.
|
|
40504
|
+
*
|
|
40505
|
+
* Every cloud object a provider creates is tagged with the orchestrator's
|
|
40506
|
+
* `jobKey`, so a retried submit finds the job it already started instead of
|
|
40507
|
+
* starting a second GPU, and `listJobs` can find orphans.
|
|
40508
|
+
*
|
|
40509
|
+
* Bytes never ride a cap field: the dataset arrives as a `ctx.peerBytes`
|
|
40510
|
+
* ticket the producer (pipeline-analytics) minted, and artefacts leave as a
|
|
40511
|
+
* ticket the provider mints (D613).
|
|
40512
|
+
*/
|
|
40513
|
+
var TrainingGpuOptionSchema = object({
|
|
40514
|
+
id: string(),
|
|
40515
|
+
label: string(),
|
|
40516
|
+
/** List price, USD per GPU-hour, before any region multiplier. */
|
|
40517
|
+
usdPerHour: number().nonnegative(),
|
|
40518
|
+
vramGb: number().nonnegative()
|
|
40519
|
+
});
|
|
40520
|
+
var TrainingRegionOptionSchema = object({
|
|
40521
|
+
/** `''` = any region (the provider's choice). */
|
|
40522
|
+
id: string(),
|
|
40523
|
+
label: string(),
|
|
40524
|
+
priceMultiplier: number().positive()
|
|
40525
|
+
});
|
|
40526
|
+
/**
|
|
40527
|
+
* The provider's per-account settings, as the orchestrator reads them. They
|
|
40528
|
+
* live in the PROVIDER addon's settings (operator decision 2026-10-08: they
|
|
40529
|
+
* depend on the user's account), never hard-coded in the orchestrator.
|
|
40530
|
+
*/
|
|
40531
|
+
var TrainingProviderDefaultsSchema = object({
|
|
40532
|
+
gpuType: string(),
|
|
40533
|
+
region: string(),
|
|
40534
|
+
costCapUsd: number().nonnegative(),
|
|
40535
|
+
maxRuntimeSec: number().int().positive(),
|
|
40536
|
+
/** Hours a FAILED job's cloud dataset is kept for debugging; 0 = delete at once. */
|
|
40537
|
+
failedDatasetGraceHours: number().nonnegative()
|
|
40538
|
+
});
|
|
40539
|
+
var TrainingProviderDescriptorSchema = object({
|
|
40540
|
+
addonId: string(),
|
|
40541
|
+
/** `modal`, `runpod`, `fake`, … */
|
|
40542
|
+
kind: string(),
|
|
40543
|
+
label: string(),
|
|
40544
|
+
gpuTypes: array(TrainingGpuOptionSchema).readonly(),
|
|
40545
|
+
regions: array(TrainingRegionOptionSchema).readonly(),
|
|
40546
|
+
maxDatasetBytes: number().int().positive(),
|
|
40547
|
+
maxRuntimeSec: number().int().positive(),
|
|
40548
|
+
freeTierNote: string().optional(),
|
|
40549
|
+
/** Where the data goes, in one sentence the confirm dialog repeats. */
|
|
40550
|
+
dataResidencyNote: string(),
|
|
40551
|
+
/** Credentials are present — never the values. */
|
|
40552
|
+
configured: boolean(),
|
|
40553
|
+
defaults: TrainingProviderDefaultsSchema
|
|
40554
|
+
});
|
|
40555
|
+
var TrainingCredentialCheckSchema = object({
|
|
40556
|
+
ok: boolean(),
|
|
40557
|
+
/** Workspace / account name, when the provider says. */
|
|
40558
|
+
account: string().optional(),
|
|
40559
|
+
reason: _enum([
|
|
40560
|
+
"missing",
|
|
40561
|
+
"invalid",
|
|
40562
|
+
"forbidden",
|
|
40563
|
+
"network",
|
|
40564
|
+
"quota"
|
|
40565
|
+
]).optional(),
|
|
40566
|
+
detail: string().optional()
|
|
40567
|
+
});
|
|
40568
|
+
var ProviderJobStateSchema = _enum([
|
|
40569
|
+
"pending",
|
|
40570
|
+
"starting",
|
|
40571
|
+
"running",
|
|
40572
|
+
"succeeded",
|
|
40573
|
+
"failed",
|
|
40574
|
+
"cancelled",
|
|
40575
|
+
"lost"
|
|
40576
|
+
]);
|
|
40577
|
+
var ProviderJobStatusSchema = object({
|
|
40578
|
+
jobKey: string(),
|
|
40579
|
+
providerJobId: string().optional(),
|
|
40580
|
+
state: ProviderJobStateSchema,
|
|
40581
|
+
startedAt: number().optional(),
|
|
40582
|
+
endedAt: number().optional(),
|
|
40583
|
+
exitCode: number().int().optional(),
|
|
40584
|
+
failureReason: string().optional(),
|
|
40585
|
+
gpuType: string(),
|
|
40586
|
+
region: string().optional(),
|
|
40587
|
+
billedSeconds: number().nonnegative(),
|
|
40588
|
+
costUsd: number().nonnegative(),
|
|
40589
|
+
/** True when `costUsd` is runtime × list price, not a billing answer. */
|
|
40590
|
+
costIsEstimate: boolean(),
|
|
40591
|
+
lastFetchedAt: number()
|
|
40592
|
+
});
|
|
40593
|
+
/**
|
|
40594
|
+
* The trainer the job runs, by SOURCE revision: the provider turns it into an
|
|
40595
|
+
* image its own way (Modal builds the published Dockerfile at that revision;
|
|
40596
|
+
* a registry-pull provider maps it to a tag). Recorded on the job and echoed
|
|
40597
|
+
* in `result.json`.
|
|
40598
|
+
*/
|
|
40599
|
+
var TrainerSourceRefSchema = object({
|
|
40600
|
+
/** Hugging Face repo id, e.g. `camstack/camstack-trainer`. */
|
|
40601
|
+
repo: string().min(1),
|
|
40602
|
+
/** A commit sha (never a branch) — the job must be reproducible. */
|
|
40603
|
+
revision: string().regex(/^[0-9a-f]{7,64}$/)
|
|
40604
|
+
});
|
|
40605
|
+
var JobRef = {
|
|
40606
|
+
addonId: string(),
|
|
40607
|
+
jobKey: string().uuid()
|
|
40608
|
+
};
|
|
40609
|
+
var TrainingLogLineSchema = object({
|
|
40610
|
+
ts: number(),
|
|
40611
|
+
text: string()
|
|
40612
|
+
});
|
|
40613
|
+
method(object({}), array(TrainingProviderDescriptorSchema).readonly(), { auth: "admin" }), method(object({ addonId: string() }), TrainingCredentialCheckSchema, {
|
|
40614
|
+
kind: "mutation",
|
|
40615
|
+
auth: "admin",
|
|
40616
|
+
timeoutMs: 3e4
|
|
40617
|
+
}), method(object({
|
|
40618
|
+
addonId: string(),
|
|
40619
|
+
gpuType: string(),
|
|
40620
|
+
region: string(),
|
|
40621
|
+
datasetBytes: number().int().nonnegative(),
|
|
40622
|
+
gpuSecondsLow: number().nonnegative(),
|
|
40623
|
+
gpuSecondsHigh: number().nonnegative()
|
|
40624
|
+
}), object({
|
|
40625
|
+
usdLow: number().nonnegative(),
|
|
40626
|
+
usdHigh: number().nonnegative(),
|
|
40627
|
+
notes: array(string()).readonly()
|
|
40628
|
+
}), { auth: "admin" }), method(object({
|
|
40629
|
+
...JobRef,
|
|
40630
|
+
ticket: PeerBytesTicketSchema
|
|
40631
|
+
}), object({
|
|
40632
|
+
bytes: number().int().nonnegative(),
|
|
40633
|
+
sha256: string()
|
|
40634
|
+
}), {
|
|
40635
|
+
kind: "mutation",
|
|
40636
|
+
auth: "admin",
|
|
40637
|
+
timeoutMs: 120 * 6e4
|
|
40638
|
+
}), method(object({
|
|
40639
|
+
...JobRef,
|
|
40640
|
+
trainer: TrainerSourceRefSchema,
|
|
40641
|
+
jobSpecJson: string().min(2).max(64e3),
|
|
40642
|
+
gpuType: string(),
|
|
40643
|
+
region: string(),
|
|
40644
|
+
maxRuntimeSec: number().int().positive()
|
|
40645
|
+
}), ProviderJobStatusSchema, {
|
|
40646
|
+
kind: "mutation",
|
|
40647
|
+
auth: "admin",
|
|
40648
|
+
timeoutMs: 30 * 6e4
|
|
40649
|
+
}), method(object(JobRef), ProviderJobStatusSchema, {
|
|
40650
|
+
auth: "admin",
|
|
40651
|
+
timeoutMs: 6e4
|
|
40652
|
+
}), method(object({
|
|
40653
|
+
...JobRef,
|
|
40654
|
+
cursor: string().optional(),
|
|
40655
|
+
max: number().int().min(1).max(500)
|
|
40656
|
+
}), object({
|
|
40657
|
+
lines: array(TrainingLogLineSchema).readonly(),
|
|
40658
|
+
cursor: string()
|
|
40659
|
+
}), {
|
|
40660
|
+
auth: "admin",
|
|
40661
|
+
timeoutMs: 6e4
|
|
40662
|
+
}), method(object(JobRef), object({ ok: literal(true) }), {
|
|
40663
|
+
kind: "mutation",
|
|
40664
|
+
auth: "admin",
|
|
40665
|
+
timeoutMs: 6e4
|
|
40666
|
+
}), method(object(JobRef), object({
|
|
40667
|
+
found: boolean(),
|
|
40668
|
+
text: string().optional()
|
|
40669
|
+
}), {
|
|
40670
|
+
kind: "mutation",
|
|
40671
|
+
auth: "admin",
|
|
40672
|
+
timeoutMs: 5 * 6e4
|
|
40673
|
+
}), method(object({
|
|
40674
|
+
...JobRef,
|
|
40675
|
+
path: _enum(["bundle.tar"])
|
|
40676
|
+
}), object({ ticket: PeerBytesTicketSchema }), {
|
|
40677
|
+
kind: "mutation",
|
|
40678
|
+
auth: "admin",
|
|
40679
|
+
timeoutMs: 5 * 6e4
|
|
40680
|
+
}), method(object(JobRef), object({ deleted: array(string()).readonly() }), {
|
|
40681
|
+
kind: "mutation",
|
|
40682
|
+
auth: "admin",
|
|
40683
|
+
timeoutMs: 5 * 6e4
|
|
40684
|
+
}), method(object({ addonId: string() }), array(ProviderJobStatusSchema).readonly(), {
|
|
40685
|
+
auth: "admin",
|
|
40686
|
+
timeoutMs: 2 * 6e4
|
|
40687
|
+
});
|
|
40688
|
+
/**
|
|
40689
|
+
* `training` — the cloud-training orchestrator (D805). Hub-only singleton,
|
|
40690
|
+
* provided by `addon-training`.
|
|
40691
|
+
*
|
|
40692
|
+
* It owns what every provider must agree on, written once:
|
|
40693
|
+
*
|
|
40694
|
+
* - **Dataset versions.** Taken over from pipeline-analytics (D796): the rows
|
|
40695
|
+
* live here (D808); pipeline-analytics still CUTS a version (it owns the corpus and
|
|
40696
|
+
* the export plan) and reaches this store through the five row methods
|
|
40697
|
+
* below, so the Retrain page and the export did not change.
|
|
40698
|
+
* - **Jobs.** A persisted state machine, a reconcile loop against the
|
|
40699
|
+
* provider, a cost guard, a daily orphan sweep and the retention rules.
|
|
40700
|
+
* - **The return flow.** Verified artefacts → Model Studio
|
|
40701
|
+
* (`custom-model-registry.importModelBundle`) → canary on cameras →
|
|
40702
|
+
* rollback. Nothing is ever registered automatically.
|
|
40703
|
+
*
|
|
40704
|
+
* Every method is `admin`.
|
|
40705
|
+
*/
|
|
40706
|
+
/** A version WITH its frame list — what the export and a job read. */
|
|
40707
|
+
var TrainingDatasetVersionRowSchema = RetrainDatasetVersionSchema.omit({ frameCount: true }).extend({ frameIds: array(string()).max(2e4).readonly() });
|
|
40708
|
+
/** A base model a detector job can fine-tune, and the baseline it is judged against. */
|
|
40709
|
+
var TrainingBaseModelSchema = object({
|
|
40710
|
+
modelId: string(),
|
|
40711
|
+
label: string(),
|
|
40712
|
+
weights: string(),
|
|
40713
|
+
imgsz: number().int(),
|
|
40714
|
+
baselineOnnxUrl: string(),
|
|
40715
|
+
baselineFloors: record(string(), number()),
|
|
40716
|
+
/** The base the fleet runs most — the UI's default. */
|
|
40717
|
+
recommended: boolean()
|
|
40718
|
+
});
|
|
40719
|
+
var TrainingPresetSchema = _enum([
|
|
40720
|
+
"quick",
|
|
40721
|
+
"standard",
|
|
40722
|
+
"thorough"
|
|
40723
|
+
]);
|
|
40724
|
+
var TrainingJobRequestSchema = object({
|
|
40725
|
+
datasetVersionId: string().min(1),
|
|
40726
|
+
/** The `training-provider` addon that runs it. */
|
|
40727
|
+
addonId: string().min(1),
|
|
40728
|
+
gpuType: string().min(1),
|
|
40729
|
+
region: string(),
|
|
40730
|
+
baseModelId: string().min(1),
|
|
40731
|
+
preset: TrainingPresetSchema,
|
|
40732
|
+
/** Freeze the backbone's first N layers; `null` = the preset's choice. */
|
|
40733
|
+
freeze: number().int().nonnegative().nullable(),
|
|
40734
|
+
/** Cameras held out whole for evaluation; `null` = the orchestrator's default. */
|
|
40735
|
+
holdoutCameras: array(number().int()).nullable()
|
|
40736
|
+
});
|
|
40737
|
+
var TrainingSplitPlanSchema = object({
|
|
40738
|
+
holdoutCameras: array(number().int()).readonly(),
|
|
40739
|
+
/** Used when no camera is held out: the last N days of every camera. */
|
|
40740
|
+
holdoutLastDays: number().int().nonnegative(),
|
|
40741
|
+
/** Holdout subjects per class (camera holdout only; `null` = known only after the split). */
|
|
40742
|
+
holdoutSupport: record(string(), number().int()).nullable(),
|
|
40743
|
+
trainSubjects: number().int()
|
|
40744
|
+
});
|
|
40745
|
+
var TrainingRefusalReasonSchema = _enum([
|
|
40746
|
+
"unknown-dataset",
|
|
40747
|
+
"unknown-provider",
|
|
40748
|
+
"provider-not-configured",
|
|
40749
|
+
"unknown-base-model",
|
|
40750
|
+
"unknown-gpu",
|
|
40751
|
+
"dataset-too-large",
|
|
40752
|
+
"no-training-subjects",
|
|
40753
|
+
"job-already-running"
|
|
40754
|
+
]);
|
|
40755
|
+
var TrainingJobPlanSchema = object({
|
|
40756
|
+
refusal: object({
|
|
40757
|
+
reason: TrainingRefusalReasonSchema,
|
|
40758
|
+
detail: string()
|
|
40759
|
+
}).nullable(),
|
|
40760
|
+
warnings: array(string()).readonly(),
|
|
40761
|
+
split: TrainingSplitPlanSchema.nullable(),
|
|
40762
|
+
estimate: object({
|
|
40763
|
+
datasetBytes: number().int(),
|
|
40764
|
+
uploadMinutesAt20Mbps: number(),
|
|
40765
|
+
gpuSecondsLow: number(),
|
|
40766
|
+
gpuSecondsHigh: number(),
|
|
40767
|
+
usdLow: number(),
|
|
40768
|
+
usdHigh: number(),
|
|
40769
|
+
notes: array(string()).readonly()
|
|
40770
|
+
}).nullable(),
|
|
40771
|
+
/** Pre-filled from the provider's settings; the operator may lower or raise them. */
|
|
40772
|
+
defaults: object({
|
|
40773
|
+
maxCostUsd: number(),
|
|
40774
|
+
maxRuntimeSec: number().int()
|
|
40775
|
+
}).nullable(),
|
|
40776
|
+
/** The sentence the confirm dialog repeats: where the frames go and when they are deleted. */
|
|
40777
|
+
dataNotice: string()
|
|
40778
|
+
});
|
|
40779
|
+
/**
|
|
40780
|
+
* Orchestrator-owned states, persisted. `uploading` covers exporting the
|
|
40781
|
+
* archive (it is streamed, never staged). Terminal: `failed`, `cancelled`,
|
|
40782
|
+
* `lost`, `expired`, `discarded`. `registered` and `canary` are where a
|
|
40783
|
+
* result lives after the operator acted on it.
|
|
40784
|
+
*/
|
|
40785
|
+
var TrainingJobStateSchema = _enum([
|
|
40786
|
+
"uploading",
|
|
40787
|
+
"submitted",
|
|
40788
|
+
"starting",
|
|
40789
|
+
"running",
|
|
40790
|
+
"collecting",
|
|
40791
|
+
"ready",
|
|
40792
|
+
"registered",
|
|
40793
|
+
"canary",
|
|
40794
|
+
"failed",
|
|
40795
|
+
"cancelling",
|
|
40796
|
+
"cancelled",
|
|
40797
|
+
"lost",
|
|
40798
|
+
"expired",
|
|
40799
|
+
"discarded"
|
|
40800
|
+
]);
|
|
40801
|
+
var TrainingFailureReasonSchema = _enum([
|
|
40802
|
+
"cost-cap",
|
|
40803
|
+
"runtime-cap",
|
|
40804
|
+
"upload-failed",
|
|
40805
|
+
"submit-failed",
|
|
40806
|
+
"trainer-failed",
|
|
40807
|
+
"result-invalid",
|
|
40808
|
+
"checksum-mismatch",
|
|
40809
|
+
"fetch-failed",
|
|
40810
|
+
"provider-error",
|
|
40811
|
+
"hub-restart-during-upload"
|
|
40812
|
+
]);
|
|
40813
|
+
var TrainingProgressPointSchema = object({
|
|
40814
|
+
epoch: number().int(),
|
|
40815
|
+
map50: number().nullable(),
|
|
40816
|
+
map50_95: number().nullable()
|
|
40817
|
+
});
|
|
40818
|
+
var TrainingCanarySchema = object({
|
|
40819
|
+
deviceIds: array(number().int()).readonly(),
|
|
40820
|
+
since: number(),
|
|
40821
|
+
/** Every override the canary replaced, exactly, so rollback restores it. */
|
|
40822
|
+
previous: array(object({
|
|
40823
|
+
deviceId: number().int(),
|
|
40824
|
+
nodeId: string(),
|
|
40825
|
+
deviceKey: string(),
|
|
40826
|
+
patch: object({
|
|
40827
|
+
modelId: string().optional(),
|
|
40828
|
+
settings: record(string(), unknown()).readonly().optional()
|
|
40829
|
+
}).nullable()
|
|
40830
|
+
})).readonly()
|
|
40831
|
+
});
|
|
40832
|
+
var TrainingJobSchema = object({
|
|
40833
|
+
id: string(),
|
|
40834
|
+
idempotencyKey: string(),
|
|
40835
|
+
name: string(),
|
|
40836
|
+
createdAt: number(),
|
|
40837
|
+
updatedAt: number(),
|
|
40838
|
+
state: TrainingJobStateSchema,
|
|
40839
|
+
stage: TrainingStageSchema.nullable(),
|
|
40840
|
+
failure: object({
|
|
40841
|
+
reason: TrainingFailureReasonSchema,
|
|
40842
|
+
stage: string().nullable(),
|
|
40843
|
+
detail: string()
|
|
40844
|
+
}).nullable(),
|
|
40845
|
+
request: TrainingJobRequestSchema,
|
|
40846
|
+
maxCostUsd: number().nonnegative(),
|
|
40847
|
+
maxRuntimeSec: number().int().positive(),
|
|
40848
|
+
trainer: TrainerSourceRefSchema,
|
|
40849
|
+
datasetLayout: RetrainExportLayoutSchema,
|
|
40850
|
+
dataset: object({
|
|
40851
|
+
bytes: number().int(),
|
|
40852
|
+
sha256: string(),
|
|
40853
|
+
uploadedAt: number()
|
|
40854
|
+
}).nullable(),
|
|
40855
|
+
split: TrainingSplitPlanSchema,
|
|
40856
|
+
provider: object({
|
|
40857
|
+
state: ProviderJobStateSchema.nullable(),
|
|
40858
|
+
providerJobId: string().nullable(),
|
|
40859
|
+
startedAt: number().nullable(),
|
|
40860
|
+
endedAt: number().nullable(),
|
|
40861
|
+
billedSeconds: number(),
|
|
40862
|
+
costUsd: number(),
|
|
40863
|
+
costIsEstimate: boolean(),
|
|
40864
|
+
lastPolledAt: number().nullable()
|
|
40865
|
+
}),
|
|
40866
|
+
progress: object({
|
|
40867
|
+
epoch: number().int().nullable(),
|
|
40868
|
+
epochs: number().int().nullable(),
|
|
40869
|
+
etaSec: number().nullable(),
|
|
40870
|
+
series: array(TrainingProgressPointSchema).readonly()
|
|
40871
|
+
}),
|
|
40872
|
+
/** The last lines of the job's output (≤ 200), newest last. Never frame paths. */
|
|
40873
|
+
logTail: array(string()).readonly(),
|
|
40874
|
+
logCursor: string().nullable(),
|
|
40875
|
+
artifacts: object({
|
|
40876
|
+
bundleBytes: number().int(),
|
|
40877
|
+
bundleSha256: string(),
|
|
40878
|
+
fetchedAt: number(),
|
|
40879
|
+
/** When the staged artefacts are deleted from the hub. */
|
|
40880
|
+
expiresAt: number()
|
|
40881
|
+
}).nullable(),
|
|
40882
|
+
/** When the provider-side copy of the frames was deleted; null while it exists. */
|
|
40883
|
+
cloudDatasetDeletedAt: number().nullable(),
|
|
40884
|
+
/** A failed job's dataset is kept until then (the provider's grace), then deleted. */
|
|
40885
|
+
cloudCleanupDueAt: number().nullable(),
|
|
40886
|
+
/** Model ids registered from this job (base, and int8 when kept). */
|
|
40887
|
+
registeredModelIds: array(string()).readonly(),
|
|
40888
|
+
canary: TrainingCanarySchema.nullable()
|
|
40889
|
+
});
|
|
40890
|
+
var IdInput = object({ id: string().min(1) });
|
|
40891
|
+
method(TrainingDatasetVersionRowSchema, object({ stored: boolean() }), {
|
|
40892
|
+
kind: "mutation",
|
|
40893
|
+
auth: "admin"
|
|
40894
|
+
}), method(IdInput, TrainingDatasetVersionRowSchema.nullable(), { auth: "admin" }), method(object({}), array(RetrainDatasetVersionSchema).readonly(), { auth: "admin" }), method(object({ name: string() }), object({ id: string().nullable() }), { auth: "admin" }), method(IdInput, object({ removed: boolean() }), {
|
|
40895
|
+
kind: "mutation",
|
|
40896
|
+
auth: "admin"
|
|
40897
|
+
}), method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" }), method(TrainingJobRequestSchema, TrainingJobPlanSchema, {
|
|
40898
|
+
auth: "admin",
|
|
40899
|
+
timeoutMs: 6e4
|
|
40900
|
+
}), method(TrainingJobRequestSchema.extend({
|
|
40901
|
+
name: string().min(1).max(120),
|
|
40902
|
+
maxCostUsd: number().positive(),
|
|
40903
|
+
maxRuntimeSec: number().int().positive(),
|
|
40904
|
+
idempotencyKey: string().min(8).max(80)
|
|
40905
|
+
}), discriminatedUnion("kind", [object({
|
|
40906
|
+
kind: literal("started"),
|
|
40907
|
+
job: TrainingJobSchema
|
|
40908
|
+
}), object({
|
|
40909
|
+
kind: literal("refused"),
|
|
40910
|
+
reason: TrainingRefusalReasonSchema,
|
|
40911
|
+
detail: string()
|
|
40912
|
+
})]), {
|
|
40913
|
+
kind: "mutation",
|
|
40914
|
+
auth: "admin",
|
|
40915
|
+
timeoutMs: 12e4
|
|
40916
|
+
}), method(object({}), array(TrainingJobSchema).readonly(), { auth: "admin" }), method(IdInput, TrainingJobSchema.nullable(), { auth: "admin" }), method(IdInput, TrainingJobSchema, {
|
|
40917
|
+
kind: "mutation",
|
|
40918
|
+
auth: "admin",
|
|
40919
|
+
timeoutMs: 12e4
|
|
40920
|
+
}), method(IdInput, TrainingResultSchema.nullable(), { auth: "admin" }), method(IdInput.extend({ canaryDeviceIds: array(number().int()).readonly() }), TrainingJobSchema, {
|
|
40921
|
+
kind: "mutation",
|
|
40922
|
+
auth: "admin",
|
|
40923
|
+
timeoutMs: 30 * 6e4
|
|
40924
|
+
}), method(IdInput.extend({ deviceIds: array(number().int()).min(1).readonly() }), TrainingJobSchema, {
|
|
40925
|
+
kind: "mutation",
|
|
40926
|
+
auth: "admin",
|
|
40927
|
+
timeoutMs: 12e4
|
|
40928
|
+
}), method(IdInput, TrainingJobSchema, {
|
|
40929
|
+
kind: "mutation",
|
|
40930
|
+
auth: "admin",
|
|
40931
|
+
timeoutMs: 12e4
|
|
40932
|
+
}), method(IdInput, TrainingJobSchema, {
|
|
40933
|
+
kind: "mutation",
|
|
40934
|
+
auth: "admin"
|
|
40935
|
+
});
|
|
38024
40936
|
SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
|
|
38025
40937
|
Object.freeze({
|
|
38026
40938
|
person: .5,
|
|
@@ -38644,6 +41556,12 @@ Object.freeze({
|
|
|
38644
41556
|
addonId: null,
|
|
38645
41557
|
access: "create"
|
|
38646
41558
|
},
|
|
41559
|
+
"backup.checkBackupKey": {
|
|
41560
|
+
capName: "backup",
|
|
41561
|
+
capScope: "system",
|
|
41562
|
+
addonId: null,
|
|
41563
|
+
access: "create"
|
|
41564
|
+
},
|
|
38647
41565
|
"backup.delete": {
|
|
38648
41566
|
capName: "backup",
|
|
38649
41567
|
capScope: "system",
|
|
@@ -38656,6 +41574,18 @@ Object.freeze({
|
|
|
38656
41574
|
addonId: null,
|
|
38657
41575
|
access: "delete"
|
|
38658
41576
|
},
|
|
41577
|
+
"backup.disableEncryption": {
|
|
41578
|
+
capName: "backup",
|
|
41579
|
+
capScope: "system",
|
|
41580
|
+
addonId: null,
|
|
41581
|
+
access: "create"
|
|
41582
|
+
},
|
|
41583
|
+
"backup.getEncryption": {
|
|
41584
|
+
capName: "backup",
|
|
41585
|
+
capScope: "system",
|
|
41586
|
+
addonId: null,
|
|
41587
|
+
access: "view"
|
|
41588
|
+
},
|
|
38659
41589
|
"backup.getEntries": {
|
|
38660
41590
|
capName: "backup",
|
|
38661
41591
|
capScope: "system",
|
|
@@ -38710,6 +41640,12 @@ Object.freeze({
|
|
|
38710
41640
|
addonId: null,
|
|
38711
41641
|
access: "create"
|
|
38712
41642
|
},
|
|
41643
|
+
"backup.setupEncryption": {
|
|
41644
|
+
capName: "backup",
|
|
41645
|
+
capScope: "system",
|
|
41646
|
+
addonId: null,
|
|
41647
|
+
access: "create"
|
|
41648
|
+
},
|
|
38713
41649
|
"backup.trigger": {
|
|
38714
41650
|
capName: "backup",
|
|
38715
41651
|
capScope: "system",
|
|
@@ -39262,6 +42198,12 @@ Object.freeze({
|
|
|
39262
42198
|
addonId: null,
|
|
39263
42199
|
access: "create"
|
|
39264
42200
|
},
|
|
42201
|
+
"customModelRegistry.importModelBundle": {
|
|
42202
|
+
capName: "custom-model-registry",
|
|
42203
|
+
capScope: "system",
|
|
42204
|
+
addonId: null,
|
|
42205
|
+
access: "create"
|
|
42206
|
+
},
|
|
39265
42207
|
"customModelRegistry.listModels": {
|
|
39266
42208
|
capName: "custom-model-registry",
|
|
39267
42209
|
capScope: "system",
|
|
@@ -40672,6 +43614,108 @@ Object.freeze({
|
|
|
40672
43614
|
addonId: null,
|
|
40673
43615
|
access: "create"
|
|
40674
43616
|
},
|
|
43617
|
+
"keychain.delete": {
|
|
43618
|
+
capName: "keychain",
|
|
43619
|
+
capScope: "system",
|
|
43620
|
+
addonId: null,
|
|
43621
|
+
access: "delete"
|
|
43622
|
+
},
|
|
43623
|
+
"keychain.getState": {
|
|
43624
|
+
capName: "keychain",
|
|
43625
|
+
capScope: "system",
|
|
43626
|
+
addonId: null,
|
|
43627
|
+
access: "view"
|
|
43628
|
+
},
|
|
43629
|
+
"keychain.listMeta": {
|
|
43630
|
+
capName: "keychain",
|
|
43631
|
+
capScope: "system",
|
|
43632
|
+
addonId: null,
|
|
43633
|
+
access: "view"
|
|
43634
|
+
},
|
|
43635
|
+
"keychain.put": {
|
|
43636
|
+
capName: "keychain",
|
|
43637
|
+
capScope: "system",
|
|
43638
|
+
addonId: null,
|
|
43639
|
+
access: "create"
|
|
43640
|
+
},
|
|
43641
|
+
"keychain.resolve": {
|
|
43642
|
+
capName: "keychain",
|
|
43643
|
+
capScope: "system",
|
|
43644
|
+
addonId: null,
|
|
43645
|
+
access: "view"
|
|
43646
|
+
},
|
|
43647
|
+
"keychainAdmin.acknowledgeReset": {
|
|
43648
|
+
capName: "keychain-admin",
|
|
43649
|
+
capScope: "system",
|
|
43650
|
+
addonId: null,
|
|
43651
|
+
access: "create"
|
|
43652
|
+
},
|
|
43653
|
+
"keychainAdmin.deleteOrphans": {
|
|
43654
|
+
capName: "keychain-admin",
|
|
43655
|
+
capScope: "system",
|
|
43656
|
+
addonId: null,
|
|
43657
|
+
access: "delete"
|
|
43658
|
+
},
|
|
43659
|
+
"keychainAdmin.downloadRecoveryKey": {
|
|
43660
|
+
capName: "keychain-admin",
|
|
43661
|
+
capScope: "system",
|
|
43662
|
+
addonId: null,
|
|
43663
|
+
access: "create"
|
|
43664
|
+
},
|
|
43665
|
+
"keychainAdmin.listAudit": {
|
|
43666
|
+
capName: "keychain-admin",
|
|
43667
|
+
capScope: "system",
|
|
43668
|
+
addonId: null,
|
|
43669
|
+
access: "view"
|
|
43670
|
+
},
|
|
43671
|
+
"keychainAdmin.listSecrets": {
|
|
43672
|
+
capName: "keychain-admin",
|
|
43673
|
+
capScope: "system",
|
|
43674
|
+
addonId: null,
|
|
43675
|
+
access: "view"
|
|
43676
|
+
},
|
|
43677
|
+
"keychainAdmin.purgeRetiredKeys": {
|
|
43678
|
+
capName: "keychain-admin",
|
|
43679
|
+
capScope: "system",
|
|
43680
|
+
addonId: null,
|
|
43681
|
+
access: "delete"
|
|
43682
|
+
},
|
|
43683
|
+
"keychainAdmin.resetKeychain": {
|
|
43684
|
+
capName: "keychain-admin",
|
|
43685
|
+
capScope: "system",
|
|
43686
|
+
addonId: null,
|
|
43687
|
+
access: "delete"
|
|
43688
|
+
},
|
|
43689
|
+
"keychainAdmin.resetReport": {
|
|
43690
|
+
capName: "keychain-admin",
|
|
43691
|
+
capScope: "system",
|
|
43692
|
+
addonId: null,
|
|
43693
|
+
access: "delete"
|
|
43694
|
+
},
|
|
43695
|
+
"keychainAdmin.reveal": {
|
|
43696
|
+
capName: "keychain-admin",
|
|
43697
|
+
capScope: "system",
|
|
43698
|
+
addonId: null,
|
|
43699
|
+
access: "create"
|
|
43700
|
+
},
|
|
43701
|
+
"keychainAdmin.rotateMasterKey": {
|
|
43702
|
+
capName: "keychain-admin",
|
|
43703
|
+
capScope: "system",
|
|
43704
|
+
addonId: null,
|
|
43705
|
+
access: "create"
|
|
43706
|
+
},
|
|
43707
|
+
"keychainAdmin.setSystemSecret": {
|
|
43708
|
+
capName: "keychain-admin",
|
|
43709
|
+
capScope: "system",
|
|
43710
|
+
addonId: null,
|
|
43711
|
+
access: "create"
|
|
43712
|
+
},
|
|
43713
|
+
"keychainAdmin.status": {
|
|
43714
|
+
capName: "keychain-admin",
|
|
43715
|
+
capScope: "system",
|
|
43716
|
+
addonId: null,
|
|
43717
|
+
access: "view"
|
|
43718
|
+
},
|
|
40675
43719
|
"lawnMowerControl.dock": {
|
|
40676
43720
|
capName: "lawn-mower-control",
|
|
40677
43721
|
capScope: "device",
|
|
@@ -42046,6 +45090,18 @@ Object.freeze({
|
|
|
42046
45090
|
addonId: null,
|
|
42047
45091
|
access: "create"
|
|
42048
45092
|
},
|
|
45093
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": {
|
|
45094
|
+
capName: "pipeline-analytics",
|
|
45095
|
+
capScope: "device",
|
|
45096
|
+
addonId: null,
|
|
45097
|
+
access: "create"
|
|
45098
|
+
},
|
|
45099
|
+
"pipelineAnalytics.addRetrainFramesToCollection": {
|
|
45100
|
+
capName: "pipeline-analytics",
|
|
45101
|
+
capScope: "device",
|
|
45102
|
+
addonId: null,
|
|
45103
|
+
access: "create"
|
|
45104
|
+
},
|
|
42049
45105
|
"pipelineAnalytics.applyDeviceSettingsPatch": {
|
|
42050
45106
|
capName: "pipeline-analytics",
|
|
42051
45107
|
capScope: "device",
|
|
@@ -42094,12 +45150,36 @@ Object.freeze({
|
|
|
42094
45150
|
addonId: null,
|
|
42095
45151
|
access: "view"
|
|
42096
45152
|
},
|
|
45153
|
+
"pipelineAnalytics.createRetrainCollection": {
|
|
45154
|
+
capName: "pipeline-analytics",
|
|
45155
|
+
capScope: "device",
|
|
45156
|
+
addonId: null,
|
|
45157
|
+
access: "create"
|
|
45158
|
+
},
|
|
45159
|
+
"pipelineAnalytics.createRetrainDatasetVersion": {
|
|
45160
|
+
capName: "pipeline-analytics",
|
|
45161
|
+
capScope: "device",
|
|
45162
|
+
addonId: null,
|
|
45163
|
+
access: "create"
|
|
45164
|
+
},
|
|
42097
45165
|
"pipelineAnalytics.deleteDeviceEvents": {
|
|
42098
45166
|
capName: "pipeline-analytics",
|
|
42099
45167
|
capScope: "device",
|
|
42100
45168
|
addonId: null,
|
|
42101
45169
|
access: "delete"
|
|
42102
45170
|
},
|
|
45171
|
+
"pipelineAnalytics.deleteRetrainCollection": {
|
|
45172
|
+
capName: "pipeline-analytics",
|
|
45173
|
+
capScope: "device",
|
|
45174
|
+
addonId: null,
|
|
45175
|
+
access: "delete"
|
|
45176
|
+
},
|
|
45177
|
+
"pipelineAnalytics.deleteRetrainDatasetVersion": {
|
|
45178
|
+
capName: "pipeline-analytics",
|
|
45179
|
+
capScope: "device",
|
|
45180
|
+
addonId: null,
|
|
45181
|
+
access: "delete"
|
|
45182
|
+
},
|
|
42103
45183
|
"pipelineAnalytics.deleteTracks": {
|
|
42104
45184
|
capName: "pipeline-analytics",
|
|
42105
45185
|
capScope: "device",
|
|
@@ -42304,6 +45384,30 @@ Object.freeze({
|
|
|
42304
45384
|
addonId: null,
|
|
42305
45385
|
access: "view"
|
|
42306
45386
|
},
|
|
45387
|
+
"pipelineAnalytics.listRetrainAssistProfiles": {
|
|
45388
|
+
capName: "pipeline-analytics",
|
|
45389
|
+
capScope: "device",
|
|
45390
|
+
addonId: null,
|
|
45391
|
+
access: "view"
|
|
45392
|
+
},
|
|
45393
|
+
"pipelineAnalytics.listRetrainCollectionFrames": {
|
|
45394
|
+
capName: "pipeline-analytics",
|
|
45395
|
+
capScope: "device",
|
|
45396
|
+
addonId: null,
|
|
45397
|
+
access: "view"
|
|
45398
|
+
},
|
|
45399
|
+
"pipelineAnalytics.listRetrainCollections": {
|
|
45400
|
+
capName: "pipeline-analytics",
|
|
45401
|
+
capScope: "device",
|
|
45402
|
+
addonId: null,
|
|
45403
|
+
access: "view"
|
|
45404
|
+
},
|
|
45405
|
+
"pipelineAnalytics.listRetrainDatasetVersions": {
|
|
45406
|
+
capName: "pipeline-analytics",
|
|
45407
|
+
capScope: "device",
|
|
45408
|
+
addonId: null,
|
|
45409
|
+
access: "view"
|
|
45410
|
+
},
|
|
42307
45411
|
"pipelineAnalytics.listRetrainFrames": {
|
|
42308
45412
|
capName: "pipeline-analytics",
|
|
42309
45413
|
capScope: "device",
|
|
@@ -42334,6 +45438,12 @@ Object.freeze({
|
|
|
42334
45438
|
addonId: null,
|
|
42335
45439
|
access: "view"
|
|
42336
45440
|
},
|
|
45441
|
+
"pipelineAnalytics.offerRetrainArchive": {
|
|
45442
|
+
capName: "pipeline-analytics",
|
|
45443
|
+
capScope: "device",
|
|
45444
|
+
addonId: null,
|
|
45445
|
+
access: "create"
|
|
45446
|
+
},
|
|
42337
45447
|
"pipelineAnalytics.ownersWithMedia": {
|
|
42338
45448
|
capName: "pipeline-analytics",
|
|
42339
45449
|
capScope: "device",
|
|
@@ -42346,12 +45456,24 @@ Object.freeze({
|
|
|
42346
45456
|
addonId: null,
|
|
42347
45457
|
access: "create"
|
|
42348
45458
|
},
|
|
45459
|
+
"pipelineAnalytics.previewRetrainDataset": {
|
|
45460
|
+
capName: "pipeline-analytics",
|
|
45461
|
+
capScope: "device",
|
|
45462
|
+
addonId: null,
|
|
45463
|
+
access: "view"
|
|
45464
|
+
},
|
|
42349
45465
|
"pipelineAnalytics.proposeRetrainAnnotations": {
|
|
42350
45466
|
capName: "pipeline-analytics",
|
|
42351
45467
|
capScope: "device",
|
|
42352
45468
|
addonId: null,
|
|
42353
45469
|
access: "create"
|
|
42354
45470
|
},
|
|
45471
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": {
|
|
45472
|
+
capName: "pipeline-analytics",
|
|
45473
|
+
capScope: "device",
|
|
45474
|
+
addonId: null,
|
|
45475
|
+
access: "create"
|
|
45476
|
+
},
|
|
42355
45477
|
"pipelineAnalytics.pruneEvents": {
|
|
42356
45478
|
capName: "pipeline-analytics",
|
|
42357
45479
|
capScope: "device",
|
|
@@ -42406,6 +45528,18 @@ Object.freeze({
|
|
|
42406
45528
|
addonId: null,
|
|
42407
45529
|
access: "create"
|
|
42408
45530
|
},
|
|
45531
|
+
"pipelineAnalytics.removeRetrainFrameFromCollection": {
|
|
45532
|
+
capName: "pipeline-analytics",
|
|
45533
|
+
capScope: "device",
|
|
45534
|
+
addonId: null,
|
|
45535
|
+
access: "delete"
|
|
45536
|
+
},
|
|
45537
|
+
"pipelineAnalytics.renameRetrainCollection": {
|
|
45538
|
+
capName: "pipeline-analytics",
|
|
45539
|
+
capScope: "device",
|
|
45540
|
+
addonId: null,
|
|
45541
|
+
access: "create"
|
|
45542
|
+
},
|
|
42409
45543
|
"pipelineAnalytics.restageRetrainTrack": {
|
|
42410
45544
|
capName: "pipeline-analytics",
|
|
42411
45545
|
capScope: "device",
|
|
@@ -42466,6 +45600,12 @@ Object.freeze({
|
|
|
42466
45600
|
addonId: null,
|
|
42467
45601
|
access: "create"
|
|
42468
45602
|
},
|
|
45603
|
+
"pipelineAnalytics.verifyRetrainDatasetVersion": {
|
|
45604
|
+
capName: "pipeline-analytics",
|
|
45605
|
+
capScope: "device",
|
|
45606
|
+
addonId: null,
|
|
45607
|
+
access: "view"
|
|
45608
|
+
},
|
|
42469
45609
|
"pipelineAnalytics.wipeAllAnalytics": {
|
|
42470
45610
|
capName: "pipeline-analytics",
|
|
42471
45611
|
capScope: "device",
|
|
@@ -42694,6 +45834,12 @@ Object.freeze({
|
|
|
42694
45834
|
addonId: null,
|
|
42695
45835
|
access: "view"
|
|
42696
45836
|
},
|
|
45837
|
+
"pipelineOrchestrator.abortNodeBenchmark": {
|
|
45838
|
+
capName: "pipeline-orchestrator",
|
|
45839
|
+
capScope: "system",
|
|
45840
|
+
addonId: null,
|
|
45841
|
+
access: "create"
|
|
45842
|
+
},
|
|
42697
45843
|
"pipelineOrchestrator.applyAutoTune": {
|
|
42698
45844
|
capName: "pipeline-orchestrator",
|
|
42699
45845
|
capScope: "system",
|
|
@@ -42718,6 +45864,12 @@ Object.freeze({
|
|
|
42718
45864
|
addonId: null,
|
|
42719
45865
|
access: "create"
|
|
42720
45866
|
},
|
|
45867
|
+
"pipelineOrchestrator.deleteNodeBenchmarkResult": {
|
|
45868
|
+
capName: "pipeline-orchestrator",
|
|
45869
|
+
capScope: "system",
|
|
45870
|
+
addonId: null,
|
|
45871
|
+
access: "delete"
|
|
45872
|
+
},
|
|
42721
45873
|
"pipelineOrchestrator.getAgentLoad": {
|
|
42722
45874
|
capName: "pipeline-orchestrator",
|
|
42723
45875
|
capScope: "system",
|
|
@@ -42826,6 +45978,24 @@ Object.freeze({
|
|
|
42826
45978
|
addonId: null,
|
|
42827
45979
|
access: "view"
|
|
42828
45980
|
},
|
|
45981
|
+
"pipelineOrchestrator.getNodeBenchmarkCandidates": {
|
|
45982
|
+
capName: "pipeline-orchestrator",
|
|
45983
|
+
capScope: "system",
|
|
45984
|
+
addonId: null,
|
|
45985
|
+
access: "view"
|
|
45986
|
+
},
|
|
45987
|
+
"pipelineOrchestrator.getNodeBenchmarkPreflight": {
|
|
45988
|
+
capName: "pipeline-orchestrator",
|
|
45989
|
+
capScope: "system",
|
|
45990
|
+
addonId: null,
|
|
45991
|
+
access: "view"
|
|
45992
|
+
},
|
|
45993
|
+
"pipelineOrchestrator.getNodeBenchmarkStatus": {
|
|
45994
|
+
capName: "pipeline-orchestrator",
|
|
45995
|
+
capScope: "system",
|
|
45996
|
+
addonId: null,
|
|
45997
|
+
access: "view"
|
|
45998
|
+
},
|
|
42829
45999
|
"pipelineOrchestrator.getNodeInferenceDevices": {
|
|
42830
46000
|
capName: "pipeline-orchestrator",
|
|
42831
46001
|
capScope: "system",
|
|
@@ -42868,6 +46038,12 @@ Object.freeze({
|
|
|
42868
46038
|
addonId: null,
|
|
42869
46039
|
access: "view"
|
|
42870
46040
|
},
|
|
46041
|
+
"pipelineOrchestrator.listNodeBenchmarkResults": {
|
|
46042
|
+
capName: "pipeline-orchestrator",
|
|
46043
|
+
capScope: "system",
|
|
46044
|
+
addonId: null,
|
|
46045
|
+
access: "view"
|
|
46046
|
+
},
|
|
42871
46047
|
"pipelineOrchestrator.pauseForStorageMigration": {
|
|
42872
46048
|
capName: "pipeline-orchestrator",
|
|
42873
46049
|
capScope: "system",
|
|
@@ -43012,6 +46188,12 @@ Object.freeze({
|
|
|
43012
46188
|
addonId: null,
|
|
43013
46189
|
access: "create"
|
|
43014
46190
|
},
|
|
46191
|
+
"pipelineOrchestrator.startNodeBenchmark": {
|
|
46192
|
+
capName: "pipeline-orchestrator",
|
|
46193
|
+
capScope: "system",
|
|
46194
|
+
addonId: null,
|
|
46195
|
+
access: "create"
|
|
46196
|
+
},
|
|
43015
46197
|
"pipelineOrchestrator.suggestShares": {
|
|
43016
46198
|
capName: "pipeline-orchestrator",
|
|
43017
46199
|
capScope: "system",
|
|
@@ -43030,6 +46212,12 @@ Object.freeze({
|
|
|
43030
46212
|
addonId: null,
|
|
43031
46213
|
access: "create"
|
|
43032
46214
|
},
|
|
46215
|
+
"pipelineRunner.abortNodeBench": {
|
|
46216
|
+
capName: "pipeline-runner",
|
|
46217
|
+
capScope: "system",
|
|
46218
|
+
addonId: null,
|
|
46219
|
+
access: "create"
|
|
46220
|
+
},
|
|
43033
46221
|
"pipelineRunner.attachCamera": {
|
|
43034
46222
|
capName: "pipeline-runner",
|
|
43035
46223
|
capScope: "system",
|
|
@@ -43078,6 +46266,12 @@ Object.freeze({
|
|
|
43078
46266
|
addonId: null,
|
|
43079
46267
|
access: "view"
|
|
43080
46268
|
},
|
|
46269
|
+
"pipelineRunner.getNodeBenchStatus": {
|
|
46270
|
+
capName: "pipeline-runner",
|
|
46271
|
+
capScope: "system",
|
|
46272
|
+
addonId: null,
|
|
46273
|
+
access: "view"
|
|
46274
|
+
},
|
|
43081
46275
|
"pipelineRunner.getParkedTrackFrame": {
|
|
43082
46276
|
capName: "pipeline-runner",
|
|
43083
46277
|
capScope: "system",
|
|
@@ -43120,6 +46314,12 @@ Object.freeze({
|
|
|
43120
46314
|
addonId: null,
|
|
43121
46315
|
access: "create"
|
|
43122
46316
|
},
|
|
46317
|
+
"pipelineRunner.startNodeBench": {
|
|
46318
|
+
capName: "pipeline-runner",
|
|
46319
|
+
capScope: "system",
|
|
46320
|
+
addonId: null,
|
|
46321
|
+
access: "create"
|
|
46322
|
+
},
|
|
43123
46323
|
"plateGallery.assignPlate": {
|
|
43124
46324
|
capName: "plate-gallery",
|
|
43125
46325
|
capScope: "system",
|
|
@@ -44782,6 +47982,174 @@ Object.freeze({
|
|
|
44782
47982
|
addonId: null,
|
|
44783
47983
|
access: "view"
|
|
44784
47984
|
},
|
|
47985
|
+
"training.canaryResult": {
|
|
47986
|
+
capName: "training",
|
|
47987
|
+
capScope: "system",
|
|
47988
|
+
addonId: null,
|
|
47989
|
+
access: "create"
|
|
47990
|
+
},
|
|
47991
|
+
"training.cancelJob": {
|
|
47992
|
+
capName: "training",
|
|
47993
|
+
capScope: "system",
|
|
47994
|
+
addonId: null,
|
|
47995
|
+
access: "create"
|
|
47996
|
+
},
|
|
47997
|
+
"training.discardResult": {
|
|
47998
|
+
capName: "training",
|
|
47999
|
+
capScope: "system",
|
|
48000
|
+
addonId: null,
|
|
48001
|
+
access: "create"
|
|
48002
|
+
},
|
|
48003
|
+
"training.findDatasetVersionIdByName": {
|
|
48004
|
+
capName: "training",
|
|
48005
|
+
capScope: "system",
|
|
48006
|
+
addonId: null,
|
|
48007
|
+
access: "view"
|
|
48008
|
+
},
|
|
48009
|
+
"training.getDatasetVersion": {
|
|
48010
|
+
capName: "training",
|
|
48011
|
+
capScope: "system",
|
|
48012
|
+
addonId: null,
|
|
48013
|
+
access: "view"
|
|
48014
|
+
},
|
|
48015
|
+
"training.getJob": {
|
|
48016
|
+
capName: "training",
|
|
48017
|
+
capScope: "system",
|
|
48018
|
+
addonId: null,
|
|
48019
|
+
access: "view"
|
|
48020
|
+
},
|
|
48021
|
+
"training.getJobResult": {
|
|
48022
|
+
capName: "training",
|
|
48023
|
+
capScope: "system",
|
|
48024
|
+
addonId: null,
|
|
48025
|
+
access: "view"
|
|
48026
|
+
},
|
|
48027
|
+
"training.listBaseModels": {
|
|
48028
|
+
capName: "training",
|
|
48029
|
+
capScope: "system",
|
|
48030
|
+
addonId: null,
|
|
48031
|
+
access: "view"
|
|
48032
|
+
},
|
|
48033
|
+
"training.listDatasetVersions": {
|
|
48034
|
+
capName: "training",
|
|
48035
|
+
capScope: "system",
|
|
48036
|
+
addonId: null,
|
|
48037
|
+
access: "view"
|
|
48038
|
+
},
|
|
48039
|
+
"training.listJobs": {
|
|
48040
|
+
capName: "training",
|
|
48041
|
+
capScope: "system",
|
|
48042
|
+
addonId: null,
|
|
48043
|
+
access: "view"
|
|
48044
|
+
},
|
|
48045
|
+
"training.planJob": {
|
|
48046
|
+
capName: "training",
|
|
48047
|
+
capScope: "system",
|
|
48048
|
+
addonId: null,
|
|
48049
|
+
access: "view"
|
|
48050
|
+
},
|
|
48051
|
+
"training.putDatasetVersion": {
|
|
48052
|
+
capName: "training",
|
|
48053
|
+
capScope: "system",
|
|
48054
|
+
addonId: null,
|
|
48055
|
+
access: "create"
|
|
48056
|
+
},
|
|
48057
|
+
"training.registerResult": {
|
|
48058
|
+
capName: "training",
|
|
48059
|
+
capScope: "system",
|
|
48060
|
+
addonId: null,
|
|
48061
|
+
access: "create"
|
|
48062
|
+
},
|
|
48063
|
+
"training.removeDatasetVersion": {
|
|
48064
|
+
capName: "training",
|
|
48065
|
+
capScope: "system",
|
|
48066
|
+
addonId: null,
|
|
48067
|
+
access: "delete"
|
|
48068
|
+
},
|
|
48069
|
+
"training.rollbackCanary": {
|
|
48070
|
+
capName: "training",
|
|
48071
|
+
capScope: "system",
|
|
48072
|
+
addonId: null,
|
|
48073
|
+
access: "create"
|
|
48074
|
+
},
|
|
48075
|
+
"training.startJob": {
|
|
48076
|
+
capName: "training",
|
|
48077
|
+
capScope: "system",
|
|
48078
|
+
addonId: null,
|
|
48079
|
+
access: "create"
|
|
48080
|
+
},
|
|
48081
|
+
"trainingProvider.cancelJob": {
|
|
48082
|
+
capName: "training-provider",
|
|
48083
|
+
capScope: "system",
|
|
48084
|
+
addonId: null,
|
|
48085
|
+
access: "create"
|
|
48086
|
+
},
|
|
48087
|
+
"trainingProvider.cleanupJob": {
|
|
48088
|
+
capName: "training-provider",
|
|
48089
|
+
capScope: "system",
|
|
48090
|
+
addonId: null,
|
|
48091
|
+
access: "create"
|
|
48092
|
+
},
|
|
48093
|
+
"trainingProvider.describe": {
|
|
48094
|
+
capName: "training-provider",
|
|
48095
|
+
capScope: "system",
|
|
48096
|
+
addonId: null,
|
|
48097
|
+
access: "view"
|
|
48098
|
+
},
|
|
48099
|
+
"trainingProvider.estimateJob": {
|
|
48100
|
+
capName: "training-provider",
|
|
48101
|
+
capScope: "system",
|
|
48102
|
+
addonId: null,
|
|
48103
|
+
access: "view"
|
|
48104
|
+
},
|
|
48105
|
+
"trainingProvider.getJob": {
|
|
48106
|
+
capName: "training-provider",
|
|
48107
|
+
capScope: "system",
|
|
48108
|
+
addonId: null,
|
|
48109
|
+
access: "view"
|
|
48110
|
+
},
|
|
48111
|
+
"trainingProvider.listJobEvents": {
|
|
48112
|
+
capName: "training-provider",
|
|
48113
|
+
capScope: "system",
|
|
48114
|
+
addonId: null,
|
|
48115
|
+
access: "view"
|
|
48116
|
+
},
|
|
48117
|
+
"trainingProvider.listJobs": {
|
|
48118
|
+
capName: "training-provider",
|
|
48119
|
+
capScope: "system",
|
|
48120
|
+
addonId: null,
|
|
48121
|
+
access: "view"
|
|
48122
|
+
},
|
|
48123
|
+
"trainingProvider.offerArtifact": {
|
|
48124
|
+
capName: "training-provider",
|
|
48125
|
+
capScope: "system",
|
|
48126
|
+
addonId: null,
|
|
48127
|
+
access: "create"
|
|
48128
|
+
},
|
|
48129
|
+
"trainingProvider.readResult": {
|
|
48130
|
+
capName: "training-provider",
|
|
48131
|
+
capScope: "system",
|
|
48132
|
+
addonId: null,
|
|
48133
|
+
access: "create"
|
|
48134
|
+
},
|
|
48135
|
+
"trainingProvider.submitJob": {
|
|
48136
|
+
capName: "training-provider",
|
|
48137
|
+
capScope: "system",
|
|
48138
|
+
addonId: null,
|
|
48139
|
+
access: "create"
|
|
48140
|
+
},
|
|
48141
|
+
"trainingProvider.uploadDataset": {
|
|
48142
|
+
capName: "training-provider",
|
|
48143
|
+
capScope: "system",
|
|
48144
|
+
addonId: null,
|
|
48145
|
+
access: "create"
|
|
48146
|
+
},
|
|
48147
|
+
"trainingProvider.validateCredentials": {
|
|
48148
|
+
capName: "training-provider",
|
|
48149
|
+
capScope: "system",
|
|
48150
|
+
addonId: null,
|
|
48151
|
+
access: "create"
|
|
48152
|
+
},
|
|
44785
48153
|
"turnProvider.getTurnServers": {
|
|
44786
48154
|
capName: "turn-provider",
|
|
44787
48155
|
capScope: "system",
|
|
@@ -44806,12 +48174,6 @@ Object.freeze({
|
|
|
44806
48174
|
addonId: null,
|
|
44807
48175
|
access: "create"
|
|
44808
48176
|
},
|
|
44809
|
-
"userManagement.createApiKey": {
|
|
44810
|
-
capName: "user-management",
|
|
44811
|
-
capScope: "system",
|
|
44812
|
-
addonId: null,
|
|
44813
|
-
access: "create"
|
|
44814
|
-
},
|
|
44815
48177
|
"userManagement.createScopedToken": {
|
|
44816
48178
|
capName: "user-management",
|
|
44817
48179
|
capScope: "system",
|
|
@@ -44848,12 +48210,6 @@ Object.freeze({
|
|
|
44848
48210
|
addonId: null,
|
|
44849
48211
|
access: "view"
|
|
44850
48212
|
},
|
|
44851
|
-
"userManagement.linkExternalIdentity": {
|
|
44852
|
-
capName: "user-management",
|
|
44853
|
-
capScope: "system",
|
|
44854
|
-
addonId: null,
|
|
44855
|
-
access: "create"
|
|
44856
|
-
},
|
|
44857
48213
|
"userManagement.listApiKeys": {
|
|
44858
48214
|
capName: "user-management",
|
|
44859
48215
|
capScope: "system",
|
|
@@ -44956,12 +48312,6 @@ Object.freeze({
|
|
|
44956
48312
|
addonId: null,
|
|
44957
48313
|
access: "create"
|
|
44958
48314
|
},
|
|
44959
|
-
"userManagement.validateApiKey": {
|
|
44960
|
-
capName: "user-management",
|
|
44961
|
-
capScope: "system",
|
|
44962
|
-
addonId: null,
|
|
44963
|
-
access: "view"
|
|
44964
|
-
},
|
|
44965
48315
|
"userManagement.validateCredentials": {
|
|
44966
48316
|
capName: "user-management",
|
|
44967
48317
|
capScope: "system",
|
|
@@ -48049,6 +51399,11 @@ Object.freeze({
|
|
|
48049
51399
|
form: "single",
|
|
48050
51400
|
optional: false
|
|
48051
51401
|
}],
|
|
51402
|
+
"pipelineAnalytics.addRetrainFrameFromRecording": [{
|
|
51403
|
+
name: "deviceId",
|
|
51404
|
+
form: "single",
|
|
51405
|
+
optional: false
|
|
51406
|
+
}],
|
|
48052
51407
|
"pipelineAnalytics.applyDeviceSettingsPatch": [{
|
|
48053
51408
|
name: "deviceId",
|
|
48054
51409
|
form: "single",
|
|
@@ -48239,6 +51594,11 @@ Object.freeze({
|
|
|
48239
51594
|
form: "single",
|
|
48240
51595
|
optional: false
|
|
48241
51596
|
}],
|
|
51597
|
+
"pipelineAnalytics.proposeRetrainAnnotationsWithLlm": [{
|
|
51598
|
+
name: "deviceId",
|
|
51599
|
+
form: "single",
|
|
51600
|
+
optional: false
|
|
51601
|
+
}],
|
|
48242
51602
|
"pipelineAnalytics.pruneEventsBefore": [{
|
|
48243
51603
|
name: "deviceId",
|
|
48244
51604
|
form: "single",
|
|
@@ -49065,6 +52425,11 @@ Object.freeze({
|
|
|
49065
52425
|
form: "single",
|
|
49066
52426
|
optional: false
|
|
49067
52427
|
}],
|
|
52428
|
+
"training.canaryResult": [{
|
|
52429
|
+
name: "deviceIds",
|
|
52430
|
+
form: "array",
|
|
52431
|
+
optional: false
|
|
52432
|
+
}],
|
|
49068
52433
|
"update.getStatus": [{
|
|
49069
52434
|
name: "deviceId",
|
|
49070
52435
|
form: "single",
|
|
@@ -113918,8 +117283,10 @@ function ptzPresetLabel(presetName) {
|
|
|
113918
117283
|
* `proxy.ptz.getPresets({})`. Toggling ON calls
|
|
113919
117284
|
* `proxy.ptz.goToPreset({presetId})` and auto-resets to OFF after 1s.
|
|
113920
117285
|
* - Four directional momentary switches ("Pan Left", "Pan Right",
|
|
113921
|
-
* "Tilt Up", "Tilt Down") that issue
|
|
113922
|
-
*
|
|
117286
|
+
* "Tilt Up", "Tilt Down") that issue ONE `ptz.move` — the PTZ cap's
|
|
117287
|
+
* self-terminating burst, whose duration the DRIVER owns and reports as
|
|
117288
|
+
* `getOptions().moveImpulseMs` (ptz.cap.ts). The exporter carries no
|
|
117289
|
+
* duration of its own. Auto-reset to OFF once the pulse is over.
|
|
113923
117290
|
* - One stateful switch "Autotrack" when the proxy has the
|
|
113924
117291
|
* `ptz-autotrack` cap bound. Toggling sets
|
|
113925
117292
|
* `proxy.ptzAutotrack.setEnabled({enabled})`. Initial value is
|
|
@@ -113935,7 +117302,7 @@ function ptzPresetLabel(presetName) {
|
|
|
113935
117302
|
*/
|
|
113936
117303
|
var MOMENTARY_RESET_MS = 1e3;
|
|
113937
117304
|
async function buildPtz(bctx) {
|
|
113938
|
-
const { ctx, accessory, proxy, numericDeviceId
|
|
117305
|
+
const { ctx, accessory, proxy, numericDeviceId } = bctx;
|
|
113939
117306
|
const log = ctx.logger.withTags({ deviceId: numericDeviceId });
|
|
113940
117307
|
const timers = /* @__PURE__ */ new Set();
|
|
113941
117308
|
const armReset = (cb, delay) => {
|
|
@@ -113964,30 +117331,29 @@ async function buildPtz(bctx) {
|
|
|
113964
117331
|
armReset(() => service.updateCharacteristic(import_dist.Characteristic.On, false), MOMENTARY_RESET_MS);
|
|
113965
117332
|
});
|
|
113966
117333
|
}
|
|
113967
|
-
if (proxy.ptz)
|
|
113968
|
-
const
|
|
113969
|
-
const
|
|
113970
|
-
|
|
113971
|
-
|
|
113972
|
-
|
|
113973
|
-
|
|
113974
|
-
|
|
113975
|
-
|
|
113976
|
-
|
|
113977
|
-
|
|
113978
|
-
|
|
113979
|
-
|
|
113980
|
-
|
|
113981
|
-
|
|
113982
|
-
|
|
113983
|
-
|
|
113984
|
-
|
|
113985
|
-
|
|
113986
|
-
|
|
113987
|
-
|
|
113988
|
-
|
|
113989
|
-
|
|
113990
|
-
});
|
|
117334
|
+
if (proxy.ptz) {
|
|
117335
|
+
const impulse = createImpulseReader(bctx);
|
|
117336
|
+
for (const dir of PTZ_DIRECTIONS) {
|
|
117337
|
+
const label = ptzServiceName(dir.label);
|
|
117338
|
+
const service = accessory.addService(import_dist.Service.Switch, label, dir.subtype);
|
|
117339
|
+
applyServiceLabel(service, label);
|
|
117340
|
+
const reset = (delayMs) => armReset(() => service.updateCharacteristic(import_dist.Characteristic.On, false), delayMs);
|
|
117341
|
+
service.getCharacteristic(import_dist.Characteristic.On).onSet(async (value) => {
|
|
117342
|
+
if (value !== true) return;
|
|
117343
|
+
const startedAt = Date.now();
|
|
117344
|
+
try {
|
|
117345
|
+
await proxy.ptz?.move({ ...dir.cmd });
|
|
117346
|
+
} catch (err) {
|
|
117347
|
+
log.warn("export-hap: ptz.move failed", { meta: {
|
|
117348
|
+
dir: dir.label,
|
|
117349
|
+
error: errMsg$4(err)
|
|
117350
|
+
} });
|
|
117351
|
+
reset(0);
|
|
117352
|
+
return;
|
|
117353
|
+
}
|
|
117354
|
+
reset(remainingPulseMs(await impulse.read(), Date.now() - startedAt));
|
|
117355
|
+
});
|
|
117356
|
+
}
|
|
113991
117357
|
}
|
|
113992
117358
|
const autotrackHandle = await tryBuildAutotrack(bctx);
|
|
113993
117359
|
return { async dispose() {
|
|
@@ -114045,6 +117411,38 @@ async function tryBuildAutotrack(bctx) {
|
|
|
114045
117411
|
});
|
|
114046
117412
|
return { async dispose() {} };
|
|
114047
117413
|
}
|
|
117414
|
+
/**
|
|
117415
|
+
* How long the switch should still read ON after `move` resolved.
|
|
117416
|
+
*
|
|
117417
|
+
* Drivers differ in WHEN `move` returns: hikvision awaits its own pulse before
|
|
117418
|
+
* resolving, while reolink (`autoStopMs`), amcrest (background stop) and onvif
|
|
117419
|
+
* (`timeout`) return as soon as the burst has started. Subtracting the time the
|
|
117420
|
+
* call took covers both: the switch stays ON for the pulse, never longer. An
|
|
117421
|
+
* unknown impulse (`null`) resets at once — the head still stops on its own.
|
|
117422
|
+
*/
|
|
117423
|
+
function remainingPulseMs(moveImpulseMs, elapsedMs) {
|
|
117424
|
+
if (moveImpulseMs === null) return 0;
|
|
117425
|
+
return Math.max(0, moveImpulseMs - elapsedMs);
|
|
117426
|
+
}
|
|
117427
|
+
/**
|
|
117428
|
+
* Reads `ptz.getOptions().moveImpulseMs` once and keeps it. A failed or
|
|
117429
|
+
* unreported read is NOT cached, so a camera that was offline at the first
|
|
117430
|
+
* press answers on a later one.
|
|
117431
|
+
*/
|
|
117432
|
+
function createImpulseReader(bctx) {
|
|
117433
|
+
const { ctx, proxy, numericDeviceId } = bctx;
|
|
117434
|
+
let known = null;
|
|
117435
|
+
return { async read() {
|
|
117436
|
+
if (known !== null) return known;
|
|
117437
|
+
try {
|
|
117438
|
+
const ms = (await proxy.ptz?.getOptions({}))?.moveImpulseMs;
|
|
117439
|
+
known = typeof ms === "number" && ms > 0 ? ms : null;
|
|
117440
|
+
} catch (err) {
|
|
117441
|
+
ctx.logger.withTags({ deviceId: numericDeviceId }).debug("export-hap: ptz.getOptions failed (non-fatal)", { meta: { error: errMsg$4(err) } });
|
|
117442
|
+
}
|
|
117443
|
+
return known;
|
|
117444
|
+
} };
|
|
117445
|
+
}
|
|
114048
117446
|
function errMsg$4(err) {
|
|
114049
117447
|
return err instanceof Error ? err.message : String(err);
|
|
114050
117448
|
}
|
|
@@ -116682,7 +120080,6 @@ var DEFAULT_CONFIG = {
|
|
|
116682
120080
|
bridgeName: "CamStack Bridge",
|
|
116683
120081
|
fixedPin: "",
|
|
116684
120082
|
interfaceName: "",
|
|
116685
|
-
ptzPulseMs: 400,
|
|
116686
120083
|
clipRetentionDays: 14,
|
|
116687
120084
|
identity: {
|
|
116688
120085
|
username: "",
|
|
@@ -116728,6 +120125,8 @@ function buildBridgeUuid(bridgeName) {
|
|
|
116728
120125
|
return import_dist.uuid.generate(`camstack:bridge:${bridgeName}:${Date.now()}`);
|
|
116729
120126
|
}
|
|
116730
120127
|
var ExportHapAddon = class extends BaseAddon {
|
|
120128
|
+
/** The bridge setup code pairs a controller: a credential, kept in the keychain (D787). */
|
|
120129
|
+
secretStatePaths = ["identity.pincode"];
|
|
116731
120130
|
exposed = /* @__PURE__ */ new Map();
|
|
116732
120131
|
lastError;
|
|
116733
120132
|
/** Shared HAP setup code applied to every published accessory. */
|
|
@@ -117027,7 +120426,6 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
117027
120426
|
deviceId: entry.deviceId,
|
|
117028
120427
|
displayName: entry.displayName,
|
|
117029
120428
|
options: {
|
|
117030
|
-
ptzPulseMs: this.config.ptzPulseMs,
|
|
117031
120429
|
decodeMemos: this.decodeMemos,
|
|
117032
120430
|
resolveFfmpeg: this.pinnedFfmpeg,
|
|
117033
120431
|
hksvClipStore: this.hksvClipStore,
|
|
@@ -117387,14 +120785,6 @@ var ExportHapAddon = class extends BaseAddon {
|
|
|
117387
120785
|
description: "CamStack keeps its own copy of every clip it sends to HomeKit Secure Video — HomeKit itself never gives one back. This is the fleet default; each camera can override it, and each can switch the copies off entirely. Clips are also capped at 200 per camera, 512 MB per camera and 4 GB overall — whichever limit is reached first wins, and the log names which one.",
|
|
117388
120786
|
default: DEFAULT_CONFIG.clipRetentionDays,
|
|
117389
120787
|
placement: { tab: "advanced" }
|
|
117390
|
-
}),
|
|
117391
|
-
this.field({
|
|
117392
|
-
type: "number",
|
|
117393
|
-
key: "ptzPulseMs",
|
|
117394
|
-
label: "PTZ pulse duration (ms)",
|
|
117395
|
-
description: "Duration of a single pan/tilt momentary command issued by the PTZ direction switches in Apple Home. Lower = finer steps; higher = bigger sweeps per tap. Defaults to 400ms.",
|
|
117396
|
-
default: DEFAULT_CONFIG.ptzPulseMs,
|
|
117397
|
-
placement: { tab: "advanced" }
|
|
117398
120788
|
})
|
|
117399
120789
|
]
|
|
117400
120790
|
}] });
|