惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Jina AI
Jina AI
WordPress大学
WordPress大学
Recent Announcements
Recent Announcements
G
Google Developers Blog
I
InfoQ
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
Check Point Blog
J
Java Code Geeks
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
量子位
A
About on SuperTechFans
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
perf(plugins): cache normalized jiti aliases · openclaw/o...
steipete · 2026-04-23 · via Recent Commits to openclaw:main

@@ -481,12 +481,15 @@ export function resolveExtensionApiAlias(params: LoaderModuleResolveParams = {})

481481

}

482482483483

const MAX_PLUGIN_LOADER_ALIAS_CACHE_ENTRIES = 512;

484+

const JITI_NORMALIZED_ALIAS_SYMBOL = Symbol.for("pathe:normalizedAlias");

485+

const JITI_ALIAS_ROOT_SENTINELS = new Set<string | undefined>(["/", "\\", undefined]);

484486485487

// Memoize loader alias/config by effective resolution context so repeated

486488

// loader setup avoids rebuilding the same filesystem-derived map and cache key.

487489

// Include cwd/env inputs because the fallback root and private QA alias

488490

// surfaces depend on them.

489491

const aliasMapCache = new Map<string, Record<string, string>>();

492+

const normalizedJitiAliasMapCache = new Map<string, Record<string, string>>();

490493

const pluginLoaderJitiConfigCache = new Map<

491494

string,

492495

{

@@ -510,6 +513,54 @@ function setBoundedCacheValue<T>(cache: Map<string, T>, key: string, value: T) {

510513

}

511514

}

512515516+

function hasJitiNormalizedAliasMarker(aliasMap: Record<string, string>) {

517+

return Boolean((aliasMap as Record<symbol, unknown>)[JITI_NORMALIZED_ALIAS_SYMBOL]);

518+

}

519+520+

function createJitiAliasContentCacheKey(aliasMap: Record<string, string>) {

521+

return JSON.stringify(

522+

Object.entries(aliasMap).toSorted(([left], [right]) => left.localeCompare(right)),

523+

);

524+

}

525+526+

function normalizePluginLoaderAliasMapForJiti(

527+

aliasMap: Record<string, string>,

528+

): Record<string, string> {

529+

if (hasJitiNormalizedAliasMarker(aliasMap)) {

530+

return aliasMap;

531+

}

532+

const cacheKey = createJitiAliasContentCacheKey(aliasMap);

533+

const cached = normalizedJitiAliasMapCache.get(cacheKey);

534+

if (cached) {

535+

return cached;

536+

}

537+

const normalizedAliasMap = Object.fromEntries(

538+

Object.entries(aliasMap).toSorted(

539+

([left], [right]) => right.split("/").length - left.split("/").length,

540+

),

541+

);

542+

for (const aliasKey in normalizedAliasMap) {

543+

for (const candidateKey in normalizedAliasMap) {

544+

if (

545+

candidateKey === aliasKey ||

546+

aliasKey.startsWith(candidateKey) ||

547+

!normalizedAliasMap[aliasKey]?.startsWith(candidateKey) ||

548+

!JITI_ALIAS_ROOT_SENTINELS.has(normalizedAliasMap[aliasKey]?.[candidateKey.length])

549+

) {

550+

continue;

551+

}

552+

normalizedAliasMap[aliasKey] =

553+

normalizedAliasMap[candidateKey] + normalizedAliasMap[aliasKey].slice(candidateKey.length);

554+

}

555+

}

556+

Object.defineProperty(normalizedAliasMap, JITI_NORMALIZED_ALIAS_SYMBOL, {

557+

value: true,

558+

enumerable: false,

559+

});

560+

setBoundedCacheValue(normalizedJitiAliasMapCache, cacheKey, normalizedAliasMap);

561+

return normalizedAliasMap;

562+

}

563+513564

function buildPluginLoaderAliasMapCacheKey(params: {

514565

modulePath: string;

515566

argv1?: string;

@@ -626,15 +677,17 @@ export function resolvePluginRuntimeModulePath(

626677

}

627678628679

export function buildPluginLoaderJitiOptions(aliasMap: Record<string, string>) {

680+

const hasAliases = Object.keys(aliasMap).length > 0;

681+

const jitiAliasMap = hasAliases ? normalizePluginLoaderAliasMapForJiti(aliasMap) : aliasMap;

629682

return {

630683

interopDefault: true,

631684

// Prefer Node's native sync ESM loader for built dist/*.js modules so

632685

// bundled plugins and plugin-sdk subpaths stay on the canonical module graph.

633686

tryNative: true,

634687

extensions: [".ts", ".tsx", ".mts", ".cts", ".mtsx", ".ctsx", ".js", ".mjs", ".cjs", ".json"],

635-

...(Object.keys(aliasMap).length > 0

688+

...(hasAliases

636689

? {

637-

alias: aliasMap,

690+

alias: jitiAliasMap,

638691

}

639692

: {}),

640693

};