devsh-memory-mcp 0.3.5 → 0.3.8
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 +20 -0
- package/dist/{chunk-MGYDYQOE.js → chunk-BKOJ5TNO.js} +37 -5
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -157,3 +157,23 @@ Logged items are reviewed by team leads and may be promoted to active orchestrat
|
|
|
157
157
|
- **P2 - Reference**: 30-day TTL. Temporary findings, debug notes.
|
|
158
158
|
|
|
159
159
|
Format: `- [YYYY-MM-DD] Your insight here`
|
|
160
|
+
|
|
161
|
+
## Development
|
|
162
|
+
|
|
163
|
+
### Running Tests
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
cd packages/devsh-memory-mcp
|
|
167
|
+
bun test
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Test Coverage
|
|
171
|
+
|
|
172
|
+
The package includes 81 unit tests covering:
|
|
173
|
+
|
|
174
|
+
- **JWT Helper** (5 tests): Token extraction, edge cases, UUID handling
|
|
175
|
+
- **Orchestration Tools** (24 tests): spawn_agent, get_agent_status, wait_for_agent schemas and URL construction
|
|
176
|
+
- **Memory Tools** (27 tests): Task/message structures, file paths, agent name validation
|
|
177
|
+
- **Learning Tools** (30 tests): log_learning, get_active_orchestration_rules, error handling
|
|
178
|
+
|
|
179
|
+
All tests run without external dependencies, suitable for CI environments
|
|
@@ -8,6 +8,20 @@ import {
|
|
|
8
8
|
import * as fs from "fs";
|
|
9
9
|
import * as path from "path";
|
|
10
10
|
import * as crypto from "crypto";
|
|
11
|
+
function extractTeamIdFromJwt(jwt) {
|
|
12
|
+
try {
|
|
13
|
+
const parts = jwt.split(".");
|
|
14
|
+
if (parts.length !== 3) return null;
|
|
15
|
+
let payload = parts[1];
|
|
16
|
+
const paddingNeeded = (4 - payload.length % 4) % 4;
|
|
17
|
+
payload = payload + "=".repeat(paddingNeeded);
|
|
18
|
+
const decoded = Buffer.from(payload, "base64").toString("utf8");
|
|
19
|
+
const data = JSON.parse(decoded);
|
|
20
|
+
return data.teamId ?? null;
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
11
25
|
var DEFAULT_MEMORY_DIR = "/root/lifecycle/memory";
|
|
12
26
|
function createMemoryMcpServer(config) {
|
|
13
27
|
const memoryDir = config?.memoryDir ?? DEFAULT_MEMORY_DIR;
|
|
@@ -1245,7 +1259,7 @@ function createMemoryMcpServer(config) {
|
|
|
1245
1259
|
case "get_agent_status": {
|
|
1246
1260
|
const { orchestrationTaskId } = args;
|
|
1247
1261
|
const jwt = process.env.CMUX_TASK_RUN_JWT;
|
|
1248
|
-
const
|
|
1262
|
+
const serverUrl = process.env.CMUX_SERVER_URL ?? "https://cmux-server.karldigi.dev";
|
|
1249
1263
|
if (!jwt) {
|
|
1250
1264
|
return {
|
|
1251
1265
|
content: [{
|
|
@@ -1254,12 +1268,21 @@ function createMemoryMcpServer(config) {
|
|
|
1254
1268
|
}]
|
|
1255
1269
|
};
|
|
1256
1270
|
}
|
|
1271
|
+
const teamId = extractTeamIdFromJwt(jwt);
|
|
1272
|
+
if (!teamId) {
|
|
1273
|
+
return {
|
|
1274
|
+
content: [{
|
|
1275
|
+
type: "text",
|
|
1276
|
+
text: "Failed to extract teamId from JWT token."
|
|
1277
|
+
}]
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1257
1280
|
try {
|
|
1258
|
-
const url = `${
|
|
1281
|
+
const url = `${serverUrl}/api/orchestrate/status/${orchestrationTaskId}?teamSlugOrId=${encodeURIComponent(teamId)}`;
|
|
1259
1282
|
const response = await fetch(url, {
|
|
1260
1283
|
method: "GET",
|
|
1261
1284
|
headers: {
|
|
1262
|
-
"
|
|
1285
|
+
"X-Task-Run-JWT": jwt,
|
|
1263
1286
|
"Content-Type": "application/json"
|
|
1264
1287
|
}
|
|
1265
1288
|
});
|
|
@@ -1292,7 +1315,7 @@ function createMemoryMcpServer(config) {
|
|
|
1292
1315
|
case "wait_for_agent": {
|
|
1293
1316
|
const { orchestrationTaskId, timeout = 3e5 } = args;
|
|
1294
1317
|
const jwt = process.env.CMUX_TASK_RUN_JWT;
|
|
1295
|
-
const
|
|
1318
|
+
const serverUrl = process.env.CMUX_SERVER_URL ?? "https://cmux-server.karldigi.dev";
|
|
1296
1319
|
if (!jwt) {
|
|
1297
1320
|
return {
|
|
1298
1321
|
content: [{
|
|
@@ -1301,11 +1324,20 @@ function createMemoryMcpServer(config) {
|
|
|
1301
1324
|
}]
|
|
1302
1325
|
};
|
|
1303
1326
|
}
|
|
1327
|
+
const teamId = extractTeamIdFromJwt(jwt);
|
|
1328
|
+
if (!teamId) {
|
|
1329
|
+
return {
|
|
1330
|
+
content: [{
|
|
1331
|
+
type: "text",
|
|
1332
|
+
text: "Failed to extract teamId from JWT token."
|
|
1333
|
+
}]
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1304
1336
|
const startTime = Date.now();
|
|
1305
1337
|
const pollInterval = 5e3;
|
|
1306
1338
|
try {
|
|
1307
1339
|
while (Date.now() - startTime < timeout) {
|
|
1308
|
-
const url = `${
|
|
1340
|
+
const url = `${serverUrl}/api/orchestrate/status/${orchestrationTaskId}?teamSlugOrId=${encodeURIComponent(teamId)}`;
|
|
1309
1341
|
const response = await fetch(url, {
|
|
1310
1342
|
method: "GET",
|
|
1311
1343
|
headers: {
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devsh-memory-mcp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"description": "MCP server for devsh/cmux agent memory - enables Claude Desktop and external clients to access sandbox memory and orchestrate multi-agent workflows",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|