@camstack/system 1.2.313 → 1.2.315

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 (111) hide show
  1. package/dist/addon-runner.js +1 -1
  2. package/dist/addon-runner.mjs +1 -1
  3. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/alerts/alerts.addon.js +1 -1
  8. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/dist/builtins/autotrack/index.js +1 -1
  10. package/dist/builtins/autotrack/index.mjs +1 -1
  11. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  12. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  13. package/dist/builtins/camera-grid/index.js +1 -1
  14. package/dist/builtins/camera-grid/index.mjs +1 -1
  15. package/dist/builtins/composer/claim-gate.d.ts +32 -0
  16. package/dist/builtins/composer/composed-device-set.d.ts +38 -0
  17. package/dist/builtins/composer/composed-device.d.ts +4 -3
  18. package/dist/builtins/composer/composer-grafts.d.ts +54 -0
  19. package/dist/builtins/composer/composer-plan.d.ts +96 -0
  20. package/dist/builtins/composer/composer-verdict.d.ts +19 -0
  21. package/dist/builtins/composer/composer.addon.js +2717 -477
  22. package/dist/builtins/composer/composer.addon.mjs +2722 -482
  23. package/dist/builtins/composer/composer.d.ts +71 -52
  24. package/dist/builtins/composer/composition-runtime.d.ts +93 -9
  25. package/dist/builtins/composer/confirmed-seed.d.ts +32 -0
  26. package/dist/builtins/composer/existing-target.d.ts +96 -0
  27. package/dist/builtins/composer/field-record.d.ts +50 -0
  28. package/dist/builtins/composer/graft-host.d.ts +47 -0
  29. package/dist/builtins/composer/held-claims.d.ts +12 -0
  30. package/dist/builtins/composer/owned-fields-target.d.ts +55 -0
  31. package/dist/builtins/composer/slice-assembler.d.ts +10 -0
  32. package/dist/builtins/composer/source-readings.d.ts +122 -0
  33. package/dist/builtins/composer/source-tracker.d.ts +35 -42
  34. package/dist/builtins/console-logging/index.js +1 -1
  35. package/dist/builtins/console-logging/index.mjs +1 -1
  36. package/dist/builtins/core-blocks/composition-api.d.ts +7 -4
  37. package/dist/builtins/core-blocks/composition-peers.d.ts +9 -0
  38. package/dist/builtins/core-blocks/composition-sources.d.ts +16 -3
  39. package/dist/builtins/core-blocks/core-block-store.d.ts +8 -1
  40. package/dist/builtins/core-blocks/core-blocks.addon.d.ts +4 -3
  41. package/dist/builtins/core-blocks/core-blocks.addon.js +255 -79
  42. package/dist/builtins/core-blocks/core-blocks.addon.mjs +255 -79
  43. package/dist/builtins/device-manager/claimed-status-overlay.d.ts +12 -0
  44. package/dist/builtins/device-manager/device-manager.addon.d.ts +16 -0
  45. package/dist/builtins/device-manager/device-manager.addon.js +1825 -317
  46. package/dist/builtins/device-manager/device-manager.addon.mjs +1825 -317
  47. package/dist/builtins/device-manager/device-provider-context.d.ts +24 -2
  48. package/dist/builtins/device-manager/device-row-store.d.ts +2 -0
  49. package/dist/builtins/device-manager/device-state-claim-views.d.ts +77 -0
  50. package/dist/builtins/device-manager/device-state-claims.d.ts +43 -0
  51. package/dist/builtins/device-manager/device-state-mirror.d.ts +145 -61
  52. package/dist/builtins/device-manager/field-claims-index.d.ts +69 -0
  53. package/dist/builtins/device-manager/field-ownership.d.ts +53 -0
  54. package/dist/builtins/device-manager/migrate-device.d.ts +27 -0
  55. package/dist/builtins/device-manager/migrate-guard.d.ts +7 -0
  56. package/dist/builtins/device-manager/migrate-hardware-state.d.ts +55 -0
  57. package/dist/builtins/device-manager/migration-refused.d.ts +23 -0
  58. package/dist/builtins/device-manager/mirror-row-writer.d.ts +138 -0
  59. package/dist/builtins/device-manager/runtime-state-persist-gate.d.ts +4 -0
  60. package/dist/builtins/doorbell/binding-mirror.d.ts +1 -0
  61. package/dist/builtins/doorbell/doorbell-composition-migration.d.ts +59 -0
  62. package/dist/builtins/doorbell/virtual-doorbell.addon.d.ts +3 -0
  63. package/dist/builtins/doorbell/virtual-doorbell.addon.js +315 -10
  64. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +315 -10
  65. package/dist/builtins/hub-forwarder/index.js +1 -1
  66. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  67. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  68. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  69. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  70. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  71. package/dist/builtins/local-network/local-network.addon.js +1 -1
  72. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  73. package/dist/builtins/loki-logging/index.js +1 -1
  74. package/dist/builtins/loki-logging/index.mjs +1 -1
  75. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  76. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  77. package/dist/builtins/platform-probe/index.js +1 -1
  78. package/dist/builtins/platform-probe/index.mjs +1 -1
  79. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  80. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  81. package/dist/builtins/snapshot/index.js +1 -1
  82. package/dist/builtins/snapshot/index.mjs +1 -1
  83. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  84. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  85. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  86. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  87. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  88. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  89. package/dist/builtins/system-config/system-config.addon.js +1 -1
  90. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  91. package/dist/builtins/winston-logging/index.js +1 -1
  92. package/dist/builtins/winston-logging/index.mjs +1 -1
  93. package/dist/{child-cap-dispatch-CHTiHbsv.mjs → child-cap-dispatch-AAltfBUH.mjs} +1484 -1417
  94. package/dist/{child-cap-dispatch-Dyn_7ezH.js → child-cap-dispatch-DzcUd_ct.js} +1503 -1424
  95. package/dist/composition-sources-DYqQLRzF.js +122 -0
  96. package/dist/composition-sources-yonsRneP.mjs +111 -0
  97. package/dist/{dist-CkRwnhbo.js → dist-DVKv5i-e.js} +5396 -4331
  98. package/dist/{dist-Cj7pJmXq.mjs → dist-MzYJVCLE.mjs} +5330 -4331
  99. package/dist/index.js +137 -8
  100. package/dist/index.mjs +133 -8
  101. package/dist/kernel/capability-registry.d.ts +43 -1
  102. package/dist/kernel/index.d.ts +3 -1
  103. package/dist/kernel/moleculer/device-cap-proxy.d.ts +0 -10
  104. package/dist/kernel/status-overlay.d.ts +18 -0
  105. package/dist/kernel/transport/claimed-get-status.d.ts +15 -0
  106. package/dist/kernel/transport/index.d.ts +2 -0
  107. package/dist/kernel/transport/local-child-registry.d.ts +23 -0
  108. package/dist/kernel/transport/parent-unowned-call.d.ts +25 -0
  109. package/dist/{retired-settings-keys-C1duPikd.mjs → retired-settings-keys-8yY2sTc-.mjs} +1 -1
  110. package/dist/{retired-settings-keys-CGSuXhP8.js → retired-settings-keys-iY5I0nKM.js} +1 -1
  111. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_child_cap_dispatch = require("./child-cap-dispatch-Dyn_7ezH.js");
2
+ const require_child_cap_dispatch = require("./child-cap-dispatch-DzcUd_ct.js");
3
3
  const require_custom_action_registry = require("./custom-action-registry-acBY3mHA.js");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_chunk.__toESM(node_path);
@@ -1,4 +1,4 @@
1
- import { H as createUdsLoggerWithControl, Mt as installManifestNativeDeps, Nt as resolveAddonClass, Sn as emitHeapDiagnosticReport, Y as LocalChildClient, Zt as RUNNER_RSS_BUDGET_ENV, _t as setWorkerNativeCapsChangeListener, f as installManifestSystemDeps, g as createUdsAddonContext, ht as getWorkerNativeCapSnapshot, i as killOwnRunnerGroupAfterParentLoss, mt as getWorkerNativeCapProvider, n as createChildCapDispatch, p as installManifestPythonDeps, u as startRunnerParentDeathWatchdog, un as startRunnerHeapWatch, yt as validateProviderRegistrations } from "./child-cap-dispatch-CHTiHbsv.mjs";
1
+ import { $t as RUNNER_RSS_BUDGET_ENV, Ft as resolveAddonClass, H as createUdsLoggerWithControl, Pt as installManifestNativeDeps, U as LocalChildClient, _t as getWorkerNativeCapSnapshot, f as installManifestSystemDeps, fn as startRunnerHeapWatch, g as createUdsAddonContext, gt as getWorkerNativeCapProvider, i as killOwnRunnerGroupAfterParentLoss, n as createChildCapDispatch, p as installManifestPythonDeps, u as startRunnerParentDeathWatchdog, wn as emitHeapDiagnosticReport, xt as validateProviderRegistrations, yt as setWorkerNativeCapsChangeListener } from "./child-cap-dispatch-AAltfBUH.mjs";
2
2
  import { t as CustomActionRegistry } from "./custom-action-registry-B4Cf4O_X.mjs";
3
3
  import { register } from "node:module";
4
4
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CkRwnhbo.js");
6
+ const require_dist = require("../../dist-DVKv5i-e.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { R as addonPagesCapability, ir as EventCategory, jn as BaseAddon, kn as errMsg } from "../../dist-Cj7pJmXq.mjs";
1
+ import { Gn as BaseAddon, R as addonPagesCapability, Wn as errMsg, hr as EventCategory } from "../../dist-MzYJVCLE.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CkRwnhbo.js");
6
+ const require_dist = require("../../dist-DVKv5i-e.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { B as addonWidgetsCapability, ir as EventCategory, jn as BaseAddon, kn as errMsg } from "../../dist-Cj7pJmXq.mjs";
1
+ import { B as addonWidgetsCapability, Gn as BaseAddon, Wn as errMsg, hr as EventCategory } from "../../dist-MzYJVCLE.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CkRwnhbo.js");
6
+ const require_dist = require("../../dist-DVKv5i-e.js");
7
7
  //#region src/builtins/alerts/prune-policy.ts
8
8
  /**
9
9
  * Ids older than `cutoffMs`, oldest first.
@@ -1,4 +1,4 @@
1
- import { V as alertsCapability, Wn as createEvent, ir as EventCategory, jn as BaseAddon, kn as errMsg, n as AlertSchema } from "../../dist-Cj7pJmXq.mjs";
1
+ import { Gn as BaseAddon, V as alertsCapability, Wn as errMsg, hr as EventCategory, n as AlertSchema, tr as createEvent } from "../../dist-MzYJVCLE.mjs";
2
2
  //#region src/builtins/alerts/prune-policy.ts
3
3
  /**
4
4
  * Ids older than `cutoffMs`, oldest first.
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CkRwnhbo.js");
6
+ const require_dist = require("../../dist-DVKv5i-e.js");
7
7
  //#region src/builtins/autotrack/autotrack-config.ts
8
8
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
9
9
  deadZoneFraction: .5,
@@ -1,4 +1,4 @@
1
- import { W as bareAddonId, Xn as isEvent, in as ptzAutotrackCapability, ir as EventCategory, jn as BaseAddon, kn as errMsg, v as FIRST_LEVEL_MACRO_CLASSES } from "../../dist-Cj7pJmXq.mjs";
1
+ import { $t as ptzAutotrackCapability, Gn as BaseAddon, W as bareAddonId, Wn as errMsg, _ as FIRST_LEVEL_MACRO_CLASSES, hr as EventCategory, sr as isEvent } from "../../dist-MzYJVCLE.mjs";
2
2
  //#region src/builtins/autotrack/autotrack-config.ts
3
3
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
4
4
  deadZoneFraction: .5,
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CkRwnhbo.js");
6
+ const require_dist = require("../../dist-DVKv5i-e.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let buffer = require("buffer");
9
9
  let node_fs_promises = require("node:fs/promises");
@@ -1,4 +1,4 @@
1
- import { U as backupCapability, ir as EventCategory, jn as BaseAddon, qt as mayWriteToLocation, vn as storageOccupancyCapability } from "../../dist-Cj7pJmXq.mjs";
1
+ import { Gn as BaseAddon, Ht as mayWriteToLocation, U as backupCapability, hr as EventCategory, mn as storageOccupancyCapability } from "../../dist-MzYJVCLE.mjs";
2
2
  import { randomBytes, randomUUID } from "node:crypto";
3
3
  import { Buffer as Buffer$1 } from "buffer";
4
4
  import * as fsp from "node:fs/promises";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-CkRwnhbo.js");
6
+ const require_dist = require("../../dist-DVKv5i-e.js");
7
7
  let zod = require("zod");
8
8
  let _camstack_types_node = require("@camstack/types/node");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { An as buildFfmpegArgs, Fn as DeviceFeature, J as cameraGridLayoutCapability, Jn as hydrateSchema, Ln as DeviceType, Wn as createEvent, Xt as motionCapability, bn as streamCatalogCapability, g as DeclaredDevices, h as DERIVED_CAMERA_SILENCED_CAP_NAMES, hn as snapshotCapability, i as BaseDevice, ir as EventCategory, jn as BaseAddon, kn as errMsg, lt as declarationOwnerNodeId, w as MOTION_CLOSE_AFTER_MS } from "../../dist-Cj7pJmXq.mjs";
1
+ import { Gn as BaseAddon, Gt as motionCapability, J as cameraGridLayoutCapability, T as MOTION_CLOSE_AFTER_MS, Un as DeviceType, Vn as DeviceFeature, Wn as errMsg, ar as hydrateSchema, dn as snapshotCapability, gn as streamCatalogCapability, h as DeclaredDevices, hr as EventCategory, i as BaseDevice, kn as buildFfmpegArgs, m as DERIVED_CAMERA_SILENCED_CAP_NAMES, ot as declarationOwnerNodeId, tr as createEvent } from "../../dist-MzYJVCLE.mjs";
2
2
  import { z } from "zod";
3
3
  import { FfmpegProcess } from "@camstack/types/node";
4
4
  import { join } from "node:path";
@@ -0,0 +1,32 @@
1
+ import { FieldClaim, IScopedLogger } from '@camstack/types';
2
+ export interface ClaimKey {
3
+ readonly deviceId: number;
4
+ readonly capName: string;
5
+ readonly owner: string;
6
+ }
7
+ export declare function claimKey(k: ClaimKey): string;
8
+ export declare class ClaimGate {
9
+ private readonly logger;
10
+ private known;
11
+ constructor(logger: IScopedLogger);
12
+ /**
13
+ * The claims the hub holds before this process applied anything. Called once
14
+ * at boot, before the first `filter`. A claim the gate already knows keeps its
15
+ * entry and its miss count.
16
+ */
17
+ seed(claims: readonly FieldClaim[]): void;
18
+ /** Every claim known under one owner — what a block whose plan is held keeps (D659 placeholder rule). */
19
+ claimsOf(owner: string): readonly ClaimKey[];
20
+ /**
21
+ * Learn `wanted` and answer the claims to release NOW: those absent from
22
+ * `wanted` on two consecutive calls, plus those whose earlier release the hub
23
+ * has not confirmed yet. A claim wanted again starts from zero misses.
24
+ */
25
+ filter(wanted: readonly ClaimKey[]): readonly ClaimKey[];
26
+ /** The hub confirmed the release (or held nothing of ours): forgotten. */
27
+ released(key: ClaimKey, how: string): void;
28
+ /** The release did not land: kept, and returned by every later `filter` until it does. Never given up. */
29
+ releaseFailed(key: ClaimKey, error: string): void;
30
+ private tagsOf;
31
+ private metaOf;
32
+ }
@@ -0,0 +1,38 @@
1
+ import { DeviceDeclaration, IScopedLogger } from '@camstack/types';
2
+ import { ComposedDeviceHandle } from './composed-device.js';
3
+ import { ComposerDerivedSpec, PlannedBlock } from './composer-plan.js';
4
+ import { PersistedComposedRow } from './composition-declarations.js';
5
+ export interface ComposerDevicePorts {
6
+ setName(deviceId: number, name: string): Promise<void>;
7
+ decommission(deviceId: number): Promise<void>;
8
+ applyDerivedSpec(deviceId: number, derived: ComposerDerivedSpec): Promise<void>;
9
+ }
10
+ export interface ComposerDeclareResult {
11
+ /** Live composed devices by stableId. */
12
+ readonly devices: ReadonlyMap<string, ComposedDeviceHandle>;
13
+ }
14
+ export type ComposerDeclare = (integrationId: string, devices: readonly DeviceDeclaration[]) => Promise<ComposerDeclareResult>;
15
+ export interface ComposedDeviceSetDeps {
16
+ readonly logger: IScopedLogger;
17
+ readonly declare: ComposerDeclare;
18
+ readonly devices: ComposerDevicePorts;
19
+ }
20
+ /** What `rebuildShapes` needs of a block's previous apply: its live device and the shape it was built for. */
21
+ export interface PreviousShape {
22
+ readonly device: ComposedDeviceHandle | null;
23
+ readonly shape: string | null;
24
+ }
25
+ export declare class ComposedDeviceSet {
26
+ private readonly deps;
27
+ private devices;
28
+ private existingRows;
29
+ private declaredFingerprint;
30
+ constructor(deps: ComposedDeviceSetDeps);
31
+ /** StableIds whose row exists. */
32
+ get rows(): ReadonlySet<string>;
33
+ seedRows(rows: readonly PersistedComposedRow[]): void;
34
+ get(stableId: string): ComposedDeviceHandle | null;
35
+ idOf(stableId: string): number | null;
36
+ rebuildShapes(planned: readonly PlannedBlock[], previousOf: (blockId: string) => PreviousShape | undefined): Promise<ReadonlyMap<string, string>>;
37
+ reconcile(integrationId: string, declarations: readonly DeviceDeclaration[], planned: readonly PlannedBlock[]): Promise<void>;
38
+ }
@@ -1,6 +1,7 @@
1
- import { BaseDevice, CapabilityDefinition, DeviceConstructor, DeviceContext, DeviceFeature, DeviceType, ExpressionValue, IDevice } from '@camstack/types';
1
+ import { BaseDevice, CapabilityDefinition, DeviceConstructor, DeviceContext, DeviceFeature, DeviceType, IDevice } from '@camstack/types';
2
2
  import { z } from 'zod';
3
3
  import { ComposedWriteTarget, WriteOutcome } from './composition-runtime.js';
4
+ import { SlicePatch } from './slice-assembler.js';
4
5
  declare const COMPOSED_DEVICE_CONFIG_SCHEMA: z.ZodObject<{}, z.core.$strip>;
5
6
  export interface ComposedDeviceHandle extends ComposedWriteTarget {
6
7
  readonly name: string;
@@ -8,8 +9,8 @@ export interface ComposedDeviceHandle extends ComposedWriteTarget {
8
9
  export declare class ComposedDevice extends BaseDevice<typeof COMPOSED_DEVICE_CONFIG_SCHEMA> implements ComposedDeviceHandle {
9
10
  readonly features: readonly DeviceFeature[];
10
11
  constructor(ctx: DeviceContext, type: DeviceType, caps: readonly CapabilityDefinition[]);
11
- seed(capName: string, slice: Readonly<Record<string, ExpressionValue>>): WriteOutcome;
12
- patch(capName: string, patch: Readonly<Record<string, ExpressionValue>>): WriteOutcome;
12
+ seed(capName: string, slice: SlicePatch): WriteOutcome;
13
+ patch(capName: string, patch: SlicePatch): WriteOutcome;
13
14
  setAvailable(available: boolean): void;
14
15
  }
15
16
  export declare function composedDeviceClass(type: DeviceType, caps: readonly CapabilityDefinition[]): DeviceConstructor<ComposedDevice>;
@@ -0,0 +1,54 @@
1
+ import { CompositionFeaturePlan, CompositionSourceRef, IScopedLogger } from '@camstack/types';
2
+ import { ComposerGraftPorts, DescribeTarget } from './existing-target.js';
3
+ /** A foreign native now serves the grafted cap: the claim stays (Task 10 rule 2). */
4
+ export declare const NATIVE_APPEARED_UNGRAFT_REASON = "a native provider appeared";
5
+ /** The block's add claim was released by the D49 gate (deleted, disabled, feature removed): its graft goes with it. */
6
+ export declare const NO_LONGER_ADDED_UNGRAFT_REASON = "the block no longer adds this cap";
7
+ /** A binding a previous composer process left, that nothing wants any more (I-3). */
8
+ export declare const STALE_GRAFT_RETRACT_REASON = "a graft left by a previous composer process that no plan wants";
9
+ /** The `device.bindings-changed` facts the graft decisions read. */
10
+ export interface BindingsChangeFacts {
11
+ readonly deviceId: number;
12
+ readonly capName: string;
13
+ readonly reason: string;
14
+ readonly addonId: string;
15
+ }
16
+ export interface GraftPlanInput {
17
+ readonly deviceId: number;
18
+ readonly ref: CompositionSourceRef;
19
+ readonly features: readonly CompositionFeaturePlan[];
20
+ /** The description the plan used: cap → the addon serving it (`getBindings`). */
21
+ readonly nativeCaps: ReadonlyMap<string, string>;
22
+ readonly enabled: boolean;
23
+ /** Planned without problems; a block whose plan failed holds what it has (rule 4). */
24
+ readonly settled: boolean;
25
+ }
26
+ /** What a block's added caps say about its verdict: null when every one is served. */
27
+ export interface GraftVerdict {
28
+ /** Nothing the block adds can be served. */
29
+ readonly allUnserved: boolean;
30
+ readonly reason: string;
31
+ }
32
+ export declare class ComposerGrafts {
33
+ private readonly ports;
34
+ private readonly logger;
35
+ private readonly readBindings;
36
+ /** Per device: the added caps no graft serves, and why. Reset by each plan of that device. */
37
+ private unserved;
38
+ /** Per DESCRIBED device: foreign natives registered since its description was read (cap → addonId). */
39
+ private foreignSince;
40
+ constructor(ports: ComposerGraftPorts | undefined, logger: IScopedLogger, readBindings: DescribeTarget);
41
+ /** A description of `deviceId` is about to be read: it covers every registration before now. */
42
+ describing(deviceId: number): void;
43
+ onBindingsChanged(data: BindingsChangeFacts): void;
44
+ /** Rule 2, at plan time only: graft what the plan adds; ungraft what it finds native; retract what a previous process left. */
45
+ plan(input: GraftPlanInput): void;
46
+ /** The gate released a claim: a graft of that cap goes with it; a previous process's binding is retracted once read as the composer's. */
47
+ released(deviceId: number, capName: string): Promise<void>;
48
+ /** The target row is gone: nothing about it is reported any more. */
49
+ gone(deviceId: number): void;
50
+ verdict(deviceId: number, features: readonly CompositionFeaturePlan[]): GraftVerdict | null;
51
+ private retractUnwanted;
52
+ private remember;
53
+ private setUnserved;
54
+ }
@@ -0,0 +1,96 @@
1
+ import { CapabilityLookup, ComposerBlock, ComposerUnreadableBlock, CompositionExistingTarget, CompositionEventPlan, CompositionFeaturePlan, CompositionFieldPlan, CompositionNewTarget, CompositionSourceRef, DeviceDeclaration, DeviceType, IScopedLogger, LogTags } from '@camstack/types';
2
+ import { TargetDescriptions } from './existing-target.js';
3
+ import { SourceResolution } from './source-tracker.js';
4
+ /** What the apply knows of a block besides its plan. `name` is null for an unreadable row whose name is unreadable too. */
5
+ export interface PlannedBlockMeta {
6
+ readonly id: string;
7
+ readonly name: string | null;
8
+ readonly enabled: boolean;
9
+ readonly updatedAt: number;
10
+ }
11
+ export interface ComposerDerivedSpec {
12
+ readonly type: DeviceType;
13
+ readonly role?: string;
14
+ }
15
+ export interface PlannedNewTarget {
16
+ readonly kind: 'new';
17
+ }
18
+ /** A row that does not parse names no target: its claims, if any, are held (D49). */
19
+ export interface PlannedUnreadableTarget {
20
+ readonly kind: 'unreadable';
21
+ }
22
+ export interface PlannedExistingTarget {
23
+ readonly kind: 'existing';
24
+ readonly ref: CompositionSourceRef;
25
+ /** The target row's id once resolved; null until then. */
26
+ readonly deviceId: number | null;
27
+ /** Why the block is `starting` rather than planned: claims unseeded, target unresolved or undescribed. Nothing is claimed. */
28
+ readonly waiting: string | null;
29
+ /** The target row is gone — two index reads agreed (rule 5). Sticky until an operator edit or restart. */
30
+ readonly gone: string | null;
31
+ readonly features: readonly CompositionFeaturePlan[];
32
+ /** The description the plan used: cap → the addon serving it; empty until described. */
33
+ readonly nativeCaps: ReadonlyMap<string, string>;
34
+ }
35
+ export type PlannedTarget = PlannedNewTarget | PlannedUnreadableTarget | PlannedExistingTarget;
36
+ export interface PlannedBlock {
37
+ readonly block: PlannedBlockMeta;
38
+ readonly fields: readonly CompositionFieldPlan[];
39
+ readonly events: readonly CompositionEventPlan[];
40
+ readonly problems: readonly string[];
41
+ readonly declaration: DeviceDeclaration | null;
42
+ /** What forces a rebuild of the live device; null when nothing is declared. */
43
+ readonly shape: string | null;
44
+ readonly spec: ComposerDerivedSpec | null;
45
+ readonly target: PlannedTarget;
46
+ }
47
+ /**
48
+ * A row that exists but does not parse is held exactly like a composition
49
+ * that stopped planning: its device (if it has a row) stays as an offline
50
+ * placeholder, its claims (if any) are kept, and the block fails naming the
51
+ * parse error. Absent, it would be withdrawn on the second apply that omitted
52
+ * it (D49).
53
+ */
54
+ export declare function planUnreadable(block: ComposerUnreadableBlock, rows: ReadonlySet<string>): PlannedBlock;
55
+ /** `target` is the block's own `new` target, narrowed by the caller: this path never sees an existing one (M-5). */
56
+ export declare function planNew(block: ComposerBlock, target: CompositionNewTarget, lookupCap: CapabilityLookup, rows: ReadonlySet<string>): PlannedBlock;
57
+ /** The tracker's resolution path, as `planExisting` needs it (rule 1). */
58
+ export interface TargetResolver {
59
+ resolve(ref: CompositionSourceRef, reset: boolean): Promise<SourceResolution>;
60
+ }
61
+ export interface ExistingPlanInput {
62
+ readonly block: ComposerBlock;
63
+ readonly target: CompositionExistingTarget;
64
+ /** The block's previous plan, if it is live. */
65
+ readonly previous: PlannedBlock | undefined;
66
+ /** An edit, a restart, or the block's first appearance: the only things that re-plan a settled block. */
67
+ readonly operatorAction: boolean;
68
+ /** Why the claims index is not seeded yet, else null. */
69
+ readonly claimsWait: string | null;
70
+ readonly tracker: TargetResolver;
71
+ readonly targets: TargetDescriptions;
72
+ readonly lookupCap: CapabilityLookup;
73
+ }
74
+ export declare function planExisting(input: ExistingPlanInput): Promise<PlannedBlock>;
75
+ /**
76
+ * Runtime preparation can still fail after a complete existing-target plan.
77
+ * Preserve its fields and description for retry, but mark it waiting so claim
78
+ * reconciliation cannot treat the unprepared candidate as live.
79
+ */
80
+ export declare function withExistingTargetWait(p: PlannedBlock, waiting: string): PlannedBlock;
81
+ /** A target the previous plan held live on `deviceId`, that this plan finds gone. */
82
+ export interface LostTarget {
83
+ readonly target: PlannedExistingTarget;
84
+ readonly deviceId: number;
85
+ }
86
+ /**
87
+ * Rule 5 on the PLAN path: `device.unregistered` is telemetry and may be
88
+ * dropped (D8), so a target is often found gone by the operator's next edit or
89
+ * restart. The previous live target is what must be ungrafted — exactly as on
90
+ * the event path. Null when nothing was lost by THIS plan.
91
+ */
92
+ export declare function lostTarget(p: PlannedBlock, previous: PlannedBlock | undefined): LostTarget | null;
93
+ /** Two plans write the same place: both new, or the very same existing-target plan (reused until the operator acts). */
94
+ export declare function sameTarget(a: PlannedTarget, b: PlannedTarget): boolean;
95
+ /** One line when a block starts or stops planning (or waiting, or loses its target) — never one per apply. */
96
+ export declare function logPlanTransition(logger: IScopedLogger, previous: PlannedBlock | undefined, p: PlannedBlock, liveTags: LogTags): void;
@@ -0,0 +1,19 @@
1
+ import { ComposerBlockVerdict, CompositionFieldState } from '@camstack/types';
2
+ import { ComposedDeviceHandle } from './composed-device.js';
3
+ import { PlannedBlock } from './composer-plan.js';
4
+ import { CompositionRuntime } from './composition-runtime.js';
5
+ import { GraftVerdict } from './composer-grafts.js';
6
+ /** A runtime built by an apply, before the apply's sync decides whether it may start. */
7
+ export declare const NOT_STARTED = "the runtime has not started yet";
8
+ export interface LiveComposition {
9
+ readonly planned: PlannedBlock;
10
+ /** The composed device of a `new` target; null for an existing one. */
11
+ readonly device: ComposedDeviceHandle | null;
12
+ readonly runtime: CompositionRuntime | null;
13
+ readonly appliedName: string | null;
14
+ /** Why the device could not be rebuilt for a new shape; the previous one is kept. */
15
+ readonly rebuildError: string | null;
16
+ /** Rule 4: the last values of a customization that stopped planning, reported stale. */
17
+ readonly heldFields: readonly CompositionFieldState[];
18
+ }
19
+ export declare function verdictOf(blockId: string, entry: LiveComposition | undefined, unsynced: boolean, grafts?: GraftVerdict | null): ComposerBlockVerdict;