← back to Pitch Guard
Pitch Guard — draft + correspondence viewer for info@ with pre-send risk gate
7b30caa281026b185dfd917fdc3bfcc04d483adb · 2026-05-19 08:13:27 -0700 · Steve
Files touched
A .gitignoreA package-lock.jsonA package.jsonA public/index.htmlA server.js
Diff
commit 7b30caa281026b185dfd917fdc3bfcc04d483adb
Author: Steve <steve@designerwallcoverings.com>
Date: Tue May 19 08:13:27 2026 -0700
Pitch Guard — draft + correspondence viewer for info@ with pre-send risk gate
---
.gitignore | 8 +
package-lock.json | 827 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
package.json | 9 +
public/index.html | 381 +++++++++++++++++++++++++
server.js | 219 +++++++++++++++
5 files changed, 1444 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1924158
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+node_modules/
+.env*
+tmp/
+*.log
+.DS_Store
+dist/
+build/
+.next/
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..6a220b0
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,827 @@
+{
+ "name": "pitch-guard",
+ "version": "1.0.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "pitch-guard",
+ "version": "1.0.0",
+ "dependencies": {
+ "express": "^4.19.2"
+ }
+ },
+ "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/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/body-parser": {
+ "version": "1.20.5",
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.5.tgz",
+ "integrity": "sha512-3grm+/2tUOvu2cjJkvsIxrv/wVpfXQW4PsQHYm7yk4vfpu7Ekl6nEsYBoJUL6qDwZUx8wUhQ8tR2qz+ad9c9OA==",
+ "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.1",
+ "iconv-lite": "~0.4.24",
+ "on-finished": "~2.4.1",
+ "qs": "~6.15.1",
+ "raw-body": "~2.5.3",
+ "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/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.2",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
+ "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie-signature": {
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
+ "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
+ "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/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/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-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/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/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/express": {
+ "version": "4.22.2",
+ "resolved": "https://registry.npmjs.org/express/-/express-4.22.2.tgz",
+ "integrity": "sha512-IuL+Elrou2ZvCFHs18/CIzy2Nzvo25nZ1/D2eIZlz7c+QUayAcYoiM2BthCjs+EBHVpjYjcuLDAiCWgeIX3X1Q==",
+ "license": "MIT",
+ "dependencies": {
+ "accepts": "~1.3.8",
+ "array-flatten": "1.1.1",
+ "body-parser": "~1.20.5",
+ "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.15.1",
+ "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/finalhandler": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
+ "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
+ "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.2",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "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/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/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/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.3",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz",
+ "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==",
+ "license": "MIT",
+ "dependencies": {
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/http-errors": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
+ "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
+ "license": "MIT",
+ "dependencies": {
+ "depd": "~2.0.0",
+ "inherits": "~2.0.4",
+ "setprototypeof": "~1.2.0",
+ "statuses": "~2.0.2",
+ "toidentifier": "~1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "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",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
+ "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/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/ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
+ "license": "MIT"
+ },
+ "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/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/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/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-to-regexp": {
+ "version": "0.1.13",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
+ "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
+ "license": "MIT"
+ },
+ "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/qs": {
+ "version": "6.15.2",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
+ "integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "side-channel": "^1.1.0"
+ },
+ "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.3",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
+ "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
+ "license": "MIT",
+ "dependencies": {
+ "bytes": "~3.1.2",
+ "http-errors": "~2.0.1",
+ "iconv-lite": "~0.4.24",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/safe-buffer": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
+ "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/send": {
+ "version": "0.19.2",
+ "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
+ "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "destroy": "1.2.0",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "fresh": "~0.5.2",
+ "http-errors": "~2.0.1",
+ "mime": "1.6.0",
+ "ms": "2.1.3",
+ "on-finished": "~2.4.1",
+ "range-parser": "~1.2.1",
+ "statuses": "~2.0.2"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "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.3",
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
+ "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
+ "license": "MIT",
+ "dependencies": {
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "parseurl": "~1.3.3",
+ "send": "~0.19.1"
+ },
+ "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/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.1",
+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
+ "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "object-inspect": "^1.13.4"
+ },
+ "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/statuses": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
+ "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "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/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/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/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"
+ }
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..a588e97
--- /dev/null
+++ b/package.json
@@ -0,0 +1,9 @@
+{
+ "name": "pitch-guard",
+ "version": "1.0.0",
+ "private": true,
+ "description": "Draft + correspondence viewer for info@designerwallcoverings.com — review every thread with a contact before sending a followup pitch, so we never pitch a customer who already ordered/paid/shipped.",
+ "main": "server.js",
+ "scripts": { "start": "node server.js" },
+ "dependencies": { "express": "^4.19.2" }
+}
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..a1f5ab3
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,381 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<title>Pitch Guard — Designer Wallcoverings</title>
+<style>
+ :root{
+ --cream:#f6f3ec; --paper:#fffdf8; --ink:#26221c; --muted:#8a8273;
+ --line:#e3ddcf; --gold:#9a7b3f; --accent:#2c4a3e;
+ --red:#a3322a; --redbg:#f7e3e0; --amber:#9a6b1e; --amberbg:#f6ecd6;
+ --green:#2c6b4f; --greenbg:#e2efe6; --slate:#5a6b78; --slatebg:#e7ecef;
+ }
+ *{box-sizing:border-box;margin:0;padding:0}
+ body{font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:var(--cream);color:var(--ink);height:100vh;overflow:hidden}
+ h1,h2,h3,.serif{font-family:Georgia,"Times New Roman",serif}
+ header{height:54px;background:var(--ink);color:var(--cream);display:flex;align-items:center;
+ padding:0 18px;gap:14px;border-bottom:3px solid var(--gold)}
+ header h1{font-size:18px;font-weight:600;letter-spacing:.3px}
+ header .sub{font-size:12px;color:#cdc6b3;letter-spacing:.4px}
+ header .spacer{flex:1}
+ header .acct{font-size:12px;background:#3a352b;padding:5px 11px;border-radius:20px;color:#e8e1cd}
+ .layout{display:flex;height:calc(100vh - 54px)}
+ /* ── panels ── */
+ .panel{display:flex;flex-direction:column;height:100%;overflow:hidden}
+ .pane-left{width:336px;border-right:1px solid var(--line);background:var(--paper)}
+ .pane-mid{flex:1;min-width:340px;background:var(--cream)}
+ .pane-right{width:438px;border-left:1px solid var(--line);background:var(--paper)}
+ .pane-hd{padding:11px 14px;border-bottom:1px solid var(--line);display:flex;
+ align-items:center;gap:8px;background:var(--paper);flex-shrink:0}
+ .pane-hd h2{font-size:13px;text-transform:uppercase;letter-spacing:.9px;color:var(--muted);font-family:inherit;font-weight:700}
+ .pane-hd .count{font-size:11px;background:var(--ink);color:var(--cream);border-radius:10px;padding:1px 8px}
+ .pane-body{flex:1;overflow-y:auto}
+ .pane-hd .spacer{flex:1}
+ /* ── buttons ── */
+ button{font:inherit;cursor:pointer;border:1px solid var(--line);background:var(--paper);
+ color:var(--ink);border-radius:6px;padding:6px 12px;transition:.12s}
+ button:hover{background:var(--cream)}
+ button:disabled{opacity:.45;cursor:not-allowed}
+ .btn-sm{font-size:11px;padding:4px 9px}
+ .btn-go{background:var(--accent);color:#fff;border-color:var(--accent);font-weight:600}
+ .btn-go:hover{background:#233b31}
+ .btn-danger{background:var(--red);color:#fff;border-color:var(--red)}
+ /* ── draft list ── */
+ .draft{padding:10px 14px;border-bottom:1px solid var(--line);cursor:pointer;position:relative}
+ .draft:hover{background:var(--cream)}
+ .draft.active{background:var(--cream);box-shadow:inset 3px 0 0 var(--gold)}
+ .draft .who{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;padding-right:54px}
+ .draft .subj{font-size:12px;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
+ .draft .meta{font-size:11px;color:var(--muted);margin-top:3px}
+ .draft .badge{position:absolute;top:9px;right:12px}
+ /* ── risk badges ── */
+ .badge{font-size:10px;font-weight:700;letter-spacing:.5px;border-radius:4px;padding:2px 6px;text-transform:uppercase}
+ .r-high{background:var(--redbg);color:var(--red)}
+ .r-elevated{background:var(--amberbg);color:var(--amber)}
+ .r-caution{background:var(--slatebg);color:var(--slate)}
+ .r-clear{background:var(--greenbg);color:var(--green)}
+ .r-pending{background:#ece8df;color:var(--muted)}
+ .spin{display:inline-block;width:11px;height:11px;border:2px solid var(--line);
+ border-top-color:var(--gold);border-radius:50%;animation:sp .7s linear infinite;vertical-align:-1px}
+ @keyframes sp{to{transform:rotate(360deg)}}
+ /* ── correspondence ── */
+ .empty{padding:48px 28px;text-align:center;color:var(--muted);font-size:13px}
+ .empty .big{font-size:34px;margin-bottom:10px;opacity:.5}
+ .risk-banner{margin:14px;border-radius:8px;padding:13px 15px;border:1px solid}
+ .risk-banner.high{background:var(--redbg);border-color:#d8b4ae}
+ .risk-banner.elevated{background:var(--amberbg);border-color:#dcc99a}
+ .risk-banner.caution{background:var(--slatebg);border-color:#c7d1d8}
+ .risk-banner.clear{background:var(--greenbg);border-color:#b6d3c0}
+ .risk-banner h3{font-size:14px;display:flex;align-items:center;gap:8px;font-family:inherit}
+ .risk-banner p{font-size:12.5px;margin-top:5px;color:var(--ink)}
+ .risk-banner .sigs{margin-top:8px;display:flex;gap:6px;flex-wrap:wrap}
+ .contact-hd{padding:4px 16px 8px;font-size:12px;color:var(--muted)}
+ .contact-hd b{color:var(--ink);font-size:13px}
+ .thread{margin:0 14px 12px;border:1px solid var(--line);border-radius:8px;background:var(--paper);overflow:hidden}
+ .thread-hd{padding:8px 12px;background:var(--cream);cursor:pointer;display:flex;align-items:center;gap:8px}
+ .thread-hd .t-subj{font-weight:600;font-size:12.5px;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
+ .thread-hd .t-meta{font-size:11px;color:var(--muted);white-space:nowrap}
+ .msg{padding:9px 12px;border-top:1px solid var(--line);cursor:pointer}
+ .msg:hover{background:var(--cream)}
+ .msg .m-top{display:flex;gap:8px;align-items:baseline}
+ .msg .dir{font-size:10px;font-weight:700;border-radius:3px;padding:1px 5px}
+ .dir.in{background:var(--slatebg);color:var(--slate)}
+ .dir.out{background:#ede7d8;color:var(--gold)}
+ .msg .m-from{font-size:12px;font-weight:600;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
+ .msg .m-date{font-size:11px;color:var(--muted)}
+ .msg .m-snip{font-size:12px;color:var(--muted);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
+ .msg .m-body{font-size:12.5px;white-space:pre-wrap;margin-top:7px;padding:9px;background:var(--cream);
+ border-radius:6px;border:1px solid var(--line);max-height:300px;overflow-y:auto;display:none}
+ .msg.open .m-body{display:block}
+ .msg.open .m-snip{display:none}
+ .sig-chip{font-size:9px;font-weight:700;letter-spacing:.4px;background:var(--redbg);color:var(--red);
+ border-radius:3px;padding:1px 5px}
+ /* ── right / pitch ── */
+ .pitch-empty{padding:48px 24px;text-align:center;color:var(--muted);font-size:13px}
+ .pitch{display:flex;flex-direction:column;height:100%}
+ .pitch-scroll{flex:1;overflow-y:auto;padding:14px}
+ .fld{margin-bottom:11px}
+ .fld label{display:block;font-size:10px;text-transform:uppercase;letter-spacing:.7px;color:var(--muted);font-weight:700;margin-bottom:3px}
+ .fld input,.fld textarea{width:100%;font:inherit;border:1px solid var(--line);border-radius:6px;
+ padding:7px 9px;background:var(--paper);color:var(--ink)}
+ .fld textarea{min-height:230px;resize:vertical;font-size:13px;line-height:1.55}
+ .fld .ro{background:var(--cream);padding:7px 9px;border:1px solid var(--line);border-radius:6px;font-size:13px}
+ .verdict{border-radius:8px;padding:11px 13px;margin-bottom:12px;border:1px solid}
+ .verdict.high{background:var(--redbg);border-color:#d8b4ae}
+ .verdict.elevated{background:var(--amberbg);border-color:#dcc99a}
+ .verdict.caution{background:var(--slatebg);border-color:#c7d1d8}
+ .verdict.clear{background:var(--greenbg);border-color:#b6d3c0}
+ .verdict h3{font-size:13px;font-family:inherit}
+ .verdict p{font-size:12px;margin-top:4px}
+ .override{margin-top:9px;font-size:12px;display:flex;gap:7px;align-items:flex-start}
+ .override input{margin-top:2px}
+ .pitch-foot{padding:11px 14px;border-top:1px solid var(--line);background:var(--paper);
+ display:flex;gap:8px;align-items:center;flex-shrink:0}
+ .pitch-foot .spacer{flex:1}
+ .toast{position:fixed;bottom:18px;left:50%;transform:translateX(-50%);background:var(--ink);
+ color:var(--cream);padding:10px 18px;border-radius:8px;font-size:13px;opacity:0;
+ transition:.25s;pointer-events:none;z-index:50}
+ .toast.show{opacity:1}
+ .toast.err{background:var(--red)}
+ .sent-stamp{font-size:11px;color:var(--green);font-weight:700}
+</style>
+</head>
+<body>
+<header>
+ <h1>Pitch Guard</h1>
+ <span class="sub">review before you follow up</span>
+ <span class="spacer"></span>
+ <span class="acct" id="acct">info@designerwallcoverings.com</span>
+</header>
+
+<div class="layout">
+ <!-- LEFT: drafts -->
+ <div class="panel pane-left">
+ <div class="pane-hd">
+ <h2>Drafts</h2><span class="count" id="draftCount">·</span>
+ <span class="spacer"></span>
+ <button class="btn-sm" id="scanAll" title="Scan every contact for prior orders">Scan risk</button>
+ </div>
+ <div class="pane-body" id="draftList">
+ <div class="empty"><div class="spin"></div> loading drafts…</div>
+ </div>
+ </div>
+
+ <!-- MIDDLE: correspondence -->
+ <div class="panel pane-mid">
+ <div class="pane-hd">
+ <h2>Correspondence</h2>
+ <span class="spacer"></span>
+ <span class="count" id="threadCount" style="display:none"></span>
+ </div>
+ <div class="pane-body" id="corr">
+ <div class="empty"><div class="big">✉</div>Pick a draft on the left to see every thread<br>with that contact before you decide.</div>
+ </div>
+ </div>
+
+ <!-- RIGHT: the pitch -->
+ <div class="panel pane-right">
+ <div class="pane-hd"><h2>The Pitch</h2></div>
+ <div class="pane-body" id="pitch">
+ <div class="pitch-empty">No draft selected.<br>The followup waiting for this client will appear here.</div>
+ </div>
+ </div>
+</div>
+
+<div class="toast" id="toast"></div>
+
+<script>
+const $ = s => document.querySelector(s);
+let DRAFTS = [], CURRENT = null, MORE = false;
+const riskCache = {}; // email -> full /api/contact result
+const liteCache = {}; // email -> light /api/risk result {risk,signals}
+const verdictOf = email => riskCache[email] || liteCache[email] || null;
+
+function toast(msg, err){ const t=$('#toast'); t.textContent=msg; t.className='toast show'+(err?' err':''); setTimeout(()=>t.className='toast',2600); }
+function esc(s){ return String(s||'').replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c])); }
+function fmtDate(d){ if(!d) return ''; const t=Date.parse(d); if(!t) return d; const dt=new Date(t);
+ return dt.toLocaleDateString('en-US',{month:'short',day:'numeric',year:'2-digit'}); }
+const riskWord = {high:'High risk',elevated:'Elevated',caution:'Caution',clear:'Clear'};
+
+// ── load drafts ──
+async function loadDrafts(){
+ try{
+ const r = await fetch('/api/drafts'); const d = await r.json();
+ if(d.error) throw new Error(d.error);
+ DRAFTS = d.drafts; MORE = d.more; $('#acct').textContent = d.account;
+ $('#draftCount').textContent = d.count + (d.more ? '+' : '');
+ $('#draftCount').title = d.more ? d.count + ' newest shown — the followup-bot backlog is larger' : d.count + ' drafts';
+ renderDrafts();
+ }catch(e){ $('#draftList').innerHTML = '<div class="empty">⚠ '+esc(e.message)+'</div>'; }
+}
+function renderDrafts(){
+ const el = $('#draftList');
+ if(!DRAFTS.length){ el.innerHTML='<div class="empty">No drafts waiting.</div>'; return; }
+ el.innerHTML = (MORE?'<div class="meta" style="padding:7px 14px;color:var(--muted);border-bottom:1px solid var(--line)">Showing the '+DRAFTS.length+' most recent followup drafts — the bot backlog is larger.</div>':'') +
+ DRAFTS.map(d=>{
+ const c = verdictOf(d.toEmail);
+ let badge = '<span class="badge r-pending">·</span>';
+ if(d._scanning) badge = '<span class="badge r-pending"><span class="spin"></span></span>';
+ else if(c) badge = '<span class="badge r-'+c.risk+'">'+c.risk+'</span>';
+ return '<div class="draft'+(CURRENT===d.id?' active':'')+'" data-id="'+d.id+'">'+
+ badge+
+ '<div class="who">'+esc(d.toName)+'</div>'+
+ '<div class="subj">'+esc(d.subject)+'</div>'+
+ '<div class="meta">'+esc(d.toEmail||'no recipient')+' · '+fmtDate(d.date)+'</div>'+
+ '</div>';
+ }).join('');
+ el.querySelectorAll('.draft').forEach(n=>n.onclick=()=>selectDraft(n.dataset.id));
+}
+
+// ── select a draft ──
+async function selectDraft(id){
+ CURRENT = id; renderDrafts();
+ const d = DRAFTS.find(x=>x.id===id); if(!d) return;
+ if(!d.toEmail){
+ $('#corr').innerHTML = '<div class="empty">This draft has no recipient address — nothing to cross-check.</div>';
+ } else {
+ $('#corr').innerHTML = '<div class="empty"><div class="spin"></div> pulling every thread with '+esc(d.toEmail)+'…</div>';
+ loadContact(d.toEmail);
+ }
+ loadPitch(d);
+}
+
+// ── middle: correspondence ──
+async function loadContact(email){
+ try{
+ let c = riskCache[email];
+ if(!c){ const r=await fetch('/api/contact?email='+encodeURIComponent(email)); c=await r.json();
+ if(c.error) throw new Error(c.error); riskCache[email]=c; renderDrafts(); }
+ renderCorr(c); renderVerdict(c);
+ }catch(e){ $('#corr').innerHTML='<div class="empty">⚠ '+esc(e.message)+'</div>'; }
+}
+function renderCorr(c){
+ $('#threadCount').style.display='inline-block';
+ $('#threadCount').textContent = c.threadCount+' thread'+(c.threadCount===1?'':'s');
+ const sigChips = c.signals.map(s=>'<span class="badge r-high">'+esc(s)+'</span>').join(' ');
+ let banner='';
+ if(c.risk==='high') banner='<div class="risk-banner high"><h3>⛔ Already a customer — do NOT pitch</h3>'+
+ '<p>This contact has thread activity that looks like a completed order. Sending a generic followup here is exactly what upsets Samantha. Verify with her before anything goes out.</p>'+
+ (sigChips?'<div class="sigs">'+sigChips+'</div>':'')+'</div>';
+ else if(c.risk==='elevated') banner='<div class="risk-banner elevated"><h3>⚠ Likely transacting</h3>'+
+ '<p>Invoice / order signals found across this contact’s threads. Read them before deciding to follow up.</p>'+
+ (sigChips?'<div class="sigs">'+sigChips+'</div>':'')+'</div>';
+ else if(c.risk==='caution') banner='<div class="risk-banner caution"><h3>↔ Multiple threads</h3>'+
+ '<p>More than one thread with this contact. Make sure the followup is not duplicating one already handled.</p></div>';
+ else banner='<div class="risk-banner clear"><h3>✓ Clear to follow up</h3>'+
+ '<p>No invoice / payment / shipping signals found in this contact’s history.</p></div>';
+
+ const threads = c.threads.map(t=>{
+ const tsig = t.signals.length? ' '+t.signals.map(s=>'<span class="sig-chip">'+esc(s)+'</span>').join('') : '';
+ const msgs = t.messages.map(m=>{
+ const ms = m.signals.length? ' '+m.signals.map(s=>'<span class="sig-chip">'+esc(s)+'</span>').join('') : '';
+ return '<div class="msg" data-mid="'+m.id+'">'+
+ '<div class="m-top"><span class="dir '+(m.inbound?'in':'out')+'">'+(m.inbound?'IN':'OUT')+'</span>'+
+ '<span class="m-from">'+esc(m.inbound?(m.fromName||m.from):'Designer Wallcoverings')+'</span>'+
+ '<span class="m-date">'+fmtDate(m.date)+'</span></div>'+
+ '<div class="m-snip">'+esc(m.snippet)+ms+'</div>'+
+ '<div class="m-body" data-loaded="0">'+ms+'</div>'+
+ '</div>';
+ }).join('');
+ return '<div class="thread"><div class="thread-hd"><span class="t-subj">'+esc(t.subject)+tsig+'</span>'+
+ '<span class="t-meta">'+t.messages.length+' msg · '+fmtDate(t.lastDate)+'</span></div>'+msgs+'</div>';
+ }).join('');
+
+ $('#corr').innerHTML = banner +
+ '<div class="contact-hd"><b>'+esc(c.email)+'</b> — '+c.totalMessages+' messages across '+c.threadCount+' thread'+(c.threadCount===1?'':'s')+
+ (c.customerReplied?' · customer has replied':'')+'</div>' + threads;
+
+ $('#corr').querySelectorAll('.msg').forEach(n=>n.onclick=()=>toggleMsg(n));
+}
+async function toggleMsg(node){
+ node.classList.toggle('open');
+ const body = node.querySelector('.m-body');
+ if(node.classList.contains('open') && body.dataset.loaded==='0'){
+ body.dataset.loaded='1';
+ body.textContent='loading…';
+ try{ const r=await fetch('/api/message/'+node.dataset.mid); const m=await r.json();
+ body.textContent = m.body || m.snippet || '(no text body)';
+ }catch(e){ body.textContent='⚠ '+e.message; }
+ }
+}
+
+// ── right: the pitch ──
+async function loadPitch(d){
+ const el = $('#pitch');
+ el.innerHTML = '<div class="pitch-empty"><div class="spin"></div> loading draft…</div>';
+ let body='';
+ try{ const r=await fetch('/api/message/'+d.id); const m=await r.json(); body=m.body||''; }
+ catch(e){ body='(could not load draft body: '+e.message+')'; }
+ el.innerHTML =
+ '<div class="pitch">'+
+ '<div class="pitch-scroll">'+
+ '<div id="verdictSlot"></div>'+
+ '<div class="fld"><label>To</label><div class="ro">'+esc(d.to||'(no recipient)')+'</div></div>'+
+ '<div class="fld"><label>Subject</label><input id="pSubj" value="'+esc(d.subject)+'"></div>'+
+ '<div class="fld"><label>Pitch / followup body — edit before sending</label>'+
+ '<textarea id="pBody">'+esc(body)+'</textarea></div>'+
+ '</div>'+
+ '<div class="pitch-foot">'+
+ '<span id="sendState"></span><span class="spacer"></span>'+
+ '<button id="skipBtn" class="btn-sm">Skip</button>'+
+ '<button id="sendBtn" class="btn-go">Send followup</button>'+
+ '</div>'+
+ '</div>';
+ $('#skipBtn').onclick=()=>{ toast('Skipped — draft left untouched in Gmail'); };
+ $('#sendBtn').onclick=()=>sendPitch(d);
+ // verdict — show any cached read instantly; the full /api/contact refines it
+ const c = verdictOf(d.toEmail);
+ if(c) renderVerdict(c);
+ else if(d.toEmail) $('#verdictSlot').innerHTML='<div class="verdict caution"><h3><span class="spin"></span> Checking every thread with this contact…</h3></div>';
+ else $('#verdictSlot').innerHTML='<div class="verdict caution"><h3>No recipient on this draft</h3></div>';
+}
+function renderVerdict(c){
+ const slot = $('#verdictSlot'); if(!slot) return;
+ let html='', gated = (c.risk==='high'||c.risk==='elevated');
+ if(c.risk==='high') html='<h3>⛔ '+riskWord.high+'</h3><p>Order / payment activity found. This client should likely <b>not</b> get a followup pitch. Confirm with Samantha first.</p>';
+ else if(c.risk==='elevated') html='<h3>⚠ '+riskWord.elevated+'</h3><p>Invoice / order signals found in other threads — review the middle panel before sending.</p>';
+ else if(c.risk==='caution') html='<h3>↔ '+riskWord.caution+'</h3><p>Multiple threads exist. Make sure this followup is not a duplicate.</p>';
+ else html='<h3>✓ '+riskWord.clear+'</h3><p>No prior-order signals. Safe to follow up.</p>';
+ if(gated) html+='<label class="override"><input type="checkbox" id="ovr">'+
+ '<span>I reviewed every thread above and confirm this followup is still appropriate.</span></label>';
+ slot.className=''; slot.innerHTML='<div class="verdict '+c.risk+'">'+html+'</div>';
+ const sb=$('#sendBtn');
+ if(sb){
+ if(gated){ sb.disabled=true; sb.classList.add('btn-danger'); sb.classList.remove('btn-go');
+ const ov=$('#ovr'); if(ov) ov.onchange=()=>{ sb.disabled=!ov.checked; }; }
+ else { sb.disabled=false; sb.classList.add('btn-go'); sb.classList.remove('btn-danger'); }
+ }
+}
+
+// ── send ──
+async function sendPitch(d){
+ const subj=$('#pSubj').value.trim(), body=$('#pBody').value.trim();
+ if(!d.toEmail){ toast('No recipient on this draft',1); return; }
+ if(!body){ toast('Body is empty',1); return; }
+ const c = riskCache[d.toEmail];
+ let warn='Send this followup to '+d.toEmail+'?';
+ if(c && (c.risk==='high'||c.risk==='elevated')) warn='⚠ '+riskWord[c.risk]+' — '+c.signals.join(', ')+
+ ' signals found. Send anyway to '+d.toEmail+'?';
+ if(!confirm(warn)) return;
+ const sb=$('#sendBtn'); sb.disabled=true; $('#sendState').innerHTML='<span class="spin"></span> sending…';
+ try{
+ const r=await fetch('/api/send',{method:'POST',headers:{'Content-Type':'application/json'},
+ body:JSON.stringify({to:d.toEmail,subject:subj,body:body.replace(/\n/g,'<br>'),threadId:d.threadId})});
+ const out=await r.json();
+ if(out.error) throw new Error(out.error);
+ $('#sendState').innerHTML='<span class="sent-stamp">✓ sent in-thread</span>';
+ toast('Followup sent to '+d.toEmail);
+ d._sent=true;
+ }catch(e){ $('#sendState').textContent=''; sb.disabled=false; toast('Send failed: '+e.message,1); }
+}
+
+// ── scan all contacts for risk ──
+async function scanAll(){
+ const btn=$('#scanAll'); btn.disabled=true;
+ const targets=[...new Set(DRAFTS.filter(d=>d.toEmail&&!verdictOf(d.toEmail)).map(d=>d.toEmail))];
+ if(!targets.length){ btn.disabled=false; toast('Every draft already scanned'); return; }
+ let i=0, done=0;
+ const tick=()=>{ btn.textContent='scanning '+done+'/'+targets.length; };
+ tick();
+ async function worker(){
+ while(i<targets.length){
+ const email=targets[i++];
+ try{ const r=await fetch('/api/risk?email='+encodeURIComponent(email)); const v=await r.json();
+ if(!v.error) liteCache[email]=v; }catch{}
+ done++; tick(); renderDrafts();
+ await new Promise(r=>setTimeout(r,250)); // gentle on Gmail quota
+ }
+ }
+ await Promise.all([worker(),worker()]); // concurrency 2
+ btn.disabled=false; btn.textContent='Scan risk';
+ const high=DRAFTS.filter(d=>{const v=verdictOf(d.toEmail);return v&&v.risk==='high';}).length;
+ const elev=DRAFTS.filter(d=>{const v=verdictOf(d.toEmail);return v&&v.risk==='elevated';}).length;
+ toast('Scan done — '+high+' high-risk, '+elev+' elevated');
+}
+$('#scanAll').onclick=scanAll;
+
+loadDrafts();
+</script>
+</body>
+</html>
diff --git a/server.js b/server.js
new file mode 100644
index 0000000..65baa18
--- /dev/null
+++ b/server.js
@@ -0,0 +1,219 @@
+'use strict';
+/**
+ * Pitch Guard — info@designerwallcoverings.com draft / correspondence viewer.
+ *
+ * The problem (per Samantha, IRL VP of DW): the followup bot drafts a generic
+ * "just following up on the quote" reply on ONE thread, while OTHER threads with
+ * the same contact have already closed — invoice sent, paid, shipped. Pitching a
+ * customer who already ordered embarrasses Samantha.
+ *
+ * This viewer pulls every draft, and for the selected draft's contact it pulls
+ * EVERY thread + scans for invoice/payment/shipping signals so you can decide,
+ * with the full picture, whether the followup pitch should actually go out.
+ *
+ * Backend = thin proxy onto George (the DW Gmail HTTP agent) for the `info` acct.
+ */
+const express = require('express');
+const path = require('path');
+
+const app = express();
+app.use(express.json({ limit: '4mb' }));
+app.use(express.static(path.join(__dirname, 'public')));
+
+const PORT = process.env.PORT || 9871;
+const GEORGE = (process.env.GEORGE_URL || 'http://100.107.67.67:9850').replace(/\/$/, '');
+const AUTH = process.env.GEORGE_BASIC_AUTH || 'YWRtaW46STNZdXNpc2RFU1VOZHh0cm1sYjNRSmV1OXE4T0RLSk8=';
+const ACCOUNT = 'info'; // info@designerwallcoverings.com
+
+// ── George proxy ──────────────────────────────────────────────────────────
+async function george(p, { method = 'GET', query, body } = {}) {
+ const url = new URL(GEORGE + p);
+ if (query) for (const [k, v] of Object.entries(query)) if (v != null) url.searchParams.set(k, String(v));
+ const res = await fetch(url, {
+ method,
+ headers: { Authorization: `Basic ${AUTH}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
+ body: body ? JSON.stringify(body) : undefined,
+ });
+ const txt = await res.text();
+ let data; try { data = JSON.parse(txt); } catch { data = { raw: txt }; }
+ if (!res.ok) { const e = new Error(data.error || txt.slice(0, 200)); e.status = res.status; throw e; }
+ return data;
+}
+
+// ── helpers ───────────────────────────────────────────────────────────────
+const EMAIL_RE = /[\w.+-]+@[\w-]+\.[\w.-]+/;
+function extractEmail(s) { const m = String(s || '').match(EMAIL_RE); return m ? m[0].toLowerCase() : ''; }
+function displayName(s) {
+ const m = String(s || '').match(/^\s*"?([^"<]+?)"?\s*</);
+ return m ? m[1].trim() : extractEmail(s);
+}
+const OURS = 'designerwallcoverings.com';
+
+// Signals that a contact has likely already transacted — the Samantha tripwire.
+const SIGNALS = [
+ { key: 'paid', level: 3, label: 'PAID', re: /\b(paid|payment received|received your payment|thank you for your (payment|order)|payment confirmation|invoice paid)\b/i },
+ { key: 'shipped', level: 3, label: 'SHIPPED', re: /\b(shipped|shipment|has shipped|tracking (number|#|no)|out for delivery|fedex|ups tracking)\b/i },
+ { key: 'ordered', level: 2, label: 'ORDERED', re: /\b(order #?\d|order confirmation|order placed|your order|purchase order|p\.?o\.? ?#?\d)\b/i },
+ { key: 'invoiced', level: 2, label: 'INVOICED', re: /\b(invoice ?#?\d|invoice attached|here('| i)s your invoice|invoice for)\b/i },
+];
+
+// in-memory contact-scan cache (TTL 10 min)
+const cache = new Map();
+const TTL = 10 * 60 * 1000;
+function cacheGet(k) { const e = cache.get(k); if (e && Date.now() - e.t < TTL) return e.v; cache.delete(k); return null; }
+function cacheSet(k, v) { cache.set(k, { t: Date.now(), v }); }
+const sleep = ms => new Promise(r => setTimeout(r, ms));
+
+// drafts list cache — the followup bot keeps a huge backlog; each page costs
+// ~100 Gmail messages.get calls, so cap + throttle to stay under the per-minute quota.
+let draftsCache = null;
+const DRAFTS_TTL = 5 * 60 * 1000;
+const DRAFT_PAGES = 4; // 4 × 100 = 400 most-recent drafts per load
+
+// ── API: list drafts ──────────────────────────────────────────────────────
+app.get('/api/drafts', async (req, res) => {
+ try {
+ if (draftsCache && !req.query.fresh && Date.now() - draftsCache.t < DRAFTS_TTL) {
+ return res.json({ ...draftsCache.v, cached: true });
+ }
+ // throttled pagination — newest drafts first, capped to stay under Gmail quota
+ let messages = [], pageToken, pages = 0, more = false;
+ do {
+ const out = await george('/api/messages', { query: { account: ACCOUNT, q: 'in:draft', maxResults: 100, pageToken } });
+ messages = messages.concat(out.messages || []);
+ pageToken = out.nextPageToken;
+ if (++pages >= DRAFT_PAGES) { more = !!pageToken; break; }
+ if (pageToken) await sleep(700);
+ } while (pageToken);
+ const drafts = messages.map(m => ({
+ id: m.id,
+ threadId: m.threadId,
+ subject: m.subject || '(no subject)',
+ to: m.to || '',
+ toEmail: extractEmail(m.to),
+ toName: displayName(m.to) || extractEmail(m.to) || '(no recipient)',
+ date: m.date || '',
+ snippet: m.snippet || '',
+ }));
+ const payload = { account: `${ACCOUNT}@${OURS}`, count: drafts.length, more, drafts };
+ draftsCache = { t: Date.now(), v: payload };
+ res.json(payload);
+ } catch (e) { res.status(e.status || 500).json({ error: e.message }); }
+});
+
+// ── API: full message (works for drafts too) ──────────────────────────────
+app.get('/api/message/:id', async (req, res) => {
+ try {
+ const m = await george(`/api/messages/${encodeURIComponent(req.params.id)}`, { query: { account: ACCOUNT } });
+ res.json(m);
+ } catch (e) { res.status(e.status || 500).json({ error: e.message }); }
+});
+
+// ── API: every thread + risk scan for one contact ─────────────────────────
+app.get('/api/contact', async (req, res) => {
+ const email = extractEmail(req.query.email);
+ if (!email) return res.status(400).json({ error: 'valid email required' });
+ const cached = !req.query.fresh && cacheGet(email);
+ if (cached) return res.json({ ...cached, cached: true });
+ try {
+ const out = await george('/api/search', {
+ query: { account: ACCOUNT, q: `from:${email} OR to:${email}`, maxResults: 60 },
+ });
+ const msgs = (out.messages || []).filter(m => !m.error).map(m => {
+ const fromEmail = extractEmail(m.from);
+ const inbound = fromEmail === email; // from the customer, not from us
+ const hay = `${m.subject || ''} ${m.snippet || ''}`;
+ const hits = SIGNALS.filter(s => s.re.test(hay)).map(s => s.key);
+ return {
+ id: m.id, threadId: m.threadId,
+ subject: m.subject || '(no subject)',
+ from: m.from || '', fromName: displayName(m.from),
+ to: m.to || '', date: m.date || '',
+ ts: Date.parse(m.date) || 0,
+ snippet: m.snippet || '', inbound, signals: hits,
+ };
+ }).sort((a, b) => b.ts - a.ts);
+
+ // group into threads
+ const tmap = new Map();
+ for (const m of msgs) {
+ if (!tmap.has(m.threadId)) tmap.set(m.threadId, { threadId: m.threadId, subject: m.subject, messages: [], signals: new Set(), lastTs: 0 });
+ const t = tmap.get(m.threadId);
+ t.messages.push(m);
+ m.signals.forEach(s => t.signals.add(s));
+ if (m.ts > t.lastTs) { t.lastTs = m.ts; t.lastDate = m.date; }
+ }
+ const threads = [...tmap.values()].map(t => ({ ...t, signals: [...t.signals] })).sort((a, b) => b.lastTs - a.lastTs);
+
+ // overall risk
+ const allSignals = new Set();
+ msgs.forEach(m => m.signals.forEach(s => allSignals.add(s)));
+ const customerReplied = msgs.some(m => m.inbound);
+ let level = 0;
+ for (const s of SIGNALS) if (allSignals.has(s.key)) level = Math.max(level, s.level);
+ if (threads.length > 1) level = Math.max(level, 1);
+ const risk = level >= 3 ? 'high' : level >= 2 ? 'elevated' : level >= 1 ? 'caution' : 'clear';
+
+ const result = {
+ email, totalMessages: msgs.length, threadCount: threads.length,
+ signals: [...allSignals].map(k => SIGNALS.find(s => s.key === k).label),
+ customerReplied, risk, threads,
+ };
+ cacheSet(email, result);
+ res.json(result);
+ } catch (e) { res.status(e.status || 500).json({ error: e.message }); }
+});
+
+// ── API: lightweight risk verdict (for bulk left-panel scanning) ──────────
+// One targeted search instead of pulling the whole history — keeps the
+// scan-all sweep under Gmail's per-minute quota.
+app.get('/api/risk', async (req, res) => {
+ const email = extractEmail(req.query.email);
+ if (!email) return res.status(400).json({ error: 'valid email required' });
+ const hit = cacheGet(email);
+ if (hit) return res.json({ email, risk: hit.risk, signals: hit.signals, cached: true });
+ const lite = cacheGet('risk:' + email);
+ if (lite) return res.json({ ...lite, cached: true });
+ try {
+ const q = `(from:${email} OR to:${email}) (invoice OR paid OR payment OR shipped OR shipping OR tracking OR receipt OR "order confirmation" OR "your order")`;
+ const out = await george('/api/search', { query: { account: ACCOUNT, q, maxResults: 8 } });
+ const allSignals = new Set();
+ for (const m of (out.messages || [])) {
+ if (m.error) continue;
+ const hay = `${m.subject || ''} ${m.snippet || ''}`;
+ SIGNALS.filter(s => s.re.test(hay)).forEach(s => allSignals.add(s.key));
+ }
+ let level = 0;
+ for (const s of SIGNALS) if (allSignals.has(s.key)) level = Math.max(level, s.level);
+ // a keyword matched but no precise signal regex did → still worth a look
+ if (!level && (out.messages || []).some(m => !m.error)) level = 2;
+ const risk = level >= 3 ? 'high' : level >= 2 ? 'elevated' : 'clear';
+ const v = { email, risk, signals: [...allSignals].map(k => SIGNALS.find(s => s.key === k).label) };
+ cacheSet('risk:' + email, v);
+ res.json(v);
+ } catch (e) { res.status(e.status || 500).json({ error: e.message }); }
+});
+
+// ── API: send the followup in-thread (Steve clicks the button) ────────────
+app.post('/api/send', async (req, res) => {
+ try {
+ const { to, subject, body, threadId } = req.body || {};
+ if (!to || !body) return res.status(400).json({ error: 'to + body required' });
+ // reply to the most recent real (non-draft) message in the thread for proper headers
+ let replyToMessageId;
+ if (threadId) {
+ try {
+ const t = await george('/api/messages', { query: { account: ACCOUNT, q: `threadId:${threadId}`, maxResults: 25 } });
+ const real = (t.messages || []).filter(m => !(m.labelIds || []).includes('DRAFT'));
+ if (real.length) replyToMessageId = real[real.length - 1].id;
+ } catch { /* fall back to plain threadId send */ }
+ }
+ const payload = { account: ACCOUNT, to, subject, body, ...(threadId ? { threadId } : {}), ...(replyToMessageId ? { replyToMessageId } : {}) };
+ const sent = await george('/api/send', { method: 'POST', body: payload });
+ res.json({ ok: true, sent });
+ } catch (e) { res.status(e.status || 500).json({ error: e.message }); }
+});
+
+app.get('/api/health', (req, res) => res.json({ ok: true, george: GEORGE, account: ACCOUNT }));
+
+app.listen(PORT, () => console.log(`Pitch Guard → http://127.0.0.1:${PORT} (info@${OURS} via George)`));
(oldest)
·
back to Pitch Guard
·
move Pitch Guard to port 8123 dd9f2df →