@blogic-cz/agent-tools 0.15.1 → 0.15.3

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.
@@ -0,0 +1,42 @@
1
+ import type { MessageSummary, SessionSummary } from "./types";
2
+
3
+ export const sessionSummariesFromMessages = (summaries: MessageSummary[]): SessionSummary[] => {
4
+ const bySession = new Map<string, SessionSummary>();
5
+
6
+ for (const summary of summaries) {
7
+ const key = `${summary.source}:${summary.sessionID}`;
8
+ const previous = bySession.get(key);
9
+ if (previous === undefined) {
10
+ bySession.set(key, {
11
+ sessionID: summary.sessionID,
12
+ title: summary.title,
13
+ createdAt: summary.created,
14
+ updatedAt: summary.created,
15
+ source: summary.source,
16
+ });
17
+ continue;
18
+ }
19
+ previous.createdAt = Math.min(previous.createdAt, summary.created);
20
+ if (summary.created > previous.updatedAt) {
21
+ previous.updatedAt = summary.created;
22
+ previous.title = summary.title;
23
+ }
24
+ }
25
+
26
+ return [...bySession.values()];
27
+ };
28
+
29
+ export const projectSessionFilter = (
30
+ sessionsBySource: ReadonlyMap<SessionSummary["source"], Set<string>>,
31
+ source: SessionSummary["source"],
32
+ allProjects: boolean,
33
+ ): Set<string> | null => (allProjects ? null : (sessionsBySource.get(source) ?? new Set()));
34
+
35
+ export const sortSessionSummaries = (summaries: SessionSummary[]): SessionSummary[] =>
36
+ summaries.toSorted(
37
+ (left, right) =>
38
+ right.updatedAt - left.updatedAt ||
39
+ right.createdAt - left.createdAt ||
40
+ left.source.localeCompare(right.source) ||
41
+ left.sessionID.localeCompare(right.sessionID),
42
+ );
@@ -10,8 +10,10 @@ export type SessionInfo = {
10
10
  projectID: string;
11
11
  };
12
12
 
13
- export const SessionSourceLiterals = Schema.Literals(["opencode", "claude-code", "codex", "pi"]);
14
- export type SessionSource = Schema.Schema.Type<typeof SessionSourceLiterals>;
13
+ export const SESSION_SOURCES = ["opencode", "claude-code", "codex", "pi"] as const;
14
+ export const SessionSourceLiterals = Schema.Literals(SESSION_SOURCES);
15
+ export type SessionSource = (typeof SESSION_SOURCES)[number];
16
+ export const ALL_SESSION_SOURCES: ReadonlySet<SessionSource> = new Set(SESSION_SOURCES);
15
17
 
16
18
  export type MessageSummary = {
17
19
  sessionID: string;
@@ -23,6 +25,14 @@ export type MessageSummary = {
23
25
  source: SessionSource;
24
26
  };
25
27
 
28
+ export type SessionSummary = {
29
+ sessionID: string;
30
+ title: string;
31
+ createdAt: number;
32
+ updatedAt: number;
33
+ source: SessionSource;
34
+ };
35
+
26
36
  export type SessionResult = {
27
37
  success: boolean;
28
38
  data?: unknown;