@wrongstack/wrongtrace 0.316.2 → 0.317.0

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/dist/discovery.js CHANGED
@@ -17,7 +17,7 @@
17
17
  import { platform } from "node:os";
18
18
  import { join } from "node:path";
19
19
  /** Default IPC paths per platform — only consulted when `/api/health` did not return `socket_path`. */
20
- export function defaultSocketPath(home = process.env.HOME ?? process.env.USERPROFILE ?? "") {
20
+ export function defaultSocketPath(home = process.env['HOME'] ?? process.env['USERPROFILE'] ?? "") {
21
21
  if (platform() === "win32")
22
22
  return "\\\\.\\pipe\\wrongtrace.sock";
23
23
  if (home)
@@ -25,7 +25,7 @@ export function defaultSocketPath(home = process.env.HOME ?? process.env.USERPRO
25
25
  return "/tmp/wrongtrace.sock";
26
26
  }
27
27
  export async function discover(opts = {}) {
28
- const baseUrl = opts.baseUrl ?? process.env.WRONGTRACE_URL ?? "http://localhost:3444";
28
+ const baseUrl = opts.baseUrl ?? process.env['WRONGTRACE_URL'] ?? "http://localhost:3444";
29
29
  const timeoutMs = opts.timeoutMs ?? 1000;
30
30
  const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
31
31
  if (typeof fetchImpl !== "function") {
@@ -106,7 +106,21 @@ export function persistWrongTraceGateCounters(projectRoot, snapshot) {
106
106
  try {
107
107
  await fs.mkdir(path.dirname(file), { recursive: true });
108
108
  await fs.writeFile(tmp, JSON.stringify({ at: new Date().toISOString(), ...snapshot }, null, 2), 'utf8');
109
- await fs.rename(tmp, file);
109
+ let renamed = false;
110
+ for (let attempt = 0; attempt < 5; attempt++) {
111
+ try {
112
+ await fs.rename(tmp, file);
113
+ renamed = true;
114
+ break;
115
+ }
116
+ catch {
117
+ await new Promise((r) => setTimeout(r, 50));
118
+ }
119
+ }
120
+ if (!renamed) {
121
+ await fs.copyFile(tmp, file);
122
+ await fs.unlink(tmp).catch(() => { });
123
+ }
110
124
  }
111
125
  catch {
112
126
  // best-effort: leave the prior file intact (rename is atomic; a failed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/wrongtrace",
3
- "version": "0.316.2",
3
+ "version": "0.317.0",
4
4
  "license": "MIT",
5
5
  "description": "Optional client adapter for the external WrongTrace AI Observability daemon. Discovers the daemon over HTTP/IPC/MCP at runtime; returns isAvailable:false when it is not reachable, so callers degrade gracefully. Not coupled to any runtime inside WrongStack — this is the 'sibling' integration protocol.",
6
6
  "repository": {