auto-mode 2.0.2 → 3.0.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.
@@ -1,5 +1,5 @@
1
1
  import { d as string, s as number, u as strictObject } from "./schemas-B_w83Dze.js";
2
- import { t as startJudgeSession } from "./start-judge-session-DX3Oek85.js";
2
+ import { t as startJudgeSession } from "./start-judge-session-vxiG-kDp.js";
3
3
  import { randomBytes } from "node:crypto";
4
4
  import { chmod, mkdir, rename, rm, stat } from "node:fs/promises";
5
5
  import { dirname, join } from "node:path";
@@ -68,20 +68,6 @@ async function startJudgeServer(options) {
68
68
  stop
69
69
  };
70
70
  }
71
- async function removeOwnSocket(socketPath, ino, onRemoved) {
72
- const current = await stat(socketPath).catch(() => null);
73
- if (ino !== null && current?.ino === ino) await rm(socketPath, { force: true });
74
- onRemoved();
75
- }
76
- function startListening(server, socketPath) {
77
- return new Promise((resolve, reject) => {
78
- server.once("error", reject);
79
- server.listen(socketPath, () => {
80
- server.off("error", reject);
81
- resolve();
82
- });
83
- });
84
- }
85
71
  function isAnswering(socketPath) {
86
72
  return new Promise((resolve) => {
87
73
  const probe = connect(socketPath);
@@ -94,6 +80,11 @@ function isAnswering(socketPath) {
94
80
  });
95
81
  });
96
82
  }
83
+ async function removeOwnSocket(socketPath, ino, onRemoved) {
84
+ const current = await stat(socketPath).catch(() => null);
85
+ if (ino !== null && current?.ino === ino) await rm(socketPath, { force: true });
86
+ onRemoved();
87
+ }
97
88
  const MAX_REQUEST_BYTES = 4194304;
98
89
  async function runReview(socket, session) {
99
90
  const controller = new AbortController();
@@ -155,9 +146,6 @@ function readLine(socket, maxBytes) {
155
146
  socket.once("close", stopReading);
156
147
  });
157
148
  }
158
- function writeResponse(socket, response) {
159
- if (!socket.destroyed) socket.end(`${JSON.stringify(response)}\n`);
160
- }
161
149
  function parseJSON(text) {
162
150
  try {
163
151
  return JSON.parse(text);
@@ -165,5 +153,17 @@ function parseJSON(text) {
165
153
  return null;
166
154
  }
167
155
  }
156
+ function writeResponse(socket, response) {
157
+ if (!socket.destroyed) socket.end(`${JSON.stringify(response)}\n`);
158
+ }
159
+ function startListening(server, socketPath) {
160
+ return new Promise((resolve, reject) => {
161
+ server.once("error", reject);
162
+ server.listen(socketPath, () => {
163
+ server.off("error", reject);
164
+ resolve();
165
+ });
166
+ });
167
+ }
168
168
  //#endregion
169
169
  export { startJudgeServer };
@@ -0,0 +1 @@
1
+ export { t as startJudgeSession } from "./start-judge-session-vxiG-kDp.js";
@@ -37795,8 +37795,8 @@ function cWe(e, t) {
37795
37795
  }), ST(n, e, o, i), n;
37796
37796
  }
37797
37797
  //#endregion
37798
- //#region src/process/find-executable.ts
37799
- function findExecutable(name, path) {
37798
+ //#region src/process/resolve-executable.ts
37799
+ function resolveExecutable(name, path) {
37800
37800
  for (const directory of (path ?? "").split(delimiter)) {
37801
37801
  if (directory === "" || !isAbsolute(directory)) continue;
37802
37802
  const candidate = join(directory, name);
@@ -37897,37 +37897,10 @@ function startJudgeSession(env) {
37897
37897
  stop
37898
37898
  };
37899
37899
  }
37900
- function waitUnlessAborted(previous, signal) {
37901
- return new Promise((resolve, reject) => {
37902
- const onAbort = () => {
37903
- reject(new DOMException("Judge review aborted", "AbortError"));
37904
- };
37905
- if (signal.aborted) {
37906
- onAbort();
37907
- return;
37908
- }
37909
- signal.addEventListener("abort", onAbort, { once: true });
37910
- waitThenRelease(previous, () => {
37911
- signal.removeEventListener("abort", onAbort);
37912
- resolve();
37913
- });
37914
- });
37915
- }
37916
- async function waitThenRelease(previous, release) {
37917
- await previous;
37918
- release();
37919
- }
37920
- async function sendClear(send, stop) {
37921
- try {
37922
- await send("/clear");
37923
- } catch {
37924
- stop();
37925
- }
37926
- }
37927
37900
  const MAX_LINE_BYTES = 1048576;
37928
37901
  function startLiveProcess(model, system, key, env) {
37929
37902
  const input = makeInputChannel();
37930
- const executable = findExecutable("claude", env["PATH"]);
37903
+ const executable = resolveExecutable("claude", env["PATH"]);
37931
37904
  let waiter = null;
37932
37905
  let closed = false;
37933
37906
  if (executable === null) throw new Error("claude is not on the PATH");
@@ -38001,12 +37974,6 @@ function startLiveProcess(model, system, key, env) {
38001
37974
  })
38002
37975
  };
38003
37976
  }
38004
- async function readMessages(stream, onMessage, onEnd) {
38005
- try {
38006
- for await (const message of stream) onMessage(message);
38007
- } catch {}
38008
- onEnd();
38009
- }
38010
37977
  function makeInputChannel() {
38011
37978
  const pending = [];
38012
37979
  let wake = null;
@@ -38053,14 +38020,27 @@ async function* readPending(reader) {
38053
38020
  await reader.waitForPush();
38054
38021
  }
38055
38022
  }
38056
- function buildChildEnv(env) {
38057
- return Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith("ANTHROPIC_") && !PROVIDER_SWITCHES.has(name)));
38058
- }
38059
38023
  const PROVIDER_SWITCHES = /* @__PURE__ */ new Set([
38060
38024
  "CLAUDE_CODE_USE_BEDROCK",
38061
38025
  "CLAUDE_CODE_USE_VERTEX",
38062
38026
  "CLAUDE_CODE_USE_FOUNDRY"
38063
38027
  ]);
38028
+ function buildChildEnv(env) {
38029
+ return Object.fromEntries(Object.entries(env).filter(([name]) => !name.startsWith("ANTHROPIC_") && !PROVIDER_SWITCHES.has(name)));
38030
+ }
38031
+ async function readMessages(stream, onMessage, onEnd) {
38032
+ try {
38033
+ for await (const message of stream) onMessage(message);
38034
+ } catch {}
38035
+ onEnd();
38036
+ }
38037
+ async function sendClear(send, stop) {
38038
+ try {
38039
+ await send("/clear");
38040
+ } catch {
38041
+ stop();
38042
+ }
38043
+ }
38064
38044
  const MODEL_USAGE = record(string(), object({ outputTokens: number() }));
38065
38045
  const SAFETY_STOPS = object({ safety_stops: number() });
38066
38046
  function buildReply(result, fallbacks, requested, warm) {
@@ -38084,5 +38064,25 @@ function isFallbackReply(usage, stops) {
38084
38064
  const entries = Object.values(usage ?? {});
38085
38065
  return entries.some((entry) => entry.outputTokens === 0) && entries.some((entry) => entry.outputTokens > 0);
38086
38066
  }
38067
+ function waitUnlessAborted(previous, signal) {
38068
+ return new Promise((resolve, reject) => {
38069
+ const onAbort = () => {
38070
+ reject(new DOMException("Judge review aborted", "AbortError"));
38071
+ };
38072
+ if (signal.aborted) {
38073
+ onAbort();
38074
+ return;
38075
+ }
38076
+ signal.addEventListener("abort", onAbort, { once: true });
38077
+ waitThenRelease(previous, () => {
38078
+ signal.removeEventListener("abort", onAbort);
38079
+ resolve();
38080
+ });
38081
+ });
38082
+ }
38083
+ async function waitThenRelease(previous, release) {
38084
+ await previous;
38085
+ release();
38086
+ }
38087
38087
  //#endregion
38088
38088
  export { startJudgeSession as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-mode",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "description": "A permission classifier library and Claude Code mod, so agents that are not Claude can run unattended",
5
5
  "keywords": [
6
6
  "agent",
@@ -79,10 +79,10 @@
79
79
  "@tsconfig/strictest": "2.0.8",
80
80
  "@types/bun": "1.4.2",
81
81
  "@types/node": "26.6.5",
82
- "@zgeoff/bun-test-extended": "0.2.0",
83
- "@zgeoff/format-codemod": "0.2.0",
84
- "@zgeoff/oxlint-config": "0.2.12",
85
- "@zgeoff/skill-gate": "0.1.0",
82
+ "@zgeoff/bun-test-extended": "0.2.1",
83
+ "@zgeoff/format-codemod": "0.3.0",
84
+ "@zgeoff/oxlint-config": "0.6.1",
85
+ "@zgeoff/skill-gate": "0.2.2",
86
86
  "gunshi": "1.0.0-rc.1",
87
87
  "knip": "6.41.0",
88
88
  "lefthook": "2.2.1",
@@ -1 +0,0 @@
1
- export { t as startJudgeSession } from "./start-judge-session-DX3Oek85.js";