jevgate 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/jevgate.js +12 -4
  2. package/package.json +2 -2
package/jevgate.js CHANGED
@@ -16,10 +16,16 @@ const LOG = path.join(DIR, "decisions.jsonl");
16
16
  const endpoint = () => process.env.JEVGATE_ENDPOINT || config().endpoint || "https://jevgate.dev";
17
17
  const TIMEOUT_MS = Number(process.env.JEVGATE_TIMEOUT_MS || 2500);
18
18
  // The hook runs on every permission request, so it must not pay npx's resolver
19
- // each time. Write the absolute path of this very script: it is stable whether
20
- // we were installed globally (npm i -g jevgate) or are running from npx's cache.
19
+ // each time, and it must not point into npx's cache (pruned by `npm cache clean`,
20
+ // re-hashed on the next version). `init` copies this script to a stable home and
21
+ // points the hooks there; re-running init after an upgrade refreshes the copy.
21
22
  const SELF = new URL(import.meta.url).pathname;
22
- const HOOK_CMD = `node "${SELF}" decide`;
23
+ const BIN = path.join(DIR, "bin", "jevgate.js");
24
+ const HOOK_CMD = `node "${BIN}" decide`;
25
+ function installStableCopy() {
26
+ fs.mkdirSync(path.dirname(BIN), { recursive: true });
27
+ if (path.resolve(SELF) !== path.resolve(BIN)) fs.copyFileSync(SELF, BIN);
28
+ }
23
29
 
24
30
  const readJson = (p, fallback) => { try { return JSON.parse(fs.readFileSync(p, "utf8")); } catch { return fallback; } };
25
31
  const writeJson = (p, v) => { fs.mkdirSync(path.dirname(p), { recursive: true }); fs.writeFileSync(p, JSON.stringify(v, null, 2) + "\n"); };
@@ -57,7 +63,7 @@ async function decide() {
57
63
  if (!res.ok) { appendLog({ ...meta(event, started), outcome: "error", status: res.status }); return; }
58
64
  result = await res.json();
59
65
  } catch (err) {
60
- appendLog({ ...meta(event, started), outcome: "error", error: String(err?.name || err) });
66
+ appendLog({ ...meta(event, started), outcome: "error", error: String(err?.cause?.code || err?.name || err) });
61
67
  return; // any failure → harness proceeds as usual
62
68
  } finally { clearTimeout(timer); }
63
69
 
@@ -128,6 +134,8 @@ function codexTask(sessionId) {
128
134
  // ---------------------------------------------------------------- init
129
135
  function init() {
130
136
  const results = [];
137
+ installStableCopy();
138
+ results.push(`installed ${BIN}`);
131
139
  // Claude Code: PermissionRequest fires exactly when a permission prompt would
132
140
  // appear. Allowing there skips the prompt; saying nothing shows it as usual.
133
141
  const claude = path.join(HOME, ".claude", "settings.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jevgate",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Auto-approve the benign majority of agent tool calls in ~300ms, with a probability and an audit log. Escalates the rest. Never denies.",
5
5
  "keywords": [
6
6
  "codex",
@@ -17,7 +17,7 @@
17
17
  "license": "MIT",
18
18
  "type": "module",
19
19
  "bin": {
20
- "jevgate": "./jevgate.js"
20
+ "jevgate": "jevgate.js"
21
21
  },
22
22
  "files": [
23
23
  "jevgate.js",