@camstack/addon-pipeline-orchestrator 1.1.33 → 1.1.34

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
@@ -4631,7 +4631,7 @@ function _instanceof(cls, params = {}) {
4631
4631
  return inst;
4632
4632
  }
4633
4633
  //#endregion
4634
- //#region ../types/dist/sleep-DiQ8xW1M.mjs
4634
+ //#region ../types/dist/sleep-DJaTV2D7.mjs
4635
4635
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4636
4636
  EventCategory["SystemBoot"] = "system.boot";
4637
4637
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -5352,10 +5352,6 @@ function hydrateField(field, values) {
5352
5352
  };
5353
5353
  }
5354
5354
  const rawValue = storedValue !== void 0 ? storedValue : defaultValue !== void 0 ? defaultValue : null;
5355
- if (field.type === "password") return {
5356
- ...field,
5357
- value: ""
5358
- };
5359
5355
  const value = field.type === "textarea" && field.isJson && rawValue !== null && typeof rawValue === "object" ? JSON.stringify(rawValue, null, 2) : rawValue;
5360
5356
  return {
5361
5357
  ...field,
@@ -7115,6 +7111,9 @@ function method(input, output, options) {
7115
7111
  timeoutMs: options?.timeoutMs
7116
7112
  };
7117
7113
  }
7114
+ var StaticDirOutputSchema$1 = object({ staticDir: string() });
7115
+ var VersionOutputSchema$1 = object({ version: string() });
7116
+ method(_void(), StaticDirOutputSchema$1), method(_void(), VersionOutputSchema$1);
7118
7117
  var StaticDirOutputSchema = object({ staticDir: string() });
7119
7118
  var VersionOutputSchema = object({ version: string() });
7120
7119
  method(_void(), StaticDirOutputSchema), method(_void(), VersionOutputSchema);
@@ -13432,6 +13431,17 @@ var WidgetMetadataSchema = object({
13432
13431
  deviceContext: boolean().default(false),
13433
13432
  integrationContext: boolean().default(false)
13434
13433
  }),
13434
+ /**
13435
+ * Loadable BEFORE authentication. The normal widget registry listing
13436
+ * (`addon-widgets.listWidgets`) is auth-gated, so a pre-auth surface
13437
+ * (the login page) cannot discover a widget through it. A widget that
13438
+ * declares `preAuth: true` marks itself as safe to mount on a pre-auth
13439
+ * screen — it is surfaced through the PUBLIC `auth.listLoginMethods`
13440
+ * login-method contribution channel (see `login-method.cap.ts`) rather
13441
+ * than the authenticated registry, and its bundle is served by the
13442
+ * public `/api/addon-widgets/:addonId/*` static route. Defaults false.
13443
+ */
13444
+ preAuth: boolean().optional().default(false),
13435
13445
  /** Dashboard placement HINTS (operator can override per instance). */
13436
13446
  defaultSize: WidgetSizeEnum.default("md"),
13437
13447
  allowedSizes: array(WidgetSizeEnum).readonly().default([
@@ -13739,6 +13749,66 @@ method(object({
13739
13749
  password: string()
13740
13750
  }), AuthResultSchema.nullable(), { kind: "mutation" }), method(object({ state: string() }), string()), method(record(string(), string()), AuthResultSchema, { kind: "mutation" }), method(object({ token: string() }), AuthResultSchema.nullable());
13741
13751
  /**
13752
+ * `login-method` — collection cap through which auth addons contribute
13753
+ * their pre-auth login surfaces to the login page. This is the SINGLE,
13754
+ * generic mechanism that supersedes the dead `auth.listProviders` reader:
13755
+ * every auth addon (OIDC, magic-link, WebAuthn/passkey) registers a
13756
+ * `login-method` provider and the PUBLIC `auth.listLoginMethods`
13757
+ * procedure aggregates them for the unauthenticated login page.
13758
+ *
13759
+ * A contribution is a discriminated union on `kind`:
13760
+ *
13761
+ * - `redirect` — a declarative button. The login page renders a generic
13762
+ * button that navigates to `startUrl` (an addon-owned HTTP route).
13763
+ * Covers OIDC (`/addon/auth-oidc/<id>/start`) and magic-link with
13764
+ * ZERO shell-side JS. A future SSO addon plugs in the same way — the
13765
+ * login page needs NO change.
13766
+ *
13767
+ * - `widget` — a Module-Federation widget the login page mounts (via
13768
+ * `loadRemoteBundle`) for an in-page ceremony. Covers the passkey
13769
+ * login ceremony, which must run `@simplewebauthn/browser` INSIDE the
13770
+ * addon bundle. The referenced widget also declares `preAuth: true` in
13771
+ * its `addon-widgets-source` catalog entry. `auth.listLoginMethods`
13772
+ * stamps a public `bundleUrl` from `addonId` + `bundle`.
13773
+ *
13774
+ * Every contribution carries a `stage`:
13775
+ * - `primary` — shown on the first credentials screen (OIDC /
13776
+ * magic-link buttons; a future usernameless passkey).
13777
+ * - `second-factor` — shown AFTER the password leg, gated on the
13778
+ * returned `factors` (passkey-as-2FA today).
13779
+ *
13780
+ * `mount: skip` — the cap is read server-side by the core auth router
13781
+ * (`registry.getCollection('login-method')`), never mounted as its own
13782
+ * tRPC router.
13783
+ */
13784
+ /** When a login method renders in the two-phase login flow. */
13785
+ var LoginStageEnum = _enum(["primary", "second-factor"]);
13786
+ /** One login-method contribution — redirect button OR pre-auth widget. */
13787
+ var LoginMethodContributionSchema = discriminatedUnion("kind", [object({
13788
+ kind: literal("redirect"),
13789
+ /** Stable id within the login-method set (e.g. `auth-oidc/google`). */
13790
+ id: string(),
13791
+ /** Operator-facing button label. */
13792
+ label: string(),
13793
+ /** lucide-react icon name. */
13794
+ icon: string().optional(),
13795
+ /** Addon-owned HTTP route the button navigates to (GET). */
13796
+ startUrl: string(),
13797
+ stage: LoginStageEnum
13798
+ }), object({
13799
+ kind: literal("widget"),
13800
+ /** Stable id within the login-method set (e.g. `auth-webauthn/passkey-login`). */
13801
+ id: string(),
13802
+ /** Owning addon id — drives the public bundle URL + the MF namespace. */
13803
+ addonId: string(),
13804
+ /** Bundle filename inside the addon's dist dir (`remoteEntry.js`). */
13805
+ bundle: string(),
13806
+ /** MF remote descriptor — `{ remoteName, exposedModule, componentKey }`. */
13807
+ remote: WidgetRemoteSchema,
13808
+ stage: LoginStageEnum
13809
+ })]);
13810
+ method(_void(), array(LoginMethodContributionSchema).readonly());
13811
+ /**
13742
13812
  * Orchestrator-side destination metadata. The orchestrator computes
13743
13813
  * `id = <addonId>:<subId>` from its provider lookup so consumers
13744
13814
  * (admin UI, restore flow) see one canonical key.
@@ -16710,6 +16780,131 @@ var pipelineOrchestratorCapability = {
16710
16780
  }
16711
16781
  };
16712
16782
  /**
16783
+ * server-management — per-NODE singleton capability for a node's ROOT
16784
+ * package lifecycle (runtime-updatable node packages, phase 2: hub + docker
16785
+ * agents).
16786
+ *
16787
+ * Each node's root package (`@camstack/server` on the hub, `@camstack/agent`
16788
+ * on agents) carries the whole software stack in its npm dep tree, so ONE
16789
+ * version describes the node. Updates install into
16790
+ * `<dataDir>/server-root/versions/<v>/` and apply on restart via the baked
16791
+ * starter (probation boot + auto-rollback to N-1).
16792
+ *
16793
+ * Providers:
16794
+ * - HUB: `ServerUpdateService` behind the `server-provided` mount
16795
+ * (`buildServerProviders` in trpc.router.ts) — the default target for
16796
+ * unpinned calls.
16797
+ * - AGENT: `AgentUpdateService` registered by the agent bootstrap under
16798
+ * the synthetic `agent-runtime` addonId and declared in the agent's
16799
+ * `$hub.registerNode` manifest.
16800
+ *
16801
+ * Node routing: singleton caps get the codegen/runtime-builder `nodeId`
16802
+ * injection on every method — `input.nodeId` (or `nodePin(nodeId)` from the
16803
+ * SDK) routes the call to that node's provider via the standard remote
16804
+ * proxy (`createCapabilityProxy` → `$agent-cap-fwd` → the agent's
16805
+ * in-process provider lookup). No `nodeId` → the hub's own provider.
16806
+ *
16807
+ * Spec: docs/superpowers/specs/2026-07-12-runtime-updatable-node-packages-design.md
16808
+ */
16809
+ /**
16810
+ * Where the running hub's code was loaded from:
16811
+ * - `workspace` — dev checkout (tsx / workspace dist); the starter defers to
16812
+ * plain resolution and runtime updates are refused.
16813
+ * - `baked` — the immutable image seed closure (no data-dir root active).
16814
+ * - `data-root` — the runtime-updatable `<dataDir>/server-root` closure.
16815
+ */
16816
+ var ServerBootModeSchema = _enum([
16817
+ "workspace",
16818
+ "baked",
16819
+ "data-root"
16820
+ ]);
16821
+ /**
16822
+ * Update lifecycle state:
16823
+ * - `idle` / `checking` / `staging` — steady / in-flight registry work.
16824
+ * - `pending-restart` — a version is staged and the node has NOT yet
16825
+ * restarted onto it (still running the OLD version).
16826
+ * - `awaiting-confirmation` — the node HAS restarted onto the staged version
16827
+ * (it is the active probation boot) and is waiting to confirm boot-health.
16828
+ * Apply/rollback are refused in this state and the node must NOT be
16829
+ * manually restarted, or the probation boot auto-rolls-back.
16830
+ */
16831
+ var ServerUpdateStateSchema = _enum([
16832
+ "idle",
16833
+ "checking",
16834
+ "staging",
16835
+ "pending-restart",
16836
+ "awaiting-confirmation"
16837
+ ]);
16838
+ var ServerRollbackInfoSchema = object({
16839
+ /** The version that failed (or was manually rolled back). */
16840
+ fromVersion: string(),
16841
+ /** The version rolled back to; null = the baked seed. */
16842
+ toVersion: string().nullable(),
16843
+ atMs: number(),
16844
+ reason: string()
16845
+ });
16846
+ var ServerPackageStatusSchema = object({
16847
+ /** Root package name (`@camstack/server` on the hub). */
16848
+ packageName: string(),
16849
+ /** Version of the code the running process ACTUALLY loaded. */
16850
+ runningVersion: string().nullable(),
16851
+ /** Node.js runtime version the node's process runs on (`process.versions.node`). */
16852
+ nodeRuntimeVersion: string().nullable(),
16853
+ /** Active data-dir root version; null when booted from seed/workspace. */
16854
+ activeVersion: string().nullable(),
16855
+ /** N-1 version kept for rollback; null when no previous version exists. */
16856
+ previousVersion: string().nullable(),
16857
+ /** Version of the immutable baked seed closure (image fallback). */
16858
+ seedVersion: string().nullable(),
16859
+ /** Latest registry version from the most recent check (null = never checked). */
16860
+ latestVersion: string().nullable(),
16861
+ updateAvailable: boolean(),
16862
+ bootMode: ServerBootModeSchema,
16863
+ updateState: ServerUpdateStateSchema,
16864
+ /** Version staged + awaiting its probation boot, when one is pending. */
16865
+ pendingVersion: string().nullable(),
16866
+ /** Set when the last freshly-activated version failed its boot health-check. */
16867
+ rolledBack: ServerRollbackInfoSchema.nullable(),
16868
+ /**
16869
+ * True when `server-root/state.json` EXISTS but is unreadable/corrupt — the
16870
+ * hub is running from the baked seed (or workspace) while installed data-dir
16871
+ * versions are being IGNORED. Surfaced as a warning in the UI.
16872
+ */
16873
+ stateFileCorrupt: boolean(),
16874
+ lastCheckedAtMs: number().nullable()
16875
+ });
16876
+ var ServerUpdateCheckResultSchema = object({
16877
+ packageName: string(),
16878
+ runningVersion: string().nullable(),
16879
+ latestVersion: string().nullable(),
16880
+ updateAvailable: boolean(),
16881
+ checkedAtMs: number(),
16882
+ /** Non-null when the registry lookup failed (offline, bad registry, …). */
16883
+ error: string().nullable()
16884
+ });
16885
+ var ServerUpdateActionResultSchema = object({
16886
+ accepted: boolean(),
16887
+ targetVersion: string().nullable(),
16888
+ /** True when a graceful restart was scheduled to apply the change. */
16889
+ restarting: boolean(),
16890
+ message: string()
16891
+ });
16892
+ method(_void(), ServerPackageStatusSchema, { auth: "admin" }), method(_void(), ServerUpdateCheckResultSchema, {
16893
+ kind: "mutation",
16894
+ auth: "admin"
16895
+ }), method(object({
16896
+ /** Explicit target version; omitted = latest from the registry. */
16897
+ version: string().optional() }), ServerUpdateActionResultSchema, {
16898
+ kind: "mutation",
16899
+ auth: "admin"
16900
+ }), method(_void(), ServerUpdateActionResultSchema, {
16901
+ kind: "mutation",
16902
+ auth: "admin"
16903
+ }), method(_void(), ServerUpdateActionResultSchema, {
16904
+ kind: "mutation",
16905
+ auth: "admin"
16906
+ });
16907
+ /**
16713
16908
  * Query filter for settings-store collections.
16714
16909
  */
16715
16910
  var QueryFilterSchema = object({
@@ -18696,6 +18891,16 @@ var TopologyCategorySchema = object({
18696
18891
  healthy: number(),
18697
18892
  addons: array(TopologyCategoryAddonSchema).readonly()
18698
18893
  });
18894
+ /**
18895
+ * The node's runtime-updatable ROOT package (`@camstack/server` on the hub,
18896
+ * `@camstack/agent` on agents) as reported by its `registerNode` manifest —
18897
+ * version visibility for the Server management surface. Nullable: offline
18898
+ * rows and pre-phase-2 nodes report none.
18899
+ */
18900
+ var TopologyRootPackageSchema = object({
18901
+ name: string(),
18902
+ version: string()
18903
+ });
18699
18904
  var TopologyNodeSchema = object({
18700
18905
  id: string(),
18701
18906
  name: string(),
@@ -18719,7 +18924,8 @@ var TopologyNodeSchema = object({
18719
18924
  status: string()
18720
18925
  })).readonly(),
18721
18926
  processes: array(TopologyProcessSchema).readonly(),
18722
- categories: array(TopologyCategorySchema).readonly()
18927
+ categories: array(TopologyCategorySchema).readonly(),
18928
+ rootPackage: TopologyRootPackageSchema.nullable()
18723
18929
  });
18724
18930
  var CapUsageEdgeSchema = object({
18725
18931
  callerAddonId: string(),
@@ -21519,6 +21725,12 @@ Object.freeze({
21519
21725
  addonId: null,
21520
21726
  access: "create"
21521
21727
  },
21728
+ "loginMethod.getLoginMethods": {
21729
+ capName: "login-method",
21730
+ capScope: "system",
21731
+ addonId: null,
21732
+ access: "view"
21733
+ },
21522
21734
  "mediaPlayer.next": {
21523
21735
  capName: "media-player",
21524
21736
  capScope: "device",
@@ -22881,6 +23093,36 @@ Object.freeze({
22881
23093
  addonId: null,
22882
23094
  access: "create"
22883
23095
  },
23096
+ "serverManagement.applyServerUpdate": {
23097
+ capName: "server-management",
23098
+ capScope: "system",
23099
+ addonId: null,
23100
+ access: "create"
23101
+ },
23102
+ "serverManagement.checkServerUpdate": {
23103
+ capName: "server-management",
23104
+ capScope: "system",
23105
+ addonId: null,
23106
+ access: "create"
23107
+ },
23108
+ "serverManagement.getServerPackageStatus": {
23109
+ capName: "server-management",
23110
+ capScope: "system",
23111
+ addonId: null,
23112
+ access: "view"
23113
+ },
23114
+ "serverManagement.restartServer": {
23115
+ capName: "server-management",
23116
+ capScope: "system",
23117
+ addonId: null,
23118
+ access: "create"
23119
+ },
23120
+ "serverManagement.rollbackServerUpdate": {
23121
+ capName: "server-management",
23122
+ capScope: "system",
23123
+ addonId: null,
23124
+ access: "create"
23125
+ },
22884
23126
  "settingsStore.count": {
22885
23127
  capName: "settings-store",
22886
23128
  capScope: "system",
@@ -23745,6 +23987,18 @@ Object.freeze({
23745
23987
  addonId: null,
23746
23988
  access: "view"
23747
23989
  },
23990
+ "viewerUi.getStaticDir": {
23991
+ capName: "viewer-ui",
23992
+ capScope: "system",
23993
+ addonId: null,
23994
+ access: "view"
23995
+ },
23996
+ "viewerUi.getVersion": {
23997
+ capName: "viewer-ui",
23998
+ capScope: "system",
23999
+ addonId: null,
24000
+ access: "view"
24001
+ },
23748
24002
  "waterHeater.setAway": {
23749
24003
  capName: "water-heater",
23750
24004
  capScope: "device",
@@ -26499,7 +26753,7 @@ var DetectionWiringController = class {
26499
26753
  * the motion stream id.
26500
26754
  *
26501
26755
  * Public — `PlacementService`'s `buildWatchdogCamera` closure (wired in
26502
- * `index.ts`) calls straight through to this method.
26756
+ * `orchestrator-bootstrap.ts`) calls straight through to this method.
26503
26757
  */
26504
26758
  buildWatchdogCamera(config, deviceName) {
26505
26759
  const continuousStages = /* @__PURE__ */ new Map();
@@ -26523,8 +26777,8 @@ var DetectionWiringController = class {
26523
26777
  * source refresh on ITS OWN stream so a dropped rfc4571 source
26524
26778
  * re-materializes and the runner's frame poller resumes.
26525
26779
  *
26526
- * Public — `PipelineWatchdog`'s `recover` closure (wired in `index.ts`)
26527
- * calls straight through to this method.
26780
+ * Public — `PipelineWatchdog`'s `recover` closure (wired in
26781
+ * `orchestrator-bootstrap.ts`) calls straight through to this method.
26528
26782
  */
26529
26783
  recoverPipelineStage(deviceId, stage, streamId) {
26530
26784
  if (stage === "audio") {
@@ -26958,7 +27212,7 @@ function selectRunnerFrameSource(input) {
26958
27212
  }
26959
27213
  //#endregion
26960
27214
  //#region src/placement-service.ts
26961
- /** Key under which the orchestrator stores its per-device manual pin — shared with `readPipelinePin`/`handleNodeDisconnect` in index.ts. */
27215
+ /** Key under which the orchestrator stores its per-device manual pin — shared with `readPipelinePin` (index.ts) and `handleNodeDisconnect` (`node-lifecycle-handler.ts`). */
26962
27216
  var PREFERRED_AGENT_SETTING = "preferredAgent";
26963
27217
  var PlacementService = class {
26964
27218
  deps;
@@ -28739,6 +28993,8 @@ var PipelineSettingsStore = class PipelineSettingsStore {
28739
28993
  dispose() {
28740
28994
  this.disposed = true;
28741
28995
  }
28996
+ blobWriteLock = new KeyedAsyncLock({ isShuttingDown: () => this.disposed });
28997
+ static AGENT_SETTINGS_LOCK_KEY = "agentSettings";
28742
28998
  _nodeBindingsState = null;
28743
28999
  _templatesState = null;
28744
29000
  _agentSettingsState = null;
@@ -28800,28 +29056,47 @@ var PipelineSettingsStore = class PipelineSettingsStore {
28800
29056
  async readAgentSettingsMap() {
28801
29057
  return { ...await this.agentSettingsState.get() };
28802
29058
  }
28803
- /** Overwrite one agent's settings. Does NOT touch other agents' entries. */
29059
+ /**
29060
+ * Overwrite one agent's settings. Does NOT touch other agents' entries.
29061
+ * The read-modify-write runs under {@link blobWriteLock}, so a concurrent
29062
+ * write for a DIFFERENT node can never be dropped (both re-read the fresh
29063
+ * blob when their turn comes and only overlay their own node's entry).
29064
+ */
28804
29065
  async writeAgentSettings(nodeId, settings) {
28805
29066
  if (typeof nodeId !== "string" || nodeId.length === 0 || nodeId === "undefined" || nodeId === "null") {
28806
29067
  this.deps.logger.warn("writeAgentSettings: refusing to persist malformed nodeId", { meta: { nodeId } });
28807
29068
  return;
28808
29069
  }
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);
29070
+ await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
29071
+ const all = await this.readAgentSettingsMap();
29072
+ const existing = all[nodeId];
29073
+ const merged = {
29074
+ ...existing,
29075
+ ...settings,
29076
+ maxCameras: settings.maxCameras !== void 0 ? settings.maxCameras ?? null : existing?.maxCameras ?? null
29077
+ };
29078
+ await this.agentSettingsState.set({
29079
+ ...all,
29080
+ [nodeId]: merged
29081
+ });
29082
+ });
28817
29083
  }
28818
- /** Drop one agent's persisted settings entry. Returns whether an entry existed. */
29084
+ /**
29085
+ * Drop one agent's persisted settings entry. Returns whether an entry
29086
+ * existed (`false` also when the store is already disposed — the locked
29087
+ * section becomes a no-op then). Serialized via {@link blobWriteLock} for
29088
+ * the same lost-write reason as {@link writeAgentSettings}.
29089
+ */
28819
29090
  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;
29091
+ let removed = false;
29092
+ await this.blobWriteLock.run(PipelineSettingsStore.AGENT_SETTINGS_LOCK_KEY, async () => {
29093
+ const all = await this.readAgentSettingsMap();
29094
+ if (!(nodeId in all)) return;
29095
+ const { [nodeId]: _drop, ...rest } = all;
29096
+ await this.agentSettingsState.set(rest);
29097
+ removed = true;
29098
+ });
29099
+ return removed;
28825
29100
  }
28826
29101
  /** Read the `cameraSettings` map (keyed on `deviceId` as string) via the durable handle. */
28827
29102
  async readCameraSettingsMap() {
@@ -29964,9 +30239,10 @@ var SessionDispatchController = class {
29964
30239
  this.sessionRegistry.setTeardownTimer(deviceId, timer);
29965
30240
  }
29966
30241
  /**
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).
30242
+ * The session + motion-watch teardown half of `stopDetection` (the other
30243
+ * half — `releaseCamera` + `audio.stopForDevice` — lives in
30244
+ * `DetectionWiringController.stopDetection` since S11 Task 3, which calls
30245
+ * this AFTER those run, same ordering as before).
29970
30246
  *
29971
30247
  * Stopping/disabling/removing an on-motion camera must also close any
29972
30248
  * ACTIVE detection session and release the motion-watch attach.
@@ -30431,7 +30707,6 @@ async function buildOrchestratorControllers(deps) {
30431
30707
  },
30432
30708
  listZones: async (deviceId) => await zonesProvider?.listZones({ deviceId }) ?? [],
30433
30709
  readPipelinePin: (deviceId) => deps.readPipelinePin(deviceId),
30434
- eventBus: deps.ctx().eventBus,
30435
30710
  logger: deps.ctx().logger
30436
30711
  });
30437
30712
  const deviceConfig = new DeviceConfigContributions({