@blogic-cz/agent-tools 0.14.29 → 0.14.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blogic-cz/agent-tools",
3
- "version": "0.14.29",
3
+ "version": "0.14.30",
4
4
  "description": "CLI tools for AI coding agent workflows — GitHub, database, Kubernetes, Azure DevOps, logs, sessions, and audit",
5
5
  "keywords": [
6
6
  "agent",
@@ -434,7 +434,8 @@ export class DbService extends Context.Service<
434
434
  startTimeMs: number,
435
435
  applyTransform = false,
436
436
  ) {
437
- const wrappedSql = `SELECT json_agg(t) FROM (${sql}) t;`;
437
+ const selectSql = sql.trim().replace(/;\s*$/, "");
438
+ const wrappedSql = `SELECT json_agg(t) FROM (${selectSql}) t;`;
438
439
  const command = buildPsqlCommand(config, wrappedSql, password, true);
439
440
  const result = yield* executeShellCommand(command);
440
441
  const endTime = yield* Clock.currentTimeMillis;
@@ -31,6 +31,20 @@ const filterBySource = (summaries: MessageSummary[], source: string): MessageSum
31
31
  return summaries.filter((s) => s.source === (source as SessionSource));
32
32
  };
33
33
 
34
+ const latestSessionSummaries = (summaries: MessageSummary[]): MessageSummary[] => {
35
+ const bySession = new Map<string, MessageSummary>();
36
+
37
+ for (const summary of summaries) {
38
+ const key = `${summary.source}:${summary.sessionID}`;
39
+ const previous = bySession.get(key);
40
+ if (previous === undefined || summary.created > previous.created) {
41
+ bySession.set(key, summary);
42
+ }
43
+ }
44
+
45
+ return [...bySession.values()].toSorted((left, right) => right.created - left.created);
46
+ };
47
+
34
48
  const buildScopeLabel = (searchAll: boolean, currentDir: string) => {
35
49
  if (searchAll) {
36
50
  return "all projects";
@@ -100,7 +114,7 @@ const listCommand = Command.make(
100
114
  }
101
115
 
102
116
  const allSummaries = yield* sessionService.getMessageSummaries(sessionFilter);
103
- const summaries = filterBySource(allSummaries, source);
117
+ const summaries = latestSessionSummaries(filterBySource(allSummaries, source));
104
118
  const results = summaries.slice(0, limit).map((summary) => ({
105
119
  created: formatDate(summary.created),
106
120
  sessionID: summary.sessionID,