@camstack/server 1.2.594 → 1.2.596
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 +225 -219
- package/dist/api/trpc/generated-cap-routers.js +5167 -4852
- 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 +7 -7
|
@@ -1,15 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resolveDeployAction = resolveDeployAction;
|
|
37
|
+
exports.createAgentService = createAgentService;
|
|
38
|
+
const node_crypto_1 = require("node:crypto");
|
|
39
|
+
const fs = __importStar(require("node:fs"));
|
|
40
|
+
const os = __importStar(require("node:os"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const system_1 = require("@camstack/system");
|
|
43
|
+
const moleculer_1 = require("moleculer");
|
|
44
|
+
const agent_deploy_swap_js_1 = require("./agent-deploy-swap.js");
|
|
45
|
+
const agent_undeploy_js_1 = require("./agent-undeploy.js");
|
|
46
|
+
const apply_model_distribution_js_1 = require("./apply-model-distribution.js");
|
|
47
|
+
const apply_stage_dev_uploads_js_1 = require("./apply-stage-dev-uploads.js");
|
|
48
|
+
const dev_uploads_bundle_js_1 = require("../api/dev-uploads-bundle.js");
|
|
49
|
+
const fetch_bundle_from_hub_js_1 = require("./fetch-bundle-from-hub.js");
|
|
13
50
|
/**
|
|
14
51
|
* Console-backed scoped logger for the deploy swap (the only consumer in this
|
|
15
52
|
* file). `applyDeployedBundle` logs only on the rare restore-after-failed-swap
|
|
@@ -22,9 +59,9 @@ const DEFAULT_DRI_RENDER_NODE = '/dev/dri/renderD128';
|
|
|
22
59
|
* `software`; `detectionDevices` lists enabled accelerator keys.
|
|
23
60
|
*/
|
|
24
61
|
function buildDecodeDetectionSlice() {
|
|
25
|
-
const hw = resolveHwAccel();
|
|
26
|
-
const signals = probePlatform();
|
|
27
|
-
const inference = mapSignalsToInferenceHardware(signals);
|
|
62
|
+
const hw = (0, system_1.resolveHwAccel)();
|
|
63
|
+
const signals = (0, system_1.probePlatform)();
|
|
64
|
+
const inference = (0, system_1.mapSignalsToInferenceHardware)(signals);
|
|
28
65
|
const driDevice = fs.existsSync(DEFAULT_DRI_RENDER_NODE) ? DEFAULT_DRI_RENDER_NODE : null;
|
|
29
66
|
const detectionDevices = [];
|
|
30
67
|
if (inference.gpu !== null)
|
|
@@ -97,16 +134,16 @@ async function withTimeout(p, ms, fallback) {
|
|
|
97
134
|
}
|
|
98
135
|
/** Bound for the metrics snapshot inside status/health — see `withTimeout`. */
|
|
99
136
|
const METRICS_SNAPSHOT_TIMEOUT_MS = 2_000;
|
|
100
|
-
|
|
137
|
+
function resolveDeployAction(seam) {
|
|
101
138
|
const applyAndReport = async (addonId, buf) => {
|
|
102
|
-
const appliedSha256 = createHash('sha256').update(buf).digest('hex');
|
|
139
|
+
const appliedSha256 = (0, node_crypto_1.createHash)('sha256').update(buf).digest('hex');
|
|
103
140
|
const { addonDir } = await seam.applyBundle(buf);
|
|
104
141
|
seam.onApplied(addonDir);
|
|
105
142
|
return { success: true, addonId, path: addonDir, appliedSha256 };
|
|
106
143
|
};
|
|
107
144
|
return async (params) => {
|
|
108
145
|
const { addonId, source, bundle } = params;
|
|
109
|
-
if (source && isAddonDeploySource(source)) {
|
|
146
|
+
if (source && (0, system_1.isAddonDeploySource)(source)) {
|
|
110
147
|
if (source.kind === 'npm') {
|
|
111
148
|
await seam.installFromNpm(addonId, source.version);
|
|
112
149
|
// npm path installs to disk via AddonInstaller and returns no addonDir; the
|
|
@@ -223,7 +260,7 @@ function createAgentService(deps) {
|
|
|
223
260
|
// Cluster topology `engines` — supported python runtime ids
|
|
224
261
|
// (`onnx` / `openvino` / `coreml` / `edgetpu`). Was declared on
|
|
225
262
|
// AgentInfo but never reported, so every node badge stayed empty.
|
|
226
|
-
pythonRuntimes: localSupportedPythonRuntimes(),
|
|
263
|
+
pythonRuntimes: (0, system_1.localSupportedPythonRuntimes)(),
|
|
227
264
|
addons: [...deps.loadedAddons.values()].map((a) => ({
|
|
228
265
|
id: a.id,
|
|
229
266
|
status: a.status,
|
|
@@ -338,8 +375,8 @@ function createAgentService(deps) {
|
|
|
338
375
|
// event loop for the whole untar, which on a large package starves
|
|
339
376
|
// concurrent hub RPCs ($agent.status heartbeat) long enough for the
|
|
340
377
|
// hub to time them out and drop the node from topology mid-deploy.
|
|
341
|
-
const { execFile } = await
|
|
342
|
-
const { promisify } = await
|
|
378
|
+
const { execFile } = await Promise.resolve().then(() => __importStar(require('node:child_process')));
|
|
379
|
+
const { promisify } = await Promise.resolve().then(() => __importStar(require('node:util')));
|
|
343
380
|
const execFileAsync = promisify(execFile);
|
|
344
381
|
// Atomic install: extract into a temp dir then swap into place. The
|
|
345
382
|
// old body `rm`'d the live dir THEN untarred — a killed/timed-out
|
|
@@ -395,7 +432,7 @@ function createAgentService(deps) {
|
|
|
395
432
|
}
|
|
396
433
|
}
|
|
397
434
|
}
|
|
398
|
-
return applyDeployedBundle({
|
|
435
|
+
return (0, agent_deploy_swap_js_1.applyDeployedBundle)({
|
|
399
436
|
addonsDir: deps.addonsDir,
|
|
400
437
|
addonId,
|
|
401
438
|
bundle: buf,
|
|
@@ -403,7 +440,7 @@ function createAgentService(deps) {
|
|
|
403
440
|
logger: deploySwapLogger,
|
|
404
441
|
});
|
|
405
442
|
},
|
|
406
|
-
fetchBundle: (s) => fetchBundleFromHub(s),
|
|
443
|
+
fetchBundle: (s) => (0, fetch_bundle_from_hub_js_1.fetchBundleFromHub)(s),
|
|
407
444
|
// Evict every addon DECLARATION id this package contributes
|
|
408
445
|
// from `loadedAddons` so the follow-up `$agent.reload` actually
|
|
409
446
|
// re-instantiates it. `loadDeployedAddons` skips any addon
|
|
@@ -433,10 +470,10 @@ function createAgentService(deps) {
|
|
|
433
470
|
const params = ctx.params;
|
|
434
471
|
const seam = {
|
|
435
472
|
dataDir: deps.dataDir,
|
|
436
|
-
fetchBundle: (s) => fetchBundleFromHub(s),
|
|
437
|
-
unpack: unpackDevUploadVersionBundle,
|
|
473
|
+
fetchBundle: (s) => (0, fetch_bundle_from_hub_js_1.fetchBundleFromHub)(s),
|
|
474
|
+
unpack: dev_uploads_bundle_js_1.unpackDevUploadVersionBundle,
|
|
438
475
|
};
|
|
439
|
-
return applyStageDevUploads(seam, params);
|
|
476
|
+
return (0, apply_stage_dev_uploads_js_1.applyStageDevUploads)(seam, params);
|
|
440
477
|
},
|
|
441
478
|
},
|
|
442
479
|
/**
|
|
@@ -449,13 +486,13 @@ function createAgentService(deps) {
|
|
|
449
486
|
distributeModel: {
|
|
450
487
|
handler: async (ctx) => {
|
|
451
488
|
const params = ctx.params;
|
|
452
|
-
const { execFile } = await
|
|
453
|
-
const { promisify } = await
|
|
489
|
+
const { execFile } = await Promise.resolve().then(() => __importStar(require('node:child_process')));
|
|
490
|
+
const { promisify } = await Promise.resolve().then(() => __importStar(require('node:util')));
|
|
454
491
|
const execFileAsync = promisify(execFile);
|
|
455
492
|
const modelsDir = path.join(deps.dataDir, 'models');
|
|
456
493
|
const seam = {
|
|
457
494
|
modelsDir,
|
|
458
|
-
fetchBundle: (s) => fetchBundleFromHub(s),
|
|
495
|
+
fetchBundle: (s) => (0, fetch_bundle_from_hub_js_1.fetchBundleFromHub)(s),
|
|
459
496
|
extract: async (tgz, destDir) => {
|
|
460
497
|
const tmp = path.join(destDir, `.dist-${Date.now()}-${Math.random().toString(36).slice(2)}.tgz`);
|
|
461
498
|
fs.writeFileSync(tmp, tgz);
|
|
@@ -473,7 +510,7 @@ function createAgentService(deps) {
|
|
|
473
510
|
},
|
|
474
511
|
mkdirp: (dir) => fs.mkdirSync(dir, { recursive: true }),
|
|
475
512
|
};
|
|
476
|
-
return applyModelDistribution(seam, params);
|
|
513
|
+
return (0, apply_model_distribution_js_1.applyModelDistribution)(seam, params);
|
|
477
514
|
},
|
|
478
515
|
},
|
|
479
516
|
/**
|
|
@@ -487,8 +524,8 @@ function createAgentService(deps) {
|
|
|
487
524
|
undeploy: {
|
|
488
525
|
handler: async (ctx) => {
|
|
489
526
|
const { params, broker } = ctx;
|
|
490
|
-
const bkr = asBrokerLike(broker);
|
|
491
|
-
return undeployFromAgent({
|
|
527
|
+
const bkr = (0, system_1.asBrokerLike)(broker);
|
|
528
|
+
return (0, agent_undeploy_js_1.undeployFromAgent)({
|
|
492
529
|
addonsDir: deps.addonsDir,
|
|
493
530
|
loadedAddons: deps.loadedAddons,
|
|
494
531
|
bootstrapPackages: deps.bootstrapPackages ?? DEFAULT_AGENT_BOOTSTRAP_PACKAGES,
|
|
@@ -528,7 +565,7 @@ function createAgentService(deps) {
|
|
|
528
565
|
restart: {
|
|
529
566
|
handler: async (ctx) => {
|
|
530
567
|
const { params, broker } = ctx;
|
|
531
|
-
const bkr = asBrokerLike(broker);
|
|
568
|
+
const bkr = (0, system_1.asBrokerLike)(broker);
|
|
532
569
|
const { addonId } = params;
|
|
533
570
|
// Delegate to THIS agent's own `$process` service — the SAME primitive
|
|
534
571
|
// the hub uses for a local forked addon (AddonRegistryService.restartAddon
|
|
@@ -542,7 +579,7 @@ function createAgentService(deps) {
|
|
|
542
579
|
if (!result.success) {
|
|
543
580
|
// Fail loudly so the hub's `nodes.restartAddon` surfaces the real
|
|
544
581
|
// error instead of the old fire-and-forget phantom success.
|
|
545
|
-
throw new Errors.MoleculerError(`$agent.restart: process restart failed for "${addonId}": ${result.reason ?? 'unknown'}`, 500, 'AGENT_RESTART_FAILED');
|
|
582
|
+
throw new moleculer_1.Errors.MoleculerError(`$agent.restart: process restart failed for "${addonId}": ${result.reason ?? 'unknown'}`, 500, 'AGENT_RESTART_FAILED');
|
|
546
583
|
}
|
|
547
584
|
return { success: true, addonId, pid: result.pid };
|
|
548
585
|
},
|
|
@@ -577,4 +614,3 @@ function createAgentService(deps) {
|
|
|
577
614
|
},
|
|
578
615
|
};
|
|
579
616
|
}
|
|
580
|
-
export { createAgentService };
|
|
@@ -1,3 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.HANDSHAKE_TIMEOUT_MS = exports.SNIFF_TIMEOUT_MS = exports.TLS_HANDSHAKE_RECORD = void 0;
|
|
37
|
+
exports.startSniffingListener = startSniffingListener;
|
|
1
38
|
/**
|
|
2
39
|
* One port, two protocols (D856): the agent's HTTP port also speaks TLS.
|
|
3
40
|
*
|
|
@@ -17,12 +54,12 @@
|
|
|
17
54
|
* The serving certificate is swapped with `setSecureContext` - new handshakes use
|
|
18
55
|
* it at once, existing connections keep the old one, nothing restarts.
|
|
19
56
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
57
|
+
const net = __importStar(require("node:net"));
|
|
58
|
+
const node_stream_1 = require("node:stream");
|
|
59
|
+
const tls = __importStar(require("node:tls"));
|
|
60
|
+
exports.TLS_HANDSHAKE_RECORD = 0x16;
|
|
61
|
+
exports.SNIFF_TIMEOUT_MS = 10_000;
|
|
62
|
+
exports.HANDSHAKE_TIMEOUT_MS = 10_000;
|
|
26
63
|
const STALL_WARN_EVERY_MS = 60_000;
|
|
27
64
|
/** On shutdown, connections still open after this long are destroyed. */
|
|
28
65
|
const CLOSE_GRACE_MS = 2_000;
|
|
@@ -33,7 +70,7 @@ const CLOSE_GRACE_MS = 2_000;
|
|
|
33
70
|
* sniffed. This duplex replays the first chunk and then forwards the socket, and
|
|
34
71
|
* exposes the address fields the servers (and the agent's loopback check) read.
|
|
35
72
|
*/
|
|
36
|
-
class ReplayDuplex extends Duplex {
|
|
73
|
+
class ReplayDuplex extends node_stream_1.Duplex {
|
|
37
74
|
socket;
|
|
38
75
|
pending;
|
|
39
76
|
constructor(socket, first) {
|
|
@@ -105,12 +142,12 @@ class ReplayDuplex extends Duplex {
|
|
|
105
142
|
callback(error);
|
|
106
143
|
}
|
|
107
144
|
}
|
|
108
|
-
|
|
145
|
+
function startSniffingListener(options) {
|
|
109
146
|
// The serving context. A swap replaces it: every NEW handshake uses the new one,
|
|
110
147
|
// connections already established keep what they negotiated.
|
|
111
148
|
let secureContext = null;
|
|
112
149
|
let refused = 0;
|
|
113
|
-
const sniffTimeoutMs = options.sniffTimeoutMs ?? SNIFF_TIMEOUT_MS;
|
|
150
|
+
const sniffTimeoutMs = options.sniffTimeoutMs ?? exports.SNIFF_TIMEOUT_MS;
|
|
114
151
|
/** Every live connection, so shutdown can end them instead of waiting on idle keep-alives. */
|
|
115
152
|
const live = new Set();
|
|
116
153
|
const track = (socket) => {
|
|
@@ -121,7 +158,7 @@ export function startSniffingListener(options) {
|
|
|
121
158
|
// with how many were suppressed.
|
|
122
159
|
let lastStallWarnAt = 0;
|
|
123
160
|
let suppressedStalls = 0;
|
|
124
|
-
const handshakeTimeoutMs = options.handshakeTimeoutMs ?? HANDSHAKE_TIMEOUT_MS;
|
|
161
|
+
const handshakeTimeoutMs = options.handshakeTimeoutMs ?? exports.HANDSHAKE_TIMEOUT_MS;
|
|
125
162
|
const setMaterial = (material) => {
|
|
126
163
|
try {
|
|
127
164
|
secureContext = tls.createSecureContext({ key: material.keyPem, cert: material.certPem });
|
|
@@ -184,7 +221,7 @@ export function startSniffingListener(options) {
|
|
|
184
221
|
socket.once('data', (chunk) => {
|
|
185
222
|
clearTimeout(timer);
|
|
186
223
|
socket.pause();
|
|
187
|
-
if (chunk[0] === TLS_HANDSHAKE_RECORD) {
|
|
224
|
+
if (chunk[0] === exports.TLS_HANDSHAKE_RECORD) {
|
|
188
225
|
if (secureContext === null) {
|
|
189
226
|
refused += 1;
|
|
190
227
|
options.onTlsRefused?.();
|
|
@@ -1,6 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.undeployFromAgent = undeployFromAgent;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const agent_group_runner_js_1 = require("./agent-group-runner.js");
|
|
4
40
|
function capName(cap) {
|
|
5
41
|
return typeof cap === 'string' ? cap : cap.name;
|
|
6
42
|
}
|
|
@@ -19,7 +55,7 @@ function resolveTarget(seam, request) {
|
|
|
19
55
|
? seam.loadedAddons.get(request.addonId)?.packageName
|
|
20
56
|
: undefined);
|
|
21
57
|
const packageDir = packageName !== undefined ? packageDirFor(seam.addonsDir, packageName) : null;
|
|
22
|
-
const manifest = packageDir !== null ? readPackageManifestAddons(packageDir) : null;
|
|
58
|
+
const manifest = packageDir !== null ? (0, agent_group_runner_js_1.readPackageManifestAddons)(packageDir) : null;
|
|
23
59
|
const capsByAddon = new Map();
|
|
24
60
|
let protectedBy = null;
|
|
25
61
|
for (const decl of manifest?.declarations ?? []) {
|
|
@@ -134,7 +170,7 @@ function removeDirs(seam, request, target) {
|
|
|
134
170
|
return removed;
|
|
135
171
|
}
|
|
136
172
|
/** Run one `$agent.undeploy`. Never throws for a refusal — it answers `refused`. */
|
|
137
|
-
|
|
173
|
+
async function undeployFromAgent(seam, request) {
|
|
138
174
|
const target = resolveTarget(seam, request);
|
|
139
175
|
const scope = request.packageName !== undefined ? 'package' : 'addon';
|
|
140
176
|
const base = {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADDON_HUB_UPDATE_UNAVAILABLE_REASON = exports.ADDON_UPDATE_UNAVAILABLE_REASON = exports.SERVER_UPDATE_UNAVAILABLE_REASON = exports.APPLY_ALREADY_RUNNING_MESSAGE = void 0;
|
|
4
|
+
exports.createAgentServerUpdateControls = createAgentServerUpdateControls;
|
|
5
|
+
exports.registerAgentUpdateRoutes = registerAgentUpdateRoutes;
|
|
6
|
+
const agent_hub_addon_update_js_1 = require("./agent-hub-addon-update.js");
|
|
2
7
|
/** The message a second concurrent apply gets. Exported so the test names it once. */
|
|
3
|
-
|
|
8
|
+
exports.APPLY_ALREADY_RUNNING_MESSAGE = 'Refused: an update is already in flight on this node.';
|
|
4
9
|
/**
|
|
5
10
|
* Bind the routes' controls to a real update engine.
|
|
6
11
|
*
|
|
@@ -9,7 +14,7 @@ export const APPLY_ALREADY_RUNNING_MESSAGE = 'Refused: an update is already in f
|
|
|
9
14
|
* not happen, and both of these arrive on a different tick from the poll that
|
|
10
15
|
* has to render them.
|
|
11
16
|
*/
|
|
12
|
-
|
|
17
|
+
function createAgentServerUpdateControls(engine, onError) {
|
|
13
18
|
let lastCheckError = null;
|
|
14
19
|
let lastApply = null;
|
|
15
20
|
let applyInFlight = false;
|
|
@@ -27,7 +32,7 @@ export function createAgentServerUpdateControls(engine, onError) {
|
|
|
27
32
|
},
|
|
28
33
|
applyLatest: () => {
|
|
29
34
|
if (applyInFlight) {
|
|
30
|
-
return { started: false, message: APPLY_ALREADY_RUNNING_MESSAGE };
|
|
35
|
+
return { started: false, message: exports.APPLY_ALREADY_RUNNING_MESSAGE };
|
|
31
36
|
}
|
|
32
37
|
applyInFlight = true;
|
|
33
38
|
lastApply = null;
|
|
@@ -59,11 +64,11 @@ export function createAgentServerUpdateControls(engine, onError) {
|
|
|
59
64
|
// Routes
|
|
60
65
|
// ---------------------------------------------------------------------------
|
|
61
66
|
/** Why the framework card renders empty when nothing was wired. */
|
|
62
|
-
|
|
67
|
+
exports.SERVER_UPDATE_UNAVAILABLE_REASON = 'Framework updates are not available on this agent build.';
|
|
63
68
|
/** Why the addon report renders empty when nothing was wired. */
|
|
64
|
-
|
|
69
|
+
exports.ADDON_UPDATE_UNAVAILABLE_REASON = 'The addon roster is not available on this agent build.';
|
|
65
70
|
/** Why the Update action is absent when the hub channel was not wired. */
|
|
66
|
-
|
|
71
|
+
exports.ADDON_HUB_UPDATE_UNAVAILABLE_REASON = 'Updating an addon through the hub is not available on this agent build.';
|
|
67
72
|
async function withHubVersions(report, hub) {
|
|
68
73
|
const versions = hub === undefined ? null : await hub.getHubVersions();
|
|
69
74
|
const progress = hub?.progress();
|
|
@@ -75,7 +80,7 @@ async function withHubVersions(report, hub) {
|
|
|
75
80
|
return {
|
|
76
81
|
...entry,
|
|
77
82
|
hubVersion,
|
|
78
|
-
behindHub: isBehindHub(entry.installedVersion, hubVersion),
|
|
83
|
+
behindHub: (0, agent_hub_addon_update_js_1.isBehindHub)(entry.installedVersion, hubVersion),
|
|
79
84
|
update: progress?.get(entry.packageName) ?? null,
|
|
80
85
|
};
|
|
81
86
|
}),
|
|
@@ -85,38 +90,38 @@ async function withHubVersions(report, hub) {
|
|
|
85
90
|
* Mount the update routes on an already-built agent HTTP server. Called from
|
|
86
91
|
* `createAgentHttpServer` AFTER the auth hook, so every path here inherits it.
|
|
87
92
|
*/
|
|
88
|
-
|
|
93
|
+
function registerAgentUpdateRoutes(app, controls) {
|
|
89
94
|
const server = controls.server;
|
|
90
95
|
const addons = controls.addons;
|
|
91
96
|
app.get('/api/agent/server-update', async () => {
|
|
92
97
|
if (server === undefined) {
|
|
93
|
-
return { available: false, reason: SERVER_UPDATE_UNAVAILABLE_REASON };
|
|
98
|
+
return { available: false, reason: exports.SERVER_UPDATE_UNAVAILABLE_REASON };
|
|
94
99
|
}
|
|
95
100
|
return { available: true, ...(await server.getView()) };
|
|
96
101
|
});
|
|
97
102
|
app.post('/api/agent/server-update/check', async (_req, reply) => {
|
|
98
103
|
if (server === undefined) {
|
|
99
|
-
return reply.status(503).send({ error: SERVER_UPDATE_UNAVAILABLE_REASON });
|
|
104
|
+
return reply.status(503).send({ error: exports.SERVER_UPDATE_UNAVAILABLE_REASON });
|
|
100
105
|
}
|
|
101
106
|
return server.check();
|
|
102
107
|
});
|
|
103
108
|
// No request body is read: the target is always registry `latest`.
|
|
104
109
|
app.post('/api/agent/server-update/apply', async (_req, reply) => {
|
|
105
110
|
if (server === undefined) {
|
|
106
|
-
return reply.status(503).send({ error: SERVER_UPDATE_UNAVAILABLE_REASON });
|
|
111
|
+
return reply.status(503).send({ error: exports.SERVER_UPDATE_UNAVAILABLE_REASON });
|
|
107
112
|
}
|
|
108
113
|
return server.applyLatest();
|
|
109
114
|
});
|
|
110
115
|
app.get('/api/agent/addon-updates', async () => {
|
|
111
116
|
if (addons === undefined) {
|
|
112
|
-
return { available: false, reason: ADDON_UPDATE_UNAVAILABLE_REASON };
|
|
117
|
+
return { available: false, reason: exports.ADDON_UPDATE_UNAVAILABLE_REASON };
|
|
113
118
|
}
|
|
114
119
|
const report = await addons.getReport();
|
|
115
120
|
return { available: true, ...(await withHubVersions(report, addons.hub)) };
|
|
116
121
|
});
|
|
117
122
|
app.post('/api/agent/addon-updates/update', async (req, reply) => {
|
|
118
123
|
if (addons?.hub === undefined) {
|
|
119
|
-
return reply.status(503).send({ error: ADDON_HUB_UPDATE_UNAVAILABLE_REASON });
|
|
124
|
+
return reply.status(503).send({ error: exports.ADDON_HUB_UPDATE_UNAVAILABLE_REASON });
|
|
120
125
|
}
|
|
121
126
|
const packageName = req.body?.packageName;
|
|
122
127
|
if (typeof packageName !== 'string' || packageName.length === 0) {
|