A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Give the desktop app its own window: the team and a Bot's chat
Fei24110cc9aad87a53
diff --git a/.gitignore b/.gitignoreindex e495159a..3bb46d61 100644--- a/.gitignore+++ b/.gitignore@@ -1,5 +1,7 @@node_modules/*.tgz+# The desktop app's window build (npm run build in app/).+/app/ui/dist/# A DeepSeek Harness checkout for the tests and the test bench./deepseek-harness/diff --git a/app/package-lock.json b/app/package-lock.jsonindex f8db60ac..e400142f 100644--- a/app/package-lock.json+++ b/app/package-lock.json@@ -13,12 +13,14 @@"@deepseek-ai/dsh-app-boot": "0.2.0-rc.2","@deepseek-ai/dsh-base": "0.2.0-rc.2","@deepseek-ai/dsh-web-app": "0.2.0-rc.2",- "@deepseek-ai/dsh-web-frontend": "0.2.0-rc.2","ds-bot": "file:../ds-bot","pnpm": "11.7.0"},"devDependencies": {- "electron": "44.7.0"+ "electron": "44.7.0",+ "react": "19.3.0",+ "react-dom": "19.3.0",+ "vite": "8.3.4"}},"node_modules/@agentclientprotocol/sdk": {@@ -6620,6 +6622,16 @@"node": ">=14"}},+ "node_modules/@oxc-project/types": {+ "version": "0.154.0",+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.154.0.tgz",+ "integrity": "sha512-KYOUGQFlLWR+s4QMV2Q9ko38TZm7EdO87Qm7rvZLqk/webse/cDjtyxKhg/47l0byCbs/k46LT8qc4PKjAikzA==",+ "dev": true,+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/oxc-project"+ }+ },"node_modules/@protobufjs/aspromise": {"version": "1.1.2","resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",@@ -6677,6 +6689,286 @@"integrity": "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug==","license": "BSD-3-Clause"},+ "node_modules/@rolldown/binding-android-arm-eabi": {+ "version": "1.2.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.14.tgz",+ "integrity": "sha512-aWR+XKH9+rW7m5fWq/5360J3mHycrx/o6xZM2DQFdJnTMdyP7/WzxPjhtLbVWdKo2y612/4U1bWqb3HQhiF7vg==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.14.tgz",+ "integrity": "sha512-QiVxHofl6A8lQU7WAtOUY4QMVZXohxwz7WJJoeh8NBEUyKfIkMRKhYyq8az/1RypNiIXzNTtiS6KwHz0erxYRQ==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.14.tgz",+ "integrity": "sha512-lTQOzHuBIooh3jIr5XINQkjPGEuGy+Dsy0meXDr6Sjty0b99kYgGh4uBC/8mJX1T0kC8d6S0aPP1Y+bHkh6aBw==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.14.tgz",+ "integrity": "sha512-hyMKEGatjmBYCs/Q4sbIcL/GqpFEqsX3wc+HYVQ/85A4rxc1o7rPm4DUI4GV4k/h0ITddwFSGpqQunI14GXjTA==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.14.tgz",+ "integrity": "sha512-u371GbXoVXrEgP20PwzoGNOdAOqAMhzo19JzzY+V4YmmnC+DTOoqdbMu+O+54emM59Mik/UdrtWgcuEDKWRPKA==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.14.tgz",+ "integrity": "sha512-BqwKsdZQf6EqVWr8fv2MrDYzAvOZ7+NYFSJESRGs87fkseEhs0TU9TXgRJTkZoRRkxTizyEg1LKUXfU3/78uqg==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.14.tgz",+ "integrity": "sha512-SD9kY8M009x/7s57Z1dgUVlP5+uYBgKQK0Tkr1WIWngrtUJmRCW1RJFMY7QDla2khXhmg2i5Io7MUjcmZNZ/KQ==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.14.tgz",+ "integrity": "sha512-BJ2CL19M6uuWesMgnqJzgxoI+N+eV7b0A9O9vLV42y+gitC41fNa8KElau1tHVzuLWX5GzEuxMPhAO0tQXQMkg==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.14.tgz",+ "integrity": "sha512-4+Kl8daPV8NDHaD7mfCcc1pRM+Qg7ab8DyMm5FG5WoZgv4h2i3KFN1CybYBNbQqmuYm7ftJLvmMI1eHYJ22S/Q==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.14.tgz",+ "integrity": "sha512-V/h8ePq1fKDrmtFMz6xcCN3DKvuvMRrwwD1q0PkBeeo4DpK64biaKvqWGVxqCeYKqeRk7gE7/iKPxLCn08O97A==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.14.tgz",+ "integrity": "sha512-WxalXzgrLVpKC93xfpaJ3gCXUWzeCr+FRCbDVD2mUAy4L6Vo3lNVz0epUEUpxPWJkLNYUwM4OSIikv36OJ9mLg==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.14.tgz",+ "integrity": "sha512-3G3tnAmTpdk9jO3GQtyHXqeFD2SlecfTws/Y3M2mmj9nMBwwuLT4kur8sZKeu7ENUHSpVO3cIsm5A52LEWWwlg==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.14.tgz",+ "integrity": "sha512-qyr5XiNGxm2ytx17vvtcJ9nXn6v1gENETi503bJx3OGwZ1tSonj7BosxbMa/xeAfSl5iS9X6KjEWYXLu6v1L7Q==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openharmony"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-win32-arm64-msvc": {+ "version": "1.2.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.14.tgz",+ "integrity": "sha512-oA4o5o0S2yB199YyYXDzKUv1Z56Rc+mgOjwm7Z/vJ9Z8igiDPYvoOuDyo6g7AK/ZaF09nPhDKVnGBcYHO11GXA==",+ "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.14",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.14.tgz",+ "integrity": "sha512-9mE94bf2GZUaR/fUSXCMpBoWkctu421Mi0ORpm4zqfbkjKep7RxzPFa5etcGs5h+2KApoWBOA/hAJa/7saGgEQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/pluginutils": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",+ "dev": true,+ "license": "MIT"+ },"node_modules/@sec-ant/readable-stream": {"version": "0.4.1","resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz",@@ -7509,6 +7801,24 @@],"license": "BSD-3-Clause"},+ "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/fetch-blob": {"version": "3.2.0","resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",@@ -7591,6 +7901,21 @@"node": ">=12.20.0"}},+ "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/gaxios": {"version": "7.3.1","resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.3.1.tgz",@@ -8080,34 +8405,307 @@"@koromix/koffi-win32-x64": "3.1.1"}},- "node_modules/long": {- "version": "5.3.2",- "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",- "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",- "license": "Apache-2.0"- },- "node_modules/lowercase-keys": {- "version": "3.0.0",- "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz",- "integrity": "sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==",- "license": "MIT",+ "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.20.0 || ^14.13.1 || >=16.0.0"+ "node": ">= 12.0.0"},"funding": {- "url": "https://github.com/sponsors/sindresorhus"- }- },- "node_modules/mime-db": {- "version": "1.54.0",- "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",- "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",- "license": "MIT",- "engines": {- "node": ">= 0.6"- }- },- "node_modules/mime-types": {+ "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/long": {+ "version": "5.3.2",+ "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",+ "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",+ "license": "Apache-2.0"+ },+ "node_modules/lowercase-keys": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz",+ "integrity": "sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==",+ "license": "MIT",+ "engines": {+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/mime-db": {+ "version": "1.54.0",+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",+ "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",+ "license": "MIT",+ "engines": {+ "node": ">= 0.6"+ }+ },+ "node_modules/mime-types": {"version": "3.0.2","resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz","integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==",@@ -8141,6 +8739,25 @@"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==","license": "MIT"},+ "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/negotiator": {"version": "1.1.0","resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz",@@ -8613,6 +9230,35 @@"url": "https://opencollective.com/pnpm"}},+ "node_modules/postcss": {+ "version": "8.5.30",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.30.tgz",+ "integrity": "sha512-zkd+e9S1AQHhmaBKye9zlFHWjOwVgqXl1q3ECYy8561K7qxR2cREf/STLskulBFd78k6AOFeA+ff1TtEzk9bAA==",+ "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/powershell-utils": {"version": "0.2.1","resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.2.1.tgz",@@ -8702,6 +9348,29 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/react": {+ "version": "19.3.0",+ "resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz",+ "integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/react-dom": {+ "version": "19.3.0",+ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz",+ "integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "scheduler": "^0.28.0"+ },+ "peerDependencies": {+ "react": "^19.3.0"+ }+ },"node_modules/readdirp": {"version": "4.1.2","resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",@@ -8769,6 +9438,40 @@"node": ">= 4"}},+ "node_modules/rolldown": {+ "version": "1.2.14",+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.14.tgz",+ "integrity": "sha512-eTBTTqMR6uHKLgcUqpJP8ntzDI6V4LYA8negAMBEI7gkgVvOdrx6VsvS2Ym+83KhOPdLCHWJu0w7UQFJZhHKNw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@oxc-project/types": "=0.154.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.14",+ "@rolldown/binding-android-arm64": "1.2.14",+ "@rolldown/binding-darwin-arm64": "1.2.14",+ "@rolldown/binding-darwin-x64": "1.2.14",+ "@rolldown/binding-freebsd-x64": "1.2.14",+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.14",+ "@rolldown/binding-linux-arm64-gnu": "1.2.14",+ "@rolldown/binding-linux-arm64-musl": "1.2.14",+ "@rolldown/binding-linux-ppc64-gnu": "1.2.14",+ "@rolldown/binding-linux-s390x-gnu": "1.2.14",+ "@rolldown/binding-linux-x64-gnu": "1.2.14",+ "@rolldown/binding-linux-x64-musl": "1.2.14",+ "@rolldown/binding-openharmony-arm64": "1.2.14",+ "@rolldown/binding-win32-arm64-msvc": "1.2.14",+ "@rolldown/binding-win32-x64-msvc": "1.2.14"+ }+ },"node_modules/run-applescript": {"version": "7.1.0","resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz",@@ -8813,6 +9516,13 @@"node": ">=v12.22.7"}},+ "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==",+ "dev": true,+ "license": "MIT"+ },"node_modules/semver": {"version": "7.8.5","resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",@@ -8999,6 +9709,16 @@"url": "https://github.com/sponsors/isaacs"}},+ "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/standardwebhooks": {"version": "1.1.1","resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.1.1.tgz",@@ -9065,6 +9785,23 @@"integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==","license": "MIT"},+ "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/ts-algebra": {"version": "2.0.0","resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz",@@ -9164,6 +9901,84 @@"node": ">= 0.8"}},+ "node_modules/vite": {+ "version": "8.3.4",+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.4.tgz",+ "integrity": "sha512-IftLE8phJhdNRIGNEV4JCCvfNScoZQVfcXaN8TQropWGJtOHcu+iAB9pHcuGvmEb/kddw0LBe/jS8ztdC6xdiQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "lightningcss": "^1.33.0",+ "picomatch": "^4.0.7",+ "postcss": "^8.5.29",+ "rolldown": "~1.2.12",+ "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",+ "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/web-streams-polyfill": {"version": "3.3.3","resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",diff --git a/app/package.json b/app/package.jsonindex 30485066..5f03c1c4 100644--- a/app/package.json+++ b/app/package.json@@ -8,7 +8,8 @@"type": "module","main": "src/main.mjs","scripts": {- "start": "electron .",+ "build": "vite build",+ "start": "vite build && electron .","shot": "node scripts/shot.mjs"},"dependencies": {@@ -16,12 +17,14 @@"@deepseek-ai/dsh-app-boot": "0.2.0-rc.2","@deepseek-ai/dsh-base": "0.2.0-rc.2","@deepseek-ai/dsh-web-app": "0.2.0-rc.2",- "@deepseek-ai/dsh-web-frontend": "0.2.0-rc.2","ds-bot": "file:../ds-bot","pnpm": "11.7.0"},"devDependencies": {- "electron": "44.7.0"+ "electron": "44.7.0",+ "react": "19.3.0",+ "react-dom": "19.3.0",+ "vite": "8.3.4"},"overrides": {"@deepseek-ai/cordis": "4.0.4",diff --git a/app/src/host-process.mjs b/app/src/host-process.mjsindex 819462bd..f36afb76 100644--- a/app/src/host-process.mjs+++ b/app/src/host-process.mjs@@ -27,7 +27,7 @@ export class HostProcess {*/constructor(options) { this.#options = options }- /** @returns {Promise<{ url: string, injections: unknown[] }>} the Host's launch URL and index injections */+ /** @returns {Promise<{ url: string }>} the Host's launch URL */start() {this.#ready ??= new Promise((resolve, reject) => {const { entry, cwd, env, pnpm } = this.#options@@ -43,7 +43,7 @@ export class HostProcess {this.#stderr = (this.#stderr + chunk).slice(-STDERR_TAIL_CHARS)})child.on('message', (message) => {- if (message?.type === 'ready') resolve({ url: message.url, injections: message.injections })+ if (message?.type === 'ready') resolve({ url: message.url })else if (message?.type === 'fatal') this.#fail(new Error(message.message), reject)})child.once('error', (error) => { this.#fail(error, reject) })diff --git a/app/src/host.mjs b/app/src/host.mjsindex d51d9770..fa05a941 100644--- a/app/src/host.mjs+++ b/app/src/host.mjs@@ -46,7 +46,7 @@ async function main() {process.once('disconnect', () => { void stop() })const { ctx } = await applicationconst url = ctx.connection.authenticatedUrl(`http://127.0.0.1:${String(ctx.webServer.port)}`)- await send({ type: 'ready', url, injections: ctx.webServer.collectIndexInjections() })+ await send({ type: 'ready', url })}main().catch(async (error) => {diff --git a/app/src/main.mjs b/app/src/main.mjsindex cdfabb5d..fa2b91a4 100644--- a/app/src/main.mjs+++ b/app/src/main.mjs@@ -1,22 +1,20 @@// Electron main process: one window for the Bot team, served by the app's own DSH Host.-// The dsh-app scheme, the request forwarding and the WebSocket header rewrite follow-// DeepSeek Harness apps/desktop/src/main.ts (MIT); see NOTICE.-import { app, BrowserWindow, dialog, ipcMain, Menu, nativeTheme, protocol, session, shell } from 'electron'-import { mkdirSync } from 'node:fs'-import { createRequire } from 'node:module'+// The dsh-app scheme and the request forwarding follow DeepSeek Harness+// apps/desktop/src/main.ts (MIT); see NOTICE.+import { app, BrowserWindow, dialog, Menu, nativeTheme, protocol, shell } from 'electron'+import { existsSync, mkdirSync } from 'node:fs'import { homedir } from 'node:os'import { dirname, join } from 'node:path'import { fileURLToPath } from 'node:url'import { HostProcess } from './host-process.mjs'-import { APP_ORIGIN, authenticateWebHost, forwardWebRequest, serveWebDocument } from './web.mjs'+import { APP_ORIGIN, authenticateWebHost, forwardWebRequest, serveFile } from './web.mjs'// DSH writes dsh-app://app/ into workspace file URLs and Markdown file links, so the window keeps that scheme.const SCHEME = 'dsh-app'-const IPC = { boot: 'ds-bot:boot', bootFailed: 'ds-bot:boot-failed' }-const STATIC_PATHS = new Set(['/', '/index.html', '/manifest.webmanifest'])const here = dirname(fileURLToPath(import.meta.url))-const webDist = join(dirname(createRequire(import.meta.url).resolve('@deepseek-ai/dsh-web-frontend/package.json')), 'dist')+// The window is the app's own build (ui/, `npm run build`); everything under /api/ goes to the Host.+const uiDist = join(here, '..', 'ui', 'dist')const dataDir = process.env.DS_BOT_HOME || join(homedir(), '.ds-bot')if (process.env.DS_BOT_SHELL_DATA) app.setPath('userData', process.env.DS_BOT_SHELL_DATA)@@ -48,6 +46,7 @@ if (!app.requestSingleInstanceLock()) {}function start() {+ if (!existsSync(join(uiDist, 'index.html'))) throw new Error('The window is not built. Run npm run build in app/.')const profileDir = join(dataDir, 'profiles', 'ds-bot')mkdirSync(profileDir, { recursive: true })host = new HostProcess({@@ -63,32 +62,14 @@ function start() {})ready.catch(fail)- protocol.handle(SCHEME, (request) => {+ // The window opens while the Host boots; its first requests wait for the Host.+ protocol.handle(SCHEME, async (request) => {const url = new URL(request.url)if (url.hostname !== 'app') return new Response(null, { status: 404 })- if (STATIC_PATHS.has(url.pathname) || url.pathname.startsWith('/assets/')) return serveWebDocument(request, webDist)- if (hostState === undefined) return new Response(null, { status: 503 })- return forwardWebRequest(request, hostState.url, hostState.cookie)- })-- ipcMain.handle(IPC.boot, async (event) => {- assertWindow(event)- const { url, injections } = await ready- return { injections, streamBaseUrl: new URL(url).origin }- })- ipcMain.handle(IPC.bootFailed, (event, message) => {- assertWindow(event)- fail(new Error(String(message)))- })-- // The stream connects to the Host directly; the Host accepts only its own origin and cookie.- session.defaultSession.webRequest.onBeforeSendHeaders({ urls: ['ws://127.0.0.1/*'] }, (details, callback) => {- if (hostState === undefined || details.webContentsId !== mainWindow?.webContents.id) { callback({}); return }- const target = new URL(hostState.url)- if (new URL(details.url).host !== target.host) { callback({}); return }- const headers = Object.fromEntries(Object.entries(details.requestHeaders).map(([name, value]) => [name.toLowerCase(), value]))- if (headers.origin !== APP_ORIGIN) { callback({ cancel: true }); return }- callback({ requestHeaders: { ...headers, origin: target.origin, cookie: hostState.cookie, 'sec-fetch-site': 'same-origin' } })+ if (!url.pathname.startsWith('/api/')) return serveFile(request, uiDist)+ const target = hostState ?? await ready.catch(() => undefined)+ if (target === undefined) return new Response(null, { status: 503 })+ return forwardWebRequest(request, target.url, target.cookie)})setMenu()@@ -99,8 +80,8 @@ function createWindow() {mainWindow = new BrowserWindow({width: 1320, height: 860, minWidth: 720, minHeight: 480,title: 'DeepSeek Bot', show: false,- backgroundColor: nativeTheme.shouldUseDarkColors ? '#1b1b1c' : '#ffffff',- webPreferences: { preload: join(here, 'preload.cjs'), contextIsolation: true, sandbox: true },+ backgroundColor: nativeTheme.shouldUseDarkColors ? '#141414' : '#fcfcfc',+ webPreferences: { contextIsolation: true, sandbox: true },})mainWindow.once('ready-to-show', () => { mainWindow?.show() })mainWindow.on('page-title-updated', (event) => { event.preventDefault() })@@ -132,12 +113,6 @@ function focusWindow() {mainWindow.focus()}-function assertWindow(event) {- const contents = mainWindow?.webContents- if (contents === undefined || event.sender !== contents || event.senderFrame !== contents.mainFrame- || !event.senderFrame.url.startsWith(`${APP_ORIGIN}/`)) throw new Error('DeepSeek Bot: rejected IPC from an unknown page')-}-function openOutside(url) {if (/^https?:\/\//iu.test(url)) void shell.openExternal(url)}diff --git a/app/src/web.mjs b/app/src/web.mjsindex 24b77b4c..b2c0a375 100644--- a/app/src/web.mjs+++ b/app/src/web.mjs@@ -1,5 +1,6 @@-// The local Web document and the authenticated request forwarding for the app window.-// Adapted from DeepSeek Harness apps/desktop/src/web-document.ts (MIT); see NOTICE.+// The window's files and the authenticated request forwarding to the Host.+// The launch-token exchange and the forwarding adapt DeepSeek Harness+// apps/desktop/src/web-document.ts (MIT); see NOTICE.import { readFile } from 'node:fs/promises'import { extname, resolve, sep } from 'node:path'@@ -10,16 +11,14 @@ const MIME = {'.css': 'text/css; charset=utf-8', '.svg': 'image/svg+xml', '.json': 'application/json','.woff2': 'font/woff2', '.png': 'image/png', '.ico': 'image/x-icon',}-// The Web entry waits on this gate until the shell hands over the Host's index injections.-const BOOT = '<script>globalThis.__DSH_BOOT_READY__ = Promise.withResolvers()</script>'/**- * Serve a file of the DSH Web build; the index gets the boot gate.+ * Serve a file of the window's build.* @param {Request} request - request from the app origin- * @param {string} root - the Web build's `dist` directory+ * @param {string} root - the build's directory* @returns {Promise<Response>}*/-export async function serveWebDocument(request, root) {+export async function serveFile(request, root) {if (!['GET', 'HEAD'].includes(request.method)) return new Response(null, { status: 405 })const url = new URL(request.url)let pathname@@ -28,12 +27,10 @@ export async function serveWebDocument(request, root) {if (!target.startsWith(resolve(root) + sep)) return new Response(null, { status: 403 })let bodytry { body = await readFile(target) } catch (error) {- if (error.code === 'ENOENT') return new Response(null, { status: 404 })+ if (error.code === 'ENOENT' || error.code === 'EISDIR') return new Response(null, { status: 404 })throw error}- const content = pathname === '/' || pathname === '/index.html'- ? body.toString().replace('<head>', '<head>' + BOOT) : new Uint8Array(body)- return new Response(request.method === 'HEAD' ? null : content, {+ return new Response(request.method === 'HEAD' ? null : new Uint8Array(body), {headers: { 'content-type': MIME[extname(target)] ?? 'application/octet-stream' },})}@@ -59,11 +56,10 @@ const WITHHELD_RESPONSE_HEADERS = ['content-encoding', 'content-length','transfer-encoding', 'connection', 'keep-alive', 'te', 'trailer', 'upgrade', 'proxy-authenticate', 'proxy-authorization',]-// The Host marks plugin bundles immutable under a revision that changes every launch.-const PLUGIN_BUNDLE_PATH = /^\/plugins\//u/*** Forward a request from the app origin to the Host as a same-origin request with the Host cookie.+ * The response streams through, so the live feed arrives as it is written.* @param {Request} request - request from the app origin* @param {string} host - Host URL* @param {string} cookie - Host cookie pair@@ -84,6 +80,5 @@ export async function forwardWebRequest(request, host, cookie) {})const outgoing = new Headers(response.headers)for (const name of WITHHELD_RESPONSE_HEADERS) outgoing.delete(name)- if (PLUGIN_BUNDLE_PATH.test(source.pathname)) outgoing.set('cache-control', 'no-store')return new Response(response.body, { status: response.status, headers: outgoing })}diff --git a/app/ui/index.html b/app/ui/index.htmlnew file mode 100644index 00000000..add4e574--- /dev/null+++ b/app/ui/index.html@@ -0,0 +1,13 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; connect-src 'self'">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>DeepSeek Bot</title>+</head>+<body>+<div id="root"></div>+<script type="module" src="./src/main.js"></script>+</body>+</html>diff --git a/app/ui/src/api.js b/app/ui/src/api.jsnew file mode 100644index 00000000..eb750c9f--- /dev/null+++ b/app/ui/src/api.js@@ -0,0 +1,74 @@+// The window talks only to ds-bot's own channel in the engine: POST api/bot for reads and+// actions, and the live feed api/bot/feed for what changes.+import { hostText, t } from '../../../ds-bot/src/client/i18n.js'++export async function call(endpoint, payload) {+ let response+ try {+ response = await fetch('api/bot', {+ method: 'POST',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ endpoint, payload: payload ?? null }),+ })+ } catch (error) {+ throw Object.assign(new Error(t('Could not reach DSH. Check that it is still running.')), { code: 'NETWORK', cause: error })+ }+ if (!response.ok) throw Object.assign(new Error(`HTTP ${response.status}`), { code: `HTTP_${response.status}` })+ const result = await response.json()+ if (!result.ok) throw Object.assign(new Error(hostText(result.error?.message ?? 'Request failed')), { code: result.error?.code ?? 'bot/error' })+ return result.value+}++const RETRY_MS = [500, 1000, 2000, 5000]++function parseEvent(block) {+ let event = 'message'+ const data = []+ for (const line of block.split('\n')) {+ if (line.startsWith('event: ')) event = line.slice(7)+ else if (line.startsWith('data: ')) data.push(line.slice(6))+ }+ if (data.length === 0) return undefined+ try { return { event, data: JSON.parse(data.join('\n')) } } catch { return undefined }+}++// Read over fetch: EventSource does not load from the window's own scheme. After a+// break the feed reconnects, and its first event (`hello`) tells the window to catch up.+export function openFeed(onEvent) {+ let stopped = false+ let controller+ const run = async () => {+ for (let failures = 0; !stopped;) {+ controller = new AbortController()+ try {+ const response = await fetch('api/bot/feed', { signal: controller.signal, cache: 'no-store' })+ if (!response.ok || response.body === null) throw new Error(`HTTP ${response.status}`)+ failures = 0+ const reader = response.body.getReader()+ const decoder = new TextDecoder()+ let buffer = ''+ for (;;) {+ const { value, done } = await reader.read()+ if (done) break+ buffer += decoder.decode(value, { stream: true })+ for (let end = buffer.indexOf('\n\n'); end >= 0; end = buffer.indexOf('\n\n')) {+ const parsed = parseEvent(buffer.slice(0, end))+ buffer = buffer.slice(end + 2)+ if (parsed !== undefined) onEvent(parsed.event, parsed.data)+ }+ }+ } catch {+ // The engine restarted or the window is going away; the loop decides.+ }+ if (stopped) return+ onEvent('lost', {})+ await new Promise(resolve => setTimeout(resolve, RETRY_MS[Math.min(failures, RETRY_MS.length - 1)]))+ failures += 1+ }+ }+ void run()+ return () => {+ stopped = true+ controller?.abort()+ }+}diff --git a/app/ui/src/app.css b/app/ui/src/app.cssnew file mode 100644index 00000000..bc7e3ecc--- /dev/null+++ b/app/ui/src/app.css@@ -0,0 +1,82 @@+/* Colors come from the plugin's --bt-* variables (themes.js and MARK_CSS); sizes follow+ the plugin's sidebar and chat. */+*,*::before,*::after{box-sizing:border-box}+html,body,#root{height:100%;margin:0}+body{color-scheme:light}+body[data-ds-dark-theme]{color-scheme:dark}+::-webkit-scrollbar{width:12px;height:12px}+::-webkit-scrollbar-thumb{border:3px solid transparent;border-radius:12px;background:var(--bt-line-2) content-box}+::-webkit-scrollbar-thumb:hover{background-color:var(--bt-ink-3)}+::-webkit-scrollbar-track,::-webkit-scrollbar-corner{background:transparent}+body{background:var(--bt-main);color:var(--bt-ink);font:14px/20px -apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,"PingFang SC","Microsoft YaHei",sans-serif;-webkit-font-smoothing:antialiased}+button,textarea{font:inherit;color:inherit}+:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px}++.app{display:grid;grid-template-columns:280px minmax(0,1fr);height:100%}+.app-blank{height:100%;display:grid;place-items:center;color:var(--bt-ink-3)}+.app-error{color:var(--bt-danger);max-width:480px;text-align:center}+.app-main{position:relative;display:flex;min-width:0;min-height:0}+.app-toast{position:absolute;left:50%;bottom:84px;translate:-50% 0;max-width:min(480px,90%);padding:6px 12px;border-radius:10px;background:var(--bt-card);border:.5px solid var(--bt-line-2);color:var(--bt-danger);font-size:12px;line-height:16px}++.side{display:flex;flex-direction:column;gap:4px;min-height:0;padding:8px;background:var(--bt-sidebar)}+.side-top{display:flex;align-items:center;height:40px;padding:0 8px;flex:none}+.side-brand{font-size:15px;line-height:20px;font-weight:600;letter-spacing:-.01em}+.side-list{display:flex;flex-direction:column;gap:3px;min-height:0;overflow-y:auto}+.side-row{position:relative;display:flex;align-items:center;gap:8px;width:100%;min-height:54px;padding:8px;border:0;border-radius:10px;background:transparent;text-align:left;cursor:pointer;transition:background-color .12s ease}+.side-row:hover{background:var(--bt-hover)}+.side-row[aria-current=page]{background:var(--bt-active)}+.side-text{display:flex;flex-direction:column;min-width:0}+.side-name,.side-role{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}+.side-name{font-size:14px;line-height:20px}+.side-role{font-size:12px;line-height:16px;color:var(--bt-ink-2)}++.chat{flex:1;display:flex;flex-direction:column;min-width:0;min-height:0}+.chat-head{display:flex;align-items:center;gap:8px;flex:none;height:52px;padding:0 16px;border-bottom:1px solid var(--bt-line)}+.chat-title{font-size:15px;line-height:20px;font-weight:600}+.chat-role{font-size:12px;line-height:16px;color:var(--bt-ink-2)}+.chat-scroll{flex:1;min-height:0;overflow-y:auto}+.chat-column{display:flex;flex-direction:column;max-width:992px;margin:0 auto;padding:8px 16px 16px}+.chat-top{display:flex;justify-content:center;min-height:28px;padding:4px 0}+.chat-soft{padding:4px 12px;border:0;border-radius:999px;background:var(--bt-hover);color:var(--bt-ink-2);font-size:12px;line-height:16px;cursor:pointer}+.chat-muted{color:var(--bt-ink-2);font-size:12px;line-height:16px}++.chat-row{display:flex;padding-block:2px}+.chat-row:not([data-prev]){margin-top:10px}+.chat-user{justify-content:flex-end}+.chat-bubble{max-width:min(80%,560px,calc(100% - 82px));padding:7px 12px;border-radius:18px;white-space:pre-wrap;overflow-wrap:anywhere}+.chat-bot .chat-bubble{background:var(--bt-bubble)}+.chat-user .chat-bubble{background:var(--bt-user);color:var(--bt-user-ink)}+.chat-bot[data-prev] .chat-bubble{border-top-left-radius:6px}+.chat-bot[data-next] .chat-bubble{border-bottom-left-radius:6px}+.chat-user[data-prev] .chat-bubble{border-top-right-radius:6px}+.chat-user[data-next] .chat-bubble{border-bottom-right-radius:6px}+.chat-row[data-pending] .chat-bubble{opacity:.55}+.chat-note{display:block;font-size:12px;line-height:16px;opacity:.7}+.chat-event{align-self:center;margin:10px 0 4px;color:var(--bt-ink-3);font-size:12px;line-height:16px}+.chat-divider{display:flex;align-items:center;gap:8px;margin:14px 0 6px;color:var(--bt-ink-3);font-size:12px;line-height:16px}+.chat-divider::before,.chat-divider::after{content:'';flex:1;height:1px;background:var(--bt-line)}+.chat-typing{display:inline-flex;align-items:center;gap:4px;height:34px}+.chat-typing i{width:6px;height:6px;border-radius:50%;background:var(--bt-ink-3);animation:chat-dot 1.2s ease-in-out infinite}+.chat-typing i:nth-child(2){animation-delay:.15s}+.chat-typing i:nth-child(3){animation-delay:.3s}+@keyframes chat-dot{0%,60%,100%{opacity:.35;transform:none}30%{opacity:1;transform:translateY(-2px)}}+@media (prefers-reduced-motion:reduce){.chat-typing i{animation:none}}++.chat-card{display:flex;flex-direction:column;gap:10px;max-width:560px;margin:12px 0 4px;padding:14px 16px;border:1px solid var(--bt-line);border-radius:14px;background:var(--bt-card)}+.chat-card p{margin:0}+.chat-question{font-weight:600}+.chat-choices{display:flex;flex-direction:column;gap:6px}+.chat-choice{display:flex;flex-direction:column;align-items:flex-start;gap:2px;padding:8px 12px;border:1px solid var(--bt-line);border-radius:10px;background:transparent;text-align:left;cursor:pointer;transition:background-color .12s ease}+.chat-choice:hover:not(:disabled){background:var(--bt-hover)}+.chat-choice:disabled{opacity:.6;cursor:default}+.chat-error{margin:0 0 6px;color:var(--bt-danger);font-size:12px;line-height:16px}++.composer-wrap{flex:none;width:100%;max-width:992px;margin:0 auto;padding:8px 16px 16px}+.composer{display:flex;align-items:flex-end;gap:8px;min-height:44px;padding:8px 8px 8px 16px;border:.5px solid var(--bt-line-2);border-radius:22px;background:var(--bt-card);box-shadow:0 2px 8px -1px color-mix(in srgb,var(--bt-ink) 6%,transparent),0 1px 2px color-mix(in srgb,var(--bt-ink) 4%,transparent);transition:border-color .15s ease,border-radius .3s ease}+.composer:focus-within{border-color:color-mix(in srgb,var(--bt-ink) 30%,transparent)}+.composer[data-multiline]{border-radius:18px}+.composer textarea{flex:1;min-height:28px;max-height:120px;padding:4px 0;border:0;outline:0;background:transparent;line-height:20px;resize:none}+.composer textarea::placeholder{color:var(--bt-ink-3)}+.composer textarea:disabled{cursor:not-allowed}+.composer-send{display:grid;place-items:center;flex:none;width:28px;height:28px;padding:0;border:0;border-radius:50%;background:var(--bt-user);color:var(--bt-user-ink);cursor:pointer;transition:opacity .12s ease}+.composer-send:disabled{opacity:.3;cursor:default}diff --git a/app/ui/src/app.js b/app/ui/src/app.jsnew file mode 100644index 00000000..c9796814--- /dev/null+++ b/app/ui/src/app.js@@ -0,0 +1,101 @@+import { createElement as h, useCallback, useEffect, useMemo, useRef, useState } from 'react'+import { t } from '../../../ds-bot/src/client/i18n.js'+import { allThemes, themeCss } from '../../../ds-bot/src/client/themes.js'+import { call, openFeed } from './api.js'+import { Chat } from './chat.js'+import { Sidebar } from './sidebar.js'++const LIVE_KEYS = ['activity', 'work', 'memoryNews', 'memoryReviews', 'connectors', 'capabilityStatuses']+// Some live facts (memory news, connector status) change without a feed notice.+const CATCH_UP_MS = 15_000++// The team as the `state` endpoint gives it: `view` changes with a new revision, `live`+// with every answer. Requests do not overlap; one asked for while another runs follows it.+function useTeam() {+ const [team, setTeam] = useState({ view: null, live: {}, error: null })+ const known = useRef({ since: undefined, models: undefined })+ const running = useRef(false)+ const again = useRef(false)+ const refresh = useCallback(async () => {+ if (running.current) { again.current = true; return }+ running.current = true+ do {+ again.current = false+ try {+ const value = await call('state', { since: known.current.since, models: known.current.models, locale: navigator.language })+ const live = Object.fromEntries(LIVE_KEYS.map(key => [key, value[key]]))+ if (value.unchanged) setTeam(current => ({ ...current, live, error: null }))+ else {+ known.current = { since: value.revision, models: value.modelsKey }+ setTeam({ view: value, live, error: null })+ }+ } catch (error) {+ setTeam(current => ({ ...current, error }))+ }+ } while (again.current)+ running.current = false+ }, [])+ return [team, refresh]+}++// Feed events for the open chat.+function createBus() {+ const listeners = new Set()+ return {+ on(listener) {+ listeners.add(listener)+ return () => { listeners.delete(listener) }+ },+ emit(event, data) { for (const listener of listeners) listener(event, data) },+ }+}++// The team's theme and accent, as the plugin paints them.+function useTheme(prefs) {+ useEffect(() => {+ const theme = allThemes()[prefs?.theme] ?? allThemes().deepseek+ const style = document.createElement('style')+ style.textContent = themeCss(theme, prefs?.accent)+ document.head.append(style)+ if (prefs?.motion) document.body.dataset.btMotion = prefs.motion+ else delete document.body.dataset.btMotion+ return () => { style.remove() }+ }, [prefs?.theme, prefs?.accent, prefs?.motion])+}++export function App() {+ const [team, refresh] = useTeam()+ const bus = useMemo(createBus, [])+ const [selected, setSelected] = useState(null)+ const view = team.view+ useTheme(view?.prefs)++ useEffect(() => {+ void refresh()+ const close = openFeed((event, data) => {+ if (event === 'hello' || event === 'revision' || event === 'live') void refresh()+ bus.emit(event, data)+ })+ const timer = setInterval(() => { void refresh() }, CATCH_UP_MS)+ return () => {+ close()+ clearInterval(timer)+ }+ }, [refresh, bus])++ const bots = useMemo(() => {+ const list = view?.bots ?? []+ const mains = view?.mainBotIds ?? []+ return [...list].sort((a, b) => (mains.includes(b.id) - mains.includes(a.id)) || (a.createdAt ?? 0) - (b.createdAt ?? 0))+ }, [view])+ const current = bots.find(bot => bot.id === selected) ?? bots.find(bot => bot.id === view?.mainBotId) ?? bots[0]++ if (view === null) {+ return h('div', { className: 'app-blank' }, team.error ? h('p', { className: 'app-error' }, team.error.message) : h('p', { className: 'app-wait' }, t('Loading…')))+ }+ return h('div', { className: 'app' },+ h(Sidebar, { bots, mainBotIds: view.mainBotIds ?? [], live: team.live, questions: view.questions ?? {}, current: current?.id, onOpen: setSelected }),+ h('main', { className: 'app-main' },+ current ? h(Chat, { key: current.id, bot: current, team: view, live: team.live, bus }) : null,+ team.error ? h('div', { className: 'app-toast', role: 'alert' }, team.error.message) : null))+}diff --git a/app/ui/src/chat.js b/app/ui/src/chat.jsnew file mode 100644index 00000000..8e52f084--- /dev/null+++ b/app/ui/src/chat.js@@ -0,0 +1,239 @@+import { createElement as h, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'+import { dateLocale, t } from '../../../ds-bot/src/client/i18n.js'+import { ArrowUpIcon } from '../../../ds-bot/src/client/icons.js'+import { BotAvatar } from '../../../ds-bot/src/client/mark.js'+import { call } from './api.js'+import { stateOf } from './sidebar.js'++// The chat follows its end while the user is this close to it.+const FOLLOW_PX = 80+const sameItem = (a, b) => a.kind === b.kind && a.time === b.time && a.text === b.text++// A Bot's own chat: pages from the `chat` endpoint, new entries and the reply being+// written from the feed. Entries that arrive while the first page loads wait for it.+function useChat(bot, bus) {+ const [view, setView] = useState({ sessionId: null, items: [], cursor: null, loading: true, failed: false })+ const [stream, setStream] = useState(null)+ const [pending, setPending] = useState([])+ const ready = useRef(false)+ const early = useRef([])+ const busy = useRef(false)+ const keep = useRef(null)++ const load = useCallback(async (cursor, scroller) => {+ if (busy.current) return+ busy.current = true+ if (cursor === undefined) ready.current = false+ setView(current => ({ ...current, loading: true, failed: false }))+ try {+ const page = await call('chat', { botId: bot.id, ...(cursor ? { cursor } : {}) })+ if (cursor === undefined) {+ const later = early.current.filter(entry => entry.sessionId === page.sessionId && !page.items.some(item => sameItem(item, entry.item)))+ early.current = []+ ready.current = true+ setView({ sessionId: page.sessionId, items: [...page.items, ...later.map(entry => entry.item)], cursor: page.cursor, loading: false, failed: false })+ } else {+ // Content added above the viewport would push the view down; keep its distance from the end.+ if (scroller) keep.current = scroller.scrollHeight - scroller.scrollTop+ setView(current => ({ ...current, items: [...page.items, ...current.items], cursor: page.cursor, loading: false }))+ }+ } catch {+ ready.current = cursor !== undefined || ready.current+ setView(current => ({ ...current, loading: false, failed: true }))+ } finally {+ busy.current = false+ }+ }, [bot.id])++ // A new part (bot.sessionId) starts the chat over.+ useEffect(() => { void load(undefined) }, [load, bot.sessionId])++ useEffect(() => bus.on((event, data) => {+ // The feed came back after a break: entries may have been missed.+ if (event === 'hello') { if (ready.current) void load(undefined); return }+ if (data?.botId !== bot.id) return+ if (event === 'message') {+ if (!ready.current) { early.current.push(data); return }+ setView(current => (data.sessionId !== current.sessionId || current.items.some(item => sameItem(item, data.item)) ? current : { ...current, items: [...current.items, data.item] }))+ if (data.item.kind === 'user') {+ setPending((list) => {+ const at = list.findIndex(entry => entry.text === data.item.text)+ return at < 0 ? list : [...list.slice(0, at), ...list.slice(at + 1)]+ })+ }+ if (data.item.kind === 'bot') setStream(null)+ } else if (event === 'stream') {+ if (data.phase === 'start') setStream({ attemptId: data.attemptId, text: '' })+ else if (data.phase === 'end') setStream(current => (current?.attemptId === data.attemptId ? null : current))+ else setStream(current => (current?.attemptId === data.attemptId ? { ...current, text: current.text + data.text } : current))+ }+ }), [bus, bot.id, load])++ const send = async (text) => {+ await call('send', { sessionId: bot.id, text })+ setPending(list => [...list, { text, time: Date.now() }])+ }+ return { view, stream, pending, load, send, keep }+}++const timeText = time => (Number.isFinite(time) ? new Date(time).toLocaleString(dateLocale(), { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }) : '')++function answerText(item) {+ return (item.answers ?? []).map(answer => [...(answer.selected ?? []), ...(answer.custom ? [answer.custom] : [])].join(', ')).filter(Boolean).join('\n')+}++function EventLine({ item, team }) {+ if (item.role === 'report') return h('div', { className: 'chat-event' }, `${t('Replies from')} ${team.rooms?.find(room => room.id === item.roomId)?.name ?? t('a group chat')}`)+ const other = team.bots.find(bot => bot.id === item.botId)+ const prefix = { stopped: t('Stopped by'), reply: t('Reply from') }[item.role] ?? t('Message from')+ return h('div', { className: 'chat-event' }, `${prefix} ${other?.name ?? item.name ?? t('a Bot')}`)+}++// Consecutive bubbles from one side share their inner corners.+function Rows({ items, team }) {+ return items.map((item, index) => {+ const key = `${index}:${item.kind}:${item.time ?? ''}`+ if (item.kind === 'divider') return h('div', { key, className: 'chat-divider' }, h('span', null, timeText(item.time)))+ if (item.kind === 'event') return h(EventLine, { key, item, team })+ const side = item.kind === 'bot' ? 'bot' : 'user'+ const sideOf = other => (other?.kind === 'bot' ? 'bot' : other?.kind === 'user' || other?.kind === 'answer' || other?.pending ? 'user' : null)+ const text = item.kind === 'answer' ? answerText(item) : item.text+ return h('div', {+ key,+ className: `chat-row chat-${side}`,+ 'data-prev': sideOf(items[index - 1]) === side || undefined,+ 'data-next': sideOf(items[index + 1]) === side || undefined,+ 'data-pending': item.pending || undefined,+ },+ h('div', { className: 'chat-bubble' }, text,+ item.images ? h('span', { className: 'chat-note' }, item.images === 1 ? t('1 image') : t('{count} images', { count: item.images })) : null))+ })+}++function ModelChoice({ bot, models }) {+ const [busy, setBusy] = useState(null)+ const [error, setError] = useState(null)+ const pick = async (ref) => {+ setBusy(ref)+ setError(null)+ try { await call('update-bot', { id: bot.id, model: ref }) } catch (failure) { setError(failure.message); setBusy(null) }+ }+ return h('div', { className: 'chat-card' },+ h('p', null, t("Hi, I'm {name}. Pick a model for me first. You can change it later in my details.", { name: bot.name })),+ models.length === 0+ ? h('p', { className: 'chat-muted' }, t("Add a provider and a model in DeepSeek Harness first, or pick one in the Bot's chat later."))+ : h('div', { className: 'chat-choices' }, models.map(model => h('button', {+ key: model.ref, type: 'button', className: 'chat-choice', disabled: busy !== null, 'aria-busy': busy === model.ref || undefined, onClick: () => pick(model.ref),+ }, h('span', null, model.name ?? model.ref), model.providerName ? h('span', { className: 'chat-muted' }, model.providerName) : null))),+ error ? h('p', { className: 'chat-error', role: 'alert' }, error) : null)+}++function QuestionCard({ bot, question }) {+ const [busy, setBusy] = useState(false)+ const [error, setError] = useState(null)+ const answer = async (label) => {+ setBusy(true)+ setError(null)+ try { await call('answer-question', { sessionId: bot.id, questionId: question.id, answer: { selected: [label], custom: '' } }) } catch (failure) { setError(failure.message) } finally { setBusy(false) }+ }+ return h('div', { className: 'chat-card' },+ h('p', { className: 'chat-question' }, question.question),+ question.detail ? h('p', { className: 'chat-muted' }, question.detail) : null,+ h('div', { className: 'chat-choices' }, (question.options ?? []).map(option => h('button', {+ key: option.label, type: 'button', className: 'chat-choice', disabled: busy, onClick: () => answer(option.label),+ }, h('span', null, option.label), option.description ? h('span', { className: 'chat-muted' }, option.description) : null))),+ error ? h('p', { className: 'chat-error', role: 'alert' }, error) : null)+}++function Composer({ bot, disabled, placeholder, onSend }) {+ const [text, setText] = useState('')+ const [error, setError] = useState(null)+ const [sending, setSending] = useState(false)+ const field = useRef(null)+ useLayoutEffect(() => {+ const node = field.current+ if (!node) return+ node.style.height = 'auto'+ node.style.height = `${Math.min(node.scrollHeight, 120)}px`+ }, [text])+ useEffect(() => { if (!disabled) field.current?.focus() }, [bot.id, disabled])+ const submit = async () => {+ const value = text.trim()+ if (value === '' || sending || disabled) return+ setSending(true)+ setError(null)+ try {+ await onSend(value)+ setText('')+ } catch (failure) {+ setError(failure.message)+ } finally {+ setSending(false)+ }+ }+ return h('div', { className: 'composer-wrap' },+ error ? h('p', { className: 'chat-error', role: 'alert' }, error) : null,+ h('form', { className: 'composer', 'data-multiline': text.includes('\n') || undefined, onSubmit: (event) => { event.preventDefault(); void submit() } },+ h('textarea', {+ ref: field,+ rows: 1,+ value: text,+ disabled,+ placeholder,+ 'aria-label': placeholder,+ onChange: event => setText(event.target.value),+ onKeyDown: (event) => {+ if (event.key === 'Enter' && !event.shiftKey && !event.nativeEvent.isComposing) {+ event.preventDefault()+ void submit()+ }+ },+ }),+ h('button', { type: 'submit', className: 'composer-send', disabled: disabled || sending || text.trim() === '', 'aria-label': t('Send message') }, h(ArrowUpIcon))))+}++export function Chat({ bot, team, live, bus }) {+ const { view, stream, pending, load, send, keep } = useChat(bot, bus)+ const scroller = useRef(null)+ const follow = useRef(true)+ const question = team.questions?.[bot.sessionId]+ const working = live.work?.bots?.[bot.id] !== undefined+ const items = [...view.items, ...pending.map(entry => ({ kind: 'user', text: entry.text, time: entry.time, pending: true }))]++ useLayoutEffect(() => {+ const node = scroller.current+ if (!node) return+ if (keep.current !== null) {+ node.scrollTop = node.scrollHeight - keep.current+ keep.current = null+ } else if (follow.current) node.scrollTop = node.scrollHeight+ }, [view.items, stream, pending, working, question])++ const onScroll = () => {+ const node = scroller.current+ follow.current = node.scrollHeight - node.scrollTop - node.clientHeight < FOLLOW_PX+ }++ return h('section', { className: 'chat', 'aria-label': bot.name },+ h('header', { className: 'chat-head' },+ h(BotAvatar, { bot, size: 28, state: stateOf(bot, live, team.questions ?? {}), main: (team.mainBotIds ?? []).includes(bot.id), badge: false }),+ h('span', { className: 'chat-title' }, bot.name),+ bot.role ? h('span', { className: 'chat-role' }, bot.role) : null),+ h('div', { ref: scroller, className: 'chat-scroll', onScroll },+ h('div', { className: 'chat-column', role: 'feed', 'aria-busy': view.loading },+ h('div', { className: 'chat-top' },+ view.loading ? h('span', { className: 'chat-muted' }, t('Loading earlier messages…'))+ : view.failed ? h('button', { type: 'button', className: 'chat-soft', onClick: () => load(view.cursor ?? undefined, scroller.current) }, t('Couldn’t load earlier messages · Retry'))+ : view.cursor ? h('button', { type: 'button', className: 'chat-soft', onClick: () => load(view.cursor, scroller.current) }, t('Load earlier')) : null),+ h(Rows, { items, team }),+ stream?.text ? h('div', { className: 'chat-row chat-bot' }, h('div', { className: 'chat-bubble' }, stream.text)) : null,+ working && !stream?.text ? h('div', { className: 'chat-row chat-bot' }, h('div', { className: 'chat-bubble chat-typing', 'aria-label': t('Working') }, h('i'), h('i'), h('i'))) : null,+ bot.waiting ? h(ModelChoice, { bot, models: team.models ?? [] }) : null,+ question ? h(QuestionCard, { bot, question }) : null)),+ h(Composer, {+ bot,+ disabled: bot.waiting === true,+ placeholder: bot.waiting ? t('Pick a model and {name} can start.', { name: bot.name }) : t('Message {name}', { name: bot.name }),+ onSend: send,+ }))+}diff --git a/app/ui/src/locale.js b/app/ui/src/locale.jsnew file mode 100644index 00000000..1683e5bf--- /dev/null+++ b/app/ui/src/locale.js@@ -0,0 +1,19 @@+// The part of DSH's locale service that the plugin's copy (ds-bot/src/client/i18n.js)+// uses: it registers its dictionary and translates through a bound namespace.+const fill = (text, params) => (params+ ? text.replace(/\{(\w+)\}/g, (match, name) => (name in params ? String(params[name]) : match))+ : text)++export function createLocale(tag) {+ const active = /^zh\b/i.test(tag) ? 'zh' : 'en'+ const dictionaries = new Map()+ return {+ getLocale: () => ({ active }),+ register(namespace, language, dictionary) {+ const key = `${namespace}:${language}`+ dictionaries.set(key, dictionary)+ return () => { dictionaries.delete(key) }+ },+ bind: namespace => (key, params) => fill(dictionaries.get(`${namespace}:${active}`)?.[key] ?? key, params),+ }+}diff --git a/app/ui/src/main.js b/app/ui/src/main.jsnew file mode 100644index 00000000..27a4595b--- /dev/null+++ b/app/ui/src/main.js@@ -0,0 +1,23 @@+import { createElement as h } from 'react'+import { createRoot } from 'react-dom/client'+import { installLocale } from '../../../ds-bot/src/client/i18n.js'+import { MARK_CSS } from '../../../ds-bot/src/client/styles.js'+import { createLocale } from './locale.js'+import { App } from './app.js'+import './app.css'++installLocale(createLocale(navigator.language))+document.documentElement.lang = navigator.language++const marks = document.createElement('style')+marks.textContent = MARK_CSS+document.head.append(marks)++// The plugin's colors switch on body[data-ds-dark-theme], which DSH sets; here the system's+// light or dark mode sets it.+const dark = matchMedia('(prefers-color-scheme: dark)')+const paint = () => { document.body.toggleAttribute('data-ds-dark-theme', dark.matches) }+paint()+dark.addEventListener('change', paint)++createRoot(document.getElementById('root')).render(h(App))diff --git a/app/ui/src/sidebar.js b/app/ui/src/sidebar.jsnew file mode 100644index 00000000..18e2e355--- /dev/null+++ b/app/ui/src/sidebar.js@@ -0,0 +1,30 @@+import { createElement as h } from 'react'+import { t } from '../../../ds-bot/src/client/i18n.js'+import { BotAvatar, botState } from '../../../ds-bot/src/client/mark.js'++export function stateOf(bot, live, questions) {+ return botState(live.work?.bots?.[bot.id] !== undefined, live.activity?.[bot.id], questions[bot.sessionId] !== undefined)+}++// `bt-row` lets the plugin's mark styles pet the avatar under the pointer.+function BotRow({ bot, main, state, current, onOpen }) {+ return h('button', { type: 'button', className: 'side-row bt-row', 'aria-current': current ? 'page' : undefined, onClick: () => onOpen(bot.id) },+ h(BotAvatar, { bot, size: 36, state, main }),+ h('span', { className: 'side-text' },+ h('span', { className: 'side-name' }, bot.name),+ bot.role ? h('span', { className: 'side-role' }, bot.role) : null))+}++export function Sidebar({ bots, mainBotIds, live, questions, current, onOpen }) {+ return h('aside', { className: 'side' },+ h('div', { className: 'side-top' }, h('span', { className: 'side-brand' }, 'DS Bot')),+ h('nav', { className: 'side-list', 'aria-label': t('Bots') },+ bots.map(bot => h(BotRow, {+ key: bot.id,+ bot,+ main: mainBotIds.includes(bot.id),+ state: stateOf(bot, live, questions),+ current: bot.id === current,+ onOpen,+ }))))+}diff --git a/app/vite.config.js b/app/vite.config.jsnew file mode 100644index 00000000..432deca0--- /dev/null+++ b/app/vite.config.js@@ -0,0 +1,12 @@+import { fileURLToPath } from 'node:url'+import { defineConfig } from 'vite'++// The window loads the build from the app's own scheme, so asset paths stay relative.+export default defineConfig({+ root: fileURLToPath(new URL('./ui', import.meta.url)),+ base: './',+ // The marks, themes and copy come from the plugin's interface code in ../ds-bot, which+ // has no React of its own.+ resolve: { dedupe: ['react', 'react-dom'] },+ build: { outDir: 'dist', emptyOutDir: true },+})