11import { spawnSync } from "node:child_process" ;
22import { mkdirSync , mkdtempSync , rmSync } from "node:fs" ;
3- import { readFile } from "node:fs/promises" ;
43import { tmpdir } from "node:os" ;
54import { join } from "node:path" ;
6- import { brotliDecompressSync } from "node:zlib" ;
75import { expect , test } from "bun:test" ;
8- import { PLUGIN_ROOT } from "./plugin-root.js" ;
9-
10- const bundledRuntime = Promise . all (
11- [ "000" , "001" ] . map ( ( part ) =>
12- readFile ( join ( PLUGIN_ROOT , "mcp" , `server.mjs.br.part-${ part } ` ) ) ,
13- ) ,
14- ) . then ( ( parts ) => brotliDecompressSync ( Buffer . concat ( parts ) ) . toString ( "utf8" ) ) ;
6+ import { loadBundledRuntime , PLUGIN_ROOT } from "./plugin-root.js" ;
157
168function bundledFunction ( runtime : string , name : string ) : string {
179 const source = new RegExp (
@@ -23,7 +15,7 @@ function bundledFunction(runtime: string, name: string): string {
2315}
2416
2517test ( "keeps every advertised Deep worker tool within Codex's name limit" , async ( ) => {
26- const runtime = await bundledRuntime ;
18+ const runtime = await loadBundledRuntime ( ) ;
2719 const method = / c o m p a c t A r t i f a c t S e r v e r \( r e q u e s t \) \{ [ \s \S ] * ?\n \} / u. exec (
2820 runtime ,
2921 ) ?. [ 0 ] ;
@@ -112,7 +104,7 @@ test("keeps every advertised Deep worker tool within Codex's name limit", async
112104} ) ;
113105
114106test ( "classifies owned worker tool failures without exposing their contents" , async ( ) => {
115- const runtime = await bundledRuntime ;
107+ const runtime = await loadBundledRuntime ( ) ;
116108 const diagnosticSource = bundledFunction ( runtime , "appendSafeItemDiagnostic" ) ;
117109 const recordHelper = / \b ( i s R e c o r d \d * ) \( i t e m \) / u. exec ( diagnosticSource ) ?. [ 1 ] ;
118110 expect ( recordHelper ) . toBeDefined ( ) ;
@@ -182,7 +174,7 @@ test("classifies owned worker tool failures without exposing their contents", as
182174} ) ;
183175
184176test ( "resumes only when the exact reducer result is missing" , async ( ) => {
185- const runtime = await bundledRuntime ;
177+ const runtime = await loadBundledRuntime ( ) ;
186178 const source = bundledFunction ( runtime , "isMissingReducerResult" ) ;
187179 const pathImport = / \( 0 , ( i m p o r t _ n o d e _ p a t h \d + ) \. j o i n \) / u. exec ( source ) ?. [ 1 ] ;
188180 expect ( pathImport ) . toBeDefined ( ) ;
0 commit comments