mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-11-07 14:38:23 -10:00
fix(omni): keep S5 off the root barrel, which was dragging 550 KB into ACP
`Check serve fast-path bundle closure` went red: the ACP agent's static import closure had acquired iconv-lite's encoding tables (~553 KB). The mechanism is worth writing down, because the obvious readings are all wrong. Nothing imported iconv-lite. What S5 did was add five re-exports to the ROOT barrel, which is statically imported by ~150 modules in the ACP closure. esbuild assigns modules to chunks by which entry points reach them, so every module added to the barrel's graph regroups the split — and that regrouping moved `sync-file-encoding` (and through it `iconvHelper`, whose top-level `import 'iconv-lite'` has side effects and cannot be shaken out) into a chunk the ACP chunk statically imports. So the fix is not "move the export somewhere else": my first two attempts relocated it to the `omni` barrel, which is itself statically imported by the root barrel and by tool-result-media, and stayed red. The barrel surface itself has to come back to baseline. None of the five needed to be there. Four had no consumer outside their own module and tests; the rest are reached by dynamic import, which does not care where the export lives: - ACP's model-call collection gets a dedicated `./omniPolicyCollection` subpath, the pattern `./goalWire` and `./transcriptRecords` already establish for "the CLI needs one deep function, not a barrel". - `reanchorRememberedMedia` moves to the `omni` door the `@`-reference funnel already loads for every other omni call it makes. - `createMediaMemoryRecallService`, `buildMediaMemoryRecallAdvisor`, `extractRequestResourceIds`, `runOmniMemorySideQuery`, `formatOmniMemorySideQueryReminder`, `OmniRecallMediaMemoryTool` and `formatResourceHandleText` simply leave the root barrel. Located by bisecting the 28 commits with the check itself, then diffing the ACP closure module sets between a green and a red metafile: the delta was exactly three modules, which is what named the mechanism.
This commit is contained in:
1 parent
78f46a81b4
commit
e60efd81fc
6 files changed
+24
-19
No files matched your search
@@ -8204,8 +8204,14 @@ export class Session implements SessionContext {
|
||||
toolResult.artifacts &&
|
||||
toolResult.artifacts.length > 0
|
||||
) {
|
||||
// Deep subpath, not the root or `omni` barrel: both are
|
||||
// statically imported across the CLI, so re-exporting this
|
||||
// through either drags the whole policy graph — and, via
|
||||
// iconvHelper's top-level iconv-lite import, its ~550 KB of
|
||||
// encoding tables — into the ACP agent's static closure
|
||||
// (scripts/check-serve-fast-path-bundle.js enforces that).
|
||||
const { collectModelPolicyCall } = await import(
|
||||
'@qwen-code/qwen-code-core'
|
||||
'@qwen-code/qwen-code-core/omniPolicyCollection'
|
||||
);
|
||||
await collectModelPolicyCall({
|
||||
config: this.config,
|
||||
|
||||
@@ -490,7 +490,7 @@ export async function resolveAtCommandQuery({
|
||||
let reanchored = false;
|
||||
if (config.isOmniEnabled?.()) {
|
||||
const { reanchorRememberedMedia } = await import(
|
||||
'@qwen-code/qwen-code-core'
|
||||
'@qwen-code/qwen-code-core/omni'
|
||||
);
|
||||
for (const dir of config.getWorkspaceContext().getDirectories()) {
|
||||
const anchor = await reanchorRememberedMedia(
|
||||
|
||||
@@ -19,6 +19,10 @@ export default defineConfig({
|
||||
__dirname,
|
||||
'../core/src/utils/transcript-records.ts',
|
||||
),
|
||||
'@qwen-code/qwen-code-core/omniPolicyCollection': path.resolve(
|
||||
__dirname,
|
||||
'../core/src/omni/policy/model-call-collection.ts',
|
||||
),
|
||||
'@qwen-code/qwen-code-core/omni': path.resolve(
|
||||
__dirname,
|
||||
'../core/src/omni/index.ts',
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
"types": "./dist/src/omni/index.d.ts",
|
||||
"import": "./dist/src/omni/index.js"
|
||||
},
|
||||
"./omniPolicyCollection": {
|
||||
"types": "./dist/src/omni/policy/model-call-collection.d.ts",
|
||||
"import": "./dist/src/omni/policy/model-call-collection.js"
|
||||
},
|
||||
"./transcriptRecords": {
|
||||
"types": "./dist/src/utils/transcript-records.d.ts",
|
||||
"import": "./dist/src/utils/transcript-records.js"
|
||||
|
||||
@@ -677,7 +677,6 @@ export {
|
||||
recognizeMediaFile,
|
||||
formatDisclosureText,
|
||||
formatOmissionText,
|
||||
formatResourceHandleText,
|
||||
buildAdditionalMediaParts,
|
||||
buildTranscriptParts,
|
||||
OmniObjectStore,
|
||||
@@ -692,22 +691,6 @@ export {
|
||||
type DownloadedMedia,
|
||||
} from './omni/index.js';
|
||||
export { processToolResultOmniMedia } from './omni/tool-result-media.js';
|
||||
export {
|
||||
buildMediaMemoryRecallAdvisor,
|
||||
createMediaMemoryRecallService,
|
||||
reanchorRememberedMedia,
|
||||
} from './omni/memory-recall.js';
|
||||
export {
|
||||
runOmniMemorySideQuery,
|
||||
formatOmniMemorySideQueryReminder,
|
||||
extractRequestResourceIds,
|
||||
type OmniMemorySideQueryOutcome,
|
||||
} from './omni/memory-side-query.js';
|
||||
export { collectModelPolicyCall } from './omni/policy/model-call-collection.js';
|
||||
export {
|
||||
OmniRecallMediaMemoryTool,
|
||||
type OmniRecallMediaMemoryParams,
|
||||
} from './omni/recall-media-memory-tool.js';
|
||||
export {
|
||||
resolveMediaPolicyModelAccess,
|
||||
isMediaPolicyToolHiddenFromModel,
|
||||
|
||||
@@ -1153,3 +1153,11 @@ export function effectiveMaxDownloadFileBytes(config: Config): number {
|
||||
}
|
||||
return uploadCap;
|
||||
}
|
||||
|
||||
// Re-anchoring is reached from the CLI's `@`-reference funnel, which already
|
||||
// loads this module dynamically for every other omni call it makes. Kept off
|
||||
// the ROOT barrel deliberately: that barrel is statically imported across the
|
||||
// CLI, and every module added to its graph regroups esbuild's chunks — which
|
||||
// is how the ACP agent's static closure acquired iconv-lite's 550 KB of
|
||||
// encoding tables (scripts/check-serve-fast-path-bundle.js caught it).
|
||||
export { reanchorRememberedMedia } from './memory-recall.js';
|
||||
Reference in new issue
Block a user