okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
fa6367a98
main
1/** 2* Which files and folders of the staged Harness are dropped, and the check that nothing the Harness imports is gone. 3* 4* The 2026-10-17 tester report: on Linux and Mac every agent chat failed ("session/create ... waiting for workflowEngine"). 5* Cause: the old rule "drop any folder named after another operating system" also removed the Harness's own JavaScript package 6* `@deepseek-ai/dsh-win32-process`. It is plain JS (no binary), and `dsh-subprocess-local` and `dsh-sandbox-local` import it by 7* name on every platform, so those two plugins failed to load, and everything waiting on them (shell, subprocess, ptcRuntime, 8* workflowEngine) never started. Windows kept it (the rule differs there), so the Windows tests passed. 9*/ 10import { existsSync , readFileSync , readdirSync } from 'node:fs' ; 11import { join , sep } from 'node:path' ; 12 13export const OTHER_OS = { 14win32 :/ ( ^ | [ \\ /._- ])( darwin | linux | android | freebsd | musl )([ \\ /._- ] | $ ) / i , 15darwin :/ ( ^ | [ \\ /._- ])( win32 | linux | android | freebsd | musl )([ \\ /._- ] | $ ) / i , 16// Linux: the AppImage bundler (linuxdeploy) resolves the libraries of every ELF file under resources and stops on one it 17// cannot satisfy (koffi's musl build wants libc.musl). The app is glibc x86_64, so musl and other-CPU builds are dropped. 18linux :/ ( ^ | [ \\ /._- ])( win32 | darwin | android | freebsd | musl | arm64 | aarch64 | armv7 | arm | ia32 | riscv64 | ppc64 | s390x | loong64 )([ \\ /._- ] | $ ) / i , 19}; 20const NATIVE_FOLDER = / prebuild | bin | native | platform | - ( win32 | darwin | linux ) / i ; 21 22/** The Harness's own JavaScript packages (`@deepseek-ai/dsh-*`) are code every platform imports by name; never drop one. */ 23export function isHarnessCodePackage ( path ) { 24const parts = path . split ( sep ); 25const i = parts . lastIndexOf ( '@deepseek-ai' ); 26return i >= 0 && i === parts . length - 2 && parts [ i + 1 ]. startsWith ( 'dsh-' ); 27} 28 29/** True when the folder `path` (a directory named `name`) is another operating system's prebuilt binary and can go. */ 30export function isOtherOsBinaryFolder ( platform , name , path ) { 31const rule = OTHER_OS [ platform ] ?? OTHER_OS . linux ; 32if ( isHarnessCodePackage ( path )) return false ; 33return rule . test ( name ) && NATIVE_FOLDER . test ( path ); 34} 35 36/** Imports the Windows copy (which works) is also without: browser-side or dev-only bundles, and the document converter the app drops on purpose. */ 37const KNOWN_ABSENT = new Set ([ 38'@deepseek-ai/libreoffice-kit' , '@deepseek-ai/dsh-client-ui-dockkit' , '@deepseek-ai/dsh-client-web' , 39'@deepseek-ai/dsh-experimental-webworker-runtime' , '@deepseek-ai/dsh-remote-mock' , '@deepseek-ai/dsh-client-test-runtime' , 40]); 41 42function jsFiles ( dir , out = []) { 43for ( const e of readdirSync ( dir , { withFileTypes :true })) { 44const p = join ( dir , e . name ); 45if ( e . isSymbolicLink ()) continue ; 46if ( e . isDirectory ()) jsFiles ( p , out ); 47else if ( / \. ( m ? js | cjs ) $ / . test ( e . name )) out . push ( p ); 48} 49return out ; 50} 51 52/** 53* Every bare `@deepseek-ai/<package>` the staged Harness's own packages import (static `from "x"` and `import("x")`) must exist 54* in the staged node_modules. Returns the list of `{from, missing}` problems (empty = good). Plugins that are only loaded on 55* another platform still count: Node resolves a static import whether or not the code runs. 56*/ 57export function missingHarnessImports ( harnessDir ) { 58const scope = join ( harnessDir , 'node_modules' , '@deepseek-ai' ); 59if ( ! existsSync ( scope )) return [{ from :scope , missing :'@deepseek-ai (no installed packages)' }]; 60const problems = []; 61const seen = new Set (); 62const re = / (?: from | import ) \s * \( ? \s * [ "' ]( @deepseek-ai\/ [ ^ "'/ ] + )(?: \/ [ ^ "' ] * ) ? [ "' ] / g ; 63for ( const pkg of readdirSync ( scope )) { 64const lib = join ( scope , pkg , 'lib' ); 65if ( ! existsSync ( lib )) continue ; 66for ( const file of jsFiles ( lib )) { 67const text = readFileSync ( file , 'utf8' ); 68for ( const m of text . matchAll ( re )) { 69const name = m [ 1 ]; 70const key = ` ${ pkg } > ${ name } ` ; 71if ( seen . has ( key ) || KNOWN_ABSENT . has ( name )) continue ; 72seen . add ( key ); 73if ( ! existsSync ( join ( harnessDir , 'node_modules' , ...name . split ( '/' ))) 74&& ! existsSync ( join ( scope , pkg , 'node_modules' , ...name . split ( '/' )))) problems . push ({ from :` ${ pkg } ` , missing :name }); 75} 76} 77} 78return problems ; 79}