Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: negotiate fpsOptions, enforce stride minimum frames, and test routedJobParams (#4681)
[._.]/ Adam Eivyedb343eb868f
diff --git a/server/services/federatedMedia/defaultRouting.js b/server/services/federatedMedia/defaultRouting.jsindex 068f35f895..43ff939746 100644--- a/server/services/federatedMedia/defaultRouting.js+++ b/server/services/federatedMedia/defaultRouting.js@@ -301,9 +301,9 @@ export function routedJobParams(params, { request, remoteMedia }) {...jobParams,prompt: '',modelId: effectiveRequest.modelId,- ...(effectiveRequest?.numFrames !== undefined ? { numFrames: effectiveRequest.numFrames } : {}),- ...(effectiveRequest?.width !== undefined ? { width: effectiveRequest.width } : {}),- ...(effectiveRequest?.height !== undefined ? { height: effectiveRequest.height } : {}),+ ...(effectiveRequest.numFrames !== undefined ? { numFrames: effectiveRequest.numFrames } : {}),+ ...(effectiveRequest.width !== undefined ? { width: effectiveRequest.width } : {}),+ ...(effectiveRequest.height !== undefined ? { height: effectiveRequest.height } : {}),remoteMedia,};}diff --git a/server/services/federatedMedia/defaultRouting.test.js b/server/services/federatedMedia/defaultRouting.test.jsindex 6e9f9109f1..9822c0406e 100644--- a/server/services/federatedMedia/defaultRouting.test.js+++ b/server/services/federatedMedia/defaultRouting.test.js@@ -590,4 +590,24 @@ describe('frame constraint negotiation (issue #4681)', () => {expect(logSpy).toHaveBeenCalledWith(expect.stringContaining('adjusted numFrames from 40 to 33'));logSpy.mockRestore();});++ it('propagates negotiated numFrames, width, and height in routedJobParams', () => {+ const jobParams = routedJobParams(+ { prompt: 'a balloon', width: 1280, height: 720, numFrames: 40, mode: 'local' },+ {+ request: { modelId: 'wan22', numFrames: 33, width: 1344, height: 768 },+ remoteMedia: { wireVersion: 1, peerId: 'peer-1' },+ },+ );++ expect(jobParams).toMatchObject({+ prompt: '',+ modelId: 'wan22',+ numFrames: 33,+ width: 1344,+ height: 768,+ remoteMedia: { wireVersion: 1, peerId: 'peer-1' },+ });+ expect(jobParams.mode).toBeUndefined();+ });});diff --git a/server/services/federatedMedia/remoteSubmission.js b/server/services/federatedMedia/remoteSubmission.jsindex 7dc668269c..90ead25f2c 100644--- a/server/services/federatedMedia/remoteSubmission.js+++ b/server/services/federatedMedia/remoteSubmission.js@@ -61,7 +61,14 @@ export function negotiateVideoConstraints(request, capability) {if (hasStride || hasMax) {let legalFrames = requestedFrames;if (hasStride) {+ const minLegal = frameStride + 1;legalFrames = Math.floor((legalFrames - 1) / frameStride) * frameStride + 1;+ if (legalFrames < minLegal) {+ throw new ServerError(+ `Requested frame count (${requestedFrames}) cannot be satisfied by ${capability.modelName || capability.modelId} (minimum ${minLegal})`,+ { status: 400, code: 'MEDIA_PROVIDER_INPUT_UNSUPPORTED' },+ );+ }}if (hasMax && legalFrames > maxNumFrames) {legalFrames = hasStride@@ -82,6 +89,21 @@ export function negotiateVideoConstraints(request, capability) {}}+ // FPS constraint negotiation+ if (Array.isArray(capability.fpsOptions) && capability.fpsOptions.length > 0 && negotiated.fps !== undefined) {+ const requestedFps = Number(negotiated.fps);+ const validFps = capability.fpsOptions.map(Number).filter((f) => Number.isInteger(f) && f > 0);+ if (validFps.length > 0 && Number.isFinite(requestedFps)) {+ const bestFps = validFps.reduce((closest, opt) =>+ Math.abs(opt - requestedFps) < Math.abs(closest - requestedFps) ? opt : closest,+ validFps[0]);+ if (bestFps !== requestedFps) {+ console.log(`🌐 Federated render: adjusted fps from ${requestedFps} to ${bestFps} for ${capability.modelName || capability.modelId}`);+ negotiated = { ...negotiated, fps: bestFps };+ }+ }+ }+// Canvas constraint negotiation (issue #4681)if (Array.isArray(capability.resolutionOptions) && capability.resolutionOptions.length > 0&& negotiated.width !== undefined && negotiated.height !== undefined) {diff --git a/server/services/federatedMedia/remoteSubmission.test.js b/server/services/federatedMedia/remoteSubmission.test.jsindex c09e92a8c3..bd8463f345 100644--- a/server/services/federatedMedia/remoteSubmission.test.js+++ b/server/services/federatedMedia/remoteSubmission.test.js@@ -100,6 +100,26 @@ describe('negotiateVideoConstraints', () => {expect(snapped1080.height).toBe(1080);});+ it('snaps fps to the nearest option when fpsOptions is present', () => {+ const capability = {+ modelId: 'minimax_h3',+ fpsOptions: [24, 25],+ };++ expect(negotiateVideoConstraints({ fps: 16 }, capability).fps).toBe(24);+ expect(negotiateVideoConstraints({ fps: 30 }, capability).fps).toBe(25);+ });++ it('rejects when requested numFrames is below minimum stride frames', () => {+ const capability = {+ modelId: 'wan22_t2v_a14b',+ frameStride: 4,+ };++ expect(() => negotiateVideoConstraints({ numFrames: 3 }, capability))+ .toThrow(/cannot be satisfied.*minimum 5/);+ });+it('rejects when requested numFrames is invalid (< 1)', () => {const capability = {modelId: 'wan22',