ccgateway 0.2.2 → 0.3.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/README.md +122 -176
- package/dist/async-watcher.d.ts +6 -0
- package/dist/async-watcher.d.ts.map +1 -1
- package/dist/async-watcher.js +32 -0
- package/dist/async-watcher.js.map +1 -1
- package/dist/cli.js +28 -87
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +5 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -2
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +11 -1
- package/dist/context.js.map +1 -1
- package/dist/messaging.d.ts.map +1 -1
- package/dist/messaging.js +12 -0
- package/dist/messaging.js.map +1 -1
- package/dist/migrate.d.ts +9 -0
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +64 -40
- package/dist/migrate.js.map +1 -1
- package/dist/plugin.d.ts +5 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugins/discord-gateway.d.ts.map +1 -1
- package/dist/plugins/discord-gateway.js +168 -88
- package/dist/plugins/discord-gateway.js.map +1 -1
- package/dist/plugins/slack-gateway.d.ts.map +1 -1
- package/dist/plugins/slack-gateway.js +36 -0
- package/dist/plugins/slack-gateway.js.map +1 -1
- package/dist/router.d.ts +10 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +41 -8
- package/dist/router.js.map +1 -1
- package/dist/spawner.d.ts +16 -0
- package/dist/spawner.d.ts.map +1 -1
- package/dist/spawner.js +109 -4
- package/dist/spawner.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
- package/skills/talk/SKILL.md +53 -0
package/README.md
CHANGED
|
@@ -2,244 +2,175 @@
|
|
|
2
2
|
<img src="assets/logo.jpg" alt="ccgateway logo" width="600" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
# ccgateway
|
|
5
|
+
# ccgateway
|
|
6
6
|
|
|
7
|
-
**
|
|
7
|
+
**An orchestration agent for Claude Code.**
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
ccgateway is a single Node.js process that orchestrates multiple Claude Code agents — routing messages between Discord, Slack, and the CLI, assembling context per turn, spawning long-running tasks into tmux, and letting agents talk to each other. No API keys, no third-party harness, no persistent agent processes. Just `claude --print` invoked with the right context, in the right workspace, at the right moment.
|
|
10
|
+
|
|
11
|
+
## Why orchestration?
|
|
12
|
+
|
|
13
|
+
Claude Code is stateless — great at one turn at a time in one directory. ccgateway is the layer above it: it decides *which* agent should answer, *where* that agent lives, *what* context it needs, and *how* to fan work out across async tasks and other agents.
|
|
14
|
+
|
|
15
|
+
- **Route** — Discord/Slack/CLI messages → the right agent based on channel bindings
|
|
16
|
+
- **Assemble** — Identity files + conversation history + skills + memory → one `--append-system-prompt` payload
|
|
17
|
+
- **Persist** — JSONL sessions per agent-per-channel, never expire, context-windowed automatically
|
|
18
|
+
- **Spawn** — Long-running work dispatched to detached tmux sessions you can attach to live
|
|
19
|
+
- **Coordinate** — Agents message each other through their own channels, with their own avatars
|
|
20
|
+
- **Extend** — Gateways are plugins; implement one interface to add Telegram, WhatsApp, or anything else
|
|
21
|
+
|
|
22
|
+
Every AI invocation is a fresh `claude --print`. No memory leaks, trivial crash recovery, and you can change models per turn. Concurrency is bounded only by your Claude Code subscription.
|
|
10
23
|
|
|
11
24
|
## Quick Start
|
|
12
25
|
|
|
13
26
|
```bash
|
|
14
|
-
# Install
|
|
15
27
|
npm install -g ccgateway
|
|
16
|
-
|
|
17
|
-
# New setup
|
|
18
28
|
ccg init
|
|
19
29
|
|
|
20
|
-
#
|
|
21
|
-
ccg migrate openclaw
|
|
22
|
-
|
|
23
|
-
# Add your bot tokens to ~/.ccgateway/.env
|
|
30
|
+
# Add bot tokens to ~/.ccgateway/.env
|
|
24
31
|
# DISCORD_SALT_TOKEN=...
|
|
25
32
|
# SLACK_PEPPER_TOKEN=...
|
|
26
33
|
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# Or run in foreground
|
|
31
|
-
source ~/.ccgateway/.env && ccg start
|
|
34
|
+
ccg install # systemd user service (recommended)
|
|
35
|
+
# or
|
|
36
|
+
source ~/.ccgateway/.env && ccg start # foreground
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
|
|
39
|
+
See [Installation](docs/getting-started/installation.md) and [Quick Start](docs/getting-started/quick-start.md) for the full walkthrough.
|
|
40
|
+
|
|
41
|
+
### Service management
|
|
35
42
|
|
|
36
43
|
```bash
|
|
37
|
-
ccg install
|
|
38
|
-
ccg uninstall
|
|
44
|
+
ccg install # install + start as systemd user service
|
|
45
|
+
ccg uninstall # stop + remove
|
|
39
46
|
|
|
40
|
-
# Standard systemd commands also work:
|
|
41
47
|
systemctl --user status ccgateway
|
|
42
48
|
systemctl --user restart ccgateway
|
|
43
49
|
journalctl --user -u ccgateway -f
|
|
44
50
|
```
|
|
45
51
|
|
|
46
|
-
`
|
|
47
|
-
|
|
48
|
-
## Why ccgateway over OpenClaw?
|
|
52
|
+
`loginctl enable-linger $USER` keeps the service alive after logout.
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
## How it works
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
```
|
|
57
|
+
┌──────────────────────────────────────────────┐
|
|
58
|
+
│ ccgateway (single process) │
|
|
59
|
+
│ │
|
|
60
|
+
│ ┌─────────┐ ┌─────────┐ ┌─────────────┐ │
|
|
61
|
+
│ │ Discord │ │ Slack │ │ Future │ │
|
|
62
|
+
│ │ Plugin │ │ Plugin │ │ Plugins │ │
|
|
63
|
+
│ └────┬────┘ └────┬────┘ └──────┬──────┘ │
|
|
64
|
+
│ └────────────┼──────────────┘ │
|
|
65
|
+
│ ↓ │
|
|
66
|
+
│ ┌──────────────┐ │
|
|
67
|
+
│ │ Router │ │
|
|
68
|
+
│ │ (bindings) │ │
|
|
69
|
+
│ └──────┬───────┘ │
|
|
70
|
+
│ ↓ │
|
|
71
|
+
│ ┌───────────────┐ │
|
|
72
|
+
│ │ Session Mgr │ │
|
|
73
|
+
│ │ (JSONL state) │ │
|
|
74
|
+
│ └───────┬───────┘ │
|
|
75
|
+
│ ↓ │
|
|
76
|
+
│ ┌─────────────────┐ │
|
|
77
|
+
│ │ Context Builder │ │
|
|
78
|
+
│ │ identity+history│ │
|
|
79
|
+
│ │ +skills+memory │ │
|
|
80
|
+
│ └────────┬────────┘ │
|
|
81
|
+
│ ↓ │
|
|
82
|
+
│ ┌─────────────────┐ │
|
|
83
|
+
│ │ claude --print │ │
|
|
84
|
+
│ └─────────────────┘ │
|
|
85
|
+
└──────────────────────────────────────────────┘
|
|
56
86
|
```
|
|
57
87
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### How is this different?
|
|
61
|
-
|
|
62
|
-
ccgateway doesn't proxy, wrap, or intercept Claude Code sessions. Every agent invocation is a direct call to `claude --print` — the same CLI binary you run in your terminal, using your Claude Code subscription. ccgateway just manages the plumbing: who talks where, what context gets injected, and where conversation history lives.
|
|
63
|
-
|
|
64
|
-
## Comparison
|
|
65
|
-
|
|
66
|
-
| Feature | OpenClaw | ccgateway |
|
|
67
|
-
|---|---|---|
|
|
68
|
-
| Anthropic will hunt you? | No | **Yes** |
|
|
69
|
-
| Uses CC subscription (no API billing) | No | **Yes** |
|
|
70
|
-
| Multi-agent identities | Yes | Yes |
|
|
71
|
-
| Discord gateway | Yes | Yes |
|
|
72
|
-
| Slack gateway | Yes | Yes |
|
|
73
|
-
| Session persistence | Yes | Yes |
|
|
74
|
-
| Cross-agent messaging | Yes | Yes |
|
|
75
|
-
| Memory system | Yes | Yes |
|
|
76
|
-
| Skills system | Yes | Yes |
|
|
77
|
-
| Heartbeats / cron | Yes | Yes |
|
|
78
|
-
| Telegram / WhatsApp | Yes | Roadmap |
|
|
79
|
-
| Browser Tools | Yes | Roadmap |
|
|
80
|
-
| Migration from OpenClaw | — | **One command** |
|
|
88
|
+
For each turn: a plugin receives a message → router matches channel to agent → session manager loads the JSONL → an optional Haiku triage call decides sync-vs-async → context builder assembles the system prompt → `claude --print` runs in the agent's workspace → response is appended to the session and posted back. Full lifecycle in [Architecture](docs/concepts/architecture.md).
|
|
81
89
|
|
|
82
|
-
##
|
|
90
|
+
## Capabilities
|
|
83
91
|
|
|
84
|
-
### Multi-
|
|
92
|
+
### Multi-agent identities
|
|
85
93
|
|
|
86
|
-
Each agent
|
|
94
|
+
Each agent is a workspace directory with its own identity files. ccgateway points Claude Code at the right workspace — identity lives in your files, not in ccgateway config.
|
|
87
95
|
|
|
88
96
|
```bash
|
|
89
97
|
ccg agents add --id salt --name Salt --workspace ~/clawd-salt --model claude-opus-4-6 --emoji "🧂"
|
|
90
98
|
ccg agents list
|
|
91
99
|
```
|
|
92
100
|
|
|
93
|
-
|
|
101
|
+
Claude Code reads `CLAUDE.md` automatically. ccgateway also injects `SOUL.md`, `IDENTITY.md`, `AGENTS.md`, plus today's and yesterday's daily logs. More in [Agents](docs/concepts/agents.md).
|
|
94
102
|
|
|
103
|
+
### Discord & Slack gateways
|
|
95
104
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
# Preview what gets imported
|
|
100
|
-
ccg migrate openclaw --dry-run
|
|
101
|
-
|
|
102
|
-
# Run the migration
|
|
103
|
-
ccg migrate openclaw
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### What gets migrated
|
|
107
|
-
|
|
108
|
-
- **Agents** — IDs, names, emojis, workspaces, model preferences
|
|
109
|
-
- **Channel bindings** — All Discord channel-to-agent mappings (from both `bindings[]` and guild channel configs)
|
|
110
|
-
- **Bot tokens** — Written to `~/.ccgateway/.env` with actual values from your OpenClaw config
|
|
111
|
-
- **Heartbeats** — Cron schedules converted from OpenClaw's job format
|
|
112
|
-
- **Discord gateway plugin** — Auto-configured with your bots, guild, and allowed users
|
|
113
|
-
|
|
114
|
-
### What stays as-is
|
|
115
|
-
|
|
116
|
-
- Agent workspaces (`CLAUDE.md`, `SOUL.md`, `MEMORY.md`, `memory/`) — untouched
|
|
117
|
-
- Git repositories, worktrees, project files — untouched
|
|
118
|
-
- Consolidation of `AGENTS.md` + `SOUL.md` + `IDENTITY.md` into `CLAUDE.md` is optional — ccgateway reads all of them
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
### Discord & Slack Gateways
|
|
122
|
-
|
|
123
|
-
Each agent can have its own Discord bot (with its own avatar and name) bound to specific channels. Slack works the same way with socket mode — no public URL needed.
|
|
105
|
+
Each agent can have its own Discord bot (avatar and name) bound to specific channels. Slack uses socket mode — no public URL needed.
|
|
124
106
|
|
|
125
107
|
```json
|
|
126
108
|
{
|
|
127
109
|
"bindings": [
|
|
128
|
-
{ "agent": "salt",
|
|
129
|
-
{ "agent": "pepper", "gateway": "slack",
|
|
110
|
+
{ "agent": "salt", "gateway": "discord", "channel": "1465736400014938230", "bot": "salt" },
|
|
111
|
+
{ "agent": "pepper", "gateway": "slack", "channel": "C07ABC123", "bot": "pepper" }
|
|
130
112
|
]
|
|
131
113
|
}
|
|
132
114
|
```
|
|
133
115
|
|
|
134
|
-
|
|
116
|
+
In-channel slash commands: `/new`, `/reset`, `/status`. Gateway-specific setup in [Discord](docs/gateways/discord.md) and [Slack](docs/gateways/slack.md).
|
|
135
117
|
|
|
136
|
-
### Session
|
|
118
|
+
### Session persistence
|
|
137
119
|
|
|
138
|
-
|
|
120
|
+
One JSONL file per agent-per-channel. Sessions never expire. When history exceeds the token budget (default 200k), older messages drop from what gets sent to Claude, but the full log stays on disk.
|
|
139
121
|
|
|
140
122
|
```bash
|
|
141
123
|
ccg sessions list
|
|
142
124
|
ccg sessions inspect salt:discord:1465736400014938230
|
|
143
|
-
ccg sessions reset
|
|
125
|
+
ccg sessions reset salt:discord:1465736400014938230
|
|
144
126
|
```
|
|
145
127
|
|
|
146
|
-
###
|
|
128
|
+
### Async task spawning
|
|
147
129
|
|
|
148
|
-
|
|
130
|
+
A Haiku triage classifies each incoming message as sync or async. Async work launches `claude` in interactive mode inside a detached tmux session with full tool access — you can attach live to watch or intervene. When the session ends, results are posted back to the channel.
|
|
149
131
|
|
|
150
132
|
```bash
|
|
151
|
-
|
|
133
|
+
tmux list-sessions
|
|
134
|
+
tmux attach -t <task-session>
|
|
152
135
|
```
|
|
153
136
|
|
|
154
|
-
|
|
137
|
+
Details in [Async Tasks](docs/features/async-tasks.md).
|
|
155
138
|
|
|
156
|
-
###
|
|
139
|
+
### Cross-agent messaging
|
|
157
140
|
|
|
158
|
-
|
|
141
|
+
Agents coordinate by posting to each other's channels. Salt messaging Pepper looks identical to a human posting in Pepper's channel — same avatar, same routing.
|
|
159
142
|
|
|
160
143
|
```bash
|
|
161
|
-
ccg
|
|
162
|
-
ccg skills add deploy-to-staging.md
|
|
163
|
-
ccg skills add navix-rca.md --agent salt
|
|
144
|
+
ccg send pepper "RCA done for NHD-10763" --from salt
|
|
164
145
|
```
|
|
165
146
|
|
|
166
|
-
Agents
|
|
147
|
+
Agents without gateway bindings fall back to a file-based inbox. See [Cross-Agent Messaging](docs/features/cross-agent-messaging.md).
|
|
167
148
|
|
|
168
|
-
###
|
|
149
|
+
### Skills
|
|
169
150
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```
|
|
173
|
-
~/clawd-salt/
|
|
174
|
-
├── CLAUDE.md # Identity + rules (loaded by CC automatically)
|
|
175
|
-
├── MEMORY.md # Curated long-term memory
|
|
176
|
-
└── memory/
|
|
177
|
-
├── 2026-04-05.md # Today's log
|
|
178
|
-
└── 2026-04-04.md # Yesterday's log
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Heartbeats
|
|
182
|
-
|
|
183
|
-
Minimal cron-based agent wakeups. If `HEARTBEAT.md` exists in the workspace, the agent reads it and acts. If nothing needs attention, the response is silently discarded — no tokens wasted on Discord.
|
|
151
|
+
Markdown files with agent-readable instructions. Shared skills available to everyone; agent-specific skills override shared ones.
|
|
184
152
|
|
|
185
153
|
```bash
|
|
186
|
-
ccg
|
|
187
|
-
ccg
|
|
154
|
+
ccg skills list
|
|
155
|
+
ccg skills add deploy-to-staging.md
|
|
156
|
+
ccg skills add navix-rca.md --agent salt
|
|
188
157
|
```
|
|
189
158
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Test agents locally without Discord or Slack:
|
|
159
|
+
More in [Skills](docs/features/skills.md).
|
|
193
160
|
|
|
194
|
-
|
|
195
|
-
ccg chat main
|
|
196
|
-
```
|
|
161
|
+
### CLI chat
|
|
197
162
|
|
|
198
|
-
|
|
163
|
+
Test agents locally without Discord or Slack — same session, same context, same identity:
|
|
199
164
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
┌──────────────────────────────────────────────┐
|
|
204
|
-
│ ccgateway (single process) │
|
|
205
|
-
│ │
|
|
206
|
-
│ ┌─────────┐ ┌─────────┐ ┌─────────────┐ │
|
|
207
|
-
│ │ Discord │ │ Slack │ │ Future │ │
|
|
208
|
-
│ │ Plugin │ │ Plugin │ │ Plugins │ │
|
|
209
|
-
│ └────┬────┘ └────┬────┘ └──────┬──────┘ │
|
|
210
|
-
│ └────────────┼──────────────┘ │
|
|
211
|
-
│ ↓ │
|
|
212
|
-
│ ┌──────────────┐ │
|
|
213
|
-
│ │ Router │ │
|
|
214
|
-
│ │ (bindings) │ │
|
|
215
|
-
│ └──────┬───────┘ │
|
|
216
|
-
│ ↓ │
|
|
217
|
-
│ ┌───────────────┐ │
|
|
218
|
-
│ │ Session Mgr │ │
|
|
219
|
-
│ │ (JSONL state) │ │
|
|
220
|
-
│ └───────┬───────┘ │
|
|
221
|
-
│ ↓ │
|
|
222
|
-
│ ┌─────────────────┐ │
|
|
223
|
-
│ │ Context Builder │ │
|
|
224
|
-
│ │ identity+history│ │
|
|
225
|
-
│ │ +skills+memory │ │
|
|
226
|
-
│ └────────┬────────┘ │
|
|
227
|
-
│ ↓ │
|
|
228
|
-
│ ┌─────────────────┐ │
|
|
229
|
-
│ │ claude --print │ │
|
|
230
|
-
│ └─────────────────┘ │
|
|
231
|
-
└──────────────────────────────────────────────┘
|
|
165
|
+
```bash
|
|
166
|
+
ccg chat salt
|
|
232
167
|
```
|
|
233
168
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
No persistent processes per agent. No session hijacking. No API keys. Just `claude --print` with the right context, in the right directory.
|
|
169
|
+
Or drop into an orchestrated subagent session with full identity injection from inside Claude Code via the `/talk` skill.
|
|
237
170
|
|
|
238
|
-
|
|
171
|
+
## Plugin architecture
|
|
239
172
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
Gateway channels are plugins. Discord and Slack ship as built-ins. Adding a new gateway means implementing one interface:
|
|
173
|
+
Gateways are plugins. Discord and Slack ship as built-ins. Add a new gateway by implementing one interface:
|
|
243
174
|
|
|
244
175
|
```typescript
|
|
245
176
|
interface CcgPlugin {
|
|
@@ -251,30 +182,45 @@ interface CcgPlugin {
|
|
|
251
182
|
}
|
|
252
183
|
```
|
|
253
184
|
|
|
254
|
-
|
|
185
|
+
Full guide: [Building a Plugin](docs/guides/building-a-plugin.md).
|
|
255
186
|
|
|
256
|
-
##
|
|
187
|
+
## Migration from OpenClaw
|
|
257
188
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
189
|
+
```bash
|
|
190
|
+
ccg migrate openclaw [--config <path>] [--dry-run]
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Agents, bindings, tokens, and skills carry over. See [Migrating from OpenClaw](docs/guides/migrating-from-openclaw.md).
|
|
263
194
|
|
|
264
195
|
## Configuration
|
|
265
196
|
|
|
266
|
-
Config lives at `~/.ccgateway/config.json` (or `$CCG_HOME/config.json`).
|
|
197
|
+
Config lives at `~/.ccgateway/config.json` (or `$CCG_HOME/config.json`). Reference: [config.md](docs/reference/config.md), [environment.md](docs/reference/environment.md), [troubleshooting.md](docs/reference/troubleshooting.md).
|
|
267
198
|
|
|
268
199
|
```bash
|
|
269
|
-
ccg agents list
|
|
270
|
-
ccg sessions list
|
|
271
|
-
ccg skills list
|
|
272
|
-
ccg status
|
|
273
|
-
ccg install # Install as background service
|
|
274
|
-
ccg uninstall # Remove background service
|
|
200
|
+
ccg agents list
|
|
201
|
+
ccg sessions list
|
|
202
|
+
ccg skills list
|
|
203
|
+
ccg status
|
|
275
204
|
```
|
|
276
205
|
|
|
277
|
-
|
|
206
|
+
## Roadmap
|
|
207
|
+
|
|
208
|
+
- **Telegram gateway** — Plugin for Telegram bot API
|
|
209
|
+
- **WhatsApp gateway** — Plugin for WhatsApp Business API
|
|
210
|
+
- **Browser tools** — Playwright-based browser interaction plugin
|
|
211
|
+
- **Shared skill packs** — Pre-built skill collections
|
|
212
|
+
- **Token-accurate context budgeting** — Replace chars/4 estimation with a real tokenizer
|
|
213
|
+
|
|
214
|
+
## Docs
|
|
215
|
+
|
|
216
|
+
Full documentation under [`docs/`](docs/index.md):
|
|
217
|
+
|
|
218
|
+
- [Getting Started](docs/getting-started/installation.md)
|
|
219
|
+
- [Concepts](docs/concepts/architecture.md) — architecture, agents, sessions, plugins, context
|
|
220
|
+
- [Features](docs/features/async-tasks.md) — async tasks, cross-agent messaging, skills, memory, CLI chat
|
|
221
|
+
- [Gateways](docs/gateways/discord.md) — Discord, Slack
|
|
222
|
+
- [Guides](docs/guides/creating-an-agent.md) — creating agents, writing skills, building plugins, migration
|
|
223
|
+
- [CLI Reference](docs/cli/reference.md)
|
|
278
224
|
|
|
279
225
|
## License
|
|
280
226
|
|
package/dist/async-watcher.d.ts
CHANGED
|
@@ -34,6 +34,12 @@ export declare class AsyncTaskWatcher {
|
|
|
34
34
|
* Get the list of active tasks.
|
|
35
35
|
*/
|
|
36
36
|
getActiveTasks(): AsyncTask[];
|
|
37
|
+
/**
|
|
38
|
+
* Cancel any async task(s) registered for the given (agent, gateway, channel).
|
|
39
|
+
* Kills the tmux/screen session and removes the task(s) from monitoring.
|
|
40
|
+
* Returns the number of tasks cancelled.
|
|
41
|
+
*/
|
|
42
|
+
cancelForChannel(agentId: string, gateway: string, channel: string): Promise<number>;
|
|
37
43
|
private poll;
|
|
38
44
|
private resolveAndPost;
|
|
39
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-watcher.d.ts","sourceRoot":"","sources":["../src/async-watcher.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpD,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,KAAK,eAAe,GAAG,CACrB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,KACZ,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,KAAK,kBAAkB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,eAAe,GAAG,IAAI,CAAC;AAMtE,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,gBAAgB;IAN1B,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,SAAS,CAA+C;gBAGtD,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,cAAc,EACxB,gBAAgB,EAAE,kBAAkB;IAG9C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI;IAK/B;;OAEG;IACH,KAAK,IAAI,IAAI;IAUb;;OAEG;IACH,IAAI,IAAI,IAAI;I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CAAC;YAkCJ,IAAI;YAqBJ,cAAc;IA8C5B;;;;;OAKG;YACW,aAAa;CAyB5B"}
|
package/dist/async-watcher.js
CHANGED
|
@@ -49,6 +49,38 @@ export class AsyncTaskWatcher {
|
|
|
49
49
|
getActiveTasks() {
|
|
50
50
|
return [...this.tasks];
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Cancel any async task(s) registered for the given (agent, gateway, channel).
|
|
54
|
+
* Kills the tmux/screen session and removes the task(s) from monitoring.
|
|
55
|
+
* Returns the number of tasks cancelled.
|
|
56
|
+
*/
|
|
57
|
+
async cancelForChannel(agentId, gateway, channel) {
|
|
58
|
+
let cancelled = 0;
|
|
59
|
+
for (let i = this.tasks.length - 1; i >= 0; i--) {
|
|
60
|
+
const task = this.tasks[i];
|
|
61
|
+
if (task.agentId === agentId &&
|
|
62
|
+
task.gateway === gateway &&
|
|
63
|
+
task.channel === channel) {
|
|
64
|
+
this.tasks.splice(i, 1);
|
|
65
|
+
try {
|
|
66
|
+
await this.spawner.killSession(task.sessionName);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
logger.warn(`async-watcher: failed to kill session ${task.sessionName}: ${err.message}`);
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const { rm } = await import("node:fs/promises");
|
|
73
|
+
await rm(task.taskDir, { recursive: true, force: true });
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// non-fatal
|
|
77
|
+
}
|
|
78
|
+
cancelled++;
|
|
79
|
+
logger.info(`async-watcher: cancelled task ${task.sessionName} for ${agentId}@${gateway}:${channel}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return cancelled;
|
|
83
|
+
}
|
|
52
84
|
// ── Polling ──────────────────────────────────────────────────────────────
|
|
53
85
|
async poll() {
|
|
54
86
|
if (this.tasks.length === 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-watcher.js","sourceRoot":"","sources":["../src/async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gBAAgB,IAAI,CAAC,WAAW,oBAAoB,OAAO,wBAAwB,CAAC;IAC7F,CAAC;CACF"}
|
package/dist/cli.js
CHANGED
|
@@ -11,11 +11,10 @@ import { SkillManager } from "./skills.js";
|
|
|
11
11
|
import { ContextBuilder } from "./context.js";
|
|
12
12
|
import { CCSpawner } from "./spawner.js";
|
|
13
13
|
import { startChat } from "./chat.js";
|
|
14
|
-
import { HeartbeatManager } from "./heartbeat.js";
|
|
15
14
|
import { CrossAgentMessenger } from "./messaging.js";
|
|
16
15
|
import { PluginLoader } from "./plugin.js";
|
|
17
16
|
import { startDaemon, stopDaemon, getDaemonStatus } from "./daemon.js";
|
|
18
|
-
import { migrateFromOpenClaw, initNew } from "./migrate.js";
|
|
17
|
+
import { migrateFromOpenClaw, initNew, installCcgSkill, uninstallCcgSkill } from "./migrate.js";
|
|
19
18
|
import { installService, uninstallService } from "./systemd.js";
|
|
20
19
|
// ── Read version from package.json ──────────────────────────────────────────
|
|
21
20
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -195,91 +194,6 @@ program
|
|
|
195
194
|
process.exitCode = 1;
|
|
196
195
|
}
|
|
197
196
|
});
|
|
198
|
-
// ── heartbeat subcommand ─────────────────────────────────────────────────
|
|
199
|
-
const heartbeatCmd = program
|
|
200
|
-
.command("heartbeat")
|
|
201
|
-
.description("Manage heartbeat schedules");
|
|
202
|
-
heartbeatCmd
|
|
203
|
-
.command("install")
|
|
204
|
-
.description("Install cron jobs for heartbeats")
|
|
205
|
-
.action(async () => {
|
|
206
|
-
const config = await loadConfig();
|
|
207
|
-
const registry = new AgentRegistry(config);
|
|
208
|
-
const spawner = new CCSpawner();
|
|
209
|
-
const manager = new HeartbeatManager(registry, spawner, config.heartbeats);
|
|
210
|
-
try {
|
|
211
|
-
const lines = manager.installCron();
|
|
212
|
-
console.log("Installed heartbeat cron jobs:");
|
|
213
|
-
console.log(lines);
|
|
214
|
-
}
|
|
215
|
-
catch (err) {
|
|
216
|
-
console.error(`Error: ${err.message}`);
|
|
217
|
-
process.exitCode = 1;
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
heartbeatCmd
|
|
221
|
-
.command("uninstall")
|
|
222
|
-
.description("Remove heartbeat cron jobs")
|
|
223
|
-
.action(async () => {
|
|
224
|
-
const config = await loadConfig();
|
|
225
|
-
const registry = new AgentRegistry(config);
|
|
226
|
-
const spawner = new CCSpawner();
|
|
227
|
-
const manager = new HeartbeatManager(registry, spawner, config.heartbeats);
|
|
228
|
-
try {
|
|
229
|
-
manager.uninstallCron();
|
|
230
|
-
console.log("Heartbeat cron jobs removed.");
|
|
231
|
-
}
|
|
232
|
-
catch (err) {
|
|
233
|
-
console.error(`Error: ${err.message}`);
|
|
234
|
-
process.exitCode = 1;
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
heartbeatCmd
|
|
238
|
-
.command("list")
|
|
239
|
-
.description("List configured heartbeats")
|
|
240
|
-
.action(async () => {
|
|
241
|
-
const config = await loadConfig();
|
|
242
|
-
const registry = new AgentRegistry(config);
|
|
243
|
-
const spawner = new CCSpawner();
|
|
244
|
-
const manager = new HeartbeatManager(registry, spawner, config.heartbeats);
|
|
245
|
-
const heartbeats = manager.listHeartbeats();
|
|
246
|
-
if (heartbeats.length === 0) {
|
|
247
|
-
console.log("No heartbeats configured.");
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
const header = ["Agent", "Cron", "Timezone"];
|
|
251
|
-
const rows = heartbeats.map((hb) => [hb.agent, hb.cron, hb.tz]);
|
|
252
|
-
const widths = header.map((h, i) => Math.max(h.length, ...rows.map((r) => r[i].length)));
|
|
253
|
-
const formatRow = (cols) => cols.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
254
|
-
console.log(formatRow(header));
|
|
255
|
-
console.log(widths.map((w) => "-".repeat(w)).join(" "));
|
|
256
|
-
for (const row of rows) {
|
|
257
|
-
console.log(formatRow(row));
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
heartbeatCmd
|
|
261
|
-
.command("run <agent>")
|
|
262
|
-
.description("Run heartbeat for an agent manually")
|
|
263
|
-
.action(async (agentId) => {
|
|
264
|
-
const config = await loadConfig();
|
|
265
|
-
const registry = new AgentRegistry(config);
|
|
266
|
-
const spawner = new CCSpawner();
|
|
267
|
-
const manager = new HeartbeatManager(registry, spawner, config.heartbeats);
|
|
268
|
-
try {
|
|
269
|
-
const result = await manager.runHeartbeat(agentId);
|
|
270
|
-
if (result.silent) {
|
|
271
|
-
console.log(`Heartbeat for "${agentId}": all clear.`);
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
console.log(`Heartbeat for "${agentId}":`);
|
|
275
|
-
console.log(result.response);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
catch (err) {
|
|
279
|
-
console.error(`Error: ${err.message}`);
|
|
280
|
-
process.exitCode = 1;
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
197
|
// ── agents subcommand ──────────────────────────────────────────────────────
|
|
284
198
|
const agentsCmd = program
|
|
285
199
|
.command("agents")
|
|
@@ -545,6 +459,33 @@ skillsCmd
|
|
|
545
459
|
}
|
|
546
460
|
console.log(`Skill "${name}" removed.`);
|
|
547
461
|
});
|
|
462
|
+
// ── install-skill / uninstall-skill ────────────────────────────────────────
|
|
463
|
+
program
|
|
464
|
+
.command("install-skill")
|
|
465
|
+
.description("Install the /talk skill into Claude Code (~/.claude/skills/)")
|
|
466
|
+
.action(async () => {
|
|
467
|
+
try {
|
|
468
|
+
await installCcgSkill();
|
|
469
|
+
console.log("Claude Code /talk skill installed to ~/.claude/skills/ccgateway-talk/");
|
|
470
|
+
}
|
|
471
|
+
catch (err) {
|
|
472
|
+
console.error(`Error: ${err.message}`);
|
|
473
|
+
process.exitCode = 1;
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
program
|
|
477
|
+
.command("uninstall-skill")
|
|
478
|
+
.description("Remove the /talk skill from Claude Code")
|
|
479
|
+
.action(async () => {
|
|
480
|
+
try {
|
|
481
|
+
await uninstallCcgSkill();
|
|
482
|
+
console.log("Claude Code /talk skill removed.");
|
|
483
|
+
}
|
|
484
|
+
catch (err) {
|
|
485
|
+
console.error(`Error: ${err.message}`);
|
|
486
|
+
process.exitCode = 1;
|
|
487
|
+
}
|
|
488
|
+
});
|
|
548
489
|
// ── Run ─────────────────────────────────────────────────────────────────────
|
|
549
490
|
program.parse();
|
|
550
491
|
//# sourceMappingURL=cli.js.map
|