@poncho-ai/messaging 0.7.7 → 0.7.9
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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +4 -13
- package/package.json +1 -1
- package/src/adapters/telegram/index.ts +10 -24
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @poncho-ai/messaging@0.7.
|
|
2
|
+
> @poncho-ai/messaging@0.7.9 build /home/runner/work/poncho-ai/poncho-ai/packages/messaging
|
|
3
3
|
> tsup src/index.ts --format esm --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
[34mCLI[39m tsup v8.5.1
|
|
8
8
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
11
|
-
[32mESM[39m ⚡️ Build success in
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m51.93 KB[39m
|
|
11
|
+
[32mESM[39m ⚡️ Build success in 52ms
|
|
12
12
|
[34mDTS[39m Build start
|
|
13
|
-
[32mDTS[39m ⚡️ Build success in
|
|
14
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m11.
|
|
13
|
+
[32mDTS[39m ⚡️ Build success in 4732ms
|
|
14
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m11.66 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @poncho-ai/messaging
|
|
2
2
|
|
|
3
|
+
## 0.7.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#71](https://github.com/cesr/poncho-ai/pull/71) [`3e5bf7e`](https://github.com/cesr/poncho-ai/commit/3e5bf7e527e394c5f823beac90712756e57cd491) Thanks [@cesr](https://github.com/cesr)! - Fix Telegram tool approval handler never persisting the approval decision, preventing the resume-from-checkpoint flow from triggering. Make answerCallbackQuery best-effort so transient fetch failures don't block approval processing.
|
|
8
|
+
|
|
9
|
+
## 0.7.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`30026c5`](https://github.com/cesr/poncho-ai/commit/30026c5eba3f714bb80c2402c5e8f32c6fd38d87) Thanks [@cesr](https://github.com/cesr)! - Fix Telegram conversation instability on serverless: use stable platformThreadId instead of in-memory session counter.
|
|
14
|
+
|
|
3
15
|
## 0.7.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -233,7 +233,6 @@ declare class TelegramAdapter implements MessagingAdapter {
|
|
|
233
233
|
private handler;
|
|
234
234
|
private resetHandler;
|
|
235
235
|
private approvalDecisionHandler;
|
|
236
|
-
private readonly sessionCounters;
|
|
237
236
|
private readonly approvalMessageIds;
|
|
238
237
|
private lastUpdateId;
|
|
239
238
|
constructor(options?: TelegramAdapterOptions);
|
|
@@ -252,7 +251,6 @@ declare class TelegramAdapter implements MessagingAdapter {
|
|
|
252
251
|
updateApprovalMessage(approvalId: string, decision: "approved" | "denied", tool: string): Promise<void>;
|
|
253
252
|
private handleRequest;
|
|
254
253
|
private handleCallbackQuery;
|
|
255
|
-
private sessionKey;
|
|
256
254
|
private extractFiles;
|
|
257
255
|
}
|
|
258
256
|
|
package/dist/index.js
CHANGED
|
@@ -1218,7 +1218,6 @@ var TelegramAdapter = class {
|
|
|
1218
1218
|
handler;
|
|
1219
1219
|
resetHandler;
|
|
1220
1220
|
approvalDecisionHandler;
|
|
1221
|
-
sessionCounters = /* @__PURE__ */ new Map();
|
|
1222
1221
|
approvalMessageIds = /* @__PURE__ */ new Map();
|
|
1223
1222
|
lastUpdateId = 0;
|
|
1224
1223
|
constructor(options = {}) {
|
|
@@ -1436,18 +1435,15 @@ ${inputSummary}` : "(no input)"
|
|
|
1436
1435
|
res.end();
|
|
1437
1436
|
return;
|
|
1438
1437
|
}
|
|
1439
|
-
const key2 = this.sessionKey(message);
|
|
1440
|
-
const current = this.sessionCounters.get(key2) ?? 0;
|
|
1441
|
-
this.sessionCounters.set(key2, current + 1);
|
|
1442
1438
|
res.writeHead(200);
|
|
1443
1439
|
res.end();
|
|
1444
1440
|
if (this.resetHandler) {
|
|
1445
1441
|
const topicId2 = message.message_thread_id;
|
|
1446
|
-
const
|
|
1442
|
+
const threadId = topicId2 ? `${chatId}:${topicId2}:0` : `${chatId}:0`;
|
|
1447
1443
|
try {
|
|
1448
1444
|
await this.resetHandler("telegram", {
|
|
1449
1445
|
channelId: chatId,
|
|
1450
|
-
platformThreadId:
|
|
1446
|
+
platformThreadId: threadId
|
|
1451
1447
|
});
|
|
1452
1448
|
} catch (err) {
|
|
1453
1449
|
console.error("[telegram-adapter] reset handler error:", err instanceof Error ? err.message : err);
|
|
@@ -1481,10 +1477,8 @@ ${inputSummary}` : "(no input)"
|
|
|
1481
1477
|
res.end();
|
|
1482
1478
|
if (!this.handler) return;
|
|
1483
1479
|
const files = await this.extractFiles(message);
|
|
1484
|
-
const key = this.sessionKey(message);
|
|
1485
|
-
const session = this.sessionCounters.get(key) ?? 0;
|
|
1486
1480
|
const topicId = message.message_thread_id;
|
|
1487
|
-
const platformThreadId = topicId ? `${chatId}:${topicId}
|
|
1481
|
+
const platformThreadId = topicId ? `${chatId}:${topicId}:0` : `${chatId}:0`;
|
|
1488
1482
|
const userId = String(message.from?.id ?? "unknown");
|
|
1489
1483
|
const userName = [message.from?.first_name, message.from?.last_name].filter(Boolean).join(" ") || void 0;
|
|
1490
1484
|
const ponchoMessage = {
|
|
@@ -1532,6 +1526,7 @@ ${inputSummary}` : "(no input)"
|
|
|
1532
1526
|
const chatId = query.message?.chat.id ? String(query.message.chat.id) : void 0;
|
|
1533
1527
|
await answerCallbackQuery(this.botToken, query.id, {
|
|
1534
1528
|
text: approved ? "Approved" : "Denied"
|
|
1529
|
+
}).catch(() => {
|
|
1535
1530
|
});
|
|
1536
1531
|
if (this.approvalDecisionHandler && chatId) {
|
|
1537
1532
|
await this.approvalDecisionHandler(approvalId, approved, chatId);
|
|
@@ -1540,10 +1535,6 @@ ${inputSummary}` : "(no input)"
|
|
|
1540
1535
|
// -----------------------------------------------------------------------
|
|
1541
1536
|
// Helpers
|
|
1542
1537
|
// -----------------------------------------------------------------------
|
|
1543
|
-
sessionKey(message) {
|
|
1544
|
-
const chatId = String(message.chat.id);
|
|
1545
|
-
return message.message_thread_id ? `${chatId}:${message.message_thread_id}` : chatId;
|
|
1546
|
-
}
|
|
1547
1538
|
async extractFiles(message) {
|
|
1548
1539
|
const files = [];
|
|
1549
1540
|
try {
|
package/package.json
CHANGED
|
@@ -85,7 +85,6 @@ export class TelegramAdapter implements MessagingAdapter {
|
|
|
85
85
|
private handler: IncomingMessageHandler | undefined;
|
|
86
86
|
private resetHandler: ResetHandler | undefined;
|
|
87
87
|
private approvalDecisionHandler: TelegramApprovalDecisionHandler | undefined;
|
|
88
|
-
private readonly sessionCounters = new Map<string, number>();
|
|
89
88
|
private readonly approvalMessageIds = new Map<string, { chatId: string; messageId: number }>();
|
|
90
89
|
private lastUpdateId = 0;
|
|
91
90
|
|
|
@@ -374,25 +373,19 @@ export class TelegramAdapter implements MessagingAdapter {
|
|
|
374
373
|
return;
|
|
375
374
|
}
|
|
376
375
|
|
|
377
|
-
const key = this.sessionKey(message);
|
|
378
|
-
const current = this.sessionCounters.get(key) ?? 0;
|
|
379
|
-
this.sessionCounters.set(key, current + 1);
|
|
380
|
-
|
|
381
376
|
res.writeHead(200);
|
|
382
377
|
res.end();
|
|
383
378
|
|
|
384
|
-
//
|
|
385
|
-
// The in-memory counter handles long-running processes; the bridge
|
|
386
|
-
// clears messages in the conversation store for serverless.
|
|
379
|
+
// Clear conversation in the store so the next message starts fresh.
|
|
387
380
|
if (this.resetHandler) {
|
|
388
381
|
const topicId = message.message_thread_id;
|
|
389
|
-
const
|
|
390
|
-
? `${chatId}:${topicId}
|
|
391
|
-
: `${chatId}
|
|
382
|
+
const threadId = topicId
|
|
383
|
+
? `${chatId}:${topicId}:0`
|
|
384
|
+
: `${chatId}:0`;
|
|
392
385
|
try {
|
|
393
386
|
await this.resetHandler("telegram", {
|
|
394
387
|
channelId: chatId,
|
|
395
|
-
platformThreadId:
|
|
388
|
+
platformThreadId: threadId,
|
|
396
389
|
});
|
|
397
390
|
} catch (err) {
|
|
398
391
|
console.error("[telegram-adapter] reset handler error:", err instanceof Error ? err.message : err);
|
|
@@ -440,12 +433,12 @@ export class TelegramAdapter implements MessagingAdapter {
|
|
|
440
433
|
const files = await this.extractFiles(message);
|
|
441
434
|
|
|
442
435
|
// -- Build thread ref -------------------------------------------------
|
|
443
|
-
|
|
444
|
-
|
|
436
|
+
// Always use a fixed session component so the conversationId is stable
|
|
437
|
+
// across serverless cold starts. /new resets via the store instead.
|
|
445
438
|
const topicId = message.message_thread_id;
|
|
446
439
|
const platformThreadId = topicId
|
|
447
|
-
? `${chatId}:${topicId}
|
|
448
|
-
: `${chatId}
|
|
440
|
+
? `${chatId}:${topicId}:0`
|
|
441
|
+
: `${chatId}:0`;
|
|
449
442
|
|
|
450
443
|
const userId = String(message.from?.id ?? "unknown");
|
|
451
444
|
const userName =
|
|
@@ -509,7 +502,7 @@ export class TelegramAdapter implements MessagingAdapter {
|
|
|
509
502
|
|
|
510
503
|
await answerCallbackQuery(this.botToken, query.id, {
|
|
511
504
|
text: approved ? "Approved" : "Denied",
|
|
512
|
-
});
|
|
505
|
+
}).catch(() => {});
|
|
513
506
|
|
|
514
507
|
if (this.approvalDecisionHandler && chatId) {
|
|
515
508
|
await this.approvalDecisionHandler(approvalId, approved, chatId);
|
|
@@ -520,13 +513,6 @@ export class TelegramAdapter implements MessagingAdapter {
|
|
|
520
513
|
// Helpers
|
|
521
514
|
// -----------------------------------------------------------------------
|
|
522
515
|
|
|
523
|
-
private sessionKey(message: TelegramMessage): string {
|
|
524
|
-
const chatId = String(message.chat.id);
|
|
525
|
-
return message.message_thread_id
|
|
526
|
-
? `${chatId}:${message.message_thread_id}`
|
|
527
|
-
: chatId;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
516
|
private async extractFiles(
|
|
531
517
|
message: TelegramMessage,
|
|
532
518
|
): Promise<FileAttachment[]> {
|