{"version":3,"file":"pi.cjs","names":["PACKAGE_SOURCE","LEADER_BINDING_PREFIX","LEADER_GROUP","LEADER_DETAIL","path","McpSession","DOOM_UI_HUB_SERVICE","requireDoomUiHub","DOOM_TOOL_SURFACE_SERVICE","requireDoomToolSurface","DOOM_CORDIS_SESSION_SERVICE","MCP_STATUS_KEY","MCP_SESSION_AUTH_STATUS_KEY","formatMcpSessionAuthStatus","readSessionConfig","DOOM_MCP_PROJECTION_SERVICE","readDoomMcpProjectionService","mcpSessionConfigFromProjection","createMcpSessionToolsService","createMcpChildTool","DOOM_MCP_STATUS_SERVICE","DOOM_MCP_TOOL_RESOLVER_SERVICE","MCP_SESSION_TOOLS_SERVICE","DOOM_CHILD_SESSION_MCP_TOOL_SERVICE","defineRoot","defineRoutedContribution","createMcpCommand","defineResource","createMcpTool","wrapTextWithAnsi","truncateToWidth","renderToolHeading","DoomToolCall","defineRoutedContribution","definePiExtension","rootSession","composeRootHooks","commandMcp","resourceDoompiUseMcp","piToolContributions","toolMcp"],"sources":["../../src/services/leader/index.ts","../../src/services/piRuntime/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/piRoot.ts","../../src/extensions/workspaces/sessions/(backend)/root.cli.ts","../../src/extensions/workspaces/sessions/(backend)/command/mcp.cli.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-mcp.cli.ts","../../src/services/mcpToolCollection/index.ts","../../src/tui/mcpToolRender.ts","../../src/extensions/workspaces/sessions/(backend)/tool/mcp.cli.ts","../../generated/pi.ts"],"sourcesContent":["import type { DoomUiHubService } from '@agimon-ai/doompi-core/uiHub';\n\nimport { COMMAND_NAME } from '../../constants/mcp';\nimport {\n  LEADER_BINDING_PREFIX,\n  LEADER_DETAIL,\n  LEADER_GROUP,\n  LEADER_KEY,\n  LEADER_LABEL,\n  PACKAGE_SOURCE,\n} from '../../constants/piMcp';\n\nexport function registerLeaderContribution(hub: DoomUiHubService): () => void {\n  const contribution = hub.registerLeader({\n    source: PACKAGE_SOURCE,\n    bindings: [\n      {\n        id: `${LEADER_BINDING_PREFIX}.open`,\n        path: [LEADER_GROUP, { key: LEADER_KEY, label: LEADER_LABEL, detail: LEADER_DETAIL }],\n        command: { name: COMMAND_NAME },\n      },\n    ],\n  });\n  return () => contribution.dispose();\n}\n","import path from 'node:path';\n\nimport { DOOM_CHILD_SESSION_MCP_TOOL_SERVICE } from '@agimon-ai/doompi-core/childSession';\nimport type { DoomCordisRuntimeService } from '@agimon-ai/doompi-core/cordisHost';\nimport { DOOM_CORDIS_SESSION_SERVICE, type DoomCordisSessionService } from '@agimon-ai/doompi-core/cordisHost';\nimport { DOOM_MCP_PROJECTION_SERVICE, readDoomMcpProjectionService } from '@agimon-ai/doompi-core/mcpProjection';\nimport { DOOM_MCP_STATUS_SERVICE, type DoomMcpStatusService } from '@agimon-ai/doompi-core/mcpStatus';\nimport {\n  DOOM_MCP_TOOL_RESOLVER_SERVICE,\n  type DoomMcpToolResolverService,\n} from '@agimon-ai/doompi-core/mcpToolResolver';\nimport { DOOM_TOOL_SURFACE_SERVICE, requireDoomToolSurface } from '@agimon-ai/doompi-core/toolSurface';\nimport { DOOM_UI_HUB_SERVICE, requireDoomUiHub } from '@agimon-ai/doompi-core/uiHub';\nimport type { Context } from '@deepseek-ai/cordis';\nimport type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nimport { MCP_STATUS_KEY } from '../../constants/piMcp';\nimport { McpSession } from '../../services/mcpSession';\nimport { mcpSessionConfigFromProjection } from '../../services/projection';\nimport { readSessionConfig } from '../../services/sessionConfig';\nimport type { McpSessionConfig } from '../../types/mcpConfig';\nimport { formatMcpSessionAuthStatus, MCP_SESSION_AUTH_STATUS_KEY } from '../../types/webMcp';\nimport { registerLeaderContribution } from '../leader';\nimport { createMcpChildTool, createMcpSessionToolsService, MCP_SESSION_TOOLS_SERVICE } from '../mcpSessionTools';\n\nconst INFO = 'info';\nconst WARNING = 'warning';\n\nfunction failClosedSessionConfig(cwd: string): McpSessionConfig {\n  return {\n    enabled: false,\n    repoRoot: cwd,\n    stagingDirectory: path.join(cwd, '.doom', 'mcp-disabled'),\n    sources: [],\n  };\n}\n\nexport function createMcpPiRuntime(runtime: DoomCordisRuntimeService) {\n  const mode = runtime.mode;\n  let activeContext: ExtensionContext | undefined;\n  let disposed = false;\n  const session = new McpSession({\n    onAuthorizationUrl: async (url, serverName, { openBrowser }) => {\n      const context = activeContext;\n      if (context?.mode === 'tui') {\n        if (!openBrowser) return;\n        try {\n          const { default: open } = await import('open');\n          await open(url.toString());\n        } catch (error) {\n          context.ui.notify(\n            `Could not open the authorization page for ${serverName}: ${error instanceof Error ? error.message : String(error)}. Press a in the MCP overlay to retry.`,\n            WARNING,\n          );\n          throw error;\n        }\n        return;\n      }\n      context?.ui?.notify(`Authorize ${serverName} by opening:\\n${url.toString()}`, INFO);\n    },\n  });\n\n  return {\n    session,\n    services: [\n      (cordis: Context) => {\n        cordis.inject([DOOM_UI_HUB_SERVICE], (uiContext) => registerLeaderContribution(requireDoomUiHub(uiContext)));\n        // The surface lives on the session fiber, so this resolves after install has\n        // already registered the cached wrappers: binding is what first hides the ones\n        // no server has confirmed.\n        cordis.inject([DOOM_TOOL_SURFACE_SERVICE], (surfaceContext) =>\n          session.bindToolSurface(requireDoomToolSurface(surfaceContext)),\n        );\n        cordis.inject([DOOM_CORDIS_SESSION_SERVICE], async (sessionContext) => {\n          const hostSession = sessionContext.get(DOOM_CORDIS_SESSION_SERVICE) as DoomCordisSessionService;\n          const context = hostSession.context;\n          const expectedSessionId = hostSession.sessionId;\n          let sessionActive = true;\n          activeContext = context;\n          // The legacy server-name status remains available to every UI. The compact\n          // authorization status is browser-only so the TUI footer stays unchanged.\n          const publishServerStatus = (): void => {\n            const servers = session.getSnapshot().servers;\n            const names = servers.map((server) => server.name).join(',');\n            context.ui?.setStatus(MCP_STATUS_KEY, names);\n            if (context.mode !== 'tui') {\n              context.ui?.setStatus(MCP_SESSION_AUTH_STATUS_KEY, formatMcpSessionAuthStatus(session.getServers()));\n            }\n          };\n          const stopPublishing = session.onChange(publishServerStatus);\n          publishServerStatus();\n\n          if (mode === 'standalone') {\n            await session.reconfigure(readSessionConfig(process.env, context.cwd), context.cwd);\n          } else {\n            await session.reconfigure(failClosedSessionConfig(context.cwd));\n            sessionContext.inject([DOOM_MCP_PROJECTION_SERVICE], async (projectionContext) => {\n              const projection = readDoomMcpProjectionService(projectionContext);\n              if (!projection || projection.sessionId !== expectedSessionId) {\n                await session.reconfigure(failClosedSessionConfig(context.cwd));\n                if (projection && sessionActive && !disposed) {\n                  context.ui?.notify(\n                    `The Doom MCP projection belongs to session \"${projection.sessionId}\", not \"${expectedSessionId}\"; MCP is disabled.`,\n                    WARNING,\n                  );\n                }\n              } else {\n                const snapshot = projection.getSnapshot();\n                await session.reconfigure(\n                  mcpSessionConfigFromProjection(snapshot, context.cwd),\n                  context.cwd,\n                  snapshot.repoRoot,\n                );\n              }\n              return async () => {\n                if (sessionActive && !disposed) await session.reconfigure(failClosedSessionConfig(context.cwd));\n              };\n            });\n          }\n\n          const status: DoomMcpStatusService = Object.freeze({\n            generation: `${hostSession.generation}:mcp-status`,\n            getSnapshot: () => session.getSnapshot(),\n            onChange: (listener: () => void) => session.onChange(listener),\n          });\n          const toolResolver: DoomMcpToolResolverService = Object.freeze({\n            generation: `${hostSession.generation}:mcp-tool-resolver`,\n            resolve: (selectors: readonly string[]) => session.resolveToolSelectors(selectors),\n          });\n          const sessionTools = createMcpSessionToolsService(session, `${hostSession.generation}:mcp-tools`);\n          const childTool = createMcpChildTool(async (parameters, signal) => {\n            if (!sessionActive || disposed) throw new Error('The parent MCP session is no longer available.');\n            const tool = sessionTools\n              .snapshot()\n              .find(\n                (candidate) => candidate.serverName === parameters.server && candidate.toolName === parameters.tool,\n              );\n            if (!tool)\n              throw new Error(\n                `MCP tool ${parameters.server}/${parameters.tool} is not available in the current session configuration.`,\n              );\n            return sessionTools.invoke(tool.piName, parameters.arguments ?? {}, signal);\n          });\n          sessionContext.plugin((providerContext) => {\n            providerContext.provide(DOOM_MCP_STATUS_SERVICE, status);\n            providerContext.provide(DOOM_MCP_TOOL_RESOLVER_SERVICE, toolResolver);\n            providerContext.provide(MCP_SESSION_TOOLS_SERVICE, sessionTools);\n            providerContext.provide(DOOM_CHILD_SESSION_MCP_TOOL_SERVICE, childTool);\n          });\n          for (const diagnostic of session.getDiagnostics()) context.ui?.notify(diagnostic, WARNING);\n          return async () => {\n            sessionActive = false;\n            stopPublishing();\n            context.ui?.setStatus(MCP_STATUS_KEY, undefined);\n            if (context.mode !== 'tui') context.ui?.setStatus(MCP_SESSION_AUTH_STATUS_KEY, undefined);\n            if (activeContext === context) activeContext = undefined;\n            if (!disposed) await session.reconfigure(failClosedSessionConfig(context.cwd));\n          };\n        });\n      },\n    ],\n    async onDispose() {\n      disposed = true;\n      activeContext = undefined;\n      await session.dispose();\n    },\n  };\n}\n","import type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport { createMcpPiRuntime } from '../../../../../services/piRuntime';\nexport const createMcpPiRoot = ({ runtime }: PiPluginContext) => {\n  if (!runtime) throw new Error('MCP requires the Cordis runtime mode.');\n  const state = createMcpPiRuntime(runtime);\n  return { value: state, services: state.services, onDispose: () => state.onDispose() };\n};\nexport type McpPiScope = Awaited<ReturnType<typeof createMcpPiRoot>>['value'];\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport { createMcpPiRoot } from './_lib/piRoot';\n\nexport default defineRoot(createMcpPiRoot);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext } from '@agimon-ai/doompi-core/piExtension';\n\nimport { createMcpCommand } from '../../../../../services/mcpCommand';\nimport type { McpPiScope } from '../_lib/piRoot';\nexport default defineRoutedContribution(\n  (context: WithRoot<PiPluginContext<unknown>, McpPiScope>) =>\n    [\n      createMcpCommand(context.root.session, {\n        openOverlay: async (ctx) => {\n          const { openMcpOverlay } = await import('../../../../../tui/mcpOverlay');\n          return openMcpOverlay(ctx, context.root.session);\n        },\n      }),\n    ] as const,\n  { cardinality: 'many' },\n);\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nexport default defineResource({\n  source: '@agimon-ai/doompi-mcp',\n  moduleUrl: import.meta.url,\n  skills: [\n    {\n      name: 'doompi-use-mcp',\n      description:\n        'Use Doom Pi MCP to inspect domain-scoped servers, authenticate, reload configuration, and troubleshoot tool availability.',\n    },\n  ],\n});\n","import type { PiToolCollection, PiToolDeclaration } from '@agimon-ai/doompi-core/piExtension';\n\nimport type { CatalogTool } from '../../services/mcpCatalog';\nimport type { McpSession } from '../../services/mcpSession';\nimport { createMcpTool, type McpToolRenderers } from '../mcpTools';\nexport function createMcpToolCollection(\n  session: McpSession,\n  renderers: (tool: CatalogTool) => McpToolRenderers = () => ({}),\n): PiToolCollection {\n  const declarations = new Map<CatalogTool, PiToolDeclaration>();\n  return {\n    snapshot: (): readonly PiToolDeclaration[] =>\n      session.toolDefinitions().map((tool) => {\n        let declaration = declarations.get(tool);\n        if (!declaration) {\n          declaration = createMcpTool(\n            session.getClientManager,\n            tool,\n            (candidate) => session.isToolAvailable(candidate),\n            renderers(tool),\n          );\n          declarations.set(tool, declaration);\n        }\n        return declaration;\n      }),\n    subscribe: (listener: () => void) => session.onChange(listener),\n  };\n}\n","import { DoomToolCall, renderToolHeading } from '@agimon-ai/doompi-ui/toolChrome';\nimport type { Theme } from '@earendil-works/pi-coding-agent';\nimport { type Component, truncateToWidth, wrapTextWithAnsi } from '@earendil-works/pi-tui';\n\nconst COLLAPSED_RESULT_LINES = 12;\nconst MAX_ARGUMENTS = 3;\nconst ELLIPSIS = '…';\n\ninterface McpToolTextLayout {\n  wrap: boolean;\n  separator: boolean;\n  trailingBlank: boolean;\n}\n\n/** Bash-compatible width budget, horizontal inset, and structural result divider. */\nclass McpToolText implements Component {\n  constructor(\n    private readonly lines: readonly string[],\n    private readonly layout: McpToolTextLayout,\n    private readonly theme: Theme,\n  ) {}\n\n  render(width: number): string[] {\n    if (width <= 0) return [];\n    const contentWidth = Math.max(1, width - 2);\n    const rendered = this.layout.wrap\n      ? this.lines.flatMap((line) => wrapTextWithAnsi(line, contentWidth))\n      : this.lines.map((line) => truncateToWidth(line, contentWidth, ELLIPSIS));\n    if (this.layout.separator) {\n      rendered.unshift(this.theme.fg('borderMuted', '─'.repeat(contentWidth)));\n    }\n    const padded = rendered.map((line) => ` ${line}`);\n    if (this.layout.trailingBlank) padded.push('');\n    return padded;\n  }\n\n  invalidate(): void {\n    // Content is immutable and reflows from the current width on every render.\n  }\n}\n\nfunction argumentValue(value: unknown): string {\n  if (typeof value === 'string') return value;\n  if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n  if (value === null) return 'null';\n  if (Array.isArray(value)) return `[${value.length}]`;\n  return '{…}';\n}\n\nfunction argumentSummary(params: Record<string, unknown>): string {\n  const entries = Object.entries(params);\n  const shown = entries.slice(0, MAX_ARGUMENTS).map(([key, value]) => `${key}=${argumentValue(value)}`);\n  if (entries.length > shown.length) shown.push(`+${entries.length - shown.length}`);\n  return shown.join(' · ');\n}\n\nexport interface McpToolIdentity {\n  serverName: string;\n  toolName: string;\n}\n\nexport function renderMcpCall(tool: McpToolIdentity, params: Record<string, unknown>, theme: Theme): Component {\n  const heading = renderToolHeading('mcp', tool.serverName, theme, 'muted');\n  const toolName = theme.fg('accent', tool.toolName);\n  const argumentsText = argumentSummary(params);\n  const text = `${heading}${theme.fg('muted', ' / ')}${toolName}${\n    argumentsText ? ` ${theme.fg('muted', `· ${argumentsText}`)}` : ''\n  }`;\n  return new DoomToolCall(text);\n}\n\nexport interface McpToolResultLike {\n  content?: Array<{ type: string; text?: string }>;\n}\n\nexport interface McpToolResultOptions {\n  expanded: boolean;\n  isPartial: boolean;\n  isError: boolean;\n}\n\nfunction resultLines(result: McpToolResultLike): string[] {\n  const text = (result.content ?? []).map((block) => block.text ?? '').join('');\n  const lines = text.split('\\n');\n  while (lines.length > 0 && lines.at(-1)?.trim() === '') lines.pop();\n  return lines;\n}\n\nexport function renderMcpResult(result: McpToolResultLike, options: McpToolResultOptions, theme: Theme): Component {\n  const all = resultLines(result);\n  const shown = options.expanded ? all : all.slice(0, COLLAPSED_RESULT_LINES);\n  const body = shown.map((line) => theme.fg('toolOutput', line));\n\n  if (options.isPartial) {\n    body.push(theme.fg('warning', '◐') + theme.fg('dim', ' running'));\n  } else if (options.isError) {\n    body.push(theme.fg('error', '✗') + theme.fg('dim', ' failed'));\n  } else if (!options.expanded && all.length > shown.length) {\n    body.push(theme.fg('dim', '… ctrl+o'));\n  } else if (body.length === 0) {\n    body.push(theme.fg('success', '✓') + theme.fg('dim', ' done'));\n  }\n\n  return new McpToolText(body, { wrap: options.expanded, separator: true, trailingBlank: true }, theme);\n}\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { PiPluginContext, PiToolCollection } from '@agimon-ai/doompi-core/piExtension';\n\nimport { createMcpToolCollection } from '../../../../../services/mcpToolCollection';\nimport { renderMcpCall, renderMcpResult } from '../../../../../tui/mcpToolRender';\nimport type { McpPiScope } from '../_lib/piRoot';\n\nexport default defineRoutedContribution(\n  (context: WithRoot<PiPluginContext<unknown>, McpPiScope>): PiToolCollection =>\n    createMcpToolCollection(context.root.session, (tool) => ({\n      renderCall: (params, theme) => renderMcpCall(tool, params as Record<string, unknown>, theme),\n      renderResult: (result, options, theme, execution) =>\n        renderMcpResult(result, { ...options, isError: execution.isError }, theme),\n    })),\n  { cardinality: 'collection' },\n);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { definePiExtension, piToolContributions, type PiPluginContext, type PiPluginContributions } from '@agimon-ai/doompi-core/piExtension';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.cli';\nimport commandMcp from '../src/extensions/workspaces/sessions/(backend)/command/mcp.cli';\nimport resourceDoompiUseMcp from '../src/extensions/workspaces/sessions/(backend)/resource/doompi-use-mcp.cli';\nimport toolMcp from '../src/extensions/workspaces/sessions/(backend)/tool/mcp.cli';\n\ntype OptionsOf<T> = T extends (context: PiPluginContext<infer Options>) => unknown ? Options : never;\ntype InferredOptions = Exclude<OptionsOf<typeof rootSession> | OptionsOf<typeof commandMcp> | OptionsOf<typeof resourceDoompiUseMcp> | OptionsOf<typeof toolMcp>, undefined>;\ntype Intersect<Union> =\n  (Union extends unknown ? (value: Union) => void : never) extends (value: infer Value) => void ? Value : never;\ntype ExtensionOptions = [InferredOptions] extends [never] ? undefined : Intersect<InferredOptions>;\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n  typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\ntype ManyFactory<T, C> = (context: C) => T | readonly T[];\nconst many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {\n  const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\n  return Array.isArray(resolved) ? resolved : [resolved as T];\n};\n\nexport const extension = definePiExtension<ExtensionOptions>('@agimon-ai/doompi-mcp', async (context) => {\n  const scopeSession = await rootSession(context);\n  const contextSession = { ...context, root: scopeSession.value };\n  return {\n    ...composeRootHooks(scopeSession),\n    get commands(): PiPluginContributions['commands'] { return [...many(commandMcp, contextSession)]; },\n    get resources(): PiPluginContributions['resources'] { return [at(resourceDoompiUseMcp, contextSession)]; },\n    ...piToolContributions('@agimon-ai/doompi-mcp', at(toolMcp, contextSession)),\n    services: [...(scopeSession.services ?? [])],\n  };\n});\n\nexport default extension;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,SAAgB,2BAA2B,KAAmC;CAC5E,MAAM,eAAe,IAAI,eAAe;EACtC,QAAQA,mBAAAA;EACR,UAAU,CACR;GACE,IAAI,GAAGC,mBAAAA,sBAAsB;GAC7B,MAAM,CAACC,mBAAAA,cAAc;IAAE,KAAA;IAAiB,OAAA;IAAqB,QAAQ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