From 81e7b6587891a5b46c6640cf11650160ac224ff3 Mon Sep 17 00:00:00 2001 From: bft-codebot Date: Thu, 26 Feb 2026 17:31:08 +0000 Subject: [PATCH] sync(bfmono): fix(gambit-core): support non-file import.meta.url at runtime init (+19 more) (bfmono@175e49006) This PR is an automated gambitmono sync of bfmono Gambit packages. - Source: `packages/gambit/` - Core: `packages/gambit/packages/gambit-core/` - bfmono rev: 175e49006 Changes: - 175e49006 fix(gambit-core): support non-file import.meta.url at runtime init - 3c44ef51a fix(gambit): include core snippets/decks/workers in compile assets - 591734506 fix(gambit): exclude .codex from Build file listing - 4fe56b200 chore(gambit): cut 0.8.5-rc.12 - 2bfffaaae fix(gambit): add codex trust preflight for workbench chat - 9c16505d6 chore(gambit): cut 0.8.5-rc.11 - b4d5cdaef fix(simulator-ui): prevent feedback reason text from being clobbered - 84952a652 fix(gambit-verify): align verify turn labels and stabilize initial run filtering - c56b7f52f feat(gambit): improve verify report controls and harden concurrent calibrate persistence - beb9435c0 feat(gambit-simulator-ui): extend listbox trigger and popover options - 25f9fdcfc fix(gambit-simulator-ui): align verify outlier chip semantics and display - a010b0ee1 feat(gambit-simulator-ui): add verify outliers to workbench chat chips - 383f2500a refactor(simulator-ui): replace nested ternaries in main routing - 13c4c8c22 fix(gambit): preserve shared references in safe session serialization - ae392aa24 feat(gambit-simulator-ui): add grader error chips to workbench chat - 1de6b335c fix(gambit): clamp deck-level maxTurns bounds in test run selection - 01d7abbb9 fix(gambit): default verify tab bootstrap flag to enabled - f3d186c7b fix(gambit): include extension schemas in exports and default serve to restored workspace - a83b7cbe7 fix(gambit): move unbounded build timeout to deck opt-in - acb2de627 fix(gambit): avoid strict json_schema 400s in openrouter responses Do not edit this repo directly; make changes in bfmono and re-run the sync. --- packages/gambit-core/src/runtime.ts | 38 ++++++++++++++++++++--------- scripts/compile.ts | 12 +++++++++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/packages/gambit-core/src/runtime.ts b/packages/gambit-core/src/runtime.ts index 0785a82a..b0fb8f22 100644 --- a/packages/gambit-core/src/runtime.ts +++ b/packages/gambit-core/src/runtime.ts @@ -3022,21 +3022,30 @@ function collectLocalImportGraph(entryPath: string): Set { return visited; } -const WORKER_ENTRY_PATHS = [ - "./runtime_worker.ts", - "./runtime_orchestration_worker.ts", -].map((relative) => path.fromFileUrl(new URL(relative, import.meta.url))); -const BUILTIN_SCHEMAS_DIR = path.resolve( - path.dirname(path.fromFileUrl(import.meta.url)), - "../schemas", -); -const BUILTIN_SNIPPETS_DIR = path.resolve( - path.dirname(path.fromFileUrl(import.meta.url)), - "../snippets", -); +const moduleBaseFilePath = (() => { + try { + return path.fromFileUrl(import.meta.url); + } catch { + return undefined; + } +})(); + +const WORKER_ENTRY_PATHS = moduleBaseFilePath + ? [ + "./runtime_worker.ts", + "./runtime_orchestration_worker.ts", + ].map((relative) => path.fromFileUrl(new URL(relative, import.meta.url))) + : []; +const BUILTIN_SCHEMAS_DIR = moduleBaseFilePath + ? path.resolve(path.dirname(moduleBaseFilePath), "../schemas") + : undefined; +const BUILTIN_SNIPPETS_DIR = moduleBaseFilePath + ? path.resolve(path.dirname(moduleBaseFilePath), "../snippets") + : undefined; let builtinSchemaBootstrapCache: Array | undefined; function builtinSchemaBootstrapReads(): Array { + if (!BUILTIN_SCHEMAS_DIR) return []; if (builtinSchemaBootstrapCache) return builtinSchemaBootstrapCache; const schemaModules: Array = []; const stack: Array = [BUILTIN_SCHEMAS_DIR]; @@ -3072,6 +3081,7 @@ function builtinSchemaBootstrapReads(): Array { let builtinSnippetBootstrapCache: Array | undefined; function builtinSnippetBootstrapReads(): Array { + if (!BUILTIN_SNIPPETS_DIR) return []; if (builtinSnippetBootstrapCache) return builtinSnippetBootstrapCache; const snippetFiles: Array = []; const stack: Array = [BUILTIN_SNIPPETS_DIR]; @@ -3115,6 +3125,10 @@ function workerBootstrapReadAllowlist(deckPath: string): Array { let trustedWorkerBootstrapCache: Array | undefined; function trustedWorkerBootstrapReads(): Array { if (trustedWorkerBootstrapCache) return trustedWorkerBootstrapCache; + if (!moduleBaseFilePath) { + trustedWorkerBootstrapCache = []; + return trustedWorkerBootstrapCache; + } const definitionsPath = path.fromFileUrl( new URL("./definitions.ts", import.meta.url), ); diff --git a/scripts/compile.ts b/scripts/compile.ts index 15e6ea6e..c7a9a8d7 100644 --- a/scripts/compile.ts +++ b/scripts/compile.ts @@ -32,7 +32,15 @@ const resolveCoreDir = async (): Promise => { const coreDir = await resolveCoreDir(); const coreRel = normalizePath(path.relative(packageRoot, coreDir)); const coreCards = normalizePath(path.join(coreRel, "cards")); +const coreSnippets = normalizePath(path.join(coreRel, "snippets")); const coreSchemas = normalizePath(path.join(coreRel, "schemas")); +const coreDecks = normalizePath(path.join(coreRel, "decks")); +const coreRuntimeWorker = normalizePath( + path.join(coreRel, "src", "runtime_worker.ts"), +); +const coreRuntimeOrchestrationWorker = normalizePath( + path.join(coreRel, "src", "runtime_orchestration_worker.ts"), +); const docIncludeCandidates = [ "docs/cli/commands", @@ -54,7 +62,11 @@ const includePaths = [ "deno.jsonc", ...docIncludes, coreCards, + coreSnippets, coreSchemas, + coreDecks, + coreRuntimeWorker, + coreRuntimeOrchestrationWorker, "src/decks", "scaffolds", "simulator-ui/dist",