@botbotgo/agent-harness 0.0.254 → 0.0.256

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.
@@ -1 +1 @@
1
- export declare const AGENT_HARNESS_VERSION = "0.0.253";
1
+ export declare const AGENT_HARNESS_VERSION = "0.0.255";
@@ -1 +1 @@
1
- export const AGENT_HARNESS_VERSION = "0.0.253";
1
+ export const AGENT_HARNESS_VERSION = "0.0.255";
@@ -163,6 +163,7 @@ export class SqlitePersistence {
163
163
  updated_at TEXT NOT NULL
164
164
  )
165
165
  `);
166
+ await this.rawExecute("CREATE INDEX IF NOT EXISTS threads_updated_idx ON threads(updated_at DESC)");
166
167
  await this.rawExecute(`
167
168
  CREATE TABLE IF NOT EXISTS runs (
168
169
  run_id TEXT PRIMARY KEY,
@@ -680,7 +681,23 @@ export class SqlitePersistence {
680
681
  const { clause, args } = buildWhereClause([
681
682
  ["threads.entry_agent_id = ?", filter.agentId],
682
683
  ]);
683
- const rows = await this.selectAll(`SELECT threads.thread_id, threads.entry_agent_id, threads.latest_run_id, threads.created_at, threads.updated_at, threads.status, run_inspection.current_agent_id,
684
+ const rows = await this.selectAll(`WITH ranked_messages AS (
685
+ SELECT thread_id,
686
+ role,
687
+ content_json,
688
+ run_id,
689
+ created_at,
690
+ ROW_NUMBER() OVER (
691
+ PARTITION BY thread_id
692
+ ORDER BY created_at ASC, id ASC
693
+ ) AS first_rank,
694
+ ROW_NUMBER() OVER (
695
+ PARTITION BY thread_id
696
+ ORDER BY created_at DESC, id DESC
697
+ ) AS last_rank
698
+ FROM thread_messages
699
+ )
700
+ SELECT threads.thread_id, threads.entry_agent_id, threads.latest_run_id, threads.created_at, threads.updated_at, threads.status, run_inspection.current_agent_id,
684
701
  COALESCE(message_counts.message_count, 0) AS message_count,
685
702
  first_message.role AS first_message_role,
686
703
  first_message.content_json AS first_message_content_json,
@@ -697,20 +714,12 @@ export class SqlitePersistence {
697
714
  FROM thread_messages
698
715
  GROUP BY thread_id
699
716
  ) message_counts ON message_counts.thread_id = threads.thread_id
700
- LEFT JOIN thread_messages AS first_message ON first_message.id = (
701
- SELECT message.id
702
- FROM thread_messages AS message
703
- WHERE message.thread_id = threads.thread_id
704
- ORDER BY message.created_at ASC, message.id ASC
705
- LIMIT 1
706
- )
707
- LEFT JOIN thread_messages AS last_message ON last_message.id = (
708
- SELECT message.id
709
- FROM thread_messages AS message
710
- WHERE message.thread_id = threads.thread_id
711
- ORDER BY message.created_at DESC, message.id DESC
712
- LIMIT 1
713
- )
717
+ LEFT JOIN ranked_messages AS first_message
718
+ ON first_message.thread_id = threads.thread_id
719
+ AND first_message.first_rank = 1
720
+ LEFT JOIN ranked_messages AS last_message
721
+ ON last_message.thread_id = threads.thread_id
722
+ AND last_message.last_rank = 1
714
723
  ${clause}
715
724
  ORDER BY threads.updated_at DESC`, args);
716
725
  return rows.map((row) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbotgo/agent-harness",
3
- "version": "0.0.254",
3
+ "version": "0.0.256",
4
4
  "description": "Workspace runtime for multi-agent applications",
5
5
  "license": "MIT",
6
6
  "type": "module",