camstack 1.2.195 → 1.2.197

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/cli.js CHANGED
@@ -37,7 +37,7 @@ async function runServe(args) {
37
37
  ...typeof values.data === "string" ? { data: values.data } : {}
38
38
  };
39
39
  Object.assign(process.env, buildServeEnv(opts));
40
- await import("./launcher-VKN5MWTJ.js");
40
+ await import("./launcher-I5A3WROT.js");
41
41
  }
42
42
 
43
43
  // src/commands/agent.ts
@@ -82,7 +82,7 @@ async function runAgent(args) {
82
82
  ...typeof values.port === "string" ? { port: values.port } : {}
83
83
  };
84
84
  Object.assign(process.env, buildAgentEnv(opts));
85
- await import("./launcher-VKN5MWTJ.js");
85
+ await import("./launcher-I5A3WROT.js");
86
86
  }
87
87
 
88
88
  // src/commands/setup.ts
@@ -122867,8 +122867,9 @@ var require_node = __commonJS({
122867
122867
  }
122868
122868
  return;
122869
122869
  }
122870
+ const flags = format2 === "tar.xz" ? "-xJf" : format2 === "tar" ? "-xf" : "-xzf";
122870
122871
  deps.exec(tar, [
122871
- format2 === "tar.xz" ? "-xJf" : "-xzf",
122872
+ flags,
122872
122873
  archivePath,
122873
122874
  "-C",
122874
122875
  destDir
@@ -123361,6 +123362,264 @@ ${(/* @__PURE__ */ new Date()).toISOString()}
123361
123362
  hash
123362
123363
  } });
123363
123364
  }
123365
+ var AR_MAGIC = "!<arch>\n";
123366
+ var AR_HEADER_BYTES = 60;
123367
+ function readArMembers(archive) {
123368
+ if (archive.subarray(0, 8).toString("latin1") !== AR_MAGIC) throw new Error('not an ar archive (a .deb starts with "!<arch>")');
123369
+ const members = [];
123370
+ let offset = 8;
123371
+ while (offset + AR_HEADER_BYTES <= archive.length) {
123372
+ const header = archive.subarray(offset, offset + AR_HEADER_BYTES).toString("latin1");
123373
+ if (header.slice(58, 60) !== "`\n") throw new Error(`corrupt ar member header at byte ${offset}`);
123374
+ const name = header.slice(0, 16).trim().replace(/\/$/, "");
123375
+ const size = Number.parseInt(header.slice(48, 58).trim(), 10);
123376
+ if (!Number.isInteger(size) || size < 0) throw new Error(`ar member "${name}" has no valid size`);
123377
+ const start = offset + AR_HEADER_BYTES;
123378
+ if (start + size > archive.length) throw new Error(`ar member "${name}" runs past the end of the archive`);
123379
+ members.push({
123380
+ name,
123381
+ data: archive.subarray(start, start + size)
123382
+ });
123383
+ offset = start + size + size % 2;
123384
+ }
123385
+ return members;
123386
+ }
123387
+ function debDataMember(deb) {
123388
+ const member = readArMembers(deb).find((m) => m.name.startsWith("data.tar"));
123389
+ if (member === void 0) throw new Error(".deb has no data.tar member");
123390
+ const suffix = member.name.slice(8);
123391
+ const compression = suffix === ".zst" ? "zst" : suffix === ".xz" ? "xz" : suffix === ".gz" ? "gz" : suffix === "" ? "none" : null;
123392
+ if (compression === null) throw new Error(`.deb payload ${member.name} uses a compression this extractor does not read`);
123393
+ return {
123394
+ compression,
123395
+ data: member.data
123396
+ };
123397
+ }
123398
+ function extractDebPayload(deb, destDir, workDir, extract = extractArchive) {
123399
+ const payload = debDataMember(deb);
123400
+ (0, node_fs.mkdirSync)(destDir, { recursive: true });
123401
+ (0, node_fs.mkdirSync)(workDir, { recursive: true });
123402
+ if (payload.compression === "xz") {
123403
+ const xzPath = (0, node_path.join)(workDir, "data.tar.xz");
123404
+ (0, node_fs.writeFileSync)(xzPath, payload.data);
123405
+ extract(xzPath, "tar.xz", destDir);
123406
+ return;
123407
+ }
123408
+ const tar = payload.compression === "zst" ? (0, node_zlib.zstdDecompressSync)(payload.data) : payload.compression === "gz" ? (0, node_zlib.gunzipSync)(payload.data) : payload.data;
123409
+ const tarPath = (0, node_path.join)(workDir, "data.tar");
123410
+ (0, node_fs.writeFileSync)(tarPath, tar);
123411
+ extract(tarPath, "tar", destDir);
123412
+ }
123413
+ function findEntryByName(dir, name) {
123414
+ for (const entry of (0, node_fs.readdirSync)(dir, { withFileTypes: true })) {
123415
+ const full = (0, node_path.join)(dir, entry.name);
123416
+ if ((entry.isFile() || entry.isSymbolicLink()) && entry.name === name) return full;
123417
+ if (entry.isDirectory()) {
123418
+ const nested = findEntryByName(full, name);
123419
+ if (nested !== null) return nested;
123420
+ }
123421
+ }
123422
+ return null;
123423
+ }
123424
+ function installLibraryFromDeb(debPath, memberName, targetPath2, workDir, extract = extractArchive) {
123425
+ const tree = (0, node_path.join)(workDir, "tree");
123426
+ try {
123427
+ extractDebPayload((0, node_fs.readFileSync)(debPath), tree, workDir, extract);
123428
+ const found = findEntryByName(tree, memberName);
123429
+ if (found === null) throw new Error(`${memberName} not found inside ${debPath}`);
123430
+ (0, node_fs.copyFileSync)(found, targetPath2);
123431
+ } finally {
123432
+ (0, node_fs.rmSync)(workDir, {
123433
+ recursive: true,
123434
+ force: true
123435
+ });
123436
+ }
123437
+ }
123438
+ var EDGETPU_LIB_ENV = "CAMSTACK_EDGETPU_LIB";
123439
+ var EDGETPU_DELEGATE_RELEASE = "16.0TF2.17.1-1";
123440
+ var LEGACY_EDGETPU_LIB = "/data/deps/edgetpu/lib/libedgetpu.so.1";
123441
+ var FERANICK = `https://github.com/feranick/libedgetpu/releases/download/${EDGETPU_DELEGATE_RELEASE}`;
123442
+ function linuxSet(deb, debSha, debSize, libusbUrl, libusbSha, libusbSize) {
123443
+ return {
123444
+ supported: true,
123445
+ files: [{
123446
+ url: `${FERANICK}/${deb}`,
123447
+ sha256: debSha,
123448
+ sizeBytes: debSize,
123449
+ container: "deb",
123450
+ member: "libedgetpu.so.1",
123451
+ installAs: "libedgetpu.so.1"
123452
+ }, {
123453
+ url: libusbUrl,
123454
+ sha256: libusbSha,
123455
+ sizeBytes: libusbSize,
123456
+ container: "deb",
123457
+ member: "libusb-1.0.so.0",
123458
+ installAs: "libusb-1.0.so.0"
123459
+ }]
123460
+ };
123461
+ }
123462
+ function getEdgetpuDelegateArtifact(platform, arch) {
123463
+ if (platform === "linux" && arch === "x64") return linuxSet("libedgetpu1-std_16.0tf2.17.1-1.ubuntu24.04_amd64.deb", "3cd98ae42d26a0ab601673d2162eb968921f751d3879ef960687637cad1cba96", 389600, "http://archive.ubuntu.com/ubuntu/pool/main/libu/libusb-1.0/libusb-1.0-0_1.0.27-1_amd64.deb", "d59e679a82ee2b724c556397e831e879936adbe8a007705872b65a5e1ec887b5", 54008);
123464
+ if (platform === "linux" && arch === "arm64") return linuxSet("libedgetpu1-std_16.0tf2.17.1-1.ubuntu24.04_arm64.deb", "6d53b6f6f9a19a6685a488e0c262aed2b11b6ff8c953f10e0aa14a16122f0d37", 338416, "http://ports.ubuntu.com/ubuntu-ports/pool/main/libu/libusb-1.0/libusb-1.0-0_1.0.27-1_arm64.deb", "c8c34ef4385b6be34fe94aabd4de06c7bbd5ae617e80e9306f412f4c979aa5e4", 54082);
123465
+ if (platform === "darwin" && arch === "arm64") return {
123466
+ supported: true,
123467
+ files: [{
123468
+ url: `${FERANICK}/libedgetpu-16.0-tf2.17.1-1_MacOS_Silicon.zip`,
123469
+ sha256: "5d57b4ff80bfe70d1d9306a3a8a83f52b38e8a151c35aecf68d807744eacf1f4",
123470
+ sizeBytes: 760105,
123471
+ container: "zip",
123472
+ member: "libedgetpu-16.0-tf2.17.1-1_MacOS_Silicon/throttled/darwin_arm64/libedgetpu.1.0.dylib",
123473
+ installAs: "libedgetpu.1.dylib"
123474
+ }]
123475
+ };
123476
+ if (platform === "darwin") return {
123477
+ supported: false,
123478
+ reason: "ai-edge-litert 2.1.6 publishes no macOS x86_64 wheel, and the Intel delegate links MacPorts libusb at /opt/local/lib"
123479
+ };
123480
+ if (platform === "win32") return {
123481
+ supported: false,
123482
+ reason: "no libedgetpu built against TF 2.17.1 exists for Windows (feranick ships Linux and macOS only)"
123483
+ };
123484
+ return {
123485
+ supported: false,
123486
+ reason: `no pinned libedgetpu build for ${platform}-${arch}`
123487
+ };
123488
+ }
123489
+ function edgetpuDelegateFileName(platform) {
123490
+ return platform === "darwin" ? "libedgetpu.1.dylib" : "libedgetpu.so.1";
123491
+ }
123492
+ function edgetpuLibDir(dataDir) {
123493
+ return (0, node_path.join)(dataDir, "deps", "edgetpu", "lib");
123494
+ }
123495
+ function chooseEdgetpuDelegate(lookup) {
123496
+ const override = lookup.override?.trim();
123497
+ if (override !== void 0 && override.length > 0) return lookup.exists(override) ? {
123498
+ path: override,
123499
+ origin: "override"
123500
+ } : null;
123501
+ if (lookup.dataDir !== void 0 && lookup.dataDir.length > 0) {
123502
+ const staged = (0, node_path.join)(edgetpuLibDir(lookup.dataDir), edgetpuDelegateFileName(lookup.platform));
123503
+ if (lookup.exists(staged)) return {
123504
+ path: staged,
123505
+ origin: "staged"
123506
+ };
123507
+ }
123508
+ if (lookup.exists("/data/deps/edgetpu/lib/libedgetpu.so.1")) return {
123509
+ path: LEGACY_EDGETPU_LIB,
123510
+ origin: "legacy"
123511
+ };
123512
+ return null;
123513
+ }
123514
+ function nodeDataRootFromEnv(env) {
123515
+ return env["CAMSTACK_DATA"] ?? env["CAMSTACK_DATA_DIR"];
123516
+ }
123517
+ async function download(url, target) {
123518
+ const response = await fetch(url, { redirect: "follow" });
123519
+ if (!response.ok) throw new Error(`download failed: ${response.status} ${response.statusText} (${url})`);
123520
+ (0, node_fs.writeFileSync)(target, Buffer.from(await response.arrayBuffer()));
123521
+ }
123522
+ async function stageFile(file, libDir, workRoot) {
123523
+ const target = (0, node_path.join)(libDir, file.installAs);
123524
+ if ((0, node_fs.existsSync)(target)) return;
123525
+ const work = (0, node_path.join)(workRoot, file.installAs);
123526
+ (0, node_fs.rmSync)(work, {
123527
+ recursive: true,
123528
+ force: true
123529
+ });
123530
+ (0, node_fs.mkdirSync)(work, { recursive: true });
123531
+ const container = (0, node_path.join)(work, `download.${file.container}`);
123532
+ const partial = `${target}.partial`;
123533
+ try {
123534
+ await download(file.url, container);
123535
+ verifySha256(container, file.sha256, file.installAs, file.url);
123536
+ if (file.container === "deb") installLibraryFromDeb(container, file.member, partial, (0, node_path.join)(work, "deb"));
123537
+ else {
123538
+ const tree = (0, node_path.join)(work, "tree");
123539
+ (0, node_fs.mkdirSync)(tree, { recursive: true });
123540
+ extractArchive(container, "zip", tree);
123541
+ const inner = (0, node_path.join)(tree, file.member);
123542
+ const found = (0, node_fs.existsSync)(inner) ? inner : findEntryByName(tree, file.member.split("/").pop() ?? file.member);
123543
+ if (found === null) throw new Error(`${file.member} not found inside ${file.url}`);
123544
+ (0, node_fs.copyFileSync)(found, partial);
123545
+ }
123546
+ (0, node_fs.renameSync)(partial, target);
123547
+ } finally {
123548
+ (0, node_fs.rmSync)(work, {
123549
+ recursive: true,
123550
+ force: true
123551
+ });
123552
+ (0, node_fs.rmSync)(partial, { force: true });
123553
+ }
123554
+ }
123555
+ var EDGETPU_DELEGATE_DIRECTIVE = "# camstack-native-dep: edgetpu-delegate";
123556
+ function declaresEdgetpuDelegate(requirementsText) {
123557
+ return requirementsText.split(/\r?\n/).some((line) => line.trim() === EDGETPU_DELEGATE_DIRECTIVE);
123558
+ }
123559
+ async function ensureEdgetpuDelegate(dataDir, logger, opts = {}) {
123560
+ const env = opts.env ?? process.env;
123561
+ const platform = opts.platform ?? process.platform;
123562
+ const arch = opts.arch ?? process.arch;
123563
+ const override = env[EDGETPU_LIB_ENV]?.trim();
123564
+ const present = chooseEdgetpuDelegate({
123565
+ platform,
123566
+ dataDir,
123567
+ override,
123568
+ exists: node_fs.existsSync
123569
+ });
123570
+ if (present !== null) {
123571
+ logger.info("Coral delegate resolved", { meta: {
123572
+ path: present.path,
123573
+ origin: present.origin
123574
+ } });
123575
+ return {
123576
+ kind: "ready",
123577
+ path: present.path,
123578
+ origin: present.origin
123579
+ };
123580
+ }
123581
+ if (override !== void 0 && override.length > 0) {
123582
+ const reason = `${EDGETPU_LIB_ENV} names a file that does not exist: ${override}`;
123583
+ logger.error("Coral delegate not staged", { meta: { reason } });
123584
+ return {
123585
+ kind: "unavailable",
123586
+ reason
123587
+ };
123588
+ }
123589
+ const artifact = getEdgetpuDelegateArtifact(platform, arch);
123590
+ if (!artifact.supported) {
123591
+ logger.warn("Coral delegate not staged", { meta: { reason: artifact.reason } });
123592
+ return {
123593
+ kind: "unavailable",
123594
+ reason: artifact.reason
123595
+ };
123596
+ }
123597
+ const libDir = edgetpuLibDir(dataDir);
123598
+ (0, node_fs.mkdirSync)(libDir, { recursive: true });
123599
+ logger.info("Coral delegate is not on this node yet \u2014 downloading the pinned set", { meta: {
123600
+ release: EDGETPU_DELEGATE_RELEASE,
123601
+ files: artifact.files.map((f) => f.installAs).join(",")
123602
+ } });
123603
+ const workRoot = (0, node_path.join)(dataDir, "deps", ".edgetpu-staging");
123604
+ try {
123605
+ for (const file of artifact.files) await stageFile(file, libDir, workRoot);
123606
+ } finally {
123607
+ (0, node_fs.rmSync)(workRoot, {
123608
+ recursive: true,
123609
+ force: true
123610
+ });
123611
+ }
123612
+ const path = (0, node_path.join)(libDir, edgetpuDelegateFileName(platform));
123613
+ logger.info("Coral delegate resolved", { meta: {
123614
+ path,
123615
+ origin: "downloaded"
123616
+ } });
123617
+ return {
123618
+ kind: "ready",
123619
+ path,
123620
+ origin: "downloaded"
123621
+ };
123622
+ }
123364
123623
  var DEFAULT_FIRST_UNIT_TIMEOUT_MS = 12e3;
123365
123624
  var FRAGMENT_LOG_EVERY = 30;
123366
123625
  var Fmp4FragmentChild = class {
@@ -124381,11 +124640,15 @@ ${(/* @__PURE__ */ new Date()).toISOString()}
124381
124640
  return input.persisted ?? input.fresh;
124382
124641
  }
124383
124642
  exports.ChildCostRegistry = ChildCostRegistry;
124643
+ exports.EDGETPU_DELEGATE_DIRECTIVE = EDGETPU_DELEGATE_DIRECTIVE;
124644
+ exports.EDGETPU_DELEGATE_RELEASE = EDGETPU_DELEGATE_RELEASE;
124645
+ exports.EDGETPU_LIB_ENV = EDGETPU_LIB_ENV;
124384
124646
  exports.FFMPEG_RELEASE = require_composition.FFMPEG_RELEASE;
124385
124647
  exports.FfmpegProcess = FfmpegProcess;
124386
124648
  exports.FilesystemStorageProvider = FilesystemStorageProvider;
124387
124649
  exports.Fmp4FragmentChild = Fmp4FragmentChild;
124388
124650
  exports.Fmp4FragmentPlane = Fmp4FragmentPlane;
124651
+ exports.LEGACY_EDGETPU_LIB = LEGACY_EDGETPU_LIB;
124389
124652
  exports.NO_COST_CLAIM = NO_COST_CLAIM;
124390
124653
  exports.NO_PINNED_FFMPEG_DETAIL = NO_PINNED_FFMPEG_DETAIL;
124391
124654
  exports.OwnerOnlyError = OwnerOnlyError;
@@ -124393,23 +124656,33 @@ ${(/* @__PURE__ */ new Date()).toISOString()}
124393
124656
  exports.buildBinaryPath = buildBinaryPath;
124394
124657
  exports.canonicalDeviceFingerprint = canonicalDeviceFingerprint;
124395
124658
  exports.canonicalHash = require_composition.canonicalHash;
124659
+ exports.chooseEdgetpuDelegate = chooseEdgetpuDelegate;
124396
124660
  exports.containsOrEquals = containsOrEquals;
124397
124661
  exports.customizationBlockName = customizationBlockName;
124662
+ exports.debDataMember = debDataMember;
124663
+ exports.declaresEdgetpuDelegate = declaresEdgetpuDelegate;
124398
124664
  exports.defaultFfmpegSpawn = defaultFfmpegSpawn;
124399
124665
  exports.diffExportTargets = diffExportTargets;
124400
124666
  exports.downloadBinary = downloadBinary;
124667
+ exports.edgetpuDelegateFileName = edgetpuDelegateFileName;
124668
+ exports.edgetpuLibDir = edgetpuLibDir;
124401
124669
  exports.ensureBinary = ensureBinary;
124670
+ exports.ensureEdgetpuDelegate = ensureEdgetpuDelegate;
124402
124671
  exports.ensureFfmpeg = ensureFfmpeg;
124403
124672
  exports.ensurePython = ensurePython;
124673
+ exports.extractDebPayload = extractDebPayload;
124404
124674
  exports.findInPath = findInPath;
124675
+ exports.getEdgetpuDelegateArtifact = getEdgetpuDelegateArtifact;
124405
124676
  exports.getFfmpegArtifact = require_composition.getFfmpegArtifact;
124406
124677
  exports.getFfmpegDownloadUrl = require_composition.getFfmpegDownloadUrl;
124407
124678
  exports.getPlatformInfo = getPlatformInfo;
124408
124679
  exports.getPythonDownloadUrl = getPythonDownloadUrl;
124409
124680
  exports.icaclsArgs = icaclsArgs;
124681
+ exports.installLibraryFromDeb = installLibraryFromDeb;
124410
124682
  exports.installPythonPackages = installPythonPackages;
124411
124683
  exports.installPythonRequirements = installPythonRequirements;
124412
124684
  exports.mkdirOwnerOnlySync = mkdirOwnerOnlySync;
124685
+ exports.nodeDataRootFromEnv = nodeDataRootFromEnv;
124413
124686
  exports.nodeProcStatReader = nodeProcStatReader;
124414
124687
  exports.parseFfmpegCapabilities = parseFfmpegCapabilities;
124415
124688
  exports.parseProcCpuSeconds = parseProcCpuSeconds;
@@ -124417,6 +124690,7 @@ ${(/* @__PURE__ */ new Date()).toISOString()}
124417
124690
  exports.physicalRootOf = physicalRootOf;
124418
124691
  exports.pinnedFfmpegSpawner = pinnedFfmpegSpawner;
124419
124692
  exports.probeFfmpegBinary = probeFfmpegBinary;
124693
+ exports.readArMembers = readArMembers;
124420
124694
  exports.readProcessCost = readProcessCost;
124421
124695
  exports.resolveExportFingerprint = resolveExportFingerprint;
124422
124696
  exports.resolvePinnedFfmpegSpawner = resolvePinnedFfmpegSpawner;
@@ -158995,6 +159269,23 @@ var require_native_metrics_addon = __commonJS({
158995
159269
  var NODE_CONTAINER_CURRENT_KEY = keyOf("container-current-mib");
158996
159270
  keyOf("process-cpu-percent");
158997
159271
  keyOf("process-rss-mib");
159272
+ var RUNNER_SAMPLE_MIN_INTERVAL_MS = 1e4;
159273
+ var RUNNER_SAMPLE_RATE_SLACK_MS = 1e3;
159274
+ function sampleIsDue(slot, ts) {
159275
+ if (slot === void 0 || ts < slot.lastTs) return true;
159276
+ return ts >= slot.nextDue - RUNNER_SAMPLE_RATE_SLACK_MS;
159277
+ }
159278
+ function nextSampleSlot(slot, ts) {
159279
+ if (slot === void 0) return {
159280
+ lastTs: ts,
159281
+ nextDue: ts + RUNNER_SAMPLE_MIN_INTERVAL_MS
159282
+ };
159283
+ if (ts < slot.lastTs) return slot;
159284
+ return {
159285
+ lastTs: ts,
159286
+ nextDue: Math.max(slot.nextDue, ts) + RUNNER_SAMPLE_MIN_INTERVAL_MS
159287
+ };
159288
+ }
158998
159289
  var DECLARATIONS = [
158999
159290
  {
159000
159291
  name: "runner-cpu-main-percent",
@@ -159084,6 +159375,8 @@ var require_native_metrics_addon = __commonJS({
159084
159375
  deps;
159085
159376
  declared = false;
159086
159377
  lastTotalsAt = /* @__PURE__ */ new Map();
159378
+ /** Per node: the door's slot for the per-runner batch (see {@link sampleIsDue}). */
159379
+ sampleSlots = /* @__PURE__ */ new Map();
159087
159380
  /** A not-ready skip was logged and device-history has not been ready since. */
159088
159381
  waitLogged = false;
159089
159382
  constructor(deps) {
@@ -159103,6 +159396,7 @@ var require_native_metrics_addon = __commonJS({
159103
159396
  }
159104
159397
  /** One process snapshot: per-runner sums plus the container's memory. */
159105
159398
  async recordSample(nodeId, atMs, processes, containerMemory) {
159399
+ if (!sampleIsDue(this.sampleSlots.get(nodeId), atMs)) return;
159106
159400
  const subject = {
159107
159401
  kind: "node",
159108
159402
  nodeId
@@ -159146,7 +159440,7 @@ var require_native_metrics_addon = __commonJS({
159146
159440
  points.push(point(RUNNER_PROCESSES_KEY, scope, t.count));
159147
159441
  }
159148
159442
  if (containerMemory !== null) points.push(point(NODE_CONTAINER_CURRENT_KEY, "", Math.round(containerMemory.currentBytes / MIB)));
159149
- await this.write(nodeId, atMs, points);
159443
+ if (await this.write(nodeId, atMs, points) > 0) this.sampleSlots.set(nodeId, nextSampleSlot(this.sampleSlots.get(nodeId), atMs));
159150
159444
  }
159151
159445
  /** One resources snapshot: the node's totals, at most every {@link NODE_TOTALS_MIN_INTERVAL_MS}. */
159152
159446
  async recordTotals(nodeId, atMs, snapshot) {
@@ -159176,8 +159470,8 @@ var require_native_metrics_addon = __commonJS({
159176
159470
  await this.write(nodeId, atMs, points);
159177
159471
  }
159178
159472
  async write(nodeId, atMs, points) {
159179
- if (points.length === 0) return;
159180
- if (!await this.ensureDeclared()) return;
159473
+ if (points.length === 0) return 0;
159474
+ if (!await this.ensureDeclared()) return 0;
159181
159475
  try {
159182
159476
  const result = await this.deps.deviceHistory.record({ points });
159183
159477
  if (result.refused.length > 0) {
@@ -159188,12 +159482,14 @@ var require_native_metrics_addon = __commonJS({
159188
159482
  refused: refusalCounts(result)
159189
159483
  } });
159190
159484
  }
159485
+ return result.accepted;
159191
159486
  } catch (err) {
159192
159487
  this.deps.logger.warn("node metrics history sample not stored", { meta: {
159193
159488
  nodeId,
159194
159489
  atMs,
159195
159490
  error: err instanceof Error ? err.message : String(err)
159196
159491
  } });
159492
+ return 0;
159197
159493
  }
159198
159494
  }
159199
159495
  async readContainerPoints(nodeId, sinceMs, maxPoints) {
@@ -164911,9 +165207,9 @@ var require_lib = __commonJS({
164911
165207
  }
164912
165208
  });
164913
165209
 
164914
- // ../system/dist/wal-maintenance-DUHEp_09.js
164915
- var require_wal_maintenance_DUHEp_09 = __commonJS({
164916
- "../system/dist/wal-maintenance-DUHEp_09.js"(exports) {
165210
+ // ../system/dist/wal-maintenance-CaJjuLHq.js
165211
+ var require_wal_maintenance_CaJjuLHq = __commonJS({
165212
+ "../system/dist/wal-maintenance-CaJjuLHq.js"(exports) {
164917
165213
  "use strict";
164918
165214
  var require_chunk = require_chunk_Cek0wNdY();
164919
165215
  var require_dist10 = require_dist_Bn_RNanh();
@@ -165487,12 +165783,14 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
165487
165783
  const eqCount = equalities.length;
165488
165784
  const eqSet = new Set(equalities.map((p) => p.field));
165489
165785
  const range = ranges[0];
165490
- const candidate = decl.indexes.find((index) => {
165786
+ const candidates = decl.indexes.filter((index) => {
165491
165787
  const leading = index.fields.slice(0, eqCount);
165492
165788
  if (leading.length !== eqCount || !leading.every((f) => eqSet.has(f))) return false;
165493
165789
  if (range !== void 0 && index.fields[eqCount] !== range.field) return false;
165494
165790
  return extra.every((f) => index.fields.includes(f));
165495
165791
  });
165792
+ const groupBy = opts.groupBy;
165793
+ const candidate = (groupBy === void 0 ? void 0 : candidates.find((index) => index.fields[eqCount] === groupBy)) ?? candidates[0];
165496
165794
  if (candidate === void 0) {
165497
165795
  const declared = decl.indexes.map((i) => `${i.name}(${i.fields.join(", ")})`).join("; ");
165498
165796
  throw new require_dist10.UnindexedFilterError(`${kind}: no declared index serves [${[...predicates.map((p) => p.field), ...extra].join(", ")}]. Declared: ${declared.length > 0 ? declared : "none"}. A filter on an unindexed field does not compile - declare an index`);
@@ -165615,9 +165913,9 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
165615
165913
  const params = [];
165616
165914
  const tag = `id:${dir}`;
165617
165915
  if (q.cursor !== void 0) {
165618
- assertCursor(q.cursor, tag, 1);
165916
+ assertCursor(q.cursor, tag, 2);
165619
165917
  clauses.push(`id ${cmp} ?`);
165620
- params.push(...q.cursor.values);
165918
+ params.push(q.cursor.values[0] ?? null);
165621
165919
  }
165622
165920
  return {
165623
165921
  sql: `SELECT ${ROW_COLUMNS}, id AS _k0 FROM records WHERE ${clauses.join(" AND ")} ORDER BY id ${dir} LIMIT ${q.limit + 1}`,
@@ -165668,7 +165966,8 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
165668
165966
  if (extra.length === 0 && q.where === void 0) throw new require_dist10.InvalidRecordError(`${kind}: a count with no field and no groupBy is "count"`);
165669
165967
  const where = planWhere(kind, decl, q.where, {
165670
165968
  allowIn: true,
165671
- extraFields: extra
165969
+ extraFields: extra,
165970
+ groupBy: q.groupBy
165672
165971
  });
165673
165972
  if (where === null) throw new require_dist10.InvalidRecordError(`${kind}: aggregate has nothing to read`);
165674
165973
  const fn = q.op.toUpperCase();
@@ -169092,7 +169391,7 @@ var require_sqlite_settings_addon = __commonJS({
169092
169391
  var require_chunk = require_chunk_Cek0wNdY();
169093
169392
  var require_dist10 = require_dist_Bn_RNanh();
169094
169393
  var require_retired_settings_keys = require_retired_settings_keys_D_VwZiDt();
169095
- var require_wal_maintenance = require_wal_maintenance_DUHEp_09();
169394
+ var require_wal_maintenance = require_wal_maintenance_CaJjuLHq();
169096
169395
  var require_sqlite_snapshot_protocol = require_sqlite_snapshot_protocol_B9OndqZv();
169097
169396
  var require_wal_checkpoint_policy = require_wal_checkpoint_policy_d2z2qPqx();
169098
169397
  var node_fs_promises = __require("fs/promises");
@@ -170819,7 +171118,7 @@ var require_sqlite_storage = __commonJS({
170819
171118
  });
170820
171119
  require_chunk_Cek0wNdY();
170821
171120
  var require_builtins_sqlite_storage_filesystem_storage_addon = require_filesystem_storage_addon();
170822
- var require_wal_maintenance = require_wal_maintenance_DUHEp_09();
171121
+ var require_wal_maintenance = require_wal_maintenance_CaJjuLHq();
170823
171122
  var require_builtins_sqlite_storage_sqlite_settings_addon = require_sqlite_settings_addon();
170824
171123
  var ConfigStore = class {
170825
171124
  db;
@@ -288030,11 +288329,12 @@ var require_restore_archive_DM1OBYq4 = __commonJS({
288030
288329
  }
288031
288330
  });
288032
288331
 
288033
- // ../system/dist/coral-accelerators-Bi_c3Rft.js
288034
- var require_coral_accelerators_Bi_c3Rft = __commonJS({
288035
- "../system/dist/coral-accelerators-Bi_c3Rft.js"(exports) {
288332
+ // ../system/dist/coral-accelerators-oUXmmbc2.js
288333
+ var require_coral_accelerators_oUXmmbc2 = __commonJS({
288334
+ "../system/dist/coral-accelerators-oUXmmbc2.js"(exports) {
288036
288335
  "use strict";
288037
288336
  var require_chunk = require_chunk_Cek0wNdY();
288337
+ var _camstack_types_node = require_node();
288038
288338
  var node_fs = __require("fs");
288039
288339
  node_fs = require_chunk.__toESM(node_fs);
288040
288340
  var CORAL_USB_IDS = [{
@@ -288047,7 +288347,13 @@ var require_coral_accelerators_Bi_c3Rft = __commonJS({
288047
288347
  var CORAL_PCI_VENDOR = "0x1ac1";
288048
288348
  var CORAL_PCI_DEVICE = "0x089a";
288049
288349
  var APEX_ENTRY = /^apex_(\d+)$/;
288050
- var DEFAULT_EDGETPU_LIB = "/data/deps/edgetpu/lib/libedgetpu.so.1";
288350
+ function currentDelegateHost() {
288351
+ return {
288352
+ platform: process.platform,
288353
+ dataDir: (0, _camstack_types_node.nodeDataRootFromEnv)(process.env),
288354
+ override: process.env[_camstack_types_node.EDGETPU_LIB_ENV]
288355
+ };
288356
+ }
288051
288357
  function countUsbCorals(fsx) {
288052
288358
  let count = 0;
288053
288359
  for (const device of fsx.listUsbDevices()) {
@@ -288083,7 +288389,7 @@ var require_coral_accelerators_Bi_c3Rft = __commonJS({
288083
288389
  driverMissing
288084
288390
  };
288085
288391
  }
288086
- function classifyCoralAccelerator(fsx) {
288392
+ function classifyCoralAccelerator(fsx, delegateHost = currentDelegateHost()) {
288087
288393
  const usb = countUsbCorals(fsx);
288088
288394
  const pci = classifyPci(fsx);
288089
288395
  const units = [];
@@ -288114,8 +288420,10 @@ var require_coral_accelerators_Bi_c3Rft = __commonJS({
288114
288420
  type: "coral-edgetpu",
288115
288421
  units
288116
288422
  };
288117
- const libPath = process.env["CAMSTACK_EDGETPU_LIB"] ?? DEFAULT_EDGETPU_LIB;
288118
- if (fsx.exists(libPath)) return {
288423
+ if ((0, _camstack_types_node.chooseEdgetpuDelegate)({
288424
+ ...delegateHost,
288425
+ exists: (p) => fsx.exists(p)
288426
+ }) !== null) return {
288119
288427
  type: "coral-edgetpu",
288120
288428
  units: [{
288121
288429
  bus: "usb",
@@ -294795,7 +295103,7 @@ var require_dist3 = __commonJS({
294795
295103
  var require_builtins_native_metrics_native_metrics_addon = require_native_metrics_addon();
294796
295104
  var require_builtins_device_history_device_history_addon = require_device_history_addon();
294797
295105
  var require_builtins_sqlite_storage_filesystem_storage_addon = require_filesystem_storage_addon();
294798
- var require_wal_maintenance = require_wal_maintenance_DUHEp_09();
295106
+ var require_wal_maintenance = require_wal_maintenance_CaJjuLHq();
294799
295107
  var require_builtins_sqlite_storage_sqlite_settings_addon = require_sqlite_settings_addon();
294800
295108
  var require_builtins_sqlite_storage_index = require_sqlite_storage();
294801
295109
  var require_builtins_storage_orchestrator_storage_orchestrator_addon = require_storage_orchestrator_addon();
@@ -294810,7 +295118,7 @@ var require_dist3 = __commonJS({
294810
295118
  var require_platform_key_source = require_platform_key_source_Di7HrlGR();
294811
295119
  var require_resource_monitor = require_resource_monitor_mio9dSCT();
294812
295120
  var require_restore_archive = require_restore_archive_DM1OBYq4();
294813
- var require_coral_accelerators = require_coral_accelerators_Bi_c3Rft();
295121
+ var require_coral_accelerators = require_coral_accelerators_oUXmmbc2();
294814
295122
  var zod = require_zod();
294815
295123
  var node_crypto = __require("crypto");
294816
295124
  node_crypto = require_chunk.__toESM(node_crypto);
@@ -299706,6 +300014,20 @@ var require_dist3 = __commonJS({
299706
300014
  }
299707
300015
  async loadDeclaration(addonDir, declaration, packageName, packageVersion, packageDisplayName, bundle) {
299708
300016
  if (!declaration.entry) throw new Error(`Addon "${declaration.id}" has no entry point in package.json`);
300017
+ const owner = this.addons.get(declaration.id);
300018
+ if (owner !== void 0 && owner.packageName !== packageName) {
300019
+ this.logger.warn(`Skipped addon "${declaration.id}" from ${packageName}: already provided by ${owner.packageName}`, {
300020
+ tags: { addonId: declaration.id },
300021
+ meta: {
300022
+ skippedPackage: packageName,
300023
+ skippedVersion: packageVersion,
300024
+ skippedDir: addonDir,
300025
+ ownerPackage: owner.packageName,
300026
+ ownerVersion: owner.packageVersion
300027
+ }
300028
+ });
300029
+ return;
300030
+ }
299709
300031
  const entryFile = declaration.entry.replace(/^\.\//, "").replace(/^src\//, "dist/").replace(/\.ts$/, ".js");
299710
300032
  let entryPath = node_path.resolve(addonDir, entryFile);
299711
300033
  if (!node_fs.existsSync(entryPath)) {
@@ -313417,6 +313739,19 @@ var require_dist3 = __commonJS({
313417
313739
  const pythonPath = await this.ensurePython();
313418
313740
  if (!pythonPath) throw new Error("Cannot install Python requirements: Python is not available");
313419
313741
  await singleFlight(this.depsDir, "python-pip", () => (0, _camstack_types_node.installPythonRequirements)(pythonPath, requirementsFile, this.logger));
313742
+ await this.stageNativeDepsDeclaredBy(requirementsFile);
313743
+ }
313744
+ /**
313745
+ * The native library a requirements file says its packages need
313746
+ * (`# camstack-native-dep: edgetpu-delegate`), staged under this node's
313747
+ * deps dir. Runs on every call — not only the first pip install — so a
313748
+ * node whose pip marker predates the line still gets the library. A
313749
+ * platform without a build answers `unavailable` (logged, not thrown); a
313750
+ * failed or tampered download throws, and provisioning reports it.
313751
+ */
313752
+ async stageNativeDepsDeclaredBy(requirementsFile) {
313753
+ if (!(0, _camstack_types_node.declaresEdgetpuDelegate)(node_fs.readFileSync(requirementsFile, "utf8"))) return;
313754
+ await singleFlight(this.depsDir, "edgetpu-delegate", () => (0, _camstack_types_node.ensureEdgetpuDelegate)(this.nodeRoot, this.logger));
313420
313755
  }
313421
313756
  getDepsDir() {
313422
313757
  return this.depsDir;
@@ -317677,6 +318012,7 @@ var require_dist3 = __commonJS({
317677
318012
  exports.RUNTIME_DEFAULTS = require_dist10.RUNTIME_DEFAULTS;
317678
318013
  exports.ReadinessRegistry = require_dist10.ReadinessRegistry;
317679
318014
  exports.ReadinessTimeoutError = require_dist10.ReadinessTimeoutError;
318015
+ exports.RecordsEngine = require_wal_maintenance.RecordsEngine;
317680
318016
  exports.ReplEngine = ReplEngine;
317681
318017
  exports.RingBuffer = RingBuffer;
317682
318018
  exports.SERVER_AUTH_OID = require_agent_https.SERVER_AUTH_OID;
@@ -588165,8 +588501,12 @@ var require_addon_registry_service = __commonJS({
588165
588501
  function isShareViewKind(value) {
588166
588502
  return typeof value === "string" && types_1.SHARE_VIEW_KINDS.includes(value);
588167
588503
  }
588504
+ var SELF_READYING_CAPABILITIES = /* @__PURE__ */ new Set([
588505
+ "platform-probe",
588506
+ "device-history"
588507
+ ]);
588168
588508
  function shouldEmitProviderRegisteredReady(capability) {
588169
- return capability !== "platform-probe";
588509
+ return !SELF_READYING_CAPABILITIES.has(capability);
588170
588510
  }
588171
588511
  var DEVICE_SCOPED_CAP_NAMES = new Set(types_1.ALL_CAPABILITY_DEFINITIONS.filter((def) => def.scope === "device").map((def) => def.name));
588172
588512
  function isDeviceScopedCapName(capName) {
@@ -589790,6 +590130,13 @@ var require_addon_registry_service = __commonJS({
589790
590130
  const failed = [];
589791
590131
  for (const registered of freshLoader.listAddons()) {
589792
590132
  const existing = this.addonEntries.get(registered.declaration.id);
590133
+ if (existing && existing.packageName !== registered.packageName) {
590134
+ this.logger.warn("loadNewAddons: skipped a package claiming a running addon id", {
590135
+ tags: { addonId: registered.declaration.id },
590136
+ meta: { skippedPackage: registered.packageName, ownerPackage: existing.packageName }
590137
+ });
590138
+ continue;
590139
+ }
589793
590140
  if (existing) {
589794
590141
  existing.packageVersion = registered.packageVersion;
589795
590142
  existing.packageName = registered.packageName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstack",
3
- "version": "1.2.195",
3
+ "version": "1.2.197",
4
4
  "description": "CLI tool for managing and running CamStack server",
5
5
  "keywords": [
6
6
  "camstack",