feat: ingest Kagi Assistant threads
Add a Kagi source that indexes Assistant conversations with the subscriber
session token, one entry per thread.
- Read the token from KAGI_SESSION_TOKEN, KAGI_SESSION_TOKEN_FILE, or the
kagi-cli config ([auth] session_token); accept full session-link URLs.
- List conversations through /api/conversations, load each thread via
/api/v2/conversations/{id}/init, and walk older turn pages through the
branch turns endpoint.
- Render one markdown document per thread (stable fingerprint by conversation
UUID, content hash for versioning), keeping the newest turns when a thread
exceeds the body budget.
- Skip re-fetching threads whose updated_at has not moved during this process.
- Wire the 30-minute watcher ticker + sync status, the `knox kagi` command,
the full ingest sweep, MCP scope filtering, thread anchoring, and web links.
This commit is contained in:
+4
-3
@@ -1112,6 +1112,7 @@ var sourceWeight = map[string]float64{
|
||||
"opencode-session": 1.0,
|
||||
"obsidian": 1.0,
|
||||
"karakeep": 1.0,
|
||||
"kagi": 0.8,
|
||||
"git": 0.35,
|
||||
"gitea": 0.35,
|
||||
"browser-history": 0.35,
|
||||
@@ -2354,7 +2355,7 @@ func (k *KnoxDB) RescanThread(threadID int64) (int, error) {
|
||||
// workSources imply active intent (vs passive browsing) when judging whether a
|
||||
// thread has a real anchor.
|
||||
var workSources = map[string]bool{
|
||||
"git": true, "gitea": true, "opencode-session": true, "obsidian": true, "filesystem": true, "karakeep": true,
|
||||
"git": true, "gitea": true, "opencode-session": true, "obsidian": true, "filesystem": true, "karakeep": true, "kagi": true,
|
||||
}
|
||||
|
||||
// ThreadAssessment is a per-thread snapshot for agent-driven grooming: value,
|
||||
@@ -2648,7 +2649,7 @@ func (k *KnoxDB) MergeSuggestions(minShared int, minRatio float64) ([]ThreadMerg
|
||||
JOIN thread_observations tos ON tos.thread_id = t.id
|
||||
JOIN observations o ON o.id = tos.observation_id
|
||||
WHERE t.status='active' AND COALESCE(o.fingerprint,'') != ''
|
||||
AND o.source_id IN ('git','gitea','opencode-session','obsidian','karakeep','filesystem')`)
|
||||
AND o.source_id IN ('git','gitea','opencode-session','obsidian','karakeep','kagi','filesystem')`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -2845,7 +2846,7 @@ func (k *KnoxDB) DenyThreadNoise(dryRun bool) (removed int, closed []int64, err
|
||||
if err := k.db.QueryRow(
|
||||
`SELECT COUNT(*) FROM thread_observations to2 JOIN observations o ON o.id = to2.observation_id
|
||||
WHERE to2.thread_id = ?
|
||||
AND o.source_id IN ('git','gitea','opencode-session','obsidian','filesystem','karakeep')`,
|
||||
AND o.source_id IN ('git','gitea','opencode-session','obsidian','filesystem','karakeep','kagi')`,
|
||||
t.id,
|
||||
).Scan(&workLinks); err != nil {
|
||||
return removed, nil, err
|
||||
|
||||
Reference in New Issue
Block a user