@0xmaxma/claude-gateway 1.7.9 → 1.8.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 +178 -44
- package/dist/agent/builtin-commands.js +2 -2
- package/dist/agent/builtin-commands.js.map +1 -1
- package/dist/agent/dreaming/accept.d.ts.map +1 -1
- package/dist/agent/dreaming/accept.js +4 -1
- package/dist/agent/dreaming/accept.js.map +1 -1
- package/dist/agent/dreaming/config.d.ts.map +1 -1
- package/dist/agent/dreaming/config.js +2 -0
- package/dist/agent/dreaming/config.js.map +1 -1
- package/dist/agent/dreaming/reviewer.d.ts.map +1 -1
- package/dist/agent/dreaming/reviewer.js +9 -2
- package/dist/agent/dreaming/reviewer.js.map +1 -1
- package/dist/agent/dreaming/staleness.d.ts +7 -1
- package/dist/agent/dreaming/staleness.d.ts.map +1 -1
- package/dist/agent/dreaming/staleness.js +17 -2
- package/dist/agent/dreaming/staleness.js.map +1 -1
- package/dist/agent/dreaming/types.d.ts +17 -1
- package/dist/agent/dreaming/types.d.ts.map +1 -1
- package/dist/agent/knowledge/archive-db.d.ts +43 -0
- package/dist/agent/knowledge/archive-db.d.ts.map +1 -1
- package/dist/agent/knowledge/archive-db.js +130 -0
- package/dist/agent/knowledge/archive-db.js.map +1 -1
- package/dist/agent/knowledge/config.d.ts +3 -1
- package/dist/agent/knowledge/config.d.ts.map +1 -1
- package/dist/agent/knowledge/config.js +32 -10
- package/dist/agent/knowledge/config.js.map +1 -1
- package/dist/agent/knowledge/index.d.ts +11 -4
- package/dist/agent/knowledge/index.d.ts.map +1 -1
- package/dist/agent/knowledge/index.js +22 -1
- package/dist/agent/knowledge/index.js.map +1 -1
- package/dist/agent/knowledge/indexer.d.ts +0 -7
- package/dist/agent/knowledge/indexer.d.ts.map +1 -1
- package/dist/agent/knowledge/indexer.js +34 -7
- package/dist/agent/knowledge/indexer.js.map +1 -1
- package/dist/agent/knowledge/lifecycle.d.ts +20 -4
- package/dist/agent/knowledge/lifecycle.d.ts.map +1 -1
- package/dist/agent/knowledge/lifecycle.js +33 -4
- package/dist/agent/knowledge/lifecycle.js.map +1 -1
- package/dist/agent/knowledge/reflection.d.ts +114 -0
- package/dist/agent/knowledge/reflection.d.ts.map +1 -0
- package/dist/agent/knowledge/reflection.js +447 -0
- package/dist/agent/knowledge/reflection.js.map +1 -0
- package/dist/agent/knowledge/shared-dedup.d.ts +85 -0
- package/dist/agent/knowledge/shared-dedup.d.ts.map +1 -0
- package/dist/agent/knowledge/shared-dedup.js +187 -0
- package/dist/agent/knowledge/shared-dedup.js.map +1 -0
- package/dist/agent/knowledge/shared-promote.d.ts +82 -7
- package/dist/agent/knowledge/shared-promote.d.ts.map +1 -1
- package/dist/agent/knowledge/shared-promote.js +244 -11
- package/dist/agent/knowledge/shared-promote.js.map +1 -1
- package/dist/agent/knowledge/shared-staleness.d.ts +51 -0
- package/dist/agent/knowledge/shared-staleness.d.ts.map +1 -0
- package/dist/agent/knowledge/shared-staleness.js +149 -0
- package/dist/agent/knowledge/shared-staleness.js.map +1 -0
- package/dist/agent/knowledge/shared-writer.d.ts +19 -0
- package/dist/agent/knowledge/shared-writer.d.ts.map +1 -1
- package/dist/agent/knowledge/shared-writer.js +42 -0
- package/dist/agent/knowledge/shared-writer.js.map +1 -1
- package/dist/agent/knowledge/types.d.ts +24 -0
- package/dist/agent/knowledge/types.d.ts.map +1 -1
- package/dist/agent/model-catalog.d.ts +62 -0
- package/dist/agent/model-catalog.d.ts.map +1 -0
- package/dist/agent/model-catalog.js +264 -0
- package/dist/agent/model-catalog.js.map +1 -0
- package/dist/agent/runner.d.ts +83 -0
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +281 -51
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/workspace-loader.d.ts +17 -2
- package/dist/agent/workspace-loader.d.ts.map +1 -1
- package/dist/agent/workspace-loader.js +17 -1
- package/dist/agent/workspace-loader.js.map +1 -1
- package/dist/api/cron-router.d.ts +12 -8
- package/dist/api/cron-router.d.ts.map +1 -1
- package/dist/api/cron-router.js +82 -16
- package/dist/api/cron-router.js.map +1 -1
- package/dist/api/gateway-router.d.ts +4 -0
- package/dist/api/gateway-router.d.ts.map +1 -1
- package/dist/api/gateway-router.js +16 -1
- package/dist/api/gateway-router.js.map +1 -1
- package/dist/api/manifest-sources.d.ts +15 -0
- package/dist/api/manifest-sources.d.ts.map +1 -0
- package/dist/api/manifest-sources.js +27 -0
- package/dist/api/manifest-sources.js.map +1 -0
- package/dist/api/meta-router.d.ts +13 -0
- package/dist/api/meta-router.d.ts.map +1 -0
- package/dist/api/meta-router.js +26 -0
- package/dist/api/meta-router.js.map +1 -0
- package/dist/api/packages.d.ts.map +1 -1
- package/dist/api/packages.js +18 -198
- package/dist/api/packages.js.map +1 -1
- package/dist/api/route-registry.d.ts +81 -0
- package/dist/api/route-registry.d.ts.map +1 -0
- package/dist/api/route-registry.js +44 -0
- package/dist/api/route-registry.js.map +1 -0
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +21 -3
- package/dist/api/router.js.map +1 -1
- package/dist/apps/compose-generator.js +7 -4
- package/dist/apps/compose-generator.js.map +1 -1
- package/dist/apps/installer.d.ts +154 -0
- package/dist/apps/installer.d.ts.map +1 -1
- package/dist/apps/installer.js +657 -54
- package/dist/apps/installer.js.map +1 -1
- package/dist/cli/args.d.ts +25 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +55 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/colors.d.ts +37 -0
- package/dist/cli/colors.d.ts.map +1 -0
- package/dist/cli/colors.js +63 -0
- package/dist/cli/colors.js.map +1 -0
- package/dist/cli/command-names.d.ts +98 -0
- package/dist/cli/command-names.d.ts.map +1 -0
- package/dist/cli/command-names.js +109 -0
- package/dist/cli/command-names.js.map +1 -0
- package/dist/cli/commands/agents.d.ts +28 -0
- package/dist/cli/commands/agents.d.ts.map +1 -0
- package/dist/cli/commands/agents.js +321 -0
- package/dist/cli/commands/agents.js.map +1 -0
- package/dist/cli/commands/channels.d.ts +17 -0
- package/dist/cli/commands/channels.d.ts.map +1 -0
- package/dist/cli/commands/channels.js +101 -0
- package/dist/cli/commands/channels.js.map +1 -0
- package/dist/cli/commands/debug-bundle.d.ts +6 -0
- package/dist/cli/commands/debug-bundle.d.ts.map +1 -0
- package/dist/cli/commands/debug-bundle.js +220 -0
- package/dist/cli/commands/debug-bundle.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +104 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/gateway.d.ts +12 -0
- package/dist/cli/commands/gateway.d.ts.map +1 -0
- package/dist/cli/commands/gateway.js +145 -0
- package/dist/cli/commands/gateway.js.map +1 -0
- package/dist/cli/commands/service.d.ts +33 -0
- package/dist/cli/commands/service.d.ts.map +1 -0
- package/dist/cli/commands/service.js +513 -0
- package/dist/cli/commands/service.js.map +1 -0
- package/dist/cli/commands/update.d.ts +16 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +149 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/commands.generated.d.ts +4 -0
- package/dist/cli/commands.generated.d.ts.map +1 -0
- package/dist/cli/commands.generated.js +220 -0
- package/dist/cli/commands.generated.js.map +1 -0
- package/dist/cli/health.d.ts +31 -0
- package/dist/cli/health.d.ts.map +1 -0
- package/dist/cli/health.js +49 -0
- package/dist/cli/health.js.map +1 -0
- package/dist/cli/http-client.d.ts +140 -0
- package/dist/cli/http-client.d.ts.map +1 -0
- package/dist/cli/http-client.js +332 -0
- package/dist/cli/http-client.js.map +1 -0
- package/dist/cli/index.d.ts +27 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +372 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/manager.d.ts +64 -0
- package/dist/cli/manager.d.ts.map +1 -0
- package/dist/cli/manager.js +181 -0
- package/dist/cli/manager.js.map +1 -0
- package/dist/cli/output.d.ts +49 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +101 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/prompt.d.ts +29 -0
- package/dist/cli/prompt.d.ts.map +1 -0
- package/dist/cli/prompt.js +154 -0
- package/dist/cli/prompt.js.map +1 -0
- package/dist/cli/redact.d.ts +3 -0
- package/dist/cli/redact.d.ts.map +1 -0
- package/dist/cli/redact.js +33 -0
- package/dist/cli/redact.js.map +1 -0
- package/dist/cli/types.d.ts +22 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +4 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/config/bootstrap.d.ts +33 -0
- package/dist/config/bootstrap.d.ts.map +1 -0
- package/dist/config/bootstrap.js +117 -0
- package/dist/config/bootstrap.js.map +1 -0
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +5 -1
- package/dist/config/loader.js.map +1 -1
- package/dist/config/watcher.d.ts.map +1 -1
- package/dist/config/watcher.js +2 -35
- package/dist/config/watcher.js.map +1 -1
- package/dist/discord/receiver.d.ts +6 -1
- package/dist/discord/receiver.d.ts.map +1 -1
- package/dist/discord/receiver.js +9 -1
- package/dist/discord/receiver.js.map +1 -1
- package/dist/entry.d.ts +3 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +83 -0
- package/dist/entry.js.map +1 -0
- package/dist/index.js +197 -47
- package/dist/index.js.map +1 -1
- package/dist/load-dotenv.d.ts +2 -0
- package/dist/load-dotenv.d.ts.map +1 -0
- package/dist/load-dotenv.js +68 -0
- package/dist/load-dotenv.js.map +1 -0
- package/dist/packages/registry.d.ts +50 -0
- package/dist/packages/registry.d.ts.map +1 -0
- package/dist/packages/registry.js +209 -0
- package/dist/packages/registry.js.map +1 -0
- package/dist/session/process.d.ts +20 -3
- package/dist/session/process.d.ts.map +1 -1
- package/dist/session/process.js +120 -5
- package/dist/session/process.js.map +1 -1
- package/dist/shell/claude-pty-shell.js +146 -27
- package/dist/shell/claude-pty-shell.js.map +1 -1
- package/dist/shell/draft-phantom.d.ts +49 -0
- package/dist/shell/draft-phantom.d.ts.map +1 -0
- package/dist/shell/draft-phantom.js +59 -0
- package/dist/shell/draft-phantom.js.map +1 -0
- package/dist/shell/submit-diag.d.ts +67 -0
- package/dist/shell/submit-diag.d.ts.map +1 -0
- package/dist/shell/submit-diag.js +69 -0
- package/dist/shell/submit-diag.js.map +1 -0
- package/dist/shutdown-signals.d.ts +47 -0
- package/dist/shutdown-signals.d.ts.map +1 -0
- package/dist/shutdown-signals.js +62 -0
- package/dist/shutdown-signals.js.map +1 -0
- package/dist/telegram/receiver.d.ts +6 -1
- package/dist/telegram/receiver.d.ts.map +1 -1
- package/dist/telegram/receiver.js +9 -1
- package/dist/telegram/receiver.js.map +1 -1
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/orphan-receivers.d.ts +90 -0
- package/dist/utils/orphan-receivers.d.ts.map +1 -0
- package/dist/utils/orphan-receivers.js +218 -0
- package/dist/utils/orphan-receivers.js.map +1 -0
- package/dist/utils/paths.d.ts +16 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +60 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/stop-child.d.ts +21 -0
- package/dist/utils/stop-child.d.ts.map +1 -0
- package/dist/utils/stop-child.js +64 -0
- package/dist/utils/stop-child.js.map +1 -0
- package/lib/pairing.ts +1 -1
- package/mcp/tools/agent/handlers.ts +1 -1
- package/mcp/tools/discord/module.ts +23 -15
- package/mcp/tools/discord/receiver-server.ts +4 -0
- package/mcp/tools/memory/archive-reader.test.ts +25 -1
- package/mcp/tools/memory/archive-reader.ts +70 -12
- package/mcp/tools/memory/archive-writer.test.ts +168 -0
- package/mcp/tools/memory/archive-writer.ts +137 -0
- package/mcp/tools/memory/module.test.ts +187 -0
- package/mcp/tools/memory/module.ts +192 -6
- package/mcp/tools/telegram/module.ts +10 -2
- package/mcp/tools/telegram/receiver-server.ts +15 -6
- package/mcp/tools/telegram/typing.ts +178 -34
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ A self-hosted multi-agent gateway for Claude Code — with agents that improve t
|
|
|
30
30
|
- 🔐 **Access control** — allowlist, open, or pairing-based Telegram access policies
|
|
31
31
|
- 🌐 **HTTP API** — REST API with key-based auth for external integrations
|
|
32
32
|
- 🛍️ **App Store** — install, update, and host Docker-compose apps on the gateway; apps get a reverse proxy at `/app/:name/:portName/*`, optional Unix socket bridge for host scripts, and optional AI agent injection
|
|
33
|
-
- ⬆️ **Self-update
|
|
33
|
+
- ⬆️ **Self-update** — check for newer versions of `claude-gateway` and `claude-code` and trigger an update via a single API call (no SSH or shell access needed), or from the terminal with `claude-gateway update` / `claude-gateway claude update`
|
|
34
34
|
- 💾 **Session persistence** — conversation history saved and restored across restarts
|
|
35
35
|
- 🖥️ **PTY shell (wrap-shell mode)** — optional interactive pseudo-terminal backend (`gateway.headless: false`) for tools that require a real TTY; includes a live browser viewer (xterm.js) and a `/api/v1/sessions/:sessionId/screen` endpoint that returns the visible screen as plain text — agents can poll it to detect hang states, menus, or unexpected output without parsing ANSI escape codes; a `/cli` chat command (Telegram/Discord/LINE) opens the same viewer for a single agent, agent-scoped and without an admin key; app-agents always stay headless
|
|
36
36
|
|
|
@@ -80,28 +80,64 @@ EOF
|
|
|
80
80
|
|
|
81
81
|
All variables are optional. Full list: [`.env.example`](.env.example)
|
|
82
82
|
|
|
83
|
-
**3.
|
|
83
|
+
**3. Start**
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
```bash
|
|
86
|
+
claude-gateway gateway start
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`claude-gateway` on its own prints help — starting the server is always the explicit
|
|
90
|
+
`gateway start`, so a stray or mistyped command can never leave a gateway listening.
|
|
91
|
+
|
|
92
|
+
No config file needed — on first run, if `~/.claude-gateway/config.json` doesn't exist yet, the gateway creates it automatically with `"agents": []` and a fresh random admin API key, and prints that key once:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
[gateway] No config found — created one at ~/.claude-gateway/config.json
|
|
96
|
+
[gateway] Admin API key (save this now — it will not be shown again):
|
|
97
|
+
[gateway] <random-hex-key>
|
|
98
|
+
[gateway] The CLI (claude-gateway agents create, etc.) picks this up automatically from ~/.claude-gateway/config.json.
|
|
99
|
+
```
|
|
86
100
|
|
|
87
|
-
|
|
101
|
+
Save that key somewhere safe — it isn't shown again (though you can always read it back from `config.json` on disk). See [`config.template.json`](config.template.json) for the full config format (models list, more options) if you want to customize it by hand later.
|
|
102
|
+
|
|
103
|
+
**4. Create an agent**
|
|
88
104
|
|
|
89
105
|
```bash
|
|
90
|
-
claude-gateway
|
|
106
|
+
claude-gateway agents create
|
|
91
107
|
```
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
Interactive wizard — describe the agent, Claude generates the workspace files, review and accept them, then optionally connect a Telegram or Discord bot. Hot-reloads immediately, no restart needed. The CLI picks up the admin key from `config.json` automatically — no need to pass `--key`. (You can also add an agent entry to `config.json` by hand instead — same template link as above.)
|
|
110
|
+
|
|
111
|
+
**Run as a service (optional)**
|
|
94
112
|
|
|
95
|
-
To keep the gateway running after
|
|
113
|
+
To keep the gateway running after you log out or the machine reboots, let the CLI install the
|
|
114
|
+
service for you. It shows the exact unit it will write, asks before installing, and verifies
|
|
115
|
+
`/health` afterwards:
|
|
96
116
|
|
|
97
117
|
```bash
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
118
|
+
claude-gateway service install # systemd *user* unit — no sudo
|
|
119
|
+
claude-gateway service install --print # just show what it would install
|
|
120
|
+
claude-gateway service status
|
|
121
|
+
claude-gateway service uninstall # asks first — this stops a running gateway
|
|
102
122
|
```
|
|
103
123
|
|
|
104
|
-
|
|
124
|
+
Install and uninstall both prompt before acting; pass `--yes` in scripts (without it, a
|
|
125
|
+
non-interactive run is refused rather than left hanging).
|
|
126
|
+
|
|
127
|
+
The systemd path writes `~/.config/systemd/user/claude-gateway.service`. Run
|
|
128
|
+
`loginctl enable-linger $USER` once if it must keep running while you're logged out.
|
|
129
|
+
Prefer [PM2](https://pm2.keymetrics.io)? `claude-gateway service install --manager pm2` registers
|
|
130
|
+
and saves the process instead (run `pm2 startup` separately for boot-time start).
|
|
131
|
+
|
|
132
|
+
Once installed, drive it through the CLI — it detects whichever manager owns the process:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
claude-gateway gateway status # manager, URL, health
|
|
136
|
+
claude-gateway gateway restart
|
|
137
|
+
claude-gateway gateway stop
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Managing PM2 directly still works too:
|
|
105
141
|
|
|
106
142
|
```bash
|
|
107
143
|
pm2 status # check gateway status
|
|
@@ -122,30 +158,32 @@ npm install # also runs bun install in mcp/
|
|
|
122
158
|
npm run build
|
|
123
159
|
```
|
|
124
160
|
|
|
125
|
-
###
|
|
126
|
-
|
|
127
|
-
The interactive wizard handles everything — workspace files, config, bot token, and pairing:
|
|
161
|
+
### Start the gateway
|
|
128
162
|
|
|
129
163
|
```bash
|
|
130
|
-
|
|
164
|
+
npm start
|
|
131
165
|
```
|
|
132
166
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
3. Review and accept generated files
|
|
137
|
-
4. Choose a channel: **Telegram** or **Discord**
|
|
138
|
-
5. Paste the bot token — wizard verifies it automatically
|
|
139
|
-
6. Send any message to the bot to complete pairing
|
|
140
|
-
7. Agent sends a welcome message
|
|
167
|
+
Config is auto-loaded from `~/.claude-gateway/config.json` — if it doesn't exist yet, `npm start` creates it automatically with `"agents": []` and a fresh admin key (see the Start step in the npm-install path above). Bot tokens are auto-loaded from `~/.claude-gateway/agents/<id>/.env`.
|
|
168
|
+
|
|
169
|
+
### Create an agent
|
|
141
170
|
|
|
142
|
-
|
|
171
|
+
The interactive wizard handles everything — workspace files, bot token, and pairing:
|
|
143
172
|
|
|
144
173
|
```bash
|
|
145
|
-
|
|
174
|
+
claude-gateway agents create
|
|
146
175
|
```
|
|
147
176
|
|
|
148
|
-
|
|
177
|
+
Steps:
|
|
178
|
+
1. Choose an agent id and describe its role — Claude generates workspace files
|
|
179
|
+
2. Review and accept the generated files
|
|
180
|
+
3. Optionally connect a channel: **Telegram** or **Discord** — paste the bot token, wizard verifies it automatically
|
|
181
|
+
4. Agent hot-reloads immediately — send any message to the bot, then approve pairing:
|
|
182
|
+
```bash
|
|
183
|
+
claude-gateway channels approve --agent <id> --channel telegram --code <code>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
To manage an existing agent — regenerate `AGENTS.md`, or connect/update/disconnect Telegram, Discord, LINE, or Slack — run `claude-gateway agents update`.
|
|
149
187
|
|
|
150
188
|
---
|
|
151
189
|
|
|
@@ -295,7 +333,7 @@ Access policy is configured per-channel in the agent's workspace state file, not
|
|
|
295
333
|
|-------|-----------|
|
|
296
334
|
| `allowlist` | Only user IDs in `allowFrom` can DM the agent (**default**) |
|
|
297
335
|
| `open` | Anyone can DM the agent |
|
|
298
|
-
| `pairing` | New users DM the bot to receive a pairing code; approve with `
|
|
336
|
+
| `pairing` | New users DM the bot to receive a pairing code; approve with `claude-gateway channels approve` |
|
|
299
337
|
|
|
300
338
|
### `gateway.headless`
|
|
301
339
|
|
|
@@ -429,7 +467,7 @@ Per-agent overrides are supported under the agent's own `dreaming` block; unset
|
|
|
429
467
|
|
|
430
468
|
- **Deterministic compaction** — before the LLM reviewer, every `auto` run moves completed/terminal log entries out of `MEMORY.md` into `memory/archive/completed.md`, leaving a one-line pointer. It is **domain-agnostic** (not just dev): an entry is archived when its lead line carries an explicit done marker — an UPPERCASE status word (`DONE`, `COMPLETED`, `RESOLVED`, `CLOSED`, `CANCELLED`, `ARCHIVED`, `MERGED`, `SUPERSEDED`, `OBSOLETE`, `DEPRECATED`, `EXPIRED`, `SHIPPED`, `FINISHED`), a checked task box `[x]`, a ✅, or a ~~strikethrough~~ — and it works on both list bullets and `###` entry headers. The archive lives under `memory/` so it is still indexed and **searchable via `memory_search`** — the agent recalls completed work on demand instead of carrying its full changelog in-prompt. It is conservative (uppercase words only, so prose like "Closes #123", "we're not done", or an unchecked `[ ]` box is never archived), idempotent, and never drops an open/active item.
|
|
431
469
|
- **Budget-scaled pruning** — when `MEMORY.md` is over its soft budget, the reviewer is put in an explicit net-shrink mode (propose only length-reducing ops) and `maxChangesPerRun` scales up **for removals** (the add cap stays tight), so an over-budget file converges toward budget instead of trickling at a few edits per night.
|
|
432
|
-
- **Archive staleness GC (`gateway.dreaming.staleness`, planning-66)** — a deterministic pass that runs next to the compactor (auto mode) to keep the Lane-2 archive's **search quality** high. This is a **search-quality fix, not a prompt-budget one**: planning-65 already moved task-log off the injected prompt, so the point here is that `memory_search` should keep surfacing *current* truth instead of stale/superseded facts. Each nightly run **soft-invalidates** archive entries — superseded ones (a deterministic `supersedes/replaces/obsoletes #N` match, which finally populates the previously-inert `supersedes_key`) and aged-out ones (idle-since-last-**retrieval** past `staleTtlDays` and retrieved fewer than `minRetrievalKeep` times) — by **moving** them to `memory/archive/stale.md` and stamping `invalid_at`. It **never deletes**: a staled entry stays under `memory/` so it is still indexed and **searchable** (ยุบได้แต่ไม่ลืม). An entry that is **retrieved after** it was invalidated is **promoted back** to the active archive (the recall feedback loop — proof we aged it out too soon). Recall is fed by an append-only read-path log (`kb_retrieval_log`, gated by `recordRetrievals`) that the GC folds into each entry's `last_retrieved`. High-importance entries (`keepImportance`) and **pinned** files (`memory/pinned/**`) are never aged out; evergreen Lane-1 (`MEMORY.md`/`USER.md`) is structurally excluded. Every move is CAS-guarded with a timestamped backup, and — being a memory-only write — drops **no live session**. Kill-switches: `staleness.enabled:false` (GC no-ops) and `recordRetrievals:false` (age falls back to first-seen only).
|
|
470
|
+
- **Archive staleness GC (`gateway.dreaming.staleness`, planning-66)** — a deterministic pass that runs next to the compactor (auto mode) to keep the Lane-2 archive's **search quality** high. This is a **search-quality fix, not a prompt-budget one**: planning-65 already moved task-log off the injected prompt, so the point here is that `memory_search` should keep surfacing *current* truth instead of stale/superseded facts. Each nightly run **soft-invalidates** archive entries — superseded ones (a deterministic `supersedes/replaces/obsoletes #N` match, which finally populates the previously-inert `supersedes_key`) and aged-out ones (idle-since-last-**retrieval** past `staleTtlDays` and retrieved fewer than `minRetrievalKeep` times) — by **moving** them to `memory/archive/stale.md` and stamping `invalid_at`. It **never deletes**: a staled entry stays under `memory/` so it is still indexed and **searchable** (ยุบได้แต่ไม่ลืม). An entry that is **retrieved after** it was invalidated is **promoted back** to the active archive (the recall feedback loop — proof we aged it out too soon). Recall is fed by an append-only read-path log (`kb_retrieval_log`, gated by `recordRetrievals`) that the GC folds into each entry's `last_retrieved`. High-importance entries (`keepImportance`) and **pinned** files (`memory/pinned/**`) are never aged out; evergreen Lane-1 (`MEMORY.md`/`USER.md`) is structurally excluded. Every move is CAS-guarded with a timestamped backup, and — being a memory-only write — drops **no live session**. One run may soft-invalidate at most `staleness.maxInvalidationsPerRun` entries (default `50`), oldest-idle first, with the remainder resuming on later runs — aging is wall-clock driven, so without a ceiling the first run after anything that widens the GC's visibility (such as backfilling lifecycle rows for previously invisible sources) would relocate every already-expired entry in one night. Restores are never capped. Kill-switches: `staleness.enabled:false` (GC no-ops), `maxInvalidationsPerRun:0` (never invalidates, still restores) and `recordRetrievals:false` (age falls back to first-seen only).
|
|
433
471
|
|
|
434
472
|
### `gateway.knowledge`
|
|
435
473
|
|
|
@@ -448,8 +486,14 @@ Two read-only MCP tools expose it to the agent: **`memory_search`** (keyword/FTS
|
|
|
448
486
|
| `shared.root` | `~/.claude-gateway/shared/kb` | Shared vault root dir (`<root>/<project>/`) |
|
|
449
487
|
| `shared.mode` | `"auto"` | Per-agent→shared promotion mode; `auto` = promote durable dreamed facts, `propose` = dry-run |
|
|
450
488
|
| `shared.graph` | `false` | Compile the memory-wiki graph + dashboards over the shared vault to `<vault>/reports/*.md` (opt-in). Independent of the dashboard **Knowledge base** tab, which computes its graph on-demand |
|
|
489
|
+
| `shared.staleness` | *(object)* | Shared-note TTL lifecycle GC; uses the same fields/defaults as `dreaming.staleness` (whole notes only; no numeric `supersedes #N` syntax) |
|
|
490
|
+
| `reflection.enabled` | `true` | Enable the singleton, per-shared-vault reflection scheduler (daily timer; see cadence note below) |
|
|
491
|
+
| `reflection.dayOfWeek` / `hour` / `minute` / `timezone` | `0` / `4` / `0` / `UTC` | `hour`/`minute` is the **daily** staleness-GC slot; `dayOfWeek` selects the weekday that additionally runs LLM consolidation (Sunday 04:00 UTC by default; invalid timezone falls back to UTC) |
|
|
492
|
+
| `reflection.maxClustersPerRun` / `reviewModel` | `5` / `claude-haiku-4-5-…` | Hard cap on changed linked-note clusters per consolidation run and the bounded synthesis model |
|
|
493
|
+
|
|
494
|
+
**Shared KB.** A shared SQLite/FTS5 vault outside any single agent's workspace lets agents build a common knowledge base. Notes under `<root>/<project>/notes/*.md` are indexed and reachable via `memory_search` with `corpus:"shared"` (the shared vault) or `corpus:"all"` (this agent's memory + shared, merged by relevance). Concurrent writers are safe without a lock — atomic note writes (temp+rename) plus a cross-process `PRAGMA busy_timeout` on the index. Per-agent overrides under the agent's own `knowledge` block. The MCP layer runs under Bun, so the read tools query `kb.sqlite` via `bun:sqlite`. Two write paths feed the vault, sharing one freeform-name namespace (issue #386, no agent-id prefix, no ownership scoping): the nightly dreaming promoter (gated by `mode:"auto"`; it promotes only content that carries a real fact — content that is nothing but `MEMORY.md` index-pointer bullets is skipped, since those links resolve only inside the promoting agent's own workspace — and names each note after the proposal's `topic` slug when the reviewer supplied one, falling back to its `reason`, so a recurring fact updates the same note across nights instead of piling up near-duplicates; a fallback name that reads as an editing instruction rather than the name of a fact is passed over, and the note is named from the fact itself instead — the promotion is only abandoned when nothing nameable remains, and every skip is logged — including a write the note-size cap refuses and an unexpected write failure. A name that doesn't collide is checked against a near-duplicate search, but an unattended **merge** now also requires real token containment against the candidate — below that bar the fact gets its own note, since two notes are recoverable while two unrelated facts fused into one are not. `[[wikilink]]`s to related notes use a lower bar than merges, because a link is additive where a merge is destructive — and they are attached whether the fact merges or lands as a new note, so a note below the merge bar is never a disconnected graph node. Containment is scored against each candidate's full body rather than the matched chunk, though against a capped seed — the bar means "half of the fact's leading topic words are already here", not half of the whole fact. Retired `stale__*` notes are never merge targets; a recurrence of a retired name folds the retired body back in and removes the twin on both the create and the update path, because a retired note stays searchable and a twin beside a live note of the same name would answer every query twice forever. The twin is only dropped once the merged write lands (issue #398)) and the **`memory_shared_create`**/**`memory_shared_get`**/**`memory_shared_update`**/**`memory_shared_delete`** MCP tools, which let any agent create, read, update, or delete any note on demand regardless of `mode`. `memory_shared_create` warns instead of writing when it finds content-similar existing notes (pass `confirm:true` to proceed — related notes get `[[wikilink]]`ed into the new note rather than left disconnected); `memory_shared_update` warns instead of writing when the edit would drop 50%+ of the existing note's lines (same `confirm:true` escape hatch). Immediate reindex after every write or delete.
|
|
451
495
|
|
|
452
|
-
**Shared
|
|
496
|
+
**Shared lifecycle + reflection (issues #392, #398).** Each shared note receives a stable whole-file lifecycle identity during indexing — including notes whose content has not changed since they were first indexed, which are backfilled from their source mtime so their real age is preserved. Its deterministic TTL GC runs **daily**, soft-invalidating aged low-recall notes by moving them to `notes/stale__<name>.md` (never deleting them from the searchable vault); a retrieval after invalidation restores the original active name. Shared `memory_search` and `memory_shared_get` reads feed the same append-only retrieval log as personal archive recall. The singleton reflection scheduler runs **once per resolved shared-vault root**, not once per agent, and fires **daily** at `hour:minute` (a fire that lands a hair early re-arms on the *next* day's slot rather than serving the same one twice): every fire runs the inexpensive TTL GC (no model call), while graph/LLM consolidation runs only on `dayOfWeek` — and even then is skipped when `kb_index_state.revision` has not changed since the prior consolidation. Weekly model spend is therefore unchanged, while a note that is retired and then retrieved returns to the active set within a day instead of up to a week. For changed vaults it clusters only active wikilink-connected notes deterministically, then makes at most `reflection.maxClustersPerRun` bounded reviewer calls to merge genuinely duplicate clusters; related-but-distinct notes remain merely linked.
|
|
453
497
|
|
|
454
498
|
**Knowledge base viewer.** The web dashboard's **Knowledge base** tab renders the shared vault as an Obsidian-style force-directed graph (nodes = notes sized by link degree and coloured by `type`; edges = `[[wiki-links]]`; contradicting claims and stale notes are flagged). It is fed by `GET /knowledge/graph`, which computes the model **on-demand** from the vault (no dependency on `shared.graph` or the nightly reindex). When the vault is empty it shows a clearly-labelled demo dataset (with a size selector for scale testing). A **source** selector switches the graph between the cross-agent Shared KB and any single agent's own Lane-2 memory (`workspace/memory`), a node **search** box filters the graph, and clicking a node opens its full note (fetched via `GET /knowledge/note`) rendered as Markdown below the graph.
|
|
455
499
|
|
|
@@ -489,6 +533,8 @@ Network interface the HTTP/WebSocket server binds to. Defaults to `127.0.0.1` (l
|
|
|
489
533
|
|
|
490
534
|
Absolute, externally-reachable origin of the gateway (for example `https://gateway.example.com`, or `https://host.example.com/gateway` behind an ingress path prefix). The process cannot infer its own public URL — it binds localhost by default and sits behind a reverse proxy — so it must be set explicitly for features that hand out a phone-openable link. Currently that is the `/cli` terminal viewer; when `publicUrl` is unset, `/cli` replies that the viewer is not configured. Leave it blank to keep `/cli` disabled. A trailing slash is optional. Use an `https://` origin — Telegram Mini Apps require HTTPS.
|
|
491
535
|
|
|
536
|
+
The CLI does **not** route through this URL when it runs on the gateway's own host: both addresses are the same server, and the public one only adds a reverse-proxy hop that may enforce its own authentication. It talks to the local bind instead, keeping `publicUrl` as a fallback if that address cannot be reached. Pass `--url` to exercise the proxy path deliberately. See [CLI.md](./CLI.md) for the full precedence.
|
|
537
|
+
|
|
492
538
|
```json
|
|
493
539
|
{
|
|
494
540
|
"gateway": {
|
|
@@ -601,6 +647,32 @@ Tools are **prefixed by channel name** to avoid collisions. Each module controls
|
|
|
601
647
|
| `TELEGRAM_RECEIVER_MODE` | `receiver-server.ts` | Polls Telegram, handles commands, POSTs to callback — **no MCP** |
|
|
602
648
|
| `TELEGRAM_SEND_ONLY` | `server.ts` | Exposes MCP tools (`telegram_*`, `cron_*`) — **no polling** |
|
|
603
649
|
|
|
650
|
+
#### Receiver lifecycle
|
|
651
|
+
|
|
652
|
+
Receivers are child processes, so they only stop when the gateway runs its
|
|
653
|
+
shutdown path. Two mechanisms keep them from outliving it:
|
|
654
|
+
|
|
655
|
+
- **`SIGTERM`, `SIGINT` and `SIGHUP` all run the same graceful shutdown.**
|
|
656
|
+
`SIGHUP` matters because Node's default action for it terminates the process
|
|
657
|
+
*without* running handlers — so before this was wired, closing a tmux pane or
|
|
658
|
+
dropping an SSH session killed the gateway and left every receiver reparented
|
|
659
|
+
to `init`. Teardown escalates `SIGTERM` → `SIGKILL` after a short grace period,
|
|
660
|
+
so a receiver wedged in an in-flight long-poll cannot survive it.
|
|
661
|
+
|
|
662
|
+
- **A boot-time sweep reclaims leftovers.** `SIGKILL` and the OOM killer can
|
|
663
|
+
never be handled in-process, so at startup the gateway terminates any
|
|
664
|
+
`receiver-server.ts` process that was spawned from *its own* installation and
|
|
665
|
+
has been reparented to `init` (proof that its supervisor is gone), logging how
|
|
666
|
+
many it reclaimed — and separately warning about any it could **not** reclaim,
|
|
667
|
+
since those are still running. Receivers belonging to another checkout on the
|
|
668
|
+
same host, or to a gateway that is still running, are never touched.
|
|
669
|
+
|
|
670
|
+
On a host where an ancestor is a child subreaper (`systemd --user`,
|
|
671
|
+
`docker run --init`/tini, s6), orphans reparent to that subreaper instead of to
|
|
672
|
+
`init` and the sweep finds nothing. Clean shutdown still works; what is lost is
|
|
673
|
+
the `SIGKILL`/OOM recovery — though such a host usually has a supervisor that
|
|
674
|
+
reaps the process group itself.
|
|
675
|
+
|
|
604
676
|
### Session Persistence
|
|
605
677
|
|
|
606
678
|
History is persisted to `SessionStore` (`.jsonl` files) after each message. When a session is spawned after an idle restart, history is injected into the initial prompt so Claude resumes the conversation seamlessly.
|
|
@@ -625,12 +697,55 @@ While an agent is working, the gateway sends real-time status updates to Telegra
|
|
|
625
697
|
- **Elapsed time** — total time since the agent started working
|
|
626
698
|
- **Auto-cleanup** — status message is deleted when the agent finishes
|
|
627
699
|
|
|
628
|
-
Status updates are sent every 5-10 seconds (first update at 5s, then every 10s).
|
|
700
|
+
Status updates are sent every 5-10 seconds (first update at 5s, then every 10s). A single
|
|
701
|
+
message is **edited in place** for the whole turn; a tick with nothing new to show issues no
|
|
702
|
+
update at all, and the message is replaced only if it is deleted or becomes uneditable.
|
|
703
|
+
|
|
704
|
+
---
|
|
705
|
+
|
|
706
|
+
## Command Line (CLI)
|
|
707
|
+
|
|
708
|
+
The `claude-gateway` binary doubles as a command-line client for a running gateway — a friendlier alternative to hand-built `curl` calls. It works the same whether the gateway was started with `make start`, pm2, or systemd (it resolves the target from your config). Run it with no arguments to see what it can do; **only `gateway start` boots the server**.
|
|
709
|
+
|
|
710
|
+
```bash
|
|
711
|
+
claude-gateway # help (never starts a server)
|
|
712
|
+
claude-gateway gateway start # run the gateway in the foreground
|
|
713
|
+
claude-gateway gateway status # is it running? which manager owns it?
|
|
714
|
+
claude-gateway service install # run it as a systemd-user (or --manager pm2) service
|
|
715
|
+
claude-gateway update check # newer claude-gateway published?
|
|
716
|
+
claude-gateway claude update # update Claude Code via its own updater
|
|
717
|
+
claude-gateway doctor # check config / key / connectivity
|
|
718
|
+
claude-gateway agents create # interactive wizard — new agent + optional channel
|
|
719
|
+
claude-gateway channels pending --agent alfred # incoming Telegram/Discord pairing requests
|
|
720
|
+
claude-gateway crons list # friendly <noun> <verb> commands
|
|
721
|
+
claude-gateway crons run <jobId>
|
|
722
|
+
claude-gateway debug-bundle # small redacted bundle for a stuck session (works even if the server is down)
|
|
723
|
+
claude-gateway api GET /v1/agents # escape hatch: call any endpoint directly
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
> **Upgrading from < 1.8:** a service unit that runs the binary with no command still starts the
|
|
727
|
+
> gateway, with a deprecation warning. Point `ExecStart` at `claude-gateway gateway start`, or
|
|
728
|
+
> reinstall the unit with `claude-gateway service install`.
|
|
729
|
+
|
|
730
|
+
Working on the CLI itself? The globally installed `claude-gateway` is the published npm package, not
|
|
731
|
+
your checkout, so a bare `claude-gateway` still runs whatever version is on your `PATH`. Use `make cli`
|
|
732
|
+
to build and exercise the local sources instead:
|
|
733
|
+
|
|
734
|
+
```bash
|
|
735
|
+
make cli ARGS="--help"
|
|
736
|
+
make cli ARGS="gateway status"
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
Commands are **generated from the same route manifest the server mounts**, so every endpoint exposed as a friendly command stays in sync with the API automatically. Global flags: `--url`, `--key`, `--json`, `--data <json>`, `--help`.
|
|
740
|
+
|
|
741
|
+
See **[CLI.md](./CLI.md)** for the full command reference.
|
|
629
742
|
|
|
630
743
|
---
|
|
631
744
|
|
|
632
745
|
## HTTP API
|
|
633
746
|
|
|
747
|
+
> For day-to-day operation, prefer the **[CLI](#command-line-cli)** above (`claude-gateway <noun> <verb>`) — it resolves the URL and key for you and is easier to read. This section is the **raw HTTP reference** for programmatic clients and integrations.
|
|
748
|
+
|
|
634
749
|
When `gateway.api.keys` is configured, the gateway exposes a REST API for external clients.
|
|
635
750
|
|
|
636
751
|
Pass API key via `X-Api-Key: <key>` or `Authorization: Bearer <key>` header.
|
|
@@ -678,7 +793,7 @@ Pass API key via `X-Api-Key: <key>` or `Authorization: Bearer <key>` header.
|
|
|
678
793
|
| `POST` | `/api/v1/apps/:name/reconfigure` | Change env vars / host ports on an installed app, with rollback → `jobId` (admin) |
|
|
679
794
|
| `GET` | `/app/:name/:portName/*` | Reverse proxy to installed app (no auth) |
|
|
680
795
|
|
|
681
|
-
**Wizard API** — create agents programmatically with the same flow as the interactive `
|
|
796
|
+
**Wizard API** — create agents programmatically with the same flow as the interactive `claude-gateway agents create` terminal wizard. The wizard generates workspace files via Claude, writes them on confirm, and optionally pairs a Telegram/Discord bot. State is in-memory with a 30-minute TTL; nothing is written until `/confirm`. See [API.md](./API.md) for the full wizard flow.
|
|
682
797
|
|
|
683
798
|
See **[API.md](./API.md)** for full reference with request/response schemas and curl examples.
|
|
684
799
|
|
|
@@ -707,6 +822,8 @@ curl http://localhost:10850/api/v1/apps/jobs/<jobId> -H "X-Api-Key: <key>" | jq
|
|
|
707
822
|
|
|
708
823
|
Apps can also be installed from a GitHub URL (`github_url` + `commit`) or a local path (`local_path`) for development. Updates use a **blue-green swap with automatic rollback** — the old containers stay intact until the new version passes its healthcheck.
|
|
709
824
|
|
|
825
|
+
The swap carries live bind-mount data forward into the new app directory. A data directory the app's own container created is owned by that image's uid (postgres leaves its `pgdata` mode 0700), and `rename(2)` on a directory needs write permission on the directory itself — so the gateway user cannot move it. Those paths are moved by a throwaway root helper container instead, mounting the nearest common ancestor of the two app directories so the move stays a real rename rather than a copy; each escalation is logged in the job. If a rollback cannot move such a path back, the update does **not** restart the app on a half-restored directory: the `-failed-` directory holding the live data is kept, the job fails with `ROLLBACK FAILED`, and the log names the paths and the directory to recover them from. That directory is kept for good — the boot sweep that reclaims update scratch dirs skips release snapshots, because it deletes with `sudo rm -rf` and a snapshot can hold the only copy of a database. It reports them on the console instead. The pre-update image tags are restored before that decision and the private `cg-rollback-*` tags are kept, so finishing the recovery by hand starts the restored source on its own build, not on the failed release's.
|
|
826
|
+
|
|
710
827
|
**Reverse proxy configuration:**
|
|
711
828
|
|
|
712
829
|
The gateway proxies `/app/:name/:portName/*` to the app containers. Two env vars control how the gateway reaches them:
|
|
@@ -736,7 +853,7 @@ See **[API.md — App Store section](./API.md#app-store-api)** for the full refe
|
|
|
736
853
|
|
|
737
854
|
```
|
|
738
855
|
claude-gateway/
|
|
739
|
-
├── Makefile ← make start /
|
|
856
|
+
├── Makefile ← make start / cli / mcp-install / release / pm2-* / system-*
|
|
740
857
|
├── config.template.json ← config template (source of truth for migration)
|
|
741
858
|
│
|
|
742
859
|
├── src/ ← Gateway core (TypeScript, compiled to dist/)
|
|
@@ -800,12 +917,10 @@ claude-gateway/
|
|
|
800
917
|
│ └── web-ui.ts ← live HTML dashboard
|
|
801
918
|
│
|
|
802
919
|
├── scripts/
|
|
803
|
-
│ ├──
|
|
804
|
-
│ ├──
|
|
805
|
-
│ ├──
|
|
806
|
-
│
|
|
807
|
-
│ ├── pair.ts ← approve channel pairing (Telegram / Discord)
|
|
808
|
-
│ └── setup-claude-settings.js ← enables channelsEnabled in Claude Code
|
|
920
|
+
│ ├── gen-cli.ts ← generates src/cli/commands.generated.ts + CLI.md from the route registry
|
|
921
|
+
│ ├── mock-line-webhook.ts ← local LINE webhook simulator for dev testing
|
|
922
|
+
│ ├── release.sh ← interactive release (make release)
|
|
923
|
+
│ └── setup-claude-settings.js ← enables channelsEnabled in Claude Code
|
|
809
924
|
│
|
|
810
925
|
└── mcp/ ← MCP server (runs in Bun, separate node_modules)
|
|
811
926
|
├── package.json ← dependencies: grammy, @modelcontextprotocol/sdk
|
|
@@ -979,9 +1094,9 @@ toggle **on**, so pairing works out of the box — no setup needed.
|
|
|
979
1094
|
1. Ask the user to DM the bot — they receive a 6-character pairing code
|
|
980
1095
|
2. Approve it:
|
|
981
1096
|
```bash
|
|
982
|
-
|
|
1097
|
+
claude-gateway channels approve --agent alfred --channel discord --code abc123
|
|
983
1098
|
```
|
|
984
|
-
(
|
|
1099
|
+
(use `--channel telegram` for Telegram; omit `--channel` on `channels pending` to check both)
|
|
985
1100
|
3. The bot confirms pairing within 5 seconds
|
|
986
1101
|
4. Lock down after everyone is paired (optional) — turn the pairing toggle off
|
|
987
1102
|
so unknown senders are dropped silently (the base policy is already
|
|
@@ -998,7 +1113,7 @@ automatically on read to `{ dmPolicy: "allowlist", pairing: true }`.
|
|
|
998
1113
|
|
|
999
1114
|
To manage channels (add/remove Telegram or Discord) on an existing agent:
|
|
1000
1115
|
```bash
|
|
1001
|
-
|
|
1116
|
+
claude-gateway agents update # choose "Connect/update a channel" or "Disconnect a channel"
|
|
1002
1117
|
```
|
|
1003
1118
|
|
|
1004
1119
|
---
|
|
@@ -1150,8 +1265,10 @@ paired, the following commands are available in a private chat:
|
|
|
1150
1265
|
|
|
1151
1266
|
| Command | Description |
|
|
1152
1267
|
|---------|-------------|
|
|
1153
|
-
| `/model` | Show the current AI model |
|
|
1154
|
-
| `/models` | Switch AI model
|
|
1268
|
+
| `/model` | Show the current AI model. On Discord and LINE, `/model <id or alias>` also switches to any model in the list — an id the list does not contain is refused rather than written into `config.json`. **Direct messages only**: switching rewrites `config.json` for the whole agent and restarts every session in every chat, and the group access gates check the guild, channel and mention but never the user. Listing is unrestricted |
|
|
1269
|
+
| `/models` | Switch AI model. On Telegram this is an inline keyboard; selecting a model triggers a graceful restart and notifies when back online, and **Dismiss** closes the picker without changing the model. Discord and LINE have no inline keyboard, so they get the same list as text plus `/model <id or alias>` to pick from it |
|
|
1270
|
+
|
|
1271
|
+
The list behind both commands is the live catalog from `{ANTHROPIC_BASE_URL}/v1/models` when a base URL is configured, falling back to `gateway.models` in `config.json` — see [GET /api/v1/models](API.md#get-apiv1models). Before this, `config.json`'s list was written once at provisioning and never re-read, so a catalog that changed upstream could never reach the picker.
|
|
1155
1272
|
|
|
1156
1273
|
**Account**
|
|
1157
1274
|
|
|
@@ -1197,6 +1314,23 @@ npm test
|
|
|
1197
1314
|
npm run typecheck
|
|
1198
1315
|
```
|
|
1199
1316
|
|
|
1317
|
+
### Writing tests that wait
|
|
1318
|
+
|
|
1319
|
+
Two rules, enforced by `tests/unit/test-timing-hygiene.test.ts`:
|
|
1320
|
+
|
|
1321
|
+
- **Wait for a signal, never for a duration.** `createWatcher()` / `watchWorkspace()` /
|
|
1322
|
+
`watchSkills()` return a handle with a `ready` promise; the PTY wrapper announces itself
|
|
1323
|
+
with a `system/init` event. Sleeping "long enough" instead is a bet on how fast the machine
|
|
1324
|
+
is — and chokidar runs with `ignoreInitial: true`, so a write that lands before its initial
|
|
1325
|
+
scan finishes emits *nothing* and the test waits out its whole deadline for an event that
|
|
1326
|
+
will never arrive.
|
|
1327
|
+
- **Poll with the shared helper**, `tests/helpers/wait-for.ts`, rather than a local copy. Its
|
|
1328
|
+
timeout is a safety net sized so only a broken build hits it, and on a timeout it reports
|
|
1329
|
+
the predicate it was waiting on instead of a bare "timeout exceeded".
|
|
1330
|
+
|
|
1331
|
+
A fixed sleep is still fine for asserting that something *doesn't* happen — there the sleep
|
|
1332
|
+
only bounds how hard the test looks, so a slow machine can't turn correct behaviour red.
|
|
1333
|
+
|
|
1200
1334
|
---
|
|
1201
1335
|
|
|
1202
1336
|
## Troubleshooting
|
|
@@ -10,8 +10,8 @@ exports.BUILTIN_COMMANDS = {
|
|
|
10
10
|
clear: { channels: ['telegram', 'api'] },
|
|
11
11
|
compact: { channels: ['telegram', 'api'] },
|
|
12
12
|
stop: { channels: ['telegram', 'api'], wordBoundary: false },
|
|
13
|
-
model: { channels: ['telegram', 'discord', 'api'] },
|
|
14
|
-
models: { channels: ['telegram'] },
|
|
13
|
+
model: { channels: ['telegram', 'discord', 'line', 'api'] },
|
|
14
|
+
models: { channels: ['telegram', 'discord', 'line'] },
|
|
15
15
|
restart: { channels: ['telegram', 'api'], wordBoundary: false },
|
|
16
16
|
start: { channels: ['telegram'] },
|
|
17
17
|
help: { channels: ['telegram'] },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-commands.js","sourceRoot":"","sources":["../../src/agent/builtin-commands.ts"],"names":[],"mappings":";;;AAkDA,4CAEC;AA1CY,QAAA,gBAAgB,GAA+B;IAC1D,OAAO,EAAG,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE;IACtD,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE;IACtD,GAAG,EAAO,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE;IACpE,MAAM,EAAI,EAAE,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE;IACzD,KAAK,EAAK,EAAE,QA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;AAED,SAAgB,gBAAgB,CAAC,OAAe,EAAE,OAAuB;IACvE,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../../src/agent/dreaming/accept.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEtE,OAAO,KAAK,EAAE,aAAa,EAA0B,MAAM,SAAS,CAAC;AAKrE,MAAM,WAAW,aAAa;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,sHAAsH;IACtH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oFAAoF;IACpF,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,kDAAkD;IAClD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"accept.d.ts","sourceRoot":"","sources":["../../../src/agent/dreaming/accept.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEtE,OAAO,KAAK,EAAE,aAAa,EAA0B,MAAM,SAAS,CAAC;AAKrE,MAAM,WAAW,aAAa;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,sHAAsH;IACtH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oFAAoF;IACpF,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,eAAe,EAAE,MAAM,CAAC;IACxB,2EAA2E;IAC3E,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,kDAAkD;IAClD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AA6BD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,MAAM,GACT,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,CAAC,CA2BnD;AAED,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAsBlE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EACxB,IAAI,EAAE,aAAa,EACnB,GAAG,GAAE,MAAmB,GACvB,YAAY,CAoFd"}
|
|
@@ -85,7 +85,10 @@ function coerceProposal(o) {
|
|
|
85
85
|
return null;
|
|
86
86
|
if ((op === 'replace' || op === 'remove') && !target)
|
|
87
87
|
return null;
|
|
88
|
-
|
|
88
|
+
// A durable `topic` slug (issue #398) is optional and only used as the shared
|
|
89
|
+
// note's identity when promoting; an invalid one is dropped, never fatal.
|
|
90
|
+
const topic = (0, episodic_1.isValidTopicSlug)(o.topic) ? o.topic : undefined;
|
|
91
|
+
return { op, file, tier: 'durable', topic, target, content, reason, score, recallCount };
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
91
94
|
* Ordered proposals for a single run (matched by `ts`), each with its index —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/agent/dreaming/accept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"accept.js","sourceRoot":"","sources":["../../../src/agent/dreaming/accept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,4CA8BC;AAGD,4CAsBC;AAOD,oDA0FC;AA7OD;;;;;;;;;;;;;;;;;GAiBG;AACH,uCAAyB;AACzB,2CAA6B;AAC7B,mCAAuC;AACvC,uCAAsE;AACtE,yCAA8C;AAG9C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAc,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AACpE,MAAM,WAAW,GAAG,IAAI,GAAG,CAAY,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;AA0BjE,gFAAgF;AAChF,SAAS,cAAc,CAAC,CAA0B;IAChD,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAgB,CAAC;IAC7C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;I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AAE,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,YAAY;QACxC,eAAe,EAAE,OAAO,CAAC,MAAM;QAC/B,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KAC5E,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/agent/dreaming/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1G,oDAAoD;AACpD,eAAO,MAAM,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/agent/dreaming/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1G,oDAAoD;AACpD,eAAO,MAAM,kBAAkB,EAAE,oBAQhC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,mBAe/B,CAAC;AAsBF;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,CAAC,EAAE,eAAe,EAC1B,SAAS,CAAC,EAAE,eAAe,GAC1B,oBAAoB,CAoBtB;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,CAAC,EAAE,cAAc,EACzB,SAAS,CAAC,EAAE,cAAc,GACzB,mBAAmB,CA+BrB"}
|
|
@@ -20,6 +20,7 @@ exports.STALENESS_DEFAULTS = {
|
|
|
20
20
|
minRetrievalKeep: 1,
|
|
21
21
|
supersession: true,
|
|
22
22
|
recordRetrievals: true,
|
|
23
|
+
maxInvalidationsPerRun: 50,
|
|
23
24
|
};
|
|
24
25
|
exports.DREAMING_DEFAULTS = {
|
|
25
26
|
enabled: true,
|
|
@@ -76,6 +77,7 @@ function resolveStalenessConfig(agentCfg, globalCfg) {
|
|
|
76
77
|
minRetrievalKeep: numOr(pick(agentCfg?.minRetrievalKeep, globalCfg?.minRetrievalKeep, d.minRetrievalKeep), d.minRetrievalKeep, 0, Infinity),
|
|
77
78
|
supersession: bool(agentCfg?.supersession, globalCfg?.supersession, d.supersession),
|
|
78
79
|
recordRetrievals: bool(agentCfg?.recordRetrievals, globalCfg?.recordRetrievals, d.recordRetrievals),
|
|
80
|
+
maxInvalidationsPerRun: numOr(pick(agentCfg?.maxInvalidationsPerRun, globalCfg?.maxInvalidationsPerRun, d.maxInvalidationsPerRun), d.maxInvalidationsPerRun, 0, Infinity),
|
|
79
81
|
};
|
|
80
82
|
}
|
|
81
83
|
function resolveDreamingConfig(agentCfg, globalCfg) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/agent/dreaming/config.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/agent/dreaming/config.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAyDH,wDAuBC;AAED,sDAkCC;AAlHD,qDAA2D;AAG3D,oDAAoD;AACvC,QAAA,kBAAkB,GAAyB;IACtD,OAAO,EAAE,IAAI;IACb,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,CAAC;IACjB,gBAAgB,EAAE,CAAC;IACnB,YAAY,EAAE,IAAI;IAClB,gBAAgB,EAAE,IAAI;IACtB,sBAAsB,EAAE,EAAE;CAC3B,CAAC;AAEW,QAAA,iBAAiB,GAAwB;IACpD,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,MAAM,EAAE,4FAA4F;IAC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AO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA0C5B"}
|
|
@@ -24,7 +24,7 @@ Rules:
|
|
|
24
24
|
- A run that proposes NOTHING is a valid, good outcome.
|
|
25
25
|
|
|
26
26
|
Respond with STRICT JSON only (no prose, no markdown fences), matching:
|
|
27
|
-
{"summary":"one line describing what this dream found","proposals":[{"op":"add"|"replace"|"remove","file":"MEMORY.md"|"USER.md","target":"substring to match for replace/remove","content":"new text for add/replace","reason":"why","score":0.0-1.0,"recallCount":N}]}
|
|
27
|
+
{"summary":"one line describing what this dream found","proposals":[{"op":"add"|"replace"|"remove","file":"MEMORY.md"|"USER.md","target":"substring to match for replace/remove","content":"new text for add/replace","topic":"<lowercase-kebab-slug naming the FACT>","reason":"why","score":0.0-1.0,"recallCount":N}]}
|
|
28
28
|
|
|
29
29
|
- proposals: [] when nothing is worth changing.
|
|
30
30
|
- "add": provide file + content. "replace": provide file + target (existing substring) + content. "remove": provide file + target.
|
|
@@ -38,7 +38,8 @@ MEMORY TIERS — route each op by what it is:
|
|
|
38
38
|
- DURABLE semantic facts (user preferences, standing rules, identity, hard-won lessons — standing context needed in FUTURE unrelated sessions) → file "MEMORY.md" or "USER.md".
|
|
39
39
|
- EPISODIC task-log (a record of what HAPPENED: completed work, PR/issue status, dated events) → tier "episodic". NEVER put task-log in MEMORY.md.
|
|
40
40
|
- Litmus: "standing context for future unrelated sessions?" → MEMORY.md. "a record of a thing that happened?" → episodic.
|
|
41
|
-
For an EPISODIC op use exactly: {"op":"add","tier":"episodic","topic":"<lowercase-kebab-slug>","content":"...","reason":"...","score":0.0-1.0,"recallCount":N}. topic MUST match ^[a-z0-9-]{1,64}$. Episodic ops are always "add" (never replace/remove). Durable ops keep the "file" form above (no "tier" needed)
|
|
41
|
+
For an EPISODIC op use exactly: {"op":"add","tier":"episodic","topic":"<lowercase-kebab-slug>","content":"...","reason":"...","score":0.0-1.0,"recallCount":N}. topic MUST match ^[a-z0-9-]{1,64}$. Episodic ops are always "add" (never replace/remove). Durable ops keep the "file" form above (no "tier" needed).
|
|
42
|
+
On a durable "add", also set "topic" to a short kebab-slug naming the FACT itself (e.g. "deploy-requires-manual-bootstrap"), matching ^[a-z0-9-]{1,64}$. It names what the fact IS, so the same fact earns the same slug on a later night; "reason" stays free-form and must NOT be an editing instruction like "insert after the cron section".`;
|
|
42
43
|
function buildPrompt(input) {
|
|
43
44
|
const overBudget = typeof input.memoryChars === 'number' &&
|
|
44
45
|
typeof input.memoryBudget === 'number' &&
|
|
@@ -177,10 +178,16 @@ function coerceProposal(raw) {
|
|
|
177
178
|
return null;
|
|
178
179
|
if ((op === 'replace' || op === 'remove') && !target)
|
|
179
180
|
return null;
|
|
181
|
+
// An optional `topic` slug names the fact itself. Used as the shared-note
|
|
182
|
+
// identity when promoting (issue #398) — a far more stable key than `reason`,
|
|
183
|
+
// which is prompted as free-form justification. An invalid slug is dropped
|
|
184
|
+
// rather than rejecting the op: the durable write itself never needs it.
|
|
185
|
+
const durableTopic = (0, episodic_1.isValidTopicSlug)(o['topic']) ? o['topic'] : undefined;
|
|
180
186
|
return {
|
|
181
187
|
op: op,
|
|
182
188
|
file: file,
|
|
183
189
|
tier: 'durable',
|
|
190
|
+
topic: durableTopic,
|
|
184
191
|
target: target === undefined ? undefined : capStr(target),
|
|
185
192
|
content: content === undefined ? undefined : capStr(content),
|
|
186
193
|
reason: typeof o['reason'] === 'string' ? capStr(o['reason']) : '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewer.js","sourceRoot":"","sources":["../../../src/agent/dreaming/reviewer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;
|
|
1
|
+
{"version":3,"file":"reviewer.js","sourceRoot":"","sources":["../../../src/agent/dreaming/reviewer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAgGH,4CAEC;AA4GD,oCAWC;AAKD,4CA8CC;AA1QD,yDAAiF;AACjF,yCAA8C;AA0B9C,MAAM,a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