okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
aff3a132f
main
1import test from 'node:test' ; 2import assert from 'node:assert/strict' ; 3import { readFile } from 'node:fs/promises' ; 4import { build } from 'esbuild' ; 5 6const languages = [ 'en' , 'zh' , 'ja' , 'de' , 'es' , 'ru' , 'pt' , 'ko' , 'fr' ]; 7const catalogs = Object . fromEntries ( await Promise . all ( languages . map ( async l => [ l , ({ ...JSON . parse ( await readFile ( `src/locales/ ${ l } .json` , 'utf8' )), ...JSON . parse ( await readFile ( `src/locales/engine- ${ l } .json` , 'utf8' )), ...JSON . parse ( await readFile ( `src/locales/gui- ${ l } .json` , 'utf8' )) })]))); 8const built = await build ({ stdin :{ contents :"export * from './src/lib/plain-errors'; export * from './src/lib/i18n';" , resolveDir :process . cwd () }, bundle :true , write :false , format :'esm' , platform :'node' , loader :{ '.json' :'json' } }); 9const { plainFailure, plainFailureText, setTranslationLanguage, loadCatalog} = await import ( `data:text/javascript;base64, ${ Buffer . from ( built . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 10for ( const l of [ 'zh' , 'ja' , 'de' , 'es' , 'ru' , 'pt' , 'ko' , 'fr' ]) await loadCatalog ( l ); // the non-English catalogs load on first use (src/lib/i18n.ts loadCatalog); load them before the first tr() 11 12const cases = [ 13[ 'Strata’s tunnel for this address is already running (PID 31), so Strata did not start a second one. Stop it first (or use it as it is), then connect again here.' , 'tunnel-own-running' , / tunnel for this address is already running / ], 14[ 'GPU 2 is already used by qwen3.8-flash-next-q2_0, so this model did not fit there. Load it on another GPU, or unload qwen3.8-flash-next-q2_0 first.' , 'gpu-shared' , / no room for this one / ], 15[ 'This model needs a newer engine: Gyro-S needs engine 0.1.45.1 or newer, and this one is 0.1.45. Update the engine in Settings, then try again.' , 'engine-too-old' , / needs a newer engine / ], 16[ 'The settings file for this model has a mistake, so the model was not started. Line 4: The settings file is not valid JSON; look near line 4.' , 'settings-file' , / settings file has a mistake / ], 17[ 'The Cloudflare connector (cloudflared) is not installed here, and the app never downloads it while it runs. Install it from the optional connector component.' , 'connector-missing' , / could not find Cloudflare’s connector / ], 18[ 'The cloudflared at /usr/bin/cloudflared is version 2021.3.0, which is too old. Strata needs 2022.1.0 or newer. Update cloudflared, then retry.' , 'connector-old' , / connector on this computer is too old / ], 19[ 'The file at /x/cloudflared did not run as cloudflared. Reinstall cloudflared, then retry.' , 'connector-broken' , / did not run / ], 20[ 'lost host child is still present; retry after it exits' , 'previous-session' , / last Strata session is still closing down / ], 21[ 'server_exited' , 'start-failed' , / model stopped while starting\. / ], 22[ 'server_exited (exit code 0xC0000135)' , 'dll-missing' , / program files is missing / ], 23[ 'server_exited (exit code 0xC000007B)' , 'dll-bad' , / does not fit this computer or is damaged / ], 24[ 'server_exited (exit code 0xC0000005)' , 'crash' , / crashed while starting / ], 25[ 'server_exited (exit code 0xC000001D)' , 'cpu-unsupported' , / newer processor feature / ], 26[ 'spawn C:/x/strata.exe ENOENT' , 'file-missing' , / could not find a file / ], 27[ 'server_exited (exit code 0xC0000022)' , 'blocked' , / security software stopped / ], 28[ 'server_exited: memory guard: 5.1 GiB of RAM free is under the 6 GiB limit' , 'memory' , / ran low on memory / ], 29[ 'server_exited (exit code 137): Killed' , 'memory' , / ran low on memory / ], 30[ 'Engine stopped (exit 3). Open diagnostics or reload.' , 'start-failed' , / model stopped while starting\. / ], 31[ 'Loading took more than five minutes. Check the engine log and free memory.' , 'slow-load' , / taking too long / ], 32[ 'No engine for this PC was found in C:/x/components: the component folder holds no engine package. The app never downloads an engine while it starts or serves.' , 'engine-missing' , / engine for this computer isn’t installed yet / ], 33[ 'cannot reach huggingface.co (<urlopen error [Errno 11001] getaddrinfo failed>)' , 'network' , / couldn’t reach the internet / ], 34[ 'sha256 mismatch for Qwen3.8-Flash-Next-00001-of-00002.gguf' , 'integrity' , / safety check / ], 35[ 'The agent component (DeepSeek Harness) is not installed.' , 'assistant-missing' , / coding assistant isn’t installed / ], 36[ 'component-missing' , 'assistant-missing' , / coding assistant / ], 37[ 'Strata Control did not answer within 60 s (models list).' , 'control' , / couldn’t read its own components / ], 38[ 'Prepare this model’s vision files before enabling picture reading.' , 'picture-reading' , / Picture reading isn’t available / ], 39[ 'server_exited (exit code 1): strata generate: GPU 0 (AMD Radeon 760M Graphics, gfx1103) is not an architecture this Strata engine was compiled for (gfx1200,gfx1201); compile it for this card' , 'gpu-no-code' , / no code for the graphics card / ], 40[ 'server_exited (exit code 1): [strata] none of this computer\'s graphics cards has code in this Strata engine (it is built for gfx1200,gfx1201). Cards found: AMD Radeon RX 6800 XT (gfx1030).' , 'gpu-no-code' , / no code for the graphics card / ], 41[ 'Traceback (most recent call last):\n File "x.py", line 3' , 'technical' , / Something went wrong / ], 42]; 43 44for ( const [ raw , kind , message ] of cases ) { 45test ( `plain words for: ${ raw . slice ( 0 , 60 )} ` , () => { 46const f = plainFailure ( raw ); 47assert . equal ( f . kind , kind ); 48assert . match ( f . message , message ); 49assert . ok ( f . next , 'a next step' ); 50assert . equal ( f . detail , raw . trim (), 'the original text stays for Details' ); 51assert . doesNotMatch ( f . message , / server_exited | exit \d | component-missing | Traceback | 0x [ 0 - 9A - F ]{ 8 } / ); 52}); 53} 54 55test ( 'a DeepSeek model of an earlier Strata: Control’s own words, the folder and size kept, the next step apart (English only until the owner approves translations)' , () => { 56const d1 = 'DeepSeek-V4.1-Flash ISTA-DAS 2.00 bpw is a DeepSeek model. This version of Strata no longer runs DeepSeek models, so it was not started.' ; 57const files = ' Its files are still on this computer: 257 GB in /home/me/Strata-data/models/deepseek-v4.1-flash-ist-das-2.00bpw. Nothing was changed or deleted.' ; 58const next = 'Choose a Qwen model to run instead. If you no longer need the DeepSeek files, you can delete that folder to free the space.' ; 59for ( const message of [ d1 , d1 + files ]) { 60const f = plainFailure ( message + ' ' + next ); 61assert . equal ( f . kind , 'deepseek-retired' ); 62assert . equal ( f . message , message ); 63assert . equal ( f . next , next ); 64assert . equal ( plainFailure ( JSON . stringify ({ error :message + ' ' + next })). message , message , 'a wrapped error body too' ); 65} 66assert . notEqual ( plainFailure ( 'server_exited' ). kind , 'deepseek-retired' ); 67assert . notEqual ( plainFailure ( 'The agent component (DeepSeek Harness) is not installed.' ). kind , 'deepseek-retired' ); 68}); 69 70test ( 'an ordinary sentence is left as it is and gets no Details' , () => { 71const f = plainFailure ( 'Some model files are missing. Use Download / repair to restore them.' ); 72assert . equal ( f . kind , 'plain' ); 73assert . equal ( f . detail , undefined ); 74}); 75 76test ( 'every plain message and next step is translated in all nine languages' , () => { 77const en = catalogs . en ; 78const ids = Object . fromEntries ( Object . entries ( en ). map (([ id , text ]) => [ text , id ])); 79for ( const [ raw ] of cases ) { 80const f = plainFailure ( raw ); 81for ( const text of [ f . message , f . next ]) { 82const id = ids [ text ]; 83assert . ok ( id , `" ${ text } " is in the catalog` ); 84for ( const l of languages ) if ( l !== 'en' ) assert . notEqual ( catalogs [ l ][ id ], text , ` ${ l } : " ${ text } " is translated` ); 85} 86} 87setTranslationLanguage ( 'de' ); 88assert . notEqual ( plainFailureText ( 'server_exited' ). message , plainFailure ( 'server_exited' ). message ); 89// a missing DLL is never described as low memory 90assert . doesNotMatch ( plainFailure ( 'server_exited (exit code 0xC0000135)' ). message + plainFailure ( 'server_exited (exit code 0xC0000135)' ). next , / memory | Leave 20 / i ); 91setTranslationLanguage ( 'en' ); 92}); 93 94test ( 'missing model files are named, in every language, with a next step (#3478)' , async () => { 95const { missingFilesError, missingNames} = await import ( '../server/missing-files.mjs' ); 96const names = missingNames ([{ part :'engine' , file :'strata.exe' , status :'missing' }, { part :'native' , file :'Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf' , status :'missing' }, { part :'vision/mmproj' , file :'mmproj-F16.gguf' , status :'missing' }], 97[[ 'C:' , 'models' , 'Qwen3.6-35B-A3B-UD-Q4_K_XL-00002-of-00003.gguf' ]. join ( String . fromCharCode ( 92 )), '/data/models/mmproj-F16.gguf' ]); 98assert . deepEqual ( names , [ 'Qwen3.6-35B-A3B-UD-Q4_K_XL-00002-of-00003.gguf' , 'mmproj-F16.gguf' , 'the engine program' , 'Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf' ]); 99const error = missingFilesError ( 'qwen36-q4' , names ); 100assert . match ( error . message , / missing: Qwen3\.6-35B-A3B-UD-Q4_K_XL-00002-of-00003\.gguf, mmproj-F16\.gguf, the engine program, Qwen3\.6-35B-A3B-UD-Q4_K_XL\.gguf\. Use Download / ); 101assert . match ( error . details [ 0 ], / Missing for qwen36-q4: / ); 102const more = missingFilesError ( 'm' , [ 'a.gguf' , 'b.gguf' , 'c.gguf' , 'd.gguf' , 'e.gguf' , 'f.gguf' ]); 103assert . match ( more . message , / a\.gguf, b\.gguf, c\.gguf, d\.gguf and 2 more\. / ); 104const f = plainFailure ( error . message ); 105assert . equal ( f . kind , 'model-files-missing' ); 106assert . equal ( f . message , 'These model files are missing: Qwen3.6-35B-A3B-UD-Q4_K_XL-00002-of-00003.gguf, mmproj-F16.gguf, the engine program, Qwen3.6-35B-A3B-UD-Q4_K_XL.gguf.' ); 107assert . ok ( f . next && f . detail === error . message ); 108for ( const language of languages ) { 109setTranslationLanguage ( language ); 110const shown = plainFailureText ( error . message ); 111if ( language !== 'en' ) { 112assert . notEqual ( shown . message , f . message , ` ${ language } : the sentence is translated` ); 113assert . notEqual ( shown . next , f . next , ` ${ language } : the next step is translated` ); 114} 115assert . ok ( shown . message . includes ( 'mmproj-F16.gguf' ), ` ${ language } : the file names survive` ); 116assert . doesNotMatch ( shown . message , / \{0\} / ); 117} 118setTranslationLanguage ( 'en' ); 119assert . equal ( plainFailure ( missingFilesError ( 'm' , []). message ). kind , 'plain' , 'with no names the old sentence is left as it was' ); 120}); 121 122test ( 'the engine component is named in words, once (#3900)' , async () => { 123const { missingNames} = await import ( '../server/missing-files.mjs' ); 124assert . deepEqual ( missingNames ([{ part :'engine' , file :'component:strata-engine' }], [ 'component:strata-engine' ]), [ 'the engine program' ]); 125});