nofax 0.2.34 → 0.2.35

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nofax",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
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.34' },
77
+ { name: 'nofax', version: '0.2.35' },
78
78
  { instructions: SERVER_INSTRUCTIONS }
79
79
  );
80
80
 
package/src/mcp-tools.mjs CHANGED
@@ -95,7 +95,8 @@ function publicRequest(request) {
95
95
 
96
96
  function validateText(value, name, max = 2200) {
97
97
  if (typeof value !== 'string' || !value.trim()) throw new Error(`NOFAX_${name}_REQUIRED`);
98
- return value.trim().slice(0, max);
98
+ const text = value.trim();
99
+ return text.length <= max ? text : `${text.slice(0, max - 14)}…[truncated]`;
99
100
  }
100
101
 
101
102
  function validateWaitSeconds(value) {
package/src/protocol.mjs CHANGED
@@ -7,6 +7,7 @@ const MAX_ARRAY = 20;
7
7
  const MAX_OBJECT_KEYS = 30;
8
8
  const MAX_SUMMARY = 2200;
9
9
  const MAX_RESPONSE_TEXT = 2000;
10
+ const TRUNCATION_MARKER = '…[truncated]';
10
11
 
11
12
  function normalizeSecretKeyName(key) {
12
13
  let normalized = '';
@@ -175,6 +176,11 @@ function randomBase64Url(bytes) {
175
176
  return randomBytes(bytes).toString('base64url');
176
177
  }
177
178
 
179
+ function boundResponseText(value) {
180
+ if (value.length <= MAX_RESPONSE_TEXT) return value;
181
+ return `${value.slice(0, MAX_RESPONSE_TEXT - TRUNCATION_MARKER.length)}${TRUNCATION_MARKER}`;
182
+ }
183
+
178
184
  export function createRequestId() {
179
185
  return `nfx_${randomBase64Url(18)}`;
180
186
  }
@@ -282,7 +288,7 @@ export function parseResponseMessage(message, { requestId, allowed, kind }) {
282
288
  if (typeof parsed.text !== 'string') return null;
283
289
  const text = parsed.text.trim();
284
290
  if (!text) return null;
285
- return { decision: 'refine', text: text.slice(0, MAX_RESPONSE_TEXT) };
291
+ return { decision: 'refine', text: boundResponseText(text) };
286
292
  }
287
293
 
288
294
  return { decision };
package/src/requests.mjs CHANGED
@@ -6,12 +6,20 @@ const REQUEST_ID = /^nfx_[A-Za-z0-9_-]{20,80}$/;
6
6
  const RESPONSE_TOPIC = /^nofax_r_[A-Za-z0-9_-]{20,120}$/;
7
7
  const KINDS = new Set(['approval', 'choice', 'refinement']);
8
8
  const STATUSES = new Set(['pending', 'resolved']);
9
+ const MAX_RESPONSE_TEXT = 2000;
10
+ const TRUNCATION_MARKER = '…[truncated]';
9
11
 
10
12
  function validateRequestId(value) {
11
13
  if (typeof value !== 'string' || !REQUEST_ID.test(value)) throw new Error('NOFAX_REQUEST_ID_INVALID');
12
14
  return value;
13
15
  }
14
16
 
17
+ function boundResponseText(value) {
18
+ const text = value.trim();
19
+ if (text.length <= MAX_RESPONSE_TEXT) return text;
20
+ return `${text.slice(0, MAX_RESPONSE_TEXT - TRUNCATION_MARKER.length)}${TRUNCATION_MARKER}`;
21
+ }
22
+
15
23
  function validateRequest(input) {
16
24
  if (!input || input.version !== 1) throw new Error('NOFAX_REQUEST_VERSION');
17
25
  const requestId = validateRequestId(input.requestId);
@@ -47,7 +55,7 @@ function validateRequest(input) {
47
55
  base.decision = decision;
48
56
  if (input.text !== undefined) {
49
57
  if (typeof input.text !== 'string' || !input.text.trim()) throw new Error('NOFAX_REQUEST_TEXT_INVALID');
50
- base.text = input.text.trim().slice(0, 2000);
58
+ base.text = boundResponseText(input.text);
51
59
  }
52
60
  }
53
61
  return base;