nofax 0.2.43 → 0.2.45

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/CHANGELOG.md CHANGED
@@ -42,6 +42,28 @@ Local Nofax `0.2.x` behavior is unchanged by these removals.
42
42
  - The capability-path form is normalized to `/mcp` before MCP protocol handling.
43
43
  - Remote read operations perform no external messaging/provider calls; only explicit `nofax_notify` invokes ntfy.
44
44
 
45
+ ## 0.2.45 - 2026-10-25
46
+
47
+ ### Fixed
48
+
49
+ - Initial approval, choice, and refinement notification publication now has a bounded transport deadline when ntfy does not settle.
50
+ - Standalone CLI, MCP, and advisory hook notifications now abort stalled ntfy publication after 15 seconds and report ambiguous delivery rather than hanging indefinitely.
51
+
52
+ Pending requests, transport timeouts, uncertain notification delivery, and disconnects never constitute human approval. No automatic publication retry or remote Worker authority expansion is introduced.
53
+
54
+ ## 0.2.44 - 2026-10-24
55
+
56
+ ### Security
57
+
58
+ - Updated the local MCP server and Zod runtime dependencies to patched, audited versions. The remote Worker MCP, Agents, and Zod dependency manifests were also updated; their production deployment is a separate operation.
59
+
60
+ ### Fixed
61
+
62
+ - Response polling now bounds fetch and response-body reads by each CLI/MCP caller's remaining deadline, so a stalled ntfy response stream cannot indefinitely extend a pending wait.
63
+ - Best-effort notification confirming an already-persisted human response now has a bounded transport deadline rather than potentially blocking the caller indefinitely.
64
+
65
+ Pending, timeout, disconnect, transport errors, and notification delivery never mean approval. Durable human-decision ownership, response-topic secrecy, and the intentionally narrower remote Worker authority remain unchanged.
66
+
45
67
  ## 0.2.43 - 2026-09-24
46
68
 
47
69
  ### Changed
package/README.md CHANGED
@@ -97,6 +97,46 @@ Start the local stdio MCP server:
97
97
  nofax mcp
98
98
  ```
99
99
 
100
+ ### Connect an MCP client
101
+
102
+ Claude Code can launch the published local MCP server directly:
103
+
104
+ ```bash
105
+ claude mcp add nofax -- npx -y nofax mcp
106
+ ```
107
+
108
+ Codex CLI can register the same stdio server:
109
+
110
+ ```bash
111
+ codex mcp add nofax -- npx -y nofax mcp
112
+ ```
113
+
114
+ Gemini CLI can register it in user settings:
115
+
116
+ ```bash
117
+ gemini mcp add --scope user --transport stdio nofax npx -- -y nofax mcp
118
+ ```
119
+
120
+ Gemini CLI may mark configured servers **Disabled** when the current workspace is untrusted. Review and trust only workspaces you control through Gemini's normal trust flow; do not use `--trust` to bypass MCP tool-call confirmations. Registering an MCP server does not automatically install the separate permission hooks documented below.
121
+
122
+ VS Code can register Nofax in its user-profile MCP configuration. Open the Command Palette, choose `MCP: Open User Configuration`, and add this entry to `mcp.json`:
123
+
124
+ ```json
125
+ {
126
+ "servers": {
127
+ "nofax": {
128
+ "type": "stdio",
129
+ "command": "npx",
130
+ "args": ["-y", "nofax", "mcp"]
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ Merge the `nofax` entry with any existing servers rather than replacing them. Review VS Code's normal server-trust prompt before starting it; MCP registration does not install separate permission hooks.
137
+
138
+ For other stdio MCP clients, set the command to `npx` with arguments `["-y", "nofax", "mcp"]`. The final `mcp` argument is required: running `npx -y nofax` without it prints the CLI usage and exits instead of starting a server. Complete the Quick start configuration before using notification or approval tools.
139
+
100
140
  Local MCP exposes:
101
141
 
102
142
  - `nofax_notify`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nofax",
3
- "version": "0.2.43",
3
+ "version": "0.2.45",
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",
@@ -30,8 +30,8 @@
30
30
  "node": ">=20.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@modelcontextprotocol/server": "2.0.0",
34
- "zod": "4.4.3"
33
+ "@modelcontextprotocol/server": "2.4.0",
34
+ "zod": "4.6.7"
35
35
  },
36
36
  "keywords": [
37
37
  "ai-agent",
@@ -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.43' },
77
+ { name: 'nofax', version: '0.2.45' },
78
78
  { instructions: SERVER_INSTRUCTIONS }
79
79
  );
80
80
 
package/src/mcp-tools.mjs CHANGED
@@ -260,13 +260,16 @@ export function createMcpToolHandlers(overrides = {}) {
260
260
  ? { server: request.server, topic: request.topic }
261
261
  : await config();
262
262
  const deadline = deps.nowImpl() + seconds * 1000;
263
- while (deps.nowImpl() < deadline) {
263
+ while (true) {
264
+ const remainingBeforePoll = deadline - deps.nowImpl();
265
+ if (remainingBeforePoll <= 0) break;
264
266
  const response = await deps.pollRemoteResponseImpl({
265
267
  config: current,
266
268
  responseTopic: request.responseTopic,
267
269
  requestId: request.requestId,
268
270
  allowed: request.allowed,
269
- kind: request.kind
271
+ kind: request.kind,
272
+ timeoutMs: remainingBeforePoll
270
273
  });
271
274
  if (response !== null) {
272
275
  const resolution = await deps.resolveRequestWithClaimImpl({
package/src/ntfy.mjs CHANGED
@@ -3,6 +3,9 @@ import { createRequestId, createResponseTopic, parseResponseMessage } from './pr
3
3
  const MAX_TITLE = 120;
4
4
  const MAX_MESSAGE = 2200;
5
5
  const DEFAULT_REFINE_SHORTCUT = 'Nofax Refine';
6
+ const POLL_TIMEOUT = Symbol('NOFAX_POLL_TIMEOUT');
7
+ const PUBLISH_TIMEOUT = Symbol('NOFAX_PUBLISH_TIMEOUT');
8
+ const DEFAULT_PUBLISH_TIMEOUT_MS = 15_000;
6
9
  // ntfy rejects validation and rate-limit responses before accepting the publish.
7
10
  const NOT_APPLIED_PUBLISH_STATUSES = new Set([400, 429]);
8
11
 
@@ -71,7 +74,7 @@ function publishError(message, deliveryState) {
71
74
  return error;
72
75
  }
73
76
 
74
- export async function sendNotification({ config, title, message, actions, priority = 4, tags = ['bell'], fetchImpl = fetch }) {
77
+ export async function sendNotification({ config, title, message, actions, priority = 4, tags = ['bell'], signal, fetchImpl = fetch, timeoutMs = DEFAULT_PUBLISH_TIMEOUT_MS }) {
75
78
  const payload = {
76
79
  topic: config.topic,
77
80
  title: boundText(title, MAX_TITLE, 'TITLE'),
@@ -81,16 +84,35 @@ export async function sendNotification({ config, title, message, actions, priori
81
84
  };
82
85
  if (actions?.length) payload.actions = actions;
83
86
 
87
+ // Caller-managed approval publication and confirmation already have a deadline.
88
+ // A direct notification needs its own bounded transport when no signal is supplied.
89
+ const ownsTimeout = signal === undefined;
90
+ if (ownsTimeout && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) {
91
+ throw new Error('NOFAX_PUBLISH_TIMEOUT_INVALID');
92
+ }
93
+ const controller = ownsTimeout ? new AbortController() : null;
94
+ let timeoutId;
95
+ const timeout = controller === null ? null : new Promise((resolve) => {
96
+ timeoutId = setTimeout(() => {
97
+ resolve(PUBLISH_TIMEOUT);
98
+ controller.abort();
99
+ }, timeoutMs);
100
+ });
84
101
  let response;
85
102
  try {
86
- response = await fetchImpl(`${config.server}/`, {
103
+ const request = fetchImpl(`${config.server}/`, {
87
104
  method: 'POST',
88
105
  headers: { 'content-type': 'application/json' },
89
- body: JSON.stringify(payload)
106
+ body: JSON.stringify(payload),
107
+ signal: controller === null ? signal : controller.signal
90
108
  });
109
+ response = timeout === null ? await request : await Promise.race([request, timeout]);
91
110
  } catch (error) {
92
111
  throw publishError(`NOFAX_NTFY_PUBLISH_NETWORK: ${error?.message ?? String(error)}`, 'ambiguous');
112
+ } finally {
113
+ if (timeoutId !== undefined) clearTimeout(timeoutId);
93
114
  }
115
+ if (response === PUBLISH_TIMEOUT) throw publishError('NOFAX_NTFY_PUBLISH_TIMEOUT', 'ambiguous');
94
116
  if (!response?.ok) {
95
117
  const status = response?.status ?? 'NETWORK';
96
118
  const deliveryState = NOT_APPLIED_PUBLISH_STATUSES.has(status) ? 'not_applied' : 'ambiguous';
@@ -125,6 +147,7 @@ export async function createRemoteRequest({
125
147
  includeRefine = false,
126
148
  shortcutName = config.refineShortcutName ?? DEFAULT_REFINE_SHORTCUT,
127
149
  beforePublish = async () => {},
150
+ publishTimeoutMs = DEFAULT_PUBLISH_TIMEOUT_MS,
128
151
  fetchImpl = fetch
129
152
  }) {
130
153
  const normalized = normalizeOptions(options);
@@ -159,7 +182,25 @@ export async function createRemoteRequest({
159
182
 
160
183
  const remote = { requestId, responseTopic, allowed };
161
184
  await beforePublish(remote);
162
- await sendNotification({ config, title, message, actions, fetchImpl });
185
+ if (!Number.isFinite(publishTimeoutMs) || publishTimeoutMs <= 0) throw new Error('NOFAX_PUBLISH_TIMEOUT_INVALID');
186
+ const controller = new AbortController();
187
+ let timeoutId;
188
+ const timeout = new Promise((resolve) => {
189
+ timeoutId = setTimeout(() => {
190
+ resolve(PUBLISH_TIMEOUT);
191
+ controller.abort();
192
+ }, publishTimeoutMs);
193
+ });
194
+ try {
195
+ const delivered = await Promise.race([
196
+ sendNotification({ config, title, message, actions, signal: controller.signal, fetchImpl }),
197
+ timeout
198
+ ]);
199
+ // A timed-out POST may have reached ntfy. Never discard persisted pending state.
200
+ if (delivered === PUBLISH_TIMEOUT) throw publishError('NOFAX_NTFY_PUBLISH_TIMEOUT', 'ambiguous');
201
+ } finally {
202
+ clearTimeout(timeoutId);
203
+ }
163
204
  return remote;
164
205
  }
165
206
 
@@ -179,21 +220,49 @@ function parseNtfyPoll(text, requestId, allowed, kind) {
179
220
  return null;
180
221
  }
181
222
 
182
- export async function pollRemoteResponse({ config, responseTopic, requestId, allowed, kind, fetchImpl = fetch }) {
183
- let response;
223
+ export async function pollRemoteResponse({ config, responseTopic, requestId, allowed, kind, timeoutMs, fetchImpl = fetch }) {
224
+ let timeoutId;
225
+ const controller = timeoutMs === undefined ? null : new AbortController();
226
+ const timeout = controller === null
227
+ ? null
228
+ : new Promise((resolve) => {
229
+ timeoutId = setTimeout(() => {
230
+ controller.abort();
231
+ resolve(POLL_TIMEOUT);
232
+ }, timeoutMs);
233
+ });
184
234
  try {
185
- response = await fetchImpl(`${config.server}/${responseTopic}/json?poll=1&since=all`, {
186
- method: 'GET',
187
- headers: { accept: 'application/x-ndjson' }
188
- });
189
- } catch (error) {
190
- throw new Error(`NOFAX_NTFY_POLL_NETWORK: ${error?.message ?? String(error)}`);
235
+ let response;
236
+ try {
237
+ const request = fetchImpl(`${config.server}/${responseTopic}/json?poll=1&since=all`, {
238
+ method: 'GET',
239
+ headers: { accept: 'application/x-ndjson' },
240
+ ...(controller === null ? {} : { signal: controller.signal })
241
+ });
242
+ response = timeout === null ? await request : await Promise.race([request, timeout]);
243
+ } catch (error) {
244
+ if (controller?.signal.aborted) return null;
245
+ throw new Error(`NOFAX_NTFY_POLL_NETWORK: ${error?.message ?? String(error)}`);
246
+ }
247
+ if (response === POLL_TIMEOUT) return null;
248
+ await ensureOk(response, 'NOFAX_NTFY_POLL');
249
+
250
+ let text;
251
+ try {
252
+ const body = response.text();
253
+ text = timeout === null ? await body : await Promise.race([body, timeout]);
254
+ } catch (error) {
255
+ if (controller?.signal.aborted) return null;
256
+ throw error;
257
+ }
258
+ if (text === POLL_TIMEOUT) return null;
259
+ return parseNtfyPoll(text, requestId, allowed, kind);
260
+ } finally {
261
+ if (timeoutId !== undefined) clearTimeout(timeoutId);
191
262
  }
192
- await ensureOk(response, 'NOFAX_NTFY_POLL');
193
- return parseNtfyPoll(await response.text(), requestId, allowed, kind);
194
263
  }
195
264
 
196
- export async function sendResponseConfirmation({ config, response, kind, title = 'Nofax', fetchImpl = fetch }) {
265
+ export async function sendResponseConfirmation({ config, response, kind, title = 'Nofax', timeoutMs = 5000, fetchImpl = fetch }) {
197
266
  let confirmationTitle = 'Response received';
198
267
  let tag = 'white_check_mark';
199
268
  if (kind === 'choice') confirmationTitle = 'Choice received';
@@ -205,8 +274,15 @@ export async function sendResponseConfirmation({ config, response, kind, title =
205
274
  } else if (response.decision === 'refine') confirmationTitle = 'Refinement received';
206
275
  else confirmationTitle = 'Choice received';
207
276
 
208
- try {
209
- await sendNotification({
277
+ const controller = new AbortController();
278
+ let timeoutId;
279
+ const timeout = new Promise((resolve) => {
280
+ timeoutId = setTimeout(() => {
281
+ controller.abort();
282
+ resolve(false);
283
+ }, timeoutMs);
284
+ });
285
+ const delivery = sendNotification({
210
286
  config,
211
287
  title: `${confirmationTitle} - ${title}`,
212
288
  message: kind !== 'choice' && response.decision === 'refine'
@@ -214,11 +290,13 @@ export async function sendResponseConfirmation({ config, response, kind, title =
214
290
  : `Nofax recorded: ${response.decision}`,
215
291
  priority: 2,
216
292
  tags: [tag],
293
+ signal: controller.signal,
217
294
  fetchImpl
218
- });
219
- return true;
220
- } catch {
221
- return false;
295
+ }).then(() => true, () => false);
296
+ try {
297
+ return await Promise.race([delivery, timeout]);
298
+ } finally {
299
+ clearTimeout(timeoutId);
222
300
  }
223
301
  }
224
302
 
@@ -235,8 +313,18 @@ export async function waitRemoteResponse({
235
313
  sleepImpl = sleep
236
314
  }) {
237
315
  const deadline = nowImpl() + timeoutMs;
238
- while (nowImpl() < deadline) {
239
- const response = await pollRemoteResponse({ config, responseTopic, requestId, allowed, kind, fetchImpl });
316
+ while (true) {
317
+ const remainingBeforePoll = deadline - nowImpl();
318
+ if (remainingBeforePoll <= 0) break;
319
+ const response = await pollRemoteResponse({
320
+ config,
321
+ responseTopic,
322
+ requestId,
323
+ allowed,
324
+ kind,
325
+ timeoutMs: remainingBeforePoll,
326
+ fetchImpl
327
+ });
240
328
  if (response !== null) return response;
241
329
  const remaining = deadline - nowImpl();
242
330
  if (remaining <= 0) break;
@@ -253,12 +341,13 @@ async function requestDecision({
253
341
  kind,
254
342
  includeRefine = false,
255
343
  fetchImpl = fetch,
344
+ publishTimeoutMs = DEFAULT_PUBLISH_TIMEOUT_MS,
256
345
  timeoutMs = config.timeoutSeconds * 1000,
257
346
  pollIntervalMs = 1000,
258
347
  nowImpl = Date.now,
259
348
  sleepImpl = sleep
260
349
  }) {
261
- const remote = await createRemoteRequest({ config, title, message, options, includeRefine, fetchImpl });
350
+ const remote = await createRemoteRequest({ config, title, message, options, includeRefine, publishTimeoutMs, fetchImpl });
262
351
  const response = await waitRemoteResponse({
263
352
  config,
264
353
  ...remote,