pi-roundtable 0.50.0 → 0.50.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.50.1] - 2026-11-16
9
+
10
+ ### Fixed
11
+
12
+ - `ChannelContextOptions.conversation` that throws, or returns something other than a string or `undefined`, is now logged and counts as `undefined` instead of rejecting the read; the docs say to set it as the host default or on every read of a channel, since an unnamed read is a conversation of its own.
13
+ - The sandbox's `channelContext` refuses `conversation` (a clear error) and ignores a host default of it: its history is one file per channel that never starts fresh for another asker, so the option would only hand the window over again.
14
+
8
15
  ## [0.50.0] - 2026-11-16
9
16
 
10
17
  ### Added
package/docs/plugins.md CHANGED
@@ -2772,7 +2772,7 @@ It reads Discord, not the host's history, so it survives restarts:
2772
2772
  - Consecutive messages of one author at least `similarity` alike (default 0.8, by their longest common run of text) count as one, the later kept.
2773
2773
  - It keeps the newest `keep` (default 15), oldest first. Mentions read as names, and stickers and files as text with their names and links; by default nothing is downloaded or shown to the model as an image (see `attachments` below). A message is cut at `messageChars` (default 500), another bot's at `botMessageChars` (default 80), and a peer bot's (one `discord.peerBots` lists for the channel, see below) at `peerMessageChars` (default 4000).
2774
2774
  - With `starter: true` (default false) a thread's opening message is always part of the context, even when it lies outside the `fetch` messages: a forum post's first message (its id is the thread's), or the message a text channel's thread was started from (`fetchStarterMessage`). It comes first, outside `keep` (a context may hold `keep` messages plus the starter), is cut at the same limits as any message by its author, and is not repeated when the window holds it already. It passes the same filters as every other message: `authors` (or `foreignWebhook`) answering `"skip"` or `"end"` for it, an empty text, the assistant's own post, and a message handed over or addressed before drop it, so it comes in the first turn that reads it and not again (the conversation's history carries it from then on); it is also dropped when it is the addressed message itself. It stays even when the assistant's last post lies after it. A channel that is not a thread, a thread without a starter (private, or its starter deleted) and a starter Discord will not return add nothing and never fail the turn (an unexpected refusal is logged at debug). A chat surface of another network that implements `channelContext` reads `starter` itself.
2775
- - With `conversation(message)` (default none) the record of what was handed over belongs to a conversation, not only to the channel. Use it where one channel holds several conversations in turn, such as a forum post where each person who asks gets a private conversation of their own (`TurnRequest.conversation` naming their principal), which the runtime makes anew, without the earlier person's history, when the asker changes. Return a key of the conversation the turn for `message` runs in, such as that principal id, or `undefined` for the channel's own. A turn of the conversation the channel's last turn ran in reads only what is new to it, as without the option; a turn of another conversation reads the window as if nothing had been handed over, the starter too. So a second person who asks in a post gets the card, the comments and the earlier discussion, and the first who asks again after them gets them once more, since their session was made anew too. One record is kept per channel either way, as many ids as before, so the option takes no more memory. It is a function, so it is set only in code, as a host default (`discord.channelContext.conversation`) or per call. The window still ends at the assistant's last post; a forum that wants the whole post answers `"skip"` for the assistant's answers with `authors`.
2775
+ - With `conversation(message)` (default none) the record of what was handed over belongs to a conversation, not only to the channel. Use it where one channel holds several conversations in turn, such as a forum post where each person who asks gets a private conversation of their own (`TurnRequest.conversation` naming their principal), which the runtime makes anew, without the earlier person's history, when the asker changes. Return a key of the conversation the turn for `message` runs in, such as that principal id, or `undefined` for the channel's own. A turn of the conversation the channel's last turn ran in reads only what is new to it, as without the option; a turn of another conversation reads the window as if nothing had been handed over, the starter too. So a second person who asks in a post gets the card, the comments and the earlier discussion, and the first who asks again after them gets them once more, since their session was made anew too. One record is kept per channel either way, as many ids as before, so the option takes no more memory. Set it as the host default or pass it on every read of a channel: a read that names none is the channel's own conversation, a key of its own, so mixing named and unnamed reads of one channel starts the record anew each time and hands the window over again. A callback that throws, or returns something other than a string or `undefined`, is logged and counts as `undefined`. The sandbox refuses the option and ignores a host default of it, since its history is one file per channel that never starts fresh. It is a function, so it is set only in code, as a host default (`discord.channelContext.conversation`) or per call. The window still ends at the assistant's last post; a forum that wants the whole post answers `"skip"` for the assistant's answers with `authors`.
2776
2776
  - It never fails the turn over Discord: a Discord error, such as a channel the bot cannot read, is logged and the turn runs without context.
2777
2777
 
2778
2778
  A plugin may mirror an outside chat into a channel through a webhook of its own, created by the bot, so that the application owns it; by default such a post counts as the assistant's own, which ends the window and is left out, and the people mirrored never reach a turn. `foreignWebhook(webhookId)` changes that for the webhooks it returns true for: a post through one is another author's, kept like another bot's (`bot: true`, `authorName` the post's username, `authorId` the webhook's id) and no longer ends the window, which then ends only at the assistant's own posts: its bot user's and every webhook `foreignWebhook` returns false for, such as an agent's voice. It may also return `"skip"` for a webhook that is neither, such as one the plugin posts its own status notices through: a post through it is dropped from the context and does not end the window, as if it were not in the channel, so notices between two mirrored posts neither appear as someone's words nor cut the window, and they are not counted among the messages delivered. Any answer other than `true` and `"skip"` reads as false. A skipped post is still one of the `fetch` messages read, so it uses the budget the window is chosen from. The host sets it as `discord.channelContext.foreignWebhook` and a call overrides it for that call; being a function, it can be set only in code. `authors(message)` is the same decision for any surface and any message, not only a webhook's: it receives the fetched message (`ChannelContextSource`: `id`, `authorId`, `authorName`, `bot`, `own`, `webhookId?`, `external?`, `attachments?`, `at`, `text`) and answers `"keep"` (another author's, which does not end the window; `foreignWebhook` returning `true`), `"skip"` (dropped as if it were not in the channel, without ending the window; `"skip"` of `foreignWebhook`), `"end"` (the assistant's own, which ends the window and is left out; `foreignWebhook` returning `false` for an application webhook) or `undefined`, which leaves the default: the assistant's own posts end the window and everything else is kept. Where it answers, it wins over `foreignWebhook`; it is a function, so it can be set only in code, as a host default (`discord.channelContext.authors`) or per call. Posts through a webhook that `foreignWebhook` returns true for are merged as near repeats only when the poster's name is the same too, since one webhook carries many people; every other message merges by author alone, as before. An edited message reads as Discord now holds it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-roundtable",
3
- "version": "0.50.0",
3
+ "version": "0.50.1",
4
4
  "description": "A plugin-driven Pi agent server for one owner, reached through Discord or the web",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -83,7 +83,10 @@ export interface ChannelContextOptions {
83
83
  * history. So a second person who asks in a post gets the earlier messages and the starter, and
84
84
  * the first who asks again after them gets them once more. `undefined` names the channel's own
85
85
  * conversation. One record is kept per channel either way, so the memory it takes is as without
86
- * this option. Default: none, every turn of a channel is one conversation's.
86
+ * this option. Set it as the host default or on every read of a channel: a read that names none
87
+ * is the channel's own conversation, a key of its own, so mixing named and unnamed reads starts
88
+ * the record anew each time. A callback that throws or returns a non-string is logged and counts
89
+ * as `undefined`. Default: none, every turn of a channel is one conversation's.
87
90
  */
88
91
  conversation?: (message: InboundMessage) => string | undefined;
89
92
  /** Which attachments of the kept messages are fetched for the turn; none by default. */
@@ -343,7 +343,10 @@ export class ChannelContextReader {
343
343
  if (surface !== "discord") return undefined;
344
344
  const settings = resolvedSettings(host, options);
345
345
  assertChannelContextSettings(settings);
346
- const seen = this.#seenIn(channelId, settings.conversation(message));
346
+ const seen = this.#seenIn(
347
+ channelId,
348
+ this.#conversationOf(settings, message),
349
+ );
347
350
  seen.add(message.messageId);
348
351
  try {
349
352
  const fetched = await this.#options.read(
@@ -441,6 +444,26 @@ export class ChannelContextReader {
441
444
  }
442
445
  }
443
446
 
447
+ /** The conversation the callback names; a throw or a value that is no string is logged and counts as none. */
448
+ #conversationOf(
449
+ settings: ChannelContextSettings,
450
+ message: InboundMessage,
451
+ ): string | undefined {
452
+ try {
453
+ const given: unknown = settings.conversation(message);
454
+ if (given === undefined || typeof given === "string") return given;
455
+ throw new TypeError(
456
+ `channel context option conversation returned ${typeof given}, not a string or undefined`,
457
+ );
458
+ } catch (error) {
459
+ this.#options.logger.warn(
460
+ { channel: message.channel, err: error },
461
+ "channel context conversation not named; the channel's own is used",
462
+ );
463
+ return undefined;
464
+ }
465
+ }
466
+
444
467
  /** The channel's record of what was handed over, made anew for a conversation other than its own. */
445
468
  #seenIn(channelId: string, conversation: string | undefined): Set<string> {
446
469
  const record = this.#seen.get(channelId);