@friendlyrobot/discord-pi-agent 0.15.0 → 0.16.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.
@@ -12,4 +12,4 @@ export type CommandContext = {
12
12
  promptQueue: PromptQueue;
13
13
  session?: AgentSession;
14
14
  };
15
- export declare function handleCommand(input: string, context: CommandContext): Promise<CommandResult>;
15
+ export declare function executeCommand(input: string, context: CommandContext): Promise<CommandResult>;
@@ -8,4 +8,4 @@ import type { AgentService } from "./agent-service";
8
8
  * Creates a temporary in-memory session, sends the media, extracts the
9
9
  * assistant's text reply, then disposes the session.
10
10
  */
11
- export declare function describeImage(agentService: AgentService, imageData: string, mimeType: string, userText: string, visionModel: Model<any>): Promise<string>;
11
+ export declare function describeMediaAttachment(agentService: AgentService, imageData: string, mimeType: string, userText: string, visionModel: Model<any>): Promise<string>;
package/dist/index.js CHANGED
@@ -110,7 +110,7 @@ async function formatWithPrettier(text) {
110
110
 
111
111
  // src/reply-buffer.ts
112
112
  var logger3 = createModuleLogger("reply-buffer");
113
- async function collectReply(session, prompt, options = {}) {
113
+ async function runPromptAndCollectReply(session, prompt, options = {}) {
114
114
  let streamedText = "";
115
115
  let eventCount = 0;
116
116
  let toolCount = 0;
@@ -278,7 +278,7 @@ class AgentService {
278
278
  async prompt(text) {
279
279
  const session = this.requireSession();
280
280
  const transformedPrompt = await this.config.promptTransform(text);
281
- return collectReply(session, transformedPrompt, {
281
+ return runPromptAndCollectReply(session, transformedPrompt, {
282
282
  logPrefix: `[agent:${session.sessionId}]`
283
283
  });
284
284
  }
@@ -889,7 +889,7 @@ var commandHandlers = [
889
889
  handleReloadCommand,
890
890
  handleResetSessionCommand
891
891
  ];
892
- async function handleCommand(input, context) {
892
+ async function executeCommand(input, context) {
893
893
  const trimmedInput = input.trim();
894
894
  if (!trimmedInput.startsWith("!")) {
895
895
  return { handled: false };
@@ -1160,7 +1160,7 @@ async function sendReply(message, text) {
1160
1160
 
1161
1161
  // src/image-description.ts
1162
1162
  var logger7 = createModuleLogger("image-description");
1163
- async function describeImage(agentService, imageData, mimeType, userText, visionModel) {
1163
+ async function describeMediaAttachment(agentService, imageData, mimeType, userText, visionModel) {
1164
1164
  const session = await agentService.createTemporarySession();
1165
1165
  await session.setModel(visionModel);
1166
1166
  const mediaType = getMediaType(mimeType);
@@ -1307,7 +1307,7 @@ async function resolveMediaAttachmentsForPrompt(mediaAttachments, content, curre
1307
1307
  }, "describing media with vision model");
1308
1308
  const descriptions = [];
1309
1309
  for (const media of mediaAttachments) {
1310
- const description = await describeImage(agentService, media.data, media.mimeType, content, visionModel);
1310
+ const description = await describeMediaAttachment(agentService, media.data, media.mimeType, content, visionModel);
1311
1311
  const label = getMediaAttachmentLabel(media.filename, media.mimeType);
1312
1312
  descriptions.push(`${label}
1313
1313
  ${description}`);
@@ -1524,7 +1524,7 @@ ${attachment.content}`;
1524
1524
  threadName: message.channel.name
1525
1525
  }, "new thread session");
1526
1526
  }
1527
- const commandResult = await handleCommand(content, {
1527
+ const commandResult = await executeCommand(content, {
1528
1528
  agentService,
1529
1529
  promptQueue,
1530
1530
  session
@@ -1581,7 +1581,7 @@ ${attachment.content}`;
1581
1581
  }
1582
1582
  const wrappedContent = buildDiscordPromptContent(message, scope, promptContent, config);
1583
1583
  const transformedPrompt = await config.promptTransform(wrappedContent);
1584
- return collectReply(session, transformedPrompt, {
1584
+ return runPromptAndCollectReply(session, transformedPrompt, {
1585
1585
  logPrefix: `[agent:${session.sessionId}]`,
1586
1586
  images: promptImages
1587
1587
  });
@@ -1654,7 +1654,7 @@ class PromptQueue {
1654
1654
  reject(error);
1655
1655
  }
1656
1656
  });
1657
- this.kick();
1657
+ this.runNextTask();
1658
1658
  });
1659
1659
  }
1660
1660
  getSnapshot() {
@@ -1663,7 +1663,7 @@ class PromptQueue {
1663
1663
  busy: this.running
1664
1664
  };
1665
1665
  }
1666
- kick() {
1666
+ runNextTask() {
1667
1667
  if (this.running) {
1668
1668
  return;
1669
1669
  }
@@ -1674,7 +1674,7 @@ class PromptQueue {
1674
1674
  this.running = true;
1675
1675
  next().finally(() => {
1676
1676
  this.running = false;
1677
- this.kick();
1677
+ this.runNextTask();
1678
1678
  });
1679
1679
  }
1680
1680
  }
@@ -8,6 +8,6 @@ export declare class PromptQueue {
8
8
  private running;
9
9
  enqueue<T>(task: QueueTask<T>): Promise<T>;
10
10
  getSnapshot(): QueueSnapshot;
11
- private kick;
11
+ private runNextTask;
12
12
  }
13
13
  export {};
@@ -4,5 +4,5 @@ type CollectReplyOptions = {
4
4
  logPrefix?: string;
5
5
  images?: ImageContent[];
6
6
  };
7
- export declare function collectReply(session: AgentSession, prompt: string, options?: CollectReplyOptions): Promise<string>;
7
+ export declare function runPromptAndCollectReply(session: AgentSession, prompt: string, options?: CollectReplyOptions): Promise<string>;
8
8
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Reusable Discord gateway for persistent pi agent sessions",
5
5
  "license": "MIT",
6
6
  "type": "module",