@solongate/proxy 0.81.63 → 0.81.64

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.
@@ -58,3 +58,4 @@
58
58
  {"ms":4,"ts":1784374792946,"tool":"Write","session":"f5933c65-c315-4440-9afb-7136fce6b695"}
59
59
  {"ms":4,"ts":1784374838495,"tool":"Write","session":"f5933c65-c315-4440-9afb-7136fce6b695"}
60
60
  {"ms":3,"ts":1784374848281,"tool":"Bash","session":"f5933c65-c315-4440-9afb-7136fce6b695"}
61
+ {"ms":4,"ts":1784375224287,"tool":"Bash","session":"f5933c65-c315-4440-9afb-7136fce6b695"}
@@ -1 +1 @@
1
- {"ms":3,"ts":1784374848281,"tool":"Bash","session":"f5933c65-c315-4440-9afb-7136fce6b695"}
1
+ {"ms":4,"ts":1784375224287,"tool":"Bash","session":"f5933c65-c315-4440-9afb-7136fce6b695"}
@@ -1 +1 @@
1
- 1784374838541
1
+ 1784375211122
@@ -6536,7 +6536,7 @@ import { resolve, join, dirname, isAbsolute } from "node:path";
6536
6536
  import { homedir } from "node:os";
6537
6537
  import { gunzipSync } from "node:zlib";
6538
6538
  import { createHash } from "node:crypto";
6539
- var HOOK_VERSION = 37;
6539
+ var HOOK_VERSION = 38;
6540
6540
  function localLogsOnly(security) {
6541
6541
  if (security && typeof security === "object") {
6542
6542
  const l = security.localLogs;
@@ -6586,9 +6586,27 @@ function writeLocalLog(security, entry) {
6586
6586
  const dir = resolveLocalLogDir(l.path);
6587
6587
  if (!dir)
6588
6588
  return;
6589
+ try {
6590
+ mkdirSync(dir, { recursive: true });
6591
+ } catch {
6592
+ }
6593
+ const file = join(dir, "solongate-audit.jsonl");
6589
6594
  const line = JSON.stringify(entry) + "\n";
6590
- const payload = Buffer.from(JSON.stringify({ dir, line }), "utf-8").toString("base64");
6591
- spawn(process.execPath, [process.argv[1], "--sg-log-write", payload], { detached: true, stdio: "ignore" }).unref();
6595
+ for (let attempt = 0; attempt < 12; attempt++) {
6596
+ try {
6597
+ appendFileSync(file, line);
6598
+ return;
6599
+ } catch {
6600
+ const _end = Date.now() + 2;
6601
+ while (Date.now() < _end) {
6602
+ }
6603
+ }
6604
+ }
6605
+ try {
6606
+ const payload = Buffer.from(JSON.stringify({ dir, line }), "utf-8").toString("base64");
6607
+ spawn(process.execPath, [process.argv[1], "--sg-log-write", payload], { detached: true, stdio: "ignore" }).unref();
6608
+ } catch {
6609
+ }
6592
6610
  } catch {
6593
6611
  }
6594
6612
  }
package/hooks/guard.mjs CHANGED
@@ -32,7 +32,7 @@ import { createHash } from 'node:crypto';
32
32
  // the installed hook self-updates when the cloud version is higher (see
33
33
  // maybeSelfUpdate). This is what makes guard fixes propagate without a manual
34
34
  // reinstall — the same trust model as the OPA WASM this hook already runs.
35
- const HOOK_VERSION = 37;
35
+ const HOOK_VERSION = 38;
36
36
 
37
37
  // True when local log storage is ON. In that mode logs are kept LOCAL ONLY and
38
38
  // nothing is sent to the cloud audit log.
@@ -102,13 +102,23 @@ function writeLocalLog(security, entry) {
102
102
  if (!l || !l.enabled || typeof l.path !== 'string' || !l.path.trim()) return;
103
103
  const dir = resolveLocalLogDir(l.path);
104
104
  if (!dir) return;
105
+ try { mkdirSync(dir, { recursive: true }); } catch {}
106
+ const file = join(dir, 'solongate-audit.jsonl');
105
107
  const line = JSON.stringify(entry) + '\n';
106
- // GUARANTEED write: hand the append to a DETACHED child in its own process
107
- // group. Even if Claude Code kills this hook mid-write during a concurrent
108
- // denial burst, the child survives and completes the append no denial is
109
- // ever lost from the local log. (Inline appends dropped under burst.)
110
- const payload = Buffer.from(JSON.stringify({ dir, line }), 'utf-8').toString('base64');
111
- spawn(process.execPath, [process.argv[1], '--sg-log-write', payload], { detached: true, stdio: 'ignore' }).unref();
108
+ // GUARANTEED write. Under a concurrent denial burst the append can transiently
109
+ // throw (contention on the shared file while the dashboard reads it); this
110
+ // hook process stays alive (it reaches blockTool), so retry the append a few
111
+ // times with a short spin-backoff until it lands.
112
+ for (let attempt = 0; attempt < 12; attempt++) {
113
+ try { appendFileSync(file, line); return; }
114
+ catch { const _end = Date.now() + 2; while (Date.now() < _end) { /* spin ~2ms */ } }
115
+ }
116
+ // Every inline attempt threw: hand off to a DETACHED child (own process group,
117
+ // survives this process's death) as the final guarantee the entry is written.
118
+ try {
119
+ const payload = Buffer.from(JSON.stringify({ dir, line }), 'utf-8').toString('base64');
120
+ spawn(process.execPath, [process.argv[1], '--sg-log-write', payload], { detached: true, stdio: 'ignore' }).unref();
121
+ } catch {}
112
122
  } catch { /* best-effort */ }
113
123
  }
114
124
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.81.63",
3
+ "version": "0.81.64",
4
4
  "description": "AI tool security proxy: protect any AI tool server with customizable policies, path/command constraints, rate limiting, and audit logging. No code changes required.",
5
5
  "type": "module",
6
6
  "bin": {