@solongate/proxy 0.81.82 → 0.81.83

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.
@@ -11,6 +11,13 @@ export declare function globalPaths(): {
11
11
  };
12
12
  export declare function clearGuardUpdateCheck(): boolean;
13
13
  export declare function runGlobalRestore(): void;
14
+ /**
15
+ * Delete the guard's cached policy/security config (`~/.solongate/.policy-cache-*.json`)
16
+ * so the next tool call RE-FETCHES it from the API. Fixes a stale cache — e.g. the
17
+ * guard still enforcing DLP `detect` after you switched it to `block` in the
18
+ * dataroom. Best-effort; returns how many cache files it cleared.
19
+ */
20
+ export declare function clearPolicyCache(): number;
14
21
  /**
15
22
  * TUI-safe (re)install — the dataroom's one-key "install / update guard" action.
16
23
  * Writes the hook files THIS CLI ships (readGuard = the current package's bundle,
@@ -1,5 +1,5 @@
1
1
  // src/global-install.ts
2
- import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } from "fs";
2
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync, readdirSync } from "fs";
3
3
  import { resolve, join, dirname } from "path";
4
4
  import { homedir } from "os";
5
5
  import { fileURLToPath } from "url";
@@ -137,6 +137,24 @@ function runGlobalRestore() {
137
137
  }
138
138
  console.log(" Global SolonGate enforcement uninstalled. Restart Claude Code.");
139
139
  }
140
+ function clearPolicyCache() {
141
+ try {
142
+ const dir = globalPaths().sgDir;
143
+ let n = 0;
144
+ for (const f of readdirSync(dir)) {
145
+ if (f.startsWith(".policy-cache-") && f.endsWith(".json")) {
146
+ try {
147
+ rmSync(join(dir, f), { force: true });
148
+ n++;
149
+ } catch {
150
+ }
151
+ }
152
+ }
153
+ return n;
154
+ } catch {
155
+ return 0;
156
+ }
157
+ }
140
158
  function installGlobalQuiet() {
141
159
  try {
142
160
  const p = globalPaths();
@@ -179,8 +197,9 @@ function installGlobalQuiet() {
179
197
  }
180
198
  };
181
199
  writeFileSync(p.settingsPath, JSON.stringify(merged, null, 2) + "\n");
200
+ clearPolicyCache();
182
201
  if (process.env["SOLONGATE_OS_LOCK"] === "1") lockProtected();
183
- return { ok: true, message: "guard installed (open a new session)" };
202
+ return { ok: true, message: "guard installed + policy refreshed (open a new session)" };
184
203
  } catch (e) {
185
204
  return { ok: false, message: e instanceof Error ? e.message : String(e) };
186
205
  }
@@ -366,6 +385,7 @@ async function installGlobalWithKey(apiKey, apiUrl) {
366
385
  }
367
386
  export {
368
387
  clearGuardUpdateCheck,
388
+ clearPolicyCache,
369
389
  globalPaths,
370
390
  guardHookOutdated,
371
391
  installClaudeShim,
package/dist/index.js CHANGED
@@ -10085,7 +10085,7 @@ var init_Audit = __esm({
10085
10085
  });
10086
10086
 
10087
10087
  // src/global-install.ts
10088
- import { readFileSync as readFileSync9, writeFileSync as writeFileSync9, existsSync as existsSync4, mkdirSync as mkdirSync8, rmSync as rmSync2 } from "fs";
10088
+ import { readFileSync as readFileSync9, writeFileSync as writeFileSync9, existsSync as existsSync4, mkdirSync as mkdirSync8, rmSync as rmSync2, readdirSync } from "fs";
10089
10089
  import { resolve as resolve4, join as join11, dirname as dirname3 } from "path";
10090
10090
  import { homedir as homedir9 } from "os";
10091
10091
  import { fileURLToPath as fileURLToPath3 } from "url";
@@ -10186,6 +10186,24 @@ function readGuard() {
10186
10186
  const bundled = join11(HOOKS_DIR, "guard.bundled.mjs");
10187
10187
  return existsSync4(bundled) ? readFileSync9(bundled, "utf-8") : readHook("guard.mjs");
10188
10188
  }
10189
+ function clearPolicyCache() {
10190
+ try {
10191
+ const dir = globalPaths().sgDir;
10192
+ let n = 0;
10193
+ for (const f of readdirSync(dir)) {
10194
+ if (f.startsWith(".policy-cache-") && f.endsWith(".json")) {
10195
+ try {
10196
+ rmSync2(join11(dir, f), { force: true });
10197
+ n++;
10198
+ } catch {
10199
+ }
10200
+ }
10201
+ }
10202
+ return n;
10203
+ } catch {
10204
+ return 0;
10205
+ }
10206
+ }
10189
10207
  function installGlobalQuiet() {
10190
10208
  try {
10191
10209
  const p = globalPaths();
@@ -10228,8 +10246,9 @@ function installGlobalQuiet() {
10228
10246
  }
10229
10247
  };
10230
10248
  writeFileSync9(p.settingsPath, JSON.stringify(merged, null, 2) + "\n");
10249
+ clearPolicyCache();
10231
10250
  if (process.env["SOLONGATE_OS_LOCK"] === "1") lockProtected();
10232
- return { ok: true, message: "guard installed (open a new session)" };
10251
+ return { ok: true, message: "guard installed + policy refreshed (open a new session)" };
10233
10252
  } catch (e) {
10234
10253
  return { ok: false, message: e instanceof Error ? e.message : String(e) };
10235
10254
  }
@@ -12350,7 +12369,7 @@ import { createServer, request as httpRequest } from "http";
12350
12369
  import { request as httpsRequest } from "https";
12351
12370
  import { spawn as spawn5 } from "child_process";
12352
12371
  import { URL as URL2 } from "url";
12353
- import { readFileSync as readFileSync11, existsSync as existsSync7, readdirSync, statSync as statSync4 } from "fs";
12372
+ import { readFileSync as readFileSync11, existsSync as existsSync7, readdirSync as readdirSync2, statSync as statSync4 } from "fs";
12354
12373
  import { resolve as resolve5 } from "path";
12355
12374
  import { homedir as homedir13 } from "os";
12356
12375
  function findCacheFile() {
@@ -12362,7 +12381,7 @@ function findCacheFile() {
12362
12381
  }
12363
12382
  let best = null, bestTs = -1;
12364
12383
  try {
12365
- for (const name of readdirSync(dir)) {
12384
+ for (const name of readdirSync2(dir)) {
12366
12385
  if (name.startsWith(".policy-cache-") && name.endsWith(".json")) {
12367
12386
  const full = resolve5(dir, name);
12368
12387
  const ts = statSync4(full).mtimeMs;
@@ -12672,7 +12691,7 @@ import { createServer as createServer2 } from "http";
12672
12691
  import { readFileSync as readFileSync12, statSync as statSync5 } from "fs";
12673
12692
  import { resolve as resolve6, join as join15, isAbsolute } from "path";
12674
12693
  import { homedir as homedir14 } from "os";
12675
- import { readdirSync as readdirSync2 } from "fs";
12694
+ import { readdirSync as readdirSync3 } from "fs";
12676
12695
  function allowedOrigins() {
12677
12696
  const base = [
12678
12697
  "https://dashboard.solongate.com",
@@ -12693,7 +12712,7 @@ function resolveLocalLogDir(rawPath) {
12693
12712
  async function findLogDir() {
12694
12713
  const base = resolve6(homedir14(), ".solongate");
12695
12714
  try {
12696
- const files = readdirSync2(base).filter((f) => f.startsWith(".policy-cache-") && f.endsWith(".json"));
12715
+ const files = readdirSync3(base).filter((f) => f.startsWith(".policy-cache-") && f.endsWith(".json"));
12697
12716
  for (const f of files) {
12698
12717
  try {
12699
12718
  const c2 = JSON.parse(readFileSync12(join15(base, f), "utf-8"));
package/dist/login.js CHANGED
@@ -26,7 +26,7 @@ var c = {
26
26
  var BANNER_COLORS = [c.blue1, c.blue2, c.blue3, c.blue4, c.blue5, c.blue6];
27
27
 
28
28
  // src/global-install.ts
29
- import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } from "fs";
29
+ import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync, readdirSync } from "fs";
30
30
  import { resolve, join, dirname } from "path";
31
31
  import { homedir } from "os";
32
32
  import { fileURLToPath } from "url";
package/dist/tui/index.js CHANGED
@@ -3140,7 +3140,7 @@ import TextInput5 from "ink-text-input";
3140
3140
  import { useEffect as useEffect6, useRef as useRef3, useState as useState7 } from "react";
3141
3141
 
3142
3142
  // src/global-install.ts
3143
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync5, existsSync as existsSync2, mkdirSync as mkdirSync4, rmSync } from "fs";
3143
+ import { readFileSync as readFileSync4, writeFileSync as writeFileSync5, existsSync as existsSync2, mkdirSync as mkdirSync4, rmSync, readdirSync } from "fs";
3144
3144
  import { resolve as resolve2, join as join6, dirname } from "path";
3145
3145
  import { homedir as homedir6 } from "os";
3146
3146
  import { fileURLToPath } from "url";
@@ -3243,6 +3243,24 @@ function readGuard() {
3243
3243
  const bundled = join6(HOOKS_DIR, "guard.bundled.mjs");
3244
3244
  return existsSync2(bundled) ? readFileSync4(bundled, "utf-8") : readHook("guard.mjs");
3245
3245
  }
3246
+ function clearPolicyCache() {
3247
+ try {
3248
+ const dir = globalPaths().sgDir;
3249
+ let n = 0;
3250
+ for (const f of readdirSync(dir)) {
3251
+ if (f.startsWith(".policy-cache-") && f.endsWith(".json")) {
3252
+ try {
3253
+ rmSync(join6(dir, f), { force: true });
3254
+ n++;
3255
+ } catch {
3256
+ }
3257
+ }
3258
+ }
3259
+ return n;
3260
+ } catch {
3261
+ return 0;
3262
+ }
3263
+ }
3246
3264
  function installGlobalQuiet() {
3247
3265
  try {
3248
3266
  const p = globalPaths();
@@ -3285,8 +3303,9 @@ function installGlobalQuiet() {
3285
3303
  }
3286
3304
  };
3287
3305
  writeFileSync5(p.settingsPath, JSON.stringify(merged, null, 2) + "\n");
3306
+ clearPolicyCache();
3288
3307
  if (process.env["SOLONGATE_OS_LOCK"] === "1") lockProtected();
3289
- return { ok: true, message: "guard installed (open a new session)" };
3308
+ return { ok: true, message: "guard installed + policy refreshed (open a new session)" };
3290
3309
  } catch (e) {
3291
3310
  return { ok: false, message: e instanceof Error ? e.message : String(e) };
3292
3311
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.81.82",
3
+ "version": "0.81.83",
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": {