mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-04 05:00:05 +08:00
* feat(super-agent): add Super Agent workspace, Artifact Viewer, and unified resource hub * fix(super-agent): align merge with main and mode composer controls * wip(super-agent): save local Super Agent updates before merging origin/main * feat(super-agent): add cloud share, game handoff, browser annotations, review fixes, and UI craft guidelines * feat(arch): add cross-platform MCP hub, desktop shell, batch/triggers, and unified Web Publish Implement OpenMotion's cross-platform MCP-first architecture and desktop packaging: - Streamable HTTP MCP gateway (/mcp) with scoped Bearer tokens and unified Stdio/HTTP dispatch - Multi-runtime Agent routing (local-direct, outbound local-bridge with macOS/Linux/Windows scripts, remote-service) - Shared Batch Content Optimization and webhook/schedule Trigger engine across HTTP, MCP, and Super Agent - Generalized HTML Web Publish service (design, game, motion, and standalone html targets) with shared Studio WebPublishPopover and Design Deploy compatibility facade - Standalone Electron desktop shell (desktop/) for macOS, Windows, and Linux with multi-platform icon pipeline, WebGL splash/OpenDesign sign-in flow, auto-updater, and diagnostic export - Static asset compression/caching (editor-server.ts), bounded LRU lifecycle helpers, and visibility-aware polling - Comprehensive unit, HTTP, MCP, performance, and desktop test suites * docs(arch): add cross-platform MCP architecture guide and interactive boundary map Document the five-layer cross-platform MCP architecture, desktop packaging boundaries, batch/trigger automation, and generalized HTML Web Publish pipeline in docs/cross-platform-mcp-architecture.md and docs/architecture-map.html. * fix(ci): schedule new backend tests, fix WorkspaceStore import, and harden Codex/runtime shutdown * feat(super-agent): refine Artifact Viewer, CodeViewer styles, runtime/share handlers, and tests * fix(ci): resolve remaining gitleaks, WebMCP tracking, i18n, menuStyle, and tokenGate checks * chore(ci): remove accidental node_modules symlink from worktree commit * fix(tracking): register motion_cloud_share tool and openmotion_cloud_share actions * fix(account): avoid treating plain-text HTTP 403 prose as structured error code * feat(super-agent): refine artifact viewer toolbar, game presentation, and cloud share trigger * test(package): exercise openmotion_cloud_share in packaged phase1 smoke E2E * fix(cloud-share): rotate file identity on entry path change and allow stop after project deletion * test(e2e): verify MCP web deploy, game lifecycle, and fix preview asset CSP * fix(super-agent): add persistent live progress dock and Continue recovery UX * fix(design): allow sandboxed preview CORS fetches and preserve top-row preview thumbnails * feat(super-agent): refine WebPublishPopover and ArtifactBrowserPane styles and tests * fix(bridge,ci): forward workingDir to bridge/remote runtimes, sync standalone Codex events, and align tracking/CI suites * fix(ci): keep 1800ms active-project polling in useWorkspace and update MCP tool count to 36 * fix(web-publish,server): stop prior slug on new_link, allow deleted-project unpublish/status, avoid bfcache SSE socket exhaustion, and await active turn cleanup * chore(distribution): raise default npm package budget to 26 MiB Baseline main is already at 23.69 MiB compressed (98.7% of the previous 24 MiB budget after Game Studio assets), and adding Super Agent, Artifact Viewer, WebPublish, Local Agent discovery/bridge, and 10-locale i18n adds +0.38 MiB compressed with no new offline media (24.06 MiB total). Update MAX_BYTES in .github/scripts/npm-package-size.py and document the 26 MiB budget in CONTRIBUTING.md. * feat(super-agent): add Game Studio Super Agent mode, masonry showcase, and artifact viewer enhancements
151 lines
4.5 KiB
JavaScript
151 lines
4.5 KiB
JavaScript
import { spawn } from 'node:child_process';
|
|
import { existsSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const repoRoot = path.resolve(__dirname, '..');
|
|
|
|
const args = new Set(process.argv.slice(2));
|
|
const modeArg = process.argv.find(item => item.startsWith('--mode='));
|
|
const mode = modeArg ? modeArg.split('=')[1] : args.has('--desktop') ? 'desktop' : 'web';
|
|
|
|
const backendPort = Number(process.env.MOTION_BACKEND_PORT || 4174);
|
|
const vitePort = Number(process.env.MOTION_VITE_PORT || 5173);
|
|
const backendOrigin = `http://127.0.0.1:${backendPort}`;
|
|
const viteOrigin = `http://127.0.0.1:${vitePort}`;
|
|
|
|
const children = new Set();
|
|
let shuttingDown = false;
|
|
|
|
function spawnService(command, commandArgs, options = {}) {
|
|
const child = spawn(command, commandArgs, {
|
|
cwd: options.cwd || repoRoot,
|
|
env: { ...process.env, ...options.env },
|
|
stdio: 'inherit',
|
|
shell: process.platform === 'win32' && command.endsWith('.cmd'),
|
|
});
|
|
children.add(child);
|
|
child.on('exit', code => {
|
|
children.delete(child);
|
|
if (!shuttingDown && options.critical !== false && code !== 0) {
|
|
console.error(`[dev-unified] ${options.name || command} exited with code ${code}`);
|
|
shutdown(code || 1);
|
|
}
|
|
});
|
|
return child;
|
|
}
|
|
|
|
async function waitForUrl(url, timeoutMs = 45_000) {
|
|
const deadline = Date.now() + timeoutMs;
|
|
while (Date.now() < deadline) {
|
|
if (shuttingDown) return;
|
|
try {
|
|
const res = await fetch(url, { signal: AbortSignal.timeout(2_000) });
|
|
if (res.ok || res.status < 500) return;
|
|
} catch {
|
|
// Wait for service startup.
|
|
}
|
|
await new Promise(resolve => setTimeout(resolve, 250));
|
|
}
|
|
throw new Error(`Timed out waiting for ${url}`);
|
|
}
|
|
|
|
function shutdown(exitCode = 0) {
|
|
if (shuttingDown) return;
|
|
shuttingDown = true;
|
|
for (const child of children) {
|
|
try {
|
|
child.kill('SIGTERM');
|
|
} catch {
|
|
// Ignore already exited child.
|
|
}
|
|
}
|
|
setTimeout(() => process.exit(exitCode), 400);
|
|
}
|
|
|
|
process.on('SIGINT', () => shutdown(0));
|
|
process.on('SIGTERM', () => shutdown(0));
|
|
|
|
async function main() {
|
|
console.log(`[dev-unified] Starting OpenMotion in "${mode}" mode…`);
|
|
|
|
// 1. Start OpenMotion Node backend (Studio serves via Vite HMR on 5173)
|
|
spawnService(process.execPath, ['--experimental-strip-types', 'server.ts'], {
|
|
name: 'backend',
|
|
env: {
|
|
PORT: String(backendPort),
|
|
HOST: '127.0.0.1',
|
|
MOTION_HEADLESS: '1',
|
|
MOTION_OPEN_BROWSER: '0',
|
|
HYPERFRAMES_HEADLESS: '1',
|
|
MOTION_DEV_BACKEND_PROXY: backendOrigin,
|
|
},
|
|
});
|
|
await waitForUrl(`${backendOrigin}/motion-api/health`);
|
|
console.log(`[dev-unified] Backend ready at ${backendOrigin}`);
|
|
|
|
// 2. Start unified Vite dev server for Studio
|
|
const viteBin = path.join(
|
|
repoRoot,
|
|
'node_modules',
|
|
'.bin',
|
|
process.platform === 'win32' ? 'vite.cmd' : 'vite',
|
|
);
|
|
spawnService(
|
|
viteBin,
|
|
['--config', 'studio/vite.dev.config.ts', '--port', String(vitePort)],
|
|
{
|
|
name: 'vite-studio',
|
|
env: {
|
|
MOTION_DEV_BACKEND_PROXY: backendOrigin,
|
|
VITE_BACKEND_PROXY: backendOrigin,
|
|
},
|
|
},
|
|
);
|
|
await waitForUrl(viteOrigin);
|
|
console.log(`[dev-unified] Studio dev server ready at ${viteOrigin}`);
|
|
|
|
if (mode === 'desktop') {
|
|
console.log('[dev-unified] Building desktop shell and launching Electron…');
|
|
const buildRes = await new Promise((resolve, reject) => {
|
|
const builder = spawn(process.execPath, ['desktop/scripts/build.mjs'], {
|
|
cwd: repoRoot,
|
|
stdio: 'inherit',
|
|
});
|
|
builder.on('error', reject);
|
|
builder.on('exit', resolve);
|
|
});
|
|
if (buildRes !== 0) {
|
|
throw new Error(`Desktop build failed with code ${buildRes}`);
|
|
}
|
|
|
|
const electronBin = path.join(
|
|
repoRoot,
|
|
'desktop',
|
|
'node_modules',
|
|
'.bin',
|
|
process.platform === 'win32' ? 'electron.cmd' : 'electron',
|
|
);
|
|
if (!existsSync(electronBin)) {
|
|
throw new Error(
|
|
`Electron binary not found at ${electronBin}. Install desktop dependencies with \`npm --prefix desktop install\`.`,
|
|
);
|
|
}
|
|
|
|
const desktopChild = spawnService(electronBin, ['desktop'], {
|
|
name: 'electron-desktop',
|
|
env: {
|
|
MOTION_DESKTOP_DEV_URL: viteOrigin,
|
|
MOTION_DESKTOP_API_URL: backendOrigin,
|
|
},
|
|
});
|
|
desktopChild.on('exit', code => shutdown(code ?? 0));
|
|
}
|
|
}
|
|
|
|
main().catch(err => {
|
|
console.error('[dev-unified]', err);
|
|
shutdown(1);
|
|
});
|