talon-agent 3.35.0 → 3.36.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.
@@ -25,7 +25,12 @@ CREATE TABLE IF NOT EXISTS history_messages (
25
25
  timestamp INTEGER NOT NULL,
26
26
  media_type TEXT,
27
27
  sticker_file_id TEXT,
28
- file_path TEXT
28
+ file_path TEXT,
29
+ -- Files attached to this message, as a JSON array of
30
+ -- {path,name,size,mimeType,image}. A message can carry several (the
31
+ -- companion's composer stages any number), so file_path above holds
32
+ -- only the first for the pre-multi-file row shape. Null when none.
33
+ attachments TEXT
29
34
  );
30
35
  CREATE INDEX IF NOT EXISTS idx_history_chat ON history_messages(chat_id, id);
31
36
  CREATE UNIQUE INDEX IF NOT EXISTS idx_history_chat_msg ON history_messages(chat_id, msg_id);
@@ -324,6 +329,10 @@ ALTER TABLE history_messages ADD COLUMN sender_handle TEXT`,
324
329
  addSessionsMetricsColumn: `-- Column reconciliation for databases that shipped before per-session
325
330
  -- metrics existed. Fresh databases get the column via schema.sql.
326
331
  ALTER TABLE sessions ADD COLUMN metrics TEXT NOT NULL DEFAULT '{"lifetime":{"counters":{"queries":0,"toolCalls":0,"turnsWithTools":0,"apiCalls":0,"inputTokens":0,"outputTokens":0,"cacheReadTokens":0,"cacheWriteTokens":0,"failedTurns":0,"flowViolationRetries":0,"flowViolationCapExhausted":0,"trailingTextDropped":0},"latency":{"count":0,"sumMs":0,"minMs":null,"maxMs":0},"toolCallsByName":{},"backend":{},"cacheHitPercent":{"count":0,"sumMs":0,"minMs":null,"maxMs":0},"toolCallsPerTurn":{"count":0,"sumMs":0,"minMs":null,"maxMs":0},"apiCallsPerTurn":{"count":0,"sumMs":0,"minMs":null,"maxMs":0}},"buckets":{}}'`,
332
+ addHistoryAttachmentsColumn: `-- Column reconciliation for databases that shipped before a message could
333
+ -- carry more than one attachment. Fresh databases get the column via
334
+ -- schema.sql.
335
+ ALTER TABLE history_messages ADD COLUMN attachments TEXT`,
327
336
  } as const;
328
337
 
329
338
  export const goalsSql = {
@@ -355,22 +364,23 @@ WHERE chat_id = ? AND status IN (/* statuses */)`,
355
364
  export const historySql = {
356
365
  insert: `INSERT OR IGNORE INTO history_messages
357
366
  (chat_id, msg_id, sender_id, sender_name, sender_handle, text,
358
- reply_to_msg_id, timestamp, media_type, sticker_file_id, file_path)
359
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
367
+ reply_to_msg_id, timestamp, media_type, sticker_file_id, file_path,
368
+ attachments)
369
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
360
370
  recent: `SELECT msg_id, sender_id, sender_name, sender_handle, text, reply_to_msg_id,
361
- timestamp, media_type, sticker_file_id, file_path
371
+ timestamp, media_type, sticker_file_id, file_path, attachments
362
372
  FROM history_messages
363
373
  WHERE chat_id = ? ORDER BY id DESC LIMIT ?`,
364
374
  recentBefore: `-- Scroll-back pagination: the window of messages strictly older than a
365
375
  -- given msg_id, newest-first (the repository reverses to chronological).
366
376
  SELECT msg_id, sender_id, sender_name, sender_handle, text, reply_to_msg_id,
367
- timestamp, media_type, sticker_file_id, file_path
377
+ timestamp, media_type, sticker_file_id, file_path, attachments
368
378
  FROM history_messages
369
379
  WHERE chat_id = ? AND msg_id < ? ORDER BY id DESC LIMIT ?`,
370
380
  recentBeforeTime: `-- Time-cursor variant of recentBefore for the read_history \`before\` date
371
381
  -- parameter: the newest \`limit\` messages strictly older than a timestamp.
372
382
  SELECT msg_id, sender_id, sender_name, sender_handle, text, reply_to_msg_id,
373
- timestamp, media_type, sticker_file_id, file_path
383
+ timestamp, media_type, sticker_file_id, file_path, attachments
374
384
  FROM history_messages
375
385
  WHERE chat_id = ? AND timestamp < ? ORDER BY id DESC LIMIT ?`,
376
386
  setFilePath: `UPDATE history_messages SET file_path = ? WHERE chat_id = ? AND msg_id = ?`,
@@ -378,7 +388,7 @@ WHERE chat_id = ? AND timestamp < ? ORDER BY id DESC LIMIT ?`,
378
388
  searchFts: `-- The match param must already be a valid FTS5 expression
379
389
  -- (see history.ts ftsQuery).
380
390
  SELECT msg_id, sender_id, sender_name, sender_handle, text, reply_to_msg_id,
381
- timestamp, media_type, sticker_file_id, file_path
391
+ timestamp, media_type, sticker_file_id, file_path, attachments
382
392
  FROM history_messages
383
393
  WHERE chat_id = ?
384
394
  AND id IN (SELECT rowid FROM history_fts WHERE history_fts MATCH ?)
@@ -387,7 +397,7 @@ ORDER BY id DESC LIMIT ?`,
387
397
  -- search_history \`after\` / \`before\` date parameters. Either bound may be
388
398
  -- the open end of the range (0 / a far-future value).
389
399
  SELECT msg_id, sender_id, sender_name, sender_handle, text, reply_to_msg_id,
390
- timestamp, media_type, sticker_file_id, file_path
400
+ timestamp, media_type, sticker_file_id, file_path, attachments
391
401
  FROM history_messages
392
402
  WHERE chat_id = ?
393
403
  AND id IN (SELECT rowid FROM history_fts WHERE history_fts MATCH ?)
@@ -395,16 +405,16 @@ WHERE chat_id = ?
395
405
  ORDER BY id DESC LIMIT ?`,
396
406
  bySenderName: `-- The fragment param is LIKE-escaped by the repository (backslash escape).
397
407
  SELECT msg_id, sender_id, sender_name, sender_handle, text, reply_to_msg_id,
398
- timestamp, media_type, sticker_file_id, file_path
408
+ timestamp, media_type, sticker_file_id, file_path, attachments
399
409
  FROM history_messages
400
410
  WHERE chat_id = ? AND lower(sender_name) LIKE ? ESCAPE '\\'
401
411
  ORDER BY id DESC LIMIT ?`,
402
412
  byMsgId: `SELECT msg_id, sender_id, sender_name, sender_handle, text, reply_to_msg_id,
403
- timestamp, media_type, sticker_file_id, file_path
413
+ timestamp, media_type, sticker_file_id, file_path, attachments
404
414
  FROM history_messages
405
415
  WHERE chat_id = ? AND msg_id = ? ORDER BY id DESC LIMIT 1`,
406
416
  bySenderId: `SELECT msg_id, sender_id, sender_name, sender_handle, text, reply_to_msg_id,
407
- timestamp, media_type, sticker_file_id, file_path
417
+ timestamp, media_type, sticker_file_id, file_path, attachments
408
418
  FROM history_messages
409
419
  WHERE chat_id = ? AND sender_id = ? ORDER BY id DESC LIMIT ?`,
410
420
  latestMsgId: `SELECT msg_id FROM history_messages WHERE chat_id = ? ORDER BY id DESC LIMIT 1`,