Skip to content

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

fix: gate pre-guard media and world routes that run host work (#13055) (#13075)

[._.]/ecc9bd990e7f
diff --git a/server/hostControlCoverage.test.js b/server/hostControlCoverage.test.js
index 9c32c91023..defd2cc039 100644
--- a/server/hostControlCoverage.test.js
+++ b/server/hostControlCoverage.test.js
@@ -36,6 +36,10 @@ const CONFIGURED_INFERENCE = 'Runs an already-configured provider or local runti
const MODEL_DATA = 'Downloads, verifies or removes model weights, or selects a built-in backend; installs no executable (local-llm #8798).';
const MANAGED_INSTALL = 'Installs a fixed, allowlisted package set into a PortOS-managed venv with an interpreter PortOS picks; no caller-chosen executable (#9015).';
const PIPELINE_DETERMINISTIC = 'Deterministic Pipeline route that never reaches the staged runner (#10068).';
+const TOOL_FREE_INFERENCE = 'Sends caller or stored text only through a tool-free transport (an HTTP chat completion or the sandboxed Codex text turn), with no CLI/TUI runner or agent fallback (#9008).';
+const IN_PROCESS_MEDIA = 'Transforms a stored gallery image in-process (sharp or pure JS) into a new variant; spawns no process and calls no provider.';
+const READ_OVER_POST = 'Reads or previews stored records over POST; writes nothing and runs nothing.';
+const DERIVED_REPORT = 'Recomputes a report from stored records without a provider; runs nothing on the host.';
const PRE_GUARD_BASELINE = 'Open when this guard landed and not yet re-audited route by route (#13055); do not add new entries.';
// 'METHOD /path' as scanRouteGraph spells it (the declaring module's :param names).
@@ -264,7 +268,6 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/code-animation/projects/:id/import', PRE_GUARD_BASELINE],
['POST /api/code-animation/projects/:id/sound-assets', PRE_GUARD_BASELINE],
['POST /api/code-animation/projects/:id/stage-runs/:runId/cancel', REDUCES_EXECUTION],
- ['POST /api/code-animation/prompt', PRE_GUARD_BASELINE],
// /api/code-review
['POST /api/code-review/cli-outcome', RECORDS],
['POST /api/code-review/report-failure', PRE_GUARD_BASELINE],
@@ -290,12 +293,12 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/cos/agents/:id/terminate', REDUCES_EXECUTION],
['DELETE /api/cos/agents/completed', REMOVES_RECORD],
['POST /api/cos/app-activity/:appId/clear-cooldown', PRE_GUARD_BASELINE],
- ['POST /api/cos/digest/generate', PRE_GUARD_BASELINE],
+ ['POST /api/cos/digest/generate', DERIVED_REPORT],
['POST /api/cos/health/check', PRE_GUARD_BASELINE],
['DELETE /api/cos/jobs/:id', REMOVES_RECORD],
['POST /api/cos/jobs/:id/gate-check', PRE_GUARD_BASELINE],
['POST /api/cos/learning/backfill', PRE_GUARD_BASELINE],
- ['POST /api/cos/learning/insights', PRE_GUARD_BASELINE],
+ ['POST /api/cos/learning/insights', RECORDS],
['POST /api/cos/learning/recalculate-durations', PRE_GUARD_BASELINE],
['POST /api/cos/learning/recommendations/clear-dismissed', PRE_GUARD_BASELINE],
['POST /api/cos/learning/recommendations/dismiss', PRE_GUARD_BASELINE],
@@ -315,7 +318,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/cos/mind/stop', REDUCES_EXECUTION],
['DELETE /api/cos/mind/thinking-request', REMOVES_RECORD],
['POST /api/cos/pause', REDUCES_EXECUTION],
- ['POST /api/cos/reports/generate', PRE_GUARD_BASELINE],
+ ['POST /api/cos/reports/generate', DERIVED_REPORT],
['PATCH /api/cos/schedule/maintenance-runs/:id/archive', PRE_GUARD_BASELINE],
['POST /api/cos/schedule/maintenance-runs/:id/stop', REDUCES_EXECUTION],
['DELETE /api/cos/schedule/on-demand/:requestId', REMOVES_RECORD],
@@ -403,9 +406,9 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/digital-twin/autobiography/stories', PRE_GUARD_BASELINE],
['DELETE /api/digital-twin/autobiography/stories/:id', REMOVES_RECORD],
['PUT /api/digital-twin/autobiography/stories/:id', PRE_GUARD_BASELINE],
- ['POST /api/digital-twin/autobiography/stories/:id/evaluate', PRE_GUARD_BASELINE],
- ['POST /api/digital-twin/autobiography/stories/:id/follow-ups', PRE_GUARD_BASELINE],
- ['POST /api/digital-twin/autobiography/stories/:id/weave', PRE_GUARD_BASELINE],
+ ['POST /api/digital-twin/autobiography/stories/:id/evaluate', TOOL_FREE_INFERENCE],
+ ['POST /api/digital-twin/autobiography/stories/:id/follow-ups', TOOL_FREE_INFERENCE],
+ ['POST /api/digital-twin/autobiography/stories/:id/weave', TOOL_FREE_INFERENCE],
['POST /api/digital-twin/autobiography/trigger', PRE_GUARD_BASELINE],
// /api/digital-twin/identity
['PUT /api/digital-twin/identity/chronotype', PRE_GUARD_BASELINE],
@@ -419,9 +422,9 @@ const REVIEWED_OPEN_MUTATIONS = [
['DELETE /api/digital-twin/identity/goals/:id/activities/:activityName', REMOVES_RECORD],
['POST /api/digital-twin/identity/goals/:id/calendars', PRE_GUARD_BASELINE],
['DELETE /api/digital-twin/identity/goals/:id/calendars/:subcalendarId', REMOVES_RECORD],
- ['POST /api/digital-twin/identity/goals/:id/check-in', PRE_GUARD_BASELINE],
- ['POST /api/digital-twin/identity/goals/:id/decompose', PRE_GUARD_BASELINE],
- ['POST /api/digital-twin/identity/goals/:id/generate-phases', PRE_GUARD_BASELINE],
+ ['POST /api/digital-twin/identity/goals/:id/check-in', TOOL_FREE_INFERENCE],
+ ['POST /api/digital-twin/identity/goals/:id/decompose', TOOL_FREE_INFERENCE],
+ ['POST /api/digital-twin/identity/goals/:id/generate-phases', TOOL_FREE_INFERENCE],
['POST /api/digital-twin/identity/goals/:id/milestones', PRE_GUARD_BASELINE],
['PUT /api/digital-twin/identity/goals/:id/milestones/:milestoneId/complete', PRE_GUARD_BASELINE],
['PUT /api/digital-twin/identity/goals/:id/milestones/:milestoneId/tasks/:taskId/complete', PRE_GUARD_BASELINE],
@@ -435,7 +438,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['DELETE /api/digital-twin/identity/goals/:id/todos/:todoId', REMOVES_RECORD],
['PUT /api/digital-twin/identity/goals/:id/todos/:todoId', PRE_GUARD_BASELINE],
['PUT /api/digital-twin/identity/goals/birth-date', PRE_GUARD_BASELINE],
- ['POST /api/digital-twin/identity/goals/organize', PRE_GUARD_BASELINE],
+ ['POST /api/digital-twin/identity/goals/organize', TOOL_FREE_INFERENCE],
['POST /api/digital-twin/identity/goals/organize/apply', PRE_GUARD_BASELINE],
['POST /api/digital-twin/identity/longevity/derive', PRE_GUARD_BASELINE],
// /api/digital-twin/social-accounts
@@ -449,7 +452,6 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/eidoverse/travel/federation/leave', PEER_SURFACE],
['POST /api/eidoverse/travel/federation/visit', PEER_SURFACE],
// /api/eidoverse/world
- ['POST /api/eidoverse/world/augment', PRE_GUARD_BASELINE],
['PUT /api/eidoverse/world/config', PRE_GUARD_BASELINE],
['POST /api/eidoverse/world/controllers', PRE_GUARD_BASELINE],
['DELETE /api/eidoverse/world/controllers/:id', REMOVES_RECORD],
@@ -463,7 +465,6 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/eidoverse/world/foundations/:id/withdraw', PRE_GUARD_BASELINE],
['POST /api/eidoverse/world/presence', PRE_GUARD_BASELINE],
['POST /api/eidoverse/world/project', PRE_GUARD_BASELINE],
- ['POST /api/eidoverse/world/say', PRE_GUARD_BASELINE],
// /api/fableloom
['POST /api/fableloom', PRE_GUARD_BASELINE],
['DELETE /api/fableloom/:id', REMOVES_RECORD],
@@ -550,18 +551,16 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/image-clean/result/:jobId/save', PRE_GUARD_BASELINE],
// /api/image-gen
['DELETE /api/image-gen/:filename', REMOVES_RECORD],
- ['POST /api/image-gen/:filename/clean', PRE_GUARD_BASELINE],
- ['POST /api/image-gen/:filename/film-look', PRE_GUARD_BASELINE],
- ['PATCH /api/image-gen/:filename/prompt', PRE_GUARD_BASELINE],
- ['POST /api/image-gen/:filename/regenerate', PRE_GUARD_BASELINE],
- ['POST /api/image-gen/:filename/remove-watermark', PRE_GUARD_BASELINE],
- ['POST /api/image-gen/:filename/visibility', PRE_GUARD_BASELINE],
+ ['POST /api/image-gen/:filename/clean', IN_PROCESS_MEDIA],
+ ['PATCH /api/image-gen/:filename/prompt', RECORDS],
+ ['POST /api/image-gen/:filename/remove-watermark', IN_PROCESS_MEDIA],
+ ['POST /api/image-gen/:filename/visibility', RECORDS],
['POST /api/image-gen/cancel', REDUCES_EXECUTION],
- ['POST /api/image-gen/gallery/lookup', PRE_GUARD_BASELINE],
+ ['POST /api/image-gen/gallery/lookup', READ_OVER_POST],
['POST /api/image-gen/models/:modelId/download', MODEL_DATA],
['POST /api/image-gen/models/:modelId/repair', MODEL_DATA],
['POST /api/image-gen/models/verify', MODEL_DATA],
- ['POST /api/image-gen/prompt-preview', PRE_GUARD_BASELINE],
+ ['POST /api/image-gen/prompt-preview', READ_OVER_POST],
['POST /api/image-gen/setup/create-venv', HANDLER_GATED],
['POST /api/image-gen/setup/flux2-install', MANAGED_INSTALL],
['DELETE /api/image-gen/setup/hf-token', REMOVES_RECORD],
@@ -592,8 +591,8 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/insights/goal-scorecard/compute', PRE_GUARD_BASELINE],
['PUT /api/insights/goal-scorecard/rules', PRE_GUARD_BASELINE],
['PUT /api/insights/goal-scorecard/settings', PRE_GUARD_BASELINE],
- ['POST /api/insights/narrative/refresh', PRE_GUARD_BASELINE],
- ['POST /api/insights/themes/refresh', PRE_GUARD_BASELINE],
+ ['POST /api/insights/narrative/refresh', TOOL_FREE_INFERENCE],
+ ['POST /api/insights/themes/refresh', TOOL_FREE_INFERENCE],
// /api/instances
['POST /api/instances/peers', PRE_GUARD_BASELINE],
['DELETE /api/instances/peers/:id', REMOVES_RECORD],
@@ -793,8 +792,8 @@ const REVIEWED_OPEN_MUTATIONS = [
['PUT /api/messages/drafts/:id', PRE_GUARD_BASELINE],
['POST /api/messages/drafts/:id/approve', PRE_GUARD_BASELINE],
['POST /api/messages/drafts/:id/reconcile', PRE_GUARD_BASELINE],
- ['POST /api/messages/drafts/generate', PRE_GUARD_BASELINE],
- ['POST /api/messages/evaluate', PRE_GUARD_BASELINE],
+ ['POST /api/messages/drafts/generate', TOOL_FREE_INFERENCE],
+ ['POST /api/messages/evaluate', TOOL_FREE_INFERENCE],
['POST /api/messages/fetch-full/:accountId', PRE_GUARD_BASELINE],
['POST /api/messages/sync/:accountId', PRE_GUARD_BASELINE],
['DELETE /api/messages/triage-rules/:index', REMOVES_RECORD],
@@ -808,13 +807,12 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/mood-boards', PRE_GUARD_BASELINE],
['DELETE /api/mood-boards/:id', REMOVES_RECORD],
['PATCH /api/mood-boards/:id', PRE_GUARD_BASELINE],
- ['POST /api/mood-boards/:id/backfill-prompts', PRE_GUARD_BASELINE],
+ ['POST /api/mood-boards/:id/backfill-prompts', RECORDS],
['POST /api/mood-boards/:id/collage', PRE_GUARD_BASELINE],
['POST /api/mood-boards/:id/items', PRE_GUARD_BASELINE],
['DELETE /api/mood-boards/:id/items/:itemId', REMOVES_RECORD],
['PATCH /api/mood-boards/:id/items/:itemId', PRE_GUARD_BASELINE],
['POST /api/mood-boards/:id/items/:itemId/extract-frames', PRE_GUARD_BASELINE],
- ['POST /api/mood-boards/:id/items/:itemId/render', PRE_GUARD_BASELINE],
['POST /api/mood-boards/:id/localize-media', PRE_GUARD_BASELINE],
['DELETE /api/mood-boards/:id/pinterest', REMOVES_RECORD],
['PUT /api/mood-boards/:id/pinterest', PRE_GUARD_BASELINE],
@@ -929,7 +927,6 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/music-video/:id/shots/:sceneId/render/cancel', REDUCES_EXECUTION],
['POST /api/music-video/:id/song-revision', PRE_GUARD_BASELINE],
['POST /api/music-video/:id/song-revision/cancel', REDUCES_EXECUTION],
- ['POST /api/music-video/:id/song-revision/generate', PRE_GUARD_BASELINE],
['POST /api/music-video/:id/song-revision/select', PRE_GUARD_BASELINE],
['POST /api/music-video/:id/song-revision/track', PRE_GUARD_BASELINE],
['POST /api/music-video/:id/song-style/suno', PRE_GUARD_BASELINE],
@@ -1052,7 +1049,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['PUT /api/privacy/brokers/:id', PRE_GUARD_BASELINE],
['POST /api/privacy/brokers/refresh', PRE_GUARD_BASELINE],
['POST /api/privacy/changes', PRE_GUARD_BASELINE],
- ['POST /api/privacy/changes/:id/orgs/:orgId/draft-email', PRE_GUARD_BASELINE],
+ ['POST /api/privacy/changes/:id/orgs/:orgId/draft-email', RECORDS],
['POST /api/privacy/changes/:id/orgs/:orgId/removed', PRE_GUARD_BASELINE],
['POST /api/privacy/changes/:id/orgs/:orgId/updated', PRE_GUARD_BASELINE],
['POST /api/privacy/optout', PRE_GUARD_BASELINE],
@@ -1182,7 +1179,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/stacker-news/actions', PRE_GUARD_BASELINE],
['POST /api/stacker-news/analyses/:id/feedback', PRE_GUARD_BASELINE],
['POST /api/stacker-news/items', PRE_GUARD_BASELINE],
- ['POST /api/stacker-news/items/:id/analyze', PRE_GUARD_BASELINE],
+ ['POST /api/stacker-news/items/:id/analyze', TOOL_FREE_INFERENCE],
['POST /api/stacker-news/territories', HANDLER_GATED],
['DELETE /api/stacker-news/territories/:id', REMOVES_RECORD],
['PATCH /api/stacker-news/territories/:id', HANDLER_GATED],
@@ -1261,7 +1258,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['DELETE /api/tribe/beeper/link', REMOVES_RECORD],
['POST /api/tribe/beeper/link', PRE_GUARD_BASELINE],
['POST /api/tribe/beeper/link-new', PRE_GUARD_BASELINE],
- ['POST /api/tribe/outreach/draft', PRE_GUARD_BASELINE],
+ ['POST /api/tribe/outreach/draft', TOOL_FREE_INFERENCE],
['POST /api/tribe/people', PRE_GUARD_BASELINE],
['DELETE /api/tribe/people/:id', REMOVES_RECORD],
['PUT /api/tribe/people/:id', PRE_GUARD_BASELINE],
@@ -1312,7 +1309,6 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/video-gen/history/:id/visibility', PRE_GUARD_BASELINE],
['POST /api/video-gen/ic-loras/:mode/download', MODEL_DATA],
['POST /api/video-gen/ic-loras/:mode/repair', MODEL_DATA],
- ['POST /api/video-gen/last-frame/:id', PRE_GUARD_BASELINE],
['POST /api/video-gen/model-terms', PRE_GUARD_BASELINE],
['POST /api/video-gen/models/:modelId/download', MODEL_DATA],
['POST /api/video-gen/models/:modelId/repair', MODEL_DATA],
@@ -1364,7 +1360,7 @@ const REVIEWED_OPEN_MUTATIONS = [
['POST /api/writers-room/works', PRE_GUARD_BASELINE],
['DELETE /api/writers-room/works/:id', REMOVES_RECORD],
['PATCH /api/writers-room/works/:id', PRE_GUARD_BASELINE],
- ['POST /api/writers-room/works/:id/analysis/:analysisId/scene-image', PRE_GUARD_BASELINE],
+ ['POST /api/writers-room/works/:id/analysis/:analysisId/scene-image', RECORDS],
['POST /api/writers-room/works/:id/cd-bridge/send', PRE_GUARD_BASELINE],
['POST /api/writers-room/works/:id/characters', PRE_GUARD_BASELINE],
['DELETE /api/writers-room/works/:id/characters/:characterId', REMOVES_RECORD],
diff --git a/server/lib/hostControlRoutes.js b/server/lib/hostControlRoutes.js
index be2b7697af..65dcba0cb3 100644
--- a/server/lib/hostControlRoutes.js
+++ b/server/lib/hostControlRoutes.js
@@ -82,6 +82,15 @@
* mood-board generate. Board, beat, panel and take CRUD, the recipe and
* node PATCH, beats/add, the recipe library and the plan/make reads only
* store or read records and stay open.
+ * - Pre-guard audit (#13055): the film-look bake (headless browser),
+ * video last-frame (ffmpeg), mood-board note render (image job), Suno
+ * song-revision generation (signed-in browser) and Eidoverse augment/say
+ * (acting as the CoS world identity) are gated whole. SynthID regenerate is
+ * gated unless `method` is `light`, and the code-animation prompt only when
+ * it names a `referenceVideo`. Left open: image clean and watermark
+ * removal (in-process sharp), and the Messages, Tribe outreach,
+ * autobiography, identity-goal and insights AI routes, whose transports
+ * are tool-free (an HTTP chat completion or the sandboxed Codex text turn).
* - Importer, Brain and analytics AI (#11036): classify/analyze/retry-issues,
* model-personality run, goal-scorecard narrative, Brain capture (it can
* dispatch classification or repository intake), inbox retry, digest/review
@@ -661,13 +670,20 @@ export const HOST_CONTROL_ROUTES = Object.freeze([
'POST /api/music-video/:id/production-runs/:runId/resume',
'POST /api/music-video/:id/auto-reviews',
'POST /api/music-video/:id/auto-reviews/:runId/resume',
+ // Song revision drives the signed-in PortOS Browser to submit the song to
+ // Suno, spending the operator's account credits (#13055).
+ 'POST /api/music-video/:id/song-revision/generate',
// Media agents retain host tools; scratch cwd and output validation are not
// execution containment (#9667). Gate before uploads, stores or queue writes,
// including inference-first requests that can fall back to CLI/TUI.
'POST /api/image-gen/generate',
'POST /api/image-gen/avatar',
+ // Film-look bake launches a headless composition browser on the host (#13055).
+ 'POST /api/image-gen/:filename/film-look',
'POST /api/video-gen',
+ // Last-frame extraction runs ffmpeg over a gallery clip (#13055).
+ 'POST /api/video-gen/last-frame/:id',
// Upscale (LTX subprocess / ffmpeg) and stitch (ffmpeg) run on the host (#11076).
'POST /api/video-gen/upscale/:id',
'POST /api/video-gen/stitch',
@@ -898,6 +914,9 @@ export const HOST_CONTROL_ROUTES = Object.freeze([
'POST /api/mood-boards/:id/compose-prompt',
'POST /api/mood-boards/:id/analyze',
'POST /api/mood-boards/:id/generate',
+ // A text note's render queues an image job on the caller-chosen backend,
+ // including local Python (#13055), like generate above.
+ 'POST /api/mood-boards/:id/items/:itemId/render',
// Storyboards (#12952): the plot and saved node prompts reach a
// caller-chosen, non-tool-free provider; node runs and make-empty also
// queue image renders.
@@ -1011,6 +1030,10 @@ export const HOST_CONTROL_ROUTES = Object.freeze([
// Explicit local gameplay can speak in this machine's private world. Scoped
// peer reachability does not grant it; operator/agent sessions retain access.
'POST /api/eidoverse/world/controllers/:id/riddle',
+ // Augment and say act in the private world as the owner-granted CoS
+ // identity (#13055), the same authority as a riddle round.
+ 'POST /api/eidoverse/world/augment',
+ 'POST /api/eidoverse/world/say',
// GitHub actions (#9013): mutating routes run `gh` with the user's GitHub
// account and change external state. Syncing repos is read-only.
@@ -1251,6 +1274,12 @@ const COMPILED_BODY_ROUTES = [
// scheduled reference-watch runs git in; name, notes and the reviewed SHA
// are records.
['PATCH /api/apps/:appId/reference-repos/:refId', (body) => ['repoUrl', 'branch'].filter((key) => body?.[key] !== undefined)],
+ // SynthID regen (#13055): the default flux method queues a local Python
+ // img2img job; the light method is an in-process sharp pass and stays open.
+ ['POST /api/image-gen/:filename/regenerate', (body) => body?.method === 'light' ? [] : ['method']],
+ // A code-animation prompt that studies a reference video runs ffmpeg over
+ // it (#13055); a prompt without one only reads records.
+ ['POST /api/code-animation/prompt', (body) => body?.referenceVideo ? ['referenceVideo'] : []],
].map(([route, pick]) => ({ ...compileRoute(route), pick }));
const bodyRouteEntry = (method, path) => (
diff --git a/server/lib/hostControlRoutes.test.js b/server/lib/hostControlRoutes.test.js
index 0c18a95ae2..9420718b96 100644
--- a/server/lib/hostControlRoutes.test.js
+++ b/server/lib/hostControlRoutes.test.js
@@ -1015,6 +1015,22 @@ describe('Importer, Brain and analytics AI policy (#11036)', () => {
}
});
+ it('gates SynthID regen unless light, and a code-animation prompt only with a reference video (#13055)', () => {
+ const regen = '/api/image-gen/example.png/regenerate';
+ expect(isHostControlRoute('POST', regen)).toBe(false);
+ for (const body of [{}, null, [], { method: 'flux' }, { method: 'LIGHT' }]) {
+ expect(hostControlBodyKeys('POST', regen, body), JSON.stringify(body)).toEqual(['method']);
+ }
+ expect(hostControlBodyKeys('POST', regen, { method: 'light' })).toEqual([]);
+ expect(hostControlBodyKeys('post', '/API/image-gen/example.png/regenerate/', {})).toEqual(['method']);
+
+ const prompt = '/api/code-animation/prompt';
+ expect(hostControlBodyKeys('POST', prompt, { concept: 'Example', referenceVideo: { filename: 'example.mp4' } })).toEqual(['referenceVideo']);
+ for (const body of [{ concept: 'Example' }, { referenceVideo: null }, null, []]) {
+ expect(hostControlBodyKeys('POST', prompt, body), JSON.stringify(body)).toEqual([]);
+ }
+ });
+
it('keeps record reads, CRUD and non-AI insights compute open', () => {
for (const [method, path] of [
['GET', '/api/importer/config'],
diff --git a/server/routes/hostControlCallerPromptedAI.test.js b/server/routes/hostControlCallerPromptedAI.test.js
index 19e1146c27..54760644e6 100644
--- a/server/routes/hostControlCallerPromptedAI.test.js
+++ b/server/routes/hostControlCallerPromptedAI.test.js
@@ -79,6 +79,7 @@ vi.mock('../services/moodBoard/index.js', async (importOriginal) => ({
...await importOriginal(),
getBoard: vi.fn(async (id) => ({ id, name: 'Example Board', items: [] })),
updateBoard: vi.fn(async (id, patch) => ({ id, ...patch })),
+ renderBoardItem: vi.fn(async () => ({ item: { id: 'example-item' }, jobId: 'example-job' })),
}));
vi.mock('../services/moodBoardStyleSynthesis.js', () => ({
synthesizeBoardStyle: vi.fn(async () => ({ styleNotes: 'Example' })),
@@ -109,6 +110,7 @@ import cosTaskRoutes from './cosTaskRoutes.js';
import { generateRound, evaluateRound, deriveRoundParts } from '../services/roundsAI.js';
import { generateAgentPersonality } from '../services/agentPersonalityGenerator.js';
import { triageSystemResources } from '../services/systemResources.js';
+import { renderBoardItem } from '../services/moodBoard/index.js';
import { synthesizeBoardStyle } from '../services/moodBoardStyleSynthesis.js';
import { composeBoardPrompt } from '../services/moodBoardCompositeStyle.js';
import { startGenerateJob } from '../services/moodBoard/generateMore.js';
@@ -130,6 +132,8 @@ const operations = [
[`/api/mood-boards/${id}/compose-prompt`, { ...picker }, composeBoardPrompt, 200],
[`/api/mood-boards/${id}/analyze`, { ...picker }, startAnalyzeJob, 202],
[`/api/mood-boards/${id}/generate`, { ...picker, requestId: id }, startGenerateJob, 202],
+ // A note render queues an image job, local Python included (#13055).
+ [`/api/mood-boards/${id}/items/example-item/render`, { mode: 'local' }, renderBoardItem, 202],
['/api/cos/tasks/enhance', { description: 'Example task' }, enhanceTaskPrompt, 200],
];
// Distinct services touched by the table, so the "never ran" check covers each once.
diff --git a/server/routes/hostControlEidoverseWorld.test.js b/server/routes/hostControlEidoverseWorld.test.js
new file mode 100644
index 0000000000..85926d5c1f
--- /dev/null
+++ b/server/routes/hostControlEidoverseWorld.test.js
@@ -0,0 +1,138 @@
+import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import express from 'express';
+import { request } from '../lib/testHelper.js';
+import { errorMiddleware } from '../lib/errorHandler.js';
+import { DEV_PROXY_CLIENT_ADDRESS_HEADER } from '../../lib/portosAuthCore.js';
+import { derivePeerAuthToken, PEER_AUTH_HEADER, PEER_INSTANCE_HEADER } from '../lib/peerHttpClient.js';
+import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../lib/mockPathsDataRoot.js';
+
+vi.mock('../lib/fileUtils.js', async (importOriginal) =>
+ makePathsProxy(await importOriginal(), { dataRoot: () => lazyTempDataRoot('portos-eidoverse-world-authority-') }));
+afterAll(cleanupTempDataRoots);
+
+// Eidoverse augment and say act in the private world as the owner-granted CoS
+// identity (#13055), the authority a riddle round already requires. Real router
+// behind the real gates; the world service is doubled so no connection opens.
+const auth = vi.hoisted(() => ({ enabled: false }));
+const world = vi.hoisted(() => ({
+ augment: vi.fn(async () => ({ success: true, applied: 1 })),
+ say: vi.fn(async () => ({ success: true })),
+ status: vi.fn(async () => ({ installed: true })),
+}));
+vi.mock('../services/auth.js', async (importOriginal) => ({
+ ...await importOriginal(),
+ isAuthEnabled: vi.fn(async () => auth.enabled),
+ verifyPassword: vi.fn(async () => true),
+}));
+vi.mock('../services/settings.js', () => ({
+ settingsEvents: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },
+ getSettings: vi.fn(async () => ({})),
+}));
+vi.mock('../services/instanceIdentity.js', () => ({
+ ensureInstanceId: vi.fn(async () => 'example-self'),
+ loadData: vi.fn(async () => ({ peers: [{
+ id: 'example-peer', instanceId: 'example-instance', enabled: true, syncSecret: 'a'.repeat(32),
+ }] })),
+}));
+vi.mock('../services/eidoverseWorld.js', () => ({
+ augmentEidoverseWorld: world.augment,
+ sayInEidoverseWorld: world.say,
+ getEidoverseWorldStatus: world.status,
+}));
+vi.mock('../services/eidoverseFoundationLedger.js', () => ({}));
+vi.mock('../services/eidoverseControllerRuntime.js', () => ({}));
+vi.mock('../services/eidoverseControllerRegistry.js', () => ({}));
+
+import { authGate, hostControlRouteGate } from '../services/authGate.js';
+import { createSession } from '../services/auth.js';
+import worldRoutes from './eidoverseWorldRoutes.js';
+
+const operations = [
+ ['/api/eidoverse/world/augment', { operations: [{ verb: 'grant', args: { id: 'example-visitor', role: 'owner' } }] }, world.augment],
+ ['/api/eidoverse/world/say', { text: 'Example message' }, world.say],
+];
+
+const appFor = (address = '192.0.2.10') => {
+ const app = express();
+ app.use((req, _res, next) => {
+ Object.defineProperty(req.socket, 'remoteAddress', { value: address });
+ next();
+ });
+ app.use(authGate, hostControlRouteGate, express.json());
+ app.use('/api/eidoverse/world', worldRoutes);
+ app.use(errorMiddleware);
+ return app;
+};
+const post = (app, [path, body], headers = {}) => {
+ const pending = request(app).post(path);
+ for (const [name, value] of Object.entries(headers)) pending.set(name, value);
+ return pending.send(body);
+};
+const expectNoEffects = () => {
+ expect(world.augment).not.toHaveBeenCalled();
+ expect(world.say).not.toHaveBeenCalled();
+};
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ auth.enabled = false;
+});
+
+describe('Eidoverse world augment/say operator authority (#13055)', () => {
+ it('refuses remote password-free callers, spoofed-proxy and case variants before the world is touched', async () => {
+ for (const [path, body] of operations) {
+ for (const [address, headers, target] of [
+ ['192.0.2.10', {}, path],
+ ['127.0.0.1', { [DEV_PROXY_CLIENT_ADDRESS_HEADER]: '192.0.2.10' }, path],
+ ['192.0.2.10', { [DEV_PROXY_CLIENT_ADDRESS_HEADER]: '127.0.0.1' }, path],
+ ['192.0.2.10', {}, path.toUpperCase() + '/'],
+ ]) {
+ const response = await post(appFor(address), [target, body], headers);
+ expect([response.status, response.body.code], target).toEqual([403, 'HOST_CONTROL_FORBIDDEN']);
+ }
+ }
+ expectNoEffects();
+ });
+
+ it('requires authentication with a password and denies legacy Basic and scoped-peer credentials', async () => {
+ auth.enabled = true;
+ for (const operation of operations) {
+ for (const [headers, status, code] of [
+ [{}, 401, 'AUTH_REQUIRED'],
+ [{ Authorization: 'Basic ' + Buffer.from(':example-password').toString('base64') }, 403, 'HOST_CONTROL_FORBIDDEN'],
+ [{
+ [PEER_AUTH_HEADER]: derivePeerAuthToken('a'.repeat(32), 'example-instance'),
+ [PEER_INSTANCE_HEADER]: 'example-instance',
+ }, 403, 'PEER_SCOPE_FORBIDDEN'],
+ ]) {
+ const response = await post(appFor(), operation, headers);
+ expect([response.status, response.body.code], operation[0]).toEqual([status, code]);
+ }
+ }
+ expectNoEffects();
+ });
+
+ it('keeps working for local callers, operator sessions and delegated agent sessions', async () => {
+ const operator = await createSession();
+ const agent = await createSession({ label: 'agent' });
+ for (const [enabled, address, headers] of [
+ [false, '127.0.0.1', {}],
+ [true, '192.0.2.10', { Authorization: `Bearer ${operator.token}` }],
+ [true, '192.0.2.10', { Authorization: `Bearer ${agent.token}` }],
+ ]) {
+ auth.enabled = enabled;
+ for (const operation of operations) {
+ const response = await post(appFor(address), operation, headers);
+ expect(response.status, `${operation[0]}: ${JSON.stringify(response.body)}`).toBe(200);
+ }
+ }
+ expect(world.augment).toHaveBeenCalledTimes(3);
+ expect(world.augment).toHaveBeenLastCalledWith(operations[0][1].operations);
+ expect(world.say).toHaveBeenLastCalledWith('Example message');
+ });
+
+ it('leaves the world status read open to a remote caller', async () => {
+ expect((await request(appFor()).get('/api/eidoverse/world/status')).status).toBe(200);
+ expectNoEffects();
+ });
+});
diff --git a/server/routes/hostControlMediaAuthoring.test.js b/server/routes/hostControlMediaAuthoring.test.js
index 5652bfa95c..586ebd03a2 100644
--- a/server/routes/hostControlMediaAuthoring.test.js
+++ b/server/routes/hostControlMediaAuthoring.test.js
@@ -114,6 +114,7 @@ vi.mock('../services/musicVideo/productionService.js', () => ({
}));
vi.mock('../services/musicVideo/songRevision.js', () => ({
resolveSongRevisionScenes: vi.fn(async () => ({ project: {} })),
+ generateSongRevision: vi.fn(async () => ({ project: {} })),
}));
vi.mock('../services/musicVideo/productionReviewService.js', () => ({
reviseProductionFromFeedback: vi.fn(async () => ({ project: {} })),
@@ -149,7 +150,7 @@ import codeAnimationRoutes from './codeAnimation.js';
import musicRoutes from './music.js';
import tracksRoutes from './tracks.js';
import musicVideoRoutes from './musicVideo.js';
-import { generateCodeAnimationBrief, startCodeAnimationGeneration } from '../services/codeAnimation/index.js';
+import { buildCodeAnimationRequest, generateCodeAnimationBrief, startCodeAnimationGeneration } from '../services/codeAnimation/index.js';
import { startProductionStageRun } from '../services/codeAnimation/stages.js';
import { describeMusic, writeLyrics } from '../services/musicDesigner.js';
import { drawWaveSketch, drawWaveSketchForTrack } from '../services/musicWaveform.js';
@@ -158,7 +159,7 @@ import { startCodeAnimationSoundtrack } from '../services/codeAnimation/soundtra
import { startAutonomousVideo, resumeAutonomousVideo } from '../services/musicVideo/autonomousService.js';
import { createSession, revokeSessionById } from '../services/auth.js';
-import { resolveSongRevisionScenes } from '../services/musicVideo/songRevision.js';
+import { generateSongRevision, resolveSongRevisionScenes } from '../services/musicVideo/songRevision.js';
import { reviseProductionFromFeedback } from '../services/musicVideo/productionReviewService.js';
import { planProject } from '../services/musicVideo/planner.js';
import { compileTreatment } from '../services/musicVideo/treatmentService.js';
@@ -187,6 +188,8 @@ const authoring = [
];
const musicVideoAuthoring = [
[`/api/music-video/${id}/song-revision/scenes`, { revisionId: 'example-revision', action: 'replan', ...picker }, resolveSongRevisionScenes, 200, 'post'],
+ // Drives the signed-in browser to submit a Suno song (#13055).
+ [`/api/music-video/${id}/song-revision/generate`, { revisionId: 'example-revision' }, generateSongRevision, 202, 'post'],
[`/api/music-video/${id}/production-review/revise`, { stage: 'storyboard', ...picker }, reviseProductionFromFeedback, 200, 'post'],
[`/api/music-video/${id}/plan`, { ...picker }, planProject, 200, 'post'],
[`/api/music-video/${id}/treatment/compile`, { baseRevision: 0, ...picker }, compileTreatment, 200, 'post'],
@@ -291,6 +294,31 @@ describe('media authoring operator authority (#9512, #9869)', () => {
}
});
+ it('gates the code-animation prompt only when it studies a reference video (#13055)', async () => {
+ const withVideo = ['/api/code-animation/prompt', { concept: 'Example scene', referenceVideo: { filename: 'example.mp4' } }];
+ for (const [address, headers] of [
+ ['192.0.2.10', {}],
+ ['127.0.0.1', { [DEV_PROXY_CLIENT_ADDRESS_HEADER]: '192.0.2.10' }],
+ ]) {
+ const refused = await call(appFor(address), withVideo, headers);
+ expect([refused.status, refused.body.code]).toEqual([403, 'HOST_CONTROL_FORBIDDEN']);
+ }
+ expect(buildCodeAnimationRequest).not.toHaveBeenCalled();
+
+ expect((await call(appFor(), ['/api/code-animation/prompt', { concept: 'Example scene', referenceVideo: null }])).status).toBe(200);
+ const agentSession = await createSession({ label: 'agent' });
+ for (const [enabled, address, headers] of [
+ [false, '127.0.0.1', {}],
+ [true, '192.0.2.10', { Authorization: `Bearer ${ownerSession.token}` }],
+ [true, '192.0.2.10', { Authorization: `Bearer ${agentSession.token}` }],
+ ]) {
+ auth.enabled = enabled;
+ expect((await call(appFor(address), withVideo, headers)).status).toBe(200);
+ }
+ expect(buildCodeAnimationRequest).toHaveBeenCalledTimes(4);
+ expect(buildCodeAnimationRequest).toHaveBeenLastCalledWith(expect.objectContaining({ referenceVideo: expect.objectContaining({ filename: 'example.mp4' }) }));
+ });
+
it('keeps song-revision remove and dismiss available without host authority', async () => {
for (const action of ['remove', 'dismiss']) {
const body = { revisionId: 'example-revision', action };
diff --git a/server/routes/hostControlMediaGeneration.test.js b/server/routes/hostControlMediaGeneration.test.js
index fe9bbfacc1..8e0e4f3146 100644
--- a/server/routes/hostControlMediaGeneration.test.js
+++ b/server/routes/hostControlMediaGeneration.test.js
@@ -1,4 +1,4 @@
-import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
+import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { EventEmitter } from 'node:events';
import express from 'express';
import { request } from '../lib/testHelper.js';
@@ -26,6 +26,9 @@ const effects = vi.hoisted(() => ({
walk: vi.fn(async () => ({})), track: vi.fn(async () => ({})),
binding: vi.fn(async () => ({})), publish: vi.fn(async () => ({})),
create: vi.fn(async () => ({})), refine: vi.fn(async () => ({})),
+ filmLook: vi.fn(async () => ({ filename: 'example_look.png' })),
+ lastFrame: vi.fn(async () => ({ filename: 'example-frame.png' })),
+ lightRegen: vi.fn(async () => ({ filename: 'example_regen-light.png' })),
}));
vi.mock('../services/auth.js', () => ({
isAuthEnabled: vi.fn(async () => auth.enabled),
@@ -54,7 +57,8 @@ vi.mock('../lib/multipart.js', () => {
});
vi.mock('./imageGenSetup.js', () => ({ default: express.Router() }));
vi.mock('../services/imageGen/index.js', async () => ({
- ...await import('../services/imageGen/modes.js'), local: {},
+ ...await import('../services/imageGen/modes.js'),
+ local: { assertGalleryFilename: vi.fn(), readImageSidecar: vi.fn(async () => ({ metadata: {} })) },
generateImage: effects.image, generateAvatar: effects.avatar,
checkConnection: vi.fn(async () => ({})), cancel: vi.fn(() => ({ cancelled: true })),
}));
@@ -71,6 +75,7 @@ vi.mock('../services/character.js', () => ({ setAvatar: vi.fn() }));
vi.mock('../services/videoGen/submitJob.js', () => ({ submitVideoGenJob: effects.video }));
vi.mock('../services/videoGen/local.js', () => ({
BYOV_RUNTIME_INFO: {}, getHistoryItem: vi.fn(async id => ({ id, filename: 'example.mp4' })),
+ extractLastFrame: effects.lastFrame,
}));
vi.mock('../services/videoGen/batch.js', () => ({ MAX_VIDEO_BATCH_SIZE: 8 }));
vi.mock('../services/sprites/records.js', () => ({
@@ -117,13 +122,22 @@ vi.mock('../services/videoUpload.js', () => ({}));
vi.mock('../services/hfDownloadStream.js', () => ({}));
vi.mock('../services/mediaSketches.js', () => ({}));
vi.mock('../services/universeCanon.js', () => ({}));
-vi.mock('../services/imageGen/variants.js', () => ({}));
+vi.mock('../services/imageGen/variants.js', () => ({ applyLightRegenVariant: effects.lightRegen }));
+vi.mock('../services/imageGen/filmLookBake.js', () => ({ applyFilmLookBake: effects.filmLook }));
+vi.mock('../services/imageGen/regen.js', async (importOriginal) => ({
+ ...await importOriginal(),
+ resolveRegenBackend: vi.fn(async () => ({ available: true, model: { id: 'example-model' }, pythonPath: null })),
+ readImageDimensions: vi.fn(async () => ({ width: 64, height: 64 })),
+}));
vi.mock('../services/fableLoom/records.js', () => ({}));
vi.mock('../services/fableLoom/visualConditioning.js', () => ({}));
vi.mock('../services/federatedMedia/remoteSubmission.js', () => ({}));
vi.mock('../services/federatedMedia/inputAssets.js', () => ({}));
-import { authGate, hostControlRouteGate } from '../services/authGate.js';
+import { mkdir, writeFile } from 'node:fs/promises';
+import { join } from 'node:path';
+import { PATHS } from '../lib/fileUtils.js';
+import { authGate, hostControlBodyGate, hostControlRouteGate } from '../services/authGate.js';
import imageRoutes from './imageGen.js';
import videoRoutes from './videoGen.js';
import spriteRoutes from './sprites.js';
@@ -142,6 +156,11 @@ const operations = [
['post', `/api/sprites/${id}/tracks/scanner/generate`, { direction: 'south', correctionPrompt: 'Example correction' }, effects.track, 200],
['post', '/api/threejs-models', { name: 'Example model', filename: 'example.png', providerId: 'example-api', prompt: 'Example shape' }, effects.create, 202],
['post', '/api/threejs-models/example-model/generate', { providerId: 'example-api', feedback: 'Example refinement' }, effects.refine, 202],
+ // Film-look bake (headless browser), SynthID flux regen (local Python job)
+ // and last-frame extraction (ffmpeg) run host processes (#13055).
+ ['post', '/api/image-gen/example.png/film-look', { look: { grain: 0.5 } }, effects.filmLook, 200],
+ ['post', '/api/image-gen/example.png/regenerate', {}, effects.enqueue, 200],
+ ['post', '/api/video-gen/last-frame/22222222-2222-4222-8222-222222222222', {}, effects.lastFrame, 200],
['put', `/api/sprites/${id}/publish-binding`, { binding: null }, effects.binding, 200],
['post', `/api/sprites/${id}/atlas/publish`, {}, effects.publish, 200],
];
@@ -151,7 +170,7 @@ const appFor = (address = '192.0.2.10') => {
Object.defineProperty(req.socket, 'remoteAddress', { value: address });
next();
});
- app.use(authGate, hostControlRouteGate, express.json());
+ app.use(authGate, hostControlRouteGate, express.json(), hostControlBodyGate);
app.use('/api/image-gen', imageRoutes);
app.use('/api/video-gen', videoRoutes);
app.use('/api/sprites', spriteRoutes);
@@ -168,6 +187,12 @@ const expectNoEffects = () => {
for (const effect of Object.values(effects)) expect(effect).not.toHaveBeenCalled();
};
+beforeAll(async () => {
+ // The regenerate route resolves its source in the gallery before queueing.
+ await mkdir(PATHS.images, { recursive: true });
+ await writeFile(join(PATHS.images, 'example.png'), 'example');
+});
+
beforeEach(() => {
vi.clearAllMocks();
auth.enabled = false;
@@ -221,7 +246,8 @@ describe('media generation and source publication authority (#9667)', () => {
}
expect(effects.create).toHaveBeenLastCalledWith(expect.objectContaining({ providerId: 'example-api' }));
expect(effects.refine).toHaveBeenLastCalledWith('example-model', expect.objectContaining({ providerId: 'example-api' }));
- expect(effects.enqueue).toHaveBeenLastCalledWith(expect.objectContaining({ params: expect.objectContaining({ mode: 'grok' }) }));
+ expect(effects.enqueue).toHaveBeenCalledWith(expect.objectContaining({ params: expect.objectContaining({ mode: 'grok' }) }));
+ expect(effects.enqueue).toHaveBeenLastCalledWith(expect.objectContaining({ params: expect.objectContaining({ mode: 'local', regenOf: 'example.png' }) }));
});
it('refuses multipart uploads before the upload middleware can stage files', async () => {
@@ -234,6 +260,16 @@ describe('media generation and source publication authority (#9667)', () => {
expectNoEffects();
});
+ it('keeps the in-process light SynthID regen open to a remote caller (#13055)', async () => {
+ const response = await call(appFor(), ['post', '/api/image-gen/example.png/regenerate', { method: 'light' }]);
+ expect(response.status, JSON.stringify(response.body)).toBe(200);
+ expect(effects.lightRegen).toHaveBeenCalledTimes(1);
+ expect(effects.enqueue).not.toHaveBeenCalled();
+ const refused = await call(appFor(), ['post', '/api/image-gen/example.png/regenerate', { method: 'flux' }]);
+ expect([refused.status, refused.body.code]).toEqual([403, 'HOST_CONTROL_FORBIDDEN']);
+ expect(effects.enqueue).not.toHaveBeenCalled();
+ });
+
it('retains remote reads and cancellation', async () => {
expect((await request(appFor()).get('/api/threejs-models')).status).toBe(200);
expect((await request(appFor()).get('/api/sprites')).status).toBe(200);