@solongate/proxy 0.82.96 → 0.82.97

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/index.js CHANGED
@@ -11407,7 +11407,26 @@ var init_doctor = __esm({
11407
11407
  import { Box as Box8, Text as Text8, useInput as useInput7 } from "ink";
11408
11408
  import TextInput6 from "ink-text-input";
11409
11409
  import { useEffect as useEffect7, useRef as useRef3, useState as useState8 } from "react";
11410
+ import { readFileSync as readFileSync11, readdirSync as readdirSync2 } from "fs";
11411
+ import { homedir as homedir11 } from "os";
11412
+ import { join as join13 } from "path";
11410
11413
  import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
11414
+ function guestAllowance() {
11415
+ try {
11416
+ const dir = join13(homedir11(), ".solongate");
11417
+ for (const f of readdirSync2(dir)) {
11418
+ if (!f.startsWith(".policy-cache-") || !f.endsWith(".json")) continue;
11419
+ try {
11420
+ const c2 = JSON.parse(readFileSync11(join13(dir, f), "utf-8"));
11421
+ const q = c2?.security?.guestQuota;
11422
+ if (q && typeof q.limit === "number") return { used: q.used ?? 0, limit: q.limit };
11423
+ } catch {
11424
+ }
11425
+ }
11426
+ } catch {
11427
+ }
11428
+ return null;
11429
+ }
11411
11430
  function SettingsPanel({
11412
11431
  active: active2,
11413
11432
  focused,
@@ -11443,6 +11462,7 @@ function SettingsPanel({
11443
11462
  const step = setInterval(() => setDiagStep((s) => Math.min(s + 1, total - 1)), 220);
11444
11463
  return () => clearInterval(step);
11445
11464
  }, [diagBusy]);
11465
+ const allowance = guestAllowance();
11446
11466
  const ver = currentVersion();
11447
11467
  useEffect7(() => {
11448
11468
  let live2 = true;
@@ -11514,6 +11534,7 @@ function SettingsPanel({
11514
11534
  const rowsAll = [
11515
11535
  ...accounts.map((acc) => ({ kind: "acct", acc })),
11516
11536
  { kind: "acct-add" },
11537
+ ...allowance ? [{ kind: "allowance", used: allowance.used, limit: allowance.limit }] : [],
11517
11538
  ...locked ? [] : [
11518
11539
  { kind: "guard" },
11519
11540
  { kind: "self" },
@@ -11965,6 +11986,15 @@ function SettingsPanel({
11965
11986
  cursor(r),
11966
11987
  /* @__PURE__ */ jsx8(Text8, { color: theme.dim, children: "+ add account (enter \u2014 device login in the browser)" })
11967
11988
  ] });
11989
+ case "allowance": {
11990
+ const left = Math.max(0, r.limit - r.used);
11991
+ return /* @__PURE__ */ jsxs8(Text8, { wrap: "truncate", children: [
11992
+ cursor(r),
11993
+ /* @__PURE__ */ jsx8(Text8, { color: theme.dim, children: "allowance".padEnd(11) }),
11994
+ /* @__PURE__ */ jsx8(Text8, { color: left === 0 ? theme.bad : left <= 20 ? theme.warn : theme.ok, bold: true, children: `${r.used}/${r.limit} tool calls` }),
11995
+ /* @__PURE__ */ jsx8(Text8, { color: theme.dim, children: left === 0 ? " used up \u2014 every call is denied \xB7 create an account to carry on" : ` ${left} left on this guest account \xB7 create an account for no limit` })
11996
+ ] });
11997
+ }
11968
11998
  case "guard":
11969
11999
  return /* @__PURE__ */ jsxs8(Text8, { wrap: "truncate", children: [
11970
12000
  cursor(r),
@@ -12051,7 +12081,7 @@ function SettingsPanel({
12051
12081
  ] });
12052
12082
  }
12053
12083
  };
12054
- const sectionOf = (r) => r.kind === "acct" || r.kind === "acct-add" ? "ACCOUNTS" : r.kind === "guard" || r.kind === "self" || r.kind === "doctor" || r.kind === "repair" ? "PROTECTION" : r.kind === "ll-enabled" || r.kind === "ll-path" || r.kind === "ll-server" ? "LOCAL LOGS" : r.kind === "wh" || r.kind === "wh-add" ? "WEBHOOKS" : "ALERTS";
12084
+ const sectionOf = (r) => r.kind === "acct" || r.kind === "acct-add" || r.kind === "allowance" ? "ACCOUNTS" : r.kind === "guard" || r.kind === "self" || r.kind === "doctor" || r.kind === "repair" ? "PROTECTION" : r.kind === "ll-enabled" || r.kind === "ll-path" || r.kind === "ll-server" ? "LOCAL LOGS" : r.kind === "wh" || r.kind === "wh-add" ? "WEBHOOKS" : "ALERTS";
12055
12085
  const SECTION_DESC = {
12056
12086
  ACCOUNTS: `on this device (${accounts.length}) \xB7 \u25CF viewing \xB7 ACTIVE = guard key \xB7 x removes`,
12057
12087
  PROTECTION: "guard hook: enter install/update \xB7 d remove \xB7 self-protection \xB7 doctor + repair",
@@ -12409,8 +12439,8 @@ __export(tui_exports, {
12409
12439
  launchTui: () => launchTui
12410
12440
  });
12411
12441
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync9 } from "fs";
12412
- import { homedir as homedir11 } from "os";
12413
- import { join as join13 } from "path";
12442
+ import { homedir as homedir12 } from "os";
12443
+ import { join as join14 } from "path";
12414
12444
  import { render } from "ink";
12415
12445
  import { jsx as jsx10 } from "react/jsx-runtime";
12416
12446
  async function launchTui() {
@@ -12421,11 +12451,11 @@ async function launchTui() {
12421
12451
  return;
12422
12452
  }
12423
12453
  process.stdout.write("\x1B[?1049h\x1B[H");
12424
- const debugLog = join13(homedir11(), ".solongate", "dataroom-debug.log");
12454
+ const debugLog = join14(homedir12(), ".solongate", "dataroom-debug.log");
12425
12455
  const saved = { log: console.log, warn: console.warn, error: console.error, info: console.info, debug: console.debug };
12426
12456
  const toFile = (level) => (...args) => {
12427
12457
  try {
12428
- mkdirSync9(join13(homedir11(), ".solongate"), { recursive: true });
12458
+ mkdirSync9(join14(homedir12(), ".solongate"), { recursive: true });
12429
12459
  appendFileSync2(debugLog, `${(/* @__PURE__ */ new Date()).toISOString()} [${level}] ${args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ")}
12430
12460
  `);
12431
12461
  } catch {
@@ -12452,7 +12482,7 @@ var init_tui = __esm({
12452
12482
  });
12453
12483
 
12454
12484
  // src/commands/policy.ts
12455
- import { readFileSync as readFileSync11 } from "fs";
12485
+ import { readFileSync as readFileSync12 } from "fs";
12456
12486
  async function run2(argv) {
12457
12487
  const { positionals, flags } = parse(argv);
12458
12488
  const sub = positionals[0];
@@ -12609,7 +12639,7 @@ function printRules(rules) {
12609
12639
  }
12610
12640
  async function resolveRules(target) {
12611
12641
  if (target.endsWith(".json")) {
12612
- const parsed = JSON.parse(readFileSync11(target, "utf-8"));
12642
+ const parsed = JSON.parse(readFileSync12(target, "utf-8"));
12613
12643
  return parsed.rules ?? [];
12614
12644
  }
12615
12645
  const p = await api.policies.get(target);
@@ -13323,10 +13353,10 @@ __export(logs_server_exports, {
13323
13353
  runLogsServer: () => runLogsServer
13324
13354
  });
13325
13355
  import { createServer } from "http";
13326
- import { readFileSync as readFileSync12, statSync as statSync4 } from "fs";
13327
- import { resolve as resolve5, join as join14, isAbsolute as isAbsolute2 } from "path";
13328
- import { homedir as homedir12 } from "os";
13329
- import { readdirSync as readdirSync2 } from "fs";
13356
+ import { readFileSync as readFileSync13, statSync as statSync4 } from "fs";
13357
+ import { resolve as resolve5, join as join15, isAbsolute as isAbsolute2 } from "path";
13358
+ import { homedir as homedir13 } from "os";
13359
+ import { readdirSync as readdirSync3 } from "fs";
13330
13360
  function allowedOrigins() {
13331
13361
  const base = [
13332
13362
  "https://dashboard.solongate.com",
@@ -13342,15 +13372,15 @@ function resolveLocalLogDir(rawPath) {
13342
13372
  const dir = String(rawPath || "").trim().replace(/[\\/]+$/, "");
13343
13373
  if (!dir) return null;
13344
13374
  if (isAbsolute2(dir)) return dir;
13345
- return resolve5(homedir12(), ".solongate", "local-logs");
13375
+ return resolve5(homedir13(), ".solongate", "local-logs");
13346
13376
  }
13347
13377
  async function findLogDir() {
13348
- const base = resolve5(homedir12(), ".solongate");
13378
+ const base = resolve5(homedir13(), ".solongate");
13349
13379
  try {
13350
- const files = readdirSync2(base).filter((f) => f.startsWith(".policy-cache-") && f.endsWith(".json"));
13380
+ const files = readdirSync3(base).filter((f) => f.startsWith(".policy-cache-") && f.endsWith(".json"));
13351
13381
  for (const f of files) {
13352
13382
  try {
13353
- const c2 = JSON.parse(readFileSync12(join14(base, f), "utf-8"));
13383
+ const c2 = JSON.parse(readFileSync13(join15(base, f), "utf-8"));
13354
13384
  const p = c2?.security?.localLogs?.path;
13355
13385
  if (typeof p === "string" && p.trim()) return { dir: resolveLocalLogDir(p), configured: p };
13356
13386
  } catch {
@@ -13359,7 +13389,7 @@ async function findLogDir() {
13359
13389
  } catch {
13360
13390
  }
13361
13391
  try {
13362
- const cfgRaw = readFileSync12(join14(base, "cloud-guard.json"), "utf-8");
13392
+ const cfgRaw = readFileSync13(join15(base, "cloud-guard.json"), "utf-8");
13363
13393
  const { apiKey, apiUrl } = JSON.parse(cfgRaw);
13364
13394
  if (apiKey) {
13365
13395
  const url = `${apiUrl || "https://api.solongate.com"}/api/v1/policies/active`;
@@ -13388,7 +13418,7 @@ function setCors(req, res) {
13388
13418
  }
13389
13419
  function fileInfo(dir) {
13390
13420
  if (!dir) return { file: null, exists: false, size: 0, mtimeMs: 0 };
13391
- const file = join14(dir, LOG_FILENAME);
13421
+ const file = join15(dir, LOG_FILENAME);
13392
13422
  try {
13393
13423
  const st = statSync4(file);
13394
13424
  return { file, exists: true, size: st.size, mtimeMs: st.mtimeMs };
@@ -13471,7 +13501,7 @@ async function runLogsServer() {
13471
13501
  return;
13472
13502
  }
13473
13503
  try {
13474
- const text = readFileSync12(info.file, "utf-8");
13504
+ const text = readFileSync13(info.file, "utf-8");
13475
13505
  res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8", "Last-Modified": lastMod, "X-Solongate-Exists": "1" });
13476
13506
  res.end(text);
13477
13507
  } catch {
@@ -13524,9 +13554,9 @@ var init_logs_server = __esm({
13524
13554
  });
13525
13555
 
13526
13556
  // src/index.ts
13527
- import { readFileSync as readFileSync13 } from "fs";
13557
+ import { readFileSync as readFileSync14 } from "fs";
13528
13558
  import { fileURLToPath as fileURLToPath4 } from "url";
13529
- import { dirname as dirname4, join as join15 } from "path";
13559
+ import { dirname as dirname4, join as join16 } from "path";
13530
13560
 
13531
13561
  // src/config.ts
13532
13562
  import { readFileSync, existsSync } from "fs";
@@ -16921,8 +16951,8 @@ if (!IS_HUMAN_CLI) {
16921
16951
  }
16922
16952
  var PKG_VERSION = (() => {
16923
16953
  try {
16924
- const p = join15(dirname4(fileURLToPath4(import.meta.url)), "..", "package.json");
16925
- return JSON.parse(readFileSync13(p, "utf-8")).version || "unknown";
16954
+ const p = join16(dirname4(fileURLToPath4(import.meta.url)), "..", "package.json");
16955
+ return JSON.parse(readFileSync14(p, "utf-8")).version || "unknown";
16926
16956
  } catch {
16927
16957
  return "unknown";
16928
16958
  }
package/dist/tui/index.js CHANGED
@@ -530,8 +530,8 @@ var init_global_install = __esm({
530
530
 
531
531
  // src/tui/index.tsx
532
532
  import { appendFileSync, mkdirSync as mkdirSync7 } from "fs";
533
- import { homedir as homedir10 } from "os";
534
- import { join as join10 } from "path";
533
+ import { homedir as homedir11 } from "os";
534
+ import { join as join11 } from "path";
535
535
  import { render } from "ink";
536
536
 
537
537
  // src/tui/App.tsx
@@ -4587,7 +4587,26 @@ async function tuiUpdateFlow(onStatus) {
4587
4587
  }
4588
4588
 
4589
4589
  // src/tui/panels/Settings.tsx
4590
+ import { readFileSync as readFileSync8, readdirSync as readdirSync2 } from "fs";
4591
+ import { homedir as homedir10 } from "os";
4592
+ import { join as join10 } from "path";
4590
4593
  import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
4594
+ function guestAllowance() {
4595
+ try {
4596
+ const dir = join10(homedir10(), ".solongate");
4597
+ for (const f of readdirSync2(dir)) {
4598
+ if (!f.startsWith(".policy-cache-") || !f.endsWith(".json")) continue;
4599
+ try {
4600
+ const c2 = JSON.parse(readFileSync8(join10(dir, f), "utf-8"));
4601
+ const q = c2?.security?.guestQuota;
4602
+ if (q && typeof q.limit === "number") return { used: q.used ?? 0, limit: q.limit };
4603
+ } catch {
4604
+ }
4605
+ }
4606
+ } catch {
4607
+ }
4608
+ return null;
4609
+ }
4591
4610
  var EVENTS = ["denials", "allowed", "all"];
4592
4611
  var SPIN2 = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
4593
4612
  var SIGNALS2 = ["any", "deny", "dlp", "ratelimit"];
@@ -4639,6 +4658,7 @@ function SettingsPanel({
4639
4658
  const step = setInterval(() => setDiagStep((s) => Math.min(s + 1, total - 1)), 220);
4640
4659
  return () => clearInterval(step);
4641
4660
  }, [diagBusy]);
4661
+ const allowance = guestAllowance();
4642
4662
  const ver = currentVersion();
4643
4663
  useEffect7(() => {
4644
4664
  let live2 = true;
@@ -4710,6 +4730,7 @@ function SettingsPanel({
4710
4730
  const rowsAll = [
4711
4731
  ...accounts.map((acc) => ({ kind: "acct", acc })),
4712
4732
  { kind: "acct-add" },
4733
+ ...allowance ? [{ kind: "allowance", used: allowance.used, limit: allowance.limit }] : [],
4713
4734
  ...locked ? [] : [
4714
4735
  { kind: "guard" },
4715
4736
  { kind: "self" },
@@ -5161,6 +5182,15 @@ function SettingsPanel({
5161
5182
  cursor(r),
5162
5183
  /* @__PURE__ */ jsx8(Text8, { color: theme.dim, children: "+ add account (enter \u2014 device login in the browser)" })
5163
5184
  ] });
5185
+ case "allowance": {
5186
+ const left = Math.max(0, r.limit - r.used);
5187
+ return /* @__PURE__ */ jsxs8(Text8, { wrap: "truncate", children: [
5188
+ cursor(r),
5189
+ /* @__PURE__ */ jsx8(Text8, { color: theme.dim, children: "allowance".padEnd(11) }),
5190
+ /* @__PURE__ */ jsx8(Text8, { color: left === 0 ? theme.bad : left <= 20 ? theme.warn : theme.ok, bold: true, children: `${r.used}/${r.limit} tool calls` }),
5191
+ /* @__PURE__ */ jsx8(Text8, { color: theme.dim, children: left === 0 ? " used up \u2014 every call is denied \xB7 create an account to carry on" : ` ${left} left on this guest account \xB7 create an account for no limit` })
5192
+ ] });
5193
+ }
5164
5194
  case "guard":
5165
5195
  return /* @__PURE__ */ jsxs8(Text8, { wrap: "truncate", children: [
5166
5196
  cursor(r),
@@ -5247,7 +5277,7 @@ function SettingsPanel({
5247
5277
  ] });
5248
5278
  }
5249
5279
  };
5250
- const sectionOf = (r) => r.kind === "acct" || r.kind === "acct-add" ? "ACCOUNTS" : r.kind === "guard" || r.kind === "self" || r.kind === "doctor" || r.kind === "repair" ? "PROTECTION" : r.kind === "ll-enabled" || r.kind === "ll-path" || r.kind === "ll-server" ? "LOCAL LOGS" : r.kind === "wh" || r.kind === "wh-add" ? "WEBHOOKS" : "ALERTS";
5280
+ const sectionOf = (r) => r.kind === "acct" || r.kind === "acct-add" || r.kind === "allowance" ? "ACCOUNTS" : r.kind === "guard" || r.kind === "self" || r.kind === "doctor" || r.kind === "repair" ? "PROTECTION" : r.kind === "ll-enabled" || r.kind === "ll-path" || r.kind === "ll-server" ? "LOCAL LOGS" : r.kind === "wh" || r.kind === "wh-add" ? "WEBHOOKS" : "ALERTS";
5251
5281
  const SECTION_DESC = {
5252
5282
  ACCOUNTS: `on this device (${accounts.length}) \xB7 \u25CF viewing \xB7 ACTIVE = guard key \xB7 x removes`,
5253
5283
  PROTECTION: "guard hook: enter install/update \xB7 d remove \xB7 self-protection \xB7 doctor + repair",
@@ -5552,11 +5582,11 @@ async function launchTui() {
5552
5582
  return;
5553
5583
  }
5554
5584
  process.stdout.write("\x1B[?1049h\x1B[H");
5555
- const debugLog = join10(homedir10(), ".solongate", "dataroom-debug.log");
5585
+ const debugLog = join11(homedir11(), ".solongate", "dataroom-debug.log");
5556
5586
  const saved = { log: console.log, warn: console.warn, error: console.error, info: console.info, debug: console.debug };
5557
5587
  const toFile = (level) => (...args) => {
5558
5588
  try {
5559
- mkdirSync7(join10(homedir10(), ".solongate"), { recursive: true });
5589
+ mkdirSync7(join11(homedir11(), ".solongate"), { recursive: true });
5560
5590
  appendFileSync(debugLog, `${(/* @__PURE__ */ new Date()).toISOString()} [${level}] ${args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ")}
5561
5591
  `);
5562
5592
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.82.96",
3
+ "version": "0.82.97",
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": {