mio-agent-runtime 0.13.0 → 0.13.2

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/bin/mio.js CHANGED
@@ -1884,6 +1884,9 @@ function printObserverPipeline(result) {
1884
1884
  }
1885
1885
  if (!result.completed) {
1886
1886
  console.log(`Observer pipeline did not complete: ${result.reason || 'unknown reason'}`)
1887
+ // Show what the run actually produced, so a failing exit code is diagnosable
1888
+ // instead of a bare "unknown reason".
1889
+ console.log(` sections=${result.sections || 0} topic=${result.topic || 'none'} insight=${result.insightId || 'none'}`)
1887
1890
  process.exitCode = 1
1888
1891
  return
1889
1892
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mio-agent-runtime",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "description": "Mio Agent Runtime installer and MCP intelligence layer",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -33,7 +33,7 @@
33
33
  "@akemi-mio/evolution-strategy": "^0.1.0",
34
34
  "@akemi-mio/evolution-safety": "^0.1.0",
35
35
  "@akemi-mio/evolution-scheduler": "^0.1.0",
36
- "@akemi-mio/observer": "^0.1.1",
36
+ "@akemi-mio/observer": "^0.1.2",
37
37
  "@akemi-mio/insight": "^0.1.0"
38
38
  },
39
39
  "main": "index.js",
@@ -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
- if (!store) store = new InsightStore(storePath)
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
 
@@ -306,12 +306,22 @@ function createObserverStore(options = {}) {
306
306
  }
307
307
  }
308
308
  const payload = envelope.payload || {}
309
+ // dagState.state is COMPLETED on @akemi-mio/observer >= 0.1.2, which marks the
310
+ // dag COMPLETED *before* publishInsight snapshots it into the envelope.
311
+ // Older producers published while the dag still said STORED even though the
312
+ // run had in fact finished, and a strict COMPLETED check turned every success
313
+ // into completed:false (D5). This branch only exists when publishing
314
+ // succeeded, so STORED counts as completed; anything else is a real failure
315
+ // and must carry a reason, otherwise the CLI can only print "unknown reason".
316
+ const state = envelope.dagState ? envelope.dagState.state : null
317
+ const completed = state === 'COMPLETED' || state === 'STORED'
309
318
  return {
310
319
  dryRun: false,
311
320
  baseDir,
312
321
  mode,
313
322
  ran: true,
314
- completed: envelope.dagState && envelope.dagState.state === 'COMPLETED',
323
+ completed,
324
+ ...(completed ? {} : { reason: `unexpected dag state: ${state || 'missing'} (expected COMPLETED)` }),
315
325
  type: envelope.type,
316
326
  taskId: envelope.dagState ? envelope.dagState.taskId : null,
317
327
  topic: payload.topic || null,