{"version":3,"file":"mcpStatus.mjs","names":[],"sources":["../../src/schemas/mcpStatus.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport { type Static, Type } from 'typebox';\n\n/** Session-scoped MCP status service owned by doompi-mcp. */\nexport const DOOM_MCP_STATUS_SERVICE = 'doom/mcp-status';\n\n/**\n * Connection state of one downstream MCP server.\n *\n * `not-connected` is the startup state: tools restored from the previous run's\n * catalog exist before any socket opens, and their server has not reported yet.\n * `disabled` comes from configuration rather than the connection stream, since a\n * disabled server is never dialled at all.\n */\nexport const McpServerStateSchema = Type.Union([\n  Type.Literal('not-connected'),\n  Type.Literal('connecting'),\n  Type.Literal('connected'),\n  Type.Literal('degraded'),\n  Type.Literal('needs-auth'),\n  Type.Literal('failed'),\n  Type.Literal('closed'),\n  Type.Literal('disabled'),\n]);\nexport type McpServerState = Static<typeof McpServerStateSchema>;\n\nexport const McpServerSnapshotSchema = Type.Object(\n  {\n    name: Type.String({ minLength: 1, maxLength: 128 }),\n    state: McpServerStateSchema,\n    /**\n     * Pi tool names registered for this server, exactly as registered.\n     *\n     * Published rather than derived: a consumer that reverse-engineers the link from\n     * tool-name prefixes cannot attribute anything under an unprefixed naming scheme,\n     * and guesses wrong whenever two servers share a prefix.\n     */\n    tools: Type.Array(Type.String({ minLength: 1 })),\n    resourceCount: Type.Integer({ minimum: 0 }),\n    /** Why the server is in `failed` or `needs-auth`; absent otherwise. */\n    error: Type.Optional(Type.String({ maxLength: 512 })),\n  },\n  { additionalProperties: false },\n);\nexport type McpServerSnapshot = Static<typeof McpServerSnapshotSchema>;\n\nexport const McpStatusSnapshotSchema = Type.Object(\n  { servers: Type.Array(McpServerSnapshotSchema) },\n  { additionalProperties: false },\n);\nexport type McpStatusSnapshot = Static<typeof McpStatusSnapshotSchema>;\n\n/**\n * The current MCP picture, with optional live change notifications.\n *\n * Consumers subscribe before reading the snapshot so startup ordering cannot\n * lose a change. Older providers remain readable through getSnapshot alone.\n *\n * No provider means MCP is not loaded for this session (`--no-mcp`), which times\n * out and is not an error.\n */\nexport interface DoomMcpStatusService {\n  /** Fences consumers against a replaced MCP session. */\n  readonly generation: string;\n  getSnapshot(): McpStatusSnapshot;\n  /** Notifies after tool registration and status updates; returns listener cleanup. */\n  onChange?(listener: () => void): () => void;\n}\n\ndeclare module '@deepseek-ai/cordis' {\n  interface Context {\n    'doom/mcp-status': DoomMcpStatusService;\n  }\n}\n\nexport function readDoomMcpStatus(context: Context): DoomMcpStatusService | undefined {\n  return context.get(DOOM_MCP_STATUS_SERVICE) as DoomMcpStatusService | undefined;\n}\n"],"mappings":"+BAIA,MAAa,EAA0B,kBAU1B,EAAuB,EAAK,MAAM,CAC7C,EAAK,QAAQ,eAAe,EAC5B,EAAK,QAAQ,YAAY,EACzB,EAAK,QAAQ,WAAW,EACxB,EAAK,QAAQ,UAAU,EACvB,EAAK,QAAQ,YAAY,EACzB,EAAK,QAAQ,QAAQ,EACrB,EAAK,QAAQ,QAAQ,EACrB,EAAK,QAAQ,UAAU,CACzB,CAAC,EAGY,EAA0B,EAAK,OAC1C,CACE,KAAM,EAAK,OAAO,CAAE,UAAW,EAAG,UAAW,GAAI,CAAC,EAClD,MAAO,EAQP,MAAO,EAAK,MAAM,EAAK,OAAO,CAAE,UAAW,CAAE,CAAC,CAAC,EAC/C,cAAe,EAAK,QAAQ,CAAE,QAAS,CAAE,CAAC,EAE1C,MAAO,EAAK,SAAS,EAAK,OAAO,CAAE,UAAW,GAAI,CAAC,CAAC,CACtD,EACA,CAAE,qBAAsB,EAAM,CAChC,EAGa,EAA0B,EAAK,OAC1C,CAAE,QAAS,EAAK,MAAM,CAAuB,CAAE,EAC/C,CAAE,qBAAsB,EAAM,CAChC,EA0BA,SAAgB,EAAkB,EAAoD,CACpF,OAAO,EAAQ,IAAI,CAAuB,CAC5C"}