@dudamel/mcp-rooms 0.0.0-stage → 2026.1104.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/claude-process.d.ts +22 -0
- package/dist/claude-process.d.ts.map +1 -0
- package/dist/files.d.ts +21 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/format.d.ts +12 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/hook.d.ts +2 -0
- package/dist/hook.d.ts.map +1 -0
- package/dist/hook.js +106 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +757 -0
- package/dist/install-hook.d.ts +8 -0
- package/dist/install-hook.d.ts.map +1 -0
- package/dist/notify-socket.d.ts +26 -0
- package/dist/notify-socket.d.ts.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/session.d.ts +56 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/stdio-server.d.ts +3 -0
- package/dist/stdio-server.d.ts.map +1 -0
- package/dist/stdio-server.js +1002 -0
- package/dist/tools.d.ts +14 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +42 -3
- package/README.md +0 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code exports `CLAUDE_CODE_MESSAGING_SOCKET=<dir>/<pid>.sock` to every MCP server
|
|
3
|
+
* and hook it spawns. Undocumented, so it is only the first of several sources.
|
|
4
|
+
*/
|
|
5
|
+
export declare function claudePidFromEnv(env: NodeJS.ProcessEnv): number | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* The nearest ancestor (from `startPid` up, inclusive) whose command line is Claude Code.
|
|
8
|
+
* Covers `npx` launching the MCP (its parent is npm, not Claude) when the env var is
|
|
9
|
+
* missing. `ps` works on Linux and macOS alike.
|
|
10
|
+
*/
|
|
11
|
+
export declare function findClaudeAncestor(startPid: number, info?: (pid: number) => {
|
|
12
|
+
ppid: number;
|
|
13
|
+
args: string;
|
|
14
|
+
} | undefined): number | undefined;
|
|
15
|
+
/** The Claude Code process this one belongs to; the parent pid as a last resort. */
|
|
16
|
+
export declare function resolveClaudePid(env: NodeJS.ProcessEnv, startPid: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Where the MCP of a Claude Code process listens. A private runtime dir when the OS has
|
|
19
|
+
* one, else the temp dir (per-user on macOS); a named pipe on Windows.
|
|
20
|
+
*/
|
|
21
|
+
export declare function notifySocketPath(claudePid: number, env: NodeJS.ProcessEnv): string;
|
|
22
|
+
//# sourceMappingURL=claude-process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-process.d.ts","sourceRoot":"","sources":["../src/claude-process.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,GAAG,SAAS,CAI3E;AAmBD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAuB,GAC9E,MAAM,GAAG,SAAS,CASpB;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAGlF"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface OutgoingAttachment {
|
|
2
|
+
fileName: string;
|
|
3
|
+
mimeType: string;
|
|
4
|
+
contentBase64: string;
|
|
5
|
+
}
|
|
6
|
+
/** Read local files for send-message. Relative paths resolve against the project dir. */
|
|
7
|
+
export declare function readAttachments(paths: string[], cwd: string): Promise<OutgoingAttachment[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Download an attachment to `<downloadDir>/<roomId>/<attachmentId>-<name>` for the model to
|
|
10
|
+
* open with Read — more reliable than image blocks in a tool result. Already there: reused.
|
|
11
|
+
*/
|
|
12
|
+
export declare function downloadAttachment(opts: {
|
|
13
|
+
apiUrl: string;
|
|
14
|
+
authHeader: string;
|
|
15
|
+
downloadDir: string;
|
|
16
|
+
roomId: string;
|
|
17
|
+
memberId: string;
|
|
18
|
+
attachmentId: string;
|
|
19
|
+
fileName: string;
|
|
20
|
+
}): Promise<string>;
|
|
21
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAwBA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,yFAAyF;AACzF,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAqBjG;AAQD;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBlB"}
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Membership, RoomMessageWire, RoomWire } from './types.js';
|
|
2
|
+
/** Prepended to anything a teammate wrote, every time it reaches the model. */
|
|
3
|
+
export declare const UNTRUSTED_NOTE: string;
|
|
4
|
+
export declare function formatRoom(room: RoomWire, me: Membership): string;
|
|
5
|
+
export interface FormattedMessage {
|
|
6
|
+
message: RoomMessageWire;
|
|
7
|
+
/** Local paths of the downloaded attachments, by attachment id. */
|
|
8
|
+
files: Map<string, string>;
|
|
9
|
+
}
|
|
10
|
+
/** Messages grouped by thread, oldest first, each line saying who to whom. */
|
|
11
|
+
export declare function formatMessages(me: Membership, messages: FormattedMessage[]): string;
|
|
12
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAExE,+EAA+E;AAC/E,eAAO,MAAM,cAAc,QAG8B,CAAC;AAM1D,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,GAAG,MAAM,CAoBjE;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,eAAe,CAAC;IACzB,mEAAmE;IACnE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,CA+BnF"}
|
package/dist/hook.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../src/hook.ts"],"names":[],"mappings":""}
|
package/dist/hook.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// src/hook.ts
|
|
2
|
+
import net from "node:net";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
|
|
5
|
+
// src/claude-process.ts
|
|
6
|
+
import { execFileSync } from "node:child_process";
|
|
7
|
+
import os from "node:os";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
function claudePidFromEnv(env) {
|
|
10
|
+
const match = /(\d+)\.sock$/.exec(env["CLAUDE_CODE_MESSAGING_SOCKET"] ?? "");
|
|
11
|
+
const pid = match ? Number(match[1]) : NaN;
|
|
12
|
+
return Number.isInteger(pid) && pid > 1 ? pid : void 0;
|
|
13
|
+
}
|
|
14
|
+
var CLAUDE_COMMAND = /(^|[\s/\\])claude(\.exe)?(\s|$)|@anthropic-ai[/\\]claude-code/;
|
|
15
|
+
function processInfo(pid) {
|
|
16
|
+
try {
|
|
17
|
+
const out = execFileSync("ps", ["-o", "ppid=,args=", "-p", String(pid)], {
|
|
18
|
+
encoding: "utf8",
|
|
19
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
20
|
+
timeout: 1e3
|
|
21
|
+
}).trim();
|
|
22
|
+
const match = /^(\d+)\s+(.*)$/.exec(out);
|
|
23
|
+
return match ? { ppid: Number(match[1]), args: match[2] ?? "" } : void 0;
|
|
24
|
+
} catch {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function findClaudeAncestor(startPid, info = processInfo) {
|
|
29
|
+
let pid = startPid;
|
|
30
|
+
for (let depth = 0; depth < 10 && pid > 1; depth++) {
|
|
31
|
+
const current = info(pid);
|
|
32
|
+
if (!current) return void 0;
|
|
33
|
+
if (CLAUDE_COMMAND.test(current.args)) return pid;
|
|
34
|
+
pid = current.ppid;
|
|
35
|
+
}
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
function resolveClaudePid(env, startPid) {
|
|
39
|
+
return claudePidFromEnv(env) ?? findClaudeAncestor(startPid) ?? startPid;
|
|
40
|
+
}
|
|
41
|
+
function notifySocketPath(claudePid, env) {
|
|
42
|
+
if (process.platform === "win32") return `\\\\.\\pipe\\dudamel-rooms-${claudePid}`;
|
|
43
|
+
return path.join(notifySocketDir(env), `${claudePid}.sock`);
|
|
44
|
+
}
|
|
45
|
+
function notifySocketDir(env) {
|
|
46
|
+
return path.join(env["XDG_RUNTIME_DIR"] || os.tmpdir(), "dudamel-rooms");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/hook.ts
|
|
50
|
+
var PROMPT_TIMEOUT_MS = 4e3;
|
|
51
|
+
function readReply(socketPath, command, timeoutMs) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
let buffer = "";
|
|
54
|
+
let done = false;
|
|
55
|
+
const finish = (text) => {
|
|
56
|
+
if (done) return;
|
|
57
|
+
done = true;
|
|
58
|
+
conn.destroy();
|
|
59
|
+
resolve(text);
|
|
60
|
+
};
|
|
61
|
+
const conn = net.connect(socketPath, () => conn.write(`${command}
|
|
62
|
+
`));
|
|
63
|
+
conn.setEncoding("utf8");
|
|
64
|
+
conn.on("data", (chunk) => buffer += chunk);
|
|
65
|
+
conn.on("end", () => {
|
|
66
|
+
try {
|
|
67
|
+
const reply = JSON.parse(buffer);
|
|
68
|
+
finish(typeof reply.text === "string" ? reply.text : null);
|
|
69
|
+
} catch {
|
|
70
|
+
finish(null);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
conn.on("error", () => finish(null));
|
|
74
|
+
conn.on("close", () => finish(null));
|
|
75
|
+
if (timeoutMs) setTimeout(() => finish(null), timeoutMs).unref();
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async function main() {
|
|
79
|
+
const mode = process.argv[2];
|
|
80
|
+
process.stdin.resume();
|
|
81
|
+
process.stdin.on("data", () => void 0);
|
|
82
|
+
const socketPath = notifySocketPath(resolveClaudePid(process.env, process.pid), process.env);
|
|
83
|
+
if (process.platform !== "win32" && !fs.existsSync(socketPath)) return 0;
|
|
84
|
+
if (mode === "prompt") {
|
|
85
|
+
const text = await readReply(socketPath, "status", PROMPT_TIMEOUT_MS);
|
|
86
|
+
if (text) {
|
|
87
|
+
process.stdout.write(
|
|
88
|
+
JSON.stringify({
|
|
89
|
+
hookSpecificOutput: { hookEventName: "UserPromptSubmit", additionalContext: text }
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
if (mode === "watch") {
|
|
96
|
+
const text = await readReply(socketPath, "wait");
|
|
97
|
+
if (!text) return 0;
|
|
98
|
+
process.stderr.write(text);
|
|
99
|
+
return 2;
|
|
100
|
+
}
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
main().then(
|
|
104
|
+
(code) => process.exit(code),
|
|
105
|
+
() => process.exit(0)
|
|
106
|
+
);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|