@xalia/agent 0.5.0 → 0.5.2
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/README.md +46 -7
- package/dist/{agent.js → agent/src/agent/agent.js} +5 -4
- package/dist/{agentUtils.js → agent/src/agent/agentUtils.js} +10 -9
- package/dist/{mcpServerManager.js → agent/src/agent/mcpServerManager.js} +2 -1
- package/dist/{sudoMcpServerManager.js → agent/src/agent/sudoMcpServerManager.js} +4 -4
- package/dist/agent/src/chat/apiKeyManager.js +23 -0
- package/dist/agent/src/chat/asyncQueue.js +41 -0
- package/dist/agent/src/chat/client.js +126 -0
- package/dist/agent/src/chat/conversationManager.js +173 -0
- package/dist/agent/src/chat/db.js +186 -0
- package/dist/agent/src/chat/messages.js +2 -0
- package/dist/agent/src/chat/server.js +158 -0
- package/dist/agent/src/index.js +2 -0
- package/dist/agent/src/test/db.test.js +73 -0
- package/dist/{test → agent/src/test}/imageLoad.test.js +1 -1
- package/dist/{test → agent/src/test}/mcpServerManager.test.js +1 -1
- package/dist/{test → agent/src/test}/prompt.test.js +1 -1
- package/dist/{test → agent/src/test}/sudoMcpServerManager.test.js +3 -3
- package/dist/{chat.js → agent/src/tool/agentChat.js} +5 -5
- package/dist/{main.js → agent/src/tool/agentMain.js} +9 -15
- package/dist/agent/src/tool/chatMain.js +207 -0
- package/dist/agent/src/tool/main.js +54 -0
- package/dist/{options.js → agent/src/tool/options.js} +36 -2
- package/dist/agent/src/utils/asyncLock.js +45 -0
- package/dist/supabase/database.types.js +8 -0
- package/eslint.config.mjs +14 -14
- package/package.json +9 -15
- package/scripts/test_chat +84 -0
- package/src/{agent.ts → agent/agent.ts} +22 -11
- package/src/{agentUtils.ts → agent/agentUtils.ts} +13 -14
- package/src/{mcpServerManager.ts → agent/mcpServerManager.ts} +2 -1
- package/src/{sudoMcpServerManager.ts → agent/sudoMcpServerManager.ts} +3 -3
- package/src/chat/apiKeyManager.ts +24 -0
- package/src/chat/asyncQueue.ts +51 -0
- package/src/chat/client.ts +142 -0
- package/src/chat/conversationManager.ts +283 -0
- package/src/chat/db.ts +264 -0
- package/src/chat/messages.ts +91 -0
- package/src/chat/server.ts +177 -0
- package/src/test/db.test.ts +103 -0
- package/src/test/imageLoad.test.ts +1 -1
- package/src/test/mcpServerManager.test.ts +1 -1
- package/src/test/prompt.test.ts +1 -1
- package/src/test/sudoMcpServerManager.test.ts +6 -10
- package/src/{chat.ts → tool/agentChat.ts} +26 -24
- package/src/{main.ts → tool/agentMain.ts} +12 -19
- package/src/tool/chatMain.ts +250 -0
- package/src/{files.ts → tool/files.ts} +1 -1
- package/src/tool/main.ts +25 -0
- package/src/{nodePlatform.ts → tool/nodePlatform.ts} +1 -1
- package/src/{options.ts → tool/options.ts} +40 -1
- package/src/utils/asyncLock.ts +43 -0
- package/test_data/simplecalc_profile.json +1 -1
- package/test_data/sudomcp_import_profile.json +1 -1
- package/test_data/test_script_profile.json +1 -1
- package/tsconfig.json +1 -1
- package/scripts/test_script +0 -60
- /package/dist/{dummyLLM.js → agent/src/agent/dummyLLM.js} +0 -0
- /package/dist/{iplatform.js → agent/src/agent/iplatform.js} +0 -0
- /package/dist/{llm.js → agent/src/agent/llm.js} +0 -0
- /package/dist/{openAILLM.js → agent/src/agent/openAILLM.js} +0 -0
- /package/dist/{openAILLMStreaming.js → agent/src/agent/openAILLMStreaming.js} +0 -0
- /package/dist/{tokenAuth.js → agent/src/agent/tokenAuth.js} +0 -0
- /package/dist/{tools.js → agent/src/agent/tools.js} +0 -0
- /package/dist/{files.js → agent/src/tool/files.js} +0 -0
- /package/dist/{nodePlatform.js → agent/src/tool/nodePlatform.js} +0 -0
- /package/dist/{prompt.js → agent/src/tool/prompt.js} +0 -0
- /package/src/{dummyLLM.ts → agent/dummyLLM.ts} +0 -0
- /package/src/{iplatform.ts → agent/iplatform.ts} +0 -0
- /package/src/{llm.ts → agent/llm.ts} +0 -0
- /package/src/{openAILLM.ts → agent/openAILLM.ts} +0 -0
- /package/src/{openAILLMStreaming.ts → agent/openAILLMStreaming.ts} +0 -0
- /package/src/{tokenAuth.ts → agent/tokenAuth.ts} +0 -0
- /package/src/{tools.ts → agent/tools.ts} +0 -0
- /package/src/{test/prompt.test.src → index.ts} +0 -0
- /package/src/{prompt.ts → tool/prompt.ts} +0 -0
@@ -1,17 +1,20 @@
|
|
1
1
|
import yocto from "yocto-spinner";
|
2
2
|
import { Spinner } from "yocto-spinner";
|
3
3
|
import * as fs from "fs";
|
4
|
-
import { Agent, AgentProfile } from "./agent";
|
5
|
-
import { displayToolCall } from "./tools";
|
6
|
-
import { McpServerManager } from "./mcpServerManager";
|
7
4
|
import OpenAI from "openai";
|
8
|
-
import { loadImageB64OrUndefined } from "./files";
|
9
|
-
import { Prompt, parsePrompt } from "./prompt";
|
10
|
-
import { SudoMcpServerManager } from "./sudoMcpServerManager";
|
11
5
|
import chalk from "chalk";
|
6
|
+
|
12
7
|
import { configuration, utils } from "@xalia/xmcp/tool";
|
13
8
|
import { getLogger, InvalidConfiguration } from "@xalia/xmcp/sdk";
|
14
|
-
|
9
|
+
|
10
|
+
import { Agent, AgentProfile } from "../agent/agent";
|
11
|
+
import { McpServerManager } from "../agent/mcpServerManager";
|
12
|
+
import { displayToolCall } from "../agent/tools";
|
13
|
+
import { SkillManager } from "../agent/sudoMcpServerManager";
|
14
|
+
import { createAgentWithSkills } from "../agent/agentUtils";
|
15
|
+
|
16
|
+
import { loadImageB64OrUndefined } from "./files";
|
17
|
+
import { Prompt, parsePrompt } from "./prompt";
|
15
18
|
import { NODE_PLATFORM } from "./nodePlatform";
|
16
19
|
|
17
20
|
const logger = getLogger();
|
@@ -78,19 +81,18 @@ export async function runChat(
|
|
78
81
|
|
79
82
|
// Create agent
|
80
83
|
|
81
|
-
const [agent, sudoMcpServerManager] =
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
);
|
84
|
+
const [agent, sudoMcpServerManager] = await createAgentWithSkills(
|
85
|
+
llmUrl,
|
86
|
+
agentProfile,
|
87
|
+
onMessage,
|
88
|
+
onToolCall,
|
89
|
+
NODE_PLATFORM,
|
90
|
+
llmApiKey,
|
91
|
+
sudomcpConfig,
|
92
|
+
utils.FRONTEND_PROD_AUTHORIZED_URL,
|
93
|
+
undefined,
|
94
|
+
stream
|
95
|
+
);
|
94
96
|
if (conversation) {
|
95
97
|
agent.setConversation(conversation);
|
96
98
|
}
|
@@ -148,7 +150,7 @@ export async function runChat(
|
|
148
150
|
async function getNextPrompt(
|
149
151
|
repl: Prompt,
|
150
152
|
agent: Agent,
|
151
|
-
sudoMcpServerManager:
|
153
|
+
sudoMcpServerManager: SkillManager
|
152
154
|
): Promise<[string | undefined, string | undefined]> {
|
153
155
|
while (true) {
|
154
156
|
// Get a line, detecting the EOF signal.
|
@@ -199,7 +201,7 @@ async function getNextPrompt(
|
|
199
201
|
async function runCommand(
|
200
202
|
agent: Agent,
|
201
203
|
mcpServerManager: McpServerManager,
|
202
|
-
sudoMcpServerManager:
|
204
|
+
sudoMcpServerManager: SkillManager,
|
203
205
|
cmds: string[]
|
204
206
|
) {
|
205
207
|
switch (cmds[0]) {
|
@@ -289,7 +291,7 @@ function listTools(mcpServerManager: McpServerManager) {
|
|
289
291
|
}
|
290
292
|
}
|
291
293
|
|
292
|
-
function listServers(sudoMcpServerManager:
|
294
|
+
function listServers(sudoMcpServerManager: SkillManager) {
|
293
295
|
console.log(`Available MCP Servers:`);
|
294
296
|
|
295
297
|
const serverBriefs = sudoMcpServerManager.getServerBriefs();
|
@@ -303,7 +305,7 @@ function listServers(sudoMcpServerManager: SudoMcpServerManager) {
|
|
303
305
|
* Adds server and enables all tools.
|
304
306
|
*/
|
305
307
|
async function addServer(
|
306
|
-
sudoMcpServerManager:
|
308
|
+
sudoMcpServerManager: SkillManager,
|
307
309
|
serverName: string
|
308
310
|
) {
|
309
311
|
try {
|
@@ -1,10 +1,15 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
// -*- typescript -*-
|
3
|
-
|
4
1
|
import * as fs from "fs";
|
5
2
|
import * as dotenv from "dotenv";
|
6
|
-
import {
|
7
|
-
import
|
3
|
+
import { command, option, flag, optional, string } from "cmd-ts";
|
4
|
+
import OpenAI from "openai";
|
5
|
+
import { strict as assert } from "assert";
|
6
|
+
|
7
|
+
import { configuration, utils } from "@xalia/xmcp/tool";
|
8
|
+
import { getLogger } from "@xalia/xmcp/sdk";
|
9
|
+
|
10
|
+
import { AgentProfile } from "../agent/agent";
|
11
|
+
import { runOneShot } from "../agent/agentUtils";
|
12
|
+
|
8
13
|
import {
|
9
14
|
llmUrl,
|
10
15
|
llmApiKey,
|
@@ -14,24 +19,19 @@ import {
|
|
14
19
|
approveToolsUpTo,
|
15
20
|
imageFile,
|
16
21
|
} from "./options";
|
17
|
-
import OpenAI from "openai";
|
18
22
|
import {
|
19
23
|
loadFileOrUndefined,
|
20
24
|
loadFileOrStdin,
|
21
25
|
loadImageB64OrUndefined,
|
22
26
|
} from "./files";
|
23
|
-
import {
|
24
|
-
import { getLogger } from "@xalia/xmcp/sdk";
|
25
|
-
import { runOneShot } from "./agentUtils";
|
26
|
-
import { runChat } from "./chat";
|
27
|
+
import { runChat } from "./agentChat";
|
27
28
|
import { NODE_PLATFORM } from "./nodePlatform";
|
28
|
-
import { strict as assert } from "assert";
|
29
29
|
|
30
30
|
dotenv.config();
|
31
31
|
|
32
32
|
const logger = getLogger();
|
33
33
|
|
34
|
-
const
|
34
|
+
export const agentMain = command({
|
35
35
|
name: "main",
|
36
36
|
args: {
|
37
37
|
promptFile,
|
@@ -178,10 +178,3 @@ const main = command({
|
|
178
178
|
}
|
179
179
|
},
|
180
180
|
});
|
181
|
-
|
182
|
-
function handleError(msg: string) {
|
183
|
-
console.error(msg);
|
184
|
-
process.exit(1);
|
185
|
-
}
|
186
|
-
|
187
|
-
run(main, process.argv.slice(2)).catch(handleError);
|
@@ -0,0 +1,250 @@
|
|
1
|
+
import {
|
2
|
+
command,
|
3
|
+
optional,
|
4
|
+
option,
|
5
|
+
flag,
|
6
|
+
string,
|
7
|
+
number,
|
8
|
+
subcommands,
|
9
|
+
} from "cmd-ts";
|
10
|
+
import { stdout } from "process";
|
11
|
+
import * as fs from "fs";
|
12
|
+
|
13
|
+
import { configuration } from "@xalia/xmcp/tool";
|
14
|
+
import { getLogger } from "@xalia/xmcp/sdk";
|
15
|
+
|
16
|
+
import { ChatClient } from "../chat/client";
|
17
|
+
import { runServer } from "../chat/server";
|
18
|
+
import { ClientUserMessage, ServerToClient } from "../chat/messages";
|
19
|
+
|
20
|
+
import { Prompt } from "./prompt";
|
21
|
+
import * as options from "./options";
|
22
|
+
|
23
|
+
const logger = getLogger();
|
24
|
+
|
25
|
+
const server = command({
|
26
|
+
name: "server",
|
27
|
+
args: {
|
28
|
+
port: option({
|
29
|
+
type: number,
|
30
|
+
long: "port",
|
31
|
+
short: "p",
|
32
|
+
env: "CHAT_SERVER_PORT",
|
33
|
+
defaultValue: () => 5003,
|
34
|
+
}),
|
35
|
+
supabaseUrl: options.supabaseUrl,
|
36
|
+
supabaseKey: options.supabaseKey,
|
37
|
+
llmUrl: options.llmUrl,
|
38
|
+
xmcpUrl: options.xmcpUrl,
|
39
|
+
pidFile: options.pidFile,
|
40
|
+
},
|
41
|
+
handler: async ({
|
42
|
+
port,
|
43
|
+
supabaseUrl,
|
44
|
+
supabaseKey,
|
45
|
+
llmUrl,
|
46
|
+
xmcpUrl,
|
47
|
+
pidFile,
|
48
|
+
}): Promise<void> => {
|
49
|
+
if (pidFile) {
|
50
|
+
fs.writeFileSync(pidFile, process.pid.toString());
|
51
|
+
}
|
52
|
+
|
53
|
+
runServer(port, supabaseUrl, supabaseKey, llmUrl, xmcpUrl);
|
54
|
+
},
|
55
|
+
});
|
56
|
+
|
57
|
+
const client = command({
|
58
|
+
name: "client",
|
59
|
+
args: {
|
60
|
+
host: option({
|
61
|
+
type: string,
|
62
|
+
long: "host",
|
63
|
+
short: "h",
|
64
|
+
env: "CHAT_SERVER_HOST",
|
65
|
+
defaultValue: () => "localhost",
|
66
|
+
}),
|
67
|
+
port: option({
|
68
|
+
type: number,
|
69
|
+
long: "port",
|
70
|
+
short: "p",
|
71
|
+
env: "CHAT_SERVER_PORT",
|
72
|
+
defaultValue: () => 5003,
|
73
|
+
}),
|
74
|
+
apiKey: options.apiKey,
|
75
|
+
session: option({
|
76
|
+
type: string,
|
77
|
+
long: "session",
|
78
|
+
description: "Session identifier (id, name, user/name)",
|
79
|
+
env: "SESSION",
|
80
|
+
}),
|
81
|
+
agentProfile: option({
|
82
|
+
type: optional(string),
|
83
|
+
long: "agent-profile",
|
84
|
+
description: "Create new session using agent profile (id, name)",
|
85
|
+
env: "AGENT_PROFILE",
|
86
|
+
}),
|
87
|
+
script: option({
|
88
|
+
type: optional(string),
|
89
|
+
long: "script",
|
90
|
+
description: "Script (file) to execute and then exit.",
|
91
|
+
}),
|
92
|
+
test: flag({
|
93
|
+
long: "test",
|
94
|
+
description: "Run a test client and disconnect",
|
95
|
+
}),
|
96
|
+
},
|
97
|
+
handler: async ({
|
98
|
+
host,
|
99
|
+
port,
|
100
|
+
apiKey,
|
101
|
+
session,
|
102
|
+
agentProfile,
|
103
|
+
script,
|
104
|
+
test,
|
105
|
+
}): Promise<void> => {
|
106
|
+
if (!apiKey) {
|
107
|
+
// TODO: configFIle param list in ../main.ts
|
108
|
+
const sudomcpConfig = configuration.loadEnsureConfig();
|
109
|
+
apiKey = sudomcpConfig.api_key;
|
110
|
+
}
|
111
|
+
|
112
|
+
if (test) {
|
113
|
+
await runClientTest(host, port, apiKey, session);
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
|
117
|
+
if (script) {
|
118
|
+
await runScript(host, port, apiKey, session, agentProfile, script);
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
|
122
|
+
const onMessage = getCLIOnMessage();
|
123
|
+
const repl = new Prompt();
|
124
|
+
const client = await ChatClient.init(
|
125
|
+
host,
|
126
|
+
port,
|
127
|
+
apiKey,
|
128
|
+
onMessage,
|
129
|
+
() => repl.shutdown(),
|
130
|
+
session,
|
131
|
+
agentProfile
|
132
|
+
);
|
133
|
+
|
134
|
+
logger.debug("client created");
|
135
|
+
|
136
|
+
while (true) {
|
137
|
+
const msgText = await repl.run("ME: ");
|
138
|
+
logger.debug(`prompt got '${msgText}'`);
|
139
|
+
if (msgText === undefined) {
|
140
|
+
logger.debug("exiting...");
|
141
|
+
client.close();
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
if (msgText.length > 0) {
|
145
|
+
const msg: ClientUserMessage = {
|
146
|
+
type: "msg",
|
147
|
+
message: msgText,
|
148
|
+
};
|
149
|
+
client.sendMessage(msg);
|
150
|
+
} else {
|
151
|
+
logger.debug("(ignoring empty message)");
|
152
|
+
}
|
153
|
+
}
|
154
|
+
},
|
155
|
+
});
|
156
|
+
|
157
|
+
function getCLIOnMessage(): (msg: ServerToClient) => void {
|
158
|
+
let startMsg = true;
|
159
|
+
return (msg: ServerToClient) => {
|
160
|
+
switch (msg.type) {
|
161
|
+
case "user_msg":
|
162
|
+
stdout.write(`[${msg.from}]: ${msg.message}\n`);
|
163
|
+
break;
|
164
|
+
case "agent_msg":
|
165
|
+
stdout.write(`[AGENT]: ${msg.message}\n`);
|
166
|
+
break;
|
167
|
+
case "agent_msg_chunk":
|
168
|
+
if (startMsg) {
|
169
|
+
stdout.write("[AGENT]: ");
|
170
|
+
startMsg = false;
|
171
|
+
}
|
172
|
+
stdout.write(msg.message);
|
173
|
+
if (msg.end) {
|
174
|
+
stdout.write("\n");
|
175
|
+
startMsg = true;
|
176
|
+
}
|
177
|
+
break;
|
178
|
+
default:
|
179
|
+
stdout.write(`(${JSON.stringify(msg)})\n`);
|
180
|
+
break;
|
181
|
+
}
|
182
|
+
};
|
183
|
+
}
|
184
|
+
|
185
|
+
async function runScript(
|
186
|
+
host: string,
|
187
|
+
port: number,
|
188
|
+
apiKey: string,
|
189
|
+
session: string,
|
190
|
+
agentProfile: string | undefined,
|
191
|
+
script: string
|
192
|
+
): Promise<void> {
|
193
|
+
const client = await ChatClient.init(
|
194
|
+
host,
|
195
|
+
port,
|
196
|
+
apiKey,
|
197
|
+
getCLIOnMessage(),
|
198
|
+
() => {},
|
199
|
+
session,
|
200
|
+
agentProfile
|
201
|
+
);
|
202
|
+
const scriptData = fs.readFileSync(script, "utf8");
|
203
|
+
const lines = scriptData.split("\n");
|
204
|
+
for (const line of lines) {
|
205
|
+
await new Promise((r) => setTimeout(r, 1000));
|
206
|
+
client.sendMessage({ type: "msg", message: line });
|
207
|
+
}
|
208
|
+
|
209
|
+
// 2 second wait period
|
210
|
+
await new Promise((r) => setTimeout(r, 2000));
|
211
|
+
|
212
|
+
client.close();
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
|
216
|
+
async function runClientTest(
|
217
|
+
host: string,
|
218
|
+
port: number,
|
219
|
+
apiKey: string,
|
220
|
+
session: string
|
221
|
+
): Promise<void> {
|
222
|
+
const client = await ChatClient.init(
|
223
|
+
host,
|
224
|
+
port,
|
225
|
+
apiKey,
|
226
|
+
getCLIOnMessage(),
|
227
|
+
() => {},
|
228
|
+
session
|
229
|
+
);
|
230
|
+
|
231
|
+
for (let i = 1; i <= 60; i++) {
|
232
|
+
await new Promise((r) => setTimeout(r, 1000));
|
233
|
+
|
234
|
+
const message: ClientUserMessage = {
|
235
|
+
type: "msg",
|
236
|
+
message: `add ${i} and ${i + 1}`,
|
237
|
+
};
|
238
|
+
client.sendMessage(message);
|
239
|
+
}
|
240
|
+
|
241
|
+
client.close();
|
242
|
+
}
|
243
|
+
|
244
|
+
export const chatMain = subcommands({
|
245
|
+
name: "chat",
|
246
|
+
cmds: {
|
247
|
+
server,
|
248
|
+
client,
|
249
|
+
},
|
250
|
+
});
|
package/src/tool/main.ts
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
// -*- typescript -*-
|
3
|
+
|
4
|
+
import * as dotenv from "dotenv";
|
5
|
+
import { run, subcommands } from "cmd-ts";
|
6
|
+
|
7
|
+
import { chatMain } from "./chatMain";
|
8
|
+
import { agentMain } from "./agentMain";
|
9
|
+
|
10
|
+
dotenv.config();
|
11
|
+
|
12
|
+
const main = subcommands({
|
13
|
+
name: "chat",
|
14
|
+
cmds: {
|
15
|
+
agent: agentMain,
|
16
|
+
chat: chatMain,
|
17
|
+
},
|
18
|
+
});
|
19
|
+
|
20
|
+
function handleError(msg: string) {
|
21
|
+
console.error(msg);
|
22
|
+
process.exit(1);
|
23
|
+
}
|
24
|
+
|
25
|
+
run(main, process.argv.slice(2)).catch(handleError);
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { boolean, option, optional, string, flag, number } from "cmd-ts";
|
2
2
|
import { ArgParser } from "cmd-ts/dist/cjs/argparser";
|
3
3
|
import { Descriptive, ProvidesHelp } from "cmd-ts/dist/cjs/helpdoc";
|
4
|
-
import { DEFAULT_LLM_URL } from "
|
4
|
+
import { DEFAULT_LLM_URL } from "../agent/agentUtils";
|
5
|
+
import { SUPABASE_LOCAL_KEY, SUPABASE_LOCAL_URL } from "../chat/db";
|
5
6
|
|
6
7
|
export type Option = ReturnType<typeof option>;
|
7
8
|
export type OptionalOption = ArgParser<string | undefined> &
|
@@ -101,3 +102,41 @@ export const llmUrl = option({
|
|
101
102
|
env: "LLM_URL",
|
102
103
|
defaultValue: () => DEFAULT_LLM_URL,
|
103
104
|
});
|
105
|
+
|
106
|
+
export const xmcpUrl = option({
|
107
|
+
type: string,
|
108
|
+
long: "xmcp-url",
|
109
|
+
description: "XMCP URL (OpenAI compatible)",
|
110
|
+
env: "XMCP_URL",
|
111
|
+
defaultValue: () => "http://localhost:5001/",
|
112
|
+
});
|
113
|
+
|
114
|
+
export const apiKey = option({
|
115
|
+
type: optional(string),
|
116
|
+
long: "api-key",
|
117
|
+
short: "k",
|
118
|
+
description: "API key",
|
119
|
+
env: "API_KEY",
|
120
|
+
});
|
121
|
+
|
122
|
+
export const supabaseUrl = option({
|
123
|
+
type: string,
|
124
|
+
long: "supabase-url",
|
125
|
+
description: "Supabase URL",
|
126
|
+
env: "SUPABASE_URL",
|
127
|
+
defaultValue: () => SUPABASE_LOCAL_URL,
|
128
|
+
});
|
129
|
+
|
130
|
+
export const supabaseKey = option({
|
131
|
+
type: string,
|
132
|
+
long: "supabase-key",
|
133
|
+
description: "Supabase Key",
|
134
|
+
env: "SUPABASE_KEY",
|
135
|
+
defaultValue: () => SUPABASE_LOCAL_KEY,
|
136
|
+
});
|
137
|
+
|
138
|
+
export const pidFile = option({
|
139
|
+
type: optional(string),
|
140
|
+
long: "pid-file",
|
141
|
+
description: "write pid file",
|
142
|
+
});
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { strict as assert } from "assert";
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Support awaiting exclusive access to a resource.
|
5
|
+
*/
|
6
|
+
export class AsyncLock {
|
7
|
+
private running: boolean = false;
|
8
|
+
private callbacks: (() => Promise<void>)[] = [];
|
9
|
+
|
10
|
+
lockAndProcess<T>(cb: () => Promise<T>): Promise<T> {
|
11
|
+
return new Promise<T>((r, e) => {
|
12
|
+
this.callbacks.push(async () => {
|
13
|
+
try {
|
14
|
+
const result = await cb();
|
15
|
+
r(result);
|
16
|
+
} catch (err) {
|
17
|
+
e(err);
|
18
|
+
}
|
19
|
+
});
|
20
|
+
|
21
|
+
if (!this.running) {
|
22
|
+
this.run();
|
23
|
+
}
|
24
|
+
});
|
25
|
+
}
|
26
|
+
|
27
|
+
private async run() {
|
28
|
+
assert(!this.running);
|
29
|
+
this.running = true;
|
30
|
+
|
31
|
+
while (this.callbacks.length > 0) {
|
32
|
+
const cb = this.callbacks.shift();
|
33
|
+
assert(cb);
|
34
|
+
try {
|
35
|
+
await cb();
|
36
|
+
} catch (e) {
|
37
|
+
assert(false, `errors should not propagate: ${e}`);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
this.running = false;
|
42
|
+
}
|
43
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
{
|
2
2
|
"system_prompt": "Your job is to parse the public README of an mcp server code repository and extract the commands to run the server. You must then create a yaml \"sudomcp\" spec of the form:\n```\nname: mongodb-local\ntitle: MongoDB Local\ndescription: Interact with a local MongoDB instance (via connection string)\nlogo_url: \"https://github.com/sudobase-ai/mcp-servers/blob/master/mongodb-local/logo.png?raw=true\"\nconfig_schema:\n connection_string:\n type: string\n default: \"mongodb://localhost\"\nstdio_server_params:\n command: \"npx\"\n args:\n - \"-y\"\n - \"mongodb-mcp-server\"\n env:\n MDB_MCP_CONNECTION_STRING: $connection_string\n```\nThe above is for a mongodb MCP server, requiring an environment variable `MDB_MCP_CONNECTION_STRING`. The `config_schema` section determines the variables that are required from the user in order to populate the `args` or the `env` values. Each server will have its own configuration requirements and some servers will not require a `config_schema` section at all. The use of \"mcp\" in the name, title and description is redundant and should be avoided.\n\nDo not explain any intermediate steps or give any justification. Just output the yaml file directly so I can pipe it to a file. No ``` or similar notation.\n\n",
|
3
|
-
"mcp_settings": {"duckduckgo-search":["fetch_content"]}
|
3
|
+
"mcp_settings": { "duckduckgo-search": ["fetch_content"] }
|
4
4
|
}
|
package/tsconfig.json
CHANGED
package/scripts/test_script
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
. env/bin/activate
|
4
|
-
make dev-setup
|
5
|
-
|
6
|
-
# Build client
|
7
|
-
|
8
|
-
pushd ../client
|
9
|
-
yarn
|
10
|
-
yarn build
|
11
|
-
client=`realpath dist/src/tool/main.js`
|
12
|
-
popd
|
13
|
-
|
14
|
-
# Build agent
|
15
|
-
yarn
|
16
|
-
yarn build
|
17
|
-
agent=`realpath dist/main.js`
|
18
|
-
|
19
|
-
set -x
|
20
|
-
set -e
|
21
|
-
|
22
|
-
# Start server
|
23
|
-
|
24
|
-
pushd ../mcppro
|
25
|
-
|
26
|
-
function stop_server() {
|
27
|
-
if [ -e sudomcp.pid ] ; then
|
28
|
-
kill `cat sudomcp.pid` || echo -n
|
29
|
-
fi
|
30
|
-
}
|
31
|
-
|
32
|
-
if [ -z ${NO_START} ] ; then
|
33
|
-
stop_server
|
34
|
-
make start-dev > server.log 2>&1 &
|
35
|
-
sleep 5
|
36
|
-
fi
|
37
|
-
|
38
|
-
[ -n "${URL}" ] || URL=http://localhost:5001
|
39
|
-
|
40
|
-
# enable agent logging
|
41
|
-
export LOG_LEVEL=DEBUG
|
42
|
-
LOG_FILE="agent.log"
|
43
|
-
rm -f $LOG_FILE && touch $LOG_FILE
|
44
|
-
export LOG_FILE=`realpath $LOG_FILE`
|
45
|
-
|
46
|
-
# list mcp servers
|
47
|
-
${client} config -f --dev --server-url ${URL}
|
48
|
-
${client} server list
|
49
|
-
|
50
|
-
if [ -z ${NO_START} ] ; then
|
51
|
-
stop_server
|
52
|
-
# cat server.log
|
53
|
-
fi
|
54
|
-
|
55
|
-
set +e
|
56
|
-
set +x
|
57
|
-
|
58
|
-
echo "=============================="
|
59
|
-
echo "== MCP Agent TEST PASSED =="
|
60
|
-
echo "=============================="
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|