diff --git a/.railway/railway.ts b/.railway/railway.ts index cb1cf7e0..1eec44ba 100644 --- a/.railway/railway.ts +++ b/.railway/railway.ts @@ -21,6 +21,8 @@ const VARIABLES: Record = { "SENTRY_DSN", "SENTRY_TRACES_SAMPLE_RATE", "WEB_CONCURRENCY", + // Turns on the MCP App (src/late/mcp/apps): interactive views in Claude and ChatGPT. + "ZERNIO_MCP_APPS", ], "zernio-mcp-dev": ["MCP_PUBLIC_URL", "PORT", "SENTRY_DSN"], dev: ["MCP_PUBLIC_URL", "PORT"], diff --git a/apps-src/.gitignore b/apps-src/.gitignore new file mode 100644 index 00000000..c2658d7d --- /dev/null +++ b/apps-src/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/apps-src/mcp-app.html b/apps-src/mcp-app.html new file mode 100644 index 00000000..3a911ef0 --- /dev/null +++ b/apps-src/mcp-app.html @@ -0,0 +1,13 @@ + + + + + + + Zernio + + +
+ + + diff --git a/apps-src/package-lock.json b/apps-src/package-lock.json new file mode 100644 index 00000000..5be3d65a --- /dev/null +++ b/apps-src/package-lock.json @@ -0,0 +1,1611 @@ +{ + "name": "zernio-mcp-app", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "zernio-mcp-app", + "dependencies": { + "@modelcontextprotocol/client": "2.4.0", + "@modelcontextprotocol/core": "2.4.0", + "@modelcontextprotocol/ext-apps": "2.0.4", + "pixelarticons": "2.4.2", + "react": "19.3.1", + "react-dom": "19.3.1", + "zod": "4.6.7" + }, + "devDependencies": { + "@types/react": "19.3.0", + "@types/react-dom": "19.3.0", + "@vitejs/plugin-react": "6.3.0", + "typescript": "7.0.2", + "vite": "8.3.8", + "vite-plugin-singlefile": "2.3.4" + } + }, + "node_modules/@emnapi/core": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", + "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "2.2.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", + "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", + "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@modelcontextprotocol/client": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/client/-/client-2.4.0.tgz", + "integrity": "sha512-LgrD2OphHuG12vfKFKz6SOnq7bKHQmhGJIAYdD+MZBn2npHEyry6uD8zvktodtl5CQM85MO0anUyD9JwmUmxww==", + "license": "Apache-2.0", + "dependencies": { + "@modelcontextprotocol/core": "2.4.0", + "cross-spawn": "^7.0.5", + "eventsource": "^3.0.2", + "eventsource-parser": "^3.0.8", + "jose": "^6.1.3", + "pkce-challenge": "^5.0.0", + "zod": "^4.2.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@modelcontextprotocol/core": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/core/-/core-2.4.0.tgz", + "integrity": "sha512-z8QBKqdfXLPzkLQuG4xp8hrVEMm1PZ1IgxMN2sMbJiFiAKOWXnAzogXn2W4aqIBlP1ea6U5yiqVquvUNM1Cj6Q==", + "license": "Apache-2.0", + "dependencies": { + "zod": "^4.2.0" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@modelcontextprotocol/ext-apps": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/ext-apps/-/ext-apps-2.0.4.tgz", + "integrity": "sha512-B+PcbuGiaf0e5I3uy4iO5tS3Abo+5w8JvZFzHMzQdq9yVwP836zJkw2+KCGOQ0r4TM1fuQi4JdnbuWjkS4aBvg==", + "license": "MIT", + "workspaces": [ + "examples/*" + ], + "dependencies": { + "@standard-schema/spec": "^1.1.0" + }, + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "@modelcontextprotocol/client": "^2.0.0", + "@modelcontextprotocol/core": "^2.0.0", + "@modelcontextprotocol/server": "^2.0.0", + "react": "^17.0.0 || ^18.0.0 || ^19.0.0", + "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0", + "zod": "^4.2.0" + }, + "peerDependenciesMeta": { + "@modelcontextprotocol/server": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", + "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", + "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", + "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", + "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", + "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", + "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", + "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", + "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", + "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", + "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", + "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", + "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", + "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", + "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", + "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", + "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz", + "integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "license": "MIT" + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz", + "integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/react": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", + "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz", + "integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.3.0" + } + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-6.3.0.tgz", + "integrity": "sha512-H9E955aVvD2F4zNHCw4eIZbIfF6xKldlh7MNu+hSU7xwQzh65lI/N+CJWqmfhi0PEjDXIt/H7T7J/4wU63KJiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rolldown/pluginutils": "^1.0.1" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0 || ^0.3.0", + "babel-plugin-react-compiler": "^1.0.0", + "oxc-transform-react": ">=0.152.0 <0.157.0", + "vite": "^8.0.0" + }, + "peerDependenciesMeta": { + "@rolldown/plugin-babel": { + "optional": true + }, + "babel-plugin-react-compiler": { + "optional": true + }, + "oxc-transform-react": { + "optional": true + } + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/csstype": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.4.tgz", + "integrity": "sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/eventsource": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz", + "integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==", + "license": "MIT", + "dependencies": { + "eventsource-parser": "^3.0.1" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/eventsource-parser": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.1.tgz", + "integrity": "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==", + "license": "MIT", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "license": "ISC" + }, + "node_modules/jose": { + "version": "6.2.17", + "resolved": "https://registry.npmjs.org/jose/-/jose-6.2.17.tgz", + "integrity": "sha512-wOuK9V1yujQFH5S0ZWmLcDZN7+IKh9bUCC2ZPCf2HDlol3WWHy+PPyNjEI75FXRLMp3vDKQcupP59xhVU95hcg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/panva" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pixelarticons": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/pixelarticons/-/pixelarticons-2.4.2.tgz", + "integrity": "sha512-BZKSU5ckLuioZCzES4fEmdQfnI8XEiQlHljdIVk+N6+KH7vTBQJNtMs+V0LQF7nC7cZbKT0qBXFOsT35sl8uhg==", + "license": "MIT", + "bin": { + "pixelarticons": "bin/upgrade.js" + }, + "peerDependencies": { + "react": ">=16" + } + }, + "node_modules/pkce-challenge": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-5.0.1.tgz", + "integrity": "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ==", + "license": "MIT", + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/postcss": { + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/react": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", + "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz", + "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.28.0" + }, + "peerDependencies": { + "react": "^19.3.1" + } + }, + "node_modules/rolldown": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", + "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.156.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.19", + "@rolldown/binding-android-arm64": "1.2.19", + "@rolldown/binding-darwin-arm64": "1.2.19", + "@rolldown/binding-darwin-x64": "1.2.19", + "@rolldown/binding-freebsd-x64": "1.2.19", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", + "@rolldown/binding-linux-arm64-gnu": "1.2.19", + "@rolldown/binding-linux-arm64-musl": "1.2.19", + "@rolldown/binding-linux-ppc64-gnu": "1.2.19", + "@rolldown/binding-linux-s390x-gnu": "1.2.19", + "@rolldown/binding-linux-x64-gnu": "1.2.19", + "@rolldown/binding-linux-x64-musl": "1.2.19", + "@rolldown/binding-openharmony-arm64": "1.2.19", + "@rolldown/binding-wasm32-wasi": "1.2.19", + "@rolldown/binding-win32-arm64-msvc": "1.2.19", + "@rolldown/binding-win32-x64-msvc": "1.2.19" + } + }, + "node_modules/scheduler": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", + "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==", + "license": "MIT" + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "optionalDependencies": { + "@typescript/typescript-aix-ppc64": "7.0.2", + "@typescript/typescript-darwin-arm64": "7.0.2", + "@typescript/typescript-darwin-x64": "7.0.2", + "@typescript/typescript-freebsd-arm64": "7.0.2", + "@typescript/typescript-freebsd-x64": "7.0.2", + "@typescript/typescript-linux-arm": "7.0.2", + "@typescript/typescript-linux-arm64": "7.0.2", + "@typescript/typescript-linux-loong64": "7.0.2", + "@typescript/typescript-linux-mips64el": "7.0.2", + "@typescript/typescript-linux-ppc64": "7.0.2", + "@typescript/typescript-linux-riscv64": "7.0.2", + "@typescript/typescript-linux-s390x": "7.0.2", + "@typescript/typescript-linux-x64": "7.0.2", + "@typescript/typescript-netbsd-arm64": "7.0.2", + "@typescript/typescript-netbsd-x64": "7.0.2", + "@typescript/typescript-openbsd-arm64": "7.0.2", + "@typescript/typescript-openbsd-x64": "7.0.2", + "@typescript/typescript-sunos-x64": "7.0.2", + "@typescript/typescript-win32-arm64": "7.0.2", + "@typescript/typescript-win32-x64": "7.0.2" + } + }, + "node_modules/vite": { + "version": "8.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.8.tgz", + "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.32", + "rolldown": "~1.2.18", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1 || ^0.8.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-plugin-singlefile": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/vite-plugin-singlefile/-/vite-plugin-singlefile-2.3.4.tgz", + "integrity": "sha512-1FAhlTCL6KJDpSUudrVU+gspapvS+tmKCg70vwNaAU6tyXn3E/C6+NnwQIze06byhBRv7VggZ78K0h+J/Rsdrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^4.0.7" + }, + "engines": { + "node": ">18.0.0" + }, + "peerDependencies": { + "rollup": "^4.59.0", + "vite": "^5.4.21 || ^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/zod": { + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/apps-src/package.json b/apps-src/package.json new file mode 100644 index 00000000..adfa4928 --- /dev/null +++ b/apps-src/package.json @@ -0,0 +1,28 @@ +{ + "name": "zernio-mcp-app", + "private": true, + "type": "module", + "description": "The Zernio MCP App (the interactive view Claude and ChatGPT render). Built into ../src/late/mcp/apps/bundle/app.html, which the Python server serves.", + "scripts": { + "build": "tsc --noEmit && vite build", + "dev": "vite build --watch", + "typecheck": "tsc --noEmit" + }, + "dependencies": { + "@modelcontextprotocol/client": "2.4.0", + "@modelcontextprotocol/core": "2.4.0", + "@modelcontextprotocol/ext-apps": "2.0.4", + "pixelarticons": "2.4.2", + "react": "19.3.1", + "react-dom": "19.3.1", + "zod": "4.6.7" + }, + "devDependencies": { + "@types/react": "19.3.0", + "@types/react-dom": "19.3.0", + "@vitejs/plugin-react": "6.3.0", + "typescript": "7.0.2", + "vite": "8.3.8", + "vite-plugin-singlefile": "2.3.4" + } +} diff --git a/apps-src/src/api.ts b/apps-src/src/api.ts new file mode 100644 index 00000000..75fe89bd --- /dev/null +++ b/apps-src/src/api.ts @@ -0,0 +1,245 @@ +/** + * The screens, the tool that opens each one, and the shapes of their data. + * + * Every screen comes from one of the server's tools as structuredContent + * `{view, data, args}` (src/late/mcp/apps/tools.py). The app switches screens + * and refreshes by calling those same tools through the host + * (app.callServerTool), so the user's scopes and the API's validation apply + * as they do for Claude. + */ +import type { App } from "@modelcontextprotocol/ext-apps"; + +export type View = "home" | "posts" | "analytics" | "accounts" | "ads" | "inbox" | "conversation" | "comments" | "preview"; + +export const TOOLS: Record = { + home: "zernio_open_app", + posts: "show_failed_posts", + analytics: "show_analytics", + accounts: "show_account_health", + ads: "show_ads_alerts", + inbox: "show_inbox", + conversation: "show_conversation", + comments: "show_post_comments", + preview: "show_post_preview", +}; + +export const VIEW_TITLES: Record = { + home: "Home", + posts: "Failed posts", + analytics: "Analytics", + accounts: "Accounts", + ads: "Ads", + inbox: "Inbox", + conversation: "Conversation", + comments: "Comments", + preview: "Post preview", +}; + +/** The screens with a tab; the others open from a tool with their own arguments. */ +export const TABS: View[] = ["home", "inbox", "posts", "analytics", "accounts", "ads"]; + +export interface Screen { + view: View; + data: D; + args: Record; +} + +export type CallResult = Awaited>; + +export function textOf(result: CallResult): string { + return result.content.map((block) => (block.type === "text" ? block.text : "")).join(""); +} + +/** The screen a tool result carries, or undefined when it is not one of ours. */ +export function screenOf(result: CallResult): Screen | undefined { + const sc = result.structuredContent as Partial | undefined; + if (!sc || typeof sc.view !== "string" || !(sc.view in TOOLS)) return undefined; + return { view: sc.view as View, data: sc.data, args: (sc.args as Record) ?? {} }; +} + +/* Data of each screen */ + +export interface Account { + accountId: string; + platform: string; + profileId?: string; + username?: string; + displayName?: string; + status: "healthy" | "warning" | "error"; + needsReconnect?: boolean; + issues?: string[]; + disconnectReason?: string | null; +} + +export interface AccountsHealth { + summary?: { total?: number; healthy?: number; warning?: number; error?: number; needsReconnect?: number }; + accounts?: Account[]; +} + +export interface FailedPost { + id: string; + title: string; + content: string; + platforms: string[]; + errors: { platform: string | null; message: string }[]; + updatedAt: string | null; +} + +export interface HomeData { + health: AccountsHealth; + failedPosts: FailedPost[]; + failedTotal: number; +} + +export interface PostsData { + posts: FailedPost[]; + total: number; +} + +export interface Metrics { + impressions?: number; + reach?: number; + likes?: number; + comments?: number; + shares?: number; + saves?: number; + clicks?: number; + views?: number; +} + +export interface AnalyticsData { + dailyData?: { date: string; postCount?: number; metrics?: Metrics }[]; + platformBreakdown?: (Metrics & { platform: string; postCount?: number })[]; + totals?: Metrics & { postCount?: number; engagement?: number }; +} + +export interface AdsAlert { + id: string; + kind?: string; + severity: "error" | "warning" | "info"; + title: string; + message?: string; + platform?: string; + entity?: { level?: string; id?: string; name?: string | null }; + fix?: { label?: string; url?: string }; +} + +export interface AdsData { + alerts?: AdsAlert[]; + counts?: { error?: number; warning?: number; info?: number }; +} + +export interface Conversation { + id: string; + platform: string; + accountId: string; + accountUsername?: string | null; + participantName?: string | null; + lastMessage?: string | null; + updatedTime?: string | null; + unreadCount?: number | null; + isGroup?: boolean | null; +} + +export interface CommentedPost { + id: string; + platform: string; + accountId: string; + accountUsername?: string | null; + content?: string | null; + createdTime?: string | null; + commentCount?: number | null; +} + +export interface InboxData { + conversations: Conversation[]; + posts: CommentedPost[]; +} + +export interface Message { + id: string; + message?: string | null; + senderName?: string | null; + direction?: "incoming" | "outgoing" | string | null; + createdAt?: string | null; + isDeleted?: boolean | null; + attachments: number; +} + +export interface ConversationData { + conversationId: string; + accountId: string; + messages: Message[]; +} + +export interface Comment { + id: string; + message?: string | null; + createdTime?: string | null; + likeCount?: number | null; + replyCount?: number | null; + canReply?: boolean | null; + isHidden?: boolean | null; + from: { name?: string | null; username?: string | null; isOwner?: boolean | null }; +} + +export interface CommentsData { + postId: string; + accountId: string; + post: { text?: string | null; permalink?: string | null; createdAt?: string | null }; + comments: Comment[]; +} + +export interface PreviewData { + content: string; + media: { type?: string; url: string }[]; + targets: { platform: string; accountId?: string; handle?: string; error?: string }[]; + validation?: { + valid?: boolean; + errors?: { platform?: string; error: string }[]; + warnings?: { platform?: string; warning: string }[]; + } | null; + request: Record; +} + +/* Platforms */ + +const PLATFORMS: Record = { + twitter: "X", x: "X", instagram: "Instagram", facebook: "Facebook", linkedin: "LinkedIn", + tiktok: "TikTok", youtube: "YouTube", threads: "Threads", pinterest: "Pinterest", + reddit: "Reddit", bluesky: "Bluesky", googlebusiness: "Google Business", + telegram: "Telegram", snapchat: "Snapchat", discord: "Discord", slack: "Slack", + whatsapp: "WhatsApp", meta: "Meta", google: "Google", microsoft: "Microsoft", + openai: "ChatGPT", linkedinads: "LinkedIn Ads", metaads: "Meta Ads", tiktokads: "TikTok Ads", + googleads: "Google Ads", pinterestads: "Pinterest Ads", xads: "X Ads", redditads: "Reddit Ads", +}; + +export function platformName(platform: string | null | undefined): string { + if (!platform) return "Unknown"; + return PLATFORMS[platform] ?? platform.charAt(0).toUpperCase() + platform.slice(1); +} + +/** The platform's full-colour app icon, as the dashboard shows it (zernio.com/platform-logos). */ +const ICON_FILES: Record = { + twitter: "x", xads: "x", googlebusiness: "google", google: "googleads", openai: "chatgpt", + metaads: "meta", linkedinads: "linkedin", tiktokads: "tiktok", pinterestads: "pinterest", + redditads: "reddit", googleads: "googleads", +}; + +export function platformIcon(platform: string): string { + return `https://zernio.com/platform-logos/${ICON_FILES[platform] ?? platform}-icon.png`; +} + +/* Formatting */ + +export function formatNumber(value: number | undefined, locale?: string, compact = false): string { + if (value === undefined || value === null) return "—"; + return new Intl.NumberFormat(locale, compact ? { notation: "compact", maximumFractionDigits: 1 } : undefined).format(value); +} + +export function formatDate(value: string | null | undefined, locale?: string, options?: Intl.DateTimeFormatOptions): string { + if (!value) return "—"; + const date = new Date(value); + if (Number.isNaN(date.getTime())) return value; + return date.toLocaleDateString(locale, options ?? { month: "short", day: "numeric" }); +} diff --git a/apps-src/src/fonts.ts b/apps-src/src/fonts.ts new file mode 100644 index 00000000..c5e15410 --- /dev/null +++ b/apps-src/src/fonts.ts @@ -0,0 +1,23 @@ +/** + * Geist, Geist Mono and Geist Pixel Square, the design system's three faces. + * MCP Apps allow fonts only from declared origins (no data: URLs), so the MCP + * server serves them; it writes its own public URL over ZERNIO_ORIGIN when it + * serves this bundle, and lists that origin in the resource's CSP. + */ +const ORIGIN = "__ZERNIO_ORIGIN__"; + +const FACES = [ + { family: "Geist", file: "Geist-Variable.woff2", weight: "100 900" }, + { family: "Geist Mono", file: "GeistMono-Variable.woff2", weight: "100 900" }, + { family: "Geist Pixel Square", file: "GeistPixel-Square.woff2", weight: "500" }, +]; + +export function installFonts(): void { + if (ORIGIN.startsWith("__")) return; + const style = document.createElement("style"); + style.textContent = FACES.map( + (f) => + `@font-face{font-family:"${f.family}";src:url("${ORIGIN}/apps/fonts/${f.file}") format("woff2");font-weight:${f.weight};font-display:swap}`, + ).join(""); + document.head.appendChild(style); +} diff --git a/apps-src/src/global.css b/apps-src/src/global.css new file mode 100644 index 00000000..c31865b8 --- /dev/null +++ b/apps-src/src/global.css @@ -0,0 +1,310 @@ +/* + * The Zernio product look (v2), as the dashboard draws it under data-look="v2". + * Values are the Figma `Product` file's, copied from Schedule-Posts-API + * libs/design-system/new-look.ts: `Theme` (light and dark, from `Primitives`), + * `Scale` (sizes, radius, spacing) and the `type/*` text styles. Change them + * there first; this file follows. + * + * In Claude the host's surface shows through: the page is transparent inline, + * the panels are bg/raised. Dark mode follows the host's theme (data-theme, + * which useHostStyles sets from the host context). + */ +:root { + /* Theme, light */ + --bg-base: #faf9f8; + --bg-raised: #ffffff; + --bg-overlay: #ffffff; + --bg-inverse: #1a1a1a; + --fill-primary: #faf9f8; + --fill-hover: rgb(92 68 37 / 0.03); + --fill-selected: rgb(92 68 37 / 0.05); + --fill-active: rgb(92 68 37 / 0.05); + --text-primary: #1a1a1a; + --text-secondary: #525252; + --text-tertiary: #6b6b6b; + --text-placeholder: #a3a3a3; + --text-inverse: #ffffff; + --text-link: #1e4a7c; + --text-disabled: #d4d4d4; + --border-default: #e4e4e4; + --border-subtle: #f2f2f2; + --border-focus: #1a1a1a; + --brand-default: #eb3514; + --brand-hover: #d12c0e; + --brand-subtle: #fbe8e5; + --status-success-fg: #15803d; + --status-success-bg: #e3f4e9; + --status-warning-fg: #7c4a18; + --status-warning-bg: #fff3c5; + --status-danger-fg: #b9342e; + --status-danger-bg: #fbe0e0; + --status-info-fg: #1e4a7c; + --status-info-bg: #e4eefb; + --shadow-color: rgb(0 0 0 / 0.1); + --chart-3: #1e4a7c; + + /* Scale */ + --size-control-sm: 28px; + --size-control-md: 32px; + --size-control-lg: 36px; + --size-icon-sm: 12px; + --size-icon-md: 16px; + --size-row: 40px; + --radius-surface: 0px; + --radius-control: 0px; + --radius-item: 4px; + --radius-item-lg: 6px; + + /* Type families */ + --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; + --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; + --font-pixel: "Geist Pixel Square", "Geist Mono", ui-monospace, Menlo, monospace; + + color-scheme: light; +} + +/* Theme, dark */ +:root[data-theme="dark"] { + --bg-base: #0f0f10; + --bg-raised: #151516; + --bg-overlay: #151516; + --bg-inverse: #1a1a1a; + --fill-primary: #0f0f10; + --fill-hover: rgb(255 255 255 / 0.04); + --fill-selected: rgb(255 255 255 / 0.06); + --fill-active: rgb(255 255 255 / 0.06); + --text-primary: #fafafa; + --text-secondary: #d4d4d4; + --text-tertiary: #a3a3a3; + --text-placeholder: #6b6b6b; + --text-inverse: #ffffff; + --text-link: #7ed4fc; + --text-disabled: #333333; + --border-default: #212122; + --border-subtle: #1c1c1d; + --border-focus: #fafafa; + --brand-subtle: #261514; + --status-success-fg: #6ee7b7; + --status-success-bg: #0d2418; + --status-warning-fg: #fcd44f; + --status-warning-bg: #2b1f0a; + --status-danger-fg: #fca6a6; + --status-danger-bg: #2b1414; + --status-info-fg: #7ed4fc; + --status-info-bg: #0e1c2e; + --shadow-color: rgb(0 0 0 / 0.5); + --chart-3: #7ed4fc; + color-scheme: dark; +} + +* { box-sizing: border-box; } +html, body { margin: 0; background: transparent; } +body { + /* body/14 */ + font: 400 14px/20px var(--font-sans); + color: var(--text-primary); + -webkit-font-smoothing: antialiased; +} +button { font: inherit; color: inherit; } +img { display: block; } + +/* Text styles (type/*), weights 400 and 500 only (11) */ +.type-page-title { font: 500 14px/20px var(--font-pixel); } +.type-eyebrow { margin: 0; font: 500 12px/16px var(--font-pixel); text-transform: uppercase; color: var(--text-tertiary); } +.type-metric { font: 500 24px/32px var(--font-sans); font-variant-numeric: tabular-nums; } +.type-label { font: 500 14px/20px var(--font-sans); } +.type-mono { font: 400 14px/20px var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; } +/* 5. A count beside a pixel title: pixel font, light outline. */ +.count { display: inline-block; margin-left: 6px; padding: 0 4px; border: 1px solid var(--border-default); border-radius: var(--radius-item); font: inherit; color: var(--text-tertiary); } +.icon { width: var(--size-icon-md); height: var(--size-icon-md); flex: none; } +.icon-sm { width: var(--size-icon-sm); height: var(--size-icon-sm); flex: none; } + +.app { padding: 2px 0 4px; } +.app-fullscreen { min-height: 100vh; max-width: 960px; margin: 0 auto; padding: 12px 12px calc(var(--safe-bottom, 0px) + 112px); background: var(--bg-base); } +.header { display: flex; align-items: center; gap: 8px; min-height: var(--size-control-md); margin-bottom: 8px; } +.crumb { color: var(--text-tertiary); } +.crumb::before { content: "/"; margin-right: 8px; color: var(--border-default); } +.header-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--text-tertiary); } + +/* 28. Underline tabs: the active one marked, the rest grey; hover darkens the text only. */ +.tabs { display: flex; gap: 16px; margin-bottom: 8px; border-bottom: 1px solid var(--border-default); } +.tab { height: var(--size-control-md); padding: 0; border: 0; border-bottom: 1px solid transparent; margin-bottom: -1px; background: none; color: var(--text-tertiary); cursor: pointer; } +.tab:hover { color: var(--text-primary); } +.tab-active { color: var(--text-primary); border-bottom-color: var(--text-primary); } +.logo { width: 18px; height: 18px; border-radius: var(--radius-item); } +.stack { display: flex; flex-direction: column; gap: 8px; } + +/* 18. Panels: white, bordered, square; a list's panel has a grey bar with its eyebrow title. */ +.section, .kpis { + border: 1px solid var(--border-default); + border-radius: var(--radius-surface); + background: var(--bg-raised); +} +.section-bar { + display: flex; align-items: center; justify-content: space-between; gap: 8px; + height: var(--size-control-md); + padding: 0 8px; + border-bottom: 1px solid var(--border-default); + background: var(--fill-primary); +} +.section-actions { display: flex; align-items: center; gap: 4px; } +.section-body { padding: 0 8px; } +.section-body-flush { padding: 0; } +.section-body > .notice { padding: 8px 0; } +.section-footer { display: flex; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border-subtle); } +.more { display: flex; padding: 4px 0 8px; } + +/* 20. KPIs: one row, divided by hairlines, grey label above the figure. */ +.kpi-row { display: grid; } +.kpi { padding: 12px; text-align: left; border: 0; background: none; color: inherit; } +.kpi + .kpi { border-left: 1px solid var(--border-default); } +button.kpi { cursor: pointer; box-shadow: inset 0 -2px 0 transparent; } +button.kpi:hover { background: var(--fill-hover); } +.kpi-selected { box-shadow: inset 0 -2px 0 var(--chart-3) !important; } +.kpi-label { color: var(--text-tertiary); } +.kpi-chart { padding: 8px 12px 12px; border-top: 1px solid var(--border-default); } + +/* 20. The chart: the panel's hue, dashed gridlines, dates under it. */ +.chart-readout { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; } +.chart-plot { position: relative; } +.chart-plot svg { display: block; width: 100%; touch-action: none; } +.chart-max { position: absolute; top: -2px; right: 0; color: var(--text-tertiary); font: 400 12px/16px var(--font-mono); background: var(--bg-raised); padding-left: 4px; } +.chart-grid { stroke: var(--border-default); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; } +.chart-axis { stroke: var(--border-default); vector-effect: non-scaling-stroke; } +.chart-line { fill: none; stroke: var(--chart-3); stroke-width: 1.5; vector-effect: non-scaling-stroke; } +.chart-dates { display: flex; justify-content: space-between; margin-top: 4px; color: var(--text-tertiary); font: 400 12px/16px var(--font-mono); } + +/* 24, 51. Tables: eyebrow headers, 14px cells, one line, the share as a grey bar. */ +.table { width: 100%; border-collapse: collapse; } +.table th { height: var(--size-control-md); padding: 0 8px; text-align: left; font: 500 12px/16px var(--font-pixel); text-transform: uppercase; color: var(--text-tertiary); border-bottom: 1px solid var(--border-default); white-space: nowrap; } +.table td { height: var(--size-row); padding: 0 8px; white-space: nowrap; } +.table tr + tr td { border-top: 1px solid var(--border-subtle); } +.table .num { text-align: right; font-variant-numeric: tabular-nums; } +.share-col { width: 25%; } +.share { display: block; height: 6px; background: var(--fill-active); } +.share > span { display: block; height: 100%; background: var(--text-tertiary); } +.cell-lead { display: inline-flex; align-items: center; gap: 8px; } + +/* 16. A label that is not a state: outline chip. */ +.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 4px; border: 1px solid var(--border-default); border-radius: var(--radius-item); color: var(--text-secondary); white-space: nowrap; flex: none; } + +/* Post preview */ +.post-body { margin: 0; padding: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; } +.media { display: flex; gap: 4px; padding-bottom: 8px; } +.media img, .media-tile { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--border-default); border-radius: var(--radius-item-lg); } +.media-tile { display: inline-flex; align-items: center; justify-content: center; color: var(--text-tertiary); background: var(--fill-primary); } + +/* Rows: 40px, one line, everything centred (22, 44); one border between rows (23). */ +.rows { list-style: none; margin: 0; padding: 0; } +.row { display: flex; align-items: center; gap: 8px; min-height: var(--size-row); } +.row + .row { border-top: 1px solid var(--border-subtle); } +.row-name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; overflow: hidden; white-space: nowrap; } +.row-name > * { overflow: hidden; text-overflow: ellipsis; } +.row-secondary { color: var(--text-tertiary); } +.row-fix { min-width: 96px; display: flex; justify-content: flex-end; flex: none; } +.row-actions { display: inline-flex; align-items: center; gap: 4px; } +.platform-tiles { display: inline-flex; align-items: center; gap: 2px; flex: none; } + +/* 42. PlatformTile md: the app icon in a 22px bordered tile, radius/item-lg. */ +.platform-tile { + display: inline-flex; align-items: center; justify-content: center; flex: none; + padding: 2px; + border: 1px solid var(--border-default); + border-radius: var(--radius-item-lg); +} +.platform-tile img { width: 16px; height: 16px; object-fit: contain; } + +/* 16, 51. StatusPill: 20px, 14px at 400, radius/item, tinted. */ +.status-pill { + display: inline-flex; align-items: center; gap: 2px; flex: none; + height: 20px; padding: 0 4px; + border-radius: var(--radius-item); + font-size: 14px; line-height: 20px; white-space: nowrap; +} +.status-pill-success { color: var(--status-success-fg); background: var(--status-success-bg); } +.status-pill-warning { color: var(--status-warning-fg); background: var(--status-warning-bg); } +.status-pill-danger { color: var(--status-danger-fg); background: var(--status-danger-bg); } +.status-pill-info { color: var(--status-info-fg); background: var(--status-info-bg); } +.status-pill-muted { color: var(--text-tertiary); background: var(--fill-primary); } + +/* Buttons: square controls; hover changes colour only (1); focus darkens the border, no ring (13). */ +.btn { + display: inline-flex; align-items: center; justify-content: center; gap: 6px; + border: 1px solid transparent; + border-radius: var(--radius-control); + background: transparent; + font-size: 14px; font-weight: 400; line-height: 20px; + cursor: pointer; white-space: nowrap; +} +.btn-md { height: var(--size-control-md); padding: 0 12px; } +.btn-sm { height: var(--size-control-sm); padding: 0 8px; } +.btn-icon.btn-md { width: var(--size-control-md); padding: 0; } +.btn-icon.btn-sm { width: var(--size-control-sm); padding: 0; } +.btn-primary { background: var(--brand-default); color: var(--text-inverse); } +.btn-primary:hover { background: var(--brand-hover); } +.btn-primary:disabled { background: var(--fill-active); color: var(--text-disabled); } +.btn-outline { border-color: var(--border-default); background: var(--bg-raised); color: var(--text-primary); } +.btn-outline:hover { background: var(--fill-hover); } +.btn-ghost { color: var(--text-primary); } +.btn-ghost:hover { background: var(--fill-hover); } +.btn-link { padding: 0; height: auto; color: var(--brand-default); } +.btn-link:hover { color: var(--brand-hover); } +.btn:disabled { cursor: default; } +.btn:focus-visible { outline: none; border-color: var(--border-focus); } +.btn-primary:focus-visible { background: var(--brand-hover); } + +.actions { display: flex; align-items: center; gap: 8px; } + +/* 15. A notice is coloured text with its icon, no fill, no border. */ +.notice { display: flex; align-items: flex-start; gap: 6px; margin: 0; } +.notice .icon { margin-top: 2px; } +.notice-danger { color: var(--status-danger-fg); } +.notice-success { color: var(--status-success-fg); } +.notice-warning { color: var(--status-warning-fg); } +.notice-muted { color: var(--text-tertiary); } + +/* 54. Empty state: icon and what the list would hold. */ +.empty { display: flex; align-items: center; gap: 6px; min-height: var(--size-row); color: var(--text-tertiary); } + +/* 17. Spinner: 3x3 pixel rain, 4px cells, stepping, in the text colour. */ +.loading { display: flex; align-items: center; justify-content: center; min-height: 96px; color: var(--text-tertiary); } +.spinner { display: inline-grid; grid-template-columns: repeat(3, 4px); gap: 2px; color: currentColor; } +.spinner > span { width: 4px; height: 4px; background: currentColor; animation: pixel-rain 600ms steps(1, end) infinite; } +@keyframes pixel-rain { + 0% { opacity: 1; } + 33.333% { opacity: 0.4; } + 66.666%, 100% { opacity: 0.15; } +} +@media (prefers-reduced-motion: reduce) { .spinner > span { animation: none; } } + +@media (max-width: 420px) { + .kpi { padding: 8px; } + .type-metric { font-size: 16px; line-height: 24px; } + .row-fix { min-width: 0; } + .row-secondary { display: none; } + .share-col { display: none; } +} + +/* 47, 13. Fields: bordered, square, 14px; focus darkens the border, no ring. */ +.field { + width: 100%; min-height: 56px; padding: 6px 8px; resize: vertical; + border: 1px solid var(--border-default); border-radius: var(--radius-control); + background: var(--bg-raised); color: var(--text-primary); + font: 400 14px/20px var(--font-sans); +} +.field::placeholder { color: var(--text-placeholder); } +.field:focus { outline: none; border-color: var(--border-focus); } +.reply { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border-subtle); } +.message .reply { border-top: 0; padding-bottom: 0; } +.reply-actions { display: flex; gap: 8px; } + +/* Threads: messages and comments, one block each, yours tinted. */ +.thread { list-style: none; margin: 0; padding: 0; } +.message { padding: 8px 0; } +.message + .message { border-top: 1px solid var(--border-subtle); } +.message-out { margin-left: 15%; padding: 8px; background: var(--fill-primary); } +.message-out + .message, .message + .message-out { border-top: 0; margin-top: 4px; } +.message-meta { display: flex; align-items: center; gap: 6px; min-height: 20px; } +.message-actions { margin-left: auto; } +.message-body { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; } +.back { display: flex; } diff --git a/apps-src/src/mcp-app.tsx b/apps-src/src/mcp-app.tsx new file mode 100644 index 00000000..0a987a0e --- /dev/null +++ b/apps-src/src/mcp-app.tsx @@ -0,0 +1,256 @@ +/** + * The Zernio MCP App, on the ext-apps React hooks (the pattern of the SDK's + * basic-server-react example), drawn in the dashboard's design system v2. + * + * Every tool in src/late/mcp/apps/tools.py opens this app on its screen and + * hands it `{view, data, args}`. The app switches screens and refreshes by + * calling those same tools, so one set of components draws everything. + */ +import type { McpUiHostContext } from "@modelcontextprotocol/ext-apps"; +import { useApp, useHostStyles } from "@modelcontextprotocol/ext-apps/react"; +import { Expand } from "pixelarticons/react/Expand.js"; +import { Reload } from "pixelarticons/react/Reload.js"; +import { StrictMode, useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { createRoot } from "react-dom/client"; +import { + type AccountsHealth, + type AdsData, + type AnalyticsData, + type CallResult, + type CommentsData, + type ConversationData, + type HomeData, + type InboxData, + type PostsData, + type PreviewData, + type Screen, + screenOf, + TABS, + textOf, + TOOLS, + type View, + VIEW_TITLES, +} from "./api"; +import { installFonts } from "./fonts"; +import { Accounts } from "./screens/Accounts"; +import { Ads } from "./screens/Ads"; +import { Analytics } from "./screens/Analytics"; +import { Comments } from "./screens/Comments"; +import { ConversationView } from "./screens/Conversation"; +import type { ActResult, Ctx } from "./screens/context"; +import { Home } from "./screens/Home"; +import { Inbox } from "./screens/Inbox"; +import { Posts } from "./screens/Posts"; +import { Preview } from "./screens/Preview"; +import { Button, Notice, Spinner, Tabs } from "./ui"; +import "./global.css"; + +installFonts(); + +/** How long to wait for the opening tool's result before loading the screen ourselves. */ +const RESULT_GRACE_MS = 2500; + +const VIEW_OF_TOOL = Object.fromEntries(Object.entries(TOOLS).map(([view, tool]) => [tool, view])) as Record; + +function ZernioApp() { + const [hostContext, setHostContext] = useState(); + const [screen, setScreen] = useState(); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(); + const [notice, setNotice] = useState(); + const toolArgs = useRef>({}); + const gotResult = useRef(false); + + const show = useCallback((result: CallResult) => { + if (result.isError) { + setError(textOf(result) || "The tool call failed."); + return; + } + const next = screenOf(result); + if (!next) { + setError("This result has no screen to show."); + return; + } + setError(undefined); + setScreen(next); + }, []); + + const { app, error: connectError } = useApp({ + appInfo: { name: "Zernio", version: "0.2.0" }, + capabilities: { availableDisplayModes: ["inline", "fullscreen"] }, + onAppCreated: (app) => { + app.ontoolinput = ({ arguments: args }) => { + toolArgs.current = args ?? {}; + }; + app.ontoolresult = (result) => { + gotResult.current = true; + show(result); + }; + app.ontoolcancelled = () => setError("Cancelled."); + app.onhostcontextchanged = (params) => setHostContext((prev) => ({ ...prev, ...params })); + app.onerror = console.error; + }, + }); + + // Theme, host CSS variables and host fonts, kept in sync with the host. + useHostStyles(app, app?.getHostContext()); + + useEffect(() => { + if (app) setHostContext(app.getHostContext()); + }, [app]); + + // A screen is a newer request than the one before it: a slow answer for a + // screen the user already left is dropped. + const seq = useRef(0); + const load = useCallback( + async (view: View, args: Record = {}) => { + if (!app) return; + const mine = ++seq.current; + setLoading(true); + setNotice(undefined); + try { + const result = await app.callServerTool({ name: TOOLS[view], arguments: args }); + if (mine === seq.current) show(result); + } catch (e) { + if (mine === seq.current) setError(e instanceof Error ? e.message : String(e)); + } finally { + if (mine === seq.current) setLoading(false); + } + }, + [app, show], + ); + + // Opened without a result (from Claude's Artifacts page, or a host that + // delivers none): load the screen of the tool that opened us, else Home. + useEffect(() => { + if (!app) return; + const timer = setTimeout(() => { + if (gotResult.current) return; + const tool = app.getHostContext()?.toolInfo?.tool?.name; + const view = (tool && VIEW_OF_TOOL[tool]) || "home"; + void load(view, view === "home" ? {} : toolArgs.current); + }, RESULT_GRACE_MS); + return () => clearTimeout(timer); + }, [app, load]); + + // Tell Claude what the app shows, so "these accounts" resolves to them. + useEffect(() => { + if (!app || !screen || !app.getHostCapabilities()?.updateModelContext) return; + void app.updateModelContext({ + content: [{ type: "text", text: `The Zernio app shows ${VIEW_TITLES[screen.view]}.` }], + structuredContent: { view: screen.view, args: screen.args }, + }); + }, [app, screen]); + + const ctx = useMemo(() => { + if (!app) return undefined; + return { + app, + locale: hostContext?.locale, + fullscreen: hostContext?.displayMode === "fullscreen", + navigate: (view, args) => void load(view, args), + async act(tool, args): Promise { + try { + const result = await app.callServerTool({ name: tool, arguments: args }); + return { ok: !result.isError, text: textOf(result), data: result.structuredContent }; + } catch (e) { + return { ok: false, text: e instanceof Error ? e.message : String(e) }; + } + }, + ask(text) { + void app.sendMessage({ role: "user", content: [{ type: "text", text }] }).then(({ isError }) => + setNotice(isError ? "Could not send it to Claude." : "Sent to Claude. Continue in the chat."), + ); + }, + tell(text) { + if (app.getHostCapabilities()?.updateModelContext) { + void app.updateModelContext({ content: [{ type: "text", text }] }); + } + }, + }; + }, [app, hostContext?.locale, hostContext?.displayMode, load]); + + if (connectError) return {connectError.message}; + if (!ctx) return ; + + const fullscreen = ctx.fullscreen; + const canExpand = !fullscreen && !!hostContext?.availableDisplayModes?.includes("fullscreen"); + const insets = hostContext?.safeAreaInsets; + + return ( +
+
+ + {/* 35. The breadcrumb is the screen's title. */} + Zernio + {screen && {VIEW_TITLES[screen.view]}} + + {loading && screen && } + {screen && ( + + )} + {canExpand && ( + // requestDisplayMode must run inside the click: the host refuses it otherwise. + + )} + +
+ {fullscreen && ( + ({ key, label: VIEW_TITLES[key] }))} + active={screen && TABS.includes(screen.view) ? screen.view : undefined} + onPick={(view) => ctx.navigate(view)} + /> + )} +
+ {error && {error}} + {notice && {notice}} + {screen ? : !error && } +
+
+ ); +} + +function ScreenView({ ctx, screen }: { ctx: Ctx; screen: Screen }) { + switch (screen.view) { + case "home": + return ; + case "posts": + return ; + case "analytics": + return ; + case "accounts": + return ; + case "ads": + return ; + case "preview": + return ; + case "inbox": + return ; + case "conversation": + return ; + case "comments": + return ; + } +} + +function Loading() { + return ( +
+ +
+ ); +} + +createRoot(document.getElementById("root")!).render( + + + , +); diff --git a/apps-src/src/screens/Accounts.tsx b/apps-src/src/screens/Accounts.tsx new file mode 100644 index 00000000..acea6571 --- /dev/null +++ b/apps-src/src/screens/Accounts.tsx @@ -0,0 +1,30 @@ +/** Accounts: every connected account by health, the broken ones first. */ +import { Users } from "pixelarticons/react/Users.js"; +import { type AccountsHealth, formatNumber } from "../api"; +import { Empty, Kpis, Rows, Section } from "../ui"; +import type { Ctx } from "./context"; +import { ACCOUNT_RANK, AccountRow } from "./rows"; + +export function Accounts({ ctx, data }: { ctx: Ctx; data: AccountsHealth }) { + const summary = data.summary ?? {}; + const accounts = [...(data.accounts ?? [])].sort((a, b) => ACCOUNT_RANK[a.status] - ACCOUNT_RANK[b.status]); + const n = (v?: number) => formatNumber(v, ctx.locale); + return ( + <> + +
+ {accounts.length ? ( + {accounts.map((a) => )} + ) : ( + }>No connected accounts yet. + )} +
+ + ); +} diff --git a/apps-src/src/screens/Ads.tsx b/apps-src/src/screens/Ads.tsx new file mode 100644 index 00000000..4fe24cd4 --- /dev/null +++ b/apps-src/src/screens/Ads.tsx @@ -0,0 +1,83 @@ +/** Ads: what needs attention across the ads, most severe first, each with its fix. */ +import { Megaphone } from "pixelarticons/react/Megaphone.js"; +import { useState } from "react"; +import { type AdsAlert, type AdsData, formatNumber, platformName } from "../api"; +import { Button, Empty, Kpis, PlatformTile, Row, Rows, Section, StatusPill, type Tone } from "../ui"; +import type { Ctx } from "./context"; + +const SEVERITY: Record = { + error: { label: "Error", tone: "danger" }, + warning: { label: "Warning", tone: "warning" }, + info: { label: "Info", tone: "info" }, +}; + +export function Ads({ ctx, data }: { ctx: Ctx; data: AdsData }) { + const [dismissed, setDismissed] = useState([]); + const alerts = (data.alerts ?? []).filter((a) => !dismissed.includes(a.id)); + const counts = data.counts ?? {}; + const n = (v?: number) => formatNumber(v ?? 0, ctx.locale); + + const dismiss = async (alert: AdsAlert) => { + const result = await ctx.act("ui_dismiss_ads_alert", { alert_id: alert.id }); + if (result.ok) { + setDismissed((d) => [...d, alert.id]); + ctx.tell(`From the Zernio app the user dismissed ads alert ${alert.id} ("${alert.title}") for 30 days.`); + } + }; + + return ( + <> + +
+ {alerts.length ? ( + + {alerts.map((alert) => ( + void dismiss(alert)} /> + ))} + + ) : ( + }>Nothing needs attention in your ads. + )} +
+ + ); +} + +function AlertRow({ ctx, alert, onDismiss }: { ctx: Ctx; alert: AdsAlert; onDismiss: () => void }) { + const severity = SEVERITY[alert.severity] ?? SEVERITY.info; + const url = alert.fix?.url ? (alert.fix.url.startsWith("/") ? `https://zernio.com${alert.fix.url}` : alert.fix.url) : undefined; + const entity = alert.entity?.name ?? undefined; + return ( + : undefined} + name={alert.title} + secondary={entity} + state={} + fix={ + + {url ? ( + + ) : ( + + )} + + + } + /> + ); +} diff --git a/apps-src/src/screens/Analytics.tsx b/apps-src/src/screens/Analytics.tsx new file mode 100644 index 00000000..f0d16f23 --- /dev/null +++ b/apps-src/src/screens/Analytics.tsx @@ -0,0 +1,148 @@ +/** + * Analytics: the KPIs on one row, the picked one's daily chart in the same + * panel (20), and the platforms with each one's share as a grey bar. + */ +import { ChartLine } from "pixelarticons/react/ChartLine.js"; +import { useState } from "react"; +import { type AnalyticsData, formatDate, formatNumber, type Metrics, platformName } from "../api"; +import { Empty, Kpis, PlatformTile, Section } from "../ui"; +import type { Ctx } from "./context"; + +type Key = "impressions" | "engagement" | "views" | "posts"; + +const LABELS: Record = { + impressions: "Impressions", + engagement: "Engagement", + views: "Views", + posts: "Posts", +}; + +function engagement(m: Metrics = {}): number { + return (m.likes ?? 0) + (m.comments ?? 0) + (m.shares ?? 0) + (m.saves ?? 0); +} + +function dayValue(day: NonNullable[number], key: Key): number { + if (key === "posts") return day.postCount ?? 0; + if (key === "engagement") return engagement(day.metrics); + return day.metrics?.[key] ?? 0; +} + +export function Analytics({ ctx, data }: { ctx: Ctx; data: AnalyticsData }) { + const [key, setKey] = useState("impressions"); + const days = [...(data.dailyData ?? [])].sort((a, b) => a.date.localeCompare(b.date)); + const totals = data.totals ?? {}; + const total: Record = { + impressions: totals.impressions ?? 0, + engagement: totals.engagement ?? engagement(totals), + views: totals.views ?? 0, + posts: totals.postCount ?? 0, + }; + const n = (v: number) => formatNumber(v, ctx.locale, true); + const platforms = [...(data.platformBreakdown ?? [])].sort((a, b) => (b.impressions ?? 0) - (a.impressions ?? 0)); + const maxImpressions = Math.max(1, ...platforms.map((p) => p.impressions ?? 0)); + + return ( + <> + ({ key: k, label: LABELS[k], value: n(total[k]) }))} + selected={key} + onSelect={(k) => setKey(k as Key)} + > + {days.length ? ( + ({ date: d.date, value: dayValue(d, key) }))} + label={LABELS[key]} + locale={ctx.locale} + tall={ctx.fullscreen} + /> + ) : ( + }>No posts in this period. + )} + + {platforms.length > 0 && ( +
+ + + + + + + + + + + + {platforms.map((p) => ( + + + + + + + + ))} + +
PlatformPostsImpressionsEngagementShare
+ {platformName(p.platform)} + {formatNumber(p.postCount, ctx.locale)}{n(p.impressions ?? 0)}{n(engagement(p))} + +
+
+ )} + + ); +} + +/** A daily line in the panel's hue (chart/3), dashed gridlines, dates at the ends and middle. */ +function Chart({ points, label, locale, tall }: { + points: { date: string; value: number }[]; + label: string; + locale?: string; + tall: boolean; +}) { + const [hover, setHover] = useState(null); + const w = 600; + const h = tall ? 220 : 120; + const max = Math.max(1, ...points.map((p) => p.value)); + const step = points.length > 1 ? w / (points.length - 1) : 0; + const xy = points.map((p, i) => [i * step, h - (p.value / max) * (h - 8) - 4] as const); + const line = xy.map(([x, y], i) => `${i ? "L" : "M"}${x.toFixed(1)} ${y.toFixed(1)}`).join(""); + const at = hover ?? points.length - 1; + const dates = [0, Math.floor((points.length - 1) / 2), points.length - 1]; + + return ( +
+
+ {formatDate(points[at].date, locale, { weekday: "short", month: "short", day: "numeric", timeZone: "UTC" })} + {formatNumber(points[at].value, locale)} {label.toLowerCase()} +
+
+ {formatNumber(max, locale, true)} + { + const box = e.currentTarget.getBoundingClientRect(); + setHover(Math.max(0, Math.min(points.length - 1, Math.round(((e.clientX - box.left) / box.width) * (points.length - 1))))); + }} + onPointerLeave={() => setHover(null)} + > + {[0.5, 1].map((f) => ( + + ))} + + + {hover !== null && } + +
+
+ {dates.map((i, k) => ( + {formatDate(points[i].date, locale, { month: "short", day: "numeric", timeZone: "UTC" })} + ))} +
+
+ ); +} diff --git a/apps-src/src/screens/Comments.tsx b/apps-src/src/screens/Comments.tsx new file mode 100644 index 00000000..e43fc221 --- /dev/null +++ b/apps-src/src/screens/Comments.tsx @@ -0,0 +1,71 @@ +/** A post's comments: each comment with its own reply box when it can be answered. */ +import { ArrowLeft } from "pixelarticons/react/ArrowLeft.js"; +import { Message } from "pixelarticons/react/Message.js"; +import { useState } from "react"; +import { type Comment, type CommentsData, formatDate } from "../api"; +import { Badge, Button, Empty, Notice, ReplyBox, Section } from "../ui"; +import type { Ctx } from "./context"; + +export function Comments({ ctx, data }: { ctx: Ctx; data: CommentsData }) { + const [open, setOpen] = useState(); + const [replied, setReplied] = useState([]); + const title = (data.post.text || "").split("\n")[0] || "Post"; + + const reply = async (comment: Comment, text: string) => { + const result = await ctx.act("comments_reply_to_inbox_post", { post_id: data.postId, account_id: data.accountId, message: text, comment_id: comment.id }); + if (!result.ok) return result.text || "The reply was not sent."; + setReplied((list) => [...list, comment.id]); + setOpen(undefined); + ctx.tell(`From the Zernio app the user replied to comment ${comment.id} on post ${data.postId}: "${text}"`); + return undefined; + }; + + return ( + <> +
+ +
+
void ctx.app.openLink({ url: data.post.permalink! })}>View post : undefined} + > + {data.comments.length ? ( +
    + {data.comments.map((c) => { + const author = c.from.name || (c.from.username ? `@${c.from.username}` : "Someone"); + return ( +
  1. +
    + {author} + {c.from.isOwner && You} + {formatDate(c.createdTime, ctx.locale)} + {!!c.replyCount && · {c.replyCount} replies} + + {replied.includes(c.id) ? ( + Replied + ) : c.canReply !== false && !c.from.isOwner ? ( + + ) : null} + +
    +

    {c.isHidden ? Hidden : c.message || No text}

    + {open === c.id && ( + reply(c, text)} + onDraft={() => ctx.ask(`Draft a reply to ${author}'s comment "${c.message ?? ""}" on my post (post_id ${data.postId}, account_id ${data.accountId}, comment_id ${c.id}).`)} + /> + )} +
  2. + ); + })} +
+ ) : ( + }>No comments on this post yet. + )} +
+ {data.comments.length > 0 && data.comments.every((c) => c.canReply === false) && This platform does not allow replies from the API.} + + ); +} diff --git a/apps-src/src/screens/Conversation.tsx b/apps-src/src/screens/Conversation.tsx new file mode 100644 index 00000000..5c186208 --- /dev/null +++ b/apps-src/src/screens/Conversation.tsx @@ -0,0 +1,58 @@ +/** A conversation: the thread, oldest first, and the reply box under it. */ +import { ArrowLeft } from "pixelarticons/react/ArrowLeft.js"; +import { Mail } from "pixelarticons/react/Mail.js"; +import { useState } from "react"; +import { type ConversationData, type Message } from "../api"; +import { Button, Empty, ReplyBox, Section } from "../ui"; +import type { Ctx } from "./context"; + +function when(value: string | null | undefined, locale?: string): string { + if (!value) return ""; + const date = new Date(value); + return Number.isNaN(date.getTime()) ? "" : date.toLocaleString(locale, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }); +} + +export function ConversationView({ ctx, data }: { ctx: Ctx; data: ConversationData }) { + const [messages, setMessages] = useState(data.messages); + const contact = messages.find((m) => m.direction === "incoming")?.senderName || "this contact"; + + const send = async (text: string) => { + const result = await ctx.act("ui_send_message", { conversation_id: data.conversationId, account_id: data.accountId, message: text }); + if (!result.ok) return result.text || "The message was not sent."; + setMessages((list) => [...list, { id: `sent-${Date.now()}`, message: text, direction: "outgoing", senderName: "You", createdAt: new Date().toISOString(), attachments: 0 }]); + ctx.tell(`From the Zernio app the user replied to ${contact} in conversation ${data.conversationId}: "${text}"`); + return undefined; + }; + + return ( + <> +
+ +
+
+ {messages.length ? ( +
    + {messages.map((m) => ( +
  1. +
    + {m.direction === "outgoing" ? "You" : m.senderName || "Them"} + {when(m.createdAt, ctx.locale)} +
    +

    + {m.isDeleted ? Deleted : m.message || {m.attachments ? `${m.attachments} attachment${m.attachments > 1 ? "s" : ""}` : "No text"}} +

    +
  2. + ))} +
+ ) : ( + }>No messages in this conversation yet. + )} + ctx.ask(`Draft a reply to ${contact} in my Zernio conversation ${data.conversationId} (account_id ${data.accountId}), based on the last messages.`)} + /> +
+ + ); +} diff --git a/apps-src/src/screens/Home.tsx b/apps-src/src/screens/Home.tsx new file mode 100644 index 00000000..e2a55fbf --- /dev/null +++ b/apps-src/src/screens/Home.tsx @@ -0,0 +1,43 @@ +/** Home: the workspace at a glance, with the way to each list. */ +import { CheckDouble } from "pixelarticons/react/CheckDouble.js"; +import { formatNumber, type HomeData } from "../api"; +import { Empty, Kpis, More, Rows, Section } from "../ui"; +import type { Ctx } from "./context"; +import { ACCOUNT_RANK, AccountRow, FailedPostRow } from "./rows"; + +export function Home({ ctx, data }: { ctx: Ctx; data: HomeData }) { + const summary = data.health.summary ?? {}; + const attention = (data.health.accounts ?? []) + .filter((a) => a.status !== "healthy") + .sort((a, b) => ACCOUNT_RANK[a.status] - ACCOUNT_RANK[b.status]); + const shown = ctx.fullscreen ? 5 : 3; + const n = (v?: number) => formatNumber(v, ctx.locale); + + return ( + <> + +
+ {attention.length ? ( + {attention.slice(0, shown).map((a) => )} + ) : ( + }>Every account can post. + )} + {attention.length > shown && ctx.navigate("accounts")} />} +
+
+ {data.failedPosts.length ? ( + {data.failedPosts.map((p) => )} + ) : ( + }>Nothing failed to publish. + )} + {data.failedTotal > data.failedPosts.length && ctx.navigate("posts")} />} +
+ + ); +} diff --git a/apps-src/src/screens/Inbox.tsx b/apps-src/src/screens/Inbox.tsx new file mode 100644 index 00000000..4e486b10 --- /dev/null +++ b/apps-src/src/screens/Inbox.tsx @@ -0,0 +1,68 @@ +/** Inbox: the latest conversations and the posts with comments, each opening its thread. */ +import { Mail } from "pixelarticons/react/Mail.js"; +import { Message } from "pixelarticons/react/Message.js"; +import { formatDate, formatNumber, type InboxData, platformName } from "../api"; +import { Button, Empty, Kpis, PlatformTile, Row, Rows, Section, StatusPill } from "../ui"; +import type { Ctx } from "./context"; + +export function Inbox({ ctx, data }: { ctx: Ctx; data: InboxData }) { + const unread = data.conversations.reduce((sum, c) => sum + (c.unreadCount ?? 0), 0); + const comments = data.posts.reduce((sum, p) => sum + (p.commentCount ?? 0), 0); + const shown = ctx.fullscreen ? 15 : 5; + const n = (v: number) => formatNumber(v, ctx.locale); + + return ( + <> + +
+ {data.conversations.length ? ( + + {data.conversations.slice(0, shown).map((c) => ( + } + name={c.participantName || (c.isGroup ? "Group" : "Unknown")} + secondary={c.lastMessage || formatDate(c.updatedTime, ctx.locale)} + state={c.unreadCount ? : undefined} + fix={ + + } + /> + ))} + + ) : ( + }>No conversations yet. + )} +
+
+ {data.posts.length ? ( + + {data.posts.slice(0, shown).map((p) => ( + } + name={(p.content || "").split("\n")[0] || `${platformName(p.platform)} post`} + secondary={`${formatNumber(p.commentCount ?? 0, ctx.locale)} comments · ${formatDate(p.createdTime, ctx.locale)}`} + fix={ + + } + /> + ))} + + ) : ( + }>No comments on your recent posts. + )} +
+ + ); +} diff --git a/apps-src/src/screens/Posts.tsx b/apps-src/src/screens/Posts.tsx new file mode 100644 index 00000000..530c17b8 --- /dev/null +++ b/apps-src/src/screens/Posts.tsx @@ -0,0 +1,18 @@ +/** Failed posts: every post that did not publish, its reason and Retry. */ +import { CheckDouble } from "pixelarticons/react/CheckDouble.js"; +import type { PostsData } from "../api"; +import { Empty, Rows, Section } from "../ui"; +import type { Ctx } from "./context"; +import { FailedPostRow } from "./rows"; + +export function Posts({ ctx, data }: { ctx: Ctx; data: PostsData }) { + return ( +
+ {data.posts.length ? ( + {data.posts.map((p) => )} + ) : ( + }>Nothing failed to publish. + )} +
+ ); +} diff --git a/apps-src/src/screens/Preview.tsx b/apps-src/src/screens/Preview.tsx new file mode 100644 index 00000000..c0eada55 --- /dev/null +++ b/apps-src/src/screens/Preview.tsx @@ -0,0 +1,103 @@ +/** + * Post preview: the post as it will go out, the account each platform reaches, + * validation, and Publish now (two steps) or Save as draft. + */ +import { Image } from "pixelarticons/react/Image.js"; +import { Video } from "pixelarticons/react/Video.js"; +import { useState } from "react"; +import { platformName, type PreviewData } from "../api"; +import { Button, Notice, PlatformTile, Row, Rows, Section, StatusPill } from "../ui"; +import type { Ctx } from "./context"; + +type Outcome = { ok: boolean; text: string }; + +export function Preview({ ctx, data }: { ctx: Ctx; data: PreviewData }) { + const [confirming, setConfirming] = useState(false); + const [busy, setBusy] = useState<"publish" | "draft" | null>(null); + const [outcome, setOutcome] = useState(); + const errors = data.validation?.errors ?? []; + const warnings = data.validation?.warnings ?? []; + const unresolved = data.targets.filter((t) => t.error); + const blocked = unresolved.length > 0 || data.validation?.valid === false; + const length = Array.from(data.content).length; + + const submit = async (mode: "publish" | "draft") => { + setBusy(mode); + setConfirming(false); + const result = await ctx.act("posts_cross_post", { ...data.request, ...(mode === "publish" ? { publish_now: true } : { is_draft: true }) }); + // posts_cross_post reports account problems as text starting with ❌. + const ok = result.ok && !result.text.trim().startsWith("❌"); + setOutcome({ ok, text: result.text }); + setBusy(null); + ctx.tell( + ok + ? `From the Zernio app the user ${mode === "publish" ? "published" : "saved as a draft"} the previewed post. ${result.text}` + : `Submitting the previewed post from the Zernio app failed. ${result.text}`, + ); + }; + + return ( + <> +
{length} characters}> +

{data.content}

+ {data.media.length > 0 && ( +
+ {data.media.slice(0, 4).map((m, i) => + m.type === "image" ? ( + {`Attached + ) : ( + + {m.type === "video" ? + ), + )} +
+ )} +
+ +
+ + {data.targets.map((t, i) => ( + } + name={platformName(t.platform)} + secondary={t.handle ? `@${t.handle}` : undefined} + state={t.error ? : } + fix={ + t.error ? ( + + ) : undefined + } + /> + ))} + +
+ + {errors.map((e, i) => {e.platform ? `${platformName(e.platform)}: ` : ""}{e.error})} + {warnings.map((w, i) => {w.platform ? `${platformName(w.platform)}: ` : ""}{w.warning})} + + {outcome ? ( + {outcome.text} + ) : ( +
+ {confirming ? ( + <> + + + + ) : ( + <> + + + + )} +
+ )} + + ); +} diff --git a/apps-src/src/screens/context.ts b/apps-src/src/screens/context.ts new file mode 100644 index 00000000..bb8c2963 --- /dev/null +++ b/apps-src/src/screens/context.ts @@ -0,0 +1,22 @@ +/** What every screen gets from the app: the host, navigation and actions. */ +import type { App } from "@modelcontextprotocol/ext-apps"; +import type { View } from "../api"; + +export interface ActResult { + ok: boolean; + text: string; + data?: unknown; +} + +export interface Ctx { + app: App; + locale?: string; + fullscreen: boolean; + navigate(view: View, args?: Record): void; + /** Calls a write tool for a button; the host asks the user to approve it. */ + act(tool: string, args: Record): Promise; + /** Hands a task that needs judgement to the chat, in the user's voice. */ + ask(text: string): void; + /** Tells Claude what just happened on screen, without a chat message. */ + tell(text: string): void; +} diff --git a/apps-src/src/screens/rows.tsx b/apps-src/src/screens/rows.tsx new file mode 100644 index 00000000..9b468b2f --- /dev/null +++ b/apps-src/src/screens/rows.tsx @@ -0,0 +1,132 @@ +/** The rows several screens share: an account and a failed post. */ +import { useState } from "react"; +import { type Account, type FailedPost, formatDate, platformName } from "../api"; +import { Button, PlatformTile, PlatformTiles, Row, StatusPill, type Tone } from "../ui"; +import type { Ctx } from "./context"; + +/** 48. Green works, amber needs action, red is broken. */ +const ACCOUNT_STATE: Record = { + healthy: { label: "Healthy", tone: "success" }, + warning: { label: "Needs attention", tone: "warning" }, + error: { label: "Broken", tone: "danger" }, +}; + +export const ACCOUNT_RANK = { error: 0, warning: 1, healthy: 2 } as const; + +function accountReason(account: Account): string { + if (account.needsReconnect) return account.disconnectReason || "Needs to be reconnected"; + return account.issues?.[0] || account.disconnectReason || ""; +} + +/** The account's own reconnect link: signing in there refreshes this account, keeping its id and history. */ +async function reconnect(ctx: Ctx, account: Account): Promise { + if (!account.profileId) return "This account has no profile to reconnect it on."; + const result = await ctx.act("ui_reconnect_account", { + account_id: account.accountId, + platform: account.platform, + profile_id: account.profileId, + }); + const url = (result.data as { authUrl?: string } | undefined)?.authUrl; + if (!result.ok || !url) return result.text || "Could not get the reconnect link."; + const opened = await ctx.app.openLink({ url }); + if (opened.isError) return "The link could not be opened."; + ctx.tell(`From the Zernio app the user opened the reconnect link for ${account.platform} account ${account.accountId}.`); + return undefined; +} + +export function AccountRow({ ctx, account }: { ctx: Ctx; account: Account }) { + const [busy, setBusy] = useState(false); + const [failed, setFailed] = useState(); + const state = ACCOUNT_STATE[account.status]; + const reason = accountReason(account); + const handle = account.username ? `@${account.username}` : account.displayName; + return ( + } + name={platformName(account.platform)} + secondary={handle} + state={ + failed ? ( + + ) : ( + + ) + } + fix={ + account.needsReconnect ? ( + + ) : account.status !== "healthy" ? ( + + ) : null + } + /> + ); +} + +/** A post's name: its title, else its first line, else what it is. */ +function postName(post: FailedPost): string { + const first = post.content.split("\n").find((line) => line.trim()); + return post.title || first || "Post without text"; +} + +export function FailedPostRow({ ctx, post }: { ctx: Ctx; post: FailedPost }) { + const [state, setState] = useState<"idle" | "busy" | "queued" | string>("idle"); + const reason = post.errors.length + ? post.errors.map((e) => (post.platforms.length > 1 ? `${platformName(e.platform)}: ${e.message}` : e.message)).join("\n") + : "No error message recorded"; + + const retry = async () => { + setState("busy"); + const result = await ctx.act("posts_retry", { post_id: post.id }); + // posts_retry answers in text: ✅ when queued, ⚠️ or ❌ when not. + const ok = result.ok && result.text.trim().startsWith("✅"); + setState(ok ? "queued" : result.text || "Retry failed"); + if (ok) ctx.tell(`From the Zernio app the user queued post ${post.id} for retry.`); + }; + + return ( + } + name={postName(post)} + secondary={formatDate(post.updatedAt, ctx.app.getHostContext()?.locale)} + state={ + state === "queued" ? ( + + ) : state !== "idle" && state !== "busy" ? ( + + ) : ( + + ) + } + fix={ + state === "queued" ? null : ( + + ) + } + /> + ); +} diff --git a/apps-src/src/ui.tsx b/apps-src/src/ui.tsx new file mode 100644 index 00000000..7a7cb22b --- /dev/null +++ b/apps-src/src/ui.tsx @@ -0,0 +1,245 @@ +/** + * The dashboard primitives the app is built from, drawn as the product look + * (v2) draws them. Every screen uses only these, so they all read alike. + * Numbers in comments are the design principles they follow + * (Schedule-Posts-API, .claude/rules/design-principles.md). + */ +import { InfoBox } from "pixelarticons/react/InfoBox.js"; +import { type ButtonHTMLAttributes, type ReactNode, useState } from "react"; +import { platformIcon, platformName } from "./api"; + +/** 18. A block is a white panel; a list's panel is headed by a grey bar with its eyebrow title. */ +export function Section({ title, count, actions, children, flush }: { + title: string; + count?: number; + actions?: ReactNode; + children: ReactNode; + /** The body runs edge to edge (a table, a chart). */ + flush?: boolean; +}) { + return ( +
+
+

+ {title} + {count !== undefined && {count}} +

+ {actions &&
{actions}
} +
+
{children}
+
+ ); +} + +export type Tone = "success" | "warning" | "danger" | "info" | "muted"; + +/** 16, 43, 48, 66. A state is a filled pill in its colour; its reason sits behind the info mark. */ +export function StatusPill({ label, tone, reason }: { label: string; tone: Tone; reason?: string }) { + return ( + + {label} + {reason && } + + ); +} + +/** 16. A label that is not a state: outlined and colourless. */ +export function Badge({ children }: { children: ReactNode }) { + return {children}; +} + +/** 7, 42. A platform shows as its app icon in a bordered tile (md, 22px). */ +export function PlatformTile({ platform }: { platform: string }) { + return ( + + {platformName(platform)} + + ); +} + +export function PlatformTiles({ platforms }: { platforms: string[] }) { + const unique = [...new Set(platforms)]; + return ( + + {unique.slice(0, 3).map((p) => )} + {unique.length > 3 && +{unique.length - 3}} + + ); +} + +/** 17. Loading is a 3x3 pixel rain in the text colour, stepping between frames. */ +export function Spinner({ label = "Loading" }: { label?: string }) { + return ( + + {Array.from({ length: 9 }, (_, i) => { + const frame = (Math.floor(i / 3) + (i % 3)) % 3; + return ; + })} + + ); +} + +/** 15. A notice is coloured text with its icon, not a box. */ +export function Notice({ tone, children }: { tone: "danger" | "warning" | "success" | "muted"; children: ReactNode }) { + return ( +

+ {tone !== "muted" && } + {children} +

+ ); +} + +type ButtonProps = ButtonHTMLAttributes & { + variant?: "primary" | "outline" | "ghost" | "link"; + size?: "sm" | "md"; + icon?: boolean; +}; + +/** Square controls, 28/32px; hover changes colour only (1); focus darkens the border (13). */ +export function Button({ variant = "outline", size = "md", icon, className, ...props }: ButtonProps) { + const classes = ["btn", `btn-${variant}`, `btn-${size}`, icon ? "btn-icon" : "", className ?? ""].filter(Boolean); + return + ) : ( +
+
{item.label}
+
{item.value}
+
+ ), + )} + + {children &&
{children}
} + + ); +} + +/** 28. Underline tabs: the active one is marked, the rest grey; hover only darkens the text. */ +export function Tabs({ items, active, onPick }: { + items: { key: K; label: string }[]; + active?: K; + onPick: (key: K) => void; +}) { + return ( + + ); +} + +/** 22, 40, 43, 44. A row is one line: lead, name with its grey secondary fact, state, then the fix. */ +export function Row({ lead, name, secondary, state, fix }: { + lead?: ReactNode; + name: ReactNode; + secondary?: ReactNode; + state?: ReactNode; + fix?: ReactNode; +}) { + return ( +
  • + {lead} +
    + {name} + {secondary && {secondary}} +
    + {state} +
    {fix}
    +
  • + ); +} + +export function Rows({ children }: { children: ReactNode }) { + return
      {children}
    ; +} + +/** 54. An empty list says what it would hold, with an icon. */ +export function Empty({ icon, children }: { icon: ReactNode; children: ReactNode }) { + return
    {icon}{children}
    ; +} + +/** A list cut short says so, with the way to the rest. */ +export function More({ label, onClick }: { label: string; onClick: () => void }) { + return ( +
    + +
    + ); +} + +/** + * 47. A reply box: a bordered field (focus darkens its border, 13) with the + * main action after it. Sending clears the field; a failure keeps the text. + */ +export function ReplyBox({ placeholder, onSend, onDraft }: { + placeholder: string; + onSend: (text: string) => Promise; + /** Hands drafting to Claude. */ + onDraft?: () => void; +}) { + const [text, setText] = useState(""); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(); + const send = async () => { + const value = text.trim(); + if (!value) return; + setBusy(true); + setError(undefined); + const failure = await onSend(value); + setBusy(false); + if (failure) setError(failure); + else setText(""); + }; + return ( +
    +