@camstack/addon-pipeline-orchestrator 1.1.33 → 1.1.35

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/index.js CHANGED
@@ -2,6 +2,33 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
+ //#region \0rolldown/runtime.js
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
14
+ key = keys[i];
15
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
+ get: ((k) => from[k]).bind(null, key),
17
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
+ });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+ //#endregion
27
+ let node_fs = require("node:fs");
28
+ node_fs = __toESM(node_fs);
29
+ let node_path = require("node:path");
30
+ node_path = __toESM(node_path);
31
+ let node_url = require("node:url");
5
32
  //#region ../../node_modules/zod/v4/core/core.js
6
33
  var _a$1;
7
34
  function $constructor(name, initializer, params) {
@@ -4631,7 +4658,7 @@ function _instanceof(cls, params = {}) {
4631
4658
  return inst;
4632
4659
  }
4633
4660
  //#endregion
4634
- //#region ../types/dist/sleep-DiQ8xW1M.mjs
4661
+ //#region ../types/dist/sleep-DJaTV2D7.mjs
4635
4662
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4636
4663
  EventCategory["SystemBoot"] = "system.boot";
4637
4664
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5352,10 +5379,6 @@ function hydrateField(field, values) {
5352
5379
  };
5353
5380
  }
5354
5381
  const rawValue = storedValue !== void 0 ? storedValue : defaultValue !== void 0 ? defaultValue : null;
5355
- if (field.type === "password") return {
5356
- ...field,
5357
- value: ""
5358
- };
5359
5382
  const value = field.type === "textarea" && field.isJson && rawValue !== null && typeof rawValue === "object" ? JSON.stringify(rawValue, null, 2) : rawValue;
5360
5383
  return {
5361
5384
  ...field,
@@ -7115,9 +7138,28 @@ function method(input, output, options) {
7115
7138
  timeoutMs: options?.timeoutMs
7116
7139
  };
7117
7140
  }
7141
+ var StaticDirOutputSchema$1 = object({ staticDir: string() });
7142
+ var VersionOutputSchema$1 = object({ version: string() });
7143
+ method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
7118
7144
  var StaticDirOutputSchema = object({ staticDir: string() });
7119
7145
  var VersionOutputSchema = object({ version: string() });
7120
- method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
7146
+ /**
7147
+ * viewer-ui — serves the CamStack VIEWER web build (the Expo/React-Native
7148
+ * universal client's PWA export) from the hub, alongside admin-ui. Mirrors
7149
+ * `admin-ui` exactly: a singleton, server-internal cap exposing the static
7150
+ * dist directory + build version so `main.ts` can mount the SPA under a
7151
+ * dedicated prefix.
7152
+ */
7153
+ var viewerUiCapability = {
7154
+ name: "viewer-ui",
7155
+ scope: "system",
7156
+ mode: "singleton",
7157
+ internal: true,
7158
+ methods: {
7159
+ getStaticDir: method(_void(), StaticDirOutputSchema),
7160
+ getVersion: method(_void(), VersionOutputSchema)
7161
+ }
7162
+ };
7121
7163
  /**
7122
7164
  * device-ops — device-scoped cap that unifies the per-IDevice operations
7123
7165
  * previously routed through the `.device-ops` Moleculer bridge service.
@@ -13432,6 +13474,17 @@ var WidgetMetadataSchema = object({
13432
13474
  deviceContext: boolean().default(false),
13433
13475
  integrationContext: boolean().default(false)
13434
13476
  }),
13477
+ /**
13478
+ * Loadable BEFORE authentication. The normal widget registry listing
13479
+ * (`addon-widgets.listWidgets`) is auth-gated, so a pre-auth surface
13480
+ * (the login page) cannot discover a widget through it. A widget that
13481
+ * declares `preAuth: true` marks itself as safe to mount on a pre-auth
13482
+ * screen — it is surfaced through the PUBLIC `auth.listLoginMethods`
13483
+ * login-method contribution channel (see `login-method.cap.ts`) rather
13484
+ * than the authenticated registry, and its bundle is served by the
13485
+ * public `/api/addon-widgets/:addonId/*` static route. Defaults false.
13486
+ */
13487
+ preAuth: boolean().optional().default(false),
13435
13488
  /** Dashboard placement HINTS (operator can override per instance). */
13436
13489
  defaultSize: WidgetSizeEnum.default("md"),
13437
13490
  allowedSizes: array(WidgetSizeEnum).readonly().default([
@@ -13739,6 +13792,66 @@ method(object({
13739
13792
  password: string()
13740
13793
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13741
13794
  /**
13795
+ * `login-method` — collection cap through which auth addons contribute
13796
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
13797
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
13798
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13799
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13800
+ * procedure aggregates them for the unauthenticated login page.
13801
+ *
13802
+ * A contribution is a discriminated union on `kind`:
13803
+ *
13804
+ * - `redirect` — a declarative button. The login page renders a generic
13805
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
13806
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13807
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13808
+ * login page needs NO change.
13809
+ *
13810
+ * - `widget` — a Module-Federation widget the login page mounts (via
13811
+ * `loadRemoteBundle`) for an in-page ceremony. Covers the passkey
13812
+ * login ceremony, which must run `@simplewebauthn/browser` INSIDE the
13813
+ * addon bundle. The referenced widget also declares `preAuth: true` in
13814
+ * its `addon-widgets-source` catalog entry. `auth.listLoginMethods`
13815
+ * stamps a public `bundleUrl` from `addonId` + `bundle`.
13816
+ *
13817
+ * Every contribution carries a `stage`:
13818
+ * - `primary` — shown on the first credentials screen (OIDC /
13819
+ * magic-link buttons; a future usernameless passkey).
13820
+ * - `second-factor` — shown AFTER the password leg, gated on the
13821
+ * returned `factors` (passkey-as-2FA today).
13822
+ *
13823
+ * `mount: skip` — the cap is read server-side by the core auth router
13824
+ * (`registry.getCollection('login-method')`), never mounted as its own
13825
+ * tRPC router.
13826
+ */
13827
+ /** When a login method renders in the two-phase login flow. */
13828
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
13829
+ /** One login-method contribution — redirect button OR pre-auth widget. */
13830
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [object({
13831
+ kind: literal("redirect"),
13832
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13833
+ id: string(),
13834
+ /** Operator-facing button label. */
13835
+ label: string(),
13836
+ /** lucide-react icon name. */
13837
+ icon: string().optional(),
13838
+ /** Addon-owned HTTP route the button navigates to (GET). */
13839
+ startUrl: string(),
13840
+ stage: LoginStageEnum
13841
+ }), object({
13842
+ kind: literal("widget"),
13843
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13844
+ id: string(),
13845
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
13846
+ addonId: string(),
13847
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13848
+ bundle: string(),
13849
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13850
+ remote: WidgetRemoteSchema,
13851
+ stage: LoginStageEnum
13852
+ })]);
13853
+ method(_void(), array(LoginMethodContributionSchema).readonly());
13854
+ /**
13742
13855
  * Orchestrator-side destination metadata. The orchestrator computes
13743
13856
  * `id = <addonId>:<subId>` from its provider lookup so consumers
13744
13857
  * (admin UI, restore flow) see one canonical key.
@@ -16710,6 +16823,131 @@ var pipelineOrchestratorCapability = {
16710
16823
  }
16711
16824
  };
16712
16825
  /**
16826
+ * server-management — per-NODE singleton capability for a node's ROOT
16827
+ * package lifecycle (runtime-updatable node packages, phase 2: hub + docker
16828
+ * agents).
16829
+ *
16830
+ * Each node's root package (`@camstack/server` on the hub, `@camstack/agent`
16831
+ * on agents) carries the whole software stack in its npm dep tree, so ONE
16832
+ * version describes the node. Updates install into
16833
+ * `<dataDir>/server-root/versions/<v>/` and apply on restart via the baked
16834
+ * starter (probation boot + auto-rollback to N-1).
16835
+ *
16836
+ * Providers:
16837
+ * - HUB: `ServerUpdateService` behind the `server-provided` mount
16838
+ * (`buildServerProviders` in trpc.router.ts) — the default target for
16839
+ * unpinned calls.
16840
+ * - AGENT: `AgentUpdateService` registered by the agent bootstrap under
16841
+ * the synthetic `agent-runtime` addonId and declared in the agent's
16842
+ * `$hub.registerNode` manifest.
16843
+ *
16844
+ * Node routing: singleton caps get the codegen/runtime-builder `nodeId`
16845
+ * injection on every method — `input.nodeId` (or `nodePin(nodeId)` from the
16846
+ * SDK) routes the call to that node's provider via the standard remote
16847
+ * proxy (`createCapabilityProxy` → `$agent-cap-fwd` → the agent's
16848
+ * in-process provider lookup). No `nodeId` → the hub's own provider.
16849
+ *
16850
+ * Spec: docs/superpowers/specs/2026-07-12-runtime-updatable-node-packages-design.md
16851
+ */
16852
+ /**
16853
+ * Where the running hub's code was loaded from:
16854
+ * - `workspace` — dev checkout (tsx / workspace dist); the starter defers to
16855
+ * plain resolution and runtime updates are refused.
16856
+ * - `baked` — the immutable image seed closure (no data-dir root active).
16857
+ * - `data-root` — the runtime-updatable `<dataDir>/server-root` closure.
16858
+ */
16859
+ var ServerBootModeSchema = _enum([
16860
+ "workspace",
16861
+ "baked",
16862
+ "data-root"
16863
+ ]);
16864
+ /**
16865
+ * Update lifecycle state:
16866
+ * - `idle` / `checking` / `staging` — steady / in-flight registry work.
16867
+ * - `pending-restart` — a version is staged and the node has NOT yet
16868
+ * restarted onto it (still running the OLD version).
16869
+ * - `awaiting-confirmation` — the node HAS restarted onto the staged version
16870
+ * (it is the active probation boot) and is waiting to confirm boot-health.
16871
+ * Apply/rollback are refused in this state and the node must NOT be
16872
+ * manually restarted, or the probation boot auto-rolls-back.
16873
+ */
16874
+ var ServerUpdateStateSchema = _enum([
16875
+ "idle",
16876
+ "checking",
16877
+ "staging",
16878
+ "pending-restart",
16879
+ "awaiting-confirmation"
16880
+ ]);
16881
+ var ServerRollbackInfoSchema = object({
16882
+ /** The version that failed (or was manually rolled back). */
16883
+ fromVersion: string(),
16884
+ /** The version rolled back to; null = the baked seed. */
16885
+ toVersion: string().nullable(),
16886
+ atMs: number(),
16887
+ reason: string()
16888
+ });
16889
+ var ServerPackageStatusSchema = object({
16890
+ /** Root package name (`@camstack/server` on the hub). */
16891
+ packageName: string(),
16892
+ /** Version of the code the running process ACTUALLY loaded. */
16893
+ runningVersion: string().nullable(),
16894
+ /** Node.js runtime version the node's process runs on (`process.versions.node`). */
16895
+ nodeRuntimeVersion: string().nullable(),
16896
+ /** Active data-dir root version; null when booted from seed/workspace. */
16897
+ activeVersion: string().nullable(),
16898
+ /** N-1 version kept for rollback; null when no previous version exists. */
16899
+ previousVersion: string().nullable(),
16900
+ /** Version of the immutable baked seed closure (image fallback). */
16901
+ seedVersion: string().nullable(),
16902
+ /** Latest registry version from the most recent check (null = never checked). */
16903
+ latestVersion: string().nullable(),
16904
+ updateAvailable: boolean(),
16905
+ bootMode: ServerBootModeSchema,
16906
+ updateState: ServerUpdateStateSchema,
16907
+ /** Version staged + awaiting its probation boot, when one is pending. */
16908
+ pendingVersion: string().nullable(),
16909
+ /** Set when the last freshly-activated version failed its boot health-check. */
16910
+ rolledBack: ServerRollbackInfoSchema.nullable(),
16911
+ /**
16912
+ * True when `server-root/state.json` EXISTS but is unreadable/corrupt — the
16913
+ * hub is running from the baked seed (or workspace) while installed data-dir
16914
+ * versions are being IGNORED. Surfaced as a warning in the UI.
16915
+ */
16916
+ stateFileCorrupt: boolean(),
16917
+ lastCheckedAtMs: number().nullable()
16918
+ });
16919
+ var ServerUpdateCheckResultSchema = object({
16920
+ packageName: string(),
16921
+ runningVersion: string().nullable(),
16922
+ latestVersion: string().nullable(),
16923
+ updateAvailable: boolean(),
16924
+ checkedAtMs: number(),
16925
+ /** Non-null when the registry lookup failed (offline, bad registry, …). */
16926
+ error: string().nullable()
16927
+ });
16928
+ var ServerUpdateActionResultSchema = object({
16929
+ accepted: boolean(),
16930
+ targetVersion: string().nullable(),
16931
+ /** True when a graceful restart was scheduled to apply the change. */
16932
+ restarting: boolean(),
16933
+ message: string()
16934
+ });
16935
+ method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
16936
+ kind: "mutation",
16937
+ auth: "admin"
16938
+ }), method(object({
16939
+ /** Explicit target version; omitted = latest from the registry. */
16940
+ version: string().optional() }), ServerUpdateActionResultSchema, {
16941
+ kind: "mutation",
16942
+ auth: "admin"
16943
+ }), method(_void(), ServerUpdateActionResultSchema, {
16944
+ kind: "mutation",
16945
+ auth: "admin"
16946
+ }), method(_void(), ServerUpdateActionResultSchema, {
16947
+ kind: "mutation",
16948
+ auth: "admin"
16949
+ });
16950
+ /**
16713
16951
  * Query filter for settings-store collections.
16714
16952
  */
16715
16953
  var QueryFilterSchema = object({
@@ -18696,6 +18934,16 @@ var TopologyCategorySchema = object({
18696
18934
  healthy: number(),
18697
18935
  addons: array(TopologyCategoryAddonSchema).readonly()
18698
18936
  });
18937
+ /**
18938
+ * The node's runtime-updatable ROOT package (`@camstack/server` on the hub,
18939
+ * `@camstack/agent` on agents) as reported by its `registerNode` manifest —
18940
+ * version visibility for the Server management surface. Nullable: offline
18941
+ * rows and pre-phase-2 nodes report none.
18942
+ */
18943
+ var TopologyRootPackageSchema = object({
18944
+ name: string(),
18945
+ version: string()
18946
+ });
18699
18947
  var TopologyNodeSchema = object({
18700
18948
  id: string(),
18701
18949
  name: string(),
@@ -18719,7 +18967,8 @@ var TopologyNodeSchema = object({
18719
18967
  status: string()
18720
18968
  })).readonly(),
18721
18969
  processes: array(TopologyProcessSchema).readonly(),
18722
- categories: array(TopologyCategorySchema).readonly()
18970
+ categories: array(TopologyCategorySchema).readonly(),
18971
+ rootPackage: TopologyRootPackageSchema.nullable()
18723
18972
  });
18724
18973
  var CapUsageEdgeSchema = object({
18725
18974
  callerAddonId: string(),
@@ -21519,6 +21768,12 @@ Object.freeze({
21519
21768
  addonId: null,
21520
21769
  access: "create"
21521
21770
  },
21771
+ "loginMethod.getLoginMethods": {
21772
+ capName: "login-method",
21773
+ capScope: "system",
21774
+ addonId: null,
21775
+ access: "view"
21776
+ },
21522
21777
  "mediaPlayer.next": {
21523
21778
  capName: "media-player",
21524
21779
  capScope: "device",
@@ -22881,6 +23136,36 @@ Object.freeze({
22881
23136
  addonId: null,
22882
23137
  access: "create"
22883
23138
  },
23139
+ "serverManagement.applyServerUpdate": {
23140
+ capName: "server-management",
23141
+ capScope: "system",
23142
+ addonId: null,
23143
+ access: "create"
23144
+ },
23145
+ "serverManagement.checkServerUpdate": {
23146
+ capName: "server-management",
23147
+ capScope: "system",
23148
+ addonId: null,
23149
+ access: "create"
23150
+ },
23151
+ "serverManagement.getServerPackageStatus": {
23152
+ capName: "server-management",
23153
+ capScope: "system",
23154
+ addonId: null,
23155
+ access: "view"
23156
+ },
23157
+ "serverManagement.restartServer": {
23158
+ capName: "server-management",
23159
+ capScope: "system",
23160
+ addonId: null,
23161
+ access: "create"
23162
+ },
23163
+ "serverManagement.rollbackServerUpdate": {
23164
+ capName: "server-management",
23165
+ capScope: "system",
23166
+ addonId: null,
23167
+ access: "create"
23168
+ },
22884
23169
  "settingsStore.count": {
22885
23170
  capName: "settings-store",
22886
23171
  capScope: "system",
@@ -23745,6 +24030,18 @@ Object.freeze({
23745
24030
  addonId: null,
23746
24031
  access: "view"
23747
24032
  },
24033
+ "viewerUi.getStaticDir": {
24034
+ capName: "viewer-ui",
24035
+ capScope: "system",
24036
+ addonId: null,
24037
+ access: "view"
24038
+ },
24039
+ "viewerUi.getVersion": {
24040
+ capName: "viewer-ui",
24041
+ capScope: "system",
24042
+ addonId: null,
24043
+ access: "view"
24044
+ },
23748
24045
  "waterHeater.setAway": {
23749
24046
  capName: "water-heater",
23750
24047
  capScope: "device",
@@ -26499,7 +26796,7 @@ var DetectionWiringController = class {
26499
26796
  * the motion stream id.
26500
26797
  *
26501
26798
  * Public — `PlacementService`'s `buildWatchdogCamera` closure (wired in
26502
- * `index.ts`) calls straight through to this method.
26799
+ * `orchestrator-bootstrap.ts`) calls straight through to this method.
26503
26800
  */
26504
26801
  buildWatchdogCamera(config, deviceName) {
26505
26802
  const continuousStages = /* @__PURE__ */ new Map();
@@ -26523,8 +26820,8 @@ var DetectionWiringController = class {
26523
26820
  * source refresh on ITS OWN stream so a dropped rfc4571 source
26524
26821
  * re-materializes and the runner's frame poller resumes.
26525
26822
  *
26526
- * Public — `PipelineWatchdog`'s `recover` closure (wired in `index.ts`)
26527
- * calls straight through to this method.
26823
+ * Public — `PipelineWatchdog`'s `recover` closure (wired in
26824
+ * `orchestrator-bootstrap.ts`) calls straight through to this method.
26528
26825
  */
26529
26826
  recoverPipelineStage(deviceId, stage, streamId) {
26530
26827
  if (stage === "audio") {
@@ -26958,7 +27255,7 @@ function selectRunnerFrameSource(input) {
26958
27255
  }
26959
27256
  //#endregion
26960
27257
  //#region src/placement-service.ts
26961
- /** Key under which the orchestrator stores its per-device manual pin — shared with `readPipelinePin`/`handleNodeDisconnect` in index.ts. */
27258
+ /** Key under which the orchestrator stores its per-device manual pin — shared with `readPipelinePin` (index.ts) and `handleNodeDisconnect` (`node-lifecycle-handler.ts`). */
26962
27259
  var PREFERRED_AGENT_SETTING = "preferredAgent";
26963
27260
  var PlacementService = class {
26964
27261
  deps;
@@ -28739,6 +29036,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
28739
29036
  dispose() {
28740
29037
  this.disposed = true;
28741
29038
  }
29039
+ blobWriteLock = new KeyedAsyncLock({ isShuttingDown: () => this.disposed });
29040
+ static AGENT_SETTINGS_LOCK_KEY = "agentSettings";
28742
29041
  _nodeBindingsState = null;
28743
29042
  _templatesState = null;
28744
29043
  _agentSettingsState = null;
@@ -28800,28 +29099,47 @@ var PipelineSettingsStore = class PipelineSettingsStore {
28800
29099
  async readAgentSettingsMap() {
28801
29100
  return { ...await this.agentSettingsState.get() };
28802
29101
  }
28803
- /** Overwrite one agent's settings. Does NOT touch other agents' entries. */
29102
+ /**
29103
+ * Overwrite one agent's settings. Does NOT touch other agents' entries.
29104
+ * The read-modify-write runs under {@link blobWriteLock}, so a concurrent
29105
+ * write for a DIFFERENT node can never be dropped (both re-read the fresh
29106
+ * blob when their turn comes and only overlay their own node's entry).
29107
+ */
28804
29108
  async writeAgentSettings(nodeId, settings) {
28805
29109
  if (typeof nodeId !== "string" || nodeId.length === 0 || nodeId === "undefined" || nodeId === "null") {
28806
29110
  this.deps.logger.warn("writeAgentSettings: refusing to persist malformed nodeId", { meta: { nodeId } });
28807
29111
  return;
28808
29112
  }
28809
- const all = await this.readAgentSettingsMap();
28810
- const existing = all[nodeId];
28811
- all[nodeId] = {
28812
- ...existing,
28813
- ...settings,
28814
- maxCameras: settings.maxCameras !== void 0 ? settings.maxCameras ?? null : existing?.maxCameras ?? null
28815
- };
28816
- await this.agentSettingsState.set(all);
29113
+ await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
29114
+ const all = await this.readAgentSettingsMap();
29115
+ const existing = all[nodeId];
29116
+ const merged = {
29117
+ ...existing,
29118
+ ...settings,
29119
+ maxCameras: settings.maxCameras !== void 0 ? settings.maxCameras ?? null : existing?.maxCameras ?? null
29120
+ };
29121
+ await this.agentSettingsState.set({
29122
+ ...all,
29123
+ [nodeId]: merged
29124
+ });
29125
+ });
28817
29126
  }
28818
- /** Drop one agent's persisted settings entry. Returns whether an entry existed. */
29127
+ /**
29128
+ * Drop one agent's persisted settings entry. Returns whether an entry
29129
+ * existed (`false` also when the store is already disposed — the locked
29130
+ * section becomes a no-op then). Serialized via {@link blobWriteLock} for
29131
+ * the same lost-write reason as {@link writeAgentSettings}.
29132
+ */
28819
29133
  async removeAgentSettings(nodeId) {
28820
- const all = await this.readAgentSettingsMap();
28821
- if (!(nodeId in all)) return false;
28822
- const { [nodeId]: _drop, ...rest } = all;
28823
- await this.agentSettingsState.set(rest);
28824
- return true;
29134
+ let removed = false;
29135
+ await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
29136
+ const all = await this.readAgentSettingsMap();
29137
+ if (!(nodeId in all)) return;
29138
+ const { [nodeId]: _drop, ...rest } = all;
29139
+ await this.agentSettingsState.set(rest);
29140
+ removed = true;
29141
+ });
29142
+ return removed;
28825
29143
  }
28826
29144
  /** Read the `cameraSettings` map (keyed on `deviceId` as string) via the durable handle. */
28827
29145
  async readCameraSettingsMap() {
@@ -29964,9 +30282,10 @@ var SessionDispatchController = class {
29964
30282
  this.sessionRegistry.setTeardownTimer(deviceId, timer);
29965
30283
  }
29966
30284
  /**
29967
- * The session + motion-watch teardown half of the addon's `stopDetection`
29968
- * (the other half — `releaseCamera` + `audio.stopForDevice` — stays on
29969
- * `index.ts`, which calls this AFTER those run, same as before).
30285
+ * The session + motion-watch teardown half of `stopDetection` (the other
30286
+ * half — `releaseCamera` + `audio.stopForDevice` — lives in
30287
+ * `DetectionWiringController.stopDetection` since S11 Task 3, which calls
30288
+ * this AFTER those run, same ordering as before).
29970
30289
  *
29971
30290
  * Stopping/disabling/removing an on-motion camera must also close any
29972
30291
  * ACTIVE detection session and release the motion-watch attach.
@@ -30431,7 +30750,6 @@ async function buildOrchestratorControllers(deps) {
30431
30750
  },
30432
30751
  listZones: async (deviceId) => await zonesProvider?.listZones({ deviceId }) ?? [],
30433
30752
  readPipelinePin: (deviceId) => deps.readPipelinePin(deviceId),
30434
- eventBus: deps.ctx().eventBus,
30435
30753
  logger: deps.ctx().logger
30436
30754
  });
30437
30755
  const deviceConfig = new DeviceConfigContributions({
@@ -30685,10 +31003,51 @@ async function buildOrchestratorControllers(deps) {
30685
31003
  };
30686
31004
  }
30687
31005
  //#endregion
31006
+ //#region src/viewer-ui-provider.ts
31007
+ /**
31008
+ * viewer-ui provider — the pipeline-orchestrator serves the CamStack viewer web
31009
+ * SPA (mirrors what the now-removed standalone addon-viewer-ui used to do).
31010
+ *
31011
+ * Why here: the orchestrator is a hub bootstrap addon (always installed + baked),
31012
+ * so folding the viewer serving into it avoids a second addon whose only job was
31013
+ * to hold static files. The viewer's Expo web export is COPIED into this addon's
31014
+ * `assets/viewer/` locally by the viewer repo's `scripts/copy-dist-to-orchestrator.js`
31015
+ * (run from a checkout that HAS the `camstack/` submodule + Expo toolchain — the
31016
+ * publish/image CI does not, which is exactly why we copy a pre-built dist rather
31017
+ * than build it here). vite emits only into `dist/`, so `assets/viewer` survives
31018
+ * the addon build; `assets` is in the package `files`, so it ships on
31019
+ * `camstack deploy`. The hub's `main.ts` resolves the `viewer-ui` singleton at
31020
+ * boot and mounts the SPA at `/viewer/camstack`.
31021
+ *
31022
+ * `index.js` runs from `dist/`, so the SPA root is one level up + `assets/viewer`.
31023
+ */
31024
+ var __dirname$1 = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
31025
+ /** Absolute path to the staged viewer web SPA (`<addon-root>/assets/viewer`). */
31026
+ function resolveViewerDistDir() {
31027
+ return node_path.default.resolve(__dirname$1, "..", "assets", "viewer");
31028
+ }
31029
+ /** Version of the staged viewer, written by the copy script; 'unknown' if absent. */
31030
+ function readViewerVersion() {
31031
+ try {
31032
+ const raw = node_fs.default.readFileSync(node_path.default.join(resolveViewerDistDir(), ".viewer-version"), "utf-8").trim();
31033
+ if (raw) return raw;
31034
+ } catch {}
31035
+ return "unknown";
31036
+ }
31037
+ /** Build the viewer-ui provider. Serves whatever dist was staged into
31038
+ * `assets/viewer`; when nothing is staged the hub's mount cleanly 404s. */
31039
+ function createViewerUiProvider() {
31040
+ return {
31041
+ getStaticDir: async () => ({ staticDir: resolveViewerDistDir() }),
31042
+ getVersion: async () => ({ version: readViewerVersion() })
31043
+ };
31044
+ }
31045
+ //#endregion
30688
31046
  //#region src/widget-catalog.ts
30689
31047
  var pipelineOrchestratorWidgets = [{
30690
31048
  tab: "device-tab",
30691
31049
  label: "Pipeline Quick Stats",
31050
+ preAuth: false,
30692
31051
  kind: "remote",
30693
31052
  remote: {
30694
31053
  remoteName: "addon_pipeline_orchestrator_widgets",
@@ -30715,6 +31074,7 @@ var pipelineOrchestratorWidgets = [{
30715
31074
  }, {
30716
31075
  tab: "device-tab",
30717
31076
  label: "Zone Editor",
31077
+ preAuth: false,
30718
31078
  kind: "remote",
30719
31079
  remote: {
30720
31080
  remoteName: "addon_pipeline_orchestrator_widgets",
@@ -31382,6 +31742,10 @@ var PipelineOrchestratorAddon = class PipelineOrchestratorAddon extends BaseAddo
31382
31742
  {
31383
31743
  capability: addonWidgetsSourceCapability,
31384
31744
  provider: { listWidgets: async () => pipelineOrchestratorWidgets }
31745
+ },
31746
+ {
31747
+ capability: viewerUiCapability,
31748
+ provider: createViewerUiProvider()
31385
31749
  }
31386
31750
  ],
31387
31751
  customActions: pipelineOrchestratorActions,