thepopebot 1.2.76-beta.8 → 1.2.77
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 +147 -124
- package/api/CLAUDE.md +21 -10
- package/api/index.js +170 -57
- package/bin/CLAUDE.md +7 -4
- package/bin/cli.js +44 -67
- package/bin/docker-build.js +80 -53
- package/bin/sync.js +18 -1
- package/config/CLAUDE.md +24 -4
- package/config/instrumentation.js +29 -1
- package/drizzle/0022_organic_apocalypse.sql +16 -0
- package/drizzle/0023_needy_ender_wiggin.sql +1 -0
- package/drizzle/0024_third_moondragon.sql +3 -0
- package/drizzle/0025_common_psylocke.sql +51 -0
- package/drizzle/0026_parched_king_bedlam.sql +1 -0
- package/drizzle/meta/0021_snapshot.json +639 -0
- package/drizzle/meta/0022_snapshot.json +743 -0
- package/drizzle/meta/0023_snapshot.json +750 -0
- package/drizzle/meta/0024_snapshot.json +771 -0
- package/drizzle/meta/0025_snapshot.json +734 -0
- package/drizzle/meta/0026_snapshot.json +742 -0
- package/drizzle/meta/_journal.json +35 -0
- package/lib/CLAUDE.md +4 -2
- package/lib/actions.js +3 -1
- package/lib/ai/CLAUDE.md +75 -57
- package/lib/ai/helper-llm.js +108 -0
- package/lib/ai/index.js +375 -459
- package/lib/ai/line-mappers.js +47 -26
- package/lib/ai/scope.js +26 -0
- package/lib/ai/sdk-adapters/CLAUDE.md +4 -3
- package/lib/ai/sdk-adapters/claude-code.js +34 -14
- package/lib/ai/system-prompt.js +23 -5
- package/lib/ai/workspace-setup.js +32 -99
- package/lib/auth/CLAUDE.md +13 -0
- package/lib/auth/actions.js +15 -22
- package/lib/auth/index.js +20 -0
- package/lib/channels/CLAUDE.md +14 -4
- package/lib/channels/base.js +6 -2
- package/lib/channels/commands/index.js +42 -0
- package/lib/channels/commands/session.js +53 -0
- package/lib/channels/commands/verify.js +18 -0
- package/lib/channels/telegram.js +79 -28
- package/lib/chat/CLAUDE.md +14 -10
- package/lib/chat/actions.js +286 -96
- package/lib/chat/api.js +89 -26
- package/lib/chat/components/CLAUDE.md +22 -15
- package/lib/chat/components/app-sidebar.js +7 -20
- package/lib/chat/components/app-sidebar.jsx +28 -26
- package/lib/chat/components/chat-input.js +45 -23
- package/lib/chat/components/chat-input.jsx +42 -20
- package/lib/chat/components/chat-page.js +2 -0
- package/lib/chat/components/chat-page.jsx +3 -0
- package/lib/chat/components/chat.js +97 -95
- package/lib/chat/components/chat.jsx +66 -53
- package/lib/chat/components/code-mode-toggle.js +141 -72
- package/lib/chat/components/code-mode-toggle.jsx +148 -96
- package/lib/chat/components/containers-page.js +58 -40
- package/lib/chat/components/containers-page.jsx +64 -25
- package/lib/chat/components/crons-page.js +17 -3
- package/lib/chat/components/crons-page.jsx +34 -6
- package/lib/chat/components/index.js +4 -4
- package/lib/chat/components/message.js +16 -1
- package/lib/chat/components/message.jsx +16 -1
- package/lib/chat/components/messages-page.js +138 -0
- package/lib/chat/components/messages-page.jsx +180 -0
- package/lib/chat/components/profile-page.js +428 -47
- package/lib/chat/components/profile-page.jsx +476 -63
- package/lib/chat/components/scope-picker.js +21 -0
- package/lib/chat/components/scope-picker.jsx +27 -0
- package/lib/chat/components/settings-chat-page.js +11 -11
- package/lib/chat/components/settings-chat-page.jsx +14 -18
- package/lib/chat/components/settings-coding-agents-page.js +152 -16
- package/lib/chat/components/settings-coding-agents-page.jsx +125 -3
- package/lib/chat/components/settings-github-page.js +5 -0
- package/lib/chat/components/settings-github-page.jsx +5 -0
- package/lib/chat/components/settings-jobs-page.js +42 -28
- package/lib/chat/components/settings-jobs-page.jsx +43 -27
- package/lib/chat/components/settings-layout.js +3 -3
- package/lib/chat/components/settings-layout.jsx +3 -3
- package/lib/chat/components/settings-secrets-layout.js +1 -2
- package/lib/chat/components/settings-secrets-layout.jsx +1 -2
- package/lib/chat/components/settings-secrets-page.js +180 -75
- package/lib/chat/components/settings-secrets-page.jsx +212 -66
- package/lib/chat/components/settings-shared.js +2 -2
- package/lib/chat/components/settings-shared.jsx +2 -2
- package/lib/chat/components/triggers-page.js +17 -3
- package/lib/chat/components/triggers-page.jsx +34 -6
- package/lib/chat/components/ui/dropdown-menu.js +23 -2
- package/lib/chat/components/ui/dropdown-menu.jsx +27 -2
- package/lib/chat/telegram-profile.js +34 -0
- package/lib/cluster/CLAUDE.md +9 -3
- package/lib/code/CLAUDE.md +21 -3
- package/lib/code/actions.js +35 -22
- package/lib/code/code-page.js +1 -1
- package/lib/code/code-page.jsx +3 -1
- package/lib/code/terminal-view.js +63 -43
- package/lib/code/terminal-view.jsx +49 -27
- package/lib/config.js +19 -4
- package/lib/containers/CLAUDE.md +17 -6
- package/lib/containers/logs.js +12 -0
- package/lib/cron.js +32 -4
- package/lib/db/CLAUDE.md +21 -7
- package/lib/db/chats.js +15 -7
- package/lib/db/code-workspaces.js +2 -1
- package/lib/db/config.js +0 -1
- package/lib/db/index.js +12 -0
- package/lib/db/messages.js +117 -0
- package/lib/db/schema.js +46 -24
- package/lib/db/user-channels.js +152 -0
- package/lib/db/users.js +32 -16
- package/lib/git-commands.js +41 -0
- package/lib/llm-providers.js +8 -0
- package/lib/tools/CLAUDE.md +18 -5
- package/lib/tools/assemblyai.js +17 -0
- package/lib/tools/create-agent-job.js +26 -8
- package/lib/tools/docker.js +19 -3
- package/lib/tools/github.js +31 -6
- package/lib/tools/telegram.js +106 -0
- package/lib/triggers.js +38 -1
- package/lib/utils/render-md.js +43 -17
- package/package.json +8 -7
- package/setup/CLAUDE.md +28 -17
- package/setup/lib/providers.mjs +2 -1
- package/setup/lib/targets.mjs +13 -16
- package/setup/setup.mjs +42 -34
- package/templates/.env.example +0 -7
- package/templates/.github/workflows/notify-pr-complete.yml +5 -1
- package/templates/.github/workflows/rebuild-event-handler.yml +1 -6
- package/templates/.gitignore.template +0 -2
- package/templates/CLAUDE.md.template +28 -6
- package/templates/agent-job/CLAUDE.md.template +11 -4
- package/templates/agent-job/CRONS.json +16 -0
- package/templates/agent-job/SYSTEM.md +17 -9
- package/templates/agents/CLAUDE.md.template +17 -17
- package/templates/data/CLAUDE.md.template +1 -1
- package/templates/docker-compose.custom.yml +1 -0
- package/templates/docker-compose.yml +1 -0
- package/templates/event-handler/CLAUDE.md.template +84 -0
- package/templates/event-handler/TRIGGERS.json +18 -2
- package/templates/skills/CLAUDE.md.template +12 -119
- package/templates/skills-library/CLAUDE.md.template +151 -0
- package/templates/skills-library/agent-job-background/SKILL.md +34 -0
- package/templates/skills-library/agent-job-background/agent-job-background.js +78 -0
- package/templates/skills-library/agent-job-dm/SKILL.md +55 -0
- package/templates/skills-library/agent-job-dm/agent-job-dm.js +81 -0
- package/templates/skills-library/agent-job-secrets/SKILL.md +23 -0
- package/templates/skills-library/agent-job-secrets/agent-job-secrets.js +68 -0
- package/lib/ai/agent.js +0 -65
- package/lib/ai/async-channel.js +0 -51
- package/lib/ai/model.js +0 -130
- package/lib/ai/tools.js +0 -167
- package/lib/chat/components/notifications-page.js +0 -89
- package/lib/chat/components/notifications-page.jsx +0 -126
- package/lib/db/notifications.js +0 -104
- package/lib/tools/openai.js +0 -37
- package/setup/lib/telegram-verify.mjs +0 -63
- package/setup/lib/telegram.mjs +0 -76
- package/setup/setup-telegram.mjs +0 -260
- package/templates/skills/active/.gitkeep +0 -0
- package/templates/skills/library/agent-job-secrets/SKILL.md +0 -23
- package/templates/skills/library/agent-job-secrets/agent-job-secrets.js +0 -62
- /package/templates/{skills/library → skills-library}/playwright-cli/SKILL.md +0 -0
package/README.md
CHANGED
|
@@ -1,194 +1,217 @@
|
|
|
1
|
-
#
|
|
1
|
+
# thepopebot
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Your personal agent, coding environment, and communication platform — all in
|
|
4
|
+
one app. Works with any LLM or coding agent. Designed to be simple, unified,
|
|
5
|
+
secure, and easy.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
- 💬 **Smart chat integrations** — Telegram today; Slack and Discord coming soon. Plus the built-in web chat.
|
|
8
|
+
- 🧠 **Any LLM** — Anthropic, OpenAI, Google, DeepSeek, MiniMax, Mistral, xAI, Kimi, OpenRouter, NVIDIA, or any OpenAI-compatible endpoint.
|
|
9
|
+
- 🤖 **Any coding agent** — Claude Code, Codex, Gemini, OpenCode, Pi, or Kimi.
|
|
10
|
+
- 💻 **Live coding workspaces** — open a terminal in your browser, attach to a running container, share the same session as your chat.
|
|
11
|
+
- 🔧 **Real work, not just chat** — agent writes code, opens a PR, auto-merges, DMs you when it's done.
|
|
12
|
+
- 🔐 **Yours, fully** — runs on your hardware, your repo, your tokens.
|
|
6
13
|
|
|
7
|
-
-
|
|
8
|
-
- **Does real work** — writes code, opens pull requests, completes multi-step tasks end to end
|
|
9
|
-
- **Agent clusters** — build teams of agents that coordinate and work together on bigger jobs
|
|
10
|
-
- **Full visibility** — every action is a commit you can review, approve, or undo
|
|
11
|
-
|
|
12
|
-
<a href="https://www.skool.com/ai-architects"><img src="docs/hero.png" width="100" alt="ThePopeBot" /></a>
|
|
14
|
+
<a href="https://www.skool.com/ai-architects"><img src="docs/hero.png" width="100" alt="thepopebot" /></a>
|
|
13
15
|
|
|
14
16
|
[Get priority support HERE](https://www.skool.com/ai-architects)
|
|
15
17
|
|
|
16
18
|
---
|
|
17
19
|
|
|
18
|
-
## How
|
|
20
|
+
## How it works
|
|
21
|
+
|
|
22
|
+
Three doors, one brain:
|
|
19
23
|
|
|
20
24
|
```
|
|
21
|
-
|
|
22
|
-
│
|
|
23
|
-
│
|
|
24
|
-
│ │
|
|
25
|
-
│ │
|
|
26
|
-
│
|
|
27
|
-
│
|
|
28
|
-
│
|
|
29
|
-
│
|
|
30
|
-
│
|
|
31
|
-
│
|
|
32
|
-
|
|
33
|
-
│
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
│
|
|
38
|
-
│
|
|
39
|
-
│
|
|
40
|
-
│
|
|
41
|
-
│ │
|
|
42
|
-
│
|
|
43
|
-
│
|
|
44
|
-
│
|
|
45
|
-
│
|
|
46
|
-
|
|
47
|
-
│ 5 (notify-pr-complete.yml → │
|
|
48
|
-
│ │ webhook to event handler) │
|
|
49
|
-
│ └──────────────────────────► Event Handler │
|
|
50
|
-
│ │
|
|
51
|
-
└──────────────────────────────────────────────────────────────────────┘
|
|
25
|
+
┌── Browser chat ──┐ ┌── Telegram (verified per-user)
|
|
26
|
+
│ ▼ ▼
|
|
27
|
+
│ ┌──────────────────────────────────┐
|
|
28
|
+
│ attach │ The Brain │
|
|
29
|
+
│ a live │ (your event handler) │
|
|
30
|
+
│ terminal │ │
|
|
31
|
+
│ │ • picks the coding agent │
|
|
32
|
+
│ │ • picks the coding agent │
|
|
33
|
+
│ │ • remembers the session │
|
|
34
|
+
│ │ • runs Docker for you │
|
|
35
|
+
└── Code ────┤ │
|
|
36
|
+
workspace └──────────────┬───────────────────┘
|
|
37
|
+
│
|
|
38
|
+
┌────────┴────────┐
|
|
39
|
+
▼ ▼
|
|
40
|
+
┌─────────────┐ ┌─────────────────┐
|
|
41
|
+
│ Live chat │ │ Agent job │
|
|
42
|
+
│ (right now) │ │ (background) │
|
|
43
|
+
│ │ │ │
|
|
44
|
+
│ same coding │ │ same coding │
|
|
45
|
+
│ agent runs │ │ agent runs in │
|
|
46
|
+
│ in-process │ │ a fresh Docker │
|
|
47
|
+
│ or in a │ │ container, │
|
|
48
|
+
│ headless │ │ opens a PR, │
|
|
49
|
+
│ container │ │ DMs you back │
|
|
50
|
+
└─────────────┘ └─────────────────┘
|
|
52
51
|
```
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
### Live chat vs. agent job
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
| Path | When | What happens |
|
|
56
|
+
|----------------|-------------------------------|----------------------------------------------------|
|
|
57
|
+
| **Live chat** | Quick questions, small edits | Coding agent runs now, streams to your screen |
|
|
58
|
+
| **Agent job** | "Build it. DM me when done." | Background worker opens a PR, auto-merges, DMs you |
|
|
57
59
|
|
|
58
|
-
|
|
60
|
+
### Two flavors of chat (`chatMode`)
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
| `chatMode` | Repo & branch | Use it for |
|
|
63
|
+
|------------|----------------------------|---------------------------------------------|
|
|
64
|
+
| `agent` | Your bot's own repo | Talking *to* your bot — config, skills, ops |
|
|
65
|
+
| `code` | Any repo + branch you pick | Real coding sessions on a project |
|
|
66
|
+
|
|
67
|
+
### Live coding workspaces
|
|
68
|
+
|
|
69
|
+
Open a workspace from any code-mode chat and the browser attaches a terminal
|
|
70
|
+
to a persistent container running your coding agent of choice. Workspace and
|
|
71
|
+
chat share the same session — fire a question in chat, hop into the terminal,
|
|
72
|
+
the agent already knows what you were just talking about.
|
|
73
|
+
|
|
74
|
+
### When you ask for a job
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
you ──► chat ──► event handler ──► creates `agent-job/<id>` branch
|
|
78
|
+
│
|
|
79
|
+
▼
|
|
80
|
+
launches a Docker container
|
|
81
|
+
locally (your chosen agent)
|
|
82
|
+
│
|
|
83
|
+
▼
|
|
84
|
+
agent commits, pushes,
|
|
85
|
+
opens a PR
|
|
86
|
+
│
|
|
87
|
+
▼
|
|
88
|
+
auto-merge.yml ──► merged
|
|
89
|
+
│
|
|
90
|
+
▼
|
|
91
|
+
notify-pr-complete.yml ──► DM to you
|
|
92
|
+
```
|
|
61
93
|
|
|
62
94
|
---
|
|
63
95
|
|
|
64
|
-
##
|
|
96
|
+
## Install
|
|
65
97
|
|
|
66
98
|
### Prerequisites
|
|
67
99
|
|
|
68
100
|
| Requirement | Install |
|
|
69
101
|
|-------------|---------|
|
|
70
102
|
| **Node.js 18+** | [nodejs.org](https://nodejs.org) |
|
|
71
|
-
| **npm** | Included with Node.js |
|
|
72
103
|
| **Git** | [git-scm.com](https://git-scm.com) |
|
|
73
104
|
| **GitHub CLI** | [cli.github.com](https://cli.github.com) |
|
|
74
|
-
| **Docker + Docker Compose** | [docker.com](https://docs.docker.com/get-docker/)
|
|
75
|
-
| **ngrok*** | [ngrok.com](https://ngrok.com/download) (free account + authtoken
|
|
105
|
+
| **Docker + Docker Compose** | [docker.com](https://docs.docker.com/get-docker/) |
|
|
106
|
+
| **ngrok*** | [ngrok.com](https://ngrok.com/download) (free account + authtoken) |
|
|
76
107
|
|
|
77
|
-
*\*ngrok is only
|
|
108
|
+
*\*ngrok is only needed for local installs without port forwarding. VPS/cloud deployments don't need it.*
|
|
78
109
|
|
|
79
110
|
### Two steps
|
|
80
111
|
|
|
81
|
-
**Step 1** — Scaffold a new project:
|
|
82
|
-
|
|
83
112
|
```bash
|
|
84
113
|
mkdir my-agent && cd my-agent
|
|
85
|
-
npx thepopebot@latest init
|
|
114
|
+
npx thepopebot@latest init # scaffold project
|
|
115
|
+
npm run setup # interactive wizard
|
|
86
116
|
```
|
|
87
117
|
|
|
88
|
-
|
|
118
|
+
The wizard checks prerequisites, creates a GitHub repo, generates a PAT, configures your URL, and starts Docker. Visit your APP_URL when it finishes.
|
|
119
|
+
|
|
120
|
+
> **Local installs**: your server needs to be reachable from the internet for GitHub webhooks and Telegram. Use [ngrok](https://ngrok.com) (`ngrok http 80`). If your ngrok URL changes, run `npx thepopebot set-var APP_URL <new-url>` and re-register the Telegram webhook from `/admin/event-handler/telegram`.
|
|
89
121
|
|
|
90
|
-
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Upgrade
|
|
91
125
|
|
|
92
126
|
```bash
|
|
93
|
-
|
|
127
|
+
npx thepopebot upgrade # latest stable
|
|
128
|
+
npx thepopebot upgrade @beta # latest beta
|
|
129
|
+
npx thepopebot upgrade 1.2.72 # specific version
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Installs the new package, syncs managed files, rebuilds, restarts Docker.
|
|
133
|
+
|
|
134
|
+
### What's protected, what gets updated
|
|
135
|
+
|
|
136
|
+
Two kinds of files behave differently — by design, so an upgrade never blows
|
|
137
|
+
away your customizations.
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
┌─ Managed files ──────────────┐ ┌─ Your files ─────────────────┐
|
|
141
|
+
│ .github/workflows/ │ │ agent-job/SYSTEM.md │
|
|
142
|
+
│ docker-compose.yml │ │ agent-job/CRONS.json │
|
|
143
|
+
│ .gitignore │ │ event-handler/TRIGGERS.json │
|
|
144
|
+
│ │ │ agents/ │
|
|
145
|
+
│ Always replaced with the │ │ skills-library/, skills/ │
|
|
146
|
+
│ latest version on every │ │ .env, secrets │
|
|
147
|
+
│ init / upgrade. │ │ Never touched by upgrade. │
|
|
148
|
+
└──────────────────────────────┘ └──────────────────────────────┘
|
|
94
149
|
```
|
|
95
150
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
- Creates a GitHub repository and pushes your initial commit
|
|
99
|
-
- Creates a GitHub Personal Access Token (scoped to your repo)
|
|
100
|
-
- Configures your public URL and webhook secret
|
|
101
|
-
- Syncs settings to `.env`, database, and GitHub secrets/variables
|
|
102
|
-
- Starts Docker for you
|
|
151
|
+
So you never lose your work — but you might miss a useful template change.
|
|
152
|
+
Three commands let you pull updates in deliberately:
|
|
103
153
|
|
|
104
|
-
|
|
154
|
+
```bash
|
|
155
|
+
npx thepopebot audit # show what's drifted from the templates
|
|
156
|
+
npx thepopebot diff <file> # show the diff for one file
|
|
157
|
+
npx thepopebot reset <file> # replace one file with the latest template
|
|
158
|
+
npx thepopebot reset-all # ⚠ nuclear: wipe local edits, restore everything
|
|
159
|
+
```
|
|
105
160
|
|
|
106
|
-
|
|
107
|
-
- **Telegram** (optional): Run `npm run setup-telegram` to connect a Telegram bot
|
|
108
|
-
- **Webhook**: Send a POST to `/api/create-agent-job` with your API key to create jobs programmatically
|
|
109
|
-
- **Cron**: Edit `agent-job/CRONS.json` to schedule recurring jobs
|
|
161
|
+
Use them when release notes mention a SYSTEM.md or workflow improvement you want.
|
|
110
162
|
|
|
111
|
-
|
|
163
|
+
> **Upgrade failed?** See [Recovering from a Failed Upgrade](docs/UPGRADE.md#recovering-from-a-failed-upgrade).
|
|
112
164
|
|
|
113
|
-
|
|
165
|
+
---
|
|
114
166
|
|
|
115
|
-
|
|
167
|
+
## How LLMs are wired
|
|
116
168
|
|
|
117
|
-
|
|
169
|
+
Two slots, you pick whether they share a model.
|
|
118
170
|
|
|
119
|
-
|
|
171
|
+
- **Coding agent** — drives **everything you actually talk to**: live chat in the browser/Telegram, code workspaces, and background agent jobs. One agent, one model. For Claude Code the chat runs in-process via the Claude Agent SDK; for any other agent (Pi, Codex, Gemini, OpenCode, Kimi) it runs in an ephemeral headless container — same chunk shape either way. Configured at `/admin/event-handler/coding-agents`.
|
|
172
|
+
- **Helper LLM** — small one-shot calls only: chat auto-titles, agent-job titles, PR-merge summaries. Independent provider/model from the coding agent. Configured at `/admin/event-handler/helper-llm`.
|
|
120
173
|
|
|
121
|
-
|
|
174
|
+
A coding-agent task can override its model per-run via `agent_backend` + `llm_model` on a cron, trigger, or chained agent job.
|
|
122
175
|
|
|
123
|
-
|
|
176
|
+
### Using a Claude subscription
|
|
124
177
|
|
|
125
|
-
|
|
178
|
+
If you have Claude Pro or Max, you can power Claude Code with your subscription instead of API billing. Generate a token:
|
|
126
179
|
|
|
127
180
|
```bash
|
|
128
|
-
# Install Claude Code CLI (if you don't have it)
|
|
129
181
|
npm install -g @anthropic-ai/claude-code
|
|
130
|
-
|
|
131
|
-
# Generate your token (opens browser to log in)
|
|
132
182
|
claude setup-token
|
|
133
183
|
```
|
|
134
184
|
|
|
135
|
-
Paste
|
|
136
|
-
|
|
137
|
-
See [Coding Agents](docs/CODING_AGENTS.md) for details on all five agent backends.
|
|
185
|
+
Paste it (starts with `sk-ant-oat01-`) into Admin > Event Handler > Coding Agents > Claude Code (auth mode: OAuth). The same token drives live chat *and* background agent jobs — no separate API key needed for chat. Add multiple tokens and they rotate LRU on each container launch.
|
|
138
186
|
|
|
139
|
-
|
|
140
|
-
>
|
|
141
|
-
> **If your ngrok URL changes** (it changes every time you restart ngrok on the free plan), you must update APP_URL everywhere:
|
|
142
|
-
>
|
|
143
|
-
> ```bash
|
|
144
|
-
> # Update .env and GitHub variable in one command:
|
|
145
|
-
> npx thepopebot set-var APP_URL https://your-new-url.ngrok.io
|
|
146
|
-
> # If Telegram is configured, re-register the webhook:
|
|
147
|
-
> npm run setup-telegram
|
|
148
|
-
> ```
|
|
187
|
+
See [Coding Agents](docs/CODING_AGENTS.md) for details on all six agent backends.
|
|
149
188
|
|
|
150
189
|
---
|
|
151
190
|
|
|
152
|
-
##
|
|
191
|
+
## Connect Telegram (optional)
|
|
153
192
|
|
|
154
|
-
|
|
155
|
-
npx thepopebot upgrade # latest stable
|
|
156
|
-
npx thepopebot upgrade @beta # latest beta
|
|
157
|
-
npx thepopebot upgrade 1.2.72 # specific version
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Saves your local changes, syncs with GitHub, installs the new version, rebuilds, pushes, and restarts Docker.
|
|
161
|
-
|
|
162
|
-
**What it does:**
|
|
193
|
+
Talk to your bot from your phone. Two steps:
|
|
163
194
|
|
|
164
|
-
1.
|
|
165
|
-
2.
|
|
166
|
-
3. Installs the new version and updates project files
|
|
167
|
-
4. Rebuilds your project
|
|
168
|
-
5. Pushes everything to GitHub
|
|
169
|
-
6. Restarts Docker containers (if running)
|
|
195
|
+
1. **Wire up the bot** — at `/admin/event-handler/telegram`, paste the bot token from [@BotFather](https://t.me/BotFather) and click **Register webhook**.
|
|
196
|
+
2. **Verify your account** — at `/profile/telegram`, generate a one-time code and send `/verify <code>` to your bot. The bot only responds to verified users; unbound chats are silently dropped.
|
|
170
197
|
|
|
171
|
-
|
|
198
|
+
Once verified: `/session` lists your active threads, `/session <id>` switches the thread your messages route to. Voice notes are transcribed when an `ASSEMBLYAI_API_KEY` is set in `/admin/event-handler/voice`.
|
|
172
199
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
See [CLI Reference](docs/CLI.md) for full details on `init`, managed vs user files, template conventions, and all CLI commands.
|
|
200
|
+
See [Chat Integrations](docs/CHAT_INTEGRATIONS.md) for the channel adapter pattern and how to add new channels (Slack, Discord coming soon).
|
|
176
201
|
|
|
177
202
|
---
|
|
178
203
|
|
|
179
204
|
## Security
|
|
180
205
|
|
|
181
|
-
thepopebot includes API key authentication, webhook secret validation (fail-closed), session encryption,
|
|
206
|
+
thepopebot includes API key authentication, webhook secret validation (fail-closed), session encryption (AES-256-GCM keyed off `AUTH_SECRET`), per-job API keys with maintenance-cron expiry, and auto-merge path restrictions. All software carries risk — thepopebot is provided as-is, and you are responsible for securing your own infrastructure. If you're running locally with a tunnel, your dev server endpoints are publicly accessible with no rate limiting and no TLS on the local hop.
|
|
182
207
|
|
|
183
|
-
See [Security](docs/SECURITY.md) for full details
|
|
208
|
+
See [Security](docs/SECURITY.md) for full details.
|
|
184
209
|
|
|
185
210
|
---
|
|
186
211
|
|
|
187
|
-
##
|
|
188
|
-
|
|
189
|
-
thepopebot supports 9 built-in LLM providers (Anthropic, OpenAI, Google, DeepSeek, MiniMax, Mistral, xAI, Kimi, OpenRouter) plus custom OpenAI-compatible endpoints. The chat layer and coding agents are independent — use Claude for interactive chat and a different model for code tasks, or run everything on a single provider.
|
|
212
|
+
## Star History
|
|
190
213
|
|
|
191
|
-
|
|
214
|
+
[](https://www.star-history.com/#stephengpope/thepopebot&type=date&legend=top-left)
|
|
192
215
|
|
|
193
216
|
---
|
|
194
217
|
|
|
@@ -198,8 +221,8 @@ See [Different Models](docs/RUNNING_DIFFERENT_MODELS.md) for the full provider r
|
|
|
198
221
|
|
|
199
222
|
SQLite can't create or open its shared-memory (`.shm`) file. Common causes:
|
|
200
223
|
|
|
201
|
-
- **Antivirus**
|
|
202
|
-
- **Cloud-synced folders** (OneDrive, Dropbox, Google Drive) — move your project to a non-synced directory
|
|
224
|
+
- **Antivirus** locking the database — add your project folder to the exclusion list
|
|
225
|
+
- **Cloud-synced folders** (OneDrive, Dropbox, Google Drive) — move your project to a non-synced directory
|
|
203
226
|
|
|
204
227
|
---
|
|
205
228
|
|
|
@@ -209,13 +232,13 @@ SQLite can't create or open its shared-memory (`.shm`) file. Common causes:
|
|
|
209
232
|
|----------|-------------|
|
|
210
233
|
| [Architecture](docs/ARCHITECTURE.md) | Two-layer design, file structure, API endpoints, GitHub Actions, Docker agent |
|
|
211
234
|
| [CLI Reference](docs/CLI.md) | `init`, managed vs user files, template conventions, all CLI commands |
|
|
212
|
-
| [Configuration](docs/CONFIGURATION.md) | Admin UI, DB-backed config, infrastructure variables,
|
|
213
|
-
| [Customization](docs/CUSTOMIZATION.md) | Personality, skills, operating system files, using your bot
|
|
235
|
+
| [Configuration](docs/CONFIGURATION.md) | Admin UI, DB-backed config, infrastructure variables, Docker Compose |
|
|
236
|
+
| [Customization](docs/CUSTOMIZATION.md) | Personality, skills, operating system files, using your bot |
|
|
214
237
|
| [Chat Integrations](docs/CHAT_INTEGRATIONS.md) | Web chat, Telegram, adding new channels |
|
|
215
|
-
| [Different Models](docs/RUNNING_DIFFERENT_MODELS.md) |
|
|
238
|
+
| [Different Models](docs/RUNNING_DIFFERENT_MODELS.md) | 10 built-in LLM providers, helper LLM vs coding agent split, per-job overrides, custom providers |
|
|
216
239
|
| [Auto-Merge](docs/AUTO_MERGE.md) | Auto-merge controls, ALLOWED_PATHS configuration |
|
|
217
240
|
| [Deployment](docs/DEPLOYMENT.md) | VPS setup, Docker Compose, HTTPS with Let's Encrypt |
|
|
218
|
-
| [Coding Agents](docs/CODING_AGENTS.md) |
|
|
241
|
+
| [Coding Agents](docs/CODING_AGENTS.md) | 6 coding agent backends, OAuth tokens, LiteLLM proxy, per-agent config |
|
|
219
242
|
| [How to Build Skills](docs/HOW_TO_BUILD_SKILLS.md) | Guide to building and activating agent skills |
|
|
220
243
|
| [Pre-Release](docs/PRE_RELEASE.md) | Installing beta/alpha builds |
|
|
221
244
|
| [Code Workspaces](docs/CODE_WORKSPACES.md) | Interactive Docker containers with in-browser terminal |
|
package/api/CLAUDE.md
CHANGED
|
@@ -4,31 +4,42 @@ This directory contains the route handlers for all `/api/*` endpoints. These rou
|
|
|
4
4
|
|
|
5
5
|
## Auth
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Most routes require a valid API key passed via the `x-api-key` header. API keys are stored in the SQLite database and managed through the admin UI — they are NOT environment variables.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
**Public routes** (no API key needed): `/ping`, `/telegram/webhook` (Telegram webhook secret), `/github/webhook` (GitHub webhook secret), `/oauth/callback` (validated via short-lived `state` token).
|
|
10
|
+
|
|
11
|
+
Auth flow: `x-api-key` header → `verifyApiKey()` → DB lookup (hashed, timing-safe comparison). Two key types exist:
|
|
12
|
+
|
|
13
|
+
- **User-owned API keys** — long-lived, created via the admin UI, used by external callers (cURL, GitHub Actions, Telegram register).
|
|
14
|
+
- **Per-job agent API keys** (`agent_job_api_key`) — short-lived, auto-created when an agent-job container launches (`createAgentJobApiKey()` in `lib/db/api-keys.js`), tied to the container name, and cleaned up by the maintenance cron after expiry. Routes that read agent-job secrets (`/api/get-agent-job-secret`, `/api/agent-job-list-secrets`) reject any other key type.
|
|
10
15
|
|
|
11
16
|
## Do NOT use these routes for browser UI
|
|
12
17
|
|
|
13
18
|
Browser-facing data fetching uses **fetch route handlers** colocated with pages (`route.js` files in `web/app/`). These check `auth()` session — never use `/api` routes from the browser. Server actions (`'use server'`) are used only for **mutations** (rename, delete, star, config updates) — never for data fetching (causes page refresh issues). Handler implementations live in `lib/chat/api.js`; route files are thin re-exports.
|
|
14
19
|
|
|
20
|
+
Mutation server actions in `lib/chat/actions.js` use `requireAdmin()` for settings/config writes and `requireAuth()` for chat CRUD on user-owned rows. Reads stay open to any logged-in user. Sidebar items like Upgrade are gated on `user.role === 'admin'`.
|
|
21
|
+
|
|
15
22
|
| Caller | Mechanism | Auth |
|
|
16
23
|
|--------|-----------|------|
|
|
17
24
|
| External (cURL, GitHub Actions, Telegram) | `/api` route | `x-api-key` header |
|
|
18
25
|
| Browser UI (data fetching) | Fetch route handler colocated with page | `auth()` session |
|
|
19
|
-
| Browser UI (mutations) | Server action | `requireAuth()`
|
|
20
|
-
| Browser UI (streaming) | `/stream/chat`, `/stream/containers`, `/stream/cluster/*/logs` | `auth()` session |
|
|
26
|
+
| Browser UI (mutations) | Server action | `requireAuth()` / `requireAdmin()` |
|
|
27
|
+
| Browser UI (streaming) | `/stream/chat`, `/stream/containers`, `/stream/containers/logs`, `/stream/cluster/*/logs` | `auth()` session |
|
|
21
28
|
|
|
22
29
|
## Routes
|
|
23
30
|
|
|
24
31
|
| Method | Path | Auth | Handler |
|
|
25
32
|
|--------|------|------|---------|
|
|
26
33
|
| GET | `/api/ping` | None | Health check |
|
|
27
|
-
| POST | `/api/create-agent-job` | `x-api-key` | Create agent job |
|
|
28
|
-
| GET | `/api/get-agent-job-secret` | `
|
|
29
|
-
| GET | `/api/agent-job-list-secrets` | `
|
|
34
|
+
| POST | `/api/create-agent-job` | `x-api-key` | Create agent job. Body: `{ agent_job, llm_model?, agent_backend?, scope?, user_id? }`. `user_id` attributes the job to that user — the PR-merge webhook reads it back to DM the originator instead of broadcasting. |
|
|
35
|
+
| GET | `/api/get-agent-job-secret` | `agent_job_api_key` only | Get an agent job secret. `key` query param is upper-cased before lookup (admin form already saves uppercase). `oauth2` credentials return only the access_token (auto-refreshed under a per-key lock; rotated refresh tokens are persisted back). Other secret types return the raw value. |
|
|
36
|
+
| GET | `/api/agent-job-list-secrets` | `agent_job_api_key` only | List agent job secret keys (no values); returns `{secrets: [{key, isSet, updatedAt, secretType}]}` |
|
|
30
37
|
| GET | `/api/agent-jobs/status` | `x-api-key` | Agent job status (query: `?agent_job_id=`) |
|
|
31
|
-
|
|
|
32
|
-
| POST | `/api/
|
|
33
|
-
| POST | `/api/
|
|
38
|
+
| GET | `/api/users` | `x-api-key` | List users with verified DM channels: `{users: [{id, email, first_name, last_name, nickname, role, channels: ['telegram', ...]}]}`. Used by the `agent-job-dm` skill. |
|
|
39
|
+
| POST | `/api/send-dm` | `x-api-key` | Dispatch a message. Body: `{ user_id?, message, payload?, system_message? }`. With `user_id`: write 1 row + push to that user's default channel. Without: fan out 1 row per admin where `subscribedToSystemMessages=1`, each pushed to their default channel. `system_message: true` (default false) marks it as a system notification — channels with `systemMessagesEnabled=0` skip the push (inbox row still written). Returns `{ok, recipients}`. |
|
|
40
|
+
| POST | `/api/telegram/webhook` | Telegram webhook secret | Telegram message handler (per-user routing via `user_channels`; verifies via `/verify <code>`, dispatches `/session` commands) |
|
|
41
|
+
| POST | `/api/github/webhook` | GitHub webhook secret | GitHub event handler. PR-merge events read `user_id` from `agent-job.config.json` and dispatch the completion message via `dispatchMessage` (per-user when set; broadcast to subscribed admins when absent). Agent-job completions are broadcasts, not system messages — they always push regardless of per-channel `systemMessagesEnabled`. |
|
|
34
42
|
| POST | `/api/cluster/:clusterId/role/:roleId/webhook` | `x-api-key` | Trigger cluster role execution |
|
|
43
|
+
| GET/POST | `/api/oauth/callback` | `state` token | OAuth provider redirect target. Exchanges `code` for tokens, persists via `setAgentJobSecret(name, stored, 'oauth')`. |
|
|
44
|
+
|
|
45
|
+
Telegram bot configuration (token + webhook registration) is done from the admin UI at `/admin/event-handler/telegram`, not via an API route.
|