@disco_trooper/apple-notes-mcp 1.0.0

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.
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Error message sanitization for client responses.
3
+ */
4
+
5
+ import { ERROR_MESSAGE_MAX_LENGTH } from "../config/constants.js";
6
+
7
+ const SAFE_ERROR_PATTERNS = [
8
+ /^Note not found/,
9
+ /^Title must be/,
10
+ /^Title cannot be/,
11
+ /^Title exceeds/,
12
+ /^Title contains/,
13
+ /^Invalid arguments/,
14
+ /^Query cannot be empty/,
15
+ /^READONLY_MODE is enabled/,
16
+ /^Add confirm: true/,
17
+ /^Multiple notes found/,
18
+ /^Folder not found/,
19
+ ];
20
+
21
+ const INTERNAL_ERROR_PATTERNS = [
22
+ /\/[a-zA-Z]+\/[a-zA-Z]+\//,
23
+ /at\s+\S+\s+\(/,
24
+ /:\d+:\d+\)/,
25
+ /TypeError:/,
26
+ /ReferenceError:/,
27
+ /ENOENT:/,
28
+ /EACCES:/,
29
+ ];
30
+
31
+ export function sanitizeErrorMessage(message: string): string {
32
+ for (const pattern of SAFE_ERROR_PATTERNS) {
33
+ if (pattern.test(message)) {
34
+ return message;
35
+ }
36
+ }
37
+
38
+ for (const pattern of INTERNAL_ERROR_PATTERNS) {
39
+ if (pattern.test(message)) {
40
+ return "An internal error occurred";
41
+ }
42
+ }
43
+
44
+ const firstLine = message.split("\n")[0];
45
+ return firstLine.substring(0, ERROR_MESSAGE_MAX_LENGTH);
46
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Text processing utilities.
3
+ */
4
+
5
+ import { MAX_INPUT_LENGTH } from "../config/constants.js";
6
+ import { createDebugLogger } from "./debug.js";
7
+
8
+ const debug = createDebugLogger("TEXT");
9
+
10
+ /**
11
+ * Truncate text to maximum allowed length for embedding models.
12
+ *
13
+ * @param text - Text to truncate
14
+ * @param maxLength - Maximum length (default: MAX_INPUT_LENGTH from constants)
15
+ * @returns Truncated text
16
+ */
17
+ export function truncateForEmbedding(text: string, maxLength = MAX_INPUT_LENGTH): string {
18
+ if (text.length <= maxLength) {
19
+ return text;
20
+ }
21
+ debug(`Truncating text from ${text.length} to ${maxLength} chars`);
22
+ return text.substring(0, maxLength);
23
+ }