@camstack/server 1.2.594 → 1.2.595
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/addon-root-inventory.js +50 -11
- package/dist/agent/addon-scan.js +44 -6
- package/dist/agent/agent-addon-runtime.js +8 -3
- package/dist/agent/agent-addon-updates.js +52 -12
- package/dist/agent/agent-cap-dispatch-service.js +5 -3
- package/dist/agent/agent-config.js +42 -7
- package/dist/agent/agent-deploy-swap.js +41 -5
- package/dist/agent/agent-group-runner.js +47 -8
- package/dist/agent/agent-http-auth.js +22 -10
- package/dist/agent/agent-http.js +113 -64
- package/dist/agent/agent-hub-addon-update.js +16 -10
- package/dist/agent/agent-hub-registration.js +7 -4
- package/dist/agent/agent-infra-capabilities.js +9 -5
- package/dist/agent/agent-json-file.js +42 -5
- package/dist/agent/agent-mesh-gate.js +8 -5
- package/dist/agent/agent-node-certificates.js +28 -25
- package/dist/agent/agent-pairing-local.js +47 -10
- package/dist/agent/agent-pairing-routes.js +20 -16
- package/dist/agent/agent-pairing-store.js +58 -18
- package/dist/agent/agent-reconnect.js +4 -1
- package/dist/agent/agent-service.js +71 -35
- package/dist/agent/agent-sniffing-listener.js +48 -11
- package/dist/agent/agent-undeploy.js +41 -5
- package/dist/agent/agent-update-routes.js +19 -14
- package/dist/agent/agent-update-service.js +80 -38
- package/dist/agent/apply-model-distribution.js +4 -1
- package/dist/agent/apply-stage-dev-uploads.js +9 -6
- package/dist/agent/derive-hub-url.js +8 -3
- package/dist/agent/fetch-bundle-from-hub.js +9 -6
- package/dist/agent/hubs-found.js +43 -6
- package/dist/agent/infra-boot-guard.js +4 -1
- package/dist/agent/infra-boot-plan.js +6 -2
- package/dist/agent/main.js +183 -148
- package/dist/agent/register-agent-cap-dispatch.js +6 -3
- package/dist/agent/serial-queue.js +7 -2
- package/dist/agent-status-page.js +4 -1
- package/dist/api/addon-upload.js +61 -22
- package/dist/api/agent-addon-delivery.js +11 -6
- package/dist/api/auth-whoami.js +4 -1
- package/dist/api/backup-download-pump.js +9 -5
- package/dist/api/backup-download.js +10 -7
- package/dist/api/core/addon-settings.router.js +19 -16
- package/dist/api/core/agent-pairing.router.js +79 -76
- package/dist/api/core/agents.router.js +24 -21
- package/dist/api/core/auth-admin-tokens.procedures.js +52 -48
- package/dist/api/core/auth-device-cert.procedures.js +67 -62
- package/dist/api/core/auth-limits.js +25 -16
- package/dist/api/core/auth-reauth.procedures.js +37 -32
- package/dist/api/core/auth-revoke-credentials.procedures.js +26 -22
- package/dist/api/core/auth-sessions.procedures.js +56 -52
- package/dist/api/core/auth.router.js +304 -300
- package/dist/api/core/cap-providers.js +121 -74
- package/dist/api/core/capabilities.router.js +37 -34
- package/dist/api/core/capability-preference-writes.js +17 -10
- package/dist/api/core/certificates.router.js +109 -106
- package/dist/api/core/cluster-nodes.router.js +18 -15
- package/dist/api/core/collection-preference.js +6 -2
- package/dist/api/core/event-bus-proxy.router.js +37 -34
- package/dist/api/core/failure-contributions.js +8 -4
- package/dist/api/core/hwaccel.router.js +20 -17
- package/dist/api/core/integration-secrets.js +12 -8
- package/dist/api/core/lifecycle-job-runner.js +49 -13
- package/dist/api/core/live-events.router.js +32 -29
- package/dist/api/core/load-contributions.js +8 -4
- package/dist/api/core/logging-settings.js +43 -30
- package/dist/api/core/logs.router.js +43 -40
- package/dist/api/core/notifications.router.js +18 -15
- package/dist/api/core/public-event-filter.js +8 -4
- package/dist/api/core/repl.router.js +21 -18
- package/dist/api/core/request-census-settings.js +16 -11
- package/dist/api/core/server-management.provider.js +4 -1
- package/dist/api/core/server-name.js +17 -9
- package/dist/api/core/site-location.js +24 -16
- package/dist/api/core/stream-probe.router.js +24 -21
- package/dist/api/core/system-events.router.js +26 -23
- package/dist/api/cors/cors-policy.js +29 -20
- package/dist/api/cors/register-cors-policy.js +14 -9
- package/dist/api/deploy-stage-registry.js +10 -6
- package/dist/api/dev-uploads-bundle.js +50 -12
- package/dist/api/health/adaptive-probe.routes.js +13 -9
- package/dist/api/health/health.routes.js +13 -8
- package/dist/api/hub-cluster-url.js +9 -3
- package/dist/api/model-distributor.js +50 -12
- package/dist/api/oauth2/consent-page.js +13 -10
- package/dist/api/oauth2/oauth2-routes.js +25 -17
- package/dist/api/oauth2/private-host.js +4 -1
- package/dist/api/server-upload-propagate.js +51 -15
- package/dist/api/server-upload.js +50 -13
- package/dist/api/sse-no-compression.js +4 -1
- package/dist/api/static/frame-policy.js +9 -4
- package/dist/api/static/precompressed-asset.js +57 -15
- package/dist/api/static/spa-mount.js +47 -8
- package/dist/api/static/spa-static.js +12 -5
- package/dist/api/tarball-manifest.js +44 -7
- package/dist/api/trpc/cap-mount-helpers.js +12 -7
- package/dist/api/trpc/cap-route-error-formatter.js +13 -10
- package/dist/api/trpc/cap-router-runtime.js +51 -40
- package/dist/api/trpc/client-ip.js +20 -9
- package/dist/api/trpc/core-cap-bridge.js +42 -32
- package/dist/api/trpc/device-collection-dispatch.js +27 -23
- package/dist/api/trpc/device-config-secret-redaction.js +40 -24
- package/dist/api/trpc/generated-cap-mounts.js +222 -218
- package/dist/api/trpc/generated-cap-routers.js +4856 -4676
- package/dist/api/trpc/http-request-census-hook.js +11 -8
- package/dist/api/trpc/http-request-census.js +41 -34
- package/dist/api/trpc/http-request-census.singleton.js +8 -4
- package/dist/api/trpc/localized-schema-paths.js +4 -1
- package/dist/api/trpc/principal-visibility.js +22 -14
- package/dist/api/trpc/remote-addon-update-grant.js +4 -1
- package/dist/api/trpc/scope-access.js +15 -10
- package/dist/api/trpc/server-provided-caps.js +7 -3
- package/dist/api/trpc/share-view-access.js +14 -6
- package/dist/api/trpc/trpc-error-device-tags.js +6 -3
- package/dist/api/trpc/trpc-error-principal.js +6 -2
- package/dist/api/trpc/trpc.context.js +25 -20
- package/dist/api/trpc/trpc.middleware.js +46 -38
- package/dist/api/trpc/trpc.router.js +99 -58
- package/dist/api/trpc/user-error.js +8 -5
- package/dist/api/trpc/ws-request-census.js +24 -17
- package/dist/api/trpc/ws-slow-consumer-guard.js +16 -11
- package/dist/api/upload-auth.js +9 -5
- package/dist/auth/addon-route-jwt-gate.js +7 -4
- package/dist/auth/addon-route-share-gate.js +12 -7
- package/dist/auth/app-confirm-page.js +22 -17
- package/dist/auth/app-confirm-routes.js +31 -26
- package/dist/auth/app-confirmations.js +44 -7
- package/dist/auth/app-page-shell.js +30 -17
- package/dist/auth/app-page-strings.js +17 -11
- package/dist/auth/app-passkey-page.js +21 -16
- package/dist/auth/app-passkey-routes.js +41 -37
- package/dist/auth/app-refused-route.js +18 -13
- package/dist/auth/auth-network-policy.js +15 -11
- package/dist/auth/auth-provider-gate.js +9 -4
- package/dist/auth/auth-rate-limit.js +7 -3
- package/dist/auth/client-address.js +9 -6
- package/dist/auth/device-enroll-proofs.js +43 -6
- package/dist/auth/external-link-intents.js +7 -3
- package/dist/auth/hub-sessions.js +12 -6
- package/dist/auth/native-link-completions.js +11 -7
- package/dist/auth/native-return.js +13 -9
- package/dist/auth/passkey-provider.js +32 -26
- package/dist/auth/second-factors.js +10 -6
- package/dist/auth/session-connections.js +12 -6
- package/dist/auth/session-cookie.js +23 -12
- package/dist/auth/session-lifetimes.js +12 -8
- package/dist/auth/session-mint.js +11 -4
- package/dist/auth/sso-finish-app.js +16 -13
- package/dist/auth/sso-finish-deps.js +27 -21
- package/dist/auth/sso-finish.js +38 -28
- package/dist/auth/sso-routes.js +25 -22
- package/dist/auth/used-bridge-ids.js +5 -1
- package/dist/boot/boot-config.js +55 -16
- package/dist/boot/init-sequence.js +4 -1
- package/dist/boot/integration-id-backfill.js +8 -3
- package/dist/boot/platform-keychain-key.js +42 -5
- package/dist/boot/post-boot.service.js +18 -14
- package/dist/boot/reconcile-lifecycle-jobs.js +6 -3
- package/dist/boot/retired-public-url-env.js +8 -4
- package/dist/bootstrap-packages.js +4 -1
- package/dist/closure-node-modules.js +38 -2
- package/dist/core/addon/addon-call-gateway.js +5 -1
- package/dist/core/addon/addon-package.service.js +123 -83
- package/dist/core/addon/addon-process-view.js +6 -2
- package/dist/core/addon/addon-realign-plan.js +4 -1
- package/dist/core/addon/addon-registry.service.js +187 -146
- package/dist/core/addon/addon-row-manifest.js +4 -1
- package/dist/core/addon/addon-search.service.js +7 -3
- package/dist/core/addon/addon-settings-provider.js +3 -1
- package/dist/core/addon/addon-uninstall.js +11 -4
- package/dist/core/addon/addon.tokens.js +5 -2
- package/dist/core/addon/device-meta-mirror.js +13 -8
- package/dist/core/addon/forked-custom-actions.js +11 -6
- package/dist/core/addon/integration-visibility.js +6 -3
- package/dist/core/addon/materialize-route-path.js +4 -1
- package/dist/core/addon/package-dir-utils.js +45 -8
- package/dist/core/addon/prune-misplaced-addons.js +43 -5
- package/dist/core/addon/runner-convergence.js +4 -1
- package/dist/core/addon/runner-serialization.js +4 -1
- package/dist/core/addon/runner-spawn-fanout.js +8 -3
- package/dist/core/addon/settings-door-wiring.js +8 -5
- package/dist/core/addon/single-flight-refresh.js +4 -1
- package/dist/core/addon-bridge/addon-bridge.service.js +44 -7
- package/dist/core/addon-pages/addon-pages.service.js +40 -3
- package/dist/core/addon-widgets/addon-widgets.service.js +42 -4
- package/dist/core/agent/agent-addon-backfill.js +17 -9
- package/dist/core/agent/agent-delivery-ledger.js +7 -3
- package/dist/core/agent/agent-liveness-event.js +6 -2
- package/dist/core/agent/agent-pairing-http.js +45 -41
- package/dist/core/agent/agent-registry.service.js +89 -50
- package/dist/core/agent/cluster-node-history-mirror.js +7 -3
- package/dist/core/agent/cluster-node-history-store.js +35 -31
- package/dist/core/agent/hub-agent-pairing.js +5 -1
- package/dist/core/agent/node-certificates-client.js +6 -3
- package/dist/core/agent/node-directory.js +4 -1
- package/dist/core/app-links/well-known-app-links.js +6 -2
- package/dist/core/auth/auth.service.js +8 -3
- package/dist/core/auth/handoff-code.service.js +49 -11
- package/dist/core/auth/record-kinds.js +19 -16
- package/dist/core/auth/share-token.service.js +79 -42
- package/dist/core/capability/capability.service.js +5 -1
- package/dist/core/config/config.schema.js +6 -1
- package/dist/core/config/config.service.js +6 -2
- package/dist/core/events/event-bus.service.js +7 -3
- package/dist/core/feature/feature.service.js +6 -2
- package/dist/core/lifecycle/lifecycle-runner.singleton.js +10 -5
- package/dist/core/lifecycle/lifecycle-state-machine.js +5 -1
- package/dist/core/logging/log-ring-buffer.js +5 -1
- package/dist/core/logging/logging.service.js +9 -5
- package/dist/core/logging/scoped-logger.js +5 -1
- package/dist/core/moleculer/agent-readiness-pull.js +4 -1
- package/dist/core/moleculer/agent-registration-request.js +7 -3
- package/dist/core/moleculer/cap-call-fn.js +7 -4
- package/dist/core/moleculer/cap-route-authority.js +8 -3
- package/dist/core/moleculer/hub-mesh-guard.js +9 -5
- package/dist/core/moleculer/moleculer.service.js +86 -79
- package/dist/core/network/network-quality.service.js +6 -2
- package/dist/core/notification/notification-wrapper.service.js +7 -3
- package/dist/core/notification/toast-wrapper.service.js +7 -3
- package/dist/core/provider/provider.tokens.js +4 -1
- package/dist/core/repl/repl-engine.service.js +8 -4
- package/dist/core/runner-health/runner-boot-check.js +15 -7
- package/dist/core/runner-health/update-preflight.js +14 -9
- package/dist/core/server-update/server-update.service.js +49 -12
- package/dist/core/server-update/system-apply-closure-patches.js +42 -6
- package/dist/core/server-update/system-ensure-prebuilds.js +6 -3
- package/dist/core/server-update/system-exec-npm.js +5 -2
- package/dist/core/storage/fs-storage-backend.js +5 -1
- package/dist/core/storage/storage-location-manager.js +5 -1
- package/dist/core/storage/storage.service.js +6 -2
- package/dist/core/streaming/ffmpeg-stream-info.js +8 -3
- package/dist/core/streaming/stream-probe.service.js +16 -12
- package/dist/core/streaming/ttl-cache.js +5 -1
- package/dist/core/topology/topology-emitter.service.js +23 -19
- package/dist/core/update-availability-emitter.js +7 -3
- package/dist/core/update-availability-store.js +45 -8
- package/dist/core/updates/agent-installed-packages.js +9 -5
- package/dist/core/updates/restart-marker.js +8 -3
- package/dist/core/updates/update-check-scheduler.js +18 -13
- package/dist/core/updates/wrapper-update-checker.js +7 -3
- package/dist/first-boot-addon-plan.js +6 -2
- package/dist/framework-nodepath.js +38 -2
- package/dist/i18n/request-lang.js +11 -7
- package/dist/launcher.js +65 -30
- package/dist/lifecycle-journal-path.js +38 -2
- package/dist/main.js +324 -286
- package/dist/manual-boot.js +156 -117
- package/dist/node-role.js +4 -1
- package/dist/package-inventory.js +48 -7
- package/dist/pending-restore.js +43 -7
- package/dist/single-copy-cleanup-runner.js +45 -9
- package/dist/single-copy-cleanup.js +15 -7
- package/dist/sqlite-restore.js +48 -9
- package/dist/starter.js +39 -4
- package/dist/ui-serving/lazy-ui-serving.js +39 -3
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* eslint-disable @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access -- pre-existing lint debt across this 800-line provider-factory module. The flagged sites delegate into Moleculer/EventBus/IntegrationRegistry surfaces typed as `unknown` to break circular dependencies; runtime contracts are validated by the cap-mount-helper layer above. Tracked separately. */
|
|
2
3
|
/**
|
|
3
4
|
* Capability provider factories for the Phase E core caps —
|
|
@@ -23,34 +24,80 @@
|
|
|
23
24
|
* `server/backend/src/api/core/{system,network-quality,toast,
|
|
24
25
|
* nodes,integrations,addons}.router.ts`.
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
30
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
31
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
32
|
+
}
|
|
33
|
+
Object.defineProperty(o, k2, desc);
|
|
34
|
+
}) : (function(o, m, k, k2) {
|
|
35
|
+
if (k2 === undefined) k2 = k;
|
|
36
|
+
o[k2] = m[k];
|
|
37
|
+
}));
|
|
38
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
39
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
40
|
+
}) : function(o, v) {
|
|
41
|
+
o["default"] = v;
|
|
42
|
+
});
|
|
43
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
44
|
+
var ownKeys = function(o) {
|
|
45
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
46
|
+
var ar = [];
|
|
47
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
48
|
+
return ar;
|
|
49
|
+
};
|
|
50
|
+
return ownKeys(o);
|
|
51
|
+
};
|
|
52
|
+
return function (mod) {
|
|
53
|
+
if (mod && mod.__esModule) return mod;
|
|
54
|
+
var result = {};
|
|
55
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
56
|
+
__setModuleDefault(result, mod);
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
})();
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.INTEGRATION_CAP_MARKERS = void 0;
|
|
62
|
+
exports.buildSystemProvider = buildSystemProvider;
|
|
63
|
+
exports.buildSettingsStoreGateway = buildSettingsStoreGateway;
|
|
64
|
+
exports.buildNetworkQualityProvider = buildNetworkQualityProvider;
|
|
65
|
+
exports.buildToastProvider = buildToastProvider;
|
|
66
|
+
exports.computeTopologyPass = computeTopologyPass;
|
|
67
|
+
exports.computeTopology = computeTopology;
|
|
68
|
+
exports.createNodeRootPackageLookup = createNodeRootPackageLookup;
|
|
69
|
+
exports.buildNodesProvider = buildNodesProvider;
|
|
70
|
+
exports.buildIntegrationsProvider = buildIntegrationsProvider;
|
|
71
|
+
exports.dispatchCustomAction = dispatchCustomAction;
|
|
72
|
+
exports.buildAddonsProvider = buildAddonsProvider;
|
|
73
|
+
const integration_secrets_1 = require("./integration-secrets");
|
|
74
|
+
const node_crypto_1 = require("node:crypto");
|
|
75
|
+
const os = __importStar(require("node:os"));
|
|
76
|
+
const system_1 = require("@camstack/system");
|
|
77
|
+
const types_1 = require("@camstack/types");
|
|
78
|
+
const server_1 = require("@trpc/server");
|
|
79
|
+
const integration_id_backfill_1 = require("../../boot/integration-id-backfill");
|
|
80
|
+
const addon_package_service_js_1 = require("../../core/addon/addon-package.service.js");
|
|
81
|
+
const addon_uninstall_js_1 = require("../../core/addon/addon-uninstall.js");
|
|
82
|
+
const lifecycle_runner_singleton_js_1 = require("../../core/lifecycle/lifecycle-runner.singleton.js");
|
|
83
|
+
const agent_installed_packages_js_1 = require("../../core/updates/agent-installed-packages.js");
|
|
84
|
+
const http_request_census_singleton_js_1 = require("../trpc/http-request-census.singleton.js");
|
|
85
|
+
const capability_preference_writes_js_1 = require("./capability-preference-writes.js");
|
|
86
|
+
const failure_contributions_js_1 = require("./failure-contributions.js");
|
|
87
|
+
const load_contributions_js_1 = require("./load-contributions.js");
|
|
88
|
+
const logging_settings_js_1 = require("./logging-settings.js");
|
|
89
|
+
const request_census_settings_js_1 = require("./request-census-settings.js");
|
|
90
|
+
const server_name_js_1 = require("./server-name.js");
|
|
91
|
+
const site_location_js_1 = require("./site-location.js");
|
|
45
92
|
// ── system ──────────────────────────────────────────────────────────
|
|
46
93
|
function getRetention(registry) {
|
|
47
94
|
return (registry?.getSingleton('analysis-data-persistence')?.retention ?? null);
|
|
48
95
|
}
|
|
49
|
-
|
|
96
|
+
function buildSystemProvider(feature, registry, logger, census = (0, http_request_census_singleton_js_1.getHttpRequestCensus)()) {
|
|
50
97
|
const siteLocation = buildSiteLocationService(registry, logger);
|
|
51
98
|
const store = buildSettingsStoreGateway(registry);
|
|
52
|
-
const serverName = new ServerNameReader({ store, ...(logger !== undefined ? { logger } : {}) });
|
|
53
|
-
const requestCensus = new RequestCensusService({
|
|
99
|
+
const serverName = new server_name_js_1.ServerNameReader({ store, ...(logger !== undefined ? { logger } : {}) });
|
|
100
|
+
const requestCensus = new request_census_settings_js_1.RequestCensusService({
|
|
54
101
|
census,
|
|
55
102
|
store,
|
|
56
103
|
...(logger !== undefined ? { logger } : {}),
|
|
@@ -62,24 +109,24 @@ export function buildSystemProvider(feature, registry, logger, census = getHttpR
|
|
|
62
109
|
// The channels themselves are DECLARED by the addons that own them and
|
|
63
110
|
// reached through the registry's per-provider proxies — hub-main never keeps
|
|
64
111
|
// a hand-written list, which would rot at the first addon that adds one.
|
|
65
|
-
const channels = buildLogChannelPlane({ entries: () => registry?.getCollectionEntries('log-channels') ?? [] }, (addonId, phase, error) => {
|
|
112
|
+
const channels = (0, logging_settings_js_1.buildLogChannelPlane)({ entries: () => registry?.getCollectionEntries('log-channels') ?? [] }, (addonId, phase, error) => {
|
|
66
113
|
logger?.warn('log-channels provider unreachable', { meta: { addonId, phase, error } });
|
|
67
114
|
});
|
|
68
115
|
// Every addon's OWN reported cost, assembled by enumeration. Nothing here
|
|
69
116
|
// knows which pid belongs to which camera — the addon that spawned the child
|
|
70
117
|
// does, and it is the one that says so.
|
|
71
|
-
const loadContributions = buildLoadContributionPlane({ entries: () => registry?.getCollectionEntries('load-contribution') ?? [] }, (addonId, error) => {
|
|
118
|
+
const loadContributions = (0, load_contributions_js_1.buildLoadContributionPlane)({ entries: () => registry?.getCollectionEntries('load-contribution') ?? [] }, (addonId, error) => {
|
|
72
119
|
logger?.warn('load-contribution provider unreachable', { meta: { addonId, error } });
|
|
73
120
|
});
|
|
74
121
|
// Every addon's OWN reported losses, per camera, with the denominator
|
|
75
122
|
// attached. Same enumeration, same reason: the addon that owns the failing
|
|
76
123
|
// path is the only thing that knows which camera it lost work for.
|
|
77
|
-
const failureContributions = buildFailureContributionPlane({ entries: () => registry?.getCollectionEntries('failure-contribution') ?? [] }, (addonId, error) => {
|
|
124
|
+
const failureContributions = (0, failure_contributions_js_1.buildFailureContributionPlane)({ entries: () => registry?.getCollectionEntries('failure-contribution') ?? [] }, (addonId, error) => {
|
|
78
125
|
logger?.warn('failure-contribution provider unreachable', { meta: { addonId, error } });
|
|
79
126
|
});
|
|
80
|
-
const loggingSettings = new LoggingSettingsService({
|
|
127
|
+
const loggingSettings = new logging_settings_js_1.LoggingSettingsService({
|
|
81
128
|
store,
|
|
82
|
-
gate: getLoggingGate(),
|
|
129
|
+
gate: (0, system_1.getLoggingGate)(),
|
|
83
130
|
requestCensus,
|
|
84
131
|
channels,
|
|
85
132
|
...(logger !== undefined ? { logger } : {}),
|
|
@@ -134,7 +181,7 @@ export function buildSystemProvider(feature, registry, logger, census = getHttpR
|
|
|
134
181
|
* invent a location out of a missing dependency.
|
|
135
182
|
*/
|
|
136
183
|
function buildSiteLocationService(registry, logger) {
|
|
137
|
-
return new SiteLocationService({
|
|
184
|
+
return new site_location_js_1.SiteLocationService({
|
|
138
185
|
store: buildSettingsStoreGateway(registry),
|
|
139
186
|
...(logger !== undefined ? { logger } : {}),
|
|
140
187
|
});
|
|
@@ -150,7 +197,7 @@ function buildSiteLocationService(registry, logger) {
|
|
|
150
197
|
* every call throws, so a caller cannot mistake a missing dependency for an
|
|
151
198
|
* empty row.
|
|
152
199
|
*/
|
|
153
|
-
|
|
200
|
+
function buildSettingsStoreGateway(registry) {
|
|
154
201
|
const resolve = () => {
|
|
155
202
|
const provider = registry?.getSingleton('settings-store') ?? null;
|
|
156
203
|
if (provider === null)
|
|
@@ -165,7 +212,7 @@ export function buildSettingsStoreGateway(registry) {
|
|
|
165
212
|
};
|
|
166
213
|
}
|
|
167
214
|
// ── network-quality ─────────────────────────────────────────────────
|
|
168
|
-
|
|
215
|
+
function buildNetworkQualityProvider(nq) {
|
|
169
216
|
return {
|
|
170
217
|
getDeviceStats: async (input) => nq.getDeviceStats(input.deviceId),
|
|
171
218
|
getAllStats: async () => nq.getAllStats(),
|
|
@@ -188,13 +235,13 @@ export function buildNetworkQualityProvider(nq) {
|
|
|
188
235
|
// can scope deliveries (broadcast vs. per-user). The cap defines
|
|
189
236
|
// `onToast` as a subscription — the codegen wires it through the
|
|
190
237
|
// `iterableSubscription` adapter and pushes raw `Toast` payloads.
|
|
191
|
-
|
|
238
|
+
function buildToastProvider(toastService, ctx) {
|
|
192
239
|
return {
|
|
193
240
|
onToast: (_input, push) => {
|
|
194
241
|
if (!toastService)
|
|
195
242
|
return () => { };
|
|
196
243
|
const userId = ctx.user?.id ?? 'anonymous';
|
|
197
|
-
const connectionId = randomUUID();
|
|
244
|
+
const connectionId = (0, node_crypto_1.randomUUID)();
|
|
198
245
|
const unsubscribe = toastService.subscribe(connectionId, userId, (toast) => push(toast));
|
|
199
246
|
return unsubscribe ?? (() => { });
|
|
200
247
|
},
|
|
@@ -202,7 +249,7 @@ export function buildToastProvider(toastService, ctx) {
|
|
|
202
249
|
}
|
|
203
250
|
/** `{ meshTransport }` for an online agent, `{}` when the hub cannot tell. */
|
|
204
251
|
function meshTransportField(nodeId) {
|
|
205
|
-
const meshTransport = getProcessNodeMeshTransport(nodeId);
|
|
252
|
+
const meshTransport = (0, system_1.getProcessNodeMeshTransport)(nodeId);
|
|
206
253
|
return meshTransport === undefined ? {} : { meshTransport };
|
|
207
254
|
}
|
|
208
255
|
function getLocalIps() {
|
|
@@ -220,11 +267,11 @@ function getLocalIps() {
|
|
|
220
267
|
return ips;
|
|
221
268
|
}
|
|
222
269
|
/** {@link computeTopology}, keeping the live entries the projection consumed. */
|
|
223
|
-
|
|
270
|
+
async function computeTopologyPass(agentRegistry, addonRegistry, getNodeRootPackage, isNodeRegistered) {
|
|
224
271
|
const [nodes, liveNodes] = await computeTopologyInternal(agentRegistry, addonRegistry, getNodeRootPackage, isNodeRegistered);
|
|
225
272
|
return { nodes, liveNodes };
|
|
226
273
|
}
|
|
227
|
-
|
|
274
|
+
async function computeTopology(agentRegistry, addonRegistry, getNodeRootPackage, isNodeRegistered) {
|
|
228
275
|
const [nodes] = await computeTopologyInternal(agentRegistry, addonRegistry, getNodeRootPackage, isNodeRegistered);
|
|
229
276
|
return nodes;
|
|
230
277
|
}
|
|
@@ -429,7 +476,7 @@ async function computeTopologyInternal(agentRegistry, addonRegistry, getNodeRoot
|
|
|
429
476
|
* running `@camstack/server` package (ServerUpdateService), agent rows from
|
|
430
477
|
* the `registerNode`-fed HubNodeRegistry (via MoleculerService).
|
|
431
478
|
*/
|
|
432
|
-
|
|
479
|
+
function createNodeRootPackageLookup(moleculer, serverUpdate) {
|
|
433
480
|
return (nodeId, isHub) => {
|
|
434
481
|
if (isHub) {
|
|
435
482
|
const running = serverUpdate?.getRunningRootPackage();
|
|
@@ -440,8 +487,8 @@ export function createNodeRootPackageLookup(moleculer, serverUpdate) {
|
|
|
440
487
|
return moleculer.getNodeRootPackage(nodeId);
|
|
441
488
|
};
|
|
442
489
|
}
|
|
443
|
-
|
|
444
|
-
const broker = asBrokerLike(moleculer.broker);
|
|
490
|
+
function buildNodesProvider(agentRegistry, moleculer, addonRegistry, getNodeRootPackage, logger) {
|
|
491
|
+
const broker = (0, system_1.asBrokerLike)(moleculer.broker);
|
|
445
492
|
return {
|
|
446
493
|
topology: async () => computeTopology(agentRegistry, addonRegistry, getNodeRootPackage, (nodeId) => moleculer.isNodeRegistered(nodeId)),
|
|
447
494
|
directory: async () => agentRegistry.listNodeDirectory(),
|
|
@@ -628,7 +675,7 @@ export function buildNodesProvider(agentRegistry, moleculer, addonRegistry, getN
|
|
|
628
675
|
* `LocalChildRegistryOptions.capUsageObserver`.
|
|
629
676
|
*/
|
|
630
677
|
getCapUsageGraph: async (input) => {
|
|
631
|
-
const reg = getCapUsageRegistry();
|
|
678
|
+
const reg = (0, system_1.getCapUsageRegistry)();
|
|
632
679
|
const stats = reg.getStats();
|
|
633
680
|
if (stats.droppedTriples > 0) {
|
|
634
681
|
// The registry is bounded (it lives on hub-main — D181). If it ever
|
|
@@ -746,11 +793,11 @@ async function runConnectionTest(ar, addonId, settings, logger) {
|
|
|
746
793
|
catch (err) {
|
|
747
794
|
logger.warn('connection test could not run', {
|
|
748
795
|
tags: { addonId },
|
|
749
|
-
meta: { phase: 'test', error: errMsg(err) },
|
|
796
|
+
meta: { phase: 'test', error: (0, types_1.errMsg)(err) },
|
|
750
797
|
});
|
|
751
798
|
return {
|
|
752
799
|
status: 'inconclusive',
|
|
753
|
-
error: `Connection test could not run: ${errMsg(err)}`,
|
|
800
|
+
error: `Connection test could not run: ${(0, types_1.errMsg)(err)}`,
|
|
754
801
|
testedBy: addonId,
|
|
755
802
|
};
|
|
756
803
|
}
|
|
@@ -780,11 +827,11 @@ async function runConnectionTest(ar, addonId, settings, logger) {
|
|
|
780
827
|
catch (err) {
|
|
781
828
|
logger.warn('broker connection test could not run', {
|
|
782
829
|
tags: { addonId },
|
|
783
|
-
meta: { phase: 'test', brokerId, error: errMsg(err) },
|
|
830
|
+
meta: { phase: 'test', brokerId, error: (0, types_1.errMsg)(err) },
|
|
784
831
|
});
|
|
785
832
|
return {
|
|
786
833
|
status: 'inconclusive',
|
|
787
|
-
error: `Broker test could not run: ${errMsg(err)}`,
|
|
834
|
+
error: `Broker test could not run: ${(0, types_1.errMsg)(err)}`,
|
|
788
835
|
testedBy: addonId,
|
|
789
836
|
};
|
|
790
837
|
}
|
|
@@ -812,8 +859,8 @@ async function runConnectionTest(ar, addonId, settings, logger) {
|
|
|
812
859
|
* Exported so the integration-markers spec can assert the recognised set
|
|
813
860
|
* without booting the whole provider factory.
|
|
814
861
|
*/
|
|
815
|
-
|
|
816
|
-
|
|
862
|
+
exports.INTEGRATION_CAP_MARKERS = new Set(['device-provider', 'device-adoption']);
|
|
863
|
+
function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegistry) {
|
|
817
864
|
const logger = loggingService.createLogger('integrations');
|
|
818
865
|
const withProcessState = (i) => ({
|
|
819
866
|
...i,
|
|
@@ -868,7 +915,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
868
915
|
tags: { addonId: input.addonId },
|
|
869
916
|
meta: { phase: 'create', status: verdict.status, testedBy: verdict.testedBy },
|
|
870
917
|
});
|
|
871
|
-
throw new TRPCError({
|
|
918
|
+
throw new server_1.TRPCError({
|
|
872
919
|
code: 'BAD_REQUEST',
|
|
873
920
|
message: verdict.error ?? `Connection test failed for '${input.addonId}'`,
|
|
874
921
|
});
|
|
@@ -887,7 +934,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
887
934
|
}
|
|
888
935
|
const integration = await reg.createIntegration(payload);
|
|
889
936
|
if (settings !== undefined && Object.keys(settings).length > 0) {
|
|
890
|
-
await writeIntegrationSettings({
|
|
937
|
+
await (0, integration_secrets_1.writeIntegrationSettings)({
|
|
891
938
|
registry: reg,
|
|
892
939
|
secrets: ownerSecrets(ar, integration.addonId),
|
|
893
940
|
onOrphaned: (refs) => logger.warn('dropped keychain refs could not be deleted', {
|
|
@@ -997,7 +1044,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
997
1044
|
// alarm panel (835) one second before the registry answered "is fixed",
|
|
998
1045
|
// and the panel came back with a new id and no state, silently breaking
|
|
999
1046
|
// every rule that named it.
|
|
1000
|
-
if (IntegrationRegistry.isFixed(integration)) {
|
|
1047
|
+
if (system_1.IntegrationRegistry.isFixed(integration)) {
|
|
1001
1048
|
throw new Error(`integration "${input.id}" is fixed — it belongs to the addon that declared it and cannot be deleted`);
|
|
1002
1049
|
}
|
|
1003
1050
|
logger.info('removing', {
|
|
@@ -1021,7 +1068,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
1021
1068
|
reg.listIntegrations(),
|
|
1022
1069
|
dm.listAll({}),
|
|
1023
1070
|
]);
|
|
1024
|
-
const stamps = planDeleteTimeStamps(input.id, integrations.map((i) => ({ id: i.id, addonId: i.addonId })), devices.map((d) => ({
|
|
1071
|
+
const stamps = (0, integration_id_backfill_1.planDeleteTimeStamps)(input.id, integrations.map((i) => ({ id: i.id, addonId: i.addonId })), devices.map((d) => ({
|
|
1025
1072
|
id: d.id,
|
|
1026
1073
|
addonId: d.addonId,
|
|
1027
1074
|
parentDeviceId: d.parentDeviceId,
|
|
@@ -1043,7 +1090,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
1043
1090
|
catch (err) {
|
|
1044
1091
|
logger.warn('legacy device claim failed (best-effort — continuing)', {
|
|
1045
1092
|
tags: { integrationId: input.id },
|
|
1046
|
-
meta: { phase: 'delete', error: errMsg(err) },
|
|
1093
|
+
meta: { phase: 'delete', error: (0, types_1.errMsg)(err) },
|
|
1047
1094
|
});
|
|
1048
1095
|
}
|
|
1049
1096
|
}
|
|
@@ -1058,7 +1105,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
1058
1105
|
catch (err) {
|
|
1059
1106
|
logger.warn('device cascade-remove failed (best-effort — continuing)', {
|
|
1060
1107
|
tags: { integrationId: input.id },
|
|
1061
|
-
meta: { phase: 'delete', error: errMsg(err) },
|
|
1108
|
+
meta: { phase: 'delete', error: (0, types_1.errMsg)(err) },
|
|
1062
1109
|
});
|
|
1063
1110
|
}
|
|
1064
1111
|
}
|
|
@@ -1073,7 +1120,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
1073
1120
|
id: `integration-deleted-${Date.now()}`,
|
|
1074
1121
|
timestamp: new Date(),
|
|
1075
1122
|
source: { type: 'integration', id: input.id },
|
|
1076
|
-
category: EventCategory.IntegrationDeleted,
|
|
1123
|
+
category: types_1.EventCategory.IntegrationDeleted,
|
|
1077
1124
|
data: {
|
|
1078
1125
|
integrationId: input.id,
|
|
1079
1126
|
addonId: integration.addonId,
|
|
@@ -1096,7 +1143,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
1096
1143
|
const caller = Reflect.get(input, 'callerAddonId');
|
|
1097
1144
|
const forOwner = typeof caller === 'string' &&
|
|
1098
1145
|
(caller === integration.addonId || ar.runnerIdFor(integration.addonId) === caller);
|
|
1099
|
-
return readIntegrationSettings({ registry: reg, secrets: forOwner ? ownerSecrets(ar, integration.addonId) : null }, { integrationId: input.id, forOwner });
|
|
1146
|
+
return (0, integration_secrets_1.readIntegrationSettings)({ registry: reg, secrets: forOwner ? ownerSecrets(ar, integration.addonId) : null }, { integrationId: input.id, forOwner });
|
|
1100
1147
|
},
|
|
1101
1148
|
setSettings: async (input) => {
|
|
1102
1149
|
const reg = requireIntegrationRegistry(ar);
|
|
@@ -1113,7 +1160,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
1113
1160
|
tags: { integrationId: input.id, addonId: integration.addonId },
|
|
1114
1161
|
meta: { phase: 'setSettings', keys: settingsKeys },
|
|
1115
1162
|
});
|
|
1116
|
-
await writeIntegrationSettings({
|
|
1163
|
+
await (0, integration_secrets_1.writeIntegrationSettings)({
|
|
1117
1164
|
registry: reg,
|
|
1118
1165
|
secrets: ownerSecrets(ar, integration.addonId),
|
|
1119
1166
|
onOrphaned: (refs) => logger.warn('dropped keychain refs could not be deleted', {
|
|
@@ -1152,7 +1199,7 @@ export function buildIntegrationsProvider(ar, eb, loggingService, capabilityRegi
|
|
|
1152
1199
|
const providerAddons = addons.filter((a) => a.process?.state !== 'failed' &&
|
|
1153
1200
|
a.manifest.capabilities?.some((c) => {
|
|
1154
1201
|
const name = typeof c === 'string' ? c : c.name;
|
|
1155
|
-
return typeof name === 'string' && INTEGRATION_CAP_MARKERS.has(name);
|
|
1202
|
+
return typeof name === 'string' && exports.INTEGRATION_CAP_MARKERS.has(name);
|
|
1156
1203
|
}));
|
|
1157
1204
|
const integrations = await reg.listIntegrations();
|
|
1158
1205
|
return providerAddons.map((addon) => {
|
|
@@ -1247,13 +1294,13 @@ function ensureCustomActionAuth(ctx, level) {
|
|
|
1247
1294
|
if (level === 'public')
|
|
1248
1295
|
return;
|
|
1249
1296
|
if (!ctx.user) {
|
|
1250
|
-
throw new TRPCError({ code: 'UNAUTHORIZED' });
|
|
1297
|
+
throw new server_1.TRPCError({ code: 'UNAUTHORIZED' });
|
|
1251
1298
|
}
|
|
1252
1299
|
if (level === 'protected')
|
|
1253
1300
|
return;
|
|
1254
1301
|
if (level === 'admin') {
|
|
1255
1302
|
if (!ctx.user.isAdmin) {
|
|
1256
|
-
throw new TRPCError({ code: 'FORBIDDEN', message: 'custom action requires admin' });
|
|
1303
|
+
throw new server_1.TRPCError({ code: 'FORBIDDEN', message: 'custom action requires admin' });
|
|
1257
1304
|
}
|
|
1258
1305
|
return;
|
|
1259
1306
|
}
|
|
@@ -1310,10 +1357,10 @@ function formatNames(names) {
|
|
|
1310
1357
|
* trusted from input).
|
|
1311
1358
|
* 5. Validate the addon's output — crash-early on a misbehaving addon.
|
|
1312
1359
|
*/
|
|
1313
|
-
|
|
1360
|
+
async function dispatchCustomAction(registry, ctx, input) {
|
|
1314
1361
|
const entry = registry.resolve(input.addonId, input.action);
|
|
1315
1362
|
if (!entry) {
|
|
1316
|
-
throw new TRPCError({ code: 'NOT_FOUND', message: describeUnresolved(registry, input) });
|
|
1363
|
+
throw new server_1.TRPCError({ code: 'NOT_FOUND', message: describeUnresolved(registry, input) });
|
|
1317
1364
|
}
|
|
1318
1365
|
ensureCustomActionAuth(ctx, entry.spec.auth);
|
|
1319
1366
|
const parsedInput = entry.spec.input.parse(input.input);
|
|
@@ -1403,7 +1450,7 @@ function buildUninstallSeam(ar, ps, broker, agentRegistry) {
|
|
|
1403
1450
|
.filter((n) => !n.isHub && !n.id.includes('/'))
|
|
1404
1451
|
.map((n) => ({ id: n.id, name: n.name, isOnline: n.isOnline }));
|
|
1405
1452
|
},
|
|
1406
|
-
agentAddons: async (nodeId) => parseAgentStatusAddons(await broker.call('$agent.status', {}, { nodeID: nodeId, timeout: AGENT_STATUS_TIMEOUT_MS })),
|
|
1453
|
+
agentAddons: async (nodeId) => parseAgentStatusAddons(await broker.call('$agent.status', {}, { nodeID: nodeId, timeout: agent_installed_packages_js_1.AGENT_STATUS_TIMEOUT_MS })),
|
|
1407
1454
|
agentUndeploy: (nodeId, request) => broker.call('$agent.undeploy', request, {
|
|
1408
1455
|
nodeID: nodeId,
|
|
1409
1456
|
timeout: AGENT_UNDEPLOY_TIMEOUT_MS,
|
|
@@ -1414,13 +1461,13 @@ function buildUninstallSeam(ar, ps, broker, agentRegistry) {
|
|
|
1414
1461
|
},
|
|
1415
1462
|
};
|
|
1416
1463
|
}
|
|
1417
|
-
|
|
1418
|
-
const broker = asBrokerLike(moleculer.broker);
|
|
1464
|
+
function buildAddonsProvider(ar, ps, ls, moleculer, configService, ctx, agentRegistry) {
|
|
1465
|
+
const broker = (0, system_1.asBrokerLike)(moleculer.broker);
|
|
1419
1466
|
const uninstallSeam = buildUninstallSeam(ar, ps, broker, agentRegistry);
|
|
1420
|
-
const frameworkAllowSet = new Set([SYSTEM_PACKAGE]);
|
|
1467
|
+
const frameworkAllowSet = new Set([addon_package_service_js_1.SYSTEM_PACKAGE]);
|
|
1421
1468
|
// Process-wide runner built once at boot (manual-boot wires its deps from the
|
|
1422
1469
|
// addon-package service + event bus). `createdBy` travels per `startJob` call.
|
|
1423
|
-
const lifecycleRunner = getLifecycleRunner();
|
|
1470
|
+
const lifecycleRunner = (0, lifecycle_runner_singleton_js_1.getLifecycleRunner)();
|
|
1424
1471
|
// Who triggered each lifecycle job from this request context.
|
|
1425
1472
|
const lifecycleCreatedBy = ctx.user?.username ?? ctx.user?.id ?? 'system';
|
|
1426
1473
|
return {
|
|
@@ -1443,7 +1490,7 @@ export function buildAddonsProvider(ar, ps, ls, moleculer, configService, ctx, a
|
|
|
1443
1490
|
}
|
|
1444
1491
|
// Agent: same roster source as listUpdates — stamp agent versions onto
|
|
1445
1492
|
// hub manifests so cards show what that node actually runs.
|
|
1446
|
-
const agentPackages = await fetchAgentInstalledPackages(broker, nodeId);
|
|
1493
|
+
const agentPackages = await (0, agent_installed_packages_js_1.fetchAgentInstalledPackages)(broker, nodeId);
|
|
1447
1494
|
const versionByPackage = new Map();
|
|
1448
1495
|
for (const pkg of agentPackages) {
|
|
1449
1496
|
versionByPackage.set(pkg.name, pkg.version);
|
|
@@ -1480,16 +1527,16 @@ export function buildAddonsProvider(ar, ps, ls, moleculer, configService, ctx, a
|
|
|
1480
1527
|
listWorkspacePackages: async () => ps.listWorkspacePackages(),
|
|
1481
1528
|
uninstallPackage: async (input) => {
|
|
1482
1529
|
try {
|
|
1483
|
-
return await uninstallPackage(uninstallSeam, input);
|
|
1530
|
+
return await (0, addon_uninstall_js_1.uninstallPackage)(uninstallSeam, input);
|
|
1484
1531
|
}
|
|
1485
1532
|
catch (err) {
|
|
1486
|
-
if (err instanceof PackageProtectedError) {
|
|
1487
|
-
throw new TRPCError({ code: 'FORBIDDEN', message: err.message });
|
|
1533
|
+
if (err instanceof addon_uninstall_js_1.PackageProtectedError) {
|
|
1534
|
+
throw new server_1.TRPCError({ code: 'FORBIDDEN', message: err.message });
|
|
1488
1535
|
}
|
|
1489
1536
|
throw err;
|
|
1490
1537
|
}
|
|
1491
1538
|
},
|
|
1492
|
-
listInstallations: async (input) => listInstallations(uninstallSeam, input.packageName),
|
|
1539
|
+
listInstallations: async (input) => (0, addon_uninstall_js_1.listInstallations)(uninstallSeam, input.packageName),
|
|
1493
1540
|
reloadPackages: async () => ps.reloadPackages(),
|
|
1494
1541
|
searchAvailable: async (input) => {
|
|
1495
1542
|
const results = await ps.searchNpm(input?.query, input?.capability);
|
|
@@ -1503,7 +1550,7 @@ export function buildAddonsProvider(ar, ps, ls, moleculer, configService, ctx, a
|
|
|
1503
1550
|
const nodeId = input.nodeId;
|
|
1504
1551
|
const updates = nodeId === undefined || isHubNode(nodeId)
|
|
1505
1552
|
? await ps.checkUpdates()
|
|
1506
|
-
: await ps.checkUpdatesForInstalled(await fetchAgentInstalledPackages(broker, nodeId), nodeId);
|
|
1553
|
+
: await ps.checkUpdatesForInstalled(await (0, agent_installed_packages_js_1.fetchAgentInstalledPackages)(broker, nodeId), nodeId);
|
|
1507
1554
|
return updates.map((u) => ({ ...u, isSystem: frameworkAllowSet.has(u.name) }));
|
|
1508
1555
|
},
|
|
1509
1556
|
updatePackage: async (input) => {
|
|
@@ -1557,7 +1604,7 @@ export function buildAddonsProvider(ar, ps, ls, moleculer, configService, ctx, a
|
|
|
1557
1604
|
if (nodeId === undefined || isHubNode(nodeId))
|
|
1558
1605
|
return ps.checkUpdates(true);
|
|
1559
1606
|
// Agent rosters carry no hub-side cache — the diff is always live.
|
|
1560
|
-
const installed = await fetchAgentInstalledPackages(broker, nodeId);
|
|
1607
|
+
const installed = await (0, agent_installed_packages_js_1.fetchAgentInstalledPackages)(broker, nodeId);
|
|
1561
1608
|
return ps.checkUpdatesForInstalled(installed, nodeId);
|
|
1562
1609
|
},
|
|
1563
1610
|
restartServer: async () => ps.restartServer(ctx.user?.username ?? ctx.user?.id),
|
|
@@ -1565,7 +1612,7 @@ export function buildAddonsProvider(ar, ps, ls, moleculer, configService, ctx, a
|
|
|
1565
1612
|
// Avoid pulling PostBootService through the cap-providers tree —
|
|
1566
1613
|
// dynamic import keeps the wiring loose and lets us read the
|
|
1567
1614
|
// static cache without a constructor dependency.
|
|
1568
|
-
const mod = await
|
|
1615
|
+
const mod = await Promise.resolve().then(() => __importStar(require('../../boot/post-boot.service.js')));
|
|
1569
1616
|
return mod.PostBootService.getLastRestart();
|
|
1570
1617
|
},
|
|
1571
1618
|
listFrameworkPackages: async () => ps.listFrameworkPackages(),
|
|
@@ -1587,7 +1634,7 @@ export function buildAddonsProvider(ar, ps, ls, moleculer, configService, ctx, a
|
|
|
1587
1634
|
// Refused (unknown cap, not a collection, unregistered provider) before
|
|
1588
1635
|
// anything is written; otherwise the new disabled-set is PERSISTED first
|
|
1589
1636
|
// and applied live only once the write landed (D675 amendment).
|
|
1590
|
-
await writeCollectionToggle(configService, ar.getCapabilityRegistry(), {
|
|
1637
|
+
await (0, capability_preference_writes_js_1.writeCollectionToggle)(configService, ar.getCapabilityRegistry(), {
|
|
1591
1638
|
capability: input.capName,
|
|
1592
1639
|
addonId: input.addonId,
|
|
1593
1640
|
enabled: input.enabled,
|
|
@@ -1624,7 +1671,7 @@ export function buildAddonsProvider(ar, ps, ls, moleculer, configService, ctx, a
|
|
|
1624
1671
|
// which has a real `$agent.deploy` path.
|
|
1625
1672
|
const offNode = (input.nodeIds ?? []).filter((id) => !isHubNode(id));
|
|
1626
1673
|
if (offNode.length > 0) {
|
|
1627
|
-
throw new TRPCError({
|
|
1674
|
+
throw new server_1.TRPCError({
|
|
1628
1675
|
code: 'BAD_REQUEST',
|
|
1629
1676
|
message: input.kind === 'uninstall'
|
|
1630
1677
|
? `The lifecycle job engine is hub-local; it cannot target ${offNode.join(', ')}. Uninstall from an agent via uninstallPackage({ packageName, nodeId }), or from every node via uninstallPackage({ packageName, everywhere: true }).`
|
|
@@ -1,50 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCapabilitiesRouter = createCapabilitiesRouter;
|
|
1
4
|
/**
|
|
2
5
|
* Capability admin router — fixed core API (not a capability).
|
|
3
6
|
*
|
|
4
7
|
* Lets admins inspect the capability registry and set system/device
|
|
5
8
|
* overrides. Wraps `CapabilityRegistry` directly (kernel primitive).
|
|
6
9
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return trpcRouter({
|
|
12
|
-
listCapabilities: adminProcedure
|
|
13
|
-
.input(z.void())
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
|
|
12
|
+
const capability_preference_writes_js_1 = require("./capability-preference-writes.js");
|
|
13
|
+
function createCapabilitiesRouter(registry, config) {
|
|
14
|
+
return (0, trpc_middleware_js_1.trpcRouter)({
|
|
15
|
+
listCapabilities: trpc_middleware_js_1.adminProcedure
|
|
16
|
+
.input(zod_1.z.void())
|
|
14
17
|
.query(() => registry?.listCapabilities() ?? []),
|
|
15
|
-
getCapability: adminProcedure.input(z.object({ name: z.string() })).query(({ input }) => {
|
|
18
|
+
getCapability: trpc_middleware_js_1.adminProcedure.input(zod_1.z.object({ name: zod_1.z.string() })).query(({ input }) => {
|
|
16
19
|
if (!registry)
|
|
17
20
|
return null;
|
|
18
21
|
return (registry.listCapabilities().find((c) => c.name === input.name) ?? null);
|
|
19
22
|
}),
|
|
20
|
-
setActiveSingleton: adminProcedure
|
|
21
|
-
.input(z.object({
|
|
22
|
-
capability: z.string(),
|
|
23
|
-
addonId: z.string(),
|
|
24
|
-
nodeId: z.string().optional(),
|
|
23
|
+
setActiveSingleton: trpc_middleware_js_1.adminProcedure
|
|
24
|
+
.input(zod_1.z.object({
|
|
25
|
+
capability: zod_1.z.string(),
|
|
26
|
+
addonId: zod_1.z.string(),
|
|
27
|
+
nodeId: zod_1.z.string().optional(),
|
|
25
28
|
}))
|
|
26
|
-
.output(z.void())
|
|
29
|
+
.output(zod_1.z.void())
|
|
27
30
|
.mutation(async ({ input }) => {
|
|
28
31
|
if (!registry)
|
|
29
32
|
throw new Error('Capability registry unavailable');
|
|
30
33
|
// Persist FIRST, under the key the boot restorer reads
|
|
31
34
|
// (`capabilities.singleton.<cap>` / `capabilities.singletonNode.<cap>.<node>`),
|
|
32
35
|
// then switch live: a write that fails changes nothing (D675 amendment).
|
|
33
|
-
await writeSingletonPreference(config, registry, {
|
|
36
|
+
await (0, capability_preference_writes_js_1.writeSingletonPreference)(config, registry, {
|
|
34
37
|
capability: input.capability,
|
|
35
38
|
addonId: input.addonId,
|
|
36
39
|
...(input.nodeId !== undefined ? { nodeId: input.nodeId } : {}),
|
|
37
40
|
});
|
|
38
41
|
}),
|
|
39
|
-
clearSingletonNodeOverride: adminProcedure
|
|
40
|
-
.input(z.object({ capability: z.string(), nodeId: z.string() }))
|
|
41
|
-
.output(z.void())
|
|
42
|
+
clearSingletonNodeOverride: trpc_middleware_js_1.adminProcedure
|
|
43
|
+
.input(zod_1.z.object({ capability: zod_1.z.string(), nodeId: zod_1.z.string() }))
|
|
44
|
+
.output(zod_1.z.void())
|
|
42
45
|
.mutation(async ({ input }) => {
|
|
43
46
|
if (!registry)
|
|
44
47
|
throw new Error('Capability registry unavailable');
|
|
45
48
|
// Persist the cleared state as null FIRST so the boot restorer doesn't
|
|
46
49
|
// re-apply a stale override; only a write that landed clears it live.
|
|
47
|
-
await config.set(singletonPreferenceKey(input.capability, input.nodeId), null);
|
|
50
|
+
await config.set((0, capability_preference_writes_js_1.singletonPreferenceKey)(input.capability, input.nodeId), null);
|
|
48
51
|
registry.clearSingletonNodeOverride(input.capability, input.nodeId);
|
|
49
52
|
}),
|
|
50
53
|
/**
|
|
@@ -54,39 +57,39 @@ export function createCapabilitiesRouter(registry, config) {
|
|
|
54
57
|
* re-enabled. Other collections are untouched. Intended as the
|
|
55
58
|
* save endpoint for a bulk multi-select UI.
|
|
56
59
|
*/
|
|
57
|
-
setCollectionEnabledProviders: adminProcedure
|
|
58
|
-
.input(z.object({
|
|
59
|
-
capability: z.string(),
|
|
60
|
-
enabledAddonIds: z.array(z.string()),
|
|
60
|
+
setCollectionEnabledProviders: trpc_middleware_js_1.adminProcedure
|
|
61
|
+
.input(zod_1.z.object({
|
|
62
|
+
capability: zod_1.z.string(),
|
|
63
|
+
enabledAddonIds: zod_1.z.array(zod_1.z.string()),
|
|
61
64
|
}))
|
|
62
|
-
.output(z.void())
|
|
65
|
+
.output(zod_1.z.void())
|
|
63
66
|
.mutation(async ({ input }) => {
|
|
64
67
|
if (!registry)
|
|
65
68
|
throw new Error('Capability registry unavailable');
|
|
66
69
|
// Persisted under `capabilities.collection.<cap>` BEFORE the live
|
|
67
70
|
// switch. It used to switch live only, so the operator's pick
|
|
68
71
|
// reverted at the next boot (D62's defect, D675 amendment).
|
|
69
|
-
await writeCollectionEnabledSet(config, registry, input.capability, input.enabledAddonIds);
|
|
72
|
+
await (0, capability_preference_writes_js_1.writeCollectionEnabledSet)(config, registry, input.capability, input.enabledAddonIds);
|
|
70
73
|
}),
|
|
71
|
-
setDeviceCapability: adminProcedure
|
|
72
|
-
.input(z.object({ deviceId: z.string(), capability: z.string(), addonId: z.string() }))
|
|
73
|
-
.output(z.void())
|
|
74
|
+
setDeviceCapability: trpc_middleware_js_1.adminProcedure
|
|
75
|
+
.input(zod_1.z.object({ deviceId: zod_1.z.string(), capability: zod_1.z.string(), addonId: zod_1.z.string() }))
|
|
76
|
+
.output(zod_1.z.void())
|
|
74
77
|
.mutation(({ input }) => {
|
|
75
78
|
if (!registry)
|
|
76
79
|
throw new Error('Capability registry unavailable');
|
|
77
80
|
registry.setDeviceOverride(input.deviceId, input.capability, input.addonId);
|
|
78
81
|
}),
|
|
79
|
-
clearDeviceCapability: adminProcedure
|
|
80
|
-
.input(z.object({ deviceId: z.string(), capability: z.string() }))
|
|
81
|
-
.output(z.void())
|
|
82
|
+
clearDeviceCapability: trpc_middleware_js_1.adminProcedure
|
|
83
|
+
.input(zod_1.z.object({ deviceId: zod_1.z.string(), capability: zod_1.z.string() }))
|
|
84
|
+
.output(zod_1.z.void())
|
|
82
85
|
.mutation(({ input }) => {
|
|
83
86
|
if (!registry)
|
|
84
87
|
throw new Error('Capability registry unavailable');
|
|
85
88
|
registry.clearDeviceOverride(input.deviceId, input.capability);
|
|
86
89
|
}),
|
|
87
|
-
getDeviceCapabilities: adminProcedure
|
|
88
|
-
.input(z.object({ deviceId: z.string() }))
|
|
89
|
-
.output(z.record(z.string(), z.string()))
|
|
90
|
+
getDeviceCapabilities: trpc_middleware_js_1.adminProcedure
|
|
91
|
+
.input(zod_1.z.object({ deviceId: zod_1.z.string() }))
|
|
92
|
+
.output(zod_1.z.record(zod_1.z.string(), zod_1.z.string()))
|
|
90
93
|
.query(({ input }) => {
|
|
91
94
|
if (!registry)
|
|
92
95
|
return {};
|