pi-llamacpp-infra 1.2.3 → 1.2.4

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 (2) hide show
  1. package/package.json +2 -1
  2. package/src/runtime.ts +16 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-llamacpp-infra",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Discovery, metrics and control of llama.cpp-family servers for pi (llama.cpp, ZINC, DwarfStar/ds4, lucebox, LM Studio): scan machines (localhost, LAN, Tailscale), register models, live metrics, per-model thinking budgets, vision detection, native config UI.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -35,6 +35,7 @@
35
35
  "src"
36
36
  ],
37
37
  "peerDependencies": {
38
+ "@earendil-works/pi-ai": "*",
38
39
  "@earendil-works/pi-coding-agent": "*"
39
40
  }
40
41
  }
package/src/runtime.ts CHANGED
@@ -67,17 +67,24 @@ async function loadOpenAICompletionsStreamSimple(): Promise<StreamSimple> {
67
67
  if (!openAICompletionsStreamPromise) {
68
68
  openAICompletionsStreamPromise = (async () => {
69
69
  try {
70
- const mod = await import("@earendil-works/pi-ai/api/openai-completions");
71
- return (mod as { streamSimple: StreamSimple }).streamSimple;
70
+ // pi's extension loader aliases the pi-ai ROOT specifier to the compat
71
+ // entry (which re-exports openAICompletionsApi), so this import works in
72
+ // every pi runtime (jiti aliases / virtual modules / tsconfig paths).
73
+ // Subpath specifiers like "@earendil-works/pi-ai/api/openai-completions"
74
+ // are NOT aliased and only resolve inside a real node_modules install.
75
+ const mod = await import("@earendil-works/pi-ai");
76
+ const streams = (mod as { openAICompletionsApi?: () => { streamSimple: StreamSimple } }).openAICompletionsApi?.();
77
+ if (typeof streams?.streamSimple === "function") return streams.streamSimple;
72
78
  } catch {
73
- // In pi package installs, pi-ai may be nested under pi-coding-agent
74
- // instead of hoisted as a top-level dependency of this extension.
75
- const piIndexUrl = import.meta.resolve("@earendil-works/pi-coding-agent");
76
- const piPackageDir = dirname(dirname(fileURLToPath(piIndexUrl)));
77
- const nestedModule = join(piPackageDir, "node_modules", "@earendil-works", "pi-ai", "dist", "api", "openai-completions.js");
78
- const mod = await import(pathToFileURL(nestedModule).href);
79
- return (mod as { streamSimple: StreamSimple }).streamSimple;
79
+ // fall through to the nested-module lookup below
80
80
  }
81
+ // In real pi package installs, pi-ai may be nested under pi-coding-agent
82
+ // instead of hoisted as a top-level dependency of this extension.
83
+ const piIndexUrl = import.meta.resolve("@earendil-works/pi-coding-agent");
84
+ const piPackageDir = dirname(dirname(fileURLToPath(piIndexUrl)));
85
+ const nestedModule = join(piPackageDir, "node_modules", "@earendil-works", "pi-ai", "dist", "api", "openai-completions.js");
86
+ const nestedMod = await import(pathToFileURL(nestedModule).href);
87
+ return (nestedMod as { streamSimple: StreamSimple }).streamSimple;
81
88
  })();
82
89
  }
83
90
  return openAICompletionsStreamPromise;