@friendlyrobot/discord-pi-agent 0.9.1 → 0.9.2

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 +22 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -975,8 +975,28 @@ var typingIntervals = new Map;
975
975
  async function sendTypingSafe(channel, channelKey) {
976
976
  logger5.info({ channelKey }, "[TYPING] calling sendTyping()");
977
977
  try {
978
- await channel.sendTyping();
979
- logger5.info({ channelKey }, "[TYPING] sendTyping() OK");
978
+ const rawFetchPromise = (async () => {
979
+ const token = channel.client.token;
980
+ const url = `https://discord.com/api/v10/channels/${channel.id}/typing`;
981
+ const response = await fetch(url, {
982
+ method: "POST",
983
+ headers: { Authorization: `Bot ${token}` }
984
+ });
985
+ logger5.info({ channelKey, status: response.status }, "[TYPING] raw fetch status");
986
+ return "raw-ok";
987
+ })();
988
+ const result = await Promise.race([
989
+ channel.sendTyping().then(() => "ok"),
990
+ rawFetchPromise,
991
+ new Promise((resolve) => setTimeout(() => resolve("timeout"), 5000))
992
+ ]);
993
+ if (result === "timeout") {
994
+ logger5.warn({ channelKey }, "[TYPING] BOTH calls TIMEOUT after 5s");
995
+ } else if (result === "raw-ok") {
996
+ logger5.info({ channelKey }, "[TYPING] raw fetch OK, discord.js STUCK");
997
+ } else {
998
+ logger5.info({ channelKey }, "[TYPING] sendTyping() OK");
999
+ }
980
1000
  } catch (error) {
981
1001
  logger5.warn({ channelKey, error }, "[TYPING] sendTyping() FAILED");
982
1002
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Reusable Discord gateway bridge for persistent pi agent sessions",
5
5
  "license": "MIT",
6
6
  "type": "module",