@geohar/pi-mcp-combiner 0.24.2 → 0.24.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/dist/client/footer.d.ts +10 -2
  3. package/dist/client/footer.d.ts.map +1 -1
  4. package/dist/client/footer.js +15 -6
  5. package/dist/client/footer.js.map +1 -1
  6. package/dist/combiner-process.d.ts +160 -0
  7. package/dist/combiner-process.d.ts.map +1 -0
  8. package/dist/combiner-process.js +721 -0
  9. package/dist/combiner-process.js.map +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +140 -306
  12. package/dist/index.js.map +1 -1
  13. package/dist/native/combiner-connection.d.ts +84 -0
  14. package/dist/native/combiner-connection.d.ts.map +1 -1
  15. package/dist/native/combiner-connection.js +194 -5
  16. package/dist/native/combiner-connection.js.map +1 -1
  17. package/dist/native/index.d.ts +32 -4
  18. package/dist/native/index.d.ts.map +1 -1
  19. package/dist/native/index.js +94 -6
  20. package/dist/native/index.js.map +1 -1
  21. package/dist/native/resources.d.ts +3 -0
  22. package/dist/native/resources.d.ts.map +1 -1
  23. package/dist/native/resources.js +6 -1
  24. package/dist/native/resources.js.map +1 -1
  25. package/dist/native/tool-surface.d.ts +31 -2
  26. package/dist/native/tool-surface.d.ts.map +1 -1
  27. package/dist/native/tool-surface.js +62 -18
  28. package/dist/native/tool-surface.js.map +1 -1
  29. package/dist/pi.d.ts +9 -1
  30. package/dist/pi.d.ts.map +1 -1
  31. package/package.json +5 -5
  32. package/src/client/footer.ts +16 -4
  33. package/src/client/panel.ts +1 -1
  34. package/src/client/renderers.ts +2 -2
  35. package/src/combiner-process.ts +813 -0
  36. package/src/index.ts +142 -355
  37. package/src/native/combiner-connection.ts +220 -10
  38. package/src/native/index.ts +119 -18
  39. package/src/native/resources.ts +8 -1
  40. package/src/native/tool-surface.ts +80 -18
  41. package/src/pi.ts +6 -1
@@ -50,19 +50,25 @@ export function countsFromHealth(health: unknown): FooterCounts {
50
50
  return { enabled, ready, disabled }
51
51
  }
52
52
 
53
+ /** A native tool-registration pass in progress: tools registered so far / to register. */
54
+ export type RegisterProgress = { done: number; total: number }
55
+
53
56
  /** Render the footer text for a mode (undefined = clear the slot). */
54
57
  export function footerText(
55
58
  mode: FooterStatus,
56
59
  counts: FooterCounts,
57
60
  connectionState: string,
58
61
  toolCount?: number,
62
+ registering?: RegisterProgress,
59
63
  ): string | undefined {
60
64
  if (mode === "off") return undefined
61
65
  if (mode === "compact") return `${PLUG} MCP ${counts.ready}/${counts.enabled}`
62
66
  let text = `${PLUG} ${counts.enabled} ${counts.enabled === 1 ? "server" : "servers"} enabled`
63
67
  if (counts.ready > 0) text += ` (${counts.ready} ready)`
64
68
  if (counts.disabled > 0) text += ` (${counts.disabled} disabled)`
65
- if (typeof toolCount === "number" && toolCount > 0) text += ` · ${toolCount} tools`
69
+ if (registering && registering.done < registering.total) {
70
+ text += ` · registering tools ${registering.done}/${registering.total}`
71
+ } else if (typeof toolCount === "number" && toolCount > 0) text += ` · ${toolCount} tools`
66
72
  if (connectionState !== "connected" && connectionState !== "disconnected") {
67
73
  text += ` — ${connectionState}`
68
74
  }
@@ -78,6 +84,9 @@ export async function updateFooter(
78
84
  ui: ExtensionUIContext | undefined,
79
85
  key: string,
80
86
  mode: FooterStatus,
87
+ /** Read AFTER the /health and tools/list awaits, so a slow paint that resolves
88
+ * last shows the progress as it is then, not as it was when it started. */
89
+ registering?: () => RegisterProgress | undefined,
81
90
  ): Promise<void> {
82
91
  if (mode === "off") return
83
92
  const setStatus = ui?.setStatus
@@ -92,9 +101,12 @@ export async function updateFooter(
92
101
  }
93
102
  let text: string | undefined
94
103
  try {
95
- const [health, tools] = await Promise.all([connection.health(), connection.listTools().catch(() => undefined)])
96
- const toolCount = tools?.length
97
- text = footerText(mode, countsFromHealth(health), connection.state, toolCount)
104
+ // List tools only on a live connection: a footer repaint must never start a
105
+ // connect itself (it would bypass the connection's reconnect backoff).
106
+ const tools = connection.state === "connected" ? connection.listTools().catch(() => undefined) : undefined
107
+ const [health, toolList] = await Promise.all([connection.health(), tools])
108
+ const toolCount = toolList?.length
109
+ text = footerText(mode, countsFromHealth(health), connection.state, toolCount, registering?.())
98
110
  } catch {
99
111
  // Combiner unreachable: report our connection state honestly, still occupying
100
112
  // the slot so the label never silently vanishes.
@@ -276,7 +276,7 @@ class CombinerPanel implements Component {
276
276
 
277
277
  // ── rendering ──
278
278
 
279
- render(width: number): string[] {
279
+ render(width: number): readonly string[] {
280
280
  const w = Math.min(PANEL_WIDTH, Math.max(40, width))
281
281
  const inner = w - 4
282
282
  this.container.clear()
@@ -37,7 +37,7 @@ class TitleRow implements TuiComponent {
37
37
  this.cached = null
38
38
  }
39
39
 
40
- render(width: number): string[] {
40
+ render(width: number): readonly string[] {
41
41
  const safeWidth = Math.max(1, Math.floor(width))
42
42
  if (this.cached?.width === safeWidth) return this.cached.lines
43
43
  const fg = this.theme?.fg?.bind(this.theme)
@@ -84,7 +84,7 @@ class CompactResult implements TuiComponent {
84
84
  this.cached = null
85
85
  }
86
86
 
87
- render(width: number): string[] {
87
+ render(width: number): readonly string[] {
88
88
  const safeWidth = Math.max(1, Math.floor(width))
89
89
  if (this.cached?.width === safeWidth) return this.cached.lines
90
90
  const fg = this.theme?.fg?.bind(this.theme)