@tora-editor/tora 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -58
- package/assets/free-audio/arcade-pop/audio/loss.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/reward.wav +0 -0
- package/assets/free-audio/arcade-pop/audio/win.wav +0 -0
- package/assets/free-audio/arcade-pop/source/INFO.txt +11 -11
- package/assets/kenney-food-starter/License.txt +28 -0
- package/assets/kenney-food-starter/burger.glb +0 -0
- package/assets/kenney-food-starter/frying-pan.glb +0 -0
- package/assets/kenney-food-starter/plan.json +61 -0
- package/assets/kenney-food-starter/plate.glb +0 -0
- package/assets/kenney-food-starter/pot.glb +0 -0
- package/assets/kenney-harvest/audio/victory.wav +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_NES/jingles_NES03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/OGG/jingles_PIZZA/jingles_PIZZA03.ogg +0 -0
- package/assets/kenney-harvest/source/music-jingles/license.txt +14 -0
- package/bin/tora.mjs +322 -28
- package/crates/packer/trusted/native-3d-meta.json +4 -3
- package/crates/packer/trusted/native-3d.js +181 -181
- package/crates/packer/trusted/native-meta.json +3 -3
- package/crates/packer/trusted/native.js +5 -5
- package/crates/packer/trusted/release-manifest.json +17 -17
- package/crates/packer/trusted/review-runtime-meta.json +4 -3
- package/crates/packer/trusted/review-runtime.js +182 -182
- package/docs/MIGRATION_0_3.md +39 -0
- package/docs/NATIVE_AGENT_TOOLS.md +12 -363
- package/docs/TORA_AGENT_SETUP.md +24 -95
- package/docs/TORA_CREATION_API.md +63 -348
- package/docs/reference/CORE_AUTHORING.md +10 -3
- package/docs/reference/PLAYABLE_STARTERS.md +20 -0
- package/docs/reference/packs/3d.md +11 -3
- package/network-rules/mintegral-appgrowth-single-html.json +10 -10
- package/package.json +6 -6
- package/packages/creative-project/project-v21.schema.json +372 -9
- package/scripts/lean/editor/entry.js +11 -6
- package/scripts/lean/editor/project-launcher.js +116 -0
- package/scripts/lean/editor/quick-edit-panel.js +479 -0
- package/scripts/lean/editor/review-editor.css +256 -68
- package/scripts/lean/editor/review-editor.js +1834 -1086
- package/scripts/lean/editor-state.mjs +6 -0
- package/scripts/lean/editor.mjs +6 -3
- package/scripts/lean/matrix.mjs +5 -0
- package/scripts/lean/native/agent-tools.mjs +39 -62
- package/scripts/lean/native/api.mjs +161 -136
- package/scripts/lean/native/asset-catalog.mjs +7 -6
- package/scripts/lean/native/asset-lineage.mjs +54 -0
- package/scripts/lean/native/asset-prep.mjs +173 -40
- package/scripts/lean/native/assets.mjs +107 -11
- package/scripts/lean/native/audio-assets.mjs +30 -0
- package/scripts/lean/native/browser-pool.mjs +34 -0
- package/scripts/lean/native/build-cache.mjs +38 -7
- package/scripts/lean/native/cc0-inputs.mjs +24 -0
- package/scripts/lean/native/cc0-staging.mjs +28 -8
- package/scripts/lean/native/compiler.mjs +9 -3
- package/scripts/lean/native/contracts.mjs +16 -11
- package/scripts/lean/native/creative-qa.mjs +365 -128
- package/scripts/lean/native/demos.mjs +53 -18
- package/scripts/lean/native/document.mjs +50 -12
- package/scripts/lean/native/export-budget.mjs +75 -0
- package/scripts/lean/native/local-bundle.mjs +7 -3
- package/scripts/lean/native/mcp-server.mjs +42 -74
- package/scripts/lean/native/media-validate.mjs +124 -0
- package/scripts/lean/native/modules/harvest-restore.mjs +3 -284
- package/scripts/lean/native/modules/sort-puzzle.mjs +51 -0
- package/scripts/lean/native/modules/star-salvage.mjs +3 -368
- package/scripts/lean/native/native-bin.mjs +3 -3
- package/scripts/lean/native/outcome-playthrough.mjs +97 -0
- package/scripts/lean/native/project-bundle.mjs +6 -5
- package/scripts/lean/native/project-index.mjs +0 -2
- package/scripts/lean/native/qa-adapters.mjs +10 -0
- package/scripts/lean/native/quick-edit.mjs +328 -0
- package/scripts/lean/native/remote-cc0-fetcher.mjs +403 -197
- package/scripts/lean/native/review.mjs +205 -571
- package/scripts/lean/native/schema-vocabulary.mjs +10 -0
- package/scripts/lean/native/schema.mjs +7 -5
- package/scripts/lean/native/scope.mjs +45 -0
- package/scripts/lean/native/service.mjs +378 -79
- package/scripts/lean/native/starters.mjs +563 -0
- package/scripts/lean/native/variant-adapters.mjs +8 -0
- package/scripts/lean/native/variants-core.mjs +186 -0
- package/scripts/lean/native/variants.mjs +63 -0
- package/scripts/lean/native/win-cues.mjs +96 -0
- package/skills/tora-playables/SKILL.md +1 -1
- package/scripts/lean/editor/review-intake.js +0 -837
- package/scripts/lean/model-client.mjs +0 -119
- package/scripts/lean/native/author-expansion-proofs.mjs +0 -240
- package/scripts/lean/native/author-games.mjs +0 -160
- package/scripts/lean/native/author-harvest.mjs +0 -74
- package/scripts/lean/native/author-primitive-proofs.mjs +0 -874
- package/scripts/lean/native/author-salvage.mjs +0 -71
- package/scripts/lean/native/chat-compose.mjs +0 -287
- package/scripts/lean/native/check-harvest-outcome-audio.mjs +0 -191
- package/scripts/lean/native/check-salvage.mjs +0 -197
- package/scripts/lean/native/compatibility.mjs +0 -34
- package/scripts/lean/native/concept.mjs +0 -633
- package/scripts/lean/native/draw-stroke.mjs +0 -26
- package/scripts/lean/native/erase-mask.mjs +0 -18
- package/scripts/lean/native/harvest-recipe.mjs +0 -21
- package/scripts/lean/native/instance-steering.mjs +0 -24
- package/scripts/lean/native/intake-creator-agent.mjs +0 -98
- package/scripts/lean/native/intake-creator-tools.mjs +0 -165
- package/scripts/lean/native/interaction-gestures.mjs +0 -45
- package/scripts/lean/native/match-board.mjs +0 -138
- package/scripts/lean/native/modules/index.mjs +0 -54
- package/scripts/lean/native/modules/tap-collect.mjs +0 -54
- package/scripts/lean/native/path-network.mjs +0 -132
- package/scripts/lean/native/physics-2d.mjs +0 -154
- package/scripts/lean/native/physics-3d.mjs +0 -259
- package/scripts/lean/native/prepare-audio-collections.mjs +0 -112
- package/scripts/lean/native/prepare-game-audio.mjs +0 -372
- package/scripts/lean/native/prepare-golf-3d-assets.py +0 -177
- package/scripts/lean/native/prepare-golf-assets.py +0 -211
- package/scripts/lean/native/prepare-harvest-audio.mjs +0 -83
- package/scripts/lean/native/prepare-harvest-images.mjs +0 -31
- package/scripts/lean/native/prepare-primitive-images.py +0 -25
- package/scripts/lean/native/prepare-space-salvage-images.mjs +0 -89
- package/scripts/lean/native/prepare-traffic-assets.py +0 -329
- package/scripts/lean/native/presentation.mjs +0 -335
- package/scripts/lean/native/review-agent-tools.mjs +0 -561
- package/scripts/lean/native/review-connection.mjs +0 -303
- package/scripts/lean/native/review-fields.mjs +0 -24
- package/scripts/lean/native/review-intake.mjs +0 -385
- package/scripts/lean/native/review-intents.mjs +0 -217
- package/scripts/lean/native/review-provider.mjs +0 -580
- package/scripts/lean/native/review-receipts.mjs +0 -76
- package/scripts/lean/native/review-resolver.mjs +0 -429
- package/scripts/lean/native/review-targets.mjs +0 -35
- package/scripts/lean/native/runtime.mjs +0 -1623
- package/scripts/lean/native/salvage-recipe.mjs +0 -20
- package/scripts/lean/native/stage-3d.mjs +0 -818
- package/scripts/lean/native/verify.mjs +0 -4
- package/scripts/lean/scene-document.mjs +0 -48
|
@@ -10,57 +10,53 @@ import {ProjectStore} from '../project-store.mjs';
|
|
|
10
10
|
import {EditorState} from '../editor-state.mjs';
|
|
11
11
|
import {NativeService} from './service.mjs';
|
|
12
12
|
import {NativeAgentTools} from './agent-tools.mjs';
|
|
13
|
+
import {packageVersion} from './native-bin.mjs';
|
|
14
|
+
import {fetchCc0Properties,pivotMode,stageCc0ItemSchema} from './cc0-inputs.mjs';
|
|
13
15
|
import {availablePacks,capabilities,capabilitiesForPacks,capabilitySummary,compactCapabilities} from './contracts.mjs';
|
|
14
16
|
import {NativeReview} from './review.mjs';
|
|
15
|
-
import {reviewRoutingFlags} from './review-resolver.mjs';
|
|
16
|
-
import {ReviewIntake} from './review-intake.mjs';
|
|
17
17
|
import {targets} from './network-targets.mjs';
|
|
18
|
-
import {readOriginal,readUploadFile} from './assets.mjs';
|
|
19
18
|
import {AssetCatalog} from './asset-catalog.mjs';
|
|
20
19
|
import {RemoteCc0Fetcher} from './remote-cc0-fetcher.mjs';
|
|
21
20
|
import {stageVerifiedCc0Assets} from './cc0-staging.mjs';
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
21
|
+
import {composeStarter,listStarters,starterInputProperties} from './starters.mjs';
|
|
22
|
+
import {prepAssets} from './asset-prep.mjs';
|
|
24
23
|
import {closeSharedBrowser,getSharedBrowser} from './browser-pool.mjs';
|
|
25
24
|
import {PACKAGE_ROOT,defaultStoreRoot,resolveWorkspaceRoot} from '../runtime-paths.mjs';
|
|
26
25
|
|
|
27
26
|
const string={type:'string'},boolean={type:'boolean'},integer={type:'integer'},strings={type:'array',items:string};
|
|
28
27
|
const expected={type:'object',properties:{revisionId:string,contentHash:string},required:['revisionId','contentHash'],additionalProperties:false};
|
|
29
|
-
const assetSchema={type:'object',properties:{id:string,mime:{type:'string',enum:['image/png','image/jpeg','audio/wav','audio/mpeg','model/tora-mesh']},data:string,sourceHash:string,rights:string,optimize:{type:'string',enum:['auto','lossless','none']},preserveResolution:boolean},required:['id','mime','rights'],additionalProperties:false};
|
|
28
|
+
const assetSchema={type:'object',properties:{id:string,mime:{type:'string',enum:['image/png','image/jpeg','audio/wav','audio/mpeg','model/tora-mesh','model/gltf-binary','model/gltf+json','model/obj']},data:string,sourceHash:string,useOriginal:boolean,maxTextureSide:integer,preserveGeometry:boolean,targetTriangles:integer,rights:string,optimize:{type:'string',enum:['auto','lossless','none']},preserveResolution:boolean},required:['id','mime','rights'],additionalProperties:false};
|
|
30
29
|
const sliceGridSchema={type:'object',properties:{cols:integer,rows:integer,margin:integer,spacing:integer,trimCells:boolean,skipEmpty:boolean,maxFrames:integer,outputMode:{type:'string',enum:['frames','strip']}},required:['cols','rows'],additionalProperties:false};
|
|
31
|
-
const prepItemSchema={type:'object',properties:{filePath:string,sourceId:string,outputPrefix:string,rights:string,styleFamily:string,crop:{type:'array',items:integer},trim:boolean,alphaThreshold:integer,paddingPx:integer,resize:{type:'array',items:integer},maxSide:integer,allowDeform:boolean,sliceGrid:sliceGridSchema},additionalProperties:false};
|
|
32
|
-
const stageCc0ItemSchema={type:'object',properties:{sourceId:string,assetId:string,optimize:{type:'string',enum:['auto','lossless','none']},preserveResolution:boolean},required:['sourceId'],additionalProperties:false};
|
|
30
|
+
const prepItemSchema={type:'object',properties:{filePath:string,sourceId:string,outputPrefix:string,rights:string,styleFamily:string,mode:{type:'string',enum:['auto','lossless','none']},maxTextureSide:integer,preserveGeometry:boolean,preserveResolution:boolean,preserveNamedNodes:boolean,preserveNodes:strings,targetTriangles:integer,targetBytes:integer,targetHeightMeters:{type:'number'},pivotMode,upAxis:{type:'string',enum:['auto','y','z']},crop:{type:'array',items:integer},trim:boolean,alphaThreshold:integer,paddingPx:integer,resize:{type:'array',items:integer},maxSide:integer,allowDeform:boolean,sliceGrid:sliceGridSchema},additionalProperties:false};
|
|
33
31
|
|
|
34
32
|
export const tools=[];
|
|
35
33
|
function define(name,description,properties={},required=[],readOnly=false){tools.push({name:'tora_'+name,description,inputSchema:{type:'object',properties,required,additionalProperties:false},annotations:{readOnlyHint:readOnly,destructiveHint:!readOnly,openWorldHint:false}});}
|
|
36
34
|
define('brief','Read current production instructions and core authoring documentation. Load domain guides with packs or legacy full references with full:true. Pass alreadyRead:[{name,sha256}] on re-reads to omit unchanged docs.',{packs:strings,full:boolean,alreadyRead:{type:'array',items:{type:'object',properties:{name:string,sha256:string},required:['name','sha256'],additionalProperties:false}}},[],true);
|
|
37
35
|
define('capabilities','Discover supported contracts. Use packs for domains, names for exact descriptors, summary for the pack index, format:"compact" for concise schema with units, or omit all for the full registry.',{names:strings,packs:strings,summary:boolean,format:{type:'string',enum:['full','compact']}},[],true);
|
|
38
|
-
define('
|
|
36
|
+
define('starters','List tested editable playable starters and their visual asset roles. Use for simple requests that match a starter.',{},[],true);
|
|
37
|
+
define('compose_starter','Create a new editable playable draft with a complete win, timeout and Store CTA. Pick a starter using tora_starters, use its bundled CC0 assets or verified source IDs, and set deliver:true to write the draft, editable bundle, and QA evidence together.',starterInputProperties,['id','starter']);
|
|
39
38
|
define('create','Create an empty editable native project. Read tora_brief first.',{id:string,name:string,androidUrl:string},['id','name']);
|
|
40
|
-
define('inspect','Inspect current state and revision identity. Use tree:true for a compact scene outline, narrow with ids/search, or full:true for the complete project.',{id:string,revisionId:string,ids:strings,fields:strings,search:string,full:boolean,tree:boolean,sceneId:string},['id'],true);
|
|
39
|
+
define('inspect','Inspect current state and revision identity. Use tree:true for a compact scene outline, narrow with ids/search, or full:true for the complete project. includeBudget adds the selected target/variant budget; includeReview adds compact pending review requests.',{id:string,revisionId:string,ids:strings,fields:strings,search:string,full:boolean,tree:boolean,sceneId:string,includeBudget:boolean,includeReview:boolean,target:string,variantId:string},['id'],true);
|
|
41
40
|
define('edit','Preview and commit native operations against expected revision. Supply operations or commitPreviewDigest (not both). Scope lists intended changed IDs; scopeCreates:true auto-allows brand-new records whose pre-existing targets are in scope.',{id:string,expected,operations:{type:'array',items:{type:'object'}},scope:strings,previewOnly:boolean,previewDigest:string,commitPreviewDigest:string,scopeCreates:boolean},['id','expected','scope']);
|
|
42
|
-
define('list_assets','Search verified local and cached CC0 assets with dimensions and style families. Set includeRemote:true to also search allowlisted Kenney
|
|
43
|
-
define('fetch_cc0_pack','Fetch, license-verify, and cache one allowlisted Kenney or OpenGameArt CC0 pack into the active workspace cache.
|
|
41
|
+
define('list_assets','Search verified local and cached CC0 assets with dimensions, 3D facts, and style families. Set includeRemote:true to also search allowlisted Kenney, Quaternius, and OpenGameArt CC0 packs.',{query:string,kind:{type:'string',enum:['sprite','audio','mesh']},styleFamily:string,includeRemote:boolean,limit:integer},[],true);
|
|
42
|
+
define('fetch_cc0_pack','Fetch, license-verify, optimize, and cache one allowlisted Kenney, Quaternius, or OpenGameArt CC0 pack into the active workspace cache. Supports 2D, audio, and bounded 3D model preparation.',fetchCc0Properties,['sourceUrl']);
|
|
44
43
|
define('stage_cc0_assets','Stage up to 32 verified local or cached remote CC0 assets into a project in one atomic revision with server-enforced provenance and single visual style family.',{id:string,expected,items:{type:'array',items:stageCc0ItemSchema}},['id','expected','items']);
|
|
45
|
-
define('prep_assets','
|
|
46
|
-
define('upload_asset','Upload and optimize PNG/JPEG/WAV/MP3 up to 8 MiB, or register a Tora mesh. Supply base64 data, a workspace filePath, or sourceHash from a retained original. Auto is default; lossless/none and preserveResolution are optional.',{id:string,expected,filePath:string,asset:assetSchema},['id','expected','asset']);
|
|
44
|
+
define('prep_assets','Prepare directory-based OBJ/glTF/GLB models with local dependencies, or prepare PNG/JPEG assets mechanically (crop, trim transparent padding, aspect-safe resize, or grid slice) into .tora/prepared-assets with hash-bound provenance receipts for tora_upload_assets.',{items:{type:'array',items:prepItemSchema}},['items']);
|
|
47
45
|
define('upload_assets','Batch upload and optimize up to 32 PNG/JPEG/WAV/MP3/mesh assets in one atomic revision. Prefer workspace filePath (avoids the 12 MiB MCP frame limit) or supply base64 data / retained sourceHash.',{id:string,expected,items:{type:'array',items:{type:'object',properties:{filePath:string,asset:assetSchema},required:['asset'],additionalProperties:false}}},['id','expected','items']);
|
|
48
46
|
define('render','Write an HTML scene preview to output. Open it in a browser for visual inspection; this tool does not capture screenshots.',{id:string,revisionId:string,sceneId:string,output:string},['id','output']);
|
|
49
|
-
define('qa','Run deterministic static, acoustic, four-viewport layout, primary-interaction, and motion filmstrip QA on a native revision. Pass recordVideo:true for an opt-in WebM clip. A pass is engineering verification, not creative, device, or network acceptance.',{id:string,revisionId:string,output:string,target:{type:'string',enum:[...targets]},motionFilmstrip:boolean,recordVideo:boolean},['id']);
|
|
50
|
-
define('export','Write standalone HTML, any of seven ad-network HTML/ZIP artifacts, a batch of targets to outputDir, or an editable project bundle. Network exports must pass Creative QA; project format exports the current working head. Passing QA is not visual, device, or network approval.',{id:string,revisionId:string,output:string,format:{type:'string',enum:['project']},target:{type:'string',enum:[...targets]},targets:{type:'array',items:{type:'string',enum:[...targets]}},outputDir:string},['id']);
|
|
47
|
+
define('qa','Run deterministic static, acoustic, four-viewport layout, primary-interaction, and motion filmstrip QA on a native revision. Pass recordVideo:true for an opt-in WebM clip or fitTargetBudget:true to verify a target-fitted export variant. A pass is engineering verification, not creative, device, or network acceptance.',{id:string,revisionId:string,output:string,target:{type:'string',enum:[...targets]},motionFilmstrip:boolean,recordVideo:boolean,fitTargetBudget:boolean,variantId:string,confirmReviewed:string},['id']);
|
|
48
|
+
define('export','Write standalone HTML, any of seven ad-network HTML/ZIP artifacts, a batch of targets to outputDir, a pinned variant matrix, or an editable project bundle. Set fitTargetBudget:true to opt in to deterministic export-time budget fitting without mutating stored revisions. Network exports must pass Creative QA and Rust artifact inspection on the exact delivered artifact; project format exports the current working head. Passing QA is not visual, device, or network approval.',{id:string,revisionId:string,output:string,format:{type:'string',enum:['project']},target:{type:'string',enum:[...targets]},targets:{type:'array',items:{type:'string',enum:[...targets]}},variants:strings,variantId:string,outputDir:string,fitTargetBudget:boolean,confirmReviewed:string},['id']);
|
|
49
|
+
define('variants','List, materialize/diff, upsert, delete, or create preset creative variants. Locale variants require complete visible component, variable, and runtime-action translations.',{id:string,revisionId:string,action:{type:'string',enum:['list','diff','upsert','delete','preset']},variantId:string,variant:{type:'object'},expectedVariantRevision:integer,preset:string,label:string,language:string,texts:{type:'object'},actionTexts:{type:'object'},variables:{type:'object'},storeUrl:string,direction:{type:'string',enum:['auto','ltr','rtl']},text:string},['id','action']);
|
|
51
50
|
define('history','Save, undo or redo against expected revision.',{id:string,expected,action:{type:'string',enum:['save','undo','redo']}},['id','expected','action']);
|
|
52
|
-
define('review_claim','Claim
|
|
53
|
-
define('review_propose','Submit
|
|
54
|
-
define('review_resolve','Run an enabled deterministic review intent through the shared native candidate service. Does not promote the candidate.',{id:string,requestId:string},['id','requestId']);
|
|
51
|
+
define('review_claim','Claim a scoped editor review request. Returns its exact baseline, native record scopes, notes, frames, and any existing candidate.',{id:string,requestId:string},['id','requestId']);
|
|
52
|
+
define('review_propose','Submit native operations for every note in a review request. The stored request supplies authorization. Creates are checked against the computed diff and shared reference rules; candidates require standalone-browser QA and are never committed automatically.',{id:string,requestId:string,proposalId:string,operations:{type:'array',items:{type:'object'}},addressedNoteIds:strings,summary:string},['id','requestId','proposalId','operations','addressedNoteIds','summary']);
|
|
55
53
|
define('review_needs_scope','Explain why a claimed note needs a different or broader edit before attempting it.',{id:string,requestId:string,reason:string},['id','requestId','reason']);
|
|
56
|
-
define('intake_read','Read a local studio intake and list source asset IDs and the brief.',{id:string},['id'],true);
|
|
57
|
-
define('intake_claim','Claim a submitted studio intake. Use the Harvest Restore or Star Salvage concept contract selected by the intake and reference the retained asset IDs.',{id:string},['id']);
|
|
58
|
-
define('intake_build','Build the initial Harvest Restore or Star Salvage playable from an intake with its v2 concept. Omit harvest.assets or salvage.assets, which are resolved from the intake.',{id:string,concept:{type:'object'}},['id']);
|
|
59
54
|
|
|
60
55
|
function valid(value,schema){
|
|
61
56
|
if(schema.type==='object'){if(!value||typeof value!=='object'||Array.isArray(value))return false;if(schema.required?.some(k=>!Object.hasOwn(value,k)))return false;if(schema.additionalProperties===false&&Object.keys(value).some(k=>!Object.hasOwn(schema.properties,k)))return false;return Object.entries(schema.properties??{}).every(([k,s])=>!Object.hasOwn(value,k)||valid(value[k],s));}
|
|
62
57
|
if(schema.type==='array')return Array.isArray(value)&&value.every(v=>valid(v,schema.items));
|
|
63
58
|
if(schema.type==='integer')return Number.isInteger(value);
|
|
59
|
+
if(schema.type==='number')return typeof value==='number'&&Number.isFinite(value);
|
|
64
60
|
return typeof value===schema.type&&(!schema.enum||schema.enum.includes(value));
|
|
65
61
|
}
|
|
66
62
|
|
|
@@ -78,8 +74,7 @@ export function createMcpServer({
|
|
|
78
74
|
const store=new ProjectStore(resolvedStoreRoot,{workspaceRoot:ws});
|
|
79
75
|
const service=new NativeService(store,new EditorState(store),{browserProvider});
|
|
80
76
|
const agent=new NativeAgentTools(service);
|
|
81
|
-
const review=new NativeReview(service
|
|
82
|
-
const intakes=new ReviewIntake(service);
|
|
77
|
+
const review=new NativeReview(service);
|
|
83
78
|
const assetCatalog=catalog??new AssetCatalog({root:PACKAGE_ROOT});
|
|
84
79
|
const cc0Fetcher=remoteFetcher??new RemoteCc0Fetcher({workspaceRoot:ws,catalog:assetCatalog});
|
|
85
80
|
|
|
@@ -123,7 +118,7 @@ export function createMcpServer({
|
|
|
123
118
|
if(known.get(doc.name)===sha256)return {name:doc.name,path:doc.path,sha256,omitted:true};
|
|
124
119
|
return doc;
|
|
125
120
|
});
|
|
126
|
-
briefRead=true;return {documents,digests,availablePacks:availablePacks.map(({id,description})=>({id,description})),store:store.root,workspace:ws,instructions:'Apply these briefs. Establish one coherent visual style and an asset plan before implementation. Use
|
|
121
|
+
briefRead=true;return {documents,digests,availablePacks:availablePacks.map(({id,description})=>({id,description})),store:store.root,workspace:ws,instructions:'Apply these briefs. Establish one coherent visual style and an asset plan before implementation. Use retained project assets or free third-party libraries with verified commercial-use license evidence, author, source URL, and source hashes. Keep visual assets within one style family; audio may use a separate compatible pack. Asset creation and image generation are outside this authoring workflow. Inspect packaged screenshots and footage; tests do not establish visual quality. Use connected browser tools to inspect actual exported output.'};
|
|
127
122
|
}
|
|
128
123
|
if(name==='tora_capabilities'){
|
|
129
124
|
if(args.summary)return capabilitySummary();
|
|
@@ -151,15 +146,22 @@ export function createMcpServer({
|
|
|
151
146
|
remotePacks:result.remotePacks,
|
|
152
147
|
};
|
|
153
148
|
}
|
|
149
|
+
if(name==='tora_starters')return listStarters();
|
|
154
150
|
if(!['tora_inspect'].includes(name)&&!briefRead)throw Error('E_MCP_READ_BRIEF_FIRST');
|
|
151
|
+
if(name==='tora_compose_starter')return composeStarter(args,{service,catalog:assetCatalog,remoteFetcher:cc0Fetcher,workspaceRoot:ws});
|
|
152
|
+
if(name==='tora_variants'){
|
|
153
|
+
try{return await agent.run({...args,command:'variants'});}
|
|
154
|
+
catch(err){if(err.message==='E_AGENT_ARGUMENT')throw Error('E_MCP_ARGUMENT',{cause:err});throw err;}
|
|
155
|
+
}
|
|
155
156
|
if(name==='tora_fetch_cc0_pack'){
|
|
156
|
-
const receipt=await cc0Fetcher.fetchPackWithFallback(
|
|
157
|
+
const receipt=await cc0Fetcher.fetchPackWithFallback(args);
|
|
157
158
|
return {
|
|
158
159
|
online:receipt.online!==false,
|
|
159
160
|
...(receipt.warning?{warning:receipt.warning}:{}),
|
|
160
161
|
...(receipt.error?{error:receipt.error}:{}),
|
|
161
162
|
...(receipt.sourceId?{sourceId:receipt.sourceId,provider:receipt.provider,packTitle:receipt.packTitle,author:receipt.author,license:receipt.license,sourceUrl:receipt.sourceUrl,cached:Boolean(receipt.cached)}:{}) ,
|
|
162
|
-
files:(receipt.files??[]).map(({
|
|
163
|
+
files:(receipt.files??[]).map(({storedPath,masterStoredPath,...file})=>{void storedPath;void masterStoredPath;return file;}),
|
|
164
|
+
skippedModels:receipt.skippedModels??[],totalMatchingModels:receipt.totalMatchingModels??0,truncated:Boolean(receipt.truncated),remainingModelPaths:receipt.remainingModelPaths??[],
|
|
163
165
|
...(receipt.fallbackLocalMatches?{fallbackLocalMatches:receipt.fallbackLocalMatches}:{}),
|
|
164
166
|
};
|
|
165
167
|
}
|
|
@@ -171,62 +173,29 @@ export function createMcpServer({
|
|
|
171
173
|
return prepAssets({workspaceRoot:ws,items:args.items,catalog:assetCatalog,remoteFetcher:cc0Fetcher});
|
|
172
174
|
}
|
|
173
175
|
if(name==='tora_review_claim')return review.claim(args.id,args.requestId);
|
|
174
|
-
if(name==='tora_review_propose')return review.propose(
|
|
175
|
-
if(name==='tora_review_resolve'){
|
|
176
|
-
const result=await review.resolveDeterministic(args.id,args.requestId);
|
|
177
|
-
if(!result)throw Error('E_REVIEW_INTENT_UNSUPPORTED');
|
|
178
|
-
return result;
|
|
179
|
-
}
|
|
176
|
+
if(name==='tora_review_propose'){const {id,...proposal}=args;return review.propose(id,proposal);}
|
|
180
177
|
if(name==='tora_review_needs_scope')return review.needsScope(args.id,args.requestId,args.reason);
|
|
181
|
-
if(name==='tora_intake_read')return intakes.read(args.id);
|
|
182
|
-
if(name==='tora_intake_claim')return intakes.claim(args.id);
|
|
183
|
-
if(name==='tora_intake_build')return intakes.build(args.id,args.concept?{concept:args.concept}:{});
|
|
184
|
-
if(name==='tora_upload_asset'){
|
|
185
|
-
const current=await service.read(args.id);if(current.revisionId!==args.expected.revisionId||current.contentHash!==args.expected.contentHash)throw Error('E_NATIVE_STALE');
|
|
186
|
-
const asset={...args.asset},sources=[Boolean(args.filePath),Boolean(asset.data),Boolean(asset.sourceHash)];if(sources.filter(Boolean).length!==1)throw Error('E_MCP_ARGUMENT');
|
|
187
|
-
let provenance;
|
|
188
|
-
if(args.filePath){
|
|
189
|
-
const bytes=await readUploadFile(ws,args.filePath);
|
|
190
|
-
const prepared=await resolvePreparedProvenance(ws,args.filePath,bytes);
|
|
191
|
-
if(prepared){
|
|
192
|
-
provenance=prepared.provenance;
|
|
193
|
-
if(prepared.rights&&!prepared.provenance.includes('"studio-original"'))asset.rights=prepared.rights;
|
|
194
|
-
}
|
|
195
|
-
asset.data=bytes.toString('base64');
|
|
196
|
-
}
|
|
197
|
-
if(asset.sourceHash){asset.data=(await readOriginal(resolve(store.root,args.id),asset.sourceHash)).toString('base64');delete asset.sourceHash;}
|
|
198
|
-
const r=await service.upload(args.id,{...args,asset,...(provenance?{provenance}:{})});return {status:'UPLOADED',asset:r.asset,expected:{revisionId:r.revisionId,contentHash:r.contentHash}};
|
|
199
|
-
}
|
|
200
178
|
if(name==='tora_upload_assets'){
|
|
201
179
|
if(!Array.isArray(args.items)||args.items.length<1||args.items.length>32)throw Error('E_MCP_ARGUMENT');
|
|
202
|
-
const current=await service.read(args.id);if(current.revisionId!==args.expected.revisionId||current.contentHash!==args.expected.contentHash)throw Error('E_NATIVE_STALE');
|
|
203
180
|
for(const item of args.items){
|
|
204
|
-
|
|
205
|
-
if(sources.filter(Boolean).length!==1)throw Error('E_MCP_ARGUMENT');
|
|
181
|
+
if([item.filePath,item.asset?.data,item.asset?.sourceHash,item.asset?.useOriginal].filter(Boolean).length!==1)throw Error('E_MCP_ARGUMENT');
|
|
206
182
|
}
|
|
207
|
-
const assets=
|
|
208
|
-
|
|
209
|
-
if(item.filePath){
|
|
210
|
-
const bytes=await readUploadFile(ws,item.filePath);
|
|
211
|
-
const prepared=await resolvePreparedProvenance(ws,item.filePath,bytes);
|
|
212
|
-
if(prepared){
|
|
213
|
-
asset.provenance=prepared.provenance;
|
|
214
|
-
if(prepared.rights&&!prepared.provenance.includes('"studio-original"'))asset.rights=prepared.rights;
|
|
215
|
-
}
|
|
216
|
-
asset.data=bytes.toString('base64');
|
|
217
|
-
}
|
|
218
|
-
return asset;
|
|
219
|
-
});
|
|
220
|
-
const r=await service.uploadBatch(args.id,{expected:args.expected,assets});
|
|
183
|
+
const assets=args.items.map(item=>item.asset);
|
|
184
|
+
const r=await service.uploadBatch(args.id,{expected:args.expected,assets},{workspaceRoot:ws,filePaths:args.items.map(item=>item.filePath)});
|
|
221
185
|
return {status:'UPLOADED',assets:r.assets,expected:{revisionId:r.revisionId,contentHash:r.contentHash}};
|
|
222
186
|
}
|
|
223
187
|
if(name==='tora_export'&&args.format==='project'&&args.revisionId)throw Error('E_MCP_PROJECT_EXPORT_HEAD_ONLY');
|
|
224
188
|
if(name==='tora_export'){
|
|
225
189
|
const isBatch=args.targets!==undefined;
|
|
226
190
|
if(isBatch&&(args.output||args.target||args.format||!args.outputDir))throw Error('E_MCP_ARGUMENT');
|
|
227
|
-
if(!isBatch&&(!args.output||args.outputDir))throw Error('E_MCP_ARGUMENT');
|
|
191
|
+
if(!isBatch&&(!args.output||args.outputDir||args.variants!==undefined))throw Error('E_MCP_ARGUMENT');
|
|
192
|
+
if(isBatch&&args.variants!==undefined&&(!args.variants.length||args.variantId))throw Error('E_MCP_ARGUMENT');
|
|
193
|
+
}
|
|
194
|
+
const input={...args,command:name.slice(5)};
|
|
195
|
+
for(const key of ['output','outputDir']){
|
|
196
|
+
if(typeof input[key]==='string'&&input[key].length)input[key]=resolve(ws,input[key]);
|
|
228
197
|
}
|
|
229
|
-
return agent.run(
|
|
198
|
+
return agent.run(input);
|
|
230
199
|
}
|
|
231
200
|
|
|
232
201
|
async function dispatch(request){
|
|
@@ -234,7 +203,7 @@ export function createMcpServer({
|
|
|
234
203
|
const notification=!Object.hasOwn(request,'id');
|
|
235
204
|
if(notification){if(request.method==='notifications/initialized'&&initialized)ready=true;return;}
|
|
236
205
|
const {id,method}=request;
|
|
237
|
-
if(method==='initialize'){if(initialized)return error(id,-32600,'Already initialized');if(!request.params?.protocolVersion)return error(id,-32602,'Missing protocolVersion');initialized=true;return {jsonrpc:'2.0',id,result:{protocolVersion:'2025-11-25',serverInfo:{name:'tora',version:
|
|
206
|
+
if(method==='initialize'){if(initialized)return error(id,-32600,'Already initialized');if(!request.params?.protocolVersion)return error(id,-32602,'Missing protocolVersion');initialized=true;return {jsonrpc:'2.0',id,result:{protocolVersion:'2025-11-25',serverInfo:{name:'tora',version:packageVersion(PACKAGE_ROOT)},capabilities:{tools:{}},instructions:'Use tora_brief before authoring. Follow current production rules and inspect actual visual output. Use tora_capabilities for supported contracts. This local service shares Tora native project storage; no HTTP endpoint is needed.'}};}
|
|
238
207
|
if(method==='ping')return {jsonrpc:'2.0',id,result:{}};
|
|
239
208
|
if(!ready)return error(id,-32000,'Initialize first');
|
|
240
209
|
if(method==='tools/list')return {jsonrpc:'2.0',id,result:{tools}};
|
|
@@ -243,9 +212,8 @@ export function createMcpServer({
|
|
|
243
212
|
const result=await call(request.params?.name,request.params?.arguments??{});
|
|
244
213
|
const content=[];
|
|
245
214
|
if(request.params.name==='tora_review_claim'){
|
|
246
|
-
const {
|
|
215
|
+
const {frames,...details}=result;
|
|
247
216
|
content.push({type:'text',text:JSON.stringify(details)});
|
|
248
|
-
if(frame)content.push({type:'image',mimeType:'image/jpeg',data:frame});
|
|
249
217
|
for(const {noteId,data} of frames??[]){
|
|
250
218
|
content.push({type:'text',text:'Frozen frame for note '+noteId},{type:'image',mimeType:'image/jpeg',data});
|
|
251
219
|
}
|
|
@@ -93,3 +93,127 @@ export function validateToraMesh(bytes, code = 'E_NATIVE_MESH_MALFORMED') {
|
|
|
93
93
|
}
|
|
94
94
|
return {vertexCount, indexCount};
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
const ALLOWED_GLTF_EXTENSIONS = new Set([
|
|
98
|
+
'KHR_mesh_quantization',
|
|
99
|
+
'KHR_materials_unlit',
|
|
100
|
+
'KHR_texture_transform',
|
|
101
|
+
'KHR_materials_emissive_strength',
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
/** Pure Uint8Array validator for Tora's strict glTF 2.0 binary (.glb) delivery subset. */
|
|
105
|
+
export function validateGlbHeader(bytes, code = 'E_MODEL_CORRUPT', maxBytes = 700000) {
|
|
106
|
+
if (!(bytes instanceof Uint8Array) || bytes.length < 28 || bytes.length > maxBytes) fail(code);
|
|
107
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
108
|
+
if (view.getUint32(0, true) !== 0x46546c67 || view.getUint32(4, true) !== 2 || view.getUint32(8, true) !== bytes.length) fail(code);
|
|
109
|
+
const jsonLen = view.getUint32(12, true);
|
|
110
|
+
if (jsonLen === 0 || jsonLen % 4 !== 0 || view.getUint32(16, true) !== 0x4e4f534a || 20 + jsonLen > bytes.length) fail(code);
|
|
111
|
+
let gltf;
|
|
112
|
+
try {
|
|
113
|
+
gltf = JSON.parse(new globalThis.TextDecoder('utf-8', {fatal: true}).decode(bytes.subarray(20, 20 + jsonLen)));
|
|
114
|
+
} catch {
|
|
115
|
+
fail(code);
|
|
116
|
+
}
|
|
117
|
+
const binAt = 20 + jsonLen;
|
|
118
|
+
let binLen = 0;
|
|
119
|
+
if (binAt < bytes.length) {
|
|
120
|
+
if (binAt + 8 > bytes.length || view.getUint32(binAt + 4, true) !== 0x004e4942) fail(code);
|
|
121
|
+
binLen = view.getUint32(binAt, true);
|
|
122
|
+
if (binLen % 4 !== 0 || binAt + 8 + binLen !== bytes.length) fail(code);
|
|
123
|
+
}
|
|
124
|
+
if (!gltf || typeof gltf !== 'object' || gltf.asset?.version !== '2.0') fail(code);
|
|
125
|
+
if (gltf.cameras?.length) fail(code);
|
|
126
|
+
const skins = gltf.skins ?? [];
|
|
127
|
+
const gltfAnimations = gltf.animations ?? [];
|
|
128
|
+
if (!Array.isArray(skins) || skins.length > 4) fail(code);
|
|
129
|
+
if (!Array.isArray(gltfAnimations) || gltfAnimations.length > 16) fail(code);
|
|
130
|
+
for (const ext of [...(gltf.extensionsUsed ?? []), ...(gltf.extensionsRequired ?? [])]) {
|
|
131
|
+
if (!ALLOWED_GLTF_EXTENSIONS.has(ext)) fail(code);
|
|
132
|
+
}
|
|
133
|
+
const stack = [gltf];
|
|
134
|
+
while (stack.length) {
|
|
135
|
+
const cur = stack.pop();
|
|
136
|
+
if (!cur || typeof cur !== 'object') continue;
|
|
137
|
+
if (!Array.isArray(cur)) {
|
|
138
|
+
if (Object.hasOwn(cur, 'uri')) fail(code);
|
|
139
|
+
for (const [k, v] of Object.entries(cur)) {
|
|
140
|
+
if (k !== 'extras' && v && typeof v === 'object') stack.push(v);
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
for (const item of cur) if (item && typeof item === 'object') stack.push(item);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (!Array.isArray(gltf.meshes) || gltf.meshes.length === 0 || !Array.isArray(gltf.scenes) || gltf.scenes.length === 0) fail(code);
|
|
147
|
+
if (!Array.isArray(gltf.buffers) || gltf.buffers.length !== 1 || gltf.buffers[0].byteLength > binLen) fail(code);
|
|
148
|
+
const accessors = gltf.accessors ?? [];
|
|
149
|
+
const nodes = gltf.nodes ?? [];
|
|
150
|
+
for (const skin of skins) {
|
|
151
|
+
if (!Array.isArray(skin?.joints) || skin.joints.length < 1 || skin.joints.length > 64) fail(code);
|
|
152
|
+
for (const jointIdx of skin.joints) {
|
|
153
|
+
if (!Number.isInteger(jointIdx) || jointIdx < 0 || jointIdx >= nodes.length) fail(code);
|
|
154
|
+
}
|
|
155
|
+
if (skin.inverseBindMatrices !== undefined) {
|
|
156
|
+
const ibmAcc = accessors[skin.inverseBindMatrices];
|
|
157
|
+
if (!ibmAcc || ibmAcc.type !== 'MAT4' || ibmAcc.componentType !== 5126 || !Number.isInteger(ibmAcc.count) || ibmAcc.count < skin.joints.length) fail(code);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
let keyframes = 0;
|
|
161
|
+
const animations = [];
|
|
162
|
+
for (let i = 0; i < gltfAnimations.length; i++) {
|
|
163
|
+
const anim = gltfAnimations[i];
|
|
164
|
+
const samplers = anim?.samplers ?? [];
|
|
165
|
+
const channels = anim?.channels ?? [];
|
|
166
|
+
if (!Array.isArray(samplers) || !Array.isArray(channels)) fail(code);
|
|
167
|
+
for (const sampler of samplers) {
|
|
168
|
+
const interp = sampler?.interpolation ?? 'LINEAR';
|
|
169
|
+
if (interp !== 'LINEAR' && interp !== 'STEP') fail(code);
|
|
170
|
+
const inAcc = accessors[sampler?.input];
|
|
171
|
+
const outAcc = accessors[sampler?.output];
|
|
172
|
+
if (!inAcc || !outAcc || inAcc.type !== 'SCALAR' || inAcc.componentType !== 5126 || !Number.isInteger(inAcc.count) || inAcc.count < 1 || outAcc.count !== inAcc.count) fail(code);
|
|
173
|
+
keyframes += inAcc.count;
|
|
174
|
+
}
|
|
175
|
+
for (const ch of channels) {
|
|
176
|
+
if (!Number.isInteger(ch?.sampler) || ch.sampler < 0 || ch.sampler >= samplers.length) fail(code);
|
|
177
|
+
const targetNode = ch?.target?.node;
|
|
178
|
+
if (targetNode !== undefined && (!Number.isInteger(targetNode) || targetNode < 0 || targetNode >= nodes.length)) fail(code);
|
|
179
|
+
}
|
|
180
|
+
animations.push(typeof anim?.name === 'string' && anim.name.length > 0 ? anim.name : `clip_${i}`);
|
|
181
|
+
}
|
|
182
|
+
if (keyframes > 8192) fail(code);
|
|
183
|
+
let triangles = 0, vertices = 0, drawCalls = 0;
|
|
184
|
+
for (const mesh of gltf.meshes) {
|
|
185
|
+
for (const prim of mesh.primitives ?? []) {
|
|
186
|
+
drawCalls++;
|
|
187
|
+
const posAcc = accessors[prim.attributes?.POSITION];
|
|
188
|
+
if (!posAcc || !Number.isInteger(posAcc.count) || posAcc.count < 1 || posAcc.count > 65535) fail(code);
|
|
189
|
+
vertices += posAcc.count;
|
|
190
|
+
if (prim.indices !== undefined) {
|
|
191
|
+
const idxAcc = accessors[prim.indices];
|
|
192
|
+
if (!idxAcc || !Number.isInteger(idxAcc.count) || idxAcc.count < 3 || idxAcc.count % 3 !== 0) fail(code);
|
|
193
|
+
triangles += idxAcc.count / 3;
|
|
194
|
+
} else {
|
|
195
|
+
if (posAcc.count < 3 || posAcc.count % 3 !== 0) fail(code);
|
|
196
|
+
triangles += posAcc.count / 3;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (triangles < 1 || triangles > 50000) fail(code);
|
|
201
|
+
const subNodes = [];
|
|
202
|
+
const seenNames = new Set();
|
|
203
|
+
for (const node of gltf.nodes ?? []) {
|
|
204
|
+
if (typeof node?.name === 'string' && node.name.length > 0 && !seenNames.has(node.name)) {
|
|
205
|
+
seenNames.add(node.name);
|
|
206
|
+
subNodes.push(node.name);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
triangles,
|
|
211
|
+
vertices,
|
|
212
|
+
drawCalls,
|
|
213
|
+
materials: (gltf.materials ?? []).length,
|
|
214
|
+
textures: (gltf.images ?? []).length,
|
|
215
|
+
skins: skins.length,
|
|
216
|
+
animations,
|
|
217
|
+
subNodes,
|
|
218
|
+
};
|
|
219
|
+
}
|