From 0aee1058351e7c525c624a9302b65cafccfabc37 Mon Sep 17 00:00:00 2001 From: pavel Date: Mon, 23 Mar 2026 23:08:40 +0100 Subject: [PATCH] init --- .gitignore | 3 + README.md | 31 + config/imagemagick/policy.xml | 35 ++ package-lock.json | 1027 +++++++++++++++++++++++++++++++++ package.json | 19 + public/app.js | 64 ++ public/index.html | 56 ++ public/styles.css | 208 +++++++ server.js | 574 ++++++++++++++++++ 9 files changed, 2017 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 config/imagemagick/policy.xml create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 public/app.js create mode 100644 public/index.html create mode 100644 public/styles.css create mode 100644 server.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f10206 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +data +.env \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..dd3ce94 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Convertoor + +A small web app that lets a user upload audio, video, or image files, describe an edit in plain English, and have a Zen-powered agent complete it using only `ffmpeg` and ImageMagick (`magick`) commands. + +## Requirements + +- Node.js 22+ +- `ffmpeg` +- ImageMagick (`magick`) +- `ZEN_API_KEY` + +## Run + +```bash +npm install +ZEN_API_KEY=your_key_here npm start +``` + +Then open `http://localhost:3000`. + +Optionally set `ZEN_MODEL` if you want a different Zen model and `ZEN_BASE_URL` if you need a non-default endpoint. + +## Notes + +- Uploaded files and generated outputs are stored in `data//`. +- The backend never shells out through bash. It only spawns `ffmpeg` and `magick` directly. +- Command arguments are restricted to the per-job workspace so the agent cannot read or write outside the upload session. +- Uploads are validated server-side to only accept audio, video, and image MIME types. +- FFmpeg is run with a restricted protocol allowlist and blocked file-driven/script-like flags. +- ImageMagick is run with a local restrictive `policy.xml` in [config/imagemagick/policy.xml](/home/pavel/convertoor/config/imagemagick/policy.xml). +- Commands are killed after 60 seconds and final outputs larger than 250 MB are rejected. diff --git a/config/imagemagick/policy.xml b/config/imagemagick/policy.xml new file mode 100644 index 0000000..a2756f6 --- /dev/null +++ b/config/imagemagick/policy.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f7b0b2a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1027 @@ +{ + "name": "convertoor", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "convertoor", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "dotenv": "^17.3.1", + "express": "^5.2.1", + "mime-types": "^3.0.2", + "multer": "^2.1.1", + "openai": "^6.32.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/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==", + "license": "MIT" + }, + "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/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "license": "MIT" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, + "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/concat-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz", + "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==", + "engines": [ + "node >= 6.0" + ], + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.0.2", + "typedarray": "^0.0.6" + } + }, + "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/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": "17.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.3.1.tgz", + "integrity": "sha512-IO8C/dzEb6O3F9/twg6ZLXz164a2fhTnEWb95H23Dm4OuN+92NmEAlTrupP9VW6Jm3sO26tQlqyvyi4CsnY9GA==", + "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/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/multer": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-2.1.1.tgz", + "integrity": "sha512-mo+QTzKlx8R7E5ylSXxWzGoXoZbOsRMpyitcht8By2KHvMbf3tjwosZ/Mu/XYU6UuJ3VZnODIrak5ZrPiPyB6A==", + "license": "MIT", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.6.0", + "concat-stream": "^2.0.0", + "type-is": "^1.6.18" + }, + "engines": { + "node": ">= 10.16.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/multer/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/multer/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/multer/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/multer/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/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/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": "6.32.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-6.32.0.tgz", + "integrity": "sha512-j3k+BjydAf8yQlcOI7WUQMQTbbF5GEIMAE2iZYCOzwwB3S2pCheaWYp+XZRNAch4jWVc52PMDGRRjutao3lLCg==", + "license": "Apache-2.0", + "bin": { + "openai": "bin/cli" + }, + "peerDependencies": { + "ws": "^8.18.0", + "zod": "^3.25 || ^4.0" + }, + "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.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/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/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "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/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": "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/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/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/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "license": "MIT" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "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/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" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..f448ffe --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "convertoor", + "version": "1.0.0", + "description": "Agentic media converter powered by ffmpeg and ImageMagick", + "main": "server.js", + "scripts": { + "start": "node server.js" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "dotenv": "^17.3.1", + "express": "^5.2.1", + "mime-types": "^3.0.2", + "multer": "^2.1.1", + "openai": "^6.32.0" + } +} diff --git a/public/app.js b/public/app.js new file mode 100644 index 0000000..93ef10c --- /dev/null +++ b/public/app.js @@ -0,0 +1,64 @@ +const form = document.getElementById("job-form"); +const filesInput = document.getElementById("files"); +const promptInput = document.getElementById("prompt"); +const statusBox = document.getElementById("status"); +const resultBox = document.getElementById("result"); +const submitButton = document.getElementById("submit-button"); +const fileList = document.getElementById("file-list"); + +function setStatus(kind, message) { + statusBox.className = `status ${kind}`; + statusBox.textContent = message; +} + +function renderFiles() { + fileList.innerHTML = ""; + + for (const file of filesInput.files) { + const pill = document.createElement("div"); + pill.className = "file-pill"; + pill.textContent = `${file.name} (${Math.round(file.size / 1024)} KB)`; + fileList.appendChild(pill); + } +} + +filesInput.addEventListener("change", renderFiles); + +form.addEventListener("submit", async (event) => { + event.preventDefault(); + + resultBox.hidden = true; + resultBox.innerHTML = ""; + submitButton.disabled = true; + setStatus("busy", "Uploading files and processing them. This can take a little while."); + + try { + const payload = new FormData(); + for (const file of filesInput.files) { + payload.append("files", file); + } + payload.append("prompt", promptInput.value.trim()); + + const response = await fetch("/api/process", { + method: "POST", + body: payload, + }); + + const body = await response.json(); + + if (!response.ok) { + throw new Error(body.error || "The request failed."); + } + + setStatus("success", "Result ready."); + resultBox.hidden = false; + resultBox.innerHTML = ` + Result ready. + Download ${body.resultFile} + `; + } catch (error) { + setStatus("error", error.message); + } finally { + submitButton.disabled = false; + } +}); diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..aa7fd1d --- /dev/null +++ b/public/index.html @@ -0,0 +1,56 @@ + + + + + + Convertoor + + + + + + +
+
+

Media editing tool

+

Describe the media transformation you want.

+

+ Upload audio, video, or images, write your prompt in plain English, and the tool will produce a + downloadable result for you. +

+
+ +
+
+ + +
+ + + + +
+ +
Waiting for a job.
+ +
+
+ + + + diff --git a/public/styles.css b/public/styles.css new file mode 100644 index 0000000..174b7ac --- /dev/null +++ b/public/styles.css @@ -0,0 +1,208 @@ +:root { + color-scheme: light; + --bg: #f3efe6; + --bg-accent: #ddd1bd; + --panel: rgba(255, 251, 245, 0.86); + --text: #1d1a17; + --muted: #645a4e; + --line: rgba(29, 26, 23, 0.14); + --brand: #0c7c59; + --brand-dark: #095740; + --shadow: 0 24px 80px rgba(54, 36, 10, 0.16); +} + +* { + box-sizing: border-box; +} + +body { + margin: 0; + min-height: 100vh; + font-family: "Space Grotesk", sans-serif; + color: var(--text); + background: + radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 30%), + radial-gradient(circle at bottom right, rgba(12, 124, 89, 0.18), transparent 30%), + linear-gradient(135deg, var(--bg) 0%, var(--bg-accent) 100%); +} + +.shell { + width: min(960px, calc(100vw - 2rem)); + margin: 0 auto; + padding: 3rem 0 4rem; +} + +.hero { + padding: 2rem 0 1.5rem; + animation: rise 700ms ease; +} + +.eyebrow { + margin: 0 0 0.75rem; + text-transform: uppercase; + letter-spacing: 0.16em; + font-size: 0.78rem; + color: var(--brand-dark); +} + +h1 { + margin: 0; + max-width: 12ch; + font-size: clamp(2.8rem, 9vw, 5.8rem); + line-height: 0.95; +} + +.lede { + max-width: 48rem; + color: var(--muted); + font-size: 1.1rem; + line-height: 1.7; +} + +code, +textarea, +.status, +.file-pill { + font-family: "IBM Plex Mono", monospace; +} + +.panel { + padding: 1.5rem; + border: 1px solid var(--line); + border-radius: 28px; + background: var(--panel); + backdrop-filter: blur(18px); + box-shadow: var(--shadow); + animation: rise 900ms ease; +} + +#job-form { + display: grid; + gap: 1.25rem; +} + +.field { + display: grid; + gap: 0.55rem; +} + +.field span { + font-weight: 700; +} + +input[type="file"], +textarea { + width: 100%; + border: 1px solid var(--line); + border-radius: 18px; + background: rgba(255, 255, 255, 0.78); + color: var(--text); +} + +input[type="file"] { + padding: 1rem; +} + +textarea { + padding: 1rem 1.1rem; + resize: vertical; + min-height: 9rem; +} + +button { + justify-self: start; + padding: 0.95rem 1.35rem; + border: 0; + border-radius: 999px; + background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); + color: white; + font: inherit; + font-weight: 700; + cursor: pointer; + transition: transform 180ms ease, box-shadow 180ms ease; + box-shadow: 0 18px 40px rgba(12, 124, 89, 0.22); +} + +button:hover { + transform: translateY(-1px); +} + +button:disabled { + opacity: 0.68; + cursor: wait; +} + +.file-list { + display: flex; + flex-wrap: wrap; + gap: 0.65rem; + min-height: 1.5rem; +} + +.file-pill { + padding: 0.45rem 0.7rem; + border-radius: 999px; + background: rgba(12, 124, 89, 0.08); + border: 1px solid rgba(12, 124, 89, 0.18); + font-size: 0.82rem; +} + +.status, +.result { + margin-top: 1.25rem; + padding: 1rem 1.1rem; + border-radius: 18px; + border: 1px solid var(--line); +} + +.status.idle { + color: var(--muted); + background: rgba(255, 255, 255, 0.42); +} + +.status.busy { + color: #5f4309; + background: rgba(255, 210, 117, 0.24); +} + +.status.error { + color: #7a1c1c; + background: rgba(211, 75, 75, 0.12); +} + +.status.success { + color: #0b5f46; + background: rgba(12, 124, 89, 0.12); +} + +.result a { + color: var(--brand-dark); + font-weight: 700; +} + +@keyframes rise { + from { + opacity: 0; + transform: translateY(18px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +@media (max-width: 720px) { + .shell { + width: min(100vw - 1rem, 100%); + padding-top: 1.25rem; + } + + .panel { + padding: 1rem; + border-radius: 22px; + } + + h1 { + max-width: 100%; + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..cd1567d --- /dev/null +++ b/server.js @@ -0,0 +1,574 @@ +const dotenv = require("dotenv"); +dotenv.config(); + +const express = require("express"); +const fs = require("fs/promises"); +const fssync = require("fs"); +const path = require("path"); +const crypto = require("crypto"); +const multer = require("multer"); +const { spawn } = require("child_process"); +const OpenAI = require("openai"); +const mime = require("mime-types"); + +const app = express(); +const PORT = process.env.PORT || 3000; +const MODEL = process.env.ZEN_MODEL || "gpt-5.4-mini"; +const ZEN_BASE_URL = process.env.ZEN_BASE_URL || "https://opencode.ai/zen/v1"; +const DATA_DIR = path.join(__dirname, "data"); +const PUBLIC_DIR = path.join(__dirname, "public"); +const IMAGEMAGICK_CONFIG_DIR = path.join(__dirname, "config", "imagemagick"); +const MAX_FILES = 10; +const MAX_FILE_SIZE = 200 * 1024 * 1024; +const MAX_RESULT_SIZE = 250 * 1024 * 1024; +const COMMAND_TIMEOUT_MS = 60_000; + +const ALLOWED_UPLOAD_PREFIXES = ["audio/", "video/", "image/"]; +const DISALLOWED_FFMPEG_FLAGS = new Set([ + "-protocol_whitelist", + "-protocol_blacklist", + "-filter_script", + "-filter_complex_script", + "-progress", + "-report", + "-attach", + "-dump_attachment", +]); +const DISALLOWED_MAGICK_FLAGS = new Set([ + "-authenticate", + "-decipher", + "-encipher", +]); +const DISALLOWED_ARG_SNIPPETS = [ + "http://", + "https://", + "ftp://", + "tcp://", + "udp://", + "rtmp://", + "rtsp://", + "amqp://", + "sftp://", + "ssh://", + "gopher://", + "data:", + "pipe:", + "fd:", + "concat:", + "concatf:", + "subfile,", + "crypto:", +]; +const DISALLOWED_FFMPEG_VALUE_SNIPPETS = [ + "movie=", + "amovie=", + "textfile=", + "fontfile=", + "filename=", + "/etc/", + "../", +]; +const DISALLOWED_MAGICK_VALUE_SNIPPETS = [ + "@", + "caption:@", + "label:@", + "pango:", + "mvg:", + "msl:", + "svg:", + "/etc/", + "../", +]; + +const zen = process.env.ZEN_API_KEY + ? new OpenAI({ + apiKey: process.env.ZEN_API_KEY, + baseURL: ZEN_BASE_URL, + }) + : null; + +async function ensureDir(dirPath) { + await fs.mkdir(dirPath, { recursive: true }); +} + +function makeId() { + return crypto.randomUUID(); +} + +function sessionPath(sessionId) { + return path.join(DATA_DIR, sessionId); +} + +function safeBasename(name) { + const base = path.basename(name); + return base.replace(/[^a-zA-Z0-9._-]+/g, "_"); +} + +function sanitizeArg(arg, workDir) { + if (typeof arg !== "string" || !arg.trim()) { + throw new Error("All command arguments must be non-empty strings."); + } + + if (arg.includes("\0")) { + throw new Error("Null bytes are not allowed in command arguments."); + } + + if (arg.startsWith("-")) { + return arg; + } + + const candidate = path.resolve(workDir, arg); + if (!candidate.startsWith(workDir + path.sep) && candidate !== workDir) { + throw new Error(`Path escapes the session workspace: ${arg}`); + } + + return path.relative(workDir, candidate) || "."; +} + +function validateUpload(file) { + return ALLOWED_UPLOAD_PREFIXES.some((prefix) => file.mimetype.startsWith(prefix)); +} + +function validateArgValue(arg, disallowedSnippets, errorLabel) { + const lower = arg.toLowerCase(); + for (const snippet of DISALLOWED_ARG_SNIPPETS) { + if (lower.includes(snippet)) { + throw new Error(`${errorLabel} cannot use external protocols or stream-like inputs.`); + } + } + + for (const snippet of disallowedSnippets) { + if (lower.includes(snippet)) { + throw new Error(`${errorLabel} includes a blocked construct.`); + } + } +} + +function validateFfmpegArgs(args) { + for (const arg of args) { + if (DISALLOWED_FFMPEG_FLAGS.has(arg)) { + throw new Error(`Blocked ffmpeg flag: ${arg}`); + } + if (!arg.startsWith("-")) { + validateArgValue(arg, DISALLOWED_FFMPEG_VALUE_SNIPPETS, "ffmpeg argument"); + } + } +} + +function validateMagickArgs(args) { + for (const arg of args) { + if (DISALLOWED_MAGICK_FLAGS.has(arg)) { + throw new Error(`Blocked ImageMagick flag: ${arg}`); + } + if (!arg.startsWith("-")) { + validateArgValue(arg, DISALLOWED_MAGICK_VALUE_SNIPPETS, "ImageMagick argument"); + } + } +} + +function makeToolFailure(args, message, extra = {}) { + return { + ok: false, + code: null, + timedOut: false, + blocked: true, + stdout: "", + stderr: message, + args, + ...extra, + }; +} + +async function listFiles(workDir) { + const entries = await fs.readdir(workDir, { withFileTypes: true }); + return entries + .filter((entry) => entry.isFile()) + .map((entry) => entry.name) + .sort((a, b) => a.localeCompare(b)); +} + +async function runCommand(binary, args, workDir) { + try { + if (binary === "ffmpeg") { + validateFfmpegArgs(args); + } else if (binary === "magick") { + validateMagickArgs(args); + } + + const sanitizedArgs = args.map((arg) => sanitizeArg(arg, workDir)); + const commandArgs = + binary === "ffmpeg" + ? ["-nostdin", "-protocol_whitelist", "file,fd", ...sanitizedArgs] + : sanitizedArgs; + + return await new Promise((resolve) => { + const child = spawn(binary, commandArgs, { + cwd: workDir, + stdio: ["ignore", "pipe", "pipe"], + env: { + ...process.env, + MAGICK_CONFIGURE_PATH: IMAGEMAGICK_CONFIG_DIR, + }, + }); + + let stdout = ""; + let stderr = ""; + let timedOut = false; + const timer = setTimeout(() => { + timedOut = true; + child.kill("SIGKILL"); + }, COMMAND_TIMEOUT_MS); + + child.stdout.on("data", (chunk) => { + stdout += chunk.toString(); + }); + + child.stderr.on("data", (chunk) => { + stderr += chunk.toString(); + }); + + child.on("error", (error) => { + clearTimeout(timer); + resolve({ + ok: false, + code: null, + timedOut: false, + blocked: false, + stdout: "", + stderr: error.message, + args: commandArgs, + }); + }); + + child.on("close", (code) => { + clearTimeout(timer); + resolve({ + ok: !timedOut && code === 0, + code: timedOut ? null : code, + timedOut, + blocked: false, + stdout: stdout.slice(-12000), + stderr: stderr.slice(-12000), + args: commandArgs, + }); + }); + }); + } catch (error) { + return makeToolFailure(args, error.message); + } +} + +async function describeFiles(workDir) { + const files = await listFiles(workDir); + return files + .map((file) => { + const ext = path.extname(file).slice(1).toLowerCase() || "unknown"; + return `- ${file} (${ext})`; + }) + .join("\n"); +} + +async function runAgent({ prompt, sessionId }) { + if (!zen) { + throw new Error("ZEN_API_KEY is missing. Set it before running the app."); + } + + const workDir = sessionPath(sessionId); + const initialFiles = await describeFiles(workDir); + + const instructions = [ + "You are a media-editing agent.", + "You can only use the provided ffmpeg and ImageMagick tools.", + "Do not mention or attempt bash, shell pipelines, Python, or any other tool.", + "Only read from and write to files in the current session workspace.", + "Use filenames exactly as provided or create new output files in the same workspace.", + "Prefer preserving the original uploads and write outputs to new files.", + "If a tool output reports blocked=true, timedOut=true, or ok=false, revise your command and try again with safer simpler arguments.", + "When the task is complete, answer with JSON matching this schema:", + '{ "result_file": "filename.ext", "summary": "short description" }', + "The result_file must be a single file that exists in the workspace.", + "If you create intermediate files, pick the final downloadable output in result_file.", + ].join(" "); + + let response = await zen.responses.create({ + model: MODEL, + instructions, + input: [ + { + role: "user", + content: [ + { + type: "input_text", + text: `User prompt: ${prompt}\n\nFiles in workspace:\n${initialFiles}`, + }, + ], + }, + ], + text: { + format: { + type: "json_schema", + name: "media_result", + schema: { + type: "object", + additionalProperties: false, + properties: { + result_file: { type: "string" }, + summary: { type: "string" }, + }, + required: ["result_file", "summary"], + }, + }, + }, + tools: [ + { + type: "function", + name: "run_ffmpeg", + description: "Run a single ffmpeg command inside the current workspace.", + strict: true, + parameters: { + type: "object", + additionalProperties: false, + properties: { + args: { + type: "array", + items: { type: "string" }, + description: "Arguments for ffmpeg, not including the ffmpeg binary.", + }, + }, + required: ["args"], + }, + }, + { + type: "function", + name: "run_magick", + description: "Run a single ImageMagick magick command inside the current workspace.", + strict: true, + parameters: { + type: "object", + additionalProperties: false, + properties: { + args: { + type: "array", + items: { type: "string" }, + description: "Arguments for magick, not including the magick binary.", + }, + }, + required: ["args"], + }, + }, + ], + }); + + for (let step = 0; step < 12; step += 1) { + const toolCalls = (response.output || []).filter((item) => item.type === "function_call"); + if (!toolCalls.length) { + break; + } + + const toolOutputs = []; + + for (const call of toolCalls) { + const parsed = JSON.parse(call.arguments); + let result; + + console.log(`Session ${sessionId}: Executing tool call ${call.name} with arguments ${call.arguments}.`); + + if (call.name === "run_ffmpeg") { + result = await runCommand("ffmpeg", parsed.args, workDir); + } else if (call.name === "run_magick") { + result = await runCommand("magick", parsed.args, workDir); + } else { + throw new Error(`Unsupported tool requested: ${call.name}`); + } + + const filesAfter = await listFiles(workDir); + toolOutputs.push({ + type: "function_call_output", + call_id: call.call_id, + output: JSON.stringify({ + ...result, + files_after: filesAfter, + }), + }); + } + + response = await zen.responses.create({ + model: MODEL, + previous_response_id: response.id, + input: toolOutputs, + text: { + format: { + type: "json_schema", + name: "media_result", + schema: { + type: "object", + additionalProperties: false, + properties: { + result_file: { type: "string" }, + summary: { type: "string" }, + }, + required: ["result_file", "summary"], + }, + }, + }, + tools: [ + { + type: "function", + name: "run_ffmpeg", + description: "Run a single ffmpeg command inside the current workspace.", + strict: true, + parameters: { + type: "object", + additionalProperties: false, + properties: { + args: { + type: "array", + items: { type: "string" }, + }, + }, + required: ["args"], + }, + }, + { + type: "function", + name: "run_magick", + description: "Run a single ImageMagick magick command inside the current workspace.", + strict: true, + parameters: { + type: "object", + additionalProperties: false, + properties: { + args: { + type: "array", + items: { type: "string" }, + }, + }, + required: ["args"], + }, + }, + ], + }); + } + + const textOutput = response.output_text; + if (!textOutput) { + throw new Error("The agent did not return a final result."); + } + + const parsed = JSON.parse(textOutput); + const resultName = safeBasename(parsed.result_file); + const resultPath = path.join(workDir, resultName); + + if (!fssync.existsSync(resultPath)) { + throw new Error(`The agent returned a missing file: ${resultName}`); + } + + const stats = await fs.stat(resultPath); + if (stats.size > MAX_RESULT_SIZE) { + throw new Error(`The result file exceeds the maximum allowed size of ${MAX_RESULT_SIZE} bytes.`); + } + + console.log(`Session ${sessionId}: Agent completed with result file ${resultName} and summary: ${parsed.summary}`); + + return { + resultFile: resultName, + summary: parsed.summary, + }; +} + +const storage = multer.diskStorage({ + destination: async (req, file, cb) => { + try { + const sessionId = req.sessionId || makeId(); + req.sessionId = sessionId; + const dir = sessionPath(sessionId); + await ensureDir(dir); + cb(null, dir); + } catch (error) { + cb(error); + } + }, + filename: (req, file, cb) => { + cb(null, safeBasename(file.originalname)); + }, +}); + +const upload = multer({ + storage, + fileFilter: (req, file, cb) => { + if (!validateUpload(file)) { + cb(new Error("Only audio, video, and image uploads are allowed.")); + return; + } + + cb(null, true); + }, + limits: { + fileSize: MAX_FILE_SIZE, + files: MAX_FILES, + }, +}); + +app.use(express.json({ limit: "2mb" })); +app.use(express.static(PUBLIC_DIR)); + +app.post("/api/process", upload.array("files", MAX_FILES), async (req, res) => { + try { + const prompt = String(req.body.prompt || "").trim(); + + if (!prompt) { + return res.status(400).json({ error: "A prompt is required." }); + } + + if (!req.files || !req.files.length) { + return res.status(400).json({ error: "Upload at least one file." }); + } + + console.log(`Session ${req.sessionId}: Received prompt ${prompt} and files ${req.files.map((f) => f.originalname)}.`); + + const sessionId = req.sessionId; + const result = await runAgent({ prompt, sessionId }); + + return res.json({ + sessionId, + resultFile: result.resultFile, + downloadUrl: `/api/download/${sessionId}/${encodeURIComponent(result.resultFile)}`, + }); + } catch (error) { + return res.status(500).json({ + error: error.message || "Processing failed.", + }); + } +}); + +app.get("/api/download/:sessionId/:fileName", async (req, res) => { + const sessionId = safeBasename(req.params.sessionId); + const fileName = safeBasename(req.params.fileName); + const filePath = path.join(sessionPath(sessionId), fileName); + + if (!fssync.existsSync(filePath)) { + return res.status(404).json({ error: "File not found." }); + } + + const type = mime.lookup(fileName) || "application/octet-stream"; + res.setHeader("Content-Type", type); + res.download(filePath, fileName); +}); + +app.use((error, req, res, next) => { + if (error instanceof multer.MulterError) { + return res.status(400).json({ error: error.message }); + } + + if (error) { + return res.status(400).json({ error: error.message || "Request failed." }); + } + + return next(error); +}); + +ensureDir(DATA_DIR).then(() => { + app.listen(PORT, () => { + console.log(`Convertoor running at http://localhost:${PORT}`); + }); +});