@camstack/addon-provider-amcrest 0.1.5 → 0.1.7

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 (3) hide show
  1. package/dist/addon.js +411 -98
  2. package/dist/addon.mjs +411 -98
  3. package/package.json +4 -1
package/dist/addon.mjs CHANGED
@@ -4634,7 +4634,7 @@ function _instanceof(cls, params = {}) {
4634
4634
  return inst;
4635
4635
  }
4636
4636
  //#endregion
4637
- //#region ../types/dist/sleep-Cc14_yxc.mjs
4637
+ //#region ../types/dist/sleep-DJaTV2D7.mjs
4638
4638
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4639
4639
  EventCategory["SystemBoot"] = "system.boot";
4640
4640
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5355,10 +5355,6 @@ function hydrateField(field, values) {
5355
5355
  };
5356
5356
  }
5357
5357
  const rawValue = storedValue !== void 0 ? storedValue : defaultValue !== void 0 ? defaultValue : null;
5358
- if (field.type === "password") return {
5359
- ...field,
5360
- value: ""
5361
- };
5362
5358
  const value = field.type === "textarea" && field.isJson && rawValue !== null && typeof rawValue === "object" ? JSON.stringify(rawValue, null, 2) : rawValue;
5363
5359
  return {
5364
5360
  ...field,
@@ -6746,6 +6742,9 @@ function method(input, output, options) {
6746
6742
  function event(data) {
6747
6743
  return { data };
6748
6744
  }
6745
+ var StaticDirOutputSchema$1 = object({ staticDir: string() });
6746
+ var VersionOutputSchema$1 = object({ version: string() });
6747
+ method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
6749
6748
  var StaticDirOutputSchema = object({ staticDir: string() });
6750
6749
  var VersionOutputSchema = object({ version: string() });
6751
6750
  method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
@@ -6932,10 +6931,18 @@ var ModelVariantGroupSchema = object({
6932
6931
  precision: _enum(["fp32", "int8"]).optional(),
6933
6932
  /**
6934
6933
  * Speed-optimization axis. Omit ⇒ the standard build. `fast` marks a
6935
- * latency-optimized export (e.g. ReLU-activation / reduced-input variant)
6936
- * — the slot the future performance variants plug into.
6934
+ * latency-optimized export (e.g. ReLU-activation variant) the slot the
6935
+ * future performance variants plug into.
6936
+ */
6937
+ optimization: _enum(["standard", "fast"]).optional(),
6938
+ /**
6939
+ * Input-resolution axis (square input side, px). Omit ⇒ the family's native
6940
+ * resolution (640 for yolo26). Reduced-input builds (320 / 256) are a big,
6941
+ * cheap latency lever — especially on Apple ANE and the Intel N100 — at a
6942
+ * small-object accuracy cost. Mirrors the model's `inputSize` but lifted onto
6943
+ * the group so the selector can offer it as a variant axis.
6937
6944
  */
6938
- optimization: _enum(["standard", "fast"]).optional()
6945
+ resolution: number().int().positive().optional()
6939
6946
  });
6940
6947
  var ModelCatalogEntrySchema = object({
6941
6948
  id: string(),
@@ -8588,6 +8595,72 @@ function createRuntimeStateBridge(params) {
8588
8595
  getStatus
8589
8596
  };
8590
8597
  }
8598
+ /** Reject after `ms`; always clears its own timer. */
8599
+ async function withTimeout(promise, ms, label) {
8600
+ let timer;
8601
+ const timeout = new Promise((_resolve, reject) => {
8602
+ timer = setTimeout(() => reject(/* @__PURE__ */ new Error(`${label} timed out after ${String(ms)}ms`)), ms);
8603
+ });
8604
+ try {
8605
+ return await Promise.race([promise, timeout]);
8606
+ } finally {
8607
+ if (timer !== void 0) clearTimeout(timer);
8608
+ }
8609
+ }
8610
+ /**
8611
+ * Start the reachability poll loop. Returns a handle whose `stop()` clears the
8612
+ * timer and prevents any further ticks. Start on device activation, stop on
8613
+ * device teardown (`removeDevice`) so no timer leaks.
8614
+ */
8615
+ function startReachabilityPoll(options) {
8616
+ const intervalMs = options.intervalMs ?? 3e4;
8617
+ const failuresToOffline = options.failuresToOffline ?? 3;
8618
+ const probeTimeoutMs = options.probeTimeoutMs ?? 1e4;
8619
+ const runImmediately = options.runImmediately ?? true;
8620
+ let stopped = false;
8621
+ let running = false;
8622
+ let consecutiveFailures = 0;
8623
+ let timer;
8624
+ const tick = async () => {
8625
+ if (stopped) return;
8626
+ if (running) return;
8627
+ if (options.isEnabled && !options.isEnabled()) return;
8628
+ running = true;
8629
+ try {
8630
+ const reachable = await withTimeout(Promise.resolve().then(options.probe), probeTimeoutMs, "reachability probe");
8631
+ if (stopped) return;
8632
+ if (reachable) {
8633
+ consecutiveFailures = 0;
8634
+ options.setOnline(true);
8635
+ } else registerFailure("probe resolved unreachable");
8636
+ } catch (error) {
8637
+ if (stopped) return;
8638
+ registerFailure(error instanceof Error ? error.message : "probe threw");
8639
+ } finally {
8640
+ running = false;
8641
+ }
8642
+ };
8643
+ const registerFailure = (reason) => {
8644
+ consecutiveFailures += 1;
8645
+ options.logger?.debug("reachability probe failed", {
8646
+ reason,
8647
+ consecutiveFailures,
8648
+ failuresToOffline
8649
+ });
8650
+ if (consecutiveFailures >= failuresToOffline) options.setOnline(false);
8651
+ };
8652
+ timer = setInterval(() => {
8653
+ tick();
8654
+ }, intervalMs);
8655
+ if (typeof timer === "object" && timer !== null && "unref" in timer) timer.unref();
8656
+ if (runImmediately) tick();
8657
+ return { stop: () => {
8658
+ if (stopped) return;
8659
+ stopped = true;
8660
+ if (timer !== void 0) clearInterval(timer);
8661
+ timer = void 0;
8662
+ } };
8663
+ }
8591
8664
  /**
8592
8665
  * Generic device-level status snapshot. Auto-registered by `BaseDevice`
8593
8666
  * for every device, regardless of provider — the kernel needs a uniform
@@ -11583,7 +11656,7 @@ var BoundingBoxSchema = object({
11583
11656
  w: number(),
11584
11657
  h: number()
11585
11658
  });
11586
- var SpatialDetectionSchema = object({
11659
+ object({
11587
11660
  class: string(),
11588
11661
  originalClass: string(),
11589
11662
  score: number(),
@@ -11774,11 +11847,6 @@ var PipelineSchemaSchema = object({
11774
11847
  selectedEngine: PipelineEngineChoiceSchema,
11775
11848
  slots: array(PipelineSlotSchemaSchema).readonly()
11776
11849
  });
11777
- var DetectorOutputSchema = object({
11778
- detections: array(SpatialDetectionSchema).readonly(),
11779
- inferenceMs: number(),
11780
- modelId: string()
11781
- });
11782
11850
  var EngineProvisioningSchema = object({
11783
11851
  runtimeId: _enum([
11784
11852
  "onnx",
@@ -11901,6 +11969,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11901
11969
  })) }), object({ success: literal(true) }), {
11902
11970
  kind: "mutation",
11903
11971
  auth: "admin"
11972
+ }), method(object({ nodeId: string() }), object({
11973
+ success: literal(true),
11974
+ clearedDevices: number()
11975
+ }), {
11976
+ kind: "mutation",
11977
+ auth: "admin"
11904
11978
  }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
11905
11979
  name: string(),
11906
11980
  steps: array(PipelineTemplateStepSchema).readonly(),
@@ -11918,10 +11992,6 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
11918
11992
  modelId: string(),
11919
11993
  format: ModelFormatSchema$1
11920
11994
  }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
11921
- addonId: string(),
11922
- frame: FrameInputSchema,
11923
- config: record(string(), unknown()).optional()
11924
- }), DetectorOutputSchema), method(object({
11925
11995
  engine: PipelineEngineChoiceSchema.optional(),
11926
11996
  steps: array(PipelineStepInputSchema).min(1),
11927
11997
  frame: FrameInputSchema.optional(),
@@ -15286,7 +15356,9 @@ var AddonPageDeclarationSchema$1 = object({
15286
15356
  icon: string(),
15287
15357
  path: string(),
15288
15358
  remoteName: string(),
15289
- bundle: string()
15359
+ bundle: string(),
15360
+ section: string().optional(),
15361
+ sectionLabel: string().optional()
15290
15362
  });
15291
15363
  var AddonPageInfoSchema = object({
15292
15364
  addonId: string(),
@@ -15326,7 +15398,18 @@ var AddonPageDeclarationSchema = object({
15326
15398
  * the static-file route can compute an mtime-based cache-buster URL
15327
15399
  * without a separate filesystem stat.
15328
15400
  */
15329
- bundle: string()
15401
+ bundle: string(),
15402
+ /**
15403
+ * Sidebar section this page docks into. Well-known ids: `'detection'`,
15404
+ * `'cluster'`, `'administration'` — the page renders inside that group.
15405
+ * Any OTHER string creates (or joins) a custom section rendered after
15406
+ * the built-in groups; its label comes from `sectionLabel` (first
15407
+ * declaration wins), falling back to the id. Absent → the legacy
15408
+ * "Addon Pages" group.
15409
+ */
15410
+ section: string().optional(),
15411
+ /** Display label for a CUSTOM `section` id (ignored for well-known ids). */
15412
+ sectionLabel: string().optional()
15330
15413
  });
15331
15414
  method(_void(), array(AddonPageDeclarationSchema).readonly());
15332
15415
  var AddonHttpRouteSchema = object({
@@ -15542,6 +15625,17 @@ var WidgetMetadataSchema = object({
15542
15625
  deviceContext: boolean().default(false),
15543
15626
  integrationContext: boolean().default(false)
15544
15627
  }),
15628
+ /**
15629
+ * Loadable BEFORE authentication. The normal widget registry listing
15630
+ * (`addon-widgets.listWidgets`) is auth-gated, so a pre-auth surface
15631
+ * (the login page) cannot discover a widget through it. A widget that
15632
+ * declares `preAuth: true` marks itself as safe to mount on a pre-auth
15633
+ * screen — it is surfaced through the PUBLIC `auth.listLoginMethods`
15634
+ * login-method contribution channel (see `login-method.cap.ts`) rather
15635
+ * than the authenticated registry, and its bundle is served by the
15636
+ * public `/api/addon-widgets/:addonId/*` static route. Defaults false.
15637
+ */
15638
+ preAuth: boolean().optional().default(false),
15545
15639
  /** Dashboard placement HINTS (operator can override per instance). */
15546
15640
  defaultSize: WidgetSizeEnum.default("md"),
15547
15641
  allowedSizes: array(WidgetSizeEnum).readonly().default([
@@ -15843,6 +15937,66 @@ method(object({
15843
15937
  password: string()
15844
15938
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
15845
15939
  /**
15940
+ * `login-method` — collection cap through which auth addons contribute
15941
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
15942
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
15943
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
15944
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
15945
+ * procedure aggregates them for the unauthenticated login page.
15946
+ *
15947
+ * A contribution is a discriminated union on `kind`:
15948
+ *
15949
+ * - `redirect` — a declarative button. The login page renders a generic
15950
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
15951
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
15952
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
15953
+ * login page needs NO change.
15954
+ *
15955
+ * - `widget` — a Module-Federation widget the login page mounts (via
15956
+ * `loadRemoteBundle`) for an in-page ceremony. Covers the passkey
15957
+ * login ceremony, which must run `@simplewebauthn/browser` INSIDE the
15958
+ * addon bundle. The referenced widget also declares `preAuth: true` in
15959
+ * its `addon-widgets-source` catalog entry. `auth.listLoginMethods`
15960
+ * stamps a public `bundleUrl` from `addonId` + `bundle`.
15961
+ *
15962
+ * Every contribution carries a `stage`:
15963
+ * - `primary` — shown on the first credentials screen (OIDC /
15964
+ * magic-link buttons; a future usernameless passkey).
15965
+ * - `second-factor` — shown AFTER the password leg, gated on the
15966
+ * returned `factors` (passkey-as-2FA today).
15967
+ *
15968
+ * `mount: skip` — the cap is read server-side by the core auth router
15969
+ * (`registry.getCollection('login-method')`), never mounted as its own
15970
+ * tRPC router.
15971
+ */
15972
+ /** When a login method renders in the two-phase login flow. */
15973
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
15974
+ /** One login-method contribution — redirect button OR pre-auth widget. */
15975
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [object({
15976
+ kind: literal("redirect"),
15977
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
15978
+ id: string(),
15979
+ /** Operator-facing button label. */
15980
+ label: string(),
15981
+ /** lucide-react icon name. */
15982
+ icon: string().optional(),
15983
+ /** Addon-owned HTTP route the button navigates to (GET). */
15984
+ startUrl: string(),
15985
+ stage: LoginStageEnum
15986
+ }), object({
15987
+ kind: literal("widget"),
15988
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
15989
+ id: string(),
15990
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
15991
+ addonId: string(),
15992
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
15993
+ bundle: string(),
15994
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
15995
+ remote: WidgetRemoteSchema,
15996
+ stage: LoginStageEnum
15997
+ })]);
15998
+ method(_void(), array(LoginMethodContributionSchema).readonly());
15999
+ /**
15846
16000
  * Orchestrator-side destination metadata. The orchestrator computes
15847
16001
  * `id = <addonId>:<subId>` from its provider lookup so consumers
15848
16002
  * (admin UI, restore flow) see one canonical key.
@@ -18160,7 +18314,12 @@ var AgentPipelineSettingsSchema = object({
18160
18314
  detectWeight: number().positive().optional(),
18161
18315
  /** Node is eligible to run the detection pipeline (decode + inference). */
18162
18316
  detect: boolean().optional(),
18163
- /** Node is eligible to host decoder sessions. */
18317
+ /**
18318
+ * DEPRECATED AND IGNORED. Decode is always co-located with its frame
18319
+ * consumer, so decode eligibility IS detect eligibility. Kept optional in
18320
+ * the schema ONLY so persisted stores written before the removal still
18321
+ * parse — no code reads it and no write path emits it.
18322
+ */
18164
18323
  decode: boolean().optional(),
18165
18324
  /** Node is eligible to run audio-analyzer sessions. */
18166
18325
  audio: boolean().optional(),
@@ -18221,25 +18380,6 @@ var PipelineAssignmentSchema = object({
18221
18380
  assignedAt: number()
18222
18381
  });
18223
18382
  /**
18224
- * Decoder placement record. Symmetric to `PipelineAssignmentSchema` but for
18225
- * the decoder-node placement domain (`balanceDecoder` decision: manual pin
18226
- * → co-located with pipeline → capacity).
18227
- */
18228
- var DecoderAssignmentSchema = object({
18229
- deviceId: number(),
18230
- /** Moleculer node id of the decoder provider currently responsible for this camera. */
18231
- decoderNodeId: string(),
18232
- /** True when the assignment was set manually via `assignDecoder`, false when chosen by the balancer. */
18233
- pinned: boolean(),
18234
- /** Why this assignment was made — useful for debugging the decoder balancer. */
18235
- reason: _enum([
18236
- "manual",
18237
- "co-located",
18238
- "capacity",
18239
- "hardware-affinity"
18240
- ])
18241
- });
18242
- /**
18243
18383
  * Per-agent load summary surfaced to the load balancer + dashboards.
18244
18384
  * Aggregated from each runner's `getLocalLoad` cap call.
18245
18385
  */
@@ -18445,15 +18585,6 @@ method(object({
18445
18585
  }), method(_void(), IngestOwnerSchema), method(object({
18446
18586
  deviceId: number(),
18447
18587
  nodeId: string()
18448
- }), _void(), {
18449
- kind: "mutation",
18450
- auth: "admin"
18451
- }), method(object({ deviceId: number() }), _void(), {
18452
- kind: "mutation",
18453
- auth: "admin"
18454
- }), method(_void(), array(DecoderAssignmentSchema).readonly()), method(object({
18455
- deviceId: number(),
18456
- nodeId: string()
18457
18588
  }), object({ success: literal(true) }), {
18458
18589
  kind: "mutation",
18459
18590
  auth: "admin"
@@ -18472,10 +18603,7 @@ method(object({
18472
18603
  nodeId: string(),
18473
18604
  pinned: boolean(),
18474
18605
  assignedAt: number()
18475
- }))), method(object({
18476
- deviceId: number(),
18477
- pipelineNodeId: string().optional()
18478
- }), DecoderAssignmentSchema), method(object({ agentNodeId: string() }), AgentPipelineSettingsSchema.nullable()), method(_void(), array(object({
18606
+ }))), method(object({ agentNodeId: string() }), AgentPipelineSettingsSchema.nullable()), method(_void(), array(object({
18479
18607
  nodeId: string(),
18480
18608
  settings: AgentPipelineSettingsSchema
18481
18609
  })).readonly()), method(object({
@@ -18505,7 +18633,6 @@ method(object({
18505
18633
  }), method(object({
18506
18634
  agentNodeId: string(),
18507
18635
  detect: boolean().nullable().optional(),
18508
- decode: boolean().nullable().optional(),
18509
18636
  audio: boolean().nullable().optional(),
18510
18637
  ingest: boolean().nullable().optional()
18511
18638
  }), object({ success: literal(true) }), {
@@ -18517,6 +18644,15 @@ method(object({
18517
18644
  }), object({ success: literal(true) }), {
18518
18645
  kind: "mutation",
18519
18646
  auth: "admin"
18647
+ }), method(object({ agentNodeId: string() }), object({
18648
+ success: literal(true),
18649
+ /** Hardware-aware default detection model now in effect on the node (null when unresolvable). */
18650
+ effectiveModelId: string().nullable(),
18651
+ /** Number of cameras whose node-scoped overrides were cleared. */
18652
+ clearedCameraOverrides: number()
18653
+ }), {
18654
+ kind: "mutation",
18655
+ auth: "admin"
18520
18656
  }), method(object({ deviceId: number() }), CameraPipelineSettingsSchema.nullable()), method(object({
18521
18657
  deviceId: number(),
18522
18658
  addonId: string(),
@@ -18562,6 +18698,131 @@ method(object({
18562
18698
  auth: "admin"
18563
18699
  });
18564
18700
  /**
18701
+ * server-management — per-NODE singleton capability for a node's ROOT
18702
+ * package lifecycle (runtime-updatable node packages, phase 2: hub + docker
18703
+ * agents).
18704
+ *
18705
+ * Each node's root package (`@camstack/server` on the hub, `@camstack/agent`
18706
+ * on agents) carries the whole software stack in its npm dep tree, so ONE
18707
+ * version describes the node. Updates install into
18708
+ * `<dataDir>/server-root/versions/<v>/` and apply on restart via the baked
18709
+ * starter (probation boot + auto-rollback to N-1).
18710
+ *
18711
+ * Providers:
18712
+ * - HUB: `ServerUpdateService` behind the `server-provided` mount
18713
+ * (`buildServerProviders` in trpc.router.ts) — the default target for
18714
+ * unpinned calls.
18715
+ * - AGENT: `AgentUpdateService` registered by the agent bootstrap under
18716
+ * the synthetic `agent-runtime` addonId and declared in the agent's
18717
+ * `$hub.registerNode` manifest.
18718
+ *
18719
+ * Node routing: singleton caps get the codegen/runtime-builder `nodeId`
18720
+ * injection on every method — `input.nodeId` (or `nodePin(nodeId)` from the
18721
+ * SDK) routes the call to that node's provider via the standard remote
18722
+ * proxy (`createCapabilityProxy` → `$agent-cap-fwd` → the agent's
18723
+ * in-process provider lookup). No `nodeId` → the hub's own provider.
18724
+ *
18725
+ * Spec: docs/superpowers/specs/2026-07-12-runtime-updatable-node-packages-design.md
18726
+ */
18727
+ /**
18728
+ * Where the running hub's code was loaded from:
18729
+ * - `workspace` — dev checkout (tsx / workspace dist); the starter defers to
18730
+ * plain resolution and runtime updates are refused.
18731
+ * - `baked` — the immutable image seed closure (no data-dir root active).
18732
+ * - `data-root` — the runtime-updatable `<dataDir>/server-root` closure.
18733
+ */
18734
+ var ServerBootModeSchema = _enum([
18735
+ "workspace",
18736
+ "baked",
18737
+ "data-root"
18738
+ ]);
18739
+ /**
18740
+ * Update lifecycle state:
18741
+ * - `idle` / `checking` / `staging` — steady / in-flight registry work.
18742
+ * - `pending-restart` — a version is staged and the node has NOT yet
18743
+ * restarted onto it (still running the OLD version).
18744
+ * - `awaiting-confirmation` — the node HAS restarted onto the staged version
18745
+ * (it is the active probation boot) and is waiting to confirm boot-health.
18746
+ * Apply/rollback are refused in this state and the node must NOT be
18747
+ * manually restarted, or the probation boot auto-rolls-back.
18748
+ */
18749
+ var ServerUpdateStateSchema = _enum([
18750
+ "idle",
18751
+ "checking",
18752
+ "staging",
18753
+ "pending-restart",
18754
+ "awaiting-confirmation"
18755
+ ]);
18756
+ var ServerRollbackInfoSchema = object({
18757
+ /** The version that failed (or was manually rolled back). */
18758
+ fromVersion: string(),
18759
+ /** The version rolled back to; null = the baked seed. */
18760
+ toVersion: string().nullable(),
18761
+ atMs: number(),
18762
+ reason: string()
18763
+ });
18764
+ var ServerPackageStatusSchema = object({
18765
+ /** Root package name (`@camstack/server` on the hub). */
18766
+ packageName: string(),
18767
+ /** Version of the code the running process ACTUALLY loaded. */
18768
+ runningVersion: string().nullable(),
18769
+ /** Node.js runtime version the node's process runs on (`process.versions.node`). */
18770
+ nodeRuntimeVersion: string().nullable(),
18771
+ /** Active data-dir root version; null when booted from seed/workspace. */
18772
+ activeVersion: string().nullable(),
18773
+ /** N-1 version kept for rollback; null when no previous version exists. */
18774
+ previousVersion: string().nullable(),
18775
+ /** Version of the immutable baked seed closure (image fallback). */
18776
+ seedVersion: string().nullable(),
18777
+ /** Latest registry version from the most recent check (null = never checked). */
18778
+ latestVersion: string().nullable(),
18779
+ updateAvailable: boolean(),
18780
+ bootMode: ServerBootModeSchema,
18781
+ updateState: ServerUpdateStateSchema,
18782
+ /** Version staged + awaiting its probation boot, when one is pending. */
18783
+ pendingVersion: string().nullable(),
18784
+ /** Set when the last freshly-activated version failed its boot health-check. */
18785
+ rolledBack: ServerRollbackInfoSchema.nullable(),
18786
+ /**
18787
+ * True when `server-root/state.json` EXISTS but is unreadable/corrupt — the
18788
+ * hub is running from the baked seed (or workspace) while installed data-dir
18789
+ * versions are being IGNORED. Surfaced as a warning in the UI.
18790
+ */
18791
+ stateFileCorrupt: boolean(),
18792
+ lastCheckedAtMs: number().nullable()
18793
+ });
18794
+ var ServerUpdateCheckResultSchema = object({
18795
+ packageName: string(),
18796
+ runningVersion: string().nullable(),
18797
+ latestVersion: string().nullable(),
18798
+ updateAvailable: boolean(),
18799
+ checkedAtMs: number(),
18800
+ /** Non-null when the registry lookup failed (offline, bad registry, …). */
18801
+ error: string().nullable()
18802
+ });
18803
+ var ServerUpdateActionResultSchema = object({
18804
+ accepted: boolean(),
18805
+ targetVersion: string().nullable(),
18806
+ /** True when a graceful restart was scheduled to apply the change. */
18807
+ restarting: boolean(),
18808
+ message: string()
18809
+ });
18810
+ method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
18811
+ kind: "mutation",
18812
+ auth: "admin"
18813
+ }), method(object({
18814
+ /** Explicit target version; omitted = latest from the registry. */
18815
+ version: string().optional() }), ServerUpdateActionResultSchema, {
18816
+ kind: "mutation",
18817
+ auth: "admin"
18818
+ }), method(_void(), ServerUpdateActionResultSchema, {
18819
+ kind: "mutation",
18820
+ auth: "admin"
18821
+ }), method(_void(), ServerUpdateActionResultSchema, {
18822
+ kind: "mutation",
18823
+ auth: "admin"
18824
+ });
18825
+ /**
18565
18826
  * Query filter for settings-store collections.
18566
18827
  */
18567
18828
  var QueryFilterSchema = object({
@@ -20591,6 +20852,16 @@ var TopologyCategorySchema = object({
20591
20852
  healthy: number(),
20592
20853
  addons: array(TopologyCategoryAddonSchema).readonly()
20593
20854
  });
20855
+ /**
20856
+ * The node's runtime-updatable ROOT package (`@camstack/server` on the hub,
20857
+ * `@camstack/agent` on agents) as reported by its `registerNode` manifest —
20858
+ * version visibility for the Server management surface. Nullable: offline
20859
+ * rows and pre-phase-2 nodes report none.
20860
+ */
20861
+ var TopologyRootPackageSchema = object({
20862
+ name: string(),
20863
+ version: string()
20864
+ });
20594
20865
  var TopologyNodeSchema = object({
20595
20866
  id: string(),
20596
20867
  name: string(),
@@ -20614,7 +20885,8 @@ var TopologyNodeSchema = object({
20614
20885
  status: string()
20615
20886
  })).readonly(),
20616
20887
  processes: array(TopologyProcessSchema).readonly(),
20617
- categories: array(TopologyCategorySchema).readonly()
20888
+ categories: array(TopologyCategorySchema).readonly(),
20889
+ rootPackage: TopologyRootPackageSchema.nullable()
20618
20890
  });
20619
20891
  var CapUsageEdgeSchema = object({
20620
20892
  callerAddonId: string(),
@@ -23713,6 +23985,12 @@ Object.freeze({
23713
23985
  addonId: null,
23714
23986
  access: "create"
23715
23987
  },
23988
+ "loginMethod.getLoginMethods": {
23989
+ capName: "login-method",
23990
+ capScope: "system",
23991
+ addonId: null,
23992
+ access: "view"
23993
+ },
23716
23994
  "mediaPlayer.next": {
23717
23995
  capName: "media-player",
23718
23996
  capScope: "device",
@@ -24343,23 +24621,23 @@ Object.freeze({
24343
24621
  addonId: null,
24344
24622
  access: "create"
24345
24623
  },
24346
- "pipelineExecutor.deleteModel": {
24624
+ "pipelineExecutor.clearDeviceOverrides": {
24347
24625
  capName: "pipeline-executor",
24348
24626
  capScope: "system",
24349
24627
  addonId: null,
24350
24628
  access: "delete"
24351
24629
  },
24352
- "pipelineExecutor.deleteTemplate": {
24630
+ "pipelineExecutor.deleteModel": {
24353
24631
  capName: "pipeline-executor",
24354
24632
  capScope: "system",
24355
24633
  addonId: null,
24356
24634
  access: "delete"
24357
24635
  },
24358
- "pipelineExecutor.detect": {
24636
+ "pipelineExecutor.deleteTemplate": {
24359
24637
  capName: "pipeline-executor",
24360
24638
  capScope: "system",
24361
24639
  addonId: null,
24362
- access: "view"
24640
+ access: "delete"
24363
24641
  },
24364
24642
  "pipelineExecutor.downloadModel": {
24365
24643
  capName: "pipeline-executor",
@@ -24565,12 +24843,6 @@ Object.freeze({
24565
24843
  addonId: null,
24566
24844
  access: "create"
24567
24845
  },
24568
- "pipelineOrchestrator.assignDecoder": {
24569
- capName: "pipeline-orchestrator",
24570
- capScope: "system",
24571
- addonId: null,
24572
- access: "create"
24573
- },
24574
24846
  "pipelineOrchestrator.assignPipeline": {
24575
24847
  capName: "pipeline-orchestrator",
24576
24848
  capScope: "system",
@@ -24649,18 +24921,6 @@ Object.freeze({
24649
24921
  addonId: null,
24650
24922
  access: "view"
24651
24923
  },
24652
- "pipelineOrchestrator.getDecoderAssignment": {
24653
- capName: "pipeline-orchestrator",
24654
- capScope: "system",
24655
- addonId: null,
24656
- access: "view"
24657
- },
24658
- "pipelineOrchestrator.getDecoderAssignments": {
24659
- capName: "pipeline-orchestrator",
24660
- capScope: "system",
24661
- addonId: null,
24662
- access: "view"
24663
- },
24664
24924
  "pipelineOrchestrator.getGlobalMetrics": {
24665
24925
  capName: "pipeline-orchestrator",
24666
24926
  capScope: "system",
@@ -24709,6 +24969,12 @@ Object.freeze({
24709
24969
  addonId: null,
24710
24970
  access: "delete"
24711
24971
  },
24972
+ "pipelineOrchestrator.resetNodePipelineDefaults": {
24973
+ capName: "pipeline-orchestrator",
24974
+ capScope: "system",
24975
+ addonId: null,
24976
+ access: "delete"
24977
+ },
24712
24978
  "pipelineOrchestrator.resolvePipeline": {
24713
24979
  capName: "pipeline-orchestrator",
24714
24980
  capScope: "system",
@@ -24781,12 +25047,6 @@ Object.freeze({
24781
25047
  addonId: null,
24782
25048
  access: "create"
24783
25049
  },
24784
- "pipelineOrchestrator.unassignDecoder": {
24785
- capName: "pipeline-orchestrator",
24786
- capScope: "system",
24787
- addonId: null,
24788
- access: "create"
24789
- },
24790
25050
  "pipelineOrchestrator.unassignPipeline": {
24791
25051
  capName: "pipeline-orchestrator",
24792
25052
  capScope: "system",
@@ -25093,6 +25353,36 @@ Object.freeze({
25093
25353
  addonId: null,
25094
25354
  access: "create"
25095
25355
  },
25356
+ "serverManagement.applyServerUpdate": {
25357
+ capName: "server-management",
25358
+ capScope: "system",
25359
+ addonId: null,
25360
+ access: "create"
25361
+ },
25362
+ "serverManagement.checkServerUpdate": {
25363
+ capName: "server-management",
25364
+ capScope: "system",
25365
+ addonId: null,
25366
+ access: "create"
25367
+ },
25368
+ "serverManagement.getServerPackageStatus": {
25369
+ capName: "server-management",
25370
+ capScope: "system",
25371
+ addonId: null,
25372
+ access: "view"
25373
+ },
25374
+ "serverManagement.restartServer": {
25375
+ capName: "server-management",
25376
+ capScope: "system",
25377
+ addonId: null,
25378
+ access: "create"
25379
+ },
25380
+ "serverManagement.rollbackServerUpdate": {
25381
+ capName: "server-management",
25382
+ capScope: "system",
25383
+ addonId: null,
25384
+ access: "create"
25385
+ },
25096
25386
  "settingsStore.count": {
25097
25387
  capName: "settings-store",
25098
25388
  capScope: "system",
@@ -25957,6 +26247,18 @@ Object.freeze({
25957
26247
  addonId: null,
25958
26248
  access: "view"
25959
26249
  },
26250
+ "viewerUi.getStaticDir": {
26251
+ capName: "viewer-ui",
26252
+ capScope: "system",
26253
+ addonId: null,
26254
+ access: "view"
26255
+ },
26256
+ "viewerUi.getVersion": {
26257
+ capName: "viewer-ui",
26258
+ capScope: "system",
26259
+ addonId: null,
26260
+ access: "view"
26261
+ },
25960
26262
  "waterHeater.setAway": {
25961
26263
  capName: "water-heater",
25962
26264
  capScope: "device",
@@ -26726,6 +27028,10 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
26726
27028
  motionActive = false;
26727
27029
  /** Keepalive re-emit timer for a sustained motion window. */
26728
27030
  motionKeepaliveTimer = null;
27031
+ /** Control-plane reachability poll — drives `device.online` from Dahua CGI
27032
+ * `getDeviceInfo` liveness, decoupled from stream-broker video health.
27033
+ * Started in `onActivate`, stopped in `removeDevice`. */
27034
+ reachabilityPoll = null;
26729
27035
  /** Single-flight guard for the `stream-params` camera refresh. */
26730
27036
  streamParamsRefreshInFlight = null;
26731
27037
  /** Single-flight guard for the `motion-zones` camera refresh. */
@@ -26898,12 +27204,33 @@ var AmcrestCamera = class AmcrestCamera extends BaseDevice {
26898
27204
  /** Phase 5 — device is live: open the onboard-motion event stream. */
26899
27205
  async onActivate() {
26900
27206
  this.ensureEventSubscription();
27207
+ this.startReachabilityPolling();
27208
+ }
27209
+ /** Start the control-plane reachability poll: a Dahua CGI `getDeviceInfo`
27210
+ * round-trip every 30s drives `device.online`, with hysteresis. Replaces
27211
+ * the old stream-health→online mirror so an on-demand (idle) but reachable
27212
+ * camera still reports ONLINE. Idempotent. */
27213
+ startReachabilityPolling() {
27214
+ if (this.reachabilityPoll) return;
27215
+ this.reachabilityPoll = startReachabilityPoll({
27216
+ probe: async () => {
27217
+ await this.ensureClient().getDeviceInfo();
27218
+ return true;
27219
+ },
27220
+ setOnline: (online) => {
27221
+ this.markOnline(online);
27222
+ },
27223
+ isEnabled: () => !this.disabled,
27224
+ logger: this.ctx.logger
27225
+ });
26901
27226
  }
26902
27227
  /** Teardown — stop the stream + motion timers, drop the client. */
26903
27228
  async removeDevice() {
26904
27229
  this.ctx.logger.info("Removing Amcrest camera", { tags: { deviceId: this.id } });
26905
27230
  this.teardownEventSubscription();
26906
27231
  this.clearPtzAutoStop();
27232
+ this.reachabilityPoll?.stop();
27233
+ this.reachabilityPoll = null;
26907
27234
  this.client = null;
26908
27235
  }
26909
27236
  registerStreamCatalogProvider() {
@@ -36924,21 +37251,7 @@ var AmcrestProviderAddon = class extends BaseDeviceProvider {
36924
37251
  throw new Error(`Amcrest: probe on ${host || "(unknown host)"} resolved neither mac nor host address — cannot persist a stable row key. Verify network reachability + credentials, then retry.`);
36925
37252
  }
36926
37253
  async onInitialize() {
36927
- const regs = await super.onInitialize();
36928
- this.subscribe({ category: EventCategory.DeviceStateChanged }, (event) => {
36929
- const data = event.data;
36930
- if (data.capName !== "camera-streams") return;
36931
- const deviceId = data.deviceId;
36932
- if (typeof deviceId !== "number") return;
36933
- const registry = this.ctx.kernel.deviceRegistry;
36934
- if (!registry) return;
36935
- if (registry.getAddonId(deviceId) !== this.addonId) return;
36936
- const device = registry.getById(deviceId);
36937
- if (!device) return;
36938
- const online = data.slice?.online === true;
36939
- if (device.online !== online) device.online = online;
36940
- });
36941
- return regs;
37254
+ return await super.onInitialize();
36942
37255
  }
36943
37256
  async supportsDiscovery() {
36944
37257
  return true;