jevgate 0.1.2 → 0.2.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/LICENSE +21 -0
- package/jevgate.js +49 -9
- package/package.json +6 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 remotehost
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/jevgate.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// jevgate — one binary, zero dependencies.
|
|
3
3
|
// jevgate init write the hooks into Claude Code and codex
|
|
4
|
-
// jevgate login
|
|
4
|
+
// jevgate login sign in from the browser (no token to paste)
|
|
5
5
|
// jevgate decide (called by the harness) stdin JSON → decision JSON or nothing
|
|
6
6
|
// jevgate status endpoint, token, usage
|
|
7
7
|
// jevgate log last decisions
|
|
8
8
|
import fs from "node:fs";
|
|
9
9
|
import os from "node:os";
|
|
10
10
|
import path from "node:path";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
11
13
|
|
|
12
14
|
const HOME = os.homedir();
|
|
13
15
|
const DIR = path.join(HOME, ".jevgate");
|
|
@@ -157,7 +159,8 @@ function init() {
|
|
|
157
159
|
if (added) results.push("codex: open codex once and accept the jevgate hook when it asks (it verifies new hooks)");
|
|
158
160
|
} else results.push("codex: not found (~/.codex)");
|
|
159
161
|
for (const r of results) console.log(" " + r);
|
|
160
|
-
if (!config().token)
|
|
162
|
+
if (!config().token) return login();
|
|
163
|
+
console.log(` signed in as ${config().email || "(token on file)"}`);
|
|
161
164
|
}
|
|
162
165
|
const isOurs = (h) => /jevgate(\.js)?"? decide\b/.test(h?.command || "");
|
|
163
166
|
// Idempotent: one jevgate group per event, always pointing at this script.
|
|
@@ -172,10 +175,47 @@ function addHook(hooks, eventName, matcher, timeout) {
|
|
|
172
175
|
}
|
|
173
176
|
|
|
174
177
|
// ---------------------------------------------------------------- misc
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
// Sign in from the browser. The CLI asks the server for a device code, opens the
|
|
179
|
+
// login page, and polls until the emailed link is clicked. The token never passes
|
|
180
|
+
// through a human. `jevgate login --token <t>` remains for automation.
|
|
181
|
+
async function login(arg, arg2) {
|
|
182
|
+
if (arg === "--token" && arg2) {
|
|
183
|
+
writeJson(CONFIG, { ...config(), token: arg2, endpoint: endpoint() });
|
|
184
|
+
console.log(" token saved to ~/.jevgate/config.json");
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const base = endpoint();
|
|
188
|
+
let start;
|
|
189
|
+
try {
|
|
190
|
+
const r = await fetch(`${base}/api/v1/device/start`, { method: "POST" });
|
|
191
|
+
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
|
192
|
+
start = await r.json();
|
|
193
|
+
} catch (e) { console.error(` could not reach ${base}: ${e.message}`); process.exit(1); }
|
|
194
|
+
console.log(`\n Confirm this device in your browser: ${start.url}`);
|
|
195
|
+
console.log(` Code: ${start.code} (opening the page for you)\n`);
|
|
196
|
+
openBrowser(start.url);
|
|
197
|
+
const deadline = Date.now() + (start.expires_in || 900) * 1000;
|
|
198
|
+
let shownEmail = false;
|
|
199
|
+
while (Date.now() < deadline) {
|
|
200
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
201
|
+
let st;
|
|
202
|
+
try { st = await (await fetch(`${base}/api/v1/device/poll?code=${encodeURIComponent(start.code)}&poll=${encodeURIComponent(start.poll)}`)).json(); }
|
|
203
|
+
catch { continue; }
|
|
204
|
+
if (st.status === "emailed" && !shownEmail) { console.log(` Sign-in link sent to ${st.email}. Waiting for the click…`); shownEmail = true; }
|
|
205
|
+
if (st.status === "done" && st.token) {
|
|
206
|
+
writeJson(CONFIG, { ...config(), token: st.token, email: st.email, endpoint: base });
|
|
207
|
+
console.log(` Signed in as ${st.email} (${st.plan}). Token saved to ~/.jevgate/config.json`);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (st.status === "expired" || st.status === "forbidden") { console.error(" login expired. Run `jevgate login` again."); process.exit(1); }
|
|
211
|
+
}
|
|
212
|
+
console.error(" login timed out. Run `jevgate login` again."); process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
function openBrowser(url) {
|
|
215
|
+
const { spawn } = require("node:child_process");
|
|
216
|
+
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
217
|
+
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
218
|
+
try { spawn(cmd, args, { stdio: "ignore", detached: true }).unref(); } catch {}
|
|
179
219
|
}
|
|
180
220
|
async function status() {
|
|
181
221
|
const cfg = config();
|
|
@@ -199,6 +239,6 @@ function log(n = 20) {
|
|
|
199
239
|
// Piped output (jevgate log | head) must not crash the process.
|
|
200
240
|
process.stdout.on("error", (e) => { if (e.code === "EPIPE") process.exit(0); });
|
|
201
241
|
|
|
202
|
-
const [cmd, arg] = process.argv.slice(2);
|
|
203
|
-
({ decide, init, login: () => login(arg), status, log: () => log(Number(arg) || 20) }[cmd] ||
|
|
204
|
-
(() => console.log("usage: jevgate <init|login
|
|
242
|
+
const [cmd, arg, arg2] = process.argv.slice(2);
|
|
243
|
+
({ decide, init, login: () => login(arg, arg2), status, log: () => log(Number(arg) || 20) }[cmd] ||
|
|
244
|
+
(() => console.log("usage: jevgate <init|login|decide|status|log>")))();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jevgate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
|
@@ -21,12 +21,16 @@
|
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"jevgate.js",
|
|
24
|
-
"README.md"
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
25
26
|
],
|
|
26
27
|
"engines": {
|
|
27
28
|
"node": ">=18"
|
|
28
29
|
},
|
|
29
30
|
"publishConfig": {
|
|
30
31
|
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://jevgate.dev"
|
|
31
35
|
}
|
|
32
36
|
}
|