@cotal-ai/connector-claude-code 0.85.0 → 0.86.0
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/.claude-plugin/plugin.json +1 -1
- package/dist/app-host.d.ts +16 -0
- package/dist/app-host.d.ts.map +1 -0
- package/dist/cli-record.d.ts +5 -0
- package/dist/cli-record.d.ts.map +1 -0
- package/dist/connection-owner.d.ts +5 -0
- package/dist/connection-owner.d.ts.map +1 -0
- package/dist/desktop-config.d.ts +15 -0
- package/dist/desktop-config.d.ts.map +1 -0
- package/dist/hook.cjs +213 -26685
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.js +270 -102
- package/dist/mcp.cjs +2038 -1349
- package/dist/mcp.d.ts.map +1 -1
- package/dist/monitor.cjs +97 -0
- package/dist/monitor.d.ts +2 -0
- package/dist/monitor.d.ts.map +1 -0
- package/dist/one-path.d.ts +17 -0
- package/dist/one-path.d.ts.map +1 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/wake-feed.d.ts +18 -0
- package/dist/wake-feed.d.ts.map +1 -0
- package/hooks/hooks.json +11 -0
- package/monitors/monitors.json +7 -0
- package/package.json +5 -4
package/dist/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAyHtD,yFAAyF;AACzF,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB;uDACmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;gFAC4E;IAC5E,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb;uDACmD;IACnD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;+BAE+B;AAC/B,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAQ3F"}
|
package/dist/monitor.cjs
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// src/monitor.ts
|
|
4
|
+
var import_node_net = require("node:net");
|
|
5
|
+
|
|
6
|
+
// ../../packages/core/dist/secret-fs.js
|
|
7
|
+
var isWin = process.platform === "win32";
|
|
8
|
+
|
|
9
|
+
// ../connector-core/dist/session-env.js
|
|
10
|
+
function hasIdentity(env = process.env) {
|
|
11
|
+
return Boolean(env.COTAL_NAME?.trim() || env.COTAL_LINK?.trim() || env.COTAL_AGENT_FILE?.trim());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ../connector-core/dist/control.js
|
|
15
|
+
var MAX_FRAME_BYTES = 1 << 20;
|
|
16
|
+
|
|
17
|
+
// src/wake-feed.ts
|
|
18
|
+
var import_node_fs = require("node:fs");
|
|
19
|
+
var import_node_os = require("node:os");
|
|
20
|
+
var import_node_path = require("node:path");
|
|
21
|
+
var WAKE_ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
22
|
+
var WIN_PIPES = "\\\\.\\pipe\\";
|
|
23
|
+
var WIN_PREFIX = "cotal-claude-wake-";
|
|
24
|
+
function wakeDir() {
|
|
25
|
+
if (process.platform === "win32") return WIN_PIPES;
|
|
26
|
+
const uid = process.getuid();
|
|
27
|
+
const dir = (0, import_node_path.join)((0, import_node_os.tmpdir)(), `cotal-claude-wake-${uid}`);
|
|
28
|
+
(0, import_node_fs.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
29
|
+
const st = (0, import_node_fs.lstatSync)(dir);
|
|
30
|
+
if (!st.isDirectory() || st.uid !== uid || (st.mode & 63) !== 0) throw new Error(`${dir} is not a private directory of this user's`);
|
|
31
|
+
return dir;
|
|
32
|
+
}
|
|
33
|
+
var entryName = (claudePid, serverPid) => process.platform === "win32" ? `${WIN_PREFIX}${claudePid}-${serverPid}` : `${claudePid}-${serverPid}.sock`;
|
|
34
|
+
var ENTRY = process.platform === "win32" ? new RegExp(`^${WIN_PREFIX}(\\d+)-(\\d+)$`) : /^(\d+)-(\d+)\.sock$/;
|
|
35
|
+
function alive(pid) {
|
|
36
|
+
try {
|
|
37
|
+
process.kill(pid, 0);
|
|
38
|
+
return true;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return e.code === "EPERM";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function wakeSocketPath(claudePid, serverPid = process.pid) {
|
|
44
|
+
const dir = wakeDir();
|
|
45
|
+
return process.platform === "win32" ? `${dir}${entryName(claudePid, serverPid)}` : (0, import_node_path.join)(dir, entryName(claudePid, serverPid));
|
|
46
|
+
}
|
|
47
|
+
function wakeSockets(claudePid) {
|
|
48
|
+
const dir = wakeDir();
|
|
49
|
+
return (0, import_node_fs.readdirSync)(dir).flatMap((name) => {
|
|
50
|
+
const m = ENTRY.exec(name);
|
|
51
|
+
return m?.[1] === String(claudePid) && alive(Number(m[2])) ? [wakeSocketPath(claudePid, Number(m[2]))] : [];
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/monitor.ts
|
|
56
|
+
var SCAN_MS = 1e3;
|
|
57
|
+
var wakeEvent = (id) => `Cotal: a new message for connection_id ${id}. Read it with cotal_inbox.`;
|
|
58
|
+
function main() {
|
|
59
|
+
if (hasIdentity()) return;
|
|
60
|
+
const claude = Number(process.env.CLAUDE_PID);
|
|
61
|
+
if (!Number.isInteger(claude) || claude <= 0) {
|
|
62
|
+
process.stderr.write("[cotal-monitor] no CLAUDE_PID, so this is not a Claude Code session\n");
|
|
63
|
+
process.exitCode = 1;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const reading = /* @__PURE__ */ new Set();
|
|
67
|
+
const read = (path) => {
|
|
68
|
+
reading.add(path);
|
|
69
|
+
let buf = "";
|
|
70
|
+
const s = (0, import_node_net.createConnection)(path);
|
|
71
|
+
s.setEncoding("utf8");
|
|
72
|
+
s.on("data", (d) => {
|
|
73
|
+
buf += d;
|
|
74
|
+
for (let i; (i = buf.indexOf("\n")) >= 0; ) {
|
|
75
|
+
const id = buf.slice(0, i);
|
|
76
|
+
buf = buf.slice(i + 1);
|
|
77
|
+
if (WAKE_ID.test(id)) process.stdout.write(`${wakeEvent(id)}
|
|
78
|
+
`);
|
|
79
|
+
}
|
|
80
|
+
if (buf.length > 256) s.destroy();
|
|
81
|
+
});
|
|
82
|
+
s.on("error", () => {
|
|
83
|
+
});
|
|
84
|
+
s.on("close", () => reading.delete(path));
|
|
85
|
+
};
|
|
86
|
+
const scan = () => {
|
|
87
|
+
try {
|
|
88
|
+
process.kill(claude, 0);
|
|
89
|
+
} catch {
|
|
90
|
+
process.exit(0);
|
|
91
|
+
}
|
|
92
|
+
for (const path of wakeSockets(claude)) if (!reading.has(path)) read(path);
|
|
93
|
+
};
|
|
94
|
+
scan();
|
|
95
|
+
setInterval(scan, SCAN_MS);
|
|
96
|
+
}
|
|
97
|
+
main();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../src/monitor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One Cotal path per Claude Code session.
|
|
3
|
+
*
|
|
4
|
+
* A session Cotal launched is on its mesh through this plugin's local server. Claude Code also loads
|
|
5
|
+
* connected-account connectors by default, so the same session can see a hosted Cotal connector and
|
|
6
|
+
* join a second time under another name. This hook answer refuses every Cotal tool of any server
|
|
7
|
+
* other than the local one, so the session keeps one identity. A plain session has no local path
|
|
8
|
+
* and keeps the hosted one.
|
|
9
|
+
*/
|
|
10
|
+
import type { LocalHookAnswer } from "@cotal-ai/connector-core/relay";
|
|
11
|
+
/** The tool's name on its server when `toolName` is a Cotal tool of a server other than the local
|
|
12
|
+
* one, else `undefined`. */
|
|
13
|
+
export declare function hostedCotalTool(toolName: unknown): string | undefined;
|
|
14
|
+
export declare const ONE_PATH_REASON: string;
|
|
15
|
+
/** Deny a call to another Cotal path's tool in a managed session, or `undefined` otherwise. */
|
|
16
|
+
export declare const otherCotalPath: LocalHookAnswer;
|
|
17
|
+
//# sourceMappingURL=one-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-path.d.ts","sourceRoot":"","sources":["../src/one-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAStE;6BAC6B;AAC7B,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAGrE;AAED,eAAO,MAAM,eAAe,QAG8B,CAAC;AAE3D,+FAA+F;AAC/F,eAAO,MAAM,cAAc,EAAE,eAW5B,CAAC"}
|
package/dist/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,sBAAsB,EAI5B,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,sBAAsB,EAI5B,MAAM,gBAAgB,CAAC;AA0JxB,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACnE,CAKA;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAK/D;AA4JD,eAAO,MAAM,mBAAmB,EAAE,sBAiGjC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A connection id the feed carries. Gateway ids are UUIDs, so anything else is not one. */
|
|
2
|
+
export declare const WAKE_ID: RegExp;
|
|
3
|
+
/** The socket server `serverPid` opens for the Claude Code process `claudePid`. */
|
|
4
|
+
export declare function wakeSocketPath(claudePid: number, serverPid?: number): string;
|
|
5
|
+
/** The feed sockets of the Claude Code process `claudePid` whose server is running, one per server. */
|
|
6
|
+
export declare function wakeSockets(claudePid: number): string[];
|
|
7
|
+
export interface WakeFeed {
|
|
8
|
+
/** Write `id` to every monitor reading the feed. False when none is. */
|
|
9
|
+
send(id: string): boolean;
|
|
10
|
+
/** Whether a monitor is reading the feed now. */
|
|
11
|
+
watched(): boolean;
|
|
12
|
+
/** Run `fn` each time a monitor starts reading. */
|
|
13
|
+
onReader(fn: () => void): void;
|
|
14
|
+
close(): void;
|
|
15
|
+
}
|
|
16
|
+
/** Serve this process's feed for the Claude Code process `claudePid`. */
|
|
17
|
+
export declare function openWakeFeed(claudePid: number): Promise<WakeFeed>;
|
|
18
|
+
//# sourceMappingURL=wake-feed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wake-feed.d.ts","sourceRoot":"","sources":["../src/wake-feed.ts"],"names":[],"mappings":"AAcA,4FAA4F;AAC5F,eAAO,MAAM,OAAO,QAA2B,CAAC;AA6BhD,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,GAAE,MAAoB,GAAG,MAAM,CAGzF;AAED,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAMvD;AAED,MAAM,WAAW,QAAQ;IACvB,wEAAwE;IACxE,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,iDAAiD;IACjD,OAAO,IAAI,OAAO,CAAC;IACnB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAC/B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,yEAAyE;AACzE,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAmCvE"}
|
package/hooks/hooks.json
CHANGED
|
@@ -30,6 +30,17 @@
|
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
|
+
"PostToolUse": [
|
|
34
|
+
{
|
|
35
|
+
"matcher": "^mcp__.+__cotal_(connect|disconnect)$",
|
|
36
|
+
"hooks": [
|
|
37
|
+
{
|
|
38
|
+
"type": "command",
|
|
39
|
+
"command": "node \"${CLAUDE_PLUGIN_ROOT}/dist/hook.cjs\""
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
33
44
|
"PostToolBatch": [
|
|
34
45
|
{
|
|
35
46
|
"hooks": [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cotal-ai/connector-claude-code",
|
|
3
3
|
"description": "Cotal connector for Claude Code: an installed plugin that joins a session to the mesh.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.86.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@cotal-ai/core": ">=0.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@cotal-ai/connector-core": "0.
|
|
29
|
-
"@cotal-ai/core": "0.
|
|
28
|
+
"@cotal-ai/connector-core": "0.86.0",
|
|
29
|
+
"@cotal-ai/core": "0.86.0",
|
|
30
30
|
"@cotal-ai/smoke-kit": "0.0.0",
|
|
31
31
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
32
32
|
"@nats-io/transport-node": "^3.4.0",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"dist",
|
|
38
38
|
".mcp.json",
|
|
39
39
|
"hooks",
|
|
40
|
+
"monitors",
|
|
40
41
|
".claude-plugin",
|
|
41
42
|
"skills-plugin"
|
|
42
43
|
],
|
|
@@ -47,6 +48,6 @@
|
|
|
47
48
|
"test": "tsx smoke/launch-env.smoke.ts",
|
|
48
49
|
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.smoke.json",
|
|
49
50
|
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json --emitDeclarationOnly && node -e \"require('node:fs').copyFileSync('dist/mcp.d.ts','dist/mcp.d.cts')\" && pnpm run bundle",
|
|
50
|
-
"bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js --external:@cotal-ai/core && esbuild src/mcp.ts --bundle --platform=node --format=cjs --target=node20 --outfile=dist/mcp.cjs --footer:js=\"module.exports = { serveClaudeSession: module.exports.serveClaudeSession };\" && esbuild src/hook.ts --bundle --platform=node --format=cjs --target=node20 --outfile=dist/hook.cjs"
|
|
51
|
+
"bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js --external:@cotal-ai/core && esbuild src/mcp.ts --bundle --platform=node --format=cjs --target=node20 --outfile=dist/mcp.cjs --footer:js=\"module.exports = { serveClaudeSession: module.exports.serveClaudeSession };\" && esbuild src/hook.ts --bundle --platform=node --format=cjs --target=node20 --outfile=dist/hook.cjs && esbuild src/monitor.ts --bundle --platform=node --format=cjs --target=node20 --outfile=dist/monitor.cjs"
|
|
51
52
|
}
|
|
52
53
|
}
|