@toolplex/client 0.1.13 → 0.1.15
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.
|
@@ -2,6 +2,7 @@ import { FileLogger } from "../../shared/fileLogger.js";
|
|
|
2
2
|
import os from "os";
|
|
3
3
|
import { initServerManagersOnly } from "../utils/initServerManagers.js";
|
|
4
4
|
import Registry from "../registry.js";
|
|
5
|
+
import envPaths from "env-paths";
|
|
5
6
|
const logger = FileLogger;
|
|
6
7
|
export async function handleInitialize(params) {
|
|
7
8
|
const startTime = Date.now();
|
|
@@ -21,12 +22,13 @@ export async function handleInitialize(params) {
|
|
|
21
22
|
: platform === "win32"
|
|
22
23
|
? "Windows"
|
|
23
24
|
: platform.charAt(0).toUpperCase() + platform.slice(1);
|
|
25
|
+
const paths = envPaths("ToolPlex", { suffix: "" });
|
|
24
26
|
const systemInfo = {
|
|
25
27
|
os: `${osName} ${os.release()}`,
|
|
26
28
|
arch: os.arch(),
|
|
27
29
|
memory: `${Math.round(os.totalmem() / (1024 * 1024 * 1024))}GB`,
|
|
28
30
|
cpuCores: os.cpus().length,
|
|
29
|
-
workDir:
|
|
31
|
+
workDir: paths.data,
|
|
30
32
|
date: new Date().toLocaleDateString("en-US", {
|
|
31
33
|
weekday: "long",
|
|
32
34
|
year: "numeric",
|
|
@@ -46,7 +48,14 @@ export async function handleInitialize(params) {
|
|
|
46
48
|
clientContext.sessionId = toolplexApiInitResponse.session_id;
|
|
47
49
|
clientContext.permissions = toolplexApiInitResponse.permissions;
|
|
48
50
|
clientContext.flags = toolplexApiInitResponse.flags;
|
|
49
|
-
|
|
51
|
+
// Replace {ARGS.workDir} in all prompts before initializing the cache
|
|
52
|
+
const processedPrompts = { ...toolplexApiInitResponse.prompts };
|
|
53
|
+
for (const [key, prompt] of Object.entries(processedPrompts)) {
|
|
54
|
+
if (typeof prompt === "string") {
|
|
55
|
+
processedPrompts[key] = prompt.replace(/\{ARGS\.workDir\}/g, paths.data);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
promptsCache.init(processedPrompts);
|
|
50
59
|
// Init PolicyEnforce after setting permissions and flags
|
|
51
60
|
policyEnforcer.init(clientContext);
|
|
52
61
|
const allSucceeded = serverManagerInitResults.succeeded;
|
|
@@ -137,7 +137,7 @@ export class ServerManager {
|
|
|
137
137
|
await logger.debug(`Getting name for server ${serverId}`);
|
|
138
138
|
return this.serverNames.get(serverId) || serverId;
|
|
139
139
|
}
|
|
140
|
-
async connectWithHandshakeTimeout(client, transport, ms =
|
|
140
|
+
async connectWithHandshakeTimeout(client, transport, ms = 60000) {
|
|
141
141
|
let connectTimeout;
|
|
142
142
|
let listToolsTimeout;
|
|
143
143
|
try {
|
|
@@ -230,7 +230,7 @@ export class ServerManager {
|
|
|
230
230
|
}
|
|
231
231
|
const client = new Client({ name: serverId, version: "1.0.0" }, { capabilities: { prompts: {}, resources: {}, tools: {} } });
|
|
232
232
|
try {
|
|
233
|
-
const toolsResponse = await this.connectWithHandshakeTimeout(client, transport,
|
|
233
|
+
const toolsResponse = await this.connectWithHandshakeTimeout(client, transport, 60000);
|
|
234
234
|
const tools = toolsResponse.tools || [];
|
|
235
235
|
this.sessions.set(serverId, client);
|
|
236
236
|
this.tools.set(serverId, tools);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.1.
|
|
1
|
+
export declare const version = "0.1.15";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '0.1.
|
|
1
|
+
export const version = '0.1.15';
|