Building the web image showed that `next build` failed. - The console imported runtime values from the contracts entry point. - Turbopack cannot follow the NodeNext `.js` imports inside that entry, which also carries zod and every schema into the browser. - Only `next dev` had ever run before, and the console used to import types only. The fix: - The executor catalog moves to an entry without imports, exported as @wishforge/contracts/providers. The console takes its values from there. - providerBaseUrl moves to its own module. - A test keeps value imports of the entry point out of the console. With the console's default budget of 50,000 tokens, every Codex run stopped after one model request: - The proxy reserves one token per request byte, and a Codex request is already about 50 KB. - The executor then reported a bare 429 as a provider failure. The fix: - A request the remaining budget cannot cover now puts the run into the `budget` wait, with what it needs and what remains. - The console defaults to 300,000 tokens and explains the reservation. The run page also marked the stage a successful run ended in as not yet done; it now shows it as complete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.6 KiB
TypeScript
38 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { readdir, readFile } from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
|
|
// The console's bundler (Turbopack) cannot follow the NodeNext `.js` imports inside the contracts
|
|
// entry point, and that entry would carry zod and every schema into the browser. The console
|
|
// takes only types from it; values come from entries that import nothing.
|
|
async function sources(directory: string): Promise<string[]> {
|
|
const entries = await readdir(directory, { withFileTypes: true });
|
|
const nested = await Promise.all(
|
|
entries.map(entry => {
|
|
const location = path.join(directory, entry.name);
|
|
if (entry.isDirectory()) return sources(location);
|
|
return /\.tsx?$/.test(entry.name) ? [location] : [];
|
|
}),
|
|
);
|
|
return nested.flat();
|
|
}
|
|
|
|
describe('console bundle', () => {
|
|
it('imports only types from the contracts entry point', async () => {
|
|
const valueImports: string[] = [];
|
|
for (const file of await sources('apps/web/src')) {
|
|
const text = await readFile(file, 'utf8');
|
|
for (const match of text.matchAll(/^\s*(?:import|export)\s+(?!type\b)[^;]*?\bfrom\s+'@wishforge\/contracts'/gm))
|
|
valueImports.push(`${file}: ${match[0].trim()}`);
|
|
}
|
|
expect(valueImports).toEqual([]);
|
|
});
|
|
it('takes the provider catalog from an entry that imports nothing', async () => {
|
|
const manifest = JSON.parse(await readFile('packages/contracts/package.json', 'utf8'));
|
|
expect(manifest.exports['./providers']).toBe('./src/providers.ts');
|
|
expect(await readFile('packages/contracts/src/providers.ts', 'utf8')).not.toMatch(
|
|
/^\s*(?:import|export)\b.*\bfrom\s/m,
|
|
);
|
|
});
|
|
});
|