mindvest-atlas 0.1.3 → 0.1.4
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/src/commands/call.js +12 -7
package/package.json
CHANGED
package/src/commands/call.js
CHANGED
|
@@ -35,13 +35,18 @@ function maybeWriteChartSink(data) {
|
|
|
35
35
|
}
|
|
36
36
|
if (!chart) return;
|
|
37
37
|
try {
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
// calls
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
// ONE FILE PER CHART, unique name, written temp-then-renamed (atomic) so the
|
|
39
|
+
// host only reads a COMPLETE file. One file per chart means concurrent chart
|
|
40
|
+
// tool calls can never interleave-corrupt a shared file — the bug that
|
|
41
|
+
// dropped a turn's charts and poisoned later writes. `sink` is the base path
|
|
42
|
+
// (`<dir>/<sessionId>.json`); we derive a sibling `<sessionId>.<uniq>.chartpart`.
|
|
43
|
+
const dir = path.dirname(sink);
|
|
44
|
+
const base = path.basename(sink, '.json');
|
|
45
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
46
|
+
const uniq = base + '.' + Date.now() + '-' + process.pid + '-' + Math.floor(Math.random() * 1e9) + '.chartpart';
|
|
47
|
+
const tmp = path.join(dir, uniq + '.tmp');
|
|
48
|
+
fs.writeFileSync(tmp, JSON.stringify({ at: Date.now(), payload: chart }));
|
|
49
|
+
fs.renameSync(tmp, path.join(dir, uniq));
|
|
45
50
|
} catch {
|
|
46
51
|
/* UI-only side channel — never fail the command */
|
|
47
52
|
}
|