@adriangalilea/utils 2.0.1 → 2.1.0

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/README.md CHANGED
@@ -449,7 +449,7 @@ Then `pnpm install`. Every `ctx.send` / `ctx.sendDocument` / `ctx.reply` / etc.
449
449
  | `@adriangalilea/utils/bot/user` | `userLabel(u)` — the conditional "[name] [@username] [id]" line every bot re-rolls for admin DMs and logs: `Ada Lovelace (@ada · 42)` / `Ada (42)` / `@ada (42)` / `id 42`, missing pieces drop instead of padding. Reads both gramio spellings (`firstName` / `first_name`); plain text by design. |
450
450
  | `@adriangalilea/utils/bot/coalesce` | Joins client-split inbound messages back into one. When a user pastes >4096 chars, Telegram clients fragment it into separate `message` updates with no marker. Middleware detects the burst and emits one combined event. |
451
451
  | `@adriangalilea/utils/llm` | Multi-provider LLM caller on the Vercel AI SDK — the policy layer the SDK doesn't ship. `createLlm({ providers, health? })` → `.stream(req)` (typed events: `delta` / `reasoning` / `reset` / `tool-call` / `end`) and `.complete(req)`. **Failover:** priority-ordered across OpenAI-compatible, Anthropic-compatible, and OpenRouter endpoints; multiple keys per provider (health tracked per key fingerprint); per-key circuit breaker with exponential cool-down persisted in any KV-shaped `HealthStore`; an attempt that dies after emitting yields `reset` (discard, next candidate regenerates); empty completions count as failures. **Accounting:** tokens summed across billed attempts; `costUsd` is the ACTUAL charge (OpenRouter usage accounting via `providerMetadata`, or a `cost` field on the raw usage frame) — never a price-table estimate. **Knobs:** per-model temperature, maxTokens caps, `disableThinking` mapped to each dialect. **Tools:** AI SDK `tool()` + `toolChoice` pass through (re-exported). Worker-safe; peers: `ai`, `@ai-sdk/openai-compatible`, `@ai-sdk/anthropic`, `@openrouter/ai-sdk-provider`. |
452
- | `@adriangalilea/utils/bot/llm` | The Telegram side of an LLM chatbot; the model side is `@adriangalilea/utils/llm`. **Output:** `streamChatReply(ctx, events, opts?)` consumes an `AsyncIterable<LlmStreamEvent>` and paints it with Telegram's native message-draft streaming (`sendMessageDraft` full-frame repaints, throttled ~1/s, keepalive under the ~30s draft TTL), then persists the finished markdown via `ctx.send`, entity-split across 4096 by `@gramio/split`. Reasoning models get a thinking phase — streams into the ephemeral draft and evaporates (`reasoning: 'preview'`, default), persists as an expandable blockquote (`'message'`), or never renders (`'hidden'`). Upstream `reset` (provider failover) repaints the draft from scratch. Drafts are private-chat-only (+ BotFather forum-topic mode); elsewhere the preview phase is skipped and only the final send happens. Returns `{ content, reasoning, toolCalls, usage, messages }`. **History:** `llmHistory({...})` returns `.plugin` (decorates `ctx.llm` with `.add() / .get() / .clear() / .all() / .clearAll()`, per-(user, thread) OpenAI `ChatMessage` shape, persisted in the shared session record so the menu's 🗑 Forget wipes it automatically) AND `.menuItem` (drop-in "🗑 Delete this thread" for `botMenu` — wipes the LLM history AND calls `deleteForumTopic` so the Telegram thread + all its messages disappear from the chat; falls back to history-only clear when no `threadId` is present). |
452
+ | `@adriangalilea/utils/bot/llm` | The Telegram side of an LLM chatbot; the model side is `@adriangalilea/utils/llm`. **Output:** `streamChatReply(ctx, events, opts?)` consumes an `AsyncIterable<LlmStreamEvent>` and paints it with Telegram's native message-draft streaming (`sendMessageDraft` full-frame repaints, throttled ~1/s, keepalive under the ~30s draft TTL), then persists the finished markdown via `ctx.send`, entity-split across 4096 by `@gramio/split`. Reasoning models get a thinking phase — streams into the ephemeral draft and evaporates (`reasoning: 'preview'`, default), persists as an expandable blockquote (`'message'`), or never renders (`'hidden'`). Upstream `reset` (provider failover) repaints the draft from scratch. Drafts are private-chat-only (+ BotFather forum-topic mode); elsewhere the preview phase is skipped and only the final send happens. Returns `{ content, reasoning, toolCalls, usage, messages }`. `createDraftPreview(ctx, { render?, throttleMs? })` is the push-driven painter underneath — for producers that push deltas or own their per-frame rendering (plain or rich-message frames) and persist path — with `streamForensics` (render-regression + reset warnings) built in and exported standalone. **History:** `llmHistory({...})` returns `.plugin` (decorates `ctx.llm` with `.add() / .get() / .clear() / .all() / .clearAll()`, per-(user, thread) OpenAI `ChatMessage` shape, persisted in the shared session record so the menu's 🗑 Forget wipes it automatically) AND `.menuItem` (drop-in "🗑 Delete this thread" for `botMenu` — wipes the LLM history AND calls `deleteForumTopic` so the Telegram thread + all its messages disappear from the chat; falls back to history-only clear when no `threadId` is present). |
453
453
  | `@adriangalilea/utils/bot/menu` | `botMenu({ command, description, items, privacy?, personalData?, adminContact })` — `/settings` command + InlineKeyboard router. Root view always renders a `🛡️ Privacy & data` submenu button that wraps the privacy policy link plus (if `personalData: { storage }`) 🗑 Forget + 📥 Export buttons. Items take `keepRow` (render on the same row as the next item — e.g. a two-per-row language picker) and `rootExtra` (render at the bottom of the root menu, below Privacy & data). `label` / `header` / `style` / `visible` resolvers may be **async** (read your db at render time — never cache render strings in the session); `parseMode: 'HTML'` renders the header formatted (you own escaping); `personalData.onForget(ctx, userId)` wipes YOUR tables inside the same try as the session delete, so Forget either forgets everything or reports failure. `toggleMenuItem({ id, read, write, label: { off, on }, toast? })` — convenience factory for boolean-toggle items with dynamic label + optional toast, storage-agnostic via `read`/`write` closures. |
454
454
  | `@adriangalilea/utils/bot/payments` | `botPayments({ session, storage, paysupport, paysupportHint?, legal, waiver, vip?, credits?, perks? })` — Telegram Stars monetization in one drop-in plugin. **Three axes, all optional:** `vip` (positional tier ladder — single rung in v1 is just `vip: [{...}]`, ladder is `vip: [{...}, {...}]`; ids are `vip.1`, `vip.2`, …), `credits` (consumable balance + top-up packs `credits.1`, `credits.2`, …), `perks` (orthogonal one-shot unlocks `perks.<key>`). **Surface:** `ctx.payments.atLeast('vip')` / `atLeast('vip.2')` (typed rank check), `ctx.payments.tier()` / `.tier.level()` / `.tier.label()`, `ctx.payments.credits.{balance, consume, tryConsume}` (throws `InsufficientCredits`), `ctx.payments.has(perkId)`, `await ctx.payments.require('vip', { feature? })` (gate that sends a localized upgrade prompt deep-linked to `/settings → 💎 VIP`), `await ctx.payments.invoice(productKey)` (threads Art. 103(m) TRLGDCU consent inline before `sendInvoice`). **Owns:** waiver consent flow (versioned text → forces re-consent on bump, snapshotted on every charge for audit), `/paysupport` slash command (Telegram ToS §6.5; `paysupportHint` overrides the where-to-manage-charges line when your menu isn't `/settings`), idempotent `successful_payment` fulfillment via `pay:idempotency:{chargeId}` sentinel, lazy subscription expiry (no cron needed), tier upgrade auto-cancel of the lower rung's renewal, and admin-DM refund approval (mirror of `accessControl`'s [✅ Aprobar][❌ Denegar] pattern). **Returns:** `{ plugin, menuItem, payouts, onFulfilled }` — `menuItem` is the drop-in `💎 VIP` entry for `botMenu`; `payouts.{record, list, export, exportForUsers}` is the Fragment payout ledger (you receive TON, log the EUR conversion, export time-windowed CSV/JSON for your gestor); `onFulfilled(productKey \| '*', handler)` / `onRefunded(...)` register fire-and-forget hooks (purchase applied / admin-approved refund — a revenue ledger writes on one, reverses on the other). **Stars-only by design** — Telegram ToS §6.2 forbids third-party payment providers for digital goods. Crypto Pay deferred (MiCA risk); Stripe-outside-Telegram is a future v2 channel. Full compliance memo (Spanish-autónomo seller-of-record analysis, Verifactu vs Crea y Crece, MiCA, Art. 103(m) waiver text, GDPR retention) in `src/bot/payments/CLAUDE.md`. |
455
455
  | `@adriangalilea/utils/bot/create` | `createBot<S>({ token?, storage?, initial?, admins?, language?, menu?, access?, payments?, handlers?, worker? })` — the composer (see "One bot file, ideation → production" above). Returns `{ build, session, poll, isMain, fetch }`: `poll()` long-polls, `export default app` is a complete Worker, `app.session(ctx)` / the `handlers` callback's `session(ctx)` is the TYPED accessor for your `S` fields. Owns storage+session wiring; resolves storage per environment (D1 binding → `bot/storage-d1`; `BOT_PERSIST` path → sqlite, `redis://` → redis, lazily-imported optional peers; else announced-ephemeral memory) — or pass `storage: (env) => Storage` when the choice is env-dependent (e.g. a D1 binding not named `DB`). Boot NARRATES the composition (`session: memory …`, `features: language(en,es) · menu(/settings)`) so every implicit decision is visible where you're looking. Runnable demo: `pnpm demo:bot`. |
package/dist/bot/llm.d.ts CHANGED
@@ -17,6 +17,14 @@
17
17
  * mode enabled in BotFather); elsewhere the preview phase is skipped and
18
18
  * only the final send happens.
19
19
  *
20
+ * `createDraftPreview(ctx, opts)` — the push-driven painter UNDER
21
+ * streamChatReply, exposed for producers that push deltas instead of
22
+ * handing over an iterable, or whose per-frame rendering / persist
23
+ * paths are their own (a `render` hook returns a plain or rich-message
24
+ * frame; the caller keeps its own finalize). Owns throttle, the
25
+ * anti-expiry keepalive, serialized sends, reset, quiesce, and
26
+ * {@link streamForensics} (also exported standalone).
27
+ *
20
28
  * `ctx.llm.add / .get / …` — HISTORY. Per-(user, thread) conversation
21
29
  * buffer in OpenAI `ChatMessage` shape, persisted in the shared
22
30
  * `@gramio/session` record under the `llm` field, so the `botMenu`
@@ -41,11 +49,83 @@
41
49
  * ctx.llm.add({ role: 'assistant', content })
42
50
  * })
43
51
  */
52
+ import { type FormattableString } from "@gramio/format";
44
53
  import type { session } from "@gramio/session";
45
54
  import { type Bot, type DeriveDefinitions, type MessageContext, Plugin } from "gramio";
46
55
  import type { LlmStreamEvent, LlmToolCall, LlmUsage, ModelMessage } from "../llm/index.js";
47
56
  import type { Polyglot } from "../say/index.js";
48
57
  import type { MenuItem } from "./menu.js";
58
+ /**
59
+ * Jitter forensics for a streamed preview: a healthy stream only GROWS. A
60
+ * render that shrinks while the accumulated markdown grew means the
61
+ * partial-markdown tail parsed differently between frames (the renderer);
62
+ * accumulated text shrinking is an upstream provider reset. Neither warning
63
+ * firing while a user still sees back-and-forth points at their CLIENT's own
64
+ * draft rendering. Built into {@link createDraftPreview}; exported standalone
65
+ * for edit-based viewers that repaint outside the painter.
66
+ */
67
+ export declare function streamForensics(label: string): {
68
+ /** Call per outgoing frame with the accumulated-markdown and rendered lengths. */
69
+ frame(accLen: number, renderedLen: number): void;
70
+ /** Call from the upstream reset path with the length being dropped. */
71
+ reset(droppedChars: number): void;
72
+ };
73
+ /**
74
+ * One rendered preview frame. `text` goes out via `sendMessageDraft` (a
75
+ * FormattableString carries entities; a raw string may carry `parseMode`);
76
+ * `rich` goes out via `sendRichMessageDraft` (Telegram's rich-message HTML).
77
+ */
78
+ export type DraftFrame = {
79
+ kind: "text";
80
+ text: string | FormattableString;
81
+ parseMode?: "HTML" | "MarkdownV2" | "Markdown";
82
+ } | {
83
+ kind: "rich";
84
+ html: string;
85
+ };
86
+ export interface DraftPreviewOptions {
87
+ /** Ms between repaints. Default 1000. */
88
+ throttleMs?: number;
89
+ /**
90
+ * Render one FULL frame from the accumulated markdown — drafts replace,
91
+ * never append, which is what makes resets and phase switches one cheap
92
+ * frame. Return null to skip (nothing renderable yet). Default:
93
+ * `markdownToFormattable`.
94
+ */
95
+ render?: (markdown: string) => DraftFrame | null;
96
+ /** Forensics label. Default `draft <id>`. */
97
+ label?: string;
98
+ }
99
+ /**
100
+ * A live message-draft preview: the push-driven primitive under
101
+ * {@link streamChatReply}, exposed for callers whose producer pushes deltas
102
+ * (rather than handing over an event iterable) or whose render/persist paths
103
+ * are their own. Owns the whole draft lifecycle: throttled full-frame
104
+ * repaints, the anti-expiry keepalive, serialized sends, reset, and quiesce.
105
+ * Previews exist in PRIVATE chats only — elsewhere every method no-ops and
106
+ * the caller's persist path is all that happens.
107
+ */
108
+ export interface DraftPreview {
109
+ /** Accumulated markdown of the current attempt. */
110
+ readonly text: string;
111
+ /** Append a delta and schedule a repaint. */
112
+ append(text: string): void;
113
+ /** Replace the buffer (phase switches); schedules a repaint. */
114
+ set(markdown: string): void;
115
+ /** Upstream failover: drop the buffer with a forensics note; the next tokens repaint from scratch. */
116
+ reset(): void;
117
+ /** Force a repaint of the current frame (render inputs changed, e.g. a cover arrived). */
118
+ repaint(): void;
119
+ /**
120
+ * Paint one last complete frame and stop. Call right before persisting:
121
+ * the preview shows the finished text (not a throttle-stale partial) and
122
+ * its ~30s TTL resets, so the handoff to the real message can't blank.
123
+ */
124
+ finish(markdown?: string): Promise<void>;
125
+ /** Stop painting without a final frame; the ephemeral draft expires on its own. */
126
+ abort(): Promise<void>;
127
+ }
128
+ export declare function createDraftPreview(ctx: MessageContext<Bot>, opts?: DraftPreviewOptions): DraftPreview;
49
129
  export interface StreamChatReplyOptions {
50
130
  /**
51
131
  * What happens to a reasoning model's thinking text.
@@ -77,8 +157,9 @@ export interface ChatReplyResult {
77
157
  }
78
158
  /**
79
159
  * Render an LLM event stream into the chat: live draft previews while
80
- * generating, entity-split persisted message(s) when done. See the module doc
81
- * for the full contract. Returns the transcript pieces plus the sent messages.
160
+ * generating (via {@link createDraftPreview}), entity-split persisted
161
+ * message(s) when done. See the module doc for the full contract. Returns the
162
+ * transcript pieces plus the sent messages.
82
163
  */
83
164
  export declare function streamChatReply(ctx: MessageContext<Bot>, events: AsyncIterable<LlmStreamEvent>, opts?: StreamChatReplyOptions): Promise<ChatReplyResult>;
84
165
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/bot/llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EACN,KAAK,GAAG,EACR,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,MAAM,EACN,MAAM,QAAQ,CAAC;AAEhB,OAAO,KAAK,EACX,cAAc,EACd,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAiB1C,MAAM,WAAW,sBAAsB;IACtC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC7C,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,CA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G;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACtE,2DAA2D;IAC3D,GAAG,EAAE,MAAM,aAAa,CAAC,WAAW,CAAC,CAAC;IACtC,uCAAuC;IACvC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,GAAG,EAAE,MAAM,QAAQ,CAAC;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;KAAE,CAAC,CAAC;IACzE,sCAAsC;IACtC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IAAE,GAAG,EAAE,aAAa,CAAA;CAAE,CAAC;AAoChD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,iBAAiB,KAAG,iBA4GpD,CAAC;AAEF,QAAA,MAAM,kBAAkB,GAAI,MAAM;IACjC,aAAa,EAAE,mBAAmB,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACtB;YAK+B,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA4ChD,CAAC"}
package/dist/bot/llm.js CHANGED
@@ -17,6 +17,14 @@
17
17
  * mode enabled in BotFather); elsewhere the preview phase is skipped and
18
18
  * only the final send happens.
19
19
  *
20
+ * `createDraftPreview(ctx, opts)` — the push-driven painter UNDER
21
+ * streamChatReply, exposed for producers that push deltas instead of
22
+ * handing over an iterable, or whose per-frame rendering / persist
23
+ * paths are their own (a `render` hook returns a plain or rich-message
24
+ * frame; the caller keeps its own finalize). Owns throttle, the
25
+ * anti-expiry keepalive, serialized sends, reset, quiesce, and
26
+ * {@link streamForensics} (also exported standalone).
27
+ *
20
28
  * `ctx.llm.add / .get / …` — HISTORY. Per-(user, thread) conversation
21
29
  * buffer in OpenAI `ChatMessage` shape, persisted in the shared
22
30
  * `@gramio/session` record under the `llm` field, so the `botMenu`
@@ -45,7 +53,7 @@ import { expandableBlockquote } from "@gramio/format";
45
53
  import { markdownToFormattable } from "@gramio/format/markdown";
46
54
  import { splitMessage } from "@gramio/split";
47
55
  import { Plugin, } from "gramio";
48
- // ─── OUTPUT: draft-streamed reply ──────────────────────────────────
56
+ // ─── OUTPUT: the draft painter + the event-stream renderer ─────────
49
57
  // Telegram animates draft repaints; one frame per second is smooth and stays
50
58
  // clear of rate limits.
51
59
  const THROTTLE_MS = 1000;
@@ -58,80 +66,202 @@ const KEEPALIVE_MS = 20_000;
58
66
  // collisions across isolates are harmless (draft ids are chat-scoped).
59
67
  let draftSeq = 0;
60
68
  /**
61
- * Render an LLM event stream into the chat: live draft previews while
62
- * generating, entity-split persisted message(s) when done. See the module doc
63
- * for the full contract. Returns the transcript pieces plus the sent messages.
69
+ * Jitter forensics for a streamed preview: a healthy stream only GROWS. A
70
+ * render that shrinks while the accumulated markdown grew means the
71
+ * partial-markdown tail parsed differently between frames (the renderer);
72
+ * accumulated text shrinking is an upstream provider reset. Neither warning
73
+ * firing while a user still sees back-and-forth points at their CLIENT's own
74
+ * draft rendering. Built into {@link createDraftPreview}; exported standalone
75
+ * for edit-based viewers that repaint outside the painter.
64
76
  */
65
- export async function streamChatReply(ctx, events, opts = {}) {
66
- const reasoningMode = opts.reasoning ?? "preview";
67
- const throttle = opts.throttleMs ?? THROTTLE_MS;
68
- // Drafts exist in private chats only; elsewhere skip the preview phase and
69
- // deliver the finished reply in one shot.
70
- const drafts = ctx.chat.type === "private";
77
+ export function streamForensics(label) {
78
+ let lastAccLen = 0;
79
+ let lastRenderedLen = 0;
80
+ return {
81
+ /** Call per outgoing frame with the accumulated-markdown and rendered lengths. */
82
+ frame(accLen, renderedLen) {
83
+ if (renderedLen < lastRenderedLen && accLen >= lastAccLen)
84
+ console.warn(`[bot/llm] ${label} render regressed · rendered ${lastRenderedLen}→${renderedLen} · acc ${accLen}`);
85
+ lastAccLen = accLen;
86
+ lastRenderedLen = renderedLen;
87
+ },
88
+ /** Call from the upstream reset path with the length being dropped. */
89
+ reset(droppedChars) {
90
+ console.warn(`[bot/llm] ${label} reset (provider failover) · dropped ${droppedChars} chars`);
91
+ },
92
+ };
93
+ }
94
+ export function createDraftPreview(ctx, opts = {}) {
95
+ const active = ctx.chat.type === "private";
96
+ const chatId = ctx.chat.id;
97
+ const threadId = ctx.threadId;
71
98
  const draftId = ++draftSeq;
72
- let content = "";
73
- let reasoning = "";
74
- const toolCalls = [];
75
- let usage = null;
76
- let lastFrameAt = 0;
99
+ const throttle = opts.throttleMs ?? THROTTLE_MS;
100
+ const render = opts.render ??
101
+ ((markdown) => ({ kind: "text", text: markdownToFormattable(markdown) }));
102
+ const forensics = streamForensics(opts.label ?? `draft ${draftId}`);
103
+ let acc = "";
104
+ let dirty = false;
105
+ let stopped = !active;
106
+ let lastFlushAt = 0;
107
+ let timer;
108
+ let flushing;
77
109
  let keepalive;
78
- let painting = Promise.resolve();
79
- // Full-frame repaint: drafts replace, never append — which is what makes
80
- // resets and phase switches (thinking → answer) one cheap frame.
81
- const paint = (formattable) => {
82
- lastFrameAt = Date.now();
83
- // Serialize frames; a rejected send must not kill the stream loop, and
84
- // the next frame repaints fully anyway.
85
- painting = painting.then(() => ctx.bot.api
110
+ // Send the current accumulated markdown as one full frame. Best-effort: a
111
+ // rejected preview (rate limit, empty render) is swallowed — the caller's
112
+ // persist path is what matters.
113
+ const sendFrame = async () => {
114
+ const frame = render(acc);
115
+ if (frame === null)
116
+ return;
117
+ if (frame.kind === "rich") {
118
+ forensics.frame(acc.length, frame.html.length);
119
+ await ctx.bot.api
120
+ .sendRichMessageDraft({
121
+ chat_id: chatId,
122
+ draft_id: draftId,
123
+ rich_message: { html: frame.html },
124
+ ...(threadId !== undefined ? { message_thread_id: threadId } : {}),
125
+ })
126
+ .catch(() => { });
127
+ return;
128
+ }
129
+ const rendered = typeof frame.text === "string" ? frame.text : frame.text.text;
130
+ forensics.frame(acc.length, rendered.length);
131
+ await ctx.bot.api
86
132
  .sendMessageDraft({
87
- chat_id: ctx.chat.id,
133
+ chat_id: chatId,
88
134
  draft_id: draftId,
89
- ...(ctx.threadId !== undefined
90
- ? { message_thread_id: ctx.threadId }
91
- : {}),
92
- text: formattable,
135
+ text: frame.text,
136
+ ...(frame.parseMode ? { parse_mode: frame.parseMode } : {}),
137
+ ...(threadId !== undefined ? { message_thread_id: threadId } : {}),
93
138
  })
94
- .catch(() => { }));
139
+ .catch(() => { });
95
140
  };
96
- const frame = () => {
97
- // The answer owns the preview as soon as it exists; before that, the
98
- // thinking phase does (unless hidden).
99
- if (content)
100
- paint(markdownToFormattable(content));
101
- else if (reasoning && reasoningMode !== "hidden")
102
- paint(markdownToFormattable(reasoning));
141
+ const flush = async () => {
142
+ if (!dirty || stopped)
143
+ return;
144
+ if (flushing)
145
+ await flushing.catch(() => { });
146
+ if (!dirty || stopped)
147
+ return;
148
+ dirty = false;
149
+ lastFlushAt = Date.now();
150
+ flushing = sendFrame();
151
+ await flushing.catch(() => { });
152
+ flushing = undefined;
153
+ if (dirty && !stopped)
154
+ schedule();
103
155
  };
104
- if (drafts) {
156
+ const schedule = () => {
157
+ dirty = true;
158
+ if (stopped || timer)
159
+ return;
160
+ const wait = Math.max(0, throttle - (Date.now() - lastFlushAt));
161
+ timer = setTimeout(() => {
162
+ timer = undefined;
163
+ void flush();
164
+ }, wait);
165
+ };
166
+ // Start the anti-expiry heartbeat once streaming has actually begun. Each
167
+ // tick reuses the normal flush path to re-paint the current frame, but only
168
+ // when the stream has gone quiet — an in-flight or pending flush already
169
+ // refreshes the draft.
170
+ const ensureKeepalive = () => {
171
+ if (keepalive || stopped)
172
+ return;
105
173
  keepalive = setInterval(() => {
106
- if (Date.now() - lastFrameAt >= KEEPALIVE_MS)
107
- frame();
174
+ if (stopped || dirty || timer || flushing || !acc.trim())
175
+ return;
176
+ schedule();
108
177
  }, KEEPALIVE_MS);
109
- }
178
+ };
179
+ // Stop scheduling and let any in-flight frame settle. Shared by finish and abort.
180
+ const quiesce = async () => {
181
+ stopped = true;
182
+ if (timer) {
183
+ clearTimeout(timer);
184
+ timer = undefined;
185
+ }
186
+ if (keepalive) {
187
+ clearInterval(keepalive);
188
+ keepalive = undefined;
189
+ }
190
+ if (flushing)
191
+ await flushing.catch(() => { });
192
+ };
193
+ return {
194
+ get text() {
195
+ return acc;
196
+ },
197
+ append(text) {
198
+ if (stopped)
199
+ return;
200
+ acc += text;
201
+ ensureKeepalive();
202
+ schedule();
203
+ },
204
+ set(markdown) {
205
+ acc = markdown;
206
+ if (!stopped)
207
+ schedule();
208
+ },
209
+ reset() {
210
+ forensics.reset(acc.length);
211
+ acc = "";
212
+ },
213
+ repaint() {
214
+ if (!stopped && acc.trim())
215
+ schedule();
216
+ },
217
+ async finish(markdown) {
218
+ if (markdown !== undefined)
219
+ acc = markdown;
220
+ const wasActive = !stopped;
221
+ await quiesce();
222
+ if (wasActive)
223
+ await sendFrame().catch(() => { });
224
+ },
225
+ abort: quiesce,
226
+ };
227
+ }
228
+ /**
229
+ * Render an LLM event stream into the chat: live draft previews while
230
+ * generating (via {@link createDraftPreview}), entity-split persisted
231
+ * message(s) when done. See the module doc for the full contract. Returns the
232
+ * transcript pieces plus the sent messages.
233
+ */
234
+ export async function streamChatReply(ctx, events, opts = {}) {
235
+ const reasoningMode = opts.reasoning ?? "preview";
236
+ const preview = createDraftPreview(ctx, { throttleMs: opts.throttleMs });
237
+ let content = "";
238
+ let reasoning = "";
239
+ const toolCalls = [];
240
+ let usage = null;
110
241
  try {
111
242
  for await (const event of events) {
112
243
  if (event.kind === "delta") {
113
- const first = content === "";
114
- content += event.text;
115
- if (drafts && (first || Date.now() - lastFrameAt >= throttle)) {
116
- // Answer taking over from thinking: persist the blockquote first
117
- // so it lands ABOVE the final answer message.
118
- if (first && reasoning && reasoningMode === "message") {
244
+ // Answer taking over from thinking: persist the blockquote first so
245
+ // it lands ABOVE the final answer message, then the answer owns the
246
+ // preview (a phase switch is one cheap full-frame repaint).
247
+ if (content === "") {
248
+ if (reasoning && reasoningMode === "message")
119
249
  await persistReasoning(ctx, reasoning);
120
- }
121
- frame();
250
+ preview.set("");
122
251
  }
252
+ content += event.text;
253
+ preview.append(event.text);
123
254
  }
124
255
  else if (event.kind === "reasoning") {
125
256
  reasoning += event.text;
126
- if (drafts && !content && Date.now() - lastFrameAt >= throttle)
127
- frame();
257
+ if (!content && reasoningMode !== "hidden")
258
+ preview.append(event.text);
128
259
  }
129
260
  else if (event.kind === "reset") {
130
261
  content = "";
131
262
  reasoning = "";
132
263
  toolCalls.length = 0;
133
- if (drafts)
134
- paint(""); // empty text = Telegram's "Thinking…" placeholder
264
+ preview.reset();
135
265
  }
136
266
  else if (event.kind === "tool-call") {
137
267
  toolCalls.push({ toolName: event.toolName, input: event.input });
@@ -141,31 +271,34 @@ export async function streamChatReply(ctx, events, opts = {}) {
141
271
  }
142
272
  }
143
273
  }
144
- finally {
145
- if (keepalive)
146
- clearInterval(keepalive);
147
- await painting.catch(() => { });
274
+ catch (err) {
275
+ await preview.abort();
276
+ throw err;
148
277
  }
149
278
  content = content.trim();
150
279
  reasoning = reasoning.trim();
151
280
  // A reasoning-only or tool-call-only turn persists nothing; the ephemeral
152
281
  // draft expires on its own.
153
- if (reasoning && reasoningMode === "message" && content === "")
154
- await persistReasoning(ctx, reasoning);
155
- let messages = [];
156
- if (content) {
157
- // Collect the entity-correct parts first, then send with params on the
158
- // last one — splitMessage's sequential action callback stays the sender
159
- // so ordering is preserved.
160
- const parts = [];
161
- await splitMessage(markdownToFormattable(content), (part) => {
162
- parts.push(part);
163
- });
164
- messages = [];
165
- for (let i = 0; i < parts.length; i++) {
166
- const isLast = i === parts.length - 1;
167
- messages.push(await ctx.send(parts[i], isLast ? opts.messageParams : undefined));
168
- }
282
+ if (content === "") {
283
+ await preview.abort();
284
+ if (reasoning && reasoningMode === "message")
285
+ await persistReasoning(ctx, reasoning);
286
+ return { content, reasoning, toolCalls, usage, messages: [] };
287
+ }
288
+ // One last complete frame (TTL reset right before the persist), then the
289
+ // real, notifying send(s) consume the ephemeral draft in place.
290
+ await preview.finish(content);
291
+ // Collect the entity-correct parts first, then send with params on the
292
+ // last one — splitMessage's sequential action callback stays the sender
293
+ // so ordering is preserved.
294
+ const parts = [];
295
+ await splitMessage(markdownToFormattable(content), (part) => {
296
+ parts.push(part);
297
+ });
298
+ const messages = [];
299
+ for (let i = 0; i < parts.length; i++) {
300
+ const isLast = i === parts.length - 1;
301
+ messages.push(await ctx.send(parts[i], isLast ? opts.messageParams : undefined));
169
302
  }
170
303
  return { content, reasoning, toolCalls, usage, messages };
171
304
  }
@@ -1 +1 @@
1
- {"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/bot/llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAE,oBAAoB,EAA0B,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAIN,MAAM,GACN,MAAM,QAAQ,CAAC;AAWhB,sEAAsE;AAEtE,6EAA6E;AAC7E,wBAAwB;AACxB,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,+EAA+E;AAC/E,4EAA4E;AAC5E,+EAA+E;AAC/E,MAAM,YAAY,GAAG,MAAM,CAAC;AAE5B,2EAA2E;AAC3E,sEAAsE;AACtE,uEAAuE;AACvE,IAAI,QAAQ,GAAG,CAAC,CAAC;AAiCjB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,GAAwB,EACxB,MAAqC,EACrC,OAA+B,EAAE;IAEjC,MAAM,aAAa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CAAC;gBACrB,CAAC;gBACD,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAA+B;gBAClE,KAAK,EAAE,GAAG,EAAE;oBACX,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;oBAC5B,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;oBACnB,WAAW,CAAC,MAAM,CAAC,CAAC;gBACrB,CAAC;gBACD,GAAG,EAAE,GAAG,EAAE,CACT,UAAU,EAER;gBACH,QAAQ,EAAE,GAAG,EAAE;oBACd,WAAW,CAAC,EAAE,CAAC,CAAC;gBACjB,CAAC;aACD;SACD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adriangalilea/utils",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "TypeScript utilities - logger, currency, formatter, GramIO bot plugins, and more",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -166,7 +166,8 @@
166
166
  "test:flags": "tsx tests/flags-test.ts",
167
167
  "test:groups": "tsx tests/groups-test.ts",
168
168
  "test:user": "tsx tests/user-test.ts",
169
- "test:language-picker": "tsx tests/language-picker-test.ts"
169
+ "test:language-picker": "tsx tests/language-picker-test.ts",
170
+ "test:llm": "tsx tests/llm-live-test.ts"
170
171
  },
171
172
  "keywords": [
172
173
  "typescript",