@llblab/pi-telegram 0.52.2 → 0.53.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/AGENTS.md +9 -7
- package/BACKLOG.md +1 -18
- package/CHANGELOG.md +15 -0
- package/README.md +7 -11
- package/api/commands.ts +3 -0
- package/dist/api/commands.d.ts +1 -1
- package/dist/lib/activity-verbosity.d.ts +1 -5
- package/dist/lib/activity-verbosity.js +15 -42
- package/dist/lib/activity.d.ts +9 -0
- package/dist/lib/activity.js +39 -10
- package/dist/lib/agent-messages.js +7 -3
- package/dist/lib/bindings.d.ts +43 -5
- package/dist/lib/bindings.js +163 -20
- package/dist/lib/bus-api.d.ts +12 -0
- package/dist/lib/bus-api.js +182 -79
- package/dist/lib/bus-follower.d.ts +111 -31
- package/dist/lib/bus-follower.js +1324 -359
- package/dist/lib/bus-leader.d.ts +41 -91
- package/dist/lib/bus-leader.js +969 -637
- package/dist/lib/bus-transport.js +16 -9
- package/dist/lib/bus.d.ts +215 -18
- package/dist/lib/bus.js +1048 -327
- package/dist/lib/channel-posts.d.ts +5 -0
- package/dist/lib/channel-posts.js +434 -261
- package/dist/lib/command-templates.d.ts +26 -5
- package/dist/lib/command-templates.js +92 -176
- package/dist/lib/commands.d.ts +168 -82
- package/dist/lib/commands.js +1409 -291
- package/dist/lib/config.d.ts +1 -8
- package/dist/lib/config.js +34 -76
- package/dist/lib/delivery.d.ts +2 -2
- package/dist/lib/delivery.js +16 -16
- package/dist/lib/extension.js +639 -171
- package/dist/lib/generative-app-worker.mjs +19 -7
- package/dist/lib/generative-apps.d.ts +0 -5
- package/dist/lib/generative-apps.js +61 -49
- package/dist/lib/inbound.d.ts +5 -0
- package/dist/lib/inbound.js +35 -59
- package/dist/lib/journal.d.ts +33 -3
- package/dist/lib/journal.js +2063 -782
- package/dist/lib/lifecycle.d.ts +2 -6
- package/dist/lib/lifecycle.js +75 -58
- package/dist/lib/locks.d.ts +29 -3
- package/dist/lib/locks.js +289 -108
- package/dist/lib/logging.js +50 -14
- package/dist/lib/media.d.ts +22 -1
- package/dist/lib/media.js +46 -28
- package/dist/lib/menu-model.d.ts +19 -5
- package/dist/lib/menu-model.js +53 -11
- package/dist/lib/menu-queue.d.ts +5 -4
- package/dist/lib/menu-queue.js +45 -63
- package/dist/lib/menu-settings.d.ts +5 -4
- package/dist/lib/menu-settings.js +114 -78
- package/dist/lib/menu-status.d.ts +1 -1
- package/dist/lib/menu-status.js +8 -25
- package/dist/lib/menu-thinking.d.ts +6 -1
- package/dist/lib/menu-thinking.js +14 -21
- package/dist/lib/menu.d.ts +8 -61
- package/dist/lib/menu.js +92 -164
- package/dist/lib/model.d.ts +1 -1
- package/dist/lib/model.js +2 -16
- package/dist/lib/outbound-attachments.d.ts +6 -27
- package/dist/lib/outbound-attachments.js +45 -38
- package/dist/lib/outbound-buttons.js +22 -16
- package/dist/lib/outbound-markup.d.ts +0 -2
- package/dist/lib/outbound-markup.js +51 -64
- package/dist/lib/outbound-voice.js +6 -3
- package/dist/lib/outbound.d.ts +6 -6
- package/dist/lib/outbound.js +65 -51
- package/dist/lib/ownership.js +6 -2
- package/dist/lib/paths.d.ts +5 -0
- package/dist/lib/paths.js +37 -21
- package/dist/lib/pi.d.ts +2 -0
- package/dist/lib/pi.js +8 -1
- package/dist/lib/polling.d.ts +21 -37
- package/dist/lib/polling.js +59 -50
- package/dist/lib/preview.js +39 -19
- package/dist/lib/process-identity.d.ts +24 -0
- package/dist/lib/process-identity.js +133 -0
- package/dist/lib/prompts.js +2 -7
- package/dist/lib/queue.d.ts +14 -16
- package/dist/lib/queue.js +252 -127
- package/dist/lib/recovery.d.ts +2 -83
- package/dist/lib/recovery.js +20 -274
- package/dist/lib/replies.d.ts +16 -24
- package/dist/lib/replies.js +99 -116
- package/dist/lib/routing.d.ts +120 -7
- package/dist/lib/routing.js +4667 -1152
- package/dist/lib/runtime.d.ts +1 -11
- package/dist/lib/sections.d.ts +4 -29
- package/dist/lib/sections.js +7 -20
- package/dist/lib/skills.js +4 -3
- package/dist/lib/status.js +86 -57
- package/dist/lib/sync.d.ts +1 -3
- package/dist/lib/sync.js +67 -43
- package/dist/lib/target.d.ts +4 -0
- package/dist/lib/target.js +18 -0
- package/dist/lib/telegram-api.d.ts +18 -13
- package/dist/lib/telegram-api.js +148 -53
- package/dist/lib/text-groups.js +4 -39
- package/dist/lib/thread-cleanup-manager.d.ts +6 -27
- package/dist/lib/thread-cleanup-manager.js +369 -186
- package/dist/lib/thread-display.d.ts +1 -2
- package/dist/lib/thread-display.js +58 -38
- package/dist/lib/thread-naming.d.ts +28 -8
- package/dist/lib/thread-naming.js +175 -66
- package/dist/lib/thread-reconciler.d.ts +42 -16
- package/dist/lib/thread-reconciler.js +90 -50
- package/dist/lib/threads.d.ts +82 -20
- package/dist/lib/threads.js +2247 -855
- package/dist/lib/time-injection.js +1 -2
- package/dist/lib/turns.js +1 -19
- package/dist/lib/updates.d.ts +169 -80
- package/dist/lib/updates.js +2418 -641
- package/dist/lib/voice.d.ts +7 -22
- package/dist/lib/voice.js +7 -22
- package/dist/lib/wire.js +1 -1
- package/dist/lib/workspace-admission.d.ts +3 -1
- package/dist/lib/workspace-admission.js +425 -211
- package/dist/lib/workspace-identity.js +8 -13
- package/dist/lib/workspace-retirement.d.ts +1 -1
- package/dist/lib/workspace-retirement.js +328 -140
- package/dist/lib/workspace-slots.js +8 -4
- package/dist/package.json +1 -1
- package/docs/architecture.md +31 -29
- package/docs/inbound.md +1 -1
- package/docs/multi-instance-bus.md +15 -3
- package/docs/outbound.md +1 -1
- package/docs/public-api.md +29 -1
- package/docs/ui-style.md +25 -8
- package/lib/activity-verbosity.ts +59 -82
- package/lib/activity.ts +146 -102
- package/lib/agent-messages.ts +12 -5
- package/lib/bindings.ts +389 -82
- package/lib/bus-api.ts +263 -102
- package/lib/bus-follower.ts +2440 -601
- package/lib/bus-leader.ts +2209 -1290
- package/lib/bus-transport.ts +46 -12
- package/lib/bus.ts +1673 -444
- package/lib/channel-posts.ts +848 -327
- package/lib/command-templates.ts +152 -265
- package/lib/commands.ts +2398 -555
- package/lib/config.ts +177 -170
- package/lib/delivery.ts +41 -29
- package/lib/extension.ts +1206 -433
- package/lib/generative-app-worker.mjs +19 -7
- package/lib/generative-apps.ts +324 -211
- package/lib/inbound.ts +95 -97
- package/lib/journal.ts +5311 -1763
- package/lib/keyboard.ts +1 -3
- package/lib/lifecycle.ts +128 -78
- package/lib/locks.ts +677 -203
- package/lib/logging.ts +147 -58
- package/lib/media.ts +82 -43
- package/lib/menu-model.ts +85 -18
- package/lib/menu-queue.ts +88 -129
- package/lib/menu-settings.ts +260 -155
- package/lib/menu-status.ts +20 -60
- package/lib/menu-thinking.ts +41 -56
- package/lib/menu.ts +112 -285
- package/lib/model.ts +8 -22
- package/lib/outbound-attachments.ts +156 -125
- package/lib/outbound-buttons.ts +76 -49
- package/lib/outbound-markup.ts +96 -94
- package/lib/outbound-voice.ts +33 -27
- package/lib/outbound.ts +128 -125
- package/lib/ownership.ts +19 -10
- package/lib/paths.ts +148 -49
- package/lib/pi.ts +35 -15
- package/lib/polling.ts +144 -147
- package/lib/preview.ts +93 -40
- package/lib/process-identity.ts +164 -0
- package/lib/prompts.ts +4 -11
- package/lib/queue.ts +516 -301
- package/lib/recovery.ts +50 -454
- package/lib/rendering.ts +1 -3
- package/lib/replies.ts +248 -209
- package/lib/routing.ts +8509 -2186
- package/lib/runtime.ts +1 -12
- package/lib/sections.ts +24 -89
- package/lib/setup.ts +1 -3
- package/lib/skills.ts +9 -4
- package/lib/status.ts +215 -110
- package/lib/sync.ts +448 -361
- package/lib/target.ts +22 -3
- package/lib/telegram-api.ts +302 -127
- package/lib/text-groups.ts +5 -39
- package/lib/thread-cleanup-manager.ts +833 -331
- package/lib/thread-display.ts +213 -97
- package/lib/thread-naming.ts +232 -87
- package/lib/thread-reconciler.ts +155 -72
- package/lib/threads.ts +5318 -1845
- package/lib/time-injection.ts +1 -4
- package/lib/turns.ts +15 -28
- package/lib/updates.ts +5184 -1612
- package/lib/voice.ts +7 -35
- package/lib/wire.ts +1 -1
- package/lib/workspace-admission.ts +996 -416
- package/lib/workspace-identity.ts +14 -17
- package/lib/workspace-retirement.ts +878 -376
- package/lib/workspace-slots.ts +22 -13
- package/package.json +1 -1
- package/scripts/check-downgrade.mjs +0 -472
- package/scripts/measure-workspace.mjs +0 -108
package/lib/outbound-markup.ts
CHANGED
|
@@ -152,9 +152,7 @@ export function replaceTopLevelHtmlComments(
|
|
|
152
152
|
return result + markdown.slice(offset);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
function findTopLevelOpenOrPartialHtmlCommentIndex(
|
|
156
|
-
markdown: string,
|
|
157
|
-
): number {
|
|
155
|
+
function findTopLevelOpenOrPartialHtmlCommentIndex(markdown: string): number {
|
|
158
156
|
const { openCommentStart } = collectTopLevelHtmlComments(markdown);
|
|
159
157
|
if (openCommentStart !== undefined) return openCommentStart;
|
|
160
158
|
let offset = 0;
|
|
@@ -231,7 +229,9 @@ function parseTelegramJsonObjectCandidate(
|
|
|
231
229
|
source: string,
|
|
232
230
|
): Record<string, unknown> | undefined {
|
|
233
231
|
const normalized = removeTelegramJsonTrailingCommas(source);
|
|
234
|
-
for (const candidate of normalized === source
|
|
232
|
+
for (const candidate of normalized === source
|
|
233
|
+
? [source]
|
|
234
|
+
: [source, normalized]) {
|
|
235
235
|
try {
|
|
236
236
|
const value: unknown = JSON.parse(candidate);
|
|
237
237
|
if (isTelegramActionPayload(value)) return value;
|
|
@@ -249,41 +249,62 @@ function looksLikeTelegramNamedJsonObject(
|
|
|
249
249
|
return /^\{\s*"(?:[^"\\]|\\.)*"\s*:/u.test(source.slice(offset));
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
/** Blank one structured span so tolerant attribute parsing never reads keys inside rejected JSON or matrices. */
|
|
253
|
+
function blankTelegramActionSpan(
|
|
254
|
+
text: string,
|
|
255
|
+
start: number,
|
|
256
|
+
end: number,
|
|
257
|
+
): string {
|
|
258
|
+
return `${text.slice(0, start)}${" ".repeat(end - start)}${text.slice(end)}`;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Scans one action comment for its first accepted structured payload. Otherwise returns the attribute envelope
|
|
263
|
+
* with every structured span blanked; implausible `[` starts are skipped without a parse attempt.
|
|
264
|
+
*/
|
|
265
|
+
function scanTelegramActionComment<T>(
|
|
253
266
|
comment: TelegramTopLevelHtmlComment,
|
|
254
267
|
command: string,
|
|
255
|
-
|
|
268
|
+
parseStructured: (content: string, offset: number) => T | undefined,
|
|
269
|
+
): { payload: T } | { attributeEnvelope: string } | undefined {
|
|
256
270
|
let content = comment.content.replace(/^\s+/, "").replace(/^!/, "");
|
|
257
271
|
if (!content.startsWith(command)) return undefined;
|
|
258
272
|
content = content.slice(command.length);
|
|
259
273
|
let attributeEnvelope = content;
|
|
260
274
|
for (let offset = 0; offset < content.length; offset += 1) {
|
|
261
|
-
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const noiseEnd = findTelegramStructuredPayloadEnd(content, offset);
|
|
267
|
-
if (noiseEnd !== undefined) {
|
|
268
|
-
attributeEnvelope = `${attributeEnvelope.slice(0, offset)}${" ".repeat(noiseEnd - offset)}${attributeEnvelope.slice(noiseEnd)}`;
|
|
269
|
-
offset = noiseEnd - 1;
|
|
270
|
-
}
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
if (content[offset] === "{") {
|
|
274
|
-
const parsed = parseTelegramAdaptiveActionPayloadRows(
|
|
275
|
-
content.slice(offset),
|
|
276
|
-
parseTelegramVoiceCompactActionPayload,
|
|
277
|
-
{ allowTrailing: true },
|
|
278
|
-
);
|
|
279
|
-
if (parsed) return parsed.rows[0]![0];
|
|
275
|
+
const char = content[offset];
|
|
276
|
+
if (char !== "{" && char !== "[") continue;
|
|
277
|
+
if (char === "{" || isPlausibleTelegramMatrixStart(content, offset)) {
|
|
278
|
+
const payload = parseStructured(content, offset);
|
|
279
|
+
if (payload !== undefined) return { payload };
|
|
280
280
|
}
|
|
281
281
|
const end = findTelegramStructuredPayloadEnd(content, offset);
|
|
282
282
|
if (end === undefined) continue;
|
|
283
|
-
attributeEnvelope =
|
|
283
|
+
attributeEnvelope = blankTelegramActionSpan(attributeEnvelope, offset, end);
|
|
284
284
|
offset = end - 1;
|
|
285
285
|
}
|
|
286
|
-
return
|
|
286
|
+
return { attributeEnvelope };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function parseTelegramActionPayload(
|
|
290
|
+
comment: TelegramTopLevelHtmlComment,
|
|
291
|
+
command: string,
|
|
292
|
+
): Record<string, unknown> | undefined {
|
|
293
|
+
const scanned = scanTelegramActionComment(
|
|
294
|
+
comment,
|
|
295
|
+
command,
|
|
296
|
+
(content, offset) =>
|
|
297
|
+
content[offset] === "{"
|
|
298
|
+
? parseTelegramAdaptiveActionPayloadRows(
|
|
299
|
+
content.slice(offset),
|
|
300
|
+
parseTelegramVoiceCompactActionPayload,
|
|
301
|
+
{ allowTrailing: true },
|
|
302
|
+
)?.rows[0]![0]
|
|
303
|
+
: undefined,
|
|
304
|
+
);
|
|
305
|
+
if (!scanned) return undefined;
|
|
306
|
+
if ("payload" in scanned) return scanned.payload;
|
|
307
|
+
return parseTolerantTelegramAttributes(scanned.attributeEnvelope, [
|
|
287
308
|
"text",
|
|
288
309
|
"value",
|
|
289
310
|
"lang",
|
|
@@ -311,8 +332,14 @@ function parseTelegramButtonCompactActionPayload(
|
|
|
311
332
|
selectedStyle !== "success" &&
|
|
312
333
|
selectedStyle !== "danger" &&
|
|
313
334
|
!(atoms.length === 4 && selectedStyle === "")
|
|
314
|
-
)
|
|
315
|
-
|
|
335
|
+
)
|
|
336
|
+
return undefined;
|
|
337
|
+
if (
|
|
338
|
+
atoms.length === 4 &&
|
|
339
|
+
!isDisabled &&
|
|
340
|
+
disabled !== "0" &&
|
|
341
|
+
disabled !== "false"
|
|
342
|
+
) {
|
|
316
343
|
return undefined;
|
|
317
344
|
}
|
|
318
345
|
return {
|
|
@@ -377,16 +404,15 @@ function parseTelegramAdaptiveActionPayloadRows(
|
|
|
377
404
|
continue;
|
|
378
405
|
}
|
|
379
406
|
if (character === "|") {
|
|
380
|
-
if (atomSources.length >= (options.maxCompactAtoms ?? 3))
|
|
407
|
+
if (atomSources.length >= (options.maxCompactAtoms ?? 3))
|
|
408
|
+
return undefined;
|
|
381
409
|
atomSources.push([]);
|
|
382
410
|
offset += 1;
|
|
383
411
|
continue;
|
|
384
412
|
}
|
|
385
413
|
if (character === "}") {
|
|
386
414
|
offset += 1;
|
|
387
|
-
const atoms = atomSources.map((atom) =>
|
|
388
|
-
normalizeAtom(atom.join("")),
|
|
389
|
-
);
|
|
415
|
+
const atoms = atomSources.map((atom) => normalizeAtom(atom.join("")));
|
|
390
416
|
if (atoms.some((atom) => atom === undefined)) return undefined;
|
|
391
417
|
return parseCompactPayload(atoms as string[]);
|
|
392
418
|
}
|
|
@@ -422,7 +448,8 @@ function parseTelegramAdaptiveActionPayloadRows(
|
|
|
422
448
|
if (
|
|
423
449
|
(character === "}" && opening !== "{") ||
|
|
424
450
|
(character === "]" && opening !== "[")
|
|
425
|
-
)
|
|
451
|
+
)
|
|
452
|
+
return undefined;
|
|
426
453
|
if (stack.length > 0) continue;
|
|
427
454
|
const candidate = source.slice(start, index + 1);
|
|
428
455
|
const value = parseTelegramJsonObjectCandidate(candidate);
|
|
@@ -499,9 +526,7 @@ function parseTelegramAdaptiveActionPayloadRows(
|
|
|
499
526
|
};
|
|
500
527
|
|
|
501
528
|
skipWhitespace();
|
|
502
|
-
const rows = source[offset] === "{"
|
|
503
|
-
? parseVerticalSequence()
|
|
504
|
-
: parseMatrix();
|
|
529
|
+
const rows = source[offset] === "{" ? parseVerticalSequence() : parseMatrix();
|
|
505
530
|
if (!rows) return undefined;
|
|
506
531
|
skipWhitespace();
|
|
507
532
|
if (!options.allowTrailing && offset !== source.length) return undefined;
|
|
@@ -546,9 +571,7 @@ function isPlausibleTelegramMatrixStart(
|
|
|
546
571
|
let offset = start + 1;
|
|
547
572
|
while (/\s/u.test(source[offset] ?? "")) offset += 1;
|
|
548
573
|
return (
|
|
549
|
-
source[offset] === "{" ||
|
|
550
|
-
source[offset] === "[" ||
|
|
551
|
-
source[offset] === "]"
|
|
574
|
+
source[offset] === "{" || source[offset] === "[" || source[offset] === "]"
|
|
552
575
|
);
|
|
553
576
|
}
|
|
554
577
|
|
|
@@ -566,60 +589,41 @@ export function parseTelegramActionPayloadRows(
|
|
|
566
589
|
comment: TelegramTopLevelHtmlComment,
|
|
567
590
|
command: string,
|
|
568
591
|
): Record<string, unknown>[][] | undefined {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
586
|
-
const parsed = parseTelegramAdaptiveActionPayloadRows(
|
|
587
|
-
content.slice(offset),
|
|
588
|
-
parseTelegramButtonCompactActionPayload,
|
|
589
|
-
{ allowTrailing: true, maxCompactAtoms: 4 },
|
|
590
|
-
);
|
|
591
|
-
if (parsed) return parsed.rows;
|
|
592
|
-
const end = findTelegramStructuredPayloadEnd(content, offset);
|
|
593
|
-
if (end === undefined) continue;
|
|
594
|
-
attributeEnvelope = `${attributeEnvelope.slice(0, offset)}${" ".repeat(end - offset)}${attributeEnvelope.slice(end)}`;
|
|
595
|
-
offset = end - 1;
|
|
596
|
-
}
|
|
597
|
-
const attributes = parseTolerantTelegramAttributes(attributeEnvelope, [
|
|
598
|
-
"label",
|
|
599
|
-
"prompt",
|
|
600
|
-
"value",
|
|
601
|
-
"selected_style",
|
|
602
|
-
"disabled",
|
|
603
|
-
]);
|
|
592
|
+
const scanned = scanTelegramActionComment(
|
|
593
|
+
comment,
|
|
594
|
+
command,
|
|
595
|
+
(content, offset) =>
|
|
596
|
+
parseTelegramAdaptiveActionPayloadRows(
|
|
597
|
+
content.slice(offset),
|
|
598
|
+
parseTelegramButtonCompactActionPayload,
|
|
599
|
+
{ allowTrailing: true, maxCompactAtoms: 4 },
|
|
600
|
+
)?.rows,
|
|
601
|
+
);
|
|
602
|
+
if (!scanned) return undefined;
|
|
603
|
+
if ("payload" in scanned) return scanned.payload;
|
|
604
|
+
const attributes = parseTolerantTelegramAttributes(
|
|
605
|
+
scanned.attributeEnvelope,
|
|
606
|
+
["label", "prompt", "value", "selected_style", "disabled"],
|
|
607
|
+
);
|
|
604
608
|
if (!attributes) return undefined;
|
|
605
|
-
return [
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
609
|
+
return [
|
|
610
|
+
[
|
|
611
|
+
{
|
|
612
|
+
...attributes,
|
|
613
|
+
...(attributes.disabled === "true" || attributes.disabled === "false"
|
|
614
|
+
? { disabled: attributes.disabled === "true" }
|
|
615
|
+
: {}),
|
|
616
|
+
},
|
|
617
|
+
],
|
|
618
|
+
];
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function normalizeMarkdownAfterVoiceExtraction(markdown: string): string {
|
|
616
622
|
return markdown.replace(/\n{3,}/g, "\n\n").trim();
|
|
617
623
|
}
|
|
618
624
|
|
|
619
625
|
function isTelegramCommentOnlyLinePrefix(value: string): boolean {
|
|
620
|
-
return /^[ \t]*(?:(?:>[ \t]*)+)?(?:(?:[-+*]|\d+[.)])[ \t]+)?$/u.test(
|
|
621
|
-
value,
|
|
622
|
-
);
|
|
626
|
+
return /^[ \t]*(?:(?:>[ \t]*)+)?(?:(?:[-+*]|\d+[.)])[ \t]+)?$/u.test(value);
|
|
623
627
|
}
|
|
624
628
|
|
|
625
629
|
function stripTelegramHtmlCommentBlocks(markdown: string): string {
|
|
@@ -674,10 +678,6 @@ export function stripTelegramCommentMarkupForDelivery(
|
|
|
674
678
|
return normalizeMarkdownAfterVoiceExtraction(deliveryMarkdown);
|
|
675
679
|
}
|
|
676
680
|
|
|
677
|
-
export function stripTelegramVoiceMarkupForPreview(markdown: string): string {
|
|
678
|
-
return stripTelegramCommentMarkupForPreview(markdown);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
681
|
export interface TelegramVoiceReplyItem {
|
|
682
682
|
text: string;
|
|
683
683
|
lang?: string;
|
|
@@ -710,7 +710,9 @@ export function planTelegramVoiceReply(
|
|
|
710
710
|
let rate: string | undefined;
|
|
711
711
|
const stripped = replaceTopLevelHtmlComments(markdown, (comment) => {
|
|
712
712
|
const command = "telegram_voice";
|
|
713
|
-
const normalizedContent = comment.content
|
|
713
|
+
const normalizedContent = comment.content
|
|
714
|
+
.replace(/^\s+/, "")
|
|
715
|
+
.replace(/^!/, "");
|
|
714
716
|
if (!normalizedContent.startsWith(command)) return comment.raw;
|
|
715
717
|
const payload = parseTelegramActionPayload(comment, command);
|
|
716
718
|
if (!payload) return "";
|
package/lib/outbound-voice.ts
CHANGED
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
getTelegramTargetThreadParams,
|
|
14
14
|
type TelegramTarget,
|
|
15
15
|
} from "./target.ts";
|
|
16
|
-
import { getTelegramVoiceSynthesisProviders } from "./voice.ts";
|
|
17
16
|
import { isTelegramApiCommitUnknownError } from "./telegram-api.ts";
|
|
17
|
+
import { getTelegramVoiceSynthesisProviders } from "./voice.ts";
|
|
18
18
|
|
|
19
19
|
export interface TelegramVoiceReplyTurnView {
|
|
20
20
|
chatId: number;
|
|
@@ -121,32 +121,38 @@ export function createTelegramVoiceReplySender<THandler = unknown>(
|
|
|
121
121
|
await sendVoiceChatAction(deps, turn.chatId);
|
|
122
122
|
if (deps.isDeliveryActive?.() === false) return;
|
|
123
123
|
await withTelegramReplyParameters(
|
|
124
|
-
turn.chatId,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
124
|
+
turn.chatId,
|
|
125
|
+
options?.replyToPrompt === false ? undefined : turn.replyToMessageId,
|
|
126
|
+
turn.target,
|
|
127
|
+
(replyParameters) =>
|
|
128
|
+
deps.sendMultipart(
|
|
129
|
+
"sendVoice",
|
|
130
|
+
{
|
|
131
|
+
chat_id: String(turn.chatId),
|
|
132
|
+
...(replyParameters
|
|
133
|
+
? { reply_parameters: JSON.stringify(replyParameters) }
|
|
134
|
+
: {}),
|
|
135
|
+
...(turn.target
|
|
136
|
+
? Object.fromEntries(
|
|
137
|
+
Object.entries(
|
|
138
|
+
getTelegramTargetThreadParams(turn.target),
|
|
139
|
+
).map(([key, value]) => [key, String(value)]),
|
|
140
|
+
)
|
|
141
|
+
: {}),
|
|
142
|
+
...(options?.replyMarkup !== undefined &&
|
|
143
|
+
options.replyMarkup !== null
|
|
144
|
+
? {
|
|
145
|
+
reply_markup:
|
|
146
|
+
typeof options.replyMarkup === "string"
|
|
147
|
+
? options.replyMarkup
|
|
148
|
+
: JSON.stringify(options.replyMarkup),
|
|
149
|
+
}
|
|
150
|
+
: {}),
|
|
151
|
+
},
|
|
152
|
+
"voice",
|
|
153
|
+
voiceFilePath,
|
|
154
|
+
basename(voiceFilePath),
|
|
155
|
+
),
|
|
150
156
|
);
|
|
151
157
|
};
|
|
152
158
|
|