@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
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import {randomUUID} from 'node:crypto';
|
|
2
|
-
import {constants} from 'node:fs';
|
|
3
|
-
import {mkdir,open,rename,rm} from 'node:fs/promises';
|
|
4
|
-
import {join} from 'node:path';
|
|
5
|
-
import process from 'node:process';
|
|
6
|
-
import {check} from './document.mjs';
|
|
7
|
-
import {assertStorePath} from './store-path.mjs';
|
|
8
|
-
import {modelListRequest,modelVerificationRequest,publicPlayableProviders,verifiedPlayableModel} from './review-provider.mjs';
|
|
9
|
-
|
|
10
|
-
const legacyKeyFile='.orcarouter.key';
|
|
11
|
-
const verifiedFile='.tora-connection.json';
|
|
12
|
-
const validKey=key=>typeof key==='string'&&/^[!-~]{8,4096}$/.test(key);
|
|
13
|
-
const keyHint=key=>typeof key==='string'&&key.length>=4?'…'+key.slice(-4):'';
|
|
14
|
-
|
|
15
|
-
function mapHttpFailure(status){
|
|
16
|
-
const failures={
|
|
17
|
-
401:'E_MODEL_AUTH',
|
|
18
|
-
402:'E_MODEL_QUOTA',
|
|
19
|
-
403:'E_MODEL_FORBIDDEN',
|
|
20
|
-
404:'E_MODEL_UNAVAILABLE',
|
|
21
|
-
408:'E_MODEL_TIMEOUT',
|
|
22
|
-
429:'E_MODEL_RATE_LIMIT',
|
|
23
|
-
504:'E_MODEL_TIMEOUT',
|
|
24
|
-
};
|
|
25
|
-
return failures[status]??(status>=500?'E_MODEL_UPSTREAM':'E_MODEL_REQUEST');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Keep credentials beside project directories with 0600 permissions so individual
|
|
29
|
-
// project bundles and review journals can be shared without exposing secrets.
|
|
30
|
-
export class ReviewConnection{
|
|
31
|
-
constructor(storeRoot,{fetchImpl=globalThis.fetch,environment=process.env}={}){
|
|
32
|
-
this.root=storeRoot;
|
|
33
|
-
this.fetch=fetchImpl;
|
|
34
|
-
this.environment=environment;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async readSecureFile(filename){
|
|
38
|
-
await assertStorePath(this.root);
|
|
39
|
-
let file;
|
|
40
|
-
try{
|
|
41
|
-
file=await open(join(this.root,filename),constants.O_RDONLY|constants.O_NOFOLLOW|constants.O_NONBLOCK);
|
|
42
|
-
const info=await file.stat();
|
|
43
|
-
if(info.isFile()&&(info.mode&0o077)===0&&info.size<=8192){
|
|
44
|
-
return await file.readFile('utf8');
|
|
45
|
-
}
|
|
46
|
-
}catch(error){
|
|
47
|
-
if(!['ENOENT','EACCES','ELOOP'].includes(error.code))throw Error('E_REVIEW_KEY_READ',{cause:error});
|
|
48
|
-
}finally{await file?.close();}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async writeSecureFile(filename,contents){
|
|
53
|
-
const temporary=join(this.root,'.conn-'+randomUUID()+'.tmp');
|
|
54
|
-
let file;
|
|
55
|
-
try{
|
|
56
|
-
await assertStorePath(this.root);
|
|
57
|
-
await mkdir(this.root,{recursive:true});
|
|
58
|
-
file=await open(temporary,'wx',0o600);
|
|
59
|
-
await file.writeFile(contents,'utf8');
|
|
60
|
-
await file.close();
|
|
61
|
-
file=undefined;
|
|
62
|
-
await rename(temporary,join(this.root,filename));
|
|
63
|
-
}catch{
|
|
64
|
-
throw Error('E_REVIEW_KEY_SAVE');
|
|
65
|
-
}finally{
|
|
66
|
-
await file?.close();
|
|
67
|
-
await rm(temporary,{force:true}).catch(()=>{});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async readVerified(){
|
|
72
|
-
const raw=await this.readSecureFile(verifiedFile);
|
|
73
|
-
if(!raw)return null;
|
|
74
|
-
try{
|
|
75
|
-
const parsed=JSON.parse(raw);
|
|
76
|
-
if(parsed?.format!=='tora-connection-1'||!validKey(parsed.apiKey))return null;
|
|
77
|
-
const verified=verifiedPlayableModel(parsed.provider,parsed.model,{
|
|
78
|
-
endpoint:parsed.endpoint,
|
|
79
|
-
preset:parsed.preset,
|
|
80
|
-
vision:typeof parsed.vision==='boolean'?parsed.vision:undefined,
|
|
81
|
-
});
|
|
82
|
-
if(!verified)return null;
|
|
83
|
-
const vision=verified.model.capabilities?.vision!==false;
|
|
84
|
-
return {
|
|
85
|
-
provider:verified.provider.id,
|
|
86
|
-
providerLabel:verified.provider.label,
|
|
87
|
-
...(verified.provider.endpoint?{endpoint:verified.provider.endpoint}:{}),
|
|
88
|
-
...(verified.provider.preset?{preset:verified.provider.preset}:{}),
|
|
89
|
-
model:verified.model.id,
|
|
90
|
-
modelLabel:verified.model.label,
|
|
91
|
-
capabilities:verified.model.capabilities,
|
|
92
|
-
audioSummary:verified.provider.audioSummary,
|
|
93
|
-
videoSummary:verified.provider.videoSummary,
|
|
94
|
-
apiKey:parsed.apiKey,
|
|
95
|
-
vision,
|
|
96
|
-
verified:true,
|
|
97
|
-
};
|
|
98
|
-
}catch{
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async key(){
|
|
104
|
-
const saved=await this.readSecureFile(legacyKeyFile);
|
|
105
|
-
if(saved&&validKey(saved))return saved;
|
|
106
|
-
const fallback=this.environment.ORCAROUTER_API_KEY?.trim();
|
|
107
|
-
return validKey(fallback)?fallback:null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async read(){
|
|
111
|
-
const verified=await this.readVerified();
|
|
112
|
-
if(verified)return verified;
|
|
113
|
-
const legacy=await this.key();
|
|
114
|
-
if(!legacy)return null;
|
|
115
|
-
return {
|
|
116
|
-
provider:'orca',
|
|
117
|
-
providerLabel:'OrcaRouter (legacy)',
|
|
118
|
-
model:'deepseek/deepseek-v4-flash-free',
|
|
119
|
-
modelLabel:'DeepSeek Flash (legacy)',
|
|
120
|
-
capabilities:{tools:true,json:true,vision:false,audio:'tora-analyzed',video:'none'},
|
|
121
|
-
audioSummary:'Tora acoustic QA + WAV catalog',
|
|
122
|
-
videoSummary:'Text-only (no vision)',
|
|
123
|
-
apiKey:legacy,
|
|
124
|
-
vision:this.environment.TORA_REVIEW_VISION==='1',
|
|
125
|
-
verified:false,
|
|
126
|
-
legacy:true,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async status(){
|
|
131
|
-
const active=await this.read();
|
|
132
|
-
const supportedProviders=publicPlayableProviders();
|
|
133
|
-
if(!active){
|
|
134
|
-
return {configured:false,supportedProviders};
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
configured:true,
|
|
138
|
-
provider:active.provider,
|
|
139
|
-
providerLabel:active.providerLabel,
|
|
140
|
-
...(active.endpoint?{endpoint:active.endpoint}:{}),
|
|
141
|
-
...(active.preset?{preset:active.preset}:{}),
|
|
142
|
-
model:active.model,
|
|
143
|
-
modelLabel:active.modelLabel,
|
|
144
|
-
capabilities:active.capabilities,
|
|
145
|
-
audioSummary:active.audioSummary,
|
|
146
|
-
videoSummary:active.videoSummary,
|
|
147
|
-
keyHint:keyHint(active.apiKey),
|
|
148
|
-
verified:Boolean(active.verified),
|
|
149
|
-
legacy:Boolean(active.legacy),
|
|
150
|
-
supportedProviders,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async fetchJson(url,headers){
|
|
155
|
-
let response;
|
|
156
|
-
try{
|
|
157
|
-
response=await this.fetch(url,{
|
|
158
|
-
headers,
|
|
159
|
-
redirect:'error',
|
|
160
|
-
signal:globalThis.AbortSignal.timeout(10000),
|
|
161
|
-
});
|
|
162
|
-
}catch(error){
|
|
163
|
-
throw Error(['TimeoutError','AbortError'].includes(error.name)?'E_MODEL_TIMEOUT':'E_MODEL_TRANSPORT',{cause:error});
|
|
164
|
-
}
|
|
165
|
-
if(!response.ok){
|
|
166
|
-
await response.body?.cancel().catch(()=>{});
|
|
167
|
-
throw Error(mapHttpFailure(response.status));
|
|
168
|
-
}
|
|
169
|
-
try{
|
|
170
|
-
return await response.json();
|
|
171
|
-
}catch{
|
|
172
|
-
throw Error('E_MODEL_UPSTREAM');
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
async listModels({provider,apiKey,endpoint,preset}){
|
|
177
|
-
const providerId=typeof provider==='string'?provider.trim():'';
|
|
178
|
-
const key=typeof apiKey==='string'?apiKey.trim():'';
|
|
179
|
-
check(validKey(key),'E_REVIEW_KEY_FORMAT');
|
|
180
|
-
const req=modelListRequest(providerId,key,{endpoint,preset});
|
|
181
|
-
const payload=await this.fetchJson(req.url,req.headers);
|
|
182
|
-
const rawItems=providerId==='gemini'
|
|
183
|
-
?(Array.isArray(payload?.models)?payload.models:[])
|
|
184
|
-
:(Array.isArray(payload?.data)?payload.data:Array.isArray(payload?.models)?payload.models:[]);
|
|
185
|
-
const providerEntry=publicPlayableProviders().find(item=>item.id===providerId);
|
|
186
|
-
const presetEntry=providerId==='openai-compatible'?providerEntry?.presets?.find(p=>p.id===preset||(p.endpoint&&String(endpoint??'').startsWith(p.endpoint))):null;
|
|
187
|
-
const curatedList=presetEntry?.models??providerEntry?.models??[];
|
|
188
|
-
const curatedOrder=new Map(curatedList.map((item,idx)=>[item.id,idx]));
|
|
189
|
-
const seen=new Set();
|
|
190
|
-
const discovered=[];
|
|
191
|
-
for(const item of rawItems){
|
|
192
|
-
if(providerId==='gemini'){
|
|
193
|
-
const methods=Array.isArray(item?.supportedGenerationMethods)?item.supportedGenerationMethods:[];
|
|
194
|
-
if(methods.length&&!methods.includes('generateContent'))continue;
|
|
195
|
-
}
|
|
196
|
-
const rawId=providerId==='gemini'
|
|
197
|
-
?String(item?.name??'').replace(/^models\//,'')
|
|
198
|
-
:String(item?.id??item?.name??'');
|
|
199
|
-
if(!rawId||seen.has(rawId))continue;
|
|
200
|
-
const verified=verifiedPlayableModel(providerId,rawId,{
|
|
201
|
-
displayName:item?.displayName||item?.display_name||item?.name,
|
|
202
|
-
endpoint,
|
|
203
|
-
preset,
|
|
204
|
-
});
|
|
205
|
-
if(!verified)continue;
|
|
206
|
-
seen.add(rawId);
|
|
207
|
-
const contextTokens=verified.model.contextTokens
|
|
208
|
-
??(typeof item?.inputTokenLimit==='number'?item.inputTokenLimit:typeof item?.context_length==='number'?item.context_length:null);
|
|
209
|
-
discovered.push({
|
|
210
|
-
id:verified.model.id,
|
|
211
|
-
label:verified.model.label,
|
|
212
|
-
badge:curatedOrder.has(rawId)?verified.model.badge:'Live from key',
|
|
213
|
-
contextTokens,
|
|
214
|
-
capabilities:{...verified.model.capabilities},
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
discovered.sort((a,b)=>{
|
|
218
|
-
const rankA=curatedOrder.has(a.id)?curatedOrder.get(a.id):999;
|
|
219
|
-
const rankB=curatedOrder.has(b.id)?curatedOrder.get(b.id):999;
|
|
220
|
-
if(rankA!==rankB)return rankA-rankB;
|
|
221
|
-
return b.id.localeCompare(a.id,undefined,{numeric:true});
|
|
222
|
-
});
|
|
223
|
-
return {provider:providerId,models:discovered};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
async verifyFetch(url,headers){
|
|
227
|
-
let response;
|
|
228
|
-
try{
|
|
229
|
-
response=await this.fetch(url,{
|
|
230
|
-
headers,
|
|
231
|
-
redirect:'error',
|
|
232
|
-
signal:globalThis.AbortSignal.timeout(10000),
|
|
233
|
-
});
|
|
234
|
-
}catch(error){
|
|
235
|
-
throw Error(['TimeoutError','AbortError'].includes(error.name)?'E_MODEL_TIMEOUT':'E_MODEL_TRANSPORT',{cause:error});
|
|
236
|
-
}
|
|
237
|
-
await response.body?.cancel().catch(()=>{});
|
|
238
|
-
if(!response.ok)throw Error(mapHttpFailure(response.status));
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
async save(input){
|
|
242
|
-
// Legacy single-string OrcaRouter connection retained for existing local automation/tests.
|
|
243
|
-
if(typeof input==='string'){
|
|
244
|
-
const key=input.trim();
|
|
245
|
-
check(validKey(key),'E_REVIEW_KEY_FORMAT');
|
|
246
|
-
await this.verifyFetch('https://api.orcarouter.ai/v1/models',{Authorization:'Bearer '+key});
|
|
247
|
-
await this.writeSecureFile(legacyKeyFile,key);
|
|
248
|
-
return {configured:true};
|
|
249
|
-
}
|
|
250
|
-
check(input&&typeof input==='object'&&!Array.isArray(input),'E_REVIEW_KEY_FORMAT');
|
|
251
|
-
const provider=typeof input.provider==='string'?input.provider.trim():'';
|
|
252
|
-
const model=typeof input.model==='string'?input.model.trim():'';
|
|
253
|
-
const key=typeof input.apiKey==='string'?input.apiKey.trim():'';
|
|
254
|
-
const endpoint=typeof input.endpoint==='string'?input.endpoint.trim():undefined;
|
|
255
|
-
const preset=typeof input.preset==='string'?input.preset.trim():undefined;
|
|
256
|
-
const vision=typeof input.vision==='boolean'?input.vision:undefined;
|
|
257
|
-
check(validKey(key),'E_REVIEW_KEY_FORMAT');
|
|
258
|
-
const verified=verifiedPlayableModel(provider,model,{endpoint,preset,vision});
|
|
259
|
-
if(!verified)throw Error('E_MODEL_UNSUPPORTED_CAPABILITY');
|
|
260
|
-
const probe=modelVerificationRequest(verified.provider.id,verified.model.id,key,{endpoint:verified.provider.endpoint,preset:verified.provider.preset,vision:verified.model.capabilities?.vision});
|
|
261
|
-
if(verified.provider.id==='openai-compatible'){
|
|
262
|
-
const listPayload=await this.fetchJson(probe.listUrl,probe.headers);
|
|
263
|
-
const items=Array.isArray(listPayload?.data)?listPayload.data:Array.isArray(listPayload?.models)?listPayload.models:[];
|
|
264
|
-
if(items.length>0&&!items.some(item=>(item?.id??item?.name)===verified.model.id)){
|
|
265
|
-
await this.verifyFetch(probe.url,probe.headers);
|
|
266
|
-
}
|
|
267
|
-
}else{
|
|
268
|
-
await this.verifyFetch(probe.url,probe.headers);
|
|
269
|
-
}
|
|
270
|
-
await this.writeSecureFile(verifiedFile,JSON.stringify({
|
|
271
|
-
format:'tora-connection-1',
|
|
272
|
-
provider:verified.provider.id,
|
|
273
|
-
...(verified.provider.endpoint?{endpoint:verified.provider.endpoint}:{}),
|
|
274
|
-
...(verified.provider.preset?{preset:verified.provider.preset}:{}),
|
|
275
|
-
...(verified.provider.id==='openai-compatible'?{vision:Boolean(verified.model.capabilities?.vision)}:{}),
|
|
276
|
-
model:verified.model.id,
|
|
277
|
-
apiKey:key,
|
|
278
|
-
}));
|
|
279
|
-
return {
|
|
280
|
-
configured:true,
|
|
281
|
-
provider:verified.provider.id,
|
|
282
|
-
providerLabel:verified.provider.label,
|
|
283
|
-
...(verified.provider.endpoint?{endpoint:verified.provider.endpoint}:{}),
|
|
284
|
-
...(verified.provider.preset?{preset:verified.provider.preset}:{}),
|
|
285
|
-
model:verified.model.id,
|
|
286
|
-
modelLabel:verified.model.label,
|
|
287
|
-
capabilities:verified.model.capabilities,
|
|
288
|
-
audioSummary:verified.provider.audioSummary,
|
|
289
|
-
videoSummary:verified.provider.videoSummary,
|
|
290
|
-
keyHint:keyHint(key),
|
|
291
|
-
verified:true,
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
async disconnect(){
|
|
296
|
-
await assertStorePath(this.root);
|
|
297
|
-
await Promise.all([
|
|
298
|
-
rm(join(this.root,verifiedFile),{force:true}).catch(()=>{}),
|
|
299
|
-
rm(join(this.root,legacyKeyFile),{force:true}).catch(()=>{}),
|
|
300
|
-
]);
|
|
301
|
-
return {configured:false,supportedProviders:publicPlayableProviders()};
|
|
302
|
-
}
|
|
303
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export const record=(project,collection,id)=>project[collection].find(item=>item.id===id);
|
|
2
|
-
export const layout=(project,id)=>record(project,'gameplay',id+'.responsive');
|
|
3
|
-
export const pixelText=/^[A-Za-z0-9 !?.,:+/'-]+$/;
|
|
4
|
-
export const standardText={maxLength:36,pattern:pixelText.source};
|
|
5
|
-
export const fieldLimits={
|
|
6
|
-
instruction:standardText,message:standardText,'timeout-caption':standardText,
|
|
7
|
-
text:{maxLength:24,pattern:pixelText.source},
|
|
8
|
-
'landscape-inset':{min:8,max:14},'hint-delay':{min:0.5,max:6},
|
|
9
|
-
'reveal-duration':{min:0.15,max:1.25},'payoff-hold':{min:0.5,max:4},
|
|
10
|
-
'feedback-duration':{min:0.1,max:0.6},'caption-alignment':{},
|
|
11
|
-
};
|
|
12
|
-
export function assertValue(field,value){
|
|
13
|
-
const bounds=fieldLimits[field];
|
|
14
|
-
if(!bounds)throw Error('E_REVIEW_SCOPE');
|
|
15
|
-
if(field==='caption-alignment'){
|
|
16
|
-
if(value!=='center')throw Error('E_REVIEW_VALUE');
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if(bounds.min!==undefined){
|
|
20
|
-
if(!Number.isFinite(value)||value<bounds.min||value>bounds.max)throw Error('E_REVIEW_VALUE');
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if(typeof value!=='string'||!value.trim()||value.length>bounds.maxLength||!pixelText.test(value))throw Error('E_REVIEW_TEXT_FIT');
|
|
24
|
-
}
|