@friendlyrobot/discord-pi-agent 0.9.10 → 0.10.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/dist/index.js +6 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -104,15 +104,12 @@ async function formatWithPrettier(text) {
|
|
|
104
104
|
// src/reply-buffer.ts
|
|
105
105
|
var logger3 = createModuleLogger("reply-buffer");
|
|
106
106
|
async function collectReply(session, prompt, options = {}) {
|
|
107
|
-
const logPrefix = options.logPrefix ?? "[agent]";
|
|
108
107
|
let streamedText = "";
|
|
109
108
|
let eventCount = 0;
|
|
110
109
|
let toolCount = 0;
|
|
111
|
-
let sawAgentEnd = false;
|
|
112
110
|
const model = session.model ? `${session.model.provider}/${session.model.id}` : "none";
|
|
113
111
|
debugPrint(prompt, "Full Prompt");
|
|
114
112
|
logger3.debug({
|
|
115
|
-
logPrefix,
|
|
116
113
|
promptLength: prompt.length,
|
|
117
114
|
model,
|
|
118
115
|
prompt
|
|
@@ -129,24 +126,22 @@ async function collectReply(session, prompt, options = {}) {
|
|
|
129
126
|
toolCount += 1;
|
|
130
127
|
logger3.debug({
|
|
131
128
|
toolName: event.toolName,
|
|
132
|
-
input:
|
|
133
|
-
|
|
134
|
-
}, "tool start");
|
|
129
|
+
input: event.toolName === "bash" ? event.args.command : event.args
|
|
130
|
+
}, `tool start: [${event.toolName}] `);
|
|
135
131
|
}
|
|
136
132
|
if (event.type === "tool_execution_end") {
|
|
137
133
|
logger3.debug({
|
|
138
134
|
toolName: event.toolName,
|
|
139
135
|
isError: event.isError,
|
|
140
|
-
output:
|
|
141
|
-
|
|
142
|
-
}, "tool end");
|
|
136
|
+
output: event.result
|
|
137
|
+
}, `tool end: [${event.toolName}]`);
|
|
143
138
|
}
|
|
144
139
|
if (event.type === "agent_end") {
|
|
145
|
-
sawAgentEnd = true;
|
|
146
140
|
logger3.debug({
|
|
147
141
|
messageCount: event.messages.length,
|
|
148
142
|
model,
|
|
149
|
-
|
|
143
|
+
toolCount,
|
|
144
|
+
eventCount
|
|
150
145
|
}, "agent end");
|
|
151
146
|
}
|
|
152
147
|
});
|
|
@@ -169,22 +164,6 @@ async function collectReply(session, prompt, options = {}) {
|
|
|
169
164
|
}
|
|
170
165
|
return "No response generated.";
|
|
171
166
|
}
|
|
172
|
-
function truncateForLog(value, maxLength = 400) {
|
|
173
|
-
if (value.length <= maxLength) {
|
|
174
|
-
return value;
|
|
175
|
-
}
|
|
176
|
-
return `${value.slice(0, maxLength)}...`;
|
|
177
|
-
}
|
|
178
|
-
function extractToolOutput(output) {
|
|
179
|
-
if (typeof output === "string") {
|
|
180
|
-
return output;
|
|
181
|
-
}
|
|
182
|
-
try {
|
|
183
|
-
return JSON.stringify(output);
|
|
184
|
-
} catch {
|
|
185
|
-
return String(output);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
167
|
function getLatestAssistantText(messages) {
|
|
189
168
|
const latestAssistantMessage = [...messages].reverse().find((message) => {
|
|
190
169
|
return message.role === "assistant";
|