@goodandready/dsh-messenger-gateway 0.4.38 → 0.4.40

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
@@ -151,6 +151,13 @@ In addition to Telegram, outbound messages can be dispatched to Discord and Slac
151
151
  - Mini App artifacts are chat-scoped: a Telegram user sees only artifacts produced in their own chat; allowlisted admins see all
152
152
  - Mini App sign-in is hardened: `auth_date` required, 1h acceptance window, one-time `query_id` (replays rejected); `initData` in URL query is not accepted — the Mini App must send it via the `Authorization: tma` header
153
153
  - HITL approvals are fail-closed by default: in `mutations` sensitivity every tool that is not recognizably read-only (including network, send and MCP tools) asks for confirmation; a chat without a target refuses unconfirmed actions
154
+ - Delivered updates are deduplicated across polling and webhook transports and the poll offset survives restarts — commands never execute twice
155
+ - Artifact SVG entering the dashboard store is sanitized (script blocks, event handlers and `javascript:` URLs stripped)
156
+ - Pending interactive asks are bounded (200 concurrent) and the ask timeout is clamped to 10 minutes
157
+ - `telegram.apiRoot` with plain `http` is only accepted for loopback hosts (a local Bot API server); the webhook URL is logged without its secret path
158
+ - `webhooks.enabled: false` removes the messenger write routes entirely; GET `/update` and `/messenger` require trusted callers
159
+ - `webAppEnabled: false` takes the whole Mini App surface down (dashboard and every `/api/*` answer 404) and clears the menu button
160
+ - Inline keyboard `replyMarkup` sent via `/messenger/send` is schema-validated (button text/actions, sizes) before delivery
154
161
  - All state files (pairing, outbox, voice prefs) are written with `0600` permissions inside `0700` directories
155
162
  - `sessionList`: `true` (default) — enables `/sessions` and `/resume` commands in chat
156
163
  - `sessionTitleFromChat`: `false` (default) — name each new session after its originating chat (`TG · @user`, `TG · Group › topic N`) instead of generic generated titles
@@ -28,7 +28,7 @@ export default function createAdapters(deps) {
28
28
  apiRoot: tg.apiRoot,
29
29
  quickActions: tg.quickActions !== false,
30
30
  artifactPreviews: tg.artifactPreviews !== false,
31
- webAppUrl: tg.webAppUrl || (tg.webhookUrl && String(tg.webhookUrl).startsWith('http') ? `${new URL(tg.webhookUrl).origin}/dsh-messenger-gateway/webapp` : ''),
31
+ webAppUrl: tg.webAppEnabled === false ? '' : (tg.webAppUrl || (tg.webhookUrl && String(tg.webhookUrl).startsWith('http') ? `${new URL(tg.webhookUrl).origin}/dsh-messenger-gateway/webapp` : '')),
32
32
  mediaGroupDebounceMs: tg.mediaGroupDebounceMs,
33
33
  media: config.media,
34
34
  onMessage,
@@ -1,4 +1,8 @@
1
1
  import { readFile } from 'node:fs/promises'
2
+ import { existsSync, readFileSync } from 'node:fs'
3
+ import { join } from 'node:path'
4
+ import { homedir } from 'node:os'
5
+ import { writeJsonAtomicSync } from '../storage-atomic.js'
2
6
  import {
3
7
  cacheName,
4
8
  extOf, saveToCache, safeName, TELEGRAM_MAX_DOC_BYTES,
@@ -66,11 +70,14 @@ export class TelegramAdapter {
66
70
  this.pollErrorCount = 0
67
71
  this.webhookUrl = String(opts.webhookUrl || '').trim()
68
72
  this.webhookSecret = String(opts.webhookSecret || '').trim()
69
- this.offset = 0
70
73
  this.stopped = false
71
74
  this.mediaGroups = new Map()
72
75
  this.mediaGroupDebounceMs = Number(opts.mediaGroupDebounceMs) || 650
73
76
  this.pollTimer = undefined
77
+ // Offset persistence (#208): the last update_id survives restarts so a
78
+ // fresh poll does not replay the tail of the previous session.
79
+ this.offsetPath = opts.offsetPath || join(process.env.DSH_HOME || join(homedir(), '.dsh'), 'storages', 'telegram-offset.json')
80
+ this.offset = this.loadOffset()
74
81
  this.botId = 0
75
82
  this.botUsername = ''
76
83
  this.apiRoot = normalizeApiRoot(opts.apiRoot)
@@ -93,6 +100,26 @@ export class TelegramAdapter {
93
100
  this.allowedUserIds = (ids || []).map(Number).filter((n) => Number.isFinite(n))
94
101
  }
95
102
 
103
+ loadOffset() {
104
+ try {
105
+ if (existsSync(this.offsetPath)) {
106
+ const raw = JSON.parse(readFileSync(this.offsetPath, 'utf8'))
107
+ return Number(raw.offset) || 0
108
+ }
109
+ } catch (e) {
110
+ this.logger?.warn?.(`telegram offset load: ${e.message}`)
111
+ }
112
+ return 0
113
+ }
114
+
115
+ persistOffset() {
116
+ try {
117
+ writeJsonAtomicSync(this.offsetPath, { offset: this.offset, updatedAt: Date.now() })
118
+ } catch (e) {
119
+ this.logger?.debug?.(`telegram offset persist: ${e.message}`)
120
+ }
121
+ }
122
+
96
123
  async call(method, params = {}, externalSignal) {
97
124
  const timeoutMs = (this.timeoutSeconds * 1000) + 15000
98
125
  // A long poll holds its request open for `timeoutSeconds`, so stopping the
@@ -244,7 +271,10 @@ export class TelegramAdapter {
244
271
  secret_token: this.webhookSecret,
245
272
  }
246
273
  await this.call('setWebhook', params)
247
- this.logger?.info?.(`dsh-messenger-gateway: telegram webhook set → ${this.webhookUrl}`)
274
+ // The webhook URL carries the secret token path: log only the origin (#205)
275
+ let webhookLogTarget = this.webhookUrl
276
+ try { webhookLogTarget = `${new URL(this.webhookUrl).origin}/***` } catch { /* keep raw */ }
277
+ this.logger?.info?.(`dsh-messenger-gateway: telegram webhook set → ${webhookLogTarget}`)
248
278
  return
249
279
  }
250
280
  try {
@@ -292,15 +322,15 @@ export class TelegramAdapter {
292
322
  }, signal)
293
323
  this.pollingConflict = false
294
324
  this.pollErrorCount = 0
325
+ let maxSeen = this.offset
295
326
  for (const update of updates || []) {
296
- this.offset = Math.max(this.offset, update.update_id + 1)
297
- if (processedUpdateIds.has(update.update_id)) {
298
- this.logger?.debug?.(`telegram: skipping already handled update ${update.update_id}`)
299
- continue
300
- }
301
- rememberUpdate(update.update_id)
327
+ maxSeen = Math.max(maxSeen, update.update_id + 1)
302
328
  await this.dispatchUpdate(update)
303
329
  }
330
+ if (maxSeen !== this.offset) {
331
+ this.offset = maxSeen
332
+ this.persistOffset()
333
+ }
304
334
  } catch (e) {
305
335
  if (!this.stopped) {
306
336
  this.pollErrorCount = (this.pollErrorCount || 0) + 1
@@ -318,6 +348,17 @@ export class TelegramAdapter {
318
348
  }
319
349
 
320
350
  async dispatchUpdate(update) {
351
+ // Shared dedup for BOTH transports (#208): Telegram redelivers updates on
352
+ // timeout or 5xx, and the webhook path has no offset bookkeeping. Updates
353
+ // without an id (synthetic/internal dispatches) bypass the dedup.
354
+ const uid = update.update_id
355
+ if (uid !== undefined) {
356
+ if (processedUpdateIds.has(uid)) {
357
+ this.logger?.debug?.(`telegram: skipping already handled update ${uid}`)
358
+ return
359
+ }
360
+ rememberUpdate(uid)
361
+ }
321
362
  if (update.callback_query) {
322
363
  const fromId = update.callback_query.from?.id
323
364
  if (fromId && !this.allowed(fromId)) {
package/lib/ask.js CHANGED
@@ -154,9 +154,24 @@ export function rejectPendingAsk(pending, err) {
154
154
 
155
155
  export const REMOVE_KEYBOARD = { inline_keyboard: [] }
156
156
 
157
+ // Bounds for pending asks (#209): unbounded concurrent asks pin memory and
158
+ // callback slots; a runaway caller must fail fast instead of exhausting the
159
+ // process. The timeout is clamped well below the previous 1h maximum.
160
+ const MAX_PENDING_ASKS = 200
161
+ const MAX_ASK_TIMEOUT_MS = 600_000
162
+ const DEFAULT_ASK_TIMEOUT_MS = 300_000
163
+
164
+ /** Clamp the caller-supplied ask timeout to a sane maximum (#209). */
165
+ export function clampAskTimeout(ms) {
166
+ return Math.min(Number(ms) || DEFAULT_ASK_TIMEOUT_MS, MAX_ASK_TIMEOUT_MS)
167
+ }
168
+
157
169
  export async function executeMessengerAsk(gw, target, payload, timeoutMs = 300_000) {
158
170
  const adapter = gw.getAdapter(target.platform)
159
171
  if (!adapter) throw new Error(`adapter ${target.platform} unavailable`)
172
+ if (gw.pendingAsks.size >= MAX_PENDING_ASKS) {
173
+ throw new Error(`too many pending asks (${gw.pendingAsks.size} >= ${MAX_PENDING_ASKS}); refusing new ask`)
174
+ }
160
175
  const token = makeAskToken()
161
176
  const isMulti = payload.mode === 'multi' || (Array.isArray(payload.options) && payload.options.length > 0)
162
177
  let replyMarkup
@@ -193,7 +208,7 @@ export async function executeMessengerAsk(gw, target, payload, timeoutMs = 300_0
193
208
  gw.pendingAsks.delete(token)
194
209
  releaseCallbacks(gw.callbackIndex, callbackKeys)
195
210
  reject(new Error('messenger.ask timed out'))
196
- }, timeoutMs)
211
+ }, clampAskTimeout(timeoutMs))
197
212
  timer.unref?.()
198
213
  gw.pendingAsks.set(token, {
199
214
  resolve, reject, timer, target, callbackKeys, isMulti,
package/lib/documents.js CHANGED
@@ -70,17 +70,25 @@ export function extractPdfText(buffer) {
70
70
  }
71
71
  }
72
72
 
73
- // Also check plain text streams if no BT/ET blocks were matched
73
+ // Also check plain text streams if no BT/ET blocks were matched. Linear
74
+ // indexOf scan (#209): no lazy quantifiers running over the whole document,
75
+ // so a crafted PDF cannot drive catastrophic backtracking.
74
76
  if (!textBlocks.length) {
75
- const streamRegex = /stream[\r\n]+([\s\S]*?)[\r\n]+endstream/g
76
- let sMatch
77
- while ((sMatch = streamRegex.exec(content)) !== null) {
78
- const stream = sMatch[1]
77
+ let cursor = 0
78
+ while (cursor < content.length) {
79
+ const start = content.indexOf('stream', cursor)
80
+ if (start === -1) break
81
+ let bodyStart = start + 'stream'.length
82
+ while (bodyStart < content.length && (content[bodyStart] === '\r' || content[bodyStart] === '\n')) bodyStart++
83
+ const end = content.indexOf('endstream', bodyStart)
84
+ if (end === -1) break
85
+ const stream = content.slice(bodyStart, end)
79
86
  const strRegex = /\(([\w\s.,;:!?-]{4,})\)/g
80
87
  let strMatch
81
88
  while ((strMatch = strRegex.exec(stream)) !== null) {
82
89
  textBlocks.push(strMatch[1])
83
90
  }
91
+ cursor = end + 'endstream'.length
84
92
  }
85
93
  }
86
94
 
@@ -1,6 +1,6 @@
1
1
  import { escapeHtml } from './telegram-format.js'
2
2
  import { realpathSync } from 'node:fs'
3
- import { readdir, stat, readFile } from 'node:fs/promises'
3
+ import { readdir, stat, open } from 'node:fs/promises'
4
4
  import { resolve, normalize, relative, join, extname, isAbsolute, sep, dirname } from 'node:path'
5
5
 
6
6
  export function formatFileSize(bytes) {
@@ -210,7 +210,16 @@ export async function getFileForDownload(baseCwd, relativePath, maxBytes = 50 *
210
210
  }
211
211
  }
212
212
 
213
- const bytes = await readFile(target)
213
+ // Read through a file descriptor opened AFTER the boundary check: swapping
214
+ // the path for a symlink between check and read cannot redirect the read
215
+ // anymore — the fd pins the already-verified inode (#209).
216
+ const handle = await open(target, 'r')
217
+ let bytes
218
+ try {
219
+ bytes = await handle.readFile()
220
+ } finally {
221
+ await handle.close()
222
+ }
214
223
  const ext = extname(safeRel).toLowerCase()
215
224
 
216
225
  const mimeMap = {
File without changes
package/lib/index.js CHANGED
@@ -132,11 +132,16 @@ async function readJsonSafe(req, res, maxBytes = 1_048_576) {
132
132
  }
133
133
  }
134
134
 
135
- function registerMessengerRoute(ctx, getGw, path, action, source) {
135
+ export function registerMessengerRoute(ctx, getGw, path, action, source) {
136
136
  ctx.effect(() => (ctx.get?.('webServer') || ctx.webServer).register({
137
137
  kind: 'exact', path,
138
138
  handler: async (req, res) => {
139
139
  if (req.method !== 'POST') return writeJson(res, 405, { ok: false, error: 'POST only' })
140
+ // The global switch takes precedence (#206): with webhooks disabled the
141
+ // messenger write routes disappear entirely (404, like unknown paths).
142
+ if (source?.()?.webhooks?.enabled === false) {
143
+ return writeJson(res, 404, { ok: false, error: 'webhooks disabled' })
144
+ }
140
145
  if (!isAuthorizedMessengerRequest(req, source?.()?.webhooks, ctx, { trustProxy: source?.()?.security?.trustProxy === true })) {
141
146
  return writeJson(res, 403, { ok: false, error: 'forbidden' })
142
147
  }
@@ -615,6 +620,7 @@ export function apply(ctx, config) {
615
620
  kind: 'exact', path: '/dsh-messenger-gateway/messenger',
616
621
  handler: async (req, res) => {
617
622
  if (req.method !== 'GET') return writeJson(res, 405, { ok: false, error: 'GET only' })
623
+ if (!isTrustedSettingsRequest(req, source().webhooks?.secret, ctx, { trustProxy: source().security?.trustProxy === true })) return writeJson(res, 403, { ok: false, error: 'forbidden' })
618
624
  writeJson(res, 200, { ok: true, schema: messengerApiSchema })
619
625
  },
620
626
  }), 'dsh-messenger-gateway: messenger schema')
@@ -781,14 +787,22 @@ export function apply(ctx, config) {
781
787
  ctx.effect(() => {
782
788
  const ws = getWebServer()
783
789
  if (!ws?.register) return
790
+ const webappHandler = createWebAppHandler({
791
+ getGateway: getGw,
792
+ getConfig: source,
793
+ ctx,
794
+ })
784
795
  return ws.register({
785
796
  kind: 'prefix',
786
797
  path: '/dsh-messenger-gateway/webapp',
787
- handler: createWebAppHandler({
788
- getGateway: getGw,
789
- getConfig: source,
790
- ctx,
791
- }),
798
+ handler: async (req, res) => {
799
+ // webAppEnabled=false must take the whole Mini App surface down —
800
+ // HTML dashboard and every /api/* endpoint answer 404 (#207).
801
+ if (source().telegram?.webAppEnabled === false) {
802
+ return writeJson(res, 404, { ok: false, error: 'webapp disabled' })
803
+ }
804
+ return webappHandler(req, res)
805
+ },
792
806
  })
793
807
  }, 'dsh-messenger-gateway: webapp dashboard')
794
808
 
@@ -796,6 +810,14 @@ export function apply(ctx, config) {
796
810
  manifestPath,
797
811
  packageName: '@goodandready/dsh-messenger-gateway',
798
812
  endpoint: '/dsh-messenger-gateway/update',
813
+ // Read endpoints answer version/profile data: gate them like other
814
+ // admin reads (#206).
815
+ isTrustedRequest: (req) => isTrustedSettingsRequest(
816
+ req,
817
+ source().webhooks?.secret,
818
+ ctx,
819
+ { trustProxy: source().security?.trustProxy === true },
820
+ ),
799
821
  }), 'dsh-messenger-gateway: plugin updater')
800
822
 
801
823
  // Cordis never delivers a 'dispose' event to `ctx.on`, so this cleanup never
@@ -147,6 +147,83 @@ export function normalizeFiles(files) {
147
147
  })
148
148
  }
149
149
 
150
+ // Telegram inline keyboard constraints: rows of buttons, each button with a
151
+ // text label and exactly one action; callback_data <= 64 bytes. Rejects
152
+ // phishing-shaped markup (script urls, oversized payloads, unknown fields)
153
+ // before it reaches the Telegram API (#206).
154
+ export function sanitizeReplyMarkup(markup) {
155
+ if (markup === undefined || markup === null) return undefined
156
+ if (typeof markup !== 'object' || Array.isArray(markup)) {
157
+ const err = /** @type {any} */ (new Error('replyMarkup must be an object'))
158
+ err.status = 400
159
+ throw err
160
+ }
161
+ const rows = markup.inline_keyboard
162
+ if (!Array.isArray(rows) || rows.length === 0 || rows.length > 100) {
163
+ const err = /** @type {any} */ (new Error('replyMarkup.inline_keyboard must be a non-empty array of at most 100 rows'))
164
+ err.status = 400
165
+ throw err
166
+ }
167
+ let total = 0
168
+ const clean = rows.map((row) => {
169
+ if (!Array.isArray(row) || row.length === 0 || row.length > 8) {
170
+ const err = /** @type {any} */ (new Error('each inline_keyboard row must contain 1..8 buttons'))
171
+ err.status = 400
172
+ throw err
173
+ }
174
+ return row.map((button) => {
175
+ total += 1
176
+ if (total > 100) {
177
+ const err = /** @type {any} */ (new Error('inline_keyboard must contain at most 100 buttons'))
178
+ err.status = 400
179
+ throw err
180
+ }
181
+ const text = typeof button?.text === 'string' ? button.text : ''
182
+ if (!text || text.length > 64) {
183
+ const err = /** @type {any} */ (new Error('button.text must be 1..64 characters'))
184
+ err.status = 400
185
+ throw err
186
+ }
187
+ const out = { text }
188
+ const kinds = ['url', 'callback_data', 'web_app']
189
+ const present = kinds.filter((k) => button[k] !== undefined)
190
+ if (present.length !== 1) {
191
+ const err = /** @type {any} */ (new Error('button must define exactly one of url, callback_data, web_app'))
192
+ err.status = 400
193
+ throw err
194
+ }
195
+ const kind = present[0]
196
+ if (kind === 'url') {
197
+ const url = String(button.url)
198
+ if (!/^https?:\/\//i.test(url) && !url.startsWith('tg://')) {
199
+ const err = /** @type {any} */ (new Error('button.url must be http(s) or tg://'))
200
+ err.status = 400
201
+ throw err
202
+ }
203
+ out.url = url
204
+ } else if (kind === 'callback_data') {
205
+ const data = String(button.callback_data)
206
+ if (!data || Buffer.byteLength(data, 'utf8') > 64) {
207
+ const err = /** @type {any} */ (new Error('button.callback_data must be 1..64 bytes'))
208
+ err.status = 400
209
+ throw err
210
+ }
211
+ out.callback_data = data
212
+ } else {
213
+ const webAppUrl = String(button.web_app?.url || '')
214
+ if (!/^https:\/\//i.test(webAppUrl)) {
215
+ const err = /** @type {any} */ (new Error('button.web_app.url must be https'))
216
+ err.status = 400
217
+ throw err
218
+ }
219
+ out.web_app = { url: webAppUrl }
220
+ }
221
+ return out
222
+ })
223
+ })
224
+ return { inline_keyboard: clean }
225
+ }
226
+
150
227
  export function normalizeSendBody(payload) {
151
228
  const text = typeof payload?.text === 'string' ? payload.text.trim() : ''
152
229
  const files = normalizeFiles(payload?.files)
@@ -158,7 +235,8 @@ export function normalizeSendBody(payload) {
158
235
  const body = {}
159
236
  if (text) body.text = text
160
237
  if (files.length) body.files = files
161
- if (payload?.replyMarkup) body.replyMarkup = payload.replyMarkup
238
+ const markup = sanitizeReplyMarkup(payload?.replyMarkup)
239
+ if (markup) body.replyMarkup = markup
162
240
  return body
163
241
  }
164
242
 
package/lib/pairing.js CHANGED
File without changes
package/lib/proxy.js CHANGED
@@ -613,6 +613,15 @@ export function normalizeApiRoot(rawUrl) {
613
613
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
614
614
  throw new Error(`Unsupported apiRoot protocol "${parsed.protocol}". Must be http: or https:`)
615
615
  }
616
+ // Plain-text http would carry the bot token in the URL path (#205): only
617
+ // loopback hosts (a local Bot API server) may use it.
618
+ if (parsed.protocol === 'http:') {
619
+ const host = parsed.hostname.toLowerCase()
620
+ const loopback = host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '[::1]'
621
+ if (!loopback) {
622
+ throw new Error(`apiRoot "${trimmed}" uses plain http for a non-loopback host; the bot token would travel unencrypted. Use https or a loopback address.`)
623
+ }
624
+ }
616
625
  return trimmed.replace(/\/+$/, '')
617
626
  }
618
627
 
File without changes
package/lib/updater.js CHANGED
@@ -251,6 +251,12 @@ export function registerPluginUpdater(ctx, options) {
251
251
  try {
252
252
  const target = runtime()
253
253
  if (request.method === 'GET' || request.method === 'HEAD') {
254
+ // Version/profile discovery is gated like other admin reads (#206)
255
+ if (typeof options.isTrustedRequest === 'function' && !options.isTrustedRequest(request)) {
256
+ response.writeHead(403, { 'content-type': 'application/json; charset=utf-8' })
257
+ response.end(JSON.stringify({ ok: false, error: 'forbidden' }))
258
+ return
259
+ }
254
260
  const payload = await getUpdateStatus(options, target)
255
261
  response.writeHead(200, {
256
262
  'content-type': 'application/json; charset=utf-8',
File without changes
package/lib/webapp.js CHANGED
@@ -94,6 +94,22 @@ export function validateTelegramWebAppData(rawInitData, botToken, maxAgeSec = 36
94
94
  }
95
95
  }
96
96
 
97
+ // Defense-in-depth for the dashboard innerHTML path (#210): SVG markup is
98
+ // normally generated by our own renderer with escaped text nodes, but anything
99
+ // entering the store is stripped of script blocks, event-handler attributes
100
+ // and javascript: URLs so a future non-escaping source cannot produce stored
101
+ // XSS in the privileged Mini App context.
102
+
103
+ /** @param {any} svg */
104
+ function sanitizeSvgMarkup(svg) {
105
+ let s = String(svg || '')
106
+ s = s.replace(/<script[\s\S]*?<\/script\s*>/gi, '')
107
+ s = s.replace(/<script[^>]*>/gi, '')
108
+ s = s.replace(/\son[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, '')
109
+ s = s.replace(/(href|xlink:href)\s*=\s*(?:"[^"]*javascript:[^"]*"|'[^']*javascript:[^']*'|[^\s>]*javascript:[^\s>]*)/gi, '$1="#"')
110
+ return s
111
+ }
112
+
97
113
  /**
98
114
  * Creates in-memory ring buffer store for artifacts and diagrams
99
115
  * @param {number} [maxItems=100]
@@ -109,7 +125,7 @@ export function createArtifactStore(maxItems = 100) {
109
125
  title: String(artifact.title || 'Artifact'),
110
126
  type: String(artifact.type || 'diagram'),
111
127
  code: String(artifact.code || ''),
112
- svg: String(artifact.svg || ''),
128
+ svg: sanitizeSvgMarkup(artifact.svg),
113
129
  createdAt: Number(artifact.createdAt) || Date.now(),
114
130
  chatId: artifact.chatId != null ? String(artifact.chatId) : null,
115
131
  }
@@ -479,7 +495,12 @@ export function createWebAppHtml(options = {}) {
479
495
  renderArtifacts(currentArtifacts)
480
496
  checkDeepLink()
481
497
  } catch (e) {
482
- document.getElementById('artifacts-list').innerHTML = '<div class="empty-state">Failed to load artifacts: ' + e.message + '</div>'
498
+ const el = document.getElementById('artifacts-list')
499
+ el.innerHTML = ''
500
+ const div = document.createElement('div')
501
+ div.className = 'empty-state'
502
+ div.textContent = 'Failed to load artifacts: ' + e.message
503
+ el.appendChild(div)
483
504
  }
484
505
  }
485
506
 
@@ -565,9 +586,9 @@ export function createWebAppHtml(options = {}) {
565
586
  document.getElementById('stat-sent').textContent = s.stats && s.stats.sent || 0
566
587
  document.getElementById('stat-chats').textContent = s.activeChats || 0
567
588
  document.getElementById('stat-outbox').textContent = s.outbox && s.outbox.pending || 0
568
- document.getElementById('tg-details').innerHTML = 'Bot: @' + (s.botUsername || 'none') + ' | Transport: ' + (s.config && s.config.telegram && s.config.telegram.transport || 'poll')
569
- document.getElementById('adapters-list').innerHTML = (s.adapters || []).map(a => '• <b>' + a + '</b>: active').join('<br>') || 'None'
570
- document.getElementById('model-details').innerHTML = 'Model: <b>' + (s.config && s.config.agent && s.config.agent.model || 'default') + '</b><br>CWD: <code>' + (s.config && s.config.agent && s.config.agent.effectiveCwd || 'standard') + '</code>'
589
+ document.getElementById('tg-details').textContent = 'Bot: @' + (s.botUsername || 'none') + ' | Transport: ' + (s.config && s.config.telegram && s.config.telegram.transport || 'poll')
590
+ document.getElementById('adapters-list').textContent = (s.adapters || []).map(a => '• ' + a + ': active').join('\n') || 'None'
591
+ document.getElementById('model-details').textContent = 'Model: ' + (s.config && s.config.agent && s.config.agent.model || 'default') + ' | CWD: ' + (s.config && s.config.agent && s.config.agent.effectiveCwd || 'standard')
571
592
  } catch (_e) {
572
593
  // ignore status fetch error
573
594
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-messenger-gateway",
3
- "version": "0.4.38",
3
+ "version": "0.4.40",
4
4
  "description": "Telegram messenger bridge for DeepSeek Harness: sessions, steer, homes, inline asks, notify bridge, and optional TTS voice notes.",
5
5
  "license": "MIT",
6
6
  "type": "module",