nofax 0.2.44 → 0.2.46
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 +23 -0
- package/README.md +69 -0
- package/package.json +1 -1
- package/src/config.mjs +1 -1
- package/src/mcp-server.mjs +1 -1
- package/src/ntfy.mjs +64 -6
package/CHANGELOG.md
CHANGED
|
@@ -42,6 +42,29 @@ 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.46 - 2026-10-29
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- Bound ntfy notification bodies to the 4,096-byte UTF-8 inline-message limit while preserving Unicode-safe truncation, the existing character cap, and the explicit truncation marker.
|
|
50
|
+
- Reject custom ntfy topics longer than the provider's 64-character maximum during configuration validation.
|
|
51
|
+
|
|
52
|
+
### Documentation
|
|
53
|
+
|
|
54
|
+
- Clarified iOS notification dismissal and web-browser HTTP action limitations: neither substitutes for explicit NoFax approval.
|
|
55
|
+
- Documented native Pi MCP setup and fail-closed polling behavior without promising automatic idle-session wake-up.
|
|
56
|
+
|
|
57
|
+
Pending, timeout, disconnect, notification delivery, and absent human response never approve any operation. The remote Worker's limited authority is unchanged.
|
|
58
|
+
|
|
59
|
+
## 0.2.45 - 2026-10-25
|
|
60
|
+
|
|
61
|
+
### Fixed
|
|
62
|
+
|
|
63
|
+
- Initial approval, choice, and refinement notification publication now has a bounded transport deadline when ntfy does not settle.
|
|
64
|
+
- Standalone CLI, MCP, and advisory hook notifications now abort stalled ntfy publication after 15 seconds and report ambiguous delivery rather than hanging indefinitely.
|
|
65
|
+
|
|
66
|
+
Pending requests, transport timeouts, uncertain notification delivery, and disconnects never constitute human approval. No automatic publication retry or remote Worker authority expansion is introduced.
|
|
67
|
+
|
|
45
68
|
## 0.2.44 - 2026-10-24
|
|
46
69
|
|
|
47
70
|
### Security
|
package/README.md
CHANGED
|
@@ -89,6 +89,8 @@ or:
|
|
|
89
89
|
|
|
90
90
|
If the request is still pending, times out, disconnects, or hits a transport error, Nofax never converts that condition into approval.
|
|
91
91
|
|
|
92
|
+
**ntfy client compatibility:** On iOS, the ntfy app may leave an HTTP action notification visible after you tap Allow or Deny, even when the action requests `clear: true` ([upstream ntfy issue #1728](https://github.com/binwiederhier/ntfy/issues/1728)). A still-visible notification does not prove whether Nofax recorded a decision: rely on Nofax's terminal `allow`/`deny` response or pending/timeout state, not on whether the notification disappears. If you use the ntfy web app instead of the mobile app, HTTP action buttons in notifications are supported in Chrome, Edge, and Opera but not Firefox or Safari; cross-origin callbacks also need the target server to allow CORS ([ntfy web-app support](https://docs.ntfy.sh/subscribe/web/)).
|
|
93
|
+
|
|
92
94
|
## MCP
|
|
93
95
|
|
|
94
96
|
Start the local stdio MCP server:
|
|
@@ -97,6 +99,46 @@ Start the local stdio MCP server:
|
|
|
97
99
|
nofax mcp
|
|
98
100
|
```
|
|
99
101
|
|
|
102
|
+
### Connect an MCP client
|
|
103
|
+
|
|
104
|
+
Claude Code can launch the published local MCP server directly:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
claude mcp add nofax -- npx -y nofax mcp
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Codex CLI can register the same stdio server:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
codex mcp add nofax -- npx -y nofax mcp
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Gemini CLI can register it in user settings:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
gemini mcp add --scope user --transport stdio nofax npx -- -y nofax mcp
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
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.
|
|
123
|
+
|
|
124
|
+
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`:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"servers": {
|
|
129
|
+
"nofax": {
|
|
130
|
+
"type": "stdio",
|
|
131
|
+
"command": "npx",
|
|
132
|
+
"args": ["-y", "nofax", "mcp"]
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
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.
|
|
139
|
+
|
|
140
|
+
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.
|
|
141
|
+
|
|
100
142
|
Local MCP exposes:
|
|
101
143
|
|
|
102
144
|
- `nofax_notify`
|
|
@@ -202,6 +244,33 @@ Current Gemini CLI builds expose a synchronous `BeforeTool` hook that can allow
|
|
|
202
244
|
|
|
203
245
|
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
246
|
|
|
247
|
+
### Pi (native MCP support)
|
|
248
|
+
|
|
249
|
+
Pi 1.x has built-in MCP support for local stdio servers; see [Pi's official MCP documentation](https://pi.dev/docs/latest/mcp). After `nofax init`, register and check the Nofax server:
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
pi mcp add nofax -- npx -y nofax mcp
|
|
253
|
+
pi mcp list
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Pi's default MCP request timeout is 60 seconds. If you use `nofax_wait_for_response` with waits longer than that (up to Nofax's 240-second maximum), add `"timeout": 300` to the existing `nofax` entry in `~/.pi/agent/mcp.json`. Do not replace unrelated server entries or settings:
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"mcpServers": {
|
|
261
|
+
"nofax": {
|
|
262
|
+
"command": "npx",
|
|
263
|
+
"args": ["-y", "nofax", "mcp"],
|
|
264
|
+
"timeout": 300
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Pi's built-in MCP configuration lives in `~/.pi/agent/mcp.json`. Third-party extensions that replace `/mcp` (such as `pi-mcp-adapter`) take over the interactive MCP integration and may not load that built-in configuration. Verify which MCP implementation your Pi session is using before adding or changing a server; do not disable Pi's permission gates or install a second MCP runtime just for Nofax.
|
|
271
|
+
|
|
272
|
+
This registers MCP tools, **not an automatic permission hook or idle-session wake-up**. While a request is pending, the agent must call `nofax_wait_for_response` again; a missing reply, timeout, or disconnect is never approval. Use Pi's normal trust/permission workflow and verify your installed Pi build exposes `pi mcp` before applying these instructions.
|
|
273
|
+
|
|
205
274
|
## Optional remote Cloudflare Worker
|
|
206
275
|
|
|
207
276
|
The `worker/` package provides a private, self-deployed MCP endpoint:
|
package/package.json
CHANGED
package/src/config.mjs
CHANGED
|
@@ -30,7 +30,7 @@ export function normalizeServer(input) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function validateTopic(topic) {
|
|
33
|
-
if (typeof topic !== 'string' || topic.length < 24 || topic.length >
|
|
33
|
+
if (typeof topic !== 'string' || topic.length < 24 || topic.length > 64 || !/^[A-Za-z0-9_-]+$/.test(topic)) {
|
|
34
34
|
throw new Error('NOFAX_TOPIC_INVALID');
|
|
35
35
|
}
|
|
36
36
|
return topic;
|
package/src/mcp-server.mjs
CHANGED
|
@@ -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.
|
|
77
|
+
{ name: 'nofax', version: '0.2.46' },
|
|
78
78
|
{ instructions: SERVER_INSTRUCTIONS }
|
|
79
79
|
);
|
|
80
80
|
|
package/src/ntfy.mjs
CHANGED
|
@@ -2,8 +2,11 @@ import { createRequestId, createResponseTopic, parseResponseMessage } from './pr
|
|
|
2
2
|
|
|
3
3
|
const MAX_TITLE = 120;
|
|
4
4
|
const MAX_MESSAGE = 2200;
|
|
5
|
+
const MAX_NTFY_MESSAGE_BYTES = 4096;
|
|
5
6
|
const DEFAULT_REFINE_SHORTCUT = 'Nofax Refine';
|
|
6
7
|
const POLL_TIMEOUT = Symbol('NOFAX_POLL_TIMEOUT');
|
|
8
|
+
const PUBLISH_TIMEOUT = Symbol('NOFAX_PUBLISH_TIMEOUT');
|
|
9
|
+
const DEFAULT_PUBLISH_TIMEOUT_MS = 15_000;
|
|
7
10
|
// ntfy rejects validation and rate-limit responses before accepting the publish.
|
|
8
11
|
const NOT_APPLIED_PUBLISH_STATUSES = new Set([400, 429]);
|
|
9
12
|
|
|
@@ -24,6 +27,23 @@ function boundText(value, max, name) {
|
|
|
24
27
|
return `${text.slice(0, end)}…[truncated]`;
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
function boundMessageText(value) {
|
|
31
|
+
const text = boundText(value, MAX_MESSAGE, 'MESSAGE');
|
|
32
|
+
if (Buffer.byteLength(text, 'utf8') <= MAX_NTFY_MESSAGE_BYTES) return text;
|
|
33
|
+
|
|
34
|
+
const marker = '…[truncated]';
|
|
35
|
+
const maxContentBytes = MAX_NTFY_MESSAGE_BYTES - Buffer.byteLength(marker, 'utf8');
|
|
36
|
+
let bytes = 0;
|
|
37
|
+
let end = 0;
|
|
38
|
+
for (const character of text) {
|
|
39
|
+
const characterBytes = Buffer.byteLength(character, 'utf8');
|
|
40
|
+
if (bytes + characterBytes > maxContentBytes) break;
|
|
41
|
+
bytes += characterBytes;
|
|
42
|
+
end += character.length;
|
|
43
|
+
}
|
|
44
|
+
return `${text.slice(0, end)}${marker}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
27
47
|
function sleep(ms) {
|
|
28
48
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
29
49
|
}
|
|
@@ -72,27 +92,45 @@ function publishError(message, deliveryState) {
|
|
|
72
92
|
return error;
|
|
73
93
|
}
|
|
74
94
|
|
|
75
|
-
export async function sendNotification({ config, title, message, actions, priority = 4, tags = ['bell'], signal, fetchImpl = fetch }) {
|
|
95
|
+
export async function sendNotification({ config, title, message, actions, priority = 4, tags = ['bell'], signal, fetchImpl = fetch, timeoutMs = DEFAULT_PUBLISH_TIMEOUT_MS }) {
|
|
76
96
|
const payload = {
|
|
77
97
|
topic: config.topic,
|
|
78
98
|
title: boundText(title, MAX_TITLE, 'TITLE'),
|
|
79
|
-
message:
|
|
99
|
+
message: boundMessageText(message),
|
|
80
100
|
priority,
|
|
81
101
|
tags
|
|
82
102
|
};
|
|
83
103
|
if (actions?.length) payload.actions = actions;
|
|
84
104
|
|
|
105
|
+
// Caller-managed approval publication and confirmation already have a deadline.
|
|
106
|
+
// A direct notification needs its own bounded transport when no signal is supplied.
|
|
107
|
+
const ownsTimeout = signal === undefined;
|
|
108
|
+
if (ownsTimeout && (!Number.isFinite(timeoutMs) || timeoutMs <= 0)) {
|
|
109
|
+
throw new Error('NOFAX_PUBLISH_TIMEOUT_INVALID');
|
|
110
|
+
}
|
|
111
|
+
const controller = ownsTimeout ? new AbortController() : null;
|
|
112
|
+
let timeoutId;
|
|
113
|
+
const timeout = controller === null ? null : new Promise((resolve) => {
|
|
114
|
+
timeoutId = setTimeout(() => {
|
|
115
|
+
resolve(PUBLISH_TIMEOUT);
|
|
116
|
+
controller.abort();
|
|
117
|
+
}, timeoutMs);
|
|
118
|
+
});
|
|
85
119
|
let response;
|
|
86
120
|
try {
|
|
87
|
-
|
|
121
|
+
const request = fetchImpl(`${config.server}/`, {
|
|
88
122
|
method: 'POST',
|
|
89
123
|
headers: { 'content-type': 'application/json' },
|
|
90
124
|
body: JSON.stringify(payload),
|
|
91
|
-
|
|
125
|
+
signal: controller === null ? signal : controller.signal
|
|
92
126
|
});
|
|
127
|
+
response = timeout === null ? await request : await Promise.race([request, timeout]);
|
|
93
128
|
} catch (error) {
|
|
94
129
|
throw publishError(`NOFAX_NTFY_PUBLISH_NETWORK: ${error?.message ?? String(error)}`, 'ambiguous');
|
|
130
|
+
} finally {
|
|
131
|
+
if (timeoutId !== undefined) clearTimeout(timeoutId);
|
|
95
132
|
}
|
|
133
|
+
if (response === PUBLISH_TIMEOUT) throw publishError('NOFAX_NTFY_PUBLISH_TIMEOUT', 'ambiguous');
|
|
96
134
|
if (!response?.ok) {
|
|
97
135
|
const status = response?.status ?? 'NETWORK';
|
|
98
136
|
const deliveryState = NOT_APPLIED_PUBLISH_STATUSES.has(status) ? 'not_applied' : 'ambiguous';
|
|
@@ -127,6 +165,7 @@ export async function createRemoteRequest({
|
|
|
127
165
|
includeRefine = false,
|
|
128
166
|
shortcutName = config.refineShortcutName ?? DEFAULT_REFINE_SHORTCUT,
|
|
129
167
|
beforePublish = async () => {},
|
|
168
|
+
publishTimeoutMs = DEFAULT_PUBLISH_TIMEOUT_MS,
|
|
130
169
|
fetchImpl = fetch
|
|
131
170
|
}) {
|
|
132
171
|
const normalized = normalizeOptions(options);
|
|
@@ -161,7 +200,25 @@ export async function createRemoteRequest({
|
|
|
161
200
|
|
|
162
201
|
const remote = { requestId, responseTopic, allowed };
|
|
163
202
|
await beforePublish(remote);
|
|
164
|
-
|
|
203
|
+
if (!Number.isFinite(publishTimeoutMs) || publishTimeoutMs <= 0) throw new Error('NOFAX_PUBLISH_TIMEOUT_INVALID');
|
|
204
|
+
const controller = new AbortController();
|
|
205
|
+
let timeoutId;
|
|
206
|
+
const timeout = new Promise((resolve) => {
|
|
207
|
+
timeoutId = setTimeout(() => {
|
|
208
|
+
resolve(PUBLISH_TIMEOUT);
|
|
209
|
+
controller.abort();
|
|
210
|
+
}, publishTimeoutMs);
|
|
211
|
+
});
|
|
212
|
+
try {
|
|
213
|
+
const delivered = await Promise.race([
|
|
214
|
+
sendNotification({ config, title, message, actions, signal: controller.signal, fetchImpl }),
|
|
215
|
+
timeout
|
|
216
|
+
]);
|
|
217
|
+
// A timed-out POST may have reached ntfy. Never discard persisted pending state.
|
|
218
|
+
if (delivered === PUBLISH_TIMEOUT) throw publishError('NOFAX_NTFY_PUBLISH_TIMEOUT', 'ambiguous');
|
|
219
|
+
} finally {
|
|
220
|
+
clearTimeout(timeoutId);
|
|
221
|
+
}
|
|
165
222
|
return remote;
|
|
166
223
|
}
|
|
167
224
|
|
|
@@ -302,12 +359,13 @@ async function requestDecision({
|
|
|
302
359
|
kind,
|
|
303
360
|
includeRefine = false,
|
|
304
361
|
fetchImpl = fetch,
|
|
362
|
+
publishTimeoutMs = DEFAULT_PUBLISH_TIMEOUT_MS,
|
|
305
363
|
timeoutMs = config.timeoutSeconds * 1000,
|
|
306
364
|
pollIntervalMs = 1000,
|
|
307
365
|
nowImpl = Date.now,
|
|
308
366
|
sleepImpl = sleep
|
|
309
367
|
}) {
|
|
310
|
-
const remote = await createRemoteRequest({ config, title, message, options, includeRefine, fetchImpl });
|
|
368
|
+
const remote = await createRemoteRequest({ config, title, message, options, includeRefine, publishTimeoutMs, fetchImpl });
|
|
311
369
|
const response = await waitRemoteResponse({
|
|
312
370
|
config,
|
|
313
371
|
...remote,
|