@friendlyrobot/discord-pi-agent 0.10.1 → 0.10.3

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -109,11 +109,6 @@ async function collectReply(session, prompt, options = {}) {
109
109
  let toolCount = 0;
110
110
  const model = session.model ? `${session.model.provider}/${session.model.id}` : "none";
111
111
  debugPrint(prompt, "Full Prompt");
112
- logger3.debug({
113
- promptLength: prompt.length,
114
- model,
115
- prompt
116
- }, "prompt start");
117
112
  const unsubscribe = session.subscribe((event) => {
118
113
  eventCount += 1;
119
114
  if (event.type === "message_update") {
@@ -133,16 +128,11 @@ async function collectReply(session, prompt, options = {}) {
133
128
  logger3.debug({
134
129
  toolName: event.toolName,
135
130
  isError: event.isError,
136
- output: event.result
131
+ output: truncateForLog(extractToolOutput(event.result))
137
132
  }, `tool end: [${event.toolName}]`);
138
133
  }
139
134
  if (event.type === "agent_end") {
140
- logger3.debug({
141
- messageCount: event.messages.length,
142
- model,
143
- toolCount,
144
- eventCount
145
- }, "agent end");
135
+ logger3.debug("agent end");
146
136
  }
147
137
  });
148
138
  try {
@@ -164,6 +154,22 @@ async function collectReply(session, prompt, options = {}) {
164
154
  }
165
155
  return "No response generated.";
166
156
  }
157
+ function truncateForLog(value, maxLength = 400) {
158
+ if (value.length <= maxLength) {
159
+ return value;
160
+ }
161
+ return `${value.slice(0, maxLength)}...`;
162
+ }
163
+ function extractToolOutput(output) {
164
+ if (typeof output === "string") {
165
+ return output;
166
+ }
167
+ try {
168
+ return JSON.stringify(output);
169
+ } catch {
170
+ return String(output);
171
+ }
172
+ }
167
173
  function getLatestAssistantText(messages) {
168
174
  const latestAssistantMessage = [...messages].reverse().find((message) => {
169
175
  return message.role === "assistant";
@@ -989,7 +995,7 @@ async function sendTypingSafe(channel, channelKey) {
989
995
  headers: { Authorization: `Bot ${token}` }
990
996
  });
991
997
  if (res.ok) {
992
- logger5.debug({ channelKey }, "[TYPING] OK");
998
+ logger5.debug(`[TYPING] STATUS UPDATED OK: ${await res.text()}`);
993
999
  return;
994
1000
  }
995
1001
  if (res.status === 429) {
@@ -1022,7 +1028,7 @@ function startTypingForChannel(channel, channelKey) {
1022
1028
  logger5.debug({ channelKey, refs: existing.refs }, "[TYPING] ref++ (reusing existing interval)");
1023
1029
  return;
1024
1030
  }
1025
- logger5.debug({ channelKey }, "[TYPING] started new interval");
1031
+ logger5.debug("[TYPING] started new interval");
1026
1032
  sendTypingSafe(channel, channelKey);
1027
1033
  const interval = setInterval(() => {
1028
1034
  sendTypingSafe(channel, channelKey);
@@ -1039,9 +1045,9 @@ function stopTypingForChannel(channelKey) {
1039
1045
  if (entry.refs <= 0) {
1040
1046
  clearInterval(entry.interval);
1041
1047
  typingIntervals.delete(channelKey);
1042
- logger5.debug({ channelKey }, "[TYPING] interval cleared (refs hit 0)");
1048
+ logger5.debug("[TYPING] interval cleared (refs hit 0)");
1043
1049
  } else {
1044
- logger5.debug({ channelKey, refs: entry.refs }, "[TYPING] ref-- (interval still active)");
1050
+ logger5.debug("[TYPING] ref-- (interval still active)");
1045
1051
  }
1046
1052
  }
1047
1053
  async function sendReply(message, text) {
@@ -1113,7 +1119,7 @@ async function startGatewayClient(config, agentService, sessionRegistry, authCon
1113
1119
  }
1114
1120
  async function onMessage(message, config, agentService, sessionRegistry, authConfig) {
1115
1121
  if (message.author.bot) {
1116
- logger5.debug({ messageId: message.id }, "ignored bot message");
1122
+ logger5.debug("ignored bot message");
1117
1123
  return;
1118
1124
  }
1119
1125
  if (message.system) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "description": "Reusable Discord gateway bridge for persistent pi agent sessions",
5
5
  "license": "MIT",
6
6
  "type": "module",