@aexol/spectral 0.0.8 → 0.1.1
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.
- package/dist/server/pi-bridge.js +24 -4
- package/package.json +1 -1
package/dist/server/pi-bridge.js
CHANGED
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
* conversations within a single WS connection work normally.
|
|
49
49
|
*/
|
|
50
50
|
import { AuthStorage, createAgentSession, DefaultResourceLoader, ModelRegistry, SessionManager, } from "@mariozechner/pi-coding-agent";
|
|
51
|
+
import { createRequire } from "node:module";
|
|
51
52
|
import { randomUUID } from "node:crypto";
|
|
52
53
|
import aexolMcpExtension from "../extensions/aexol-mcp.js";
|
|
53
54
|
import { fetchAllowedModels as defaultFetchAllowedModels, } from "../relay/models-fetch.js";
|
|
@@ -116,13 +117,32 @@ export class PiBridge {
|
|
|
116
117
|
async start() {
|
|
117
118
|
if (this.disposed)
|
|
118
119
|
throw new Error("PiBridge already disposed");
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
120
|
+
// Build extension factories. Always include the Aexol MCP extension;
|
|
121
|
+
// dynamically load the pi-mcp-adapter (standard MCP servers) with
|
|
122
|
+
// graceful degradation when the package is not installed.
|
|
123
|
+
const extensionFactories = [aexolMcpExtension];
|
|
124
|
+
// Use createRequire to avoid TypeScript walking into pi-mcp-adapter's
|
|
125
|
+
// raw .ts sources (the package doesn't ship .d.ts). The extension factory
|
|
126
|
+
// is the default export: `export default function mcpAdapter(pi)`.
|
|
127
|
+
try {
|
|
128
|
+
const piMcpRequire = createRequire(import.meta.url);
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
130
|
+
const mcpAdapterExtension = piMcpRequire("pi-mcp-adapter");
|
|
131
|
+
if (typeof mcpAdapterExtension === "function") {
|
|
132
|
+
extensionFactories.push(mcpAdapterExtension);
|
|
133
|
+
console.info("[PiBridge] Standard MCP adapter loaded (pi-mcp-adapter)");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
console.info("[PiBridge] pi-mcp-adapter not found; standard MCP servers disabled.");
|
|
138
|
+
}
|
|
139
|
+
// ResourceLoader with extensions wired in via factories.
|
|
140
|
+
// Each factory's signature `(pi: ExtensionAPI) => Promise<void>` matches
|
|
141
|
+
// the ExtensionFactory type exactly, so we can pass them directly.
|
|
122
142
|
const resourceLoader = new DefaultResourceLoader({
|
|
123
143
|
cwd: this.opts.cwd,
|
|
124
144
|
agentDir: this.opts.agentDir ?? `${process.env.HOME ?? ""}/.pi/agent`,
|
|
125
|
-
extensionFactories
|
|
145
|
+
extensionFactories,
|
|
126
146
|
// Skip on-disk extension/skill discovery so the server is self-contained.
|
|
127
147
|
noExtensions: false,
|
|
128
148
|
noSkills: true,
|