nofax 0.2.32 → 0.2.33

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.32",
3
+ "version": "0.2.33",
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.32' },
77
+ { name: 'nofax', version: '0.2.33' },
78
78
  { instructions: SERVER_INSTRUCTIONS }
79
79
  );
80
80
 
package/src/requests.mjs CHANGED
@@ -17,7 +17,11 @@ function validateRequest(input) {
17
17
  const requestId = validateRequestId(input.requestId);
18
18
  if (!KINDS.has(input.kind)) throw new Error('NOFAX_REQUEST_KIND_INVALID');
19
19
  if (typeof input.responseTopic !== 'string' || !RESPONSE_TOPIC.test(input.responseTopic)) throw new Error('NOFAX_RESPONSE_TOPIC_INVALID');
20
- if (!Array.isArray(input.allowed) || input.allowed.length < 1 || input.allowed.length > 3 || input.allowed.some((value) => typeof value !== 'string' || !value.trim() || value.length > 80)) {
20
+ if (!Array.isArray(input.allowed) || input.allowed.length < 1 || input.allowed.length > 3 || input.allowed.some((value) => typeof value !== 'string')) {
21
+ throw new Error('NOFAX_REQUEST_ALLOWED_INVALID');
22
+ }
23
+ const allowed = input.allowed.map((value) => value.trim());
24
+ if (allowed.some((value) => !value || value.length > 80)) {
21
25
  throw new Error('NOFAX_REQUEST_ALLOWED_INVALID');
22
26
  }
23
27
  if (!STATUSES.has(input.status)) throw new Error('NOFAX_REQUEST_STATUS_INVALID');
@@ -27,18 +31,20 @@ function validateRequest(input) {
27
31
  requestId,
28
32
  kind: input.kind,
29
33
  responseTopic: input.responseTopic,
30
- allowed: [...input.allowed],
34
+ allowed,
31
35
  status: input.status,
32
36
  createdAt: input.createdAt
33
37
  };
34
38
  if (input.status === 'resolved') {
35
39
  if (typeof input.resolvedAt !== 'string' || Number.isNaN(Date.parse(input.resolvedAt))) throw new Error('NOFAX_REQUEST_RESOLVED_AT_INVALID');
36
- if (typeof input.decision !== 'string' || !input.allowed.includes(input.decision)) throw new Error('NOFAX_REQUEST_DECISION_INVALID');
37
- if (input.decision === 'refine' && input.kind !== 'choice' && (typeof input.text !== 'string' || !input.text.trim())) {
40
+ if (typeof input.decision !== 'string') throw new Error('NOFAX_REQUEST_DECISION_INVALID');
41
+ const decision = input.decision.trim();
42
+ if (!allowed.includes(decision)) throw new Error('NOFAX_REQUEST_DECISION_INVALID');
43
+ if (decision === 'refine' && input.kind !== 'choice' && (typeof input.text !== 'string' || !input.text.trim())) {
38
44
  throw new Error('NOFAX_REQUEST_TEXT_INVALID');
39
45
  }
40
46
  base.resolvedAt = input.resolvedAt;
41
- base.decision = input.decision;
47
+ base.decision = decision;
42
48
  if (input.text !== undefined) {
43
49
  if (typeof input.text !== 'string' || !input.text.trim()) throw new Error('NOFAX_REQUEST_TEXT_INVALID');
44
50
  base.text = input.text.trim().slice(0, 2000);
@@ -120,12 +126,14 @@ export async function loadRequest({ home, env, requestId }) {
120
126
  export async function resolveRequestWithClaim({ home, env, requestId, response, resolvedAt = new Date().toISOString() }) {
121
127
  const current = await loadRequest({ home, env, requestId });
122
128
  if (current.status === 'resolved') return { request: current, claimed: false };
123
- if (!response || typeof response.decision !== 'string' || !current.allowed.includes(response.decision)) throw new Error('NOFAX_REQUEST_DECISION_INVALID');
129
+ if (!response || typeof response.decision !== 'string') throw new Error('NOFAX_REQUEST_DECISION_INVALID');
130
+ const decision = response.decision.trim();
131
+ if (!current.allowed.includes(decision)) throw new Error('NOFAX_REQUEST_DECISION_INVALID');
124
132
  const resolved = validateRequest({
125
133
  ...current,
126
134
  status: 'resolved',
127
135
  resolvedAt,
128
- decision: response.decision,
136
+ decision,
129
137
  ...(response.text === undefined ? {} : { text: response.text })
130
138
  });
131
139
  const { terminal } = paths({ home, env, requestId });