mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-06 23:57:17 +08:00
* feat(game-static-play): add 274-template R2 zip packaging, cookieless static play deploy, and verification pipeline * feat(game-skill): port 21-section OpenGame skill with dual-mode workflow and fast-play path * feat(onboarding): upgrade Cloud MCP install guide and add shared OpenGame prompt builders * feat(game-catalog): sync 274 official templates, 4 kits, downloads manifest, and game contract * feat(cloud-mcp): add read-only game catalog, free asset search, guest catalog API, redirects, and Docker packaging * feat(opengame): enable Stage 1 Game Studio routing, feature flags, and analytics * feat(opengame): add Stage 1 market, multi-client modal, Cursor HTTP fix, SuperAgent prompt, and i18n * fix(opengame): align nullable GameCardWithMeta fields and add opengame-catalog MCP capability * test(mcp-onboarding): update registered public tool count from 22 to 24 for Stage 1 game tools * chore(game-catalog): register 26 verified live R2 in-repo template bundles in game-downloads.json * fix(opengame): address Stage 1 review feedback and failing CI lanes - Send no play URL when GAME_PLAY_PUBLIC_ORIGIN is unset instead of a main-site path that no route serves; Studio falls back to bundled in-repo templates - Keep legacy-host 301 redirects on the configured origin for network-path inputs - Correct the BlenderKit page host in the asset search allowlist - Reuse the shared withdrawn list, TOP earning tag, curated order and comparator in Studio - Remove the unused shared prompt module; the shipped builders stay covered by Studio tests - Drop the blurred launch backdrop and the in-dialog copy notices in favour of Toasts - Describe the shipped read-only Game Studio boundary and 24-tool MCP contract in the architecture - Schedule the game skill and static play suites in CI and budget the three OpenGame events * fix(game-static-play): retry stalled template bundle downloads before failing the run * fix(game-asset-search): size the pagination cursor limit for every supported query A 200-unit query with non-ASCII, control or lone-surrogate characters produced a cursor longer than the 512-character limit, so nextCursor was rejected by both the decoder and the public schema. Share one limit derived from the worst-case JSON/base64url expansion and add a round-trip test for maximum-length queries. * fix(game-asset-search): accept BlenderKit pages on www.blendkit.com and guide licence checks www.blenderkit.com now redirects to www.blendkit.com and the upstream catalog returns that host, so requiring www.blenderkit.com dropped every BlenderKit result. Restore the live host, pin a real upstream row in tests, and tell Agents to confirm the licence on the source page when a source omits it. * fix(deploy): forward game play origin and legacy redirect hosts to the API deploy/.env.example and deploy/k8s/configmap.yaml declared GAME_PLAY_PUBLIC_ORIGIN and APP_REDIRECT_FROM_HOSTS, but neither the compose api service nor the reference api Deployment passed them to the process. Wire both and assert that every reference ConfigMap key is read by a workload. * Address review: keep legacy-host writes, enforce play-origin isolation, share catalog constants - Legacy-host redirects answer GET/HEAD with 301 and every other method with 308, so MCP and API writes keep their method and body. - parseConfig rejects a GAME_PLAY_PUBLIC_ORIGIN that is not https (loopback http excepted), carries a path, or shares or sits under the APP_PUBLIC_ORIGIN host. - The template id pattern, bundle key prefix, withdrawn set and TOP tag predicate live in shared/game-contract.ts; static play, deploy/verify scripts and the catalog service reuse them and the shared bundle URL builder. - Remove unused game-contract and model-catalog exports. - Update the MCP contract, AGENTS.md, README and docs to the 24-name phase-one surface and document the read-only OpenGame tools and guest catalog routes. * fix(game-static-play): make the full play-site upload resumable Upload through the S3 SDK instead of one aws CLI process per file, skip objects whose ETag already matches the local MD5, retry each request with backoff, and write assets before entry pages and the manifest. Give large bundle downloads time for a slow link. Record the provisioned bucket, domain and remaining header rule in the runbook. * feat(game-static-play): harden live play verification and add manual R2 publish workflow * fix(opengame): raise prompt/remix maxLength for >4k OG-13 test and reset notes on target change * fix(mcp): register resources/templates/list handler for Codex MCP compliance * chore(game-catalog): register uploaded tidebreaker bundle for 274/274 R2 CDN parity --------- Co-authored-by: heggria <bshengtao@gmail.com>
106 lines
8.3 KiB
TypeScript
106 lines
8.3 KiB
TypeScript
import { findLandingScene, findMediaStudio, findTechniqueStudio } from './studio-catalog.ts';
|
|
import { workspacePageName } from './workspace-page-name.ts';
|
|
|
|
export { workspacePageName };
|
|
|
|
export const providerSetupEntries = [
|
|
'agent_providers', 'agent_media_signed_out', 'agent_media_upgrade_free', 'agent_media_upgrade_go',
|
|
'agent_media_balance_low', 'agent_media_key_rejected', 'agent_media_handbook',
|
|
] as const;
|
|
export type ProviderSetupEntry = typeof providerSetupEntries[number];
|
|
|
|
export type WorkspacePresentation = { embedded: boolean; sidebar: boolean; conversation: boolean };
|
|
/** Independent workspace pages remain usable even when the retained project cannot start. */
|
|
export function isWorkspaceSettingsPage(search: string, hash = '') {
|
|
const query = new URLSearchParams(search), page = workspacePageName(query, hash);
|
|
if (page === 'model') return Boolean(query.get('model'));
|
|
if (page === 'model-hub') return Boolean(query.get('hub'));
|
|
if (page === 'create') return Boolean(findLandingScene(query.get('scene')));
|
|
return page === '404' || page === 'settings' || page === 'mcp' || page === 'assets' || page === 'skills' || page === 'brand-kit' || page === 'explore' || page === 'motion' || page === 'audio' || page === 'scenario' || page === 'scenarios' || page === 'agent' || Boolean(findMediaStudio(page) || findTechniqueStudio(page));
|
|
}
|
|
export function workspacePresentation(search: string): WorkspacePresentation {
|
|
const query = new URLSearchParams(search), embedded = query.get('embed') === '1';
|
|
return { embedded, sidebar: !embedded && query.get('sidebar') !== '0', conversation: !embedded && query.get('conversation') !== '0' };
|
|
}
|
|
export function sessionPath(sessionId: string, projectId?: string, options: { openArtifact?: boolean; embedded?: boolean } = {}) {
|
|
const query = new URLSearchParams({ session: sessionId });
|
|
if (options.openArtifact) query.set('openArtifact', '1');
|
|
if (options.embedded) query.set('embed', '1');
|
|
if (projectId) {
|
|
const encoded = encodeURIComponent(projectId);
|
|
return `/editor/${encoded}?${query}#project/${encoded}`;
|
|
}
|
|
return `/editor?${query}`;
|
|
}
|
|
export function preservePresentation(target: string, search: string) {
|
|
const url = new URL(target, 'http://workspace.local'), current = new URLSearchParams(search);
|
|
for (const key of ['embed', 'sidebar', 'conversation']) if (current.has(key)) url.searchParams.set(key, current.get(key)!);
|
|
const tracking = current.get('tracking_context');
|
|
if (tracking && /^[0-9a-f-]{36}$/i.test(tracking) && !url.searchParams.has('tracking_context')) url.searchParams.set('tracking_context', tracking);
|
|
return url.pathname + url.search + url.hash;
|
|
}
|
|
|
|
/** Browsing the library has no project, session or content-version identity. */
|
|
export function templateLibraryPreview(origin: string, options: { embedded?: boolean; presentation?: string } = {}) {
|
|
return workspacePagePreview(origin, 'templates', options);
|
|
}
|
|
|
|
/** Provider/model settings handoff is independent of project initialization and editing. */
|
|
export function providerSettingsPreview(
|
|
origin: string,
|
|
options: {
|
|
embedded?: boolean;
|
|
presentation?: string;
|
|
entry?: string;
|
|
attributeEntry?: boolean;
|
|
modelProvidersEnabled?: boolean;
|
|
} = {},
|
|
) {
|
|
return workspacePagePreview(origin, 'providers', options);
|
|
}
|
|
|
|
export function resolveProviderSetupEntry(entry?: string): ProviderSetupEntry {
|
|
return (providerSetupEntries as readonly string[]).includes(entry ?? '') ? entry as ProviderSetupEntry : 'agent_providers';
|
|
}
|
|
|
|
function workspacePagePreview(
|
|
origin: string,
|
|
target: 'templates' | 'providers',
|
|
options: {
|
|
embedded?: boolean;
|
|
presentation?: string;
|
|
entry?: string;
|
|
attributeEntry?: boolean;
|
|
modelProvidersEnabled?: boolean;
|
|
},
|
|
) {
|
|
const modelProvidersGated = target === 'providers' && options.modelProvidersEnabled === false;
|
|
const query = new URLSearchParams(target === 'providers' ? undefined : { templates: '1' });
|
|
if (target === 'providers') {
|
|
const entry = resolveProviderSetupEntry(options.entry);
|
|
if (!modelProvidersGated && (entry === 'agent_media_signed_out' || entry === 'agent_media_upgrade_free' || entry === 'agent_media_upgrade_go' || entry === 'agent_media_balance_low')) {
|
|
query.set('provider', 'account');
|
|
}
|
|
if (options.attributeEntry !== false) query.set('entry_from', entry);
|
|
}
|
|
if (options.embedded !== false) query.set('embed', '1');
|
|
const serialized = query.toString();
|
|
const previewUrl = target === 'providers'
|
|
? `${origin}${modelProvidersGated ? '/settings/models' : '/settings/providers'}${serialized ? `?${serialized}` : ''}`
|
|
: `${origin}/?${serialized}`;
|
|
const presentation = options.presentation ?? 'foreground';
|
|
const background = presentation === 'background';
|
|
const instructions = target !== 'providers'
|
|
? 'Open previewUrl in the host built-in browser in the calling chat. Reuse a matching native host tab in this chat after checking its identity and URL; preserve all URL parameters. Present it immediately when this chat is active. Queue without switching only when the host confirms this chat is inactive; a queued acknowledgment alone does not prove inactivity. Only presentation=now permits switching. Observe settled native panel visibility and template library content before reporting it opened. If presentation fails or the native tab is gone, retry presentation once, then report the display failure without repeatedly creating tabs. A prepared URL, hidden automation tab or queued acknowledgment is not visible delivery. On return from a deferred chat, recheck the live library. If the host has no browser, provide the actual link and state the limitation. Browsing and previewing templates must not create a project. Create only after the user selects Open and edit or explicitly asks the Agent to use an exact template. No project record_display receipt is needed for this page.'
|
|
: modelProvidersGated
|
|
? 'Open previewUrl in the host built-in browser in the calling chat and follow the same focus policy. Verify that Default models is visible before reporting it opened. If the host has no browser, provide the actual link and state the limitation. In Cloud Phase 1, the Model providers settings entry is hidden and all media generation routes through the unified OpenDesign Model Gateway (no third-party BYOK API keys are required). Guide the user to sign in under Settings > Account, or click Check account & plan / open Settings > Subscription & usage > Manage subscription to upgrade to OpenDesign Plus or above (Plus and above include image, video, speech and music generation; Free and Go do not), then choose workspace defaults in Default models if needed. Ask them to tell you once done. Re-inspect media availability after confirmation and resume the original request. This page does not create or select a project and needs no project record_display receipt.'
|
|
: 'Open previewUrl in the host built-in browser in the calling chat and follow the same focus policy. Verify that Model providers is visible before reporting it opened. If the host has no browser, provide the actual link and state the limitation. Guide the user to click Sign in with OpenDesign or Upgrade to Plus directly on the opened OpenDesign page in Model providers; select OpenDesign in the provider list first if needed. OpenDesign Plus or above includes image, video, speech and music generation; Free and Go do not. For API key setup, guide the user to save or replace their OpenDesign Cloud or other supported provider key here in Model providers. Ask them to tell you once done. Keep credentials in settings. Re-inspect providers after confirmation and resume the original request. This page does not create or select a project and needs no project record_display receipt.';
|
|
return { target, previewUrl, projectCreated: false, openedByHost: false,
|
|
previewHandoff: { target, previewUrl, placement: 'right', reuseExistingTab: true, presentation,
|
|
focusPolicy: background ? 'background' : presentation === 'now' ? 'switch_to_calling_chat' : 'preserve_current_chat',
|
|
state: background ? 'background' : 'pending', openedByHost: false, hostActionRequired: !background,
|
|
nextAction: background ? null : { kind: 'host', operation: 'present_preview', previewUrl, placement: 'right', reuseExistingTab: true,
|
|
codex: { tool: 'open_in_codex', arguments: { placement: 'right', target: { type: 'browser', url: previewUrl } } } },
|
|
instructions } };
|
|
}
|