pi-durable-bot 0.7.2 → 0.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/CHANGELOG.md +26 -0
- package/README.md +10 -2
- package/dist/agent/agent.js +2 -1
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/scopes.js +267 -0
- package/dist/agent/scopes.js.map +1 -0
- package/dist/agent/screen.js +37 -2
- package/dist/agent/screen.js.map +1 -1
- package/dist/bot/bot.js +58 -11
- package/dist/bot/bot.js.map +1 -1
- package/dist/bot/definition.js +7 -0
- package/dist/bot/definition.js.map +1 -1
- package/dist/bot/prompt.js +26 -9
- package/dist/bot/prompt.js.map +1 -1
- package/dist/cli/bots.js +69 -5
- package/dist/cli/bots.js.map +1 -1
- package/dist/cli/chat.js +59 -4
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/commands.js +23 -2
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/init.js +4 -19
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/pages.js +25 -6
- package/dist/cli/pages.js.map +1 -1
- package/dist/cli/service.js +30 -1
- package/dist/cli/service.js.map +1 -1
- package/dist/main.js +8 -0
- package/dist/main.js.map +1 -1
- package/dist/pages/desktop-page.js +293 -0
- package/dist/pages/desktop-page.js.map +1 -0
- package/dist/pages/desktop.js +672 -0
- package/dist/pages/desktop.js.map +1 -0
- package/dist/pages/host.js +55 -2
- package/dist/pages/host.js.map +1 -1
- package/dist/pages/rfb.js +389 -0
- package/dist/pages/rfb.js.map +1 -0
- package/dist/pages/server.js +172 -1
- package/dist/pages/server.js.map +1 -1
- package/dist/pages/store.js +26 -4
- package/dist/pages/store.js.map +1 -1
- package/docs/for-agents.md +17 -2
- package/kit/desktop/desktop.css +1010 -0
- package/kit/desktop/desktop.js +1421 -0
- package/kit/desktop/novnc/AUTHORS +13 -0
- package/kit/desktop/novnc/LICENSE.BSD-2-Clause +22 -0
- package/kit/desktop/novnc/LICENSE.BSD-3-Clause +24 -0
- package/kit/desktop/novnc/LICENSE.MPL-2.0 +373 -0
- package/kit/desktop/novnc/LICENSE.OFL-1.1 +91 -0
- package/kit/desktop/novnc/LICENSE.pako +21 -0
- package/kit/desktop/novnc/LICENSE.txt +62 -0
- package/kit/desktop/novnc.js +14404 -0
- package/package.json +5 -5
- package/skills/desktop-page/SKILL.md +153 -0
- package/skills/discord-channel/SKILL.md +4 -4
- package/skills/pages/SKILL.md +9 -4
- package/skills/slack-channel/SKILL.md +6 -5
- package/skills/telegram-channel/SKILL.md +4 -4
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-durable-bot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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
|
-
"license": "MIT",
|
|
5
|
+
"license": "MIT AND MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"homepage": "https://github.com/Crokily/pi-durable-bot#readme",
|
|
8
8
|
"repository": {
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"@effect/platform-node-shared": "4.1.2",
|
|
71
71
|
"chat": "4.44.0",
|
|
72
72
|
"discord.js": "14.28.1",
|
|
73
|
-
"effect": "4.1.2"
|
|
73
|
+
"effect": "4.1.2",
|
|
74
|
+
"ws": "8.22.1"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
77
|
"@effect/vitest": "4.1.2",
|
|
@@ -78,8 +79,7 @@
|
|
|
78
79
|
"@types/ws": "8.18.2",
|
|
79
80
|
"fast-check": "4.10.2",
|
|
80
81
|
"typescript": "7.0.2",
|
|
81
|
-
"vitest": "5.1.0"
|
|
82
|
-
"ws": "8.22.1"
|
|
82
|
+
"vitest": "5.1.0"
|
|
83
83
|
},
|
|
84
84
|
"overrides": {
|
|
85
85
|
"@earendil-works/chord": {
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: desktop-page
|
|
3
|
+
description: "The desktop page, a one-time link with which a person sees and controls your screen from their phone or computer, does one step, and hands it back to you. Use when a step needs a person on your screen, such as a sign-in with their password or a code, a CAPTCHA, an approval or a choice only they can make. Also how to set up the VNC server it needs, on Linux, macOS and Windows, how to set up a screen of your own on a Linux computer whose desktop other bots already use, and what to know when you drive a Linux desktop."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# The desktop page
|
|
7
|
+
|
|
8
|
+
`pots page desktop` gives you a link to a page of Pots' own. The person who opens it sees your whole screen and controls it with their mouse and keyboard, or their fingers on a phone, does the step, and hands the desktop back. It works through a VNC server that shows your screen on this computer: Pots signs in to it itself, so its password never leaves this computer. They see what you see: the browser's own bars and prompts, other apps, and every site signed in there.
|
|
9
|
+
|
|
10
|
+
## The screen they get
|
|
11
|
+
|
|
12
|
+
- They see the screen as you leave it: the window in front, the page at the step, the field you clicked.
|
|
13
|
+
- When the VNC server can change the desktop's size, the desktop takes the shape of their screen while they use it, at least 500 pixels wide, so a phone held upright makes it tall and narrow; it gets its own size back at the end. A maximized window follows the new size; other windows keep theirs and may reach past the edge.
|
|
14
|
+
- Whether it can change size depends on the VNC server: TigerVNC's Xvnc can; x0vncserver only when its X server can take the new size; most others cannot. Then their page shows the desktop as it is, fitted to their screen, and they zoom in with two fingers; `--area` starts them zoomed in on the part that matters.
|
|
15
|
+
|
|
16
|
+
## Make a link
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pots page desktop --text "Sign in to LinkedIn with your password. If a check comes, solve it. Then press Done." --for slack:@U123 --input password
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
| Flag | What it does |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `--text` | What they should do, and that they press Done when it is done. Line breaks show as you write them: put each of several steps on its own line (a newline in the argument), and a line that starts with a number or a bullet reads as a list. |
|
|
25
|
+
| `--for <person address>` | The person the link is for. The wake then says which link was used, never who used it. |
|
|
26
|
+
| `--input password\|code\|text` | What the step asks them to type. On a phone, their typing field becomes a password field that their password manager can fill, a one-time code field (phones offer a code that came by text message), or a text field. |
|
|
27
|
+
| `--area x,y,width,height` | A part of your screen in its pixels now, such as the sign-in box from a screenshot. When the desktop cannot change size, their page starts zoomed in there. |
|
|
28
|
+
| `--minutes <1-60>` | How long the link works after they press Start. Default 15. |
|
|
29
|
+
|
|
30
|
+
Make the link for the person where they will open it, and send it there. When their request reached you through another bot or the terminal, but they work in Slack, that is their Slack address, and a DM to it.
|
|
31
|
+
|
|
32
|
+
It prints JSON: `{"link": "D1", "url": "https://…/d/<token>/", "expires": "<time>", "via": …, "note": …}`. `expires` is when the link stops working if nobody presses Start: one hour after you made it. Pots checks first that it reaches the VNC server of bot.json; when it does not, the command fails with the reason, and no link is made. `note` comes with a Quick Tunnel.
|
|
33
|
+
|
|
34
|
+
## What the person sees
|
|
35
|
+
|
|
36
|
+
- Your text, when the link ends, what the link can do, and a Start button. Nothing of the desktop shows before Start, so a platform's link preview shows nothing; still turn previews off.
|
|
37
|
+
- The first browser that presses Start keeps the link. It can open the link again, after a reload or when the phone was in another app, until the link ends; any other browser is told that the link is open on another device.
|
|
38
|
+
- The picture fills their screen. A group of buttons floats on it: one with the time left, keyboard (on a phone), more, and Done. At the start your text shows in full next to them for a few seconds, then folds into the first button; a tap on it shows the text again. They can drag the group to any edge of the screen, and it stays there. On a phone: a tap clicks, a drag drags, a long press right-clicks, two fingers scroll, and a pinch zooms the picture, not the page under it. The keyboard button opens a field that sends each character as they type it; an input method's characters, such as Chinese, go when they are chosen. More gives Esc, Tab, Enter, arrows, select all, paste, a trackpad mode and the picture's size. On a computer, their keyboard types straight in, and ⌘ on a Mac becomes Ctrl.
|
|
39
|
+
- Done asks whether the step is done or they could not do it, with an optional note for you. Then the page says they can close it.
|
|
40
|
+
- With a Quick Tunnel, the page says that Cloudflare can see the screen and what they type.
|
|
41
|
+
|
|
42
|
+
## While it is in use
|
|
43
|
+
|
|
44
|
+
- From Start until the link ends, the person holds your screen: screen commands, yours, your children's and those of other bots on this screen, do not run, and say why.
|
|
45
|
+
- `pots page list` lists the link under `desktopLinks`: its state (`open`, `started`, `done`, `cannot`, `expired`), when it ends, and whether a browser is connected now.
|
|
46
|
+
- `pots page unlink D1` ends it at once: their page closes, the desktop gets its size back, and no wake comes.
|
|
47
|
+
|
|
48
|
+
## When you are woken
|
|
49
|
+
|
|
50
|
+
You are woken once when the link ends, and once if the person cannot reach your desktop, as a timed wake with one of these notes:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
desktop page: someone handed your desktop back on link D1 (made for slack:@U123) and pressed Done: the step is done, they say. Their note: "…". The screen is yours again. Its size is back to 1280×775, as at Start.
|
|
54
|
+
desktop page: someone handed your desktop back on link D1 (made for …) without doing the step: they pressed "I can't do it". They left no note. The screen is yours again.
|
|
55
|
+
desktop page: link D1 (made for …) ended at <time>, 15 minutes after Start, and nobody pressed Done. The screen is yours again.
|
|
56
|
+
desktop page: link D1 (made for …) expired at <time>: nobody pressed Start within an hour.
|
|
57
|
+
desktop page: someone pressed Start on link D1 (made for …), but Pots could not reach your desktop: <why>. Their page says so; the link still works, and Start tries again.
|
|
58
|
+
desktop page: the person on link D1 (made for …) lost your desktop: Pots could not reach it: <why>. Their page tries again by itself until the link ends.
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The last two mean that the VNC server does not answer, or bot.json's `vnc` does not lead to it. The person's page goes on by itself once it answers.
|
|
62
|
+
|
|
63
|
+
- Done is what the person says; a screenshot shows what happened.
|
|
64
|
+
- The note is the person's own text.
|
|
65
|
+
|
|
66
|
+
## What the person should know
|
|
67
|
+
|
|
68
|
+
- The link controls your whole desktop, with every site signed in there, and works for whoever has it until someone presses Start. A DM to the person it is for keeps it with them.
|
|
69
|
+
- With a Quick Tunnel (`"via": "quick-tunnel"`), Cloudflare can see the screen and every key they type. Tell them so each time, as with a password page, and offer Tailscale Funnel; the pages skill says how to set it up.
|
|
70
|
+
- A passkey on their own phone or computer cannot be used through a remote view of any kind. An account you use is easier to sign in to from here when it keeps a password with a code from an authenticator app, a text message or an email; tell them when an account has only a passkey.
|
|
71
|
+
|
|
72
|
+
## Set up the VNC server
|
|
73
|
+
|
|
74
|
+
Pots connects only to a VNC server on this computer, at 127.0.0.1, and signs in with no password (None) or the VNC password (VncAuth). Find out first what runs: `ss -ltnp | grep -E ':59[0-9][0-9]'` on Linux, `lsof -iTCP -sTCP:LISTEN | grep -i vnc` on macOS, `netstat -ano | findstr :5900` on Windows. A VNC server that the person already uses from their network stays as it is unless they want it changed: ask first. A new one should listen on this computer only.
|
|
75
|
+
|
|
76
|
+
Then add to bot.json, next to `screen`:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
"vnc": {"port": 5900, "passwordFile": "vnc.env"}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- `passwordFile` is a file name in the secrets folder, or a path (`~/` works). The file holds `VNC_PASSWORD=<password>`, as `pots page secret --file vnc.env --keys VNC_PASSWORD` writes it, or it is a password file as `vncpasswd` writes it. VNC uses the first 8 characters of a password.
|
|
83
|
+
- Leave `passwordFile` out only for a server that asks for no password, which must then listen on this computer only.
|
|
84
|
+
- bot.json changes apply within seconds. Then `pots page desktop` checks the server when it makes a link.
|
|
85
|
+
|
|
86
|
+
| Computer | A VNC server for its screen |
|
|
87
|
+
|---|---|
|
|
88
|
+
| Linux with an X11 desktop | TigerVNC's `x0vncserver` shares the running desktop: `x0vncserver -display :0 -localhost -rfbport 5900 -SecurityTypes VncAuth -PasswordFile ~/.vnc/passwd`, with the password from `vncpasswd ~/.vnc/passwd`. `x11vnc -display :0 -localhost -rfbauth ~/.vnc/passwd -forever -shared` works too. Run it as a user service, so it starts again after a restart. |
|
|
89
|
+
| Linux with a Wayland desktop | `wayvnc` for wlroots desktops (Sway, Hyprland), GNOME Remote Desktop's VNC backend, or TigerVNC's `w0vncserver` (1.16 and newer). |
|
|
90
|
+
| Linux with no desktop | A virtual desktop: TigerVNC's `Xvnc :1 -geometry 1280x800 -localhost -rfbport 5901 -SecurityTypes VncAuth -PasswordFile ~/.vnc/passwd`, a window manager and the browser on `DISPLAY=:1`; then `"screen": {"DISPLAY": ":1"}` and `"vnc": {"port": 5901, …}` in bot.json. Xvnc can change its size for the person's screen. The packages need sudo (on Ubuntu, `tigervnc-standalone-server`). |
|
|
91
|
+
| macOS | Screen Sharing, turned on by the person: System Settings, General, Sharing, Screen Sharing, the info button, "VNC viewers may control screen with password", and a password. It listens on port 5900. Take the password with `pots page secret --file vnc.env --keys VNC_PASSWORD`. |
|
|
92
|
+
| Windows | A VNC server such as TightVNC, with a password. TightVNC refuses connections from the same computer until "Allow loopback connections" is on in its Access Control settings; "Allow only loopback connections" keeps it off the network. |
|
|
93
|
+
|
|
94
|
+
What the desktop page cannot do: sound, file transfer, and copying from the desktop to a phone. Whether a phone's Chinese, Japanese or Korean characters arrive depends on the VNC server: TigerVNC's do.
|
|
95
|
+
|
|
96
|
+
## A screen of your own on a computer that already has a desktop
|
|
97
|
+
|
|
98
|
+
Only one agent can use a screen at a time, also across bots, so bots that share the desktop wait for each other. On Linux you can have a screen of your own next to it: a virtual desktop with its own browser, which the person reaches with a desktop page link like any other. It takes about 0.5–1 GB of memory with its browser. On macOS and Windows a second screen is not practical: bots take turns on the one desktop.
|
|
99
|
+
|
|
100
|
+
Here is a setup that works on a Linux computer with systemd, from a bot that runs its own screen this way on display `:2`. Below, `<id>` is your bot ID (your folder's name), and `:2` and port 5902 stand for a display and a port that nothing else uses: `ls /tmp/.X11-unix/` lists the displays in use (`X0` is `:0`), and the VNC port is 5900 plus the display's number.
|
|
101
|
+
|
|
102
|
+
- **Packages**, once, with sudo: TigerVNC's Xvnc and a light window manager, on Ubuntu and Debian `tigervnc-standalone-server` and `openbox`. Check first with `command -v Xvnc openbox`: when they are installed, there is nothing to install. Without a window manager, windows have no frames and do not take focus as they should. Installing one can change the system's `x-window-manager` alternative; if it did (`update-alternatives --display x-window-manager`), set it back, so the person's desktop stays as it was.
|
|
103
|
+
- **A VNC password of your own**, in a file in the secrets folder, readable only by you: `vncpasswd -f > ~/.pots/secrets/<id>-vnc.passwd` reads the password from standard input. VNC uses its first 8 characters.
|
|
104
|
+
- **A D-Bus session bus of your own.** Without one, programs on your screen use the session bus of the person's desktop, and the keyring's password prompt, file choosers from a portal and notifications open on their screen, not yours. Run a `dbus-daemon` with a config file of your own: `<type>session</type>`, `<listen>unix:path=/run/user/<uid>/<id>-bus</listen>`, `<auth>EXTERNAL</auth>`, a policy that allows everything, and no service directories, so that no service starts on it by itself. Then set `DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/<uid>/<id>-bus` for everything on your screen.
|
|
105
|
+
- **A browser profile of your own.** For Chrome: `--user-data-dir=~/.config/<id>-chrome`, not the person's profile: with theirs, Chrome opens the window in the browser that already runs, on their desktop; `--password-store=basic`, so it asks for no keyring, whose prompt would open on the other desktop; `--no-first-run --no-default-browser-check`. What you sign in to stays in that profile. One browser is enough; open tabs in it.
|
|
106
|
+
- **systemd user units**, one each for the bus, Xvnc, the window manager and the browser, so that they start again when the computer restarts and do not stop with Pots: what your commands leave running stops when Pots' service is stopped, and does not come back after the computer restarts. Turn on lingering, so that they run without a login: `loginctl show-user $USER -p Linger`, and `sudo loginctl enable-linger $USER` when it says no.
|
|
107
|
+
|
|
108
|
+
```ini
|
|
109
|
+
# ~/.config/systemd/user/<id>-xvnc.service
|
|
110
|
+
[Unit]
|
|
111
|
+
Description=<Name>'s desktop: Xvnc on :2, VNC on 127.0.0.1:5902
|
|
112
|
+
|
|
113
|
+
[Service]
|
|
114
|
+
ExecStart=/usr/bin/Xvnc :2 -geometry 1280x800 -depth 24 -nolisten tcp -localhost -rfbport 5902 -SecurityTypes VncAuth -PasswordFile %h/.pots/secrets/<id>-vnc.passwd -AlwaysShared
|
|
115
|
+
ExecStartPost=/bin/sh -c 'for i in $(seq 100); do [ -S /tmp/.X11-unix/X2 ] && exit 0; sleep 0.1; done; exit 1'
|
|
116
|
+
Restart=on-failure
|
|
117
|
+
|
|
118
|
+
[Install]
|
|
119
|
+
WantedBy=default.target
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```ini
|
|
123
|
+
# ~/.config/systemd/user/<id>-chrome.service
|
|
124
|
+
[Unit]
|
|
125
|
+
Description=<Name>'s Chrome on :2
|
|
126
|
+
BindsTo=<id>-xvnc.service
|
|
127
|
+
After=<id>-xvnc.service <id>-dbus.service <id>-openbox.service
|
|
128
|
+
Wants=<id>-dbus.service <id>-openbox.service
|
|
129
|
+
|
|
130
|
+
[Service]
|
|
131
|
+
Environment=DISPLAY=:2 DBUS_SESSION_BUS_ADDRESS=unix:path=%t/<id>-bus
|
|
132
|
+
UnsetEnvironment=XAUTHORITY GTK_IM_MODULE QT_IM_MODULE XMODIFIERS XDG_CURRENT_DESKTOP DESKTOP_SESSION SSH_AUTH_SOCK
|
|
133
|
+
ExecStart=/usr/bin/google-chrome-stable --user-data-dir=%h/.config/<id>-chrome --password-store=basic --no-first-run --no-default-browser-check --start-maximized
|
|
134
|
+
Restart=always
|
|
135
|
+
MemoryHigh=1536M
|
|
136
|
+
|
|
137
|
+
[Install]
|
|
138
|
+
WantedBy=<id>-xvnc.service
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`<id>-openbox.service` is like the browser's, with `ExecStart=/usr/bin/openbox`, `After=<id>-xvnc.service <id>-dbus.service`, `Wants=<id>-dbus.service` and `Restart=on-failure`. `<id>-dbus.service` runs `/usr/bin/dbus-daemon --nofork --nopidfile --config-file=<your config file>`, with `WantedBy=default.target`. `UnsetEnvironment` keeps the person's desktop session and input method out of your screen. Above `MemoryHigh`, the kernel takes memory back from the browser, not from other programs. Then `systemctl --user daemon-reload`, `systemctl --user enable --now <id>-dbus <id>-xvnc <id>-openbox <id>-chrome`, and in bot.json:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
"screen": {"DISPLAY": ":2", "DBUS_SESSION_BUS_ADDRESS": "unix:path=/run/user/<uid>/<id>-bus"},
|
|
145
|
+
"vnc": {"port": 5902, "passwordFile": "<id>-vnc.passwd"}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Check it: a screenshot of `:2` shows the browser, `pots page desktop` makes a link, and after `systemctl --user restart <id>-xvnc` it all comes back.
|
|
149
|
+
|
|
150
|
+
## When you drive a Linux desktop
|
|
151
|
+
|
|
152
|
+
- An input method, such as fcitx5 or IBus, can change or drop text that `xdotool type` sends. Paste instead: put the text on the clipboard (`printf '%s' "$text" | xclip -selection clipboard`) and press Ctrl+V. Or turn the input method off while you type, with `fcitx5-remote -c`, and on again after, with `fcitx5-remote -o`. After you paste a secret, put something else on the clipboard.
|
|
153
|
+
- `gnome-screenshot` can give a picture 10 to 30 seconds old. Take the picture from the X server itself, for example with Python's PIL, `ImageGrab.grab(xdisplay=":2")`, or with `xwd -root -display :2`, converted to PNG. When a browser's window is slow to draw, a small mouse move makes it draw before the picture.
|
|
@@ -19,22 +19,22 @@ Written for a bot that connects itself; a person can follow it too. The bot conn
|
|
|
19
19
|
https://discord.com/oauth2/authorize?client_id=<Application ID>&scope=bot&permissions=309237763136
|
|
20
20
|
```
|
|
21
21
|
Adding a bot to a server needs the **Manage Server** permission there. Give the URL to a person who has it; they open it, pick the server, and choose **Authorize**. You are then in the server. Give the URL again for each other server.
|
|
22
|
-
6. Write the token to
|
|
22
|
+
6. Write the token to a file of your own in the secrets folder (`~/.pots/secrets/`), readable only by this user: `discord-<your bot ID>.env`, for example `discord-ada.env`. Your bot ID is the name of your folder. Other bots on this computer keep their tokens in the same folder, so never write to a file that is not yours, such as a `discord.env` that is already there:
|
|
23
23
|
```sh
|
|
24
24
|
DISCORD_BOT_TOKEN=...
|
|
25
25
|
```
|
|
26
26
|
Do not put the token in a chat message, a log or any other file. When the person copied the token, ask for it in the terminal channel instead:
|
|
27
|
-
`call <terminal channel id> ask-secret {"text": "…", "file": "discord
|
|
27
|
+
`call <terminal channel id> ask-secret {"text": "…", "file": "discord-<your bot ID>.env", "keys": ["DISCORD_BOT_TOKEN"]}`. `pots chat` writes it to this file without showing it to you.
|
|
28
28
|
7. Add the channel to `channels` in your `bot.json`:
|
|
29
29
|
```json
|
|
30
|
-
{ "id": "discord", "type": "discord", "secrets": "~/.pots/secrets/discord
|
|
30
|
+
{ "id": "discord", "type": "discord", "secrets": "~/.pots/secrets/discord-<your bot ID>.env" }
|
|
31
31
|
```
|
|
32
32
|
It connects within a few seconds. `pots status` lists it; if it fails, the reason is in `bot.json.error`.
|
|
33
33
|
8. So that nobody else can add you to their server: under **Installation**, set **Install Link** to **None** and save; then under **Bot**, turn off **Public Bot** and save. Discord refuses the second while the first is set. After this, only the person who owns the application can add you to another server, with the same URL.
|
|
34
34
|
|
|
35
35
|
You read every channel of a server that your role lets you see. A server's admins choose which channels those are. People can also send you a DM.
|
|
36
36
|
|
|
37
|
-
A second Discord bot is a second channel entry with its own `id` (for example `discord-shop`) and its own env file.
|
|
37
|
+
A second Discord bot is a second channel entry with its own `id` (for example `discord-shop`) and its own env file (`discord-shop-<your bot ID>.env`).
|
|
38
38
|
|
|
39
39
|
## Sending
|
|
40
40
|
|
package/skills/pages/SKILL.md
CHANGED
|
@@ -18,6 +18,7 @@ A guide, not a rule; you decide.
|
|
|
18
18
|
| Show something large: a plan, a report, a table, a chart | A display page | Long content does not fit a chat window |
|
|
19
19
|
| Many inputs at once: choices, text, a comment on each step, approve or reject | An answer page | One page, one submit |
|
|
20
20
|
| A secret: a password, a token, a key | The Pots password page (`pots page secret`) | The value goes straight to a file in the secrets folder, never into the chat, the log or your conversation |
|
|
21
|
+
| A step only a person can do on your screen: a sign-in, a CAPTCHA, an approval | The Pots desktop page (`pots page desktop`): the desktop-page skill | They see and control your screen from their phone or computer, and hand it back |
|
|
21
22
|
|
|
22
23
|
Never ask for a secret in a chat message, and never write your own page for one. If someone pastes a secret into a chat, tell them that the chat keeps it, and suggest they replace it. In the terminal channel (`pots chat`), ask-secret works as before.
|
|
23
24
|
|
|
@@ -44,6 +45,8 @@ pots page unlink <link ID or URL> # the link stops working at on
|
|
|
44
45
|
pots page list # your pages, their links, when each was last opened and changed
|
|
45
46
|
```
|
|
46
47
|
|
|
48
|
+
`pots page list` also lists your password links (`secretLinks`, IDs S1, S2, …) and desktop links (`desktopLinks`, D1, D2, …), and `pots page unlink` takes those back too.
|
|
49
|
+
|
|
47
50
|
`pots page link` prints JSON: `{"link": "<link ID>", "url": "https://…/p/<token>/", "via": "public-url" or "quick-tunnel", "note": "…"}`. `note` comes with a Quick Tunnel and gives its facts (see below). Nobody can guess a link, but anyone who has it can open it, and a link can be forwarded.
|
|
48
51
|
|
|
49
52
|
- Make a link per person with `--for <person address>` when you want to know whose link an answer came through. Then say "someone used the link made for Alice", never "Alice answered": you know the link, not the person. To know for sure who answered, use a platform button: the platform names the account that clicked.
|
|
@@ -172,9 +175,11 @@ The answers of the example page look like this:
|
|
|
172
175
|
## The password page
|
|
173
176
|
|
|
174
177
|
```sh
|
|
175
|
-
pots page secret --file slack.env --keys SLACK_APP_TOKEN,SLACK_BOT_TOKEN --text "Paste the two Slack tokens from step 5" --for slack:@U123
|
|
178
|
+
pots page secret --file slack-ada.env --keys SLACK_APP_TOKEN,SLACK_BOT_TOKEN --text "Paste the two Slack tokens from step 5" --for slack:@U123
|
|
176
179
|
```
|
|
177
180
|
|
|
181
|
+
Name the file for yourself, as here for the bot `ada`: other bots on this computer keep their secrets in the same folder.
|
|
182
|
+
|
|
178
183
|
It prints JSON: `{"link": "<link ID>", "url": "https://…/s/<token>", "expires": "<time>", "via": …, "note": …}`. The page is Pots' own; you choose only the text, the keys and the file. One person submits it once: the values go straight into that file in the secrets folder (`~/.pots/secrets/`), and the link stops working. A link that nobody submits stops working after 1 hour. Opening the page does not use it up, so a platform's link preview cannot either; still turn previews off.
|
|
179
184
|
|
|
180
185
|
You are woken with:
|
|
@@ -183,14 +188,14 @@ You are woken with:
|
|
|
183
188
|
secret page: someone used link <link ID> (made for <person address | anyone>) and wrote <KEY1>, <KEY2> to <file> in the secrets folder
|
|
184
189
|
```
|
|
185
190
|
|
|
186
|
-
You never see the values; they are not in the log, the wake or a trace. Then use the file as after ask-secret, for example as `secrets` of a channel in bot.json. The file has the values exactly as they were typed, one `KEY=value` line each, so never `source` it or `.` it in a shell: a value can hold `$(…)`. To use one value in a command, read just that line, for example `"$(grep '^SLACK_BOT_TOKEN=' ~/.pots/secrets/slack.env | cut -d= -f2-)"`, and never print it. Send the link in a DM to that person when you can. With a Quick Tunnel, tell them every time that Cloudflare can see what they type into the page (see below), and offer Tailscale Funnel.
|
|
191
|
+
You never see the values; they are not in the log, the wake or a trace. Then use the file as after ask-secret, for example as `secrets` of a channel in bot.json. The file has the values exactly as they were typed, one `KEY=value` line each, so never `source` it or `.` it in a shell: a value can hold `$(…)`. To use one value in a command, read just that line, for example `"$(grep '^SLACK_BOT_TOKEN=' ~/.pots/secrets/slack-ada.env | cut -d= -f2-)"`, and never print it. Send the link in a DM to that person when you can. With a Quick Tunnel, tell them every time that Cloudflare can see what they type into the page (see below), and offer Tailscale Funnel.
|
|
187
192
|
|
|
188
193
|
## Where links point: a Quick Tunnel or your own address
|
|
189
194
|
|
|
190
195
|
Pots serves pages on this computer only (127.0.0.1, at `pagePort` in `~/.pots/settings.json`). The internet reaches them in one of two ways:
|
|
191
196
|
|
|
192
197
|
- `publicUrl` in `~/.pots/settings.json` is set (a Tailscale Funnel address, a domain, a reverse proxy): links use it, and no Quick Tunnel starts. `via` is `public-url`.
|
|
193
|
-
- `publicUrl` is not set: Pots starts a Cloudflare [Quick Tunnel](https://developers.cloudflare.com/tunnel/get-started/quick-tunnels/) at the first `pots page link` or `pots page
|
|
198
|
+
- `publicUrl` is not set: Pots starts a Cloudflare [Quick Tunnel](https://developers.cloudflare.com/tunnel/get-started/quick-tunnels/) at the first `pots page link`, `pots page secret` or `pots page desktop`, and keeps it until the gateway stops. `via` is `quick-tunnel`. All bots of this computer share it.
|
|
194
199
|
|
|
195
200
|
What a Quick Tunnel means, from Cloudflare's docs and how it works:
|
|
196
201
|
|
|
@@ -237,6 +242,6 @@ All pages of this computer, of every bot, are under one address, so the browser
|
|
|
237
242
|
## Cleanup
|
|
238
243
|
|
|
239
244
|
- Pots deletes a page, with its links, when nobody opened it, you made no link to it and you did not change it for 30 days. Pages in `pages/keep/` are never deleted that way.
|
|
240
|
-
- A password page link expires 1 hour after you made it, unless it was used before.
|
|
245
|
+
- A password page link expires 1 hour after you made it, unless it was used before. A desktop page link ends as the desktop-page skill says.
|
|
241
246
|
- Deleting a bot deletes its pages and links.
|
|
242
247
|
- `pages/keep/` grows until you tidy it. Look through it now and then and ask the people whether old pages can go; a routine helps, for example `pots routine add tidy-pages --cron "0 10 1 * *" --note "Look through pages/keep/"`.
|
|
@@ -12,23 +12,24 @@ Written for a bot that connects itself; a person can follow it too. The app uses
|
|
|
12
12
|
1. Open https://api.slack.com/apps?new_app=1 in the browser on your screen. If Slack asks to sign in, ask the person to sign in there; they can take over the screen.
|
|
13
13
|
If this computer has no screen, ask the person how they want to do it (your instructions, under the screen, say what each way costs): a virtual desktop they can watch over VNC, a browser-only tool such as agent-browser, or steps 1 to 4 in the browser on their own computer while you guide them. In the last case, give them the manifest with your name already in it, and ask for the two tokens with ask-secret in the terminal channel (step 5).
|
|
14
14
|
2. Choose **From a manifest**, pick the workspace, and paste [slack-app-manifest.yaml](slack-app-manifest.yaml). Change `name` and `display_name` to your own name first. Create the app.
|
|
15
|
+
A manifest cannot set the app's icon. To give it one, go to **Basic Information → Display Information**, choose **Add App Icon**, and upload a square image file from this computer; the page says which sizes it takes. In the file dialog you can type or paste the file's path instead of clicking through folders: Ctrl+L opens a field for it on Linux, Cmd+Shift+G on a Mac; on Windows, use the file name field. The icon is saved at once.
|
|
15
16
|
3. **Basic Information → App-Level Tokens → Generate Token and Scopes**: add the scope `connections:write` and generate. This is the app token (`xapp-…`).
|
|
16
17
|
4. **Install App → Install to workspace → Allow**. Some workspaces need an admin to approve; then ask the person. Copy the **Bot User OAuth Token** (`xoxb-…`).
|
|
17
|
-
5. Write both tokens to
|
|
18
|
+
5. Write both tokens to a file of your own in the secrets folder (`~/.pots/secrets/`), readable only by this user: `slack-<your bot ID>.env`, for example `slack-ada.env`. Your bot ID is the name of your folder. Other bots on this computer keep their tokens in the same folder, so never write to a file that is not yours, such as a `slack.env` that is already there:
|
|
18
19
|
```sh
|
|
19
20
|
SLACK_APP_TOKEN=xapp-...
|
|
20
21
|
SLACK_BOT_TOKEN=xoxb-...
|
|
21
22
|
```
|
|
22
23
|
Do not put tokens in a chat message, a log or any other file. When the person copied the tokens, ask for them in the terminal channel instead:
|
|
23
|
-
`call <terminal channel id> ask-secret {"text": "…", "file": "slack
|
|
24
|
+
`call <terminal channel id> ask-secret {"text": "…", "file": "slack-<your bot ID>.env", "keys": ["SLACK_APP_TOKEN", "SLACK_BOT_TOKEN"]}`. `pots chat` writes them to this file without showing them to you.
|
|
24
25
|
6. Add the channel to `channels` in your `bot.json`:
|
|
25
26
|
```json
|
|
26
|
-
{ "id": "slack", "type": "slack", "secrets": "~/.pots/secrets/slack
|
|
27
|
+
{ "id": "slack", "type": "slack", "secrets": "~/.pots/secrets/slack-<your bot ID>.env" }
|
|
27
28
|
```
|
|
28
29
|
It connects within a few seconds. `pots status` lists it; if it fails, the reason is in `bot.json.error`.
|
|
29
30
|
7. You join only the places you are invited to. Ask the person to invite you to the right channels (`/invite @yourname`) or to send you a DM in Slack.
|
|
30
31
|
|
|
31
|
-
A second Slack workspace is a second channel entry with its own `id` (for example `slack-acme`) and its own env file.
|
|
32
|
+
A second Slack workspace is a second channel entry with its own `id` (for example `slack-acme`) and its own env file (`slack-acme-<your bot ID>.env`).
|
|
32
33
|
|
|
33
34
|
## Sending
|
|
34
35
|
|
|
@@ -107,7 +108,7 @@ EOF
|
|
|
107
108
|
The files of a message are saved for you, and the wake gives their paths. The message log keeps each file's `url_private`. Downloading it needs the bot token (scope `files:read`), so Pots downloads only from Slack's own hosts. To download a file again later, read the token from its line of the env file in the shell, so that it stays out of messages and logs, and send it in the `Authorization` header:
|
|
108
109
|
|
|
109
110
|
```sh
|
|
110
|
-
curl -sS -o plan.png -H "Authorization: Bearer $(grep '^SLACK_BOT_TOKEN=' ~/.pots/secrets/slack
|
|
111
|
+
curl -sS -o plan.png -H "Authorization: Bearer $(grep '^SLACK_BOT_TOKEN=' ~/.pots/secrets/slack-<your bot ID>.env | cut -d= -f2-)" "<url_private>"
|
|
111
112
|
```
|
|
112
113
|
|
|
113
114
|
Never `source` the env file or `.` it in a shell, and never print the token: the file holds each value exactly as it was typed, and a value with `$(…)` in it would run as a command.
|
|
@@ -12,15 +12,15 @@ Written for a bot that connects itself; a person can follow it too. The bot gets
|
|
|
12
12
|
1. The person makes the Telegram bot in their own Telegram app. Only a Telegram account can make a bot, and you cannot use theirs. Ask them to open a chat with [@BotFather](https://t.me/BotFather), send `/newbot`, and give a name (what people see, for example your name) and a username that ends in `bot`. BotFather answers with the token (`123456789:AA…`).
|
|
13
13
|
2. In the same chat, ask them to send `/setprivacy`, choose the bot, and choose **Disable**. Without this, you get only the group messages that mention you, reply to you or are commands. The change counts only in groups the bot joins after it: in a group the bot is already in, they remove it and add it again.
|
|
14
14
|
3. Ask for the token with ask-secret in the terminal channel:
|
|
15
|
-
`call <terminal channel id> ask-secret {"text": "…", "file": "telegram
|
|
16
|
-
`pots chat` writes it to `telegram
|
|
15
|
+
`call <terminal channel id> ask-secret {"text": "…", "file": "telegram-<your bot ID>.env", "keys": ["TELEGRAM_BOT_TOKEN"]}`.
|
|
16
|
+
`pots chat` writes it to `telegram-<your bot ID>.env` in the secrets folder (`~/.pots/secrets/`), readable only by this user, without showing it to you. Your bot ID is the name of your folder, so for the bot `ada` the file is `telegram-ada.env`. Other bots on this computer keep their tokens in the same folder, so never use a file that is not yours, such as a `telegram.env` that is already there:
|
|
17
17
|
```sh
|
|
18
18
|
TELEGRAM_BOT_TOKEN=123456789:AA...
|
|
19
19
|
```
|
|
20
20
|
Do not put the token in a chat message, a log or any other file.
|
|
21
21
|
4. Add the channel to `channels` in your `bot.json`:
|
|
22
22
|
```json
|
|
23
|
-
{ "id": "telegram", "type": "telegram", "secrets": "~/.pots/secrets/telegram
|
|
23
|
+
{ "id": "telegram", "type": "telegram", "secrets": "~/.pots/secrets/telegram-<your bot ID>.env" }
|
|
24
24
|
```
|
|
25
25
|
It connects within a few seconds. `pots status` lists it; if it fails, the reason is in `bot.json.error`. Only one process can get a bot's messages: when another one uses the same token, the gateway's output says so.
|
|
26
26
|
5. Ask the person to add you to their groups (the group's info → **Add members** → your username). To see reactions, you must be an admin of the group: Telegram sends reactions only to admins. To post in a Telegram channel, you must be an admin there.
|
|
@@ -71,7 +71,7 @@ The files of a message are saved for you, and the wake gives their paths. The me
|
|
|
71
71
|
1. `call <channel id> getFile {"file_id": "<file ID>"}` gives its `file_path`.
|
|
72
72
|
2. Download it from Telegram's file host with the token from its line of the env file, read in the shell, so that it stays out of messages and logs:
|
|
73
73
|
```sh
|
|
74
|
-
curl -sS -o photo.jpg "https://api.telegram.org/file/bot$(grep '^TELEGRAM_BOT_TOKEN=' ~/.pots/secrets/telegram
|
|
74
|
+
curl -sS -o photo.jpg "https://api.telegram.org/file/bot$(grep '^TELEGRAM_BOT_TOKEN=' ~/.pots/secrets/telegram-<your bot ID>.env | cut -d= -f2-)/<file_path>"
|
|
75
75
|
```
|
|
76
76
|
Never `source` the env file or `.` it in a shell, and never print the token: the file holds each value exactly as it was typed, and a value with `$(…)` in it would run as a command.
|
|
77
77
|
The link works for at least an hour. Telegram gives bots files of at most 20 MB.
|