{"record":{"id":"e6159f148c8bb397","repo":"can1357/oh-my-pi","slug":"trusted-extension-failed-to-load-trustedextensi","errorCode":null,"errorMessage":"Trusted extension failed to load: ${trustedExtensions.errors.map(item => item.error).join(\"; \")}","messagePattern":"Trusted extension failed to load: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/main.ts","lineNumber":432,"sourceCode":"export function createAcpSessionFactory(args: AcpSessionFactoryOptions): AcpSessionFactory {\n\treturn async (cwd, factoryOptions) => {\n\t\tconst nextSettings = await args.settings.cloneForCwd(cwd);\n\t\tconst nextSessionManager = SessionManager.create(cwd, args.sessionDir);\n\t\tconst agentId = `acp:${nextSessionManager.getSessionId()}`;\n\t\t// `baseOptions.titleSystemPrompt` is resolved from the launch cwd; an ACP\n\t\t// host can open `session/new` for any client-supplied workspace, so\n\t\t// re-discover `TITLE_SYSTEM.md` against THIS session's `cwd` to keep the\n\t\t// replan-driven title refresh consistent with the target project's\n\t\t// policy (PR #3736 follow-up).\n\t\tconst titleSystemPromptSource = discoverTitleSystemPromptFile(cwd);\n\t\tconst titleSystemPrompt = await resolvePromptInput(titleSystemPromptSource, \"title system prompt\");\n\t\tconst eventBus = new EventBus();\n\t\tconst trustedExtensions =\n\t\t\targs.parsedArgs.trustedExtensions && args.parsedArgs.trustedExtensions.length > 0\n\t\t\t\t? await loadTrustedSessionExtensions(args.baseOptions, cwd, eventBus)\n\t\t\t\t: undefined;\n\t\tif (trustedExtensions && trustedExtensions.errors.length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Trusted extension failed to load: ${trustedExtensions.errors.map(item => item.error).join(\"; \")}`,\n\t\t\t);\n\t\t}\n\t\tconst { session: nextSession, setToolUIContext } = await args.createSession({\n\t\t\t...args.baseOptions,\n\t\t\tcwd,\n\t\t\tsessionManager: nextSessionManager,\n\t\t\tsettings: nextSettings,\n\t\t\tauthStorage: args.authStorage,\n\t\t\tmodelRegistry: args.modelRegistry,\n\t\t\tagentId,\n\t\t\t// ACP defers the `ask` capability and reserve-policy confirmation until\n\t\t\t// client capabilities are known, without enabling other UI-only behavior.\n\t\t\tinteractivePrompts: factoryOptions?.interactivePrompts,\n\t\t\tdeferUsageReserveConfirmation: true,\n\t\t\tenableMCP: false,\n\t\t\ttitleSystemPrompt,\n\t\t\teventBus,","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/main.ts#L414-L450","documentation":"In the ACP session factory, after trusted extensions are loaded, any per-extension load error collected by loadTrustedSessionExtensions is aggregated and thrown as a single fatal error, joining all individual error messages with '; '. The ACP path treats trusted extensions as required, so partial load failure aborts session creation.","triggerScenarios":"createAcpSessionFactory invoked with args.parsedArgs.trustedExtensions non-empty, and loadTrustedSessionExtensions returns { errors: [...] } (syntax error in an extension module, missing dependency, top-level throw, import of a nonexistent file).","commonSituations":"Extension module has a TypeScript/import error or references an uninstalled dependency; extension file was moved/renamed after being configured; extension throws during initialization; Node/Bun version incompatibility in extension code.","solutions":["Read the joined messages to find each failing extension and its root cause.","Fix or remove the failing extension path from --trusted-extension arguments.","Run the extension module directly (bun run path/to/ext.ts) to reproduce its load error in isolation.","Reinstall missing dependencies the extension imports."],"exampleFix":"// before\nomp --trusted-extension ./broken-ext.ts\n// error: Trusted extension failed to load: Cannot find module 'missing-dep'\n// after\nbun add missing-dep   # or fix/remove the extension path\nomp --trusted-extension ./broken-ext.ts","handlingStrategy":"try-catch","validationCode":"for (const p of trustedExtensionPaths) {\n  try { await import(p); } catch (e) { console.error(`Extension ${p} fails to load: ${e.message}`); }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await startAcpSession(args);\n} catch (err) {\n  if (err.message.startsWith(\"Trusted extension failed to load:\")) {\n    for (const msg of err.message.slice(\"Trusted extension failed to load: \".length).split(\"; \")) console.error(msg);\n  }\n  throw err;\n}","preventionTips":["Pre-flight import each trusted extension in isolation before wiring it into omp.","Keep extension dependencies installed in the extension's own node_modules.","Remove stale extension paths from launch scripts after renaming files."],"tags":["cli","extensions","acp","module-load"],"backgroundTag":"extension-load-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}