@friendlyrobot/discord-pi-agent 0.5.0 → 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.
- package/README.md +36 -32
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# @friendlyrobot/discord-pi-agent
|
|
2
2
|
|
|
3
|
-
Reusable Discord
|
|
3
|
+
Reusable Discord gateway bridge for persistent pi agent sessions — DM and forum channels.
|
|
4
4
|
|
|
5
5
|
## What it does
|
|
6
6
|
|
|
7
|
-
- runs
|
|
8
|
-
- resumes
|
|
7
|
+
- runs persistent pi agent sessions (one per DM, one per forum thread)
|
|
8
|
+
- resumes sessions on restart via scoped session directories
|
|
9
9
|
- loads project context from the target repo via pi resource loading
|
|
10
|
-
- accepts DM messages from
|
|
11
|
-
- serializes prompts through
|
|
12
|
-
- exposes built-in session commands
|
|
10
|
+
- accepts DM messages and forum thread messages from allowed users
|
|
11
|
+
- serializes prompts per-scope through FIFO queues
|
|
12
|
+
- exposes built-in session commands (per-scope, including `!archive`)
|
|
13
13
|
|
|
14
14
|
## Built-in commands
|
|
15
15
|
|
|
@@ -19,8 +19,9 @@ Reusable Discord DM bridge for persistent pi agent sessions.
|
|
|
19
19
|
- `!compact`
|
|
20
20
|
- `!reload`
|
|
21
21
|
- `!reset-session`
|
|
22
|
+
- `!archive` (forum threads only — archives the thread and shuts down the session)
|
|
22
23
|
|
|
23
|
-
Any other
|
|
24
|
+
Any other text is sent to the active session (DM or thread).
|
|
24
25
|
|
|
25
26
|
## Install
|
|
26
27
|
|
|
@@ -28,41 +29,33 @@ Any other DM text is sent to the persistent agent session.
|
|
|
28
29
|
bun add @friendlyrobot/discord-pi-agent
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
##
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
import { startDiscordPiBridge } from "@friendlyrobot/discord-pi-agent";
|
|
35
|
-
|
|
36
|
-
const bridge = await startDiscordPiBridge({
|
|
37
|
-
discordBotToken: process.env.DISCORD_BOT_TOKEN!,
|
|
38
|
-
discordAllowedUserId: process.env.DISCORD_ALLOWED_USER_ID!,
|
|
39
|
-
cwd: process.cwd(),
|
|
40
|
-
modelProvider: "openrouter",
|
|
41
|
-
modelId: "anthropic/claude-3.5-haiku",
|
|
42
|
-
});
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Usage with dotenv and time context
|
|
32
|
+
## Usage
|
|
46
33
|
|
|
47
34
|
```ts
|
|
48
35
|
import {
|
|
49
36
|
buildTimeContextPrompt,
|
|
50
|
-
|
|
51
|
-
|
|
37
|
+
loadDiscordGatewayConfigFromEnv,
|
|
38
|
+
startDiscordGateway,
|
|
52
39
|
} from "@friendlyrobot/discord-pi-agent";
|
|
53
40
|
|
|
54
|
-
const config =
|
|
41
|
+
const config = loadDiscordGatewayConfigFromEnv({
|
|
42
|
+
cwd: process.cwd(),
|
|
55
43
|
promptTransform: (input) => {
|
|
56
44
|
return buildTimeContextPrompt(input, {
|
|
57
45
|
timeZone: "Australia/Sydney",
|
|
58
46
|
locale: "en-AU",
|
|
59
47
|
});
|
|
60
48
|
},
|
|
49
|
+
// Enable forum channel support (omit for DM-only)
|
|
50
|
+
discordAllowedForumChannelIds: ["1498563501780897832"],
|
|
61
51
|
});
|
|
62
52
|
|
|
63
|
-
await
|
|
53
|
+
await startDiscordGateway(config);
|
|
64
54
|
```
|
|
65
55
|
|
|
56
|
+
Each forum post creates a scoped pi session in `sessions/thread-<id>/`.
|
|
57
|
+
The initial post body becomes the first prompt. Sessions survive restarts.
|
|
58
|
+
|
|
66
59
|
## Config
|
|
67
60
|
|
|
68
61
|
### Required
|
|
@@ -81,9 +74,15 @@ await startDiscordPiBridge(config);
|
|
|
81
74
|
- `startupMessage` default: `Bot is online and ready.`
|
|
82
75
|
- `shutdownOnSignals` default: `true`
|
|
83
76
|
|
|
84
|
-
|
|
77
|
+
### Forum channel options
|
|
85
78
|
|
|
86
|
-
`
|
|
79
|
+
- `discordAllowedForumChannelIds` — string array of forum channel IDs to respond in
|
|
80
|
+
- `discordAllowedUserIds` — string array of allowed user IDs (defaults to `[discordAllowedUserId]`)
|
|
81
|
+
- `sessionIdleTimeoutMs` — auto-shutdown idle thread sessions (null = never)
|
|
82
|
+
|
|
83
|
+
## Env helpers
|
|
84
|
+
|
|
85
|
+
`loadDiscordGatewayConfigFromEnv()` — the config loader:
|
|
87
86
|
|
|
88
87
|
- `DISCORD_BOT_TOKEN`
|
|
89
88
|
- `DISCORD_ALLOWED_USER_ID`
|
|
@@ -92,9 +91,11 @@ await startDiscordPiBridge(config);
|
|
|
92
91
|
- `PI_MODEL_PROVIDER`
|
|
93
92
|
- `PI_MODEL_ID`
|
|
94
93
|
- `DISCORD_STARTUP_MESSAGE`
|
|
94
|
+
- `DISCORD_FORUM_CHANNEL_IDS` — comma-separated forum channel IDs
|
|
95
|
+
- `DISCORD_ALLOWED_USER_IDS` — comma-separated allowed user IDs
|
|
96
|
+
- `DISCORD_SESSION_IDLE_TIMEOUT_MS` — idle timeout in ms
|
|
95
97
|
|
|
96
98
|
If `PI_AGENT_CWD` is missing it falls back to `process.cwd()`.
|
|
97
|
-
|
|
98
99
|
Set `DISCORD_STARTUP_MESSAGE=false` to disable the startup DM.
|
|
99
100
|
|
|
100
101
|
## Thinking Levels
|
|
@@ -112,7 +113,10 @@ bun run typecheck
|
|
|
112
113
|
|
|
113
114
|
## Notes
|
|
114
115
|
|
|
115
|
-
- DM
|
|
116
|
-
-
|
|
117
|
-
-
|
|
116
|
+
- DM and forum threads supported via `startDiscordGateway`
|
|
117
|
+
- Forum thread sessions are stored in `sessions/thread-<id>/` (one directory per thread)
|
|
118
|
+
- Sessions survive restarts — `SessionManager.continueRecent()` resumes the latest `.jsonl`
|
|
119
|
+
- Single Discord client with all intents (DM + Guild + MessageContent)
|
|
120
|
+
- No mode flags — forum support activates when `discordAllowedForumChannelIds` is set
|
|
121
|
+
- The package does not register Discord slash commands
|
|
118
122
|
- pi resources are loaded from the configured `cwd` and `agentDir`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friendlyrobot/discord-pi-agent",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Reusable Discord gateway bridge for persistent pi agent sessions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"typecheck": "tsgo --noEmit -p tsconfig.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@mariozechner/pi-ai": "^0.70.
|
|
40
|
-
"@mariozechner/pi-coding-agent": "^0.70.
|
|
39
|
+
"@mariozechner/pi-ai": "^0.70.5",
|
|
40
|
+
"@mariozechner/pi-coding-agent": "^0.70.5",
|
|
41
41
|
"discord.js": "^14.26.3",
|
|
42
42
|
"dotenv": "^17.4.2",
|
|
43
43
|
"marked": "^18.0.2",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "^25.6.0",
|
|
48
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
48
|
+
"@typescript/native-preview": "^7.0.0-dev.20260427.1",
|
|
49
49
|
"@vitest/ui": "^4.1.5",
|
|
50
50
|
"vitest": "^4.1.5"
|
|
51
51
|
}
|