Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

Merge feature/motion and retain tracking with runtime compatibility checks

罗高fb2162017878
diff --cc .github/workflows/ci.yml
index 39014b99,80af3498..dc486f07
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@@ -70,10 -69,8 +70,10 @@@ jobs
npm run check
npm run typecheck:studio
npm run build:studio
+ npm run build:tracking
+ node --experimental-strip-types --test tests/tracking.test.ts
- name: Validate standalone installation and packaging
- run: node --experimental-strip-types --test tests/install.test.ts tests/npm-installer.test.ts tests/npm-package.test.ts tests/test-package.test.ts tests/source-install.test.ts tests/bootstrap.test.ts tests/mcp-registry.test.ts tests/phase1.test.ts tests/adapters.test.ts tests/package.test.ts tests/recreate-measure.test.ts tests/workflow.test.ts tests/catalog.test.ts tests/prism-templates.test.ts tests/extension-boundary.test.ts tests/connections.test.ts
+ run: node --experimental-strip-types --test tests/install.test.ts tests/npm-installer.test.ts tests/npm-package.test.ts tests/test-package.test.ts tests/source-install.test.ts tests/bootstrap.test.ts tests/mcp-registry.test.ts tests/mcp-runtime.test.ts tests/mcp-upgrade.test.ts tests/preview.test.ts tests/phase1.test.ts tests/adapters.test.ts tests/package.test.ts tests/recreate-measure.test.ts tests/workflow.test.ts tests/catalog.test.ts tests/prism-templates.test.ts tests/extension-boundary.test.ts tests/connections.test.ts
- name: Studio regression
run: npm run test:studio -- --maxWorkers=2
- name: Build phase-one ZIP and exercise all public tools
diff --cc mcp.ts
index a8c8af9d,e98aa63d..fc25f93c
--- a/mcp.ts
+++ b/mcp.ts
@@@ -17,35 -16,10 +19,37 @@@ export function mcpRegistry(profile = r
export const releaseRegistry = mcpRegistry();
export const publicTools = releaseRegistry.tools;
const selections = new WeakMap<WorkspaceStore, { sessionId: string; projectId: string }>();
+const trackingByStore = new WeakMap<WorkspaceStore, Promise<OmTracking>>();
+
+function trackingFor(store: WorkspaceStore) {
+ let tracking = trackingByStore.get(store);
+ if (!tracking) { tracking = createAppTracking(store.directory, 'mcp'); trackingByStore.set(store, tracking); }
+ return tracking;
+}
+ const runtimeRoot = fileURLToPath(new URL('./', import.meta.url));
+ const runtimeDirectory = statSync(runtimeRoot);
export async function rpc(message: any, store = new WorkspaceStore(), registry = releaseRegistry, connection?: { selection: Selection }) {
+ const name = message?.params?.name;
+ if (message?.jsonrpc !== '2.0' || message.id === undefined || message.method !== 'tools/call'
+ || registry.profile !== 'phase1' || !(toolNames as readonly unknown[]).includes(name)) return invokeRpc(message, store, registry, connection);
+ const tracking = await trackingFor(store), started = performance.now(), callId = crypto.randomUUID();
+ let accepted = false;
+ try { validateInput(phase1Tools.find(tool => tool.name === name)!.inputSchema, message.params.arguments ?? {}); accepted = true; } catch {}
+ const fields = { tool_name: name as typeof toolNames[number], call_id: callId, accepted,
+ ...(uuid.test(message.params.arguments?.requestId) ? { operation_id: message.params.arguments.requestId } : {}) };
+ if (accepted) tracking.track('mcp_tool_started', fields);
+ const response = await invokeRpc(message, store, registry, connection);
+ const value = (response as any)?.result;
+ const content = value?.structuredContent;
+ const outcome = value?.isError || content?.status === 'failed' ? 'failure' : content?.status === 'partial' ? 'partial' : value ? 'success' : 'unknown';
+ tracking.track('mcp_tool_finished', { ...fields, outcome, duration_ms: Math.min(86_400_000, Math.round(performance.now() - started)),
+ ...(value?.isError ? { error_code: trackingError(new Error(String(content?.error?.code ?? 'TOOL_FAILED'))) } : {}),
+ ...(typeof content?.replayed === 'boolean' ? { replayed: content.replayed } : {}) });
+ return response;
+}
+
+async function invokeRpc(message: any, store: WorkspaceStore, registry: ReturnType<typeof mcpRegistry>, connection?: { selection: Selection }) {
if (!message || message.jsonrpc !== '2.0' || typeof message.method !== 'string') return { jsonrpc: '2.0', id: message?.id ?? null, error: { code: -32600, message: 'Invalid request' } };
if (message.id === undefined) return null;
const result = (value: unknown) => ({ jsonrpc: '2.0', id: message.id, result: value });
diff --cc server.ts
index 27b5d4da,d71e6f7a..b0606c82
--- a/server.ts
+++ b/server.ts
@@@ -22,15 -22,12 +22,16 @@@ import { creationMode, creationModes, a
import { gatewayFor } from './gateway/service.ts';
import { WorkspaceBrowser } from './browser.ts';
import { Phase1Service } from './phase1.ts';
+ import { phase1McpCapabilities } from './shared/phase1-tools.ts';
import { recoverProjectTransactions } from './phase1-versions.ts';
import { verifyExport } from './scripts/verify-export.ts';
+import { createAppTracking, closeTracking, saveTrackingPreference, trackingPreference, trackingLocked, type OmTracking } from './shared/tracking.ts';
+import { browserEvents } from './tracking/events.ts';
+import { validPending } from './tracking/core.ts';
+import { omEvents } from './tracking/events.ts';
const sharedStore = new WorkspaceStore();
-export type Service = { studio?: Studio; runtimeRoot?: string; ffmpeg?: boolean; switching?: boolean; studioPort?: number; browser?: WorkspaceBrowser; editorToken?: string; ensureStudio?: (projectId?: string) => Promise<Studio>; launchStudio?: (directory: string, port: number) => Promise<Studio>; phase1?: Phase1Service; phase1Mutation?: Promise<void> };
+export type Service = { studio?: Studio; runtimeRoot?: string; ffmpeg?: boolean; switching?: boolean; studioPort?: number; browser?: WorkspaceBrowser; editorToken?: string; ensureStudio?: (projectId?: string) => Promise<Studio>; launchStudio?: (directory: string, port: number) => Promise<Studio>; phase1?: Phase1Service; phase1Mutation?: Promise<void>; tracking?: OmTracking };
const service: Service = {};
const working = new Set<string>();
const runningExports = new Map<string, AbortController>();