@saleso.innovations/bridge 0.1.24 → 0.1.25
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
|
-
{"version":3,"file":"hermesSessionDb.d.ts","sourceRoot":"","sources":["../src/hermesSessionDb.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"hermesSessionDb.d.ts","sourceRoot":"","sources":["../src/hermesSessionDb.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAyIF,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAapE;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAuBxF;AAED,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GACxE,oBAAoB,EAAE,CAwCxB;AAED,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,GAChB;IAAE,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,CAmCzD;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAO7C;AAED,wBAAgB,qBAAqB,IAAI;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAgBzD"}
|
package/dist/hermesSessionDb.js
CHANGED
|
@@ -93,13 +93,29 @@ function sessionTitleFromChain(db, sessionId) {
|
|
|
93
93
|
}
|
|
94
94
|
return null;
|
|
95
95
|
}
|
|
96
|
+
function sessionTitleFromFirstUserMessage(db, sessionId) {
|
|
97
|
+
const resolved = resolveResumeSessionId(db, sessionId);
|
|
98
|
+
const chain = sessionAncestorChain(db, resolved);
|
|
99
|
+
const placeholders = chain.map(() => "?").join(", ");
|
|
100
|
+
const row = db
|
|
101
|
+
.prepare(`SELECT content FROM messages
|
|
102
|
+
WHERE session_id IN (${placeholders}) AND role = 'user'
|
|
103
|
+
ORDER BY timestamp ASC, id ASC
|
|
104
|
+
LIMIT 1`)
|
|
105
|
+
.get(...chain);
|
|
106
|
+
const snippet = decodeMessageContent(row?.content ?? null).trim().slice(0, 120);
|
|
107
|
+
return snippet || null;
|
|
108
|
+
}
|
|
109
|
+
function sessionTitleForLookupId(db, sessionId) {
|
|
110
|
+
return sessionTitleFromChain(db, sessionId) ?? sessionTitleFromFirstUserMessage(db, sessionId);
|
|
111
|
+
}
|
|
96
112
|
export function resolveSessionTitle(sessionId) {
|
|
97
113
|
if (!sessionId.trim() || !hermesStateDbExists()) {
|
|
98
114
|
return null;
|
|
99
115
|
}
|
|
100
116
|
const db = openReadOnlyDb();
|
|
101
117
|
try {
|
|
102
|
-
return
|
|
118
|
+
return sessionTitleForLookupId(db, sessionId);
|
|
103
119
|
}
|
|
104
120
|
catch {
|
|
105
121
|
return null;
|
|
@@ -120,7 +136,7 @@ export function resolveSessionTitles(sessionIds) {
|
|
|
120
136
|
const db = openReadOnlyDb();
|
|
121
137
|
try {
|
|
122
138
|
for (const sessionId of uniqueIds) {
|
|
123
|
-
titles[sessionId] =
|
|
139
|
+
titles[sessionId] = sessionTitleForLookupId(db, sessionId);
|
|
124
140
|
}
|
|
125
141
|
}
|
|
126
142
|
catch {
|