@gonzih/cc-discord 0.2.48 → 0.2.49
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/bot.d.ts +20 -11
- package/dist/bot.js +328 -74
- package/dist/index.d.ts +9 -5
- package/dist/index.js +17 -10
- package/dist/meta-agent-manager.d.ts +2 -2
- package/dist/meta-agent-manager.js +565 -79
- package/dist/notifier.d.ts +2 -2
- package/dist/notifier.js +80 -55
- package/dist/tokens.d.ts +1 -1
- package/dist/tokens.js +1 -1
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* cc-discord — Claude Code
|
|
3
|
+
* cc-discord — Discord bot for Claude Code or Codex routed agents
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
6
|
* npx @gonzih/cc-discord
|
|
7
7
|
*
|
|
8
8
|
* Required env:
|
|
9
9
|
* DISCORD_BOT_TOKEN — from Discord Developer Portal
|
|
10
|
-
* CLAUDE_CODE_OAUTH_TOKEN —
|
|
10
|
+
* CLAUDE_CODE_OAUTH_TOKEN — Claude Code OAuth token (or ANTHROPIC_API_KEY) when using Claude
|
|
11
|
+
* CODEX_API_KEY — optional Codex API key when using Codex automation
|
|
11
12
|
*
|
|
12
13
|
* Optional env:
|
|
13
14
|
* DISCORD_GUILD_IDS — comma-separated Discord guild/server IDs (for instant slash command registration)
|
|
14
15
|
* DISCORD_ALLOWED_USER_IDS — comma-separated Discord user IDs to whitelist (leave empty to allow all)
|
|
15
16
|
* DISCORD_NOTIFY_CHANNEL_ID — Discord channel ID for job notifications
|
|
16
|
-
*
|
|
17
|
+
* CC_DISCORD_NAMESPACE — primary namespace (default: money-brain)
|
|
17
18
|
* REDIS_URL — Redis connection URL (default: redis://localhost:6379)
|
|
18
|
-
* CWD — working directory for
|
|
19
|
+
* CWD — working directory for local sessions (default: process.cwd())
|
|
19
20
|
* DEFAULT_GITHUB_ORG — default GitHub org for #repo routing (default: gonzih)
|
|
20
|
-
*
|
|
21
|
+
* CC_DISCORD_AGENT_DRIVER — claude (default) or codex for routed meta-agents
|
|
22
|
+
* ATC_BIN — optional, override ATC binary path
|
|
23
|
+
* ATC_ROOT — optional, ATC data directory
|
|
24
|
+
* CC_DISCORD_MCP_JSON — JSON template for .mcp.json injection into workspaces
|
|
21
25
|
*/
|
|
22
26
|
import { createRequire } from "node:module";
|
|
23
27
|
import { randomUUID } from "crypto";
|
|
@@ -47,10 +51,11 @@ Set them and run again:
|
|
|
47
51
|
return val;
|
|
48
52
|
}
|
|
49
53
|
const discordToken = required("DISCORD_BOT_TOKEN");
|
|
54
|
+
const agentDriver = (process.env.CC_DISCORD_AGENT_DRIVER ?? process.env.AGENT_DRIVER ?? "claude").toLowerCase();
|
|
50
55
|
const claudeToken = process.env.CLAUDE_CODE_TOKEN ??
|
|
51
56
|
process.env.CLAUDE_CODE_OAUTH_TOKEN ??
|
|
52
57
|
process.env.ANTHROPIC_API_KEY;
|
|
53
|
-
if (!claudeToken) {
|
|
58
|
+
if (agentDriver !== "codex" && !claudeToken) {
|
|
54
59
|
console.error(`
|
|
55
60
|
ERROR: No Claude token set. Set one of: CLAUDE_CODE_TOKEN, CLAUDE_CODE_OAUTH_TOKEN, or ANTHROPIC_API_KEY.
|
|
56
61
|
`);
|
|
@@ -69,7 +74,7 @@ const allowedUserIds = process.env.DISCORD_ALLOWED_USER_IDS
|
|
|
69
74
|
: [];
|
|
70
75
|
const cwd = process.env.CWD ?? process.cwd();
|
|
71
76
|
const redisUrl = process.env.REDIS_URL || "redis://localhost:6379";
|
|
72
|
-
const namespace = process.env.
|
|
77
|
+
const namespace = process.env.CC_DISCORD_NAMESPACE || "money-brain";
|
|
73
78
|
const notifyChannelId = process.env.DISCORD_NOTIFY_CHANNEL_ID ?? null;
|
|
74
79
|
// Redis
|
|
75
80
|
const sharedRedis = new Redis(redisUrl);
|
|
@@ -100,9 +105,11 @@ sharedRedis.once("ready", () => {
|
|
|
100
105
|
});
|
|
101
106
|
}, INSTANCE_REFRESH_MS);
|
|
102
107
|
// Store master token so MetaAgentManager can retrieve it
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
if (claudeToken) {
|
|
109
|
+
wire.token.setMaster(claudeToken).catch((err) => {
|
|
110
|
+
console.warn("[cc-discord] failed to set master token:", err.message);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
106
113
|
// Run startup migrations (async, best-effort)
|
|
107
114
|
void runStartupMigrations();
|
|
108
115
|
});
|
|
@@ -29,7 +29,7 @@ export declare function ensureWorkspace(ns: string, repoUrl: string): Promise<vo
|
|
|
29
29
|
*
|
|
30
30
|
* Template priority:
|
|
31
31
|
* 1. CC_DISCORD_MCP_JSON env var (full JSON string) — operator-supplied override
|
|
32
|
-
* 2. Built-in template:
|
|
32
|
+
* 2. Built-in template: gitkb MCP plus ATC shell environment
|
|
33
33
|
*
|
|
34
34
|
* Variables substituted in the template: {namespace}, {workspacePath}, {token},
|
|
35
35
|
* {npmCache}, {trustedOwners}, {path}.
|
|
@@ -67,7 +67,7 @@ export interface MetaAgentManager {
|
|
|
67
67
|
}
|
|
68
68
|
export declare function createMetaAgentManager(): MetaAgentManager;
|
|
69
69
|
/**
|
|
70
|
-
* Migrate the old
|
|
70
|
+
* Migrate the old meta input key to the new cc-discord key.
|
|
71
71
|
* Old: cca:meta:{ns}:input → New: cca:discord:meta:{ns}:input
|
|
72
72
|
*
|
|
73
73
|
* Called once on startup.
|