mio-agent-runtime 0.13.0 → 0.13.1
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/server/insight-store.js +28 -1
package/package.json
CHANGED
package/server/insight-store.js
CHANGED
|
@@ -9,8 +9,23 @@
|
|
|
9
9
|
// same "not installed" error, and isInsightAvailable() lets the MCP server gate
|
|
10
10
|
// tool registration on it.
|
|
11
11
|
|
|
12
|
+
const fs = require('fs')
|
|
12
13
|
const path = require('path')
|
|
13
14
|
|
|
15
|
+
// Cache validity key for insight reads, in the same spirit as
|
|
16
|
+
// memory-store.js's read cache: a file's (size, mtimeMs) pair. The underlying
|
|
17
|
+
// InsightStore loads its JSON once in its constructor and answers every later
|
|
18
|
+
// read from that frozen in-memory copy, so an instance held for the life of a
|
|
19
|
+
// process goes stale the moment another process writes.
|
|
20
|
+
function fileSignature(filePath) {
|
|
21
|
+
try {
|
|
22
|
+
const st = fs.statSync(filePath)
|
|
23
|
+
return `${st.size}:${st.mtimeMs}`
|
|
24
|
+
} catch (_) {
|
|
25
|
+
return 'missing'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
// Same two-step resolution as server/runtime-modules.js: the published package
|
|
15
30
|
// first, then the workspace source. In a checkout the @akemi-mio/* packages are
|
|
16
31
|
// NOT linked into node_modules (there is no node_modules/@akemi-mio at all), so
|
|
@@ -51,11 +66,23 @@ function createInsightStore(options = {}) {
|
|
|
51
66
|
// Built on first use rather than at construction: the MCP server used to
|
|
52
67
|
// build it eagerly at module load, which touched the filesystem even when no
|
|
53
68
|
// insight tool was ever called.
|
|
69
|
+
//
|
|
70
|
+
// Rebuilt whenever the file changes, not cached forever. A long-running MCP
|
|
71
|
+
// process used to keep one InsightStore instance, so insights generated by a
|
|
72
|
+
// separate `mio insight generate` (or another session) never showed up: MCP
|
|
73
|
+
// status reported 0 while `mio insight status` reported 4. The file signature
|
|
74
|
+
// is checked on every call, so a write from any process is picked up without
|
|
75
|
+
// restarting -- the same guarantee memory-store.js gives its JSONL reads.
|
|
54
76
|
let store = null
|
|
77
|
+
let storeSignature = null
|
|
55
78
|
function requireStore() {
|
|
56
79
|
if (!InsightStore) throw new Error('@akemi-mio/insight not installed')
|
|
57
80
|
if (!storePath) throw new Error('insight store requires dataDir or storePath')
|
|
58
|
-
|
|
81
|
+
const signature = fileSignature(storePath)
|
|
82
|
+
if (!store || storeSignature !== signature) {
|
|
83
|
+
store = new InsightStore(storePath)
|
|
84
|
+
storeSignature = signature
|
|
85
|
+
}
|
|
59
86
|
return store
|
|
60
87
|
}
|
|
61
88
|
|