@camstack/system 1.2.316 → 1.2.318

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 (87) hide show
  1. package/dist/addon-runner.js +1 -1
  2. package/dist/addon-runner.mjs +1 -1
  3. package/dist/auth/auth-manager.d.ts +11 -0
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  5. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  7. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  8. package/dist/builtins/alerts/alerts.addon.js +1 -1
  9. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  10. package/dist/builtins/autotrack/index.js +1 -1
  11. package/dist/builtins/autotrack/index.mjs +1 -1
  12. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  13. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  14. package/dist/builtins/camera-grid/index.js +1 -1
  15. package/dist/builtins/camera-grid/index.mjs +1 -1
  16. package/dist/builtins/composer/composer.addon.js +347 -181
  17. package/dist/builtins/composer/composer.addon.mjs +347 -181
  18. package/dist/builtins/composer/composition-evaluation.d.ts +37 -0
  19. package/dist/builtins/composer/composition-runtime.d.ts +11 -52
  20. package/dist/builtins/composer/composition-target.d.ts +50 -0
  21. package/dist/builtins/composer/existing-target.d.ts +19 -1
  22. package/dist/builtins/composer/own-field-reads.d.ts +19 -0
  23. package/dist/builtins/console-logging/index.js +1 -1
  24. package/dist/builtins/console-logging/index.mjs +1 -1
  25. package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  26. package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  27. package/dist/builtins/device-manager/device-manager.addon.js +265 -29
  28. package/dist/builtins/device-manager/device-manager.addon.mjs +265 -29
  29. package/dist/builtins/device-manager/device-provider-context.d.ts +6 -0
  30. package/dist/builtins/device-manager/device-source-activation.d.ts +26 -1
  31. package/dist/builtins/device-manager/device-state-mirror.d.ts +41 -9
  32. package/dist/builtins/device-manager/mirror-row-writer.d.ts +59 -1
  33. package/dist/builtins/doorbell/binding-mirror.d.ts +45 -81
  34. package/dist/builtins/doorbell/doorbell-extension-slot.d.ts +4 -3
  35. package/dist/builtins/doorbell/virtual-doorbell.addon.d.ts +53 -11
  36. package/dist/builtins/doorbell/virtual-doorbell.addon.js +207 -82
  37. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +207 -82
  38. package/dist/builtins/hub-forwarder/index.js +1 -1
  39. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  40. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  41. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  42. package/dist/builtins/local-auth/local-auth.addon.js +47 -3
  43. package/dist/builtins/local-auth/local-auth.addon.mjs +46 -4
  44. package/dist/builtins/local-network/local-network.addon.js +1 -1
  45. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  46. package/dist/builtins/loki-logging/index.js +1 -1
  47. package/dist/builtins/loki-logging/index.mjs +1 -1
  48. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  49. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  50. package/dist/builtins/platform-probe/index.js +1 -1
  51. package/dist/builtins/platform-probe/index.mjs +1 -1
  52. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  53. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  54. package/dist/builtins/snapshot/index.js +1 -1
  55. package/dist/builtins/snapshot/index.mjs +1 -1
  56. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  57. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  58. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  59. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  60. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  61. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  62. package/dist/builtins/system-config/system-config.addon.js +4 -4
  63. package/dist/builtins/system-config/system-config.addon.mjs +4 -4
  64. package/dist/builtins/winston-logging/index.js +1 -1
  65. package/dist/builtins/winston-logging/index.mjs +1 -1
  66. package/dist/{child-cap-dispatch-AAltfBUH.mjs → child-cap-dispatch-C2VINHu1.mjs} +70 -18
  67. package/dist/{child-cap-dispatch-DzcUd_ct.js → child-cap-dispatch-C8uts1P4.js} +70 -18
  68. package/dist/{composition-sources-BwE1POnF.js → composition-sources-BjRPhWtU.js} +1 -1
  69. package/dist/{composition-sources-fUyF4z39.mjs → composition-sources-Cg2MP-qf.mjs} +1 -1
  70. package/dist/{dist-BPvku43i.mjs → dist-CQ9vXSUh.mjs} +220 -8
  71. package/dist/{dist-RAl10EfG.js → dist-Dcy0gVHu.js} +220 -8
  72. package/dist/index.js +739 -350
  73. package/dist/index.mjs +737 -352
  74. package/dist/kernel/bootstrap-config.d.ts +8 -0
  75. package/dist/kernel/capability-registry.d.ts +30 -0
  76. package/dist/kernel/config-manager.d.ts +75 -129
  77. package/dist/kernel/index.d.ts +5 -2
  78. package/dist/kernel/moleculer/runtime-state-load.d.ts +19 -0
  79. package/dist/kernel/settings-door-view.d.ts +24 -1
  80. package/dist/kernel/settings-read-error.d.ts +37 -0
  81. package/dist/kernel/settings-view-types.d.ts +105 -0
  82. package/dist/kernel/store-settings-view.d.ts +17 -0
  83. package/dist/kernel/system-settings-mirror.d.ts +34 -0
  84. package/dist/kernel/system-settings-policy.d.ts +47 -0
  85. package/dist/{retired-settings-keys-DqVWSrVw.mjs → retired-settings-keys-DNIbyfTR.mjs} +1 -1
  86. package/dist/{retired-settings-keys-D3rGTGq5.js → retired-settings-keys-pzlrLUbA.js} +1 -1
  87. package/package.json +1 -1
@@ -1,55 +1,8 @@
1
- import { CapabilityLookup, ClaimOutcome, CompositionEventPlan, CompositionFieldPlan, CompositionFieldState, IScopedLogger, SourceReader, SystemEvent } from '@camstack/types';
2
- import { SlicePatch } from './slice-assembler.js';
1
+ import { CapabilityLookup, CompositionEventPlan, CompositionFieldPlan, CompositionFieldRead, CompositionFieldState, IScopedLogger, SourceReader } from '@camstack/types';
2
+ import { ComposedWriteTarget, CompositionEventEmitter, DeadlineTimer } from './composition-target.js';
3
3
  import { ReleasedField } from './field-record.js';
4
4
  export type { ReleasedField } from './field-record.js';
5
- export interface WriteOk {
6
- readonly ok: true;
7
- }
8
- export interface WriteRefused {
9
- readonly ok: false;
10
- readonly error: string;
11
- }
12
- export type WriteOutcome = WriteOk | WriteRefused;
13
- /** Why an enqueued write did not land. `refused` carries the hub's code so the target can escalate by name (S5). */
14
- export type TargetAsyncFailure = {
15
- readonly kind: 'threw';
16
- readonly error: string;
17
- } | {
18
- readonly kind: 'refused';
19
- readonly code: Extract<ClaimOutcome, {
20
- ok: false;
21
- }>['code'];
22
- readonly message: string;
23
- };
24
- /**
25
- * Where a composition writes. A write answers `{ ok: false }` rather than
26
- * throwing, and `setAvailable` does not throw. The runtime survives either
27
- * anyway: a throwing write is a failed write, a throwing `setAvailable` is
28
- * retried on the next pass. A target whose writes are asynchronous reports
29
- * what did not land through `onAsyncFailure`.
30
- */
31
- export interface ComposedWriteTarget {
32
- readonly id: number;
33
- seed(capName: string, slice: SlicePatch): WriteOutcome;
34
- patch(capName: string, patch: SlicePatch): WriteOutcome;
35
- setAvailable(available: boolean): void;
36
- onAsyncFailure?(listener: (cap: string, failure: TargetAsyncFailure) => void): void;
37
- /**
38
- * S1b: these fields of `cap` are NOT the composition's to write right now
39
- * (their `release`-mode source is unavailable). The claim is narrowed to the
40
- * rest; an empty rest releases the whole cap. `[]` re-widens. Absent on a
41
- * `new`-target device (`ComposedDevice`): `release` is planned only on
42
- * existing targets.
43
- */
44
- withhold?(cap: string, fields: readonly string[]): WriteOutcome;
45
- }
46
- export interface DeadlineTimer {
47
- arm(at: number, fire: () => void): void;
48
- disarm(): void;
49
- }
50
- export interface CompositionEventEmitter {
51
- emit(event: SystemEvent): void;
52
- }
5
+ export type { ComposedWriteTarget, CompositionEventEmitter, DeadlineTimer, TargetAsyncFailure, WriteOk, WriteOutcome, WriteRefused, } from './composition-target.js';
53
6
  export interface CompositionRuntimeDeps {
54
7
  readonly blockId: string;
55
8
  readonly fields: readonly CompositionFieldPlan[];
@@ -60,6 +13,12 @@ export interface CompositionRuntimeDeps {
60
13
  /** Effective target slices captured before an existing-target runtime takes ownership. */
61
14
  readonly initialByCap?: ReadonlyMap<string, Readonly<Record<string, unknown>> | null>;
62
15
  readonly read: SourceReader;
16
+ /**
17
+ * Whether `read` is of this composition's OWN output (an added cap on its
18
+ * existing target, or its composed device): answered from the runtime's
19
+ * record, never from `read`. Absent = none is.
20
+ */
21
+ readonly isOwnRead?: (read: CompositionFieldRead) => boolean;
63
22
  readonly now: () => number;
64
23
  readonly timer: DeadlineTimer;
65
24
  readonly logger: IScopedLogger;
@@ -95,6 +54,8 @@ export declare class CompositionRuntime {
95
54
  private releaseFlaps;
96
55
  /** Caps the target refused for good (`TERMINAL_REFUSALS`): never written again by this runtime. */
97
56
  private terminal;
57
+ /** What `composition-evaluation.ts` reads and commits through. */
58
+ private readonly evaluation;
98
59
  constructor(deps: CompositionRuntimeDeps);
99
60
  start(): void;
100
61
  onSourcesChanged(sliceKeys: ReadonlySet<string>): void;
@@ -124,8 +85,6 @@ export declare class CompositionRuntime {
124
85
  /** Once per distinct failure, not once per pass: a reader that keeps throwing logs one line. */
125
86
  private logPassError;
126
87
  private pass;
127
- private evaluate;
128
- private emitStateEvent;
129
88
  private recordsOf;
130
89
  /** `retry`: write-pending caps this pass re-writes WHOLE, whether or not a value changed. */
131
90
  private writeCaps;
@@ -0,0 +1,50 @@
1
+ import { ClaimOutcome, SystemEvent } from '@camstack/types';
2
+ import { SlicePatch } from './slice-assembler.js';
3
+ export interface WriteOk {
4
+ readonly ok: true;
5
+ }
6
+ export interface WriteRefused {
7
+ readonly ok: false;
8
+ readonly error: string;
9
+ }
10
+ export type WriteOutcome = WriteOk | WriteRefused;
11
+ /** Why an enqueued write did not land. `refused` carries the hub's code so the target can escalate by name (S5). */
12
+ export type TargetAsyncFailure = {
13
+ readonly kind: 'threw';
14
+ readonly error: string;
15
+ } | {
16
+ readonly kind: 'refused';
17
+ readonly code: Extract<ClaimOutcome, {
18
+ ok: false;
19
+ }>['code'];
20
+ readonly message: string;
21
+ };
22
+ /**
23
+ * Where a composition writes. A write answers `{ ok: false }` rather than
24
+ * throwing, and `setAvailable` does not throw. The runtime survives either
25
+ * anyway: a throwing write is a failed write, a throwing `setAvailable` is
26
+ * retried on the next pass. A target whose writes are asynchronous reports
27
+ * what did not land through `onAsyncFailure`.
28
+ */
29
+ export interface ComposedWriteTarget {
30
+ readonly id: number;
31
+ seed(capName: string, slice: SlicePatch): WriteOutcome;
32
+ patch(capName: string, patch: SlicePatch): WriteOutcome;
33
+ setAvailable(available: boolean): void;
34
+ onAsyncFailure?(listener: (cap: string, failure: TargetAsyncFailure) => void): void;
35
+ /**
36
+ * S1b: these fields of `cap` are NOT the composition's to write right now
37
+ * (their `release`-mode source is unavailable). The claim is narrowed to the
38
+ * rest; an empty rest releases the whole cap. `[]` re-widens. Absent on a
39
+ * `new`-target device (`ComposedDevice`): `release` is planned only on
40
+ * existing targets.
41
+ */
42
+ withhold?(cap: string, fields: readonly string[]): WriteOutcome;
43
+ }
44
+ export interface DeadlineTimer {
45
+ arm(at: number, fire: () => void): void;
46
+ disarm(): void;
47
+ }
48
+ export interface CompositionEventEmitter {
49
+ emit(event: SystemEvent): void;
50
+ }
@@ -1,4 +1,4 @@
1
- import { ClaimsListing, CompositionFeaturePlan, CompositionFieldPlan, CompositionFieldState, CompositionSourceRef, CompositionTargetFound, deviceStateCapability, DeviceType, FieldClaimMode, IScopedLogger } from '@camstack/types';
1
+ import { CapabilityLookup, ClaimsListing, CompositionFeaturePlan, CompositionFieldPlan, CompositionFieldState, CompositionSourceRef, CompositionTargetFound, deviceStateCapability, DeviceType, FieldClaimMode, IScopedLogger } from '@camstack/types';
2
2
  import { z } from 'zod';
3
3
  import { ReleasedField } from './composition-runtime.js';
4
4
  import { GraftOutcome } from './graft-host.js';
@@ -12,6 +12,24 @@ export interface ComposerClaimsApi extends OwnedFieldsApi {
12
12
  export interface ExistingTargetSeedRead {
13
13
  readonly byCap: ReadonlyMap<string, Readonly<Record<string, unknown>> | null>;
14
14
  }
15
+ export interface SeedlessRestoredCapsInput {
16
+ readonly logger: IScopedLogger;
17
+ readonly blockId: string;
18
+ readonly deviceId: number;
19
+ readonly features: readonly CompositionFeaturePlan[];
20
+ readonly seed: ExistingTargetSeedRead;
21
+ readonly lookupCap: CapabilityLookup;
22
+ }
23
+ /**
24
+ * Review M3: an ADDED `restored` cap seeded from NOTHING says so, once per
25
+ * runtime build, on its device. After a restart its state comes from the
26
+ * target's runtime-state row; a row that lost the slice (D677: 615's doorbell,
27
+ * dropped at a hub boot) used to surface as "not seeded yet" and now seeds a
28
+ * clean `{ null, 0 }` — a lifetime count silently reset unless this line
29
+ * names it. A first composition of a device that never had the slice logs it
30
+ * too: the line cannot tell the two apart, and says both.
31
+ */
32
+ export declare function reportSeedlessRestoredCaps(input: SeedlessRestoredCapsInput): void;
15
33
  /**
16
34
  * Read every affected effective capability exactly once, before the composer
17
35
  * grafts or claims any of them. A null slice is a successful empty seed; a
@@ -0,0 +1,19 @@
1
+ import { SourceReading } from '@camstack/types';
2
+ import { FieldRecord } from './field-record.js';
3
+ /** `keys` in evaluation order: derived, then accumulators, then the rest; stable within a rank. */
4
+ export declare function orderForEvaluation(keys: readonly string[], records: ReadonlyMap<string, FieldRecord>): readonly string[];
5
+ /**
6
+ * The own field `key` as the runtime holds it right now (`records`: the pass in
7
+ * progress) — exactly what the runtime PUBLISHES for it, which is what the hub
8
+ * answered before (review H1). An unavailable field under the `null` or
9
+ * `unknown` policy is published as `null` / `'unknown'`, so a reader sees that
10
+ * value; only a field nothing is written for (`release`, `offline`) reads as
11
+ * unavailable. Answering those as unavailable left `count` unprimed while a
12
+ * source was late at boot, and it then swallowed the first press as its seed.
13
+ *
14
+ * Not evaluated yet is unavailable: nothing is published, and unknown is never
15
+ * `null` (D393). The evaluation order makes this unreachable for a derived
16
+ * reader of a derived field. Never fatal here: a gone source fails the block
17
+ * through the field that reads it directly.
18
+ */
19
+ export declare function ownFieldReading(records: ReadonlyMap<string, FieldRecord>, key: string): SourceReading;
@@ -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-RAl10EfG.js");
6
+ const require_dist = require("../../dist-Dcy0gVHu.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  //#region src/builtins/console-logging/console-destination.ts
9
9
  var LEVEL_RANK = {
@@ -1,4 +1,4 @@
1
- import { Gn as BaseAddon, Rt as logDestinationCapability } from "../../dist-BPvku43i.mjs";
1
+ import { Gn as BaseAddon, Rt as logDestinationCapability } from "../../dist-CQ9vXSUh.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  //#region src/builtins/console-logging/console-destination.ts
4
4
  var LEVEL_RANK = {
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-RAl10EfG.js");
4
- const require_composition_sources = require("../../composition-sources-BwE1POnF.js");
3
+ const require_dist = require("../../dist-Dcy0gVHu.js");
4
+ const require_composition_sources = require("../../composition-sources-BjRPhWtU.js");
5
5
  let node_crypto = require("node:crypto");
6
6
  let _camstack_types_node = require("@camstack/types/node");
7
7
  let node_fs_promises = require("node:fs/promises");
@@ -1,5 +1,5 @@
1
- import { $ as coreBlockAddonId, Gn as BaseAddon, In as compositionSourceKey, K as buildCapabilityLookup, Q as compositionSourceRefs, Wn as errMsg, Xt as planComposition, d as CORE_BLOCK_ADDON_PREFIX, et as coreBlockComposition, f as CoreBlockSchema, h as DeclaredDevices, jn as composedDeviceRef, l as COMPOSER_RUNNER_ID, nt as coreBlockSourceKind, rt as coreBlocksCapability, t as ALL_CAPABILITY_DEFINITIONS, tn as replacedFieldKeys, tt as coreBlockIdFromAddonId, u as CORE_BLOCKS_ADDON_ID, yn as validateComposition } from "../../dist-BPvku43i.mjs";
2
- import { t as describeCompositionSources } from "../../composition-sources-fUyF4z39.mjs";
1
+ import { $ as coreBlockAddonId, Gn as BaseAddon, In as compositionSourceKey, K as buildCapabilityLookup, Q as compositionSourceRefs, Wn as errMsg, Xt as planComposition, d as CORE_BLOCK_ADDON_PREFIX, et as coreBlockComposition, f as CoreBlockSchema, h as DeclaredDevices, jn as composedDeviceRef, l as COMPOSER_RUNNER_ID, nt as coreBlockSourceKind, rt as coreBlocksCapability, t as ALL_CAPABILITY_DEFINITIONS, tn as replacedFieldKeys, tt as coreBlockIdFromAddonId, u as CORE_BLOCKS_ADDON_ID, yn as validateComposition } from "../../dist-CQ9vXSUh.mjs";
2
+ import { t as describeCompositionSources } from "../../composition-sources-Cg2MP-qf.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { customizationBlockName } from "@camstack/types/node";
5
5
  import * as fs from "node:fs/promises";