@friendlyrobot/discord-pi-agent 0.19.17 → 0.20.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/dist/index.js +28 -9
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -279,6 +279,12 @@ function normalizeCodeFences(text) {
|
|
|
279
279
|
result.push(beforeFence);
|
|
280
280
|
}
|
|
281
281
|
result.push("```");
|
|
282
|
+
} else if (trimmed.startsWith("```") && !isValidFenceLine(trimmed)) {
|
|
283
|
+
result.push("```");
|
|
284
|
+
const afterFence = trimmed.slice(3).trimStart();
|
|
285
|
+
if (afterFence) {
|
|
286
|
+
result.push(afterFence);
|
|
287
|
+
}
|
|
282
288
|
} else {
|
|
283
289
|
result.push(line);
|
|
284
290
|
}
|
|
@@ -286,6 +292,27 @@ function normalizeCodeFences(text) {
|
|
|
286
292
|
return result.join(`
|
|
287
293
|
`);
|
|
288
294
|
}
|
|
295
|
+
function isValidFenceLine(line) {
|
|
296
|
+
const trimmed = line.trimEnd();
|
|
297
|
+
if (trimmed === "```") {
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
const afterFence = trimmed.slice(3);
|
|
301
|
+
if (!afterFence) {
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
304
|
+
if (afterFence.codePointAt(0) > 127) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
const tokens = afterFence.trimStart().split(/\s+/);
|
|
308
|
+
if (tokens.length > 1) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
if (tokens[0].includes("`")) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
289
316
|
async function formatWithPrettier(text) {
|
|
290
317
|
const prettier = await import("prettier");
|
|
291
318
|
try {
|
|
@@ -327,8 +354,7 @@ async function runAgentTurn(session, prompt, options = {}) {
|
|
|
327
354
|
debugPrint(input, "CMD");
|
|
328
355
|
} else {
|
|
329
356
|
logger4.debug({
|
|
330
|
-
toolName: event.toolName
|
|
331
|
-
input
|
|
357
|
+
toolName: event.toolName
|
|
332
358
|
}, `agent tool start: [${event.toolName}]`);
|
|
333
359
|
}
|
|
334
360
|
}
|
|
@@ -340,7 +366,6 @@ async function runAgentTurn(session, prompt, options = {}) {
|
|
|
340
366
|
} else {
|
|
341
367
|
logger4.debug({
|
|
342
368
|
toolName: event.toolName,
|
|
343
|
-
input: truncateForLog(extractToolOutput(input)),
|
|
344
369
|
isError: event.isError
|
|
345
370
|
}, `agent tool end: [${event.toolName}]`);
|
|
346
371
|
}
|
|
@@ -365,12 +390,6 @@ async function runAgentTurn(session, prompt, options = {}) {
|
|
|
365
390
|
}
|
|
366
391
|
return "No response generated.";
|
|
367
392
|
}
|
|
368
|
-
function truncateForLog(value, maxLength = 400) {
|
|
369
|
-
if (value.length <= maxLength) {
|
|
370
|
-
return value;
|
|
371
|
-
}
|
|
372
|
-
return `${value.slice(0, maxLength)}...`;
|
|
373
|
-
}
|
|
374
393
|
function extractToolOutput(output) {
|
|
375
394
|
if (typeof output === "object" && output !== null) {
|
|
376
395
|
const obj = output;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friendlyrobot/discord-pi-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Reusable Discord gateway for persistent pi agent sessions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
"typecheck": "tsgo --noEmit -p tsconfig.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@earendil-works/pi-ai": "^0.75.
|
|
40
|
-
"@earendil-works/pi-coding-agent": "^0.75.
|
|
39
|
+
"@earendil-works/pi-ai": "^0.75.4",
|
|
40
|
+
"@earendil-works/pi-coding-agent": "^0.75.4",
|
|
41
41
|
"discord.js": "^14.26.4",
|
|
42
42
|
"dotenv": "^17.4.2",
|
|
43
|
-
"marked": "^18.0.
|
|
43
|
+
"marked": "^18.0.4",
|
|
44
44
|
"pino": "^10.3.1",
|
|
45
45
|
"pino-pretty": "^13.1.3",
|
|
46
46
|
"prettier": "^3.8.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/node": "^25.
|
|
50
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
51
|
-
"@vitest/coverage-v8": "^4.1.
|
|
52
|
-
"@vitest/ui": "^4.1.
|
|
53
|
-
"vitest": "^4.1.
|
|
49
|
+
"@types/node": "^25.9.1",
|
|
50
|
+
"@typescript/native-preview": "^7.0.0-dev.20260521.1",
|
|
51
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
52
|
+
"@vitest/ui": "^4.1.7",
|
|
53
|
+
"vitest": "^4.1.7"
|
|
54
54
|
}
|
|
55
55
|
}
|