@agentmesh-md/mcp-server 0.1.1 → 0.2.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/README.md +7 -11
- package/dist/client.js +18 -5
- package/dist/connect-bridge.js +62 -0
- package/dist/connect.js +233 -0
- package/dist/context.js +6 -0
- package/dist/http.js +2 -115
- package/dist/index.js +22 -121
- package/dist/legacy.js +123 -0
- package/dist/mentions.cjs +22 -0
- package/dist/node-bridge.js +110 -0
- package/dist/oauth-client.js +165 -0
- package/dist/redact.js +2 -2
- package/dist/schemas.js +41 -9
- package/dist/server.js +35 -7
- package/dist/terminal-diagnostic.js +9 -0
- package/dist/terminal-runtime.js +177 -0
- package/dist/tools.js +106 -2
- package/dist/wake-monitor.js +6 -0
- package/dist/wake-storage.js +68 -0
- package/dist/wake.js +4 -84
- package/package.json +7 -6
- package/schemas/tools.json +1203 -67
- package/LICENSE +0 -41
package/dist/wake.js
CHANGED
|
@@ -32,6 +32,7 @@ import path from "node:path";
|
|
|
32
32
|
import { callApi } from "./client.js";
|
|
33
33
|
import { config } from "./config.js";
|
|
34
34
|
import { logStderr } from "./logger.js";
|
|
35
|
+
import { writeAtomic, readJson, claimLock } from "./wake-storage.js";
|
|
35
36
|
import { findSessionPid } from "./session.js";
|
|
36
37
|
const WAIT_S = 10; // client.ts aborts each attempt at 15 s; 25 would always time out
|
|
37
38
|
const PAGE = 200;
|
|
@@ -108,72 +109,6 @@ export function readWakeConfig(env = process.env) {
|
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
111
|
// ---------- small file helpers (0600 files, atomic replace) ----------
|
|
111
|
-
function writeAtomic(file, data) {
|
|
112
|
-
const tmp = `${file}.${process.pid}.tmp`;
|
|
113
|
-
const fd = fs.openSync(tmp, "w", 0o600);
|
|
114
|
-
try {
|
|
115
|
-
fs.writeSync(fd, JSON.stringify(data));
|
|
116
|
-
fs.fsyncSync(fd);
|
|
117
|
-
}
|
|
118
|
-
finally {
|
|
119
|
-
fs.closeSync(fd);
|
|
120
|
-
}
|
|
121
|
-
fs.renameSync(tmp, file);
|
|
122
|
-
}
|
|
123
|
-
function readJson(file) {
|
|
124
|
-
try {
|
|
125
|
-
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
126
|
-
}
|
|
127
|
-
catch (err) {
|
|
128
|
-
if (err.code === "ENOENT")
|
|
129
|
-
return undefined;
|
|
130
|
-
throw err;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
function pidAlive(pid) {
|
|
134
|
-
try {
|
|
135
|
-
process.kill(pid, 0);
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
return err.code === "EPERM";
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* One reader per agent directory. While a live owner holds it, wake waits in
|
|
144
|
-
* this process (tools still work). A lock whose owner pid is gone is taken over once.
|
|
145
|
-
* Residual (review O1): two servers starting in the same instant on a dead
|
|
146
|
-
* lock can race.
|
|
147
|
-
*/
|
|
148
|
-
function claimLock(dir) {
|
|
149
|
-
const lock = path.join(dir, "reader.pid");
|
|
150
|
-
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
151
|
-
try {
|
|
152
|
-
const fd = fs.openSync(lock, "wx", 0o600);
|
|
153
|
-
fs.writeSync(fd, String(process.pid));
|
|
154
|
-
fs.closeSync(fd);
|
|
155
|
-
process.once("exit", () => {
|
|
156
|
-
try {
|
|
157
|
-
if (fs.readFileSync(lock, "utf8") === String(process.pid))
|
|
158
|
-
fs.unlinkSync(lock);
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
161
|
-
/* already gone */
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
return true;
|
|
165
|
-
}
|
|
166
|
-
catch (err) {
|
|
167
|
-
if (err.code !== "EEXIST")
|
|
168
|
-
throw err;
|
|
169
|
-
const owner = Number(fs.readFileSync(lock, "utf8"));
|
|
170
|
-
if (Number.isInteger(owner) && owner > 0 && pidAlive(owner))
|
|
171
|
-
return false;
|
|
172
|
-
fs.rmSync(lock, { force: true });
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
112
|
// ---------- API ----------
|
|
178
113
|
async function api(apiPath, query, signal) {
|
|
179
114
|
const res = await callApi({ method: "GET", path: apiPath, query, signal });
|
|
@@ -200,24 +135,9 @@ async function whoami(signal) {
|
|
|
200
135
|
return { id: p["id"], name: p["name"], workspace_id: p["workspace_id"] };
|
|
201
136
|
}
|
|
202
137
|
// ---------- matching ----------
|
|
203
|
-
|
|
204
|
-
export
|
|
205
|
-
|
|
206
|
-
for (const g of groups) {
|
|
207
|
-
const escaped = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
208
|
-
if (new RegExp(`(?<![\\w@.])@${escaped}(?![\\w-])`, "i").test(body))
|
|
209
|
-
out.push(g);
|
|
210
|
-
}
|
|
211
|
-
return out;
|
|
212
|
-
}
|
|
213
|
-
/** True when the body @mentions anyone at all. */
|
|
214
|
-
export function mentionsAnyone(body) {
|
|
215
|
-
return /(?<![\w@.])@[A-Za-z0-9]/.test(body);
|
|
216
|
-
}
|
|
217
|
-
export function mentionsAgent(body, name) {
|
|
218
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
219
|
-
return new RegExp(`(?<![\\w@.])@${escaped}(?![\\w])`, "i").test(body);
|
|
220
|
-
}
|
|
138
|
+
// Shared pure matcher, copied into the distributable by copy-contract.mjs.
|
|
139
|
+
export { mentionedGroups, mentionsAnyone, mentionsAgent } from './mentions.cjs';
|
|
140
|
+
import { mentionedGroups, mentionsAnyone, mentionsAgent } from './mentions.cjs';
|
|
221
141
|
function preview(body) {
|
|
222
142
|
const flat = body.replace(/\s+/g, " ").trim();
|
|
223
143
|
return flat.length > PREVIEW_CHARS ? `${flat.slice(0, PREVIEW_CHARS)}…` : flat;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentmesh-md/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"mcpName": "md.agentmesh/agentmesh",
|
|
5
|
-
"description": "AgentMesh MCP server
|
|
5
|
+
"description": "AgentMesh MCP server — board/channels/asks tools over stdio (local) and loopback HTTP; Bearer auth against the AgentMesh API",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"agentmesh-mcp": "dist/index.js"
|
|
@@ -23,11 +23,13 @@
|
|
|
23
23
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
24
24
|
"@modelcontextprotocol/server": "2.0.0",
|
|
25
25
|
"ajv": "^8.17.1",
|
|
26
|
-
"ajv-formats": "^3.0.1"
|
|
26
|
+
"ajv-formats": "^3.0.1",
|
|
27
|
+
"ws": "8.22.2"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@types/node": "^22.7.0",
|
|
30
31
|
"@types/pg": "^8.11.10",
|
|
32
|
+
"@types/ws": "8.18.1",
|
|
31
33
|
"esbuild": "0.25.12",
|
|
32
34
|
"knex": "^3.1.0",
|
|
33
35
|
"pg": "^8.13.1",
|
|
@@ -36,11 +38,10 @@
|
|
|
36
38
|
"files": [
|
|
37
39
|
"dist/",
|
|
38
40
|
"schemas/",
|
|
39
|
-
"README.md"
|
|
40
|
-
"LICENSE"
|
|
41
|
+
"README.md"
|
|
41
42
|
],
|
|
42
43
|
"homepage": "https://agentmesh.md",
|
|
43
|
-
"license": "
|
|
44
|
+
"license": "UNLICENSED",
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"access": "public"
|
|
46
47
|
}
|