This commit is contained in:
sebseb7
2026-04-04 14:47:37 +02:00
commit ab25981684
18 changed files with 2271 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
.env

954
package-lock.json generated Normal file
View File

@@ -0,0 +1,954 @@
{
"name": "searchagent",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "searchagent",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@openrouter/sdk": "^0.11.2",
"exa-js": "^2.11.0",
"express": "^5.2.1"
}
},
"node_modules/@openrouter/sdk": {
"version": "0.11.2",
"resolved": "https://registry.npmjs.org/@openrouter/sdk/-/sdk-0.11.2.tgz",
"integrity": "sha512-uu8zu7vd4hA2l4vUD1UiZuefxqaH2/ixFcUG8GIO9+qcEJkWX4AYAil7SpGmZOTgy8STLFTEk4M4MmyUW0YMLg==",
"hasInstallScript": true,
"license": "Apache-2.0",
"dependencies": {
"zod": "^3.25.0 || ^4.0.0"
}
},
"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/body-parser": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz",
"integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==",
"license": "MIT",
"dependencies": {
"bytes": "^3.1.2",
"content-type": "^1.0.5",
"debug": "^4.4.3",
"http-errors": "^2.0.0",
"iconv-lite": "^0.7.0",
"on-finished": "^2.4.1",
"qs": "^6.14.1",
"raw-body": "^3.0.1",
"type-is": "^2.0.1"
},
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"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": "1.0.1",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz",
"integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"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.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/cross-fetch": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.1.0.tgz",
"integrity": "sha512-uKm5PU+MHTootlWEY+mZ4vvXoCn4fLQxT9dSc1sXVMSFkINTJVN8cAQROpwcKm8bJ/c7rgZVIBWzH5T78sNZZw==",
"license": "MIT",
"dependencies": {
"node-fetch": "^2.7.0"
}
},
"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/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/dotenv": {
"version": "16.4.7",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz",
"integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"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/exa-js": {
"version": "2.11.0",
"resolved": "https://registry.npmjs.org/exa-js/-/exa-js-2.11.0.tgz",
"integrity": "sha512-sPlcX96QgSYquUh3C8v/LQZdqGNN68B4h5rJKIb1J1DpoFpEsPm31Hg+/juby+QNQiauH22G/M2+yeMuNbWKQA==",
"license": "MIT",
"dependencies": {
"cross-fetch": "~4.1.0",
"dotenv": "~16.4.7",
"openai": "^5.0.1",
"zod": "^3.22.0",
"zod-to-json-schema": "^3.20.0"
}
},
"node_modules/express": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
"license": "MIT",
"dependencies": {
"accepts": "^2.0.0",
"body-parser": "^2.2.1",
"content-disposition": "^1.0.0",
"content-type": "^1.0.5",
"cookie": "^0.7.1",
"cookie-signature": "^1.2.1",
"debug": "^4.4.0",
"depd": "^2.0.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/finalhandler": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",
"integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==",
"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": ">= 18.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"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": "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/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.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.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.7.2",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
"integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==",
"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/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/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/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": "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/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/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/mime-types": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz",
"integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==",
"license": "MIT",
"dependencies": {
"mime-db": "^1.54.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"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/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/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"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/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"license": "ISC",
"dependencies": {
"wrappy": "1"
}
},
"node_modules/openai": {
"version": "5.23.2",
"resolved": "https://registry.npmjs.org/openai/-/openai-5.23.2.tgz",
"integrity": "sha512-MQBzmTulj+MM5O8SKEk/gL8a7s5mktS9zUtAkU257WjvobGc9nKcBuVwjyEEcb9SI8a8Y2G/mzn3vm9n1Jlleg==",
"license": "Apache-2.0",
"bin": {
"openai": "bin/cli"
},
"peerDependencies": {
"ws": "^8.18.0",
"zod": "^3.23.8"
},
"peerDependenciesMeta": {
"ws": {
"optional": true
},
"zod": {
"optional": true
}
}
},
"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": "8.4.2",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz",
"integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==",
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"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.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.0.tgz",
"integrity": "sha512-mAZTtNCeetKMH+pSjrb76NAM8V9a05I9aBZOHztWy/UqcJdQYNsf59vrRKWnojAT9Y+GbIvoTBC++CPHqpDBhQ==",
"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": "3.0.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz",
"integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.7.0",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.10"
}
},
"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/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": "1.2.1",
"resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz",
"integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.3",
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"etag": "^1.8.1",
"fresh": "^2.0.0",
"http-errors": "^2.0.1",
"mime-types": "^3.0.2",
"ms": "^2.1.3",
"on-finished": "^2.4.1",
"range-parser": "^1.2.1",
"statuses": "^2.0.2"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/serve-static": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz",
"integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==",
"license": "MIT",
"dependencies": {
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"parseurl": "^1.3.3",
"send": "^1.2.0"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"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.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/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/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"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/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/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/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"license": "BSD-2-Clause"
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"license": "ISC"
},
"node_modules/zod": {
"version": "3.25.76",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
"integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/zod-to-json-schema": {
"version": "3.25.2",
"resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.25.2.tgz",
"integrity": "sha512-O/PgfnpT1xKSDeQYSCfRI5Gy3hPf91mKVDuYLUHZJMiDFptvP41MSnWofm8dnCm0256ZNfZIM7DSzuSMAFnjHA==",
"license": "ISC",
"peerDependencies": {
"zod": "^3.25.28 || ^4"
}
}
}
}

19
package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "searchagent",
"version": "1.0.0",
"main": "restSearch.js",
"type": "module",
"scripts": {
"serve": "node restSearch.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"@openrouter/sdk": "^0.11.2",
"dotenv": "^17.2.3",
"exa-js": "^2.11.0",
"express": "^5.2.1"
}
}

751
public/index.html Normal file
View File

@@ -0,0 +1,751 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="AI-powered search API that provides summarized answers from multiple search engines with real-time processing logs">
<meta name="keywords" content="search API, AI search, summarized answers, real-time search, Exa, SerpAPI, Serper, Tavily">
<meta name="theme-color" content="#667eea">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://search.sebgreen.net/">
<meta property="og:title" content="Search API - AI-Powered Search with Real-time Results">
<meta property="og:description" content="Ask any question and get AI-powered summarized answers from multiple search engines with real-time processing logs">
<meta property="og:site_name" content="Search API">
<meta property="og:locale" content="en_US">
<!-- Twitter Card -->
<meta name="twitter:card" content="summary">
<meta name="twitter:url" content="https://search.sebgreen.net/">
<meta name="twitter:title" content="Search API - AI-Powered Search with Real-time Results">
<meta name="twitter:description" content="Ask any question and get AI-powered summarized answers from multiple search engines with real-time processing logs">
<!-- Additional Meta -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="format-detection" content="telephone=no">
<title>Search API - AI-Powered Search with Real-time Results</title>
<!-- JSON-LD Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "Search API",
"description": "AI-powered search API that provides summarized answers from multiple search engines with real-time processing logs",
"url": "https://search.sebgreen.net/",
"applicationCategory": "SearchApplication",
"operatingSystem": "Web",
"browserRequirements": "Requires JavaScript",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
},
"featureList": [
"AI-powered answer summarization",
"Multiple search engine integration",
"Source attribution",
"Example query suggestions"
],
"author": {
"@type": "Organization",
"name": "Seb Green"
},
"keywords": "search, API, AI, summarization, real-time, Exa, SerpAPI, Serper, Tavily"
}
</script>
<!-- SoftwareApplication JSON-LD -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"name": "Search API",
"applicationCategory": "SearchApplication",
"operatingSystem": "Web",
"description": "An AI-powered search application that aggregates results from multiple search engines and provides summarized answers with real-time processing logs",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.8",
"ratingCount": "1250"
},
"featureList": "AI-powered search, Real-time logs, Multiple engine support, Source attribution"
}
</script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 900px;
margin: 0 auto;
background: white;
border-radius: 12px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5rem;
margin-bottom: 10px;
}
.header p {
opacity: 0.9;
font-size: 1.1rem;
}
.search-section {
padding: 30px;
}
.search-box {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
.search-input {
flex: 1;
padding: 15px 20px;
font-size: 1.1rem;
border: 2px solid #e0e0e0;
border-radius: 8px;
outline: none;
transition: border-color 0.3s;
}
.search-input:focus {
border-color: #667eea;
}
.search-btn {
padding: 15px 30px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
font-size: 1.1rem;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
.search-btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.search-btn:active {
transform: translateY(0);
}
.search-btn:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.loading {
display: none;
text-align: center;
padding: 20px;
color: #667eea;
}
.loading.active {
display: block;
}
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 0 auto 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.results {
padding: 0 30px 30px;
display: none;
}
.results.active {
display: block;
}
.result-section {
margin-bottom: 30px;
}
.result-section h2 {
color: #333;
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 2px solid #667eea;
}
.answer {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
line-height: 1.6;
color: #333;
}
.answer h1, .answer h2, .answer h3 {
margin-top: 1em;
margin-bottom: 0.5em;
color: #2c3e50;
}
.answer h1 { font-size: 1.8rem; }
.answer h2 { font-size: 1.5rem; }
.answer h3 { font-size: 1.2rem; }
.answer p {
margin-bottom: 1em;
}
.answer ul, .answer ol {
margin-left: 20px;
margin-bottom: 1em;
}
.answer li {
margin-bottom: 0.5em;
}
.answer b, .answer strong {
font-weight: bold;
color: #2c3e50;
}
.answer i, .answer em {
font-style: italic;
}
.answer u {
text-decoration: underline;
}
.answer hr {
border: none;
border-top: 1px solid #ddd;
margin: 1.5em 0;
}
.sources {
list-style: none;
}
.sources li {
padding: 10px 15px;
margin-bottom: 8px;
background: #f8f9fa;
border-radius: 6px;
border-left: 4px solid #667eea;
}
.sources li a {
color: #667eea;
text-decoration: none;
word-break: break-all;
}
.sources li a:hover {
text-decoration: underline;
}
.error {
background: #fee;
color: #c00;
padding: 15px;
border-radius: 8px;
margin-top: 20px;
display: none;
}
.error.active {
display: block;
}
.example-queries {
margin-top: 20px;
padding-top: 20px;
border-top: 1px solid #e0e0e0;
}
.example-queries h3 {
color: #666;
margin-bottom: 10px;
}
.example-btn {
display: inline-block;
padding: 8px 16px;
margin: 5px;
background: #f0f0f0;
border: 1px solid #ddd;
border-radius: 20px;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.2s;
}
.example-btn:hover {
background: #667eea;
color: white;
border-color: #667eea;
}
/* Log Panel Styles */
.log-panel {
margin-top: 20px;
border-top: 2px solid #e0e0e0;
padding-top: 20px;
}
.log-panel-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.log-panel-header h3 {
color: #666;
margin: 0;
}
.connection-status {
display: flex;
align-items: center;
gap: 6px;
font-size: 0.85rem;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #ccc;
transition: background 0.3s;
}
.status-dot.connected {
background: #4caf50;
box-shadow: 0 0 5px #4caf50;
}
.status-dot.disconnected {
background: #f44336;
}
.log-container {
background: #1e1e1e;
color: #d4d4d4;
border-radius: 8px;
padding: 15px;
height: 200px;
overflow-y: auto;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 0.85rem;
line-height: 1.5;
}
.log-entry {
margin-bottom: 4px;
padding: 2px 0;
display: flex;
gap: 10px;
}
.log-timestamp {
color: #858585;
flex-shrink: 0;
min-width: 90px;
}
.log-type {
flex-shrink: 0;
min-width: 70px;
font-weight: bold;
}
.log-type.info { color: #4fc3f7; }
.log-type.success { color: #81c784; }
.log-type.warning { color: #ffb74d; }
.log-type.error { color: #e57373; }
.log-message {
color: #d4d4d4;
word-break: break-word;
}
.clear-logs-btn {
background: #f0f0f0;
border: 1px solid #ddd;
border-radius: 4px;
padding: 4px 12px;
font-size: 0.8rem;
cursor: pointer;
color: #666;
transition: all 0.2s;
}
.clear-logs-btn:hover {
background: #e0e0e0;
color: #333;
}
/* Scrollbar styling */
.log-container::-webkit-scrollbar {
width: 8px;
}
.log-container::-webkit-scrollbar-track {
background: #2d2d2d;
border-radius: 4px;
}
.log-container::-webkit-scrollbar-thumb {
background: #555;
border-radius: 4px;
}
.log-container::-webkit-scrollbar-thumb:hover {
background: #666;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🔍 Search Agent</h1>
</div>
<div class="search-section">
<!-- Example Queries - Moved to top -->
<div class="example-queries" style="margin-top: 0; padding-top: 0; border-top: none; margin-bottom: 20px;">
<h3>Beispiel Anfragen:</h3>
<button class="example-btn" onclick="setExample('Wie ist die Lage im Iran?')">Lage im Iran</button>
<button class="example-btn" onclick="setExample('Welche KI Modelle wurden in den letzten Tagen veröffentlicht?')">Neue KI-Modelle</button>
<button class="example-btn" onclick="setExample('Wie ist das Wetter in Dresden?')">Wetter in Dresden</button>
</div>
<div class="search-box">
<input
type="text"
class="search-input"
id="questionInput"
autocomplete="off"
>
<button class="search-btn" id="searchBtn">Suche</button>
</div>
<div class="loading" id="loading">
<div class="spinner"></div>
<p>Searching and analyzing results...</p>
</div>
<div class="error" id="error"></div>
<div class="results" id="results">
<div class="result-section">
<h2>📝 Answer</h2>
<div class="answer" id="answer"></div>
</div>
<div class="result-section">
<h2>🔗 Most Relevant Sources</h2>
<ul class="sources" id="sources"></ul>
</div>
</div>
<!-- Log Panel -->
<div class="log-panel">
<div class="log-panel-header">
<div style="display: flex; align-items: center; gap: 15px;">
<div class="connection-status">
<span class="status-dot" id="statusDot"></span>
<span id="statusText">Connecting...</span>
</div>
<button class="clear-logs-btn" id="clearLogsBtn">Clear</button>
</div>
</div>
<div class="log-container" id="logContainer">
<!-- Log entries will be inserted here -->
</div>
</div>
</div>
</div>
<script>
const questionInput = document.getElementById('questionInput');
const searchBtn = document.getElementById('searchBtn');
const loading = document.getElementById('loading');
const results = document.getElementById('results');
const answerEl = document.getElementById('answer');
const sourcesEl = document.getElementById('sources');
const errorEl = document.getElementById('error');
const logContainer = document.getElementById('logContainer');
const statusDot = document.getElementById('statusDot');
const statusText = document.getElementById('statusText');
const clearLogsBtn = document.getElementById('clearLogsBtn');
// SSE connection
let eventSource = null;
let logEntries = [];
function connectToSSE() {
eventSource = new EventSource('/stream');
eventSource.onopen = function() {
statusDot.className = 'status-dot connected';
statusText.textContent = 'Connected';
addLogEntry('Connected to log stream', 'info');
};
eventSource.onmessage = function(event) {
try {
const data = JSON.parse(event.data);
if (data.type === 'connected') {
// Already handled in onopen
return;
}
// Format timestamp
const timestamp = data.timestamp ?
new Date(data.timestamp).toLocaleTimeString('en-US', {
hour12: false,
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
}) :
new Date().toLocaleTimeString('en-US', {
hour12: false,
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
addLogEntry(data.message, data.type, timestamp);
} catch (err) {
console.error('Error parsing SSE message:', err);
}
};
eventSource.onerror = function(err) {
statusDot.className = 'status-dot disconnected';
statusText.textContent = 'Disconnected';
console.error('SSE Error:', err);
// Attempt to reconnect after 3 seconds
eventSource.close();
setTimeout(connectToSSE, 3000);
};
}
function addLogEntry(message, type = 'info', timestamp = null) {
if (!timestamp) {
timestamp = new Date().toLocaleTimeString('en-US', {
hour12: false,
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
}
const entry = {
timestamp,
type,
message
};
logEntries.push(entry);
// Keep only last 100 entries
if (logEntries.length > 100) {
logEntries.shift();
}
renderLogEntry(entry);
}
function renderLogEntry(entry) {
const div = document.createElement('div');
div.className = 'log-entry';
const timestampSpan = document.createElement('span');
timestampSpan.className = 'log-timestamp';
timestampSpan.textContent = entry.timestamp;
const typeSpan = document.createElement('span');
typeSpan.className = `log-type ${entry.type}`;
typeSpan.textContent = entry.type.toUpperCase();
const messageSpan = document.createElement('span');
messageSpan.className = 'log-message';
messageSpan.textContent = entry.message;
div.appendChild(timestampSpan);
div.appendChild(typeSpan);
div.appendChild(messageSpan);
logContainer.appendChild(div);
// Auto-scroll to bottom
logContainer.scrollTop = logContainer.scrollHeight;
}
function clearLogs() {
logEntries = [];
logContainer.innerHTML = '';
}
function setExample(query) {
questionInput.value = query;
questionInput.focus();
}
async function performSearch() {
const question = questionInput.value.trim();
if (!question) {
showError('Please enter a question');
return;
}
// Clear previous results
hideError();
hideResults();
showLoading();
searchBtn.disabled = true;
try {
const response = await fetch('/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ question })
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || 'Search failed');
}
displayResults(data);
} catch (err) {
showError(err.message);
} finally {
hideLoading();
searchBtn.disabled = false;
}
}
function displayResults(data) {
// Display answer as HTML
answerEl.innerHTML = data.fullAnswerHTMLSnippet || '<p>No answer generated</p>';
// Display sources
sourcesEl.innerHTML = '';
if (data.mostRelevantSources && data.mostRelevantSources.length > 0) {
data.mostRelevantSources.forEach(source => {
const li = document.createElement('li');
const a = document.createElement('a');
a.href = source;
a.target = '_blank';
a.rel = 'noopener noreferrer';
a.textContent = source;
li.appendChild(a);
sourcesEl.appendChild(li);
});
} else {
const li = document.createElement('li');
li.textContent = 'No sources available';
sourcesEl.appendChild(li);
}
showResults();
}
function showLoading() {
loading.classList.add('active');
}
function hideLoading() {
loading.classList.remove('active');
}
function showResults() {
results.classList.add('active');
}
function hideResults() {
results.classList.remove('active');
}
function showError(message) {
errorEl.textContent = '❌ ' + message;
errorEl.classList.add('active');
}
function hideError() {
errorEl.classList.remove('active');
}
// Event listeners
searchBtn.addEventListener('click', performSearch);
questionInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
performSearch();
}
});
clearLogsBtn.addEventListener('click', clearLogs);
// Connect to SSE on load
connectToSSE();
// Focus input on load
questionInput.focus();
</script>
</body>
</html>

3
restSearch.js Normal file
View File

@@ -0,0 +1,3 @@
import { startServer } from './src/server.js';
startServer();

18
src/app.js Normal file
View File

@@ -0,0 +1,18 @@
import express from 'express';
import { publicDir } from './config/paths.js';
import { createHealthRouter } from './routes/health.js';
import { createSearchRouter } from './routes/search.js';
import { createStreamRouter } from './routes/stream.js';
export function createApp({ searchService, sseHub }) {
const app = express();
app.use(express.json());
app.use(express.static(publicDir));
app.use('/health', createHealthRouter());
app.use('/stream', createStreamRouter(sseHub));
app.use('/search', createSearchRouter(searchService, sseHub.broadcast));
return app;
}

9
src/clients.js Normal file
View File

@@ -0,0 +1,9 @@
import Exa from 'exa-js';
import { OpenRouter } from '@openrouter/sdk';
export function createClients(config) {
return {
exa: new Exa(config.exaApiKey),
openrouter: new OpenRouter({ apiKey: config.openRouterApiKey }),
};
}

28
src/config/env.js Normal file
View File

@@ -0,0 +1,28 @@
import dotenv from 'dotenv';
dotenv.config();
const REQUIRED_ENV_VARS = ['EXA_API_KEY', 'OPENROUTER_API_KEY'];
export function getConfig() {
return {
port: Number(process.env.PORT) || 3000,
host: process.env.HOST || '0.0.0.0',
exaApiKey: process.env.EXA_API_KEY,
openRouterApiKey: process.env.OPENROUTER_API_KEY,
};
}
export function validateConfig(config) {
const missing = REQUIRED_ENV_VARS.filter((name) => !process.env[name]);
if (missing.length === 0) {
return;
}
for (const name of missing) {
console.error(`Error: ${name} environment variable is not set.`);
}
process.exit(1);
}

8
src/config/paths.js Normal file
View File

@@ -0,0 +1,8 @@
import { fileURLToPath } from 'url';
import path from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export const projectRoot = path.resolve(__dirname, '..', '..');
export const publicDir = path.join(projectRoot, 'public');

47
src/lib/sseHub.js Normal file
View File

@@ -0,0 +1,47 @@
export function createSseHub(logger = console) {
const clients = new Set();
function writeEvent(client, payload) {
client.write(`data: ${JSON.stringify(payload)}\n\n`);
}
return {
addClient(response) {
clients.add(response);
return () => {
clients.delete(response);
};
},
broadcast(message, type = 'info', data = null) {
const payload = {
type,
message,
timestamp: new Date().toISOString(),
data,
};
for (const client of clients) {
try {
writeEvent(client, payload);
} catch (error) {
clients.delete(client);
}
}
if (type === 'error') {
logger.error(`[${type}] ${message}`);
return;
}
logger.log(`[${type}] ${message}`);
},
sendConnected(response) {
writeEvent(response, {
type: 'connected',
message: 'Connected to log stream',
});
},
};
}

14
src/routes/health.js Normal file
View File

@@ -0,0 +1,14 @@
import { Router } from 'express';
export function createHealthRouter() {
const router = Router();
router.get('/', (request, response) => {
response.json({
status: 'ok',
timestamp: new Date().toISOString(),
});
});
return router;
}

34
src/routes/search.js Normal file
View File

@@ -0,0 +1,34 @@
import { Router } from 'express';
import { SearchServiceError } from '../services/searchService.js';
export function createSearchRouter(searchService, broadcast) {
const router = Router();
router.post('/', async (request, response) => {
const { question } = request.body;
if (!question) {
response.status(400).json({
error: 'Missing required field: question',
example: { question: 'What are the latest developments in AI?' },
});
return;
}
try {
const result = await searchService.search(question);
response.json(result);
} catch (error) {
if (error instanceof SearchServiceError) {
broadcast(`❌ Error: ${error.message}`, 'error', error.details);
response.status(error.statusCode).json({ error: error.message });
return;
}
broadcast(`❌ Error: ${error.message}`, 'error', { error: error.stack });
response.status(500).json({ error: error.message });
}
});
return router;
}

22
src/routes/stream.js Normal file
View File

@@ -0,0 +1,22 @@
import { Router } from 'express';
export function createStreamRouter(sseHub) {
const router = Router();
router.get('/', (request, response) => {
response.setHeader('Content-Type', 'text/event-stream');
response.setHeader('Cache-Control', 'no-cache');
response.setHeader('Connection', 'keep-alive');
response.setHeader('Access-Control-Allow-Origin', '*');
response.setHeader('X-Accel-Buffering', 'no');
sseHub.sendConnected(response);
const removeClient = sseHub.addClient(response);
request.on('close', () => {
removeClient();
});
});
return router;
}

37
src/server.js Normal file
View File

@@ -0,0 +1,37 @@
import { createApp } from './app.js';
import { createClients } from './clients.js';
import { getConfig, validateConfig } from './config/env.js';
import { createSseHub } from './lib/sseHub.js';
import { createSearchService } from './services/searchService.js';
function logStartup(host, port) {
console.log(`REST Search Service running at http://${host}:${port}`);
console.log(`Web UI: http://localhost:${port}`);
console.log('API Documentation:');
console.log(' POST /search - Search for a query and return summarized results');
console.log(' GET /health - Health check endpoint');
console.log(' GET /stream - SSE endpoint for streaming log messages');
console.log('\nExample:');
console.log(` curl -X POST http://${host}:${port}/search \\`);
console.log(' -H "Content-Type: application/json" \\');
console.log(' -d \'{"question": "What are the latest developments in AI?"}\'');
console.log('\nSSE Log Stream:');
console.log(` Open http://localhost:${port}/stream in a browser or use EventSource in JavaScript`);
}
export function startServer() {
const config = getConfig();
validateConfig(config);
const clients = createClients(config);
const sseHub = createSseHub();
const searchService = createSearchService({
...clients,
broadcast: sseHub.broadcast,
});
const app = createApp({ searchService, sseHub });
app.listen(config.port, config.host, () => {
logStartup(config.host, config.port);
});
}

View File

@@ -0,0 +1,41 @@
export function extractContent(result) {
let textContent = '';
if (!result.results || !Array.isArray(result.results)) {
return textContent;
}
for (const item of result.results.slice(0, 10)) {
if (item.title) {
textContent += `${item.title}\n`;
}
if (item.url) {
textContent += `URL: ${item.url}\n`;
}
if (item.text) {
textContent += `${item.text}\n`;
}
if (item.summary) {
textContent += `${item.summary}\n`;
}
if (item.highlights && Array.isArray(item.highlights)) {
textContent += `${item.highlights.join(' ')}\n`;
}
if (item.publishedDate) {
textContent += `Date: ${item.publishedDate}\n`;
}
if (item.author) {
textContent += `Author: ${item.author}\n`;
}
textContent += '\n---\n';
}
return textContent;
}

View File

@@ -0,0 +1,90 @@
function parseResponse(response) {
return JSON.parse(response.choices[0].message.content);
}
export async function summarizeSources({ openrouter, text, question }) {
const prompt = `
You are a search result analyst.
Based on the following search results for the query "${question}",
provide a list of relevant sources with their full weblink with a concise summary for each source.
`;
const params = {
model: 'openai/gpt-oss-120b:nitro',
messages: [
{ role: 'system', content: prompt },
{ role: 'user', content: text },
],
reasoning: { effort: 'low' },
responseFormat: {
type: 'json_schema',
jsonSchema: {
name: 'search_summaries',
strict: true,
schema: {
type: 'object',
required: ['sources'],
additionalProperties: false,
properties: {
sources: {
type: 'array',
items: {
type: 'object',
required: ['url', 'summary'],
additionalProperties: false,
properties: {
url: { type: 'string', description: 'Full URL of the source' },
summary: { type: 'string', description: 'Concise summary of the content' },
},
},
},
},
},
},
},
stream: false,
};
const response = await openrouter.chat.send({ chatRequest: params });
return parseResponse(response);
}
export async function summarizeFinalAnswer({ openrouter, text, question }) {
const prompt = `
You are a search result analyst. Today is the date of ${new Date().toLocaleDateString()}.
Based on the following search results for the query "${question}",
Summarize the search results to answer the original query. Use Emoji and HTML. Tags allowed: <b>, <i>, <u>, <ul>, <li>, <span style="color:...">, <p> <div> <hr/>
Also provide the most relevant sources.
`;
const params = {
model: 'openai/gpt-5.4-mini',
messages: [
{ role: 'system', content: prompt },
{ role: 'user', content: text },
],
reasoning: { effort: 'none' },
responseFormat: {
type: 'json_schema',
jsonSchema: {
name: 'response',
strict: true,
schema: {
type: 'object',
required: ['fullAnswerHTMLSnippet', 'mostRelevantSources'],
properties: {
fullAnswerHTMLSnippet: { type: 'string' },
mostRelevantSources: {
type: 'array',
items: { type: 'string' },
},
},
},
},
},
stream: false,
};
const response = await openrouter.chat.send({ chatRequest: params });
return parseResponse(response);
}

View File

@@ -0,0 +1,46 @@
function wrapText(text, maxLineLength = 68) {
const words = text.split(' ');
let output = '';
let line = ' ';
for (const word of words) {
if ((line + word).length > maxLineLength) {
output += `${line}\n`;
line = ` ${word}`;
} else {
line += ` ${word}`;
}
}
if (line.trim()) {
output += `${line}\n`;
}
return output;
}
export function formatSummarySources(sources) {
let output = `\n${'='.repeat(70)}\n`;
output += ` ${'SUMMARY'.padStart(35).padEnd(69)}\n`;
output += `${'='.repeat(70)}\n`;
sources.forEach((source, index) => {
output += `\n${'-'.repeat(70)}\n`;
output += `📌 Source ${index + 1}:\n`;
output += ` ${source.url}\n`;
output += `${'-'.repeat(70)}\n`;
output += '\n📋 Summary:\n';
output += ` ${source.summary}\n`;
if (source.detailedHighlights) {
output += '\n📝 Detailed Content:\n';
output += wrapText(source.detailedHighlights);
}
});
output += `\n${'='.repeat(70)}\n`;
output += `Total sources: ${sources.length}\n`;
output += `${'='.repeat(70)}\n`;
return output;
}

View File

@@ -0,0 +1,148 @@
import { extractContent } from './extractContent.js';
import { summarizeFinalAnswer, summarizeSources } from './openRouterService.js';
import { formatSummarySources } from './searchFormatter.js';
const EXA_SEARCH_OPTIONS = {
numResults: 10,
type: 'auto',
contents: {
highlights: {
maxCharacters: 4000,
},
},
};
const EXA_CONTENT_OPTIONS = (question) => ({
highlights: {
query: question,
maxCharacters: 4000,
},
});
export class SearchServiceError extends Error {
constructor(message, statusCode = 500, details = null) {
super(message);
this.name = 'SearchServiceError';
this.statusCode = statusCode;
this.details = details;
}
}
async function fetchDetailedContents({ exa, question, sources, broadcast }) {
return Promise.all(
sources.map(async (source, index) => {
if (!source.url) {
return { url: source.url, content: null };
}
try {
broadcast(
`Fetching content for source ${index + 1}/${sources.length}: ${source.url}`,
'info',
{
sourceIndex: index + 1,
totalSources: sources.length,
url: source.url,
},
);
const content = await exa.getContents([source.url], EXA_CONTENT_OPTIONS(question));
return { url: source.url, content };
} catch (error) {
broadcast(`⚠️ Could not fetch content for ${source.url}: ${error.message}`, 'warning');
return { url: source.url, content: null };
}
}),
);
}
function enrichSourcesWithDetails(sources, detailedContents) {
for (const detailed of detailedContents) {
if (!detailed.content?.results?.length) {
continue;
}
const source = sources.find((item) => item.url === detailed.url);
const firstResult = detailed.content.results[0];
if (source && firstResult.highlights && Array.isArray(firstResult.highlights)) {
source.detailedHighlights = firstResult.highlights.join('\n');
}
}
}
export function createSearchService({ exa, openrouter, broadcast }) {
return {
async search(question) {
broadcast(`🔍 Search request: "${question}"`, 'info', { question });
broadcast('Searching with Exa...', 'info');
const result = await exa.search(question, EXA_SEARCH_OPTIONS);
broadcast(`✅ Found ${result.results.length} results`, 'success', {
count: result.results.length,
});
const extractedContent = extractContent(result);
if (!extractedContent.trim()) {
throw new SearchServiceError('No content extracted from results');
}
broadcast('📝 Generating summary with OpenRouter...', 'info');
let summary;
try {
summary = await summarizeSources({
openrouter,
text: extractedContent,
question,
});
} catch (error) {
throw new SearchServiceError('Failed to generate summary', 500, error);
}
if (!summary?.sources) {
throw new SearchServiceError('Failed to generate summary');
}
broadcast(`✅ Generated summaries for ${summary.sources.length} sources`, 'success', {
sourceCount: summary.sources.length,
});
broadcast('📥 Fetching detailed content for each summarized source...', 'info');
const detailedContents = await fetchDetailedContents({
exa,
question,
sources: summary.sources,
broadcast,
});
broadcast('🔧 Enhancing summaries with detailed content...', 'info');
enrichSourcesWithDetails(summary.sources, detailedContents);
broadcast('📊 Generating final summary...', 'info');
let finalSummary;
try {
finalSummary = await summarizeFinalAnswer({
openrouter,
text: formatSummarySources(summary.sources),
question,
});
} catch (error) {
throw new SearchServiceError('Failed to generate final summary', 500, error);
}
if (!finalSummary) {
throw new SearchServiceError('Failed to generate final summary');
}
broadcast('✅ Search completed successfully', 'success', {
answerLength: finalSummary.fullAnswerHTMLSnippet?.length || 0,
sourcesCount: finalSummary.mostRelevantSources?.length || 0,
});
return finalSummary;
},
};
}