nofax 0.2.35 → 0.2.36
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/package.json +1 -1
- package/src/mcp-server.mjs +1 -1
- package/src/mcp-tools.mjs +8 -1
- package/src/ntfy.mjs +8 -1
- package/src/protocol.mjs +15 -5
- package/src/requests.mjs +7 -1
package/package.json
CHANGED
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.36' },
|
|
78
78
|
{ instructions: SERVER_INSTRUCTIONS }
|
|
79
79
|
);
|
|
80
80
|
|
package/src/mcp-tools.mjs
CHANGED
|
@@ -93,10 +93,17 @@ function publicRequest(request) {
|
|
|
93
93
|
return result;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
function safeSliceEnd(text, end) {
|
|
97
|
+
const previous = text.charCodeAt(end - 1);
|
|
98
|
+
return previous >= 0xD800 && previous <= 0xDBFF ? end - 1 : end;
|
|
99
|
+
}
|
|
100
|
+
|
|
96
101
|
function validateText(value, name, max = 2200) {
|
|
97
102
|
if (typeof value !== 'string' || !value.trim()) throw new Error(`NOFAX_${name}_REQUIRED`);
|
|
98
103
|
const text = value.trim();
|
|
99
|
-
|
|
104
|
+
if (text.length <= max) return text;
|
|
105
|
+
const end = safeSliceEnd(text, max - 14);
|
|
106
|
+
return `${text.slice(0, end)}…[truncated]`;
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
function validateWaitSeconds(value) {
|
package/src/ntfy.mjs
CHANGED
|
@@ -4,10 +4,17 @@ const MAX_TITLE = 120;
|
|
|
4
4
|
const MAX_MESSAGE = 2200;
|
|
5
5
|
const DEFAULT_REFINE_SHORTCUT = 'Nofax Refine';
|
|
6
6
|
|
|
7
|
+
function safeSliceEnd(text, end) {
|
|
8
|
+
const previous = text.charCodeAt(end - 1);
|
|
9
|
+
return previous >= 0xD800 && previous <= 0xDBFF ? end - 1 : end;
|
|
10
|
+
}
|
|
11
|
+
|
|
7
12
|
function boundText(value, max, name) {
|
|
8
13
|
if (typeof value !== 'string' || value.trim().length === 0) throw new Error(`NOFAX_${name}_REQUIRED`);
|
|
9
14
|
const text = value.trim();
|
|
10
|
-
|
|
15
|
+
if (text.length <= max) return text;
|
|
16
|
+
const end = safeSliceEnd(text, max - 14);
|
|
17
|
+
return `${text.slice(0, end)}…[truncated]`;
|
|
11
18
|
}
|
|
12
19
|
|
|
13
20
|
function sleep(ms) {
|
package/src/protocol.mjs
CHANGED
|
@@ -176,9 +176,15 @@ function randomBase64Url(bytes) {
|
|
|
176
176
|
return randomBytes(bytes).toString('base64url');
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
function safeSliceEnd(text, end) {
|
|
180
|
+
const previous = text.charCodeAt(end - 1);
|
|
181
|
+
return previous >= 0xD800 && previous <= 0xDBFF ? end - 1 : end;
|
|
182
|
+
}
|
|
183
|
+
|
|
179
184
|
function boundResponseText(value) {
|
|
180
185
|
if (value.length <= MAX_RESPONSE_TEXT) return value;
|
|
181
|
-
|
|
186
|
+
const end = safeSliceEnd(value, MAX_RESPONSE_TEXT - TRUNCATION_MARKER.length);
|
|
187
|
+
return `${value.slice(0, end)}${TRUNCATION_MARKER}`;
|
|
182
188
|
}
|
|
183
189
|
|
|
184
190
|
export function createRequestId() {
|
|
@@ -195,8 +201,10 @@ export function createPhoneTopic() {
|
|
|
195
201
|
|
|
196
202
|
function boundString(value) {
|
|
197
203
|
const redacted = redactSecretText(value);
|
|
198
|
-
const bounded = redacted.length <= MAX_STRING
|
|
199
|
-
|
|
204
|
+
const bounded = redacted.length <= MAX_STRING
|
|
205
|
+
? redacted
|
|
206
|
+
: redacted.slice(0, safeSliceEnd(redacted, MAX_STRING));
|
|
207
|
+
return value.length <= MAX_STRING ? bounded : `${bounded}${TRUNCATION_MARKER}`;
|
|
200
208
|
}
|
|
201
209
|
|
|
202
210
|
export function redactAndBound(value, options = {}) {
|
|
@@ -254,7 +262,8 @@ function serializeBounded(value) {
|
|
|
254
262
|
serialized = '[unserializable]';
|
|
255
263
|
}
|
|
256
264
|
if (serialized.length <= 1400) return serialized;
|
|
257
|
-
|
|
265
|
+
const end = safeSliceEnd(serialized, 1400);
|
|
266
|
+
return `${serialized.slice(0, end)}\n${TRUNCATION_MARKER}`;
|
|
258
267
|
}
|
|
259
268
|
|
|
260
269
|
export function buildAgentSummary({ source, toolName, cwd, toolInput, message }) {
|
|
@@ -266,7 +275,8 @@ export function buildAgentSummary({ source, toolName, cwd, toolInput, message })
|
|
|
266
275
|
if (toolInput !== undefined) lines.push('', 'Request:', serializeBounded(toolInput));
|
|
267
276
|
const result = lines.join('\n').trim();
|
|
268
277
|
if (result.length <= MAX_SUMMARY) return result;
|
|
269
|
-
|
|
278
|
+
const end = safeSliceEnd(result, MAX_SUMMARY - 14);
|
|
279
|
+
return `${result.slice(0, end)}\n${TRUNCATION_MARKER}`;
|
|
270
280
|
}
|
|
271
281
|
|
|
272
282
|
export function parseResponseMessage(message, { requestId, allowed, kind }) {
|
package/src/requests.mjs
CHANGED
|
@@ -14,10 +14,16 @@ function validateRequestId(value) {
|
|
|
14
14
|
return value;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
function safeSliceEnd(text, end) {
|
|
18
|
+
const previous = text.charCodeAt(end - 1);
|
|
19
|
+
return previous >= 0xD800 && previous <= 0xDBFF ? end - 1 : end;
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
function boundResponseText(value) {
|
|
18
23
|
const text = value.trim();
|
|
19
24
|
if (text.length <= MAX_RESPONSE_TEXT) return text;
|
|
20
|
-
|
|
25
|
+
const end = safeSliceEnd(text, MAX_RESPONSE_TEXT - TRUNCATION_MARKER.length);
|
|
26
|
+
return `${text.slice(0, end)}${TRUNCATION_MARKER}`;
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
function validateRequest(input) {
|