@friendlyrobot/discord-pi-agent 0.3.10 → 0.3.11
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 +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -6
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Reusable Discord DM bridge for persistent pi agent sessions.
|
|
4
4
|
|
|
5
5
|
## What it does
|
|
6
|
+
|
|
6
7
|
- runs one long-lived pi agent session
|
|
7
8
|
- resumes the latest session on restart
|
|
8
9
|
- loads project context from the target repo via pi resource loading
|
|
@@ -11,6 +12,7 @@ Reusable Discord DM bridge for persistent pi agent sessions.
|
|
|
11
12
|
- exposes built-in session commands
|
|
12
13
|
|
|
13
14
|
## Built-in commands
|
|
15
|
+
|
|
14
16
|
- `!help`
|
|
15
17
|
- `!status`
|
|
16
18
|
- `!compact`
|
|
@@ -52,7 +54,6 @@ const config = loadDiscordPiBridgeConfigFromEnv({
|
|
|
52
54
|
return buildTimeContextPrompt(input, {
|
|
53
55
|
timeZone: "Australia/Sydney",
|
|
54
56
|
locale: "en-AU",
|
|
55
|
-
locationLabel: "Sydney",
|
|
56
57
|
});
|
|
57
58
|
},
|
|
58
59
|
});
|
|
@@ -63,11 +64,13 @@ await startDiscordPiBridge(config);
|
|
|
63
64
|
## Config
|
|
64
65
|
|
|
65
66
|
### Required
|
|
67
|
+
|
|
66
68
|
- `discordBotToken`
|
|
67
69
|
- `discordAllowedUserId`
|
|
68
70
|
- `cwd`
|
|
69
71
|
|
|
70
72
|
### Optional
|
|
73
|
+
|
|
71
74
|
- `agentDir` default: `<cwd>/.pi-agent`
|
|
72
75
|
- `modelProvider` default: `moonshot-cn`
|
|
73
76
|
- `modelId` default: `kimi-k2.5`
|
|
@@ -99,6 +102,7 @@ bun run typecheck
|
|
|
99
102
|
```
|
|
100
103
|
|
|
101
104
|
## Notes
|
|
105
|
+
|
|
102
106
|
- DM-only by design
|
|
103
107
|
- single allowed user by design
|
|
104
108
|
- the package does not register Discord slash commands
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DiscordPiBridge, DiscordPiBridgeConfig } from "./types";
|
|
2
|
-
export { buildTimeContextPrompt, type TimeContextPromptOptions } from "./prompt-context";
|
|
2
|
+
export { buildTimeContextPrompt, type TimeContextPromptOptions, } from "./prompt-context";
|
|
3
3
|
export { loadDiscordPiBridgeConfigFromEnv, resolveConfig } from "./config";
|
|
4
4
|
export type { AgentStatus, DiscordPiBridge, DiscordPiBridgeConfig, PromptTransform, ResolvedDiscordPiBridgeConfig, } from "./types";
|
|
5
5
|
export declare function startDiscordPiBridge(config: DiscordPiBridgeConfig): Promise<DiscordPiBridge>;
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,9 @@ async function collectReply(session, prompt, options = {}) {
|
|
|
42
42
|
}
|
|
43
43
|
if (event.type === "agent_end") {
|
|
44
44
|
sawAgentEnd = true;
|
|
45
|
-
console.log(`${logPrefix} agent end`, {
|
|
45
|
+
console.log(`${logPrefix} agent end`, {
|
|
46
|
+
messageCount: event.messages.length
|
|
47
|
+
});
|
|
46
48
|
}
|
|
47
49
|
});
|
|
48
50
|
try {
|
|
@@ -141,7 +143,9 @@ class AgentService {
|
|
|
141
143
|
async prompt(text) {
|
|
142
144
|
const session = this.requireSession();
|
|
143
145
|
const transformedPrompt = await this.config.promptTransform(text);
|
|
144
|
-
return collectReply(session, transformedPrompt, {
|
|
146
|
+
return collectReply(session, transformedPrompt, {
|
|
147
|
+
logPrefix: `[agent:${session.sessionId}]`
|
|
148
|
+
});
|
|
145
149
|
}
|
|
146
150
|
async compact() {
|
|
147
151
|
const session = this.requireSession();
|
|
@@ -245,7 +249,9 @@ class AgentService {
|
|
|
245
249
|
const available = session.getAvailableThinkingLevels();
|
|
246
250
|
if (available.includes(this.config.thinkingLevel)) {
|
|
247
251
|
session.setThinkingLevel(this.config.thinkingLevel);
|
|
248
|
-
console.log("[agent] thinking level applied", {
|
|
252
|
+
console.log("[agent] thinking level applied", {
|
|
253
|
+
level: this.config.thinkingLevel
|
|
254
|
+
});
|
|
249
255
|
} else {
|
|
250
256
|
console.log("[agent] thinking level not available for model", {
|
|
251
257
|
requested: this.config.thinkingLevel,
|
|
@@ -343,7 +349,14 @@ function parseThinkingLevel(value) {
|
|
|
343
349
|
return;
|
|
344
350
|
}
|
|
345
351
|
const trimmed = value.trim().toLowerCase();
|
|
346
|
-
const validLevels = [
|
|
352
|
+
const validLevels = [
|
|
353
|
+
"off",
|
|
354
|
+
"minimal",
|
|
355
|
+
"low",
|
|
356
|
+
"medium",
|
|
357
|
+
"high",
|
|
358
|
+
"xhigh"
|
|
359
|
+
];
|
|
347
360
|
if (validLevels.includes(trimmed)) {
|
|
348
361
|
return trimmed;
|
|
349
362
|
}
|
|
@@ -480,7 +493,10 @@ function chunkMessage(text) {
|
|
|
480
493
|
// src/discord-client.ts
|
|
481
494
|
async function startDiscordClient(config, agentService, promptQueue) {
|
|
482
495
|
const client = new Client({
|
|
483
|
-
intents: [
|
|
496
|
+
intents: [
|
|
497
|
+
GatewayIntentBits.DirectMessages,
|
|
498
|
+
GatewayIntentBits.MessageContent
|
|
499
|
+
],
|
|
484
500
|
partials: [Partials.Channel]
|
|
485
501
|
});
|
|
486
502
|
client.once(Events.ClientReady, async (readyClient) => {
|
|
@@ -579,7 +595,9 @@ async function onMessage(message, config, agentService, promptQueue) {
|
|
|
579
595
|
}
|
|
580
596
|
async function sendReply(message, text) {
|
|
581
597
|
if (!message.channel.isSendable()) {
|
|
582
|
-
console.log("[discord] reply skipped, channel not sendable", {
|
|
598
|
+
console.log("[discord] reply skipped, channel not sendable", {
|
|
599
|
+
messageId: message.id
|
|
600
|
+
});
|
|
583
601
|
return;
|
|
584
602
|
}
|
|
585
603
|
const chunks = chunkMessage(text);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friendlyrobot/discord-pi-agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Reusable Discord gateway bridge for persistent pi agent sessions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,17 +24,19 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
+
"format": "prettier --write .",
|
|
27
28
|
"build": "rm -rf dist && bun build ./src/index.ts --outdir ./dist --target node --format esm --packages external && tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationMap false",
|
|
28
29
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@mariozechner/pi-ai": "^0.69.0",
|
|
32
33
|
"@mariozechner/pi-coding-agent": "^0.69.0",
|
|
33
|
-
"discord.js": "^14.
|
|
34
|
-
"dotenv": "^
|
|
34
|
+
"discord.js": "^14.26.3",
|
|
35
|
+
"dotenv": "^17.4.2"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/node": "^24.6.0",
|
|
39
|
+
"prettier": "^3.8.3",
|
|
38
40
|
"typescript": "^5.9.3"
|
|
39
41
|
}
|
|
40
42
|
}
|