nofax 0.2.7 → 0.2.9

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
@@ -198,7 +198,7 @@ Current Gemini CLI builds expose a synchronous `BeforeTool` hook that can allow
198
198
  }
199
199
  ```
200
200
 
201
- `BeforeTool` waits for an explicit Nofax Allow/Deny result. A Nofax timeout or transport failure emits valid no-decision JSON and leaves Gemini CLI's own policy/confirmation flow in control rather than converting failure into approval. The `Notification` hook remains advisory and is forwarded only as a phone notification.
201
+ `BeforeTool` waits for an explicit Nofax Allow/Deny result. A Nofax timeout or transport failure returns Gemini's `ask` decision, forcing the native interactive confirmation instead of allowing an auto-approval policy to treat the missing Nofax decision as permission. The `Notification` hook remains advisory and is forwarded only as a phone notification.
202
202
 
203
203
  Adjust the matcher to the tools you want Nofax to gate. Keep the hook timeout longer than Nofax's configured approval timeout (`timeoutSeconds`, 300 seconds by default).
204
204
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nofax",
3
- "version": "0.2.7",
3
+ "version": "0.2.9",
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",
@@ -49,9 +49,9 @@ export async function handleGeminiHook(input, {
49
49
  if (result.decision === 'deny') {
50
50
  return { decision: 'deny', reason: 'Denied remotely via Nofax.' };
51
51
  }
52
- return {};
52
+ return { decision: 'ask' };
53
53
  } catch (error) {
54
54
  onError(error);
55
- return {};
55
+ return { decision: 'ask' };
56
56
  }
57
57
  }
@@ -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.7' },
77
+ { name: 'nofax', version: '0.2.9' },
78
78
  { instructions: SERVER_INSTRUCTIONS }
79
79
  );
80
80
 
@@ -135,7 +135,7 @@ export function buildMcpServer({ handlers = createMcpToolHandlers() } = {}) {
135
135
  'nofax_request_refinement',
136
136
  {
137
137
  title: 'Request human refinement',
138
- description: 'Ask the human for free-text refinement through the configured Nofax Refine iOS Shortcut. Returns a durable pending requestId. IMPORTANT: call nofax_wait_for_response and repeat while pending.',
138
+ description: 'Ask the human for free-text refinement through the configured Nofax Refine iOS Shortcut. Use this when free-text edits are needed; use nofax_request_approval for Allow/Deny or nofax_request_choice for predefined options. Returns a durable pending requestId; call nofax_wait_for_response and repeat while pending.',
139
139
  inputSchema: z.object({
140
140
  title: z.string().min(1).max(120).optional().describe('Optional refinement prompt title shown to the human; defaults to "Nofax refinement".'),
141
141
  message: z.string().min(1).max(2200).describe('Context or draft the human should refine with free text.')
@@ -165,7 +165,7 @@ export function buildMcpServer({ handlers = createMcpToolHandlers() } = {}) {
165
165
  'nofax_get_request',
166
166
  {
167
167
  title: 'Get Nofax request',
168
- description: 'Recover safe metadata and terminal state for a durable Nofax request. Secret response topics are never returned.',
168
+ description: 'Inspect safe metadata and terminal state for one known durable requestId without waiting. Use nofax_wait_for_response when the caller must wait for a human decision, or nofax_list_pending to recover requestIds after interruption. Secret response topics are never returned.',
169
169
  inputSchema: z.object({
170
170
  requestId: z.string().min(24).max(84).describe('Durable Nofax request handle to inspect without exposing its secret response topic.')
171
171
  }),
package/src/protocol.mjs CHANGED
@@ -8,6 +8,17 @@ const MAX_OBJECT_KEYS = 30;
8
8
  const MAX_SUMMARY = 2200;
9
9
  const MAX_RESPONSE_TEXT = 2000;
10
10
 
11
+ function normalizeSecretKeyName(key) {
12
+ return key
13
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
14
+ .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
15
+ .replace(/[^A-Za-z0-9]+/g, '_');
16
+ }
17
+
18
+ function isSecretKey(key) {
19
+ return SECRET_KEY.test(normalizeSecretKeyName(key));
20
+ }
21
+
11
22
  function randomBase64Url(bytes) {
12
23
  return randomBytes(bytes).toString('base64url');
13
24
  }
@@ -50,7 +61,7 @@ export function redactAndBound(value, options = {}) {
50
61
 
51
62
  const out = {};
52
63
  for (const [key, child] of Object.entries(value).slice(0, MAX_OBJECT_KEYS)) {
53
- out[key] = SECRET_KEY.test(key)
64
+ out[key] = isSecretKey(key)
54
65
  ? '[REDACTED]'
55
66
  : redactAndBound(child, { seen, depth: depth + 1 });
56
67
  }
@@ -97,7 +108,7 @@ export function parseResponseMessage(message, { requestId, allowed }) {
97
108
  if (typeof parsed.text !== 'string') return null;
98
109
  const text = parsed.text.trim();
99
110
  if (!text) return null;
100
- return { decision: 'refine', text: boundString(text).slice(0, MAX_RESPONSE_TEXT) };
111
+ return { decision: 'refine', text: text.slice(0, MAX_RESPONSE_TEXT) };
101
112
  }
102
113
 
103
114
  return { decision: parsed.decision };