@friendlyrobot/discord-pi-agent 0.1.3 → 0.2.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 CHANGED
@@ -470,7 +470,7 @@ async function onMessage(message, config, agentService, promptQueue) {
470
470
  console.log("[discord] channel is not sendable", { messageId: message.id });
471
471
  return;
472
472
  }
473
- await message.channel.sendTyping();
473
+ const typingInterval = await startTypingInterval(message.channel);
474
474
  const queuePosition = promptQueue.getSnapshot().pending;
475
475
  console.log("[queue] enqueue request", {
476
476
  messageId: message.id,
@@ -483,6 +483,7 @@ async function onMessage(message, config, agentService, promptQueue) {
483
483
  console.log(`[queue] processing message ${message.id}`);
484
484
  return agentService.prompt(content);
485
485
  });
486
+ stopTypingInterval(typingInterval);
486
487
  console.log("[discord] response ready", {
487
488
  messageId: message.id,
488
489
  responseLength: response.length,
@@ -510,6 +511,16 @@ async function sendReply(message, text) {
510
511
  await message.channel.send(chunk);
511
512
  }
512
513
  }
514
+ var TYPING_INTERVAL_MS = 8000;
515
+ function startTypingInterval(channel) {
516
+ channel.sendTyping();
517
+ return setInterval(() => {
518
+ channel.sendTyping();
519
+ }, TYPING_INTERVAL_MS);
520
+ }
521
+ function stopTypingInterval(interval) {
522
+ clearInterval(interval);
523
+ }
513
524
 
514
525
  // src/prompt-queue.ts
515
526
  class PromptQueue {
@@ -553,7 +564,6 @@ class PromptQueue {
553
564
  function buildTimeContextPrompt(userMessage, options = {}) {
554
565
  const timeZone = options.timeZone || "UTC";
555
566
  const locale = options.locale || "en-AU";
556
- const locationLabel = options.locationLabel || timeZone;
557
567
  const now = options.now || new Date;
558
568
  const localTime = new Intl.DateTimeFormat(locale, {
559
569
  timeZone,
@@ -562,10 +572,11 @@ function buildTimeContextPrompt(userMessage, options = {}) {
562
572
  year: "2-digit",
563
573
  hour: "2-digit",
564
574
  minute: "2-digit",
565
- hour12: false
575
+ hour12: false,
576
+ timeZoneName: "short"
566
577
  }).format(now);
567
578
  const trimmedMessage = userMessage.trim();
568
- return [`Local time: ${localTime}, ${locationLabel}`, "", "User message:", trimmedMessage].join(`
579
+ return [`<time>${localTime}</time>`, "", trimmedMessage].join(`
569
580
  `);
570
581
  }
571
582
 
@@ -1,7 +1,6 @@
1
1
  export type TimeContextPromptOptions = {
2
2
  timeZone?: string;
3
3
  locale?: string;
4
- locationLabel?: string;
5
4
  now?: Date;
6
5
  };
7
6
  export declare function buildTimeContextPrompt(userMessage: string, options?: TimeContextPromptOptions): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "Reusable Discord gateway bridge for persistent pi agent sessions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",