pi-roundtable 0.53.0 → 0.53.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.53.2] - 2026-11-19
9
+
10
+ ### Changed
11
+
12
+ - Messages between an agent and its own temp knights no longer count toward the cap of 8 agent messages without the owner in between: the parent's `message_agent` to its temp knight, and the temp knight's to its parent, count on their own, toward a cap of 40 (`MAX_HELPER_MESSAGES`) that only stops the two writing to each other forever. The cap of 8 still holds for messages between independent agents, in the same run.
13
+
14
+ ## [0.53.1] - 2026-11-18
15
+
16
+ ### Added
17
+
18
+ - `InboundMessage.reference.channel` is the channel key of the message a reply quotes, which the Discord surface now sets on live and caught-up messages alike. A claim compares it with the message's own `channel` to tell a reply within the conversation, such as one to a forum post's starter, from a reply to a message of another channel, before it acts on `reference.attachments`.
19
+
8
20
  ## [0.53.0] - 2026-11-18
9
21
 
10
22
  ### Added
package/docs/plugins.md CHANGED
@@ -2983,6 +2983,7 @@ It resolves with `AttachmentBytes` (`id`, `name`, `contentType`, empty when Disc
2983
2983
  At most the host's `discord.attachmentRead.maxBytes` (default `ATTACHMENT_READ_MAX_BYTES`, 10 MiB; at most 100 MiB) is read, and a call's `maxBytes` may lower that, never raise it; a `maxBytes` that is not a positive whole number rejects with the code `invalid`. `discordPlugin` throws a `ConfigError` for an `attachmentRead.maxBytes` outside 1 to 100 MiB, as the config file does.
2984
2984
  Nothing is parsed, stored or logged: what the bytes are for (text extraction, an image for the model, a file in the workspace) is the plugin's call.
2985
2985
  The core checks nothing about who may read which channel beyond what the bot can see: pass the channel of the conversation the file was posted in, such as the addressed message's channel, never one a model names in a tool call.
2986
+ A reply may quote a message of another channel, so a reply's `reference.channel` names the channel the quoted message is in (the Discord surface sets it, live and when it catches up). It is a channel key, like `channel`: pass its id (`parseChannelKey(reference.channel).id`) to `readAttachment` to read a quoted file, and compare it with the message's `channel` before treating the quoted files as the conversation's own. A forum post's starter is in the post itself, so a reply that quotes it compares as the same channel; a message of a thread's parent text channel, such as the one the thread was started from, is in that text channel, so a reply that quotes it compares as another.
2986
2987
 
2987
2988
  ```ts
2988
2989
  import { AttachmentReadError, DISCORD } from "pi-roundtable/discord";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-roundtable",
3
- "version": "0.53.0",
3
+ "version": "0.53.2",
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",
@@ -19,6 +19,7 @@ import {
19
19
  agentReplyText,
20
20
  chainLimitReason,
21
21
  deliveredMessagePost,
22
+ helperChainLimitReason,
22
23
  } from "./agent-prompt.ts";
23
24
  import { answersTo } from "./agent-rules.ts";
24
25
  import type { Agent } from "./agent-store.ts";
@@ -26,6 +27,7 @@ import { conversationLabel, messageTarget } from "./message-target.ts";
26
27
  import {
27
28
  type Chain,
28
29
  MAX_CHAIN_MESSAGES,
30
+ MAX_HELPER_MESSAGES,
29
31
  type TurnHost,
30
32
  } from "./team-turn-types.ts";
31
33
 
@@ -77,7 +79,16 @@ export class AgentMessages {
77
79
  throw new AgentError(
78
80
  "message_agent can only be used during an agent turn.",
79
81
  );
80
- if (chain.messages >= MAX_CHAIN_MESSAGES)
82
+ // Between an agent and its own temp knight the run is one agent's work, so it does not count
83
+ // toward the chain cap; a higher cap of its own only stops the two writing to each other forever.
84
+ const kin = target.parent === caller.name || sender.parent === target.name;
85
+ if (kin && (chain.helperMessages ?? 0) >= MAX_HELPER_MESSAGES)
86
+ throw new AgentError(
87
+ helperChainLimitReason(
88
+ addressee(chain.speaker, this.#host.options.owner),
89
+ ),
90
+ );
91
+ if (!kin && chain.messages >= MAX_CHAIN_MESSAGES)
81
92
  throw new AgentError(
82
93
  chainLimitReason(addressee(chain.speaker, this.#host.options.owner)),
83
94
  );
@@ -87,7 +98,8 @@ export class AgentMessages {
87
98
  throw new AgentError(
88
99
  `"${target.name}" is a temp knight of "${target.parent}" and answers only the conversation that made it; ask "${target.parent}" there.`,
89
100
  );
90
- chain.messages += 1;
101
+ if (kin) chain.helperMessages = (chain.helperMessages ?? 0) + 1;
102
+ else chain.messages += 1;
91
103
  // A temp knight is working from the moment a message is handed to it until it has answered.
92
104
  this.#host.helpers.begin(target.name);
93
105
  // The request shows in the sender's turn channel as a small card under the sender's name.
@@ -190,6 +190,12 @@ export function chainLimitReason(who: OwnerIdentity): string {
190
190
  return `This chain of agent messages has reached 8 messages without ${o.name} in between, so it is stopped. Tell ${o.him} what was done and ask whether to continue.`;
191
191
  }
192
192
 
193
+ /** Why a parent and its own temp knights stop writing to each other without the owner in between. */
194
+ export function helperChainLimitReason(who: OwnerIdentity): string {
195
+ const o = ownerWords(who);
196
+ return `You and your temp knights have sent each other 40 messages without ${o.name} in between, so this is stopped. Tell ${o.him} what was done and ask whether to continue.`;
197
+ }
198
+
193
199
  /**
194
200
  * Where a turn's conversation is: the surface of the turn's conversation (`home`: the agent's own
195
201
  * channel or room, or the group's in a group round), named by its `label`, and the other surfaces the agents have places on:
@@ -25,11 +25,18 @@ import type { TeamPlaces } from "./team-places.ts";
25
25
 
26
26
  /** Agent messages without an owner message in between (spec behavior 13). */
27
27
  export const MAX_CHAIN_MESSAGES = 8;
28
+ /**
29
+ * Messages between an agent and its own temp knights in one run, which `MAX_CHAIN_MESSAGES` does
30
+ * not count; this higher cap only stops a parent and its temp knight writing to each other forever.
31
+ */
32
+ export const MAX_HELPER_MESSAGES = 40;
28
33
  export const BACKLOG_LIMIT = 40;
29
34
 
30
35
  /** A run of agent messages started by one owner message, schedule, or report. */
31
36
  export interface Chain {
32
37
  messages: number;
38
+ /** Messages between an agent and its own temp knights, counted apart from `messages`. */
39
+ helperMessages?: number;
33
40
  /** Whoever started the run; the agents it wakes work for the same person. */
34
41
  speaker: Speaker;
35
42
  }
@@ -117,6 +117,12 @@ export interface InboundMessage {
117
117
  reference?: {
118
118
  text: string;
119
119
  attachments: AttachmentRef[];
120
+ /**
121
+ * The channel the referenced message is in, when the surface reports it; Discord does. Compare
122
+ * it with `channel` to tell a reply within the conversation (such as to a forum post's starter)
123
+ * from one to a message of another channel.
124
+ */
125
+ channel?: ChannelKey;
120
126
  /** The surface's id of the referenced message's author, when the surface reports it. */
121
127
  authorId?: string;
122
128
  /** The name a webhook posted the referenced message under, such as an agent's. */
@@ -41,6 +41,8 @@ function referenceOf(referenced: Message, mention: RegExp) {
41
41
  .replace(mention, "")
42
42
  .trim(),
43
43
  attachments: attachmentRefs(referenced, referenced.id),
44
+ // The fetched message's own channel: a forum post's starter is in the post itself; a referenced message elsewhere, such as a crosspost's source, is in another channel.
45
+ channel: channelKey("discord", referenced.channelId),
44
46
  authorId: referenced.author.id,
45
47
  ...(referenced.webhookId
46
48
  ? { webhookName: referenced.author.username }