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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindvest-atlas",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Atlas CLI — OAuth login, tool calls, and live alert/flow streaming for the Atlas trading API",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,13 +35,18 @@ function maybeWriteChartSink(data) {
35
35
  }
36
36
  if (!chart) return;
37
37
  try {
38
- fs.mkdirSync(path.dirname(sink), { recursive: true });
39
- // APPEND one JSON line per chart (JSONL) — never overwrite. Two chart tool
40
- // calls in the SAME turn each land their own line, so the Studio watcher
41
- // captures BOTH; an overwrite lost the first when the second raced in
42
- // before the watcher read it (the "multi-chart-per-turn never rendered"
43
- // bug). The host reads the file whole and fires each new line.
44
- fs.appendFileSync(sink, JSON.stringify({ at: Date.now(), payload: chart }) + '\n');
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
  }