@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,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Extracted, testable helper for registering the agent-side cap-dispatch
|
|
3
4
|
* service with a Moleculer broker.
|
|
@@ -6,7 +7,9 @@
|
|
|
6
7
|
* (undefined → no-op; defined → create service) can be exercised in a unit
|
|
7
8
|
* test independently of the full bootstrap lifecycle.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.registerAgentCapDispatch = registerAgentCapDispatch;
|
|
12
|
+
const agent_cap_dispatch_service_js_1 = require("./agent-cap-dispatch-service.js");
|
|
10
13
|
// ---------------------------------------------------------------------------
|
|
11
14
|
// Exported helper
|
|
12
15
|
// ---------------------------------------------------------------------------
|
|
@@ -27,8 +30,8 @@ import { createAgentCapDispatchService } from './agent-cap-dispatch-service.js';
|
|
|
27
30
|
* of failing with "no provider".
|
|
28
31
|
* @param logger Optional scoped logger forwarded to the service.
|
|
29
32
|
*/
|
|
30
|
-
|
|
33
|
+
function registerAgentCapDispatch(registrar, agentUdsRegistry, inProcessLookup, logger) {
|
|
31
34
|
if (agentUdsRegistry === undefined)
|
|
32
35
|
return;
|
|
33
|
-
registrar.createService(createAgentCapDispatchService(registrar.nodeID, agentUdsRegistry, inProcessLookup, logger));
|
|
36
|
+
registrar.createService((0, agent_cap_dispatch_service_js_1.createAgentCapDispatchService)(registrar.nodeID, agentUdsRegistry, inProcessLookup, logger));
|
|
34
37
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SerialQueueTimeoutError = void 0;
|
|
4
|
+
exports.createSerialQueue = createSerialQueue;
|
|
5
|
+
class SerialQueueTimeoutError extends Error {
|
|
2
6
|
deadlineMs;
|
|
3
7
|
constructor(deadlineMs) {
|
|
4
8
|
super(`the job did not finish within ${deadlineMs} ms and was abandoned`);
|
|
@@ -6,12 +10,13 @@ export class SerialQueueTimeoutError extends Error {
|
|
|
6
10
|
this.name = 'SerialQueueTimeoutError';
|
|
7
11
|
}
|
|
8
12
|
}
|
|
13
|
+
exports.SerialQueueTimeoutError = SerialQueueTimeoutError;
|
|
9
14
|
function defaultSetTimer(fn, ms) {
|
|
10
15
|
const timer = setTimeout(fn, ms);
|
|
11
16
|
timer.unref?.();
|
|
12
17
|
return { cancel: () => clearTimeout(timer) };
|
|
13
18
|
}
|
|
14
|
-
|
|
19
|
+
function createSerialQueue(job, options = {}) {
|
|
15
20
|
let tail = Promise.resolve();
|
|
16
21
|
const setTimer = options.setTimer ?? defaultSetTimer;
|
|
17
22
|
const guarded = () => {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderAgentStatusPage = renderAgentStatusPage;
|
|
1
4
|
function formatUptime(seconds) {
|
|
2
5
|
const days = Math.floor(seconds / 86400);
|
|
3
6
|
const hours = Math.floor((seconds % 86400) / 3600);
|
|
@@ -22,7 +25,7 @@ function escapeHtml(str) {
|
|
|
22
25
|
* No React, no build system. Pure HTML + inline CSS.
|
|
23
26
|
* Designed for local debugging only.
|
|
24
27
|
*/
|
|
25
|
-
|
|
28
|
+
function renderAgentStatusPage(data) {
|
|
26
29
|
const statusColor = data.connected ? '#22c55e' : '#ef4444';
|
|
27
30
|
const statusText = data.connected ? 'Connected' : 'Disconnected';
|
|
28
31
|
const memUsedMB = data.memoryTotalMB - data.memoryFreeMB;
|
package/dist/api/addon-upload.js
CHANGED
|
@@ -1,14 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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.getDeployStageRegistry = getDeployStageRegistry;
|
|
37
|
+
exports.registerDeployBundleRoute = registerDeployBundleRoute;
|
|
38
|
+
exports.buildHubHttpSource = buildHubHttpSource;
|
|
39
|
+
exports.registerAddonUploadRoute = registerAddonUploadRoute;
|
|
40
|
+
const fs = __importStar(require("node:fs"));
|
|
41
|
+
const os = __importStar(require("node:os"));
|
|
42
|
+
const path = __importStar(require("node:path"));
|
|
43
|
+
const addon_package_service_js_1 = require("../core/addon/addon-package.service.js");
|
|
44
|
+
const index_js_1 = require("../server-root/index.js");
|
|
45
|
+
const agent_addon_delivery_js_1 = require("./agent-addon-delivery.js");
|
|
46
|
+
const deploy_stage_registry_js_1 = require("./deploy-stage-registry.js");
|
|
47
|
+
const tarball_manifest_js_1 = require("./tarball-manifest.js");
|
|
48
|
+
const upload_auth_js_1 = require("./upload-auth.js");
|
|
49
|
+
const deployStageRegistry = new deploy_stage_registry_js_1.DeployStageRegistry();
|
|
50
|
+
function getDeployStageRegistry() {
|
|
12
51
|
return deployStageRegistry;
|
|
13
52
|
}
|
|
14
53
|
/**
|
|
@@ -16,7 +55,7 @@ export function getDeployStageRegistry() {
|
|
|
16
55
|
* the per-deploy token minted in `DeployStageRegistry.stage()` and carried to
|
|
17
56
|
* the agent in the `$agent.deploy` `hub-http` source descriptor.
|
|
18
57
|
*/
|
|
19
|
-
|
|
58
|
+
function registerDeployBundleRoute(fastify) {
|
|
20
59
|
// `compress: false` — never gzip/brotli this route. The body is a large
|
|
21
60
|
// binary tarball (addon bundle / model artifact) the agent pulls with undici
|
|
22
61
|
// + sha256 verification. With global @fastify/compress on, the 1–2MB response
|
|
@@ -63,7 +102,7 @@ async function resolveBaseUrlOrReason(resolve) {
|
|
|
63
102
|
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
64
103
|
}
|
|
65
104
|
}
|
|
66
|
-
|
|
105
|
+
function buildHubHttpSource(buffer, hubBaseUrl) {
|
|
67
106
|
const staged = getDeployStageRegistry().stage(buffer);
|
|
68
107
|
return {
|
|
69
108
|
kind: 'hub-http',
|
|
@@ -73,7 +112,7 @@ export function buildHubHttpSource(buffer, hubBaseUrl) {
|
|
|
73
112
|
bytes: staged.bytes,
|
|
74
113
|
};
|
|
75
114
|
}
|
|
76
|
-
|
|
115
|
+
async function registerAddonUploadRoute(fastify, addonBridge, authService, moleculer, addonRegistry, addonPackageService, logger,
|
|
77
116
|
/**
|
|
78
117
|
* The base URL agents pull the staged bundle from — the `local-network`
|
|
79
118
|
* cap's cluster address (`hub-cluster-url.ts`), resolved per delivery.
|
|
@@ -86,7 +125,7 @@ resolveClusterBaseUrl,
|
|
|
86
125
|
* not build one; `main.ts` always passes the AgentRegistryService's.
|
|
87
126
|
*/
|
|
88
127
|
deliveryLedger) {
|
|
89
|
-
await fastify.register(
|
|
128
|
+
await fastify.register(Promise.resolve().then(() => __importStar(require('@fastify/multipart'))), {
|
|
90
129
|
limits: { fileSize: MAX_UPLOAD_BYTES },
|
|
91
130
|
});
|
|
92
131
|
registerDeployBundleRoute(fastify);
|
|
@@ -94,7 +133,7 @@ deliveryLedger) {
|
|
|
94
133
|
// Auth chain (shared with /api/server-upload): JWT (isAdmin) OR scoped
|
|
95
134
|
// token whose scopes grant `create` access on the `addons` capability.
|
|
96
135
|
// See upload-auth.ts for the full rationale.
|
|
97
|
-
const auth = await authorizeUploadRequest({
|
|
136
|
+
const auth = await (0, upload_auth_js_1.authorizeUploadRequest)({
|
|
98
137
|
authHeader: request.headers.authorization,
|
|
99
138
|
authService,
|
|
100
139
|
addonRegistry,
|
|
@@ -106,7 +145,7 @@ deliveryLedger) {
|
|
|
106
145
|
if (!data) {
|
|
107
146
|
return reply.status(400).send({ error: 'No file uploaded' });
|
|
108
147
|
}
|
|
109
|
-
if (!isTarballFilename(data.filename)) {
|
|
148
|
+
if (!(0, tarball_manifest_js_1.isTarballFilename)(data.filename)) {
|
|
110
149
|
return reply.status(400).send({ error: 'File must be a .tgz or .tar.gz archive' });
|
|
111
150
|
}
|
|
112
151
|
// Drain the file part FIRST. `data.fields` is the plugin's live `body`
|
|
@@ -131,7 +170,7 @@ deliveryLedger) {
|
|
|
131
170
|
// Gate: reject archives that don't expose a parseable package.json with
|
|
132
171
|
// name + version. The hub installer did this implicitly via npm; the
|
|
133
172
|
// agent path would otherwise fail mid-extraction with no clean rollback.
|
|
134
|
-
const manifest = readTarballManifest(buffer, data.filename);
|
|
173
|
+
const manifest = (0, tarball_manifest_js_1.readTarballManifest)(buffer, data.filename);
|
|
135
174
|
if (!manifest) {
|
|
136
175
|
return reply.status(400).send({
|
|
137
176
|
error: 'Tarball missing or malformed package/package.json (name + version required)',
|
|
@@ -217,7 +256,7 @@ async function propagateToAgents(moleculer, logger, packageName, buffer, resolve
|
|
|
217
256
|
// yet. Wiring it later must also make the agent's npm path evict the addon's
|
|
218
257
|
// declaration ids before `$agent.reload`, otherwise an npm update pins the
|
|
219
258
|
// stale version.
|
|
220
|
-
results.push(await deliverAddonToAgent({
|
|
259
|
+
results.push(await (0, agent_addon_delivery_js_1.deliverAddonToAgent)({
|
|
221
260
|
broker,
|
|
222
261
|
logger,
|
|
223
262
|
nodeId,
|
|
@@ -280,7 +319,7 @@ async function installToHub(reply, addonBridge, addonRegistry, addonPackageServi
|
|
|
280
319
|
// settings. The new code is now on disk; a clean server restart reloads it
|
|
281
320
|
// and re-runs boot initialization. The 10s restart grace lets this response
|
|
282
321
|
// flush before the process exits, so the CLI sees a clean confirmation.
|
|
283
|
-
if (isFrameworkPackage(result.name)) {
|
|
322
|
+
if ((0, addon_package_service_js_1.isFrameworkPackage)(result.name)) {
|
|
284
323
|
// Framework live-sync is GONE (superseded by the runtime-updatable root
|
|
285
324
|
// package — the hub main + its framework deps now update as ONE
|
|
286
325
|
// `@camstack/server` closure via the `server-management` cap).
|
|
@@ -290,7 +329,7 @@ async function installToHub(reply, addonBridge, addonRegistry, addonPackageServi
|
|
|
290
329
|
// BEFORE uploading — a plain restart loads the new code, no mirror
|
|
291
330
|
// needed. `camstack deploy packages/system` therefore keeps working in
|
|
292
331
|
// dev unchanged.
|
|
293
|
-
const workspaceRoot = detectWorkspaceRoot(__dirname);
|
|
332
|
+
const workspaceRoot = (0, index_js_1.detectWorkspaceRoot)(__dirname);
|
|
294
333
|
if (workspaceRoot !== null) {
|
|
295
334
|
logger.info('framework package deployed (workspace) — scheduling server restart', {
|
|
296
335
|
meta: { packageName: result.name, packageVersion: result.version, workspaceRoot },
|
|
@@ -407,7 +446,7 @@ async function deployToAgent(reply, moleculer, logger, nodeId, addonId, buffer,
|
|
|
407
446
|
// yet. Wiring it later must also make the agent's npm path evict the addon's
|
|
408
447
|
// declaration ids before `$agent.reload`, otherwise an npm update pins the
|
|
409
448
|
// stale version.
|
|
410
|
-
const result = await deliverAddonToAgent({
|
|
449
|
+
const result = await (0, agent_addon_delivery_js_1.deliverAddonToAgent)({
|
|
411
450
|
broker: moleculer.broker,
|
|
412
451
|
logger,
|
|
413
452
|
nodeId,
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AGENT_RELOAD_TIMEOUT_MS = exports.AGENT_DEPLOY_CONTROL_TIMEOUT_MS = void 0;
|
|
4
|
+
exports.isAgentDeployResponse = isAgentDeployResponse;
|
|
5
|
+
exports.deliverAddonToAgent = deliverAddonToAgent;
|
|
1
6
|
/**
|
|
2
7
|
* Delivering an addon bundle to an agent — the single implementation.
|
|
3
8
|
*
|
|
@@ -40,13 +45,13 @@
|
|
|
40
45
|
* exactly like a deploy that worked. `agent-deploy-timeout.spec.ts` pins the
|
|
41
46
|
* relationship so they cannot separate again.
|
|
42
47
|
*/
|
|
43
|
-
|
|
48
|
+
exports.AGENT_DEPLOY_CONTROL_TIMEOUT_MS = 300_000;
|
|
44
49
|
/**
|
|
45
50
|
* `$agent.reload` re-forks group runners and re-registers their capabilities —
|
|
46
51
|
* legitimately slow on a node with a Python inference pool.
|
|
47
52
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
exports.AGENT_RELOAD_TIMEOUT_MS = 60_000;
|
|
54
|
+
function isAgentDeployResponse(value) {
|
|
50
55
|
if (value === null || typeof value !== 'object')
|
|
51
56
|
return false;
|
|
52
57
|
const v = value;
|
|
@@ -74,7 +79,7 @@ function readLoaded(value) {
|
|
|
74
79
|
* Never throws: a per-node failure is returned so one unreachable agent cannot
|
|
75
80
|
* abort a cluster propagation or the hub's own install.
|
|
76
81
|
*/
|
|
77
|
-
|
|
82
|
+
async function deliverAddonToAgent(args) {
|
|
78
83
|
const { broker, logger, nodeId, packageName, source } = args;
|
|
79
84
|
// Opened BEFORE the first byte and closed in the `finally` below — the window
|
|
80
85
|
// must cover `$agent.deploy` (which evicts the package's declaration ids) AND
|
|
@@ -82,7 +87,7 @@ export async function deliverAddonToAgent(args) {
|
|
|
82
87
|
// happy path.
|
|
83
88
|
const closeWindow = args.deliveryLedger?.begin(nodeId, packageName);
|
|
84
89
|
try {
|
|
85
|
-
const deployRaw = await broker.call('$agent.deploy', { addonId: packageName, source }, { nodeID: nodeId, timeout: AGENT_DEPLOY_CONTROL_TIMEOUT_MS });
|
|
90
|
+
const deployRaw = await broker.call('$agent.deploy', { addonId: packageName, source }, { nodeID: nodeId, timeout: exports.AGENT_DEPLOY_CONTROL_TIMEOUT_MS });
|
|
86
91
|
if (!isAgentDeployResponse(deployRaw)) {
|
|
87
92
|
logger.warn('agent deploy: malformed deploy response', {
|
|
88
93
|
meta: { nodeId, packageName },
|
|
@@ -114,7 +119,7 @@ export async function deliverAddonToAgent(args) {
|
|
|
114
119
|
});
|
|
115
120
|
// Reload. Without this the deploy is write-to-disk-only and the node keeps
|
|
116
121
|
// running the previous dist — the whole point of this module.
|
|
117
|
-
const reloadRaw = await broker.call('$agent.reload', {}, { nodeID: nodeId, timeout: AGENT_RELOAD_TIMEOUT_MS });
|
|
122
|
+
const reloadRaw = await broker.call('$agent.reload', {}, { nodeID: nodeId, timeout: exports.AGENT_RELOAD_TIMEOUT_MS });
|
|
118
123
|
const loaded = readLoaded(reloadRaw);
|
|
119
124
|
if (loaded.length === 0) {
|
|
120
125
|
// Not fatal — a reload can legitimately find nothing to (re)instantiate
|
package/dist/api/auth-whoami.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAuthWhoamiRoute = registerAuthWhoamiRoute;
|
|
4
|
+
async function registerAuthWhoamiRoute(fastify, authService, addonRegistry) {
|
|
2
5
|
fastify.get('/api/auth/whoami', async (request, reply) => {
|
|
3
6
|
const authHeader = request.headers.authorization;
|
|
4
7
|
if (!authHeader) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* backup-download-pump — a backup archive is streamed at the pace the client
|
|
3
4
|
* READS it, and a client that stops reading is cut, never buffered until
|
|
@@ -42,15 +43,18 @@
|
|
|
42
43
|
* `warn` for a cut client or a failed source. The route previously logged
|
|
43
44
|
* nothing on success and `console.error` on failure.
|
|
44
45
|
*/
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.BACKUP_DOWNLOAD_DRAIN_GRACE_MS = exports.BACKUP_DOWNLOAD_CHUNK_BYTES = void 0;
|
|
48
|
+
exports.pumpDownload = pumpDownload;
|
|
45
49
|
/** Bytes read from the storage cap per round trip; one chunk is the most the response holds. */
|
|
46
|
-
|
|
50
|
+
exports.BACKUP_DOWNLOAD_CHUNK_BYTES = 8 * 1024 * 1024;
|
|
47
51
|
/**
|
|
48
52
|
* How long a `write` may stay unacknowledged by `drain` before the client is
|
|
49
53
|
* cut. A `ServerResponse` signals `drain` once the socket has taken its
|
|
50
54
|
* buffer (16 KiB by default): a client that cannot take 16 KiB in a minute is
|
|
51
55
|
* under 0.3 KB/s — not a slow link, an absent reader.
|
|
52
56
|
*/
|
|
53
|
-
|
|
57
|
+
exports.BACKUP_DOWNLOAD_DRAIN_GRACE_MS = 60_000;
|
|
54
58
|
function waitForDrain(sink, graceMs) {
|
|
55
59
|
return new Promise((resolve) => {
|
|
56
60
|
const settle = (outcome) => {
|
|
@@ -74,10 +78,10 @@ function errorOf(err) {
|
|
|
74
78
|
* next only once the socket has taken the previous. Never throws: every exit
|
|
75
79
|
* is a {@link PumpResult} the caller can log.
|
|
76
80
|
*/
|
|
77
|
-
|
|
81
|
+
async function pumpDownload(options) {
|
|
78
82
|
const { sizeBytes, read, sink } = options;
|
|
79
|
-
const chunkBytes = options.chunkBytes ?? BACKUP_DOWNLOAD_CHUNK_BYTES;
|
|
80
|
-
const graceMs = options.graceMs ?? BACKUP_DOWNLOAD_DRAIN_GRACE_MS;
|
|
83
|
+
const chunkBytes = options.chunkBytes ?? exports.BACKUP_DOWNLOAD_CHUNK_BYTES;
|
|
84
|
+
const graceMs = options.graceMs ?? exports.BACKUP_DOWNLOAD_DRAIN_GRACE_MS;
|
|
81
85
|
const now = options.now ?? (() => Date.now());
|
|
82
86
|
const startedAt = now();
|
|
83
87
|
let offset = 0;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerBackupDownloadRoute = registerBackupDownloadRoute;
|
|
4
|
+
const backup_download_pump_js_1 = require("./backup-download-pump.js");
|
|
5
|
+
const client_ip_js_1 = require("./trpc/client-ip.js");
|
|
3
6
|
/** Strip what would break the `Content-Disposition` header. Whitespace is fine. */
|
|
4
7
|
function safeAttachmentName(name) {
|
|
5
8
|
return name.replace(/[\r\n"]/g, '_');
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
function registerBackupDownloadRoute(fastify, options) {
|
|
8
11
|
const { verifier, capabilities, logger } = options;
|
|
9
|
-
const chunkBytes = options.chunkBytes ?? BACKUP_DOWNLOAD_CHUNK_BYTES;
|
|
10
|
-
const graceMs = options.graceMs ?? BACKUP_DOWNLOAD_DRAIN_GRACE_MS;
|
|
12
|
+
const chunkBytes = options.chunkBytes ?? backup_download_pump_js_1.BACKUP_DOWNLOAD_CHUNK_BYTES;
|
|
13
|
+
const graceMs = options.graceMs ?? backup_download_pump_js_1.BACKUP_DOWNLOAD_DRAIN_GRACE_MS;
|
|
11
14
|
fastify.get('/api/backup/download/:locationId/:archiveId', async (request, reply) => {
|
|
12
15
|
const authHeader = request.headers.authorization;
|
|
13
16
|
if (!authHeader) {
|
|
@@ -57,13 +60,13 @@ export function registerBackupDownloadRoute(fastify, options) {
|
|
|
57
60
|
archiveId,
|
|
58
61
|
filename: archive.filename,
|
|
59
62
|
sizeBytes,
|
|
60
|
-
ip: extractClientIp(request.raw) ?? '(unidentified)',
|
|
63
|
+
ip: (0, client_ip_js_1.extractClientIp)(request.raw) ?? '(unidentified)',
|
|
61
64
|
chunkBytes,
|
|
62
65
|
graceMs,
|
|
63
66
|
};
|
|
64
67
|
let result;
|
|
65
68
|
try {
|
|
66
|
-
result = await pumpDownload({
|
|
69
|
+
result = await (0, backup_download_pump_js_1.pumpDownload)({
|
|
67
70
|
sizeBytes,
|
|
68
71
|
chunkBytes,
|
|
69
72
|
graceMs,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAddonSettingsRouter = createAddonSettingsRouter;
|
|
1
4
|
/**
|
|
2
5
|
* `addonSettingsRaw` — admin read of an addon's RAW stored settings.
|
|
3
6
|
*
|
|
@@ -53,21 +56,21 @@
|
|
|
53
56
|
* merging (defaults → global → per-device). That happens on the consumer side
|
|
54
57
|
* where the addon's `ConfigUISchema` is available.
|
|
55
58
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const AddonSettingsRecordSchema = z.record(z.string(), z.unknown());
|
|
61
|
-
const AddonIdInputSchema = z.object({
|
|
62
|
-
addonId: z.string().min(1),
|
|
59
|
+
const server_1 = require("@trpc/server");
|
|
60
|
+
const system_1 = require("@camstack/system");
|
|
61
|
+
const zod_1 = require("zod");
|
|
62
|
+
const trpc_middleware_js_1 = require("../trpc/trpc.middleware.js");
|
|
63
|
+
const AddonSettingsRecordSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.unknown());
|
|
64
|
+
const AddonIdInputSchema = zod_1.z.object({
|
|
65
|
+
addonId: zod_1.z.string().min(1),
|
|
63
66
|
});
|
|
64
67
|
/**
|
|
65
68
|
* `deviceId` stays a STRING on the wire (the shape callers already send) but
|
|
66
69
|
* must be a numeric device id: the per-device rows are keyed by the numeric id.
|
|
67
70
|
*/
|
|
68
|
-
const AddonDeviceInputSchema = z.object({
|
|
69
|
-
addonId: z.string().min(1),
|
|
70
|
-
deviceId: z.string().regex(/^\d+$/, 'deviceId must be a numeric device id'),
|
|
71
|
+
const AddonDeviceInputSchema = zod_1.z.object({
|
|
72
|
+
addonId: zod_1.z.string().min(1),
|
|
73
|
+
deviceId: zod_1.z.string().regex(/^\d+$/, 'deviceId must be a numeric device id'),
|
|
71
74
|
});
|
|
72
75
|
/** A settings read that could not be answered is an error, never `{}`. */
|
|
73
76
|
async function answerOrRefuse(read) {
|
|
@@ -75,20 +78,20 @@ async function answerOrRefuse(read) {
|
|
|
75
78
|
return await read();
|
|
76
79
|
}
|
|
77
80
|
catch (err) {
|
|
78
|
-
if (isSettingsReadUnavailable(err)) {
|
|
79
|
-
throw new TRPCError({ code: 'SERVICE_UNAVAILABLE', message: err.message, cause: err });
|
|
81
|
+
if ((0, system_1.isSettingsReadUnavailable)(err)) {
|
|
82
|
+
throw new server_1.TRPCError({ code: 'SERVICE_UNAVAILABLE', message: err.message, cause: err });
|
|
80
83
|
}
|
|
81
84
|
throw err;
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
|
-
|
|
85
|
-
return trpcRouter({
|
|
87
|
+
function createAddonSettingsRouter(cfg) {
|
|
88
|
+
return (0, trpc_middleware_js_1.trpcRouter)({
|
|
86
89
|
/**
|
|
87
90
|
* The addon-global stored record for the given addon — raw values, no
|
|
88
91
|
* defaults, no device overrides. `{}` only when the store answered with no
|
|
89
92
|
* row for this addon; a failed read is `SERVICE_UNAVAILABLE`.
|
|
90
93
|
*/
|
|
91
|
-
getGlobal: adminProcedure
|
|
94
|
+
getGlobal: trpc_middleware_js_1.adminProcedure
|
|
92
95
|
.input(AddonIdInputSchema)
|
|
93
96
|
.output(AddonSettingsRecordSchema)
|
|
94
97
|
.query(({ input }) => answerOrRefuse(() => cfg.readAddonGlobalStrict(input.addonId))),
|
|
@@ -97,7 +100,7 @@ export function createAddonSettingsRouter(cfg) {
|
|
|
97
100
|
* values. `{}` only when the store answered with none; a failed read is
|
|
98
101
|
* `SERVICE_UNAVAILABLE`.
|
|
99
102
|
*/
|
|
100
|
-
getDeviceOverrides: adminProcedure
|
|
103
|
+
getDeviceOverrides: trpc_middleware_js_1.adminProcedure
|
|
101
104
|
.input(AddonDeviceInputSchema)
|
|
102
105
|
.output(AddonSettingsRecordSchema)
|
|
103
106
|
.query(({ input }) => answerOrRefuse(() => cfg.readAddonDeviceStrict(input.addonId, Number(input.deviceId)))),
|