@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 +1 -1
- package/src/db-tool/service.ts +2 -1
- package/src/session-tool/index.ts +15 -1
package/package.json
CHANGED
package/src/db-tool/service.ts
CHANGED
|
@@ -434,7 +434,8 @@ export class DbService extends Context.Service<
|
|
|
434
434
|
startTimeMs: number,
|
|
435
435
|
applyTransform = false,
|
|
436
436
|
) {
|
|
437
|
-
const
|
|
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,
|