@relaymessenger/pi 0.1.4-staging.35 → 0.1.4-staging.37

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 +12 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -179,6 +179,17 @@ export class PiChannel {
179
179
  const messages = answerMessages(answer);
180
180
  if (messages[0]?.error)
181
181
  console.error(`Relay: the component block in pi's answer was left as text: ${messages[0].error}.`);
182
+ // An answer to another agent replies to its Message, as a bot's reply
183
+ // names the message it answers (Telegram `reply_to_message_id`); Relay's
184
+ // A2A door gives a calling agent the reply that names its message. A
185
+ // person's Message is not named, so the chat looks as it always has. An
186
+ // agent may not reply to buttons or a selection, and a reply names part 0.
187
+ // Turns in one chat already run one after another, so an agent's two
188
+ // messages each get their own answer.
189
+ const opening = data.parts[0]?.type;
190
+ const replyTo = data.sender_handle.kind === "agent" && opening !== "buttons" && opening !== "selection"
191
+ ? { reply_to: { message_id: data.id } }
192
+ : {};
182
193
  for (const [index, message] of messages.entries()) {
183
194
  const key = `pi-${event.event_id}-${index}`;
184
195
  let parts = message.parts;
@@ -193,7 +204,7 @@ export class PiChannel {
193
204
  continue;
194
205
  }
195
206
  }
196
- await this.#relay.chats.messages.send(data.chat.id, { message: { parts, idempotency_key: key } });
207
+ await this.#relay.chats.messages.send(data.chat.id, { message: { parts, idempotency_key: key, ...(index === 0 ? replyTo : {}) } });
197
208
  }
198
209
  }
199
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relaymessenger/pi",
3
- "version": "0.1.4-staging.35",
3
+ "version": "0.1.4-staging.37",
4
4
  "description": "Relay Messenger channel for Pi over Relay v1 WebSocket delivery.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,7 +34,7 @@
34
34
  "test": "vitest run"
35
35
  },
36
36
  "dependencies": {
37
- "@relaymessenger/sdk": "0.3.6-staging.36"
37
+ "@relaymessenger/sdk": "0.3.6-staging.38"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@earendil-works/pi-coding-agent": "0.86.0",