@openviking/opencode-plugin 2026.10.14 → 2026.10.15
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/lib/memory-session.mjs +16 -1
- package/package.json +2 -2
package/lib/memory-session.mjs
CHANGED
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
safeStringify,
|
|
26
26
|
} from "./utils.mjs"
|
|
27
27
|
|
|
28
|
+
const STALE_SESSION_STATE_MS = 7 * 24 * 60 * 60 * 1000
|
|
29
|
+
|
|
28
30
|
export function createMemorySessionManager({ config, pluginRoot }) {
|
|
29
31
|
const sessions = new Map()
|
|
30
32
|
const statePath = path.join(pluginRoot, "openviking-session-state.json")
|
|
@@ -77,10 +79,17 @@ export function createMemorySessionManager({ config, pluginRoot }) {
|
|
|
77
79
|
log("ERROR", "persistence", "Unsupported session map version", { version: data.version })
|
|
78
80
|
return
|
|
79
81
|
}
|
|
82
|
+
const staleBefore = Date.now() - STALE_SESSION_STATE_MS
|
|
83
|
+
let pruned = 0
|
|
80
84
|
for (const [opencodeSessionId, persisted] of Object.entries(data.sessions ?? {})) {
|
|
85
|
+
if (isPrunable(persisted, staleBefore)) {
|
|
86
|
+
pruned += 1
|
|
87
|
+
continue
|
|
88
|
+
}
|
|
81
89
|
sessions.set(opencodeSessionId, deserializeSessionState(persisted))
|
|
82
90
|
}
|
|
83
|
-
log("INFO", "persistence", "Session state loaded", { count: sessions.size })
|
|
91
|
+
log("INFO", "persistence", "Session state loaded", { count: sessions.size, pruned })
|
|
92
|
+
if (pruned > 0) await enqueueSave()
|
|
84
93
|
} catch (error) {
|
|
85
94
|
log("ERROR", "persistence", "Failed to load session state", { error: error?.message })
|
|
86
95
|
if (fs.existsSync(statePath)) {
|
|
@@ -133,6 +142,12 @@ export function createMemorySessionManager({ config, pluginRoot }) {
|
|
|
133
142
|
}
|
|
134
143
|
}
|
|
135
144
|
|
|
145
|
+
// A stale session whose messages are all captured holds nothing left to send.
|
|
146
|
+
function isPrunable(persisted, staleBefore) {
|
|
147
|
+
if ((persisted.lastActivityAt ?? 0) >= staleBefore) return false
|
|
148
|
+
return (persisted.messages ?? []).every(([, message]) => message.captured)
|
|
149
|
+
}
|
|
150
|
+
|
|
136
151
|
function deserializeSessionState(persisted) {
|
|
137
152
|
return {
|
|
138
153
|
ovSessionId: persisted.ovSessionId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openviking/opencode-plugin",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.15",
|
|
4
4
|
"author": "@openviking",
|
|
5
5
|
"description": "Unified OpenCode plugin for OpenViking repository retrieval and long-term memory",
|
|
6
6
|
"type": "module",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"code-search"
|
|
47
47
|
],
|
|
48
48
|
"license": "Apache-2.0",
|
|
49
|
-
"openvikingSourceCommit": "
|
|
49
|
+
"openvikingSourceCommit": "60629f92bfd7d05c67bc50aa452f852acbc77c39"
|
|
50
50
|
}
|