@camstack/system 1.2.39 → 1.2.40
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/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
- package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
- package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
- package/dist/builtins/alerts/alerts.addon.js +1 -1
- package/dist/builtins/alerts/alerts.addon.mjs +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
- package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
- package/dist/builtins/console-logging/index.js +1 -1
- package/dist/builtins/console-logging/index.mjs +1 -1
- package/dist/builtins/core-blocks/block-package.d.ts +59 -0
- package/dist/builtins/core-blocks/block-supervisor.d.ts +86 -0
- package/dist/builtins/core-blocks/core-blocks.addon.d.ts +18 -0
- package/dist/builtins/core-blocks/core-blocks.addon.js +533 -68
- package/dist/builtins/core-blocks/core-blocks.addon.mjs +528 -69
- package/dist/builtins/core-blocks/index.d.ts +5 -3
- package/dist/builtins/core-blocks/index.js +6 -0
- package/dist/builtins/core-blocks/index.mjs +2 -2
- package/dist/builtins/device-manager/device-manager.addon.js +14 -6
- package/dist/builtins/device-manager/device-manager.addon.mjs +14 -6
- package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
- package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
- package/dist/builtins/hub-forwarder/index.js +1 -1
- package/dist/builtins/hub-forwarder/index.mjs +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
- package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
- package/dist/builtins/local-auth/local-auth.addon.js +1 -1
- package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
- package/dist/builtins/local-network/local-network.addon.js +1 -1
- package/dist/builtins/local-network/local-network.addon.mjs +1 -1
- package/dist/builtins/loki-logging/index.js +1 -1
- package/dist/builtins/loki-logging/index.mjs +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
- package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
- package/dist/builtins/platform-probe/index.js +1 -1
- package/dist/builtins/platform-probe/index.mjs +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
- package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
- package/dist/builtins/snapshot/index.js +281 -16
- package/dist/builtins/snapshot/index.mjs +282 -17
- package/dist/builtins/snapshot/snapshot-cache.d.ts +45 -0
- package/dist/builtins/snapshot/snapshot-media-handler.d.ts +32 -2
- package/dist/builtins/snapshot/snapshot-resize.d.ts +50 -0
- package/dist/builtins/snapshot/snapshot.addon.d.ts +13 -0
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
- package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +1 -1
- package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
- package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
- package/dist/builtins/system-config/system-config.addon.js +1 -1
- package/dist/builtins/system-config/system-config.addon.mjs +1 -1
- package/dist/builtins/winston-logging/index.js +1 -1
- package/dist/builtins/winston-logging/index.mjs +1 -1
- package/dist/{dist-DO76YVO2.mjs → dist-BXS0DP92.mjs} +24 -2
- package/dist/{dist-CFinlH7b.js → dist-Cj0LAuXi.js} +24 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -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-
|
|
6
|
+
const require_dist = require("../../dist-Cj0LAuXi.js");
|
|
7
7
|
const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
node_fs = require_chunk.__toESM(node_fs);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pt as EventCategory, ct as BaseAddon, m as addonPagesCapability, st as errMsg } from "../../dist-
|
|
1
|
+
import { Pt as EventCategory, ct as BaseAddon, m as addonPagesCapability, st as errMsg } from "../../dist-BXS0DP92.mjs";
|
|
2
2
|
import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
|
|
3
3
|
import * as fs from "node:fs";
|
|
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-
|
|
6
|
+
const require_dist = require("../../dist-Cj0LAuXi.js");
|
|
7
7
|
const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
|
|
8
8
|
let node_fs = require("node:fs");
|
|
9
9
|
node_fs = require_chunk.__toESM(node_fs);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pt as EventCategory, ct as BaseAddon, g as addonWidgetsCapability, st as errMsg } from "../../dist-
|
|
1
|
+
import { Pt as EventCategory, ct as BaseAddon, g as addonWidgetsCapability, st as errMsg } from "../../dist-BXS0DP92.mjs";
|
|
2
2
|
import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
|
|
3
3
|
import * as fs from "node:fs";
|
|
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-
|
|
6
|
+
const require_dist = require("../../dist-Cj0LAuXi.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 { Pt as EventCategory, _ as alertsCapability, ct as BaseAddon, n as AlertSchema, st as errMsg, xt as createEvent } from "../../dist-
|
|
1
|
+
import { Pt as EventCategory, _ as alertsCapability, ct as BaseAddon, n as AlertSchema, st as errMsg, xt as createEvent } from "../../dist-BXS0DP92.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
|
const require_chunk = require("../../chunk-Cek0wNdY.js");
|
|
6
|
-
const require_dist = require("../../dist-
|
|
6
|
+
const require_dist = require("../../dist-Cj0LAuXi.js");
|
|
7
7
|
let node_fs = require("node:fs");
|
|
8
8
|
let node_fs$1 = require_chunk.__toESM(node_fs, 1);
|
|
9
9
|
node_fs = require_chunk.__toESM(node_fs);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pt as EventCategory, b as backupCapability, ct as BaseAddon } from "../../dist-
|
|
1
|
+
import { Pt as EventCategory, b as backupCapability, ct as BaseAddon } from "../../dist-BXS0DP92.mjs";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import Kt from "node:fs";
|
|
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-
|
|
6
|
+
const require_dist = require("../../dist-Cj0LAuXi.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 { H as logDestinationCapability, ct as BaseAddon } from "../../dist-
|
|
1
|
+
import { H as logDestinationCapability, ct as BaseAddon } from "../../dist-BXS0DP92.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 = {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a stored block into something the addon runner can fork.
|
|
3
|
+
*
|
|
4
|
+
* The runner already knows how to do everything a block needs — fork a
|
|
5
|
+
* process, build the full UDS `ctx`, redirect host-provided imports, and hand
|
|
6
|
+
* the whole thing to `CrashSupervisor` (D6). What it does NOT know how to do is
|
|
7
|
+
* load code out of a database row: `addon-runner` reads a package.json off
|
|
8
|
+
* disk. So a block is MATERIALISED as a minimal addon package and spawned like
|
|
9
|
+
* any other addon. No second runner, no second supervisor, no `node:vm`.
|
|
10
|
+
*
|
|
11
|
+
* Two files are generated per block:
|
|
12
|
+
*
|
|
13
|
+
* `dist/block.js` — the author's TypeScript, transpiled.
|
|
14
|
+
* `dist/index.js` — a generated wrapper that adapts the author's contract
|
|
15
|
+
* (`export default (ctx) => disposer`) to `ICamstackAddon`.
|
|
16
|
+
*
|
|
17
|
+
* The wrapper exists so the author never writes `super({})`, which is the trap
|
|
18
|
+
* that killed `CoreBlocksAddon` in production while the build stayed green and
|
|
19
|
+
* the topology reported it running.
|
|
20
|
+
*/
|
|
21
|
+
/** Prefix for the generated addon id AND the runner id — one addon, one
|
|
22
|
+
* process, so the two are the same string (D2). Grep-able on purpose: an
|
|
23
|
+
* operator reading `$process.list` must be able to tell a block runner from
|
|
24
|
+
* an addon runner at a glance. */
|
|
25
|
+
export declare const BLOCK_ADDON_PREFIX = "core-block-";
|
|
26
|
+
/** The generated addon/runner id for a block. */
|
|
27
|
+
export declare function blockAddonId(blockId: string): string;
|
|
28
|
+
/** The block id behind a generated addon/runner id, or null when the id
|
|
29
|
+
* belongs to something else. The inverse of {@link blockAddonId} — used to
|
|
30
|
+
* read the live process list back into block terms. */
|
|
31
|
+
export declare function blockIdFromAddonId(addonId: string): string | null;
|
|
32
|
+
export interface MaterializeBlockInput {
|
|
33
|
+
/** Root under which every block package lives — one directory per block. */
|
|
34
|
+
readonly root: string;
|
|
35
|
+
readonly blockId: string;
|
|
36
|
+
readonly blockName: string;
|
|
37
|
+
/** The block's transpiled JavaScript. */
|
|
38
|
+
readonly js: string;
|
|
39
|
+
}
|
|
40
|
+
export interface MaterializedBlock {
|
|
41
|
+
/** What `$process.spawnRunner` gets as `addonDir` — the package root. */
|
|
42
|
+
readonly addonDir: string;
|
|
43
|
+
readonly addonId: string;
|
|
44
|
+
}
|
|
45
|
+
/** Build the wrapper for one block. Exported for the test that asserts the
|
|
46
|
+
* generated source actually carries the block's identity. */
|
|
47
|
+
export declare function renderBlockWrapper(blockId: string, blockName: string): string;
|
|
48
|
+
/** The package manifest the addon runner reads to find the entry point. */
|
|
49
|
+
export declare function renderBlockManifest(blockId: string, blockName: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Write (or rewrite) a block's package. Idempotent, and deliberately a full
|
|
52
|
+
* rewrite: the author's code is the thing that changes, and a partial update
|
|
53
|
+
* that left a stale `block.js` behind would run yesterday's code while the
|
|
54
|
+
* editor showed today's.
|
|
55
|
+
*/
|
|
56
|
+
export declare function materializeBlock(input: MaterializeBlockInput): Promise<MaterializedBlock>;
|
|
57
|
+
/** Remove a block's package. Idempotent — a missing directory is the desired
|
|
58
|
+
* end state, not an error. */
|
|
59
|
+
export declare function removeBlockPackage(root: string, blockId: string): Promise<void>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { CoreBlock, IScopedLogger } from '@camstack/types';
|
|
2
|
+
/** The runner lifecycle states `$process.list` reports. `stopping`/`stopped`
|
|
3
|
+
* are transient states of a runner on its way out and are treated as absent. */
|
|
4
|
+
export type BlockRunnerState = 'starting' | 'running' | 'stopping' | 'stopped' | 'crashed' | 'failed';
|
|
5
|
+
export interface BlockRunnerSnapshot {
|
|
6
|
+
/** The runner id — equal to the generated addon id for a block runner. */
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly state: BlockRunnerState;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The process plane, narrowed to the three things a block needs.
|
|
12
|
+
*
|
|
13
|
+
* Injected rather than reached for, so the decision logic above is testable
|
|
14
|
+
* without a broker — and so the day a block runs on an agent, only this
|
|
15
|
+
* implementation changes.
|
|
16
|
+
*/
|
|
17
|
+
export interface BlockProcessHost {
|
|
18
|
+
list(): Promise<readonly BlockRunnerSnapshot[]>;
|
|
19
|
+
spawn(input: {
|
|
20
|
+
runnerId: string;
|
|
21
|
+
addonId: string;
|
|
22
|
+
addonDir: string;
|
|
23
|
+
}): Promise<void>;
|
|
24
|
+
stop(runnerId: string): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
export interface BlockCompileOutcome {
|
|
27
|
+
readonly ok: boolean;
|
|
28
|
+
readonly error?: string;
|
|
29
|
+
readonly js?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface BlockSupervisorDeps {
|
|
32
|
+
/** This node's id, already stripped of any `/<addon>` runner suffix. */
|
|
33
|
+
readonly nodeId: string;
|
|
34
|
+
/** Where block packages are materialised — one directory per block. */
|
|
35
|
+
readonly root: string;
|
|
36
|
+
readonly store: BlockStoreView;
|
|
37
|
+
readonly host: BlockProcessHost;
|
|
38
|
+
readonly compile: (code: string) => Promise<BlockCompileOutcome>;
|
|
39
|
+
readonly logger: IScopedLogger;
|
|
40
|
+
}
|
|
41
|
+
/** The slice of `CoreBlockStore` the supervisor uses. */
|
|
42
|
+
export interface BlockStoreView {
|
|
43
|
+
list(): readonly CoreBlock[];
|
|
44
|
+
get(blockId: string): CoreBlock | null;
|
|
45
|
+
setStatus(blockId: string, status: CoreBlock['status'], error?: string): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export declare class BlockSupervisor {
|
|
48
|
+
private readonly deps;
|
|
49
|
+
/**
|
|
50
|
+
* `blockId → updatedAt` of the source this supervisor last materialised.
|
|
51
|
+
* The only way to know a running block is running YESTERDAY'S code: the
|
|
52
|
+
* process is alive either way, and nothing on disk carries the version.
|
|
53
|
+
* In-memory is correct — a hub restart takes every child with it.
|
|
54
|
+
*/
|
|
55
|
+
private readonly materialized;
|
|
56
|
+
private timer;
|
|
57
|
+
/** Serialises passes so a timer tick cannot interleave with a write-driven
|
|
58
|
+
* converge and spawn the same runner twice. */
|
|
59
|
+
private inFlight;
|
|
60
|
+
constructor(deps: BlockSupervisorDeps);
|
|
61
|
+
/** Start the reconcile timer. The first pass runs immediately. */
|
|
62
|
+
start(intervalMs: number): void;
|
|
63
|
+
stop(): void;
|
|
64
|
+
/** One reconcile pass. Never throws — a pass that failed must not stop the
|
|
65
|
+
* next one, and the reason belongs in the log, not in a rejected promise
|
|
66
|
+
* nobody awaits. */
|
|
67
|
+
converge(): Promise<void>;
|
|
68
|
+
private runPass;
|
|
69
|
+
private reconcile;
|
|
70
|
+
/** Compile, write the package, spawn. Each failure is reported ON the block
|
|
71
|
+
* — the author asked for this to run, so they are owed the reason it does
|
|
72
|
+
* not. */
|
|
73
|
+
private launch;
|
|
74
|
+
private reportRunnerState;
|
|
75
|
+
/**
|
|
76
|
+
* Write a status only when it actually changed.
|
|
77
|
+
*
|
|
78
|
+
* A reconcile pass runs on a timer, and every write rewrites the row AND
|
|
79
|
+
* moves `lastChangedAt` — which is the only thing telling an operator WHEN a
|
|
80
|
+
* block last did something. Rewriting it every tick would make it read as
|
|
81
|
+
* "just now", forever.
|
|
82
|
+
*/
|
|
83
|
+
private report;
|
|
84
|
+
private isPlacedHere;
|
|
85
|
+
private stopReason;
|
|
86
|
+
}
|
|
@@ -11,8 +11,26 @@ export declare class CoreBlocksAddon extends BaseAddon {
|
|
|
11
11
|
private store;
|
|
12
12
|
private transpiler;
|
|
13
13
|
private typeDefs;
|
|
14
|
+
private supervisor;
|
|
14
15
|
protected onInitialize(): Promise<ProviderRegistration[]>;
|
|
15
16
|
protected onShutdown(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Build the supervisor, or explain in one line why this node runs no blocks.
|
|
19
|
+
*
|
|
20
|
+
* Two ways to end up with none, and both are logged rather than inferred:
|
|
21
|
+
* this is not the hub (execution is hub-only for now), or the kernel exposed
|
|
22
|
+
* no cluster broker, which is the only door to `$process.*`.
|
|
23
|
+
*/
|
|
24
|
+
private buildSupervisor;
|
|
25
|
+
/**
|
|
26
|
+
* Reconcile now, after a write.
|
|
27
|
+
*
|
|
28
|
+
* The timer would get there on its own, but an operator who presses Save and
|
|
29
|
+
* watches a block sit at `stopped` for fifteen seconds has been told nothing
|
|
30
|
+
* happened. Deliberately NOT awaited by the cap method: converging forks a
|
|
31
|
+
* process, and the write is already durable.
|
|
32
|
+
*/
|
|
33
|
+
private convergeSoon;
|
|
16
34
|
private requireStore;
|
|
17
35
|
/**
|
|
18
36
|
* Compile, or explain why not.
|