MCPcopy Create free account
hub / github.com/Noumena-Network/code / refreshPluginState

Function refreshPluginState

src/cli/print.ts:1791–1816  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1789 // settings were fetched. Without clearing, getCommands() would rebuild
1790 // from a stale plugin list.
1791 async function refreshPluginState(): Promise<void> {
1792 // refreshActivePlugins handles the full cache sweep (clearAllCaches),
1793 // reloads all plugin component loaders, writes AppState.plugins +
1794 // AppState.agentDefinitions, registers hooks, and bumps mcp.pluginReconnectKey.
1795 const { agentDefinitions: freshAgentDefs } =
1796 await refreshActivePlugins(setAppState)
1797
1798 // Headless-specific: currentCommands/currentAgents are local mutable refs
1799 // captured by the query loop (REPL uses AppState instead). getCommands is
1800 // fresh because refreshActivePlugins cleared its cache.
1801 currentCommands = await getCommands(cwd())
1802
1803 // Preserve SDK-provided agents (--agents CLI flag or SDK initialize
1804 // control_request) — both inject via parseAgentsFromJson with
1805 // source='flagSettings'. loadMarkdownFilesForSubdir never assigns this
1806 // source, so it cleanly discriminates "injected, not disk-loadable".
1807 //
1808 // The previous filter used a negative set-diff (!freshAgentTypes.has(a))
1809 // which also matched plugin agents that were in the poisoned initial
1810 // currentAgents but correctly excluded from freshAgentDefs after managed
1811 // settings applied — leaking policy-blocked agents into the init message.
1812 // See gh-23085: isBridgeEnabled() at Commander-definition time poisoned
1813 // the settings cache before setEligibility(true) ran.
1814 const sdkAgents = currentAgents.filter(a => a.source === 'flagSettings')
1815 currentAgents = [...freshAgentDefs.allAgents, ...sdkAgents]
1816 }
1817
1818 // Re-diff MCP configs after plugin state changes. Filters to
1819 // process-transport-supported types and carries SDK-mode servers through

Callers 1

runFunction · 0.85

Calls 3

refreshActivePluginsFunction · 0.85
getCommandsFunction · 0.85
cwdFunction · 0.85

Tested by

no test coverage detected