nofax 0.2.6 → 0.2.7

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/README.md CHANGED
@@ -158,6 +158,10 @@ Codex hooks are enabled by default. Configure `~/.codex/hooks.json`:
158
158
 
159
159
  Restart Codex, run `/hooks`, and review/trust the exact Nofax hook definition before relying on it. Codex skips non-managed hooks until they are trusted, and a changed hook definition must be reviewed again. If an administrator or local policy has explicitly disabled hooks, re-enable them with `[features] hooks = true` in `~/.codex/config.toml`.
160
160
 
161
+ Codex currently evaluates `PermissionRequest` hooks before its configured approval reviewer. A terminal Nofax Allow/Deny therefore resolves the request before Codex can route it to `approvals_reviewer = "auto_review"` (or the legacy `guardian_subagent` value). If you want Nofax to be the human approval surface, use `approvals_reviewer = "user"`; do not combine this Nofax approval hook with Auto-review/Guardian expecting both reviewers to run. Current Codex hook input does not expose the effective reviewer, so Nofax cannot safely distinguish a user-routed approval from one that Codex intended to auto-review.
162
+
163
+ `PermissionRequest` hooks are also serial with Codex's native approval UI: while Nofax is waiting, the normal Codex approval prompt is not simultaneously available. If Nofax returns no decision (for example after timeout or transport failure), Codex falls back to its normal approval flow. Nofax never converts that fallback condition into approval.
164
+
161
165
  ### Gemini CLI
162
166
 
163
167
  Current Gemini CLI builds expose a synchronous `BeforeTool` hook that can allow or deny a tool call. Route selected tools through Nofax in `~/.gemini/settings.json`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nofax",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "mcpName": "io.github.AKzar1el/nofax",
5
5
  "description": "Human-in-the-loop approvals and notifications for AI coding agents via CLI, MCP, and agent hooks.",
6
6
  "type": "module",
@@ -74,7 +74,7 @@ const LIST_PENDING_OUTPUT_SCHEMA = z.object({
74
74
 
75
75
  export function buildMcpServer({ handlers = createMcpToolHandlers() } = {}) {
76
76
  const server = new McpServer(
77
- { name: 'nofax', version: '0.2.6' },
77
+ { name: 'nofax', version: '0.2.7' },
78
78
  { instructions: SERVER_INSTRUCTIONS }
79
79
  );
80
80
 
package/src/mcp-tools.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  listPendingRequests,
10
10
  loadRequest,
11
- resolveRequest,
11
+ resolveRequestWithClaim,
12
12
  savePendingRequest
13
13
  } from './requests.mjs';
14
14
 
@@ -116,7 +116,7 @@ export function createMcpToolHandlers(overrides = {}) {
116
116
  sendResponseConfirmationImpl: overrides.sendResponseConfirmationImpl ?? sendResponseConfirmation,
117
117
  savePendingRequestImpl: overrides.savePendingRequestImpl ?? savePendingRequest,
118
118
  loadRequestImpl: overrides.loadRequestImpl ?? loadRequest,
119
- resolveRequestImpl: overrides.resolveRequestImpl ?? resolveRequest,
119
+ resolveRequestWithClaimImpl: overrides.resolveRequestWithClaimImpl ?? resolveRequestWithClaim,
120
120
  listPendingRequestsImpl: overrides.listPendingRequestsImpl ?? listPendingRequests,
121
121
  nowImpl: overrides.nowImpl ?? Date.now,
122
122
  sleepImpl: overrides.sleepImpl ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)))
@@ -214,14 +214,16 @@ export function createMcpToolHandlers(overrides = {}) {
214
214
  allowed: request.allowed
215
215
  });
216
216
  if (response !== null) {
217
- request = await deps.resolveRequestImpl({
217
+ const resolution = await deps.resolveRequestWithClaimImpl({
218
218
  home: deps.home,
219
219
  env: deps.env,
220
220
  requestId: request.requestId,
221
221
  response,
222
222
  resolvedAt: new Date(deps.nowImpl()).toISOString()
223
223
  });
224
- const acceptedResponse = request.decision === response.decision
224
+ request = resolution.request;
225
+ const acceptedResponse = resolution.claimed
226
+ && request.decision === response.decision
225
227
  && (request.text ?? undefined) === (response.text ?? undefined);
226
228
  if (acceptedResponse) {
227
229
  await deps.sendResponseConfirmationImpl({
package/src/requests.mjs CHANGED
@@ -114,9 +114,9 @@ export async function loadRequest({ home, env, requestId }) {
114
114
  }
115
115
  }
116
116
 
117
- export async function resolveRequest({ home, env, requestId, response, resolvedAt = new Date().toISOString() }) {
117
+ export async function resolveRequestWithClaim({ home, env, requestId, response, resolvedAt = new Date().toISOString() }) {
118
118
  const current = await loadRequest({ home, env, requestId });
119
- if (current.status === 'resolved') return current;
119
+ if (current.status === 'resolved') return { request: current, claimed: false };
120
120
  if (!response || typeof response.decision !== 'string' || !current.allowed.includes(response.decision)) throw new Error('NOFAX_REQUEST_DECISION_INVALID');
121
121
  const resolved = validateRequest({
122
122
  ...current,
@@ -127,9 +127,13 @@ export async function resolveRequest({ home, env, requestId, response, resolvedA
127
127
  });
128
128
  const { terminal } = paths({ home, env, requestId });
129
129
  if (!await claimTerminal(terminal, resolved)) {
130
- return loadRequest({ home, env, requestId });
130
+ return { request: await loadRequest({ home, env, requestId }), claimed: false };
131
131
  }
132
- return resolved;
132
+ return { request: resolved, claimed: true };
133
+ }
134
+
135
+ export async function resolveRequest(options) {
136
+ return (await resolveRequestWithClaim(options)).request;
133
137
  }
134
138
 
135
139
  export async function listPendingRequests({ home, env, limit = 20 } = {}) {
@@ -144,7 +148,7 @@ export async function listPendingRequests({ home, env, limit = 20 } = {}) {
144
148
  throw error;
145
149
  }
146
150
  const results = [];
147
- for (const name of names.sort().reverse()) {
151
+ for (const name of names) {
148
152
  if (!name.endsWith('.json')) continue;
149
153
  const requestId = name.slice(0, -5);
150
154
  if (!REQUEST_ID.test(requestId)) continue;
@@ -152,7 +156,8 @@ export async function listPendingRequests({ home, env, limit = 20 } = {}) {
152
156
  const request = await loadRequest({ home: root, requestId });
153
157
  if (request.status === 'pending') results.push(request);
154
158
  } catch {}
155
- if (results.length >= limit) break;
156
159
  }
157
- return results;
160
+ return results
161
+ .sort((left, right) => Date.parse(right.createdAt) - Date.parse(left.createdAt) || right.requestId.localeCompare(left.requestId))
162
+ .slice(0, limit);
158
163
  }