pi-durable-bot 0.4.1 → 0.5.1

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +16 -10
  3. package/dist/agent/agent.js +52 -34
  4. package/dist/agent/agent.js.map +1 -1
  5. package/dist/agent/children.js +11 -10
  6. package/dist/agent/children.js.map +1 -1
  7. package/dist/agent/memory.js +6 -2
  8. package/dist/agent/memory.js.map +1 -1
  9. package/dist/bot/bot.js.map +1 -1
  10. package/dist/bot/prompt.js +2 -1
  11. package/dist/bot/prompt.js.map +1 -1
  12. package/dist/channels/discord/index.js +955 -0
  13. package/dist/channels/discord/index.js.map +1 -0
  14. package/dist/channels/slack/index.js +83 -23
  15. package/dist/channels/slack/index.js.map +1 -1
  16. package/dist/channels/slack/sdk.js +12 -0
  17. package/dist/channels/slack/sdk.js.map +1 -1
  18. package/dist/channels/telegram/index.js +875 -0
  19. package/dist/channels/telegram/index.js.map +1 -0
  20. package/dist/channels/telegram/sdk.js +24 -0
  21. package/dist/channels/telegram/sdk.js.map +1 -0
  22. package/dist/channels/test/index.js +1 -1
  23. package/dist/channels/test/index.js.map +1 -1
  24. package/dist/cli/ai.js +55 -22
  25. package/dist/cli/ai.js.map +1 -1
  26. package/dist/cli/commands.js +2 -1
  27. package/dist/cli/commands.js.map +1 -1
  28. package/dist/cli/login.js +38 -0
  29. package/dist/cli/login.js.map +1 -0
  30. package/dist/core/channel.js +2 -1
  31. package/dist/core/channel.js.map +1 -1
  32. package/dist/gateway/channels.js +33 -4
  33. package/dist/gateway/channels.js.map +1 -1
  34. package/dist/gateway/gateway.js +1 -0
  35. package/dist/gateway/gateway.js.map +1 -1
  36. package/dist/gateway/inbox.js +31 -2
  37. package/dist/gateway/inbox.js.map +1 -1
  38. package/dist/gateway/log.js +3 -2
  39. package/dist/gateway/log.js.map +1 -1
  40. package/dist/gateway/outbox.js +3 -0
  41. package/dist/gateway/outbox.js.map +1 -1
  42. package/dist/main.js +10 -3
  43. package/dist/main.js.map +1 -1
  44. package/docs/channels/discord.md +60 -0
  45. package/docs/channels/slack.md +46 -0
  46. package/docs/channels/telegram.md +50 -0
  47. package/docs/for-agents.md +21 -19
  48. package/package.json +25 -14
@@ -12,16 +12,16 @@ Pots (the npm package `pi-durable-bot`, the command `pots`) is an open-source AI
12
12
  - **It decides when to act.** A mention or a DM wakes it at once. Every other message comes to it too, and it decides whether it is about its work; a judge can read those first and ask "is this about me, and should I respond?", using the bot's own list of responsibilities. The bot also sets its own timed wakes, such as "check Acme's pricing every Monday", and keeps them. Being woken does not mean speaking: most of the time the right answer is to stay quiet.
13
13
  - **It works on its own computer.** It has a shell, files, the internet and, when there is one, the screen, mouse and keyboard. It writes and runs the code it needs instead of waiting for someone to add a plugin. That covers research, reports, watching a web page, filling forms, and code.
14
14
  - **It remembers.** One long conversation runs across every channel. The bot saves what is worth keeping (preferences, rules, facts about people and the work, decisions) to its memory by itself, as Claude Code's automatic memory does: plain markdown files with an index, in its folder, and one more memory that the bots of the computer share about the person. People change that memory by talking to it. When the context gets full, the bot writes notes for itself and "turns the page"; its memory comes along. Its persona and responsibilities are plain files it edits itself.
15
- - **It survives crashes.** Every step is journaled ([pi-durable](https://github.com/earendil-works/pi)). Every incoming event is on disk before it is acknowledged. Every outgoing message has a send ID, so the bot never sends the same message twice.
15
+ - **It survives crashes.** Every step is journaled ([pi-durable](https://github.com/earendil-works/pi)). Every incoming event is on disk before it is acknowledged. Every outgoing message has a send ID, so the bot never sends the same message twice (on Telegram, a crash at the moment of a send can repeat it).
16
16
  - **It is open and yours.** It is MIT-licensed and runs on the person's own machine. It can use a subscription they already pay for (ChatGPT, Claude, GitHub Copilot, Grok, Kimi and more), an API key from any of 40+ providers, or a local model (Ollama, LM Studio, llama.cpp). The data stays on their machine, in each bot's folder. One machine can run several bots, each with its own name, persona and memory.
17
17
 
18
- Slack works today, and so does the person's own terminal (`pots chat`). Discord, Teams, Telegram and email are next. The [README](../README.md) has the full picture, a demo video and diagrams.
18
+ Slack, Discord and Telegram work today, and so does the person's own terminal (`pots chat`). Teams and email are next. The [README](../README.md) has the full picture, a demo video and diagrams.
19
19
 
20
20
  ## The one thing to get right: the bot sets itself up
21
21
 
22
- Once `pots init` is done, **the bot connects its chat apps itself**. For each app, it creates what that platform needs (on Slack, a Slack app), gets the tokens, writes its own `bot.json` and asks the person only for what it cannot do, such as signing in or approving an install.
22
+ Once the bot is made, **it connects its chat apps itself**. For each app, it creates what that platform needs (on Slack, a Slack app), gets the tokens, writes its own `bot.json` and asks the person only for what it cannot do, such as signing in or approving an install.
23
23
 
24
- So do not create the chat app (such as a Slack app), write a manifest, collect tokens or edit `~/.pots/` by hand for your person, and do not tell them to do any of that first. Your job is to get Pots installed and `pots init` done. After that, hand the person over to their bot: they say "join our Slack" in `pots chat`, and the bot does the rest.
24
+ So do not create the chat app (such as a Slack app), write a manifest, collect tokens or edit `~/.pots/` by hand for your person, and do not tell them to do any of that first. Your job is to install Pots and make the bot, as below. After that, hand the person over to their bot: they say "join our Slack" in `pots chat`, and the bot does the rest.
25
25
 
26
26
  On a computer without a desktop, such as a cloud server reached over SSH, the bot still does this. It explains the choices and lets the person pick:
27
27
 
@@ -33,29 +33,30 @@ When it needs tokens the person copied, it asks for them in `pots chat` with hid
33
33
 
34
34
  ## Before you start
35
35
 
36
- - **The bot gets full control of the computer it runs on**, as the user who runs `pots init`. It runs commands, installs software and uses the screen, with no approval step. Tell your person this, and recommend a computer or VM of its own. `pots init` asks them to confirm it too.
36
+ - **The bot gets full control of the computer it runs on**, as the user who runs `pots init`. It runs commands, installs software and uses the screen, with no approval step. Tell your person this, recommend a computer or VM of its own, and go on only when they agree: `pots init --yes` accepts it for them.
37
37
  - **Set it up on the computer where the bot will live.** If your person reaches a server over SSH, the commands run there, not on their laptop.
38
38
  - **Requirements:** Node.js 24 or newer, on macOS, Linux or Windows. Windows also needs [Git for Windows](https://git-scm.com/download/win).
39
39
 
40
40
  ## Set it up
41
41
 
42
- ```sh
43
- npm install -g pi-durable-bot
44
- pots init
45
- ```
46
-
47
- `pots init` asks four things: the bot's name, how it gets its AI, who decides on group messages that do not mention the bot (the bot itself by default, or a judge such as Jev, with a TypeSafe API key), and one optional sentence about what it is for. Then it starts the gateway as a background service (launchd on macOS, a systemd user service on Linux, Task Scheduler on Windows), and the person is talking to their bot in the terminal.
48
-
49
- `pots init` is interactive and needs a real terminal, and your own shell is probably not one. There are two ways to handle that:
50
-
51
- 1. **Ask your person to run `pots init` in their own terminal. Prefer this.** Signing in with a subscription opens a browser, or on a server, prints a link and asks for a code (choose "Copy code login (headless)" when it is offered). Only the person can do that. The steps take about a minute.
52
- 2. **Run it without questions** if pi already has a login or key for a model on this computer (in `~/.pi/agent/`; `pi --list-models` lists them when the pi command line is installed):
42
+ Do the setup yourself, in your own shell. Only one step is your person's: signing in to a model. A subscription sign-in opens their browser, and an API key must not pass through your conversation, so they do it in their own terminal with `pots login`.
43
+
44
+ 1. **Install:** `npm install -g pi-durable-bot`.
45
+ 2. **Ask your person**, in your chat:
46
+ - the bot's name;
47
+ - in one sentence, what it is for (optional; the bot asks them later if they skip it);
48
+ - how it should get its AI: a subscription they already pay for (ChatGPT, Claude, GitHub Copilot, Grok, Kimi and more), an API key from a provider, or a local model server (Ollama, LM Studio, llama.cpp, vLLM);
49
+ - who decides whether a group message that does not mention the bot wakes it: the bot itself (the default: every such message wakes it), or Jev, a fast judge from TypeSafe that wakes it only for messages about its work, with their TypeSafe API key.
50
+ 3. **See what pi can use already:** `pots login --list`. It lists the models (for `--model`) and judges (for `--judge`) that have a login, a key or a local server on this computer, and never shows a secret.
51
+ 4. **If what they chose is not listed, ask them to run `pots login` in their own terminal.** It asks how to get the AI, signs in or takes the key with hidden input, tries a model, and ends with a line such as `Ready: openai/gpt-6.1-sol`. On a computer without a browser, such as a server over SSH, it prints a link and asks for the code the page shows (choose "Copy code login (headless)" when it is offered). For Jev, they run it once more and choose "Use an API key", then TypeSafe. Then run `pots login --list` again.
52
+ 5. **Make the bot:**
53
53
  ```sh
54
- pots init --yes --name "Ada" --model anthropic/claude-opus-5-5 --about "our team's research and ops assistant" --no-chat
54
+ pots init --yes --name "Ada" --model openai/gpt-6.1-sol --about "our team's research and ops assistant" --no-chat
55
55
  ```
56
- Without `--judge`, every group message that does not mention the bot wakes it; `--judge typesafe/jev-latest` uses Jev when pi has a TypeSafe API key. Then tell your person to run `pots chat` to meet the bot.
56
+ Add `--judge typesafe/jev-latest` for Jev. `pots init` tries the model and the judge before it makes the bot, then starts the gateway as a background service (launchd on macOS, a systemd user service on Linux, Task Scheduler on Windows). On Linux it turns on lingering for the user (with `sudo` when the system asks for it), so the bot keeps running after your person logs out of SSH; `pots init --system` installs a system service instead (it needs sudo).
57
+ 6. **Hand over:** tell your person to run `pots chat` to meet the bot. It says hello, checks the screen and asks which chat apps to join.
57
58
 
58
- On Linux, `pots init` turns on lingering for the user (with `sudo` when the system asks for it), so the bot keeps running after your person logs out of SSH; there is no need to run `loginctl enable-linger` yourself. `pots init --system` installs a system service instead (it needs sudo).
59
+ A person without an AI agent runs `pots init` alone instead: it asks the same things in the terminal, signs in, and opens the chat at the end.
59
60
 
60
61
  ## After setup
61
62
 
@@ -67,6 +68,7 @@ Tell your person:
67
68
 
68
69
  | Command | What it does |
69
70
  |---|---|
71
+ | `pots login` | Sign in to a model, or add an API key or a local server (in a terminal); `--list` shows what can be used |
70
72
  | `pots status` | The gateway, the service and each bot |
71
73
  | `pots service logs` | The gateway's output |
72
74
  | `pots trace` | What a bot did: its last wakes, or one wake from its events to the messages it sent |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-durable-bot",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "Open-source AI coworkers that read every channel, decide what matters, and act on their own computer. Self-hosted, any model.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -44,23 +44,34 @@
44
44
  "prepare": "npm run build"
45
45
  },
46
46
  "dependencies": {
47
- "@chat-adapter/slack": "4.43.0",
48
- "@chat-adapter/state-memory": "4.43.0",
49
- "@earendil-works/chord": "1.4.0",
50
- "@earendil-works/pi-ai": "1.4.0",
51
- "@earendil-works/pi-coding-agent": "1.4.0",
52
- "@earendil-works/pi-durable": "1.4.0",
53
- "@earendil-works/pi-telemetry": "1.4.0",
54
- "@effect/platform-node": "4.0.7",
55
- "@effect/platform-node-shared": "4.0.7",
56
- "chat": "4.43.0",
57
- "effect": "4.0.7"
47
+ "@chat-adapter/discord": "4.44.0",
48
+ "@chat-adapter/slack": "4.44.0",
49
+ "@chat-adapter/state-memory": "4.44.0",
50
+ "@chat-adapter/telegram": "4.44.0",
51
+ "@earendil-works/chord": "1.5.0",
52
+ "@earendil-works/pi-ai": "1.5.0",
53
+ "@earendil-works/pi-coding-agent": "1.5.0",
54
+ "@earendil-works/pi-durable": "1.5.0",
55
+ "@earendil-works/pi-schema": "1.5.0",
56
+ "@earendil-works/pi-telemetry": "1.5.0",
57
+ "@effect/platform-node": "4.1.2",
58
+ "@effect/platform-node-shared": "4.1.2",
59
+ "chat": "4.44.0",
60
+ "discord.js": "14.28.1",
61
+ "effect": "4.1.2"
58
62
  },
59
63
  "devDependencies": {
60
- "@effect/vitest": "4.0.7",
64
+ "@effect/vitest": "4.1.2",
61
65
  "@types/node": "26.6.5",
66
+ "@types/ws": "8.18.2",
62
67
  "fast-check": "4.10.2",
63
68
  "typescript": "7.0.2",
64
- "vitest": "5.0.5"
69
+ "vitest": "5.1.0",
70
+ "ws": "8.22.1"
71
+ },
72
+ "overrides": {
73
+ "@earendil-works/chord": {
74
+ "ws": "$ws"
75
+ }
65
76
  }
66
77
  }