@camstack/addon-model-studio 1.1.49 → 1.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. package/dist/{MotionZonesSettings-nSvd3wgP.mjs → MotionZonesSettings-C0cFDSjW.mjs} +2 -2
  2. package/dist/{PrivacyMaskSettings-DpUECTGc.mjs → PrivacyMaskSettings-B0xou5VT.mjs} +4 -4
  3. package/dist/{SceneMonitorEditor-BYUThwmI.mjs → SceneMonitorEditor-CM4NQvb5.mjs} +3 -3
  4. package/dist/_stub.js +12 -12
  5. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-BrFWLLUB.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_model_studio_page-Co3sb2DR.mjs} +4 -4
  6. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-CE4txY-m.mjs +26 -0
  7. package/dist/{hostInit-GLZyh6hk.mjs → hostInit-CK6zsVKu.mjs} +3 -3
  8. package/dist/model-studio.addon.js +285 -150
  9. package/dist/model-studio.addon.mjs +280 -143
  10. package/dist/{player-overlays-DxPiRDNZ.mjs → player-overlays-p43mMwWT.mjs} +1 -1
  11. package/dist/remoteEntry.js +1 -1
  12. package/dist/{responsive-ChIDJ7ve.mjs → responsive-BWVkSjgC.mjs} +1 -1
  13. package/dist/{square-CpAXUT52.mjs → square-DNWB0Fvw.mjs} +1 -1
  14. package/dist/{trash-2-siK2nOpd.mjs → trash-2-BKgeax2l.mjs} +1 -1
  15. package/dist/{use-device-snapshot-CLLnyzyW.mjs → use-device-snapshot-CkQG2lkA.mjs} +1 -1
  16. package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-D-6VGno6.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_model_studio_page__remoteEntry_js-DOi9vT32.mjs} +1 -1
  17. package/package.json +3 -2
  18. package/dist/_virtual_mf___mfe_internal__addon_model_studio_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D5YltPmo.mjs +0 -26
@@ -23,109 +23,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  //#endregion
24
24
  let node_child_process = require("node:child_process");
25
25
  let node_crypto = require("node:crypto");
26
- node_crypto = __toESM(node_crypto, 1);
26
+ node_crypto = __toESM(node_crypto);
27
27
  let node_fs = require("node:fs");
28
- let node_fs$1 = __toESM(node_fs, 1);
29
28
  node_fs = __toESM(node_fs);
30
29
  let node_os = require("node:os");
31
30
  node_os = __toESM(node_os);
32
31
  let node_path = require("node:path");
33
- let node_path$1 = __toESM(node_path, 1);
34
32
  node_path = __toESM(node_path);
35
- let node_util = require("node:util");
36
- let node_zlib = require("node:zlib");
37
- //#region ../system/dist/file-data-plane-BhKdxJgf.mjs
38
- /** Build fetch headers, including HF auth token for huggingface.co URLs */
39
- function buildHeaders(url) {
40
- const headers = { "User-Agent": "CamStack/1.0" };
41
- const hfToken = process.env["HF_TOKEN"] ?? process.env["HUGGING_FACE_HUB_TOKEN"];
42
- if (hfToken && url.includes("huggingface.co")) headers["Authorization"] = `Bearer ${hfToken}`;
43
- return headers;
44
- }
45
- var DEFAULT_MAX_REDIRECTS = 5;
46
- function normalizeDownloadOptions(third) {
47
- if (typeof third === "function") return { onProgress: third };
48
- return third ?? {};
49
- }
50
- function isRedirectStatus(status) {
51
- return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
52
- }
53
- function resolveRedirectUrl(current, location) {
54
- return new URL(location, current);
55
- }
56
- async function downloadFile(url, destPath, onProgressOrOptions) {
57
- if (node_fs$1.existsSync(destPath)) return destPath;
58
- const opts = normalizeDownloadOptions(onProgressOrOptions);
59
- const fetchImpl = opts.fetchImpl ?? fetch;
60
- const maxRedirects = opts.maxRedirects ?? DEFAULT_MAX_REDIRECTS;
61
- node_fs$1.mkdirSync(node_path$1.dirname(destPath), { recursive: true });
62
- const tmpPath = destPath + ".downloading";
63
- try {
64
- let current = url;
65
- const seen = /* @__PURE__ */ new Set();
66
- let response;
67
- const manual = opts.redirectPolicy !== void 0;
68
- for (let hop = 0; hop <= maxRedirects; hop++) {
69
- const parsed = new URL(current);
70
- if (opts.redirectPolicy) opts.redirectPolicy(parsed, hop);
71
- if (seen.has(parsed.href)) throw new Error(`Redirect loop detected at ${parsed.href}`);
72
- seen.add(parsed.href);
73
- const controller = opts.timeoutMs !== void 0 ? new AbortController() : void 0;
74
- const timer = controller && opts.timeoutMs !== void 0 ? setTimeout(() => controller.abort(), opts.timeoutMs) : void 0;
75
- try {
76
- response = await fetchImpl(current, {
77
- redirect: manual ? "manual" : "follow",
78
- headers: buildHeaders(current),
79
- ...controller ? { signal: controller.signal } : {}
80
- });
81
- } finally {
82
- if (timer) clearTimeout(timer);
83
- }
84
- if (manual && isRedirectStatus(response.status)) {
85
- const location = response.headers.get("location");
86
- if (!location) throw new Error(`Redirect ${response.status} missing Location header`);
87
- if (hop >= maxRedirects) throw new Error(`Too many redirects (max ${maxRedirects}) downloading ${url}`);
88
- current = resolveRedirectUrl(current, location).href;
89
- continue;
90
- }
91
- break;
92
- }
93
- if (!response) throw new Error(`No response downloading ${url}`);
94
- if (manual && isRedirectStatus(response.status)) throw new Error(`Too many redirects (max ${maxRedirects}) downloading ${url}`);
95
- if (!response.ok) throw new Error(`HTTP ${response.status} downloading ${url}`);
96
- if (!response.body) throw new Error(`No response body from ${url}`);
97
- const total = parseInt(response.headers.get("content-length") ?? "0", 10);
98
- let downloaded = 0;
99
- const fileStream = node_fs$1.createWriteStream(tmpPath);
100
- const reader = response.body.getReader();
101
- try {
102
- for (;;) {
103
- const { done, value } = await reader.read();
104
- if (done || !value) break;
105
- downloaded += value.length;
106
- if (opts.maxBytes !== void 0 && downloaded > opts.maxBytes) throw new Error(`Downloaded ${downloaded} bytes exceeds the ${opts.maxBytes}-byte limit`);
107
- fileStream.write(value);
108
- opts.onProgress?.(downloaded, total);
109
- }
110
- } finally {
111
- fileStream.end();
112
- await new Promise((resolve, reject) => {
113
- fileStream.on("finish", resolve);
114
- fileStream.on("error", reject);
115
- });
116
- }
117
- node_fs$1.renameSync(tmpPath, destPath);
118
- return destPath;
119
- } catch (err) {
120
- try {
121
- node_fs$1.unlinkSync(tmpPath);
122
- } catch {}
123
- throw err;
124
- }
125
- }
126
- (0, node_util.promisify)(node_zlib.brotliCompress);
127
- (0, node_util.promisify)(node_zlib.gzip);
128
- //#endregion
33
+ let _camstack_system_addon_utils = require("@camstack/system/addon-utils");
129
34
  //#region src/scrypted/scrypted-download-policy.ts
130
35
  /**
131
36
  * Strict per-hop allow-list for Scrypted catalog downloads.
@@ -618,7 +523,7 @@ async function importScryptedCatalogModel(input, deps) {
618
523
  }
619
524
  }
620
525
  //#endregion
621
- //#region ../types/dist/event-category-CIa_iT6b.mjs
526
+ //#region ../types/dist/event-category-BZL-fdNj.mjs
622
527
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
623
528
  EventCategory["SystemBoot"] = "system.boot";
624
529
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -1055,7 +960,7 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
1055
960
  EventCategory["MetricsNodeResourcesSnapshot"] = "metrics.node-resources-snapshot";
1056
961
  /**
1057
962
  * Periodic per-node process-tree snapshot (camstack-related pids
1058
- * with ghost / managed / root classification). Emitted ~0.2 Hz by
963
+ * with root / managed / system classification). Emitted ~0.2 Hz by
1059
964
  * the metrics-provider addon. Drives the Cluster → Processes tab
1060
965
  * without polling `metricsProvider.listNodeProcesses`.
1061
966
  */
@@ -4338,7 +4243,7 @@ function initializeContext(params) {
4338
4243
  external: params?.external ?? void 0
4339
4244
  };
4340
4245
  }
4341
- function process$1(schema, ctx, _params = {
4246
+ function process(schema, ctx, _params = {
4342
4247
  path: [],
4343
4248
  schemaPath: []
4344
4249
  }) {
@@ -4375,7 +4280,7 @@ function process$1(schema, ctx, _params = {
4375
4280
  const parent = schema._zod.parent;
4376
4281
  if (parent) {
4377
4282
  if (!result.ref) result.ref = parent;
4378
- process$1(parent, ctx, params);
4283
+ process(parent, ctx, params);
4379
4284
  ctx.seen.get(parent).isParent = true;
4380
4285
  }
4381
4286
  }
@@ -4595,7 +4500,7 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
4595
4500
  ...params,
4596
4501
  processors
4597
4502
  });
4598
- process$1(schema, ctx);
4503
+ process(schema, ctx);
4599
4504
  extractDefs(ctx, schema);
4600
4505
  return finalize(ctx, schema);
4601
4506
  };
@@ -4607,7 +4512,7 @@ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) =
4607
4512
  io,
4608
4513
  processors
4609
4514
  });
4610
- process$1(schema, ctx);
4515
+ process(schema, ctx);
4611
4516
  extractDefs(ctx, schema);
4612
4517
  return finalize(ctx, schema);
4613
4518
  };
@@ -4721,7 +4626,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
4721
4626
  if (typeof minimum === "number") json.minItems = minimum;
4722
4627
  if (typeof maximum === "number") json.maxItems = maximum;
4723
4628
  json.type = "array";
4724
- json.items = process$1(def.element, ctx, {
4629
+ json.items = process(def.element, ctx, {
4725
4630
  ...params,
4726
4631
  path: [...params.path, "items"]
4727
4632
  });
@@ -4732,7 +4637,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
4732
4637
  json.type = "object";
4733
4638
  json.properties = {};
4734
4639
  const shape = def.shape;
4735
- for (const key in shape) json.properties[key] = process$1(shape[key], ctx, {
4640
+ for (const key in shape) json.properties[key] = process(shape[key], ctx, {
4736
4641
  ...params,
4737
4642
  path: [
4738
4643
  ...params.path,
@@ -4750,7 +4655,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
4750
4655
  if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
4751
4656
  else if (!def.catchall) {
4752
4657
  if (ctx.io === "output") json.additionalProperties = false;
4753
- } else if (def.catchall) json.additionalProperties = process$1(def.catchall, ctx, {
4658
+ } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
4754
4659
  ...params,
4755
4660
  path: [...params.path, "additionalProperties"]
4756
4661
  });
@@ -4758,7 +4663,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
4758
4663
  var unionProcessor = (schema, ctx, json, params) => {
4759
4664
  const def = schema._zod.def;
4760
4665
  const isExclusive = def.inclusive === false;
4761
- const options = def.options.map((x, i) => process$1(x, ctx, {
4666
+ const options = def.options.map((x, i) => process(x, ctx, {
4762
4667
  ...params,
4763
4668
  path: [
4764
4669
  ...params.path,
@@ -4771,7 +4676,7 @@ var unionProcessor = (schema, ctx, json, params) => {
4771
4676
  };
4772
4677
  var intersectionProcessor = (schema, ctx, json, params) => {
4773
4678
  const def = schema._zod.def;
4774
- const a = process$1(def.left, ctx, {
4679
+ const a = process(def.left, ctx, {
4775
4680
  ...params,
4776
4681
  path: [
4777
4682
  ...params.path,
@@ -4779,7 +4684,7 @@ var intersectionProcessor = (schema, ctx, json, params) => {
4779
4684
  0
4780
4685
  ]
4781
4686
  });
4782
- const b = process$1(def.right, ctx, {
4687
+ const b = process(def.right, ctx, {
4783
4688
  ...params,
4784
4689
  path: [
4785
4690
  ...params.path,
@@ -4796,7 +4701,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
4796
4701
  json.type = "array";
4797
4702
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
4798
4703
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
4799
- const prefixItems = def.items.map((x, i) => process$1(x, ctx, {
4704
+ const prefixItems = def.items.map((x, i) => process(x, ctx, {
4800
4705
  ...params,
4801
4706
  path: [
4802
4707
  ...params.path,
@@ -4804,7 +4709,7 @@ var tupleProcessor = (schema, ctx, _json, params) => {
4804
4709
  i
4805
4710
  ]
4806
4711
  }));
4807
- const rest = def.rest ? process$1(def.rest, ctx, {
4712
+ const rest = def.rest ? process(def.rest, ctx, {
4808
4713
  ...params,
4809
4714
  path: [
4810
4715
  ...params.path,
@@ -4835,7 +4740,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
4835
4740
  const keyType = def.keyType;
4836
4741
  const patterns = keyType._zod.bag?.patterns;
4837
4742
  if (def.mode === "loose" && patterns && patterns.size > 0) {
4838
- const valueSchema = process$1(def.valueType, ctx, {
4743
+ const valueSchema = process(def.valueType, ctx, {
4839
4744
  ...params,
4840
4745
  path: [
4841
4746
  ...params.path,
@@ -4846,11 +4751,11 @@ var recordProcessor = (schema, ctx, _json, params) => {
4846
4751
  json.patternProperties = {};
4847
4752
  for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
4848
4753
  } else {
4849
- if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$1(def.keyType, ctx, {
4754
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process(def.keyType, ctx, {
4850
4755
  ...params,
4851
4756
  path: [...params.path, "propertyNames"]
4852
4757
  });
4853
- json.additionalProperties = process$1(def.valueType, ctx, {
4758
+ json.additionalProperties = process(def.valueType, ctx, {
4854
4759
  ...params,
4855
4760
  path: [...params.path, "additionalProperties"]
4856
4761
  });
@@ -4863,7 +4768,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
4863
4768
  };
4864
4769
  var nullableProcessor = (schema, ctx, json, params) => {
4865
4770
  const def = schema._zod.def;
4866
- const inner = process$1(def.innerType, ctx, params);
4771
+ const inner = process(def.innerType, ctx, params);
4867
4772
  const seen = ctx.seen.get(schema);
4868
4773
  if (ctx.target === "openapi-3.0") {
4869
4774
  seen.ref = def.innerType;
@@ -4872,27 +4777,27 @@ var nullableProcessor = (schema, ctx, json, params) => {
4872
4777
  };
4873
4778
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
4874
4779
  const def = schema._zod.def;
4875
- process$1(def.innerType, ctx, params);
4780
+ process(def.innerType, ctx, params);
4876
4781
  const seen = ctx.seen.get(schema);
4877
4782
  seen.ref = def.innerType;
4878
4783
  };
4879
4784
  var defaultProcessor = (schema, ctx, json, params) => {
4880
4785
  const def = schema._zod.def;
4881
- process$1(def.innerType, ctx, params);
4786
+ process(def.innerType, ctx, params);
4882
4787
  const seen = ctx.seen.get(schema);
4883
4788
  seen.ref = def.innerType;
4884
4789
  json.default = JSON.parse(JSON.stringify(def.defaultValue));
4885
4790
  };
4886
4791
  var prefaultProcessor = (schema, ctx, json, params) => {
4887
4792
  const def = schema._zod.def;
4888
- process$1(def.innerType, ctx, params);
4793
+ process(def.innerType, ctx, params);
4889
4794
  const seen = ctx.seen.get(schema);
4890
4795
  seen.ref = def.innerType;
4891
4796
  if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4892
4797
  };
4893
4798
  var catchProcessor = (schema, ctx, json, params) => {
4894
4799
  const def = schema._zod.def;
4895
- process$1(def.innerType, ctx, params);
4800
+ process(def.innerType, ctx, params);
4896
4801
  const seen = ctx.seen.get(schema);
4897
4802
  seen.ref = def.innerType;
4898
4803
  let catchValue;
@@ -4907,26 +4812,26 @@ var pipeProcessor = (schema, ctx, _json, params) => {
4907
4812
  const def = schema._zod.def;
4908
4813
  const inIsTransform = def.in._zod.traits.has("$ZodTransform");
4909
4814
  const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
4910
- process$1(innerType, ctx, params);
4815
+ process(innerType, ctx, params);
4911
4816
  const seen = ctx.seen.get(schema);
4912
4817
  seen.ref = innerType;
4913
4818
  };
4914
4819
  var readonlyProcessor = (schema, ctx, json, params) => {
4915
4820
  const def = schema._zod.def;
4916
- process$1(def.innerType, ctx, params);
4821
+ process(def.innerType, ctx, params);
4917
4822
  const seen = ctx.seen.get(schema);
4918
4823
  seen.ref = def.innerType;
4919
4824
  json.readOnly = true;
4920
4825
  };
4921
4826
  var optionalProcessor = (schema, ctx, _json, params) => {
4922
4827
  const def = schema._zod.def;
4923
- process$1(def.innerType, ctx, params);
4828
+ process(def.innerType, ctx, params);
4924
4829
  const seen = ctx.seen.get(schema);
4925
4830
  seen.ref = def.innerType;
4926
4831
  };
4927
4832
  var lazyProcessor = (schema, ctx, _json, params) => {
4928
4833
  const innerType = schema._zod.innerType;
4929
- process$1(innerType, ctx, params);
4834
+ process(innerType, ctx, params);
4930
4835
  const seen = ctx.seen.get(schema);
4931
4836
  seen.ref = innerType;
4932
4837
  };
@@ -11844,6 +11749,19 @@ var SettingsRecordSchema = object({
11844
11749
  data: record(string(), unknown())
11845
11750
  });
11846
11751
  /**
11752
+ * One record of a BULK insert — {@link SettingsRecordSchema} with the id made
11753
+ * optional.
11754
+ *
11755
+ * A separate schema rather than loosening the shared one: every other method
11756
+ * on this cap addresses a row BY its id, and making that field optional
11757
+ * everywhere would turn a forgotten key into a silently generated one on
11758
+ * `update` and `delete` as well.
11759
+ */
11760
+ var BulkRecordSchema = object({
11761
+ id: string().optional(),
11762
+ data: record(string(), unknown())
11763
+ });
11764
+ /**
11847
11765
  * Column declaration for a structured (SQL-backed) collection.
11848
11766
  *
11849
11767
  * Logical types — the backend translates each to the matching SQLite
@@ -11900,6 +11818,10 @@ method(object({
11900
11818
  collection: string(),
11901
11819
  record: SettingsRecordSchema
11902
11820
  }), _void(), { kind: "mutation" }), method(object({
11821
+ namespace: string().optional(),
11822
+ collection: string(),
11823
+ records: array(BulkRecordSchema).readonly()
11824
+ }), object({ inserted: number().int() }), { kind: "mutation" }), method(object({
11903
11825
  namespace: string().optional(),
11904
11826
  collection: string(),
11905
11827
  id: string(),
@@ -12008,6 +11930,13 @@ method(_void(), EngineInfoSchema, { auth: "admin" }), method(object({
12008
11930
  }), _void(), {
12009
11931
  kind: "mutation",
12010
11932
  auth: "admin"
11933
+ }), method(object({
11934
+ namespace: string().optional(),
11935
+ collection: string(),
11936
+ records: array(BulkRecordSchema).readonly()
11937
+ }), object({ inserted: number().int() }), {
11938
+ kind: "mutation",
11939
+ auth: "admin"
12011
11940
  }), method(object({
12012
11941
  namespace: string().optional(),
12013
11942
  collection: string(),
@@ -13776,6 +13705,68 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13776
13705
  limit: number().optional(),
13777
13706
  tags: record(string(), string()).optional()
13778
13707
  }), array(LogEntrySchema).readonly());
13708
+ var LoadContributionSchema = object({
13709
+ role: _enum([
13710
+ "decode",
13711
+ "transcode",
13712
+ "recording",
13713
+ "streaming",
13714
+ "detection"
13715
+ ]),
13716
+ /**
13717
+ * The NUMERIC device id — the same value every log line carries as
13718
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13719
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
13720
+ * contributor that cannot name its camera must not emit the entry at all,
13721
+ * because an unnamed per-camera entry is indistinguishable from a shared one
13722
+ * and would quietly turn one camera's cost into everybody's.
13723
+ */
13724
+ deviceId: number().int().positive().nullable(),
13725
+ attribution: _enum([
13726
+ "measured",
13727
+ "accounted",
13728
+ "unattributable"
13729
+ ]),
13730
+ /**
13731
+ * What ONE entry is, in the contributor's own words — `615/high`,
13732
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13733
+ * family and inventing a common one would lose the only information that
13734
+ * makes two entries for the same camera distinguishable.
13735
+ */
13736
+ unit: string(),
13737
+ /**
13738
+ * The OS process this cost lives in, when there is one. Present so a
13739
+ * consumer can (a) tell two generations of the same unit apart across a
13740
+ * restart, and (b) subtract claimed processes from the node's process
13741
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13742
+ * process of its own.
13743
+ */
13744
+ pid: number().int().positive().optional(),
13745
+ /**
13746
+ * When this generation started. The pid's incarnation marker: a consumer
13747
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13748
+ * window when this changes, because the counter restarted from zero in a new
13749
+ * process.
13750
+ */
13751
+ startedAtMs: number().optional(),
13752
+ /**
13753
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13754
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
13755
+ * contribution is asked for.
13756
+ *
13757
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
13758
+ * needs a sampler, and a new per-node sampler is the defect half of
13759
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13760
+ * by whoever already keeps a history; a rate cannot be un-averaged.
13761
+ *
13762
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13763
+ * an entry with no process.
13764
+ */
13765
+ cpuSeconds: number().optional(),
13766
+ /** Resident bytes of this unit's process, same source and same rules. */
13767
+ rssBytes: number().optional()
13768
+ });
13769
+ method(_void(), array(LoadContributionSchema).readonly());
13779
13770
  /**
13780
13771
  * `login-method` — collection cap through which auth addons contribute
13781
13772
  * their pre-auth login surfaces to the login page. This is the SINGLE,
@@ -13979,8 +13970,7 @@ var NodeProcessSchema = object({
13979
13970
  classification: _enum([
13980
13971
  "root",
13981
13972
  "managed",
13982
- "system",
13983
- "ghost"
13973
+ "system"
13984
13974
  ]),
13985
13975
  /** `$process` addon binding when `managed`, else null. */
13986
13976
  addonId: string().nullable(),
@@ -13988,22 +13978,39 @@ var NodeProcessSchema = object({
13988
13978
  nodeId: string().nullable(),
13989
13979
  /** Truncated command line. */
13990
13980
  command: string(),
13981
+ /**
13982
+ * `ps pcpu` — CPU averaged over the process's WHOLE LIFETIME, not a rate.
13983
+ * On a runner up for days it barely moves. Fine as a column, useless as a
13984
+ * series: use `cpuMainPercent + cpuGcPercent` for anything time-varying.
13985
+ */
13991
13986
  cpuPercent: number(),
13992
13987
  memoryRssBytes: number(),
13988
+ /**
13989
+ * Instantaneous CPU% of the process's own threads over the last
13990
+ * process-snapshot window, from a `/proc/<pid>/task/*` tick delta.
13991
+ *
13992
+ * `null` = UNKNOWN, never zero: no previous sample yet (first tick after
13993
+ * boot), the pid was recycled, or this node is not Linux.
13994
+ */
13995
+ cpuMainPercent: number().nullable(),
13996
+ /**
13997
+ * Instantaneous CPU% of V8's `V8Worker` platform pool over the same window.
13998
+ *
13999
+ * This is the number that rewrote the 2026-08-27 diagnosis — hub-main 73%,
14000
+ * `stream-broker` 61% (`docs/architecture/load-ledger.md`). A CPU chart that
14001
+ * does not separate it from `cpuMainPercent` shows "busy" where the truth is
14002
+ * "allocating too much".
14003
+ *
14004
+ * Concurrent GC is the dominant tenant of that pool but not the only one
14005
+ * (background compilation runs there too), so it is reported as
14006
+ * "GC / V8 helpers" rather than as pure collection time. `null` has the same
14007
+ * meaning as on `cpuMainPercent`.
14008
+ */
14009
+ cpuGcPercent: number().nullable(),
14010
+ /** Threads seen in the tick scan. `null` under the same conditions. */
14011
+ threadCount: number().nullable(),
13993
14012
  /** Wall-clock uptime (seconds). Parsed from `ps etime`. */
13994
- uptimeSec: number(),
13995
- /** True when ancestor walk reaches `ppid=1` (reparented to init/launchd). */
13996
- orphaned: boolean()
13997
- });
13998
- var KillProcessInputSchema = object({
13999
- pid: number(),
14000
- /** Force = SIGKILL. Default is SIGTERM. */
14001
- force: boolean().optional()
14002
- });
14003
- var KillProcessResultSchema = object({
14004
- success: boolean(),
14005
- reason: string().optional(),
14006
- signal: _enum(["SIGTERM", "SIGKILL"]).optional()
14013
+ uptimeSec: number()
14007
14014
  });
14008
14015
  var DumpHeapSnapshotInputSchema = object({
14009
14016
  /** The addon whose runner should dump a heap snapshot. */
@@ -14016,6 +14023,104 @@ var DumpHeapSnapshotResultSchema = object({
14016
14023
  pid: number().optional(),
14017
14024
  reason: string().optional()
14018
14025
  });
14026
+ /**
14027
+ * One point of one function's series.
14028
+ *
14029
+ * The unsuffixed fields are the bucket's **MAXIMUM**, and that choice is the
14030
+ * point of the whole surface. The two obvious reductions both lie: a mean per
14031
+ * bucket smears a spike away, and taking every Nth sample skips it outright.
14032
+ * Either would give us a tool built to find peaks that does not show peaks.
14033
+ * `...Min` carries the other end, `samples` says how many raw snapshots folded
14034
+ * into the bucket, and a mean stays derivable where it is wanted.
14035
+ *
14036
+ * An UNREDUCED point is a one-sample bucket: `samples === 1` and each `...Min`
14037
+ * equals its unsuffixed twin. Reduced and unreduced are the same shape, so a
14038
+ * caller cannot tell which it received — which is what "one reader" means.
14039
+ */
14040
+ var LoadPointSchema = object({
14041
+ /** Bucket START, or the snapshot's own timestamp when unreduced. */
14042
+ atMs: number(),
14043
+ /** Raw snapshots in this bucket. Never 0 — AN EMPTY BUCKET IS ABSENT. */
14044
+ samples: number().int(),
14045
+ /**
14046
+ * `null` = UNKNOWN and it PROPAGATES: a bucket is null unless every process
14047
+ * of every snapshot in it reported a thread split. A partial sum is a
14048
+ * smaller number that looks exactly as real as a complete one.
14049
+ */
14050
+ cpuMainPercent: number().nullable(),
14051
+ cpuMainPercentMin: number().nullable(),
14052
+ cpuGcPercent: number().nullable(),
14053
+ cpuGcPercentMin: number().nullable(),
14054
+ /** Lifetime-average CPU%, summed. Always known — and never a rate. */
14055
+ cpuLifetimePercent: number(),
14056
+ cpuLifetimePercentMin: number(),
14057
+ memoryRssBytes: number(),
14058
+ memoryRssBytesMin: number(),
14059
+ processCount: number().int(),
14060
+ processCountMin: number().int()
14061
+ });
14062
+ /** One function's series. `key` is an addonId, `__root__` or `__unattributed__`. */
14063
+ var LoadFunctionSeriesSchema = object({
14064
+ key: string(),
14065
+ kind: _enum([
14066
+ "addon",
14067
+ "root",
14068
+ "unattributed"
14069
+ ]),
14070
+ /** Oldest-first. A missing interval is MISSING — never zero-filled. */
14071
+ points: array(LoadPointSchema).readonly()
14072
+ });
14073
+ var NodeLoadSeriesSchema = object({
14074
+ nodeId: string(),
14075
+ /** One entry per function seen in the window, heaviest-first. */
14076
+ series: array(LoadFunctionSeriesSchema).readonly(),
14077
+ /**
14078
+ * Width of one returned bucket, in ms. Equals the sampling cadence when no
14079
+ * reduction was needed — so a caller can always say what one point covers
14080
+ * without having to know whether it was reduced.
14081
+ */
14082
+ bucketMs: number(),
14083
+ /** Raw snapshots that went into this answer, across both tiers. */
14084
+ retainedSamples: number(),
14085
+ /** Oldest snapshot represented, or `null` when nothing is retained. */
14086
+ oldestAtMs: number().nullable(),
14087
+ /** The fixed sampling cadence in force on the cluster, in ms. */
14088
+ cadenceMs: number(),
14089
+ /**
14090
+ * Did the DURABLE tier contribute? `false` means the answer is the hot ring
14091
+ * alone — an agent (which holds no table), or a store that refused.
14092
+ * Reported because "the last hour" and "the last six hours" are different
14093
+ * questions and an operator must not have to guess which was answered.
14094
+ */
14095
+ durable: boolean()
14096
+ });
14097
+ var GetLoadSeriesInputSchema = object({
14098
+ /**
14099
+ * The node whose series is wanted.
14100
+ *
14101
+ * NOT named `nodeId`: the generated cap router strips a top-level
14102
+ * `nodeId` from every method input and uses it to ROUTE the call to
14103
+ * that node's provider (`generated-cap-routers.ts`). A series target
14104
+ * called `nodeId` would silently become a routing pin and never reach
14105
+ * the provider. The hub holds every node it hears from, so the
14106
+ * ordinary call is unpinned — answered by the hub, for any node.
14107
+ */
14108
+ forNodeId: string(),
14109
+ /**
14110
+ * EXCLUSIVE lower bound. A caller passes the newest `atMs` it already
14111
+ * holds and receives only what it is missing, so seeding a live chart
14112
+ * from this method cannot double a point already drawn.
14113
+ */
14114
+ sinceMs: number().optional(),
14115
+ /**
14116
+ * Most points the caller wants PER FUNCTION. The window is reduced to fit,
14117
+ * preserving min and max per bucket.
14118
+ *
14119
+ * Absent means NO reduction — legitimate for a short window and a trap for a
14120
+ * long one, which is why a chart passes its own pixel width.
14121
+ */
14122
+ maxPoints: number().int().positive().optional()
14123
+ });
14019
14124
  var SystemMetricsSchema = object({
14020
14125
  cpuPercent: number(),
14021
14126
  memoryPercent: number(),
@@ -14026,10 +14131,7 @@ var SystemMetricsSchema = object({
14026
14131
  gpuPercent: number().optional(),
14027
14132
  gpuMemoryPercent: number().optional()
14028
14133
  });
14029
- method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(KillProcessInputSchema, KillProcessResultSchema, {
14030
- kind: "mutation",
14031
- auth: "admin"
14032
- }), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
14134
+ method(_void(), SystemResourceSnapshotSchema), method(_void(), SystemResourceSnapshotSchema.nullable()), method(_void(), SystemMetricsSchema), method(object({ dirPath: string() }), DiskSpaceInfoSchema), method(_void(), MetricsGpuInfoSchema.nullable()), method(_void(), number().nullable()), method(object({ pids: array(number()) }), array(PidResourceStatsSchema)), method(_void(), array(AddonInstanceSchema).readonly()), method(object({ addonId: string() }), PidResourceStatsSchema.nullable()), method(_void(), array(NodeProcessSchema).readonly()), method(GetLoadSeriesInputSchema, NodeLoadSeriesSchema), method(DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, {
14033
14135
  kind: "mutation",
14034
14136
  auth: "admin"
14035
14137
  });
@@ -27338,6 +27440,15 @@ var LoggingSettingsPatchSchema = object({
27338
27440
  * authority over the whole hierarchy and answers for every layer, so the
27339
27441
  * layer selector needs a name the transport does not already own.
27340
27442
  */
27443
+ /**
27444
+ * One contribution, plus WHO reported it.
27445
+ *
27446
+ * The addon and node are added by the hub as it enumerates providers, never by
27447
+ * the contributor: an addon reporting its own identity could report somebody
27448
+ * else's, and the whole point of this surface is that no claim is made by
27449
+ * anyone but its owner.
27450
+ */
27451
+ var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
27341
27452
  var GetLoggingSettingsInputSchema = object({
27342
27453
  scopeNodeId: string().optional(),
27343
27454
  /**
@@ -27396,7 +27507,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
27396
27507
  }), method(_void(), SiteLocationStatusSchema, {
27397
27508
  kind: "mutation",
27398
27509
  auth: "admin"
27399
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
27510
+ }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
27400
27511
  kind: "mutation",
27401
27512
  auth: "admin"
27402
27513
  });
@@ -29012,6 +29123,12 @@ Object.freeze({
29012
29123
  addonId: null,
29013
29124
  access: "create"
29014
29125
  },
29126
+ "dataStoreProvider.insertMany": {
29127
+ capName: "data-store-provider",
29128
+ capScope: "system",
29129
+ addonId: null,
29130
+ access: "create"
29131
+ },
29015
29132
  "dataStoreProvider.isEmpty": {
29016
29133
  capName: "data-store-provider",
29017
29134
  capScope: "system",
@@ -30326,6 +30443,12 @@ Object.freeze({
30326
30443
  addonId: null,
30327
30444
  access: "create"
30328
30445
  },
30446
+ "loadContribution.list": {
30447
+ capName: "load-contribution",
30448
+ capScope: "system",
30449
+ addonId: null,
30450
+ access: "view"
30451
+ },
30329
30452
  "localNetwork.downloadCa": {
30330
30453
  capName: "local-network",
30331
30454
  capScope: "system",
@@ -30626,17 +30749,17 @@ Object.freeze({
30626
30749
  addonId: null,
30627
30750
  access: "view"
30628
30751
  },
30629
- "metricsProvider.getProcessStats": {
30752
+ "metricsProvider.getLoadSeries": {
30630
30753
  capName: "metrics-provider",
30631
30754
  capScope: "system",
30632
30755
  addonId: null,
30633
30756
  access: "view"
30634
30757
  },
30635
- "metricsProvider.killProcess": {
30758
+ "metricsProvider.getProcessStats": {
30636
30759
  capName: "metrics-provider",
30637
30760
  capScope: "system",
30638
30761
  addonId: null,
30639
- access: "create"
30762
+ access: "view"
30640
30763
  },
30641
30764
  "metricsProvider.listAddonInstances": {
30642
30765
  capName: "metrics-provider",
@@ -32648,6 +32771,12 @@ Object.freeze({
32648
32771
  addonId: null,
32649
32772
  access: "create"
32650
32773
  },
32774
+ "settingsStore.insertMany": {
32775
+ capName: "settings-store",
32776
+ capScope: "system",
32777
+ addonId: null,
32778
+ access: "create"
32779
+ },
32651
32780
  "settingsStore.isEmpty": {
32652
32781
  capName: "settings-store",
32653
32782
  capScope: "system",
@@ -33260,6 +33389,12 @@ Object.freeze({
33260
33389
  addonId: null,
33261
33390
  access: "create"
33262
33391
  },
33392
+ "system.getLoadContributions": {
33393
+ capName: "system",
33394
+ capScope: "system",
33395
+ addonId: null,
33396
+ access: "view"
33397
+ },
33263
33398
  "system.getLoggingSettings": {
33264
33399
  capName: "system",
33265
33400
  capScope: "system",
@@ -37109,7 +37244,7 @@ var ModelStudioAddon = class ModelStudioAddon extends BaseAddon {
37109
37244
  },
37110
37245
  downloadOnnx: async (url, destDir, modelId) => {
37111
37246
  const filename = `camstack-${modelId}.onnx`;
37112
- return downloadFile(url, node_path.default.join(destDir, filename));
37247
+ return (0, _camstack_system_addon_utils.downloadFile)(url, node_path.default.join(destDir, filename));
37113
37248
  },
37114
37249
  writeJob: async (job) => {
37115
37250
  const tmpDir = this.ctx.dataDir ?? node_os.default.tmpdir();
@@ -37413,7 +37548,7 @@ var ModelStudioAddon = class ModelStudioAddon extends BaseAddon {
37413
37548
  const descriptor = await importScryptedCatalogModel(input, {
37414
37549
  stagingDir: node_path.default.join(this.ctx.dataDir ?? node_os.default.tmpdir(), "scrypted-import"),
37415
37550
  modelsDir,
37416
- downloadFile: (url, destPath) => downloadFile(url, destPath, {
37551
+ downloadFile: (url, destPath) => (0, _camstack_system_addon_utils.downloadFile)(url, destPath, {
37417
37552
  redirectPolicy: assertScryptedDownloadUrl,
37418
37553
  maxBytes: SCRYPTED_IMPORT_MAX_FILE_BYTES,
37419
37554
  timeoutMs: 6e4
@@ -37470,7 +37605,7 @@ var ModelStudioAddon = class ModelStudioAddon extends BaseAddon {
37470
37605
  const modelsDir = await this.resolveModelsDir();
37471
37606
  const filename = cat.url.split("/").at(-1) ?? `${descriptor.entry.id}.${cat.format}`;
37472
37607
  const destPath = node_path.default.join(modelsDir, filename);
37473
- await downloadFile(cat.url, destPath);
37608
+ await (0, _camstack_system_addon_utils.downloadFile)(cat.url, destPath);
37474
37609
  const bytes = (await node_fs.default.promises.stat(destPath)).size;
37475
37610
  const declaredBytes = cat.sizeMB * 1e6;
37476
37611
  if (bytes < declaredBytes * .5 || bytes > declaredBytes * 2) {
@@ -37512,7 +37647,7 @@ var ModelStudioAddon = class ModelStudioAddon extends BaseAddon {
37512
37647
  const filename = `${input.modelId}${traits.extension}`;
37513
37648
  const modelsDir = await this.resolveModelsDir();
37514
37649
  const destPath = node_path.default.join(modelsDir, filename);
37515
- await downloadFile(downloadUrl, destPath);
37650
+ await (0, _camstack_system_addon_utils.downloadFile)(downloadUrl, destPath);
37516
37651
  const bytes = (await node_fs.default.promises.stat(destPath)).size;
37517
37652
  if (bytes < 1e4) {
37518
37653
  await node_fs.default.promises.rm(destPath, { force: true });