@friendlyrobot/discord-pi-agent 0.9.0 → 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 +26 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -972,13 +972,34 @@ async function removeWorkingReaction(message) {
972
972
  }
973
973
  var TYPING_INTERVAL_MS = 9000;
974
974
  var typingIntervals = new Map;
975
- function sendTypingSafe(channel, channelKey) {
975
+ async function sendTypingSafe(channel, channelKey) {
976
976
  logger5.info({ channelKey }, "[TYPING] calling sendTyping()");
977
- channel.sendTyping().then(() => {
978
- logger5.info({ channelKey }, "[TYPING] sendTyping() OK");
979
- }).catch((error) => {
977
+ try {
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
+ }
1000
+ } catch (error) {
980
1001
  logger5.warn({ channelKey, error }, "[TYPING] sendTyping() FAILED");
981
- });
1002
+ }
982
1003
  }
983
1004
  function startTypingForChannel(channel, channelKey) {
984
1005
  const existing = typingIntervals.get(channelKey);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.9.0",
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",