mio-agent-runtime 0.13.4 → 0.13.5

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.
@@ -72,8 +72,8 @@ function readJsonSafe(filePath) {
72
72
  if (!fs.existsSync(filePath)) return null
73
73
  try {
74
74
  return JSON.parse(fs.readFileSync(filePath, 'utf8'))
75
- } catch {
76
- return null
75
+ } catch (err) {
76
+ throw new Error(`Failed to parse JSON from ${filePath}: ${err.message}`)
77
77
  }
78
78
  }
79
79
 
@@ -91,19 +91,20 @@ function todayTaskId() {
91
91
  function readJsonlSafe(filePath) {
92
92
  if (!fs.existsSync(filePath)) return []
93
93
  try {
94
- return fs
94
+ const lines = fs
95
95
  .readFileSync(filePath, 'utf8')
96
96
  .trim()
97
97
  .split('\n')
98
98
  .filter(Boolean)
99
- .map((l) => {
100
- try {
101
- return JSON.parse(l)
102
- } catch {
103
- return null
104
- }
105
- })
106
- .filter(Boolean)
99
+ const results = []
100
+ for (let i = 0; i < lines.length; i++) {
101
+ try {
102
+ results.push(JSON.parse(lines[i]))
103
+ } catch (err) {
104
+ console.warn(`Skipping corrupted line ${i + 1} in ${filePath}: ${err.message}`)
105
+ }
106
+ }
107
+ return results
107
108
  } catch {
108
109
  return []
109
110
  }