@gonzih/cc-discord 0.2.2 → 0.2.4
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/meta-agent-manager.js +46 -16
- package/dist/notifier.js +13 -2
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 4. spawnSession: claude --continue -p "{message}" pipes stdout → wire.discord.publishOutgoing
|
|
9
9
|
*/
|
|
10
10
|
import { spawn, execSync } from "child_process";
|
|
11
|
-
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
12
12
|
import { join } from "path";
|
|
13
13
|
import { homedir } from "os";
|
|
14
14
|
import { CC_DISCORD_WORKSPACE_ROOT, TIMING, discordMetaInputKey, } from "@gonzih/cc-wire";
|
|
@@ -59,25 +59,55 @@ export function injectMcp(ns, wsPath, token) {
|
|
|
59
59
|
const npmCache = process.env.npm_config_cache ?? `${homedir()}/.npm`;
|
|
60
60
|
const trustedOwners = process.env.CC_AGENT_TRUSTED_OWNERS ?? "";
|
|
61
61
|
const systemPath = process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin";
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
npm_config_cache: npmCache,
|
|
75
|
-
},
|
|
62
|
+
const servers = {
|
|
63
|
+
"cc-agent": {
|
|
64
|
+
command: "/opt/homebrew/bin/npx",
|
|
65
|
+
args: ["-y", "--prefer-online", "@gonzih/cc-agent"],
|
|
66
|
+
env: {
|
|
67
|
+
CC_AGENT_NAMESPACE: ns,
|
|
68
|
+
CWD: wsPath,
|
|
69
|
+
CLAUDE_CODE_OAUTH_TOKEN: token,
|
|
70
|
+
CLAUDE_TOKENS: token,
|
|
71
|
+
CC_AGENT_TRUSTED_OWNERS: trustedOwners,
|
|
72
|
+
PATH: systemPath,
|
|
73
|
+
npm_config_cache: npmCache,
|
|
76
74
|
},
|
|
77
75
|
},
|
|
78
76
|
};
|
|
77
|
+
// Merge extra MCP servers from ~/.config/cc-discord-mcp.json (credentials file, not in source)
|
|
78
|
+
const extraMcpPath = join(homedir(), ".config", "cc-discord-mcp.json");
|
|
79
|
+
if (existsSync(extraMcpPath)) {
|
|
80
|
+
try {
|
|
81
|
+
const extra = JSON.parse(readFileSync(extraMcpPath, "utf8"));
|
|
82
|
+
Object.assign(servers, extra);
|
|
83
|
+
console.log(`[meta-agent-manager] merged extra MCP servers from ${extraMcpPath}: ${Object.keys(extra).join(", ")}`);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
87
|
+
console.warn(`[meta-agent-manager] failed to read extra MCP config: ${msg}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Also check env vars as fallback for gmail and github
|
|
91
|
+
const gmailEmail = process.env.GMAIL_EMAIL;
|
|
92
|
+
const gmailPass = process.env.GMAIL_APP_PASSWORD;
|
|
93
|
+
if (gmailEmail && gmailPass && !servers["gmail-personal"]) {
|
|
94
|
+
servers["gmail-personal"] = {
|
|
95
|
+
command: "/opt/homebrew/bin/npx",
|
|
96
|
+
args: ["-y", "gmail-mcp-imap"],
|
|
97
|
+
env: { GMAIL_EMAIL: gmailEmail, GMAIL_APP_PASSWORD: gmailPass, npm_config_cache: npmCache },
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const ghToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
|
|
101
|
+
if (ghToken && !servers["github"]) {
|
|
102
|
+
servers["github"] = {
|
|
103
|
+
command: "docker",
|
|
104
|
+
args: ["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"],
|
|
105
|
+
env: { GITHUB_PERSONAL_ACCESS_TOKEN: ghToken },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const config = { mcpServers: servers };
|
|
79
109
|
writeFileSync(mcpPath, JSON.stringify(config, null, 2), "utf8");
|
|
80
|
-
console.log(`[meta-agent-manager] injected MCP config for namespace=${ns}`);
|
|
110
|
+
console.log(`[meta-agent-manager] injected MCP config for namespace=${ns} (servers: ${Object.keys(servers).join(", ")})`);
|
|
81
111
|
}
|
|
82
112
|
/**
|
|
83
113
|
* Resolve claude binary — same logic as claude.ts resolveClaude.
|
package/dist/notifier.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* cca:discord:chat:log:{ns} — LPUSH + LTRIM 0 499 (last 500 messages)
|
|
11
11
|
* cca:discord:chat:outgoing:{ns} — PUBLISH for web UI to consume
|
|
12
12
|
*/
|
|
13
|
-
import { discordChatLog, discordChatOutgoing, discordNotify, chatIncomingChannel, createCcWire, TIMING, } from "@gonzih/cc-wire";
|
|
13
|
+
import { discordChatLog, discordChatOutgoing, discordNotify, notifyChannel, chatIncomingChannel, createCcWire, TIMING, } from "@gonzih/cc-wire";
|
|
14
14
|
import { existsSync, statSync } from "fs";
|
|
15
15
|
import { splitLongMessage, stripAnsi } from "./formatter.js";
|
|
16
16
|
const SAFE_DIRS = ["/tmp/", "/var/folders/"];
|
|
@@ -152,9 +152,11 @@ export function startNotifier(bot, notifyChannelId, namespace, redis, handleUser
|
|
|
152
152
|
if (subscribedNamespaces.has(ns))
|
|
153
153
|
return;
|
|
154
154
|
subscribedNamespaces.add(ns);
|
|
155
|
-
const notifyCh = discordNotify(ns);
|
|
155
|
+
const notifyCh = discordNotify(ns); // cca:discord:notify:{ns} — new cc-wire path
|
|
156
|
+
const legacyNotifyCh = notifyChannel(ns); // cca:notify:{ns} — cc-agent still publishes here
|
|
156
157
|
const incomingCh = chatIncomingChannel(ns);
|
|
157
158
|
channelToNamespace.set(notifyCh, ns);
|
|
159
|
+
channelToNamespace.set(legacyNotifyCh, ns);
|
|
158
160
|
channelToNamespace.set(incomingCh, ns);
|
|
159
161
|
sub.subscribe(notifyCh, (err) => {
|
|
160
162
|
if (err) {
|
|
@@ -164,6 +166,15 @@ export function startNotifier(bot, notifyChannelId, namespace, redis, handleUser
|
|
|
164
166
|
log("info", `subscribed to ${notifyCh}`);
|
|
165
167
|
}
|
|
166
168
|
});
|
|
169
|
+
// Also subscribe to legacy cc-agent notification channel
|
|
170
|
+
sub.subscribe(legacyNotifyCh, (err) => {
|
|
171
|
+
if (err) {
|
|
172
|
+
log("error", `subscribe ${legacyNotifyCh} failed:`, err.message);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
log("info", `subscribed to ${legacyNotifyCh} (legacy cc-agent)`);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
167
178
|
sub.subscribe(incomingCh, (err) => {
|
|
168
179
|
if (err) {
|
|
169
180
|
log("error", `subscribe ${incomingCh} failed:`, err.message);
|