diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index a3f32130..00000000 --- a/package-lock.json +++ /dev/null @@ -1,3882 +0,0 @@ -{ - "name": "claude-mem", - "version": "7.1.5", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "claude-mem", - "version": "7.1.5", - "license": "AGPL-3.0", - "dependencies": { - "@anthropic-ai/claude-agent-sdk": "^0.1.67", - "@modelcontextprotocol/sdk": "^1.20.1", - "ansi-to-html": "^0.7.2", - "express": "^4.18.2", - "glob": "^11.0.3", - "handlebars": "^4.7.8", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "zod-to-json-schema": "^3.24.6" - }, - "devDependencies": { - "@types/cors": "^2.8.19", - "@types/express": "^4.17.21", - "@types/node": "^20.0.0", - "@types/react": "^18.3.5", - "@types/react-dom": "^18.3.0", - "esbuild": "^0.25.12", - "tsx": "^4.20.6", - "typescript": "^5.3.0", - "vitest": "^4.0.15" - }, - "engines": { - "bun": ">=1.0.0", - "node": ">=18.0.0" - } - }, - "node_modules/@anthropic-ai/claude-agent-sdk": { - "version": "0.1.67", - "resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk/-/claude-agent-sdk-0.1.67.tgz", - "integrity": "sha512-SPeMOfBeQ4Q6BcTRGRyMzaSEzKja3w8giZn6xboab02rPly5KQmgDK0wNerUntPe+xyw7c01xdu5K/pjZXq0dw==", - "license": "SEE LICENSE IN README.md", - "engines": { - "node": ">=18.0.0" - }, - "optionalDependencies": { - "@img/sharp-darwin-arm64": "^0.33.5", - "@img/sharp-darwin-x64": "^0.33.5", - "@img/sharp-linux-arm": "^0.33.5", - "@img/sharp-linux-arm64": "^0.33.5", - "@img/sharp-linux-x64": "^0.33.5", - "@img/sharp-linuxmusl-arm64": "^0.33.5", - "@img/sharp-linuxmusl-x64": "^0.33.5", - "@img/sharp-win32-x64": "^0.33.5" - }, - "peerDependencies": { - "zod": "^3.24.1" - } - }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", - "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", - "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", - "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", - "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", - "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", - "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", - "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", - "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", - "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", - "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", - "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", - "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", - "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", - "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", - "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", - "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", - "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-arm64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", - "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", - "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-arm64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", - "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", - "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openharmony-arm64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", - "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", - "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", - "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", - "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", - "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@img/sharp-darwin-arm64": { - "version": "0.33.5", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.0.4" - } - }, - "node_modules/@img/sharp-darwin-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.5.tgz", - "integrity": "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.0.4" - } - }, - "node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.0.4", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "darwin" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.4.tgz", - "integrity": "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "darwin" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.5.tgz", - "integrity": "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==", - "cpu": [ - "arm" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.4.tgz", - "integrity": "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.4.tgz", - "integrity": "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.4.tgz", - "integrity": "sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==", - "cpu": [ - "arm64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.4.tgz", - "integrity": "sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==", - "cpu": [ - "x64" - ], - "license": "LGPL-3.0-or-later", - "optional": true, - "os": [ - "linux" - ], - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@img/sharp-linux-arm": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.5.tgz", - "integrity": "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==", - "cpu": [ - "arm" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-arm": "1.0.5" - } - }, - "node_modules/@img/sharp-linux-arm64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.5.tgz", - "integrity": "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-arm64": "1.0.4" - } - }, - "node_modules/@img/sharp-linux-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.5.tgz", - "integrity": "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linux-x64": "1.0.4" - } - }, - "node_modules/@img/sharp-linuxmusl-arm64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.5.tgz", - "integrity": "sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==", - "cpu": [ - "arm64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-arm64": "1.0.4" - } - }, - "node_modules/@img/sharp-linuxmusl-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.5.tgz", - "integrity": "sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - }, - "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-x64": "1.0.4" - } - }, - "node_modules/@img/sharp-win32-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.5.tgz", - "integrity": "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==", - "cpu": [ - "x64" - ], - "license": "Apache-2.0 AND LGPL-3.0-or-later", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": "^18.17.0 || ^20.3.0 || >=21.0.0" - }, - "funding": { - "url": "https://opencollective.com/libvips" - } - }, - "node_modules/@isaacs/balanced-match": { - "version": "4.0.1", - "license": "MIT", - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/@isaacs/brace-expansion": { - "version": "5.0.0", - "license": "MIT", - "dependencies": { - "@isaacs/balanced-match": "^4.0.1" - }, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "license": "ISC", - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@isaacs/cliui/node_modules/string-width": { - "version": "5.1.2", - "license": "MIT", - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@isaacs/cliui/node_modules/string-width/node_modules/emoji-regex": { - "version": "9.2.2", - "license": "MIT" - }, - "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { - "version": "8.1.0", - "license": "MIT", - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", - "dev": true, - "license": "MIT" - }, - "node_modules/@modelcontextprotocol/sdk": { - "version": "1.20.1", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.20.1.tgz", - "integrity": "sha512-j/P+yuxXfgxb+mW7OEoRCM3G47zCTDqUPivJo/VzpjbG8I9csTXtOprCf5FfOfHK4whOJny0aHuBEON+kS7CCA==", - "license": "MIT", - "dependencies": { - "ajv": "^6.12.6", - "content-type": "^1.0.5", - "cors": "^2.8.5", - "cross-spawn": "^7.0.5", - "eventsource": "^3.0.2", - "eventsource-parser": "^3.0.0", - "express": "^5.0.1", - "express-rate-limit": "^7.5.0", - "pkce-challenge": "^5.0.0", - "raw-body": "^3.0.0", - "zod": "^3.23.8", - "zod-to-json-schema": "^3.24.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/accepts": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", - "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", - "license": "MIT", - "dependencies": { - "mime-types": "^3.0.0", - "negotiator": "^1.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/body-parser": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.0.tgz", - "integrity": "sha512-02qvAaxv8tp7fBa/mw1ga98OGm+eCbqzJOKoRt70sLmfEEi+jyBYVTDGfCL/k06/4EMk/z01gCe7HoCH/f2LTg==", - "license": "MIT", - "dependencies": { - "bytes": "^3.1.2", - "content-type": "^1.0.5", - "debug": "^4.4.0", - "http-errors": "^2.0.0", - "iconv-lite": "^0.6.3", - "on-finished": "^2.4.1", - "qs": "^6.14.0", - "raw-body": "^3.0.0", - "type-is": "^2.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/content-disposition": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", - "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", - "license": "MIT", - "dependencies": { - "safe-buffer": "5.2.1" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/cookie-signature": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", - "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", - "license": "MIT", - "engines": { - "node": ">=6.6.0" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/express": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/express/-/express-5.1.0.tgz", - "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", - "license": "MIT", - "dependencies": { - "accepts": "^2.0.0", - "body-parser": "^2.2.0", - "content-disposition": "^1.0.0", - "content-type": "^1.0.5", - "cookie": "^0.7.1", - "cookie-signature": "^1.2.1", - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "finalhandler": "^2.1.0", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "merge-descriptors": "^2.0.0", - "mime-types": "^3.0.0", - "on-finished": "^2.4.1", - "once": "^1.4.0", - "parseurl": "^1.3.3", - "proxy-addr": "^2.0.7", - "qs": "^6.14.0", - "range-parser": "^1.2.1", - "router": "^2.2.0", - "send": "^1.1.0", - "serve-static": "^2.2.0", - "statuses": "^2.0.1", - "type-is": "^2.0.1", - "vary": "^1.1.2" - }, - "engines": { - "node": ">= 18" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/finalhandler": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", - "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "on-finished": "^2.4.1", - "parseurl": "^1.3.3", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/fresh": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", - "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/iconv-lite": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", - "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/media-typer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", - "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/merge-descriptors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", - "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", - "license": "MIT", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/mime-db": { - "version": "1.54.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", - "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/mime-types": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", - "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", - "license": "MIT", - "dependencies": { - "mime-db": "^1.54.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/negotiator": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", - "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/qs": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", - "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", - "license": "BSD-3-Clause", - "dependencies": { - "side-channel": "^1.1.0" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/raw-body": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.1.tgz", - "integrity": "sha512-9G8cA+tuMS75+6G/TzW8OtLzmBDMo8p1JRxN5AZ+LAp8uxGA8V8GZm4GQ4/N5QNQEnLmg6SS7wyuSmbKepiKqA==", - "license": "MIT", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.7.0", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/raw-body/node_modules/iconv-lite": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz", - "integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3.0.0" - }, - "engines": { - "node": ">=0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/send": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", - "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", - "license": "MIT", - "dependencies": { - "debug": "^4.3.5", - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "etag": "^1.8.1", - "fresh": "^2.0.0", - "http-errors": "^2.0.0", - "mime-types": "^3.0.1", - "ms": "^2.1.3", - "on-finished": "^2.4.1", - "range-parser": "^1.2.1", - "statuses": "^2.0.1" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/serve-static": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", - "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", - "license": "MIT", - "dependencies": { - "encodeurl": "^2.0.0", - "escape-html": "^1.0.3", - "parseurl": "^1.3.3", - "send": "^1.2.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/@modelcontextprotocol/sdk/node_modules/type-is": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", - "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", - "license": "MIT", - "dependencies": { - "content-type": "^1.0.5", - "media-typer": "^1.1.0", - "mime-types": "^3.0.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.53.3.tgz", - "integrity": "sha512-mRSi+4cBjrRLoaal2PnqH82Wqyb+d3HsPUN/W+WslCXsZsyHa9ZeQQX/pQsZaVIWDkPcpV6jJ+3KLbTbgnwv8w==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-android-arm64": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.53.3.tgz", - "integrity": "sha512-CbDGaMpdE9sh7sCmTrTUyllhrg65t6SwhjlMJsLr+J8YjFuPmCEjbBSx4Z/e4SmDyH3aB5hGaJUP2ltV/vcs4w==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.53.3.tgz", - "integrity": "sha512-Nr7SlQeqIBpOV6BHHGZgYBuSdanCXuw09hon14MGOLGmXAFYjx1wNvquVPmpZnl0tLjg25dEdr4IQ6GgyToCUA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.53.3.tgz", - "integrity": "sha512-DZ8N4CSNfl965CmPktJ8oBnfYr3F8dTTNBQkRlffnUarJ2ohudQD17sZBa097J8xhQ26AwhHJ5mvUyQW8ddTsQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.53.3.tgz", - "integrity": "sha512-yMTrCrK92aGyi7GuDNtGn2sNW+Gdb4vErx4t3Gv/Tr+1zRb8ax4z8GWVRfr3Jw8zJWvpGHNpss3vVlbF58DZ4w==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ] - }, - "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.53.3.tgz", - "integrity": "sha512-lMfF8X7QhdQzseM6XaX0vbno2m3hlyZFhwcndRMw8fbAGUGL3WFMBdK0hbUBIUYcEcMhVLr1SIamDeuLBnXS+Q==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ] - }, - "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.53.3.tgz", - "integrity": "sha512-k9oD15soC/Ln6d2Wv/JOFPzZXIAIFLp6B+i14KhxAfnq76ajt0EhYc5YPeX6W1xJkAdItcVT+JhKl1QZh44/qw==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.53.3.tgz", - "integrity": "sha512-vTNlKq+N6CK/8UktsrFuc+/7NlEYVxgaEgRXVUVK258Z5ymho29skzW1sutgYjqNnquGwVUObAaxae8rZ6YMhg==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.53.3.tgz", - "integrity": "sha512-RGrFLWgMhSxRs/EWJMIFM1O5Mzuz3Xy3/mnxJp/5cVhZ2XoCAxJnmNsEyeMJtpK+wu0FJFWz+QF4mjCA7AUQ3w==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.53.3.tgz", - "integrity": "sha512-kASyvfBEWYPEwe0Qv4nfu6pNkITLTb32p4yTgzFCocHnJLAHs+9LjUu9ONIhvfT/5lv4YS5muBHyuV84epBo/A==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.53.3.tgz", - "integrity": "sha512-JiuKcp2teLJwQ7vkJ95EwESWkNRFJD7TQgYmCnrPtlu50b4XvT5MOmurWNrCj3IFdyjBQ5p9vnrX4JM6I8OE7g==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.53.3.tgz", - "integrity": "sha512-EoGSa8nd6d3T7zLuqdojxC20oBfNT8nexBbB/rkxgKj5T5vhpAQKKnD+h3UkoMuTyXkP5jTjK/ccNRmQrPNDuw==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.53.3.tgz", - "integrity": "sha512-4s+Wped2IHXHPnAEbIB0YWBv7SDohqxobiiPA1FIWZpX+w9o2i4LezzH/NkFUl8LRci/8udci6cLq+jJQlh+0g==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.53.3.tgz", - "integrity": "sha512-68k2g7+0vs2u9CxDt5ktXTngsxOQkSEV/xBbwlqYcUrAVh6P9EgMZvFsnHy4SEiUl46Xf0IObWVbMvPrr2gw8A==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.53.3.tgz", - "integrity": "sha512-VYsFMpULAz87ZW6BVYw3I6sWesGpsP9OPcyKe8ofdg9LHxSbRMd7zrVrr5xi/3kMZtpWL/wC+UIJWJYVX5uTKg==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.53.3.tgz", - "integrity": "sha512-3EhFi1FU6YL8HTUJZ51imGJWEX//ajQPfqWLI3BQq4TlvHy4X0MOr5q3D2Zof/ka0d5FNdPwZXm3Yyib/UEd+w==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.53.3.tgz", - "integrity": "sha512-eoROhjcc6HbZCJr+tvVT8X4fW3/5g/WkGvvmwz/88sDtSJzO7r/blvoBDgISDiCjDRZmHpwud7h+6Q9JxFwq1Q==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.53.3.tgz", - "integrity": "sha512-OueLAWgrNSPGAdUdIjSWXw+u/02BRTcnfw9PN41D2vq/JSEPnJnVuBgw18VkN8wcd4fjUs+jFHVM4t9+kBSNLw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ] - }, - "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.53.3.tgz", - "integrity": "sha512-GOFuKpsxR/whszbF/bzydebLiXIHSgsEUp6M0JI8dWvi+fFa1TD6YQa4aSZHtpmh2/uAlj/Dy+nmby3TJ3pkTw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.53.3.tgz", - "integrity": "sha512-iah+THLcBJdpfZ1TstDFbKNznlzoxa8fmnFYK4V67HvmuNYkVdAywJSoteUszvBQ9/HqN2+9AZghbajMsFT+oA==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.53.3.tgz", - "integrity": "sha512-J9QDiOIZlZLdcot5NXEepDkstocktoVjkaKUtqzgzpt2yWjGlbYiKyp05rWwk4nypbYUNoFAztEgixoLaSETkg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.53.3.tgz", - "integrity": "sha512-UhTd8u31dXadv0MopwGgNOBpUVROFKWVQgAg5N1ESyCz8AuBcMqm4AuTjrwgQKGDfoFuz02EuMRHQIw/frmYKQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@standard-schema/spec": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz", - "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/body-parser": { - "version": "1.19.6", - "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz", - "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/connect": "*", - "@types/node": "*" - } - }, - "node_modules/@types/chai": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", - "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/deep-eql": "*", - "assertion-error": "^2.0.1" - } - }, - "node_modules/@types/connect": { - "version": "3.4.38", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", - "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/cors": { - "version": "2.8.19", - "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz", - "integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/deep-eql": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", - "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/estree": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", - "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/express": { - "version": "4.17.23", - "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.23.tgz", - "integrity": "sha512-Crp6WY9aTYP3qPi2wGDo9iUe/rceX01UMhnF1jmwDcKCFM6cx7YhGP/Mpr3y9AASpfHixIG0E6azCcL5OcDHsQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/body-parser": "*", - "@types/express-serve-static-core": "^4.17.33", - "@types/qs": "*", - "@types/serve-static": "*" - } - }, - "node_modules/@types/express-serve-static-core": { - "version": "4.19.7", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.7.tgz", - "integrity": "sha512-FvPtiIf1LfhzsaIXhv/PHan/2FeQBbtBDtfX2QfvPxdUelMDEckK08SM6nqo1MIZY3RUlfA+HV8+hFUSio78qg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*", - "@types/send": "*" - } - }, - "node_modules/@types/http-errors": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", - "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/mime": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", - "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "20.19.22", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.22.tgz", - "integrity": "sha512-hRnu+5qggKDSyWHlnmThnUqg62l29Aj/6vcYgUaSFL9oc7DVjeWEQN3PRgdSc6F8d9QRMWkf36CLMch1Do/+RQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~6.21.0" - } - }, - "node_modules/@types/prop-types": { - "version": "15.7.15", - "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz", - "integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/qs": { - "version": "6.14.0", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.14.0.tgz", - "integrity": "sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/range-parser": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", - "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/react": { - "version": "18.3.26", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.26.tgz", - "integrity": "sha512-RFA/bURkcKzx/X9oumPG9Vp3D3JUgus/d0b67KB0t5S/raciymilkOa66olh78MUI92QLbEJevO7rvqU/kjwKA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/prop-types": "*", - "csstype": "^3.0.2" - } - }, - "node_modules/@types/react-dom": { - "version": "18.3.7", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.7.tgz", - "integrity": "sha512-MEe3UeoENYVFXzoXEWsvcpg6ZvlrFNlOQ7EOsvhI3CfAXwzPfO8Qwuxd40nepsYKqyyVQnTdEfv68q91yLcKrQ==", - "dev": true, - "license": "MIT", - "peerDependencies": { - "@types/react": "^18.0.0" - } - }, - "node_modules/@types/send": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.0.tgz", - "integrity": "sha512-zBF6vZJn1IaMpg3xUF25VK3gd3l8zwE0ZLRX7dsQyQi+jp4E8mMDJNGDYnYse+bQhYwWERTxVwHpi3dMOq7RKQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/serve-static": { - "version": "1.15.9", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.9.tgz", - "integrity": "sha512-dOTIuqpWLyl3BBXU3maNQsS4A3zuuoYRNIvYSxxhebPfXg2mzWQEPne/nlJ37yOse6uGgR386uTpdsx4D0QZWA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/http-errors": "*", - "@types/node": "*", - "@types/send": "<1" - } - }, - "node_modules/@types/serve-static/node_modules/@types/send": { - "version": "0.17.5", - "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.5.tgz", - "integrity": "sha512-z6F2D3cOStZvuk2SaP6YrwkNO65iTZcwA2ZkSABegdkAh/lf+Aa/YQndZVfmEXT5vgAp6zv06VQ3ejSVjAny4w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/mime": "^1", - "@types/node": "*" - } - }, - "node_modules/@vitest/expect": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.0.15.tgz", - "integrity": "sha512-Gfyva9/GxPAWXIWjyGDli9O+waHDC0Q0jaLdFP1qPAUUfo1FEXPXUfUkp3eZA0sSq340vPycSyOlYUeM15Ft1w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@standard-schema/spec": "^1.0.0", - "@types/chai": "^5.2.2", - "@vitest/spy": "4.0.15", - "@vitest/utils": "4.0.15", - "chai": "^6.2.1", - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/mocker": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.0.15.tgz", - "integrity": "sha512-CZ28GLfOEIFkvCFngN8Sfx5h+Se0zN+h4B7yOsPVCcgtiO7t5jt9xQh2E1UkFep+eb9fjyMfuC5gBypwb07fvQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/spy": "4.0.15", - "estree-walker": "^3.0.3", - "magic-string": "^0.30.21" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "msw": "^2.4.9", - "vite": "^6.0.0 || ^7.0.0-0" - }, - "peerDependenciesMeta": { - "msw": { - "optional": true - }, - "vite": { - "optional": true - } - } - }, - "node_modules/@vitest/pretty-format": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.0.15.tgz", - "integrity": "sha512-SWdqR8vEv83WtZcrfLNqlqeQXlQLh2iilO1Wk1gv4eiHKjEzvgHb2OVc3mIPyhZE6F+CtfYjNlDJwP5MN6Km7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/runner": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.0.15.tgz", - "integrity": "sha512-+A+yMY8dGixUhHmNdPUxOh0la6uVzun86vAbuMT3hIDxMrAOmn5ILBHm8ajrqHE0t8R9T1dGnde1A5DTnmi3qw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/utils": "4.0.15", - "pathe": "^2.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/snapshot": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.0.15.tgz", - "integrity": "sha512-A7Ob8EdFZJIBjLjeO0DZF4lqR6U7Ydi5/5LIZ0xcI+23lYlsYJAfGn8PrIWTYdZQRNnSRlzhg0zyGu37mVdy5g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "4.0.15", - "magic-string": "^0.30.21", - "pathe": "^2.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/spy": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.0.15.tgz", - "integrity": "sha512-+EIjOJmnY6mIfdXtE/bnozKEvTC4Uczg19yeZ2vtCz5Yyb0QQ31QWVQ8hswJ3Ysx/K2EqaNsVanjr//2+P3FHw==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/utils": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.0.15.tgz", - "integrity": "sha512-HXjPW2w5dxhTD0dLwtYHDnelK3j8sR8cWIaLxr22evTyY6q8pRCjZSmhRWVjBaOVXChQd6AwMzi9pucorXCPZA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "4.0.15", - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/accepts": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", - "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", - "license": "MIT", - "dependencies": { - "mime-types": "~2.1.34", - "negotiator": "0.6.3" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-regex": { - "version": "6.2.2", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/ansi-styles": { - "version": "6.2.3", - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/ansi-to-html": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ansi-to-html/-/ansi-to-html-0.7.2.tgz", - "integrity": "sha512-v6MqmEpNlxF+POuyhKkidusCHWWkaLcGRURzivcU3I9tv7k4JVhFcnukrM5Rlk2rUywdZuzYAZ+kbZqWCnfN3g==", - "license": "MIT", - "dependencies": { - "entities": "^2.2.0" - }, - "bin": { - "ansi-to-html": "bin/ansi-to-html" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", - "license": "MIT" - }, - "node_modules/assertion-error": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", - "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - } - }, - "node_modules/body-parser": { - "version": "1.20.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", - "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", - "license": "MIT", - "dependencies": { - "bytes": "3.1.2", - "content-type": "~1.0.5", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "on-finished": "2.4.1", - "qs": "6.13.0", - "raw-body": "2.5.2", - "type-is": "~1.6.18", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/call-bound": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", - "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "get-intrinsic": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/chai": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.1.tgz", - "integrity": "sha512-p4Z49OGG5W/WBCPSS/dH3jQ73kD6tiMmUM+bckNK6Jr5JHMG3k9bg/BvKR8lKmtVBKmOiuVaV2ws8s9oSbwysg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "license": "MIT", - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "license": "MIT" - }, - "node_modules/content-disposition": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", - "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", - "license": "MIT", - "dependencies": { - "safe-buffer": "5.2.1" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", - "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", - "license": "MIT" - }, - "node_modules/cors": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", - "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/cross-spawn": { - "version": "7.0.6", - "license": "MIT", - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/csstype": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", - "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", - "dev": true, - "license": "MIT" - }, - "node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "license": "MIT", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/destroy": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", - "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", - "license": "MIT", - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "license": "MIT" - }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "license": "MIT" - }, - "node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "license": "BSD-2-Clause", - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-module-lexer": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", - "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", - "dev": true, - "license": "MIT" - }, - "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/esbuild": { - "version": "0.25.12", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", - "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.25.12", - "@esbuild/android-arm": "0.25.12", - "@esbuild/android-arm64": "0.25.12", - "@esbuild/android-x64": "0.25.12", - "@esbuild/darwin-arm64": "0.25.12", - "@esbuild/darwin-x64": "0.25.12", - "@esbuild/freebsd-arm64": "0.25.12", - "@esbuild/freebsd-x64": "0.25.12", - "@esbuild/linux-arm": "0.25.12", - "@esbuild/linux-arm64": "0.25.12", - "@esbuild/linux-ia32": "0.25.12", - "@esbuild/linux-loong64": "0.25.12", - "@esbuild/linux-mips64el": "0.25.12", - "@esbuild/linux-ppc64": "0.25.12", - "@esbuild/linux-riscv64": "0.25.12", - "@esbuild/linux-s390x": "0.25.12", - "@esbuild/linux-x64": "0.25.12", - "@esbuild/netbsd-arm64": "0.25.12", - "@esbuild/netbsd-x64": "0.25.12", - "@esbuild/openbsd-arm64": "0.25.12", - "@esbuild/openbsd-x64": "0.25.12", - "@esbuild/openharmony-arm64": "0.25.12", - "@esbuild/sunos-x64": "0.25.12", - "@esbuild/win32-arm64": "0.25.12", - "@esbuild/win32-ia32": "0.25.12", - "@esbuild/win32-x64": "0.25.12" - } - }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "license": "MIT" - }, - "node_modules/estree-walker": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", - "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/estree": "^1.0.0" - } - }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/eventsource": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", - "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", - "license": "MIT", - "dependencies": { - "eventsource-parser": "^3.0.1" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/eventsource-parser": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.6.tgz", - "integrity": "sha512-Vo1ab+QXPzZ4tCa8SwIHJFaSzy4R6SHf7BY79rFBDf0idraZWAkYrDjDj8uWaSm3S2TK+hJ7/t1CEmZ7jXw+pg==", - "license": "MIT", - "engines": { - "node": ">=18.0.0" - } - }, - "node_modules/expect-type": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.2.tgz", - "integrity": "sha512-JhFGDVJ7tmDJItKhYgJCGLOWjuK9vPxiXoUFLwLDc99NlmklilbiQJwoctZtt13+xMw91MCk/REan6MWHqDjyA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/express": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", - "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", - "license": "MIT", - "dependencies": { - "accepts": "~1.3.8", - "array-flatten": "1.1.1", - "body-parser": "1.20.3", - "content-disposition": "0.5.4", - "content-type": "~1.0.4", - "cookie": "0.7.1", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "2.0.0", - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "1.3.1", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "merge-descriptors": "1.0.3", - "methods": "~1.1.2", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.12", - "proxy-addr": "~2.0.7", - "qs": "6.13.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.2.1", - "send": "0.19.0", - "serve-static": "1.16.2", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/express-rate-limit": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.1.tgz", - "integrity": "sha512-7iN8iPMDzOMHPUYllBEsQdWVB6fPDMPqwjBaFrgr4Jgr/+okjvzAy+UHlYYL/Vs0OsOrMkwS6PJDkFlJwoxUnw==", - "license": "MIT", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/express-rate-limit" - }, - "peerDependencies": { - "express": ">= 4.11" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "license": "MIT" - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "license": "MIT" - }, - "node_modules/finalhandler": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", - "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", - "license": "MIT", - "dependencies": { - "debug": "2.6.9", - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "on-finished": "2.4.1", - "parseurl": "~1.3.3", - "statuses": "2.0.1", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/foreground-child": { - "version": "3.3.1", - "license": "ISC", - "dependencies": { - "cross-spawn": "^7.0.6", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "license": "MIT", - "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/get-tsconfig": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.0.tgz", - "integrity": "sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "resolve-pkg-maps": "^1.0.0" - }, - "funding": { - "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" - } - }, - "node_modules/glob": { - "version": "11.0.3", - "license": "ISC", - "dependencies": { - "foreground-child": "^3.3.1", - "jackspeak": "^4.1.1", - "minimatch": "^10.0.3", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^2.0.0" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/handlebars": { - "version": "4.7.8", - "license": "MIT", - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.2", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/http-errors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", - "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", - "license": "MIT", - "dependencies": { - "depd": "2.0.0", - "inherits": "2.0.4", - "setprototypeof": "1.2.0", - "statuses": "2.0.1", - "toidentifier": "1.0.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "license": "ISC" - }, - "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/is-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", - "license": "MIT" - }, - "node_modules/isexe": { - "version": "2.0.0", - "license": "ISC" - }, - "node_modules/jackspeak": { - "version": "4.1.1", - "license": "BlueOak-1.0.0", - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "license": "MIT" - }, - "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "license": "MIT" - }, - "node_modules/loose-envify": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", - "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", - "license": "MIT", - "dependencies": { - "js-tokens": "^3.0.0 || ^4.0.0" - }, - "bin": { - "loose-envify": "cli.js" - } - }, - "node_modules/lru-cache": { - "version": "11.2.2", - "license": "ISC", - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/magic-string": { - "version": "0.30.21", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", - "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.5" - } - }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/merge-descriptors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", - "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "license": "MIT", - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/minimatch": { - "version": "10.0.3", - "license": "ISC", - "dependencies": { - "@isaacs/brace-expansion": "^5.0.0" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/minipass": { - "version": "7.1.2", - "license": "ISC", - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "license": "MIT" - }, - "node_modules/nanoid": { - "version": "3.3.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", - "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/neo-async": { - "version": "2.6.2", - "license": "MIT" - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", - "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/obug": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", - "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", - "dev": true, - "funding": [ - "https://github.com/sponsors/sxzz", - "https://opencollective.com/debug" - ], - "license": "MIT" - }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/once": { - "version": "1.4.0", - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "license": "BlueOak-1.0.0" - }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/path-key": { - "version": "3.1.1", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/path-scurry": { - "version": "2.0.0", - "license": "BlueOak-1.0.0", - "dependencies": { - "lru-cache": "^11.0.0", - "minipass": "^7.1.2" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/path-to-regexp": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", - "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", - "license": "MIT" - }, - "node_modules/pathe": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", - "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", - "dev": true, - "license": "MIT" - }, - "node_modules/picocolors": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", - "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, - "license": "ISC" - }, - "node_modules/pkce-challenge": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.0.tgz", - "integrity": "sha512-ueGLflrrnvwB3xuo/uGob5pd5FN7l0MsLf0Z87o/UQmRtwjvfylfc9MurIxRAWywCYTgrvpXBcqjV4OfCYGCIQ==", - "license": "MIT", - "engines": { - "node": ">=16.20.0" - } - }, - "node_modules/postcss": { - "version": "8.5.6", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", - "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", - "dev": true, - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "dependencies": { - "nanoid": "^3.3.11", - "picocolors": "^1.1.1", - "source-map-js": "^1.2.1" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "license": "MIT", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, - "node_modules/qs": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", - "license": "BSD-3-Clause", - "dependencies": { - "side-channel": "^1.0.6" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/raw-body": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", - "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", - "license": "MIT", - "dependencies": { - "bytes": "3.1.2", - "http-errors": "2.0.0", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/react": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", - "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", - "license": "MIT", - "dependencies": { - "loose-envify": "^1.1.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/react-dom": { - "version": "18.3.1", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", - "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", - "license": "MIT", - "dependencies": { - "loose-envify": "^1.1.0", - "scheduler": "^0.23.2" - }, - "peerDependencies": { - "react": "^18.3.1" - } - }, - "node_modules/resolve-pkg-maps": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", - "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" - } - }, - "node_modules/rollup": { - "version": "4.53.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.53.3.tgz", - "integrity": "sha512-w8GmOxZfBmKknvdXU1sdM9NHcoQejwF/4mNgj2JuEEdRaHwwF12K7e9eXn1nLZ07ad+du76mkVsyeb2rKGllsA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/estree": "1.0.8" - }, - "bin": { - "rollup": "dist/bin/rollup" - }, - "engines": { - "node": ">=18.0.0", - "npm": ">=8.0.0" - }, - "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.53.3", - "@rollup/rollup-android-arm64": "4.53.3", - "@rollup/rollup-darwin-arm64": "4.53.3", - "@rollup/rollup-darwin-x64": "4.53.3", - "@rollup/rollup-freebsd-arm64": "4.53.3", - "@rollup/rollup-freebsd-x64": "4.53.3", - "@rollup/rollup-linux-arm-gnueabihf": "4.53.3", - "@rollup/rollup-linux-arm-musleabihf": "4.53.3", - "@rollup/rollup-linux-arm64-gnu": "4.53.3", - "@rollup/rollup-linux-arm64-musl": "4.53.3", - "@rollup/rollup-linux-loong64-gnu": "4.53.3", - "@rollup/rollup-linux-ppc64-gnu": "4.53.3", - "@rollup/rollup-linux-riscv64-gnu": "4.53.3", - "@rollup/rollup-linux-riscv64-musl": "4.53.3", - "@rollup/rollup-linux-s390x-gnu": "4.53.3", - "@rollup/rollup-linux-x64-gnu": "4.53.3", - "@rollup/rollup-linux-x64-musl": "4.53.3", - "@rollup/rollup-openharmony-arm64": "4.53.3", - "@rollup/rollup-win32-arm64-msvc": "4.53.3", - "@rollup/rollup-win32-ia32-msvc": "4.53.3", - "@rollup/rollup-win32-x64-gnu": "4.53.3", - "@rollup/rollup-win32-x64-msvc": "4.53.3", - "fsevents": "~2.3.2" - } - }, - "node_modules/router": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", - "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", - "license": "MIT", - "dependencies": { - "debug": "^4.4.0", - "depd": "^2.0.0", - "is-promise": "^4.0.0", - "parseurl": "^1.3.3", - "path-to-regexp": "^8.0.0" - }, - "engines": { - "node": ">= 18" - } - }, - "node_modules/router/node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/router/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/router/node_modules/path-to-regexp": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", - "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "license": "MIT" - }, - "node_modules/scheduler": { - "version": "0.23.2", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", - "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", - "license": "MIT", - "dependencies": { - "loose-envify": "^1.1.0" - } - }, - "node_modules/send": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", - "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", - "license": "MIT", - "dependencies": { - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "2.0.0", - "mime": "1.6.0", - "ms": "2.1.3", - "on-finished": "2.4.1", - "range-parser": "~1.2.1", - "statuses": "2.0.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/send/node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/send/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/serve-static": { - "version": "1.16.2", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", - "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", - "license": "MIT", - "dependencies": { - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.19.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "license": "ISC" - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "license": "MIT", - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/side-channel": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", - "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.3", - "side-channel-list": "^1.0.0", - "side-channel-map": "^1.0.1", - "side-channel-weakmap": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-list": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", - "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-map": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", - "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-weakmap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", - "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3", - "side-channel-map": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/siginfo": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", - "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", - "dev": true, - "license": "ISC" - }, - "node_modules/signal-exit": { - "version": "4.1.0", - "license": "ISC", - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/source-map": { - "version": "0.6.1", - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", - "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/stackback": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", - "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", - "dev": true, - "license": "MIT" - }, - "node_modules/statuses": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", - "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/std-env": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", - "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", - "dev": true, - "license": "MIT" - }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "license": "MIT" - }, - "node_modules/string-width-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/strip-ansi/node_modules/ansi-regex": { - "version": "5.0.1", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "7.1.2", - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/tinybench": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", - "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", - "dev": true, - "license": "MIT" - }, - "node_modules/tinyexec": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", - "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/tinyglobby": { - "version": "0.2.15", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", - "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "fdir": "^6.5.0", - "picomatch": "^4.0.3" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/SuperchupuDev" - } - }, - "node_modules/tinyglobby/node_modules/fdir": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", - "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "picomatch": "^3 || ^4" - }, - "peerDependenciesMeta": { - "picomatch": { - "optional": true - } - } - }, - "node_modules/tinyglobby/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/tinyrainbow": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.0.3.tgz", - "integrity": "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "license": "MIT", - "engines": { - "node": ">=0.6" - } - }, - "node_modules/tsx": { - "version": "4.20.6", - "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.6.tgz", - "integrity": "sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==", - "dev": true, - "license": "MIT", - "dependencies": { - "esbuild": "~0.25.0", - "get-tsconfig": "^4.7.5" - }, - "bin": { - "tsx": "dist/cli.mjs" - }, - "engines": { - "node": ">=18.0.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - } - }, - "node_modules/type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "license": "MIT", - "dependencies": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/uglify-js": { - "version": "3.19.3", - "license": "BSD-2-Clause", - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/undici-types": { - "version": "6.21.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", - "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "license": "BSD-2-Clause", - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", - "license": "MIT", - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/vite": { - "version": "7.2.7", - "resolved": "https://registry.npmjs.org/vite/-/vite-7.2.7.tgz", - "integrity": "sha512-ITcnkFeR3+fI8P1wMgItjGrR10170d8auB4EpMLPqmx6uxElH3a/hHGQabSHKdqd4FXWO1nFIp9rRn7JQ34ACQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "esbuild": "^0.25.0", - "fdir": "^6.5.0", - "picomatch": "^4.0.3", - "postcss": "^8.5.6", - "rollup": "^4.43.0", - "tinyglobby": "^0.2.15" - }, - "bin": { - "vite": "bin/vite.js" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "funding": { - "url": "https://github.com/vitejs/vite?sponsor=1" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - }, - "peerDependencies": { - "@types/node": "^20.19.0 || >=22.12.0", - "jiti": ">=1.21.0", - "less": "^4.0.0", - "lightningcss": "^1.21.0", - "sass": "^1.70.0", - "sass-embedded": "^1.70.0", - "stylus": ">=0.54.8", - "sugarss": "^5.0.0", - "terser": "^5.16.0", - "tsx": "^4.8.1", - "yaml": "^2.4.2" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - }, - "jiti": { - "optional": true - }, - "less": { - "optional": true - }, - "lightningcss": { - "optional": true - }, - "sass": { - "optional": true - }, - "sass-embedded": { - "optional": true - }, - "stylus": { - "optional": true - }, - "sugarss": { - "optional": true - }, - "terser": { - "optional": true - }, - "tsx": { - "optional": true - }, - "yaml": { - "optional": true - } - } - }, - "node_modules/vite/node_modules/fdir": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", - "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "picomatch": "^3 || ^4" - }, - "peerDependenciesMeta": { - "picomatch": { - "optional": true - } - } - }, - "node_modules/vite/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/vitest": { - "version": "4.0.15", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.0.15.tgz", - "integrity": "sha512-n1RxDp8UJm6N0IbJLQo+yzLZ2sQCDyl1o0LeugbPWf8+8Fttp29GghsQBjYJVmWq3gBFfe9Hs1spR44vovn2wA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/expect": "4.0.15", - "@vitest/mocker": "4.0.15", - "@vitest/pretty-format": "4.0.15", - "@vitest/runner": "4.0.15", - "@vitest/snapshot": "4.0.15", - "@vitest/spy": "4.0.15", - "@vitest/utils": "4.0.15", - "es-module-lexer": "^1.7.0", - "expect-type": "^1.2.2", - "magic-string": "^0.30.21", - "obug": "^2.1.1", - "pathe": "^2.0.3", - "picomatch": "^4.0.3", - "std-env": "^3.10.0", - "tinybench": "^2.9.0", - "tinyexec": "^1.0.2", - "tinyglobby": "^0.2.15", - "tinyrainbow": "^3.0.3", - "vite": "^6.0.0 || ^7.0.0", - "why-is-node-running": "^2.3.0" - }, - "bin": { - "vitest": "vitest.mjs" - }, - "engines": { - "node": "^20.0.0 || ^22.0.0 || >=24.0.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "@edge-runtime/vm": "*", - "@opentelemetry/api": "^1.9.0", - "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.0.15", - "@vitest/browser-preview": "4.0.15", - "@vitest/browser-webdriverio": "4.0.15", - "@vitest/ui": "4.0.15", - "happy-dom": "*", - "jsdom": "*" - }, - "peerDependenciesMeta": { - "@edge-runtime/vm": { - "optional": true - }, - "@opentelemetry/api": { - "optional": true - }, - "@types/node": { - "optional": true - }, - "@vitest/browser-playwright": { - "optional": true - }, - "@vitest/browser-preview": { - "optional": true - }, - "@vitest/browser-webdriverio": { - "optional": true - }, - "@vitest/ui": { - "optional": true - }, - "happy-dom": { - "optional": true - }, - "jsdom": { - "optional": true - } - } - }, - "node_modules/vitest/node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/which": { - "version": "2.0.2", - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/why-is-node-running": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", - "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", - "dev": true, - "license": "MIT", - "dependencies": { - "siginfo": "^2.0.0", - "stackback": "0.0.2" - }, - "bin": { - "why-is-node-running": "cli.js" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wordwrap": { - "version": "1.0.0", - "license": "MIT" - }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { - "version": "4.3.0", - "license": "MIT", - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "license": "MIT", - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width/node_modules/emoji-regex": { - "version": "8.0.0", - "license": "MIT" - }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi/node_modules/ansi-regex": { - "version": "5.0.1", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "license": "ISC" - }, - "node_modules/zod": { - "version": "3.25.76", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, - "node_modules/zod-to-json-schema": { - "version": "3.24.6", - "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.6.tgz", - "integrity": "sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==", - "license": "ISC", - "peerDependencies": { - "zod": "^3.24.1" - } - } - } -} diff --git a/plugin/hooks/hooks.json b/plugin/hooks/hooks.json index 2a632d7e..1d8d660d 100644 --- a/plugin/hooks/hooks.json +++ b/plugin/hooks/hooks.json @@ -7,12 +7,12 @@ "hooks": [ { "type": "command", - "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/smart-install.js\" && bun \"${CLAUDE_PLUGIN_ROOT}/scripts/context-hook.js\"", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/smart-install.js\" && node \"${CLAUDE_PLUGIN_ROOT}/scripts/context-hook.js\"", "timeout": 300 }, { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/user-message-hook.js\"", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/user-message-hook.js\"", "timeout": 10 } ] @@ -23,7 +23,7 @@ "hooks": [ { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/new-hook.js\"", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/new-hook.js\"", "timeout": 120 } ] @@ -35,7 +35,7 @@ "hooks": [ { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/save-hook.js\"", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/save-hook.js\"", "timeout": 120 } ] @@ -46,7 +46,7 @@ "hooks": [ { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/summary-hook.js\"", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/summary-hook.js\"", "timeout": 120 } ] @@ -57,7 +57,7 @@ "hooks": [ { "type": "command", - "command": "bun \"${CLAUDE_PLUGIN_ROOT}/scripts/cleanup-hook.js\"", + "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/cleanup-hook.js\"", "timeout": 120 } ] diff --git a/plugin/scripts/cleanup-hook.js b/plugin/scripts/cleanup-hook.js index 54b415e8..60a42919 100755 --- a/plugin/scripts/cleanup-hook.js +++ b/plugin/scripts/cleanup-hook.js @@ -1,7 +1,7 @@ #!/usr/bin/env bun -import{stdin as y}from"process";import A from"path";import{homedir as mt}from"os";import{spawnSync as dt}from"child_process";import{existsSync as St,writeFileSync as H,readFileSync as Tt}from"fs";import{readFileSync as J,writeFileSync as q,existsSync as Q}from"fs";import{join as z}from"path";import{homedir as Z}from"os";var X=["bugfix","feature","refactor","discovery","decision","change"],Y=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var v=X.join(","),U=Y.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:z(Z(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:v,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:U,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!Q(t))return this.getAllDefaults();let e=J(t,"utf-8"),n=JSON.parse(e),r=n;if(n.env&&typeof n.env=="object"){r=n.env;try{q(t,JSON.stringify(r,null,2),"utf-8"),c.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){c.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))r[i]!==void 0&&(s[i]=r[i]);return s}};var C=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(C||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=C[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} -${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let n=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&n.command){let r=n.command.length>50?n.command.substring(0,50)+"...":n.command;return`${t}(${r})`}if(t==="Read"&&n.file_path){let r=n.file_path.split("/").pop()||n.file_path;return`${t}(${r})`}if(t==="Edit"&&n.file_path){let r=n.file_path.split("/").pop()||n.file_path;return`${t}(${r})`}if(t==="Write"&&n.file_path){let r=n.file_path.split("/").pop()||n.file_path;return`${t}(${r})`}return t}catch{return t}}log(t,e,n,r,s){if(t0&&(k=` {${Object.entries(w).map(([B,G])=>`${B}=${G}`).join(", ")}}`)}let P=`[${i}] [${u}] [${f}] ${a}${n}${k}${g}`;t===3?console.error(P):console.log(P)}debug(t,e,n,r){this.log(0,t,e,n,r)}info(t,e,n,r){this.log(1,t,e,n,r)}warn(t,e,n,r){this.log(2,t,e,n,r)}error(t,e,n,r){this.log(3,t,e,n,r)}dataIn(t,e,n,r){this.info(t,`\u2192 ${e}`,n,r)}dataOut(t,e,n,r){this.info(t,`\u2190 ${e}`,n,r)}success(t,e,n,r){this.info(t,`\u2713 ${e}`,n,r)}failure(t,e,n,r){this.error(t,`\u2717 ${e}`,n,r)}timing(t,e,n,r){this.info(t,`\u23F1 ${e}`,r,{duration:`${n}ms`})}},c=new M;var d={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function b(o){return process.platform==="win32"?Math.round(o*d.WINDOWS_MULTIPLIER):o}import{existsSync as L,readFileSync as ot,writeFileSync as st,unlinkSync as it,mkdirSync as N}from"fs";import{createWriteStream as at}from"fs";import{join as T}from"path";import{spawn as ct,spawnSync as ut}from"child_process";import{homedir as lt}from"os";import{join as p,dirname as tt,basename as Kt}from"path";import{homedir as et}from"os";import{fileURLToPath as rt}from"url";function nt(){return typeof __dirname<"u"?__dirname:tt(rt(import.meta.url))}var Xt=nt(),E=l.get("CLAUDE_MEM_DATA_DIR"),D=process.env.CLAUDE_CONFIG_DIR||p(et(),".claude"),Yt=p(E,"archives"),Jt=p(E,"logs"),qt=p(E,"trash"),Qt=p(E,"backups"),zt=p(E,"settings.json"),Zt=p(E,"claude-mem.db"),te=p(E,"vector-db"),ee=p(D,"settings.json"),re=p(D,"commands"),ne=p(D,"CLAUDE.md");var S=T(E,"worker.pid"),x=T(E,"logs"),$=T(lt(),".claude","plugins","marketplaces","thedotmack"),pt=5e3,Et=1e4,ft=200,_t=1e3,gt=100,O=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};N(x,{recursive:!0});let e=T($,"plugin","scripts","worker-service.cjs");if(!L(e))return{success:!1,error:`Worker script not found at ${e}`};let n=this.getLogFilePath();return this.startWithBun(e,n,t)}static isBunAvailable(){try{return ut("bun",["--version"],{stdio:"pipe",timeout:5e3}).status===0}catch{return!1}}static async startWithBun(t,e,n){if(!this.isBunAvailable())return{success:!1,error:"Bun is required but not found in PATH. Install from https://bun.sh"};try{let r=process.platform==="win32",s=ct("bun",[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(n)},cwd:$,...r&&{windowsHide:!0}}),i=at(e,{flags:"a"});return s.stdout?.pipe(i),s.stderr?.pipe(i),s.unref(),s.pid?(this.writePidFile({pid:s.pid,port:n,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(s.pid,n)):{success:!1,error:"Failed to get PID from spawned process"}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}static async stop(t=pt){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!L(S))return null;let t=ot(S,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){N(E,{recursive:!0}),st(S,JSON.stringify(t,null,2))}static removePidFile(){try{L(S)&&it(S)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,n=Et){let r=Date.now();for(;Date.now()-rsetTimeout(s,ft))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let n=Date.now();for(;Date.now()-nsetTimeout(r,gt))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return T(x,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),r=Date.now()-e,s=Math.floor(r/1e3),i=Math.floor(s/60),u=Math.floor(i/60),f=Math.floor(u/24);return f>0?`${f}d ${u%24}h`:u>0?`${u}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function I(o={}){let{port:t,includeSkillFallback:e=!1,customPrefix:n}=o,r=process.platform==="win32",s=r?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=r?"Command Prompt or PowerShell":"Terminal",u=n||"Worker service connection failed.",f=t?` (port ${t})`:"",a=`${u}${f} +import{stdin as y}from"process";import A from"path";import{homedir as Ot}from"os";import{spawnSync as At}from"child_process";import{existsSync as Ct,writeFileSync as B,readFileSync as Mt}from"fs";import{readFileSync as Z,writeFileSync as tt,existsSync as et}from"fs";import{join as rt}from"path";import{homedir as nt}from"os";var Q=["bugfix","feature","refactor","discovery","decision","change"],z=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var v=Q.join(","),U=z.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:rt(nt(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:v,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:U,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!et(t))return this.getAllDefaults();let e=Z(t,"utf-8"),r=JSON.parse(e),n=r;if(r.env&&typeof r.env=="object"){n=r.env;try{tt(t,JSON.stringify(n,null,2),"utf-8"),u.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){u.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))n[i]!==void 0&&(s[i]=n[i]);return s}};var C=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(C||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=C[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} +${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let r=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&r.command){let n=r.command.length>50?r.command.substring(0,50)+"...":r.command;return`${t}(${n})`}if(t==="Read"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Edit"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Write"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}return t}catch{return t}}log(t,e,r,n,s){if(t0&&(w=` {${Object.entries(k).map(([J,q])=>`${J}=${q}`).join(", ")}}`)}let P=`[${i}] [${c}] [${E}] ${a}${r}${w}${g}`;t===3?console.error(P):console.log(P)}debug(t,e,r,n){this.log(0,t,e,r,n)}info(t,e,r,n){this.log(1,t,e,r,n)}warn(t,e,r,n){this.log(2,t,e,r,n)}error(t,e,r,n){this.log(3,t,e,r,n)}dataIn(t,e,r,n){this.info(t,`\u2192 ${e}`,r,n)}dataOut(t,e,r,n){this.info(t,`\u2190 ${e}`,r,n)}success(t,e,r,n){this.info(t,`\u2713 ${e}`,r,n)}failure(t,e,r,n){this.error(t,`\u2717 ${e}`,r,n)}timing(t,e,r,n){this.info(t,`\u23F1 ${e}`,n,{duration:`${r}ms`})}},u=new M;var d={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function N(o){return process.platform==="win32"?Math.round(o*d.WINDOWS_MULTIPLIER):o}import{existsSync as I,readFileSync as lt,writeFileSync as pt,unlinkSync as ft,mkdirSync as H}from"fs";import{createWriteStream as Et}from"fs";import{join as T}from"path";import{spawn as mt}from"child_process";import{homedir as gt}from"os";import{join as p,dirname as ot,basename as Xt}from"path";import{homedir as st}from"os";import{fileURLToPath as it}from"url";function at(){return typeof __dirname<"u"?__dirname:ot(it(import.meta.url))}var zt=at(),f=l.get("CLAUDE_MEM_DATA_DIR"),D=process.env.CLAUDE_CONFIG_DIR||p(st(),".claude"),Zt=p(f,"archives"),te=p(f,"logs"),ee=p(f,"trash"),re=p(f,"backups"),ne=p(f,"settings.json"),oe=p(f,"claude-mem.db"),se=p(f,"vector-db"),ie=p(D,"settings.json"),ae=p(D,"commands"),ce=p(D,"CLAUDE.md");import{spawnSync as ct}from"child_process";import{existsSync as ut}from"fs";import{join as x}from"path";import{homedir as $}from"os";function L(){let o=process.platform==="win32";try{if(ct("bun",["--version"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:o}).status===0)return"bun"}catch{}let t=o?[x($(),".bun","bin","bun.exe")]:[x($(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"];for(let e of t)if(ut(e))return e;return null}function W(){return L()!==null}var S=T(f,"worker.pid"),F=T(f,"logs"),K=T(gt(),".claude","plugins","marketplaces","thedotmack"),_t=5e3,dt=1e4,St=200,Tt=1e3,ht=100,h=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};H(F,{recursive:!0});let e=T(K,"plugin","scripts","worker-service.cjs");if(!I(e))return{success:!1,error:`Worker script not found at ${e}`};let r=this.getLogFilePath();return this.startWithBun(e,r,t)}static isBunAvailable(){return W()}static async startWithBun(t,e,r){let n=L();if(!n)return{success:!1,error:"Bun is required but not found in PATH or common installation paths. Install from https://bun.sh"};try{let s=process.platform==="win32",i=mt(n,[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(r)},cwd:K,...s&&{windowsHide:!0}}),c=Et(e,{flags:"a"});return i.stdout?.pipe(c),i.stderr?.pipe(c),i.unref(),i.pid?(this.writePidFile({pid:i.pid,port:r,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(i.pid,r)):{success:!1,error:"Failed to get PID from spawned process"}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}static async stop(t=_t){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!I(S))return null;let t=lt(S,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){H(f,{recursive:!0}),pt(S,JSON.stringify(t,null,2))}static removePidFile(){try{I(S)&&ft(S)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,r=dt){let n=Date.now();for(;Date.now()-nsetTimeout(s,St))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let r=Date.now();for(;Date.now()-rsetTimeout(n,ht))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return T(F,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),n=Date.now()-e,s=Math.floor(n/1e3),i=Math.floor(s/60),c=Math.floor(i/60),E=Math.floor(c/24);return E>0?`${E}d ${c%24}h`:c>0?`${c}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function R(o={}){let{port:t,includeSkillFallback:e=!1,customPrefix:r}=o,n=process.platform==="win32",s=n?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=n?"Command Prompt or PowerShell":"Terminal",c=r||"Worker service connection failed.",E=t?` (port ${t})`:"",a=`${c}${E} `;return a+=`To restart the worker: `,a+=`1. Exit Claude Code completely @@ -9,6 +9,6 @@ ${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Obje `,a+=`3. Navigate to: ${s} `,a+="4. Run: npm run worker:restart",e&&(a+=` -If that doesn't work, try: /troubleshoot`),a}var W=A.join(mt(),".claude","plugins","marketplaces","thedotmack"),K=b(d.HEALTH_CHECK),m=null;function _(){if(m!==null)return m;try{let o=A.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(o);return m=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),m}catch(o){return c.debug("SYSTEM","Failed to load port from settings, using default",{error:o}),m=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),m}}async function R(){try{let o=_();return(await fetch(`http://127.0.0.1:${o}/health`,{signal:AbortSignal.timeout(K)})).ok}catch(o){return c.debug("SYSTEM","Worker health check failed",{error:o instanceof Error?o.message:String(o),errorType:o?.constructor?.name}),!1}}function Ot(){try{let o=A.join(W,"package.json");return JSON.parse(Tt(o,"utf-8")).version}catch(o){return c.debug("SYSTEM","Failed to read plugin version",{error:o instanceof Error?o.message:String(o)}),null}}async function ht(){try{let o=_(),t=await fetch(`http://127.0.0.1:${o}/api/version`,{signal:AbortSignal.timeout(K)});return t.ok?(await t.json()).version:null}catch(o){return c.debug("SYSTEM","Failed to get worker version",{error:o instanceof Error?o.message:String(o)}),null}}async function F(){let o=Ot(),t=await ht();!o||!t||o!==t&&(c.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:o,workerVersion:t}),await O.restart(_()),await new Promise(e=>setTimeout(e,1e3)),await R()||c.error("SYSTEM","Worker failed to restart after version mismatch"))}async function At(){let o=A.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!St(o))try{dt("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),H(o,new Date().toISOString(),"utf-8"),c.debug("SYSTEM","PM2 cleanup completed and marked")}catch{H(o,new Date().toISOString(),"utf-8")}let t=_(),e=await O.start(t);return e.success||c.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:W}),e.success}async function V(){if(await R()){await F();return}if(!await At()){let e=_();throw new Error(I({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(n=>setTimeout(n,500)),await R()){await F();return}let t=_();throw c.error("SYSTEM","Worker started but not responding to health checks"),new Error(I({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}import{appendFileSync as Ct}from"fs";import{homedir as Mt}from"os";import{join as Dt}from"path";var Lt=Dt(Mt(),".claude-mem","silent.log");function h(o,t,e=""){let n=new Date().toISOString(),u=((new Error().stack||"").split(` -`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),f=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",a=`[${n}] [HAPPY-PATH-ERROR] [${f}] ${o}`;if(t!==void 0)try{a+=` ${JSON.stringify(t)}`}catch(g){a+=` [stringify error: ${g}]`}a+=` -`;try{Ct(Lt,a)}catch(g){console.error("[silent-debug] Failed to write to log:",g)}return e}async function j(o){if(await V(),h("[cleanup-hook] Hook fired",{session_id:o?.session_id,reason:o?.reason}),!o)throw new Error("cleanup-hook requires input from Claude Code");let{session_id:t,reason:e}=o,n=_();try{let r=await fetch(`http://127.0.0.1:${n}/api/sessions/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeSessionId:t,reason:e}),signal:AbortSignal.timeout(d.DEFAULT)});if(r.ok){let s=await r.json();h("[cleanup-hook] Session cleanup completed",s)}else h("[cleanup-hook] Session not found or already cleaned up")}catch(r){h("[cleanup-hook] Worker not reachable (non-critical)",{error:r.message})}console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}if(y.isTTY)j(void 0);else{let o="";y.on("data",t=>o+=t),y.on("end",async()=>{let t=o?JSON.parse(o):void 0;await j(t)})} +If that doesn't work, try: /troubleshoot`),a}var V=A.join(Ot(),".claude","plugins","marketplaces","thedotmack"),G=N(d.HEALTH_CHECK),_=null;function m(){if(_!==null)return _;try{let o=A.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(o);return _=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),_}catch(o){return u.debug("SYSTEM","Failed to load port from settings, using default",{error:o}),_=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),_}}async function b(){try{let o=m();return(await fetch(`http://127.0.0.1:${o}/health`,{signal:AbortSignal.timeout(G)})).ok}catch(o){return u.debug("SYSTEM","Worker health check failed",{error:o instanceof Error?o.message:String(o),errorType:o?.constructor?.name}),!1}}function Dt(){try{let o=A.join(V,"package.json");return JSON.parse(Mt(o,"utf-8")).version}catch(o){return u.debug("SYSTEM","Failed to read plugin version",{error:o instanceof Error?o.message:String(o)}),null}}async function Lt(){try{let o=m(),t=await fetch(`http://127.0.0.1:${o}/api/version`,{signal:AbortSignal.timeout(G)});return t.ok?(await t.json()).version:null}catch(o){return u.debug("SYSTEM","Failed to get worker version",{error:o instanceof Error?o.message:String(o)}),null}}async function j(){let o=Dt(),t=await Lt();!o||!t||o!==t&&(u.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:o,workerVersion:t}),await h.restart(m()),await new Promise(e=>setTimeout(e,1e3)),await b()||u.error("SYSTEM","Worker failed to restart after version mismatch"))}async function It(){let o=A.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!Ct(o))try{At("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),B(o,new Date().toISOString(),"utf-8"),u.debug("SYSTEM","PM2 cleanup completed and marked")}catch{B(o,new Date().toISOString(),"utf-8")}let t=m(),e=await h.start(t);return e.success||u.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:V}),e.success}async function X(){if(await b()){await j();return}if(!await It()){let e=m();throw new Error(R({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(r=>setTimeout(r,500)),await b()){await j();return}let t=m();throw u.error("SYSTEM","Worker started but not responding to health checks"),new Error(R({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}import{appendFileSync as Rt}from"fs";import{homedir as bt}from"os";import{join as yt}from"path";var wt=yt(bt(),".claude-mem","silent.log");function O(o,t,e=""){let r=new Date().toISOString(),c=((new Error().stack||"").split(` +`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),E=c?`${c[1].split("/").pop()}:${c[2]}`:"unknown",a=`[${r}] [HAPPY-PATH-ERROR] [${E}] ${o}`;if(t!==void 0)try{a+=` ${JSON.stringify(t)}`}catch(g){a+=` [stringify error: ${g}]`}a+=` +`;try{Rt(wt,a)}catch(g){console.error("[silent-debug] Failed to write to log:",g)}return e}async function Y(o){if(await X(),O("[cleanup-hook] Hook fired",{session_id:o?.session_id,reason:o?.reason}),!o)throw new Error("cleanup-hook requires input from Claude Code");let{session_id:t,reason:e}=o,r=m();try{let n=await fetch(`http://127.0.0.1:${r}/api/sessions/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeSessionId:t,reason:e}),signal:AbortSignal.timeout(d.DEFAULT)});if(n.ok){let s=await n.json();O("[cleanup-hook] Session cleanup completed",s)}else O("[cleanup-hook] Session not found or already cleaned up")}catch(n){O("[cleanup-hook] Worker not reachable (non-critical)",{error:n.message})}console.log('{"continue": true, "suppressOutput": true}'),process.exit(0)}if(y.isTTY)Y(void 0);else{let o="";y.on("data",t=>o+=t),y.on("end",async()=>{let t=o?JSON.parse(o):void 0;await Y(t)})} diff --git a/plugin/scripts/context-hook.js b/plugin/scripts/context-hook.js index 7e092889..1e9d422c 100755 --- a/plugin/scripts/context-hook.js +++ b/plugin/scripts/context-hook.js @@ -1,12 +1,12 @@ #!/usr/bin/env bun -import At from"path";import{stdin as I}from"process";import h from"path";import{homedir as mt}from"os";import{spawnSync as St}from"child_process";import{existsSync as dt,writeFileSync as W,readFileSync as Tt}from"fs";import{readFileSync as J,writeFileSync as q,existsSync as Q}from"fs";import{join as z}from"path";import{homedir as Z}from"os";var X=["bugfix","feature","refactor","discovery","decision","change"],Y=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var P=X.join(","),U=Y.join(",");var u=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:z(Z(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:P,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:U,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!Q(t))return this.getAllDefaults();let e=J(t,"utf-8"),o=JSON.parse(e),r=o;if(o.env&&typeof o.env=="object"){r=o.env;try{q(t,JSON.stringify(r,null,2),"utf-8"),a.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){a.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))r[i]!==void 0&&(s[i]=r[i]);return s}};var A=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(A||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=u.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=A[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} -${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let o=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&o.command){let r=o.command.length>50?o.command.substring(0,50)+"...":o.command;return`${t}(${r})`}if(t==="Read"&&o.file_path){let r=o.file_path.split("/").pop()||o.file_path;return`${t}(${r})`}if(t==="Edit"&&o.file_path){let r=o.file_path.split("/").pop()||o.file_path;return`${t}(${r})`}if(t==="Write"&&o.file_path){let r=o.file_path.split("/").pop()||o.file_path;return`${t}(${r})`}return t}catch{return t}}log(t,e,o,r,s){if(t0&&(w=` {${Object.entries(k).map(([B,G])=>`${B}=${G}`).join(", ")}}`)}let y=`[${i}] [${E}] [${_}] ${c}${o}${w}${C}`;t===3?console.error(y):console.log(y)}debug(t,e,o,r){this.log(0,t,e,o,r)}info(t,e,o,r){this.log(1,t,e,o,r)}warn(t,e,o,r){this.log(2,t,e,o,r)}error(t,e,o,r){this.log(3,t,e,o,r)}dataIn(t,e,o,r){this.info(t,`\u2192 ${e}`,o,r)}dataOut(t,e,o,r){this.info(t,`\u2190 ${e}`,o,r)}success(t,e,o,r){this.info(t,`\u2713 ${e}`,o,r)}failure(t,e,o,r){this.error(t,`\u2717 ${e}`,o,r)}timing(t,e,o,r){this.info(t,`\u23F1 ${e}`,r,{duration:`${o}ms`})}},a=new M;var S={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function v(n){return process.platform==="win32"?Math.round(n*S.WINDOWS_MULTIPLIER):n}import{existsSync as L,readFileSync as ot,writeFileSync as st,unlinkSync as it,mkdirSync as b}from"fs";import{createWriteStream as at}from"fs";import{join as T}from"path";import{spawn as ct,spawnSync as ut}from"child_process";import{homedir as lt}from"os";import{join as l,dirname as tt,basename as Ht}from"path";import{homedir as et}from"os";import{fileURLToPath as rt}from"url";function nt(){return typeof __dirname<"u"?__dirname:tt(rt(import.meta.url))}var Bt=nt(),p=u.get("CLAUDE_MEM_DATA_DIR"),D=process.env.CLAUDE_CONFIG_DIR||l(et(),".claude"),Gt=l(p,"archives"),Xt=l(p,"logs"),Yt=l(p,"trash"),Jt=l(p,"backups"),qt=l(p,"settings.json"),Qt=l(p,"claude-mem.db"),zt=l(p,"vector-db"),Zt=l(D,"settings.json"),te=l(D,"commands"),ee=l(D,"CLAUDE.md");var d=T(p,"worker.pid"),N=T(p,"logs"),x=T(lt(),".claude","plugins","marketplaces","thedotmack"),pt=5e3,Et=1e4,ft=200,gt=1e3,_t=100,O=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};b(N,{recursive:!0});let e=T(x,"plugin","scripts","worker-service.cjs");if(!L(e))return{success:!1,error:`Worker script not found at ${e}`};let o=this.getLogFilePath();return this.startWithBun(e,o,t)}static isBunAvailable(){try{return ut("bun",["--version"],{stdio:"pipe",timeout:5e3}).status===0}catch{return!1}}static async startWithBun(t,e,o){if(!this.isBunAvailable())return{success:!1,error:"Bun is required but not found in PATH. Install from https://bun.sh"};try{let r=process.platform==="win32",s=ct("bun",[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(o)},cwd:x,...r&&{windowsHide:!0}}),i=at(e,{flags:"a"});return s.stdout?.pipe(i),s.stderr?.pipe(i),s.unref(),s.pid?(this.writePidFile({pid:s.pid,port:o,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(s.pid,o)):{success:!1,error:"Failed to get PID from spawned process"}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}static async stop(t=pt){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!L(d))return null;let t=ot(d,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){b(p,{recursive:!0}),st(d,JSON.stringify(t,null,2))}static removePidFile(){try{L(d)&&it(d)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,o=Et){let r=Date.now();for(;Date.now()-rsetTimeout(s,ft))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let o=Date.now();for(;Date.now()-osetTimeout(r,_t))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return T(N,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),r=Date.now()-e,s=Math.floor(r/1e3),i=Math.floor(s/60),E=Math.floor(i/60),_=Math.floor(E/24);return _>0?`${_}d ${E%24}h`:E>0?`${E}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function g(n={}){let{port:t,includeSkillFallback:e=!1,customPrefix:o}=n,r=process.platform==="win32",s=r?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=r?"Command Prompt or PowerShell":"Terminal",E=o||"Worker service connection failed.",_=t?` (port ${t})`:"",c=`${E}${_} +import It from"path";import{stdin as w}from"process";import h from"path";import{homedir as ht}from"os";import{spawnSync as Ct}from"child_process";import{existsSync as At,writeFileSync as K,readFileSync as Mt}from"fs";import{readFileSync as Z,writeFileSync as tt,existsSync as et}from"fs";import{join as rt}from"path";import{homedir as nt}from"os";var Q=["bugfix","feature","refactor","discovery","decision","change"],z=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var k=Q.join(","),v=z.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:rt(nt(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:k,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:v,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!et(t))return this.getAllDefaults();let e=Z(t,"utf-8"),n=JSON.parse(e),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{tt(t,JSON.stringify(o,null,2),"utf-8"),a.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){a.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))o[i]!==void 0&&(s[i]=o[i]);return s}};var A=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(A||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=A[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} +${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let n=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&n.command){let o=n.command.length>50?n.command.substring(0,50)+"...":n.command;return`${t}(${o})`}if(t==="Read"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}if(t==="Edit"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}if(t==="Write"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}return t}catch{return t}}log(t,e,n,o,s){if(t0&&(b=` {${Object.entries(y).map(([J,q])=>`${J}=${q}`).join(", ")}}`)}let P=`[${i}] [${c}] [${g}] ${u}${n}${b}${C}`;t===3?console.error(P):console.log(P)}debug(t,e,n,o){this.log(0,t,e,n,o)}info(t,e,n,o){this.log(1,t,e,n,o)}warn(t,e,n,o){this.log(2,t,e,n,o)}error(t,e,n,o){this.log(3,t,e,n,o)}dataIn(t,e,n,o){this.info(t,`\u2192 ${e}`,n,o)}dataOut(t,e,n,o){this.info(t,`\u2190 ${e}`,n,o)}success(t,e,n,o){this.info(t,`\u2713 ${e}`,n,o)}failure(t,e,n,o){this.error(t,`\u2717 ${e}`,n,o)}timing(t,e,n,o){this.info(t,`\u23F1 ${e}`,o,{duration:`${n}ms`})}},a=new M;var d={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function U(r){return process.platform==="win32"?Math.round(r*d.WINDOWS_MULTIPLIER):r}import{existsSync as R,readFileSync as lt,writeFileSync as pt,unlinkSync as ft,mkdirSync as F}from"fs";import{createWriteStream as Et}from"fs";import{join as T}from"path";import{spawn as mt}from"child_process";import{homedir as gt}from"os";import{join as p,dirname as ot,basename as Vt}from"path";import{homedir as st}from"os";import{fileURLToPath as it}from"url";function at(){return typeof __dirname<"u"?__dirname:ot(it(import.meta.url))}var qt=at(),f=l.get("CLAUDE_MEM_DATA_DIR"),D=process.env.CLAUDE_CONFIG_DIR||p(st(),".claude"),Qt=p(f,"archives"),zt=p(f,"logs"),Zt=p(f,"trash"),te=p(f,"backups"),ee=p(f,"settings.json"),re=p(f,"claude-mem.db"),ne=p(f,"vector-db"),oe=p(D,"settings.json"),se=p(D,"commands"),ie=p(D,"CLAUDE.md");import{spawnSync as ct}from"child_process";import{existsSync as ut}from"fs";import{join as N}from"path";import{homedir as x}from"os";function L(){let r=process.platform==="win32";try{if(ct("bun",["--version"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:r}).status===0)return"bun"}catch{}let t=r?[N(x(),".bun","bin","bun.exe")]:[N(x(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"];for(let e of t)if(ut(e))return e;return null}function W(){return L()!==null}var S=T(f,"worker.pid"),H=T(f,"logs"),$=T(gt(),".claude","plugins","marketplaces","thedotmack"),_t=5e3,dt=1e4,St=200,Tt=1e3,Ot=100,O=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};F(H,{recursive:!0});let e=T($,"plugin","scripts","worker-service.cjs");if(!R(e))return{success:!1,error:`Worker script not found at ${e}`};let n=this.getLogFilePath();return this.startWithBun(e,n,t)}static isBunAvailable(){return W()}static async startWithBun(t,e,n){let o=L();if(!o)return{success:!1,error:"Bun is required but not found in PATH or common installation paths. Install from https://bun.sh"};try{let s=process.platform==="win32",i=mt(o,[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(n)},cwd:$,...s&&{windowsHide:!0}}),c=Et(e,{flags:"a"});return i.stdout?.pipe(c),i.stderr?.pipe(c),i.unref(),i.pid?(this.writePidFile({pid:i.pid,port:n,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(i.pid,n)):{success:!1,error:"Failed to get PID from spawned process"}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}static async stop(t=_t){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!R(S))return null;let t=lt(S,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){F(f,{recursive:!0}),pt(S,JSON.stringify(t,null,2))}static removePidFile(){try{R(S)&&ft(S)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,n=dt){let o=Date.now();for(;Date.now()-osetTimeout(s,St))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let n=Date.now();for(;Date.now()-nsetTimeout(o,Ot))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return T(H,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),o=Date.now()-e,s=Math.floor(o/1e3),i=Math.floor(s/60),c=Math.floor(i/60),g=Math.floor(c/24);return g>0?`${g}d ${c%24}h`:c>0?`${c}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function m(r={}){let{port:t,includeSkillFallback:e=!1,customPrefix:n}=r,o=process.platform==="win32",s=o?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=o?"Command Prompt or PowerShell":"Terminal",c=n||"Worker service connection failed.",g=t?` (port ${t})`:"",u=`${c}${g} -`;return c+=`To restart the worker: -`,c+=`1. Exit Claude Code completely -`,c+=`2. Open ${i} -`,c+=`3. Navigate to: ${s} -`,c+="4. Run: npm run worker:restart",e&&(c+=` +`;return u+=`To restart the worker: +`,u+=`1. Exit Claude Code completely +`,u+=`2. Open ${i} +`,u+=`3. Navigate to: ${s} +`,u+="4. Run: npm run worker:restart",e&&(u+=` -If that doesn't work, try: /troubleshoot`),c}var H=h.join(mt(),".claude","plugins","marketplaces","thedotmack"),$=v(S.HEALTH_CHECK),m=null;function f(){if(m!==null)return m;try{let n=h.join(u.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=u.loadFromFile(n);return m=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),m}catch(n){return a.debug("SYSTEM","Failed to load port from settings, using default",{error:n}),m=parseInt(u.get("CLAUDE_MEM_WORKER_PORT"),10),m}}async function R(){try{let n=f();return(await fetch(`http://127.0.0.1:${n}/health`,{signal:AbortSignal.timeout($)})).ok}catch(n){return a.debug("SYSTEM","Worker health check failed",{error:n instanceof Error?n.message:String(n),errorType:n?.constructor?.name}),!1}}function Ot(){try{let n=h.join(H,"package.json");return JSON.parse(Tt(n,"utf-8")).version}catch(n){return a.debug("SYSTEM","Failed to read plugin version",{error:n instanceof Error?n.message:String(n)}),null}}async function ht(){try{let n=f(),t=await fetch(`http://127.0.0.1:${n}/api/version`,{signal:AbortSignal.timeout($)});return t.ok?(await t.json()).version:null}catch(n){return a.debug("SYSTEM","Failed to get worker version",{error:n instanceof Error?n.message:String(n)}),null}}async function F(){let n=Ot(),t=await ht();!n||!t||n!==t&&(a.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:n,workerVersion:t}),await O.restart(f()),await new Promise(e=>setTimeout(e,1e3)),await R()||a.error("SYSTEM","Worker failed to restart after version mismatch"))}async function Ct(){let n=h.join(u.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!dt(n))try{St("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),W(n,new Date().toISOString(),"utf-8"),a.debug("SYSTEM","PM2 cleanup completed and marked")}catch{W(n,new Date().toISOString(),"utf-8")}let t=f(),e=await O.start(t);return e.success||a.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:H}),e.success}async function K(){if(await R()){await F();return}if(!await Ct()){let e=f();throw new Error(g({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(o=>setTimeout(o,500)),await R()){await F();return}let t=f();throw a.error("SYSTEM","Worker started but not responding to health checks"),new Error(g({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}function j(n){throw n.cause?.code==="ECONNREFUSED"||n.code==="ConnectionRefused"||n.name==="TimeoutError"||n.message?.includes("fetch failed")||n.message?.includes("Unable to connect")?new Error(g()):n}async function V(n){await K();let t=n?.cwd??process.cwd(),e=t?At.basename(t):"unknown-project",r=`http://127.0.0.1:${f()}/api/context/inject?project=${encodeURIComponent(e)}`;try{let s=await fetch(r,{signal:AbortSignal.timeout(S.DEFAULT)});if(!s.ok){let E=await s.text();throw new Error(g({includeSkillFallback:!0}))}return(await s.text()).trim()}catch(s){j(s)}}var Mt=process.argv.includes("--colors");if(I.isTTY||Mt)V(void 0).then(n=>{console.log(n),process.exit(0)});else{let n="";I.on("data",t=>n+=t),I.on("end",async()=>{let t=n.trim()?JSON.parse(n):void 0,e=await V(t);console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:e}})),process.exit(0)})} +If that doesn't work, try: /troubleshoot`),u}var j=h.join(ht(),".claude","plugins","marketplaces","thedotmack"),V=U(d.HEALTH_CHECK),_=null;function E(){if(_!==null)return _;try{let r=h.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(r);return _=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),_}catch(r){return a.debug("SYSTEM","Failed to load port from settings, using default",{error:r}),_=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),_}}async function I(){try{let r=E();return(await fetch(`http://127.0.0.1:${r}/health`,{signal:AbortSignal.timeout(V)})).ok}catch(r){return a.debug("SYSTEM","Worker health check failed",{error:r instanceof Error?r.message:String(r),errorType:r?.constructor?.name}),!1}}function Dt(){try{let r=h.join(j,"package.json");return JSON.parse(Mt(r,"utf-8")).version}catch(r){return a.debug("SYSTEM","Failed to read plugin version",{error:r instanceof Error?r.message:String(r)}),null}}async function Lt(){try{let r=E(),t=await fetch(`http://127.0.0.1:${r}/api/version`,{signal:AbortSignal.timeout(V)});return t.ok?(await t.json()).version:null}catch(r){return a.debug("SYSTEM","Failed to get worker version",{error:r instanceof Error?r.message:String(r)}),null}}async function B(){let r=Dt(),t=await Lt();!r||!t||r!==t&&(a.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:r,workerVersion:t}),await O.restart(E()),await new Promise(e=>setTimeout(e,1e3)),await I()||a.error("SYSTEM","Worker failed to restart after version mismatch"))}async function Rt(){let r=h.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!At(r))try{Ct("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),K(r,new Date().toISOString(),"utf-8"),a.debug("SYSTEM","PM2 cleanup completed and marked")}catch{K(r,new Date().toISOString(),"utf-8")}let t=E(),e=await O.start(t);return e.success||a.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:j}),e.success}async function G(){if(await I()){await B();return}if(!await Rt()){let e=E();throw new Error(m({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(n=>setTimeout(n,500)),await I()){await B();return}let t=E();throw a.error("SYSTEM","Worker started but not responding to health checks"),new Error(m({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}function X(r){throw r.cause?.code==="ECONNREFUSED"||r.code==="ConnectionRefused"||r.name==="TimeoutError"||r.message?.includes("fetch failed")||r.message?.includes("Unable to connect")?new Error(m()):r}async function Y(r){await G();let t=r?.cwd??process.cwd(),e=t?It.basename(t):"unknown-project",o=`http://127.0.0.1:${E()}/api/context/inject?project=${encodeURIComponent(e)}`;try{let s=await fetch(o,{signal:AbortSignal.timeout(d.DEFAULT)});if(!s.ok){let c=await s.text();throw new Error(m({includeSkillFallback:!0}))}return(await s.text()).trim()}catch(s){X(s)}}var wt=process.argv.includes("--colors");if(w.isTTY||wt)Y(void 0).then(r=>{console.log(r),process.exit(0)});else{let r="";w.on("data",t=>r+=t),w.on("end",async()=>{let t=r.trim()?JSON.parse(r):void 0,e=await Y(t);console.log(JSON.stringify({hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:e}})),process.exit(0)})} diff --git a/plugin/scripts/mcp-server.cjs b/plugin/scripts/mcp-server.cjs index 80e22e8d..e5066ef9 100755 --- a/plugin/scripts/mcp-server.cjs +++ b/plugin/scripts/mcp-server.cjs @@ -9,7 +9,7 @@ `)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),d=o?`${o[1].split("/").pop()}:${o[2]}`:"unknown",f=`[${s}] [HAPPY-PATH-ERROR] [${d}] ${a}`;if(e!==void 0)try{f+=` ${JSON.stringify(e)}`}catch(p){f+=` [stringify error: ${p}]`}f+=` `;try{(0,tl.appendFileSync)(Mf,f)}catch(p){console.error("[silent-debug] Failed to write to log:",p)}return t}var Pa=Ia(require("path"),1),As=require("os");var mt=require("fs"),ol=require("path"),ll=require("os");var Ff=["bugfix","feature","refactor","discovery","decision","change"],Lf=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var nl=Ff.join(","),il=Lf.join(",");var ar=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:(0,ol.join)((0,ll.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:nl,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:il,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return this.DEFAULTS[e]}static getInt(e){let t=this.get(e);return parseInt(t,10)}static getBool(e){return this.get(e)==="true"}static loadFromFile(e){if(!(0,mt.existsSync)(e))return this.getAllDefaults();let t=(0,mt.readFileSync)(e,"utf-8"),s=JSON.parse(t),r=s;if(s.env&&typeof s.env=="object"){r=s.env;try{(0,mt.writeFileSync)(e,JSON.stringify(r,null,2),"utf-8"),Ct.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:e})}catch(l){Ct.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:e},l)}}let n={...this.DEFAULTS};for(let l of Object.keys(this.DEFAULTS))r[l]!==void 0&&(n[l]=r[l]);return n}};var ws=(n=>(n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR",n[n.SILENT=4]="SILENT",n))(ws||{}),Os=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let e=ar.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=ws[e]??1}return this.level}correlationId(e,t){return`obs-${e}-${t}`}sessionId(e){return`session-${e}`}formatData(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="object"){if(e instanceof Error)return this.getLevel()===0?`${e.message} ${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let t=Object.keys(e);return t.length===0?"{}":t.length<=3?JSON.stringify(e):`{${t.length} keys: ${t.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,t){if(!t)return e;try{let s=typeof t=="string"?JSON.parse(t):t;if(e==="Bash"&&s.command){let r=s.command.length>50?s.command.substring(0,50)+"...":s.command;return`${e}(${r})`}if(e==="Read"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}if(e==="Edit"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}if(e==="Write"&&s.file_path){let r=s.file_path.split("/").pop()||s.file_path;return`${e}(${r})`}return e}catch{return e}}log(e,t,s,r,n){if(e0&&(m=` {${Object.entries(v).map(([T,P])=>`${T}=${P}`).join(", ")}}`)}let b=`[${l}] [${o}] [${d}] ${f}${s}${m}${p}`;e===3?console.error(b):console.log(b)}debug(e,t,s,r){this.log(0,e,t,s,r)}info(e,t,s,r){this.log(1,e,t,s,r)}warn(e,t,s,r){this.log(2,e,t,s,r)}error(e,t,s,r){this.log(3,e,t,s,r)}dataIn(e,t,s,r){this.info(e,`\u2192 ${t}`,s,r)}dataOut(e,t,s,r){this.info(e,`\u2190 ${t}`,s,r)}success(e,t,s,r){this.info(e,`\u2713 ${t}`,s,r)}failure(e,t,s,r){this.error(e,`\u2717 ${t}`,s,r)}timing(e,t,s,r){this.info(e,`\u23F1 ${t}`,r,{duration:`${s}ms`})}},Ct=new Os;var Rs={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function cl(a){return process.platform==="win32"?Math.round(a*Rs.WINDOWS_MULTIPLIER):a}var xa=require("path");var fl=require("os");var ke=require("path"),ul=require("os");var dl=require("url");var Uf={};function qf(){return typeof __dirname<"u"?__dirname:(0,ke.dirname)((0,dl.fileURLToPath)(Uf.url))}var Mg=qf(),dr=ar.get("CLAUDE_MEM_DATA_DIR"),Ts=process.env.CLAUDE_CONFIG_DIR||(0,ke.join)((0,ul.homedir)(),".claude"),Fg=(0,ke.join)(dr,"archives"),Lg=(0,ke.join)(dr,"logs"),qg=(0,ke.join)(dr,"trash"),Ug=(0,ke.join)(dr,"backups"),Vg=(0,ke.join)(dr,"settings.json"),zg=(0,ke.join)(dr,"claude-mem.db"),Hg=(0,ke.join)(dr,"vector-db"),Zg=(0,ke.join)(Ts,"settings.json"),Bg=(0,ke.join)(Ts,"commands"),Wg=(0,ke.join)(Ts,"CLAUDE.md");var Jg=(0,xa.join)(dr,"worker.pid"),Gg=(0,xa.join)(dr,"logs"),Yg=(0,xa.join)((0,fl.homedir)(),".claude","plugins","marketplaces","thedotmack");var ly=Pa.default.join((0,As.homedir)(),".claude","plugins","marketplaces","thedotmack"),cy=cl(Rs.HEALTH_CHECK),vt=null;function pl(){if(vt!==null)return vt;try{let a=Pa.default.join(ar.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=ar.loadFromFile(a);return vt=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),vt}catch(a){return Ct.debug("SYSTEM","Failed to load port from settings, using default",{error:a}),vt=parseInt(ar.get("CLAUDE_MEM_WORKER_PORT"),10),vt}}function hl(){let a=Pa.default.join((0,As.homedir)(),".claude-mem","settings.json");return ar.loadFromFile(a).CLAUDE_MEM_WORKER_HOST}var Vf=pl(),zf=hl(),wa=`http://${zf}:${Vf}`,Me={search:"/api/search",timeline:"/api/timeline",decisions:"/api/decisions",changes:"/api/changes",how_it_works:"/api/how-it-works",search_observations:"/api/search/observations",search_sessions:"/api/search/sessions",search_user_prompts:"/api/search/prompts",find_by_concept:"/api/search/by-concept",find_by_file:"/api/search/by-file",find_by_type:"/api/search/by-type",get_recent_context:"/api/context/recent",get_context_timeline:"/api/context/timeline",get_timeline_by_query:"/api/timeline/by-query"};async function Fe(a,e){tr("[mcp-server] \u2192 Worker API",{endpoint:a,params:e});try{let t=new URLSearchParams;for(let[l,o]of Object.entries(e))o!=null&&t.append(l,String(o));let s=`${wa}${a}?${t}`,r=await fetch(s);if(!r.ok){let l=await r.text();throw new Error(`Worker API error (${r.status}): ${l}`)}let n=await r.json();return tr("[mcp-server] \u2190 Worker API success",{endpoint:a}),n}catch(t){return tr("[mcp-server] \u2190 Worker API error",{endpoint:a,error:t.message}),{content:[{type:"text",text:`Error calling Worker API: ${t.message}`}],isError:!0}}}async function Hf(){try{return(await fetch(`${wa}/api/health`)).ok}catch{return!1}}var ml=[{name:"search",description:'Unified search across all memory types (observations, sessions, and user prompts) using vector-first semantic search (ChromaDB). Returns combined results from all document types. IMPORTANT: Always use index format first (default) to get an overview with minimal token usage, then use format: "full" only for specific items of interest.',inputSchema:i.object({query:i.string().optional().describe("Natural language search query for semantic ranking via ChromaDB vector search. Optional - omit for date-filtered queries only (Chroma cannot filter by date, requires direct SQLite)."),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED for initial search), "full" for complete details (use only after reviewing index results)'),type:i.enum(["observations","sessions","prompts"]).optional().describe("Filter by document type (observations, sessions, or prompts). Omit to search all types."),obs_type:i.string().optional().describe('Filter observations by type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change). Only applies when type="observations"'),concepts:i.string().optional().describe('Filter by concept tags (single value or comma-separated list). Only applies when type="observations"'),files:i.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match). Only applies when type="observations"'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Me.search;return await Fe(e,a)}},{name:"timeline",description:"Fetch timeline of observations around a specific point in time. Supports two modes: anchor-based (fetch observations before/after a specific observation ID) and query-based (semantic search for anchor point). IMPORTANT: Use anchor_id when you know the specific observation, or query to find an anchor point first.",inputSchema:i.object({query:i.string().optional().describe("Natural language query to find anchor observation (query-based mode). Mutually exclusive with anchor_id."),anchor_id:i.number().optional().describe("Observation ID to use as anchor (anchor-based mode). Mutually exclusive with query."),before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),obs_type:i.string().optional().describe("Filter observations by type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name")}),handler:async a=>{let e=Me.timeline;return await Fe(e,a)}},{name:"decisions",description:"Semantic shortcut for finding architectural, design, and implementation decisions. Optimized for decision-type observations with relevant keyword boosting.",inputSchema:i.object({query:i.string().describe("Natural language query for finding decisions"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.decisions;return await Fe(e,a)}},{name:"changes",description:"Semantic shortcut for finding code changes, refactorings, and modifications. Optimized for change-type observations with relevant keyword boosting.",inputSchema:i.object({query:i.string().describe("Natural language query for finding changes"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.changes;return await Fe(e,a)}},{name:"how_it_works",description:"Semantic shortcut for understanding system architecture, design patterns, and implementation details. Optimized for discovery-type observations with architecture/design keyword boosting.",inputSchema:i.object({query:i.string().describe("Natural language query for understanding how something works"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.how_it_works;return await Fe(e,a)}},{name:"search_observations",description:'[DEPRECATED - Use "search" with type="observations" instead] Search observations (facts/narratives) using FTS5 full-text search. Supports filtering by type, concepts, files, and date range.',inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Me.search_observations;return await Fe(e,a)}},{name:"search_sessions",description:'[DEPRECATED - Use "search" with type="sessions" instead] Search session summaries using FTS5 full-text search. Returns both request_summary and learned_summary fields.',inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Me.search_sessions;return await Fe(e,a)}},{name:"search_user_prompts",description:'[DEPRECATED - Use "search" with type="prompts" instead] Search user prompts using FTS5 full-text search. Searches prompt text only.',inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Me.search_user_prompts;return await Fe(e,a)}},{name:"find_by_concept",description:"Find observations tagged with specific concepts. Returns observations that match any of the provided concept tags.",inputSchema:i.object({concepts:i.string().describe("Concept tag(s) to filter by (single value or comma-separated list)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Me.find_by_concept;return await Fe(e,a)}},{name:"find_by_file",description:"Find observations related to specific file paths. Uses partial matching - searches for file paths containing the provided string.",inputSchema:i.object({files:i.string().describe("File path(s) to filter by (single value or comma-separated list for partial match)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Me.find_by_file;return await Fe(e,a)}},{name:"find_by_type",description:"Find observations of specific types. Returns observations matching any of the provided observation types.",inputSchema:i.object({type:i.string().describe("Observation type(s) to filter by (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Me.find_by_type;return await Fe(e,a)}},{name:"get_recent_context",description:"Get recent session context for timeline display. Returns recent observations, sessions, and user prompts with metadata for building timeline UI.",inputSchema:i.object({limit:i.number().min(1).max(100).default(30).describe("Maximum number of timeline items to return"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.get_recent_context;return await Fe(e,a)}},{name:"get_context_timeline",description:"Get timeline of observations around a specific observation ID. Returns observations before and after the anchor point with metadata for timeline display.",inputSchema:i.object({anchor_id:i.number().describe("Observation ID to use as anchor point"),before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name")}),handler:async a=>{let e=Me.get_context_timeline;return await Fe(e,a)}},{name:"get_timeline_by_query",description:"Combined search + timeline tool. First searches for observations matching the query, then returns timeline around the best match. Useful for finding specific observations and viewing their context.",inputSchema:i.object({query:i.string().describe("Natural language query to find anchor observation"),before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.get_timeline_by_query;return await Fe(e,a)}}],Ds=new va({name:"claude-mem-search-server",version:"1.0.0"},{capabilities:{tools:{}}});Ds.setRequestHandler(za,async()=>({tools:ml.map(a=>({name:a.name,description:a.description,inputSchema:Ps(a.inputSchema)}))}));Ds.setRequestHandler(Ha,async a=>{let e=ml.find(t=>t.name===a.params.name);if(!e)throw new Error(`Unknown tool: ${a.params.name}`);try{return await e.handler(a.params.arguments||{})}catch(t){return{content:[{type:"text",text:`Tool execution failed: ${t.message}`}],isError:!0}}});async function vl(){tr("[mcp-server] Shutting down..."),process.exit(0)}process.on("SIGTERM",vl);process.on("SIGINT",vl);async function Zf(){let a=new ya;await Ds.connect(a),tr("[mcp-server] Claude-mem search server started"),setTimeout(async()=>{await Hf()?tr("[mcp-server] Worker available at",wa):(tr("[mcp-server] WARNING: Worker not available at",wa),tr("[mcp-server] Tools will fail until Worker is started"),tr("[mcp-server] Start Worker with: npm run worker:restart"))},0)}Zf().catch(a=>{tr("[mcp-server] Fatal error:",a),process.exit(1)}); +`+JSON.stringify(n,null,2):p=" "+this.formatData(n));let m="";if(r){let{sessionId:c,sdkSessionId:y,correlationId:_,...v}=r;Object.keys(v).length>0&&(m=` {${Object.entries(v).map(([T,P])=>`${T}=${P}`).join(", ")}}`)}let b=`[${l}] [${o}] [${d}] ${f}${s}${m}${p}`;e===3?console.error(b):console.log(b)}debug(e,t,s,r){this.log(0,e,t,s,r)}info(e,t,s,r){this.log(1,e,t,s,r)}warn(e,t,s,r){this.log(2,e,t,s,r)}error(e,t,s,r){this.log(3,e,t,s,r)}dataIn(e,t,s,r){this.info(e,`\u2192 ${t}`,s,r)}dataOut(e,t,s,r){this.info(e,`\u2190 ${t}`,s,r)}success(e,t,s,r){this.info(e,`\u2713 ${t}`,s,r)}failure(e,t,s,r){this.error(e,`\u2717 ${t}`,s,r)}timing(e,t,s,r){this.info(e,`\u23F1 ${t}`,r,{duration:`${s}ms`})}},Ct=new Os;var Rs={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function cl(a){return process.platform==="win32"?Math.round(a*Rs.WINDOWS_MULTIPLIER):a}var xa=require("path");var fl=require("os");var ke=require("path"),ul=require("os");var dl=require("url");var Uf={};function qf(){return typeof __dirname<"u"?__dirname:(0,ke.dirname)((0,dl.fileURLToPath)(Uf.url))}var Mg=qf(),dr=ar.get("CLAUDE_MEM_DATA_DIR"),Ts=process.env.CLAUDE_CONFIG_DIR||(0,ke.join)((0,ul.homedir)(),".claude"),Fg=(0,ke.join)(dr,"archives"),Lg=(0,ke.join)(dr,"logs"),qg=(0,ke.join)(dr,"trash"),Ug=(0,ke.join)(dr,"backups"),Vg=(0,ke.join)(dr,"settings.json"),zg=(0,ke.join)(dr,"claude-mem.db"),Hg=(0,ke.join)(dr,"vector-db"),Zg=(0,ke.join)(Ts,"settings.json"),Bg=(0,ke.join)(Ts,"commands"),Wg=(0,ke.join)(Ts,"CLAUDE.md");var ey=(0,xa.join)(dr,"worker.pid"),ry=(0,xa.join)(dr,"logs"),ty=(0,xa.join)((0,fl.homedir)(),".claude","plugins","marketplaces","thedotmack");var fy=Pa.default.join((0,As.homedir)(),".claude","plugins","marketplaces","thedotmack"),py=cl(Rs.HEALTH_CHECK),vt=null;function pl(){if(vt!==null)return vt;try{let a=Pa.default.join(ar.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=ar.loadFromFile(a);return vt=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),vt}catch(a){return Ct.debug("SYSTEM","Failed to load port from settings, using default",{error:a}),vt=parseInt(ar.get("CLAUDE_MEM_WORKER_PORT"),10),vt}}function hl(){let a=Pa.default.join((0,As.homedir)(),".claude-mem","settings.json");return ar.loadFromFile(a).CLAUDE_MEM_WORKER_HOST}var Vf=pl(),zf=hl(),wa=`http://${zf}:${Vf}`,Me={search:"/api/search",timeline:"/api/timeline",decisions:"/api/decisions",changes:"/api/changes",how_it_works:"/api/how-it-works",search_observations:"/api/search/observations",search_sessions:"/api/search/sessions",search_user_prompts:"/api/search/prompts",find_by_concept:"/api/search/by-concept",find_by_file:"/api/search/by-file",find_by_type:"/api/search/by-type",get_recent_context:"/api/context/recent",get_context_timeline:"/api/context/timeline",get_timeline_by_query:"/api/timeline/by-query"};async function Fe(a,e){tr("[mcp-server] \u2192 Worker API",{endpoint:a,params:e});try{let t=new URLSearchParams;for(let[l,o]of Object.entries(e))o!=null&&t.append(l,String(o));let s=`${wa}${a}?${t}`,r=await fetch(s);if(!r.ok){let l=await r.text();throw new Error(`Worker API error (${r.status}): ${l}`)}let n=await r.json();return tr("[mcp-server] \u2190 Worker API success",{endpoint:a}),n}catch(t){return tr("[mcp-server] \u2190 Worker API error",{endpoint:a,error:t.message}),{content:[{type:"text",text:`Error calling Worker API: ${t.message}`}],isError:!0}}}async function Hf(){try{return(await fetch(`${wa}/api/health`)).ok}catch{return!1}}var ml=[{name:"search",description:'Unified search across all memory types (observations, sessions, and user prompts) using vector-first semantic search (ChromaDB). Returns combined results from all document types. IMPORTANT: Always use index format first (default) to get an overview with minimal token usage, then use format: "full" only for specific items of interest.',inputSchema:i.object({query:i.string().optional().describe("Natural language search query for semantic ranking via ChromaDB vector search. Optional - omit for date-filtered queries only (Chroma cannot filter by date, requires direct SQLite)."),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED for initial search), "full" for complete details (use only after reviewing index results)'),type:i.enum(["observations","sessions","prompts"]).optional().describe("Filter by document type (observations, sessions, or prompts). Omit to search all types."),obs_type:i.string().optional().describe('Filter observations by type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change). Only applies when type="observations"'),concepts:i.string().optional().describe('Filter by concept tags (single value or comma-separated list). Only applies when type="observations"'),files:i.string().optional().describe('Filter by file paths (single value or comma-separated list for partial match). Only applies when type="observations"'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Me.search;return await Fe(e,a)}},{name:"timeline",description:"Fetch timeline of observations around a specific point in time. Supports two modes: anchor-based (fetch observations before/after a specific observation ID) and query-based (semantic search for anchor point). IMPORTANT: Use anchor_id when you know the specific observation, or query to find an anchor point first.",inputSchema:i.object({query:i.string().optional().describe("Natural language query to find anchor observation (query-based mode). Mutually exclusive with anchor_id."),anchor_id:i.number().optional().describe("Observation ID to use as anchor (anchor-based mode). Mutually exclusive with query."),before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),obs_type:i.string().optional().describe("Filter observations by type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name")}),handler:async a=>{let e=Me.timeline;return await Fe(e,a)}},{name:"decisions",description:"Semantic shortcut for finding architectural, design, and implementation decisions. Optimized for decision-type observations with relevant keyword boosting.",inputSchema:i.object({query:i.string().describe("Natural language query for finding decisions"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.decisions;return await Fe(e,a)}},{name:"changes",description:"Semantic shortcut for finding code changes, refactorings, and modifications. Optimized for change-type observations with relevant keyword boosting.",inputSchema:i.object({query:i.string().describe("Natural language query for finding changes"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.changes;return await Fe(e,a)}},{name:"how_it_works",description:"Semantic shortcut for understanding system architecture, design patterns, and implementation details. Optimized for discovery-type observations with architecture/design keyword boosting.",inputSchema:i.object({query:i.string().describe("Natural language query for understanding how something works"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.how_it_works;return await Fe(e,a)}},{name:"search_observations",description:'[DEPRECATED - Use "search" with type="observations" instead] Search observations (facts/narratives) using FTS5 full-text search. Supports filtering by type, concepts, files, and date range.',inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Me.search_observations;return await Fe(e,a)}},{name:"search_sessions",description:'[DEPRECATED - Use "search" with type="sessions" instead] Search session summaries using FTS5 full-text search. Returns both request_summary and learned_summary fields.',inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Me.search_sessions;return await Fe(e,a)}},{name:"search_user_prompts",description:'[DEPRECATED - Use "search" with type="prompts" instead] Search user prompts using FTS5 full-text search. Searches prompt text only.',inputSchema:i.object({query:i.string().optional().describe("Full-text search query (FTS5)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["relevance","date_desc","date_asc"]).default("relevance").describe("Sort order (relevance only when query provided)")}),handler:async a=>{let e=Me.search_user_prompts;return await Fe(e,a)}},{name:"find_by_concept",description:"Find observations tagged with specific concepts. Returns observations that match any of the provided concept tags.",inputSchema:i.object({concepts:i.string().describe("Concept tag(s) to filter by (single value or comma-separated list)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Me.find_by_concept;return await Fe(e,a)}},{name:"find_by_file",description:"Find observations related to specific file paths. Uses partial matching - searches for file paths containing the provided string.",inputSchema:i.object({files:i.string().describe("File path(s) to filter by (single value or comma-separated list for partial match)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Me.find_by_file;return await Fe(e,a)}},{name:"find_by_type",description:"Find observations of specific types. Returns observations matching any of the provided observation types.",inputSchema:i.object({type:i.string().describe("Observation type(s) to filter by (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)"),limit:i.number().min(1).max(100).default(20).describe("Maximum number of results"),offset:i.number().min(0).default(0).describe("Number of results to skip"),orderBy:i.enum(["date_desc","date_asc"]).default("date_desc").describe("Sort order")}),handler:async a=>{let e=Me.find_by_type;return await Fe(e,a)}},{name:"get_recent_context",description:"Get recent session context for timeline display. Returns recent observations, sessions, and user prompts with metadata for building timeline UI.",inputSchema:i.object({limit:i.number().min(1).max(100).default(30).describe("Maximum number of timeline items to return"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.get_recent_context;return await Fe(e,a)}},{name:"get_context_timeline",description:"Get timeline of observations around a specific observation ID. Returns observations before and after the anchor point with metadata for timeline display.",inputSchema:i.object({anchor_id:i.number().describe("Observation ID to use as anchor point"),before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name")}),handler:async a=>{let e=Me.get_context_timeline;return await Fe(e,a)}},{name:"get_timeline_by_query",description:"Combined search + timeline tool. First searches for observations matching the query, then returns timeline around the best match. Useful for finding specific observations and viewing their context.",inputSchema:i.object({query:i.string().describe("Natural language query to find anchor observation"),before:i.number().min(0).max(100).default(10).describe("Number of observations to fetch before anchor"),after:i.number().min(0).max(100).default(10).describe("Number of observations to fetch after anchor"),format:i.enum(["index","full"]).default("index").describe('Output format: "index" for titles/dates only (default, RECOMMENDED), "full" for complete details'),type:i.string().optional().describe("Filter by observation type (single value or comma-separated list: decision,bugfix,feature,refactor,discovery,change)"),concepts:i.string().optional().describe("Filter by concept tags (single value or comma-separated list)"),files:i.string().optional().describe("Filter by file paths (single value or comma-separated list for partial match)"),project:i.string().optional().describe("Filter by project name"),dateStart:i.union([i.string(),i.number()]).optional().describe("Start date for filtering (ISO string or epoch timestamp)"),dateEnd:i.union([i.string(),i.number()]).optional().describe("End date for filtering (ISO string or epoch timestamp)")}),handler:async a=>{let e=Me.get_timeline_by_query;return await Fe(e,a)}}],Ds=new va({name:"claude-mem-search-server",version:"1.0.0"},{capabilities:{tools:{}}});Ds.setRequestHandler(za,async()=>({tools:ml.map(a=>({name:a.name,description:a.description,inputSchema:Ps(a.inputSchema)}))}));Ds.setRequestHandler(Ha,async a=>{let e=ml.find(t=>t.name===a.params.name);if(!e)throw new Error(`Unknown tool: ${a.params.name}`);try{return await e.handler(a.params.arguments||{})}catch(t){return{content:[{type:"text",text:`Tool execution failed: ${t.message}`}],isError:!0}}});async function vl(){tr("[mcp-server] Shutting down..."),process.exit(0)}process.on("SIGTERM",vl);process.on("SIGINT",vl);async function Zf(){let a=new ya;await Ds.connect(a),tr("[mcp-server] Claude-mem search server started"),setTimeout(async()=>{await Hf()?tr("[mcp-server] Worker available at",wa):(tr("[mcp-server] WARNING: Worker not available at",wa),tr("[mcp-server] Tools will fail until Worker is started"),tr("[mcp-server] Start Worker with: npm run worker:restart"))},0)}Zf().catch(a=>{tr("[mcp-server] Fatal error:",a),process.exit(1)}); /*! Bundled license information: uri-js/dist/es5/uri.all.js: diff --git a/plugin/scripts/new-hook.js b/plugin/scripts/new-hook.js index 7ef72141..e6f24c3d 100755 --- a/plugin/scripts/new-hook.js +++ b/plugin/scripts/new-hook.js @@ -1,14 +1,14 @@ #!/usr/bin/env bun -import yt from"path";import{stdin as G}from"process";function J(n,t,e){return n==="SessionStart"?t&&e.context?{continue:!0,suppressOutput:!0,hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:e.context}}:{continue:!0,suppressOutput:!0}:n==="UserPromptSubmit"||n==="PostToolUse"?{continue:!0,suppressOutput:!0}:n==="Stop"?{continue:!0,suppressOutput:!0}:{continue:t,suppressOutput:!0,...e.reason&&!t?{stopReason:e.reason}:{}}}function C(n,t,e={}){let r=J(n,t,e);return JSON.stringify(r)}import h from"path";import{homedir as Tt}from"os";import{spawnSync as Ot}from"child_process";import{existsSync as ht,writeFileSync as W,readFileSync as At}from"fs";import{readFileSync as z,writeFileSync as Z,existsSync as tt}from"fs";import{join as et}from"path";import{homedir as rt}from"os";var q=["bugfix","feature","refactor","discovery","decision","change"],Q=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var U=q.join(","),v=Q.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:et(rt(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:U,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:v,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!tt(t))return this.getAllDefaults();let e=z(t,"utf-8"),r=JSON.parse(e),o=r;if(r.env&&typeof r.env=="object"){o=r.env;try{Z(t,JSON.stringify(o,null,2),"utf-8"),p.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(a){p.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},a)}}let s={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))o[a]!==void 0&&(s[a]=o[a]);return s}};var M=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(M||{}),D=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=M[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} -${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let r=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&r.command){let o=r.command.length>50?r.command.substring(0,50)+"...":r.command;return`${t}(${o})`}if(t==="Read"&&r.file_path){let o=r.file_path.split("/").pop()||r.file_path;return`${t}(${o})`}if(t==="Edit"&&r.file_path){let o=r.file_path.split("/").pop()||r.file_path;return`${t}(${o})`}if(t==="Write"&&r.file_path){let o=r.file_path.split("/").pop()||r.file_path;return`${t}(${o})`}return t}catch{return t}}log(t,e,r,o,s){if(t0&&(A=` {${Object.entries(P).map(([X,Y])=>`${X}=${Y}`).join(", ")}}`)}let b=`[${a}] [${c}] [${E}] ${i}${r}${A}${u}`;t===3?console.error(b):console.log(b)}debug(t,e,r,o){this.log(0,t,e,r,o)}info(t,e,r,o){this.log(1,t,e,r,o)}warn(t,e,r,o){this.log(2,t,e,r,o)}error(t,e,r,o){this.log(3,t,e,r,o)}dataIn(t,e,r,o){this.info(t,`\u2192 ${e}`,r,o)}dataOut(t,e,r,o){this.info(t,`\u2190 ${e}`,r,o)}success(t,e,r,o){this.info(t,`\u2713 ${e}`,r,o)}failure(t,e,r,o){this.error(t,`\u2717 ${e}`,r,o)}timing(t,e,r,o){this.info(t,`\u23F1 ${e}`,o,{duration:`${r}ms`})}},p=new D;var L={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function N(n){return process.platform==="win32"?Math.round(n*L.WINDOWS_MULTIPLIER):n}import{existsSync as I,readFileSync as at,writeFileSync as ct,unlinkSync as ut,mkdirSync as x}from"fs";import{createWriteStream as pt}from"fs";import{join as T}from"path";import{spawn as lt,spawnSync as ft}from"child_process";import{homedir as mt}from"os";import{join as f,dirname as nt,basename as Yt}from"path";import{homedir as ot}from"os";import{fileURLToPath as st}from"url";function it(){return typeof __dirname<"u"?__dirname:nt(st(import.meta.url))}var Zt=it(),m=l.get("CLAUDE_MEM_DATA_DIR"),R=process.env.CLAUDE_CONFIG_DIR||f(ot(),".claude"),te=f(m,"archives"),ee=f(m,"logs"),re=f(m,"trash"),ne=f(m,"backups"),oe=f(m,"settings.json"),se=f(m,"claude-mem.db"),ie=f(m,"vector-db"),ae=f(R,"settings.json"),ce=f(R,"commands"),ue=f(R,"CLAUDE.md");var d=T(m,"worker.pid"),H=T(m,"logs"),$=T(mt(),".claude","plugins","marketplaces","thedotmack"),Et=5e3,gt=1e4,_t=200,St=1e3,dt=100,O=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};x(H,{recursive:!0});let e=T($,"plugin","scripts","worker-service.cjs");if(!I(e))return{success:!1,error:`Worker script not found at ${e}`};let r=this.getLogFilePath();return this.startWithBun(e,r,t)}static isBunAvailable(){try{return ft("bun",["--version"],{stdio:"pipe",timeout:5e3}).status===0}catch{return!1}}static async startWithBun(t,e,r){if(!this.isBunAvailable())return{success:!1,error:"Bun is required but not found in PATH. Install from https://bun.sh"};try{let o=process.platform==="win32",s=lt("bun",[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(r)},cwd:$,...o&&{windowsHide:!0}}),a=pt(e,{flags:"a"});return s.stdout?.pipe(a),s.stderr?.pipe(a),s.unref(),s.pid?(this.writePidFile({pid:s.pid,port:r,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(s.pid,r)):{success:!1,error:"Failed to get PID from spawned process"}}catch(o){return{success:!1,error:o instanceof Error?o.message:String(o)}}}static async stop(t=Et){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!I(d))return null;let t=at(d,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){x(m,{recursive:!0}),ct(d,JSON.stringify(t,null,2))}static removePidFile(){try{I(d)&&ut(d)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,r=gt){let o=Date.now();for(;Date.now()-osetTimeout(s,_t))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let r=Date.now();for(;Date.now()-rsetTimeout(o,dt))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return T(H,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),o=Date.now()-e,s=Math.floor(o/1e3),a=Math.floor(s/60),c=Math.floor(a/60),E=Math.floor(c/24);return E>0?`${E}d ${c%24}h`:c>0?`${c}h ${a%60}m`:a>0?`${a}m ${s%60}s`:`${s}s`}};function g(n={}){let{port:t,includeSkillFallback:e=!1,customPrefix:r}=n,o=process.platform==="win32",s=o?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",a=o?"Command Prompt or PowerShell":"Terminal",c=r||"Worker service connection failed.",E=t?` (port ${t})`:"",i=`${c}${E} +import vt from"path";import{stdin as q}from"process";function Z(r,t,e){return r==="SessionStart"?t&&e.context?{continue:!0,suppressOutput:!0,hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:e.context}}:{continue:!0,suppressOutput:!0}:r==="UserPromptSubmit"||r==="PostToolUse"?{continue:!0,suppressOutput:!0}:r==="Stop"?{continue:!0,suppressOutput:!0}:{continue:t,suppressOutput:!0,...e.reason&&!t?{stopReason:e.reason}:{}}}function C(r,t,e={}){let n=Z(r,t,e);return JSON.stringify(n)}import O from"path";import{homedir as Mt}from"os";import{spawnSync as Dt}from"child_process";import{existsSync as bt,writeFileSync as j,readFileSync as Lt}from"fs";import{readFileSync as rt,writeFileSync as nt,existsSync as ot}from"fs";import{join as st}from"path";import{homedir as it}from"os";var tt=["bugfix","feature","refactor","discovery","decision","change"],et=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var v=tt.join(","),N=et.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:st(it(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:v,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:N,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!ot(t))return this.getAllDefaults();let e=rt(t,"utf-8"),n=JSON.parse(e),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{nt(t,JSON.stringify(o,null,2),"utf-8"),p.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){p.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))o[i]!==void 0&&(s[i]=o[i]);return s}};var M=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(M||{}),D=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=M[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} +${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let n=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&n.command){let o=n.command.length>50?n.command.substring(0,50)+"...":n.command;return`${t}(${o})`}if(t==="Read"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}if(t==="Edit"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}if(t==="Write"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}return t}catch{return t}}log(t,e,n,o,s){if(t0&&(A=` {${Object.entries(U).map(([Q,z])=>`${Q}=${z}`).join(", ")}}`)}let P=`[${i}] [${c}] [${g}] ${a}${n}${A}${u}`;t===3?console.error(P):console.log(P)}debug(t,e,n,o){this.log(0,t,e,n,o)}info(t,e,n,o){this.log(1,t,e,n,o)}warn(t,e,n,o){this.log(2,t,e,n,o)}error(t,e,n,o){this.log(3,t,e,n,o)}dataIn(t,e,n,o){this.info(t,`\u2192 ${e}`,n,o)}dataOut(t,e,n,o){this.info(t,`\u2190 ${e}`,n,o)}success(t,e,n,o){this.info(t,`\u2713 ${e}`,n,o)}failure(t,e,n,o){this.error(t,`\u2717 ${e}`,n,o)}timing(t,e,n,o){this.info(t,`\u23F1 ${e}`,o,{duration:`${n}ms`})}},p=new D;var b={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function x(r){return process.platform==="win32"?Math.round(r*b.WINDOWS_MULTIPLIER):r}import{existsSync as w,readFileSync as mt,writeFileSync as gt,unlinkSync as Et,mkdirSync as F}from"fs";import{createWriteStream as _t}from"fs";import{join as T}from"path";import{spawn as dt}from"child_process";import{homedir as St}from"os";import{join as f,dirname as at,basename as Zt}from"path";import{homedir as ct}from"os";import{fileURLToPath as ut}from"url";function pt(){return typeof __dirname<"u"?__dirname:at(ut(import.meta.url))}var oe=pt(),m=l.get("CLAUDE_MEM_DATA_DIR"),L=process.env.CLAUDE_CONFIG_DIR||f(ct(),".claude"),se=f(m,"archives"),ie=f(m,"logs"),ae=f(m,"trash"),ce=f(m,"backups"),ue=f(m,"settings.json"),pe=f(m,"claude-mem.db"),le=f(m,"vector-db"),fe=f(L,"settings.json"),me=f(L,"commands"),ge=f(L,"CLAUDE.md");import{spawnSync as lt}from"child_process";import{existsSync as ft}from"fs";import{join as $}from"path";import{homedir as H}from"os";function R(){let r=process.platform==="win32";try{if(lt("bun",["--version"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:r}).status===0)return"bun"}catch{}let t=r?[$(H(),".bun","bin","bun.exe")]:[$(H(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"];for(let e of t)if(ft(e))return e;return null}function W(){return R()!==null}var S=T(m,"worker.pid"),K=T(m,"logs"),B=T(St(),".claude","plugins","marketplaces","thedotmack"),Tt=5e3,ht=1e4,Ot=200,At=1e3,Ct=100,h=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};F(K,{recursive:!0});let e=T(B,"plugin","scripts","worker-service.cjs");if(!w(e))return{success:!1,error:`Worker script not found at ${e}`};let n=this.getLogFilePath();return this.startWithBun(e,n,t)}static isBunAvailable(){return W()}static async startWithBun(t,e,n){let o=R();if(!o)return{success:!1,error:"Bun is required but not found in PATH or common installation paths. Install from https://bun.sh"};try{let s=process.platform==="win32",i=dt(o,[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(n)},cwd:B,...s&&{windowsHide:!0}}),c=_t(e,{flags:"a"});return i.stdout?.pipe(c),i.stderr?.pipe(c),i.unref(),i.pid?(this.writePidFile({pid:i.pid,port:n,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(i.pid,n)):{success:!1,error:"Failed to get PID from spawned process"}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}static async stop(t=Tt){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!w(S))return null;let t=mt(S,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){F(m,{recursive:!0}),gt(S,JSON.stringify(t,null,2))}static removePidFile(){try{w(S)&&Et(S)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,n=ht){let o=Date.now();for(;Date.now()-osetTimeout(s,Ot))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let n=Date.now();for(;Date.now()-nsetTimeout(o,Ct))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return T(K,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),o=Date.now()-e,s=Math.floor(o/1e3),i=Math.floor(s/60),c=Math.floor(i/60),g=Math.floor(c/24);return g>0?`${g}d ${c%24}h`:c>0?`${c}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function E(r={}){let{port:t,includeSkillFallback:e=!1,customPrefix:n}=r,o=process.platform==="win32",s=o?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=o?"Command Prompt or PowerShell":"Terminal",c=n||"Worker service connection failed.",g=t?` (port ${t})`:"",a=`${c}${g} -`;return i+=`To restart the worker: -`,i+=`1. Exit Claude Code completely -`,i+=`2. Open ${a} -`,i+=`3. Navigate to: ${s} -`,i+="4. Run: npm run worker:restart",e&&(i+=` +`;return a+=`To restart the worker: +`,a+=`1. Exit Claude Code completely +`,a+=`2. Open ${i} +`,a+=`3. Navigate to: ${s} +`,a+="4. Run: npm run worker:restart",e&&(a+=` -If that doesn't work, try: /troubleshoot`),i}var K=h.join(Tt(),".claude","plugins","marketplaces","thedotmack"),j=N(L.HEALTH_CHECK),S=null;function _(){if(S!==null)return S;try{let n=h.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(n);return S=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),S}catch(n){return p.debug("SYSTEM","Failed to load port from settings, using default",{error:n}),S=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),S}}async function k(){try{let n=_();return(await fetch(`http://127.0.0.1:${n}/health`,{signal:AbortSignal.timeout(j)})).ok}catch(n){return p.debug("SYSTEM","Worker health check failed",{error:n instanceof Error?n.message:String(n),errorType:n?.constructor?.name}),!1}}function Ct(){try{let n=h.join(K,"package.json");return JSON.parse(At(n,"utf-8")).version}catch(n){return p.debug("SYSTEM","Failed to read plugin version",{error:n instanceof Error?n.message:String(n)}),null}}async function Mt(){try{let n=_(),t=await fetch(`http://127.0.0.1:${n}/api/version`,{signal:AbortSignal.timeout(j)});return t.ok?(await t.json()).version:null}catch(n){return p.debug("SYSTEM","Failed to get worker version",{error:n instanceof Error?n.message:String(n)}),null}}async function F(){let n=Ct(),t=await Mt();!n||!t||n!==t&&(p.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:n,workerVersion:t}),await O.restart(_()),await new Promise(e=>setTimeout(e,1e3)),await k()||p.error("SYSTEM","Worker failed to restart after version mismatch"))}async function Dt(){let n=h.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!ht(n))try{Ot("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),W(n,new Date().toISOString(),"utf-8"),p.debug("SYSTEM","PM2 cleanup completed and marked")}catch{W(n,new Date().toISOString(),"utf-8")}let t=_(),e=await O.start(t);return e.success||p.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:K}),e.success}async function V(){if(await k()){await F();return}if(!await Dt()){let e=_();throw new Error(g({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(r=>setTimeout(r,500)),await k()){await F();return}let t=_();throw p.error("SYSTEM","Worker started but not responding to health checks"),new Error(g({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}import{appendFileSync as Lt}from"fs";import{homedir as Rt}from"os";import{join as It}from"path";var kt=It(Rt(),".claude-mem","silent.log");function B(n,t,e=""){let r=new Date().toISOString(),c=((new Error().stack||"").split(` -`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),E=c?`${c[1].split("/").pop()}:${c[2]}`:"unknown",i=`[${r}] [HAPPY-PATH-ERROR] [${E}] ${n}`;if(t!==void 0)try{i+=` ${JSON.stringify(t)}`}catch(u){i+=` [stringify error: ${u}]`}i+=` -`;try{Lt(kt,i)}catch(u){console.error("[silent-debug] Failed to write to log:",u)}return e}function y(n){throw n.cause?.code==="ECONNREFUSED"||n.code==="ConnectionRefused"||n.name==="TimeoutError"||n.message?.includes("fetch failed")||n.message?.includes("Unable to connect")?new Error(g()):n}async function wt(n){if(await V(),!n)throw new Error("newHook requires input");let{session_id:t,cwd:e,prompt:r}=n,o=yt.basename(e);B("[new-hook] Input received",{session_id:t,project:o,prompt_length:r?.length});let s=_(),a,c;try{let i=await fetch(`http://127.0.0.1:${s}/api/sessions/init`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeSessionId:t,project:o,prompt:r}),signal:AbortSignal.timeout(5e3)});if(!i.ok){let A=await i.text();throw new Error(g({includeSkillFallback:!0}))}let u=await i.json();if(a=u.sessionDbId,c=u.promptNumber,u.skipped&&u.reason==="private"){console.error(`[new-hook] Session ${a}, prompt #${c} (fully private - skipped)`),console.log(C("UserPromptSubmit",!0));return}console.error(`[new-hook] Session ${a}, prompt #${c}`)}catch(i){y(i)}let E=r.startsWith("/")?r.substring(1):r;try{let i=await fetch(`http://127.0.0.1:${s}/sessions/${a}/init`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userPrompt:E,promptNumber:c}),signal:AbortSignal.timeout(5e3)});if(!i.ok){let u=await i.text();throw new Error(g({includeSkillFallback:!0}))}}catch(i){y(i)}console.log(C("UserPromptSubmit",!0))}var w="";G.on("data",n=>w+=n);G.on("end",async()=>{let n=w?JSON.parse(w):void 0;await wt(n)}); +If that doesn't work, try: /troubleshoot`),a}var G=O.join(Mt(),".claude","plugins","marketplaces","thedotmack"),X=x(b.HEALTH_CHECK),d=null;function _(){if(d!==null)return d;try{let r=O.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(r);return d=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),d}catch(r){return p.debug("SYSTEM","Failed to load port from settings, using default",{error:r}),d=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),d}}async function I(){try{let r=_();return(await fetch(`http://127.0.0.1:${r}/health`,{signal:AbortSignal.timeout(X)})).ok}catch(r){return p.debug("SYSTEM","Worker health check failed",{error:r instanceof Error?r.message:String(r),errorType:r?.constructor?.name}),!1}}function Rt(){try{let r=O.join(G,"package.json");return JSON.parse(Lt(r,"utf-8")).version}catch(r){return p.debug("SYSTEM","Failed to read plugin version",{error:r instanceof Error?r.message:String(r)}),null}}async function wt(){try{let r=_(),t=await fetch(`http://127.0.0.1:${r}/api/version`,{signal:AbortSignal.timeout(X)});return t.ok?(await t.json()).version:null}catch(r){return p.debug("SYSTEM","Failed to get worker version",{error:r instanceof Error?r.message:String(r)}),null}}async function V(){let r=Rt(),t=await wt();!r||!t||r!==t&&(p.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:r,workerVersion:t}),await h.restart(_()),await new Promise(e=>setTimeout(e,1e3)),await I()||p.error("SYSTEM","Worker failed to restart after version mismatch"))}async function It(){let r=O.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!bt(r))try{Dt("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),j(r,new Date().toISOString(),"utf-8"),p.debug("SYSTEM","PM2 cleanup completed and marked")}catch{j(r,new Date().toISOString(),"utf-8")}let t=_(),e=await h.start(t);return e.success||p.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:G}),e.success}async function Y(){if(await I()){await V();return}if(!await It()){let e=_();throw new Error(E({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(n=>setTimeout(n,500)),await I()){await V();return}let t=_();throw p.error("SYSTEM","Worker started but not responding to health checks"),new Error(E({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}import{appendFileSync as kt}from"fs";import{homedir as yt}from"os";import{join as Pt}from"path";var Ut=Pt(yt(),".claude-mem","silent.log");function J(r,t,e=""){let n=new Date().toISOString(),c=((new Error().stack||"").split(` +`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),g=c?`${c[1].split("/").pop()}:${c[2]}`:"unknown",a=`[${n}] [HAPPY-PATH-ERROR] [${g}] ${r}`;if(t!==void 0)try{a+=` ${JSON.stringify(t)}`}catch(u){a+=` [stringify error: ${u}]`}a+=` +`;try{kt(Ut,a)}catch(u){console.error("[silent-debug] Failed to write to log:",u)}return e}function k(r){throw r.cause?.code==="ECONNREFUSED"||r.code==="ConnectionRefused"||r.name==="TimeoutError"||r.message?.includes("fetch failed")||r.message?.includes("Unable to connect")?new Error(E()):r}async function Nt(r){if(await Y(),!r)throw new Error("newHook requires input");let{session_id:t,cwd:e,prompt:n}=r,o=vt.basename(e);J("[new-hook] Input received",{session_id:t,project:o,prompt_length:n?.length});let s=_(),i,c;try{let a=await fetch(`http://127.0.0.1:${s}/api/sessions/init`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeSessionId:t,project:o,prompt:n}),signal:AbortSignal.timeout(5e3)});if(!a.ok){let A=await a.text();throw new Error(E({includeSkillFallback:!0}))}let u=await a.json();if(i=u.sessionDbId,c=u.promptNumber,u.skipped&&u.reason==="private"){console.error(`[new-hook] Session ${i}, prompt #${c} (fully private - skipped)`),console.log(C("UserPromptSubmit",!0));return}console.error(`[new-hook] Session ${i}, prompt #${c}`)}catch(a){k(a)}let g=n.startsWith("/")?n.substring(1):n;try{let a=await fetch(`http://127.0.0.1:${s}/sessions/${i}/init`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userPrompt:g,promptNumber:c}),signal:AbortSignal.timeout(5e3)});if(!a.ok){let u=await a.text();throw new Error(E({includeSkillFallback:!0}))}}catch(a){k(a)}console.log(C("UserPromptSubmit",!0))}var y="";q.on("data",r=>y+=r);q.on("end",async()=>{let r=y?JSON.parse(y):void 0;await Nt(r)}); diff --git a/plugin/scripts/save-hook.js b/plugin/scripts/save-hook.js index 002fbe12..7d9d2d4b 100755 --- a/plugin/scripts/save-hook.js +++ b/plugin/scripts/save-hook.js @@ -1,7 +1,7 @@ #!/usr/bin/env bun -import{stdin as G}from"process";function J(r,t,e){return r==="SessionStart"?t&&e.context?{continue:!0,suppressOutput:!0,hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:e.context}}:{continue:!0,suppressOutput:!0}:r==="UserPromptSubmit"||r==="PostToolUse"?{continue:!0,suppressOutput:!0}:r==="Stop"?{continue:!0,suppressOutput:!0}:{continue:t,suppressOutput:!0,...e.reason&&!t?{stopReason:e.reason}:{}}}function w(r,t,e={}){let o=J(r,t,e);return JSON.stringify(o)}import{readFileSync as z,writeFileSync as Z,existsSync as tt}from"fs";import{join as et}from"path";import{homedir as rt}from"os";var q=["bugfix","feature","refactor","discovery","decision","change"],Q=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var U=q.join(","),b=Q.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:et(rt(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:U,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:b,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!tt(t))return this.getAllDefaults();let e=z(t,"utf-8"),o=JSON.parse(e),n=o;if(o.env&&typeof o.env=="object"){n=o.env;try{Z(t,JSON.stringify(n,null,2),"utf-8"),c.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){c.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))n[i]!==void 0&&(s[i]=n[i]);return s}};var C=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(C||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=C[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} -${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let o=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&o.command){let n=o.command.length>50?o.command.substring(0,50)+"...":o.command;return`${t}(${n})`}if(t==="Read"&&o.file_path){let n=o.file_path.split("/").pop()||o.file_path;return`${t}(${n})`}if(t==="Edit"&&o.file_path){let n=o.file_path.split("/").pop()||o.file_path;return`${t}(${n})`}if(t==="Write"&&o.file_path){let n=o.file_path.split("/").pop()||o.file_path;return`${t}(${n})`}return t}catch{return t}}log(t,e,o,n,s){if(t0&&(y=` {${Object.entries(P).map(([X,Y])=>`${X}=${Y}`).join(", ")}}`)}let k=`[${i}] [${u}] [${p}] ${a}${o}${y}${m}`;t===3?console.error(k):console.log(k)}debug(t,e,o,n){this.log(0,t,e,o,n)}info(t,e,o,n){this.log(1,t,e,o,n)}warn(t,e,o,n){this.log(2,t,e,o,n)}error(t,e,o,n){this.log(3,t,e,o,n)}dataIn(t,e,o,n){this.info(t,`\u2192 ${e}`,o,n)}dataOut(t,e,o,n){this.info(t,`\u2190 ${e}`,o,n)}success(t,e,o,n){this.info(t,`\u2713 ${e}`,o,n)}failure(t,e,o,n){this.error(t,`\u2717 ${e}`,o,n)}timing(t,e,o,n){this.info(t,`\u23F1 ${e}`,n,{duration:`${o}ms`})}},c=new M;import A from"path";import{homedir as Tt}from"os";import{spawnSync as Ot}from"child_process";import{existsSync as ht,writeFileSync as $,readFileSync as At}from"fs";var d={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function v(r){return process.platform==="win32"?Math.round(r*d.WINDOWS_MULTIPLIER):r}import{existsSync as L,readFileSync as at,writeFileSync as ct,unlinkSync as ut,mkdirSync as N}from"fs";import{createWriteStream as pt}from"fs";import{join as O}from"path";import{spawn as lt,spawnSync as ft}from"child_process";import{homedir as Et}from"os";import{join as f,dirname as ot,basename as Xt}from"path";import{homedir as nt}from"os";import{fileURLToPath as st}from"url";function it(){return typeof __dirname<"u"?__dirname:ot(st(import.meta.url))}var zt=it(),E=l.get("CLAUDE_MEM_DATA_DIR"),D=process.env.CLAUDE_CONFIG_DIR||f(nt(),".claude"),Zt=f(E,"archives"),te=f(E,"logs"),ee=f(E,"trash"),re=f(E,"backups"),oe=f(E,"settings.json"),ne=f(E,"claude-mem.db"),se=f(E,"vector-db"),ie=f(D,"settings.json"),ae=f(D,"commands"),ce=f(D,"CLAUDE.md");var T=O(E,"worker.pid"),x=O(E,"logs"),H=O(Et(),".claude","plugins","marketplaces","thedotmack"),gt=5e3,mt=1e4,_t=200,St=1e3,dt=100,h=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};N(x,{recursive:!0});let e=O(H,"plugin","scripts","worker-service.cjs");if(!L(e))return{success:!1,error:`Worker script not found at ${e}`};let o=this.getLogFilePath();return this.startWithBun(e,o,t)}static isBunAvailable(){try{return ft("bun",["--version"],{stdio:"pipe",timeout:5e3}).status===0}catch{return!1}}static async startWithBun(t,e,o){if(!this.isBunAvailable())return{success:!1,error:"Bun is required but not found in PATH. Install from https://bun.sh"};try{let n=process.platform==="win32",s=lt("bun",[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(o)},cwd:H,...n&&{windowsHide:!0}}),i=pt(e,{flags:"a"});return s.stdout?.pipe(i),s.stderr?.pipe(i),s.unref(),s.pid?(this.writePidFile({pid:s.pid,port:o,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(s.pid,o)):{success:!1,error:"Failed to get PID from spawned process"}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}static async stop(t=gt){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!L(T))return null;let t=at(T,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){N(E,{recursive:!0}),ct(T,JSON.stringify(t,null,2))}static removePidFile(){try{L(T)&&ut(T)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,o=mt){let n=Date.now();for(;Date.now()-nsetTimeout(s,_t))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let o=Date.now();for(;Date.now()-osetTimeout(n,dt))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return O(x,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),n=Date.now()-e,s=Math.floor(n/1e3),i=Math.floor(s/60),u=Math.floor(i/60),p=Math.floor(u/24);return p>0?`${p}d ${u%24}h`:u>0?`${u}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function _(r={}){let{port:t,includeSkillFallback:e=!1,customPrefix:o}=r,n=process.platform==="win32",s=n?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=n?"Command Prompt or PowerShell":"Terminal",u=o||"Worker service connection failed.",p=t?` (port ${t})`:"",a=`${u}${p} +import{stdin as q}from"process";function Z(r,t,e){return r==="SessionStart"?t&&e.context?{continue:!0,suppressOutput:!0,hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:e.context}}:{continue:!0,suppressOutput:!0}:r==="UserPromptSubmit"||r==="PostToolUse"?{continue:!0,suppressOutput:!0}:r==="Stop"?{continue:!0,suppressOutput:!0}:{continue:t,suppressOutput:!0,...e.reason&&!t?{stopReason:e.reason}:{}}}function k(r,t,e={}){let n=Z(r,t,e);return JSON.stringify(n)}import{readFileSync as rt,writeFileSync as nt,existsSync as ot}from"fs";import{join as st}from"path";import{homedir as it}from"os";var tt=["bugfix","feature","refactor","discovery","decision","change"],et=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var U=tt.join(","),v=et.join(",");var p=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:st(it(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:U,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:v,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!ot(t))return this.getAllDefaults();let e=rt(t,"utf-8"),n=JSON.parse(e),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{nt(t,JSON.stringify(o,null,2),"utf-8"),c.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){c.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))o[i]!==void 0&&(s[i]=o[i]);return s}};var C=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(C||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=p.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=C[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} +${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let n=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&n.command){let o=n.command.length>50?n.command.substring(0,50)+"...":n.command;return`${t}(${o})`}if(t==="Read"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}if(t==="Edit"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}if(t==="Write"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}return t}catch{return t}}log(t,e,n,o,s){if(t0&&(I=` {${Object.entries(P).map(([Q,z])=>`${Q}=${z}`).join(", ")}}`)}let y=`[${i}] [${u}] [${l}] ${a}${n}${I}${g}`;t===3?console.error(y):console.log(y)}debug(t,e,n,o){this.log(0,t,e,n,o)}info(t,e,n,o){this.log(1,t,e,n,o)}warn(t,e,n,o){this.log(2,t,e,n,o)}error(t,e,n,o){this.log(3,t,e,n,o)}dataIn(t,e,n,o){this.info(t,`\u2192 ${e}`,n,o)}dataOut(t,e,n,o){this.info(t,`\u2190 ${e}`,n,o)}success(t,e,n,o){this.info(t,`\u2713 ${e}`,n,o)}failure(t,e,n,o){this.error(t,`\u2717 ${e}`,n,o)}timing(t,e,n,o){this.info(t,`\u23F1 ${e}`,o,{duration:`${n}ms`})}},c=new M;import A from"path";import{homedir as Mt}from"os";import{spawnSync as Dt}from"child_process";import{existsSync as Lt,writeFileSync as B,readFileSync as Rt}from"fs";var S={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function N(r){return process.platform==="win32"?Math.round(r*S.WINDOWS_MULTIPLIER):r}import{existsSync as R,readFileSync as mt,writeFileSync as Et,unlinkSync as gt,mkdirSync as W}from"fs";import{createWriteStream as _t}from"fs";import{join as O}from"path";import{spawn as dt}from"child_process";import{homedir as St}from"os";import{join as f,dirname as at,basename as zt}from"path";import{homedir as ct}from"os";import{fileURLToPath as ut}from"url";function lt(){return typeof __dirname<"u"?__dirname:at(ut(import.meta.url))}var ne=lt(),m=p.get("CLAUDE_MEM_DATA_DIR"),D=process.env.CLAUDE_CONFIG_DIR||f(ct(),".claude"),oe=f(m,"archives"),se=f(m,"logs"),ie=f(m,"trash"),ae=f(m,"backups"),ce=f(m,"settings.json"),ue=f(m,"claude-mem.db"),le=f(m,"vector-db"),pe=f(D,"settings.json"),fe=f(D,"commands"),me=f(D,"CLAUDE.md");import{spawnSync as pt}from"child_process";import{existsSync as ft}from"fs";import{join as x}from"path";import{homedir as H}from"os";function L(){let r=process.platform==="win32";try{if(pt("bun",["--version"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:r}).status===0)return"bun"}catch{}let t=r?[x(H(),".bun","bin","bun.exe")]:[x(H(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"];for(let e of t)if(ft(e))return e;return null}function $(){return L()!==null}var T=O(m,"worker.pid"),F=O(m,"logs"),K=O(St(),".claude","plugins","marketplaces","thedotmack"),Tt=5e3,Ot=1e4,ht=200,At=1e3,Ct=100,h=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};W(F,{recursive:!0});let e=O(K,"plugin","scripts","worker-service.cjs");if(!R(e))return{success:!1,error:`Worker script not found at ${e}`};let n=this.getLogFilePath();return this.startWithBun(e,n,t)}static isBunAvailable(){return $()}static async startWithBun(t,e,n){let o=L();if(!o)return{success:!1,error:"Bun is required but not found in PATH or common installation paths. Install from https://bun.sh"};try{let s=process.platform==="win32",i=dt(o,[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(n)},cwd:K,...s&&{windowsHide:!0}}),u=_t(e,{flags:"a"});return i.stdout?.pipe(u),i.stderr?.pipe(u),i.unref(),i.pid?(this.writePidFile({pid:i.pid,port:n,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(i.pid,n)):{success:!1,error:"Failed to get PID from spawned process"}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}static async stop(t=Tt){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!R(T))return null;let t=mt(T,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){W(m,{recursive:!0}),Et(T,JSON.stringify(t,null,2))}static removePidFile(){try{R(T)&>(T)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,n=Ot){let o=Date.now();for(;Date.now()-osetTimeout(s,ht))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let n=Date.now();for(;Date.now()-nsetTimeout(o,Ct))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return O(F,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),o=Date.now()-e,s=Math.floor(o/1e3),i=Math.floor(s/60),u=Math.floor(i/60),l=Math.floor(u/24);return l>0?`${l}d ${u%24}h`:u>0?`${u}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function _(r={}){let{port:t,includeSkillFallback:e=!1,customPrefix:n}=r,o=process.platform==="win32",s=o?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=o?"Command Prompt or PowerShell":"Terminal",u=n||"Worker service connection failed.",l=t?` (port ${t})`:"",a=`${u}${l} `;return a+=`To restart the worker: `,a+=`1. Exit Claude Code completely @@ -9,6 +9,6 @@ ${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Obje `,a+=`3. Navigate to: ${s} `,a+="4. Run: npm run worker:restart",e&&(a+=` -If that doesn't work, try: /troubleshoot`),a}var W=A.join(Tt(),".claude","plugins","marketplaces","thedotmack"),K=v(d.HEALTH_CHECK),S=null;function g(){if(S!==null)return S;try{let r=A.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(r);return S=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),S}catch(r){return c.debug("SYSTEM","Failed to load port from settings, using default",{error:r}),S=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),S}}async function R(){try{let r=g();return(await fetch(`http://127.0.0.1:${r}/health`,{signal:AbortSignal.timeout(K)})).ok}catch(r){return c.debug("SYSTEM","Worker health check failed",{error:r instanceof Error?r.message:String(r),errorType:r?.constructor?.name}),!1}}function Ct(){try{let r=A.join(W,"package.json");return JSON.parse(At(r,"utf-8")).version}catch(r){return c.debug("SYSTEM","Failed to read plugin version",{error:r instanceof Error?r.message:String(r)}),null}}async function Mt(){try{let r=g(),t=await fetch(`http://127.0.0.1:${r}/api/version`,{signal:AbortSignal.timeout(K)});return t.ok?(await t.json()).version:null}catch(r){return c.debug("SYSTEM","Failed to get worker version",{error:r instanceof Error?r.message:String(r)}),null}}async function F(){let r=Ct(),t=await Mt();!r||!t||r!==t&&(c.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:r,workerVersion:t}),await h.restart(g()),await new Promise(e=>setTimeout(e,1e3)),await R()||c.error("SYSTEM","Worker failed to restart after version mismatch"))}async function Dt(){let r=A.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!ht(r))try{Ot("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),$(r,new Date().toISOString(),"utf-8"),c.debug("SYSTEM","PM2 cleanup completed and marked")}catch{$(r,new Date().toISOString(),"utf-8")}let t=g(),e=await h.start(t);return e.success||c.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:W}),e.success}async function V(){if(await R()){await F();return}if(!await Dt()){let e=g();throw new Error(_({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(o=>setTimeout(o,500)),await R()){await F();return}let t=g();throw c.error("SYSTEM","Worker started but not responding to health checks"),new Error(_({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}import{appendFileSync as Lt}from"fs";import{homedir as Rt}from"os";import{join as It}from"path";var yt=It(Rt(),".claude-mem","silent.log");function j(r,t,e=""){let o=new Date().toISOString(),u=((new Error().stack||"").split(` -`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),p=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",a=`[${o}] [HAPPY-PATH-ERROR] [${p}] ${r}`;if(t!==void 0)try{a+=` ${JSON.stringify(t)}`}catch(m){a+=` [stringify error: ${m}]`}a+=` -`;try{Lt(yt,a)}catch(m){console.error("[silent-debug] Failed to write to log:",m)}return e}function B(r){throw r.cause?.code==="ECONNREFUSED"||r.code==="ConnectionRefused"||r.name==="TimeoutError"||r.message?.includes("fetch failed")||r.message?.includes("Unable to connect")?new Error(_()):r}async function kt(r){if(await V(),!r)throw new Error("saveHook requires input");let{session_id:t,cwd:e,tool_name:o,tool_input:n,tool_response:s}=r,i=g(),u=c.formatTool(o,n);c.dataIn("HOOK",`PostToolUse: ${u}`,{workerPort:i});try{let p=await fetch(`http://127.0.0.1:${i}/api/sessions/observations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeSessionId:t,tool_name:o,tool_input:n,tool_response:s,cwd:j("Missing cwd in PostToolUse hook input",{session_id:t,tool_name:o},e||"")}),signal:AbortSignal.timeout(d.DEFAULT)});if(!p.ok){let a=await p.text();throw c.failure("HOOK","Failed to send observation",{status:p.status},a),new Error(_({includeSkillFallback:!0}))}c.debug("HOOK","Observation sent successfully",{toolName:o})}catch(p){B(p)}console.log(w("PostToolUse",!0))}var I="";G.on("data",r=>I+=r);G.on("end",async()=>{let r=I?JSON.parse(I):void 0;await kt(r)}); +If that doesn't work, try: /troubleshoot`),a}var j=A.join(Mt(),".claude","plugins","marketplaces","thedotmack"),G=N(S.HEALTH_CHECK),d=null;function E(){if(d!==null)return d;try{let r=A.join(p.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=p.loadFromFile(r);return d=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),d}catch(r){return c.debug("SYSTEM","Failed to load port from settings, using default",{error:r}),d=parseInt(p.get("CLAUDE_MEM_WORKER_PORT"),10),d}}async function b(){try{let r=E();return(await fetch(`http://127.0.0.1:${r}/health`,{signal:AbortSignal.timeout(G)})).ok}catch(r){return c.debug("SYSTEM","Worker health check failed",{error:r instanceof Error?r.message:String(r),errorType:r?.constructor?.name}),!1}}function bt(){try{let r=A.join(j,"package.json");return JSON.parse(Rt(r,"utf-8")).version}catch(r){return c.debug("SYSTEM","Failed to read plugin version",{error:r instanceof Error?r.message:String(r)}),null}}async function wt(){try{let r=E(),t=await fetch(`http://127.0.0.1:${r}/api/version`,{signal:AbortSignal.timeout(G)});return t.ok?(await t.json()).version:null}catch(r){return c.debug("SYSTEM","Failed to get worker version",{error:r instanceof Error?r.message:String(r)}),null}}async function V(){let r=bt(),t=await wt();!r||!t||r!==t&&(c.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:r,workerVersion:t}),await h.restart(E()),await new Promise(e=>setTimeout(e,1e3)),await b()||c.error("SYSTEM","Worker failed to restart after version mismatch"))}async function It(){let r=A.join(p.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!Lt(r))try{Dt("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),B(r,new Date().toISOString(),"utf-8"),c.debug("SYSTEM","PM2 cleanup completed and marked")}catch{B(r,new Date().toISOString(),"utf-8")}let t=E(),e=await h.start(t);return e.success||c.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:j}),e.success}async function X(){if(await b()){await V();return}if(!await It()){let e=E();throw new Error(_({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(n=>setTimeout(n,500)),await b()){await V();return}let t=E();throw c.error("SYSTEM","Worker started but not responding to health checks"),new Error(_({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}import{appendFileSync as yt}from"fs";import{homedir as Pt}from"os";import{join as kt}from"path";var Ut=kt(Pt(),".claude-mem","silent.log");function Y(r,t,e=""){let n=new Date().toISOString(),u=((new Error().stack||"").split(` +`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),l=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",a=`[${n}] [HAPPY-PATH-ERROR] [${l}] ${r}`;if(t!==void 0)try{a+=` ${JSON.stringify(t)}`}catch(g){a+=` [stringify error: ${g}]`}a+=` +`;try{yt(Ut,a)}catch(g){console.error("[silent-debug] Failed to write to log:",g)}return e}function J(r){throw r.cause?.code==="ECONNREFUSED"||r.code==="ConnectionRefused"||r.name==="TimeoutError"||r.message?.includes("fetch failed")||r.message?.includes("Unable to connect")?new Error(_()):r}async function vt(r){if(await X(),!r)throw new Error("saveHook requires input");let{session_id:t,cwd:e,tool_name:n,tool_input:o,tool_response:s}=r,i=E(),u=c.formatTool(n,o);c.dataIn("HOOK",`PostToolUse: ${u}`,{workerPort:i});try{let l=await fetch(`http://127.0.0.1:${i}/api/sessions/observations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeSessionId:t,tool_name:n,tool_input:o,tool_response:s,cwd:Y("Missing cwd in PostToolUse hook input",{session_id:t,tool_name:n},e||"")}),signal:AbortSignal.timeout(S.DEFAULT)});if(!l.ok){let a=await l.text();throw c.failure("HOOK","Failed to send observation",{status:l.status},a),new Error(_({includeSkillFallback:!0}))}c.debug("HOOK","Observation sent successfully",{toolName:n})}catch(l){J(l)}console.log(k("PostToolUse",!0))}var w="";q.on("data",r=>w+=r);q.on("end",async()=>{let r=w?JSON.parse(w):void 0;await vt(r)}); diff --git a/plugin/scripts/summary-hook.js b/plugin/scripts/summary-hook.js index a0dc2197..22734f88 100755 --- a/plugin/scripts/summary-hook.js +++ b/plugin/scripts/summary-hook.js @@ -1,7 +1,7 @@ #!/usr/bin/env bun -import{stdin as X}from"process";function q(r,t,e){return r==="SessionStart"?t&&e.context?{continue:!0,suppressOutput:!0,hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:e.context}}:{continue:!0,suppressOutput:!0}:r==="UserPromptSubmit"||r==="PostToolUse"?{continue:!0,suppressOutput:!0}:r==="Stop"?{continue:!0,suppressOutput:!0}:{continue:t,suppressOutput:!0,...e.reason&&!t?{stopReason:e.reason}:{}}}function b(r,t,e={}){let n=q(r,t,e);return JSON.stringify(n)}import{readFileSync as Z,writeFileSync as tt,existsSync as et}from"fs";import{join as rt}from"path";import{homedir as nt}from"os";var z=["bugfix","feature","refactor","discovery","decision","change"],Q=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var U=z.join(","),v=Q.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:rt(nt(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:U,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:v,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!et(t))return this.getAllDefaults();let e=Z(t,"utf-8"),n=JSON.parse(e),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{tt(t,JSON.stringify(o,null,2),"utf-8"),c.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){c.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))o[i]!==void 0&&(s[i]=o[i]);return s}};var C=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(C||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=C[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} +import{stdin as z}from"process";function tt(r,t,e){return r==="SessionStart"?t&&e.context?{continue:!0,suppressOutput:!0,hookSpecificOutput:{hookEventName:"SessionStart",additionalContext:e.context}}:{continue:!0,suppressOutput:!0}:r==="UserPromptSubmit"||r==="PostToolUse"?{continue:!0,suppressOutput:!0}:r==="Stop"?{continue:!0,suppressOutput:!0}:{continue:t,suppressOutput:!0,...e.reason&&!t?{stopReason:e.reason}:{}}}function U(r,t,e={}){let n=tt(r,t,e);return JSON.stringify(n)}import{readFileSync as nt,writeFileSync as ot,existsSync as st}from"fs";import{join as it}from"path";import{homedir as at}from"os";var et=["bugfix","feature","refactor","discovery","decision","change"],rt=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var v=et.join(","),N=rt.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:it(at(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:v,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:N,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!st(t))return this.getAllDefaults();let e=nt(t,"utf-8"),n=JSON.parse(e),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{ot(t,JSON.stringify(o,null,2),"utf-8"),c.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){c.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))o[i]!==void 0&&(s[i]=o[i]);return s}};var C=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(C||{}),M=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=C[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} ${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let n=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&n.command){let o=n.command.length>50?n.command.substring(0,50)+"...":n.command;return`${t}(${o})`}if(t==="Read"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}if(t==="Edit"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}if(t==="Write"&&n.file_path){let o=n.file_path.split("/").pop()||n.file_path;return`${t}(${o})`}return t}catch{return t}}log(t,e,n,o,s){if(t0&&(k=` {${Object.entries(P).map(([Y,J])=>`${Y}=${J}`).join(", ")}}`)}let w=`[${i}] [${a}] [${p}] ${u}${n}${k}${E}`;t===3?console.error(w):console.log(w)}debug(t,e,n,o){this.log(0,t,e,n,o)}info(t,e,n,o){this.log(1,t,e,n,o)}warn(t,e,n,o){this.log(2,t,e,n,o)}error(t,e,n,o){this.log(3,t,e,n,o)}dataIn(t,e,n,o){this.info(t,`\u2192 ${e}`,n,o)}dataOut(t,e,n,o){this.info(t,`\u2190 ${e}`,n,o)}success(t,e,n,o){this.info(t,`\u2713 ${e}`,n,o)}failure(t,e,n,o){this.error(t,`\u2717 ${e}`,n,o)}timing(t,e,n,o){this.info(t,`\u23F1 ${e}`,o,{duration:`${n}ms`})}},c=new M;import A from"path";import{homedir as Tt}from"os";import{spawnSync as ht}from"child_process";import{existsSync as At,writeFileSync as $,readFileSync as Ct}from"fs";var d={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function N(r){return process.platform==="win32"?Math.round(r*d.WINDOWS_MULTIPLIER):r}import{existsSync as D,readFileSync as ct,writeFileSync as ut,unlinkSync as pt,mkdirSync as x}from"fs";import{createWriteStream as lt}from"fs";import{join as T}from"path";import{spawn as ft,spawnSync as gt}from"child_process";import{homedir as mt}from"os";import{join as f,dirname as ot,basename as qt}from"path";import{homedir as st}from"os";import{fileURLToPath as it}from"url";function at(){return typeof __dirname<"u"?__dirname:ot(it(import.meta.url))}var ee=at(),g=l.get("CLAUDE_MEM_DATA_DIR"),L=process.env.CLAUDE_CONFIG_DIR||f(st(),".claude"),re=f(g,"archives"),ne=f(g,"logs"),oe=f(g,"trash"),se=f(g,"backups"),ie=f(g,"settings.json"),ae=f(g,"claude-mem.db"),ce=f(g,"vector-db"),ue=f(L,"settings.json"),pe=f(L,"commands"),le=f(L,"CLAUDE.md");var O=T(g,"worker.pid"),H=T(g,"logs"),F=T(mt(),".claude","plugins","marketplaces","thedotmack"),Et=5e3,_t=1e4,St=200,dt=1e3,Ot=100,h=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};x(H,{recursive:!0});let e=T(F,"plugin","scripts","worker-service.cjs");if(!D(e))return{success:!1,error:`Worker script not found at ${e}`};let n=this.getLogFilePath();return this.startWithBun(e,n,t)}static isBunAvailable(){try{return gt("bun",["--version"],{stdio:"pipe",timeout:5e3}).status===0}catch{return!1}}static async startWithBun(t,e,n){if(!this.isBunAvailable())return{success:!1,error:"Bun is required but not found in PATH. Install from https://bun.sh"};try{let o=process.platform==="win32",s=ft("bun",[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(n)},cwd:F,...o&&{windowsHide:!0}}),i=lt(e,{flags:"a"});return s.stdout?.pipe(i),s.stderr?.pipe(i),s.unref(),s.pid?(this.writePidFile({pid:s.pid,port:n,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(s.pid,n)):{success:!1,error:"Failed to get PID from spawned process"}}catch(o){return{success:!1,error:o instanceof Error?o.message:String(o)}}}static async stop(t=Et){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!D(O))return null;let t=ct(O,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){x(g,{recursive:!0}),ut(O,JSON.stringify(t,null,2))}static removePidFile(){try{D(O)&&pt(O)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,n=_t){let o=Date.now();for(;Date.now()-osetTimeout(s,St))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let n=Date.now();for(;Date.now()-nsetTimeout(o,Ot))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return T(H,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),o=Date.now()-e,s=Math.floor(o/1e3),i=Math.floor(s/60),a=Math.floor(i/60),p=Math.floor(a/24);return p>0?`${p}d ${a%24}h`:a>0?`${a}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function _(r={}){let{port:t,includeSkillFallback:e=!1,customPrefix:n}=r,o=process.platform==="win32",s=o?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=o?"Command Prompt or PowerShell":"Terminal",a=n||"Worker service connection failed.",p=t?` (port ${t})`:"",u=`${a}${p} +`+JSON.stringify(s,null,2):E=" "+this.formatData(s));let I="";if(o){let{sessionId:$t,sdkSessionId:Ft,correlationId:Wt,...P}=o;Object.keys(P).length>0&&(I=` {${Object.entries(P).map(([Q,Z])=>`${Q}=${Z}`).join(", ")}}`)}let k=`[${i}] [${a}] [${p}] ${u}${n}${I}${E}`;t===3?console.error(k):console.log(k)}debug(t,e,n,o){this.log(0,t,e,n,o)}info(t,e,n,o){this.log(1,t,e,n,o)}warn(t,e,n,o){this.log(2,t,e,n,o)}error(t,e,n,o){this.log(3,t,e,n,o)}dataIn(t,e,n,o){this.info(t,`\u2192 ${e}`,n,o)}dataOut(t,e,n,o){this.info(t,`\u2190 ${e}`,n,o)}success(t,e,n,o){this.info(t,`\u2713 ${e}`,n,o)}failure(t,e,n,o){this.error(t,`\u2717 ${e}`,n,o)}timing(t,e,n,o){this.info(t,`\u23F1 ${e}`,o,{duration:`${n}ms`})}},c=new M;import A from"path";import{homedir as Lt}from"os";import{spawnSync as yt}from"child_process";import{existsSync as Dt,writeFileSync as j,readFileSync as Rt}from"fs";var d={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function x(r){return process.platform==="win32"?Math.round(r*d.WINDOWS_MULTIPLIER):r}import{existsSync as D,readFileSync as gt,writeFileSync as Et,unlinkSync as _t,mkdirSync as W}from"fs";import{createWriteStream as St}from"fs";import{join as O}from"path";import{spawn as dt}from"child_process";import{homedir as Tt}from"os";import{join as f,dirname as ct,basename as ee}from"path";import{homedir as ut}from"os";import{fileURLToPath as pt}from"url";function lt(){return typeof __dirname<"u"?__dirname:ct(pt(import.meta.url))}var ie=lt(),m=l.get("CLAUDE_MEM_DATA_DIR"),L=process.env.CLAUDE_CONFIG_DIR||f(ut(),".claude"),ae=f(m,"archives"),ce=f(m,"logs"),ue=f(m,"trash"),pe=f(m,"backups"),le=f(m,"settings.json"),fe=f(m,"claude-mem.db"),me=f(m,"vector-db"),ge=f(L,"settings.json"),Ee=f(L,"commands"),_e=f(L,"CLAUDE.md");import{spawnSync as ft}from"child_process";import{existsSync as mt}from"fs";import{join as H}from"path";import{homedir as $}from"os";function y(){let r=process.platform==="win32";try{if(ft("bun",["--version"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:r}).status===0)return"bun"}catch{}let t=r?[H($(),".bun","bin","bun.exe")]:[H($(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"];for(let e of t)if(mt(e))return e;return null}function F(){return y()!==null}var T=O(m,"worker.pid"),K=O(m,"logs"),B=O(Tt(),".claude","plugins","marketplaces","thedotmack"),Ot=5e3,ht=1e4,At=200,Ct=1e3,Mt=100,h=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};W(K,{recursive:!0});let e=O(B,"plugin","scripts","worker-service.cjs");if(!D(e))return{success:!1,error:`Worker script not found at ${e}`};let n=this.getLogFilePath();return this.startWithBun(e,n,t)}static isBunAvailable(){return F()}static async startWithBun(t,e,n){let o=y();if(!o)return{success:!1,error:"Bun is required but not found in PATH or common installation paths. Install from https://bun.sh"};try{let s=process.platform==="win32",i=dt(o,[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(n)},cwd:B,...s&&{windowsHide:!0}}),a=St(e,{flags:"a"});return i.stdout?.pipe(a),i.stderr?.pipe(a),i.unref(),i.pid?(this.writePidFile({pid:i.pid,port:n,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(i.pid,n)):{success:!1,error:"Failed to get PID from spawned process"}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}static async stop(t=Ot){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!D(T))return null;let t=gt(T,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){W(m,{recursive:!0}),Et(T,JSON.stringify(t,null,2))}static removePidFile(){try{D(T)&&_t(T)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,n=ht){let o=Date.now();for(;Date.now()-osetTimeout(s,At))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let n=Date.now();for(;Date.now()-nsetTimeout(o,Mt))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return O(K,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),o=Date.now()-e,s=Math.floor(o/1e3),i=Math.floor(s/60),a=Math.floor(i/60),p=Math.floor(a/24);return p>0?`${p}d ${a%24}h`:a>0?`${a}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function _(r={}){let{port:t,includeSkillFallback:e=!1,customPrefix:n}=r,o=process.platform==="win32",s=o?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=o?"Command Prompt or PowerShell":"Terminal",a=n||"Worker service connection failed.",p=t?` (port ${t})`:"",u=`${a}${p} `;return u+=`To restart the worker: `,u+=`1. Exit Claude Code completely @@ -9,10 +9,10 @@ ${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Obje `,u+=`3. Navigate to: ${s} `,u+="4. Run: npm run worker:restart",e&&(u+=` -If that doesn't work, try: /troubleshoot`),u}var K=A.join(Tt(),".claude","plugins","marketplaces","thedotmack"),j=N(d.HEALTH_CHECK),S=null;function m(){if(S!==null)return S;try{let r=A.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(r);return S=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),S}catch(r){return c.debug("SYSTEM","Failed to load port from settings, using default",{error:r}),S=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),S}}async function y(){try{let r=m();return(await fetch(`http://127.0.0.1:${r}/health`,{signal:AbortSignal.timeout(j)})).ok}catch(r){return c.debug("SYSTEM","Worker health check failed",{error:r instanceof Error?r.message:String(r),errorType:r?.constructor?.name}),!1}}function Mt(){try{let r=A.join(K,"package.json");return JSON.parse(Ct(r,"utf-8")).version}catch(r){return c.debug("SYSTEM","Failed to read plugin version",{error:r instanceof Error?r.message:String(r)}),null}}async function Lt(){try{let r=m(),t=await fetch(`http://127.0.0.1:${r}/api/version`,{signal:AbortSignal.timeout(j)});return t.ok?(await t.json()).version:null}catch(r){return c.debug("SYSTEM","Failed to get worker version",{error:r instanceof Error?r.message:String(r)}),null}}async function W(){let r=Mt(),t=await Lt();!r||!t||r!==t&&(c.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:r,workerVersion:t}),await h.restart(m()),await new Promise(e=>setTimeout(e,1e3)),await y()||c.error("SYSTEM","Worker failed to restart after version mismatch"))}async function Dt(){let r=A.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!At(r))try{ht("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),$(r,new Date().toISOString(),"utf-8"),c.debug("SYSTEM","PM2 cleanup completed and marked")}catch{$(r,new Date().toISOString(),"utf-8")}let t=m(),e=await h.start(t);return e.success||c.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:K}),e.success}async function V(){if(await y()){await W();return}if(!await Dt()){let e=m();throw new Error(_({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(n=>setTimeout(n,500)),await y()){await W();return}let t=m();throw c.error("SYSTEM","Worker started but not responding to health checks"),new Error(_({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}import{appendFileSync as yt}from"fs";import{homedir as Rt}from"os";import{join as It}from"path";var kt=It(Rt(),".claude-mem","silent.log");function B(r,t,e=""){let n=new Date().toISOString(),a=((new Error().stack||"").split(` +If that doesn't work, try: /troubleshoot`),u}var G=A.join(Lt(),".claude","plugins","marketplaces","thedotmack"),X=x(d.HEALTH_CHECK),S=null;function g(){if(S!==null)return S;try{let r=A.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(r);return S=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),S}catch(r){return c.debug("SYSTEM","Failed to load port from settings, using default",{error:r}),S=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),S}}async function R(){try{let r=g();return(await fetch(`http://127.0.0.1:${r}/health`,{signal:AbortSignal.timeout(X)})).ok}catch(r){return c.debug("SYSTEM","Worker health check failed",{error:r instanceof Error?r.message:String(r),errorType:r?.constructor?.name}),!1}}function bt(){try{let r=A.join(G,"package.json");return JSON.parse(Rt(r,"utf-8")).version}catch(r){return c.debug("SYSTEM","Failed to read plugin version",{error:r instanceof Error?r.message:String(r)}),null}}async function wt(){try{let r=g(),t=await fetch(`http://127.0.0.1:${r}/api/version`,{signal:AbortSignal.timeout(X)});return t.ok?(await t.json()).version:null}catch(r){return c.debug("SYSTEM","Failed to get worker version",{error:r instanceof Error?r.message:String(r)}),null}}async function V(){let r=bt(),t=await wt();!r||!t||r!==t&&(c.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:r,workerVersion:t}),await h.restart(g()),await new Promise(e=>setTimeout(e,1e3)),await R()||c.error("SYSTEM","Worker failed to restart after version mismatch"))}async function It(){let r=A.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!Dt(r))try{yt("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),j(r,new Date().toISOString(),"utf-8"),c.debug("SYSTEM","PM2 cleanup completed and marked")}catch{j(r,new Date().toISOString(),"utf-8")}let t=g(),e=await h.start(t);return e.success||c.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:G}),e.success}async function Y(){if(await R()){await V();return}if(!await It()){let e=g();throw new Error(_({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(n=>setTimeout(n,500)),await R()){await V();return}let t=g();throw c.error("SYSTEM","Worker started but not responding to health checks"),new Error(_({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}import{appendFileSync as kt}from"fs";import{homedir as Pt}from"os";import{join as Ut}from"path";var vt=Ut(Pt(),".claude-mem","silent.log");function J(r,t,e=""){let n=new Date().toISOString(),a=((new Error().stack||"").split(` `)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),p=a?`${a[1].split("/").pop()}:${a[2]}`:"unknown",u=`[${n}] [HAPPY-PATH-ERROR] [${p}] ${r}`;if(t!==void 0)try{u+=` ${JSON.stringify(t)}`}catch(E){u+=` [stringify error: ${E}]`}u+=` -`;try{yt(kt,u)}catch(E){console.error("[silent-debug] Failed to write to log:",E)}return e}function G(r){throw r.cause?.code==="ECONNREFUSED"||r.code==="ConnectionRefused"||r.name==="TimeoutError"||r.message?.includes("fetch failed")||r.message?.includes("Unable to connect")?new Error(_()):r}import{readFileSync as wt,existsSync as Pt}from"fs";function R(r,t,e=!1){if(!r||!Pt(r))return"";try{let n=wt(r,"utf-8").trim();if(!n)return"";let o=n.split(` +`;try{kt(vt,u)}catch(E){console.error("[silent-debug] Failed to write to log:",E)}return e}function q(r){throw r.cause?.code==="ECONNREFUSED"||r.code==="ConnectionRefused"||r.name==="TimeoutError"||r.message?.includes("fetch failed")||r.message?.includes("Unable to connect")?new Error(_()):r}import{readFileSync as Nt,existsSync as xt}from"fs";function b(r,t,e=!1){if(!r||!xt(r))return"";try{let n=Nt(r,"utf-8").trim();if(!n)return"";let o=n.split(` `);for(let s=o.length-1;s>=0;s--)try{let i=JSON.parse(o[s]);if(i.type===t&&i.message?.content){let a="",p=i.message.content;return typeof p=="string"?a=p:Array.isArray(p)&&(a=p.filter(u=>u.type==="text").map(u=>u.text).join(` `)),e&&(a=a.replace(/[\s\S]*?<\/system-reminder>/g,""),a=a.replace(/\n{3,}/g,` -`).trim()),a}}catch{continue}}catch(n){c.error("HOOK","Failed to read transcript",{transcriptPath:r},n)}return""}async function bt(r){if(await V(),!r)throw new Error("summaryHook requires input");let{session_id:t}=r,e=m(),n=B("Missing transcript_path in Stop hook input",{session_id:t},r.transcript_path||""),o=R(n,"user"),s=R(n,"assistant",!0);c.dataIn("HOOK","Stop: Requesting summary",{workerPort:e,hasLastUserMessage:!!o,hasLastAssistantMessage:!!s});try{let i=await fetch(`http://127.0.0.1:${e}/api/sessions/summarize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeSessionId:t,last_user_message:o,last_assistant_message:s}),signal:AbortSignal.timeout(d.DEFAULT)});if(!i.ok){let a=await i.text();throw c.failure("HOOK","Failed to generate summary",{status:i.status},a),new Error(_({includeSkillFallback:!0}))}c.debug("HOOK","Summary request sent successfully")}catch(i){G(i)}finally{try{let i=await fetch(`http://127.0.0.1:${e}/api/processing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({isProcessing:!1}),signal:AbortSignal.timeout(2e3)});i.ok||c.warn("HOOK","Failed to stop spinner",{status:i.status})}catch(i){c.warn("HOOK","Could not stop spinner",{error:i.message})}}console.log(b("Stop",!0))}var I="";X.on("data",r=>I+=r);X.on("end",async()=>{let r=I?JSON.parse(I):void 0;await bt(r)}); +`).trim()),a}}catch{continue}}catch(n){c.error("HOOK","Failed to read transcript",{transcriptPath:r},n)}return""}async function Ht(r){if(await Y(),!r)throw new Error("summaryHook requires input");let{session_id:t}=r,e=g(),n=J("Missing transcript_path in Stop hook input",{session_id:t},r.transcript_path||""),o=b(n,"user"),s=b(n,"assistant",!0);c.dataIn("HOOK","Stop: Requesting summary",{workerPort:e,hasLastUserMessage:!!o,hasLastAssistantMessage:!!s});try{let i=await fetch(`http://127.0.0.1:${e}/api/sessions/summarize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({claudeSessionId:t,last_user_message:o,last_assistant_message:s}),signal:AbortSignal.timeout(d.DEFAULT)});if(!i.ok){let a=await i.text();throw c.failure("HOOK","Failed to generate summary",{status:i.status},a),new Error(_({includeSkillFallback:!0}))}c.debug("HOOK","Summary request sent successfully")}catch(i){q(i)}finally{try{let i=await fetch(`http://127.0.0.1:${e}/api/processing`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({isProcessing:!1}),signal:AbortSignal.timeout(2e3)});i.ok||c.warn("HOOK","Failed to stop spinner",{status:i.status})}catch(i){c.warn("HOOK","Could not stop spinner",{error:i.message})}}console.log(U("Stop",!0))}var w="";z.on("data",r=>w+=r);z.on("end",async()=>{let r=w?JSON.parse(w):void 0;await Ht(r)}); diff --git a/plugin/scripts/user-message-hook.js b/plugin/scripts/user-message-hook.js index 78480203..00cb0142 100755 --- a/plugin/scripts/user-message-hook.js +++ b/plugin/scripts/user-message-hook.js @@ -1,15 +1,15 @@ #!/usr/bin/env bun -import{basename as ht}from"path";import O from"path";import{homedir as ft}from"os";import{spawnSync as _t}from"child_process";import{existsSync as mt,writeFileSync as W,readFileSync as dt}from"fs";import{readFileSync as X,writeFileSync as Y,existsSync as J}from"fs";import{join as q}from"path";import{homedir as Q}from"os";var B=["bugfix","feature","refactor","discovery","decision","change"],G=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var v=B.join(","),P=G.join(",");var u=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:q(Q(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:v,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:P,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!J(t))return this.getAllDefaults();let e=X(t,"utf-8"),r=JSON.parse(e),n=r;if(r.env&&typeof r.env=="object"){n=r.env;try{Y(t,JSON.stringify(n,null,2),"utf-8"),a.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){a.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))n[i]!==void 0&&(s[i]=n[i]);return s}};var C=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(C||{}),A=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=u.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=C[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} -${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let r=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&r.command){let n=r.command.length>50?r.command.substring(0,50)+"...":r.command;return`${t}(${n})`}if(t==="Read"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Edit"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Write"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}return t}catch{return t}}log(t,e,r,n,s){if(t0&&(I=` {${Object.entries(w).map(([j,V])=>`${j}=${V}`).join(", ")}}`)}let y=`[${i}] [${E}] [${f}] ${c}${r}${I}${h}`;t===3?console.error(y):console.log(y)}debug(t,e,r,n){this.log(0,t,e,r,n)}info(t,e,r,n){this.log(1,t,e,r,n)}warn(t,e,r,n){this.log(2,t,e,r,n)}error(t,e,r,n){this.log(3,t,e,r,n)}dataIn(t,e,r,n){this.info(t,`\u2192 ${e}`,r,n)}dataOut(t,e,r,n){this.info(t,`\u2190 ${e}`,r,n)}success(t,e,r,n){this.info(t,`\u2713 ${e}`,r,n)}failure(t,e,r,n){this.error(t,`\u2717 ${e}`,r,n)}timing(t,e,r,n){this.info(t,`\u23F1 ${e}`,n,{duration:`${r}ms`})}},a=new A;var M={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5},k={SUCCESS:0,FAILURE:1,USER_MESSAGE_ONLY:3};function U(o){return process.platform==="win32"?Math.round(o*M.WINDOWS_MULTIPLIER):o}import{existsSync as L,readFileSync as rt,writeFileSync as nt,unlinkSync as ot,mkdirSync as b}from"fs";import{createWriteStream as st}from"fs";import{join as d}from"path";import{spawn as it,spawnSync as at}from"child_process";import{homedir as ct}from"os";import{join as l,dirname as z,basename as xt}from"path";import{homedir as Z}from"os";import{fileURLToPath as tt}from"url";function et(){return typeof __dirname<"u"?__dirname:z(tt(import.meta.url))}var Kt=et(),p=u.get("CLAUDE_MEM_DATA_DIR"),D=process.env.CLAUDE_CONFIG_DIR||l(Z(),".claude"),jt=l(p,"archives"),Vt=l(p,"logs"),Bt=l(p,"trash"),Gt=l(p,"backups"),Xt=l(p,"settings.json"),Yt=l(p,"claude-mem.db"),Jt=l(p,"vector-db"),qt=l(D,"settings.json"),Qt=l(D,"commands"),zt=l(D,"CLAUDE.md");var m=d(p,"worker.pid"),N=d(p,"logs"),x=d(ct(),".claude","plugins","marketplaces","thedotmack"),ut=5e3,lt=1e4,pt=200,Et=1e3,gt=100,S=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};b(N,{recursive:!0});let e=d(x,"plugin","scripts","worker-service.cjs");if(!L(e))return{success:!1,error:`Worker script not found at ${e}`};let r=this.getLogFilePath();return this.startWithBun(e,r,t)}static isBunAvailable(){try{return at("bun",["--version"],{stdio:"pipe",timeout:5e3}).status===0}catch{return!1}}static async startWithBun(t,e,r){if(!this.isBunAvailable())return{success:!1,error:"Bun is required but not found in PATH. Install from https://bun.sh"};try{let n=process.platform==="win32",s=it("bun",[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(r)},cwd:x,...n&&{windowsHide:!0}}),i=st(e,{flags:"a"});return s.stdout?.pipe(i),s.stderr?.pipe(i),s.unref(),s.pid?(this.writePidFile({pid:s.pid,port:r,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(s.pid,r)):{success:!1,error:"Failed to get PID from spawned process"}}catch(n){return{success:!1,error:n instanceof Error?n.message:String(n)}}}static async stop(t=ut){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!L(m))return null;let t=rt(m,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){b(p,{recursive:!0}),nt(m,JSON.stringify(t,null,2))}static removePidFile(){try{L(m)&&ot(m)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,r=lt){let n=Date.now();for(;Date.now()-nsetTimeout(s,pt))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let r=Date.now();for(;Date.now()-rsetTimeout(n,gt))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return d(N,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),n=Date.now()-e,s=Math.floor(n/1e3),i=Math.floor(s/60),E=Math.floor(i/60),f=Math.floor(E/24);return f>0?`${f}d ${E%24}h`:E>0?`${E}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function T(o={}){let{port:t,includeSkillFallback:e=!1,customPrefix:r}=o,n=process.platform==="win32",s=n?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=n?"Command Prompt or PowerShell":"Terminal",E=r||"Worker service connection failed.",f=t?` (port ${t})`:"",c=`${E}${f} +import{basename as Lt}from"path";import h from"path";import{homedir as Tt}from"os";import{spawnSync as ht}from"child_process";import{existsSync as Ot,writeFileSync as K,readFileSync as Ct}from"fs";import{readFileSync as Q,writeFileSync as z,existsSync as Z}from"fs";import{join as tt}from"path";import{homedir as et}from"os";var J=["bugfix","feature","refactor","discovery","decision","change"],q=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var P=J.join(","),v=q.join(",");var l=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:tt(et(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:P,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:v,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!Z(t))return this.getAllDefaults();let e=Q(t,"utf-8"),r=JSON.parse(e),n=r;if(r.env&&typeof r.env=="object"){n=r.env;try{z(t,JSON.stringify(n,null,2),"utf-8"),a.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){a.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))n[i]!==void 0&&(s[i]=n[i]);return s}};var C=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(C||{}),A=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=l.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=C[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} +${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let r=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&r.command){let n=r.command.length>50?r.command.substring(0,50)+"...":r.command;return`${t}(${n})`}if(t==="Read"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Edit"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Write"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}return t}catch{return t}}log(t,e,r,n,s){if(t0&&(R=` {${Object.entries(y).map(([X,Y])=>`${X}=${Y}`).join(", ")}}`)}let w=`[${i}] [${c}] [${m}] ${u}${r}${R}${O}`;t===3?console.error(w):console.log(w)}debug(t,e,r,n){this.log(0,t,e,r,n)}info(t,e,r,n){this.log(1,t,e,r,n)}warn(t,e,r,n){this.log(2,t,e,r,n)}error(t,e,r,n){this.log(3,t,e,r,n)}dataIn(t,e,r,n){this.info(t,`\u2192 ${e}`,r,n)}dataOut(t,e,r,n){this.info(t,`\u2190 ${e}`,r,n)}success(t,e,r,n){this.info(t,`\u2713 ${e}`,r,n)}failure(t,e,r,n){this.error(t,`\u2717 ${e}`,r,n)}timing(t,e,r,n){this.info(t,`\u23F1 ${e}`,n,{duration:`${r}ms`})}},a=new A;var M={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5},k={SUCCESS:0,FAILURE:1,USER_MESSAGE_ONLY:3};function U(o){return process.platform==="win32"?Math.round(o*M.WINDOWS_MULTIPLIER):o}import{existsSync as b,readFileSync as ct,writeFileSync as ut,unlinkSync as lt,mkdirSync as F}from"fs";import{createWriteStream as pt}from"fs";import{join as d}from"path";import{spawn as Et}from"child_process";import{homedir as ft}from"os";import{join as p,dirname as rt,basename as Kt}from"path";import{homedir as nt}from"os";import{fileURLToPath as ot}from"url";function st(){return typeof __dirname<"u"?__dirname:rt(ot(import.meta.url))}var Xt=st(),E=l.get("CLAUDE_MEM_DATA_DIR"),D=process.env.CLAUDE_CONFIG_DIR||p(nt(),".claude"),Yt=p(E,"archives"),Jt=p(E,"logs"),qt=p(E,"trash"),Qt=p(E,"backups"),zt=p(E,"settings.json"),Zt=p(E,"claude-mem.db"),te=p(E,"vector-db"),ee=p(D,"settings.json"),re=p(D,"commands"),ne=p(D,"CLAUDE.md");import{spawnSync as it}from"child_process";import{existsSync as at}from"fs";import{join as N}from"path";import{homedir as x}from"os";function L(){let o=process.platform==="win32";try{if(it("bun",["--version"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:o}).status===0)return"bun"}catch{}let t=o?[N(x(),".bun","bin","bun.exe")]:[N(x(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"];for(let e of t)if(at(e))return e;return null}function W(){return L()!==null}var _=d(E,"worker.pid"),H=d(E,"logs"),$=d(ft(),".claude","plugins","marketplaces","thedotmack"),mt=5e3,gt=1e4,_t=200,dt=1e3,St=100,S=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};F(H,{recursive:!0});let e=d($,"plugin","scripts","worker-service.cjs");if(!b(e))return{success:!1,error:`Worker script not found at ${e}`};let r=this.getLogFilePath();return this.startWithBun(e,r,t)}static isBunAvailable(){return W()}static async startWithBun(t,e,r){let n=L();if(!n)return{success:!1,error:"Bun is required but not found in PATH or common installation paths. Install from https://bun.sh"};try{let s=process.platform==="win32",i=Et(n,[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(r)},cwd:$,...s&&{windowsHide:!0}}),c=pt(e,{flags:"a"});return i.stdout?.pipe(c),i.stderr?.pipe(c),i.unref(),i.pid?(this.writePidFile({pid:i.pid,port:r,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(i.pid,r)):{success:!1,error:"Failed to get PID from spawned process"}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s)}}}static async stop(t=mt){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!b(_))return null;let t=ct(_,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){F(E,{recursive:!0}),ut(_,JSON.stringify(t,null,2))}static removePidFile(){try{b(_)&<(_)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,r=gt){let n=Date.now();for(;Date.now()-nsetTimeout(s,_t))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let r=Date.now();for(;Date.now()-rsetTimeout(n,St))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return d(H,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),n=Date.now()-e,s=Math.floor(n/1e3),i=Math.floor(s/60),c=Math.floor(i/60),m=Math.floor(c/24);return m>0?`${m}d ${c%24}h`:c>0?`${c}h ${i%60}m`:i>0?`${i}m ${s%60}s`:`${s}s`}};function T(o={}){let{port:t,includeSkillFallback:e=!1,customPrefix:r}=o,n=process.platform==="win32",s=n?"%USERPROFILE%\\.claude\\plugins\\marketplaces\\thedotmack":"~/.claude/plugins/marketplaces/thedotmack",i=n?"Command Prompt or PowerShell":"Terminal",c=r||"Worker service connection failed.",m=t?` (port ${t})`:"",u=`${c}${m} -`;return c+=`To restart the worker: -`,c+=`1. Exit Claude Code completely -`,c+=`2. Open ${i} -`,c+=`3. Navigate to: ${s} -`,c+="4. Run: npm run worker:restart",e&&(c+=` +`;return u+=`To restart the worker: +`,u+=`1. Exit Claude Code completely +`,u+=`2. Open ${i} +`,u+=`3. Navigate to: ${s} +`,u+="4. Run: npm run worker:restart",e&&(u+=` -If that doesn't work, try: /troubleshoot`),c}var H=O.join(ft(),".claude","plugins","marketplaces","thedotmack"),$=U(M.HEALTH_CHECK),_=null;function g(){if(_!==null)return _;try{let o=O.join(u.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=u.loadFromFile(o);return _=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),_}catch(o){return a.debug("SYSTEM","Failed to load port from settings, using default",{error:o}),_=parseInt(u.get("CLAUDE_MEM_WORKER_PORT"),10),_}}async function R(){try{let o=g();return(await fetch(`http://127.0.0.1:${o}/health`,{signal:AbortSignal.timeout($)})).ok}catch(o){return a.debug("SYSTEM","Worker health check failed",{error:o instanceof Error?o.message:String(o),errorType:o?.constructor?.name}),!1}}function St(){try{let o=O.join(H,"package.json");return JSON.parse(dt(o,"utf-8")).version}catch(o){return a.debug("SYSTEM","Failed to read plugin version",{error:o instanceof Error?o.message:String(o)}),null}}async function Tt(){try{let o=g(),t=await fetch(`http://127.0.0.1:${o}/api/version`,{signal:AbortSignal.timeout($)});return t.ok?(await t.json()).version:null}catch(o){return a.debug("SYSTEM","Failed to get worker version",{error:o instanceof Error?o.message:String(o)}),null}}async function F(){let o=St(),t=await Tt();!o||!t||o!==t&&(a.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:o,workerVersion:t}),await S.restart(g()),await new Promise(e=>setTimeout(e,1e3)),await R()||a.error("SYSTEM","Worker failed to restart after version mismatch"))}async function Ot(){let o=O.join(u.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!mt(o))try{_t("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),W(o,new Date().toISOString(),"utf-8"),a.debug("SYSTEM","PM2 cleanup completed and marked")}catch{W(o,new Date().toISOString(),"utf-8")}let t=g(),e=await S.start(t);return e.success||a.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:H}),e.success}async function K(){if(await R()){await F();return}if(!await Ot()){let e=g();throw new Error(T({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(r=>setTimeout(r,500)),await R()){await F();return}let t=g();throw a.error("SYSTEM","Worker started but not responding to health checks"),new Error(T({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}try{await K();let o=g(),t=ht(process.cwd()),e=await fetch(`http://127.0.0.1:${o}/api/context/inject?project=${encodeURIComponent(t)}&colors=true`,{method:"GET",signal:AbortSignal.timeout(5e3)});if(!e.ok)throw new Error(T({includeSkillFallback:!0}));let r=await e.text();console.error(` +If that doesn't work, try: /troubleshoot`),u}var j=h.join(Tt(),".claude","plugins","marketplaces","thedotmack"),V=U(M.HEALTH_CHECK),g=null;function f(){if(g!==null)return g;try{let o=h.join(l.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=l.loadFromFile(o);return g=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),g}catch(o){return a.debug("SYSTEM","Failed to load port from settings, using default",{error:o}),g=parseInt(l.get("CLAUDE_MEM_WORKER_PORT"),10),g}}async function I(){try{let o=f();return(await fetch(`http://127.0.0.1:${o}/health`,{signal:AbortSignal.timeout(V)})).ok}catch(o){return a.debug("SYSTEM","Worker health check failed",{error:o instanceof Error?o.message:String(o),errorType:o?.constructor?.name}),!1}}function At(){try{let o=h.join(j,"package.json");return JSON.parse(Ct(o,"utf-8")).version}catch(o){return a.debug("SYSTEM","Failed to read plugin version",{error:o instanceof Error?o.message:String(o)}),null}}async function Mt(){try{let o=f(),t=await fetch(`http://127.0.0.1:${o}/api/version`,{signal:AbortSignal.timeout(V)});return t.ok?(await t.json()).version:null}catch(o){return a.debug("SYSTEM","Failed to get worker version",{error:o instanceof Error?o.message:String(o)}),null}}async function B(){let o=At(),t=await Mt();!o||!t||o!==t&&(a.info("SYSTEM","Worker version mismatch detected - restarting worker",{pluginVersion:o,workerVersion:t}),await S.restart(f()),await new Promise(e=>setTimeout(e,1e3)),await I()||a.error("SYSTEM","Worker failed to restart after version mismatch"))}async function Dt(){let o=h.join(l.get("CLAUDE_MEM_DATA_DIR"),".pm2-migrated");if(!Ot(o))try{ht("pm2",["delete","claude-mem-worker"],{stdio:"ignore"}),K(o,new Date().toISOString(),"utf-8"),a.debug("SYSTEM","PM2 cleanup completed and marked")}catch{K(o,new Date().toISOString(),"utf-8")}let t=f(),e=await S.start(t);return e.success||a.error("SYSTEM","Failed to start worker",{platform:process.platform,port:t,error:e.error,marketplaceRoot:j}),e.success}async function G(){if(await I()){await B();return}if(!await Dt()){let e=f();throw new Error(T({port:e,customPrefix:`Worker service failed to start on port ${e}.`}))}for(let e=0;e<5;e++)if(await new Promise(r=>setTimeout(r,500)),await I()){await B();return}let t=f();throw a.error("SYSTEM","Worker started but not responding to health checks"),new Error(T({port:t,customPrefix:`Worker service started but is not responding on port ${t}.`}))}try{await G();let o=f(),t=Lt(process.cwd()),e=await fetch(`http://127.0.0.1:${o}/api/context/inject?project=${encodeURIComponent(t)}&colors=true`,{method:"GET",signal:AbortSignal.timeout(5e3)});if(!e.ok)throw new Error(T({includeSkillFallback:!0}));let r=await e.text();console.error(` \u{1F4DD} Claude-Mem Context Loaded \u2139\uFE0F Note: This appears as stderr but is informational only diff --git a/plugin/scripts/worker-cli.js b/plugin/scripts/worker-cli.js index 63ae3850..1169087a 100755 --- a/plugin/scripts/worker-cli.js +++ b/plugin/scripts/worker-cli.js @@ -1,4 +1,4 @@ #!/usr/bin/env bun -import{existsSync as C,readFileSync as J,writeFileSync as q,unlinkSync as Q,mkdirSync as P}from"fs";import{createWriteStream as z}from"fs";import{join as _}from"path";import{spawn as Z,spawnSync as tt}from"child_process";import{homedir as et}from"os";import{join as a,dirname as j,basename as Mt}from"path";import{homedir as G}from"os";import{fileURLToPath as X}from"url";import{readFileSync as F,writeFileSync as H,existsSync as K}from"fs";import{join as V}from"path";import{homedir as B}from"os";var W=["bugfix","feature","refactor","discovery","decision","change"],$=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var I=W.join(","),R=$.join(",");var T=(n=>(n[n.DEBUG=0]="DEBUG",n[n.INFO=1]="INFO",n[n.WARN=2]="WARN",n[n.ERROR=3]="ERROR",n[n.SILENT=4]="SILENT",n))(T||{}),O=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=u.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=T[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} -${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let o=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&o.command){let r=o.command.length>50?o.command.substring(0,50)+"...":o.command;return`${t}(${r})`}if(t==="Read"&&o.file_path){let r=o.file_path.split("/").pop()||o.file_path;return`${t}(${r})`}if(t==="Edit"&&o.file_path){let r=o.file_path.split("/").pop()||o.file_path;return`${t}(${r})`}if(t==="Write"&&o.file_path){let r=o.file_path.split("/").pop()||o.file_path;return`${t}(${r})`}return t}catch{return t}}log(t,e,o,r,n){if(t0&&(M=` {${Object.entries(L).map(([N,x])=>`${N}=${x}`).join(", ")}}`)}let D=`[${i}] [${p}] [${m}] ${S}${o}${M}${d}`;t===3?console.error(D):console.log(D)}debug(t,e,o,r){this.log(0,t,e,o,r)}info(t,e,o,r){this.log(1,t,e,o,r)}warn(t,e,o,r){this.log(2,t,e,o,r)}error(t,e,o,r){this.log(3,t,e,o,r)}dataIn(t,e,o,r){this.info(t,`\u2192 ${e}`,o,r)}dataOut(t,e,o,r){this.info(t,`\u2190 ${e}`,o,r)}success(t,e,o,r){this.info(t,`\u2713 ${e}`,o,r)}failure(t,e,o,r){this.error(t,`\u2717 ${e}`,o,r)}timing(t,e,o,r){this.info(t,`\u23F1 ${e}`,r,{duration:`${o}ms`})}},g=new O;var u=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:V(B(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:I,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:R,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!K(t))return this.getAllDefaults();let e=F(t,"utf-8"),o=JSON.parse(e),r=o;if(o.env&&typeof o.env=="object"){r=o.env;try{H(t,JSON.stringify(r,null,2),"utf-8"),g.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){g.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let n={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))r[i]!==void 0&&(n[i]=r[i]);return n}};function Y(){return typeof __dirname<"u"?__dirname:j(X(import.meta.url))}var Pt=Y(),c=u.get("CLAUDE_MEM_DATA_DIR"),A=process.env.CLAUDE_CONFIG_DIR||a(G(),".claude"),yt=a(c,"archives"),wt=a(c,"logs"),kt=a(c,"trash"),Ut=a(c,"backups"),vt=a(c,"settings.json"),bt=a(c,"claude-mem.db"),Nt=a(c,"vector-db"),xt=a(A,"settings.json"),Wt=a(A,"commands"),$t=a(A,"CLAUDE.md");var f=_(c,"worker.pid"),y=_(c,"logs"),w=_(et(),".claude","plugins","marketplaces","thedotmack"),rt=5e3,ot=1e4,nt=200,st=1e3,it=100,l=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};P(y,{recursive:!0});let e=_(w,"plugin","scripts","worker-service.cjs");if(!C(e))return{success:!1,error:`Worker script not found at ${e}`};let o=this.getLogFilePath();return this.startWithBun(e,o,t)}static isBunAvailable(){try{return tt("bun",["--version"],{stdio:"pipe",timeout:5e3}).status===0}catch{return!1}}static async startWithBun(t,e,o){if(!this.isBunAvailable())return{success:!1,error:"Bun is required but not found in PATH. Install from https://bun.sh"};try{let r=process.platform==="win32",n=Z("bun",[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(o)},cwd:w,...r&&{windowsHide:!0}}),i=z(e,{flags:"a"});return n.stdout?.pipe(i),n.stderr?.pipe(i),n.unref(),n.pid?(this.writePidFile({pid:n.pid,port:o,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(n.pid,o)):{success:!1,error:"Failed to get PID from spawned process"}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}static async stop(t=rt){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!C(f))return null;let t=J(f,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){P(c,{recursive:!0}),q(f,JSON.stringify(t,null,2))}static removePidFile(){try{C(f)&&Q(f)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,o=ot){let r=Date.now();for(;Date.now()-rsetTimeout(n,nt))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let o=Date.now();for(;Date.now()-osetTimeout(r,it))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return _(y,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),r=Date.now()-e,n=Math.floor(r/1e3),i=Math.floor(n/60),p=Math.floor(i/60),m=Math.floor(p/24);return m>0?`${m}d ${p%24}h`:p>0?`${p}h ${i%60}m`:i>0?`${i}m ${n%60}s`:`${n}s`}};import U from"path";import{homedir as at}from"os";var h={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function k(s){return process.platform==="win32"?Math.round(s*h.WINDOWS_MULTIPLIER):s}var ne=U.join(at(),".claude","plugins","marketplaces","thedotmack"),se=k(h.HEALTH_CHECK),E=null;function v(){if(E!==null)return E;try{let s=U.join(u.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=u.loadFromFile(s);return E=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),E}catch(s){return g.debug("SYSTEM","Failed to load port from settings, using default",{error:s}),E=parseInt(u.get("CLAUDE_MEM_WORKER_PORT"),10),E}}var ct=process.argv[2],b=v();async function ut(){switch(ct){case"start":{let s=await l.start(b);if(s.success){console.log(`Worker started (PID: ${s.pid})`);let t=new Date().toISOString().slice(0,10);console.log(`Logs: ~/.claude-mem/logs/worker-${t}.log`),process.exit(0)}else console.error(`Failed to start: ${s.error}`),process.exit(1);break}case"stop":await l.stop(),console.log("Worker stopped"),process.exit(0);case"restart":{let s=await l.restart(b);s.success?(console.log(`Worker restarted (PID: ${s.pid})`),process.exit(0)):(console.error(`Failed to restart: ${s.error}`),process.exit(1));break}case"status":{let s=await l.status();s.running?(console.log("Worker is running"),console.log(` PID: ${s.pid}`),console.log(` Port: ${s.port}`),console.log(` Uptime: ${s.uptime}`)):console.log("Worker is not running"),process.exit(0)}default:console.log("Usage: worker-cli.js "),process.exit(1)}}ut().catch(s=>{console.error(s),process.exit(1)}); +import{existsSync as C,readFileSync as et,writeFileSync as rt,unlinkSync as nt,mkdirSync as k}from"fs";import{createWriteStream as ot}from"fs";import{join as m}from"path";import{spawn as st}from"child_process";import{homedir as it}from"os";import{join as a,dirname as J,basename as bt}from"path";import{homedir as q}from"os";import{fileURLToPath as Q}from"url";import{readFileSync as V,writeFileSync as j,existsSync as G}from"fs";import{join as X}from"path";import{homedir as Y}from"os";var K=["bugfix","feature","refactor","discovery","decision","change"],B=["how-it-works","why-it-exists","what-changed","problem-solution","gotcha","pattern","trade-off"];var R=K.join(","),b=B.join(",");var T=(o=>(o[o.DEBUG=0]="DEBUG",o[o.INFO=1]="INFO",o[o.WARN=2]="WARN",o[o.ERROR=3]="ERROR",o[o.SILENT=4]="SILENT",o))(T||{}),O=class{level=null;useColor;constructor(){this.useColor=process.stdout.isTTY??!1}getLevel(){if(this.level===null){let t=u.get("CLAUDE_MEM_LOG_LEVEL").toUpperCase();this.level=T[t]??1}return this.level}correlationId(t,e){return`obs-${t}-${e}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message} +${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let e=Object.keys(t);return e.length===0?"{}":e.length<=3?JSON.stringify(t):`{${e.length} keys: ${e.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,e){if(!e)return t;try{let r=typeof e=="string"?JSON.parse(e):e;if(t==="Bash"&&r.command){let n=r.command.length>50?r.command.substring(0,50)+"...":r.command;return`${t}(${n})`}if(t==="Read"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Edit"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}if(t==="Write"&&r.file_path){let n=r.file_path.split("/").pop()||r.file_path;return`${t}(${n})`}return t}catch{return t}}log(t,e,r,n,o){if(t0&&(D=` {${Object.entries(I).map(([F,H])=>`${F}=${H}`).join(", ")}}`)}let L=`[${i}] [${l}] [${_}] ${S}${r}${D}${d}`;t===3?console.error(L):console.log(L)}debug(t,e,r,n){this.log(0,t,e,r,n)}info(t,e,r,n){this.log(1,t,e,r,n)}warn(t,e,r,n){this.log(2,t,e,r,n)}error(t,e,r,n){this.log(3,t,e,r,n)}dataIn(t,e,r,n){this.info(t,`\u2192 ${e}`,r,n)}dataOut(t,e,r,n){this.info(t,`\u2190 ${e}`,r,n)}success(t,e,r,n){this.info(t,`\u2713 ${e}`,r,n)}failure(t,e,r,n){this.error(t,`\u2717 ${e}`,r,n)}timing(t,e,r,n){this.info(t,`\u23F1 ${e}`,n,{duration:`${r}ms`})}},f=new O;var u=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_DATA_DIR:X(Y(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"true",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES:R,CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS:b,CLAUDE_MEM_CONTEXT_FULL_COUNT:"5",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return this.DEFAULTS[t]}static getInt(t){let e=this.get(t);return parseInt(e,10)}static getBool(t){return this.get(t)==="true"}static loadFromFile(t){if(!G(t))return this.getAllDefaults();let e=V(t,"utf-8"),r=JSON.parse(e),n=r;if(r.env&&typeof r.env=="object"){n=r.env;try{j(t,JSON.stringify(n,null,2),"utf-8"),f.info("SETTINGS","Migrated settings file from nested to flat schema",{settingsPath:t})}catch(i){f.warn("SETTINGS","Failed to auto-migrate settings file",{settingsPath:t},i)}}let o={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))n[i]!==void 0&&(o[i]=n[i]);return o}};function z(){return typeof __dirname<"u"?__dirname:J(Q(import.meta.url))}var vt=z(),c=u.get("CLAUDE_MEM_DATA_DIR"),h=process.env.CLAUDE_CONFIG_DIR||a(q(),".claude"),Ut=a(c,"archives"),Nt=a(c,"logs"),xt=a(c,"trash"),Wt=a(c,"backups"),$t=a(c,"settings.json"),Ft=a(c,"claude-mem.db"),Ht=a(c,"vector-db"),Kt=a(h,"settings.json"),Bt=a(h,"commands"),Vt=a(h,"CLAUDE.md");import{spawnSync as Z}from"child_process";import{existsSync as tt}from"fs";import{join as w}from"path";import{homedir as P}from"os";function A(){let s=process.platform==="win32";try{if(Z("bun",["--version"],{encoding:"utf-8",stdio:["pipe","pipe","pipe"],shell:s}).status===0)return"bun"}catch{}let t=s?[w(P(),".bun","bin","bun.exe")]:[w(P(),".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun"];for(let e of t)if(tt(e))return e;return null}function y(){return A()!==null}var g=m(c,"worker.pid"),v=m(c,"logs"),U=m(it(),".claude","plugins","marketplaces","thedotmack"),at=5e3,ct=1e4,ut=200,lt=1e3,pt=100,p=class{static async start(t){if(isNaN(t)||t<1024||t>65535)return{success:!1,error:`Invalid port ${t}. Must be between 1024 and 65535`};if(await this.isRunning())return{success:!0,pid:this.getPidInfo()?.pid};k(v,{recursive:!0});let e=m(U,"plugin","scripts","worker-service.cjs");if(!C(e))return{success:!1,error:`Worker script not found at ${e}`};let r=this.getLogFilePath();return this.startWithBun(e,r,t)}static isBunAvailable(){return y()}static async startWithBun(t,e,r){let n=A();if(!n)return{success:!1,error:"Bun is required but not found in PATH or common installation paths. Install from https://bun.sh"};try{let o=process.platform==="win32",i=st(n,[t],{detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,CLAUDE_MEM_WORKER_PORT:String(r)},cwd:U,...o&&{windowsHide:!0}}),l=ot(e,{flags:"a"});return i.stdout?.pipe(l),i.stderr?.pipe(l),i.unref(),i.pid?(this.writePidFile({pid:i.pid,port:r,startedAt:new Date().toISOString(),version:process.env.npm_package_version||"unknown"}),this.waitForHealth(i.pid,r)):{success:!1,error:"Failed to get PID from spawned process"}}catch(o){return{success:!1,error:o instanceof Error?o.message:String(o)}}}static async stop(t=at){let e=this.getPidInfo();if(!e)return!0;try{process.kill(e.pid,"SIGTERM"),await this.waitForExit(e.pid,t)}catch{try{process.kill(e.pid,"SIGKILL")}catch{}}return this.removePidFile(),!0}static async restart(t){return await this.stop(),this.start(t)}static async status(){let t=this.getPidInfo();if(!t)return{running:!1};let e=this.isProcessAlive(t.pid);return{running:e,pid:e?t.pid:void 0,port:e?t.port:void 0,uptime:e?this.formatUptime(t.startedAt):void 0}}static async isRunning(){let t=this.getPidInfo();if(!t)return!1;let e=this.isProcessAlive(t.pid);return e||this.removePidFile(),e}static getPidInfo(){try{if(!C(g))return null;let t=et(g,"utf-8"),e=JSON.parse(t);return typeof e.pid!="number"||typeof e.port!="number"?null:e}catch{return null}}static writePidFile(t){k(c,{recursive:!0}),rt(g,JSON.stringify(t,null,2))}static removePidFile(){try{C(g)&&nt(g)}catch{}}static isProcessAlive(t){try{return process.kill(t,0),!0}catch{return!1}}static async waitForHealth(t,e,r=ct){let n=Date.now();for(;Date.now()-nsetTimeout(o,ut))}return{success:!1,error:"Health check timed out"}}static async waitForExit(t,e){let r=Date.now();for(;Date.now()-rsetTimeout(n,pt))}throw new Error("Process did not exit within timeout")}static getLogFilePath(){let t=new Date().toISOString().slice(0,10);return m(v,`worker-${t}.log`)}static formatUptime(t){let e=new Date(t).getTime(),n=Date.now()-e,o=Math.floor(n/1e3),i=Math.floor(o/60),l=Math.floor(i/60),_=Math.floor(l/24);return _>0?`${_}d ${l%24}h`:l>0?`${l}h ${i%60}m`:i>0?`${i}m ${o%60}s`:`${o}s`}};import x from"path";import{homedir as Et}from"os";var M={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function N(s){return process.platform==="win32"?Math.round(s*M.WINDOWS_MULTIPLIER):s}var me=x.join(Et(),".claude","plugins","marketplaces","thedotmack"),_e=N(M.HEALTH_CHECK),E=null;function W(){if(E!==null)return E;try{let s=x.join(u.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=u.loadFromFile(s);return E=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),E}catch(s){return f.debug("SYSTEM","Failed to load port from settings, using default",{error:s}),E=parseInt(u.get("CLAUDE_MEM_WORKER_PORT"),10),E}}var ft=process.argv[2],$=W();async function gt(){switch(ft){case"start":{let s=await p.start($);if(s.success){console.log(`Worker started (PID: ${s.pid})`);let t=new Date().toISOString().slice(0,10);console.log(`Logs: ~/.claude-mem/logs/worker-${t}.log`),process.exit(0)}else console.error(`Failed to start: ${s.error}`),process.exit(1);break}case"stop":await p.stop(),console.log("Worker stopped"),process.exit(0);case"restart":{let s=await p.restart($);s.success?(console.log(`Worker restarted (PID: ${s.pid})`),process.exit(0)):(console.error(`Failed to restart: ${s.error}`),process.exit(1));break}case"status":{let s=await p.status();s.running?(console.log("Worker is running"),console.log(` PID: ${s.pid}`),console.log(` Port: ${s.port}`),console.log(` Uptime: ${s.uptime}`)):console.log("Worker is not running"),process.exit(0)}default:console.log("Usage: worker-cli.js "),process.exit(1)}}gt().catch(s=>{console.error(s),process.exit(1)}); diff --git a/plugin/scripts/worker-service.cjs b/plugin/scripts/worker-service.cjs index 7435f9fe..067c7366 100755 --- a/plugin/scripts/worker-service.cjs +++ b/plugin/scripts/worker-service.cjs @@ -467,7 +467,7 @@ ${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let r=Obje JOIN sdk_sessions s ON up.claude_session_id = s.claude_session_id WHERE up.created_at_epoch >= ? AND up.created_at_epoch <= ? ${n.replace("project","s.project")} ORDER BY up.created_at_epoch ASC - `;try{let d=this.db.prepare(u).all(l,c,...o),v=this.db.prepare(p).all(l,c,...o),h=this.db.prepare(m).all(l,c,...o);return{observations:d,sessions:v.map(f=>({id:f.id,sdk_session_id:f.sdk_session_id,project:f.project,request:f.request,completed:f.completed,next_steps:f.next_steps,created_at:f.created_at,created_at_epoch:f.created_at_epoch})),prompts:h.map(f=>({id:f.id,claude_session_id:f.claude_session_id,project:f.project,prompt:f.prompt_text,created_at:f.created_at,created_at_epoch:f.created_at_epoch}))}}catch(d){return console.error("[SessionStore] Error querying timeline records:",d.message),{observations:[],sessions:[],prompts:[]}}}close(){this.db.close()}}});var Kw=U((OB,Xw)=>{"use strict";var Zw=Object.getOwnPropertySymbols,a5=Object.prototype.hasOwnProperty,s5=Object.prototype.propertyIsEnumerable;function n5(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function i5(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;var t=Object.getOwnPropertyNames(e).map(function(i){return e[i]});if(t.join("")!=="0123456789")return!1;var s={};return"abcdefghijklmnopqrst".split("").forEach(function(i){s[i]=i}),Object.keys(Object.assign({},s)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}Xw.exports=i5()?Object.assign:function(a,e){for(var r,t=n5(a),s,i=1;i{(function(){"use strict";var a=Kw(),e=Yp(),r={origin:"*",methods:"GET,HEAD,PUT,PATCH,POST,DELETE",preflightContinue:!1,optionsSuccessStatus:204};function t(v){return typeof v=="string"||v instanceof String}function s(v,h){if(Array.isArray(h)){for(var f=0;fv5});function c5(){let a=Bs.default.join((0,ql.homedir)(),".claude-mem","settings.json"),e=lt.loadFromFile(a);try{return{totalObservationCount:parseInt(e.CLAUDE_MEM_CONTEXT_OBSERVATIONS,10),fullObservationCount:parseInt(e.CLAUDE_MEM_CONTEXT_FULL_COUNT,10),sessionCount:parseInt(e.CLAUDE_MEM_CONTEXT_SESSION_COUNT,10),showReadTokens:e.CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS==="true",showWorkTokens:e.CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS==="true",showSavingsAmount:e.CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT==="true",showSavingsPercent:e.CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT==="true",observationTypes:new Set(e.CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES.split(",").map(r=>r.trim()).filter(Boolean)),observationConcepts:new Set(e.CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS.split(",").map(r=>r.trim()).filter(Boolean)),fullObservationField:e.CLAUDE_MEM_CONTEXT_FULL_FIELD,showLastSummary:e.CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY==="true",showLastMessage:e.CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE==="true"}}catch(r){return M.warn("WORKER","Failed to load context settings, using defaults",{},r),{totalObservationCount:50,fullObservationCount:5,sessionCount:10,showReadTokens:!0,showWorkTokens:!0,showSavingsAmount:!0,showSavingsPercent:!0,observationTypes:new Set(jn),observationConcepts:new Set($n),fullObservationField:"narrative",showLastSummary:!0,showLastMessage:!1}}}function l1(a){if(!a)return[];try{let e=JSON.parse(a);return Array.isArray(e)?e:[]}catch{return[]}}function u5(a){return new Date(a).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}function p5(a){return new Date(a).toLocaleString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function d5(a){return new Date(a).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"})}function f5(a,e){return Bs.default.isAbsolute(a)?Bs.default.relative(e,a):a}function Fl(a,e,r,t){return e?t?[`${r}${a}:${ae.reset} ${e}`,""]:[`**${a}**: ${e}`,""]:[]}function m5(a){return a.replace(/\//g,"-")}function h5(a){try{if(!(0,ei.existsSync)(a))return{userMessage:"",assistantMessage:""};let e=(0,ei.readFileSync)(a,"utf-8").trim();if(!e)return{userMessage:"",assistantMessage:""};let r=e.split(` + `;try{let d=this.db.prepare(u).all(l,c,...o),v=this.db.prepare(p).all(l,c,...o),h=this.db.prepare(m).all(l,c,...o);return{observations:d,sessions:v.map(f=>({id:f.id,sdk_session_id:f.sdk_session_id,project:f.project,request:f.request,completed:f.completed,next_steps:f.next_steps,created_at:f.created_at,created_at_epoch:f.created_at_epoch})),prompts:h.map(f=>({id:f.id,claude_session_id:f.claude_session_id,project:f.project,prompt:f.prompt_text,created_at:f.created_at,created_at_epoch:f.created_at_epoch}))}}catch(d){return console.error("[SessionStore] Error querying timeline records:",d.message),{observations:[],sessions:[],prompts:[]}}}close(){this.db.close()}}});var Kw=U((IB,Xw)=>{"use strict";var Zw=Object.getOwnPropertySymbols,a5=Object.prototype.hasOwnProperty,s5=Object.prototype.propertyIsEnumerable;function n5(a){if(a==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(a)}function i5(){try{if(!Object.assign)return!1;var a=new String("abc");if(a[5]="de",Object.getOwnPropertyNames(a)[0]==="5")return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;var t=Object.getOwnPropertyNames(e).map(function(i){return e[i]});if(t.join("")!=="0123456789")return!1;var s={};return"abcdefghijklmnopqrst".split("").forEach(function(i){s[i]=i}),Object.keys(Object.assign({},s)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}Xw.exports=i5()?Object.assign:function(a,e){for(var r,t=n5(a),s,i=1;i{(function(){"use strict";var a=Kw(),e=Yp(),r={origin:"*",methods:"GET,HEAD,PUT,PATCH,POST,DELETE",preflightContinue:!1,optionsSuccessStatus:204};function t(v){return typeof v=="string"||v instanceof String}function s(v,h){if(Array.isArray(h)){for(var f=0;fv5});function c5(){let a=Bs.default.join((0,ql.homedir)(),".claude-mem","settings.json"),e=lt.loadFromFile(a);try{return{totalObservationCount:parseInt(e.CLAUDE_MEM_CONTEXT_OBSERVATIONS,10),fullObservationCount:parseInt(e.CLAUDE_MEM_CONTEXT_FULL_COUNT,10),sessionCount:parseInt(e.CLAUDE_MEM_CONTEXT_SESSION_COUNT,10),showReadTokens:e.CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS==="true",showWorkTokens:e.CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS==="true",showSavingsAmount:e.CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT==="true",showSavingsPercent:e.CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT==="true",observationTypes:new Set(e.CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES.split(",").map(r=>r.trim()).filter(Boolean)),observationConcepts:new Set(e.CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS.split(",").map(r=>r.trim()).filter(Boolean)),fullObservationField:e.CLAUDE_MEM_CONTEXT_FULL_FIELD,showLastSummary:e.CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY==="true",showLastMessage:e.CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE==="true"}}catch(r){return M.warn("WORKER","Failed to load context settings, using defaults",{},r),{totalObservationCount:50,fullObservationCount:5,sessionCount:10,showReadTokens:!0,showWorkTokens:!0,showSavingsAmount:!0,showSavingsPercent:!0,observationTypes:new Set(jn),observationConcepts:new Set($n),fullObservationField:"narrative",showLastSummary:!0,showLastMessage:!1}}}function l1(a){if(!a)return[];try{let e=JSON.parse(a);return Array.isArray(e)?e:[]}catch{return[]}}function u5(a){return new Date(a).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0})}function p5(a){return new Date(a).toLocaleString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function d5(a){return new Date(a).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"})}function f5(a,e){return Bs.default.isAbsolute(a)?Bs.default.relative(e,a):a}function Fl(a,e,r,t){return e?t?[`${r}${a}:${ae.reset} ${e}`,""]:[`**${a}**: ${e}`,""]:[]}function m5(a){return a.replace(/\//g,"-")}function h5(a){try{if(!(0,ei.existsSync)(a))return{userMessage:"",assistantMessage:""};let e=(0,ei.readFileSync)(a,"utf-8").trim();if(!e)return{userMessage:"",assistantMessage:""};let r=e.split(` `).filter(s=>s.trim()),t="";for(let s=r.length-1;s>=0;s--)try{let i=r[s];if(!i.includes('"type":"assistant"'))continue;let n=JSON.parse(i);if(n.type==="assistant"&&n.message?.content&&Array.isArray(n.message.content)){let o="";for(let l of n.message.content)l.type==="text"&&(o+=l.text);if(o=o.replace(/[\s\S]*?<\/system-reminder>/g,"").trim(),o){t=o;break}}}catch{continue}return{userMessage:"",assistantMessage:t}}catch(e){return M.failure("WORKER","Failed to extract prior messages from transcript",{transcriptPath:a},e),{userMessage:"",assistantMessage:""}}}async function v5(a,e=!1){let r=c5(),t=a?.cwd??process.cwd(),s=t?Bs.default.basename(t):"unknown-project",i=null;try{i=new $a}catch(y){if(y.code==="ERR_DLOPEN_FAILED"){try{(0,ei.unlinkSync)(o5)}catch{}return console.error("Native module rebuild needed - restart Claude Code to auto-fix"),""}throw y}let n=Array.from(r.observationTypes),o=n.map(()=>"?").join(","),l=Array.from(r.observationConcepts),c=l.map(()=>"?").join(","),u=i.db.prepare(` SELECT id, sdk_session_id, type, title, subtitle, narrative, @@ -499,7 +499,7 @@ No previous sessions found for this project yet.`;let v=p.slice(0,r.sessionCount `):null;if(e){let $e=Q?`${ae.dim}${Ee}${ae.reset}`:" ".repeat(Ee.length),ze=r.showReadTokens&&G>0?`${ae.dim}(~${G}t)${ae.reset}`:"",_e=r.showWorkTokens&&te>0?`${ae.dim}(${le} ${te.toLocaleString()}t)${ae.reset}`:"";f.push(` ${ae.dim}#${Y.id}${ae.reset} ${$e} ${De} ${ae.bright}${we}${ae.reset}`),ce&&f.push(` ${ae.dim}${ce}${ae.reset}`),(ze||_e)&&f.push(` ${ze} ${_e}`),f.push("")}else{X&&(f.push(""),X=!1),f.push(`**#${Y.id}** ${ne||"\u2033"} ${De} **${we}**`),ce&&(f.push(""),f.push(ce),f.push(""));let $e=[];r.showReadTokens&&$e.push(`Read: ~${G}`),r.showWorkTokens&&$e.push(`Work: ${W}`),$e.length>0&&f.push($e.join(", ")),f.push(""),K=null}}else if(e){let ce=Q?`${ae.dim}${Ee}${ae.reset}`:" ".repeat(Ee.length),$e=r.showReadTokens&&G>0?`${ae.dim}(~${G}t)${ae.reset}`:"",ze=r.showWorkTokens&&te>0?`${ae.dim}(${le} ${te.toLocaleString()}t)${ae.reset}`:"";f.push(` ${ae.dim}#${Y.id}${ae.reset} ${ce} ${De} ${we} ${$e} ${ze}`)}else{let ce=r.showReadTokens?`~${G}`:"",$e=r.showWorkTokens?W:"";f.push(`| #${Y.id} | ${ne||"\u2033"} | ${De} | ${we} | ${ce} | ${$e} |`)}}X&&f.push("")}let O=p[0],j=u[0];if(r.showLastSummary&&O&&(O.investigated||O.learned||O.completed||O.next_steps)&&(!j||O.created_at_epoch>j.created_at_epoch)&&(f.push(...Fl("Investigated",O.investigated,ae.blue,e)),f.push(...Fl("Learned",O.learned,ae.yellow,e)),f.push(...Fl("Completed",O.completed,ae.green,e)),f.push(...Fl("Next Steps",O.next_steps,ae.magenta,e))),d&&(f.push(""),f.push("---"),f.push(""),e?(f.push(`${ae.bright}${ae.magenta}\u{1F4CB} Previously${ae.reset}`),f.push(""),f.push(`${ae.dim}A: ${d}${ae.reset}`)):(f.push("**\u{1F4CB} Previously**"),f.push(""),f.push(`A: ${d}`)),f.push("")),T&&b>0&&w>0){let z=Math.round(b/1e3);f.push(""),e?f.push(`${ae.dim}\u{1F4B0} Access ${z}k tokens of past research & decisions for just ${g.toLocaleString()}t. Use the mem-search skill to access memories by ID instead of re-reading files.${ae.reset}`):f.push(`\u{1F4B0} Access ${z}k tokens of past research & decisions for just ${g.toLocaleString()}t. Use the mem-search skill to access memories by ID instead of re-reading files.`)}}return i?.close(),f.join(` `).trimEnd()}var Bs,ql,ei,o5,c1,l5,ae,If=Zs(()=>{"use strict";Bs=Tt(require("path"),1),ql=require("os"),ei=require("fs");nl();el();mt();oa();o5=Bs.default.join((0,ql.homedir)(),".claude","plugins","marketplaces","thedotmack","plugin",".install-version");c1=4,l5=1,ae={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",cyan:"\x1B[36m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",gray:"\x1B[90m",red:"\x1B[31m"}});var b5={};tu(b5,{WorkerService:()=>Vl});module.exports=C1(b5);var v1=Tt(rd(),1),zl=Tt(require("path"),1);var S={};tu(S,{BRAND:()=>YD,DIRTY:()=>ss,EMPTY_PATH:()=>kD,INVALID:()=>Re,NEVER:()=>$N,OK:()=>kt,ParseStatus:()=>Rt,Schema:()=>Be,ZodAny:()=>Aa,ZodArray:()=>ia,ZodBigInt:()=>is,ZodBoolean:()=>os,ZodBranded:()=>Hi,ZodCatch:()=>ys,ZodDate:()=>cs,ZodDefault:()=>gs,ZodDiscriminatedUnion:()=>Sc,ZodEffects:()=>dr,ZodEnum:()=>hs,ZodError:()=>Bt,ZodFirstPartyTypeKind:()=>Ce,ZodFunction:()=>wc,ZodIntersection:()=>ds,ZodIssueCode:()=>ee,ZodLazy:()=>fs,ZodLiteral:()=>ms,ZodMap:()=>On,ZodNaN:()=>kn,ZodNativeEnum:()=>vs,ZodNever:()=>kr,ZodNull:()=>us,ZodNullable:()=>Vr,ZodNumber:()=>ns,ZodObject:()=>zt,ZodOptional:()=>ur,ZodParsedType:()=>pe,ZodPipeline:()=>Bi,ZodPromise:()=>Ia,ZodReadonly:()=>bs,ZodRecord:()=>Ec,ZodSchema:()=>Be,ZodSet:()=>Cn,ZodString:()=>ka,ZodSymbol:()=>Rn,ZodTransformer:()=>dr,ZodTuple:()=>zr,ZodType:()=>Be,ZodUndefined:()=>ls,ZodUnion:()=>ps,ZodUnknown:()=>na,ZodVoid:()=>Pn,addIssueToContext:()=>ie,any:()=>oN,array:()=>pN,bigint:()=>rN,boolean:()=>Zx,coerce:()=>jN,custom:()=>Vx,date:()=>aN,datetimeRegex:()=>Bx,defaultErrorMap:()=>aa,discriminatedUnion:()=>hN,effect:()=>PN,enum:()=>wN,function:()=>_N,getErrorMap:()=>En,getParsedType:()=>Br,instanceof:()=>eN,intersection:()=>vN,isAborted:()=>xc,isAsync:()=>wn,isDirty:()=>_c,isValid:()=>Ca,late:()=>JD,lazy:()=>SN,literal:()=>EN,makeIssue:()=>Ui,map:()=>bN,nan:()=>tN,nativeEnum:()=>TN,never:()=>lN,null:()=>iN,nullable:()=>CN,number:()=>Wx,object:()=>dN,objectUtil:()=>ad,oboolean:()=>NN,onumber:()=>DN,optional:()=>ON,ostring:()=>IN,pipeline:()=>AN,preprocess:()=>kN,promise:()=>RN,quotelessJson:()=>PD,record:()=>yN,set:()=>xN,setErrorMap:()=>CD,strictObject:()=>fN,string:()=>Gx,symbol:()=>sN,transformer:()=>PN,tuple:()=>gN,undefined:()=>nN,union:()=>mN,unknown:()=>cN,util:()=>We,void:()=>uN});var We;(function(a){a.assertEqual=s=>{};function e(s){}a.assertIs=e;function r(s){throw new Error}a.assertNever=r,a.arrayToEnum=s=>{let i={};for(let n of s)i[n]=n;return i},a.getValidEnumValues=s=>{let i=a.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),n={};for(let o of i)n[o]=s[o];return a.objectValues(n)},a.objectValues=s=>a.objectKeys(s).map(function(i){return s[i]}),a.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&i.push(n);return i},a.find=(s,i)=>{for(let n of s)if(i(n))return n},a.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function t(s,i=" | "){return s.map(n=>typeof n=="string"?`'${n}'`:n).join(i)}a.joinValues=t,a.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(We||(We={}));var ad;(function(a){a.mergeShapes=(e,r)=>({...e,...r})})(ad||(ad={}));var pe=We.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Br=a=>{switch(typeof a){case"undefined":return pe.undefined;case"string":return pe.string;case"number":return Number.isNaN(a)?pe.nan:pe.number;case"boolean":return pe.boolean;case"function":return pe.function;case"bigint":return pe.bigint;case"symbol":return pe.symbol;case"object":return Array.isArray(a)?pe.array:a===null?pe.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?pe.promise:typeof Map<"u"&&a instanceof Map?pe.map:typeof Set<"u"&&a instanceof Set?pe.set:typeof Date<"u"&&a instanceof Date?pe.date:pe.object;default:return pe.unknown}};var ee=We.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),PD=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:"),Bt=class a extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=t=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},t={_errors:[]},s=i=>{for(let n of i.issues)if(n.code==="invalid_union")n.unionErrors.map(s);else if(n.code==="invalid_return_type")s(n.returnTypeError);else if(n.code==="invalid_arguments")s(n.argumentsError);else if(n.path.length===0)t._errors.push(r(n));else{let o=t,l=0;for(;lr.message){let r={},t=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else t.push(e(s));return{formErrors:t,fieldErrors:r}}get formErrors(){return this.flatten()}};Bt.create=a=>new Bt(a);var OD=(a,e)=>{let r;switch(a.code){case ee.invalid_type:a.received===pe.undefined?r="Required":r=`Expected ${a.expected}, received ${a.received}`;break;case ee.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(a.expected,We.jsonStringifyReplacer)}`;break;case ee.unrecognized_keys:r=`Unrecognized key(s) in object: ${We.joinValues(a.keys,", ")}`;break;case ee.invalid_union:r="Invalid input";break;case ee.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${We.joinValues(a.options)}`;break;case ee.invalid_enum_value:r=`Invalid enum value. Expected ${We.joinValues(a.options)}, received '${a.received}'`;break;case ee.invalid_arguments:r="Invalid function arguments";break;case ee.invalid_return_type:r="Invalid function return type";break;case ee.invalid_date:r="Invalid date";break;case ee.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(r=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?r=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?r=`Invalid input: must end with "${a.validation.endsWith}"`:We.assertNever(a.validation):a.validation!=="regex"?r=`Invalid ${a.validation}`:r="Invalid";break;case ee.too_small:a.type==="array"?r=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?r=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?r=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="bigint"?r=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?r=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:r="Invalid input";break;case ee.too_big:a.type==="array"?r=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?r=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?r=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?r=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?r=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:r="Invalid input";break;case ee.custom:r="Invalid input";break;case ee.invalid_intersection_types:r="Intersection results could not be merged";break;case ee.not_multiple_of:r=`Number must be a multiple of ${a.multipleOf}`;break;case ee.not_finite:r="Number must be finite";break;default:r=e.defaultError,We.assertNever(a)}return{message:r}},aa=OD;var Lx=aa;function CD(a){Lx=a}function En(){return Lx}var Ui=a=>{let{data:e,path:r,errorMaps:t,issueData:s}=a,i=[...r,...s.path||[]],n={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",l=t.filter(c=>!!c).slice().reverse();for(let c of l)o=c(n,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},kD=[];function ie(a,e){let r=En(),t=Ui({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,r,r===aa?void 0:aa].filter(s=>!!s)});a.common.issues.push(t)}var Rt=class a{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let t=[];for(let s of r){if(s.status==="aborted")return Re;s.status==="dirty"&&e.dirty(),t.push(s.value)}return{status:e.value,value:t}}static async mergeObjectAsync(e,r){let t=[];for(let s of r){let i=await s.key,n=await s.value;t.push({key:i,value:n})}return a.mergeObjectSync(e,t)}static mergeObjectSync(e,r){let t={};for(let s of r){let{key:i,value:n}=s;if(i.status==="aborted"||n.status==="aborted")return Re;i.status==="dirty"&&e.dirty(),n.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof n.value<"u"||s.alwaysSet)&&(t[i.value]=n.value)}return{status:e.value,value:t}}},Re=Object.freeze({status:"aborted"}),ss=a=>({status:"dirty",value:a}),kt=a=>({status:"valid",value:a}),xc=a=>a.status==="aborted",_c=a=>a.status==="dirty",Ca=a=>a.status==="valid",wn=a=>typeof Promise<"u"&&a instanceof Promise;var ve;(function(a){a.errToObj=e=>typeof e=="string"?{message:e}:e||{},a.toString=e=>typeof e=="string"?e:e?.message})(ve||(ve={}));var pr=class{constructor(e,r,t,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=t,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Fx=(a,e)=>{if(Ca(e))return{success:!0,data:e.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Bt(a.common.issues);return this._error=r,this._error}}};function Fe(a){if(!a)return{};let{errorMap:e,invalid_type_error:r,required_error:t,description:s}=a;if(e&&(r||t))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(n,o)=>{let{message:l}=a;return n.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??t??o.defaultError}:n.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:s}}var Be=class{get description(){return this._def.description}_getType(e){return Br(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Br(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Rt,ctx:{common:e.parent.common,data:e.data,parsedType:Br(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(wn(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let t=this.safeParse(e,r);if(t.success)return t.data;throw t.error}safeParse(e,r){let t={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)},s=this._parseSync({data:e,path:t.path,parent:t});return Fx(t,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)};if(!this["~standard"].async)try{let t=this._parseSync({data:e,path:[],parent:r});return Ca(t)?{value:t.value}:{issues:r.common.issues}}catch(t){t?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(t=>Ca(t)?{value:t.value}:{issues:r.common.issues})}async parseAsync(e,r){let t=await this.safeParseAsync(e,r);if(t.success)return t.data;throw t.error}async safeParseAsync(e,r){let t={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Br(e)},s=this._parse({data:e,path:t.path,parent:t}),i=await(wn(s)?s:Promise.resolve(s));return Fx(t,i)}refine(e,r){let t=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let n=e(s),o=()=>i.addIssue({code:ee.custom,...t(s)});return typeof Promise<"u"&&n instanceof Promise?n.then(l=>l?!0:(o(),!1)):n?!0:(o(),!1)})}refinement(e,r){return this._refinement((t,s)=>e(t)?!0:(s.addIssue(typeof r=="function"?r(t,s):r),!1))}_refinement(e){return new dr({schema:this,typeName:Ce.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return ur.create(this,this._def)}nullable(){return Vr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ia.create(this)}promise(){return Ia.create(this,this._def)}or(e){return ps.create([this,e],this._def)}and(e){return ds.create(this,e,this._def)}transform(e){return new dr({...Fe(this._def),schema:this,typeName:Ce.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new gs({...Fe(this._def),innerType:this,defaultValue:r,typeName:Ce.ZodDefault})}brand(){return new Hi({typeName:Ce.ZodBranded,type:this,...Fe(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ys({...Fe(this._def),innerType:this,catchValue:r,typeName:Ce.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Bi.create(this,e)}readonly(){return bs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},AD=/^c[^\s-]{8,}$/i,ID=/^[0-9a-z]+$/,DD=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ND=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,jD=/^[a-z0-9_-]{21}$/i,$D=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,MD=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,LD=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,FD="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",sd,qD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,UD=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,HD=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,BD=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zD=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,VD=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ux="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",GD=new RegExp(`^${Ux}$`);function Hx(a){let e="[0-5]\\d";a.precision?e=`${e}\\.\\d{${a.precision}}`:a.precision==null&&(e=`${e}(\\.\\d+)?`);let r=a.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function WD(a){return new RegExp(`^${Hx(a)}$`)}function Bx(a){let e=`${Ux}T${Hx(a)}`,r=[];return r.push(a.local?"Z?":"Z"),a.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function ZD(a,e){return!!((e==="v4"||!e)&&qD.test(a)||(e==="v6"||!e)&&HD.test(a))}function XD(a,e){if(!$D.test(a))return!1;try{let[r]=a.split(".");if(!r)return!1;let t=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(t));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function KD(a,e){return!!((e==="v4"||!e)&&UD.test(a)||(e==="v6"||!e)&&BD.test(a))}var ka=class a extends Be{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==pe.string){let i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:pe.string,received:i.parsedType}),Re}let t=new Rt,s;for(let i of this._def.checks)if(i.kind==="min")e.data.lengthi.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="length"){let n=e.data.length>i.value,o=e.data.lengthe.test(s),{validation:r,code:ee.invalid_string,...ve.errToObj(t)})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ve.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ve.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ve.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ve.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ve.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ve.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ve.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ve.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ve.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ve.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ve.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ve.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ve.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ve.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...ve.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ve.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...ve.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...ve.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...ve.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...ve.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...ve.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...ve.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...ve.errToObj(r)})}nonempty(e){return this.min(1,ve.errToObj(e))}trim(){return new a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew ka({checks:[],typeName:Ce.ZodString,coerce:a?.coerce??!1,...Fe(a)});function QD(a,e){let r=(a.toString().split(".")[1]||"").length,t=(e.toString().split(".")[1]||"").length,s=r>t?r:t,i=Number.parseInt(a.toFixed(s).replace(".","")),n=Number.parseInt(e.toFixed(s).replace(".",""));return i%n/10**s}var ns=class a extends Be{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==pe.number){let i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:pe.number,received:i.parsedType}),Re}let t,s=new Rt;for(let i of this._def.checks)i.kind==="int"?We.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),ie(t,{code:ee.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ee.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?QD(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ee.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),ie(t,{code:ee.not_finite,message:i.message}),s.dirty()):We.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,ve.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ve.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ve.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ve.toString(r))}setLimit(e,r,t,s){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:t,message:ve.toString(s)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ve.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ve.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ve.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ve.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ve.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ve.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:ve.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ve.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ve.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuee.kind==="int"||e.kind==="multipleOf"&&We.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let t of this._def.checks){if(t.kind==="finite"||t.kind==="int"||t.kind==="multipleOf")return!0;t.kind==="min"?(r===null||t.value>r)&&(r=t.value):t.kind==="max"&&(e===null||t.valuenew ns({checks:[],typeName:Ce.ZodNumber,coerce:a?.coerce||!1,...Fe(a)});var is=class a extends Be{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==pe.bigint)return this._getInvalidInput(e);let t,s=new Rt;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ee.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),ie(t,{code:ee.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):We.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:pe.bigint,received:r.parsedType}),Re}gte(e,r){return this.setLimit("min",e,!0,ve.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ve.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ve.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ve.toString(r))}setLimit(e,r,t,s){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:t,message:ve.toString(s)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ve.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ve.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ve.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ve.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ve.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew is({checks:[],typeName:Ce.ZodBigInt,coerce:a?.coerce??!1,...Fe(a)});var os=class extends Be{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==pe.boolean){let t=this._getOrReturnCtx(e);return ie(t,{code:ee.invalid_type,expected:pe.boolean,received:t.parsedType}),Re}return kt(e.data)}};os.create=a=>new os({typeName:Ce.ZodBoolean,coerce:a?.coerce||!1,...Fe(a)});var cs=class a extends Be{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==pe.date){let i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:pe.date,received:i.parsedType}),Re}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_date}),Re}let t=new Rt,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):We.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:ve.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:ve.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew cs({checks:[],coerce:a?.coerce||!1,typeName:Ce.ZodDate,...Fe(a)});var Rn=class extends Be{_parse(e){if(this._getType(e)!==pe.symbol){let t=this._getOrReturnCtx(e);return ie(t,{code:ee.invalid_type,expected:pe.symbol,received:t.parsedType}),Re}return kt(e.data)}};Rn.create=a=>new Rn({typeName:Ce.ZodSymbol,...Fe(a)});var ls=class extends Be{_parse(e){if(this._getType(e)!==pe.undefined){let t=this._getOrReturnCtx(e);return ie(t,{code:ee.invalid_type,expected:pe.undefined,received:t.parsedType}),Re}return kt(e.data)}};ls.create=a=>new ls({typeName:Ce.ZodUndefined,...Fe(a)});var us=class extends Be{_parse(e){if(this._getType(e)!==pe.null){let t=this._getOrReturnCtx(e);return ie(t,{code:ee.invalid_type,expected:pe.null,received:t.parsedType}),Re}return kt(e.data)}};us.create=a=>new us({typeName:Ce.ZodNull,...Fe(a)});var Aa=class extends Be{constructor(){super(...arguments),this._any=!0}_parse(e){return kt(e.data)}};Aa.create=a=>new Aa({typeName:Ce.ZodAny,...Fe(a)});var na=class extends Be{constructor(){super(...arguments),this._unknown=!0}_parse(e){return kt(e.data)}};na.create=a=>new na({typeName:Ce.ZodUnknown,...Fe(a)});var kr=class extends Be{_parse(e){let r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:pe.never,received:r.parsedType}),Re}};kr.create=a=>new kr({typeName:Ce.ZodNever,...Fe(a)});var Pn=class extends Be{_parse(e){if(this._getType(e)!==pe.undefined){let t=this._getOrReturnCtx(e);return ie(t,{code:ee.invalid_type,expected:pe.void,received:t.parsedType}),Re}return kt(e.data)}};Pn.create=a=>new Pn({typeName:Ce.ZodVoid,...Fe(a)});var ia=class a extends Be{_parse(e){let{ctx:r,status:t}=this._processInputParams(e),s=this._def;if(r.parsedType!==pe.array)return ie(r,{code:ee.invalid_type,expected:pe.array,received:r.parsedType}),Re;if(s.exactLength!==null){let n=r.data.length>s.exactLength.value,o=r.data.lengths.maxLength.value&&(ie(r,{code:ee.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),t.dirty()),r.common.async)return Promise.all([...r.data].map((n,o)=>s.type._parseAsync(new pr(r,n,r.path,o)))).then(n=>Rt.mergeArray(t,n));let i=[...r.data].map((n,o)=>s.type._parseSync(new pr(r,n,r.path,o)));return Rt.mergeArray(t,i)}get element(){return this._def.type}min(e,r){return new a({...this._def,minLength:{value:e,message:ve.toString(r)}})}max(e,r){return new a({...this._def,maxLength:{value:e,message:ve.toString(r)}})}length(e,r){return new a({...this._def,exactLength:{value:e,message:ve.toString(r)}})}nonempty(e){return this.min(1,e)}};ia.create=(a,e)=>new ia({type:a,minLength:null,maxLength:null,exactLength:null,typeName:Ce.ZodArray,...Fe(e)});function Tn(a){if(a instanceof zt){let e={};for(let r in a.shape){let t=a.shape[r];e[r]=ur.create(Tn(t))}return new zt({...a._def,shape:()=>e})}else return a instanceof ia?new ia({...a._def,type:Tn(a.element)}):a instanceof ur?ur.create(Tn(a.unwrap())):a instanceof Vr?Vr.create(Tn(a.unwrap())):a instanceof zr?zr.create(a.items.map(e=>Tn(e))):a}var zt=class a extends Be{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=We.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==pe.object){let c=this._getOrReturnCtx(e);return ie(c,{code:ee.invalid_type,expected:pe.object,received:c.parsedType}),Re}let{status:t,ctx:s}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof kr&&this._def.unknownKeys==="strip"))for(let c in s.data)n.includes(c)||o.push(c);let l=[];for(let c of n){let u=i[c],p=s.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new pr(s,p,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof kr){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of o)l.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(c==="strict")o.length>0&&(ie(s,{code:ee.unrecognized_keys,keys:o}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of o){let p=s.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new pr(s,p,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let p=await u.key,m=await u.value;c.push({key:p,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>Rt.mergeObjectSync(t,c)):Rt.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return ve.errToObj,new a({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,t)=>{let s=this._def.errorMap?.(r,t).message??t.defaultError;return r.code==="unrecognized_keys"?{message:ve.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new a({...this._def,unknownKeys:"strip"})}passthrough(){return new a({...this._def,unknownKeys:"passthrough"})}extend(e){return new a({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new a({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ce.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new a({...this._def,catchall:e})}pick(e){let r={};for(let t of We.objectKeys(e))e[t]&&this.shape[t]&&(r[t]=this.shape[t]);return new a({...this._def,shape:()=>r})}omit(e){let r={};for(let t of We.objectKeys(this.shape))e[t]||(r[t]=this.shape[t]);return new a({...this._def,shape:()=>r})}deepPartial(){return Tn(this)}partial(e){let r={};for(let t of We.objectKeys(this.shape)){let s=this.shape[t];e&&!e[t]?r[t]=s:r[t]=s.optional()}return new a({...this._def,shape:()=>r})}required(e){let r={};for(let t of We.objectKeys(this.shape))if(e&&!e[t])r[t]=this.shape[t];else{let i=this.shape[t];for(;i instanceof ur;)i=i._def.innerType;r[t]=i}return new a({...this._def,shape:()=>r})}keyof(){return zx(We.objectKeys(this.shape))}};zt.create=(a,e)=>new zt({shape:()=>a,unknownKeys:"strip",catchall:kr.create(),typeName:Ce.ZodObject,...Fe(e)});zt.strictCreate=(a,e)=>new zt({shape:()=>a,unknownKeys:"strict",catchall:kr.create(),typeName:Ce.ZodObject,...Fe(e)});zt.lazycreate=(a,e)=>new zt({shape:a,unknownKeys:"strip",catchall:kr.create(),typeName:Ce.ZodObject,...Fe(e)});var ps=class extends Be{_parse(e){let{ctx:r}=this._processInputParams(e),t=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let n=i.map(o=>new Bt(o.ctx.common.issues));return ie(r,{code:ee.invalid_union,unionErrors:n}),Re}if(r.common.async)return Promise.all(t.map(async i=>{let n={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:n}),ctx:n}})).then(s);{let i,n=[];for(let l of t){let c={...r,common:{...r.common,issues:[]},parent:null},u=l._parseSync({data:r.data,path:r.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:c}),c.common.issues.length&&n.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=n.map(l=>new Bt(l));return ie(r,{code:ee.invalid_union,unionErrors:o}),Re}}get options(){return this._def.options}};ps.create=(a,e)=>new ps({options:a,typeName:Ce.ZodUnion,...Fe(e)});var sa=a=>a instanceof fs?sa(a.schema):a instanceof dr?sa(a.innerType()):a instanceof ms?[a.value]:a instanceof hs?a.options:a instanceof vs?We.objectValues(a.enum):a instanceof gs?sa(a._def.innerType):a instanceof ls?[void 0]:a instanceof us?[null]:a instanceof ur?[void 0,...sa(a.unwrap())]:a instanceof Vr?[null,...sa(a.unwrap())]:a instanceof Hi||a instanceof bs?sa(a.unwrap()):a instanceof ys?sa(a._def.innerType):[],Sc=class a extends Be{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==pe.object)return ie(r,{code:ee.invalid_type,expected:pe.object,received:r.parsedType}),Re;let t=this.discriminator,s=r.data[t],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(ie(r,{code:ee.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[t]}),Re)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,t){let s=new Map;for(let i of r){let n=sa(i.shape[e]);if(!n.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of n){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new a({typeName:Ce.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...Fe(t)})}};function nd(a,e){let r=Br(a),t=Br(e);if(a===e)return{valid:!0,data:a};if(r===pe.object&&t===pe.object){let s=We.objectKeys(e),i=We.objectKeys(a).filter(o=>s.indexOf(o)!==-1),n={...a,...e};for(let o of i){let l=nd(a[o],e[o]);if(!l.valid)return{valid:!1};n[o]=l.data}return{valid:!0,data:n}}else if(r===pe.array&&t===pe.array){if(a.length!==e.length)return{valid:!1};let s=[];for(let i=0;i{if(xc(i)||xc(n))return Re;let o=nd(i.value,n.value);return o.valid?((_c(i)||_c(n))&&r.dirty(),{status:r.value,value:o.data}):(ie(t,{code:ee.invalid_intersection_types}),Re)};return t.common.async?Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([i,n])=>s(i,n)):s(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};ds.create=(a,e,r)=>new ds({left:a,right:e,typeName:Ce.ZodIntersection,...Fe(r)});var zr=class a extends Be{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==pe.array)return ie(t,{code:ee.invalid_type,expected:pe.array,received:t.parsedType}),Re;if(t.data.lengththis._def.items.length&&(ie(t,{code:ee.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...t.data].map((n,o)=>{let l=this._def.items[o]||this._def.rest;return l?l._parse(new pr(t,n,t.path,o)):null}).filter(n=>!!n);return t.common.async?Promise.all(i).then(n=>Rt.mergeArray(r,n)):Rt.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new a({...this._def,rest:e})}};zr.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new zr({items:a,typeName:Ce.ZodTuple,rest:null,...Fe(e)})};var Ec=class a extends Be{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==pe.object)return ie(t,{code:ee.invalid_type,expected:pe.object,received:t.parsedType}),Re;let s=[],i=this._def.keyType,n=this._def.valueType;for(let o in t.data)s.push({key:i._parse(new pr(t,o,t.path,o)),value:n._parse(new pr(t,t.data[o],t.path,o)),alwaysSet:o in t.data});return t.common.async?Rt.mergeObjectAsync(r,s):Rt.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,t){return r instanceof Be?new a({keyType:e,valueType:r,typeName:Ce.ZodRecord,...Fe(t)}):new a({keyType:ka.create(),valueType:e,typeName:Ce.ZodRecord,...Fe(r)})}},On=class extends Be{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==pe.map)return ie(t,{code:ee.invalid_type,expected:pe.map,received:t.parsedType}),Re;let s=this._def.keyType,i=this._def.valueType,n=[...t.data.entries()].map(([o,l],c)=>({key:s._parse(new pr(t,o,t.path,[c,"key"])),value:i._parse(new pr(t,l,t.path,[c,"value"]))}));if(t.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let l of n){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Re;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(c.value,u.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let l of n){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Re;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(c.value,u.value)}return{status:r.value,value:o}}}};On.create=(a,e,r)=>new On({valueType:e,keyType:a,typeName:Ce.ZodMap,...Fe(r)});var Cn=class a extends Be{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==pe.set)return ie(t,{code:ee.invalid_type,expected:pe.set,received:t.parsedType}),Re;let s=this._def;s.minSize!==null&&t.data.sizes.maxSize.value&&(ie(t,{code:ee.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function n(l){let c=new Set;for(let u of l){if(u.status==="aborted")return Re;u.status==="dirty"&&r.dirty(),c.add(u.value)}return{status:r.value,value:c}}let o=[...t.data.values()].map((l,c)=>i._parse(new pr(t,l,t.path,c)));return t.common.async?Promise.all(o).then(l=>n(l)):n(o)}min(e,r){return new a({...this._def,minSize:{value:e,message:ve.toString(r)}})}max(e,r){return new a({...this._def,maxSize:{value:e,message:ve.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Cn.create=(a,e)=>new Cn({valueType:a,minSize:null,maxSize:null,typeName:Ce.ZodSet,...Fe(e)});var wc=class a extends Be{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==pe.function)return ie(r,{code:ee.invalid_type,expected:pe.function,received:r.parsedType}),Re;function t(o,l){return Ui({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,En(),aa].filter(c=>!!c),issueData:{code:ee.invalid_arguments,argumentsError:l}})}function s(o,l){return Ui({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,En(),aa].filter(c=>!!c),issueData:{code:ee.invalid_return_type,returnTypeError:l}})}let i={errorMap:r.common.contextualErrorMap},n=r.data;if(this._def.returns instanceof Ia){let o=this;return kt(async function(...l){let c=new Bt([]),u=await o._def.args.parseAsync(l,i).catch(d=>{throw c.addIssue(t(l,d)),c}),p=await Reflect.apply(n,this,u);return await o._def.returns._def.type.parseAsync(p,i).catch(d=>{throw c.addIssue(s(p,d)),c})})}else{let o=this;return kt(function(...l){let c=o._def.args.safeParse(l,i);if(!c.success)throw new Bt([t(l,c.error)]);let u=Reflect.apply(n,this,c.data),p=o._def.returns.safeParse(u,i);if(!p.success)throw new Bt([s(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new a({...this._def,args:zr.create(e).rest(na.create())})}returns(e){return new a({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,t){return new a({args:e||zr.create([]).rest(na.create()),returns:r||na.create(),typeName:Ce.ZodFunction,...Fe(t)})}},fs=class extends Be{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};fs.create=(a,e)=>new fs({getter:a,typeName:Ce.ZodLazy,...Fe(e)});var ms=class extends Be{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return ie(r,{received:r.data,code:ee.invalid_literal,expected:this._def.value}),Re}return{status:"valid",value:e.data}}get value(){return this._def.value}};ms.create=(a,e)=>new ms({value:a,typeName:Ce.ZodLiteral,...Fe(e)});function zx(a,e){return new hs({values:a,typeName:Ce.ZodEnum,...Fe(e)})}var hs=class a extends Be{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),t=this._def.values;return ie(r,{expected:We.joinValues(t),received:r.parsedType,code:ee.invalid_type}),Re}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),t=this._def.values;return ie(r,{received:r.data,code:ee.invalid_enum_value,options:t}),Re}return kt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return a.create(e,{...this._def,...r})}exclude(e,r=this._def){return a.create(this.options.filter(t=>!e.includes(t)),{...this._def,...r})}};hs.create=zx;var vs=class extends Be{_parse(e){let r=We.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(e);if(t.parsedType!==pe.string&&t.parsedType!==pe.number){let s=We.objectValues(r);return ie(t,{expected:We.joinValues(s),received:t.parsedType,code:ee.invalid_type}),Re}if(this._cache||(this._cache=new Set(We.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=We.objectValues(r);return ie(t,{received:t.data,code:ee.invalid_enum_value,options:s}),Re}return kt(e.data)}get enum(){return this._def.values}};vs.create=(a,e)=>new vs({values:a,typeName:Ce.ZodNativeEnum,...Fe(e)});var Ia=class extends Be{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==pe.promise&&r.common.async===!1)return ie(r,{code:ee.invalid_type,expected:pe.promise,received:r.parsedType}),Re;let t=r.parsedType===pe.promise?r.data:Promise.resolve(r.data);return kt(t.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Ia.create=(a,e)=>new Ia({type:a,typeName:Ce.ZodPromise,...Fe(e)});var dr=class extends Be{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ce.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:t}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:n=>{ie(t,n),n.fatal?r.abort():r.dirty()},get path(){return t.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let n=s.transform(t.data,i);if(t.common.async)return Promise.resolve(n).then(async o=>{if(r.value==="aborted")return Re;let l=await this._def.schema._parseAsync({data:o,path:t.path,parent:t});return l.status==="aborted"?Re:l.status==="dirty"?ss(l.value):r.value==="dirty"?ss(l.value):l});{if(r.value==="aborted")return Re;let o=this._def.schema._parseSync({data:n,path:t.path,parent:t});return o.status==="aborted"?Re:o.status==="dirty"?ss(o.value):r.value==="dirty"?ss(o.value):o}}if(s.type==="refinement"){let n=o=>{let l=s.refinement(o,i);if(t.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(t.common.async===!1){let o=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});return o.status==="aborted"?Re:(o.status==="dirty"&&r.dirty(),n(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(o=>o.status==="aborted"?Re:(o.status==="dirty"&&r.dirty(),n(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(t.common.async===!1){let n=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!Ca(n))return Re;let o=s.transform(n.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(n=>Ca(n)?Promise.resolve(s.transform(n.value,i)).then(o=>({status:r.value,value:o})):Re);We.assertNever(s)}};dr.create=(a,e,r)=>new dr({schema:a,typeName:Ce.ZodEffects,effect:e,...Fe(r)});dr.createWithPreprocess=(a,e,r)=>new dr({schema:e,effect:{type:"preprocess",transform:a},typeName:Ce.ZodEffects,...Fe(r)});var ur=class extends Be{_parse(e){return this._getType(e)===pe.undefined?kt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ur.create=(a,e)=>new ur({innerType:a,typeName:Ce.ZodOptional,...Fe(e)});var Vr=class extends Be{_parse(e){return this._getType(e)===pe.null?kt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Vr.create=(a,e)=>new Vr({innerType:a,typeName:Ce.ZodNullable,...Fe(e)});var gs=class extends Be{_parse(e){let{ctx:r}=this._processInputParams(e),t=r.data;return r.parsedType===pe.undefined&&(t=this._def.defaultValue()),this._def.innerType._parse({data:t,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};gs.create=(a,e)=>new gs({innerType:a,typeName:Ce.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Fe(e)});var ys=class extends Be{_parse(e){let{ctx:r}=this._processInputParams(e),t={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});return wn(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Bt(t.common.issues)},input:t.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Bt(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};ys.create=(a,e)=>new ys({innerType:a,typeName:Ce.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Fe(e)});var kn=class extends Be{_parse(e){if(this._getType(e)!==pe.nan){let t=this._getOrReturnCtx(e);return ie(t,{code:ee.invalid_type,expected:pe.nan,received:t.parsedType}),Re}return{status:"valid",value:e.data}}};kn.create=a=>new kn({typeName:Ce.ZodNaN,...Fe(a)});var YD=Symbol("zod_brand"),Hi=class extends Be{_parse(e){let{ctx:r}=this._processInputParams(e),t=r.data;return this._def.type._parse({data:t,path:r.path,parent:r})}unwrap(){return this._def.type}},Bi=class a extends Be{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:t.data,path:t.path,parent:t});return i.status==="aborted"?Re:i.status==="dirty"?(r.dirty(),ss(i.value)):this._def.out._parseAsync({data:i.value,path:t.path,parent:t})})();{let s=this._def.in._parseSync({data:t.data,path:t.path,parent:t});return s.status==="aborted"?Re:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:t.path,parent:t})}}static create(e,r){return new a({in:e,out:r,typeName:Ce.ZodPipeline})}},bs=class extends Be{_parse(e){let r=this._def.innerType._parse(e),t=s=>(Ca(s)&&(s.value=Object.freeze(s.value)),s);return wn(r)?r.then(s=>t(s)):t(r)}unwrap(){return this._def.innerType}};bs.create=(a,e)=>new bs({innerType:a,typeName:Ce.ZodReadonly,...Fe(e)});function qx(a,e){let r=typeof a=="function"?a(e):typeof a=="string"?{message:a}:a;return typeof r=="string"?{message:r}:r}function Vx(a,e={},r){return a?Aa.create().superRefine((t,s)=>{let i=a(t);if(i instanceof Promise)return i.then(n=>{if(!n){let o=qx(e,t),l=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:l})}});if(!i){let n=qx(e,t),o=n.fatal??r??!0;s.addIssue({code:"custom",...n,fatal:o})}}):Aa.create()}var JD={object:zt.lazycreate},Ce;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(Ce||(Ce={}));var eN=(a,e={message:`Input not instance of ${a.name}`})=>Vx(r=>r instanceof a,e),Gx=ka.create,Wx=ns.create,tN=kn.create,rN=is.create,Zx=os.create,aN=cs.create,sN=Rn.create,nN=ls.create,iN=us.create,oN=Aa.create,cN=na.create,lN=kr.create,uN=Pn.create,pN=ia.create,dN=zt.create,fN=zt.strictCreate,mN=ps.create,hN=Sc.create,vN=ds.create,gN=zr.create,yN=Ec.create,bN=On.create,xN=Cn.create,_N=wc.create,SN=fs.create,EN=ms.create,wN=hs.create,TN=vs.create,RN=Ia.create,PN=dr.create,ON=ur.create,CN=Vr.create,kN=dr.createWithPreprocess,AN=Bi.create,IN=()=>Gx().optional(),DN=()=>Wx().optional(),NN=()=>Zx().optional(),jN={string:(a=>ka.create({...a,coerce:!0})),number:(a=>ns.create({...a,coerce:!0})),boolean:(a=>os.create({...a,coerce:!0})),bigint:(a=>is.create({...a,coerce:!0})),date:(a=>cs.create({...a,coerce:!0}))};var $N=Re;var id="2025-06-18";var Xx=[id,"2025-03-26","2024-11-05","2024-10-07"],Tc="2.0",Kx=S.union([S.string(),S.number().int()]),Qx=S.string(),MN=S.object({progressToken:S.optional(Kx)}).passthrough(),hr=S.object({_meta:S.optional(MN)}).passthrough(),Vt=S.object({method:S.string(),params:S.optional(hr)}),zi=S.object({_meta:S.optional(S.object({}).passthrough())}).passthrough(),Gr=S.object({method:S.string(),params:S.optional(zi)}),vr=S.object({_meta:S.optional(S.object({}).passthrough())}).passthrough(),Rc=S.union([S.string(),S.number().int()]),Yx=S.object({jsonrpc:S.literal(Tc),id:Rc}).merge(Vt).strict(),Jx=a=>Yx.safeParse(a).success,e0=S.object({jsonrpc:S.literal(Tc)}).merge(Gr).strict(),t0=a=>e0.safeParse(a).success,r0=S.object({jsonrpc:S.literal(Tc),id:Rc,result:vr}).strict(),od=a=>r0.safeParse(a).success,fr;(function(a){a[a.ConnectionClosed=-32e3]="ConnectionClosed",a[a.RequestTimeout=-32001]="RequestTimeout",a[a.ParseError=-32700]="ParseError",a[a.InvalidRequest=-32600]="InvalidRequest",a[a.MethodNotFound=-32601]="MethodNotFound",a[a.InvalidParams=-32602]="InvalidParams",a[a.InternalError=-32603]="InternalError"})(fr||(fr={}));var a0=S.object({jsonrpc:S.literal(Tc),id:Rc,error:S.object({code:S.number().int(),message:S.string(),data:S.optional(S.unknown())})}).strict(),s0=a=>a0.safeParse(a).success,n0=S.union([Yx,e0,r0,a0]),xs=vr.strict(),Pc=Gr.extend({method:S.literal("notifications/cancelled"),params:zi.extend({requestId:Rc,reason:S.string().optional()})}),LN=S.object({src:S.string(),mimeType:S.optional(S.string()),sizes:S.optional(S.array(S.string()))}).passthrough(),Vi=S.object({icons:S.array(LN).optional()}).passthrough(),Gi=S.object({name:S.string(),title:S.optional(S.string())}).passthrough(),i0=Gi.extend({version:S.string(),websiteUrl:S.optional(S.string())}).merge(Vi),FN=S.object({experimental:S.optional(S.object({}).passthrough()),sampling:S.optional(S.object({}).passthrough()),elicitation:S.optional(S.object({}).passthrough()),roots:S.optional(S.object({listChanged:S.optional(S.boolean())}).passthrough())}).passthrough(),qN=Vt.extend({method:S.literal("initialize"),params:hr.extend({protocolVersion:S.string(),capabilities:FN,clientInfo:i0})});var UN=S.object({experimental:S.optional(S.object({}).passthrough()),logging:S.optional(S.object({}).passthrough()),completions:S.optional(S.object({}).passthrough()),prompts:S.optional(S.object({listChanged:S.optional(S.boolean())}).passthrough()),resources:S.optional(S.object({subscribe:S.optional(S.boolean()),listChanged:S.optional(S.boolean())}).passthrough()),tools:S.optional(S.object({listChanged:S.optional(S.boolean())}).passthrough())}).passthrough(),cd=vr.extend({protocolVersion:S.string(),capabilities:UN,serverInfo:i0,instructions:S.optional(S.string())}),HN=Gr.extend({method:S.literal("notifications/initialized")});var Oc=Vt.extend({method:S.literal("ping")}),BN=S.object({progress:S.number(),total:S.optional(S.number()),message:S.optional(S.string())}).passthrough(),Cc=Gr.extend({method:S.literal("notifications/progress"),params:zi.merge(BN).extend({progressToken:Kx})}),kc=Vt.extend({params:hr.extend({cursor:S.optional(Qx)}).optional()}),Ac=vr.extend({nextCursor:S.optional(Qx)}),o0=S.object({uri:S.string(),mimeType:S.optional(S.string()),_meta:S.optional(S.object({}).passthrough())}).passthrough(),c0=o0.extend({text:S.string()}),ld=S.string().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),l0=o0.extend({blob:ld}),u0=Gi.extend({uri:S.string(),description:S.optional(S.string()),mimeType:S.optional(S.string()),_meta:S.optional(S.object({}).passthrough())}).merge(Vi),zN=Gi.extend({uriTemplate:S.string(),description:S.optional(S.string()),mimeType:S.optional(S.string()),_meta:S.optional(S.object({}).passthrough())}).merge(Vi),VN=kc.extend({method:S.literal("resources/list")}),ud=Ac.extend({resources:S.array(u0)}),GN=kc.extend({method:S.literal("resources/templates/list")}),pd=Ac.extend({resourceTemplates:S.array(zN)}),WN=Vt.extend({method:S.literal("resources/read"),params:hr.extend({uri:S.string()})}),dd=vr.extend({contents:S.array(S.union([c0,l0]))}),ZN=Gr.extend({method:S.literal("notifications/resources/list_changed")}),XN=Vt.extend({method:S.literal("resources/subscribe"),params:hr.extend({uri:S.string()})}),KN=Vt.extend({method:S.literal("resources/unsubscribe"),params:hr.extend({uri:S.string()})}),QN=Gr.extend({method:S.literal("notifications/resources/updated"),params:zi.extend({uri:S.string()})}),YN=S.object({name:S.string(),description:S.optional(S.string()),required:S.optional(S.boolean())}).passthrough(),JN=Gi.extend({description:S.optional(S.string()),arguments:S.optional(S.array(YN)),_meta:S.optional(S.object({}).passthrough())}).merge(Vi),e2=kc.extend({method:S.literal("prompts/list")}),fd=Ac.extend({prompts:S.array(JN)}),t2=Vt.extend({method:S.literal("prompts/get"),params:hr.extend({name:S.string(),arguments:S.optional(S.record(S.string()))})}),md=S.object({type:S.literal("text"),text:S.string(),_meta:S.optional(S.object({}).passthrough())}).passthrough(),hd=S.object({type:S.literal("image"),data:ld,mimeType:S.string(),_meta:S.optional(S.object({}).passthrough())}).passthrough(),vd=S.object({type:S.literal("audio"),data:ld,mimeType:S.string(),_meta:S.optional(S.object({}).passthrough())}).passthrough(),r2=S.object({type:S.literal("resource"),resource:S.union([c0,l0]),_meta:S.optional(S.object({}).passthrough())}).passthrough(),a2=u0.extend({type:S.literal("resource_link")}),p0=S.union([md,hd,vd,a2,r2]),s2=S.object({role:S.enum(["user","assistant"]),content:p0}).passthrough(),gd=vr.extend({description:S.optional(S.string()),messages:S.array(s2)}),n2=Gr.extend({method:S.literal("notifications/prompts/list_changed")}),i2=S.object({title:S.optional(S.string()),readOnlyHint:S.optional(S.boolean()),destructiveHint:S.optional(S.boolean()),idempotentHint:S.optional(S.boolean()),openWorldHint:S.optional(S.boolean())}).passthrough(),o2=Gi.extend({description:S.optional(S.string()),inputSchema:S.object({type:S.literal("object"),properties:S.optional(S.object({}).passthrough()),required:S.optional(S.array(S.string()))}).passthrough(),outputSchema:S.optional(S.object({type:S.literal("object"),properties:S.optional(S.object({}).passthrough()),required:S.optional(S.array(S.string()))}).passthrough()),annotations:S.optional(i2),_meta:S.optional(S.object({}).passthrough())}).merge(Vi),c2=kc.extend({method:S.literal("tools/list")}),yd=Ac.extend({tools:S.array(o2)}),Ic=vr.extend({content:S.array(p0).default([]),structuredContent:S.object({}).passthrough().optional(),isError:S.optional(S.boolean())}),S3=Ic.or(vr.extend({toolResult:S.unknown()})),l2=Vt.extend({method:S.literal("tools/call"),params:hr.extend({name:S.string(),arguments:S.optional(S.record(S.unknown()))})}),u2=Gr.extend({method:S.literal("notifications/tools/list_changed")}),d0=S.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),p2=Vt.extend({method:S.literal("logging/setLevel"),params:hr.extend({level:d0})}),d2=Gr.extend({method:S.literal("notifications/message"),params:zi.extend({level:d0,logger:S.optional(S.string()),data:S.unknown()})}),f2=S.object({name:S.string().optional()}).passthrough(),m2=S.object({hints:S.optional(S.array(f2)),costPriority:S.optional(S.number().min(0).max(1)),speedPriority:S.optional(S.number().min(0).max(1)),intelligencePriority:S.optional(S.number().min(0).max(1))}).passthrough(),h2=S.object({role:S.enum(["user","assistant"]),content:S.union([md,hd,vd])}).passthrough(),v2=Vt.extend({method:S.literal("sampling/createMessage"),params:hr.extend({messages:S.array(h2),systemPrompt:S.optional(S.string()),includeContext:S.optional(S.enum(["none","thisServer","allServers"])),temperature:S.optional(S.number()),maxTokens:S.number().int(),stopSequences:S.optional(S.array(S.string())),metadata:S.optional(S.object({}).passthrough()),modelPreferences:S.optional(m2)})}),g2=vr.extend({model:S.string(),stopReason:S.optional(S.enum(["endTurn","stopSequence","maxTokens"]).or(S.string())),role:S.enum(["user","assistant"]),content:S.discriminatedUnion("type",[md,hd,vd])}),y2=S.object({type:S.literal("boolean"),title:S.optional(S.string()),description:S.optional(S.string()),default:S.optional(S.boolean())}).passthrough(),b2=S.object({type:S.literal("string"),title:S.optional(S.string()),description:S.optional(S.string()),minLength:S.optional(S.number()),maxLength:S.optional(S.number()),format:S.optional(S.enum(["email","uri","date","date-time"]))}).passthrough(),x2=S.object({type:S.enum(["number","integer"]),title:S.optional(S.string()),description:S.optional(S.string()),minimum:S.optional(S.number()),maximum:S.optional(S.number())}).passthrough(),_2=S.object({type:S.literal("string"),title:S.optional(S.string()),description:S.optional(S.string()),enum:S.array(S.string()),enumNames:S.optional(S.array(S.string()))}).passthrough(),S2=S.union([y2,b2,x2,_2]),E2=Vt.extend({method:S.literal("elicitation/create"),params:hr.extend({message:S.string(),requestedSchema:S.object({type:S.literal("object"),properties:S.record(S.string(),S2),required:S.optional(S.array(S.string()))}).passthrough()})}),w2=vr.extend({action:S.enum(["accept","decline","cancel"]),content:S.optional(S.record(S.string(),S.unknown()))}),T2=S.object({type:S.literal("ref/resource"),uri:S.string()}).passthrough();var R2=S.object({type:S.literal("ref/prompt"),name:S.string()}).passthrough(),P2=Vt.extend({method:S.literal("completion/complete"),params:hr.extend({ref:S.union([R2,T2]),argument:S.object({name:S.string(),value:S.string()}).passthrough(),context:S.optional(S.object({arguments:S.optional(S.record(S.string(),S.string()))}))})}),bd=vr.extend({completion:S.object({values:S.array(S.string()).max(100),total:S.optional(S.number().int()),hasMore:S.optional(S.boolean())}).passthrough()}),O2=S.object({uri:S.string().startsWith("file://"),name:S.optional(S.string()),_meta:S.optional(S.object({}).passthrough())}).passthrough(),C2=Vt.extend({method:S.literal("roots/list")}),k2=vr.extend({roots:S.array(O2)}),A2=Gr.extend({method:S.literal("notifications/roots/list_changed")}),E3=S.union([Oc,qN,P2,p2,t2,e2,VN,GN,WN,XN,KN,l2,c2]),w3=S.union([Pc,Cc,HN,A2]),T3=S.union([xs,g2,w2,k2]),R3=S.union([Oc,v2,E2,C2]),P3=S.union([Pc,Cc,d2,QN,ZN,u2,n2]),O3=S.union([xs,cd,bd,gd,fd,ud,pd,dd,Ic,yd]),mr=class extends Error{constructor(e,r,t){super(`MCP error ${e}: ${r}`),this.code=e,this.data=t,this.name="McpError"}};var I2=6e4,Dc=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(Pc,r=>{let t=this._requestHandlerAbortControllers.get(r.params.requestId);t?.abort(r.params.reason)}),this.setNotificationHandler(Cc,r=>{this._onprogress(r)}),this.setRequestHandler(Oc,r=>({}))}_setupTimeout(e,r,t,s,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(s,r),startTime:Date.now(),timeout:r,maxTotalTimeout:t,resetTimeoutOnProgress:i,onTimeout:s})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let t=Date.now()-r.startTime;if(r.maxTotalTimeout&&t>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),new mr(fr.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:t});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var r,t,s;this._transport=e;let i=(r=this.transport)===null||r===void 0?void 0:r.onclose;this._transport.onclose=()=>{i?.(),this._onclose()};let n=(t=this.transport)===null||t===void 0?void 0:t.onerror;this._transport.onerror=l=>{n?.(l),this._onerror(l)};let o=(s=this._transport)===null||s===void 0?void 0:s.onmessage;this._transport.onmessage=(l,c)=>{o?.(l,c),od(l)||s0(l)?this._onresponse(l):Jx(l)?this._onrequest(l,c):t0(l)?this._onnotification(l):this._onerror(new Error(`Unknown message type: ${JSON.stringify(l)}`))},await this._transport.start()}_onclose(){var e;let r=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let t=new mr(fr.ConnectionClosed,"Connection closed");for(let s of r.values())s(t)}_onerror(e){var r;(r=this.onerror)===null||r===void 0||r.call(this,e)}_onnotification(e){var r;let t=(r=this._notificationHandlers.get(e.method))!==null&&r!==void 0?r:this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){var t,s;let i=(t=this._requestHandlers.get(e.method))!==null&&t!==void 0?t:this.fallbackRequestHandler,n=this._transport;if(i===void 0){n?.send({jsonrpc:"2.0",id:e.id,error:{code:fr.MethodNotFound,message:"Method not found"}}).catch(c=>this._onerror(new Error(`Failed to send an error response: ${c}`)));return}let o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);let l={signal:o.signal,sessionId:n?.sessionId,_meta:(s=e.params)===null||s===void 0?void 0:s._meta,sendNotification:c=>this.notification(c,{relatedRequestId:e.id}),sendRequest:(c,u,p)=>this.request(c,u,{...p,relatedRequestId:e.id}),authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo};Promise.resolve().then(()=>i(e,l)).then(c=>{if(!o.signal.aborted)return n?.send({result:c,jsonrpc:"2.0",id:e.id})},c=>{var u;if(!o.signal.aborted)return n?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(c.code)?c.code:fr.InternalError,message:(u=c.message)!==null&&u!==void 0?u:"Internal error"}})}).catch(c=>this._onerror(new Error(`Failed to send response: ${c}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...t}=e.params,s=Number(r),i=this._progressHandlers.get(s);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let n=this._responseHandlers.get(s),o=this._timeoutInfo.get(s);if(o&&n&&o.resetTimeoutOnProgress)try{this._resetTimeout(s)}catch(l){n(l);return}i(t)}_onresponse(e){let r=Number(e.id),t=this._responseHandlers.get(r);if(t===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),od(e))t(e);else{let s=new mr(e.error.code,e.error.message,e.error.data);t(s)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,r,t){let{relatedRequestId:s,resumptionToken:i,onresumptiontoken:n}=t??{};return new Promise((o,l)=>{var c,u,p,m,d,v;if(!this._transport){l(new Error("Not connected"));return}((c=this._options)===null||c===void 0?void 0:c.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(u=t?.signal)===null||u===void 0||u.throwIfAborted();let h=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:h};t?.onprogress&&(this._progressHandlers.set(h,t.onprogress),f.params={...e.params,_meta:{...((p=e.params)===null||p===void 0?void 0:p._meta)||{},progressToken:h}});let y=w=>{var P;this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),(P=this._transport)===null||P===void 0||P.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(w)}},{relatedRequestId:s,resumptionToken:i,onresumptiontoken:n}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`))),l(w)};this._responseHandlers.set(h,w=>{var P;if(!(!((P=t?.signal)===null||P===void 0)&&P.aborted)){if(w instanceof Error)return l(w);try{let T=r.parse(w.result);o(T)}catch(T){l(T)}}}),(m=t?.signal)===null||m===void 0||m.addEventListener("abort",()=>{var w;y((w=t?.signal)===null||w===void 0?void 0:w.reason)});let g=(d=t?.timeout)!==null&&d!==void 0?d:I2,b=()=>y(new mr(fr.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(h,g,t?.maxTotalTimeout,b,(v=t?.resetTimeoutOnProgress)!==null&&v!==void 0?v:!1),this._transport.send(f,{relatedRequestId:s,resumptionToken:i,onresumptiontoken:n}).catch(w=>{this._cleanupTimeout(h),l(w)})})}async notification(e,r){var t,s;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((s=(t=this._options)===null||t===void 0?void 0:t.debouncedNotificationMethods)!==null&&s!==void 0?s:[]).includes(e.method)&&!e.params&&!r?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var l;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let c={...e,jsonrpc:"2.0"};(l=this._transport)===null||l===void 0||l.send(c,r).catch(u=>this._onerror(u))});return}let o={...e,jsonrpc:"2.0"};await this._transport.send(o,r)}setRequestHandler(e,r){let t=e.shape.method.value;this.assertRequestHandlerCapability(t),this._requestHandlers.set(t,(s,i)=>Promise.resolve(r(e.parse(s),i)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){this._notificationHandlers.set(e.shape.method.value,t=>Promise.resolve(r(e.parse(t))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function f0(a,e){return Object.entries(e).reduce((r,[t,s])=>(s&&typeof s=="object"?r[t]=r[t]?{...r[t],...s}:s:r[t]=s,r),{...a})}var hS=Tt(mS(),1),An=class extends Dc{constructor(e,r){var t;super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=(t=r?.capabilities)!==null&&t!==void 0?t:{},this._ajv=new hS.default}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=f0(this._capabilities,e)}assertCapability(e,r){var t;if(!(!((t=this._serverCapabilities)===null||t===void 0)&&t[e]))throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{let t=await this.request({method:"initialize",params:{protocolVersion:id,capabilities:this._capabilities,clientInfo:this._clientInfo}},cd,r);if(t===void 0)throw new Error(`Server sent invalid initialize result: ${t}`);if(!Xx.includes(t.protocolVersion))throw new Error(`Server's protocol version is not supported: ${t.protocolVersion}`);this._serverCapabilities=t.capabilities,this._serverVersion=t.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(t.protocolVersion),this._instructions=t.instructions,await this.notification({method:"notifications/initialized"})}catch(t){throw this.close(),t}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var r,t,s,i,n;switch(e){case"logging/setLevel":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((t=this._serverCapabilities)===null||t===void 0)&&t.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((s=this._serverCapabilities)===null||s===void 0)&&s.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((i=this._serverCapabilities)===null||i===void 0)&&i.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.completions))throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){var r;switch(e){case"notifications/roots/list_changed":if(!(!((r=this._capabilities.roots)===null||r===void 0)&&r.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},xs,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},bd,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},xs,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},gd,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},fd,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},ud,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},pd,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},dd,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},xs,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},xs,r)}async callTool(e,r=Ic,t){let s=await this.request({method:"tools/call",params:e},r,t),i=this.getToolOutputValidator(e.name);if(i){if(!s.structuredContent&&!s.isError)throw new mr(fr.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(s.structuredContent)try{if(!i(s.structuredContent))throw new mr(fr.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(i.errors)}`)}catch(n){throw n instanceof mr?n:new mr(fr.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return s}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(let r of e)if(r.outputSchema)try{let t=this._ajv.compile(r.outputSchema);this._cachedToolOutputValidators.set(r.name,t)}catch{}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){let t=await this.request({method:"tools/list",params:e},yd,r);return this.cacheToolOutputSchemas(t.tools),t}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var nE=Tt(aE(),1),Zi=Tt(require("node:process"),1),iE=require("node:stream");var Jc=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(` `);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),M$(r)}clear(){this._buffer=void 0}};function M$(a){return n0.parse(JSON.parse(a))}function sE(a){return JSON.stringify(a)+` -`}var L$=Zi.default.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function F$(){let a={};for(let e of L$){let r=Zi.default.env[e];r!==void 0&&(r.startsWith("()")||(a[e]=r))}return a}var Nn=class{constructor(e){this._abortController=new AbortController,this._readBuffer=new Jc,this._stderrStream=null,this._serverParams=e,(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new iE.PassThrough)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{var t,s,i,n,o;this._process=(0,nE.default)(this._serverParams.command,(t=this._serverParams.args)!==null&&t!==void 0?t:[],{env:{...F$(),...this._serverParams.env},stdio:["pipe","pipe",(s=this._serverParams.stderr)!==null&&s!==void 0?s:"inherit"],shell:!1,signal:this._abortController.signal,windowsHide:Zi.default.platform==="win32"&&q$(),cwd:this._serverParams.cwd}),this._process.on("error",l=>{var c,u;if(l.name==="AbortError"){(c=this.onclose)===null||c===void 0||c.call(this);return}r(l),(u=this.onerror)===null||u===void 0||u.call(this,l)}),this._process.on("spawn",()=>{e()}),this._process.on("close",l=>{var c;this._process=void 0,(c=this.onclose)===null||c===void 0||c.call(this)}),(i=this._process.stdin)===null||i===void 0||i.on("error",l=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,l)}),(n=this._process.stdout)===null||n===void 0||n.on("data",l=>{this._readBuffer.append(l),this.processReadBuffer()}),(o=this._process.stdout)===null||o===void 0||o.on("error",l=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,l)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){var e,r;return this._stderrStream?this._stderrStream:(r=(e=this._process)===null||e===void 0?void 0:e.stderr)!==null&&r!==void 0?r:null}get pid(){var e,r;return(r=(e=this._process)===null||e===void 0?void 0:e.pid)!==null&&r!==void 0?r:null}processReadBuffer(){for(var e,r;;)try{let t=this._readBuffer.readMessage();if(t===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,t)}catch(t){(r=this.onerror)===null||r===void 0||r.call(this,t)}}async close(){this._abortController.abort(),this._process=void 0,this._readBuffer.clear()}send(e){return new Promise(r=>{var t;if(!(!((t=this._process)===null||t===void 0)&&t.stdin))throw new Error("Not connected");let s=sE(e);this._process.stdin.write(s)?r():this._process.stdin.once("drain",r)})}};function q$(){return"type"in Zi.default}var sl=Tt(require("path"),1),af=require("os");mt();var tf={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function fE(a){return process.platform==="win32"?Math.round(a*tf.WINDOWS_MULTIPLIER):a}var al=require("path");var gE=require("os");Ar();var uH=(0,al.join)(Gt,"worker.pid"),pH=(0,al.join)(Gt,"logs"),dH=(0,al.join)((0,gE.homedir)(),".claude","plugins","marketplaces","thedotmack");oa();var SH=sl.default.join((0,af.homedir)(),".claude","plugins","marketplaces","thedotmack"),EH=fE(tf.HEALTH_CHECK),Es=null;function Fn(){if(Es!==null)return Es;try{let a=sl.default.join(lt.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=lt.loadFromFile(a);return Es=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),Es}catch(a){return M.debug("SYSTEM","Failed to load port from settings, using default",{error:a}),Es=parseInt(lt.get("CLAUDE_MEM_WORKER_PORT"),10),Es}}function yE(){Es=null}function bE(){let a=sl.default.join((0,af.homedir)(),".claude-mem","settings.json");return lt.loadFromFile(a).CLAUDE_MEM_WORKER_HOST}mt();var g1=require("child_process"),y1=require("util");nl();var _E=require("bun:sqlite");Ar();var il=class{db;constructor(e){e||(rl(Gt),e=tl),this.db=new _E.Database(e),this.db.run("PRAGMA journal_mode = WAL"),this.ensureFTSTables()}ensureFTSTables(){try{if(this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%_fts'").all().some(t=>t.name==="observations_fts"||t.name==="session_summaries_fts"))return;console.error("[SessionSearch] Creating FTS5 tables..."),this.db.run(` +`}var L$=Zi.default.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function F$(){let a={};for(let e of L$){let r=Zi.default.env[e];r!==void 0&&(r.startsWith("()")||(a[e]=r))}return a}var Nn=class{constructor(e){this._abortController=new AbortController,this._readBuffer=new Jc,this._stderrStream=null,this._serverParams=e,(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new iE.PassThrough)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{var t,s,i,n,o;this._process=(0,nE.default)(this._serverParams.command,(t=this._serverParams.args)!==null&&t!==void 0?t:[],{env:{...F$(),...this._serverParams.env},stdio:["pipe","pipe",(s=this._serverParams.stderr)!==null&&s!==void 0?s:"inherit"],shell:!1,signal:this._abortController.signal,windowsHide:Zi.default.platform==="win32"&&q$(),cwd:this._serverParams.cwd}),this._process.on("error",l=>{var c,u;if(l.name==="AbortError"){(c=this.onclose)===null||c===void 0||c.call(this);return}r(l),(u=this.onerror)===null||u===void 0||u.call(this,l)}),this._process.on("spawn",()=>{e()}),this._process.on("close",l=>{var c;this._process=void 0,(c=this.onclose)===null||c===void 0||c.call(this)}),(i=this._process.stdin)===null||i===void 0||i.on("error",l=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,l)}),(n=this._process.stdout)===null||n===void 0||n.on("data",l=>{this._readBuffer.append(l),this.processReadBuffer()}),(o=this._process.stdout)===null||o===void 0||o.on("error",l=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,l)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){var e,r;return this._stderrStream?this._stderrStream:(r=(e=this._process)===null||e===void 0?void 0:e.stderr)!==null&&r!==void 0?r:null}get pid(){var e,r;return(r=(e=this._process)===null||e===void 0?void 0:e.pid)!==null&&r!==void 0?r:null}processReadBuffer(){for(var e,r;;)try{let t=this._readBuffer.readMessage();if(t===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,t)}catch(t){(r=this.onerror)===null||r===void 0||r.call(this,t)}}async close(){this._abortController.abort(),this._process=void 0,this._readBuffer.clear()}send(e){return new Promise(r=>{var t;if(!(!((t=this._process)===null||t===void 0)&&t.stdin))throw new Error("Not connected");let s=sE(e);this._process.stdin.write(s)?r():this._process.stdin.once("drain",r)})}};function q$(){return"type"in Zi.default}var sl=Tt(require("path"),1),af=require("os");mt();var tf={DEFAULT:5e3,HEALTH_CHECK:1e3,WORKER_STARTUP_WAIT:1e3,WORKER_STARTUP_RETRIES:15,WINDOWS_MULTIPLIER:1.5};function fE(a){return process.platform==="win32"?Math.round(a*tf.WINDOWS_MULTIPLIER):a}var al=require("path");var gE=require("os");Ar();var mH=(0,al.join)(Gt,"worker.pid"),hH=(0,al.join)(Gt,"logs"),vH=(0,al.join)((0,gE.homedir)(),".claude","plugins","marketplaces","thedotmack");oa();var RH=sl.default.join((0,af.homedir)(),".claude","plugins","marketplaces","thedotmack"),PH=fE(tf.HEALTH_CHECK),Es=null;function Fn(){if(Es!==null)return Es;try{let a=sl.default.join(lt.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=lt.loadFromFile(a);return Es=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),Es}catch(a){return M.debug("SYSTEM","Failed to load port from settings, using default",{error:a}),Es=parseInt(lt.get("CLAUDE_MEM_WORKER_PORT"),10),Es}}function yE(){Es=null}function bE(){let a=sl.default.join((0,af.homedir)(),".claude-mem","settings.json");return lt.loadFromFile(a).CLAUDE_MEM_WORKER_HOST}mt();var g1=require("child_process"),y1=require("util");nl();var _E=require("bun:sqlite");Ar();var il=class{db;constructor(e){e||(rl(Gt),e=tl),this.db=new _E.Database(e),this.db.run("PRAGMA journal_mode = WAL"),this.ensureFTSTables()}ensureFTSTables(){try{if(this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%_fts'").all().some(t=>t.name==="observations_fts"||t.name==="session_summaries_fts"))return;console.error("[SessionSearch] Creating FTS5 tables..."),this.db.run(` CREATE VIRTUAL TABLE IF NOT EXISTS observations_fts USING fts5( title, subtitle, @@ -896,7 +896,7 @@ MEMORY PROCESSING CONTINUED `))}finally{this.cancelControllers.delete(e.request_id)}}handleControlCancelRequest(e){let r=this.cancelControllers.get(e.request_id);r&&(r.abort(),this.cancelControllers.delete(e.request_id))}async processControlRequest(e,r){if(e.request.subtype==="can_use_tool"){if(!this.canUseTool)throw new Error("canUseTool callback is not provided.");return{...await this.canUseTool(e.request.tool_name,e.request.input,{signal:r,suggestions:e.request.permission_suggestions,blockedPath:e.request.blocked_path,decisionReason:e.request.decision_reason,toolUseID:e.request.tool_use_id,agentID:e.request.agent_id}),toolUseID:e.request.tool_use_id}}else{if(e.request.subtype==="hook_callback")return await this.handleHookCallbacks(e.request.callback_id,e.request.input,e.request.tool_use_id,r);if(e.request.subtype==="mcp_message"){let t=e.request,s=this.sdkMcpTransports.get(t.server_name);if(!s)throw new Error(`SDK MCP server not found: ${t.server_name}`);return"method"in t.message&&"id"in t.message&&t.message.id!==null?{mcp_response:await this.handleMcpControlRequest(t.server_name,t,s)}:(s.onmessage&&s.onmessage(t.message),{mcp_response:{jsonrpc:"2.0",result:{},id:0}})}}throw new Error("Unsupported control request subtype: "+e.request.subtype)}async*readSdkMessages(){for await(let e of this.inputStream)yield e}async initialize(){let e;if(this.hooks){e={};for(let[i,n]of Object.entries(this.hooks))n.length>0&&(e[i]=n.map(o=>{let l=[];for(let c of o.hooks){let u=`hook_${this.nextCallbackId++}`;this.hookCallbacks.set(u,c),l.push(u)}return{matcher:o.matcher,hookCallbackIds:l,timeout:o.timeout}}))}let r=this.sdkMcpTransports.size>0?Array.from(this.sdkMcpTransports.keys()):void 0,t={subtype:"initialize",hooks:e,sdkMcpServers:r,jsonSchema:this.jsonSchema,systemPrompt:this.initConfig?.systemPrompt,appendSystemPrompt:this.initConfig?.appendSystemPrompt,agents:this.initConfig?.agents};return(await this.request(t)).response}async interrupt(){await this.request({subtype:"interrupt"})}async setPermissionMode(e){await this.request({subtype:"set_permission_mode",mode:e})}async setModel(e){await this.request({subtype:"set_model",model:e})}async setMaxThinkingTokens(e){await this.request({subtype:"set_max_thinking_tokens",max_thinking_tokens:e})}async rewindFiles(e){await this.request({subtype:"rewind_files",user_message_id:e})}async processPendingPermissionRequests(e){for(let r of e)r.request.subtype==="can_use_tool"&&this.handleControlRequest(r).catch(()=>{})}request(e){let r=Math.random().toString(36).substring(2,15),t={request_id:r,type:"control_request",request:e};return new Promise((s,i)=>{this.pendingControlResponses.set(r,n=>{n.subtype==="success"?s(n):(i(new Error(n.error)),n.pending_permission_requests&&this.processPendingPermissionRequests(n.pending_permission_requests))}),Promise.resolve(this.transport.write(JSON.stringify(t)+` `))})}async supportedCommands(){return(await this.initialization).commands}async supportedModels(){return(await this.initialization).models}async mcpServerStatus(){return(await this.request({subtype:"mcp_status"})).response.mcpServers}async accountInfo(){return(await this.initialization).account}async streamInput(e){Ir("[Query.streamInput] Starting to process input stream");try{let r=0;for await(let t of e){if(r++,Ir(`[Query.streamInput] Processing message ${r}: ${t.type}`),this.abortController?.signal.aborted)break;await Promise.resolve(this.transport.write(JSON.stringify(t)+` `))}Ir(`[Query.streamInput] Finished processing ${r} messages from input stream`),this.hasBidirectionalNeeds()&&(Ir("[Query.streamInput] Has bidirectional needs, waiting for inactivity"),await this.waitForInactivity()),Ir("[Query] Calling transport.endInput() to close stdin to CLI process"),this.transport.endInput()}catch(r){if(!(r instanceof Ts))throw r}}async handleSingleTurnInputComplete(){this.hasBidirectionalNeeds()&&(Ir("[Query.handleSingleTurnInputComplete] Has bidirectional needs, waiting for inactivity"),await this.waitForInactivity()),Ir("[Query.handleSingleTurnInputComplete] Calling transport.endInput()"),this.transport.endInput()}async waitForInactivity(){return Ir(`[Query.waitForInactivity] Waiting for inactivity (timeout: ${this.streamCloseTimeout}ms)`),new Promise(e=>{if(this.userInputEndedResolve=e,this.abortController?.signal.aborted){e();return}this.abortController?.signal.addEventListener("abort",()=>e(),{once:!0});let r=()=>{if(this.abortController?.signal.aborted){e();return}let t=Date.now()-this.lastActivityTime;if(t>=this.streamCloseTimeout)Ir(`[Query.waitForInactivity] Inactivity timeout reached (${t}ms elapsed). Closing stdin. If your tools or hooks need more time, set CLAUDE_CODE_STREAM_CLOSE_TIMEOUT to a higher value (current: ${this.streamCloseTimeout}ms).`),e();else{let s=this.streamCloseTimeout-t;Ir(`[Query.waitForInactivity] Still active, checking again in ${s}ms`),setTimeout(r,s)}};r()})}handleHookCallbacks(e,r,t,s){let i=this.hookCallbacks.get(e);if(!i)throw new Error(`No hook callback found for ID: ${e}`);return i(r,t,{signal:s})}sendMcpServerMessageToCli(e,r){if("id"in r&&r.id!==null&&r.id!==void 0){let s=`${e}:${r.id}`,i=this.pendingMcpResponses.get(s);if(i){i.resolve(r),this.pendingMcpResponses.delete(s);return}}let t={type:"control_request",request_id:(0,bw.randomUUID)(),request:{subtype:"mcp_message",server_name:e,message:r}};this.transport.write(JSON.stringify(t)+` -`)}handleMcpControlRequest(e,r,t){let s="id"in r.message?r.message.id:null,i=`${e}:${s}`;return new Promise((n,o)=>{let l=()=>{this.pendingMcpResponses.delete(i)},c=p=>{l(),n(p)},u=p=>{l(),o(p)};if(this.pendingMcpResponses.set(i,{resolve:c,reject:u}),t.onmessage)t.onmessage(r.message);else{l(),o(new Error("No message handler registered"));return}})}};var E={};K$(E,{void:()=>EL,util:()=>Xe,unknown:()=>_L,union:()=>PL,undefined:()=>yL,tuple:()=>kL,transformer:()=>WE,symbol:()=>gL,string:()=>Rw,strictObject:()=>RL,setErrorMap:()=>HM,set:()=>DL,record:()=>AL,quotelessJson:()=>qM,promise:()=>FL,preprocess:()=>HL,pipeline:()=>BL,ostring:()=>zL,optional:()=>qL,onumber:()=>VL,oboolean:()=>GL,objectUtil:()=>mf,object:()=>TL,number:()=>Pw,nullable:()=>UL,null:()=>bL,never:()=>SL,nativeEnum:()=>LL,nan:()=>mL,map:()=>IL,makeIssue:()=>vl,literal:()=>$L,lazy:()=>jL,late:()=>dL,isValid:()=>Ps,isDirty:()=>vf,isAsync:()=>Qi,isAborted:()=>hf,intersection:()=>CL,instanceof:()=>fL,getParsedType:()=>ua,getErrorMap:()=>hl,function:()=>NL,enum:()=>ML,effect:()=>WE,discriminatedUnion:()=>OL,defaultErrorMap:()=>Hn,datetimeRegex:()=>Ew,date:()=>vL,custom:()=>Tw,coerce:()=>WL,boolean:()=>Ow,bigint:()=>hL,array:()=>wL,any:()=>xL,addIssueToContext:()=>oe,ZodVoid:()=>zn,ZodUnknown:()=>da,ZodUnion:()=>Ns,ZodUndefined:()=>Is,ZodType:()=>Me,ZodTuple:()=>Zr,ZodTransformer:()=>rr,ZodSymbol:()=>Bn,ZodString:()=>Ma,ZodSet:()=>Gn,ZodSchema:()=>Me,ZodRecord:()=>yl,ZodReadonly:()=>Hs,ZodPromise:()=>Fa,ZodPipeline:()=>Ji,ZodParsedType:()=>de,ZodOptional:()=>gr,ZodObject:()=>Wt,ZodNumber:()=>Os,ZodNullable:()=>Xr,ZodNull:()=>Ds,ZodNever:()=>Dr,ZodNativeEnum:()=>Fs,ZodNaN:()=>Wn,ZodMap:()=>Vn,ZodLiteral:()=>Ms,ZodLazy:()=>$s,ZodIssueCode:()=>re,ZodIntersection:()=>js,ZodFunction:()=>bl,ZodFirstPartyTypeKind:()=>ke,ZodError:()=>tr,ZodEnum:()=>Ls,ZodEffects:()=>rr,ZodDiscriminatedUnion:()=>gl,ZodDefault:()=>qs,ZodDate:()=>As,ZodCatch:()=>Us,ZodBranded:()=>Yi,ZodBoolean:()=>ks,ZodBigInt:()=>Cs,ZodArray:()=>fa,ZodAny:()=>La,Schema:()=>Me,ParseStatus:()=>It,OK:()=>jt,NEVER:()=>ZL,INVALID:()=>Oe,EMPTY_PATH:()=>BM,DIRTY:()=>Un,BRAND:()=>pL});var Xe;(function(a){a.assertEqual=s=>{};function e(s){}a.assertIs=e;function r(s){throw new Error}a.assertNever=r,a.arrayToEnum=s=>{let i={};for(let n of s)i[n]=n;return i},a.getValidEnumValues=s=>{let i=a.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),n={};for(let o of i)n[o]=s[o];return a.objectValues(n)},a.objectValues=s=>a.objectKeys(s).map(function(i){return s[i]}),a.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&i.push(n);return i},a.find=(s,i)=>{for(let n of s)if(i(n))return n},a.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function t(s,i=" | "){return s.map(n=>typeof n=="string"?`'${n}'`:n).join(i)}a.joinValues=t,a.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Xe||(Xe={}));var mf;(function(a){a.mergeShapes=(e,r)=>({...e,...r})})(mf||(mf={}));var de=Xe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ua=a=>{switch(typeof a){case"undefined":return de.undefined;case"string":return de.string;case"number":return Number.isNaN(a)?de.nan:de.number;case"boolean":return de.boolean;case"function":return de.function;case"bigint":return de.bigint;case"symbol":return de.symbol;case"object":return Array.isArray(a)?de.array:a===null?de.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?de.promise:typeof Map<"u"&&a instanceof Map?de.map:typeof Set<"u"&&a instanceof Set?de.set:typeof Date<"u"&&a instanceof Date?de.date:de.object;default:return de.unknown}},re=Xe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),qM=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:"),tr=class a extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=t=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},t={_errors:[]},s=i=>{for(let n of i.issues)if(n.code==="invalid_union")n.unionErrors.map(s);else if(n.code==="invalid_return_type")s(n.returnTypeError);else if(n.code==="invalid_arguments")s(n.argumentsError);else if(n.path.length===0)t._errors.push(r(n));else{let o=t,l=0;for(;lr.message){let r={},t=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else t.push(e(s));return{formErrors:t,fieldErrors:r}}get formErrors(){return this.flatten()}};tr.create=a=>new tr(a);var UM=(a,e)=>{let r;switch(a.code){case re.invalid_type:a.received===de.undefined?r="Required":r=`Expected ${a.expected}, received ${a.received}`;break;case re.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(a.expected,Xe.jsonStringifyReplacer)}`;break;case re.unrecognized_keys:r=`Unrecognized key(s) in object: ${Xe.joinValues(a.keys,", ")}`;break;case re.invalid_union:r="Invalid input";break;case re.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Xe.joinValues(a.options)}`;break;case re.invalid_enum_value:r=`Invalid enum value. Expected ${Xe.joinValues(a.options)}, received '${a.received}'`;break;case re.invalid_arguments:r="Invalid function arguments";break;case re.invalid_return_type:r="Invalid function return type";break;case re.invalid_date:r="Invalid date";break;case re.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(r=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?r=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?r=`Invalid input: must end with "${a.validation.endsWith}"`:Xe.assertNever(a.validation):a.validation!=="regex"?r=`Invalid ${a.validation}`:r="Invalid";break;case re.too_small:a.type==="array"?r=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?r=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?r=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="bigint"?r=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?r=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:r="Invalid input";break;case re.too_big:a.type==="array"?r=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?r=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?r=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?r=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?r=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:r="Invalid input";break;case re.custom:r="Invalid input";break;case re.invalid_intersection_types:r="Intersection results could not be merged";break;case re.not_multiple_of:r=`Number must be a multiple of ${a.multipleOf}`;break;case re.not_finite:r="Number must be finite";break;default:r=e.defaultError,Xe.assertNever(a)}return{message:r}},Hn=UM,xw=Hn;function HM(a){xw=a}function hl(){return xw}var vl=a=>{let{data:e,path:r,errorMaps:t,issueData:s}=a,i=[...r,...s.path||[]],n={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",l=t.filter(c=>!!c).slice().reverse();for(let c of l)o=c(n,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},BM=[];function oe(a,e){let r=hl(),t=vl({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,r,r===Hn?void 0:Hn].filter(s=>!!s)});a.common.issues.push(t)}var It=class a{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let t=[];for(let s of r){if(s.status==="aborted")return Oe;s.status==="dirty"&&e.dirty(),t.push(s.value)}return{status:e.value,value:t}}static async mergeObjectAsync(e,r){let t=[];for(let s of r){let i=await s.key,n=await s.value;t.push({key:i,value:n})}return a.mergeObjectSync(e,t)}static mergeObjectSync(e,r){let t={};for(let s of r){let{key:i,value:n}=s;if(i.status==="aborted"||n.status==="aborted")return Oe;i.status==="dirty"&&e.dirty(),n.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof n.value<"u"||s.alwaysSet)&&(t[i.value]=n.value)}return{status:e.value,value:t}}},Oe=Object.freeze({status:"aborted"}),Un=a=>({status:"dirty",value:a}),jt=a=>({status:"valid",value:a}),hf=a=>a.status==="aborted",vf=a=>a.status==="dirty",Ps=a=>a.status==="valid",Qi=a=>typeof Promise<"u"&&a instanceof Promise,ge;(function(a){a.errToObj=e=>typeof e=="string"?{message:e}:e||{},a.toString=e=>typeof e=="string"?e:e?.message})(ge||(ge={}));var yr=class{constructor(e,r,t,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=t,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},VE=(a,e)=>{if(Ps(e))return{success:!0,data:e.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new tr(a.common.issues);return this._error=r,this._error}}};function qe(a){if(!a)return{};let{errorMap:e,invalid_type_error:r,required_error:t,description:s}=a;if(e&&(r||t))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(n,o)=>{let{message:l}=a;return n.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??t??o.defaultError}:n.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:s}}var Me=class{get description(){return this._def.description}_getType(e){return ua(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ua(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new It,ctx:{common:e.parent.common,data:e.data,parsedType:ua(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Qi(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let t=this.safeParse(e,r);if(t.success)return t.data;throw t.error}safeParse(e,r){let t={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ua(e)},s=this._parseSync({data:e,path:t.path,parent:t});return VE(t,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ua(e)};if(!this["~standard"].async)try{let t=this._parseSync({data:e,path:[],parent:r});return Ps(t)?{value:t.value}:{issues:r.common.issues}}catch(t){t?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(t=>Ps(t)?{value:t.value}:{issues:r.common.issues})}async parseAsync(e,r){let t=await this.safeParseAsync(e,r);if(t.success)return t.data;throw t.error}async safeParseAsync(e,r){let t={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ua(e)},s=this._parse({data:e,path:t.path,parent:t}),i=await(Qi(s)?s:Promise.resolve(s));return VE(t,i)}refine(e,r){let t=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let n=e(s),o=()=>i.addIssue({code:re.custom,...t(s)});return typeof Promise<"u"&&n instanceof Promise?n.then(l=>l?!0:(o(),!1)):n?!0:(o(),!1)})}refinement(e,r){return this._refinement((t,s)=>e(t)?!0:(s.addIssue(typeof r=="function"?r(t,s):r),!1))}_refinement(e){return new rr({schema:this,typeName:ke.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return gr.create(this,this._def)}nullable(){return Xr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fa.create(this)}promise(){return Fa.create(this,this._def)}or(e){return Ns.create([this,e],this._def)}and(e){return js.create(this,e,this._def)}transform(e){return new rr({...qe(this._def),schema:this,typeName:ke.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new qs({...qe(this._def),innerType:this,defaultValue:r,typeName:ke.ZodDefault})}brand(){return new Yi({typeName:ke.ZodBranded,type:this,...qe(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Us({...qe(this._def),innerType:this,catchValue:r,typeName:ke.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ji.create(this,e)}readonly(){return Hs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},zM=/^c[^\s-]{8,}$/i,VM=/^[0-9a-z]+$/,GM=/^[0-9A-HJKMNP-TV-Z]{26}$/i,WM=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ZM=/^[a-z0-9_-]{21}$/i,XM=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,KM=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,QM=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,YM="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",nf,JM=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,eL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,tL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,rL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,aL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,_w="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",nL=new RegExp(`^${_w}$`);function Sw(a){let e="[0-5]\\d";a.precision?e=`${e}\\.\\d{${a.precision}}`:a.precision==null&&(e=`${e}(\\.\\d+)?`);let r=a.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function iL(a){return new RegExp(`^${Sw(a)}$`)}function Ew(a){let e=`${_w}T${Sw(a)}`,r=[];return r.push(a.local?"Z?":"Z"),a.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function oL(a,e){return!!((e==="v4"||!e)&&JM.test(a)||(e==="v6"||!e)&&tL.test(a))}function cL(a,e){if(!XM.test(a))return!1;try{let[r]=a.split(".");if(!r)return!1;let t=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(t));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function lL(a,e){return!!((e==="v4"||!e)&&eL.test(a)||(e==="v6"||!e)&&rL.test(a))}var Ma=class a extends Me{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==de.string){let i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:de.string,received:i.parsedType}),Oe}let t=new It,s;for(let i of this._def.checks)if(i.kind==="min")e.data.lengthi.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="length"){let n=e.data.length>i.value,o=e.data.lengthe.test(s),{validation:r,code:re.invalid_string,...ge.errToObj(t)})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ge.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ge.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ge.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ge.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ge.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ge.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ge.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ge.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ge.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ge.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ge.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ge.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ge.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ge.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...ge.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ge.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...ge.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...ge.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...ge.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...ge.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...ge.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...ge.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...ge.errToObj(r)})}nonempty(e){return this.min(1,ge.errToObj(e))}trim(){return new a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew Ma({checks:[],typeName:ke.ZodString,coerce:a?.coerce??!1,...qe(a)});function uL(a,e){let r=(a.toString().split(".")[1]||"").length,t=(e.toString().split(".")[1]||"").length,s=r>t?r:t,i=Number.parseInt(a.toFixed(s).replace(".","")),n=Number.parseInt(e.toFixed(s).replace(".",""));return i%n/10**s}var Os=class a extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==de.number){let i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:de.number,received:i.parsedType}),Oe}let t,s=new It;for(let i of this._def.checks)i.kind==="int"?Xe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),oe(t,{code:re.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),oe(t,{code:re.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?uL(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),oe(t,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),oe(t,{code:re.not_finite,message:i.message}),s.dirty()):Xe.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,ge.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ge.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ge.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ge.toString(r))}setLimit(e,r,t,s){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:t,message:ge.toString(s)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ge.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ge.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ge.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ge.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ge.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ge.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:ge.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ge.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ge.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuee.kind==="int"||e.kind==="multipleOf"&&Xe.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let t of this._def.checks){if(t.kind==="finite"||t.kind==="int"||t.kind==="multipleOf")return!0;t.kind==="min"?(r===null||t.value>r)&&(r=t.value):t.kind==="max"&&(e===null||t.valuenew Os({checks:[],typeName:ke.ZodNumber,coerce:a?.coerce||!1,...qe(a)});var Cs=class a extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==de.bigint)return this._getInvalidInput(e);let t,s=new It;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),oe(t,{code:re.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),oe(t,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Xe.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:de.bigint,received:r.parsedType}),Oe}gte(e,r){return this.setLimit("min",e,!0,ge.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ge.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ge.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ge.toString(r))}setLimit(e,r,t,s){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:t,message:ge.toString(s)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ge.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ge.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ge.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ge.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ge.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew Cs({checks:[],typeName:ke.ZodBigInt,coerce:a?.coerce??!1,...qe(a)});var ks=class extends Me{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==de.boolean){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.boolean,received:t.parsedType}),Oe}return jt(e.data)}};ks.create=a=>new ks({typeName:ke.ZodBoolean,coerce:a?.coerce||!1,...qe(a)});var As=class a extends Me{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==de.date){let i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:de.date,received:i.parsedType}),Oe}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_date}),Oe}let t=new It,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()i.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):Xe.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:ge.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:ge.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew As({checks:[],coerce:a?.coerce||!1,typeName:ke.ZodDate,...qe(a)});var Bn=class extends Me{_parse(e){if(this._getType(e)!==de.symbol){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.symbol,received:t.parsedType}),Oe}return jt(e.data)}};Bn.create=a=>new Bn({typeName:ke.ZodSymbol,...qe(a)});var Is=class extends Me{_parse(e){if(this._getType(e)!==de.undefined){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.undefined,received:t.parsedType}),Oe}return jt(e.data)}};Is.create=a=>new Is({typeName:ke.ZodUndefined,...qe(a)});var Ds=class extends Me{_parse(e){if(this._getType(e)!==de.null){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.null,received:t.parsedType}),Oe}return jt(e.data)}};Ds.create=a=>new Ds({typeName:ke.ZodNull,...qe(a)});var La=class extends Me{constructor(){super(...arguments),this._any=!0}_parse(e){return jt(e.data)}};La.create=a=>new La({typeName:ke.ZodAny,...qe(a)});var da=class extends Me{constructor(){super(...arguments),this._unknown=!0}_parse(e){return jt(e.data)}};da.create=a=>new da({typeName:ke.ZodUnknown,...qe(a)});var Dr=class extends Me{_parse(e){let r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:de.never,received:r.parsedType}),Oe}};Dr.create=a=>new Dr({typeName:ke.ZodNever,...qe(a)});var zn=class extends Me{_parse(e){if(this._getType(e)!==de.undefined){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.void,received:t.parsedType}),Oe}return jt(e.data)}};zn.create=a=>new zn({typeName:ke.ZodVoid,...qe(a)});var fa=class a extends Me{_parse(e){let{ctx:r,status:t}=this._processInputParams(e),s=this._def;if(r.parsedType!==de.array)return oe(r,{code:re.invalid_type,expected:de.array,received:r.parsedType}),Oe;if(s.exactLength!==null){let n=r.data.length>s.exactLength.value,o=r.data.lengths.maxLength.value&&(oe(r,{code:re.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),t.dirty()),r.common.async)return Promise.all([...r.data].map((n,o)=>s.type._parseAsync(new yr(r,n,r.path,o)))).then(n=>It.mergeArray(t,n));let i=[...r.data].map((n,o)=>s.type._parseSync(new yr(r,n,r.path,o)));return It.mergeArray(t,i)}get element(){return this._def.type}min(e,r){return new a({...this._def,minLength:{value:e,message:ge.toString(r)}})}max(e,r){return new a({...this._def,maxLength:{value:e,message:ge.toString(r)}})}length(e,r){return new a({...this._def,exactLength:{value:e,message:ge.toString(r)}})}nonempty(e){return this.min(1,e)}};fa.create=(a,e)=>new fa({type:a,minLength:null,maxLength:null,exactLength:null,typeName:ke.ZodArray,...qe(e)});function qn(a){if(a instanceof Wt){let e={};for(let r in a.shape){let t=a.shape[r];e[r]=gr.create(qn(t))}return new Wt({...a._def,shape:()=>e})}else return a instanceof fa?new fa({...a._def,type:qn(a.element)}):a instanceof gr?gr.create(qn(a.unwrap())):a instanceof Xr?Xr.create(qn(a.unwrap())):a instanceof Zr?Zr.create(a.items.map(e=>qn(e))):a}var Wt=class a extends Me{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Xe.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==de.object){let c=this._getOrReturnCtx(e);return oe(c,{code:re.invalid_type,expected:de.object,received:c.parsedType}),Oe}let{status:t,ctx:s}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof Dr&&this._def.unknownKeys==="strip"))for(let c in s.data)n.includes(c)||o.push(c);let l=[];for(let c of n){let u=i[c],p=s.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new yr(s,p,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Dr){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of o)l.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(c==="strict")o.length>0&&(oe(s,{code:re.unrecognized_keys,keys:o}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of o){let p=s.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new yr(s,p,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let p=await u.key,m=await u.value;c.push({key:p,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>It.mergeObjectSync(t,c)):It.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return ge.errToObj,new a({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,t)=>{let s=this._def.errorMap?.(r,t).message??t.defaultError;return r.code==="unrecognized_keys"?{message:ge.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new a({...this._def,unknownKeys:"strip"})}passthrough(){return new a({...this._def,unknownKeys:"passthrough"})}extend(e){return new a({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new a({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ke.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new a({...this._def,catchall:e})}pick(e){let r={};for(let t of Xe.objectKeys(e))e[t]&&this.shape[t]&&(r[t]=this.shape[t]);return new a({...this._def,shape:()=>r})}omit(e){let r={};for(let t of Xe.objectKeys(this.shape))e[t]||(r[t]=this.shape[t]);return new a({...this._def,shape:()=>r})}deepPartial(){return qn(this)}partial(e){let r={};for(let t of Xe.objectKeys(this.shape)){let s=this.shape[t];e&&!e[t]?r[t]=s:r[t]=s.optional()}return new a({...this._def,shape:()=>r})}required(e){let r={};for(let t of Xe.objectKeys(this.shape))if(e&&!e[t])r[t]=this.shape[t];else{let i=this.shape[t];for(;i instanceof gr;)i=i._def.innerType;r[t]=i}return new a({...this._def,shape:()=>r})}keyof(){return ww(Xe.objectKeys(this.shape))}};Wt.create=(a,e)=>new Wt({shape:()=>a,unknownKeys:"strip",catchall:Dr.create(),typeName:ke.ZodObject,...qe(e)});Wt.strictCreate=(a,e)=>new Wt({shape:()=>a,unknownKeys:"strict",catchall:Dr.create(),typeName:ke.ZodObject,...qe(e)});Wt.lazycreate=(a,e)=>new Wt({shape:a,unknownKeys:"strip",catchall:Dr.create(),typeName:ke.ZodObject,...qe(e)});var Ns=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let n=i.map(o=>new tr(o.ctx.common.issues));return oe(r,{code:re.invalid_union,unionErrors:n}),Oe}if(r.common.async)return Promise.all(t.map(async i=>{let n={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:n}),ctx:n}})).then(s);{let i,n=[];for(let l of t){let c={...r,common:{...r.common,issues:[]},parent:null},u=l._parseSync({data:r.data,path:r.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:c}),c.common.issues.length&&n.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=n.map(l=>new tr(l));return oe(r,{code:re.invalid_union,unionErrors:o}),Oe}}get options(){return this._def.options}};Ns.create=(a,e)=>new Ns({options:a,typeName:ke.ZodUnion,...qe(e)});var la=a=>a instanceof $s?la(a.schema):a instanceof rr?la(a.innerType()):a instanceof Ms?[a.value]:a instanceof Ls?a.options:a instanceof Fs?Xe.objectValues(a.enum):a instanceof qs?la(a._def.innerType):a instanceof Is?[void 0]:a instanceof Ds?[null]:a instanceof gr?[void 0,...la(a.unwrap())]:a instanceof Xr?[null,...la(a.unwrap())]:a instanceof Yi||a instanceof Hs?la(a.unwrap()):a instanceof Us?la(a._def.innerType):[],gl=class a extends Me{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==de.object)return oe(r,{code:re.invalid_type,expected:de.object,received:r.parsedType}),Oe;let t=this.discriminator,s=r.data[t],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(oe(r,{code:re.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[t]}),Oe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,t){let s=new Map;for(let i of r){let n=la(i.shape[e]);if(!n.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of n){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new a({typeName:ke.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...qe(t)})}};function gf(a,e){let r=ua(a),t=ua(e);if(a===e)return{valid:!0,data:a};if(r===de.object&&t===de.object){let s=Xe.objectKeys(e),i=Xe.objectKeys(a).filter(o=>s.indexOf(o)!==-1),n={...a,...e};for(let o of i){let l=gf(a[o],e[o]);if(!l.valid)return{valid:!1};n[o]=l.data}return{valid:!0,data:n}}else if(r===de.array&&t===de.array){if(a.length!==e.length)return{valid:!1};let s=[];for(let i=0;i{if(hf(i)||hf(n))return Oe;let o=gf(i.value,n.value);return o.valid?((vf(i)||vf(n))&&r.dirty(),{status:r.value,value:o.data}):(oe(t,{code:re.invalid_intersection_types}),Oe)};return t.common.async?Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([i,n])=>s(i,n)):s(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};js.create=(a,e,r)=>new js({left:a,right:e,typeName:ke.ZodIntersection,...qe(r)});var Zr=class a extends Me{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==de.array)return oe(t,{code:re.invalid_type,expected:de.array,received:t.parsedType}),Oe;if(t.data.lengththis._def.items.length&&(oe(t,{code:re.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...t.data].map((n,o)=>{let l=this._def.items[o]||this._def.rest;return l?l._parse(new yr(t,n,t.path,o)):null}).filter(n=>!!n);return t.common.async?Promise.all(i).then(n=>It.mergeArray(r,n)):It.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new a({...this._def,rest:e})}};Zr.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Zr({items:a,typeName:ke.ZodTuple,rest:null,...qe(e)})};var yl=class a extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==de.object)return oe(t,{code:re.invalid_type,expected:de.object,received:t.parsedType}),Oe;let s=[],i=this._def.keyType,n=this._def.valueType;for(let o in t.data)s.push({key:i._parse(new yr(t,o,t.path,o)),value:n._parse(new yr(t,t.data[o],t.path,o)),alwaysSet:o in t.data});return t.common.async?It.mergeObjectAsync(r,s):It.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,t){return r instanceof Me?new a({keyType:e,valueType:r,typeName:ke.ZodRecord,...qe(t)}):new a({keyType:Ma.create(),valueType:e,typeName:ke.ZodRecord,...qe(r)})}},Vn=class extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==de.map)return oe(t,{code:re.invalid_type,expected:de.map,received:t.parsedType}),Oe;let s=this._def.keyType,i=this._def.valueType,n=[...t.data.entries()].map(([o,l],c)=>({key:s._parse(new yr(t,o,t.path,[c,"key"])),value:i._parse(new yr(t,l,t.path,[c,"value"]))}));if(t.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let l of n){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Oe;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(c.value,u.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let l of n){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Oe;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(c.value,u.value)}return{status:r.value,value:o}}}};Vn.create=(a,e,r)=>new Vn({valueType:e,keyType:a,typeName:ke.ZodMap,...qe(r)});var Gn=class a extends Me{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==de.set)return oe(t,{code:re.invalid_type,expected:de.set,received:t.parsedType}),Oe;let s=this._def;s.minSize!==null&&t.data.sizes.maxSize.value&&(oe(t,{code:re.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function n(l){let c=new Set;for(let u of l){if(u.status==="aborted")return Oe;u.status==="dirty"&&r.dirty(),c.add(u.value)}return{status:r.value,value:c}}let o=[...t.data.values()].map((l,c)=>i._parse(new yr(t,l,t.path,c)));return t.common.async?Promise.all(o).then(l=>n(l)):n(o)}min(e,r){return new a({...this._def,minSize:{value:e,message:ge.toString(r)}})}max(e,r){return new a({...this._def,maxSize:{value:e,message:ge.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Gn.create=(a,e)=>new Gn({valueType:a,minSize:null,maxSize:null,typeName:ke.ZodSet,...qe(e)});var bl=class a extends Me{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==de.function)return oe(r,{code:re.invalid_type,expected:de.function,received:r.parsedType}),Oe;function t(o,l){return vl({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,hl(),Hn].filter(c=>!!c),issueData:{code:re.invalid_arguments,argumentsError:l}})}function s(o,l){return vl({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,hl(),Hn].filter(c=>!!c),issueData:{code:re.invalid_return_type,returnTypeError:l}})}let i={errorMap:r.common.contextualErrorMap},n=r.data;if(this._def.returns instanceof Fa){let o=this;return jt(async function(...l){let c=new tr([]),u=await o._def.args.parseAsync(l,i).catch(d=>{throw c.addIssue(t(l,d)),c}),p=await Reflect.apply(n,this,u);return await o._def.returns._def.type.parseAsync(p,i).catch(d=>{throw c.addIssue(s(p,d)),c})})}else{let o=this;return jt(function(...l){let c=o._def.args.safeParse(l,i);if(!c.success)throw new tr([t(l,c.error)]);let u=Reflect.apply(n,this,c.data),p=o._def.returns.safeParse(u,i);if(!p.success)throw new tr([s(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new a({...this._def,args:Zr.create(e).rest(da.create())})}returns(e){return new a({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,t){return new a({args:e||Zr.create([]).rest(da.create()),returns:r||da.create(),typeName:ke.ZodFunction,...qe(t)})}},$s=class extends Me{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};$s.create=(a,e)=>new $s({getter:a,typeName:ke.ZodLazy,...qe(e)});var Ms=class extends Me{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return oe(r,{received:r.data,code:re.invalid_literal,expected:this._def.value}),Oe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ms.create=(a,e)=>new Ms({value:a,typeName:ke.ZodLiteral,...qe(e)});function ww(a,e){return new Ls({values:a,typeName:ke.ZodEnum,...qe(e)})}var Ls=class a extends Me{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),t=this._def.values;return oe(r,{expected:Xe.joinValues(t),received:r.parsedType,code:re.invalid_type}),Oe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),t=this._def.values;return oe(r,{received:r.data,code:re.invalid_enum_value,options:t}),Oe}return jt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return a.create(e,{...this._def,...r})}exclude(e,r=this._def){return a.create(this.options.filter(t=>!e.includes(t)),{...this._def,...r})}};Ls.create=ww;var Fs=class extends Me{_parse(e){let r=Xe.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(e);if(t.parsedType!==de.string&&t.parsedType!==de.number){let s=Xe.objectValues(r);return oe(t,{expected:Xe.joinValues(s),received:t.parsedType,code:re.invalid_type}),Oe}if(this._cache||(this._cache=new Set(Xe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=Xe.objectValues(r);return oe(t,{received:t.data,code:re.invalid_enum_value,options:s}),Oe}return jt(e.data)}get enum(){return this._def.values}};Fs.create=(a,e)=>new Fs({values:a,typeName:ke.ZodNativeEnum,...qe(e)});var Fa=class extends Me{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==de.promise&&r.common.async===!1)return oe(r,{code:re.invalid_type,expected:de.promise,received:r.parsedType}),Oe;let t=r.parsedType===de.promise?r.data:Promise.resolve(r.data);return jt(t.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Fa.create=(a,e)=>new Fa({type:a,typeName:ke.ZodPromise,...qe(e)});var rr=class extends Me{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ke.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:t}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:n=>{oe(t,n),n.fatal?r.abort():r.dirty()},get path(){return t.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let n=s.transform(t.data,i);if(t.common.async)return Promise.resolve(n).then(async o=>{if(r.value==="aborted")return Oe;let l=await this._def.schema._parseAsync({data:o,path:t.path,parent:t});return l.status==="aborted"?Oe:l.status==="dirty"||r.value==="dirty"?Un(l.value):l});{if(r.value==="aborted")return Oe;let o=this._def.schema._parseSync({data:n,path:t.path,parent:t});return o.status==="aborted"?Oe:o.status==="dirty"||r.value==="dirty"?Un(o.value):o}}if(s.type==="refinement"){let n=o=>{let l=s.refinement(o,i);if(t.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(t.common.async===!1){let o=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});return o.status==="aborted"?Oe:(o.status==="dirty"&&r.dirty(),n(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(o=>o.status==="aborted"?Oe:(o.status==="dirty"&&r.dirty(),n(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(t.common.async===!1){let n=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!Ps(n))return Oe;let o=s.transform(n.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(n=>Ps(n)?Promise.resolve(s.transform(n.value,i)).then(o=>({status:r.value,value:o})):Oe);Xe.assertNever(s)}};rr.create=(a,e,r)=>new rr({schema:a,typeName:ke.ZodEffects,effect:e,...qe(r)});rr.createWithPreprocess=(a,e,r)=>new rr({schema:e,effect:{type:"preprocess",transform:a},typeName:ke.ZodEffects,...qe(r)});var gr=class extends Me{_parse(e){return this._getType(e)===de.undefined?jt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};gr.create=(a,e)=>new gr({innerType:a,typeName:ke.ZodOptional,...qe(e)});var Xr=class extends Me{_parse(e){return this._getType(e)===de.null?jt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xr.create=(a,e)=>new Xr({innerType:a,typeName:ke.ZodNullable,...qe(e)});var qs=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t=r.data;return r.parsedType===de.undefined&&(t=this._def.defaultValue()),this._def.innerType._parse({data:t,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};qs.create=(a,e)=>new qs({innerType:a,typeName:ke.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...qe(e)});var Us=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});return Qi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new tr(t.common.issues)},input:t.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new tr(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};Us.create=(a,e)=>new Us({innerType:a,typeName:ke.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...qe(e)});var Wn=class extends Me{_parse(e){if(this._getType(e)!==de.nan){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.nan,received:t.parsedType}),Oe}return{status:"valid",value:e.data}}};Wn.create=a=>new Wn({typeName:ke.ZodNaN,...qe(a)});var pL=Symbol("zod_brand"),Yi=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t=r.data;return this._def.type._parse({data:t,path:r.path,parent:r})}unwrap(){return this._def.type}},Ji=class a extends Me{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:t.data,path:t.path,parent:t});return i.status==="aborted"?Oe:i.status==="dirty"?(r.dirty(),Un(i.value)):this._def.out._parseAsync({data:i.value,path:t.path,parent:t})})();{let s=this._def.in._parseSync({data:t.data,path:t.path,parent:t});return s.status==="aborted"?Oe:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:t.path,parent:t})}}static create(e,r){return new a({in:e,out:r,typeName:ke.ZodPipeline})}},Hs=class extends Me{_parse(e){let r=this._def.innerType._parse(e),t=s=>(Ps(s)&&(s.value=Object.freeze(s.value)),s);return Qi(r)?r.then(s=>t(s)):t(r)}unwrap(){return this._def.innerType}};Hs.create=(a,e)=>new Hs({innerType:a,typeName:ke.ZodReadonly,...qe(e)});function GE(a,e){let r=typeof a=="function"?a(e):typeof a=="string"?{message:a}:a;return typeof r=="string"?{message:r}:r}function Tw(a,e={},r){return a?La.create().superRefine((t,s)=>{let i=a(t);if(i instanceof Promise)return i.then(n=>{if(!n){let o=GE(e,t),l=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:l})}});if(!i){let n=GE(e,t),o=n.fatal??r??!0;s.addIssue({code:"custom",...n,fatal:o})}}):La.create()}var dL={object:Wt.lazycreate},ke;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(ke||(ke={}));var fL=(a,e={message:`Input not instance of ${a.name}`})=>Tw(r=>r instanceof a,e),Rw=Ma.create,Pw=Os.create,mL=Wn.create,hL=Cs.create,Ow=ks.create,vL=As.create,gL=Bn.create,yL=Is.create,bL=Ds.create,xL=La.create,_L=da.create,SL=Dr.create,EL=zn.create,wL=fa.create,TL=Wt.create,RL=Wt.strictCreate,PL=Ns.create,OL=gl.create,CL=js.create,kL=Zr.create,AL=yl.create,IL=Vn.create,DL=Gn.create,NL=bl.create,jL=$s.create,$L=Ms.create,ML=Ls.create,LL=Fs.create,FL=Fa.create,WE=rr.create,qL=gr.create,UL=Xr.create,HL=rr.createWithPreprocess,BL=Ji.create,zL=()=>Rw().optional(),VL=()=>Pw().optional(),GL=()=>Ow().optional(),WL={string:a=>Ma.create({...a,coerce:!0}),number:a=>Os.create({...a,coerce:!0}),boolean:a=>ks.create({...a,coerce:!0}),bigint:a=>Cs.create({...a,coerce:!0}),date:a=>As.create({...a,coerce:!0})},ZL=Oe;var El="2.0",Cw=E.union([E.string(),E.number().int()]),kw=E.string(),XL=E.object({progressToken:E.optional(Cw)}).passthrough(),br=E.object({_meta:E.optional(XL)}).passthrough(),Zt=E.object({method:E.string(),params:E.optional(br)}),to=E.object({_meta:E.optional(E.object({}).passthrough())}).passthrough(),Kr=E.object({method:E.string(),params:E.optional(to)}),xr=E.object({_meta:E.optional(E.object({}).passthrough())}).passthrough(),wl=E.union([E.string(),E.number().int()]),KL=E.object({jsonrpc:E.literal(El),id:wl}).merge(Zt).strict();var QL=E.object({jsonrpc:E.literal(El)}).merge(Kr).strict();var YL=E.object({jsonrpc:E.literal(El),id:wl,result:xr}).strict();var ZE;(function(a){a[a.ConnectionClosed=-32e3]="ConnectionClosed",a[a.RequestTimeout=-32001]="RequestTimeout",a[a.ParseError=-32700]="ParseError",a[a.InvalidRequest=-32600]="InvalidRequest",a[a.MethodNotFound=-32601]="MethodNotFound",a[a.InvalidParams=-32602]="InvalidParams",a[a.InternalError=-32603]="InternalError"})(ZE||(ZE={}));var JL=E.object({jsonrpc:E.literal(El),id:wl,error:E.object({code:E.number().int(),message:E.string(),data:E.optional(E.unknown())})}).strict();var JH=E.union([KL,QL,YL,JL]),Aw=xr.strict(),Iw=Kr.extend({method:E.literal("notifications/cancelled"),params:to.extend({requestId:wl,reason:E.string().optional()})}),ro=E.object({name:E.string(),title:E.optional(E.string())}).passthrough(),Dw=ro.extend({version:E.string()}),e6=E.object({experimental:E.optional(E.object({}).passthrough()),sampling:E.optional(E.object({}).passthrough()),elicitation:E.optional(E.object({}).passthrough()),roots:E.optional(E.object({listChanged:E.optional(E.boolean())}).passthrough())}).passthrough(),t6=Zt.extend({method:E.literal("initialize"),params:br.extend({protocolVersion:E.string(),capabilities:e6,clientInfo:Dw})}),r6=E.object({experimental:E.optional(E.object({}).passthrough()),logging:E.optional(E.object({}).passthrough()),completions:E.optional(E.object({}).passthrough()),prompts:E.optional(E.object({listChanged:E.optional(E.boolean())}).passthrough()),resources:E.optional(E.object({subscribe:E.optional(E.boolean()),listChanged:E.optional(E.boolean())}).passthrough()),tools:E.optional(E.object({listChanged:E.optional(E.boolean())}).passthrough())}).passthrough(),a6=xr.extend({protocolVersion:E.string(),capabilities:r6,serverInfo:Dw,instructions:E.optional(E.string())}),s6=Kr.extend({method:E.literal("notifications/initialized")}),Nw=Zt.extend({method:E.literal("ping")}),n6=E.object({progress:E.number(),total:E.optional(E.number()),message:E.optional(E.string())}).passthrough(),jw=Kr.extend({method:E.literal("notifications/progress"),params:to.merge(n6).extend({progressToken:Cw})}),Tl=Zt.extend({params:br.extend({cursor:E.optional(kw)}).optional()}),Rl=xr.extend({nextCursor:E.optional(kw)}),$w=E.object({uri:E.string(),mimeType:E.optional(E.string()),_meta:E.optional(E.object({}).passthrough())}).passthrough(),Mw=$w.extend({text:E.string()}),wf=E.string().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),Lw=$w.extend({blob:wf}),Fw=ro.extend({uri:E.string(),description:E.optional(E.string()),mimeType:E.optional(E.string()),_meta:E.optional(E.object({}).passthrough())}),i6=ro.extend({uriTemplate:E.string(),description:E.optional(E.string()),mimeType:E.optional(E.string()),_meta:E.optional(E.object({}).passthrough())}),o6=Tl.extend({method:E.literal("resources/list")}),c6=Rl.extend({resources:E.array(Fw)}),l6=Tl.extend({method:E.literal("resources/templates/list")}),u6=Rl.extend({resourceTemplates:E.array(i6)}),p6=Zt.extend({method:E.literal("resources/read"),params:br.extend({uri:E.string()})}),d6=xr.extend({contents:E.array(E.union([Mw,Lw]))}),f6=Kr.extend({method:E.literal("notifications/resources/list_changed")}),m6=Zt.extend({method:E.literal("resources/subscribe"),params:br.extend({uri:E.string()})}),h6=Zt.extend({method:E.literal("resources/unsubscribe"),params:br.extend({uri:E.string()})}),v6=Kr.extend({method:E.literal("notifications/resources/updated"),params:to.extend({uri:E.string()})}),g6=E.object({name:E.string(),description:E.optional(E.string()),required:E.optional(E.boolean())}).passthrough(),y6=ro.extend({description:E.optional(E.string()),arguments:E.optional(E.array(g6)),_meta:E.optional(E.object({}).passthrough())}),b6=Tl.extend({method:E.literal("prompts/list")}),x6=Rl.extend({prompts:E.array(y6)}),_6=Zt.extend({method:E.literal("prompts/get"),params:br.extend({name:E.string(),arguments:E.optional(E.record(E.string()))})}),Tf=E.object({type:E.literal("text"),text:E.string(),_meta:E.optional(E.object({}).passthrough())}).passthrough(),Rf=E.object({type:E.literal("image"),data:wf,mimeType:E.string(),_meta:E.optional(E.object({}).passthrough())}).passthrough(),Pf=E.object({type:E.literal("audio"),data:wf,mimeType:E.string(),_meta:E.optional(E.object({}).passthrough())}).passthrough(),S6=E.object({type:E.literal("resource"),resource:E.union([Mw,Lw]),_meta:E.optional(E.object({}).passthrough())}).passthrough(),E6=Fw.extend({type:E.literal("resource_link")}),qw=E.union([Tf,Rf,Pf,E6,S6]),w6=E.object({role:E.enum(["user","assistant"]),content:qw}).passthrough(),T6=xr.extend({description:E.optional(E.string()),messages:E.array(w6)}),R6=Kr.extend({method:E.literal("notifications/prompts/list_changed")}),P6=E.object({title:E.optional(E.string()),readOnlyHint:E.optional(E.boolean()),destructiveHint:E.optional(E.boolean()),idempotentHint:E.optional(E.boolean()),openWorldHint:E.optional(E.boolean())}).passthrough(),O6=ro.extend({description:E.optional(E.string()),inputSchema:E.object({type:E.literal("object"),properties:E.optional(E.object({}).passthrough()),required:E.optional(E.array(E.string()))}).passthrough(),outputSchema:E.optional(E.object({type:E.literal("object"),properties:E.optional(E.object({}).passthrough()),required:E.optional(E.array(E.string()))}).passthrough()),annotations:E.optional(P6),_meta:E.optional(E.object({}).passthrough())}),C6=Tl.extend({method:E.literal("tools/list")}),k6=Rl.extend({tools:E.array(O6)}),Uw=xr.extend({content:E.array(qw).default([]),structuredContent:E.object({}).passthrough().optional(),isError:E.optional(E.boolean())}),eB=Uw.or(xr.extend({toolResult:E.unknown()})),A6=Zt.extend({method:E.literal("tools/call"),params:br.extend({name:E.string(),arguments:E.optional(E.record(E.unknown()))})}),I6=Kr.extend({method:E.literal("notifications/tools/list_changed")}),Hw=E.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),D6=Zt.extend({method:E.literal("logging/setLevel"),params:br.extend({level:Hw})}),N6=Kr.extend({method:E.literal("notifications/message"),params:to.extend({level:Hw,logger:E.optional(E.string()),data:E.unknown()})}),j6=E.object({name:E.string().optional()}).passthrough(),$6=E.object({hints:E.optional(E.array(j6)),costPriority:E.optional(E.number().min(0).max(1)),speedPriority:E.optional(E.number().min(0).max(1)),intelligencePriority:E.optional(E.number().min(0).max(1))}).passthrough(),M6=E.object({role:E.enum(["user","assistant"]),content:E.union([Tf,Rf,Pf])}).passthrough(),L6=Zt.extend({method:E.literal("sampling/createMessage"),params:br.extend({messages:E.array(M6),systemPrompt:E.optional(E.string()),includeContext:E.optional(E.enum(["none","thisServer","allServers"])),temperature:E.optional(E.number()),maxTokens:E.number().int(),stopSequences:E.optional(E.array(E.string())),metadata:E.optional(E.object({}).passthrough()),modelPreferences:E.optional($6)})}),F6=xr.extend({model:E.string(),stopReason:E.optional(E.enum(["endTurn","stopSequence","maxTokens"]).or(E.string())),role:E.enum(["user","assistant"]),content:E.discriminatedUnion("type",[Tf,Rf,Pf])}),q6=E.object({type:E.literal("boolean"),title:E.optional(E.string()),description:E.optional(E.string()),default:E.optional(E.boolean())}).passthrough(),U6=E.object({type:E.literal("string"),title:E.optional(E.string()),description:E.optional(E.string()),minLength:E.optional(E.number()),maxLength:E.optional(E.number()),format:E.optional(E.enum(["email","uri","date","date-time"]))}).passthrough(),H6=E.object({type:E.enum(["number","integer"]),title:E.optional(E.string()),description:E.optional(E.string()),minimum:E.optional(E.number()),maximum:E.optional(E.number())}).passthrough(),B6=E.object({type:E.literal("string"),title:E.optional(E.string()),description:E.optional(E.string()),enum:E.array(E.string()),enumNames:E.optional(E.array(E.string()))}).passthrough(),z6=E.union([q6,U6,H6,B6]),V6=Zt.extend({method:E.literal("elicitation/create"),params:br.extend({message:E.string(),requestedSchema:E.object({type:E.literal("object"),properties:E.record(E.string(),z6),required:E.optional(E.array(E.string()))}).passthrough()})}),G6=xr.extend({action:E.enum(["accept","decline","cancel"]),content:E.optional(E.record(E.string(),E.unknown()))}),W6=E.object({type:E.literal("ref/resource"),uri:E.string()}).passthrough(),Z6=E.object({type:E.literal("ref/prompt"),name:E.string()}).passthrough(),X6=Zt.extend({method:E.literal("completion/complete"),params:br.extend({ref:E.union([Z6,W6]),argument:E.object({name:E.string(),value:E.string()}).passthrough(),context:E.optional(E.object({arguments:E.optional(E.record(E.string(),E.string()))}))})}),K6=xr.extend({completion:E.object({values:E.array(E.string()).max(100),total:E.optional(E.number().int()),hasMore:E.optional(E.boolean())}).passthrough()}),Q6=E.object({uri:E.string().startsWith("file://"),name:E.optional(E.string()),_meta:E.optional(E.object({}).passthrough())}).passthrough(),Y6=Zt.extend({method:E.literal("roots/list")}),J6=xr.extend({roots:E.array(Q6)}),e5=Kr.extend({method:E.literal("notifications/roots/list_changed")}),tB=E.union([Nw,t6,X6,D6,_6,b6,o6,l6,p6,m6,h6,A6,C6]),rB=E.union([Iw,jw,s6,e5]),aB=E.union([Aw,F6,G6,J6]),sB=E.union([Nw,L6,V6,Y6]),nB=E.union([Iw,jw,N6,v6,f6,I6,R6]),iB=E.union([Aw,a6,K6,T6,x6,c6,u6,d6,Uw,k6]);var oB=X$(k8(),1);var cB=Symbol("Let zodToJsonSchema decide on which parser to use");var lB=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var yf;(function(a){a.Completable="McpCompletable"})(yf||(yf={}));var xl=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t=r.data;return this._def.type._parse({data:t,path:r.path,parent:r})}unwrap(){return this._def.type}};xl.create=(a,e)=>new xl({type:a,typeName:yf.Completable,complete:e.complete,...t5(e)});function t5(a){if(!a)return{};let{errorMap:e,invalid_type_error:r,required_error:t,description:s}=a;if(e&&(r||t))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(n,o)=>{var l,c;let{message:u}=a;return n.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:(l=u??t)!==null&&l!==void 0?l:o.defaultError}:n.code!=="invalid_type"?{message:o.defaultError}:{message:(c=u??r)!==null&&c!==void 0?c:o.defaultError}},description:s}}function Bw({prompt:a,options:e}){let{systemPrompt:r,settingSources:t,sandbox:s,...i}=e??{},n,o;r===void 0?n="":typeof r=="string"?n=r:r.type==="preset"&&(o=r.append);let l=i.pathToClaudeCodeExecutable;if(!l){let Te=(0,JE.fileURLToPath)(r5.url),ce=(0,cf.join)(Te,"..");l=(0,cf.join)(ce,"cli.js")}process.env.CLAUDE_AGENT_SDK_VERSION="0.1.67";let{abortController:c=tw(),additionalDirectories:u=[],agents:p,allowedTools:m=[],betas:d,canUseTool:v,continue:h,cwd:f,disallowedTools:y=[],tools:g,env:b,executable:w=gw()?"bun":"node",executableArgs:P=[],extraArgs:T={},fallbackModel:k,enableFileCheckpointing:N,forkSession:A,hooks:$,includePartialMessages:D,persistSession:C,maxThinkingTokens:O,maxTurns:j,maxBudgetUsd:q,mcpServers:z,model:V,outputFormat:K,permissionMode:Z="default",allowDangerouslySkipPermissions:X=!1,permissionPromptToolName:se,plugins:Y,resume:Pe,resumeSessionAt:fe,stderr:Ee,strictMcpConfig:we}=i,De=K?.type==="json_schema"?K.schema:void 0,H=b;if(H||(H={...process.env}),H.CLAUDE_CODE_ENTRYPOINT||(H.CLAUDE_CODE_ENTRYPOINT="sdk-ts"),N&&(H.CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING="true"),!l)throw new Error("pathToClaudeCodeExecutable is required");let G={},te=new Map;if(z)for(let[Te,ce]of Object.entries(z))ce.type==="sdk"&&"instance"in ce?(te.set(Te,ce.instance),G[Te]={type:"sdk",name:Te}):G[Te]=ce;let le=typeof a=="string",W=new uf({abortController:c,additionalDirectories:u,betas:d,cwd:f,executable:w,executableArgs:P,extraArgs:T,pathToClaudeCodeExecutable:l,env:H,forkSession:A,stderr:Ee,maxThinkingTokens:O,maxTurns:j,maxBudgetUsd:q,model:V,fallbackModel:k,jsonSchema:De,permissionMode:Z,allowDangerouslySkipPermissions:X,permissionPromptToolName:se,continueConversation:h,resume:Pe,resumeSessionAt:fe,settingSources:t??[],allowedTools:m,disallowedTools:y,tools:g,mcpServers:G,strictMcpConfig:we,canUseTool:!!v,hooks:!!$,includePartialMessages:D,persistSession:C,plugins:Y,sandbox:s,spawnClaudeCodeProcess:i.spawnClaudeCodeProcess}),Q={systemPrompt:n,appendSystemPrompt:o,agents:p},ne=new ff(W,le,v,$,c,te,De,Q);return typeof a=="string"?(W.write(JSON.stringify({type:"user",session_id:"",message:{role:"user",content:[{type:"text",text:a}]},parent_tool_use_id:null})+` +`)}handleMcpControlRequest(e,r,t){let s="id"in r.message?r.message.id:null,i=`${e}:${s}`;return new Promise((n,o)=>{let l=()=>{this.pendingMcpResponses.delete(i)},c=p=>{l(),n(p)},u=p=>{l(),o(p)};if(this.pendingMcpResponses.set(i,{resolve:c,reject:u}),t.onmessage)t.onmessage(r.message);else{l(),o(new Error("No message handler registered"));return}})}};var E={};K$(E,{void:()=>EL,util:()=>Xe,unknown:()=>_L,union:()=>PL,undefined:()=>yL,tuple:()=>kL,transformer:()=>WE,symbol:()=>gL,string:()=>Rw,strictObject:()=>RL,setErrorMap:()=>HM,set:()=>DL,record:()=>AL,quotelessJson:()=>qM,promise:()=>FL,preprocess:()=>HL,pipeline:()=>BL,ostring:()=>zL,optional:()=>qL,onumber:()=>VL,oboolean:()=>GL,objectUtil:()=>mf,object:()=>TL,number:()=>Pw,nullable:()=>UL,null:()=>bL,never:()=>SL,nativeEnum:()=>LL,nan:()=>mL,map:()=>IL,makeIssue:()=>vl,literal:()=>$L,lazy:()=>jL,late:()=>dL,isValid:()=>Ps,isDirty:()=>vf,isAsync:()=>Qi,isAborted:()=>hf,intersection:()=>CL,instanceof:()=>fL,getParsedType:()=>ua,getErrorMap:()=>hl,function:()=>NL,enum:()=>ML,effect:()=>WE,discriminatedUnion:()=>OL,defaultErrorMap:()=>Hn,datetimeRegex:()=>Ew,date:()=>vL,custom:()=>Tw,coerce:()=>WL,boolean:()=>Ow,bigint:()=>hL,array:()=>wL,any:()=>xL,addIssueToContext:()=>oe,ZodVoid:()=>zn,ZodUnknown:()=>da,ZodUnion:()=>Ns,ZodUndefined:()=>Is,ZodType:()=>Me,ZodTuple:()=>Zr,ZodTransformer:()=>rr,ZodSymbol:()=>Bn,ZodString:()=>Ma,ZodSet:()=>Gn,ZodSchema:()=>Me,ZodRecord:()=>yl,ZodReadonly:()=>Hs,ZodPromise:()=>Fa,ZodPipeline:()=>Ji,ZodParsedType:()=>de,ZodOptional:()=>gr,ZodObject:()=>Wt,ZodNumber:()=>Os,ZodNullable:()=>Xr,ZodNull:()=>Ds,ZodNever:()=>Dr,ZodNativeEnum:()=>Fs,ZodNaN:()=>Wn,ZodMap:()=>Vn,ZodLiteral:()=>Ms,ZodLazy:()=>$s,ZodIssueCode:()=>re,ZodIntersection:()=>js,ZodFunction:()=>bl,ZodFirstPartyTypeKind:()=>ke,ZodError:()=>tr,ZodEnum:()=>Ls,ZodEffects:()=>rr,ZodDiscriminatedUnion:()=>gl,ZodDefault:()=>qs,ZodDate:()=>As,ZodCatch:()=>Us,ZodBranded:()=>Yi,ZodBoolean:()=>ks,ZodBigInt:()=>Cs,ZodArray:()=>fa,ZodAny:()=>La,Schema:()=>Me,ParseStatus:()=>It,OK:()=>jt,NEVER:()=>ZL,INVALID:()=>Oe,EMPTY_PATH:()=>BM,DIRTY:()=>Un,BRAND:()=>pL});var Xe;(function(a){a.assertEqual=s=>{};function e(s){}a.assertIs=e;function r(s){throw new Error}a.assertNever=r,a.arrayToEnum=s=>{let i={};for(let n of s)i[n]=n;return i},a.getValidEnumValues=s=>{let i=a.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),n={};for(let o of i)n[o]=s[o];return a.objectValues(n)},a.objectValues=s=>a.objectKeys(s).map(function(i){return s[i]}),a.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let n in s)Object.prototype.hasOwnProperty.call(s,n)&&i.push(n);return i},a.find=(s,i)=>{for(let n of s)if(i(n))return n},a.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function t(s,i=" | "){return s.map(n=>typeof n=="string"?`'${n}'`:n).join(i)}a.joinValues=t,a.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Xe||(Xe={}));var mf;(function(a){a.mergeShapes=(e,r)=>({...e,...r})})(mf||(mf={}));var de=Xe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ua=a=>{switch(typeof a){case"undefined":return de.undefined;case"string":return de.string;case"number":return Number.isNaN(a)?de.nan:de.number;case"boolean":return de.boolean;case"function":return de.function;case"bigint":return de.bigint;case"symbol":return de.symbol;case"object":return Array.isArray(a)?de.array:a===null?de.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?de.promise:typeof Map<"u"&&a instanceof Map?de.map:typeof Set<"u"&&a instanceof Set?de.set:typeof Date<"u"&&a instanceof Date?de.date:de.object;default:return de.unknown}},re=Xe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),qM=a=>JSON.stringify(a,null,2).replace(/"([^"]+)":/g,"$1:"),tr=class a extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=t=>{this.issues=[...this.issues,t]},this.addIssues=(t=[])=>{this.issues=[...this.issues,...t]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(i){return i.message},t={_errors:[]},s=i=>{for(let n of i.issues)if(n.code==="invalid_union")n.unionErrors.map(s);else if(n.code==="invalid_return_type")s(n.returnTypeError);else if(n.code==="invalid_arguments")s(n.argumentsError);else if(n.path.length===0)t._errors.push(r(n));else{let o=t,l=0;for(;lr.message){let r={},t=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];r[i]=r[i]||[],r[i].push(e(s))}else t.push(e(s));return{formErrors:t,fieldErrors:r}}get formErrors(){return this.flatten()}};tr.create=a=>new tr(a);var UM=(a,e)=>{let r;switch(a.code){case re.invalid_type:a.received===de.undefined?r="Required":r=`Expected ${a.expected}, received ${a.received}`;break;case re.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(a.expected,Xe.jsonStringifyReplacer)}`;break;case re.unrecognized_keys:r=`Unrecognized key(s) in object: ${Xe.joinValues(a.keys,", ")}`;break;case re.invalid_union:r="Invalid input";break;case re.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Xe.joinValues(a.options)}`;break;case re.invalid_enum_value:r=`Invalid enum value. Expected ${Xe.joinValues(a.options)}, received '${a.received}'`;break;case re.invalid_arguments:r="Invalid function arguments";break;case re.invalid_return_type:r="Invalid function return type";break;case re.invalid_date:r="Invalid date";break;case re.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(r=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?r=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?r=`Invalid input: must end with "${a.validation.endsWith}"`:Xe.assertNever(a.validation):a.validation!=="regex"?r=`Invalid ${a.validation}`:r="Invalid";break;case re.too_small:a.type==="array"?r=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?r=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?r=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="bigint"?r=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?r=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:r="Invalid input";break;case re.too_big:a.type==="array"?r=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?r=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?r=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?r=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?r=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:r="Invalid input";break;case re.custom:r="Invalid input";break;case re.invalid_intersection_types:r="Intersection results could not be merged";break;case re.not_multiple_of:r=`Number must be a multiple of ${a.multipleOf}`;break;case re.not_finite:r="Number must be finite";break;default:r=e.defaultError,Xe.assertNever(a)}return{message:r}},Hn=UM,xw=Hn;function HM(a){xw=a}function hl(){return xw}var vl=a=>{let{data:e,path:r,errorMaps:t,issueData:s}=a,i=[...r,...s.path||[]],n={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",l=t.filter(c=>!!c).slice().reverse();for(let c of l)o=c(n,{data:e,defaultError:o}).message;return{...s,path:i,message:o}},BM=[];function oe(a,e){let r=hl(),t=vl({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,r,r===Hn?void 0:Hn].filter(s=>!!s)});a.common.issues.push(t)}var It=class a{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let t=[];for(let s of r){if(s.status==="aborted")return Oe;s.status==="dirty"&&e.dirty(),t.push(s.value)}return{status:e.value,value:t}}static async mergeObjectAsync(e,r){let t=[];for(let s of r){let i=await s.key,n=await s.value;t.push({key:i,value:n})}return a.mergeObjectSync(e,t)}static mergeObjectSync(e,r){let t={};for(let s of r){let{key:i,value:n}=s;if(i.status==="aborted"||n.status==="aborted")return Oe;i.status==="dirty"&&e.dirty(),n.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof n.value<"u"||s.alwaysSet)&&(t[i.value]=n.value)}return{status:e.value,value:t}}},Oe=Object.freeze({status:"aborted"}),Un=a=>({status:"dirty",value:a}),jt=a=>({status:"valid",value:a}),hf=a=>a.status==="aborted",vf=a=>a.status==="dirty",Ps=a=>a.status==="valid",Qi=a=>typeof Promise<"u"&&a instanceof Promise,ge;(function(a){a.errToObj=e=>typeof e=="string"?{message:e}:e||{},a.toString=e=>typeof e=="string"?e:e?.message})(ge||(ge={}));var yr=class{constructor(e,r,t,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=t,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},VE=(a,e)=>{if(Ps(e))return{success:!0,data:e.value};if(!a.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new tr(a.common.issues);return this._error=r,this._error}}};function qe(a){if(!a)return{};let{errorMap:e,invalid_type_error:r,required_error:t,description:s}=a;if(e&&(r||t))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(n,o)=>{let{message:l}=a;return n.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??t??o.defaultError}:n.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:s}}var Me=class{get description(){return this._def.description}_getType(e){return ua(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ua(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new It,ctx:{common:e.parent.common,data:e.data,parsedType:ua(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Qi(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let t=this.safeParse(e,r);if(t.success)return t.data;throw t.error}safeParse(e,r){let t={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ua(e)},s=this._parseSync({data:e,path:t.path,parent:t});return VE(t,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ua(e)};if(!this["~standard"].async)try{let t=this._parseSync({data:e,path:[],parent:r});return Ps(t)?{value:t.value}:{issues:r.common.issues}}catch(t){t?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(t=>Ps(t)?{value:t.value}:{issues:r.common.issues})}async parseAsync(e,r){let t=await this.safeParseAsync(e,r);if(t.success)return t.data;throw t.error}async safeParseAsync(e,r){let t={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ua(e)},s=this._parse({data:e,path:t.path,parent:t}),i=await(Qi(s)?s:Promise.resolve(s));return VE(t,i)}refine(e,r){let t=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,i)=>{let n=e(s),o=()=>i.addIssue({code:re.custom,...t(s)});return typeof Promise<"u"&&n instanceof Promise?n.then(l=>l?!0:(o(),!1)):n?!0:(o(),!1)})}refinement(e,r){return this._refinement((t,s)=>e(t)?!0:(s.addIssue(typeof r=="function"?r(t,s):r),!1))}_refinement(e){return new rr({schema:this,typeName:ke.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return gr.create(this,this._def)}nullable(){return Xr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return fa.create(this)}promise(){return Fa.create(this,this._def)}or(e){return Ns.create([this,e],this._def)}and(e){return js.create(this,e,this._def)}transform(e){return new rr({...qe(this._def),schema:this,typeName:ke.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new qs({...qe(this._def),innerType:this,defaultValue:r,typeName:ke.ZodDefault})}brand(){return new Yi({typeName:ke.ZodBranded,type:this,...qe(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Us({...qe(this._def),innerType:this,catchValue:r,typeName:ke.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ji.create(this,e)}readonly(){return Hs.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},zM=/^c[^\s-]{8,}$/i,VM=/^[0-9a-z]+$/,GM=/^[0-9A-HJKMNP-TV-Z]{26}$/i,WM=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ZM=/^[a-z0-9_-]{21}$/i,XM=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,KM=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,QM=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,YM="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",nf,JM=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,eL=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,tL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,rL=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,aL=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sL=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,_w="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",nL=new RegExp(`^${_w}$`);function Sw(a){let e="[0-5]\\d";a.precision?e=`${e}\\.\\d{${a.precision}}`:a.precision==null&&(e=`${e}(\\.\\d+)?`);let r=a.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function iL(a){return new RegExp(`^${Sw(a)}$`)}function Ew(a){let e=`${_w}T${Sw(a)}`,r=[];return r.push(a.local?"Z?":"Z"),a.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function oL(a,e){return!!((e==="v4"||!e)&&JM.test(a)||(e==="v6"||!e)&&tL.test(a))}function cL(a,e){if(!XM.test(a))return!1;try{let[r]=a.split(".");if(!r)return!1;let t=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(t));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function lL(a,e){return!!((e==="v4"||!e)&&eL.test(a)||(e==="v6"||!e)&&rL.test(a))}var Ma=class a extends Me{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==de.string){let i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:de.string,received:i.parsedType}),Oe}let t=new It,s;for(let i of this._def.checks)if(i.kind==="min")e.data.lengthi.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),t.dirty());else if(i.kind==="length"){let n=e.data.length>i.value,o=e.data.lengthe.test(s),{validation:r,code:re.invalid_string,...ge.errToObj(t)})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ge.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ge.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ge.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ge.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ge.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ge.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ge.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ge.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ge.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ge.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ge.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ge.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ge.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ge.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...ge.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ge.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...ge.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...ge.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...ge.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...ge.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...ge.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...ge.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...ge.errToObj(r)})}nonempty(e){return this.min(1,ge.errToObj(e))}trim(){return new a({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new a({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew Ma({checks:[],typeName:ke.ZodString,coerce:a?.coerce??!1,...qe(a)});function uL(a,e){let r=(a.toString().split(".")[1]||"").length,t=(e.toString().split(".")[1]||"").length,s=r>t?r:t,i=Number.parseInt(a.toFixed(s).replace(".","")),n=Number.parseInt(e.toFixed(s).replace(".",""));return i%n/10**s}var Os=class a extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==de.number){let i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:de.number,received:i.parsedType}),Oe}let t,s=new It;for(let i of this._def.checks)i.kind==="int"?Xe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),oe(t,{code:re.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),oe(t,{code:re.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?uL(e.data,i.value)!==0&&(t=this._getOrReturnCtx(e,t),oe(t,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),oe(t,{code:re.not_finite,message:i.message}),s.dirty()):Xe.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,ge.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ge.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ge.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ge.toString(r))}setLimit(e,r,t,s){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:t,message:ge.toString(s)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ge.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ge.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ge.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ge.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ge.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ge.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:ge.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ge.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ge.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuee.kind==="int"||e.kind==="multipleOf"&&Xe.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let t of this._def.checks){if(t.kind==="finite"||t.kind==="int"||t.kind==="multipleOf")return!0;t.kind==="min"?(r===null||t.value>r)&&(r=t.value):t.kind==="max"&&(e===null||t.valuenew Os({checks:[],typeName:ke.ZodNumber,coerce:a?.coerce||!1,...qe(a)});var Cs=class a extends Me{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==de.bigint)return this._getInvalidInput(e);let t,s=new It;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.datai.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),oe(t,{code:re.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),oe(t,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Xe.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:de.bigint,received:r.parsedType}),Oe}gte(e,r){return this.setLimit("min",e,!0,ge.toString(r))}gt(e,r){return this.setLimit("min",e,!1,ge.toString(r))}lte(e,r){return this.setLimit("max",e,!0,ge.toString(r))}lt(e,r){return this.setLimit("max",e,!1,ge.toString(r))}setLimit(e,r,t,s){return new a({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:t,message:ge.toString(s)}]})}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ge.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ge.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ge.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ge.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:ge.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew Cs({checks:[],typeName:ke.ZodBigInt,coerce:a?.coerce??!1,...qe(a)});var ks=class extends Me{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==de.boolean){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.boolean,received:t.parsedType}),Oe}return jt(e.data)}};ks.create=a=>new ks({typeName:ke.ZodBoolean,coerce:a?.coerce||!1,...qe(a)});var As=class a extends Me{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==de.date){let i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:de.date,received:i.parsedType}),Oe}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_date}),Oe}let t=new It,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()i.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):Xe.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new a({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:ge.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:ge.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.valuenew As({checks:[],coerce:a?.coerce||!1,typeName:ke.ZodDate,...qe(a)});var Bn=class extends Me{_parse(e){if(this._getType(e)!==de.symbol){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.symbol,received:t.parsedType}),Oe}return jt(e.data)}};Bn.create=a=>new Bn({typeName:ke.ZodSymbol,...qe(a)});var Is=class extends Me{_parse(e){if(this._getType(e)!==de.undefined){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.undefined,received:t.parsedType}),Oe}return jt(e.data)}};Is.create=a=>new Is({typeName:ke.ZodUndefined,...qe(a)});var Ds=class extends Me{_parse(e){if(this._getType(e)!==de.null){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.null,received:t.parsedType}),Oe}return jt(e.data)}};Ds.create=a=>new Ds({typeName:ke.ZodNull,...qe(a)});var La=class extends Me{constructor(){super(...arguments),this._any=!0}_parse(e){return jt(e.data)}};La.create=a=>new La({typeName:ke.ZodAny,...qe(a)});var da=class extends Me{constructor(){super(...arguments),this._unknown=!0}_parse(e){return jt(e.data)}};da.create=a=>new da({typeName:ke.ZodUnknown,...qe(a)});var Dr=class extends Me{_parse(e){let r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:de.never,received:r.parsedType}),Oe}};Dr.create=a=>new Dr({typeName:ke.ZodNever,...qe(a)});var zn=class extends Me{_parse(e){if(this._getType(e)!==de.undefined){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.void,received:t.parsedType}),Oe}return jt(e.data)}};zn.create=a=>new zn({typeName:ke.ZodVoid,...qe(a)});var fa=class a extends Me{_parse(e){let{ctx:r,status:t}=this._processInputParams(e),s=this._def;if(r.parsedType!==de.array)return oe(r,{code:re.invalid_type,expected:de.array,received:r.parsedType}),Oe;if(s.exactLength!==null){let n=r.data.length>s.exactLength.value,o=r.data.lengths.maxLength.value&&(oe(r,{code:re.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),t.dirty()),r.common.async)return Promise.all([...r.data].map((n,o)=>s.type._parseAsync(new yr(r,n,r.path,o)))).then(n=>It.mergeArray(t,n));let i=[...r.data].map((n,o)=>s.type._parseSync(new yr(r,n,r.path,o)));return It.mergeArray(t,i)}get element(){return this._def.type}min(e,r){return new a({...this._def,minLength:{value:e,message:ge.toString(r)}})}max(e,r){return new a({...this._def,maxLength:{value:e,message:ge.toString(r)}})}length(e,r){return new a({...this._def,exactLength:{value:e,message:ge.toString(r)}})}nonempty(e){return this.min(1,e)}};fa.create=(a,e)=>new fa({type:a,minLength:null,maxLength:null,exactLength:null,typeName:ke.ZodArray,...qe(e)});function qn(a){if(a instanceof Wt){let e={};for(let r in a.shape){let t=a.shape[r];e[r]=gr.create(qn(t))}return new Wt({...a._def,shape:()=>e})}else return a instanceof fa?new fa({...a._def,type:qn(a.element)}):a instanceof gr?gr.create(qn(a.unwrap())):a instanceof Xr?Xr.create(qn(a.unwrap())):a instanceof Zr?Zr.create(a.items.map(e=>qn(e))):a}var Wt=class a extends Me{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Xe.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==de.object){let c=this._getOrReturnCtx(e);return oe(c,{code:re.invalid_type,expected:de.object,received:c.parsedType}),Oe}let{status:t,ctx:s}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof Dr&&this._def.unknownKeys==="strip"))for(let c in s.data)n.includes(c)||o.push(c);let l=[];for(let c of n){let u=i[c],p=s.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new yr(s,p,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Dr){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of o)l.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(c==="strict")o.length>0&&(oe(s,{code:re.unrecognized_keys,keys:o}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of o){let p=s.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new yr(s,p,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let p=await u.key,m=await u.value;c.push({key:p,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>It.mergeObjectSync(t,c)):It.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return ge.errToObj,new a({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,t)=>{let s=this._def.errorMap?.(r,t).message??t.defaultError;return r.code==="unrecognized_keys"?{message:ge.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new a({...this._def,unknownKeys:"strip"})}passthrough(){return new a({...this._def,unknownKeys:"passthrough"})}extend(e){return new a({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new a({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ke.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new a({...this._def,catchall:e})}pick(e){let r={};for(let t of Xe.objectKeys(e))e[t]&&this.shape[t]&&(r[t]=this.shape[t]);return new a({...this._def,shape:()=>r})}omit(e){let r={};for(let t of Xe.objectKeys(this.shape))e[t]||(r[t]=this.shape[t]);return new a({...this._def,shape:()=>r})}deepPartial(){return qn(this)}partial(e){let r={};for(let t of Xe.objectKeys(this.shape)){let s=this.shape[t];e&&!e[t]?r[t]=s:r[t]=s.optional()}return new a({...this._def,shape:()=>r})}required(e){let r={};for(let t of Xe.objectKeys(this.shape))if(e&&!e[t])r[t]=this.shape[t];else{let i=this.shape[t];for(;i instanceof gr;)i=i._def.innerType;r[t]=i}return new a({...this._def,shape:()=>r})}keyof(){return ww(Xe.objectKeys(this.shape))}};Wt.create=(a,e)=>new Wt({shape:()=>a,unknownKeys:"strip",catchall:Dr.create(),typeName:ke.ZodObject,...qe(e)});Wt.strictCreate=(a,e)=>new Wt({shape:()=>a,unknownKeys:"strict",catchall:Dr.create(),typeName:ke.ZodObject,...qe(e)});Wt.lazycreate=(a,e)=>new Wt({shape:a,unknownKeys:"strip",catchall:Dr.create(),typeName:ke.ZodObject,...qe(e)});var Ns=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;let n=i.map(o=>new tr(o.ctx.common.issues));return oe(r,{code:re.invalid_union,unionErrors:n}),Oe}if(r.common.async)return Promise.all(t.map(async i=>{let n={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:n}),ctx:n}})).then(s);{let i,n=[];for(let l of t){let c={...r,common:{...r.common,issues:[]},parent:null},u=l._parseSync({data:r.data,path:r.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:c}),c.common.issues.length&&n.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let o=n.map(l=>new tr(l));return oe(r,{code:re.invalid_union,unionErrors:o}),Oe}}get options(){return this._def.options}};Ns.create=(a,e)=>new Ns({options:a,typeName:ke.ZodUnion,...qe(e)});var la=a=>a instanceof $s?la(a.schema):a instanceof rr?la(a.innerType()):a instanceof Ms?[a.value]:a instanceof Ls?a.options:a instanceof Fs?Xe.objectValues(a.enum):a instanceof qs?la(a._def.innerType):a instanceof Is?[void 0]:a instanceof Ds?[null]:a instanceof gr?[void 0,...la(a.unwrap())]:a instanceof Xr?[null,...la(a.unwrap())]:a instanceof Yi||a instanceof Hs?la(a.unwrap()):a instanceof Us?la(a._def.innerType):[],gl=class a extends Me{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==de.object)return oe(r,{code:re.invalid_type,expected:de.object,received:r.parsedType}),Oe;let t=this.discriminator,s=r.data[t],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(oe(r,{code:re.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[t]}),Oe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,t){let s=new Map;for(let i of r){let n=la(i.shape[e]);if(!n.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of n){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,i)}}return new a({typeName:ke.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...qe(t)})}};function gf(a,e){let r=ua(a),t=ua(e);if(a===e)return{valid:!0,data:a};if(r===de.object&&t===de.object){let s=Xe.objectKeys(e),i=Xe.objectKeys(a).filter(o=>s.indexOf(o)!==-1),n={...a,...e};for(let o of i){let l=gf(a[o],e[o]);if(!l.valid)return{valid:!1};n[o]=l.data}return{valid:!0,data:n}}else if(r===de.array&&t===de.array){if(a.length!==e.length)return{valid:!1};let s=[];for(let i=0;i{if(hf(i)||hf(n))return Oe;let o=gf(i.value,n.value);return o.valid?((vf(i)||vf(n))&&r.dirty(),{status:r.value,value:o.data}):(oe(t,{code:re.invalid_intersection_types}),Oe)};return t.common.async?Promise.all([this._def.left._parseAsync({data:t.data,path:t.path,parent:t}),this._def.right._parseAsync({data:t.data,path:t.path,parent:t})]).then(([i,n])=>s(i,n)):s(this._def.left._parseSync({data:t.data,path:t.path,parent:t}),this._def.right._parseSync({data:t.data,path:t.path,parent:t}))}};js.create=(a,e,r)=>new js({left:a,right:e,typeName:ke.ZodIntersection,...qe(r)});var Zr=class a extends Me{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==de.array)return oe(t,{code:re.invalid_type,expected:de.array,received:t.parsedType}),Oe;if(t.data.lengththis._def.items.length&&(oe(t,{code:re.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...t.data].map((n,o)=>{let l=this._def.items[o]||this._def.rest;return l?l._parse(new yr(t,n,t.path,o)):null}).filter(n=>!!n);return t.common.async?Promise.all(i).then(n=>It.mergeArray(r,n)):It.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new a({...this._def,rest:e})}};Zr.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Zr({items:a,typeName:ke.ZodTuple,rest:null,...qe(e)})};var yl=class a extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==de.object)return oe(t,{code:re.invalid_type,expected:de.object,received:t.parsedType}),Oe;let s=[],i=this._def.keyType,n=this._def.valueType;for(let o in t.data)s.push({key:i._parse(new yr(t,o,t.path,o)),value:n._parse(new yr(t,t.data[o],t.path,o)),alwaysSet:o in t.data});return t.common.async?It.mergeObjectAsync(r,s):It.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,t){return r instanceof Me?new a({keyType:e,valueType:r,typeName:ke.ZodRecord,...qe(t)}):new a({keyType:Ma.create(),valueType:e,typeName:ke.ZodRecord,...qe(r)})}},Vn=class extends Me{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==de.map)return oe(t,{code:re.invalid_type,expected:de.map,received:t.parsedType}),Oe;let s=this._def.keyType,i=this._def.valueType,n=[...t.data.entries()].map(([o,l],c)=>({key:s._parse(new yr(t,o,t.path,[c,"key"])),value:i._parse(new yr(t,l,t.path,[c,"value"]))}));if(t.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let l of n){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Oe;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(c.value,u.value)}return{status:r.value,value:o}})}else{let o=new Map;for(let l of n){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Oe;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),o.set(c.value,u.value)}return{status:r.value,value:o}}}};Vn.create=(a,e,r)=>new Vn({valueType:e,keyType:a,typeName:ke.ZodMap,...qe(r)});var Gn=class a extends Me{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.parsedType!==de.set)return oe(t,{code:re.invalid_type,expected:de.set,received:t.parsedType}),Oe;let s=this._def;s.minSize!==null&&t.data.sizes.maxSize.value&&(oe(t,{code:re.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function n(l){let c=new Set;for(let u of l){if(u.status==="aborted")return Oe;u.status==="dirty"&&r.dirty(),c.add(u.value)}return{status:r.value,value:c}}let o=[...t.data.values()].map((l,c)=>i._parse(new yr(t,l,t.path,c)));return t.common.async?Promise.all(o).then(l=>n(l)):n(o)}min(e,r){return new a({...this._def,minSize:{value:e,message:ge.toString(r)}})}max(e,r){return new a({...this._def,maxSize:{value:e,message:ge.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Gn.create=(a,e)=>new Gn({valueType:a,minSize:null,maxSize:null,typeName:ke.ZodSet,...qe(e)});var bl=class a extends Me{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==de.function)return oe(r,{code:re.invalid_type,expected:de.function,received:r.parsedType}),Oe;function t(o,l){return vl({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,hl(),Hn].filter(c=>!!c),issueData:{code:re.invalid_arguments,argumentsError:l}})}function s(o,l){return vl({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,hl(),Hn].filter(c=>!!c),issueData:{code:re.invalid_return_type,returnTypeError:l}})}let i={errorMap:r.common.contextualErrorMap},n=r.data;if(this._def.returns instanceof Fa){let o=this;return jt(async function(...l){let c=new tr([]),u=await o._def.args.parseAsync(l,i).catch(d=>{throw c.addIssue(t(l,d)),c}),p=await Reflect.apply(n,this,u);return await o._def.returns._def.type.parseAsync(p,i).catch(d=>{throw c.addIssue(s(p,d)),c})})}else{let o=this;return jt(function(...l){let c=o._def.args.safeParse(l,i);if(!c.success)throw new tr([t(l,c.error)]);let u=Reflect.apply(n,this,c.data),p=o._def.returns.safeParse(u,i);if(!p.success)throw new tr([s(u,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new a({...this._def,args:Zr.create(e).rest(da.create())})}returns(e){return new a({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,t){return new a({args:e||Zr.create([]).rest(da.create()),returns:r||da.create(),typeName:ke.ZodFunction,...qe(t)})}},$s=class extends Me{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};$s.create=(a,e)=>new $s({getter:a,typeName:ke.ZodLazy,...qe(e)});var Ms=class extends Me{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return oe(r,{received:r.data,code:re.invalid_literal,expected:this._def.value}),Oe}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ms.create=(a,e)=>new Ms({value:a,typeName:ke.ZodLiteral,...qe(e)});function ww(a,e){return new Ls({values:a,typeName:ke.ZodEnum,...qe(e)})}var Ls=class a extends Me{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),t=this._def.values;return oe(r,{expected:Xe.joinValues(t),received:r.parsedType,code:re.invalid_type}),Oe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),t=this._def.values;return oe(r,{received:r.data,code:re.invalid_enum_value,options:t}),Oe}return jt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return a.create(e,{...this._def,...r})}exclude(e,r=this._def){return a.create(this.options.filter(t=>!e.includes(t)),{...this._def,...r})}};Ls.create=ww;var Fs=class extends Me{_parse(e){let r=Xe.getValidEnumValues(this._def.values),t=this._getOrReturnCtx(e);if(t.parsedType!==de.string&&t.parsedType!==de.number){let s=Xe.objectValues(r);return oe(t,{expected:Xe.joinValues(s),received:t.parsedType,code:re.invalid_type}),Oe}if(this._cache||(this._cache=new Set(Xe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=Xe.objectValues(r);return oe(t,{received:t.data,code:re.invalid_enum_value,options:s}),Oe}return jt(e.data)}get enum(){return this._def.values}};Fs.create=(a,e)=>new Fs({values:a,typeName:ke.ZodNativeEnum,...qe(e)});var Fa=class extends Me{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==de.promise&&r.common.async===!1)return oe(r,{code:re.invalid_type,expected:de.promise,received:r.parsedType}),Oe;let t=r.parsedType===de.promise?r.data:Promise.resolve(r.data);return jt(t.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Fa.create=(a,e)=>new Fa({type:a,typeName:ke.ZodPromise,...qe(e)});var rr=class extends Me{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ke.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:t}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:n=>{oe(t,n),n.fatal?r.abort():r.dirty()},get path(){return t.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let n=s.transform(t.data,i);if(t.common.async)return Promise.resolve(n).then(async o=>{if(r.value==="aborted")return Oe;let l=await this._def.schema._parseAsync({data:o,path:t.path,parent:t});return l.status==="aborted"?Oe:l.status==="dirty"||r.value==="dirty"?Un(l.value):l});{if(r.value==="aborted")return Oe;let o=this._def.schema._parseSync({data:n,path:t.path,parent:t});return o.status==="aborted"?Oe:o.status==="dirty"||r.value==="dirty"?Un(o.value):o}}if(s.type==="refinement"){let n=o=>{let l=s.refinement(o,i);if(t.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(t.common.async===!1){let o=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});return o.status==="aborted"?Oe:(o.status==="dirty"&&r.dirty(),n(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(o=>o.status==="aborted"?Oe:(o.status==="dirty"&&r.dirty(),n(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(t.common.async===!1){let n=this._def.schema._parseSync({data:t.data,path:t.path,parent:t});if(!Ps(n))return Oe;let o=s.transform(n.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:t.data,path:t.path,parent:t}).then(n=>Ps(n)?Promise.resolve(s.transform(n.value,i)).then(o=>({status:r.value,value:o})):Oe);Xe.assertNever(s)}};rr.create=(a,e,r)=>new rr({schema:a,typeName:ke.ZodEffects,effect:e,...qe(r)});rr.createWithPreprocess=(a,e,r)=>new rr({schema:e,effect:{type:"preprocess",transform:a},typeName:ke.ZodEffects,...qe(r)});var gr=class extends Me{_parse(e){return this._getType(e)===de.undefined?jt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};gr.create=(a,e)=>new gr({innerType:a,typeName:ke.ZodOptional,...qe(e)});var Xr=class extends Me{_parse(e){return this._getType(e)===de.null?jt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Xr.create=(a,e)=>new Xr({innerType:a,typeName:ke.ZodNullable,...qe(e)});var qs=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t=r.data;return r.parsedType===de.undefined&&(t=this._def.defaultValue()),this._def.innerType._parse({data:t,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};qs.create=(a,e)=>new qs({innerType:a,typeName:ke.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...qe(e)});var Us=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:t.data,path:t.path,parent:{...t}});return Qi(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new tr(t.common.issues)},input:t.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new tr(t.common.issues)},input:t.data})}}removeCatch(){return this._def.innerType}};Us.create=(a,e)=>new Us({innerType:a,typeName:ke.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...qe(e)});var Wn=class extends Me{_parse(e){if(this._getType(e)!==de.nan){let t=this._getOrReturnCtx(e);return oe(t,{code:re.invalid_type,expected:de.nan,received:t.parsedType}),Oe}return{status:"valid",value:e.data}}};Wn.create=a=>new Wn({typeName:ke.ZodNaN,...qe(a)});var pL=Symbol("zod_brand"),Yi=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t=r.data;return this._def.type._parse({data:t,path:r.path,parent:r})}unwrap(){return this._def.type}},Ji=class a extends Me{_parse(e){let{status:r,ctx:t}=this._processInputParams(e);if(t.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:t.data,path:t.path,parent:t});return i.status==="aborted"?Oe:i.status==="dirty"?(r.dirty(),Un(i.value)):this._def.out._parseAsync({data:i.value,path:t.path,parent:t})})();{let s=this._def.in._parseSync({data:t.data,path:t.path,parent:t});return s.status==="aborted"?Oe:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:t.path,parent:t})}}static create(e,r){return new a({in:e,out:r,typeName:ke.ZodPipeline})}},Hs=class extends Me{_parse(e){let r=this._def.innerType._parse(e),t=s=>(Ps(s)&&(s.value=Object.freeze(s.value)),s);return Qi(r)?r.then(s=>t(s)):t(r)}unwrap(){return this._def.innerType}};Hs.create=(a,e)=>new Hs({innerType:a,typeName:ke.ZodReadonly,...qe(e)});function GE(a,e){let r=typeof a=="function"?a(e):typeof a=="string"?{message:a}:a;return typeof r=="string"?{message:r}:r}function Tw(a,e={},r){return a?La.create().superRefine((t,s)=>{let i=a(t);if(i instanceof Promise)return i.then(n=>{if(!n){let o=GE(e,t),l=o.fatal??r??!0;s.addIssue({code:"custom",...o,fatal:l})}});if(!i){let n=GE(e,t),o=n.fatal??r??!0;s.addIssue({code:"custom",...n,fatal:o})}}):La.create()}var dL={object:Wt.lazycreate},ke;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(ke||(ke={}));var fL=(a,e={message:`Input not instance of ${a.name}`})=>Tw(r=>r instanceof a,e),Rw=Ma.create,Pw=Os.create,mL=Wn.create,hL=Cs.create,Ow=ks.create,vL=As.create,gL=Bn.create,yL=Is.create,bL=Ds.create,xL=La.create,_L=da.create,SL=Dr.create,EL=zn.create,wL=fa.create,TL=Wt.create,RL=Wt.strictCreate,PL=Ns.create,OL=gl.create,CL=js.create,kL=Zr.create,AL=yl.create,IL=Vn.create,DL=Gn.create,NL=bl.create,jL=$s.create,$L=Ms.create,ML=Ls.create,LL=Fs.create,FL=Fa.create,WE=rr.create,qL=gr.create,UL=Xr.create,HL=rr.createWithPreprocess,BL=Ji.create,zL=()=>Rw().optional(),VL=()=>Pw().optional(),GL=()=>Ow().optional(),WL={string:a=>Ma.create({...a,coerce:!0}),number:a=>Os.create({...a,coerce:!0}),boolean:a=>ks.create({...a,coerce:!0}),bigint:a=>Cs.create({...a,coerce:!0}),date:a=>As.create({...a,coerce:!0})},ZL=Oe;var El="2.0",Cw=E.union([E.string(),E.number().int()]),kw=E.string(),XL=E.object({progressToken:E.optional(Cw)}).passthrough(),br=E.object({_meta:E.optional(XL)}).passthrough(),Zt=E.object({method:E.string(),params:E.optional(br)}),to=E.object({_meta:E.optional(E.object({}).passthrough())}).passthrough(),Kr=E.object({method:E.string(),params:E.optional(to)}),xr=E.object({_meta:E.optional(E.object({}).passthrough())}).passthrough(),wl=E.union([E.string(),E.number().int()]),KL=E.object({jsonrpc:E.literal(El),id:wl}).merge(Zt).strict();var QL=E.object({jsonrpc:E.literal(El)}).merge(Kr).strict();var YL=E.object({jsonrpc:E.literal(El),id:wl,result:xr}).strict();var ZE;(function(a){a[a.ConnectionClosed=-32e3]="ConnectionClosed",a[a.RequestTimeout=-32001]="RequestTimeout",a[a.ParseError=-32700]="ParseError",a[a.InvalidRequest=-32600]="InvalidRequest",a[a.MethodNotFound=-32601]="MethodNotFound",a[a.InvalidParams=-32602]="InvalidParams",a[a.InternalError=-32603]="InternalError"})(ZE||(ZE={}));var JL=E.object({jsonrpc:E.literal(El),id:wl,error:E.object({code:E.number().int(),message:E.string(),data:E.optional(E.unknown())})}).strict();var aB=E.union([KL,QL,YL,JL]),Aw=xr.strict(),Iw=Kr.extend({method:E.literal("notifications/cancelled"),params:to.extend({requestId:wl,reason:E.string().optional()})}),ro=E.object({name:E.string(),title:E.optional(E.string())}).passthrough(),Dw=ro.extend({version:E.string()}),e6=E.object({experimental:E.optional(E.object({}).passthrough()),sampling:E.optional(E.object({}).passthrough()),elicitation:E.optional(E.object({}).passthrough()),roots:E.optional(E.object({listChanged:E.optional(E.boolean())}).passthrough())}).passthrough(),t6=Zt.extend({method:E.literal("initialize"),params:br.extend({protocolVersion:E.string(),capabilities:e6,clientInfo:Dw})}),r6=E.object({experimental:E.optional(E.object({}).passthrough()),logging:E.optional(E.object({}).passthrough()),completions:E.optional(E.object({}).passthrough()),prompts:E.optional(E.object({listChanged:E.optional(E.boolean())}).passthrough()),resources:E.optional(E.object({subscribe:E.optional(E.boolean()),listChanged:E.optional(E.boolean())}).passthrough()),tools:E.optional(E.object({listChanged:E.optional(E.boolean())}).passthrough())}).passthrough(),a6=xr.extend({protocolVersion:E.string(),capabilities:r6,serverInfo:Dw,instructions:E.optional(E.string())}),s6=Kr.extend({method:E.literal("notifications/initialized")}),Nw=Zt.extend({method:E.literal("ping")}),n6=E.object({progress:E.number(),total:E.optional(E.number()),message:E.optional(E.string())}).passthrough(),jw=Kr.extend({method:E.literal("notifications/progress"),params:to.merge(n6).extend({progressToken:Cw})}),Tl=Zt.extend({params:br.extend({cursor:E.optional(kw)}).optional()}),Rl=xr.extend({nextCursor:E.optional(kw)}),$w=E.object({uri:E.string(),mimeType:E.optional(E.string()),_meta:E.optional(E.object({}).passthrough())}).passthrough(),Mw=$w.extend({text:E.string()}),wf=E.string().refine(a=>{try{return atob(a),!0}catch{return!1}},{message:"Invalid Base64 string"}),Lw=$w.extend({blob:wf}),Fw=ro.extend({uri:E.string(),description:E.optional(E.string()),mimeType:E.optional(E.string()),_meta:E.optional(E.object({}).passthrough())}),i6=ro.extend({uriTemplate:E.string(),description:E.optional(E.string()),mimeType:E.optional(E.string()),_meta:E.optional(E.object({}).passthrough())}),o6=Tl.extend({method:E.literal("resources/list")}),c6=Rl.extend({resources:E.array(Fw)}),l6=Tl.extend({method:E.literal("resources/templates/list")}),u6=Rl.extend({resourceTemplates:E.array(i6)}),p6=Zt.extend({method:E.literal("resources/read"),params:br.extend({uri:E.string()})}),d6=xr.extend({contents:E.array(E.union([Mw,Lw]))}),f6=Kr.extend({method:E.literal("notifications/resources/list_changed")}),m6=Zt.extend({method:E.literal("resources/subscribe"),params:br.extend({uri:E.string()})}),h6=Zt.extend({method:E.literal("resources/unsubscribe"),params:br.extend({uri:E.string()})}),v6=Kr.extend({method:E.literal("notifications/resources/updated"),params:to.extend({uri:E.string()})}),g6=E.object({name:E.string(),description:E.optional(E.string()),required:E.optional(E.boolean())}).passthrough(),y6=ro.extend({description:E.optional(E.string()),arguments:E.optional(E.array(g6)),_meta:E.optional(E.object({}).passthrough())}),b6=Tl.extend({method:E.literal("prompts/list")}),x6=Rl.extend({prompts:E.array(y6)}),_6=Zt.extend({method:E.literal("prompts/get"),params:br.extend({name:E.string(),arguments:E.optional(E.record(E.string()))})}),Tf=E.object({type:E.literal("text"),text:E.string(),_meta:E.optional(E.object({}).passthrough())}).passthrough(),Rf=E.object({type:E.literal("image"),data:wf,mimeType:E.string(),_meta:E.optional(E.object({}).passthrough())}).passthrough(),Pf=E.object({type:E.literal("audio"),data:wf,mimeType:E.string(),_meta:E.optional(E.object({}).passthrough())}).passthrough(),S6=E.object({type:E.literal("resource"),resource:E.union([Mw,Lw]),_meta:E.optional(E.object({}).passthrough())}).passthrough(),E6=Fw.extend({type:E.literal("resource_link")}),qw=E.union([Tf,Rf,Pf,E6,S6]),w6=E.object({role:E.enum(["user","assistant"]),content:qw}).passthrough(),T6=xr.extend({description:E.optional(E.string()),messages:E.array(w6)}),R6=Kr.extend({method:E.literal("notifications/prompts/list_changed")}),P6=E.object({title:E.optional(E.string()),readOnlyHint:E.optional(E.boolean()),destructiveHint:E.optional(E.boolean()),idempotentHint:E.optional(E.boolean()),openWorldHint:E.optional(E.boolean())}).passthrough(),O6=ro.extend({description:E.optional(E.string()),inputSchema:E.object({type:E.literal("object"),properties:E.optional(E.object({}).passthrough()),required:E.optional(E.array(E.string()))}).passthrough(),outputSchema:E.optional(E.object({type:E.literal("object"),properties:E.optional(E.object({}).passthrough()),required:E.optional(E.array(E.string()))}).passthrough()),annotations:E.optional(P6),_meta:E.optional(E.object({}).passthrough())}),C6=Tl.extend({method:E.literal("tools/list")}),k6=Rl.extend({tools:E.array(O6)}),Uw=xr.extend({content:E.array(qw).default([]),structuredContent:E.object({}).passthrough().optional(),isError:E.optional(E.boolean())}),sB=Uw.or(xr.extend({toolResult:E.unknown()})),A6=Zt.extend({method:E.literal("tools/call"),params:br.extend({name:E.string(),arguments:E.optional(E.record(E.unknown()))})}),I6=Kr.extend({method:E.literal("notifications/tools/list_changed")}),Hw=E.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),D6=Zt.extend({method:E.literal("logging/setLevel"),params:br.extend({level:Hw})}),N6=Kr.extend({method:E.literal("notifications/message"),params:to.extend({level:Hw,logger:E.optional(E.string()),data:E.unknown()})}),j6=E.object({name:E.string().optional()}).passthrough(),$6=E.object({hints:E.optional(E.array(j6)),costPriority:E.optional(E.number().min(0).max(1)),speedPriority:E.optional(E.number().min(0).max(1)),intelligencePriority:E.optional(E.number().min(0).max(1))}).passthrough(),M6=E.object({role:E.enum(["user","assistant"]),content:E.union([Tf,Rf,Pf])}).passthrough(),L6=Zt.extend({method:E.literal("sampling/createMessage"),params:br.extend({messages:E.array(M6),systemPrompt:E.optional(E.string()),includeContext:E.optional(E.enum(["none","thisServer","allServers"])),temperature:E.optional(E.number()),maxTokens:E.number().int(),stopSequences:E.optional(E.array(E.string())),metadata:E.optional(E.object({}).passthrough()),modelPreferences:E.optional($6)})}),F6=xr.extend({model:E.string(),stopReason:E.optional(E.enum(["endTurn","stopSequence","maxTokens"]).or(E.string())),role:E.enum(["user","assistant"]),content:E.discriminatedUnion("type",[Tf,Rf,Pf])}),q6=E.object({type:E.literal("boolean"),title:E.optional(E.string()),description:E.optional(E.string()),default:E.optional(E.boolean())}).passthrough(),U6=E.object({type:E.literal("string"),title:E.optional(E.string()),description:E.optional(E.string()),minLength:E.optional(E.number()),maxLength:E.optional(E.number()),format:E.optional(E.enum(["email","uri","date","date-time"]))}).passthrough(),H6=E.object({type:E.enum(["number","integer"]),title:E.optional(E.string()),description:E.optional(E.string()),minimum:E.optional(E.number()),maximum:E.optional(E.number())}).passthrough(),B6=E.object({type:E.literal("string"),title:E.optional(E.string()),description:E.optional(E.string()),enum:E.array(E.string()),enumNames:E.optional(E.array(E.string()))}).passthrough(),z6=E.union([q6,U6,H6,B6]),V6=Zt.extend({method:E.literal("elicitation/create"),params:br.extend({message:E.string(),requestedSchema:E.object({type:E.literal("object"),properties:E.record(E.string(),z6),required:E.optional(E.array(E.string()))}).passthrough()})}),G6=xr.extend({action:E.enum(["accept","decline","cancel"]),content:E.optional(E.record(E.string(),E.unknown()))}),W6=E.object({type:E.literal("ref/resource"),uri:E.string()}).passthrough(),Z6=E.object({type:E.literal("ref/prompt"),name:E.string()}).passthrough(),X6=Zt.extend({method:E.literal("completion/complete"),params:br.extend({ref:E.union([Z6,W6]),argument:E.object({name:E.string(),value:E.string()}).passthrough(),context:E.optional(E.object({arguments:E.optional(E.record(E.string(),E.string()))}))})}),K6=xr.extend({completion:E.object({values:E.array(E.string()).max(100),total:E.optional(E.number().int()),hasMore:E.optional(E.boolean())}).passthrough()}),Q6=E.object({uri:E.string().startsWith("file://"),name:E.optional(E.string()),_meta:E.optional(E.object({}).passthrough())}).passthrough(),Y6=Zt.extend({method:E.literal("roots/list")}),J6=xr.extend({roots:E.array(Q6)}),e5=Kr.extend({method:E.literal("notifications/roots/list_changed")}),nB=E.union([Nw,t6,X6,D6,_6,b6,o6,l6,p6,m6,h6,A6,C6]),iB=E.union([Iw,jw,s6,e5]),oB=E.union([Aw,F6,G6,J6]),cB=E.union([Nw,L6,V6,Y6]),lB=E.union([Iw,jw,N6,v6,f6,I6,R6]),uB=E.union([Aw,a6,K6,T6,x6,c6,u6,d6,Uw,k6]);var pB=X$(k8(),1);var dB=Symbol("Let zodToJsonSchema decide on which parser to use");var fB=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var yf;(function(a){a.Completable="McpCompletable"})(yf||(yf={}));var xl=class extends Me{_parse(e){let{ctx:r}=this._processInputParams(e),t=r.data;return this._def.type._parse({data:t,path:r.path,parent:r})}unwrap(){return this._def.type}};xl.create=(a,e)=>new xl({type:a,typeName:yf.Completable,complete:e.complete,...t5(e)});function t5(a){if(!a)return{};let{errorMap:e,invalid_type_error:r,required_error:t,description:s}=a;if(e&&(r||t))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(n,o)=>{var l,c;let{message:u}=a;return n.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:(l=u??t)!==null&&l!==void 0?l:o.defaultError}:n.code!=="invalid_type"?{message:o.defaultError}:{message:(c=u??r)!==null&&c!==void 0?c:o.defaultError}},description:s}}function Bw({prompt:a,options:e}){let{systemPrompt:r,settingSources:t,sandbox:s,...i}=e??{},n,o;r===void 0?n="":typeof r=="string"?n=r:r.type==="preset"&&(o=r.append);let l=i.pathToClaudeCodeExecutable;if(!l){let Te=(0,JE.fileURLToPath)(r5.url),ce=(0,cf.join)(Te,"..");l=(0,cf.join)(ce,"cli.js")}process.env.CLAUDE_AGENT_SDK_VERSION="0.1.67";let{abortController:c=tw(),additionalDirectories:u=[],agents:p,allowedTools:m=[],betas:d,canUseTool:v,continue:h,cwd:f,disallowedTools:y=[],tools:g,env:b,executable:w=gw()?"bun":"node",executableArgs:P=[],extraArgs:T={},fallbackModel:k,enableFileCheckpointing:N,forkSession:A,hooks:$,includePartialMessages:D,persistSession:C,maxThinkingTokens:O,maxTurns:j,maxBudgetUsd:q,mcpServers:z,model:V,outputFormat:K,permissionMode:Z="default",allowDangerouslySkipPermissions:X=!1,permissionPromptToolName:se,plugins:Y,resume:Pe,resumeSessionAt:fe,stderr:Ee,strictMcpConfig:we}=i,De=K?.type==="json_schema"?K.schema:void 0,H=b;if(H||(H={...process.env}),H.CLAUDE_CODE_ENTRYPOINT||(H.CLAUDE_CODE_ENTRYPOINT="sdk-ts"),N&&(H.CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING="true"),!l)throw new Error("pathToClaudeCodeExecutable is required");let G={},te=new Map;if(z)for(let[Te,ce]of Object.entries(z))ce.type==="sdk"&&"instance"in ce?(te.set(Te,ce.instance),G[Te]={type:"sdk",name:Te}):G[Te]=ce;let le=typeof a=="string",W=new uf({abortController:c,additionalDirectories:u,betas:d,cwd:f,executable:w,executableArgs:P,extraArgs:T,pathToClaudeCodeExecutable:l,env:H,forkSession:A,stderr:Ee,maxThinkingTokens:O,maxTurns:j,maxBudgetUsd:q,model:V,fallbackModel:k,jsonSchema:De,permissionMode:Z,allowDangerouslySkipPermissions:X,permissionPromptToolName:se,continueConversation:h,resume:Pe,resumeSessionAt:fe,settingSources:t??[],allowedTools:m,disallowedTools:y,tools:g,mcpServers:G,strictMcpConfig:we,canUseTool:!!v,hooks:!!$,includePartialMessages:D,persistSession:C,plugins:Y,sandbox:s,spawnClaudeCodeProcess:i.spawnClaudeCodeProcess}),Q={systemPrompt:n,appendSystemPrompt:o,agents:p},ne=new ff(W,le,v,$,c,te,De,Q);return typeof a=="string"?(W.write(JSON.stringify({type:"user",session_id:"",message:{role:"user",content:[{type:"text",text:a}]},parent_tool_use_id:null})+` `),ne.handleSingleTurnInputComplete()):ne.streamInput(a),ne}var Pl=class{dbManager;sessionManager;constructor(e,r){this.dbManager=e,this.sessionManager=r}async startSession(e,r){try{let t=this.findClaudeExecutable(),s=this.getModelId(),i=["Bash","Read","Write","Edit","Grep","Glob","WebFetch","WebSearch","Task","NotebookEdit","AskUserQuestion","TodoWrite"],n=this.createMessageGenerator(e),o=Bw({prompt:n,options:{model:s,disallowedTools:i,abortController:e.abortController,pathToClaudeCodeExecutable:t}});for await(let c of o){if(c.type==="assistant"){let u=c.message.content,p=Array.isArray(u)?u.filter(f=>f.type==="text").map(f=>f.text).join(` `):typeof u=="string"?u:"",m=p.length,d=e.cumulativeInputTokens+e.cumulativeOutputTokens,v=c.message.usage;v&&(e.cumulativeInputTokens+=v.input_tokens||0,e.cumulativeOutputTokens+=v.output_tokens||0,v.cache_creation_input_tokens&&(e.cumulativeInputTokens+=v.cache_creation_input_tokens),M.debug("SDK","Token usage captured",{sessionId:e.sessionDbId,inputTokens:v.input_tokens,outputTokens:v.output_tokens,cacheCreation:v.cache_creation_input_tokens||0,cacheRead:v.cache_read_input_tokens||0,cumulativeInput:e.cumulativeInputTokens,cumulativeOutput:e.cumulativeOutputTokens}));let h=e.cumulativeInputTokens+e.cumulativeOutputTokens-d;if(m>0){let f=m>100?p.substring(0,100)+"...":p;M.dataOut("SDK",`Response received (${m} chars)`,{sessionId:e.sessionDbId,promptNumber:e.lastPromptNumber},f),await this.processSDKResponse(e,p,r,h)}}c.type==="result"&&c.subtype}let l=Date.now()-e.startTime;M.success("SDK","Agent completed",{sessionId:e.sessionDbId,duration:`${(l/1e3).toFixed(1)}s`}),this.dbManager.getSessionStore().markSessionCompleted(e.sessionDbId)}catch(t){throw t.name==="AbortError"?M.warn("SDK","Agent aborted",{sessionId:e.sessionDbId}):M.failure("SDK","Agent error",{sessionDbId:e.sessionDbId},t),t}finally{this.sessionManager.deleteSession(e.sessionDbId).catch(()=>{})}}async*createMessageGenerator(e){yield{type:"user",message:{role:"user",content:e.lastPromptNumber===1?kE(e.project,e.claudeSessionId,e.userPrompt):DE(e.userPrompt,e.lastPromptNumber,e.claudeSessionId)},session_id:e.claudeSessionId,parent_tool_use_id:null,isSynthetic:!0};for await(let r of this.sessionManager.getMessageIterator(e.sessionDbId))r.type==="observation"?(r.prompt_number!==void 0&&(e.lastPromptNumber=r.prompt_number),yield{type:"user",message:{role:"user",content:AE({id:0,tool_name:r.tool_name,tool_input:JSON.stringify(r.tool_input),tool_output:JSON.stringify(r.tool_response),created_at_epoch:Date.now(),cwd:r.cwd})},session_id:e.claudeSessionId,parent_tool_use_id:null,isSynthetic:!0}):r.type==="summarize"&&(yield{type:"user",message:{role:"user",content:IE({id:e.sessionDbId,sdk_session_id:e.sdkSessionId,project:e.project,user_prompt:e.userPrompt,last_user_message:ft("Missing last_user_message for summary in SDKAgent",{sessionDbId:e.sessionDbId,sdkSessionId:e.sdkSessionId},r.last_user_message||""),last_assistant_message:ft("Missing last_assistant_message for summary in SDKAgent",{sessionDbId:e.sessionDbId,sdkSessionId:e.sdkSessionId},r.last_assistant_message||"")})},session_id:e.claudeSessionId,parent_tool_use_id:null,isSynthetic:!0})}async processSDKResponse(e,r,t,s){let i=OE(r,e.claudeSessionId);for(let o of i){let{id:l,createdAtEpoch:c}=this.dbManager.getSessionStore().storeObservation(e.claudeSessionId,e.project,o,e.lastPromptNumber,s);M.info("SDK","Observation saved",{sessionId:e.sessionDbId,obsId:l,type:o.type,title:o.title||ft("obs.title is null",{obsId:l,type:o.type},"(untitled)"),filesRead:o.files_read?.length??(ft("obs.files_read is null/undefined",{obsId:l}),0),filesModified:o.files_modified?.length??(ft("obs.files_modified is null/undefined",{obsId:l}),0),concepts:o.concepts?.length??(ft("obs.concepts is null/undefined",{obsId:l}),0)});let u=Date.now(),p=o.type,m=o.title||ft("obs.title is null for Chroma sync",{obsId:l,type:o.type},"(untitled)");this.dbManager.getChromaSync().syncObservation(l,e.claudeSessionId,e.project,o,e.lastPromptNumber,c,s).then(()=>{let d=Date.now()-u;M.debug("CHROMA","Observation synced",{obsId:l,duration:`${d}ms`,type:p,title:m})}).catch(d=>{M.error("CHROMA","Failed to sync observation",{obsId:l,sessionId:e.sessionDbId,type:p,title:m},d)}),t&&t.sseBroadcaster&&t.sseBroadcaster.broadcast({type:"new_observation",observation:{id:l,sdk_session_id:e.sdkSessionId,session_id:e.claudeSessionId,type:o.type,title:o.title,subtitle:o.subtitle,text:o.text||null,narrative:o.narrative||null,facts:JSON.stringify(o.facts||[]),concepts:JSON.stringify(o.concepts||[]),files_read:JSON.stringify(o.files||[]),files_modified:JSON.stringify([]),project:e.project,prompt_number:e.lastPromptNumber,created_at_epoch:c}})}let n=CE(r,e.sessionDbId);if(n){let{id:o,createdAtEpoch:l}=this.dbManager.getSessionStore().storeSummary(e.claudeSessionId,e.project,n,e.lastPromptNumber,s);M.info("SDK","Summary saved",{sessionId:e.sessionDbId,summaryId:o,request:n.request||ft("summary.request is null",{summaryId:o},"(no request)"),hasCompleted:!!n.completed,hasNextSteps:!!n.next_steps});let c=Date.now(),u=n.request||ft("summary.request is null for Chroma sync",{summaryId:o},"(no request)");this.dbManager.getChromaSync().syncSummary(o,e.claudeSessionId,e.project,n,e.lastPromptNumber,l,s).then(()=>{let p=Date.now()-c;M.debug("CHROMA","Summary synced",{summaryId:o,duration:`${p}ms`,request:u})}).catch(p=>{M.error("CHROMA","Failed to sync summary",{summaryId:o,sessionId:e.sessionDbId,request:u},p)}),t&&t.sseBroadcaster&&t.sseBroadcaster.broadcast({type:"new_summary",summary:{id:o,session_id:e.claudeSessionId,request:n.request,investigated:n.investigated,learned:n.learned,completed:n.completed,next_steps:n.next_steps,notes:n.notes,project:e.project,prompt_number:e.lastPromptNumber,created_at_epoch:l}})}t&&typeof t.broadcastProcessingStatus=="function"&&t.broadcastProcessingStatus()}findClaudeExecutable(){let r=lt.loadFromFile(Ln).CLAUDE_CODE_PATH||(0,zw.execSync)(process.platform==="win32"?"where claude":"which claude",{encoding:"utf8",windowsHide:!0}).trim().split(` `)[0].trim();if(!r)throw new Error("Claude executable not found in PATH");return r}getModelId(){let e=Gw.default.join((0,Vw.homedir)(),".claude-mem","settings.json");return lt.loadFromFile(e).CLAUDE_MEM_MODEL}};var Ol=class{dbManager;constructor(e){this.dbManager=e}stripProjectPath(e,r){let t=`/${r}/`,s=e.indexOf(t);return s!==-1?e.substring(s+t.length):e}stripProjectPaths(e,r){if(!e)return e;try{let s=JSON.parse(e).map(i=>this.stripProjectPath(i,r));return JSON.stringify(s)}catch{return e}}sanitizeObservation(e){return{...e,files_read:this.stripProjectPaths(e.files_read,e.project),files_modified:this.stripProjectPaths(e.files_modified,e.project)}}getObservations(e,r,t){let s=this.paginate("observations","id, sdk_session_id, project, type, title, subtitle, narrative, text, facts, concepts, files_read, files_modified, prompt_number, created_at, created_at_epoch",e,r,t);return{...s,items:s.items.map(i=>this.sanitizeObservation(i))}}getSummaries(e,r,t){let s=this.dbManager.getSessionStore().db,i=` diff --git a/src/services/process/ProcessManager.ts b/src/services/process/ProcessManager.ts index 9ea4bc3e..8bceff3a 100644 --- a/src/services/process/ProcessManager.ts +++ b/src/services/process/ProcessManager.ts @@ -1,9 +1,10 @@ import { existsSync, readFileSync, writeFileSync, unlinkSync, mkdirSync } from 'fs'; import { createWriteStream } from 'fs'; import { join } from 'path'; -import { spawn, spawnSync } from 'child_process'; +import { spawn } from 'child_process'; import { homedir } from 'os'; import { DATA_DIR } from '../../shared/paths.js'; +import { getBunPath, isBunAvailable } from '../../utils/bun-path.js'; const PID_FILE = join(DATA_DIR, 'worker.pid'); const LOG_DIR = join(DATA_DIR, 'logs'); @@ -56,26 +57,22 @@ export class ProcessManager { } private static isBunAvailable(): boolean { - try { - const result = spawnSync('bun', ['--version'], { stdio: 'pipe', timeout: 5000 }); - return result.status === 0; - } catch { - return false; - } + return isBunAvailable(); } private static async startWithBun(script: string, logFile: string, port: number): Promise<{ success: boolean; pid?: number; error?: string }> { - if (!this.isBunAvailable()) { + const bunPath = getBunPath(); + if (!bunPath) { return { success: false, - error: 'Bun is required but not found in PATH. Install from https://bun.sh' + error: 'Bun is required but not found in PATH or common installation paths. Install from https://bun.sh' }; } try { const isWindows = process.platform === 'win32'; - const child = spawn('bun', [script], { + const child = spawn(bunPath, [script], { detached: true, stdio: ['ignore', 'pipe', 'pipe'], env: { ...process.env, CLAUDE_MEM_WORKER_PORT: String(port) }, diff --git a/src/utils/bun-path.ts b/src/utils/bun-path.ts new file mode 100644 index 00000000..d4f0822f --- /dev/null +++ b/src/utils/bun-path.ts @@ -0,0 +1,77 @@ +/** + * Bun Path Utility + * + * Resolves the Bun executable path for environments where Bun is not in PATH + * (e.g., fish shell users where ~/.config/fish/config.fish isn't read by /bin/sh) + */ + +import { spawnSync } from 'child_process'; +import { existsSync } from 'fs'; +import { join } from 'path'; +import { homedir } from 'os'; + +/** + * Get the Bun executable path + * Tries PATH first, then checks common installation locations + * Returns absolute path if found, null otherwise + */ +export function getBunPath(): string | null { + const isWindows = process.platform === 'win32'; + + // Try PATH first + try { + const result = spawnSync('bun', ['--version'], { + encoding: 'utf-8', + stdio: ['pipe', 'pipe', 'pipe'], + shell: isWindows + }); + if (result.status === 0) { + return 'bun'; // Available in PATH + } + } catch { + // Not in PATH, continue to check common locations + } + + // Check common installation paths + const bunPaths = isWindows + ? [join(homedir(), '.bun', 'bin', 'bun.exe')] + : [ + join(homedir(), '.bun', 'bin', 'bun'), + '/usr/local/bin/bun', + '/opt/homebrew/bin/bun', // Apple Silicon Homebrew + '/home/linuxbrew/.linuxbrew/bin/bun' // Linux Homebrew + ]; + + for (const bunPath of bunPaths) { + if (existsSync(bunPath)) { + return bunPath; + } + } + + return null; +} + +/** + * Get the Bun executable path or throw an error + * Use this when Bun is required for operation + */ +export function getBunPathOrThrow(): string { + const bunPath = getBunPath(); + if (!bunPath) { + const isWindows = process.platform === 'win32'; + const installCmd = isWindows + ? 'powershell -c "irm bun.sh/install.ps1 | iex"' + : 'curl -fsSL https://bun.sh/install | bash'; + throw new Error( + `Bun is required but not found. Install it with:\n ${installCmd}\nThen restart your terminal.` + ); + } + return bunPath; +} + +/** + * Check if Bun is available (in PATH or common locations) + */ +export function isBunAvailable(): boolean { + return getBunPath() !== null; +} diff --git a/tests/bun-path.test.ts b/tests/bun-path.test.ts new file mode 100644 index 00000000..15079703 --- /dev/null +++ b/tests/bun-path.test.ts @@ -0,0 +1,101 @@ +import { describe, it, expect, vi } from 'vitest'; +import { existsSync } from 'fs'; +import { spawnSync } from 'child_process'; + +// Mock the dependencies +vi.mock('fs', () => ({ + existsSync: vi.fn() +})); + +vi.mock('child_process', () => ({ + spawnSync: vi.fn() +})); + +// Import after mocking +import { getBunPath, isBunAvailable, getBunPathOrThrow } from '../src/utils/bun-path'; + +describe('bun-path utility', () => { + it('should return "bun" when available in PATH', () => { + // Mock successful bun --version check + vi.mocked(spawnSync).mockReturnValue({ + status: 0, + stdout: Buffer.from('1.0.0'), + stderr: Buffer.from(''), + pid: 1234, + output: [], + signal: null + } as any); + + const result = getBunPath(); + expect(result).toBe('bun'); + expect(spawnSync).toHaveBeenCalledWith('bun', ['--version'], expect.any(Object)); + }); + + it('should check common installation paths when not in PATH', () => { + // Mock failed PATH check + vi.mocked(spawnSync).mockReturnValue({ + status: 1, + stdout: Buffer.from(''), + stderr: Buffer.from(''), + pid: 1234, + output: [], + signal: null + } as any); + + // Mock existsSync to return true for ~/.bun/bin/bun + vi.mocked(existsSync).mockImplementation((path: any) => { + return path.includes('.bun/bin/bun'); + }); + + const result = getBunPath(); + expect(result).toContain('.bun/bin/bun'); + }); + + it('should return null when bun is not found anywhere', () => { + // Mock failed PATH check + vi.mocked(spawnSync).mockReturnValue({ + status: 1, + stdout: Buffer.from(''), + stderr: Buffer.from(''), + pid: 1234, + output: [], + signal: null + } as any); + + // Mock existsSync to always return false + vi.mocked(existsSync).mockReturnValue(false); + + const result = getBunPath(); + expect(result).toBeNull(); + }); + + it('should return true for isBunAvailable when bun is found', () => { + // Mock successful bun check + vi.mocked(spawnSync).mockReturnValue({ + status: 0, + stdout: Buffer.from('1.0.0'), + stderr: Buffer.from(''), + pid: 1234, + output: [], + signal: null + } as any); + + const result = isBunAvailable(); + expect(result).toBe(true); + }); + + it('should throw error in getBunPathOrThrow when bun not found', () => { + // Mock failed bun check + vi.mocked(spawnSync).mockReturnValue({ + status: 1, + stdout: Buffer.from(''), + stderr: Buffer.from(''), + pid: 1234, + output: [], + signal: null + } as any); + vi.mocked(existsSync).mockReturnValue(false); + + expect(() => getBunPathOrThrow()).toThrow('Bun is required'); + }); +});