@e4779/pi-fabric 0.105.0-fork.18 → 0.105.0-fork.22

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.
@@ -6487,4 +6487,4 @@ export {
6487
6487
  FABRIC_MANAGED_HOST_VERSION,
6488
6488
  createFabricExtension
6489
6489
  };
6490
- //# sourceMappingURL=chunk-6VXPACGC.js.map
6490
+ //# sourceMappingURL=chunk-EXWS4ZS3.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FABRIC_MANAGED_HOST_VERSION,
3
3
  createFabricExtension
4
- } from "./chunks/chunk-6VXPACGC.js";
4
+ } from "./chunks/chunk-EXWS4ZS3.js";
5
5
  import "./chunks/chunk-U2UBUKNQ.js";
6
6
  import "./chunks/chunk-J7ZQERKA.js";
7
7
  import "./chunks/chunk-QNMQJNXE.js";
@@ -10235,7 +10235,11 @@ var PiNativeMcpTools = class {
10235
10235
  return this.#tools(server).map((entry) => this.#descriptor(entry)).filter((entry) => !query || `${entry.name} ${entry.description}`.toLowerCase().includes(query));
10236
10236
  }
10237
10237
  serverInfo() {
10238
- const tools = this.#tools();
10238
+ let tools = this.#tools();
10239
+ const indexed = new Set(tools.map((tool) => tool.server));
10240
+ if (this.servers.some((name) => !indexed.has(name)) && this.#pollLiveRegistrations()) {
10241
+ tools = this.#tools();
10242
+ }
10239
10243
  return this.servers.map((name) => {
10240
10244
  const selected = tools.filter((tool) => tool.server === name);
10241
10245
  return {
@@ -10248,17 +10252,35 @@ var PiNativeMcpTools = class {
10248
10252
  });
10249
10253
  }
10250
10254
  #resolve(server, requested) {
10251
- this.#refreshIndex();
10252
- const visible = this.#visibility();
10253
- const index = this.#indexes.get(server);
10254
- if (index) this.#checkMetadata(index, visible);
10255
- const candidates = index?.exact.get(requested) ?? index?.aliases.get(requested) ?? [];
10256
- const matches = candidates.filter((entry) => visible(entry.registered));
10255
+ const attempt = () => {
10256
+ this.#refreshIndex();
10257
+ const visible = this.#visibility();
10258
+ const index = this.#indexes.get(server);
10259
+ if (index) this.#checkMetadata(index, visible);
10260
+ const candidates = index?.exact.get(requested) ?? index?.aliases.get(requested) ?? [];
10261
+ return candidates.filter((entry) => visible(entry.registered));
10262
+ };
10263
+ let matches = attempt();
10264
+ if (matches.length !== 1 && this.#pollLiveRegistrations()) matches = attempt();
10257
10265
  if (matches.length !== 1) {
10258
10266
  throw new Error(`Unknown or ambiguous Pi MCP tool: ${server}.${requested}. Check /mcp and the tool exposure; no mcporter fallback was attempted.`);
10259
10267
  }
10260
10268
  return matches[0];
10261
10269
  }
10270
+ // Mirrors Pi's "waits for the servers it names" semantics inside the borrow
10271
+ // layer: never polls on a timer, only once per failed lookup, and reports
10272
+ // change only when the capture catalog actually moved.
10273
+ #pollLiveRegistrations() {
10274
+ const runner = this.catalog.runner;
10275
+ if (typeof runner?.getAllRegisteredTools !== "function") return false;
10276
+ const before = this.catalog.registeredTools();
10277
+ try {
10278
+ runner.getAllRegisteredTools();
10279
+ } catch {
10280
+ return false;
10281
+ }
10282
+ return this.catalog.registeredTools() !== before;
10283
+ }
10262
10284
  describe(server, tool) {
10263
10285
  return this.#descriptor(this.#resolve(server, tool));
10264
10286
  }